/**
      +----------------------------------------------------------
 * 根据表单生成查询条件
 * 进行列表过滤
      +----------------------------------------------------------
 * @access protected
      +----------------------------------------------------------
 * @param Model $model 数据对象
 * @param HashMap $map 过滤条件
 * @param string $sortBy 排序
 * @param boolean $asc 是否正序
      +----------------------------------------------------------
 * @return void
      +----------------------------------------------------------
 * @throws ThinkExecption
      +----------------------------------------------------------
 */
 protected function _list($model, $map, $sortBy = '', $asc = false)
 {
     //排序字段 默认为主键名
     if (isset($_REQUEST['_order'])) {
         $order = $_REQUEST['_order'];
     } else {
         $order = !empty($sortBy) ? $sortBy : $model->getPk();
     }
     //排序方式默认按照倒序排列
     //接受 sost参数 0 表示倒序 非0都 表示正序
     if (isset($_REQUEST['_sort'])) {
         $sort = $_REQUEST['_sort'] ? 'asc' : 'desc';
     } else {
         $sort = $asc ? 'asc' : 'desc';
     }
     //取得满足条件的记录数
     $count = $model->where($map)->count('id');
     if ($count > 0) {
         //创建分页对象
         if (!empty($_REQUEST['listRows'])) {
             $listRows = $_REQUEST['listRows'];
         } else {
             $listRows = '';
         }
         $p = new Page($count, $listRows);
         //分页查询数据
         $voList = $model->where($map)->order("`" . $order . "` " . $sort)->limit($p->firstRow . ',' . $p->listRows)->findAll();
         //			echo $model->getlastsql();
         //分页跳转的时候保证查询条件
         foreach ($map as $key => $val) {
             if (!is_array($val)) {
                 $p->parameter .= "{$key}=" . urlencode($val) . "&";
             }
         }
         //分页显示
         $page = $p->show();
         //列表排序显示
         $sortImg = $sort;
         //排序图标
         $sortAlt = $sort == 'desc' ? l("ASC_SORT") : l("DESC_SORT");
         //排序提示
         $sort = $sort == 'desc' ? 1 : 0;
         //排序方式
         //模板赋值显示
         $this->assign('list', $voList);
         $this->assign('sort', $sort);
         $this->assign('order', $order);
         $this->assign('sortImg', $sortImg);
         $this->assign('sortType', $sortAlt);
         $this->assign("page", $page);
         $this->assign("nowPage", $p->nowPage);
     }
     return;
 }
Beispiel #2
0
 /**
 +----------------------------------------------------------
 * 根据表单生成查询条件
 * 进行列表过滤
 +----------------------------------------------------------
 * @access protected
 +----------------------------------------------------------
 * @param Model $model 数据对象
 * @param HashMap $map 过滤条件
 * @param string $sortBy 排序
 * @param boolean $asc 是否正序
 +----------------------------------------------------------
 * @return void
 +----------------------------------------------------------
 * @throws ThinkExecption
 +----------------------------------------------------------
 */
 protected function _list($model, $map, $sortBy = '', $asc = false)
 {
     //排序字段 默认为主键名
     if (isset($_REQUEST['_order'])) {
         $order = $_REQUEST['_order'];
     } else {
         $order = !empty($sortBy) ? $sortBy : $model->getPk();
     }
     //取得满足条件的记录数
     $count = $model->where($map)->count('id');
     if ($count > 0) {
         import("ORG.Util.Page");
         //创建分页对象
         if (!empty($_REQUEST['listRows'])) {
             $listRows = $_REQUEST['listRows'];
         } else {
             $listRows = '';
         }
         $p = new Page($count, $listRows);
         //分页查询数据
         $voList = $model->where($map)->order("" . $order . " desc")->limit($p->firstRow . ',' . $p->listRows)->select();
         //分页跳转的时候保证查询条件
         foreach ($map as $key => $val) {
             if (!is_array($val)) {
                 $p->parameter .= "{$key}=" . urlencode($val) . "&";
             }
         }
         //分页显示
         $page = $p->show();
         //列表排序显示
         $sortImg = $sort;
         //排序图标
         $sortAlt = $sort == 'desc' ? '升序排列' : '倒序排列';
         //排序提示
         //模板赋值显示
         $this->assign('list', $voList);
         $this->assign('order', $order);
         $this->assign('sortImg', $sortImg);
         $this->assign('sortType', $sortAlt);
         $this->assign("page", $page);
     }
     $MagazineType = M("MagazineType");
     $MagazineTypeList = $MagazineType->field('id, name')->select();
     $this->assign('MagazineTypeList', $MagazineTypeList);
     $this->assign('totalCount', $count);
     $this->assign('numPerPage', C('PAGE_LISTROWS'));
     $this->assign('currentPage', !empty($_REQUEST[C('VAR_PAGE')]) ? $_REQUEST[C('VAR_PAGE')] : 1);
     Cookie::set('_currentUrl_', __SELF__);
     return;
 }
