[ Index ] |
|
Code source de vtiger CRM 5.0.2 |
1 <?php 2 /********************************************************************************* 3 * The contents of this file are subject to the SugarCRM Public License Version 1.1.2 4 * ("License"); You may not use this file except in compliance with the 5 * License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL 6 * Software distributed under the License is distributed on an "AS IS" basis, 7 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for 8 * the specific language governing rights and limitations under the License. 9 * The Original Code is: SugarCRM Open Source 10 * The Initial Developer of the Original Code is SugarCRM, Inc. 11 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.; 12 * All Rights Reserved. 13 * Contributor(s): ______________________________________. 14 ********************************************************************************/ 15 /********************************************************************************* 16 * $Header: /advent/projects/wesat/vtiger_crm/vtigercrm/modules/HelpDesk/Save.php,v 1.8 2005/04/25 05:21:46 Mickie Exp $ 17 * Description: Saves an Account record and then redirects the browser to the 18 * defined return URL. 19 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. 20 * All Rights Reserved. 21 * Contributor(s): ______________________________________.. 22 ********************************************************************************/ 23 24 require_once ('modules/HelpDesk/HelpDesk.php'); 25 require_once ('include/logging.php'); 26 require_once ('include/database/PearDatabase.php'); 27 28 $focus = new HelpDesk(); 29 30 setObjectValuesFromRequest(&$focus); 31 32 global $adb; 33 //Added to update the ticket history 34 //Before save we have to construct the update log. 35 $mode = $_REQUEST['mode']; 36 $fldvalue = $focus->constructUpdateLog(&$focus, $mode, $_REQUEST['assigned_group_name'], $_REQUEST['assigntype']); 37 $fldvalue = from_html($adb->formatString('vtiger_troubletickets','update_log',$fldvalue),($mode == 'edit')?true:false); 38 39 $focus->save("HelpDesk"); 40 41 //After save the record, we should update the log 42 $adb->query("update vtiger_troubletickets set update_log=$fldvalue where ticketid=".$focus->id); 43 44 //Added to retrieve the existing attachment of the ticket and save it for the new duplicated ticket 45 if($_FILES['filename']['name'] == '' && $_REQUEST['mode'] != 'edit' && $_REQUEST['old_id'] != '') 46 { 47 $sql = "select vtiger_attachments.* from vtiger_attachments inner join vtiger_seattachmentsrel on vtiger_seattachmentsrel.attachmentsid=vtiger_attachments.attachmentsid where vtiger_seattachmentsrel.crmid= ".$_REQUEST['old_id']; 48 $result = $adb->query($sql); 49 if($adb->num_rows($result) != 0) 50 { 51 $attachmentid = $adb->query_result($result,0,'attachmentsid'); 52 $filename = $adb->query_result($result,0,'name'); 53 $filetype = $adb->query_result($result,0,'type'); 54 $filepath = $adb->query_result($result,0,'path'); 55 56 $new_attachmentid = $adb->getUniqueID("vtiger_crmentity"); 57 $date_var = date('YmdHis'); 58 59 $upload_filepath = decideFilePath(); 60 61 //Read the old file contents and write it as a new file with new attachment id 62 $handle = @fopen($upload_filepath.$new_attachmentid."_".$filename,'w'); 63 fputs($handle, file_get_contents($filepath.$attachmentid."_".$filename)); 64 fclose($handle); 65 66 $adb->query("update vtiger_troubletickets set filename=\"$filename\" where ticketid=$focus->id"); 67 $adb->query("insert into vtiger_crmentity (crmid,setype,createdtime) values('".$new_attachmentid."','HelpDesk Attachment','".$date_var."')"); 68 69 $adb->query("insert into vtiger_attachments values(".$new_attachmentid.",'".$filename."','','".$filetype."','".$upload_filepath."')"); 70 71 $adb->query("insert into vtiger_seattachmentsrel values('".$focus->id."','".$new_attachmentid."')"); 72 } 73 } 74 75 76 $return_id = $focus->id; 77 78 if(isset($_REQUEST['parenttab']) && $_REQUEST['parenttab'] != "") $parenttab = $_REQUEST['parenttab']; 79 if(isset($_REQUEST['return_module']) && $_REQUEST['return_module'] != "") $return_module = $_REQUEST['return_module']; 80 else $return_module = "HelpDesk"; 81 if(isset($_REQUEST['return_action']) && $_REQUEST['return_action'] != "") $return_action = $_REQUEST['return_action']; 82 else $return_action = "DetailView"; 83 if(isset($_REQUEST['return_id']) && $_REQUEST['return_id'] != "") $return_id = $_REQUEST['return_id']; 84 85 if($_REQUEST['mode'] == 'edit') 86 $reply = 'Re : '; 87 else 88 $reply = ''; 89 90 $subject = '[ Ticket ID : '.$focus->id.' ] '.$reply.$_REQUEST['ticket_title']; 91 $bodysubject = ' Ticket ID : '.$focus->id.'<br> Subject : '.$_REQUEST['ticket_title']; 92 93 $emailoptout = 0; 94 95 //To get the emailoptout vtiger_field value and then decide whether send mail about the tickets or not 96 if($focus->column_fields['parent_id'] != '') 97 { 98 $parent_module = getSalesEntityType($focus->column_fields['parent_id']); 99 if($parent_module == 'Contacts') 100 { 101 $result = $adb->query("select * from vtiger_contactdetails where contactid=".$focus->column_fields['parent_id']); 102 $emailoptout = $adb->query_result($result,0,'emailoptout'); 103 $contactname = $adb->query_result($result,0,'firstname').' '.$adb->query_result($result,0,'lastname'); 104 $parentname = $contactname; 105 $contact_mailid = $adb->query_result($result,0,'email'); 106 } 107 if($parent_module == 'Accounts') 108 { 109 $result = $adb->query("select * from vtiger_account where accountid=".$focus->column_fields['parent_id']); 110 $emailoptout = $adb->query_result($result,0,'emailoptout'); 111 $parentname = $adb->query_result($result,0,'accountname'); 112 } 113 } 114 115 //Get the status of the vtiger_portal user. if the customer is active then send the vtiger_portal link in the mail 116 if($contact_mailid != '') 117 { 118 $sql = "select * from vtiger_portalinfo where user_name='".$contact_mailid."'"; 119 $isactive = $adb->query_result($adb->query($sql),0,'isactive'); 120 } 121 if($isactive == 1) 122 { 123 $bodydetails = "Dear ".$contactname.",<br><br>"; 124 $bodydetails .= 'There is a reply to <b>'.$_REQUEST['ticket_title'].'</b> in the "Customer Portal" at VTiger.'; 125 $bodydetails .= "You can use the following link to view the replies made:<br>"; 126 127 $bodydetails .= "<a href='".$PORTAL_URL."/general.php?action=UserTickets&ticketid=".$focus->id."&fun=detail'>Ticket Details</a>"; 128 $bodydetails .= "<br><br>Thanks,<br><br> Vtiger Support Team "; 129 130 $email_body = $bodysubject.'<br><br>'.$bodydetails; 131 } 132 else 133 { 134 $desc = 'Ticket ID : '.$focus->id.'<br> Ticket Title : '.$reply.$_REQUEST['ticket_title']; 135 $desc .= "<br><br>Dear ".$parentname.",<br><br>The Ticket is replied and the details are : <br>"; 136 $desc .= "<br> Status : ".$focus->column_fields['ticketstatus']; 137 $desc .= "<br> Category : ".$focus->column_fields['ticketcategories']; 138 $desc .= "<br> Severity : ".$focus->column_fields['ticketseverities']; 139 $desc .= "<br> Priority : ".$focus->column_fields['ticketpriorities']; 140 $desc .= '<br><br>Description : <br>'.$focus->column_fields['description']; 141 $desc .= '<br><br>Solution : <br>'.$focus->column_fields['solution']; 142 $desc .= getTicketComments($focus->id); 143 144 $desc .= '<br><br><br>'; 145 $desc .= '<br><br><br>'; 146 $desc .= '<br><br><br>'; 147 $desc .= '<br>Regards, HelpDesk Team<br>'; 148 $email_body = $desc; 149 } 150 $_REQUEST['return_id'] = $return_id; 151 152 if($_REQUEST['product_id'] != '' && $focus->id != '' && $_REQUEST['mode'] != 'edit') 153 { 154 $sql = 'insert into vtiger_seticketsrel values('.$_REQUEST['product_id'].' , '.$focus->id.')'; 155 $adb->query($sql); 156 157 if($_REQUEST['return_module'] == 'Products') 158 $return_id = $_REQUEST['product_id']; 159 } 160 161 //send mail to the assigned to user and the parent to whom this ticket is assigned 162 require_once ('modules/Emails/mail.php'); 163 $user_emailid = getUserEmailId('id',$focus->column_fields['assigned_user_id']); 164 if($user_emailid != '') 165 { 166 $mail_status = send_mail('HelpDesk',$user_emailid,$HELPDESK_SUPPORT_NAME,$HELPDESK_SUPPORT_EMAIL_ID,$subject,$email_body); 167 $mail_status_str = $user_emailid."=".$mail_status."&&&"; 168 } 169 else 170 { 171 $mail_status_str = "'".$to_email."'=0&&&"; 172 } 173 //added condition to check the emailoptout(this is for contacts and vtiger_accounts.) 174 if($emailoptout == 0) 175 { 176 //send mail to parent 177 if($_REQUEST['parent_id'] != '' && $_REQUEST['parent_type'] != '') 178 { 179 $parentmodule = $_REQUEST['parent_type']; 180 $parentid = $_REQUEST['parent_id']; 181 182 $parent_email = getParentMailId($parentmodule,$parentid); 183 $mail_status = send_mail('HelpDesk',$parent_email,$HELPDESK_SUPPORT_NAME,$HELPDESK_SUPPORT_EMAIL_ID,$subject,$email_body); 184 $mail_status_str .= $parent_email."=".$mail_status."&&&"; 185 } 186 } 187 else 188 { 189 $adb->println("'".$parentname."' is not want to get the email about the ticket details as emailoptout is selected"); 190 } 191 192 $mail_error_status = getMailErrorString($mail_status_str); 193 194 //code added for returning back to the current view after edit from list view 195 if($_REQUEST['return_viewname'] == '') $return_viewname='0'; 196 if($_REQUEST['return_viewname'] != '')$return_viewname=$_REQUEST['return_viewname']; 197 header("Location: index.php?action=$return_action&module=$return_module&parenttab=$parenttab&record=$return_id&$mail_error_status&viewname=$return_viewname"); 198 199 /** Function to get all the comments for a troubleticket 200 * @param int $ticketid -- troubleticket id 201 * return all the comments as a sequencial string which are related to this ticket 202 **/ 203 function getTicketComments($ticketid) 204 { 205 global $log; 206 $log->debug("Entering getTicketComments(".$ticketid.") method ..."); 207 global $adb; 208 209 $commentlist = ''; 210 $sql = "select * from vtiger_ticketcomments where ticketid=".$ticketid; 211 $result = $adb->query($sql); 212 for($i=0;$i<$adb->num_rows($result);$i++) 213 { 214 $comment = $adb->query_result($result,$i,'comments'); 215 if($comment != '') 216 { 217 $commentlist .= '<br><br>'.$comment; 218 } 219 } 220 if($commentlist != '') 221 $commentlist = '<br><br> The comments are : '.$commentlist; 222 223 $log->debug("Exiting getTicketComments method ..."); 224 return $commentlist; 225 } 226 227 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Feb 25 10:22:19 2007 | par Balluche grâce à PHPXref 0.7 |