[Vtigercrm-commits] [vtiger-commits] r4780 - in /vtigercrm/trunk/modules: Invoice/Save.php Quotes/Save.php SalesOrder/Save.php
vtigercrm-commits at vtiger.fosslabs.com
vtigercrm-commits at vtiger.fosslabs.com
Thu Mar 30 08:12:21 EST 2006
Author: saraj
Date: Thu Mar 30 06:12:11 2006
New Revision: 4780
Log:
* Removed the functions updateStk, sendMail about stock, getPrdQtyInStck, getPrdReOrderLevel and getPrdHandler because all these are common for SalesOrder, Quotes and Invoice and these function moved to InventoryUtils.php file
Modified:
vtigercrm/trunk/modules/Invoice/Save.php
vtigercrm/trunk/modules/Quotes/Save.php
vtigercrm/trunk/modules/SalesOrder/Save.php
Modified: vtigercrm/trunk/modules/Invoice/Save.php
==============================================================================
--- vtigercrm/trunk/modules/Invoice/Save.php (original)
+++ vtigercrm/trunk/modules/Invoice/Save.php Thu Mar 30 06:12:11 2006
@@ -79,7 +79,7 @@
$query ="insert into invoiceproductrel values(".$focus->id.",".$prod_id.",".$qty.",".$listprice.")";
$adb->query($query);
//Updating the Quantity in Stock in the Product Table
- updateStk($prod_id,$qty,$focus->mode,$ext_prod_arr);
+ updateStk($prod_id,$qty,$focus->mode,$ext_prod_arr,'Invoice');
}
}
$return_id = $focus->id;
@@ -92,114 +92,6 @@
$local_log->debug("Saved record with id of ".$return_id);
-function updateStk($product_id,$qty,$mode,$ext_prod_arr)
-{
- global $adb,$current_user;
- $prod_name = getProductName($product_id);
- $qtyinstk= getPrdQtyInStck($product_id);
- if($mode == 'edit')
- {
- if(array_key_exists($product_id,$ext_prod_arr))
- {
- $old_qty = $ext_prod_arr[$product_id];
- if($old_qty > $qty)
- {
-
- $diff_qty = $old_qty - $qty;
- $upd_qty = $qtyinstk+$diff_qty;
- //Updating the Product Quantity
- updateProductQty($product_id, $upd_qty);
- sendPrdStckMail($product_id,$upd_qty,$prod_name);
-
- }
- elseif($old_qty < $qty)
- {
- $diff_qty = $qty - $old_qty;
- $upd_qty = $qtyinstk-$diff_qty;
- updateProductQty($product_id, $upd_qty);
- sendPrdStckMail($product_id,$upd_qty,$prod_name);
-
-
- }
- }
- else
- {
- $upd_qty = $qtyinstk-$qty;
- updateProductQty($product_id, $upd_qty);
- sendPrdStckMail($product_id,$upd_qty,$prod_name);
-
- }
- }
- else
- {
-
- $upd_qty = $qtyinstk-$qty;
- updateProductQty($product_id, $upd_qty);
- sendPrdStckMail($product_id,$upd_qty,$prod_name);
- }
-
- //Check for reorder level and send mail
-
-}
-
-function sendPrdStckMail($product_id,$upd_qty,$prod_name)
-{
- global $current_user,$adb;
- $reorderlevel = getPrdReOrderLevel($product_id);
- if($upd_qty < $reorderlevel)
- {
- //send mail to the handler
- $handler=getPrdHandler($product_id);
- $handler_name = getUserName($handler);
- $to_address= getUserEmail($handler);
- //Get the email details from database;
- $query = "select * from inventorynotification where notificationname='InvoiceNotification'";
- $result = $adb->query($query);
-
- $subject = $adb->query_result($result,0,'notificationsubject');
- $body = $adb->query_result($result,0,'notificationbody');
-
- $subject = str_replace('{PRODUCTNAME}',$prod_name,$subject);
- $body = str_replace('{HANDLER}',$handler_name,$body);
- $body = str_replace('{PRODUCTNAME}',$prod_name,$body);
- $body = str_replace('{CURRENTSTOCK}',$upd_qty,$body);
- $body = str_replace('{REORDERLEVELVALUE}',$reorderlevel,$body);
- $body = str_replace('{CURRENTUSER}',$current_user->user_name,$body);
-
- $mail_status = send_mail("Invoice",$to_address,$current_user->user_name,$current_user->email1,$subject,$body);
- }
-}
-
-
-function getPrdQtyInStck($product_id)
-{
- global $adb;
- $query1 = "select qtyinstock from products where productid=".$product_id;
- $result=$adb->query($query1);
- $qtyinstck= $adb->query_result($result,0,"qtyinstock");
- return $qtyinstck;
-
-
-}
-function getPrdReOrderLevel($product_id)
-{
- global $adb;
- $query1 = "select reorderlevel from products where productid=".$product_id;
- $result=$adb->query($query1);
- $reorderlevel= $adb->query_result($result,0,"reorderlevel");
- return $reorderlevel;
-
-}
-function getPrdHandler($product_id)
-{
- global $adb;
- $query1 = "select handler from products where productid=".$product_id;
- $result=$adb->query($query1);
- $handler= $adb->query_result($result,0,"handler");
- return $handler;
-
-}
-
//code added for returning back to the current view after edit from list view
if($_REQUEST['return_viewname'] == '') $return_viewname='0';
if($_REQUEST['return_viewname'] != '')$return_viewname=$_REQUEST['return_viewname'];
Modified: vtigercrm/trunk/modules/Quotes/Save.php
==============================================================================
--- vtigercrm/trunk/modules/Quotes/Save.php (original)
+++ vtigercrm/trunk/modules/Quotes/Save.php Thu Mar 30 06:12:11 2006
@@ -33,26 +33,9 @@
$log->debug("Inside Quote Save");
$focus = new Quote();
-if(isset($_REQUEST['record']))
-{
- $focus->id = $_REQUEST['record'];
- $log->debug("Quote ID ".$focus->id);
-}
-if(isset($_REQUEST['mode']))
-{
- $focus->mode = $_REQUEST['mode'];
- $log->debug("Mode is ".$focus->mode);
-}
-foreach($focus->column_fields as $fieldname => $val)
-{
- if(isset($_REQUEST[$fieldname]))
- {
- $value = $_REQUEST[$fieldname];
- $focus->column_fields[$fieldname] = $value;
- }
-
-}
+setObjectValuesFromRequest(&$focus);
+
$log->debug("The Field Value Array -----> ".$focus->column_fields);
$focus->save("Quotes");
@@ -94,8 +77,8 @@
$query ="insert into quotesproductrel values(".$focus->id.",".$prod_id.",".$qty.",".$listprice.")";
$adb->query($query);
//Checking the re-order level and sending mail
- updateStk($prod_id,$qty,$focus->mode,$ext_prod_arr);
- }
+ updateStk($prod_id,$qty,$focus->mode,$ext_prod_arr,'Quotes');
+ }
}
@@ -109,122 +92,6 @@
$local_log->debug("Saved record with id of ".$return_id);
-function updateStk($product_id,$qty,$mode,$ext_prod_arr)
-{
- global $log;
- global $adb;
- global $current_user;
- $log->debug("Inside Quote updateStk function.");
- $log->debug("Product Id is".$product_id);
- $log->debug("Qty is".$qty);
-
- $prod_name = getProductName($product_id);
- $qtyinstk= getPrdQtyInStck($product_id);
- $log->debug("Prd Qty in Stock ".$qtyinstk);
- if($mode == 'edit')
- {
- if(array_key_exists($product_id,$ext_prod_arr))
- {
- $old_qty = $ext_prod_arr[$product_id];
- if($old_qty > $qty)
- {
-
- $diff_qty = $old_qty - $qty;
- $upd_qty = $qtyinstk+$diff_qty;
- sendPrdStckMail($product_id,$upd_qty,$prod_name,$qtyinstk,$qty);
-
- }
- elseif($old_qty < $qty)
- {
- $diff_qty = $qty - $old_qty;
- $upd_qty = $qtyinstk-$diff_qty;
- sendPrdStckMail($product_id,$upd_qty,$prod_name,$qtyinstk,$qty);
-
-
- }
- }
- else
- {
- $upd_qty = $qtyinstk-$qty;
- sendPrdStckMail($product_id,$upd_qty,$prod_name,$qtyinstk,$qty);
-
- }
- }
- else
- {
-
- $upd_qty = $qtyinstk-$qty;
- sendPrdStckMail($product_id,$upd_qty,$prod_name,$qtyinstk,$qty);
- }
-
-}
-
-function sendPrdStckMail($product_id,$upd_qty,$prod_name,$qtyinstk,$qty)
-{
- global $current_user;
- global $adb;
- global $log;
- $reorderlevel = getPrdReOrderLevel($product_id);
- $log->debug("Prd reorder level ".$reorderlevel);
- if($upd_qty < $reorderlevel)
- {
-
- //send mail to the handler
- $log->debug("Sending mail to handler ");
- $handler=getPrdHandler($product_id);
- $handler_name = getUserName($handler);
- $log->debug("Handler Name is ".$handler_name);
- $to_address= getUserEmail($handler);
- $log->debug("Handler Email is ".$to_address);
- //Get the email details from database;
- $query = "select * from inventorynotification where notificationname='QuoteNotification'";
- $result = $adb->query($query);
-
- $subject = $adb->query_result($result,0,'notificationsubject');
- $body = $adb->query_result($result,0,'notificationbody');
-
- $subject = str_replace('{PRODUCTNAME}',$prod_name,$subject);
- $body = str_replace('{HANDLER}',$handler_name,$body);
- $body = str_replace('{PRODUCTNAME}',$prod_name,$body);
- $body = str_replace('{CURRENTSTOCK}',$qtyinstk,$body);
- $body = str_replace('{QUOTEQUANTITY}',$qty,$body);
- $body = str_replace('{CURRENTUSER}',$current_user->user_name,$body);
-
- $mail_status = send_mail("Quotes",$to_address,$current_user->user_name,$current_user->email1,$subject,$body);
- }
-
-}
-
-
-function getPrdQtyInStck($product_id)
-{
- global $adb;
- $query1 = "select qtyinstock from products where productid=".$product_id;
- $result=$adb->query($query1);
- $qtyinstck= $adb->query_result($result,0,"qtyinstock");
- return $qtyinstck;
-
-
-}
-function getPrdReOrderLevel($product_id)
-{
- global $adb;
- $query1 = "select reorderlevel from products where productid=".$product_id;
- $result=$adb->query($query1);
- $reorderlevel= $adb->query_result($result,0,"reorderlevel");
- return $reorderlevel;
-
-}
-function getPrdHandler($product_id)
-{
- global $adb;
- $query1 = "select handler from products where productid=".$product_id;
- $result=$adb->query($query1);
- $handler= $adb->query_result($result,0,"handler");
- return $handler;
-
-}
-
//code added for returning back to the current view after edit from list view
if($_REQUEST['return_viewname'] == '') $return_viewname='0';
if($_REQUEST['return_viewname'] != '')$return_viewname=$_REQUEST['return_viewname'];
Modified: vtigercrm/trunk/modules/SalesOrder/Save.php
==============================================================================
--- vtigercrm/trunk/modules/SalesOrder/Save.php (original)
+++ vtigercrm/trunk/modules/SalesOrder/Save.php Thu Mar 30 06:12:11 2006
@@ -78,7 +78,7 @@
$query ="insert into soproductrel values(".$focus->id.",".$prod_id.",".$qty.",".$listprice.")";
$adb->query($query);
- updateStk($prod_id,$qty,$focus->mode,$ext_prod_arr);
+ updateStk($prod_id,$qty,$focus->mode,$ext_prod_arr,'SalesOrder');
}
}
$return_id = $focus->id;
@@ -91,111 +91,6 @@
$local_log->debug("Saved record with id of ".$return_id);
-function updateStk($product_id,$qty,$mode,$ext_prod_arr)
-{
- global $adb;
- global $current_user;
- $prod_name = getProductName($product_id);
- $qtyinstk= getPrdQtyInStck($product_id);
-
- if($mode == 'edit')
- {
- if(array_key_exists($product_id,$ext_prod_arr))
- {
- $old_qty = $ext_prod_arr[$product_id];
- if($old_qty > $qty)
- {
-
- $diff_qty = $old_qty - $qty;
- $upd_qty = $qtyinstk+$diff_qty;
- sendPrdStckMail($product_id,$upd_qty,$prod_name,$qtyinstk,$qty);
-
- }
- elseif($old_qty < $qty)
- {
- $diff_qty = $qty - $old_qty;
- $upd_qty = $qtyinstk-$diff_qty;
- sendPrdStckMail($product_id,$upd_qty,$prod_name,$qtyinstk,$qty);
-
-
- }
- }
- else
- {
- $upd_qty = $qtyinstk-$qty;
- sendPrdStckMail($product_id,$upd_qty,$prod_name,$qtyinstk,$qty);
-
- }
- }
- else
- {
-
- $upd_qty = $qtyinstk-$qty;
- sendPrdStckMail($product_id,$upd_qty,$prod_name,$qtyinstk,$qty);
- }
-
-}
-
-
-function sendPrdStckMail($product_id,$upd_qty,$prod_name,$qtyinstk,$qty)
-{
- global $current_user;
- global $adb;
- $reorderlevel = getPrdReOrderLevel($product_id);
- if($upd_qty < $reorderlevel)
- {
-
- //send mail to the handler
- $handler=getPrdHandler($product_id);
- $handler_name = getUserName($handler);
- $to_address= getUserEmail($handler);
- //Get the email details from database;
- $query = "select * from inventorynotification where notificationname='SalesOrderNotification'";
- $result = $adb->query($query);
-
- $subject = $adb->query_result($result,0,'notificationsubject');
- $body = $adb->query_result($result,0,'notificationbody');
-
- $subject = str_replace('{PRODUCTNAME}',$prod_name,$subject);
- $body = str_replace('{HANDLER}',$handler_name,$body);
- $body = str_replace('{PRODUCTNAME}',$prod_name,$body);
- $body = str_replace('{CURRENTSTOCK}',$qtyinstk,$body);
- $body = str_replace('{SOQUANTITY}',$qty,$body);
- $body = str_replace('{CURRENTUSER}',$current_user->user_name,$body);
-
- $mail_status = send_mail("SalesOrder",$to_address,$current_user->user_name,$current_user->email1,$subject,$body);
- }
-}
-
-function getPrdQtyInStck($product_id)
-{
- global $adb;
- $query1 = "select qtyinstock from products where productid=".$product_id;
- $result=$adb->query($query1);
- $qtyinstck= $adb->query_result($result,0,"qtyinstock");
- return $qtyinstck;
-
-
-}
-function getPrdReOrderLevel($product_id)
-{
- global $adb;
- $query1 = "select reorderlevel from products where productid=".$product_id;
- $result=$adb->query($query1);
- $reorderlevel= $adb->query_result($result,0,"reorderlevel");
- return $reorderlevel;
-
-}
-function getPrdHandler($product_id)
-{
- global $adb;
- $query1 = "select handler from products where productid=".$product_id;
- $result=$adb->query($query1);
- $handler= $adb->query_result($result,0,"handler");
- return $handler;
-
-}
-
//code added for returning back to the current view after edit from list view
if($_REQUEST['return_viewname'] == '') $return_viewname='0';
if($_REQUEST['return_viewname'] != '')$return_viewname=$_REQUEST['return_viewname'];
More information about the vtigercrm-commits
mailing list