[Vtigercrm-commits] [vtiger-commits] r7564 - /vtigercrm/trunk/modules/Migration/ModifyDatabase/42P2_to_50Alpha.php
vtigercrm-commits at vtiger.fosslabs.com
vtigercrm-commits at vtiger.fosslabs.com
Tue Jun 27 05:29:21 EDT 2006
Author: saraj
Date: Tue Jun 27 03:29:18 2006
New Revision: 7564
Log:
* Fixed the insert queries for emaildetails table
Modified:
vtigercrm/trunk/modules/Migration/ModifyDatabase/42P2_to_50Alpha.php
Modified: vtigercrm/trunk/modules/Migration/ModifyDatabase/42P2_to_50Alpha.php
==============================================================================
--- vtigercrm/trunk/modules/Migration/ModifyDatabase/42P2_to_50Alpha.php (original)
+++ vtigercrm/trunk/modules/Migration/ModifyDatabase/42P2_to_50Alpha.php Tue Jun 27 03:29:18 2006
@@ -2910,37 +2910,41 @@
$fieldid_array = Array("Leads"=>"$leadfieldid","Contacts"=>"$contactfieldid");
$idname_array = Array("Leads"=>"leadid","Contacts"=>"contactid");
-$query = 'select * from vtiger_seactivityrel where activityid in (select activityid from vtiger_activity where activitytype="Emails")';
+$query = 'select * from vtiger_seactivityrel where activityid in (select activityid from vtiger_activity where activitytype="Emails") group by activityid';
$result = $conn->query($query);
$numofrows = $conn->num_rows($result);
-$islists = '';
-$toemail = '';
for($i=0;$i<$numofrows;$i++)
{
- $parentid = $conn->query_result($result,$i,'crmid');
+ $toemail = "";
+ $idlists = '';
+
$emailid = $conn->query_result($result,$i,'activityid');
- $query = 'select setype from vtiger_crmentity where crmid='.$parentid;
- $result1 = $conn->query($query);
- $module = $conn->query_result($result1,0,'setype');
-
- $idlists = "$parentid@$fieldid_array[$module]|";
-
- if($module == 'Leads' || $module == 'Contacts')
+ $result1 = $conn->query("select * from vtiger_seactivityrel where activityid = $emailid");
+ while($row = $conn->fetch_array($result1))
{
- $result2 = $conn->query("select lastname, firstname, email from $obj_array[$module] where $idname_array[$module] = $parentid");
- $toemail = $conn->query_result($result2,0,'lastname').' '.$conn->query_result($result2,0,'firstname').'<'.$conn->query_result($result2,0,'email').'>###';
-
- //insert this idlists and toemail values in vtiger_emaildetails table
- $sql = "insert into vtiger_emaildetails values ($emailid,'',\"$toemail\",'','','',\"$idlists\",'SAVE')";
- Execute($sql);
+ $result2 = $conn->query("select setype from vtiger_crmentity where crmid=".$row['crmid']);
+ $module = $conn->query_result($result2,0,'setype');
+ $idlists .= $row['crmid']."@$fieldid_array[$module]|";
+
+ if($module == 'Leads' || $module == 'Contacts')
+ {
+ $result3 = $conn->query("select lastname, firstname, email from $obj_array[$module] where $idname_array[$module] = ".$row['crmid']);
+
+ $toemail .= $conn->query_result($result3,0,'lastname')." ".$conn->query_result($result3,0,'firstname')."<".$conn->query_result($result3,0,'email').">###";
+ }
+ else
+ {
+ //the parent is not a Lead or Contact. so we have avoided the insert query
+ }
}
- else
- {
- //the parent is not a Lead or Contact. so we have avoided the insert query
- }
-}
+
+ //insert this idlists and toemail values in vtiger_emaildetails table
+ $sql = "insert into vtiger_emaildetails values ($emailid,'',\"$toemail\",'','','',\"$idlists\",'SAVE')";
+ Execute($sql);
+}
+
$update_query5 = "update vtiger_field set quickcreate=1, quickcreatesequence=NULL where tabid in (10,14)";
Execute($update_query5);
More information about the vtigercrm-commits
mailing list