chengkun
2025-04-18 1bb985f32f2efe0f9dd69f3cf29a1c809b1cf96d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
<?php
 
/*
 * $Author :PHPYUN开发团队
 *
 * 官网: http://www.phpyun.com
 *
 * 版权所有 2009-2021 宿迁鑫潮信息技术有限公司,并保留所有权利。
 *
 * 软件声明:未经授权前提下,不得用于商业运营、二次开发以及任何形式的再次发布。
 */
class crm_salesman_list_controller extends adminCommon
{
 
    function crm_class()
    {
        $cacheM     =   $this->MODEL('cache');
 
        $crmCache   =   $cacheM->GetCache(array('crm'));
 
        $this -> yunset(array('cache' => $crmCache, 'crmClassName' => $crmCache['crmclass_name'], 'crmDepart' => $crmCache['crmdata']['crm_depart']));
    }
 
    /**
     * @desc CRM管理 - 列表
     */
    function index_action()
    {
        $this->crm_class();
 
        $adminM     =   $this->MODEL('admin');
 
        $where['did']       =   0;
        $where['is_crm']    =    1;
        $typeStr    =   intval($_GET['type']);
        $keywordStr =   trim($_GET['keyword']);
        
        if (empty($keywordStr)) {
 
            if ($typeStr == 1) {
                
                $where['username']  =   array('like', $keywordStr);
            }else if ($typeStr == 2) {
                
                $where['name']      =   array('like', $keywordStr);
            }else if ($typeStr == 3) {
                
                $where['uid']       =   array('=', $keywordStr);
            }  
            
            $urlarr['type']         =   $typeStr;
            $urlarr['keyword']      =   $keywordStr;
        }
        $urlarr            =   $_GET;
        $urlarr['page'] =   "{{page}}";
        $pageurl        =   Url($_GET['m'], $urlarr, 'admin');
        $pageM          =   $this->MODEL('page');
        $pages          =   $pageM->pageList('admin_user', $where, $pageurl, $_GET['page']);
 
        if ($pages['total'] > 0) {
             
            if ($_GET['order'] && $_GET['t']) {
                
                $where['orderby']   =   $_GET['t'].','.$_GET['order'];
                $urlarr['order']    =   $_GET['order'];
                $urlarr['t']        =   $_GET['t'];
            } else {
                
                $where['orderby']   =   array('uid,desc');
            }
            $where['limit']         =   $pages['limit'];
 
            $rows   =   $adminM->getList($where, array('utype' => 'crm', 'field' => '`uid`,`name`,`status`,`username`,`did`,`depart`,`org`'));
            $this->yunset('userrows', $rows);
        }
 
        $this->yuntpl(array('admin/crm_salesman_list'));
    }
 
    /**
     * @desc 分配客户 - 列表页
     */
    public function assign_company_action()
    {
        $where['crm_uid']   =   0;
        $urlarr                =   $_GET;
        $urlarr['c']        =   $_GET['c'];
        $urlarr['uid']      =   $_GET['uid'];
        $urlarr['page']     =   "{{page}}";
        
        $pageurl    =   Url($_GET['m'], $urlarr, 'admin');
        
        $pageM      =   $this->MODEL('page');
        $pages      =   $pageM->pageList('company', $where, $pageurl, $_GET['page']);
 
        if ($pages['total'] > 0) {
            
            if ($_GET['order'] && $_GET['t']) {
 
                $where['orderby']   =   $_GET['t'].','.$_GET['order'];
                $urlarr['order']    =   $_GET['order'];
                $urlarr['t']        =   $_GET['t'];
            } else {
                
                $where['orderby']   =   array('uid,desc');
            }
            
            $where['limit'] =   $pages['limit'];
            $companyM       =   $this->MODEL('company');
            $rows           =   $companyM->getList($where, array('field' => '`uid`,`name`'));
            $this->yunset('company', $rows['list']);
        }
 
        $this->yuntpl(array('admin/crm_assign_company'));
    }
 
    /**
     * @desc 分配客户
     */
    public function ajax_assign_action()
    {
        $salesmanId =   isset($_POST['uid']) ? $_POST['uid'] : 0;
        $companyId  =   isset($_POST['comid']) ? $_POST['comid'] : '';
 
        if ($salesmanId == 0 || $companyId == '') {
            echo '请选择企业进行分配';
            exit();
        }
        $comids =   @explode(',',$companyId);
        $comM   =   $this->MODEL('company');
        $return =   $comM->upInfo($comids, '', array('crm_uid' => $salesmanId, 'crm_time' => time()));
        
        echo $return ? '1' : '分配失败,数据错误'; exit();
    }
 
