Overview

Packages

  • application
    • commands
    • components
      • actions
      • filters
      • leftWidget
      • permissions
      • sortableWidget
      • util
      • webupdater
      • x2flow
        • actions
        • triggers
      • X2GridView
      • X2Settings
    • controllers
    • models
      • embedded
    • modules
      • accounts
        • controllers
        • models
      • actions
        • controllers
        • models
      • calendar
        • controllers
        • models
      • charts
        • models
      • contacts
        • controllers
        • models
      • docs
        • components
        • controllers
        • models
      • groups
        • controllers
        • models
      • marketing
        • components
        • controllers
        • models
      • media
        • controllers
        • models
      • mobile
        • components
      • opportunities
        • controllers
        • models
      • products
        • controllers
        • models
      • quotes
        • controllers
        • models
      • services
        • controllers
        • models
      • template
        • models
      • users
        • controllers
        • models
      • workflow
        • controllers
        • models
      • x2Leads
        • controllers
        • models
  • None
  • system
    • base
    • caching
    • console
    • db
      • ar
      • schema
    • validators
    • web
      • actions
      • auth
      • helpers
      • widgets
        • captcha
        • pagers
  • zii
    • widgets
      • grid

Classes

  • InlineRelationshipsGridView
  • X2GridViewGeneric
  • Overview
  • Package
  • Class
  • Tree
  1: <?php
  2: /*****************************************************************************************
  3:  * X2Engine Open Source Edition is a customer relationship management program developed by
  4:  * X2Engine, Inc. Copyright (C) 2011-2016 X2Engine Inc.
  5:  * 
  6:  * This program 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 X2ENGINE, X2ENGINE DISCLAIMS THE WARRANTY
 11:  * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 12:  * 
 13:  * This program 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 X2Engine, Inc. P.O. Box 66752, Scotts Valley,
 24:  * California 95067, USA. or at email address contact@x2engine.com.
 25:  * 
 26:  * The interactive user interfaces in modified source and object code 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 "Powered by
 32:  * X2Engine" logo. If the display of the logo is not reasonably feasible for
 33:  * technical reasons, the Appropriate Legal Notices must display the words
 34:  * "Powered by X2Engine".
 35:  *****************************************************************************************/
 36: 
 37: Yii::import('zii.widgets.grid.CGridView');
 38: Yii::import('X2GridViewBase');
 39: 
 40: /**
 41:  * @package application.components.X2GridView
 42:  */
 43: class X2GridViewGeneric extends X2GridViewBase {
 44: 
 45:     /**
 46:      * @var bool $rememberColumnSort whether or not to preserve order of columns in gvSettings
 47:      */
 48:     public $rememberColumnSort = true;  
 49: 
 50:     /**
 51:      * Used to populate allFieldNames property with attribute labels indexed by
 52:      * attribute names.
 53:      */
 54:     protected function addFieldNames () {
 55:         foreach ($this->columns as $column) {
 56:             $header = (isset ($column['header'])) ? $column['header'] : '';
 57:             $name = (isset ($column['name'])) ? $column['name'] : '';
 58:             $this->allFieldNames[$name] = $header;
 59:         }
 60:     }
 61: 
 62:     protected function generateColumns () {
 63:         $unsortedColumns = array ();
 64: 
 65:         foreach ($this->columns as &$column) {
 66:             $name = (isset ($column['name'])) ? $column['name'] : '';
 67:             if (!isset ($column['id'])) {
 68:                 if (isset ($column['class']) && 
 69:                     is_subclass_of ($column['class'], 'CCheckboxColumn')) {
 70: 
 71:                     $column['id'] = $this->namespacePrefix.'C_gvCheckbox'.$name;
 72:                 } else {
 73:                     $column['id'] = $this->namespacePrefix.'C_'.$name;
 74:                 }
 75:             } else {
 76:                 $column['id'] = $this->namespacePrefix.$column['id'];
 77:             }
 78:             if (!isset ($this->gvSettings[$name])) {
 79:                 if ($name === 'gvCheckbox') {
 80:                     $column = $this->getGvCheckboxColumn (null, $column);
 81:                 }
 82:                 $unsortedColumns[] = $column;
 83:                 continue;
 84:             }
 85:             $width = $this->gvSettings[$name];
 86:             $width = $this->formatWidth ($width);
 87:             if ($width) {
 88:                 $column['headerHtmlOptions'] = array_merge (
 89:                     isset ($column['headerHtmlOptions']) ? $column['headerHtmlOptions'] : array (),
 90:                     array('style'=>'width:'.$width.';')
 91:                 );
 92:                 $column['htmlOptions'] = X2Html::mergeHtmlOptions (
 93:                     isset ($column['htmlOptions']) ? 
 94:                         $column['htmlOptions'] : array (), array ('width' => $width));
 95:             }
 96:         }
 97:         unset ($column); // unset lingering reference
 98: 
 99:         if (isset ($this->gvSettings['gvControls']) && $this->enableControls) {
100:             $width = $this->gvSettings['gvControls'];
101:             $width = (!empty($width) && is_numeric($width))? $width : null;
102:             $this->columns[] =  $this->getGvControlsColumn ($width);
103:         }
104:         if (isset ($this->gvSettings['gvCheckBox'])) {
105:             $width = $this->gvSettings['gvCheckBox'];
106:             $width = (!empty($width) && is_numeric($width))? $width : null;
107:             $this->columns[] =  $this->getGvCheckboxColumn ($width);
108:         }
109: 
110:         if ($this->rememberColumnSort) {
111:             $sortedColumns = array ();
112:             foreach ($this->gvSettings as $columnName => $width) {
113:                 foreach ($this->columns as $column) {
114:                     $name = (isset ($column['name'])) ? $column['name'] : '';
115:                     if ($name === $columnName) {
116:                         $sortedColumns[] = $column;
117:                         break;
118:                     } 
119:                 }
120:             }
121:             $this->columns = array_merge ($sortedColumns, $unsortedColumns);
122:         } 
123:     }
124: 
125: 
126:     public function setSummaryText () {
127:         if ($this->asa ('X2GridViewSortableWidgetsBehavior')) {
128:             $this->setSummaryTextForSortableWidgets ();
129:             return;
130:         }
131: 
132:         /* add a dropdown to the summary text that let's user set how many rows to show on each 
133:            page */
134:         $this->summaryText =  Yii::t('app', '<b>{start}&ndash;{end}</b> of <b>{count}</b>')
135:         .'<div class="form no-border" style="display:inline;"> '
136:         .CHtml::dropDownList(
137:             'resultsPerPage', 
138:             $this->getResultsPerPage (), 
139:             $this->getPossibleResultsPerPageFormatted(),
140:             array(
141:                 'ajax' => array(
142:                     'url' => Yii::app()->controller->createUrl('/profile/setResultsPerPage'),
143:                     'data' => 'js:{results:$(this).val()}',
144:                     'complete' => 'function(response) { 
145:                         $.fn.yiiGridView.update("'.$this->id.'"); 
146:                     }',
147:                 ),
148:                 'id' => 'resultsPerPage'.$this->id,
149:                 'style' => 'margin: 0;',
150:                 'class' => 'x2-select resultsPerPage',
151:             )
152:         ).'</div>';
153:     }
154: 
155: }
156: ?>
157: 
X2CRM Documentation API documentation generated by ApiGen 2.8.0