PageRenderTime 51ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/modules/EmailTemplates/DetailView.php

https://gitlab.com/tjaafar/SuiteCRM
PHP | 207 lines | 122 code | 32 blank | 53 comment | 38 complexity | bac3936c3e490b5c7ef46a9a59c9ce45 MD5 | raw file
  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-2013 SugarCRM Inc.
  6. * SuiteCRM is an extension to SugarCRM Community Edition developed by Salesagility Ltd.
  7. * Copyright (C) 2011 - 2014 Salesagility Ltd.
  8. *
  9. * This program is free software; you can redistribute it and/or modify it under
  10. * the terms of the GNU Affero General Public License version 3 as published by the
  11. * Free Software Foundation with the addition of the following permission added
  12. * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
  13. * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
  14. * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
  15. *
  16. * This program is distributed in the hope that it will be useful, but WITHOUT
  17. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  18. * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
  19. * details.
  20. *
  21. * You should have received a copy of the GNU Affero General Public License along with
  22. * this program; if not, see http://www.gnu.org/licenses or write to the Free
  23. * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  24. * 02110-1301 USA.
  25. *
  26. * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
  27. * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
  28. *
  29. * The interactive user interfaces in modified source and object code versions
  30. * of this program must display Appropriate Legal Notices, as required under
  31. * Section 5 of the GNU Affero General Public License version 3.
  32. *
  33. * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
  34. * these Appropriate Legal Notices must retain the display of the "Powered by
  35. * SugarCRM" logo and "Supercharged by SuiteCRM" logo. If the display of the logos is not
  36. * reasonably feasible for technical reasons, the Appropriate Legal Notices must
  37. * display the words "Powered by SugarCRM" and "Supercharged by SuiteCRM".
  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. require_once('include/upload_file.php');
  46. require_once('include/DetailView/DetailView.php');
  47. //Old DetailView compares wrong session variable against new view.list. Need to sync so that
  48. //the pagination on the DetailView page will show.
  49. if(isset($_SESSION['EMAILTEMPLATE_FROM_LIST_VIEW']))
  50. $_SESSION['EMAIL_TEMPLATE_FROM_LIST_VIEW'] = $_SESSION['EMAILTEMPLATE_FROM_LIST_VIEW'];
  51. global $app_strings;
  52. global $mod_strings;
  53. $focus = new EmailTemplate();
  54. $detailView = new DetailView();
  55. $offset=0;
  56. if(isset($_REQUEST['offset']) or isset($_REQUEST['record'])) {
  57. $result = $detailView->processSugarBean("EMAIL_TEMPLATE", $focus, $offset);
  58. if($result == null) {
  59. sugar_die($app_strings['ERROR_NO_RECORD']);
  60. }
  61. $focus=$result;
  62. } else {
  63. header("Location: index.php?module=Accounts&action=index");
  64. }
  65. if(isset($_REQUEST['isDuplicate']) && $_REQUEST['isDuplicate'] == 'true') {
  66. $focus->id = "";
  67. }
  68. //needed when creating a new note with default values passed in
  69. if(isset($_REQUEST['contact_name']) && is_null($focus->contact_name)) {
  70. $focus->contact_name = $_REQUEST['contact_name'];
  71. }
  72. if(isset($_REQUEST['contact_id']) && is_null($focus->contact_id)) {
  73. $focus->contact_id = $_REQUEST['contact_id'];
  74. }
  75. if(isset($_REQUEST['opportunity_name']) && is_null($focus->parent_name)) {
  76. $focus->parent_name = $_REQUEST['opportunity_name'];
  77. }
  78. if(isset($_REQUEST['opportunity_id']) && is_null($focus->parent_id)) {
  79. $focus->parent_id = $_REQUEST['opportunity_id'];
  80. }
  81. if(isset($_REQUEST['account_name']) && is_null($focus->parent_name)) {
  82. $focus->parent_name = $_REQUEST['account_name'];
  83. }
  84. if(isset($_REQUEST['account_id']) && is_null($focus->parent_id)) {
  85. $focus->parent_id = $_REQUEST['account_id'];
  86. }
  87. $params = array();
  88. $params[] = $focus->name;
  89. echo getClassicModuleTitle($focus->module_dir, $params, true);
  90. $GLOBALS['log']->info("EmailTemplate detail view");
  91. $xtpl=new XTemplate ('modules/EmailTemplates/DetailView.html');
  92. $xtpl->assign("MOD", $mod_strings);
  93. $xtpl->assign("APP", $app_strings);
  94. $buttons = array(
  95. <<<EOD
  96. <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']}">
  97. EOD
  98. ,
  99. <<<EOD
  100. <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']}">
  101. EOD
  102. ,
  103. <<<EOD
  104. <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']}">
  105. EOD
  106. );
  107. require_once('include/Smarty/plugins/function.sugar_action_menu.php');
  108. $action_button = smarty_function_sugar_action_menu(array(
  109. 'id' => 'detail_header_action_menu',
  110. 'buttons' => $buttons,
  111. 'class' => 'clickMenu fancymenu',
  112. ), $xtpl);
  113. $xtpl->assign("ACTION_BUTTON", $action_button);
  114. if(isset($_REQUEST['return_module'])) $xtpl->assign("RETURN_MODULE", $_REQUEST['return_module']);
  115. if(isset($_REQUEST['return_action'])) $xtpl->assign("RETURN_ACTION", $_REQUEST['return_action']);
  116. if(isset($_REQUEST['return_id'])) $xtpl->assign("RETURN_ID", $_REQUEST['return_id']);
  117. $xtpl->assign("GRIDLINE", $gridline);
  118. $xtpl->assign("PRINT_URL", "index.php?".$GLOBALS['request_string']);
  119. $xtpl->assign("ID", $focus->id);
  120. $xtpl->assign("CREATED_BY", $focus->created_by_name);
  121. $xtpl->assign("MODIFIED_BY", $focus->modified_by_name);
  122. //if text only is set to true, then make sure input is checked and value set to 1
  123. if(isset($focus->text_only) && $focus->text_only){
  124. $xtpl->assign("TEXT_ONLY_CHECKED","CHECKED");
  125. }
  126. $xtpl->assign("NAME", $focus->name);
  127. $xtpl->assign("DESCRIPTION", $focus->description);
  128. $xtpl->assign("SUBJECT", $focus->subject);
  129. $xtpl->assign("BODY", $focus->body);
  130. $xtpl->assign("BODY_HTML", json_encode(from_html($focus->body_html)));
  131. $xtpl->assign("DATE_MODIFIED", $focus->date_modified);
  132. $xtpl->assign("DATE_ENTERED", $focus->date_entered);
  133. $xtpl->assign("ASSIGNED_USER_NAME", $focus->assigned_user_name);
  134. $xtpl->assign("TYPE", $app_list_strings['emailTemplates_type_list'][$focus->type]);
  135. if($focus->ACLAccess('EditView')) {
  136. $xtpl->parse("main.edit");
  137. //$xtpl->out("EDIT");
  138. }
  139. if(!empty($focus->body)) {
  140. $xtpl->assign('ALT_CHECKED', 'CHECKED');
  141. }
  142. else
  143. $xtpl->assign('ALT_CHECKED', '');
  144. if( $focus->published == 'on')
  145. {
  146. $xtpl->assign("PUBLISHED","CHECKED");
  147. }
  148. ///////////////////////////////////////////////////////////////////////////////
  149. //// NOTES (attachements, etc.)
  150. ///////////////////////////////////////////////////////////////////////////////
  151. $note = new Note();
  152. $where = "notes.parent_id='{$focus->id}'";
  153. $notes_list = $note->get_full_list("notes.name", $where,true);
  154. if(! isset($notes_list)) {
  155. $notes_list = array();
  156. }
  157. $attachments = '';
  158. for($i=0; $i<count($notes_list); $i++) {
  159. $the_note = $notes_list[$i];
  160. $attachments .= "<a href=\"index.php?entryPoint=download&id={$the_note->id}&type=Notes\">".$the_note->name."</a><br />";
  161. }
  162. $xtpl->assign("ATTACHMENTS", $attachments);
  163. global $current_user;
  164. if(is_admin($current_user) && $_REQUEST['module'] != 'DynamicLayout' && !empty($_SESSION['editinplace'])) {
  165. $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>");
  166. }
  167. $xtpl->assign("DESCRIPTION", $focus->description);
  168. $detailView->processListNavigation($xtpl, "EMAIL_TEMPLATE", $offset);
  169. // adding custom fields:
  170. require_once('modules/DynamicFields/templates/Files/DetailView.php');
  171. $xtpl->parse("main");
  172. $xtpl->out("main");
  173. ?>