2 if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
3 /*********************************************************************************
4 * SugarCRM Community Edition is a customer relationship management program developed by
5 * SugarCRM, Inc. Copyright (C) 2004-2013 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);
108 <input type="submit" class="button" id="editEmailTemplatesButton" title="{$app_strings['LBL_EDIT_BUTTON_TITLE']}" accessKey="{$app_strings['LBL_EDIT_BUTTON_KEY']}" onclick="this.form.return_module.value='EmailTemplates'; this.form.return_action.value='DetailView'; this.form.return_id.value='{$focus->id}'; this.form.action.value='EditView'" value="{$app_strings['LBL_EDIT_BUTTON_LABEL']}">
112 <input title="{$app_strings['LBL_DUPLICATE_BUTTON_TITLE']}" accessKey="{$app_strings['LBL_DUPLICATE_BUTTON_KEY']}" class="button" onclick="this.form.return_module.value='EmailTemplates'; this.form.return_action.value='index'; this.form.isDuplicate.value=true; this.form.action.value='EditView'" type="submit" name="button" value="{$app_strings['LBL_DUPLICATE_BUTTON_LABEL']}">
116 <input title="{$app_strings['LBL_DELETE_BUTTON_TITLE']}" accessKey="{$app_strings['LBL_DELETE_BUTTON_KEY']}" class="button" onclick="check_deletable_EmailTemplate();" type="button" name="button" value="{$app_strings['LBL_DELETE_BUTTON_LABEL']}">
119 require_once('include/Smarty/plugins/function.sugar_action_menu.php');
120 $action_button = smarty_function_sugar_action_menu(array(
121 'id' => 'detail_header_action_menu',
122 'buttons' => $buttons,
123 'class' => 'clickMenu fancymenu',
126 $xtpl->assign("ACTION_BUTTON", $action_button);
128 if(isset($_REQUEST['return_module'])) $xtpl->assign("RETURN_MODULE", $_REQUEST['return_module']);
129 if(isset($_REQUEST['return_action'])) $xtpl->assign("RETURN_ACTION", $_REQUEST['return_action']);
130 if(isset($_REQUEST['return_id'])) $xtpl->assign("RETURN_ID", $_REQUEST['return_id']);
131 $xtpl->assign("GRIDLINE", $gridline);
132 $xtpl->assign("PRINT_URL", "index.php?".$GLOBALS['request_string']);
133 $xtpl->assign("ID", $focus->id);
134 $xtpl->assign("CREATED_BY", $focus->created_by_name);
135 $xtpl->assign("MODIFIED_BY", $focus->modified_by_name);
136 //if text only is set to true, then make sure input is checked and value set to 1
137 if(isset($focus->text_only) && $focus->text_only){
138 $xtpl->assign("TEXT_ONLY_CHECKED","CHECKED");
140 $xtpl->assign("NAME", $focus->name);
141 $xtpl->assign("DESCRIPTION", $focus->description);
142 $xtpl->assign("SUBJECT", $focus->subject);
143 $xtpl->assign("BODY", $focus->body);
144 $xtpl->assign("BODY_HTML", json_encode(from_html($focus->body_html)));
145 $xtpl->assign("DATE_MODIFIED", $focus->date_modified);
146 $xtpl->assign("DATE_ENTERED", $focus->date_entered);
147 $xtpl->assign("ASSIGNED_USER_NAME", $focus->assigned_user_name);
149 $xtpl->assign("TYPE", $app_list_strings['emailTemplates_type_list'][$focus->type]);
151 if($focus->ACLAccess('EditView')) {
152 $xtpl->parse("main.edit");
153 //$xtpl->out("EDIT");
156 if(!empty($focus->body)) {
157 $xtpl->assign('ALT_CHECKED', 'CHECKED');
160 $xtpl->assign('ALT_CHECKED', '');
161 if( $focus->published == 'on')
163 $xtpl->assign("PUBLISHED","CHECKED");
167 ///////////////////////////////////////////////////////////////////////////////
168 //// NOTES (attachements, etc.)
169 ///////////////////////////////////////////////////////////////////////////////
171 $where = "notes.parent_id='{$focus->id}'";
172 $notes_list = $note->get_full_list("notes.name", $where,true);
174 if(! isset($notes_list)) {
175 $notes_list = array();
179 for($i=0; $i<count($notes_list); $i++) {
180 $the_note = $notes_list[$i];
181 $attachments .= "<a href=\"index.php?entryPoint=download&id={$the_note->id}&type=Notes\">".$the_note->name."</a><br />";
184 $xtpl->assign("ATTACHMENTS", $attachments);
187 global $current_user;
188 if(is_admin($current_user) && $_REQUEST['module'] != 'DynamicLayout' && !empty($_SESSION['editinplace'])) {
190 $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' align='bottom'",null,null,'.gif',$mod_strings['LBL_EDIT_LAYOUT'])."</a>");
193 $xtpl->assign("DESCRIPTION", $focus->description);
195 $detailView->processListNavigation($xtpl, "EMAIL_TEMPLATE", $offset);
196 // adding custom fields:
197 require_once('modules/DynamicFields/templates/Files/DetailView.php');
200 $xtpl->parse("main");