MainController.php 245 KB

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