MainController.php 232 KB

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