当前位置: 首页>>代码示例>>PHP>>正文


PHP CPagination::getItemCount方法代码示例

本文整理汇总了PHP中CPagination::getItemCount方法的典型用法代码示例。如果您正苦于以下问题:PHP CPagination::getItemCount方法的具体用法?PHP CPagination::getItemCount怎么用?PHP CPagination::getItemCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CPagination的用法示例。


在下文中一共展示了CPagination::getItemCount方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: run

 /**
  * Executes the widget.
  */
 public function run()
 {
     if ($this->pagination->getPageCount() == $this->pagination->getCurrentPage() + 1) {
         return;
     }
     $showMoreUrl = CHtml::normalizeUrl(Yii::app()->createUrl('comment/comment/show', array('contentModel' => get_class($this->object), 'contentId' => $this->object->getPrimaryKey(), 'page' => $this->pagination->getCurrentPage() + 2)));
     $moreCount = $this->pagination->getPageSize();
     if ($this->pagination->getPageCount() == $this->pagination->getCurrentPage() + 2) {
         $moreCount = $this->pagination->getItemCount() - $this->pagination->getPageSize() - $this->pagination->getOffset();
     }
     $this->render('showMore', array('object' => $this->object, 'pagination' => $this->pagination, 'id' => get_class($this->object) . "_" . $this->object->getPrimaryKey(), 'showMoreUrl' => $showMoreUrl, 'moreCount' => $moreCount));
 }
开发者ID:skapl,项目名称:design,代码行数:15,代码来源:CommentsShowMoreWidget.php

示例2: actionGridData


