Exemple #1
2
 public function run()
 {
     $model = new MailLog();
     //条件
     $criteria = new CDbCriteria();
     $accept = trim(Yii::app()->request->getParam('accept'));
     //收件人
     $subject = trim(Yii::app()->request->getParam('subject'));
     //主题
     $start_time = Yii::app()->request->getParam('start_time');
     $end_time = Yii::app()->request->getParam('end_time');
     $accept && $criteria->addSearchCondition('accept', $accept);
     $subject && $criteria->addSearchCondition('subject', $subject);
     $start_time && $criteria->compare('sendtime', '>=' . strtotime($start_time));
     $end_time && $criteria->compare('sendtime', '<=' . strtotime($end_time));
     $criteria->order = 't.id DESC';
     $count = $model->count($criteria);
     //分页
     $pages = new CPagination($count);
     $pages->pageSize = 20;
     $pages->applyLimit($criteria);
     //查询
     $result = $model->findAll($criteria);
     $this->controller->render('index', array('model' => $model, 'datalist' => $result, 'pagebar' => $pages));
 }
 public function run()
 {
     $params = array();
     $criteria = new CDbCriteria();
     //        $criteria->select = array('id,username,fullname,phone,address,status');
     $criteria->select = '*';
     if (isset($this->team_lear_id) and $this->team_lear_id != '') {
         $criteria->addCondition('team_lear_id=' . $this->team_lear_id);
     }
     $criteria->params = $params;
     $total = ATrainingTeam::model()->count($criteria);
     $offset = $this->limit * ($this->page - 1);
     $criteria->limit = $this->limit;
     $criteria->offset = $offset;
     $data = ATrainingTeam::model()->findAll($criteria);
     $listTrainee = array();
     if (!empty($data)) {
         foreach ($data as $item) {
             $listTrainee[] = CJSON::decode(CJSON::encode($item->pls_user));
         }
     }
     $data = $listTrainee;
     $pages = new CPagination($total);
     $pages->pageSize = $this->limit;
     $pages->applyLimit($criteria);
     $this->render($this->view, array('data' => $data, 'pages' => $pages));
 }
Exemple #3
0
 public function actionIndex($uid)
 {
     //自己才能看自己的个人中心
     if ($uid != Yii::app()->user->id) {
         $this->redirect('/');
     }
     //显示用户资料
     $user_model = Users::model()->findByPk($uid);
     //获取ype
     if (isset($_GET['type']) && $_GET['type'] == 'focus') {
         //获取关注的问题
         $sql = "select `{{question}}`.`id`,`{{question}}`.`question_content`,`{{question}}`.`add_time`,`{{question}}`.`published_uid`,`{{question}}`.`lock`,`{{question}}`.`best_answer`,`{{question}}`.`answer_count`,`{{question}}`.`view_count` from `{{question}}` left join `{{question_focus}}` on (`{{question_focus}}`.`question_id`=`{{question}}`.`id`) where `{{question_focus}}`.`uid`={$uid} order by `{{question_focus}}`.`add_time` desc";
     } elseif (isset($_GET['type']) && $_GET['type'] == 'answer') {
         //获取回复的问题
         $sql = "select `{{question}}`.`id`,`{{question}}`.`question_content`,`{{question}}`.`add_time`,`{{question}}`.`published_uid`,`{{question}}`.`lock`,`{{question}}`.`best_answer`,`{{question}}`.`answer_count`,`{{question}}`.`view_count` from `{{question}}` left join `{{answer}}` on (`{{answer}}`.`question_id`=`{{question}}`.`id`) where `{{answer}}`.`uid`={$uid}";
     } else {
         //获取自己发布的问题
         $sql = "select `{{question}}`.`id`,`{{question}}`.`question_content`,`{{question}}`.`add_time`,`{{question}}`.`published_uid`,`{{question}}`.`lock`,`{{question}}`.`best_answer`,`{{question}}`.`answer_count`,`{{question}}`.`view_count` from `{{question}}` where `{{question}}`.`published_uid`={$uid} order by `{{question}}`.`add_time` desc";
     }
     $connection = Yii::app()->db;
     $criteria = new CDbCriteria();
     $models = $connection->createCommand($sql)->queryAll();
     $count = count($models);
     $pages = new CPagination($count);
     $pages->pageSize = 10;
     $pages->applylimit($criteria);
     $models = $connection->createCommand($sql . " LIMIT :offset,:limit");
     $models->bindValue(':offset', $pages->currentPage * $pages->pageSize);
     $models->bindValue(':limit', $pages->pageSize);
     $models = $models->queryAll();
     $this->render('index', array('user_model' => $user_model, 'models' => $models, 'pages' => $pages, 'count' => $count));
 }
 public function actionFind()
 {
     if (isset($_POST['flightNumber'])) {
         $current = date('Y-m-d');
         $flightNumber = $_POST['flightNumber'];
         $criteria = new CDbCriteria();
         $criteria->join = 'LEFT JOIN tbl_mry_user ON tbl_mry_plan.userId=tbl_mry_user.userId';
         $criteria->addCondition('flightNumber=:flightNumber');
         $criteria->params = array(':flightNumber' => $flightNumber);
         $criteria->order = 'startDate DESC';
         $UserModel = User::model();
         $total = $UserModel->count($criteria);
         $pager = new CPagination($total);
         $pager->pageSize = 10;
         $pager->applyLimit($criteria);
         $UserList = $UserModel->findAll($criteria);
         //删除PASSWORD相关的信息
         $dataFormat = new DataFormat();
         $format = $dataFormat->format($userList, null, null);
         $clientFlash = new ClientFlash();
         if ($total > 0) {
             $clientFlash->pushMobile(0, $format);
         } else {
             _echo(3, 数据为空);
         }
     }
 }
