public function search($resultsPerPage = null, $uniqueId = null) { $criteria = new CDbCriteria(); $parameters = array('limit' => ceil(Profile::getResultsPerPage())); $criteria->scopes = array('findAll' => array($parameters)); return $this->searchBase($criteria, $resultsPerPage); }
public function setSummaryText() { /* add a dropdown to the summary text that let's user set how many rows to show on each page */ $jqueryMethod = $this->owner instanceof CGridView ? 'yiiGridView' : 'yiiListView'; $this->owner->summaryText = Yii::t('app', '<span class="grid-view-summary-text"> <b>{start}–{end}</b> of <b>{count}</b></span>') . '<div class="form no-border" style="display:inline;"> ' . CHtml::dropDownList('resultsPerPage', Profile::getResultsPerPage(), Profile::getPossibleResultsPerPage(), array('class' => 'x2-minimal-select', 'onchange' => '$.ajax ({ data: { results: $(this).val () }, url: "' . $this->owner->controller->createUrl('/profile/setResultsPerPage') . '", complete: function (response) { $.fn.' . $jqueryMethod . '.update("' . $this->owner->id . '", {' . (isset($this->owner->modelName) ? 'data: {' . $this->owner->modelName . '_page: 1},' : '') . 'complete: function () {}' . '}); } });')) . '</div>'; }
public function smartSearch($criteria, $pageSize = null) { $sort = new SmartSort(get_class($this->owner), isset($this->owner->uid) ? $this->owner->uid : get_class($this->owner)); $sort->multiSort = false; $sort->attributes = $this->owner->getSort(); $sort->defaultOrder = 't.lastUpdated DESC, t.id DESC'; if (!$pageSize) { if (!Yii::app()->user->isGuest) { $pageSize = Profile::getResultsPerPage(); } else { $pageSize = 20; } } $dataProvider = new SmartActiveDataProvider(get_class($this->owner), array('sort' => $sort, 'pagination' => array('pageSize' => $pageSize), 'criteria' => $criteria, 'uid' => $this->owner->uid, 'dbPersistentGridSettings' => $this->owner->dbPersistentGridSettings)); $sort->applyOrder($criteria); return $dataProvider; }
/** * Retrieves a list of models based on the current search/filter conditions. * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions. */ public function search() { // Warning: Please modify the following code to remove attributes that // should not be searched. $criteria = new CDbCriteria(); $fields = Fields::model()->findAllByAttributes(array('modelName' => 'ProductFeature')); foreach ($fields as $field) { $fieldName = $field->fieldName; switch ($field->type) { case 'boolean': $criteria->compare($field->fieldName, $this->compareBoolean($this->{$fieldName}), true); break; case 'assignment': $criteria->compare($field->fieldName, $this->compareAssignment($this->{$fieldName}), true); break; default: $criteria->compare($field->fieldName, $this->{$fieldName}, true); } } return new CActiveDataProvider(get_class($this), array('criteria' => $criteria, 'pagination' => array('pageSize' => Profile::getResultsPerPage()))); }
/** * Base search function, includes Retrieves a list of models based on the current * search/filter conditions. * @param CDbCriteria $criteria the attribute name * @param integer $pageSize If set, will override property of profile model * @return CActiveDataProvider the data provider that can return the models based on the * search/filter conditions. */ public function searchBase($criteria, $pageSize = null, $showHidden = false) { if (isset($_GET['showHidden']) && $_GET['showHidden'] && Yii::app()->user->checkAccess(self::getModuleName(get_class($this)) . 'Admin')) { $showHidden = true; } if ($criteria === null) { $criteria = $this->getAccessCriteria('t', Yii::app()->params->modelPermissions, $showHidden); } else { $criteria->mergeWith($this->getAccessCriteria('t', Yii::app()->params->modelPermissions, $showHidden)); } $filterCriteria = new CDbCriteria(); $this->compareAttributes($filterCriteria); $criteria->mergeWith($filterCriteria); $criteria->with = array(); // No joins necessary! $sort = new SmartSort(get_class($this), isset($this->uid) ? $this->uid : get_class($this)); $sort->multiSort = false; $sort->attributes = $this->getSort(); $sort->defaultOrder = 't.lastUpdated DESC, t.id DESC'; if ($pageSize === null) { if (!Yii::app()->user->isGuest) { $pageSize = Profile::getResultsPerPage(); } else { $pageSize = 20; } } $dataProvider = new SmartActiveDataProvider(get_class($this), array('sort' => $sort, 'pagination' => array('pageSize' => $pageSize), 'criteria' => $criteria, 'uid' => $this->uid, 'dbPersistentGridSettings' => $this->dbPersistentGridSettings, 'disablePersistentGridSettings' => $this->disablePersistentGridSettings)); $sort->applyOrder($criteria); return $dataProvider; }
/** * Return a SQL data provider for a list of emails in a campaign * includes associated contact info with each email * @return CSqlDataProvider */ public function campaignDataProvider($pageSize = null) { $criteria = X2Model::model('Campaign')->getAccessCriteria(); $conditions = $criteria->condition; $params = array('listId' => $this->id); $count = Yii::app()->db->createCommand()->select('count(*)')->from(X2ListItem::model()->tableName() . ' as list')->leftJoin(X2Model::model($this->modelName)->tableName() . ' t', 'list.contactId=t.id')->where('list.listId=:listId AND (' . $conditions . ')', array_merge(array(':listId' => $this->id), $criteria->params))->queryScalar(); $sql = Yii::app()->db->createCommand()->select('list.*, t.*')->from(X2ListItem::model()->tableName() . ' as list')->leftJoin(X2Model::model($this->modelName)->tableName() . ' t', 'list.contactId=t.id')->where('list.listId=:listId AND (' . $conditions . ')')->getText(); return new CSqlDataProvider($sql, array('params' => array_merge($params, $criteria->params), 'totalItemCount' => $count, 'pagination' => array('pageSize' => !empty($pageSize) ? $pageSize : Profile::getResultsPerPage()), 'sort' => array('attributes' => array('name', 'email', 'phone', 'address', 'sent', 'opened', 'clicked', 'unsubscribed', 'doNotEmail'), 'defaultOrder' => 'opened DESC, sent DESC, name DESC'))); }
public function getResultsPerPage() { if (!isset($this->_resultsPerPage)) { $this->_resultsPerPage = Profile::getResultsPerPage(); } return $this->_resultsPerPage; }
public function searchInvoice() { $criteria = new CDbCriteria(); $parameters = array('limit' => ceil(Profile::getResultsPerPage())); $criteria->scopes = array('findAll' => array($parameters)); $criteria->addCondition("t.type='invoice'"); return $this->searchBase($criteria); }
/** * Retrieves a list of models based on the current search/filter conditions. * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions. */ public function search() { // Warning: Please modify the following code to remove attributes that // should not be searched. $criteria = new CDbCriteria(); $parameters = array('limit' => ceil(Profile::getResultsPerPage())); $criteria->scopes = array('findAll' => array($parameters)); $criteria->compare('id', $this->id); $criteria->compare('type', $this->type, true); $criteria->compare('itemId', $this->itemId); $criteria->compare('changedBy', $this->changedBy, true); $criteria->compare('recordName', $this->recordName, true); $criteria->compare('fieldName', $this->fieldName, true); $criteria->compare('oldValue', $this->oldValue, true); $criteria->compare('newValue', $this->newValue, true); $criteria->compare('diff', $this->diff, true); $criteria->compare('timestamp', $this->timestamp); return new SmartActiveDataProvider(get_class($this), array('sort' => array('defaultOrder' => 'timestamp DESC'), 'pagination' => array('pageSize' => Profile::getResultsPerPage()), 'criteria' => $criteria)); }
public function actionLists() { $filter = new X2List('search'); $criteria = new CDbCriteria(); $criteria->addCondition('type="static" OR type="dynamic"'); if (!Yii::app()->params->isAdmin) { $condition = 'visibility="1" OR assignedTo="Anyone" OR assignedTo="' . Yii::app()->user->getName() . '"'; /* x2temp */ $groupLinks = Yii::app()->db->createCommand()->select('groupId')->from('x2_group_to_user')->where('userId=' . Yii::app()->user->getId())->queryColumn(); if (!empty($groupLinks)) { $condition .= ' OR assignedTo IN (' . implode(',', $groupLinks) . ')'; } $condition .= 'OR (visibility=2 AND assignedTo IN (SELECT username FROM x2_group_to_user WHERE groupId IN (SELECT groupId FROM x2_group_to_user WHERE userId=' . Yii::app()->user->getId() . ') ) )'; $criteria->addCondition($condition); } $perPage = Profile::getResultsPerPage(); //$criteria->offset = isset($_GET['page']) ? $_GET['page'] * $perPage - 3 : -3; //$criteria->limit = $perPage; $criteria->order = 'createDate DESC'; $filter->compareAttributes($criteria); $contactLists = X2Model::model('X2List')->findAll($criteria); $totalContacts = X2Model::model('Contacts')->count(); $totalMyContacts = X2Model::model('Contacts')->count('assignedTo="' . Yii::app()->user->getName() . '"'); $totalNewContacts = X2Model::model('Contacts')->count('assignedTo="' . Yii::app()->user->getName() . '" AND createDate >= ' . mktime(0, 0, 0)); $allContacts = new X2List(); $allContacts->attributes = array('id' => 'all', 'name' => Yii::t('contacts', 'All {module}', array('{module}' => Modules::displayName())), 'description' => '', 'type' => 'dynamic', 'visibility' => 1, 'count' => $totalContacts, 'createDate' => 0, 'lastUpdated' => 0); $newContacts = new X2List(); $newContacts->attributes = array('id' => 'new', 'assignedTo' => Yii::app()->user->getName(), 'name' => Yii::t('contacts', 'New {module}', array('{module}' => Modules::displayName())), 'description' => '', 'type' => 'dynamic', 'visibility' => 1, 'count' => $totalNewContacts, 'createDate' => 0, 'lastUpdated' => 0); $myContacts = new X2List(); $myContacts->attributes = array('id' => 'my', 'assignedTo' => Yii::app()->user->getName(), 'name' => Yii::t('contacts', 'My {module}', array('{module}' => Modules::displayName())), 'description' => '', 'type' => 'dynamic', 'visibility' => 1, 'count' => $totalMyContacts, 'createDate' => 0, 'lastUpdated' => 0); $contactListData = array($allContacts, $myContacts, $newContacts); $filteredPseudoLists = $filter->filter($contactListData); $lists = array_merge($filteredPseudoLists, $contactLists); $dataProvider = new CArrayDataProvider($lists, array('pagination' => array('pageSize' => $perPage), 'sort' => array('attributes' => array('name', 'type' => array('asc' => 'type asc, id desc', 'desc' => 'type desc, id desc'), 'count' => array('asc' => 'count asc, id desc', 'desc' => 'count desc, id desc'), 'assignedTo' => array('asc' => 'assignedTo asc, id desc', 'desc' => 'assignedTo desc, id desc'))), 'totalItemCount' => count($contactLists) + 3)); $this->render('listIndex', array('contactLists' => $dataProvider, 'filter' => $filter)); }
<?php } ?> <div style="margin-top: 23px;"> <?php if (isset($contactList) && $model->launchDate) { //these columns will be passed to gridview, depending on the campaign type $displayColumns = array(array('name' => 'name', 'header' => Yii::t('contacts', 'Name'), 'headerHtmlOptions' => array('style' => 'width: 15%;'), 'value' => 'CHtml::link($data["firstName"] . " " . $data["lastName"],array("/contacts/contacts/view","id"=>$data["id"]))', 'type' => 'raw')); if ($model->type == 'Email' && $contactList->type == 'campaign') { $displayColumns = array_merge($displayColumns, array(array('name' => 'email', 'header' => Yii::t('contacts', 'Email'), 'headerHtmlOptions' => array('style' => 'width: 20%;'), 'value' => '!empty($data["email"]) ? $data["email"] : (!empty($data["emailAddress"]) ? $data["emailAddress"] : "")'), array('name' => 'sent', 'header' => Yii::t('marketing', 'Sent') . ': ' . $contactList->statusCount('sent'), 'class' => 'CCheckBoxColumn', 'checked' => '$data["sent"] > 0', 'selectableRows' => 0, 'htmlOptions' => array('style' => 'text-align: center;'), 'headerHtmlOptions' => array('style' => 'width: 7%;', 'title' => $contactList->statusCount('sent'))), array('name' => 'opened', 'value' => '$data["opened"]', 'header' => Yii::t('marketing', 'Opened') . ': ' . $contactList->statusCount('opened'), 'class' => 'CDataColumn', 'type' => 'raw', 'value' => 'CHtml::checkbox( "", $data["opened"] != 0, array("onclick"=>"return false;"))', 'htmlOptions' => array('style' => 'text-align: center;'), 'headerHtmlOptions' => array('style' => 'width: 7%;', 'title' => $contactList->statusCount('opened'))), array('name' => 'clicked', 'header' => Yii::t('marketing', 'Clicked') . ': ' . $contactList->statusCount('clicked'), 'class' => 'CCheckBoxColumn', 'checked' => '$data["clicked"] != 0', 'selectableRows' => 0, 'htmlOptions' => array('style' => 'text-align: center;'), 'headerHtmlOptions' => array('style' => 'width: 7%;')), array('name' => 'unsubscribed', 'header' => Yii::t('marketing', 'Unsubscribed') . ': ' . $contactList->statusCount('unsubscribed'), 'class' => 'CCheckBoxColumn', 'checked' => '$data["unsubscribed"] != 0', 'selectableRows' => 0, 'htmlOptions' => array('style' => 'text-align: center;'), 'headerHtmlOptions' => array('style' => 'width: 9%;', 'title' => $contactList->statusCount('unsubscribed'))), array('name' => 'doNotEmail', 'header' => Yii::t('contacts', 'Do Not Email'), 'class' => 'CCheckBoxColumn', 'checked' => '$data["doNotEmail"] == 1', 'selectableRows' => 0, 'htmlOptions' => array('style' => 'text-align: center;'), 'headerHtmlOptions' => array('style' => 'width: 7%;')))); } elseif ($model->type == 'Call List') { $displayColumns = array_merge($displayColumns, array(array('name' => 'phone', 'header' => Yii::t('contacts', 'Phone'), 'headerHtmlOptions' => array('style' => 'width: 10%;')))); } elseif ($model->type == 'Physical Mail') { $displayColumns = array_merge($displayColumns, array(array('name' => 'address', 'header' => Yii::t('contacts', 'Address'), 'headerHtmlOptions' => array('style' => 'width: 25%;'), 'value' => '$data["address"]." ".$data["address2"]." ".$data["city"]."' . ' ".$data["state"]." ".$data["zipcode"]." ".$data["country"]'))); } ?> <div class='x2-layout-island'> <?php $this->widget('X2GridViewGeneric', array('defaultGvSettings' => array('name' => 140, 'email' => 140, 'opened' => 80, 'clicked' => 80, 'unsubscribed' => 80, 'doNotEmail' => 80, 'sent' => 80), 'id' => 'campaign-grid', 'template' => '<div class="page-title">{title}' . '{buttons}{summary}</div>{items}{pager}', 'buttons' => array('autoResize'), 'dataProvider' => $contactList->campaignDataProvider(Profile::getResultsPerPage()), 'columns' => $displayColumns, 'enablePagination' => true, 'gvSettingsName' => 'campaignProgressGrid')); } ?> </div> </div> </div> <?php $this->widget('X2WidgetList', array('layoutManager' => $layoutManager, 'block' => 'center', 'model' => $model, 'modelType' => 'Marketing'));
/** * View all notifications for the current web user. */ public function actionViewNotifications() { $pageSize = Profile::getResultsPerPage(); $dataProvider = new CActiveDataProvider('Notification', array('criteria' => array('condition' => 'user="******"'), 'pagination' => array('pageSize' => $pageSize), 'sort' => array('defaultOrder' => 'createDate DESC'))); $this->render('viewNotifications', array('dataProvider' => $dataProvider)); }
public function actionTriggerLogs($pageSize = null) { $triggerLogsDataProvider = new CActiveDataProvider('TriggerLog', array('criteria' => array('order' => 'triggeredAt DESC'), 'pagination' => array('pageSize' => !empty($pageSize) ? $pageSize : Profile::getResultsPerPage()))); $viewParams['triggerLogsDataProvider'] = $triggerLogsDataProvider; $this->render('triggerLogs', array('triggerLogsDataProvider' => $triggerLogsDataProvider)); }
public function searchBase($criteria, $pageSize = null, $showHidden = false) { if ($pageSize === null) { $pageSize = Profile::getResultsPerPage(); } $this->compareAttributes($criteria); /*$criteria->with = 'actionText'; $criteria->compare('actionText.text', $this->actionDescriptionTemp, true);*/ if (!empty($criteria->order)) { $criteria->order = $order = "sticky DESC, " . $criteria->order; } else { $order = 'sticky DESC, IF( complete="No", IFNULL(dueDate, IFNULL(createDate,0)), GREATEST(createDate, IFNULL(completeDate,0), IFNULL(lastUpdated,0))) DESC'; } $dataProvider = new SmartActiveDataProvider('Actions', array('sort' => array('defaultOrder' => $order), 'pagination' => array('pageSize' => $pageSize), 'criteria' => $criteria, 'uid' => $this->uid, 'dbPersistentGridSettings' => $this->dbPersistentGridSettings)); return $dataProvider; }
public function search($resultsPerPage = null, $uniqueId = null) { $criteria = new CDbCriteria(); $parameters = array('limit' => ceil(Profile::getResultsPerPage())); $criteria->scopes = array('findAll' => array($parameters)); // allows converted leads to be filtered out of grid by default $filters = $this->asa('ERememberFiltersBehavior')->getSetting('filters'); if (!isset($filters['converted'])) { $this->converted = 'false'; } elseif ($filters['converted'] === 'all') { unset($this->converted); } return $this->searchBase($criteria, $resultsPerPage); }
/** * Search X2Engine for a record. * * This is the action called by the search bar in the main menu. */ public function actionSearch() { ini_set('memory_limit', -1); $term = isset($_GET['term']) ? $_GET['term'] : ""; if (empty($term)) { $dataProvider = new CArrayDataProvider(array()); Yii::app()->user->setFlash('error', Yii::t('app', "Search term cannot be empty.")); $this->render('search', array('dataProvider' => $dataProvider)); } else { if (substr($term, 0, 1) != "#") { $modules = Modules::model()->findAllByAttributes(array('searchable' => 1)); $comparisons = array(); $other = array(); foreach ($modules as $module) { $module->name == 'products' ? $type = ucfirst('Product') : ($type = ucfirst($module->name)); $module->name == 'quotes' ? $type = ucfirst('Quote') : ($type = $type); $module->name == 'opportunities' ? $type = ucfirst('Opportunity') : ($type = $type); $criteria = new CDbCriteria(); $fields = Fields::model()->findAllByAttributes(array('modelName' => $type, 'searchable' => 1)); $temp = array(); $fieldNames = array(); if (count($fields) < 1) { $criteria->compare('id', '<0', true, 'AND'); } foreach ($fields as $field) { $temp[] = $field->id; $fieldNames[] = $field->fieldName; $criteria->compare($field->fieldName, $term, true, "OR"); if ($field->type == 'phone') { $tempPhone = preg_replace('/\\D/', '', $term); $phoneLookup = PhoneNumber::model()->findByAttributes(array('modelType' => $field->modelName, 'number' => $tempPhone, 'fieldName' => $field->fieldName)); if (isset($phoneLookup)) { $criteria->compare('id', $phoneLookup->modelId, true, "OR"); } } } if (Yii::app()->user->getName() != 'admin' && X2Model::model($type)->hasAttribute('visibility') && X2Model::model($type)->hasAttribute('assignedTo')) { $condition = 'visibility="1" OR (assignedTo="Anyone" AND visibility!="0") OR assignedTo="' . Yii::app()->user->getName() . '"'; /* x2temp */ $groupLinks = Yii::app()->db->createCommand()->select('groupId')->from('x2_group_to_user')->where('userId=' . Yii::app()->user->getId())->queryColumn(); if (!empty($groupLinks)) { $condition .= ' OR assignedTo IN (' . implode(',', $groupLinks) . ')'; } $condition .= 'OR (visibility=2 AND assignedTo IN (SELECT username FROM x2_group_to_user WHERE groupId IN (SELECT groupId FROM x2_group_to_user WHERE userId=' . Yii::app()->user->getId() . ')))'; $criteria->addCondition($condition); } if ($module->name == 'actions') { $criteria->with = array('actionText'); $criteria->compare('actionText.text', $term, true, "OR"); } if (class_exists($type)) { $arr = X2Model::model($type)->findAll($criteria); $comparisons[$type] = $temp; $other[$type] = $arr; } } $high = array(); $medium = array(); $low = array(); $userHigh = array(); $userMedium = array(); $userLow = array(); $records = array(); $userRecords = array(); $regEx = "/" . preg_quote($term, '/') . "/i"; foreach ($other as $key => $recordType) { $fieldList = $comparisons[$key]; foreach ($recordType as $otherRecord) { if ($key == 'Actions') { if ($otherRecord->hasAttribute('assignedTo') && $otherRecord->assignedTo == Yii::app()->user->getName()) { $userHigh[] = $otherRecord; } else { $high[] = $otherRecord; } } else { foreach ($fieldList as $field) { $fieldRecord = Fields::model()->findByPk($field); $fieldName = $fieldRecord->fieldName; if (preg_match($regEx, $otherRecord->{$fieldName}) > 0) { switch ($fieldRecord->relevance) { case "High": if (!in_array($otherRecord, $high, true) && !in_array($otherRecord, $medium, true) && !in_array($otherRecord, $low, true) && !in_array($otherRecord, $userHigh, true) && !in_array($otherRecord, $userMedium, true) && !in_array($otherRecord, $userLow, true)) { if ($otherRecord->hasAttribute('assignedTo') && $otherRecord->assignedTo == Yii::app()->user->getName()) { $userHigh[] = $otherRecord; } else { $high[] = $otherRecord; } } break; case "Medium": if (!in_array($otherRecord, $high, true) && !in_array($otherRecord, $medium, true) && !in_array($otherRecord, $low, true) && !in_array($otherRecord, $userHigh, true) && !in_array($otherRecord, $userMedium, true) && !in_array($otherRecord, $userLow, true)) { if ($otherRecord->hasAttribute('assignedTo') && $otherRecord->assignedTo == Yii::app()->user->getName()) { $userMedium[] = $otherRecord; } else { $medium[] = $otherRecord; } } break; case "Low": if (!in_array($otherRecord, $high, true) && !in_array($otherRecord, $medium, true) && !in_array($otherRecord, $low, true) && !in_array($otherRecord, $userHigh, true) && !in_array($otherRecord, $userMedium, true) && !in_array($otherRecord, $userLow, true)) { if ($otherRecord->hasAttribute('assignedTo') && $otherRecord->assignedTo == Yii::app()->user->getName()) { $userLow[] = $otherRecord; } else { $low[] = $otherRecord; } } break; default: if ($otherRecord->hasAttribute('assignedTo') && $otherRecord->assignedTo == Yii::app()->user->getName()) { $userLow[] = $otherRecord; } else { $low[] = $otherRecord; } } } elseif ($fieldRecord->type == 'phone') { $tempPhone = preg_replace('/\\D/', '', $term); if (strlen($tempPhone) == 10) { $phoneLookup = PhoneNumber::model()->findByAttributes(array('modelType' => $fieldRecord->modelName, 'number' => $tempPhone, 'fieldName' => $fieldName)); if (!in_array($otherRecord, $high, true) && !in_array($otherRecord, $medium, true) && !in_array($otherRecord, $low, true) && !in_array($otherRecord, $userHigh, true) && !in_array($otherRecord, $userMedium, true) && !in_array($otherRecord, $userLow, true)) { if (isset($phoneLookup) && $otherRecord->id == $phoneLookup->modelId) { if ($otherRecord->hasAttribute('assignedTo') && $otherRecord->assignedTo == Yii::app()->user->getName()) { $userHigh[] = $otherRecord; } else { $high[] = $otherRecord; } } } } } } } } } $records = array_merge($high, $medium); $records = array_merge($records, $low); $userRecords = array_merge($userHigh, $userMedium); $userRecords = array_merge($userRecords, $userLow); $records = array_merge($userRecords, $records); $records = Record::convert($records, false); if (count($records) == 1) { // Only one match, so go straight to it. // // The record's corresponding model class must have // X2LinkableBehavior for this to be possible. if (!empty($records[0]['#recordUrl'])) { $this->redirect($records[0]['#recordUrl']); } } $dataProvider = new CArrayDataProvider($records, array('id' => 'id', 'pagination' => array('pageSize' => Profile::getResultsPerPage()))); $this->render('search', array('records' => $records, 'dataProvider' => $dataProvider, 'term' => $term)); } else { Yii::app()->user->setState('vcr-list', $term); $_COOKIE['vcr-list'] = $term; $tagQuery = "\n SELECT * \n FROM x2_tags\n WHERE tag=:tag\n group BY tag, type, itemId"; $params = array(':tag' => $term); // group by type and itemId to prevent display of duplicate tags $sql = Yii::app()->db->createCommand($tagQuery); $totalItemCount = Yii::app()->db->createCommand("\n SELECT count(*)\n FROM ({$tagQuery}) as t1;\n ")->queryScalar($params); $results = new CSqlDataProvider($sql, array('totalItemCount' => $totalItemCount, 'sort' => array('defaultOrder' => 'timestamp DESC'), 'pagination' => array('pageSize' => Profile::getResultsPerPage()), 'params' => $params)); $this->render('searchTags', array('tags' => $results, 'term' => $term)); } } }
/** * Lists all models. */ public function actionIndex($order = null) { $model = new Topics('search'); $orderStr = $model->getOrder($order); $dataProvider = new CActiveDataProvider('Topics', array('criteria' => array('select' => 't.*, (SELECT COUNT(id) FROM x2_topic_replies WHERE topicId = t.id) AS replyCount, min(lastPost.createDate) as minCreateDate', 'with' => array('lastPost'), 'order' => $orderStr, 'group' => 'lastPost.topicId'), 'pagination' => array('pageSize' => Profile::getResultsPerPage()))); $this->render('index', array('model' => $model, 'dataProvider' => $dataProvider, 'order' => $order)); }
/** * Retrieves a list of models based on the current search/filter conditions. * @return CActiveDataProvider the data provider that can return the models based on the * search/filter conditions. */ public function search() { $criteria = new CDbCriteria(); $criteria->compare('id', $this->id); $criteria->compare('active', $this->active); $criteria->compare('name', $this->name, true); $criteria->compare('createDate', $this->createDate, true); $criteria->compare('lastUpdated', $this->lastUpdated, true); return new CActiveDataProvider($this, array('criteria' => $criteria, 'pagination' => array('pageSize' => Profile::getResultsPerPage()))); }
public function searchList($id, $pageSize = null) { $list = X2List::model()->findByPk($id); if (isset($list)) { $search = $list->queryCriteria(); $this->compareAttributes($search); return new SmartActiveDataProvider('Accounts', array('criteria' => $search, 'sort' => array('defaultOrder' => 't.lastUpdated DESC'), 'pagination' => array('pageSize' => isset($pageSize) ? $pageSize : Profile::getResultsPerPage()))); } else { //if list is not working, return all contacts return $this->searchBase(); } }
* technical reasons, the Appropriate Legal Notices must display the words * "Powered by X2Engine". *****************************************************************************************/ $heading = Yii::t('contacts', '{module} Lists', array('{module}' => Modules::displayName(false))); $this->pageTitle = $heading; $opportunityModule = Modules::model()->findByAttributes(array('name' => 'opportunities')); $accountModule = Modules::model()->findByAttributes(array('name' => 'accounts')); $menuOptions = array('all', 'lists', 'create', 'createList'); if ($opportunityModule->visible && $accountModule->visible) { $menuOptions[] = 'quick'; } $this->insertMenu($menuOptions); Yii::app()->clientScript->registerScript('search', "\n\$('.search-button').click(function(){\n\t\$('.search-form').toggle();\n\treturn false;\n});\n\$('.search-form form').submit(function(){\n\t\$.fn.yiiGridView.update('contacts-grid', {\n\t\tdata: \$(this).serialize()\n\t});\n\treturn false;\n});\n"); ?> <?php foreach (Yii::app()->user->getFlashes() as $key => $message) { echo '<div class="flash-' . $key . '">' . $message . "</div>\n"; } ?> <?php $attributeLabels = CActiveRecord::model('X2List')->attributeLabels(); $this->widget('X2GridViewGeneric', array('id' => 'lists-grid', 'template' => '<div class="page-title icon contacts"><h2>' . $heading . '</h2>{buttons}{filterHint}{summary}</div>{items}{pager}', 'buttons' => array('clearFilters', 'autoResize'), 'summaryText' => Yii::t('app', '<b>{start}–{end}</b> of <b>{count}</b>') . '<div class="form no-border" style="display:inline;"> ' . CHtml::dropDownList('resultsPerPage', Profile::getResultsPerPage(), Profile::getPossibleResultsPerPage(), array('ajax' => array('url' => $this->createUrl('/profile/setResultsPerPage'), 'data' => 'js:{results:$(this).val()}', 'complete' => 'function(response) { $.fn.yiiGridView.update("lists-grid"); }'))) . ' </div>', 'dataProvider' => $contactLists, 'filter' => $filter, 'gvSettingsName' => 'listsGrid', 'rowCssClassExpression' => '$this->rowCssClass[$row%2].($data["id"]==="all"?" bold":"")', 'defaultGvSettings' => array('name' => 180, 'type' => 180, 'assignedTo' => 180, 'count' => 180, 'gvControls' => 75), 'columns' => array(array('name' => 'name', 'header' => $attributeLabels['name'], 'type' => 'raw', 'value' => 'CHtml::link($data["name"],X2List::getRoute($data["id"]))'), array('name' => 'type', 'header' => $attributeLabels['type'], 'type' => 'raw', 'value' => '$data["type"]=="static"? Yii::t("contacts","Static") : Yii::t("contacts","Dynamic")'), array('name' => 'assignedTo', 'header' => $attributeLabels['assignedTo'], 'type' => 'raw', 'value' => 'User::getUserLinks($data["assignedTo"])'), array('name' => 'count', 'header' => $attributeLabels['count'], 'headerHtmlOptions' => array('class' => 'contact-count'), 'htmlOptions' => array('class' => 'contact-count'), 'filter' => '', 'value' => 'Yii::app()->locale->numberFormatter->formatDecimal($data->calculateCount ())'), array('id' => 'C_gvControls', 'class' => 'X2ButtonColumn', 'header' => Yii::t('app', 'Tools'), 'updateButtonUrl' => "Yii::app()->createUrl ('/contacts/updateList', array ('id' => \$data['id']))", 'cssClassExpression' => "!is_numeric (\$data['id']) ? 'hide-edit-delete-buttons' : ''", 'viewButtonUrl' => "X2List::getRoute (\$data['id'])", 'deleteButtonUrl' => "Yii::app()->createUrl ('/contacts/deleteList', array ('id' => \$data['id']))")))); ?> <div class="form"> <?php echo CHtml::link('<span>' . Yii::t('app', 'New List') . '</span>', array('/contacts/contacts/createList'), array('class' => 'x2-button')); ?> </div>
/** * Retrieves a list of models based on the current search/filter conditions. * @return CActiveDataProvider the data provider that can return the models based on the * search/filter conditions. */ public function search($id) { $criteria = new CDbCriteria(array('condition' => 'workflowId=' . $id, 'order' => 'stageNumber ASC')); return new CActiveDataProvider(get_class($this), array('criteria' => $criteria, 'pagination' => array('pageSize' => ceil(Profile::getResultsPerPage())))); }
if (isset($_GET['offset'])) { $offset = $_GET['offset']; } else { $offset = 'first day of this week'; } ?> <div class="search-form" style="display:none"> <?php $this->renderPartial('_search', array('model' => $model)); ?> </div><!-- search-form --> <div class='flush-grid-view'> <?php $this->widget('X2GridViewGeneric', array('id' => 'users-grid', 'buttons' => array('clearFilters', 'autoResize'), 'baseScriptUrl' => Yii::app()->request->baseUrl . '/themes/' . Yii::app()->theme->name . '/css/gridview/', 'title' => Yii::t('users', 'Manage {users}', array('{users}' => Modules::displayName())), 'template' => '<div class="page-title icon users">{title}' . '{buttons}{filterHint}{summary}</div>{items}{pager}', 'summaryText' => Yii::t('app', '<b>{start}–{end}</b> of <b>{count}</b>') . '<div class="form no-border" style="display:inline;"> ' . CHtml::dropDownList('resultsPerPage', Profile::getResultsPerPage(), Profile::getPossibleResultsPerPage(), array('ajax' => array('url' => $this->createUrl('/profile/setResultsPerPage'), 'data' => 'js:{results:$(this).val()}', 'complete' => 'function(response) { $.fn.yiiGridView.update("users-grid"); }'), 'style' => 'margin: 0;')) . ' </div>', 'gvSettingsName' => 'users-grid', 'viewName' => 'admin', 'dataProvider' => $model->search(), 'filter' => $model, 'defaultGvSettings' => array('username' => 90, 'firstName' => 90, 'lastName' => 90, 'login' => 90, 'emailAddress' => 60), 'columns' => array(array('name' => 'username', 'value' => 'CHtml::link(CHtml::encode($data->alias),array("/users/users/view","id"=>$data->id))', 'type' => 'raw'), array('name' => 'firstName'), array('name' => 'lastName'), array('name' => 'login', 'header' => Yii::t('users', 'Last Login'), 'value' => '$data->login?date("Y-m-d",$data->login):"n/a"', 'type' => 'raw'), array('header' => Yii::t('app', 'Active'), 'value' => '$data->status? Yii::t("app","Yes") : Yii::t("app","No")', 'type' => 'raw', 'headerHtmlOptions' => array('style' => 'width:60px;')), array('name' => 'emailAddress')))); ?> </div> <?php if ($count > 0) { ?> <br /> <h2><?php echo Yii::t('users', "Invited {users}", array('{users}' => Modules::displayName())); ?> </h2> <div class="form"> <b><?php echo Yii::t('users', "{n} {user}(s) have been invited but have not yet completed registration.", array('{n}' => $count, '{user}' => Modules::displayName(false))); ?> </b>
/** * Retrieves a list of models based on the current search/filter conditions. * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions. */ public function search() { $criteria = new CDbCriteria(); $criteria->compare('id', $this->id); $criteria->compare('firstName', $this->firstName, true); $criteria->compare('lastName', $this->lastName, true); $criteria->compare('username', $this->username, true); $criteria->compare('password', $this->password, true); $criteria->compare('title', $this->title, true); $criteria->compare('department', $this->department, true); $criteria->compare('officePhone', $this->officePhone, true); $criteria->compare('cellPhone', $this->cellPhone, true); $criteria->compare('homePhone', $this->homePhone, true); $criteria->compare('address', $this->address, true); $criteria->compare('backgroundInfo', $this->backgroundInfo, true); $criteria->compare('emailAddress', $this->emailAddress, true); $criteria->compare('status', $this->status); $criteria->compare('lastUpdated', $this->lastUpdated, true); $criteria->compare('updatedBy', $this->updatedBy, true); $criteria->compare('recentItems', $this->recentItems, true); $criteria->compare('topContacts', $this->topContacts, true); $criteria->compare('lastLogin', $this->lastLogin); $criteria->compare('login', $this->login); $criteria->addCondition('(temporary=0 OR temporary IS NULL)'); return new SmartActiveDataProvider(get_class($this), array('criteria' => $criteria, 'pagination' => array('pageSize' => Profile::getResultsPerPage()))); }
public function getPageSize() { return Profile::getResultsPerPage(); }
* * The interactive user interfaces in modified source and object code versions * of this program must display Appropriate Legal Notices, as required under * Section 5 of the GNU Affero General Public License version 3. * * In accordance with Section 7(b) of the GNU Affero General Public License version 3, * these Appropriate Legal Notices must retain the display of the "Powered by * X2Engine" logo. If the display of the logo is not reasonably feasible for * technical reasons, the Appropriate Legal Notices must display the words * "Powered by X2Engine". *****************************************************************************************/ Yii::app()->clientScript->registerCss('viewNotificationsCss', "\n\n#clear-all-button {\n margin-top: 4px;\n}\n\n"); ?> <div class="flush-grid-view"> <?php $this->widget('zii.widgets.grid.CGridView', array('id' => 'notifs-grid', 'baseScriptUrl' => Yii::app()->request->baseUrl . '/themes/' . Yii::app()->theme->name . '/css/gridview', 'dataProvider' => $dataProvider, 'template' => '<div class="page-title"><h2>' . Yii::t('app', 'Notifications') . '</h2>' . CHtml::link(Yii::t('app', 'Clear All'), '#', array('class' => 'x2-button right', 'id' => 'clear-all-button', 'submit' => array('/notifications/deleteAll'), 'confirm' => Yii::t('app', 'Permanently delete all notifications?'))) . '<div class="title-bar right">{summary}</div></div>{items}{pager}', 'summaryText' => Yii::t('app', '<b>{start}–{end}</b> of <b>{count}</b>') . '<div class="form no-border" style="display:inline;"> ' . CHtml::dropDownList('resultsPerPage', Profile::getResultsPerPage(), Profile::getPossibleResultsPerPage(), array('ajax' => array('url' => Yii::app()->controller->createUrl('/profile/setResultsPerPage'), 'data' => 'js:{results:$(this).val()}', 'complete' => 'function(response) { $.fn.yiiGridView.update("notifs-grid"); }'), 'style' => 'margin: 0;')) . '</div>', 'columns' => array(array('header' => Yii::t('actions', 'Notification'), 'value' => '$data->getMessage()', 'type' => 'raw', 'headerHtmlOptions' => array('style' => 'width:70%')), array('name' => 'createDate', 'header' => Yii::t('actions', 'Time'), 'value' => 'date("Y-m-d",$data->createDate)." ".date("g:i A",$data->createDate)', 'type' => 'raw'), array('class' => 'X2ButtonColumn', 'template' => '{delete}', 'deleteButtonUrl' => 'Yii::app()->controller->createUrl("/notifications/delete",array("id"=>$data->id))', 'afterDelete' => 'function(link,success,data){ var match = $(link).attr ("href").match (/[0-9]+$/); if (match !== null) x2.Notifs.triggerNotifRemoval (match[0]); }', 'deleteConfirmation' => false, 'headerHtmlOptions' => array('style' => 'width:40px'))), 'rowCssClassExpression' => '$data->viewed? "" : "unviewed"', 'pager' => array('class' => 'CLinkPager', 'header' => '', 'firstPageCssClass' => '', 'lastPageCssClass' => '', 'prevPageLabel' => '<', 'nextPageLabel' => '>', 'firstPageLabel' => '<<', 'lastPageLabel' => '>>'))); ?> </div> <?php foreach ($dataProvider->getData() as $notif) { if (!$notif->viewed) { $notif->viewed = true; $notif->update(); } } unset($notif);
public function searchBase($criteria, $pageSize = null, $showHidden = false) { if ($pageSize === null) { $pageSize = Profile::getResultsPerPage(); } $this->compareAttributes($criteria); /*$criteria->with = 'actionText'; $criteria->compare('actionText.text', $this->actionDescriptionTemp, true);*/ if (!empty($criteria->order)) { $criteria->order = $order = "t.sticky DESC, " . $criteria->order; } else { $order = 't.sticky DESC, IF( t.complete="No", IFNULL(t.dueDate, IFNULL(t.createDate,0)), GREATEST(t.createDate, IFNULL(t.completeDate,0), IFNULL(t.lastUpdated,0))) DESC'; } if (Yii::app()->controller instanceof ActionsController && Yii::app()->controller->action->id !== 'index') { $dataProvider = new SmartActiveDataProvider('Actions', array('sort' => array('defaultOrder' => $order), 'pagination' => array('pageSize' => $pageSize), 'criteria' => $criteria, 'uid' => $this->uid, 'dbPersistentGridSettings' => $this->dbPersistentGridSettings)); } else { // for actions index, use CActiveDataProvider since SmartActiveDataProvider is // incompatible with IasPager $dataProvider = new CActiveDataProvider('Actions', array('sort' => array('defaultOrder' => $order), 'pagination' => array('pageSize' => $pageSize), 'criteria' => $criteria)); } return $dataProvider; }
public function searchBase($criteria, $pageSize = null, $showHidden = 'false') { $criteria->compare('name', $this->name, true); return new SmartActiveDataProvider(get_class($this), array('sort' => array('defaultOrder' => 'createDate ASC'), 'pagination' => array('pageSize' => Profile::getResultsPerPage()), 'criteria' => $criteria)); }
/** * General field management. * * This action serves as the landing page for all of the custom field related * actions within the software. */ public function actionManageFields() { // New model for the form: $model = new Fields(); // Set up grid view: $searchModel = new Fields('search'); $criteria = new CDbCriteria(); $criteria->addCondition('modified=1'); $searchModel->setAttributes(isset($_GET['Fields']) ? $_GET['Fields'] : array(), false); foreach ($searchModel->attributes as $name => $value) { $criteria->compare($name, $value); } $pageSize = Profile::getResultsPerPage(); $dataProvider = new SmartActiveDataProvider('Fields', array('criteria' => $criteria, 'pagination' => array('pageSize' => Profile::getResultsPerPage()))); // Set up fields list $fields = Fields::model()->findAllByAttributes(array('custom' => '1')); $arr = array(); foreach ($fields as $field) { $arr[$field->id] = $field->attributeLabel; } $this->render('manageFields', array('dataProvider' => $dataProvider, 'model' => $model, 'searchModel' => $searchModel, 'fields' => $arr)); }
public function getContents() { $contents = array(0 => $this->createFileSystemObject(0, 'parent', null)); $index = 1; $children = $this->getChildren(); foreach ($children['folders'] as $folder) { $contents[$index] = $this->createFileSystemObject($index, 'folder', $folder); $index++; } foreach ($children['docs'] as $doc) { $contents[$index] = $this->createFileSystemObject($index, 'doc', $doc); $index++; } return new CArrayDataProvider($contents, array('id' => $this->id . '-folder-contents', 'pagination' => array('pageSize' => Profile::getResultsPerPage()))); }