MainController.php 247 KB

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