public function actionIndex() { $with = array('active_keywords'); $whereType = "and t.type='" . Globals::TYPE_REGISTRATION . "' and active_keywords.type='" . Globals::TYPE_ACTIVE . "'"; $this->layout = '//layouts/memberList'; $dataProvider = new CActiveDataProvider('ActiveModel', array('criteria' => array('order' => 't.id DESC', 'with' => $with, 'condition' => "t.wechatId = {$this->wechatInfo->id} {$whereType}", 'together' => true), 'pagination' => array('pageSize' => Page::SIZE, 'pageVar' => 'page'))); $this->render('index', array('data' => $dataProvider->getData(), 'pages' => $dataProvider->getPagination(), 'wechatInfo' => $this->wechatInfo)); }
/** * 手机客户端的分页,防止分页重复,与网页显示无关 * @param CActiveDataProvider $dataProvider * */ public function page(CActiveDataProvider &$dataProvider, $more = true) { $total = $dataProvider->getTotalItemCount(); $pageSzie = $dataProvider->getPagination()->getPageSize(); $dataProvider->getPagination()->pageVar = 'page'; $pageCount = ceil($total / $pageSzie); if ($dataProvider->getTotalItemCount() == 0) { $this->send(ERROR_EMPTY, 'data empty', $more); } else { if (isset($_GET['page'])) { if ($pageCount >= $_GET['page']) { $this->send(0, $dataProvider->getData(), $more, array('page' => $pageCount)); } } else { $this->send(ERROR_NONE, $dataProvider->getData(), $more, array('page' => $pageCount)); } } }
public function actionUser() { $this->layout = '//layouts/list'; $group = GroupModel::model()->findall(); foreach ($group as $v) { $groupList[$v->group_id] = $v->name; } $dataProvider = new CActiveDataProvider('UserModel', array('criteria' => array('order' => 'uid desc'), 'pagination' => array('pageSize' => Page::SIZE))); $this->render('userList', array('data' => $dataProvider->getData(), 'pages' => $dataProvider->getPagination(), 'group' => $groupList)); }
public function actionReplay() { $this->layout = '/layouts/memberList'; $type = Yii::app()->request->getParam('type'); $type = $type ? $type : GiftModel::TYPE_KEYWORDS; switch ($type) { case GiftModel::TYPE_KEYWORDS: $with = array('open_keywords', 'open_openPlatForm'); $whereType = " and t.type ='" . GiftModel::TYPE_KEYWORDS . "' and open_keywords.type='" . OpenReplayModel::OPEN_TYPE . "'"; break; case GiftModel::TYPE_MENU: $with = array('open_menuaction', 'open_openPlatForm'); $whereType = " and t.type ='" . GiftModel::TYPE_MENU . "'"; break; } $dataProvider = new CActiveDataProvider('OpenReplayModel', array('criteria' => array('order' => 't.id DESC', 'with' => $with, 'condition' => "t.wechatId = {$this->wechatInfo->id} {$whereType}", 'together' => true), 'pagination' => array('pageSize' => Page::SIZE, 'pageVar' => 'page'))); $this->render('replay', array('data' => $dataProvider->getData(), 'pages' => $dataProvider->getPagination(), 'type' => $type, 'wechatInfo' => $this->wechatInfo)); }
public function registerClientScript() { $id = $this->getId(); if ($this->ajaxUpdate === false) { $ajaxUpdate = false; } else { $ajaxUpdate = array_unique(preg_split('/\\s*,\\s*/', $this->ajaxUpdate . ',' . $id, -1, PREG_SPLIT_NO_EMPTY)); } $options = array('ajaxUpdate' => $ajaxUpdate, 'pagerClass' => $this->pagerCssClass, 'updateSelector' => $this->updateSelector, 'loadingClass' => $this->loadingCssClass, 'checkbox' => $this->checkbox); if ($this->enablePagination) { $options['pageVar'] = $this->dataProvider->getPagination()->pageVar; } $options = CJavaScript::encode($options); $cs = Yii::app()->getClientScript(); Yii::app()->bootstrap->registerAssetCss('jquery.kanbanview.css'); Yii::app()->bootstrap->registerAssetJs('jquery.kanbanlistview.js'); $cs->registerScript(__CLASS__ . $this->id, "jQuery('#{$id}').kanbanView({$options})"); }
public function actionIndex() { $type = Yii::app()->request->getParam('type'); $type = $type ? $type : Globals::TYPE_KEYWORDS; switch ($type) { case Globals::TYPE_KEYWORDS: $with = array('wheel_keywords'); $whereType = "and t.type='" . Globals::TYPE_KEYWORDS . "'\n and wheel_keywords.type='" . Globals::TYPE_WHEEL . "'"; break; case Globals::TYPE_MENU: $with = array('wheel_menuaction'); $whereType = "and t.type='" . Globals::TYPE_MENU . "'"; break; } $this->layout = '//layouts/memberList'; $dataProvider = new CActiveDataProvider('WheelModel', array('criteria' => array('order' => 't.id DESC', 'with' => $with, 'condition' => "t.wechatId = {$this->wechatInfo->id} {$whereType}", 'together' => true), 'pagination' => array('pageSize' => Page::SIZE, 'pageVar' => 'page'))); $this->render('index', array('data' => $dataProvider->getData(), 'pages' => $dataProvider->getPagination(), 'type' => $type, 'wechatInfo' => $this->wechatInfo)); }
public static function inquirylistdata($app) { $data = $app['arrt']; $organID = Yii::app()->user->getOrganID(); $criteria = new CDbCriteria(); $criteria->addCondition('OrganID=' . $organID); if ($data['startdate']) { $criteria->addCondition('CreateTime>=' . strtotime($data['startdate'])); } if ($data['enddate']) { $criteria->addCondition('CreateTime<' . strtotime("+1 day", strtotime($data['enddate']))); } if (!empty($data['status']) || $data['status'] == '0') { $criteria->addCondition('Status =' . $data['status']); } if ($data['inquirySn']) { $criteria->addSearchCondition('InquirySn', $data['inquirySn']); } $criteria->order = 'CreateTime desc'; $dataProvider = new CActiveDataProvider('PapInquiry', array('criteria' => $criteria, 'pagination' => array('pageSize' => '10'))); $pages = $dataProvider->getPagination(); $result = array('pages' => $pages, 'dataProvider' => $dataProvider); return $result; }
/** * An AJAX called method to export module data. * * This method actually prepares all the data via recursive AJAX requests * until all data has been exported. This exports each module into the CSV * by class, using pagination to cut down on request time. * * @param string $model The name of the current model being exported * @param int $page The page of data which the data provider's paginator is on */ public function actionGlobalExport($model, $page) { if (class_exists($model)) { ini_set('memory_limit', -1); $file = $this->safePath(); $fp = fopen($file, 'a+'); $tempModel = X2Model::model($model); $meta = array_keys($tempModel->attributes); $meta[] = $model; if ($page == 0) { fputcsv($fp, $meta); } // If we're on the first page for this model, need to add metadata. $dp = new CActiveDataProvider($model, array('pagination' => array('pageSize' => 100))); $pg = $dp->getPagination(); $pg->setCurrentPage($page); // These two lines will set the data provider $dp->setPagination($pg); // paginator to the requested page of data $records = $dp->getData(); $pageCount = $dp->getPagination()->getPageCount(); // Total number of pages foreach ($records as $record) { // Re-pack all unpacked attributes for writing to a file, so that // they can be interpolated as strings: foreach ($record->behaviors() as $name => $config) { $behavior = $record->asa($name); if ($behavior instanceof TransformedFieldStorageBehavior) { $behavior->packAll(); $record->disableBehavior($name); } } $tempAttributes = $tempModel->attributes; $tempAttributes = array_merge($tempAttributes, $record->attributes); if ($model == 'Profile') { $tempAttributes['theme'] = json_encode($record->theme); } $tempAttributes[] = $model; fputcsv($fp, $tempAttributes); // Export the data to CSV } unset($tempModel, $dp); fclose($fp); if ($page + 1 < $pageCount) { echo $page + 1; // If there are still more pages to go, echo the next page number } } }
public function init() { if (!isset($this->htmlOptions['class'])) { $this->htmlOptions['class'] = 'datatable-view'; } parent::init(); if ($this->selectableRows == 1) { $this->itemsCssClass .= ' singleSelect'; $this->config['fnInitComplete'] = new CJavaScriptExpression("function() { \$(this).find('tr input:checked').each(function() { \$(this).closest('tr').addClass('selected'); }); }"); } elseif ($this->selectableRows > 1) { $this->itemsCssClass .= ' multiSelect'; $this->config['fnInitComplete'] = new CJavaScriptExpression("function() { \$(this).find('tr input:checked').each(function() { \$(this).closest('tr').addClass('selected'); }); }"); } if ($this->dataProvider->pagination !== false && $this->enablePagination) { $this->config["paging"] = true; $this->config["pageLength"] = $this->dataProvider->getPagination()->pageSize; } else { $this->config["paging"] = false; } $this->config["language"]["info"] = Yii::t('app', "Showing entries {start} to {end} out of {total}", array('{start}' => '_START_', '{end}' => '_END_', '{total}' => '_TOTAL_')); $this->config["language"]["emptyTable"] = $this->emptyText; $this->config["language"]["infoEmpty"] = Yii::t('datatable', "Showing entries 0 to 0 out of 0"); $this->config["language"]["infoFiltered"] = Yii::t('datatable', "- filtering from {max} record(s)", array('{max}' => '_MAX_')); $this->config["language"]['paginate']['next'] = Yii::t('datatable', 'Next'); $this->config["language"]['paginate']['previous'] = Yii::t('datatable', 'Previous'); $this->config["language"]['filter']['none'] = Yii::t('datatable', 'No filter'); $this->config["ordering"] = $this->enableSorting; $this->config["searching"] = !is_null($this->filter); $this->config["dom"] = 'lrtip'; if (!empty($this->pageSizeOptions)) { $this->config['lengthMenu'] = true; if (key($this->pageSizeOptions) == 0) { $this->config['lengthMenu'] = $this->pageSizeOptions; $oneDimension = true; } else { $oneDimension = false; } $this->config['lengthMenu'][0] = []; $this->config['lengthMenu'][1] = []; foreach ($this->pageSizeOptions as $key => $value) { if ($oneDimension) { $this->config['lengthMenu'][0][] = $value; } else { $this->config['lengthMenu'][0][] = $key; } if ($value == -1) { $this->config['lengthMenu'][1][] = Yii::t('datatable', 'All'); } else { $this->config['lengthMenu'][1][] = $value; } } } else { $this->config['lengthChange'] = false; } if (isset($this->ajaxUrl)) { $this->config['ajax']['url'] = $this->ajaxUrl; // $this->config['processing'] = true; $this->config['serverSide'] = true; $this->config['deferLoading'] = true; } }
/** * @param string $veranstaltungsreihe_id * @param string $veranstaltung_id * @param int|null $status */ public function actionIndex($veranstaltungsreihe_id = "", $veranstaltung_id, $status = null) { $this->loadVeranstaltung($veranstaltungsreihe_id, $veranstaltung_id); if (!$this->veranstaltung->isAdminCurUser()) { $this->redirect($this->createUrl("/veranstaltung/login", array("back" => yii::app()->getRequest()->requestUri))); } /** @var Aenderungsantrag[] $aenderungsantraege */ $aenderungsantraege = Aenderungsantrag::model()->findAll(array("with" => "antrag", "alias" => "a", "condition" => 'antrag.veranstaltung_id=' . IntVal($this->veranstaltung->id) . " AND a.status != " . IAntrag::$STATUS_GELOESCHT . " AND antrag.status != " . IAntrag::$STATUS_GELOESCHT)); $stati = array(); $gesamtzahl = 0; foreach ($aenderungsantraege as $ae) { if ($ae->status == IAntrag::$STATUS_GELOESCHT) { continue; } if (!isset($stati[$ae->status])) { $stati[$ae->status] = 0; } $stati[$ae->status]++; $gesamtzahl++; } if ($status !== null) { $aenderungsantraege = Aenderungsantrag::model()->findAll(array("with" => "antrag", "alias" => "a", "condition" => 'antrag.veranstaltung_id=' . IntVal($this->veranstaltung->id) . " AND a.status = " . IntVal($status) . " AND a.status != " . IAntrag::$STATUS_GELOESCHT . " AND antrag.status != " . IAntrag::$STATUS_GELOESCHT)); } $dataProvider = new CActiveDataProvider('Aenderungsantrag', array("data" => $aenderungsantraege)); $dataProvider->getPagination()->pageSize = 50; $this->render('index', array('dataProvider' => $dataProvider, 'anzahl_stati' => $stati, 'anzahl_gesamt' => $gesamtzahl, 'status_curr' => $status)); }
public function actionIndex() { $this->layout = "//layouts/list"; $dataProvider = new CActiveDataProvider('ActiveRecordLog', array('criteria' => array('order' => 'created_at desc'), 'pagination' => array('pageSize' => Page::SIZE))); $this->render('index', array('data' => $dataProvider->getData(), 'pages' => $dataProvider->getPagination())); }
public function actionCreate1() { if (isset($_GET['id'])) { $dataset_id = $_GET['id']; } else { Yii::app()->user->setFlash('error', "Can't retrieve the files"); $this->redirect("/user/view_profile"); } $defaultFileSortColumn = 'dataset.name'; $defaultFileSortOrder = CSort::SORT_DESC; if (isset($_GET['filesort'])) { // use new sort and save to cookie // check if desc or not $order = substr($_GET['filesort'], strlen($_GET['filesort']) - 5, 5); $columnName = $defaultFileSortColumn; if ($order == '.desc') { $columnName = substr($_GET['filesort'], 0, strlen($_GET['filesort']) - 5); $order = 1; } else { $columnName = $_GET['filesort']; $order = 0; } $defaultFileSortColumn = $columnName; $defaultFileSortOrder = $order; Yii::app()->request->cookies['file_sort_column'] = new CHttpCookie('file_sort_column', $columnName); Yii::app()->request->cookies['file_sort_order'] = new CHttpCookie('file_sort_order', $order); } else { // use old sort if exists if (isset(Yii::app()->request->cookies['file_sort_column'])) { $cookie = Yii::app()->request->cookies['file_sort_column']->value; $defaultFileSortColumn = $cookie; } if (isset(Yii::app()->request->cookies['file_sort_order'])) { $cookie = Yii::app()->request->cookies['file_sort_order']->value; $defaultFileSortOrder = $cookie; } } $fsort = new MySort(); $fsort->attributes = array('*'); $fsort->attributes[] = "dataset.identifier"; $fsort->defaultOrder = array($defaultFileSortColumn => $defaultFileSortOrder); $fpagination = new CPagination(); $fpagination->pageVar = 'files_page'; $files = new CActiveDataProvider('File', array('criteria' => array('condition' => "dataset_id = " . $dataset_id, 'join' => 'JOIN dataset ON dataset.id = t.dataset_id', 'order' => 't.id'), 'sort' => $fsort, 'pagination' => $fpagination)); $updateAll = 0; if (isset($_POST['File'])) { if (isset($_POST['files'])) { $updateAll = 1; } $count = count($_POST['File']); $page = $_POST['page']; $pageCount = $_POST['pageCount']; if ($page < $pageCount) { $page++; $files->getPagination()->setCurrentPage($page); } for ($i = 0; $i < $count; $i++) { if ($updateAll == 0 && !isset($_POST[$i])) { continue; } $model = $this->loadModel($_POST['File'][$i]['id']); // $model->dataset_id = $dataset_id; $model->attributes = $_POST['File'][$i]; if ($model->date_stamp == "") { $model->date_stamp = NULL; } if (!$model->save()) { var_dump($_POST['File'][$i]); } } //determine if it want to submit // if (isset($_POST['file'])) { // $this->redirect("/dataset/submit"); // } } $dataset = Dataset::model()->findByAttributes(array('id' => $dataset_id)); $samples = $dataset->samples; $samples_data = array(); //add none and All , Multiple $samples_data[''] = ''; $samples_data['none'] = 'none'; $samples_data['All'] = 'All'; $samples_data['Multiple'] = 'Multiple'; foreach ($samples as $sample) { $samples_data[$sample->name] = $sample->name; } $identifier = $dataset->identifier; $action = 'create1'; $this->render($action, array('files' => $files, 'identifier' => $identifier, 'samples_data' => $samples_data, 'model' => $dataset)); }
public function actionIndex() { $this->layout = '//layouts/memberList'; $dataProvider = new CActiveDataProvider('WechatModel', array('criteria' => array('order' => 'created_at desc', 'condition' => 'uid=' . Yii::app()->session['userInfo']['uid']), 'pagination' => array('pageSize' => Page::SIZE))); $this->render('index', array('data' => $dataProvider->getData(), 'pages' => $dataProvider->getPagination())); }
public function actionIndex() { $dataProvider = new CActiveDataProvider('UserModel', array('criteria' => array('order' => 'uid desc'), 'pagination' => array('pageSize' => Page::SIZE))); $this->render('index', array('data' => $dataProvider->getData(), 'pages' => $dataProvider->getPagination())); }
/** * 技术服务点列表页面 */ public function actionTechnique() { $organID = Yii::app()->user->getOrganID(); $criteria = new CDbCriteria(); $criteria->condition = 'OrganID=' . $organID; $criteria->order = 'ID DESC'; $dataProvider = new CActiveDataProvider('MakeTechnique', array('criteria' => $criteria, 'pagination' => array('pageSize' => '10'))); $pages = $dataProvider->getPagination(); $this->render('techque', array('pages' => $pages, 'dataProvider' => $dataProvider)); }