[Vtigercrm-commits] [vtiger-commits] r10394 - in /vtigercrm/branches/5.0.3: Smarty/templates/ include/utils/ modules/HelpDesk/ modules/HelpDesk/language/ modules/Potentials/
vtigercrm-commits at vtiger.fosslabs.com
vtigercrm-commits at vtiger.fosslabs.com
Thu Mar 8 09:22:18 EST 2007
Author: saraj
Date: Thu Mar 8 07:22:04 2007
New Revision: 10394
Log:
Enabled send mail for ajax edit in helpdesk tickets
Modified:
vtigercrm/branches/5.0.3/Smarty/templates/DisplayFields.tpl
vtigercrm/branches/5.0.3/include/utils/CommonUtils.php
vtigercrm/branches/5.0.3/modules/HelpDesk/DetailViewAjax.php
vtigercrm/branches/5.0.3/modules/HelpDesk/Save.php
vtigercrm/branches/5.0.3/modules/HelpDesk/language/en_us.lang.php
vtigercrm/branches/5.0.3/modules/Potentials/DetailViewAjax.php
Modified: vtigercrm/branches/5.0.3/Smarty/templates/DisplayFields.tpl
==============================================================================
--- vtigercrm/branches/5.0.3/Smarty/templates/DisplayFields.tpl (original)
+++ vtigercrm/branches/5.0.3/Smarty/templates/DisplayFields.tpl Thu Mar 8 07:22:04 2007
@@ -62,6 +62,9 @@
</td>
<td colspan=3>
<textarea class="detailedViewTextBox" tabindex="{$vt_tab}" onFocus="this.className='detailedViewTextBoxOn'" name="{$fldname}" onBlur="this.className='detailedViewTextBox'" cols="90" rows="8">{$fldvalue}</textarea>
+ {if $fldlabel eq $MOD.Solution}
+ <input type = "hidden" name="helpdesk_solution" value = '{$fldvalue}'>
+ {/if}
</td>
{elseif $uitype eq 21 || $uitype eq 24}
<td width=20% class="dvtCellLabel" align=right>
Modified: vtigercrm/branches/5.0.3/include/utils/CommonUtils.php
==============================================================================
--- vtigercrm/branches/5.0.3/include/utils/CommonUtils.php (original)
+++ vtigercrm/branches/5.0.3/include/utils/CommonUtils.php Thu Mar 8 07:22:04 2007
@@ -2704,12 +2704,94 @@
{
$fieldname = $adb->query_result($result,$i,'fieldname');
$fieldlabel = $adb->query_result($result,$i,'fieldlabel');
- $fieldslist[$fieldname] = $fieldlabel;
+ $fieldslist[$fieldname] = getTranslatedString($fieldlabel);
}
$log->debug("Exit from function getImportFieldsList($module)");
return $fieldslist;
}
+/** Function to get all the comments for a troubleticket
+ * @param int $ticketid -- troubleticket id
+ * return all the comments as a sequencial string which are related to this ticket
+**/
+function getTicketComments($ticketid)
+{
+ global $log;
+ $log->debug("Entering getTicketComments(".$ticketid.") method ...");
+ global $adb;
+
+ $commentlist = '';
+ $sql = "select * from vtiger_ticketcomments where ticketid=".$ticketid;
+ $result = $adb->query($sql);
+ for($i=0;$i<$adb->num_rows($result);$i++)
+ {
+ $comment = $adb->query_result($result,$i,'comments');
+ if($comment != '')
+ {
+ $commentlist .= '<br><br>'.$comment;
+ }
+ }
+ if($commentlist != '')
+ $commentlist = '<br><br> The comments are : '.$commentlist;
+
+ $log->debug("Exiting getTicketComments method ...");
+ return $commentlist;
+}
+
+function getTicketDetails($id,$whole_date)
+{
+ global $adb,$mod_strings;
+ if($whole_date['mode'] == 'edit')
+ {
+ $reply = $mod_strings["replied"];
+ $temp = "Re : ";
+ }
+ else
+ {
+ $reply = $mod_strings["created"];
+ $temp = " ";
+ }
+
+ $desc = $mod_strings['Ticket ID'] .' : '.$id.'<br> Ticket Title : '. $temp .' '.$whole_date['sub'];
+ $desc .= "<br><br>".$mod_strings['Hi']." ". $whole_date['parent_name'].",<br><br>".$mod_strings['LBL_PORTAL_BODY_MAILINFO']." ".$reply." ".$mod_strings['LBL_DETAIL']."<br>";
+ $desc .= "<br>".$mod_strings['Status']." : ".$whole_date['status'];
+ $desc .= "<br>".$mod_strings['Category']." : ".$whole_date['category'];
+ $desc .= "<br>".$mod_strings['Severity']." : ".$whole_date['severity'];
+ $desc .= "<br>".$mod_strings['Priority']." : ".$whole_date['priority'];
+ $desc .= "<br><br>".$mod_strings['Description']." : <br>".$whole_date['description'];
+ $desc .= "<br><br>".$mod_strings['Solution']." : <br>".$whole_date['solution'];
+ $desc .= getTicketComments($id);
+
+ $sql = "SELECT * FROM vtiger_ticketcf WHERE ticketid = \"".$id."\"";
+ $result = $adb->query($sql);
+ $cffields = $adb->getFieldsArray($result);
+ foreach ($cffields as $cfOneField)
+ {
+ if ($cfOneField != 'ticketid')
+ {
+ $cfData = $adb->query_result($result,0,$cfOneField);
+ $sql = "SELECT fieldlabel FROM vtiger_field WHERE columnname = \"$cfOneField\"";
+ $cfLabel = $adb->query_result($adb->query($sql),0,'fieldlabel');
+ $desc .= '<br><br>'.$cfLabel.' : <br>'.$cfData;
+ }
+ }
+ // end of contribution
+ $desc .= '<br><br><br>';
+ $desc .= '<br>'.$mod_strings["LBL_REGARDS"].',<br>'.$mod_strings["LBL_TEAM"].'.<br>';
+ return $desc;
+
+}
+function getPortalInfo_Ticket($id,$title,$contactname,$portal_url)
+{
+ global $mod_strings;
+ $bodydetails =$mod_strings['Dear']." ".$contactname.",<br><br>";
+ $bodydetails .= $mod_strings['reply'].' <b>'.$title.'</b>'.$mod_strings['customer_portal'];
+ $bodydetails .= $mod_strings["link"].'<br>';
+ $bodydetails .= $portal_url;
+ $bodydetails .= '<br><br>'.$mod_strings["Thanks"].'<br><br>'.$mod_strings["Support_team"];
+ return $bodydetails;
+}
+
?>
Modified: vtigercrm/branches/5.0.3/modules/HelpDesk/DetailViewAjax.php
==============================================================================
--- vtigercrm/branches/5.0.3/modules/HelpDesk/DetailViewAjax.php (original)
+++ vtigercrm/branches/5.0.3/modules/HelpDesk/DetailViewAjax.php Thu Mar 8 07:22:04 2007
@@ -22,7 +22,7 @@
$crmid = $_REQUEST["recordid"];
$tablename = $_REQUEST["tableName"];
$fieldname = $_REQUEST["fldName"];
- $fieldvalue = utf8RawUrlDecode($_REQUEST["fieldValue"]);
+ $fieldvalue = utf8RawUrlDecode($_REQUEST["fieldValue"]);
if($crmid != "")
{
@@ -45,7 +45,70 @@
$fldvalue = from_html($adb->formatString('vtiger_troubletickets','update_log',$fldvalue),($modObj->mode == 'edit')?true:false);
$modObj->save("HelpDesk");
-
+ global $mod_strings;
+ if($fieldname == "solution" || $fieldname == "comments" || $fieldname =="assigned_user_id" ||($fieldname == "ticketstatus" && $fieldvalue == $mod_strings['Closed']))
+ {
+ require_once('modules/Emails/mail.php');
+ $user_emailid = getUserEmailId('id',$modObj->column_fields['assigned_user_id']);
+
+ $subject = '[ Ticket ID : '.$modObj->id.' ] Re :'.$modObj->column_fields['ticket_title'];
+ $parent_id = $modObj->column_fields['parent_id'];
+ if($parent_id != '')
+ {
+ $parent_module = getSalesEntityType($parent_id);
+ if($parent_module == 'Contacts')
+ {
+ $result = $adb->query("select * from vtiger_contactdetails where contactid=".$parent_id);
+ $emailoptout = $adb->query_result($result,0,'emailoptout');
+ $contactname = $adb->query_result($result,0,'firstname').' '.$adb->query_result($result,0,'lastname');
+ $parentname = $contactname;
+ $contact_mailid = $adb->query_result($result,0,'email');
+ }
+ if($parent_module == 'Accounts')
+ {
+ $result = $adb->query("select * from vtiger_account where accountid=".$parent_id);
+ $emailoptout = $adb->query_result($result,0,'emailoptout');
+ $parentname = $adb->query_result($result,0,'accountname');
+ }
+ }
+ if($contact_mailid != '')
+ {
+ $sql = "select * from vtiger_portalinfo where user_name='".$contact_mailid."'";
+ $isactive = $adb->query_result($adb->query($sql),0,'isactive');
+ }
+ if($isactive == 1)
+ {
+ $url = "<a href='".$PORTAL_URL."/index.php?module=Tickets&action=index&ticketid=".$id."&fun=detail'>Ticket Details</a>";
+ $email_body = $subject.'<br><br>'.getPortalInfo_Ticket($modObj->id,$sub,$contactname,$url,"edit");
+ }
+ else
+ {
+ $data['sub']=$modObj->column_fields['ticket_title'];
+ $data['parent_name']=$parentname;
+ $data['status']=$modObj->column_fields['ticketstatus'];
+ $data['category']=$modObj->column_fields['ticketcategories'];
+ $data['severity'] = $modObj->column_fields['ticketseverities'];
+ $data['priority']=$modObj->column_fields['ticketpriorities'];
+ $data['description']=$modObj->column_fields['description'];
+ $data['solution'] = $modObj->column_fields['solution'];
+ $data['mode']= 'edit';
+ $email_body = getTicketDetails($modObj->id,$data);
+ }
+ if($user_emailid != '')
+ {
+ $mail_status = send_mail('HelpDesk',$user_emailid,$HELPDESK_SUPPORT_NAME,$HELPDESK_SUPPORT_EMAIL_ID,$subject,$email_body);
+ }
+ if($emailoptout == 0)
+ {
+ //send mail to parent
+ if($parent_id != '' )
+ {
+ $parent_email = getParentMailId($parent_module,$parent_id);
+ $mail_status = send_mail('HelpDesk',$parent_email,$HELPDESK_SUPPORT_NAME,$HELPDESK_SUPPORT_EMAIL_ID,$subject,$email_body);
+ }
+ }
+
+ }
//update the log information for ticket history
$adb->query("update vtiger_troubletickets set update_log=$fldvalue where ticketid=".$modObj->id);
Modified: vtigercrm/branches/5.0.3/modules/HelpDesk/Save.php
==============================================================================
--- vtigercrm/branches/5.0.3/modules/HelpDesk/Save.php (original)
+++ vtigercrm/branches/5.0.3/modules/HelpDesk/Save.php Thu Mar 8 07:22:04 2007
@@ -28,11 +28,15 @@
$focus = new HelpDesk();
setObjectValuesFromRequest(&$focus);
-
-global $adb;
+global $adb,$mod_strings;
//Added to update the ticket history
//Before save we have to construct the update log.
$mode = $_REQUEST['mode'];
+if($mode == 'edit')
+{
+ $usr_qry = $adb->query("select * from vtiger_crmentity where crmid='".$focus->id."'");
+ $old_user_id = $adb->query_result($usr_qry,0,"smownerid");
+}
$fldvalue = $focus->constructUpdateLog(&$focus, $mode, $_REQUEST['assigned_group_name'], $_REQUEST['assigntype']);
$fldvalue = from_html($adb->formatString('vtiger_troubletickets','update_log',$fldvalue),($mode == 'edit')?true:false);
@@ -120,46 +124,21 @@
}
if($isactive == 1)
{
- $bodydetails = "Dear ".$contactname.",<br><br>";
- $bodydetails .= 'There is a reply to <b>'.$_REQUEST['ticket_title'].'</b> in the "Customer Portal" at VTiger.';
- $bodydetails .= "You can use the following link to view the replies made:<br>";
-
- $bodydetails .= "<a href='".$PORTAL_URL."/index.php?module=Tickets&action=index&ticketid=".$focus->id."&fun=detail'>Ticket Details</a>";
- $bodydetails .= "<br><br>Thanks,<br><br> Vtiger Support Team ";
-
- $email_body = $bodysubject.'<br><br>'.$bodydetails;
-}
-else
-{
- $desc = 'Ticket ID : '.$focus->id.'<br> Ticket Title : '.$reply.$_REQUEST['ticket_title'];
- $desc .= "<br><br>Dear ".$parentname.",<br><br>The Ticket is replied and the details are : <br>";
- $desc .= "<br> Status : ".$focus->column_fields['ticketstatus'];
- $desc .= "<br> Category : ".$focus->column_fields['ticketcategories'];
- $desc .= "<br> Severity : ".$focus->column_fields['ticketseverities'];
- $desc .= "<br> Priority : ".$focus->column_fields['ticketpriorities'];
- $desc .= '<br><br>Description : <br>'.$focus->column_fields['description'];
- $desc .= '<br><br>Solution : <br>'.$focus->column_fields['solution'];
- $desc .= getTicketComments($focus->id);
-
- // code contribution by john read. Topik. 09.11.06
- // get the ticketCF field contents
- $sql = "SELECT * FROM vtiger_ticketcf WHERE ticketid = \"".$focus->id."\"";
- $result = $adb->query($sql);
- $cffields = $adb->getFieldsArray($result);
- foreach ($cffields as $cfOneField)
- {
- if ($cfOneField != 'ticketid')
- {
- $cfData = $adb->query_result($result,0,$cfOneField);
- $sql = "SELECT fieldlabel FROM vtiger_field WHERE columnname = \"$cfOneField\"";
- $cfLabel = $adb->query_result($adb->query($sql),0,'fieldlabel');
- $desc .= '<br><br>'.$cfLabel.' : <br>'.$cfData;
- }
- }
- // end of contribution
- $desc .= '<br><br><br>';
- $desc .= '<br>Regards,<br>HelpDesk Team<br>';
- $email_body = $desc;
+ $url = "<a href='".$PORTAL_URL."/index.php?module=Tickets&action=index&ticketid=".$id."&fun=detail'>Ticket Details</a>";
+ $email_body = $subject.'<br><br>'.getPortalInfo_Ticket($focus->id,$_REQUEST['ticket_title'],$contactname,$url,$_REQUEST['mode']);
+}
+else
+{
+ $data['sub']=$_REQUEST['ticket_title'];
+ $data['parent_name']=$parentname;
+ $data['status']=$focus->column_fields['ticketstatus'];
+ $data['category']=$focus->column_fields['ticketcategories'];
+ $data['severity'] = $focus->column_fields['ticketseverities'];
+ $data['priority']=$focus->column_fields['ticketpriorities'];
+ $data['description']=$focus->column_fields['description'];
+ $data['solution'] = $focus->column_fields['solution'];
+ $data['mode']= $_REQUEST['mode'];
+ $email_body = getTicketDetails($focus->id,$data);
}
$_REQUEST['return_id'] = $return_id;
@@ -175,9 +154,22 @@
//send mail to the assigned to user and the parent to whom this ticket is assigned
require_once('modules/Emails/mail.php');
$user_emailid = getUserEmailId('id',$focus->column_fields['assigned_user_id']);
+
if($user_emailid != '')
{
- $mail_status = send_mail('HelpDesk',$user_emailid,$HELPDESK_SUPPORT_NAME,$HELPDESK_SUPPORT_EMAIL_ID,$subject,$email_body);
+ if($_REQUEST['mode'] != 'edit')
+ {
+ $mail_status = send_mail('HelpDesk',$user_emailid,$HELPDESK_SUPPORT_NAME,$HELPDESK_SUPPORT_EMAIL_ID,$subject,$email_body);
+ }
+ else
+ {
+ if(($focus->column_fields['ticketstatus'] == $mod_strings["Closed"]) || ($focus->column_fields['comments'] != '') || ($_REQUEST['helpdesk_solution'] != $_REQUEST['solution']) || ($focus->column_fields['assigned_user_id'] != $old_user_id))
+ {
+ $mail_status = send_mail('HelpDesk',$user_emailid,$HELPDESK_SUPPORT_NAME,$HELPDESK_SUPPORT_EMAIL_ID,$subject,$email_body);
+ }
+
+ }
+
$mail_status_str = $user_emailid."=".$mail_status."&&&";
}
else
@@ -193,8 +185,18 @@
$parentmodule = $_REQUEST['parent_type'];
$parentid = $_REQUEST['parent_id'];
- $parent_email = getParentMailId($parentmodule,$parentid);
+ $parent_email = getParentMailId($parentmodule,$parentid);
+ if($_REQUEST['mode'] != 'edit')
+ {
$mail_status = send_mail('HelpDesk',$parent_email,$HELPDESK_SUPPORT_NAME,$HELPDESK_SUPPORT_EMAIL_ID,$subject,$email_body);
+ }
+ else
+ {
+ if(( $focus->column_fields['ticketstatus']== $mod_strings["Closed"]) || ($focus->column_fields['comments'] != '' ) || ($_REQUEST['helpdesk_solution'] != $_REQUEST['solution']))
+ {
+ $mail_status = send_mail('HelpDesk',$parent_email,$HELPDESK_SUPPORT_NAME,$HELPDESK_SUPPORT_EMAIL_ID,$subject,$email_body);
+ }
+ }
$mail_status_str .= $parent_email."=".$mail_status."&&&";
}
}
@@ -210,32 +212,4 @@
if($_REQUEST['return_viewname'] != '')$return_viewname=$_REQUEST['return_viewname'];
header("Location: index.php?action=$return_action&module=$return_module&parenttab=$parenttab&record=$return_id&$mail_error_status&viewname=$return_viewname");
-/** Function to get all the comments for a troubleticket
- * @param int $ticketid -- troubleticket id
- * return all the comments as a sequencial string which are related to this ticket
-**/
-function getTicketComments($ticketid)
-{
- global $log;
- $log->debug("Entering getTicketComments(".$ticketid.") method ...");
- global $adb;
-
- $commentlist = '';
- $sql = "select * from vtiger_ticketcomments where ticketid=".$ticketid;
- $result = $adb->query($sql);
- for($i=0;$i<$adb->num_rows($result);$i++)
- {
- $comment = $adb->query_result($result,$i,'comments');
- if($comment != '')
- {
- $commentlist .= '<br><br>'.$comment;
- }
- }
- if($commentlist != '')
- $commentlist = '<br><br> The comments are : '.$commentlist;
-
- $log->debug("Exiting getTicketComments method ...");
- return $commentlist;
-}
-
?>
Modified: vtigercrm/branches/5.0.3/modules/HelpDesk/language/en_us.lang.php
==============================================================================
--- vtigercrm/branches/5.0.3/modules/HelpDesk/language/en_us.lang.php (original)
+++ vtigercrm/branches/5.0.3/modules/HelpDesk/language/en_us.lang.php Thu Mar 8 07:22:04 2007
@@ -179,6 +179,21 @@
'Wait For Response'=>'Wait For Response',
'Closed'=>'Closed',
+//added to support i18n in ticket mails
+'Hi' => 'Hi',
+'Dear'=> 'Dear',
+'LBL_PORTAL_BODY_MAILINFO'=> 'The Ticket is',
+'LBL_DETAIL' => 'the details are :',
+'LBL_REGARDS'=> 'Regards',
+'LBL_TEAM'=> 'HelpDesk Team',
+'created' => 'created',
+'replied' => 'replied',
+'reply'=>'There is a reply to',
+'customer_portal' => 'in the "Customer Portal" at VTiger.',
+'link' => 'You can use the following link to view the replies made:',
+'Thanks' => 'Thanks',
+'Support_team' => 'Vtiger Support Team',
+
);
?>
Modified: vtigercrm/branches/5.0.3/modules/Potentials/DetailViewAjax.php
==============================================================================
--- vtigercrm/branches/5.0.3/modules/Potentials/DetailViewAjax.php (original)
+++ vtigercrm/branches/5.0.3/modules/Potentials/DetailViewAjax.php Thu Mar 8 07:22:04 2007
@@ -36,6 +36,7 @@
$modObj->id = $crmid;
$modObj->mode = "edit";
$modObj->save("Potentials");
+ sendNotificationToOwner('Potentials',&$modObj);
if($modObj->id != "")
{
echo ":#:SUCCESS";
More information about the vtigercrm-commits
mailing list