1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735 |
- <?php
- /**
- * @author darkredz
- */
- class MobileController extends DooController {
-
- function __construct() {
-
- // Doo::loadCore ( 'uri/DooUriRouter' );
- // $router = new DooUriRouter ();
- // $routeRs = $router->execute ( Doo::app ()->route, Doo::conf ()->SUBFOLDER );
- //
- // if($routeRs['1']!="loginHttp"){
- // if(isset($_COOKIE["staff"])){
- // if(empty($_COOKIE["staff"])){
- // setcookie("staff", '', time()+36000,"/");
- // echo json_encode(array('status'=>3,'msg'=>'请登录'));die;
- // }
- // }else{
- // setcookie("staff", '', time()+36000,"/");
- // echo json_encode(array('status'=>3,'msg'=>'请登录'));die;
- // }
- //
- // }
- }
-
- function loginHttp(){
-
- $pw2=$pw = $this->get_args('pw') ? $this->get_args('pw') : "";
- $user = $this->get_args('user') ? $this->get_args('user') : "";
- //$t = $this->get_args('t') ? $this->get_args('t') : 0;
-
- Doo::loadModel ( 'staff' );
- Doo::loadModel('tag');
- $tag=new tag();
- $staff = new staff ();
- Doo::loadClass ( 'XDeode' );
- $XDeode = new XDeode ( 5 );
-
-
- if(!empty($pw)){
- if(isset($_COOKIE['staff']))//$this->authcode(,'DECODE',$this->key)
- $pw2=base64_decode($pw);
- $userinfo=$staff->checkUser($user,$pw2);
-
- if(!empty($userinfo)){//$pw;$this->authcode(,'',$this->key)
- //get user tag
- $tagList=$tag->find(array('where'=>'sid='.$userinfo[0]['sid'],'asArray'=>true));
- $userinfo[0]['passwork']=base64_encode($pw2);
- setcookie("staff", $XDeode->encode ($userinfo[0]['sid']), time()+36000,"/");
- $a=filemtime(DOO::conf()->SITE_PATH.$userinfo[0]['avatar']."_2.jpg");
- $userinfo[0]['avatarUpdateTime']=$a;
- //if ($t){
- $staff->appDate=date('Y-m-d H:i');
- $staff->update(array('where'=>'sid='.$userinfo[0]['sid']));
- //}
- echo json_encode(array('status'=>1,'msg'=>'登陆成功','userList'=>$userinfo,'tagList'=>$tagList));
- }else{
- if(isset($_COOKIE['staff']))
- $userinfo=$staff->checkUser($user,$pw);
- if(!empty($userinfo)){//$pw;$this->authcode(,'',$this->key)
- //get user tag
- $tagList=$tag->find(array('where'=>'sid='.$userinfo[0]['sid'],'asArray'=>true));
- $userinfo[0]['passwork']=base64_encode($pw);
- $a=filemtime(DOO::conf()->SITE_PATH.$userinfo[0]['avatar']."_2.jpg");
- $userinfo[0]['avatarUpdateTime']=$a;
- //if ($t){
- $staff->appDate=date('Y-m-d H:i');
- $staff->update(array('where'=>'sid='.$userinfo[0]['sid']));
- //}
- echo json_encode(array('status'=>1,'msg'=>'登陆成功C','userList'=>$userinfo,'tagList'=>$tagList));
- }else
- echo json_encode(array('status'=>2,'msg'=>'账号或密码不正确','userList'=>array()));
- }
- }else
- echo json_encode(array('status'=>2,'msg'=>'账号或密码不正确','userList'=>array()));
- }
-
- function outHttp(){
- setcookie("staff", '', time()+36000,"/");
- echo json_encode(array('status'=>1,'msg'=>'退出成功'));
- }
-
- function searchHttp(){
- $search=$pw = $this->get_args('search') ? $this->get_args('search') : "";
- $page = $this->get_args('page')&&is_numeric($this->get_args('page')) ? $this->get_args('page') : 1;
- $size = $this->get_args('size')&&is_numeric($this->get_args('size')) ? $this->get_args('size') : 10;
-
- Doo::loadModel ( 'client' );
- $client = new client ();
- Doo::loadModel ( 'staff' );
- Doo::loadModel('tag_client');
- Doo::loadModel('C_tooltip');
- Doo::loadModel('tag');
- $tagObj = new tag ();
- $cTooltip=new C_tooltip();
- $tagClient=new tag_client();
- $staff = new staff ();
-
- Doo::loadClass ( 'XDeode' );
- $XDeode = new XDeode ( 5 );
- $sid = $XDeode->decode ( $_COOKIE ["staff"] );
-
- $staffDetail=$staff->getOne(array('where'=>'sid='.$sid,'asArray'=>true));
-
- if ($page!=1)
- $page=$page*$size-1;
- else
- $page--;
-
- $ClientTagList=$tagClient->getTagClientBySid( $sid);
- $toollist=$cTooltip->find(array('where'=>'cateid='.$staffDetail["cid"],'asArray'=>true));
- $count=$client->count(array('limit'=>$page.','.$size,'where'=>" address like '%".$search."%' or clientname like '%".$search."%' or companyname like '%".$search."%' or qq like '%".$search."%' or telephone like '%".$search."%' or phone like '%".$search."%'",'asArray'=>true));
- $list=$client->find(array('limit'=>$page.','.$size,'where'=>" address like '%".$search."%' or clientname like '%".$search."%' or companyname like '%".$search."%' or qq like '%".$search."%' or telephone like '%".$search."%' or phone like '%".$search."%'",'asArray'=>true));
-
- foreach ($ClientTagList as $key=>$value){
- $ClientTagList[$key]['taginfo']= $tagObj->getTagByTidL($value['tag']);
- }
-
- foreach ($list as $key=>$value){
- if(!empty($value['cid'])){
- $list[$key]['taginfo']= array();
- $list[$key]['tag']="";
-
- foreach ($ClientTagList as $k=>$v){
- if($value['cid']==$v['client']){
- $list[$key]['taginfo']= $v['taginfo'];
- $list[$key]['tag']=$v['tag'];
- }
- }
- }
-
- $list[$key]['tooltipList']=array();
- foreach ($toollist as $k=>$v){
- if($v['cid']==$value['cid']){
- $list[$key]['tooltipList']=explode(",", $v['name']);
- break;
- }//array_pop 可以优化数组
- }
- }
-
- echo json_encode(array('status'=>1,'clientList'=>$list,'count'=>$count));
- }
-
- function districtHttp(){
- $did = $this->get_args('did')&&is_numeric($this->get_args('did')) ? $this->get_args('did') : 0;
-
- Doo::loadModel('district');
- Doo::loadModel('staff');
- $staff=new staff();
- $district=new district();
-
- Doo::loadClass ( 'XDeode' );
- $XDeode = new XDeode ( 5 );
- $sid = $XDeode->decode ( $_COOKIE ["staff"] );
-
- $staffDetail=$staff->getOne(array('where'=>'sid='.$sid,'asArray'=>true));
-
- if($did==0){
- if ($staffDetail['isadmin'])
- $districtList=$district->get_lvByid(0,$did);
- else
- $districtList=$district->get_lvByStaffid(1,$sid);
- }else{
- $districtList=$district->get_lvByid(0,$did);
- }
- echo json_encode(array('msg'=>"",'districtList'=>$districtList));
- }
-
- function clientDetailHttp(){
- $cid = $this->get_args('cid')&&is_numeric($this->get_args('cid')) ? $this->get_args('cid') : 0;
-
- if($cid!=0){
- Doo::loadModel ( 'client' );
- Doo::loadModel ( 'company' );
- Doo::loadModel ( 'service_log' );
- Doo::loadModel('longle');
- $longle = new longle();
- $client = new client ();
- $company = new company ();
- $serviceLog = new service_log ();
- Doo::loadModel ( 'client_staff' );
- Doo::loadModel ( 'staff' );
- Doo::loadModel('tag_client');
- Doo::loadModel('C_tooltip');
- Doo::loadModel('tag');
- $tagObj = new tag ();
- $cTooltip=new C_tooltip();
- $tagClient=new tag_client();
- $staff = new staff ();
- $client_staff = new client_staff ();
- Doo::loadModel('tagCompany');
- $tagCompany = new tagCompany ();
- Doo::loadModel('tagCompanyNexus');
- $tagCompanyNexus = new tagCompanyNexus ();
-
- Doo::loadClass ( 'XDeode' );
- $XDeode = new XDeode ( 5 );
-
- if (!isset($_COOKIE ["staff"])){
- $sid=0;
- }else{
-
- $sid = $XDeode->decode ( $_COOKIE ["staff"] );
- }
-
-
-
- $clientList=$client->getOne(array('where'=>'cid='.$cid,'asArray'=>true));
-
- $companyList=$longleList=$colleague=$serviceLogList=array();$clientCount=array();
- if (!empty($clientList)){
-
- $companyList=$company->getOne(array('where'=>'cid='.$clientList['companyid'],'asArray'=>true));
- $serviceLogList=$serviceLog->find(array('where'=>'clientid='.$cid,'desc'=>'date','asArray'=>true));
- $clientCount=$client->count(array('where'=>'companyid='.$clientList['companyid'],'asArray'=>true));
- $longleList=$longle->find(array('where'=>'clientid='.$cid,'asArray'=>true));
- $colleague=$client->find(array('where'=>'companyid='.$clientList['companyid'].' and cid!='.$cid,'asArray'=>true));
- }
-
- $staffDetail=$staff->getOne(array('where'=>'sid='.$sid,'asArray'=>true));
- $ClientTagList=$tagClient->getTagClientBySid( $sid);
- $toollist=array();
- if (!empty($staffDetail))
- $toollist=$cTooltip->find(array('where'=>'cateid='.$staffDetail["cid"],'asArray'=>true));
-
- $companyTagL=$tagCompany->find(array('where'=>'sid='.$sid,'asArray'=>true));
- $CompanyTagList=$tagCompanyNexus->getTagClientBySid( $sid);
- foreach ($CompanyTagList as $key=>$value){
- $CompanyTagList[$key]['taginfo']= $tagCompany->getTagByTidL($value['tag']);
- }
-
-
- if(!empty($companyList['cid'])){
- $companyList['taginfo']= array();
- $companyList['tag']="";
-
- foreach ($CompanyTagList as $k=>$v){
- if($companyList['cid']==$v['company']){
- $companyList['taginfo']= $v['taginfo'];
- $companyList['tag']=$v['tag'];
- }
- }
- }
-
-
- foreach ($ClientTagList as $key=>$value){
- $ClientTagList[$key]['taginfo']= $tagObj->getTagByTidL($value['tag']);
- }
-
-
- if(!empty($clientList['cid'])){
- $clientList['taginfo']= array();
- $clientList['tag']="";
-
- foreach ($ClientTagList as $k=>$v){
- if($clientList['cid']==$v['client']){
- $clientList['taginfo']= $v['taginfo'];
- $clientList['tag']=$v['tag'];
- }
- }
- }
-
- //$list[$key]['tooltipList']=array();
- foreach ($toollist as $k=>$v){
- if($v['cid']==$clientList['cid']){
- $clientList['tooltipList']=explode(",", $v['name']);
- break;
- }//array_pop 可以优化数组
- }
-
-
- foreach ($colleague as $key=>$value){
- if(!empty($value['cid'])){
- $colleague[$key]['taginfo']= array();
- $colleague[$key]['tag']="";
-
- foreach ($ClientTagList as $k=>$v){
- if($value['cid']==$v['client']){
- $colleague[$key]['taginfo']= $v['taginfo'];
- $colleague[$key]['tag']=$v['tag'];
- }
- }
- }
-
- $colleague[$key]['tooltipList']=array();
- foreach ($toollist as $k=>$v){
- if($v['cid']==$value['cid']){
- $colleague[$key]['tooltipList']=explode(",", $v['name']);
- break;
- }//array_pop 可以优化数组
- }
- }
-
- $companyList['clientCount']=$clientCount;
- echo json_encode(array('status'=>1,'clientList'=>$clientList,'colleague'=>$colleague,'companyList'=>$companyList,'companyTag'=>$companyTagL,'serviceLogList'=>$serviceLogList,'longleList'=>$longleList,'msg'=>''));die;
- }
- echo json_encode(array('status'=>2,'clientList'=>array(),'companyList'=>array(),'serviceLogList'=>array(),'msg'=>"请输入正确的请求路径"));
- }
-
- function advancedSearchHttp(){
- $lv1 = $this->get_args('lv1')&&is_numeric($this->get_args('lv1')) ? $this->get_args('lv1') : "";
- $lv2 = $this->get_args('lv2')&&is_numeric($this->get_args('lv2')) ? $this->get_args('lv2') : "";
- $lv3 = $this->get_args('lv3')&&is_numeric($this->get_args('lv3')) ? $this->get_args('lv3') : "";
- $tag = $this->get_args('tag') ? $this->get_args('tag') : "";
- $teamTag = $this->get_args('teamTag') ? $this->get_args('teamTag') : "";
- $page = $this->get_args('page')&&is_numeric($this->get_args('page')) ? $this->get_args('page') : 1;
- $size = $this->get_args('size')&&is_numeric($this->get_args('size')) ? $this->get_args('size') : 10;
-
- Doo::loadModel ( 'client_staff' );
- Doo::loadModel ( 'staff' );
- Doo::loadModel('tag_client');
- Doo::loadModel('C_tooltip');
- Doo::loadModel('tag');
- $tagObj = new tag ();
- $cTooltip=new C_tooltip();
- $tagClient=new tag_client();
- $staff = new staff ();
- $client_staff = new client_staff ();
-
- Doo::loadClass ( 'XDeode' );
- $XDeode = new XDeode ( 5 );
- $sid = $XDeode->decode ( $_COOKIE ["staff"] );
-
- $staffDetail=$staff->getOne(array('where'=>'sid='.$sid,'asArray'=>true));
-
- $condition="";
- if(!empty($lv1))
- $condition.=" and district like '".$lv1.",%'";
- if(!empty($lv2))
- $condition.=" and district like '".$lv1.",".$lv2.",%'";
- if(!empty($lv3))
- $condition.=" and district like '".$lv1.",".$lv2.",".$lv3."'";
-
- if(!empty($tag)){
- $tagList=explode("@", $tag);
- foreach ($tagList as $value){
- $condition.=" and c.tag like '%".$value."%' ";
- }
- }
- if ($page!=1)
- $page=$page*$size-1;
- else
- $page--;
- $limit = " limit " . $page . " , " . $size . " ";
- //获得标签
- $ClientTagList=$tagClient->getTagClientBySid( $sid);
- $toollist=$cTooltip->find(array('where'=>'cateid='.$staffDetail["cid"],'asArray'=>true));
- $count = $this->getTableCount ( "CLD_client_staff", $condition ,$staffDetail["sid"],"",$teamTag,$staffDetail['cid']);
- $clientList=$client_staff->getClientByStaff($condition,$limit,$staffDetail["sid"],$staffDetail["sid"],"",$teamTag,$staffDetail['cid']);
-
- foreach ($ClientTagList as $key=>$value){
- $ClientTagList[$key]['taginfo']= $tagObj->getTagByTidL($value['tag']);
- }
-
- foreach ($clientList as $key=>$value){
- if(!empty($value['cid'])){
- $clientList[$key]['taginfo']= array();
- $clientList[$key]['tag']="";
-
- foreach ($ClientTagList as $k=>$v){
- if($value['cid']==$v['client']){
- $clientList[$key]['taginfo']= $v['taginfo'];
- $clientList[$key]['tag']=$v['tag'];
- }
- }
- }
-
- $clientList[$key]['tooltipList']=array();
- foreach ($toollist as $k=>$v){
- if($v['cid']==$value['cid']){
- $clientList[$key]['tooltipList']=explode(",", $v['name']);
- break;
- }//array_pop 可以优化数组
- }
- $clientList[$key]['locount']=0;
- }
- echo json_encode(array('status'=>1,'clientList'=>$clientList,'count'=>$count,'msg'=>''));
- }
-
- function lockNoHttp(){
- $lockNo = $this->get_args('lockNo') ? $this->get_args('lockNo') : "";
- $page = $this->get_args('page')&&is_numeric($this->get_args('page')) ? $this->get_args('page') : 1;
- $size = $this->get_args('size')&&is_numeric($this->get_args('size')) ? $this->get_args('size') : 10;
-
- if (!empty($lockNo)){
- // Doo::loadModel("service_log");
- // $service_log = new service_log ();
- Doo::loadModel("longle");
- $longle = new longle ();
-
- if ($page!=1)
- $page=$page*$size-1;
- else
- $page--;
-
- $count=$longle->count(array('limit'=>$page.','.$size,'where'=>" key_num like '%".$lockNo."%' ",'asArray'=>true));
- $lockList=$longle->find(array('limit'=>$page.','.$size,'where'=>" key_num like '%".$lockNo."%' ",'asArray'=>true));
-
- echo json_encode(array('status'=>1,'lockList'=>$lockList,'count'=>$count,'msg'=>''));die;
- }
- echo json_encode(array('status'=>1,'lockList'=>array(),'count'=>0,'msg'=>''));
- }
-
- function lockJournalHttp(){
- $lid = $this->get_args('lid')&&is_numeric($this->get_args('lid')) ? $this->get_args('lid') : 0;
-
- if(!empty($lid)){
- Doo::loadModel("longle_log");
- $longleLog = new longle_log ();
-
- $longleLogList=$longleLog->find(array('where'=>'lid='.$lid,'asArray'=>true));
-
- echo json_encode(array('status'=>1,'JournalList'=>$longleLogList,'msg'=>''));die;
- }
- echo json_encode(array('status'=>1,'JournalList'=>array(),'msg'=>''));
- }
-
- function districtDetailHttp(){
- $dStr = $this->get_args('dStr') ? $this->get_args('dStr') : "";
- $cid = $this->get_args('cid') ? $this->get_args('cid') : 0;
- if(!empty($dStr)){
- Doo::loadModel('district');
- Doo::loadModel ( 'client' );
- $district=new district();
- $client = new client ();
-
- $districtList=$district->find(array('where'=>'id in('.$dStr.')','asArray'=>true));
- $jsonString=array();
- foreach ($districtList as $value){
- array_push($jsonString, $value['name']);
- }
- $jsonString=implode(",", $jsonString);
- if (!empty($jsonString)&&!empty($cid)){
- $client->cid=$cid;
- $client->local=$jsonString;
- $client->update();
- }
-
- echo json_encode(array('status'=>1,'districtList'=>$jsonString,'msg'=>''));die;
- }
- }
-
- function clientInfoHttp(){
- $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'):0;
- $lv22=$this->get_args('lv22')?$this->get_args('lv22'):0;
- $lv23=$this->get_args('lv23')?$this->get_args('lv23'):0;
-
- if(!empty($cid)&&!empty($clientname)){
-
- Doo::loadModel ( 'client' );
- Doo::loadModel('district');
- $district=new district();
- $client = new client();
- Doo::loadModel ( 'staff' );
- $staff = new staff ();
-
- $client->cid=$cid;
- $client->clientname=$clientname;
- if(!empty($gender))
- $client->gender=$gender;
- 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($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;
- }
-
- 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($qq))
- $client->qq=$qq;
- if(!empty($stay))
- $client->stay=$stay;
- if(!empty($priority))
- $client->priority=$priority;
- if(!empty($mark))
- $client->mark=$mark;
-
- $client->updatetime=time();
- $client->update();
-
- Doo::loadClass ( 'XDeode' );
- $XDeode = new XDeode ( 5 );
- $sid = $XDeode->decode ( $_COOKIE ["staff"] );
-
- $staffDetail=$staff->getOne(array('where'=>'sid='.$sid,'asArray'=>true));
-
- //标签
- $tid = $this->get_args ( 'tagALD' );
- Doo::loadModel('tag_client');
- //$strtid=implode(",", $tid);
- $strtid=$tid;
-
- $tagClient=new tag_client();
- $tagClientInfo=$tagClient->getTagClientBySCid($cid,$sid);
-
- //$ar=explode(",", $strtid.','.$tagClientInfo['tag']);
- //$re=array_filter(array_unique($ar));
- //$tagClient->tag=implode(",", $re);
- $tagClient->tag=$strtid;
-
- if(!empty($tagClientInfo)){
- $tagClient->tcid=$tagClientInfo['tcid'];
- $tagClient->update();
- }else{
-
- $tagClient->sid=$sid;
- $tagClient->client=$cid;
- $tagClient->insert();
- }
-
- $tid = $this->get_args ( 'tooltiplist' );
- //$k=implode(",", $tid);
- $k=$tid;
- Doo::loadModel('C_tooltip');
-
- $s=" and cateid=".$staffDetail["cid"];
-
- if(!empty($staffDetail['othercid'])){
- $othercid=explode(",", $staffDetail['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='.$cid." ".$s,'asArray'=>true));
-
- if(empty($tooltip)){
- $C_tooltip->cid=$cid;
- $C_tooltip->name=$k;
- $C_tooltip->cateid=$staffDetail['cid'];
- $C_tooltip->insert();
- }else{
- $C_tooltip->tip=$tooltip['tip'];
- $C_tooltip->name=$k;
- $C_tooltip->update();
- }
- //}
-
-
- $clientInfo=$client->getOne(array('where'=>' cid='.$cid,'asArray'=>true));
- //日常行为
- Doo::loadModel("action_log");
- $action_log=new action_log();
- $action_log->action=$staffDetail['category'].'<b href="javascript:void(0)" onclick="showStaff(\''.$staffDetail['sid'].'\')" >'.$staffDetail['username'].'</b>编辑了<a href="javascript:void(0)" onclick="showClick(\''.$cid.'\')">'.$clientname.'</a>('.$clientInfo['companyname'].')';
- $action_log->updatetime=date("Y-m-d");
- $action_log->sid=$staffDetail['sid'];
- $action_log->cid=$staffDetail['cid'];
- $action_log->status=2;
- $action_log->time=date("H:i");
-
- $action_log->class=$action_log->iconContacts;
-
-
-
- $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('status'=>1,'msg'=>''));die;
- }else
- echo json_encode(array('status'=>2,'msg'=>''));die;
-
- }
-
- function serviceLogHttp(){
-
- $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=isset($_POST['Remind'])?$_POST['Remind']:0;
- $time=isset($_POST['time'])?$_POST['time']:0;
- $remark=isset($_POST['remark'])?$_POST['remark']:"";
-
- //echo $mark;die;
- if(!empty($status)&&!empty($clientid)){
- Doo::loadModel ( 'service_log' );
- Doo::loadModel ( 'client_staff' );
-
- $clientStaff=new client_staff();
- $service_log = new service_log();
- Doo::loadModel("action_log");
- $action_log=new action_log();
- Doo::loadModel("client");
- $client=new client();
- Doo::loadModel ( 'staff' );
- $staff = new staff ();
-
- Doo::loadClass ( 'XDeode' );
- $XDeode = new XDeode ( 5 );
- $sid = $XDeode->decode ( $_COOKIE ["staff"] );
-
- $staffDetail=$staff->getOne(array('where'=>'sid='.$sid,'asArray'=>true));
-
- $service_log->status=$status;
- $service_log->clientid=$clientid;
- $service_log->mark=htmlspecialchars($mark);
- $service_log->date=$y."-".$m."-".$d;
- $service_log->category=$staffDetail['category'];
- $service_log->staffname=$staffDetail['username'];
- $service_log->staffid=$staffDetail['sid'];
-
- $service_log->insert();
-
- //日常行为
-
- //记录服务时间
- $client->cid=$clientid;
- $client->servicetime=time();
- $client->update();
-
- $clientInfo=$client->getOne(array('where'=>' cid='.$clientid,'asArray' => TRUE));
- $action_log->action=$staffDetail['category'].'<b href="javascript:void(0)" onclick="showStaff(\''.$staffDetail['sid'].'\')">'.$staffDetail['username'].'</b>为<a href="javascript:void(0)" onclick="showClick(\''.$clientInfo['cid'].'\')">'.$clientInfo['clientname'].'</a>('.$clientInfo['companyname'].')添加新客户记录。';
- $action_log->updatetime=date("Y-m-d");
-
- $action_log->sid=$staffDetail['sid'];
- $action_log->cid=$staffDetail['cid'];
-
- $action_log->time=date("H:i");
- $action_log->status=3;
-
- $action_log->districtid=$clientInfo['district'];
-
- Doo::loadModel('district');
- $district=new 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();
-
- 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=$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('status'=>1,'msg'=>''));die;
- }else
- echo json_encode(array('status'=>2,'msg'=>''));die;
- }
-
- function updateCompanyHttp(){
- $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=isset($_POST['nature'])?$_POST['nature']:false;
-
- $fax=isset($_POST['fax'])?$_POST['fax']:false;
- $webservice=isset($_POST['webservice'])?$_POST['webservice']:false;
-
- $address=isset($_POST['address'])?$_POST['address']:false;
- $ride=isset($_POST['ride'])?$_POST['ride']:false;
- $stay=isset($_POST['stay'])?$_POST['stay']:false;
- $landmarks=isset($_POST['landmarks'])?$_POST['landmarks']:false;
-
- if(empty($cid)||empty($companyname)){
- echo json_encode(array('status'=>2,'msg'=>''));die;
- }
-
- Doo::loadModel("company");
- Doo::loadModel("client");
-
- $client=new client();
- $company=new company();
-
- Doo::loadClass ( 'XDeode' );
- $XDeode = new XDeode ( 5 );
- $sid = $XDeode->decode ( $_COOKIE ["staff"] );
-
- $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($companyname)){
- $company->companyname=$companyname;
- $client->companyname=$companyname;
- }
-
- if($fax!==false)
- $company->fax=$fax;
- if($webservice!==false){
-
- $company->webservice=$webservice;
- }
- if($address!==false)
- $company->address=$address;
- if($ride!==false)
- $company->ride=$ride;
- if($stay!==false)
- $company->stay=$stay;
- if($landmarks!==false)
- $company->landmarks=$landmarks;
-
- $company->update();
- $client->update(array('where'=>' companyid ='.$cid));
-
- //标签
- $tid = $this->get_args ( 'tagALD' );
- Doo::loadModel('tagCompanyNexus');
- $strtid=$tid;
- $tagClient=new tagCompanyNexus();
- $tagClientInfo=$tagClient->getTagClientBySCid($cid,$sid);
- $tagClient->tag=$strtid;
- if(!empty($tagClientInfo)){
- $tagClient->tcid=$tagClientInfo['tcid'];
- $tagClient->update();
- }else{
- $tagClient->sid=$sid;
- $tagClient->company=$cid;
- $tagClient->insert();
- }
-
- echo json_encode(array('status'=>1,'msg'=>''));die;
- }
-
- function searchCompanyHttp(){
- $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(array('status'=>1,'companyList'=>$clientInfo));die;
-
- }else
- echo json_encode(array('status'=>2,'companyList'=>''));die;
- }
-
- function changeCompanyHttp(){
-
- $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)){
- echo json_encode(array('status'=>2,'msg'=>''));die;
- }
-
- 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();
- }
- echo json_encode(array('status'=>1,'msg'=>''));die;
- }
-
- function getProudctHttp(){
- Doo::loadModel('product');
- $product=new product();
-
- $product=$product->getProudct();
- echo json_encode(array('status'=>1,'product'=>$product));
- }
-
- function getClientHttp(){
- $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(array('status'=>1,'client'=>$clientInfo));
- }else
- echo json_encode(array('status'=>2,'client'=>array()));
- }
-
- function getLongleHttp(){
- $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(array('status'=>1,'longle'=>$longleInfo));
- }else{
- echo json_encode(array('status'=>2,'longle'=>array()));
- }
- }
-
- function getLongleIdHttp(){
- $id=$this->get_args('id')?$this->get_args('id'):"";
-
- if(!empty($id)){
-
- Doo::loadModel ( 'longle' );
- $longle = new longle();
- $longleInfo=$longle->getOne(array('where'=>'lid ='.$id,'asArray'=>true));
- echo json_encode(array('status'=>1,'longle'=>$longleInfo));
- }else{
- echo json_encode(array('status'=>2,'longle'=>array()));
- }
- }
-
- function addLockLogHttp(){
- 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 ();
- Doo::loadModel ( 'staff' );
- $staff = new staff ();
-
- Doo::loadClass ( 'XDeode' );
- $XDeode = new XDeode ( 5 );
- $sid = $XDeode->decode ( $_COOKIE ["staff"] );
-
- $status=$this->get_args('longleStatus')?$this->get_args('longleStatus'):0;
- $lid=$this->get_args('klid')?$this->get_args('klid'):0;
-
- if(empty($lid)){
- echo json_encode(array('status'=>2,'msg'=>''));die;
- }
- $linfo=$longle->getLongleByLid($lid);
- $this->staff=$staff->find(array('where'=>'sid='.$sid,'asArray'=>true));
-
- if($status==0){
- echo json_encode(array('status'=>2,'msg'=>''));die;
- }elseif($status==3){
-
- $client=$this->get_args('browseClient')?$this->get_args('browseClient'):"";
- $client=explode('-', $client);
-
- $product=isset($_POST['browseProduct'])?$_POST['browseProduct']:"";
-
- $clientname=$clientobj->getClientByName2($client[0],$client[1]);
-
- if(empty($clientname)){
- echo json_encode(array('status'=>2,'msg'=>''));die;
- }
-
- 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'].'<b href="javascript:void(0)" onclick="showStaff(\''.$this->staff[0]['sid'].'\')">'.$this->staff[0]['username'].'</b>借出<a href="javascript:void(0)" onclick="showLook(\''.$linfo[0]['key_num'].'\')">'.$linfo[0]['key_num'].'</a>给<a href="javascript:void(0)" onclick="showClick(\''.$clientname[0]['cid'].'\')">'.$client[0].'</a>('.$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=isset($_POST['sellProduct'])?$_POST['sellProduct']:"";
- $client=isset($_POST['sellClient'])?$_POST['sellClient']:"";
- $client=explode('-', $client);
- $clientname=$clientobj->getClientByName2($client[0],$client[1]);
-
- if(empty($clientname)){
- echo json_encode(array('status'=>2,'msg'=>''));die;
- }
- 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'].'<b href="javascript:void(0)" onclick="showStaff(\''.$this->staff[0]['sid'].'\')">'.$this->staff[0]['username'].'</b>销售<a href="javascript:void(0)" onclick="showLook(\''.$linfo[0]['key_num'].'\')">'.$linfo[0]['key_num'].'</a>给<a href="javascript:void(0)" onclick="showClick(\''.$clientname[0]['cid'].'\')">'.$client[0].'</a>('.$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=isset($_POST['newProduct'])?$_POST['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'].'<b href="javascript:void(0)" onclick="showStaff(\''.$this->staff[0]['sid'].'\')" >'.$this->staff[0]['username'].'</b>为<a href="javascript:void(0)" onclick="showClick(\''.$linfo[0]['clientid'].'\')">'.$linfo[0]['client'].'</a>('.$clientname['companyname'].')升级为<a href="javascript:void(0)" onclick="showLook(\''.$linfo[0]['key_num'].'\')">'.$linfo[0]['key_num'].'</a>';
- $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=isset($_POST['key_num'])?$_POST['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'];
- $newlid=$newLongle->update(array('where'=>' key_num= \''.$key_num."'"));
- $longleinfo=$longle->getOne(array('where'=>' key_num =\''.$key_num."'",'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();
-
- //新锁状态拷贝
- $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'].'<b href="javascript:void(0)" onclick="showStaff(\''.$this->staff[0]['sid'].'\')">'.$this->staff[0]['username'].'</b>为<a href="javascript:void(0)" onclick="showClick(\''.$linfo[0]['clientid'].'\')">'.$linfo[0]['client'].'</a>('.$clientname['companyname'].')更换为<a href="javascript:void(0)" onclick="showLook(\''.$key_num.'\')">'.$key_num.'</a>('.$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'].'<b href="javascript:void(0)" onclick="showStaff(\''.$this->staff[0]['sid'].'\')">'.$this->staff[0]['username'].'</b>收回<a href="javascript:void(0)">'.$linfo[0]['client'].'</a>的<a href="javascript:void(0)" onclick="showLook(\''.$linfo[0]['key_num'].'\')">'.$linfo[0]['key_num'].'</a>通过<a href="javascript:void(0)" onclick="showStaff(\''.$linfo[0]['responsible'].'\')">'.$linfo[0]['responsible'].'</a>';
- $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=isset($_POST['mark'])?$_POST['mark']:"";
- $longle_log->mark=$mark;
-
- //日常行为
- $action_log=new action_log();
-
- $action_log->action=$this->staff[0]['category'].'<b href="javascript:void(0)" onclick="showStaff(\''.$this->staff[0]['sid'].'\')">'.$this->staff[0]['username'].'</b>为<a href="javascript:void(0)" onclick="showLook(\''.$linfo[0]['key_num'].'\')">'.$linfo[0]['key_num'].'</a>添加新备注。';
- $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=isset($_POST['giftClient'])?$_POST['giftClient']:"";
- $client=explode('-', $client);
- $clientname=$clientobj->getClientByName2($client[0],$client[1]);
-
- if(empty($clientname)){
- echo json_encode(array('status'=>2,'msg'=>''));die;
- }
-
- 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'].'<b href="javascript:void(0)" onclick="showStaff(\''.$this->staff[0]['username'].'\')">'.$this->staff[0]['username'].'</b>赠送<a href="javascript:void(0)" onclick="showLook(\''.$linfo[0]['key_num'].'\')">'.$linfo[0]['key_num'].'</a>给<a href="javascript:void(0)" onclick="showClick(\''.$clientname[0]['cid'].'\')">'.$client[0].'</a>('.$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){
- echo json_encode(array('status'=>1,'msg'=>''));die;
- }
- }
-
- 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('status'=>1,'msg'=>''));die;
- }
-
- function getClientByPhoneHttp(){
- $phone = $this->get_args('phone') ? $this->get_args('phone') : '';
-
- if(!empty($phone)){
- Doo::loadModel ( 'client' );
- $client = new client ();
- Doo::loadModel('district');
- $district=new district();
-
- $con="";
- if(preg_match("/^13[0-9]{1}[0-9]{8}$|15[0189]{1}[0-9]{8}$|189[0-9]{8}$/",$phone)||preg_match("/^13[0-9]{1}[0-9]{8}$|15[0189]{1}[0-9]{8}$|189[0-9]{8}$/",$phone)){
- $con='telephone like "%'.$phone.'"';
- }elseif(preg_match("/^(0(10|21|22|23|[1-9][0-9]{2})(-|))?[0-9]{7,8}$/",$phone)){
- if(strlen ($phone)==10){
- $phone=substr($phone, 3);
- $con='phone like "%'.$phone.'"';
- }elseif (strlen ($phone)==11){
- $phone=substr($phone, 4);
- $con='phone like "%'.$phone.'"';
- }elseif (strlen ($phone)==12){
- $phone=substr($phone, 5);
- $con='phone like "%'.$phone.'"';
- }else{
- $con='telephone like "%'.$phone.'" or phone like "%'.$phone.'"';
- }
- }else{
- $con='telephone like "%'.$phone.'" or phone like "%'.$phone.'"';
- }
-
-
- $info=$client->getOne(array('where'=>$con,'asArray'=>true));
- $d=$district->find(array('select'=>'name','where'=>'id in('.$info['district'].')','asArray'=>true));
- $info['local']=$d;
- echo json_encode(array('status'=>1,'info'=>$info));die;
- }
- echo json_encode(array('status'=>2,'info'=>''));die;
- }
-
- function informationHttp(){
-
- $sid=$this->get_args('sid')?$this->get_args('sid'):0;
- $DATE=$this->get_args('date')?$this->get_args('date'):date("Y-m-d");
- //$month=$this->get_args('month')?$this->get_args('month'):date('m');
- $status=$this->get_args('status')?$this->get_args('status'):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 ();
-
- $condition="";$limit=50;
-
- if(!empty($sid))
- $condition.=" and sid=".$sid;
- if (!empty($status))
- $condition.=" and status in (".$status.")";
-
- $actionLogList=$action_log->find(array('where'=>' 1 '.$condition.' and date(updatetime) >= date_sub("'.$DATE.'",interval 30 day) and date(updatetime) <= date_sub("'.$DATE.'",interval 0 day) ','desc'=>'aid','asArray'=>true));
-
- //抽取日期 ,'groupby'=>'updatetime'
- $dateLog=$action_log->find(array('select'=>'updatetime','where'=>' 1 '.$condition.' and date(updatetime) >= date_sub("'.$DATE.'",interval 30 day) and date(updatetime) <= date_sub("'.$DATE.'",interval 0 day) ','limit'=>50,'desc'=>'aid','asArray'=>true));
-
- $count=$action_log->count(array('where'=>' 1 '.$condition,'limit'=>$limit,'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]);
- }
- }
- }
-
- $i=0;
- foreach ($log as $key=>$value){
-
- if (empty($value))
- unset($log[$key]);
- if($i>=3)
- unset($log[$key]);
- $i++;
- }
-
- echo json_encode(array('status'=>1,'count'=>$count,'list'=>$log));die;
- }
-
- function communicationHttp(){
- Doo::loadModel ( 'staff' );
- $staff = new staff ();
-
- $list=$staff->find(array ('where' => "username!= 'admin'", 'asArray' => TRUE ));
- echo json_encode(array('status'=>1,'list'=>$list));die;
- }
-
- function getStaffHttp(){
- $sid=$this->get_args('sid')?$this->get_args('sid'):0;
-
- Doo::loadModel ( 'staff' );
- $staff = new staff ();
-
- if (!empty($sid)){
- $info=$staff->getOne(array ('where' => "username!= 'admin' and sid='".$sid."'", 'asArray' => TRUE ));
- $colleague=$staff->find(array ('where' => "cid= '".$info['cid']."' and sid!='".$info['sid']."'", 'asArray' => TRUE ));
- array_push($colleague, $info);
- echo json_encode(array('status'=>1,'list'=>$colleague));die;
- }
- echo json_encode(array('status'=>2,'list'=>array()));die;
- }
-
- function getUserHttp(){
- $sid=$this->get_args('sid')?$this->get_args('sid'):0;
-
- Doo::loadModel ( 'staff' );
- $staff = new staff ();
-
- if (!empty($sid)){
- $info=$staff->getOne(array ('where' => "username!= 'admin' and sid='".$sid."'", 'asArray' => TRUE ));
- echo json_encode(array('status'=>1,'list'=>$info));die;
- }
- echo json_encode(array('status'=>2,'list'=>array()));die;
- }
-
- function editStaffHttp(){
-
- $telephone=$this->get_args('telephone')?$_POST['telephone']:0;
-
- $phone=$this->get_args('phone')?$_POST['phone']:0;
- $email=isset($_POST['email'])?$_POST['email']:"";
-
- $qq=is_numeric($this->get_args('qq'))?$_POST['qq']:0;
- $year=$this->get_args('year')?$_POST['year']:date("Y");
- $month=$this->get_args('month')?$_POST['month']:"";
- $day=$this->get_args('day')?$_POST['day']:"";
- $position=$this->get_args('position')?$_POST['position']:"";
-
- $gender=$this->get_args('gender')?$_POST['gender']:"男";
-
- $oldpassword=isset($_POST['oldpassword'])?$_POST['oldpassword']:"";
-
- $newpassword=isset($_POST['newpassword'])?$_POST['newpassword']:"";
- $rnewpassword=isset($_POST['rnewpassword'])?$_POST['rnewpassword']:"";
-
- Doo::loadModel ( 'staff' );
- $staff = new staff ();
- Doo::loadModel ( 'staffDynamic' );
- $staffDynamic=new staffDynamic();
-
- Doo::loadClass ( 'XDeode' );
- $XDeode = new XDeode ( 5 );
- $sid = $XDeode->decode ( $_COOKIE ["staff"] );
-
- $this->staff=$staff->find(array ('where' => "sid='".$sid."'", 'asArray' => TRUE ));
-
- $staff->sid=$this->staff[0]['sid'];
-
- $content="";$ext="更新了他的";
- if($telephone!=0&&$this->staff[0]['telephone']!=$telephone){
- $staff->telephone=$telephone;
- $content.="<b>手机</b> ";
- }
- if($phone!=0&&$this->staff[0]['phone']!=$phone){
- $staff->phone=$phone;
- $content.="<b>电话</b> ";
- }
-
- if($qq!=0&&$this->staff[0]['qq']!=$qq){
- $staff->qq=$qq;
- $content.="<b>QQ</b> ";
- }
- if($year!=2014){
- $staff->birthday=$year."-".$month."-".$day;
- $content.="<b>生日</b> ";
- }
- if($email!=""&&filter_var($email, FILTER_VALIDATE_EMAIL)&&$this->staff[0]['email']!=$email){
- $staff->email=$email;
- $content.="<b>邮箱</b> ";
- }
- if (!empty($position)){
- $staff->position=$position;
- $content.="<b>职位</b> ";
- }
-
- $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();
- }
-
- $fileName='avatar_'.$this->staff[0]['sid'];
- $t=DOO::conf()->SITE_PATH."global/avatar/";
- if(isset($_FILES['photo100'])){
- $file = $_FILES['photo100']['tmp_name'];
- if (is_uploaded_file($file) ){
- $upload_file ='avatar_'.$this->staff[0]['sid']."_1.jpg";
- move_uploaded_file($file, $t.$upload_file);
- }
- }
-
- if(isset($_FILES['photo50'])){
- $file2 = $_FILES['photo50']['tmp_name'];
- if (is_uploaded_file($file2) ){
- $upload_file ='avatar_'.$this->staff[0]['sid']."_2.jpg";
- move_uploaded_file($file2, $t.$upload_file);
- }
- }
-
- if(isset($_FILES['photo32'])){
- $file3 = $_FILES['photo32']['tmp_name'];
- if (is_uploaded_file($file3) ){
- $upload_file ='avatar_'.$this->staff[0]['sid']."_3.jpg";
- move_uploaded_file($file3, $t.$upload_file);
- }
- }
-
- //echo $_FILES['photo50']['tmp_name'];
- //var_dump($_FILES['photo32']['tmp_name']);
- $staff->avatar="/global/avatar/".$fileName;
- $staff->update(array('where'=>' sid='.$this->staff[0]['sid']));
- //phpinfo();
- echo json_encode(array('status'=>1,'msg'=>''));die;
- }
-
- function getRemindHttp(){
- Doo::loadModel('remind');
- $remind=new remind();
-
- Doo::loadClass ( 'XDeode' );
- $XDeode = new XDeode ( 5 );
- $sid = $XDeode->decode ( $_COOKIE ["staff"] );
-
- //Doo::loadModel ( 'client' );
- //$client = new client();
- // and date_add(time, INTERVAL day DAY) <= CURDATE()
- $remindList=$remind->find(array('where' => "staffID = '".$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]['clientInfo']=$client->getOne(array('where' => "cid = '".$value["clientID"]."'",'asArray' => TRUE));
- $remindList[$key]['Ctime']=date('m-d',strtotime($value['time']));
- $remindList[$key]['Etime']=date('m-d',strtotime($value['time']." +".$value['day']." days"));
- }
- echo json_encode(array('status'=>1,'remindList'=>$remindList,'remindCount'=>$rc,'msg'=>''));die;
- }
-
- function remindCLHttp(){
- $rid=$this->get_args('rid')&&is_numeric($this->get_args('rid'))?$this->get_args('rid'):0;
- if (!empty($rid)){
- Doo::loadModel('remind');
- $remind=new remind();
-
- Doo::loadClass ( 'XDeode' );
- $XDeode = new XDeode ( 5 );
- $sid = $XDeode->decode ( $_COOKIE ["staff"] );
-
- $remind->status=1;
- $remind->update(array('where' => "staffID = '".$sid."' and rid=".$rid,'asArray' => TRUE));
-
- echo json_encode(array('status'=>1,'msg'=>''));die;
- }
- echo json_encode(array('status'=>2,'msg'=>''));die;
- }
-
- /**
- * 获取get或者POST值
- * @param string $name 属性名称
- * @return fixed 值
- */
- function get_args($name) {
- if (isset ( $_GET [$name] )) {
- if (is_array ( $_GET [$name] ))
- return $_GET [$name];
- else {
- return addslashes ( $_GET [$name] );
-
- //return $_GET [$name] ;
- }
-
- } elseif (isset ( $_POST [$name] )) {
- if (is_array ( $_POST [$name] ))
- return $_POST [$name];
- else {
- return addslashes ( $_POST [$name] );
-
- //return $_POST [$name];
- }
- } else {
-
- return false;
- }
- }
-
- /**
- * 获取总页数
- * @param unknown_type $table
- * @param unknown_type $condition
- */
- public function getTableCount($table = "", $condition = "",$staffid="",$search,$tooltip,$cateid) {
- if (!empty($staffid)){
- //$staffid="and a.sid= '".$staffid."'"; " . $table . " as a left join on (a.cid=b.cid ".$staffid.")
- $sql = "select count(*) as count from CLD_client as b left join CLD_tag_client as c on (b.cid=c.client) where 1 " . $condition ;
- }else{
- if(strlen($condition)==1||empty($condition))
- $sql = "select count(*) as count from CLD_client as a ".$condition;
- else
- $sql = "select count(*) as count from CLD_tag_client as a left join CLD_client as c on (a.client=c.cid) where 1 ".$condition;
- }
-
- if(!empty($search))
- $sql = "select count(*) as count from CLD_client as a where 1 ".$condition ;
-
- if(!empty($tooltip)){
- $condition=str_replace("a.","c.",$condition);
-
- $sql = "select count(*) as count from CLD_C_tooltip as a left join CLD_tag_client as c on (a.cid=c.client) left join CLD_client as b on (c.client=b.cid ) where a.name like '%".$tooltip."%' and a.cateid = ".$cateid." ".$condition ;
-
- }
- //echo $sql;
- $query = Doo::db ()->query ( $sql );
-
- $result = $query->fetch ();
-
- return $result ['count'];
- }
-
- /*
- * 生成WSDL文件
- */
- function interfaceDetail(){
- Doo::loadClass("MobileApi/Service");
- }
-
- function login($user,$pw){
-
- Doo::loadModel ( 'staff' );
- $staff = new staff ();
-
- if(!empty($pw)){
- $userinfo=$staff->checkUser($user,$pw);
-
- if(!empty($userinfo)){
- setcookie("staff", $userinfo[0]['sid'], time()+36000,"/");
- return array('status'=>1,'msg'=>'登陆成功','userList'=>$userinfo);
- }else
- return array('status'=>2,'msg'=>'账号或密码不正确2','userList'=>array());
- }else
- return array('status'=>2,'msg'=>'账号或密码不正确3','userList'=>array());
- }
-
- function register($username, $gameid, $fromurl, $advertiser, $adfrom, $pagetype, $pagename, $tgid, $ip, $registertime) {
- $param = array(
- 'tg_account' => $username,
- 'tg_gameID' => $gameid,
- 'tg_advertiser' => $fromurl,
- 'tg_adFrom'=>$advertiser,
- 'tg_pageParam' => $adfrom,
- 'tg_adType' => $pagetype,
- 'tg_adsID' => $tgid,
- 'tg_ip' => $tgid,
- 'tg_registerTime' => $registertime
- );
- return $param;
- }
-
- public function service(){
-
- ini_set("soap.wsdl_cache_enabled", "0");
- $server = new SoapServer('protected/class/MobileApi/interfaceDetail.wsdl', array('soap_version' => SOAP_1_2));
- $server->setClass("MobileController");
- $server->addFunction(array('login','register'));
- $server->addFunction(SOAP_FUNCTIONS_ALL);
- $server->handle();
-
- }
-
- }
- ?>
|