[ 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 require_once ('include/database/PearDatabase.php'); 12 require_once ('Smarty_setup.php'); 13 require_once ('modules/PriceBooks/PriceBooks.php'); 14 require_once ('include/utils/utils.php'); 15 require_once ('include/ComboUtil.php'); 16 17 global $app_strings,$mod_strings,$current_language,$theme,$log; 18 19 $current_module_strings = return_module_language($current_language, 'Products'); 20 21 $productid = $_REQUEST['return_id']; 22 $theme_path="themes/".$theme."/"; 23 $image_path=$theme_path."images/"; 24 require_once ($theme_path.'layout_utils.php'); 25 $productname = getProductName($productid); 26 27 $smarty=new vtigerCRM_Smarty; 28 29 $smarty->assign("MOD", $mod_strings); 30 $smarty->assign("APP", $app_strings); 31 $smarty->assign("IMAGE_PATH",$image_path); 32 33 $focus = new PriceBooks(); 34 35 //Retreive the list of PriceBooks 36 $list_query = getListQuery("PriceBooks"); 37 38 $list_query .= ' ORDER BY pricebookid DESC '; 39 40 $list_result = $adb->query($list_query); 41 $num_rows = $adb->num_rows($list_result); 42 43 $record_string= "Total No of PriceBooks : ".$num_rows; 44 45 //Retreiving the array of already releated products 46 $sql1="select vtiger_crmentity.crmid, vtiger_pricebookproductrel.pricebookid,vtiger_products.unit_price from vtiger_pricebookproductrel inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_pricebookproductrel.productid inner join vtiger_products on vtiger_products.productid=vtiger_pricebookproductrel.productid where vtiger_crmentity.deleted=0 and vtiger_pricebookproductrel.productid=".$productid; 47 $res1 = $adb->query($sql1); 48 $num_prod_rows = $adb->num_rows($res1); 49 $pbk_array = Array(); 50 $unit_price = getUnitPrice($productid); 51 for($i=0; $i<$num_prod_rows; $i++) 52 { 53 $pbkid=$adb->query_result($res1,$i,"pricebookid"); 54 $pbk_array[$pbkid] = $pbkid; 55 } 56 57 58 $field_name_array=array(); 59 for($i=0; $i<$num_rows; $i++) 60 { 61 62 $entity_id = $adb->query_result($list_result,$i,"crmid"); 63 if(! array_key_exists($entity_id, $pbk_array)) 64 { 65 $field_name=$entity_id."_listprice"; 66 $field_name_array[]="'".$field_name."'"; 67 } 68 } 69 70 71 $other_text = ' 72 <table border="0" cellpadding="1" cellspacing="0" width="90%" align="center"> 73 <form name="addToPB" method="POST" id="addToPB"> 74 <tr> 75 <td align="center"> 76 <input name="product_id" type="hidden" value="'.$productid.'"> 77 <input name="idlist" type="hidden"> 78 <input name="viewname" type="hidden">'; 79 80 //we should not display the Add to PriceBook button if there is no pricebooks to associate 81 if($num_rows != $num_prod_rows) 82 $other_text .='<input class="crmbutton small save" type="submit" value="Add To PriceBook" onclick="return addtopricebook()"/> '; 83 84 $other_text .='<input title="'.$app_strings[LBL_CANCEL_BUTTON_TITLE].'" accessKey="'.$app_strings[LBL_CANCEL_BUTTON_KEY].'" class="crmbutton small cancel" onclick="window.history.back()" type="button" name="button" value="'.$app_strings[LBL_CANCEL_BUTTON_LABEL].'"></td>'; 85 $other_text .=' 86 </tr> 87 </table>'; 88 89 $smarty->assign("PRICEBOOKLISTHEADER", get_form_header($current_module_strings['LBL_LIST_PRICEBOOK_FORM_TITLE'], $other_text, false )); 90 91 $smarty->assign("FIELD_NAME_ARRAY",implode(",",$field_name_array)); 92 93 94 95 //List View Table Header 96 $list_header = ''; 97 $list_header .= '<tr>'; 98 $list_header .='<td class="lvtCol" width="9%"><input type="checkbox" name="selectall" onClick=\'toggleSelect(this.checked,"selected_id");updateAllListPrice("'.$unit_price.'") \'></td>'; 99 $list_header .= '<td class="lvtCol" width="45%">'.$mod_strings['LBL_PRICEBOOK'].'</td>'; 100 $list_header .= '<td class="lvtCol" width="23%">'.$mod_strings['LBL_PRODUCT_UNIT_PRICE'].'</td>'; 101 $list_header .= '<td class="lvtCol" width="23%">'.$mod_strings['LBL_PB_LIST_PRICE'].'</td>'; 102 $list_header .= '</tr>'; 103 104 $smarty->assign("LISTHEADER", $list_header); 105 106 $list_body =''; 107 for($i=0; $i<$num_rows; $i++) 108 { 109 110 $log->info("Products :: Showing Price Books to be added in the product"); 111 $entity_id = $adb->query_result($list_result,$i,"crmid"); 112 if(! array_key_exists($entity_id, $pbk_array)) 113 { 114 $list_body .= '<tr class="lvtColData" onmouseover="this.className=\'lvtColDataHover\'" onmouseout="this.className=\'lvtColData\'" bgcolor="white">'; 115 $field_name=$entity_id."_listprice"; 116 $list_body .= '<td><INPUT type=checkbox NAME="selected_id" id="check_'.$entity_id.'" value= '.$entity_id.' onClick=\'toggleSelectAll(this.name,"selectall");updateListPrice("'.$unit_price.'","'.$field_name.'",this)\'></td>'; 117 $list_body .= '<td>'.$adb->query_result($list_result,$i,"bookname").'</td>'; 118 $list_body .= '<td>'.$unit_price.'</td>'; 119 $list_body .= '<td><input type="text" name="'.$field_name.'" style="visibility:hidden;" id="'.$field_name.'"></td>'; 120 $list_body .= '</tr>'; 121 } 122 123 } 124 125 126 127 if($order_by !='') 128 $url_string .="&order_by=".$order_by; 129 if($sorder !='') 130 $url_string .="&sorder=".$sorder; 131 132 $smarty->assign("LISTENTITY", $list_body); 133 $smarty->assign("RETURN_ID", $productid); 134 135 $smarty->display("AddProductToPriceBooks.tpl"); 136 137 138 139 ?>
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 |