MainController.php 244 KB

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