[Vtigercrm-commits] [vtiger-commits] r5029 - in /vtigercrm/trunk: Smarty/templates/DetailView.tpl modules/Webmails/Save.php
vtigercrm-commits at vtiger.fosslabs.com
vtigercrm-commits at vtiger.fosslabs.com
Sat Apr 8 05:40:17 EDT 2006
Author: mmbrich
Date: Sat Apr 8 03:40:14 2006
New Revision: 5029
Log:
Add to CRM button
on saving a new webmail to the CRM the save function will
do a record search on accounts/contacts/leads to find matches
to relate to the new email.
Modified:
vtigercrm/trunk/Smarty/templates/DetailView.tpl
vtigercrm/trunk/modules/Webmails/Save.php
Modified: vtigercrm/trunk/Smarty/templates/DetailView.tpl
==============================================================================
--- vtigercrm/trunk/Smarty/templates/DetailView.tpl (original)
+++ vtigercrm/trunk/Smarty/templates/DetailView.tpl Sat Apr 8 03:40:14 2006
@@ -141,6 +141,9 @@
<input title="{$APP.LBL_DELETE_BUTTON_TITLE}" accessKey="{$APP.LBL_DELETE_BUTTON_KEY}" class="small" onclick="this.form.return_module.value='{$MODULE}'; this.form.return_action.value='index'; this.form.action.value='Delete'; return confirm('{$APP.NTC_DELETE_CONFIRMATION}')" type="submit" name="Delete" value="{$APP.LBL_DELETE_BUTTON_LABEL}">
{/if}
+ {if $MODULE eq 'Webmails'}
+ <input title="Add to CRM" class="small" onclick="window.location='index.php?module={$MODULE}&action=Save&mailid={$ID}';return false;" type="submit" name="addtocrm" value="Add to CRM">
+ {/if}
{if $MODULE eq 'Leads' || $MODULE eq 'Contacts'}
{if $SENDMAILBUTTON eq 'permitted'}
<input title="{$APP.LBL_SENDMAIL_BUTTON_TITLE}" accessKey="{$APP.LBL_SENDMAIL_BUTTON_KEY}" class="small" onclick="this.form.return_module.value='{$MODULE}'; this.form.module.value='Emails';this.form.email_directing_module.value='{$REDIR_MOD}';this.form.return_action.value='DetailView';this.form.action.value='EditView';" type="submit" name="SendMail" value="{$APP.LBL_SENDMAIL_BUTTON_LABEL}">
Modified: vtigercrm/trunk/modules/Webmails/Save.php
==============================================================================
--- vtigercrm/trunk/modules/Webmails/Save.php (original)
+++ vtigercrm/trunk/modules/Webmails/Save.php Sat Apr 8 03:40:14 2006
@@ -39,14 +39,16 @@
if(isset($_REQUEST["email_body"]))
$msgData = $_REQUEST["email_body"];
-else {
- $email->loadMail();
- $msgData = $email->body;
-}
+else {
+ $email->loadMail();
+ $msgData = $email->body;
+ $subject = $email->subject;
+ $imported=true;
+}
if($email->relationship != 0)
-{
- $focus->column_fields['parent_id']=$email->relationship["id"];
-}
+{
+ $focus->column_fields['parent_id']=$email->relationship["id"];
+}
$focus->column_fields['subject']=$subject;
$focus->column_fields["activitytype"]="Emails";
@@ -61,20 +63,43 @@
$focus->column_fields["description"]=strip_tags($tmpBody);
$focus->save("Emails");
-$return_id = $_REQUEST["mailid"];
-$return_module='Webmails';
-$return_action='ListView';
-
-if(isset($_REQUEST["send_mail"]) && $_REQUEST["send_mail"] == "true") {
- require_once("sendmail.php");
- global $adb;
- $sql = "select email1, first_name,last_name from users where id='".$current_user->id."'";
- $res = $adb->query($sql);
- $emailaddr = $adb->query_result($res,0,'email1');
- $who = $adb->query_result($res,0,'first_name')." ".$adb->query_result($res,0,'last_name');
- sendmail($to_address,$cc_address,$bcc_address,$emailaddr,$who,$subject,$msgData);
-} else
- header("Location: index.php?action=$return_action&module=$return_module&mailid=$return_id");
-
-return;
-?>
+$return_id = $_REQUEST["mailid"];
+$return_module='Webmails';
+$return_action='DetailView';
+
+
+// check for relationships
+if(!isset($_REQUEST["email_body"])) {
+ $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(isset($_REQUEST["send_mail"]) && $_REQUEST["send_mail"] == "true") {
+ require_once("sendmail.php");
+ global $adb;
+ $sql = "select email1, first_name,last_name from users where id='".$current_user->id."'";
+ $res = $adb->query($sql);
+ $emailaddr = $adb->query_result($res,0,'email1');
+ $who = $adb->query_result($res,0,'first_name')." ".$adb->query_result($res,0,'last_name');
+ sendmail($to_address,$cc_address,$bcc_address,$emailaddr,$who,$subject,$msgData);
+} else
+ header("Location: index.php?action=$return_action&module=$return_module&record=$return_id");
+
+return;
+?>
More information about the vtigercrm-commits
mailing list