    /**
     * @desc CRM 在职/离职 设置
     */ 
    function status_action()
    {
        $adminM =   $this->MODEL('admin');
 
        $uid    =   intval($_POST['uid']);
 
        $nid    =   $adminM->upInfo(array('status' => (int) $_POST['status']), array('uid' => $uid));
 
        if ($nid) {
            
            $status    =    (int)$_POST['status'];
 
            $msg    =    $status == 1 ? '在职' : '离职';
 
            $this->MODEL('log')->addAdminLog("业务员(ID:" . $uid . ")".$msg."设置成功!");
            
            if($status == 2){    //    离职设置,客户状态重置未分配
 
                $companyM   =   $this->MODEL('company');
                $companyM -> upInfo('', array('crm_uid' => $uid), array('crm_uid' => 0, 'crm_time' => 0));
            }
 
            $this->ACT_layer_msg("业务员(ID:" . $uid . ")".$msg."设置成功!", 9, $_SERVER['HTTP_REFERER'], 2);
 
        } else {
 
            $this->ACT_layer_msg("设置失败!", 8, $_SERVER['HTTP_REFERER']);
        }
    }
 
    /**
     * @desc  批量转移客户 - 列表
     */
    public function shift_company_action()
    {
        $where['crm_uid']   =   $_GET['uid'];
        $urlarr                =   $_GET;
        $urlarr['c']        =   $_GET['c'];
        $urlarr['uid']      =   $_GET['uid'];
        $urlarr['page']     =   "{{page}}";
        
        $pageurl            =   Url($_GET['m'], $urlarr, 'admin');
        
        $pageM  =   $this->MODEL('page');
        $pages  =   $pageM->pageList('company', $where, $pageurl, $_GET['page']);
 
        if ($pages['total'] > 0) {
            if ($_GET['order'] && $_GET['t']) {
 
                $where['orderby']   =   $_GET['t'].','.$_GET['order'];
                $urlarr['order']    =   $_GET['order'];
                $urlarr['t']        =   $_GET['t'];
            } else {
                
                $where['orderby']   =   array('uid,desc');
            }
            $where['limit'] =   $pages['limit'];
            $companyM       =   $this->MODEL('company');
            $rows           =   $companyM->getList($where, array('field' => '`uid`,`name`,`isfollow`, `f_time'));
            $this->yunset('company', $rows['list']);
        }
 
        $adminM             =   $this->MODEL('admin');
         
        $uwhere['is_crm']   =   1;
        $uwhere['did']        =   0;
        $uwhere['uid']        =   array('<>', $_GET['uid']);
 
        $new_uid            =   $adminM -> getList($uwhere, array('field' => '`uid`,`name`'));
        $this->yunset('new_uid', $new_uid);
 
        $this->yuntpl(array('admin/crm_shift_company'));
    }
 
    /**
     * @desc 批量转移客户
     */
    public function ajax_shift_action()
    {
        $salesmanId =   isset($_POST['uid']) ? $_POST['uid'] : 0;
        $companyId  =   isset($_POST['comid']) ? $_POST['comid'] : '';
        $new_uid    =   isset($_POST['new_uid']) ? $_POST['new_uid'] : 0;
 
        if ($salesmanId == 0 || $companyId == '' || $new_uid == 0) {
            echo '请选择企业/业务员进行转移';
            exit();
        }
        $companyId  =   @explode(',', $companyId);
        
        $comM   =   $this->MODEL('company');
        $return =   $comM->upInfo($companyId, array('crm_uid' => $salesmanId), array('crm_uid' => $new_uid, 'crm_time' => time()));
 
        echo $return ? '1' : '转移失败,数据库错误'; exit();
    }
    
