MainController.php 230 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921
  1. <?php
  2. /**
  3. * @author darkredz
  4. */
  5. class MainController extends DooController {
  6. public $staff;
  7. public $nature = array (
  8. '1' => '设计',
  9. '2' => '造价管理',
  10. '3' => '业主',
  11. '4' => '交通局',
  12. '5' => '公路局',
  13. '6' => '审计',
  14. '7' => '财政',
  15. '8' => '审核',
  16. '9' => '施工',
  17. '10' => '咨询',
  18. '11' => '招标代理',
  19. '12' => '监理',
  20. '13' => '学校',
  21. '14' => '个人',
  22. '15' => '合作伙伴'
  23. );
  24. public $tooltip = array (
  25. '1' => array (
  26. 'L',
  27. '点击筛选标签'
  28. ),
  29. '2' => array (
  30. 'M',
  31. '点击筛选标签'
  32. ),
  33. '3' => array (
  34. 'N',
  35. '点击筛选标签'
  36. ),
  37. '4' => array (
  38. 'O',
  39. '点击筛选标签'
  40. ),
  41. '5' => array (
  42. 'P',
  43. '点击筛选标签'
  44. ),
  45. '6' => array (
  46. 'Q',
  47. '点击筛选标签'
  48. ),
  49. '7' => array (
  50. 'R',
  51. '点击筛选标签'
  52. )
  53. );
  54. public $webPath = "http://cld.smartcost.com.cn/upload/emailAnnex/";
  55. function __construct() {
  56. //phpinfo();die;
  57. // include './protected/config/common.conf.php';
  58. // include $config['BASE_PATH'].'diagnostic/debug.php';
  59. if (isset ( $_COOKIE ["staff"] )) {
  60. if (! empty ( $_COOKIE ["staff"] )) {
  61. Doo::loadModel ( 'staff' );
  62. $staff = new staff ();
  63. $this->staff = $staff->getUserByIdList ( $_COOKIE ["staff"] );
  64. return "/";
  65. }
  66. }
  67. Doo::loadCore ( 'uri/DooUriRouter' );
  68. $router = new DooUriRouter ();
  69. $routeRs = $router->execute ( Doo::app ()->route, Doo::conf ()->SUBFOLDER );
  70. if ($routeRs ['1'] != "login") {
  71. header ( 'Content-Type:text/html;charset=utf-8' );
  72. @header ( "Location: /login" );
  73. }
  74. }
  75. function isMobile() {
  76. // 如果有HTTP_X_WAP_PROFILE则一定是移动设备
  77. if (isset ( $_SERVER ['HTTP_X_WAP_PROFILE'] )) {
  78. return true;
  79. }
  80. // 如果via信息含有wap则一定是移动设备,部分服务商会屏蔽该信息
  81. if (isset ( $_SERVER ['HTTP_VIA'] )) {
  82. // 找不到为flase,否则为true
  83. return stristr ( $_SERVER ['HTTP_VIA'], "wap" ) ? true : false;
  84. }
  85. // 脑残法,判断手机发送的客户端标志,兼容性有待提高
  86. if (isset ( $_SERVER ['HTTP_USER_AGENT'] )) {
  87. $clientkeywords = array (
  88. 'nokia',
  89. 'sony',
  90. 'ericsson',
  91. 'mot',
  92. 'samsung',
  93. 'htc',
  94. 'sgh',
  95. 'lg',
  96. 'sharp',
  97. 'sie-',
  98. 'philips',
  99. 'panasonic',
  100. 'alcatel',
  101. 'lenovo',
  102. 'iphone',
  103. 'ipod',
  104. 'blackberry',
  105. 'meizu',
  106. 'android',
  107. 'netfront',
  108. 'symbian',
  109. 'ucweb',
  110. 'windowsce',
  111. 'palm',
  112. 'operamini',
  113. 'operamobi',
  114. 'openwave',
  115. 'nexusone',
  116. 'cldc',
  117. 'midp',
  118. 'wap',
  119. 'mobile'
  120. );
  121. // 从HTTP_USER_AGENT中查找手机浏览器的关键字
  122. if (preg_match ( "/(" . implode ( '|', $clientkeywords ) . ")/i", strtolower ( $_SERVER ['HTTP_USER_AGENT'] ) )) {
  123. return true;
  124. }
  125. }
  126. // 协议法,因为有可能不准确,放到最后判断
  127. if (isset ( $_SERVER ['HTTP_ACCEPT'] )) {
  128. // 如果只支持wml并且不支持html那一定是移动设备
  129. // 如果支持wml和html但是wml在html之前则是移动设备
  130. if ((strpos ( $_SERVER ['HTTP_ACCEPT'], 'vnd.wap.wml' ) !== false) && (strpos ( $_SERVER ['HTTP_ACCEPT'], 'text/html' ) === false || (strpos ( $_SERVER ['HTTP_ACCEPT'], 'vnd.wap.wml' ) < strpos ( $_SERVER ['HTTP_ACCEPT'], 'text/html' )))) {
  131. return true;
  132. }
  133. }
  134. return false;
  135. }
  136. function login() {
  137. $passwork = $this->get_args ( 'passwork' ) ? $this->get_args ( 'passwork' ) : 0;
  138. $uid = $this->get_args ( 'user' ) ? $this->get_args ( 'user' ) : 0;
  139. Doo::loadModel ( 'staff' );
  140. $staff = new staff ();
  141. Doo::loadClass ( 'XDeode' );
  142. $XDeode = new XDeode ( 5 );
  143. if (! empty ( $passwork )) {
  144. $userinfo = $staff->checkUser ( $uid, $passwork );
  145. if (! empty ( $userinfo )) {
  146. setcookie ( "staff", $XDeode->encode ( $userinfo [0] ['sid'] ), time () + 36000, "/" );
  147. return "/";
  148. }
  149. }
  150. $data ['staff'] = ""; // $staff->getUser ();
  151. $data ['login'] = "";
  152. if (! empty ( $passwork ))
  153. $data ['login'] = "inputErrow";
  154. $this->render ( "/login", $data );
  155. }
  156. function out() {
  157. setcookie ( "staff", "", time () - 3600, "/" );
  158. return "/";
  159. }
  160. function index2() {
  161. // include Doo::conf()->BASE_PATH.'diagnostic/debug.php';
  162. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  163. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  164. $page = $this->get_args ( 'page' ) ? $this->get_args ( 'page' ) : 1;
  165. Doo::loadModel ( 'action_log' );
  166. $action_log = new action_log ();
  167. Doo::loadModel ( 'staff' );
  168. $staff = new staff ();
  169. Doo::loadModel ( 'client_staff' );
  170. $client_staff = new client_staff ();
  171. Doo::loadModel ( 'longle' );
  172. $longle = new longle ();
  173. Doo::loadModel ( 'L_category' );
  174. $lcategory = new L_category ();
  175. $limit = 50;
  176. $p = $page;
  177. if ($page != 1)
  178. $page = $page * $limit - 1;
  179. else
  180. $page --;
  181. $condition = "";
  182. // if (!empty($cid) && $cid != 12) {
  183. // $condition = " and cid=" . $cid . " and sid=" . $sid;
  184. // }
  185. $staffCondition = "";
  186. $categorylist2 = array ();
  187. if ($this->staff [0] ['cid'] != 12) {
  188. $staffCondition = " and cid=" . $this->staff [0] ['cid'];
  189. array_push ( $categorylist2, array (
  190. 'cid' => $this->staff [0] ['cid'],
  191. 'title' => $this->staff [0] ['category']
  192. ) );
  193. if (! empty ( $sid ))
  194. $condition = " and cid=" . $this->staff [0] ['cid'] . " and sid=" . $sid;
  195. else
  196. $condition = " and cid=" . $this->staff [0] ['cid'];
  197. } else {
  198. $sql = 'SELECT `CLD_L_category`.cid,`CLD_L_category`.title,count(`CLD_staff`.sid) as count FROM `CLD_L_category` left join `CLD_staff` on `CLD_L_category`.cid=`CLD_staff`.cid group by `CLD_staff`.cid HAVING count(`CLD_staff`.sid)>0 order by count(`CLD_staff`.sid) desc';
  199. $query = Doo::db ()->query ( $sql );
  200. $result = $query->fetchAll ();
  201. $categorylist2 = $result;
  202. }
  203. if (! empty ( $cid )) {
  204. $staffCondition = " and cid=" . $cid;
  205. if (! empty ( $sid ))
  206. $condition = " and cid=" . $cid . " and sid=" . $sid;
  207. else
  208. $condition = " and cid=" . $cid;
  209. }
  210. /*
  211. * $itemCategoryList=$action_log->find(array('select'=>'updatetime,COUNT(*)', 'where'=>" Year(updatetime)=2014",'groupby'=>'Month(updatetime)','asArray'=>true)); print_r($itemCategoryList);die;
  212. */
  213. $staffList = $staff->find ( array (
  214. 'where' => ' username!="admin" ' . $staffCondition,
  215. 'asArray' => true
  216. ) );
  217. $actionLogList = $action_log->find ( array (
  218. 'where' => ' 1 ' . $condition,
  219. 'limit' => $page . ',' . $limit,
  220. 'desc' => 'aid',
  221. 'asArray' => true
  222. ) );
  223. // echo $condition;
  224. // 抽取日期 ,'groupby'=>'updatetime'
  225. $dateLog = $action_log->find ( array (
  226. 'select' => 'updatetime',
  227. 'where' => ' 1 ' . $condition,
  228. 'limit' => $limit,
  229. 'desc' => 'aid',
  230. 'asArray' => true
  231. ) );
  232. $dl = array ();
  233. foreach ( $dateLog as $value ) {
  234. array_push ( $dl, $value ['updatetime'] );
  235. }
  236. $dateLog = array_unique ( $dl );
  237. $log = array ();
  238. foreach ( $dateLog as $key => $value ) {
  239. $log [$value] = array ();
  240. foreach ( $actionLogList as $k => $v ) {
  241. if ($value == $v ['updatetime']) {
  242. array_push ( $log [$value], $v );
  243. unset ( $actionLogList [$k] );
  244. }
  245. }
  246. }
  247. $max = array ();
  248. foreach ( $staffList as $key => $value ) {
  249. $staffList [$key] ['count'] = $client_staff->count ( array (
  250. 'where' => 'sid=' . $value ['sid'],
  251. 'asArray' => true
  252. ) );
  253. array_push ( $max, $staffList [$key] ['count'] . ':' . $value ['username'] );
  254. }
  255. rsort ( $max, SORT_NUMERIC );
  256. $sum = 0;
  257. foreach ( $max as $key => $value ) {
  258. $max [$key] = explode ( ":", $value );
  259. $sum += $max [$key] [0];
  260. }
  261. $max2 = $max;
  262. array_shift ( $max2 );
  263. array_shift ( $max2 );
  264. array_shift ( $max2 );
  265. $lcategoryList = $lcategory->find ( array (
  266. 'asArray' => true
  267. ) );
  268. $useL = array ();
  269. $Rsum = $Ssum = 0;
  270. foreach ( $lcategoryList as $key => $value ) {
  271. $longleR = $longle->count ( array (
  272. 'where' => 'cid=' . $value ['cid'],
  273. 'asArray' => true
  274. ) );
  275. $longleS = $longle->count ( array (
  276. 'where' => 'cid=' . $value ['cid'] . ' and status!=1 and status!=2',
  277. 'asArray' => true
  278. ) );
  279. $Rsum += $longleR;
  280. $Ssum += $longleS;
  281. if (! empty ( $longleS ))
  282. array_push ( $useL, round ( ($longleS / $longleR) * 100 ) . '% :' . $value ['title'] );
  283. else
  284. array_push ( $useL, '0% :' . $value ['title'] );
  285. }
  286. rsort ( $useL, SORT_NUMERIC ); // $sum=0;
  287. foreach ( $useL as $key => $value ) {
  288. $useL [$key] = explode ( ":", $value );
  289. // $sum+=$max[$key][0];
  290. }
  291. $useL2 = $useL;
  292. array_shift ( $useL2 );
  293. array_shift ( $useL2 );
  294. array_shift ( $useL2 );
  295. $data ['Ssum'] = round ( ($Ssum / $Rsum) * 100 ) . '%';
  296. $data ['Rsum'] = $Rsum;
  297. $data ['useL2'] = $useL2;
  298. $data ['useL'] = $useL;
  299. $data ['sum'] = $sum;
  300. $data ['max'] = $max;
  301. $data ['max2'] = $max2;
  302. $data ['log'] = $log;
  303. $data ['page'] = $p;
  304. $data ['staffList'] = $staffList;
  305. $data ['categorylist2'] = $categorylist2;
  306. $data ['cid'] = $cid;
  307. $data ['sid'] = $sid;
  308. $data ['memu'] = "index";
  309. $data ['staff'] = $this->staff;
  310. $this->render ( "index2", $data );
  311. }
  312. function indexPage() {
  313. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  314. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  315. $page = $this->get_args ( 'page' ) ? $this->get_args ( 'page' ) : 1;
  316. Doo::loadModel ( 'action_log' );
  317. $action_log = new action_log ();
  318. $limit = 50;
  319. $p = $page;
  320. // if ($page!=1)
  321. // $page=$page*$limit-1;
  322. // else
  323. // $page--;
  324. $page = (-- $p) * $limit;
  325. /*
  326. * $condition=""; if (!empty($cid)&&$cid!=12){ $condition=" and cid=".$cid; } $staffCondition=""; if($this->staff[0]['cid']!=12){ $staffCondition=" and cid=".$this->staff[0]['cid']; $condition=" and cid=".$this->staff[0]['cid']; }
  327. */
  328. $condition = "";
  329. if (! empty ( $cid ) && $cid != 12) {
  330. $condition = " and cid=" . $cid . " and sid=" . $sid;
  331. }
  332. $staffCondition = "";
  333. if ($this->staff [0] ['cid'] != 12) {
  334. $staffCondition = " and cid=" . $this->staff [0] ['cid'];
  335. if (! empty ( $sid ))
  336. $condition = " and cid=" . $this->staff [0] ['cid'] . " and sid=" . $sid;
  337. else
  338. $condition = " and cid=" . $this->staff [0] ['cid'];
  339. }
  340. $actionLogList = $action_log->find ( array (
  341. 'where' => ' 1 ' . $condition,
  342. 'limit' => $page . ',' . $limit,
  343. 'desc' => 'aid',
  344. 'asArray' => true
  345. ) );
  346. // 抽取日期 ,'groupby'=>'updatetime'
  347. $dateLog = $action_log->find ( array (
  348. 'select' => 'updatetime',
  349. 'where' => ' 1 ' . $condition,
  350. 'limit' => $page . ',' . $limit,
  351. 'desc' => 'aid',
  352. 'asArray' => true
  353. ) );
  354. $dl = array ();
  355. foreach ( $dateLog as $value ) {
  356. array_push ( $dl, $value ['updatetime'] );
  357. }
  358. $dateLog = array_unique ( $dl );
  359. $log = array ();
  360. foreach ( $dateLog as $key => $value ) {
  361. $log [$value] = array ();
  362. foreach ( $actionLogList as $k => $v ) {
  363. if ($value == $v ['updatetime']) {
  364. array_push ( $log [$value], $v );
  365. unset ( $actionLogList [$k] );
  366. }
  367. }
  368. }
  369. $html = '';
  370. foreach ( $log as $key => $value ) {
  371. $html .= '<div class="item">
  372. <div class="date">' . $key . '</div>
  373. <dl class="recordList clearfix">';
  374. foreach ( $value as $k => $v ) {
  375. $html .= '<dd class="' . $v ['class'] . '"><span class="fR">' . $v ['time'] . '</span>' . $v ['action'] . '</dd>';
  376. }
  377. $html .= '</dl></div>';
  378. }
  379. echo $html;
  380. }
  381. function logStatistics() {
  382. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  383. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  384. Doo::loadModel ( 'action_log' );
  385. $action_log = new action_log ();
  386. Doo::loadModel ( 'staff' );
  387. $staff = new staff ();
  388. Doo::loadModel ( 'client_staff' );
  389. $client_staff = new client_staff ();
  390. Doo::loadModel ( 'longle' );
  391. $longle = new longle ();
  392. Doo::loadModel ( 'L_category' );
  393. $lcategory = new L_category ();
  394. Doo::loadModel ( 'department' );
  395. $department = new department ();
  396. $staffCondition = "";
  397. $categorylist2 = array ();
  398. if ($this->staff [0] ['cid'] != 12) {
  399. $staffCondition = " and cid=" . $this->staff [0] ['cid'];
  400. // array_push ( $categorylist2, array (
  401. // 'cid' => $this->staff [0] ['cid'],
  402. // 'title' => $this->staff [0] ['category']
  403. // ) );
  404. $otherC=$lcategory->getCategoryById($this->staff [0] ['cid'],$this->staff [0] ['othercid']);
  405. foreach ($otherC as $value){
  406. array_push ( $categorylist2, array (
  407. 'cid' => $value ['cid'],
  408. 'title' => $value ['title']
  409. ) );
  410. }
  411. } else {
  412. $sql = 'SELECT `CLD_L_category`.cid,`CLD_L_category`.title,count(`CLD_staff`.sid) as count FROM `CLD_L_category` left join `CLD_staff` on `CLD_L_category`.cid=`CLD_staff`.cid group by `CLD_staff`.cid HAVING count(`CLD_staff`.sid)>0 order by count(`CLD_staff`.sid) desc';
  413. $query = Doo::db ()->query ( $sql );
  414. $result = $query->fetchAll ();
  415. $categorylist2 = $result;
  416. //$otherC=$lcategory->getCategoryById($this->staff [0] ['cid'],$this->staff [0] ['othercid']);
  417. }
  418. //print_r($categorylist2);
  419. //有待优化
  420. $categorylist3=$categorylist2;$bakCategory=array();
  421. foreach ($categorylist3 as $key=>$value){
  422. $departList=$department->getDepartmentBycid($value['cid']);
  423. if (!empty($departList)){
  424. //$bakCategory=$categorylist2[$key];
  425. array_unshift($bakCategory,$value);
  426. unset($categorylist2[$key]);
  427. foreach ($departList as $v){
  428. array_unshift($bakCategory,array(
  429. 'cid'=>$v['cid'],
  430. 'title'=>$value['title'],
  431. 'count'=>$value['count'],
  432. 'did'=>$v['did'],
  433. 'departmentName'=>$v['departmentName'],
  434. ));
  435. }
  436. }
  437. }
  438. foreach ($bakCategory as $value){
  439. array_unshift($categorylist2,$value);
  440. }
  441. //array_unshift($categorylist2,$bakCategory);
  442. //print_r($categorylist2);
  443. $did=$data ['did']='';
  444. $othercateSql='';
  445. if (!empty($this->staff [0] ['othercid']))
  446. $othercateSql=" or (othercid like '".$this->staff [0] ['othercid']."')";
  447. if (! empty ( $cid )){//
  448. if(is_numeric($cid))
  449. $staffCondition = " and cid=" . $cid.$othercateSql;
  450. else {
  451. $cdid=explode('-', $cid);
  452. $cid=$cdid[0];
  453. $data ['did'] =$did= $cdid[1];
  454. $staffCondition = " and cid=" . $cdid[0]." and departmentID=".$cdid[1].$othercateSql;
  455. }
  456. }
  457. //echo $staffCondition;
  458. //echo $staffCondition;
  459. // Doo::db()->beginTransaction();
  460. $staffList = $staff->find ( array (
  461. 'where' => ' username !="admin"' . $staffCondition,
  462. 'asArray' => true
  463. ) );
  464. $max = array ();
  465. $kkk = array ();
  466. foreach ( $staffList as $key => $value ) {
  467. $staffList [$key] ['count'] = $client_staff->count ( array (
  468. 'where' => 'sid=' . $value ['sid'],
  469. 'asArray' => true
  470. ) );
  471. array_push ( $max, $staffList [$key] ['count'] . ':' . $value ['username'] );
  472. if ($this->staff [0] ['cid'] == 12)
  473. array_push ( $kkk, $staffList [$key] ['count'] );
  474. if ($this->staff [0] ['cid'] == $value ['cid'] && $this->staff [0] ['cid'] != 12) {
  475. array_push ( $kkk, $staffList [$key] ['count'] );
  476. }
  477. }
  478. $sum = 0;
  479. foreach ( $kkk as $key => $value ) {
  480. $sum += $value;
  481. }
  482. rsort ( $max, SORT_NUMERIC );
  483. foreach ( $max as $key => $value ) {
  484. $max [$key] = explode ( ":", $value );
  485. // $sum+=$max[$key][0];
  486. }
  487. $max2 = $max;
  488. array_shift ( $max2 );
  489. array_shift ( $max2 );
  490. array_shift ( $max2 );
  491. $lcategoryList = $lcategory->find ( array (
  492. 'asArray' => true
  493. ) );
  494. $useL = array ();
  495. $Rsum = $Ssum = 0;
  496. foreach ( $lcategoryList as $key => $value ) {
  497. $longleR = $longle->count ( array (
  498. 'where' => 'cid=' . $value ['cid'],
  499. 'asArray' => true
  500. ) );
  501. $longleS = $longle->count ( array (
  502. 'where' => 'cid=' . $value ['cid'] . ' and status!=1 and status!=2',
  503. 'asArray' => true
  504. ) );
  505. $Rsum += $longleR;
  506. $Ssum += $longleS;
  507. if (! empty ( $longleS ))
  508. array_push ( $useL, round ( ($longleS / $longleR) * 100 ) . '% :' . $value ['title'] );
  509. else
  510. array_push ( $useL, '0% :' . $value ['title'] );
  511. }
  512. // Doo::db()->commit();
  513. rsort ( $useL, SORT_NUMERIC ); // $sum=0;
  514. foreach ( $useL as $key => $value ) {
  515. $useL [$key] = explode ( ":", $value );
  516. // $sum+=$max[$key][0];
  517. }
  518. $useL2 = $useL;
  519. array_shift ( $useL2 );
  520. array_shift ( $useL2 );
  521. array_shift ( $useL2 );
  522. // statistics
  523. $categoryCondition = " and cid=" . $this->staff [0] ['cid'];
  524. $sidCondition = "";
  525. if (! empty ( $cid )){
  526. $categoryCondition = " and cid=" . $cid;
  527. // if (!empty($did))
  528. // $categoryCondition .= " and departmentID=" . $did;
  529. }
  530. if (! empty ( $sid ))
  531. $sidCondition = " and sid=" . $sid;
  532. if ($this->staff [0] ['cid'] == 12 && empty ( $cid )) {
  533. $categoryCondition = "";
  534. }
  535. //echo $categoryCondition;
  536. // Year(updatetime)=".date('Y')." and Month(updatetime)=".date('m')." date_format(updatetime,"%m-%d")
  537. $actionLogClient = $action_log->find ( array (
  538. 'select' => 'date_format(updatetime,"%m-%d") as updatetime,COUNT(*) as count',
  539. 'where' => " date_sub(curdate(), INTERVAL 30 DAY) <= date(updatetime) and status=1" . $categoryCondition . $sidCondition,
  540. 'groupby' => 'date_format(updatetime,"%m-%d")',
  541. 'asArray' => true
  542. ) );
  543. $actionLogLongle = $action_log->find ( array (
  544. 'select' => 'date_format(updatetime,"%m-%d") as updatetime,COUNT(*) as count',
  545. 'where' => " date_sub(curdate(), INTERVAL 30 DAY) <= date(updatetime) and status=3" . $categoryCondition . $sidCondition,
  546. 'groupby' => 'date_format(updatetime,"%m-%d")',
  547. 'asArray' => true
  548. ) );
  549. // $actionLogClient=array();
  550. // $actionLogLongle=array();
  551. $statisticsDay = array ();
  552. $statisticsClient = $statisticsLongle = array ();
  553. for($d = 0; $d <= 29; $d ++) {
  554. $MD = date ( "m-d", strtotime ( "-" . $d . " day" ) );
  555. $falgClient = $falgLongle = true;
  556. array_push ( $statisticsDay, $MD );
  557. foreach ( $actionLogClient as $value ) {
  558. if ($value ['updatetime'] == $MD) {
  559. array_push ( $statisticsClient, $value ['count'] );
  560. $falgClient = false;
  561. break;
  562. }
  563. }
  564. if ($falgClient)
  565. array_push ( $statisticsClient, 0 );
  566. foreach ( $actionLogLongle as $value ) {
  567. if ($value ['updatetime'] == $MD) {
  568. array_push ( $statisticsLongle, $value ['count'] );
  569. $falgLongle = false;
  570. break;
  571. }
  572. }
  573. if ($falgLongle)
  574. array_push ( $statisticsLongle, 0 );
  575. }
  576. // print_r($actionLogLongle);
  577. $statisticsClient = array_reverse ( $statisticsClient );
  578. $statisticsLongle = array_reverse ( $statisticsLongle );
  579. $statisticsDay = array_reverse ( $statisticsDay );
  580. // / Year(updatetime)=".date('Y')." and Month(updatetime)=".date('m')." and
  581. $categoryList = $lcategory->find ( array (
  582. 'asArray' => true
  583. ) );
  584. $CategoryClient = $action_log->find ( array (
  585. 'select' => 'cid,COUNT(*) as count,city',
  586. 'where' => " date_sub(curdate(), INTERVAL 30 DAY) <= date(updatetime) and status=1" . $categoryCondition . $sidCondition,
  587. 'groupby' => 'cid',
  588. 'asArray' => true
  589. ) );
  590. // or status=2
  591. $CategoryCompany = $action_log->find ( array (
  592. 'select' => 'cid, COUNT(*) as count,company,districtid',
  593. 'where' => " date_sub(curdate(), INTERVAL 30 DAY) <= date(updatetime) and (status=1 )" . $categoryCondition . $sidCondition,
  594. 'groupby' => 'cid,districtid,company',
  595. 'asArray' => true
  596. ) );
  597. $natureList = $action_log->find ( array (
  598. 'select' => 'cid, COUNT(*) as count,nature',
  599. 'where' => " date_sub(curdate(), INTERVAL 30 DAY) <= date(updatetime) and status=1 and nature !=''" . $categoryCondition . $sidCondition,
  600. 'groupby' => 'nature',
  601. 'asArray' => true
  602. ) );
  603. $statisticsCategory = array ();
  604. $statisticsCompany = array ();
  605. foreach ( $categoryList as $value ) {
  606. $falgClient = $falgLongle = true;
  607. foreach ( $CategoryClient as $v ) {
  608. if ($value ['cid'] == $v ['cid'] && $v ['cid'] != 12) {
  609. array_push ( $statisticsCategory, array (
  610. 'value' => $v ['count'],
  611. 'name' => str_replace ( "办", "省", $value ['title'] )
  612. ) );
  613. $falgClient = false;
  614. break;
  615. }
  616. }
  617. if ($falgClient) {
  618. array_push ( $statisticsCategory, array (
  619. 'value' => 0,
  620. 'name' => str_replace ( "办", "省", $value ['title'] )
  621. ) );
  622. }
  623. // company statistics
  624. $i = 0;
  625. foreach ( $CategoryCompany as $v ) {
  626. if ($value ['cid'] == $v ['cid'] && $v ['cid'] != 12) {
  627. $i ++;
  628. }
  629. }
  630. array_push ( $statisticsCompany, array (
  631. 'value' => $i,
  632. 'name' => str_replace ( "办", "省", $value ['title'] )
  633. ) );
  634. }
  635. // print_r($CategoryClient);
  636. $statisticsNature = array ();
  637. foreach ( $this->nature as $value ) {
  638. $flagNature = true;
  639. foreach ( $natureList as $v ) {
  640. if ($value == $v ['nature']) {
  641. array_push ( $statisticsNature, array (
  642. 'value' => $v ['count'],
  643. 'name' => $value
  644. ) );
  645. $flagNature = false;
  646. break;
  647. }
  648. }
  649. if ($flagNature)
  650. array_push ( $statisticsNature, array (
  651. 'value' => 0,
  652. 'name' => $value
  653. ) );
  654. }
  655. // print_r($max2);//die;
  656. $data ['statisticsNature'] = json_encode ( $statisticsNature );
  657. $data ['statisticsCompany'] = json_encode ( $statisticsCompany );
  658. $data ['statisticsCategory'] = json_encode ( $statisticsCategory );
  659. $data ['statisticsDay'] = json_encode ( $statisticsDay );
  660. $data ['statisticsClient'] = json_encode ( $statisticsClient );
  661. $data ['statisticsLongle'] = json_encode ( $statisticsLongle );
  662. $data ['categorylist2'] = $categorylist2;
  663. $data ['Ssum'] = round ( ($Ssum / $Rsum) * 100 ) . '%';
  664. $data ['Rsum'] = $Rsum;
  665. $data ['useL2'] = $useL2;
  666. $data ['useL'] = $useL;
  667. $data ['sum'] = $sum;
  668. $data ['max'] = $max;
  669. $data ['max2'] = $max2;
  670. $data ['staffList'] = $staffList;
  671. $data ['cid'] = $cid;
  672. $data ['sid'] = $sid;
  673. $data ['memu'] = "index";
  674. $data ['staff'] = $this->staff;
  675. $this->render ( "/indexStat", $data );
  676. }
  677. function longleStatistics() {
  678. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  679. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  680. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 4;
  681. $districtH = $this->get_args ( 'district' ) ? $this->get_args ( 'district' ) : 0;
  682. Doo::loadModel ( 'action_log' );
  683. $action_log = new action_log ();
  684. Doo::loadModel ( 'staff' );
  685. $staff = new staff ();
  686. Doo::loadModel ( 'client_staff' );
  687. $client_staff = new client_staff ();
  688. Doo::loadModel ( 'longle' );
  689. $longle = new longle ();
  690. Doo::loadModel ( 'L_category' );
  691. $lcategory = new L_category ();
  692. Doo::loadModel ( 'district' );
  693. $district = new district ();
  694. $staffCondition = "";
  695. $categorylist2 = array ();
  696. if ($this->staff [0] ['cid'] != 12) {
  697. $staffCondition = " and cid=" . $this->staff [0] ['cid'];
  698. array_push ( $categorylist2, array (
  699. 'cid' => $this->staff [0] ['cid'],
  700. 'title' => $this->staff [0] ['category']
  701. ) );
  702. } else {
  703. $sql = 'SELECT `CLD_L_category`.cid,`CLD_L_category`.title,count(`CLD_staff`.sid) as count FROM `CLD_L_category` left join `CLD_staff` on `CLD_L_category`.cid=`CLD_staff`.cid group by `CLD_staff`.cid HAVING count(`CLD_staff`.sid)>0 order by count(`CLD_staff`.sid) desc';
  704. $query = Doo::db ()->query ( $sql );
  705. $result = $query->fetchAll ();
  706. $categorylist2 = $result;
  707. }
  708. if (! empty ( $cid ))
  709. $staffCondition = " and cid=" . $cid;
  710. $staffList = $staff->find ( array (
  711. 'where' => ' username!="admin"' . $staffCondition,
  712. 'asArray' => true
  713. ) );
  714. $max = array ();
  715. foreach ( $staffList as $key => $value ) {
  716. $staffList [$key] ['count'] = $client_staff->count ( array (
  717. 'where' => 'sid=' . $value ['sid'],
  718. 'asArray' => true
  719. ) );
  720. array_push ( $max, $staffList [$key] ['count'] . ':' . $value ['username'] );
  721. }
  722. rsort ( $max, SORT_NUMERIC );
  723. $sum = 0;
  724. foreach ( $max as $key => $value ) {
  725. $max [$key] = explode ( ":", $value );
  726. $sum += $max [$key] [0];
  727. }
  728. $max2 = $max;
  729. array_shift ( $max2 );
  730. array_shift ( $max2 );
  731. array_shift ( $max2 );
  732. $lcategoryList = $lcategory->find ( array (
  733. 'asArray' => true
  734. ) );
  735. $useL = array ();
  736. $Rsum = $Ssum = 0;
  737. foreach ( $lcategoryList as $key => $value ) {
  738. $longleR = $longle->count ( array (
  739. 'where' => 'cid=' . $value ['cid'],
  740. 'asArray' => true
  741. ) );
  742. $longleS = $longle->count ( array (
  743. 'where' => 'cid=' . $value ['cid'] . ' and status!=1 and status!=2',
  744. 'asArray' => true
  745. ) );
  746. $Rsum += $longleR;
  747. $Ssum += $longleS;
  748. if (! empty ( $longleS ))
  749. array_push ( $useL, round ( ($longleS / $longleR) * 100 ) . '% :' . $value ['title'] );
  750. else
  751. array_push ( $useL, '0% :' . $value ['title'] );
  752. }
  753. rsort ( $useL, SORT_NUMERIC ); // $sum=0;
  754. foreach ( $useL as $key => $value ) {
  755. $useL [$key] = explode ( ":", $value );
  756. // $sum+=$max[$key][0];
  757. }
  758. $useL2 = $useL;
  759. array_shift ( $useL2 );
  760. array_shift ( $useL2 );
  761. array_shift ( $useL2 );
  762. // statistics
  763. $categoryCondition = " and cid=" . $this->staff [0] ['cid'];
  764. $sidCondition = "";
  765. if (! empty ( $cid ))
  766. $categoryCondition = " and cid=" . $cid;
  767. if (! empty ( $sid ))
  768. $sidCondition = " and sid=" . $sid;
  769. if ($this->staff [0] ['cid'] == 12 && empty ( $cid )) {
  770. $categoryCondition = "";
  771. }
  772. // Year(updatetime)=".date('Y')." and Month(updatetime)=".date('m')." date_format(updatetime,"%m-%d") Day(updatetime)
  773. $actionLogClient = $action_log->find ( array (
  774. 'select' => 'date_format(updatetime,"%m-%d") as updatetime,COUNT(*) as count',
  775. 'where' => " date_sub(curdate(), INTERVAL 30 DAY) <= date(updatetime) and status=4" . $categoryCondition . $sidCondition,
  776. 'groupby' => 'Day(updatetime)',
  777. 'asArray' => true
  778. ) );
  779. $actionLogLongle = $action_log->find ( array (
  780. 'select' => 'date_format(updatetime,"%m-%d") as updatetime,COUNT(*) as count',
  781. 'where' => " date_sub(curdate(), INTERVAL 30 DAY) <= date(updatetime) and status=5" . $categoryCondition . $sidCondition,
  782. 'groupby' => 'Day(updatetime)',
  783. 'asArray' => true
  784. ) );
  785. $actionLogGet = $action_log->find ( array (
  786. 'select' => 'date_format(updatetime,"%m-%d") as updatetime,COUNT(*) as count',
  787. 'where' => " date_sub(curdate(), INTERVAL 30 DAY) <= date(updatetime) and status=6" . $categoryCondition . $sidCondition,
  788. 'groupby' => 'Day(updatetime)',
  789. 'asArray' => true
  790. ) );
  791. $statisticsDay = array ();
  792. $statisticsClient = $statisticsLongle = $statisticsGet = array ();
  793. /**
  794. * for ($d=1;$d<=date("t");$d++){ $MD=date('m')."-".$d;
  795. */
  796. for($d = 0; $d <= 29; $d ++) {
  797. $MD = date ( "m-d", strtotime ( "-" . $d . " day" ) );
  798. $falgClient = $falgLongle = $falgGet = true;
  799. array_push ( $statisticsDay, $MD );
  800. foreach ( $actionLogClient as $value ) {
  801. if ($value ['updatetime'] == $MD) {
  802. array_push ( $statisticsClient, $value ['count'] );
  803. $falgClient = false;
  804. break;
  805. }
  806. }
  807. if ($falgClient)
  808. array_push ( $statisticsClient, 0 );
  809. foreach ( $actionLogLongle as $value ) {
  810. if ($value ['updatetime'] == $MD) {
  811. array_push ( $statisticsLongle, $value ['count'] );
  812. $falgLongle = false;
  813. break;
  814. }
  815. }
  816. if ($falgLongle)
  817. array_push ( $statisticsLongle, 0 );
  818. foreach ( $actionLogGet as $value ) {
  819. if ($value ['updatetime'] == $MD) {
  820. array_push ( $statisticsGet, $value ['count'] );
  821. $falgGet = false;
  822. break;
  823. }
  824. }
  825. if ($falgGet)
  826. array_push ( $statisticsGet, 0 );
  827. }
  828. $statisticsClient = array_reverse ( $statisticsClient );
  829. $statisticsLongle = array_reverse ( $statisticsLongle );
  830. $statisticsGet = array_reverse ( $statisticsGet );
  831. $statisticsDay = array_reverse ( $statisticsDay );
  832. // /
  833. $districtCondition = "";
  834. $topDistrict = $district->get_lvByid ( 0, 0 );
  835. if (! empty ( $sid )) {
  836. $s = $staff->getOne ( array (
  837. 'where' => ' sid=' . $sid,
  838. 'asArray' => true
  839. ) );
  840. $l = $lcategory->find ( array (
  841. 'where' => ' cid in(' . $s ['cid'] . ')',
  842. 'asArray' => true
  843. ) );
  844. if (! empty ( $s ['othercid'] ))
  845. $l = $lcategory->find ( array (
  846. 'where' => ' cid in(' . $s ['cid'] . ',' . $s ['othercid'] . ')',
  847. 'asArray' => true
  848. ) );
  849. if (! empty ( $districtH )) {
  850. $districtCondition = " and districtid like '" . $districtH . ",%'";
  851. $sidCondition = "";
  852. $topDistrict = $district->find ( array (
  853. 'where' => ' upid=' . $districtH,
  854. 'asArray' => true
  855. ) );
  856. } else {
  857. $districtCondition = " and districtid like '" . $l [0] ['districtid'] . ",%'";
  858. $sidCondition = "";
  859. $topDistrict = $district->find ( array (
  860. 'where' => ' upid=' . $l [0] ['districtid'],
  861. 'asArray' => true
  862. ) );
  863. }
  864. $str = array ();
  865. foreach ( $l as $value ) {
  866. array_push ( $str, $value ['districtid'] );
  867. }
  868. $str = implode ( ",", $str );
  869. $data ['districtHtml'] = $district->find ( array (
  870. 'where' => ' id in (' . $str . ')',
  871. 'asArray' => true
  872. ) );
  873. $data ['districtH'] = $l [0] ['districtid'];
  874. if (! empty ( $districtH ))
  875. $data ['districtH'] = $districtH;
  876. }
  877. // Year(updatetime)=".date('Y')." and Month(updatetime)=".date('m')." and
  878. if (! empty ( $sid ))
  879. $districtClient = $action_log->find ( array (
  880. 'select' => 'city,province,COUNT(*) as count',
  881. 'where' => " date_sub(curdate(), INTERVAL 30 DAY) <= date(updatetime) and status=" . $status . $categoryCondition . $sidCondition . $districtCondition,
  882. 'groupby' => 'province',
  883. 'asArray' => true
  884. ) );
  885. else
  886. $districtClient = $action_log->find ( array (
  887. 'select' => 'city,province,COUNT(*) as count',
  888. 'where' => " date_sub(curdate(), INTERVAL 30 DAY) <= date(updatetime) and status=" . $status . $categoryCondition . $sidCondition . $districtCondition,
  889. 'groupby' => 'city',
  890. 'asArray' => true
  891. ) );
  892. $statisticsLend = array ();
  893. $statisticsCompany = array ();
  894. if (! empty ( $sid )) {
  895. foreach ( $topDistrict as $value ) {
  896. $falgLend = $falgLongle = true;
  897. foreach ( $districtClient as $v ) {
  898. if ($value ['name'] == $v ['province']) {
  899. array_push ( $statisticsLend, array (
  900. 'value' => $v ['count'],
  901. 'name' => $value ['name']
  902. ) );
  903. $falgLend = false;
  904. break;
  905. }
  906. }
  907. if ($falgLend)
  908. array_push ( $statisticsLend, array (
  909. 'value' => 0,
  910. 'name' => $value ['name']
  911. ) );
  912. }
  913. } else {
  914. foreach ( $topDistrict as $value ) {
  915. $falgLend = $falgLongle = true;
  916. foreach ( $districtClient as $v ) {
  917. if ($value ['name'] == $v ['city']) {
  918. array_push ( $statisticsLend, array (
  919. 'value' => $v ['count'],
  920. 'name' => $value ['name']
  921. ) );
  922. $falgLend = false;
  923. break;
  924. }
  925. }
  926. if ($falgLend)
  927. array_push ( $statisticsLend, array (
  928. 'value' => 0,
  929. 'name' => $value ['name']
  930. ) );
  931. }
  932. }
  933. // print_r($statisticsLend);die;
  934. $natureList = $action_log->find ( array (
  935. 'select' => 'cid, COUNT(*) as count,nature',
  936. 'where' => " date_sub(curdate(), INTERVAL 30 DAY) <= date(updatetime) and status=" . $status . " and nature !=''" . $categoryCondition . $sidCondition . $districtCondition,
  937. 'groupby' => 'nature',
  938. 'asArray' => true
  939. ) );
  940. $statisticsNature = array ();
  941. foreach ( $this->nature as $value ) {
  942. $flagNature = true;
  943. foreach ( $natureList as $v ) {
  944. if ($value == $v ['nature']) {
  945. array_push ( $statisticsNature, array (
  946. 'value' => $v ['count'],
  947. 'name' => $value
  948. ) );
  949. $flagNature = false;
  950. break;
  951. }
  952. }
  953. if ($flagNature)
  954. array_push ( $statisticsNature, array (
  955. 'value' => 0,
  956. 'name' => $value
  957. ) );
  958. }
  959. $data ['statisticsNature'] = json_encode ( $statisticsNature );
  960. // print_r($statisticsLend);die;
  961. $data ['statisticsLend'] = json_encode ( $statisticsLend );
  962. $data ['status'] = $status;
  963. $data ['statisticsDay'] = json_encode ( $statisticsDay );
  964. $data ['statisticsClient'] = json_encode ( $statisticsClient );
  965. $data ['statisticsLongle'] = json_encode ( $statisticsLongle );
  966. $data ['statisticsGet'] = json_encode ( $statisticsGet );
  967. $data ['categorylist2'] = $categorylist2;
  968. $data ['Ssum'] = round ( ($Ssum / $Rsum) * 100 ) . '%';
  969. $data ['Rsum'] = $Rsum;
  970. $data ['useL2'] = $useL2;
  971. $data ['useL'] = $useL;
  972. $data ['sum'] = $sum;
  973. $data ['max'] = $max;
  974. $data ['max2'] = $max2;
  975. $data ['staffList'] = $staffList;
  976. $data ['cid'] = $cid;
  977. $data ['sid'] = $sid;
  978. $data ['memu'] = "index";
  979. $data ['staff'] = $this->staff;
  980. $this->render ( "/indexLongle", $data );
  981. }
  982. function index() {
  983. die ( 'dd' );
  984. $data ['memu'] = "index";
  985. $data ['staff'] = $this->staff;
  986. Doo::loadModel ( 'action_log' );
  987. $action_log = new action_log ();
  988. $data ['today'] = explode ( "-", date ( "Y-m-d" ) );
  989. $str = "";
  990. if ($this->staff [0] ['isadmin'] != 1) {
  991. $str = " and (action like '%" . $this->staff [0] ['category'] . "%'";
  992. $khql = explode ( ",", $this->staff [0] ['othercategory'] );
  993. if (! empty ( $khql [0] )) {
  994. foreach ( $khql as $key => $value ) {
  995. $str .= " or action like '%" . $value . "%'";
  996. }
  997. $str .= ")";
  998. } else
  999. $str .= ")";
  1000. }
  1001. $data ['actionListNow'] = $action_log->find ( array (
  1002. 'where' => ' updatetime=\'' . date ( "Y-m-d" ) . "'" . $str,
  1003. 'desc' => 'aid',
  1004. 'asArray' => TRUE
  1005. ) );
  1006. $d2 = mktime ( 0, 0, 0, date ( "m" ), date ( "d" ) - 1, date ( "Y" ) );
  1007. $strdate = date ( "Y-m-d", $d2 );
  1008. $data ['day2'] = explode ( "-", $strdate );
  1009. $data ['actionListNow2'] = $action_log->find ( array (
  1010. 'where' => ' updatetime=\'' . $strdate . "'" . $str,
  1011. 'desc' => 'aid',
  1012. 'asArray' => TRUE
  1013. ) );
  1014. $d3 = mktime ( 0, 0, 0, date ( "m" ), date ( "d" ) - 2, date ( "Y" ) );
  1015. $strdate = date ( "Y-m-d", $d3 );
  1016. $data ['day3'] = explode ( "-", $strdate );
  1017. $data ['actionListNow3'] = $action_log->find ( array (
  1018. 'where' => ' updatetime=\'' . $strdate . "'" . $str,
  1019. 'desc' => 'aid',
  1020. 'asArray' => TRUE
  1021. ) );
  1022. $d4 = mktime ( 0, 0, 0, date ( "m" ), date ( "d" ) - 3, date ( "Y" ) );
  1023. $strdate = date ( "Y-m-d", $d4 );
  1024. $data ['day4'] = explode ( "-", $strdate );
  1025. $data ['actionListNow4'] = $action_log->find ( array (
  1026. 'where' => ' updatetime=\'' . $strdate . "'" . $str,
  1027. 'asArray' => TRUE
  1028. ) );
  1029. $d5 = mktime ( 0, 0, 0, date ( "m" ), date ( "d" ) - 4, date ( "Y" ) );
  1030. $strdate = date ( "Y-m-d", $d5 );
  1031. $data ['day5'] = explode ( "-", $strdate );
  1032. $data ['actionListNow5'] = $action_log->find ( array (
  1033. 'where' => ' updatetime=\'' . $strdate . "'" . $str,
  1034. 'asArray' => TRUE
  1035. ) );
  1036. $d6 = mktime ( 0, 0, 0, date ( "m" ), date ( "d" ) - 5, date ( "Y" ) );
  1037. $strdate = date ( "Y-m-d", $d6 );
  1038. $data ['day6'] = explode ( "-", $strdate );
  1039. $data ['actionListNow6'] = $action_log->find ( array (
  1040. 'where' => ' updatetime=\'' . $strdate . "'" . $str,
  1041. 'asArray' => TRUE
  1042. ) );
  1043. $d7 = mktime ( 0, 0, 0, date ( "m" ), date ( "d" ) - 6, date ( "Y" ) );
  1044. $strdate = date ( "Y-m-d", $d7 );
  1045. $data ['day7'] = explode ( "-", $strdate );
  1046. $data ['actionListNow7'] = $action_log->find ( array (
  1047. 'where' => ' updatetime=\'' . $strdate . "'" . $str,
  1048. 'asArray' => TRUE
  1049. ) );
  1050. Doo::loadModel ( 'staff' );
  1051. Doo::loadModel ( 'client_staff' );
  1052. $client_staff = new client_staff ();
  1053. $staff = new staff ();
  1054. $st = $staff->find ( array (
  1055. 'where' => '1',
  1056. 'asArray' => true
  1057. ) );
  1058. foreach ( $st as $key => $value ) {
  1059. $st [$key] ['count'] = $client_staff->count ( array (
  1060. 'where' => 'sid=' . $value ['sid'],
  1061. 'asArray' => true
  1062. ) );
  1063. }
  1064. $data ['staffCount'] = $st;
  1065. $this->render ( "/index", $data );
  1066. }
  1067. function receive() {
  1068. $data ['memu'] = "keyonline";
  1069. $data ['staff'] = $this->staff;
  1070. Doo::loadModel ( 'longle' );
  1071. $longle = new longle ();
  1072. $data ['arrayReceive'] = $longle->getLongleReceive ( $this->staff [0] ['cid'], 1, $this->staff [0] ['othercid'] );
  1073. $this->render ( "/look_receive", $data );
  1074. }
  1075. function doLongleReceive() {
  1076. $arrLid = $this->get_args ( 'lid' ) ? $this->get_args ( 'lid' ) : array ();
  1077. Doo::loadModel ( 'longle_log' );
  1078. Doo::loadModel ( 'longle' );
  1079. foreach ( $arrLid as $key => $value ) {
  1080. $ky = explode ( "-", $value );
  1081. $longle = new longle ();
  1082. $longle_log = new longle_log ();
  1083. $longle->lid = $ky [0];
  1084. $longle->status = 2;
  1085. $longle->statusT = '接收';
  1086. $longle->responsible = $this->staff [0] ['username'];
  1087. // 记录锁状态
  1088. $longle->statuslog = "1,2";
  1089. $longle->update ();
  1090. $longle_log->lid = $ky [0];
  1091. $longle_log->status = 2;
  1092. $longle_log->statusT = '接收';
  1093. $longle_log->responsible = $this->staff [0] ['username'];
  1094. $longle_log->operator = $this->staff [0] ['username'];
  1095. $longle_log->category = $ky [1];
  1096. $longle_log->dateline = date ( "Y-m-d" );
  1097. $longle_log->insert ();
  1098. }
  1099. return "/receive";
  1100. }
  1101. function addClient() {
  1102. $this->get_args ( 'clientname' ) ? $this->get_args ( 'clientname' ) : "";
  1103. $clientname = $this->get_args ( 'clientname' ) ? $this->get_args ( 'clientname' ) : "";
  1104. $gender = $this->get_args ( 'gender' ) ? $this->get_args ( 'gender' ) : "";
  1105. $nicename = $this->get_args ( 'nicename' ) ? $this->get_args ( 'nicename' ) : "";
  1106. $telephone = $this->get_args ( 'telephone' ) ? $this->get_args ( 'telephone' ) : "";
  1107. $phone = $this->get_args ( 'phone' ) ? $this->get_args ( 'phone' ) : "";
  1108. $email = $this->get_args ( 'email' ) ? $this->get_args ( 'email' ) : "";
  1109. $qq = $this->get_args ( 'qq' ) ? $this->get_args ( 'qq' ) : "";
  1110. $tid = $this->get_args ( 'tid' ) ? $this->get_args ( 'tid' ) : "";
  1111. $companyname = $this->get_args ( 'companyname' ) ? $this->get_args ( 'companyname' ) : "";
  1112. $local1 = $this->get_args ( 'lv21' ) ? $this->get_args ( 'lv21' ) : "";
  1113. $local2 = $this->get_args ( 'lv22' ) ? $this->get_args ( 'lv22' ) : "";
  1114. $local3 = $this->get_args ( 'lv23' ) ? $this->get_args ( 'lv23' ) : "";
  1115. $nature = $this->get_args ( 'nature' ) ? $this->get_args ( 'nature' ) : "";
  1116. $fax = $this->get_args ( 'fax' ) ? $this->get_args ( 'fax' ) : "";
  1117. $webservice = $this->get_args ( 'webservice' ) ? $this->get_args ( 'webservice' ) : "";
  1118. $department = $this->get_args ( 'department' ) ? $this->get_args ( 'department' ) : "";
  1119. $position = $this->get_args ( 'position' ) ? $this->get_args ( 'position' ) : "";
  1120. $office = $this->get_args ( 'office' ) ? $this->get_args ( 'office' ) : "";
  1121. $address = $this->get_args ( 'address' ) ? $this->get_args ( 'address' ) : "";
  1122. $ride = $this->get_args ( 'ride' ) ? $this->get_args ( 'ride' ) : "";
  1123. $landmarks = $this->get_args ( 'landmarks' ) ? $this->get_args ( 'landmarks' ) : "";
  1124. $priority = $this->get_args ( 'priority' ) ? $this->get_args ( 'priority' ) : "";
  1125. $stay = $this->get_args ( 'stay' ) ? $this->get_args ( 'stay' ) : "";
  1126. $mark = $this->get_args ( 'mark' ) ? $this->get_args ( 'mark' ) : "";
  1127. $clientname = trim ( $clientname );
  1128. $companyname = trim ( $companyname );
  1129. if (empty ( $companyname ))
  1130. return "/contacts";
  1131. if (empty ( $this->staff [0] ['sid'] ))
  1132. return "/contacts";
  1133. if (! empty ( $clientname )) {
  1134. // 相同的公司和客户
  1135. Doo::loadModel ( 'company' );
  1136. $company = new company ();
  1137. Doo::loadModel ( 'client' );
  1138. $client = new client ();
  1139. $cinfo = $client->getClientByNameT ( $clientname );
  1140. if (! empty ( $cinfo )) {
  1141. $ninfo = $company->getCompanyByCompanyname ( $companyname );
  1142. if (! empty ( $ninfo )) {
  1143. foreach ( $cinfo as $key => $value ) { // 问题
  1144. if ($value ['companyid'] == $ninfo [0] ['cid'])
  1145. return "/contacts";
  1146. }
  1147. }
  1148. }
  1149. Doo::loadModel ( 'district' );
  1150. $district = new district ();
  1151. $companyInfo = $company->getOne ( array (
  1152. 'where' => "companyname = '" . $companyname . "'",
  1153. "asArray" => true
  1154. ) );
  1155. // 更新公司信息
  1156. $lv1 = $district->getbyid ( $local1 );
  1157. $lv2 = $district->getbyid ( $local2 );
  1158. $lv3 = $district->getbyid ( $local3 );
  1159. if (empty ( $lv1 ))
  1160. $lv1 [0] ['name'] = "";
  1161. if (empty ( $lv2 ))
  1162. $lv2 [0] ['name'] = "";
  1163. if (empty ( $lv3 ))
  1164. $lv3 [0] ['name'] = "";
  1165. if (! empty ( $local1 ) && ! empty ( $local2 ))
  1166. $company->local = $lv1 [0] ['name'] . "," . $lv2 [0] ['name'] . "," . $lv3 [0] ['name'];
  1167. if (! empty ( $nature ))
  1168. $company->nature = implode ( ',', $nature );
  1169. if (! empty ( $fax ))
  1170. $company->fax = $fax;
  1171. if (! empty ( $webservice ))
  1172. $company->webservice = $webservice;
  1173. if (! empty ( $address ))
  1174. $company->address = $address;
  1175. if (! empty ( $ride ))
  1176. $company->ride = $ride;
  1177. if (! empty ( $landmarks ))
  1178. $company->landmarks = $landmarks;
  1179. if (! empty ( $office ))
  1180. $company->office = $office;
  1181. if (! empty ( $local1 ) && ! empty ( $local2 ))
  1182. $company->district = $local1 . "," . $local2 . "," . $local3;
  1183. if (! empty ( $stay ))
  1184. $company->stay = $stay;
  1185. if (empty ( $companyInfo )) {
  1186. $company->companyname = $companyname;
  1187. $company->staffid = $this->staff [0] ['sid'];
  1188. $cid = $company->insert ();
  1189. } else { // 不编辑公司,地区判断,作为新公司
  1190. // $cid=$companyInfo['cid'];
  1191. //
  1192. // $companyname=$companyInfo['companyname'];
  1193. //
  1194. // $company->cid=$cid;
  1195. //
  1196. // $company->update();
  1197. $diqu = $local1 . "," . $local2 . "," . $local3;
  1198. $cid = $companyInfo ['cid'];
  1199. $company2 = new company ();
  1200. $companyList = $company2->find ( array (
  1201. 'where' => " companyname like '" . $companyname . "'",
  1202. "asArray" => true
  1203. ) );
  1204. $falg = false;
  1205. // print_r($companyList);
  1206. foreach ( $companyList as $key => $value ) {
  1207. if ($value ['district'] != $diqu) {
  1208. $falg = true;
  1209. } elseif ($value ['district'] == $diqu) {
  1210. $falg = false;
  1211. $cid = $value ['cid'];
  1212. break;
  1213. }
  1214. }
  1215. // var_dump($falg) ;die;
  1216. if ($falg) {
  1217. $company->companyname = $companyname;
  1218. $company->staffid = $this->staff [0] ['sid'];
  1219. $cid = $company->insert ();
  1220. }
  1221. }
  1222. Doo::loadModel ( 'client_staff' );
  1223. $client_staff = new client_staff ();
  1224. $client->clientname = $clientname;
  1225. $client->gender = $gender;
  1226. $client->priority = $priority;
  1227. if (! empty ( $nicename ))
  1228. $client->nicename = $nicename;
  1229. if (! empty ( $telephone ))
  1230. $client->telephone = $telephone;
  1231. if (! empty ( $phone ))
  1232. $client->phone = $phone;
  1233. if (! empty ( $email ))
  1234. $client->email = $email;
  1235. if (! empty ( $qq ) && is_numeric ( $qq ))
  1236. $client->qq = $qq;
  1237. $client->companyid = $cid;
  1238. $client->companyname = $companyname;
  1239. $client->district = $local1 . "," . $local2 . "," . $local3;
  1240. // echo $client->district;
  1241. // die;
  1242. if (! empty ( $tid ))
  1243. $client->tag = implode ( ',', $tid );
  1244. if (! empty ( $fax ))
  1245. $client->fax = $fax;
  1246. if (! empty ( $webservice ))
  1247. $client->webservice = $webservice;
  1248. if (! empty ( $department ))
  1249. $client->department = $department;
  1250. if (! empty ( $position ))
  1251. $client->position = $position;
  1252. if (! empty ( $office ))
  1253. $client->office = $office;
  1254. if (! empty ( $address ))
  1255. $client->address = $address;
  1256. if (! empty ( $ride ))
  1257. $client->ride = $ride;
  1258. if (! empty ( $landmarks ))
  1259. $client->landmarks = $landmarks;
  1260. if (! empty ( $stay ))
  1261. $client->stay = $stay;
  1262. if (! empty ( $mark ))
  1263. $client->mark = $mark;
  1264. $id = $client->insert ();
  1265. $client_staff->cid = $id;
  1266. $client_staff->sid = $this->staff [0] ['sid'];
  1267. $client_staff->insert ();
  1268. // 加入地区记录
  1269. Doo::loadModel ( "district_staff" );
  1270. $district_staff = new district_staff ();
  1271. $district_staff->did = $lv1 [0] ['id'];
  1272. $district_staff->sid = $this->staff [0] ['sid'];
  1273. $district_staff->insert ();
  1274. // 日常行为
  1275. Doo::loadModel ( "action_log" );
  1276. $action_log = new action_log ();
  1277. $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 . ')';
  1278. $action_log->sid = $this->staff [0] ['sid'];
  1279. $action_log->cid = $this->staff [0] ['cid'];
  1280. $action_log->updatetime = date ( "Y-m-d" );
  1281. $action_log->time = date ( "H:i" );
  1282. $action_log->status = 1;
  1283. $action_log->districtid = $local1 . "," . $local2 . "," . $local3;
  1284. $action_log->city = $lv1 [0] ['name'];
  1285. $action_log->province = $lv2 [0] ['name'];
  1286. if (isset ( $nature [0] ))
  1287. $action_log->nature = $nature [0];
  1288. $action_log->company = $companyname;
  1289. $action_log->class = $action_log->iconContacts;
  1290. $action_log->insert ();
  1291. }
  1292. return "/contacts";
  1293. }
  1294. function mycompany() {
  1295. $search = $this->get_args ( 'search' ) ? $this->get_args ( 'search' ) : "";
  1296. $districtLv = $this->get_args ( 'districtLv' ) ? $this->get_args ( 'districtLv' ) : 0;
  1297. $nature = $this->get_args ( 'nature' ) ? $this->get_args ( 'nature' ) : "";
  1298. $lv1 = $this->get_args ( 'lv1' ) ? $this->get_args ( 'lv1' ) : 0;
  1299. $lv2 = $this->get_args ( 'lv2' ) ? $this->get_args ( 'lv2' ) : 0;
  1300. $lv3 = $this->get_args ( 'lv3' ) ? $this->get_args ( 'lv3' ) : 0;
  1301. $tagList = $this->get_args ( 'tag' ) ? $this->get_args ( 'tag' ) : array ();
  1302. if ($lv1 == 0) {
  1303. $lv1 = isset ( $this->params ['lv1'] ) && is_numeric ( $this->params ['lv1'] ) ? $this->params ['lv1'] : 0;
  1304. if ($lv1 != 0)
  1305. $districtLv = 1;
  1306. }
  1307. if ($lv2 == 0) {
  1308. $lv2 = isset ( $this->params ['lv2'] ) && is_numeric ( $this->params ['lv2'] ) ? $this->params ['lv2'] : 0;
  1309. if ($lv2 != 0)
  1310. $districtLv = 2;
  1311. }
  1312. if ($lv3 == 0) {
  1313. $lv3 = isset ( $this->params ['lv3'] ) && is_numeric ( $this->params ['lv3'] ) ? $this->params ['lv3'] : 0;
  1314. if ($lv2 != 0)
  1315. $districtLv = 3;
  1316. }
  1317. if (empty ( $search ))
  1318. $search = urldecode ( isset ( $this->params ['search'] ) ? $this->params ['search'] : "" );
  1319. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  1320. $data ['memu'] = "contacts";
  1321. $data ['staff'] = $this->staff;
  1322. Doo::loadModel ( 'district' );
  1323. Doo::loadModel ( 'company' );
  1324. Doo::loadModel ( 'client' );
  1325. Doo::loadModel ( 'tag' );
  1326. Doo::loadModel ( 'L_category' );
  1327. $lcategory = new L_category ();
  1328. $tag = new tag ();
  1329. $client = new client ();
  1330. $company = new company ();
  1331. $district = new district ();
  1332. Doo::loadModel ( 'tagCompany' );
  1333. $tagCompany = new tagCompany ();
  1334. Doo::loadModel ( 'tagCompanyNexus' );
  1335. $tagCompanyNexus = new tagCompanyNexus ();
  1336. $data ['district2'] = $district->get_lv ( 1 );
  1337. $category = $lcategory->getCategoryById ( $this->staff [0] ['cid'], $this->staff [0] ['othercid'] );
  1338. $cateStr = "";
  1339. $list = array ();
  1340. foreach ( $category as $key => $value ) {
  1341. array_push ( $list, " district like '" . $value ['districtid'] . ",%' " );
  1342. }
  1343. if ($this->staff [0] ['isadmin'] != 1)
  1344. $cateStr = implode ( " or ", $list );
  1345. else
  1346. $cateStr = " 1";
  1347. $size = 300;
  1348. if (! empty ( $nature ))
  1349. $cateStr = " 1";
  1350. $data ['htmllv2'] = array ();
  1351. $data ['htmllv3'] = array ();
  1352. $condition = "";
  1353. if ($districtLv == 1) {
  1354. $condition = "";
  1355. if (! empty ( $lv1 )) {
  1356. $condition = " district like '" . $lv1 . ",%'";
  1357. $data ['htmllv2'] = $district->get_lvByid ( 2, $lv1 );
  1358. }
  1359. }
  1360. if ($districtLv == 2) {
  1361. if (! empty ( $lv2 ))
  1362. $condition = " district like '" . $lv1 . "," . $lv2 . ",%'";
  1363. else
  1364. $condition = " district like '" . $lv1 . ",%'";
  1365. $data ['htmllv2'] = $district->get_lvByid ( 2, $lv1 );
  1366. $data ['htmllv3'] = $district->get_lvByid ( 2, $lv2 );
  1367. }
  1368. if ($districtLv == 3) {
  1369. if (! empty ( $lv3 ))
  1370. $condition = " district like '" . $lv1 . "," . $lv2 . "," . $lv3 . "'";
  1371. else
  1372. $condition = " district like '" . $lv1 . "," . $lv2 . ",%'";
  1373. $data ['htmllv2'] = $district->get_lvByid ( 2, $lv1 );
  1374. $data ['htmllv3'] = $district->get_lvByid ( 2, $lv2 );
  1375. }
  1376. $districtCount = $condition;
  1377. if (! empty ( $condition ))
  1378. $cateStr = $condition;
  1379. if (! empty ( $nature ))
  1380. $cateStr .= " and nature like '%" . $nature . "%'";
  1381. // echo "<div style='display:none'>".$cateStr."</div><br/>";
  1382. $tagSQL = false;
  1383. if (! empty ( $tagList )) {
  1384. $tagSQL = true;
  1385. foreach ( $tagList as $value ) {
  1386. $cateStr .= " and a.tag like '%" . $value . "%' ";
  1387. }
  1388. }
  1389. if ($this->staff [0] ['isadmin'] != 1) {
  1390. $pageinfo = $this->get_Tpage ( "CLD_company", $cateStr, $page, $size, "", $tagSQL );
  1391. } else {
  1392. if ($tagSQL)
  1393. $pageinfo = $this->get_Tpage ( "CLD_company", $cateStr, $page, $size, "", $tagSQL );
  1394. else {
  1395. $total_page = $company->count ( array () );
  1396. $total = intval ( $total_page / $size );
  1397. $pageinfo ['total_page'] = ($total_page % $size) == 0 ? $total : $total + 1;
  1398. }
  1399. }
  1400. $k = "";
  1401. for($i = 1; $i <= $pageinfo ['total_page']; $i ++) {
  1402. if ($page == $i)
  1403. $k .= "<option value='" . $search . ":" . $i . ":" . $lv1 . ":" . $lv2 . ":" . $lv3 . "' selected>第" . $i . "页</option>";
  1404. else
  1405. $k .= "<option value='" . $search . ":" . $i . ":" . $lv1 . ":" . $lv2 . ":" . $lv3 . "'>第" . $i . "页</option>";
  1406. }
  1407. $data ['pageinfo'] = $k;
  1408. $data ['company'] = $company->getCompanyByDistrict ( $this->staff [0] ['sid'], $cateStr, $this->staff [0] ['isadmin'], $page, $size, $tagSQL );
  1409. if ($this->staff [0] ['isadmin'] != 1) {
  1410. $data ['district'] = $district->get_lvByStaffid ( 1, $this->staff [0] ['sid'] );
  1411. } else {
  1412. $data ['district'] = $data ['district2'];
  1413. }
  1414. // 获得标签
  1415. $ClientTagList = $tagCompanyNexus->getTagClientBySid ( $this->staff [0] ['sid'] );
  1416. foreach ( $ClientTagList as $key => $value ) {
  1417. $ClientTagList [$key] ['taginfo'] = $tagCompany->getTagByTidL ( $value ['tag'] );
  1418. }
  1419. foreach ( $data ['company'] as $key => $value ) {
  1420. if (! empty ( $value ['cid'] )) {
  1421. $data ['company'] [$key] ['taginfo'] = array ();
  1422. $data ['company'] [$key] ['tag'] = "";
  1423. foreach ( $ClientTagList as $k => $v ) {
  1424. if ($value ['cid'] == $v ['company']) {
  1425. $data ['company'] [$key] ['taginfo'] = $v ['taginfo'];
  1426. $data ['company'] [$key] ['tag'] = $v ['tag'];
  1427. }
  1428. }
  1429. }
  1430. }
  1431. $comcid = $countL = array ();
  1432. foreach ( $data ['company'] as $key => $value ) {
  1433. array_push ( $comcid, $value ['cid'] );
  1434. }
  1435. $comcid = implode ( ",", $comcid );
  1436. if (! empty ( $comcid ))
  1437. $countL = $client->getCountByCompany ( $comcid );
  1438. foreach ( $data ['company'] as $key => $value ) {
  1439. $data ['company'] [$key] ['count'] = 0;
  1440. foreach ( $countL as $k => $v ) {
  1441. if ($value ['cid'] == $v ['companyid']) {
  1442. $data ['company'] [$key] ['count'] = $v ['count'];
  1443. break;
  1444. }
  1445. }
  1446. }
  1447. $CC1 = "";
  1448. $CC2 = "";
  1449. $CC3 = "";
  1450. $natureHtml = '';
  1451. if (! empty ( $districtCount )) {
  1452. $clientCount = $company->find ( array (
  1453. 'select' => 'district',
  1454. 'where' => "district like '" . $lv1 . ",%'",
  1455. 'asArray' => TRUE
  1456. ) );
  1457. $CC1 = count ( $clientCount );
  1458. if (! empty ( $clientCount ) && ! empty ( $lv2 )) {
  1459. $CC2 = 0;
  1460. foreach ( $clientCount as $key => $value ) {
  1461. if (strpos ( $value ['district'], $lv2 )) {
  1462. $CC2 ++;
  1463. }
  1464. }
  1465. }
  1466. if (! empty ( $clientCount ) && ! empty ( $lv3 )) {
  1467. $CC3 = 0;
  1468. foreach ( $clientCount as $key => $value ) {
  1469. if (strpos ( $value ['district'], $lv3 )) {
  1470. $CC3 ++;
  1471. }
  1472. }
  1473. }
  1474. $clientCount = $company->find ( array (
  1475. 'select' => 'district,nature',
  1476. 'where' => $districtCount,
  1477. 'asArray' => TRUE
  1478. ) );
  1479. $natureCount = array ();
  1480. foreach ( $this->nature as $value ) {
  1481. $natureCount [$value] = 0;
  1482. foreach ( $clientCount as $v ) {
  1483. $ak = explode ( ",", $v ['nature'] );
  1484. foreach ( $ak as $a ) {
  1485. if ($value == $a) {
  1486. $natureCount [$value] ++;
  1487. }
  1488. }
  1489. }
  1490. }
  1491. }
  1492. $natureHtml = '';
  1493. foreach ( $this->nature as $value ) {
  1494. $natureHtml .= '<a href="javascript:void(0)" ';
  1495. if ($value == $nature)
  1496. $natureHtml .= 'class="now"';
  1497. if (isset ( $natureCount [$value] ))
  1498. $natureHtml .= 'onclick="showNature(\'' . $value . '\',this)">' . $value . '(' . $natureCount [$value] . ')</a>';
  1499. else
  1500. $natureHtml .= 'onclick="showNature(\'' . $value . '\',this)">' . $value . '</a>';
  1501. }
  1502. $taglist = $tagCompany->find ( array (
  1503. 'where' => 'sid=' . $this->staff [0] ['sid'],
  1504. 'asArray' => TRUE
  1505. ) );
  1506. if (empty ( $taglist )) {
  1507. for($i = 1; $i <= 7; $i ++) {
  1508. $tag = new tagCompany ();
  1509. $tag->name = "个人标签";
  1510. $tag->sid = $this->staff [0] ['sid'];
  1511. $tag->colorid = $i;
  1512. $tag->insert ();
  1513. }
  1514. }
  1515. $data ['product'] = array ();
  1516. $data ['tagList'] = $tagList;
  1517. $data ['tag'] = $tagCompany->getAllBySid ( $this->staff [0] ['sid'] );
  1518. $data ['natureHtml'] = $natureHtml;
  1519. $data ['CC1'] = $CC1;
  1520. $data ['CC2'] = $CC2;
  1521. $data ['CC3'] = $CC3;
  1522. $data ['lv1'] = $lv1;
  1523. $data ['lv2'] = $lv2;
  1524. $data ['lv3'] = $lv3;
  1525. $data ['districtLv'] = $districtLv;
  1526. $data ['Hnature'] = $nature;
  1527. $data ['nature'] = $this->nature;
  1528. $this->render ( "/contacts_company", $data );
  1529. }
  1530. function contacts() {
  1531. $data ['memu'] = "contacts";
  1532. $data ['staff'] = $this->staff;
  1533. $search = $this->get_args ( 'search' ) ? trim ( $this->get_args ( 'search' ) ) : "";
  1534. if (empty ( $search ))
  1535. $search = urldecode ( isset ( $this->params ['search'] ) ? $this->params ['search'] : "" );
  1536. $lv1 = $this->get_args ( 'lv1' ) ? $this->get_args ( 'lv1' ) : 0;
  1537. $lv2 = $this->get_args ( 'lv2' ) ? $this->get_args ( 'lv2' ) : 0;
  1538. $lv3 = $this->get_args ( 'lv3' ) ? $this->get_args ( 'lv3' ) : 0;
  1539. $lv4 = $this->get_args ( 'lv4' ) ? $this->get_args ( 'lv4' ) : "";
  1540. $tagList = $this->get_args ( 'tag' ) ? $this->get_args ( 'tag' ) : array ();
  1541. $tooltip = $this->get_args ( 'tooltip' ) ? $this->get_args ( 'tooltip' ) : "";
  1542. $districtLv = $this->get_args ( 'districtLv' ) ? $this->get_args ( 'districtLv' ) : 0;
  1543. if ($lv1 == 0) {
  1544. $lv1 = isset ( $this->params ['lv1'] ) && is_numeric ( $this->params ['lv1'] ) ? $this->params ['lv1'] : 0;
  1545. if ($lv1 != 0)
  1546. $districtLv = 1;
  1547. }
  1548. if ($lv2 == 0) {
  1549. $lv2 = isset ( $this->params ['lv2'] ) && is_numeric ( $this->params ['lv2'] ) ? $this->params ['lv2'] : 0;
  1550. if ($lv2 != 0)
  1551. $districtLv = 2;
  1552. }
  1553. if ($lv3 == 0) {
  1554. $lv3 = isset ( $this->params ['lv3'] ) && is_numeric ( $this->params ['lv3'] ) ? $this->params ['lv3'] : 0;
  1555. if ($lv2 != 0)
  1556. $districtLv = 3;
  1557. }
  1558. $sortV = $this->get_args ( 'sortV' ) ? $this->get_args ( 'sortV' ) : "h";
  1559. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  1560. Doo::loadModel ( 'client_staff' );
  1561. Doo::loadModel ( 'client' );
  1562. Doo::loadModel ( 'tag' );
  1563. Doo::loadModel ( 'district' );
  1564. Doo::loadModel ( 'tag_client' );
  1565. Doo::loadModel ( 'L_category' );
  1566. Doo::loadModel ( 'longle' );
  1567. Doo::loadModel ( 'C_tooltip' );
  1568. $c_tooltip = new C_tooltip ();
  1569. $longle = new longle ();
  1570. $client = new client ();
  1571. $category = new L_category ();
  1572. $tagClient = new tag_client ();
  1573. $district = new district ();
  1574. $tag = new tag ();
  1575. $client_staff = new client_staff ();
  1576. $data ['tag'] = $tag->getAllBySid ( $this->staff [0] ['sid'] );
  1577. $data ['district2'] = $district->get_lv ( 1 );
  1578. $page_size = 200;
  1579. $linfo = $category->getCategoryById ( $this->staff [0] ['cid'], $this->staff ['0'] ['othercid'] );
  1580. $staffid = $condition = $a = "";
  1581. if ($this->staff [0] ['isadmin'] != 1) {
  1582. // 加入办事处地区
  1583. $data ['district'] = $district->get_lvByStaffid ( 1, $this->staff [0] ['sid'] );
  1584. if (! empty ( $search ))
  1585. $sch = " and ( address like '%" . $search . "%' or clientname like '%" . $search . "%' or companyname like '%" . $search . "%' or qq like '%" . $search . "%' or telephone like '%" . $search . "%' or phone like '%" . $search . "%')";
  1586. else {
  1587. // or b.district like '".$linfo[0]['districtid']."%'
  1588. $a = " and b.district like '" . $linfo [0] ['districtid'] . "%'";
  1589. if (! empty ( $tooltip ))
  1590. $sch = "";
  1591. $search = urldecode ( isset ( $this->params ['search'] ) ? $this->params ['search'] : "" );
  1592. if (! empty ( $search ))
  1593. $sch = " and ( address like '%" . $search . "%' or clientname like '%" . $search . "%' or companyname like '%" . $search . "%' or qq like '%" . $search . "%' or telephone like '%" . $search . "%' or phone like '%" . $search . "%')";
  1594. else {
  1595. $staffid = $data ['staff'] [0] ['sid'];
  1596. $sqstr = "";
  1597. foreach ( $linfo as $key => $value ) {
  1598. if ($key != 0) {
  1599. $sqstr .= " or b.district like '" . $value ['districtid'] . ",%'";
  1600. }
  1601. }
  1602. $a = "and b.district like '" . $linfo [0] ['districtid'] . ",%'" . $sqstr;
  1603. }
  1604. }
  1605. } else {
  1606. $data ['district'] = $data ['district2'];
  1607. if (! empty ( $search ))
  1608. $sch = " and ( address like '%" . $search . "%' or clientname like '%" . $search . "%' or companyname like '%" . $search . "%' or qq like '%" . $search . "%' or telephone like '%" . $search . "%' or phone like '%" . $search . "%')";
  1609. else {
  1610. $sch = " ";
  1611. $search = urldecode ( isset ( $this->params ['search'] ) ? $this->params ['search'] : "" );
  1612. if (! empty ( $search ))
  1613. $sch = " and ( address like '%" . $search . "%' or clientname like '%" . $search . "%' or companyname like '%" . $search . "%' or qq like '%" . $search . "%' or telephone like '%" . $search . "%' or phone like '%" . $search . "%')";
  1614. }
  1615. }
  1616. $data ['htmllv2'] = $data ['htmllv3'] = array ();
  1617. if ($districtLv == 1) {
  1618. $a = "";
  1619. $condition = "";
  1620. if (! empty ( $lv1 )) {
  1621. $condition .= " and district like '" . $lv1 . ",%'";
  1622. $data ['htmllv2'] = $district->get_lvByid ( 2, $lv1 );
  1623. }
  1624. }
  1625. if ($districtLv == 2) {
  1626. $a = "";
  1627. if (! empty ( $lv2 ))
  1628. $condition .= " and district like '" . $lv1 . "," . $lv2 . ",%'";
  1629. else
  1630. $condition .= " and district like '" . $lv1 . ",%'";
  1631. $data ['htmllv2'] = $district->get_lvByid ( 2, $lv1 );
  1632. $data ['htmllv3'] = $district->get_lvByid ( 2, $lv2 );
  1633. }
  1634. if ($districtLv == 3) {
  1635. $a = "";
  1636. if (! empty ( $lv3 ))
  1637. $condition .= " and district like '" . $lv1 . "," . $lv2 . "," . $lv3 . "'";
  1638. else
  1639. $condition .= " and district like '" . $lv1 . "," . $lv2 . ",%'";
  1640. $data ['htmllv2'] = $district->get_lvByid ( 2, $lv1 );
  1641. $data ['htmllv3'] = $district->get_lvByid ( 2, $lv2 );
  1642. }
  1643. $condition .= $a;
  1644. $districtCount = $condition;
  1645. if (! empty ( $lv4 )) {
  1646. $condition .= " and nature like '%" . $lv4 . "%'";
  1647. }
  1648. $tagSQL = false;
  1649. if (! empty ( $tagList )) {
  1650. $tagSQL = true;
  1651. foreach ( $tagList as $value ) {
  1652. $condition .= " and c.tag like '%" . $value . "%' ";
  1653. }
  1654. $search = "";
  1655. }
  1656. if (! empty ( $search ))
  1657. $condition .= $sch;
  1658. // if(!empty($tooltip))
  1659. // $condition.=" and tooltip like '%".$tooltip."%'";
  1660. $pageinfo = $this->get_page ( "CLD_client_staff", $condition, $page, $page_size, "", "", "", $staffid, $search, $tooltip, $this->staff [0] ['cid'], $tagSQL );
  1661. if ($sortV == "h") { // order by a.cid desc
  1662. $limit = " order by cid desc limit " . $pageinfo ['lower'] . " , " . $page_size . " ";
  1663. }
  1664. if ($sortV == "g") { // order by updatetime desc
  1665. $limit = " limit " . $pageinfo ['lower'] . " , " . $page_size . " ";
  1666. }
  1667. if ($sortV == "f") { // order by updatetime desc
  1668. $limit = " limit " . $pageinfo ['lower'] . " , " . $page_size . " ";
  1669. }
  1670. if ($sortV == "i") { // order by servicetime desc
  1671. $limit = " limit " . $pageinfo ['lower'] . " , " . $page_size . " ";
  1672. }
  1673. // 检索是全局
  1674. $data ['clientInfo'] = $client_staff->getClientByStaff ( $condition, $limit, $staffid, $this->staff [0] ['sid'], $search, $tooltip, $this->staff [0] ['cid'], $tagSQL );
  1675. // 获取其他办事处的客户
  1676. // if(!empty($districtstr)){
  1677. // $buclient=$client->getClientByDistrict($districtstr);
  1678. //
  1679. // foreach ($buclient as $key=>$vlaue){
  1680. //
  1681. // $falg=true;
  1682. //
  1683. // foreach ($data['clientInfo'] as $y=>$v){
  1684. // if($vlaue['clientname']==$v['clientname']&&$vlaue['companyname']==$v['companyname'])
  1685. // $falg=false;
  1686. // }
  1687. // if($falg)
  1688. // array_push($data['clientInfo'], $vlaue);
  1689. // }
  1690. //
  1691. // }
  1692. $k = "";
  1693. for($i = 1; $i <= $pageinfo ['total_page']; $i ++) {
  1694. if ($page == $i)
  1695. $k .= "<option value='" . $search . ":" . $i . ":" . $lv1 . ":" . $lv2 . ":" . $lv3 . "' selected>第" . $i . "页</option>";
  1696. else
  1697. $k .= "<option value='" . $search . ":" . $i . ":" . $lv1 . ":" . $lv2 . ":" . $lv3 . "'>第" . $i . "页</option>";
  1698. }
  1699. $data ['pageinfo'] = $k;
  1700. Doo::loadModel ( 'product' );
  1701. $product = new product ();
  1702. $data ['nature'] = $this->nature;
  1703. $data ['product'] = $product->getProudct ();
  1704. // 获得标签
  1705. $ClientTagList = $tagClient->getTagClientBySid ( $this->staff [0] ['sid'] );
  1706. $toollist = $c_tooltip->find ( array (
  1707. 'where' => 'cateid=' . $this->staff [0] ['cid'],
  1708. 'asArray' => true
  1709. ) );
  1710. // $ToolTipList=$
  1711. foreach ( $ClientTagList as $key => $value ) {
  1712. $ClientTagList [$key] ['taginfo'] = $tag->getTagByTidL ( $value ['tag'] );
  1713. }
  1714. // print_r($ClientTagList);die;
  1715. foreach ( $data ['clientInfo'] as $key => $value ) {
  1716. if (! empty ( $value ['cid'] )) {
  1717. // $tinfo=$tagClient->getTagClientBySCid($value['cid'], $this->staff[0]['sid']);
  1718. $data ['clientInfo'] [$key] ['taginfo'] = array ();
  1719. $data ['clientInfo'] [$key] ['tag'] = "";
  1720. foreach ( $ClientTagList as $k => $v ) {
  1721. // $tag->getTagByTidL($value['tag']);$value['tag'];
  1722. if ($value ['cid'] == $v ['client']) {
  1723. $data ['clientInfo'] [$key] ['taginfo'] = $v ['taginfo'];
  1724. $data ['clientInfo'] [$key] ['tag'] = $v ['tag'];
  1725. }
  1726. }
  1727. // array_pop 可以优化数组
  1728. }
  1729. $data ['clientInfo'] [$key] ['tooltipList'] = array ();
  1730. foreach ( $toollist as $k => $v ) {
  1731. if ($v ['cid'] == $value ['cid']) {
  1732. $data ['clientInfo'] [$key] ['tooltipList'] = explode ( ",", $v ['name'] );
  1733. break;
  1734. } // array_pop 可以优化数组
  1735. }
  1736. // $tl=array();
  1737. // if(!empty($value['tooltip']))
  1738. // $tl=explode(',', $value['tooltip']);
  1739. // $data['clientInfo'][$key]['tooltipList']=$tl;
  1740. $data ['clientInfo'] [$key] ['locount'] = 0; // $longle->count(array('where'=>'clientid='.$value['cid']));
  1741. }
  1742. $CC1 = "";
  1743. $CC2 = "";
  1744. $CC3 = "";
  1745. if (! empty ( $districtCount )) {
  1746. $clientCount = $client->find ( array (
  1747. 'select' => 'district',
  1748. 'where' => "district like '" . $lv1 . ",%'",
  1749. 'asArray' => TRUE
  1750. ) );
  1751. $CC1 = count ( $clientCount );
  1752. if (! empty ( $clientCount ) && ! empty ( $lv2 )) {
  1753. $CC2 = 0;
  1754. foreach ( $clientCount as $key => $value ) {
  1755. if (strpos ( $value ['district'], $lv2 )) {
  1756. $CC2 ++;
  1757. }
  1758. }
  1759. }
  1760. if (! empty ( $clientCount ) && ! empty ( $lv3 )) {
  1761. $CC3 = 0;
  1762. foreach ( $clientCount as $key => $value ) {
  1763. if (strpos ( $value ['district'], $lv3 )) {
  1764. $CC3 ++;
  1765. }
  1766. }
  1767. }
  1768. }
  1769. Doo::loadModel ( 'remind' );
  1770. $remind = new remind ();
  1771. // and date_add(time, INTERVAL day DAY) <= CURDATE()
  1772. $remindList = $remind->find ( array (
  1773. 'where' => "staffID = '" . $this->staff [0] ['sid'] . "' and status=0 ",
  1774. 'asc' => 'date_add(time, INTERVAL day DAY)',
  1775. 'asArray' => TRUE
  1776. ) );
  1777. $rc = 0;
  1778. foreach ( $remindList as $key => $value ) {
  1779. $a = strtotime ( $value ['time'] . " +" . $value ['day'] . " days" );
  1780. $b = strtotime ( date ( 'y-m-d' ) );
  1781. if ($a <= $b) {
  1782. $rc ++;
  1783. $remindList [$key] ['isRemind'] = 1;
  1784. } else
  1785. $remindList [$key] ['isRemind'] = 0;
  1786. $remindList [$key] ['Ctime'] = date ( 'm-d', strtotime ( $value ['time'] ) );
  1787. $remindList [$key] ['Etime'] = date ( 'm-d', strtotime ( $value ['time'] . " +" . $value ['day'] . " days" ) );
  1788. }
  1789. $data ['remindCount'] = $rc;
  1790. $data ['remindList'] = $remindList;
  1791. $data ['CC1'] = $CC1;
  1792. $data ['CC2'] = $CC2;
  1793. $data ['CC3'] = $CC3;
  1794. $data ['lv1'] = $lv1;
  1795. $data ['lv2'] = $lv2;
  1796. $data ['lv3'] = $lv3;
  1797. $data ['lv4'] = $lv4;
  1798. $data ['districtLv'] = $districtLv;
  1799. $data ['tagList'] = $tagList;
  1800. $data ['tooltip'] = $this->tooltip;
  1801. $data ['ttip'] = $tooltip;
  1802. $data ['search'] = $search;
  1803. $data ['totalData'] = $pageinfo ['total_data'];
  1804. // $data['messagehtml']=$html;
  1805. $this->render ( "/contacts_client", $data );
  1806. }
  1807. function remindCL() {
  1808. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1809. Doo::loadModel ( 'remind' );
  1810. $remind = new remind ();
  1811. $remind->status = 1;
  1812. $remind->update ( array (
  1813. 'where' => "staffID = '" . $this->staff [0] ['sid'] . "' and rid=" . $rid,
  1814. 'asArray' => TRUE
  1815. ) );
  1816. return "/contacts";
  1817. }
  1818. function communication() {
  1819. $data ['memu'] = "contacts";
  1820. $data ['staff'] = $this->staff;
  1821. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  1822. Doo::loadModel ( 'L_category' );
  1823. $L_category = new L_category ();
  1824. Doo::loadModel ( 'staff' );
  1825. $staff = new staff ();
  1826. Doo::loadModel ( 'staffDynamic' );
  1827. $staffDynamic = new staffDynamic ();
  1828. if (! empty ( $cid ))
  1829. $data ['staffList'] = $staff->getStaffByCid ( $cid );
  1830. else
  1831. $data ['staffList'] = $staff->getStaff ();
  1832. foreach ( $data ['staffList'] as $key => $value ) {
  1833. if (! empty ( $value ['birthday'] )) {
  1834. $dataD = date ( "d", strtotime ( $value ['birthday'] ) );
  1835. if (date ( 'm' ) == date ( "m", strtotime ( $value ['birthday'] ) )) {
  1836. $now = date ( 'd' );
  1837. $post = $dataD - 7; // date("d",mktime(0,0,0,date("m"),date("d")+7,date("Y")));
  1838. if ($now >= $post && $now <= $dataD) {
  1839. $data ['staffList'] [$key] ['birthday'] = "birthday";
  1840. $data ['staffList'] [$key] ['birthDAY'] = date ( "m-d", strtotime ( $value ['birthday'] ) );
  1841. }
  1842. }
  1843. }
  1844. $happy = date ( "m-d", strtotime ( $value ['birthday'] ) );
  1845. if ($happy == date ( 'm-d' )) {
  1846. $SBL = $staffDynamic->getStaffBirthday ( $happy, $value ['sid'] );
  1847. if (empty ( $SBL )) {
  1848. $staffDynamic->content = '<img src="/global/img/cake.gif"><span class="colOrange">今天过生日!</span>';
  1849. $staffDynamic->cid = $value ['cid'];
  1850. $staffDynamic->category = $value ['category'];
  1851. $staffDynamic->time = time ();
  1852. $staffDynamic->sid = $value ['sid'];
  1853. $staffDynamic->staff = $value ['username'];
  1854. $staffDynamic->insert ();
  1855. }
  1856. }
  1857. }
  1858. $sDynaimic = $staffDynamic->getStaffDynamic ();
  1859. foreach ( $sDynaimic as $key => $value ) {
  1860. $time = date ( "Y-m-d", $value ['time'] );
  1861. $timeArray = explode ( '-', $time );
  1862. $sDynaimic [$key] ['year'] = $timeArray [0];
  1863. $sDynaimic [$key] ['month'] = $timeArray [1];
  1864. $sDynaimic [$key] ['day'] = $timeArray [2];
  1865. }
  1866. $data ['sDynaimic'] = $sDynaimic;
  1867. $data ['category'] = $L_category->getCategory ();
  1868. $data ['cid'] = $cid;
  1869. $this->render ( "/staff_contacts", $data );
  1870. }
  1871. function app() {
  1872. $data ['memu'] = "app";
  1873. $data ['staff'] = $this->staff;
  1874. $this->render ( "/app", $data );
  1875. }
  1876. function synClient() {
  1877. if ($this->staff [0] ['isadmin'] != 1) {
  1878. Doo::loadModel ( 'L_category' );
  1879. Doo::loadModel ( 'client_staff' );
  1880. $client_staff = new client_staff ();
  1881. $cate = new L_category ();
  1882. $district = $cate->getOne ( array (
  1883. 'where' => 'cid=' . $this->staff [0] ['cid'],
  1884. 'asArray' => true
  1885. ) );
  1886. $syn = $client_staff->synClient ( $this->staff [0] ['sid'], $district ['districtid'] );
  1887. $bei = $client_staff->find ( array (
  1888. 'where' => "sid = " . $this->staff [0] ['sid'],
  1889. 'asArray' => true
  1890. ) );
  1891. foreach ( $syn as $value ) {
  1892. $falg = true;
  1893. foreach ( $bei as $v ) {
  1894. if (($v ['cid'] == $value ['cid']) && ($v ['sid'] == $this->staff [0] ['sid'])) {
  1895. $falg = false;
  1896. break;
  1897. }
  1898. }
  1899. if ($falg) {
  1900. $client_staff = new client_staff ();
  1901. $client_staff->sid = $this->staff [0] ['sid'];
  1902. $client_staff->cid = $value ['cid'];
  1903. $client_staff->insert ();
  1904. }
  1905. }
  1906. }
  1907. return "/contacts";
  1908. }
  1909. function DoAddTagCompany() {
  1910. $cid = $this->get_args ( 'id' );
  1911. $tid = $this->get_args ( 'tagALD' );
  1912. Doo::loadModel ( 'tagCompanyNexus' );
  1913. $strtid = implode ( ",", $tid );
  1914. foreach ( $cid as $key => $value ) {
  1915. $tagClient = new tagCompanyNexus ();
  1916. $tagClientInfo = $tagClient->getTagClientBySCid ( $value, $this->staff [0] ['sid'] );
  1917. $ar = explode ( ",", $strtid . ',' . $tagClientInfo ['tag'] );
  1918. $re = array_filter ( array_unique ( $ar ) );
  1919. $tagClient->tag = implode ( ",", $re );
  1920. if (! empty ( $tagClientInfo )) {
  1921. $tagClient->tcid = $tagClientInfo ['tcid'];
  1922. $tagClient->update ();
  1923. } else {
  1924. $tagClient->sid = $this->staff [0] ['sid'];
  1925. $tagClient->company = $value;
  1926. $tagClient->insert ();
  1927. }
  1928. }
  1929. header ( "Location: /mycompany" );
  1930. }
  1931. function DoAddTag() {
  1932. $cid = $this->get_args ( 'id' );
  1933. $tooltipAct = $this->get_args ( 'tooltipAct' ) ? $this->get_args ( 'tooltipAct' ) : "";
  1934. Doo::loadModel ( 'client' );
  1935. if (! empty ( $tooltipAct )) {
  1936. $tid = $this->get_args ( 'tooltiplist' );
  1937. $k = implode ( ",", $tid );
  1938. Doo::loadModel ( 'C_tooltip' );
  1939. $s = " and cateid=" . $this->staff [0] ['cid'];
  1940. if (! empty ( $this->staff [0] ['othercid'] )) {
  1941. $othercid = explode ( ",", $this->staff [0] ['othercid'] );
  1942. foreach ( $othercid as $value ) {
  1943. $s .= " or cateid=" . $value;
  1944. }
  1945. }
  1946. foreach ( $cid as $key => $value ) {
  1947. $C_tooltip = new C_tooltip ();
  1948. $tooltip = $C_tooltip->getOne ( array (
  1949. 'where' => 'cid=' . $value . " " . $s,
  1950. 'asArray' => true
  1951. ) );
  1952. if (empty ( $tooltip )) {
  1953. $C_tooltip->cid = $value;
  1954. $C_tooltip->name = $k;
  1955. $C_tooltip->cateid = $this->staff [0] ['cid'];
  1956. $C_tooltip->insert ();
  1957. } else {
  1958. $C_tooltip->tip = $tooltip ['tip'];
  1959. $C_tooltip->name = $k;
  1960. $C_tooltip->update ();
  1961. }
  1962. }
  1963. } else {
  1964. $tid = $this->get_args ( 'tagALD' );
  1965. Doo::loadModel ( 'tag_client' );
  1966. $strtid = implode ( ",", $tid );
  1967. foreach ( $cid as $key => $value ) {
  1968. $tagClient = new tag_client ();
  1969. $tagClientInfo = $tagClient->getTagClientBySCid ( $value, $this->staff [0] ['sid'] );
  1970. $ar = explode ( ",", $strtid . ',' . $tagClientInfo ['tag'] );
  1971. $re = array_filter ( array_unique ( $ar ) );
  1972. $tagClient->tag = implode ( ",", $re );
  1973. if (! empty ( $tagClientInfo )) {
  1974. $tagClient->tcid = $tagClientInfo ['tcid'];
  1975. $tagClient->update ();
  1976. } else {
  1977. $tagClient->sid = $this->staff [0] ['sid'];
  1978. $tagClient->client = $value;
  1979. $tagClient->insert ();
  1980. }
  1981. }
  1982. }
  1983. header ( "Location: /contacts" );
  1984. }
  1985. function ajaxDeleteTag() {
  1986. $cid = $this->get_args ( 'cid' );
  1987. $tid = $this->get_args ( 'tid' );
  1988. Doo::loadModel ( 'tag_client' );
  1989. $tagClient = new tag_client ();
  1990. $tagInfo = $tagClient->getTagClientBySCid ( $cid, $this->staff [0] ['sid'] );
  1991. $tag = str_replace ( $tid, "", $tagInfo ['tag'] );
  1992. $ar = explode ( ',', $tag );
  1993. $tag = implode ( ',', array_filter ( $ar ) );
  1994. $tagClient->tcid = $tagInfo ['tcid'];
  1995. $tagClient->tag = $tag;
  1996. $tagClient->update ();
  1997. }
  1998. function ajaxDeleteTagCompany() {
  1999. $cid = $this->get_args ( 'cid' );
  2000. $tid = $this->get_args ( 'tid' );
  2001. Doo::loadModel ( 'tagCompanyNexus' );
  2002. $tagClient = new tagCompanyNexus ();
  2003. $tagInfo = $tagClient->getTagClientBySCid ( $cid, $this->staff [0] ['sid'] );
  2004. $tag = str_replace ( $tid, "", $tagInfo ['tag'] );
  2005. $ar = explode ( ',', $tag );
  2006. $tag = implode ( ',', array_filter ( $ar ) );
  2007. $tagClient->tcid = $tagInfo ['tcid'];
  2008. $tagClient->tag = $tag;
  2009. $tagClient->update ();
  2010. }
  2011. function deleteToolTip() {
  2012. $cid = $this->get_args ( 'cid' );
  2013. $cateid = $this->get_args ( 'cateid' );
  2014. $name = $this->get_args ( 'name' );
  2015. Doo::loadModel ( "C_tooltip" );
  2016. $tooltip = new C_tooltip ();
  2017. if (! empty ( $cid ) && ! empty ( $cateid ) && ! empty ( $name )) {
  2018. $tool = $tooltip->getOne ( array (
  2019. 'where' => 'cid=' . $cid . ' and cateid=' . $cateid,
  2020. 'asArray' => true
  2021. ) );
  2022. if (! empty ( $tool )) {
  2023. $name = str_replace ( $name, "", $tool ['name'] );
  2024. $name = explode ( ',', $name );
  2025. $name = implode ( ',', array_filter ( $name ) );
  2026. $tooltip->name = $name;
  2027. $tooltip->tip = $tool ['tip'];
  2028. $tooltip->update ();
  2029. }
  2030. }
  2031. }
  2032. function DoEdiTagCompany() {
  2033. $tag_1 = $this->get_args ( 'tag_1' ) ? $this->get_args ( 'tag_1' ) : "";
  2034. $tag_2 = $this->get_args ( 'tag_2' ) ? $this->get_args ( 'tag_2' ) : "";
  2035. $tag_3 = $this->get_args ( 'tag_3' ) ? $this->get_args ( 'tag_3' ) : "";
  2036. $tag_4 = $this->get_args ( 'tag_4' ) ? $this->get_args ( 'tag_4' ) : "";
  2037. $tag_5 = $this->get_args ( 'tag_5' ) ? $this->get_args ( 'tag_5' ) : "";
  2038. $tag_6 = $this->get_args ( 'tag_6' ) ? $this->get_args ( 'tag_6' ) : "";
  2039. $tag_7 = $this->get_args ( 'tag_7' ) ? $this->get_args ( 'tag_7' ) : "";
  2040. $tid_1 = $this->get_args ( 'tid_1' ) ? $this->get_args ( 'tid_1' ) : 0;
  2041. $tid_2 = $this->get_args ( 'tid_2' ) ? $this->get_args ( 'tid_2' ) : 0;
  2042. $tid_3 = $this->get_args ( 'tid_3' ) ? $this->get_args ( 'tid_3' ) : 0;
  2043. $tid_4 = $this->get_args ( 'tid_4' ) ? $this->get_args ( 'tid_4' ) : 0;
  2044. $tid_5 = $this->get_args ( 'tid_5' ) ? $this->get_args ( 'tid_5' ) : 0;
  2045. $tid_6 = $this->get_args ( 'tid_6' ) ? $this->get_args ( 'tid_6' ) : 0;
  2046. $tid_7 = $this->get_args ( 'tid_7' ) ? $this->get_args ( 'tid_7' ) : 0;
  2047. Doo::loadModel ( 'tagCompany' );
  2048. if (! empty ( $tag_1 ) && ! empty ( $tid_1 )) {
  2049. $tag = new tagCompany ();
  2050. $tag->tid = $tid_1;
  2051. $tag->name = $tag_1;
  2052. $tag->update ();
  2053. }
  2054. if (! empty ( $tag_2 ) && ! empty ( $tid_2 )) {
  2055. $tag = new tagCompany ();
  2056. $tag->tid = $tid_2;
  2057. $tag->name = $tag_2;
  2058. $tag->update ();
  2059. }
  2060. if (! empty ( $tag_3 ) && ! empty ( $tid_3 )) {
  2061. $tag = new tagCompany ();
  2062. $tag->tid = $tid_3;
  2063. $tag->name = $tag_3;
  2064. $tag->update ();
  2065. }
  2066. if (! empty ( $tag_4 ) && ! empty ( $tid_4 )) {
  2067. $tag = new tagCompany ();
  2068. $tag->tid = $tid_4;
  2069. $tag->name = $tag_4;
  2070. $tag->update ();
  2071. }
  2072. if (! empty ( $tag_5 ) && ! empty ( $tid_5 )) {
  2073. $tag = new tagCompany ();
  2074. $tag->tid = $tid_5;
  2075. $tag->name = $tag_5;
  2076. $tag->update ();
  2077. }
  2078. if (! empty ( $tag_6 ) && ! empty ( $tid_6 )) {
  2079. $tag = new tagCompany ();
  2080. $tag->tid = $tid_6;
  2081. $tag->name = $tag_6;
  2082. $tag->update ();
  2083. }
  2084. if (! empty ( $tag_7 ) && ! empty ( $tid_7 )) {
  2085. $tag = new tagCompany ();
  2086. $tag->tid = $tid_7;
  2087. $tag->name = $tag_7;
  2088. $tag->update ();
  2089. }
  2090. return "/mycompany";
  2091. }
  2092. function DoEdiTag() {
  2093. $tag_1 = $this->get_args ( 'tag_1' ) ? $this->get_args ( 'tag_1' ) : "";
  2094. $tag_2 = $this->get_args ( 'tag_2' ) ? $this->get_args ( 'tag_2' ) : "";
  2095. $tag_3 = $this->get_args ( 'tag_3' ) ? $this->get_args ( 'tag_3' ) : "";
  2096. $tag_4 = $this->get_args ( 'tag_4' ) ? $this->get_args ( 'tag_4' ) : "";
  2097. $tag_5 = $this->get_args ( 'tag_5' ) ? $this->get_args ( 'tag_5' ) : "";
  2098. $tag_6 = $this->get_args ( 'tag_6' ) ? $this->get_args ( 'tag_6' ) : "";
  2099. $tag_7 = $this->get_args ( 'tag_7' ) ? $this->get_args ( 'tag_7' ) : "";
  2100. $tid_1 = $this->get_args ( 'tid_1' ) ? $this->get_args ( 'tid_1' ) : 0;
  2101. $tid_2 = $this->get_args ( 'tid_2' ) ? $this->get_args ( 'tid_2' ) : 0;
  2102. $tid_3 = $this->get_args ( 'tid_3' ) ? $this->get_args ( 'tid_3' ) : 0;
  2103. $tid_4 = $this->get_args ( 'tid_4' ) ? $this->get_args ( 'tid_4' ) : 0;
  2104. $tid_5 = $this->get_args ( 'tid_5' ) ? $this->get_args ( 'tid_5' ) : 0;
  2105. $tid_6 = $this->get_args ( 'tid_6' ) ? $this->get_args ( 'tid_6' ) : 0;
  2106. $tid_7 = $this->get_args ( 'tid_7' ) ? $this->get_args ( 'tid_7' ) : 0;
  2107. Doo::loadModel ( 'tag' );
  2108. if (! empty ( $tag_1 ) && ! empty ( $tid_1 )) {
  2109. $tag = new tag ();
  2110. $tag->tid = $tid_1;
  2111. $tag->name = $tag_1;
  2112. $tag->update ();
  2113. }
  2114. if (! empty ( $tag_2 ) && ! empty ( $tid_2 )) {
  2115. $tag = new tag ();
  2116. $tag->tid = $tid_2;
  2117. $tag->name = $tag_2;
  2118. $tag->update ();
  2119. }
  2120. if (! empty ( $tag_3 ) && ! empty ( $tid_3 )) {
  2121. $tag = new tag ();
  2122. $tag->tid = $tid_3;
  2123. $tag->name = $tag_3;
  2124. $tag->update ();
  2125. }
  2126. if (! empty ( $tag_4 ) && ! empty ( $tid_4 )) {
  2127. $tag = new tag ();
  2128. $tag->tid = $tid_4;
  2129. $tag->name = $tag_4;
  2130. $tag->update ();
  2131. }
  2132. if (! empty ( $tag_5 ) && ! empty ( $tid_5 )) {
  2133. $tag = new tag ();
  2134. $tag->tid = $tid_5;
  2135. $tag->name = $tag_5;
  2136. $tag->update ();
  2137. }
  2138. if (! empty ( $tag_6 ) && ! empty ( $tid_6 )) {
  2139. $tag = new tag ();
  2140. $tag->tid = $tid_6;
  2141. $tag->name = $tag_6;
  2142. $tag->update ();
  2143. }
  2144. if (! empty ( $tag_7 ) && ! empty ( $tid_7 )) {
  2145. $tag = new tag ();
  2146. $tag->tid = $tid_7;
  2147. $tag->name = $tag_7;
  2148. $tag->update ();
  2149. }
  2150. return "/contacts";
  2151. }
  2152. function ajaxGetLv2() {
  2153. $lv1 = $this->get_args('lv1') ? $this->get_args('lv1') : 0;
  2154. $s = $this->get_args('s') ? $this->get_args('s') : 0;
  2155. if ($lv1 == 0) {
  2156. echo json_encode ( array (
  2157. "success" => false,
  2158. "info" => ""
  2159. ) );
  2160. die ();
  2161. }
  2162. if (! empty ( $lv1 )) {
  2163. Doo::loadModel ( 'district' );
  2164. $district = new district ();
  2165. $district = $district->get_lvByid ( $s, $lv1 );
  2166. echo json_encode ( array (
  2167. "success" => true,
  2168. "info" => $district
  2169. ) );
  2170. }
  2171. }
  2172. function keyonline() {
  2173. $data ['memu'] = "keyonline";
  2174. $data ['staff'] = $this->staff;
  2175. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  2176. if (empty ( $year ))
  2177. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( 'Y' );
  2178. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : "";
  2179. if (empty ( $cid ))
  2180. $cid = isset ( $this->params ['cid'] ) ? $this->params ['cid'] : $this->staff [0] ['cid'];
  2181. $staff = $this->get_args ( 'staff' ) ? $this->get_args ( 'staff' ) : "";
  2182. if (empty ( $staff ))
  2183. $staff = isset ( $this->params ['staff'] ) ? $this->params ['staff'] : "";
  2184. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : "";
  2185. if (empty ( $status ))
  2186. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : 0;
  2187. $search = $this->get_args ( 'search' ) ? $this->get_args ( 'search' ) : "";
  2188. $productW = $this->get_args ( 'product' ) ? $this->get_args ( 'product' ) : "";
  2189. Doo::loadModel ( 'longle' );
  2190. $longle = new longle ();
  2191. $data ['longleArray'] = $longle->getLongleByStatus ( $year, $cid, $staff, $status, $search, $productW );
  2192. // 获取接收锁信息
  2193. // $longle->getLongleByRe($this->staff[0]['cid'],1);
  2194. $othstr = "";
  2195. if (! empty ( $this->staff [0] ['othercid'] ))
  2196. $othstr = " cid in (" . $this->staff [0] ['cid'] . "," . $this->staff [0] ['othercid'] . ")";
  2197. else
  2198. $othstr = " cid in (" . $this->staff [0] ['cid'] . ")";
  2199. $data ['reLongle'] = $longle->count ( array (
  2200. 'where' => $othstr . ' and status=1'
  2201. ) );
  2202. $data ['cid'] = $cid;
  2203. $data ['year'] = $year;
  2204. $data ['staff'] = $staff;
  2205. $data ['status'] = $status;
  2206. $data ['productName'] = $productW;
  2207. Doo::loadModel ( 'L_category' );
  2208. Doo::loadModel ( 'staff' );
  2209. Doo::loadModel ( 'product' );
  2210. $product = new product ();
  2211. $staff = new staff ();
  2212. $L_category = new L_category ();
  2213. $data ['product'] = $product->getProudct ();
  2214. $data ['staffu'] = $staff->getUserById ( $this->staff [0] ['sid'] );
  2215. $data ['category'] = $L_category->getCategory ();
  2216. $data ['staffList'] = $staff->getStaffByCid ( $cid );
  2217. if ($cid == 1)
  2218. $data ['cid'] = $data ['category'] [0] ['cid'];
  2219. $dateHtml = "";
  2220. $now = date ( "Y" );
  2221. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  2222. if ($YEARD <= $now) {
  2223. $dateHtml .= '<option ';
  2224. if ($data ['year'] == $YEARD) {
  2225. $dateHtml .= 'selected ';
  2226. }
  2227. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  2228. }
  2229. }
  2230. $data ['dateHtml'] = $dateHtml;
  2231. $this->render ( "/lock_look", $data );
  2232. }
  2233. function keyStatistics() {
  2234. Doo::loadModel ( 'staff' );
  2235. $staff = new staff ();
  2236. Doo::loadModel ( 'longle' );
  2237. $longle = new longle ();
  2238. $staffCondition = "";
  2239. if ($this->staff [0] ['cid'] != 12)
  2240. $staffCondition = " and cid=" . $this->staff [0] ['cid'];
  2241. $staffList = $staff->find ( array (
  2242. 'where' => "isadmin= 0 " . $staffCondition,
  2243. 'asArray' => TRUE
  2244. ) );
  2245. Doo::db ()->beginTransaction ();
  2246. foreach ( $staffList as $key => $value ) { // not in(1,2)
  2247. $sum = $longle->count ( array (
  2248. 'where' => "status!= 1 and responsible ='" . $value ['username'] . "'",
  2249. 'asArray' => TRUE
  2250. ) );
  2251. $a = $longle->count ( array (
  2252. 'where' => "status!= 2 and status!= 1 and responsible ='" . $value ['username'] . "'",
  2253. 'asArray' => TRUE
  2254. ) );
  2255. $b = $sum - $a;
  2256. $staffList [$key] ['sum'] = $sum;
  2257. $staffList [$key] ['a'] = $a;
  2258. $staffList [$key] ['b'] = $b;
  2259. }
  2260. Doo::db ()->commit ();
  2261. $data ['staff'] = $this->staff;
  2262. $data ['staffList'] = $staffList;
  2263. $data ['memu'] = "keyStatistics";
  2264. $this->render ( "lock_count", $data );
  2265. }
  2266. function addDoLockLog() {
  2267. Doo::loadModel ( 'longle_log' );
  2268. Doo::loadModel ( 'longle' );
  2269. Doo::loadModel ( "action_log" );
  2270. Doo::loadModel ( 'client' );
  2271. $clientobj = new client ();
  2272. $longle = new longle ();
  2273. $longle_log = new longle_log ();
  2274. Doo::loadModel ( 'district' );
  2275. $district = new district ();
  2276. $status = $this->get_args('longleStatus') ? $this->get_args('longleStatus') : 0;
  2277. $lid = $this->get_args('klid') ? $this->get_args('klid') : 0;
  2278. if (empty ( $lid ))
  2279. return "/keyonline/";
  2280. $linfo = $longle->getLongleByLid ( $lid );
  2281. if ($status == 0)
  2282. return "/keyonline/" . $lid;
  2283. elseif ($status == 3) {
  2284. $client = $this->get_args('browseClient') ? $this->get_args('browseClient') : "";
  2285. $client = explode ( '-', $client );
  2286. $product = $this->get_args('browseProduct') ? $this->get_args('browseProduct') : "";
  2287. $clientname = $clientobj->getClientByName2 ( $client [0], $client [1] );
  2288. if (empty ( $clientname ))
  2289. return "/keyonline/" . $lid;
  2290. if ($client [0] != "") {
  2291. $longle->client = $client [0];
  2292. $longle->clientid = $clientname [0] ['cid'];
  2293. }
  2294. // if($product!="")
  2295. // $longle->product=$product;
  2296. $longle->statusT = "借出";
  2297. $longle_log->client = $client [0];
  2298. $longle_log->clientid = $clientname [0] ['cid'];
  2299. $longle_log->product = $linfo [0] ['product'];
  2300. $longle_log->statusT = "借出";
  2301. // 日常行为
  2302. $action_log = new action_log ();
  2303. $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'] . ')';
  2304. $action_log->sid = $this->staff [0] ['sid'];
  2305. $action_log->cid = $this->staff [0] ['cid'];
  2306. $action_log->updatetime = date ( "Y-m-d" );
  2307. $action_log->time = date ( "H:i" );
  2308. $action_log->status = 4;
  2309. $action_log->districtid = $clientname [0] ['district'];
  2310. $local = $district->getbyidlist ( $clientname [0] ['district'] );
  2311. $action_log->city = $local [0] ['name'];
  2312. $action_log->province = $local [1] ['name'];
  2313. $action_log->company = $clientname [0] ['companyname'];
  2314. Doo::loadModel ( 'company' );
  2315. $company = new company ();
  2316. $companyInfo = $company->getOne ( array (
  2317. 'where' => ' companyname="' . $clientname [0] ['companyname'] . '"',
  2318. 'asArray' => true
  2319. ) );
  2320. $nature = explode ( ',', $companyInfo ['nature'] );
  2321. $action_log->nature = $nature [0];
  2322. $action_log->class = $action_log->iconBorrow;
  2323. $action_log->insert ();
  2324. } elseif ($status == 4) {
  2325. $product = $this->get_args('sellProduct') ? $this->get_args('sellProduct') : "";
  2326. $client = $this->get_args('sellClient') ? $this->get_args('sellClient') : "";
  2327. $client = explode ( '-', $client );
  2328. $clientname = $clientobj->getClientByName2 ( $client [0], $client [1] );
  2329. if (empty ( $clientname ))
  2330. return "/keyonline/" . $lid;
  2331. if ($client [0] != "") {
  2332. $longle->client = $client [0];
  2333. $longle->clientid = $clientname [0] ['cid'];
  2334. }
  2335. // if($product!="")
  2336. // $longle->product=$product;
  2337. $longle->statusT = "销售";
  2338. $longle_log->client = $client [0];
  2339. $longle_log->clientid = $clientname [0] ['cid'];
  2340. $longle_log->product = $linfo [0] ['product'];
  2341. $longle_log->statusT = "销售";
  2342. // 日常行为
  2343. $action_log = new action_log ();
  2344. $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'] . ')';
  2345. $action_log->sid = $this->staff [0] ['sid'];
  2346. $action_log->cid = $this->staff [0] ['cid'];
  2347. $action_log->updatetime = date ( "Y-m-d" );
  2348. $action_log->time = date ( "H:i" );
  2349. $action_log->status = 5;
  2350. $action_log->districtid = $clientname [0] ['district'];
  2351. $local = $district->getbyidlist ( $clientname [0] ['district'] );
  2352. $action_log->city = $local [0] ['name'];
  2353. $action_log->province = $local [1] ['name'];
  2354. $action_log->company = $clientname [0] ['companyname'];
  2355. Doo::loadModel ( 'company' );
  2356. $company = new company ();
  2357. $companyInfo = $company->getOne ( array (
  2358. 'where' => ' companyname="' . $clientname [0] ['companyname'] . '"',
  2359. 'asArray' => true
  2360. ) );
  2361. $nature = explode ( ',', $companyInfo ['nature'] );
  2362. $action_log->nature = $nature [0];
  2363. $action_log->class = $action_log->iconSell;
  2364. $action_log->insert ();
  2365. } elseif ($status == 5) {
  2366. $product = $this->get_args('newProduct') ? $this->get_args('newProduct') : "";
  2367. if ($product != "")
  2368. $longle->product = $linfo [0] ['product'] . "+" . $product;
  2369. $longle->statusT = "升级";
  2370. $longle_log->product = $linfo [0] ['product'] . "+" . $product;
  2371. $longle_log->statusT = "升级";
  2372. $longle_log->client = $linfo [0] ['client'];
  2373. $longle_log->clientid = $linfo [0] ['clientid'];
  2374. $clientname = $clientobj->getOne ( array (
  2375. 'where' => "cid= '" . $linfo [0] ['clientid'] . "'",
  2376. 'asArray' => TRUE
  2377. ) );
  2378. // 日常行为
  2379. $action_log = new action_log ();
  2380. $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>';
  2381. $action_log->sid = $this->staff [0] ['sid'];
  2382. $action_log->cid = $this->staff [0] ['cid'];
  2383. $action_log->updatetime = date ( "Y-m-d" );
  2384. $action_log->time = date ( "H:i" );
  2385. $action_log->class = $action_log->iconUpdate;
  2386. $action_log->sid = $this->staff [0] ['sid'];
  2387. $action_log->cid = $this->staff [0] ['cid'];
  2388. $action_log->status = 7;
  2389. $action_log->insert ();
  2390. } elseif ($status == 6) {
  2391. $key_num = $this->get_args('key_num') ? $this->get_args('key_num') : "";
  2392. $key_num2 = explode ( "-", $key_num );
  2393. $key_num = $key_num2 [0] . "-" . $key_num2 [1];
  2394. // if($key_num!="")
  2395. // $longle->key_num=$key_num;
  2396. // 新锁拷贝记录
  2397. $newLongle = new longle ();
  2398. // $newLongle->product=$linfo[0]['product'];
  2399. $newLongle->statusT = "更换";
  2400. $newLongle->status = 6;
  2401. $newLongle->client = $linfo [0] ['client'];
  2402. $newLongle->clientid = $linfo [0] ['clientid'];
  2403. $newlid = $newLongle->update ( array (
  2404. 'where' => ' key_num= \'' . $key_num . "'"
  2405. ) );
  2406. $longleinfo = $longle->getOne ( array (
  2407. 'where' => ' key_num =\'' . $key_num . "'",
  2408. 'asArray' => true
  2409. ) );
  2410. $longleLog = $longle_log->getOne ( array (
  2411. 'where' => ' lid =' . $linfo [0] ['lid'],
  2412. 'desc' => 'logid',
  2413. 'asArray' => true
  2414. ) );
  2415. // 新记录日志
  2416. $newlongle_log = new longle_log ();
  2417. $newlongle_log->statusT = "更换";
  2418. $newlongle_log->status = 6;
  2419. $newlongle_log->client = $linfo [0] ['client'];
  2420. $newlongle_log->new_key_num = $linfo [0] ['key_num'];
  2421. $newlongle_log->product = $linfo [0] ['product'];
  2422. $newlongle_log->category = $this->staff [0] ['category'];
  2423. $newlongle_log->dateline = date ( "Y-m-d" );
  2424. $newlongle_log->operator = $this->staff [0] ['username'];
  2425. $newlongle_log->lid = $longleinfo ['lid'];
  2426. $newlongle_log->insert ();
  2427. $newlongle_log = new longle_log ();
  2428. $newlongle_log->statusT = $longleLog ['statusT'];
  2429. $newlongle_log->status = $longleLog ['status'];
  2430. $newlongle_log->client = $longleLog ['client'];
  2431. $newlongle_log->new_key_num = $longleLog ['new_key_num'];
  2432. $newlongle_log->product = $longleLog ['product'];
  2433. $newlongle_log->category = $longleLog ['category'];
  2434. $newlongle_log->dateline = $longleLog ['dateline'];
  2435. $newlongle_log->operator = $longleLog ['operator'];
  2436. $newlongle_log->lid = $longleinfo ['lid'];
  2437. $newlongle_log->insert ();
  2438. $newLongle = new longle ();
  2439. $newLongle->statusT = $longleLog ['statusT'];
  2440. $newLongle->status = $longleLog ['status'];
  2441. $newlid = $newLongle->update ( array (
  2442. 'where' => ' key_num= \'' . $key_num . "'"
  2443. ) );
  2444. // 新锁状态拷贝
  2445. $longle->statusT = "更换";
  2446. $longle_log->new_key_num = $key_num;
  2447. $longle_log->statusT = "更换";
  2448. $longle_log->client = $linfo [0] ['client'];
  2449. $clientname = $clientobj->getOne ( array (
  2450. 'where' => "cid= '" . $linfo [0] ['clientid'] . "'",
  2451. 'asArray' => TRUE
  2452. ) );
  2453. // 日常行为
  2454. $action_log = new action_log ();
  2455. $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'] . ')';
  2456. $action_log->sid = $this->staff [0] ['sid'];
  2457. $action_log->cid = $this->staff [0] ['cid'];
  2458. $action_log->updatetime = date ( "Y-m-d" );
  2459. $action_log->time = date ( "H:i" );
  2460. $action_log->class = $action_log->iconReplace;
  2461. $action_log->sid = $this->staff [0] ['sid'];
  2462. $action_log->cid = $this->staff [0] ['cid'];
  2463. $action_log->status = 8;
  2464. $action_log->insert ();
  2465. } elseif ($status == 7) {
  2466. $longle->statusT = "收回";
  2467. $longle_log->statusT = "收回";
  2468. $longle_log->responsible = $linfo [0] ['responsible'];
  2469. // 日常行为
  2470. $action_log = new action_log ();
  2471. $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(\'' . $this->staff [0] ['responsible'] . '\')">' . $this->staff [0] ['responsible'] . '</a>';
  2472. $action_log->sid = $this->staff [0] ['sid'];
  2473. $action_log->cid = $this->staff [0] ['cid'];
  2474. $action_log->updatetime = date ( "Y-m-d" );
  2475. $action_log->time = date ( "H:i" );
  2476. $action_log->class = $action_log->iconRecycle;
  2477. $action_log->sid = $this->staff [0] ['sid'];
  2478. $action_log->cid = $this->staff [0] ['cid'];
  2479. $action_log->status = 9;
  2480. $action_log->insert ();
  2481. } elseif ($status == 8) {
  2482. $mark = $this->get_args('mark') ? $this->get_args('mark') : "";
  2483. if (empty ( $mark )) {
  2484. echo json_encode ( array (
  2485. 'msg' => 2
  2486. ) );
  2487. die ();
  2488. }
  2489. $longle_log->mark = $mark;
  2490. // 日常行为
  2491. $action_log = new action_log ();
  2492. $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>添加新备注。';
  2493. $action_log->sid = $this->staff [0] ['sid'];
  2494. $action_log->cid = $this->staff [0] ['cid'];
  2495. $action_log->updatetime = date ( "Y-m-d" );
  2496. $action_log->time = date ( "H:i" );
  2497. $action_log->sid = $this->staff [0] ['sid'];
  2498. $action_log->cid = $this->staff [0] ['cid'];
  2499. $action_log->status = 10;
  2500. $action_log->class = $action_log->iconLock;
  2501. $action_log->insert ();
  2502. } elseif ($status == 9) {
  2503. $longle->statusT = "赠送";
  2504. $longle_log->statusT = "赠送";
  2505. $client = $this->get_args('giftClient') ? $this->get_args('giftClient') : "";
  2506. $client = explode ( '-', $client );
  2507. $clientname = $clientobj->getClientByName2 ( $client [0], $client [1] );
  2508. if (empty ( $clientname ))
  2509. return "/keyonline/" . $lid;
  2510. if ($client [0] != "") {
  2511. $longle->client = $client [0];
  2512. $longle->clientid = $clientname [0] ['cid'];
  2513. }
  2514. $longle_log->client = $client [0];
  2515. $longle_log->clientid = $clientname [0] ['cid'];
  2516. // 日常行为
  2517. $action_log = new action_log ();
  2518. $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'] . ')';
  2519. $action_log->updatetime = date ( "Y-m-d" );
  2520. $action_log->time = date ( "H:i" );
  2521. $action_log->class = $action_log->iconRecycle;
  2522. $action_log->sid = $this->staff [0] ['sid'];
  2523. $action_log->cid = $this->staff [0] ['cid'];
  2524. $action_log->status = 6;
  2525. $action_log->districtid = $clientname [0] ['district'];
  2526. $local = $district->getbyidlist ( $clientname [0] ['district'] );
  2527. $action_log->city = $local [0] ['name'];
  2528. $action_log->province = $local [1] ['name'];
  2529. $action_log->company = $clientname [0] ['companyname'];
  2530. Doo::loadModel ( 'company' );
  2531. $company = new company ();
  2532. $companyInfo = $company->getOne ( array (
  2533. 'where' => ' companyname="' . $clientname [0] ['companyname'] . '"',
  2534. 'asArray' => true
  2535. ) );
  2536. $nature = explode ( ',', $companyInfo ['nature'] );
  2537. $action_log->nature = $nature [0];
  2538. $action_log->insert ();
  2539. }
  2540. // 记录使用过的状态
  2541. $statuslog = $status . "," . $linfo [0] ['statuslog'];
  2542. $ar = explode ( ',', $statuslog );
  2543. $statuslog = implode ( ',', array_unique ( array_filter ( $ar ) ) );
  2544. $longle->statuslog = $statuslog;
  2545. if ($linfo [0] ['status'] <= 2) {
  2546. if ($status >= 4 && $status <= 2) {
  2547. return "/keyonline/" . $lid;
  2548. }
  2549. }
  2550. if ($lid != 0) {
  2551. $longle->lid = $lid;
  2552. if ($status != 8)
  2553. $longle->status = $status;
  2554. // if($status!=8)
  2555. $longle->responsible = $this->staff [0] ['username'];
  2556. $longle->update ();
  2557. }
  2558. $longle_log->lid = $lid;
  2559. $longle_log->status = $status;
  2560. $longle_log->operator = $this->staff [0] ['username'];
  2561. // 责任人
  2562. $longle_log->category = $this->staff [0] ['category'];
  2563. $longle_log->dateline = date ( "Y-m-d" );
  2564. $longle_log->insert ();
  2565. echo json_encode ( array (
  2566. 'msg' => 1
  2567. ) );
  2568. die ();
  2569. // return "/keyonline/".$lid;
  2570. }
  2571. function ajaxGetLongleByName() {
  2572. Doo::loadModel ( 'longle_log' );
  2573. Doo::loadModel ( 'longle' );
  2574. $longle = new longle ();
  2575. $longle_log = new longle_log ();
  2576. $name = $this->get_args('name') ? $this->get_args('name') : "";
  2577. if (empty ( $name )) {
  2578. echo json_encode ( array (
  2579. "success" => false
  2580. ) );
  2581. die ();
  2582. }
  2583. $ky = $longle->getLongleBykeynum ( $name );
  2584. $t = $longle_log->getLongleByLid ( $ky [0] ['lid'] );
  2585. if (isset ( $t [0] ))
  2586. $tk = $t [0];
  2587. else
  2588. $tk = array ();
  2589. $longleLog = $tk;
  2590. $longleLog ['klid'] = $t [0] ['lid'];
  2591. $longleLog ['longle'] = $ky [0];
  2592. $longleLog ['longleLogHtml'] = $this->_getLongleLogHtml ( $t );
  2593. echo json_encode ( $longleLog );
  2594. }
  2595. function ajaxGetLongleN() {
  2596. Doo::loadModel ( 'longle_log' );
  2597. Doo::loadModel ( 'longle' );
  2598. $longle = new longle ();
  2599. $longle_log = new longle_log ();
  2600. $keynum = $this->get_args('keynum') ? $this->get_args('keynum') : "";
  2601. if (empty ( $keynum )) {
  2602. echo json_encode ( array (
  2603. "success" => false
  2604. ) );
  2605. die ();
  2606. }
  2607. $ky = $longle->getLongleBykeynum ( $keynum );
  2608. if (! empty ( $ky )) {
  2609. $t = $longle_log->getLongleByLid ( $ky [0] ['lid'] );
  2610. if (isset ( $t [0] ))
  2611. $tk = $t [0];
  2612. else
  2613. $tk = array ();
  2614. $longleLog = $tk;
  2615. $longleLog ['klid'] = $ky [0] ['lid'];
  2616. $longleLog ['longle'] = $ky [0];
  2617. $longleLog ['longleLogHtml'] = $this->_getLongleLogHtml ( $t );
  2618. echo json_encode ( $longleLog );
  2619. }
  2620. }
  2621. function ajaxGetLongle() {
  2622. Doo::loadModel ( 'longle_log' );
  2623. Doo::loadModel ( 'longle' );
  2624. $longle = new longle ();
  2625. $longle_log = new longle_log ();
  2626. $lid = $this->get_args('lid') ? $this->get_args('lid') : 0;
  2627. if ($lid == 0) {
  2628. echo json_encode ( array (
  2629. "success" => false
  2630. ) );
  2631. die ();
  2632. }
  2633. $t = $longle_log->getLongleByLid ( $lid );
  2634. if (isset ( $t [0] ))
  2635. $tk = $t [0];
  2636. else
  2637. $tk = array ();
  2638. $longleLog = $tk;
  2639. $longleLog ['klid'] = $lid;
  2640. $ky = $longle->getLongleByLid ( $lid );
  2641. $longleLog ['longle'] = $ky [0];
  2642. $longleLog ['longleLogHtml'] = $this->_getLongleLogHtml ( $t );
  2643. echo json_encode ( $longleLog );
  2644. }
  2645. function ajaxGetStaffInfo() {
  2646. $username = $this->get_args('username') ? $this->get_args('username') : "";
  2647. if ($username == "") {
  2648. echo json_encode ( array (
  2649. "success" => false
  2650. ) );
  2651. die ();
  2652. }
  2653. Doo::loadModel ( 'staff' );
  2654. $staff = new staff ();
  2655. $staffInfo = $staff->getOne ( array (
  2656. 'where' => ' username like "' . $username . '"',
  2657. 'asArray' => TRUE
  2658. ) );
  2659. if (empty ( $staffInfo )) {
  2660. echo json_encode ( array (
  2661. "success" => false,
  2662. 'html' => ''
  2663. ) );
  2664. die ();
  2665. }
  2666. $staffHtml = array (
  2667. 'html' => '<div class="contactPanel"><h1>' . $staffInfo ['username'] . '</h1>
  2668. <table><tbody><tr><th>性别</th><td>' . $staffInfo ['gender'] . '</td><th>办事处</th><td>' . $staffInfo ['category'] . '</td></tr>
  2669. <tr><th>手机</th><td>' . $staffInfo ['telephone'] . '</td><th>电话</th><td>' . $staffInfo ['phone'] . '</td></tr>
  2670. <tr><th>QQ</th><td>' . $staffInfo ['qq'] . '</td><th>邮箱</th><td>' . $staffInfo ['email'] . '</td></tr>
  2671. </tbody></table>
  2672. </div>'
  2673. );
  2674. echo json_encode ( $staffHtml );
  2675. }
  2676. function ajaxGetCompanyByAdd() {
  2677. $cid = $this->get_args('cid') ? $this->get_args('cid') : "";
  2678. if (! empty ( $cid )) {
  2679. Doo::loadModel ( 'company' );
  2680. $company = new company ();
  2681. Doo::loadModel ( 'client' );
  2682. Doo::loadModel ( 'district' );
  2683. $district = new district ();
  2684. $client = new client ();
  2685. $districtInfo = $district->get_lv ( 1 );
  2686. $companyInfo = $client->getClientByCompanyId ( $cid );
  2687. $companyInfo = $companyInfo [0];
  2688. $cInfo = $company->getOne ( array (
  2689. 'where' => "cid = " . $cid,
  2690. 'asArray' => TRUE
  2691. ) );
  2692. $companyInfo ['ride'] = $cInfo ['ride'];
  2693. $companyInfo ['landmarks'] = $cInfo ['landmarks'];
  2694. $companyInfo ['stay'] = $cInfo ['stay'];
  2695. $artld = explode ( ',', $cInfo ['local'] );
  2696. $districtid = explode ( ',', $cInfo ['district'] );
  2697. $html = "";
  2698. $html .= '<select name="lv21" id="lv31" onchange="dislv(\'lv31\',\'32\');"><option value="' . $districtid [0] . '">' . $artld [0] . '</option>';
  2699. // foreach ($districtInfo as $key=>$value){
  2700. //
  2701. // $html.='<option selected value="'.$value['id'].'">'.$value['name'].'</option>';
  2702. // }
  2703. $html .= '</select>&nbsp;';
  2704. $html .= '<span id="mlv32">
  2705. <select id="lv32" name="lv22">
  2706. <option selected value="' . $districtid [1] . '" >' . $artld [1] . '</option>
  2707. </select>
  2708. </span>';
  2709. $html .= '<span id="mlv33">
  2710. <select id="lv33" name="lv23">
  2711. <option selected value="' . $districtid [2] . '" >' . $artld [2] . '</option>
  2712. </select>&nbsp;
  2713. </span>';
  2714. $companyInfo ['dishtml'] = $html;
  2715. $companyInfo ['natureAr'] = $this->nature;
  2716. $companyInfo ['natureArlenght'] = 12;
  2717. echo json_encode ( array (
  2718. "success" => true,
  2719. 'data' => $companyInfo
  2720. ) );
  2721. die ();
  2722. } else
  2723. echo json_encode ( array (
  2724. "success" => false,
  2725. 'data' => ''
  2726. ) );
  2727. die ();
  2728. }
  2729. function doEditCompanyD() {
  2730. $cid = $this->get_args('cid') ? $this->get_args('cid') : 0;
  2731. $companyname = $this->get_args('companyname') ? $this->get_args('companyname') : "";
  2732. $lv21 = $this->get_args('lv21') ? $this->get_args('lv21') : 0;
  2733. $lv22 = $this->get_args('lv22') ? $this->get_args('lv22') : 0;
  2734. $lv23 = $this->get_args('lv23') ? $this->get_args('lv23') : 0;
  2735. $nature = $this->get_args('nature') ? $this->get_args('nature') : "";
  2736. $fax = $this->get_args('fax') ? $this->get_args('fax') : "";
  2737. $webservice = $this->get_args('webservice') ? $this->get_args('webservice') : "";
  2738. $address = $this->get_args('address') ? $this->get_args('address') : "";
  2739. $ride = $this->get_args('ride') ? $this->get_args('ride') : "";
  2740. $stay = $this->get_args('stay') ? $this->get_args('stay') : "";
  2741. $landmarks = $this->get_args('landmarks') ? $this->get_args('landmarks') : "";
  2742. if (empty ( $cid ) || empty ( $companyname )) {
  2743. echo json_encode ( array (
  2744. "success" => false
  2745. ) );
  2746. die ();
  2747. }
  2748. Doo::loadModel ( "company" );
  2749. Doo::loadModel ( "client" );
  2750. $client = new client ();
  2751. $company = new company ();
  2752. $company->cid = $cid;
  2753. if (! empty ( $lv21 ) && ! empty ( $lv22 ) && ! empty ( $lv23 )) {
  2754. Doo::loadModel ( 'district' );
  2755. $district = new district ();
  2756. // 更新公司信息
  2757. $lv1 = $district->getbyid ( $lv21 );
  2758. $lv2 = $district->getbyid ( $lv22 );
  2759. $lv3 = $district->getbyid ( $lv23 );
  2760. $company->district = $lv21 . "," . $lv22 . "," . $lv23;
  2761. $company->local = $lv1 [0] ['name'] . "," . $lv2 [0] ['name'] . "," . $lv3 [0] ['name'];
  2762. }
  2763. if (! empty ( $nature )) {
  2764. $nature = implode ( ",", $nature );
  2765. $company->nature = $nature;
  2766. }
  2767. if (! empty ( $companyname )) {
  2768. $company->companyname = $companyname;
  2769. $client->companyname = $companyname;
  2770. }
  2771. if (! empty ( $fax ))
  2772. $company->fax = $fax;
  2773. if (! empty ( $webservice ))
  2774. $company->webservice = $webservice;
  2775. if (! empty ( $address ))
  2776. $company->address = $address;
  2777. if (! empty ( $ride ))
  2778. $company->ride = $ride;
  2779. if (! empty ( $stay ))
  2780. $company->stay = $stay;
  2781. if (! empty ( $landmarks ))
  2782. $company->landmarks = $landmarks;
  2783. $company->update ();
  2784. $client->update ( array (
  2785. 'where' => ' companyid =' . $cid
  2786. ) );
  2787. echo json_encode ( array (
  2788. "success" => true
  2789. ) );
  2790. die ();
  2791. }
  2792. function ajaxEditCompany() {
  2793. $companyname = $this->get_args('companyId') ? $this->get_args('companyId') : 0;
  2794. if (! empty ( $companyname )) {
  2795. Doo::loadModel ( 'company' );
  2796. $company = new company ();
  2797. $companyInfo = $company->getOne ( array (
  2798. 'where' => "cid = '" . $companyname . "'",
  2799. 'asArray' => TRUE
  2800. ) );
  2801. if (! empty ( $companyInfo )) {
  2802. Doo::loadModel ( 'district' );
  2803. $district = new district ();
  2804. $districtinfo = $district->get_lv ( 1 );
  2805. $dinfo = $district->getbyidlist ( $companyInfo ['district'] );
  2806. $html = '
  2807. <div class="contactInfo clearfix">
  2808. <div class="header">
  2809. <h1 class="companyName">' . $companyInfo ['companyname'] . '</h1>
  2810. </div>
  2811. </div>
  2812. <div class="lockRecord">
  2813. <div class="contactPanel">
  2814. <table>
  2815. <tbody><tr><th>单位全称</th><td colspan="3"><input type="text" name="companyname" id="companyname" value="' . $companyInfo ['companyname'] . '"></td></tr>
  2816. <tr><th>地区</th><td colspan="3">
  2817. <select name="lv21" id="lv21" onchange="dislv(\'lv21\',22);">
  2818. <option value="0">请选择</option>';
  2819. foreach ( $districtinfo as $key => $value ) {
  2820. if ($value ['id'] == $dinfo [0] ['id'])
  2821. $html .= '<option selected value="' . $value ['id'] . '">' . $value ['name'] . '</option>';
  2822. else
  2823. $html .= '<option value="' . $value ['id'] . '">' . $value ['name'] . '</option>';
  2824. }
  2825. $html .= '</select>
  2826. <span id="mlv22">
  2827. <select id="lv22">
  2828. <option value="' . $dinfo [1] ['id'] . '">' . $dinfo [1] ['name'] . '</option>
  2829. </select>
  2830. </span>
  2831. <span id="mlv23">
  2832. <select id="lv23">
  2833. <option value="' . $dinfo [2] ['id'] . '">' . $dinfo [2] ['name'] . '</option>
  2834. </select>&nbsp;
  2835. </span>
  2836. </td></tr>
  2837. ';
  2838. $html .= '<tr><th>性质</th><td colspan="3">';
  2839. $ntre = explode ( ",", $companyInfo ['nature'] );
  2840. foreach ( $this->nature as $key => $value ) {
  2841. $falg = true;
  2842. foreach ( $ntre as $k => $v ) {
  2843. if ($value == $v) {
  2844. $falg = false;
  2845. $html .= '<label><input type="checkbox" checked name="nature[]" value="' . $value . '">' . $value . '</label>&nbsp;';
  2846. }
  2847. }
  2848. if ($falg)
  2849. $html .= '<label><input type="checkbox" name="nature[]" value="' . $value . '">' . $value . '</label>&nbsp;';
  2850. }
  2851. $html .= ' </td></tr>
  2852. <tr><th>传真</th><td><input type="text" name="fax" id="fax" value="' . $companyInfo ['fax'] . '"> </td><th>主页</th><td><input type="text" name="webservice" id="webservice" value="' . $companyInfo ['webservice'] . '"> </td></tr>
  2853. <tr><th>单位地址</th><td colspan="3"><input type="text" name="address" id="address" value="' . $companyInfo ['address'] . '"> </td></tr>
  2854. <tr><th>乘车路线</th><td colspan="3"><input type="text" name="ride" id="ride" value="' . $companyInfo ['ride'] . '"> </td></tr>
  2855. <tr><th>地标建筑</th><td colspan="3"><input type="text" name="landmarks" id="landmarks" value="' . $companyInfo ['landmarks'] . '"> </td></tr>
  2856. <tr><th>住宿参考</th><td colspan="3"><input type="text" name="stay" id="stay" value="' . $companyInfo ['stay'] . '"> </td></tr>
  2857. <tr><td colspan="4"><input type="hidden" name="cid" id="cid" value="' . $companyInfo ['cid'] . '"><input type="button" onclick="doCompanyEdit()" class="button" value="确定"><span id="editCompanyD"></span></td></tr>
  2858. </tbody></table>
  2859. <div class="bsAlert bsInfo">单位全称将与该单位已存在的客户进行同步;其他单位信息不会进行同步;<br>单位信息随该单位第一位客户录入,并作为“在这添加客户”的基础数据</div>
  2860. </div>
  2861. </div>
  2862. ';
  2863. echo json_encode ( array (
  2864. "success" => true,
  2865. 'html' => $html
  2866. ) );
  2867. die ();
  2868. }
  2869. } else
  2870. echo json_encode ( array (
  2871. "success" => false,
  2872. 'html' => ''
  2873. ) );
  2874. die ();
  2875. }
  2876. function ajaxGetCompany() {
  2877. $companyname = $this->get_args('companyId') ? $this->get_args('companyId') : 0;
  2878. if (! empty ( $companyname )) {
  2879. Doo::loadModel ( 'company' );
  2880. $company = new company ();
  2881. $companyInfo = $company->getOne ( array (
  2882. 'where' => "cid = '" . $companyname . "'",
  2883. 'asArray' => TRUE
  2884. ) );
  2885. if (! empty ( $companyInfo )) {
  2886. Doo::loadModel ( 'client' );
  2887. Doo::loadModel ( 'staff' );
  2888. Doo::loadModel ( 'client_staff' );
  2889. Doo::loadModel ( 'longle' );
  2890. $longle = new longle ();
  2891. $client_staff = new client_staff ();
  2892. $staff = new staff ();
  2893. $client = new client ();
  2894. Doo::loadModel ( 'district' );
  2895. $district = new district ();
  2896. $clientlist = $client->getClientByCompanyId ( $companyInfo ['cid'] );
  2897. $department = $client->getDepartment ( $companyInfo ['cid'] );
  2898. Doo::loadModel ( "tagCompanyNexus" );
  2899. Doo::loadModel ( "tagCompany" );
  2900. $tag = new tagCompany ();
  2901. $tag_client = new tagCompanyNexus ();
  2902. $tagId = $tag_client->getTagClientBySCid ( $companyInfo ['cid'], $this->staff [0] ['sid'] );
  2903. $taginfo = $tag->getTagByTidL ( $tagId ['tag'] );
  2904. $taghtml = "";
  2905. foreach ( $taginfo as $key => $value ) {
  2906. $taghtml .= '<span class="contactsTag tagCol-0' . $value ['colorid'] . '">' . $value ['name'] . '</span>';
  2907. }
  2908. $html = '<div class="header">
  2909. <h1 class="companyName"><div class="fR">
  2910. <a class="icon- add" node-syn="show" href="javascript:void(0)" title="同步地址信息">S</a>
  2911. <a href="javascript:void(0)" title="编辑单位" class="icon- edit" onclick="editByCompany(' . $companyInfo ['cid'] . ')" >I</a> | <a title="在这个单位下添加客户" href="javascript:void(0)" class="icon- add" onclick="addClientByCompany(' . $companyInfo ['cid'] . ')" >H</a></div>' . $companyInfo ['companyname'] . '</h1>
  2912. <div class="contactPanel">
  2913. <table>
  2914. <tbody>
  2915. <tr><th>单位地区</th><td><span>' . $companyInfo ['local'] . '</span></td><th>单位性质</th><td>' . $companyInfo ['nature'] . '</td></tr>
  2916. <tr><th>单位地址</th><td colspan="3">' . $companyInfo ['address'] . '</td></tr>
  2917. <tr><th>单位乘车</th><td colspan="3">' . $companyInfo ['ride'] . '</td></tr>
  2918. <tr><th>单位地标</th><td colspan="3">' . $companyInfo ['landmarks'] . '</td></tr>
  2919. <tr><th>单位住宿</th><td colspan="3">' . $companyInfo ['stay'] . '</td></tr>
  2920. <tr><td colspan="4">
  2921. ' . $taghtml . '
  2922. </td></tr>
  2923. <tr><td colspan="4" >
  2924. <a class="button" style="display:none" node-synadd="true" href="javascript:void(0)">确定同步</a>
  2925. <span node-synAdd="msg" class="bsAlert bsSuccess fL hide"></span>
  2926. <span class="hide" id="skop">已选择 <span id="tl">0</span>/<span id="bl">'.sizeof($clientlist).'</span></span>
  2927. </td>
  2928. </tr>
  2929. </tbody></table></div>
  2930. <h2 class="cate">';
  2931. $html .= '<a href="javascript:void(0)" onclick="departmentC()" class="now">不限</a>';
  2932. foreach ( $department as $key => $value ) {
  2933. if ($value != "")
  2934. $html .= '<a href="javascript:void(0)" onclick="departmentC(\'' . $value ['department'] . '\')">' . $value ['department'] . '</a>';
  2935. }
  2936. $html .= '</h2></div><script>$(".header .cate a").click(function(){
  2937. $(this).addClass("now").siblings("a").removeClass("now");
  2938. });
  2939. </script>';
  2940. $html .= '<div class="lockRecord autoHeightR2" >';
  2941. foreach ( $clientlist as $key => $value ) {
  2942. $scinfo = $client_staff->getClientByCid ( $value ['cid'] );
  2943. $staffinfo = $staff->getUserById ( $scinfo ['sid'] );
  2944. //客户信息
  2945. $html .= '<div class="contactPanel" id="PART_' . $value ['department'] . '">
  2946. <h1><p class="fR">' . $staffinfo [0] ['category'] . '-<a href="javascript:void(0)" onclick="getStaffInfo(\'' . $staffinfo [0] ['username'] . '\')" >
  2947. ' . $staffinfo [0] ['username'] . '</a></p>
  2948. <input type="checkbox" name="CASYN[]" CAS-NUM="TR" class="hide" value="'.$value ['cid'].'">
  2949. <a href="javascript:void(0)" onclick="getClientInfo(\'' . $value ['cid'] . '\')" class="clientName">' . $value ['clientname'] . ' </a>
  2950. <i class="icon- sport">' . $value ['priority'] . '</i><a class="icon- edit" title="编辑客户" href="javascript:clientEdit(' . $value ['cid'] . ')">I</a></h1><table>
  2951. <tbody><tr><th>性别</th><td>' . $value ['gender'] . '</td><th>昵称</th><td>' . $value ['nicename'] . '</td></tr>
  2952. <tr><th>部门</th><td>' . $value ['department'] . '</td><th>办公室</th><td>' . $value ['office'] . '</td></tr>
  2953. <tr><th>手机</th><td>' . $value ['telephone'] . '</td><th>电话</th><td>' . $value ['phone'] . '</td></tr>
  2954. <tr><th>QQ</th><td>' . $value ['qq'] . '</td><th>邮箱</th><td>' . $value ['email'] . '</td></tr>
  2955. <tr node-ck=fz ><th>备注</th><td >' . $value ['mark'] . '</td>
  2956. </tr>';
  2957. $longleinfo = $longle->getLongleByClientid ( $value ['cid'] );
  2958. if (empty ( $longleinfo )) {
  2959. $longleinfo = array (
  2960. 0 => array (
  2961. 'lid' => '',
  2962. 'key_num' => '',
  2963. 'product' => '',
  2964. 'statusT' => ''
  2965. )
  2966. );
  2967. }
  2968. $html .= '<tr node-ck=fz ><th>软件锁</th><td colspan="3"><a href="javascript:void(0)" onclick="getLongleLog(' . $longleinfo [0] ['lid'] . ')">' . $longleinfo [0] ['key_num'] . '</a>/' . $longleinfo [0] ['product'] . '/' . $longleinfo [0] ['statusT'] . '</td></tr>';
  2969. $districtList = $district->getbyidlist ( $value ['district'] );
  2970. $localdis='';
  2971. foreach ($districtList as $lov){
  2972. $localdis.=' '.$lov['name'];
  2973. }
  2974. $html .= '
  2975. <tr node-synCom=pany style="display:none" ><th>客户地区</th><td colspan="4">'.$localdis.'</td></tr>
  2976. <tr node-synCom=pany style="display:none" ><th>客户地址</th><td colspan="4">'.$value['address'].'</td></tr>
  2977. <tr node-synCom=pany style="display:none" ><th>客户乘车</th><td colspan="4">'.$value['ride'].'</td></tr>
  2978. <tr node-synCom=pany style="display:none" ><th>客户地标</th><td colspan="4">'.$value['landmarks'].'</td></tr>
  2979. <tr node-synCom=pany style="display:none" ><th>客户住宿</th><td colspan="4">'.$value['stay'].'</td></tr>';
  2980. $html .= '</tbody></table></div>';
  2981. }
  2982. $html .= "</div><script type='text/javascript'>
  2983. $(\"a[node-syn=show]\").click(function() {
  2984. $(\"a[node-synadd='true']\").show();
  2985. $('input[CAS-NUM=TR]').show();
  2986. $('#skop').show();
  2987. $('tr[node-ck=fz]').hide();
  2988. $('tr[node-synCom=pany]').show();
  2989. });
  2990. $(\"input[CAS-NUM='TR']\").click(function() {
  2991. $('#tl').html($('input[CAS-NUM=TR]:checked').length);
  2992. });
  2993. $(\"a[node-synadd='true']\").click(function() {
  2994. var id_array=new Array();
  2995. $('input[CAS-NUM=TR]:checked').each(function(){
  2996. id_array.push($(this).val());
  2997. });
  2998. if(id_array.length==0){
  2999. alert('未选中客户');
  3000. }else{
  3001. var idstr=id_array.join(',');
  3002. var url='/ajaxSetCompanyAddress';
  3003. $.ajax({
  3004. url:url,
  3005. type: 'post',
  3006. cache: false,
  3007. dataType: 'json',
  3008. data: {
  3009. cidString:idstr,
  3010. company:".$companyInfo ['cid']."
  3011. },
  3012. global: true,
  3013. success: function(data){
  3014. if(data.status>0){
  3015. $(\"span[node-synAdd=msg]\").html('同步成功');
  3016. for(var i=0;i<id_array.length;i++){
  3017. $(\"td[node-address=company_\"+id_array[i]+\"]\").html('" . $companyInfo ['address'] . "');
  3018. }
  3019. $(\"a[node-synadd='true']\").hide();
  3020. $('input[CAS-NUM=TR]').hide();
  3021. $('#skop').hide();
  3022. $(\"span[node-synAdd=msg]\").show().delay(2000).fadeOut();
  3023. }else if(data.status==-1){
  3024. $(\"span[node-synAdd=msg]\").html('操作不成功');
  3025. $(\"span[node-synAdd=msg]\").show().delay(2000).fadeOut();
  3026. }else if(data.status==0){
  3027. $(\"span[node-synAdd=msg]\").html('地址已同步过');
  3028. $(\"span[node-synAdd=msg]\").show().delay(2000).fadeOut();
  3029. }
  3030. },
  3031. error:function(err){
  3032. }
  3033. });
  3034. }
  3035. });
  3036. autoFlashHeight();
  3037. </script>";
  3038. echo json_encode ( array (
  3039. "success" => true,
  3040. 'html' => $html
  3041. ) );
  3042. die ();
  3043. }
  3044. } else
  3045. echo json_encode ( array (
  3046. "success" => false,
  3047. 'html' => ''
  3048. ) );
  3049. die ();
  3050. }
  3051. function ajaxSetCompanyAddress(){
  3052. $cidString = $this->get_args('cidString') ? $this->get_args('cidString') : "";
  3053. $companyId = $this->get_args('company')&&is_numeric ($this->get_args('company')) ? $this->get_args('company') : 0;
  3054. if(!empty($cidString)&&!empty($companyId)){
  3055. Doo::loadModel ( 'client' );
  3056. $client = new client ();
  3057. Doo::loadModel ( 'company' );
  3058. $company = new company ();
  3059. $cidList=explode(',', $cidString);
  3060. foreach ($cidList as $value){
  3061. if(!is_numeric($value))
  3062. die ('illegal request3');
  3063. }
  3064. $companyInfo = $company->getOne ( array (
  3065. 'where' => "cid = '" . $companyId . "'",
  3066. 'asArray' => TRUE
  3067. ) );
  3068. $client->address=$companyInfo['address'];
  3069. $client->ride=$companyInfo['ride'];
  3070. $client->landmarks=$companyInfo['landmarks'];
  3071. $client->stay=$companyInfo['stay'];
  3072. $client->local=$companyInfo['local'];
  3073. $client->district=$companyInfo['district'];
  3074. $falg=$client->update (array('where'=>'companyid ='.$companyInfo['cid'].' and cid in ('.$cidString.')'));
  3075. echo json_encode ( array (
  3076. 'status' => $falg,
  3077. 'msg' => 'illegal request2'
  3078. ) );
  3079. die ();
  3080. }
  3081. echo json_encode ( array (
  3082. 'status' => -1,
  3083. 'msg' => 'illegal request'
  3084. ) );
  3085. die ();
  3086. }
  3087. function checkclicomname() { // 地区区分
  3088. $companyname = $this->get_args('companyname') ? $this->get_args('companyname') : "";
  3089. $clientname = $this->get_args('clientname') ? $this->get_args('clientname') : "";
  3090. $district1 = $this->get_args('district1') ? $this->get_args('district1') : 0;
  3091. $district2 = $this->get_args('district2') ? $this->get_args('district2') : 0;
  3092. $district3 = $this->get_args('district3') ? $this->get_args('district3') : 0;
  3093. Doo::loadModel ( 'client' );
  3094. $client = new client ();
  3095. $local = $district1 . "," . $district2 . "," . $district3;
  3096. $companyname = trim ( $companyname );
  3097. $clientname = trim ( $clientname );
  3098. $clientinfo = $client->getClientToName ( $clientname, $companyname, $local );
  3099. if (! empty ( $clientinfo )) {
  3100. echo json_encode ( array (
  3101. 'success' => false
  3102. ) );
  3103. } else {
  3104. echo json_encode ( array (
  3105. 'success' => true
  3106. ) );
  3107. }
  3108. }
  3109. function ajaxGetClientInfoN() {
  3110. $clientname = $this->get_args('client') ? $this->get_args('client') : "";
  3111. if ($clientname == "") {
  3112. echo json_encode ( array (
  3113. "success" => false
  3114. ) );
  3115. die ();
  3116. }
  3117. Doo::loadModel ( 'client' );
  3118. Doo::loadModel ( 'client_staff' );
  3119. Doo::loadModel ( 'longle' );
  3120. Doo::loadModel ( 'company' );
  3121. Doo::loadModel ( 'service_log' );
  3122. $service_log = new service_log ();
  3123. $company = new company ();
  3124. $longle = new longle ();
  3125. $client = new client ();
  3126. $client_staff = new client_staff ();
  3127. $clientInfo = $client->getOne ( array (
  3128. "where" => ' cid like "' . $clientname . '"',
  3129. 'asArray' => TRUE
  3130. ) );
  3131. if (empty ( $clientInfo )) {
  3132. echo json_encode ( array (
  3133. "success" => false,
  3134. 'html' => ''
  3135. ) );
  3136. die ();
  3137. }
  3138. // 获取锁
  3139. $longleInfo = $longle->getLongleByClient ( $clientname );
  3140. $k = "";
  3141. foreach ( $longleInfo as $key => $value ) {
  3142. if ($value ['status'] == 6 || $value ['status'] == 7)
  3143. $k .= '<a href="javascript:void(0)" class="disenable" onclick="getLock(' . $value ['lid'] . ')" >' . $value ['key_num'] . '/' . $value ['product'] . '/' . $value ['statusT'] . '</a>&nbsp; ';
  3144. else
  3145. $k .= '<a href="javascript:void(0)" onclick="getLock(' . $value ['lid'] . ')" >' . $value ['key_num'] . '/' . $value ['product'] . '/' . $value ['statusT'] . '</a>&nbsp; ';
  3146. }
  3147. // 获取办事人
  3148. $staffInfo = $client_staff->getClientByCid ( $clientInfo ['cid'] );
  3149. // 获取公司信息
  3150. $companyInfo = $company->getCompanyByCid ( $clientInfo ['companyid'] );
  3151. $serviceLog = $service_log->getServiceByClientid ( $clientInfo ['cid'] );
  3152. $u = "";
  3153. $order = array (
  3154. "\r\n",
  3155. "\n",
  3156. "\r"
  3157. );
  3158. $replace = '</br>';
  3159. foreach ( $serviceLog as $key => $value ) {
  3160. $datetime = explode ( "-", $value ['date'] );
  3161. $u .= '<div class="infoFlowList">
  3162. <div class="dateTitle">
  3163. <em class="month"><span class="num">' . $datetime ['1'] . '</span><span class="text">-' . $datetime ['2'] . '</span></em>
  3164. <span class="year">' . $datetime ['0'] . '</span>
  3165. </div>
  3166. <ul class="flowList">';
  3167. if ($value ['status'] == 1)
  3168. $u .= '<li class="item iconService">上门服务</li>';
  3169. elseif ($value ['status'] == 2)
  3170. $u .= '<li class="item iconPhone">电话拜访</li>';
  3171. elseif ($value ['status'] == 3)
  3172. $u .= '<li class="item iconOther">其他</li>';
  3173. $u .= '
  3174. <li class="item">' . $value ['category'] . '<a href="javascript:void(0)" onclick="getStaffInfo(\'' . $value ['staffname'] . '\')" >' . $value ['staffname'] . '</a></li>
  3175. <li class="item">
  3176. ' . str_replace ( $order, $replace, $value ['mark'] ) . '
  3177. </li>
  3178. </ul>
  3179. </div>';
  3180. }
  3181. Doo::loadModel ( "tag_client" );
  3182. Doo::loadModel ( "tag" );
  3183. $tag = new tag ();
  3184. $tag_client = new tag_client ();
  3185. $tagId = $tag_client->getTagClientBySCid ( $clientInfo ['cid'], $this->staff [0] ['sid'] );
  3186. $taginfo = $tag->getTagByTidL ( $tagId ['tag'] );
  3187. // $taghtml="";
  3188. //
  3189. // foreach ($taginfo as $key=>$value){
  3190. // $taghtml.='<span class="contactsTag tagCol-0'.$value['colorid'].'">'.$value['name'].'</span>';
  3191. // }
  3192. $mhtml = "";
  3193. $dhtml = "";
  3194. for($month = 1; $month <= 12; $month ++) {
  3195. if (date ( "m" ) == $month)
  3196. $mhtml .= '<option selected value="' . $month . '">' . $month . '月</option>';
  3197. else
  3198. $mhtml .= '<option value="' . $month . '">' . $month . '月</option>';
  3199. }
  3200. for($day = 1; $day <= 31; $day ++) {
  3201. if (date ( "d" ) == $day)
  3202. $dhtml .= '<option selected value="' . $day . '">' . $day . '日</option>';
  3203. else
  3204. $dhtml .= '<option value="' . $day . '">' . $day . '日</option>';
  3205. }
  3206. // $b="";
  3207. // if(!empty($staffInfo))
  3208. // $b='<p class="fR">'.$staffInfo['category'].'-<a href="javascript:void(0)" onclick="getStaffInfo(\''.$staffInfo['username'].'\')" >'.$staffInfo['username'].'</a></p>'.$clientInfo['clientname'].' ';
  3209. //
  3210. $m = "";
  3211. if (! empty ( $companyInfo )) {
  3212. $m = '
  3213. <table width="100%">
  3214. <tbody>
  3215. <tr><th>单位全称</th><td colspan="3"><a href="javascript:void(0)" >' . $companyInfo [0] ['companyname'] . '</a></td></tr>
  3216. <tr><th>地区</th><td>' . $companyInfo [0] ['local'] . '</td><th>部门/职位</th><td>' . $clientInfo ['department'] . '/' . $clientInfo ['position'] . '</td></tr>
  3217. <tr><th>传真</th><td>' . $companyInfo [0] ['fax'] . '</td><th>办公室</th><td>' . $companyInfo [0] ['office'] . '</td></tr>
  3218. <tr><th>单位地址</th><td colspan="3">' . $companyInfo [0] ['address'] . '</td></tr>
  3219. <tr><th>乘车路线</th><td colspan="3">' . $companyInfo [0] ['ride'] . '</td></tr>
  3220. <tr><th>地标建筑</th><td colspan="3">' . $companyInfo [0] ['landmarks'] . '</td></tr>
  3221. <tr><th>参考住宿</th><td colspan="3">' . $clientInfo ['stay'] . '</td></tr>
  3222. <tr><th>单位主页</th><td colspan="3">' . $clientInfo ['webservice'] . '</td></tr>
  3223. </tbody></table>
  3224. ';
  3225. }
  3226. $clientHtml = array (
  3227. 'html' => '
  3228. <div class="modal-dialog ">
  3229. <div class="modal-content">
  3230. <div class="modal-header">
  3231. <h3><span class="fR"><a>' . $staffInfo ['category'] . ' ' . $staffInfo ['username'] . '</a></span>' . $clientInfo ['clientname'] . '</h3>
  3232. </div>
  3233. <div class="modal-body">
  3234. <div class="modalClientTable">
  3235. <table width="100%">
  3236. <tbody><tr><th>性别</th><td>' . $clientInfo ['gender'] . '</td><th>昵称</th><td>' . $clientInfo ['nicename'] . '</td></tr>
  3237. <tr><th>手机</th><td>' . $clientInfo ['telephone'] . '</td><th>QQ</th><td>' . $clientInfo ['qq'] . '</td></tr>
  3238. <tr><th>电话</th><td>' . $clientInfo ['phone'] . '</td><th>邮箱</th><td>' . $clientInfo ['email'] . '</td></tr>
  3239. <tr><th>软件锁</th><td colspan="3">' . $k . '</td></tr>
  3240. <tr><td colspan="4">
  3241. </td></tr>
  3242. </tbody>
  3243. </table>
  3244. ' . $m . '
  3245. <div class="clearfix">
  3246. ' . $u . '
  3247. </div>
  3248. </div>
  3249. </div>
  3250. <div class="modal-footer">
  3251. <a href="javascript:void(0)" onclick="closeClick()" class="button btn-gray" data-dismiss="modal" aria-hidden="true">关闭</a>
  3252. </div>
  3253. </div></div>
  3254. '
  3255. );
  3256. echo json_encode ( $clientHtml );
  3257. }
  3258. function ajaxGetClientInfo() {
  3259. $clientname = $this->get_args('client') ? $this->get_args('client') : "";
  3260. if ($clientname == "") {
  3261. echo json_encode ( array (
  3262. "success" => false
  3263. ) );
  3264. die ();
  3265. }
  3266. Doo::loadModel ( 'client' );
  3267. Doo::loadModel ( 'client_staff' );
  3268. Doo::loadModel ( 'longle' );
  3269. Doo::loadModel ( 'company' );
  3270. Doo::loadModel ( 'service_log' );
  3271. Doo::loadModel ( "district" );
  3272. $district = new district ();
  3273. $service_log = new service_log ();
  3274. $company = new company ();
  3275. $longle = new longle ();
  3276. $client = new client ();
  3277. $client_staff = new client_staff ();
  3278. $nameStr = explode ( ",", $clientname );
  3279. // $clientname=$nameStr[1];
  3280. if (! empty ( $nameStr [0] )) {
  3281. $clientInfo = $client->getOne ( array (
  3282. "where" => ' cid = "' . $nameStr [0] . '"',
  3283. 'asArray' => TRUE
  3284. ) );
  3285. } elseif (! empty ( $nameStr [1] ))
  3286. $clientInfo = $client->getOne ( array (
  3287. "where" => ' clientname = "' . $nameStr [1] . '"',
  3288. 'asArray' => TRUE
  3289. ) );
  3290. else
  3291. $clientInfo = array ();
  3292. if (empty ( $clientInfo )) {
  3293. echo json_encode ( array (
  3294. "success" => false,
  3295. 'html' => ''
  3296. ) );
  3297. die ();
  3298. }
  3299. // 获取锁
  3300. $longleInfo = $longle->getLongleByClientid ( $clientInfo ['cid'] );
  3301. $k = "";
  3302. foreach ( $longleInfo as $key => $value ) {
  3303. if ($value ['status'] == 6 || $value ['status'] == 7)
  3304. $k .= '<a href="javascript:void(0)" class="disenable" onclick="getLock(' . $value ['lid'] . ')" >' . $value ['key_num'] . '/' . $value ['product'] . '/' . $value ['statusT'] . '</a>&nbsp; ';
  3305. else
  3306. $k .= '<a href="javascript:void(0)" onclick="getLock(' . $value ['lid'] . ')" >' . $value ['key_num'] . '/' . $value ['product'] . '/' . $value ['statusT'] . '</a>&nbsp; ';
  3307. }
  3308. // 获取办事人
  3309. $staffInfo = $client_staff->getClientByCid ( $clientInfo ['cid'] );
  3310. $b = "";
  3311. if (! empty ( $staffInfo ))
  3312. $b = '<p class="fR">' . $staffInfo ['category'] . '-<a href="javascript:void(0)" onclick="getStaffInfo(\'' . $staffInfo ['username'] . '\')" >' . $staffInfo ['username'] . '</a></p>' . $clientInfo ['clientname'] . '<i class="icon- sport">' . $clientInfo ['priority'] . '</i>';
  3313. // 获取公司信息
  3314. $companyInfo = $company->getCompanyByCid ( $clientInfo ['companyid'] );
  3315. $serviceLog = $service_log->getServiceByClientid ( $clientInfo ['cid'] );
  3316. $local = $district->getbyidlist ( $clientInfo ['district'] );
  3317. if (! isset ( $local [1] ))
  3318. $local [1] ['name'] = "";
  3319. if (! isset ( $local [2] ))
  3320. $local [2] ['name'] = "";
  3321. $m = "";
  3322. if (! empty ( $companyInfo )) {
  3323. $m = '<div class="contactPanel">
  3324. <table>
  3325. <tbody>
  3326. <tr><th>单位全称</th><td colspan="3"><a href="javascript:void(0)" onclick="getCompany(\'' . $companyInfo [0] ['cid'] . '\')">' . $companyInfo [0] ['companyname'] . '</a></td></tr>
  3327. <tr><th>单位主页</th><td colspan="3">' . $clientInfo ['webservice'] . '</td></tr>
  3328. <tr><th>客户地区</th><td>' . $local [0] ['name'] . ',' . $local [1] ['name'] . ',' . $local [2] ['name'] . '</td><th>部门/职位</th><td>' . $clientInfo ['department'] . '/' . $clientInfo ['position'] . '</td></tr>
  3329. <tr><th>客户传真</th><td>' . $clientInfo ['fax'] . '</td><th>办公室</th><td>' . $clientInfo ['office'] . '</td></tr>
  3330. <tr><th>客户地址</th><td colspan="3">' . $clientInfo ['address'] . '</td></tr>
  3331. <tr><th>客户乘车</th><td colspan="3">' . $clientInfo ['ride'] . '</td></tr>
  3332. <tr><th>客户地标</th><td colspan="3">' . $clientInfo ['landmarks'] . '</td></tr>
  3333. <tr><th>客户住宿</th><td colspan="3">' . $clientInfo ['stay'] . '</td></tr>
  3334. </tbody></table>
  3335. </div>';
  3336. }
  3337. $u = "";
  3338. $order = array (
  3339. "\r\n",
  3340. "\n",
  3341. "\r"
  3342. );
  3343. $replace = '</br>';
  3344. foreach ( $serviceLog as $key => $value ) {
  3345. $datetime = explode ( "-", $value ['date'] );
  3346. $u .= '<div class="infoFlowList">
  3347. <div class="dateTitle">
  3348. <em class="month"><span class="num">' . $datetime ['1'] . '</span><span class="text">-' . $datetime ['2'] . '</span></em>
  3349. <span class="year">' . $datetime ['0'] . '</span>
  3350. </div>
  3351. <ul class="flowList">';
  3352. if ($value ['status'] == 1)
  3353. $u .= '<li class="item iconService">上门服务<';
  3354. elseif ($value ['status'] == 2)
  3355. $u .= '<li class="item iconPhone">电话拜访<';
  3356. elseif ($value ['status'] == 3)
  3357. $u .= '<li class="item iconOther">其他<';
  3358. $u .= $value ['category'] . '<a href="javascript:void(0)" onclick="getStaffInfo(\'' . $value ['staffname'] . '\')" >' . $value ['staffname'] . '</a></li>
  3359. <li class="item">
  3360. ' . str_replace ( $order, $replace, $value ['mark'] ) . '
  3361. </li>
  3362. </ul>
  3363. </div>';
  3364. }
  3365. Doo::loadModel ( "tag_client" );
  3366. Doo::loadModel ( "tag" );
  3367. $tag = new tag ();
  3368. $tag_client = new tag_client ();
  3369. $tagId = $tag_client->getTagClientBySCid ( $clientInfo ['cid'], $this->staff [0] ['sid'] );
  3370. $taginfo = $tag->getTagByTidL ( $tagId ['tag'] );
  3371. $taghtml = "";
  3372. foreach ( $taginfo as $key => $value ) {
  3373. $taghtml .= '<span class="contactsTag tagCol-0' . $value ['colorid'] . '">' . $value ['name'] . '</span>';
  3374. }
  3375. $mhtml = "";
  3376. $dhtml = "";
  3377. $yhtml = "";
  3378. for($year = 2020; $year >= 2004; $year --) {
  3379. if (date ( "Y" ) == $year)
  3380. $yhtml .= '<option selected value="' . $year . '">' . $year . '年</option>';
  3381. else
  3382. $yhtml .= '<option value="' . $year . '">' . $year . '年</option>';
  3383. }
  3384. for($month = 1; $month <= 12; $month ++) {
  3385. if (date ( "m" ) == $month)
  3386. $mhtml .= '<option selected value="' . $month . '">' . $month . '月</option>';
  3387. else
  3388. $mhtml .= '<option value="' . $month . '">' . $month . '月</option>';
  3389. }
  3390. for($day = 1; $day <= 31; $day ++) {
  3391. if (date ( "d" ) == $day)
  3392. $dhtml .= '<option selected value="' . $day . '">' . $day . '日</option>';
  3393. else
  3394. $dhtml .= '<option value="' . $day . '">' . $day . '日</option>';
  3395. }
  3396. $clientHtml = array (
  3397. 'html' => '<div class="contactInfo clearfix">
  3398. <div class="contactPanel">
  3399. <h1>' . $b . '<a data-original-title="编辑客户" data-toggle="ctooltip" data-placement="right" href="javascript:clientEdit(' . $clientInfo ['cid'] . ')" class="icon- edit">I</a></h1>
  3400. <table>
  3401. <tbody><tr><th>性别</th><td>' . $clientInfo ['gender'] . '</td><th>昵称</th><td>' . $clientInfo ['nicename'] . '</td></tr>
  3402. <tr><th>手机</th><td>' . $clientInfo ['telephone'] . '</td><th>QQ</th><td>' . $clientInfo ['qq'] . '</td></tr>
  3403. <tr><th>电话</th><td>' . $clientInfo ['phone'] . '</td><th>邮箱</th><td>' . $clientInfo ['email'] . '</td></tr>
  3404. <tr><th>软件锁</th><td colspan="3">' . $k . '</td></tr>
  3405. <tr><th>备注</th><td colspan="3">' . $clientInfo ['mark'] . '</td></tr>
  3406. <tr><td colspan="4">
  3407. ' . $taghtml . '
  3408. </td></tr>
  3409. </tbody></table>
  3410. </div>
  3411. ' . $m . '
  3412. </div>
  3413. <div class="lockRecord autoHeightR1" >
  3414. <!--添加记录按钮-->
  3415. <div class="addRecord addRecordButton clearfix" >
  3416. <a href="#" onclick="slideupInfo(this)">+ 打开添加服务记录</a>
  3417. </div>
  3418. <!--添加记录-->
  3419. <div class="addRecord addRecordForm clearfix hide">
  3420. <a onclick="slidedownInfo(this)" class="fR slidedownInfo">- 关闭添加记录</a>
  3421. <form name="lk" action="/addServiceLog" method="post" >
  3422. <div class="control-group">
  3423. <div class="controls">
  3424. <label class="radio inline">
  3425. <input type="radio" name="logstatus" id="status" checked value="2">电话拜访
  3426. </label>
  3427. <label class="radio inline">
  3428. <input type="radio" name="logstatus" id="status" value="1" >上门服务
  3429. </label>
  3430. <label class="radio inline">
  3431. <input type="radio" name="logstatus" id="status" value="3">其他
  3432. </label>
  3433. </div>
  3434. </div>
  3435. <div class="control-group">
  3436. <div class="controls">时间:
  3437. <select name="y" id="y">
  3438. ' . $yhtml . '
  3439. </select>
  3440. <select name="m" id="m">
  3441. ' . $mhtml . '
  3442. </select>
  3443. <select name="d" id="d">
  3444. ' . $dhtml . '
  3445. </select>
  3446. </div>
  3447. </div>
  3448. <link href="' . WEB_SITE_GLOBAL . 'css/bootstrap-datetimepicker.min.css" rel="stylesheet" media="screen">
  3449. <!--添加记录-备注-->
  3450. <!--<div class="control-group">
  3451. <div class="controls">
  3452. <select name="date" id="date">
  3453. <option value="2013">2013</option>
  3454. </select>
  3455. </div>
  3456. </div>-->
  3457. <div class="control-group">
  3458. <div class="controls" onclick="slideupInfo()">
  3459. <textarea name="mark" id="mark" style="width:95%" rows="5"></textarea>
  3460. <div class="bsAlert bsWarning"><b>含泪告知:</b>客户记录暂时无法修改!删除!,添加时请谨慎。点击确定添加成功后,信息会立即出现在下方!注意咯,别猛戳‘确定添加’导致重复添加了哦~</div>
  3461. </div>
  3462. </div>
  3463. <div class="control-group">
  3464. <div class="controls">
  3465. <div style="display:inline-block;margin-right:10px"><label><input name="Remind" onclick="reFK()" type="checkbox" value="1"> 添加提醒</label></div>
  3466. <span id="reHL" class="hide">
  3467. <div>
  3468. 限期:
  3469. <input type="date" name="time" id="dtp_input2" value="" class="hide"/>
  3470. </div>
  3471. <div>
  3472. 备注:<input id="remark" name="remark" type="text"></span>
  3473. </div>
  3474. </div>
  3475. <div class="control-group">
  3476. <div class="controls clearfix">
  3477. <input type="button" value="确定添加" id="conSer" onclick="aServiceLog(\'' . $this->staff [0] ['category'] . '\',\'' . $this->staff [0] ['username'] . '\',' . $clientInfo ['cid'] . ')" class="button"></input>
  3478. <div id="load"></div>
  3479. </div>
  3480. </div>
  3481. </div>
  3482. </form>
  3483. </div>
  3484. <!--添加记录按钮-->
  3485. <!--记录列表-->
  3486. <div id="kl"></div>
  3487. ' . $u . '
  3488. <script type="text/javascript">autoFlashHeight();</script> </div>'
  3489. );
  3490. echo json_encode ( $clientHtml );
  3491. }
  3492. function ajaxGetCompanyInfo() {
  3493. }
  3494. function checkClient() {
  3495. $searchDbInforItem = $this->get_args('name') ? $this->get_args('name') : "";
  3496. $searchDbInforItem = explode ( '-', $searchDbInforItem );
  3497. if (! empty ( $searchDbInforItem )) {
  3498. Doo::loadModel ( 'client' );
  3499. $client = new client ();
  3500. $clientInfo = $client->getClientByName2 ( $searchDbInforItem [0], $searchDbInforItem [1] );
  3501. if (! empty ( $clientInfo ))
  3502. echo json_encode ( array (
  3503. "success" => true
  3504. ) );
  3505. else
  3506. echo json_encode ( array (
  3507. "success" => false
  3508. ) );
  3509. } else {
  3510. echo json_encode ( array (
  3511. "success" => false
  3512. ) );
  3513. }
  3514. }
  3515. function searchClient() {
  3516. $searchDbInforItem = $this->get_args('searchDbInforItem') ? $this->get_args('searchDbInforItem') : "";
  3517. if (! empty ( $searchDbInforItem )) {
  3518. Doo::loadModel ( 'client' );
  3519. $client = new client ();
  3520. $clientInfo = $client->getClientByName ( $searchDbInforItem );
  3521. echo json_encode ( $clientInfo );
  3522. } else {
  3523. echo json_encode ( array (
  3524. 0 => array (
  3525. 'clientname' => ''
  3526. )
  3527. ) );
  3528. }
  3529. }
  3530. function searchCompany() {
  3531. $searchDbInforItem = $this->get_args('searchDbInforItem') ? $this->get_args('searchDbInforItem') : "";
  3532. if (! empty ( $searchDbInforItem )) {
  3533. Doo::loadModel ( 'company' );
  3534. $company = new company ();
  3535. $clientInfo = $company->searchCompany ( $searchDbInforItem );
  3536. echo json_encode ( $clientInfo );
  3537. } else {
  3538. echo json_encode ( array (
  3539. 0 => array (
  3540. 'companyname' => '',
  3541. 'local' => ''
  3542. )
  3543. ) );
  3544. }
  3545. }
  3546. function checkCompany() {
  3547. $searchDbInforItem = $this->get_args('name') ? $this->get_args('name') : "";
  3548. $searchDbInforItem = explode ( '-', $searchDbInforItem );
  3549. $this->nature ['naturelenght'] = 15;
  3550. Doo::loadModel ( 'district' );
  3551. $district = new district ();
  3552. $d = $district->get_lv ( 1 );
  3553. $html = '<option vlaue="0">请选择</option>';
  3554. foreach ( $d as $key => $value ) {
  3555. $html .= '<option value="' . $value ['id'] . '">' . $value ['name'] . '</option>';
  3556. }
  3557. $this->nature ['district'] = $html;
  3558. if (! empty ( $searchDbInforItem )) {
  3559. Doo::loadModel ( 'company' );
  3560. $company = new company ();
  3561. if (! isset ( $searchDbInforItem [1] )) {
  3562. echo json_encode ( array (
  3563. "success" => false,
  3564. 'nature' => $this->nature
  3565. ) );
  3566. die ();
  3567. }
  3568. $clientInfo = $company->getCompanyByName ( $searchDbInforItem [0], $searchDbInforItem [1] );
  3569. if (! empty ( $clientInfo ))
  3570. echo json_encode ( array (
  3571. "success" => true,
  3572. 'data' => $clientInfo
  3573. ) );
  3574. else
  3575. echo json_encode ( array (
  3576. "success" => false,
  3577. 'nature' => $this->nature
  3578. ) );
  3579. } else {
  3580. echo json_encode ( array (
  3581. "success" => false,
  3582. 'nature' => $this->nature
  3583. ) );
  3584. }
  3585. }
  3586. function checkLongle() {
  3587. $searchDbInforItem = $this->get_args('name') ? $this->get_args('name') : "";
  3588. $searchDbInforItem = explode ( ' ', $searchDbInforItem );
  3589. if (! empty ( $searchDbInforItem )) {
  3590. Doo::loadModel ( 'longle' );
  3591. $longle = new longle ();
  3592. $clientInfo = $longle->getLongleBykeynum ( $searchDbInforItem [0] );
  3593. if (! empty ( $clientInfo ))
  3594. echo json_encode ( array (
  3595. "success" => true
  3596. ) );
  3597. else
  3598. echo json_encode ( array (
  3599. "success" => false
  3600. ) );
  3601. } else {
  3602. echo json_encode ( array (
  3603. "success" => false
  3604. ) );
  3605. }
  3606. }
  3607. function searchLongle() {
  3608. $searchDbInforItem = $this->get_args('searchDbInforItem') ? $this->get_args('searchDbInforItem') : "";
  3609. if (! empty ( $searchDbInforItem )) {
  3610. Doo::loadModel ( 'longle' );
  3611. $longle = new longle ();
  3612. $longleInfo = $longle->getLongleBykeynum2 ( $searchDbInforItem );
  3613. echo json_encode ( $longleInfo );
  3614. } else {
  3615. echo json_encode ( array (
  3616. 0 => array (
  3617. 'clientname' => ''
  3618. )
  3619. ) );
  3620. }
  3621. }
  3622. function updateChangeCompany() {
  3623. $cid = $this->get_args('cid') ? $this->get_args('cid') : 0;
  3624. $clientID = $this->get_args('clientID') ? $this->get_args('clientID') : 0;
  3625. $companyname = $this->get_args('companyname') ? $this->get_args('companyname') : "";
  3626. Doo::loadModel ( 'company' );
  3627. Doo::loadModel ( 'client' );
  3628. $client = new client ();
  3629. $company = new company ();
  3630. $companyname = explode ( "-", $companyname );
  3631. if (isset ( $companyname [1] ))
  3632. $k = $company->getCompanyByName ( $companyname [0], $companyname [1] );
  3633. else
  3634. $k = array ();
  3635. if (! empty ( $cid ) && ! empty ( $k ) && ! empty ( $clientID )) {
  3636. $client->cid = $clientID;
  3637. $client->companyid = $cid;
  3638. $client->companyname = $companyname [0];
  3639. $client->update ();
  3640. } else {
  3641. $local1 = $this->get_args('lv21') ? $this->get_args('lv21') : 0;
  3642. $local2 = $this->get_args('lv22') ? $this->get_args('lv22') : 0;
  3643. $local3 = $this->get_args('lv23') ? $this->get_args('lv23') : 0;
  3644. Doo::loadModel ( 'district' );
  3645. $district = new district ();
  3646. // 更新公司信息
  3647. $lv1 = $district->getbyid ( $local1 );
  3648. $lv2 = $district->getbyid ( $local2 );
  3649. $lv3 = $district->getbyid ( $local3 );
  3650. if (empty ( $local1 ) || empty ( $local2 ))
  3651. return "/";
  3652. if (! empty ( $local1 ) && ! empty ( $local2 ))
  3653. $company->local = $lv1 [0] ['name'] . "," . $lv2 [0] ['name'] . "," . $lv3 [0] ['name'];
  3654. if (! empty ( $local1 ) && ! empty ( $local2 ))
  3655. $company->district = $local1 . "," . $local2 . "," . $local3;
  3656. $nature = $this->get_args('nature') ? $this->get_args('nature') : "";
  3657. $fax = $this->get_args('fax') ? $this->get_args('fax') : "";
  3658. $webservice = $this->get_args('webservice') ? $this->get_args('webservice') : "";
  3659. $address = $this->get_args('address') ? $this->get_args('address') : "";
  3660. $landmarks = $this->get_args('landmarks') ? $this->get_args('landmarks') : "";
  3661. $stay = $this->get_args('stay') ? $this->get_args('stay') : "";
  3662. $ride = $this->get_args('ride') ? $this->get_args('ride') : "";
  3663. $nature = implode ( ",", $nature );
  3664. $company->companyname = $companyname [0];
  3665. $company->ride = $ride;
  3666. $company->fax = $fax;
  3667. $company->webservice = $webservice;
  3668. $company->address = $address;
  3669. $company->landmarks = $landmarks;
  3670. $company->stay = $stay;
  3671. $company->nature = $nature;
  3672. $cid = $company->insert ();
  3673. $client->cid = $clientID;
  3674. $client->companyid = $cid;
  3675. $client->companyname = $companyname [0];
  3676. $client->update ();
  3677. }
  3678. return "/";
  3679. }
  3680. function AddClientInfo() { // 不编辑公司
  3681. $cid = $this->get_args('cid') ? $this->get_args('cid') : 0;
  3682. $clientname = $this->get_args('clientname') ? $this->get_args('clientname') : "";
  3683. $gender = $this->get_args('gender') ? $this->get_args('gender') : "";
  3684. $nicename = $this->get_args('nicename') ? $this->get_args('nicename') : "";
  3685. $telephone = $this->get_args('telephone') ? $this->get_args('telephone') : "";
  3686. $phone = $this->get_args('phone') ? $this->get_args('phone') : "";
  3687. $email = $this->get_args('email') ? $this->get_args('email') : "";
  3688. $unit = $this->get_args('unit') ? $this->get_args('unit') : "";
  3689. $fax = $this->get_args('fax') ? $this->get_args('fax') : "";
  3690. $webservice = $this->get_args('webservice') ? $this->get_args('webservice') : "";
  3691. $department = $this->get_args('department') ? $this->get_args('department') : "";
  3692. $position = $this->get_args('position') ? $this->get_args('position') : "";
  3693. $office = $this->get_args('office') ? $this->get_args('office') : "";
  3694. $address = $this->get_args('address') ? $this->get_args('address') : "";
  3695. $ride = $this->get_args('ride') ? $this->get_args('ride') : "";
  3696. $landmarks = $this->get_args('landmarks') ? $this->get_args('landmarks') : "";
  3697. $qq = $this->get_args('qq') ? $this->get_args('qq') : "";
  3698. $priority = $this->get_args('priority') ? $this->get_args('priority') : 5;
  3699. $stay = $this->get_args('stay') ? $this->get_args('stay') : "";
  3700. $mark = $this->get_args('mark') ? $this->get_args('mark') : "";
  3701. $lv21 = $this->get_args('lv21') ? $this->get_args('lv21') : "";
  3702. $lv22 = $this->get_args('lv22') ? $this->get_args('lv22') : "";
  3703. $lv23 = $this->get_args('lv23') ? $this->get_args('lv23') : "";
  3704. if (! empty ( $cid ) && ! empty ( $clientname )) {
  3705. Doo::loadModel ( 'client' );
  3706. Doo::loadModel ( 'district' );
  3707. $district = new district ();
  3708. $client = new client ();
  3709. $client->cid = $cid;
  3710. $client->clientname = $clientname;
  3711. $client->gender = $gender;
  3712. $client->nicename = $nicename;
  3713. $client->telephone = $telephone;
  3714. $client->phone = $phone;
  3715. $client->email = $email;
  3716. // if(!empty($unit)){
  3717. // $client->unit=$unit;
  3718. // $client->companyname=$unit;
  3719. // }
  3720. if (! empty ( $lv21 ) && ! empty ( $lv22 ) && ! empty ( $lv23 )) {
  3721. $client->district = $lv21 . "," . $lv22 . "," . $lv23;
  3722. }
  3723. if (! empty ( $client->district )) {
  3724. $districtList = $district->find ( array (
  3725. 'where' => 'id in(' . $client->district . ')',
  3726. 'asArray' => true
  3727. ) );
  3728. $jsonString = array ();
  3729. foreach ( $districtList as $value ) {
  3730. array_push ( $jsonString, $value ['name'] );
  3731. }
  3732. $jsonString = implode ( ",", $jsonString );
  3733. if (! empty ( $jsonString ))
  3734. $client->local = $jsonString;
  3735. }
  3736. $client->fax = $fax;
  3737. $client->webservice = $webservice;
  3738. $client->department = $department;
  3739. $client->position = $position;
  3740. $client->office = $office;
  3741. $client->address = $address;
  3742. $client->ride = $ride;
  3743. $client->landmarks = $landmarks;
  3744. $client->qq = $qq;
  3745. $client->stay = $stay;
  3746. $client->priority = $priority;
  3747. $client->mark = $mark;
  3748. $client->updatetime = time ();
  3749. $client->update ();
  3750. // Doo::loadModel ( 'company' );
  3751. // $company = new company();
  3752. // $companyid=$client->getOne(array('where'=>' cid='.$cid,'asArray'=>true));
  3753. // $company->office=$office;
  3754. // $company->fax=$fax;
  3755. // $company->address=$address;
  3756. // $company->ride=$ride;
  3757. // $company->landmarks=$landmarks;
  3758. // $company->cid=$companyid['companyid'];
  3759. // if(!empty($unit)){
  3760. // $company->companyname=$unit;
  3761. // }
  3762. // $company->update();
  3763. $clientInfo = $client->getOne ( array (
  3764. 'where' => ' cid=' . $cid,
  3765. 'asArray' => true
  3766. ) );
  3767. // 日常行为
  3768. Doo::loadModel ( "action_log" );
  3769. $action_log = new action_log ();
  3770. $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(\'' . $cid . '\')">' . $clientname . '</a>(' . $clientInfo ['companyname'] . ')';
  3771. $action_log->sid = $this->staff [0] ['sid'];
  3772. $action_log->cid = $this->staff [0] ['cid'];
  3773. $action_log->updatetime = date ( "Y-m-d" );
  3774. $action_log->time = date ( "H:i" );
  3775. $action_log->class = $action_log->iconContacts;
  3776. $action_log->status = 2;
  3777. $action_log->districtid = $clientInfo ['district'];
  3778. $local = $district->getbyidlist ( $clientInfo ['district'] );
  3779. $action_log->city = $local [0] ['name'];
  3780. $action_log->province = $local [1] ['name'];
  3781. $action_log->company = $clientInfo ['companyname'];
  3782. Doo::loadModel ( 'company' );
  3783. $company = new company ();
  3784. $companyInfo = $company->getOne ( array (
  3785. 'where' => ' companyname="' . $clientInfo ['companyname'] . '"',
  3786. 'asArray' => true
  3787. ) );
  3788. $nature = explode ( ',', $companyInfo ['nature'] );
  3789. $action_log->nature = $nature [0];
  3790. $action_log->insert ();
  3791. echo json_encode ( array (
  3792. "success" => true
  3793. ) );
  3794. die ();
  3795. } else
  3796. echo json_encode ( array (
  3797. "success" => false
  3798. ) );
  3799. die ();
  3800. }
  3801. function ajaxClientInfo() {
  3802. $cid = $this->get_args('cid') ? $this->get_args('cid') : 0;
  3803. if (! empty ( $cid )) {
  3804. Doo::loadModel ( 'client' );
  3805. Doo::loadModel ( 'company' );
  3806. $company = new company ();
  3807. $client = new client ();
  3808. $info = $client->getOne ( array (
  3809. 'where' => ' cid=' . $cid,
  3810. 'asArray' => true
  3811. ) );
  3812. $cinfo = $company->getOne ( array (
  3813. 'where' => ' cid=' . $info ['companyid'],
  3814. 'asArray' => true
  3815. ) );
  3816. Doo::loadModel ( 'district' );
  3817. $district = new district ();
  3818. $districtLv1 = $district->get_lv ( 1 );
  3819. $info ['districtList'] = $district->getbyidlist ( $info ['district'] );
  3820. $optionHtml = '<option vlaue="0">请选择</option>';
  3821. foreach ( $districtLv1 as $key => $value ) {
  3822. if ($value ['name'] == $info ['districtList'] [0] ['name'])
  3823. $optionHtml .= '<option selected value="' . $value ['id'] . '">' . $value ['name'] . '</option>';
  3824. else
  3825. $optionHtml .= '<option value="' . $value ['id'] . '">' . $value ['name'] . '</option>';
  3826. }
  3827. $info ['districtLv1'] = $optionHtml;
  3828. $info ['companyInfo'] = $cinfo;
  3829. echo json_encode ( array (
  3830. "success" => true,
  3831. 'html' => $info
  3832. ) );
  3833. die ();
  3834. } else
  3835. echo json_encode ( array (
  3836. "success" => false,
  3837. 'html' => ''
  3838. ) );
  3839. die ();
  3840. }
  3841. function ajaxAddServiceLog() {
  3842. $status = $this->get_args('status') ? $this->get_args('status') : "";
  3843. $clientid = $this->get_args('cid') ? $this->get_args('cid') : "";
  3844. $mark = $this->get_args('mark') ? $this->get_args('mark') : "";
  3845. $m = $this->get_args('m') ? $this->get_args('m') : "";
  3846. $d = $this->get_args('d') ? $this->get_args('d') : "";
  3847. $y = $this->get_args('y') ? $this->get_args('y') : date ( "Y" );
  3848. $Remind = $this->get_args('Remind') ? $this->get_args('Remind') : 0;
  3849. $time = $this->get_args('time') ? $this->get_args('time') : 0;
  3850. $remark = $this->get_args('remark') ? $this->get_args('remark') : "";
  3851. if (! empty ( $status ) && ! empty ( $clientid )) {
  3852. Doo::loadModel ( 'service_log' );
  3853. Doo::loadModel ( 'client_staff' );
  3854. Doo::loadModel ( 'client' );
  3855. Doo::loadModel ( 'district' );
  3856. $district = new district ();
  3857. $client = new client ();
  3858. $clientStaff = new client_staff ();
  3859. $service_log = new service_log ();
  3860. $service_log->status = $status;
  3861. $service_log->clientid = $clientid;
  3862. $service_log->mark = htmlspecialchars ( $mark );
  3863. $service_log->date = $y . "-" . $m . "-" . $d;
  3864. $service_log->category = $this->staff [0] ['category'];
  3865. $service_log->staffname = $this->staff [0] ['username'];
  3866. $service_log->staffid = $this->staff [0] ['sid'];
  3867. $service_log->insert ();
  3868. // 日常行为
  3869. Doo::loadModel ( "action_log" );
  3870. Doo::loadModel ( "client" );
  3871. $client = new client ();
  3872. // 记录服务时间
  3873. $client->cid = $clientid;
  3874. $client->servicetime = time ();
  3875. $client->update ();
  3876. $action_log = new action_log ();
  3877. $clientInfo = $client->getOne ( array (
  3878. 'where' => ' cid=' . $clientid,
  3879. 'asArray' => TRUE
  3880. ) );
  3881. $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(\'' . $clientid . '\')">' . $clientInfo ['clientname'] . '</a>(' . $clientInfo ['companyname'] . ')添加新客户记录。';
  3882. $action_log->sid = $this->staff [0] ['sid'];
  3883. $action_log->cid = $this->staff [0] ['cid'];
  3884. $action_log->updatetime = date ( "Y-m-d" );
  3885. $action_log->time = date ( "H:i" );
  3886. $action_log->status = 3;
  3887. $action_log->districtid = $clientInfo ['district'];
  3888. $local = $district->getbyidlist ( $clientInfo ['district'] );
  3889. $action_log->city = $local [0] ['name'];
  3890. $action_log->province = $local [1] ['name'];
  3891. $action_log->company = $clientInfo ['companyname'];
  3892. Doo::loadModel ( 'company' );
  3893. $company = new company ();
  3894. $companyInfo = $company->getOne ( array (
  3895. 'where' => ' companyname="' . $clientInfo ['companyname'] . '"',
  3896. 'asArray' => true
  3897. ) );
  3898. $nature = explode ( ',', $companyInfo ['nature'] );
  3899. $action_log->nature = $nature [0];
  3900. $action_log->class = $action_log->iconContacts;
  3901. $action_log->insert ();
  3902. if (! empty ( $Remind )) {
  3903. Doo::loadModel ( 'remind' );
  3904. $remindObj = new remind ();
  3905. $datetime1 = new DateTime ( date ( 'Y-m-d' ) );
  3906. $datetime2 = new DateTime ( $time );
  3907. $interval = $datetime1->diff ( $datetime2 );
  3908. $remindObj->day = $interval->format ( '%a' );
  3909. $remindObj->remark = $remark;
  3910. $remindObj->time = date ( "Y-m-d" );
  3911. $remindObj->clientName = $clientInfo ['clientname'];
  3912. $remindObj->clientID = $clientid;
  3913. $remindObj->companyName = $clientInfo ['companyname'];
  3914. $remindObj->companyID = $companyInfo ['cid'];
  3915. $remindObj->staffID = $this->staff [0] ['sid'];
  3916. if ($status == 1)
  3917. $remindObj->class = "iconService";
  3918. if ($status == 2)
  3919. $remindObj->class = "iconPhone";
  3920. if ($status == 3)
  3921. $remindObj->class = "iconOther";
  3922. $remindObj->insert ();
  3923. }
  3924. echo json_encode ( array (
  3925. "success" => true,
  3926. 'html' => ''
  3927. ) );
  3928. die ();
  3929. } else
  3930. echo json_encode ( array (
  3931. "success" => false,
  3932. 'html' => ''
  3933. ) );
  3934. die ();
  3935. }
  3936. function _getLongleLogHtml($longleLog = array()) {
  3937. $html = "";
  3938. foreach ( $longleLog as $key => $value ) {
  3939. $dateline = explode ( "-", $value ['dateline'] );
  3940. $html .= '<div class="infoFlowList">
  3941. <div class="dateTitle">
  3942. <em class="month"><span class="num">' . $dateline [1] . '</span><span class="text">-' . $dateline [2] . '</span></em>
  3943. <span class="year">' . $dateline [0] . '</span>
  3944. </div>
  3945. ';
  3946. // 备注
  3947. if ($value ['status'] == 8) {
  3948. $html .= '
  3949. <ul class="flowList">
  3950. <li class="item iconLock">备注<' . $value ['category'] . '<a href="javascript:void(0);" onclick="getStaffInfo(\'' . $value ['operator'] . '\')" >' . $value ['operator'] . '</a></li>
  3951. <li class="item">' . $value ['mark'] . '</li>
  3952. </ul>';
  3953. // 生成
  3954. } elseif ($value ['status'] == 1) {
  3955. $html .= '<ul class="flowList">
  3956. <li class="item iconGenerate">生成<' . $value ['category'] . '<a href="javascript:void(0);" onclick="getStaffInfo(\'' . $value ['operator'] . '\')" >' . $value ['operator'] . '</a></li>
  3957. </ul>';
  3958. // 接收
  3959. } elseif ($value ['status'] == 2) {
  3960. $html .= '<ul class="flowList">
  3961. <li class="item iconReceive">接收<' . $value ['category'] . '<a href="javascript:void(0);" onclick="getStaffInfo(\'' . $value ['operator'] . '\')" >' . $value ['operator'] . '</a></li>
  3962. </ul>';
  3963. // 借出
  3964. } elseif ($value ['status'] == 3) {
  3965. $html .= '<ul class="flowList">
  3966. <li class="item iconBorrow">借出<' . $value ['category'] . '<a href="javascript:void(0);" onclick="getStaffInfo(\'' . $value ['operator'] . '\')" >' . $value ['operator'] . '</a></li>
  3967. <li class="item">' . $value ['product'] . '</li>
  3968. <li class="item"><a href="javascript:void(0);" onclick="getClientInfo(\'' . $value ['clientid'] . "," . $value ['client'] . '\')" >' . $value ['client'] . '</a></li>
  3969. </ul>';
  3970. // 销售
  3971. } elseif ($value ['status'] == 4) {
  3972. $html .= '<ul class="flowList">
  3973. <li class="item iconSell">销售<' . $value ['category'] . '<a href="javascript:void(0);" onclick="getStaffInfo(\'' . $value ['operator'] . '\')" >' . $value ['operator'] . '</a></li>
  3974. <li class="item">' . $value ['product'] . '</li>
  3975. <li class="item"><a href="javascript:void(0);" onclick="getClientInfo(\'' . $value ['clientid'] . "," . $value ['client'] . '\')" >' . $value ['client'] . '</a></li>
  3976. </ul>';
  3977. // 升级
  3978. } elseif ($value ['status'] == 5) {
  3979. $html .= '<ul class="flowList">
  3980. <li class="item iconUpdate">升级<' . $value ['category'] . '<a href="javascript:void(0);" onclick="getStaffInfo(\'' . $value ['operator'] . '\')" >' . $value ['operator'] . '</a></li>
  3981. <li class="item">' . $value ['product'] . '</li>
  3982. <li class="item"><a href="javascript:void(0);" onclick="getClientInfo(\'' . $value ['clientid'] . "," . $value ['client'] . '\')" >' . $value ['client'] . '</a></li>
  3983. </ul>';
  3984. // 更换
  3985. } elseif ($value ['status'] == 6) {
  3986. $html .= '<ul class="flowList">
  3987. <li class="item iconReplace">更换<' . $value ['category'] . '<a href="javascript:void(0);" onclick="getStaffInfo(\'' . $value ['operator'] . '\')">' . $value ['operator'] . '</a></li>
  3988. <li class="item"><a href="javascript:void(0);" onclick="getLockByName(\'' . $value ['new_key_num'] . '\')">' . $value ['new_key_num'] . '</a>
  3989. <li class="item"><a href="javascript:void(0);" onclick="getClientInfo(\'' . $value ['clientid'] . "," . $value ['client'] . '\')" >' . $value ['client'] . '</a></li>
  3990. </ul>';
  3991. // 回收
  3992. } elseif ($value ['status'] == 7) {
  3993. Doo::loadModel ( 'staff' );
  3994. $staff = new staff ();
  3995. $staffinfo = $staff->getOne ( array (
  3996. 'where' => ' username like "' . $value ['responsible'] . '"',
  3997. 'asArray' => true
  3998. ) );
  3999. if (empty ( $staffinfo ))
  4000. $staffinfo ['category'] = "";
  4001. $html .= '<ul class="flowList">
  4002. <li class="item iconRecycle">收回<' . $value ['category'] . '<a href="javascript:void(0);" onclick="getStaffInfo(\'' . $value ['operator'] . '\')">' . $value ['operator'] . '</a></li>
  4003. <li class="item">' . $staffinfo ['category'] . '<a href="javascript:void(0);" id="ajaxStaff" data="' . $value ['responsible'] . '">' . $value ['responsible'] . '</a></li>
  4004. </ul>';
  4005. } elseif ($value ['status'] == 9) {
  4006. $html .= '<ul class="flowList">
  4007. <li class="item iconGif">赠送 &lt; ' . $value ['category'] . '<a href="javascript:void(0);" onclick="getStaffInfo(\'' . $value ['operator'] . '\')">' . $value ['operator'] . '</a></li>
  4008. <li class="item"><a href="javascript:void(0);" onclick="getClientInfo(\'' . $value ['clientid'] . "," . $value ['client'] . '\')" >' . $value ['client'] . '</a></li>
  4009. </ul>';
  4010. }
  4011. $html .= '</div>';
  4012. }
  4013. return $html;
  4014. }
  4015. function adminLock() {
  4016. $emsg = isset ( $this->params ['emsg'] ) ? $this->params ['emsg'] : "";
  4017. $data ['emsg'] = "";
  4018. if ($emsg != "")
  4019. $data ['emsg'] = "请填写完整的数据";
  4020. $data ['memu'] = "keyonline";
  4021. $data ['staff'] = $this->staff;
  4022. if ($this->staff [0] ['isadmin'] != 1)
  4023. return "/adminmyinfo";
  4024. Doo::loadModel ( 'L_category' );
  4025. $L_category = new L_category ();
  4026. $data ['category'] = $L_category->getCategory ();
  4027. $data ['time'] = time ();
  4028. $this->render ( "/admin/admin_addlock", $data );
  4029. }
  4030. function adminAddLock() {
  4031. $cid = $this->get_args('cid') ? $this->get_args('cid') : 0;
  4032. $path = $this->get_args('path') ? $this->get_args('path') : "";
  4033. if ($cid != 0 && $path != "") {
  4034. Doo::loadModel ( 'longle' );
  4035. Doo::loadModel ( 'L_category' );
  4036. $L_category = new L_category ();
  4037. Doo::loadModel ( 'longle_log' );
  4038. $exlArray = $this->_format_excel_to_array ( DOO::conf ()->SITE_PATH . "upload/" . iconv ( "UTF-8", "GB2312", $path ) );
  4039. // print_r($exlArray);die;
  4040. // echo json_encode($exlArray);die;
  4041. $category = $L_category->getCategoryById ( $cid );
  4042. foreach ( $exlArray as $key => $value ) {
  4043. // 锁记录
  4044. $longle = new longle ();
  4045. $longle->key_num = str_replace ( "'", "", $value ['key_num'] );
  4046. $longle->product = str_replace ( "'", "", $value ['product'] );
  4047. $longle->make_day = $value ['make_day'];
  4048. $longle->alloted_time = $value ['alloted_time'];
  4049. $longle->status = 1;
  4050. $longle->statusT = "生成";
  4051. $longle->cid = $cid;
  4052. $longle->category = $category [0] ['title'];
  4053. $longle->SerialNumber = $value ['SerialNumber'];
  4054. $longle->version = $value ['version'];
  4055. $lid = $longle->insert ();
  4056. // 锁日志记录
  4057. $longle_log = new longle_log ();
  4058. $longle_log->lid = $lid;
  4059. $longle_log->status = 1;
  4060. $longle_log->statusT = "生成";
  4061. $longle_log->operator = $this->staff [0] ['username'];
  4062. $longle_log->product = $longle->product;
  4063. $longle_log->category = $this->staff [0] ['category'];
  4064. $longle_log->dateline = date ( "Y-m-d" );
  4065. $id = $longle_log->insert ();
  4066. }
  4067. // 记录日常行为
  4068. Doo::loadModel ( "action_log" );
  4069. $action_log = new action_log ();
  4070. $action_log->action = '总部<b href="javascript:void(0)" onclick="showStaff(\'' . $this->staff [0] ['sid'] . '\')" >' . $this->staff [0] ['username'] . '</b>生成<a href="javascript:void(0)" onclick="showLook(\'' . str_replace ( "'", "", $exlArray [0] ['key_num'] ) . '\')">' . str_replace ( "'", "", $exlArray [0] ['key_num'] ) . '</a>等<b>' . count ( $exlArray ) . '</b>个锁';
  4071. $action_log->sid = $this->staff [0] ['sid'];
  4072. $action_log->cid = $this->staff [0] ['cid'];
  4073. $action_log->class = $action_log->iconGenerate;
  4074. $action_log->updatetime = date ( "Y-m-d" );
  4075. $action_log->time = date ( "H:i" );
  4076. $action_log->status = 11;
  4077. $action_log->insert ();
  4078. return "/keyonline";
  4079. } else
  4080. return "/adminlock/error";
  4081. }
  4082. function avatarCM() {
  4083. $vid = isset ( $this->params ['vid'] ) ? $this->params ['vid'] : 0;
  4084. if (! empty ( $vid )) {
  4085. Doo::loadModel ( "verify" );
  4086. $verify = new verify ();
  4087. Doo::loadModel ( 'staff' );
  4088. $staff = new staff ();
  4089. $list = $verify->getOne ( array (
  4090. 'where' => 'vid=' . $vid,
  4091. 'asArray' => true
  4092. ) );
  4093. if (empty ( $list ))
  4094. return "/adminverify";
  4095. $avatar = json_decode ( $list ['staff'] );
  4096. foreach ( $avatar as $key => $value ) {
  4097. $uinfo = $staff->getOne ( array (
  4098. 'where' => 'sid=' . $value [0],
  4099. 'asArray' => true
  4100. ) );
  4101. $avatar [$key] ['2'] = $uinfo ['avatar'];
  4102. }
  4103. $verify->staff = json_encode ( $avatar );
  4104. $verify->update ( array (
  4105. 'where' => 'vid=' . $vid
  4106. ) );
  4107. }
  4108. return "/adminverify";
  4109. }
  4110. function adminmyinfo() {
  4111. $data ['memu'] = "adminmyinfo";
  4112. $data ['staff'] = $this->staff;
  4113. $birArray = explode ( '-', $this->staff [0] ['birthday'] );
  4114. $data ['year'] = $birArray [0];
  4115. $year = date ( 'Y' );
  4116. $yearHtml = "";
  4117. for(; $year >= 1900; $year --) {
  4118. $yearHtml .= '<option ';
  4119. if ($data ['year'] == $year)
  4120. $yearHtml .= 'selected';
  4121. $yearHtml .= ' value="' . $year . '">' . $year . '</option>';
  4122. }
  4123. $data ['yearHtml'] = $yearHtml;
  4124. $data ['month'] = 01;
  4125. $data ['day'] = 01;
  4126. if (isset ( $birArray [1] )) {
  4127. $data ['month'] = $birArray [1];
  4128. $data ['day'] = $birArray [2];
  4129. }
  4130. $data ['msg'] = urldecode ( $this->params ['msg'] );
  4131. $this->render ( "/admin/admin_myinfo", $data );
  4132. }
  4133. function updateMyinfo() {
  4134. $telephone = $this->get_args ( 'telephone' ) ? $this->get_args ( 'telephone' ) : 0;
  4135. $phone = $this->get_args ( 'phone' ) ? $this->get_args ( 'phone' ) : 0;
  4136. $email = $this->get_args('email') ? $this->get_args('email') : "";
  4137. $qq = is_numeric ( $this->get_args ( 'qq' ) ) ? $_POST ['qq'] : 0;
  4138. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  4139. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  4140. $day = $this->get_args ( 'day' ) ? $this->get_args ( 'day' ) : "";
  4141. $position = $this->get_args ( 'position' ) ? $this->get_args ( 'position' ) : "";
  4142. $gender = $this->get_args ( 'gender' ) ? $this->get_args ( 'gender' ) : "男";
  4143. $oldpassword = $this->get_args ( 'oldpassword' ) ? $this->get_args ( 'oldpassword' ) : "";
  4144. $newpassword = $this->get_args ( 'newpassword' ) ? $this->get_args ( 'newpassword' ) : "";
  4145. $rnewpassword = $this->get_args ( 'rnewpassword' ) ?$this->get_args ( 'rnewpassword' ) : "";
  4146. Doo::loadModel ( 'staff' );
  4147. $staff = new staff ();
  4148. Doo::loadModel ( 'staffDynamic' );
  4149. $staffDynamic = new staffDynamic ();
  4150. $staff->sid = $this->staff [0] ['sid'];
  4151. $content = "";
  4152. $ext = "更新了他的";
  4153. if ($telephone != 0 && $this->staff [0] ['telephone'] != $telephone) {
  4154. $staff->telephone = $telephone;
  4155. $content .= "<b>手机</b>&nbsp;";
  4156. }
  4157. if ($phone != 0 && $this->staff [0] ['phone'] != $phone) {
  4158. $staff->phone = $phone;
  4159. $content .= "<b>电话</b>&nbsp;";
  4160. }
  4161. if ($qq != 0 && $this->staff [0] ['qq'] != $qq) {
  4162. $staff->qq = $qq;
  4163. $content .= "<b>QQ</b>&nbsp;";
  4164. }
  4165. if ($year != 2014) {
  4166. $staff->birthday = $year . "-" . $month . "-" . $day;
  4167. $content .= "<b>生日</b>&nbsp;";
  4168. }
  4169. if ($email != "" && filter_var ( $email, FILTER_VALIDATE_EMAIL ) && $this->staff [0] ['email'] != $email) {
  4170. $staff->email = $email;
  4171. $content .= "<b>邮箱</b>&nbsp;";
  4172. }
  4173. if (! empty ( $position )) {
  4174. $staff->position = $position;
  4175. $content .= "<b>职位</b>&nbsp;";
  4176. }
  4177. $staff->gender = $gender;
  4178. $msg = "更新成功";
  4179. if ($this->staff [0] ['passwork'] == md5 ( $oldpassword )) {
  4180. if ($newpassword == $rnewpassword && (! empty ( $newpassword )))
  4181. $staff->passwork = md5 ( $newpassword );
  4182. else
  4183. $msg = "密码不一致";
  4184. } else {
  4185. if ($oldpassword != "")
  4186. $msg = "密码错误";
  4187. }
  4188. if (! empty ( $content )) {
  4189. $staffDynamic->content = $ext . $content;
  4190. $staffDynamic->cid = $this->staff [0] ['cid'];
  4191. $staffDynamic->category = $this->staff [0] ['category'];
  4192. $staffDynamic->time = time ();
  4193. $staffDynamic->sid = $this->staff [0] ['sid'];
  4194. $staffDynamic->staff = $this->staff [0] ['username'];
  4195. $staffDynamic->insert ();
  4196. }
  4197. $staff->update ( array (
  4198. 'where' => ' sid=' . $this->staff [0] ['sid']
  4199. ) );
  4200. return "/adminmyinfo/" . $msg;
  4201. }
  4202. function admincontacts() {
  4203. $data ['memu'] = "admincontacts";
  4204. $data ['staff'] = $this->staff;
  4205. Doo::loadModel ( 'L_category' );
  4206. Doo::loadModel ( 'staff' );
  4207. $staff = new staff ();
  4208. $L_category = new L_category ();
  4209. $this->render ( "/admin/admin_addContacts", $data );
  4210. }
  4211. /**
  4212. * 微信通知设置
  4213. */
  4214. function notificationConf(){
  4215. Doo::loadModel ( "notificationConf" );
  4216. $notificationConf = new notificationConf ();
  4217. $detail=$notificationConf->getNotificationConfBySid($this->staff[0]['sid']);
  4218. $rule=json_decode($detail['conf'],true);
  4219. $data ['rule'] = $rule;
  4220. $data ['memu'] = "notificationConf";
  4221. $data ['staff'] = $this->staff;
  4222. $this->render ( "/admin/invoiceNotificationConf", $data );
  4223. }
  4224. function ajaxSetNotificationConf(){
  4225. $notificationType=$this->get_args('notificationType')?$this->get_args('notificationType'):"";
  4226. $notificationValue=$this->get_args('notificationValue')?$this->get_args('notificationValue'):'';
  4227. if (!empty($notificationType)&&!empty($notificationValue)&&!empty($this->staff[0]['sid'])){
  4228. Doo::loadModel("notificationConf");
  4229. $notificationConf=new notificationConf();
  4230. $detail=$notificationConf->getNotificationConfBySid($this->staff [0] ['sid']);
  4231. if (empty($detail)){
  4232. $rule=array($notificationType=>$notificationValue);
  4233. $rule=json_encode($rule);
  4234. $item=array(
  4235. 'sid'=>$this->staff[0]['sid'],
  4236. 'conf'=>$rule
  4237. );
  4238. $notificationConf->addNotification($item);
  4239. }else{
  4240. $rule=json_decode($detail['conf'],true);
  4241. $rule[$notificationType]=$notificationValue;
  4242. $rule=json_encode($rule);
  4243. $item=array(
  4244. 'nid'=>$detail['nid'],
  4245. 'conf'=>$rule
  4246. );
  4247. $notificationConf->setNotificationByCondition($item);
  4248. }
  4249. echo json_encode ( array (
  4250. 'status' => 1,
  4251. 'msgType'=>$notificationType,
  4252. 'msg' => ''
  4253. ) );
  4254. die;
  4255. }
  4256. echo json_encode ( array (
  4257. 'status' => 2,
  4258. 'msgType'=>$notificationType,
  4259. 'msg' => 'illegal request'
  4260. ) );
  4261. die;
  4262. }
  4263. function eMailTask() {
  4264. Doo::loadModel ( 'tag' );
  4265. $tag = new tag ();
  4266. Doo::loadModel ( 'district' );
  4267. $district = new district ();
  4268. $tagList = $tag->getAllBySid ( $this->staff [0] ['sid'] );
  4269. $districtList = $district->get_lv ( 1 );
  4270. $data ['tagList'] = $tagList;
  4271. $data ['districtList'] = $districtList;
  4272. $data ['memu'] = "eMailTask";
  4273. $data ['staff'] = $this->staff;
  4274. $data ['mailMemu'] = 'eMailTask';
  4275. $data ['nature'] = $this->nature;
  4276. $this->render ( "/mail_create", $data );
  4277. }
  4278. function eMialCenter() {
  4279. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  4280. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : 0;
  4281. Doo::loadModel ( 'eMailList' );
  4282. $eMailList = new eMailList ();
  4283. Doo::loadModel ( 'tag' );
  4284. $tag = new tag ();
  4285. Doo::loadModel ( 'staff' );
  4286. $staff = new staff ();
  4287. $dateCondition = "status!=2 and Year(date) =" . $year;
  4288. if (! empty ( $month ))
  4289. $dateCondition = "Year(date) =" . $year . " and Month(date) = " . $month;
  4290. $mailList = $eMailList->find ( array (
  4291. 'where' => $dateCondition,
  4292. 'asc' => 'status',
  4293. 'desc' => 'elid',
  4294. 'asArray' => true
  4295. ) );
  4296. foreach ( $mailList as $key => $value ) {
  4297. $mailList [$key] ['clientName2'] = $mailList [$key] ['clientName3'] = array ();
  4298. $mailList [$key] ['clientName'] = json_decode ( gzuncompress ( base64_decode ( $value ['clientName'] ) ), true );
  4299. if (! empty ( $value ['clientName2'] ))
  4300. $mailList [$key] ['clientName2'] = json_decode ( gzuncompress ( base64_decode ( $value ['clientName2'] ) ), true );
  4301. if (! empty ( $value ['clientName3'] ))
  4302. $mailList [$key] ['clientName3'] = json_decode ( gzuncompress ( base64_decode ( $value ['clientName3'] ) ), true );
  4303. $mailList [$key] ['illegalEmail'] = json_decode ( $value ['illegalEmail'], true );
  4304. $mailList [$key] ['sendEmail'] = json_decode ( $value ['sendEmail'], true );
  4305. $mailList [$key] ['clientCount'] = count ( $mailList [$key] ['clientName'] ) + count ( $mailList [$key] ['clientName2'] ) + count ( $mailList [$key] ['clientName3'] );
  4306. $mailList [$key] ['tag'] = array ();
  4307. $kks = $staff->getOne ( array (
  4308. 'where' => 'username like "' . $value ['staffName'] . '"',
  4309. 'asArray' => true
  4310. ) );
  4311. $mailList [$key] ['category'] = $kks ['category'];
  4312. if (! empty ( $value ['tag'] ))
  4313. $mailList [$key] ['tag'] = $tag->find ( array (
  4314. 'where' => 'tid in ( ' . $value ['tag'] . ') ',
  4315. 'asArray' => true
  4316. ) );
  4317. }
  4318. $dateHtml = "";
  4319. $now = date ( "Y" );
  4320. for($YEARD = 2014; $YEARD <= 2050; $YEARD ++) {
  4321. if ($YEARD <= $now) {
  4322. $dateHtml .= '<option ';
  4323. if ($year == $YEARD)
  4324. $dateHtml .= ' selected ';
  4325. $dateHtml .= ' value="' . $YEARD . '">' . $YEARD . '</option>';
  4326. }
  4327. }
  4328. $monthHtml = '<option value="0">所有月份</option>';
  4329. for($i = 1; $i <= 12; $i ++) {
  4330. $monthHtml .= '<option ';
  4331. if ($i == $month)
  4332. $monthHtml .= ' selected ';
  4333. $monthHtml .= ' value="' . $i . '">' . $i . '</option>';
  4334. }
  4335. $data ['monthHtml'] = $monthHtml;
  4336. $data ['dateHtml'] = $dateHtml;
  4337. $data ['mailList'] = $mailList;
  4338. $data ['memu'] = "eMailTask";
  4339. $data ['staff'] = $this->staff;
  4340. $data ['mailMemu'] = 'eMialCenter';
  4341. $data ['nature'] = $this->nature;
  4342. $this->render ( "/mailCenter", $data );
  4343. }
  4344. function authMail() {
  4345. $elid = isset ( $this->params ['elid'] ) ? $this->params ['elid'] : 0;
  4346. if (! empty ( $elid )) {
  4347. Doo::loadModel ( 'eMailList' );
  4348. $eMailList = new eMailList ();
  4349. $eMailList->examine = 2;
  4350. $eMailList->mark = $this->staff [0] ['username'] . "已同意";
  4351. $eMailList->update ( array (
  4352. 'where' => 'elid=' . $elid,
  4353. 'asArray' => true
  4354. ) );
  4355. }
  4356. return '/eMialCenter';
  4357. }
  4358. function editMailView() {
  4359. $elid = isset ( $this->params ['elid'] ) ? $this->params ['elid'] : 0;
  4360. Doo::loadModel ( 'tag' );
  4361. $tag = new tag ();
  4362. Doo::loadModel ( 'district' );
  4363. $district = new district ();
  4364. Doo::loadModel ( 'eMailList' );
  4365. $eMList = new eMailList ();
  4366. $mail = $eMList->getOne ( array (
  4367. 'where' => 'elid =' . $elid . '',
  4368. 'asArray' => true
  4369. ) );
  4370. if (empty ( $mail ))
  4371. return "/eMailList";
  4372. $mail ['tagList'] = explode ( ",", $mail ['tag'] );
  4373. $tagList = $tag->getAllBySid ( $this->staff [0] ['sid'] );
  4374. $districtList = $district->get_lv ( 1 );
  4375. $tagHtml = '';
  4376. foreach ( $tagList as $key => $value ) {
  4377. $tagHtml .= '<label><span data-original-title="' . $value ['name'] . '" data-toggle="ctooltip" data-placement="right" class="contactsTag tagCol-0' . $value ['colorid'] . '">
  4378. <input type="checkbox" name="tagId[]"';
  4379. foreach ( $mail ['tagList'] as $k => $v ) {
  4380. if ($value ['tid'] == $v) {
  4381. $tagHtml .= ' checked ';
  4382. break;
  4383. }
  4384. }
  4385. $tagHtml .= ' value="' . $value ['tid'] . '"></span></label>';
  4386. }
  4387. $districtHtml = '';
  4388. foreach ( $districtList as $key => $value ) {
  4389. $districtHtml .= '<option value="' . $value ['id'] . '"';
  4390. if ($value ['id'] == $mail ['districtId'])
  4391. $districtHtml .= 'selected';
  4392. $districtHtml .= '>' . $value ['name'] . '</option>';
  4393. }
  4394. $natureHtml = '';
  4395. $natList = explode ( ",", $mail ['nature'] );
  4396. foreach ( $this->nature as $key => $value ) {
  4397. $natureHtml .= '<label><input type="checkbox" name="nature[]" ';
  4398. foreach ( $natList as $k => $v ) {
  4399. if ($value == $v) {
  4400. $natureHtml .= ' checked ';
  4401. break;
  4402. }
  4403. }
  4404. $natureHtml .= 'value="' . $value . '">' . $value . '</label>';
  4405. }
  4406. $data ['natureHtml'] = $natureHtml;
  4407. $data ['districtHtml'] = $districtHtml;
  4408. $data ['tagHtml'] = $tagHtml;
  4409. $data ['mail'] = $mail;
  4410. $data ['tagList'] = $tagList;
  4411. $data ['districtList'] = $districtList;
  4412. $data ['memu'] = "eMailTask";
  4413. $data ['staff'] = $this->staff;
  4414. $data ['mailMemu'] = 'eMailList';
  4415. $data ['nature'] = $this->nature;
  4416. $this->render ( "/mailEdit", $data );
  4417. }
  4418. function editEmail() {
  4419. $title = $this->get_args ( 'title' ) ? $this->get_args ( 'title' ) : "";
  4420. $skin = $this->get_args ( 'skin' ) ? $this->get_args ( 'skin' ) : "";
  4421. $content = isset ( $_POST ['content'] ) ? $_POST ['content'] : "";
  4422. $tagId = $this->get_args ( 'tagId' ) ? $this->get_args ( 'tagId' ) : array ();
  4423. $nature = $this->get_args ( 'nature' ) ? $this->get_args ( 'nature' ) : array ();
  4424. $natureNULL = $this->get_args ( 'natureNULL' ) ? $this->get_args ( 'natureNULL' ) : "";
  4425. $did = $this->get_args ( 'did' ) ? $this->get_args ( 'did' ) : "";
  4426. $stype = $this->get_args ( 'stype' ) ? $this->get_args ( 'stype' ) : "";
  4427. $elid = $this->get_args ( 'elid' ) ? $this->get_args ( 'elid' ) : "";
  4428. if (! empty ( $title ) && ! empty ( $elid ) && (! empty ( $tagId ) || ! empty ( $did ))) {
  4429. Doo::loadModel ( 'eMailList' );
  4430. $eMailList = new eMailList ();
  4431. $etid = $eMailList->getOne ( array (
  4432. 'select' => 'etid,annexName,annex',
  4433. 'where' => 'elid=' . $elid,
  4434. 'asArray' => true
  4435. ) );
  4436. Doo::loadModel ( 'eMailTemplate' );
  4437. $eMailTemplate = new eMailTemplate ();
  4438. Doo::loadModel ( 'eMailJournal' );
  4439. $eMailJournal = new eMailJournal ();
  4440. if ($natureNULL != 'NULL') {
  4441. if (empty ( $tagId ) && ! empty ( $did ) && empty ( $nature ))
  4442. die ( '请选择性质' );
  4443. }
  4444. // annex
  4445. $annexPath = "";
  4446. $annexEXT = $this->_GetFileEXT ( $_FILES ["annex"] ["name"] );
  4447. $annexName = "";
  4448. if (isset ( $_FILES ['annex'] ['name'] )) {
  4449. if ((($annexEXT == "doc") || ($annexEXT == "xls") || ($annexEXT == "pdf") || ($annexEXT == "ppt") || ($annexEXT == "txt") || ($annexEXT == "smr") || ($annexEXT == "spu") || ($annexEXT == "zip") || ($annexEXT == "rar") || ($annexEXT == "jpg") || ($annexEXT == "png")) && ($_FILES ["annex"] ["size"] < 10485760)) {
  4450. $path = DOO::conf ()->SITE_PATH . "upload/emailAnnex/";
  4451. if (! file_exists ( $path . $_FILES ["annex"] ["name"] )) {
  4452. $fileName = time () . "." . $annexEXT;
  4453. $annexName = $_FILES ['annex'] ['name'];
  4454. $annexPath = $path . $fileName;
  4455. move_uploaded_file ( $_FILES ["annex"] ["tmp_name"], $annexPath );
  4456. $annexPath = $this->webPath . $fileName;
  4457. }
  4458. }
  4459. }
  4460. if (! empty ( $annexPath )) {
  4461. $annexHtml = '<table style="width:100%;margin:10px 0">
  4462. <thead>
  4463. <tr>
  4464. <th align="left" colspan="2" style="background-color:ff6501;color:#fff;font-size:16px;padding:5px">下载附件:</th>
  4465. </tr>
  4466. </thead>
  4467. <tbody>
  4468. <tr>
  4469. <td style="padding:5px"><a href="' . $annexPath . '" target="_blank" style="font-size:16px">' . $annexName . '</a></td>
  4470. <td>&nbsp;</td>
  4471. </tr>
  4472. </tbody>
  4473. </table>';
  4474. } elseif (! empty ( $etid ['annexName'] ) && empty ( $annexPath ))
  4475. $annexHtml = $etid ['annex'];
  4476. $smartcostMail = 'smartcost_mail_1';
  4477. $info = "";
  4478. // html template
  4479. if ($skin == 1) {
  4480. $html = '<div><table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0">
  4481. <tbody><tr><td align="center"><table style="margin:20px;background-color:#fff;box-shadow:0px 1px 6px rgba(0, 0, 0, 0.3);width:60%;" cellpadding="0" cellspacing="0" align="center">
  4482. <tbody><tr>
  4483. <td style="background-color:#ff6501;padding:20px 0 25px;" align="center">
  4484. <span style="vertical-align:bottom;font-size:20px;color:#fff;">' . $title . '</span>
  4485. </td></tr><tr><td>
  4486. <table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;border-top:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  4487. <tbody><tr><td style="padding: 0 40px;" align="left">
  4488. <p style="margin-top:40px;margin-bottom:10px;color:#383838;font-size:16px;line-height:32px;"><b>CLIENTNAME</b>,您好</p>
  4489. </td></tr><tr><td style="padding: 0 40px;" align="left">
  4490. <p style="margin-top:0px;margin-bottom:10px;color:#383838;font-size:16px;line-height:32px;">我是纵横公路造价软件 <b>' . $this->staff [0] ['username'] . '</b>:</p>
  4491. <p style="margin-top:0px;margin-bottom:20px;color:#383838;font-size:16px;line-height:32px;">
  4492. ' . $content . '</p>
  4493. </td></tr>
  4494. <tr><td align="left" style="padding: 0 40px;background:#fff">
  4495. ' . $annexHtml . '
  4496. </td></tr>
  4497. <tr> <td style="padding: 20px 40px;border-top:1px dashed #ddd" align="left">
  4498. <p style="margin-bottom:10px;color:#383838;font-size:16px;line-height:22px;border-left:2px solid #FF6501;padding-left:5px">
  4499. 纵横公路造价软件' . $this->staff [0] ['category'] . '办事处</p>
  4500. <table>
  4501. <tr><th align="right">电话:</th><td>' . $this->staff [0] ['phone'] . '</td></tr>
  4502. <tr><th align="right">联系人:</th><td>' . $this->staff [0] ['username'] . '</td></tr>
  4503. <tr><th align="right">手机:</th><td>' . $this->staff [0] ['telephone'] . '</td></tr>
  4504. <tr><th align="right">QQ:</th><td>' . $this->staff [0] ['qq'] . '</td></tr>
  4505. <tr><th align="right">邮箱:</th><td>' . $this->staff [0] ['email'] . '</td></tr>
  4506. </table></td></tr></tbody></table></td></tr><tr>
  4507. <td style="padding: 0 40px;background-color:#383838;"><p style="color:#fff;padding:10px 0;text-align:center;margin:0">珠海纵横创新软件有限公司 <a href="http://www.smartcost.com.cn" style="color:#fff;text-decoration: underline;">smartcost.com.cn</a></p></td>
  4508. </tr></tbody></table></td></tr></tbody></table></div>';
  4509. $info = '<table><tr><th align="right">电话:</th><td>' . $this->staff [0] ['phone'] . '</td></tr>
  4510. <tr><th align="right">联系人:</th><td>' . $this->staff [0] ['username'] . '</td></tr>
  4511. <tr><th align="right">手机:</th><td>' . $this->staff [0] ['telephone'] . '</td></tr>
  4512. <tr><th align="right">QQ:</th><td>' . $this->staff [0] ['qq'] . '</td></tr>
  4513. <tr><th align="right">邮箱:</th><td>' . $this->staff [0] ['email'] . '</td></tr></table>';
  4514. } elseif ($skin == 2) {
  4515. $smartcostMail = 'smartcost_mail_2';
  4516. $html = '<table cellspacing="0" cellpadding="0" style="background-color:#e4e4e4; width:100%;"><tbody><tr><td>
  4517. <table align="center" cellspacing="0" cellpadding="0" style="background-color:#f8f8f8; width:640px;margin-bottom:20px">
  4518. <tbody><tr><td align="left" style="background-color:#e4e4e4;"><p style="margin-top:10px;margin-bottom:10px;color:#999;font-size:16px;line-height:32px;">
  4519. <b><span name="titleHtml">' . $title . '</span></b></p></td>
  4520. </tr><tr><td><table align="center" cellspacing="0" cellpadding="0" style="border:1px solid #ddd;"><tbody><tr>
  4521. <td align="center" style="background-color:#EEF2F5;padding:20px 0 "><a style="text-decoration:none;" href="http://www.teambition.com/" target="_blank"><img width="291px" height="46" src="http://zonghengvideo.qiniudn.com/maillogo1.png"></a></td>
  4522. </tr><tr><td align="center" style="background-color:#fff;"><img width="640" height="191" src="http://zonghengvideo.qiniudn.com/hero.jpg"></td>
  4523. </tr><tr><td align="left" style="background-color:#fff;padding:40px;border-bottom:1px solid #ddd;">
  4524. <p style="margin-top:0px;margin-bottom:10px;color:#383838;font-size:16px;line-height:32px;"><b>CLIENTNAME</b>,您好</p>
  4525. <p style="margin-top:0px;margin-bottom:10px;color:#383838;font-size:16px;line-height:32px;">我是纵横公路造价软件 <b>' . $this->staff [0] ['username'] . '</b>:</p>
  4526. <p name="contentHtml" style="margin-top:0px;margin-bottom:15px;color:#383838;font-size:16px;line-height:32px;">' . $content . '</p></td>
  4527. </tr>
  4528. <tr><td align="left" style="padding: 0 40px;background:#fff">
  4529. ' . $annexHtml . '
  4530. </td></tr>
  4531. <tr><td style="padding: 10px 0;background:#EEF2F5"><table><tbody><tr>
  4532. <td style="font-size:14pxl;color:#333;padding:0 20px"><b>纵横公路造价软件' . $this->staff [0] ['category'] . '办事处</b><br>' . $this->staff [0] ['username'] . '</td>
  4533. <td><table><tbody><tr style="font-size:12px;color:#666">
  4534. <th align="right">电话:</th><td style="padding:0 20px 0 0">' . $this->staff [0] ['phone'] . '</td>
  4535. <th align="right">手机:</th><td>' . $this->staff [0] ['telephone'] . '</td></tr><tr style="font-size:12px;color:#666">
  4536. <th align="right">QQ:</th><td>' . $this->staff [0] ['qq'] . '</td>
  4537. <th align="right">邮箱: </th><td>' . $this->staff [0] ['email'] . '</td>
  4538. </tr></tbody></table></td></tr></tbody></table></td></tr></tbody></table></td></tr><tr>
  4539. <td style="padding: 0 40px;background-color:#383838;"><p style="color:#fff;padding:10px 0;text-align:center;margin:0;font-size:12px">珠海纵横创新软件有限公司 <a href="http://www.smartcost.com.cn" style="color:#fff;text-decoration:underline;">smartcost.com.cn</a></p></td>
  4540. </tr></tbody></table></td></tr></tbody> </table>';
  4541. $info = '<table><tbody><tr style="font-size:12px;color:#666">
  4542. <th align="right">电话:</th><td style="padding:0 20px 0 0">' . $this->staff [0] ['phone'] . '</td>
  4543. <th align="right">手机:</th><td>' . $this->staff [0] ['telephone'] . '</td></tr><tr style="font-size:12px;color:#666">
  4544. <th align="right">QQ:</th><td>' . $this->staff [0] ['qq'] . '</td>
  4545. <th align="right">邮箱: </th><td>' . $this->staff [0] ['email'] . '</td>
  4546. </tr></tbody></table>';
  4547. } else {
  4548. $smartcostMail = 'smartcost_mail_3';
  4549. $html = '<table cellspacing="0" cellpadding="0" style="background-color:#ECF0E1; width:100%">
  4550. <tbody>
  4551. <tr>
  4552. <td>
  4553. <table align="center" cellspacing="0" cellpadding="0" style="width:698px;margin-bottom:30px;margin-top:30px;">
  4554. <tbody>
  4555. <tr>
  4556. <td>
  4557. <table align="center" cellspacing="0" cellpadding="0" style="border:1px solid #ccc;width:100%;border-top:none">
  4558. <tbody>
  4559. <tr>
  4560. <td align="right" style="background:#fff url(http://zonghengvideo.qiniudn.com/mail3-top-bg.png) no-repeat top center;padding:30px 20px 20px 20px;border-bottom:1px solid #E9EBE2;">
  4561. <div style="position:relative;text-align:right">
  4562. <b style="font-size:24px;color:#8A9F98;z-index:999"><span name="titleHtml">' . $title . '</span></b>
  4563. <div style="width:80px;height:80px;position:absolute;top:0;left:0"><img src="http://zonghengvideo.qiniudn.com/zonghenglogo.png"></div>
  4564. </div>
  4565. </td>
  4566. </tr>
  4567. <tr>
  4568. <td align="left" style="background-color:#fff;padding:40px;border-bottom:1px solid #ddd;">
  4569. <p style="margin-top:0px;margin-bottom:10px;color:#666;font-size:16px;line-height:32px;"><b>CLIENTNAME</b>,您好</p>
  4570. <p style="margin-top:0px;margin-bottom:10px;color:#666;font-size:16px;line-height:32px;">我是纵横公路造价软件 <b>' . $this->staff [0] ['username'] . '</b>:</p>
  4571. <p name="contentHtml" style="margin-top:0px;margin-bottom:15px;color:#666;font-size:16px;line-height:32px;">' . $content . '</p></td>
  4572. </tr>
  4573. <tr><td align="left" style="padding: 0 40px;background:#fff">
  4574. ' . $annexHtml . '
  4575. </td></tr>
  4576. <tr>
  4577. <td style="padding: 10px 0 0;background:#F6F6F6;">
  4578. <table>
  4579. <tbody><tr>
  4580. <td style="font-size:14pxl;color:#666;padding:0 20px"><b>纵横公路造价软件' . $this->staff [0] ['category'] . '办事处</b><br>' . $this->staff [0] ['username'] . '<br><a href="http://www.smartcost.com.cn" style="color:#666;font-size:12px;text-decoration:underline;">smartcost.com.cn</a></td>
  4581. <td>
  4582. <table style="width:100%">
  4583. <tbody><tr style="font-size:12px;color:#496781">
  4584. <th align="right">电话:</th><td>' . $this->staff [0] ['phone'] . '</td>
  4585. <th align="right">手机:</th><td>' . $this->staff [0] ['telephone'] . '</td>
  4586. </tr>
  4587. <tr style="font-size:12px;color:#496781">
  4588. <th align="right">QQ:</th><td>' . $this->staff [0] ['qq'] . '</td>
  4589. <th align="right">邮箱: </th><td>' . $this->staff [0] ['email'] . '</td>
  4590. </tr>
  4591. </tbody></table>
  4592. </td>
  4593. </tr>
  4594. </tbody></table>
  4595. </td>
  4596. </tr>
  4597. <tr>
  4598. <td style="background:#F6F6F6 url(http://zonghengvideo.qiniudn.com/mail3-bottom-bg.png) no-repeat bottom center;"><p style="color:#fff;padding:0 0 20px;text-align:center;margin:0;font-size:12px"></p></td>
  4599. </tr>
  4600. </tbody>
  4601. </table></td>
  4602. </tr>
  4603. </tbody>
  4604. </table></td>
  4605. </tr>
  4606. </tbody>
  4607. </table>';
  4608. $info = '<table><tr style="font-size:12px;color:#496781"><th align="right">电话:</th><td>' . $this->staff [0] ['phone'] . '</td>
  4609. <th align="right">手机:</th><td>' . $this->staff [0] ['telephone'] . '</td></tr><tr style="font-size:12px;color:#496781">
  4610. <th align="right">QQ:</th><td>' . $this->staff [0] ['qq'] . '</td>
  4611. <th align="right">邮箱: </th><td>' . $this->staff [0] ['email'] . '</td></tr></table>
  4612. ';
  4613. }
  4614. Doo::loadModel ( 'tag_client' );
  4615. $tagClient = new tag_client ();
  4616. Doo::loadModel ( 'client' );
  4617. $client = new client ();
  4618. Doo::loadModel ( 'company' );
  4619. $company = new company ();
  4620. $eMailTemplate->title = $title;
  4621. $eMailTemplate->skin = $skin;
  4622. $eMailTemplate->content = $content;
  4623. if (! empty ( $tagId ))
  4624. $eMailTemplate->tag = implode ( ",", $tagId );
  4625. $eMailTemplate->staffId = $this->staff [0] ['sid'];
  4626. $eMailTemplate->staffName = $this->staff [0] ['username'];
  4627. $eMailTemplate->status = 0;
  4628. $eMailTemplate->html = $html;
  4629. if (! empty ( $annexPath )) {
  4630. $eMailTemplate->annex = $annexPath;
  4631. $eMailTemplate->annexName = $annexName;
  4632. }
  4633. $etid = $eMailTemplate->update ( array (
  4634. 'where' => 'etid=' . $etid ['etid']
  4635. ) );
  4636. // create email list
  4637. $tagCondition = "";
  4638. $tagArray = array ();
  4639. foreach ( $tagId as $value ) {
  4640. array_push ( $tagArray, " tag like '%" . $value . "%' " );
  4641. }
  4642. if (! empty ( $tagArray ))
  4643. $tagCondition = ' and (' . implode ( " or ", $tagArray ) . ')';
  4644. $clientList = $tagClient->find ( array (
  4645. 'select' => 'client',
  4646. 'where' => 'sid=' . $this->staff [0] ['sid'] . $tagCondition,
  4647. 'asArray' => true
  4648. ) );
  4649. $clientArray = array ();
  4650. foreach ( $clientList as $value ) {
  4651. array_push ( $clientArray, $value ['client'] );
  4652. }
  4653. $clientEmailList = array ();
  4654. if (! empty ( $clientArray ))
  4655. $clientEmailList = $client->find ( array (
  4656. 'select' => 'email,cid,nicename as clientname,companyname',
  4657. 'where' => 'cid in (' . implode ( ",", $clientArray ) . ')',
  4658. 'asArray' => true
  4659. ) );
  4660. //
  4661. if ($stype == 2) {
  4662. // 获取性质相关数据
  4663. $cidList = '';
  4664. if ($natureNULL == '') {
  4665. $nD = array ();
  4666. foreach ( $nature as $key => $value ) {
  4667. array_push ( $nD, ' nature like "' . $value . '"' );
  4668. // $nD=' nature like "'.$value.'"';
  4669. }
  4670. $nD = implode ( ' or ', $nD );
  4671. $companycid = $company->find ( array (
  4672. 'select' => 'cid',
  4673. 'where' => $nD,
  4674. 'asArray' => true
  4675. ) );
  4676. $cidList = array ();
  4677. foreach ( $companycid as $key => $value ) {
  4678. array_push ( $cidList, $value ['cid'] );
  4679. }
  4680. $cidList = implode ( ',', $cidList );
  4681. if (! empty ( $cidList ))
  4682. $cidList = ' and companyid in (' . $cidList . ')';
  4683. else
  4684. $cidList = '';
  4685. }
  4686. // 'select'=>'email,cid,nicename as clientname,companyname,district'
  4687. $clientEmailList = $client->find ( array (
  4688. 'select' => 'email,cid,nicename as clientname,companyname,district',
  4689. 'where' => 'district like "' . $did . ',%" ' . $cidList,
  4690. 'asArray' => true
  4691. ) );
  4692. }
  4693. // ;datediff(curdate(), 'date')>=10
  4694. $eMailJournal->delete ( array (
  4695. 'where' => "datediff(curdate(), date)>=7"
  4696. ) );
  4697. $eMailJournal->delete ( array (
  4698. 'where' => 'DATE_SUB(CURDATE(), INTERVAL 7 DAY) <= date(date)'
  4699. ) );
  4700. $checkMail = $eMailJournal->find ( array (
  4701. 'where' => 'DATE_SUB(CURDATE(), INTERVAL 7 DAY) <= date(date)',
  4702. ' groupby' => 'email',
  4703. 'asArray' => true
  4704. ) );
  4705. $emailNameList = $emailArray = $illegalEmail = $sendEmail = array ();
  4706. Doo::db ()->beginTransaction ();
  4707. foreach ( $clientEmailList as $value ) {
  4708. if (filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) {
  4709. if (! empty ( $checkMail )) {
  4710. $falg = true;
  4711. foreach ( $checkMail as $v ) {
  4712. if ($v ['email'] == $value ['email']) {
  4713. $Bdate = strtotime ( $v ['date'] ) + 7 * 24 * 3600;
  4714. if ($Bdate <= time ()) {
  4715. array_push ( $emailArray, $value ['email'] );
  4716. array_push ( $emailNameList, $value );
  4717. $eMailJournal->date = date ( "Y-m-d" );
  4718. $eMailJournal->update ( array (
  4719. 'where' => 'ejid=' . $v ['ejid']
  4720. ) );
  4721. } else {
  4722. array_push ( $sendEmail, $value );
  4723. }
  4724. $falg = false;
  4725. break;
  4726. }
  4727. }
  4728. if ($falg) {
  4729. array_push ( $emailArray, $value ['email'] );
  4730. array_push ( $emailNameList, $value );
  4731. $eMailJournal->clientId = $value ['cid'];
  4732. $eMailJournal->status = 1;
  4733. $eMailJournal->email = $value ['email'];
  4734. $eMailJournal->date = date ( "Y-m-d" );
  4735. $eMailJournal->insert ();
  4736. }
  4737. } else {
  4738. array_push ( $emailArray, $value ['email'] );
  4739. array_push ( $emailNameList, $value );
  4740. $eMailJournal->clientId = $value ['cid'];
  4741. $eMailJournal->status = 1;
  4742. $eMailJournal->email = $value ['email'];
  4743. $eMailJournal->date = date ( "Y-m-d" );
  4744. $eMailJournal->insert ();
  4745. }
  4746. } else {
  4747. array_push ( $illegalEmail, $value );
  4748. }
  4749. }
  4750. Doo::db ()->commit ();
  4751. // echo json_encode($illegalEmail);
  4752. // json_encode(array_slice($illegalEmail,0,100))
  4753. // $kk=gzcompress();
  4754. // $ll=gzuncompress($kk);
  4755. // ."</br>".strlen($kk)."</br>".strlen($ll);die;
  4756. $size = floor ( count ( $emailArray ) / 3 );
  4757. if (! empty ( $emailArray )) {
  4758. if (count ( $emailArray ) < 3) {
  4759. $list = array (
  4760. 0 => $emailArray,
  4761. 1 => array (),
  4762. 2 => array ()
  4763. );
  4764. } else
  4765. $list = array_chunk ( $emailArray, $size );
  4766. } else
  4767. $list = array (
  4768. 0 => array (),
  4769. 1 => array (),
  4770. 2 => array ()
  4771. );
  4772. $emailJson = array ();
  4773. foreach ( $list as $value ) {
  4774. $em = array ();
  4775. foreach ( $value as $v ) {
  4776. array_push ( $em, $v );
  4777. }
  4778. array_push ( $emailJson, $em );
  4779. }
  4780. $size = floor ( count ( $emailNameList ) / 3 );
  4781. if (! empty ( $emailNameList )) {
  4782. if (count ( $emailNameList ) < 3) {
  4783. $list = array (
  4784. 0 => $emailNameList,
  4785. 1 => array (),
  4786. 2 => array ()
  4787. );
  4788. } else
  4789. $list = array_chunk ( $emailNameList, $size );
  4790. } else
  4791. $list = array (
  4792. 0 => array (),
  4793. 1 => array (),
  4794. 2 => array ()
  4795. );
  4796. $emailNameJson = array ();
  4797. foreach ( $list as $value ) {
  4798. $em = array ();
  4799. foreach ( $value as $v ) {
  4800. array_push ( $em, $v );
  4801. }
  4802. array_push ( $emailNameJson, $em );
  4803. }
  4804. //
  4805. $eMailList->date = date ( "Y-m-d" );
  4806. $eMailList->clientEmail = base64_encode ( gzcompress ( json_encode ( $emailJson [0] ) ) );
  4807. $eMailList->clientEmail2 = base64_encode ( gzcompress ( json_encode ( $emailJson [1] ) ) );
  4808. $eMailList->clientEmail3 = base64_encode ( gzcompress ( json_encode ( $emailJson [2] ) ) );
  4809. $eMailList->clientName = base64_encode ( gzcompress ( json_encode ( $emailNameJson [0] ) ) );
  4810. $eMailList->clientName2 = base64_encode ( gzcompress ( json_encode ( $emailNameJson [1] ) ) );
  4811. $eMailList->clientName3 = base64_encode ( gzcompress ( json_encode ( $emailNameJson [2] ) ) );
  4812. $eMailList->illegalEmail = json_encode ( array_slice ( $illegalEmail, 0, 100 ) ); // json_encode($illegalEmail);
  4813. $eMailList->sendEmail = json_encode ( $sendEmail );
  4814. $eMailList->templateName = $smartcostMail;
  4815. $eMailList->eTitle = $title;
  4816. $eMailList->html = $html;
  4817. $eMailList->content = $content;
  4818. $eMailList->info = $info;
  4819. if (! empty ( $annexName )) {
  4820. $eMailList->annex = $annexHtml;
  4821. $eMailList->annexName = $annexName;
  4822. }
  4823. if ($stype == 1) {
  4824. $eMailList->tag = implode ( ",", $tagId );
  4825. $eMailList->districtId = "";
  4826. $eMailList->nature = "";
  4827. }
  4828. if ($stype == 2) {
  4829. $eMailList->districtId = $did;
  4830. $eMailList->nature = implode ( ",", $nature );
  4831. $eMailList->tag = "";
  4832. }
  4833. $eMailList->update ( array (
  4834. 'where' => 'elid=' . $elid
  4835. ) );
  4836. return "/eMailList";
  4837. }
  4838. return "/eMailTask";
  4839. }
  4840. function createEmail() {
  4841. // include Doo::conf()->BASE_PATH.'diagnostic/debug.php';
  4842. $title = $this->get_args ( 'title' ) ? $this->get_args ( 'title' ) : "";
  4843. $skin = $this->get_args ( 'skin' ) ? $this->get_args ( 'skin' ) : "";
  4844. $content = isset ( $_POST ['content'] ) ? $_POST ['content'] : "";
  4845. $tagId = $this->get_args ( 'tagId' ) ? $this->get_args ( 'tagId' ) : array ();
  4846. $nature = $this->get_args ( 'nature' ) ? $this->get_args ( 'nature' ) : array ();
  4847. $natureNULL = $this->get_args ( 'natureNULL' ) ? $this->get_args ( 'natureNULL' ) : "";
  4848. $did = $this->get_args ( 'did' ) ? $this->get_args ( 'did' ) : "";
  4849. $stype = $this->get_args ( 'stype' ) ? $this->get_args ( 'stype' ) : "";
  4850. if (! empty ( $title ) && (! empty ( $tagId ) || ! empty ( $did ))) {
  4851. Doo::loadModel ( 'eMailTemplate' );
  4852. $eMailTemplate = new eMailTemplate ();
  4853. Doo::loadModel ( 'eMailJournal' );
  4854. $eMailJournal = new eMailJournal ();
  4855. if ($natureNULL != 'NULL') {
  4856. if (empty ( $tagId ) && ! empty ( $did ) && empty ( $nature )) {
  4857. header ( 'Content-Type:text/html;charset=utf-8' );
  4858. die ( '请选择性质' );
  4859. }
  4860. }
  4861. // annex
  4862. $annexPath = "";
  4863. $annexEXT = $this->_GetFileEXT ( $_FILES ["annex"] ["name"] );
  4864. $annexName = "";
  4865. if (isset ( $_FILES ['annex'] ['name'] )) {
  4866. if ((($annexEXT == "doc") || ($annexEXT == "xls") || ($annexEXT == "pdf") || ($annexEXT == "ppt") || ($annexEXT == "txt") || ($annexEXT == "smr") || ($annexEXT == "spu") || ($annexEXT == "zip") || ($annexEXT == "rar") || ($annexEXT == "jpg") || ($annexEXT == "png")) && ($_FILES ["annex"] ["size"] < 10485760)) {
  4867. $path = DOO::conf ()->SITE_PATH . "upload/emailAnnex/";
  4868. if (! file_exists ( $path . $_FILES ["annex"] ["name"] )) {
  4869. $fileName = time () . "." . $annexEXT;
  4870. $annexName = $_FILES ['annex'] ['name'];
  4871. $annexPath = $path . $fileName;
  4872. move_uploaded_file ( $_FILES ["annex"] ["tmp_name"], $annexPath );
  4873. $annexPath = $this->webPath . $fileName;
  4874. }
  4875. }
  4876. }
  4877. $annexHtml = '<table style="width:100%;margin:10px 0">
  4878. <thead>
  4879. <tr>
  4880. <th align="left" colspan="2">下载附件:</th>
  4881. </tr>
  4882. </thead>
  4883. <tbody>
  4884. <tr>
  4885. <td><a href="' . $annexPath . '" target="_blank">' . $annexName . '</a></td>
  4886. <td>&nbsp;</td>
  4887. </tr>
  4888. </tbody>
  4889. </table>';
  4890. $smartcostMail = 'smartcost_mail_1';
  4891. $info = "";
  4892. // html template
  4893. if ($skin == 1) {
  4894. $html = '<div><table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0">
  4895. <tbody><tr><td align="center"><table style="margin:20px;background-color:#fff;box-shadow:0px 1px 6px rgba(0, 0, 0, 0.3);width:60%;" cellpadding="0" cellspacing="0" align="center">
  4896. <tbody><tr>
  4897. <td style="background-color:#ff6501;padding:20px 0 25px;" align="center">
  4898. <span style="vertical-align:bottom;font-size:20px;color:#fff;">' . $title . '</span>
  4899. </td></tr><tr><td>
  4900. <table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;border-top:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  4901. <tbody><tr><td style="padding: 0 40px;" align="left">
  4902. <p style="margin-top:40px;margin-bottom:10px;color:#383838;font-size:16px;line-height:32px;"><b>CLIENTNAME</b>,您好</p>
  4903. </td></tr><tr><td style="padding: 0 40px;" align="left">
  4904. <p style="margin-top:0px;margin-bottom:10px;color:#383838;font-size:16px;line-height:32px;">我是纵横公路造价软件 <b>' . $this->staff [0] ['username'] . '</b>:</p>
  4905. <p style="margin-top:0px;margin-bottom:20px;color:#383838;font-size:16px;line-height:32px;">
  4906. ' . $content . '</p>
  4907. </td></tr>
  4908. <tr><td align="left" style="padding: 0 40px;background:#fff">
  4909. ' . $annexHtml . '
  4910. </td></tr>
  4911. <tr> <td style="padding: 20px 40px;border-top:1px dashed #ddd" align="left">
  4912. <p style="margin-bottom:10px;color:#383838;font-size:16px;line-height:22px;border-left:2px solid #FF6501;padding-left:5px">
  4913. 纵横公路造价软件' . $this->staff [0] ['category'] . '办事处</p>
  4914. <table>
  4915. <tr><th align="right">电话:</th><td>' . $this->staff [0] ['phone'] . '</td></tr>
  4916. <tr><th align="right">联系人:</th><td>' . $this->staff [0] ['username'] . '</td></tr>
  4917. <tr><th align="right">手机:</th><td>' . $this->staff [0] ['telephone'] . '</td></tr>
  4918. <tr><th align="right">QQ:</th><td>' . $this->staff [0] ['qq'] . '</td></tr>
  4919. <tr><th align="right">邮箱:</th><td>' . $this->staff [0] ['email'] . '</td></tr>
  4920. </table></td></tr></tbody></table></td></tr><tr>
  4921. <td style="padding: 0 40px;background-color:#383838;"><p style="color:#fff;padding:10px 0;text-align:center;margin:0">珠海纵横创新软件有限公司 <a href="http://www.smartcost.com.cn" style="color:#fff;text-decoration: underline;">smartcost.com.cn</a></p></td>
  4922. </tr></tbody></table></td></tr></tbody></table></div>';
  4923. $info = '<table><tr><th align="right">电话:</th><td>' . $this->staff [0] ['phone'] . '</td></tr>
  4924. <tr><th align="right">联系人:</th><td>' . $this->staff [0] ['username'] . '</td></tr>
  4925. <tr><th align="right">手机:</th><td>' . $this->staff [0] ['telephone'] . '</td></tr>
  4926. <tr><th align="right">QQ:</th><td>' . $this->staff [0] ['qq'] . '</td></tr>
  4927. <tr><th align="right">邮箱:</th><td>' . $this->staff [0] ['email'] . '</td></tr></table>';
  4928. } elseif ($skin == 2) {
  4929. $smartcostMail = 'smartcost_mail_2';
  4930. $html = '<table cellspacing="0" cellpadding="0" style="background-color:#e4e4e4; width:100%;"><tbody><tr><td>
  4931. <table align="center" cellspacing="0" cellpadding="0" style="background-color:#f8f8f8; width:640px;margin-bottom:20px">
  4932. <tbody><tr><td align="left" style="background-color:#e4e4e4;"><p style="margin-top:10px;margin-bottom:10px;color:#999;font-size:16px;line-height:32px;">
  4933. <b><span name="titleHtml">' . $title . '</span></b></p></td>
  4934. </tr><tr><td><table align="center" cellspacing="0" cellpadding="0" style="border:1px solid #ddd;"><tbody><tr>
  4935. <td align="center" style="background-color:#EEF2F5;padding:20px 0 "><a style="text-decoration:none;" href="http://www.teambition.com/" target="_blank"><img width="291px" height="46" src="http://zonghengvideo.qiniudn.com/maillogo1.png"></a></td>
  4936. </tr><tr><td align="center" style="background-color:#fff;"><img width="640" height="191" src="http://zonghengvideo.qiniudn.com/hero.jpg"></td>
  4937. </tr><tr><td align="left" style="background-color:#fff;padding:40px;border-bottom:1px solid #ddd;">
  4938. <p style="margin-top:0px;margin-bottom:10px;color:#383838;font-size:16px;line-height:32px;"><b>CLIENTNAME</b>,您好</p>
  4939. <p style="margin-top:0px;margin-bottom:10px;color:#383838;font-size:16px;line-height:32px;">我是纵横公路造价软件 <b>' . $this->staff [0] ['username'] . '</b>:</p>
  4940. <p name="contentHtml" style="margin-top:0px;margin-bottom:15px;color:#383838;font-size:16px;line-height:32px;">' . $content . '</p></td>
  4941. </tr>
  4942. <tr><td align="left" style="padding: 0 40px;background:#fff">
  4943. ' . $annexHtml . '
  4944. </td></tr>
  4945. <tr><td style="padding: 10px 0;background:#EEF2F5"><table><tbody><tr>
  4946. <td style="font-size:14pxl;color:#333;padding:0 20px"><b>纵横公路造价软件' . $this->staff [0] ['category'] . '办事处</b><br>' . $this->staff [0] ['username'] . '</td>
  4947. <td><table><tbody><tr style="font-size:12px;color:#666">
  4948. <th align="right">电话:</th><td style="padding:0 20px 0 0">' . $this->staff [0] ['phone'] . '</td>
  4949. <th align="right">手机:</th><td>' . $this->staff [0] ['telephone'] . '</td></tr><tr style="font-size:12px;color:#666">
  4950. <th align="right">QQ:</th><td>' . $this->staff [0] ['qq'] . '</td>
  4951. <th align="right">邮箱: </th><td>' . $this->staff [0] ['email'] . '</td>
  4952. </tr></tbody></table></td></tr></tbody></table></td></tr></tbody></table></td></tr><tr>
  4953. <td style="padding: 0 40px;background-color:#383838;"><p style="color:#fff;padding:10px 0;text-align:center;margin:0;font-size:12px">珠海纵横创新软件有限公司 <a href="http://www.smartcost.com.cn" style="color:#fff;text-decoration:underline;">smartcost.com.cn</a></p></td>
  4954. </tr></tbody></table></td></tr></tbody> </table>';
  4955. $info = '<table><tbody><tr style="font-size:12px;color:#666">
  4956. <th align="right">电话:</th><td style="padding:0 20px 0 0">' . $this->staff [0] ['phone'] . '</td>
  4957. <th align="right">手机:</th><td>' . $this->staff [0] ['telephone'] . '</td></tr><tr style="font-size:12px;color:#666">
  4958. <th align="right">QQ:</th><td>' . $this->staff [0] ['qq'] . '</td>
  4959. <th align="right">邮箱: </th><td>' . $this->staff [0] ['email'] . '</td>
  4960. </tr></tbody></table>';
  4961. } else {
  4962. $smartcostMail = 'smartcost_mail_3';
  4963. $html = '<table cellspacing="0" cellpadding="0" style="background-color:#ECF0E1; width:100%">
  4964. <tbody>
  4965. <tr>
  4966. <td>
  4967. <table align="center" cellspacing="0" cellpadding="0" style="width:698px;margin-bottom:30px;margin-top:30px;">
  4968. <tbody>
  4969. <tr>
  4970. <td>
  4971. <table align="center" cellspacing="0" cellpadding="0" style="border:1px solid #ccc;width:100%;border-top:none">
  4972. <tbody>
  4973. <tr>
  4974. <td align="right" style="background:#fff url(http://zonghengvideo.qiniudn.com/mail3-top-bg.png) no-repeat top center;padding:30px 20px 20px 20px;border-bottom:1px solid #E9EBE2;">
  4975. <div style="position:relative;text-align:right">
  4976. <b style="font-size:24px;color:#8A9F98;z-index:999"><span name="titleHtml">' . $title . '</span></b>
  4977. <div style="width:80px;height:80px;position:absolute;top:0;left:0"><img src="http://zonghengvideo.qiniudn.com/zonghenglogo.png"></div>
  4978. </div>
  4979. </td>
  4980. </tr>
  4981. <tr>
  4982. <td align="left" style="background-color:#fff;padding:40px;border-bottom:1px solid #ddd;">
  4983. <p style="margin-top:0px;margin-bottom:10px;color:#666;font-size:16px;line-height:32px;"><b>CLIENTNAME</b>,您好</p>
  4984. <p style="margin-top:0px;margin-bottom:10px;color:#666;font-size:16px;line-height:32px;">我是纵横公路造价软件 <b>' . $this->staff [0] ['username'] . '</b>:</p>
  4985. <p name="contentHtml" style="margin-top:0px;margin-bottom:15px;color:#666;font-size:16px;line-height:32px;">' . $content . '</p></td>
  4986. </tr>
  4987. <tr><td align="left" style="padding: 0 40px;background:#fff">
  4988. ' . $annexHtml . '
  4989. </td></tr>
  4990. <tr>
  4991. <td style="padding: 10px 0 0;background:#F6F6F6;">
  4992. <table>
  4993. <tbody><tr>
  4994. <td style="font-size:14pxl;color:#666;padding:0 20px"><b>纵横公路造价软件' . $this->staff [0] ['category'] . '办事处</b><br>' . $this->staff [0] ['username'] . '<br><a href="http://www.smartcost.com.cn" style="color:#666;font-size:12px;text-decoration:underline;">smartcost.com.cn</a></td>
  4995. <td>
  4996. <table style="width:100%">
  4997. <tbody><tr style="font-size:12px;color:#496781">
  4998. <th align="right">电话:</th><td>' . $this->staff [0] ['phone'] . '</td>
  4999. <th align="right">手机:</th><td>' . $this->staff [0] ['telephone'] . '</td>
  5000. </tr>
  5001. <tr style="font-size:12px;color:#496781">
  5002. <th align="right">QQ:</th><td>' . $this->staff [0] ['qq'] . '</td>
  5003. <th align="right">邮箱: </th><td>' . $this->staff [0] ['email'] . '</td>
  5004. </tr>
  5005. </tbody></table>
  5006. </td>
  5007. </tr>
  5008. </tbody></table>
  5009. </td>
  5010. </tr>
  5011. <tr>
  5012. <td style="background:#F6F6F6 url(http://zonghengvideo.qiniudn.com/mail3-bottom-bg.png) no-repeat bottom center;"><p style="color:#fff;padding:0 0 20px;text-align:center;margin:0;font-size:12px"></p></td>
  5013. </tr>
  5014. </tbody>
  5015. </table></td>
  5016. </tr>
  5017. </tbody>
  5018. </table></td>
  5019. </tr>
  5020. </tbody>
  5021. </table>';
  5022. $info = '<table><tr style="font-size:12px;color:#496781"><th align="right">电话:</th><td>' . $this->staff [0] ['phone'] . '</td>
  5023. <th align="right">手机:</th><td>' . $this->staff [0] ['telephone'] . '</td></tr><tr style="font-size:12px;color:#496781">
  5024. <th align="right">QQ:</th><td>' . $this->staff [0] ['qq'] . '</td>
  5025. <th align="right">邮箱: </th><td>' . $this->staff [0] ['email'] . '</td></tr></table>
  5026. ';
  5027. }
  5028. $eMailTemplate->title = $title;
  5029. $eMailTemplate->skin = $skin;
  5030. $eMailTemplate->content = $content;
  5031. if (! empty ( $tagId ))
  5032. $eMailTemplate->tag = implode ( ",", $tagId );
  5033. $eMailTemplate->staffId = $this->staff [0] ['sid'];
  5034. $eMailTemplate->staffName = $this->staff [0] ['username'];
  5035. $eMailTemplate->status = 0;
  5036. $eMailTemplate->html = $html;
  5037. $eMailTemplate->annex = $annexPath;
  5038. $eMailTemplate->annexName = $annexName;
  5039. $etid = $eMailTemplate->insert ();
  5040. // create email list
  5041. Doo::loadModel ( 'tag_client' );
  5042. $tagClient = new tag_client ();
  5043. Doo::loadModel ( 'client' );
  5044. $client = new client ();
  5045. Doo::loadModel ( 'eMailList' );
  5046. $eMailList = new eMailList ();
  5047. Doo::loadModel ( 'company' );
  5048. $company = new company ();
  5049. $tagCondition = "";
  5050. $tagArray = array ();
  5051. foreach ( $tagId as $value ) {
  5052. array_push ( $tagArray, " tag like '%" . $value . "%' " );
  5053. }
  5054. if (! empty ( $tagArray ))
  5055. $tagCondition = ' and (' . implode ( " or ", $tagArray ) . ')';
  5056. $clientList = $tagClient->find ( array (
  5057. 'select' => 'client',
  5058. 'where' => 'sid=' . $this->staff [0] ['sid'] . $tagCondition,
  5059. 'asArray' => true
  5060. ) );
  5061. $clientArray = array ();
  5062. foreach ( $clientList as $value ) {
  5063. array_push ( $clientArray, $value ['client'] );
  5064. }
  5065. $clientEmailList = array ();
  5066. if (! empty ( $clientArray ))
  5067. $clientEmailList = $client->find ( array (
  5068. 'select' => 'email,cid,nicename as clientname,companyname',
  5069. 'where' => 'cid in (' . implode ( ",", $clientArray ) . ')',
  5070. 'asArray' => true
  5071. ) );
  5072. //
  5073. if ($stype == 2) {
  5074. // 获取性质相关数据
  5075. $cidList = '';
  5076. if ($natureNULL == '') {
  5077. $nD = array ();
  5078. foreach ( $nature as $key => $value ) {
  5079. array_push ( $nD, ' nature like "' . $value . '"' );
  5080. // $nD=' nature like "'.$value.'"';
  5081. }
  5082. $nD = implode ( ' or ', $nD );
  5083. $companycid = $company->find ( array (
  5084. 'select' => 'cid',
  5085. 'where' => $nD,
  5086. 'asArray' => true
  5087. ) );
  5088. $cidList = array ();
  5089. foreach ( $companycid as $key => $value ) {
  5090. array_push ( $cidList, $value ['cid'] );
  5091. }
  5092. $cidList = implode ( ',', $cidList );
  5093. if (! empty ( $cidList ))
  5094. $cidList = ' and companyid in (' . $cidList . ')';
  5095. else
  5096. $cidList = '';
  5097. }
  5098. // 'select'=>'email,cid,nicename as clientname,companyname,district'
  5099. $clientEmailList = $client->find ( array (
  5100. 'select' => 'email,cid,nicename as clientname,companyname,district',
  5101. 'where' => 'district like "' . $did . ',%" ' . $cidList,
  5102. 'asArray' => true
  5103. ) );
  5104. }
  5105. // ;datediff(curdate(), 'date')>=10
  5106. $eMailJournal->delete ( array (
  5107. 'where' => "datediff(curdate(), date)>=7"
  5108. ) );
  5109. $checkMail = $eMailJournal->find ( array (
  5110. 'where' => 'DATE_SUB(CURDATE(), INTERVAL 7 DAY) <= date(date)',
  5111. ' groupby' => 'email',
  5112. 'asArray' => true
  5113. ) );
  5114. $emailNameList = $emailArray = $illegalEmail = $sendEmail = array ();
  5115. Doo::db ()->beginTransaction ();
  5116. foreach ( $clientEmailList as $value ) {
  5117. if (filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) {
  5118. if (! empty ( $checkMail )) {
  5119. $falg = true;
  5120. foreach ( $checkMail as $v ) {
  5121. if ($v ['email'] == $value ['email']) {
  5122. $Bdate = strtotime ( $v ['date'] ) + 7 * 24 * 3600;
  5123. if ($Bdate <= time ()) {
  5124. array_push ( $emailArray, $value ['email'] );
  5125. array_push ( $emailNameList, $value );
  5126. $eMailJournal->date = date ( "Y-m-d" );
  5127. $eMailJournal->update ( array (
  5128. 'where' => 'ejid=' . $v ['ejid']
  5129. ) );
  5130. } else {
  5131. array_push ( $sendEmail, $value );
  5132. }
  5133. $falg = false;
  5134. break;
  5135. }
  5136. }
  5137. if ($falg) {
  5138. array_push ( $emailArray, $value ['email'] );
  5139. array_push ( $emailNameList, $value );
  5140. $eMailJournal->clientId = $value ['cid'];
  5141. $eMailJournal->status = 1;
  5142. $eMailJournal->email = $value ['email'];
  5143. $eMailJournal->date = date ( "Y-m-d" );
  5144. // $eMailJournal->insert();
  5145. }
  5146. } else {
  5147. array_push ( $emailArray, $value ['email'] );
  5148. array_push ( $emailNameList, $value );
  5149. $eMailJournal->clientId = $value ['cid'];
  5150. $eMailJournal->status = 1;
  5151. $eMailJournal->email = $value ['email'];
  5152. $eMailJournal->date = date ( "Y-m-d" );
  5153. // $eMailJournal->insert();
  5154. }
  5155. } else {
  5156. array_push ( $illegalEmail, $value );
  5157. }
  5158. }
  5159. Doo::db ()->commit ();
  5160. // echo json_encode($illegalEmail);
  5161. // json_encode(array_slice($illegalEmail,0,100))
  5162. // $kk=gzcompress();
  5163. // $ll=gzuncompress($kk);
  5164. // ."</br>".strlen($kk)."</br>".strlen($ll);die;
  5165. $size = floor ( count ( $emailArray ) / 3 );
  5166. if (! empty ( $emailArray )) {
  5167. if (count ( $emailArray ) < 3) {
  5168. $list = array (
  5169. 0 => $emailArray,
  5170. 1 => array (),
  5171. 2 => array ()
  5172. );
  5173. } else
  5174. $list = array_chunk ( $emailArray, $size );
  5175. } else
  5176. $list = array (
  5177. 0 => array (),
  5178. 1 => array (),
  5179. 2 => array ()
  5180. );
  5181. $emailJson = array ();
  5182. foreach ( $list as $value ) {
  5183. $em = array ();
  5184. foreach ( $value as $v ) {
  5185. array_push ( $em, $v );
  5186. }
  5187. array_push ( $emailJson, $em );
  5188. }
  5189. $size = floor ( count ( $emailNameList ) / 3 );
  5190. if (! empty ( $emailNameList )) {
  5191. if (count ( $emailNameList ) < 3) {
  5192. $list = array (
  5193. 0 => $emailNameList,
  5194. 1 => array (),
  5195. 2 => array ()
  5196. );
  5197. } else
  5198. $list = array_chunk ( $emailNameList, $size );
  5199. } else
  5200. $list = array (
  5201. 0 => array (),
  5202. 1 => array (),
  5203. 2 => array ()
  5204. );
  5205. $emailNameJson = array ();
  5206. foreach ( $list as $value ) {
  5207. $em = array ();
  5208. foreach ( $value as $v ) {
  5209. array_push ( $em, $v );
  5210. }
  5211. array_push ( $emailNameJson, $em );
  5212. }
  5213. //
  5214. $eMailList->date = date ( "Y-m-d" );
  5215. $eMailList->clientEmail = base64_encode ( gzcompress ( json_encode ( $emailJson [0] ) ) );
  5216. $eMailList->clientEmail2 = base64_encode ( gzcompress ( json_encode ( $emailJson [1] ) ) );
  5217. $eMailList->clientEmail3 = base64_encode ( gzcompress ( json_encode ( $emailJson [2] ) ) );
  5218. $eMailList->clientName = base64_encode ( gzcompress ( json_encode ( $emailNameJson [0] ) ) );
  5219. $eMailList->clientName2 = base64_encode ( gzcompress ( json_encode ( $emailNameJson [1] ) ) );
  5220. $eMailList->clientName3 = base64_encode ( gzcompress ( json_encode ( $emailNameJson [2] ) ) );
  5221. $eMailList->illegalEmail = json_encode ( array_slice ( $illegalEmail, 0, 100 ) ); // json_encode($illegalEmail);
  5222. $eMailList->sendEmail = json_encode ( $sendEmail );
  5223. $eMailList->etid = $etid;
  5224. $eMailList->templateName = $smartcostMail;
  5225. $eMailList->eTitle = $title;
  5226. $eMailList->html = $html;
  5227. $eMailList->content = $content;
  5228. $eMailList->info = $info;
  5229. if (! empty ( $annexName ))
  5230. $eMailList->annex = $annexHtml;
  5231. $eMailList->annexName = $annexName;
  5232. $eMailList->staffId = $this->staff [0] ['sid'];
  5233. $eMailList->staffName = $this->staff [0] ['username'];
  5234. if ($stype == 1)
  5235. $eMailList->tag = implode ( ",", $tagId );
  5236. if ($stype == 2) {
  5237. $eMailList->districtId = $did;
  5238. $eMailList->nature = implode ( ",", $nature );
  5239. }
  5240. $eMailList->insert ();
  5241. return "/eMailList";
  5242. }
  5243. return "/eMailTask";
  5244. }
  5245. function eMailList() {
  5246. Doo::loadModel ( 'eMailList' );
  5247. $eMailList = new eMailList ();
  5248. Doo::loadModel ( 'tag' );
  5249. $tag = new tag ();
  5250. $mailList = $eMailList->find ( array (
  5251. 'where' => 'staffId=' . $this->staff [0] ['sid'],
  5252. 'desc' => 'elid',
  5253. 'asArray' => true
  5254. ) );
  5255. foreach ( $mailList as $key => $value ) {
  5256. $mailList [$key] ['clientName2'] = $mailList [$key] ['clientName3'] = array ();
  5257. $mailList [$key] ['clientName'] = json_decode ( gzuncompress ( base64_decode ( $value ['clientName'] ) ), true );
  5258. if (! empty ( $value ['clientName2'] ))
  5259. $mailList [$key] ['clientName2'] = json_decode ( gzuncompress ( base64_decode ( $value ['clientName2'] ) ), true );
  5260. if (! empty ( $value ['clientName3'] ))
  5261. $mailList [$key] ['clientName3'] = json_decode ( gzuncompress ( base64_decode ( $value ['clientName3'] ) ), true );
  5262. $mailList [$key] ['illegalEmail'] = json_decode ( $value ['illegalEmail'], true );
  5263. $mailList [$key] ['sendEmail'] = json_decode ( $value ['sendEmail'], true );
  5264. $mailList [$key] ['clientCount'] = count ( $mailList [$key] ['clientName'] ) + count ( $mailList [$key] ['clientName2'] ) + count ( $mailList [$key] ['clientName3'] );
  5265. $mailList [$key] ['tag'] = array ();
  5266. if (! empty ( $value ['tag'] ))
  5267. $mailList [$key] ['tag'] = $tag->find ( array (
  5268. 'where' => 'tid in ( ' . $value ['tag'] . ') ',
  5269. 'asArray' => true
  5270. ) );
  5271. }
  5272. $data ['mailList'] = $mailList;
  5273. $data ['memu'] = "eMailTask";
  5274. $data ['staff'] = $this->staff;
  5275. $data ['mailMemu'] = 'eMailList';
  5276. $this->render ( "/mail_list", $data );
  5277. }
  5278. function showEmailContent() {
  5279. $elid = isset ( $this->params ['elid'] ) ? $this->params ['elid'] : 0;
  5280. Doo::loadModel ( 'eMailList' );
  5281. $eMList = new eMailList ();
  5282. $isSend = $eMList->getOne ( array (
  5283. 'where' => 'elid =' . $elid . '',
  5284. 'asArray' => true
  5285. ) );
  5286. echo htmlspecialchars ( $isSend ['content'] );
  5287. }
  5288. function postEmail() {
  5289. // include Doo::conf()->BASE_PATH.'diagnostic/debug.php';
  5290. $elid = isset ( $this->params ['elid'] ) ? $this->params ['elid'] : 0;
  5291. $send = isset ( $this->params ['send'] ) ? $this->params ['send'] : 0;
  5292. Doo::loadModel ( 'eMailList' );
  5293. $eMList = new eMailList ();
  5294. if (! empty ( $elid )) {
  5295. $isSend = $eMList->getOne ( array (
  5296. 'select' => 'send' . $send,
  5297. 'where' => 'elid =' . $elid . ' and status=0 and send' . $send . '=1',
  5298. 'asArray' => true
  5299. ) );
  5300. if (! empty ( $isSend ))
  5301. die ( '这批邮件已经发送' );
  5302. if ($send == 1)
  5303. $send = '';
  5304. $eMailList = $eMList->getOne ( array (
  5305. 'select' => 'eTitle,staffName,clientName' . $send . ' as clientName,clientEmail' . $send . ' as clientEmail,annex,info,content,templateName',
  5306. 'where' => 'elid =' . $elid . ' and status=0',
  5307. 'asArray' => true
  5308. ) );
  5309. $toFormatMail = array ();
  5310. $sub = array ();
  5311. $toMail = json_decode ( gzuncompress ( base64_decode ( $eMailList ['clientEmail'] ) ), true );
  5312. // $toMailCount=count($toMail);
  5313. $subMail = json_decode ( gzuncompress ( base64_decode ( $eMailList ['clientName'] ) ), true );
  5314. $chunkMail = array_chunk ( $toMail, 80 );
  5315. $chunkSubMail = array_chunk ( $subMail, 80 );
  5316. $vii = 0;
  5317. foreach ( $chunkMail as $key => $value ) {
  5318. $l = $s = $c = $i = $cate = $con = $annex = array ();
  5319. $toFormatMail ['to'] = $value;
  5320. $cn = $chunkSubMail [$key];
  5321. foreach ( $cn as $v ) {
  5322. array_push ( $l, $eMailList ['eTitle'] );
  5323. array_push ( $s, $eMailList ['staffName'] );
  5324. array_push ( $c, $v ['clientname'] );
  5325. array_push ( $annex, $eMailList ['annex'] );
  5326. array_push ( $i, $eMailList ['info'] );
  5327. // array_push($con, $eMailList['content']);
  5328. array_push ( $cate, $this->staff [0] ['category'] );
  5329. }
  5330. $sub ['%eTitle%'] = $l;
  5331. $sub ['%staffName%'] = $s;
  5332. $sub ['%clientName%'] = $c;
  5333. $sub ['%category%'] = $cate;
  5334. $sub ['%info%'] = $i;
  5335. // $sub['%content%']=$con;
  5336. $sub ['%annex%'] = $annex;
  5337. $toFormatMail ['sub'] = $sub;
  5338. $url = 'http://sendcloud.sohu.com/webapi/mail.send_template.xml';
  5339. $param = array (
  5340. 'api_user' => 'cldmail',
  5341. 'api_key' => 'cDO1GjtY1seH',
  5342. 'template_invoke_name' => $eMailList ['templateName'],
  5343. 'from' => $this->staff [0] ['email'],
  5344. 'fromname' => '纵横' . $eMailList ['staffName'],
  5345. 'subject' => $eMailList ['eTitle'],
  5346. 'substitution_vars' => json_encode ( $toFormatMail )
  5347. );
  5348. $post_data = http_build_query ( $param );
  5349. $ch = curl_init ();
  5350. curl_setopt ( $ch, CURLOPT_POST, 1 );
  5351. curl_setopt ( $ch, CURLOPT_URL, $url );
  5352. curl_setopt ( $ch, CURLOPT_HEADER, false ); // 设定是否输出页面内容
  5353. curl_setopt ( $ch, CURLOPT_NOBODY, false );
  5354. curl_setopt ( $ch, CURLOPT_POSTFIELDS, $post_data );
  5355. $result = curl_exec ( $ch );
  5356. curl_close ( $ch );
  5357. /*
  5358. * if($result=='success'){ $eM=new eMailList(); $eM->status='2'; $eM->update(array('where'=>'elid=?','param'=>array($elid))); }
  5359. */
  5360. }
  5361. if ($send == "")
  5362. $send = 1;
  5363. $sql = "update `CLD_eMailList` set send" . $send . "='1' where elid = '" . $elid . "'";
  5364. Doo::db ()->query ( $sql );
  5365. $isSend = $eMList->getOne ( array (
  5366. 'where' => 'elid =' . $elid . ' and status=0 and send1=1 and send2=1 and send3=1',
  5367. 'asArray' => true
  5368. ) );
  5369. if (! empty ( $isSend )) {
  5370. $sql = "update `CLD_eMailList` set status='2' where elid = '" . $elid . "'";
  5371. Doo::db ()->query ( $sql );
  5372. }
  5373. // die;
  5374. return '/eMailList';
  5375. }
  5376. }
  5377. function a() {
  5378. $substitution_vars = $this->get_args ( 'substitution_vars' );
  5379. file_put_contents ( DOO::conf ()->SITE_PATH . 'upload/' . "_" . time () . "_" . rand ( 100, 999 ) . ".log", $substitution_vars );
  5380. }
  5381. function deleteEmail() {
  5382. $elid = isset ( $this->params ['elid'] ) ? $this->params ['elid'] : 0;
  5383. if (! empty ( $elid )) {
  5384. $sql = "DELETE FROM `CLD_eMailList` where elid = '" . $elid . "'";
  5385. Doo::db ()->query ( $sql );
  5386. return '/eMailList';
  5387. }
  5388. }
  5389. /**
  5390. * 发送post请求
  5391. * @param string $url 请求地址
  5392. * @param array $post_data post键值对数据
  5393. * @return string
  5394. */
  5395. function sendPost($url, $post_data) {
  5396. $postdata = http_build_query ( $post_data );
  5397. // X-Amzn-Authorization: AWS3 AWSAccessKeyId=AKIAIDSE5VYNX5ERJHXQ,Signature=lBP67vCvGlDMBQ=dofZxg8E8SUEXAMPLE,Algorithm=HmacSHA256,SignedHeaders=qG1BdSh9QyYPlWLnjqvjDXjyPdFjl7fUSkfs0Hk2
  5398. $options = array (
  5399. 'http' => array (
  5400. 'method' => 'POST',
  5401. 'header' => '
  5402. Content-Type: application/x-www-form-urlencoded
  5403. ',
  5404. 'content' => $postdata,
  5405. 'timeout' => 15 * 60
  5406. ) // 超时时间(单位:s)
  5407. );
  5408. $context = stream_context_create ( $options );
  5409. $result = file_get_contents ( $url, false, $context );
  5410. return $result;
  5411. }
  5412. function avatar() {
  5413. $result = array ();
  5414. $result ['success'] = false;
  5415. $successNum = 0;
  5416. // 定义一个变量用以储存当前头像的序号
  5417. $avatarNumber = 1;
  5418. $i = 0;
  5419. $msg = '';
  5420. // 上传目录
  5421. $dir = DOO::conf ()->SITE_PATH . "global/avatar";
  5422. // 遍历所有文件域
  5423. while ( list ( $key, $val ) = each ( $_FILES ) ) {
  5424. if ($_FILES [$key] ['error'] > 0)
  5425. $msg .= $_FILES [$key] ['error'];
  5426. else {
  5427. $fileName = 'avatar_' . $this->staff [0] ['sid'];
  5428. // 原始图片(file 域的名称:__source,如果客户端定义可以上传的话,可在此处理)。
  5429. if ($key == '__source') { // 当前头像基于原图的初始化参数,用于修改头像时保证界面的视图跟保存头像时一致。帮助提升用户体验度。修改头像时设置默认加载的原图的url为此图片的url+该参数即可。
  5430. $initParams = $_POST ["__initParams"];
  5431. $virtualPath = $dir . "/" . $fileName . "_" . $avatarNumber . ".jpg";
  5432. $result ['sourceUrl'] = '/' . $virtualPath . $initParams;
  5433. move_uploaded_file ( $_FILES [$key] ["tmp_name"], $virtualPath );
  5434. $successNum ++;
  5435. } else if (strpos ( $key, '__avatar' ) === 0) { // 头像图片(file 域的名称:__avatar1,2,3...)。
  5436. $virtualPath = $dir . "/" . $fileName . "_" . $avatarNumber . ".jpg";
  5437. $result ['avatarUrls'] [$i] = '/' . $virtualPath;
  5438. move_uploaded_file ( $_FILES [$key] ["tmp_name"], $virtualPath );
  5439. $avatarNumber ++;
  5440. $successNum ++;
  5441. $i ++;
  5442. }
  5443. }
  5444. }
  5445. $result ['msg'] = $msg;
  5446. if ($successNum > 0)
  5447. $result ['success'] = true;
  5448. // 返回图片的保存结果(返回内容为json字符串)
  5449. Doo::loadModel ( 'staff' );
  5450. $staff = new staff ();
  5451. $staff->sid = $this->staff [0] ['sid'];
  5452. $staff->avatar = "/global/avatar/" . $fileName;
  5453. $staff->update ();
  5454. echo json_encode ( $result );
  5455. }
  5456. function lockUpload() {
  5457. // move_uploaded_file($_FILES['Filedata']['tmp_name'], "/upload/".$_FILES['Filedata']['name']);
  5458. if (isset ( $_FILES ['Filedata'] ['name'] )) {
  5459. $file = $_FILES ['Filedata'] ['tmp_name'];
  5460. $error = false;
  5461. if (! is_uploaded_file ( $file )) {
  5462. $error = '400 Bad Request';
  5463. }
  5464. if ($error) {
  5465. header ( 'HTTP/1.0 ' . $error );
  5466. die ( 'Error ' . $error );
  5467. } else {
  5468. include (DOO::conf ()->SITE_PATH . 'protected/plugin/io.han.php');
  5469. $this->IoHandler = new IoHandler ();
  5470. $pics = explode ( '.', $_FILES ['Filedata'] ['name'] );
  5471. // $filedir=$_POST['time'];
  5472. // 调用定义物理路径
  5473. $t = DOO::conf ()->SITE_PATH . "upload/";
  5474. $this->IoHandler->MakeDir ( $t );
  5475. $filename = $this->_GetFileEXT ( $_FILES ['Filedata'] ['name'] );
  5476. if ($filename != 'xlsx')
  5477. return "";
  5478. // $upload_dir = $t."/".time().rand(10,100).".".$filename;
  5479. $upload_file = iconv ( "UTF-8", "GB2312", $_FILES ["Filedata"] ["name"] );
  5480. $upload_dir = $t . "/" . $upload_file;
  5481. $k = move_uploaded_file ( $file, $upload_dir );
  5482. if ($k) {
  5483. // "series/".$filedir."/".
  5484. $m = round ( $_FILES ['Filedata'] ['size'] / 1024 / 1024, 2 );
  5485. echo $pics [0] . "." . $filename . "#" . $m . "#" . $_FILES ['Filedata'] ['size'];
  5486. }
  5487. }
  5488. }
  5489. }
  5490. function getAuthentication() {
  5491. }
  5492. function loadCVS() {
  5493. Doo::loadModel ( 'longle' );
  5494. $longle = new longle ();
  5495. $list = $longle->find ( array (
  5496. 'select' => 'key_num',
  5497. 'asArray' => TRUE
  5498. ) );
  5499. $file = fopen ( DOO::conf ()->SITE_PATH . "upload/key2.csv", 'r' );
  5500. while ( $data = fgetcsv ( $file ) ) {
  5501. $goods_list [$data [0]] = $data [1];
  5502. }
  5503. fclose ( $file );
  5504. $sqlArray = array ();
  5505. $sql = 'UPDATE CLD_longle SET SerialNumber = CASE key_num ';
  5506. foreach ( $list as $key => $value ) {
  5507. if (array_key_exists ( $value ['key_num'], $goods_list )) {
  5508. // echo $value['key_num'].'-'.$goods_list[$value['key_num']].'<br/>';
  5509. // $longle->SerialNumber=$goods_list[$value['key_num']];
  5510. // $longle->update(array('where'=>'key_num="'.$value['key_num'].'"'));
  5511. $sql .= ' WHEN "' . $value ['key_num'] . '" THEN "' . $goods_list [$value ['key_num']] . '" ';
  5512. array_push ( $sqlArray, '"' . $value ['key_num'] . '"' );
  5513. unset ( $goods_list [$value ['key_num']] );
  5514. }
  5515. }
  5516. $sql .= 'END WHERE key_num IN (' . implode ( ',', $sqlArray ) . ')';
  5517. echo $sql . '<br/>--------------------------------<br/>';
  5518. foreach ( $goods_list as $key => $value ) {
  5519. echo $key . ',' . $value . '<br/>';
  5520. }
  5521. }
  5522. private function getRandChar($length) {
  5523. $str = null;
  5524. $strPol = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz";
  5525. $max = strlen ( $strPol ) - 1;
  5526. for($i = 0; $i < $length; $i ++) {
  5527. $str .= $strPol [rand ( 0, $max )]; // rand($min,$max)生成介于min和max两个数之间的一个随机整数
  5528. }
  5529. return $str;
  5530. }
  5531. // private function getReceiptCount(){
  5532. // $status=2;
  5533. // $year=date('Y');
  5534. // Doo::loadModel('receipt');
  5535. // $receipt=new receipt();
  5536. // $dateCondition=" and Year(date) =".$year;
  5537. // $approvalCondition=' and nowStaff like "%'.$this->staff[0]['sid'].'%" ';
  5538. // $receiptList=$receipt->find(array('where'=>' status='.$status.$dateCondition.$approvalCondition,'desc'=>'rid','asArray'=>true));
  5539. // return count($receiptList);
  5540. // }
  5541. // private function getExeCount(){
  5542. // Doo::loadModel('receipt');
  5543. // $receipt=new receipt();
  5544. // $receiptList=$receipt->find(array('where'=>'(executeCopy like \'%["'.$this->staff[0]['sid'].'%\' and executeStaff NOT LIKE \'%'.$this->staff[0]['sid'].'%\' ) and (status=1 or status=6)','desc'=>'rid','asArray'=>true));
  5545. // return count($receiptList);
  5546. // }
  5547. /**
  5548. * 格式化excel文件为数组
  5549. * @param unknown_type $file_url
  5550. * @param unknown_type $mcid
  5551. */
  5552. function _format_excel_to_array($file_url = "") {
  5553. if (! file_exists ( $file_url ))
  5554. return array ();
  5555. Doo::loadClass ( 'PHPExcel' );
  5556. $PHPExcel = new PHPExcel ();
  5557. $PHPReader = new PHPExcel_Reader_Excel2007 ();
  5558. if (! $PHPReader->canRead ( $file_url )) {
  5559. $PHPReader = new PHPExcel_Reader_Excel5 ();
  5560. if (! $PHPReader->canRead ( $file_url )) {
  5561. echo 'no Excel';
  5562. return;
  5563. }
  5564. }
  5565. $PHPExcel = $PHPReader->load ( $file_url );
  5566. /**
  5567. * 读取excel文件中的第一个工作表
  5568. */
  5569. $currentSheet = $PHPExcel->getSheet ( 0 );
  5570. /**
  5571. * 取得最大的列号
  5572. */
  5573. $allColumn = $currentSheet->getHighestColumn ();
  5574. /**
  5575. * 取得一共有多少行
  5576. */
  5577. $allRow = $currentSheet->getHighestRow ();
  5578. $excel_array = array ();
  5579. for($currentRow = 2; $currentRow <= $allRow; $currentRow ++) {
  5580. $excel_column = array ();
  5581. // 后期改进
  5582. if ($allColumn == 'AM')
  5583. $allColumn = 'Z';
  5584. /**
  5585. * 从第A列开始输出
  5586. */
  5587. for($currentColumn = 'A'; $currentColumn <= $allColumn; $currentColumn ++) {
  5588. $val = $currentSheet->getCellByColumnAndRow ( ord ( $currentColumn ) - 65, $currentRow )->getValue ();
  5589. /**
  5590. * ord()将字符转为十进制数 iconv ( 'utf-8', 'gb2312',
  5591. */
  5592. $val = "'" . addslashes ( $val ) . "'";
  5593. if ($currentColumn == 'A')
  5594. $excel_column ['key_num'] = $val;
  5595. elseif ($currentColumn == 'C')
  5596. $excel_column ['product'] = $val;
  5597. elseif ($currentColumn == 'D') {
  5598. $val = str_replace ( "'", "", $val );
  5599. $excel_column ['make_day'] = $this->excelTime ( $val );
  5600. } elseif ($currentColumn == 'E') {
  5601. $val = str_replace ( "'", "", $val );
  5602. $excel_column ['alloted_time'] = $this->excelTime ( $val );
  5603. } elseif ($currentColumn == 'F') {
  5604. $val = str_replace ( "'", "", $val );
  5605. $excel_column ['version'] = $val;
  5606. } elseif ($currentColumn == 'B') {
  5607. $val = str_replace ( "'", "", $val );
  5608. $excel_column ['SerialNumber'] = $val;
  5609. }
  5610. }
  5611. array_push ( $excel_array, $excel_column );
  5612. }
  5613. return $excel_array;
  5614. }
  5615. function excelTime($date, $time = false) {
  5616. if (function_exists ( 'GregorianToJD' )) {
  5617. if (is_numeric ( $date )) {
  5618. $jd = GregorianToJD ( 1, 1, 1970 );
  5619. $gregorian = JDToGregorian ( $jd + intval ( $date ) - 25569 );
  5620. $date = explode ( '/', $gregorian );
  5621. $date_str = str_pad ( $date [2], 4, '0', STR_PAD_LEFT ) . "-" . str_pad ( $date [0], 2, '0', STR_PAD_LEFT ) . "-" . str_pad ( $date [1], 2, '0', STR_PAD_LEFT ) . ($time ? " 00:00:00" : '');
  5622. return $date_str;
  5623. }
  5624. } else {
  5625. $date = $date > 25568 ? $date + 1 : 25569;
  5626. /* There was a bug if Converting date before 1-1-1970 (tstamp 0) */
  5627. $ofs = (70 * 365 + 17 + 2) * 86400;
  5628. $date = date ( "Y-m-d", ($date * 86400) - $ofs ) . ($time ? " 00:00:00" : '');
  5629. }
  5630. return $date;
  5631. }
  5632. function _GetFileEXT($filename) {
  5633. $pics = explode ( '.', $filename );
  5634. $num = count ( $pics );
  5635. return $pics [$num - 1];
  5636. }
  5637. /**
  5638. * 获取get或者POST值
  5639. * @param string $name 属性名称
  5640. * @return fixed 值
  5641. */
  5642. function get_args($name) {
  5643. if (isset ( $_GET [$name] )) {
  5644. if (is_array ( $_GET [$name] ))
  5645. return $_GET [$name];
  5646. else {
  5647. return addslashes ( $_GET [$name] );
  5648. }
  5649. } elseif (isset ( $_POST [$name] )) {
  5650. if (is_array ( $_POST [$name] ))
  5651. return $_POST [$name];
  5652. else {
  5653. return addslashes ( $_POST [$name] );
  5654. }
  5655. } else {
  5656. return false;
  5657. }
  5658. }
  5659. function get_previous($on_page = 1) {
  5660. return $on_page != 0 ? $on_page - 1 : $on_page;
  5661. }
  5662. /**
  5663. * 获得分页数据
  5664. * @param unknown_type $table
  5665. * @param unknown_type $condition
  5666. * @param unknown_type $on_page
  5667. * @param unknown_type $page_size
  5668. */
  5669. function get_Tpage($table = "", $condition = "", $on_page = 1, $page_size = 20, $action = "", $tagSQL) {
  5670. $page_c = "";
  5671. $page ['previous'] = $this->get_previous ( $on_page );
  5672. $page ['on_page'] = $on_page;
  5673. $total_count = $this->get_table_Tcount ( $table, $condition, $tagSQL );
  5674. $total = intval ( $total_count / $page_size );
  5675. $page ['total_page'] = ($total_count % $page_size) == 0 ? $total : $total + 1;
  5676. $page ['total_data'] = $total_count;
  5677. $page ['next'] = $on_page == $page ['total_page'] ? $page ['total_page'] : $on_page + 1;
  5678. $i = 1;
  5679. $page_max = 1;
  5680. if ($on_page > 10) {
  5681. $page_max = intval ( $on_page / 10 ) + 1;
  5682. $i = intval ( $on_page / 10 ) * 10 - 1;
  5683. }
  5684. $page ['page'] = $page_c;
  5685. $page ['lower'] = (-- $on_page) * $page_size;
  5686. return $page;
  5687. }
  5688. /**
  5689. * 获得分页数据
  5690. * @param unknown_type $table
  5691. * @param unknown_type $condition
  5692. * @param unknown_type $on_page
  5693. * @param unknown_type $page_size
  5694. */
  5695. function get_page($table = "", $condition = "", $on_page = 1, $page_size = 20, $action = "", $get = "", $other = "page", $staffid = "", $search, $tooltip, $cateid, $tagSQL) {
  5696. $page_c = "";
  5697. $page ['previous'] = $this->get_previous ( $on_page );
  5698. $page ['on_page'] = $on_page;
  5699. $total_count = $this->get_table_count ( $table, $condition, $staffid, $search, $tooltip, $cateid, $tagSQL );
  5700. $total = intval ( $total_count / $page_size );
  5701. $page ['total_page'] = ($total_count % $page_size) == 0 ? $total : $total + 1;
  5702. $page ['total_data'] = $total_count;
  5703. $page ['next'] = $on_page == $page ['total_page'] ? $page ['total_page'] : $on_page + 1;
  5704. $i = 1;
  5705. $page_max = 1;
  5706. if ($on_page > 10) {
  5707. $page_max = intval ( $on_page / 10 ) + 1;
  5708. $i = intval ( $on_page / 10 ) * 10 - 1;
  5709. }
  5710. for(; $i <= $page ['total_page']; $i ++) {
  5711. if ($i == $on_page) {
  5712. if ($other == "page")
  5713. $page_c .= '<a href="javascript:void(0);" class="current">' . $i . '</a>';
  5714. else
  5715. $page_c .= '&nbsp;<span class="current">' . $i . '</span>&nbsp;';
  5716. } else if ($other == "page")
  5717. $page_c .= '<a href="' . $action . $i . $get . '" class="paginate">' . $i . '</a>';
  5718. else
  5719. $page_c .= '&nbsp;<a href="' . $action . $i . $get . '" class="paginate">' . $i . '</a>&nbsp;';
  5720. if ($i == (10 * $page_max))
  5721. break;
  5722. }
  5723. $page ['page'] = $page_c;
  5724. $page ['lower'] = (-- $on_page) * $page_size;
  5725. return $page;
  5726. }
  5727. /**
  5728. * 获取总页数
  5729. * @param unknown_type $table
  5730. * @param unknown_type $condition
  5731. */
  5732. public function get_table_Tcount($table = "", $condition = "", $tagSQL) {
  5733. if ($tagSQL)
  5734. $sql = "select count(*) as count from CLD_tagCompanyNexus as a left join CLD_company as b on (a.company=b.cid ) where " . $condition;
  5735. else
  5736. $sql = "select count(*) as count from CLD_company where " . $condition;
  5737. $query = Doo::db ()->query ( $sql );
  5738. $result = $query->fetch ();
  5739. return $result ['count'];
  5740. }
  5741. /**
  5742. * 获取总页数
  5743. * @param unknown_type $table
  5744. * @param unknown_type $condition
  5745. */
  5746. public function get_table_count($table = "", $condition = "", $staffid = "", $search, $tooltip, $cateid, $tagSQL) {
  5747. // $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  5748. // echo $staffid;die;
  5749. //
  5750. if (! empty ( $staffid )) {
  5751. // $staffid="and a.sid= '".$staffid."'"; " . $table . " as a left join on (a.cid=b.cid ".$staffid.")
  5752. $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;
  5753. } else {
  5754. if (strlen ( $condition ) == 1 || empty ( $condition ))
  5755. $sql = "select count(*) as count from CLD_client as a " . $condition;
  5756. else
  5757. $sql = "select count(*) as count from CLD_client as a left join CLD_tag_client as c on (a.cid=c.client) where 1 " . $condition;
  5758. }
  5759. if (! empty ( $search ))
  5760. $sql = "select count(*) as count from CLD_client as a where 1 " . $condition;
  5761. if (! empty ( $tooltip )) {
  5762. $condition = str_replace ( "a.", "c.", $condition );
  5763. if ($tagSQL)
  5764. $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;
  5765. else
  5766. $sql = "select count(*) as count from CLD_C_tooltip as a left join CLD_client as b on (a.cid=b.cid ) where a.name like '%" . $tooltip . "%' and a.cateid = " . $cateid . " " . $condition;
  5767. }
  5768. // echo $sql;
  5769. $query = Doo::db ()->query ( $sql );
  5770. $result = $query->fetch ();
  5771. return $result ['count'];
  5772. }
  5773. }
  5774. ?>