Beispiel #3
0
 /**
      +----------------------------------------------------------
 * 根据表单生成查询条件
 * 进行列表过滤
      +----------------------------------------------------------
 * @access protected
      +----------------------------------------------------------
 * @param Model $model 数据对象
 * @param HashMap $map 过滤条件
 * @param string $sortBy 排序
 * @param boolean $asc 是否正序
      +----------------------------------------------------------
 * @return void
      +----------------------------------------------------------
 * @throws ThinkExecption
      +----------------------------------------------------------
 */
 protected function _list($model, $map, $sortBy = '', $asc = false)
 {
     //排序字段 默认为主键名
     if (isset($_REQUEST['_order'])) {
         $order = $_REQUEST['_order'];
     } else {
         $order = !empty($sortBy) ? $sortBy : $model->getPk();
     }
     //排序方式默认按照倒序排列
     //接受 sost参数 0 表示倒序 非0都 表示正序
     if (isset($_REQUEST['_sort'])) {
         $sort = $_REQUEST['_sort'] ? 'asc' : 'desc';
     } else {
         $sort = $asc ? 'asc' : 'desc';
     }
     //是否是支付列表
     $is_payment_list = 0;
     if (!empty($map['is_payment_list'])) {
         $is_payment_list = $map['is_payment_list'];
         unset($map['is_payment_list']);
     }
     if ($map['s_create_time'] && $map['e_create_time']) {
         $map['create_time'] = array('between', array($map['s_create_time'], $map['e_create_time']));
         unset($map['s_create_time']);
         unset($map['e_create_time']);
     }
     //取得满足条件的记录数
     $count = $model->where($map)->count('id');
     if ($count > 0) {
         //创建分页对象
         if (!empty($_REQUEST['listRows'])) {
             $listRows = $_REQUEST['listRows'];
         } else {
             $listRows = '';
         }
         $p = new Page($count, $listRows);
         //分页查询数据
         if (isset($_REQUEST['_order']) && $_REQUEST['_order'] == 'finished_order_count' || isset($_REQUEST['_order']) && $_REQUEST['_order'] == 'unfinished_order_count' || isset($_REQUEST['_order']) && $_REQUEST['_order'] == 'tech_count' || isset($_REQUEST['_order']) && $_REQUEST['_order'] == 'cost_amount' || isset($_REQUEST['_order']) && $_REQUEST['_order'] == 'comp_amount') {
             $order = !empty($sortBy) ? $sortBy : $model->getPk();
         }
         $voList = $model->where($map)->order("`" . $order . "` " . $sort)->limit($p->firstRow . ',' . $p->listRows)->findAll();
         if (!empty($is_payment_list)) {
             $should_pay_money = 0;
             $not_pay_money = 0;
             $paid_money = 0;
             foreach ($voList as $key => $val) {
                 if ($val['is_paid'] == 1) {
                     $paid_money += $val['money'];
                 } else {
                     $not_pay_money += $val['money'];
                 }
                 $should_pay_money += $val['money'];
             }
             $this->assign('should_pay_money', $should_pay_money);
             $this->assign('not_pay_money', $not_pay_money);
             $this->assign('paid_money', $paid_money);
         }
         //如果是会员列表
         if ($map[DB_PREFIX . 'user.service_type_id'] == 1) {
             foreach ($voList as $key => $value) {
                 //拼接地址
                 $province = M('RegionConf')->where(array('id' => $value['province_id']))->find();
                 $city = M('RegionConf')->where(array('id' => $value['city_id']))->find();
                 $addr = $province['name'] . ' ' . $city['name'] . ' ' . $value['addr_detail'];
                 $value['province_id'] = $addr;
                 //性别
                 if ($value['sex'] == 1) {
                     $value['sex'] = '男';
                 } elseif ($value['sex'] == 0) {
                     $value['sex'] = '女';
                 } else {
                     $value['sex'] = '保密';
                 }
                 //星级
                 $level = M('ServiceLevel')->where(array('id' => $value['service_level_id']))->find();
                 $value['service_level_id'] = $level['levelname'];
                 //已完成订单总消费
                 $finished[DB_PREFIX . 'deal_order.user_id'] = $value['id'];
                 $finished[DB_PREFIX . 'deal_order.order_status'] = 1;
                 $finished[DB_PREFIX . 'deal_order.extra_status'] = 0;
                 $finished[DB_PREFIX . 'deal_order.after_sale'] = 0;
                 $cost_amount = M('DealOrder')->where($finished)->sum('pay_amount');
                 $value['cost_amount'] = $cost_amount;
                 $comp_amount = M('Complain')->where(array('user_id' => $value['id']))->count('complain_id');
                 $value['comp_amount'] = $comp_amount;
                 $voList[$key] = $value;
             }
             if (isset($_REQUEST['_order']) && $_REQUEST['_order'] == 'cost_amount' && isset($_REQUEST['_sort']) && $_REQUEST['_sort'] == 1) {
                 $cost_amount_list = array();
                 foreach ($voList as $value) {
                     $cost_amount_list[] = $value['cost_amount'];
                 }
                 array_multisort($cost_amount_list, SORT_ASC, $voList);
             }
             if (isset($_REQUEST['_order']) && $_REQUEST['_order'] == 'cost_amount' && isset($_REQUEST['_sort']) && $_REQUEST['_sort'] == 0) {
                 $cost_amount_list = array();
                 foreach ($voList as $value) {
                     $cost_amount_list[] = $value['cost_amount'];
                 }
                 array_multisort($cost_amount_list, SORT_DESC, $voList);
             }
             if (isset($_REQUEST['_order']) && $_REQUEST['_order'] == 'comp_amount' && isset($_REQUEST['_sort']) && $_REQUEST['_sort'] == 1) {
                 $comp_amount_list = array();
                 foreach ($voList as $value) {
                     $comp_amount_list[] = $value['comp_amount'];
                 }
                 array_multisort($comp_amount_list, SORT_ASC, $voList);
             }
             if (isset($_REQUEST['_order']) && $_REQUEST['_order'] == 'comp_amount' && isset($_REQUEST['_sort']) && $_REQUEST['_sort'] == 0) {
                 $comp_amount_list = array();
                 foreach ($voList as $value) {
                     $comp_amount_list[] = $value['comp_amount'];
                 }
                 array_multisort($comp_amount_list, SORT_DESC, $voList);
             }
         }
         //如果是技师列表
         if ($map[DB_PREFIX . 'user.service_type_id'] == 2) {
             foreach ($voList as $key => $value) {
                 //拼接地址
                 $province = M('RegionConf')->where(array('id' => $value['province_id']))->find();
                 $city = M('RegionConf')->where(array('id' => $value['city_id']))->find();
                 $addr = $province['name'] . ' ' . $city['name'] . ' ' . $value['addr_detail'];
                 $value['province_id'] = $addr;
                 //性别
                 if ($value['sex'] == 1) {
                     $value['sex'] = '男';
                 } elseif ($value['sex'] == 0) {
                     $value['sex'] = '女';
                 } else {
                     $value['sex'] = '保密';
                 }
                 $level = M('ServiceLevel')->where(array('id' => $value['service_level_id']))->find();
                 $value['service_level_id'] = $level['levelname'];
                 //已完成
                 $finished[DB_PREFIX . 'deal_order.technician_id'] = $value['id'];
                 $finished[DB_PREFIX . 'deal_order.order_status'] = 1;
                 $finished_order_count = M('DealOrder')->where($finished)->count('id');
                 //未完成
                 $unfinished[DB_PREFIX . 'deal_order.technician_id'] = $value['id'];
                 $unfinished[DB_PREFIX . 'deal_order.order_status'] = 0;
                 $unfinished_order_count = M('DealOrder')->where($unfinished)->count('id');
                 $value['finished_order_count'] = $finished_order_count;
                 $value['unfinished_order_count'] = $unfinished_order_count;
                 $voList[$key] = $value;
             }
             if (isset($_REQUEST['_order']) && $_REQUEST['_order'] == 'finished_order_count' && isset($_REQUEST['_sort']) && $_REQUEST['_sort'] == 1) {
                 $finished_order_sort_list = array();
                 foreach ($voList as $value) {
                     $finished_order_sort_list[] = $value['finished_order_count'];
                 }
                 array_multisort($finished_order_sort_list, SORT_ASC, $voList);
             }
             if (isset($_REQUEST['_order']) && $_REQUEST['_order'] == 'finished_order_count' && isset($_REQUEST['_sort']) && $_REQUEST['_sort'] == 0) {
                 $finished_order_sort_list = array();
                 foreach ($voList as $value) {
                     $finished_order_sort_list[] = $value['finished_order_count'];
                 }
                 array_multisort($finished_order_sort_list, SORT_DESC, $voList);
             }
             if (isset($_REQUEST['_order']) && $_REQUEST['_order'] == 'unfinished_order_count' && isset($_REQUEST['_sort']) && $_REQUEST['_sort'] == 1) {
                 $unfinished_order_sort_list = array();
                 foreach ($voList as $value) {
                     $unfinished_order_sort_list[] = $value['unfinished_order_count'];
                 }
                 array_multisort($unfinished_order_sort_list, SORT_ASC, $voList);
             }
             if (isset($_REQUEST['_order']) && $_REQUEST['_order'] == 'unfinished_order_count' && isset($_REQUEST['_sort']) && $_REQUEST['_sort'] == 0) {
                 $unfinished_order_sort_list = array();
                 foreach ($voList as $value) {
                     $unfinished_order_sort_list[] = $value['unfinished_order_count'];
                 }
                 array_multisort($unfinished_order_sort_list, SORT_DESC, $voList);
             }
         }
         //如果是经理列表
         if ($map[DB_PREFIX . 'user.service_type_id'] == 3) {
             foreach ($voList as $key => $value) {
                 //拼接地址
                 $province = M('RegionConf')->where(array('id' => $value['province_id']))->find();
                 $city = M('RegionConf')->where(array('id' => $value['city_id']))->find();
                 $addr = $province['name'] . ' ' . $city['name'] . ' ' . $value['addr_detail'];
                 $value['province_id'] = $addr;
                 //性别
                 if ($value['sex'] == 1) {
                     $value['sex'] = '男';
                 } elseif ($value['sex'] == 0) {
                     $value['sex'] = '女';
                 } else {
                     $value['sex'] = '保密';
                 }
                 $level = M('ServiceLevel')->where(array('id' => $value['service_level_id']))->find();
                 $value['service_level_id'] = $level['levelname'];
                 $tech_count = M('User')->where(array('p_id' => $value['id']))->count('id');
                 $value['tech_count'] = $tech_count;
                 $voList[$key] = $value;
             }
             if (isset($_REQUEST['_order']) && $_REQUEST['_order'] == 'tech_count' && isset($_REQUEST['_sort']) && $_REQUEST['_sort'] == 1) {
                 $tech_count_sort_list = array();
                 foreach ($voList as $value) {
                     $tech_count_sort_list[] = $value['tech_count'];
                 }
                 array_multisort($tech_count_sort_list, SORT_ASC, $voList);
             }
             if (isset($_REQUEST['_order']) && $_REQUEST['_order'] == 'tech_count' && isset($_REQUEST['_sort']) && $_REQUEST['_sort'] == 0) {
                 $tech_count_sort_list = array();
                 foreach ($voList as $value) {
                     $tech_count_sort_list[] = $value['tech_count'];
                 }
                 array_multisort($tech_count_sort_list, SORT_DESC, $voList);
             }
         }
         //			echo $model->getlastsql();
         //分页跳转的时候保证查询条件
         foreach ($map as $key => $val) {
             if (!is_array($val)) {
                 $p->parameter .= "{$key}=" . urlencode($val) . "&";
             }
         }
         //分页显示
         $page = $p->show();
         //列表排序显示
         $sortImg = $sort;
         //排序图标
         $sortAlt = $sort == 'desc' ? l("ASC_SORT") : l("DESC_SORT");
         //排序提示
         $sort = $sort == 'desc' ? 1 : 0;
         //排序方式
         //模板赋值显示
         $this->assign('list', $voList);
         $this->assign('sort', $sort);
         $this->assign('order', $order);
         $this->assign('sortImg', $sortImg);
         $this->assign('sortType', $sortAlt);
         $this->assign("page", $page);
         $this->assign("nowPage", $p->nowPage);
     }
     return;
 }