Exemple #5
0
 public function actionMore()
 {
     Yii::app()->clientScript->registerCssFile(Yii::app()->theme->baseUrl . '/css/enjoy.css');
     $city_id = Yii::app()->request->getQuery('city', 0);
     $time_sort = Yii::app()->request->getQuery('time_sort', 'DESC');
     $price_sort = Yii::app()->request->getQuery('lp_dol');
     $criteria = new CDbCriteria();
     $criteria->order = 'id DESC';
     if (!empty($city_id)) {
         $criteria->addCondition('city_id=' . $city_id);
     }
     if (!empty($time_sort)) {
         $criteria->order = 'accessDate ' . $time_sort;
     }
     if (!empty($price_sort)) {
         $criteria->order = 'lp_dol ' . $price_sort;
     }
     $criteria->addCondition('lp_dol>3000000');
     $count = House::model()->count($criteria);
     $pager = new CPagination($count);
     $pager->pageSize = 10;
     $pager->applyLimit($criteria);
     $house_list = House::model()->findAll($criteria);
     $subject_list = Subject::model()->findAll(array('order' => 'id DESC'));
     $cur_city = City::model()->findByPk($city_id);
     $data = array('house_list' => $house_list, 'subject_list' => $subject_list, 'cur_city' => $cur_city, 'count' => $count, 'time_sort' => $time_sort, 'price_sort' => $price_sort, 'pages' => $pager);
     $this->render('more', $data);
 }
Exemple #6
0
 public function actionIndexdata()
 {
     $criteria = new CDbCriteria();
     $criteria->select = '*';
     //'BrandID,BrandName,Pinyin,Remarks';
     $criteria->order = 'CreateTime desc';
     $criteria->addCondition('OrganID=' . Commonmodel::getOrganID());
     $res = MakeGoodsBrand::model()->findAll($criteria);
     $count = count($res);
     $page = new CPagination($count);
     $page->pageSize = $_GET['rows'];
     $page->applyLimit($criteria);
     $res = MakeGoodsBrand::model()->findAll($criteria);
     $data = array();
     if (is_array($res)) {
         foreach ($res as $key => $val) {
             $data[$key] = $val->attributes;
             $sQl = 'select count(b.goods_brand)as number from tbl_make_goods a,tbl_make_goods_version b where b.goods_brand=' . $val->BrandID . ' and b.organID=' . $val->OrganID . ' and a.IsSale=0 and a.ISdelete=0 and  a.NewVersion=b.version_name and a.id=b.goods_id';
             $query = Yii::app()->db->createCommand($sQl)->queryAll();
             $data[$key]['Number'] = $query[0]['number'];
         }
     }
     // var_dump($data);
     echo json_encode(array('total' => $count, 'rows' => $data ? $data : array()));
 }
 public function actionIndex($is_product = 1)
 {
     if (!empty($_POST)) {
         $is_new_product = $is_product;
         $images = CUploadedFile::getInstancesByName('images');
         if (isset($images) && count($images) > 0) {
             // go through each uploaded image
             foreach ($images as $image => $pic) {
                 $model = new Slides();
                 $imageType = explode('.', $pic->name);
                 $imageType = $imageType[count($imageType) - 1];
                 $imageName = md5(uniqid()) . '.' . $imageType;
                 if ($pic->saveAs(Yii::getPathOfAlias('webroot') . '/upload/images/' . $imageName)) {
                     $model->image = $imageName;
                     $model->name = $pic->name;
                     $model->is_product = $is_new_product;
                     $model->save();
                     Yii::app()->user->setFlash('success', translate('Thêm thành công.'));
                 }
                 // handle the errors here, if you want
             }
         }
         PIUrl::createUrl('/admin/slides/index', array('is_product' => $is_product));
     }
     $criteria = new CDbCriteria();
     $criteria->addCondition("is_product= {$is_product}");
     $criteria->order = 'id DESC';
     $count = Slides::model()->count($criteria);
     $pages = new CPagination($count);
     // results per page
     $pages->pageSize = 6;
     $pages->applyLimit($criteria);
     $model = Slides::model()->findAll($criteria);
     $this->render('index', compact('model', 'pages'));
 }
Exemple #8
0
 public function run()
 {
     $model = new Comment();
     //条件
     $criteria = new CDbCriteria();
     $type = trim(Yii::app()->request->getParam('type'));
     $type && $criteria->addColumnCondition(array('type' => $type));
     $status = trim(Yii::app()->request->getParam('status'));
     $status && $criteria->addColumnCondition(array('status' => $status));
     $title = trim(Yii::app()->request->getParam('content'));
     $title && $criteria->addSearchCondition('content', $title);
     $criteria->order = 't.id DESC';
     $count = $model->count($criteria);
     //分页
     $pages = new CPagination($count);
     $pages->pageSize = 10;
     $pages->applyLimit($criteria);
     //查询
     $result = $model->findAll($criteria);
     //全部类型
     $model_types = ModelType::model()->findAll();
     Yii::app()->clientScript->registerCssFile($this->controller->_static_public . "/js/kindeditor/code/prettify.css");
     Yii::app()->clientScript->registerScriptFile($this->controller->_static_public . "/js/kindeditor/code/prettify.js", CClientScript::POS_END);
     $this->controller->render('index', array('model' => $model, 'model_types' => $model_types, 'datalist' => $result, 'pagebar' => $pages));
 }
