MobileController.php 61 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836
  1. <?php
  2. /**
  3. * @author darkredz
  4. */
  5. class MobileController extends DooController {
  6. function __construct() {
  7. // Doo::loadCore ( 'uri/DooUriRouter' );
  8. // $router = new DooUriRouter ();
  9. // $routeRs = $router->execute ( Doo::app ()->route, Doo::conf ()->SUBFOLDER );
  10. //
  11. // if($routeRs['1']!="loginHttp"){
  12. // if(isset($_COOKIE["staff"])){
  13. // if(empty($_COOKIE["staff"])){
  14. // setcookie("staff", '', time()+36000,"/");
  15. // echo json_encode(array('status'=>3,'msg'=>'请登录'));die;
  16. // }
  17. // }else{
  18. // setcookie("staff", '', time()+36000,"/");
  19. // echo json_encode(array('status'=>3,'msg'=>'请登录'));die;
  20. // }
  21. //
  22. // }
  23. }
  24. function loginHttp(){
  25. $pw2=$pw = $this->get_args('pw') ? $this->get_args('pw') : "";
  26. $user = $this->get_args('user') ? $this->get_args('user') : "";
  27. //$t = $this->get_args('t') ? $this->get_args('t') : 0;
  28. Doo::loadModel ( 'staff' );
  29. Doo::loadModel('tag');
  30. $tag=new tag();
  31. $staff = new staff ();
  32. Doo::loadClass ( 'XDeode' );
  33. $XDeode = new XDeode ( 5 );
  34. if(!empty($pw)){
  35. if(isset($_COOKIE['staff']))//$this->authcode(,'DECODE',$this->key)
  36. $pw2=base64_decode($pw);
  37. $userinfo=$staff->checkUser($user,$pw2);
  38. if(!empty($userinfo)){//$pw;$this->authcode(,'',$this->key)
  39. //get user tag
  40. $tagList=$tag->find(array('where'=>'sid='.$userinfo[0]['sid'],'asArray'=>true));
  41. $userinfo[0]['passwork']=base64_encode($pw2);
  42. setcookie("staff", $XDeode->encode ($userinfo[0]['sid']), time()+36000,"/");
  43. $a=filemtime(DOO::conf()->SITE_PATH.$userinfo[0]['avatar']."_2.jpg");
  44. $userinfo[0]['avatarUpdateTime']=$a;
  45. //if ($t){
  46. $staff->appDate=date('Y-m-d H:i');
  47. $staff->update(array('where'=>'sid='.$userinfo[0]['sid']));
  48. //}
  49. echo json_encode(array('status'=>1,'msg'=>'登陆成功','userList'=>$userinfo,'tagList'=>$tagList));
  50. }else{
  51. if(isset($_COOKIE['staff']))
  52. $userinfo=$staff->checkUser($user,$pw);
  53. if(!empty($userinfo)){//$pw;$this->authcode(,'',$this->key)
  54. //get user tag
  55. $tagList=$tag->find(array('where'=>'sid='.$userinfo[0]['sid'],'asArray'=>true));
  56. $userinfo[0]['passwork']=base64_encode($pw);
  57. $a=filemtime(DOO::conf()->SITE_PATH.$userinfo[0]['avatar']."_2.jpg");
  58. $userinfo[0]['avatarUpdateTime']=$a;
  59. //if ($t){
  60. $staff->appDate=date('Y-m-d H:i');
  61. $staff->update(array('where'=>'sid='.$userinfo[0]['sid']));
  62. //}
  63. echo json_encode(array('status'=>1,'msg'=>'登陆成功C','userList'=>$userinfo,'tagList'=>$tagList));
  64. }else
  65. echo json_encode(array('status'=>2,'msg'=>'账号或密码不正确','userList'=>array()));
  66. }
  67. }else
  68. echo json_encode(array('status'=>2,'msg'=>'账号或密码不正确','userList'=>array()));
  69. }
  70. function outHttp(){
  71. setcookie("staff", '', time()+36000,"/");
  72. echo json_encode(array('status'=>1,'msg'=>'退出成功'));
  73. }
  74. function searchHttp(){
  75. $search=$pw = $this->get_args('search') ? $this->get_args('search') : "";
  76. $page = $this->get_args('page')&&is_numeric($this->get_args('page')) ? $this->get_args('page') : 1;
  77. $size = $this->get_args('size')&&is_numeric($this->get_args('size')) ? $this->get_args('size') : 10;
  78. Doo::loadModel ( 'client' );
  79. $client = new client ();
  80. Doo::loadModel ( 'staff' );
  81. Doo::loadModel('tag_client');
  82. Doo::loadModel('C_tooltip');
  83. Doo::loadModel('tag');
  84. $tagObj = new tag ();
  85. $cTooltip=new C_tooltip();
  86. $tagClient=new tag_client();
  87. $staff = new staff ();
  88. Doo::loadClass ( 'XDeode' );
  89. $XDeode = new XDeode ( 5 );
  90. $sid = $XDeode->decode ( $_COOKIE ["staff"] );
  91. $staffDetail=$staff->getOne(array('where'=>'sid='.$sid,'asArray'=>true));
  92. if ($page!=1)
  93. $page=$page*$size-1;
  94. else
  95. $page--;
  96. $ClientTagList=$tagClient->getTagClientBySid( $sid);
  97. $toollist=$cTooltip->find(array('where'=>'cateid='.$staffDetail["cid"],'asArray'=>true));
  98. $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));
  99. $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));
  100. foreach ($ClientTagList as $key=>$value){
  101. $ClientTagList[$key]['taginfo']= $tagObj->getTagByTidL($value['tag']);
  102. }
  103. foreach ($list as $key=>$value){
  104. if(!empty($value['cid'])){
  105. $list[$key]['taginfo']= array();
  106. $list[$key]['tag']="";
  107. foreach ($ClientTagList as $k=>$v){
  108. if($value['cid']==$v['client']){
  109. $list[$key]['taginfo']= $v['taginfo'];
  110. $list[$key]['tag']=$v['tag'];
  111. }
  112. }
  113. }
  114. $list[$key]['tooltipList']=array();
  115. foreach ($toollist as $k=>$v){
  116. if($v['cid']==$value['cid']){
  117. $list[$key]['tooltipList']=explode(",", $v['name']);
  118. break;
  119. }//array_pop 可以优化数组
  120. }
  121. }
  122. echo json_encode(array('status'=>1,'clientList'=>$list,'count'=>$count));
  123. }
  124. function districtHttp(){
  125. $did = $this->get_args('did')&&is_numeric($this->get_args('did')) ? $this->get_args('did') : 0;
  126. Doo::loadModel('district');
  127. Doo::loadModel('staff');
  128. $staff=new staff();
  129. $district=new district();
  130. Doo::loadClass ( 'XDeode' );
  131. $XDeode = new XDeode ( 5 );
  132. $sid = $XDeode->decode ( $_COOKIE ["staff"] );
  133. $staffDetail=$staff->getOne(array('where'=>'sid='.$sid,'asArray'=>true));
  134. if($did==0){
  135. if ($staffDetail['isadmin'])
  136. $districtList=$district->get_lvByid(0,$did);
  137. else
  138. $districtList=$district->get_lvByStaffid(1,$sid);
  139. }else{
  140. $districtList=$district->get_lvByid(0,$did);
  141. }
  142. echo json_encode(array('msg'=>"",'districtList'=>$districtList));
  143. }
  144. function clientDetailHttp(){
  145. $cid = $this->get_args('cid')&&is_numeric($this->get_args('cid')) ? $this->get_args('cid') : 0;
  146. if($cid!=0){
  147. Doo::loadModel ( 'client' );
  148. Doo::loadModel ( 'company' );
  149. Doo::loadModel ( 'service_log' );
  150. Doo::loadModel('longle');
  151. $longle = new longle();
  152. $client = new client ();
  153. $company = new company ();
  154. $serviceLog = new service_log ();
  155. Doo::loadModel ( 'client_staff' );
  156. Doo::loadModel ( 'staff' );
  157. Doo::loadModel('tag_client');
  158. Doo::loadModel('C_tooltip');
  159. Doo::loadModel('tag');
  160. $tagObj = new tag ();
  161. $cTooltip=new C_tooltip();
  162. $tagClient=new tag_client();
  163. $staff = new staff ();
  164. $client_staff = new client_staff ();
  165. Doo::loadModel('tagCompany');
  166. $tagCompany = new tagCompany ();
  167. Doo::loadModel('tagCompanyNexus');
  168. $tagCompanyNexus = new tagCompanyNexus ();
  169. Doo::loadClass ( 'XDeode' );
  170. $XDeode = new XDeode ( 5 );
  171. if (!isset($_COOKIE ["staff"])){
  172. $sid=0;
  173. }else{
  174. $sid = $XDeode->decode ( $_COOKIE ["staff"] );
  175. }
  176. $clientList=$client->getOne(array('where'=>'cid='.$cid,'asArray'=>true));
  177. $companyList=$longleList=$colleague=$serviceLogList=array();$clientCount=array();
  178. if (!empty($clientList)){
  179. $companyList=$company->getOne(array('where'=>'cid='.$clientList['companyid'],'asArray'=>true));
  180. $serviceLogList=$serviceLog->find(array('where'=>'clientid='.$cid,'desc'=>'date','asArray'=>true));
  181. $clientCount=$client->count(array('where'=>'companyid='.$clientList['companyid'],'asArray'=>true));
  182. $longleList=$longle->find(array('where'=>'clientid='.$cid,'asArray'=>true));
  183. $colleague=$client->find(array('where'=>'companyid='.$clientList['companyid'].' and cid!='.$cid,'asArray'=>true));
  184. }
  185. $staffDetail=$staff->getOne(array('where'=>'sid='.$sid,'asArray'=>true));
  186. $ClientTagList=$tagClient->getTagClientBySid( $sid);
  187. $toollist=array();
  188. if (!empty($staffDetail))
  189. $toollist=$cTooltip->find(array('where'=>'cateid='.$staffDetail["cid"],'asArray'=>true));
  190. $companyTagL=$tagCompany->find(array('where'=>'sid='.$sid,'asArray'=>true));
  191. $CompanyTagList=$tagCompanyNexus->getTagClientBySid( $sid);
  192. foreach ($CompanyTagList as $key=>$value){
  193. $CompanyTagList[$key]['taginfo']= $tagCompany->getTagByTidL($value['tag']);
  194. }
  195. if(!empty($companyList['cid'])){
  196. $companyList['taginfo']= array();
  197. $companyList['tag']="";
  198. foreach ($CompanyTagList as $k=>$v){
  199. if($companyList['cid']==$v['company']){
  200. $companyList['taginfo']= $v['taginfo'];
  201. $companyList['tag']=$v['tag'];
  202. }
  203. }
  204. }
  205. foreach ($ClientTagList as $key=>$value){
  206. $ClientTagList[$key]['taginfo']= $tagObj->getTagByTidL($value['tag']);
  207. }
  208. if(!empty($clientList['cid'])){
  209. $clientList['taginfo']= array();
  210. $clientList['tag']="";
  211. foreach ($ClientTagList as $k=>$v){
  212. if($clientList['cid']==$v['client']){
  213. $clientList['taginfo']= $v['taginfo'];
  214. $clientList['tag']=$v['tag'];
  215. }
  216. }
  217. }
  218. //$list[$key]['tooltipList']=array();
  219. foreach ($toollist as $k=>$v){
  220. if($v['cid']==$clientList['cid']){
  221. $clientList['tooltipList']=explode(",", $v['name']);
  222. break;
  223. }//array_pop 可以优化数组
  224. }
  225. foreach ($colleague as $key=>$value){
  226. if(!empty($value['cid'])){
  227. $colleague[$key]['taginfo']= array();
  228. $colleague[$key]['tag']="";
  229. foreach ($ClientTagList as $k=>$v){
  230. if($value['cid']==$v['client']){
  231. $colleague[$key]['taginfo']= $v['taginfo'];
  232. $colleague[$key]['tag']=$v['tag'];
  233. }
  234. }
  235. }
  236. $colleague[$key]['tooltipList']=array();
  237. foreach ($toollist as $k=>$v){
  238. if($v['cid']==$value['cid']){
  239. $colleague[$key]['tooltipList']=explode(",", $v['name']);
  240. break;
  241. }//array_pop 可以优化数组
  242. }
  243. }
  244. $companyList['clientCount']=$clientCount;
  245. echo json_encode(array('status'=>1,'clientList'=>$clientList,'colleague'=>$colleague,'companyList'=>$companyList,'companyTag'=>$companyTagL,'serviceLogList'=>$serviceLogList,'longleList'=>$longleList,'msg'=>''));die;
  246. }
  247. echo json_encode(array('status'=>2,'clientList'=>array(),'companyList'=>array(),'serviceLogList'=>array(),'msg'=>"请输入正确的请求路径"));
  248. }
  249. function advancedSearchHttp(){
  250. $lv1 = $this->get_args('lv1')&&is_numeric($this->get_args('lv1')) ? $this->get_args('lv1') : "";
  251. $lv2 = $this->get_args('lv2')&&is_numeric($this->get_args('lv2')) ? $this->get_args('lv2') : "";
  252. $lv3 = $this->get_args('lv3')&&is_numeric($this->get_args('lv3')) ? $this->get_args('lv3') : "";
  253. $tag = $this->get_args('tag') ? $this->get_args('tag') : "";
  254. $teamTag = $this->get_args('teamTag') ? $this->get_args('teamTag') : "";
  255. $page = $this->get_args('page')&&is_numeric($this->get_args('page')) ? $this->get_args('page') : 1;
  256. $size = $this->get_args('size')&&is_numeric($this->get_args('size')) ? $this->get_args('size') : 10;
  257. Doo::loadModel ( 'client_staff' );
  258. Doo::loadModel ( 'staff' );
  259. Doo::loadModel('tag_client');
  260. Doo::loadModel('C_tooltip');
  261. Doo::loadModel('tag');
  262. $tagObj = new tag ();
  263. $cTooltip=new C_tooltip();
  264. $tagClient=new tag_client();
  265. $staff = new staff ();
  266. $client_staff = new client_staff ();
  267. Doo::loadClass ( 'XDeode' );
  268. $XDeode = new XDeode ( 5 );
  269. $sid = $XDeode->decode ( $_COOKIE ["staff"] );
  270. $staffDetail=$staff->getOne(array('where'=>'sid='.$sid,'asArray'=>true));
  271. $condition="";
  272. if(!empty($lv1))
  273. $condition.=" and district like '".$lv1.",%'";
  274. if(!empty($lv2))
  275. $condition.=" and district like '".$lv1.",".$lv2.",%'";
  276. if(!empty($lv3))
  277. $condition.=" and district like '".$lv1.",".$lv2.",".$lv3."'";
  278. if(!empty($tag)){
  279. $tagList=explode("@", $tag);
  280. foreach ($tagList as $value){
  281. $condition.=" and c.tag like '%".$value."%' ";
  282. }
  283. }
  284. if ($page!=1)
  285. $page=$page*$size-1;
  286. else
  287. $page--;
  288. $limit = " limit " . $page . " , " . $size . " ";
  289. //获得标签
  290. $ClientTagList=$tagClient->getTagClientBySid( $sid);
  291. $toollist=$cTooltip->find(array('where'=>'cateid='.$staffDetail["cid"],'asArray'=>true));
  292. $count = $this->getTableCount ( "CLD_client_staff", $condition ,$staffDetail["sid"],"",$teamTag,$staffDetail['cid']);
  293. $clientList=$client_staff->getClientByStaff($condition,$limit,$staffDetail["sid"],$staffDetail["sid"],"",$teamTag,$staffDetail['cid']);
  294. foreach ($ClientTagList as $key=>$value){
  295. $ClientTagList[$key]['taginfo']= $tagObj->getTagByTidL($value['tag']);
  296. }
  297. foreach ($clientList as $key=>$value){
  298. if(!empty($value['cid'])){
  299. $clientList[$key]['taginfo']= array();
  300. $clientList[$key]['tag']="";
  301. foreach ($ClientTagList as $k=>$v){
  302. if($value['cid']==$v['client']){
  303. $clientList[$key]['taginfo']= $v['taginfo'];
  304. $clientList[$key]['tag']=$v['tag'];
  305. }
  306. }
  307. }
  308. $clientList[$key]['tooltipList']=array();
  309. foreach ($toollist as $k=>$v){
  310. if($v['cid']==$value['cid']){
  311. $clientList[$key]['tooltipList']=explode(",", $v['name']);
  312. break;
  313. }//array_pop 可以优化数组
  314. }
  315. $clientList[$key]['locount']=0;
  316. }
  317. echo json_encode(array('status'=>1,'clientList'=>$clientList,'count'=>$count,'msg'=>''));
  318. }
  319. function lockNoHttp(){
  320. $lockNo = $this->get_args('lockNo') ? $this->get_args('lockNo') : "";
  321. $page = $this->get_args('page')&&is_numeric($this->get_args('page')) ? $this->get_args('page') : 1;
  322. $size = $this->get_args('size')&&is_numeric($this->get_args('size')) ? $this->get_args('size') : 10;
  323. if (!empty($lockNo)){
  324. // Doo::loadModel("service_log");
  325. // $service_log = new service_log ();
  326. Doo::loadModel("longle");
  327. $longle = new longle ();
  328. if ($page!=1)
  329. $page=$page*$size-1;
  330. else
  331. $page--;
  332. $count=$longle->count(array('limit'=>$page.','.$size,'where'=>" key_num like '%".$lockNo."%' ",'asArray'=>true));
  333. $lockList=$longle->find(array('limit'=>$page.','.$size,'where'=>" key_num like '%".$lockNo."%' ",'asArray'=>true));
  334. echo json_encode(array('status'=>1,'lockList'=>$lockList,'count'=>$count,'msg'=>''));die;
  335. }
  336. echo json_encode(array('status'=>1,'lockList'=>array(),'count'=>0,'msg'=>''));
  337. }
  338. function lockJournalHttp(){
  339. $lid = $this->get_args('lid')&&is_numeric($this->get_args('lid')) ? $this->get_args('lid') : 0;
  340. if(!empty($lid)){
  341. Doo::loadModel("longle_log");
  342. $longleLog = new longle_log ();
  343. $longleLogList=$longleLog->find(array('where'=>'lid='.$lid,'asArray'=>true));
  344. echo json_encode(array('status'=>1,'JournalList'=>$longleLogList,'msg'=>''));die;
  345. }
  346. echo json_encode(array('status'=>1,'JournalList'=>array(),'msg'=>''));
  347. }
  348. function districtDetailHttp(){
  349. $dStr = $this->get_args('dStr') ? $this->get_args('dStr') : "";
  350. $cid = $this->get_args('cid') ? $this->get_args('cid') : 0;
  351. if(!empty($dStr)){
  352. Doo::loadModel('district');
  353. Doo::loadModel ( 'client' );
  354. $district=new district();
  355. $client = new client ();
  356. $districtList=$district->find(array('where'=>'id in('.$dStr.')','asArray'=>true));
  357. $jsonString=array();
  358. foreach ($districtList as $value){
  359. array_push($jsonString, $value['name']);
  360. }
  361. $jsonString=implode(",", $jsonString);
  362. if (!empty($jsonString)&&!empty($cid)){
  363. $client->cid=$cid;
  364. $client->local=$jsonString;
  365. $client->update();
  366. }
  367. echo json_encode(array('status'=>1,'districtList'=>$jsonString,'msg'=>''));die;
  368. }
  369. }
  370. function clientInfoHttp(){
  371. $cid=$this->get_args('cid')?$this->get_args('cid'):0;
  372. $clientname=$this->get_args('clientname')?$this->get_args('clientname'):"";
  373. $gender=$this->get_args('gender')?$this->get_args('gender'):"";
  374. $nicename=$this->get_args('nicename')?$this->get_args('nicename'):"";
  375. $telephone=$this->get_args('telephone')?$this->get_args('telephone'):"";
  376. $phone=$this->get_args('phone')?$this->get_args('phone'):"";
  377. $email=$this->get_args('email')?$this->get_args('email'):"";
  378. $unit=$this->get_args('unit')?$this->get_args('unit'):"";
  379. $fax=$this->get_args('fax')?$this->get_args('fax'):"";
  380. $webservice=$this->get_args('webservice')?$this->get_args('webservice'):"";
  381. $department=$this->get_args('department')?$this->get_args('department'):"";
  382. $position=$this->get_args('position')?$this->get_args('position'):"";
  383. $office=$this->get_args('office')?$this->get_args('office'):"";
  384. $address=$this->get_args('address')?$this->get_args('address'):"";
  385. $ride=$this->get_args('ride')?$this->get_args('ride'):"";
  386. $landmarks=$this->get_args('landmarks')?$this->get_args('landmarks'):"";
  387. $qq=$this->get_args('qq')?$this->get_args('qq'):"";
  388. $priority=$this->get_args('priority')?$this->get_args('priority'):5;
  389. $stay=$this->get_args('stay')?$this->get_args('stay'):"";
  390. $mark=$this->get_args('mark')?$this->get_args('mark'):"";
  391. $lv21=$this->get_args('lv21')?$this->get_args('lv21'):0;
  392. $lv22=$this->get_args('lv22')?$this->get_args('lv22'):0;
  393. $lv23=$this->get_args('lv23')?$this->get_args('lv23'):0;
  394. if(!empty($cid)&&!empty($clientname)){
  395. Doo::loadModel ( 'client' );
  396. Doo::loadModel('district');
  397. $district=new district();
  398. $client = new client();
  399. Doo::loadModel ( 'staff' );
  400. $staff = new staff ();
  401. $client->cid=$cid;
  402. $client->clientname=$clientname;
  403. if(!empty($gender))
  404. $client->gender=$gender;
  405. if(!empty($nicename))
  406. $client->nicename=$nicename;
  407. if(!empty($telephone))
  408. $client->telephone=$telephone;
  409. if(!empty($phone))
  410. $client->phone=$phone;
  411. if(!empty($email))
  412. $client->email=$email;
  413. if(!empty($lv21)&&!empty($lv22)&&!empty($lv23)){
  414. $client->district=$lv21.",".$lv22.",".$lv23;
  415. }
  416. if(!empty($client->district)){
  417. $districtList=$district->find(array('where'=>'id in('.$client->district.')','asArray'=>true));
  418. $jsonString=array();
  419. foreach ($districtList as $value){
  420. array_push($jsonString, $value['name']);
  421. }
  422. $jsonString=implode(",", $jsonString);
  423. if (!empty($jsonString))
  424. $client->local=$jsonString;
  425. }
  426. if(!empty($fax))
  427. $client->fax=$fax;
  428. if(!empty($webservice))
  429. $client->webservice=$webservice;
  430. if(!empty($department))
  431. $client->department=$department;
  432. if(!empty($position))
  433. $client->position=$position;
  434. if(!empty($office))
  435. $client->office=$office;
  436. if(!empty($address))
  437. $client->address=$address;
  438. if(!empty($ride))
  439. $client->ride=$ride;
  440. if(!empty($landmarks))
  441. $client->landmarks=$landmarks;
  442. if(!empty($qq))
  443. $client->qq=$qq;
  444. if(!empty($stay))
  445. $client->stay=$stay;
  446. if(!empty($priority))
  447. $client->priority=$priority;
  448. if(!empty($mark))
  449. $client->mark=$mark;
  450. $client->updatetime=time();
  451. $client->update();
  452. Doo::loadClass ( 'XDeode' );
  453. $XDeode = new XDeode ( 5 );
  454. $sid = $XDeode->decode ( $_COOKIE ["staff"] );
  455. $staffDetail=$staff->getOne(array('where'=>'sid='.$sid,'asArray'=>true));
  456. //标签
  457. $tid = $this->get_args ( 'tagALD' );
  458. Doo::loadModel('tag_client');
  459. //$strtid=implode(",", $tid);
  460. $strtid=$tid;
  461. $tagClient=new tag_client();
  462. $tagClientInfo=$tagClient->getTagClientBySCid($cid,$sid);
  463. //$ar=explode(",", $strtid.','.$tagClientInfo['tag']);
  464. //$re=array_filter(array_unique($ar));
  465. //$tagClient->tag=implode(",", $re);
  466. $tagClient->tag=$strtid;
  467. if(!empty($tagClientInfo)){
  468. $tagClient->tcid=$tagClientInfo['tcid'];
  469. $tagClient->update();
  470. }else{
  471. $tagClient->sid=$sid;
  472. $tagClient->client=$cid;
  473. $tagClient->insert();
  474. }
  475. $tid = $this->get_args ( 'tooltiplist' );
  476. //$k=implode(",", $tid);
  477. $k=$tid;
  478. Doo::loadModel('C_tooltip');
  479. $s=" and cateid=".$staffDetail["cid"];
  480. if(!empty($staffDetail['othercid'])){
  481. $othercid=explode(",", $staffDetail['othercid']);
  482. foreach ($othercid as $value){
  483. $s.=" or cateid=".$value;
  484. }
  485. }
  486. //foreach ($cid as $key=>$value){
  487. $C_tooltip = new C_tooltip ();
  488. $tooltip=$C_tooltip->getOne(array('where'=>'cid='.$cid." ".$s,'asArray'=>true));
  489. if(empty($tooltip)){
  490. $C_tooltip->cid=$cid;
  491. $C_tooltip->name=$k;
  492. $C_tooltip->cateid=$staffDetail['cid'];
  493. $C_tooltip->insert();
  494. }else{
  495. $C_tooltip->tip=$tooltip['tip'];
  496. $C_tooltip->name=$k;
  497. $C_tooltip->update();
  498. }
  499. //}
  500. $clientInfo=$client->getOne(array('where'=>' cid='.$cid,'asArray'=>true));
  501. //日常行为
  502. Doo::loadModel("action_log");
  503. $action_log=new action_log();
  504. $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'].')';
  505. $action_log->updatetime=date("Y-m-d");
  506. $action_log->sid=$staffDetail['sid'];
  507. $action_log->cid=$staffDetail['cid'];
  508. $action_log->status=2;
  509. $action_log->time=date("H:i");
  510. $action_log->class=$action_log->iconContacts;
  511. $action_log->districtid=$clientInfo['district'];
  512. $local=$district->getbyidlist($clientInfo['district']);
  513. $action_log->city=$local[0]['name'];
  514. $action_log->province=$local[1]['name'];
  515. $action_log->company=$clientInfo['companyname'];
  516. Doo::loadModel('company');
  517. $company=new company();
  518. $companyInfo=$company->getOne(array('where'=>' companyname="'.$clientInfo['companyname'].'"','asArray'=>true));
  519. $nature=explode(',', $companyInfo['nature']);
  520. $action_log->nature=$nature[0];
  521. $action_log->insert();
  522. echo json_encode(array('status'=>1,'msg'=>''));die;
  523. }else
  524. echo json_encode(array('status'=>2,'msg'=>''));die;
  525. }
  526. function serviceLogHttp(){
  527. $status=$this->get_args('status')?$this->get_args('status'):"";
  528. $clientid=$this->get_args('cid')?$this->get_args('cid'):"";
  529. $mark=$this->get_args('mark')?$this->get_args('mark'):"";
  530. $m=$this->get_args('m')?$this->get_args('m'):"";
  531. $d=$this->get_args('d')?$this->get_args('d'):"";
  532. $y=$this->get_args('y')?$this->get_args('y'):date("Y");
  533. $Remind=isset($_POST['Remind'])?$_POST['Remind']:0;
  534. $time=isset($_POST['time'])?$_POST['time']:0;
  535. $remark=isset($_POST['remark'])?$_POST['remark']:"";
  536. //echo $mark;die;
  537. if(!empty($status)&&!empty($clientid)){
  538. Doo::loadModel ( 'service_log' );
  539. Doo::loadModel ( 'client_staff' );
  540. $clientStaff=new client_staff();
  541. $service_log = new service_log();
  542. Doo::loadModel("action_log");
  543. $action_log=new action_log();
  544. Doo::loadModel("client");
  545. $client=new client();
  546. Doo::loadModel ( 'staff' );
  547. $staff = new staff ();
  548. Doo::loadClass ( 'XDeode' );
  549. $XDeode = new XDeode ( 5 );
  550. $sid = $XDeode->decode ( $_COOKIE ["staff"] );
  551. $staffDetail=$staff->getOne(array('where'=>'sid='.$sid,'asArray'=>true));
  552. $service_log->status=$status;
  553. $service_log->clientid=$clientid;
  554. $service_log->mark=htmlspecialchars($mark);
  555. $service_log->date=$y."-".$m."-".$d;
  556. $service_log->category=$staffDetail['category'];
  557. $service_log->staffname=$staffDetail['username'];
  558. $service_log->staffid=$staffDetail['sid'];
  559. $service_log->insert();
  560. //日常行为
  561. //记录服务时间
  562. $client->cid=$clientid;
  563. $client->servicetime=time();
  564. $client->update();
  565. $clientInfo=$client->getOne(array('where'=>' cid='.$clientid,'asArray' => TRUE));
  566. $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'].')添加新客户记录。';
  567. $action_log->updatetime=date("Y-m-d");
  568. $action_log->sid=$staffDetail['sid'];
  569. $action_log->cid=$staffDetail['cid'];
  570. $action_log->time=date("H:i");
  571. $action_log->status=3;
  572. $action_log->districtid=$clientInfo['district'];
  573. Doo::loadModel('district');
  574. $district=new district();
  575. $local=$district->getbyidlist($clientInfo['district']);
  576. $action_log->city=$local[0]['name'];
  577. $action_log->province=$local[1]['name'];
  578. $action_log->company=$clientInfo['companyname'];
  579. Doo::loadModel('company');
  580. $company=new company();
  581. $companyInfo=$company->getOne(array('where'=>' companyname="'.$clientInfo['companyname'].'"','asArray'=>true));
  582. $nature=explode(',', $companyInfo['nature']);
  583. $action_log->nature=$nature[0];
  584. $action_log->class=$action_log->iconContacts;
  585. $action_log->insert();
  586. // 更新信息中心服务日志统计数量
  587. $redis = new Redis ();
  588. $redis->connect ( '127.0.0.1', '6379' );
  589. $categoryCondition = " and cid=" . $staffDetail ['cid'];
  590. $sidCondition = " and sid=" . $staffDetail ['sid'];
  591. // actionlog免查询值 $alCondition='';
  592. $alCondition = ' aid>' . REMIT . ' and ';
  593. // 个人服务日志数量redis值
  594. $redisKeyCS = date ( 'Y-m-d' ) . 'SL_' . $staffDetail ['cid'] . '_' . $staffDetail ['sid'];
  595. $action_log = new action_log ();
  596. $actionLogLongle = $action_log->find ( array (
  597. 'select' => 'date_format(updatetime,"%m-%d") as updatetime,COUNT(*) as count',
  598. 'where' => $alCondition . " status=3 " . $categoryCondition . $sidCondition . " and date_sub(curdate(), INTERVAL 30 DAY) <= date(updatetime) ",
  599. 'groupby' => 'date_format(updatetime,"%m-%d")',
  600. 'asArray' => true
  601. ) );
  602. $statisticsLongle = array ();
  603. for($d = 0; $d <= 29; $d ++) {
  604. $MD = date ( "m-d", strtotime ( "-" . $d . " day" ) );
  605. $falgLongle = true;
  606. foreach ( $actionLogLongle as $value ) {
  607. if ($value ['updatetime'] == $MD) {
  608. array_push ( $statisticsLongle, $value ['count'] );
  609. $falgLongle = false;
  610. break;
  611. }
  612. }
  613. if ($falgLongle)
  614. array_push ( $statisticsLongle, 0 );
  615. }
  616. $statisticsLongle = array_reverse ( $statisticsLongle );
  617. $jsl = json_encode ( $statisticsLongle );
  618. $redis->set ( $redisKeyCS, $jsl );
  619. // 办事处服务日志数量reids值
  620. $redisKeyC = date ( 'Y-m-d' ) . 'SL_' . $staffDetail ['cid'] . '_';
  621. $action_log = new action_log ();
  622. $actionLogLongle = $action_log->find ( array (
  623. 'select' => 'date_format(updatetime,"%m-%d") as updatetime,COUNT(*) as count',
  624. 'where' => $alCondition . " status=3 " . $categoryCondition . " and date_sub(curdate(), INTERVAL 30 DAY) <= date(updatetime) ",
  625. 'groupby' => 'date_format(updatetime,"%m-%d")',
  626. 'asArray' => true
  627. ) );
  628. $statisticsLongle = array ();
  629. for($d = 0; $d <= 29; $d ++) {
  630. $MD = date ( "m-d", strtotime ( "-" . $d . " day" ) );
  631. $falgLongle = true;
  632. foreach ( $actionLogLongle as $value ) {
  633. if ($value ['updatetime'] == $MD) {
  634. array_push ( $statisticsLongle, $value ['count'] );
  635. $falgLongle = false;
  636. break;
  637. }
  638. }
  639. if ($falgLongle)
  640. array_push ( $statisticsLongle, 0 );
  641. }
  642. $statisticsLongle = array_reverse ( $statisticsLongle );
  643. $jsl = json_encode ( $statisticsLongle );
  644. $redis->set ( $redisKeyC, $jsl );
  645. // 全员处服务日志数量的redis值
  646. $redisKey = date ( 'Y-m-d' ) . 'SL__';
  647. $action_log = new action_log ();
  648. $actionLogLongle = $action_log->find ( array (
  649. 'select' => 'date_format(updatetime,"%m-%d") as updatetime,COUNT(*) as count',
  650. 'where' => $alCondition . " status=3 and date_sub(curdate(), INTERVAL 30 DAY) <= date(updatetime) ",
  651. 'groupby' => 'date_format(updatetime,"%m-%d")',
  652. 'asArray' => true
  653. ) );
  654. $statisticsLongle = array ();
  655. for($d = 0; $d <= 29; $d ++) {
  656. $MD = date ( "m-d", strtotime ( "-" . $d . " day" ) );
  657. $falgLongle = true;
  658. foreach ( $actionLogLongle as $value ) {
  659. if ($value ['updatetime'] == $MD) {
  660. array_push ( $statisticsLongle, $value ['count'] );
  661. $falgLongle = false;
  662. break;
  663. }
  664. }
  665. if ($falgLongle)
  666. array_push ( $statisticsLongle, 0 );
  667. }
  668. $statisticsLongle = array_reverse ( $statisticsLongle );
  669. $jsl = json_encode ( $statisticsLongle );
  670. $redis->set ( $redisKey, $jsl );
  671. if (!empty($Remind)){
  672. Doo::loadModel('remind');
  673. $remindObj=new remind();
  674. $datetime1 = new DateTime(date('Y-m-d'));
  675. $datetime2 = new DateTime($time);
  676. $interval = $datetime1->diff($datetime2);
  677. $remindObj->day=$interval->format('%a');
  678. $remindObj->remark=$remark;
  679. $remindObj->time=date("Y-m-d");
  680. $remindObj->clientName=$clientInfo['clientname'];
  681. $remindObj->clientID=$clientid;
  682. $remindObj->companyName=$clientInfo['companyname'];
  683. $remindObj->companyID=$companyInfo['cid'];
  684. $remindObj->staffID=$sid;
  685. if ($status==1)
  686. $remindObj->class="iconService";
  687. if ($status==2)
  688. $remindObj->class="iconPhone";
  689. if ($status==3)
  690. $remindObj->class="iconOther";
  691. $remindObj->insert();
  692. }
  693. echo json_encode(array('status'=>1,'msg'=>''));die;
  694. }else
  695. echo json_encode(array('status'=>2,'msg'=>''));die;
  696. }
  697. function updateCompanyHttp(){
  698. $cid=$this->get_args('cid')?$this->get_args('cid'):0;
  699. $companyname=$this->get_args('companyName')?$this->get_args('companyName'):"";
  700. $lv21=$this->get_args('lv21')?$this->get_args('lv21'):0;
  701. $lv22=$this->get_args('lv22')?$this->get_args('lv22'):0;
  702. $lv23=$this->get_args('lv23')?$this->get_args('lv23'):0;
  703. $nature=isset($_POST['nature'])?$_POST['nature']:false;
  704. $fax=isset($_POST['fax'])?$_POST['fax']:false;
  705. $webservice=isset($_POST['webservice'])?$_POST['webservice']:false;
  706. $address=isset($_POST['address'])?$_POST['address']:false;
  707. $ride=isset($_POST['ride'])?$_POST['ride']:false;
  708. $stay=isset($_POST['stay'])?$_POST['stay']:false;
  709. $landmarks=isset($_POST['landmarks'])?$_POST['landmarks']:false;
  710. if(empty($cid)||empty($companyname)){
  711. echo json_encode(array('status'=>2,'msg'=>''));die;
  712. }
  713. Doo::loadModel("company");
  714. Doo::loadModel("client");
  715. $client=new client();
  716. $company=new company();
  717. Doo::loadClass ( 'XDeode' );
  718. $XDeode = new XDeode ( 5 );
  719. $sid = $XDeode->decode ( $_COOKIE ["staff"] );
  720. $company->cid=$cid;
  721. if(!empty($lv21)&&!empty($lv22)&&!empty($lv23)){
  722. Doo::loadModel ( 'district' );
  723. $district = new district ();
  724. //更新公司信息
  725. $lv1=$district->getbyid($lv21);
  726. $lv2=$district->getbyid($lv22);
  727. $lv3=$district->getbyid($lv23);
  728. $company->district=$lv21.",".$lv22.",".$lv23;
  729. $company->local=$lv1[0]['name'].",".$lv2[0]['name'].",".$lv3[0]['name'];
  730. }
  731. if(!empty($companyname)){
  732. $company->companyname=$companyname;
  733. $client->companyname=$companyname;
  734. }
  735. if($fax!==false)
  736. $company->fax=$fax;
  737. if($webservice!==false){
  738. $company->webservice=$webservice;
  739. }
  740. if($address!==false)
  741. $company->address=$address;
  742. if($ride!==false)
  743. $company->ride=$ride;
  744. if($stay!==false)
  745. $company->stay=$stay;
  746. if($landmarks!==false)
  747. $company->landmarks=$landmarks;
  748. $company->update();
  749. $client->update(array('where'=>' companyid ='.$cid));
  750. //标签
  751. $tid = $this->get_args ( 'tagALD' );
  752. Doo::loadModel('tagCompanyNexus');
  753. $strtid=$tid;
  754. $tagClient=new tagCompanyNexus();
  755. $tagClientInfo=$tagClient->getTagClientBySCid($cid,$sid);
  756. $tagClient->tag=$strtid;
  757. if(!empty($tagClientInfo)){
  758. $tagClient->tcid=$tagClientInfo['tcid'];
  759. $tagClient->update();
  760. }else{
  761. $tagClient->sid=$sid;
  762. $tagClient->company=$cid;
  763. $tagClient->insert();
  764. }
  765. echo json_encode(array('status'=>1,'msg'=>''));die;
  766. }
  767. function searchCompanyHttp(){
  768. $searchDbInforItem=$this->get_args('searchDbInforItem')?$this->get_args('searchDbInforItem'):"";
  769. if(!empty($searchDbInforItem)){
  770. Doo::loadModel ( 'company' );
  771. $company = new company();
  772. $clientInfo=$company->searchCompany($searchDbInforItem);
  773. echo json_encode(array('status'=>1,'companyList'=>$clientInfo));die;
  774. }else
  775. echo json_encode(array('status'=>2,'companyList'=>''));die;
  776. }
  777. function changeCompanyHttp(){
  778. $cid=$this->get_args('cid')?$this->get_args('cid'):0;
  779. $clientID=$this->get_args('clientID')?$this->get_args('clientID'):0;
  780. $companyname=$this->get_args('companyName')?$this->get_args('companyName'):"";
  781. Doo::loadModel ( 'company' );
  782. Doo::loadModel ( 'client' );
  783. $client = new client();
  784. $company = new company();
  785. $companyname=explode("-", $companyname);
  786. if(isset($companyname[1]))
  787. $k=$company->getCompanyByName($companyname[0], $companyname[1]);
  788. else
  789. $k=array();
  790. if(!empty($cid)&&!empty($k)&&!empty($clientID)){
  791. $client->cid=$clientID;
  792. $client->companyid=$cid;
  793. $client->companyname=$companyname[0];
  794. $client->update();
  795. }else{
  796. $local1=$this->get_args('lv21')?$this->get_args('lv21'):0;
  797. $local2=$this->get_args('lv22')?$this->get_args('lv22'):0;
  798. $local3=$this->get_args('lv23')?$this->get_args('lv23'):0;
  799. Doo::loadModel ('district');
  800. $district = new district ();
  801. //更新公司信息
  802. $lv1=$district->getbyid($local1);
  803. $lv2=$district->getbyid($local2);
  804. $lv3=$district->getbyid($local3);
  805. if(empty($local1)||empty($local2)){
  806. echo json_encode(array('status'=>2,'msg'=>''));die;
  807. }
  808. if(!empty($local1)&&!empty($local2))
  809. $company->local=$lv1[0]['name'].",".$lv2[0]['name'].",".$lv3[0]['name'];
  810. if(!empty($local1)&&!empty($local2))
  811. $company->district=$local1.",".$local2.",".$local3;
  812. $nature=$this->get_args('nature')?$this->get_args('nature'):"";
  813. $fax=$this->get_args('fax')?$this->get_args('fax'):"";
  814. $webservice=$this->get_args('webservice')?$this->get_args('webservice'):"";
  815. $address=$this->get_args('address')?$this->get_args('address'):"";
  816. $landmarks=$this->get_args('landmarks')?$this->get_args('landmarks'):"";
  817. $stay=$this->get_args('stay')?$this->get_args('stay'):"";
  818. $ride=$this->get_args('ride')?$this->get_args('ride'):"";
  819. //$nature=implode(",", $nature);
  820. $company->companyname=$companyname[0];
  821. $company->ride=$ride;
  822. $company->fax=$fax;
  823. $company->webservice=$webservice;
  824. $company->address=$address;
  825. $company->landmarks=$landmarks;
  826. $company->stay=$stay;
  827. $company->nature=$nature;
  828. $cid=$company->insert();
  829. $client->cid=$clientID;
  830. $client->companyid=$cid;
  831. $client->companyname=$companyname[0];
  832. $client->update();
  833. }
  834. echo json_encode(array('status'=>1,'msg'=>''));die;
  835. }
  836. function getProudctHttp(){
  837. Doo::loadModel('product');
  838. $product=new product();
  839. $product=$product->getProudct();
  840. echo json_encode(array('status'=>1,'product'=>$product));
  841. }
  842. function getClientHttp(){
  843. $searchDbInforItem=$this->get_args('searchDbInforItem')?$this->get_args('searchDbInforItem'):"";
  844. if(!empty($searchDbInforItem)){
  845. Doo::loadModel ( 'client' );
  846. $client = new client();
  847. $clientInfo=$client->getClientByName($searchDbInforItem);
  848. echo json_encode(array('status'=>1,'client'=>$clientInfo));
  849. }else
  850. echo json_encode(array('status'=>2,'client'=>array()));
  851. }
  852. function getLongleHttp(){
  853. $searchDbInforItem=$this->get_args('searchDbInforItem')?$this->get_args('searchDbInforItem'):"";
  854. if(!empty($searchDbInforItem)){
  855. Doo::loadModel ( 'longle' );
  856. $longle = new longle();
  857. $longleInfo=$longle->getLongleBykeynum2($searchDbInforItem);
  858. echo json_encode(array('status'=>1,'longle'=>$longleInfo));
  859. }else{
  860. echo json_encode(array('status'=>2,'longle'=>array()));
  861. }
  862. }
  863. function getLongleIdHttp(){
  864. $id=$this->get_args('id')?$this->get_args('id'):"";
  865. if(!empty($id)){
  866. Doo::loadModel ( 'longle' );
  867. $longle = new longle();
  868. $longleInfo=$longle->getOne(array('where'=>'lid ='.$id,'asArray'=>true));
  869. echo json_encode(array('status'=>1,'longle'=>$longleInfo));
  870. }else{
  871. echo json_encode(array('status'=>2,'longle'=>array()));
  872. }
  873. }
  874. function addLockLogHttp(){
  875. Doo::loadModel ( 'longle_log' );
  876. Doo::loadModel ( 'longle' );
  877. Doo::loadModel("action_log");
  878. Doo::loadModel ( 'client' );
  879. $clientobj = new client ();
  880. $longle = new longle ();
  881. $longle_log = new longle_log ();
  882. Doo::loadModel ( 'district' );
  883. $district = new district ();
  884. Doo::loadModel ( 'staff' );
  885. $staff = new staff ();
  886. Doo::loadClass ( 'XDeode' );
  887. $XDeode = new XDeode ( 5 );
  888. $sid = $XDeode->decode ( $_COOKIE ["staff"] );
  889. $status=$this->get_args('longleStatus')?$this->get_args('longleStatus'):0;
  890. $lid=$this->get_args('klid')?$this->get_args('klid'):0;
  891. if(empty($lid)){
  892. echo json_encode(array('status'=>2,'msg'=>''));die;
  893. }
  894. $linfo=$longle->getLongleByLid($lid);
  895. $this->staff=$staff->find(array('where'=>'sid='.$sid,'asArray'=>true));
  896. if($status==0){
  897. echo json_encode(array('status'=>2,'msg'=>''));die;
  898. }elseif($status==3){
  899. $client=$this->get_args('browseClient')?$this->get_args('browseClient'):"";
  900. $client=explode('-', $client);
  901. $product=isset($_POST['browseProduct'])?$_POST['browseProduct']:"";
  902. $clientname=$clientobj->getClientByName2($client[0],$client[1]);
  903. if(empty($clientname)){
  904. echo json_encode(array('status'=>2,'msg'=>''));die;
  905. }
  906. if($client[0]!=""){
  907. $longle->client=$client[0];
  908. $longle->clientid=$clientname[0]['cid'];
  909. }
  910. // if($product!="")
  911. // $longle->product=$product;
  912. $longle->statusT="借出";
  913. $longle_log->client=$client[0];
  914. $longle_log->clientid=$clientname[0]['cid'];
  915. $longle_log->product=$linfo[0]['product'];
  916. $longle_log->statusT="借出";
  917. //日常行为
  918. $action_log=new action_log();
  919. $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'].')';
  920. $action_log->sid=$this->staff[0]['sid'];
  921. $action_log->cid=$this->staff[0]['cid'];
  922. $action_log->updatetime=date("Y-m-d");
  923. $action_log->time=date("H:i");
  924. $action_log->status=4;
  925. $action_log->districtid=$clientname[0]['district'];
  926. $local=$district->getbyidlist($clientname[0]['district']);
  927. $action_log->city=$local[0]['name'];
  928. $action_log->province=$local[1]['name'];
  929. $action_log->company=$clientname[0]['companyname'];
  930. Doo::loadModel('company');
  931. $company=new company();
  932. $companyInfo=$company->getOne(array('where'=>' companyname="'.$clientname[0]['companyname'].'"','asArray'=>true));
  933. $nature=explode(',', $companyInfo['nature']);
  934. $action_log->nature=$nature[0];
  935. $action_log->class=$action_log->iconBorrow;
  936. $action_log->insert();
  937. }elseif($status==4){
  938. //$sellClient =
  939. $product=isset($_POST['sellProduct'])?$_POST['sellProduct']:"";
  940. $client=$this->get_args ( 'sellClient' ) ? $this->get_args ( 'sellClient' ) : "";//isset($_POST['sellClient'])?$_POST['sellClient']:"";
  941. $client=explode('-', $client);
  942. $clientname=$clientobj->getClientByName2($client[0],$client[1]);
  943. if(empty($clientname)){
  944. echo json_encode(array('status'=>2,'msg'=>'not found client'));die;
  945. }
  946. if($client[0]!=""){
  947. $longle->client=$client[0];
  948. $longle->clientid=$clientname[0]['cid'];
  949. }
  950. // if($product!="")
  951. // $longle->product=$product;
  952. $longle->statusT="销售";
  953. $longle_log->client=$client[0];
  954. $longle_log->clientid=$clientname[0]['cid'];
  955. $longle_log->product=$linfo[0]['product'];
  956. $longle_log->statusT="销售";
  957. //日常行为
  958. $action_log=new action_log();
  959. $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'].')';
  960. $action_log->sid=$this->staff[0]['sid'];
  961. $action_log->cid=$this->staff[0]['cid'];
  962. $action_log->updatetime=date("Y-m-d");
  963. $action_log->time=date("H:i");
  964. $action_log->status=5;
  965. $action_log->districtid=$clientname[0]['district'];
  966. $local=$district->getbyidlist($clientname[0]['district']);
  967. $action_log->city=$local[0]['name'];
  968. $action_log->province=$local[1]['name'];
  969. $action_log->company=$clientname[0]['companyname'];
  970. Doo::loadModel('company');
  971. $company=new company();
  972. $companyInfo=$company->getOne(array('where'=>' companyname="'.$clientname[0]['companyname'].'"','asArray'=>true));
  973. $nature=explode(',', $companyInfo['nature']);
  974. $action_log->nature=$nature[0];
  975. $action_log->class=$action_log->iconSell;
  976. $action_log->insert();
  977. }elseif($status==5){
  978. $product=isset($_POST['newProduct'])?$_POST['newProduct']:"";
  979. if($product!="")
  980. $longle->product=$linfo[0]['product']."+".$product;
  981. $longle->statusT="升级";
  982. $longle_log->product=$linfo[0]['product']."+".$product;
  983. $longle_log->statusT="升级";
  984. $longle_log->client=$linfo[0]['client'];
  985. $longle_log->clientid=$linfo[0]['clientid'];
  986. $clientname=$clientobj->getOne( array ('where' => "cid= '".$linfo[0]['clientid']."'",'asArray' => TRUE));
  987. //日常行为
  988. $action_log=new action_log();
  989. $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>';
  990. $action_log->sid=$this->staff[0]['sid'];
  991. $action_log->cid=$this->staff[0]['cid'];
  992. $action_log->updatetime=date("Y-m-d");
  993. $action_log->time=date("H:i");
  994. $action_log->class=$action_log->iconUpdate;
  995. $action_log->sid=$this->staff[0]['sid'];
  996. $action_log->cid=$this->staff[0]['cid'];
  997. $action_log->status=7;
  998. $action_log->insert();
  999. }elseif($status==6){
  1000. $key_num=isset($_POST['key_num'])?$_POST['key_num']:"";
  1001. $key_num2=explode("-", $key_num);
  1002. $key_num=$key_num2[0]."-".$key_num2[1];
  1003. //if($key_num!="")
  1004. // $longle->key_num=$key_num;
  1005. //新锁拷贝记录
  1006. $newLongle=new longle();
  1007. $newLongle->product=$linfo[0]['product'];
  1008. $newLongle->statusT="更换";
  1009. $newLongle->status=6;
  1010. $newLongle->client=$linfo[0]['client'];
  1011. $newlid=$newLongle->update(array('where'=>' key_num= \''.$key_num."'"));
  1012. $longleinfo=$longle->getOne(array('where'=>' key_num =\''.$key_num."'",'asArray'=>true));
  1013. //新记录日志
  1014. $newlongle_log=new longle_log();
  1015. $newlongle_log->statusT="更换";
  1016. $newlongle_log->status=6;
  1017. $newlongle_log->client=$linfo[0]['client'];
  1018. $newlongle_log->new_key_num=$linfo[0]['key_num'];
  1019. $newlongle_log->product=$linfo[0]['product'];
  1020. $newlongle_log->category=$this->staff[0]['category'];
  1021. $newlongle_log->dateline=date("Y-m-d");
  1022. $newlongle_log->operator=$this->staff[0]['username'];
  1023. $newlongle_log->lid=$longleinfo['lid'];
  1024. $newlongle_log->insert();
  1025. //新锁状态拷贝
  1026. $longle->statusT="更换";
  1027. $longle_log->new_key_num=$key_num;
  1028. $longle_log->statusT="更换";
  1029. $longle_log->client=$linfo[0]['client'];
  1030. $clientname=$clientobj->getOne( array ('where' => "cid= '".$linfo[0]['clientid']."'",'asArray' => TRUE));
  1031. //日常行为
  1032. $action_log=new action_log();
  1033. $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'].')';
  1034. $action_log->sid=$this->staff[0]['sid'];
  1035. $action_log->cid=$this->staff[0]['cid'];
  1036. $action_log->updatetime=date("Y-m-d");
  1037. $action_log->time=date("H:i");
  1038. $action_log->class=$action_log->iconReplace;
  1039. $action_log->sid=$this->staff[0]['sid'];
  1040. $action_log->cid=$this->staff[0]['cid'];
  1041. $action_log->status=8;
  1042. $action_log->insert();
  1043. }elseif($status==7){
  1044. $longle->statusT="收回";
  1045. $longle_log->statusT="收回";
  1046. $longle_log->responsible=$linfo[0]['responsible'];
  1047. //日常行为
  1048. $action_log=new action_log();
  1049. $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>';
  1050. $action_log->sid=$this->staff[0]['sid'];
  1051. $action_log->cid=$this->staff[0]['cid'];
  1052. $action_log->updatetime=date("Y-m-d");
  1053. $action_log->time=date("H:i");
  1054. $action_log->class=$action_log->iconRecycle;
  1055. $action_log->sid=$this->staff[0]['sid'];
  1056. $action_log->cid=$this->staff[0]['cid'];
  1057. $action_log->status=9;
  1058. $action_log->insert();
  1059. }elseif($status==8){
  1060. $mark=isset($_POST['mark'])?$_POST['mark']:"";
  1061. $longle_log->mark=$mark;
  1062. //日常行为
  1063. $action_log=new action_log();
  1064. $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>添加新备注。';
  1065. $action_log->sid=$this->staff[0]['sid'];
  1066. $action_log->cid=$this->staff[0]['cid'];
  1067. $action_log->updatetime=date("Y-m-d");
  1068. $action_log->time=date("H:i");
  1069. $action_log->sid=$this->staff[0]['sid'];
  1070. $action_log->cid=$this->staff[0]['cid'];
  1071. $action_log->status=10;
  1072. $action_log->class=$action_log->iconLock;
  1073. $action_log->insert();
  1074. }elseif($status==9){
  1075. $longle->statusT="赠送";
  1076. $longle_log->statusT="赠送";
  1077. $client=isset($_POST['giftClient'])?$_POST['giftClient']:"";
  1078. $client=explode('-', $client);
  1079. $clientname=$clientobj->getClientByName2($client[0],$client[1]);
  1080. if(empty($clientname)){
  1081. echo json_encode(array('status'=>2,'msg'=>''));die;
  1082. }
  1083. if($client[0]!=""){
  1084. $longle->client=$client[0];
  1085. $longle->clientid=$clientname[0]['cid'];
  1086. }
  1087. $longle_log->client=$client[0];
  1088. $longle_log->clientid=$clientname[0]['cid'];
  1089. //日常行为
  1090. $action_log=new action_log();
  1091. $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'].')';
  1092. $action_log->updatetime=date("Y-m-d");
  1093. $action_log->time=date("H:i");
  1094. $action_log->class=$action_log->iconRecycle;
  1095. $action_log->sid=$this->staff[0]['sid'];
  1096. $action_log->cid=$this->staff[0]['cid'];
  1097. $action_log->status=6;
  1098. $action_log->districtid=$clientname[0]['district'];
  1099. $local=$district->getbyidlist($clientname[0]['district']);
  1100. $action_log->city=$local[0]['name'];
  1101. $action_log->province=$local[1]['name'];
  1102. $action_log->company=$clientname[0]['companyname'];
  1103. Doo::loadModel('company');
  1104. $company=new company();
  1105. $companyInfo=$company->getOne(array('where'=>' companyname="'.$clientname[0]['companyname'].'"','asArray'=>true));
  1106. $nature=explode(',', $companyInfo['nature']);
  1107. $action_log->nature=$nature[0];
  1108. $action_log->insert();
  1109. }
  1110. //记录使用过的状态
  1111. $statuslog=$status.",".$linfo[0]['statuslog'];
  1112. $ar=explode(',', $statuslog);
  1113. $statuslog=implode(',', array_unique(array_filter($ar)));
  1114. $longle->statuslog=$statuslog;
  1115. if($linfo[0]['status']<=2){
  1116. if($status>=4&&$status<=2){
  1117. echo json_encode(array('status'=>1,'msg'=>''));die;
  1118. }
  1119. }
  1120. if($lid!=0){
  1121. $longle->lid=$lid;
  1122. if($status!=8)
  1123. $longle->status=$status;
  1124. //if($status!=8)
  1125. $longle->responsible=$this->staff[0]['username'];
  1126. $longle->update();
  1127. }
  1128. $longle_log->lid=$lid;
  1129. $longle_log->status=$status;
  1130. $longle_log->operator=$this->staff[0]['username'];
  1131. //责任人
  1132. $longle_log->category=$this->staff[0]['category'];
  1133. $longle_log->dateline=date("Y-m-d");
  1134. $longle_log->insert();
  1135. echo json_encode(array('status'=>1,'msg'=>''));die;
  1136. }
  1137. function getClientByPhoneHttp(){
  1138. $phone = $this->get_args('phone') ? $this->get_args('phone') : '';
  1139. if(!empty($phone)){
  1140. Doo::loadModel ( 'client' );
  1141. $client = new client ();
  1142. Doo::loadModel('district');
  1143. $district=new district();
  1144. $con="";
  1145. 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)){
  1146. $con='telephone like "%'.$phone.'"';
  1147. }elseif(preg_match("/^(0(10|21|22|23|[1-9][0-9]{2})(-|))?[0-9]{7,8}$/",$phone)){
  1148. if(strlen ($phone)==10){
  1149. $phone=substr($phone, 3);
  1150. $con='phone like "%'.$phone.'"';
  1151. }elseif (strlen ($phone)==11){
  1152. $phone=substr($phone, 4);
  1153. $con='phone like "%'.$phone.'"';
  1154. }elseif (strlen ($phone)==12){
  1155. $phone=substr($phone, 5);
  1156. $con='phone like "%'.$phone.'"';
  1157. }else{
  1158. $con='telephone like "%'.$phone.'" or phone like "%'.$phone.'"';
  1159. }
  1160. }else{
  1161. $con='telephone like "%'.$phone.'" or phone like "%'.$phone.'"';
  1162. }
  1163. $info=$client->getOne(array('where'=>$con,'asArray'=>true));
  1164. $d=$district->find(array('select'=>'name','where'=>'id in('.$info['district'].')','asArray'=>true));
  1165. $info['local']=$d;
  1166. echo json_encode(array('status'=>1,'info'=>$info));die;
  1167. }
  1168. echo json_encode(array('status'=>2,'info'=>''));die;
  1169. }
  1170. function informationHttp(){
  1171. $sid=$this->get_args('sid')?$this->get_args('sid'):0;
  1172. $DATE=$this->get_args('date')?$this->get_args('date'):date("Y-m-d");
  1173. //$month=$this->get_args('month')?$this->get_args('month'):date('m');
  1174. $status=$this->get_args('status')?$this->get_args('status'):0;
  1175. Doo::loadModel('action_log');
  1176. $action_log=new action_log();
  1177. Doo::loadModel ( 'staff' );
  1178. $staff = new staff ();
  1179. Doo::loadModel('client_staff');
  1180. $client_staff=new client_staff();
  1181. Doo::loadModel('longle');
  1182. $longle=new longle();
  1183. Doo::loadModel('L_category');
  1184. $lcategory = new L_category ();
  1185. $condition="";$limit=50;
  1186. if(!empty($sid))
  1187. $condition.=" and sid=".$sid;
  1188. if (!empty($status))
  1189. $condition.=" and status in (".$status.")";
  1190. $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));
  1191. //抽取日期 ,'groupby'=>'updatetime'
  1192. $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));
  1193. $count=$action_log->count(array('where'=>' 1 '.$condition,'limit'=>$limit,'asArray'=>true));
  1194. $dl=array();
  1195. foreach ($dateLog as $value){
  1196. array_push($dl, $value['updatetime']);
  1197. }
  1198. $dateLog=array_unique($dl);
  1199. $log=array();
  1200. foreach ($dateLog as $key=>$value){
  1201. $log[$value]=array();
  1202. foreach ($actionLogList as $k=>$v){
  1203. if($value==$v['updatetime']){
  1204. array_push($log[$value], $v);
  1205. unset($actionLogList[$k]);
  1206. }
  1207. }
  1208. }
  1209. $i=0;
  1210. foreach ($log as $key=>$value){
  1211. if (empty($value))
  1212. unset($log[$key]);
  1213. if($i>=3)
  1214. unset($log[$key]);
  1215. $i++;
  1216. }
  1217. echo json_encode(array('status'=>1,'count'=>$count,'list'=>$log));die;
  1218. }
  1219. function communicationHttp(){
  1220. Doo::loadModel ( 'staff' );
  1221. $staff = new staff ();
  1222. $list=$staff->find(array ('where' => "username!= 'admin'", 'asArray' => TRUE ));
  1223. echo json_encode(array('status'=>1,'list'=>$list));die;
  1224. }
  1225. function getStaffHttp(){
  1226. $sid=$this->get_args('sid')?$this->get_args('sid'):0;
  1227. Doo::loadModel ( 'staff' );
  1228. $staff = new staff ();
  1229. if (!empty($sid)){
  1230. $info=$staff->getOne(array ('where' => "username!= 'admin' and sid='".$sid."'", 'asArray' => TRUE ));
  1231. $colleague=$staff->find(array ('where' => "cid= '".$info['cid']."' and sid!='".$info['sid']."'", 'asArray' => TRUE ));
  1232. array_push($colleague, $info);
  1233. echo json_encode(array('status'=>1,'list'=>$colleague));die;
  1234. }
  1235. echo json_encode(array('status'=>2,'list'=>array()));die;
  1236. }
  1237. function getUserHttp(){
  1238. $sid=$this->get_args('sid')?$this->get_args('sid'):0;
  1239. Doo::loadModel ( 'staff' );
  1240. $staff = new staff ();
  1241. if (!empty($sid)){
  1242. $info=$staff->getOne(array ('where' => "username!= 'admin' and sid='".$sid."'", 'asArray' => TRUE ));
  1243. echo json_encode(array('status'=>1,'list'=>$info));die;
  1244. }
  1245. echo json_encode(array('status'=>2,'list'=>array()));die;
  1246. }
  1247. function editStaffHttp(){
  1248. $telephone=$this->get_args('telephone')?$_POST['telephone']:0;
  1249. $phone=$this->get_args('phone')?$_POST['phone']:0;
  1250. $email=isset($_POST['email'])?$_POST['email']:"";
  1251. $qq=is_numeric($this->get_args('qq'))?$_POST['qq']:0;
  1252. $year=$this->get_args('year')?$_POST['year']:date("Y");
  1253. $month=$this->get_args('month')?$_POST['month']:"";
  1254. $day=$this->get_args('day')?$_POST['day']:"";
  1255. $position=$this->get_args('position')?$_POST['position']:"";
  1256. $gender=$this->get_args('gender')?$_POST['gender']:"男";
  1257. $oldpassword=isset($_POST['oldpassword'])?$_POST['oldpassword']:"";
  1258. $newpassword=isset($_POST['newpassword'])?$_POST['newpassword']:"";
  1259. $rnewpassword=isset($_POST['rnewpassword'])?$_POST['rnewpassword']:"";
  1260. Doo::loadModel ( 'staff' );
  1261. $staff = new staff ();
  1262. Doo::loadModel ( 'staffDynamic' );
  1263. $staffDynamic=new staffDynamic();
  1264. Doo::loadClass ( 'XDeode' );
  1265. $XDeode = new XDeode ( 5 );
  1266. $sid = $XDeode->decode ( $_COOKIE ["staff"] );
  1267. $this->staff=$staff->find(array ('where' => "sid='".$sid."'", 'asArray' => TRUE ));
  1268. $staff->sid=$this->staff[0]['sid'];
  1269. $content="";$ext="更新了他的";
  1270. if($telephone!=0&&$this->staff[0]['telephone']!=$telephone){
  1271. $staff->telephone=$telephone;
  1272. $content.="<b>手机</b>&nbsp;";
  1273. }
  1274. if($phone!=0&&$this->staff[0]['phone']!=$phone){
  1275. $staff->phone=$phone;
  1276. $content.="<b>电话</b>&nbsp;";
  1277. }
  1278. if($qq!=0&&$this->staff[0]['qq']!=$qq){
  1279. $staff->qq=$qq;
  1280. $content.="<b>QQ</b>&nbsp;";
  1281. }
  1282. if($year!=2014){
  1283. $staff->birthday=$year."-".$month."-".$day;
  1284. $content.="<b>生日</b>&nbsp;";
  1285. }
  1286. if($email!=""&&filter_var($email, FILTER_VALIDATE_EMAIL)&&$this->staff[0]['email']!=$email){
  1287. $staff->email=$email;
  1288. $content.="<b>邮箱</b>&nbsp;";
  1289. }
  1290. if (!empty($position)){
  1291. $staff->position=$position;
  1292. $content.="<b>职位</b>&nbsp;";
  1293. }
  1294. $staff->gender=$gender;
  1295. $msg="更新成功";
  1296. if($this->staff[0]['passwork']==md5($oldpassword)){
  1297. if($newpassword==$rnewpassword&&(!empty($newpassword)))
  1298. $staff->passwork=md5($newpassword);
  1299. else
  1300. $msg="密码不一致";
  1301. }else{
  1302. if($oldpassword!="")
  1303. $msg="密码错误";
  1304. }
  1305. if (!empty($content)){
  1306. $staffDynamic->content=$ext.$content;
  1307. $staffDynamic->cid=$this->staff[0]['cid'];
  1308. $staffDynamic->category=$this->staff[0]['category'];
  1309. $staffDynamic->time=time();
  1310. $staffDynamic->sid=$this->staff[0]['sid'];
  1311. $staffDynamic->staff=$this->staff[0]['username'];
  1312. $staffDynamic->insert();
  1313. }
  1314. $fileName='avatar_'.$this->staff[0]['sid'];
  1315. $t=DOO::conf()->SITE_PATH."global/avatar/";
  1316. if(isset($_FILES['photo100'])){
  1317. $file = $_FILES['photo100']['tmp_name'];
  1318. if (is_uploaded_file($file) ){
  1319. $upload_file ='avatar_'.$this->staff[0]['sid']."_1.jpg";
  1320. move_uploaded_file($file, $t.$upload_file);
  1321. }
  1322. }
  1323. if(isset($_FILES['photo50'])){
  1324. $file2 = $_FILES['photo50']['tmp_name'];
  1325. if (is_uploaded_file($file2) ){
  1326. $upload_file ='avatar_'.$this->staff[0]['sid']."_2.jpg";
  1327. move_uploaded_file($file2, $t.$upload_file);
  1328. }
  1329. }
  1330. if(isset($_FILES['photo32'])){
  1331. $file3 = $_FILES['photo32']['tmp_name'];
  1332. if (is_uploaded_file($file3) ){
  1333. $upload_file ='avatar_'.$this->staff[0]['sid']."_3.jpg";
  1334. move_uploaded_file($file3, $t.$upload_file);
  1335. }
  1336. }
  1337. //echo $_FILES['photo50']['tmp_name'];
  1338. //var_dump($_FILES['photo32']['tmp_name']);
  1339. $staff->avatar="/global/avatar/".$fileName;
  1340. $staff->update(array('where'=>' sid='.$this->staff[0]['sid']));
  1341. //phpinfo();
  1342. echo json_encode(array('status'=>1,'msg'=>''));die;
  1343. }
  1344. function getRemindHttp(){
  1345. Doo::loadModel('remind');
  1346. $remind=new remind();
  1347. Doo::loadClass ( 'XDeode' );
  1348. $XDeode = new XDeode ( 5 );
  1349. $sid = $XDeode->decode ( $_COOKIE ["staff"] );
  1350. //Doo::loadModel ( 'client' );
  1351. //$client = new client();
  1352. // and date_add(time, INTERVAL day DAY) <= CURDATE()
  1353. $remindList=$remind->find(array('where' => "staffID = '".$sid."' and status=0 ",'asc'=>'date_add(time, INTERVAL day DAY)','asArray' => TRUE));
  1354. $rc=0;
  1355. foreach ($remindList as $key=>$value){
  1356. $a=strtotime($value['time']." +".$value['day']." days");
  1357. $b=strtotime(date('y-m-d'));
  1358. if ($a<=$b){
  1359. $rc++;
  1360. $remindList[$key]['isRemind']=1;
  1361. }else
  1362. $remindList[$key]['isRemind']=0;
  1363. //$remindList[$key]['clientInfo']=$client->getOne(array('where' => "cid = '".$value["clientID"]."'",'asArray' => TRUE));
  1364. $remindList[$key]['Ctime']=date('m-d',strtotime($value['time']));
  1365. $remindList[$key]['Etime']=date('m-d',strtotime($value['time']." +".$value['day']." days"));
  1366. }
  1367. echo json_encode(array('status'=>1,'remindList'=>$remindList,'remindCount'=>$rc,'msg'=>''));die;
  1368. }
  1369. function remindCLHttp(){
  1370. $rid=$this->get_args('rid')&&is_numeric($this->get_args('rid'))?$this->get_args('rid'):0;
  1371. if (!empty($rid)){
  1372. Doo::loadModel('remind');
  1373. $remind=new remind();
  1374. Doo::loadClass ( 'XDeode' );
  1375. $XDeode = new XDeode ( 5 );
  1376. $sid = $XDeode->decode ( $_COOKIE ["staff"] );
  1377. $remind->status=1;
  1378. $remind->update(array('where' => "staffID = '".$sid."' and rid=".$rid,'asArray' => TRUE));
  1379. echo json_encode(array('status'=>1,'msg'=>''));die;
  1380. }
  1381. echo json_encode(array('status'=>2,'msg'=>''));die;
  1382. }
  1383. /**
  1384. * 获取get或者POST值
  1385. * @param string $name 属性名称
  1386. * @return fixed 值
  1387. */
  1388. function get_args($name) {
  1389. if (isset ( $_GET [$name] )) {
  1390. if (is_array ( $_GET [$name] ))
  1391. return $_GET [$name];
  1392. else {
  1393. return addslashes ( $_GET [$name] );
  1394. //return $_GET [$name] ;
  1395. }
  1396. } elseif (isset ( $_POST [$name] )) {
  1397. if (is_array ( $_POST [$name] ))
  1398. return $_POST [$name];
  1399. else {
  1400. return addslashes ( $_POST [$name] );
  1401. //return $_POST [$name];
  1402. }
  1403. } else {
  1404. return false;
  1405. }
  1406. }
  1407. /**
  1408. * 获取总页数
  1409. * @param unknown_type $table
  1410. * @param unknown_type $condition
  1411. */
  1412. public function getTableCount($table = "", $condition = "",$staffid="",$search,$tooltip,$cateid) {
  1413. if (!empty($staffid)){
  1414. //$staffid="and a.sid= '".$staffid."'"; " . $table . " as a left join on (a.cid=b.cid ".$staffid.")
  1415. $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 ;
  1416. }else{
  1417. if(strlen($condition)==1||empty($condition))
  1418. $sql = "select count(*) as count from CLD_client as a ".$condition;
  1419. else
  1420. $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;
  1421. }
  1422. if(!empty($search))
  1423. $sql = "select count(*) as count from CLD_client as a where 1 ".$condition ;
  1424. if(!empty($tooltip)){
  1425. $condition=str_replace("a.","c.",$condition);
  1426. $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 ;
  1427. }
  1428. //echo $sql;
  1429. $query = Doo::db ()->query ( $sql );
  1430. $result = $query->fetch ();
  1431. return $result ['count'];
  1432. }
  1433. /*
  1434. * 生成WSDL文件
  1435. */
  1436. function interfaceDetail(){
  1437. Doo::loadClass("MobileApi/Service");
  1438. }
  1439. function login($user,$pw){
  1440. Doo::loadModel ( 'staff' );
  1441. $staff = new staff ();
  1442. if(!empty($pw)){
  1443. $userinfo=$staff->checkUser($user,$pw);
  1444. if(!empty($userinfo)){
  1445. setcookie("staff", $userinfo[0]['sid'], time()+36000,"/");
  1446. return array('status'=>1,'msg'=>'登陆成功','userList'=>$userinfo);
  1447. }else
  1448. return array('status'=>2,'msg'=>'账号或密码不正确2','userList'=>array());
  1449. }else
  1450. return array('status'=>2,'msg'=>'账号或密码不正确3','userList'=>array());
  1451. }
  1452. function register($username, $gameid, $fromurl, $advertiser, $adfrom, $pagetype, $pagename, $tgid, $ip, $registertime) {
  1453. $param = array(
  1454. 'tg_account' => $username,
  1455. 'tg_gameID' => $gameid,
  1456. 'tg_advertiser' => $fromurl,
  1457. 'tg_adFrom'=>$advertiser,
  1458. 'tg_pageParam' => $adfrom,
  1459. 'tg_adType' => $pagetype,
  1460. 'tg_adsID' => $tgid,
  1461. 'tg_ip' => $tgid,
  1462. 'tg_registerTime' => $registertime
  1463. );
  1464. return $param;
  1465. }
  1466. public function service(){
  1467. ini_set("soap.wsdl_cache_enabled", "0");
  1468. $server = new SoapServer('protected/class/MobileApi/interfaceDetail.wsdl', array('soap_version' => SOAP_1_2));
  1469. $server->setClass("MobileController");
  1470. $server->addFunction(array('login','register'));
  1471. $server->addFunction(SOAP_FUNCTIONS_ALL);
  1472. $server->handle();
  1473. }
  1474. }
  1475. ?>