MobileController.php 80 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543
  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 (
  15. 'status' => 3,
  16. 'msg' => '请登录'
  17. ) );
  18. die ();
  19. }
  20. } else {
  21. setcookie ( "staff", '', time () + 36000, "/" );
  22. echo json_encode ( array (
  23. 'status' => 3,
  24. 'msg' => '请登录'
  25. ) );
  26. die ();
  27. }
  28. }
  29. }
  30. function loginHttp() {
  31. $pw2 = $pw = $this->get_args ( 'pw' ) ? $this->get_args ( 'pw' ) : "";
  32. $user = $this->get_args ( 'user' ) ? $this->get_args ( 'user' ) : "";
  33. // $t = $this->get_args('t') ? $this->get_args('t') : 0;
  34. Doo::loadModel ( 'staff' );
  35. Doo::loadModel ( 'tag' );
  36. $tag = new tag ();
  37. $staff = new staff ();
  38. Doo::loadClass ( 'XDeode' );
  39. $XDeode = new XDeode ( 5 );
  40. if (! empty ( $pw )) {
  41. if (isset ( $_COOKIE ['staff'] )) // $this->authcode(,'DECODE',$this->key)
  42. $pw2 = base64_decode ( $pw );
  43. $userinfo = $staff->checkUser ( $user, $pw2 );
  44. if (! empty ( $userinfo )) { // $pw;$this->authcode(,'',$this->key)
  45. // get user tag
  46. $tagList = $tag->find ( array (
  47. 'where' => 'sid=' . $userinfo [0] ['sid'],
  48. 'asArray' => true
  49. ) );
  50. $userinfo [0] ['passwork'] = base64_encode ( $pw2 );
  51. setcookie ( "staff", $XDeode->encode ( $userinfo [0] ['sid'] ), time () + 36000, "/" );
  52. $a = filemtime ( DOO::conf ()->SITE_PATH . $userinfo [0] ['avatar'] . "_2.jpg" );
  53. $userinfo [0] ['avatarUpdateTime'] = $a;
  54. // if ($t){
  55. $staff->appDate = date ( 'Y-m-d H:i' );
  56. $staff->update ( array (
  57. 'where' => 'sid=' . $userinfo [0] ['sid']
  58. ) );
  59. // }
  60. echo json_encode ( array (
  61. 'status' => 1,
  62. 'msg' => '登陆成功',
  63. 'userList' => $userinfo,
  64. 'tagList' => $tagList
  65. ) );
  66. } else {
  67. if (isset ( $_COOKIE ['staff'] ))
  68. $userinfo = $staff->checkUser ( $user, $pw );
  69. if (! empty ( $userinfo )) { // $pw;$this->authcode(,'',$this->key)
  70. // get user tag
  71. $tagList = $tag->find ( array (
  72. 'where' => 'sid=' . $userinfo [0] ['sid'],
  73. 'asArray' => true
  74. ) );
  75. $userinfo [0] ['passwork'] = base64_encode ( $pw );
  76. $a =0;
  77. if(file_exists(DOO::conf ()->SITE_PATH . $userinfo [0] ['avatar'] . "_2.jpg"))
  78. $a = filemtime ( DOO::conf ()->SITE_PATH . $userinfo [0] ['avatar'] . "_2.jpg" );
  79. $userinfo [0] ['avatarUpdateTime'] = $a;
  80. // if ($t){
  81. $staff->appDate = date ( 'Y-m-d H:i' );
  82. $staff->update ( array (
  83. 'where' => 'sid=' . $userinfo [0] ['sid']
  84. ) );
  85. // }
  86. echo json_encode ( array (
  87. 'status' => 1,
  88. 'msg' => '登陆成功C',
  89. 'userList' => $userinfo,
  90. 'tagList' => $tagList
  91. ) );
  92. } else
  93. echo json_encode ( array (
  94. 'status' => 2,
  95. 'msg' => '账号或密码不正确',
  96. 'userList' => array ()
  97. ) );
  98. }
  99. } else
  100. echo json_encode ( array (
  101. 'status' => 2,
  102. 'msg' => '账号或密码不正确',
  103. 'userList' => array ()
  104. ) );
  105. }
  106. function outHttp() {
  107. setcookie ( "staff", '', time () + 36000, "/" );
  108. echo json_encode ( array (
  109. 'status' => 1,
  110. 'msg' => '退出成功'
  111. ) );
  112. }
  113. function searchHttp() {
  114. $search = $pw = $this->get_args ( 'search' ) ? $this->get_args ( 'search' ) : "";
  115. $page = $this->get_args ( 'page' ) && is_numeric ( $this->get_args ( 'page' ) ) ? $this->get_args ( 'page' ) : 1;
  116. $size = $this->get_args ( 'size' ) && is_numeric ( $this->get_args ( 'size' ) ) ? $this->get_args ( 'size' ) : 10;
  117. Doo::loadModel ( 'client' );
  118. $client = new client ();
  119. Doo::loadModel ( 'staff' );
  120. Doo::loadModel ( 'tag_client' );
  121. Doo::loadModel ( 'C_tooltip' );
  122. Doo::loadModel ( 'tag' );
  123. $tagObj = new tag ();
  124. $cTooltip = new C_tooltip ();
  125. $tagClient = new tag_client ();
  126. $staff = new staff ();
  127. Doo::loadClass ( 'XDeode' );
  128. $XDeode = new XDeode ( 5 );
  129. $sid = $XDeode->decode ( $_COOKIE ["staff"] );
  130. $staffDetail = $staff->getOne ( array (
  131. 'where' => 'sid=' . $sid,
  132. 'asArray' => true
  133. ) );
  134. if ($page != 1)
  135. $page = $page * $size - 1;
  136. else
  137. $page --;
  138. $ClientTagList = $tagClient->getTagClientBySid ( $sid );
  139. $toollist = $cTooltip->find ( array (
  140. 'where' => 'cateid=' . $staffDetail ["cid"],
  141. 'asArray' => true
  142. ) );
  143. $count = $client->count ( array (
  144. 'limit' => $page . ',' . $size,
  145. 'where' => " address like '%" . $search . "%' or clientname like '%" . $search . "%' or companyname like '%" . $search . "%' or qq like '%" . $search . "%' or telephone like '%" . $search . "%' or phone like '%" . $search . "%'",
  146. 'asArray' => true
  147. ) );
  148. $list = $client->find ( array (
  149. 'limit' => $page . ',' . $size,
  150. 'where' => " address like '%" . $search . "%' or clientname like '%" . $search . "%' or companyname like '%" . $search . "%' or qq like '%" . $search . "%' or telephone like '%" . $search . "%' or phone like '%" . $search . "%'",
  151. 'asArray' => true
  152. ) );
  153. foreach ( $ClientTagList as $key => $value ) {
  154. $ClientTagList [$key] ['taginfo'] = $tagObj->getTagByTidL ( $value ['tag'] );
  155. }
  156. foreach ( $list as $key => $value ) {
  157. if (! empty ( $value ['cid'] )) {
  158. $list [$key] ['taginfo'] = array ();
  159. $list [$key] ['tag'] = "";
  160. foreach ( $ClientTagList as $k => $v ) {
  161. if ($value ['cid'] == $v ['client']) {
  162. $list [$key] ['taginfo'] = $v ['taginfo'];
  163. $list [$key] ['tag'] = $v ['tag'];
  164. }
  165. }
  166. }
  167. $list [$key] ['tooltipList'] = array ();
  168. foreach ( $toollist as $k => $v ) {
  169. if ($v ['cid'] == $value ['cid']) {
  170. $list [$key] ['tooltipList'] = explode ( ",", $v ['name'] );
  171. break;
  172. } // array_pop 可以优化数组
  173. }
  174. }
  175. echo json_encode ( array (
  176. 'status' => 1,
  177. 'clientList' => $list,
  178. 'count' => $count
  179. ) );
  180. }
  181. function districtHttp() {
  182. $did = $this->get_args ( 'did' ) && is_numeric ( $this->get_args ( 'did' ) ) ? $this->get_args ( 'did' ) : 0;
  183. Doo::loadModel ( 'district' );
  184. Doo::loadModel ( 'staff' );
  185. $staff = new staff ();
  186. $district = new district ();
  187. Doo::loadClass ( 'XDeode' );
  188. $XDeode = new XDeode ( 5 );
  189. // if (!is_numeric($_COOKIE ["staff"]))
  190. $sid = $XDeode->decode ( $_COOKIE ["staff"] );
  191. $staffDetail = $staff->getOne ( array (
  192. 'where' => 'sid=' . $sid,
  193. 'asArray' => true
  194. ) );
  195. if ($did == 0) {
  196. //if ($staffDetail ['isadmin'])
  197. $districtList = $district->get_lvByid ( 0, $did );
  198. //else
  199. // $districtList = $district->get_lvByStaffid ( 1, $sid );
  200. } else {
  201. $districtList = $district->get_lvByid ( 0, $did );
  202. }
  203. echo json_encode ( array (
  204. 'msg' => '',
  205. 'districtList' => $districtList
  206. ) );
  207. }
  208. function clientDetailHttp() {
  209. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  210. if ($cid != 0) {
  211. Doo::loadModel ( 'client' );
  212. Doo::loadModel ( 'company' );
  213. Doo::loadModel ( 'service_log' );
  214. Doo::loadModel ( 'longle' );
  215. $longle = new longle ();
  216. $client = new client ();
  217. $company = new company ();
  218. $serviceLog = new service_log ();
  219. Doo::loadModel ( 'client_staff' );
  220. Doo::loadModel ( 'staff' );
  221. Doo::loadModel ( 'tag_client' );
  222. Doo::loadModel ( 'C_tooltip' );
  223. Doo::loadModel ( 'tag' );
  224. $tagObj = new tag ();
  225. $cTooltip = new C_tooltip ();
  226. $tagClient = new tag_client ();
  227. $staff = new staff ();
  228. $client_staff = new client_staff ();
  229. Doo::loadModel ( 'tagCompany' );
  230. $tagCompany = new tagCompany ();
  231. Doo::loadModel ( 'tagCompanyNexus' );
  232. $tagCompanyNexus = new tagCompanyNexus ();
  233. Doo::loadClass ( 'XDeode' );
  234. $XDeode = new XDeode ( 5 );
  235. if (! isset ( $_COOKIE ["staff"] )) {
  236. $sid = 0;
  237. } else {
  238. $sid = $XDeode->decode ( $_COOKIE ["staff"] );
  239. }
  240. $clientList = $client->getOne ( array (
  241. 'where' => 'cid=' . $cid,
  242. 'asArray' => true
  243. ) );
  244. $companyList = $longleList = $colleague = $serviceLogList = array ();
  245. $clientCount = array ();
  246. if (! empty ( $clientList )) {
  247. $companyList = $company->getOne ( array (
  248. 'where' => 'cid=' . $clientList ['companyid'],
  249. 'asArray' => true
  250. ) );
  251. $serviceLogList = $serviceLog->find ( array (
  252. 'where' => 'clientid=' . $cid,
  253. 'desc' => 'date',
  254. 'asArray' => true
  255. ) );
  256. $clientCount = $client->count ( array (
  257. 'where' => 'companyid=' . $clientList ['companyid'],
  258. 'asArray' => true
  259. ) );
  260. $longleList = $longle->find ( array (
  261. 'where' => 'clientid=' . $cid,
  262. 'asArray' => true
  263. ) );
  264. $colleague = $client->find ( array (
  265. 'where' => 'companyid=' . $clientList ['companyid'] . ' and cid!=' . $cid,
  266. 'asArray' => true
  267. ) );
  268. }
  269. $staffDetail = $staff->getOne ( array (
  270. 'where' => 'sid=' . $sid,
  271. 'asArray' => true
  272. ) );
  273. $ClientTagList = $tagClient->getTagClientBySid ( $sid );
  274. $toollist = array ();
  275. if (! empty ( $staffDetail ))
  276. $toollist = $cTooltip->find ( array (
  277. 'where' => 'cateid=' . $staffDetail ["cid"],
  278. 'asArray' => true
  279. ) );
  280. $companyTagL = $tagCompany->find ( array (
  281. 'where' => 'sid=' . $sid,
  282. 'asArray' => true
  283. ) );
  284. $CompanyTagList = $tagCompanyNexus->getTagClientBySid ( $sid );
  285. foreach ( $CompanyTagList as $key => $value ) {
  286. $CompanyTagList [$key] ['taginfo'] = $tagCompany->getTagByTidL ( $value ['tag'] );
  287. }
  288. if (! empty ( $companyList ['cid'] )) {
  289. $companyList ['taginfo'] = array ();
  290. $companyList ['tag'] = "";
  291. foreach ( $CompanyTagList as $k => $v ) {
  292. if ($companyList ['cid'] == $v ['company']) {
  293. $companyList ['taginfo'] = $v ['taginfo'];
  294. $companyList ['tag'] = $v ['tag'];
  295. }
  296. }
  297. }
  298. foreach ( $ClientTagList as $key => $value ) {
  299. $ClientTagList [$key] ['taginfo'] = $tagObj->getTagByTidL ( $value ['tag'] );
  300. }
  301. if (! empty ( $clientList ['cid'] )) {
  302. $clientList ['taginfo'] = array ();
  303. $clientList ['tag'] = "";
  304. foreach ( $ClientTagList as $k => $v ) {
  305. if ($clientList ['cid'] == $v ['client']) {
  306. $clientList ['taginfo'] = $v ['taginfo'];
  307. $clientList ['tag'] = $v ['tag'];
  308. }
  309. }
  310. }
  311. // $list[$key]['tooltipList']=array();
  312. foreach ( $toollist as $k => $v ) {
  313. if ($v ['cid'] == $clientList ['cid']) {
  314. $clientList ['tooltipList'] = explode ( ",", $v ['name'] );
  315. break;
  316. } // array_pop 可以优化数组
  317. }
  318. foreach ( $colleague as $key => $value ) {
  319. if (! empty ( $value ['cid'] )) {
  320. $colleague [$key] ['taginfo'] = array ();
  321. $colleague [$key] ['tag'] = "";
  322. foreach ( $ClientTagList as $k => $v ) {
  323. if ($value ['cid'] == $v ['client']) {
  324. $colleague [$key] ['taginfo'] = $v ['taginfo'];
  325. $colleague [$key] ['tag'] = $v ['tag'];
  326. }
  327. }
  328. }
  329. $colleague [$key] ['tooltipList'] = array ();
  330. foreach ( $toollist as $k => $v ) {
  331. if ($v ['cid'] == $value ['cid']) {
  332. $colleague [$key] ['tooltipList'] = explode ( ",", $v ['name'] );
  333. break;
  334. } // array_pop 可以优化数组
  335. }
  336. }
  337. $companyList ['clientCount'] = $clientCount;
  338. echo json_encode ( array (
  339. 'status' => 1,
  340. 'clientList' => $clientList,
  341. 'colleague' => $colleague,
  342. 'companyList' => $companyList,
  343. 'companyTag' => $companyTagL,
  344. 'serviceLogList' => $serviceLogList,
  345. 'longleList' => $longleList,
  346. 'msg' => ''
  347. ) );
  348. die ();
  349. }
  350. echo json_encode ( array (
  351. 'status' => 2,
  352. 'clientList' => array (),
  353. 'companyList' => array (),
  354. 'serviceLogList' => array (),
  355. 'msg' => "请输入正确的请求路径"
  356. ) );
  357. }
  358. function advancedSearchHttp() {
  359. $lv1 = $this->get_args ( 'lv1' ) && is_numeric ( $this->get_args ( 'lv1' ) ) ? $this->get_args ( 'lv1' ) : "";
  360. $lv2 = $this->get_args ( 'lv2' ) && is_numeric ( $this->get_args ( 'lv2' ) ) ? $this->get_args ( 'lv2' ) : "";
  361. $lv3 = $this->get_args ( 'lv3' ) && is_numeric ( $this->get_args ( 'lv3' ) ) ? $this->get_args ( 'lv3' ) : "";
  362. $tag = $this->get_args ( 'tag' ) ? $this->get_args ( 'tag' ) : "";
  363. $teamTag = $this->get_args ( 'teamTag' ) ? $this->get_args ( 'teamTag' ) : "";
  364. $page = $this->get_args ( 'page' ) && is_numeric ( $this->get_args ( 'page' ) ) ? $this->get_args ( 'page' ) : 1;
  365. $size = $this->get_args ( 'size' ) && is_numeric ( $this->get_args ( 'size' ) ) ? $this->get_args ( 'size' ) : 10;
  366. Doo::loadModel ( 'client_staff' );
  367. Doo::loadModel ( 'staff' );
  368. Doo::loadModel ( 'tag_client' );
  369. Doo::loadModel ( 'C_tooltip' );
  370. Doo::loadModel ( 'tag' );
  371. $tagObj = new tag ();
  372. $cTooltip = new C_tooltip ();
  373. $tagClient = new tag_client ();
  374. $staff = new staff ();
  375. $client_staff = new client_staff ();
  376. Doo::loadClass ( 'XDeode' );
  377. $XDeode = new XDeode ( 5 );
  378. // if (!is_numeric($_COOKIE ["staff"]))
  379. $sid = $XDeode->decode ( $_COOKIE ["staff"] );
  380. $staffDetail = $staff->getOne ( array (
  381. 'where' => 'sid=' . $sid,
  382. 'asArray' => true
  383. ) );
  384. if (empty ( $staffDetail )) {
  385. echo json_encode ( array (
  386. 'status' => 1,
  387. 'clientList' => array (),
  388. 'count' => 0,
  389. 'msg' => ''
  390. ) );
  391. die ();
  392. }
  393. $condition = "";
  394. if (! empty ( $lv1 ))
  395. $condition .= " and district like '" . $lv1 . ",%'";
  396. if (! empty ( $lv2 ))
  397. $condition .= " and district like '" . $lv1 . "," . $lv2 . ",%'";
  398. if (! empty ( $lv3 ))
  399. $condition .= " and district like '" . $lv1 . "," . $lv2 . "," . $lv3 . "'";
  400. if (! empty ( $tag )) {
  401. $tagList = explode ( "@", $tag );
  402. foreach ( $tagList as $value ) {
  403. $condition .= " and c.tag like '%" . $value . "%' ";
  404. }
  405. }
  406. if ($page != 1)
  407. $page = $page * $size - 1;
  408. else
  409. $page --;
  410. $limit = " limit " . $page . " , " . $size . " ";
  411. // 获得标签
  412. $ClientTagList = $tagClient->getTagClientBySid ( $sid );
  413. $toollist = $cTooltip->find ( array (
  414. 'where' => 'cateid=' . $staffDetail ["cid"],
  415. 'asArray' => true
  416. ) );
  417. $count = $this->getTableCount ( "CLD_client_staff", $condition, $staffDetail ["sid"], "", $teamTag, $staffDetail ['cid'] );
  418. $clientList = $client_staff->getClientByStaff ( $condition, $limit, $staffDetail ["sid"], $staffDetail ["sid"], "", $teamTag, $staffDetail ['cid'] );
  419. foreach ( $ClientTagList as $key => $value ) {
  420. $ClientTagList [$key] ['taginfo'] = $tagObj->getTagByTidL ( $value ['tag'] );
  421. }
  422. foreach ( $clientList as $key => $value ) {
  423. if (! empty ( $value ['cid'] )) {
  424. $clientList [$key] ['taginfo'] = array ();
  425. $clientList [$key] ['tag'] = "";
  426. foreach ( $ClientTagList as $k => $v ) {
  427. if ($value ['cid'] == $v ['client']) {
  428. $clientList [$key] ['taginfo'] = $v ['taginfo'];
  429. $clientList [$key] ['tag'] = $v ['tag'];
  430. }
  431. }
  432. }
  433. $clientList [$key] ['tooltipList'] = array ();
  434. foreach ( $toollist as $k => $v ) {
  435. if ($v ['cid'] == $value ['cid']) {
  436. $clientList [$key] ['tooltipList'] = explode ( ",", $v ['name'] );
  437. break;
  438. } // array_pop 可以优化数组
  439. }
  440. $clientList [$key] ['locount'] = 0;
  441. }
  442. echo json_encode ( array (
  443. 'status' => 1,
  444. 'clientList' => $clientList,
  445. 'count' => $count,
  446. 'msg' => ''
  447. ) );
  448. }
  449. function lockNoHttp() {
  450. $lockNo = $this->get_args ( 'lockNo' ) ? $this->get_args ( 'lockNo' ) : "";
  451. $page = $this->get_args ( 'page' ) && is_numeric ( $this->get_args ( 'page' ) ) ? $this->get_args ( 'page' ) : 1;
  452. $size = $this->get_args ( 'size' ) && is_numeric ( $this->get_args ( 'size' ) ) ? $this->get_args ( 'size' ) : 10;
  453. if (! empty ( $lockNo )) {
  454. // Doo::loadModel("service_log");
  455. // $service_log = new service_log ();
  456. Doo::loadModel ( "longle" );
  457. $longle = new longle ();
  458. if ($page != 1)
  459. $page = $page * $size - 1;
  460. else
  461. $page --;
  462. $count = $longle->count ( array (
  463. 'limit' => $page . ',' . $size,
  464. 'where' => " key_num like '%" . $lockNo . "%' ",
  465. 'asArray' => true
  466. ) );
  467. $lockList = $longle->find ( array (
  468. 'limit' => $page . ',' . $size,
  469. 'where' => " key_num like '%" . $lockNo . "%' ",
  470. 'asArray' => true
  471. ) );
  472. echo json_encode ( array (
  473. 'status' => 1,
  474. 'lockList' => $lockList,
  475. 'count' => $count,
  476. 'msg' => ''
  477. ) );
  478. die ();
  479. }
  480. echo json_encode ( array (
  481. 'status' => 1,
  482. 'lockList' => array (),
  483. 'count' => 0,
  484. 'msg' => ''
  485. ) );
  486. }
  487. function lockJournalHttp() {
  488. $lid = $this->get_args ( 'lid' ) && is_numeric ( $this->get_args ( 'lid' ) ) ? $this->get_args ( 'lid' ) : 0;
  489. if (! empty ( $lid )) {
  490. Doo::loadModel ( "longle_log" );
  491. $longleLog = new longle_log ();
  492. $longleLogList = $longleLog->find ( array (
  493. 'where' => 'lid=' . $lid,
  494. 'asArray' => true
  495. ) );
  496. echo json_encode ( array (
  497. 'status' => 1,
  498. 'JournalList' => $longleLogList,
  499. 'msg' => ''
  500. ) );
  501. die ();
  502. }
  503. echo json_encode ( array (
  504. 'status' => 1,
  505. 'JournalList' => array (),
  506. 'msg' => ''
  507. ) );
  508. }
  509. function districtDetailHttp() {
  510. $dStr = $this->get_args ( 'dStr' ) ? $this->get_args ( 'dStr' ) : "";
  511. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  512. if (! empty ( $dStr )) {
  513. Doo::loadModel ( 'district' );
  514. Doo::loadModel ( 'client' );
  515. $district = new district ();
  516. $client = new client ();
  517. $districtList = $district->find ( array (
  518. 'where' => 'id in(' . $dStr . ')',
  519. 'asArray' => true
  520. ) );
  521. $jsonString = array ();
  522. foreach ( $districtList as $value ) {
  523. array_push ( $jsonString, $value ['name'] );
  524. }
  525. $jsonString = implode ( ",", $jsonString );
  526. if (! empty ( $jsonString ) && ! empty ( $cid )) {
  527. $client->cid = $cid;
  528. $client->local = $jsonString;
  529. $client->update ();
  530. }
  531. echo json_encode ( array (
  532. 'status' => 1,
  533. 'districtList' => $jsonString,
  534. 'msg' => ''
  535. ) );
  536. die ();
  537. }
  538. }
  539. function clientInfoHttp() {
  540. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  541. $clientname = $this->get_args ( 'clientname' ) ? $this->get_args ( 'clientname' ) : "";
  542. $gender = $this->get_args ( 'gender' ) ? $this->get_args ( 'gender' ) : "";
  543. $nicename = $this->get_args ( 'nicename' ) ? $this->get_args ( 'nicename' ) : "";
  544. $telephone = $this->get_args ( 'telephone' ) ? $this->get_args ( 'telephone' ) : "";
  545. $phone = $this->get_args ( 'phone' ) ? $this->get_args ( 'phone' ) : "";
  546. $email = $this->get_args ( 'email' ) ? $this->get_args ( 'email' ) : "";
  547. $unit = $this->get_args ( 'unit' ) ? $this->get_args ( 'unit' ) : "";
  548. $fax = $this->get_args ( 'fax' ) ? $this->get_args ( 'fax' ) : "";
  549. $webservice = $this->get_args ( 'webservice' ) ? $this->get_args ( 'webservice' ) : "";
  550. $department = $this->get_args ( 'department' ) ? $this->get_args ( 'department' ) : "";
  551. $position = $this->get_args ( 'position' ) ? $this->get_args ( 'position' ) : "";
  552. $office = $this->get_args ( 'office' ) ? $this->get_args ( 'office' ) : "";
  553. $address = $this->get_args ( 'address' ) ? $this->get_args ( 'address' ) : "";
  554. $ride = $this->get_args ( 'ride' ) ? $this->get_args ( 'ride' ) : "";
  555. $landmarks = $this->get_args ( 'landmarks' ) ? $this->get_args ( 'landmarks' ) : "";
  556. $qq = $this->get_args ( 'qq' ) ? $this->get_args ( 'qq' ) : "";
  557. $priority = $this->get_args ( 'priority' ) ? $this->get_args ( 'priority' ) : 5;
  558. $stay = $this->get_args ( 'stay' ) ? $this->get_args ( 'stay' ) : "";
  559. $mark = $this->get_args ( 'mark' ) ? $this->get_args ( 'mark' ) : "";
  560. $lv21 = $this->get_args ( 'lv21' ) ? $this->get_args ( 'lv21' ) : 0;
  561. $lv22 = $this->get_args ( 'lv22' ) ? $this->get_args ( 'lv22' ) : 0;
  562. $lv23 = $this->get_args ( 'lv23' ) ? $this->get_args ( 'lv23' ) : 0;
  563. if (! empty ( $cid ) && ! empty ( $clientname )) {
  564. Doo::loadModel ( 'client' );
  565. Doo::loadModel ( 'district' );
  566. $district = new district ();
  567. $client = new client ();
  568. Doo::loadModel ( 'staff' );
  569. $staff = new staff ();
  570. $client->cid = $cid;
  571. $client->clientname = $clientname;
  572. if (! empty ( $gender ))
  573. $client->gender = $gender;
  574. if (! empty ( $nicename ))
  575. $client->nicename = $nicename;
  576. if (! empty ( $telephone ))
  577. $client->telephone = $telephone;
  578. if (! empty ( $phone ))
  579. $client->phone = $phone;
  580. if (! empty ( $email ))
  581. $client->email = $email;
  582. if (! empty ( $lv21 ) && ! empty ( $lv22 ) && ! empty ( $lv23 )) {
  583. $client->district = $lv21 . "," . $lv22 . "," . $lv23;
  584. }
  585. if (! empty ( $client->district )) {
  586. $districtList = $district->find ( array (
  587. 'where' => 'id in(' . $client->district . ')',
  588. 'asArray' => true
  589. ) );
  590. $jsonString = array ();
  591. foreach ( $districtList as $value ) {
  592. array_push ( $jsonString, $value ['name'] );
  593. }
  594. $jsonString = implode ( ",", $jsonString );
  595. if (! empty ( $jsonString ))
  596. $client->local = $jsonString;
  597. }
  598. if (! empty ( $fax ))
  599. $client->fax = $fax;
  600. if (! empty ( $webservice ))
  601. $client->webservice = $webservice;
  602. if (! empty ( $department ))
  603. $client->department = $department;
  604. if (! empty ( $position ))
  605. $client->position = $position;
  606. if (! empty ( $office ))
  607. $client->office = $office;
  608. if (! empty ( $address ))
  609. $client->address = $address;
  610. if (! empty ( $ride ))
  611. $client->ride = $ride;
  612. if (! empty ( $landmarks ))
  613. $client->landmarks = $landmarks;
  614. if (! empty ( $qq ))
  615. $client->qq = $qq;
  616. if (! empty ( $stay ))
  617. $client->stay = $stay;
  618. if (! empty ( $priority ))
  619. $client->priority = $priority;
  620. if (! empty ( $mark ))
  621. $client->mark = $mark;
  622. $client->updatetime = time ();
  623. $client->update ();
  624. Doo::loadClass ( 'XDeode' );
  625. $XDeode = new XDeode ( 5 );
  626. $sid = $XDeode->decode ( $_COOKIE ["staff"] );
  627. $staffDetail = $staff->getOne ( array (
  628. 'where' => 'sid=' . $sid,
  629. 'asArray' => true
  630. ) );
  631. // 标签
  632. $tid = $this->get_args ( 'tagALD' );
  633. Doo::loadModel ( 'tag_client' );
  634. // $strtid=implode(",", $tid);
  635. $strtid = $tid;
  636. $tagClient = new tag_client ();
  637. $tagClientInfo = $tagClient->getTagClientBySCid ( $cid, $sid );
  638. // $ar=explode(",", $strtid.','.$tagClientInfo['tag']);
  639. // $re=array_filter(array_unique($ar));
  640. // $tagClient->tag=implode(",", $re);
  641. $tagClient->tag = $strtid;
  642. if (! empty ( $tagClientInfo )) {
  643. $tagClient->tcid = $tagClientInfo ['tcid'];
  644. $tagClient->update ();
  645. } else {
  646. $tagClient->sid = $sid;
  647. $tagClient->client = $cid;
  648. $tagClient->insert ();
  649. }
  650. $tid = $this->get_args ( 'tooltiplist' );
  651. // $k=implode(",", $tid);
  652. $k = $tid;
  653. Doo::loadModel ( 'C_tooltip' );
  654. $s = " and cateid=" . $staffDetail ["cid"];
  655. if (! empty ( $staffDetail ['othercid'] )) {
  656. $othercid = explode ( ",", $staffDetail ['othercid'] );
  657. foreach ( $othercid as $value ) {
  658. $s .= " or cateid=" . $value;
  659. }
  660. }
  661. // foreach ($cid as $key=>$value){
  662. $C_tooltip = new C_tooltip ();
  663. $tooltip = $C_tooltip->getOne ( array (
  664. 'where' => 'cid=' . $cid . " " . $s,
  665. 'asArray' => true
  666. ) );
  667. if (empty ( $tooltip )) {
  668. $C_tooltip->cid = $cid;
  669. $C_tooltip->name = $k;
  670. $C_tooltip->cateid = $staffDetail ['cid'];
  671. $C_tooltip->insert ();
  672. } else {
  673. $C_tooltip->tip = $tooltip ['tip'];
  674. $C_tooltip->name = $k;
  675. $C_tooltip->update ();
  676. }
  677. // }
  678. $clientInfo = $client->getOne ( array (
  679. 'where' => ' cid=' . $cid,
  680. 'asArray' => true
  681. ) );
  682. // 日常行为
  683. Doo::loadModel ( "action_log" );
  684. $action_log = new action_log ();
  685. $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'] . ')';
  686. $action_log->updatetime = date ( "Y-m-d" );
  687. $action_log->sid = $staffDetail ['sid'];
  688. $action_log->cid = $staffDetail ['cid'];
  689. $action_log->status = 2;
  690. $action_log->time = date ( "H:i" );
  691. $action_log->class = $action_log->iconContacts;
  692. $action_log->districtid = $clientInfo ['district'];
  693. $local = $district->getbyidlist ( $clientInfo ['district'] );
  694. $action_log->city = $local [0] ['name'];
  695. $action_log->province = $local [1] ['name'];
  696. $action_log->company = $clientInfo ['companyname'];
  697. Doo::loadModel ( 'company' );
  698. $company = new company ();
  699. $companyInfo = $company->getOne ( array (
  700. 'where' => ' companyname="' . $clientInfo ['companyname'] . '"',
  701. 'asArray' => true
  702. ) );
  703. $nature = explode ( ',', $companyInfo ['nature'] );
  704. $action_log->nature = $nature [0];
  705. $action_log->insert ();
  706. echo json_encode ( array (
  707. 'status' => 1,
  708. 'msg' => ''
  709. ) );
  710. die ();
  711. } else
  712. echo json_encode ( array (
  713. 'status' => 2,
  714. 'msg' => ''
  715. ) );
  716. die ();
  717. }
  718. function serviceLogHttp() {
  719. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : "";
  720. $clientid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : "";
  721. $mark = $this->get_args ( 'mark' ) ? $this->get_args ( 'mark' ) : "";
  722. $m = $this->get_args ( 'm' ) ? $this->get_args ( 'm' ) : "";
  723. $d = $this->get_args ( 'd' ) ? $this->get_args ( 'd' ) : "";
  724. $y = $this->get_args ( 'y' ) ? $this->get_args ( 'y' ) : date ( "Y" );
  725. $Remind = isset ( $_POST ['Remind'] ) ? $_POST ['Remind'] : 0;
  726. $time = isset ( $_POST ['time'] ) ? $_POST ['time'] : 0;
  727. $remark = isset ( $_POST ['remark'] ) ? $_POST ['remark'] : "";
  728. // echo $mark;die;
  729. if (! empty ( $status ) && ! empty ( $clientid )) {
  730. Doo::loadModel ( 'service_log' );
  731. Doo::loadModel ( 'client_staff' );
  732. $clientStaff = new client_staff ();
  733. $service_log = new service_log ();
  734. Doo::loadModel ( "action_log" );
  735. $action_log = new action_log ();
  736. Doo::loadModel ( "client" );
  737. $client = new client ();
  738. Doo::loadModel ( 'staff' );
  739. $staff = new staff ();
  740. Doo::loadClass ( 'XDeode' );
  741. $XDeode = new XDeode ( 5 );
  742. $sid = $XDeode->decode ( $_COOKIE ["staff"] );
  743. $staffDetail = $staff->getOne ( array (
  744. 'where' => 'sid=' . $sid,
  745. 'asArray' => true
  746. ) );
  747. $service_log->status = $status;
  748. $service_log->clientid = $clientid;
  749. $service_log->mark = htmlspecialchars ( $mark );
  750. $service_log->date = $y . "-" . $m . "-" . $d;
  751. $service_log->category = $staffDetail ['category'];
  752. $service_log->staffname = $staffDetail ['username'];
  753. $service_log->staffid = $staffDetail ['sid'];
  754. $service_log->insert ();
  755. // 日常行为
  756. // 记录服务时间
  757. $client->cid = $clientid;
  758. $client->servicetime = time ();
  759. $client->update ();
  760. $clientInfo = $client->getOne ( array (
  761. 'where' => ' cid=' . $clientid,
  762. 'asArray' => TRUE
  763. ) );
  764. $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'] . ')添加新客户记录。';
  765. $action_log->updatetime = date ( "Y-m-d" );
  766. $action_log->sid = $staffDetail ['sid'];
  767. $action_log->cid = $staffDetail ['cid'];
  768. $action_log->time = date ( "H:i" );
  769. $action_log->status = 3;
  770. $action_log->districtid = $clientInfo ['district'];
  771. Doo::loadModel ( 'district' );
  772. $district = new district ();
  773. $local = $district->getbyidlist ( $clientInfo ['district'] );
  774. $action_log->city = $local [0] ['name'];
  775. $action_log->province = $local [1] ['name'];
  776. $action_log->company = $clientInfo ['companyname'];
  777. Doo::loadModel ( 'company' );
  778. $company = new company ();
  779. $companyInfo = $company->getOne ( array (
  780. 'where' => ' companyname="' . $clientInfo ['companyname'] . '"',
  781. 'asArray' => true
  782. ) );
  783. $nature = explode ( ',', $companyInfo ['nature'] );
  784. $action_log->nature = $nature [0];
  785. $action_log->class = $action_log->iconContacts;
  786. $action_log->insert ();
  787. // 更新信息中心服务日志统计数量
  788. $redis = new Redis ();
  789. $redis->connect ( '127.0.0.1', '6379' );
  790. $categoryCondition = " and cid=" . $staffDetail ['cid'];
  791. $sidCondition = " and sid=" . $staffDetail ['sid'];
  792. // actionlog免查询值 $alCondition='';
  793. $alCondition = ' aid>' . REMIT . ' and ';
  794. // 个人服务日志数量redis值
  795. $redisKeyCS = date ( 'Y-m-d' ) . 'SL_' . $staffDetail ['cid'] . '_' . $staffDetail ['sid'];
  796. $action_log = new action_log ();
  797. $actionLogLongle = $action_log->find ( array (
  798. 'select' => 'date_format(updatetime,"%m-%d") as updatetime,COUNT(*) as count',
  799. 'where' => $alCondition . " status=3 " . $categoryCondition . $sidCondition . " and date_sub(curdate(), INTERVAL 30 DAY) <= date(updatetime) ",
  800. 'groupby' => 'date_format(updatetime,"%m-%d")',
  801. 'asArray' => true
  802. ) );
  803. $statisticsLongle = array ();
  804. for($d = 0; $d <= 29; $d ++) {
  805. $MD = date ( "m-d", strtotime ( "-" . $d . " day" ) );
  806. $falgLongle = true;
  807. foreach ( $actionLogLongle as $value ) {
  808. if ($value ['updatetime'] == $MD) {
  809. array_push ( $statisticsLongle, $value ['count'] );
  810. $falgLongle = false;
  811. break;
  812. }
  813. }
  814. if ($falgLongle)
  815. array_push ( $statisticsLongle, 0 );
  816. }
  817. $statisticsLongle = array_reverse ( $statisticsLongle );
  818. $jsl = json_encode ( $statisticsLongle );
  819. $redis->set ( $redisKeyCS, $jsl );
  820. // 办事处服务日志数量reids值
  821. $redisKeyC = date ( 'Y-m-d' ) . 'SL_' . $staffDetail ['cid'] . '_';
  822. $action_log = new action_log ();
  823. $actionLogLongle = $action_log->find ( array (
  824. 'select' => 'date_format(updatetime,"%m-%d") as updatetime,COUNT(*) as count',
  825. 'where' => $alCondition . " status=3 " . $categoryCondition . " and date_sub(curdate(), INTERVAL 30 DAY) <= date(updatetime) ",
  826. 'groupby' => 'date_format(updatetime,"%m-%d")',
  827. 'asArray' => true
  828. ) );
  829. $statisticsLongle = array ();
  830. for($d = 0; $d <= 29; $d ++) {
  831. $MD = date ( "m-d", strtotime ( "-" . $d . " day" ) );
  832. $falgLongle = true;
  833. foreach ( $actionLogLongle as $value ) {
  834. if ($value ['updatetime'] == $MD) {
  835. array_push ( $statisticsLongle, $value ['count'] );
  836. $falgLongle = false;
  837. break;
  838. }
  839. }
  840. if ($falgLongle)
  841. array_push ( $statisticsLongle, 0 );
  842. }
  843. $statisticsLongle = array_reverse ( $statisticsLongle );
  844. $jsl = json_encode ( $statisticsLongle );
  845. $redis->set ( $redisKeyC, $jsl );
  846. // 全员处服务日志数量的redis值
  847. $redisKey = date ( 'Y-m-d' ) . 'SL__';
  848. $action_log = new action_log ();
  849. $actionLogLongle = $action_log->find ( array (
  850. 'select' => 'date_format(updatetime,"%m-%d") as updatetime,COUNT(*) as count',
  851. 'where' => $alCondition . " status=3 and date_sub(curdate(), INTERVAL 30 DAY) <= date(updatetime) ",
  852. 'groupby' => 'date_format(updatetime,"%m-%d")',
  853. 'asArray' => true
  854. ) );
  855. $statisticsLongle = array ();
  856. for($d = 0; $d <= 29; $d ++) {
  857. $MD = date ( "m-d", strtotime ( "-" . $d . " day" ) );
  858. $falgLongle = true;
  859. foreach ( $actionLogLongle as $value ) {
  860. if ($value ['updatetime'] == $MD) {
  861. array_push ( $statisticsLongle, $value ['count'] );
  862. $falgLongle = false;
  863. break;
  864. }
  865. }
  866. if ($falgLongle)
  867. array_push ( $statisticsLongle, 0 );
  868. }
  869. $statisticsLongle = array_reverse ( $statisticsLongle );
  870. $jsl = json_encode ( $statisticsLongle );
  871. $redis->set ( $redisKey, $jsl );
  872. if (! empty ( $Remind )) {
  873. Doo::loadModel ( 'remind' );
  874. $remindObj = new remind ();
  875. $datetime1 = new DateTime ( date ( 'Y-m-d' ) );
  876. $datetime2 = new DateTime ( $time );
  877. $interval = $datetime1->diff ( $datetime2 );
  878. $remindObj->day = $interval->format ( '%a' );
  879. $remindObj->remark = $remark;
  880. $remindObj->time = date ( "Y-m-d" );
  881. $remindObj->clientName = $clientInfo ['clientname'];
  882. $remindObj->clientID = $clientid;
  883. $remindObj->companyName = $clientInfo ['companyname'];
  884. $remindObj->companyID = $companyInfo ['cid'];
  885. $remindObj->staffID = $sid;
  886. if ($status == 1)
  887. $remindObj->class = "iconService";
  888. if ($status == 2)
  889. $remindObj->class = "iconPhone";
  890. if ($status == 3)
  891. $remindObj->class = "iconOther";
  892. $remindObj->insert ();
  893. }
  894. echo json_encode ( array (
  895. 'status' => 1,
  896. 'msg' => ''
  897. ) );
  898. die ();
  899. } else
  900. echo json_encode ( array (
  901. 'status' => 2,
  902. 'msg' => ''
  903. ) );
  904. die ();
  905. }
  906. function updateCompanyHttp() {
  907. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  908. $companyname = $this->get_args ( 'companyName' ) ? $this->get_args ( 'companyName' ) : "";
  909. $lv21 = $this->get_args ( 'lv21' ) ? $this->get_args ( 'lv21' ) : 0;
  910. $lv22 = $this->get_args ( 'lv22' ) ? $this->get_args ( 'lv22' ) : 0;
  911. $lv23 = $this->get_args ( 'lv23' ) ? $this->get_args ( 'lv23' ) : 0;
  912. $nature = isset ( $_POST ['nature'] ) ? $_POST ['nature'] : false;
  913. $fax = isset ( $_POST ['fax'] ) ? $_POST ['fax'] : false;
  914. $webservice = isset ( $_POST ['webservice'] ) ? $_POST ['webservice'] : false;
  915. $address = isset ( $_POST ['address'] ) ? $_POST ['address'] : false;
  916. $ride = isset ( $_POST ['ride'] ) ? $_POST ['ride'] : false;
  917. $stay = isset ( $_POST ['stay'] ) ? $_POST ['stay'] : false;
  918. $landmarks = isset ( $_POST ['landmarks'] ) ? $_POST ['landmarks'] : false;
  919. if (empty ( $cid ) || empty ( $companyname )) {
  920. echo json_encode ( array (
  921. 'status' => 2,
  922. 'msg' => ''
  923. ) );
  924. die ();
  925. }
  926. Doo::loadModel ( "company" );
  927. Doo::loadModel ( "client" );
  928. $client = new client ();
  929. $company = new company ();
  930. Doo::loadClass ( 'XDeode' );
  931. $XDeode = new XDeode ( 5 );
  932. $sid = $XDeode->decode ( $_COOKIE ["staff"] );
  933. $company->cid = $cid;
  934. if (! empty ( $lv21 ) && ! empty ( $lv22 ) && ! empty ( $lv23 )) {
  935. Doo::loadModel ( 'district' );
  936. $district = new district ();
  937. // 更新公司信息
  938. $lv1 = $district->getbyid ( $lv21 );
  939. $lv2 = $district->getbyid ( $lv22 );
  940. $lv3 = $district->getbyid ( $lv23 );
  941. $company->district = $lv21 . "," . $lv22 . "," . $lv23;
  942. $company->local = $lv1 [0] ['name'] . "," . $lv2 [0] ['name'] . "," . $lv3 [0] ['name'];
  943. }
  944. if (! empty ( $companyname )) {
  945. $company->companyname = $companyname;
  946. $client->companyname = $companyname;
  947. }
  948. if ($fax !== false)
  949. $company->fax = $fax;
  950. if ($webservice !== false) {
  951. $company->webservice = $webservice;
  952. }
  953. if ($address !== false)
  954. $company->address = $address;
  955. if ($ride !== false)
  956. $company->ride = $ride;
  957. if ($stay !== false)
  958. $company->stay = $stay;
  959. if ($landmarks !== false)
  960. $company->landmarks = $landmarks;
  961. $company->update ();
  962. $client->update ( array (
  963. 'where' => ' companyid =' . $cid
  964. ) );
  965. // 标签
  966. $tid = $this->get_args ( 'tagALD' );
  967. Doo::loadModel ( 'tagCompanyNexus' );
  968. $strtid = $tid;
  969. $tagClient = new tagCompanyNexus ();
  970. $tagClientInfo = $tagClient->getTagClientBySCid ( $cid, $sid );
  971. $tagClient->tag = $strtid;
  972. if (! empty ( $tagClientInfo )) {
  973. $tagClient->tcid = $tagClientInfo ['tcid'];
  974. $tagClient->update ();
  975. } else {
  976. $tagClient->sid = $sid;
  977. $tagClient->company = $cid;
  978. $tagClient->insert ();
  979. }
  980. echo json_encode ( array (
  981. 'status' => 1,
  982. 'msg' => ''
  983. ) );
  984. die ();
  985. }
  986. function searchCompanyHttp() {
  987. $searchDbInforItem = $this->get_args ( 'searchDbInforItem' ) ? $this->get_args ( 'searchDbInforItem' ) : "";
  988. if (! empty ( $searchDbInforItem )) {
  989. Doo::loadModel ( 'company' );
  990. $company = new company ();
  991. $clientInfo = $company->searchCompany ( $searchDbInforItem );
  992. echo json_encode ( array (
  993. 'status' => 1,
  994. 'companyList' => $clientInfo
  995. ) );
  996. die ();
  997. } else
  998. echo json_encode ( array (
  999. 'status' => 2,
  1000. 'companyList' => ''
  1001. ) );
  1002. die ();
  1003. }
  1004. function changeCompanyHttp() {
  1005. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  1006. $clientID = $this->get_args ( 'clientID' ) ? $this->get_args ( 'clientID' ) : 0;
  1007. $companyname = $this->get_args ( 'companyName' ) ? $this->get_args ( 'companyName' ) : "";
  1008. Doo::loadModel ( 'company' );
  1009. Doo::loadModel ( 'client' );
  1010. $client = new client ();
  1011. $company = new company ();
  1012. $companyname = explode ( "-", $companyname );
  1013. if (isset ( $companyname [1] ))
  1014. $k = $company->getCompanyByName ( $companyname [0], $companyname [1] );
  1015. else
  1016. $k = array ();
  1017. if (! empty ( $cid ) && ! empty ( $k ) && ! empty ( $clientID )) {
  1018. $client->cid = $clientID;
  1019. $client->companyid = $cid;
  1020. $client->companyname = $companyname [0];
  1021. $client->update ();
  1022. } else {
  1023. $local1 = $this->get_args ( 'lv21' ) ? $this->get_args ( 'lv21' ) : 0;
  1024. $local2 = $this->get_args ( 'lv22' ) ? $this->get_args ( 'lv22' ) : 0;
  1025. $local3 = $this->get_args ( 'lv23' ) ? $this->get_args ( 'lv23' ) : 0;
  1026. Doo::loadModel ( 'district' );
  1027. $district = new district ();
  1028. // 更新公司信息
  1029. $lv1 = $district->getbyid ( $local1 );
  1030. $lv2 = $district->getbyid ( $local2 );
  1031. $lv3 = $district->getbyid ( $local3 );
  1032. if (empty ( $local1 ) || empty ( $local2 )) {
  1033. echo json_encode ( array (
  1034. 'status' => 2,
  1035. 'msg' => ''
  1036. ) );
  1037. die ();
  1038. }
  1039. if (! empty ( $local1 ) && ! empty ( $local2 ))
  1040. $company->local = $lv1 [0] ['name'] . "," . $lv2 [0] ['name'] . "," . $lv3 [0] ['name'];
  1041. if (! empty ( $local1 ) && ! empty ( $local2 ))
  1042. $company->district = $local1 . "," . $local2 . "," . $local3;
  1043. $nature = $this->get_args ( 'nature' ) ? $this->get_args ( 'nature' ) : "";
  1044. $fax = $this->get_args ( 'fax' ) ? $this->get_args ( 'fax' ) : "";
  1045. $webservice = $this->get_args ( 'webservice' ) ? $this->get_args ( 'webservice' ) : "";
  1046. $address = $this->get_args ( 'address' ) ? $this->get_args ( 'address' ) : "";
  1047. $landmarks = $this->get_args ( 'landmarks' ) ? $this->get_args ( 'landmarks' ) : "";
  1048. $stay = $this->get_args ( 'stay' ) ? $this->get_args ( 'stay' ) : "";
  1049. $ride = $this->get_args ( 'ride' ) ? $this->get_args ( 'ride' ) : "";
  1050. // $nature=implode(",", $nature);
  1051. $company->companyname = $companyname [0];
  1052. $company->ride = $ride;
  1053. $company->fax = $fax;
  1054. $company->webservice = $webservice;
  1055. $company->address = $address;
  1056. $company->landmarks = $landmarks;
  1057. $company->stay = $stay;
  1058. $company->nature = $nature;
  1059. $cid = $company->insert ();
  1060. $client->cid = $clientID;
  1061. $client->companyid = $cid;
  1062. $client->companyname = $companyname [0];
  1063. $client->update ();
  1064. }
  1065. echo json_encode ( array (
  1066. 'status' => 1,
  1067. 'msg' => ''
  1068. ) );
  1069. die ();
  1070. }
  1071. function getProudctHttp() {
  1072. Doo::loadModel ( 'product' );
  1073. $product = new product ();
  1074. $product = $product->getProudct ();
  1075. echo json_encode ( array (
  1076. 'status' => 1,
  1077. 'product' => $product
  1078. ) );
  1079. }
  1080. function getClientHttp() {
  1081. $searchDbInforItem = $this->get_args ( 'searchDbInforItem' ) ? $this->get_args ( 'searchDbInforItem' ) : "";
  1082. if (! empty ( $searchDbInforItem )) {
  1083. Doo::loadModel ( 'client' );
  1084. $client = new client ();
  1085. $clientInfo = $client->getClientByName ( $searchDbInforItem );
  1086. echo json_encode ( array (
  1087. 'status' => 1,
  1088. 'client' => $clientInfo
  1089. ) );
  1090. } else
  1091. echo json_encode ( array (
  1092. 'status' => 2,
  1093. 'client' => array ()
  1094. ) );
  1095. }
  1096. function getLongleHttp() {
  1097. $searchDbInforItem = $this->get_args ( 'searchDbInforItem' ) ? $this->get_args ( 'searchDbInforItem' ) : "";
  1098. if (! empty ( $searchDbInforItem )) {
  1099. Doo::loadModel ( 'longle' );
  1100. $longle = new longle ();
  1101. $longleInfo = $longle->getLongleBykeynum2 ( $searchDbInforItem );
  1102. echo json_encode ( array (
  1103. 'status' => 1,
  1104. 'longle' => $longleInfo
  1105. ) );
  1106. } else {
  1107. echo json_encode ( array (
  1108. 'status' => 2,
  1109. 'longle' => array ()
  1110. ) );
  1111. }
  1112. }
  1113. function getLongleIdHttp() {
  1114. $id = $this->get_args ( 'id' ) ? $this->get_args ( 'id' ) : "";
  1115. if (! empty ( $id )) {
  1116. Doo::loadModel ( 'longle' );
  1117. $longle = new longle ();
  1118. $longleInfo = $longle->getOne ( array (
  1119. 'where' => 'lid =' . $id,
  1120. 'asArray' => true
  1121. ) );
  1122. echo json_encode ( array (
  1123. 'status' => 1,
  1124. 'longle' => $longleInfo
  1125. ) );
  1126. } else {
  1127. echo json_encode ( array (
  1128. 'status' => 2,
  1129. 'longle' => array ()
  1130. ) );
  1131. }
  1132. }
  1133. function addLockLogHttp() {
  1134. Doo::loadModel ( 'longle_log' );
  1135. Doo::loadModel ( 'longle' );
  1136. Doo::loadModel ( "action_log" );
  1137. Doo::loadModel ( 'client' );
  1138. $clientobj = new client ();
  1139. $longle = new longle ();
  1140. $longle_log = new longle_log ();
  1141. Doo::loadModel ( 'district' );
  1142. $district = new district ();
  1143. Doo::loadModel ( 'staff' );
  1144. $staff = new staff ();
  1145. Doo::loadClass ( 'XDeode' );
  1146. $XDeode = new XDeode ( 5 );
  1147. $sid = $XDeode->decode ( $_COOKIE ["staff"] );
  1148. $status = $this->get_args ( 'longleStatus' ) ? $this->get_args ( 'longleStatus' ) : 0;
  1149. $lid = $this->get_args ( 'klid' ) ? $this->get_args ( 'klid' ) : 0;
  1150. if (empty ( $lid )) {
  1151. echo json_encode ( array (
  1152. 'status' => 2,
  1153. 'msg' => ''
  1154. ) );
  1155. die ();
  1156. }
  1157. $linfo = $longle->getLongleByLid ( $lid );
  1158. $this->staff = $staff->find ( array (
  1159. 'where' => 'sid=' . $sid,
  1160. 'asArray' => true
  1161. ) );
  1162. if ($status == 0) {
  1163. echo json_encode ( array (
  1164. 'status' => 2,
  1165. 'msg' => ''
  1166. ) );
  1167. die ();
  1168. } elseif ($status == 3) {
  1169. $client = $this->get_args ( 'browseClient' ) ? $this->get_args ( 'browseClient' ) : "";
  1170. $client = explode ( '-', $client );
  1171. $product = isset ( $_POST ['browseProduct'] ) ? $_POST ['browseProduct'] : "";
  1172. $clientname = $clientobj->getClientByName2 ( $client [0], $client [1] );
  1173. if (empty ( $clientname )) {
  1174. echo json_encode ( array (
  1175. 'status' => 2,
  1176. 'msg' => ''
  1177. ) );
  1178. die ();
  1179. }
  1180. if ($client [0] != "") {
  1181. $longle->client = $client [0];
  1182. $longle->clientid = $clientname [0] ['cid'];
  1183. }
  1184. // if($product!="")
  1185. // $longle->product=$product;
  1186. $longle->statusT = "借出";
  1187. $longle_log->client = $client [0];
  1188. $longle_log->clientid = $clientname [0] ['cid'];
  1189. $longle_log->product = $linfo [0] ['product'];
  1190. $longle_log->statusT = "借出";
  1191. // 日常行为
  1192. $action_log = new action_log ();
  1193. $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'] . ')';
  1194. $action_log->sid = $this->staff [0] ['sid'];
  1195. $action_log->cid = $this->staff [0] ['cid'];
  1196. $action_log->updatetime = date ( "Y-m-d" );
  1197. $action_log->time = date ( "H:i" );
  1198. $action_log->status = 4;
  1199. $action_log->districtid = $clientname [0] ['district'];
  1200. $local = $district->getbyidlist ( $clientname [0] ['district'] );
  1201. $action_log->city = $local [0] ['name'];
  1202. $action_log->province = $local [1] ['name'];
  1203. $action_log->company = $clientname [0] ['companyname'];
  1204. Doo::loadModel ( 'company' );
  1205. $company = new company ();
  1206. $companyInfo = $company->getOne ( array (
  1207. 'where' => ' companyname="' . $clientname [0] ['companyname'] . '"',
  1208. 'asArray' => true
  1209. ) );
  1210. $nature = explode ( ',', $companyInfo ['nature'] );
  1211. $action_log->nature = $nature [0];
  1212. $action_log->class = $action_log->iconBorrow;
  1213. $action_log->insert ();
  1214. } elseif ($status == 4) {
  1215. // $sellClient =
  1216. $product = isset ( $_POST ['sellProduct'] ) ? $_POST ['sellProduct'] : "";
  1217. $client = $this->get_args ( 'sellClient' ) ? $this->get_args ( 'sellClient' ) : ""; // isset($_POST['sellClient'])?$_POST['sellClient']:"";
  1218. $client = explode ( '-', $client );
  1219. $clientname = $clientobj->getClientByName2 ( $client [0], $client [1] );
  1220. if (empty ( $clientname )) {
  1221. echo json_encode ( array (
  1222. 'status' => 2,
  1223. 'msg' => 'not found client'
  1224. ) );
  1225. die ();
  1226. }
  1227. if ($client [0] != "") {
  1228. $longle->client = $client [0];
  1229. $longle->clientid = $clientname [0] ['cid'];
  1230. }
  1231. // if($product!="")
  1232. // $longle->product=$product;
  1233. $longle->statusT = "销售";
  1234. $longle_log->client = $client [0];
  1235. $longle_log->clientid = $clientname [0] ['cid'];
  1236. $longle_log->product = $linfo [0] ['product'];
  1237. $longle_log->statusT = "销售";
  1238. // 日常行为
  1239. $action_log = new action_log ();
  1240. $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'] . ')';
  1241. $action_log->sid = $this->staff [0] ['sid'];
  1242. $action_log->cid = $this->staff [0] ['cid'];
  1243. $action_log->updatetime = date ( "Y-m-d" );
  1244. $action_log->time = date ( "H:i" );
  1245. $action_log->status = 5;
  1246. $action_log->districtid = $clientname [0] ['district'];
  1247. $local = $district->getbyidlist ( $clientname [0] ['district'] );
  1248. $action_log->city = $local [0] ['name'];
  1249. $action_log->province = $local [1] ['name'];
  1250. $action_log->company = $clientname [0] ['companyname'];
  1251. Doo::loadModel ( 'company' );
  1252. $company = new company ();
  1253. $companyInfo = $company->getOne ( array (
  1254. 'where' => ' companyname="' . $clientname [0] ['companyname'] . '"',
  1255. 'asArray' => true
  1256. ) );
  1257. $nature = explode ( ',', $companyInfo ['nature'] );
  1258. $action_log->nature = $nature [0];
  1259. $action_log->class = $action_log->iconSell;
  1260. $action_log->insert ();
  1261. } elseif ($status == 5) {
  1262. $product = isset ( $_POST ['newProduct'] ) ? $_POST ['newProduct'] : "";
  1263. if ($product != "")
  1264. $longle->product = $linfo [0] ['product'] . "+" . $product;
  1265. $longle->statusT = "升级";
  1266. $longle_log->product = $linfo [0] ['product'] . "+" . $product;
  1267. $longle_log->statusT = "升级";
  1268. $longle_log->client = $linfo [0] ['client'];
  1269. $longle_log->clientid = $linfo [0] ['clientid'];
  1270. $clientname = $clientobj->getOne ( array (
  1271. 'where' => "cid= '" . $linfo [0] ['clientid'] . "'",
  1272. 'asArray' => TRUE
  1273. ) );
  1274. // 日常行为
  1275. $action_log = new action_log ();
  1276. $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>';
  1277. $action_log->sid = $this->staff [0] ['sid'];
  1278. $action_log->cid = $this->staff [0] ['cid'];
  1279. $action_log->updatetime = date ( "Y-m-d" );
  1280. $action_log->time = date ( "H:i" );
  1281. $action_log->class = $action_log->iconUpdate;
  1282. $action_log->sid = $this->staff [0] ['sid'];
  1283. $action_log->cid = $this->staff [0] ['cid'];
  1284. $action_log->status = 7;
  1285. $action_log->insert ();
  1286. } elseif ($status == 6) {
  1287. $key_num = isset ( $_POST ['key_num'] ) ? $_POST ['key_num'] : "";
  1288. $key_num2 = explode ( "-", $key_num );
  1289. $key_num = $key_num2 [0] . "-" . $key_num2 [1];
  1290. // if($key_num!="")
  1291. // $longle->key_num=$key_num;
  1292. // 新锁拷贝记录
  1293. $newLongle = new longle ();
  1294. $newLongle->product = $linfo [0] ['product'];
  1295. $newLongle->statusT = "更换";
  1296. $newLongle->status = 6;
  1297. $newLongle->client = $linfo [0] ['client'];
  1298. $newlid = $newLongle->update ( array (
  1299. 'where' => ' key_num= \'' . $key_num . "'"
  1300. ) );
  1301. $longleinfo = $longle->getOne ( array (
  1302. 'where' => ' key_num =\'' . $key_num . "'",
  1303. 'asArray' => true
  1304. ) );
  1305. // 新记录日志
  1306. $newlongle_log = new longle_log ();
  1307. $newlongle_log->statusT = "更换";
  1308. $newlongle_log->status = 6;
  1309. $newlongle_log->client = $linfo [0] ['client'];
  1310. $newlongle_log->new_key_num = $linfo [0] ['key_num'];
  1311. $newlongle_log->product = $linfo [0] ['product'];
  1312. $newlongle_log->category = $this->staff [0] ['category'];
  1313. $newlongle_log->dateline = date ( "Y-m-d" );
  1314. $newlongle_log->operator = $this->staff [0] ['username'];
  1315. $newlongle_log->lid = $longleinfo ['lid'];
  1316. $newlongle_log->insert ();
  1317. // 新锁状态拷贝
  1318. $longle->statusT = "更换";
  1319. $longle_log->new_key_num = $key_num;
  1320. $longle_log->statusT = "更换";
  1321. $longle_log->client = $linfo [0] ['client'];
  1322. $clientname = $clientobj->getOne ( array (
  1323. 'where' => "cid= '" . $linfo [0] ['clientid'] . "'",
  1324. 'asArray' => TRUE
  1325. ) );
  1326. // 日常行为
  1327. $action_log = new action_log ();
  1328. $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'] . ')';
  1329. $action_log->sid = $this->staff [0] ['sid'];
  1330. $action_log->cid = $this->staff [0] ['cid'];
  1331. $action_log->updatetime = date ( "Y-m-d" );
  1332. $action_log->time = date ( "H:i" );
  1333. $action_log->class = $action_log->iconReplace;
  1334. $action_log->sid = $this->staff [0] ['sid'];
  1335. $action_log->cid = $this->staff [0] ['cid'];
  1336. $action_log->status = 8;
  1337. $action_log->insert ();
  1338. } elseif ($status == 7) {
  1339. $longle->statusT = "收回";
  1340. $longle_log->statusT = "收回";
  1341. $longle_log->responsible = $linfo [0] ['responsible'];
  1342. // 日常行为
  1343. $action_log = new action_log ();
  1344. $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>';
  1345. $action_log->sid = $this->staff [0] ['sid'];
  1346. $action_log->cid = $this->staff [0] ['cid'];
  1347. $action_log->updatetime = date ( "Y-m-d" );
  1348. $action_log->time = date ( "H:i" );
  1349. $action_log->class = $action_log->iconRecycle;
  1350. $action_log->sid = $this->staff [0] ['sid'];
  1351. $action_log->cid = $this->staff [0] ['cid'];
  1352. $action_log->status = 9;
  1353. $action_log->insert ();
  1354. } elseif ($status == 8) {
  1355. $mark = isset ( $_POST ['mark'] ) ? $_POST ['mark'] : "";
  1356. $longle_log->mark = $mark;
  1357. // 日常行为
  1358. $action_log = new action_log ();
  1359. $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>添加新备注。';
  1360. $action_log->sid = $this->staff [0] ['sid'];
  1361. $action_log->cid = $this->staff [0] ['cid'];
  1362. $action_log->updatetime = date ( "Y-m-d" );
  1363. $action_log->time = date ( "H:i" );
  1364. $action_log->sid = $this->staff [0] ['sid'];
  1365. $action_log->cid = $this->staff [0] ['cid'];
  1366. $action_log->status = 10;
  1367. $action_log->class = $action_log->iconLock;
  1368. $action_log->insert ();
  1369. } elseif ($status == 9) {
  1370. $longle->statusT = "赠送";
  1371. $longle_log->statusT = "赠送";
  1372. $client = isset ( $_POST ['giftClient'] ) ? $_POST ['giftClient'] : "";
  1373. $client = explode ( '-', $client );
  1374. $clientname = $clientobj->getClientByName2 ( $client [0], $client [1] );
  1375. if (empty ( $clientname )) {
  1376. echo json_encode ( array (
  1377. 'status' => 2,
  1378. 'msg' => ''
  1379. ) );
  1380. die ();
  1381. }
  1382. if ($client [0] != "") {
  1383. $longle->client = $client [0];
  1384. $longle->clientid = $clientname [0] ['cid'];
  1385. }
  1386. $longle_log->client = $client [0];
  1387. $longle_log->clientid = $clientname [0] ['cid'];
  1388. // 日常行为
  1389. $action_log = new action_log ();
  1390. $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'] . ')';
  1391. $action_log->updatetime = date ( "Y-m-d" );
  1392. $action_log->time = date ( "H:i" );
  1393. $action_log->class = $action_log->iconRecycle;
  1394. $action_log->sid = $this->staff [0] ['sid'];
  1395. $action_log->cid = $this->staff [0] ['cid'];
  1396. $action_log->status = 6;
  1397. $action_log->districtid = $clientname [0] ['district'];
  1398. $local = $district->getbyidlist ( $clientname [0] ['district'] );
  1399. $action_log->city = $local [0] ['name'];
  1400. $action_log->province = $local [1] ['name'];
  1401. $action_log->company = $clientname [0] ['companyname'];
  1402. Doo::loadModel ( 'company' );
  1403. $company = new company ();
  1404. $companyInfo = $company->getOne ( array (
  1405. 'where' => ' companyname="' . $clientname [0] ['companyname'] . '"',
  1406. 'asArray' => true
  1407. ) );
  1408. $nature = explode ( ',', $companyInfo ['nature'] );
  1409. $action_log->nature = $nature [0];
  1410. $action_log->insert ();
  1411. }
  1412. // 记录使用过的状态
  1413. $statuslog = $status . "," . $linfo [0] ['statuslog'];
  1414. $ar = explode ( ',', $statuslog );
  1415. $statuslog = implode ( ',', array_unique ( array_filter ( $ar ) ) );
  1416. $longle->statuslog = $statuslog;
  1417. if ($linfo [0] ['status'] <= 2) {
  1418. if ($status >= 4 && $status <= 2) {
  1419. echo json_encode ( array (
  1420. 'status' => 1,
  1421. 'msg' => ''
  1422. ) );
  1423. die ();
  1424. }
  1425. }
  1426. if ($lid != 0) {
  1427. $longle->lid = $lid;
  1428. if ($status != 8)
  1429. $longle->status = $status;
  1430. // if($status!=8)
  1431. $longle->responsible = $this->staff [0] ['username'];
  1432. $longle->update ();
  1433. }
  1434. $longle_log->lid = $lid;
  1435. $longle_log->status = $status;
  1436. $longle_log->operator = $this->staff [0] ['username'];
  1437. // 责任人
  1438. $longle_log->category = $this->staff [0] ['category'];
  1439. $longle_log->dateline = date ( "Y-m-d" );
  1440. $longle_log->insert ();
  1441. echo json_encode ( array (
  1442. 'status' => 1,
  1443. 'msg' => ''
  1444. ) );
  1445. die ();
  1446. }
  1447. function getClientByPhoneHttp() {
  1448. $phone = $this->get_args ( 'phone' ) ? $this->get_args ( 'phone' ) : '';
  1449. if (! empty ( $phone )) {
  1450. Doo::loadModel ( 'client' );
  1451. $client = new client ();
  1452. Doo::loadModel ( 'district' );
  1453. $district = new district ();
  1454. $con = "";
  1455. 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 )) {
  1456. $con = 'telephone like "%' . $phone . '"';
  1457. } elseif (preg_match ( "/^(0(10|21|22|23|[1-9][0-9]{2})(-|))?[0-9]{7,8}$/", $phone )) {
  1458. if (strlen ( $phone ) == 10) {
  1459. $phone = substr ( $phone, 3 );
  1460. $con = 'phone like "%' . $phone . '"';
  1461. } elseif (strlen ( $phone ) == 11) {
  1462. $phone = substr ( $phone, 4 );
  1463. $con = 'phone like "%' . $phone . '"';
  1464. } elseif (strlen ( $phone ) == 12) {
  1465. $phone = substr ( $phone, 5 );
  1466. $con = 'phone like "%' . $phone . '"';
  1467. } else {
  1468. $con = 'telephone like "%' . $phone . '" or phone like "%' . $phone . '"';
  1469. }
  1470. } else {
  1471. $con = 'telephone like "%' . $phone . '" or phone like "%' . $phone . '"';
  1472. }
  1473. $info = $client->getOne ( array (
  1474. 'where' => $con,
  1475. 'asArray' => true
  1476. ) );
  1477. $d = $district->find ( array (
  1478. 'select' => 'name',
  1479. 'where' => 'id in(' . $info ['district'] . ')',
  1480. 'asArray' => true
  1481. ) );
  1482. $info ['local'] = $d;
  1483. echo json_encode ( array (
  1484. 'status' => 1,
  1485. 'info' => $info
  1486. ) );
  1487. die ();
  1488. }
  1489. echo json_encode ( array (
  1490. 'status' => 2,
  1491. 'info' => ''
  1492. ) );
  1493. die ();
  1494. }
  1495. function informationHttp() {
  1496. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  1497. $DATE = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : date ( "Y-m-d" );
  1498. // $month=$this->get_args('month')?$this->get_args('month'):date('m');
  1499. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 0;
  1500. $dateType = $this->get_args ( 'dateType' ) ? $this->get_args ( 'dateType' ) : 0;
  1501. Doo::loadModel ( 'action_log' );
  1502. $action_log = new action_log ();
  1503. Doo::loadModel ( 'staff' );
  1504. $staff = new staff ();
  1505. Doo::loadModel ( 'client_staff' );
  1506. $client_staff = new client_staff ();
  1507. Doo::loadModel ( 'longle' );
  1508. $longle = new longle ();
  1509. Doo::loadModel ( 'L_category' );
  1510. $lcategory = new L_category ();
  1511. $condition = "";
  1512. $limit = 50;
  1513. if (! empty ( $sid ))
  1514. $condition .= " and sid=" . $sid;
  1515. if (! empty ( $status ))
  1516. $condition .= " and status in (" . $status . ")";
  1517. if (empty ( $dateType ))
  1518. $condition .= ' and date(updatetime) >= date_sub("' . $DATE . '",interval 30 day) and date(updatetime) <= date_sub("' . $DATE . '",interval 0 day)';
  1519. else
  1520. $condition .= ' and updatetime = ' . $DATE . ' ';
  1521. $actionLogList = $action_log->find ( array (
  1522. 'where' => ' 1 ' . $condition . ' ',
  1523. 'desc' => 'aid',
  1524. 'asArray' => true
  1525. ) );
  1526. // 抽取日期 ,'groupby'=>'updatetime'
  1527. $dateLog = $action_log->find ( array (
  1528. 'select' => 'updatetime',
  1529. 'where' => ' 1 ' . $condition . ' and date(updatetime) >= date_sub("' . $DATE . '",interval 30 day) and date(updatetime) <= date_sub("' . $DATE . '",interval 0 day) ',
  1530. 'limit' => 50,
  1531. 'desc' => 'aid',
  1532. 'asArray' => true
  1533. ) );
  1534. $count = $action_log->count ( array (
  1535. 'where' => ' 1 ' . $condition,
  1536. 'limit' => $limit,
  1537. 'asArray' => true
  1538. ) );
  1539. $dl = array ();
  1540. foreach ( $dateLog as $value ) {
  1541. array_push ( $dl, $value ['updatetime'] );
  1542. }
  1543. $dateLog = array_unique ( $dl );
  1544. $log = array ();
  1545. foreach ( $dateLog as $key => $value ) {
  1546. $log [$value] = array ();
  1547. foreach ( $actionLogList as $k => $v ) {
  1548. if ($value == $v ['updatetime']) {
  1549. array_push ( $log [$value], $v );
  1550. unset ( $actionLogList [$k] );
  1551. }
  1552. }
  1553. }
  1554. $i = 0;
  1555. foreach ( $log as $key => $value ) {
  1556. if (empty ( $value ))
  1557. unset ( $log [$key] );
  1558. if ($i >= 3)
  1559. unset ( $log [$key] );
  1560. $i ++;
  1561. }
  1562. echo json_encode ( array (
  1563. 'status' => 1,
  1564. 'count' => $count,
  1565. 'list' => $log
  1566. ) );
  1567. die ();
  1568. }
  1569. function communicationHttp() {
  1570. Doo::loadModel ( 'staff' );
  1571. $staff = new staff ();
  1572. $list = $staff->find ( array (
  1573. 'where' => "username!= 'admin'",
  1574. 'asArray' => TRUE
  1575. ) );
  1576. echo json_encode ( array (
  1577. 'status' => 1,
  1578. 'list' => $list
  1579. ) );
  1580. die ();
  1581. }
  1582. function getStaffHttp() {
  1583. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  1584. Doo::loadModel ( 'staff' );
  1585. $staff = new staff ();
  1586. if (! empty ( $sid )) {
  1587. $info = $staff->getOne ( array (
  1588. 'where' => "username!= 'admin' and sid='" . $sid . "'",
  1589. 'asArray' => TRUE
  1590. ) );
  1591. $colleague = $staff->find ( array (
  1592. 'where' => "cid= '" . $info ['cid'] . "' and sid!='" . $info ['sid'] . "'",
  1593. 'asArray' => TRUE
  1594. ) );
  1595. array_push ( $colleague, $info );
  1596. echo json_encode ( array (
  1597. 'status' => 1,
  1598. 'list' => $colleague
  1599. ) );
  1600. die ();
  1601. }
  1602. echo json_encode ( array (
  1603. 'status' => 2,
  1604. 'list' => array ()
  1605. ) );
  1606. die ();
  1607. }
  1608. function getUserHttp() {
  1609. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  1610. Doo::loadModel ( 'staff' );
  1611. $staff = new staff ();
  1612. if (! empty ( $sid )) {
  1613. $info = $staff->getOne ( array (
  1614. 'where' => "username!= 'admin' and sid='" . $sid . "'",
  1615. 'asArray' => TRUE
  1616. ) );
  1617. echo json_encode ( array (
  1618. 'status' => 1,
  1619. 'list' => $info
  1620. ) );
  1621. die ();
  1622. }
  1623. echo json_encode ( array (
  1624. 'status' => 2,
  1625. 'list' => array ()
  1626. ) );
  1627. die ();
  1628. }
  1629. function editStaffHttp() {
  1630. $telephone = $this->get_args ( 'telephone' ) ? $_POST ['telephone'] : 0;
  1631. $phone = $this->get_args ( 'phone' ) ? $_POST ['phone'] : 0;
  1632. $email = isset ( $_POST ['email'] ) ? $_POST ['email'] : "";
  1633. $qq = is_numeric ( $this->get_args ( 'qq' ) ) ? $_POST ['qq'] : 0;
  1634. $year = $this->get_args ( 'year' ) ? $_POST ['year'] : date ( "Y" );
  1635. $month = $this->get_args ( 'month' ) ? $_POST ['month'] : "";
  1636. $day = $this->get_args ( 'day' ) ? $_POST ['day'] : "";
  1637. $position = $this->get_args ( 'position' ) ? $_POST ['position'] : "";
  1638. $gender = $this->get_args ( 'gender' ) ? $_POST ['gender'] : "男";
  1639. $oldpassword = isset ( $_POST ['oldpassword'] ) ? $_POST ['oldpassword'] : "";
  1640. $newpassword = isset ( $_POST ['newpassword'] ) ? $_POST ['newpassword'] : "";
  1641. $rnewpassword = isset ( $_POST ['rnewpassword'] ) ? $_POST ['rnewpassword'] : "";
  1642. Doo::loadModel ( 'staff' );
  1643. $staff = new staff ();
  1644. Doo::loadModel ( 'staffDynamic' );
  1645. $staffDynamic = new staffDynamic ();
  1646. Doo::loadClass ( 'XDeode' );
  1647. $XDeode = new XDeode ( 5 );
  1648. $sid = $XDeode->decode ( $_COOKIE ["staff"] );
  1649. $this->staff = $staff->find ( array (
  1650. 'where' => "sid='" . $sid . "'",
  1651. 'asArray' => TRUE
  1652. ) );
  1653. $staff->sid = $this->staff [0] ['sid'];
  1654. $content = "";
  1655. $ext = "更新了他的";
  1656. if ($telephone != 0 && $this->staff [0] ['telephone'] != $telephone) {
  1657. $staff->telephone = $telephone;
  1658. $content .= "<b>手机</b>&nbsp;";
  1659. }
  1660. if ($phone != 0 && $this->staff [0] ['phone'] != $phone) {
  1661. $staff->phone = $phone;
  1662. $content .= "<b>电话</b>&nbsp;";
  1663. }
  1664. if ($qq != 0 && $this->staff [0] ['qq'] != $qq) {
  1665. $staff->qq = $qq;
  1666. $content .= "<b>QQ</b>&nbsp;";
  1667. }
  1668. if ($year != 2014) {
  1669. $staff->birthday = $year . "-" . $month . "-" . $day;
  1670. $content .= "<b>生日</b>&nbsp;";
  1671. }
  1672. if ($email != "" && filter_var ( $email, FILTER_VALIDATE_EMAIL ) && $this->staff [0] ['email'] != $email) {
  1673. $staff->email = $email;
  1674. $content .= "<b>邮箱</b>&nbsp;";
  1675. }
  1676. if (! empty ( $position )) {
  1677. $staff->position = $position;
  1678. $content .= "<b>职位</b>&nbsp;";
  1679. }
  1680. $staff->gender = $gender;
  1681. $msg = "更新成功";
  1682. if ($this->staff [0] ['passwork'] == md5 ( $oldpassword )) {
  1683. if ($newpassword == $rnewpassword && (! empty ( $newpassword )))
  1684. $staff->passwork = md5 ( $newpassword );
  1685. else
  1686. $msg = "密码不一致";
  1687. } else {
  1688. if ($oldpassword != "")
  1689. $msg = "密码错误";
  1690. }
  1691. if (! empty ( $content )) {
  1692. $staffDynamic->content = $ext . $content;
  1693. $staffDynamic->cid = $this->staff [0] ['cid'];
  1694. $staffDynamic->category = $this->staff [0] ['category'];
  1695. $staffDynamic->time = time ();
  1696. $staffDynamic->sid = $this->staff [0] ['sid'];
  1697. $staffDynamic->staff = $this->staff [0] ['username'];
  1698. $staffDynamic->insert ();
  1699. }
  1700. $fileName = 'avatar_' . $this->staff [0] ['sid'];
  1701. $t = DOO::conf ()->SITE_PATH . "global/avatar/";
  1702. if (isset ( $_FILES ['photo100'] )) {
  1703. $file = $_FILES ['photo100'] ['tmp_name'];
  1704. if (is_uploaded_file ( $file )) {
  1705. $upload_file = 'avatar_' . $this->staff [0] ['sid'] . "_1.jpg";
  1706. move_uploaded_file ( $file, $t . $upload_file );
  1707. }
  1708. }
  1709. if (isset ( $_FILES ['photo50'] )) {
  1710. $file2 = $_FILES ['photo50'] ['tmp_name'];
  1711. if (is_uploaded_file ( $file2 )) {
  1712. $upload_file = 'avatar_' . $this->staff [0] ['sid'] . "_2.jpg";
  1713. move_uploaded_file ( $file2, $t . $upload_file );
  1714. }
  1715. }
  1716. if (isset ( $_FILES ['photo32'] )) {
  1717. $file3 = $_FILES ['photo32'] ['tmp_name'];
  1718. if (is_uploaded_file ( $file3 )) {
  1719. $upload_file = 'avatar_' . $this->staff [0] ['sid'] . "_3.jpg";
  1720. move_uploaded_file ( $file3, $t . $upload_file );
  1721. }
  1722. }
  1723. // echo $_FILES['photo50']['tmp_name'];
  1724. // var_dump($_FILES['photo32']['tmp_name']);
  1725. $staff->avatar = "/global/avatar/" . $fileName;
  1726. $staff->update ( array (
  1727. 'where' => ' sid=' . $this->staff [0] ['sid']
  1728. ) );
  1729. // phpinfo();
  1730. echo json_encode ( array (
  1731. 'status' => 1,
  1732. 'msg' => ''
  1733. ) );
  1734. die ();
  1735. }
  1736. function getRemindHttp() {
  1737. Doo::loadModel ( 'remind' );
  1738. $remind = new remind ();
  1739. Doo::loadClass ( 'XDeode' );
  1740. $XDeode = new XDeode ( 5 );
  1741. $sid = $XDeode->decode ( $_COOKIE ["staff"] );
  1742. // Doo::loadModel ( 'client' );
  1743. // $client = new client();
  1744. // and date_add(time, INTERVAL day DAY) <= CURDATE()
  1745. $remindList = $remind->find ( array (
  1746. 'where' => "staffID = '" . $sid . "' and status=0 ",
  1747. 'asc' => 'date_add(time, INTERVAL day DAY)',
  1748. 'asArray' => TRUE
  1749. ) );
  1750. $rc = 0;
  1751. foreach ( $remindList as $key => $value ) {
  1752. $a = strtotime ( $value ['time'] . " +" . $value ['day'] . " days" );
  1753. $b = strtotime ( date ( 'y-m-d' ) );
  1754. if ($a <= $b) {
  1755. $rc ++;
  1756. $remindList [$key] ['isRemind'] = 1;
  1757. } else
  1758. $remindList [$key] ['isRemind'] = 0;
  1759. // $remindList[$key]['clientInfo']=$client->getOne(array('where' => "cid = '".$value["clientID"]."'",'asArray' => TRUE));
  1760. $remindList [$key] ['Ctime'] = date ( 'm-d', strtotime ( $value ['time'] ) );
  1761. $remindList [$key] ['Etime'] = date ( 'm-d', strtotime ( $value ['time'] . " +" . $value ['day'] . " days" ) );
  1762. }
  1763. echo json_encode ( array (
  1764. 'status' => 1,
  1765. 'remindList' => $remindList,
  1766. 'remindCount' => $rc,
  1767. 'msg' => ''
  1768. ) );
  1769. die ();
  1770. }
  1771. function remindCLHttp() {
  1772. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  1773. if (! empty ( $rid )) {
  1774. Doo::loadModel ( 'remind' );
  1775. $remind = new remind ();
  1776. Doo::loadClass ( 'XDeode' );
  1777. $XDeode = new XDeode ( 5 );
  1778. $sid = $XDeode->decode ( $_COOKIE ["staff"] );
  1779. $remind->status = 1;
  1780. $remind->update ( array (
  1781. 'where' => "staffID = '" . $sid . "' and rid=" . $rid,
  1782. 'asArray' => TRUE
  1783. ) );
  1784. echo json_encode ( array (
  1785. 'status' => 1,
  1786. 'msg' => ''
  1787. ) );
  1788. die ();
  1789. }
  1790. echo json_encode ( array (
  1791. 'status' => 2,
  1792. 'msg' => ''
  1793. ) );
  1794. die ();
  1795. }
  1796. function addClientHttp() {
  1797. $clientname = $this->get_args ( 'clientname' ) ? $this->get_args ( 'clientname' ) : "";
  1798. $gender = $this->get_args ( 'gender' ) ? $this->get_args ( 'gender' ) : "";
  1799. $nicename = $this->get_args ( 'nicename' ) ? $this->get_args ( 'nicename' ) : "";
  1800. $telephone = $this->get_args ( 'telephone' ) ? $this->get_args ( 'telephone' ) : "";
  1801. $phone = $this->get_args ( 'phone' ) ? $this->get_args ( 'phone' ) : "";
  1802. $email = $this->get_args ( 'email' ) ? $this->get_args ( 'email' ) : "";
  1803. $qq = $this->get_args ( 'qq' ) ? $this->get_args ( 'qq' ) : "";
  1804. $tid = $this->get_args ( 'tid' ) ? $this->get_args ( 'tid' ) : "";
  1805. $companyname = $this->get_args ( 'companyname' ) ? $this->get_args ( 'companyname' ) : "";
  1806. $local1 = $this->get_args ( 'lv21' ) ? $this->get_args ( 'lv21' ) : "";
  1807. $local2 = $this->get_args ( 'lv22' ) ? $this->get_args ( 'lv22' ) : "";
  1808. $local3 = $this->get_args ( 'lv23' ) ? $this->get_args ( 'lv23' ) : "";
  1809. $nature = $this->get_args ( 'nature' ) ? $this->get_args ( 'nature' ) : "";
  1810. $fax = $this->get_args ( 'fax' ) ? $this->get_args ( 'fax' ) : "";
  1811. $webservice = $this->get_args ( 'webservice' ) ? $this->get_args ( 'webservice' ) : "";
  1812. $department = $this->get_args ( 'department' ) ? $this->get_args ( 'department' ) : "";
  1813. $position = $this->get_args ( 'position' ) ? $this->get_args ( 'position' ) : "";
  1814. $office = $this->get_args ( 'office' ) ? $this->get_args ( 'office' ) : "";
  1815. $address = $this->get_args ( 'address' ) ? $this->get_args ( 'address' ) : "";
  1816. $ride = $this->get_args ( 'ride' ) ? $this->get_args ( 'ride' ) : "";
  1817. $landmarks = $this->get_args ( 'landmarks' ) ? $this->get_args ( 'landmarks' ) : "";
  1818. $priority = $this->get_args ( 'priority' ) ? $this->get_args ( 'priority' ) : "1";
  1819. $stay = $this->get_args ( 'stay' ) ? $this->get_args ( 'stay' ) : "";
  1820. $mark = $this->get_args ( 'mark' ) ? $this->get_args ( 'mark' ) : "";
  1821. $clientname = trim ( $clientname );
  1822. $companyname = trim ( $companyname );
  1823. Doo::loadModel ( 'staff' );
  1824. $staff = new staff ();
  1825. $this->staff = $staff->getUserByIdList ( $_COOKIE ["staff"] );
  1826. if (empty ( $companyname ))
  1827. return "/contacts";
  1828. if (empty ( $this->staff [0] ['sid'] ))
  1829. return "/contacts";
  1830. if (! empty ( $clientname )) {
  1831. // 相同的公司和客户
  1832. Doo::loadModel ( 'company' );
  1833. $company = new company ();
  1834. Doo::loadModel ( 'client' );
  1835. $client = new client ();
  1836. $redis = new Redis ();
  1837. $redis->connect ( '127.0.0.1', '6379' );
  1838. $cinfo = $client->getClientByNameT ( $clientname );
  1839. if (! empty ( $cinfo )) {
  1840. $ninfo = $company->getCompanyByCompanyname ( $companyname );
  1841. if (! empty ( $ninfo )) {
  1842. foreach ( $cinfo as $key => $value ) { // 问题
  1843. if ($value ['companyid'] == $ninfo [0] ['cid'])
  1844. return "/contacts";
  1845. }
  1846. }
  1847. }
  1848. Doo::loadModel ( 'district' );
  1849. $district = new district ();
  1850. $companyInfo = $company->getOne ( array (
  1851. 'where' => "companyname = '" . $companyname . "'",
  1852. "asArray" => true
  1853. ) );
  1854. // 更新公司信息
  1855. $lv1 = $district->getbyid ( $local1 );
  1856. $lv2 = $district->getbyid ( $local2 );
  1857. $lv3 = $district->getbyid ( $local3 );
  1858. if (empty ( $lv1 ))
  1859. $lv1 [0] ['name'] = "";
  1860. if (empty ( $lv2 ))
  1861. $lv2 [0] ['name'] = "";
  1862. if (empty ( $lv3 ))
  1863. $lv3 [0] ['name'] = "";
  1864. if (! empty ( $local1 ) && ! empty ( $local2 ))
  1865. $company->local = $lv1 [0] ['name'] . "," . $lv2 [0] ['name'] . "," . $lv3 [0] ['name'];
  1866. if (! empty ( $nature ))
  1867. $company->nature = implode ( ',', $nature );
  1868. if (! empty ( $fax ))
  1869. $company->fax = $fax;
  1870. if (! empty ( $webservice ))
  1871. $company->webservice = $webservice;
  1872. if (! empty ( $address ))
  1873. $company->address = $address;
  1874. if (! empty ( $ride ))
  1875. $company->ride = $ride;
  1876. if (! empty ( $landmarks ))
  1877. $company->landmarks = $landmarks;
  1878. if (! empty ( $office ))
  1879. $company->office = $office;
  1880. if (! empty ( $local1 ) && ! empty ( $local2 ))
  1881. $company->district = $local1 . "," . $local2 . "," . $local3;
  1882. if (! empty ( $stay ))
  1883. $company->stay = $stay;
  1884. if (empty ( $companyInfo )) {
  1885. $company->companyname = $companyname;
  1886. $company->staffid = $this->staff [0] ['sid'];
  1887. $cid = $company->insert ();
  1888. } else { // 不编辑公司,地区判断,作为新公司
  1889. $diqu = $local1 . "," . $local2 . "," . $local3;
  1890. $cid = $companyInfo ['cid'];
  1891. $company2 = new company ();
  1892. $companyList = $company2->find ( array (
  1893. 'where' => " companyname like '" . $companyname . "'",
  1894. "asArray" => true
  1895. ) );
  1896. $falg = false;
  1897. // print_r($companyList);
  1898. foreach ( $companyList as $key => $value ) {
  1899. if ($value ['district'] != $diqu) {
  1900. $falg = true;
  1901. } elseif ($value ['district'] == $diqu) {
  1902. $falg = false;
  1903. $cid = $value ['cid'];
  1904. break;
  1905. }
  1906. }
  1907. if ($falg) {
  1908. $company->companyname = $companyname;
  1909. $company->staffid = $this->staff [0] ['sid'];
  1910. $cid = $company->insert ();
  1911. }
  1912. }
  1913. Doo::loadModel ( 'client_staff' );
  1914. $client_staff = new client_staff ();
  1915. $client->clientname = $clientname;
  1916. $client->gender = $gender;
  1917. $client->priority = $priority;
  1918. if (! empty ( $nicename ))
  1919. $client->nicename = $nicename;
  1920. if (! empty ( $telephone ))
  1921. $client->telephone = $telephone;
  1922. if (! empty ( $phone ))
  1923. $client->phone = $phone;
  1924. if (! empty ( $email ))
  1925. $client->email = $email;
  1926. if (! empty ( $qq ) && is_numeric ( $qq ))
  1927. $client->qq = $qq;
  1928. $client->companyid = $cid;
  1929. $client->companyname = $companyname;
  1930. $client->district = $local1 . "," . $local2 . "," . $local3;
  1931. if (! empty ( $tid ))
  1932. $client->tag = implode ( ',', $tid );
  1933. if (! empty ( $fax ))
  1934. $client->fax = $fax;
  1935. if (! empty ( $webservice ))
  1936. $client->webservice = $webservice;
  1937. if (! empty ( $department ))
  1938. $client->department = $department;
  1939. if (! empty ( $position ))
  1940. $client->position = $position;
  1941. if (! empty ( $office ))
  1942. $client->office = $office;
  1943. if (! empty ( $address ))
  1944. $client->address = $address;
  1945. if (! empty ( $ride ))
  1946. $client->ride = $ride;
  1947. if (! empty ( $landmarks ))
  1948. $client->landmarks = $landmarks;
  1949. if (! empty ( $stay ))
  1950. $client->stay = $stay;
  1951. if (! empty ( $mark ))
  1952. $client->mark = $mark;
  1953. $id = $client->insert ();
  1954. $client_staff->cid = $id;
  1955. $client_staff->sid = $this->staff [0] ['sid'];
  1956. $client_staff->insert ();
  1957. // 加入地区记录
  1958. Doo::loadModel ( "district_staff" );
  1959. $district_staff = new district_staff ();
  1960. $district_staff->did = $lv1 [0] ['id'];
  1961. $district_staff->sid = $this->staff [0] ['sid'];
  1962. $district_staff->insert ();
  1963. // 日常行为
  1964. Doo::loadModel ( "action_log" );
  1965. $action_log = new action_log ();
  1966. $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(\'' . $id . '\')">' . $clientname . '</a>(' . $companyname . ')';
  1967. $action_log->sid = $this->staff [0] ['sid'];
  1968. $action_log->cid = $this->staff [0] ['cid'];
  1969. $action_log->updatetime = date ( "Y-m-d" );
  1970. $action_log->time = date ( "H:i" );
  1971. $action_log->status = 1;
  1972. $action_log->districtid = $local1 . "," . $local2 . "," . $local3;
  1973. $action_log->city = $lv1 [0] ['name'];
  1974. $action_log->province = $lv2 [0] ['name'];
  1975. if (isset ( $nature [0] ))
  1976. $action_log->nature = $nature [0];
  1977. $action_log->company = $companyname;
  1978. $action_log->class = $action_log->iconContacts;
  1979. $action_log->insert ();
  1980. // 事实更新信息中心记录数量 需要更新3个redis 内的值
  1981. $categoryCondition = " and cid=" . $this->staff [0] ['cid'];
  1982. $sidCondition = " and sid=" . $this->staff [0] ['sid'];
  1983. // actionlog免查询值 $alCondition='';
  1984. $alCondition = ' aid>' . REMIT . ' and ';
  1985. // 个人添加数量redis值
  1986. $redisKeyCS = date ( 'Y-m-d' ) . 'SC_' . $this->staff [0] ['cid'] . '_' . $this->staff [0] ['sid'];
  1987. $action_log = new action_log ();
  1988. $actionLogClient = $action_log->find ( array (
  1989. 'select' => 'date_format(updatetime,"%m-%d") as updatetime,COUNT(*) as count',
  1990. 'where' => $alCondition . " status=1" . $sidCondition . $categoryCondition . ' and date_sub(curdate(), INTERVAL 30 DAY) <= date(updatetime)',
  1991. 'groupby' => 'date_format(updatetime,"%m-%d")',
  1992. 'asArray' => true
  1993. ) );
  1994. $statisticsClient = array ();
  1995. for($d = 0; $d <= 29; $d ++) {
  1996. $MD = date ( "m-d", strtotime ( "-" . $d . " day" ) );
  1997. $falgClient = true;
  1998. foreach ( $actionLogClient as $value ) {
  1999. if ($value ['updatetime'] == $MD) {
  2000. array_push ( $statisticsClient, $value ['count'] );
  2001. $falgClient = false;
  2002. break;
  2003. }
  2004. }
  2005. if ($falgClient)
  2006. array_push ( $statisticsClient, 0 );
  2007. }
  2008. $statisticsClient = array_reverse ( $statisticsClient );
  2009. $jsc = json_encode ( $statisticsClient );
  2010. $redis->set ( $redisKeyCS, $jsc );
  2011. // 办事处添加数量reids值
  2012. $redisKeyC = date ( 'Y-m-d' ) . 'SC_' . $this->staff [0] ['cid'] . '_';
  2013. $action_log = new action_log ();
  2014. $actionLogClient = $action_log->find ( array (
  2015. 'select' => 'date_format(updatetime,"%m-%d") as updatetime,COUNT(*) as count',
  2016. 'where' => $alCondition . " status=1" . $categoryCondition . ' and date_sub(curdate(), INTERVAL 30 DAY) <= date(updatetime)',
  2017. 'groupby' => 'date_format(updatetime,"%m-%d")',
  2018. 'asArray' => true
  2019. ) );
  2020. $statisticsClient = array ();
  2021. for($d = 0; $d <= 29; $d ++) {
  2022. $MD = date ( "m-d", strtotime ( "-" . $d . " day" ) );
  2023. $falgClient = true;
  2024. foreach ( $actionLogClient as $value ) {
  2025. if ($value ['updatetime'] == $MD) {
  2026. array_push ( $statisticsClient, $value ['count'] );
  2027. $falgClient = false;
  2028. break;
  2029. }
  2030. }
  2031. if ($falgClient)
  2032. array_push ( $statisticsClient, 0 );
  2033. }
  2034. $statisticsClient = array_reverse ( $statisticsClient );
  2035. $jsc = json_encode ( $statisticsClient );
  2036. $redis->set ( $redisKeyC, $jsc );
  2037. // 全员添加数量的redis值
  2038. $redisKey = date ( 'Y-m-d' ) . 'SC__';
  2039. $action_log = new action_log ();
  2040. $actionLogClient = $action_log->find ( array (
  2041. 'select' => 'date_format(updatetime,"%m-%d") as updatetime,COUNT(*) as count',
  2042. 'where' => $alCondition . ' status=1 and date_sub(curdate(), INTERVAL 30 DAY) <= date(updatetime)',
  2043. 'groupby' => 'date_format(updatetime,"%m-%d")',
  2044. 'asArray' => true
  2045. ) );
  2046. $statisticsClient = array ();
  2047. for($d = 0; $d <= 29; $d ++) {
  2048. $MD = date ( "m-d", strtotime ( "-" . $d . " day" ) );
  2049. $falgClient = true;
  2050. foreach ( $actionLogClient as $value ) {
  2051. if ($value ['updatetime'] == $MD) {
  2052. array_push ( $statisticsClient, $value ['count'] );
  2053. $falgClient = false;
  2054. break;
  2055. }
  2056. }
  2057. if ($falgClient)
  2058. array_push ( $statisticsClient, 0 );
  2059. }
  2060. $statisticsClient = array_reverse ( $statisticsClient );
  2061. $jsc = json_encode ( $statisticsClient );
  2062. $redis->set ( $redisKey, $jsc );
  2063. }
  2064. echo json_encode ( array (
  2065. 'status' => 1,
  2066. 'msg' => ''
  2067. ) );
  2068. die ();
  2069. }
  2070. /**
  2071. * 获取get或者POST值
  2072. * @param string $name 属性名称
  2073. * @return fixed 值
  2074. */
  2075. function get_args($name) {
  2076. if (isset ( $_GET [$name] )) {
  2077. if (is_array ( $_GET [$name] ))
  2078. return $_GET [$name];
  2079. else {
  2080. return addslashes ( $_GET [$name] );
  2081. // return $_GET [$name] ;
  2082. }
  2083. } elseif (isset ( $_POST [$name] )) {
  2084. if (is_array ( $_POST [$name] ))
  2085. return $_POST [$name];
  2086. else {
  2087. return addslashes ( $_POST [$name] );
  2088. // return $_POST [$name];
  2089. }
  2090. } else {
  2091. return false;
  2092. }
  2093. }
  2094. /**
  2095. * 获取总页数
  2096. * @param unknown_type $table
  2097. * @param unknown_type $condition
  2098. */
  2099. public function getTableCount($table = "", $condition = "", $staffid = "", $search, $tooltip, $cateid) {
  2100. if (! empty ( $staffid )) {
  2101. // $staffid="and a.sid= '".$staffid."'"; " . $table . " as a left join on (a.cid=b.cid ".$staffid.")
  2102. $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;
  2103. } else {
  2104. if (strlen ( $condition ) == 1 || empty ( $condition ))
  2105. $sql = "select count(*) as count from CLD_client as a " . $condition;
  2106. else
  2107. $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;
  2108. }
  2109. if (! empty ( $search ))
  2110. $sql = "select count(*) as count from CLD_client as a where 1 " . $condition;
  2111. if (! empty ( $tooltip )) {
  2112. $condition = str_replace ( "a.", "c.", $condition );
  2113. $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;
  2114. }
  2115. // echo $sql;
  2116. $query = Doo::db ()->query ( $sql );
  2117. $result = $query->fetch ();
  2118. return $result ['count'];
  2119. }
  2120. /*
  2121. * 生成WSDL文件
  2122. */
  2123. function interfaceDetail() {
  2124. Doo::loadClass ( "MobileApi/Service" );
  2125. }
  2126. function login($user, $pw) {
  2127. Doo::loadModel ( 'staff' );
  2128. $staff = new staff ();
  2129. if (! empty ( $pw )) {
  2130. $userinfo = $staff->checkUser ( $user, $pw );
  2131. if (! empty ( $userinfo )) {
  2132. setcookie ( "staff", $userinfo [0] ['sid'], time () + 36000, "/" );
  2133. return array (
  2134. 'status' => 1,
  2135. 'msg' => '登陆成功',
  2136. 'userList' => $userinfo
  2137. );
  2138. } else
  2139. return array (
  2140. 'status' => 2,
  2141. 'msg' => '账号或密码不正确2',
  2142. 'userList' => array ()
  2143. );
  2144. } else
  2145. return array (
  2146. 'status' => 2,
  2147. 'msg' => '账号或密码不正确3',
  2148. 'userList' => array ()
  2149. );
  2150. }
  2151. function register($username, $gameid, $fromurl, $advertiser, $adfrom, $pagetype, $pagename, $tgid, $ip, $registertime) {
  2152. $param = array (
  2153. 'tg_account' => $username,
  2154. 'tg_gameID' => $gameid,
  2155. 'tg_advertiser' => $fromurl,
  2156. 'tg_adFrom' => $advertiser,
  2157. 'tg_pageParam' => $adfrom,
  2158. 'tg_adType' => $pagetype,
  2159. 'tg_adsID' => $tgid,
  2160. 'tg_ip' => $tgid,
  2161. 'tg_registerTime' => $registertime
  2162. );
  2163. return $param;
  2164. }
  2165. public function service() {
  2166. ini_set ( "soap.wsdl_cache_enabled", "0" );
  2167. $server = new SoapServer ( 'protected/class/MobileApi/interfaceDetail.wsdl', array (
  2168. 'soap_version' => SOAP_1_2
  2169. ) );
  2170. $server->setClass ( "MobileController" );
  2171. $server->addFunction ( array (
  2172. 'login',
  2173. 'register'
  2174. ) );
  2175. $server->addFunction ( SOAP_FUNCTIONS_ALL );
  2176. $server->handle ();
  2177. }
  2178. }
  2179. ?>