[ 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 ('user_privileges/default_module_view.php'); 19 20 class PriceBooks extends CRMEntity { 21 var $log; 22 var $db; 23 24 var $tab_name = Array('vtiger_crmentity','vtiger_pricebook','vtiger_pricebookcf'); 25 var $tab_name_index = Array('vtiger_crmentity'=>'crmid','vtiger_pricebook'=>'pricebookid','vtiger_pricebookcf'=>'pricebookid'); 26 var $column_fields = Array(); 27 28 var $sortby_fields = Array('bookname'); 29 30 // This is the list of fields that are in the lists. 31 var $list_fields = Array( 32 'Price Book Name'=>Array('pricebook'=>'bookname'), 33 'Active'=>Array('pricebook'=>'active') 34 ); 35 var $list_fields_name = Array( 36 'Price Book Name'=>'bookname', 37 'Active'=>'active' 38 ); 39 var $list_link_field= 'bookname'; 40 41 var $search_fields = Array( 42 'Price Book Name'=>Array('pricebook'=>'bookname') 43 ); 44 var $search_fields_name = Array( 45 'Price Book Name'=>'bookname', 46 ); 47 48 //Added these variables which are used as default order by and sortorder in ListView 49 var $default_order_by = 'bookname'; 50 var $default_sort_order = 'ASC'; 51 52 /** Constructor which will set the column_fields in this object 53 */ 54 function PriceBooks() { 55 $this->log =LoggerManager::getLogger('pricebook'); 56 $this->log->debug("Entering PriceBooks() method ..."); 57 $this->db = new PearDatabase(); 58 $this->column_fields = getColumnFields('PriceBooks'); 59 $this->log->debug("Exiting PriceBook method ..."); 60 } 61 62 function save_module($module) 63 { 64 } 65 66 /** Function used to get the sort order for PriceBook listview 67 * @return string $sorder - first check the $_REQUEST['sorder'] if request value is empty then check in the $_SESSION['PRICEBOOK_SORT_ORDER'] if this session value is empty then default sort order will be returned. 68 */ 69 function getSortOrder() 70 { 71 global $log; 72 $log->debug("Entering getSortOrder() method ..."); 73 if(isset($_REQUEST['sorder'])) 74 $sorder = $_REQUEST['sorder']; 75 else 76 $sorder = (($_SESSION['PRICEBOOK_SORT_ORDER'] != '')?($_SESSION['PRICEBOOK_SORT_ORDER']):($this->default_sort_order)); 77 $log->debug("Exiting getSortOrder() method ..."); 78 return $sorder; 79 } 80 81 /** Function used to get the order by value for PriceBook listview 82 * @return string $order_by - first check the $_REQUEST['order_by'] if request value is empty then check in the $_SESSION['PRICEBOOK_ORDER_BY'] if this session value is empty then default order by will be returned. 83 */ 84 function getOrderBy() 85 { 86 global $log; 87 $log->debug("Entering getOrderBy() method ..."); 88 if (isset($_REQUEST['order_by'])) 89 $order_by = $_REQUEST['order_by']; 90 else 91 $order_by = (($_SESSION['PRICEBOOK_ORDER_BY'] != '')?($_SESSION['PRICEBOOK_ORDER_BY']):($this->default_order_by)); 92 $log->debug("Exiting getOrderBy method ..."); 93 return $order_by; 94 } 95 96 /** function used to get the products which are related to the pricebook 97 * @param int $id - pricebook id 98 * @return array - return an array which will be returned from the function getPriceBookRelatedProducts 99 **/ 100 function get_pricebook_products($id) 101 { 102 global $log,$singlepane_view; 103 $log->debug("Entering get_pricebook_products(".$id.") method ..."); 104 global $app_strings; 105 require_once ('modules/Products/Products.php'); 106 $focus = new Products(); 107 108 $button = ''; 109 110 if($singlepane_view == 'true') 111 $returnset = '&return_module=PriceBooks&return_action=DetailView&return_id='.$id; 112 else 113 $returnset = '&return_module=PriceBooks&return_action=CallRelatedList&return_id='.$id; 114 115 $query = 'select vtiger_products.productid, vtiger_products.productname, vtiger_products.productcode, vtiger_products.commissionrate, vtiger_products.qty_per_unit, vtiger_products.unit_price, vtiger_crmentity.crmid, vtiger_crmentity.smownerid,vtiger_pricebookproductrel.listprice from vtiger_products inner join vtiger_pricebookproductrel on vtiger_products.productid = vtiger_pricebookproductrel.productid inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_products.productid inner join vtiger_pricebook on vtiger_pricebook.pricebookid = vtiger_pricebookproductrel.pricebookid where vtiger_pricebook.pricebookid = '.$id.' and vtiger_crmentity.deleted = 0'; 116 $log->debug("Exiting get_pricebook_products method ..."); 117 return getPriceBookRelatedProducts($query,$focus,$returnset); 118 } 119 120 /** function used to get whether the pricebook has related with a product or not 121 * @param int $id - product id 122 * @return true or false - if there are no pricebooks available or associated pricebooks for the product is equal to total number of pricebooks then return false, else return true 123 */ 124 function get_pricebook_noproduct($id) 125 { 126 global $log; 127 $log->debug("Entering get_pricebook_noproduct(".$id.") method ..."); 128 129 $query = "select vtiger_crmentity.crmid, vtiger_pricebook.* from vtiger_pricebook inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_pricebook.pricebookid where vtiger_crmentity.deleted=0"; 130 $result = $this->db->query($query); 131 $no_count = $this->db->num_rows($result); 132 if($no_count !=0) 133 { 134 $pb_query = 'select vtiger_crmentity.crmid, vtiger_pricebook.pricebookid,vtiger_pricebookproductrel.productid from vtiger_pricebook inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_pricebook.pricebookid inner join vtiger_pricebookproductrel on vtiger_pricebookproductrel.pricebookid=vtiger_pricebook.pricebookid where vtiger_crmentity.deleted=0 and vtiger_pricebookproductrel.productid='.$id; 135 $result_pb = $this->db->query($pb_query); 136 if($no_count == $this->db->num_rows($result_pb)) 137 { 138 $log->debug("Exiting get_pricebook_noproduct method ..."); 139 return false; 140 } 141 elseif($this->db->num_rows($result_pb) == 0) 142 { 143 $log->debug("Exiting get_pricebook_noproduct method ..."); 144 return true; 145 } 146 elseif($this->db->num_rows($result_pb) < $no_count) 147 { 148 $log->debug("Exiting get_pricebook_noproduct method ..."); 149 return true; 150 } 151 } 152 else 153 { 154 $log->debug("Exiting get_pricebook_noproduct method ..."); 155 return false; 156 } 157 } 158 159 } 160 ?>
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 |