MainController.php 247 KB

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