    function set_search(){
        
        $cacheM     =   $this->MODEL('cache');
        
        $crmCache   =   $cacheM -> GetCache(array('crm'));
        
        $this->yunset(array('cache'=>$crmCache,'crmClassName' => $crmCache['crmclass_name'], 'crmStatus' => $crmCache['crmdata']['client_status'], 'crmType' => $crmCache['crmdata']['client_type']));
        
        $yyzz       =   array('1'=>'已认证', '2'=>'待审核', '3'=>'未通过', '4' => '待认证');
        
        $ratingM    =   $this -> MODEL('rating');
        $ratingArr  =   $ratingM -> getList(array( 'category' => '1', 'orderby' => 'sort' ), array('field'=>'`id`,`name`'));
        $vipEtime   =   array('1'=>'三天内', '2'=>'七天内', '3'=>'一月内', '4' => '已到期');
        
        $orders     =   array('1'=>'客户ID','2'=> '更新日期', '3'=>'VIP到期时间');
        
        $lastFtime  =   array('1'=>'从未跟进', '2'=>'今天', '3'=>'三天未跟进', '4'=>'七天未跟进', '5'=>'一月未跟进', '6'=>'一百天未跟进');
        $nextFtime  =   array('1'=>'今天', '2'=>'明天', '3'=>'三天内', '4'=>'七天内', '5'=>'一月内');
        
        $this -> yunset(array('yyzzStatus' => $yyzz, 'ratingArr' => $ratingArr, 'vipEtime' => $vipEtime, 'orders' => $orders, 'lastFtime' => $lastFtime, 'nextFtime' => $nextFtime));
        
        //提取顾问信息
        $adminM    =   $this->MODEL('admin');
         
        $crmUser   =   $adminM -> getList(array('is_crm' => '1'));
        $this -> yunset('crmUser',$crmUser);
        
        $this->yunset('todayStart', strtotime('today'));
    }
 