Exemple #9
0
 /**
  * 获取一定条件下的文章
  * @param array $params = ('condition'=> '额外条件', 'order'=>'排序', 'with'=>'关联表', 'limit'=>'条数', 'page'=>'是否分页')
  * @param $pages 分页widget
  * @return array
  */
 public static function getList($params = array(), &$pages = null)
 {
     $pages = array();
     $params['condition'] = isset($params['condition']) ? $params['condition'] : '';
     $params['order'] = isset($params['order']) ? $params['order'] : '';
     $params['with'] = isset($params['with']) ? $params['with'] : '';
     $params['limit'] = isset($params['limit']) ? $params['limit'] : '';
     $params['page'] = isset($params['page']) ? $params['page'] : '';
     //组合条件
     $criteria = new CDbCriteria();
     $criteria->condition = 't.status=:status';
     $params['condition'] && ($criteria->condition .= $params['condition']);
     $criteria->order = $params['order'] ? $params['order'] : 't.id DESC';
     $criteria->with = array('catalog');
     $criteria->select = "t.title, t.id,t.title_style, ";
     $criteria->select .= " t.copy_from, t.copy_url, t.update_time,t.introduce, t.tags, t.view_count";
     $criteria->params = array(':status' => 'Y');
     $params['with'] && ($criteria->with = (array) $params['with']);
     $limit = $params['limit'] > 0 ? intval($params['limit']) : 15;
     //是否分页
     if ($params['page']) {
         //分页
         $count = self::model()->count($criteria);
         $pages = new CPagination($count);
         $pages->pageSize = $limit;
         $pages->applyLimit($criteria);
     } else {
         $criteria->limit = $limit;
     }
     $data = self::model()->findAll($criteria);
     return $data ? $data : array();
 }
Exemple #10
0
 public function actionPosts($name)
 {
     $tag = urldecode($name);
     $this->setSiteTitle(t('tag_posts', 'main', array('{name}' => $tag)));
     // @todo 关键字的描述没有指定
     $this->setPageKeyWords($tag);
     $this->setPageDescription(t('tag_posts_page_description', 'main', array('{name}' => $tag)));
     cs()->registerMetaTag('all', 'robots');
     $cmd = app()->getDb()->createCommand()->select('p.id')->from(TABLE_TAG . ' t')->where('t.name = :tagname', array(':tagname' => $tag))->join(TABLE_POST_TAG . ' pt', 'pt.tag_id = t.id')->join(TABLE_POST . ' p', 'p.id = pt.post_id');
     $ids = $cmd->queryColumn();
     if (count($ids) > 0) {
         $criteria = new CDbCriteria();
         if (param('post_list_type') == POST_LIST_TYPE_TITLE) {
             $criteria->select = array('t.id', 't.title', 't.visit_nums', 't.comment_nums', 't.create_time');
         }
         $criteria->order = 't.istop, t.create_time desc, t.id desc';
         $criteria->addInCondition('t.id', $ids)->addCondition('t.state = :state');
         $criteria->params += array(':state' => POST_STATE_ENABLED);
         $count = Post::model()->count($criteria);
         $pages = new CPagination($count);
         $pages->setPageSize(param('postCountOfTitleListPage'));
         $pages->applyLimit($criteria);
         $posts = Post::model()->findAll($criteria);
     }
     $listType = param('post_list_type');
     $view = $listType == POST_LIST_TYPE_SUMMARY ? '/post/_summary_list' : '/post/_title_list';
     $blockTitle = t('tag_posts', 'main', array('{name}' => $tag));
     $data = array('blockTitle' => $blockTitle, 'posts' => $posts, 'pages' => $pages);
     $postListHtml = $this->renderPartial($view, $data, true);
     $this->render('posts', array('postListHtml' => $postListHtml));
 }
 public function actionFiltertest()
 {
     $kind_of_test = isset($_REQUEST['kind_of_test']) ? $_REQUEST['kind_of_test'] : '';
     $criteria = new CDbCriteria();
     if ($kind_of_test != '') {
         $criteria->condition = 'created_by=:created_by and kind_of_test=:kind_of_test';
         $criteria->params = array(':created_by' => Yii::app()->user->id, ':kind_of_test' => $kind_of_test);
     } else {
         $criteria->condition = 'created_by=:created_by';
         $criteria->params = array(':created_by' => Yii::app()->user->id);
     }
     $criteria->order = 'created_date DESC';
     $total = WTest::model()->count($criteria);
     $limit = 6;
     $page = (isset($_GET['page']) and !empty($_GET['page'])) ? $_GET['page'] : 1;
     $offset = $limit * ($page - 1);
     $criteria->limit = $limit;
     $criteria->offset = $offset;
     $data = WTest::model()->findAll($criteria);
     if ($total > 0) {
         $pages = new CPagination($total);
         $pages->pageSize = $limit;
         $pages->applyLimit($criteria);
     } else {
         $pages = NULL;
     }
     $html = $this->renderPartial('/wTest/_filter', array('data' => $data, 'pages' => $pages));
     echo $html;
     exit;
 }
 public function actioncxIndex()
 {
     //print_r( ucfirst($this->getId() ) );
     //$this->actionId     = $this->getAction()->getId();
     $controllerId = $this->controllerId;
     $criteria = new CDbCriteria();
     if (isset($_GET['keyword']) || !empty($_GET['keyword']) || strlen($_GET['keyword']) > 0) {
         $keyword = trim($_GET['keyword']);
         $criteria->condition = 'title like :keyword ';
         $criteria->params = array(':keyword' => "%{$keyword}%");
         $is_partial = true;
     }
     $imodel = new $controllerId();
     $item_count = call_user_func(array($imodel, 'count'), $criteria);
     $page_size = 10;
     $pages = new CPagination($item_count);
     $pages->setPageSize($page_size);
     $pagination = new CLinkPager();
     $pagination->cssFile = false;
     $pagination->setPages($pages);
     $pagination->init();
     $criteria->limit = $page_size;
     $criteria->offset = $pages->offset;
     $select_pagination = new CListPager();
     $select_pagination->header = '跳转到:';
     $select_pagination->htmlOptions['onchange'] = "";
     $select_pagination->setPages($pages);
     $select_pagination->init();
     $list = call_user_func(array($imodel, 'findAll'), $criteria);
     if ($is_partial) {
         $this->renderPartial('_index', array('list' => $list, 'pagination' => $pagination, 'select_pagination' => $select_pagination), false, true);
     } else {
         $this->render('index', array('list' => $list, 'pagination' => $pagination, 'select_pagination' => $select_pagination), false, true);
     }
 }
