Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.
 All Data Structures Functions Variables Pages
MixedDateTypesElement.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  abstract class MixedDateTypesElement extends Element
42  {
43  abstract protected function getValueTypeEditableInputId();
44 
45  abstract protected function getValueFirstDateEditableInputId();
46 
47  abstract protected function getValueSecondDateEditableInputId();
48 
49  abstract protected function getValueTypeEditableInputName();
50 
51  abstract protected function getValueFirstDateEditableInputName();
52 
53  abstract protected function getValueSecondDateEditableInputName();
54 
55  abstract protected function getValueFirstDate();
56 
57  abstract protected function getValueSecondDate();
58 
59  abstract protected function getValueType();
60 
61  protected function renderEditable()
62  {
63  $data = array();
64  $data['label'] = $this->renderLabel();
65  $data['content'] = $this->renderEditableValueTypeContent() . $this->renderControlEditable();
66  $data['error'] = $this->renderError();
67  $data['colspan'] = $this->getColumnSpan();
68  return $this->resolveContentTemplate($this->editableTemplate, $data);
69  }
70 
75  protected function renderControlEditable()
76  {
77  $valueTypeId = $this->getValueTypeEditableInputId();
78  $firstDateSpanAreaSuffix = '-first-date-area';
79  $secondDateSpanAreaSuffix = '-second-date-area';
80  $thirdDateSpanAreaSuffix = '-third-date-area';
81  $firstDateSpanAreaId = $valueTypeId . $firstDateSpanAreaSuffix;
82  $secondDateSpanAreaId = $valueTypeId . $secondDateSpanAreaSuffix;
83  $thirdDateSpanAreaId = $valueTypeId . $thirdDateSpanAreaSuffix;
84  $valueTypesRequiringFirstDateInput = MixedDateTypesSearchFormAttributeMappingRules::
86  $valueTypesRequiringSecondDateInput = MixedDateTypesSearchFormAttributeMappingRules::
88  $valueTypesRequiringThirdDateInput = $this->getValueTypesRequiringThirdDateInput();
89  Yii::app()->clientScript->registerScript('mixedDateTypes', "
90  $('.dateValueType').change( function()
91  {
92  arr = " . CJSON::encode($valueTypesRequiringFirstDateInput) . ";
93  arr2 = " . CJSON::encode($valueTypesRequiringSecondDateInput) . ";
94  arr3 = " . CJSON::encode($valueTypesRequiringThirdDateInput) . ";
95  firstDateSpanAreaQualifier = '#' + $(this).attr('id') + '" . $firstDateSpanAreaSuffix . "';
96  secondDateSpanAreaQualifier = '#' + $(this).attr('id') + '" . $secondDateSpanAreaSuffix . "';
97  thirdDateSpanAreaQualifier = '#' + $(this).attr('id') + '" . $thirdDateSpanAreaSuffix . "';
98  if ($.inArray($(this).val(), arr) != -1)
99  {
100  $(firstDateSpanAreaQualifier).show();
101  $(firstDateSpanAreaQualifier).find('.hasDatepicker').prop('disabled', false);
102  }
103  else
104  {
105  $(firstDateSpanAreaQualifier).hide();
106  $(firstDateSpanAreaQualifier).find('.hasDatepicker').prop('disabled', true);
107  }
108  if ($.inArray($(this).val(), arr2) != -1)
109  {
110  $(secondDateSpanAreaQualifier).show();
111  $(secondDateSpanAreaQualifier).find('.hasDatepicker').prop('disabled', false);
112  }
113  else
114  {
115  $(secondDateSpanAreaQualifier).hide();
116  $(secondDateSpanAreaQualifier).find('.hasDatepicker').prop('disabled', true);
117  }
118  if ($.inArray($(this).val(), arr3) != -1)
119  {
120  $(thirdDateSpanAreaQualifier).show();
121  $(thirdDateSpanAreaQualifier).find('.hasDatepicker').prop('disabled', false);
122  }
123  else
124  {
125  $(thirdDateSpanAreaQualifier).hide();
126  $(thirdDateSpanAreaQualifier).find('.hasDatepicker').prop('disabled', true);
127  }
128  }
129  );
130  ");
131  $startingDivStyleFirstDate = null;
132  $startingDivStyleSecondDate = null;
133  $startingDivStyleThirdDate = null;
134  if (!in_array($this->getValueType(), $valueTypesRequiringFirstDateInput))
135  {
136  $startingDivStyleFirstDate = "display:none;";
137  $firstDateDisabled = 'disabled';
138  }
139  else
140  {
141  $firstDateDisabled = null;
142  }
143  if (!in_array($this->getValueType(), $valueTypesRequiringSecondDateInput))
144  {
145  $startingDivStyleSecondDate = "display:none;";
146  $secondDateDisabled = 'disabled';
147  }
148  else
149  {
150  $secondDateDisabled = null;
151  }
152  if (!in_array($this->getValueType(), $valueTypesRequiringThirdDateInput))
153  {
154  $startingDivStyleThirdDate = "display:none;";
155  $thirdDateDisabled = 'disabled';
156  }
157  else
158  {
159  $thirdDateDisabled = null;
160  }
161  $content = '<div class="date-area-holder">';
162  $content .= ZurmoHtml::tag('span', array('id' => $firstDateSpanAreaId,
163  'class' => 'date-area first-date-area',
164  'style' => $startingDivStyleFirstDate),
165  $this->renderEditableFirstDateContent($firstDateDisabled));
166  $content .= ZurmoHtml::tag('span', array('id' => $secondDateSpanAreaId,
167  'class' => 'date-area second-date-area',
168  'style' => $startingDivStyleSecondDate),
169  ZurmoHtml::Tag('span', array('class' => 'dynamic-and-for-mixed'), Zurmo::t('Core', 'and')) .
170  $this->renderEditableSecondDateContent($secondDateDisabled));
171  $content .= ZurmoHtml::tag('span', array('id' => $thirdDateSpanAreaId,
172  'class' => 'date-area third-date-area',
173  'style' => $startingDivStyleThirdDate),
174  $this->renderEditableThirdDateContent($thirdDateDisabled));
175  $content .= '</div>';
176  return $content;
177  }
178 
179  protected function renderEditableValueTypeContent()
180  {
181  return ZurmoHtml::dropDownList($this->getValueTypeEditableInputName(),
182  $this->getValueType(),
183  $this->getValueTypeDropDownArray(),
184  $this->getEditableValueTypeHtmlOptions());
185  }
186 
187  protected function renderEditableFirstDateContent($disabled = null)
188  {
189  assert('$disabled === null || $disabled = "disabled"');
190  $cClipWidget = new CClipWidget();
191  $cClipWidget->beginClip("EditableDateElement");
192  $cClipWidget->widget('application.core.widgets.ZurmoJuiDatePicker', array(
193  'attribute' => $this->attribute,
195  $this->getValueFirstDate(),
196  DateTimeUtil::DISPLAY_FORMAT_FOR_INPUT),
197  'htmlOptions' => array(
198  'id' => $this->getValueFirstDateEditableInputId(),
199  'name' => $this->getValueFirstDateEditableInputName(),
200  'disabled' => $disabled,
201  )));
202  $cClipWidget->endClip();
203  $content = $cClipWidget->getController()->clips['EditableDateElement'];
204  return ZurmoHtml::tag('div', array('class' => 'has-date-select'), $content);
205  }
206 
207  protected function renderEditableSecondDateContent($disabled = null)
208  {
209  assert('$disabled === null || $disabled = "disabled"');
210  $cClipWidget = new CClipWidget();
211  $cClipWidget->beginClip("EditableDateElement");
212  $cClipWidget->widget('application.core.widgets.ZurmoJuiDatePicker', array(
213  'attribute' => $this->attribute,
215  $this->getValueSecondDate(),
216  DateTimeUtil::DISPLAY_FORMAT_FOR_INPUT),
217  'htmlOptions' => array(
218  'id' => $this->getValueSecondDateEditableInputId(),
219  'name' => $this->getValueSecondDateEditableInputName(),
220  'disabled' => $disabled,
221  )));
222  $cClipWidget->endClip();
223  $content = $cClipWidget->getController()->clips['EditableDateElement'];
224  return ZurmoHtml::tag('div', array('class' => 'has-date-select'), $content);
225  }
226 
227  protected function getEditableValueTypeHtmlOptions()
228  {
229  $htmlOptions = array(
230  'id' => $this->getValueTypeEditableInputId(),
231  'class' => 'dateValueType',
232  );
233  $htmlOptions['empty'] = Zurmo::t('Core', '(None)');
234  $htmlOptions['disabled'] = $this->getDisabledValue();
235  return $htmlOptions;
236  }
237 
238  protected function getValueTypeDropDownArray()
239  {
241  }
242 
247  protected function renderControlNonEditable()
248  {
249  throw new NotSupportedException();
250  }
251 
252  protected function renderLabel()
253  {
254  $label = $this->getFormattedAttributeLabel();
255  if ($this->form === null)
256  {
257  return $label;
258  }
259  return ZurmoHtml::label($label, false);
260  }
261 
267  protected function renderError()
268  {
269  }
270 
271  protected function getValueTypesRequiringThirdDateInput()
272  {
273  return array();
274  }
275 
276  protected function renderEditableThirdDateContent($disabled = null)
277  {
278  }
279  }
280 ?>
static dropDownList($name, $select, $data, $htmlOptions=array())
Definition: ZurmoHtml.php:627
getColumnSpan()
Definition: Element.php:195
resolveContentTemplate($template, $data)
Definition: Element.php:253
static resolveValueForDateLocaleFormattedDisplay($date, $displayFormat=null)
Generated on Wed Jul 8 2020 07:10:30
Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.