/** * 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)); }
/** * Handles all incoming requests for the entire site that are not previous defined in CUrlManager * Requests come in, are verified, and then pulled from the database dynamically * Shows all blog posts for a particular category_id * @param $id - The content ID that we want to pull from the database * @return $this->render() - Render of page that we want to display **/ public function actionIndex($id = NULL) { // Run a pre check of our data $this->beforeCiiAction($id); // Retrieve the data $category = Categories::model()->findByPk($id); $this->breadcrumbs = Categories::model()->getParentCategories($id); // Parse Metadata $meta = Categories::model()->parseMeta($category->metadata); $this->setPageTitle(Yii::t('ciims.controllers.Categories', '{{app_name}} | {{label}}', array('{{app_name}}' => Cii::getConfig('name', Yii::app()->name), '{{label}}' => $category->name))); $layout = isset($meta['layout']) ? $meta['layout']['value'] : 'default'; // Set the layout $this->setLayout($layout); $data = array(); $pages = array(); $itemCount = 0; $pageSize = Cii::getConfig('categoryPaginationSize', 10); $criteria = Content::model()->getBaseCriteria()->addCondition('type_id >= 2')->addCondition("category_id = " . $id)->addCondition('password = ""'); $criteria->limit = $pageSize; $criteria->order = 'created DESC'; $itemCount = Content::model()->count($criteria); $pages = new CPagination($itemCount); $pages->pageSize = $pageSize; $criteria->offset = $criteria->limit * $pages->getCurrentPage(); $data = Content::model()->findAll($criteria); $pages->applyLimit($criteria); $this->render('index', array('id' => $id, 'category' => $category, 'data' => $data, 'itemCount' => $itemCount, 'pages' => $pages, 'meta' => array('description' => $category->getDescription()))); }
public function actionShow() { $uid = Ibos::app()->user->uid; $docid = EnvUtil::getRequest("id"); $version = EnvUtil::getRequest("version"); if (empty($docid)) { $this->ajaxReturn("", "JSONP"); } $officialDocEntity = new ICOfficialdoc($docid); $officialDoc = $officialDocEntity->getAttributes(); if ($version) { $versionData = OfficialdocVersion::model()->fetchByAttributes(array("docid" => $docid, "version" => $version)); $officialDoc = array_merge($officialDoc, $versionData); } if (!empty($officialDoc)) { if (!OfficialdocUtil::checkReadScope($uid, $officialDoc)) { $this->error(Ibos::lang("You do not have permission to read the officialdoc"), $this->createUrl("default/index")); } $data = ICOfficialdoc::getShowData($officialDoc); OfficialdocReader::model()->addReader($docid, $uid); Officialdoc::model()->updateClickCount($docid, $data["clickcount"]); $page = EnvUtil::getRequest("page"); $criteria = new CDbCriteria(); $pages = new CPagination(OfficialdocUtil::getCharacterLength($data["content"])); $pages->pageSize = 2000; $pages->applyLimit($criteria); $tmpContent = OfficialdocUtil::subHtml($data["content"], $pages->getCurrentPage() * $pages->getPageSize(), ($pages->getCurrentPage() + 1) * $pages->getPageSize()); $data["content"] = $tmpContent; if (!empty($page) && $page != 1) { $data["content"] = "<div><div style=\"border-bottom:4px solid #e26f50;margin-top:60px;\"></div><div style=\"border-top:1px solid #e26f50;margin-top:4px;\"><div><p style=\"text-align:center;\"></p><div id=\"original-content\" style=\"min-height:400px;font:16px/2 fangsong,simsun;color:#666;\"><table cellspacing=\"0\" cellpadding=\"0\" width=\"95%\" align=\"center\"><tbody><tr><td class=\"p1\"><span><p>" . $tmpContent . "</p>"; $data["content"] = OfficialdocUtil::subHtml($data["content"], 0, $pages->pageSize * 2); } $params = array("data" => $data, "pages" => $pages, "dashboardConfig" => Yii::app()->setting->get("setting/docconfig")); if ($data["rcid"]) { $params["rcType"] = RcType::model()->fetchByPk($data["rcid"]); } } else { $params = ""; } $this->ajaxReturn($params, "JSONP"); }
/** * 部门列表 */ public function actionList($page = 1) { $count = IMDepartment::model()->count(); $pager = new CPagination($count); $pager->pageSize = Yii::app()->params['perPage']; if (empty($page)) { $pager->currentPage = 1; } $list = IMDepartment::model()->findAll(array('order' => 'id DESC', 'offset' => $pager->getCurrentPage() * $pager->getPageSize(), 'limit' => $pager->pageSize)); foreach ($list as $v) { $data[] = $v->attributes; } $this->render('list', array('list' => $data, 'pager' => $pager)); }
public function actionIndex() { $c = array('conditions' => array('status' => array('==' => 1))); $total = WebArticlesModel::model()->count($c); $pager = new CPagination($total); $itemOnPaging = 5; $pager->pageSize = 10; $curr_page = $pager->getCurrentPage(); $limit = $pager->getLimit(); $offset = $pager->getOffset(); $c = array('conditions' => array('status' => array('==' => 1)), 'sort' => array('_id' => EMongoCriteria::SORT_DESC), 'limit' => $limit, 'offset' => $offset); $data = FeedModel::model()->findAll($c); $this->render('index', compact('data', 'pager', 'itemOnPaging')); }
public function actionIndex() { $criteria = new EMongoCriteria(); #$criteria->order = 'username desc'; //按什么字段来排序 $model = Admin::model(); $count = $model->count($criteria); //count() 函数计算数组中的单元数目或对象中的属性个数。 $pager = new CPagination($count); $pager->pageSize = 12; //每页显示的行数 $criteria->limit($pager->pageSize); $criteria->offset($pager->getCurrentPage() * $pager->pageSize); $list = $model->findAll($criteria); //查询所有的数据 $this->render('index', array('list' => $list, 'pages' => $pager)); }
public function actionView() { $playlistId = Yii::app()->request->getParam('id'); $playlist = WapPlaylistModel::model()->published()->findByPk($playlistId); $user_msisdn = $playlist->msisdn; if (!$playlist) { $this->forward("/site/error", true); } $songsOfPlaylist = WapPlaylistModel::model()->getSongs($playlistId); //samge user $countPlSameUser = WapPlaylistModel::model()->countPlaylistByPhone($this->userPhone); $playlistPages = new CPagination($countPlSameUser); $pageSize = Yii::app()->params['pageSize']; $playlistPages->setPageSize($pageSize); $currentPage = $playlistPages->getCurrentPage(); $playlistsSameUser = WapPlaylistModel::model()->getSamePlaylistByPhone($playlist->id, $this->userPhone, $currentPage * $pageSize, $pageSize); $errorCode = 'success'; $errorDescription = ''; //for show price $checkPlay = WapUserTransactionModel::model()->checkCharging24h($this->userPhone, $this->userPhone, $playlistId, 'play_album'); $userSub = $this->userSub; //WapUserSubscribeModel::model()->getUserSubscribe($phone); if ($checkPlay) { $playPrice = 0; } else { if ($userSub) { $playPrice = 0; } } if ($checkPlay) { $playPrice = 0; } // $registerText = WapAlbumModel::model()->getCustomMetaData('REG_TEXT'); $this->itemName = $playlist->name; $this->artist = "Chacha"; //$playlist->username; $this->thumb = UserModel::model()->getThumbnailUrl('s1', $playlist->user_id); $this->url = URLHelper::buildFriendlyURL("playlist", $playlist->id, Common::makeFriendlyUrl($playlist->name)); $this->description = $playlist->name; $this->render('view', array('playlist' => $playlist, 'songsOfPlaylist' => $songsOfPlaylist, 'playlistsSameUser' => $playlistsSameUser, 'playlistPages' => $playlistPages, 'errorCode' => $errorCode, 'errorDescription' => $errorDescription, 'userSub' => $userSub, 'user_msisdn' => $user_msisdn)); }
public static function fetchAllArray($limit = 20) { $limit = (int) $limit; $cmd = app()->getDb()->createCommand()->select('count(*)')->from(TABLE_FILTER_KEYWORD); $count = (int) $cmd->queryScalar(); if ($count == 0) { return array(); } $cmd = app()->getDb()->createCommand()->from(TABLE_FILTER_KEYWORD)->order('id asc'); if ($limit > 0) { $cmd->limit($limit); } $pages = new CPagination($count); $pages->setPageSize($limit); $page = $pages->getCurrentPage(); $offset = $page * $limit; if ($offset >= 0) { $cmd->offset($offset); } $rows = $cmd->queryAll(); return array('rows' => $rows, 'pages' => $pages); }
public function actionIndex() { $keyword = Yii::app()->request->getParam('keyword', ''); $page = Yii::app()->request->getParam('page', 1); // Find all records witch have first name starring on a, b and c, case insensitive search $keyRegexPattern = self::formatKeywordsPatternSearch($keyword); if (empty($keyRegexPattern)) { $data = null; } else { $regexObj = new MongoRegex($keyRegexPattern); $c = array('conditions' => array('status' => array('==' => 1), 'title' => array('==' => $regexObj))); $total = WebArticlesModel::model()->count($c); $pager = new CPagination($total); $itemOnPaging = 5; $pager->pageSize = 10; $curr_page = $pager->getCurrentPage(); $limit = $pager->getLimit(); $offset = $pager->getOffset(); $c = array('conditions' => array('status' => array('==' => 1), 'title' => array('==' => $regexObj)), 'limit' => $limit, 'offset' => $offset); $data = WebArticlesModel::model()->findAll($c); } $this->render('index', compact('data', 'pager', 'itemOnPaging', 'keyword', 'limit')); }
/** * 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 $company = isset($_GET['company']) ? $_GET['company'] : null; if ($company !== 'all' && !ctype_digit($company)) { $company = 'all'; } $priority = isset($_GET['priority']) ? $_GET['priority'] : null; if ($priority !== 'all' && $priority !== (string) Project::PRIORITY_HIGHEST && $priority !== (string) Project::PRIORITY_HIGH && $priority !== (string) Project::PRIORITY_MEDIUM && $priority !== (string) Project::PRIORITY_LOW && $priority !== (string) Project::PRIORITY_LOWEST) { $priority = 'all'; } $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`.closeDate, `t`.hourlyRate, `t`.openDate, `t`.priority, `t`.title"; //$criteria->select="`t`.`closeDate`, `t`.`hourlyRate`, `t`.`openDate`, `t`.`priority`, `t`.`title`"; // uncomment in yii-1.1.2 if ($jqGrid['searchField'] !== null && $jqGrid['searchString'] !== null && $jqGrid['searchOper'] !== null) { $field = array('closeDate' => "`t`.`closeDate`", 'hourlyRate' => "`t`.`hourlyRate`", 'openDate' => "`t`.`openDate`", 'priority' => "`t`.`priority`", 'title' => "`t`.`title`", 'company' => "`Project_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("`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); }
public function actionViewType() { $artistId = Yii::app()->request->getParam('id'); $artist = ArtistModel::model()->findByPk($artistId); $this->artist = $artist->name; $this->thumb = ArtistModel::model()->getAvatarUrl($artist->id, 150); $this->url = URLHelper::buildFriendlyURL("artist", $artist->id, $artist->url_key); if (!$artist) { $this->forward("/site/error", true); } $listType = Yii::app()->request->getParam('list', 'song'); $countSongsOfArtist = $artist->song_count; $countClipsOfArtist = $artist->video_count; $countAlbumsOfArtist = $artist->album_count; $pageSize = Yii::app()->params['numberSongsPerPage']; if ($listType == 'song') { // in case that list songs of artist $songPages = new CPagination($countSongsOfArtist); $songPages->setPageSize($pageSize); $currentPage = $songPages->getCurrentPage(); $songsOfArtist = WapSongModel::model()->getSongsSameSinger(0, $artist->id, $currentPage * $pageSize, $pageSize); $this->render('viewtype', array('artist' => $artist, 'listType' => $listType, 'countSongsOfArtist' => $countSongsOfArtist, 'countClipsOfArtist' => $countClipsOfArtist, 'countAlbumsOfArtist' => $countAlbumsOfArtist, 'songsOfArtist' => $songsOfArtist, 'songPages' => $songPages)); } elseif ($listType == 'clip') { // in case that list clips of artist $clipPages = new CPagination($countClipsOfArtist); $clipPages->setPageSize($pageSize); $currentPage = $clipPages->getCurrentPage(); $clipsOfArtist = WapVideoModel::model()->getVideosSameArtist(0, $artist->id, $currentPage * $pageSize, $pageSize); $this->render('viewtype', array('artist' => $artist, 'listType' => $listType, 'countSongsOfArtist' => $countSongsOfArtist, 'countClipsOfArtist' => $countClipsOfArtist, 'countAlbumsOfArtist' => $countAlbumsOfArtist, 'clipsOfArtist' => $clipsOfArtist, 'clipPages' => $clipPages)); } else { // in case that list albums of artist $albumPages = new CPagination($countAlbumsOfArtist); $albumPages->setPageSize($pageSize); $currentPage = $albumPages->getCurrentPage(); $albumsOfArtist = WapAlbumModel::model()->getAlbumsSameArtist(0, $artist->id, $currentPage * $pageSize, $pageSize); $this->render('viewtype', array('artist' => $artist, 'listType' => $listType, 'countSongsOfArtist' => $countSongsOfArtist, 'countClipsOfArtist' => $countClipsOfArtist, 'countAlbumsOfArtist' => $countAlbumsOfArtist, 'albumsOfArtist' => $albumsOfArtist, 'albumPages' => $albumPages)); } }
/** * 群组列表 */ public function actionList($page = 1) { $count = IMGroup::model()->count(array('condition' => 'status = 0')); $pager = new CPagination($count); $pager->pageSize = Yii::app()->params['perPage']; if (empty($page)) { $pager->currentPage = 1; } $list = IMGroup::model()->findAll(array('condition' => 'status = 0', 'order' => 'groupId DESC', 'offset' => $pager->getCurrentPage() * $pager->getPageSize(), 'limit' => $pager->pageSize)); $data = array(); if (!empty($list)) { foreach ($list as $v) { $data[] = $v->attributes; } } $this->render('list', array('list' => $data, 'pager' => $pager)); }
/** * 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); }
public function getCurrentPage($recalculate = true) { $page = parent::getCurrentPage($recalculate); $page = $page ? ($page + 1) / $this->getPageSize() : $page; return (int) $page; }
public function actionList() { $this->setPageTitle(Yii::t('ciims.controllers.Content', '{{app_name}} | {{label}}', array('{{app_name}}' => Cii::getConfig('name', Yii::app()->name), '{{label}}' => Yii::t('ciims.controllers.Content', 'All Content')))); $this->setLayout('default'); $pageSize = Cii::getConfig('contentPaginationSize', 10); $criteria = Content::model()->getBaseCriteria()->addCondition('type_id >= 2')->addCondition('password = ""'); $criteria->order = 'published DESC'; $criteria->limit = $pageSize; $itemCount = Content::model()->count($criteria); $pages = new CPagination($itemCount); $pages->pageSize = $pageSize; $criteria->offset = $criteria->limit * $pages->getCurrentPage(); $data = Content::model()->findAll($criteria); $pages->applyLimit($criteria); $this->render('all', array('data' => $data, 'itemCount' => $itemCount, 'pages' => $pages)); }
/** * Load same album via Ajax */ public function actionLoadAjax() { $s = CHtml::encode(Yii::app()->request->getParam('s')); $albumId = Yii::app()->request->getParam('id', 0); $artist_id = (int) Yii::app()->request->getParam('artist_id', 0); $genre_id = (int) Yii::app()->request->getParam('genre_id', 0); if ($s == 'genre') { $countAlbumsSameGenre = WapAlbumModel::model()->countAlbumsSameGenre($albumId, $genre_id); $albumPages = new CPagination($countAlbumsSameGenre); $pageSize = Yii::app()->params['pageSize']; $albumPages->setPageSize($pageSize); $currentPage = $albumPages->getCurrentPage(); $data = WapAlbumModel::model()->getAlbumsSameGenre($albumId, $genre_id, $currentPage * $pageSize, $pageSize); } else { $countAlbumsSameArtist = AlbumArtistModel::model()->countAlbumByArtist($artist_id); $albumPages = new CPagination($countAlbumsSameArtist); $pageSize = Yii::app()->params['pageSize']; $albumPages->setPageSize($pageSize); $currentPage = $albumPages->getCurrentPage(); // $data = WapAlbumModel::model()->getAlbumsSameArtist($albumId, $artist_id, $currentPage * $pageSize, $pageSize); /* NEW */ $artists = AlbumArtistModel::model()->getArtistsByAlbum($albumId); $artistIds = ''; if ($artists) { foreach ($artists as $artist) { $artistIds .= ',' . $artist->artist_id; } } $artistIds = $artistIds != '' ? substr($artistIds, 1) : ''; $data = $albumsSameArtist = WapAlbumModel::model()->getAlbumbyArtists($artistIds, $pageSize, $currentPage * $pageSize); /* END */ } $this->renderPartial('_same', array('albums' => $data), false, true); }
/** * Provides basic searching functionality * @param int $id The search pagination id */ public function actionSearch($id = 1) { $this->setPageTitle(Yii::t('ciims.controllers.Site', '{{app_name}} | {{label}}', array('{{app_name}}' => Cii::getConfig('name', Yii::app()->name), '{{label}}' => Yii::t('ciims.controllers.Site', 'Search')))); $this->layout = '//layouts/default'; $data = array(); $pages = array(); $itemCount = 0; $pageSize = Cii::getConfig('searchPaginationSize', 10); if (Cii::get($_GET, 'q', false)) { $criteria = new CDbCriteria(); $criteria->addCondition('status = 1')->addCondition('published <= UTC_TIMESTAMP()'); if (strpos($_GET['q'], 'user_id') !== false) { $criteria->addCondition('author_id = :author_id')->addCondition("vid=(SELECT MAX(vid) FROM content AS v WHERE v.id=t.id)"); $criteria->params = array(':author_id' => str_replace('user_id:', '', Cii::get($_GET, 'q', 0))); } else { $param = Cii::get($_GET, 'q', 0); $criteria->addCondition("vid=(SELECT MAX(vid) FROM content AS v WHERE v.id=t.id) AND ((t.content LIKE :param) OR (t.title LIKE :param2))"); $criteria->params = array(':param' => '%' . $param . '%', ':param2' => '%' . $param . '%'); } $criteria->addCondition('password = ""'); $criteria->limit = $pageSize; $criteria->order = 'id DESC'; $itemCount = Content::model()->count($criteria); $pages = new CPagination($itemCount); $pages->pageSize = $pageSize; $criteria->offset = $criteria->limit * $pages->getCurrentPage(); $data = Content::model()->findAll($criteria); $pages->applyLimit($criteria); } $this->render('search', array('url' => 'search', 'id' => $id, 'data' => $data, 'itemCount' => $itemCount, 'pages' => $pages)); }
public function actionUnwanted_words($page = 1) { $limit = 20; $token = $this->getToken(); $res = RpcClient_STD_Admin::Instance()->GetUnwantWordList($token, $page, $limit); $data = $res['data']; $total = isset($data['total']) ? $data['total'] : 0; $pages = new CPagination($total); $pages->pageSize = $limit; $pages->applyLimit(new CDbCriteria()); $params['list'] = $data['list'] ? $data['list'] : array(); $params['pages'] = $pages; $params['total'] = $total; $this->jsApp = array('controller/list', 'Init', array("type" => "unwanted_words", "apis" => array("delete" => "admin/RemoveUnwantWord"))); //print $pages->getOffset(); //print $pages->getPageSize(); $params['current_from'] = $pages->getCurrentPage() * $limit + 1; $params['current_to'] = $params['current_from'] + count($params['list']) - 1; // echo '<pre>'; // var_dump($params);die; // echo '</pre>'; $params['current_time'] = date('y-m-d h:i:s', time()); $this->render('unwanted_words', $params); }
/** * * 员工营业额统计 * */ public function actionTurnOver() { $str = Yii::app()->request->getParam('str', $this->companyId); $download = Yii::app()->request->getParam('d', 0); $beginTime = Yii::app()->request->getParam('begin_time', date('Y-m-d', time())); $endTime = Yii::app()->request->getParam('end_time', date('Y-m-d', time())); $db = Yii::app()->db; $sql = 'select t.* from (select username,sum(reality_total) as total from nb_order where order_status in (3,4,8) and dpid in (' . $str . ') and create_at >="' . $beginTime . ' 00:00:00" and create_at <="' . $endTime . ' 23:59:59" group by username order by lid desc)t'; if ($download) { $models = $db->createCommand($sql)->queryAll(); $this->exportTurnOver($models); exit; } $count = $db->createCommand(str_replace('t.*', 'count(*)', $sql))->queryScalar(); $pages = new CPagination($count); $pdata = $db->createCommand($sql . " LIMIT :offset,:limit"); $pdata->bindValue(':offset', $pages->getCurrentPage() * $pages->getPageSize()); $pdata->bindValue(':limit', $pages->getPageSize()); //$pages->getLimit(); $models = $pdata->queryAll(); $comName = $this->getComName(); $this->render('turnover', array('models' => $models, 'pages' => $pages, 'begin_time' => $beginTime, 'end_time' => $endTime, 'comName' => $comName, 'str' => $str)); }
/** * 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 $company = isset($_GET['company']) ? $_GET['company'] : null; if ($company !== 'all' && !ctype_digit($company)) { $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); }
/** * 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 $company = isset($_GET['company']) ? $_GET['company'] : null; if ($company !== 'all' && !ctype_digit($company)) { $company = 'all'; } $consultant = isset($_GET['consultant']) ? $_GET['consultant'] : null; if ($consultant !== 'all' && $consultant !== 'me' && !ctype_digit($consultant)) { $consultant = 'all'; } if (Yii::app()->user->checkAccess(User::CONSULTANT)) { $consultant = 'me'; } $manager = isset($_GET['manager']) ? $_GET['manager'] : null; if ($manager !== 'all' && !ctype_digit($manager)) { $manager = 'all'; } $project = isset($_GET['project']) ? $_GET['project'] : null; if ($project !== 'all' && !ctype_digit($project)) { $project = 'all'; } $task = isset($_GET['task']) ? $_GET['task'] : null; if ($task !== 'all' && !ctype_digit($task)) { $task = 'all'; } // criteria $criteria = new CDbCriteria(); $criteria->group = "`t`.`id`"; // 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); }
/** * 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); }
<?php if ($route1->is_paid == '0') { echo CHtml::link(Yii::t('hostel', 'Pay Fees'), array('/transport/Transportation/Payfees', 'id' => $route1->student_id), array('confirm' => 'Are you sure?')); } else { echo Yii::t('hostel', 'Paid'); echo CHtml::link(' Print Receipt', array('/transport/Transportation/print', 'id' => $route1->student_id), array('target' => '_blank')); } ?> </td> </tr> <?php } } else { echo '<tr><td align="center" colspan="6"><strong>' . Yii::t('transport', 'No data available.') . '</strong></div>'; } ?> </table> <div class="pagecon"> <?php $this->widget('CLinkPager', array('currentPage' => $pages->getCurrentPage(), 'itemCount' => $total, 'pageSize' => $page_size, 'maxButtonCount' => 5, 'header' => '', 'htmlOptions' => array('class' => 'pages'))); ?> </div> </div> </div> </td> </tr> </table>
public function actionIndex() { $type = Yii::app()->request->getParam('type'); $state = Yii::app()->request->getParam('State'); $city = Yii::app()->request->getParam('City'); $homeajax = Yii::app()->request->getParam('homeajax'); $pagesize = 12; if ($state === '') { $province = 'all'; } elseif ($state === null) { $province = '370000'; } else { $province = $state; } $brand = Yii::app()->request->getParam('brand'); $type = $type === null ? 1 : $type; //1网格 2列表 //获得联盟id $organID = Yii::app()->user->getOrganID(); $unionid = MallService::getUnioninfo($organID); $unionid = $unionid ? $unionid : '-1'; //联盟商品 $dids = MallService::getUnionOrgan(array('UnionID' => $unionid, 'type' => 2)); $where = ' where Identity=2 and IsBlack="0" and IsFreeze="0" and Status="1"'; $where .= ' and ID in (' . $dids . ')'; if ($homeajax == 1) { $province = 'all'; $pagesize = 6; } if ($province !== 'all') { $where .= ' and Province=' . $province; } if ($city) { $where .= ' and City=' . $city; } if (!empty($brand)) { $ids = $this->getdealerbybrand($brand); $where .= ' and ID in' . $ids; } if ($homeajax == 1) { //工作台首页 $sql = ' select ID,OrganName,Logo from jpd_organ' . $where; } else { $sql = ' select * from jpd_organ' . $where; } $sqlcount = ' select count(*) from jpd_organ' . $where; $count = Yii::app()->jpdb->createCommand($sqlcount)->queryScalar(); $sql .= ' order by Sort ASC '; $dataProvider = new CSqlDataProvider($sql, array('db' => Yii::app()->jpdb, 'totalItemCount' => $count, 'pagination' => array('pageSize' => $pagesize))); $organ = $dataProvider->getData(); if ($homeajax == 1) { echo json_encode($organ); die; } if ($organ) { foreach ($organ as $key => $val) { $a = array(); $b = array(); $organ[$key]['OrganName'] = '<a target="_black" href="' . Yii::app()->createUrl('servicer/servicedetail/detail', array('dealer' => $val['ID'])) . '">' . $val['OrganName'] . '</a>'; $brand = PapBrand::model()->findAll('OrganID=:organ', array(':organ' => $val['ID'])); $brand_str = ""; foreach ($brand as $k => $v) { if ($v['BrandName'] === null) { continue; } $a[] = $v['BrandName']; } if ($a) { $brand_str = implode(',', $a); $organ[$key]['brand'] = '<a title="' . $brand_str . '">' . $brand_str . '</a>'; $organ[$key]['firstbrand'] = '<a title="' . $brand_str . '">' . $a[0] . '</a>'; } else { $organ[$key]['brand'] = '暂无'; $organ[$key]['firstbrand'] = '主营品牌:暂无'; } $vehicles = DealerVehicles::model()->findAll('OrganID=:organ', array(':organ' => $val['ID'])); $str = ""; foreach ($vehicles as $k => $v) { $car = $v['Make']; if ($v['Car']) { $car .= ' ' . $v['Car']; if ($v['Year']) { $car .= ' ' . $v['Year']; if ($v['Model']) { $car .= ' ' . $v['Model']; } else { $car .= ' ' . '全车型'; } } else { $car .= ' ' . '全年款'; } } else { $car .= ' ' . '全车系'; } $b[] = $car; } if ($b) { $str = implode('; ', $b); //$organ[$key]['vehicles'] = '<a title="' . $str . '">' . $str . '</a>'; $organ[$key]['vehicles'] = $str; } else { $organ[$key]['vehicles'] = '暂无'; } $organ[$key]['TelPhone'] = $organ[$key]['TelPhone'] ? $organ[$key]['TelPhone'] : '暂无'; } } $dataProvider->setData($organ); $branddata = $this->getBrand($dids); $get = $this->geturlparams($_GET); $get['type'] = $type; $pages = new CPagination($count); $pages->pageSize = $pagesize; $page = $pages->getCurrentPage() + 1; $totalpage = $pages->getPageCount(); $start = 1 + ($page - 1) * $pagesize; $end = $page < $totalpage ? $start + $pagesize - 1 : $count; $footer = '<span class="zdyfooter">第 ' . $start . ' - ' . $end . ' 条, 共 ' . $count . ' 条.</span>'; $this->render('index', array('dataProvider' => $dataProvider, 'brand' => $branddata, 'get' => $get, 'type' => $type, 'province' => $province, 'city' => $city, 'pages' => $pages, 'footer' => $footer)); }
/** * hien thi danh sach bai hat/video/album/playlist cua 1 the loai * @param type $genreModel * @param type $type */ public function showList($genreModel, $type, $genre_id) { $arr = array('song' => array('modelClass' => 'WapSongModel', 'countGenreFunc' => 'countSongsByGenre', 'getGenreFunc' => 'getSongsByGenre', 'widget' => '', 'text' => 'Bài hát'), 'video' => array('modelClass' => 'WapVideoModel', 'countGenreFunc' => 'countVideosByGenre', 'getGenreFunc' => 'getVideosByGenre', 'widget' => '', 'text' => 'Video'), 'album' => array('modelClass' => 'WapAlbumModel', 'countGenreFunc' => 'countAlbumsByGenre', 'getGenreFunc' => 'getAlbumsByGenre', 'widget' => '', 'text' => 'Album'), 'videoPlaylist' => array('modelClass' => 'VideoPlaylistModel', 'countGenreFunc' => 'countVideoPlaylistByGenre', 'getGenreFunc' => 'getVideoPlaylistByGenre', 'widget' => '', 'text' => 'VideoPlaylist')); $page = Yii::app()->request->getParam('page', 1); $pageSize = Yii::app()->params['pageSize']; $headerText = $arr[$type]['text'] . " " . $genreModel->name; $genres_ = MainActiveRecord::getGenre(); $countObject = $arr[$type]['modelClass']::$arr[$type]['countGenreFunc']($genreModel->id); $objectPages = new CPagination($countObject); $objectPages->setPageSize($pageSize); $currentPage = $objectPages->getCurrentPage(); if (!$currentPage) { $currentPage = 1; } $objects = $arr[$type]['modelClass']::$arr[$type]['getGenreFunc']($genreModel->id, ($page - 1) * $pageSize, $pageSize); $options = array(); $options['col'] = $headerText; $options['headerText'] = $headerText; $this->render('application.views.wap.' . $type . '.list', array($type . 's' => $objects, $type . 'Pages' => $objectPages, 'type' => 'list', 'options' => $options, 'link' => Yii::app()->createUrl('/genre'), 'genres' => $genres_, 'genre_id' => $genre_id, 'pager' => $objectPages, 'headerText' => $headerText)); }
public function actionLoadAjax() { $keyword = trim(yii::app()->request->getParam('q', '')); $search_type = $type = trim(yii::app()->request->getParam('type', 'song')); $page = intval(yii::app()->request->getParam('page', 1)); $is_search = Yii::app()->request->getParam('is_search', 1); $paging = array('page' => $page, 'recordsPerPage' => !$search_type ? Yii::app()->params['numberPerPage'] : Yii::app()->params['pageSize']); switch ($search_type) { case 'song': $response = SearchHelper::getInstance()->search($keyword, 'song', $paging['recordsPerPage'], $page - 1); $results = $this->copyAndCast($response->docs, array('name' => 'name', 'artist_name' => 'artist_name')); if ($response->numFound > 0) { $countSong = $response->numFound; $pages = new CPagination($countSong); $pageSize = Yii::app()->params['pageSize']; $pages->params = array('q' => $keyword, 'type' => $type); $pages->setPageSize($pageSize); $topItems = array(); $topItemPages = new CPagination(0); $results = $this->getStatistic($results, $type); } else { $pages = new CPagination(0); $pageSize = Yii::app()->params['numberPerPage']; $topItemPages = new CPagination($pageSize); $topItemPages->setPageSize($pageSize); $currentPage = $topItemPages->getCurrentPage(); $topItems = null; // WapSongModel::model()->getTopSongsWeek($currentPage * $pageSize, $pageSize);;//WapSongModel::getListHot(1,$pageSize,'filter_sync_status'); } $total_results[$type] = array('numFound' => $response->numFound, 'results' => $results, 'topItems' => $topItems, 'pages' => $pages, 'topItemPages' => $topItemPages); break; case 'clip': $response = SearchHelper::getInstance()->search($keyword, 'video', $paging['recordsPerPage'], $page - 1); $results = $this->copyAndCast($response->docs, array('artist' => 'artist_name')); if ($response->numFound > 0) { $countClip = $response->numFound; $pages = new CPagination($countClip); $pageSize = Yii::app()->params['pageSize']; $pages->params = array('q' => $keyword, 'type' => $type); $pages->setPageSize($pageSize); $topItems = array(); $topItemPages = new CPagination(0); $results = $this->getStatistic($results, $type); } else { $pages = new CPagination(0); $pageSize = Yii::app()->params['numberPerPage']; $topItemPages = new CPagination($pageSize); $currentPage = $topItemPages->getCurrentPage(); $topItemPages->setPageSize($pageSize); $topItems = null; //WapVideoModel::model()->getTopVideosWeek($currentPage * $pageSize, $pageSize);//WapVideoModel::getListHot(1,$pageSize,'filter_sync_status'); } $total_results[$type] = array('numFound' => $response->numFound, 'results' => $results, 'topItems' => $topItems, 'pages' => $pages, 'topItemPages' => $topItemPages); break; case 'album': $response = SearchHelper::getInstance()->search($keyword, 'album', $paging['recordsPerPage'], $page - 1); $results = $this->copyAndCast($response->docs, array('artist' => 'artist_name')); if ($response->numFound > 0) { $countAlbum = $response->numFound; $pages = new CPagination($countAlbum); $pageSize = Yii::app()->params['pageSize']; $pages->params = array('q' => $keyword, 'type' => $type); $pages->setPageSize($pageSize); $topItems = array(); $topItemPages = new CPagination(0); $results = $this->getStatistic($results, $type); } else { $pages = new CPagination(0); $pageSize = Yii::app()->params['numberPerPage']; $topItemPages = new CPagination($pageSize); $topItemPages->setPageSize($pageSize); $currentPage = $topItemPages->getCurrentPage(); $topItems = null; //WapAlbumModel::model()->getTopAlbumsWeek($currentPage * $pageSize, $pageSize);//WapAlbumModel::getListHot(1,$pageSize); } $total_results[$type] = array('numFound' => $response->numFound, 'results' => $results, 'topItems' => $topItems, 'pages' => $pages, 'topItemPages' => $topItemPages); break; case 'artist': $response = SearchHelper::getInstance()->search($keyword, 'artist', $paging['recordsPerPage'], $page - 1); $results = $this->copyAndCast($response->docs, array('artist' => 'artist_name')); if ($response->numFound > 0) { $countArtist = $response->numFound; $pages = new CPagination($countArtist); $pageSize = Yii::app()->params['pageSize']; $pages->params = array('q' => $keyword, 'type' => $type); $pages->setPageSize($pageSize); $topItems = array(); $topItemPages = new CPagination(0); $results = $this->getStatistic($results, $type, 'song_count'); } else { $pages = new CPagination(0); $pageSize = Yii::app()->params['numberPerPage']; $topItemPages = new CPagination($pageSize); $currentPage = $topItemPages->getCurrentPage(); $topItemPages->setPageSize($pageSize); $topItems = null; //WapArtistModel::model()->getTopArtists($currentPage * $pageSize, $pageSize); } $total_results[$type] = array('numFound' => $response->numFound, 'results' => $results, 'topItems' => $topItems, 'pages' => $pages, 'topItemPages' => $topItemPages); break; case 'videoplaylist': $response = SearchHelper::getInstance()->search($keyword, 'videoplaylist', $paging['recordsPerPage'], $page - 1); $results = $this->copyAndCast($response->docs, array('artist' => 'artist_name')); if ($response->numFound > 0) { $countArtist = $response->numFound; $pages = new CPagination($countArtist); $pageSize = Yii::app()->params['pageSize']; $pages->params = array('q' => $keyword, 'type' => $type); $pages->setPageSize($pageSize); $topItems = array(); $topItemPages = new CPagination(0); $results = $this->getStatistic($results, $type); } else { $pages = new CPagination(0); $pageSize = Yii::app()->params['numberPerPage']; $topItemPages = new CPagination($pageSize); $currentPage = $topItemPages->getCurrentPage(); $topItemPages->setPageSize($pageSize); $topItems = null; //WapArtistModel::model()->getTopArtists($currentPage * $pageSize, $pageSize); } $total_results[$type] = array('numFound' => $response->numFound, 'results' => $results, 'topItems' => $topItems, 'pages' => $pages, 'topItemPages' => $topItemPages); break; } $this->layout = false; $this->render("_ajaxList", compact('total_results', 'search_type')); }
public function actionLoadAjax() { $callBack = (int) Yii::app()->request->getParam('call_back', 0); $s = CHtml::encode(Yii::app()->request->getParam('s')); $id = (int) Yii::app()->request->getParam('id', 0); $artist_id = (int) Yii::app()->request->getParam('artist_id', 0); $genre_id = (int) Yii::app()->request->getParam('genre_id', 0); if ($s == 'genre') { $callBackLink = Yii::app()->createUrl("song/loadAjax", array('s' => 'genre', 'genre_id' => $genre_id)); $count = WapSongModel::model()->countSongsByGenre($genre_id); $pager = new CPagination($count); $pageSize = Yii::app()->params['pageSize']; $pager->setPageSize($pageSize); $currentPage = $pager->getCurrentPage(); $songs = WapSongModel::model()->getSongsByGenre($genre_id, $pager->getOffset(), $pager->getLimit()); } else { $callBackLink = Yii::app()->createUrl("song/loadAjax", array('s' => 'artist', 'artist_id' => $artist_id)); $count = WapSongModel::model()->countSongsSameSinger($id, $artist_id); $pager = new CPagination($count); $pageSize = Yii::app()->params['pageSize']; $pager->setPageSize($pageSize); $currentPage = $pager->getCurrentPage(); $songs = WapSongModel::model()->getSongsSameSinger($id, $artist_id, $pager->getOffset(), $pager->getLimit()); } if ($callBack) { $this->renderPartial("_ajaxList", compact('songs', 'pager'), false, true); } else { $this->renderPartial("_same", compact('songs', 'pager', 'callBackLink'), false, true); } }