Exemple #13
0
 public function run()
 {
     $this->controller->_seoTitle = '交易记录 - ' . $this->controller->_setting['site_name'];
     $this->controller->loadModel();
     $model = new UserTrade();
     $criteria = new CDbCriteria();
     //查询条件
     $create_time_start = Yii::app()->request->getParam('create_time_start');
     $create_time_end = Yii::app()->request->getParam('create_time_end');
     $trade_type = Yii::app()->request->getParam('trade_type');
     $trade_status = Yii::app()->request->getParam('trade_status');
     $create_time_start && $criteria->addBetweenCondition('time_create', strtotime($create_time_start), strtotime($create_time_end));
     if ($trade_type && $trade_type != 'all') {
         $criteria->addColumnCondition(['type' => $trade_type]);
     }
     if ($trade_status && $trade_status != 'all') {
         $criteria->addColumnCondition(['status' => $trade_status]);
     }
     $criteria->addColumnCondition(array('user_id' => Yii::app()->user->id));
     $count = $model->count($criteria);
     $pages = new CPagination($count);
     $pages->pageSize = 10;
     $pages->applyLimit($criteria);
     $lists = $model->findAll($criteria);
     //加载css js
     Yii::app()->clientScript->registerScriptFile($this->controller->_static_public . "/js/jquery/jquery.js");
     Yii::app()->clientScript->registerScriptFile($this->controller->_static_public . "/js/My97DatePicker/WdatePicker.js", CClientScript::POS_END);
     $this->controller->render('list_trade', array('lists' => $lists, 'pages' => $pages, 'create_time_start' => $create_time_start, 'create_time_end' => $create_time_end, 'trade_type' => $trade_type, 'trade_status' => $trade_status));
 }
Exemple #14
0
 public function actionIndex()
 {
     $id = $_REQUEST['id'];
     $this->data['cur_moduleid'] = $id;
     $module = Yii::app()->cache->get("module_" . $id);
     if ($module == false) {
         $module = $this->connection->createCommand("select * from xm_module where module_id = " . $id)->queryRow();
         Yii::app()->cache->set("module_" . $id, $module);
     }
     $this->data['module'] = $module;
     /*右侧导航栏*/
     $topid = $this->getTopIdFromIDEN($module['iden']);
     $modulequeue = Yii::app()->cache->get("modulequeue_" . $topid);
     if ($modulequeue == false) {
         $modulequeue = $this->getQueueModulesById($topid);
         Yii::app()->cache->set("modulequeue_" . $topid, $modulequeue);
     }
     $this->data['modulequeue'] = $modulequeue;
     $criteria = new CDbCriteria();
     $criteria->addCondition('module_id=' . $id, 'AND');
     $criteria->order = "createtime desc";
     $count = Message::model()->count($criteria);
     $pager = new CPagination($count);
     $pager->pageSize = 10;
     $pager->applyLimit($criteria);
     $articles = Message::model()->findAll($criteria);
     $this->data['pages'] = $pager;
     $this->data['list'] = $articles;
     Yii::app()->params['TITLE'] = $module['category'];
     Yii::app()->params['APPKEYWORDS'] = $module['category'];
     Yii::app()->params['APPDESCRIPTION'] = $module['category'];
     $this->render('index', $this->data);
 }
