2 if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
3 /*********************************************************************************
4 * SugarCRM is a customer relationship management program developed by
5 * SugarCRM, Inc. Copyright (C) 2004-2011 SugarCRM Inc.
7 * This program is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU Affero General Public License version 3 as published by the
9 * Free Software Foundation with the addition of the following permission added
10 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
11 * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
12 * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
14 * This program is distributed in the hope that it will be useful, but WITHOUT
15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
19 * You should have received a copy of the GNU Affero General Public License along with
20 * this program; if not, see http://www.gnu.org/licenses or write to the Free
21 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
24 * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
25 * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
27 * The interactive user interfaces in modified source and object code versions
28 * of this program must display Appropriate Legal Notices, as required under
29 * Section 5 of the GNU Affero General Public License version 3.
31 * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
32 * these Appropriate Legal Notices must retain the display of the "Powered by
33 * SugarCRM" logo. If the display of the logo is not reasonably feasible for
34 * technical reasons, the Appropriate Legal Notices must display the words
35 * "Powered by SugarCRM".
36 ********************************************************************************/
38 /*********************************************************************************
40 * Description: TODO: To be written.
41 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
42 * All Rights Reserved.
43 * Contributor(s): ______________________________________..
44 ********************************************************************************/
47 require_once('include/upload_file.php');
48 require_once('include/DetailView/DetailView.php');
50 //Old DetailView compares wrong session variable against new view.list. Need to sync so that
51 //the pagination on the DetailView page will show.
52 if(isset($_SESSION['EMAILTEMPLATE_FROM_LIST_VIEW']))
53 $_SESSION['EMAIL_TEMPLATE_FROM_LIST_VIEW'] = $_SESSION['EMAILTEMPLATE_FROM_LIST_VIEW'];
58 $focus = new EmailTemplate();
60 $detailView = new DetailView();
62 if(isset($_REQUEST['offset']) or isset($_REQUEST['record'])) {
63 $result = $detailView->processSugarBean("EMAIL_TEMPLATE", $focus, $offset);
65 sugar_die($app_strings['ERROR_NO_RECORD']);
69 header("Location: index.php?module=Accounts&action=index");
71 if(isset($_REQUEST['isDuplicate']) && $_REQUEST['isDuplicate'] == 'true') {
75 //needed when creating a new note with default values passed in
76 if(isset($_REQUEST['contact_name']) && is_null($focus->contact_name)) {
77 $focus->contact_name = $_REQUEST['contact_name'];
79 if(isset($_REQUEST['contact_id']) && is_null($focus->contact_id)) {
80 $focus->contact_id = $_REQUEST['contact_id'];
82 if(isset($_REQUEST['opportunity_name']) && is_null($focus->parent_name)) {
83 $focus->parent_name = $_REQUEST['opportunity_name'];
85 if(isset($_REQUEST['opportunity_id']) && is_null($focus->parent_id)) {
86 $focus->parent_id = $_REQUEST['opportunity_id'];
88 if(isset($_REQUEST['account_name']) && is_null($focus->parent_name)) {
89 $focus->parent_name = $_REQUEST['account_name'];
91 if(isset($_REQUEST['account_id']) && is_null($focus->parent_id)) {
92 $focus->parent_id = $_REQUEST['account_id'];
96 $params[] = $focus->name;
98 echo getClassicModuleTitle($focus->module_dir, $params, true);
101 $GLOBALS['log']->info("EmailTemplate detail view");
103 $xtpl=new XTemplate ('modules/EmailTemplates/DetailView.html');
104 $xtpl->assign("MOD", $mod_strings);
105 $xtpl->assign("APP", $app_strings);
107 if(isset($_REQUEST['return_module'])) $xtpl->assign("RETURN_MODULE", $_REQUEST['return_module']);
108 if(isset($_REQUEST['return_action'])) $xtpl->assign("RETURN_ACTION", $_REQUEST['return_action']);
109 if(isset($_REQUEST['return_id'])) $xtpl->assign("RETURN_ID", $_REQUEST['return_id']);
110 $xtpl->assign("GRIDLINE", $gridline);
111 $xtpl->assign("PRINT_URL", "index.php?".$GLOBALS['request_string']);
112 $xtpl->assign("ID", $focus->id);
113 $xtpl->assign("CREATED_BY", $focus->created_by_name);
114 $xtpl->assign("MODIFIED_BY", $focus->modified_by_name);
115 //if text only is set to true, then make sure input is checked and value set to 1
116 if(isset($focus->text_only) && $focus->text_only){
117 $xtpl->assign("TEXT_ONLY_CHECKED","CHECKED");
119 $xtpl->assign("NAME", $focus->name);
120 $xtpl->assign("DESCRIPTION", $focus->description);
121 $xtpl->assign("SUBJECT", $focus->subject);
122 $xtpl->assign("BODY", $focus->body);
123 $xtpl->assign("BODY_HTML", from_html($focus->body_html));
124 $xtpl->assign("DATE_MODIFIED", $focus->date_modified);
125 $xtpl->assign("DATE_ENTERED", $focus->date_entered);
126 $xtpl->assign("ASSIGNED_USER_NAME", $focus->assigned_user_name);
129 if(ACLController::checkAccess('EmailTemplates', 'edit', true)) {
130 $xtpl->parse("main.edit");
131 //$xtpl->out("EDIT");
134 if(!empty($focus->body)) {
135 $xtpl->assign('ALT_CHECKED', 'CHECKED');
138 $xtpl->assign('ALT_CHECKED', '');
139 if( $focus->published == 'on')
141 $xtpl->assign("PUBLISHED","CHECKED");
145 ///////////////////////////////////////////////////////////////////////////////
146 //// NOTES (attachements, etc.)
147 ///////////////////////////////////////////////////////////////////////////////
149 $where = "notes.parent_id='{$focus->id}'";
150 $notes_list = $note->get_full_list("notes.name", $where,true);
152 if(! isset($notes_list)) {
153 $notes_list = array();
157 for($i=0; $i<count($notes_list); $i++) {
158 $the_note = $notes_list[$i];
159 //$attachments .= "<a href=\"".UploadFile::get_url($the_note->filename,$the_note->id)."\" target=\"_blank\">". $the_note->filename ."</a><br>";
160 $attachments .= "<a href=\"index.php?entryPoint=download&id=".$the_note->id."&type=Notes\">".$the_note->name.$the_note->description."</a><br />";
163 $xtpl->assign("ATTACHMENTS", $attachments);
166 global $current_user;
167 if(is_admin($current_user) && $_REQUEST['module'] != 'DynamicLayout' && !empty($_SESSION['editinplace'])) {
169 $xtpl->assign("ADMIN_EDIT","<a href='index.php?action=index&module=DynamicLayout&from_action=".$_REQUEST['action'] ."&from_module=".$_REQUEST['module'] ."&record=".$_REQUEST['record']. "'>".SugarThemeRegistry::current()->getImage("EditLayout","border='0' alt='Edit Layout' align='bottom'")."</a>");
172 $xtpl->assign("DESCRIPTION", $focus->description);
174 $detailView->processListNavigation($xtpl, "EMAIL_TEMPLATE", $offset);
175 // adding custom fields:
176 require_once('modules/DynamicFields/templates/Files/DetailView.php');
179 $xtpl->parse("main");