[ 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.1 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 * PriceBooks Record Model Class 13 */ 14 class PriceBooks_Record_Model extends Vtiger_Record_Model { 15 16 /** 17 * Function return the url to fetch List Price of the Product for the current PriceBook 18 * @return <String> 19 */ 20 function getProductListPriceURL() { 21 $url = 'module=PriceBooks&action=ProductListPrice&record=' . $this->getId(); 22 $rawData = $this->getRawData(); 23 $src_record = $rawData['src_record']; 24 if (!empty($src_record)) { 25 $url .= '&itemId=' . $src_record; 26 } 27 return $url; 28 } 29 /** 30 * Function returns the List Price for PriceBook-Product/Service relation 31 * @param <Integer> $relatedRecordId - Product/Service Id 32 * @return <Integer> 33 */ 34 function getProductsListPrice($relatedRecordId) { 35 $db = PearDatabase::getInstance(); 36 37 $result = $db->pquery('SELECT listprice FROM vtiger_pricebookproductrel WHERE pricebookid = ? AND productid = ?', 38 array($this->getId(), $relatedRecordId)); 39 40 if($db->num_rows($result)) { 41 return $db->query_result($result, 0, 'listprice'); 42 } 43 return false; 44 } 45 46 /** 47 * Function updates ListPrice for PriceBook-Product/Service relation 48 * @param <Integer> $relatedRecordId - Product/Service Id 49 * @param <Integer> $price - listprice 50 */ 51 function updateListPrice($relatedRecordId, $price) { 52 $db = PearDatabase::getInstance(); 53 54 $result = $db->pquery('SELECT * FROM vtiger_pricebookproductrel WHERE pricebookid = ? AND productid = ?', 55 array($this->getId(), $relatedRecordId)); 56 if($db->num_rows($result)) { 57 $db->pquery('UPDATE vtiger_pricebookproductrel SET listprice = ? WHERE pricebookid = ? AND productid = ?', 58 array($price, $this->getId(), $relatedRecordId)); 59 } else { 60 $db->pquery('INSERT INTO vtiger_pricebookproductrel (pricebookid,productid,listprice,usedcurrency) values(?,?,?,?)', 61 array($this->getId(), $relatedRecordId, $price, $this->get('currency_id'))); 62 } 63 } 64 65 /** 66 * Function deletes the List Price for PriceBooks-Product/Services relationship 67 * @param <Integer> $relatedRecordId - Product/Service Id 68 */ 69 function deleteListPrice($relatedRecordId) { 70 $db = PearDatabase::getInstance(); 71 $db->pquery('DELETE FROM vtiger_pricebookproductrel WHERE pricebookid = ? AND productid = ?', 72 array($this->getId(), $relatedRecordId)); 73 } 74 }
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 |