Exemple #15
0
 public function getWishListForWeb($user_id)
 {
     $criteria = new CDbCriteria();
     $criteria->condition = "user_id = {$user_id}";
     $wishlists = Wishlist::model()->findAll($criteria);
     $wishlist_arr = array();
     foreach ($wishlists as $wishlist) {
         $wishlist_arr[] = $wishlist->post_id;
     }
     //var_dump($wishlist_arr); die;
     $returnArr = array();
     $criteria_post = new CDbCriteria();
     $criteria_post->addInCondition('t.post_id', $wishlist_arr);
     $count = Posts::model()->count($criteria_post);
     $pages = new CPagination($count);
     $pages->validateCurrentPage = FALSE;
     $pages->pageSize = Yii::app()->params['RESULT_PER_PAGE'];
     $pages->applyLimit($criteria_post);
     $posts = Posts::model()->findAll($criteria_post);
     $is_followed = User::model()->isFollowedByUser(Yii::app()->session['user_id'], $user_id, 'USER');
     $profile = User::model()->findByPk($user_id);
     foreach ($posts as $post) {
         $itemArr = Posts::model()->getPostById($post->post_id, Yii::app()->session['user_id']);
         $returnArr[] = $itemArr;
     }
     return array('data' => $returnArr, 'pages' => $pages, 'profile' => $profile, 'is_followed' => $is_followed);
     // return FALSE;
 }
 public function run()
 {
     $params = array();
     $criteria = new CDbCriteria();
     $criteria->select = array('lecture_name,training_minute,id,lecture_type');
     if (isset($this->lecture_name) and $this->lecture_name != '') {
         $keyword = addcslashes($this->lecture_name, '%_');
         $criteria->addCondition('lecture_name LIKE :keyword');
         $params[':keyword'] = "%{$keyword}%";
     }
     if (isset($this->lecture_cat) and $this->lecture_cat != '') {
         $criteria->addCondition('lecture_cat_id=' . $this->lecture_cat);
     }
     if (isset($this->trainer) and $this->trainer != '') {
         $criteria->addCondition('created_by=' . $this->trainer);
     }
     if (!empty(Yii::app()->user->id) and Yii::app()->session['group_id'] == 1) {
         $criteria->addCondition('created_by=' . Yii::app()->user->id);
     }
     $criteria->params = $params;
     $criteria->order = 'created_date DESC';
     $total = Lecture::model()->count($criteria);
     $offset = $this->limit * ($this->page - 1);
     $criteria->limit = $this->limit;
     $criteria->offset = $offset;
     $data = Lecture::model()->findAll($criteria);
     if (!empty($data)) {
         $data = CJSON::decode(CJSON::encode($data));
     }
     $pages = new CPagination($total);
     $pages->pageSize = $this->limit;
     $pages->applyLimit($criteria);
     $this->render($this->view, array('data' => $data, 'pages' => $pages));
 }
 /**
  * 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()
 {
     // handle space visibility changes
     if (isset($_POST['reputationUsers'])) {
         $user = $this->getUser();
         $userSpace = Yii::app()->request->getParam('reputationUsers');
         foreach ($userSpace as $space) {
             if (isset($_POST['reputationUser_' . $space])) {
                 $userSettings = Yii::app()->request->getParam('reputationUser_' . $space);
                 $reputationUser = ReputationUser::model()->findByAttributes(array('space_id' => $space, 'user_id' => $user->id));
                 if ($reputationUser != null) {
                     $reputationUser->visibility = isset($userSettings['visibility']) && $userSettings['visibility'] == 1 ? 1 : 0;
                     $reputationUser->save();
                 }
             }
         }
         Yii::app()->user->setFlash('data-saved', Yii::t('SpaceModule.controllers_AdminController', 'Saved'));
     }
     $user = $this->getUser();
     $criteria = new CDbCriteria();
     $criteria->condition = 'user_id=:userId';
     $criteria->order = 'space_id ASC';
     $criteria->params = array(':userId' => $user->id);
     $itemCount = ReputationUser::model()->count($criteria);
     $pages = new CPagination($itemCount);
     $pages->pageSize = 10;
     $pages->applyLimit($criteria);
     $reputations = ReputationUser::model()->findAll($criteria);
     $this->render('userReputation', array('user' => $user, 'reputations' => $reputations, 'pages' => $pages));
 }
 public function actionAll()
 {
     $model = Notify::model();
     $user_id = Yii::app()->user->id;
     $criteria = new CDbCriteria();
     $criteria->with = ['status' => ['select' => ['status.id', 'status.notify_id', 'status.user_id', 'status.read_status', 'IF(status.date_showed, status.date_showed, "' . date('c') . '") as date_showed'], 'on' => 'status.user_id = :user_id']];
     $criteria->params = [':user_id' => $user_id, ':all_users' => Notify::All_USERS, ':type' => Notify::TYPE_DEFAULT, ':today' => date('c'), ':user_date_create' => $model->getUserDateCreate($user_id)];
     $criteria->addCondition('t.user_id=:user_id OR t.user_id=:all_users');
     if ($model->isGroupSupport() && $model->getUserGroups($user_id)) {
         $criteria->addInCondition('t.group_id', $model->getUserGroups($user_id), 'OR');
     }
     $criteria->addCondition('(t.date_create >= :user_date_create AND t.date_show<=:today) AND  (IF(date_end, :today <= date_end, 1) OR status.user_id IS NOT NULL)');
     $criteria->addCondition('t.type = :type');
     $criteria->order = 'date_showed desc, t.date_show desc';
     $count = Notify::model()->count($criteria);
     $pages = new CPagination($count);
     $pages->pageSize = Yii::app()->notify->numberDisplayInAll;
     $pages->applyLimit($criteria);
     $notifications = Notify::model()->findAll($criteria);
     $ids = array_keys(array_filter(CHtml::listData($notifications, 'id', 'status.read_status'), function ($var) {
         return $var == 0;
     }));
     if ($ids) {
         Notify::changeReadStatusByIds($ids, $user_id, Notify::READ);
         $notifications = Notify::model()->findAll($criteria);
     }
     $this->render('all', ['notifications' => $notifications, 'pages' => $pages]);
 }
Exemple #20
0
 /**
  * 显示问题列表
  */
 public function actionIndex()
 {
     $sql = "select `{{question}}`.`id`,`{{question}}`.`question_content`,`{{question}}`.`add_time`,`{{question}}`.`update_time`,`{{question}}`.`answer_count`,`{{question}}`.`view_count`,`{{question}}`.`lock`,`{{question}}`.`focus_count`,`{{question}}`.`comment_count`,`{{question}}`.`best_answer`,`{{question}}`.`ip`,`{{users}}`.`username`,`{{users}}`.`uid`\n\t\t\t\tfrom `{{question}}`\t\t\t\t\n\t\t\t\tleft join `{{users}}` on (`{{users}}`.`uid` = `{{question}}`.`published_uid`)";
     $condition = array();
     //根据uid搜索
     if (isset($_GET['uid'])) {
         $condition[] = "`{{users}}`.`uid`={$_GET['uid']} ";
     }
     if (isset($_POST['content'])) {
         $condition[] = " `{{question}}`.`question_content` like '%{$_POST['content']}%'";
     }
     $conditions = implode('AND', $condition);
     //var_dump($conditions);
     if ($conditions) {
         $conditions = ' where ' . $conditions;
         $sql .= $conditions;
     }
     $sql .= " order by `{{question}}`.`add_time` desc ";
     $connection = Yii::app()->db;
     $criteria = new CDbCriteria();
     $models = $connection->createCommand($sql)->queryAll();
     $count = count($models);
     $pages = new CPagination($count);
     $pages->pageSize = 12;
     $pages->applylimit($criteria);
     $models = $connection->createCommand($sql . " LIMIT :offset,:limit");
     $models->bindValue(':offset', $pages->currentPage * $pages->pageSize);
     $models->bindValue(':limit', $pages->pageSize);
     $models = $models->queryAll();
     $this->render('index', array('models' => $models, 'pages' => $pages, 'count' => $count));
 }
 public function actionList()
 {
     $_default_item_perpage = 10;
     if (isset($_GET['limit']) && (int) $_GET['limit'] > 0) {
         Yii::app()->session['current'] = $_GET['limit'];
         $_default_item_perpage = Yii::app()->session['current'];
     } else {
         if (isset(Yii::app()->session['current'])) {
             $_default_item_perpage = Yii::app()->session['current'];
         } else {
             Yii::app()->session['current'] = $_default_item_perpage;
         }
     }
     $criteria = new CDbCriteria();
     $criteria->addCondition('current=1 AND web=1');
     $q = Yii::app()->getRequest()->getQuery('q');
     if ($q) {
         $criteria->addCondition('`title` LIKE "%' . $q . '%" OR `code` LIKE "%' . $q . '%" OR `description_short` LIKE "%' . $q . '%"');
     }
     $criteria->order = _xls_get_sort_order();
     $item_count = Product::model()->count($criteria);
     $pages = new CPagination($item_count);
     $pages->setPageSize($_default_item_perpage);
     $pages->applyLimit($criteria);
     $model = Product::model()->findAll($criteria);
     $this->render('list', array('model' => $model, 'item_count' => $item_count, 'page_size' => $_default_item_perpage, 'items_count' => $item_count, 'pages' => $pages));
 }