Beispiel #4
0
 /**
 +----------------------------------------------------------
 * 根据表单生成查询条件
 * 进行列表过滤
 +----------------------------------------------------------
 * @access protected
 +----------------------------------------------------------
 * @param Model $model 数据对象
 * @param HashMap $map 过滤条件
 * @param string $sortBy 排序
 * @param boolean $asc 是否正序
 +----------------------------------------------------------
 * @return void
 +----------------------------------------------------------
 * @throws ThinkExecption
 +----------------------------------------------------------
 */
 protected function _list($model, $map, $sortBy = '', $asc = false)
 {
     //排序字段 默认为主键名
     if (isset($_REQUEST['_order'])) {
         $order = $_REQUEST['_order'];
     } else {
         $order = !empty($sortBy) ? $sortBy : $model->getPk();
     }
     //排序方式默认按照倒序排列
     //接受 sost参数 0 表示倒序 非0都 表示正序
     if (isset($_REQUEST['_sort'])) {
         $sort = $_REQUEST['_sort'] ? 'asc' : 'desc';
     } else {
         $sort = $asc ? 'asc' : 'desc';
     }
     //取得满足条件的记录数
     $count = $model->where($map)->count($model->pk);
     if ($count > 0) {
         import("@.ORG.Util.Page");
         //创建分页对象
         if (!empty($_REQUEST['listRows'])) {
             $listRows = $_REQUEST['listRows'];
         } else {
             $listRows = $this->get_list_rows();
         }
         $p = new Page($count, $listRows);
         //分页查询数据
         $voList = $model->where($map)->order("`" . $order . "` " . $sort)->limit($p->firstRow . ',' . $p->listRows)->select();
         $p->parameter = $this->_search;
         //分页显示
         $page = $p->show();
         //列表排序显示
         $sortImg = $sort;
         //排序图标
         $sortAlt = $sort == 'desc' ? '升序排列' : '倒序排列';
         //排序提示
         $sort = $sort == 'desc' ? 1 : 0;
         //排序方式
         //模板赋值显示
         $name = $this->getActionName();
         $this->assign('list', $voList);
         $this->assign('sort', $sort);
         $this->assign('order', $order);
         $this->assign('sortImg', $sortImg);
         $this->assign('sortType', $sortAlt);
         $this->assign("page", $page);
     }
     return;
 }
 /**
      +----------------------------------------------------------
 * 连接查询列表显示
 * 进行列表过滤
      +----------------------------------------------------------
 * @access protected
      +----------------------------------------------------------
 * @param Model $model 数据对象
 * @param HashMap $map 过滤条件
 * @param string $sortBy 排序
 * @param boolean $asc 是否正序
      +----------------------------------------------------------
 * @return void
      +----------------------------------------------------------
 * @throws ThinkExecption
      +----------------------------------------------------------
 */
 protected function _listLink($model, $map, $option = array(), $sortBy = '', $asc = false)
 {
     extract($option);
     $field || ($field = "*");
     $table || ($table = $model->getTableName());
     //$table = "{$this->trueTableName} j";
     //$r = $this->table($table)->field($field)->join($join)->where($map)->count();
     //dump($r);
     //return $r;
     //排序字段 默认为主键名
     if (isset($_REQUEST['_order'])) {
         $order = $_REQUEST['_order'];
     } else {
         $order = !empty($sortBy) ? $sortBy : $model->getPk();
     }
     //排序方式默认按照倒序排列
     //接受 sost参数 0 表示倒序 非0都 表示正序
     //$setOrder = setOrder(array(array('viewCount', 'a.view_count'), 'a.id'), $orderBy, $orderType, 'a');
     if (isset($_REQUEST['_sort'])) {
         $sort = $_REQUEST['_sort'] ? 'asc' : 'desc';
     } else {
         $sort = $asc ? 'asc' : 'desc';
     }
     //取得满足条件的记录数
     if ($sql) {
         $sqlCount = getCountSql($sql);
         //处理map查询条件
         $count = $db->query($sqlCount);
     } else {
         $pk = $model->getPk();
         $count = $model->table($table)->field($field)->join($join)->where($map)->count($pk);
     }
     if ($count > 0) {
         import("ORG.Util.XPage");
         //创建分页对象
         if (!empty($_REQUEST['listRows'])) {
             $listRows = $_REQUEST['listRows'];
         } else {
             $listRows = '';
         }
         $p = new XPage($count, $listRows);
         //echo C('PAGE_STYLE');exit;
         //$s =  rand(1,25);echo $s;
         $p->style = C('PAGE_STYLE');
         //设置风格
         //分页查询数据
         if ($sql) {
             //处理map查询条件
             $voList = $model->query(sql . "`" . $order . "` " . $sort . $p->firstRow . ',' . $p->listRows);
         } else {
             $voList = $model->table($table)->field($field)->join($join)->where($map)->order("`" . $order . "` " . $sort)->limit($p->firstRow . ',' . $p->listRows)->select();
         }
         //echo $model->getlastsql();
         //高亮关键字
         if (C('highLightKeyword') && $_REQUEST['keyword']) {
             $keyword = $_REQUEST['keyword'];
             foreach ($voList as $k => $v) {
                 $voList[$k]['jtitle'] = hightLightKeyword($v['jtitle'], $keyword);
                 $voList[$k]['request'] = hightLightKeyword($v['request'], $keyword);
                 $voList[$k]['ctitle'] = hightLightKeyword($v['ctitle'], $keyword);
             }
         }
         //分页跳转的时候保证查询条件
         foreach ($map as $key => $val) {
             if (!is_array($val)) {
                 $p->parameter .= "{$key}=" . urlencode($val) . "&";
             }
         }
         //分页显示
         $page = $p->show();
         //列表排序显示
         $sortImg = $sort;
         //排序图标
         $sortAlt = $sort == 'desc' ? '升序排列' : '倒序排列';
         //排序提示
         $sort = $sort == 'desc' ? 1 : 0;
         //排序方式
         //模板赋值显示
         $this->assign('list', $voList);
         $this->assign('sort', $sort);
         $this->assign('order', $order);
         $this->assign('sortImg', $sortImg);
         $this->assign('sortType', $sortAlt);
         $this->assign("page", $page);
     }
     Cookie::set('_currentUrl_', __SELF__);
     return;
 }
