MobileController.php 57 KB

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