    /**
     * @desc CRM客户列表
     */
    public function customer_list_action()
    {
 
        $this -> set_search();
 
        $comM       =   $this -> MODEL('company');
        $userInfoM  =   $this -> MODEL('userinfo');
        $crmM       =   $this -> MODEL('crm');
 
        if (isset($_GET['iscrm']) && $_GET['iscrm'] == 1){
 
            $where['crm_uid']   =   array('>', 0);
            $urlarr['iscrm']    =   $_GET['iscrm'];
        }
 
        if ($_GET['auid']) {
 
            $adminM             =   $this->MODEL('admin');
            $adminUserInfo      =   $adminM -> getAdminUser(array('uid' => $_GET['auid']));
            $this->yunset('adminUserInfo', $adminUserInfo);
            $where['crm_uid']   =   $_GET['auid'];
            $urlarr['auid']     =   $_GET['auid'];
        }
 
        if (!empty($_GET['crm_status'])) {
 
            $crm_status             =   intval($_GET['crm_status']);
            $where['crm_status']    =   $crm_status;
            $urlarr['crm_status']   =   $crm_status;
        }
 
        if (!empty($_GET['crmType'])) {
 
            $crmType                =   intval($_GET['crmType']);
            $where['crm_type']      =   $crmType;
            $urlarr['crmType']      =   $crmType;
        }
 
        if (!empty($_GET['yyzz_status'])) {
 
            $yyzz_status            =   intval($_GET['yyzz_status']);
            if ($yyzz_status == 1) {
 
                $where['yyzz_status']   =   $yyzz_status;
            } else if ($yyzz_status == 4) {
 
                $where['yyzz_status']   =   0;
            } else {
                if ($yyzz_status == 2) {
 
                    $certWhere          =   array('type' => 3, 'status' => 0);
                } elseif ($yyzz_status == 3) {
 
                    $certWhere          =   array('type' => 3, 'status' => 3);
                }
                $certList   =   $comM->getCertList($certWhere, array('field' => '`uid`'));
                $uidArrA    =   array();
                foreach ($certList as $cv) {
                    $uidArrA[]  =   $cv['uid'];
                }
                $where['uid']   =   array('in', pylode(',', $uidArrA));
            }
            $urlarr['yyzz_status']  =   $yyzz_status;
        }
 
        if (!empty($_GET['rating'])) {
 
            $rating             =    intval($_GET['rating']);
            $where['rating']    =   $rating;
            $urlarr['rating']   =   $rating;
        }
 
        if (isset($_GET['vip']) && $_GET['vip'] == 1) {
 
            $where['PHPYUNBTWSTART_A']  =   '';
            $where['rating'][]          =   array('>', 0, 'and');
            $where['rating'][]          =   array('<>', $this->config['sy_free_id'], 'and');
            $where['PHPYUNBTWEND_A']    =   '';
            $urlarr['vip']              =   $_GET['vip'];
        }
 
        if (!empty($_GET['vipetime'])) {
 
            $etime  =   intval($_GET['vipetime']);
 
            if ($etime != 4) {
 
                if ($etime == 1) {
                    $num    =   '+3 days';
                }else if ($etime == 2) {
                    $num    =   '+7 days';
                }elseif ($etime == 3){
                    $num    =   '+1 month';
                }else if ($etime == 5) {
                    $num    =   '+15 days';
                }
 
                $where['PHPYUNBTWSTART_A']  =   '';
                $where['vipetime'][]        =   array('>', time(),'AND');
                $where['vipetime'][]        =   array('<', strtotime($num),'AND');
                $where['PHPYUNBTWEND_A']    =   '';
 
            }else{
 
                $where['PHPYUNBTWSTART_A']  =   '';
                $where['vipetime'][]        =   array('<', time(), '');
                $where['vipetime'][]        =   array('>', '0', '');
                $where['PHPYUNBTWEND_A']    =   '';
            }
 
            $urlarr['vipetime'] =   $etime;
 
        }
 
        if (isset($_GET['reg']) && $_GET['reg'] == 1) {
 
            $rList      =   $userInfoM->getList(array('reg_date' => array('>=', strtotime(date('Y-m-d'))), 'usertype' => 2), array('field' => 'uid'));
            $uidArrR    =   array();
            foreach ($rList as $rv) {
                $uidArrR[]  =   $rv['uid'];
            }
            $where['uid']   =   array('in', pylode(',', $uidArrR));
        }
 
        if (!empty($_GET['regStart']) || !empty($_GET['regEnd'])) {
 
            $regStart   =   strtotime($_GET['regStart']);
            $regEnd     =   strtotime($_GET['regEnd']) + 86400;
 
            $mWhere['PHPYUNBTWSTART_A']     =   '';
            $mWhere['reg_date'][]           =   array('>', $regStart, 'AND');
            $mWhere['reg_date'][]           =   array('<', $regEnd, 'AND');
            $mWhere['PHPYUNBTWEND_A']       =   '';
 
            $memberList     =   $userInfoM -> getList($mWhere, array('field' => 'uid'));
 
            $uidArrB        =   array();
            foreach ($memberList as $mv) {
                $uidArrB[]  =   $mv['uid'];
            }
 
            $where['uid']   =   array('in', pylode(',', $uidArrB));
 
            $urlarr['regStart'] =   $_GET['regStart'];
            $urlarr['regEnd']   =   $_GET['regEnd'];
        }
 
        if (!empty($_GET['isfollow'])) {
            $where['isfollow']  =   $_GET['isfollow'] == 1 ? 1 : 0;
            $urlarr['isfollow'] =   $_GET['isfollow'];
        }
 
        if (isset($_GET['newF'])){
 
            $where['f_time']    =   array('>', strtotime(date('Y-m-d')));
            $urlarr['newF']     =   $_GET['newF'];
        }
 
        if (isset($_GET['recent'])){
 
            $where['f_time']    =   array('>', strtotime('-7 days'));
            $urlarr['recent']   =   $_GET['recent'];
        }
 
        if (!empty($_GET['lastFtime'])) {
 
            $lastFtime = intval($_GET['lastFtime']);
 
            if ($lastFtime == 1) {
 
                $where['isfollow'] = '0';
            } else {
 
                $where['isfollow'] = 1;
 
                if ($lastFtime == 2) {
 
                    $where['f_time'] = array('>', strtotime(date('Y-m-d')));
                } elseif ($lastFtime == 3) {
 
                    $where['f_time'] = array('<', strtotime('-3 day'));
                } elseif ($lastFtime == 4) {
 
                    $where['f_time'] = array('<', strtotime('-7 day'));
                } elseif ($lastFtime == 5) {
 
                    $where['f_time'] = array('<', strtotime('-1 month'));
                } elseif ($lastFtime == 6) {
 
                    $where['f_time'] = array('<', strtotime('-100 day'));
                }
            }
            $urlarr['lastFtime'] = $lastFtime;
        }
 
        if (!empty($_GET['nextFtime'])) {
 
            $nextFtime  =   intval($_GET['nextFtime']);
 
            $taskWhere  =   array();
 
            if($nextFtime == 1){
 
                $taskWhere['stime']             =   array('<', strtotime(date('Y-m-d 23:59:59')));  //  之前未完成的跟进同步显示
            }elseif ($nextFtime == 2){
 
                $taskWhere['PHPYUNBTWSTART_A']  =   '';
                $taskWhere['stime'][]           =   array('>', strtotime(date('Y-m-d 23:59:59')));
                $taskWhere['stime'][]           =   array('<', strtotime(date('Y-m-d 23:59:59')) + 86400);
                $taskWhere['PHPYUNBTWEND_A']    =   '';
            }elseif ($nextFtime == 3){
 
                $taskWhere['PHPYUNBTWSTART_A']  =   '';
                $taskWhere['stime'][]           =   array('>', time());
                $taskWhere['stime'][]           =   array('<', strtotime('+3 day'));
                $taskWhere['PHPYUNBTWEND_A']    =   '';
            }elseif ($nextFtime == 4){
 
                $taskWhere['PHPYUNBTWSTART_A']  =   '';
                $taskWhere['stime'][]           =   array('>', time());
                $taskWhere['stime'][]           =   array('<', strtotime('+1 week'));
                $taskWhere['PHPYUNBTWEND_A']    =   '';
            }elseif ($nextFtime == 5){
 
                $taskWhere['PHPYUNBTWSTART_A']  =   '';
                $taskWhere['stime'][]           =   array('>', time());
                $taskWhere['stime'][]           =   array('<', strtotime('+1 month'));
                $taskWhere['PHPYUNBTWEND_A']    =   '';
            }
 
            if($_GET['auid']){
 
                $taskWhere['uid']   =   $_GET['auid'];
            }
            $taskList   =   $crmM -> getTaskList($taskWhere, array('field' => '`comid`'));
 
            $uidArrN    =   array();
            foreach ($taskList as $tv) {
 
                $uidArrN[]  =   $tv['comid'];
            }
 
            $where['uid']   =   array('in', pylode(',', $uidArrN));
        }
 
        if ($_GET['keyword']) {
 
            $keywordStr     =   trim($_GET['keyword']);
 
            $typeStr        =   intval($_GET['crm_type']);
 
            if (!empty($keywordStr)) {
 
                if ($typeStr == 1) {
 
                    $where['name']      =   array('like', $keywordStr);
 
                }else if($typeStr == 2){
 
                    $where['linkman']   =   array('like', $keywordStr);
 
                }else if($typeStr == 3){
 
                    $where['linktel']   =   array('like', $keywordStr);
 
                }else if($typeStr == 4){
 
                    $where['uid']       =   array('=', $keywordStr);
                }
 
            }
            $urlarr['crm_type']        =    $typeStr;
            $urlarr['keyword']        =    $keywordStr;
        }
 
        if ($_GET['time'] || $_GET['stime']) {
            if ($_GET['time']) {
                if ($_GET['time'] == -1) {
                    $timeBegin  =   mktime(0, 0, 0, date('m'), date('d'), date('Y'));
                    $timeEnd    =   time();
                } elseif ($_GET['time'] == 1) {
                    $timeBegin  =   mktime(0, 0, 0, date('m'), date('d'), date('Y')) - 86400;
                    $timeEnd    =   mktime(23, 59, 59, date('m'), date('d'), date('Y')) - 86400;
                } else {
                    $timeBegin  =   mktime(0, 0, 0, date('m'), date('d'), date('Y')) - $_GET['time'] * 86400;
                    $timeEnd    =   mktime(23, 59, 59, date('m'), date('d'), date('Y'));
                }
                $urlarr['time'] =   $_GET['time'];
            }else if ($_GET['stime']) {
                $stime          =   explode('-', $_GET['stime']);
                $etime          =   explode('-', $_GET['etime']);
                $timeBegin      =   mktime(0, 0, 0, $stime[1], $stime[2], $stime[0]);
                $timeEnd        =   mktime(23, 59, 59, $etime[1], $etime[2], $etime[0]);
                $urlarr['stime']=   $_GET['stime'];
            }
 
            $where['PHPYUNBTWSTART_A']  =   '';
            $where['crm_time'][]        =   array('>=', $timeBegin, '');
            $where['crm_time'][]        =   array('<', $timeEnd, '');
            $where['PHPYUNBTWEND_A']    =   '';
        }
 
        if ($_GET['crm_time']){
 
            $timeA  =   explode('-', $_GET['crm_time']);
            $month  =   (int)$timeA[1];
 
            $sTime  =   mktime(0, 0, 0, $month, 1, $timeA[0]);
            $eTime  =   mktime(23, 59, 59, $month+1, 0, $timeA[0]);
 
            $where['PHPYUNBTWSTART_A']  =   '';
            $where['crm_time'][]        =   array('>=', $sTime, '');
            $where['crm_time'][]        =   array('<', $eTime, '');
            $where['PHPYUNBTWEND_A']    =   '';
            $urlarr['crm_time']         =   $_GET['crm_time'];
        }
 
        if (!empty($_GET['ordertype'])) {
 
            $orderType  = intval($_GET['ordertype']);
 
            if ($orderType == 1) {
                $order  =   'uid';
            }else if ($orderType == 2) {
                $order  =   'lastupdate';
            }else if ($orderType == 3) {
                $order  =   'vipetime';
            }
 
            $urlarr['ordertype']    =   $orderType;
        }
 
        $urlarr                =   $_GET;
        $urlarr['page']        =    '{{page}}';
 
        $urlarr['c']        =    $_GET['c'];
 
        $pageurl            =    Url($_GET['m'], $urlarr, 'admin');
 
        $pageM              =    $this  -> MODEL('page');
 
        $pages              =    $pageM -> pageList('company', $where, $pageurl, $_GET['page']);
 
        if ($pages['total'] > 0) {
 
            if ($_GET['order']) {
 
                if ($_GET['t']) {
 
                    $where['orderby']   =   $_GET['t'].','.$_GET['order'];
                    $urlarr['t']        =   $_GET['t'];
                }else if($order){
 
                    $where['orderby']   =   $order.','.$_GET['order'];
                }else{
 
                    $where['orderby']   =   'uid';
                }
 
                $urlarr['order']    =   $_GET['order'];
            }
 
            $where['limit']         =   $pages['limit'];
 
            $listA                  =   $comM -> getList($where,array('utype' => 'crm'));
            $this -> yunset(array('rows' => $listA['list'],'auid' => intval($_SESSION['auid'])));
        }
 
 
        /**
         * @desc 今日跟进任务 ;今日需跟进客户数量
         */
        $toWhere        =   array(
            'uid'   =>  intval($_SESSION['auid']),
            'type'  =>  '22',
            'status'=>  '1',
            'stime' =>  array('<', strtotime(date('Y-m-d 23:59:59')))
        );
        $toFollowList   =   $crmM -> getTaskList($toWhere, array('field' => '`comid`'));
 
        $toUids =   array();
        foreach ($toFollowList as $toV) {
            $toUids[$toV['comid']]  =   $toV['comid'];
        }
        $todayNum   =   count($toUids) > 0 ? count($toUids) : 0;
 
        /**
         * @desc 跟进期限内未跟进客户数量 【期限参数:sy_crm_follow_deadline】
         */
        if ((int)$this->config['sy_crm_follow_deadline'] > 0) {
 
            $noFollowDeadList   =   $crmM -> getConcernList(array('auid' => intval($_SESSION['auid']), 'atime' => array('<', strtotime('- '.$this->config['sy_crm_follow_deadline'].' day'))), array('field' => '`uid`'));
 
            $noFollowUids   =   array();
            foreach ($noFollowDeadList as $noV) {
                $noFollowUids[$noV['uid']] = $noV['uid'];
            }
            $noNum1 =   count($noFollowUids) > 0 ? count($noFollowUids) : 0;    //  跟进后查过期限未跟进客户
 
            $noNum2 =   $comM -> getCompanyNum(array('crm_uid' => $_SESSION['auid'], 'isfollow' => '0', 'crm_time' => array('<', strtotime('- '.$this->config['sy_crm_follow_deadline'].' day')))); // 超期限从未跟进
 
            $noFollowNum    =   $noNum1 + $noNum2;
        }
 
        $this -> yunset(array('todayNum' => $todayNum, 'noFollowNum' => $noFollowNum));
 
        $AdminM            =    $this -> MODEL('admin');
        $adminUserList    =    $AdminM -> getList(array(),array('field'=>'`uid`,username'));
        $this->yunset('adminUserList',$adminUserList);
 
 
        $this->yuntpl(array('admin/crm_customer_list'));
    }
}
?>