MainController.php 266 KB

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