//.........这里部分代码省略.........
         $company = 'all';
     }
     $paymentMethod = isset($_GET['paymentMethod']) ? $_GET['paymentMethod'] : null;
     if ($paymentMethod !== 'all' && $paymentMethod !== (string) CompanyPayment::CASH && $paymentMethod !== (string) CompanyPayment::CHECK && $paymentMethod !== (string) CompanyPayment::CREDIT_CARD && $paymentMethod !== (string) CompanyPayment::PAYPAL && $paymentMethod !== (string) CompanyPayment::WIRE) {
         $paymentMethod = 'all';
     }
     // criteria
     $criteria = new CDbCriteria();
     $criteria->group = "`t`.`id`";
     // required by together()
     $criteria->select = "`t`.amount, `t`.paymentDate, `t`.paymentMethod, `t`.paymentNumber";
     //$criteria->select="`t`.`amount`, `t`.`paymentDate`, `t`.`paymentMethod`, `t`.`paymentNumber`"; // uncomment in yii-1.1.2
     if ($jqGrid['searchField'] !== null && $jqGrid['searchString'] !== null && $jqGrid['searchOper'] !== null) {
         $field = array('amount' => "`t`.`amount`", 'paymentDate' => "`t`.`paymentDate`", 'paymentMethod' => "`t`.`paymentMethod`", 'paymentNumber' => "`t`.`paymentNumber`", 'company' => "`CompanyPayment_Company`.`title`");
         $operation = $this->getJqGridOperationArray();
         $keywordFormula = $this->getJqGridKeywordFormulaArray();
         if (isset($field[$jqGrid['searchField']]) && isset($operation[$jqGrid['searchOper']])) {
             $criteria->condition = '(' . $field[$jqGrid['searchField']] . ' ' . $operation[$jqGrid['searchOper']] . ' :keyword)';
             $criteria->params = array(':keyword' => str_replace('keyword', $jqGrid['searchString'], $keywordFormula[$jqGrid['searchOper']]));
             // search by special field types
             if ($jqGrid['searchField'] === 'createTime' && ($keyword = strtotime($jqGrid['searchString'])) !== false) {
                 $criteria->params = array(':keyword' => str_replace('keyword', $keyword, $keywordFormula[$jqGrid['searchOper']]));
                 if (date('H:i:s', $keyword) === '00:00:00') {
                     // visitor is looking for a precision by day, not by second
                     $criteria->condition = '(TO_DAYS(FROM_UNIXTIME(' . $field[$jqGrid['searchField']] . ',"%Y-%m-%d")) ' . $operation[$jqGrid['searchOper']] . ' TO_DAYS(FROM_UNIXTIME(:keyword,"%Y-%m-%d")))';
                 }
             }
         }
     }
     if ($company !== 'all') {
         $criteria->addCondition("`CompanyPayment_Company`.`id`=:companyId");
         $criteria->params[':companyId'] = $company;
     }
     if ($paymentMethod === (string) CompanyPayment::CASH) {
         $criteria->addCondition("`t`.`paymentMethod`=:cash");
         $criteria->params[':cash'] = CompanyPayment::CASH;
     } else {
         if ($paymentMethod === (string) CompanyPayment::CHECK) {
             $criteria->addCondition("`t`.`paymentMethod`=:check");
             $criteria->params[':check'] = CompanyPayment::CHECK;
         } else {
             if ($paymentMethod === (string) CompanyPayment::CREDIT_CARD) {
                 $criteria->addCondition("`t`.`paymentMethod`=:creditCard");
                 $criteria->params[':creditCard'] = CompanyPayment::CREDIT_CARD;
             } else {
                 if ($paymentMethod === (string) CompanyPayment::PAYPAL) {
                     $criteria->addCondition("`t`.`paymentMethod`=:paypal");
                     $criteria->params[':paypal'] = CompanyPayment::PAYPAL;
                 } else {
                     if ($paymentMethod === (string) CompanyPayment::WIRE) {
                         $criteria->addCondition("`t`.`paymentMethod`=:wire");
                         $criteria->params[':wire'] = CompanyPayment::WIRE;
                     }
                 }
             }
         }
     }
     if (User::isClient()) {
         $criteria->addCondition("`Company_User2Company`.`userId`=:clientId AND `Company_User2Company`.`position`=:clientPosition");
         $criteria->params[':clientId'] = Yii::app()->user->id;
         $criteria->params[':clientPosition'] = Company::OWNER;
     }
     // pagination
     $with = array();
     if (strpos($criteria->condition, 'CompanyPayment_Company') !== false) {
         $with[] = 'company';
     }
     if (strpos($criteria->condition, 'Company_User2Company') !== false) {
         $with[] = 'company.allUser2Company';
     }
     if (count($with) >= 1) {
         $pages = new CPagination(CompanyPayment::model()->with($with)->count($criteria));
     } else {
         $pages = new CPagination(CompanyPayment::model()->count($criteria));
     }
     $pages->pageSize = $jqGrid['pageSize'] !== null ? $jqGrid['pageSize'] : self::GRID_PAGE_SIZE;
     $pages->applyLimit($criteria);
     // sort
     $sort = new CSort('CompanyPayment');
     $sort->attributes = array('amount' => array('asc' => "`t`.`amount`", 'desc' => "`t`.`amount` desc", 'label' => CompanyPayment::model()->getAttributeLabel('amount')), 'paymentDate' => array('asc' => "`t`.`paymentDate`", 'desc' => "`t`.`paymentDate` desc", 'label' => CompanyPayment::model()->getAttributeLabel('Date')), 'paymentMethod' => array('asc' => "`t`.`paymentMethod`", 'desc' => "`t`.`paymentMethod` desc", 'label' => CompanyPayment::model()->getAttributeLabel('Method')), 'paymentNumber' => array('asc' => "`t`.`paymentNumber`", 'desc' => "`t`.`paymentNumber` desc", 'label' => CompanyPayment::model()->getAttributeLabel('Number')), 'company' => array('asc' => "`CompanyPayment_Company`.`title`", 'desc' => "`CompanyPayment_Company`.`title` desc", 'label' => CompanyPayment::model()->getAttributeLabel('companyId')));
     $sort->defaultOrder = "`t`.`paymentDate` DESC";
     $sort->applyOrder($criteria);
     // find all
     $with = array('company' => array('select' => 'title'));
     if (strpos($criteria->condition, 'Company_User2Company') !== false) {
         $with['company.allUser2Company'] = array('select' => 'id');
     }
     $together = strpos($criteria->condition, 'Company_User2Company') !== false;
     if ($together) {
         $models = CompanyPayment::model()->with($with)->together()->findAll($criteria);
     } else {
         $models = CompanyPayment::model()->with($with)->findAll($criteria);
     }
     // create resulting data array
     $data = array('page' => $pages->getCurrentPage() + 1, 'total' => $pages->getPageCount(), 'records' => $pages->getItemCount(), 'rows' => array());
     foreach ($models as $model) {
         $data['rows'][] = array('id' => $model->id, 'cell' => array(isset($model->company->id) ? CHtml::link(CHtml::encode($model->company->title), array('company/show', 'id' => $model->company->id)) : '', CHtml::encode(MDate::format($model->paymentDate, 'medium', null)), CHtml::encode($model->amount), CHtml::encode($model->getAttributeView('paymentMethod')), CHtml::encode($model->paymentNumber), CHtml::link('<span class="ui-icon ui-icon-zoomin"></span>', array('show', 'id' => $model->id), array('class' => 'w3-ig w3-link-icon w3-border-1px-transparent w3-first ui-corner-all', 'title' => Yii::t('link', 'Show'))) . CHtml::link('<span class="ui-icon ui-icon-pencil"></span>', array('update', 'id' => $model->id), array('class' => 'w3-ig w3-link-icon w3-border-1px-transparent w3-last ui-corner-all', 'title' => Yii::t('link', 'Edit')))));
     }
     $this->printJson($data);
 }
开发者ID:megabr,项目名称:web3cms,代码行数:101,代码来源:CompanyPaymentController.php

示例3: actionGridData


