MobileController.php 57 KB

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