MainController.php 260 KB

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