Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.
 All Data Structures Functions Variables Pages
KanbanBoardExtendedGridView.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  {
47  public $enablePagination = false;
48 
52  public $groupByAttribute;
53 
57  public $groupByAttributeVisibleValues = array();
58 
62  public $groupByDataAndTranslatedLabels = array();
63 
67  public $cardColumns = array();
68 
72  public $selectedTheme;
73 
77  public static function resolvePageSizeForMaxCount()
78  {
79  return static::getMaxCount();
80  }
81 
85  public static function getMaxCount()
86  {
87  $maxCount = Yii::app()->pagination->getGlobalValueByType('kanbanBoardPageSize');
88  return (int) $maxCount;
89  }
90 
91  public function init()
92  {
93  $this->registerScripts();
94  parent::init();
95  }
96 
100  public function renderTableBody()
101  {
102  $data = $this->dataProvider->getData();
103  $modelsCount = count($data);
104  $totalModelsCount = $this->dataProvider->calculateTotalItemCount();
105  $columnsData = $this->resolveDataIntoKanbanColumns();
106  $width = 100 / count($columnsData);
107  echo "<tbody>";
108  echo "<tr><td id=\"kanban-holder\" class='". $this->selectedTheme . "'>";
109  if ($modelsCount > 0)
110  {
111  if ($this->isMaxCountCheckRequired() && $modelsCount == static::getMaxCount() &&
112  $totalModelsCount > static::getMaxCount())
113  {
114  $this->renderOverMaxCountText($totalModelsCount);
115  }
116  $counter = 0;
117  echo "<div id=\"kanban-board\">";
118  foreach ($columnsData as $attributeValue => $attributeValueAndData)
119  {
120  echo '<div class="kanban-column" style="width:'.$width.'%;">'; // Not Coding Standard
121  echo "<div data-value='" . $attributeValue . "' class='droppable-dynamic-rows-container'>";
122  echo ZurmoHtml::tag('div', array('class' => 'column-header'), $this->resolveGroupByColumnHeaderLabel($attributeValue));
123  $listItems = $this->getListItemsByAttributeValueAndData($attributeValueAndData);
124  echo $this->renderUlTagForKanbanColumn($listItems, $attributeValue);
125  $dropZone = ZurmoHtml::tag('div', array('class' => 'drop-zone'), '');
126  echo ZurmoHtml::tag('div', array('class' => 'drop-zone-container'), $dropZone);
127  echo "</div>";
128  echo "</div>";
129  $counter++;
130  }
131  echo "</div>";
132  }
133  else
134  {
135  $this->renderEmptyText();
136  }
137  echo "</td></tr>";
138  echo "</tbody>";
139  }
140 
145  public function renderOverMaxCountText($totalCount)
146  {
147  $label = Zurmo::t('Core',
148  'Too many results to display. Showing the first {maxCount} of {totalCount} records. Try filtering your search or switching to the grid view.',
149  array('{maxCount}' => static::getMaxCount(), '{totalCount}' => $totalCount));
150  $content = '<div class="general-issue-notice"><span class="icon-notice"></span><p>';
151  $content .= $label;
152  $content .= '</p></div>';
153  echo $content;
154  }
155 
159  protected function getOffset()
160  {
161  $pagination = $this->dataProvider->getPagination();
162  if (isset($pagination))
163  {
164  $offset = $pagination->getOffset();
165  }
166  else
167  {
168  $offset = 0;
169  }
170  return $offset;
171  }
172 
177  protected function resolveGroupByColumnHeaderLabel($value)
178  {
179  if (isset($this->groupByDataAndTranslatedLabels[$value]))
180  {
181  return $this->groupByDataAndTranslatedLabels[$value];
182  }
183  return $value;
184  }
185 
189  protected function resolveDataIntoKanbanColumns()
190  {
191  $columnsData = $this->makeColumnsDataAndStructure();
192  foreach ($this->dataProvider->data as $row => $data)
193  {
194  if (isset($columnsData[$data->{$this->groupByAttribute}->value]))
195  {
196  $columnsData[$data->{$this->groupByAttribute}->value][] = $row;
197  }
198  }
199  return $columnsData;
200  }
201 
205  protected function makeColumnsDataAndStructure()
206  {
207  $columnsData = array();
208  foreach ($this->groupByAttributeVisibleValues as $value)
209  {
210  $columnsData[$value] = array();
211  }
212  return $columnsData;
213  }
214 
215  protected function registerScripts()
216  {
217  Yii::app()->clientScript->registerScriptFile(
218  Yii::app()->getAssetManager()->publish(
219  Yii::getPathOfAlias('application.core.kanbanBoard.widgets.assets')) . '/KanbanUtils.js');
220  $script = '
221  $(".droppable-dynamic-rows-container").live("drop", function(event, ui)
222  {
223  ' . $this->getAjaxForDroppedAttribute() . '
224  $("ul", this).append(ui.draggable);
225  });
226  setupKanbanDragDrop();
227  ';
228  Yii::app()->getClientScript()->registerScript('KanbanDragDropScript', $script);
229  }
230 
234  protected function getAjaxForDroppedAttribute()
235  {
236  return ZurmoHtml::ajax(array(
237  'type' => 'GET',
238  'url' => 'js:$.param.querystring("' . $this->getUpdateAttributeValueUrl() .
239  '", "id=" + ui.helper.attr("id") + "&value=" + $(this).data("value"))',
240  'beforeSend' => 'js:function()
241  {
242  $(".ui-overlay-block").fadeIn(50);
243  $(this).makeLargeLoadingSpinner(true, ".ui-overlay-block"); //- add spinner to block anything else
244  }',
245  'success' => 'js:function(data)
246  {
247  $(this).makeLargeLoadingSpinner(false, ".ui-overlay-block");
248  $(".ui-overlay-block").fadeOut(50);
249  }'
250  ));
251  }
252 
256  protected function getUpdateAttributeValueUrl()
257  {
258  $modelClassName = $this->dataProvider->getModelClassName();
259  $moduleClassName = $modelClassName::getModuleClassName();
260  $moduleId = $moduleClassName::getDirectoryName();
261  return Yii::app()->createUrl($moduleId . '/default/updateAttributeValue', array('attribute' => $this->groupByAttribute));
262  }
263 
268  protected function renderCardDetailsContent($row)
269  {
270  $cardDetails = null;
271  foreach ($this->cardColumns as $cardData)
272  {
273  $content = $this->renderCardDataContent($cardData, $this->dataProvider->data[$row], $row);
274  $cardDetails .= ZurmoHtml::tag('span', array('class' => $cardData['class']), $content);
275  }
276  $userUrl = Yii::app()->createUrl('/users/default/details', array('id' => $this->dataProvider->data[$row]->owner->id));
277  $cardDetails .= ZurmoHtml::link($this->dataProvider->data[$row]->owner->getAvatarImage(20), $userUrl,
278  array('class' => 'opportunity-owner'));
279  return $cardDetails;
280  }
281 
282  protected function renderCardDataContent(array $cardData, RedBeanModel $model, $row)
283  {
284  assert('is_int($row)');
285  return $this->evaluateExpression($cardData['value'], array('data' => $model,
286  'offset' => ($this->getOffset() + $row)));
287  }
288 
294  protected function renderUlTagForKanbanColumn($listItems, $attributeValue = null)
295  {
296  return ZurmoHtml::tag('ul', array(), $listItems);
297  }
298 
302  protected function getRowClassForKanbanColumn()
303  {
304  return 'kanban-card item-to-place';
305  }
306 
311  protected function createRowForKanbanColumn($row)
312  {
313  return ZurmoHtml::tag('li', array('class' => $this->getRowClassForKanbanColumn(),
314  'data-id' => $this->dataProvider->data[$row]->id),
315  $this->wrapCardDetailsContent($row));
316  }
317 
322  protected function getListItemsByAttributeValueAndData($attributeValueAndData)
323  {
324  $listItems = '';
325  foreach ($attributeValueAndData as $row)
326  {
327  $listItems .= $this->createRowForKanbanColumn($row);
328  }
329  return $listItems;
330  }
331 
337  protected function wrapCardDetailsContent($row)
338  {
339  return ZurmoHtml::tag('div', array(), $this->renderCardDetailsContent($row));
340  }
341 
346  protected function isMaxCountCheckRequired()
347  {
348  return true;
349  }
350  }
351 ?>
renderUlTagForKanbanColumn($listItems, $attributeValue=null)
getListItemsByAttributeValueAndData($attributeValueAndData)
Generated on Thu Jul 9 2020 07:10:29
Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.