[ Index ] |
|
Code source de vtiger CRM 5.0.2 |
1 <?php 2 /********************************************************************************* 3 ** The contents of this file are subject to the vtiger CRM Public License Version 1.0 4 * ("License"); You may not use this file except in compliance with the License 5 * The Original Code is: vtiger CRM Open Source 6 * The Initial Developer of the Original Code is vtiger. 7 * Portions created by vtiger are Copyright (C) vtiger. 8 * All Rights Reserved. 9 * 10 ********************************************************************************/ 11 12 13 /** function used to get the permitted blocks 14 * @param string $module - module name 15 * @param string $disp_view - view name, this may be create_view, edit_view or detail_view 16 * @return string $blockid_list - list of block ids within the paranthesis with comma seperated 17 */ 18 function getPermittedBlocks($module, $disp_view) 19 { 20 global $adb, $log; 21 $log->debug("Entering into the function getPermittedBlocks($module, $disp_view)"); 22 23 $tabid = getTabid($module); 24 $block_detail = Array(); 25 $query="select blockid,blocklabel,show_title from vtiger_blocks where tabid=$tabid and $disp_view=0 and visible = 0 order by sequence"; 26 27 $result = $adb->query($query); 28 $noofrows = $adb->num_rows($result); 29 $blockid_list ='('; 30 for($i=0; $i<$noofrows; $i++) 31 { 32 $blockid = $adb->query_result($result,$i,"blockid"); 33 if($i != 0) 34 $blockid_list .= ', '; 35 $blockid_list .= $blockid; 36 $block_label[$blockid] = $adb->query_result($result,$i,"blocklabel"); 37 } 38 $blockid_list .= ')'; 39 40 $log->debug("Exit from the function getPermittedBlocks($module, $disp_view). Return value = $blockid_list"); 41 return $blockid_list; 42 } 43 44 /** function used to get the query which will list the permitted fields 45 * @param string $module - module name 46 * @param string $disp_view - view name, this may be create_view, edit_view or detail_view 47 * @return string $sql - query to get the list of fields which are permitted to the current user 48 */ 49 function getPermittedFieldsQuery($module, $disp_view) 50 { 51 global $adb, $log; 52 $log->debug("Entering into the function getPermittedFieldsQuery($module, $disp_view)"); 53 54 global $current_user; 55 require('user_privileges/user_privileges_'.$current_user->id.'.php'); 56 57 //To get the permitted blocks 58 $blockid_list = getPermittedBlocks($module, $disp_view); 59 60 $tabid = getTabid($module); 61 if($is_admin == true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] == 0 || $module == "Users") 62 { 63 $sql = "SELECT vtiger_field.columnname, vtiger_field.fieldlabel, vtiger_field.tablename FROM vtiger_field WHERE vtiger_field.tabid=".$tabid." AND vtiger_field.block IN $blockid_list AND vtiger_field.displaytype IN (1,2,4) ORDER BY block,sequence"; 64 } 65 else 66 { 67 $profileList = getCurrentUserProfileList(); 68 $sql = "SELECT vtiger_field.columnname, vtiger_field.fieldlabel, vtiger_field.tablename FROM vtiger_field INNER JOIN vtiger_profile2field ON vtiger_profile2field.fieldid=vtiger_field.fieldid INNER JOIN vtiger_def_org_field ON vtiger_def_org_field.fieldid=vtiger_field.fieldid WHERE vtiger_field.tabid=".$tabid." AND vtiger_field.block IN ".$blockid_list." AND vtiger_field.displaytype IN (1,2,4) AND vtiger_profile2field.visible=0 AND vtiger_def_org_field.visible=0 AND vtiger_profile2field.profileid IN ".$profileList." GROUP BY vtiger_field.fieldid ORDER BY block,sequence"; 69 } 70 71 $log->debug("Exit from the function getPermittedFieldsQuery($module, $disp_view). Return value = $sql"); 72 return $sql; 73 } 74 75 /** function used to get the list of fields from the input query as a comma seperated string 76 * @param string $query - field table query which contains the list of fields 77 * @return string $fields - list of fields as a comma seperated string 78 */ 79 function getFieldsListFromQuery($query) 80 { 81 global $adb, $log; 82 $log->debug("Entering into the function getFieldsListFromQuery($query)"); 83 84 $result = $adb->query($query); 85 $num_rows = $adb->num_rows($result); 86 87 for($i=0; $i < $num_rows;$i++) 88 { 89 $columnName = $adb->query_result($result,$i,"columnname"); 90 $fieldlable = $adb->query_result($result,$i,"fieldlabel"); 91 $tablename = $adb->query_result($result,$i,"tablename"); 92 93 //HANDLE HERE - Mismatch fieldname-tablename in field table, in future we have to avoid these if elses 94 if($columnName == 'smownerid')//for all assigned to user name 95 { 96 $fields .= "vtiger_users.user_name as '".$fieldlable."', "; 97 } 98 elseif($tablename == 'vtiger_account' && $columnName == 'parentid')//Account - Member Of 99 { 100 $fields .= "vtiger_account2.accountname as '".$fieldlable."', "; 101 } 102 elseif($tablename == 'vtiger_contactdetails' && $columnName == 'accountid')//Contact - Account Name 103 { 104 $fields .= "vtiger_account.accountname as '".$fieldlable."', "; 105 } 106 elseif($tablename == 'vtiger_contactdetails' && $columnName == 'reportsto')//Contact - Reports To 107 { 108 $fields .= " concat(vtiger_contactdetails2.lastname,' ',vtiger_contactdetails2.firstname) as 'Reports To Contact', "; 109 } 110 elseif($tablename == 'vtiger_potential' && $columnName == 'accountid')//Potential - Account Name 111 { 112 $fields .= "vtiger_account.accountname as '".$fieldlable."',"; 113 } 114 elseif($tablename == 'vtiger_potential' && $columnName == 'campaignid')//Potential - Campaign Source 115 { 116 $fields .= "vtiger_campaign.campaignname as '".$fieldlable."',"; 117 } 118 elseif($tablename == 'vtiger_seproductsrel' && $columnName == 'crmid')//Product - Related To 119 { 120 $fields .= "case vtiger_crmentityRelatedTo.setype 121 when 'Leads' then concat('Leads ::: ',vtiger_ProductRelatedToLead.lastname,' ',vtiger_ProductRelatedToLead.firstname) 122 when 'Accounts' then concat('Accounts ::: ',vtiger_ProductRelatedToAccount.accountname) 123 when 'Potentials' then concat('Potentials ::: ',vtiger_ProductRelatedToPotential.potentialname) 124 End as 'Related To',"; 125 //This will export as 3 seperate columns for each Leads, Accounts and Potentials 126 //$fields .= " case vtiger_crmentityRelatedTo.setype when 'Leads' then vtiger_ProductRelatedToLead.lastname End as 'Lead Name', case vtiger_crmentityRelatedTo.setype when 'Accounts' then vtiger_ProductRelatedToAccount.accountname End as 'Account Name', case vtiger_crmentityRelatedTo.setype when 'Potentials' then vtiger_ProductRelatedToPotential.potentialname End as 'Potential Name',"; 127 } 128 elseif($tablename == 'vtiger_products' && $columnName == 'contactid')//Product - Contact 129 { 130 $fields .= " concat(vtiger_contactdetails.lastname,' ',vtiger_contactdetails.firstname) as 'Contact Name',"; 131 } 132 elseif($tablename == 'vtiger_products' && $columnName == 'vendor_id')//Product - Vendor Name 133 { 134 $fields .= "vtiger_vendor.vendorname as '".$fieldlable."',"; 135 } 136 elseif($tablename == 'vtiger_producttaxrel' && $columnName == 'taxclass')//avoid product - taxclass 137 { 138 $fields .= ""; 139 } 140 elseif($tablename == 'vtiger_notes' && $columnName == 'contact_id')//Notes - contact_id 141 { 142 $fields .= " concat(vtiger_contactdetails.lastname,' ',vtiger_contactdetails.firstname) as 'Contact Name',"; 143 } 144 elseif($tablename == 'vtiger_senotesrel' && $columnName == 'crmid')//Notes - Related To 145 { 146 $fields .= "case vtiger_crmentityRelatedTo.setype 147 when 'Leads' then concat('Leads ::: ',vtiger_NoteRelatedToLead.lastname,' ',vtiger_NoteRelatedToLead.firstname) 148 when 'Accounts' then concat('Accounts ::: ',vtiger_NoteRelatedToAccount.accountname) 149 when 'Potentials' then concat('Potentials ::: ',vtiger_NoteRelatedToPotential.potentialname) 150 when 'Products' then concat('Products ::: ',vtiger_NoteRelatedToProduct.productname) 151 when 'Invoice' then concat('Invoice ::: ',vtiger_NoteRelatedToInvoice.subject) 152 when 'PurchaseOrder' then concat('PurchaseOrder ::: ',vtiger_NoteRelatedToPO.subject) 153 when 'SalesOrder' then concat('SalesOrder ::: ',vtiger_NoteRelatedToSO.subject) 154 End as 'Related To',"; 155 } 156 elseif($tablename == 'vtiger_attachments' && $columnName == 'filename')//Emails filename 157 { 158 $fields .= $tablename.".name '".$fieldlable."',"; 159 } 160 else 161 { 162 $fields .= $tablename.".".$columnName. " '" .$fieldlable."',"; 163 } 164 } 165 $fields = trim($fields,","); 166 167 $log->debug("Exit from the function getFieldsListFromQuery($query). Return value = $fields"); 168 return $fields; 169 } 170 171 172 173 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Feb 25 10:22:19 2007 | par Balluche grâce à PHPXref 0.7 |