//.........这里部分代码省略.........
             $criteria->condition = '(' . $field[$jqGrid['searchField']] . ' ' . $operation[$jqGrid['searchOper']] . ' :keyword)';
             $criteria->params = array(':keyword' => str_replace('keyword', $jqGrid['searchString'], $keywordFormula[$jqGrid['searchOper']]));
             // search by special field types
             if ($jqGrid['searchField'] === 'createTime' && ($keyword = strtotime($jqGrid['searchString'])) !== false) {
                 $criteria->params = array(':keyword' => str_replace('keyword', $keyword, $keywordFormula[$jqGrid['searchOper']]));
                 if (date('H:i:s', $keyword) === '00:00:00') {
                     // visitor is looking for a precision by day, not by second
                     $criteria->condition = '(TO_DAYS(FROM_UNIXTIME(' . $field[$jqGrid['searchField']] . ',"%Y-%m-%d")) ' . $operation[$jqGrid['searchOper']] . ' TO_DAYS(FROM_UNIXTIME(:keyword,"%Y-%m-%d")))';
                 }
             }
         }
     }
     if ($company !== 'all') {
         $criteria->addCondition("`Project_Company`.`id`=:companyId");
         $criteria->params[':companyId'] = $company;
     }
     if ($priority === (string) Project::PRIORITY_HIGHEST) {
         $criteria->addCondition("`t`.`priority`=:priorityHighest");
         $criteria->params[':priorityHighest'] = Project::PRIORITY_HIGHEST;
     } else {
         if ($priority === (string) Project::PRIORITY_HIGH) {
             $criteria->addCondition("`t`.`priority`=:priorityHigh");
             $criteria->params[':priorityHigh'] = Project::PRIORITY_HIGH;
         } else {
             if ($priority === (string) Project::PRIORITY_MEDIUM) {
                 $criteria->addCondition("`t`.`priority`=:priorityMedium");
                 $criteria->params[':priorityMedium'] = Project::PRIORITY_MEDIUM;
             } else {
                 if ($priority === (string) Project::PRIORITY_LOW) {
                     $criteria->addCondition("`t`.`priority`=:priorityLow");
                     $criteria->params[':priorityLow'] = Project::PRIORITY_LOW;
                 } else {
                     if ($priority === (string) Project::PRIORITY_LOWEST) {
                         $criteria->addCondition("`t`.`priority`=:priorityLowest");
                         $criteria->params[':priorityLowest'] = Project::PRIORITY_LOWEST;
                     }
                 }
             }
         }
     }
     if ($state === 'closed') {
         $criteria->addCondition("`t`.`closeDate` IS NOT NULL");
     } else {
         if ($state === 'open') {
             $criteria->addCondition("(`t`.`closeDate` IS NULL OR TO_DAYS('" . MDate::formatToDb(time(), 'date') . "') < TO_DAYS(`t`.`closeDate`))");
         }
     }
     if (User::isClient()) {
         $criteria->addCondition("`Company_User2Company`.`userId`=:clientId AND `Company_User2Company`.`position`=:clientPosition");
         $criteria->params[':clientId'] = Yii::app()->user->id;
         $criteria->params[':clientPosition'] = Company::OWNER;
     }
     if (User::isConsultant()) {
         $criteria->addCondition("`Task_Consultant`.`id`=:consultantId");
         $criteria->params[':consultantId'] = Yii::app()->user->id;
     }
     // pagination
     $with = array();
     if (strpos($criteria->condition, 'Project_Company') !== false) {
         $with[] = 'allCompany';
     }
     if (strpos($criteria->condition, 'Company_User2Company') !== false) {
         $with[] = 'allCompany.allUser2Company';
     }
     if (strpos($criteria->condition, 'Task_Consultant') !== false) {
         $with[] = 'allTask.allConsultant';
     }
     if (count($with) >= 1) {
         $pages = new CPagination(Project::model()->with($with)->count($criteria));
     } else {
         $pages = new CPagination(Project::model()->count($criteria));
     }
     $pages->pageSize = $jqGrid['pageSize'] !== null ? $jqGrid['pageSize'] : self::GRID_PAGE_SIZE;
     $pages->applyLimit($criteria);
     // sort
     $sort = new CSort('Project');
     $sort->attributes = array('closeDate' => array('asc' => "`t`.`closeDate`", 'desc' => "`t`.`closeDate` desc", 'label' => Project::model()->getAttributeLabel('Closed')), 'hourlyRate' => array('asc' => "`t`.`hourlyRate`", 'desc' => "`t`.`hourlyRate` desc", 'label' => Project::model()->getAttributeLabel('Rate')), 'openDate' => array('asc' => "`t`.`openDate`", 'desc' => "`t`.`openDate` desc", 'label' => Project::model()->getAttributeLabel('Opened')), 'priority' => array('asc' => "`t`.`priority`", 'desc' => "`t`.`priority` desc", 'label' => Project::model()->getAttributeLabel('priority')), 'title' => array('asc' => "`t`.`title`", 'desc' => "`t`.`title` desc", 'label' => Project::model()->getAttributeLabel('title')), 'company' => array('asc' => "`Project_Company`.`title`", 'desc' => "`Project_Company`.`title` desc", 'label' => Company2Project::model()->getAttributeLabel('companyId')));
     $sort->defaultOrder = "`t`.`closeDate` ASC, `t`.`priority` ASC, `t`.`createTime` DESC";
     $sort->applyOrder($criteria);
     // find all
     $with = array('allCompany' => array('select' => 'title'));
     if (strpos($criteria->condition, 'Company_User2Company') !== false) {
         $with['allCompany.allUser2Company'] = array('select' => 'id');
     }
     if (strpos($criteria->condition, 'Task_Consultant') !== false) {
         $with['allTask.allConsultant'] = array('select' => 'id');
     }
     $together = strpos($criteria->condition, 'Project_Company') !== false || strpos($criteria->order, 'Project_Company') !== false || strpos($criteria->condition, 'Company_User2Company') !== false || strpos($criteria->condition, 'Task_Consultant') !== false;
     if ($together) {
         $models = Project::model()->with($with)->together()->findAll($criteria);
     } else {
         $models = Project::model()->with($with)->findAll($criteria);
     }
     // create resulting data array
     $data = array('page' => $pages->getCurrentPage() + 1, 'total' => $pages->getPageCount(), 'records' => $pages->getItemCount(), 'rows' => array());
     foreach ($models as $model) {
         $data['rows'][] = array('id' => $model->id, 'cell' => array(isset($model->allCompany[0]->id) ? CHtml::link(CHtml::encode($model->allCompany[0]->title), array('company/show', 'id' => $model->allCompany[0]->id)) : '', CHtml::encode($model->title), CHtml::encode($model->hourlyRate), CHtml::encode($model->getAttributeView('priority')), CHtml::encode(MDate::format($model->openDate, 'medium', null)), CHtml::encode(MDate::format($model->closeDate, 'medium', null)), CHtml::link('<span class="ui-icon ui-icon-zoomin"></span>', array('show', 'id' => $model->id), array('class' => 'w3-ig w3-link-icon w3-border-1px-transparent w3-first ui-corner-all', 'title' => Yii::t('link', 'Show'))) . CHtml::link('<span class="ui-icon ui-icon-pencil"></span>', array('update', 'id' => $model->id), array('class' => 'w3-ig w3-link-icon w3-border-1px-transparent w3-last ui-corner-all', 'title' => Yii::t('link', 'Edit')))));
     }
     $this->printJson($data);
 }
