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 [email protected].
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 ('application.components.sortableWidget.ProfileGridViewWidget');
38:
39: /**
40: * @package application.components
41: */
42: class ProfilesGridViewProfileWidget extends ProfileGridViewWidget {
43:
44: public $canBeDeleted = true;
45:
46: public $viewFile = '_activeGridViewProfileWidget';
47:
48: public $relabelingEnabled = true;
49:
50: private static $_JSONPropertiesStructure;
51:
52: protected $_viewFileParams;
53:
54: /**
55: * @var array the config array passed to widget ()
56: */
57: private $_gridViewConfig;
58:
59: public $defaultTitle = 'People';
60:
61: protected function getModel () {
62: if (!isset ($this->_model)) {
63: $this->_model = new Profile ('search',
64: $this->widgetKey,
65: $this->getWidgetProperty ('dbPersistentGridSettings'));
66:
67: $this->afterGetModel ();
68: }
69: return $this->_model;
70: }
71:
72: public static function getJSONPropertiesStructure () {
73: if (!isset (self::$_JSONPropertiesStructure)) {
74: self::$_JSONPropertiesStructure = array_merge (
75: parent::getJSONPropertiesStructure (),
76: array ('label' => 'People')
77: );
78: }
79: return self::$_JSONPropertiesStructure;
80: }
81:
82: public function getDataProvider () {
83: if (!isset ($this->_dataProvider)) {
84: $resultsPerPage = self::getJSONProperty (
85: $this->profile, 'resultsPerPage', $this->widgetType, $this->widgetUID);
86: $this->_dataProvider = $this->model->search (
87: $resultsPerPage, $this->widgetKey, true);
88: }
89: return $this->_dataProvider;
90: }
91:
92: /**
93: * @return array the config array passed to widget ()
94: */
95: public function getGridViewConfig () {
96: if (!isset ($this->_gridViewConfig)) {
97: $this->_gridViewConfig = array_merge (
98: parent::getGridViewConfig (),
99: array (
100: 'possibleResultsPerPage' => array (5, 10, 20, 30, 40, 50, 75, 100),
101: 'defaultGvSettings'=>array(
102: 'isActive' => 65,
103: 'fullName' => 125,
104: //'tagLine' => 100,
105: //'cellPhone' => 100,
106: 'lastLogin' => 80,
107: 'emailAddress' => 100,
108: ),
109: 'template'=>
110: CHtml::openTag ('div', X2Html::mergeHtmlOptions (array (
111: 'class' => 'page-title'
112: ), array (
113: 'style' =>
114: !CPropertyValue::ensureBoolean (
115: $this->getWidgetProperty('showHeader')) &&
116: !CPropertyValue::ensureBoolean (
117: $this->getWidgetProperty('hideFullHeader')) ?
118: 'display: none;' : ''
119:
120: ))).
121: '<h2 class="grid-widget-title-bar-dummy-element">'.
122: '</h2>{buttons}{filterHint}'.
123: '{summary}{topPager}</div>{items}{pager}',
124: 'includedFields'=>array (
125: 'tagLine', 'username', 'officePhone', 'cellPhone', 'emailAddress',
126: 'googleId', 'isActive', 'leadRoutingAvailability',
127: ),
128: 'specialColumns'=>array(
129: 'fullName'=>array(
130: 'name'=>'fullName',
131: 'header'=>Yii::t('profile', 'Full Name'),
132: 'value'=>'CHtml::link(CHtml::encode($data->fullName),array("view","id"=>$data->id))',
133: 'type'=>'raw',
134: ),
135: 'lastLogin'=>array(
136: 'name'=>'lastLogin',
137: 'header'=>Yii::t('profile', 'Last Login'),
138: 'value'=>'$data->user ? ($data->user->lastLogin == 0 ? "" : '.
139: 'Formatter::formatDateDynamic ($data->user->lastLogin)) : ""',
140: 'type'=>'raw',
141: ),
142: 'isActive'=>array(
143: 'name'=>'isActive',
144: 'header'=>Yii::t('profile', 'Active'),
145: 'value'=>'"<span title=\''.
146: '".(Session::isOnline ($data->username) ? '.
147: '"'.Yii::t('profile', 'Active User').'" : "'.
148: Yii::t('profile', 'Inactive User').'")."\''.
149: ' class=\'".(Session::isOnline ($data->username) ? '.
150: '"active-indicator" : "inactive-indicator")."\'></span>"',
151: 'type'=>'raw',
152: ),
153: 'username' => array(
154: 'name' => 'username',
155: 'header' => Yii::t('profile','Username'),
156: 'value' => '$data->user ? CHtml::encode($data->user->alias) : ""',
157: 'type' => 'raw'
158: ),
159: 'leadRoutingAvailability' => array(
160: 'name' => 'leadRoutingAvailability',
161: 'header' => Yii::t('profile','Lead Routing Availability'),
162: 'value' => 'CHtml::encode($data->leadRoutingAvailability ?
163: Yii::t("profile", "Available") :
164: Yii::t("profile", "Unavailable"))',
165: 'type' => 'raw'
166: ),
167: ),
168: 'enableControls'=>false,
169: )
170: );
171: }
172: return $this->_gridViewConfig;
173: }
174:
175: }
176: ?>
177: