All Data Structures Functions Variables Pages
CreateEmailMessageModalEditView.php
1 <?php
2  /*********************************************************************************
3  * Zurmo is a customer relationship management program developed by
4  * Zurmo, Inc. Copyright (C) 2017 Zurmo Inc.
5  *
6  * Zurmo is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU Affero General Public License version 3 as published by the
8  * Free Software Foundation with the addition of the following permission added
9  * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
10  * IN WHICH THE COPYRIGHT IS OWNED BY ZURMO, ZURMO DISCLAIMS THE WARRANTY
11  * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
12  *
13  * Zurmo is distributed in the hope that it will be useful, but WITHOUT
14  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15  * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Affero General Public License along with
19  * this program; if not, see http://www.gnu.org/licenses or write to the Free
20  * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21  * 02110-1301 USA.
22  *
23  * You can contact Zurmo, Inc. with a mailing address at 27 North Wacker Drive
24  * Suite 370 Chicago, IL 60606. or at email address contact@zurmo.com.
25  *
26  * The interactive user interfaces in original and modified versions
27  * of this program must display Appropriate Legal Notices, as required under
28  * Section 5 of the GNU Affero General Public License version 3.
29  *
30  * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
31  * these Appropriate Legal Notices must retain the display of the Zurmo
32  * logo and Zurmo copyright notice. If the display of the logo is not reasonably
33  * feasible for technical reasons, the Appropriate Legal Notices must display the words
34  * "Copyright Zurmo Inc. 2017. All rights reserved".
35  ********************************************************************************/
36 
41  {
46  protected $wrapContentInWrapperDiv = false;
47 
48  protected function renderTitleContent()
49  {
50  return null;
51  }
52 
53  public static function getDefaultMetadata()
54  {
55  $metadata = array(
56  'global' => array(
57  'toolbar' => array(
58  'elements' => array(
59  array('type' => 'SaveButton', 'label' => Zurmo::t('EmailMessagesModule', 'Send')),
60  ),
61  ),
62  'derivedAttributeTypes' => array(
63  'EmailMessageAllRecipientTypes',
64  'Files',
65  ),
66  'nonPlaceableAttributeNames' => array(
67  'sentDateTime',
68  'sender'
69  ),
70  'panelsDisplayType' => FormLayout::PANELS_DISPLAY_TYPE_ALL,
71  'panels' => array(
72  array(
73  'rows' => array(
74  array('cells' =>
75  array(
76  array(
77  'elements' => array(
78  array('attributeName' => 'recipientsData',
79  'type' => 'EmailMessageAllRecipientTypes'),
80  ),
81  ),
82  )
83  ),
84  array('cells' =>
85  array(
86  array(
87  'elements' => array(
88  array('attributeName' => 'subject', 'type' => 'Text'),
89  ),
90  ),
91  )
92  ),
93  array('cells' =>
94  array(
95  array(
96  'elements' => array(
97  array('attributeName' => 'null',
98  'type' => 'EmailMessageEmailTemplate')
99  ),
100  ),
101  )
102  ),
103  array('cells' =>
104  array(
105  array(
106  'elements' => array(
107  array('attributeName' => 'content', 'type' => 'EmailMessageContent'),
108  ),
109  ),
110  )
111  ),
112  array('cells' =>
113  array(
114  array(
115  'elements' => array(
116  array('attributeName' => 'null', 'type' => 'Files'),
117  ),
118  ),
119  )
120  ),
121  ),
122  ),
123  ),
124  ),
125  );
126  return $metadata;
127  }
128 
133  protected function resolveElementDuringFormLayoutRender(& $element)
134  {
135  if ($element->getAttribute() == 'subject')
136  {
137  $label = ZurmoHtml::tag('label',
138  array('for' => get_class($this->model) . '_subject'),
139  $this->model->getAttributeLabel('subject'));
140  $element->editableTemplate = '<td><div class="overlay-label-field">' . $label . '{content}{error}</div></td>';
141  }
142  elseif (get_class($element) == 'EmailMessageEmailTemplateElement')
143  {
144  $element->editableTemplate = '<td><div class="overlay-label-field"><div class="has-model-select">{label}{content}{error}</div></td>';
145  }
146  else
147  {
148  $element->editableTemplate = '<td>{content}{error}</td>';
149  }
150  }
151 
156  protected function doesLabelHaveOwnCell()
157  {
158  return false;
159  }
160 
161  protected function resolveActiveFormAjaxValidationOptions()
162  {
163  $afterValidateAjax = $this->renderConfigSaveAjax(
164  static::getFormId(),
165  $this->moduleId,
166  $this->controllerId,
167  'createEmailMessage');
168  return array(
169  'enableAjaxValidation' => true,
170  'clientOptions' => array(
171  'beforeValidate' => 'js:$(this).beforeValidateAction',
172  'afterValidate' => 'js:$(this).afterValidateAjaxAction',
173  'validateOnSubmit' => true,
174  'validateOnChange' => false,
175  'inputContainer' => 'td',
176  'afterValidateAjax' => $afterValidateAjax,
177  )
178  );
179  }
180 
181  protected function renderConfigSaveAjax($formName, $moduleId, $controllerId, $actionSave)
182  {
183  return ZurmoHtml::ajax(array(
184  'type' => 'POST',
185  'data' => 'js:$("#' . $formName . '").serialize()',
186  'url' => Yii::app()->createUrl($moduleId . '/' . $controllerId . '/' . $actionSave, GetUtil::getData()),
187  'complete' => "function(XMLHttpRequest, textStatus){\$('#modalContainer').dialog('close');
188  //find if there is a latest activities portlet
189  $('.LatestActivitiesForPortletView').each(function()
190  {
191  $(this).find('.pager').find('.refresh').find('a').click();
192  });}"
193  ));
194  }
195  }
196 ?>
Generated on Tue May 26 2020 07:10:30