Beispiel #6
0
 /**
  +----------------------------------------------------------
 * 根据表单生成查询条件
 * 进行列表过滤
  +----------------------------------------------------------
 * @access protected
  +----------------------------------------------------------
 * @param Model $model 数据对象
 * @param HashMap $map 过滤条件
 * @param string $sortBy 排序
 * @param boolean $asc 是否正序
  +----------------------------------------------------------
 * @return void
  +----------------------------------------------------------
 * @throws ThinkExecption
  +----------------------------------------------------------
 */
 protected function _list($model, $map, $sortBy = '', $asc = false, $group = '')
 {
     //排序字段 默认为主键名
     if (isset($_REQUEST['_order'])) {
         $order = $_REQUEST['_order'];
     } else {
         $order = !empty($sortBy) ? $sortBy : $model->getPk();
     }
     //排序方式默认按照倒序排列
     //接受 sost参数 0 表示倒序 非0都 表示正序
     if (isset($_REQUEST['_sort'])) {
         $sort = $_REQUEST['_sort'] ? 'asc' : 'desc';
     } else {
         $sort = $asc ? 'asc' : 'desc';
     }
     //取得满足条件的记录数
     if (empty($group)) {
         $count = $model->where($map)->count('id');
     } else {
         $count = $model->where($map)->count('distinct ' . $group);
     }
     if ($count > 0) {
         import("@.ORG.Page");
         //创建分页对象
         if (!empty($_REQUEST['listRows'])) {
             $listRows = $_REQUEST['listRows'];
         } else {
             $listRows = '10';
         }
         $p = new Page($count, $listRows);
         //分页查询数据
         //			if(empty($group))
         //			{
         //				$voList = $model->where($map)->order("`" . $order . "` " . $sort)->limit($p->firstRow . ',' . $p->listRows)->findAll();
         //			}else {
         $voList = $model->where($map)->order($order . " " . $sort)->group($group)->limit($p->firstRow . ',' . $p->listRows)->findAll();
         //			}
         //分页跳转的时候保证查询条件
         foreach ($map as $key => $val) {
             if (!is_array($val)) {
                 $p->parameter .= "{$key}=" . urlencode($val) . "&";
             }
         }
         //分页显示
         $page = $p->show();
         //列表排序显示
         $sortImg = $sort;
         //排序图标
         $sortAlt = $sort == 'desc' ? '升序排列' : '倒序排列';
         //排序提示
         $sort = $sort == 'desc' ? 1 : 0;
         //排序方式
         //模板赋值显示
         $this->assign('list', $voList);
         $this->assign('sort', $sort);
         $this->assign('order', $order);
         $this->assign('sortImg', $sortImg);
         $this->assign('sortType', $sortAlt);
         $this->assign("page", $page);
     }
     $this->assign("count", $count);
     Cookie::set('_currentUrl_', __SELF__);
     return;
 }
  /**
    +----------------------------------------------------------
	* 根据表单生成查询条件
	* 进行列表过滤
    +----------------------------------------------------------
	* @access protected
    +----------------------------------------------------------
	* @param Model $model 数据对象
	* @param HashMap $map 过滤条件
	* @param string $sortBy 排序
	* @param boolean $asc 是否正序
    +----------------------------------------------------------
	* @return void
    +----------------------------------------------------------
	* @throws ThinkExecption
    +----------------------------------------------------------
	*/
  protected function _list($model, $map, $sortBy = '', $asc = false) {
	//排序字段 默认为主键名
	if (isset ( $_REQUEST ['_order'] )) {
		$order = $_REQUEST ['_order'];
	} else {
		$order = ! empty ( $sortBy ) ? $sortBy : $model->getPk ();
	}
	//排序方式默认按照倒序排列
	//接受 sost参数 0 表示倒序 非0都 表示正序
	if (isset ( $_REQUEST ['_sort'] )) {
		$sort = $_REQUEST ['_sort'] ? 'asc' : 'desc';
	} else {
		$sort = $asc ? 'asc' : 'desc';
	}
	//取得满足条件的记录数
	$count = $model->where ( $map )->count ();
	if (! empty ( $_REQUEST ['listRows'] )) {
		$listRows = $_REQUEST ['listRows'];
	} else {
		$page_size = C('page_size');
		$listRows = $page_size ? $page_size : 20;
	}
	$page_count = ceil($count/$listRows);
	$this->assign('count',$count);
	$this->assign('page_count',$page_count);
	if ($count > 0) {
		//import ( "@.ORG.Page1" );.
		//import("@.ORG.Util.Page");
		//创建分页对象
		$p = new \Page ( $count, $listRows );
		//分页查询数据

		$voList = $model->where($map)->order( "`" . $order . "` " . $sort)->limit($p->firstRow . ',' . $p->listRows)->select ( );
		//分页跳转的时候保证查询条件
		foreach ( $map as $key => $val ) {
			if (! is_array ( $val )) {
				$p->parameter .= "$key=" . urlencode ( $val ) . "&";
			}
		}
		//分页显示
		$page = $p->show ();
		//列表排序显示
		$sortImg = $sort; //排序图标
		$sortAlt = $sort == 'desc' ? '升序排列' : '倒序排列'; //排序提示
		$sort = $sort == 'desc' ? 1 : 0; //排序方式
		//模板赋值显示
		$this->assign ( 'list', $voList );
		$this->assign ( 'sort', $sort );
		$this->assign ( 'order', $order );
		$this->assign ( 'sortImg', $sortImg );
		$this->assign ( 'sortType', $sortAlt );
		$this->assign ( "page", $page );
	}
	Cookie( '_currentUrl_', __SELF__ );
	return;
  }
Beispiel #8
0
 /**
     +----------------------------------------------------------
 * 根据表单生成查询条件
 * 进行列表过滤
     +----------------------------------------------------------
 * @access protected
     +----------------------------------------------------------
 * @param Model $model 数据对象
 * @param HashMap $map 过滤条件
 * @param string $sortBy 排序
 * @param boolean $asc 是否正序
     +----------------------------------------------------------
 * @return void
     +----------------------------------------------------------
 * @throws ThinkExecption
     +----------------------------------------------------------
 */
 protected function _list($model, $map, $sortBy = '', $asc = false)
 {
     //排序字段 默认为主键名
     if (!empty($_REQUEST['_order'])) {
         $order = $_REQUEST['_order'];
     } else {
         $order = !empty($sortBy) ? $sortBy : $model->getPk();
     }
     //排序方式默认按照倒序排列
     //接受 sost参数 0 表示倒序 非0都 表示正序
     if (isset($_REQUEST['_sort'])) {
         $sort = $_REQUEST['_sort'] == 'asc' ? 'asc' : 'desc';
         //zhanghuihua@msn.com
     } else {
         $sort = $asc ? 'desc' : 'asc';
     }
     //取得满足条件的记录数
     $count = $model->where($map)->count('id');
     if ($count > 0) {
         //创建分页对象
         if (!empty($_REQUEST['numPerPage'])) {
             $listRows = $_REQUEST['numPerPage'];
         } else {
             $listRows = 10;
         }
         $p = new \Extcom\Lib\Page($count, $listRows);
         $p->setConfig('prev', '<span class="pageprev"></span>');
         $p->setConfig('next', '<span class="pagenext"></span>');
         //            $currentPage = $_REQUEST['pageNum'] ? $_REQUEST['pageNum'] : 1;
         $currentPage = isset($_REQUEST['p']) ? $_REQUEST['p'] : 1;
         $p->firstRow = ($currentPage - 1) * $listRows;
         //分页查询数据
         $voList = $model->where($map)->order("`" . $order . "` " . $sort)->limit($p->firstRow . ',' . $p->listRows)->select();
         //模板赋值显示
         $this->assign('list', $voList);
         if ($count > $listRows) {
             $this->assign('page', $p->show());
         }
         return $voList;
     }
     return;
 }