开发者ID:megabr,项目名称:web3cms,代码行数:101,代码来源:ProjectController.php

示例4: actionGridData

 /**
  * Print out array of models for the jqGrid rows.
  */
 public function actionGridData()
 {
     if (!Yii::app()->request->isPostRequest) {
         throw new CHttpException(400, Yii::t('http', 'Invalid request. Please do not repeat this request again.'));
         exit;
     }
     // specify request details
     $jqGrid = $this->processJqGridRequest();
     // specify filter parameters
     $state = isset($_GET['state']) ? $_GET['state'] : null;
     if ($state !== 'all' && $state !== 'closed' && $state !== 'open') {
         $state = 'all';
     }
     // criteria
     $criteria = new CDbCriteria();
     $criteria->group = "`t`.`id`";
     // required by together()
     $criteria->select = "`t`.contactName, `t`.createTime, `t`.deactivationTime, `t`.title, `t`.titleAbbr";
     //$criteria->select="`t`.`contactName`, `t`.`createTime`, `t`.`deactivationTime`, `t`.`title`, `t`.`titleAbbr`"; // uncomment in yii-1.1.2
     if ($jqGrid['searchField'] !== null && $jqGrid['searchString'] !== null && $jqGrid['searchOper'] !== null) {
         $field = array('contactName' => "`t`.`contactName`", 'createTime' => "`t`.`createTime`", 'deactivationTime' => "`t`.`deactivationTime`", 'title' => "`t`.`title`", 'titleAbbr' => "`t`.`titleAbbr`");
         $operation = $this->getJqGridOperationArray();
         $keywordFormula = $this->getJqGridKeywordFormulaArray();
         if (isset($field[$jqGrid['searchField']]) && isset($operation[$jqGrid['searchOper']])) {
             $criteria->condition = '(' . $field[$jqGrid['searchField']] . ' ' . $operation[$jqGrid['searchOper']] . ' :keyword)';
             $criteria->params = array(':keyword' => str_replace('keyword', $jqGrid['searchString'], $keywordFormula[$jqGrid['searchOper']]));
             // search by special field types
             if ($jqGrid['searchField'] === 'createTime' && ($keyword = strtotime($jqGrid['searchString'])) !== false) {
                 $criteria->params = array(':keyword' => str_replace('keyword', $keyword, $keywordFormula[$jqGrid['searchOper']]));
                 if (date('H:i:s', $keyword) === '00:00:00') {
                     // visitor is looking for a precision by day, not by second
                     $criteria->condition = '(TO_DAYS(FROM_UNIXTIME(' . $field[$jqGrid['searchField']] . ',"%Y-%m-%d")) ' . $operation[$jqGrid['searchOper']] . ' TO_DAYS(FROM_UNIXTIME(:keyword,"%Y-%m-%d")))';
                 }
             }
         }
     }
     if ($state === 'closed') {
         $criteria->addCondition("(`t`.`isActive` IS NULL OR `t`.`isActive`!=:isActive)");
         $criteria->params[':isActive'] = Company::IS_ACTIVE;
     } else {
         if ($state === 'open') {
             $criteria->addCondition("`t`.`isActive`=:isActive");
             $criteria->params[':isActive'] = Company::IS_ACTIVE;
         }
     }
     if (User::isClient()) {
         $criteria->addCondition("`Company_User2Company`.`userId`=:clientId AND `Company_User2Company`.`position`=:clientPosition");
         $criteria->params[':clientId'] = Yii::app()->user->id;
         $criteria->params[':clientPosition'] = Company::OWNER;
     }
     // pagination
     $with = array();
     if (strpos($criteria->condition, 'Company_User2Company') !== false) {
         $with[] = 'allUser2Company';
     }
     if (count($with) >= 1) {
         $pages = new CPagination(Company::model()->with($with)->count($criteria));
     } else {
         $pages = new CPagination(Company::model()->count($criteria));
     }
     $pages->pageSize = $jqGrid['pageSize'] !== null ? $jqGrid['pageSize'] : self::GRID_PAGE_SIZE;
     $pages->applyLimit($criteria);
     // sort
     $sort = new CSort('Company');
     $sort->attributes = array('contactName' => array('asc' => "`t`.`contactName`", 'desc' => "`t`.`contactName` desc", 'label' => Company::model()->getAttributeLabel('contactName')), 'createTime' => array('asc' => "`t`.`createTime`", 'desc' => "`t`.`createTime` desc", 'label' => Company::model()->getAttributeLabel('Opened')), 'deactivationTime' => array('asc' => "`t`.`deactivationTime`", 'desc' => "`t`.`deactivationTime` desc", 'label' => Company::model()->getAttributeLabel('Closed')), 'title' => array('asc' => "`t`.`title`", 'desc' => "`t`.`title` desc", 'label' => Company::model()->getAttributeLabel('title')), 'titleAbbr' => array('asc' => "`t`.`titleAbbr`", 'desc' => "`t`.`titleAbbr` desc", 'label' => Company::model()->getAttributeLabel('Abbr')));
     $sort->defaultOrder = "`t`.`deactivationTime` ASC, `t`.`title` ASC";
     $sort->applyOrder($criteria);
     // find all
     $with = array();
     if (strpos($criteria->condition, 'Company_User2Company') !== false) {
         $with['allUser2Company'] = array('select' => 'id');
     }
     $together = strpos($criteria->condition, 'Company_User2Company') !== false;
     if ($together) {
         $models = Company::model()->with($with)->together()->findAll($criteria);
     } else {
         $models = Company::model()->with($with)->findAll($criteria);
     }
     // create resulting data array
     $data = array('page' => $pages->getCurrentPage() + 1, 'total' => $pages->getPageCount(), 'records' => $pages->getItemCount(), 'rows' => array());
     foreach ($models as $model) {
         $data['rows'][] = array('id' => $model->id, 'cell' => array(CHtml::encode($model->title), CHtml::encode($model->titleAbbr), CHtml::encode($model->contactName), CHtml::encode(MDate::format($model->createTime, 'medium', null)), CHtml::encode(MDate::format($model->deactivationTime, 'medium', null)), CHtml::link('<span class="ui-icon ui-icon-zoomin"></span>', array('show', 'id' => $model->id), array('class' => 'w3-ig w3-link-icon w3-border-1px-transparent w3-first ui-corner-all', 'title' => Yii::t('link', 'Show'))) . CHtml::link('<span class="ui-icon ui-icon-pencil"></span>', array('update', 'id' => $model->id), array('class' => 'w3-ig w3-link-icon w3-border-1px-transparent w3-last ui-corner-all', 'title' => Yii::t('link', 'Edit')))));
     }
     $this->printJson($data);
 }
