[ Index ] |
PHP Cross Reference of vtigercrm-6.1.0 |
[Summary view] [Print] [Text view]
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 class Products_Module_Model extends Vtiger_Module_Model { 12 13 /** 14 * Function to get list view query for popup window 15 * @param <String> $sourceModule Parent module 16 * @param <String> $field parent fieldname 17 * @param <Integer> $record parent id 18 * @param <String> $listQuery 19 * @return <String> Listview Query 20 */ 21 public function getQueryByModuleField($sourceModule, $field, $record, $listQuery) { 22 $supportedModulesList = array($this->getName(), 'Vendors', 'Leads', 'Accounts', 'Contacts', 'Potentials'); 23 if (($sourceModule == 'PriceBooks' && $field == 'priceBookRelatedList') 24 || in_array($sourceModule, $supportedModulesList) 25 || in_array($sourceModule, getInventoryModules())) { 26 27 $condition = " vtiger_products.discontinued = 1 "; 28 if ($sourceModule === $this->getName()) { 29 $condition .= " AND vtiger_products.productid NOT IN (SELECT productid FROM vtiger_seproductsrel WHERE crmid = '$record' UNION SELECT crmid FROM vtiger_seproductsrel WHERE productid = '$record') AND vtiger_products.productid <> '$record' "; 30 } elseif ($sourceModule === 'PriceBooks') { 31 $condition .= " AND vtiger_products.productid NOT IN (SELECT productid FROM vtiger_pricebookproductrel WHERE pricebookid = '$record') "; 32 } elseif ($sourceModule === 'Vendors') { 33 $condition .= " AND vtiger_products.vendor_id != '$record' "; 34 } elseif (in_array($sourceModule, $supportedModulesList)) { 35 $condition .= " AND vtiger_products.productid NOT IN (SELECT productid FROM vtiger_seproductsrel WHERE crmid = '$record')"; 36 } 37 38 $pos = stripos($listQuery, 'where'); 39 if ($pos) { 40 $split = spliti('where', $listQuery); 41 $overRideQuery = $split[0] . ' WHERE ' . $split[1] . ' AND ' . $condition; 42 } else { 43 $overRideQuery = $listQuery. ' WHERE ' . $condition; 44 } 45 return $overRideQuery; 46 } 47 } 48 49 /** 50 * Function to get Specific Relation Query for this Module 51 * @param <type> $relatedModule 52 * @return <type> 53 */ 54 public function getSpecificRelationQuery($relatedModule) { 55 if ($relatedModule === 'Leads') { 56 $specificQuery = 'AND vtiger_leaddetails.converted = 0'; 57 return $specificQuery; 58 } 59 return parent::getSpecificRelationQuery($relatedModule); 60 } 61 62 /** 63 * Function to get prices for specified products with specific currency 64 * @param <Integer> $currenctId 65 * @param <Array> $productIdsList 66 * @return <Array> 67 */ 68 public function getPricesForProducts($currencyId, $productIdsList) { 69 return getPricesForProducts($currencyId, $productIdsList, $this->getName()); 70 } 71 72 /** 73 * Function to check whether the module is summary view supported 74 * @return <Boolean> - true/false 75 */ 76 public function isSummaryViewSupported() { 77 return false; 78 } 79 80 /** 81 * Function searches the records in the module, if parentId & parentModule 82 * is given then searches only those records related to them. 83 * @param <String> $searchValue - Search value 84 * @param <Integer> $parentId - parent recordId 85 * @param <String> $parentModule - parent module name 86 * @return <Array of Vtiger_Record_Model> 87 */ 88 public function searchRecord($searchValue, $parentId=false, $parentModule=false, $relatedModule=false) { 89 if(!empty($searchValue) && empty($parentId) && empty($parentModule) && (in_array($relatedModule, getInventoryModules()))) { 90 $matchingRecords = Products_Record_Model::getSearchResult($searchValue, $this->getName()); 91 }else { 92 return parent::searchRecord($searchValue); 93 } 94 95 return $matchingRecords; 96 } 97 98 /** 99 * Function returns query for Product-PriceBooks relation 100 * @param <Vtiger_Record_Model> $recordModel 101 * @param <Vtiger_Record_Model> $relatedModuleModel 102 * @return <String> 103 */ 104 function get_product_pricebooks($recordModel, $relatedModuleModel) { 105 $query = 'SELECT vtiger_pricebook.pricebookid, vtiger_pricebook.bookname, vtiger_pricebook.active, vtiger_crmentity.crmid, 106 vtiger_crmentity.smownerid, vtiger_pricebookproductrel.listprice, vtiger_products.unit_price 107 FROM vtiger_pricebook 108 INNER JOIN vtiger_pricebookproductrel ON vtiger_pricebook.pricebookid = vtiger_pricebookproductrel.pricebookid 109 INNER JOIN vtiger_crmentity on vtiger_crmentity.crmid = vtiger_pricebook.pricebookid 110 INNER JOIN vtiger_products on vtiger_products.productid = vtiger_pricebookproductrel.productid 111 INNER JOIN vtiger_pricebookcf on vtiger_pricebookcf.pricebookid = vtiger_pricebook.pricebookid 112 LEFT JOIN vtiger_users ON vtiger_users.id=vtiger_crmentity.smownerid 113 LEFT JOIN vtiger_groups ON vtiger_groups.groupid = vtiger_crmentity.smownerid ' 114 . Users_Privileges_Model::getNonAdminAccessControlQuery($relatedModuleModel->getName()) .' 115 WHERE vtiger_products.productid = '.$recordModel->getId().' and vtiger_crmentity.deleted = 0'; 116 117 return $query; 118 } 119 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Nov 28 20:08:37 2014 | Cross-referenced by PHPXref 0.7.1 |