Beispiel #9
0
 /**
      +----------------------------------------------------------
 * 根据表单生成查询条件
 * 进行列表过滤
      +----------------------------------------------------------
 * @access protected
      +----------------------------------------------------------
 * @param Model $model 数据对象
 * @param HashMap $map 过滤条件
 * @param string $sortBy 排序
 * @param boolean $asc 是否正序
      +----------------------------------------------------------
 * @return void
      +----------------------------------------------------------
 * @throws ThinkExecption
      +----------------------------------------------------------
 */
 protected function _list($model, $map, $sortBy = '', $asc = false, $countPk = 'id')
 {
     //排序字段 默认为主键名
     if (!empty($_REQUEST['_order'])) {
         $order = $_REQUEST['_order'];
     } else {
         $order = !empty($sortBy) ? $sortBy : $model->getPk();
     }
     //排序方式默认按照倒序排列
     //接受 sost参数 0 表示倒序 非0都 表示正序
     if (isset($_REQUEST['_sort'])) {
         //			$sort = $_REQUEST ['_sort'] ? 'asc' : 'desc';
         $sort = $_REQUEST['_sort'] == 'asc' ? 'asc' : 'desc';
         //zhanghuihua@msn.com
     } else {
         $sort = $asc ? 'asc' : 'desc';
     }
     //取得满足条件的记录数
     $count = $model->where($map)->count($countPk);
     if ($count > 0) {
         import("@.ORG.Util.Page");
         //创建分页对象
         if (!empty($_REQUEST['listRows'])) {
             $listRows = $_REQUEST['listRows'];
         } else {
             $listRows = '';
         }
         $p = new Page($count, $listRows);
         //分页查询数据
         $voList = $model->where($map)->order("`" . $order . "` " . $sort)->limit($p->firstRow . ',' . $p->listRows)->select();
         //echo $model->getlastsql();
         //分页跳转的时候保证查询条件
         foreach ($map as $key => $val) {
             if (!is_array($val)) {
                 $p->parameter .= "{$key}=" . urlencode($val) . "&";
             }
         }
         //分页显示
         $page = $p->show();
         //列表排序显示
         $sortImg = $sort;
         //排序图标
         $sortAlt = $sort == 'desc' ? '升序排列' : '倒序排列';
         //排序提示
         $sort = $sort == 'desc' ? 1 : 0;
         //排序方式
         //模板赋值显示
         $this->assign('list', $voList);
         $this->assign('sort', $sort);
         $this->assign('order', $order);
         $this->assign('sortImg', $sortImg);
         $this->assign('sortType', $sortAlt);
         $this->assign("page", $page);
     }
     //zhanghuihua@msn.com
     $this->assign('totalCount', $count);
     $this->assign('numPerPage', $p->listRows);
     $this->assign('currentPage', !empty($_REQUEST[C('VAR_PAGE')]) ? $_REQUEST[C('VAR_PAGE')] : 1);
     Cookie::set('_currentUrl_', __SELF__);
     return;
 }
Beispiel #10
0
 /**
  * Unregister an alias
  *
  * @param \Model $objModel The model object
  * @param string $strAlias The alias name
  * @param mixed  $varValue The value of the alias
  *
  * @throws \InvalidArgumentException If the alias is not registered
  */
 public function unregisterAlias(\Model $objModel, $strAlias, $varValue)
 {
     $strTable = $objModel->getTable();
     if (!isset($this->arrAliases[$strTable][$strAlias][$varValue])) {
         $strPk = $objModel->getPk();
         $varPk = $objModel->{$strPk};
         throw new \RuntimeException("The registry does not contain an alias for {$strTable}::{$strPk}({$varPk}) ({$strAlias}/{$varValue})");
     }
     unset($this->arrAliases[$strTable][$strAlias][$varValue]);
 }
Beispiel #11
0
 /**
      +----------------------------------------------------------
 * 根据查询语句
 * 进行列表过滤
      +----------------------------------------------------------
 * @access protected
      +----------------------------------------------------------
 * @param Model $model 数据对象
 * @param string $sql 查询语句
 * @param int $count 数据总量,用于分页
 * @param array $parameter 分页跳转的时候保证查询条件
 * @param string $sortBy 排序
 * @param boolean $asc 是否正序
      +----------------------------------------------------------
 * @return void
      +----------------------------------------------------------
 * @throws ThinkExecption
      +----------------------------------------------------------
 */
 protected function _sqlList($model, $sql, $count, $parameter = array(), $sortBy = '', $asc = false, $returnUrl = 'returnUrl')
 {
     //排序字段 默认为主键名
     if (isset($_REQUEST['_order'])) {
         $order = $_REQUEST['_order'];
     } else {
         $order = !empty($sortBy) ? $sortBy : $model->getPk();
     }
     //排序方式默认按照倒序排列
     //接受 sost参数 0 表示倒序 非0都 表示正序
     if (isset($_REQUEST['_sort'])) {
         $sort = $_REQUEST['_sort'] ? 'asc' : 'desc';
     } else {
         $sort = $asc ? 'asc' : 'desc';
     }
     if ($count > 0) {
         import("@.ORG.Page");
         //创建分页对象
         if (!empty($_REQUEST['listRows'])) {
             $listRows = $_REQUEST['listRows'];
         } else {
             $listRows = '';
         }
         $p = new Page($count, $listRows);
         //分页查询数据
         if (!empty($order)) {
             $sql .= ' ORDER BY ' . $order . ' ' . $sort;
         }
         $sql .= ' LIMIT ' . $p->firstRow . ',' . $p->listRows;
         $voList = $model->query($sql, false);
         //echo $model->getlastsql();
         //分页跳转的时候保证查询条件
         foreach ($parameter as $key => $val) {
             if (!is_array($val)) {
                 $p->parameter .= "&{$key}=" . urlencode($val);
             }
         }
         //分页显示
         $page = $p->show();
         //列表排序显示
         $sortImg = $sort;
         //排序图标
         $sortAlt = $sort == 'desc' ? L('ASC_TITLE') : L('DESC_TITLE');
         //排序提示
         $sort = $sort == 'desc' ? 1 : 0;
         //排序方式
         //模板赋值显示
         $this->assign('list', $voList);
         $this->assign('sort', $sort);
         $this->assign('order', $order);
         $this->assign('sortImg', $sortImg);
         $this->assign('sortType', $sortAlt);
         $this->assign("page", $page);
         Cookie::set('_currentUrl_', $p->currentUrl);
         Cookie::set($returnUrl, $p->currentUrl);
     } else {
         Cookie::set('_currentUrl_', U($this->getActionName() . "/index"));
         Cookie::set($returnUrl, U($this->getActionName() . "/index"));
     }
     return;
 }
 /**
 +----------------------------------------------------------
 * 更新一个数据对象
 +----------------------------------------------------------
 * @access protected 
 +----------------------------------------------------------
 * @param Model $model 数据对象 
 +----------------------------------------------------------
 * @return void
 +----------------------------------------------------------
 * @throws ThinkExecption
 +----------------------------------------------------------
 */
 protected function _update($model)
 {
     $vo = $model->create('', 'edit');
     if (!$vo) {
         $this->error($model->getError());
     }
     $id = is_array($vo) ? $vo[$model->getPk()] : $vo->{$model->getPk()};
     $guid = $model->getModelName() . '_' . $id;
     if (S($guid) == $vo) {
         $this->error(L('无需更新!'));
     }
     $result = $model->save($vo);
     if ($result) {
         $vo = $model->getById($id);
         // 保存成功,更新缓存Vo对象
         S($guid, $vo);
         //数据保存触发器
         if (method_exists($this, '_trigger')) {
             $this->_trigger($vo);
         }
         if (!empty($_FILES)) {
             //如果有文件上传
             //执行默认上传操作
             //保存附件信息到数据库
             $this->_upload(MODULE_NAME, $id);
         }
         //成功提示
         $this->success(L('_UPDATE_SUCCESS_'));
     } else {
         //错误提示
         $this->error($model->getError());
     }
 }
 /**
  * Create a mobel by passing a Contao model
  *
  * @param \Model $model
  * @return \DcGeneral\Data\ModelInterface
  */
 public static function byContaoModel(\Model $model)
 {
     return static::create($model->getTable(), $model->{$model->getPk()}, $model->row());
 }
