MainController.php 266 KB

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