Exemple #1
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 #2
0
 public function actionList()
 {
     $page = isset($_GET['page']) ? intval($_GET['page']) : 1;
     $list = array();
     $criteria = new CDbCriteria(array('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);
     $mynum = $mynum2 = array();
     $rnum = new Rnum();
     foreach ($list as $key => $site) {
         $row = $rnum->find('sname=:sname', array(':sname' => $site->name));
         $mynum[$key] = $row->onum;
         $mynum2[$key] = $row->cnum;
     }
     $this->render('list', array('r' => Yii::app()->request->baseUrl . '/', 'pages' => $pager, 'list' => $list, 'mynum' => $mynum, 'mynum2' => $mynum2));
 }
Exemple #3
0
 /**
  * 获取所有统计记录
  */
 public function getList($param, $page = -1, $pageSize = 15)
 {
     $ids = array();
     $pages = null;
     $criteria = new CDbCriteria();
     if (!empty($param['username'])) {
         $userbehavior = new UserBehavior();
         $username = $userbehavior->getUserByLoginName($param['username']);
         if (!empty($username)) {
             foreach ($username as $key => $user) {
                 $ids[] = $user['id'];
             }
         }
         $criteria->addInCondition("user_id", $ids);
     }
     $criteria->order = "ctime DESC";
     $criteria->addColumnCondition(array('is_deleted' => 0));
     if (!empty($param['page'])) {
         $page = $param['page'];
     }
     $count = Stats::model()->count($criteria);
     $pages = new CPagination($count);
     $pages->setCurrentPage(0);
     $pages->pageSize = $pageSize;
     $pages->applyLimit($criteria);
     $stats = Stats::model()->findAll($criteria);
     foreach ($stats as $key => $stat) {
         $userbehavior = new UserBehavior();
         $username = $userbehavior->getUserById($stat['user_id']);
         $result[$key]['user'] = $username;
         $result[$key]['stat'] = $stat;
     }
     return compact('pages', 'result');
 }
Exemple #4
0
 public function actionList()
 {
     $page = isset($_GET['page']) ? intval($_GET['page']) : 1;
     $list = array();
     $criteria = new CDbCriteria(array('order' => 'id ASC'));
     $types = new Type();
     $count = $types->count($criteria);
     $pager = new CPagination($count);
     $pager->pageSize = Yii::app()->params['postsPerPage'];
     $pager->setCurrentPage($page - 1);
     $pager->applyLimit($criteria);
     $list = $types->findAll($criteria);
     $this->render('list', array('r' => Yii::app()->request->baseUrl . '/', 'pages' => $pager, 'list' => $list));
 }
 /**
  * Shows a particular model.
  */
 public function actionShow()
 {
     $model = $this->loadPageSlug();
     $this->pageTitle = $model->title;
     if (isset($_GET['page'])) {
         $section = $_GET['page'];
     } else {
         $section = 1;
     }
     $leaves = array();
     $leaves = explode('<!--leaf-->', $model->content);
     $sections = new CPagination(sizeof($leaves));
     $sections->pageSize = 1;
     $sections->applyLimit($criteria = new CDbCriteria());
     $sections->setCurrentPage($section - 1);
     $this->render('show', array('model' => $model, 'pages' => $sections));
 }
 public function actionList()
 {
     $page = isset($_GET['page']) ? intval($_GET['page']) : 1;
     $list = array();
     $criteria = new CDbCriteria(array('order' => 'id ASC'));
     $request = Yii::app()->getRequest();
     $id = trim($request->getParam("id"));
     if ($id) {
         $criteria->addCondition("id = {$id}");
     }
     $domains = new Domain();
     $count = $domains->count($criteria);
     $pager = new CPagination($count);
     $pager->pageSize = Yii::app()->params['postsPerPage'];
     $pager->setCurrentPage($page - 1);
     $pager->applyLimit($criteria);
     $list = $domains->findAll($criteria);
     $this->render('list', array('r' => Yii::app()->request->baseUrl . '/', 'pages' => $pager, 'list' => $list));
 }
 /**
  * Displayes the authitem manage page
  */
 public function actionManage()
 {
     $this->processAdminCommand();
     $page = Yii::app()->getRequest()->getParam("page", "");
     if (Yii::app()->request->isAjaxRequest || $page != "") {
         $selectedType = Yii::app()->request->getParam('selectedType', Yii::app()->user->getState("selectedType"));
     } else {
         $selectedType = "";
     }
     Yii::app()->user->setState("selectedType", $selectedType);
     $criteria = new CDbCriteria();
     if ($selectedType != "") {
         $criteria->condition = "type = " . $selectedType;
     }
     if (!Yii::app()->request->isAjaxRequest) {
         Yii::app()->user->setState("currentPage", Yii::app()->request->getParam('page', 0) - 1);
     }
     $pages = new CPagination(AuthItem::model()->count($criteria));
     $pages->route = "manage";
     $pages->pageSize = $this->module->pageSize;
     $pages->applyLimit($criteria);
     $pages->setCurrentPage(Yii::app()->user->getState('currentPage'));
     $sort = new CSort('AuthItem');
     $sort->applyOrder($criteria);
     $models = AuthItem::model()->findAll($criteria);
     $full = Yii::app()->request->getParam("full");
     if (Yii::app()->request->isAjaxRequest && !$full) {
         $this->renderPartial('manage/list', array('models' => $models, 'pages' => $pages, 'sort' => $sort, 'full' => $full), false, true);
     } else {
         if (Yii::app()->request->isAjaxRequest && $full) {
             $this->renderPartial('manage/manage', array('models' => $models, 'pages' => $pages, 'sort' => $sort, 'full' => $full), false, true);
         } else {
             $this->render('manage/manage', array('models' => $models, 'pages' => $pages, 'sort' => $sort, 'full' => $full));
         }
     }
 }
Exemple #8
0
 public function managers($filter = array())
 {
     $result = array();
     $managers = array();
     $criteria = new CDbCriteria();
     $criteria->addColumnCondition(array('is_deleted' => 0));
     $count = $this->count($criteria);
     $pages = new CPagination($count);
     $pages->pageSize = 20;
     if (!empty($filter['pageSzie'])) {
         $pages->pageSize = $filter['pageSzie'];
     }
     if (!empty($filter['current_page'])) {
         $pages->setCurrentPage($filter['current_page']);
     }
     $pages->applyLimit($criteria);
     $objects = $this->findAll($criteria);
     if (!empty($objects)) {
         foreach ($objects as $obj) {
             $item = $obj->attributes;
             if (!empty($item['sp'])) {
                 $item['sp'] = CJSON::decode($item['sp']);
             }
             $managers[] = $item;
         }
     }
     $result = array('managers' => $managers, 'pages' => $pages);
     return $result;
 }
 /**
  * Search goods
  */
 public function actionSearch()
 {
     if (!isset($_POST['feature'])) {
         echo 'Категория пуста';
         return;
     }
     //print_r($_POST);
     $catId = $_POST['category_id'];
     if (isset($_POST['brand'])) {
         foreach ($_POST['brand'] as $key => $value) {
             $brands[] = $key;
         }
     }
     $price = $_POST['price'];
     $res = array();
     $first_step = true;
     foreach ($_POST['feature'] as $featureId => $feature) {
         if (!empty($feature) || $feature == '0') {
             $attr = Attr::model()->cache(3600)->findByPk($featureId);
             if ($attr->type == '2' && $feature == '2') {
                 continue;
             }
             if ($attr->type == '3' && empty($feature['min']) && empty($feature['max'])) {
                 continue;
             }
             $criteria = new CDbCriteria();
             $criteria->compare('category_id', $catId, false);
             if (!empty($brands)) {
                 $criteria->compare('brand_id', $brands, false);
             }
             if (!empty($price) && !empty($price['min'])) {
                 $criteria->condition .= ' AND price >= ' . $price["min"];
             }
             if (!empty($price) && !empty($price['max'])) {
                 $criteria->condition .= ' AND price <= ' . $price["max"];
             }
             $criteria->join = 'left join good_attr_val v ON v.good_id=t.id';
             if ($attr->type == '1') {
                 $values = array();
                 foreach ($feature as $key => $value) {
                     if ($value == '1') {
                         $values[] = $key;
                     }
                 }
                 $criteria->compare('v.attr_value_id', $values);
             }
             if ($attr->type == '2') {
                 $criteria->condition .= ' AND v.value=' . $feature . ' and v.attr_id=' . $attr->id;
             }
             if ($attr->type == '3') {
                 if (!empty($feature['min']) && !empty($feature['max'])) {
                     $criteria->condition .= ' AND v.value>=' . $feature['min'] . ' AND v.value<=' . $feature['max'] . ' AND v.attr_id =' . $attr->id;
                 } elseif (!empty($feature['min']) && empty($feature['max'])) {
                     $criteria->condition .= ' AND v.value>=' . $feature['min'] . ' AND v.attr_id =' . $attr->id;
                 } elseif (empty($feature['min']) && !empty($feature['max'])) {
                     $criteria->condition .= ' AND v.value<=' . $feature['max'] . ' AND v.attr_id =' . $attr->id;
                 }
             }
             $goods = Good::model()->with(array('goodImages'))->findAll($criteria);
             $good_ids = array();
             foreach ($goods as $good) {
                 $good_ids[] = $good->id;
             }
             //echo 'id=' . $featureId . '<br>';
             if (empty($res) && $first_step) {
                 //print_r($good_ids);echo '<br>';
                 $res = $good_ids;
                 if (empty($res) && !$first_step) {
                     echo 'Ничего не найдено по этим критериям';
                     return;
                 }
                 $first_step = FALSE;
                 continue;
             }
             if (empty($good_ids)) {
                 echo 'Ничего не найдено по этим критериям';
                 return;
             }
             foreach ($res as $good_id) {
                 if (!in_array($good_id, $good_ids)) {
                     unset($res[array_search($good_id, $res)]);
                 }
             }
         }
     }
     if ($first_step) {
         $criteria = new CDbCriteria();
         $criteria->compare('category_id', $catId, false);
         if (!empty($brands)) {
             $criteria->compare('brand_id', $brands, false);
         }
         if (!empty($price) && !empty($price['min'])) {
             $criteria->condition .= ' AND price >= ' . $price["min"];
         }
         if (!empty($price) && !empty($price['max'])) {
             $criteria->condition .= ' AND price <= ' . $price["max"];
         }
         if (!empty($_POST['order'])) {
             $criteria->order = $_POST['order'] . ' ';
         }
         $count = Good::model()->count($criteria);
         $pages = new CPagination($count);
         $pages->pageSize = 10;
         $pages->setCurrentPage($_POST['page']);
         $pages->applyLimit($criteria);
         $goods = Good::model()->with(array('goodImages'))->findAll($criteria);
     } else {
         if (count($res) == 0) {
             echo 'Ничего не найдено по этим критериям';
             return;
         }
         $new_res = array();
         foreach ($res as $value) {
             $new_res[] = $value;
         }
         $count = count($new_res);
         $criteria = new CDbCriteria();
         $pages = new CPagination($count);
         $pages->pageSize = 10;
         $pages->setCurrentPage($_POST['page']);
         $pages->applyLimit($criteria);
         $criteria->compare('id', $new_res);
         if (!empty($_POST['order'])) {
             $criteria->order = $_POST['order'] . ' ';
         }
         $goods = Good::model()->with(array('goodImages'))->findAll($criteria);
     }
     $this->renderPartial('search-result', array('goods' => $goods, 'pages' => $pages, 'count' => $count));
 }
 public function actionCreatePager($total, $noLink, $page)
 {
     $pages = new CPagination($total);
     $pages->setPageSize($noLink);
     $pages->setCurrentPage($page - 1);
     ob_start();
     $this->widget('CLinkPager', array('header' => '', 'firstPageLabel' => ' First &lt;&lt;', 'prevPageLabel' => '&lt; Previous', 'nextPageLabel' => 'Next &gt;', 'lastPageLabel' => ' Last &lt;&lt;', 'pages' => $pages, 'htmlOptions' => array('class' => 'pagination')));
     $str = ob_get_clean();
     return $str;
 }
Exemple #11
0
 public static function setPages($content, $pageSize, $page)
 {
     $contentLength = strlen($content);
     $pageCount = ceil($contentLength / $pageSize);
     $pages = new CPagination($pageCount);
     $pages->setPageSize($pageSize);
     $pages->setCurrentPage(0);
     $data = array();
     for ($i = 0; $i < $pageCount; $i++) {
         $data[$i] = substr($content, $i * $pageSize, ($i + 1) * $pageSize);
     }
     return array("data" => $data[$page - 1], "pages" => $pages);
 }
Exemple #12
0
 public function actionImportoutexcel()
 {
     $objectPHPExcel = new PHPExcel();
     $objectPHPExcel->setActiveSheetIndex(0);
     //当期查询出的数据
     //$page = isset($_GET['User_page']) ? intval($_GET['User_page']) : 1;
     $page = Yii::app()->session['page'];
     $user = Yii::app()->session['user'];
     $username = isset($user['username']) ? trim($user['username']) : null;
     $email = isset($user['email']) ? trim($user['email']) : null;
     $identity = isset($user['identity']) ? $user['identity'] : null;
     $phone = isset($user['phone']) ? trim($user['phone']) : null;
     $freeze = isset($user['freeze']) ? trim($user['freeze']) : null;
     $state = isset($user['Province']) ? trim($user['Province']) : null;
     $city = isset($user['City']) ? trim($user['City']) : null;
     $district = isset($user['Area']) ? trim($user['Area']) : null;
     $page_size = 10;
     $sql = "select a.username,a.email,a.identity,a.create_at,b.truename,\n    \t\t  b.phone,b.usertype,b.freeze\n    \t\t from tbl_user a,tbl_profiles b where b.user_id=a.id and b.Status=0 and b.isblack=0";
     if ($username) {
         $sql .= " and a.username like '%{$username}%'";
     }
     if ($email) {
         $sql .= " and a.email like '%{$email}%'";
     }
     if ($identity) {
         $sql .= " and a.identity='{$identity}'";
     }
     if ($phone) {
         $sql .= " and b.phone like '%{$phone}%'";
     }
     if ($freeze) {
         $sql .= " and b.freeze ='{$freeze}'";
     }
     if ($state) {
         $sql .= " and b.state='{$state}' and b.city='{$city}' and b.district='{$district}' ";
     }
     $sql .= " order by create_at desc";
     $model = Yii::app()->db->CreateCommand($sql)->queryAll();
     $count = count($model);
     $pages = new CPagination(count($model));
     $pages->pageSize = 10;
     $pages->setCurrentPage($page - 1);
     //$pages->applylimit($criteria);
     $model = Yii::app()->db->createCommand($sql . " LIMIT :offset,:limit");
     $model->bindValue(':offset', $pages->currentPage * $pages->pageSize);
     $model->bindValue(':limit', $pages->pageSize);
     $model = $model->queryAll();
     $page_count = (int) ($count / $page_size) + 1;
     $n = 0;
     foreach ($model as $list) {
         if ($n % $page_size === 0) {
             //报表头的输出
             $objectPHPExcel->getActiveSheet()->mergeCells('B1:G1');
             $objectPHPExcel->getActiveSheet()->setCellValue('B1', '会员信息表');
             $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('B2', '会员信息表');
             $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('B2', '会员信息表');
             $objectPHPExcel->setActiveSheetIndex(0)->getStyle('B1')->getFont()->setSize(24);
             $objectPHPExcel->setActiveSheetIndex(0)->getStyle('B1')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
             $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('B2', '日期:' . date("Y年m月j日"));
             $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('E2', '第' . $page . '/' . $page_count . '页');
             $objectPHPExcel->setActiveSheetIndex(0)->getStyle('E2')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
             //表格头的输出
             $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('B3', '用户名称');
             $objectPHPExcel->getActiveSheet()->getColumnDimension('B')->setWidth(22);
             $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('C3', '创建时间');
             $objectPHPExcel->getActiveSheet()->getColumnDimension('C')->setWidth(22);
             $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('D3', '邮箱');
             $objectPHPExcel->getActiveSheet()->getColumnDimension('D')->setWidth(22);
             $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('E3', '机构');
             $objectPHPExcel->getActiveSheet()->getColumnDimension('E')->setWidth(22);
             $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('F3', '真实姓名');
             $objectPHPExcel->getActiveSheet()->getColumnDimension('F')->setWidth(22);
             $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('G3', '会员类型');
             $objectPHPExcel->getActiveSheet()->getColumnDimension('G')->setWidth(22);
             $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('H3', '手机号');
             $objectPHPExcel->getActiveSheet()->getColumnDimension('H')->setWidth(22);
             $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('I3', '是否冻结');
             $objectPHPExcel->getActiveSheet()->getColumnDimension('I')->setWidth(22);
             $objectPHPExcel->getActiveSheet()->getRowDimension('1')->setRowHeight(32);
             //设置居中
             $objectPHPExcel->getActiveSheet()->getStyle('B3:I3')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
             //设置边框
             $objectPHPExcel->getActiveSheet()->getStyle('B3:I3')->getBorders()->getTop()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
             $objectPHPExcel->getActiveSheet()->getStyle('B3:I3')->getBorders()->getLeft()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
             $objectPHPExcel->getActiveSheet()->getStyle('B3:I3')->getBorders()->getRight()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
             $objectPHPExcel->getActiveSheet()->getStyle('B3:I3')->getBorders()->getBottom()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
             $objectPHPExcel->getActiveSheet()->getStyle('B3:I3')->getBorders()->getVertical()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
             $objectPHPExcel->getActiveSheet()->getStyle('B3:I3')->getBorders()->getVertical()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
             $objectPHPExcel->getActiveSheet()->getStyle('B3:I3')->getBorders()->getVertical()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
             $objectPHPExcel->getActiveSheet()->getStyle('B3:I3')->getBorders()->getVertical()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
             $objectPHPExcel->getActiveSheet()->getStyle('B3:I3')->getBorders()->getVertical()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
             $objectPHPExcel->getActiveSheet()->getStyle('B3:I3')->getBorders()->getVertical()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
             //设置颜色
             $objectPHPExcel->getActiveSheet()->getStyle('B3:I3')->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID)->getStartColor()->setARGB('FF66CCCC');
         }
         //明细的输出
         $objectPHPExcel->getActiveSheet()->setCellValue('B' . ($n + 4), $list['username']);
         $objectPHPExcel->getActiveSheet()->setCellValue('C' . ($n + 4), $list['create_at']);
         $objectPHPExcel->getActiveSheet()->setCellValue('D' . ($n + 4), $list['email']);
         switch ($list['identity']) {
             case 1:
                 $objectPHPExcel->getActiveSheet()->setCellValue('E' . ($n + 4), '生产商');
                 break;
             case 2:
                 $objectPHPExcel->getActiveSheet()->setCellValue('E' . ($n + 4), '经销商');
                 break;
             case 3:
                 $objectPHPExcel->getActiveSheet()->setCellValue('E' . ($n + 4), '修理厂');
                 break;
         }
         $objectPHPExcel->getActiveSheet()->setCellValue('F' . ($n + 4), $list['truename']);
         switch ($list['usertype']) {
             case 0:
                 $objectPHPExcel->getActiveSheet()->setCellValue('G' . ($n + 4), '非会员');
                 break;
             case 1:
                 $objectPHPExcel->getActiveSheet()->setCellValue('G' . ($n + 4), '试用会员');
                 break;
             case 2:
                 $objectPHPExcel->getActiveSheet()->setCellValue('G' . ($n + 4), '正式会员');
                 break;
         }
         $objectPHPExcel->getActiveSheet()->setCellValue('H' . ($n + 4), $list['phone']);
         switch ($list['freeze']) {
             case 0:
                 $objectPHPExcel->getActiveSheet()->setCellValue('I' . ($n + 4), '未冻结');
                 break;
             case 1:
                 $objectPHPExcel->getActiveSheet()->setCellValue('I' . ($n + 4), '已冻结');
                 break;
         }
         //设置边框
         $currentRowNum = $n + 4;
         $objectPHPExcel->getActiveSheet()->getStyle('B' . ($n + 4) . ':I' . $currentRowNum)->getBorders()->getTop()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
         $objectPHPExcel->getActiveSheet()->getStyle('B' . ($n + 4) . ':I' . $currentRowNum)->getBorders()->getLeft()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
         $objectPHPExcel->getActiveSheet()->getStyle('B' . ($n + 4) . ':I' . $currentRowNum)->getBorders()->getRight()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
         $objectPHPExcel->getActiveSheet()->getStyle('B' . ($n + 4) . ':I' . $currentRowNum)->getBorders()->getBottom()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
         $objectPHPExcel->getActiveSheet()->getStyle('B' . ($n + 4) . ':I' . $currentRowNum)->getBorders()->getVertical()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
         $n = $n + 1;
         //设置分页显示
         $objectPHPExcel->getActiveSheet()->setBreak('I55', PHPExcel_Worksheet::BREAK_ROW);
         $objectPHPExcel->getActiveSheet()->setBreak('I10', PHPExcel_Worksheet::BREAK_COLUMN);
         //$objectPHPExcel->getActiveSheet()->getPageSetup()->setHorizontalCentered(true);
         //$objectPHPExcel->getActiveSheet()->getPageSetup()->setVerticalCentered(false);
         ob_end_clean();
         ob_start();
     }
     header('Content-Type : application/vnd.ms-excel');
     header('Content-Disposition:attachment;filename="' . '会员信息表-' . date("Y-m-d") . '.xls"');
     $objWriter = PHPExcel_IOFactory::createWriter($objectPHPExcel, 'Excel5');
     $objWriter->save('php://output');
 }
 /**
  * @uses 根据参数查询图片信息。
  * 1:如果国家信息不为空,无城市参数,获取国家全部城市列表。
  * 2:如果国家信息为空,则以城市信息为准获取图片数据。
  * @link http://brs.baicheng.com/index.php?r=Api/Picture/picture
  * $json_params包含如下参数
  * country_id 国家id 【可选】 默认为:0 。
  * city_ids 城市id串 【可选】默认为空 例如:123,234,122。
  * cate_id 图片类型id 【可选】 默认为:0
  * page_size 分页大小 【可选】 默认为:20
  * page 页码 【可选】默认为:1
  * @return bool 返回数据,如果参数错误返回false,如果参数正确并获取到数据,则返回对应的json数据
  */
 public function ActionPicture()
 {
     $json_params = Yii::app()->request->getParam('json_params');
     if (!empty($json_params)) {
         $params_arr = json_decode($json_params, true);
         //大洲
         if (isset($params_arr['country_id']) && !empty($params_arr['country_id'])) {
             $country_id = $params_arr['country_id'];
         } else {
             $country_id = 0;
         }
         //城市
         if (isset($params_arr['city_ids']) && !empty($params_arr['city_ids'])) {
             $city_ids = $params_arr['city_ids'];
         } else {
             $city_ids = "";
         }
         //类型
         if (isset($params_arr['cate_id']) && !empty($params_arr['cate_id'])) {
             $cate_id = $params_arr['cate_id'];
         } else {
             $cate_id = 0;
         }
         //分页大小
         if (isset($params_arr['page_size']) && !empty($params_arr['page_size'])) {
             $page_size = $params_arr['page_size'];
         } else {
             $page_size = 20;
         }
         //页码
         if (isset($params_arr['page']) && !empty($params_arr['page'])) {
             $page = $params_arr['page'];
         } else {
             $page = 1;
         }
         if (empty($country_id) && empty($city_ids) || $page < 1 || $page_size < 1) {
             //参数错误
             return false;
         } else {
             if (!empty($country_id) && empty($city_ids)) {
                 //如果有国家id,无城市ids,将获取国家下的所有城市。
                 $country_cities = City::model()->findAllByAttributes(array('CountryID' => $country_id));
                 $country_cities_arr = array();
                 foreach ($country_cities as $cc) {
                     $country_cities_arr[] = $cc['ID'];
                 }
                 array_unique($country_cities_arr);
                 $city_ids = implode(",", $country_cities_arr);
                 //该国家所有的城市id串
             }
             $cities_arr = explode(",", $city_ids);
             //城市id串
             $pictures_arr = array();
             //返回的数组
             //分页获取图片信息
             $pic_condition = new CDbCriteria();
             $pic_condition->addInCondition('CityId', $cities_arr);
             $pic_condition->addColumnCondition(array('Valid' => 0));
             if (!empty($cate_id)) {
                 $pic_condition->addColumnCondition(array('CategoryId' => $cate_id));
             }
             $pic_condition->order = 'ID ASC';
             $count = Picture::model()->count($pic_condition);
             $pager = new CPagination($count);
             $pager->pageSize = $page_size;
             $pager->setCurrentPage($page - 1);
             $pager->applyLimit($pic_condition);
             $picture_list = Picture::model()->findAll($pic_condition);
             //返回数组中分页信息
             $pictures_arr['PageCount'] = $count;
             $pictures_arr['PageSize'] = $page_size;
             $pictures_arr['Page'] = $page;
             //封装返回数据
             foreach ($picture_list as $key => $val) {
                 $pictures_arr['PictureList'][$key]['ID'] = $val['ID'];
                 $pictures_arr['PictureList'][$key]['CityId'] = $val['CityId'];
                 $pictures_arr['PictureList'][$key]['CategoryId'] = $val['CategoryId'];
                 $pictures_arr['PictureList'][$key]['PictureCategoryName'] = $val->picture_category['PictureCategoryName'];
                 $pictures_arr['PictureList'][$key]['Name'] = $val['Name'];
                 $pictures_arr['PictureList'][$key]['Title'] = $val['Title'];
                 $pictures_arr['PictureList'][$key]['Description'] = $val['Description'];
                 foreach ($val->picture_source as $v) {
                     if ($v['SizeType'] == 0) {
                         $pictures_arr['PictureList'][$key]['PicSrcBig'] = str_replace("uploads/", "", $v['PicSrc']);
                     } elseif ($v['SizeType'] == 1) {
                         $pictures_arr['PictureList'][$key]['PicSrcMiddle'] = str_replace("uploads/", "", $v['PicSrc']);
                     } elseif ($v['SizeType'] == 2) {
                         $pictures_arr['PictureList'][$key]['PicSrcSmall'] = str_replace("uploads/", "", $v['PicSrc']);
                     }
                 }
             }
             if (!empty($pictures_arr)) {
                 //如果有查询数据则返回json格式数据
                 echo json_encode($pictures_arr);
             } else {
                 //无符合条件数据,则返回false
                 echo false;
             }
         }
     }
 }