Commit d1ea0550 by html5-李恒逸

fix bugs

parent 7d169742
...@@ -376,7 +376,7 @@ class Channeladmin extends CI_Controller ...@@ -376,7 +376,7 @@ class Channeladmin extends CI_Controller
$admins = array(); $admins = array();
$admins = $this->channel->get_all_info($where, $page_no, self::PAGE_SIZE); $admins = $this->channel->get_all_info($where, $page_no, self::PAGE_SIZE);
$this->data['customers'] = $admins; $this->data['customers'] = $admins;
$this->data['num_start'] = ($page_no - 1) * self::PAGE_SIZE + 1;
//获取分页 //获取分页
$this->data['num_link'] = set_page1( $this->data['num_link'] = set_page1(
$this,site_url('admin/channeladmin/customerSearch?distributor_name='.$get['distributor_name'].'&status='.$get['status'].'&channel_id='.$get['channel_id'].'&building_title='.$get['building_title'].'&time='.$get['time']), $this,site_url('admin/channeladmin/customerSearch?distributor_name='.$get['distributor_name'].'&status='.$get['status'].'&channel_id='.$get['channel_id'].'&building_title='.$get['building_title'].'&time='.$get['time']),
...@@ -467,7 +467,7 @@ class Channeladmin extends CI_Controller ...@@ -467,7 +467,7 @@ class Channeladmin extends CI_Controller
$admins = array(); $admins = array();
$admins = $this->channel->get_all_info($where, $page_no, self::PAGE_SIZE); $admins = $this->channel->get_all_info($where, $page_no, self::PAGE_SIZE);
$this->data['customers'] = $admins; $this->data['customers'] = $admins;
$this->data['num_start'] = ($page_no - 1) * self::PAGE_SIZE + 1;
//获取分页 //获取分页
$this->data['num_link'] = set_page1( $this->data['num_link'] = set_page1(
$this,site_url('admin/channeladmin/customerExport?distributor_name='.$get['distributor_name'].'&status='.$get['status'].'&channel_id='.$get['channel_id'].'&building_title='.$get['building_title'].'&time='.$get['time']), $this,site_url('admin/channeladmin/customerExport?distributor_name='.$get['distributor_name'].'&status='.$get['status'].'&channel_id='.$get['channel_id'].'&building_title='.$get['building_title'].'&time='.$get['time']),
......
...@@ -9,7 +9,7 @@ class Kpiadmin extends CI_Controller ...@@ -9,7 +9,7 @@ class Kpiadmin extends CI_Controller
const PAGE_SIZE = 20; const PAGE_SIZE = 20;
protected $status = array(); protected $status = array();
/** /**
* 构造器 * 构造器
*/ */
...@@ -21,7 +21,7 @@ class Kpiadmin extends CI_Controller ...@@ -21,7 +21,7 @@ class Kpiadmin extends CI_Controller
//语言包 //语言包
$this->lang->load('op_log','chinese'); $this->lang->load('op_log','chinese');
$this->u_name = $this->session->userdata('user_name'); $this->u_name = $this->session->userdata('user_name');
//加载菜单 //加载菜单
$this->load->helper('util'); $this->load->helper('util');
$this->data['menu'] = newgenerate_menu(); $this->data['menu'] = newgenerate_menu();
...@@ -31,7 +31,7 @@ class Kpiadmin extends CI_Controller ...@@ -31,7 +31,7 @@ class Kpiadmin extends CI_Controller
//模型 //模型
$this->load->model('activity_model', 'activity'); $this->load->model('activity_model', 'activity');
$is_admin = $this->session->userdata('type') == 1 && $this->session->userdata('role')? true : false; $is_admin = $this->session->userdata('type') == 1 && $this->session->userdata('role')? true : false;
if(!$this->session->userdata('u_id') || !$is_admin) if(!$this->session->userdata('u_id') || !$is_admin)
{ {
alert_redirect(site_url('admin/index/login')); alert_redirect(site_url('admin/index/login'));
...@@ -89,7 +89,7 @@ class Kpiadmin extends CI_Controller ...@@ -89,7 +89,7 @@ class Kpiadmin extends CI_Controller
if ($con_arr['building_title']) { if ($con_arr['building_title']) {
$where .= ' and B.building_title like "%' . $con_arr['building_title'] . '%"'; $where .= ' and B.building_title like "%' . $con_arr['building_title'] . '%"';
} }
//我是销管 //我是销管
$user_id = (int)$this->session->userdata('u_id'); $user_id = (int)$this->session->userdata('u_id');
...@@ -101,11 +101,11 @@ class Kpiadmin extends CI_Controller ...@@ -101,11 +101,11 @@ class Kpiadmin extends CI_Controller
//获取所有的客户 //获取所有的客户
$this->data['customers'] = array(); $this->data['customers'] = array();
if($count >0){ if($count >0){
//获取客户信息 //获取客户信息
$customers = $this->customer->get_recommend_page($where, $page_no, self::PAGE_SIZE); $customers = $this->customer->get_recommend_page($where, $page_no, self::PAGE_SIZE);
if ($customers) if ($customers)
{ {
foreach ($customers as $key => $customer) { foreach ($customers as $key => $customer) {
$customers[$key]['customers'] = 0; $customers[$key]['customers'] = 0;
...@@ -167,7 +167,7 @@ class Kpiadmin extends CI_Controller ...@@ -167,7 +167,7 @@ class Kpiadmin extends CI_Controller
} }
if ($con_arr['channel']) { if ($con_arr['channel']) {
$where .= ' and D.channel like "%' . $con_arr['channel'] . '%"'; $where .= ' and M.manager_name like "%' . $con_arr['channel'] . '%"';
} }
if ($con_arr['customer_user']) { if ($con_arr['customer_user']) {
...@@ -190,12 +190,12 @@ class Kpiadmin extends CI_Controller ...@@ -190,12 +190,12 @@ class Kpiadmin extends CI_Controller
$where .= ' and CB.create_time >= ' . strtotime($con_arr['start_day']); $where .= ' and CB.create_time >= ' . strtotime($con_arr['start_day']);
} }
if ($con_arr['end_day']) { if ($con_arr['end_day']) {
$where .= ' and CB.create_time < ' . (strtotime($con_arr['end_day']) + 24*3600 - 1); $where .= ' and CB.create_time < ' . (strtotime($con_arr['end_day']) + 24*3600 - 1);
} }
//经纪人 //经纪人
if ($con_arr['agent_name']) { if ($con_arr['agent_name']) {
$where .= ' and (UPP.true_name like "%' . $con_arr['agent_name'] . '%" OR UPP.user_name like "%' . $con_arr['agent_name'] . '%")'; $where .= ' and (UPP.true_name like "%' . $con_arr['agent_name'] . '%" OR UPP.user_name like "%' . $con_arr['agent_name'] . '%")';
} }
...@@ -203,20 +203,20 @@ class Kpiadmin extends CI_Controller ...@@ -203,20 +203,20 @@ class Kpiadmin extends CI_Controller
$user_id = (int)$this->session->userdata('u_id'); $user_id = (int)$this->session->userdata('u_id');
$info = $this->manager->get(array('id' => $user_id)); $info = $this->manager->get(array('id' => $user_id));
if ($info['role_id'] == 10) if ($info['role_id'] == 10)
{ {
$where .= ' and RR.user_id =' . $user_id; $where .= ' and RR.user_id =' . $user_id;
} else if ($info['role_id'] == 11){ } else if ($info['role_id'] == 11){
$where .= ' and D.manager_id =' . $user_id; $where .= ' and D.manager_id =' . $user_id;
} }
$where = trim($where, ' and '); $where = trim($where, ' and ');
//获取客户总数 //获取客户总数
$count = $this->customer->get_distributor_page_count($where); $count = $this->customer->get_distributor_page_count($where);
//获取所有的客户 //获取所有的客户
$this->data['customers'] = array(); $this->data['customers'] = array();
if($count >0){ if($count >0){
//获取客户信息 //获取客户信息
$customers = $this->customer->get_distributor_page($where, $page_no, self::PAGE_SIZE); $customers = $this->customer->get_distributor_page($where, $page_no, self::PAGE_SIZE);
...@@ -224,7 +224,7 @@ class Kpiadmin extends CI_Controller ...@@ -224,7 +224,7 @@ class Kpiadmin extends CI_Controller
//获取分页 //获取分页
$this->data['num_link'] = set_page_new($data_arr,$this,site_url('admin/kpiadmin/distributor'),$count,self::PAGE_SIZE,4,'',true); $this->data['num_link'] = set_page_new($data_arr,$this,site_url('admin/kpiadmin/distributor'),$count,self::PAGE_SIZE,4,'',true);
} }
$this->data['num_start'] = ($page_no - 1) * self::PAGE_SIZE + 1; $this->data['num_start'] = ($page_no - 1) * self::PAGE_SIZE + 1;
//查询客户信息列表 //查询客户信息列表
$this->load->view('admin/kpiadmin/distributor',$this->data); $this->load->view('admin/kpiadmin/distributor',$this->data);
...@@ -276,20 +276,20 @@ class Kpiadmin extends CI_Controller ...@@ -276,20 +276,20 @@ class Kpiadmin extends CI_Controller
//分销商查看自己的经纪人 //分销商查看自己的经纪人
$uid = $this->session->userdata('u_id'); $uid = $this->session->userdata('u_id');
$distributor = $this->distributor->get(array('manager_id' => $uid)); $distributor = $this->distributor->get(array('manager_id' => $uid));
if ($distributor && $distributor['uniqid_id']) { if ($distributor && $distributor['uniqid_id']) {
$where .= ' U.uniqid_id =' . $distributor['uniqid_id']; $where .= ' U.uniqid_id =' . $distributor['uniqid_id'];
} }
$where = trim($where, ' and '); $where = trim($where, ' and ');
$count = $this->customer->get_agents_page_count($where); $count = $this->customer->get_agents_page_count($where);
//获取所有的客户 //获取所有的客户
$this->data['agents'] = array(); $this->data['agents'] = array();
if($count >0){ if($count >0){
$agents = $this->customer->get_agents_page($where, $page_no, self::PAGE_SIZE); $agents = $this->customer->get_agents_page($where, $page_no, self::PAGE_SIZE);
if ($agents) if ($agents)
{ {
foreach ($agents as $key => $agent) { foreach ($agents as $key => $agent) {
...@@ -309,7 +309,7 @@ class Kpiadmin extends CI_Controller ...@@ -309,7 +309,7 @@ class Kpiadmin extends CI_Controller
//获取分页 //获取分页
$this->data['num_link'] = set_page_new($data_arr,$this,site_url('admin/kpiadmin/agents'),$count,self::PAGE_SIZE,4,'',true); $this->data['num_link'] = set_page_new($data_arr,$this,site_url('admin/kpiadmin/agents'),$count,self::PAGE_SIZE,4,'',true);
} }
$this->data['num_start'] = ($page_no - 1) * self::PAGE_SIZE + 1; $this->data['num_start'] = ($page_no - 1) * self::PAGE_SIZE + 1;
$this->load->view('admin/kpiadmin/agents',$this->data); $this->load->view('admin/kpiadmin/agents',$this->data);
} }
...@@ -361,11 +361,11 @@ class Kpiadmin extends CI_Controller ...@@ -361,11 +361,11 @@ class Kpiadmin extends CI_Controller
//获取所有的客户 //获取所有的客户
$this->data['customers'] = array(); $this->data['customers'] = array();
if($count >0){ if($count >0){
//获取客户信息 //获取客户信息
$customers = $this->customer->get_recommend_page($where, 1, $count); $customers = $this->customer->get_recommend_page($where, 1, $count);
if ($customers) if ($customers)
{ {
foreach ($customers as $key => $customer) { foreach ($customers as $key => $customer) {
$customers[$key]['customers'] = 0; $customers[$key]['customers'] = 0;
...@@ -387,7 +387,7 @@ class Kpiadmin extends CI_Controller ...@@ -387,7 +387,7 @@ class Kpiadmin extends CI_Controller
} }
} }
$data = array(); $data = array();
if ($customers) { if ($customers) {
foreach ($customers as $key => $item) { foreach ($customers as $key => $item) {
...@@ -396,7 +396,7 @@ class Kpiadmin extends CI_Controller ...@@ -396,7 +396,7 @@ class Kpiadmin extends CI_Controller
$temp['building_title'] = iconv('utf-8', 'gbk//IGNORE', $item['building_title']); $temp['building_title'] = iconv('utf-8', 'gbk//IGNORE', $item['building_title']);
$temp['customers'] = $item['customers']; $temp['customers'] = $item['customers'];
$temp['channel'] = iconv('utf-8', 'gbk', $item['channel_name']); $temp['channel'] = iconv('utf-8', 'gbk', $item['channel_name']);
array_push($data, $temp); array_push($data, $temp);
} }
} }
...@@ -463,19 +463,19 @@ class Kpiadmin extends CI_Controller ...@@ -463,19 +463,19 @@ class Kpiadmin extends CI_Controller
$user_id = (int)$this->session->userdata('u_id'); $user_id = (int)$this->session->userdata('u_id');
$info = $this->manager->get(array('id' => $user_id)); $info = $this->manager->get(array('id' => $user_id));
if ($info['role_id'] == 10) if ($info['role_id'] == 10)
{ {
$where .= ' and RR.user_id =' . $user_id; $where .= ' and RR.user_id =' . $user_id;
} else if ($info['role_id'] == 11){ } else if ($info['role_id'] == 11){
$where .= ' and D.manager_id =' . $user_id; $where .= ' and D.manager_id =' . $user_id;
} }
//获取客户总数 //获取客户总数
$count = $this->customer->get_distributor_page_count($where); $count = $this->customer->get_distributor_page_count($where);
$customers = $this->customer->get_distributor_page($where, 1, $count); $customers = $this->customer->get_distributor_page($where, 1, $count);
$data = array(); $data = array();
if ($customers) { if ($customers) {
foreach ($customers as $key => $item) { foreach ($customers as $key => $item) {
$item['customer_type'] = $item['customer_type'] === null ? '0' : $item['customer_type']; $item['customer_type'] = $item['customer_type'] === null ? '0' : $item['customer_type'];
...@@ -495,7 +495,7 @@ class Kpiadmin extends CI_Controller ...@@ -495,7 +495,7 @@ class Kpiadmin extends CI_Controller
$temp['partner_name'] = iconv('utf-8', 'gbk', $item['partner_name']); $temp['partner_name'] = iconv('utf-8', 'gbk', $item['partner_name']);
$temp['pumobile'] = iconv('utf-8', 'gbk', $item['partner_user_mobile']); $temp['pumobile'] = iconv('utf-8', 'gbk', $item['partner_user_mobile']);
$temp['remark'] = iconv('utf-8', 'gbk', $item['remark']); $temp['remark'] = iconv('utf-8', 'gbk', $item['remark']);
array_push($data, $temp); array_push($data, $temp);
} }
} }
...@@ -548,11 +548,11 @@ class Kpiadmin extends CI_Controller ...@@ -548,11 +548,11 @@ class Kpiadmin extends CI_Controller
//分销商查看自己的经纪人 //分销商查看自己的经纪人
$uid = $this->session->userdata('u_id'); $uid = $this->session->userdata('u_id');
$distributor = $this->distributor->get(array('manager_id' => $uid)); $distributor = $this->distributor->get(array('manager_id' => $uid));
if ($distributor && $distributor['uniqid_id']) { if ($distributor && $distributor['uniqid_id']) {
$where .= ' U.uniqid_id =' . $distributor['uniqid_id']; $where .= ' U.uniqid_id =' . $distributor['uniqid_id'];
} }
$where = trim($where, ' and '); $where = trim($where, ' and ');
$count = $this->customer->get_agents_page_count($where); $count = $this->customer->get_agents_page_count($where);
...@@ -577,7 +577,7 @@ class Kpiadmin extends CI_Controller ...@@ -577,7 +577,7 @@ class Kpiadmin extends CI_Controller
} }
} }
$data = array(); $data = array();
if ($agents) { if ($agents) {
foreach ($agents as $key => $item) { foreach ($agents as $key => $item) {
...@@ -585,7 +585,7 @@ class Kpiadmin extends CI_Controller ...@@ -585,7 +585,7 @@ class Kpiadmin extends CI_Controller
$temp['user_name'] = iconv('utf-8', 'gbk', $item['true_name'] ? : $item['user_name']); $temp['user_name'] = iconv('utf-8', 'gbk', $item['true_name'] ? : $item['user_name']);
$temp['user_mobile'] = $item['user_mobile']; $temp['user_mobile'] = $item['user_mobile'];
$temp['building_title'] = iconv('utf-8', 'gbk', $item['building_title']); $temp['building_title'] = iconv('utf-8', 'gbk', $item['building_title']);
$temp['customers'] = $item['customers']; $temp['customers'] = $item['customers'];
array_push($data, $temp); array_push($data, $temp);
} }
} }
...@@ -595,9 +595,9 @@ class Kpiadmin extends CI_Controller ...@@ -595,9 +595,9 @@ class Kpiadmin extends CI_Controller
$titles = iconv('utf-8', 'gbk', $titles); $titles = iconv('utf-8', 'gbk', $titles);
$file = iconv('utf-8', 'gbk', '经纪人数据列表.xls'); $file = iconv('utf-8', 'gbk', '经纪人数据列表.xls');
$this->export->export_excel($file, $titles, $data); $this->export->export_excel($file, $titles, $data);
break; break;
default: default:
# code... # code...
break; break;
...@@ -657,7 +657,7 @@ class Kpiadmin extends CI_Controller ...@@ -657,7 +657,7 @@ class Kpiadmin extends CI_Controller
//获取所有的客户 //获取所有的客户
$this->data['customers'] = array(); $this->data['customers'] = array();
if($count >0){ if($count >0){
//获取客户信息 //获取客户信息
$customers = $this->customer->get_channel_page($where, $page_no, self::PAGE_SIZE); $customers = $this->customer->get_channel_page($where, $page_no, self::PAGE_SIZE);
...@@ -759,4 +759,4 @@ class Kpiadmin extends CI_Controller ...@@ -759,4 +759,4 @@ class Kpiadmin extends CI_Controller
$this->load->view('admin/kpiadmin/customer',$this->data); $this->load->view('admin/kpiadmin/customer',$this->data);
} }
} }
\ No newline at end of file
<?php <?php
/** /**
* 客户模型 * 客户模型
* *
* @package application/model * @package application/model
* @version 2012-10-31 * @version 2012-10-31
* @author wenhuijang * @author wenhuijang
...@@ -13,7 +13,7 @@ class Customer_model extends MY_Model{ ...@@ -13,7 +13,7 @@ class Customer_model extends MY_Model{
* 使用到的表 * 使用到的表
*/ */
public $table = 'tb_customer'; public $table = 'tb_customer';
/** /**
* 构造器 * 构造器
*/ */
...@@ -25,7 +25,7 @@ class Customer_model extends MY_Model{ ...@@ -25,7 +25,7 @@ class Customer_model extends MY_Model{
} }
/** /**
* *
* 总数 * 总数
* @param int $where * @param int $where
* @return array 总数 * @return array 总数
...@@ -56,7 +56,7 @@ class Customer_model extends MY_Model{ ...@@ -56,7 +56,7 @@ class Customer_model extends MY_Model{
} }
/** /**
* *
* 后台管理 分页数据 * 后台管理 分页数据
* @param int $where * @param int $where
* @param int $offset 结果偏移量 * @param int $offset 结果偏移量
...@@ -86,7 +86,7 @@ class Customer_model extends MY_Model{ ...@@ -86,7 +86,7 @@ class Customer_model extends MY_Model{
$this->db->where($where); $this->db->where($where);
} }
$this->db->order_by('CB.id','desc'); $this->db->order_by('CB.id','desc');
$query = $this->db->get(null,$page_size, ($page-1) * $page_size); $query = $this->db->get(null,$page_size, ($page-1) * $page_size);
if($query->num_rows() > 0) if($query->num_rows() > 0)
{ {
...@@ -95,7 +95,7 @@ class Customer_model extends MY_Model{ ...@@ -95,7 +95,7 @@ class Customer_model extends MY_Model{
return false; return false;
} }
/** /**
* *
* 后台管理 统计客户分页数据 * 后台管理 统计客户分页数据
* @param int $where * @param int $where
* @param int $offset 结果偏移量 * @param int $offset 结果偏移量
...@@ -108,7 +108,7 @@ class Customer_model extends MY_Model{ ...@@ -108,7 +108,7 @@ class Customer_model extends MY_Model{
{ {
$this->db->select( $this->db->select(
'C.customer_user, C.customer_mobile, C.create_time, 'C.customer_user, C.customer_mobile, C.create_time,
CB.id, CB.building_id, B.building_title, CB.distribution_status, CB.order_time, CB.deal_price, CB.payed_price, CB.payed_status, CB.id, CB.building_id, B.building_title, CB.distribution_status, CB.order_time, CB.deal_price, CB.payed_price, CB.payed_status,
R.region_code, R.region_name, R.region_code, R.region_name,
CB.sale_id, UP.user_name sale_name, CB.sale_id, UP.user_name sale_name,
CB.manager_id, UM.user_name manager_name, CB.manager_id, UM.user_name manager_name,
...@@ -130,7 +130,7 @@ class Customer_model extends MY_Model{ ...@@ -130,7 +130,7 @@ class Customer_model extends MY_Model{
$this->db->where($where); $this->db->where($where);
} }
$this->db->order_by('CB.id','desc'); $this->db->order_by('CB.id','desc');
$query = $this->db->get(null,$page_size, ($page-1) * $page_size); $query = $this->db->get(null,$page_size, ($page-1) * $page_size);
if($query->num_rows() > 0) if($query->num_rows() > 0)
{ {
...@@ -154,7 +154,7 @@ class Customer_model extends MY_Model{ ...@@ -154,7 +154,7 @@ class Customer_model extends MY_Model{
{ {
$this->db->where($where); $this->db->where($where);
} }
$query = $this->db->get(); $query = $this->db->get();
if($query->num_rows() > 0) if($query->num_rows() > 0)
{ {
...@@ -164,7 +164,7 @@ class Customer_model extends MY_Model{ ...@@ -164,7 +164,7 @@ class Customer_model extends MY_Model{
return 0; return 0;
} }
/** /**
* *
* 后台管理 统计客户分页数据 * 后台管理 统计客户分页数据
* @param int $where * @param int $where
* @param int $offset 结果偏移量 * @param int $offset 结果偏移量
...@@ -200,19 +200,19 @@ class Customer_model extends MY_Model{ ...@@ -200,19 +200,19 @@ class Customer_model extends MY_Model{
$this->db->where($where); $this->db->where($where);
} }
$this->db->order_by('CB.user_id desc'); $this->db->order_by('CB.user_id desc');
$query = $this->db->get(null,$page_size, ($page-1) * $page_size); $query = $this->db->get(null,$page_size, ($page-1) * $page_size);
if($query->num_rows() > 0) if($query->num_rows() > 0)
{ {
return $query->result_array(); return $query->result_array();
} }
return false; return false;
} }
public function get_partner_page_statistics_count($where = '') public function get_partner_page_statistics_count($where = '')
{ {
$this->db->select('count(*) total'); $this->db->select('count(*) total');
$this->db->from($this->table . ' C'); $this->db->from($this->table . ' C');
$this->db->join('tb_customer_building CB', 'CB.customer_id = C.id', 'left'); $this->db->join('tb_customer_building CB', 'CB.customer_id = C.id', 'left');
...@@ -226,7 +226,7 @@ class Customer_model extends MY_Model{ ...@@ -226,7 +226,7 @@ class Customer_model extends MY_Model{
{ {
$this->db->where($where); $this->db->where($where);
} }
$query = $this->db->get(); $query = $this->db->get();
if($query->num_rows() > 0) if($query->num_rows() > 0)
{ {
...@@ -238,7 +238,7 @@ class Customer_model extends MY_Model{ ...@@ -238,7 +238,7 @@ class Customer_model extends MY_Model{
/** /**
* *
* 后台管理 渠道分布分销列表 * 后台管理 渠道分布分销列表
* @param int $where * @param int $where
* @param int $offset 结果偏移量 * @param int $offset 结果偏移量
...@@ -276,16 +276,16 @@ class Customer_model extends MY_Model{ ...@@ -276,16 +276,16 @@ class Customer_model extends MY_Model{
} }
$this->db->group_by('CB.id'); $this->db->group_by('CB.id');
$this->db->order_by('CB.user_id desc'); $this->db->order_by('CB.user_id desc');
$query = $this->db->get(null,$page_size, ($page-1) * $page_size); $query = $this->db->get(null,$page_size, ($page-1) * $page_size);
if($query->num_rows() > 0) if($query->num_rows() > 0)
{ {
return $query->result_array(); return $query->result_array();
} }
return false; return false;
} }
public function get_channel_page_count($where = '') public function get_channel_page_count($where = '')
{ {
$this->db->select('count(*) total'); $this->db->select('count(*) total');
...@@ -303,7 +303,7 @@ class Customer_model extends MY_Model{ ...@@ -303,7 +303,7 @@ class Customer_model extends MY_Model{
{ {
$this->db->where($where); $this->db->where($where);
} }
$query = $this->db->get(); $query = $this->db->get();
if($query->num_rows() > 0) if($query->num_rows() > 0)
{ {
...@@ -314,7 +314,7 @@ class Customer_model extends MY_Model{ ...@@ -314,7 +314,7 @@ class Customer_model extends MY_Model{
} }
/** /**
* *
* 后台管理 分销推荐客户列表 * 后台管理 分销推荐客户列表
* @param int $where * @param int $where
* @param int $offset 结果偏移量 * @param int $offset 结果偏移量
...@@ -349,9 +349,9 @@ class Customer_model extends MY_Model{ ...@@ -349,9 +349,9 @@ class Customer_model extends MY_Model{
} }
$this->db->group_by('CB.id'); $this->db->group_by('CB.id');
$this->db->order_by('CB.id desc'); $this->db->order_by('CB.id desc');
$query = $this->db->get(null,$page_size, ($page-1) * $page_size); $query = $this->db->get(null,$page_size, ($page-1) * $page_size);
if($query->num_rows() > 0) if($query->num_rows() > 0)
{ {
return $query->result_array(); return $query->result_array();
...@@ -362,7 +362,7 @@ class Customer_model extends MY_Model{ ...@@ -362,7 +362,7 @@ class Customer_model extends MY_Model{
//统计所属分销客户的总数 //统计所属分销客户的总数
public function get_distributor_page_count($where = '') public function get_distributor_page_count($where = '')
{ {
$this->db->select('count(DISTINCT CB.id) total'); $this->db->select('count(DISTINCT CB.id) total');
$this->db->from('tb_customer_building CB'); $this->db->from('tb_customer_building CB');
$this->db->join($this->table . ' C', 'CB.customer_id = C.id', 'left'); $this->db->join($this->table . ' C', 'CB.customer_id = C.id', 'left');
...@@ -372,13 +372,15 @@ class Customer_model extends MY_Model{ ...@@ -372,13 +372,15 @@ class Customer_model extends MY_Model{
$this->db->join('tb_user US', 'US.id = CB.sale_id', 'left'); $this->db->join('tb_user US', 'US.id = CB.sale_id', 'left');
$this->db->join('tb_distributor D', 'D.id = CB.distributor_id', 'left'); $this->db->join('tb_distributor D', 'D.id = CB.distributor_id', 'left');
$this->db->join('tb_building_distributor_relate RR', 'RR.distributor_id = D.id', 'left'); $this->db->join('tb_building_distributor_relate RR', 'RR.distributor_id = D.id', 'left');
$this->db->join('tb_channel TC', 'TC.id = D.channel_id', 'left');
$this->db->join('tb_manager M', 'M.id = TC.manager_id', 'left');
if(!empty($where)) if(!empty($where))
{ {
$this->db->where($where); $this->db->where($where);
} }
$query = $this->db->get(); $query = $this->db->get();
if($query->num_rows() > 0) if($query->num_rows() > 0)
{ {
$return = $query->row_array(); $return = $query->row_array();
...@@ -388,7 +390,7 @@ class Customer_model extends MY_Model{ ...@@ -388,7 +390,7 @@ class Customer_model extends MY_Model{
} }
/** /**
* *
* 后台管理 统计销售分页数据 * 后台管理 统计销售分页数据
* @param int $where * @param int $where
* @param int $offset 结果偏移量 * @param int $offset 结果偏移量
...@@ -401,7 +403,7 @@ class Customer_model extends MY_Model{ ...@@ -401,7 +403,7 @@ class Customer_model extends MY_Model{
{ {
$this->db->select( $this->db->select(
'C.customer_user, C.customer_mobile, C.create_time, 'C.customer_user, C.customer_mobile, C.create_time,
CB.id, CB.customer_id, CB.building_id, B.building_title, CB.distribution_status, CB.order_time, CB.deal_price, CB.payed_price, CB.payed_status, CB.id, CB.customer_id, CB.building_id, B.building_title, CB.distribution_status, CB.order_time, CB.deal_price, CB.payed_price, CB.payed_status,
R.region_code, R.region_name, R.region_code, R.region_name,
CB.sale_id, UP.user_name sale_name, UP.user_mobile sale_user_mobile, CB.sale_id, UP.user_name sale_name, UP.user_mobile sale_user_mobile,
CB.manager_id, UM.user_name manager_name, CB.manager_id, UM.user_name manager_name,
...@@ -422,7 +424,7 @@ class Customer_model extends MY_Model{ ...@@ -422,7 +424,7 @@ class Customer_model extends MY_Model{
$this->db->where($where); $this->db->where($where);
} }
$this->db->order_by('CB.sale_id desc'); $this->db->order_by('CB.sale_id desc');
$query = $this->db->get(null,$page_size, ($page-1) * $page_size); $query = $this->db->get(null,$page_size, ($page-1) * $page_size);
if($query->num_rows() > 0) if($query->num_rows() > 0)
{ {
...@@ -446,7 +448,7 @@ class Customer_model extends MY_Model{ ...@@ -446,7 +448,7 @@ class Customer_model extends MY_Model{
{ {
$this->db->where($where); $this->db->where($where);
} }
$query = $this->db->get(); $query = $this->db->get();
if($query->num_rows() > 0) if($query->num_rows() > 0)
{ {
...@@ -456,7 +458,7 @@ class Customer_model extends MY_Model{ ...@@ -456,7 +458,7 @@ class Customer_model extends MY_Model{
return 0; return 0;
} }
/** /**
* *
* 详情 * 详情
* @param int $where * @param int $where
* @return array 包含统计起止时间的数组 * @return array 包含统计起止时间的数组
...@@ -490,8 +492,8 @@ class Customer_model extends MY_Model{ ...@@ -490,8 +492,8 @@ class Customer_model extends MY_Model{
} }
return array(); return array();
} }
/** /**
* *
* 前台 分页数据 * 前台 分页数据
...@@ -516,7 +518,7 @@ class Customer_model extends MY_Model{ ...@@ -516,7 +518,7 @@ class Customer_model extends MY_Model{
$this->db->where($where); $this->db->where($where);
} }
$this->db->order_by('C.id','desc'); $this->db->order_by('C.id','desc');
$query = $this->db->get(null,$page_size, ($page-1) * $page_size); $query = $this->db->get(null,$page_size, ($page-1) * $page_size);
if($query->num_rows() > 0) if($query->num_rows() > 0)
{ {
...@@ -549,9 +551,9 @@ class Customer_model extends MY_Model{ ...@@ -549,9 +551,9 @@ class Customer_model extends MY_Model{
$this->db->where($where); $this->db->where($where);
} }
$this->db->order_by('C.id','desc'); $this->db->order_by('C.id','desc');
$query = $this->db->get(null,$page_size, ($page-1) * $page_size); $query = $this->db->get(null,$page_size, ($page-1) * $page_size);
if($query->num_rows() > 0) if($query->num_rows() > 0)
{ {
return $query->result_array(); return $query->result_array();
...@@ -581,7 +583,7 @@ class Customer_model extends MY_Model{ ...@@ -581,7 +583,7 @@ class Customer_model extends MY_Model{
$this->db->where($where); $this->db->where($where);
} }
$this->db->order_by('U.id','desc'); $this->db->order_by('U.id','desc');
$query = $this->db->get(null,$page_size, ($page-1) * $page_size); $query = $this->db->get(null,$page_size, ($page-1) * $page_size);
if($query->num_rows() > 0) if($query->num_rows() > 0)
{ {
...@@ -629,7 +631,7 @@ class Customer_model extends MY_Model{ ...@@ -629,7 +631,7 @@ class Customer_model extends MY_Model{
$this->db->where($where); $this->db->where($where);
} }
$this->db->order_by('U.id','desc'); $this->db->order_by('U.id','desc');
$query = $this->db->get(null,$page_size, ($page-1) * $page_size); $query = $this->db->get(null,$page_size, ($page-1) * $page_size);
if($query->num_rows() > 0) if($query->num_rows() > 0)
{ {
...@@ -637,7 +639,7 @@ class Customer_model extends MY_Model{ ...@@ -637,7 +639,7 @@ class Customer_model extends MY_Model{
} }
return false; return false;
} }
/** /**
* 判断客户推荐是否存在 * 判断客户推荐是否存在
* @param string $where * @param string $where
...@@ -666,7 +668,7 @@ class Customer_model extends MY_Model{ ...@@ -666,7 +668,7 @@ class Customer_model extends MY_Model{
$this->db->select('id') $this->db->select('id')
->from($this->table) ->from($this->table)
->where("customer_mobile = '{$mobile}'"); ->where("customer_mobile = '{$mobile}'");
$query = $this->db->get(null); $query = $this->db->get(null);
if($query->num_rows() > 0) if($query->num_rows() > 0)
{ {
...@@ -688,9 +690,9 @@ class Customer_model extends MY_Model{ ...@@ -688,9 +690,9 @@ class Customer_model extends MY_Model{
public function get_customer_building_manager($where = '', $page = 1, $page_size = 0, $order = NULL) public function get_customer_building_manager($where = '', $page = 1, $page_size = 0, $order = NULL)
{ {
$this->db->select( $this->db->select(
'C.id, C.user_id, C.customer_user, C.customer_mobile, 'C.id, C.user_id, C.customer_user, C.customer_mobile,
CB.id as cb_id, CB.customer_id, CB.building_id, CB.deal_price, CB.payed_price, CB.sale_id, CB.recommend_status, CB.order_time, CB.id as cb_id, CB.customer_id, CB.building_id, CB.deal_price, CB.payed_price, CB.sale_id, CB.recommend_status, CB.order_time,
B.building_title, B.building_title,
M.user_name manager_name, M.true_name manager_true_name, M.user_name manager_name, M.true_name manager_true_name,
S.user_name sale_name, S.true_name sale_true_name, S.user_name sale_name, S.true_name sale_true_name,
U.user_name user_name, U.true_name user_true_name,' U.user_name user_name, U.true_name user_true_name,'
...@@ -701,25 +703,25 @@ class Customer_model extends MY_Model{ ...@@ -701,25 +703,25 @@ class Customer_model extends MY_Model{
->join('tb_user M', 'M.id = CB.manager_id', 'left') ->join('tb_user M', 'M.id = CB.manager_id', 'left')
->join('tb_user S', 'S.id = CB.sale_id', 'left') ->join('tb_user S', 'S.id = CB.sale_id', 'left')
->join('tb_user U', 'U.id = C.user_id', 'left'); ->join('tb_user U', 'U.id = C.user_id', 'left');
if(!empty($where)) if(!empty($where))
{ {
$this->db->where($where); $this->db->where($where);
} }
$this->db->order_by('C.id','desc'); $this->db->order_by('C.id','desc');
$query = $this->db->get(null,$page_size, ($page-1) * $page_size); $query = $this->db->get(null,$page_size, ($page-1) * $page_size);
if($query->num_rows() > 0) if($query->num_rows() > 0)
{ {
return $query->result_array(); return $query->result_array();
} }
return false; return false;
} }
/** /**
* *
* 后台管理 统计经纪人数据 * 后台管理 统计经纪人数据
* @param int $where * @param int $where
* @param int $offset 结果偏移量 * @param int $offset 结果偏移量
...@@ -747,9 +749,9 @@ class Customer_model extends MY_Model{ ...@@ -747,9 +749,9 @@ class Customer_model extends MY_Model{
//} //}
$this->db->order_by('U.id desc'); $this->db->order_by('U.id desc');
$query = $this->db->get(null,$page_size, ($page-1) * $page_size); $query = $this->db->get(null,$page_size, ($page-1) * $page_size);
if($query->num_rows() > 0) if($query->num_rows() > 0)
{ {
return $query->result_array(); return $query->result_array();
...@@ -758,7 +760,7 @@ class Customer_model extends MY_Model{ ...@@ -758,7 +760,7 @@ class Customer_model extends MY_Model{
} }
/** /**
* *
* 后台管理 统计经纪人数据 * 后台管理 统计经纪人数据
* @param int $where * @param int $where
* @param int $offset 结果偏移量 * @param int $offset 结果偏移量
...@@ -783,9 +785,9 @@ class Customer_model extends MY_Model{ ...@@ -783,9 +785,9 @@ class Customer_model extends MY_Model{
$this->db->group_by('CB.user_id,R.building_id'); $this->db->group_by('CB.user_id,R.building_id');
$this->db->order_by('U.id desc'); $this->db->order_by('U.id desc');
$query = $this->db->get(); $query = $this->db->get();
if($query->num_rows() > 0) if($query->num_rows() > 0)
{ {
$return = $query->row_array(); $return = $query->row_array();
...@@ -796,7 +798,7 @@ class Customer_model extends MY_Model{ ...@@ -796,7 +798,7 @@ class Customer_model extends MY_Model{
/** /**
* *
* 后台管理 统计经纪人数据(新) * 后台管理 统计经纪人数据(新)
* @param int $where * @param int $where
* @param int $offset 结果偏移量 * @param int $offset 结果偏移量
...@@ -818,9 +820,9 @@ class Customer_model extends MY_Model{ ...@@ -818,9 +820,9 @@ class Customer_model extends MY_Model{
} }
$this->db->order_by('U.id desc'); $this->db->order_by('U.id desc');
$query = $this->db->get(); $query = $this->db->get();
if($query->num_rows() > 0) if($query->num_rows() > 0)
{ {
$return = $query->row_array(); $return = $query->row_array();
...@@ -830,7 +832,7 @@ class Customer_model extends MY_Model{ ...@@ -830,7 +832,7 @@ class Customer_model extends MY_Model{
} }
/** /**
* *
* 后台管理 统计经纪人数据(新) * 后台管理 统计经纪人数据(新)
* @param int $where * @param int $where
* @param int $offset 结果偏移量 * @param int $offset 结果偏移量
...@@ -859,8 +861,8 @@ class Customer_model extends MY_Model{ ...@@ -859,8 +861,8 @@ class Customer_model extends MY_Model{
$query = $this->db->get(null,$page_size, ($page-1) * $page_size); $query = $this->db->get(null,$page_size, ($page-1) * $page_size);
} else { } else {
$query = $this->db->get(); $query = $this->db->get();
} }
if($query->num_rows() > 0) if($query->num_rows() > 0)
{ {
$return = $query->result_array(); $return = $query->result_array();
...@@ -868,9 +870,9 @@ class Customer_model extends MY_Model{ ...@@ -868,9 +870,9 @@ class Customer_model extends MY_Model{
} }
return 0; return 0;
} }
/** /**
* *
* 后台管理 分销推荐客户列表统计 * 后台管理 分销推荐客户列表统计
* @param int $where * @param int $where
* @param int $offset 结果偏移量 * @param int $offset 结果偏移量
...@@ -893,9 +895,9 @@ class Customer_model extends MY_Model{ ...@@ -893,9 +895,9 @@ class Customer_model extends MY_Model{
$this->db->where($where); $this->db->where($where);
} }
$this->db->order_by('R.id desc'); $this->db->order_by('R.id desc');
$query = $this->db->get(null,$page_size, ($page-1) * $page_size); $query = $this->db->get(null,$page_size, ($page-1) * $page_size);
if($query->num_rows() > 0) if($query->num_rows() > 0)
{ {
return $query->result_array(); return $query->result_array();
...@@ -905,7 +907,7 @@ class Customer_model extends MY_Model{ ...@@ -905,7 +907,7 @@ class Customer_model extends MY_Model{
public function get_recommend_page_count($where = '') public function get_recommend_page_count($where = '')
{ {
$this->db->select('count(*) total'); $this->db->select('count(*) total');
$this->db->from('tb_building_distributor_relate R'); $this->db->from('tb_building_distributor_relate R');
$this->db->join('tb_distributor D', 'R.distributor_id = D.id', 'left'); $this->db->join('tb_distributor D', 'R.distributor_id = D.id', 'left');
...@@ -915,7 +917,7 @@ class Customer_model extends MY_Model{ ...@@ -915,7 +917,7 @@ class Customer_model extends MY_Model{
{ {
$this->db->where($where); $this->db->where($where);
} }
$query = $this->db->get(); $query = $this->db->get();
if($query->num_rows() > 0) if($query->num_rows() > 0)
{ {
...@@ -935,7 +937,7 @@ class Customer_model extends MY_Model{ ...@@ -935,7 +937,7 @@ class Customer_model extends MY_Model{
$this->db->from('tb_customer C'); $this->db->from('tb_customer C');
$this->db->where('C.rongchuang_id <> " "'); $this->db->where('C.rongchuang_id <> " "');
$query = $this->db->get(); $query = $this->db->get();
if($query->num_rows() > 0) if($query->num_rows() > 0)
{ {
$return = $query->result_array(); $return = $query->result_array();
...@@ -948,7 +950,7 @@ class Customer_model extends MY_Model{ ...@@ -948,7 +950,7 @@ class Customer_model extends MY_Model{
$this->db->from('tb_customer C'); $this->db->from('tb_customer C');
$this->db->where('C.rongchuang_id',$rcId); $this->db->where('C.rongchuang_id',$rcId);
$query = $this->db->get(); $query = $this->db->get();
if($query->num_rows() > 0) if($query->num_rows() > 0)
{ {
$return = $query->result_array(); $return = $query->result_array();
...@@ -956,4 +958,4 @@ class Customer_model extends MY_Model{ ...@@ -956,4 +958,4 @@ class Customer_model extends MY_Model{
} }
return 0; return 0;
} }
} }
\ No newline at end of file
...@@ -90,6 +90,7 @@ ...@@ -90,6 +90,7 @@
<table class="table table-striped table-bordered table-hover" id="sample_1"> <table class="table table-striped table-bordered table-hover" id="sample_1">
<thead> <thead>
<tr> <tr>
<th>序号</th>
<th>用户ID</th> <th>用户ID</th>
<th>客户姓名</th> <th>客户姓名</th>
<th>客户电话</th> <th>客户电话</th>
...@@ -109,6 +110,7 @@ ...@@ -109,6 +110,7 @@
foreach($customers as $customer): foreach($customers as $customer):
?> ?>
<tr> <tr>
<td><?php echo $num_start++ ; ?></td>
<td><?php echo $customer['id'];?></td> <td><?php echo $customer['id'];?></td>
<td><?php echo $customer['customer_user'];?></td> <td><?php echo $customer['customer_user'];?></td>
<td><?php echo $customer['customer_mobile']?></td> <td><?php echo $customer['customer_mobile']?></td>
......
...@@ -88,6 +88,7 @@ ...@@ -88,6 +88,7 @@
<table class="table table-striped table-bordered table-hover" id="sample_1"> <table class="table table-striped table-bordered table-hover" id="sample_1">
<thead> <thead>
<tr> <tr>
<th>序号</th>
<th>用户ID</th> <th>用户ID</th>
<th>客户姓名</th> <th>客户姓名</th>
<th>客户电话</th> <th>客户电话</th>
...@@ -107,6 +108,7 @@ ...@@ -107,6 +108,7 @@
foreach($customers as $customer): foreach($customers as $customer):
?> ?>
<tr> <tr>
<td><?php echo $num_start++ ; ?></td>
<td><?php echo $customer['id'];?></td> <td><?php echo $customer['id'];?></td>
<td><?php echo $customer['customer_user'];?></td> <td><?php echo $customer['customer_user'];?></td>
<td><?php echo $customer['customer_mobile']?></td> <td><?php echo $customer['customer_mobile']?></td>
...@@ -227,7 +229,7 @@ ...@@ -227,7 +229,7 @@
var e = $("#time").val = ""; var e = $("#time").val = "";
location.href = "<?php echo site_url('admin/channeladmin/customerSearch')?>?distributor_name="+a+"&status="+b+"&channel_id="+c+"&building_title="+d+"&time="+e location.href = "<?php echo site_url('admin/channeladmin/customerSearch')?>?distributor_name="+a+"&status="+b+"&channel_id="+c+"&building_title="+d+"&time="+e
}) })
}); });
......
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