[Vtigercrm-commits] [vtiger-commits] r5034 - in /vtigercrm/trunk/modules/Webmails: Save.php Webmail.php showOverviewUI.php

vtigercrm-commits at vtiger.fosslabs.com vtigercrm-commits at vtiger.fosslabs.com
Sat Apr 8 06:33:04 EDT 2006


Author: mmbrich
Date: Sat Apr  8 04:33:02 2006
New Revision: 5034

Log:
cleaned up relationship checking code


Modified:
    vtigercrm/trunk/modules/Webmails/Save.php
    vtigercrm/trunk/modules/Webmails/Webmail.php
    vtigercrm/trunk/modules/Webmails/showOverviewUI.php

Modified: vtigercrm/trunk/modules/Webmails/Save.php
==============================================================================
--- vtigercrm/trunk/modules/Webmails/Save.php (original)
+++ vtigercrm/trunk/modules/Webmails/Save.php Sat Apr  8 04:33:02 2006
@@ -73,20 +73,9 @@
     $return_id = $focus->id;
     $return_module='Emails';
     $return_action='DetailView';
-    $tables = array("account"=>array("email1","email2"),"contactdetails"=>array("email"),"leaddetails"=>array("email"));
-    $ids = array("accountid","contactid","leadid");
-    $i=0;
-    foreach($tables as $key=>$value) {
-	for($j=0;$j<count($tables[$key]);$j++) {
-		$q = "SELECT ".$ids[$i]." AS id FROM ".$key." WHERE ".$tables[$key][$j]."='".$email->from."'";
-		$rs = $adb->query($q);
-		if($adb->num_rows($rs) > 0) {
-			$entity = $adb->fetch_array($rs);
-			$q = "INSERT INTO seactivityrel (crmid,activityid) VALUES ('".$entity["id"]."','".$focus->id."')";
-			$rs = $adb->query($q);
-		}
-	}
-	$i++;
+    if($email->relationship != 0) {
+	$q = "INSERT INTO seactivityrel (crmid,activityid) VALUES ('".$email->relationship["id"]."','".$focus->id."')";
+	$rs = $adb->query($q);
     }
 }
 