Exemple #22
0
 /**
  * Action for the members section of the directory
  *
  * @todo Dont pass lucene hits to view, build user array inside of action
  */
 public function actionMembers()
 {
     $details = Yii::app()->db->createCommand()->select('companyname, username, firstname, lastname, title, guid')->from('user, profile')->where('user.id=profile.user_id and group_id=3')->order('companyname')->queryAll();
     $companycount = Yii::app()->db->createCommand()->select('count(distinct(companyname)) as count')->from('profile')->where('companyname not like \'student\'')->order('companyname')->queryAll();
     $item_count = (int) $companycount[0]["count"];
     $page_size = (int) $companycount[0]["count"];
     $pages = new CPagination($item_count);
     $pages->setPageSize($page_size);
     $end = $pages->offset + $pages->limit <= $item_count ? $pages->offset + $pages->limit : $item_count;
     $sample = array();
     $y = "";
     $i = 0;
     $j = 0;
     foreach ($details as $x) {
         if ($x["companyname"] != $y) {
             $sample[$i++] = array('cname' => $x["companyname"], 'detail' => array());
             $j = 0;
         }
         $sample[$i - 1]["detail"][$j++] = $x;
         $y = $x["companyname"];
     }
     $pg_content = array();
     for ($i = $pages->offset; $i < $end; $i++) {
         $pg_content[$i] = $sample[$i];
     }
     $this->render('members', array('item_count' => $item_count, 'page_size' => $page_size, 'items_count' => $item_count, 'pages' => $pages, 'sample' => $pg_content));
 }
 public function actionIndex()
 {
     Yii::app()->clientScript->registerCssFile(Yii::app()->theme->baseUrl . '/css/post.css');
     $left_news = Post::model()->findAll(array('select' => 'id, title, image, summary', 'condition' => 'catalog_id = :catalog_id', 'params' => array(':catalog_id' => 3), 'order' => 'id DESC', 'limit' => 3));
     $special_ids = array();
     foreach ($left_news as $row) {
         array_push($special_ids, $row->id);
     }
     $criteria = new CDbCriteria();
     $criteria->select = 'id, title, summary';
     $criteria->order = 'id DESC';
     $criteria->addCondition('catalog_id = 3');
     $criteria->addNotInCondition('id', $special_ids);
     $criteria->limit = 1;
     $top_news = Post::model()->findAll($criteria);
     array_push($special_ids, $top_news[0]->id);
     $criteria = new CDbCriteria();
     $criteria->order = 'id DESC';
     $criteria->addCondition('catalog_id = 3');
     $criteria->addNotInCondition('id', $special_ids);
     $count = Post::model()->count($criteria);
     $pager = new CPagination($count);
     $pager->pageSize = 30;
     $pager->applyLimit($criteria);
     $more_news = Post::model()->findAll($criteria);
     $data = array('left_news' => $left_news, 'top_news' => $top_news[0], 'more_news' => $more_news, 'pages' => $pager);
     $this->render('index', $data);
 }
 public function actionIndex()
 {
     //include scripts and css
     Yii::app()->getClientScript()->registerCoreScript('jquery');
     $cs = Yii::app()->clientScript;
     $cs->registerScriptFile('/js/' . 'books.js');
     // register script file
     //
     //pager creation
     $criteria = new CDbCriteria();
     $count = Books::model()->count($criteria);
     $pages = new CPagination($count);
     //  elements on page
     $pages->pageSize = 5;
     $pages->applyLimit($criteria);
     $b_data = Books::model()->with('authors')->findAll($criteria);
     //get Book with authors through many to many relation
     foreach ($b_data as $item) {
         //get only author lastname.
         $tmp_auth = array();
         foreach ($item->authors as $auth) {
             $tmp_auth[] = $auth->firstname . ' ' . $auth->lastname;
         }
         $item->authors = $tmp_auth;
     }
     $this->render('index', array('b_data' => $b_data, 'pages' => $pages));
 }