Beispiel #14
0
 /**
  * 获取返回数据的关联记录
  * @access protected
  * @param mixed $result  返回数据
  * @param string|array $name  关联名称
  * @param boolean $return 是否返回关联数据本身
  * @return array
  */
 protected function getRelation(&$result, $name = '', $return = false)
 {
     if (!empty($this->link)) {
         foreach ($this->link as $key => $val) {
             $mappingName = !empty($val['mapping_name']) ? $val['mapping_name'] : $key;
             // 映射名称
             if (empty($name) || true === $name || $mappingName == $name || is_array($name) && in_array($mappingName, $name)) {
                 $mappingType = !empty($val['mapping_type']) ? $val['mapping_type'] : $val;
                 //  关联类型
                 $mappingClass = !empty($val['class_name']) ? $val['class_name'] : $key;
                 //  关联类名
                 $mappingFields = !empty($val['mapping_fields']) ? $val['mapping_fields'] : '*';
                 // 映射字段
                 $mappingCondition = !empty($val['condition']) ? $val['condition'] : '1=1';
                 // 关联条件
                 $mappingKey = !empty($val['mapping_key']) ? $val['mapping_key'] : $this->getPk();
                 // 关联键名
                 if (strtoupper($mappingClass) == strtoupper($this->name)) {
                     // 自引用关联 获取父键名
                     $mappingFk = !empty($val['parent_key']) ? $val['parent_key'] : 'parent_id';
                 } else {
                     $mappingFk = !empty($val['foreign_key']) ? $val['foreign_key'] : strtolower($this->name) . '_id';
                     //  关联外键
                 }
                 // 获取关联模型对象
                 $model = new Model($mappingClass);
                 switch ($mappingType) {
                     case HAS_ONE:
                         $pk = $result[$mappingKey];
                         $mappingCondition .= " AND {$mappingFk}='{$pk}'";
                         $relationData = $model->where($mappingCondition)->field($mappingFields)->find();
                         break;
                     case BELONGS_TO:
                         if (strtoupper($mappingClass) == strtoupper($this->name)) {
                             // 自引用关联 获取父键名
                             $mappingFk = !empty($val['parent_key']) ? $val['parent_key'] : 'parent_id';
                         } else {
                             $mappingFk = !empty($val['foreign_key']) ? $val['foreign_key'] : strtolower($model->getModelName()) . '_id';
                             //  关联外键
                         }
                         $fk = $result[$mappingFk];
                         $mappingCondition .= " AND {$model->getPk()}='{$fk}'";
                         $relationData = $model->where($mappingCondition)->field($mappingFields)->find();
                         break;
                     case HAS_MANY:
                         $pk = $result[$mappingKey];
                         $mappingCondition .= " AND {$mappingFk}='{$pk}'";
                         $mappingOrder = !empty($val['mapping_order']) ? $val['mapping_order'] : '';
                         $mappingLimit = !empty($val['mapping_limit']) ? $val['mapping_limit'] : '';
                         // 延时获取关联记录
                         $relationData = $model->where($mappingCondition)->field($mappingFields)->order($mappingOrder)->limit($mappingLimit)->select();
                         break;
                     case MANY_TO_MANY:
                         $pk = $result[$mappingKey];
                         $mappingCondition = " {$mappingFk}='{$pk}'";
                         $mappingOrder = $val['mapping_order'];
                         $mappingLimit = $val['mapping_limit'];
                         $mappingRelationFk = $val['relation_foreign_key'] ? $val['relation_foreign_key'] : $model->getModelName() . '_id';
                         $mappingRelationTable = $val['relation_table'] ? $val['relation_table'] : $this->getRelationTableName($model);
                         $sql = "SELECT b.{$mappingFields} FROM {$mappingRelationTable} AS a, " . $model->getTableName() . " AS b WHERE a.{$mappingRelationFk} = b.{$model->getPk()} AND a.{$mappingCondition}";
                         if (!empty($val['condition'])) {
                             $sql .= ' AND ' . $val['condition'];
                         }
                         if (!empty($mappingOrder)) {
                             $sql .= ' ORDER BY ' . $mappingOrder;
                         }
                         if (!empty($mappingLimit)) {
                             $sql .= ' LIMIT ' . $mappingLimit;
                         }
                         $relationData = $this->query($sql);
                         break;
                 }
                 if (!$return) {
                     if (isset($val['as_fields']) && in_array($mappingType, [HAS_ONE, BELONGS_TO])) {
                         // 支持直接把关联的字段值映射成数据对象中的某个字段
                         // 仅仅支持HAS_ONE BELONGS_TO
                         $fields = explode(',', $val['as_fields']);
                         foreach ($fields as $field) {
                             if (strpos($field, ':')) {
                                 list($relationName, $nick) = explode(':', $field);
                                 $result[$nick] = $relationData[$relationName];
                             } else {
                                 $result[$field] = $relationData[$field];
                             }
                         }
                     } else {
                         $result[$mappingName] = $relationData;
                     }
                     unset($relationData);
                 } else {
                     return $relationData;
                 }
             }
         }
     }
     return $result;
 }
 /**
      +----------------------------------------------------------
 * 根据表单生成查询条件
 * 进行列表过滤
      +----------------------------------------------------------
 * @access protected
      +----------------------------------------------------------
 * @param Model $model 数据对象
 * @param HashMap $map 过滤条件
 * @param string $sortBy 排序
 * @param boolean $asc 是否正序
      +----------------------------------------------------------
 * @return void
      +----------------------------------------------------------
 * @throws ThinkExecption
      +----------------------------------------------------------
 */
 protected function _list($model, $map, $sortBy = '', $asc = true)
 {
     $pk = $model->getPk();
     $dbArray = $model->getDbFields();
     unset($dbArray['_autoinc']);
     // _autoinc 表示主键是否自动增长类型
     unset($dbArray['_pk']);
     //_pk 表示主键字段名称
     $order = "";
     if (in_array("sort", $dbArray)) {
         $order .= "sort desc,";
     }
     $order .= $pk . " desc";
     //取得满足条件的记录数
     $count = $model->where($map)->count('id');
     if ($count > 0) {
         import("@.ORG.Util.Page");
         //创建分页对象
         if (!empty($_REQUEST['listRows'])) {
             $listRows = $_REQUEST['listRows'];
         } else {
             $listRows = '';
         }
         $p = new Page($count, $listRows);
         $pageNum = empty($_REQUEST['numPerPage']) ? C('PAGE_LISTROWS') : $_REQUEST['numPerPage'];
         //分页查询数据
         $voList = $model->where($map)->order($order)->limit($pageNum)->page($_REQUEST[C('VAR_PAGE')])->select();
         //分页跳转的时候保证查询条件
         foreach ($map as $key => $val) {
             if (!is_array($val)) {
                 $p->parameter .= "{$key}=" . urlencode($val) . "&";
             }
         }
         //分页显示
         $page = $p->show();
         $name = $this->getActionName();
         if ($name == 'Rleave') {
             foreach ($voList as $k => $v) {
                 $voList[$k] = $v;
                 $user = M('student')->where("id = {$v['sid']}")->find();
                 $voList[$k]['account'] = $user['account'];
                 $voList[$k]['class_id'] = $user['class_id'];
                 $voList[$k]['nickname'] = $user['nickname'];
                 $voList[$k]['gender'] = $user['gender'];
                 $voList[$k]['tel'] = $user['tel'];
             }
         }
         //模板赋值显示
         $this->assign('list', $voList);
         $this->assign('sort', $sort);
         $this->assign('order', $order);
         $this->assign('sortImg', $sortImg);
         $this->assign('sortType', $sortAlt);
         $this->assign("page", $page);
     }
     //zhanghuihua@msn.com
     $this->assign('totalCount', $count);
     //lxz
     $pageNum = empty($_REQUEST['numPerPage']) ? C('PAGE_LISTROWS') : $_REQUEST['numPerPage'];
     $this->assign('numPerPage', $pageNum);
     //每页显示多少条
     $this->assign('currentPage', !empty($_REQUEST[C('VAR_PAGE')]) ? $_REQUEST[C('VAR_PAGE')] : 1);
     Cookie::set('_currentUrl_', __SELF__);
     return;
 }
 /**
  +----------------------------------------------------------
 * 根据表单生成查询条件
 * 进行列表过滤
  +----------------------------------------------------------
 * @access protected
  +----------------------------------------------------------
 * @param Model $model 数据对象
 * @param HashMap $map 过滤条件
 * @param string $sortBy 排序
 * @param boolean $asc 是否正序
  +----------------------------------------------------------
 * @return void
  +----------------------------------------------------------
 * @throws ThinkExecption
  +----------------------------------------------------------
 */
 protected function _list($model, $field = '*', $map = array(), $sortBy = '', $asc = false, $search = array())
 {
     session('listaction', ACTION_NAME);
     //排序字段 默认为主键名
     $pkname = $model->getPk();
     $order = !empty($sortBy) ? $sortBy : $pkname;
     //排序方式默认按照倒序排列
     //接受 sost参数 0 表示倒序 非0都 表示正序
     $sort = $asc ? $asc : 'desc';
     //取得满足条件的记录数
     $count = $model->where($map)->count($pkname);
     import("ORG.Util.Page");
     //创建分页对象
     $listRows = !empty($_REQUEST['listRows']) ? $_REQUEST['listRows'] : C('ADMIN_PAGE_SIZE');
     $p = new \Org\Util\Page($count, $listRows);
     //分页查询数据
     $list = $model->field($field)->where($map)->order($order . ' ' . $sort)->limit($p->firstRow . ',' . $p->listRows)->select();
     //分页跳转的时候保证查询条件
     foreach ($map as $key => $val) {
         if (!is_array($val)) {
             $p->parameter .= "{$key}=" . urlencode($val) . "&";
         }
     }
     foreach ($search as $key => $val) {
         if (!is_array($val)) {
             $p->parameter .= "{$key}=" . urlencode($val) . "&";
         }
     }
     if (method_exists($this, '_listFilter')) {
         $list = $this->_listFilter($list);
     }
     //分页显示
     $page = $p->show();
     //列表排序显示
     $sortImg = $sort;
     //排序图标
     $sortAlt = $sort == 'desc' ? '升序排列' : '倒序排列';
     //排序提示
     $sort = $sort == 'desc' ? 1 : 0;
     //排序方式
     //模板赋值显示
     $this->assign('list', $list);
     $this->assign("pagebar", $page);
     return;
 }
 /**
  +----------------------------------------------------------
 * 根据表单生成查询条件
 * 进行列表过滤
  +----------------------------------------------------------
 * @access protected
  +----------------------------------------------------------
 * @param Model $model 数据对象
 * @param HashMap $map 过滤条件
 * @param string $sortBy 排序
 * @param boolean $asc 是否正序
  +----------------------------------------------------------
 * @return void
  +----------------------------------------------------------
 * @throws ThinkExecption
  +----------------------------------------------------------
 */
 protected function _list($model, $map, $sortBy = '', $asc = false)
 {
     if (!empty($sortBy)) {
         $order = $sortBy;
         if ($asc) {
             $order .= ' asc';
         } else {
             $order .= ' desc';
         }
     } else {
         //排序字段 默认为主键名
         $order = $model->getPk() . ' desc';
     }
     //取得满足条件的记录数
     $count = $model->where($map)->count('id');
     if ($count > 0) {
         //创建分页对象  ,默认10条记录
         if (!empty($_REQUEST['listRows'])) {
             $listRows = $_REQUEST['listRows'];
         } else {
             $listRows = '10';
         }
         $p = new Think\Page($count, $listRows);
         $pageNum = empty($_REQUEST['numPerPage']) ? C('PAGE_LISTROWS') : $_REQUEST['numPerPage'];
         //分页查询数据
         $voList = $model->where($map)->order($order)->limit($pageNum)->page($_REQUEST[C('VAR_PAGE')])->select();
         //分页跳转的时候保证查询条件
         foreach ($map as $key => $val) {
             if (!is_array($val)) {
                 $p->parameter .= "{$key}=" . urlencode($val) . "&";
             }
         }
         //分页显示
         $page = $p->show();
         //列表排序显示
         $sortImg = $sort;
         //排序图标
         $sortAlt = $sort == 'desc' ? '升序排列' : '倒序排列';
         //排序提示
         $sort = $sort == 'desc' ? 1 : 0;
         //排序方式
         //模板赋值显示
         //            dump($voList);
         $this->assign('list', $voList);
         $this->assign('sort', $sort);
         $this->assign('order', $order);
         $this->assign('sortImg', $sortImg);
         $this->assign('sortType', $sortAlt);
         $this->assign("page", $page);
     }
     //囚鸟先生
     $this->assign('totalCount', $count);
     $pageNum = empty($_REQUEST['numPerPage']) ? C('PAGE_LISTROWS') : $_REQUEST['numPerPage'];
     $this->assign('numPerPage', $pageNum);
     //每页显示多少条
     $this->assign('currentPage', !empty($_REQUEST[C('VAR_PAGE')]) ? $_REQUEST[C('VAR_PAGE')] : 1);
     cookie('_currentUrl_', __SELF__);
     return $voList;
 }
 /**
  +----------------------------------------------------------
 * 根据表单生成查询条件
 * 进行列表过滤
  +----------------------------------------------------------
 * @access protected
  +----------------------------------------------------------
 * @param Model $model 数据对象
 * @param HashMap $map 过滤条件
 * @param string $sortBy 排序
 * @param boolean $asc 是否正序
  +----------------------------------------------------------
 * @return void
  +----------------------------------------------------------
 * @throws ThinkExecption
  +----------------------------------------------------------
 */
 protected function _list($model, $map, $sortBy = '', $asc = false)
 {
     //排序字段 默认为主键名
     if (isset($_REQUEST['_order'])) {
         $order = $_REQUEST['_order'];
     } else {
         $order = !empty($sortBy) ? $sortBy : $model->getPk();
     }
     //排序方式默认按照倒序排列
     //接受 sost参数 0 表示倒序 非0都 表示正序
     if (isset($_REQUEST['_sort'])) {
         $sort = $_REQUEST['_sort'] ? 'asc' : 'desc';
     } else {
         $sort = $asc ? 'asc' : 'desc';
     }
     //取得满足条件的记录数
     $count = $model->where($map)->count('id');
     if ($count > 0) {
         //创建分页对象  ,每页10条记录
         $p = new Think\Page($count, 10);
         //分页查询数据
         $voList = $model->where($map)->order("`" . $order . "` " . $sort)->limit($p->firstRow . ',' . $p->listRows)->select();
         //分页显示
         $page = $p->show();
         //列表排序显示
         $sortImg = $sort;
         //排序图标
         $sortAlt = $sort == 'desc' ? '升序排列' : '倒序排列';
         //排序提示
         $sort = $sort == 'desc' ? 1 : 0;
         //排序方式
         //模板赋值显示
         $this->assign('list', $voList);
         $this->assign('sort', $sort);
         $this->assign('order', $order);
         $this->assign('sortImg', $sortImg);
         $this->assign('sortType', $sortAlt);
         $this->assign("page", $page);
     }
     cookie('_currentUrl_', __SELF__);
     return;
 }
Beispiel #19
0
 /**
      +----------------------------------------------------------
 * 根据表单生成查询条件
 * 进行列表过滤
      +----------------------------------------------------------
 * @access protected
      +----------------------------------------------------------
 * @param Model $model 数据对象
 * @param HashMap $map 过滤条件
 * @param string $sortBy 排序
 * @param boolean $asc 是否正序
      +----------------------------------------------------------
 * @return void
      +----------------------------------------------------------
 * @throws ThinkExecption
      +----------------------------------------------------------
 */
 protected function _list($model, $map, $sortBy = '', $asc = true)
 {
     if ($this->_get('_')) {
         unset($_SESSION['maps']);
         unset($_SESSION['tpls']);
     }
     $pk = $model->getPk();
     $dbArray = $model->getDbFields();
     unset($dbArray['_autoinc']);
     // _autoinc 表示主键是否自动增长类型
     unset($dbArray['_pk']);
     //_pk 表示主键字段名称
     $order = "";
     if (in_array("sort", $dbArray)) {
         $order .= "sort desc,";
     }
     $order .= $pk . " desc";
     if ($map) {
         $_SESSION['maps'] = $map;
     }
     $map = $_SESSION['maps'];
     if ($_POST['moshi'] == 2) {
         $_SESSION['tpls'] = 'touxiang';
     }
     if ($_POST['moshi'] == 1) {
         unset($_SESSION['tpls']);
     }
     //print_r($map);
     //取得满足条件的记录数
     $count = $model->where($map)->count('id');
     if ($count > 0) {
         import("@.ORG.Util.Page");
         //创建分页对象
         if (!empty($_REQUEST['listRows'])) {
             $listRows = $_REQUEST['listRows'];
         } else {
             $listRows = '';
         }
         $p = new Page($count, $listRows);
         $pageNum = empty($_REQUEST['numPerPage']) ? C('PAGE_LISTROWS') : $_REQUEST['numPerPage'];
         //分页查询数据
         $voList = $model->where($map)->order($order)->limit($pageNum)->page($_REQUEST[C('VAR_PAGE')])->select();
         //分页跳转的时候保证查询条件
         foreach ($map as $key => $val) {
             if (!is_array($val)) {
                 $p->parameter .= "{$key}=" . urlencode($val) . "&";
             }
         }
         //分页显示
         $page = $p->show();
         //print_r($voList);
         //模板赋值显示
         $this->assign('list', $voList);
         $this->assign('sort', $sort);
         $this->assign('order', $order);
         $this->assign('sortImg', $sortImg);
         $this->assign('sortType', $sortAlt);
         $this->assign("page", $page);
     }
     //echo $model->getLastSql();
     //echo 11111;
     //zhanghuihua@msn.com
     $this->assign('totalCount', $count);
     //lxz
     $pageNum = empty($_REQUEST['numPerPage']) ? C('PAGE_LISTROWS') : $_REQUEST['numPerPage'];
     $this->assign('numPerPage', $pageNum);
     //每页显示多少条
     $this->assign('currentPage', !empty($_REQUEST[C('VAR_PAGE')]) ? $_REQUEST[C('VAR_PAGE')] : 1);
     Cookie::set('_currentUrl_', __SELF__);
     if ($_SESSION['tpls'] == 'touxiang') {
         $this->display($_SESSION['tpls']);
         exit;
     }
     return;
 }
