MobileController.php 56 KB

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