Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.
 All Data Structures Functions Variables Pages
OperatorStaticDropDownElement.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  {
42  protected function getEditableHtmlOptions()
43  {
44  $htmlOptions = parent::getEditableHtmlOptions();
45  if (isset($htmlOptions['class']))
46  {
47  $htmlOptions['class'] .= ' operatorType';
48  }
49  else
50  {
51  $htmlOptions['class'] = 'operatorType';
52  }
53  return $htmlOptions;
54  }
55 
56  protected function renderControlEditable()
57  {
58  $content = parent::renderControlEditable();
59  return $content;
60  }
61 
62  protected function getDataAndLabelsModelPropertyName()
63  {
64  return 'getOperatorValuesAndLabels';
65  }
66 
67  public static function getValueTypesRequiringFirstInput()
68  {
69  return array(OperatorRules::TYPE_EQUALS,
70  OperatorRules::TYPE_DOES_NOT_EQUAL,
71  OperatorRules::TYPE_GREATER_THAN_OR_EQUAL_TO,
72  OperatorRules::TYPE_LESS_THAN_OR_EQUAL_TO,
73  OperatorRules::TYPE_GREATER_THAN,
74  OperatorRules::TYPE_LESS_THAN,
75  OperatorRules::TYPE_ONE_OF,
76  OperatorRules::TYPE_BETWEEN,
77  OperatorRules::TYPE_STARTS_WITH,
78  OperatorRules::TYPE_DOES_NOT_STARTS_WITH,
79  OperatorRules::TYPE_ENDS_WITH,
80  OperatorRules::TYPE_DOES_NOT_ENDS_WITH,
81  OperatorRules::TYPE_CONTAINS,
82  OperatorRules::TYPE_DOES_NOT_CONTAINS,
83  OperatorRules::TYPE_BECOMES,
84  OperatorRules::TYPE_WAS,
85  OperatorRules::TYPE_BECOMES_ONE_OF,
86  OperatorRules::TYPE_WAS_ONE_OF,
87  );
88  }
89 
90  public static function getValueTypesRequiringSecondInput()
91  {
92  return array(OperatorRules::TYPE_BETWEEN);
93  }
94 
95  public static function registerOnLoadAndOnChangeScript()
96  {
97  Yii::app()->clientScript->registerScript('operatorOnLoadAndOnChangeScript', "
98  $('.operatorType').live('change', function()
99  {
100  arr = " . CJSON::encode(self::getValueTypesRequiringFirstInput()) . ";
101  arr2 = " . CJSON::encode(self::getValueTypesRequiringSecondInput()) . ";
102  var firstValueArea = $(this).parent().parent().parent().find('.value-data').find('.first-value-area');
103  var secondValueArea = $(this).parent().parent().parent().find('.value-data').find('.second-value-area');
104  if ($.inArray($(this).val(), arr) != -1)
105  {
106  firstValueArea.show();
107  firstValueArea.find(':input, select').prop('disabled', false);
108  }
109  else
110  {
111  firstValueArea.hide();
112  firstValueArea.find(':input, select').prop('disabled', true);
113  }
114  if ($.inArray($(this).val(), arr2) != -1)
115  {
116  secondValueArea.show();
117  secondValueArea.find(':input, select').prop('disabled', false);
118  }
119  else
120  {
121  secondValueArea.hide();
122  secondValueArea.find(':input, select').prop('disabled', true);
123  }
124  arr = " . CJSON::encode(static::getValuesRequiringMultiSelect()) . ";
125  if (!$(this).hasClass('alwaysMultiple'))
126  {
127  if ($.inArray($(this).val(), arr) != -1)
128  {
129  var newName = $(this).parent().parent().parent().find('.value-data')
130  .find('.flexible-drop-down').attr('name') + '[]';
131  $(this).parent().parent().parent().find('.value-data').find('.flexible-drop-down')
132  .attr('multiple', 'multiple').addClass('multiple').addClass('ignore-style')
133  .attr('name', newName);
134  $(this).parent().parent().parent().find('.value-data')
135  .find('.flexible-drop-down').parent().addClass('isMultiSelect');
136  }
137  else
138  {
139  var newName = $(this).parent().parent().parent().find('.value-data')
140  .find('.flexible-drop-down').attr('name');
141  if (newName != undefined)
142  {
143  $(this).parent().parent().parent().find('.value-data').find('.flexible-drop-down')
144  .prop('multiple', false).removeClass('multiple').removeClass('ignore-style')
145  .attr('name', newName.replace('[]', ''));
146  $(this).parent().parent().parent().find('.value-data')
147  .find('.flexible-drop-down').parent().removeClass('isMultiSelect');
148  }
149  }
150  }
151  }
152  );
153  ");
154  }
155 
156  public static function getValuesRequiringMultiSelect()
157  {
158  return array(OperatorRules::TYPE_ONE_OF,
159  OperatorRules::TYPE_BECOMES_ONE_OF,
160  OperatorRules::TYPE_WAS_ONE_OF
161  );
162  }
163  }
164 ?>
Generated on Tue Jul 14 2020 07:10:28
Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.