Modified: vtigercrm/trunk/modules/Webmails/Webmail.php
==============================================================================
--- vtigercrm/trunk/modules/Webmails/Webmail.php (original)
+++ vtigercrm/trunk/modules/Webmails/Webmail.php Sat Apr  8 04:33:02 2006
@@ -118,44 +118,30 @@
     	return $ret = Array("header"=>$mailHeader);
 }
 function find_relationships($db,$from) {
-
+
 	// leads search
-	$sql = "SELECT * from leaddetails left join crmentity on crmentity.crmid=leaddetails.leadid where leaddetails.email = '".$from."' AND crmentity.deleted='0' AND crmentity.presence='0'";
+	$sql = "SELECT * from leaddetails left join crmentity on crmentity.crmid=leaddetails.leadid where leaddetails.email = '".$from."' AND crmentity.deleted='0'";
+	$res = $db->query($sql,true,"Error: "."<BR>$query");
+	$numRows = $db->num_rows($res);
+	if($numRows > 0)
+		return array('type'=>"Leads",'id'=>$db->query_result($res,0,"leadid"),'name'=>$db->query_result($res,0,"firstname")." ".$db->query_result($res,0,"lastname"));
+
+	// contacts search
+	$sql = "SELECT * from contactdetails left join crmentity on crmentity.crmid=contactdetails.contactid where contactdetails.email = '".$from."'  AND crmentity.deleted='0'";
+	$res = $db->query($sql,true,"Error: "."<BR>$query");
+	$numRows = $db->num_rows($res);
+	if($numRows > 0)
+		return array('type'=>"Contacts",'id'=>$db->query_result($res,0,"contactid"),'name'=>$db->query_result($res,0,"firstname")." ".$db->query_result($res,0,"lastname"));
+
+	// accounts search
+	$sql = "SELECT * from account left join crmentity on crmentity.crmid=account.accountid where account.email1 = '".$from."' OR account.email1='".$from."'  AND crmentity.deleted='0'";
 	$res = $db->query($sql,true,"Error: "."<BR>$query");
 	$numRows = $db->num_rows($res);
 	if($numRows > 0)
-		return array('type'=>"Leads",'id'=>$db->query_result($res,0,"leadid"),'name'=>$db->query_result($res,0,"firstname")." ".$db->query_result($res,0,"lastname"));
-
-	// contacts search
-	$sql = "SELECT * from contactdetails left join crmentity on crmentity.crmid=contactdetails.contactid where contactdetails.email = '".$from."'  AND crmentity.deleted='0'";
-	$res = $db->query($sql,true,"Error: "."<BR>$query");
-	$numRows = $db->num_rows($res);
-	if($numRows > 0)
-		return array('type'=>"Contacts",'id'=>$db->query_result($res,0,"contactid"),'name'=>$db->query_result($res,0,"firstname")." ".$db->query_result($res,0,"lastname"));
-
-	// accounts search
-	$sql = "SELECT * from account left join crmentity on crmentity.crmid=account.accountid where account.email1 = '".$from."' OR account.email1='".$from."'  AND crmentity.deleted='0' AND crmentity.presence='0'";
-	$res = $db->query($sql,true,"Error: "."<BR>$query");
-	$numRows = $db->num_rows($res);
-	if($numRows > 0)
-		return array('type'=>"Accounts",'id'=>$db->query_result($res,0,"accountid"),'name'=>$db->query_result($res,0,"accountname"));
-/*
-	// user search
-	$sql = "SELECT * from users where users.email1 = '".$from."' OR users.email2='".$from."' AND deleted='0'";
-	$res = $db->query($sql,true,"Error: "."<BR>$query");
-	$numRows = $db->num_rows($res);
-	if($numRows > 0)
-		return array('type'=>"User",'id'=>$db->query_result($res,0,"userid"));
-
-	// vendor search
-	$sql = "SELECT * from vendor left join crmentity on crmentity.crmid=vendor.vendorid where vendor.email = '".$from."'";
-	$res = $db->query($sql,true,"Error: "."<BR>$query");
-	$numRows = $db->num_rows($res);
-	if($numRows > 0)
-		return array('type'=>"Vendor",'id'=>$db->query_result($res,0,"vendorid"));
-*/
-	return 0;
-}
+		return array('type'=>"Accounts",'id'=>$db->query_result($res,0,"accountid"),'name'=>$db->query_result($res,0,"accountname"));
+
+	return 0;
+}
 
 function dl_inline($mailid,$mbox) {
         $struct = imap_fetchstructure($mbox, $mailid);

Modified: vtigercrm/trunk/modules/Webmails/showOverviewUI.php
==============================================================================
--- vtigercrm/trunk/modules/Webmails/showOverviewUI.php (original)
+++ vtigercrm/trunk/modules/Webmails/showOverviewUI.php Sat Apr  8 04:33:02 2006
@@ -143,12 +143,12 @@
 				<td width="50%">
 				<table border=0 cellspacing=0 cellpadding=0 width="50%" align="left">
 					<?
-					$relationship = $webmail->relationship;
-					if($relationship != 0) {
+					$relationship = $webmail->relationship;
+					if($relationship != 0) {
 						echo '<tr><td nowrap align="left" width="50%" valign="top"><b>Relationship Found: </b></td></tr>';
 						echo "<tr><td width='100%' align='left' nowrap>Type: ".$relationship["type"]."</td></tr>";
 						echo "<tr><td width='100%' align='left' nowrap>Name: <a href='index.php?module=".$relationship["type"]."&action=DetailView&record=".$relationship["id"]."'>".$relationship["name"]."</a></td></tr>";
-					} else {
+					} else {
 						echo '<tr><td nowrap align="left" width="50%" valign="top"><b>Create New Relationship: </b></td></tr>';
 						echo "<tr><td width='100%' align='left'><a href='index.php?module=Leads&action=EditView&return_module=Webmails&return_action=ListView'>New Lead</a></td></tr>";
 						echo "<tr><td width='100%' align='left'><a href='index.php?module=Contacts&action=EditView&return_module=Webmails&return_action=ListView'>New Contact</a></td></tr>";





More information about the vtigercrm-commits mailing list