MobileController.php 52 KB

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