]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - modules/EmailTemplates/DetailView.php
Release 6.4.0
[Github/sugarcrm.git] / modules / EmailTemplates / DetailView.php
1 <?php
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-2011 SugarCRM Inc.
6  * 
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.
13  * 
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
17  * details.
18  * 
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
22  * 02110-1301 USA.
23  * 
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.
26  * 
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.
30  * 
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  ********************************************************************************/
37
38 /*********************************************************************************
39
40  * Description:  TODO: To be written.
41  * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
42  * All Rights Reserved.
43  * Contributor(s): ______________________________________..
44  ********************************************************************************/
45
46
47 require_once('include/upload_file.php');
48 require_once('include/DetailView/DetailView.php');
49
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'];
54
55 global $app_strings;
56 global $mod_strings;
57
58 $focus = new EmailTemplate();
59
60 $detailView = new DetailView();
61 $offset=0;
62 if(isset($_REQUEST['offset']) or isset($_REQUEST['record'])) {
63         $result = $detailView->processSugarBean("EMAIL_TEMPLATE", $focus, $offset);
64         if($result == null) {
65             sugar_die($app_strings['ERROR_NO_RECORD']);
66         }
67         $focus=$result;
68 } else {
69         header("Location: index.php?module=Accounts&action=index");
70 }
71 if(isset($_REQUEST['isDuplicate']) && $_REQUEST['isDuplicate'] == 'true') {
72         $focus->id = "";
73 }
74
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'];
78 }
79 if(isset($_REQUEST['contact_id']) && is_null($focus->contact_id)) {
80         $focus->contact_id = $_REQUEST['contact_id'];
81 }
82 if(isset($_REQUEST['opportunity_name']) && is_null($focus->parent_name)) {
83         $focus->parent_name = $_REQUEST['opportunity_name'];
84 }
85 if(isset($_REQUEST['opportunity_id']) && is_null($focus->parent_id)) {
86         $focus->parent_id = $_REQUEST['opportunity_id'];
87 }
88 if(isset($_REQUEST['account_name']) && is_null($focus->parent_name)) {
89         $focus->parent_name = $_REQUEST['account_name'];
90 }
91 if(isset($_REQUEST['account_id']) && is_null($focus->parent_id)) {
92         $focus->parent_id = $_REQUEST['account_id'];
93 }
94
95 $params = array();
96 $params[] = $focus->name;
97
98 echo getClassicModuleTitle($focus->module_dir, $params, true);
99
100
101 $GLOBALS['log']->info("EmailTemplate detail view");
102
103 $xtpl=new XTemplate ('modules/EmailTemplates/DetailView.html');
104 $xtpl->assign("MOD", $mod_strings);
105 $xtpl->assign("APP", $app_strings);
106
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");
118 }
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", json_encode(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);
127
128
129 if($focus->ACLAccess('EditView')) {
130         $xtpl->parse("main.edit");
131         //$xtpl->out("EDIT");
132
133 }
134 if(!empty($focus->body)) {
135         $xtpl->assign('ALT_CHECKED', 'CHECKED');
136
137 else 
138         $xtpl->assign('ALT_CHECKED', '');
139 if( $focus->published == 'on')
140 {
141 $xtpl->assign("PUBLISHED","CHECKED");
142 }
143
144
145 ///////////////////////////////////////////////////////////////////////////////
146 ////    NOTES (attachements, etc.)
147 ///////////////////////////////////////////////////////////////////////////////
148 $note = new Note();
149 $where = "notes.parent_id='{$focus->id}'";
150 $notes_list = $note->get_full_list("notes.name", $where,true);
151
152 if(! isset($notes_list)) {
153         $notes_list = array();
154 }
155
156 $attachments = '';
157 for($i=0; $i<count($notes_list); $i++) {
158         $the_note = $notes_list[$i];
159         $attachments .= "<a href=\"index.php?entryPoint=download&id={$the_note->id}&type=Notes\">".$the_note->name.$the_note->description."</a><br />";
160 }
161
162 $xtpl->assign("ATTACHMENTS", $attachments);
163
164
165 global $current_user;
166 if(is_admin($current_user) && $_REQUEST['module'] != 'DynamicLayout' && !empty($_SESSION['editinplace'])) {
167
168         $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>");
169 }
170
171 $xtpl->assign("DESCRIPTION", $focus->description);
172
173 $detailView->processListNavigation($xtpl, "EMAIL_TEMPLATE", $offset);
174 // adding custom fields:
175 require_once('modules/DynamicFields/templates/Files/DetailView.php');
176
177
178 $xtpl->parse("main");
179
180 $xtpl->out("main");
181
182 ?>