'设计', '2' => '造价管理', '3' => '业主', '4' => '交通局', '5' => '公路局', '6' => '审计', '7' => '财政', '8' => '审核', '9' => '施工', '10' => '咨询', '11' => '招标代理', '12' => '监理', '13' => '学校', '14' => '个人', '15' => '合作伙伴' ); public $tooltip = array ( '1' => array ( 'L', '点击筛选标签' ), '2' => array ( 'M', '点击筛选标签' ), '3' => array ( 'N', '点击筛选标签' ), '4' => array ( 'O', '点击筛选标签' ), '5' => array ( 'P', '点击筛选标签' ), '6' => array ( 'Q', '点击筛选标签' ), '7' => array ( 'R', '点击筛选标签' ) ); public $webPath = "http://cld.smartcost.com.cn/upload/emailAnnex/"; function __construct() { //phpinfo();die; // include './protected/config/common.conf.php'; // include $config['BASE_PATH'].'diagnostic/debug.php'; if (isset ( $_COOKIE ["staff"] )) { if (! empty ( $_COOKIE ["staff"] )) { Doo::loadModel ( 'staff' ); $staff = new staff (); $this->staff = $staff->getUserByIdList ( $_COOKIE ["staff"] ); return "/"; } } Doo::loadCore ( 'uri/DooUriRouter' ); $router = new DooUriRouter (); $routeRs = $router->execute ( Doo::app ()->route, Doo::conf ()->SUBFOLDER ); if ($routeRs ['1'] != "login") { header ( 'Content-Type:text/html;charset=utf-8' ); @header ( "Location: /login" ); } } function isMobile() { // 如果有HTTP_X_WAP_PROFILE则一定是移动设备 if (isset ( $_SERVER ['HTTP_X_WAP_PROFILE'] )) { return true; } // 如果via信息含有wap则一定是移动设备,部分服务商会屏蔽该信息 if (isset ( $_SERVER ['HTTP_VIA'] )) { // 找不到为flase,否则为true return stristr ( $_SERVER ['HTTP_VIA'], "wap" ) ? true : false; } // 脑残法,判断手机发送的客户端标志,兼容性有待提高 if (isset ( $_SERVER ['HTTP_USER_AGENT'] )) { $clientkeywords = array ( 'nokia', 'sony', 'ericsson', 'mot', 'samsung', 'htc', 'sgh', 'lg', 'sharp', 'sie-', 'philips', 'panasonic', 'alcatel', 'lenovo', 'iphone', 'ipod', 'blackberry', 'meizu', 'android', 'netfront', 'symbian', 'ucweb', 'windowsce', 'palm', 'operamini', 'operamobi', 'openwave', 'nexusone', 'cldc', 'midp', 'wap', 'mobile' ); // 从HTTP_USER_AGENT中查找手机浏览器的关键字 if (preg_match ( "/(" . implode ( '|', $clientkeywords ) . ")/i", strtolower ( $_SERVER ['HTTP_USER_AGENT'] ) )) { return true; } } // 协议法,因为有可能不准确,放到最后判断 if (isset ( $_SERVER ['HTTP_ACCEPT'] )) { // 如果只支持wml并且不支持html那一定是移动设备 // 如果支持wml和html但是wml在html之前则是移动设备 if ((strpos ( $_SERVER ['HTTP_ACCEPT'], 'vnd.wap.wml' ) !== false) && (strpos ( $_SERVER ['HTTP_ACCEPT'], 'text/html' ) === false || (strpos ( $_SERVER ['HTTP_ACCEPT'], 'vnd.wap.wml' ) < strpos ( $_SERVER ['HTTP_ACCEPT'], 'text/html' )))) { return true; } } return false; } function login() { $passwork = $this->get_args ( 'passwork' ) ? $this->get_args ( 'passwork' ) : 0; $uid = $this->get_args ( 'user' ) ? $this->get_args ( 'user' ) : 0; Doo::loadModel ( 'staff' ); $staff = new staff (); Doo::loadClass ( 'XDeode' ); $XDeode = new XDeode ( 5 ); if (! empty ( $passwork )) { $userinfo = $staff->checkUser ( $uid, $passwork ); if (! empty ( $userinfo )) { setcookie ( "staff", $XDeode->encode ( $userinfo [0] ['sid'] ), time () + 36000, "/" ); return "/"; } } $data ['staff'] = ""; // $staff->getUser (); $data ['login'] = ""; if (! empty ( $passwork )) $data ['login'] = "inputErrow"; $this->render ( "/login", $data ); } function out() { setcookie ( "staff", "", time () - 3600, "/" ); return "/"; } function test(){ //实例化redis } function index2() { // include Doo::conf()->BASE_PATH.'diagnostic/debug.php'; $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0; $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0; $page = $this->get_args ( 'page' ) ? $this->get_args ( 'page' ) : 1; Doo::loadModel ( 'action_log' ); $action_log = new action_log (); Doo::loadModel ( 'staff' ); $staff = new staff (); Doo::loadModel ( 'client_staff' ); $client_staff = new client_staff (); Doo::loadModel ( 'longle' ); $longle = new longle (); Doo::loadModel ( 'L_category' ); $lcategory = new L_category (); $limit = 50; $p = $page; if ($page != 1) $page = $page * $limit - 1; else $page --; $condition = ""; // if (!empty($cid) && $cid != 12) { // $condition = " and cid=" . $cid . " and sid=" . $sid; // } $staffCondition = ""; $categorylist2 = array (); if ($this->staff [0] ['cid'] != 12) { $staffCondition = " and cid=" . $this->staff [0] ['cid']; array_push ( $categorylist2, array ( 'cid' => $this->staff [0] ['cid'], 'title' => $this->staff [0] ['category'] ) ); if (! empty ( $sid )) $condition = " and cid=" . $this->staff [0] ['cid'] . " and sid=" . $sid; else $condition = " and cid=" . $this->staff [0] ['cid']; } else { $sql = 'SELECT `CLD_L_category`.cid,`CLD_L_category`.title,count(`CLD_staff`.sid) as count FROM `CLD_L_category` left join `CLD_staff` on `CLD_L_category`.cid=`CLD_staff`.cid group by `CLD_staff`.cid HAVING count(`CLD_staff`.sid)>0 order by count(`CLD_staff`.sid) desc'; $query = Doo::db ()->query ( $sql ); $result = $query->fetchAll (); $categorylist2 = $result; } //有待优化 Doo::loadModel ( 'department' ); $department = new department (); $categorylist3=$categorylist2;$bakCategory=array(); foreach ($categorylist3 as $key=>$value){ $departList=$department->getDepartmentBycid($value['cid']); if (!empty($departList)){ //$bakCategory=$categorylist2[$key]; array_unshift($bakCategory,$value); unset($categorylist2[$key]); foreach ($departList as $v){ array_unshift($bakCategory,array( 'cid'=>$v['cid'], 'title'=>$value['title'], 'count'=>$value['count'], 'did'=>$v['did'], 'departmentName'=>$v['departmentName'], )); } } } foreach ($bakCategory as $value){ array_unshift($categorylist2,$value); } $data ['did'] = ''; if (! empty ( $cid )) { $staffCondition = " and cid=" . $cid; if (!is_numeric($cid)){ $cdid=explode('-', $cid); $cid=$cdid[0]; $data ['did'] = $cdid[1]; $staffCondition = " and cid=" . $cid." and departmentID=".$cdid[1]; } if (! empty ( $sid )) $condition = " and cid=" . $cid . " and sid=" . $sid; else $condition = " and cid=" . $cid; } /* * $itemCategoryList=$action_log->find(array('select'=>'updatetime,COUNT(*)', 'where'=>" Year(updatetime)=2014",'groupby'=>'Month(updatetime)','asArray'=>true)); print_r($itemCategoryList);die; */ $staffList = $staff->find ( array ( 'where' => ' username!="admin" ' . $staffCondition, 'asArray' => true ) ); $alCondition=' aid>'.REMIT.' '; $actionLogList = $action_log->find ( array ( 'where' =>$alCondition . $condition, 'limit' => $page . ',' . $limit, 'desc' => 'aid', 'asArray' => true ) ); // echo $condition; // 抽取日期 ,'groupby'=>'updatetime' $dateLog = $action_log->find ( array ( 'select' => 'updatetime', 'where' => $alCondition . $condition, 'limit' => $limit, 'desc' => 'aid', 'asArray' => true ) ); $dl = array (); foreach ( $dateLog as $value ) { array_push ( $dl, $value ['updatetime'] ); } $dateLog = array_unique ( $dl ); $log = array (); foreach ( $dateLog as $key => $value ) { $log [$value] = array (); foreach ( $actionLogList as $k => $v ) { if ($value == $v ['updatetime']) { array_push ( $log [$value], $v ); unset ( $actionLogList [$k] ); } } } $max = array (); foreach ( $staffList as $key => $value ) { $staffList [$key] ['count'] = $client_staff->count ( array ( 'where' => 'sid=' . $value ['sid'], 'asArray' => true ) ); array_push ( $max, $staffList [$key] ['count'] . ':' . $value ['username'] ); } rsort ( $max, SORT_NUMERIC ); $sum = 0; foreach ( $max as $key => $value ) { $max [$key] = explode ( ":", $value ); $sum += $max [$key] [0]; } $max2 = $max; array_shift ( $max2 ); array_shift ( $max2 ); array_shift ( $max2 ); $lcategoryList = $lcategory->find ( array ( 'asArray' => true ) ); $useL = array (); $Rsum = $Ssum = 0; foreach ( $lcategoryList as $key => $value ) { $longleR = $longle->count ( array ( 'where' => 'cid=' . $value ['cid'], 'asArray' => true ) ); $longleS = $longle->count ( array ( 'where' => 'cid=' . $value ['cid'] . ' and status!=1 and status!=2', 'asArray' => true ) ); $Rsum += $longleR; $Ssum += $longleS; if (! empty ( $longleS )) array_push ( $useL, round ( ($longleS / $longleR) * 100 ) . '% :' . $value ['title'] ); else array_push ( $useL, '0% :' . $value ['title'] ); } rsort ( $useL, SORT_NUMERIC ); // $sum=0; foreach ( $useL as $key => $value ) { $useL [$key] = explode ( ":", $value ); // $sum+=$max[$key][0]; } $useL2 = $useL; array_shift ( $useL2 ); array_shift ( $useL2 ); array_shift ( $useL2 ); $data ['Ssum'] = round ( ($Ssum / $Rsum) * 100 ) . '%'; $data ['Rsum'] = $Rsum; $data ['useL2'] = $useL2; $data ['useL'] = $useL; $data ['sum'] = $sum; $data ['max'] = $max; $data ['max2'] = $max2; $data ['log'] = $log; $data ['page'] = $p; $data ['staffList'] = $staffList; $data ['categorylist2'] = $categorylist2; $data ['cid'] = $cid; $data ['sid'] = $sid; $data ['memu'] = "index"; $data ['staff'] = $this->staff; $this->render ( "index2", $data ); } function indexPage() { $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0; $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0; $page = $this->get_args ( 'page' ) ? $this->get_args ( 'page' ) : 1; Doo::loadModel ( 'action_log' ); $action_log = new action_log (); $limit = 50; $p = $page; // if ($page!=1) // $page=$page*$limit-1; // else // $page--; $page = (-- $p) * $limit; /* * $condition=""; if (!empty($cid)&&$cid!=12){ $condition=" and cid=".$cid; } $staffCondition=""; if($this->staff[0]['cid']!=12){ $staffCondition=" and cid=".$this->staff[0]['cid']; $condition=" and cid=".$this->staff[0]['cid']; } */ $condition = ""; if (! empty ( $cid ) && $cid != 12) { $condition = " and cid=" . $cid . " and sid=" . $sid; } $staffCondition = ""; if ($this->staff [0] ['cid'] != 12) { $staffCondition = " and cid=" . $this->staff [0] ['cid']; if (! empty ( $sid )) $condition = " and cid=" . $this->staff [0] ['cid'] . " and sid=" . $sid; else $condition = " and cid=" . $this->staff [0] ['cid']; } $actionLogList = $action_log->find ( array ( 'where' => ' 1 ' . $condition, 'limit' => $page . ',' . $limit, 'desc' => 'aid', 'asArray' => true ) ); // 抽取日期 ,'groupby'=>'updatetime' $dateLog = $action_log->find ( array ( 'select' => 'updatetime', 'where' => ' 1 ' . $condition, 'limit' => $page . ',' . $limit, 'desc' => 'aid', 'asArray' => true ) ); $dl = array (); foreach ( $dateLog as $value ) { array_push ( $dl, $value ['updatetime'] ); } $dateLog = array_unique ( $dl ); $log = array (); foreach ( $dateLog as $key => $value ) { $log [$value] = array (); foreach ( $actionLogList as $k => $v ) { if ($value == $v ['updatetime']) { array_push ( $log [$value], $v ); unset ( $actionLogList [$k] ); } } } $html = ''; foreach ( $log as $key => $value ) { $html .= '
' . $key . '
'; foreach ( $value as $k => $v ) { $html .= '
' . $v ['time'] . '' . $v ['action'] . '
'; } $html .= '
'; } echo $html; } function logStatistics() { $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0; $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0; Doo::loadModel ( 'action_log' ); $action_log = new action_log (); Doo::loadModel ( 'staff' ); $staff = new staff (); Doo::loadModel ( 'client_staff' ); $client_staff = new client_staff (); Doo::loadModel ( 'longle' ); $longle = new longle (); Doo::loadModel ( 'L_category' ); $lcategory = new L_category (); Doo::loadModel ( 'department' ); $department = new department (); $redis = new Redis(); $redis->connect('127.0.0.1', '6379');//120.27.200.79 $staffCondition = ""; $categorylist2 = array (); if ($this->staff [0] ['cid'] != 12) { $staffCondition = " and cid=" . $this->staff [0] ['cid']; // array_push ( $categorylist2, array ( // 'cid' => $this->staff [0] ['cid'], // 'title' => $this->staff [0] ['category'] // ) ); $otherC=$lcategory->getCategoryById($this->staff [0] ['cid'],$this->staff [0] ['othercid']); foreach ($otherC as $value){ array_push ( $categorylist2, array ( 'cid' => $value ['cid'], 'title' => $value ['title'] ) ); } } else { $sql = 'SELECT `CLD_L_category`.cid,`CLD_L_category`.title,count(`CLD_staff`.sid) as count FROM `CLD_L_category` left join `CLD_staff` on `CLD_L_category`.cid=`CLD_staff`.cid group by `CLD_staff`.cid HAVING count(`CLD_staff`.sid)>0 order by count(`CLD_staff`.sid) desc'; $query = Doo::db ()->query ( $sql ); $result = $query->fetchAll (); $categorylist2 = $result; //$otherC=$lcategory->getCategoryById($this->staff [0] ['cid'],$this->staff [0] ['othercid']); } //print_r($categorylist2); //有待优化 $categorylist3=$categorylist2;$bakCategory=array(); foreach ($categorylist3 as $key=>$value){ $departList=$department->getDepartmentBycid($value['cid']); if (!empty($departList)){ //$bakCategory=$categorylist2[$key]; array_unshift($bakCategory,$value); unset($categorylist2[$key]); foreach ($departList as $v){ array_unshift($bakCategory,array( 'cid'=>$v['cid'], 'title'=>$value['title'], 'count'=>$value['count'], 'did'=>$v['did'], 'departmentName'=>$v['departmentName'], )); } } } foreach ($bakCategory as $value){ array_unshift($categorylist2,$value); } //array_unshift($categorylist2,$bakCategory); //print_r($categorylist2); $did=$data ['did']=''; $othercateSql=''; if (!empty($this->staff [0] ['othercid'])) $othercateSql=" or (othercid like '".$this->staff [0] ['othercid']."')"; if (! empty ( $cid )){// if(is_numeric($cid)) $staffCondition = " and cid=" . $cid.$othercateSql; else { $cdid=explode('-', $cid); $cid=$cdid[0]; $data ['did'] =$did= $cdid[1]; $staffCondition = " and cid=" . $cdid[0]." and departmentID=".$cdid[1].$othercateSql; } } //echo $staffCondition; //echo $staffCondition; // Doo::db()->beginTransaction(); $staffList = $staff->find ( array ( 'where' => ' username !="admin"' . $staffCondition, 'asArray' => true ) ); $max = array (); $sum=0; //客户总数 $redisKey=date('Y-m-d').'_logStatisticsCSum_'.$this->staff [0] ['cid']; $redisValue = $redis->lrange($redisKey, 0, -1); if (empty($redisValue)){ $kkk = array (); foreach ( $staffList as $key => $value ) { $staffList [$key] ['count'] = $client_staff->count ( array ( 'where' => 'sid=' . $value ['sid'], 'asArray' => true ) ); array_push ( $max, $staffList [$key] ['count'] . ':' . $value ['username'] ); if ($this->staff [0] ['cid'] == 12) array_push ( $kkk, $staffList [$key] ['count'] ); if ($this->staff [0] ['cid'] == $value ['cid'] && $this->staff [0] ['cid'] != 12) { array_push ( $kkk, $staffList [$key] ['count'] ); } } foreach ( $kkk as $key => $value ) { $sum += $value; } $sortMaxStr=json_encode ( $max ); $redis->lpush($redisKey, $sum); $redis->lpush($redisKey, $sortMaxStr); }else{ $sum=$redisValue[1]; $max=json_decode($redisValue[0],true); } rsort ( $max, SORT_NUMERIC ); foreach ( $max as $key => $value ) { $max [$key] = explode ( ":", $value ); // $sum+=$max[$key][0]; } $max2 = $max; array_shift ( $max2 ); array_shift ( $max2 ); array_shift ( $max2 ); $lcategoryList = $lcategory->find ( array ( 'asArray' => true ) ); $useL = array (); $Rsum = $Ssum = 0; $redisKey=date('Y-m-d').'_logStatisticsLongle'; $redisValue = $redis->lrange($redisKey, 0, -1); if (empty($redisValue)){ foreach ( $lcategoryList as $key => $value ) { $longleR = $longle->count ( array ( 'where' => 'cid=' . $value ['cid'], 'asArray' => true ) ); $longleS = $longle->count ( array ( 'where' => 'cid=' . $value ['cid'] . ' and status!=1 and status!=2', 'asArray' => true ) ); $Rsum += $longleR; $Ssum += $longleS; if (! empty ( $longleS )) array_push ( $useL, round ( ($longleS / $longleR) * 100 ) . '% :' . $value ['title'] ); else array_push ( $useL, '0% :' . $value ['title'] ); } $useLStr=json_encode ( $useL ); $redis->lpush($redisKey, $Rsum); $redis->lpush($redisKey, $Ssum); $redis->lpush($redisKey, $useLStr); }else{ $useL=$redisValue[0]; $useL=json_decode($useL,true); $Ssum=$redisValue[1]; $Rsum=$redisValue[2]; } rsort ( $useL, SORT_NUMERIC ); foreach ( $useL as $key => $value ) { $useL [$key] = explode ( ":", $value ); } $useL2 = $useL; array_shift ( $useL2 ); array_shift ( $useL2 ); array_shift ( $useL2 ); // statistics //30天操作日志数 $categoryCondition = " and cid=" . $this->staff [0] ['cid']; $redisCid=$this->staff [0] ['cid']; $sidCondition=$redisSid = ""; if (! empty ( $cid )){ $categoryCondition = " and cid=" . $cid; $redisCid=$cid; } if (! empty ( $sid )){ $redisSid=$sid; $sidCondition = " and sid=" . $sid; } if ($this->staff [0] ['cid'] == 12 && empty ( $cid )) { $categoryCondition = ""; $redisCid=''; } $redisKey=date('Y-m-d').'SL_'.$redisCid.'_'.$redisSid; $redisValue=$redis->get($redisKey); if (empty($redisValue)){ $actionLogLongle = $action_log->find ( array ( 'select' => 'date_format(updatetime,"%m-%d") as updatetime,COUNT(*) as count', 'where' => " date_sub(curdate(), INTERVAL 30 DAY) <= date(updatetime) and status=3" . $categoryCondition . $sidCondition, 'groupby' => 'date_format(updatetime,"%m-%d")', 'asArray' => true ) ); $statisticsLongle = array (); for($d = 0; $d <= 29; $d ++) { $MD = date ( "m-d", strtotime ( "-" . $d . " day" ) ); $falgLongle = true; foreach ( $actionLogLongle as $value ) { if ($value ['updatetime'] == $MD) { array_push ( $statisticsLongle, $value ['count'] ); $falgLongle = false; break; } } if ($falgLongle) array_push ( $statisticsLongle, 0 ); } $statisticsLongle = array_reverse ( $statisticsLongle ); $jsl=json_encode ( $statisticsLongle ); $redis->set($redisKey,$jsl); $data ['statisticsLongle'] = $jsl; }else{ $data ['statisticsLongle'] = $redisValue; } //添加客户 数30天 $redisKey=date('Y-m-d').'SC_'.$redisCid.'_'.$redisSid; // echo $redisKey; // echo "
date_sub(curdate(), INTERVAL 30 DAY) <= date(updatetime) and status=1" . $categoryCondition . $sidCondition; $redisValue=$redis->get($redisKey); if (empty($redisValue)){ $actionLogClient = $action_log->find ( array ( 'select' => 'date_format(updatetime,"%m-%d") as updatetime,COUNT(*) as count', 'where' => " date_sub(curdate(), INTERVAL 30 DAY) <= date(updatetime) and status=1" . $categoryCondition . $sidCondition, 'groupby' => 'date_format(updatetime,"%m-%d")', 'asArray' => true ) ); $statisticsClient = array (); for($d = 0; $d <= 29; $d ++) { $MD = date ( "m-d", strtotime ( "-" . $d . " day" ) ); $falgClient = true; foreach ( $actionLogClient as $value ) { if ($value ['updatetime'] == $MD) { array_push ( $statisticsClient, $value ['count'] ); $falgClient = false; break; } } if ($falgClient) array_push ( $statisticsClient, 0 ); } $statisticsClient = array_reverse ( $statisticsClient ); $jsc=json_encode ( $statisticsClient ); $redis->set($redisKey,$jsc); $data ['statisticsClient'] = $jsc; }else{ $data ['statisticsClient'] = $redisValue; } $statisticsDay = array (); for($d = 0; $d <= 29; $d ++) { $MD = date ( "m-d", strtotime ( "-" . $d . " day" ) ); array_push ( $statisticsDay, $MD ); } $statisticsDay = array_reverse ( $statisticsDay ); // / Year(updatetime)=".date('Y')." and Month(updatetime)=".date('m')." and $categoryList = $lcategory->find ( array ( 'asArray' => true ) ); //最近30天区域分布图 $redisKey=date('Y-m-d').'SCCT_'.$redisCid.'_'.$redisSid; $redisValue=$redis->lrange($redisKey, 0, -1); if (empty($redisValue)){ $CategoryClient = $action_log->find ( array ( 'select' => 'cid,COUNT(*) as count,city', 'where' => " date_sub(curdate(), INTERVAL 30 DAY) <= date(updatetime) and status=1" . $categoryCondition . $sidCondition, 'groupby' => 'cid', 'asArray' => true ) ); $CategoryCompany = $action_log->find ( array ( 'select' => 'cid, COUNT(*) as count,company,districtid', 'where' => " date_sub(curdate(), INTERVAL 30 DAY) <= date(updatetime) and (status=1 )" . $categoryCondition . $sidCondition, 'groupby' => 'cid,districtid,company', 'asArray' => true ) ); $statisticsCategory = array (); $statisticsCompany = array (); foreach ( $categoryList as $value ) { $falgClient = $falgLongle = true; foreach ( $CategoryClient as $v ) { if ($value ['cid'] == $v ['cid'] && $v ['cid'] != 12) { array_push ( $statisticsCategory, array ( 'value' => $v ['count'], 'name' => str_replace ( "办", "省", $value ['title'] ) ) ); $falgClient = false; break; } } if ($falgClient) { array_push ( $statisticsCategory, array ( 'value' => 0, 'name' => str_replace ( "办", "省", $value ['title'] ) ) ); } // company statistics $i = 0; foreach ( $CategoryCompany as $v ) { if ($value ['cid'] == $v ['cid'] && $v ['cid'] != 12) { $i ++; } } array_push ( $statisticsCompany, array ( 'value' => $i, 'name' => str_replace ( "办", "省", $value ['title'] ) ) ); } $scctA=json_encode ( $statisticsCompany ); $scctB=json_encode ( $statisticsCategory ); $redis->lpush($redisKey, $scctA); $redis->lpush($redisKey, $scctB); $data ['statisticsCompany'] = $scctA; $data ['statisticsCategory'] = $scctB; }else{ $data ['statisticsCompany'] = $redisValue[1]; $data ['statisticsCategory'] = $redisValue[0]; } // print_r($CategoryClient); $redisKey=date('Y-m-d').'SN_'.$redisCid.'_'.$redisSid; $redisValue=$redis->get($redisKey); if (empty($redisValue)){ $natureList = $action_log->find ( array ( 'select' => 'cid, COUNT(*) as count,nature', 'where' => " date_sub(curdate(), INTERVAL 30 DAY) <= date(updatetime) and status=1 and nature !=''" . $categoryCondition . $sidCondition, 'groupby' => 'nature', 'asArray' => true ) ); $statisticsNature = array (); foreach ( $this->nature as $value ) { $flagNature = true; foreach ( $natureList as $v ) { if ($value == $v ['nature']) { array_push ( $statisticsNature, array ( 'value' => $v ['count'], 'name' => $value ) ); $flagNature = false; break; } } if ($flagNature) array_push ( $statisticsNature, array ( 'value' => 0, 'name' => $value ) ); } $jsn=json_encode ( $statisticsNature ); $redis->set($redisKey,$jsn); $data ['statisticsNature'] = $jsn; }else{ $data ['statisticsNature'] = $redisValue; } $data ['statisticsDay'] = json_encode ( $statisticsDay ); $data ['categorylist2'] = $categorylist2; $data ['Ssum'] = round ( ($Ssum / $Rsum) * 100 ) . '%'; $data ['Rsum'] = $Rsum; $data ['useL2'] = $useL2; $data ['useL'] = $useL; $data ['sum'] = $sum; $data ['max'] = $max; $data ['max2'] = $max2; $data ['staffList'] = $staffList; $data ['cid'] = $cid; $data ['sid'] = $sid; $data ['memu'] = "index"; $data ['staff'] = $this->staff; $this->render ( "/indexStat", $data ); } function longleStatistics() { $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0; $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0; $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 4; $districtH = $this->get_args ( 'district' ) ? $this->get_args ( 'district' ) : 0; Doo::loadModel ( 'action_log' ); $action_log = new action_log (); Doo::loadModel ( 'staff' ); $staff = new staff (); Doo::loadModel ( 'client_staff' ); $client_staff = new client_staff (); Doo::loadModel ( 'longle' ); $longle = new longle (); Doo::loadModel ( 'L_category' ); $lcategory = new L_category (); Doo::loadModel ( 'district' ); $district = new district (); $staffCondition = ""; $categorylist2 = array (); if ($this->staff [0] ['cid'] != 12) { $staffCondition = " and cid=" . $this->staff [0] ['cid']; array_push ( $categorylist2, array ( 'cid' => $this->staff [0] ['cid'], 'title' => $this->staff [0] ['category'] ) ); } else { $sql = 'SELECT `CLD_L_category`.cid,`CLD_L_category`.title,count(`CLD_staff`.sid) as count FROM `CLD_L_category` left join `CLD_staff` on `CLD_L_category`.cid=`CLD_staff`.cid group by `CLD_staff`.cid HAVING count(`CLD_staff`.sid)>0 order by count(`CLD_staff`.sid) desc'; $query = Doo::db ()->query ( $sql ); $result = $query->fetchAll (); $categorylist2 = $result; } //有待优化 Doo::loadModel ( 'department' ); $department = new department (); $categorylist3=$categorylist2;$bakCategory=array(); foreach ($categorylist3 as $key=>$value){ $departList=$department->getDepartmentBycid($value['cid']); if (!empty($departList)){ //$bakCategory=$categorylist2[$key]; array_unshift($bakCategory,$value); unset($categorylist2[$key]); foreach ($departList as $v){ array_unshift($bakCategory,array( 'cid'=>$v['cid'], 'title'=>$value['title'], 'count'=>$value['count'], 'did'=>$v['did'], 'departmentName'=>$v['departmentName'], )); } } } foreach ($bakCategory as $value){ array_unshift($categorylist2,$value); } $data ['did'] = ''; if (! empty ( $cid )){ if(is_numeric($cid)) $staffCondition = " and cid=" . $cid; else { $cdid=explode('-', $cid); $cid=$cdid[0]; $data ['did'] = $cdid[1]; $staffCondition = " and cid=" . $cdid[0]." and departmentID=".$cdid[1]; } //$staffCondition = " and cid=" . $cid; } $staffList = $staff->find ( array ( 'where' => ' username!="admin"' . $staffCondition, 'asArray' => true ) ); $max = array (); foreach ( $staffList as $key => $value ) { $staffList [$key] ['count'] = $client_staff->count ( array ( 'where' => 'sid=' . $value ['sid'], 'asArray' => true ) ); array_push ( $max, $staffList [$key] ['count'] . ':' . $value ['username'] ); } rsort ( $max, SORT_NUMERIC ); $sum = 0; foreach ( $max as $key => $value ) { $max [$key] = explode ( ":", $value ); $sum += $max [$key] [0]; } $max2 = $max; array_shift ( $max2 ); array_shift ( $max2 ); array_shift ( $max2 ); $lcategoryList = $lcategory->find ( array ( 'asArray' => true ) ); $useL = array (); $Rsum = $Ssum = 0; foreach ( $lcategoryList as $key => $value ) { $longleR = $longle->count ( array ( 'where' => 'cid=' . $value ['cid'], 'asArray' => true ) ); $longleS = $longle->count ( array ( 'where' => 'cid=' . $value ['cid'] . ' and status!=1 and status!=2', 'asArray' => true ) ); $Rsum += $longleR; $Ssum += $longleS; if (! empty ( $longleS )) array_push ( $useL, round ( ($longleS / $longleR) * 100 ) . '% :' . $value ['title'] ); else array_push ( $useL, '0% :' . $value ['title'] ); } rsort ( $useL, SORT_NUMERIC ); // $sum=0; foreach ( $useL as $key => $value ) { $useL [$key] = explode ( ":", $value ); // $sum+=$max[$key][0]; } $useL2 = $useL; array_shift ( $useL2 ); array_shift ( $useL2 ); array_shift ( $useL2 ); // statistics $categoryCondition = " and cid=" . $this->staff [0] ['cid']; $sidCondition = ""; if (! empty ( $cid )) $categoryCondition = " and cid=" . $cid; if (! empty ( $sid )) $sidCondition = " and sid=" . $sid; if ($this->staff [0] ['cid'] == 12 && empty ( $cid )) { $categoryCondition = ""; } // Year(updatetime)=".date('Y')." and Month(updatetime)=".date('m')." date_format(updatetime,"%m-%d") Day(updatetime) $actionLogClient = $action_log->find ( array ( 'select' => 'date_format(updatetime,"%m-%d") as updatetime,COUNT(*) as count', 'where' => " date_sub(curdate(), INTERVAL 30 DAY) <= date(updatetime) and status=4" . $categoryCondition . $sidCondition, 'groupby' => 'Day(updatetime)', 'asArray' => true ) ); $actionLogLongle = $action_log->find ( array ( 'select' => 'date_format(updatetime,"%m-%d") as updatetime,COUNT(*) as count', 'where' => " date_sub(curdate(), INTERVAL 30 DAY) <= date(updatetime) and status=5" . $categoryCondition . $sidCondition, 'groupby' => 'Day(updatetime)', 'asArray' => true ) ); $actionLogGet = $action_log->find ( array ( 'select' => 'date_format(updatetime,"%m-%d") as updatetime,COUNT(*) as count', 'where' => " date_sub(curdate(), INTERVAL 30 DAY) <= date(updatetime) and status=6" . $categoryCondition . $sidCondition, 'groupby' => 'Day(updatetime)', 'asArray' => true ) ); $statisticsDay = array (); $statisticsClient = $statisticsLongle = $statisticsGet = array (); /** * for ($d=1;$d<=date("t");$d++){ $MD=date('m')."-".$d; */ for($d = 0; $d <= 29; $d ++) { $MD = date ( "m-d", strtotime ( "-" . $d . " day" ) ); $falgClient = $falgLongle = $falgGet = true; array_push ( $statisticsDay, $MD ); foreach ( $actionLogClient as $value ) { if ($value ['updatetime'] == $MD) { array_push ( $statisticsClient, $value ['count'] ); $falgClient = false; break; } } if ($falgClient) array_push ( $statisticsClient, 0 ); foreach ( $actionLogLongle as $value ) { if ($value ['updatetime'] == $MD) { array_push ( $statisticsLongle, $value ['count'] ); $falgLongle = false; break; } } if ($falgLongle) array_push ( $statisticsLongle, 0 ); foreach ( $actionLogGet as $value ) { if ($value ['updatetime'] == $MD) { array_push ( $statisticsGet, $value ['count'] ); $falgGet = false; break; } } if ($falgGet) array_push ( $statisticsGet, 0 ); } $statisticsClient = array_reverse ( $statisticsClient ); $statisticsLongle = array_reverse ( $statisticsLongle ); $statisticsGet = array_reverse ( $statisticsGet ); $statisticsDay = array_reverse ( $statisticsDay ); // / $districtCondition = ""; $topDistrict = $district->get_lvByid ( 0, 0 ); if (! empty ( $sid )) { $s = $staff->getOne ( array ( 'where' => ' sid=' . $sid, 'asArray' => true ) ); $l = $lcategory->find ( array ( 'where' => ' cid in(' . $s ['cid'] . ')', 'asArray' => true ) ); if (! empty ( $s ['othercid'] )) $l = $lcategory->find ( array ( 'where' => ' cid in(' . $s ['cid'] . ',' . $s ['othercid'] . ')', 'asArray' => true ) ); if (! empty ( $districtH )) { $districtCondition = " and districtid like '" . $districtH . ",%'"; $sidCondition = ""; $topDistrict = $district->find ( array ( 'where' => ' upid=' . $districtH, 'asArray' => true ) ); } else { $districtCondition = " and districtid like '" . $l [0] ['districtid'] . ",%'"; $sidCondition = ""; $topDistrict = $district->find ( array ( 'where' => ' upid=' . $l [0] ['districtid'], 'asArray' => true ) ); } $str = array (); foreach ( $l as $value ) { array_push ( $str, $value ['districtid'] ); } $str = implode ( ",", $str ); $data ['districtHtml'] = $district->find ( array ( 'where' => ' id in (' . $str . ')', 'asArray' => true ) ); $data ['districtH'] = $l [0] ['districtid']; if (! empty ( $districtH )) $data ['districtH'] = $districtH; } // Year(updatetime)=".date('Y')." and Month(updatetime)=".date('m')." and if (! empty ( $sid )) $districtClient = $action_log->find ( array ( 'select' => 'city,province,COUNT(*) as count', 'where' => " date_sub(curdate(), INTERVAL 30 DAY) <= date(updatetime) and status=" . $status . $categoryCondition . $sidCondition . $districtCondition, 'groupby' => 'province', 'asArray' => true ) ); else $districtClient = $action_log->find ( array ( 'select' => 'city,province,COUNT(*) as count', 'where' => " date_sub(curdate(), INTERVAL 30 DAY) <= date(updatetime) and status=" . $status . $categoryCondition . $sidCondition . $districtCondition, 'groupby' => 'city', 'asArray' => true ) ); $statisticsLend = array (); $statisticsCompany = array (); if (! empty ( $sid )) { foreach ( $topDistrict as $value ) { $falgLend = $falgLongle = true; foreach ( $districtClient as $v ) { if ($value ['name'] == $v ['province']) { array_push ( $statisticsLend, array ( 'value' => $v ['count'], 'name' => $value ['name'] ) ); $falgLend = false; break; } } if ($falgLend) array_push ( $statisticsLend, array ( 'value' => 0, 'name' => $value ['name'] ) ); } } else { foreach ( $topDistrict as $value ) { $falgLend = $falgLongle = true; foreach ( $districtClient as $v ) { if ($value ['name'] == $v ['city']) { array_push ( $statisticsLend, array ( 'value' => $v ['count'], 'name' => $value ['name'] ) ); $falgLend = false; break; } } if ($falgLend) array_push ( $statisticsLend, array ( 'value' => 0, 'name' => $value ['name'] ) ); } } // print_r($statisticsLend);die; $natureList = $action_log->find ( array ( 'select' => 'cid, COUNT(*) as count,nature', 'where' => " date_sub(curdate(), INTERVAL 30 DAY) <= date(updatetime) and status=" . $status . " and nature !=''" . $categoryCondition . $sidCondition . $districtCondition, 'groupby' => 'nature', 'asArray' => true ) ); $statisticsNature = array (); foreach ( $this->nature as $value ) { $flagNature = true; foreach ( $natureList as $v ) { if ($value == $v ['nature']) { array_push ( $statisticsNature, array ( 'value' => $v ['count'], 'name' => $value ) ); $flagNature = false; break; } } if ($flagNature) array_push ( $statisticsNature, array ( 'value' => 0, 'name' => $value ) ); } $data ['statisticsNature'] = json_encode ( $statisticsNature ); // print_r($statisticsLend);die; $data ['statisticsLend'] = json_encode ( $statisticsLend ); $data ['status'] = $status; $data ['statisticsDay'] = json_encode ( $statisticsDay ); $data ['statisticsClient'] = json_encode ( $statisticsClient ); $data ['statisticsLongle'] = json_encode ( $statisticsLongle ); $data ['statisticsGet'] = json_encode ( $statisticsGet ); $data ['categorylist2'] = $categorylist2; $data ['Ssum'] = round ( ($Ssum / $Rsum) * 100 ) . '%'; $data ['Rsum'] = $Rsum; $data ['useL2'] = $useL2; $data ['useL'] = $useL; $data ['sum'] = $sum; $data ['max'] = $max; $data ['max2'] = $max2; $data ['staffList'] = $staffList; $data ['cid'] = $cid; $data ['sid'] = $sid; $data ['memu'] = "index"; $data ['staff'] = $this->staff; $this->render ( "/indexLongle", $data ); } function index() { die ( 'dd' ); $data ['memu'] = "index"; $data ['staff'] = $this->staff; Doo::loadModel ( 'action_log' ); $action_log = new action_log (); $data ['today'] = explode ( "-", date ( "Y-m-d" ) ); $str = ""; if ($this->staff [0] ['isadmin'] != 1) { $str = " and (action like '%" . $this->staff [0] ['category'] . "%'"; $khql = explode ( ",", $this->staff [0] ['othercategory'] ); if (! empty ( $khql [0] )) { foreach ( $khql as $key => $value ) { $str .= " or action like '%" . $value . "%'"; } $str .= ")"; } else $str .= ")"; } $data ['actionListNow'] = $action_log->find ( array ( 'where' => ' updatetime=\'' . date ( "Y-m-d" ) . "'" . $str, 'desc' => 'aid', 'asArray' => TRUE ) ); $d2 = mktime ( 0, 0, 0, date ( "m" ), date ( "d" ) - 1, date ( "Y" ) ); $strdate = date ( "Y-m-d", $d2 ); $data ['day2'] = explode ( "-", $strdate ); $data ['actionListNow2'] = $action_log->find ( array ( 'where' => ' updatetime=\'' . $strdate . "'" . $str, 'desc' => 'aid', 'asArray' => TRUE ) ); $d3 = mktime ( 0, 0, 0, date ( "m" ), date ( "d" ) - 2, date ( "Y" ) ); $strdate = date ( "Y-m-d", $d3 ); $data ['day3'] = explode ( "-", $strdate ); $data ['actionListNow3'] = $action_log->find ( array ( 'where' => ' updatetime=\'' . $strdate . "'" . $str, 'desc' => 'aid', 'asArray' => TRUE ) ); $d4 = mktime ( 0, 0, 0, date ( "m" ), date ( "d" ) - 3, date ( "Y" ) ); $strdate = date ( "Y-m-d", $d4 ); $data ['day4'] = explode ( "-", $strdate ); $data ['actionListNow4'] = $action_log->find ( array ( 'where' => ' updatetime=\'' . $strdate . "'" . $str, 'asArray' => TRUE ) ); $d5 = mktime ( 0, 0, 0, date ( "m" ), date ( "d" ) - 4, date ( "Y" ) ); $strdate = date ( "Y-m-d", $d5 ); $data ['day5'] = explode ( "-", $strdate ); $data ['actionListNow5'] = $action_log->find ( array ( 'where' => ' updatetime=\'' . $strdate . "'" . $str, 'asArray' => TRUE ) ); $d6 = mktime ( 0, 0, 0, date ( "m" ), date ( "d" ) - 5, date ( "Y" ) ); $strdate = date ( "Y-m-d", $d6 ); $data ['day6'] = explode ( "-", $strdate ); $data ['actionListNow6'] = $action_log->find ( array ( 'where' => ' updatetime=\'' . $strdate . "'" . $str, 'asArray' => TRUE ) ); $d7 = mktime ( 0, 0, 0, date ( "m" ), date ( "d" ) - 6, date ( "Y" ) ); $strdate = date ( "Y-m-d", $d7 ); $data ['day7'] = explode ( "-", $strdate ); $data ['actionListNow7'] = $action_log->find ( array ( 'where' => ' updatetime=\'' . $strdate . "'" . $str, 'asArray' => TRUE ) ); Doo::loadModel ( 'staff' ); Doo::loadModel ( 'client_staff' ); $client_staff = new client_staff (); $staff = new staff (); $st = $staff->find ( array ( 'where' => '1', 'asArray' => true ) ); foreach ( $st as $key => $value ) { $st [$key] ['count'] = $client_staff->count ( array ( 'where' => 'sid=' . $value ['sid'], 'asArray' => true ) ); } $data ['staffCount'] = $st; $this->render ( "/index", $data ); } function receive() { $data ['memu'] = "keyonline"; $data ['staff'] = $this->staff; Doo::loadModel ( 'longle' ); $longle = new longle (); $data ['arrayReceive'] = $longle->getLongleReceive ( $this->staff [0] ['cid'], 1, $this->staff [0] ['othercid'] ); $this->render ( "/look_receive", $data ); } function doLongleReceive() { $arrLid = $this->get_args ( 'lid' ) ? $this->get_args ( 'lid' ) : array (); Doo::loadModel ( 'longle_log' ); Doo::loadModel ( 'longle' ); foreach ( $arrLid as $key => $value ) { $ky = explode ( "-", $value ); $longle = new longle (); $longle_log = new longle_log (); $longle->lid = $ky [0]; $longle->status = 2; $longle->statusT = '接收'; $longle->responsible = $this->staff [0] ['username']; // 记录锁状态 $longle->statuslog = "1,2"; $longle->update (); $longle_log->lid = $ky [0]; $longle_log->status = 2; $longle_log->statusT = '接收'; $longle_log->responsible = $this->staff [0] ['username']; $longle_log->operator = $this->staff [0] ['username']; $longle_log->category = $ky [1]; $longle_log->dateline = date ( "Y-m-d" ); $longle_log->insert (); } return "/receive"; } function addClient() { $this->get_args ( 'clientname' ) ? $this->get_args ( 'clientname' ) : ""; $clientname = $this->get_args ( 'clientname' ) ? $this->get_args ( 'clientname' ) : ""; $gender = $this->get_args ( 'gender' ) ? $this->get_args ( 'gender' ) : ""; $nicename = $this->get_args ( 'nicename' ) ? $this->get_args ( 'nicename' ) : ""; $telephone = $this->get_args ( 'telephone' ) ? $this->get_args ( 'telephone' ) : ""; $phone = $this->get_args ( 'phone' ) ? $this->get_args ( 'phone' ) : ""; $email = $this->get_args ( 'email' ) ? $this->get_args ( 'email' ) : ""; $qq = $this->get_args ( 'qq' ) ? $this->get_args ( 'qq' ) : ""; $tid = $this->get_args ( 'tid' ) ? $this->get_args ( 'tid' ) : ""; $companyname = $this->get_args ( 'companyname' ) ? $this->get_args ( 'companyname' ) : ""; $local1 = $this->get_args ( 'lv21' ) ? $this->get_args ( 'lv21' ) : ""; $local2 = $this->get_args ( 'lv22' ) ? $this->get_args ( 'lv22' ) : ""; $local3 = $this->get_args ( 'lv23' ) ? $this->get_args ( 'lv23' ) : ""; $nature = $this->get_args ( 'nature' ) ? $this->get_args ( 'nature' ) : ""; $fax = $this->get_args ( 'fax' ) ? $this->get_args ( 'fax' ) : ""; $webservice = $this->get_args ( 'webservice' ) ? $this->get_args ( 'webservice' ) : ""; $department = $this->get_args ( 'department' ) ? $this->get_args ( 'department' ) : ""; $position = $this->get_args ( 'position' ) ? $this->get_args ( 'position' ) : ""; $office = $this->get_args ( 'office' ) ? $this->get_args ( 'office' ) : ""; $address = $this->get_args ( 'address' ) ? $this->get_args ( 'address' ) : ""; $ride = $this->get_args ( 'ride' ) ? $this->get_args ( 'ride' ) : ""; $landmarks = $this->get_args ( 'landmarks' ) ? $this->get_args ( 'landmarks' ) : ""; $priority = $this->get_args ( 'priority' ) ? $this->get_args ( 'priority' ) : ""; $stay = $this->get_args ( 'stay' ) ? $this->get_args ( 'stay' ) : ""; $mark = $this->get_args ( 'mark' ) ? $this->get_args ( 'mark' ) : ""; $clientname = trim ( $clientname ); $companyname = trim ( $companyname ); if (empty ( $companyname )) return "/contacts"; if (empty ( $this->staff [0] ['sid'] )) return "/contacts"; if (! empty ( $clientname )) { // 相同的公司和客户 Doo::loadModel ( 'company' ); $company = new company (); Doo::loadModel ( 'client' ); $client = new client (); $redis = new Redis(); $redis->connect('127.0.0.1', '6379'); $cinfo = $client->getClientByNameT ( $clientname ); if (! empty ( $cinfo )) { $ninfo = $company->getCompanyByCompanyname ( $companyname ); if (! empty ( $ninfo )) { foreach ( $cinfo as $key => $value ) { // 问题 if ($value ['companyid'] == $ninfo [0] ['cid']) return "/contacts"; } } } Doo::loadModel ( 'district' ); $district = new district (); $companyInfo = $company->getOne ( array ( 'where' => "companyname = '" . $companyname . "'", "asArray" => true ) ); // 更新公司信息 $lv1 = $district->getbyid ( $local1 ); $lv2 = $district->getbyid ( $local2 ); $lv3 = $district->getbyid ( $local3 ); if (empty ( $lv1 )) $lv1 [0] ['name'] = ""; if (empty ( $lv2 )) $lv2 [0] ['name'] = ""; if (empty ( $lv3 )) $lv3 [0] ['name'] = ""; if (! empty ( $local1 ) && ! empty ( $local2 )) $company->local = $lv1 [0] ['name'] . "," . $lv2 [0] ['name'] . "," . $lv3 [0] ['name']; if (! empty ( $nature )) $company->nature = implode ( ',', $nature ); if (! empty ( $fax )) $company->fax = $fax; if (! empty ( $webservice )) $company->webservice = $webservice; if (! empty ( $address )) $company->address = $address; if (! empty ( $ride )) $company->ride = $ride; if (! empty ( $landmarks )) $company->landmarks = $landmarks; if (! empty ( $office )) $company->office = $office; if (! empty ( $local1 ) && ! empty ( $local2 )) $company->district = $local1 . "," . $local2 . "," . $local3; if (! empty ( $stay )) $company->stay = $stay; if (empty ( $companyInfo )) { $company->companyname = $companyname; $company->staffid = $this->staff [0] ['sid']; $cid = $company->insert (); } else { // 不编辑公司,地区判断,作为新公司 // $cid=$companyInfo['cid']; // // $companyname=$companyInfo['companyname']; // // $company->cid=$cid; // // $company->update(); $diqu = $local1 . "," . $local2 . "," . $local3; $cid = $companyInfo ['cid']; $company2 = new company (); $companyList = $company2->find ( array ( 'where' => " companyname like '" . $companyname . "'", "asArray" => true ) ); $falg = false; // print_r($companyList); foreach ( $companyList as $key => $value ) { if ($value ['district'] != $diqu) { $falg = true; } elseif ($value ['district'] == $diqu) { $falg = false; $cid = $value ['cid']; break; } } if ($falg) { $company->companyname = $companyname; $company->staffid = $this->staff [0] ['sid']; $cid = $company->insert (); } } Doo::loadModel ( 'client_staff' ); $client_staff = new client_staff (); $client->clientname = $clientname; $client->gender = $gender; $client->priority = $priority; if (! empty ( $nicename )) $client->nicename = $nicename; if (! empty ( $telephone )) $client->telephone = $telephone; if (! empty ( $phone )) $client->phone = $phone; if (! empty ( $email )) $client->email = $email; if (! empty ( $qq ) && is_numeric ( $qq )) $client->qq = $qq; $client->companyid = $cid; $client->companyname = $companyname; $client->district = $local1 . "," . $local2 . "," . $local3; // echo $client->district; // die; if (! empty ( $tid )) $client->tag = implode ( ',', $tid ); if (! empty ( $fax )) $client->fax = $fax; if (! empty ( $webservice )) $client->webservice = $webservice; if (! empty ( $department )) $client->department = $department; if (! empty ( $position )) $client->position = $position; if (! empty ( $office )) $client->office = $office; if (! empty ( $address )) $client->address = $address; if (! empty ( $ride )) $client->ride = $ride; if (! empty ( $landmarks )) $client->landmarks = $landmarks; if (! empty ( $stay )) $client->stay = $stay; if (! empty ( $mark )) $client->mark = $mark; $id = $client->insert (); $client_staff->cid = $id; $client_staff->sid = $this->staff [0] ['sid']; $client_staff->insert (); // 加入地区记录 Doo::loadModel ( "district_staff" ); $district_staff = new district_staff (); $district_staff->did = $lv1 [0] ['id']; $district_staff->sid = $this->staff [0] ['sid']; $district_staff->insert (); // 日常行为 Doo::loadModel ( "action_log" ); $action_log = new action_log (); $action_log->action = $this->staff [0] ['category'] . '' . $this->staff [0] ['username'] . '添加了' . $clientname . '(' . $companyname . ')'; $action_log->sid = $this->staff [0] ['sid']; $action_log->cid = $this->staff [0] ['cid']; $action_log->updatetime = date ( "Y-m-d" ); $action_log->time = date ( "H:i" ); $action_log->status = 1; $action_log->districtid = $local1 . "," . $local2 . "," . $local3; $action_log->city = $lv1 [0] ['name']; $action_log->province = $lv2 [0] ['name']; if (isset ( $nature [0] )) $action_log->nature = $nature [0]; $action_log->company = $companyname; $action_log->class = $action_log->iconContacts; $action_log->insert (); //事实更新信息中心记录数量 需要更新3个redis 内的值 $categoryCondition = " and cid=" . $this->staff [0] ['cid']; $sidCondition = " and sid=" . $this->staff [0] ['sid']; //actionlog免查询值 $alCondition=''; $alCondition=' aid>'.REMIT.' and '; //个人添加数量redis值 $redisKeyCS=date('Y-m-d').'SC_'.$this->staff [0] ['cid'].'_'.$this->staff [0] ['sid']; $action_log = new action_log (); $actionLogClient = $action_log->find ( array ( 'select' => 'date_format(updatetime,"%m-%d") as updatetime,COUNT(*) as count', 'where' => $alCondition." status=1" . $sidCondition . $categoryCondition.' and date_sub(curdate(), INTERVAL 30 DAY) <= date(updatetime)', 'groupby' => 'date_format(updatetime,"%m-%d")', 'asArray' => true ) ); $statisticsClient = array (); for($d = 0; $d <= 29; $d ++) { $MD = date ( "m-d", strtotime ( "-" . $d . " day" ) ); $falgClient = true; foreach ( $actionLogClient as $value ) { if ($value ['updatetime'] == $MD) { array_push ( $statisticsClient, $value ['count'] ); $falgClient = false; break; } } if ($falgClient) array_push ( $statisticsClient, 0 ); } $statisticsClient = array_reverse ( $statisticsClient ); $jsc=json_encode ( $statisticsClient ); $redis->set($redisKeyCS,$jsc); //办事处添加数量reids值 $redisKeyC=date('Y-m-d').'SC_'.$this->staff [0] ['cid'].'_'; $action_log = new action_log (); $actionLogClient = $action_log->find ( array ( 'select' => 'date_format(updatetime,"%m-%d") as updatetime,COUNT(*) as count', 'where' => $alCondition." status=1" . $categoryCondition.' and date_sub(curdate(), INTERVAL 30 DAY) <= date(updatetime)', 'groupby' => 'date_format(updatetime,"%m-%d")', 'asArray' => true ) ); $statisticsClient = array (); for($d = 0; $d <= 29; $d ++) { $MD = date ( "m-d", strtotime ( "-" . $d . " day" ) ); $falgClient = true; foreach ( $actionLogClient as $value ) { if ($value ['updatetime'] == $MD) { array_push ( $statisticsClient, $value ['count'] ); $falgClient = false; break; } } if ($falgClient) array_push ( $statisticsClient, 0 ); } $statisticsClient = array_reverse ( $statisticsClient ); $jsc=json_encode ( $statisticsClient ); $redis->set($redisKeyC,$jsc); //全员添加数量的redis值 $redisKey=date('Y-m-d').'SC__'; $action_log = new action_log (); $actionLogClient = $action_log->find ( array ( 'select' => 'date_format(updatetime,"%m-%d") as updatetime,COUNT(*) as count', 'where' => $alCondition.' status=1 and date_sub(curdate(), INTERVAL 30 DAY) <= date(updatetime)', 'groupby' => 'date_format(updatetime,"%m-%d")', 'asArray' => true ) ); $statisticsClient = array (); for($d = 0; $d <= 29; $d ++) { $MD = date ( "m-d", strtotime ( "-" . $d . " day" ) ); $falgClient = true; foreach ( $actionLogClient as $value ) { if ($value ['updatetime'] == $MD) { array_push ( $statisticsClient, $value ['count'] ); $falgClient = false; break; } } if ($falgClient) array_push ( $statisticsClient, 0 ); } $statisticsClient = array_reverse ( $statisticsClient ); $jsc=json_encode ( $statisticsClient ); $redis->set($redisKey,$jsc); } return "/contacts"; } function mycompany() { $search = $this->get_args ( 'search' ) ? $this->get_args ( 'search' ) : ""; $districtLv = $this->get_args ( 'districtLv' ) ? $this->get_args ( 'districtLv' ) : 0; $nature = $this->get_args ( 'nature' ) ? $this->get_args ( 'nature' ) : ""; $lv1 = $this->get_args ( 'lv1' ) ? $this->get_args ( 'lv1' ) : 0; $lv2 = $this->get_args ( 'lv2' ) ? $this->get_args ( 'lv2' ) : 0; $lv3 = $this->get_args ( 'lv3' ) ? $this->get_args ( 'lv3' ) : 0; $tagList = $this->get_args ( 'tag' ) ? $this->get_args ( 'tag' ) : array (); if ($lv1 == 0) { $lv1 = isset ( $this->params ['lv1'] ) && is_numeric ( $this->params ['lv1'] ) ? $this->params ['lv1'] : 0; if ($lv1 != 0) $districtLv = 1; } if ($lv2 == 0) { $lv2 = isset ( $this->params ['lv2'] ) && is_numeric ( $this->params ['lv2'] ) ? $this->params ['lv2'] : 0; if ($lv2 != 0) $districtLv = 2; } if ($lv3 == 0) { $lv3 = isset ( $this->params ['lv3'] ) && is_numeric ( $this->params ['lv3'] ) ? $this->params ['lv3'] : 0; if ($lv2 != 0) $districtLv = 3; } if (empty ( $search )) $search = urldecode ( isset ( $this->params ['search'] ) ? $this->params ['search'] : "" ); $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1; $data ['memu'] = "contacts"; $data ['staff'] = $this->staff; Doo::loadModel ( 'district' ); Doo::loadModel ( 'company' ); Doo::loadModel ( 'client' ); Doo::loadModel ( 'tag' ); Doo::loadModel ( 'L_category' ); $lcategory = new L_category (); $tag = new tag (); $client = new client (); $company = new company (); $district = new district (); Doo::loadModel ( 'tagCompany' ); $tagCompany = new tagCompany (); Doo::loadModel ( 'tagCompanyNexus' ); $tagCompanyNexus = new tagCompanyNexus (); $data ['district2'] = $district->get_lv ( 1 ); $category = $lcategory->getCategoryById ( $this->staff [0] ['cid'], $this->staff [0] ['othercid'] ); $cateStr = ""; $list = array (); foreach ( $category as $key => $value ) { array_push ( $list, " district like '" . $value ['districtid'] . ",%' " ); } if ($this->staff [0] ['isadmin'] != 1) $cateStr = implode ( " or ", $list ); else $cateStr = " 1"; $size = 300; if (! empty ( $nature )) $cateStr = " 1"; $data ['htmllv2'] = array (); $data ['htmllv3'] = array (); $condition = ""; if ($districtLv == 1) { $condition = ""; if (! empty ( $lv1 )) { $condition = " district like '" . $lv1 . ",%'"; $data ['htmllv2'] = $district->get_lvByid ( 2, $lv1 ); } } if ($districtLv == 2) { if (! empty ( $lv2 )) $condition = " district like '" . $lv1 . "," . $lv2 . ",%'"; else $condition = " district like '" . $lv1 . ",%'"; $data ['htmllv2'] = $district->get_lvByid ( 2, $lv1 ); $data ['htmllv3'] = $district->get_lvByid ( 2, $lv2 ); } if ($districtLv == 3) { if (! empty ( $lv3 )) $condition = " district like '" . $lv1 . "," . $lv2 . "," . $lv3 . "'"; else $condition = " district like '" . $lv1 . "," . $lv2 . ",%'"; $data ['htmllv2'] = $district->get_lvByid ( 2, $lv1 ); $data ['htmllv3'] = $district->get_lvByid ( 2, $lv2 ); } $districtCount = $condition; if (! empty ( $condition )) $cateStr = $condition; if (! empty ( $nature )) $cateStr .= " and nature like '%" . $nature . "%'"; // echo "
".$cateStr."

"; $tagSQL = false; if (! empty ( $tagList )) { $tagSQL = true; foreach ( $tagList as $value ) { $cateStr .= " and a.tag like '%" . $value . "%' "; } } if ($this->staff [0] ['isadmin'] != 1) { $pageinfo = $this->get_Tpage ( "CLD_company", $cateStr, $page, $size, "", $tagSQL ); } else { if ($tagSQL) $pageinfo = $this->get_Tpage ( "CLD_company", $cateStr, $page, $size, "", $tagSQL ); else { $total_page = $company->count ( array () ); $total = intval ( $total_page / $size ); $pageinfo ['total_page'] = ($total_page % $size) == 0 ? $total : $total + 1; } } $k = ""; for($i = 1; $i <= $pageinfo ['total_page']; $i ++) { if ($page == $i) $k .= ""; else $k .= ""; } $data ['pageinfo'] = $k; $data ['company'] = $company->getCompanyByDistrict ( $this->staff [0] ['sid'], $cateStr, $this->staff [0] ['isadmin'], $page, $size, $tagSQL ); if ($this->staff [0] ['isadmin'] != 1) { $data ['district'] = $district->get_lvByStaffid ( 1, $this->staff [0] ['sid'] ); } else { $data ['district'] = $data ['district2']; } // 获得标签 $ClientTagList = $tagCompanyNexus->getTagClientBySid ( $this->staff [0] ['sid'] ); foreach ( $ClientTagList as $key => $value ) { $ClientTagList [$key] ['taginfo'] = $tagCompany->getTagByTidL ( $value ['tag'] ); } foreach ( $data ['company'] as $key => $value ) { if (! empty ( $value ['cid'] )) { $data ['company'] [$key] ['taginfo'] = array (); $data ['company'] [$key] ['tag'] = ""; foreach ( $ClientTagList as $k => $v ) { if ($value ['cid'] == $v ['company']) { $data ['company'] [$key] ['taginfo'] = $v ['taginfo']; $data ['company'] [$key] ['tag'] = $v ['tag']; } } } } $comcid = $countL = array (); foreach ( $data ['company'] as $key => $value ) { array_push ( $comcid, $value ['cid'] ); } $comcid = implode ( ",", $comcid ); if (! empty ( $comcid )) $countL = $client->getCountByCompany ( $comcid ); foreach ( $data ['company'] as $key => $value ) { $data ['company'] [$key] ['count'] = 0; foreach ( $countL as $k => $v ) { if ($value ['cid'] == $v ['companyid']) { $data ['company'] [$key] ['count'] = $v ['count']; break; } } } $CC1 = ""; $CC2 = ""; $CC3 = ""; $natureHtml = ''; if (! empty ( $districtCount )) { $clientCount = $company->find ( array ( 'select' => 'district', 'where' => "district like '" . $lv1 . ",%'", 'asArray' => TRUE ) ); $CC1 = count ( $clientCount ); if (! empty ( $clientCount ) && ! empty ( $lv2 )) { $CC2 = 0; foreach ( $clientCount as $key => $value ) { if (strpos ( $value ['district'], $lv2 )) { $CC2 ++; } } } if (! empty ( $clientCount ) && ! empty ( $lv3 )) { $CC3 = 0; foreach ( $clientCount as $key => $value ) { if (strpos ( $value ['district'], $lv3 )) { $CC3 ++; } } } $clientCount = $company->find ( array ( 'select' => 'district,nature', 'where' => $districtCount, 'asArray' => TRUE ) ); $natureCount = array (); foreach ( $this->nature as $value ) { $natureCount [$value] = 0; foreach ( $clientCount as $v ) { $ak = explode ( ",", $v ['nature'] ); foreach ( $ak as $a ) { if ($value == $a) { $natureCount [$value] ++; } } } } } $natureHtml = ''; foreach ( $this->nature as $value ) { $natureHtml .= '' . $value . '(' . $natureCount [$value] . ')'; else $natureHtml .= 'onclick="showNature(\'' . $value . '\',this)">' . $value . ''; } $taglist = $tagCompany->find ( array ( 'where' => 'sid=' . $this->staff [0] ['sid'], 'asArray' => TRUE ) ); if (empty ( $taglist )) { for($i = 1; $i <= 7; $i ++) { $tag = new tagCompany (); $tag->name = "个人标签"; $tag->sid = $this->staff [0] ['sid']; $tag->colorid = $i; $tag->insert (); } } $data ['product'] = array (); $data ['tagList'] = $tagList; $data ['tag'] = $tagCompany->getAllBySid ( $this->staff [0] ['sid'] ); $data ['natureHtml'] = $natureHtml; $data ['CC1'] = $CC1; $data ['CC2'] = $CC2; $data ['CC3'] = $CC3; $data ['lv1'] = $lv1; $data ['lv2'] = $lv2; $data ['lv3'] = $lv3; $data ['districtLv'] = $districtLv; $data ['Hnature'] = $nature; $data ['nature'] = $this->nature; $this->render ( "/contacts_company", $data ); } function contacts() { $data ['memu'] = "contacts"; $data ['staff'] = $this->staff; $search = $this->get_args ( 'search' ) ? trim ( $this->get_args ( 'search' ) ) : ""; if (empty ( $search )) $search = urldecode ( isset ( $this->params ['search'] ) ? $this->params ['search'] : "" ); $lv1 = $this->get_args ( 'lv1' ) ? $this->get_args ( 'lv1' ) : 0; $lv2 = $this->get_args ( 'lv2' ) ? $this->get_args ( 'lv2' ) : 0; $lv3 = $this->get_args ( 'lv3' ) ? $this->get_args ( 'lv3' ) : 0; $lv4 = $this->get_args ( 'lv4' ) ? $this->get_args ( 'lv4' ) : ""; $tagList = $this->get_args ( 'tag' ) ? $this->get_args ( 'tag' ) : array (); $tooltip = $this->get_args ( 'tooltip' ) ? $this->get_args ( 'tooltip' ) : ""; $districtLv = $this->get_args ( 'districtLv' ) ? $this->get_args ( 'districtLv' ) : 0; if ($lv1 == 0) { $lv1 = isset ( $this->params ['lv1'] ) && is_numeric ( $this->params ['lv1'] ) ? $this->params ['lv1'] : 0; if ($lv1 != 0) $districtLv = 1; } if ($lv2 == 0) { $lv2 = isset ( $this->params ['lv2'] ) && is_numeric ( $this->params ['lv2'] ) ? $this->params ['lv2'] : 0; if ($lv2 != 0) $districtLv = 2; } if ($lv3 == 0) { $lv3 = isset ( $this->params ['lv3'] ) && is_numeric ( $this->params ['lv3'] ) ? $this->params ['lv3'] : 0; if ($lv2 != 0) $districtLv = 3; } $sortV = $this->get_args ( 'sortV' ) ? $this->get_args ( 'sortV' ) : "h"; $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1; Doo::loadModel ( 'client_staff' ); Doo::loadModel ( 'client' ); Doo::loadModel ( 'tag' ); Doo::loadModel ( 'district' ); Doo::loadModel ( 'tag_client' ); Doo::loadModel ( 'L_category' ); Doo::loadModel ( 'longle' ); Doo::loadModel ( 'C_tooltip' ); $c_tooltip = new C_tooltip (); $longle = new longle (); $client = new client (); $category = new L_category (); $tagClient = new tag_client (); $district = new district (); $tag = new tag (); $client_staff = new client_staff (); $data ['tag'] = $tag->getAllBySid ( $this->staff [0] ['sid'] ); $data ['district2'] = $district->get_lv ( 1 ); $page_size = 200; $linfo = $category->getCategoryById ( $this->staff [0] ['cid'], $this->staff ['0'] ['othercid'] ); $staffid = $condition = $a = ""; if ($this->staff [0] ['isadmin'] != 1) { // 加入办事处地区 $data ['district'] = $district->get_lvByStaffid ( 1, $this->staff [0] ['sid'] ); if (! empty ( $search )) $sch = " and ( address like '%" . $search . "%' or clientname like '%" . $search . "%' or companyname like '%" . $search . "%' or qq like '%" . $search . "%' or telephone like '%" . $search . "%' or phone like '%" . $search . "%')"; else { // or b.district like '".$linfo[0]['districtid']."%' $a = " and b.district like '" . $linfo [0] ['districtid'] . "%'"; if (! empty ( $tooltip )) $sch = ""; $search = urldecode ( isset ( $this->params ['search'] ) ? $this->params ['search'] : "" ); if (! empty ( $search )) $sch = " and ( address like '%" . $search . "%' or clientname like '%" . $search . "%' or companyname like '%" . $search . "%' or qq like '%" . $search . "%' or telephone like '%" . $search . "%' or phone like '%" . $search . "%')"; else { $staffid = $data ['staff'] [0] ['sid']; $sqstr = ""; foreach ( $linfo as $key => $value ) { if ($key != 0) { $sqstr .= " or b.district like '" . $value ['districtid'] . ",%'"; } } $a = "and b.district like '" . $linfo [0] ['districtid'] . ",%'" . $sqstr; } } } else { $data ['district'] = $data ['district2']; if (! empty ( $search )) $sch = " and ( address like '%" . $search . "%' or clientname like '%" . $search . "%' or companyname like '%" . $search . "%' or qq like '%" . $search . "%' or telephone like '%" . $search . "%' or phone like '%" . $search . "%')"; else { $sch = " "; $search = urldecode ( isset ( $this->params ['search'] ) ? $this->params ['search'] : "" ); if (! empty ( $search )) $sch = " and ( address like '%" . $search . "%' or clientname like '%" . $search . "%' or companyname like '%" . $search . "%' or qq like '%" . $search . "%' or telephone like '%" . $search . "%' or phone like '%" . $search . "%')"; } } $data ['htmllv2'] = $data ['htmllv3'] = array (); if ($districtLv == 1) { $a = ""; $condition = ""; if (! empty ( $lv1 )) { $condition .= " and district like '" . $lv1 . ",%'"; $data ['htmllv2'] = $district->get_lvByid ( 2, $lv1 ); } } if ($districtLv == 2) { $a = ""; if (! empty ( $lv2 )) $condition .= " and district like '" . $lv1 . "," . $lv2 . ",%'"; else $condition .= " and district like '" . $lv1 . ",%'"; $data ['htmllv2'] = $district->get_lvByid ( 2, $lv1 ); $data ['htmllv3'] = $district->get_lvByid ( 2, $lv2 ); } if ($districtLv == 3) { $a = ""; if (! empty ( $lv3 )) $condition .= " and district like '" . $lv1 . "," . $lv2 . "," . $lv3 . "'"; else $condition .= " and district like '" . $lv1 . "," . $lv2 . ",%'"; $data ['htmllv2'] = $district->get_lvByid ( 2, $lv1 ); $data ['htmllv3'] = $district->get_lvByid ( 2, $lv2 ); } $condition .= $a; $districtCount = $condition; if (! empty ( $lv4 )) { $condition .= " and nature like '%" . $lv4 . "%'"; } $tagSQL = false; if (! empty ( $tagList )) { $tagSQL = true; foreach ( $tagList as $value ) { $condition .= " and c.tag like '%" . $value . "%' "; } $search = ""; } if (! empty ( $search )) $condition .= $sch; // if(!empty($tooltip)) // $condition.=" and tooltip like '%".$tooltip."%'"; $pageinfo = $this->get_page ( "CLD_client_staff", $condition, $page, $page_size, "", "", "", $staffid, $search, $tooltip, $this->staff [0] ['cid'], $tagSQL ); if ($sortV == "h") { // order by a.cid desc $limit = " order by cid desc limit " . $pageinfo ['lower'] . " , " . $page_size . " "; } if ($sortV == "g") { // order by updatetime desc $limit = " limit " . $pageinfo ['lower'] . " , " . $page_size . " "; } if ($sortV == "f") { // order by updatetime desc $limit = " limit " . $pageinfo ['lower'] . " , " . $page_size . " "; } if ($sortV == "i") { // order by servicetime desc $limit = " limit " . $pageinfo ['lower'] . " , " . $page_size . " "; } // 检索是全局 $data ['clientInfo'] = $client_staff->getClientByStaff ( $condition, $limit, $staffid, $this->staff [0] ['sid'], $search, $tooltip, $this->staff [0] ['cid'], $tagSQL ); // 获取其他办事处的客户 // if(!empty($districtstr)){ // $buclient=$client->getClientByDistrict($districtstr); // // foreach ($buclient as $key=>$vlaue){ // // $falg=true; // // foreach ($data['clientInfo'] as $y=>$v){ // if($vlaue['clientname']==$v['clientname']&&$vlaue['companyname']==$v['companyname']) // $falg=false; // } // if($falg) // array_push($data['clientInfo'], $vlaue); // } // // } $k = ""; for($i = 1; $i <= $pageinfo ['total_page']; $i ++) { if ($page == $i) $k .= ""; else $k .= ""; } $data ['pageinfo'] = $k; Doo::loadModel ( 'product' ); $product = new product (); $data ['nature'] = $this->nature; $data ['product'] = $product->getProudct (); // 获得标签 $ClientTagList = $tagClient->getTagClientBySid ( $this->staff [0] ['sid'] ); $toollist = $c_tooltip->find ( array ( 'where' => 'cateid=' . $this->staff [0] ['cid'], 'asArray' => true ) ); // $ToolTipList=$ foreach ( $ClientTagList as $key => $value ) { $ClientTagList [$key] ['taginfo'] = $tag->getTagByTidL ( $value ['tag'] ); } // print_r($ClientTagList);die; foreach ( $data ['clientInfo'] as $key => $value ) { if (! empty ( $value ['cid'] )) { // $tinfo=$tagClient->getTagClientBySCid($value['cid'], $this->staff[0]['sid']); $data ['clientInfo'] [$key] ['taginfo'] = array (); $data ['clientInfo'] [$key] ['tag'] = ""; foreach ( $ClientTagList as $k => $v ) { // $tag->getTagByTidL($value['tag']);$value['tag']; if ($value ['cid'] == $v ['client']) { $data ['clientInfo'] [$key] ['taginfo'] = $v ['taginfo']; $data ['clientInfo'] [$key] ['tag'] = $v ['tag']; } } // array_pop 可以优化数组 } $data ['clientInfo'] [$key] ['tooltipList'] = array (); foreach ( $toollist as $k => $v ) { if ($v ['cid'] == $value ['cid']) { $data ['clientInfo'] [$key] ['tooltipList'] = explode ( ",", $v ['name'] ); break; } // array_pop 可以优化数组 } // $tl=array(); // if(!empty($value['tooltip'])) // $tl=explode(',', $value['tooltip']); // $data['clientInfo'][$key]['tooltipList']=$tl; $data ['clientInfo'] [$key] ['locount'] = 0; // $longle->count(array('where'=>'clientid='.$value['cid'])); } $CC1 = ""; $CC2 = ""; $CC3 = ""; if (! empty ( $districtCount )) { $clientCount = $client->find ( array ( 'select' => 'district', 'where' => "district like '" . $lv1 . ",%'", 'asArray' => TRUE ) ); $CC1 = count ( $clientCount ); if (! empty ( $clientCount ) && ! empty ( $lv2 )) { $CC2 = 0; foreach ( $clientCount as $key => $value ) { if (strpos ( $value ['district'], $lv2 )) { $CC2 ++; } } } if (! empty ( $clientCount ) && ! empty ( $lv3 )) { $CC3 = 0; foreach ( $clientCount as $key => $value ) { if (strpos ( $value ['district'], $lv3 )) { $CC3 ++; } } } } Doo::loadModel ( 'remind' ); $remind = new remind (); // and date_add(time, INTERVAL day DAY) <= CURDATE() $remindList = $remind->find ( array ( 'where' => "staffID = '" . $this->staff [0] ['sid'] . "' and status=0 ", 'asc' => 'date_add(time, INTERVAL day DAY)', 'asArray' => TRUE ) ); $rc = 0; foreach ( $remindList as $key => $value ) { $a = strtotime ( $value ['time'] . " +" . $value ['day'] . " days" ); $b = strtotime ( date ( 'y-m-d' ) ); if ($a <= $b) { $rc ++; $remindList [$key] ['isRemind'] = 1; } else $remindList [$key] ['isRemind'] = 0; $remindList [$key] ['Ctime'] = date ( 'm-d', strtotime ( $value ['time'] ) ); $remindList [$key] ['Etime'] = date ( 'm-d', strtotime ( $value ['time'] . " +" . $value ['day'] . " days" ) ); } $data ['remindCount'] = $rc; $data ['remindList'] = $remindList; $data ['CC1'] = $CC1; $data ['CC2'] = $CC2; $data ['CC3'] = $CC3; $data ['lv1'] = $lv1; $data ['lv2'] = $lv2; $data ['lv3'] = $lv3; $data ['lv4'] = $lv4; $data ['districtLv'] = $districtLv; $data ['tagList'] = $tagList; $data ['tooltip'] = $this->tooltip; $data ['ttip'] = $tooltip; $data ['search'] = $search; $data ['totalData'] = $pageinfo ['total_data']; // $data['messagehtml']=$html; $this->render ( "/contacts_client", $data ); } function remindCL() { $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0; Doo::loadModel ( 'remind' ); $remind = new remind (); $remind->status = 1; $remind->update ( array ( 'where' => "staffID = '" . $this->staff [0] ['sid'] . "' and rid=" . $rid, 'asArray' => TRUE ) ); return "/contacts"; } function communication() { $data ['memu'] = "contacts"; $data ['staff'] = $this->staff; $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0; Doo::loadModel ( 'L_category' ); $L_category = new L_category (); Doo::loadModel ( 'staff' ); $staff = new staff (); Doo::loadModel ( 'staffDynamic' ); $staffDynamic = new staffDynamic (); if (! empty ( $cid )) $data ['staffList'] = $staff->getStaffByCid ( $cid ); else $data ['staffList'] = $staff->getStaff (); foreach ( $data ['staffList'] as $key => $value ) { if (! empty ( $value ['birthday'] )) { $dataD = date ( "d", strtotime ( $value ['birthday'] ) ); if (date ( 'm' ) == date ( "m", strtotime ( $value ['birthday'] ) )) { $now = date ( 'd' ); $post = $dataD - 7; // date("d",mktime(0,0,0,date("m"),date("d")+7,date("Y"))); if ($now >= $post && $now <= $dataD) { $data ['staffList'] [$key] ['birthday'] = "birthday"; $data ['staffList'] [$key] ['birthDAY'] = date ( "m-d", strtotime ( $value ['birthday'] ) ); } } } $happy = date ( "m-d", strtotime ( $value ['birthday'] ) ); if ($happy == date ( 'm-d' )) { $SBL = $staffDynamic->getStaffBirthday ( $happy, $value ['sid'] ); if (empty ( $SBL )) { $staffDynamic->content = '今天过生日!'; $staffDynamic->cid = $value ['cid']; $staffDynamic->category = $value ['category']; $staffDynamic->time = time (); $staffDynamic->sid = $value ['sid']; $staffDynamic->staff = $value ['username']; $staffDynamic->insert (); } } } $sDynaimic = $staffDynamic->getStaffDynamic (); foreach ( $sDynaimic as $key => $value ) { $time = date ( "Y-m-d", $value ['time'] ); $timeArray = explode ( '-', $time ); $sDynaimic [$key] ['year'] = $timeArray [0]; $sDynaimic [$key] ['month'] = $timeArray [1]; $sDynaimic [$key] ['day'] = $timeArray [2]; } $data ['sDynaimic'] = $sDynaimic; $data ['category'] = $L_category->getCategory (); $data ['cid'] = $cid; $this->render ( "/staff_contacts", $data ); } function app() { $data ['memu'] = "app"; $data ['staff'] = $this->staff; $this->render ( "/app", $data ); } function synClient() { if ($this->staff [0] ['isadmin'] != 1) { Doo::loadModel ( 'L_category' ); Doo::loadModel ( 'client_staff' ); $client_staff = new client_staff (); $cate = new L_category (); $district = $cate->getOne ( array ( 'where' => 'cid=' . $this->staff [0] ['cid'], 'asArray' => true ) ); $syn = $client_staff->synClient ( $this->staff [0] ['sid'], $district ['districtid'] ); $bei = $client_staff->find ( array ( 'where' => "sid = " . $this->staff [0] ['sid'], 'asArray' => true ) ); foreach ( $syn as $value ) { $falg = true; foreach ( $bei as $v ) { if (($v ['cid'] == $value ['cid']) && ($v ['sid'] == $this->staff [0] ['sid'])) { $falg = false; break; } } if ($falg) { $client_staff = new client_staff (); $client_staff->sid = $this->staff [0] ['sid']; $client_staff->cid = $value ['cid']; $client_staff->insert (); } } } return "/contacts"; } function DoAddTagCompany() { $cid = $this->get_args ( 'id' ); $tid = $this->get_args ( 'tagALD' ); Doo::loadModel ( 'tagCompanyNexus' ); $strtid = implode ( ",", $tid ); foreach ( $cid as $key => $value ) { $tagClient = new tagCompanyNexus (); $tagClientInfo = $tagClient->getTagClientBySCid ( $value, $this->staff [0] ['sid'] ); $ar = explode ( ",", $strtid . ',' . $tagClientInfo ['tag'] ); $re = array_filter ( array_unique ( $ar ) ); $tagClient->tag = implode ( ",", $re ); if (! empty ( $tagClientInfo )) { $tagClient->tcid = $tagClientInfo ['tcid']; $tagClient->update (); } else { $tagClient->sid = $this->staff [0] ['sid']; $tagClient->company = $value; $tagClient->insert (); } } header ( "Location: /mycompany" ); } function DoAddTag() { $cid = $this->get_args ( 'id' ); $tooltipAct = $this->get_args ( 'tooltipAct' ) ? $this->get_args ( 'tooltipAct' ) : ""; Doo::loadModel ( 'client' ); if (! empty ( $tooltipAct )) { $tid = $this->get_args ( 'tooltiplist' ); $k = implode ( ",", $tid ); Doo::loadModel ( 'C_tooltip' ); $s = " and cateid=" . $this->staff [0] ['cid']; if (! empty ( $this->staff [0] ['othercid'] )) { $othercid = explode ( ",", $this->staff [0] ['othercid'] ); foreach ( $othercid as $value ) { $s .= " or cateid=" . $value; } } foreach ( $cid as $key => $value ) { $C_tooltip = new C_tooltip (); $tooltip = $C_tooltip->getOne ( array ( 'where' => 'cid=' . $value . " " . $s, 'asArray' => true ) ); if (empty ( $tooltip )) { $C_tooltip->cid = $value; $C_tooltip->name = $k; $C_tooltip->cateid = $this->staff [0] ['cid']; $C_tooltip->insert (); } else { $C_tooltip->tip = $tooltip ['tip']; $C_tooltip->name = $k; $C_tooltip->update (); } } } else { $tid = $this->get_args ( 'tagALD' ); Doo::loadModel ( 'tag_client' ); $strtid = implode ( ",", $tid ); foreach ( $cid as $key => $value ) { $tagClient = new tag_client (); $tagClientInfo = $tagClient->getTagClientBySCid ( $value, $this->staff [0] ['sid'] ); $ar = explode ( ",", $strtid . ',' . $tagClientInfo ['tag'] ); $re = array_filter ( array_unique ( $ar ) ); $tagClient->tag = implode ( ",", $re ); if (! empty ( $tagClientInfo )) { $tagClient->tcid = $tagClientInfo ['tcid']; $tagClient->update (); } else { $tagClient->sid = $this->staff [0] ['sid']; $tagClient->client = $value; $tagClient->insert (); } } } header ( "Location: /contacts" ); } function ajaxDeleteTag() { $cid = $this->get_args ( 'cid' ); $tid = $this->get_args ( 'tid' ); Doo::loadModel ( 'tag_client' ); $tagClient = new tag_client (); $tagInfo = $tagClient->getTagClientBySCid ( $cid, $this->staff [0] ['sid'] ); $tag = str_replace ( $tid, "", $tagInfo ['tag'] ); $ar = explode ( ',', $tag ); $tag = implode ( ',', array_filter ( $ar ) ); $tagClient->tcid = $tagInfo ['tcid']; $tagClient->tag = $tag; $tagClient->update (); } function ajaxDeleteTagCompany() { $cid = $this->get_args ( 'cid' ); $tid = $this->get_args ( 'tid' ); Doo::loadModel ( 'tagCompanyNexus' ); $tagClient = new tagCompanyNexus (); $tagInfo = $tagClient->getTagClientBySCid ( $cid, $this->staff [0] ['sid'] ); $tag = str_replace ( $tid, "", $tagInfo ['tag'] ); $ar = explode ( ',', $tag ); $tag = implode ( ',', array_filter ( $ar ) ); $tagClient->tcid = $tagInfo ['tcid']; $tagClient->tag = $tag; $tagClient->update (); } function deleteToolTip() { $cid = $this->get_args ( 'cid' ); $cateid = $this->get_args ( 'cateid' ); $name = $this->get_args ( 'name' ); Doo::loadModel ( "C_tooltip" ); $tooltip = new C_tooltip (); if (! empty ( $cid ) && ! empty ( $cateid ) && ! empty ( $name )) { $tool = $tooltip->getOne ( array ( 'where' => 'cid=' . $cid . ' and cateid=' . $cateid, 'asArray' => true ) ); if (! empty ( $tool )) { $name = str_replace ( $name, "", $tool ['name'] ); $name = explode ( ',', $name ); $name = implode ( ',', array_filter ( $name ) ); $tooltip->name = $name; $tooltip->tip = $tool ['tip']; $tooltip->update (); } } } function DoEdiTagCompany() { $tag_1 = $this->get_args ( 'tag_1' ) ? $this->get_args ( 'tag_1' ) : ""; $tag_2 = $this->get_args ( 'tag_2' ) ? $this->get_args ( 'tag_2' ) : ""; $tag_3 = $this->get_args ( 'tag_3' ) ? $this->get_args ( 'tag_3' ) : ""; $tag_4 = $this->get_args ( 'tag_4' ) ? $this->get_args ( 'tag_4' ) : ""; $tag_5 = $this->get_args ( 'tag_5' ) ? $this->get_args ( 'tag_5' ) : ""; $tag_6 = $this->get_args ( 'tag_6' ) ? $this->get_args ( 'tag_6' ) : ""; $tag_7 = $this->get_args ( 'tag_7' ) ? $this->get_args ( 'tag_7' ) : ""; $tid_1 = $this->get_args ( 'tid_1' ) ? $this->get_args ( 'tid_1' ) : 0; $tid_2 = $this->get_args ( 'tid_2' ) ? $this->get_args ( 'tid_2' ) : 0; $tid_3 = $this->get_args ( 'tid_3' ) ? $this->get_args ( 'tid_3' ) : 0; $tid_4 = $this->get_args ( 'tid_4' ) ? $this->get_args ( 'tid_4' ) : 0; $tid_5 = $this->get_args ( 'tid_5' ) ? $this->get_args ( 'tid_5' ) : 0; $tid_6 = $this->get_args ( 'tid_6' ) ? $this->get_args ( 'tid_6' ) : 0; $tid_7 = $this->get_args ( 'tid_7' ) ? $this->get_args ( 'tid_7' ) : 0; Doo::loadModel ( 'tagCompany' ); if (! empty ( $tag_1 ) && ! empty ( $tid_1 )) { $tag = new tagCompany (); $tag->tid = $tid_1; $tag->name = $tag_1; $tag->update (); } if (! empty ( $tag_2 ) && ! empty ( $tid_2 )) { $tag = new tagCompany (); $tag->tid = $tid_2; $tag->name = $tag_2; $tag->update (); } if (! empty ( $tag_3 ) && ! empty ( $tid_3 )) { $tag = new tagCompany (); $tag->tid = $tid_3; $tag->name = $tag_3; $tag->update (); } if (! empty ( $tag_4 ) && ! empty ( $tid_4 )) { $tag = new tagCompany (); $tag->tid = $tid_4; $tag->name = $tag_4; $tag->update (); } if (! empty ( $tag_5 ) && ! empty ( $tid_5 )) { $tag = new tagCompany (); $tag->tid = $tid_5; $tag->name = $tag_5; $tag->update (); } if (! empty ( $tag_6 ) && ! empty ( $tid_6 )) { $tag = new tagCompany (); $tag->tid = $tid_6; $tag->name = $tag_6; $tag->update (); } if (! empty ( $tag_7 ) && ! empty ( $tid_7 )) { $tag = new tagCompany (); $tag->tid = $tid_7; $tag->name = $tag_7; $tag->update (); } return "/mycompany"; } function DoEdiTag() { $tag_1 = $this->get_args ( 'tag_1' ) ? $this->get_args ( 'tag_1' ) : ""; $tag_2 = $this->get_args ( 'tag_2' ) ? $this->get_args ( 'tag_2' ) : ""; $tag_3 = $this->get_args ( 'tag_3' ) ? $this->get_args ( 'tag_3' ) : ""; $tag_4 = $this->get_args ( 'tag_4' ) ? $this->get_args ( 'tag_4' ) : ""; $tag_5 = $this->get_args ( 'tag_5' ) ? $this->get_args ( 'tag_5' ) : ""; $tag_6 = $this->get_args ( 'tag_6' ) ? $this->get_args ( 'tag_6' ) : ""; $tag_7 = $this->get_args ( 'tag_7' ) ? $this->get_args ( 'tag_7' ) : ""; $tid_1 = $this->get_args ( 'tid_1' ) ? $this->get_args ( 'tid_1' ) : 0; $tid_2 = $this->get_args ( 'tid_2' ) ? $this->get_args ( 'tid_2' ) : 0; $tid_3 = $this->get_args ( 'tid_3' ) ? $this->get_args ( 'tid_3' ) : 0; $tid_4 = $this->get_args ( 'tid_4' ) ? $this->get_args ( 'tid_4' ) : 0; $tid_5 = $this->get_args ( 'tid_5' ) ? $this->get_args ( 'tid_5' ) : 0; $tid_6 = $this->get_args ( 'tid_6' ) ? $this->get_args ( 'tid_6' ) : 0; $tid_7 = $this->get_args ( 'tid_7' ) ? $this->get_args ( 'tid_7' ) : 0; Doo::loadModel ( 'tag' ); if (! empty ( $tag_1 ) && ! empty ( $tid_1 )) { $tag = new tag (); $tag->tid = $tid_1; $tag->name = $tag_1; $tag->update (); } if (! empty ( $tag_2 ) && ! empty ( $tid_2 )) { $tag = new tag (); $tag->tid = $tid_2; $tag->name = $tag_2; $tag->update (); } if (! empty ( $tag_3 ) && ! empty ( $tid_3 )) { $tag = new tag (); $tag->tid = $tid_3; $tag->name = $tag_3; $tag->update (); } if (! empty ( $tag_4 ) && ! empty ( $tid_4 )) { $tag = new tag (); $tag->tid = $tid_4; $tag->name = $tag_4; $tag->update (); } if (! empty ( $tag_5 ) && ! empty ( $tid_5 )) { $tag = new tag (); $tag->tid = $tid_5; $tag->name = $tag_5; $tag->update (); } if (! empty ( $tag_6 ) && ! empty ( $tid_6 )) { $tag = new tag (); $tag->tid = $tid_6; $tag->name = $tag_6; $tag->update (); } if (! empty ( $tag_7 ) && ! empty ( $tid_7 )) { $tag = new tag (); $tag->tid = $tid_7; $tag->name = $tag_7; $tag->update (); } return "/contacts"; } function ajaxGetLv2() { $lv1 = $this->get_args('lv1') ? $this->get_args('lv1') : 0; $s = $this->get_args('s') ? $this->get_args('s') : 0; if ($lv1 == 0) { echo json_encode ( array ( "success" => false, "info" => "" ) ); die (); } if (! empty ( $lv1 )) { Doo::loadModel ( 'district' ); $district = new district (); $district = $district->get_lvByid ( $s, $lv1 ); echo json_encode ( array ( "success" => true, "info" => $district ) ); } } function keyonline() { $data ['memu'] = "keyonline"; $data ['staff'] = $this->staff; $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : ""; if (empty ( $year )) $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( 'Y' ); $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : ""; if (empty ( $cid )) $cid = isset ( $this->params ['cid'] ) ? $this->params ['cid'] : $this->staff [0] ['cid']; $staff = $this->get_args ( 'staff' ) ? $this->get_args ( 'staff' ) : ""; if (empty ( $staff )) $staff = isset ( $this->params ['staff'] ) ? $this->params ['staff'] : ""; $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : ""; if (empty ( $status )) $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : 0; $search = $this->get_args ( 'search' ) ? $this->get_args ( 'search' ) : ""; $productW = $this->get_args ( 'product' ) ? $this->get_args ( 'product' ) : ""; Doo::loadModel ( 'longle' ); $longle = new longle (); $data ['longleArray'] = $longle->getLongleByStatus ( $year, $cid, $staff, $status, $search, $productW ); // 获取接收锁信息 // $longle->getLongleByRe($this->staff[0]['cid'],1); $othstr = ""; if (! empty ( $this->staff [0] ['othercid'] )) $othstr = " cid in (" . $this->staff [0] ['cid'] . "," . $this->staff [0] ['othercid'] . ")"; else $othstr = " cid in (" . $this->staff [0] ['cid'] . ")"; $data ['reLongle'] = $longle->count ( array ( 'where' => $othstr . ' and status=1' ) ); $data ['cid'] = $cid; $data ['year'] = $year; $data ['staff'] = $staff; $data ['status'] = $status; $data ['productName'] = $productW; Doo::loadModel ( 'L_category' ); Doo::loadModel ( 'staff' ); Doo::loadModel ( 'product' ); $product = new product (); $staff = new staff (); $L_category = new L_category (); $data ['product'] = $product->getProudct (); $data ['staffu'] = $staff->getUserById ( $this->staff [0] ['sid'] ); $data ['category'] = $L_category->getCategory (); $data ['staffList'] = $staff->getStaffByCid ( $cid ); if ($cid == 1) $data ['cid'] = $data ['category'] [0] ['cid']; $dateHtml = ""; $now = date ( "Y" ); for($YEARD = 2050; $YEARD >= 2004; $YEARD --) { if ($YEARD <= $now) { $dateHtml .= ''; } } $data ['dateHtml'] = $dateHtml; $this->render ( "/lock_look", $data ); } function keyStatistics() { Doo::loadModel ( 'staff' ); $staff = new staff (); Doo::loadModel ( 'longle' ); $longle = new longle (); $staffCondition = ""; if ($this->staff [0] ['cid'] != 12) $staffCondition = " and cid=" . $this->staff [0] ['cid']; $staffList = $staff->find ( array ( 'where' => "isadmin= 0 " . $staffCondition, 'asArray' => TRUE ) ); Doo::db ()->beginTransaction (); foreach ( $staffList as $key => $value ) { // not in(1,2) $sum = $longle->count ( array ( 'where' => "status!= 1 and responsible ='" . $value ['username'] . "'", 'asArray' => TRUE ) ); $a = $longle->count ( array ( 'where' => "status!= 2 and status!= 1 and responsible ='" . $value ['username'] . "'", 'asArray' => TRUE ) ); $b = $sum - $a; $staffList [$key] ['sum'] = $sum; $staffList [$key] ['a'] = $a; $staffList [$key] ['b'] = $b; } Doo::db ()->commit (); $data ['staff'] = $this->staff; $data ['staffList'] = $staffList; $data ['memu'] = "keyStatistics"; $this->render ( "lock_count", $data ); } function addDoLockLog() { Doo::loadModel ( 'longle_log' ); Doo::loadModel ( 'longle' ); Doo::loadModel ( "action_log" ); Doo::loadModel ( 'client' ); $clientobj = new client (); $longle = new longle (); $longle_log = new longle_log (); Doo::loadModel ( 'district' ); $district = new district (); $status = $this->get_args('longleStatus') ? $this->get_args('longleStatus') : 0; $lid = $this->get_args('klid') ? $this->get_args('klid') : 0; if (empty ( $lid )) return "/keyonline/"; $linfo = $longle->getLongleByLid ( $lid ); if ($status == 0) return "/keyonline/" . $lid; elseif ($status == 3) { $client = $this->get_args('browseClient') ? $this->get_args('browseClient') : ""; $client = explode ( '-', $client ); $product = $this->get_args('browseProduct') ? $this->get_args('browseProduct') : ""; $clientname = $clientobj->getClientByName2 ( $client [0], $client [1] ); if (empty ( $clientname )) return "/keyonline/" . $lid; if ($client [0] != "") { $longle->client = $client [0]; $longle->clientid = $clientname [0] ['cid']; } // if($product!="") // $longle->product=$product; $longle->statusT = "借出"; $longle_log->client = $client [0]; $longle_log->clientid = $clientname [0] ['cid']; $longle_log->product = $linfo [0] ['product']; $longle_log->statusT = "借出"; // 日常行为 $action_log = new action_log (); $action_log->action = $this->staff [0] ['category'] . '' . $this->staff [0] ['username'] . '借出' . $linfo [0] ['key_num'] . '' . $client [0] . '(' . $clientname [0] ['companyname'] . ')'; $action_log->sid = $this->staff [0] ['sid']; $action_log->cid = $this->staff [0] ['cid']; $action_log->updatetime = date ( "Y-m-d" ); $action_log->time = date ( "H:i" ); $action_log->status = 4; $action_log->districtid = $clientname [0] ['district']; $local = $district->getbyidlist ( $clientname [0] ['district'] ); $action_log->city = $local [0] ['name']; $action_log->province = $local [1] ['name']; $action_log->company = $clientname [0] ['companyname']; Doo::loadModel ( 'company' ); $company = new company (); $companyInfo = $company->getOne ( array ( 'where' => ' companyname="' . $clientname [0] ['companyname'] . '"', 'asArray' => true ) ); $nature = explode ( ',', $companyInfo ['nature'] ); $action_log->nature = $nature [0]; $action_log->class = $action_log->iconBorrow; $action_log->insert (); } elseif ($status == 4) { $product = $this->get_args('sellProduct') ? $this->get_args('sellProduct') : ""; $client = $this->get_args('sellClient') ? $this->get_args('sellClient') : ""; $client = explode ( '-', $client ); $clientname = $clientobj->getClientByName2 ( $client [0], $client [1] ); if (empty ( $clientname )) return "/keyonline/" . $lid; if ($client [0] != "") { $longle->client = $client [0]; $longle->clientid = $clientname [0] ['cid']; } // if($product!="") // $longle->product=$product; $longle->statusT = "销售"; $longle_log->client = $client [0]; $longle_log->clientid = $clientname [0] ['cid']; $longle_log->product = $linfo [0] ['product']; $longle_log->statusT = "销售"; // 日常行为 $action_log = new action_log (); $action_log->action = $this->staff [0] ['category'] . '' . $this->staff [0] ['username'] . '销售' . $linfo [0] ['key_num'] . '' . $client [0] . '(' . $clientname [0] ['companyname'] . ')'; $action_log->sid = $this->staff [0] ['sid']; $action_log->cid = $this->staff [0] ['cid']; $action_log->updatetime = date ( "Y-m-d" ); $action_log->time = date ( "H:i" ); $action_log->status = 5; $action_log->districtid = $clientname [0] ['district']; $local = $district->getbyidlist ( $clientname [0] ['district'] ); $action_log->city = $local [0] ['name']; $action_log->province = $local [1] ['name']; $action_log->company = $clientname [0] ['companyname']; Doo::loadModel ( 'company' ); $company = new company (); $companyInfo = $company->getOne ( array ( 'where' => ' companyname="' . $clientname [0] ['companyname'] . '"', 'asArray' => true ) ); $nature = explode ( ',', $companyInfo ['nature'] ); $action_log->nature = $nature [0]; $action_log->class = $action_log->iconSell; $action_log->insert (); } elseif ($status == 5) { $product = $this->get_args('newProduct') ? $this->get_args('newProduct') : ""; if ($product != "") $longle->product = $linfo [0] ['product'] . "+" . $product; $longle->statusT = "升级"; $longle_log->product = $linfo [0] ['product'] . "+" . $product; $longle_log->statusT = "升级"; $longle_log->client = $linfo [0] ['client']; $longle_log->clientid = $linfo [0] ['clientid']; $clientname = $clientobj->getOne ( array ( 'where' => "cid= '" . $linfo [0] ['clientid'] . "'", 'asArray' => TRUE ) ); // 日常行为 $action_log = new action_log (); $action_log->action = $this->staff [0] ['category'] . '' . $this->staff [0] ['username'] . '' . $linfo [0] ['client'] . '(' . $clientname ['companyname'] . ')升级为' . $linfo [0] ['key_num'] . ''; $action_log->sid = $this->staff [0] ['sid']; $action_log->cid = $this->staff [0] ['cid']; $action_log->updatetime = date ( "Y-m-d" ); $action_log->time = date ( "H:i" ); $action_log->class = $action_log->iconUpdate; $action_log->sid = $this->staff [0] ['sid']; $action_log->cid = $this->staff [0] ['cid']; $action_log->status = 7; $action_log->insert (); } elseif ($status == 6) { $key_num = $this->get_args('key_num') ? $this->get_args('key_num') : ""; $key_num2 = explode ( "-", $key_num ); $key_num = $key_num2 [0] . "-" . $key_num2 [1]; // if($key_num!="") // $longle->key_num=$key_num; // 新锁拷贝记录 $newLongle = new longle (); // $newLongle->product=$linfo[0]['product']; $newLongle->statusT = "更换"; $newLongle->status = 6; $newLongle->client = $linfo [0] ['client']; $newLongle->clientid = $linfo [0] ['clientid']; $newlid = $newLongle->update ( array ( 'where' => ' key_num= \'' . $key_num . "'" ) ); $longleinfo = $longle->getOne ( array ( 'where' => ' key_num =\'' . $key_num . "'", 'asArray' => true ) ); $longleLog = $longle_log->getOne ( array ( 'where' => ' lid =' . $linfo [0] ['lid'], 'desc' => 'logid', 'asArray' => true ) ); // 新记录日志 $newlongle_log = new longle_log (); $newlongle_log->statusT = "更换"; $newlongle_log->status = 6; $newlongle_log->client = $linfo [0] ['client']; $newlongle_log->new_key_num = $linfo [0] ['key_num']; $newlongle_log->product = $linfo [0] ['product']; $newlongle_log->category = $this->staff [0] ['category']; $newlongle_log->dateline = date ( "Y-m-d" ); $newlongle_log->operator = $this->staff [0] ['username']; $newlongle_log->lid = $longleinfo ['lid']; $newlongle_log->insert (); $newlongle_log = new longle_log (); $newlongle_log->statusT = $longleLog ['statusT']; $newlongle_log->status = $longleLog ['status']; $newlongle_log->client = $longleLog ['client']; $newlongle_log->new_key_num = $longleLog ['new_key_num']; $newlongle_log->product = $longleLog ['product']; $newlongle_log->category = $longleLog ['category']; $newlongle_log->dateline = $longleLog ['dateline']; $newlongle_log->operator = $longleLog ['operator']; $newlongle_log->lid = $longleinfo ['lid']; $newlongle_log->insert (); $newLongle = new longle (); $newLongle->statusT = $longleLog ['statusT']; $newLongle->status = $longleLog ['status']; $newlid = $newLongle->update ( array ( 'where' => ' key_num= \'' . $key_num . "'" ) ); // 新锁状态拷贝 $longle->statusT = "更换"; $longle_log->new_key_num = $key_num; $longle_log->statusT = "更换"; $longle_log->client = $linfo [0] ['client']; $clientname = $clientobj->getOne ( array ( 'where' => "cid= '" . $linfo [0] ['clientid'] . "'", 'asArray' => TRUE ) ); // 日常行为 $action_log = new action_log (); $action_log->action = $this->staff [0] ['category'] . '' . $this->staff [0] ['username'] . '' . $linfo [0] ['client'] . '(' . $clientname ['companyname'] . ')更换为' . $key_num . '(' . $linfo [0] ['key_num'] . ')'; $action_log->sid = $this->staff [0] ['sid']; $action_log->cid = $this->staff [0] ['cid']; $action_log->updatetime = date ( "Y-m-d" ); $action_log->time = date ( "H:i" ); $action_log->class = $action_log->iconReplace; $action_log->sid = $this->staff [0] ['sid']; $action_log->cid = $this->staff [0] ['cid']; $action_log->status = 8; $action_log->insert (); } elseif ($status == 7) { $longle->statusT = "收回"; $longle_log->statusT = "收回"; $longle_log->responsible = $linfo [0] ['responsible']; // 日常行为 $action_log = new action_log (); $action_log->action = $this->staff [0] ['category'] . '' . $this->staff [0] ['username'] . '收回' . $linfo [0] ['client'] . '' . $linfo [0] ['key_num'] . '通过' . $this->staff [0] ['responsible'] . ''; $action_log->sid = $this->staff [0] ['sid']; $action_log->cid = $this->staff [0] ['cid']; $action_log->updatetime = date ( "Y-m-d" ); $action_log->time = date ( "H:i" ); $action_log->class = $action_log->iconRecycle; $action_log->sid = $this->staff [0] ['sid']; $action_log->cid = $this->staff [0] ['cid']; $action_log->status = 9; $action_log->insert (); } elseif ($status == 8) { $mark = $this->get_args('mark') ? $this->get_args('mark') : ""; if (empty ( $mark )) { echo json_encode ( array ( 'msg' => 2 ) ); die (); } $longle_log->mark = $mark; // 日常行为 $action_log = new action_log (); $action_log->action = $this->staff [0] ['category'] . '' . $this->staff [0] ['username'] . '' . $linfo [0] ['key_num'] . '添加新备注。'; $action_log->sid = $this->staff [0] ['sid']; $action_log->cid = $this->staff [0] ['cid']; $action_log->updatetime = date ( "Y-m-d" ); $action_log->time = date ( "H:i" ); $action_log->sid = $this->staff [0] ['sid']; $action_log->cid = $this->staff [0] ['cid']; $action_log->status = 10; $action_log->class = $action_log->iconLock; $action_log->insert (); } elseif ($status == 9) { $longle->statusT = "赠送"; $longle_log->statusT = "赠送"; $client = $this->get_args('giftClient') ? $this->get_args('giftClient') : ""; $client = explode ( '-', $client ); $clientname = $clientobj->getClientByName2 ( $client [0], $client [1] ); if (empty ( $clientname )) return "/keyonline/" . $lid; if ($client [0] != "") { $longle->client = $client [0]; $longle->clientid = $clientname [0] ['cid']; } $longle_log->client = $client [0]; $longle_log->clientid = $clientname [0] ['cid']; // 日常行为 $action_log = new action_log (); $action_log->action = $this->staff [0] ['category'] . '' . $this->staff [0] ['username'] . '赠送' . $linfo [0] ['key_num'] . '' . $client [0] . '(' . $clientname [0] ['companyname'] . ')'; $action_log->updatetime = date ( "Y-m-d" ); $action_log->time = date ( "H:i" ); $action_log->class = $action_log->iconRecycle; $action_log->sid = $this->staff [0] ['sid']; $action_log->cid = $this->staff [0] ['cid']; $action_log->status = 6; $action_log->districtid = $clientname [0] ['district']; $local = $district->getbyidlist ( $clientname [0] ['district'] ); $action_log->city = $local [0] ['name']; $action_log->province = $local [1] ['name']; $action_log->company = $clientname [0] ['companyname']; Doo::loadModel ( 'company' ); $company = new company (); $companyInfo = $company->getOne ( array ( 'where' => ' companyname="' . $clientname [0] ['companyname'] . '"', 'asArray' => true ) ); $nature = explode ( ',', $companyInfo ['nature'] ); $action_log->nature = $nature [0]; $action_log->insert (); } // 记录使用过的状态 $statuslog = $status . "," . $linfo [0] ['statuslog']; $ar = explode ( ',', $statuslog ); $statuslog = implode ( ',', array_unique ( array_filter ( $ar ) ) ); $longle->statuslog = $statuslog; if ($linfo [0] ['status'] <= 2) { if ($status >= 4 && $status <= 2) { return "/keyonline/" . $lid; } } if ($lid != 0) { $longle->lid = $lid; if ($status != 8) $longle->status = $status; // if($status!=8) $longle->responsible = $this->staff [0] ['username']; $longle->update (); } $longle_log->lid = $lid; $longle_log->status = $status; $longle_log->operator = $this->staff [0] ['username']; // 责任人 $longle_log->category = $this->staff [0] ['category']; $longle_log->dateline = date ( "Y-m-d" ); $longle_log->insert (); echo json_encode ( array ( 'msg' => 1 ) ); die (); // return "/keyonline/".$lid; } function ajaxGetLongleByName() { Doo::loadModel ( 'longle_log' ); Doo::loadModel ( 'longle' ); $longle = new longle (); $longle_log = new longle_log (); $name = $this->get_args('name') ? $this->get_args('name') : ""; if (empty ( $name )) { echo json_encode ( array ( "success" => false ) ); die (); } $ky = $longle->getLongleBykeynum ( $name ); $t = $longle_log->getLongleByLid ( $ky [0] ['lid'] ); if (isset ( $t [0] )) $tk = $t [0]; else $tk = array (); $longleLog = $tk; $longleLog ['klid'] = $t [0] ['lid']; $longleLog ['longle'] = $ky [0]; $longleLog ['longleLogHtml'] = $this->_getLongleLogHtml ( $t ); echo json_encode ( $longleLog ); } function ajaxGetLongleN() { Doo::loadModel ( 'longle_log' ); Doo::loadModel ( 'longle' ); $longle = new longle (); $longle_log = new longle_log (); $keynum = $this->get_args('keynum') ? $this->get_args('keynum') : ""; if (empty ( $keynum )) { echo json_encode ( array ( "success" => false ) ); die (); } $ky = $longle->getLongleBykeynum ( $keynum ); if (! empty ( $ky )) { $t = $longle_log->getLongleByLid ( $ky [0] ['lid'] ); if (isset ( $t [0] )) $tk = $t [0]; else $tk = array (); $longleLog = $tk; $longleLog ['klid'] = $ky [0] ['lid']; $longleLog ['longle'] = $ky [0]; $longleLog ['longleLogHtml'] = $this->_getLongleLogHtml ( $t ); echo json_encode ( $longleLog ); } } function ajaxGetLongle() { Doo::loadModel ( 'longle_log' ); Doo::loadModel ( 'longle' ); $longle = new longle (); $longle_log = new longle_log (); $lid = $this->get_args('lid') ? $this->get_args('lid') : 0; if ($lid == 0) { echo json_encode ( array ( "success" => false ) ); die (); } $t = $longle_log->getLongleByLid ( $lid ); if (isset ( $t [0] )) $tk = $t [0]; else $tk = array (); $longleLog = $tk; $longleLog ['klid'] = $lid; $ky = $longle->getLongleByLid ( $lid ); $longleLog ['longle'] = $ky [0]; $longleLog ['longleLogHtml'] = $this->_getLongleLogHtml ( $t ); echo json_encode ( $longleLog ); } function ajaxGetStaffInfo() { $username = $this->get_args('username') ? $this->get_args('username') : ""; if ($username == "") { echo json_encode ( array ( "success" => false ) ); die (); } Doo::loadModel ( 'staff' ); $staff = new staff (); $staffInfo = $staff->getOne ( array ( 'where' => ' username like "' . $username . '"', 'asArray' => TRUE ) ); if (empty ( $staffInfo )) { echo json_encode ( array ( "success" => false, 'html' => '' ) ); die (); } $staffHtml = array ( 'html' => '

' . $staffInfo ['username'] . '

性别' . $staffInfo ['gender'] . '办事处' . $staffInfo ['category'] . '
手机' . $staffInfo ['telephone'] . '电话' . $staffInfo ['phone'] . '
QQ' . $staffInfo ['qq'] . '邮箱' . $staffInfo ['email'] . '
' ); echo json_encode ( $staffHtml ); } function ajaxGetCompanyByAdd() { $cid = $this->get_args('cid') ? $this->get_args('cid') : ""; if (! empty ( $cid )) { Doo::loadModel ( 'company' ); $company = new company (); Doo::loadModel ( 'client' ); Doo::loadModel ( 'district' ); $district = new district (); $client = new client (); $districtInfo = $district->get_lv ( 1 ); $companyInfo = $client->getClientByCompanyId ( $cid ); $companyInfo = $companyInfo [0]; $cInfo = $company->getOne ( array ( 'where' => "cid = " . $cid, 'asArray' => TRUE ) ); $companyInfo ['ride'] = $cInfo ['ride']; $companyInfo ['landmarks'] = $cInfo ['landmarks']; $companyInfo ['stay'] = $cInfo ['stay']; $artld = explode ( ',', $cInfo ['local'] ); $districtid = explode ( ',', $cInfo ['district'] ); $html = ""; $html .= ' '; $html .= ' '; $html .= '   '; $companyInfo ['dishtml'] = $html; $companyInfo ['natureAr'] = $this->nature; $companyInfo ['natureArlenght'] = 12; echo json_encode ( array ( "success" => true, 'data' => $companyInfo ) ); die (); } else echo json_encode ( array ( "success" => false, 'data' => '' ) ); die (); } function doEditCompanyD() { $cid = $this->get_args('cid') ? $this->get_args('cid') : 0; $companyname = $this->get_args('companyname') ? $this->get_args('companyname') : ""; $lv21 = $this->get_args('lv21') ? $this->get_args('lv21') : 0; $lv22 = $this->get_args('lv22') ? $this->get_args('lv22') : 0; $lv23 = $this->get_args('lv23') ? $this->get_args('lv23') : 0; $nature = $this->get_args('nature') ? $this->get_args('nature') : ""; $fax = $this->get_args('fax') ? $this->get_args('fax') : ""; $webservice = $this->get_args('webservice') ? $this->get_args('webservice') : ""; $address = $this->get_args('address') ? $this->get_args('address') : ""; $ride = $this->get_args('ride') ? $this->get_args('ride') : ""; $stay = $this->get_args('stay') ? $this->get_args('stay') : ""; $landmarks = $this->get_args('landmarks') ? $this->get_args('landmarks') : ""; if (empty ( $cid ) || empty ( $companyname )) { echo json_encode ( array ( "success" => false ) ); die (); } Doo::loadModel ( "company" ); Doo::loadModel ( "client" ); $client = new client (); $company = new company (); $company->cid = $cid; if (! empty ( $lv21 ) && ! empty ( $lv22 ) && ! empty ( $lv23 )) { Doo::loadModel ( 'district' ); $district = new district (); // 更新公司信息 $lv1 = $district->getbyid ( $lv21 ); $lv2 = $district->getbyid ( $lv22 ); $lv3 = $district->getbyid ( $lv23 ); $company->district = $lv21 . "," . $lv22 . "," . $lv23; $company->local = $lv1 [0] ['name'] . "," . $lv2 [0] ['name'] . "," . $lv3 [0] ['name']; } if (! empty ( $nature )) { $nature = implode ( ",", $nature ); $company->nature = $nature; } if (! empty ( $companyname )) { $company->companyname = $companyname; $client->companyname = $companyname; } if (! empty ( $fax )) $company->fax = $fax; if (! empty ( $webservice )) $company->webservice = $webservice; if (! empty ( $address )) $company->address = $address; if (! empty ( $ride )) $company->ride = $ride; if (! empty ( $stay )) $company->stay = $stay; if (! empty ( $landmarks )) $company->landmarks = $landmarks; $company->update (); $client->update ( array ( 'where' => ' companyid =' . $cid ) ); echo json_encode ( array ( "success" => true ) ); die (); } function ajaxEditCompany() { $companyname = $this->get_args('companyId') ? $this->get_args('companyId') : 0; if (! empty ( $companyname )) { Doo::loadModel ( 'company' ); $company = new company (); $companyInfo = $company->getOne ( array ( 'where' => "cid = '" . $companyname . "'", 'asArray' => TRUE ) ); if (! empty ( $companyInfo )) { Doo::loadModel ( 'district' ); $district = new district (); $districtinfo = $district->get_lv ( 1 ); $dinfo = $district->getbyidlist ( $companyInfo ['district'] ); $html = '

' . $companyInfo ['companyname'] . '

'; $html .= '
单位全称
地区  
性质'; $ntre = explode ( ",", $companyInfo ['nature'] ); foreach ( $this->nature as $key => $value ) { $falg = true; foreach ( $ntre as $k => $v ) { if ($value == $v) { $falg = false; $html .= ' '; } } if ($falg) $html .= ' '; } $html .= '
传真 主页
单位地址
乘车路线
地标建筑
住宿参考
单位全称将与该单位已存在的客户进行同步;其他单位信息不会进行同步;
单位信息随该单位第一位客户录入,并作为“在这添加客户”的基础数据
'; echo json_encode ( array ( "success" => true, 'html' => $html ) ); die (); } } else echo json_encode ( array ( "success" => false, 'html' => '' ) ); die (); } function ajaxGetCompany() { $companyname = $this->get_args('companyId') ? $this->get_args('companyId') : 0; if (! empty ( $companyname )) { Doo::loadModel ( 'company' ); $company = new company (); $companyInfo = $company->getOne ( array ( 'where' => "cid = '" . $companyname . "'", 'asArray' => TRUE ) ); if (! empty ( $companyInfo )) { Doo::loadModel ( 'client' ); Doo::loadModel ( 'staff' ); Doo::loadModel ( 'client_staff' ); Doo::loadModel ( 'longle' ); $longle = new longle (); $client_staff = new client_staff (); $staff = new staff (); $client = new client (); Doo::loadModel ( 'district' ); $district = new district (); $clientlist = $client->getClientByCompanyId ( $companyInfo ['cid'] ); $department = $client->getDepartment ( $companyInfo ['cid'] ); Doo::loadModel ( "tagCompanyNexus" ); Doo::loadModel ( "tagCompany" ); $tag = new tagCompany (); $tag_client = new tagCompanyNexus (); $tagId = $tag_client->getTagClientBySCid ( $companyInfo ['cid'], $this->staff [0] ['sid'] ); $taginfo = $tag->getTagByTidL ( $tagId ['tag'] ); $taghtml = ""; foreach ( $taginfo as $key => $value ) { $taghtml .= '' . $value ['name'] . ''; } $html = '

S I | H
' . $companyInfo ['companyname'] . '

单位地区' . $companyInfo ['local'] . '单位性质' . $companyInfo ['nature'] . '
单位地址' . $companyInfo ['address'] . '
单位乘车' . $companyInfo ['ride'] . '
单位地标' . $companyInfo ['landmarks'] . '
单位住宿' . $companyInfo ['stay'] . '
' . $taghtml . '
已选择 0/'.sizeof($clientlist).'

'; $html .= '不限'; foreach ( $department as $key => $value ) { if ($value != "") $html .= '' . $value ['department'] . ''; } $html .= '

'; $html .= '
'; foreach ( $clientlist as $key => $value ) { $scinfo = $client_staff->getClientByCid ( $value ['cid'] ); $staffinfo = $staff->getUserById ( $scinfo ['sid'] ); //客户信息 $html .= '

' . $staffinfo [0] ['category'] . '- ' . $staffinfo [0] ['username'] . '

' . $value ['clientname'] . ' ' . $value ['priority'] . 'I

'; $longleinfo = $longle->getLongleByClientid ( $value ['cid'] ); if (empty ( $longleinfo )) { $longleinfo = array ( 0 => array ( 'lid' => '', 'key_num' => '', 'product' => '', 'statusT' => '' ) ); } $html .= ''; $districtList = $district->getbyidlist ( $value ['district'] ); $localdis=''; foreach ($districtList as $lov){ $localdis.=' '.$lov['name']; } $html .= ' '; $html .= '
性别' . $value ['gender'] . '昵称' . $value ['nicename'] . '
部门' . $value ['department'] . '办公室' . $value ['office'] . '
手机' . $value ['telephone'] . '电话' . $value ['phone'] . '
QQ' . $value ['qq'] . '邮箱' . $value ['email'] . '
备注' . $value ['mark'] . '
软件锁' . $longleinfo [0] ['key_num'] . '/' . $longleinfo [0] ['product'] . '/' . $longleinfo [0] ['statusT'] . '
客户地区'.$localdis.'
客户地址'.$value['address'].'
客户乘车'.$value['ride'].'
客户地标'.$value['landmarks'].'
客户住宿'.$value['stay'].'
'; } $html .= "
"; echo json_encode ( array ( "success" => true, 'html' => $html ) ); die (); } } else echo json_encode ( array ( "success" => false, 'html' => '' ) ); die (); } function ajaxSetCompanyAddress(){ $cidString = $this->get_args('cidString') ? $this->get_args('cidString') : ""; $companyId = $this->get_args('company')&&is_numeric ($this->get_args('company')) ? $this->get_args('company') : 0; if(!empty($cidString)&&!empty($companyId)){ Doo::loadModel ( 'client' ); $client = new client (); Doo::loadModel ( 'company' ); $company = new company (); $cidList=explode(',', $cidString); foreach ($cidList as $value){ if(!is_numeric($value)) die ('illegal request3'); } $companyInfo = $company->getOne ( array ( 'where' => "cid = '" . $companyId . "'", 'asArray' => TRUE ) ); $client->address=$companyInfo['address']; $client->ride=$companyInfo['ride']; $client->landmarks=$companyInfo['landmarks']; $client->stay=$companyInfo['stay']; $client->local=$companyInfo['local']; $client->district=$companyInfo['district']; $falg=$client->update (array('where'=>'companyid ='.$companyInfo['cid'].' and cid in ('.$cidString.')')); echo json_encode ( array ( 'status' => $falg, 'msg' => 'illegal request2' ) ); die (); } echo json_encode ( array ( 'status' => -1, 'msg' => 'illegal request' ) ); die (); } function checkclicomname() { // 地区区分 $companyname = $this->get_args('companyname') ? $this->get_args('companyname') : ""; $clientname = $this->get_args('clientname') ? $this->get_args('clientname') : ""; $district1 = $this->get_args('district1') ? $this->get_args('district1') : 0; $district2 = $this->get_args('district2') ? $this->get_args('district2') : 0; $district3 = $this->get_args('district3') ? $this->get_args('district3') : 0; Doo::loadModel ( 'client' ); $client = new client (); $local = $district1 . "," . $district2 . "," . $district3; $companyname = trim ( $companyname ); $clientname = trim ( $clientname ); $clientinfo = $client->getClientToName ( $clientname, $companyname, $local ); if (! empty ( $clientinfo )) { echo json_encode ( array ( 'success' => false ) ); } else { echo json_encode ( array ( 'success' => true ) ); } } function ajaxGetClientInfoN() { $clientname = $this->get_args('client') ? $this->get_args('client') : ""; if ($clientname == "") { echo json_encode ( array ( "success" => false ) ); die (); } Doo::loadModel ( 'client' ); Doo::loadModel ( 'client_staff' ); Doo::loadModel ( 'longle' ); Doo::loadModel ( 'company' ); Doo::loadModel ( 'service_log' ); $service_log = new service_log (); $company = new company (); $longle = new longle (); $client = new client (); $client_staff = new client_staff (); $clientInfo = $client->getOne ( array ( "where" => ' cid like "' . $clientname . '"', 'asArray' => TRUE ) ); if (empty ( $clientInfo )) { echo json_encode ( array ( "success" => false, 'html' => '' ) ); die (); } // 获取锁 $longleInfo = $longle->getLongleByClient ( $clientname ); $k = ""; foreach ( $longleInfo as $key => $value ) { if ($value ['status'] == 6 || $value ['status'] == 7) $k .= '' . $value ['key_num'] . '/' . $value ['product'] . '/' . $value ['statusT'] . '  '; else $k .= '' . $value ['key_num'] . '/' . $value ['product'] . '/' . $value ['statusT'] . '  '; } // 获取办事人 $staffInfo = $client_staff->getClientByCid ( $clientInfo ['cid'] ); // 获取公司信息 $companyInfo = $company->getCompanyByCid ( $clientInfo ['companyid'] ); $serviceLog = $service_log->getServiceByClientid ( $clientInfo ['cid'] ); $u = ""; $order = array ( "\r\n", "\n", "\r" ); $replace = '
'; foreach ( $serviceLog as $key => $value ) { $datetime = explode ( "-", $value ['date'] ); $u .= '
' . $datetime ['1'] . '-' . $datetime ['2'] . ' ' . $datetime ['0'] . '
'; } Doo::loadModel ( "tag_client" ); Doo::loadModel ( "tag" ); $tag = new tag (); $tag_client = new tag_client (); $tagId = $tag_client->getTagClientBySCid ( $clientInfo ['cid'], $this->staff [0] ['sid'] ); $taginfo = $tag->getTagByTidL ( $tagId ['tag'] ); // $taghtml=""; // // foreach ($taginfo as $key=>$value){ // $taghtml.=''.$value['name'].''; // } $mhtml = ""; $dhtml = ""; for($month = 1; $month <= 12; $month ++) { if (date ( "m" ) == $month) $mhtml .= ''; else $mhtml .= ''; } for($day = 1; $day <= 31; $day ++) { if (date ( "d" ) == $day) $dhtml .= ''; else $dhtml .= ''; } // $b=""; // if(!empty($staffInfo)) // $b='

'.$staffInfo['category'].'-'.$staffInfo['username'].'

'.$clientInfo['clientname'].' '; // $m = ""; if (! empty ( $companyInfo )) { $m = '
单位全称' . $companyInfo [0] ['companyname'] . '
地区' . $companyInfo [0] ['local'] . '部门/职位' . $clientInfo ['department'] . '/' . $clientInfo ['position'] . '
传真' . $companyInfo [0] ['fax'] . '办公室' . $companyInfo [0] ['office'] . '
单位地址' . $companyInfo [0] ['address'] . '
乘车路线' . $companyInfo [0] ['ride'] . '
地标建筑' . $companyInfo [0] ['landmarks'] . '
参考住宿' . $clientInfo ['stay'] . '
单位主页' . $clientInfo ['webservice'] . '
'; } $clientHtml = array ( 'html' => ' ' ); echo json_encode ( $clientHtml ); } function ajaxGetClientInfo() { $clientname = $this->get_args('client') ? $this->get_args('client') : ""; if ($clientname == "") { echo json_encode ( array ( "success" => false ) ); die (); } Doo::loadModel ( 'client' ); Doo::loadModel ( 'client_staff' ); Doo::loadModel ( 'longle' ); Doo::loadModel ( 'company' ); Doo::loadModel ( 'service_log' ); Doo::loadModel ( "district" ); $district = new district (); $service_log = new service_log (); $company = new company (); $longle = new longle (); $client = new client (); $client_staff = new client_staff (); $nameStr = explode ( ",", $clientname ); // $clientname=$nameStr[1]; if (! empty ( $nameStr [0] )) { $clientInfo = $client->getOne ( array ( "where" => ' cid = "' . $nameStr [0] . '"', 'asArray' => TRUE ) ); } elseif (! empty ( $nameStr [1] )) $clientInfo = $client->getOne ( array ( "where" => ' clientname = "' . $nameStr [1] . '"', 'asArray' => TRUE ) ); else $clientInfo = array (); if (empty ( $clientInfo )) { echo json_encode ( array ( "success" => false, 'html' => '' ) ); die (); } // 获取锁 $longleInfo = $longle->getLongleByClientid ( $clientInfo ['cid'] ); $k = ""; foreach ( $longleInfo as $key => $value ) { if ($value ['status'] == 6 || $value ['status'] == 7) $k .= '' . $value ['key_num'] . '/' . $value ['product'] . '/' . $value ['statusT'] . '  '; else $k .= '' . $value ['key_num'] . '/' . $value ['product'] . '/' . $value ['statusT'] . '  '; } // 获取办事人 $staffInfo = $client_staff->getClientByCid ( $clientInfo ['cid'] ); $b = ""; if (! empty ( $staffInfo )) $b = '

' . $staffInfo ['category'] . '-' . $staffInfo ['username'] . '

' . $clientInfo ['clientname'] . '' . $clientInfo ['priority'] . ''; // 获取公司信息 $companyInfo = $company->getCompanyByCid ( $clientInfo ['companyid'] ); $serviceLog = $service_log->getServiceByClientid ( $clientInfo ['cid'] ); $local = $district->getbyidlist ( $clientInfo ['district'] ); if (! isset ( $local [1] )) $local [1] ['name'] = ""; if (! isset ( $local [2] )) $local [2] ['name'] = ""; $m = ""; if (! empty ( $companyInfo )) { $m = '
单位全称' . $companyInfo [0] ['companyname'] . '
单位主页' . $clientInfo ['webservice'] . '
客户地区' . $local [0] ['name'] . ',' . $local [1] ['name'] . ',' . $local [2] ['name'] . '部门/职位' . $clientInfo ['department'] . '/' . $clientInfo ['position'] . '
客户传真' . $clientInfo ['fax'] . '办公室' . $clientInfo ['office'] . '
客户地址' . $clientInfo ['address'] . '
客户乘车' . $clientInfo ['ride'] . '
客户地标' . $clientInfo ['landmarks'] . '
客户住宿' . $clientInfo ['stay'] . '
'; } $u = ""; $order = array ( "\r\n", "\n", "\r" ); $replace = '
'; foreach ( $serviceLog as $key => $value ) { $datetime = explode ( "-", $value ['date'] ); $u .= '
' . $datetime ['1'] . '-' . $datetime ['2'] . ' ' . $datetime ['0'] . '
'; } Doo::loadModel ( "tag_client" ); Doo::loadModel ( "tag" ); $tag = new tag (); $tag_client = new tag_client (); $tagId = $tag_client->getTagClientBySCid ( $clientInfo ['cid'], $this->staff [0] ['sid'] ); $taginfo = $tag->getTagByTidL ( $tagId ['tag'] ); $taghtml = ""; foreach ( $taginfo as $key => $value ) { $taghtml .= '' . $value ['name'] . ''; } $mhtml = ""; $dhtml = ""; $yhtml = ""; for($year = 2020; $year >= 2004; $year --) { if (date ( "Y" ) == $year) $yhtml .= ''; else $yhtml .= ''; } for($month = 1; $month <= 12; $month ++) { if (date ( "m" ) == $month) $mhtml .= ''; else $mhtml .= ''; } for($day = 1; $day <= 31; $day ++) { if (date ( "d" ) == $day) $dhtml .= ''; else $dhtml .= ''; } $clientHtml = array ( 'html' => '

' . $b . 'I

性别' . $clientInfo ['gender'] . '昵称' . $clientInfo ['nicename'] . '
手机' . $clientInfo ['telephone'] . 'QQ' . $clientInfo ['qq'] . '
电话' . $clientInfo ['phone'] . '邮箱' . $clientInfo ['email'] . '
软件锁' . $k . '
备注' . $clientInfo ['mark'] . '
' . $taghtml . '
' . $m . '
+ 打开添加服务记录
- 关闭添加记录
时间:
含泪告知:客户记录暂时无法修改!删除!,添加时请谨慎。点击确定添加成功后,信息会立即出现在下方!注意咯,别猛戳‘确定添加’导致重复添加了哦~
限期:
备注:
' . $u . '
' ); echo json_encode ( $clientHtml ); } function ajaxGetCompanyInfo() { } function checkClient() { $searchDbInforItem = $this->get_args('name') ? $this->get_args('name') : ""; $searchDbInforItem = explode ( '-', $searchDbInforItem ); if (! empty ( $searchDbInforItem )) { Doo::loadModel ( 'client' ); $client = new client (); $clientInfo = $client->getClientByName2 ( $searchDbInforItem [0], $searchDbInforItem [1] ); if (! empty ( $clientInfo )) echo json_encode ( array ( "success" => true ) ); else echo json_encode ( array ( "success" => false ) ); } else { echo json_encode ( array ( "success" => false ) ); } } function searchClient() { $searchDbInforItem = $this->get_args('searchDbInforItem') ? $this->get_args('searchDbInforItem') : ""; if (! empty ( $searchDbInforItem )) { Doo::loadModel ( 'client' ); $client = new client (); $clientInfo = $client->getClientByName ( $searchDbInforItem ); echo json_encode ( $clientInfo ); } else { echo json_encode ( array ( 0 => array ( 'clientname' => '' ) ) ); } } function searchCompany() { $searchDbInforItem = $this->get_args('searchDbInforItem') ? $this->get_args('searchDbInforItem') : ""; if (! empty ( $searchDbInforItem )) { Doo::loadModel ( 'company' ); $company = new company (); $clientInfo = $company->searchCompany ( $searchDbInforItem ); echo json_encode ( $clientInfo ); } else { echo json_encode ( array ( 0 => array ( 'companyname' => '', 'local' => '' ) ) ); } } function checkCompany() { $searchDbInforItem = $this->get_args('name') ? $this->get_args('name') : ""; $searchDbInforItem = explode ( '-', $searchDbInforItem ); $this->nature ['naturelenght'] = 15; Doo::loadModel ( 'district' ); $district = new district (); $d = $district->get_lv ( 1 ); $html = ''; foreach ( $d as $key => $value ) { $html .= ''; } $this->nature ['district'] = $html; if (! empty ( $searchDbInforItem )) { Doo::loadModel ( 'company' ); $company = new company (); if (! isset ( $searchDbInforItem [1] )) { echo json_encode ( array ( "success" => false, 'nature' => $this->nature ) ); die (); } $clientInfo = $company->getCompanyByName ( $searchDbInforItem [0], $searchDbInforItem [1] ); if (! empty ( $clientInfo )) echo json_encode ( array ( "success" => true, 'data' => $clientInfo ) ); else echo json_encode ( array ( "success" => false, 'nature' => $this->nature ) ); } else { echo json_encode ( array ( "success" => false, 'nature' => $this->nature ) ); } } function checkLongle() { $searchDbInforItem = $this->get_args('name') ? $this->get_args('name') : ""; $searchDbInforItem = explode ( ' ', $searchDbInforItem ); if (! empty ( $searchDbInforItem )) { Doo::loadModel ( 'longle' ); $longle = new longle (); $clientInfo = $longle->getLongleBykeynum ( $searchDbInforItem [0] ); if (! empty ( $clientInfo )) echo json_encode ( array ( "success" => true ) ); else echo json_encode ( array ( "success" => false ) ); } else { echo json_encode ( array ( "success" => false ) ); } } function searchLongle() { $searchDbInforItem = $this->get_args('searchDbInforItem') ? $this->get_args('searchDbInforItem') : ""; if (! empty ( $searchDbInforItem )) { Doo::loadModel ( 'longle' ); $longle = new longle (); $longleInfo = $longle->getLongleBykeynum2 ( $searchDbInforItem ); echo json_encode ( $longleInfo ); } else { echo json_encode ( array ( 0 => array ( 'clientname' => '' ) ) ); } } function updateChangeCompany() { $cid = $this->get_args('cid') ? $this->get_args('cid') : 0; $clientID = $this->get_args('clientID') ? $this->get_args('clientID') : 0; $companyname = $this->get_args('companyname') ? $this->get_args('companyname') : ""; Doo::loadModel ( 'company' ); Doo::loadModel ( 'client' ); $client = new client (); $company = new company (); $companyname = explode ( "-", $companyname ); if (isset ( $companyname [1] )) $k = $company->getCompanyByName ( $companyname [0], $companyname [1] ); else $k = array (); if (! empty ( $cid ) && ! empty ( $k ) && ! empty ( $clientID )) { $client->cid = $clientID; $client->companyid = $cid; $client->companyname = $companyname [0]; $client->update (); } else { $local1 = $this->get_args('lv21') ? $this->get_args('lv21') : 0; $local2 = $this->get_args('lv22') ? $this->get_args('lv22') : 0; $local3 = $this->get_args('lv23') ? $this->get_args('lv23') : 0; Doo::loadModel ( 'district' ); $district = new district (); // 更新公司信息 $lv1 = $district->getbyid ( $local1 ); $lv2 = $district->getbyid ( $local2 ); $lv3 = $district->getbyid ( $local3 ); if (empty ( $local1 ) || empty ( $local2 )) return "/"; if (! empty ( $local1 ) && ! empty ( $local2 )) $company->local = $lv1 [0] ['name'] . "," . $lv2 [0] ['name'] . "," . $lv3 [0] ['name']; if (! empty ( $local1 ) && ! empty ( $local2 )) $company->district = $local1 . "," . $local2 . "," . $local3; $nature = $this->get_args('nature') ? $this->get_args('nature') : ""; $fax = $this->get_args('fax') ? $this->get_args('fax') : ""; $webservice = $this->get_args('webservice') ? $this->get_args('webservice') : ""; $address = $this->get_args('address') ? $this->get_args('address') : ""; $landmarks = $this->get_args('landmarks') ? $this->get_args('landmarks') : ""; $stay = $this->get_args('stay') ? $this->get_args('stay') : ""; $ride = $this->get_args('ride') ? $this->get_args('ride') : ""; $nature = implode ( ",", $nature ); $company->companyname = $companyname [0]; $company->ride = $ride; $company->fax = $fax; $company->webservice = $webservice; $company->address = $address; $company->landmarks = $landmarks; $company->stay = $stay; $company->nature = $nature; $cid = $company->insert (); $client->cid = $clientID; $client->companyid = $cid; $client->companyname = $companyname [0]; $client->update (); } return "/contacts"; } function AddClientInfo() { // 不编辑公司 $cid = $this->get_args('cid') ? $this->get_args('cid') : 0; $clientname = $this->get_args('clientname') ? $this->get_args('clientname') : ""; $gender = $this->get_args('gender') ? $this->get_args('gender') : ""; $nicename = $this->get_args('nicename') ? $this->get_args('nicename') : ""; $telephone = $this->get_args('telephone') ? $this->get_args('telephone') : ""; $phone = $this->get_args('phone') ? $this->get_args('phone') : ""; $email = $this->get_args('email') ? $this->get_args('email') : ""; $unit = $this->get_args('unit') ? $this->get_args('unit') : ""; $fax = $this->get_args('fax') ? $this->get_args('fax') : ""; $webservice = $this->get_args('webservice') ? $this->get_args('webservice') : ""; $department = $this->get_args('department') ? $this->get_args('department') : ""; $position = $this->get_args('position') ? $this->get_args('position') : ""; $office = $this->get_args('office') ? $this->get_args('office') : ""; $address = $this->get_args('address') ? $this->get_args('address') : ""; $ride = $this->get_args('ride') ? $this->get_args('ride') : ""; $landmarks = $this->get_args('landmarks') ? $this->get_args('landmarks') : ""; $qq = $this->get_args('qq') ? $this->get_args('qq') : ""; $priority = $this->get_args('priority') ? $this->get_args('priority') : 5; $stay = $this->get_args('stay') ? $this->get_args('stay') : ""; $mark = $this->get_args('mark') ? $this->get_args('mark') : ""; $lv21 = $this->get_args('lv21') ? $this->get_args('lv21') : ""; $lv22 = $this->get_args('lv22') ? $this->get_args('lv22') : ""; $lv23 = $this->get_args('lv23') ? $this->get_args('lv23') : ""; if (! empty ( $cid ) && ! empty ( $clientname )) { Doo::loadModel ( 'client' ); Doo::loadModel ( 'district' ); $district = new district (); $client = new client (); $client->cid = $cid; $client->clientname = $clientname; $client->gender = $gender; $client->nicename = $nicename; $client->telephone = $telephone; $client->phone = $phone; $client->email = $email; // if(!empty($unit)){ // $client->unit=$unit; // $client->companyname=$unit; // } if (! empty ( $lv21 ) && ! empty ( $lv22 ) && ! empty ( $lv23 )) { $client->district = $lv21 . "," . $lv22 . "," . $lv23; } if (! empty ( $client->district )) { $districtList = $district->find ( array ( 'where' => 'id in(' . $client->district . ')', 'asArray' => true ) ); $jsonString = array (); foreach ( $districtList as $value ) { array_push ( $jsonString, $value ['name'] ); } $jsonString = implode ( ",", $jsonString ); if (! empty ( $jsonString )) $client->local = $jsonString; } $client->fax = $fax; $client->webservice = $webservice; $client->department = $department; $client->position = $position; $client->office = $office; $client->address = $address; $client->ride = $ride; $client->landmarks = $landmarks; $client->qq = $qq; $client->stay = $stay; $client->priority = $priority; $client->mark = $mark; $client->updatetime = time (); $client->update (); // Doo::loadModel ( 'company' ); // $company = new company(); // $companyid=$client->getOne(array('where'=>' cid='.$cid,'asArray'=>true)); // $company->office=$office; // $company->fax=$fax; // $company->address=$address; // $company->ride=$ride; // $company->landmarks=$landmarks; // $company->cid=$companyid['companyid']; // if(!empty($unit)){ // $company->companyname=$unit; // } // $company->update(); $clientInfo = $client->getOne ( array ( 'where' => ' cid=' . $cid, 'asArray' => true ) ); // 日常行为 Doo::loadModel ( "action_log" ); $action_log = new action_log (); $action_log->action = $this->staff [0] ['category'] . '' . $this->staff [0] ['username'] . '编辑了' . $clientname . '(' . $clientInfo ['companyname'] . ')'; $action_log->sid = $this->staff [0] ['sid']; $action_log->cid = $this->staff [0] ['cid']; $action_log->updatetime = date ( "Y-m-d" ); $action_log->time = date ( "H:i" ); $action_log->class = $action_log->iconContacts; $action_log->status = 2; $action_log->districtid = $clientInfo ['district']; $local = $district->getbyidlist ( $clientInfo ['district'] ); $action_log->city = $local [0] ['name']; $action_log->province = $local [1] ['name']; $action_log->company = $clientInfo ['companyname']; Doo::loadModel ( 'company' ); $company = new company (); $companyInfo = $company->getOne ( array ( 'where' => ' companyname="' . $clientInfo ['companyname'] . '"', 'asArray' => true ) ); $nature = explode ( ',', $companyInfo ['nature'] ); $action_log->nature = $nature [0]; $action_log->insert (); echo json_encode ( array ( "success" => true ) ); die (); } else echo json_encode ( array ( "success" => false ) ); die (); } function ajaxClientInfo() { $cid = $this->get_args('cid') ? $this->get_args('cid') : 0; if (! empty ( $cid )) { Doo::loadModel ( 'client' ); Doo::loadModel ( 'company' ); $company = new company (); $client = new client (); $info = $client->getOne ( array ( 'where' => ' cid=' . $cid, 'asArray' => true ) ); $cinfo = $company->getOne ( array ( 'where' => ' cid=' . $info ['companyid'], 'asArray' => true ) ); Doo::loadModel ( 'district' ); $district = new district (); $districtLv1 = $district->get_lv ( 1 ); $info ['districtList'] = $district->getbyidlist ( $info ['district'] ); $optionHtml = ''; foreach ( $districtLv1 as $key => $value ) { if ($value ['name'] == $info ['districtList'] [0] ['name']) $optionHtml .= ''; else $optionHtml .= ''; } $info ['districtLv1'] = $optionHtml; $info ['companyInfo'] = $cinfo; echo json_encode ( array ( "success" => true, 'html' => $info ) ); die (); } else echo json_encode ( array ( "success" => false, 'html' => '' ) ); die (); } /** * 为客户添加服务日志 */ function ajaxAddServiceLog() { $status = $this->get_args('status') ? $this->get_args('status') : ""; $clientid = $this->get_args('cid') ? $this->get_args('cid') : ""; $mark = $this->get_args('mark') ? $this->get_args('mark') : ""; $m = $this->get_args('m') ? $this->get_args('m') : ""; $d = $this->get_args('d') ? $this->get_args('d') : ""; $y = $this->get_args('y') ? $this->get_args('y') : date ( "Y" ); $Remind = $this->get_args('Remind') ? $this->get_args('Remind') : 0; $time = $this->get_args('time') ? $this->get_args('time') : 0; $remark = $this->get_args('remark') ? $this->get_args('remark') : ""; if (! empty ( $status ) && ! empty ( $clientid )) { Doo::loadModel ( 'service_log' ); Doo::loadModel ( 'client_staff' ); Doo::loadModel ( 'client' ); Doo::loadModel ( 'district' ); $district = new district (); $client = new client (); $clientStaff = new client_staff (); $service_log = new service_log (); $service_log->status = $status; $service_log->clientid = $clientid; $service_log->mark = htmlspecialchars ( $mark ); $service_log->date = $y . "-" . $m . "-" . $d; $service_log->category = $this->staff [0] ['category']; $service_log->staffname = $this->staff [0] ['username']; $service_log->staffid = $this->staff [0] ['sid']; $service_log->insert (); // 日常行为 Doo::loadModel ( "action_log" ); Doo::loadModel ( "client" ); $client = new client (); // 记录服务时间 $client->cid = $clientid; $client->servicetime = time (); $client->update (); $action_log = new action_log (); $clientInfo = $client->getOne ( array ( 'where' => ' cid=' . $clientid, 'asArray' => TRUE ) ); $action_log->action = $this->staff [0] ['category'] . '' . $this->staff [0] ['username'] . '' . $clientInfo ['clientname'] . '(' . $clientInfo ['companyname'] . ')添加新客户记录。'; $action_log->sid = $this->staff [0] ['sid']; $action_log->cid = $this->staff [0] ['cid']; $action_log->updatetime = date ( "Y-m-d" ); $action_log->time = date ( "H:i" ); $action_log->status = 3; $action_log->districtid = $clientInfo ['district']; $local = $district->getbyidlist ( $clientInfo ['district'] ); $action_log->city = $local [0] ['name']; $action_log->province = $local [1] ['name']; $action_log->company = $clientInfo ['companyname']; Doo::loadModel ( 'company' ); $company = new company (); $companyInfo = $company->getOne ( array ( 'where' => ' companyname="' . $clientInfo ['companyname'] . '"', 'asArray' => true ) ); $nature = explode ( ',', $companyInfo ['nature'] ); $action_log->nature = $nature [0]; $action_log->class = $action_log->iconContacts; $action_log->insert (); //更新信息中心服务日志统计数量 $redis = new Redis(); $redis->connect('127.0.0.1', '6379'); $categoryCondition = " and cid=" . $this->staff [0] ['cid']; $sidCondition = " and sid=" . $this->staff [0] ['sid']; //actionlog免查询值 $alCondition=''; $alCondition=' aid>'.REMIT.' and '; //个人服务日志数量redis值 $redisKeyCS=date('Y-m-d').'SL_'.$this->staff [0] ['cid'].'_'.$this->staff [0] ['sid']; $action_log = new action_log (); $actionLogLongle = $action_log->find ( array ( 'select' => 'date_format(updatetime,"%m-%d") as updatetime,COUNT(*) as count', 'where' => $alCondition." status=3 ".$categoryCondition.$sidCondition." and date_sub(curdate(), INTERVAL 30 DAY) <= date(updatetime) " , 'groupby' => 'date_format(updatetime,"%m-%d")', 'asArray' => true ) ); $statisticsLongle = array (); for($d = 0; $d <= 29; $d ++) { $MD = date ( "m-d", strtotime ( "-" . $d . " day" ) ); $falgLongle = true; foreach ( $actionLogLongle as $value ) { if ($value ['updatetime'] == $MD) { array_push ( $statisticsLongle, $value ['count'] ); $falgLongle = false; break; } } if ($falgLongle) array_push ( $statisticsLongle, 0 ); } $statisticsLongle = array_reverse ( $statisticsLongle ); $jsl=json_encode ( $statisticsLongle ); $redis->set($redisKeyCS,$jsl); //办事处服务日志数量reids值 $redisKeyC=date('Y-m-d').'SL_'.$this->staff [0] ['cid'].'_'; $action_log = new action_log (); $actionLogLongle = $action_log->find ( array ( 'select' => 'date_format(updatetime,"%m-%d") as updatetime,COUNT(*) as count', 'where' => $alCondition." status=3 ".$categoryCondition." and date_sub(curdate(), INTERVAL 30 DAY) <= date(updatetime) " , 'groupby' => 'date_format(updatetime,"%m-%d")', 'asArray' => true ) ); $statisticsLongle = array (); for($d = 0; $d <= 29; $d ++) { $MD = date ( "m-d", strtotime ( "-" . $d . " day" ) ); $falgLongle = true; foreach ( $actionLogLongle as $value ) { if ($value ['updatetime'] == $MD) { array_push ( $statisticsLongle, $value ['count'] ); $falgLongle = false; break; } } if ($falgLongle) array_push ( $statisticsLongle, 0 ); } $statisticsLongle = array_reverse ( $statisticsLongle ); $jsl=json_encode ( $statisticsLongle ); $redis->set($redisKeyC,$jsl); //全员处服务日志数量的redis值 $redisKey=date('Y-m-d').'SL__'; $action_log = new action_log (); $actionLogLongle = $action_log->find ( array ( 'select' => 'date_format(updatetime,"%m-%d") as updatetime,COUNT(*) as count', 'where' => $alCondition." status=3 and date_sub(curdate(), INTERVAL 30 DAY) <= date(updatetime) " , 'groupby' => 'date_format(updatetime,"%m-%d")', 'asArray' => true ) ); $statisticsLongle = array (); for($d = 0; $d <= 29; $d ++) { $MD = date ( "m-d", strtotime ( "-" . $d . " day" ) ); $falgLongle = true; foreach ( $actionLogLongle as $value ) { if ($value ['updatetime'] == $MD) { array_push ( $statisticsLongle, $value ['count'] ); $falgLongle = false; break; } } if ($falgLongle) array_push ( $statisticsLongle, 0 ); } $statisticsLongle = array_reverse ( $statisticsLongle ); $jsl=json_encode ( $statisticsLongle ); $redis->set($redisKey,$jsl); if (! empty ( $Remind )) { Doo::loadModel ( 'remind' ); $remindObj = new remind (); $datetime1 = new DateTime ( date ( 'Y-m-d' ) ); $datetime2 = new DateTime ( $time ); $interval = $datetime1->diff ( $datetime2 ); $remindObj->day = $interval->format ( '%a' ); $remindObj->remark = $remark; $remindObj->time = date ( "Y-m-d" ); $remindObj->clientName = $clientInfo ['clientname']; $remindObj->clientID = $clientid; $remindObj->companyName = $clientInfo ['companyname']; $remindObj->companyID = $companyInfo ['cid']; $remindObj->staffID = $this->staff [0] ['sid']; if ($status == 1) $remindObj->class = "iconService"; if ($status == 2) $remindObj->class = "iconPhone"; if ($status == 3) $remindObj->class = "iconOther"; $remindObj->insert (); } echo json_encode ( array ( "success" => true, 'html' => '' ) ); die (); } else echo json_encode ( array ( "success" => false, 'html' => '' ) ); die (); } function _getLongleLogHtml($longleLog = array()) { $html = ""; foreach ( $longleLog as $key => $value ) { $dateline = explode ( "-", $value ['dateline'] ); $html .= '
' . $dateline [1] . '-' . $dateline [2] . ' ' . $dateline [0] . '
'; // 备注 if ($value ['status'] == 8) { $html .= ' '; // 生成 } elseif ($value ['status'] == 1) { $html .= ''; // 接收 } elseif ($value ['status'] == 2) { $html .= ''; // 借出 } elseif ($value ['status'] == 3) { $html .= ''; // 销售 } elseif ($value ['status'] == 4) { $html .= ''; // 升级 } elseif ($value ['status'] == 5) { $html .= ''; // 更换 } elseif ($value ['status'] == 6) { $html .= ''; // 回收 } elseif ($value ['status'] == 7) { Doo::loadModel ( 'staff' ); $staff = new staff (); $staffinfo = $staff->getOne ( array ( 'where' => ' username like "' . $value ['responsible'] . '"', 'asArray' => true ) ); if (empty ( $staffinfo )) $staffinfo ['category'] = ""; $html .= ''; } elseif ($value ['status'] == 9) { $html .= ''; } $html .= '
'; } return $html; } function adminLock() { $emsg = isset ( $this->params ['emsg'] ) ? $this->params ['emsg'] : ""; $data ['emsg'] = ""; if ($emsg != "") $data ['emsg'] = "请填写完整的数据"; $data ['memu'] = "keyonline"; $data ['staff'] = $this->staff; if ($this->staff [0] ['isadmin'] != 1) return "/adminmyinfo"; Doo::loadModel ( 'L_category' ); $L_category = new L_category (); $data ['category'] = $L_category->getCategory (); $data ['time'] = time (); $this->render ( "/admin/admin_addlock", $data ); } function adminAddLock() { $cid = $this->get_args('cid') ? $this->get_args('cid') : 0; $path = $this->get_args('path') ? $this->get_args('path') : ""; if ($cid != 0 && $path != "") { Doo::loadModel ( 'longle' ); Doo::loadModel ( 'L_category' ); $L_category = new L_category (); Doo::loadModel ( 'longle_log' ); $exlArray = $this->_format_excel_to_array ( DOO::conf ()->SITE_PATH . "upload/" . iconv ( "UTF-8", "GB2312", $path ) ); // print_r($exlArray);die; // echo json_encode($exlArray);die; $category = $L_category->getCategoryById ( $cid ); foreach ( $exlArray as $key => $value ) { // 锁记录 $longle = new longle (); $longle->key_num = str_replace ( "'", "", $value ['key_num'] ); $longle->product = str_replace ( "'", "", $value ['product'] ); $longle->make_day = $value ['make_day']; $longle->alloted_time = $value ['alloted_time']; $longle->status = 1; $longle->statusT = "生成"; $longle->cid = $cid; $longle->category = $category [0] ['title']; $longle->SerialNumber = $value ['SerialNumber']; $longle->version = $value ['version']; $lid = $longle->insert (); // 锁日志记录 $longle_log = new longle_log (); $longle_log->lid = $lid; $longle_log->status = 1; $longle_log->statusT = "生成"; $longle_log->operator = $this->staff [0] ['username']; $longle_log->product = $longle->product; $longle_log->category = $this->staff [0] ['category']; $longle_log->dateline = date ( "Y-m-d" ); $id = $longle_log->insert (); } // 记录日常行为 Doo::loadModel ( "action_log" ); $action_log = new action_log (); $action_log->action = '总部' . $this->staff [0] ['username'] . '生成' . str_replace ( "'", "", $exlArray [0] ['key_num'] ) . '' . count ( $exlArray ) . '个锁'; $action_log->sid = $this->staff [0] ['sid']; $action_log->cid = $this->staff [0] ['cid']; $action_log->class = $action_log->iconGenerate; $action_log->updatetime = date ( "Y-m-d" ); $action_log->time = date ( "H:i" ); $action_log->status = 11; $action_log->insert (); return "/keyonline"; } else return "/adminlock/error"; } function avatarCM() { $vid = isset ( $this->params ['vid'] ) ? $this->params ['vid'] : 0; if (! empty ( $vid )) { Doo::loadModel ( "verify" ); $verify = new verify (); Doo::loadModel ( 'staff' ); $staff = new staff (); $list = $verify->getOne ( array ( 'where' => 'vid=' . $vid, 'asArray' => true ) ); if (empty ( $list )) return "/adminverify"; $avatar = json_decode ( $list ['staff'] ); foreach ( $avatar as $key => $value ) { $uinfo = $staff->getOne ( array ( 'where' => 'sid=' . $value [0], 'asArray' => true ) ); $avatar [$key] ['2'] = $uinfo ['avatar']; } $verify->staff = json_encode ( $avatar ); $verify->update ( array ( 'where' => 'vid=' . $vid ) ); } return "/adminverify"; } function adminmyinfo() { $data ['memu'] = "adminmyinfo"; $data ['staff'] = $this->staff; $birArray = explode ( '-', $this->staff [0] ['birthday'] ); $data ['year'] = $birArray [0]; $year = date ( 'Y' ); $yearHtml = ""; for(; $year >= 1900; $year --) { $yearHtml .= ''; } $data ['yearHtml'] = $yearHtml; $data ['month'] = 01; $data ['day'] = 01; if (isset ( $birArray [1] )) { $data ['month'] = $birArray [1]; $data ['day'] = $birArray [2]; } $data ['msg'] = urldecode ( $this->params ['msg'] ); $this->render ( "/admin/admin_myinfo", $data ); } function updateMyinfo() { $telephone = $this->get_args ( 'telephone' ) ? $this->get_args ( 'telephone' ) : 0; $phone = $this->get_args ( 'phone' ) ? $this->get_args ( 'phone' ) : 0; $email = $this->get_args('email') ? $this->get_args('email') : ""; $qq = is_numeric ( $this->get_args ( 'qq' ) ) ? $_POST ['qq'] : 0; $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" ); $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : ""; $day = $this->get_args ( 'day' ) ? $this->get_args ( 'day' ) : ""; $position = $this->get_args ( 'position' ) ? $this->get_args ( 'position' ) : ""; $gender = $this->get_args ( 'gender' ) ? $this->get_args ( 'gender' ) : "男"; $oldpassword = $this->get_args ( 'oldpassword' ) ? $this->get_args ( 'oldpassword' ) : ""; $newpassword = $this->get_args ( 'newpassword' ) ? $this->get_args ( 'newpassword' ) : ""; $rnewpassword = $this->get_args ( 'rnewpassword' ) ?$this->get_args ( 'rnewpassword' ) : ""; Doo::loadModel ( 'staff' ); $staff = new staff (); Doo::loadModel ( 'staffDynamic' ); $staffDynamic = new staffDynamic (); $staff->sid = $this->staff [0] ['sid']; $content = ""; $ext = "更新了他的"; if ($telephone != 0 && $this->staff [0] ['telephone'] != $telephone) { $staff->telephone = $telephone; $content .= "手机 "; } if ($phone != 0 && $this->staff [0] ['phone'] != $phone) { $staff->phone = $phone; $content .= "电话 "; } if ($qq != 0 && $this->staff [0] ['qq'] != $qq) { $staff->qq = $qq; $content .= "QQ "; } if ($year != 2014) { $staff->birthday = $year . "-" . $month . "-" . $day; $content .= "生日 "; } if ($email != "" && filter_var ( $email, FILTER_VALIDATE_EMAIL ) && $this->staff [0] ['email'] != $email) { $staff->email = $email; $content .= "邮箱 "; } if (! empty ( $position )) { $staff->position = $position; $content .= "职位 "; } $staff->gender = $gender; $msg = "更新成功"; if ($this->staff [0] ['passwork'] == md5 ( $oldpassword )) { if ($newpassword == $rnewpassword && (! empty ( $newpassword ))) $staff->passwork = md5 ( $newpassword ); else $msg = "密码不一致"; } else { if ($oldpassword != "") $msg = "密码错误"; } if (! empty ( $content )) { $staffDynamic->content = $ext . $content; $staffDynamic->cid = $this->staff [0] ['cid']; $staffDynamic->category = $this->staff [0] ['category']; $staffDynamic->time = time (); $staffDynamic->sid = $this->staff [0] ['sid']; $staffDynamic->staff = $this->staff [0] ['username']; $staffDynamic->insert (); } $staff->update ( array ( 'where' => ' sid=' . $this->staff [0] ['sid'] ) ); return "/adminmyinfo/" . $msg; } function admincontacts() { $data ['memu'] = "admincontacts"; $data ['staff'] = $this->staff; Doo::loadModel ( 'L_category' ); Doo::loadModel ( 'staff' ); $staff = new staff (); $L_category = new L_category (); $this->render ( "/admin/admin_addContacts", $data ); } /** * 微信通知设置 */ function notificationConf(){ Doo::loadModel ( "notificationConf" ); $notificationConf = new notificationConf (); $detail=$notificationConf->getNotificationConfBySid($this->staff[0]['sid']); $rule=json_decode($detail['conf'],true); $data ['rule'] = $rule; $data ['memu'] = "notificationConf"; $data ['staff'] = $this->staff; $this->render ( "/admin/invoiceNotificationConf", $data ); } function ajaxSetNotificationConf(){ $notificationType=$this->get_args('notificationType')?$this->get_args('notificationType'):""; $notificationValue=$this->get_args('notificationValue')?$this->get_args('notificationValue'):''; if (!empty($notificationType)&&!empty($notificationValue)&&!empty($this->staff[0]['sid'])){ Doo::loadModel("notificationConf"); $notificationConf=new notificationConf(); $detail=$notificationConf->getNotificationConfBySid($this->staff [0] ['sid']); if (empty($detail)){ $rule=array($notificationType=>$notificationValue); $rule=json_encode($rule); $item=array( 'sid'=>$this->staff[0]['sid'], 'conf'=>$rule ); $notificationConf->addNotification($item); }else{ $rule=json_decode($detail['conf'],true); $rule[$notificationType]=$notificationValue; $rule=json_encode($rule); $item=array( 'nid'=>$detail['nid'], 'conf'=>$rule ); $notificationConf->setNotificationByCondition($item); } echo json_encode ( array ( 'status' => 1, 'msgType'=>$notificationType, 'msg' => '' ) ); die; } echo json_encode ( array ( 'status' => 2, 'msgType'=>$notificationType, 'msg' => 'illegal request' ) ); die; } function eMailTask() { Doo::loadModel ( 'tag' ); $tag = new tag (); Doo::loadModel ( 'district' ); $district = new district (); $tagList = $tag->getAllBySid ( $this->staff [0] ['sid'] ); $districtList = $district->get_lv ( 1 ); $data ['tagList'] = $tagList; $data ['districtList'] = $districtList; $data ['memu'] = "eMailTask"; $data ['staff'] = $this->staff; $data ['mailMemu'] = 'eMailTask'; $data ['nature'] = $this->nature; $this->render ( "/mail_create", $data ); } function eMialCenter() { $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" ); $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : 0; Doo::loadModel ( 'eMailList' ); $eMailList = new eMailList (); Doo::loadModel ( 'tag' ); $tag = new tag (); Doo::loadModel ( 'staff' ); $staff = new staff (); $dateCondition = "status!=2 and Year(date) =" . $year; if (! empty ( $month )) $dateCondition = "Year(date) =" . $year . " and Month(date) = " . $month; $mailList = $eMailList->find ( array ( 'where' => $dateCondition, 'asc' => 'status', 'desc' => 'elid', 'asArray' => true ) ); foreach ( $mailList as $key => $value ) { $mailList [$key] ['clientName2'] = $mailList [$key] ['clientName3'] = array (); $mailList [$key] ['clientName'] = json_decode ( gzuncompress ( base64_decode ( $value ['clientName'] ) ), true ); if (! empty ( $value ['clientName2'] )) $mailList [$key] ['clientName2'] = json_decode ( gzuncompress ( base64_decode ( $value ['clientName2'] ) ), true ); if (! empty ( $value ['clientName3'] )) $mailList [$key] ['clientName3'] = json_decode ( gzuncompress ( base64_decode ( $value ['clientName3'] ) ), true ); $mailList [$key] ['illegalEmail'] = json_decode ( $value ['illegalEmail'], true ); $mailList [$key] ['sendEmail'] = json_decode ( $value ['sendEmail'], true ); $mailList [$key] ['clientCount'] = count ( $mailList [$key] ['clientName'] ) + count ( $mailList [$key] ['clientName2'] ) + count ( $mailList [$key] ['clientName3'] ); $mailList [$key] ['tag'] = array (); $kks = $staff->getOne ( array ( 'where' => 'username like "' . $value ['staffName'] . '"', 'asArray' => true ) ); $mailList [$key] ['category'] = $kks ['category']; if (! empty ( $value ['tag'] )) $mailList [$key] ['tag'] = $tag->find ( array ( 'where' => 'tid in ( ' . $value ['tag'] . ') ', 'asArray' => true ) ); } $dateHtml = ""; $now = date ( "Y" ); for($YEARD = 2014; $YEARD <= 2050; $YEARD ++) { if ($YEARD <= $now) { $dateHtml .= ''; } } $monthHtml = ''; for($i = 1; $i <= 12; $i ++) { $monthHtml .= ''; } $data ['monthHtml'] = $monthHtml; $data ['dateHtml'] = $dateHtml; $data ['mailList'] = $mailList; $data ['memu'] = "eMailTask"; $data ['staff'] = $this->staff; $data ['mailMemu'] = 'eMialCenter'; $data ['nature'] = $this->nature; $this->render ( "/mailCenter", $data ); } function authMail() { $elid = isset ( $this->params ['elid'] ) ? $this->params ['elid'] : 0; if (! empty ( $elid )) { Doo::loadModel ( 'eMailList' ); $eMailList = new eMailList (); $eMailList->examine = 2; $eMailList->mark = $this->staff [0] ['username'] . "已同意"; $eMailList->update ( array ( 'where' => 'elid=' . $elid, 'asArray' => true ) ); } return '/eMialCenter'; } function editMailView() { $elid = isset ( $this->params ['elid'] ) ? $this->params ['elid'] : 0; Doo::loadModel ( 'tag' ); $tag = new tag (); Doo::loadModel ( 'district' ); $district = new district (); Doo::loadModel ( 'eMailList' ); $eMList = new eMailList (); $mail = $eMList->getOne ( array ( 'where' => 'elid =' . $elid . '', 'asArray' => true ) ); if (empty ( $mail )) return "/eMailList"; $mail ['tagList'] = explode ( ",", $mail ['tag'] ); $tagList = $tag->getAllBySid ( $this->staff [0] ['sid'] ); $districtList = $district->get_lv ( 1 ); $tagHtml = ''; foreach ( $tagList as $key => $value ) { $tagHtml .= ''; } $districtHtml = ''; foreach ( $districtList as $key => $value ) { $districtHtml .= '