Ejemplo n.º 1
0
 public function view_index()
 {
     $carrierManage = new CarrierManageAct();
     $this->smarty->assign('title', '运输方式管理');
     //接收参数生成条件
     $curpage = isset($_GET['page']) ? abs(intval($_GET['page'])) : 1;
     $type = isset($_GET['type']) ? trim($_GET['type']) : '';
     $key = isset($_GET['key']) ? post_check(trim($_GET['key'])) : '';
     $condition = "1";
     if ($type && $key) {
         if (!in_array($type, array('carrierNameEn', 'carrierNameCn'))) {
             redirect_to("index.php?mod=carrierManage&act=index");
         }
         $condition .= ' AND ' . $type . " = '" . $key . "'";
     }
     //获取符合条件的数据并分页
     $pagenum = 20;
     //每页显示的个数
     $res = $carrierManage->actList($condition, $curpage, $pagenum);
     $total = $carrierManage->actListCount($condition);
     //页面总数量
     $page = new Page($total, $pagenum, '', 'CN');
     $pageStr = "";
     if ($res) {
         if ($total > $pagenum) {
             $pageStr = $page->fpage(array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9));
         } else {
             $pageStr = $page->fpage(array(0, 1, 2, 3));
         }
     } else {
         $pageStr = '暂无数据';
     }
     //替换页面内容变量
     $this->smarty->assign('key', $key);
     //关键词
     $this->smarty->assign('type', $type);
     //循环赋值
     $this->smarty->assign('lists', $res);
     //循环赋值
     $this->smarty->assign('pageStr', $pageStr);
     //分页输出
     $this->smarty->display('carrierManage.htm');
 }