[ 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 PriceBook 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 PriceBook() { 55 $this->log =LoggerManager::getLogger('pricebook'); 56 $this->log->debug("Entering PriceBook() method ..."); 57 $this->db = new PearDatabase(); 58 $this->column_fields = getColumnFields('PriceBooks'); 59 $this->log->debug("Exiting PriceBook method ..."); 60 } 61 62 /** Function used to get the sort order for PriceBook listview 63 * @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. 64 */ 65 function getSortOrder() 66 { 67 global $log; 68 $log->debug("Entering getSortOrder() method ..."); 69 if(isset($_REQUEST['sorder'])) 70 $sorder = $_REQUEST['sorder']; 71 else 72 $sorder = (($_SESSION['PRICEBOOK_SORT_ORDER'] != '')?($_SESSION['PRICEBOOK_SORT_ORDER']):($this->default_sort_order)); 73 $log->debug("Exiting getSortOrder() method ..."); 74 return $sorder; 75 } 76 77 /** Function used to get the order by value for PriceBook listview 78 * @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. 79 */ 80 function getOrderBy() 81 { 82 global $log; 83 $log->debug("Entering getOrderBy() method ..."); 84 if (isset($_REQUEST['order_by'])) 85 $order_by = $_REQUEST['order_by']; 86 else 87 $order_by = (($_SESSION['PRICEBOOK_ORDER_BY'] != '')?($_SESSION['PRICEBOOK_ORDER_BY']):($this->default_order_by)); 88 $log->debug("Exiting getOrderBy method ..."); 89 return $order_by; 90 } 91 92 /** function used to get the products which are related to the pricebook 93 * @param int $id - pricebook id 94 * @return array - return an array which will be returned from the function getPriceBookRelatedProducts 95 **/ 96 function get_pricebook_products($id) 97 { 98 global $log,$singlepane_view; 99 $log->debug("Entering get_pricebook_products(".$id.") method ..."); 100 global $app_strings; 101 require_once ('modules/Products/Product.php'); 102 $focus = new Product(); 103 104 $button = ''; 105 106 if($singlepane_view == 'true') 107 $returnset = '&return_module=PriceBooks&return_action=DetailView&return_id='.$id; 108 else 109 $returnset = '&return_module=PriceBooks&return_action=CallRelatedList&return_id='.$id; 110 111 $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'; 112 $log->debug("Exiting get_pricebook_products method ..."); 113 return getPriceBookRelatedProducts($query,$focus,$returnset); 114 } 115 116 /** function used to get whether the pricebook has related with a product or not 117 * @param int $id - product id 118 * @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 119 */ 120 function get_pricebook_noproduct($id) 121 { 122 global $log; 123 $log->debug("Entering get_pricebook_noproduct(".$id.") method ..."); 124 125 $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"; 126 $result = $this->db->query($query); 127 $no_count = $this->db->num_rows($result); 128 if($no_count !=0) 129 { 130 $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; 131 $result_pb = $this->db->query($pb_query); 132 if($no_count == $this->db->num_rows($result_pb)) 133 { 134 $log->debug("Exiting get_pricebook_noproduct method ..."); 135 return false; 136 } 137 elseif($this->db->num_rows($result_pb) == 0) 138 { 139 $log->debug("Exiting get_pricebook_noproduct method ..."); 140 return true; 141 } 142 elseif($this->db->num_rows($result_pb) < $no_count) 143 { 144 $log->debug("Exiting get_pricebook_noproduct method ..."); 145 return true; 146 } 147 } 148 else 149 { 150 $log->debug("Exiting get_pricebook_noproduct method ..."); 151 return false; 152 } 153 } 154 155 } 156 ?>
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 |