Commit edd6fbcf by HTML5-侯张振

修复 保护期分页bug

parent 726c86c0
...@@ -988,7 +988,7 @@ class Report extends CI_Controller ...@@ -988,7 +988,7 @@ class Report extends CI_Controller
$uid = $this->session->userdata['u_id']; $uid = $this->session->userdata['u_id'];
$info = $this->manager->get(array('id' => $uid)); $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%'"; $where1 = "B.building_title like '%$building%'";
...@@ -1005,10 +1005,10 @@ class Report extends CI_Controller ...@@ -1005,10 +1005,10 @@ class Report extends CI_Controller
$con_arr = array(); $con_arr = array();
if ($get) { if ($get) {
$con_arr = array( $con_arr = array(
'company_name' => $get['building_title'] ? : '' 'company_name' => $get['company_name'] ? : ''
); );
if (isset($get['building_title']) && $get['building_title']) { if (isset($get['company_name']) && $get['company_name']) {
$where .= ' and D.company_name like "%' . trim($get['building_title']) . '%"'; $where .= ' and D.company_name like "%' . trim($get['company_name']) . '%"';
} }
// if (isset($get['uniqid_id'])) { // if (isset($get['uniqid_id'])) {
...@@ -1022,13 +1022,13 @@ class Report extends CI_Controller ...@@ -1022,13 +1022,13 @@ class Report extends CI_Controller
$where.= ' and A.id ='.$user_data['u_id']; $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']); $der = explode(',',$info['building_id']);
$protection_arr = array(); $protection_arr = array();
foreach($admins as $admin){ 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){ foreach($data_arrid as $k=>$id){
if(in_array($data_arrid[$k]['building_id'],$der)){ if(in_array($data_arrid[$k]['building_id'],$der)){
$protection_arr[] = $data_arrid[$k]; $protection_arr[] = $data_arrid[$k];
...@@ -1036,9 +1036,18 @@ class Report extends CI_Controller ...@@ -1036,9 +1036,18 @@ class Report extends CI_Controller
} }
} }
$this->data['count'] = $count; $count = count($protection_arr);
$this->data['buildings'] = $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;
$data_arr = '?company_name=' . $building; $data_arr = '?company_name=' . $building;
$this->data['num_start'] = ($page_no - 1) * self::PAGE_SIZE + 1; $this->data['num_start'] = ($page_no - 1) * self::PAGE_SIZE + 1;
......
...@@ -204,7 +204,7 @@ class Building_distributor_model extends MY_Model{ ...@@ -204,7 +204,7 @@ class Building_distributor_model extends MY_Model{
return array(); 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->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->from('tb_building_distributor_relate BD');
$this->db->join('tb_building B','B.id = BD.building_id','left'); $this->db->join('tb_building B','B.id = BD.building_id','left');
...@@ -213,11 +213,36 @@ class Building_distributor_model extends MY_Model{ ...@@ -213,11 +213,36 @@ class Building_distributor_model extends MY_Model{
{ {
$this->db->where($where); $this->db->where($where);
} }
if (!$page)
{
$query = $this->db->get(); $query = $this->db->get();
if($query->num_rows() > 0) } 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))
{ {
$this->db->where($where);
}
$query = $this->db->get();
//$query = $this->db->get();
if($query->num_rows() > 0){
return $query->result_array(); return $query->result_array();
} }
return false; return array();
} }
} }
...@@ -175,7 +175,32 @@ class Distributor_model extends MY_Model{ ...@@ -175,7 +175,32 @@ class Distributor_model extends MY_Model{
return array(); 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) public function get_distributor($where = '', $page = 1, $page_size = 0, $order = NULL)
{ {
......
...@@ -69,8 +69,6 @@ ...@@ -69,8 +69,6 @@
<td><?php echo $building['building_title'];?></td> <td><?php echo $building['building_title'];?></td>
<td><?php echo $building['company_name'];?></td> <td><?php echo $building['company_name'];?></td>
<td><?php echo $building['set_protection'] ? $building['set_protection'] : 7;?></td> <td><?php echo $building['set_protection'] ? $building['set_protection'] : 7;?></td>
</tr> </tr>
<?php <?php
endforeach; endforeach;
......
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