Beispiel #20
0
 /**
  * 根据表单生成查询条件
  * 进行列表过滤
  * @param Model $model 数据对象
  * @param HashMap $map 过滤条件
  * @param string $sortBy 排序
  * @param boolean $asc 是否正序
  */
 protected function _list($model, $map = array(), $sortBy = '', $asc = false)
 {
     //排序字段 默认为主键名
     if (!empty($_REQUEST['_order'])) {
         $order = $_REQUEST['_order'];
     } else {
         $order = !empty($sortBy) ? $sortBy : $model->getPk();
     }
     //排序方式默认按照倒序排列
     //接受 sort参数 0 表示倒序 非0都 表示正序
     if (!empty($_REQUEST['_sort'])) {
         $sort = $_REQUEST['_sort'] == 'asc' ? 'asc' : 'desc';
     } else {
         $sort = $asc ? 'asc' : 'desc';
     }
     //取得满足条件的记录数
     $count = $model->where($map)->count();
     //每页显示的记录数
     if (!empty($_REQUEST['numPerPage'])) {
         $listRows = $_REQUEST['numPerPage'];
     } else {
         $listRows = '10';
     }
     //设置当前页码
     if (!empty($_REQUEST['pageNum'])) {
         $nowPage = $_REQUEST['pageNum'];
     } else {
         $nowPage = 1;
     }
     $_GET['p'] = $nowPage;
     //创建分页对象
     import("ORG.Util.Page");
     $p = new Page($count, $listRows);
     //分页查询数据
     //$list = $model->where($map)->order($order . ' ' . $sort)->select();
     $model = D('Comment');
     $list = $model->where($map)->relation(true)->order($order . ' ' . $sort)->limit($p->firstRow . ',' . $p->listRows)->select();
     //回调函数,用于数据加工,如将用户id,替换成用户名称
     if (method_exists($this, '_tigger_list')) {
         $this->_tigger_list($list);
     }
     //分页跳转的时候保证查询条件
     foreach ($map as $key => $val) {
         if (!is_array($val)) {
             $p->parameter .= "{$key}=" . urlencode($val) . "&";
         }
     }
     //分页显示
     $page = $p->show();
     //列表排序显示
     $sortImg = $sort;
     //排序图标
     $sortAlt = $sort == 'desc' ? '升序排列' : '倒序排列';
     //排序提示
     $sort = $sort == 'desc' ? 1 : 0;
     //排序方式
     //模板赋值显示
     $this->assign('list', $list);
     $this->assign('sort', $sort);
     $this->assign('order', $order);
     $this->assign('sortImg', $sortImg);
     $this->assign('sortType', $sortAlt);
     $this->assign("page", $page);
     $this->assign("search", $search);
     //搜索类型
     $this->assign("values", $_POST['values']);
     //搜索输入框内容
     $this->assign("totalCount", $count);
     //总条数
     $this->assign("numPerPage", $p->listRows);
     //每页显多少条
     $this->assign("currentPage", $nowPage);
     //当前页码
 }
Beispiel #21
0
 /**
      +----------------------------------------------------------
 * 根据表单生成查询条件
 * 进行列表过滤
      +----------------------------------------------------------
 * @access protected
      +----------------------------------------------------------
 * @param Model $model 数据对象
 * @param HashMap $map 过滤条件
 * @param string $sortBy 排序
 * @param boolean $asc 是否正序
      +----------------------------------------------------------
 * @return void
      +----------------------------------------------------------
 * @throws ThinkExecption
      +----------------------------------------------------------
 */
 protected function _list($model, $map, $sortBy = '', $asc = false)
 {
     //排序字段 默认为主键名
     if (isset($_REQUEST['_order'])) {
         $order = $_REQUEST['_order'];
     } else {
         $order = !empty($sortBy) ? $sortBy : $model->getPk();
     }
     //排序方式默认按照倒序排列
     //接受 sost参数 0 表示倒序 非0都 表示正序
     if (isset($_REQUEST['_sort'])) {
         $sort = $_REQUEST['_sort'] ? 'asc' : 'desc';
     } else {
         $sort = $asc ? 'asc' : 'desc';
     }
     if (isset($_REQUEST['fileds'])) {
         $fileds = $_REQUEST['fileds'];
     } else {
         $fileds = '*';
     }
     $count = $model->where($map)->count();
     $page_size = $_REQUEST['page_size'] ? $_REQUEST['page_size'] : C('default_page_size');
     $page_count = ceil($count / $page_size);
     $pageno = $_REQUEST['pageno'] ? $_REQUEST['pageno'] : 1;
     $offset = ($pageno - 1) * $page_size;
     $voList = $model->field($fileds)->where($map)->order("`" . $order . "` " . $sort)->limit($offset . ',' . $page_size)->select();
     foreach ($voList as $key => $val) {
         if ($val['msg']) {
             $voList[$key]['msg'] = str_cut(htmlspecialchars_decode($val['msg']), 30);
         }
         if ($val['content']) {
             $voList[$key]['content'] = str_cut(htmlspecialchars_decode($val['content']), 30);
         }
     }
     //echo $model->getlastsql();
     $list['count'] = $count;
     $list['page_count'] = $page_count;
     $list['data'] = $voList;
     ajaxSucReturn($list);
     //echo  json_encode($list);exit;
 }