Exemple #25
0
 public function run()
 {
     $model = new User();
     //审核状态
     $user_status = array('all' => '所有', User::STATUS_AUDIT => '待审核', User::STATUS_DISABLE => '禁用', User::STATUS_NORMAL => '正常');
     //条件
     $criteria = new CDbCriteria();
     $groupid = intval(Yii::app()->request->getParam('groupid'));
     $username = trim(Yii::app()->request->getParam('username'));
     $status = Yii::app()->request->getParam('status', 'all');
     $groupid > 0 && $criteria->addColumnCondition(array('groupid' => $groupid));
     if ($status != 'all') {
         $criteria->addSearchCondition('status', $status);
     }
     $criteria->addSearchCondition('username', $username);
     $criteria->order = 'uid ASC';
     $count = $model->count($criteria);
     //分页
     $pages = new CPagination($count);
     $pages->pageSize = 10;
     $pages->applyLimit($criteria);
     //查询
     $result = $model->findAll($criteria);
     $this->controller->render('index', array('datalist' => $result, 'pagebar' => $pages, 'status' => $status, 'user_status' => $user_status));
 }
Exemple #26
0
 public function actionPickAtt()
 {
     $return_id = $_GET['return_id'];
     $rtype = $_GET['rtype'];
     $criteria = new CDbCriteria();
     if (isset($_GET['keyword'])) {
         $screen_name = trim($_GET['keyword']);
         $criteria->condition = 'screen_name like :screen_name';
         $criteria->params = array(':screen_name' => "%{$screen_name}%");
         $partial_tpl = '_att';
         //$atts = Attachment::model()->findAll($criteria);
         //$this->renderPartial('_att',array('return_id' => $return_id,'atts' => $atts,'rtype' => $rtype ),false,true);
     } else {
         $partial_tpl = 'pickatt';
         //$atts = Attachment::model()->findAll();
         //$this->renderPartial('pickatt',array('return_id' => $return_id,'atts' => $atts ,'rtype' => $rtype ),false,true);
     }
     $item_count = Attachment::model()->count($criteria);
     $page_size = 10;
     $pages = new CPagination($item_count);
     $pages->setPageSize($page_size);
     $pagination = new CLinkPager();
     $pagination->cssFile = false;
     $pagination->setPages($pages);
     $pagination->init();
     $criteria->limit = $page_size;
     $criteria->offset = $pages->offset;
     $select_pagination = new CListPager();
     $select_pagination->htmlOptions['onchange'] = "";
     $select_pagination->setPages($pages);
     $select_pagination->init();
     $atts = Attachment::model()->findAll($criteria);
     $this->renderPartial($partial_tpl, array('return_id' => $return_id, 'atts' => $atts, 'rtype' => $rtype, 'pagination' => $pagination, 'select_pagination' => $select_pagination), false, true);
 }
