[ 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 13 require_once ("include/database/PearDatabase.php"); 14 $conn = new PearDatabase(); 15 16 $ajax_val = $_REQUEST['ajax']; 17 18 if($ajax_val == 1) 19 { 20 $crate = $_REQUEST['crate']; 21 $conn->println('conversion rate = '.$crate); 22 23 $query = "update vtiger_currency_info set conversion_rate='".$_REQUEST['crate']."' where id=1"; 24 $result = $conn->query($query); 25 26 //array should be id || vtiger_fieldname => vtiger_tablename 27 $modules_array = Array( 28 "accountid||annualrevenue" => "account", 29 30 "leadid||annualrevenue" => "leaddetails", 31 32 "potentialid||amount" => "potential", 33 34 "productid||unit_price" => "products", 35 36 "salesorderid||salestax" => "salesorder", 37 "salesorderid||adjustment" => "salesorder", 38 "salesorderid||total" => "salesorder", 39 "salesorderid||subtotal" => "salesorder", 40 41 "purchaseorderid||salestax" => "purchaseorder", 42 "purchaseorderid||adjustment" => "purchaseorder", 43 "purchaseorderid||total" => "purchaseorder", 44 "purchaseorderid||subtotal" => "purchaseorder", 45 46 "quoteid||tax" => "quotes", 47 "quoteid||adjustment" => "quotes", 48 "quoteid||total" => "quotes", 49 "quoteid||subtotal" => "quotes", 50 51 "invoiceid||salestax" => "invoice", 52 "invoiceid||adjustment" => "invoice", 53 "invoiceid||total" => "invoice", 54 "invoiceid||subtotal" => "invoice", 55 ); 56 57 foreach($modules_array as $fielddetails => $table) 58 { 59 $temp = explode("||",$fielddetails); 60 $id_name = $temp[0]; 61 $fieldname = $temp[1]; 62 63 $res = $conn->query("select $id_name, $fieldname from $table"); 64 $record_count = $conn->num_rows($res); 65 66 for($i=0;$i<$record_count;$i++) 67 { 68 $recordid = $conn->query_result($res,$i,$id_name); 69 $old_value = $conn->query_result($res,$i,$fieldname); 70 71 //calculate the new value 72 $new_value = $old_value/$crate;//convertToDollar($old_value,$crate); 73 $conn->println("old value = $old_value && new value = $new_value"); 74 75 $update_query = "update $table set $fieldname='".$new_value."' where $id_name=$recordid"; 76 $update_result = $conn->query($update_query); 77 } 78 } 79 } 80 81 82 ?>
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 |