MobileController.php 61 KB

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