Create default widget for vtiger
September 05, 2013
Create default widget for vtigerYou change happen in following files
modules/Users/Users.php modules/Users/language/en_us.lang.php modules/Home/language/en_us.lang.php include/Home.phpStep 1
want to see your widget in your home page you follow this step.
Add your widget identifier to $homeorder_array in Users.php search "$homeorder_array"
I added 'SOLD'
var $homeorder_array = array('HDB','ALVT','PLVT','QLTQ','CVLVT','HLT','OLV','GRT','OLTSO','ILTI','MNL','OLTPO','LTFAQ', 'UA', 'PA', 'SOLD'); Do the same in the function getHomeStuffOrder($id) function $this->homeorder_array = array('UA', 'PA', 'ALVT','HDB','PLVT','QLTQ','CVLVT','HLT','GRT','OLTSO','ILTI','MNL','OLTPO','LTFAQ','SOLD'); The above will allow vtiger to pull the widget into your myprefrecnes view so you can select to make visible
Step 2: Adding language file to how you look like add line in these files modules/Users/language/en_us.lang.php modules/Home/language/en_us.lang.php search using "Home page order" and add like this
Step 3:'SOLD'=>'Partially Completed Lead',
These queries are in Users.php They will add your widget to the DB when a user is created. Remeber you will need to create a new user for this to take affect, because that is when the module info will be inserted into the DB for each user. Also you could manually insert the fields for a existing user. //** $s18=$adb->getUniqueID("vtiger_homestuff"); $visibility=$this->getDefaultHomeModuleVisibility('SOLD',$inVal); $sql="insert into vtiger_homestuff values(?,?,?,?,?,?)"; $res=$adb->pquery($sql, array($s18,18,'Default',$uid,$visibility,'Sold Policies')); //** $sql="insert into vtiger_homedefault values(".$s18.",'SOLD',10,'SoldPolicies')"; $adb->query($sql);
Step 4:
In Home.php within the function getDefaultDetails($dfid,$calCnt) add the code that will select your custom widget code }elseif($hometype=="SOLD" && vtlib_isModuleActive("Leads")){ if(isPermitted('Leads','index') == "yes"){ $home_values=$this->getCustomDetails($dfid); } }
Step 5:
Create the custom code that displays your data My getCustomDetails($dfid) function returns array loded with all the detials to dsplay a widget. You will need to write a similar fucntion that return this array.
$title=array(); $title[]='keyMetrics.gif'; $title[]=$app_strings['LBL_HOME_KEY_METRICS']; $title[]='home_metrics'; $header=Array(); $header[]='Lead Name'; $header[]='Company'; $header[]='Phone'; $entries=Array(); for($l=0; $l $lastname = $adb->query_result($result,$l,"lastname"); $firstname = $adb->query_result($result,$l,"firstname"); $phone = $adb->query_result($result,$l,"phone"); $lead_id = $adb->query_result($result,$l,"leadid"); $value=array(); $value[]=''.$firstname.' '.$lastname.''; $value[]=''.$company.''; $value[]=''.$phone.''; $entries[]=$value; } $values=Array('Title'=>$title,'Header'=>$header,'Entries'=>$entries); if ( ($display_empty_home_blocks ) || (count($value)!= 0) ) return $values; }