Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.
 All Data Structures Functions Variables Pages
CheckBoxColumn.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 
43  class CheckBoxColumn extends CCheckBoxColumn
44  {
45  public function init()
46  {
47  if (isset($this->checkBoxHtmlOptions['name']))
48  {
49  $name = $this->checkBoxHtmlOptions['name'];
50  }
51  else
52  {
53  $name = $this->id;
54  if (substr($name, -2) !== '[]')
55  {
56  $name .= '[]';
57  }
58  $this->checkBoxHtmlOptions['name'] = $name;
59  }
60  $name = strtr($name, array('[' => "\\[", ']' => "\\]"));
61  if ($this->grid->selectableRows == 1)
62  {
63  $one = "\n\tjQuery(\"input:not(#\"+$(this).attr('id')+\")[name = '$name']\").attr('checked', false);"; // Not Coding Standard
64  }
65  else
66  {
67  $one = '';
68  }
69  // Begin Not Coding Standard
70  $js = <<<END
71 jQuery('#{$this->id}_all').live('click', function()
72 {
73  var checked = this.checked;
74 
75  //custom checkbox style
76  if (this.checked){
77  jQuery(this).parent().addClass('c_on');
78  }
79  else
80  {
81  jQuery(this).parent().removeClass('c_on');
82  }
83 
84  jQuery("input[name='$name']").each(function()
85  {
86  this.checked = checked;
87  updateListViewSelectedIds('{$this->grid->id}', $(this).val(), checked);
88 
89  //custom checkbox style
90  if (this.checked){
91  jQuery(this).parent().addClass('c_on');
92  }
93  else
94  {
95  jQuery(this).parent().removeClass('c_on');
96  }
97  });
98 });
99 jQuery("input[name='$name']").live('click', function()
100 {
101  jQuery('#{$this->id}_all').attr( 'checked', jQuery("input[name='$name']").length == jQuery("input[name='$name']:checked").length);{$one}
102  updateListViewSelectedIds('{$this->grid->id}', $(this).val(), $(this).attr('checked'));
103 
104  //custom checkbox style
105  if ( jQuery('#{$this->id}_all').attr( 'checked') === 'checked' ){
106  jQuery('#{$this->id}_all').parent().addClass('c_on');
107  }
108  else
109  {
110  jQuery('#{$this->id}_all').parent().removeClass('c_on');
111  }
112  if ( this.checked )
113  {
114  jQuery(this).parent().addClass('c_on');
115  }
116  else
117  {
118  jQuery(this).parent().removeClass('c_on');
119  }
120 });
121 END;
122  // End Not Coding Standard
123  Yii::app()->getClientScript()->registerScript(__CLASS__ . '#' . $this->id, $js);
124  }
125 
131  protected function renderHeaderCellContent()
132  {
133  if ($this->grid->selectableRows>1)
134  {
135  $checked = false;
136  $disabled = '';
137  $htmlOptions = array('disabled' => $disabled);
138  echo ZurmoHtml::checkBox($this->id . '_all', $checked, $htmlOptions);
139  }
140  else
141  {
142  parent::renderHeaderCellContent();
143  }
144  }
145 
146  public function renderDataCellContentFromOutsideClass($row, $data)
147  {
148  $this->renderDataCellContent($row, $data);
149  }
150 
156  protected function renderDataCellContent($row, $data)
157  {
158  if ($this->value !== null)
159  {
160  $value = $this->evaluateExpression($this->value, array('data' => $data, 'row' => $row));
161  }
162  elseif ($this->name !== null)
163  {
164  $value = ZurmoHtml::value($data, $this->name);
165  }
166  else
167  {
168  $value = $this->grid->dataProvider->keys[$row];
169  }
170 
171  $checked = false;
172  if ($this->checked !== null)
173  {
174  $checked = $this->evaluateExpression($this->checked, array('data' => $data, 'row' => $row));
175  }
176  $options = $this->checkBoxHtmlOptions;
177  $name = $options['name'];
178  unset($options['name']);
179  $options['value'] = $value;
180  $options['id'] = $this->id . '_' . $row;
181  echo ZurmoHtml::checkBox($name, $checked, $options);
182  }
183  }
184 ?>
static checkBox($name, $checked=false, $htmlOptions=array())
Definition: ZurmoHtml.php:267
renderDataCellContent($row, $data)
Generated on Thu Sep 24 2020 07:10:25
Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.