开发者ID:megabr,项目名称:web3cms,代码行数:88,代码来源:CompanyController.php

示例5: actiongetposterPages

 /**
  * 根据分页获取海报分页标签
  **/
 public function actiongetposterPages()
 {
     $limit = 18;
     $page_sum = Yii::app()->request->getParam("page_sum");
     $criteria = new CDbCriteria();
     $pages = new CPagination($page_sum);
     $pages->pageSize = $limit;
     $pages->applyLimit($criteria);
     $this->widget('CLinkPager', array('header' => $pages->getItemCount() . "条&nbsp;&nbsp;共" . $pages->getPageCount() . "页&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;", 'firstPageLabel' => '首页', 'lastPageLabel' => '末页', 'prevPageLabel' => '上一页', 'nextPageLabel' => '下一页', 'pagelist' => true, 'maxButtonCount' => 5, 'pages' => $pages, "cssFile" => "/css/pager.css"));
 }
开发者ID:bobwuyan,项目名称:testproject,代码行数:13,代码来源:ERPController.php

示例6: actionGridData

 /**
  * Print out array of models for the jqGrid rows.
  */
 public function actionGridData()
 {
     if (!Yii::app()->request->isPostRequest) {
         throw new CHttpException(400, Yii::t('http', 'Invalid request. Please do not repeat this request again.'));
         exit;
     }
     // specify request details
     $jqGrid = $this->processJqGridRequest();
     // specify filter parameters
     $accessType = isset($_GET['accessType']) ? $_GET['accessType'] : null;
     if ($accessType !== 'all' && $accessType !== (string) User::MEMBER && $accessType !== (string) User::CLIENT && $accessType !== (string) User::CONSULTANT && $accessType !== (string) User::MANAGER && $accessType !== (string) User::ADMINISTRATOR) {
         $accessType = 'all';
     }
     $state = isset($_GET['state']) ? $_GET['state'] : null;
     if ($state !== 'all' && $state !== 'active' && $state !== 'inactive') {
         $state = 'all';
     }
     // criteria
     $criteria = new CDbCriteria();
     if ($jqGrid['searchField'] !== null && $jqGrid['searchString'] !== null && $jqGrid['searchOper'] !== null) {
         $field = array('accessType' => "`t`.`accessType`", 'createTime' => "`t`.`createTime`", 'email' => "`t`.`email`", 'screenName' => "`t`.`screenName`", 'deactivationTime' => "`User_UserDetails`.`deactivationTime`", 'occupation' => "`User_UserDetails`.`occupation`");
         $operation = $this->getJqGridOperationArray();
         $keywordFormula = $this->getJqGridKeywordFormulaArray();
         if (isset($field[$jqGrid['searchField']]) && isset($operation[$jqGrid['searchOper']])) {
             $criteria->condition = '(' . $field[$jqGrid['searchField']] . ' ' . $operation[$jqGrid['searchOper']] . ' :keyword)';
             $criteria->params = array(':keyword' => str_replace('keyword', $jqGrid['searchString'], $keywordFormula[$jqGrid['searchOper']]));
             // search by special field types
             if ($jqGrid['searchField'] === 'createTime' && ($keyword = strtotime($jqGrid['searchString'])) !== false) {
                 $criteria->params = array(':keyword' => str_replace('keyword', $keyword, $keywordFormula[$jqGrid['searchOper']]));
                 if (date('H:i:s', $keyword) === '00:00:00') {
                     // visitor is looking for a precision by day, not by second
                     $criteria->condition = '(TO_DAYS(FROM_UNIXTIME(' . $field[$jqGrid['searchField']] . ',"%Y-%m-%d")) ' . $operation[$jqGrid['searchOper']] . ' TO_DAYS(FROM_UNIXTIME(:keyword,"%Y-%m-%d")))';
                 }
             }
         }
     }
     if ($accessType === (string) User::MEMBER) {
         $criteria->addCondition("`t`.`accessType`=:member");
         $criteria->params[':member'] = User::MEMBER;
     } else {
         if ($accessType === (string) User::CLIENT) {
             $criteria->addCondition("`t`.`accessType`=:client");
             $criteria->params[':client'] = User::CLIENT;
         } else {
             if ($accessType === (string) User::CONSULTANT) {
                 $criteria->addCondition("`t`.`accessType`=:consultant");
                 $criteria->params[':consultant'] = User::CONSULTANT;
             } else {
                 if ($accessType === (string) User::MANAGER) {
                     $criteria->addCondition("`t`.`accessType`=:manager");
                     $criteria->params[':manager'] = User::MANAGER;
                 } else {
                     if ($accessType === (string) User::ADMINISTRATOR) {
                         $criteria->addCondition("`t`.`accessType`=:administrator");
                         $criteria->params[':administrator'] = User::ADMINISTRATOR;
                     }
                 }
             }
         }
     }
     if ($state === 'active') {
         $criteria->addCondition("(`t`.`isActive` IS NULL OR `t`.`isActive`!=:isNotActive)");
         $criteria->params[':isNotActive'] = User::IS_NOT_ACTIVE;
     } else {
         if ($state === 'inactive') {
             $criteria->addCondition("`t`.`isActive`=:isNotActive");
             $criteria->params[':isNotActive'] = User::IS_NOT_ACTIVE;
         }
     }
     // pagination
     $with = array();
     if (strpos($criteria->condition, 'User_UserDetails') !== false) {
         $with[] = 'details';
     }
     if (count($with) >= 1) {
         $pages = new CPagination(User::model()->with($with)->count($criteria));
     } else {
         $pages = new CPagination(User::model()->count($criteria));
     }
     $pages->pageSize = $jqGrid['pageSize'] !== null ? $jqGrid['pageSize'] : self::GRID_PAGE_SIZE;
     $pages->applyLimit($criteria);
     // sort
     $sort = new CSort('User');
     $sort->attributes = array('accessType' => array('asc' => "`t`.`accessLevel`", 'desc' => "`t`.`accessLevel` desc", 'label' => User::model()->getAttributeLabel('accessType')), 'createTime' => array('asc' => "`t`.`createTime`", 'desc' => "`t`.`createTime` desc", 'label' => User::model()->getAttributeLabel('Registered')), 'email' => array('asc' => "`t`.`email`", 'desc' => "`t`.`email` desc", 'label' => User::model()->getAttributeLabel('email')), 'screenName' => array('asc' => "`t`.`screenName`", 'desc' => "`t`.`screenName` desc", 'label' => User::model()->getAttributeLabel('screenName')), 'deactivationTime' => array('asc' => "`User_UserDetails`.`deactivationTime`", 'desc' => "`User_UserDetails`.`deactivationTime` desc", 'label' => UserDetails::model()->getAttributeLabel('Deact')), 'occupation' => array('asc' => "`User_UserDetails`.`occupation`", 'desc' => "`User_UserDetails`.`occupation` desc", 'label' => UserDetails::model()->getAttributeLabel('occupation')));
     $sort->defaultOrder = "`t`.`screenName`";
     $sort->applyOrder($criteria);
     // find all
     $models = User::model()->with('details')->findAll($criteria);
     // create resulting data array
     $data = array('page' => $pages->getCurrentPage() + 1, 'total' => $pages->getPageCount(), 'records' => $pages->getItemCount(), 'rows' => array());
     foreach ($models as $model) {
         $data['rows'][] = array('id' => $model->id, 'cell' => array(CHtml::encode($model->screenName), CHtml::encode($model->details->occupation), CHtml::encode($model->email), CHtml::encode(MDate::format($model->createTime, 'medium', null)), CHtml::encode(MDate::format($model->details->deactivationTime, 'medium', null)), CHtml::encode($model->getAttributeView('accessType')), CHtml::link('<span class="ui-icon ui-icon-zoomin"></span>', array('show', 'id' => $model->id), array('class' => 'w3-ig w3-link-icon w3-border-1px-transparent w3-first ui-corner-all', 'title' => Yii::t('link', 'Show'))) . CHtml::link('<span class="ui-icon ui-icon-pencil"></span>', array('update', 'id' => $model->id), array('class' => 'w3-ig w3-link-icon w3-border-1px-transparent w3-last ui-corner-all', 'title' => Yii::t('link', 'Edit')))));
     }
     $this->printJson($data);
 }
