Commit edd6fbcf by HTML5-侯张振

修复 保护期分页bug

parent 726c86c0
......@@ -988,7 +988,7 @@ class Report extends CI_Controller
$uid = $this->session->userdata['u_id'];
$info = $this->manager->get(array('id' => $uid));
$this->data['building_title'] = $building = $get['building_title'];
$this->data['building_title'] = $building = $get['company_name'];
$where1 = "B.building_title like '%$building%'";
......@@ -1005,10 +1005,10 @@ class Report extends CI_Controller
$con_arr = array();
if ($get) {
$con_arr = array(
'company_name' => $get['building_title'] ? : ''
'company_name' => $get['company_name'] ? : ''
);
if (isset($get['building_title']) && $get['building_title']) {
$where .= ' and D.company_name like "%' . trim($get['building_title']) . '%"';
if (isset($get['company_name']) && $get['company_name']) {
$where .= ' and D.company_name like "%' . trim($get['company_name']) . '%"';
}
// if (isset($get['uniqid_id'])) {
......@@ -1022,27 +1022,36 @@ class Report extends CI_Controller
$where.= ' and A.id ='.$user_data['u_id'];
};
$admins = $this->distributor->get_distributor_new($where, $page_no, self::PAGE_SIZE);
$admins = $this->distributor->get_protection_new($where);
$der = explode(',',$info['building_id']);
$protection_arr = array();
foreach($admins as $admin){
$data_arrid = $this->relate->protection_list(array('distributor_id'=>$admin['distributor_id']));
$data_arrid = $this->relate->protection_list_count(array('distributor_id'=>$admin['distributor_id']));
foreach($data_arrid as $k=>$id){
if(in_array($data_arrid[$k]['building_id'],$der)){
$protection_arr[] = $data_arrid[$k];
$protection_arr[] = $data_arrid[$k];
}
}
}
$count = count($protection_arr);
$where3 = 'BD.is_deleted ='.'0';
$where3 .= " and BD.building_id in(" . $info['building_id'] . ")";
if($user_data['role'] == 12){
$where3.= ' and A.id ='.$user_data['u_id'];
};
$protection_list = $this->relate->protection_list($where3, $page_no, self::PAGE_SIZE);
$this->data['buildings'] = $protection_list;
$this->data['count'] = $count;
$this->data['buildings'] = $protection_arr;
$data_arr = '?company_name=' . $building;
$this->data['num_start'] = ($page_no - 1) * self::PAGE_SIZE + 1;
//获取分页
$this->data['num_link'] = set_page_new($data_arr, $this, site_url('admin/report/protection'), $count,self::PAGE_SIZE, 4, '', true);
......
......@@ -204,7 +204,7 @@ class Building_distributor_model extends MY_Model{
return array();
}
//获取保护期查看列表
public function protection_list($where){
public function protection_list($where, $page = 1, $page_size = 0, $order = NULL){
$this->db->select('set_protection, B.building_title building_title, D.company_name company_name, BD.building_id building_id');
$this->db->from('tb_building_distributor_relate BD');
$this->db->join('tb_building B','B.id = BD.building_id','left');
......@@ -213,11 +213,36 @@ class Building_distributor_model extends MY_Model{
{
$this->db->where($where);
}
$query = $this->db->get();
if($query->num_rows() > 0)
if (!$page)
{
$query = $this->db->get();
} else {
$query = $this->db->get(null, $page_size, ($page-1) * $page_size);
}
//$query = $this->db->get();
if($query->num_rows() > 0){
return $query->result_array();
}
return array();
}
public function protection_list_count($where){
$this->db->select('set_protection, B.building_title building_title, D.company_name company_name, BD.building_id building_id');
$this->db->from('tb_building_distributor_relate BD');
$this->db->join('tb_building B','B.id = BD.building_id','left');
$this->db->join('tb_distributor D','D.id = BD.distributor_id','left');
if(!empty($where))
{
return $query->result_array();
$this->db->where($where);
}
return false;
$query = $this->db->get();
//$query = $this->db->get();
if($query->num_rows() > 0){
return $query->result_array();
}
return array();
}
}
......@@ -175,7 +175,32 @@ class Distributor_model extends MY_Model{
return array();
}
//保护期查看统计列表
public function get_protection_new($where = '')
{
$this->db->select('D.id distributor_id')
->from('tb_distributor D')
->join('tb_channel CH','CH.id=D.channel_id','left')
->join('tb_manager M','M.id=D.manager_id','left')
->join('tb_manager A','CH.manager_id=A.id','left')
->join('tb_building_distributor_relate R', 'R.distributor_id=D.id', 'left')
->join('tb_building B','B.id=R.building_id','left');
if(!empty($where)){
$this->db->where($where);
}
$this->db->group_by('D.id');
$this->db->order_by('D.id desc');
$query = $this->db->get();
if($query->num_rows() > 0){
return $query->result_array();
}
return array();
}
//后台分销商管理统计列表
public function get_distributor($where = '', $page = 1, $page_size = 0, $order = NULL)
{
......
......@@ -65,17 +65,15 @@
foreach($buildings as $building):
?>
<tr>
<td><?php echo $num_start++; ?></td>
<td><?php echo $building['building_title'];?></td>
<td><?php echo $building['company_name'];?></td>
<td><?php echo $building['set_protection'] ? $building['set_protection'] : 7;?></td>
<td><?php echo $num_start++; ?></td>
<td><?php echo $building['building_title'];?></td>
<td><?php echo $building['company_name'];?></td>
<td><?php echo $building['set_protection'] ? $building['set_protection'] : 7;?></td>
</tr>
<?php
endforeach;
else:
?>
else:
?>
<tr>
<td colspan="16" align="center">暂无数据.</td>
</tr>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment