[Vtigercrm-commits] [vtiger-commits] r9682 - in /vtigercrm/branches/4.2: data/CRMEntity.php modules/Potentials/Opportunity.php

vtigercrm-commits at vtiger.fosslabs.com vtigercrm-commits at vtiger.fosslabs.com
Mon Oct 23 15:48:53 EDT 2006


Author: allanbush
Date: Mon Oct 23 13:48:51 2006
New Revision: 9682

Log:
Moved potential sales stage tracking code into it's proper module.

Modified:
    vtigercrm/branches/4.2/data/CRMEntity.php
    vtigercrm/branches/4.2/modules/Potentials/Opportunity.php

Modified: vtigercrm/branches/4.2/data/CRMEntity.php
==============================================================================
--- vtigercrm/branches/4.2/data/CRMEntity.php (original)
+++ vtigercrm/branches/4.2/data/CRMEntity.php Mon Oct 23 13:48:51 2006
@@ -612,20 +612,6 @@
 
 	  if($insertion_mode == 'edit')
 	  {
-		  if($_REQUEST['module'] == 'Potentials')
-		  {
-			  $dbquery = 'select sales_stage from potential where potentialid = '.$this->id;
-			  $sales_stage = $adb->query_result($adb->query($dbquery),0,'sales_stage');
-			  if($sales_stage != $_REQUEST['sales_stage'])
-			  {
-    				  $date_var = $adb->database->DBTimeStamp(date('YmdHis'));
-				  //$sql = "insert into potstagehistory values('',".$this->id.",".$_REQUEST['amount'].",'".$_REQUEST['sales_stage']."',".$_REQUEST['probability'].",".$_REQUEST['expectedrevenue'].",".$adb->formatString("potstagehistory","closedate",$_REQUEST['closingdate']).",".$adb->formatString("potstagehistory","lastmodified",$date_var).")";
-				  $id = $adb->getUniqueID('potstagehistory');
-				  $sql = "insert into potstagehistory values($id,".$this->id.",'".$_REQUEST['amount']."','".$sales_stage."','".$_REQUEST['probability']."',0,".$adb->formatString("potstagehistory","closedate",$_REQUEST['closingdate']).",".$date_var.")";
-				  $adb->query($sql);
-			  }
-		  }
-		
 		  //Check done by Don. If update is empty the the query fails
 		  if(trim($update) != '')
         	  {

Modified: vtigercrm/branches/4.2/modules/Potentials/Opportunity.php
==============================================================================
--- vtigercrm/branches/4.2/modules/Potentials/Opportunity.php (original)
+++ vtigercrm/branches/4.2/modules/Potentials/Opportunity.php Mon Oct 23 13:48:51 2006
@@ -337,6 +337,37 @@
         }
 
 
+	function save($module)
+	{
+		global $adb;
+
+		if($this->id) {
+			$sql = 'SELECT sales_stage
+				FROM potential
+				WHERE potentialid = '.$this->id;
+			$sales_stage = $adb->query_result($adb->query($sql),0,'sales_stage');
+		}
+
+		parent::save($module);
+
+		// update the sales stage history
+		if($this->mode == 'edit' && $sales_stage != $_REQUEST['sales_stage']) {
+			$date_var = $adb->database->DBTimeStamp(date('YmdHis'));
+			$id = $adb->getUniqueID('potstagehistory');
+			$amount = $_REQUEST['amount'] == '' ? 'NULL' : $adb->quote((float) $_REQUEST['amount']);
+			$probability = $_REQUEST['probability'] == '' ? 'NULL' : $adb->quote((float) $_REQUEST['probability']);
+			$sql = "INSERT INTO potstagehistory
+				VALUES (".$id.",
+					".$this->id.",
+					".$amount.",
+					".$adb->quote($sales_stage).",
+					".$probability.",
+					0,
+					".$adb->formatString("potstagehistory","closedate",$_REQUEST['closingdate']).",
+					".$date_var.")";
+			$adb->query($sql);
+		}
+	}
 
 	function save_relationship_changes($is_update)
     {





More information about the vtigercrm-commits mailing list