开发者ID:megabr,项目名称:web3cms,代码行数:98,代码来源:UserController.php

示例7: actionGridData


//.........这里部分代码省略.........
     // required by together()
     $criteria->select = "`t`.billedMinute, `t`.spentMinute, `t`.timeDate, `t`.title";
     //$criteria->select="`t`.`billedMinute`, `t`.`spentMinute`, `t`.`timeDate`, `t`.`title`"; // uncomment in yii-1.1.2
     if ($jqGrid['searchField'] !== null && $jqGrid['searchString'] !== null && $jqGrid['searchOper'] !== null) {
         $field = array('billedMinute' => "`t`.`billedMinute`", 'spentMinute' => "`t`.`spentMinute`", 'timeDate' => "`t`.`timeDate`", 'title' => "`t`.`title`", 'consultant' => "`Time_Consultant`.`screenName`", 'manager' => "`Time_Manager`.`screenName`", 'task' => "`Time_Task`.`title`", 'company' => "`Task_Company`.`title`", 'project' => "`Task_Project`.`title`");
         $operation = $this->getJqGridOperationArray();
         $keywordFormula = $this->getJqGridKeywordFormulaArray();
         if (isset($field[$jqGrid['searchField']]) && isset($operation[$jqGrid['searchOper']])) {
             $criteria->condition = '(' . $field[$jqGrid['searchField']] . ' ' . $operation[$jqGrid['searchOper']] . ' :keyword)';
             $criteria->params = array(':keyword' => str_replace('keyword', $jqGrid['searchString'], $keywordFormula[$jqGrid['searchOper']]));
             // search by special field types
             if ($jqGrid['searchField'] === 'createTime' && ($keyword = strtotime($jqGrid['searchString'])) !== false) {
                 $criteria->params = array(':keyword' => str_replace('keyword', $keyword, $keywordFormula[$jqGrid['searchOper']]));
                 if (date('H:i:s', $keyword) === '00:00:00') {
                     // visitor is looking for a precision by day, not by second
                     $criteria->condition = '(TO_DAYS(FROM_UNIXTIME(' . $field[$jqGrid['searchField']] . ',"%Y-%m-%d")) ' . $operation[$jqGrid['searchOper']] . ' TO_DAYS(FROM_UNIXTIME(:keyword,"%Y-%m-%d")))';
                 }
             }
         }
     }
     if ($company !== 'all') {
         $criteria->addCondition("`Task_Company`.`id`=:companyId");
         $criteria->params[':companyId'] = $company;
     }
     if ($consultant !== 'all') {
         if ($consultant === 'me') {
             $criteria->addCondition("`Time_Consultant`.`id`=:consultantId");
             $criteria->params[':consultantId'] = Yii::app()->user->id;
         } else {
             $criteria->addCondition("`Time_Consultant`.`id`=:consultantId");
             $criteria->params[':consultantId'] = $consultant;
         }
     }
     if ($manager !== 'all') {
         $criteria->addCondition("`Time_Manager`.`id`=:managerId");
         $criteria->params[':managerId'] = $manager;
     }
     if ($project !== 'all') {
         $criteria->addCondition("`Task_Project`.`id`=:projectId");
         $criteria->params[':projectId'] = $project;
     }
     if ($task !== 'all') {
         $criteria->addCondition("`Time_Task`.`id`=:taskId");
         $criteria->params[':taskId'] = $task;
     }
     if (Yii::app()->user->checkAccess(User::CLIENT)) {
         $criteria->addCondition("`Company_User2Company`.`userId`=:clientId AND `Company_User2Company`.`position`=:clientPosition");
         $criteria->params[':clientId'] = Yii::app()->user->id;
         $criteria->params[':clientPosition'] = Company::OWNER;
     }
     // pagination
     $with = array();
     if (strpos($criteria->condition, 'Task_Company') !== false) {
         $with[] = 'task.company';
     }
     if (strpos($criteria->condition, 'Time_Consultant') !== false) {
         $with[] = 'consultant';
     }
     if (strpos($criteria->condition, 'Time_Manager') !== false) {
         $with[] = 'manager';
     }
     if (strpos($criteria->condition, 'Task_Project') !== false) {
         $with[] = 'task.project';
     }
     if (strpos($criteria->condition, 'Time_Task') !== false) {
         $with[] = 'task';
     }
     if (strpos($criteria->condition, 'Company_User2Company') !== false) {
         $with[] = 'task.company.allUser2Company';
     }
     if (count($with) >= 1) {
         $pages = new CPagination(Time::model()->with($with)->count($criteria));
     } else {
         $pages = new CPagination(Time::model()->count($criteria));
     }
     $pages->pageSize = $jqGrid['pageSize'] !== null ? $jqGrid['pageSize'] : self::GRID_PAGE_SIZE;
     $pages->applyLimit($criteria);
     // sort
     $sort = new CSort('Time');
     $sort->attributes = array('billedMinute' => array('asc' => "`t`.`billedMinute`", 'desc' => "`t`.`billedMinute` desc", 'label' => Time::model()->getAttributeLabel('Bld')), 'spentMinute' => array('asc' => "`t`.`spentMinute`", 'desc' => "`t`.`spentMinute` desc", 'label' => Time::model()->getAttributeLabel('Spt')), 'timeDate' => array('asc' => "`t`.`timeDate`", 'desc' => "`t`.`timeDate` desc", 'label' => Time::model()->getAttributeLabel('Date')), 'title' => array('asc' => "`t`.`title`", 'desc' => "`t`.`title` desc", 'label' => Time::model()->getAttributeLabel('title')), 'consultant' => array('asc' => "`Time_Consultant`.`screenName`", 'desc' => "`Time_Consultant`.`screenName` desc", 'label' => Time::model()->getAttributeLabel('consultantId')), 'manager' => array('asc' => "`Time_Manager`.`screenName`", 'desc' => "`Time_Manager`.`screenName` desc", 'label' => Time::model()->getAttributeLabel('managerId')), 'task' => array('asc' => "`Time_Task`.`title`", 'desc' => "`Time_Task`.`title` desc", 'label' => Time::model()->getAttributeLabel('taskId')), 'company' => array('asc' => "`Task_Company`.`title`", 'desc' => "`Task_Company`.`title` desc", 'label' => Task::model()->getAttributeLabel('companyId')), 'project' => array('asc' => "`Task_Project`.`title`", 'desc' => "`Task_Project`.`title` desc", 'label' => Task::model()->getAttributeLabel('projectId')));
     $sort->defaultOrder = "`t`.`timeDate` DESC, `t`.`createTime` DESC";
     $sort->applyOrder($criteria);
     // find all
     $with = array('consultant' => array('select' => 'screenName'), 'manager' => array('select' => 'screenName'), 'task' => array('select' => 'title'), 'task.company' => array('select' => 'title'), 'task.project' => array('select' => 'title'));
     if (strpos($criteria->condition, 'Company_User2Company') !== false) {
         $with['task.company.allUser2Company'] = array('select' => 'id');
     }
     $together = strpos($criteria->condition, 'Company_User2Company') !== false;
     if ($together) {
         $models = Time::model()->with($with)->together()->findAll($criteria);
     } else {
         $models = Time::model()->with($with)->findAll($criteria);
     }
     // create resulting data array
     $data = array('page' => $pages->getCurrentPage() + 1, 'total' => $pages->getPageCount(), 'records' => $pages->getItemCount(), 'rows' => array());
     foreach ($models as $model) {
         $data['rows'][] = array('id' => $model->id, 'cell' => array(isset($model->task->company->id) ? CHtml::link(CHtml::encode($model->task->company->title), array('company/show', 'id' => $model->task->company->id)) : '', isset($model->task->project->id) ? CHtml::link(CHtml::encode($model->task->project->title), array('project/show', 'id' => $model->task->project->id)) : '', isset($model->task->id) ? CHtml::link(CHtml::encode($model->task->title), array('task/show', 'id' => $model->task->id)) : '', isset($model->manager->id) ? CHtml::link(CHtml::encode($model->manager->screenName), array('user/show', 'id' => $model->manager->id)) : '', isset($model->consultant->id) ? CHtml::link(CHtml::encode($model->consultant->screenName), array('user/show', 'id' => $model->consultant->id)) : '', CHtml::encode(MDate::format($model->timeDate, 'medium', null)), CHtml::encode($model->getAttributeView('spentMinute')), CHtml::encode($model->getAttributeView('billedMinute')), CHtml::encode($model->title), Yii::app()->user->checkAccess('time/show') ? CHtml::link('<span class="ui-icon ui-icon-zoomin"></span>', array('show', 'id' => $model->id), array('class' => 'w3-ig w3-link-icon w3-border-1px-transparent w3-first ui-corner-all', 'title' => Yii::t('link', 'Show'))) . CHtml::link('<span class="ui-icon ui-icon-pencil"></span>', array('update', 'id' => $model->id), array('class' => 'w3-ig w3-link-icon w3-border-1px-transparent ui-corner-all', 'title' => Yii::t('link', 'Edit'))) . CHtml::link('<span class="ui-icon ui-icon-trash"></span>', array('delete', 'id' => $model->id), array('class' => 'w3-ig w3-link-icon w3-border-1px-transparent w3-last ui-corner-all', 'title' => Yii::t('link', 'Delete the record number {id}', array('{id}' => $model->id)))) : CHtml::link('<span class="ui-icon ui-icon-zoomin"></span>', array('show', 'id' => $model->id), array('class' => 'w3-ig w3-link-icon w3-border-1px-transparent w3-first w3-last ui-corner-all', 'title' => Yii::t('link', 'Show')))));
     }
     $this->printJson($data);
 }
开发者ID:megabr,项目名称:web3cms,代码行数:101,代码来源:TimeController.php


注:本文中的CPagination::getItemCount方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。