[Vtigercrm-commits] [vtiger-commits] r7173 - /vtigercrm/trunk/modules/Campaigns/updateRelations.php

vtigercrm-commits at vtiger.fosslabs.com vtigercrm-commits at vtiger.fosslabs.com
Fri Jun 16 04:55:47 EDT 2006


Author: saraj
Date: Fri Jun 16 02:55:44 2006
New Revision: 7173

Log:
changes made to update lead data in campaign RL

Modified:
    vtigercrm/trunk/modules/Campaigns/updateRelations.php

Modified: vtigercrm/trunk/modules/Campaigns/updateRelations.php
==============================================================================
--- vtigercrm/trunk/modules/Campaigns/updateRelations.php (original)
+++ vtigercrm/trunk/modules/Campaigns/updateRelations.php Fri Jun 16 02:55:44 2006
@@ -12,7 +12,19 @@
 require_once('include/database/PearDatabase.php');
 global $adb;
 $idlist = $_REQUEST['idlist'];
-$returnmodule = $_REQUEST['return_module'];
+$update_mod = $_REQUEST['destination_module'];
+if($update_mod == 'Leads')
+{
+	$rel_table = 'vtiger_campaignleadrel';
+	$mod_table = 'vtiger_leaddetails';
+	$mod_field = 'leadid';
+}
+elseif($update_mod == 'Contacts')
+{
+	$rel_table = 'vtiger_campaigncontrel';
+	$mod_table = 'vtiger_contactdetails';
+	$mod_field = 'contactid';
+}
 if(isset($_REQUEST['idlist']) && $_REQUEST['idlist'] != '')
 {
 	//split the string and store in an array
@@ -21,9 +33,9 @@
 	{
 		if($id != '')
 		{
-		    $sql = "insert into  vtiger_campaigncontrel values(".$_REQUEST["parentid"]." , ".$id.")";
+		    $sql = "insert into  ".$rel_table." values(".$_REQUEST["parentid"]." , ".$id.")";
 	            $adb->query($sql);
-		    $sql = "update vtiger_contactdetails set campaignid = ".$_REQUEST["parentid"]." where contactid = ".$id;
+		    $sql = "update ".$mod_table." set campaignid = ".$_REQUEST["parentid"]." where ".$mod_field." = ".$id;
                     $adb->query($sql);
 		}
 	}
@@ -31,9 +43,9 @@
 }
 elseif(isset($_REQUEST['entityid']) && $_REQUEST['entityid'] != '')
 {	
-		$sql = "insert into vtiger_campaigncontrel values(".$_REQUEST["parid"].",".$_REQUEST["entityid"].")";
+		$sql = "insert into ".$rel_table." values(".$_REQUEST["parid"].",".$_REQUEST["entityid"].")";
 		$adb->query($sql);
-		$sql = "update vtiger_contactdetails set campaignid = ".$_REQUEST["parid"]." where contactid = ".$_REQUEST["entityid"];
+		$sql = "update ".$mod_table." set campaignid = ".$_REQUEST["parid"]." where ".$mod_field." = ".$_REQUEST["entityid"];
                 $adb->query($sql);
  		header("Location: index.php?action=CallRelatedList&module=Campaigns&record=".$_REQUEST["parid"]);
 }





More information about the vtigercrm-commits mailing list