| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543 | <?php/** * @author darkredz */class MobileController extends DooController {	function __construct() {		Doo::loadCore ( 'uri/DooUriRouter' );		$router = new DooUriRouter ();		$routeRs = $router->execute ( Doo::app ()->route, Doo::conf ()->SUBFOLDER );				if ($routeRs ['1'] != "loginHttp") {			if (isset ( $_COOKIE ["staff"] )) {				if (empty ( $_COOKIE ["staff"] )) {					setcookie ( "staff", '', time () + 36000, "/" );					echo json_encode ( array (							'status' => 3,							'msg' => '请登录' 					) );					die ();				}			} else {				setcookie ( "staff", '', time () + 36000, "/" );				echo json_encode ( array (						'status' => 3,						'msg' => '请登录' 				) );				die ();			}		}	}	function loginHttp() {		$pw2 = $pw = $this->get_args ( 'pw' ) ? $this->get_args ( 'pw' ) : "";		$user = $this->get_args ( 'user' ) ? $this->get_args ( 'user' ) : "";		// $t = $this->get_args('t') ? $this->get_args('t') : 0;				Doo::loadModel ( 'staff' );		Doo::loadModel ( 'tag' );		$tag = new tag ();		$staff = new staff ();		Doo::loadClass ( 'XDeode' );		$XDeode = new XDeode ( 5 );				if (! empty ( $pw )) {			if (isset ( $_COOKIE ['staff'] )) // $this->authcode(,'DECODE',$this->key)				$pw2 = base64_decode ( $pw );			$userinfo = $staff->checkUser ( $user, $pw2 );						if (! empty ( $userinfo )) { // $pw;$this->authcode(,'',$this->key)			                       // get user tag				$tagList = $tag->find ( array (						'where' => 'sid=' . $userinfo [0] ['sid'],						'asArray' => true 				) );				$userinfo [0] ['passwork'] = base64_encode ( $pw2 );				setcookie ( "staff", $XDeode->encode ( $userinfo [0] ['sid'] ), time () + 36000, "/" );				$a = filemtime ( DOO::conf ()->SITE_PATH . $userinfo [0] ['avatar'] . "_2.jpg" );				$userinfo [0] ['avatarUpdateTime'] = $a;				// if ($t){				$staff->appDate = date ( 'Y-m-d H:i' );				$staff->update ( array (						'where' => 'sid=' . $userinfo [0] ['sid'] 				) );				// }				echo json_encode ( array (						'status' => 1,						'msg' => '登陆成功',						'userList' => $userinfo,						'tagList' => $tagList 				) );			} else {				if (isset ( $_COOKIE ['staff'] ))					$userinfo = $staff->checkUser ( $user, $pw );				if (! empty ( $userinfo )) { // $pw;$this->authcode(,'',$this->key)				                       // get user tag					$tagList = $tag->find ( array (							'where' => 'sid=' . $userinfo [0] ['sid'],							'asArray' => true 					) );					$userinfo [0] ['passwork'] = base64_encode ( $pw );					$a =0;					if(file_exists(DOO::conf ()->SITE_PATH . $userinfo [0] ['avatar'] . "_2.jpg"))						$a = filemtime ( DOO::conf ()->SITE_PATH . $userinfo [0] ['avatar'] . "_2.jpg" );					$userinfo [0] ['avatarUpdateTime'] = $a;					// if ($t){					$staff->appDate = date ( 'Y-m-d H:i' );					$staff->update ( array (							'where' => 'sid=' . $userinfo [0] ['sid'] 					) );					// }					echo json_encode ( array (							'status' => 1,							'msg' => '登陆成功C',							'userList' => $userinfo,							'tagList' => $tagList 					) );				} else					echo json_encode ( array (							'status' => 2,							'msg' => '账号或密码不正确',							'userList' => array () 					) );			}		} else			echo json_encode ( array (					'status' => 2,					'msg' => '账号或密码不正确',					'userList' => array () 			) );	}	function outHttp() {		setcookie ( "staff", '', time () + 36000, "/" );		echo json_encode ( array (				'status' => 1,				'msg' => '退出成功' 		) );	}	function searchHttp() {		$search = $pw = $this->get_args ( 'search' ) ? $this->get_args ( 'search' ) : "";		$page = $this->get_args ( 'page' ) && is_numeric ( $this->get_args ( 'page' ) ) ? $this->get_args ( 'page' ) : 1;		$size = $this->get_args ( 'size' ) && is_numeric ( $this->get_args ( 'size' ) ) ? $this->get_args ( 'size' ) : 10;				Doo::loadModel ( 'client' );		$client = new client ();		Doo::loadModel ( 'staff' );		Doo::loadModel ( 'tag_client' );		Doo::loadModel ( 'C_tooltip' );		Doo::loadModel ( 'tag' );		$tagObj = new tag ();		$cTooltip = new C_tooltip ();		$tagClient = new tag_client ();		$staff = new staff ();				Doo::loadClass ( 'XDeode' );		$XDeode = new XDeode ( 5 );		$sid = $XDeode->decode ( $_COOKIE ["staff"] );				$staffDetail = $staff->getOne ( array (				'where' => 'sid=' . $sid,				'asArray' => true 		) );				if ($page != 1)			$page = $page * $size - 1;		else			$page --;				$ClientTagList = $tagClient->getTagClientBySid ( $sid );		$toollist = $cTooltip->find ( array (				'where' => 'cateid=' . $staffDetail ["cid"],				'asArray' => true 		) );		$count = $client->count ( array (				'limit' => $page . ',' . $size,				'where' => " address like '%" . $search . "%' or clientname like '%" . $search . "%' or companyname like '%" . $search . "%' or qq like '%" . $search . "%' or telephone like '%" . $search . "%' or phone like '%" . $search . "%'",				'asArray' => true 		) );		$list = $client->find ( array (				'limit' => $page . ',' . $size,				'where' => " address like '%" . $search . "%' or clientname like '%" . $search . "%' or companyname like '%" . $search . "%' or qq like '%" . $search . "%' or telephone like '%" . $search . "%' or phone like '%" . $search . "%'",				'asArray' => true 		) );				foreach ( $ClientTagList as $key => $value ) {			$ClientTagList [$key] ['taginfo'] = $tagObj->getTagByTidL ( $value ['tag'] );		}				foreach ( $list as $key => $value ) {			if (! empty ( $value ['cid'] )) {				$list [$key] ['taginfo'] = array ();				$list [$key] ['tag'] = "";								foreach ( $ClientTagList as $k => $v ) {					if ($value ['cid'] == $v ['client']) {						$list [$key] ['taginfo'] = $v ['taginfo'];						$list [$key] ['tag'] = $v ['tag'];					}				}			}						$list [$key] ['tooltipList'] = array ();			foreach ( $toollist as $k => $v ) {				if ($v ['cid'] == $value ['cid']) {					$list [$key] ['tooltipList'] = explode ( ",", $v ['name'] );					break;				} // array_pop 可以优化数组			}		}				echo json_encode ( array (				'status' => 1,				'clientList' => $list,				'count' => $count 		) );	}	function districtHttp() {		$did = $this->get_args ( 'did' ) && is_numeric ( $this->get_args ( 'did' ) ) ? $this->get_args ( 'did' ) : 0;				Doo::loadModel ( 'district' );		Doo::loadModel ( 'staff' );		$staff = new staff ();		$district = new district ();				Doo::loadClass ( 'XDeode' );		$XDeode = new XDeode ( 5 );		// if (!is_numeric($_COOKIE ["staff"]))				$sid = $XDeode->decode ( $_COOKIE ["staff"] );				$staffDetail = $staff->getOne ( array (				'where' => 'sid=' . $sid,				'asArray' => true 		) );				if ($did == 0) {			if ($staffDetail ['isadmin'])				$districtList = $district->get_lvByid ( 0, $did );			else				$districtList = $district->get_lvByStaffid ( 1, $sid );		} else {						$districtList = $district->get_lvByid ( 0, $did );		}		echo json_encode ( array (				'msg' => '',				'districtList' => $districtList 		) );	}	function clientDetailHttp() {		$cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;				if ($cid != 0) {			Doo::loadModel ( 'client' );			Doo::loadModel ( 'company' );			Doo::loadModel ( 'service_log' );			Doo::loadModel ( 'longle' );			$longle = new longle ();			$client = new client ();			$company = new company ();			$serviceLog = new service_log ();			Doo::loadModel ( 'client_staff' );			Doo::loadModel ( 'staff' );			Doo::loadModel ( 'tag_client' );			Doo::loadModel ( 'C_tooltip' );			Doo::loadModel ( 'tag' );			$tagObj = new tag ();			$cTooltip = new C_tooltip ();			$tagClient = new tag_client ();			$staff = new staff ();			$client_staff = new client_staff ();			Doo::loadModel ( 'tagCompany' );			$tagCompany = new tagCompany ();			Doo::loadModel ( 'tagCompanyNexus' );			$tagCompanyNexus = new tagCompanyNexus ();						Doo::loadClass ( 'XDeode' );			$XDeode = new XDeode ( 5 );						if (! isset ( $_COOKIE ["staff"] )) {				$sid = 0;			} else {								$sid = $XDeode->decode ( $_COOKIE ["staff"] );			}						$clientList = $client->getOne ( array (					'where' => 'cid=' . $cid,					'asArray' => true 			) );						$companyList = $longleList = $colleague = $serviceLogList = array ();			$clientCount = array ();			if (! empty ( $clientList )) {								$companyList = $company->getOne ( array (						'where' => 'cid=' . $clientList ['companyid'],						'asArray' => true 				) );				$serviceLogList = $serviceLog->find ( array (						'where' => 'clientid=' . $cid,						'desc' => 'date',						'asArray' => true 				) );				$clientCount = $client->count ( array (						'where' => 'companyid=' . $clientList ['companyid'],						'asArray' => true 				) );				$longleList = $longle->find ( array (						'where' => 'clientid=' . $cid,						'asArray' => true 				) );				$colleague = $client->find ( array (						'where' => 'companyid=' . $clientList ['companyid'] . ' and cid!=' . $cid,						'asArray' => true 				) );			}						$staffDetail = $staff->getOne ( array (					'where' => 'sid=' . $sid,					'asArray' => true 			) );			$ClientTagList = $tagClient->getTagClientBySid ( $sid );			$toollist = array ();			if (! empty ( $staffDetail ))				$toollist = $cTooltip->find ( array (						'where' => 'cateid=' . $staffDetail ["cid"],						'asArray' => true 				) );						$companyTagL = $tagCompany->find ( array (					'where' => 'sid=' . $sid,					'asArray' => true 			) );			$CompanyTagList = $tagCompanyNexus->getTagClientBySid ( $sid );			foreach ( $CompanyTagList as $key => $value ) {				$CompanyTagList [$key] ['taginfo'] = $tagCompany->getTagByTidL ( $value ['tag'] );			}						if (! empty ( $companyList ['cid'] )) {				$companyList ['taginfo'] = array ();				$companyList ['tag'] = "";								foreach ( $CompanyTagList as $k => $v ) {					if ($companyList ['cid'] == $v ['company']) {						$companyList ['taginfo'] = $v ['taginfo'];						$companyList ['tag'] = $v ['tag'];					}				}			}						foreach ( $ClientTagList as $key => $value ) {				$ClientTagList [$key] ['taginfo'] = $tagObj->getTagByTidL ( $value ['tag'] );			}						if (! empty ( $clientList ['cid'] )) {				$clientList ['taginfo'] = array ();				$clientList ['tag'] = "";								foreach ( $ClientTagList as $k => $v ) {					if ($clientList ['cid'] == $v ['client']) {						$clientList ['taginfo'] = $v ['taginfo'];						$clientList ['tag'] = $v ['tag'];					}				}			}						// $list[$key]['tooltipList']=array();			foreach ( $toollist as $k => $v ) {				if ($v ['cid'] == $clientList ['cid']) {					$clientList ['tooltipList'] = explode ( ",", $v ['name'] );					break;				} // array_pop 可以优化数组			}						foreach ( $colleague as $key => $value ) {				if (! empty ( $value ['cid'] )) {					$colleague [$key] ['taginfo'] = array ();					$colleague [$key] ['tag'] = "";										foreach ( $ClientTagList as $k => $v ) {						if ($value ['cid'] == $v ['client']) {							$colleague [$key] ['taginfo'] = $v ['taginfo'];							$colleague [$key] ['tag'] = $v ['tag'];						}					}				}								$colleague [$key] ['tooltipList'] = array ();				foreach ( $toollist as $k => $v ) {					if ($v ['cid'] == $value ['cid']) {						$colleague [$key] ['tooltipList'] = explode ( ",", $v ['name'] );						break;					} // array_pop 可以优化数组				}			}						$companyList ['clientCount'] = $clientCount;			echo json_encode ( array (					'status' => 1,					'clientList' => $clientList,					'colleague' => $colleague,					'companyList' => $companyList,					'companyTag' => $companyTagL,					'serviceLogList' => $serviceLogList,					'longleList' => $longleList,					'msg' => '' 			) );			die ();		}		echo json_encode ( array (				'status' => 2,				'clientList' => array (),				'companyList' => array (),				'serviceLogList' => array (),				'msg' => "请输入正确的请求路径" 		) );	}	function advancedSearchHttp() {		$lv1 = $this->get_args ( 'lv1' ) && is_numeric ( $this->get_args ( 'lv1' ) ) ? $this->get_args ( 'lv1' ) : "";		$lv2 = $this->get_args ( 'lv2' ) && is_numeric ( $this->get_args ( 'lv2' ) ) ? $this->get_args ( 'lv2' ) : "";		$lv3 = $this->get_args ( 'lv3' ) && is_numeric ( $this->get_args ( 'lv3' ) ) ? $this->get_args ( 'lv3' ) : "";		$tag = $this->get_args ( 'tag' ) ? $this->get_args ( 'tag' ) : "";		$teamTag = $this->get_args ( 'teamTag' ) ? $this->get_args ( 'teamTag' ) : "";		$page = $this->get_args ( 'page' ) && is_numeric ( $this->get_args ( 'page' ) ) ? $this->get_args ( 'page' ) : 1;		$size = $this->get_args ( 'size' ) && is_numeric ( $this->get_args ( 'size' ) ) ? $this->get_args ( 'size' ) : 10;				Doo::loadModel ( 'client_staff' );		Doo::loadModel ( 'staff' );		Doo::loadModel ( 'tag_client' );		Doo::loadModel ( 'C_tooltip' );		Doo::loadModel ( 'tag' );		$tagObj = new tag ();		$cTooltip = new C_tooltip ();		$tagClient = new tag_client ();		$staff = new staff ();		$client_staff = new client_staff ();				Doo::loadClass ( 'XDeode' );		$XDeode = new XDeode ( 5 );		// if (!is_numeric($_COOKIE ["staff"]))		$sid = $XDeode->decode ( $_COOKIE ["staff"] );				$staffDetail = $staff->getOne ( array (				'where' => 'sid=' . $sid,				'asArray' => true 		) );		if (empty ( $staffDetail )) {			echo json_encode ( array (					'status' => 1,					'clientList' => array (),					'count' => 0,					'msg' => '' 			) );			die ();		}				$condition = "";		if (! empty ( $lv1 ))			$condition .= " and district like '" . $lv1 . ",%'";		if (! empty ( $lv2 ))			$condition .= " and district like '" . $lv1 . "," . $lv2 . ",%'";		if (! empty ( $lv3 ))			$condition .= " and district like '" . $lv1 . "," . $lv2 . "," . $lv3 . "'";				if (! empty ( $tag )) {			$tagList = explode ( "@", $tag );			foreach ( $tagList as $value ) {				$condition .= " and c.tag like '%" . $value . "%' ";			}		}		if ($page != 1)			$page = $page * $size - 1;		else			$page --;		$limit = "  limit " . $page . " , " . $size . " ";				// 获得标签		$ClientTagList = $tagClient->getTagClientBySid ( $sid );		$toollist = $cTooltip->find ( array (				'where' => 'cateid=' . $staffDetail ["cid"],				'asArray' => true 		) );		$count = $this->getTableCount ( "CLD_client_staff", $condition, $staffDetail ["sid"], "", $teamTag, $staffDetail ['cid'] );		$clientList = $client_staff->getClientByStaff ( $condition, $limit, $staffDetail ["sid"], $staffDetail ["sid"], "", $teamTag, $staffDetail ['cid'] );				foreach ( $ClientTagList as $key => $value ) {			$ClientTagList [$key] ['taginfo'] = $tagObj->getTagByTidL ( $value ['tag'] );		}				foreach ( $clientList as $key => $value ) {			if (! empty ( $value ['cid'] )) {				$clientList [$key] ['taginfo'] = array ();				$clientList [$key] ['tag'] = "";								foreach ( $ClientTagList as $k => $v ) {					if ($value ['cid'] == $v ['client']) {						$clientList [$key] ['taginfo'] = $v ['taginfo'];						$clientList [$key] ['tag'] = $v ['tag'];					}				}			}						$clientList [$key] ['tooltipList'] = array ();			foreach ( $toollist as $k => $v ) {				if ($v ['cid'] == $value ['cid']) {					$clientList [$key] ['tooltipList'] = explode ( ",", $v ['name'] );					break;				} // array_pop 可以优化数组			}			$clientList [$key] ['locount'] = 0;		}				echo json_encode ( array (				'status' => 1,				'clientList' => $clientList,				'count' => $count,				'msg' => '' 		) );	}	function lockNoHttp() {		$lockNo = $this->get_args ( 'lockNo' ) ? $this->get_args ( 'lockNo' ) : "";		$page = $this->get_args ( 'page' ) && is_numeric ( $this->get_args ( 'page' ) ) ? $this->get_args ( 'page' ) : 1;		$size = $this->get_args ( 'size' ) && is_numeric ( $this->get_args ( 'size' ) ) ? $this->get_args ( 'size' ) : 10;				if (! empty ( $lockNo )) {			// Doo::loadModel("service_log");			// $service_log = new service_log ();			Doo::loadModel ( "longle" );			$longle = new longle ();						if ($page != 1)				$page = $page * $size - 1;			else				$page --;						$count = $longle->count ( array (					'limit' => $page . ',' . $size,					'where' => " key_num like '%" . $lockNo . "%' ",					'asArray' => true 			) );			$lockList = $longle->find ( array (					'limit' => $page . ',' . $size,					'where' => " key_num like '%" . $lockNo . "%' ",					'asArray' => true 			) );						echo json_encode ( array (					'status' => 1,					'lockList' => $lockList,					'count' => $count,					'msg' => '' 			) );			die ();		}		echo json_encode ( array (				'status' => 1,				'lockList' => array (),				'count' => 0,				'msg' => '' 		) );	}	function lockJournalHttp() {		$lid = $this->get_args ( 'lid' ) && is_numeric ( $this->get_args ( 'lid' ) ) ? $this->get_args ( 'lid' ) : 0;				if (! empty ( $lid )) {			Doo::loadModel ( "longle_log" );			$longleLog = new longle_log ();						$longleLogList = $longleLog->find ( array (					'where' => 'lid=' . $lid,					'asArray' => true 			) );						echo json_encode ( array (					'status' => 1,					'JournalList' => $longleLogList,					'msg' => '' 			) );			die ();		}		echo json_encode ( array (				'status' => 1,				'JournalList' => array (),				'msg' => '' 		) );	}	function districtDetailHttp() {		$dStr = $this->get_args ( 'dStr' ) ? $this->get_args ( 'dStr' ) : "";		$cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;		if (! empty ( $dStr )) {			Doo::loadModel ( 'district' );			Doo::loadModel ( 'client' );			$district = new district ();			$client = new client ();						$districtList = $district->find ( array (					'where' => 'id in(' . $dStr . ')',					'asArray' => true 			) );			$jsonString = array ();			foreach ( $districtList as $value ) {				array_push ( $jsonString, $value ['name'] );			}			$jsonString = implode ( ",", $jsonString );			if (! empty ( $jsonString ) && ! empty ( $cid )) {				$client->cid = $cid;				$client->local = $jsonString;				$client->update ();			}						echo json_encode ( array (					'status' => 1,					'districtList' => $jsonString,					'msg' => '' 			) );			die ();		}	}	function clientInfoHttp() {		$cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;		$clientname = $this->get_args ( 'clientname' ) ? $this->get_args ( 'clientname' ) : "";		$gender = $this->get_args ( 'gender' ) ? $this->get_args ( 'gender' ) : "";		$nicename = $this->get_args ( 'nicename' ) ? $this->get_args ( 'nicename' ) : "";		$telephone = $this->get_args ( 'telephone' ) ? $this->get_args ( 'telephone' ) : "";		$phone = $this->get_args ( 'phone' ) ? $this->get_args ( 'phone' ) : "";		$email = $this->get_args ( 'email' ) ? $this->get_args ( 'email' ) : "";		$unit = $this->get_args ( 'unit' ) ? $this->get_args ( 'unit' ) : "";		$fax = $this->get_args ( 'fax' ) ? $this->get_args ( 'fax' ) : "";		$webservice = $this->get_args ( 'webservice' ) ? $this->get_args ( 'webservice' ) : "";		$department = $this->get_args ( 'department' ) ? $this->get_args ( 'department' ) : "";		$position = $this->get_args ( 'position' ) ? $this->get_args ( 'position' ) : "";		$office = $this->get_args ( 'office' ) ? $this->get_args ( 'office' ) : "";		$address = $this->get_args ( 'address' ) ? $this->get_args ( 'address' ) : "";		$ride = $this->get_args ( 'ride' ) ? $this->get_args ( 'ride' ) : "";		$landmarks = $this->get_args ( 'landmarks' ) ? $this->get_args ( 'landmarks' ) : "";		$qq = $this->get_args ( 'qq' ) ? $this->get_args ( 'qq' ) : "";		$priority = $this->get_args ( 'priority' ) ? $this->get_args ( 'priority' ) : 5;		$stay = $this->get_args ( 'stay' ) ? $this->get_args ( 'stay' ) : "";		$mark = $this->get_args ( 'mark' ) ? $this->get_args ( 'mark' ) : "";				$lv21 = $this->get_args ( 'lv21' ) ? $this->get_args ( 'lv21' ) : 0;		$lv22 = $this->get_args ( 'lv22' ) ? $this->get_args ( 'lv22' ) : 0;		$lv23 = $this->get_args ( 'lv23' ) ? $this->get_args ( 'lv23' ) : 0;				if (! empty ( $cid ) && ! empty ( $clientname )) {						Doo::loadModel ( 'client' );			Doo::loadModel ( 'district' );			$district = new district ();			$client = new client ();			Doo::loadModel ( 'staff' );			$staff = new staff ();						$client->cid = $cid;			$client->clientname = $clientname;			if (! empty ( $gender ))				$client->gender = $gender;			if (! empty ( $nicename ))				$client->nicename = $nicename;			if (! empty ( $telephone ))				$client->telephone = $telephone;			if (! empty ( $phone ))				$client->phone = $phone;			if (! empty ( $email ))				$client->email = $email;						if (! empty ( $lv21 ) && ! empty ( $lv22 ) && ! empty ( $lv23 )) {				$client->district = $lv21 . "," . $lv22 . "," . $lv23;			}						if (! empty ( $client->district )) {				$districtList = $district->find ( array (						'where' => 'id in(' . $client->district . ')',						'asArray' => true 				) );				$jsonString = array ();				foreach ( $districtList as $value ) {					array_push ( $jsonString, $value ['name'] );				}				$jsonString = implode ( ",", $jsonString );				if (! empty ( $jsonString ))					$client->local = $jsonString;			}						if (! empty ( $fax ))				$client->fax = $fax;			if (! empty ( $webservice ))				$client->webservice = $webservice;			if (! empty ( $department ))				$client->department = $department;			if (! empty ( $position ))				$client->position = $position;			if (! empty ( $office ))				$client->office = $office;			if (! empty ( $address ))				$client->address = $address;			if (! empty ( $ride ))				$client->ride = $ride;			if (! empty ( $landmarks ))				$client->landmarks = $landmarks;			if (! empty ( $qq ))				$client->qq = $qq;			if (! empty ( $stay ))				$client->stay = $stay;			if (! empty ( $priority ))				$client->priority = $priority;			if (! empty ( $mark ))				$client->mark = $mark;						$client->updatetime = time ();			$client->update ();						Doo::loadClass ( 'XDeode' );			$XDeode = new XDeode ( 5 );			$sid = $XDeode->decode ( $_COOKIE ["staff"] );						$staffDetail = $staff->getOne ( array (					'where' => 'sid=' . $sid,					'asArray' => true 			) );						// 标签			$tid = $this->get_args ( 'tagALD' );			Doo::loadModel ( 'tag_client' );			// $strtid=implode(",", $tid);			$strtid = $tid;						$tagClient = new tag_client ();			$tagClientInfo = $tagClient->getTagClientBySCid ( $cid, $sid );						// $ar=explode(",", $strtid.','.$tagClientInfo['tag']);			// $re=array_filter(array_unique($ar));			// $tagClient->tag=implode(",", $re);			$tagClient->tag = $strtid;						if (! empty ( $tagClientInfo )) {				$tagClient->tcid = $tagClientInfo ['tcid'];				$tagClient->update ();			} else {								$tagClient->sid = $sid;				$tagClient->client = $cid;				$tagClient->insert ();			}						$tid = $this->get_args ( 'tooltiplist' );			// $k=implode(",", $tid);			$k = $tid;			Doo::loadModel ( 'C_tooltip' );						$s = " and cateid=" . $staffDetail ["cid"];						if (! empty ( $staffDetail ['othercid'] )) {				$othercid = explode ( ",", $staffDetail ['othercid'] );				foreach ( $othercid as $value ) {					$s .= " or cateid=" . $value;				}			}						// foreach ($cid as $key=>$value){			$C_tooltip = new C_tooltip ();			$tooltip = $C_tooltip->getOne ( array (					'where' => 'cid=' . $cid . " " . $s,					'asArray' => true 			) );						if (empty ( $tooltip )) {				$C_tooltip->cid = $cid;				$C_tooltip->name = $k;				$C_tooltip->cateid = $staffDetail ['cid'];				$C_tooltip->insert ();			} else {				$C_tooltip->tip = $tooltip ['tip'];				$C_tooltip->name = $k;				$C_tooltip->update ();			}			// }						$clientInfo = $client->getOne ( array (					'where' => ' cid=' . $cid,					'asArray' => true 			) );			// 日常行为			Doo::loadModel ( "action_log" );			$action_log = new action_log ();			$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'] . ')';			$action_log->updatetime = date ( "Y-m-d" );			$action_log->sid = $staffDetail ['sid'];			$action_log->cid = $staffDetail ['cid'];			$action_log->status = 2;			$action_log->time = date ( "H:i" );						$action_log->class = $action_log->iconContacts;						$action_log->districtid = $clientInfo ['district'];						$local = $district->getbyidlist ( $clientInfo ['district'] );			$action_log->city = $local [0] ['name'];			$action_log->province = $local [1] ['name'];						$action_log->company = $clientInfo ['companyname'];						Doo::loadModel ( 'company' );			$company = new company ();			$companyInfo = $company->getOne ( array (					'where' => ' companyname="' . $clientInfo ['companyname'] . '"',					'asArray' => true 			) );			$nature = explode ( ',', $companyInfo ['nature'] );			$action_log->nature = $nature [0];						$action_log->insert ();						echo json_encode ( array (					'status' => 1,					'msg' => '' 			) );			die ();		} else			echo json_encode ( array (					'status' => 2,					'msg' => '' 			) );		die ();	}	function serviceLogHttp() {		$status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : "";		$clientid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : "";		$mark = $this->get_args ( 'mark' ) ? $this->get_args ( 'mark' ) : "";				$m = $this->get_args ( 'm' ) ? $this->get_args ( 'm' ) : "";		$d = $this->get_args ( 'd' ) ? $this->get_args ( 'd' ) : "";		$y = $this->get_args ( 'y' ) ? $this->get_args ( 'y' ) : date ( "Y" );				$Remind = isset ( $_POST ['Remind'] ) ? $_POST ['Remind'] : 0;		$time = isset ( $_POST ['time'] ) ? $_POST ['time'] : 0;		$remark = isset ( $_POST ['remark'] ) ? $_POST ['remark'] : "";				// echo $mark;die;		if (! empty ( $status ) && ! empty ( $clientid )) {			Doo::loadModel ( 'service_log' );			Doo::loadModel ( 'client_staff' );						$clientStaff = new client_staff ();			$service_log = new service_log ();			Doo::loadModel ( "action_log" );			$action_log = new action_log ();			Doo::loadModel ( "client" );			$client = new client ();			Doo::loadModel ( 'staff' );			$staff = new staff ();						Doo::loadClass ( 'XDeode' );			$XDeode = new XDeode ( 5 );			$sid = $XDeode->decode ( $_COOKIE ["staff"] );						$staffDetail = $staff->getOne ( array (					'where' => 'sid=' . $sid,					'asArray' => true 			) );						$service_log->status = $status;			$service_log->clientid = $clientid;			$service_log->mark = htmlspecialchars ( $mark );			$service_log->date = $y . "-" . $m . "-" . $d;			$service_log->category = $staffDetail ['category'];			$service_log->staffname = $staffDetail ['username'];			$service_log->staffid = $staffDetail ['sid'];						$service_log->insert ();						// 日常行为						// 记录服务时间			$client->cid = $clientid;			$client->servicetime = time ();			$client->update ();						$clientInfo = $client->getOne ( array (					'where' => ' cid=' . $clientid,					'asArray' => TRUE 			) );			$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'] . ')添加新客户记录。';			$action_log->updatetime = date ( "Y-m-d" );						$action_log->sid = $staffDetail ['sid'];			$action_log->cid = $staffDetail ['cid'];						$action_log->time = date ( "H:i" );			$action_log->status = 3;						$action_log->districtid = $clientInfo ['district'];						Doo::loadModel ( 'district' );			$district = new district ();			$local = $district->getbyidlist ( $clientInfo ['district'] );			$action_log->city = $local [0] ['name'];			$action_log->province = $local [1] ['name'];						$action_log->company = $clientInfo ['companyname'];						Doo::loadModel ( 'company' );			$company = new company ();			$companyInfo = $company->getOne ( array (					'where' => ' companyname="' . $clientInfo ['companyname'] . '"',					'asArray' => true 			) );			$nature = explode ( ',', $companyInfo ['nature'] );			$action_log->nature = $nature [0];						$action_log->class = $action_log->iconContacts;			$action_log->insert ();						// 更新信息中心服务日志统计数量			$redis = new Redis ();			$redis->connect ( '127.0.0.1', '6379' );						$categoryCondition = " and cid=" . $staffDetail ['cid'];			$sidCondition = " and sid=" . $staffDetail ['sid'];			// actionlog免查询值 $alCondition='';			$alCondition = ' aid>' . REMIT . ' and ';						// 个人服务日志数量redis值			$redisKeyCS = date ( 'Y-m-d' ) . 'SL_' . $staffDetail ['cid'] . '_' . $staffDetail ['sid'];			$action_log = new action_log ();						$actionLogLongle = $action_log->find ( array (					'select' => 'date_format(updatetime,"%m-%d") as updatetime,COUNT(*) as count',					'where' => $alCondition . " status=3 " . $categoryCondition . $sidCondition . " and date_sub(curdate(), INTERVAL 30 DAY) <= date(updatetime)  ",					'groupby' => 'date_format(updatetime,"%m-%d")',					'asArray' => true 			) );						$statisticsLongle = array ();			for($d = 0; $d <= 29; $d ++) {				$MD = date ( "m-d", strtotime ( "-" . $d . " day" ) );				$falgLongle = true;								foreach ( $actionLogLongle as $value ) {					if ($value ['updatetime'] == $MD) {						array_push ( $statisticsLongle, $value ['count'] );						$falgLongle = false;						break;					}				}				if ($falgLongle)					array_push ( $statisticsLongle, 0 );			}			$statisticsLongle = array_reverse ( $statisticsLongle );			$jsl = json_encode ( $statisticsLongle );			$redis->set ( $redisKeyCS, $jsl );						// 办事处服务日志数量reids值			$redisKeyC = date ( 'Y-m-d' ) . 'SL_' . $staffDetail ['cid'] . '_';			$action_log = new action_log ();			$actionLogLongle = $action_log->find ( array (					'select' => 'date_format(updatetime,"%m-%d") as updatetime,COUNT(*) as count',					'where' => $alCondition . " status=3 " . $categoryCondition . " and date_sub(curdate(), INTERVAL 30 DAY) <= date(updatetime)  ",					'groupby' => 'date_format(updatetime,"%m-%d")',					'asArray' => true 			) );			$statisticsLongle = array ();			for($d = 0; $d <= 29; $d ++) {				$MD = date ( "m-d", strtotime ( "-" . $d . " day" ) );				$falgLongle = true;								foreach ( $actionLogLongle as $value ) {					if ($value ['updatetime'] == $MD) {						array_push ( $statisticsLongle, $value ['count'] );						$falgLongle = false;						break;					}				}				if ($falgLongle)					array_push ( $statisticsLongle, 0 );			}			$statisticsLongle = array_reverse ( $statisticsLongle );			$jsl = json_encode ( $statisticsLongle );			$redis->set ( $redisKeyC, $jsl );						// 全员处服务日志数量的redis值			$redisKey = date ( 'Y-m-d' ) . 'SL__';			$action_log = new action_log ();			$actionLogLongle = $action_log->find ( array (					'select' => 'date_format(updatetime,"%m-%d") as updatetime,COUNT(*) as count',					'where' => $alCondition . " status=3  and date_sub(curdate(), INTERVAL 30 DAY) <= date(updatetime)  ",					'groupby' => 'date_format(updatetime,"%m-%d")',					'asArray' => true 			) );			$statisticsLongle = array ();			for($d = 0; $d <= 29; $d ++) {				$MD = date ( "m-d", strtotime ( "-" . $d . " day" ) );				$falgLongle = true;								foreach ( $actionLogLongle as $value ) {					if ($value ['updatetime'] == $MD) {						array_push ( $statisticsLongle, $value ['count'] );						$falgLongle = false;						break;					}				}				if ($falgLongle)					array_push ( $statisticsLongle, 0 );			}			$statisticsLongle = array_reverse ( $statisticsLongle );			$jsl = json_encode ( $statisticsLongle );			$redis->set ( $redisKey, $jsl );						if (! empty ( $Remind )) {				Doo::loadModel ( 'remind' );				$remindObj = new remind ();								$datetime1 = new DateTime ( date ( 'Y-m-d' ) );				$datetime2 = new DateTime ( $time );				$interval = $datetime1->diff ( $datetime2 );								$remindObj->day = $interval->format ( '%a' );				$remindObj->remark = $remark;				$remindObj->time = date ( "Y-m-d" );				$remindObj->clientName = $clientInfo ['clientname'];				$remindObj->clientID = $clientid;				$remindObj->companyName = $clientInfo ['companyname'];				$remindObj->companyID = $companyInfo ['cid'];				$remindObj->staffID = $sid;				if ($status == 1)					$remindObj->class = "iconService";				if ($status == 2)					$remindObj->class = "iconPhone";				if ($status == 3)					$remindObj->class = "iconOther";				$remindObj->insert ();			}						echo json_encode ( array (					'status' => 1,					'msg' => '' 			) );			die ();		} else			echo json_encode ( array (					'status' => 2,					'msg' => '' 			) );		die ();	}	function updateCompanyHttp() {		$cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;		$companyname = $this->get_args ( 'companyName' ) ? $this->get_args ( 'companyName' ) : "";		$lv21 = $this->get_args ( 'lv21' ) ? $this->get_args ( 'lv21' ) : 0;		$lv22 = $this->get_args ( 'lv22' ) ? $this->get_args ( 'lv22' ) : 0;		$lv23 = $this->get_args ( 'lv23' ) ? $this->get_args ( 'lv23' ) : 0;				$nature = isset ( $_POST ['nature'] ) ? $_POST ['nature'] : false;				$fax = isset ( $_POST ['fax'] ) ? $_POST ['fax'] : false;		$webservice = isset ( $_POST ['webservice'] ) ? $_POST ['webservice'] : false;				$address = isset ( $_POST ['address'] ) ? $_POST ['address'] : false;		$ride = isset ( $_POST ['ride'] ) ? $_POST ['ride'] : false;		$stay = isset ( $_POST ['stay'] ) ? $_POST ['stay'] : false;		$landmarks = isset ( $_POST ['landmarks'] ) ? $_POST ['landmarks'] : false;				if (empty ( $cid ) || empty ( $companyname )) {			echo json_encode ( array (					'status' => 2,					'msg' => '' 			) );			die ();		}				Doo::loadModel ( "company" );		Doo::loadModel ( "client" );				$client = new client ();		$company = new company ();				Doo::loadClass ( 'XDeode' );		$XDeode = new XDeode ( 5 );		$sid = $XDeode->decode ( $_COOKIE ["staff"] );				$company->cid = $cid;				if (! empty ( $lv21 ) && ! empty ( $lv22 ) && ! empty ( $lv23 )) {						Doo::loadModel ( 'district' );			$district = new district ();						// 更新公司信息			$lv1 = $district->getbyid ( $lv21 );			$lv2 = $district->getbyid ( $lv22 );			$lv3 = $district->getbyid ( $lv23 );						$company->district = $lv21 . "," . $lv22 . "," . $lv23;			$company->local = $lv1 [0] ['name'] . "," . $lv2 [0] ['name'] . "," . $lv3 [0] ['name'];		}				if (! empty ( $companyname )) {			$company->companyname = $companyname;			$client->companyname = $companyname;		}				if ($fax !== false)			$company->fax = $fax;		if ($webservice !== false) {						$company->webservice = $webservice;		}		if ($address !== false)			$company->address = $address;		if ($ride !== false)			$company->ride = $ride;		if ($stay !== false)			$company->stay = $stay;		if ($landmarks !== false)			$company->landmarks = $landmarks;				$company->update ();		$client->update ( array (				'where' => ' companyid =' . $cid 		) );				// 标签		$tid = $this->get_args ( 'tagALD' );		Doo::loadModel ( 'tagCompanyNexus' );				$strtid = $tid;		$tagClient = new tagCompanyNexus ();		$tagClientInfo = $tagClient->getTagClientBySCid ( $cid, $sid );				$tagClient->tag = $strtid;		if (! empty ( $tagClientInfo )) {			$tagClient->tcid = $tagClientInfo ['tcid'];			$tagClient->update ();		} else {			$tagClient->sid = $sid;			$tagClient->company = $cid;			$tagClient->insert ();		}				echo json_encode ( array (				'status' => 1,				'msg' => '' 		) );		die ();	}	function searchCompanyHttp() {		$searchDbInforItem = $this->get_args ( 'searchDbInforItem' ) ? $this->get_args ( 'searchDbInforItem' ) : "";				if (! empty ( $searchDbInforItem )) {			Doo::loadModel ( 'company' );			$company = new company ();			$clientInfo = $company->searchCompany ( $searchDbInforItem );			echo json_encode ( array (					'status' => 1,					'companyList' => $clientInfo 			) );			die ();		} else			echo json_encode ( array (					'status' => 2,					'companyList' => '' 			) );		die ();	}	function changeCompanyHttp() {		$cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;				$clientID = $this->get_args ( 'clientID' ) ? $this->get_args ( 'clientID' ) : 0;				$companyname = $this->get_args ( 'companyName' ) ? $this->get_args ( 'companyName' ) : "";				Doo::loadModel ( 'company' );		Doo::loadModel ( 'client' );				$client = new client ();		$company = new company ();				$companyname = explode ( "-", $companyname );				if (isset ( $companyname [1] ))			$k = $company->getCompanyByName ( $companyname [0], $companyname [1] );		else			$k = array ();				if (! empty ( $cid ) && ! empty ( $k ) && ! empty ( $clientID )) {			$client->cid = $clientID;			$client->companyid = $cid;			$client->companyname = $companyname [0];						$client->update ();		} else {						$local1 = $this->get_args ( 'lv21' ) ? $this->get_args ( 'lv21' ) : 0;			$local2 = $this->get_args ( 'lv22' ) ? $this->get_args ( 'lv22' ) : 0;			$local3 = $this->get_args ( 'lv23' ) ? $this->get_args ( 'lv23' ) : 0;						Doo::loadModel ( 'district' );			$district = new district ();						// 更新公司信息			$lv1 = $district->getbyid ( $local1 );			$lv2 = $district->getbyid ( $local2 );			$lv3 = $district->getbyid ( $local3 );						if (empty ( $local1 ) || empty ( $local2 )) {				echo json_encode ( array (						'status' => 2,						'msg' => '' 				) );				die ();			}						if (! empty ( $local1 ) && ! empty ( $local2 ))				$company->local = $lv1 [0] ['name'] . "," . $lv2 [0] ['name'] . "," . $lv3 [0] ['name'];						if (! empty ( $local1 ) && ! empty ( $local2 ))				$company->district = $local1 . "," . $local2 . "," . $local3;						$nature = $this->get_args ( 'nature' ) ? $this->get_args ( 'nature' ) : "";			$fax = $this->get_args ( 'fax' ) ? $this->get_args ( 'fax' ) : "";			$webservice = $this->get_args ( 'webservice' ) ? $this->get_args ( 'webservice' ) : "";			$address = $this->get_args ( 'address' ) ? $this->get_args ( 'address' ) : "";			$landmarks = $this->get_args ( 'landmarks' ) ? $this->get_args ( 'landmarks' ) : "";			$stay = $this->get_args ( 'stay' ) ? $this->get_args ( 'stay' ) : "";			$ride = $this->get_args ( 'ride' ) ? $this->get_args ( 'ride' ) : "";						// $nature=implode(",", $nature);						$company->companyname = $companyname [0];			$company->ride = $ride;			$company->fax = $fax;						$company->webservice = $webservice;						$company->address = $address;			$company->landmarks = $landmarks;			$company->stay = $stay;						$company->nature = $nature;			$cid = $company->insert ();						$client->cid = $clientID;			$client->companyid = $cid;			$client->companyname = $companyname [0];						$client->update ();		}		echo json_encode ( array (				'status' => 1,				'msg' => '' 		) );		die ();	}	function getProudctHttp() {		Doo::loadModel ( 'product' );		$product = new product ();				$product = $product->getProudct ();		echo json_encode ( array (				'status' => 1,				'product' => $product 		) );	}	function getClientHttp() {		$searchDbInforItem = $this->get_args ( 'searchDbInforItem' ) ? $this->get_args ( 'searchDbInforItem' ) : "";				if (! empty ( $searchDbInforItem )) {			Doo::loadModel ( 'client' );			$client = new client ();			$clientInfo = $client->getClientByName ( $searchDbInforItem );			echo json_encode ( array (					'status' => 1,					'client' => $clientInfo 			) );		} else			echo json_encode ( array (					'status' => 2,					'client' => array () 			) );	}	function getLongleHttp() {		$searchDbInforItem = $this->get_args ( 'searchDbInforItem' ) ? $this->get_args ( 'searchDbInforItem' ) : "";				if (! empty ( $searchDbInforItem )) {						Doo::loadModel ( 'longle' );			$longle = new longle ();			$longleInfo = $longle->getLongleBykeynum2 ( $searchDbInforItem );			echo json_encode ( array (					'status' => 1,					'longle' => $longleInfo 			) );		} else {			echo json_encode ( array (					'status' => 2,					'longle' => array () 			) );		}	}	function getLongleIdHttp() {		$id = $this->get_args ( 'id' ) ? $this->get_args ( 'id' ) : "";				if (! empty ( $id )) {						Doo::loadModel ( 'longle' );			$longle = new longle ();			$longleInfo = $longle->getOne ( array (					'where' => 'lid =' . $id,					'asArray' => true 			) );			echo json_encode ( array (					'status' => 1,					'longle' => $longleInfo 			) );		} else {			echo json_encode ( array (					'status' => 2,					'longle' => array () 			) );		}	}	function addLockLogHttp() {		Doo::loadModel ( 'longle_log' );		Doo::loadModel ( 'longle' );		Doo::loadModel ( "action_log" );		Doo::loadModel ( 'client' );		$clientobj = new client ();		$longle = new longle ();		$longle_log = new longle_log ();		Doo::loadModel ( 'district' );		$district = new district ();		Doo::loadModel ( 'staff' );		$staff = new staff ();				Doo::loadClass ( 'XDeode' );		$XDeode = new XDeode ( 5 );		$sid = $XDeode->decode ( $_COOKIE ["staff"] );				$status = $this->get_args ( 'longleStatus' ) ? $this->get_args ( 'longleStatus' ) : 0;		$lid = $this->get_args ( 'klid' ) ? $this->get_args ( 'klid' ) : 0;				if (empty ( $lid )) {			echo json_encode ( array (					'status' => 2,					'msg' => '' 			) );			die ();		}				$linfo = $longle->getLongleByLid ( $lid );		$this->staff = $staff->find ( array (				'where' => 'sid=' . $sid,				'asArray' => true 		) );				if ($status == 0) {			echo json_encode ( array (					'status' => 2,					'msg' => '' 			) );			die ();		} elseif ($status == 3) {						$client = $this->get_args ( 'browseClient' ) ? $this->get_args ( 'browseClient' ) : "";			$client = explode ( '-', $client );						$product = isset ( $_POST ['browseProduct'] ) ? $_POST ['browseProduct'] : "";						$clientname = $clientobj->getClientByName2 ( $client [0], $client [1] );						if (empty ( $clientname )) {				echo json_encode ( array (						'status' => 2,						'msg' => '' 				) );				die ();			}						if ($client [0] != "") {				$longle->client = $client [0];				$longle->clientid = $clientname [0] ['cid'];			}			// if($product!="")			// $longle->product=$product;						$longle->statusT = "借出";						$longle_log->client = $client [0];			$longle_log->clientid = $clientname [0] ['cid'];			$longle_log->product = $linfo [0] ['product'];			$longle_log->statusT = "借出";			// 日常行为			$action_log = new action_log ();						$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'] . ')';			$action_log->sid = $this->staff [0] ['sid'];			$action_log->cid = $this->staff [0] ['cid'];			$action_log->updatetime = date ( "Y-m-d" );			$action_log->time = date ( "H:i" );			$action_log->status = 4;			$action_log->districtid = $clientname [0] ['district'];						$local = $district->getbyidlist ( $clientname [0] ['district'] );			$action_log->city = $local [0] ['name'];			$action_log->province = $local [1] ['name'];			$action_log->company = $clientname [0] ['companyname'];						Doo::loadModel ( 'company' );			$company = new company ();			$companyInfo = $company->getOne ( array (					'where' => ' companyname="' . $clientname [0] ['companyname'] . '"',					'asArray' => true 			) );			$nature = explode ( ',', $companyInfo ['nature'] );			$action_log->nature = $nature [0];						$action_log->class = $action_log->iconBorrow;						$action_log->insert ();		} elseif ($status == 4) {						// $sellClient =						$product = isset ( $_POST ['sellProduct'] ) ? $_POST ['sellProduct'] : "";			$client = $this->get_args ( 'sellClient' ) ? $this->get_args ( 'sellClient' ) : ""; // isset($_POST['sellClient'])?$_POST['sellClient']:"";			$client = explode ( '-', $client );						$clientname = $clientobj->getClientByName2 ( $client [0], $client [1] );						if (empty ( $clientname )) {				echo json_encode ( array (						'status' => 2,						'msg' => 'not found client' 				) );				die ();			}			if ($client [0] != "") {				$longle->client = $client [0];				$longle->clientid = $clientname [0] ['cid'];			}			// if($product!="")			// $longle->product=$product;						$longle->statusT = "销售";						$longle_log->client = $client [0];			$longle_log->clientid = $clientname [0] ['cid'];			$longle_log->product = $linfo [0] ['product'];			$longle_log->statusT = "销售";						// 日常行为			$action_log = new action_log ();						$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'] . ')';			$action_log->sid = $this->staff [0] ['sid'];			$action_log->cid = $this->staff [0] ['cid'];			$action_log->updatetime = date ( "Y-m-d" );			$action_log->time = date ( "H:i" );			$action_log->status = 5;			$action_log->districtid = $clientname [0] ['district'];						$local = $district->getbyidlist ( $clientname [0] ['district'] );			$action_log->city = $local [0] ['name'];			$action_log->province = $local [1] ['name'];			$action_log->company = $clientname [0] ['companyname'];						Doo::loadModel ( 'company' );			$company = new company ();			$companyInfo = $company->getOne ( array (					'where' => ' companyname="' . $clientname [0] ['companyname'] . '"',					'asArray' => true 			) );			$nature = explode ( ',', $companyInfo ['nature'] );			$action_log->nature = $nature [0];						$action_log->class = $action_log->iconSell;						$action_log->insert ();		} elseif ($status == 5) {						$product = isset ( $_POST ['newProduct'] ) ? $_POST ['newProduct'] : "";						if ($product != "")				$longle->product = $linfo [0] ['product'] . "+" . $product;						$longle->statusT = "升级";			$longle_log->product = $linfo [0] ['product'] . "+" . $product;			$longle_log->statusT = "升级";						$longle_log->client = $linfo [0] ['client'];			$longle_log->clientid = $linfo [0] ['clientid'];						$clientname = $clientobj->getOne ( array (					'where' => "cid= '" . $linfo [0] ['clientid'] . "'",					'asArray' => TRUE 			) );			// 日常行为			$action_log = new action_log ();						$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>';			$action_log->sid = $this->staff [0] ['sid'];			$action_log->cid = $this->staff [0] ['cid'];			$action_log->updatetime = date ( "Y-m-d" );			$action_log->time = date ( "H:i" );			$action_log->class = $action_log->iconUpdate;			$action_log->sid = $this->staff [0] ['sid'];			$action_log->cid = $this->staff [0] ['cid'];			$action_log->status = 7;						$action_log->insert ();		} elseif ($status == 6) {						$key_num = isset ( $_POST ['key_num'] ) ? $_POST ['key_num'] : "";			$key_num2 = explode ( "-", $key_num );			$key_num = $key_num2 [0] . "-" . $key_num2 [1];						// if($key_num!="")			// $longle->key_num=$key_num;						// 新锁拷贝记录			$newLongle = new longle ();			$newLongle->product = $linfo [0] ['product'];			$newLongle->statusT = "更换";			$newLongle->status = 6;			$newLongle->client = $linfo [0] ['client'];			$newlid = $newLongle->update ( array (					'where' => ' key_num= \'' . $key_num . "'" 			) );			$longleinfo = $longle->getOne ( array (					'where' => ' key_num =\'' . $key_num . "'",					'asArray' => true 			) );						// 新记录日志			$newlongle_log = new longle_log ();			$newlongle_log->statusT = "更换";			$newlongle_log->status = 6;			$newlongle_log->client = $linfo [0] ['client'];			$newlongle_log->new_key_num = $linfo [0] ['key_num'];			$newlongle_log->product = $linfo [0] ['product'];			$newlongle_log->category = $this->staff [0] ['category'];			$newlongle_log->dateline = date ( "Y-m-d" );			$newlongle_log->operator = $this->staff [0] ['username'];			$newlongle_log->lid = $longleinfo ['lid'];			$newlongle_log->insert ();						// 新锁状态拷贝			$longle->statusT = "更换";						$longle_log->new_key_num = $key_num;			$longle_log->statusT = "更换";						$longle_log->client = $linfo [0] ['client'];						$clientname = $clientobj->getOne ( array (					'where' => "cid= '" . $linfo [0] ['clientid'] . "'",					'asArray' => TRUE 			) );			// 日常行为			$action_log = new action_log ();						$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'] . ')';			$action_log->sid = $this->staff [0] ['sid'];			$action_log->cid = $this->staff [0] ['cid'];			$action_log->updatetime = date ( "Y-m-d" );			$action_log->time = date ( "H:i" );			$action_log->class = $action_log->iconReplace;			$action_log->sid = $this->staff [0] ['sid'];			$action_log->cid = $this->staff [0] ['cid'];			$action_log->status = 8;						$action_log->insert ();		} elseif ($status == 7) {						$longle->statusT = "收回";			$longle_log->statusT = "收回";			$longle_log->responsible = $linfo [0] ['responsible'];						// 日常行为			$action_log = new action_log ();			$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>';			$action_log->sid = $this->staff [0] ['sid'];			$action_log->cid = $this->staff [0] ['cid'];			$action_log->updatetime = date ( "Y-m-d" );			$action_log->time = date ( "H:i" );			$action_log->class = $action_log->iconRecycle;			$action_log->sid = $this->staff [0] ['sid'];			$action_log->cid = $this->staff [0] ['cid'];			$action_log->status = 9;						$action_log->insert ();		} elseif ($status == 8) {						$mark = isset ( $_POST ['mark'] ) ? $_POST ['mark'] : "";			$longle_log->mark = $mark;						// 日常行为			$action_log = new action_log ();						$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>添加新备注。';			$action_log->sid = $this->staff [0] ['sid'];			$action_log->cid = $this->staff [0] ['cid'];			$action_log->updatetime = date ( "Y-m-d" );			$action_log->time = date ( "H:i" );			$action_log->sid = $this->staff [0] ['sid'];			$action_log->cid = $this->staff [0] ['cid'];			$action_log->status = 10;						$action_log->class = $action_log->iconLock;						$action_log->insert ();		} elseif ($status == 9) {			$longle->statusT = "赠送";			$longle_log->statusT = "赠送";			$client = isset ( $_POST ['giftClient'] ) ? $_POST ['giftClient'] : "";			$client = explode ( '-', $client );			$clientname = $clientobj->getClientByName2 ( $client [0], $client [1] );						if (empty ( $clientname )) {				echo json_encode ( array (						'status' => 2,						'msg' => '' 				) );				die ();			}						if ($client [0] != "") {				$longle->client = $client [0];				$longle->clientid = $clientname [0] ['cid'];			}			$longle_log->client = $client [0];			$longle_log->clientid = $clientname [0] ['cid'];			// 日常行为			$action_log = new action_log ();			$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'] . ')';			$action_log->updatetime = date ( "Y-m-d" );			$action_log->time = date ( "H:i" );			$action_log->class = $action_log->iconRecycle;			$action_log->sid = $this->staff [0] ['sid'];			$action_log->cid = $this->staff [0] ['cid'];			$action_log->status = 6;						$action_log->districtid = $clientname [0] ['district'];						$local = $district->getbyidlist ( $clientname [0] ['district'] );			$action_log->city = $local [0] ['name'];			$action_log->province = $local [1] ['name'];			$action_log->company = $clientname [0] ['companyname'];						Doo::loadModel ( 'company' );			$company = new company ();			$companyInfo = $company->getOne ( array (					'where' => ' companyname="' . $clientname [0] ['companyname'] . '"',					'asArray' => true 			) );			$nature = explode ( ',', $companyInfo ['nature'] );			$action_log->nature = $nature [0];						$action_log->insert ();		}				// 记录使用过的状态				$statuslog = $status . "," . $linfo [0] ['statuslog'];		$ar = explode ( ',', $statuslog );		$statuslog = implode ( ',', array_unique ( array_filter ( $ar ) ) );		$longle->statuslog = $statuslog;				if ($linfo [0] ['status'] <= 2) {			if ($status >= 4 && $status <= 2) {				echo json_encode ( array (						'status' => 1,						'msg' => '' 				) );				die ();			}		}				if ($lid != 0) {						$longle->lid = $lid;			if ($status != 8)				$longle->status = $status;								// if($status!=8)			$longle->responsible = $this->staff [0] ['username'];						$longle->update ();		}				$longle_log->lid = $lid;		$longle_log->status = $status;		$longle_log->operator = $this->staff [0] ['username'];				// 责任人				$longle_log->category = $this->staff [0] ['category'];		$longle_log->dateline = date ( "Y-m-d" );		$longle_log->insert ();				echo json_encode ( array (				'status' => 1,				'msg' => '' 		) );		die ();	}	function getClientByPhoneHttp() {		$phone = $this->get_args ( 'phone' ) ? $this->get_args ( 'phone' ) : '';				if (! empty ( $phone )) {			Doo::loadModel ( 'client' );			$client = new client ();			Doo::loadModel ( 'district' );			$district = new district ();						$con = "";			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 )) {				$con = 'telephone like "%' . $phone . '"';			} elseif (preg_match ( "/^(0(10|21|22|23|[1-9][0-9]{2})(-|))?[0-9]{7,8}$/", $phone )) {				if (strlen ( $phone ) == 10) {					$phone = substr ( $phone, 3 );					$con = 'phone like "%' . $phone . '"';				} elseif (strlen ( $phone ) == 11) {					$phone = substr ( $phone, 4 );					$con = 'phone like "%' . $phone . '"';				} elseif (strlen ( $phone ) == 12) {					$phone = substr ( $phone, 5 );					$con = 'phone like "%' . $phone . '"';				} else {					$con = 'telephone like "%' . $phone . '" or phone like "%' . $phone . '"';				}			} else {				$con = 'telephone like "%' . $phone . '" or phone like "%' . $phone . '"';			}						$info = $client->getOne ( array (					'where' => $con,					'asArray' => true 			) );			$d = $district->find ( array (					'select' => 'name',					'where' => 'id in(' . $info ['district'] . ')',					'asArray' => true 			) );			$info ['local'] = $d;			echo json_encode ( array (					'status' => 1,					'info' => $info 			) );			die ();		}		echo json_encode ( array (				'status' => 2,				'info' => '' 		) );		die ();	}	function informationHttp() {		$sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;		$DATE = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : date ( "Y-m-d" );		// $month=$this->get_args('month')?$this->get_args('month'):date('m');		$status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 0;		$dateType = $this->get_args ( 'dateType' ) ? $this->get_args ( 'dateType' ) : 0;				Doo::loadModel ( 'action_log' );		$action_log = new action_log ();		Doo::loadModel ( 'staff' );		$staff = new staff ();		Doo::loadModel ( 'client_staff' );		$client_staff = new client_staff ();		Doo::loadModel ( 'longle' );		$longle = new longle ();		Doo::loadModel ( 'L_category' );		$lcategory = new L_category ();				$condition = "";		$limit = 50;				if (! empty ( $sid ))			$condition .= " and sid=" . $sid;		if (! empty ( $status ))			$condition .= " and status in (" . $status . ")";		if (empty ( $dateType ))			$condition .= ' and date(updatetime) >= date_sub("' . $DATE . '",interval 30 day) and date(updatetime) <=  date_sub("' . $DATE . '",interval 0 day)';		else			$condition .= ' and updatetime = ' . $DATE . ' ';				$actionLogList = $action_log->find ( array (				'where' => ' 1 ' . $condition . '  ',				'desc' => 'aid',				'asArray' => true 		) );				// 抽取日期 ,'groupby'=>'updatetime'		$dateLog = $action_log->find ( array (				'select' => 'updatetime',				'where' => ' 1 ' . $condition . ' and date(updatetime) >= date_sub("' . $DATE . '",interval 30 day) and date(updatetime) <=  date_sub("' . $DATE . '",interval 0 day)   ',				'limit' => 50,				'desc' => 'aid',				'asArray' => true 		) );				$count = $action_log->count ( array (				'where' => ' 1 ' . $condition,				'limit' => $limit,				'asArray' => true 		) );				$dl = array ();		foreach ( $dateLog as $value ) {			array_push ( $dl, $value ['updatetime'] );		}				$dateLog = array_unique ( $dl );		$log = array ();		foreach ( $dateLog as $key => $value ) {			$log [$value] = array ();			foreach ( $actionLogList as $k => $v ) {				if ($value == $v ['updatetime']) {					array_push ( $log [$value], $v );					unset ( $actionLogList [$k] );				}			}		}				$i = 0;		foreach ( $log as $key => $value ) {						if (empty ( $value ))				unset ( $log [$key] );						if ($i >= 3)				unset ( $log [$key] );			$i ++;		}				echo json_encode ( array (				'status' => 1,				'count' => $count,				'list' => $log 		) );		die ();	}	function communicationHttp() {		Doo::loadModel ( 'staff' );		$staff = new staff ();				$list = $staff->find ( array (				'where' => "username!= 'admin'",				'asArray' => TRUE 		) );		echo json_encode ( array (				'status' => 1,				'list' => $list 		) );		die ();	}	function getStaffHttp() {		$sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;				Doo::loadModel ( 'staff' );		$staff = new staff ();				if (! empty ( $sid )) {			$info = $staff->getOne ( array (					'where' => "username!= 'admin' and sid='" . $sid . "'",					'asArray' => TRUE 			) );			$colleague = $staff->find ( array (					'where' => "cid= '" . $info ['cid'] . "' and sid!='" . $info ['sid'] . "'",					'asArray' => TRUE 			) );			array_push ( $colleague, $info );			echo json_encode ( array (					'status' => 1,					'list' => $colleague 			) );			die ();		}		echo json_encode ( array (				'status' => 2,				'list' => array () 		) );		die ();	}	function getUserHttp() {		$sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;				Doo::loadModel ( 'staff' );		$staff = new staff ();				if (! empty ( $sid )) {			$info = $staff->getOne ( array (					'where' => "username!= 'admin' and sid='" . $sid . "'",					'asArray' => TRUE 			) );			echo json_encode ( array (					'status' => 1,					'list' => $info 			) );			die ();		}		echo json_encode ( array (				'status' => 2,				'list' => array () 		) );		die ();	}	function editStaffHttp() {		$telephone = $this->get_args ( 'telephone' ) ? $_POST ['telephone'] : 0;				$phone = $this->get_args ( 'phone' ) ? $_POST ['phone'] : 0;		$email = isset ( $_POST ['email'] ) ? $_POST ['email'] : "";				$qq = is_numeric ( $this->get_args ( 'qq' ) ) ? $_POST ['qq'] : 0;		$year = $this->get_args ( 'year' ) ? $_POST ['year'] : date ( "Y" );		$month = $this->get_args ( 'month' ) ? $_POST ['month'] : "";		$day = $this->get_args ( 'day' ) ? $_POST ['day'] : "";		$position = $this->get_args ( 'position' ) ? $_POST ['position'] : "";				$gender = $this->get_args ( 'gender' ) ? $_POST ['gender'] : "男";				$oldpassword = isset ( $_POST ['oldpassword'] ) ? $_POST ['oldpassword'] : "";				$newpassword = isset ( $_POST ['newpassword'] ) ? $_POST ['newpassword'] : "";		$rnewpassword = isset ( $_POST ['rnewpassword'] ) ? $_POST ['rnewpassword'] : "";				Doo::loadModel ( 'staff' );		$staff = new staff ();		Doo::loadModel ( 'staffDynamic' );		$staffDynamic = new staffDynamic ();				Doo::loadClass ( 'XDeode' );		$XDeode = new XDeode ( 5 );		$sid = $XDeode->decode ( $_COOKIE ["staff"] );				$this->staff = $staff->find ( array (				'where' => "sid='" . $sid . "'",				'asArray' => TRUE 		) );				$staff->sid = $this->staff [0] ['sid'];				$content = "";		$ext = "更新了他的";		if ($telephone != 0 && $this->staff [0] ['telephone'] != $telephone) {			$staff->telephone = $telephone;			$content .= "<b>手机</b> ";		}		if ($phone != 0 && $this->staff [0] ['phone'] != $phone) {			$staff->phone = $phone;			$content .= "<b>电话</b> ";		}				if ($qq != 0 && $this->staff [0] ['qq'] != $qq) {			$staff->qq = $qq;			$content .= "<b>QQ</b> ";		}		if ($year != 2014) {			$staff->birthday = $year . "-" . $month . "-" . $day;			$content .= "<b>生日</b> ";		}		if ($email != "" && filter_var ( $email, FILTER_VALIDATE_EMAIL ) && $this->staff [0] ['email'] != $email) {			$staff->email = $email;			$content .= "<b>邮箱</b> ";		}		if (! empty ( $position )) {			$staff->position = $position;			$content .= "<b>职位</b> ";		}				$staff->gender = $gender;				$msg = "更新成功";				if ($this->staff [0] ['passwork'] == md5 ( $oldpassword )) {			if ($newpassword == $rnewpassword && (! empty ( $newpassword )))				$staff->passwork = md5 ( $newpassword );			else				$msg = "密码不一致";		} else {			if ($oldpassword != "")				$msg = "密码错误";		}				if (! empty ( $content )) {			$staffDynamic->content = $ext . $content;			$staffDynamic->cid = $this->staff [0] ['cid'];			$staffDynamic->category = $this->staff [0] ['category'];			$staffDynamic->time = time ();			$staffDynamic->sid = $this->staff [0] ['sid'];			$staffDynamic->staff = $this->staff [0] ['username'];			$staffDynamic->insert ();		}				$fileName = 'avatar_' . $this->staff [0] ['sid'];		$t = DOO::conf ()->SITE_PATH . "global/avatar/";		if (isset ( $_FILES ['photo100'] )) {			$file = $_FILES ['photo100'] ['tmp_name'];			if (is_uploaded_file ( $file )) {				$upload_file = 'avatar_' . $this->staff [0] ['sid'] . "_1.jpg";				move_uploaded_file ( $file, $t . $upload_file );			}		}				if (isset ( $_FILES ['photo50'] )) {			$file2 = $_FILES ['photo50'] ['tmp_name'];			if (is_uploaded_file ( $file2 )) {				$upload_file = 'avatar_' . $this->staff [0] ['sid'] . "_2.jpg";				move_uploaded_file ( $file2, $t . $upload_file );			}		}				if (isset ( $_FILES ['photo32'] )) {			$file3 = $_FILES ['photo32'] ['tmp_name'];			if (is_uploaded_file ( $file3 )) {				$upload_file = 'avatar_' . $this->staff [0] ['sid'] . "_3.jpg";				move_uploaded_file ( $file3, $t . $upload_file );			}		}				// echo $_FILES['photo50']['tmp_name'];		// var_dump($_FILES['photo32']['tmp_name']);		$staff->avatar = "/global/avatar/" . $fileName;		$staff->update ( array (				'where' => ' sid=' . $this->staff [0] ['sid'] 		) );		// phpinfo();		echo json_encode ( array (				'status' => 1,				'msg' => '' 		) );		die ();	}	function getRemindHttp() {		Doo::loadModel ( 'remind' );		$remind = new remind ();				Doo::loadClass ( 'XDeode' );		$XDeode = new XDeode ( 5 );		$sid = $XDeode->decode ( $_COOKIE ["staff"] );				// Doo::loadModel ( 'client' );		// $client = new client();		// and date_add(time, INTERVAL day DAY) <= CURDATE()		$remindList = $remind->find ( array (				'where' => "staffID = '" . $sid . "' and status=0 ",				'asc' => 'date_add(time, INTERVAL day DAY)',				'asArray' => TRUE 		) );		$rc = 0;		foreach ( $remindList as $key => $value ) {			$a = strtotime ( $value ['time'] . " +" . $value ['day'] . " days" );			$b = strtotime ( date ( 'y-m-d' ) );			if ($a <= $b) {				$rc ++;				$remindList [$key] ['isRemind'] = 1;			} else				$remindList [$key] ['isRemind'] = 0;				// $remindList[$key]['clientInfo']=$client->getOne(array('where' => "cid = '".$value["clientID"]."'",'asArray' => TRUE));			$remindList [$key] ['Ctime'] = date ( 'm-d', strtotime ( $value ['time'] ) );			$remindList [$key] ['Etime'] = date ( 'm-d', strtotime ( $value ['time'] . " +" . $value ['day'] . " days" ) );		}		echo json_encode ( array (				'status' => 1,				'remindList' => $remindList,				'remindCount' => $rc,				'msg' => '' 		) );		die ();	}	function remindCLHttp() {		$rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;		if (! empty ( $rid )) {			Doo::loadModel ( 'remind' );			$remind = new remind ();						Doo::loadClass ( 'XDeode' );			$XDeode = new XDeode ( 5 );			$sid = $XDeode->decode ( $_COOKIE ["staff"] );						$remind->status = 1;			$remind->update ( array (					'where' => "staffID = '" . $sid . "' and rid=" . $rid,					'asArray' => TRUE 			) );						echo json_encode ( array (					'status' => 1,					'msg' => '' 			) );			die ();		}		echo json_encode ( array (				'status' => 2,				'msg' => '' 		) );		die ();	}	function addClientHttp() {				$clientname = $this->get_args ( 'clientname' ) ? $this->get_args ( 'clientname' ) : "";		$gender = $this->get_args ( 'gender' ) ? $this->get_args ( 'gender' ) : "";		$nicename = $this->get_args ( 'nicename' ) ? $this->get_args ( 'nicename' ) : "";		$telephone = $this->get_args ( 'telephone' ) ? $this->get_args ( 'telephone' ) : "";		$phone = $this->get_args ( 'phone' ) ? $this->get_args ( 'phone' ) : "";		$email = $this->get_args ( 'email' ) ? $this->get_args ( 'email' ) : "";		$qq = $this->get_args ( 'qq' ) ? $this->get_args ( 'qq' ) : "";		$tid = $this->get_args ( 'tid' ) ? $this->get_args ( 'tid' ) : "";		$companyname = $this->get_args ( 'companyname' ) ? $this->get_args ( 'companyname' ) : "";				$local1 = $this->get_args ( 'lv21' ) ? $this->get_args ( 'lv21' ) : "";		$local2 = $this->get_args ( 'lv22' ) ? $this->get_args ( 'lv22' ) : "";		$local3 = $this->get_args ( 'lv23' ) ? $this->get_args ( 'lv23' ) : "";				$nature = $this->get_args ( 'nature' ) ? $this->get_args ( 'nature' ) : "";				$fax = $this->get_args ( 'fax' ) ? $this->get_args ( 'fax' ) : "";		$webservice = $this->get_args ( 'webservice' ) ? $this->get_args ( 'webservice' ) : "";		$department = $this->get_args ( 'department' ) ? $this->get_args ( 'department' ) : "";		$position = $this->get_args ( 'position' ) ? $this->get_args ( 'position' ) : "";		$office = $this->get_args ( 'office' ) ? $this->get_args ( 'office' ) : "";		$address = $this->get_args ( 'address' ) ? $this->get_args ( 'address' ) : "";		$ride = $this->get_args ( 'ride' ) ? $this->get_args ( 'ride' ) : "";		$landmarks = $this->get_args ( 'landmarks' ) ? $this->get_args ( 'landmarks' ) : "";		$priority = $this->get_args ( 'priority' ) ? $this->get_args ( 'priority' ) : "1";		$stay = $this->get_args ( 'stay' ) ? $this->get_args ( 'stay' ) : "";		$mark = $this->get_args ( 'mark' ) ? $this->get_args ( 'mark' ) : "";				$clientname = trim ( $clientname );				$companyname = trim ( $companyname );						Doo::loadModel ( 'staff' );		$staff = new staff ();		$this->staff = $staff->getUserByIdList ( $_COOKIE ["staff"] );				if (empty ( $companyname ))			return "/contacts";				if (empty ( $this->staff [0] ['sid'] ))			return "/contacts";				if (! empty ( $clientname )) {						// 相同的公司和客户			Doo::loadModel ( 'company' );			$company = new company ();			Doo::loadModel ( 'client' );			$client = new client ();						$redis = new Redis ();			$redis->connect ( '127.0.0.1', '6379' );						$cinfo = $client->getClientByNameT ( $clientname );			if (! empty ( $cinfo )) {				$ninfo = $company->getCompanyByCompanyname ( $companyname );				if (! empty ( $ninfo )) {					foreach ( $cinfo as $key => $value ) { // 问题						if ($value ['companyid'] == $ninfo [0] ['cid'])							return "/contacts";					}				}			}						Doo::loadModel ( 'district' );			$district = new district ();						$companyInfo = $company->getOne ( array (					'where' => "companyname = '" . $companyname . "'",					"asArray" => true 			) );						// 更新公司信息			$lv1 = $district->getbyid ( $local1 );			$lv2 = $district->getbyid ( $local2 );			$lv3 = $district->getbyid ( $local3 );						if (empty ( $lv1 ))				$lv1 [0] ['name'] = "";						if (empty ( $lv2 ))				$lv2 [0] ['name'] = "";			if (empty ( $lv3 ))				$lv3 [0] ['name'] = "";						if (! empty ( $local1 ) && ! empty ( $local2 ))				$company->local = $lv1 [0] ['name'] . "," . $lv2 [0] ['name'] . "," . $lv3 [0] ['name'];						if (! empty ( $nature ))				$company->nature = implode ( ',', $nature );						if (! empty ( $fax ))				$company->fax = $fax;						if (! empty ( $webservice ))				$company->webservice = $webservice;						if (! empty ( $address ))				$company->address = $address;						if (! empty ( $ride ))				$company->ride = $ride;						if (! empty ( $landmarks ))				$company->landmarks = $landmarks;						if (! empty ( $office ))				$company->office = $office;						if (! empty ( $local1 ) && ! empty ( $local2 ))				$company->district = $local1 . "," . $local2 . "," . $local3;						if (! empty ( $stay ))				$company->stay = $stay;						if (empty ( $companyInfo )) {								$company->companyname = $companyname;								$company->staffid = $this->staff [0] ['sid'];								$cid = $company->insert ();			} else { // 不编辑公司,地区判断,作为新公司			  				$diqu = $local1 . "," . $local2 . "," . $local3;				$cid = $companyInfo ['cid'];				$company2 = new company ();				$companyList = $company2->find ( array (						'where' => " companyname like '" . $companyname . "'",						"asArray" => true 				) );								$falg = false;				// print_r($companyList);				foreach ( $companyList as $key => $value ) {					if ($value ['district'] != $diqu) {						$falg = true;					} elseif ($value ['district'] == $diqu) {						$falg = false;						$cid = $value ['cid'];						break;					}				}								if ($falg) {					$company->companyname = $companyname;					$company->staffid = $this->staff [0] ['sid'];					$cid = $company->insert ();				}			}						Doo::loadModel ( 'client_staff' );			$client_staff = new client_staff ();						$client->clientname = $clientname;			$client->gender = $gender;			$client->priority = $priority;						if (! empty ( $nicename ))				$client->nicename = $nicename;			if (! empty ( $telephone ))				$client->telephone = $telephone;			if (! empty ( $phone ))				$client->phone = $phone;			if (! empty ( $email ))				$client->email = $email;			if (! empty ( $qq ) && is_numeric ( $qq ))				$client->qq = $qq;						$client->companyid = $cid;			$client->companyname = $companyname;			$client->district = $local1 . "," . $local2 . "," . $local3;						if (! empty ( $tid ))				$client->tag = implode ( ',', $tid );						if (! empty ( $fax ))				$client->fax = $fax;						if (! empty ( $webservice ))				$client->webservice = $webservice;						if (! empty ( $department ))				$client->department = $department;						if (! empty ( $position ))				$client->position = $position;						if (! empty ( $office ))				$client->office = $office;						if (! empty ( $address ))				$client->address = $address;						if (! empty ( $ride ))				$client->ride = $ride;						if (! empty ( $landmarks ))				$client->landmarks = $landmarks;						if (! empty ( $stay ))				$client->stay = $stay;						if (! empty ( $mark ))				$client->mark = $mark;						$id = $client->insert ();						$client_staff->cid = $id;			$client_staff->sid = $this->staff [0] ['sid'];			$client_staff->insert ();						// 加入地区记录			Doo::loadModel ( "district_staff" );			$district_staff = new district_staff ();			$district_staff->did = $lv1 [0] ['id'];			$district_staff->sid = $this->staff [0] ['sid'];			$district_staff->insert ();						// 日常行为			Doo::loadModel ( "action_log" );			$action_log = new action_log ();						$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 . ')';			$action_log->sid = $this->staff [0] ['sid'];			$action_log->cid = $this->staff [0] ['cid'];			$action_log->updatetime = date ( "Y-m-d" );			$action_log->time = date ( "H:i" );			$action_log->status = 1;			$action_log->districtid = $local1 . "," . $local2 . "," . $local3;			$action_log->city = $lv1 [0] ['name'];			$action_log->province = $lv2 [0] ['name'];			if (isset ( $nature [0] ))				$action_log->nature = $nature [0];			$action_log->company = $companyname;			$action_log->class = $action_log->iconContacts;			$action_log->insert ();						// 事实更新信息中心记录数量 需要更新3个redis 内的值			$categoryCondition = " and cid=" . $this->staff [0] ['cid'];			$sidCondition = " and sid=" . $this->staff [0] ['sid'];						// actionlog免查询值 $alCondition='';			$alCondition = ' aid>' . REMIT . ' and ';						// 个人添加数量redis值			$redisKeyCS = date ( 'Y-m-d' ) . 'SC_' . $this->staff [0] ['cid'] . '_' . $this->staff [0] ['sid'];			$action_log = new action_log ();			$actionLogClient = $action_log->find ( array (					'select' => 'date_format(updatetime,"%m-%d") as updatetime,COUNT(*) as count',					'where' => $alCondition . " status=1" . $sidCondition . $categoryCondition . ' and date_sub(curdate(), INTERVAL 30 DAY) <= date(updatetime)',					'groupby' => 'date_format(updatetime,"%m-%d")',					'asArray' => true 			) );						$statisticsClient = array ();			for($d = 0; $d <= 29; $d ++) {				$MD = date ( "m-d", strtotime ( "-" . $d . " day" ) );				$falgClient = true;								foreach ( $actionLogClient as $value ) {					if ($value ['updatetime'] == $MD) {						array_push ( $statisticsClient, $value ['count'] );						$falgClient = false;						break;					}				}				if ($falgClient)					array_push ( $statisticsClient, 0 );			}			$statisticsClient = array_reverse ( $statisticsClient );			$jsc = json_encode ( $statisticsClient );			$redis->set ( $redisKeyCS, $jsc );						// 办事处添加数量reids值			$redisKeyC = date ( 'Y-m-d' ) . 'SC_' . $this->staff [0] ['cid'] . '_';			$action_log = new action_log ();			$actionLogClient = $action_log->find ( array (					'select' => 'date_format(updatetime,"%m-%d") as updatetime,COUNT(*) as count',					'where' => $alCondition . " status=1" . $categoryCondition . ' and date_sub(curdate(), INTERVAL 30 DAY) <= date(updatetime)',					'groupby' => 'date_format(updatetime,"%m-%d")',					'asArray' => true 			) );						$statisticsClient = array ();			for($d = 0; $d <= 29; $d ++) {				$MD = date ( "m-d", strtotime ( "-" . $d . " day" ) );				$falgClient = true;								foreach ( $actionLogClient as $value ) {					if ($value ['updatetime'] == $MD) {						array_push ( $statisticsClient, $value ['count'] );						$falgClient = false;						break;					}				}				if ($falgClient)					array_push ( $statisticsClient, 0 );			}			$statisticsClient = array_reverse ( $statisticsClient );			$jsc = json_encode ( $statisticsClient );			$redis->set ( $redisKeyC, $jsc );						// 全员添加数量的redis值			$redisKey = date ( 'Y-m-d' ) . 'SC__';			$action_log = new action_log ();			$actionLogClient = $action_log->find ( array (					'select' => 'date_format(updatetime,"%m-%d") as updatetime,COUNT(*) as count',					'where' => $alCondition . ' status=1  and date_sub(curdate(), INTERVAL 30 DAY) <= date(updatetime)',					'groupby' => 'date_format(updatetime,"%m-%d")',					'asArray' => true 			) );			$statisticsClient = array ();			for($d = 0; $d <= 29; $d ++) {				$MD = date ( "m-d", strtotime ( "-" . $d . " day" ) );				$falgClient = true;								foreach ( $actionLogClient as $value ) {					if ($value ['updatetime'] == $MD) {						array_push ( $statisticsClient, $value ['count'] );						$falgClient = false;						break;					}				}				if ($falgClient)					array_push ( $statisticsClient, 0 );			}			$statisticsClient = array_reverse ( $statisticsClient );			$jsc = json_encode ( $statisticsClient );			$redis->set ( $redisKey, $jsc );		}		echo json_encode ( array (				'status' => 1,				'msg' => ''		) );		die ();	}		/**	 * 获取get或者POST值	 * @param string $name 属性名称	 * @return fixed 值	 */	function get_args($name) {		if (isset ( $_GET [$name] )) {			if (is_array ( $_GET [$name] ))				return $_GET [$name];			else {				return addslashes ( $_GET [$name] );								// return $_GET [$name] ;			}		} elseif (isset ( $_POST [$name] )) {			if (is_array ( $_POST [$name] ))				return $_POST [$name];			else {				return addslashes ( $_POST [$name] );								// return $_POST [$name];			}		} else {						return false;		}	}		/**	 * 获取总页数	 * @param unknown_type $table	 * @param unknown_type $condition	 */	public function getTableCount($table = "", $condition = "", $staffid = "", $search, $tooltip, $cateid) {		if (! empty ( $staffid )) {			// $staffid="and a.sid= '".$staffid."'"; " . $table . " as a left join on (a.cid=b.cid ".$staffid.")			$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;		} else {			if (strlen ( $condition ) == 1 || empty ( $condition ))				$sql = "select count(*) as count from  CLD_client as a  " . $condition;			else				$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;		}				if (! empty ( $search ))			$sql = "select count(*) as count from  CLD_client as a where 1 " . $condition;				if (! empty ( $tooltip )) {			$condition = str_replace ( "a.", "c.", $condition );						$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;		}		// echo $sql;		$query = Doo::db ()->query ( $sql );				$result = $query->fetch ();				return $result ['count'];	}		/*	 * 生成WSDL文件	 */	function interfaceDetail() {		Doo::loadClass ( "MobileApi/Service" );	}	function login($user, $pw) {		Doo::loadModel ( 'staff' );		$staff = new staff ();				if (! empty ( $pw )) {			$userinfo = $staff->checkUser ( $user, $pw );						if (! empty ( $userinfo )) {				setcookie ( "staff", $userinfo [0] ['sid'], time () + 36000, "/" );				return array (						'status' => 1,						'msg' => '登陆成功',						'userList' => $userinfo 				);			} else				return array (						'status' => 2,						'msg' => '账号或密码不正确2',						'userList' => array () 				);		} else			return array (					'status' => 2,					'msg' => '账号或密码不正确3',					'userList' => array () 			);	}	function register($username, $gameid, $fromurl, $advertiser, $adfrom, $pagetype, $pagename, $tgid, $ip, $registertime) {		$param = array (				'tg_account' => $username,				'tg_gameID' => $gameid,				'tg_advertiser' => $fromurl,				'tg_adFrom' => $advertiser,				'tg_pageParam' => $adfrom,				'tg_adType' => $pagetype,								'tg_adsID' => $tgid,				'tg_ip' => $tgid,				'tg_registerTime' => $registertime 		);		return $param;	}	public function service() {		ini_set ( "soap.wsdl_cache_enabled", "0" );		$server = new SoapServer ( 'protected/class/MobileApi/interfaceDetail.wsdl', array (				'soap_version' => SOAP_1_2 		) );		$server->setClass ( "MobileController" );		$server->addFunction ( array (				'login',				'register' 		) );		$server->addFunction ( SOAP_FUNCTIONS_ALL );		$server->handle ();	}}?>
 |