| [ 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 include_once ('config.php'); 13 require_once ('include/logging.php'); 14 require_once ('include/database/PearDatabase.php'); 15 require_once ('data/SugarBean.php'); 16 require_once ('data/CRMEntity.php'); 17 require_once ('include/utils/utils.php'); 18 require_once ('include/RelatedListView.php'); 19 require_once ('user_privileges/default_module_view.php'); 20 21 class Product extends CRMEntity { 22 var $log; 23 var $db; 24 25 // Josh added for importing and exporting -added in patch2 26 var $unit_price; 27 var $table_name = "vtiger_products"; 28 var $object_name = "Product"; 29 var $entity_table = "vtiger_crmentity"; 30 var $required_fields = Array( 31 'productname'=>1 32 ); 33 34 35 var $tab_name = Array('vtiger_crmentity','vtiger_products','vtiger_productcf','vtiger_seproductsrel','vtiger_producttaxrel','vtiger_attachments'); 36 var $tab_name_index = Array('vtiger_crmentity'=>'crmid','vtiger_products'=>'productid','vtiger_productcf'=>'productid','vtiger_seproductsrel'=>'productid','vtiger_producttaxrel'=>'productid','vtiger_attachments'=>'attachmentsid'); 37 var $column_fields = Array(); 38 39 var $sortby_fields = Array('productname','productcode','commissionrate'); 40 41 // This is the list of vtiger_fields that are in the lists. 42 var $list_fields = Array( 43 'Product Name'=>Array('products'=>'productname'), 44 'Part Number'=>Array('products'=>'productcode'), 45 'Commission Rate'=>Array('products'=>'commissionrate'), 46 'Qty/Unit'=>Array('products'=>'qty_per_unit'), 47 'Unit Price'=>Array('products'=>'unit_price') 48 ); 49 var $list_fields_name = Array( 50 'Product Name'=>'productname', 51 'Part Number'=>'productcode', 52 'Commission Rate'=>'commissionrate', 53 'Qty/Unit'=>'qty_per_unit', 54 'Unit Price'=>'unit_price' 55 ); 56 var $list_link_field= 'productname'; 57 58 var $search_fields = Array( 59 'Product Name'=>Array('products'=>'productname'), 60 'Part Number'=>Array('products'=>'productcode'), 61 'Unit Price'=>Array('products'=>'unit_price') 62 ); 63 var $search_fields_name = Array( 64 'Product Name'=>'productname', 65 'Part Number'=>'productcode', 66 'Unit Price'=>'unit_price' 67 ); 68 69 //Added these variables which are used as default order by and sortorder in ListView 70 var $default_order_by = 'productname'; 71 var $default_sort_order = 'ASC'; 72 73 /** Constructor which will set the column_fields in this object 74 */ 75 function Product() { 76 $this->log =LoggerManager::getLogger('product'); 77 $this->log->debug("Entering Product() method ..."); 78 $this->db = new PearDatabase(); 79 $this->column_fields = getColumnFields('Products'); 80 $this->log->debug("Exiting Product method ..."); 81 } 82 83 /** Function used to get the sort order for Product listview 84 * @return string $sorder - first check the $_REQUEST['sorder'] if request value is empty then check in the $_SESSION['PRODUCTS_SORT_ORDER'] if this session value is empty then default sort order will be returned. 85 */ 86 function getSortOrder() 87 { 88 global $log; 89 $log->debug("Entering getSortOrder() method ..."); 90 if(isset($_REQUEST['sorder'])) 91 $sorder = $_REQUEST['sorder']; 92 else 93 $sorder = (($_SESSION['PRODUCTS_SORT_ORDER'] != '')?($_SESSION['PRODUCTS_SORT_ORDER']):($this->default_sort_order)); 94 $log->debug("Exiting getSortOrder() method ..."); 95 return $sorder; 96 } 97 98 /** Function used to get the order by value for Product listview 99 * @return string $order_by - first check the $_REQUEST['order_by'] if request value is empty then check in the $_SESSION['PRODUCTS_ORDER_BY'] if this session value is empty then default order by will be returned. 100 */ 101 function getOrderBy() 102 { 103 global $log; 104 $log->debug("Entering getOrderBy() method ..."); 105 if (isset($_REQUEST['order_by'])) 106 $order_by = $_REQUEST['order_by']; 107 else 108 $order_by = (($_SESSION['PRODUCTS_ORDER_BY'] != '')?($_SESSION['PRODUCTS_ORDER_BY']):($this->default_order_by)); 109 $log->debug("Exiting getOrderBy method ..."); 110 return $order_by; 111 } 112 113 /** function used to get the attachment which are related to the product 114 * @param int $id - product id to which we want to retrieve the attachments and notes 115 * @return array - array which will be returned from the function getAttachmentsAndNotes 116 **/ 117 function get_attachments($id) 118 { 119 global $log; 120 $log->debug("Entering get_attachments(".$id.") method ..."); 121 122 $query = "SELECT vtiger_notes.title, 'Notes ' AS ActivityType, 123 vtiger_notes.filename, vtiger_attachments.type AS FileType, 124 crm2.modifiedtime AS lastmodified, 125 vtiger_seattachmentsrel.attachmentsid AS attachmentsid, 126 vtiger_notes.notesid AS crmid, vtiger_crmentity.createdtime, 127 vtiger_notes.notecontent AS description, 128 vtiger_users.user_name 129 FROM vtiger_notes 130 INNER JOIN vtiger_senotesrel 131 ON vtiger_senotesrel.notesid = vtiger_notes.notesid 132 INNER JOIN vtiger_crmentity 133 ON vtiger_crmentity.crmid = vtiger_senotesrel.crmid 134 INNER JOIN vtiger_crmentity AS crm2 135 ON crm2.crmid = vtiger_notes.notesid 136 AND crm2.deleted = 0 137 LEFT JOIN vtiger_seattachmentsrel 138 ON vtiger_seattachmentsrel.crmid = vtiger_notes.notesid 139 LEFT JOIN vtiger_attachments 140 ON vtiger_seattachmentsrel.attachmentsid = vtiger_attachments.attachmentsid 141 INNER JOIN vtiger_users 142 ON vtiger_crmentity.smcreatorid = vtiger_users.id 143 WHERE vtiger_crmentity.crmid = ".$id." 144 UNION ALL 145 SELECT vtiger_attachments.description AS title, 146 'Attachments' AS ActivityType, 147 vtiger_attachments.name AS filename, 148 vtiger_attachments.type AS FileType, 149 crm2.modifiedtime AS lastmodified, 150 vtiger_attachments.attachmentsid AS attachmentsid, 151 vtiger_seattachmentsrel.attachmentsid AS crmid, 152 vtiger_crmentity.createdtime, 153 vtiger_attachments.description, vtiger_users.user_name 154 FROM vtiger_attachments 155 INNER JOIN vtiger_seattachmentsrel 156 ON vtiger_seattachmentsrel.attachmentsid = vtiger_attachments.attachmentsid 157 INNER JOIN vtiger_crmentity 158 ON vtiger_crmentity.crmid = vtiger_seattachmentsrel.crmid 159 INNER JOIN vtiger_crmentity AS crm2 160 ON crm2.crmid = vtiger_attachments.attachmentsid 161 INNER JOIN vtiger_users 162 ON vtiger_crmentity.smcreatorid = vtiger_users.id 163 WHERE vtiger_crmentity.crmid = ".$id; 164 165 $log->debug("Exiting get_attachments method ..."); 166 return getAttachmentsAndNotes('Products',$query,$id); 167 } 168 169 /** function used to get the list of potentials which are related to the product 170 * @param int $id - product id 171 * @return void - but this function will call the function renderRelatedPotentials with parameter query 172 */ 173 function get_opportunities($id) 174 { 175 global $log; 176 $log->debug("Entering get_opportunities(".$id.") method ..."); 177 $query = "SELECT vtiger_potential.potentialid, vtiger_potential.potentialname, 178 vtiger_potential.potentialtype, vtiger_products.productid, 179 vtiger_products.productname, vtiger_products.qty_per_unit, 180 vtiger_products.unit_price, vtiger_products.expiry_date 181 FROM vtiger_potential 182 INNER JOIN vtiger_products 183 ON vtiger_potential.productid = vtiger_products.productid 184 LEFT JOIN vtiger_potentialgrouprelation 185 ON vtiger_potential.potentialid = vtiger_potentialgrouprelation.potentialid 186 LEFT JOIN vtiger_groups 187 ON vtiger_groups.groupname = vtiger_potentialgrouprelation.groupname 188 inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_products.productid 189 WHERE vtiger_crmentity.deleted = 0 190 AND vtiger_products.productid = ".$id; 191 $log->debug("Exiting get_opportunities method ..."); 192 renderRelatedPotentials($query); 193 } 194 195 /** function used to get the list of tickets which are related to the product 196 * @param int $id - product id 197 * @return array - array which will be returned from the function GetRelatedList 198 */ 199 function get_tickets($id) 200 { 201 global $log, $singlepane_view; 202 $log->debug("Entering get_tickets(".$id.") method ..."); 203 global $mod_strings; 204 require_once ('modules/HelpDesk/HelpDesk.php'); 205 $focus = new HelpDesk(); 206 207 $button = ''; 208 209 if($singlepane_view == 'true') 210 $returnset = '&return_module=Products&return_action=DetailView&return_id='.$id; 211 else 212 $returnset = '&return_module=Products&return_action=CallRelatedList&return_id='.$id; 213 214 $query = "SELECT vtiger_users.user_name, vtiger_users.id, 215 vtiger_products.productid, vtiger_products.productname, 216 vtiger_troubletickets.ticketid, 217 vtiger_troubletickets.parent_id, vtiger_troubletickets.title, 218 vtiger_troubletickets.status, vtiger_troubletickets.priority, 219 vtiger_crmentity.crmid, vtiger_crmentity.smownerid, 220 vtiger_crmentity.modifiedtime 221 FROM vtiger_troubletickets 222 INNER JOIN vtiger_crmentity 223 ON vtiger_crmentity.crmid = vtiger_troubletickets.ticketid 224 LEFT JOIN vtiger_products 225 ON vtiger_products.productid = vtiger_troubletickets.product_id 226 LEFT JOIN vtiger_users 227 ON vtiger_users.id = vtiger_crmentity.smownerid 228 LEFT JOIN vtiger_ticketgrouprelation 229 ON vtiger_troubletickets.ticketid = vtiger_ticketgrouprelation.ticketid 230 LEFT JOIN vtiger_groups 231 ON vtiger_groups.groupname = vtiger_ticketgrouprelation.groupname 232 WHERE vtiger_crmentity.deleted = 0 233 AND vtiger_products.productid = ".$id; 234 $log->debug("Exiting get_tickets method ..."); 235 return GetRelatedList('Products','HelpDesk',$focus,$query,$button,$returnset); 236 } 237 238 /** function used to get the list of activities which are related to the product 239 * @param int $id - product id 240 * @return array - array which will be returned from the function GetRelatedList 241 */ 242 function get_activities($id) 243 { 244 global $log, $singlepane_view; 245 $log->debug("Entering get_activities(".$id.") method ..."); 246 global $app_strings; 247 248 require_once ('modules/Calendar/Activity.php'); 249 250 //if($this->column_fields['contact_id']!=0 && $this->column_fields['contact_id']!='') 251 $focus = new Activity(); 252 253 $button = ''; 254 255 if($singlepane_view == 'true') 256 $returnset = '&return_module=Products&return_action=DetailView&return_id='.$id; 257 else 258 $returnset = '&return_module=Products&return_action=CallRelatedList&return_id='.$id; 259 260 261 $query = "SELECT vtiger_contactdetails.lastname, 262 vtiger_contactdetails.firstname, 263 vtiger_contactdetails.contactid, 264 vtiger_activity.*, 265 vtiger_seactivityrel.*, 266 vtiger_crmentity.crmid, vtiger_crmentity.smownerid, 267 vtiger_crmentity.modifiedtime, 268 vtiger_users.user_name, 269 vtiger_recurringevents.recurringtype 270 FROM vtiger_activity 271 INNER JOIN vtiger_seactivityrel 272 ON vtiger_seactivityrel.activityid = vtiger_activity.activityid 273 INNER JOIN vtiger_crmentity 274 ON vtiger_crmentity.crmid=vtiger_activity.activityid 275 LEFT JOIN vtiger_cntactivityrel 276 ON vtiger_cntactivityrel.activityid = vtiger_activity.activityid 277 LEFT JOIN vtiger_contactdetails 278 ON vtiger_contactdetails.contactid = vtiger_cntactivityrel.contactid 279 LEFT JOIN vtiger_users 280 ON vtiger_users.id = vtiger_crmentity.smownerid 281 LEFT OUTER JOIN vtiger_recurringevents 282 ON vtiger_recurringevents.activityid = vtiger_activity.activityid 283 LEFT JOIN vtiger_activitygrouprelation 284 ON vtiger_activitygrouprelation.activityid = vtiger_crmentity.crmid 285 LEFT JOIN vtiger_groups 286 ON vtiger_groups.groupname = vtiger_activitygrouprelation.groupname 287 WHERE vtiger_seactivityrel.crmid=".$id." 288 AND (activitytype = 'Task' 289 OR vtiger_activitytype = 'Call' 290 OR vtiger_activitytype = 'Meeting')"; 291 $log->debug("Exiting get_activities method ..."); 292 return GetRelatedList('Products','Calendar',$focus,$query,$button,$returnset); 293 } 294 295 /** function used to get the list of quotes which are related to the product 296 * @param int $id - product id 297 * @return array - array which will be returned from the function GetRelatedList 298 */ 299 function get_quotes($id) 300 { 301 global $log, $singlepane_view; 302 $log->debug("Entering get_quotes(".$id.") method ..."); 303 global $app_strings; 304 require_once ('modules/Quotes/Quote.php'); 305 $focus = new Quote(); 306 307 $button = ''; 308 if($singlepane_view == 'true') 309 $returnset = '&return_module=Products&return_action=DetailView&return_id='.$id; 310 else 311 $returnset = '&return_module=Products&return_action=CallRelatedList&return_id='.$id; 312 313 314 $query = "SELECT vtiger_crmentity.*, 315 vtiger_quotes.*, 316 vtiger_potential.potentialname, 317 vtiger_account.accountname, 318 vtiger_inventoryproductrel.productid 319 FROM vtiger_quotes 320 INNER JOIN vtiger_crmentity 321 ON vtiger_crmentity.crmid = vtiger_quotes.quoteid 322 INNER JOIN vtiger_inventoryproductrel 323 ON vtiger_inventoryproductrel.id = vtiger_quotes.quoteid 324 LEFT OUTER JOIN vtiger_account 325 ON vtiger_account.accountid = vtiger_quotes.accountid 326 LEFT OUTER JOIN vtiger_potential 327 ON vtiger_potential.potentialid = vtiger_quotes.potentialid 328 LEFT JOIN vtiger_quotegrouprelation 329 ON vtiger_quotes.quoteid = vtiger_quotegrouprelation.quoteid 330 LEFT JOIN vtiger_groups 331 ON vtiger_groups.groupname = vtiger_quotegrouprelation.groupname 332 WHERE vtiger_crmentity.deleted = 0 333 AND vtiger_inventoryproductrel.productid = ".$id; 334 $log->debug("Exiting get_quotes method ..."); 335 return GetRelatedList('Products','Quotes',$focus,$query,$button,$returnset); 336 } 337 338 /** function used to get the list of purchase orders which are related to the product 339 * @param int $id - product id 340 * @return array - array which will be returned from the function GetRelatedList 341 */ 342 function get_purchase_orders($id) 343 { 344 global $log,$singlepane_view; 345 $log->debug("Entering get_purchase_orders(".$id.") method ..."); 346 global $app_strings; 347 require_once ('modules/PurchaseOrder/PurchaseOrder.php'); 348 $focus = new Order(); 349 350 $button = ''; 351 352 if($singlepane_view == 'true') 353 $returnset = '&return_module=Products&return_action=DetailView&return_id='.$id; 354 else 355 $returnset = '&return_module=Products&return_action=CallRelatedList&return_id='.$id; 356 357 $query = "SELECT vtiger_crmentity.*, 358 vtiger_purchaseorder.*, 359 vtiger_products.productname, 360 vtiger_inventoryproductrel.productid 361 FROM vtiger_purchaseorder 362 INNER JOIN vtiger_crmentity 363 ON vtiger_crmentity.crmid = vtiger_purchaseorder.purchaseorderid 364 INNER JOIN vtiger_inventoryproductrel 365 ON vtiger_inventoryproductrel.id = vtiger_purchaseorder.purchaseorderid 366 INNER JOIN vtiger_products 367 ON vtiger_products.productid = vtiger_inventoryproductrel.productid 368 LEFT JOIN vtiger_pogrouprelation 369 ON vtiger_purchaseorder.purchaseorderid = vtiger_pogrouprelation.purchaseorderid 370 LEFT JOIN vtiger_groups 371 ON vtiger_groups.groupname = vtiger_pogrouprelation.groupname 372 WHERE vtiger_crmentity.deleted = 0 373 AND vtiger_products.productid = ".$id; 374 $log->debug("Exiting get_purchase_orders method ..."); 375 return GetRelatedList('Products','PurchaseOrder',$focus,$query,$button,$returnset); 376 } 377 378 /** function used to get the list of sales orders which are related to the product 379 * @param int $id - product id 380 * @return array - array which will be returned from the function GetRelatedList 381 */ 382 function get_salesorder($id) 383 { 384 global $log,$singlepane_view; 385 $log->debug("Entering get_salesorder(".$id.") method ..."); 386 global $app_strings; 387 require_once ('modules/SalesOrder/SalesOrder.php'); 388 389 $focus = new SalesOrder(); 390 391 $button = ''; 392 if($singlepane_view == 'true') 393 $returnset = '&return_module=Products&return_action=DetailView&return_id='.$id; 394 else 395 $returnset = '&return_module=Products&return_action=CallRelatedList&return_id='.$id; 396 397 $query = "SELECT vtiger_crmentity.*, 398 vtiger_salesorder.*, 399 vtiger_products.productname AS productname, 400 vtiger_account.accountname 401 FROM vtiger_salesorder 402 INNER JOIN vtiger_crmentity 403 ON vtiger_crmentity.crmid = vtiger_salesorder.salesorderid 404 INNER JOIN vtiger_inventoryproductrel 405 ON vtiger_inventoryproductrel.id = vtiger_salesorder.salesorderid 406 INNER JOIN vtiger_products 407 ON vtiger_products.productid = vtiger_inventoryproductrel.productid 408 LEFT OUTER JOIN vtiger_account 409 ON vtiger_account.accountid = vtiger_salesorder.accountid 410 LEFT JOIN vtiger_sogrouprelation 411 ON vtiger_salesorder.salesorderid = vtiger_sogrouprelation.salesorderid 412 LEFT JOIN vtiger_groups 413 ON vtiger_groups.groupname = vtiger_sogrouprelation.groupname 414 WHERE vtiger_crmentity.deleted = 0 415 AND vtiger_products.productid = ".$id; 416 $log->debug("Exiting get_salesorder method ..."); 417 return GetRelatedList('Products','SalesOrder',$focus,$query,$button,$returnset); 418 } 419 420 /** function used to get the list of invoices which are related to the product 421 * @param int $id - product id 422 * @return array - array which will be returned from the function GetRelatedList 423 */ 424 function get_invoices($id) 425 { 426 global $log,$singlepane_view; 427 $log->debug("Entering get_invoices(".$id.") method ..."); 428 global $app_strings; 429 require_once ('modules/Invoice/Invoice.php'); 430 $focus = new Invoice(); 431 432 $button = ''; 433 if($singlepane_view == 'true') 434 $returnset = '&return_module=Products&return_action=DetailView&return_id='.$id; 435 else 436 $returnset = '&return_module=Products&return_action=CallRelatedList&return_id='.$id; 437 438 439 $query = "SELECT vtiger_crmentity.*, 440 vtiger_invoice.*, 441 vtiger_inventoryproductrel.quantity, 442 vtiger_account.accountname 443 FROM vtiger_invoice 444 INNER JOIN vtiger_crmentity 445 ON vtiger_crmentity.crmid = vtiger_invoice.invoiceid 446 LEFT OUTER JOIN vtiger_account 447 ON vtiger_account.accountid = vtiger_invoice.accountid 448 INNER JOIN vtiger_inventoryproductrel 449 ON vtiger_inventoryproductrel.id = vtiger_invoice.invoiceid 450 LEFT JOIN vtiger_invoicegrouprelation 451 ON vtiger_invoice.invoiceid = vtiger_invoicegrouprelation.invoiceid 452 LEFT JOIN vtiger_groups 453 ON vtiger_groups.groupname = vtiger_invoicegrouprelation.groupname 454 WHERE vtiger_crmentity.deleted = 0 455 AND vtiger_inventoryproductrel.productid = ".$id; 456 $log->debug("Exiting get_invoices method ..."); 457 return GetRelatedList('Products','Invoice',$focus,$query,$button,$returnset); 458 } 459 460 /** function used to get the list of pricebooks which are related to the product 461 * @param int $id - product id 462 * @return array - array which will be returned from the function GetRelatedList 463 */ 464 function get_product_pricebooks($id) 465 { 466 global $log,$singlepane_view; 467 $log->debug("Entering get_product_pricebooks(".$id.") method ..."); 468 global $mod_strings; 469 require_once ('modules/PriceBooks/PriceBook.php'); 470 $focus = new PriceBook(); 471 $button = ''; 472 if($singlepane_view == 'true') 473 $returnset = '&return_module=Products&return_action=DetailView&return_id='.$id; 474 else 475 $returnset = '&return_module=Products&return_action=CallRelatedList&return_id='.$id; 476 477 478 $query = "SELECT vtiger_crmentity.crmid, 479 vtiger_pricebook.*, 480 vtiger_pricebookproductrel.productid as prodid 481 FROM vtiger_pricebook 482 INNER JOIN vtiger_crmentity 483 ON vtiger_crmentity.crmid = vtiger_pricebook.pricebookid 484 INNER JOIN vtiger_pricebookproductrel 485 ON vtiger_pricebookproductrel.pricebookid = vtiger_pricebook.pricebookid 486 WHERE vtiger_crmentity.deleted = 0 487 AND vtiger_pricebookproductrel.productid = ".$id; 488 $log->debug("Exiting get_product_pricebooks method ..."); 489 return GetRelatedList('Products','PriceBooks',$focus,$query,$button,$returnset); 490 } 491 492 /** function used to get the number of vendors which are related to the product 493 * @param int $id - product id 494 * @return int number of rows - return the number of products which do not have relationship with vendor 495 */ 496 function product_novendor() 497 { 498 global $log; 499 $log->debug("Entering product_novendor() method ..."); 500 $query = "SELECT vtiger_products.productname, vtiger_crmentity.deleted 501 FROM vtiger_products 502 INNER JOIN vtiger_crmentity 503 ON vtiger_crmentity.crmid = vtiger_products.productid 504 WHERE vtiger_crmentity.deleted = 0 505 AND vtiger_products.vendor_id is NULL"; 506 $result=$this->db->query($query); 507 $log->debug("Exiting product_novendor method ..."); 508 return $this->db->num_rows($result); 509 } 510 511 /** function used to get the export query for product 512 * @param reference &$order_by - reference of the order by variable which will be added with the query 513 * @param reference &$where - reference of the where variable which will be added with the query 514 * @return string $query - return the query which will give the list of products to export 515 */ 516 function create_export_query(&$order_by, &$where) 517 { 518 global $log; 519 $log->debug("Entering create_export_query(".$order_by.",".$where.") method ..."); 520 521 include ("include/utils/ExportUtils.php"); 522 523 //To get the Permitted fields query and the permitted fields list 524 $sql = getPermittedFieldsQuery("Products", "detail_view"); 525 $fields_list = getFieldsListFromQuery($sql); 526 527 $query = "SELECT $fields_list FROM ".$this->table_name ." 528 INNER JOIN vtiger_crmentity 529 ON vtiger_crmentity.crmid = vtiger_products.productid 530 LEFT JOIN vtiger_productcf 531 ON vtiger_products.productid = vtiger_productcf.productid 532 LEFT JOIN vtiger_seproductsrel 533 ON vtiger_seproductsrel.productid = vtiger_products.productid 534 LEFT JOIN vtiger_producttaxrel 535 ON vtiger_producttaxrel.productid = vtiger_products.productid 536 INNER JOIN vtiger_users 537 ON vtiger_users.id=vtiger_crmentity.smownerid 538 539 LEFT JOIN vtiger_crmentity vtiger_crmentityRelatedTo 540 ON vtiger_crmentityRelatedTo.crmid = vtiger_seproductsrel.crmid 541 542 LEFT JOIN vtiger_leaddetails vtiger_ProductRelatedToLead 543 ON vtiger_ProductRelatedToLead.leadid = vtiger_seproductsrel.crmid 544 LEFT JOIN vtiger_account vtiger_ProductRelatedToAccount 545 ON vtiger_ProductRelatedToAccount.accountid = vtiger_seproductsrel.crmid 546 LEFT JOIN vtiger_potential vtiger_ProductRelatedToPotential 547 ON vtiger_ProductRelatedToPotential.potentialid = vtiger_seproductsrel.crmid 548 549 LEFT JOIN vtiger_contactdetails 550 ON vtiger_contactdetails.contactid = vtiger_products.contactid 551 LEFT JOIN vtiger_vendor 552 ON vtiger_vendor.vendorid = vtiger_products.vendor_id 553 554 WHERE vtiger_crmentity.deleted = 0 AND vtiger_users.status = 'Active' 555 AND ((vtiger_seproductsrel.crmid IS NULL 556 AND (vtiger_products.contactid = 0 OR vtiger_products.contactid IS NULL)) 557 OR vtiger_seproductsrel.crmid IN (".getReadEntityIds('Leads').") 558 OR vtiger_seproductsrel.crmid IN (".getReadEntityIds('Accounts').") 559 OR vtiger_seproductsrel.crmid IN (".getReadEntityIds('Potentials').") 560 OR vtiger_products.contactid IN (".getReadEntityIds('Contacts').")) 561 group by vtiger_products.productid 562 "; 563 //ProductRelatedToLead, Account and Potential tables are added to get the Related to field 564 565 566 if($where != "") 567 $query .= " AND ($where) "; 568 569 if(!empty($order_by)) 570 $query .= " ORDER BY $order_by"; 571 572 $log->debug("Exiting create_export_query method ..."); 573 return $query; 574 575 } 576 577 578 } 579 ?>
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 |