Exemple #27
0
 public function actionGetlogisticslist()
 {
     $organID = Commonmodel::getOrganID();
     //获取机构ID
     $criteria = new CDbCriteria();
     $criteria->select = "*";
     $criteria->order = "id DESC";
     $criteria->addCondition("OrganID=" . $organID);
     //查询条件:根据机构ID查询物流数据
     $count = Logistics::model()->count($criteria);
     $pages = new CPagination($count);
     $pages->applyLimit($criteria);
     $modeles = Logistics::model()->findAll($criteria);
     foreach ($modeles as $key => $value) {
         $data[$key]['ID'] = $value['ID'];
         $data[$key]['OrganID'] = $value['OrganID'];
         $data[$key]['Company'] = F::msubstr($value['LogisticsCompany']);
         $data[$key]['Description'] = F::msubstr($value['LogisticsDescription']);
         $data[$key]['LogisticsCompany'] = $value['LogisticsCompany'];
         $data[$key]['LogisticsDescription'] = $value['LogisticsDescription'];
         $data[$key]['CreateTime'] = date("Y-m-d H:i:s", $value['CreateTime']);
         $data[$key]['UpdateTime'] = $value['UpdateTime'];
         $data[$key]['Status'] = $value['Status'];
         $address = $this->getAddress($value['ID']);
         $data[$key]['Address'] = $address ? F::msubstr(substr($address, 0, -3)) : '';
         $data[$key]['AddressDetail'] = $address ? substr($address, 0, -3) : '';
         //$data[$key]['Address'] = Area::getCity($address['Province']) . Area::getCity($address['City']) . Area::getCity($address['Area']);
     }
     $rs = array('total' => $count, 'rows' => $data ? $data : array());
     //        var_dump($rs);exit;
     echo json_encode($rs);
 }
 public function actionIndex()
 {
     $id = $_REQUEST['category_id'];
     $price = $_REQUEST['price'];
     $category = Category::model()->findByPk($id);
     if ($id) {
         $catmodel = new Category();
         $ids = $catmodel->getMeChildsId($id);
         $cid = implode(',', $ids);
         $condition = $id ? 'is_show = 1 and category_id in (' . $cid . ')' : 'is_show = 1';
     }
     if ($price) {
         if ($price && $id) {
             $catmodel = new Category();
             $ids = $catmodel->getMeChildsId($id);
             $cid = implode(',', $ids);
             $condition = $id ? 'is_show = 1 and  shop_price=' . $price . ' and category_id in (' . $cid . ')' : 'is_show = 1';
         }
     }
     $keyword = $_REQUEST['keyword'];
     if ($keyword) {
         $condition = $keyword ? 'is_show = 1 and title like' . "'%{$keyword}%'" . 'or sn like' . "'%{$keyword}%'" : 'is_show = 1';
     }
     $criteria = new CDbCriteria(array('condition' => $condition, 'order' => 'sort_order asc, item_id desc'));
     $count = Item::model()->count($criteria);
     $pages = new CPagination($count);
     // results per page
     $pages->pageSize = 20;
     $pages->applyLimit($criteria);
     $items = Item::model()->findAll($criteria);
     $this->render('index', array('items' => $items, 'pages' => $pages, 'keyword' => $keyword, 'category' => $category));
 }
Exemple #29
0
 public function actionList()
 {
     $page = isset($_GET['page']) ? intval($_GET['page']) : 1;
     $list = array();
     $criteria = new CDbCriteria();
     $criteria->select = 'sid,name';
     $criteria->order = 'sid ASC';
     $request = Yii::app()->getRequest();
     $id = trim($request->getParam("id"));
     if ($id) {
         $criteria->addCondition("sid = {$id}");
     }
     $sites = new Site();
     $count = $sites->count($criteria);
     $pager = new CPagination($count);
     $pager->pageSize = Yii::app()->params['postsPerPage'];
     $pager->setCurrentPage($page - 1);
     $pager->applyLimit($criteria);
     $list = $sites->findAll($criteria);
     $res = new Seo();
     $seo = array();
     foreach ($list as $key => $site) {
         $row = $res->find('sid=:sid', array(':sid' => $site->sid));
         $seo[$key] = $row;
     }
     $this->render('list', array('r' => Yii::app()->request->baseUrl . '/', 'pages' => $pager, 'list' => $list, 'seo' => $seo));
 }
Exemple #30
0
 public function actionIndex()
 {
     $this->pageTitle = 'Управление переводом';
     $criteria = new CDbCriteria();
     $criteria->with = array();
     $criteria->order = 't.created_at DESC';
     $filter = array();
     $checkBoxDefaultOn = TRUE;
     $count = Translate::model()->count($criteria);
     $pages = new CPagination($count);
     $pages->pageSize = TRANSLATES_PER_PAGE;
     $pages->applyLimit($criteria);
     $translates = Translate::model()->findAll($criteria);
     $langs = Langs::model()->findAll();
     $translatesLang = array();
     foreach ($translates as $translate) {
         $translatesLang[$translate->id] = array();
         foreach ($translate->langs as $translateLang) {
             foreach ($langs as $lang) {
                 if (!array_key_exists($lang->alias, $translatesLang[$translate->id])) {
                     $translatesLang[$translate->id][$lang->alias] = '';
                 }
                 if ($translateLang->lang == $lang->alias) {
                     $translatesLang[$translate->id][$lang->alias] = $translateLang->translate;
                 }
             }
         }
     }
     $model = new Translate();
     $modelLang = new TranslateLang();
     $this->include_jquery_form();
     CHtml::asset(Yii::getPathOfAlias('application.modules.admin.modules.translate.css'));
     $this->render('index', array('translates' => $translates, 'pages' => $pages, 'model' => $model, 'modelLang' => $modelLang, 'langs' => $langs, 'translatesLang' => $translatesLang, 'filter' => $filter, 'checkBoxDefaultOn' => $checkBoxDefaultOn));
 }