MainController.php 260 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804
  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. $token = $this->get_args ( 'token' ) ? $this->get_args ( 'token' ) : "";
  1585. if (empty ( $token )) {
  1586. die ( 'illegal request-token' );
  1587. } else {
  1588. session_start ();
  1589. if ($_SESSION ['token_' . $this->staff [0] ['sidKey']] != $token) {
  1590. header ( 'Content-Type:text/html;charset=utf-8' );
  1591. die ( '请勿重复填写客户资料' );
  1592. } else {
  1593. $_SESSION ['token_' . $this->staff [0] ['sidKey']] = '';
  1594. }
  1595. }
  1596. if (empty ( $this->staff [0] ['sid'] ))
  1597. return "/contacts";
  1598. if (! empty ( $clientname )) {
  1599. // 相同的公司和客户
  1600. Doo::loadModel ( 'company' );
  1601. $company = new company ();
  1602. Doo::loadModel ( 'client' );
  1603. $client = new client ();
  1604. $redis = new Redis ();
  1605. $redis->connect ( '127.0.0.1', '6379' );
  1606. $cinfo = $client->getClientByNameT ( $clientname );
  1607. Doo::loadModel ( 'district' );
  1608. $district = new district ();
  1609. // 修改
  1610. Doo::loadClass ( 'XDeode' );
  1611. $XDeode = new XDeode ( 5 );
  1612. $comId = $XDeode->decode ( $companyKey );
  1613. $companyInfo = $company->getOne ( array (
  1614. 'where' => "cid = '" . $comId . "'",
  1615. "asArray" => true
  1616. ) );
  1617. // 更新公司信息
  1618. $lv1 = $district->getbyid ( $local1 );
  1619. $lv2 = $district->getbyid ( $local2 );
  1620. $lv3 = $district->getbyid ( $local3 );
  1621. if (empty ( $lv1 ))
  1622. $lv1 [0] ['name'] = "";
  1623. if (empty ( $lv2 ))
  1624. $lv2 [0] ['name'] = "";
  1625. if (empty ( $lv3 ))
  1626. $lv3 [0] ['name'] = "";
  1627. // if (! empty ( $local1 ) && ! empty ( $local2 ))
  1628. // $company->local = $lv1 [0] ['name'] . "," . $lv2 [0] ['name'] . "," . $lv3 [0] ['name'];
  1629. // if (! empty ( $nature ))
  1630. // $company->nature = implode ( ',', $nature );
  1631. // if (! empty ( $fax ))
  1632. // $company->fax = $fax;
  1633. // if (! empty ( $webservice ))
  1634. // $company->webservice = $webservice;
  1635. // if (! empty ( $address ))
  1636. // $company->address = $address;
  1637. // if (! empty ( $ride ))
  1638. // $company->ride = $ride;
  1639. // if (! empty ( $landmarks ))
  1640. // $company->landmarks = $landmarks;
  1641. // if (! empty ( $office ))
  1642. // $company->office = $office;
  1643. // if (! empty ( $local1 ) && ! empty ( $local2 ))
  1644. // $company->district = $local1 . "," . $local2 . "," . $local3;
  1645. // if (! empty ( $stay ))
  1646. // $company->stay = $stay;
  1647. $cid = $companyInfo ['cid'];
  1648. if (empty ( $companyInfo )) {
  1649. } else { // 不编辑公司,地区判断,作为新公司
  1650. // $cid=$companyInfo['cid'];
  1651. //
  1652. // $companyname=$companyInfo['companyname'];
  1653. //
  1654. // $company->cid=$cid;
  1655. //
  1656. // $company->update();
  1657. // $diqu = $local1 . "," . $local2 . "," . $local3;
  1658. // $cid = $companyInfo ['cid'];
  1659. // $company2 = new company ();
  1660. // $companyList = $company2->find ( array (
  1661. // 'where' => " companyname like '" . $companyname . "'",
  1662. // "asArray" => true
  1663. // ) );
  1664. // $falg = false;
  1665. // // print_r($companyList);
  1666. // foreach ( $companyList as $key => $value ) {
  1667. // if ($value ['district'] != $diqu) {
  1668. // $falg = true;
  1669. // } elseif ($value ['district'] == $diqu) {
  1670. // $falg = false;
  1671. // $cid = $value ['cid'];
  1672. // break;
  1673. // }
  1674. // }
  1675. // if ($falg) {
  1676. // $company->companyname = $companyname;
  1677. // $company->staffid = $this->staff [0] ['sid'];
  1678. // $cid = $company->insert ();
  1679. // }
  1680. }
  1681. Doo::loadModel ( 'client_staff' );
  1682. $client_staff = new client_staff ();
  1683. $client->clientname = $clientname;
  1684. $client->gender = $gender;
  1685. $client->priority = $priority;
  1686. if (! empty ( $nicename ))
  1687. $client->nicename = $nicename;
  1688. if (! empty ( $telephone ))
  1689. $client->telephone = $telephone;
  1690. if (! empty ( $phone ))
  1691. $client->phone = $phone;
  1692. if (! empty ( $email ))
  1693. $client->email = $email;
  1694. if (! empty ( $qq ) && is_numeric ( $qq ))
  1695. $client->qq = $qq;
  1696. $client->companyid = $cid;
  1697. $client->companyname = $companyInfo['companyname'];
  1698. $client->district = $local1 . "," . $local2 . "," . $local3;
  1699. // echo $client->district;
  1700. // die;
  1701. if (! empty ( $tid ))
  1702. $client->tag = implode ( ',', $tid );
  1703. if (! empty ( $fax ))
  1704. $client->fax = $fax;
  1705. if (! empty ( $webservice ))
  1706. $client->webservice = $webservice;
  1707. if (! empty ( $department ))
  1708. $client->department = $department;
  1709. if (! empty ( $position ))
  1710. $client->position = $position;
  1711. if (! empty ( $office ))
  1712. $client->office = $office;
  1713. if (! empty ( $address ))
  1714. $client->address = $address;
  1715. if (! empty ( $ride ))
  1716. $client->ride = $ride;
  1717. if (! empty ( $landmarks ))
  1718. $client->landmarks = $landmarks;
  1719. if (! empty ( $stay ))
  1720. $client->stay = $stay;
  1721. if (! empty ( $mark ))
  1722. $client->mark = $mark;
  1723. $id = $client->insert ();
  1724. $client_staff->cid = $id;
  1725. $client_staff->sid = $this->staff [0] ['sid'];
  1726. $client_staff->insert ();
  1727. // 加入地区记录
  1728. Doo::loadModel ( "district_staff" );
  1729. $district_staff = new district_staff ();
  1730. $district_staff->did = $lv1 [0] ['id'];
  1731. $district_staff->sid = $this->staff [0] ['sid'];
  1732. $district_staff->insert ();
  1733. // 日常行为
  1734. Doo::loadModel ( "action_log" );
  1735. $action_log = new action_log ();
  1736. $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'] . ')';
  1737. $action_log->sid = $this->staff [0] ['sid'];
  1738. $action_log->cid = $this->staff [0] ['cid'];
  1739. $action_log->updatetime = date ( "Y-m-d" );
  1740. $action_log->time = date ( "H:i" );
  1741. $action_log->status = 1;
  1742. $action_log->districtid = $local1 . "," . $local2 . "," . $local3;
  1743. $action_log->city = $lv1 [0] ['name'];
  1744. $action_log->province = $lv2 [0] ['name'];
  1745. if (isset ( $nature [0] ))
  1746. $action_log->nature = $nature [0];
  1747. $action_log->company = $companyInfo['companyname'];
  1748. $action_log->class = $action_log->iconContacts;
  1749. $action_log->insert ();
  1750. // 事实更新信息中心记录数量 需要更新3个redis 内的值
  1751. $categoryCondition = " and cid=" . $this->staff [0] ['cid'];
  1752. $sidCondition = " and sid=" . $this->staff [0] ['sid'];
  1753. // actionlog免查询值 $alCondition='';
  1754. $alCondition = ' aid>' . REMIT . ' and ';
  1755. // 个人添加数量redis值
  1756. $redisKeyCS = date ( 'Y-m-d' ) . 'SC_' . $this->staff [0] ['cid'] . '_' . $this->staff [0] ['sid'];
  1757. $action_log = new action_log ();
  1758. $actionLogClient = $action_log->find ( array (
  1759. 'select' => 'date_format(updatetime,"%m-%d") as updatetime,COUNT(*) as count',
  1760. 'where' => $alCondition . " status=1" . $sidCondition . $categoryCondition . ' and date_sub(curdate(), INTERVAL 30 DAY) <= date(updatetime)',
  1761. 'groupby' => 'date_format(updatetime,"%m-%d")',
  1762. 'asArray' => true
  1763. ) );
  1764. $statisticsClient = array ();
  1765. for($d = 0; $d <= 29; $d ++) {
  1766. $MD = date ( "m-d", strtotime ( "-" . $d . " day" ) );
  1767. $falgClient = true;
  1768. foreach ( $actionLogClient as $value ) {
  1769. if ($value ['updatetime'] == $MD) {
  1770. array_push ( $statisticsClient, $value ['count'] );
  1771. $falgClient = false;
  1772. break;
  1773. }
  1774. }
  1775. if ($falgClient)
  1776. array_push ( $statisticsClient, 0 );
  1777. }
  1778. $statisticsClient = array_reverse ( $statisticsClient );
  1779. $jsc = json_encode ( $statisticsClient );
  1780. $redis->set ( $redisKeyCS, $jsc );
  1781. // 办事处添加数量reids值
  1782. $redisKeyC = date ( 'Y-m-d' ) . 'SC_' . $this->staff [0] ['cid'] . '_';
  1783. $action_log = new action_log ();
  1784. $actionLogClient = $action_log->find ( array (
  1785. 'select' => 'date_format(updatetime,"%m-%d") as updatetime,COUNT(*) as count',
  1786. 'where' => $alCondition . " status=1" . $categoryCondition . ' and date_sub(curdate(), INTERVAL 30 DAY) <= date(updatetime)',
  1787. 'groupby' => 'date_format(updatetime,"%m-%d")',
  1788. 'asArray' => true
  1789. ) );
  1790. $statisticsClient = array ();
  1791. for($d = 0; $d <= 29; $d ++) {
  1792. $MD = date ( "m-d", strtotime ( "-" . $d . " day" ) );
  1793. $falgClient = true;
  1794. foreach ( $actionLogClient as $value ) {
  1795. if ($value ['updatetime'] == $MD) {
  1796. array_push ( $statisticsClient, $value ['count'] );
  1797. $falgClient = false;
  1798. break;
  1799. }
  1800. }
  1801. if ($falgClient)
  1802. array_push ( $statisticsClient, 0 );
  1803. }
  1804. $statisticsClient = array_reverse ( $statisticsClient );
  1805. $jsc = json_encode ( $statisticsClient );
  1806. $redis->set ( $redisKeyC, $jsc );
  1807. // 全员添加数量的redis值
  1808. $redisKey = date ( 'Y-m-d' ) . 'SC__';
  1809. $action_log = new action_log ();
  1810. $actionLogClient = $action_log->find ( array (
  1811. 'select' => 'date_format(updatetime,"%m-%d") as updatetime,COUNT(*) as count',
  1812. 'where' => $alCondition . ' status=1 and date_sub(curdate(), INTERVAL 30 DAY) <= date(updatetime)',
  1813. 'groupby' => 'date_format(updatetime,"%m-%d")',
  1814. 'asArray' => true
  1815. ) );
  1816. $statisticsClient = array ();
  1817. for($d = 0; $d <= 29; $d ++) {
  1818. $MD = date ( "m-d", strtotime ( "-" . $d . " day" ) );
  1819. $falgClient = true;
  1820. foreach ( $actionLogClient as $value ) {
  1821. if ($value ['updatetime'] == $MD) {
  1822. array_push ( $statisticsClient, $value ['count'] );
  1823. $falgClient = false;
  1824. break;
  1825. }
  1826. }
  1827. if ($falgClient)
  1828. array_push ( $statisticsClient, 0 );
  1829. }
  1830. $statisticsClient = array_reverse ( $statisticsClient );
  1831. $jsc = json_encode ( $statisticsClient );
  1832. $redis->set ( $redisKey, $jsc );
  1833. }
  1834. return "/contacts";
  1835. }
  1836. function mycompany() {
  1837. $search = $this->get_args ( 'search' ) ? $this->get_args ( 'search' ) : "";
  1838. $districtLv = $this->get_args ( 'districtLv' ) ? $this->get_args ( 'districtLv' ) : 0;
  1839. $nature = $this->get_args ( 'nature' ) ? $this->get_args ( 'nature' ) : "";
  1840. $lv1 = $this->get_args ( 'lv1' ) ? $this->get_args ( 'lv1' ) : 0;
  1841. $lv2 = $this->get_args ( 'lv2' ) ? $this->get_args ( 'lv2' ) : 0;
  1842. $lv3 = $this->get_args ( 'lv3' ) ? $this->get_args ( 'lv3' ) : 0;
  1843. $tagList = $this->get_args ( 'tag' ) ? $this->get_args ( 'tag' ) : array ();
  1844. if ($lv1 == 0) {
  1845. $lv1 = isset ( $this->params ['lv1'] ) && is_numeric ( $this->params ['lv1'] ) ? $this->params ['lv1'] : 0;
  1846. if ($lv1 != 0)
  1847. $districtLv = 1;
  1848. }
  1849. if ($lv2 == 0) {
  1850. $lv2 = isset ( $this->params ['lv2'] ) && is_numeric ( $this->params ['lv2'] ) ? $this->params ['lv2'] : 0;
  1851. if ($lv2 != 0)
  1852. $districtLv = 2;
  1853. }
  1854. if ($lv3 == 0) {
  1855. $lv3 = isset ( $this->params ['lv3'] ) && is_numeric ( $this->params ['lv3'] ) ? $this->params ['lv3'] : 0;
  1856. if ($lv2 != 0)
  1857. $districtLv = 3;
  1858. }
  1859. if (empty ( $search ))
  1860. $search = urldecode ( isset ( $this->params ['search'] ) ? $this->params ['search'] : "" );
  1861. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  1862. $data ['memu'] = "contacts";
  1863. $data ['staff'] = $this->staff;
  1864. Doo::loadModel ( 'district' );
  1865. Doo::loadModel ( 'company' );
  1866. Doo::loadModel ( 'client' );
  1867. Doo::loadModel ( 'tag' );
  1868. Doo::loadModel ( 'L_category' );
  1869. $lcategory = new L_category ();
  1870. $tag = new tag ();
  1871. $client = new client ();
  1872. $company = new company ();
  1873. $district = new district ();
  1874. Doo::loadModel ( 'tagCompany' );
  1875. $tagCompany = new tagCompany ();
  1876. Doo::loadModel ( 'tagCompanyNexus' );
  1877. $tagCompanyNexus = new tagCompanyNexus ();
  1878. $data ['district2'] = $district->get_lv ( 1 );
  1879. $category = $lcategory->getCategoryById ( $this->staff [0] ['cid'], $this->staff [0] ['othercid'] );
  1880. $cateStr = " cid =0 ";
  1881. Doo::loadClass ( 'XDeode' );
  1882. $XDeode = new XDeode ( 5 );
  1883. $didList = explode ( ',', $this->staff [0] ['did'] );
  1884. $didList = array_filter ( $didList );
  1885. $didListContont = array ();
  1886. if (! empty ( $didList )) {
  1887. foreach ( $didList as $key => $value ) {
  1888. array_push ( $didListContont, $XDeode->decode ( $value ) );
  1889. }
  1890. $data ['district'] = $district->getDistrictInId ( implode ( ',', $didListContont ) ); // $district->get_lvByStaffid ( 1, $this->staff [0] ['sid'] );
  1891. } else {
  1892. $data ['district'] = array ();
  1893. }
  1894. $sqstr = '';
  1895. if (! empty ( $didListContont )) {
  1896. foreach ( $didListContont as $key => $value ) {
  1897. if ($key != 0) {
  1898. $sqstr .= " or district like '" . $value . ",%'";
  1899. }
  1900. }
  1901. $cateStr = " ( district like '" . $didListContont [0] . ",%'" . $sqstr . ')';
  1902. }
  1903. // $list = array ();
  1904. // foreach ( $category as $key => $value ) {
  1905. // array_push ( $list, " district like '" . $value ['districtid'] . ",%' " );
  1906. // }
  1907. // if ($this->staff [0] ['isadmin'] != 1)
  1908. // $cateStr = implode ( " or ", $list );
  1909. // else
  1910. // $cateStr = " 1";
  1911. //
  1912. // if (! empty ( $nature ))
  1913. // $cateStr = " 1";
  1914. $size = 300;
  1915. $data ['htmllv2'] = array ();
  1916. $data ['htmllv3'] = array ();
  1917. $condition = "";
  1918. if ($districtLv == 1) {
  1919. $condition = "";
  1920. if (! empty ( $lv1 )) {
  1921. $condition = " district like '" . $lv1 . ",%'";
  1922. $data ['htmllv2'] = $district->get_lvByid ( 2, $lv1 );
  1923. }
  1924. }
  1925. if ($districtLv == 2) {
  1926. if (! empty ( $lv2 ))
  1927. $condition = " district like '" . $lv1 . "," . $lv2 . ",%'";
  1928. else
  1929. $condition = " district like '" . $lv1 . ",%'";
  1930. $data ['htmllv2'] = $district->get_lvByid ( 2, $lv1 );
  1931. $data ['htmllv3'] = $district->get_lvByid ( 2, $lv2 );
  1932. }
  1933. if ($districtLv == 3) {
  1934. if (! empty ( $lv3 ))
  1935. $condition = " district like '" . $lv1 . "," . $lv2 . "," . $lv3 . "'";
  1936. else
  1937. $condition = " district like '" . $lv1 . "," . $lv2 . ",%'";
  1938. $data ['htmllv2'] = $district->get_lvByid ( 2, $lv1 );
  1939. $data ['htmllv3'] = $district->get_lvByid ( 2, $lv2 );
  1940. }
  1941. $districtCount = $condition;
  1942. if (! empty ( $condition ))
  1943. $cateStr = $condition;
  1944. if (! empty ( $nature ))
  1945. $cateStr .= " and nature like '%" . $nature . "%'";
  1946. // echo "<div style='display:none'>".$cateStr."</div><br/>";
  1947. $tagSQL = false;
  1948. if (! empty ( $tagList )) {
  1949. $tagSQL = true;
  1950. foreach ( $tagList as $value ) {
  1951. $cateStr .= " and a.tag like '%" . $value . "%' ";
  1952. }
  1953. }
  1954. if ($this->staff [0] ['isadmin'] != 1) {
  1955. $pageinfo = $this->get_Tpage ( "CLD_company", $cateStr, $page, $size, "", $tagSQL );
  1956. } else {
  1957. if ($tagSQL)
  1958. $pageinfo = $this->get_Tpage ( "CLD_company", $cateStr, $page, $size, "", $tagSQL );
  1959. else {
  1960. $total_page = $company->count ( array () );
  1961. $total = intval ( $total_page / $size );
  1962. $pageinfo ['total_page'] = ($total_page % $size) == 0 ? $total : $total + 1;
  1963. }
  1964. }
  1965. $k = "";
  1966. for($i = 1; $i <= $pageinfo ['total_page']; $i ++) {
  1967. if ($page == $i)
  1968. $k .= "<option value='" . $search . ":" . $i . ":" . $lv1 . ":" . $lv2 . ":" . $lv3 . "' selected>第" . $i . "页</option>";
  1969. else
  1970. $k .= "<option value='" . $search . ":" . $i . ":" . $lv1 . ":" . $lv2 . ":" . $lv3 . "'>第" . $i . "页</option>";
  1971. }
  1972. $data ['pageinfo'] = $k;
  1973. $data ['company'] = $company->getCompanyByDistrict ( $this->staff [0] ['sid'], $cateStr, $this->staff [0] ['isadmin'], $page, $size, $tagSQL );
  1974. // if ($this->staff [0] ['isadmin'] != 1) {
  1975. // $data ['district'] = $district->get_lvByStaffid ( 1, $this->staff [0] ['sid'] );
  1976. // } else {
  1977. // $data ['district'] = $data ['district2'];
  1978. // }
  1979. // 获得标签
  1980. $ClientTagList = $tagCompanyNexus->getTagClientBySid ( $this->staff [0] ['sid'] );
  1981. foreach ( $ClientTagList as $key => $value ) {
  1982. $ClientTagList [$key] ['taginfo'] = $tagCompany->getTagByTidL ( $value ['tag'] );
  1983. }
  1984. foreach ( $data ['company'] as $key => $value ) {
  1985. if (! empty ( $value ['cid'] )) {
  1986. $data ['company'] [$key] ['taginfo'] = array ();
  1987. $data ['company'] [$key] ['tag'] = "";
  1988. foreach ( $ClientTagList as $k => $v ) {
  1989. if ($value ['cid'] == $v ['company']) {
  1990. $data ['company'] [$key] ['taginfo'] = $v ['taginfo'];
  1991. $data ['company'] [$key] ['tag'] = $v ['tag'];
  1992. }
  1993. }
  1994. }
  1995. }
  1996. $comcid = $countL = array ();
  1997. foreach ( $data ['company'] as $key => $value ) {
  1998. array_push ( $comcid, $value ['cid'] );
  1999. }
  2000. $comcid = implode ( ",", $comcid );
  2001. if (! empty ( $comcid ))
  2002. $countL = $client->getCountByCompany ( $comcid );
  2003. foreach ( $data ['company'] as $key => $value ) {
  2004. $data ['company'] [$key] ['count'] = 0;
  2005. foreach ( $countL as $k => $v ) {
  2006. if ($value ['cid'] == $v ['companyid']) {
  2007. $data ['company'] [$key] ['count'] = $v ['count'];
  2008. break;
  2009. }
  2010. }
  2011. }
  2012. $CC1 = "";
  2013. $CC2 = "";
  2014. $CC3 = "";
  2015. $natureHtml = '';
  2016. if (! empty ( $districtCount )) {
  2017. $clientCount = $company->find ( array (
  2018. 'select' => 'district',
  2019. 'where' => "district like '" . $lv1 . ",%'",
  2020. 'asArray' => TRUE
  2021. ) );
  2022. $CC1 = count ( $clientCount );
  2023. if (! empty ( $clientCount ) && ! empty ( $lv2 )) {
  2024. $CC2 = 0;
  2025. foreach ( $clientCount as $key => $value ) {
  2026. if (strpos ( $value ['district'], $lv2 )) {
  2027. $CC2 ++;
  2028. }
  2029. }
  2030. }
  2031. if (! empty ( $clientCount ) && ! empty ( $lv3 )) {
  2032. $CC3 = 0;
  2033. foreach ( $clientCount as $key => $value ) {
  2034. if (strpos ( $value ['district'], $lv3 )) {
  2035. $CC3 ++;
  2036. }
  2037. }
  2038. }
  2039. $clientCount = $company->find ( array (
  2040. 'select' => 'district,nature',
  2041. 'where' => $districtCount,
  2042. 'asArray' => TRUE
  2043. ) );
  2044. $natureCount = array ();
  2045. foreach ( $this->nature as $value ) {
  2046. $natureCount [$value] = 0;
  2047. foreach ( $clientCount as $v ) {
  2048. $ak = explode ( ",", $v ['nature'] );
  2049. foreach ( $ak as $a ) {
  2050. if ($value == $a) {
  2051. $natureCount [$value] ++;
  2052. }
  2053. }
  2054. }
  2055. }
  2056. }
  2057. $natureHtml = '';
  2058. foreach ( $this->nature as $value ) {
  2059. $natureHtml .= '<a href="javascript:void(0)" ';
  2060. if ($value == $nature)
  2061. $natureHtml .= 'class="now"';
  2062. if (isset ( $natureCount [$value] ))
  2063. $natureHtml .= 'onclick="showNature(\'' . $value . '\',this)">' . $value . '(' . $natureCount [$value] . ')</a>';
  2064. else
  2065. $natureHtml .= 'onclick="showNature(\'' . $value . '\',this)">' . $value . '</a>';
  2066. }
  2067. $taglist = $tagCompany->find ( array (
  2068. 'where' => 'sid=' . $this->staff [0] ['sid'],
  2069. 'asArray' => TRUE
  2070. ) );
  2071. if (empty ( $taglist )) {
  2072. for($i = 1; $i <= 7; $i ++) {
  2073. $tag = new tagCompany ();
  2074. $tag->name = "个人标签";
  2075. $tag->sid = $this->staff [0] ['sid'];
  2076. $tag->colorid = $i;
  2077. $tag->insert ();
  2078. }
  2079. }
  2080. $data ['product'] = array ();
  2081. $data ['tagList'] = $tagList;
  2082. $data ['tag'] = $tagCompany->getAllBySid ( $this->staff [0] ['sid'] );
  2083. $data ['natureHtml'] = $natureHtml;
  2084. $data ['CC1'] = $CC1;
  2085. $data ['CC2'] = $CC2;
  2086. $data ['CC3'] = $CC3;
  2087. $data ['lv1'] = $lv1;
  2088. $data ['lv2'] = $lv2;
  2089. $data ['lv3'] = $lv3;
  2090. $data ['districtLv'] = $districtLv;
  2091. $data ['Hnature'] = $nature;
  2092. $data ['nature'] = $this->nature;
  2093. $this->render ( "/contacts_company", $data );
  2094. }
  2095. function contacts() {
  2096. $data ['memu'] = "contacts";
  2097. $data ['staff'] = $this->staff;
  2098. $search = $this->get_args ( 'search' ) ? trim ( $this->get_args ( 'search' ) ) : "";
  2099. if (empty ( $search ))
  2100. $search = urldecode ( isset ( $this->params ['search'] ) ? $this->params ['search'] : "" );
  2101. $lv1 = $this->get_args ( 'lv1' ) ? $this->get_args ( 'lv1' ) : 0;
  2102. $lv2 = $this->get_args ( 'lv2' ) ? $this->get_args ( 'lv2' ) : 0;
  2103. $lv3 = $this->get_args ( 'lv3' ) ? $this->get_args ( 'lv3' ) : 0;
  2104. $lv4 = $this->get_args ( 'lv4' ) ? $this->get_args ( 'lv4' ) : "";
  2105. $tagList = $this->get_args ( 'tag' ) ? $this->get_args ( 'tag' ) : array ();
  2106. $tooltip = $this->get_args ( 'tooltip' ) ? $this->get_args ( 'tooltip' ) : "";
  2107. $districtLv = $this->get_args ( 'districtLv' ) ? $this->get_args ( 'districtLv' ) : 0;
  2108. if ($lv1 == 0) {
  2109. $lv1 = isset ( $this->params ['lv1'] ) && is_numeric ( $this->params ['lv1'] ) ? $this->params ['lv1'] : 0;
  2110. if ($lv1 != 0)
  2111. $districtLv = 1;
  2112. }
  2113. if ($lv2 == 0) {
  2114. $lv2 = isset ( $this->params ['lv2'] ) && is_numeric ( $this->params ['lv2'] ) ? $this->params ['lv2'] : 0;
  2115. if ($lv2 != 0)
  2116. $districtLv = 2;
  2117. }
  2118. if ($lv3 == 0) {
  2119. $lv3 = isset ( $this->params ['lv3'] ) && is_numeric ( $this->params ['lv3'] ) ? $this->params ['lv3'] : 0;
  2120. if ($lv2 != 0)
  2121. $districtLv = 3;
  2122. }
  2123. $sortV = $this->get_args ( 'sortV' ) ? $this->get_args ( 'sortV' ) : "h";
  2124. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  2125. Doo::loadModel ( 'client_staff' );
  2126. Doo::loadModel ( 'client' );
  2127. Doo::loadModel ( 'tag' );
  2128. Doo::loadModel ( 'district' );
  2129. Doo::loadModel ( 'tag_client' );
  2130. Doo::loadModel ( 'L_category' );
  2131. Doo::loadModel ( 'longle' );
  2132. Doo::loadModel ( 'C_tooltip' );
  2133. $c_tooltip = new C_tooltip ();
  2134. $longle = new longle ();
  2135. $client = new client ();
  2136. $category = new L_category ();
  2137. $tagClient = new tag_client ();
  2138. $district = new district ();
  2139. $tag = new tag ();
  2140. $client_staff = new client_staff ();
  2141. $data ['tag'] = $tag->getAllBySid ( $this->staff [0] ['sid'] );
  2142. $data ['district2'] = $district->get_lv ( 1 );
  2143. $page_size = 200;
  2144. $linfo = $category->getCategoryById ( $this->staff [0] ['cid'], $this->staff ['0'] ['othercid'] );
  2145. $staffid = $condition = $a = "";
  2146. // if ($this->staff [0] ['isadmin'] != 1) {
  2147. // 加入办事处地区
  2148. Doo::loadClass ( 'XDeode' );
  2149. $XDeode = new XDeode ( 5 );
  2150. $didList = explode ( ',', $this->staff [0] ['did'] );
  2151. $didList = array_filter ( $didList );
  2152. $didListContont = array ();
  2153. if (! empty ( $didList )) {
  2154. foreach ( $didList as $key => $value ) {
  2155. array_push ( $didListContont, $XDeode->decode ( $value ) );
  2156. }
  2157. $data ['district'] = $district->getDistrictInId ( implode ( ',', $didListContont ) ); // $district->get_lvByStaffid ( 1, $this->staff [0] ['sid'] );
  2158. } else {
  2159. $data ['district'] = array ();
  2160. }
  2161. if (! empty ( $search ))
  2162. $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 . "%')";
  2163. else {
  2164. $a = '';
  2165. $sqstr = '';
  2166. if (! empty ( $didListContont )) {
  2167. $a = '';
  2168. foreach ( $didListContont as $key => $value ) {
  2169. if ($key != 0) {
  2170. $sqstr .= " or b.district like '" . $value . ",%'";
  2171. }
  2172. }
  2173. $a = "and ( b.district like '" . $didListContont [0] . ",%'" . $sqstr . ')';
  2174. }
  2175. if (! empty ( $tooltip ))
  2176. $sch = "";
  2177. $staffid = $data ['staff'] [0] ['sid'];
  2178. }
  2179. $data ['htmllv2'] = $data ['htmllv3'] = array ();
  2180. if ($districtLv == 1) {
  2181. $a = "";
  2182. $condition = "";
  2183. if (! empty ( $lv1 )) {
  2184. $condition .= " and district like '" . $lv1 . ",%'";
  2185. $data ['htmllv2'] = $district->get_lvByid ( 2, $lv1 );
  2186. }
  2187. }
  2188. if ($districtLv == 2) {
  2189. $a = "";
  2190. if (! empty ( $lv2 ))
  2191. $condition .= " and district like '" . $lv1 . "," . $lv2 . ",%'";
  2192. else
  2193. $condition .= " and district like '" . $lv1 . ",%'";
  2194. $data ['htmllv2'] = $district->get_lvByid ( 2, $lv1 );
  2195. $data ['htmllv3'] = $district->get_lvByid ( 2, $lv2 );
  2196. }
  2197. if ($districtLv == 3) {
  2198. $a = "";
  2199. if (! empty ( $lv3 ))
  2200. $condition .= " and district like '" . $lv1 . "," . $lv2 . "," . $lv3 . "'";
  2201. else
  2202. $condition .= " and district like '" . $lv1 . "," . $lv2 . ",%'";
  2203. $data ['htmllv2'] = $district->get_lvByid ( 2, $lv1 );
  2204. $data ['htmllv3'] = $district->get_lvByid ( 2, $lv2 );
  2205. }
  2206. $condition .= $a;
  2207. $districtCount = $condition;
  2208. if (! empty ( $lv4 )) {
  2209. $condition .= " and nature like '%" . $lv4 . "%'";
  2210. }
  2211. $tagSQL = false;
  2212. if (! empty ( $tagList )) {
  2213. $tagSQL = true;
  2214. foreach ( $tagList as $value ) {
  2215. $condition .= " and c.tag like '%" . $value . "%' ";
  2216. }
  2217. $search = "";
  2218. }
  2219. if (! empty ( $search ))
  2220. $condition .= $sch;
  2221. // if(!empty($tooltip))
  2222. // $condition.=" and tooltip like '%".$tooltip."%'";
  2223. $pageinfo = array (
  2224. 'lower' => 0,
  2225. 'total_page' => 0,
  2226. 'total_data' => 0
  2227. );
  2228. if (! empty ( $didListContont ) || ! empty ( $search ))
  2229. $pageinfo = $this->get_page ( "CLD_client_staff", $condition, $page, $page_size, "", "", "", $staffid, $search, $tooltip, $this->staff [0] ['cid'], $tagSQL );
  2230. if ($sortV == "h") { // order by a.cid desc
  2231. $limit = " order by cid desc limit " . $pageinfo ['lower'] . " , " . $page_size . " ";
  2232. }
  2233. if ($sortV == "g") { // order by updatetime desc
  2234. $limit = " limit " . $pageinfo ['lower'] . " , " . $page_size . " ";
  2235. }
  2236. if ($sortV == "f") { // order by updatetime desc
  2237. $limit = " limit " . $pageinfo ['lower'] . " , " . $page_size . " ";
  2238. }
  2239. if ($sortV == "i") { // order by servicetime desc
  2240. $limit = " limit " . $pageinfo ['lower'] . " , " . $page_size . " ";
  2241. }
  2242. // 检索是全局
  2243. // echo $condition;
  2244. $data ['clientInfo'] = array ();
  2245. if (! empty ( $didListContont ) || ! empty ( $search ))
  2246. $data ['clientInfo'] = $client_staff->getClientByStaff ( $condition, $limit, $staffid, $this->staff [0] ['sid'], $search, $tooltip, $this->staff [0] ['cid'], $tagSQL );
  2247. // 获取其他办事处的客户
  2248. // if(!empty($districtstr)){
  2249. // $buclient=$client->getClientByDistrict($districtstr);
  2250. //
  2251. // foreach ($buclient as $key=>$vlaue){
  2252. //
  2253. // $falg=true;
  2254. //
  2255. // foreach ($data['clientInfo'] as $y=>$v){
  2256. // if($vlaue['clientname']==$v['clientname']&&$vlaue['companyname']==$v['companyname'])
  2257. // $falg=false;
  2258. // }
  2259. // if($falg)
  2260. // array_push($data['clientInfo'], $vlaue);
  2261. // }
  2262. //
  2263. // }
  2264. $k = "";
  2265. for($i = 1; $i <= $pageinfo ['total_page']; $i ++) {
  2266. if ($page == $i)
  2267. $k .= "<option value='" . $search . ":" . $i . ":" . $lv1 . ":" . $lv2 . ":" . $lv3 . "' selected>第" . $i . "页</option>";
  2268. else
  2269. $k .= "<option value='" . $search . ":" . $i . ":" . $lv1 . ":" . $lv2 . ":" . $lv3 . "'>第" . $i . "页</option>";
  2270. }
  2271. $data ['pageinfo'] = $k;
  2272. Doo::loadModel ( 'product' );
  2273. $product = new product ();
  2274. $data ['nature'] = $this->nature;
  2275. $data ['product'] = $product->getProudct ();
  2276. // 获得标签
  2277. $ClientTagList = $tagClient->getTagClientBySid ( $this->staff [0] ['sid'] );
  2278. $toollist = $c_tooltip->find ( array (
  2279. 'where' => 'cateid=' . $this->staff [0] ['cid'],
  2280. 'asArray' => true
  2281. ) );
  2282. // $ToolTipList=$
  2283. foreach ( $ClientTagList as $key => $value ) {
  2284. $ClientTagList [$key] ['taginfo'] = $tag->getTagByTidL ( $value ['tag'] );
  2285. }
  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. if (isset($longleDetail[0])){
  2787. $data['longleDetail']=$longleDetail[0];
  2788. }else{
  2789. $data['longleDetail']=array();
  2790. }
  2791. $data ['longleLogHtml'] = $this->_getLongleLogHtml ( $longleLogDetail );
  2792. $data ['cid'] = $cid;
  2793. $data ['year'] = $year;
  2794. $data ['staff'] = $staff;
  2795. $data ['status'] = $status;
  2796. $data ['productName'] = $productW;
  2797. $data ['search'] =$search;
  2798. Doo::loadModel ( 'L_category' );
  2799. Doo::loadModel ( 'staff' );
  2800. Doo::loadModel ( 'product' );
  2801. $product = new product ();
  2802. $staff = new staff ();
  2803. $L_category = new L_category ();
  2804. $data ['product'] = $product->getProudct ();
  2805. $data ['staffu'] = $staff->getUserById ( $this->staff [0] ['sid'] );
  2806. $data ['category'] = $L_category->getCategory ();
  2807. $data ['staffList'] = $staff->getStaffByCid ( $cid );
  2808. if ($cid == 1)
  2809. $data ['cid'] = $data ['category'] [0] ['cid'];
  2810. $dateHtml = "";
  2811. $now = date ( "Y" );
  2812. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  2813. if ($YEARD <= $now) {
  2814. $dateHtml .= '<option ';
  2815. if ($data ['year'] == $YEARD) {
  2816. $dateHtml .= 'selected ';
  2817. }
  2818. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  2819. }
  2820. }
  2821. $data ['dateHtml'] = $dateHtml;
  2822. $this->render ( "/lock_look", $data );
  2823. }
  2824. function keyStatistics() {
  2825. Doo::loadModel ( 'staff' );
  2826. $staff = new staff ();
  2827. Doo::loadModel ( 'longle' );
  2828. $longle = new longle ();
  2829. $staffCondition = "";
  2830. if ($this->staff [0] ['cid'] != 12)
  2831. $staffCondition = " and cid=" . $this->staff [0] ['cid'];
  2832. $staffList = $staff->find ( array (
  2833. 'where' => "isadmin= 0 " . $staffCondition,
  2834. 'asArray' => TRUE
  2835. ) );
  2836. Doo::db ()->beginTransaction ();
  2837. foreach ( $staffList as $key => $value ) { // not in(1,2)
  2838. $sum = $longle->count ( array (
  2839. 'where' => "status!= 1 and responsible ='" . $value ['username'] . "'",
  2840. 'asArray' => TRUE
  2841. ) );
  2842. $a = $longle->count ( array (
  2843. 'where' => "status!= 2 and status!= 1 and responsible ='" . $value ['username'] . "'",
  2844. 'asArray' => TRUE
  2845. ) );
  2846. $b = $sum - $a;
  2847. $staffList [$key] ['sum'] = $sum;
  2848. $staffList [$key] ['a'] = $a;
  2849. $staffList [$key] ['b'] = $b;
  2850. }
  2851. Doo::db ()->commit ();
  2852. $data ['staff'] = $this->staff;
  2853. $data ['staffList'] = $staffList;
  2854. $data ['memu'] = "keyStatistics";
  2855. $this->render ( "lock_count", $data );
  2856. }
  2857. function addDoLockLog() {
  2858. Doo::loadModel ( 'longle_log' );
  2859. Doo::loadModel ( 'longle' );
  2860. Doo::loadModel ( "action_log" );
  2861. Doo::loadModel ( 'client' );
  2862. $clientobj = new client ();
  2863. $longle = new longle ();
  2864. $longle_log = new longle_log ();
  2865. Doo::loadModel ( 'district' );
  2866. $district = new district ();
  2867. $status = $this->get_args ( 'longleStatus' ) ? $this->get_args ( 'longleStatus' ) : 0;
  2868. $lidKey = $this->get_args ( 'klid' ) ? $this->get_args ( 'klid' ) : 0;
  2869. $name = $this->get_args ( 'name' ) ? $this->get_args ( 'name' ) : "";
  2870. $company = $this->get_args ( 'company' ) ? $this->get_args ( 'company' ) : '';
  2871. $alloted_time = $this->get_args ( 'alloted_time' ) ? $this->get_args ( 'alloted_time' ) : '';
  2872. if (empty ( $lidKey ))
  2873. return "/keyonline/";
  2874. Doo::loadClass ( 'XDeode' );
  2875. $XDeode = new XDeode ( 5 );
  2876. $lid = $XDeode->decode ( $lidKey );
  2877. $linfo = $longle->getLongleByLid ( $lid );
  2878. if ($status == 0)
  2879. return "/keyonline/" . $lid;
  2880. elseif ($status == 3) {
  2881. $clientname = $clientobj->getClientByName2 ( $name, $company );
  2882. if (empty ( $clientname ))
  2883. return "/keyonline/" . $lid;
  2884. if ($name != "") {
  2885. $longle->client = $name;
  2886. $longle->clientid = $clientname [0] ['cid'];
  2887. }
  2888. // if($product!="")
  2889. // $longle->product=$product;
  2890. $longle->statusT = "借出";
  2891. $longle_log->client = $name;
  2892. $longle_log->clientid = $clientname [0] ['cid'];
  2893. $longle_log->product = $linfo [0] ['product'];
  2894. $longle_log->statusT = "借出";
  2895. // 日常行为
  2896. $action_log = new action_log ();
  2897. $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'] . ')';
  2898. $action_log->sid = $this->staff [0] ['sid'];
  2899. $action_log->cid = $this->staff [0] ['cid'];
  2900. $action_log->updatetime = date ( "Y-m-d" );
  2901. $action_log->time = date ( "H:i" );
  2902. $action_log->status = 4;
  2903. $action_log->districtid = $clientname [0] ['district'];
  2904. $local = $district->getbyidlist ( $clientname [0] ['district'] );
  2905. $action_log->city = $local [0] ['name'];
  2906. $action_log->province = $local [1] ['name'];
  2907. $action_log->company = $clientname [0] ['companyname'];
  2908. Doo::loadModel ( 'company' );
  2909. $company = new company ();
  2910. $companyInfo = $company->getOne ( array (
  2911. 'where' => ' companyname="' . $clientname [0] ['companyname'] . '"',
  2912. 'asArray' => true
  2913. ) );
  2914. $nature = explode ( ',', $companyInfo ['nature'] );
  2915. $action_log->nature = $nature [0];
  2916. $action_log->class = $action_log->iconBorrow;
  2917. $action_log->insert ();
  2918. } elseif ($status == 4) {
  2919. $clientname = $clientobj->getClientByName2 ( $name, $company );
  2920. if (empty ( $clientname ))
  2921. return "/keyonline/" . $lid;
  2922. if ($name != "") {
  2923. $longle->client = $name;
  2924. $longle->clientid = $clientname [0] ['cid'];
  2925. }
  2926. $longle->statusT = "销售";
  2927. $longle_log->client = $name;
  2928. $longle_log->clientid = $clientname [0] ['cid'];
  2929. $longle_log->product = $linfo [0] ['product'];
  2930. $longle_log->statusT = "销售";
  2931. // 日常行为
  2932. $action_log = new action_log ();
  2933. $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'] . ')';
  2934. $action_log->sid = $this->staff [0] ['sid'];
  2935. $action_log->cid = $this->staff [0] ['cid'];
  2936. $action_log->updatetime = date ( "Y-m-d" );
  2937. $action_log->time = date ( "H:i" );
  2938. $action_log->status = 5;
  2939. $action_log->districtid = $clientname [0] ['district'];
  2940. $local = $district->getbyidlist ( $clientname [0] ['district'] );
  2941. $action_log->city = $local [0] ['name'];
  2942. $action_log->province = $local [1] ['name'];
  2943. $action_log->company = $clientname [0] ['companyname'];
  2944. Doo::loadModel ( 'company' );
  2945. $company = new company ();
  2946. $companyInfo = $company->getOne ( array (
  2947. 'where' => ' companyname="' . $clientname [0] ['companyname'] . '"',
  2948. 'asArray' => true
  2949. ) );
  2950. $nature = explode ( ',', $companyInfo ['nature'] );
  2951. $action_log->nature = $nature [0];
  2952. $action_log->class = $action_log->iconSell;
  2953. $action_log->insert ();
  2954. } elseif ($status == 5) {
  2955. $product = $this->get_args ( 'newProduct' ) ? $this->get_args ( 'newProduct' ) : "";
  2956. if ($product != "")
  2957. $longle->product = $linfo [0] ['product'] . "+" . $product;
  2958. $longle->statusT = "升级";
  2959. $longle_log->product = $linfo [0] ['product'] . "+" . $product;
  2960. $longle_log->statusT = "升级";
  2961. $longle_log->client = $linfo [0] ['client'];
  2962. $longle_log->clientid = $linfo [0] ['clientid'];
  2963. $clientname = $clientobj->getOne ( array (
  2964. 'where' => "cid= '" . $linfo [0] ['clientid'] . "'",
  2965. 'asArray' => TRUE
  2966. ) );
  2967. // 日常行为
  2968. $action_log = new action_log ();
  2969. $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>';
  2970. $action_log->sid = $this->staff [0] ['sid'];
  2971. $action_log->cid = $this->staff [0] ['cid'];
  2972. $action_log->updatetime = date ( "Y-m-d" );
  2973. $action_log->time = date ( "H:i" );
  2974. $action_log->class = $action_log->iconUpdate;
  2975. $action_log->sid = $this->staff [0] ['sid'];
  2976. $action_log->cid = $this->staff [0] ['cid'];
  2977. $action_log->status = 7;
  2978. $action_log->insert ();
  2979. } elseif ($status == 6) {
  2980. $key_num = $this->get_args ( 'key_num' ) ? $this->get_args ( 'key_num' ) : "";
  2981. $key_num2 = explode ( "-", $key_num );
  2982. $key_num = $key_num2 [0] . "-" . $key_num2 [1];
  2983. // if($key_num!="")
  2984. // $longle->key_num=$key_num;
  2985. // 新锁拷贝记录
  2986. $newLongle = new longle ();
  2987. // $newLongle->product=$linfo[0]['product'];
  2988. $newLongle->statusT = "更换";
  2989. $newLongle->status = 6;
  2990. $newLongle->client = $linfo [0] ['client'];
  2991. $newLongle->clientid = $linfo [0] ['clientid'];
  2992. $newlid = $newLongle->update ( array (
  2993. 'where' => ' key_num= \'' . $key_num . "'"
  2994. ) );
  2995. $longleinfo = $longle->getOne ( array (
  2996. 'where' => ' key_num =\'' . $key_num . "'",
  2997. 'asArray' => true
  2998. ) );
  2999. $longleLog = $longle_log->getOne ( array (
  3000. 'where' => ' lid =' . $linfo [0] ['lid'],
  3001. 'desc' => 'logid',
  3002. 'asArray' => true
  3003. ) );
  3004. // 新记录日志
  3005. $newlongle_log = new longle_log ();
  3006. $newlongle_log->statusT = "更换";
  3007. $newlongle_log->status = 6;
  3008. $newlongle_log->client = $linfo [0] ['client'];
  3009. $newlongle_log->new_key_num = $linfo [0] ['key_num'];
  3010. $newlongle_log->product = $linfo [0] ['product'];
  3011. $newlongle_log->category = $this->staff [0] ['category'];
  3012. $newlongle_log->dateline = date ( "Y-m-d" );
  3013. $newlongle_log->operator = $this->staff [0] ['username'];
  3014. $newlongle_log->lid = $longleinfo ['lid'];
  3015. $newlongle_log->insert ();
  3016. $newlongle_log = new longle_log ();
  3017. $newlongle_log->statusT = $longleLog ['statusT'];
  3018. $newlongle_log->status = $longleLog ['status'];
  3019. $newlongle_log->client = $longleLog ['client'];
  3020. $newlongle_log->new_key_num = $longleLog ['new_key_num'];
  3021. $newlongle_log->product = $longleLog ['product'];
  3022. $newlongle_log->category = $longleLog ['category'];
  3023. $newlongle_log->dateline = $longleLog ['dateline'];
  3024. $newlongle_log->operator = $longleLog ['operator'];
  3025. $newlongle_log->lid = $longleinfo ['lid'];
  3026. $newlongle_log->insert ();
  3027. $newLongle = new longle ();
  3028. $newLongle->statusT = $longleLog ['statusT'];
  3029. $newLongle->status = $longleLog ['status'];
  3030. $newlid = $newLongle->update ( array (
  3031. 'where' => ' key_num= \'' . $key_num . "'"
  3032. ) );
  3033. // 新锁状态拷贝
  3034. $longle->statusT = "更换";
  3035. $longle_log->new_key_num = $key_num;
  3036. $longle_log->statusT = "更换";
  3037. $longle_log->client = $linfo [0] ['client'];
  3038. $clientname = $clientobj->getOne ( array (
  3039. 'where' => "cid= '" . $linfo [0] ['clientid'] . "'",
  3040. 'asArray' => TRUE
  3041. ) );
  3042. // 日常行为
  3043. $action_log = new action_log ();
  3044. $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'] . ')';
  3045. $action_log->sid = $this->staff [0] ['sid'];
  3046. $action_log->cid = $this->staff [0] ['cid'];
  3047. $action_log->updatetime = date ( "Y-m-d" );
  3048. $action_log->time = date ( "H:i" );
  3049. $action_log->class = $action_log->iconReplace;
  3050. $action_log->sid = $this->staff [0] ['sid'];
  3051. $action_log->cid = $this->staff [0] ['cid'];
  3052. $action_log->status = 8;
  3053. $action_log->insert ();
  3054. } elseif ($status == 7) {
  3055. $longle->statusT = "收回";
  3056. $longle_log->statusT = "收回";
  3057. $longle_log->responsible = $linfo [0] ['responsible'];
  3058. // 日常行为
  3059. $action_log = new action_log ();
  3060. $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>';
  3061. $action_log->sid = $this->staff [0] ['sid'];
  3062. $action_log->cid = $this->staff [0] ['cid'];
  3063. $action_log->updatetime = date ( "Y-m-d" );
  3064. $action_log->time = date ( "H:i" );
  3065. $action_log->class = $action_log->iconRecycle;
  3066. $action_log->sid = $this->staff [0] ['sid'];
  3067. $action_log->cid = $this->staff [0] ['cid'];
  3068. $action_log->status = 9;
  3069. $action_log->insert ();
  3070. } elseif ($status == 8) {
  3071. $mark = $this->get_args ( 'mark' ) ? $this->get_args ( 'mark' ) : "";
  3072. if (empty ( $mark )) {
  3073. echo json_encode ( array (
  3074. 'msg' => 2
  3075. ) );
  3076. die ();
  3077. }
  3078. $longle_log->mark = $mark;
  3079. // 日常行为
  3080. $action_log = new action_log ();
  3081. $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>添加新备注。';
  3082. $action_log->sid = $this->staff [0] ['sid'];
  3083. $action_log->cid = $this->staff [0] ['cid'];
  3084. $action_log->updatetime = date ( "Y-m-d" );
  3085. $action_log->time = date ( "H:i" );
  3086. $action_log->sid = $this->staff [0] ['sid'];
  3087. $action_log->cid = $this->staff [0] ['cid'];
  3088. $action_log->status = 10;
  3089. $action_log->class = $action_log->iconLock;
  3090. $action_log->insert ();
  3091. } elseif ($status == 9) {
  3092. $longle->statusT = "赠送";
  3093. $longle_log->statusT = "赠送";
  3094. $clientname = $clientobj->getClientByName2 ($name, $company );
  3095. if (empty ( $clientname ))
  3096. return "/keyonline/" . $lid;
  3097. if ($name != "") {
  3098. $longle->client = $name;
  3099. $longle->clientid = $clientname [0] ['cid'];
  3100. }
  3101. $longle_log->client = $name;
  3102. $longle_log->clientid = $clientname [0] ['cid'];
  3103. // 日常行为
  3104. $action_log = new action_log ();
  3105. $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'] . ')';
  3106. $action_log->updatetime = date ( "Y-m-d" );
  3107. $action_log->time = date ( "H:i" );
  3108. $action_log->class = $action_log->iconRecycle;
  3109. $action_log->sid = $this->staff [0] ['sid'];
  3110. $action_log->cid = $this->staff [0] ['cid'];
  3111. $action_log->status = 6;
  3112. $action_log->districtid = $clientname [0] ['district'];
  3113. $local = $district->getbyidlist ( $clientname [0] ['district'] );
  3114. $action_log->city = $local [0] ['name'];
  3115. $action_log->province = $local [1] ['name'];
  3116. $action_log->company = $clientname [0] ['companyname'];
  3117. Doo::loadModel ( 'company' );
  3118. $company = new company ();
  3119. $companyInfo = $company->getOne ( array (
  3120. 'where' => ' companyname="' . $clientname [0] ['companyname'] . '"',
  3121. 'asArray' => true
  3122. ) );
  3123. $nature = explode ( ',', $companyInfo ['nature'] );
  3124. $action_log->nature = $nature [0];
  3125. $action_log->insert ();
  3126. }elseif($status == 10){
  3127. $longle->alloted_time = $alloted_time;
  3128. $longle_log->mark ='由'.$linfo[0]['alloted_time'].'延期至'.$alloted_time;
  3129. // 日常行为
  3130. $action_log = new action_log ();
  3131. $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;
  3132. $action_log->sid = $this->staff [0] ['sid'];
  3133. $action_log->cid = $this->staff [0] ['cid'];
  3134. $action_log->updatetime = date ( "Y-m-d" );
  3135. $action_log->time = date ( "H:i" );
  3136. $action_log->sid = $this->staff [0] ['sid'];
  3137. $action_log->cid = $this->staff [0] ['cid'];
  3138. $action_log->status = 12;
  3139. $action_log->class = $action_log->iconLock;
  3140. $action_log->insert ();
  3141. }
  3142. // 记录使用过的状态
  3143. $statuslog = $status . "," . $linfo [0] ['statuslog'];
  3144. $ar = explode ( ',', $statuslog );
  3145. $statuslog = implode ( ',', array_unique ( array_filter ( $ar ) ) );
  3146. $longle->statuslog = $statuslog;
  3147. if ($linfo [0] ['status'] <= 2) {
  3148. if ($status >= 4 && $status <= 2) {
  3149. return "/keyonline/" . $lid;
  3150. }
  3151. }
  3152. if ($lid != 0) {
  3153. $longle->lid = $lid;
  3154. if (!($status == 8||$status == 10))
  3155. $longle->status = $status;
  3156. // if($status!=8)
  3157. $longle->responsible = $this->staff [0] ['username'];
  3158. $longle->update ();
  3159. }
  3160. $longle_log->lid = $lid;
  3161. $longle_log->status = $status;
  3162. $longle_log->operator = $this->staff [0] ['username'];
  3163. // 责任人
  3164. $longle_log->category = $this->staff [0] ['category'];
  3165. $longle_log->dateline = date ( "Y-m-d" );
  3166. $longle_log->insert ();
  3167. echo json_encode ( array (
  3168. 'msg' => 1
  3169. ) );
  3170. die ();
  3171. // return "/keyonline/".$lid;
  3172. }
  3173. function ajaxGetLongleByName() {
  3174. Doo::loadModel ( 'longle_log' );
  3175. Doo::loadModel ( 'longle' );
  3176. $longle = new longle ();
  3177. $longle_log = new longle_log ();
  3178. $name = $this->get_args ( 'name' ) ? $this->get_args ( 'name' ) : "";
  3179. if (empty ( $name )) {
  3180. echo json_encode ( array (
  3181. "success" => false
  3182. ) );
  3183. die ();
  3184. }
  3185. $ky = $longle->getLongleBykeynum ( $name );
  3186. $t = $longle_log->getLongleByLid ( $ky [0] ['lid'] );
  3187. if (isset ( $t [0] ))
  3188. $tk = $t [0];
  3189. else
  3190. $tk = array ();
  3191. $longleLog = $tk;
  3192. $longleLog ['klid'] = $t [0] ['lid'];
  3193. $longleLog ['longle'] = $ky [0];
  3194. $longleLog ['longleLogHtml'] = $this->_getLongleLogHtml ( $t );
  3195. echo json_encode ( $longleLog );
  3196. }
  3197. function ajaxGetLongleN() {
  3198. Doo::loadModel ( 'longle_log' );
  3199. Doo::loadModel ( 'longle' );
  3200. $longle = new longle ();
  3201. $longle_log = new longle_log ();
  3202. $keynum = $this->get_args ( 'keynum' ) ? $this->get_args ( 'keynum' ) : "";
  3203. if (empty ( $keynum )) {
  3204. echo json_encode ( array (
  3205. "success" => false
  3206. ) );
  3207. die ();
  3208. }
  3209. $ky = $longle->getLongleBykeynum ( $keynum );
  3210. if (! empty ( $ky )) {
  3211. $t = $longle_log->getLongleByLid ( $ky [0] ['lid'] );
  3212. if (isset ( $t [0] ))
  3213. $tk = $t [0];
  3214. else
  3215. $tk = array ();
  3216. $longleLog = $tk;
  3217. $longleLog ['klid'] = $ky [0] ['lid'];
  3218. $longleLog ['longle'] = $ky [0];
  3219. $longleLog ['longleLogHtml'] = $this->_getLongleLogHtml ( $t );
  3220. echo json_encode ( $longleLog );
  3221. }
  3222. }
  3223. function ajaxGetLongle() {
  3224. Doo::loadModel ( 'longle_log' );
  3225. Doo::loadModel ( 'longle' );
  3226. $longle = new longle ();
  3227. $longle_log = new longle_log ();
  3228. Doo::loadClass ( 'XDeode' );
  3229. $XDeode = new XDeode ( 5 );
  3230. $lid = $this->get_args ( 'lid' ) ? $this->get_args ( 'lid' ) : 0;
  3231. if ($lid == 0) {
  3232. echo json_encode ( array (
  3233. "success" => false
  3234. ) );
  3235. die ();
  3236. }
  3237. $t = $longle_log->getLongleByLid ( $lid );
  3238. if (isset ( $t [0] ))
  3239. $tk = $t [0];
  3240. else
  3241. $tk = array ();
  3242. $longleLog = $tk;
  3243. $longleLog ['klid'] = $lid;
  3244. $longleLog ['lidKey'] =$XDeode->encode ( $lid );
  3245. $ky = $longle->getLongleByLid ( $lid );
  3246. $longleLog ['longle'] = $ky [0];
  3247. $longleLog ['longleLogHtml'] = $this->_getLongleLogHtml ( $t );
  3248. echo json_encode ( $longleLog );
  3249. }
  3250. function ajaxGetStaffInfo() {
  3251. $username = $this->get_args ( 'username' ) ? $this->get_args ( 'username' ) : "";
  3252. if ($username == "") {
  3253. echo json_encode ( array (
  3254. "success" => false
  3255. ) );
  3256. die ();
  3257. }
  3258. Doo::loadModel ( 'staff' );
  3259. $staff = new staff ();
  3260. $staffInfo = $staff->getOne ( array (
  3261. 'where' => ' username like "' . $username . '"',
  3262. 'asArray' => TRUE
  3263. ) );
  3264. if (empty ( $staffInfo )) {
  3265. echo json_encode ( array (
  3266. "success" => false,
  3267. 'html' => ''
  3268. ) );
  3269. die ();
  3270. }
  3271. $staffHtml = array (
  3272. 'html' => '<div class="contactPanel"><h1>' . $staffInfo ['username'] . '</h1>
  3273. <table><tbody><tr><th>性别</th><td>' . $staffInfo ['gender'] . '</td><th>办事处</th><td>' . $staffInfo ['category'] . '</td></tr>
  3274. <tr><th>手机</th><td>' . $staffInfo ['telephone'] . '</td><th>电话</th><td>' . $staffInfo ['phone'] . '</td></tr>
  3275. <tr><th>QQ</th><td>' . $staffInfo ['qq'] . '</td><th>邮箱</th><td>' . $staffInfo ['email'] . '</td></tr>
  3276. </tbody></table>
  3277. </div>'
  3278. );
  3279. echo json_encode ( $staffHtml );
  3280. }
  3281. function ajaxGetCompanyByAdd() {
  3282. session_start ();
  3283. $cidKey = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : "";
  3284. if (empty($cidKey)){
  3285. echo json_encode ( array (
  3286. "success" => false,
  3287. 'data' => ''
  3288. ) );
  3289. }
  3290. Doo::loadClass ( 'XDeode' );
  3291. $XDeode = new XDeode ( 5 );
  3292. $cid = $XDeode->decode ( $cidKey );
  3293. if (! empty ( $cid )) {
  3294. Doo::loadModel ( 'company' );
  3295. $company = new company ();
  3296. Doo::loadModel ( 'client' );
  3297. Doo::loadModel ( 'district' );
  3298. $district = new district ();
  3299. $client = new client ();
  3300. $districtInfo = $district->get_lv ( 1 );
  3301. // $companyInfo = $client->getClientByCompanyId ( $cid );
  3302. // $companyInfo = $companyInfo [0];
  3303. $companyInfo = $company->getOne ( array (
  3304. 'where' => "cid = " . $cid,
  3305. 'asArray' => TRUE
  3306. ) );
  3307. $companyInfo ['companyKey'] = $XDeode->encode ( $companyInfo ['cid'] );
  3308. // $companyInfo ['companyname'] = $cInfo ['companyname'];
  3309. // $companyInfo ['address'] = $cInfo ['address'];
  3310. // $companyInfo ['ride'] = $cInfo ['ride'];
  3311. // $companyInfo ['landmarks'] = $cInfo ['landmarks'];
  3312. // $companyInfo ['stay'] = $cInfo ['stay'];
  3313. $artld = explode ( ',', $companyInfo ['local'] );
  3314. $districtid = explode ( ',', $companyInfo ['district'] );
  3315. $html = "";
  3316. $html .= '<select name="lv21" id="lv31" onchange="dislv(\'lv31\',\'32\');"><option value="' . $districtid [0] . '">' . $artld [0] . '</option>';
  3317. // foreach ($districtInfo as $key=>$value){
  3318. //
  3319. // $html.='<option selected value="'.$value['id'].'">'.$value['name'].'</option>';
  3320. // }
  3321. $html .= '</select>&nbsp;';
  3322. $html .= '<span id="mlv32">
  3323. <select id="lv32" name="lv22">
  3324. <option selected value="' . $districtid [1] . '" >' . $artld [1] . '</option>
  3325. </select>
  3326. </span>';
  3327. $html .= '<span id="mlv33">
  3328. <select id="lv33" name="lv23">
  3329. <option selected value="' . $districtid [2] . '" >' . $artld [2] . '</option>
  3330. </select>&nbsp;
  3331. </span>';
  3332. $companyInfo ['dishtml'] = $html;
  3333. $companyInfo ['natureAr'] = $this->nature;
  3334. $companyInfo ['natureArlenght'] = 12;
  3335. $token = $this->set_token ();
  3336. $_SESSION ['token_' . $this->staff [0] ['sidKey']] = $token;
  3337. $companyInfo ['token'] = $token;
  3338. echo json_encode ( array (
  3339. "success" => true,
  3340. 'data' => $companyInfo
  3341. ) );
  3342. die ();
  3343. } else
  3344. echo json_encode ( array (
  3345. "success" => false,
  3346. 'data' => ''
  3347. ) );
  3348. die ();
  3349. }
  3350. function doEditCompanyD() {
  3351. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  3352. $companyname = $this->get_args ( 'companyname' ) ? $this->get_args ( 'companyname' ) : "";
  3353. $lv21 = $this->get_args ( 'lv21' ) ? $this->get_args ( 'lv21' ) : 0;
  3354. $lv22 = $this->get_args ( 'lv22' ) ? $this->get_args ( 'lv22' ) : 0;
  3355. $lv23 = $this->get_args ( 'lv23' ) ? $this->get_args ( 'lv23' ) : 0;
  3356. $nature = $this->get_args ( 'nature' ) ? $this->get_args ( 'nature' ) : "";
  3357. $fax = $this->get_args ( 'fax' ) ? $this->get_args ( 'fax' ) : "";
  3358. $webservice = $this->get_args ( 'webservice' ) ? $this->get_args ( 'webservice' ) : "";
  3359. $address = $this->get_args ( 'address' ) ? $this->get_args ( 'address' ) : "";
  3360. $ride = $this->get_args ( 'ride' ) ? $this->get_args ( 'ride' ) : "";
  3361. $stay = $this->get_args ( 'stay' ) ? $this->get_args ( 'stay' ) : "";
  3362. $landmarks = $this->get_args ( 'landmarks' ) ? $this->get_args ( 'landmarks' ) : "";
  3363. if (empty ( $cid ) || empty ( $companyname )) {
  3364. echo json_encode ( array (
  3365. "success" => false
  3366. ) );
  3367. die ();
  3368. }
  3369. Doo::loadModel ( "company" );
  3370. Doo::loadModel ( "client" );
  3371. $client = new client ();
  3372. $company = new company ();
  3373. $company->cid = $cid;
  3374. if (! empty ( $lv21 ) && ! empty ( $lv22 ) && ! empty ( $lv23 )) {
  3375. Doo::loadModel ( 'district' );
  3376. $district = new district ();
  3377. // 更新公司信息
  3378. $lv1 = $district->getbyid ( $lv21 );
  3379. $lv2 = $district->getbyid ( $lv22 );
  3380. $lv3 = $district->getbyid ( $lv23 );
  3381. $company->district = $lv21 . "," . $lv22 . "," . $lv23;
  3382. $company->local = $lv1 [0] ['name'] . "," . $lv2 [0] ['name'] . "," . $lv3 [0] ['name'];
  3383. }
  3384. if (! empty ( $nature )) {
  3385. $nature = implode ( ",", $nature );
  3386. $company->nature = $nature;
  3387. }
  3388. if (! empty ( $companyname )) {
  3389. $company->companyname = $companyname;
  3390. $client->companyname = $companyname;
  3391. }
  3392. if (! empty ( $fax ))
  3393. $company->fax = $fax;
  3394. if (! empty ( $webservice ))
  3395. $company->webservice = $webservice;
  3396. $company->address = $address;
  3397. $company->ride = $ride;
  3398. $company->stay = $stay;
  3399. $company->landmarks = $landmarks;
  3400. $company->update ();
  3401. $client->update ( array (
  3402. 'where' => ' companyid =' . $cid
  3403. ) );
  3404. echo json_encode ( array (
  3405. "success" => true
  3406. ) );
  3407. die ();
  3408. }
  3409. function ajaxEditCompany() {
  3410. $companyname = $this->get_args ( 'companyId' ) ? $this->get_args ( 'companyId' ) : 0;
  3411. if (! empty ( $companyname )) {
  3412. Doo::loadModel ( 'company' );
  3413. $company = new company ();
  3414. $companyInfo = $company->getOne ( array (
  3415. 'where' => "cid = '" . $companyname . "'",
  3416. 'asArray' => TRUE
  3417. ) );
  3418. if (! empty ( $companyInfo )) {
  3419. Doo::loadModel ( 'district' );
  3420. $district = new district ();
  3421. $districtinfo = $district->get_lv ( 1 );
  3422. $dinfo = $district->getbyidlist ( $companyInfo ['district'] );
  3423. $html = '
  3424. <div class="contactInfo clearfix">
  3425. <div class="header">
  3426. <h1 class="companyName">' . $companyInfo ['companyname'] . '</h1>
  3427. </div>
  3428. </div>
  3429. <div class="lockRecord">
  3430. <div class="contactPanel">
  3431. <table>
  3432. <tbody><tr><th>单位全称</th><td colspan="3"><input type="text" name="companyname" id="companyname" value="' . $companyInfo ['companyname'] . '"></td></tr>
  3433. <tr><th>地区</th><td colspan="3">
  3434. <select name="lv21" id="lv21" onchange="dislv(\'lv21\',22);">
  3435. <option value="0">请选择</option>';
  3436. foreach ( $districtinfo as $key => $value ) {
  3437. if ($value ['id'] == $dinfo [0] ['id'])
  3438. $html .= '<option selected value="' . $value ['id'] . '">' . $value ['name'] . '</option>';
  3439. else
  3440. $html .= '<option value="' . $value ['id'] . '">' . $value ['name'] . '</option>';
  3441. }
  3442. $html .= '</select>
  3443. <span id="mlv22">
  3444. <select id="lv22">
  3445. <option value="' . $dinfo [1] ['id'] . '">' . $dinfo [1] ['name'] . '</option>
  3446. </select>
  3447. </span>
  3448. <span id="mlv23">
  3449. <select id="lv23">
  3450. <option value="' . $dinfo [2] ['id'] . '">' . $dinfo [2] ['name'] . '</option>
  3451. </select>&nbsp;
  3452. </span>
  3453. </td></tr>
  3454. ';
  3455. $html .= '<tr><th>性质</th><td colspan="3">';
  3456. $ntre = explode ( ",", $companyInfo ['nature'] );
  3457. foreach ( $this->nature as $key => $value ) {
  3458. $falg = true;
  3459. foreach ( $ntre as $k => $v ) {
  3460. if ($value == $v) {
  3461. $falg = false;
  3462. $html .= '<label><input type="checkbox" checked name="nature[]" value="' . $value . '">' . $value . '</label>&nbsp;';
  3463. }
  3464. }
  3465. if ($falg)
  3466. $html .= '<label><input type="checkbox" name="nature[]" value="' . $value . '">' . $value . '</label>&nbsp;';
  3467. }
  3468. $html .= ' </td></tr>
  3469. <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>
  3470. <tr><th>单位地址</th><td colspan="3"><input type="text" name="address" id="address" value="' . $companyInfo ['address'] . '"> </td></tr>
  3471. <tr><th>乘车路线</th><td colspan="3"><input type="text" name="ride" id="ride" value="' . $companyInfo ['ride'] . '"> </td></tr>
  3472. <tr><th>地标建筑</th><td colspan="3"><input type="text" name="landmarks" id="landmarks" value="' . $companyInfo ['landmarks'] . '"> </td></tr>
  3473. <tr><th>住宿参考</th><td colspan="3"><input type="text" name="stay" id="stay" value="' . $companyInfo ['stay'] . '"> </td></tr>
  3474. <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>
  3475. </tbody></table>
  3476. <div class="bsAlert bsInfo">单位全称将与该单位已存在的客户进行同步;其他单位信息不会进行同步;<br>单位信息随该单位第一位客户录入,并作为“在这添加客户”的基础数据</div>
  3477. </div>
  3478. </div>
  3479. ';
  3480. echo json_encode ( array (
  3481. "success" => true,
  3482. 'html' => $html
  3483. ) );
  3484. die ();
  3485. }
  3486. } else
  3487. echo json_encode ( array (
  3488. "success" => false,
  3489. 'html' => ''
  3490. ) );
  3491. die ();
  3492. }
  3493. function ajaxGetCompany() {
  3494. $companyIdKey = $this->get_args ( 'companyId' ) ? $this->get_args ( 'companyId' ) : 0;
  3495. if (empty($companyIdKey)){
  3496. echo json_encode ( array (
  3497. "success" => false,
  3498. 'html' => ''
  3499. ) );
  3500. }
  3501. Doo::loadClass ( 'XDeode' );
  3502. $XDeode = new XDeode ( 5 );
  3503. $companyname = $XDeode->decode ( $companyIdKey );
  3504. if (! empty ( $companyname )) {
  3505. Doo::loadModel ( 'company' );
  3506. $company = new company ();
  3507. $companyInfo = $company->getOne ( array (
  3508. 'where' => "cid = '" . $companyname . "'",
  3509. 'asArray' => TRUE
  3510. ) );
  3511. if (! empty ( $companyInfo )) {
  3512. Doo::loadModel ( 'client' );
  3513. Doo::loadModel ( 'staff' );
  3514. Doo::loadModel ( 'client_staff' );
  3515. Doo::loadModel ( 'longle' );
  3516. $longle = new longle ();
  3517. $client_staff = new client_staff ();
  3518. $staff = new staff ();
  3519. $client = new client ();
  3520. Doo::loadModel ( 'district' );
  3521. $district = new district ();
  3522. $clientlist = $client->getClientByCompanyId ( $companyInfo ['cid'] );
  3523. $department = $client->getDepartment ( $companyInfo ['cid'] );
  3524. Doo::loadModel ( "tagCompanyNexus" );
  3525. Doo::loadModel ( "tagCompany" );
  3526. $tag = new tagCompany ();
  3527. $tag_client = new tagCompanyNexus ();
  3528. $tagId = $tag_client->getTagClientBySCid ( $companyInfo ['cid'], $this->staff [0] ['sid'] );
  3529. $taginfo = $tag->getTagByTidL ( $tagId ['tag'] );
  3530. $taghtml = "";
  3531. foreach ( $taginfo as $key => $value ) {
  3532. $taghtml .= '<span class="contactsTag tagCol-0' . $value ['colorid'] . '">' . $value ['name'] . '</span>';
  3533. }
  3534. $html = '<div class="header">
  3535. <h1 class="companyName"><div class="fR">
  3536. <a class="icon- add" node-syn="show" href="javascript:void(0)" title="同步地址信息">S</a>
  3537. <a href="javascript:void(0)" title="编辑单位" class="icon- edit" onclick="editByCompany(' . $companyInfo ['cid'] . ')" >I</a> |
  3538. <a title="在这个单位下添加客户" href="javascript:void(0)" class="icon- add" onclick="addClientByCompany(\'' . $companyIdKey . '\')" >H</a></div>' . $companyInfo ['companyname'] . '</h1>
  3539. <div class="contactPanel">
  3540. <table>
  3541. <tbody>
  3542. <tr><th>单位地区</th><td><span>' . $companyInfo ['local'] . '</span></td><th>单位性质</th><td>' . $companyInfo ['nature'] . '</td></tr>
  3543. <tr><th>单位地址</th><td colspan="3">' . $companyInfo ['address'] . '</td></tr>
  3544. <tr><th>单位乘车</th><td colspan="3">' . $companyInfo ['ride'] . '</td></tr>
  3545. <tr><th>单位地标</th><td colspan="3">' . $companyInfo ['landmarks'] . '</td></tr>
  3546. <tr><th>单位住宿</th><td colspan="3">' . $companyInfo ['stay'] . '</td></tr>
  3547. <tr><td colspan="4">
  3548. ' . $taghtml . '
  3549. </td></tr>
  3550. <tr><td colspan="4" >
  3551. <a class="button" style="display:none" node-synadd="true" href="javascript:void(0)">确定同步</a>
  3552. <span node-synAdd="msg" class="bsAlert bsSuccess fL hide"></span>
  3553. <span class="hide" id="skop">已选择 <span id="tl">0</span>/<span id="bl">' . sizeof ( $clientlist ) . '</span>
  3554. <input type="checkbox" name="CASYN[]" cas-all="TR" class="hide" value="19595" style="display: inline-block;">全选客户
  3555. </td>
  3556. </tr>
  3557. </tbody></table></div>
  3558. <h2 class="cate">';
  3559. $html .= '<a href="javascript:void(0)" onclick="departmentC()" class="now">不限</a>';
  3560. foreach ( $department as $key => $value ) {
  3561. if ($value != "")
  3562. $html .= '<a href="javascript:void(0)" onclick="departmentC(\'' . $value ['department'] . '\')">' . $value ['department'] . '</a>';
  3563. }
  3564. $html .= '</h2></div><script>$(".header .cate a").click(function(){
  3565. $(this).addClass("now").siblings("a").removeClass("now");
  3566. });
  3567. </script>';
  3568. $html .= '<div class="lockRecord autoHeightR2" >';
  3569. foreach ( $clientlist as $key => $value ) {
  3570. $scinfo = $client_staff->getClientByCid ( $value ['cid'] );
  3571. $staffinfo = $staff->getUserById ( $scinfo ['sid'] );
  3572. // 客户信息
  3573. $html .= '<div class="contactPanel" id="PART_' . $value ['department'] . '">
  3574. <h1><p class="fR">' . $staffinfo [0] ['category'] . '-<a href="javascript:void(0)" onclick="getStaffInfo(\'' . $staffinfo [0] ['username'] . '\')" >
  3575. ' . $staffinfo [0] ['username'] . '</a></p>
  3576. <input type="checkbox" name="CASYN[]" CAS-NUM="TR" class="hide" value="' . $value ['cid'] . '">
  3577. <a href="javascript:void(0)" onclick="getClientInfo(\'' . $value ['cid'] . '\')" class="clientName">' . $value ['clientname'] . ' </a>
  3578. <i class="icon- sport">' . $value ['priority'] . '</i><a class="icon- edit" title="编辑客户" href="javascript:clientEdit(' . $value ['cid'] . ')">I</a></h1><table>
  3579. <tbody><tr><th>性别</th><td>' . $value ['gender'] . '</td><th>昵称</th><td>' . $value ['nicename'] . '</td></tr>
  3580. <tr><th>部门</th><td>' . $value ['department'] . '</td><th>办公室</th><td>' . $value ['office'] . '</td></tr>
  3581. <tr><th>手机</th><td>' . $value ['telephone'] . '</td><th>电话</th><td>' . $value ['phone'] . '</td></tr>
  3582. <tr><th>QQ</th><td>' . $value ['qq'] . '</td><th>邮箱</th><td>' . $value ['email'] . '</td></tr>
  3583. <tr node-ck=fz ><th>备注</th><td >' . $value ['mark'] . '</td>
  3584. </tr>';
  3585. $longleinfo = $longle->getLongleByClientid ( $value ['cid'] );
  3586. if (empty ( $longleinfo )) {
  3587. $longleinfo = array (
  3588. 0 => array (
  3589. 'lid' => '',
  3590. 'key_num' => '',
  3591. 'product' => '',
  3592. 'statusT' => ''
  3593. )
  3594. );
  3595. }
  3596. $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>';
  3597. $districtList = $district->getbyidlist ( $value ['district'] );
  3598. $localdis = '';
  3599. foreach ( $districtList as $lov ) {
  3600. $localdis .= ' ' . $lov ['name'];
  3601. }
  3602. $html .= '
  3603. <tr node-synCom=pany style="display:none" ><th>客户地区</th><td colspan="4">' . $localdis . '</td></tr>
  3604. <tr node-synCom=pany style="display:none" ><th>客户地址</th><td colspan="4">' . $value ['address'] . '</td></tr>
  3605. <tr node-synCom=pany style="display:none" ><th>客户乘车</th><td colspan="4">' . $value ['ride'] . '</td></tr>
  3606. <tr node-synCom=pany style="display:none" ><th>客户地标</th><td colspan="4">' . $value ['landmarks'] . '</td></tr>
  3607. <tr node-synCom=pany style="display:none" ><th>客户住宿</th><td colspan="4">' . $value ['stay'] . '</td></tr>';
  3608. $html .= '</tbody></table></div>';
  3609. }
  3610. $html .= "</div><script type='text/javascript'>
  3611. $(\"a[node-syn=show]\").click(function() {
  3612. $(\"a[node-synadd='true']\").show();
  3613. $('input[CAS-NUM=TR]').show();
  3614. $('#skop').show();
  3615. $('tr[node-ck=fz]').hide();
  3616. $('tr[node-synCom=pany]').show();
  3617. });
  3618. $(\"input[cas-all='TR']\").click(function() {
  3619. if (this.checked) {
  3620. $(\"input[CAS-NUM=TR]:checkbox\").each(function() {
  3621. $(this).attr(\"checked\", true);
  3622. })
  3623. }else{
  3624. $(\"input[CAS-NUM=TR]:checkbox\").each(function() {
  3625. $(this).attr(\"checked\", false);
  3626. })
  3627. }
  3628. $('#tl').html($('input[CAS-NUM=TR]:checked').length);
  3629. });
  3630. $(\"input[CAS-NUM='TR']\").click(function() {
  3631. $('#tl').html($('input[CAS-NUM=TR]:checked').length);
  3632. });
  3633. $(\"a[node-synadd='true']\").click(function() {
  3634. var id_array=new Array();
  3635. $('input[CAS-NUM=TR]:checked').each(function(){
  3636. id_array.push($(this).val());
  3637. });
  3638. if(id_array.length==0){
  3639. alert('未选中客户');
  3640. }else{
  3641. var idstr=id_array.join(',');
  3642. var url='/ajaxSetCompanyAddress';
  3643. $.ajax({
  3644. url:url,
  3645. type: 'post',
  3646. cache: false,
  3647. dataType: 'json',
  3648. data: {
  3649. cidString:idstr,
  3650. company:" . $companyInfo ['cid'] . "
  3651. },
  3652. global: true,
  3653. success: function(data){
  3654. if(data.status>0){
  3655. $(\"span[node-synAdd=msg]\").html('同步成功');
  3656. for(var i=0;i<id_array.length;i++){
  3657. $(\"td[node-address=company_\"+id_array[i]+\"]\").html('" . $companyInfo ['address'] . "');
  3658. }
  3659. $(\"a[node-synadd='true']\").hide();
  3660. $('input[CAS-NUM=TR]').hide();
  3661. $('#skop').hide();
  3662. $(\"span[node-synAdd=msg]\").show().delay(2000).fadeOut();
  3663. }else if(data.status==-1){
  3664. $(\"span[node-synAdd=msg]\").html('操作不成功');
  3665. $(\"span[node-synAdd=msg]\").show().delay(2000).fadeOut();
  3666. }else if(data.status==0){
  3667. $(\"span[node-synAdd=msg]\").html('地址已同步过');
  3668. $(\"span[node-synAdd=msg]\").show().delay(2000).fadeOut();
  3669. }
  3670. },
  3671. error:function(err){
  3672. }
  3673. });
  3674. }
  3675. });
  3676. autoFlashHeight();
  3677. </script>";
  3678. echo json_encode ( array (
  3679. "success" => true,
  3680. 'html' => $html
  3681. ) );
  3682. die ();
  3683. }
  3684. }
  3685. die ();
  3686. }
  3687. function ajaxSetCompanyAddress() {
  3688. $cidString = $this->get_args ( 'cidString' ) ? $this->get_args ( 'cidString' ) : "";
  3689. $companyId = $this->get_args ( 'company' ) && is_numeric ( $this->get_args ( 'company' ) ) ? $this->get_args ( 'company' ) : 0;
  3690. if (! empty ( $cidString ) && ! empty ( $companyId )) {
  3691. Doo::loadModel ( 'client' );
  3692. $client = new client ();
  3693. Doo::loadModel ( 'company' );
  3694. $company = new company ();
  3695. $cidList = explode ( ',', $cidString );
  3696. foreach ( $cidList as $value ) {
  3697. if (! is_numeric ( $value ))
  3698. die ( 'illegal request3' );
  3699. }
  3700. $companyInfo = $company->getOne ( array (
  3701. 'where' => "cid = '" . $companyId . "'",
  3702. 'asArray' => TRUE
  3703. ) );
  3704. $client->address = $companyInfo ['address'];
  3705. $client->ride = $companyInfo ['ride'];
  3706. $client->landmarks = $companyInfo ['landmarks'];
  3707. $client->stay = $companyInfo ['stay'];
  3708. $client->local = $companyInfo ['local'];
  3709. $client->district = $companyInfo ['district'];
  3710. $falg = $client->update ( array (
  3711. 'where' => 'companyid =' . $companyInfo ['cid'] . ' and cid in (' . $cidString . ')'
  3712. ) );
  3713. echo json_encode ( array (
  3714. 'status' => $falg,
  3715. 'msg' => 'illegal request2'
  3716. ) );
  3717. die ();
  3718. }
  3719. echo json_encode ( array (
  3720. 'status' => - 1,
  3721. 'msg' => 'illegal request'
  3722. ) );
  3723. die ();
  3724. }
  3725. function checkclicomname() { // 地区区分
  3726. $companyname = $this->get_args ( 'companyname' ) ? $this->get_args ( 'companyname' ) : "";
  3727. $clientname = $this->get_args ( 'clientname' ) ? $this->get_args ( 'clientname' ) : "";
  3728. $district1 = $this->get_args ( 'district1' ) ? $this->get_args ( 'district1' ) : 0;
  3729. $district2 = $this->get_args ( 'district2' ) ? $this->get_args ( 'district2' ) : 0;
  3730. $district3 = $this->get_args ( 'district3' ) ? $this->get_args ( 'district3' ) : 0;
  3731. Doo::loadModel ( 'client' );
  3732. $client = new client ();
  3733. $local = $district1 . "," . $district2 . "," . $district3;
  3734. $companyname = trim ( $companyname );
  3735. $clientname = trim ( $clientname );
  3736. $clientinfo = $client->getClientToName ( $clientname, $companyname, $local );
  3737. if (! empty ( $clientinfo )) {
  3738. echo json_encode ( array (
  3739. 'success' => false
  3740. ) );
  3741. } else {
  3742. echo json_encode ( array (
  3743. 'success' => true
  3744. ) );
  3745. }
  3746. }
  3747. function ajaxGetClientInfoN() {
  3748. $clientname = $this->get_args ( 'client' ) ? $this->get_args ( 'client' ) : "";
  3749. if ($clientname == "") {
  3750. echo json_encode ( array (
  3751. "success" => false
  3752. ) );
  3753. die ();
  3754. }
  3755. Doo::loadModel ( 'client' );
  3756. Doo::loadModel ( 'client_staff' );
  3757. Doo::loadModel ( 'longle' );
  3758. Doo::loadModel ( 'company' );
  3759. Doo::loadModel ( 'service_log' );
  3760. $service_log = new service_log ();
  3761. $company = new company ();
  3762. $longle = new longle ();
  3763. $client = new client ();
  3764. $client_staff = new client_staff ();
  3765. $clientInfo = $client->getOne ( array (
  3766. "where" => ' cid like "' . $clientname . '"',
  3767. 'asArray' => TRUE
  3768. ) );
  3769. if (empty ( $clientInfo )) {
  3770. echo json_encode ( array (
  3771. "success" => false,
  3772. 'html' => ''
  3773. ) );
  3774. die ();
  3775. }
  3776. // 获取锁
  3777. $longleInfo = $longle->getLongleByClientid ( $clientname );
  3778. $k = "";
  3779. foreach ( $longleInfo as $key => $value ) {
  3780. if ($value ['status'] == 6 || $value ['status'] == 7)
  3781. $k .= '<a href="javascript:void(0)" class="disenable" onclick="getLock(' . $value ['lid'] . ')" >' . $value ['key_num'] . '/' . $value ['product'] . '/' . $value ['statusT'] . '</a>&nbsp; ';
  3782. else
  3783. $k .= '<a href="javascript:void(0)" onclick="getLock(' . $value ['lid'] . ')" >' . $value ['key_num'] . '/' . $value ['product'] . '/' . $value ['statusT'] . '</a>&nbsp; ';
  3784. }
  3785. // 获取办事人
  3786. $staffInfo = $client_staff->getClientByCid ( $clientInfo ['cid'] );
  3787. // 获取公司信息
  3788. $companyInfo = $company->getCompanyByCid ( $clientInfo ['companyid'] );
  3789. $serviceLog = $service_log->getServiceByClientid ( $clientInfo ['cid'] );
  3790. $u = "";
  3791. $order = array (
  3792. "\r\n",
  3793. "\n",
  3794. "\r"
  3795. );
  3796. $replace = '</br>';
  3797. foreach ( $serviceLog as $key => $value ) {
  3798. $datetime = explode ( "-", $value ['date'] );
  3799. $u .= '<div class="infoFlowList">
  3800. <div class="dateTitle">
  3801. <em class="month"><span class="num">' . $datetime ['1'] . '</span><span class="text">-' . $datetime ['2'] . '</span></em>
  3802. <span class="year">' . $datetime ['0'] . '</span>
  3803. </div>
  3804. <ul class="flowList">';
  3805. if ($value ['status'] == 1)
  3806. $u .= '<li class="item iconService">上门服务</li>';
  3807. elseif ($value ['status'] == 2)
  3808. $u .= '<li class="item iconPhone">电话拜访</li>';
  3809. elseif ($value ['status'] == 3)
  3810. $u .= '<li class="item iconOther">其他</li>';
  3811. $u .= '
  3812. <li class="item">' . $value ['category'] . '<a href="javascript:void(0)" onclick="getStaffInfo(\'' . $value ['staffname'] . '\')" >' . $value ['staffname'] . '</a></li>
  3813. <li class="item">
  3814. ' . str_replace ( $order, $replace, $value ['mark'] ) . '
  3815. </li>
  3816. </ul>
  3817. </div>';
  3818. }
  3819. Doo::loadModel ( "tag_client" );
  3820. Doo::loadModel ( "tag" );
  3821. $tag = new tag ();
  3822. $tag_client = new tag_client ();
  3823. $tagId = $tag_client->getTagClientBySCid ( $clientInfo ['cid'], $this->staff [0] ['sid'] );
  3824. $taginfo = $tag->getTagByTidL ( $tagId ['tag'] );
  3825. // $taghtml="";
  3826. //
  3827. // foreach ($taginfo as $key=>$value){
  3828. // $taghtml.='<span class="contactsTag tagCol-0'.$value['colorid'].'">'.$value['name'].'</span>';
  3829. // }
  3830. $mhtml = "";
  3831. $dhtml = "";
  3832. for($month = 1; $month <= 12; $month ++) {
  3833. if (date ( "m" ) == $month)
  3834. $mhtml .= '<option selected value="' . $month . '">' . $month . '月</option>';
  3835. else
  3836. $mhtml .= '<option value="' . $month . '">' . $month . '月</option>';
  3837. }
  3838. for($day = 1; $day <= 31; $day ++) {
  3839. if (date ( "d" ) == $day)
  3840. $dhtml .= '<option selected value="' . $day . '">' . $day . '日</option>';
  3841. else
  3842. $dhtml .= '<option value="' . $day . '">' . $day . '日</option>';
  3843. }
  3844. // $b="";
  3845. // if(!empty($staffInfo))
  3846. // $b='<p class="fR">'.$staffInfo['category'].'-<a href="javascript:void(0)" onclick="getStaffInfo(\''.$staffInfo['username'].'\')" >'.$staffInfo['username'].'</a></p>'.$clientInfo['clientname'].' ';
  3847. //
  3848. $m = "";
  3849. if (! empty ( $companyInfo )) {
  3850. $m = '
  3851. <table width="100%">
  3852. <tbody>
  3853. <tr><th>单位全称</th><td colspan="3"><a href="javascript:void(0)" >' . $companyInfo [0] ['companyname'] . '</a></td></tr>
  3854. <tr><th>地区</th><td>' . $companyInfo [0] ['local'] . '</td><th>部门/职位</th><td>' . $clientInfo ['department'] . '/' . $clientInfo ['position'] . '</td></tr>
  3855. <tr><th>传真</th><td>' . $companyInfo [0] ['fax'] . '</td><th>办公室</th><td>' . $companyInfo [0] ['office'] . '</td></tr>
  3856. <tr><th>单位地址</th><td colspan="3">' . $companyInfo [0] ['address'] . '</td></tr>
  3857. <tr><th>乘车路线</th><td colspan="3">' . $companyInfo [0] ['ride'] . '</td></tr>
  3858. <tr><th>地标建筑</th><td colspan="3">' . $companyInfo [0] ['landmarks'] . '</td></tr>
  3859. <tr><th>参考住宿</th><td colspan="3">' . $clientInfo ['stay'] . '</td></tr>
  3860. <tr><th>单位主页</th><td colspan="3">' . $clientInfo ['webservice'] . '</td></tr>
  3861. </tbody></table>
  3862. ';
  3863. }
  3864. $clientHtml = array (
  3865. 'html' => '
  3866. <div class="modal-dialog ">
  3867. <div class="modal-content">
  3868. <div class="modal-header">
  3869. <h3><span class="fR"><a>' . $staffInfo ['category'] . ' ' . $staffInfo ['username'] . '</a></span>' . $clientInfo ['clientname'] . '</h3>
  3870. </div>
  3871. <div class="modal-body">
  3872. <div class="modalClientTable">
  3873. <table width="100%">
  3874. <tbody><tr><th>性别</th><td>' . $clientInfo ['gender'] . '</td><th>昵称</th><td>' . $clientInfo ['nicename'] . '</td></tr>
  3875. <tr><th>手机</th><td>' . $clientInfo ['telephone'] . '</td><th>QQ</th><td>' . $clientInfo ['qq'] . '</td></tr>
  3876. <tr><th>电话</th><td>' . $clientInfo ['phone'] . '</td><th>邮箱</th><td>' . $clientInfo ['email'] . '</td></tr>
  3877. <tr><th>软件锁</th><td colspan="3"> <div class="lockContent">' . $k . '</div></td></tr>
  3878. <tr><td colspan="4">
  3879. </td></tr>
  3880. </tbody>
  3881. </table>
  3882. ' . $m . '
  3883. <div class="clearfix">
  3884. ' . $u . '
  3885. </div>
  3886. </div>
  3887. </div>
  3888. <div class="modal-footer">
  3889. <a href="javascript:void(0)" onclick="closeClick()" class="button btn-gray" data-dismiss="modal" aria-hidden="true">关闭</a>
  3890. </div>
  3891. </div></div>'
  3892. );
  3893. echo json_encode ( $clientHtml );
  3894. }
  3895. function ajaxGetClientInfo() {
  3896. $clientname = $this->get_args ( 'client' )&&is_numeric($this->get_args ( 'client' )) ? $this->get_args ( 'client' ) : "";
  3897. if ($clientname == "") {
  3898. echo json_encode ( array (
  3899. "success" => false
  3900. ) );
  3901. die ();
  3902. }
  3903. Doo::loadModel ( 'client' );
  3904. Doo::loadModel ( 'client_staff' );
  3905. Doo::loadModel ( 'longle' );
  3906. Doo::loadModel ( 'company' );
  3907. Doo::loadModel ( 'service_log' );
  3908. Doo::loadModel ( "district" );
  3909. $district = new district ();
  3910. $service_log = new service_log ();
  3911. $company = new company ();
  3912. $longle = new longle ();
  3913. $client = new client ();
  3914. $client_staff = new client_staff ();
  3915. $clientInfo = $client->getOne ( array (
  3916. "where" => ' cid = "' . $clientname . '"',
  3917. 'asArray' => TRUE
  3918. ) );
  3919. if (empty ( $clientInfo )) {
  3920. echo json_encode ( array (
  3921. "success" => false,
  3922. 'html' => ''
  3923. ) );
  3924. die ();
  3925. }
  3926. // 获取锁
  3927. $longleInfo = $longle->getLongleByClientid ( $clientInfo ['cid'] );
  3928. $k = "";
  3929. foreach ( $longleInfo as $key => $value ) {
  3930. if ($value ['status'] == 6 || $value ['status'] == 7)
  3931. $k .= '<a href="javascript:void(0)" class="disenable" onclick="getLock(' . $value ['lid'] . ')" >' . $value ['key_num'] . '/' . $value ['product'] . '/' . $value ['statusT'] . '</a>&nbsp; ';
  3932. else
  3933. $k .= '<a href="javascript:void(0)" onclick="getLock(' . $value ['lid'] . ')" >' . $value ['key_num'] . '/' . $value ['product'] . '/' . $value ['statusT'] . '</a>&nbsp; ';
  3934. }
  3935. // 获取办事人
  3936. $staffInfo = $client_staff->getClientByCid ( $clientInfo ['cid'] );
  3937. $b = "";
  3938. if (! empty ( $staffInfo ))
  3939. $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>';
  3940. // 获取公司信息
  3941. $companyInfo = $company->getCompanyByCid ( $clientInfo ['companyid'] );
  3942. $serviceLog = $service_log->getServiceByClientid ( $clientInfo ['cid'] );
  3943. $local = $district->getbyidlist ( $clientInfo ['district'] );
  3944. if (! isset ( $local [1] ))
  3945. $local [1] ['name'] = "";
  3946. if (! isset ( $local [2] ))
  3947. $local [2] ['name'] = "";
  3948. $m = "";
  3949. if (! empty ( $companyInfo )) {
  3950. $m = '<div class="contactPanel">
  3951. <table>
  3952. <tbody>
  3953. <tr><th>单位全称</th><td colspan="3"><a href="javascript:void(0)" onclick="getCompany(\'' . $companyInfo [0] ['cidKey'] . '\')">' . $companyInfo [0] ['companyname'] . '</a></td></tr>
  3954. <tr><th>单位主页</th><td colspan="3">' . $clientInfo ['webservice'] . '</td></tr>
  3955. <tr><th>客户地区</th><td>' . $local [0] ['name'] . ',' . $local [1] ['name'] . ',' . $local [2] ['name'] . '</td><th>部门/职位</th><td>' . $clientInfo ['department'] . '/' . $clientInfo ['position'] . '</td></tr>
  3956. <tr><th>客户传真</th><td>' . $clientInfo ['fax'] . '</td><th>办公室</th><td>' . $clientInfo ['office'] . '</td></tr>
  3957. <tr><th>客户地址</th><td colspan="3">' . $clientInfo ['address'] . '</td></tr>
  3958. <tr><th>客户乘车</th><td colspan="3">' . $clientInfo ['ride'] . '</td></tr>
  3959. <tr><th>客户地标</th><td colspan="3">' . $clientInfo ['landmarks'] . '</td></tr>
  3960. <tr><th>客户住宿</th><td colspan="3">' . $clientInfo ['stay'] . '</td></tr>
  3961. </tbody></table>
  3962. </div>';
  3963. }
  3964. $u = "";
  3965. $order = array (
  3966. "\r\n",
  3967. "\n",
  3968. "\r"
  3969. );
  3970. $replace = '</br>';
  3971. foreach ( $serviceLog as $key => $value ) {
  3972. $datetime = explode ( "-", $value ['date'] );
  3973. $u .= '<div class="infoFlowList">
  3974. <div class="dateTitle">
  3975. <em class="month"><span class="num">' . $datetime ['1'] . '</span><span class="text">-' . $datetime ['2'] . '</span></em>
  3976. <span class="year">' . $datetime ['0'] . '</span>
  3977. </div>
  3978. <ul class="flowList">';
  3979. if ($value ['status'] == 1)
  3980. $u .= '<li class="item iconService">上门服务<';
  3981. elseif ($value ['status'] == 2)
  3982. $u .= '<li class="item iconPhone">电话拜访<';
  3983. elseif ($value ['status'] == 3)
  3984. $u .= '<li class="item iconOther">其他<';
  3985. $u .= $value ['category'] . '<a href="javascript:void(0)" onclick="getStaffInfo(\'' . $value ['staffname'] . '\')" >' . $value ['staffname'] . '</a></li>
  3986. <li class="item">
  3987. ' . str_replace ( $order, $replace, $value ['mark'] ) . '
  3988. </li>
  3989. </ul>
  3990. </div>';
  3991. }
  3992. Doo::loadModel ( "tag_client" );
  3993. Doo::loadModel ( "tag" );
  3994. $tag = new tag ();
  3995. $tag_client = new tag_client ();
  3996. $tagId = $tag_client->getTagClientBySCid ( $clientInfo ['cid'], $this->staff [0] ['sid'] );
  3997. $taginfo = $tag->getTagByTidL ( $tagId ['tag'] );
  3998. $taghtml = "";
  3999. foreach ( $taginfo as $key => $value ) {
  4000. $taghtml .= '<span class="contactsTag tagCol-0' . $value ['colorid'] . '">' . $value ['name'] . '</span>';
  4001. }
  4002. $mhtml = "";
  4003. $dhtml = "";
  4004. $yhtml = "";
  4005. for($year = 2020; $year >= 2004; $year --) {
  4006. if (date ( "Y" ) == $year)
  4007. $yhtml .= '<option selected value="' . $year . '">' . $year . '年</option>';
  4008. else
  4009. $yhtml .= '<option value="' . $year . '">' . $year . '年</option>';
  4010. }
  4011. for($month = 1; $month <= 12; $month ++) {
  4012. if (date ( "m" ) == $month)
  4013. $mhtml .= '<option selected value="' . $month . '">' . $month . '月</option>';
  4014. else
  4015. $mhtml .= '<option value="' . $month . '">' . $month . '月</option>';
  4016. }
  4017. for($day = 1; $day <= 31; $day ++) {
  4018. if (date ( "d" ) == $day)
  4019. $dhtml .= '<option selected value="' . $day . '">' . $day . '日</option>';
  4020. else
  4021. $dhtml .= '<option value="' . $day . '">' . $day . '日</option>';
  4022. }
  4023. $clientHtml = array (
  4024. 'html' => '<div class="contactInfo clearfix">
  4025. <div class="contactPanel">
  4026. <h1>' . $b . '<a data-original-title="编辑客户" data-toggle="ctooltip" data-placement="right" href="javascript:clientEdit(' . $clientInfo ['cid'] . ')" class="icon- edit">I</a></h1>
  4027. <table>
  4028. <tbody><tr><th>性别</th><td>' . $clientInfo ['gender'] . '</td><th>昵称</th><td>' . $clientInfo ['nicename'] . '</td></tr>
  4029. <tr><th>手机</th><td>' . $clientInfo ['telephone'] . '</td><th>QQ</th><td>' . $clientInfo ['qq'] . '</td></tr>
  4030. <tr><th>电话</th><td>' . $clientInfo ['phone'] . '</td><th>邮箱</th><td>' . $clientInfo ['email'] . '</td></tr>
  4031. <tr><th>软件锁</th><td colspan="3"><div class="lockContent">' . $k . '</div></td></tr>
  4032. <tr><th>备注</th><td colspan="3">' . $clientInfo ['mark'] . '</td></tr>
  4033. <tr><td colspan="4">
  4034. ' . $taghtml . '
  4035. </td></tr>
  4036. </tbody></table>
  4037. </div>
  4038. ' . $m . '
  4039. </div>
  4040. <div class="lockRecord autoHeightR1" >
  4041. <!--添加记录按钮-->
  4042. <div class="addRecord addRecordButton clearfix" >
  4043. <a href="#" onclick="slideupInfo(this)">+ 打开添加服务记录</a>
  4044. </div>
  4045. <!--添加记录-->
  4046. <div class="addRecord addRecordForm clearfix hide">
  4047. <a onclick="slidedownInfo(this)" class="fR slidedownInfo">- 关闭添加记录</a>
  4048. <form name="lk" action="/addServiceLog" method="post" >
  4049. <div class="control-group">
  4050. <div class="controls">
  4051. <label class="radio inline">
  4052. <input type="radio" name="logstatus" id="status" checked value="2">电话拜访
  4053. </label>
  4054. <label class="radio inline">
  4055. <input type="radio" name="logstatus" id="status" value="1" >上门服务
  4056. </label>
  4057. <label class="radio inline">
  4058. <input type="radio" name="logstatus" id="status" value="3">其他
  4059. </label>
  4060. </div>
  4061. </div>
  4062. <div class="control-group">
  4063. <div class="controls">时间:
  4064. <select name="y" id="y">
  4065. ' . $yhtml . '
  4066. </select>
  4067. <select name="m" id="m">
  4068. ' . $mhtml . '
  4069. </select>
  4070. <select name="d" id="d">
  4071. ' . $dhtml . '
  4072. </select>
  4073. </div>
  4074. </div>
  4075. <link href="' . WEB_SITE_GLOBAL . 'css/bootstrap-datetimepicker.min.css" rel="stylesheet" media="screen">
  4076. <!--添加记录-备注-->
  4077. <!--<div class="control-group">
  4078. <div class="controls">
  4079. <select name="date" id="date">
  4080. <option value="2013">2013</option>
  4081. </select>
  4082. </div>
  4083. </div>-->
  4084. <div class="control-group">
  4085. <div class="controls" onclick="slideupInfo()">
  4086. <textarea name="mark" id="mark" style="width:95%" rows="5"></textarea>
  4087. <div class="bsAlert bsWarning"><b>含泪告知:</b>客户记录暂时无法修改!删除!,添加时请谨慎。点击确定添加成功后,信息会立即出现在下方!注意咯,别猛戳‘确定添加’导致重复添加了哦~</div>
  4088. </div>
  4089. </div>
  4090. <div class="control-group">
  4091. <div class="controls">
  4092. <div style="display:inline-block;margin-right:10px"><label><input name="Remind" onclick="reFK()" type="checkbox" value="1"> 添加提醒</label></div>
  4093. <span id="reHL" class="hide">
  4094. <div>
  4095. 限期:
  4096. <input type="date" name="time" id="dtp_input2" value="" class="hide"/>
  4097. </div>
  4098. <div>
  4099. 备注:<input id="remark" name="remark" type="text"></span>
  4100. </div>
  4101. </div>
  4102. <div class="control-group">
  4103. <div class="controls clearfix">
  4104. <input type="button" value="确定添加" id="conSer" onclick="aServiceLog(\'' . $this->staff [0] ['category'] . '\',\'' . $this->staff [0] ['username'] . '\',' . $clientInfo ['cid'] . ')" class="button"></input>
  4105. <div id="load"></div>
  4106. </div>
  4107. </div>
  4108. </div>
  4109. </form>
  4110. </div>
  4111. <!--添加记录按钮-->
  4112. <!--记录列表-->
  4113. <div id="kl"></div>
  4114. ' . $u . '
  4115. <script type="text/javascript">autoFlashHeight();</script> </div>'
  4116. );
  4117. echo json_encode ( $clientHtml );
  4118. }
  4119. function ajaxGetCompanyInfo() {
  4120. }
  4121. function checkClient() {
  4122. $name = $this->get_args ( 'name' ) ? $this->get_args ( 'name' ) : "";
  4123. $company = $this->get_args ( 'company' ) ? $this->get_args ( 'company' ) : "";
  4124. if (! empty ( $name )&&! empty ( $company )) {
  4125. Doo::loadModel ( 'client' );
  4126. $client = new client ();
  4127. $clientInfo = $client->getClientByName2 ( $name, $company );
  4128. if (! empty ( $clientInfo ))
  4129. echo json_encode ( array (
  4130. "success" => true
  4131. ) );
  4132. else
  4133. echo json_encode ( array (
  4134. "success" => false
  4135. ) );
  4136. } else {
  4137. echo json_encode ( array (
  4138. "success" => false
  4139. ) );
  4140. }
  4141. }
  4142. function searchClient() {
  4143. $searchDbInforItem = $this->get_args ( 'searchDbInforItem' ) ? $this->get_args ( 'searchDbInforItem' ) : "";
  4144. if (! empty ( $searchDbInforItem )) {
  4145. Doo::loadModel ( 'client' );
  4146. $client = new client ();
  4147. $clientInfo = $client->getClientByName ( $searchDbInforItem );
  4148. echo json_encode ( $clientInfo );
  4149. } else {
  4150. echo json_encode ( array (
  4151. 0 => array (
  4152. 'clientname' => ''
  4153. )
  4154. ) );
  4155. }
  4156. }
  4157. function searchCompany() {
  4158. $searchDbInforItem = $this->get_args ( 'searchDbInforItem' ) ? $this->get_args ( 'searchDbInforItem' ) : "";
  4159. if (! empty ( $searchDbInforItem )) {
  4160. Doo::loadModel ( 'company' );
  4161. $company = new company ();
  4162. $clientInfo = $company->searchCompany ( $searchDbInforItem );
  4163. echo json_encode ( $clientInfo );
  4164. } else {
  4165. echo json_encode ( array (
  4166. 0 => array (
  4167. 'companyname' => '',
  4168. 'local' => ''
  4169. )
  4170. ) );
  4171. }
  4172. }
  4173. function checkCompany() {
  4174. $searchDbInforItem = $this->get_args ( 'name' ) ? $this->get_args ( 'name' ) : "";
  4175. $searchDbInforItem = explode ( '-', $searchDbInforItem );
  4176. $this->nature ['naturelenght'] = 15;
  4177. Doo::loadModel ( 'district' );
  4178. $district = new district ();
  4179. $d = $district->get_lv ( 1 );
  4180. $html = '<option vlaue="0">请选择</option>';
  4181. foreach ( $d as $key => $value ) {
  4182. $html .= '<option value="' . $value ['id'] . '">' . $value ['name'] . '</option>';
  4183. }
  4184. $this->nature ['district'] = $html;
  4185. if (! empty ( $searchDbInforItem )) {
  4186. Doo::loadModel ( 'company' );
  4187. $company = new company ();
  4188. if (! isset ( $searchDbInforItem [1] )) {
  4189. echo json_encode ( array (
  4190. "success" => false,
  4191. 'nature' => $this->nature
  4192. ) );
  4193. die ();
  4194. }
  4195. $clientInfo = $company->getCompanyByName ( $searchDbInforItem [0], $searchDbInforItem [1] );
  4196. if (! empty ( $clientInfo ))
  4197. echo json_encode ( array (
  4198. "success" => true,
  4199. 'data' => $clientInfo
  4200. ) );
  4201. else
  4202. echo json_encode ( array (
  4203. "success" => false,
  4204. 'nature' => $this->nature
  4205. ) );
  4206. } else {
  4207. echo json_encode ( array (
  4208. "success" => false,
  4209. 'nature' => $this->nature
  4210. ) );
  4211. }
  4212. }
  4213. function checkLongle() {
  4214. $searchDbInforItem = $this->get_args ( 'name' ) ? $this->get_args ( 'name' ) : "";
  4215. $searchDbInforItem = explode ( ' ', $searchDbInforItem );
  4216. if (! empty ( $searchDbInforItem )) {
  4217. Doo::loadModel ( 'longle' );
  4218. $longle = new longle ();
  4219. $clientInfo = $longle->getLongleBykeynum ( $searchDbInforItem [0] );
  4220. if (! empty ( $clientInfo ))
  4221. echo json_encode ( array (
  4222. "success" => true
  4223. ) );
  4224. else
  4225. echo json_encode ( array (
  4226. "success" => false
  4227. ) );
  4228. } else {
  4229. echo json_encode ( array (
  4230. "success" => false
  4231. ) );
  4232. }
  4233. }
  4234. function searchLongle() {
  4235. $searchDbInforItem = $this->get_args ( 'searchDbInforItem' ) ? $this->get_args ( 'searchDbInforItem' ) : "";
  4236. if (! empty ( $searchDbInforItem )) {
  4237. Doo::loadModel ( 'longle' );
  4238. $longle = new longle ();
  4239. $longleInfo = $longle->getLongleBykeynum2 ( $searchDbInforItem );
  4240. echo json_encode ( $longleInfo );
  4241. } else {
  4242. echo json_encode ( array (
  4243. 0 => array (
  4244. 'clientname' => ''
  4245. )
  4246. ) );
  4247. }
  4248. }
  4249. function updateChangeCompany() {
  4250. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  4251. $clientID = $this->get_args ( 'clientID' ) ? $this->get_args ( 'clientID' ) : 0;
  4252. $companyname = $this->get_args ( 'companyname' ) ? $this->get_args ( 'companyname' ) : "";
  4253. Doo::loadModel ( 'company' );
  4254. Doo::loadModel ( 'client' );
  4255. $client = new client ();
  4256. $company = new company ();
  4257. $companyname = explode ( "-", $companyname );
  4258. if (isset ( $companyname [1] ))
  4259. $k = $company->getCompanyByName ( $companyname [0], $companyname [1] );
  4260. else
  4261. $k = array ();
  4262. if (! empty ( $cid ) && ! empty ( $k ) && ! empty ( $clientID )) {
  4263. $client->cid = $clientID;
  4264. $client->companyid = $cid;
  4265. $client->companyname = $companyname [0];
  4266. $client->update ();
  4267. } else {
  4268. $local1 = $this->get_args ( 'lv21' ) ? $this->get_args ( 'lv21' ) : 0;
  4269. $local2 = $this->get_args ( 'lv22' ) ? $this->get_args ( 'lv22' ) : 0;
  4270. $local3 = $this->get_args ( 'lv23' ) ? $this->get_args ( 'lv23' ) : 0;
  4271. Doo::loadModel ( 'district' );
  4272. $district = new district ();
  4273. // 更新公司信息
  4274. $lv1 = $district->getbyid ( $local1 );
  4275. $lv2 = $district->getbyid ( $local2 );
  4276. $lv3 = $district->getbyid ( $local3 );
  4277. if (empty ( $local1 ) || empty ( $local2 ))
  4278. return "/";
  4279. if (! empty ( $local1 ) && ! empty ( $local2 ))
  4280. $company->local = $lv1 [0] ['name'] . "," . $lv2 [0] ['name'] . "," . $lv3 [0] ['name'];
  4281. if (! empty ( $local1 ) && ! empty ( $local2 ))
  4282. $company->district = $local1 . "," . $local2 . "," . $local3;
  4283. $nature = $this->get_args ( 'nature' ) ? $this->get_args ( 'nature' ) : "";
  4284. $fax = $this->get_args ( 'fax' ) ? $this->get_args ( 'fax' ) : "";
  4285. $webservice = $this->get_args ( 'webservice' ) ? $this->get_args ( 'webservice' ) : "";
  4286. $address = $this->get_args ( 'address' ) ? $this->get_args ( 'address' ) : "";
  4287. $landmarks = $this->get_args ( 'landmarks' ) ? $this->get_args ( 'landmarks' ) : "";
  4288. $stay = $this->get_args ( 'stay' ) ? $this->get_args ( 'stay' ) : "";
  4289. $ride = $this->get_args ( 'ride' ) ? $this->get_args ( 'ride' ) : "";
  4290. $nature = implode ( ",", $nature );
  4291. $company->companyname = $companyname [0];
  4292. $company->ride = $ride;
  4293. $company->fax = $fax;
  4294. $company->webservice = $webservice;
  4295. $company->address = $address;
  4296. $company->landmarks = $landmarks;
  4297. $company->stay = $stay;
  4298. $company->nature = $nature;
  4299. $cid = $company->insert ();
  4300. $client->cid = $clientID;
  4301. $client->companyid = $cid;
  4302. $client->companyname = $companyname [0];
  4303. $client->update ();
  4304. }
  4305. return "/contacts";
  4306. }
  4307. function AddClientInfo() { // 不编辑公司
  4308. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  4309. $clientname = $this->get_args ( 'clientname' ) ? $this->get_args ( 'clientname' ) : "";
  4310. $gender = $this->get_args ( 'gender' ) ? $this->get_args ( 'gender' ) : "";
  4311. $nicename = $this->get_args ( 'nicename' ) ? $this->get_args ( 'nicename' ) : "";
  4312. $telephone = $this->get_args ( 'telephone' ) ? $this->get_args ( 'telephone' ) : "";
  4313. $phone = $this->get_args ( 'phone' ) ? $this->get_args ( 'phone' ) : "";
  4314. $email = $this->get_args ( 'email' ) ? $this->get_args ( 'email' ) : "";
  4315. $unit = $this->get_args ( 'unit' ) ? $this->get_args ( 'unit' ) : "";
  4316. $fax = $this->get_args ( 'fax' ) ? $this->get_args ( 'fax' ) : "";
  4317. $webservice = $this->get_args ( 'webservice' ) ? $this->get_args ( 'webservice' ) : "";
  4318. $department = $this->get_args ( 'department' ) ? $this->get_args ( 'department' ) : "";
  4319. $position = $this->get_args ( 'position' ) ? $this->get_args ( 'position' ) : "";
  4320. $office = $this->get_args ( 'office' ) ? $this->get_args ( 'office' ) : "";
  4321. $address = $this->get_args ( 'address' ) ? $this->get_args ( 'address' ) : "";
  4322. $ride = $this->get_args ( 'ride' ) ? $this->get_args ( 'ride' ) : "";
  4323. $landmarks = $this->get_args ( 'landmarks' ) ? $this->get_args ( 'landmarks' ) : "";
  4324. $qq = $this->get_args ( 'qq' ) ? $this->get_args ( 'qq' ) : "";
  4325. $priority = $this->get_args ( 'priority' ) ? $this->get_args ( 'priority' ) : 5;
  4326. $stay = $this->get_args ( 'stay' ) ? $this->get_args ( 'stay' ) : "";
  4327. $mark = $this->get_args ( 'mark' ) ? $this->get_args ( 'mark' ) : "";
  4328. $lv21 = $this->get_args ( 'lv21' ) ? $this->get_args ( 'lv21' ) : "";
  4329. $lv22 = $this->get_args ( 'lv22' ) ? $this->get_args ( 'lv22' ) : "";
  4330. $lv23 = $this->get_args ( 'lv23' ) ? $this->get_args ( 'lv23' ) : "";
  4331. if (! empty ( $cid ) && ! empty ( $clientname )) {
  4332. Doo::loadModel ( 'client' );
  4333. Doo::loadModel ( 'district' );
  4334. $district = new district ();
  4335. $client = new client ();
  4336. $client->cid = $cid;
  4337. $client->clientname = $clientname;
  4338. $client->gender = $gender;
  4339. $client->nicename = $nicename;
  4340. $client->telephone = $telephone;
  4341. $client->phone = $phone;
  4342. $client->email = $email;
  4343. // if(!empty($unit)){
  4344. // $client->unit=$unit;
  4345. // $client->companyname=$unit;
  4346. // }
  4347. if (! empty ( $lv21 ) && ! empty ( $lv22 ) && ! empty ( $lv23 )) {
  4348. $client->district = $lv21 . "," . $lv22 . "," . $lv23;
  4349. }
  4350. if (! empty ( $client->district )) {
  4351. $districtList = $district->find ( array (
  4352. 'where' => 'id in(' . $client->district . ')',
  4353. 'asArray' => true
  4354. ) );
  4355. $jsonString = array ();
  4356. foreach ( $districtList as $value ) {
  4357. array_push ( $jsonString, $value ['name'] );
  4358. }
  4359. $jsonString = implode ( ",", $jsonString );
  4360. if (! empty ( $jsonString ))
  4361. $client->local = $jsonString;
  4362. }
  4363. $client->fax = $fax;
  4364. $client->webservice = $webservice;
  4365. $client->department = $department;
  4366. $client->position = $position;
  4367. $client->office = $office;
  4368. $client->address = $address;
  4369. $client->ride = $ride;
  4370. $client->landmarks = $landmarks;
  4371. $client->qq = $qq;
  4372. $client->stay = $stay;
  4373. $client->priority = $priority;
  4374. $client->mark = $mark;
  4375. $client->updatetime = time ();
  4376. $client->update ();
  4377. // Doo::loadModel ( 'company' );
  4378. // $company = new company();
  4379. // $companyid=$client->getOne(array('where'=>' cid='.$cid,'asArray'=>true));
  4380. // $company->office=$office;
  4381. // $company->fax=$fax;
  4382. // $company->address=$address;
  4383. // $company->ride=$ride;
  4384. // $company->landmarks=$landmarks;
  4385. // $company->cid=$companyid['companyid'];
  4386. // if(!empty($unit)){
  4387. // $company->companyname=$unit;
  4388. // }
  4389. // $company->update();
  4390. $clientInfo = $client->getOne ( array (
  4391. 'where' => ' cid=' . $cid,
  4392. 'asArray' => true
  4393. ) );
  4394. // 日常行为
  4395. Doo::loadModel ( "action_log" );
  4396. $action_log = new action_log ();
  4397. $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'] . ')';
  4398. $action_log->sid = $this->staff [0] ['sid'];
  4399. $action_log->cid = $this->staff [0] ['cid'];
  4400. $action_log->updatetime = date ( "Y-m-d" );
  4401. $action_log->time = date ( "H:i" );
  4402. $action_log->class = $action_log->iconContacts;
  4403. $action_log->status = 2;
  4404. $action_log->districtid = $clientInfo ['district'];
  4405. $local = $district->getbyidlist ( $clientInfo ['district'] );
  4406. $action_log->city = $local [0] ['name'];
  4407. $action_log->province = $local [1] ['name'];
  4408. $action_log->company = $clientInfo ['companyname'];
  4409. Doo::loadModel ( 'company' );
  4410. $company = new company ();
  4411. $companyInfo = $company->getOne ( array (
  4412. 'where' => ' companyname="' . $clientInfo ['companyname'] . '"',
  4413. 'asArray' => true
  4414. ) );
  4415. $nature = explode ( ',', $companyInfo ['nature'] );
  4416. $action_log->nature = $nature [0];
  4417. $action_log->insert ();
  4418. echo json_encode ( array (
  4419. "success" => true
  4420. ) );
  4421. die ();
  4422. } else
  4423. echo json_encode ( array (
  4424. "success" => false
  4425. ) );
  4426. die ();
  4427. }
  4428. function ajaxClientInfo() {
  4429. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  4430. if (! empty ( $cid )) {
  4431. Doo::loadModel ( 'client' );
  4432. Doo::loadModel ( 'company' );
  4433. $company = new company ();
  4434. $client = new client ();
  4435. $info = $client->getOne ( array (
  4436. 'where' => ' cid=' . $cid,
  4437. 'asArray' => true
  4438. ) );
  4439. $cinfo = $company->getOne ( array (
  4440. 'where' => ' cid=' . $info ['companyid'],
  4441. 'asArray' => true
  4442. ) );
  4443. Doo::loadModel ( 'district' );
  4444. $district = new district ();
  4445. $districtLv1 = $district->get_lv ( 1 );
  4446. $info ['districtList'] = $district->getbyidlist ( $info ['district'] );
  4447. $optionHtml = '<option vlaue="0">请选择</option>';
  4448. foreach ( $districtLv1 as $key => $value ) {
  4449. if ($value ['name'] == $info ['districtList'] [0] ['name']) {
  4450. $optionHtml .= '<option selected value="' . $value ['id'] . '">' . $value ['name'] . '</option>';
  4451. } else
  4452. $optionHtml .= '<option value="' . $value ['id'] . '">' . $value ['name'] . '</option>';
  4453. }
  4454. $districtLv2 = $district->get_lvByid ( 2, $info ['districtList'] [0] ['id'] );
  4455. $optionHtml2 = '';
  4456. foreach ( $districtLv2 as $key => $value ) {
  4457. if ($value ['name'] == $info ['districtList'] [1] ['name'])
  4458. $optionHtml2 .= '<option selected value="' . $value ['id'] . '">' . $value ['name'] . '</option>';
  4459. else
  4460. $optionHtml2 .= '<option value="' . $value ['id'] . '">' . $value ['name'] . '</option>';
  4461. }
  4462. $districtLv3 = $district->get_lvByid ( 2, $info ['districtList'] [1] ['id'] );
  4463. $optionHtml3 = '';
  4464. foreach ( $districtLv3 as $key => $value ) {
  4465. if ($value ['name'] == $info ['districtList'] [2] ['name'])
  4466. $optionHtml3 .= '<option selected value="' . $value ['id'] . '">' . $value ['name'] . '</option>';
  4467. else
  4468. $optionHtml3 .= '<option value="' . $value ['id'] . '">' . $value ['name'] . '</option>';
  4469. }
  4470. $info ['districtLv1'] = $optionHtml;
  4471. $info ['districtLv2'] = $optionHtml2;
  4472. $info ['districtLv3'] = $optionHtml3;
  4473. $info ['companyInfo'] = $cinfo;
  4474. echo json_encode ( array (
  4475. "success" => true,
  4476. 'html' => $info
  4477. ) );
  4478. die ();
  4479. } else
  4480. echo json_encode ( array (
  4481. "success" => false,
  4482. 'html' => ''
  4483. ) );
  4484. die ();
  4485. }
  4486. /**
  4487. * 为客户添加服务日志
  4488. */
  4489. function ajaxAddServiceLog() {
  4490. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : "";
  4491. $clientid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : "";
  4492. $mark = $this->get_args ( 'mark' ) ? $this->get_args ( 'mark' ) : "";
  4493. $m = $this->get_args ( 'm' ) ? $this->get_args ( 'm' ) : "";
  4494. $d = $this->get_args ( 'd' ) ? $this->get_args ( 'd' ) : "";
  4495. $y = $this->get_args ( 'y' ) ? $this->get_args ( 'y' ) : date ( "Y" );
  4496. $Remind = $this->get_args ( 'Remind' ) ? $this->get_args ( 'Remind' ) : 0;
  4497. $time = $this->get_args ( 'time' ) ? $this->get_args ( 'time' ) : 0;
  4498. $remark = $this->get_args ( 'remark' ) ? $this->get_args ( 'remark' ) : "";
  4499. if (! empty ( $status ) && ! empty ( $clientid )) {
  4500. Doo::loadModel ( 'service_log' );
  4501. Doo::loadModel ( 'client_staff' );
  4502. Doo::loadModel ( 'client' );
  4503. Doo::loadModel ( 'district' );
  4504. $district = new district ();
  4505. $client = new client ();
  4506. $clientStaff = new client_staff ();
  4507. $service_log = new service_log ();
  4508. $service_log->status = $status;
  4509. $service_log->clientid = $clientid;
  4510. $service_log->mark = htmlspecialchars ( $mark );
  4511. $service_log->date = $y . "-" . $m . "-" . $d;
  4512. $service_log->category = $this->staff [0] ['category'];
  4513. $service_log->staffname = $this->staff [0] ['username'];
  4514. $service_log->staffid = $this->staff [0] ['sid'];
  4515. $service_log->insert ();
  4516. // 日常行为
  4517. Doo::loadModel ( "action_log" );
  4518. Doo::loadModel ( "client" );
  4519. $client = new client ();
  4520. // 记录服务时间
  4521. $client->cid = $clientid;
  4522. $client->servicetime = time ();
  4523. $client->update ();
  4524. $action_log = new action_log ();
  4525. $clientInfo = $client->getOne ( array (
  4526. 'where' => ' cid=' . $clientid,
  4527. 'asArray' => TRUE
  4528. ) );
  4529. $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'] . ')添加新客户记录。';
  4530. $action_log->sid = $this->staff [0] ['sid'];
  4531. $action_log->cid = $this->staff [0] ['cid'];
  4532. $action_log->updatetime = date ( "Y-m-d" );
  4533. $action_log->time = date ( "H:i" );
  4534. $action_log->status = 3;
  4535. $action_log->districtid = $clientInfo ['district'];
  4536. $local = $district->getbyidlist ( $clientInfo ['district'] );
  4537. $action_log->city = $local [0] ['name'];
  4538. $action_log->province = $local [1] ['name'];
  4539. $action_log->company = $clientInfo ['companyname'];
  4540. Doo::loadModel ( 'company' );
  4541. $company = new company ();
  4542. $companyInfo = $company->getOne ( array (
  4543. 'where' => ' companyname="' . $clientInfo ['companyname'] . '"',
  4544. 'asArray' => true
  4545. ) );
  4546. $nature = explode ( ',', $companyInfo ['nature'] );
  4547. $action_log->nature = $nature [0];
  4548. $action_log->class = $action_log->iconContacts;
  4549. $action_log->insert ();
  4550. // 更新信息中心服务日志统计数量
  4551. $redis = new Redis ();
  4552. $redis->connect ( '127.0.0.1', '6379' );
  4553. $categoryCondition = " and cid=" . $this->staff [0] ['cid'];
  4554. $sidCondition = " and sid=" . $this->staff [0] ['sid'];
  4555. // actionlog免查询值 $alCondition='';
  4556. $alCondition = ' aid>' . REMIT . ' and ';
  4557. // 个人服务日志数量redis值
  4558. $redisKeyCS = date ( 'Y-m-d' ) . 'SL_' . $this->staff [0] ['cid'] . '_' . $this->staff [0] ['sid'];
  4559. $action_log = new action_log ();
  4560. $actionLogLongle = $action_log->find ( array (
  4561. 'select' => 'date_format(updatetime,"%m-%d") as updatetime,COUNT(*) as count',
  4562. 'where' => $alCondition . " status=3 " . $categoryCondition . $sidCondition . " and date_sub(curdate(), INTERVAL 30 DAY) <= date(updatetime) ",
  4563. 'groupby' => 'date_format(updatetime,"%m-%d")',
  4564. 'asArray' => true
  4565. ) );
  4566. $statisticsLongle = array ();
  4567. for($d = 0; $d <= 29; $d ++) {
  4568. $MD = date ( "m-d", strtotime ( "-" . $d . " day" ) );
  4569. $falgLongle = true;
  4570. foreach ( $actionLogLongle as $value ) {
  4571. if ($value ['updatetime'] == $MD) {
  4572. array_push ( $statisticsLongle, $value ['count'] );
  4573. $falgLongle = false;
  4574. break;
  4575. }
  4576. }
  4577. if ($falgLongle)
  4578. array_push ( $statisticsLongle, 0 );
  4579. }
  4580. $statisticsLongle = array_reverse ( $statisticsLongle );
  4581. $jsl = json_encode ( $statisticsLongle );
  4582. $redis->set ( $redisKeyCS, $jsl );
  4583. // 办事处服务日志数量reids值
  4584. $redisKeyC = date ( 'Y-m-d' ) . 'SL_' . $this->staff [0] ['cid'] . '_';
  4585. $action_log = new action_log ();
  4586. $actionLogLongle = $action_log->find ( array (
  4587. 'select' => 'date_format(updatetime,"%m-%d") as updatetime,COUNT(*) as count',
  4588. 'where' => $alCondition . " status=3 " . $categoryCondition . " and date_sub(curdate(), INTERVAL 30 DAY) <= date(updatetime) ",
  4589. 'groupby' => 'date_format(updatetime,"%m-%d")',
  4590. 'asArray' => true
  4591. ) );
  4592. $statisticsLongle = array ();
  4593. for($d = 0; $d <= 29; $d ++) {
  4594. $MD = date ( "m-d", strtotime ( "-" . $d . " day" ) );
  4595. $falgLongle = true;
  4596. foreach ( $actionLogLongle as $value ) {
  4597. if ($value ['updatetime'] == $MD) {
  4598. array_push ( $statisticsLongle, $value ['count'] );
  4599. $falgLongle = false;
  4600. break;
  4601. }
  4602. }
  4603. if ($falgLongle)
  4604. array_push ( $statisticsLongle, 0 );
  4605. }
  4606. $statisticsLongle = array_reverse ( $statisticsLongle );
  4607. $jsl = json_encode ( $statisticsLongle );
  4608. $redis->set ( $redisKeyC, $jsl );
  4609. // 全员处服务日志数量的redis值
  4610. $redisKey = date ( 'Y-m-d' ) . 'SL__';
  4611. $action_log = new action_log ();
  4612. $actionLogLongle = $action_log->find ( array (
  4613. 'select' => 'date_format(updatetime,"%m-%d") as updatetime,COUNT(*) as count',
  4614. 'where' => $alCondition . " status=3 and date_sub(curdate(), INTERVAL 30 DAY) <= date(updatetime) ",
  4615. 'groupby' => 'date_format(updatetime,"%m-%d")',
  4616. 'asArray' => true
  4617. ) );
  4618. $statisticsLongle = array ();
  4619. for($d = 0; $d <= 29; $d ++) {
  4620. $MD = date ( "m-d", strtotime ( "-" . $d . " day" ) );
  4621. $falgLongle = true;
  4622. foreach ( $actionLogLongle as $value ) {
  4623. if ($value ['updatetime'] == $MD) {
  4624. array_push ( $statisticsLongle, $value ['count'] );
  4625. $falgLongle = false;
  4626. break;
  4627. }
  4628. }
  4629. if ($falgLongle)
  4630. array_push ( $statisticsLongle, 0 );
  4631. }
  4632. $statisticsLongle = array_reverse ( $statisticsLongle );
  4633. $jsl = json_encode ( $statisticsLongle );
  4634. $redis->set ( $redisKey, $jsl );
  4635. if (! empty ( $Remind )) {
  4636. Doo::loadModel ( 'remind' );
  4637. $remindObj = new remind ();
  4638. $datetime1 = new DateTime ( date ( 'Y-m-d' ) );
  4639. $datetime2 = new DateTime ( $time );
  4640. $interval = $datetime1->diff ( $datetime2 );
  4641. $remindObj->day = $interval->format ( '%a' );
  4642. $remindObj->remark = $remark;
  4643. $remindObj->time = date ( "Y-m-d" );
  4644. $remindObj->clientName = $clientInfo ['clientname'];
  4645. $remindObj->clientID = $clientid;
  4646. $remindObj->companyName = $clientInfo ['companyname'];
  4647. $remindObj->companyID = $companyInfo ['cid'];
  4648. $remindObj->staffID = $this->staff [0] ['sid'];
  4649. if ($status == 1)
  4650. $remindObj->class = "iconService";
  4651. if ($status == 2)
  4652. $remindObj->class = "iconPhone";
  4653. if ($status == 3)
  4654. $remindObj->class = "iconOther";
  4655. $remindObj->insert ();
  4656. }
  4657. echo json_encode ( array (
  4658. "success" => true,
  4659. 'html' => ''
  4660. ) );
  4661. die ();
  4662. } else
  4663. echo json_encode ( array (
  4664. "success" => false,
  4665. 'html' => ''
  4666. ) );
  4667. die ();
  4668. }
  4669. function _getLongleLogHtml($longleLog = array()) {
  4670. $html = "";
  4671. foreach ( $longleLog as $key => $value ) {
  4672. $dateline = explode ( "-", $value ['dateline'] );
  4673. $html .= '<div class="infoFlowList">
  4674. <div class="dateTitle">
  4675. <em class="month"><span class="num">' . $dateline [1] . '</span><span class="text">-' . $dateline [2] . '</span></em>
  4676. <span class="year">' . $dateline [0] . '</span>
  4677. </div>
  4678. ';
  4679. // 备注
  4680. if ($value ['status'] == 8) {
  4681. $html .= '
  4682. <ul class="flowList">
  4683. <li class="item iconLock">备注<' . $value ['category'] . '<a href="javascript:void(0);" onclick="getStaffInfo(\'' . $value ['operator'] . '\')" >' . $value ['operator'] . '</a></li>
  4684. <li class="item">' . $value ['mark'] . '</li>
  4685. </ul>';
  4686. } elseif ($value ['status'] == 10) {
  4687. $html .= '
  4688. <ul class="flowList">
  4689. <li class="item iconLock">延期<' . $value ['category'] . '<a href="javascript:void(0);" onclick="getStaffInfo(\'' . $value ['operator'] . '\')" >' . $value ['operator'] . '</a></li>
  4690. <li class="item">' . $value ['mark'] . '</li>
  4691. </ul>';
  4692. // 生成
  4693. }elseif ($value ['status'] == 1) {
  4694. $html .= '<ul class="flowList">
  4695. <li class="item iconGenerate">生成<' . $value ['category'] . '<a href="javascript:void(0);" onclick="getStaffInfo(\'' . $value ['operator'] . '\')" >' . $value ['operator'] . '</a></li>
  4696. </ul>';
  4697. // 接收
  4698. } elseif ($value ['status'] == 2) {
  4699. $html .= '<ul class="flowList">
  4700. <li class="item iconReceive">接收<' . $value ['category'] . '<a href="javascript:void(0);" onclick="getStaffInfo(\'' . $value ['operator'] . '\')" >' . $value ['operator'] . '</a></li>
  4701. </ul>';
  4702. // 借出
  4703. } elseif ($value ['status'] == 3) {
  4704. $html .= '<ul class="flowList">
  4705. <li class="item iconBorrow">借出<' . $value ['category'] . '<a href="javascript:void(0);" onclick="getStaffInfo(\'' . $value ['operator'] . '\')" >' . $value ['operator'] . '</a></li>
  4706. <li class="item">' . $value ['product'] . '</li>
  4707. <li class="item"><a href="javascript:void(0);" onclick="getClientInfo(\'' . $value ['clientid'] .'\')" >' . $value ['client'] . '</a></li>
  4708. </ul>';
  4709. // 销售
  4710. } elseif ($value ['status'] == 4) {
  4711. $html .= '<ul class="flowList">
  4712. <li class="item iconSell">销售<' . $value ['category'] . '<a href="javascript:void(0);" onclick="getStaffInfo(\'' . $value ['operator'] . '\')" >' . $value ['operator'] . '</a></li>
  4713. <li class="item">' . $value ['product'] . '</li>
  4714. <li class="item"><a href="javascript:void(0);" onclick="getClientInfo(\'' . $value ['clientid'] . '\')" >' . $value ['client'] . '</a></li>
  4715. </ul>';
  4716. // 升级
  4717. } elseif ($value ['status'] == 5) {
  4718. $html .= '<ul class="flowList">
  4719. <li class="item iconUpdate">升级<' . $value ['category'] . '<a href="javascript:void(0);" onclick="getStaffInfo(\'' . $value ['operator'] . '\')" >' . $value ['operator'] . '</a></li>
  4720. <li class="item">' . $value ['product'] . '</li>
  4721. <li class="item"><a href="javascript:void(0);" onclick="getClientInfo(\'' . $value ['clientid'] . '\')" >' . $value ['client'] . '</a></li>
  4722. </ul>';
  4723. // 更换
  4724. } elseif ($value ['status'] == 6) {
  4725. $html .= '<ul class="flowList">
  4726. <li class="item iconReplace">更换<' . $value ['category'] . '<a href="javascript:void(0);" onclick="getStaffInfo(\'' . $value ['operator'] . '\')">' . $value ['operator'] . '</a></li>
  4727. <li class="item"><a href="javascript:void(0);" onclick="getLockByName(\'' . $value ['new_key_num'] . '\')">' . $value ['new_key_num'] . '</a>
  4728. <li class="item"><a href="javascript:void(0);" onclick="getClientInfo(\'' . $value ['clientid'] . '\')" >' . $value ['client'] . '</a></li>
  4729. </ul>';
  4730. // 回收
  4731. } elseif ($value ['status'] == 7) {
  4732. Doo::loadModel ( 'staff' );
  4733. $staff = new staff ();
  4734. $staffinfo = $staff->getOne ( array (
  4735. 'where' => ' username like "' . $value ['responsible'] . '"',
  4736. 'asArray' => true
  4737. ) );
  4738. if (empty ( $staffinfo ))
  4739. $staffinfo ['category'] = "";
  4740. $html .= '<ul class="flowList">
  4741. <li class="item iconRecycle">收回<' . $value ['category'] . '<a href="javascript:void(0);" onclick="getStaffInfo(\'' . $value ['operator'] . '\')">' . $value ['operator'] . '</a></li>
  4742. <li class="item">' . $staffinfo ['category'] . '<a href="javascript:void(0);" id="ajaxStaff" data="' . $value ['responsible'] . '">' . $value ['responsible'] . '</a></li>
  4743. </ul>';
  4744. } elseif ($value ['status'] == 9) {
  4745. $html .= '<ul class="flowList">
  4746. <li class="item iconGif">赠送 &lt; ' . $value ['category'] . '<a href="javascript:void(0);" onclick="getStaffInfo(\'' . $value ['operator'] . '\')">' . $value ['operator'] . '</a></li>
  4747. <li class="item"><a href="javascript:void(0);" onclick="getClientInfo(\'' . $value ['clientid'] . '\')" >' . $value ['client'] . '</a></li>
  4748. </ul>';
  4749. }
  4750. $html .= '</div>';
  4751. }
  4752. return $html;
  4753. }
  4754. function adminLock() {
  4755. $emsg = isset ( $this->params ['emsg'] ) ? $this->params ['emsg'] : "";
  4756. $data ['emsg'] = "";
  4757. if ($emsg != "")
  4758. $data ['emsg'] = "请填写完整的数据";
  4759. $data ['memu'] = "keyonline";
  4760. $data ['staff'] = $this->staff;
  4761. if ($this->staff [0] ['isadmin'] != 1)
  4762. return "/adminmyinfo";
  4763. Doo::loadModel ( 'L_category' );
  4764. $L_category = new L_category ();
  4765. $data ['category'] = $L_category->getCategory ();
  4766. $data ['time'] = time ();
  4767. $this->render ( "/admin/admin_addlock", $data );
  4768. }
  4769. function adminAddLock() {
  4770. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  4771. $path = $this->get_args ( 'path' ) ? $this->get_args ( 'path' ) : "";
  4772. if ($cid != 0 && $path != "") {
  4773. Doo::loadModel ( 'longle' );
  4774. Doo::loadModel ( 'L_category' );
  4775. $L_category = new L_category ();
  4776. Doo::loadModel ( 'longle_log' );
  4777. $exlArray = $this->_format_excel_to_array ( DOO::conf ()->SITE_PATH . "upload/" . iconv ( "UTF-8", "GB2312", $path ) );
  4778. // print_r($exlArray);die;
  4779. // echo json_encode($exlArray);die;
  4780. $category = $L_category->getCategoryById ( $cid );
  4781. foreach ( $exlArray as $key => $value ) {
  4782. // 锁记录
  4783. $longle = new longle ();
  4784. $longle->key_num = str_replace ( "'", "", $value ['key_num'] );
  4785. $longle->product = str_replace ( "'", "", $value ['product'] );
  4786. $longle->make_day = $value ['make_day'];
  4787. $longle->alloted_time = $value ['alloted_time'];
  4788. $longle->status = 1;
  4789. $longle->statusT = "生成";
  4790. $longle->cid = $cid;
  4791. $longle->category = $category [0] ['title'];
  4792. $longle->SerialNumber = $value ['SerialNumber'];
  4793. $longle->version = $value ['version'];
  4794. $lid = $longle->insert ();
  4795. // 锁日志记录
  4796. $longle_log = new longle_log ();
  4797. $longle_log->lid = $lid;
  4798. $longle_log->status = 1;
  4799. $longle_log->statusT = "生成";
  4800. $longle_log->operator = $this->staff [0] ['username'];
  4801. $longle_log->product = $longle->product;
  4802. $longle_log->category = $this->staff [0] ['category'];
  4803. $longle_log->dateline = date ( "Y-m-d" );
  4804. $id = $longle_log->insert ();
  4805. }
  4806. // 记录日常行为
  4807. Doo::loadModel ( "action_log" );
  4808. $action_log = new action_log ();
  4809. $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>个锁';
  4810. $action_log->sid = $this->staff [0] ['sid'];
  4811. $action_log->cid = $this->staff [0] ['cid'];
  4812. $action_log->class = $action_log->iconGenerate;
  4813. $action_log->updatetime = date ( "Y-m-d" );
  4814. $action_log->time = date ( "H:i" );
  4815. $action_log->status = 11;
  4816. $action_log->insert ();
  4817. return "/keyonline";
  4818. } else
  4819. return "/adminlock/error";
  4820. }
  4821. function avatarCM() {
  4822. $vid = isset ( $this->params ['vid'] ) ? $this->params ['vid'] : 0;
  4823. if (! empty ( $vid )) {
  4824. Doo::loadModel ( "verify" );
  4825. $verify = new verify ();
  4826. Doo::loadModel ( 'staff' );
  4827. $staff = new staff ();
  4828. $list = $verify->getOne ( array (
  4829. 'where' => 'vid=' . $vid,
  4830. 'asArray' => true
  4831. ) );
  4832. if (empty ( $list ))
  4833. return "/adminverify";
  4834. $avatar = json_decode ( $list ['staff'] );
  4835. foreach ( $avatar as $key => $value ) {
  4836. $uinfo = $staff->getOne ( array (
  4837. 'where' => 'sid=' . $value [0],
  4838. 'asArray' => true
  4839. ) );
  4840. $avatar [$key] ['2'] = $uinfo ['avatar'];
  4841. }
  4842. $verify->staff = json_encode ( $avatar );
  4843. $verify->update ( array (
  4844. 'where' => 'vid=' . $vid
  4845. ) );
  4846. }
  4847. return "/adminverify";
  4848. }
  4849. function adminmyinfo() {
  4850. $data ['memu'] = "adminmyinfo";
  4851. $data ['staff'] = $this->staff;
  4852. $birArray = explode ( '-', $this->staff [0] ['birthday'] );
  4853. $data ['year'] = $birArray [0];
  4854. $year = date ( 'Y' );
  4855. $yearHtml = "";
  4856. for(; $year >= 1900; $year --) {
  4857. $yearHtml .= '<option ';
  4858. if ($data ['year'] == $year)
  4859. $yearHtml .= 'selected';
  4860. $yearHtml .= ' value="' . $year . '">' . $year . '</option>';
  4861. }
  4862. $data ['yearHtml'] = $yearHtml;
  4863. $data ['month'] = 01;
  4864. $data ['day'] = 01;
  4865. if (isset ( $birArray [1] )) {
  4866. $data ['month'] = $birArray [1];
  4867. $data ['day'] = $birArray [2];
  4868. }
  4869. $data ['msg'] = urldecode ( $this->params ['msg'] );
  4870. $this->render ( "/admin/admin_myinfo", $data );
  4871. }
  4872. function updateMyinfo() {
  4873. $telephone = $this->get_args ( 'telephone' ) ? $this->get_args ( 'telephone' ) : 0;
  4874. $phone = $this->get_args ( 'phone' ) ? $this->get_args ( 'phone' ) : 0;
  4875. $email = $this->get_args ( 'email' ) ? $this->get_args ( 'email' ) : "";
  4876. $qq = is_numeric ( $this->get_args ( 'qq' ) ) ? $_POST ['qq'] : 0;
  4877. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  4878. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  4879. $day = $this->get_args ( 'day' ) ? $this->get_args ( 'day' ) : "";
  4880. $position = $this->get_args ( 'position' ) ? $this->get_args ( 'position' ) : "";
  4881. $gender = $this->get_args ( 'gender' ) ? $this->get_args ( 'gender' ) : "男";
  4882. $oldpassword = $this->get_args ( 'oldpassword' ) ? $this->get_args ( 'oldpassword' ) : "";
  4883. $newpassword = $this->get_args ( 'newpassword' ) ? $this->get_args ( 'newpassword' ) : "";
  4884. $rnewpassword = $this->get_args ( 'rnewpassword' ) ? $this->get_args ( 'rnewpassword' ) : "";
  4885. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  4886. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  4887. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  4888. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  4889. Doo::loadModel ( 'staff' );
  4890. $staff = new staff ();
  4891. Doo::loadModel ( 'staffDynamic' );
  4892. $staffDynamic = new staffDynamic ();
  4893. $staff->sid = $this->staff [0] ['sid'];
  4894. if (! empty ( $remittanceName ))
  4895. $staff->remittanceName = $remittanceName;
  4896. if (! empty ( $bankName ))
  4897. $staff->bankName = $bankName;
  4898. if (! empty ( $bankNumber ))
  4899. $staff->bankNumber = $bankNumber;
  4900. if (! empty ( $coupletNumber ))
  4901. $staff->coupletNumber = $coupletNumber;
  4902. $content = "";
  4903. $ext = "更新了他的";
  4904. if ($telephone != 0 && $this->staff [0] ['telephone'] != $telephone) {
  4905. $staff->telephone = $telephone;
  4906. $content .= "<b>手机</b>&nbsp;";
  4907. }
  4908. if ($phone != 0 && $this->staff [0] ['phone'] != $phone) {
  4909. $staff->phone = $phone;
  4910. $content .= "<b>电话</b>&nbsp;";
  4911. }
  4912. if ($qq != 0 && $this->staff [0] ['qq'] != $qq) {
  4913. $staff->qq = $qq;
  4914. $content .= "<b>QQ</b>&nbsp;";
  4915. }
  4916. if ($year != 2014) {
  4917. $staff->birthday = $year . "-" . $month . "-" . $day;
  4918. $content .= "<b>生日</b>&nbsp;";
  4919. }
  4920. if ($email != "" && filter_var ( $email, FILTER_VALIDATE_EMAIL ) && $this->staff [0] ['email'] != $email) {
  4921. $staff->email = $email;
  4922. $content .= "<b>邮箱</b>&nbsp;";
  4923. }
  4924. if (! empty ( $position )) {
  4925. $staff->position = $position;
  4926. $content .= "<b>职位</b>&nbsp;";
  4927. }
  4928. $staff->gender = $gender;
  4929. $msg = "更新成功";
  4930. if ($this->staff [0] ['passwork'] == md5 ( $oldpassword )) {
  4931. if ($newpassword == $rnewpassword && (! empty ( $newpassword )))
  4932. $staff->passwork = md5 ( $newpassword );
  4933. else
  4934. $msg = "密码不一致";
  4935. } else {
  4936. if ($oldpassword != "")
  4937. $msg = "密码错误";
  4938. }
  4939. if (! empty ( $content )) {
  4940. $staffDynamic->content = $ext . $content;
  4941. $staffDynamic->cid = $this->staff [0] ['cid'];
  4942. $staffDynamic->category = $this->staff [0] ['category'];
  4943. $staffDynamic->time = time ();
  4944. $staffDynamic->sid = $this->staff [0] ['sid'];
  4945. $staffDynamic->staff = $this->staff [0] ['username'];
  4946. $staffDynamic->insert ();
  4947. }
  4948. $staff->update ( array (
  4949. 'where' => ' sid=' . $this->staff [0] ['sid']
  4950. ) );
  4951. return "/adminmyinfo/" . $msg;
  4952. }
  4953. function admincontacts() {
  4954. $data ['memu'] = "admincontacts";
  4955. $data ['staff'] = $this->staff;
  4956. Doo::loadModel ( 'L_category' );
  4957. Doo::loadModel ( 'staff' );
  4958. $staff = new staff ();
  4959. $L_category = new L_category ();
  4960. $this->render ( "/admin/admin_addContacts", $data );
  4961. }
  4962. /**
  4963. * 微信通知设置
  4964. */
  4965. // function notificationConf() {
  4966. // Doo::loadModel ( "notificationConf" );
  4967. // $notificationConf = new notificationConf ();
  4968. // $detail = $notificationConf->getNotificationConfBySid ( $this->staff [0] ['sid'] );
  4969. // $rule = json_decode ( $detail ['conf'], true );
  4970. // $data ['rule'] = $rule;
  4971. // $data ['memu'] = "notificationConf";
  4972. // $data ['staff'] = $this->staff;
  4973. // $this->render ( "/admin/invoiceNotificationConf", $data );
  4974. // }
  4975. // function ajaxSetNotificationConf() {
  4976. // $notificationType = $this->get_args ( 'notificationType' ) ? $this->get_args ( 'notificationType' ) : "";
  4977. // $notificationValue = $this->get_args ( 'notificationValue' ) ? $this->get_args ( 'notificationValue' ) : '';
  4978. // if (! empty ( $notificationType ) && ! empty ( $notificationValue ) && ! empty ( $this->staff [0] ['sid'] )) {
  4979. // Doo::loadModel ( "notificationConf" );
  4980. // $notificationConf = new notificationConf ();
  4981. // $detail = $notificationConf->getNotificationConfBySid ( $this->staff [0] ['sid'] );
  4982. // if (empty ( $detail )) {
  4983. // $rule = array (
  4984. // $notificationType => $notificationValue
  4985. // );
  4986. // $rule = json_encode ( $rule );
  4987. // $item = array (
  4988. // 'sid' => $this->staff [0] ['sid'],
  4989. // 'conf' => $rule
  4990. // );
  4991. // $notificationConf->addNotification ( $item );
  4992. // } else {
  4993. // $rule = json_decode ( $detail ['conf'], true );
  4994. // $rule [$notificationType] = $notificationValue;
  4995. // $rule = json_encode ( $rule );
  4996. // $item = array (
  4997. // 'nid' => $detail ['nid'],
  4998. // 'conf' => $rule
  4999. // );
  5000. // $notificationConf->setNotificationByCondition ( $item );
  5001. // }
  5002. // echo json_encode ( array (
  5003. // 'status' => 1,
  5004. // 'msgType' => $notificationType,
  5005. // 'msg' => ''
  5006. // ) );
  5007. // die ();
  5008. // }
  5009. // echo json_encode ( array (
  5010. // 'status' => 2,
  5011. // 'msgType' => $notificationType,
  5012. // 'msg' => 'illegal request'
  5013. // ) );
  5014. // die ();
  5015. // }
  5016. function eMailTask() {
  5017. Doo::loadModel ( 'tag' );
  5018. $tag = new tag ();
  5019. Doo::loadModel ( 'district' );
  5020. $district = new district ();
  5021. $tagList = $tag->getAllBySid ( $this->staff [0] ['sid'] );
  5022. $districtList = $district->get_lv ( 1 );
  5023. $data ['tagList'] = $tagList;
  5024. $data ['districtList'] = $districtList;
  5025. $data ['memu'] = "eMailTask";
  5026. $data ['staff'] = $this->staff;
  5027. $data ['mailMemu'] = 'eMailTask';
  5028. $data ['nature'] = $this->nature;
  5029. $this->render ( "/mail_create", $data );
  5030. }
  5031. function eMialCenter() {
  5032. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  5033. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : 0;
  5034. Doo::loadModel ( 'eMailList' );
  5035. $eMailList = new eMailList ();
  5036. Doo::loadModel ( 'tag' );
  5037. $tag = new tag ();
  5038. Doo::loadModel ( 'staff' );
  5039. $staff = new staff ();
  5040. $dateCondition = "status!=2 and Year(date) =" . $year;
  5041. if (! empty ( $month ))
  5042. $dateCondition = "Year(date) =" . $year . " and Month(date) = " . $month;
  5043. $mailList = $eMailList->find ( array (
  5044. 'where' => $dateCondition,
  5045. 'asc' => 'status',
  5046. 'desc' => 'elid',
  5047. 'asArray' => true
  5048. ) );
  5049. foreach ( $mailList as $key => $value ) {
  5050. $mailList [$key] ['clientName2'] = $mailList [$key] ['clientName3'] = array ();
  5051. $mailList [$key] ['clientName'] = json_decode ( gzuncompress ( base64_decode ( $value ['clientName'] ) ), true );
  5052. if (! empty ( $value ['clientName2'] ))
  5053. $mailList [$key] ['clientName2'] = json_decode ( gzuncompress ( base64_decode ( $value ['clientName2'] ) ), true );
  5054. if (! empty ( $value ['clientName3'] ))
  5055. $mailList [$key] ['clientName3'] = json_decode ( gzuncompress ( base64_decode ( $value ['clientName3'] ) ), true );
  5056. $mailList [$key] ['illegalEmail'] = json_decode ( $value ['illegalEmail'], true );
  5057. $mailList [$key] ['sendEmail'] = json_decode ( $value ['sendEmail'], true );
  5058. $mailList [$key] ['clientCount'] = count ( $mailList [$key] ['clientName'] ) + count ( $mailList [$key] ['clientName2'] ) + count ( $mailList [$key] ['clientName3'] );
  5059. $mailList [$key] ['tag'] = array ();
  5060. $kks = $staff->getOne ( array (
  5061. 'where' => 'username like "' . $value ['staffName'] . '"',
  5062. 'asArray' => true
  5063. ) );
  5064. $mailList [$key] ['category'] = $kks ['category'];
  5065. if (! empty ( $value ['tag'] ))
  5066. $mailList [$key] ['tag'] = $tag->find ( array (
  5067. 'where' => 'tid in ( ' . $value ['tag'] . ') ',
  5068. 'asArray' => true
  5069. ) );
  5070. }
  5071. $dateHtml = "";
  5072. $now = date ( "Y" );
  5073. for($YEARD = 2014; $YEARD <= 2050; $YEARD ++) {
  5074. if ($YEARD <= $now) {
  5075. $dateHtml .= '<option ';
  5076. if ($year == $YEARD)
  5077. $dateHtml .= ' selected ';
  5078. $dateHtml .= ' value="' . $YEARD . '">' . $YEARD . '</option>';
  5079. }
  5080. }
  5081. $monthHtml = '<option value="0">所有月份</option>';
  5082. for($i = 1; $i <= 12; $i ++) {
  5083. $monthHtml .= '<option ';
  5084. if ($i == $month)
  5085. $monthHtml .= ' selected ';
  5086. $monthHtml .= ' value="' . $i . '">' . $i . '</option>';
  5087. }
  5088. $data ['monthHtml'] = $monthHtml;
  5089. $data ['dateHtml'] = $dateHtml;
  5090. $data ['mailList'] = $mailList;
  5091. $data ['memu'] = "eMailTask";
  5092. $data ['staff'] = $this->staff;
  5093. $data ['mailMemu'] = 'eMialCenter';
  5094. $data ['nature'] = $this->nature;
  5095. $this->render ( "/mailCenter", $data );
  5096. }
  5097. function authMail() {
  5098. $elid = isset ( $this->params ['elid'] ) ? $this->params ['elid'] : 0;
  5099. if (! empty ( $elid )) {
  5100. Doo::loadModel ( 'eMailList' );
  5101. $eMailList = new eMailList ();
  5102. $eMailList->examine = 2;
  5103. $eMailList->mark = $this->staff [0] ['username'] . "已同意";
  5104. $eMailList->update ( array (
  5105. 'where' => 'elid=' . $elid,
  5106. 'asArray' => true
  5107. ) );
  5108. }
  5109. return '/eMialCenter';
  5110. }
  5111. function editMailView() {
  5112. $elid = isset ( $this->params ['elid'] ) ? $this->params ['elid'] : 0;
  5113. Doo::loadModel ( 'tag' );
  5114. $tag = new tag ();
  5115. Doo::loadModel ( 'district' );
  5116. $district = new district ();
  5117. Doo::loadModel ( 'eMailList' );
  5118. $eMList = new eMailList ();
  5119. $mail = $eMList->getOne ( array (
  5120. 'where' => 'elid =' . $elid . '',
  5121. 'asArray' => true
  5122. ) );
  5123. if (empty ( $mail ))
  5124. return "/eMailList";
  5125. $mail ['tagList'] = explode ( ",", $mail ['tag'] );
  5126. $tagList = $tag->getAllBySid ( $this->staff [0] ['sid'] );
  5127. $districtList = $district->get_lv ( 1 );
  5128. $tagHtml = '';
  5129. foreach ( $tagList as $key => $value ) {
  5130. $tagHtml .= '<label><span data-original-title="' . $value ['name'] . '" data-toggle="ctooltip" data-placement="right" class="contactsTag tagCol-0' . $value ['colorid'] . '">
  5131. <input type="checkbox" name="tagId[]"';
  5132. foreach ( $mail ['tagList'] as $k => $v ) {
  5133. if ($value ['tid'] == $v) {
  5134. $tagHtml .= ' checked ';
  5135. break;
  5136. }
  5137. }
  5138. $tagHtml .= ' value="' . $value ['tid'] . '"></span></label>';
  5139. }
  5140. $districtHtml = '';
  5141. foreach ( $districtList as $key => $value ) {
  5142. $districtHtml .= '<option value="' . $value ['id'] . '"';
  5143. if ($value ['id'] == $mail ['districtId'])
  5144. $districtHtml .= 'selected';
  5145. $districtHtml .= '>' . $value ['name'] . '</option>';
  5146. }
  5147. $natureHtml = '';
  5148. $natList = explode ( ",", $mail ['nature'] );
  5149. foreach ( $this->nature as $key => $value ) {
  5150. $natureHtml .= '<label><input type="checkbox" name="nature[]" ';
  5151. foreach ( $natList as $k => $v ) {
  5152. if ($value == $v) {
  5153. $natureHtml .= ' checked ';
  5154. break;
  5155. }
  5156. }
  5157. $natureHtml .= 'value="' . $value . '">' . $value . '</label>';
  5158. }
  5159. $data ['natureHtml'] = $natureHtml;
  5160. $data ['districtHtml'] = $districtHtml;
  5161. $data ['tagHtml'] = $tagHtml;
  5162. $data ['mail'] = $mail;
  5163. $data ['tagList'] = $tagList;
  5164. $data ['districtList'] = $districtList;
  5165. $data ['memu'] = "eMailTask";
  5166. $data ['staff'] = $this->staff;
  5167. $data ['mailMemu'] = 'eMailList';
  5168. $data ['nature'] = $this->nature;
  5169. $this->render ( "/mailEdit", $data );
  5170. }
  5171. function editEmail() {
  5172. $title = $this->get_args ( 'title' ) ? $this->get_args ( 'title' ) : "";
  5173. $skin = $this->get_args ( 'skin' ) ? $this->get_args ( 'skin' ) : "";
  5174. $content = isset ( $_POST ['content'] ) ? $_POST ['content'] : "";
  5175. $tagId = $this->get_args ( 'tagId' ) ? $this->get_args ( 'tagId' ) : array ();
  5176. $nature = $this->get_args ( 'nature' ) ? $this->get_args ( 'nature' ) : array ();
  5177. $natureNULL = $this->get_args ( 'natureNULL' ) ? $this->get_args ( 'natureNULL' ) : "";
  5178. $did = $this->get_args ( 'did' ) ? $this->get_args ( 'did' ) : "";
  5179. $stype = $this->get_args ( 'stype' ) ? $this->get_args ( 'stype' ) : "";
  5180. $elid = $this->get_args ( 'elid' ) ? $this->get_args ( 'elid' ) : "";
  5181. if (! empty ( $title ) && ! empty ( $elid ) && (! empty ( $tagId ) || ! empty ( $did ))) {
  5182. Doo::loadModel ( 'eMailList' );
  5183. $eMailList = new eMailList ();
  5184. $etid = $eMailList->getOne ( array (
  5185. 'select' => 'etid,annexName,annex',
  5186. 'where' => 'elid=' . $elid,
  5187. 'asArray' => true
  5188. ) );
  5189. Doo::loadModel ( 'eMailTemplate' );
  5190. $eMailTemplate = new eMailTemplate ();
  5191. Doo::loadModel ( 'eMailJournal' );
  5192. $eMailJournal = new eMailJournal ();
  5193. if ($natureNULL != 'NULL') {
  5194. if (empty ( $tagId ) && ! empty ( $did ) && empty ( $nature ))
  5195. die ( '请选择性质' );
  5196. }
  5197. // annex
  5198. $annexPath = "";
  5199. $annexEXT = $this->_GetFileEXT ( $_FILES ["annex"] ["name"] );
  5200. $annexName = "";
  5201. if (isset ( $_FILES ['annex'] ['name'] )) {
  5202. 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)) {
  5203. $path = DOO::conf ()->SITE_PATH . "upload/emailAnnex/";
  5204. if (! file_exists ( $path . $_FILES ["annex"] ["name"] )) {
  5205. $fileName = time () . "." . $annexEXT;
  5206. $annexName = $_FILES ['annex'] ['name'];
  5207. $annexPath = $path . $fileName;
  5208. move_uploaded_file ( $_FILES ["annex"] ["tmp_name"], $annexPath );
  5209. $annexPath = $this->webPath . $fileName;
  5210. }
  5211. }
  5212. }
  5213. if (! empty ( $annexPath )) {
  5214. $annexHtml = '<table style="width:100%;margin:10px 0">
  5215. <thead>
  5216. <tr>
  5217. <th align="left" colspan="2" style="background-color:ff6501;color:#fff;font-size:16px;padding:5px">下载附件:</th>
  5218. </tr>
  5219. </thead>
  5220. <tbody>
  5221. <tr>
  5222. <td style="padding:5px"><a href="' . $annexPath . '" target="_blank" style="font-size:16px">' . $annexName . '</a></td>
  5223. <td>&nbsp;</td>
  5224. </tr>
  5225. </tbody>
  5226. </table>';
  5227. } elseif (! empty ( $etid ['annexName'] ) && empty ( $annexPath ))
  5228. $annexHtml = $etid ['annex'];
  5229. $smartcostMail = 'smartcost_mail_1';
  5230. $info = "";
  5231. // html template
  5232. if ($skin == 1) {
  5233. $html = '<div><table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0">
  5234. <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">
  5235. <tbody><tr>
  5236. <td style="background-color:#ff6501;padding:20px 0 25px;" align="center">
  5237. <span style="vertical-align:bottom;font-size:20px;color:#fff;">' . $title . '</span>
  5238. </td></tr><tr><td>
  5239. <table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;border-top:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  5240. <tbody><tr><td style="padding: 0 40px;" align="left">
  5241. <p style="margin-top:40px;margin-bottom:10px;color:#383838;font-size:16px;line-height:32px;"><b>CLIENTNAME</b>,您好</p>
  5242. </td></tr><tr><td style="padding: 0 40px;" align="left">
  5243. <p style="margin-top:0px;margin-bottom:10px;color:#383838;font-size:16px;line-height:32px;">我是纵横公路造价软件 <b>' . $this->staff [0] ['username'] . '</b>:</p>
  5244. <p style="margin-top:0px;margin-bottom:20px;color:#383838;font-size:16px;line-height:32px;">
  5245. ' . $content . '</p>
  5246. </td></tr>
  5247. <tr><td align="left" style="padding: 0 40px;background:#fff">
  5248. ' . $annexHtml . '
  5249. </td></tr>
  5250. <tr> <td style="padding: 20px 40px;border-top:1px dashed #ddd" align="left">
  5251. <p style="margin-bottom:10px;color:#383838;font-size:16px;line-height:22px;border-left:2px solid #FF6501;padding-left:5px">
  5252. 纵横公路造价软件' . $this->staff [0] ['category'] . '办事处</p>
  5253. <table>
  5254. <tr><th align="right">电话:</th><td>' . $this->staff [0] ['phone'] . '</td></tr>
  5255. <tr><th align="right">联系人:</th><td>' . $this->staff [0] ['username'] . '</td></tr>
  5256. <tr><th align="right">手机:</th><td>' . $this->staff [0] ['telephone'] . '</td></tr>
  5257. <tr><th align="right">QQ:</th><td>' . $this->staff [0] ['qq'] . '</td></tr>
  5258. <tr><th align="right">邮箱:</th><td>' . $this->staff [0] ['email'] . '</td></tr>
  5259. </table></td></tr></tbody></table></td></tr><tr>
  5260. <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>
  5261. </tr></tbody></table></td></tr></tbody></table></div>';
  5262. $info = '<table><tr><th align="right">电话:</th><td>' . $this->staff [0] ['phone'] . '</td></tr>
  5263. <tr><th align="right">联系人:</th><td>' . $this->staff [0] ['username'] . '</td></tr>
  5264. <tr><th align="right">手机:</th><td>' . $this->staff [0] ['telephone'] . '</td></tr>
  5265. <tr><th align="right">QQ:</th><td>' . $this->staff [0] ['qq'] . '</td></tr>
  5266. <tr><th align="right">邮箱:</th><td>' . $this->staff [0] ['email'] . '</td></tr></table>';
  5267. } elseif ($skin == 2) {
  5268. $smartcostMail = 'smartcost_mail_2';
  5269. $html = '<table cellspacing="0" cellpadding="0" style="background-color:#e4e4e4; width:100%;"><tbody><tr><td>
  5270. <table align="center" cellspacing="0" cellpadding="0" style="background-color:#f8f8f8; width:640px;margin-bottom:20px">
  5271. <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;">
  5272. <b><span name="titleHtml">' . $title . '</span></b></p></td>
  5273. </tr><tr><td><table align="center" cellspacing="0" cellpadding="0" style="border:1px solid #ddd;"><tbody><tr>
  5274. <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>
  5275. </tr><tr><td align="center" style="background-color:#fff;"><img width="640" height="191" src="http://zonghengvideo.qiniudn.com/hero.jpg"></td>
  5276. </tr><tr><td align="left" style="background-color:#fff;padding:40px;border-bottom:1px solid #ddd;">
  5277. <p style="margin-top:0px;margin-bottom:10px;color:#383838;font-size:16px;line-height:32px;"><b>CLIENTNAME</b>,您好</p>
  5278. <p style="margin-top:0px;margin-bottom:10px;color:#383838;font-size:16px;line-height:32px;">我是纵横公路造价软件 <b>' . $this->staff [0] ['username'] . '</b>:</p>
  5279. <p name="contentHtml" style="margin-top:0px;margin-bottom:15px;color:#383838;font-size:16px;line-height:32px;">' . $content . '</p></td>
  5280. </tr>
  5281. <tr><td align="left" style="padding: 0 40px;background:#fff">
  5282. ' . $annexHtml . '
  5283. </td></tr>
  5284. <tr><td style="padding: 10px 0;background:#EEF2F5"><table><tbody><tr>
  5285. <td style="font-size:14pxl;color:#333;padding:0 20px"><b>纵横公路造价软件' . $this->staff [0] ['category'] . '办事处</b><br>' . $this->staff [0] ['username'] . '</td>
  5286. <td><table><tbody><tr style="font-size:12px;color:#666">
  5287. <th align="right">电话:</th><td style="padding:0 20px 0 0">' . $this->staff [0] ['phone'] . '</td>
  5288. <th align="right">手机:</th><td>' . $this->staff [0] ['telephone'] . '</td></tr><tr style="font-size:12px;color:#666">
  5289. <th align="right">QQ:</th><td>' . $this->staff [0] ['qq'] . '</td>
  5290. <th align="right">邮箱: </th><td>' . $this->staff [0] ['email'] . '</td>
  5291. </tr></tbody></table></td></tr></tbody></table></td></tr></tbody></table></td></tr><tr>
  5292. <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>
  5293. </tr></tbody></table></td></tr></tbody> </table>';
  5294. $info = '<table><tbody><tr style="font-size:12px;color:#666">
  5295. <th align="right">电话:</th><td style="padding:0 20px 0 0">' . $this->staff [0] ['phone'] . '</td>
  5296. <th align="right">手机:</th><td>' . $this->staff [0] ['telephone'] . '</td></tr><tr style="font-size:12px;color:#666">
  5297. <th align="right">QQ:</th><td>' . $this->staff [0] ['qq'] . '</td>
  5298. <th align="right">邮箱: </th><td>' . $this->staff [0] ['email'] . '</td>
  5299. </tr></tbody></table>';
  5300. } else {
  5301. $smartcostMail = 'smartcost_mail_3';
  5302. $html = '<table cellspacing="0" cellpadding="0" style="background-color:#ECF0E1; width:100%">
  5303. <tbody>
  5304. <tr>
  5305. <td>
  5306. <table align="center" cellspacing="0" cellpadding="0" style="width:698px;margin-bottom:30px;margin-top:30px;">
  5307. <tbody>
  5308. <tr>
  5309. <td>
  5310. <table align="center" cellspacing="0" cellpadding="0" style="border:1px solid #ccc;width:100%;border-top:none">
  5311. <tbody>
  5312. <tr>
  5313. <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;">
  5314. <div style="position:relative;text-align:right">
  5315. <b style="font-size:24px;color:#8A9F98;z-index:999"><span name="titleHtml">' . $title . '</span></b>
  5316. <div style="width:80px;height:80px;position:absolute;top:0;left:0"><img src="http://zonghengvideo.qiniudn.com/zonghenglogo.png"></div>
  5317. </div>
  5318. </td>
  5319. </tr>
  5320. <tr>
  5321. <td align="left" style="background-color:#fff;padding:40px;border-bottom:1px solid #ddd;">
  5322. <p style="margin-top:0px;margin-bottom:10px;color:#666;font-size:16px;line-height:32px;"><b>CLIENTNAME</b>,您好</p>
  5323. <p style="margin-top:0px;margin-bottom:10px;color:#666;font-size:16px;line-height:32px;">我是纵横公路造价软件 <b>' . $this->staff [0] ['username'] . '</b>:</p>
  5324. <p name="contentHtml" style="margin-top:0px;margin-bottom:15px;color:#666;font-size:16px;line-height:32px;">' . $content . '</p></td>
  5325. </tr>
  5326. <tr><td align="left" style="padding: 0 40px;background:#fff">
  5327. ' . $annexHtml . '
  5328. </td></tr>
  5329. <tr>
  5330. <td style="padding: 10px 0 0;background:#F6F6F6;">
  5331. <table>
  5332. <tbody><tr>
  5333. <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>
  5334. <td>
  5335. <table style="width:100%">
  5336. <tbody><tr style="font-size:12px;color:#496781">
  5337. <th align="right">电话:</th><td>' . $this->staff [0] ['phone'] . '</td>
  5338. <th align="right">手机:</th><td>' . $this->staff [0] ['telephone'] . '</td>
  5339. </tr>
  5340. <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>
  5343. </tr>
  5344. </tbody></table>
  5345. </td>
  5346. </tr>
  5347. </tbody></table>
  5348. </td>
  5349. </tr>
  5350. <tr>
  5351. <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>
  5352. </tr>
  5353. </tbody>
  5354. </table></td>
  5355. </tr>
  5356. </tbody>
  5357. </table></td>
  5358. </tr>
  5359. </tbody>
  5360. </table>';
  5361. $info = '<table><tr style="font-size:12px;color:#496781"><th align="right">电话:</th><td>' . $this->staff [0] ['phone'] . '</td>
  5362. <th align="right">手机:</th><td>' . $this->staff [0] ['telephone'] . '</td></tr><tr style="font-size:12px;color:#496781">
  5363. <th align="right">QQ:</th><td>' . $this->staff [0] ['qq'] . '</td>
  5364. <th align="right">邮箱: </th><td>' . $this->staff [0] ['email'] . '</td></tr></table>
  5365. ';
  5366. }
  5367. Doo::loadModel ( 'tag_client' );
  5368. $tagClient = new tag_client ();
  5369. Doo::loadModel ( 'client' );
  5370. $client = new client ();
  5371. Doo::loadModel ( 'company' );
  5372. $company = new company ();
  5373. $eMailTemplate->title = $title;
  5374. $eMailTemplate->skin = $skin;
  5375. $eMailTemplate->content = $content;
  5376. if (! empty ( $tagId ))
  5377. $eMailTemplate->tag = implode ( ",", $tagId );
  5378. $eMailTemplate->staffId = $this->staff [0] ['sid'];
  5379. $eMailTemplate->staffName = $this->staff [0] ['username'];
  5380. $eMailTemplate->status = 0;
  5381. $eMailTemplate->html = $html;
  5382. if (! empty ( $annexPath )) {
  5383. $eMailTemplate->annex = $annexPath;
  5384. $eMailTemplate->annexName = $annexName;
  5385. }
  5386. $etid = $eMailTemplate->update ( array (
  5387. 'where' => 'etid=' . $etid ['etid']
  5388. ) );
  5389. // create email list
  5390. $tagCondition = "";
  5391. $tagArray = array ();
  5392. foreach ( $tagId as $value ) {
  5393. array_push ( $tagArray, " tag like '%" . $value . "%' " );
  5394. }
  5395. if (! empty ( $tagArray ))
  5396. $tagCondition = ' and (' . implode ( " or ", $tagArray ) . ')';
  5397. $clientList = $tagClient->find ( array (
  5398. 'select' => 'client',
  5399. 'where' => 'sid=' . $this->staff [0] ['sid'] . $tagCondition,
  5400. 'asArray' => true
  5401. ) );
  5402. $clientArray = array ();
  5403. foreach ( $clientList as $value ) {
  5404. array_push ( $clientArray, $value ['client'] );
  5405. }
  5406. $clientEmailList = array ();
  5407. if (! empty ( $clientArray ))
  5408. $clientEmailList = $client->find ( array (
  5409. 'select' => 'email,cid,nicename as clientname,companyname',
  5410. 'where' => 'cid in (' . implode ( ",", $clientArray ) . ')',
  5411. 'asArray' => true
  5412. ) );
  5413. //
  5414. if ($stype == 2) {
  5415. // 获取性质相关数据
  5416. $cidList = '';
  5417. if ($natureNULL == '') {
  5418. $nD = array ();
  5419. foreach ( $nature as $key => $value ) {
  5420. array_push ( $nD, ' nature like "' . $value . '"' );
  5421. // $nD=' nature like "'.$value.'"';
  5422. }
  5423. $nD = implode ( ' or ', $nD );
  5424. $companycid = $company->find ( array (
  5425. 'select' => 'cid',
  5426. 'where' => $nD,
  5427. 'asArray' => true
  5428. ) );
  5429. $cidList = array ();
  5430. foreach ( $companycid as $key => $value ) {
  5431. array_push ( $cidList, $value ['cid'] );
  5432. }
  5433. $cidList = implode ( ',', $cidList );
  5434. if (! empty ( $cidList ))
  5435. $cidList = ' and companyid in (' . $cidList . ')';
  5436. else
  5437. $cidList = '';
  5438. }
  5439. // 'select'=>'email,cid,nicename as clientname,companyname,district'
  5440. $clientEmailList = $client->find ( array (
  5441. 'select' => 'email,cid,nicename as clientname,companyname,district',
  5442. 'where' => 'district like "' . $did . ',%" ' . $cidList,
  5443. 'asArray' => true
  5444. ) );
  5445. }
  5446. // ;datediff(curdate(), 'date')>=10
  5447. $eMailJournal->delete ( array (
  5448. 'where' => "datediff(curdate(), date)>=7"
  5449. ) );
  5450. $eMailJournal->delete ( array (
  5451. 'where' => 'DATE_SUB(CURDATE(), INTERVAL 7 DAY) <= date(date)'
  5452. ) );
  5453. $checkMail = $eMailJournal->find ( array (
  5454. 'where' => 'DATE_SUB(CURDATE(), INTERVAL 7 DAY) <= date(date)',
  5455. ' groupby' => 'email',
  5456. 'asArray' => true
  5457. ) );
  5458. $emailNameList = $emailArray = $illegalEmail = $sendEmail = array ();
  5459. Doo::db ()->beginTransaction ();
  5460. foreach ( $clientEmailList as $value ) {
  5461. if (filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) {
  5462. if (! empty ( $checkMail )) {
  5463. $falg = true;
  5464. foreach ( $checkMail as $v ) {
  5465. if ($v ['email'] == $value ['email']) {
  5466. $Bdate = strtotime ( $v ['date'] ) + 7 * 24 * 3600;
  5467. if ($Bdate <= time ()) {
  5468. array_push ( $emailArray, $value ['email'] );
  5469. array_push ( $emailNameList, $value );
  5470. $eMailJournal->date = date ( "Y-m-d" );
  5471. $eMailJournal->update ( array (
  5472. 'where' => 'ejid=' . $v ['ejid']
  5473. ) );
  5474. } else {
  5475. array_push ( $sendEmail, $value );
  5476. }
  5477. $falg = false;
  5478. break;
  5479. }
  5480. }
  5481. if ($falg) {
  5482. array_push ( $emailArray, $value ['email'] );
  5483. array_push ( $emailNameList, $value );
  5484. $eMailJournal->clientId = $value ['cid'];
  5485. $eMailJournal->status = 1;
  5486. $eMailJournal->email = $value ['email'];
  5487. $eMailJournal->date = date ( "Y-m-d" );
  5488. $eMailJournal->insert ();
  5489. }
  5490. } else {
  5491. array_push ( $emailArray, $value ['email'] );
  5492. array_push ( $emailNameList, $value );
  5493. $eMailJournal->clientId = $value ['cid'];
  5494. $eMailJournal->status = 1;
  5495. $eMailJournal->email = $value ['email'];
  5496. $eMailJournal->date = date ( "Y-m-d" );
  5497. $eMailJournal->insert ();
  5498. }
  5499. } else {
  5500. array_push ( $illegalEmail, $value );
  5501. }
  5502. }
  5503. Doo::db ()->commit ();
  5504. // echo json_encode($illegalEmail);
  5505. // json_encode(array_slice($illegalEmail,0,100))
  5506. // $kk=gzcompress();
  5507. // $ll=gzuncompress($kk);
  5508. // ."</br>".strlen($kk)."</br>".strlen($ll);die;
  5509. $size = floor ( count ( $emailArray ) / 3 );
  5510. if (! empty ( $emailArray )) {
  5511. if (count ( $emailArray ) < 3) {
  5512. $list = array (
  5513. 0 => $emailArray,
  5514. 1 => array (),
  5515. 2 => array ()
  5516. );
  5517. } else
  5518. $list = array_chunk ( $emailArray, $size );
  5519. } else
  5520. $list = array (
  5521. 0 => array (),
  5522. 1 => array (),
  5523. 2 => array ()
  5524. );
  5525. $emailJson = array ();
  5526. foreach ( $list as $value ) {
  5527. $em = array ();
  5528. foreach ( $value as $v ) {
  5529. array_push ( $em, $v );
  5530. }
  5531. array_push ( $emailJson, $em );
  5532. }
  5533. $size = floor ( count ( $emailNameList ) / 3 );
  5534. if (! empty ( $emailNameList )) {
  5535. if (count ( $emailNameList ) < 3) {
  5536. $list = array (
  5537. 0 => $emailNameList,
  5538. 1 => array (),
  5539. 2 => array ()
  5540. );
  5541. } else
  5542. $list = array_chunk ( $emailNameList, $size );
  5543. } else
  5544. $list = array (
  5545. 0 => array (),
  5546. 1 => array (),
  5547. 2 => array ()
  5548. );
  5549. $emailNameJson = array ();
  5550. foreach ( $list as $value ) {
  5551. $em = array ();
  5552. foreach ( $value as $v ) {
  5553. array_push ( $em, $v );
  5554. }
  5555. array_push ( $emailNameJson, $em );
  5556. }
  5557. //
  5558. $eMailList->date = date ( "Y-m-d" );
  5559. $eMailList->clientEmail = base64_encode ( gzcompress ( json_encode ( $emailJson [0] ) ) );
  5560. $eMailList->clientEmail2 = base64_encode ( gzcompress ( json_encode ( $emailJson [1] ) ) );
  5561. $eMailList->clientEmail3 = base64_encode ( gzcompress ( json_encode ( $emailJson [2] ) ) );
  5562. $eMailList->clientName = base64_encode ( gzcompress ( json_encode ( $emailNameJson [0] ) ) );
  5563. $eMailList->clientName2 = base64_encode ( gzcompress ( json_encode ( $emailNameJson [1] ) ) );
  5564. $eMailList->clientName3 = base64_encode ( gzcompress ( json_encode ( $emailNameJson [2] ) ) );
  5565. $eMailList->illegalEmail = json_encode ( array_slice ( $illegalEmail, 0, 100 ) ); // json_encode($illegalEmail);
  5566. $eMailList->sendEmail = json_encode ( $sendEmail );
  5567. $eMailList->templateName = $smartcostMail;
  5568. $eMailList->eTitle = $title;
  5569. $eMailList->html = $html;
  5570. $eMailList->content = $content;
  5571. $eMailList->info = $info;
  5572. if (! empty ( $annexName )) {
  5573. $eMailList->annex = $annexHtml;
  5574. $eMailList->annexName = $annexName;
  5575. }
  5576. if ($stype == 1) {
  5577. $eMailList->tag = implode ( ",", $tagId );
  5578. $eMailList->districtId = "";
  5579. $eMailList->nature = "";
  5580. }
  5581. if ($stype == 2) {
  5582. $eMailList->districtId = $did;
  5583. $eMailList->nature = implode ( ",", $nature );
  5584. $eMailList->tag = "";
  5585. }
  5586. $eMailList->update ( array (
  5587. 'where' => 'elid=' . $elid
  5588. ) );
  5589. return "/eMailList";
  5590. }
  5591. return "/eMailTask";
  5592. }
  5593. function createEmail() {
  5594. // include Doo::conf()->BASE_PATH.'diagnostic/debug.php';
  5595. $title = $this->get_args ( 'title' ) ? $this->get_args ( 'title' ) : "";
  5596. $skin = $this->get_args ( 'skin' ) ? $this->get_args ( 'skin' ) : "";
  5597. $content = isset ( $_POST ['content'] ) ? $_POST ['content'] : "";
  5598. $tagId = $this->get_args ( 'tagId' ) ? $this->get_args ( 'tagId' ) : array ();
  5599. $nature = $this->get_args ( 'nature' ) ? $this->get_args ( 'nature' ) : array ();
  5600. $natureNULL = $this->get_args ( 'natureNULL' ) ? $this->get_args ( 'natureNULL' ) : "";
  5601. $did = $this->get_args ( 'did' ) ? $this->get_args ( 'did' ) : "";
  5602. $stype = $this->get_args ( 'stype' ) ? $this->get_args ( 'stype' ) : "";
  5603. if (! empty ( $title ) && (! empty ( $tagId ) || ! empty ( $did ))) {
  5604. Doo::loadModel ( 'eMailTemplate' );
  5605. $eMailTemplate = new eMailTemplate ();
  5606. Doo::loadModel ( 'eMailJournal' );
  5607. $eMailJournal = new eMailJournal ();
  5608. if ($natureNULL != 'NULL') {
  5609. if (empty ( $tagId ) && ! empty ( $did ) && empty ( $nature )) {
  5610. header ( 'Content-Type:text/html;charset=utf-8' );
  5611. die ( '请选择性质' );
  5612. }
  5613. }
  5614. // annex
  5615. $annexPath = "";
  5616. $annexEXT = $this->_GetFileEXT ( $_FILES ["annex"] ["name"] );
  5617. $annexName = "";
  5618. if (isset ( $_FILES ['annex'] ['name'] )) {
  5619. 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)) {
  5620. $path = DOO::conf ()->SITE_PATH . "upload/emailAnnex/";
  5621. if (! file_exists ( $path . $_FILES ["annex"] ["name"] )) {
  5622. $fileName = time () . "." . $annexEXT;
  5623. $annexName = $_FILES ['annex'] ['name'];
  5624. $annexPath = $path . $fileName;
  5625. move_uploaded_file ( $_FILES ["annex"] ["tmp_name"], $annexPath );
  5626. $annexPath = $this->webPath . $fileName;
  5627. }
  5628. }
  5629. }
  5630. $annexHtml = '<table style="width:100%;margin:10px 0">
  5631. <thead>
  5632. <tr>
  5633. <th align="left" colspan="2">下载附件:</th>
  5634. </tr>
  5635. </thead>
  5636. <tbody>
  5637. <tr>
  5638. <td><a href="' . $annexPath . '" target="_blank">' . $annexName . '</a></td>
  5639. <td>&nbsp;</td>
  5640. </tr>
  5641. </tbody>
  5642. </table>';
  5643. $smartcostMail = 'smartcost_mail_1';
  5644. $info = "";
  5645. // html template
  5646. if ($skin == 1) {
  5647. $html = '<div><table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0">
  5648. <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">
  5649. <tbody><tr>
  5650. <td style="background-color:#ff6501;padding:20px 0 25px;" align="center">
  5651. <span style="vertical-align:bottom;font-size:20px;color:#fff;">' . $title . '</span>
  5652. </td></tr><tr><td>
  5653. <table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;border-top:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  5654. <tbody><tr><td style="padding: 0 40px;" align="left">
  5655. <p style="margin-top:40px;margin-bottom:10px;color:#383838;font-size:16px;line-height:32px;"><b>CLIENTNAME</b></p>
  5656. </td></tr><tr><td style="padding: 0 40px;" align="left">
  5657. <p style="margin-top:0px;margin-bottom:10px;color:#383838;font-size:16px;line-height:32px;">您好,我是纵横公路造价软件 <b>' . $this->staff [0] ['username'] . '</b>:</p>
  5658. <p style="margin-top:0px;margin-bottom:20px;color:#383838;font-size:16px;line-height:32px;">
  5659. ' . $content . '</p>
  5660. </td></tr>
  5661. <tr><td align="left" style="padding: 0 40px;background:#fff">
  5662. ' . $annexHtml . '
  5663. </td></tr>
  5664. <tr>
  5665. <td style="padding: 10px 0 0;background:#F6F6F6;">
  5666. <table>
  5667. <tr>
  5668. <td style="font-size:14pxl;color:#666;padding:0 20px"><b>纵横软件公司' . $this->staff [0] ['category'] . '服务中心</b><br>' . $this->staff [0] ['username'] . '<br>
  5669. <a href="[图片]http://www.smartcost.com.cn" style="color:#666;font-size:12px;text-decoration:underline;">[图片]smartcost.com.cn</a></td>
  5670. <td>
  5671. <table>
  5672. <tr style="font-size:12px;color:#666">
  5673. <th align="right">电话:</th><td style="padding:0 20px 0 0">' . $this->staff [0] ['phone'] . '</td>
  5674. <th align="right">手机:</th><td>' . $this->staff [0] ['telephone'] . '</td>
  5675. </tr>
  5676. <tr style="font-size:12px;color:#666">
  5677. <th align="right">Q Q:</th><td>' . $this->staff [0] ['qq'] . '</td>
  5678. <th align="right">邮箱: </th><td>' . $this->staff [0] ['email'] . '</td>
  5679. </tr>
  5680. </table>
  5681. </td>
  5682. </tr>
  5683. </table>
  5684. </td></tr></tbody></table></td></tr><tr>
  5685. <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>
  5686. </tr></tbody></table></td></tr></tbody></table></div>';
  5687. $info = '<table><tr><th align="right">电话:</th><td>' . $this->staff [0] ['phone'] . '</td></tr>
  5688. <tr><th align="right">联系人:</th><td>' . $this->staff [0] ['username'] . '</td></tr>
  5689. <tr><th align="right">手机:</th><td>' . $this->staff [0] ['telephone'] . '</td></tr>
  5690. <tr><th align="right">QQ:</th><td>' . $this->staff [0] ['qq'] . '</td></tr>
  5691. <tr><th align="right">邮箱:</th><td>' . $this->staff [0] ['email'] . '</td></tr></table>';
  5692. } elseif ($skin == 2) {
  5693. $smartcostMail = 'smartcost_mail_2';
  5694. $html = '<table cellspacing="0" cellpadding="0" style="background-color:#e4e4e4; width:100%;"><tbody><tr><td>
  5695. <table align="center" cellspacing="0" cellpadding="0" style="background-color:#f8f8f8; width:640px;margin-bottom:20px">
  5696. <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;">
  5697. <b><span name="titleHtml">' . $title . '</span></b></p></td>
  5698. </tr><tr><td><table align="center" cellspacing="0" cellpadding="0" style="border:1px solid #ddd;"><tbody><tr>
  5699. <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>
  5700. </tr><tr><td align="center" style="background-color:#fff;"><img width="640" height="191" src="http://zonghengvideo.qiniudn.com/hero.jpg"></td>
  5701. </tr><tr><td align="left" style="background-color:#fff;padding:40px;border-bottom:1px solid #ddd;">
  5702. <p style="margin-top:0px;margin-bottom:10px;color:#383838;font-size:16px;line-height:32px;"><b>CLIENTNAME</b></p>
  5703. <p style="margin-top:0px;margin-bottom:10px;color:#383838;font-size:16px;line-height:32px;">您好,我是纵横公路造价软件 <b>' . $this->staff [0] ['username'] . '</b>:</p>
  5704. <p name="contentHtml" style="margin-top:0px;margin-bottom:15px;color:#383838;font-size:16px;line-height:32px;">' . $content . '</p></td>
  5705. </tr>
  5706. <tr><td align="left" style="padding: 0 40px;background:#fff">
  5707. ' . $annexHtml . '
  5708. </td></tr>
  5709. <tr>
  5710. <td style="padding: 10px 0;background:#F6F6F6">
  5711. <table>
  5712. <tbody>
  5713. <tr>
  5714. <td style="font-size:14pxl;color:#333;padding:0 20px">
  5715. <b>纵横公路造价软件' . $this->staff [0] ['category'] . '服务中心</b><br>' . $this->staff [0] ['username'] . '</td>
  5716. <td>
  5717. <table>
  5718. <tbody>
  5719. <tr style="font-size:12px;color:#666">
  5720. <th align="right">电话:</th><td style="padding:0 20px 0 0">' . $this->staff [0] ['phone'] . '</td>
  5721. <th align="right">手机:</th><td>' . $this->staff [0] ['telephone'] . '</td></tr><tr style="font-size:12px;color:#666">
  5722. <th align="right">Q Q:</th><td>' . $this->staff [0] ['qq'] . '</td>
  5723. <th align="right">邮箱: </th><td>' . $this->staff [0] ['email'] . '</td>
  5724. </tr></tbody></table></td></tr></tbody></table></td></tr></tbody></table></td></tr><tr>
  5725. <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>
  5726. </tr></tbody></table></td></tr></tbody> </table>';
  5727. $info = '<table><tbody><tr style="font-size:12px;color:#666">
  5728. <th align="right">电话:</th><td style="padding:0 20px 0 0">' . $this->staff [0] ['phone'] . '</td>
  5729. <th align="right">手机:</th><td>' . $this->staff [0] ['telephone'] . '</td></tr><tr style="font-size:12px;color:#666">
  5730. <th align="right">QQ:</th><td>' . $this->staff [0] ['qq'] . '</td>
  5731. <th align="right">邮箱: </th><td>' . $this->staff [0] ['email'] . '</td>
  5732. </tr></tbody></table>';
  5733. } else {
  5734. $smartcostMail = 'smartcost_mail_3';
  5735. $html = '<table cellspacing="0" cellpadding="0" style="background-color:#ECF0E1; width:100%">
  5736. <tbody>
  5737. <tr>
  5738. <td>
  5739. <table align="center" cellspacing="0" cellpadding="0" style="width:698px;margin-bottom:30px;margin-top:30px;">
  5740. <tbody>
  5741. <tr>
  5742. <td>
  5743. <table align="center" cellspacing="0" cellpadding="0" style="border:1px solid #ccc;width:100%;border-top:none">
  5744. <tbody>
  5745. <tr>
  5746. <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;">
  5747. <div style="position:relative;text-align:right">
  5748. <b style="font-size:24px;color:#8A9F98;z-index:999"><span name="titleHtml">' . $title . '</span></b>
  5749. <div style="width:80px;height:80px;position:absolute;top:0;left:0"><img src="http://zonghengvideo.qiniudn.com/zonghenglogo.png"></div>
  5750. </div>
  5751. </td>
  5752. </tr>
  5753. <tr>
  5754. <td align="left" style="background-color:#fff;padding:40px;border-bottom:1px solid #ddd;">
  5755. <p style="margin-top:0px;margin-bottom:10px;color:#666;font-size:16px;line-height:32px;"><b>CLIENTNAME</b></p>
  5756. <p style="margin-top:0px;margin-bottom:10px;color:#666;font-size:16px;line-height:32px;">您好,我是纵横公路造价软件 <b>' . $this->staff [0] ['username'] . '</b>:</p>
  5757. <p name="contentHtml" style="margin-top:0px;margin-bottom:15px;color:#666;font-size:16px;line-height:32px;">' . $content . '</p></td>
  5758. </tr>
  5759. <tr><td align="left" style="padding: 0 40px;background:#fff">
  5760. ' . $annexHtml . '
  5761. </td></tr>
  5762. <tr>
  5763. <td style="padding: 10px 0 0;background:#F6F6F6;">
  5764. <table>
  5765. <tbody><tr>
  5766. <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>
  5767. <td>
  5768. <table style="width:100%">
  5769. <tbody><tr style="font-size:12px;color:#496781">
  5770. <th align="right">电话:</th><td>' . $this->staff [0] ['phone'] . '</td>
  5771. <th align="right">手机:</th><td>' . $this->staff [0] ['telephone'] . '</td>
  5772. </tr>
  5773. <tr style="font-size:12px;color:#496781">
  5774. <th align="right">Q Q:</th><td>' . $this->staff [0] ['qq'] . '</td>
  5775. <th align="right">邮箱: </th><td>' . $this->staff [0] ['email'] . '</td>
  5776. </tr>
  5777. </tbody></table>
  5778. </td>
  5779. </tr>
  5780. </tbody></table>
  5781. </td>
  5782. </tr>
  5783. <tr>
  5784. <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>
  5785. </tr>
  5786. </tbody>
  5787. </table></td>
  5788. </tr>
  5789. </tbody>
  5790. </table></td>
  5791. </tr>
  5792. </tbody>
  5793. </table>';
  5794. $info = '<table><tr style="font-size:12px;color:#496781"><th align="right">电话:</th><td>' . $this->staff [0] ['phone'] . '</td>
  5795. <th align="right">手机:</th><td>' . $this->staff [0] ['telephone'] . '</td></tr><tr style="font-size:12px;color:#496781">
  5796. <th align="right">QQ:</th><td>' . $this->staff [0] ['qq'] . '</td>
  5797. <th align="right">邮箱: </th><td>' . $this->staff [0] ['email'] . '</td></tr></table>
  5798. ';
  5799. }
  5800. $eMailTemplate->title = $title;
  5801. $eMailTemplate->skin = $skin;
  5802. $eMailTemplate->content = $content;
  5803. if (! empty ( $tagId ))
  5804. $eMailTemplate->tag = implode ( ",", $tagId );
  5805. $eMailTemplate->staffId = $this->staff [0] ['sid'];
  5806. $eMailTemplate->staffName = $this->staff [0] ['username'];
  5807. $eMailTemplate->status = 0;
  5808. $eMailTemplate->html = $html;
  5809. $eMailTemplate->annex = $annexPath;
  5810. $eMailTemplate->annexName = $annexName;
  5811. $etid = $eMailTemplate->insert ();
  5812. // create email list
  5813. Doo::loadModel ( 'tag_client' );
  5814. $tagClient = new tag_client ();
  5815. Doo::loadModel ( 'client' );
  5816. $client = new client ();
  5817. Doo::loadModel ( 'eMailList' );
  5818. $eMailList = new eMailList ();
  5819. Doo::loadModel ( 'company' );
  5820. $company = new company ();
  5821. $tagCondition = "";
  5822. $tagArray = array ();
  5823. foreach ( $tagId as $value ) {
  5824. array_push ( $tagArray, " tag like '%" . $value . "%' " );
  5825. }
  5826. if (! empty ( $tagArray ))
  5827. $tagCondition = ' and (' . implode ( " or ", $tagArray ) . ')';
  5828. $clientList = $tagClient->find ( array (
  5829. 'select' => 'client',
  5830. 'where' => 'sid=' . $this->staff [0] ['sid'] . $tagCondition,
  5831. 'asArray' => true
  5832. ) );
  5833. $clientArray = array ();
  5834. foreach ( $clientList as $value ) {
  5835. array_push ( $clientArray, $value ['client'] );
  5836. }
  5837. $clientEmailList = array ();
  5838. if (! empty ( $clientArray ))
  5839. $clientEmailList = $client->find ( array (
  5840. 'select' => 'email,cid,nicename as clientname,companyname',
  5841. 'where' => 'cid in (' . implode ( ",", $clientArray ) . ')',
  5842. 'asArray' => true
  5843. ) );
  5844. //
  5845. if ($stype == 2) {
  5846. // 获取性质相关数据
  5847. $cidList = '';
  5848. if ($natureNULL == '') {
  5849. $nD = array ();
  5850. foreach ( $nature as $key => $value ) {
  5851. array_push ( $nD, ' nature like "' . $value . '"' );
  5852. // $nD=' nature like "'.$value.'"';
  5853. }
  5854. $nD = implode ( ' or ', $nD );
  5855. $companycid = $company->find ( array (
  5856. 'select' => 'cid',
  5857. 'where' => $nD,
  5858. 'asArray' => true
  5859. ) );
  5860. $cidList = array ();
  5861. foreach ( $companycid as $key => $value ) {
  5862. array_push ( $cidList, $value ['cid'] );
  5863. }
  5864. $cidList = implode ( ',', $cidList );
  5865. if (! empty ( $cidList ))
  5866. $cidList = ' and companyid in (' . $cidList . ')';
  5867. else
  5868. $cidList = '';
  5869. }
  5870. // 'select'=>'email,cid,nicename as clientname,companyname,district'
  5871. $clientEmailList = $client->find ( array (
  5872. 'select' => 'email,cid,nicename as clientname,companyname,district',
  5873. 'where' => 'district like "' . $did . ',%" ' . $cidList,
  5874. 'asArray' => true
  5875. ) );
  5876. }
  5877. // ;datediff(curdate(), 'date')>=10
  5878. $eMailJournal->delete ( array (
  5879. 'where' => "datediff(curdate(), date)>=7"
  5880. ) );
  5881. $checkMail = $eMailJournal->find ( array (
  5882. 'where' => 'DATE_SUB(CURDATE(), INTERVAL 7 DAY) <= date(date)',
  5883. ' groupby' => 'email',
  5884. 'asArray' => true
  5885. ) );
  5886. $emailNameList = $emailArray = $illegalEmail = $sendEmail = array ();
  5887. Doo::db ()->beginTransaction ();
  5888. foreach ( $clientEmailList as $value ) {
  5889. if (filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) {
  5890. if (! empty ( $checkMail )) {
  5891. $falg = true;
  5892. foreach ( $checkMail as $v ) {
  5893. if ($v ['email'] == $value ['email']) {
  5894. $Bdate = strtotime ( $v ['date'] ) + 7 * 24 * 3600;
  5895. if ($Bdate <= time ()) {
  5896. array_push ( $emailArray, $value ['email'] );
  5897. array_push ( $emailNameList, $value );
  5898. $eMailJournal->date = date ( "Y-m-d" );
  5899. $eMailJournal->update ( array (
  5900. 'where' => 'ejid=' . $v ['ejid']
  5901. ) );
  5902. } else {
  5903. array_push ( $sendEmail, $value );
  5904. }
  5905. $falg = false;
  5906. break;
  5907. }
  5908. }
  5909. if ($falg) {
  5910. array_push ( $emailArray, $value ['email'] );
  5911. array_push ( $emailNameList, $value );
  5912. $eMailJournal->clientId = $value ['cid'];
  5913. $eMailJournal->status = 1;
  5914. $eMailJournal->email = $value ['email'];
  5915. $eMailJournal->date = date ( "Y-m-d" );
  5916. // $eMailJournal->insert();
  5917. }
  5918. } else {
  5919. array_push ( $emailArray, $value ['email'] );
  5920. array_push ( $emailNameList, $value );
  5921. $eMailJournal->clientId = $value ['cid'];
  5922. $eMailJournal->status = 1;
  5923. $eMailJournal->email = $value ['email'];
  5924. $eMailJournal->date = date ( "Y-m-d" );
  5925. // $eMailJournal->insert();
  5926. }
  5927. } else {
  5928. array_push ( $illegalEmail, $value );
  5929. }
  5930. }
  5931. Doo::db ()->commit ();
  5932. // echo json_encode($illegalEmail);
  5933. // json_encode(array_slice($illegalEmail,0,100))
  5934. // $kk=gzcompress();
  5935. // $ll=gzuncompress($kk);
  5936. // ."</br>".strlen($kk)."</br>".strlen($ll);die;
  5937. $size = floor ( count ( $emailArray ) / 3 );
  5938. if (! empty ( $emailArray )) {
  5939. if (count ( $emailArray ) < 3) {
  5940. $list = array (
  5941. 0 => $emailArray,
  5942. 1 => array (),
  5943. 2 => array ()
  5944. );
  5945. } else
  5946. $list = array_chunk ( $emailArray, $size );
  5947. } else
  5948. $list = array (
  5949. 0 => array (),
  5950. 1 => array (),
  5951. 2 => array ()
  5952. );
  5953. $emailJson = array ();
  5954. foreach ( $list as $value ) {
  5955. $em = array ();
  5956. foreach ( $value as $v ) {
  5957. array_push ( $em, $v );
  5958. }
  5959. array_push ( $emailJson, $em );
  5960. }
  5961. $size = floor ( count ( $emailNameList ) / 3 );
  5962. if (! empty ( $emailNameList )) {
  5963. if (count ( $emailNameList ) < 3) {
  5964. $list = array (
  5965. 0 => $emailNameList,
  5966. 1 => array (),
  5967. 2 => array ()
  5968. );
  5969. } else
  5970. $list = array_chunk ( $emailNameList, $size );
  5971. } else
  5972. $list = array (
  5973. 0 => array (),
  5974. 1 => array (),
  5975. 2 => array ()
  5976. );
  5977. $emailNameJson = array ();
  5978. foreach ( $list as $value ) {
  5979. $em = array ();
  5980. foreach ( $value as $v ) {
  5981. array_push ( $em, $v );
  5982. }
  5983. array_push ( $emailNameJson, $em );
  5984. }
  5985. //
  5986. $eMailList->date = date ( "Y-m-d" );
  5987. $eMailList->clientEmail = base64_encode ( gzcompress ( json_encode ( $emailJson [0] ) ) );
  5988. $eMailList->clientEmail2 = base64_encode ( gzcompress ( json_encode ( $emailJson [1] ) ) );
  5989. $eMailList->clientEmail3 = base64_encode ( gzcompress ( json_encode ( $emailJson [2] ) ) );
  5990. $eMailList->clientName = base64_encode ( gzcompress ( json_encode ( $emailNameJson [0] ) ) );
  5991. $eMailList->clientName2 = base64_encode ( gzcompress ( json_encode ( $emailNameJson [1] ) ) );
  5992. $eMailList->clientName3 = base64_encode ( gzcompress ( json_encode ( $emailNameJson [2] ) ) );
  5993. $eMailList->illegalEmail = json_encode ( array_slice ( $illegalEmail, 0, 100 ) ); // json_encode($illegalEmail);
  5994. $eMailList->sendEmail = json_encode ( $sendEmail );
  5995. $eMailList->etid = $etid;
  5996. $eMailList->templateName = $smartcostMail;
  5997. $eMailList->eTitle = $title;
  5998. $eMailList->html = $html;
  5999. $eMailList->content = $content;
  6000. $eMailList->info = $info;
  6001. if (! empty ( $annexName ))
  6002. $eMailList->annex = $annexHtml;
  6003. $eMailList->annexName = $annexName;
  6004. $eMailList->staffId = $this->staff [0] ['sid'];
  6005. $eMailList->staffName = $this->staff [0] ['username'];
  6006. if ($stype == 1)
  6007. $eMailList->tag = implode ( ",", $tagId );
  6008. if ($stype == 2) {
  6009. $eMailList->districtId = $did;
  6010. $eMailList->nature = implode ( ",", $nature );
  6011. }
  6012. $eMailList->insert ();
  6013. // 创建邮件地址
  6014. // 'http://sendcloud.sohu.com/webapi/list_member.add.json';
  6015. // print_r($emailJson);
  6016. // die;
  6017. return "/eMailList";
  6018. }
  6019. return "/eMailTask";
  6020. }
  6021. function eMailList() {
  6022. Doo::loadModel ( 'eMailList' );
  6023. $eMailList = new eMailList ();
  6024. Doo::loadModel ( 'tag' );
  6025. $tag = new tag ();
  6026. $mailList = $eMailList->find ( array (
  6027. 'where' => 'staffId=' . $this->staff [0] ['sid'],
  6028. 'desc' => 'elid',
  6029. 'asArray' => true
  6030. ) );
  6031. foreach ( $mailList as $key => $value ) {
  6032. $mailList [$key] ['clientName2'] = $mailList [$key] ['clientName3'] = array ();
  6033. $mailList [$key] ['clientName'] = json_decode ( gzuncompress ( base64_decode ( $value ['clientName'] ) ), true );
  6034. if (! empty ( $value ['clientName2'] ))
  6035. $mailList [$key] ['clientName2'] = json_decode ( gzuncompress ( base64_decode ( $value ['clientName2'] ) ), true );
  6036. if (! empty ( $value ['clientName3'] ))
  6037. $mailList [$key] ['clientName3'] = json_decode ( gzuncompress ( base64_decode ( $value ['clientName3'] ) ), true );
  6038. $mailList [$key] ['illegalEmail'] = json_decode ( $value ['illegalEmail'], true );
  6039. $mailList [$key] ['sendEmail'] = json_decode ( $value ['sendEmail'], true );
  6040. $mailList [$key] ['clientCount'] = count ( $mailList [$key] ['clientName'] ) + count ( $mailList [$key] ['clientName2'] ) + count ( $mailList [$key] ['clientName3'] );
  6041. $mailList [$key] ['tag'] = array ();
  6042. if (! empty ( $value ['tag'] ))
  6043. $mailList [$key] ['tag'] = $tag->find ( array (
  6044. 'where' => 'tid in ( ' . $value ['tag'] . ') ',
  6045. 'asArray' => true
  6046. ) );
  6047. }
  6048. $data ['mailList'] = $mailList;
  6049. $data ['memu'] = "eMailTask";
  6050. $data ['staff'] = $this->staff;
  6051. $data ['mailMemu'] = 'eMailList';
  6052. $this->render ( "/mail_list", $data );
  6053. }
  6054. function showEmailContent() {
  6055. $elid = isset ( $this->params ['elid'] ) ? $this->params ['elid'] : 0;
  6056. Doo::loadModel ( 'eMailList' );
  6057. $eMList = new eMailList ();
  6058. $isSend = $eMList->getOne ( array (
  6059. 'where' => 'elid =' . $elid . '',
  6060. 'asArray' => true
  6061. ) );
  6062. echo htmlspecialchars ( $isSend ['content'] );
  6063. }
  6064. function postEmail() {
  6065. // include Doo::conf()->BASE_PATH.'diagnostic/debug.php';
  6066. $elid = isset ( $this->params ['elid'] ) ? $this->params ['elid'] : 0;
  6067. $send = isset ( $this->params ['send'] ) ? $this->params ['send'] : 0;
  6068. Doo::loadModel ( 'eMailList' );
  6069. $eMList = new eMailList ();
  6070. if (! empty ( $elid )) {
  6071. $isSend = $eMList->getOne ( array (
  6072. 'select' => 'send' . $send,
  6073. 'where' => 'elid =' . $elid . ' and status=0 and send' . $send . '=1',
  6074. 'asArray' => true
  6075. ) );
  6076. if (! empty ( $isSend ))
  6077. die ( '这批邮件已经发送' );
  6078. if ($send == 1)
  6079. $send = '';
  6080. $eMailList = $eMList->getOne ( array (
  6081. 'select' => 'eTitle,staffName,clientName' . $send . ' as clientName,clientEmail' . $send . ' as clientEmail,annex,info,content,templateName',
  6082. 'where' => 'elid =' . $elid . ' and status=0',
  6083. 'asArray' => true
  6084. ) );
  6085. if ($send == "")
  6086. $send = 1;
  6087. $sql = "update `CLD_eMailList` set send" . $send . "='1' where elid = '" . $elid . "'";
  6088. Doo::db ()->query ( $sql );
  6089. $isSend = $eMList->getOne ( array (
  6090. 'where' => 'elid =' . $elid . ' and status=0 and send1=1 and send2=1 and send3=1',
  6091. 'asArray' => true
  6092. ) );
  6093. if (! empty ( $isSend )) {
  6094. $sql = "update `CLD_eMailList` set status='2' where elid = '" . $elid . "'";
  6095. Doo::db ()->query ( $sql );
  6096. }
  6097. $toFormatMail = array ();
  6098. $sub = array ();
  6099. // file_put_contents("test.txt", "This is another something.<br/>", FILE_APPEND);
  6100. // sleep(4);
  6101. // die;
  6102. $toMail = json_decode ( gzuncompress ( base64_decode ( $eMailList ['clientEmail'] ) ), true );
  6103. // $toMailCount=count($toMail);
  6104. $subMail = json_decode ( gzuncompress ( base64_decode ( $eMailList ['clientName'] ) ), true );
  6105. $chunkMail = array_chunk ( $toMail, 80 );
  6106. $chunkSubMail = array_chunk ( $subMail, 80 );
  6107. $vii = 0;
  6108. foreach ( $chunkMail as $key => $value ) {
  6109. $l = $s = $c = $i = $cate = $con = $annex = array ();
  6110. $toFormatMail ['to'] = $value;
  6111. $cn = $chunkSubMail [$key];
  6112. foreach ( $cn as $v ) {
  6113. array_push ( $l, $eMailList ['eTitle'] );
  6114. array_push ( $s, $eMailList ['staffName'] );
  6115. array_push ( $c, $v ['clientname'] );
  6116. array_push ( $annex, $eMailList ['annex'] );
  6117. array_push ( $i, $eMailList ['info'] );
  6118. // array_push($con, $eMailList['content']);
  6119. array_push ( $cate, $this->staff [0] ['category'] );
  6120. }
  6121. $sub ['%eTitle%'] = $l;
  6122. $sub ['%staffName%'] = $s;
  6123. $sub ['%clientName%'] = $c;
  6124. $sub ['%category%'] = $cate;
  6125. $sub ['%info%'] = $i;
  6126. // $sub['%content%']=$con;
  6127. $sub ['%annex%'] = $annex;
  6128. $toFormatMail ['sub'] = $sub;
  6129. $url = 'http://sendcloud.sohu.com/webapi/mail.send_template.xml';
  6130. $param = array (
  6131. 'api_user' => 'cldmail',
  6132. 'api_key' => 'cDO1GjtY1seH',
  6133. 'template_invoke_name' => $eMailList ['templateName'],
  6134. 'from' => $this->staff [0] ['email'],
  6135. 'fromname' => '纵横' . $eMailList ['staffName'],
  6136. 'subject' => $eMailList ['eTitle'],
  6137. 'substitution_vars' => json_encode ( $toFormatMail )
  6138. );
  6139. $post_data = http_build_query ( $param );
  6140. $ch = curl_init ();
  6141. curl_setopt ( $ch, CURLOPT_POST, 1 );
  6142. curl_setopt ( $ch, CURLOPT_URL, $url );
  6143. curl_setopt ( $ch, CURLOPT_HEADER, false ); // 设定是否输出页面内容
  6144. curl_setopt ( $ch, CURLOPT_NOBODY, false );
  6145. curl_setopt ( $ch, CURLOPT_POSTFIELDS, $post_data );
  6146. $result = curl_exec ( $ch );
  6147. curl_close ( $ch );
  6148. /*
  6149. * if($result=='success'){ $eM=new eMailList(); $eM->status='2'; $eM->update(array('where'=>'elid=?','param'=>array($elid))); }
  6150. */
  6151. }
  6152. // die;
  6153. return '/eMailList';
  6154. }
  6155. }
  6156. function a() {
  6157. $substitution_vars = $this->get_args ( 'substitution_vars' );
  6158. file_put_contents ( DOO::conf ()->SITE_PATH . 'upload/' . "_" . time () . "_" . rand ( 100, 999 ) . ".log", $substitution_vars );
  6159. }
  6160. function deleteEmail() {
  6161. $elid = isset ( $this->params ['elid'] ) ? $this->params ['elid'] : 0;
  6162. if (! empty ( $elid )) {
  6163. $sql = "DELETE FROM `CLD_eMailList` where elid = '" . $elid . "'";
  6164. Doo::db ()->query ( $sql );
  6165. return '/eMailList';
  6166. }
  6167. }
  6168. /**
  6169. * 发送post请求
  6170. * @param string $url 请求地址
  6171. * @param array $post_data post键值对数据
  6172. * @return string
  6173. */
  6174. function sendPost($url, $post_data) {
  6175. $postdata = http_build_query ( $post_data );
  6176. // X-Amzn-Authorization: AWS3 AWSAccessKeyId=AKIAIDSE5VYNX5ERJHXQ,Signature=lBP67vCvGlDMBQ=dofZxg8E8SUEXAMPLE,Algorithm=HmacSHA256,SignedHeaders=qG1BdSh9QyYPlWLnjqvjDXjyPdFjl7fUSkfs0Hk2
  6177. $options = array (
  6178. 'http' => array (
  6179. 'method' => 'POST',
  6180. 'header' => '
  6181. Content-Type: application/x-www-form-urlencoded
  6182. ',
  6183. 'content' => $postdata,
  6184. 'timeout' => 15 * 60
  6185. )
  6186. ); // 超时时间(单位:s)
  6187. $context = stream_context_create ( $options );
  6188. $result = file_get_contents ( $url, false, $context );
  6189. return $result;
  6190. }
  6191. function avatar() {
  6192. $result = array ();
  6193. $result ['success'] = false;
  6194. $successNum = 0;
  6195. // 定义一个变量用以储存当前头像的序号
  6196. $avatarNumber = 1;
  6197. $i = 0;
  6198. $msg = '';
  6199. // 上传目录
  6200. $dir = DOO::conf ()->SITE_PATH . "global/avatar";
  6201. // 遍历所有文件域
  6202. while ( list ( $key, $val ) = each ( $_FILES ) ) {
  6203. if ($_FILES [$key] ['error'] > 0)
  6204. $msg .= $_FILES [$key] ['error'];
  6205. else {
  6206. $fileName = 'avatar_' . $this->staff [0] ['sid'];
  6207. // 原始图片(file 域的名称:__source,如果客户端定义可以上传的话,可在此处理)。
  6208. if ($key == '__source') { // 当前头像基于原图的初始化参数,用于修改头像时保证界面的视图跟保存头像时一致。帮助提升用户体验度。修改头像时设置默认加载的原图的url为此图片的url+该参数即可。
  6209. $initParams = $_POST ["__initParams"];
  6210. $virtualPath = $dir . "/" . $fileName . "_" . $avatarNumber . ".jpg";
  6211. $result ['sourceUrl'] = '/' . $virtualPath . $initParams;
  6212. move_uploaded_file ( $_FILES [$key] ["tmp_name"], $virtualPath );
  6213. $successNum ++;
  6214. } else if (strpos ( $key, '__avatar' ) === 0) { // 头像图片(file 域的名称:__avatar1,2,3...)。
  6215. $virtualPath = $dir . "/" . $fileName . "_" . $avatarNumber . ".jpg";
  6216. $result ['avatarUrls'] [$i] = '/' . $virtualPath;
  6217. move_uploaded_file ( $_FILES [$key] ["tmp_name"], $virtualPath );
  6218. $avatarNumber ++;
  6219. $successNum ++;
  6220. $i ++;
  6221. }
  6222. }
  6223. }
  6224. $result ['msg'] = $msg;
  6225. if ($successNum > 0)
  6226. $result ['success'] = true;
  6227. // 返回图片的保存结果(返回内容为json字符串)
  6228. Doo::loadModel ( 'staff' );
  6229. $staff = new staff ();
  6230. $staff->sid = $this->staff [0] ['sid'];
  6231. $staff->avatar = "/global/avatar/" . $fileName;
  6232. $staff->update ();
  6233. echo json_encode ( $result );
  6234. }
  6235. function lockUpload() {
  6236. // move_uploaded_file($_FILES['Filedata']['tmp_name'], "/upload/".$_FILES['Filedata']['name']);
  6237. if (isset ( $_FILES ['Filedata'] ['name'] )) {
  6238. $file = $_FILES ['Filedata'] ['tmp_name'];
  6239. $error = false;
  6240. if (! is_uploaded_file ( $file )) {
  6241. $error = '400 Bad Request';
  6242. }
  6243. if ($error) {
  6244. header ( 'HTTP/1.0 ' . $error );
  6245. die ( 'Error ' . $error );
  6246. } else {
  6247. include (DOO::conf ()->SITE_PATH . 'protected/plugin/io.han.php');
  6248. $this->IoHandler = new IoHandler ();
  6249. $pics = explode ( '.', $_FILES ['Filedata'] ['name'] );
  6250. // $filedir=$_POST['time'];
  6251. // 调用定义物理路径
  6252. $t = DOO::conf ()->SITE_PATH . "upload/";
  6253. $this->IoHandler->MakeDir ( $t );
  6254. $filename = $this->_GetFileEXT ( $_FILES ['Filedata'] ['name'] );
  6255. if ($filename != 'xlsx')
  6256. return "";
  6257. // $upload_dir = $t."/".time().rand(10,100).".".$filename;
  6258. $upload_file = iconv ( "UTF-8", "GB2312", $_FILES ["Filedata"] ["name"] );
  6259. $upload_dir = $t . "/" . $upload_file;
  6260. $k = move_uploaded_file ( $file, $upload_dir );
  6261. if ($k) {
  6262. // "series/".$filedir."/".
  6263. $m = round ( $_FILES ['Filedata'] ['size'] / 1024 / 1024, 2 );
  6264. echo $pics [0] . "." . $filename . "#" . $m . "#" . $_FILES ['Filedata'] ['size'];
  6265. }
  6266. }
  6267. }
  6268. }
  6269. function getAuthentication() {
  6270. }
  6271. function loadCVS() {
  6272. Doo::loadModel ( 'longle' );
  6273. $longle = new longle ();
  6274. $list = $longle->find ( array (
  6275. 'select' => 'key_num',
  6276. 'asArray' => TRUE
  6277. ) );
  6278. $file = fopen ( DOO::conf ()->SITE_PATH . "upload/key2.csv", 'r' );
  6279. while ( $data = fgetcsv ( $file ) ) {
  6280. $goods_list [$data [0]] = $data [1];
  6281. }
  6282. fclose ( $file );
  6283. $sqlArray = array ();
  6284. $sql = 'UPDATE CLD_longle SET SerialNumber = CASE key_num ';
  6285. foreach ( $list as $key => $value ) {
  6286. if (array_key_exists ( $value ['key_num'], $goods_list )) {
  6287. // echo $value['key_num'].'-'.$goods_list[$value['key_num']].'<br/>';
  6288. // $longle->SerialNumber=$goods_list[$value['key_num']];
  6289. // $longle->update(array('where'=>'key_num="'.$value['key_num'].'"'));
  6290. $sql .= ' WHEN "' . $value ['key_num'] . '" THEN "' . $goods_list [$value ['key_num']] . '" ';
  6291. array_push ( $sqlArray, '"' . $value ['key_num'] . '"' );
  6292. unset ( $goods_list [$value ['key_num']] );
  6293. }
  6294. }
  6295. $sql .= 'END WHERE key_num IN (' . implode ( ',', $sqlArray ) . ')';
  6296. echo $sql . '<br/>--------------------------------<br/>';
  6297. foreach ( $goods_list as $key => $value ) {
  6298. echo $key . ',' . $value . '<br/>';
  6299. }
  6300. }
  6301. private function getRandChar($length) {
  6302. $str = null;
  6303. $strPol = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz";
  6304. $max = strlen ( $strPol ) - 1;
  6305. for($i = 0; $i < $length; $i ++) {
  6306. $str .= $strPol [rand ( 0, $max )]; // rand($min,$max)生成介于min和max两个数之间的一个随机整数
  6307. }
  6308. return $str;
  6309. }
  6310. // private function getReceiptCount(){
  6311. // $status=2;
  6312. // $year=date('Y');
  6313. // Doo::loadModel('receipt');
  6314. // $receipt=new receipt();
  6315. // $dateCondition=" and Year(date) =".$year;
  6316. // $approvalCondition=' and nowStaff like "%'.$this->staff[0]['sid'].'%" ';
  6317. // $receiptList=$receipt->find(array('where'=>' status='.$status.$dateCondition.$approvalCondition,'desc'=>'rid','asArray'=>true));
  6318. // return count($receiptList);
  6319. // }
  6320. // private function getExeCount(){
  6321. // Doo::loadModel('receipt');
  6322. // $receipt=new receipt();
  6323. // $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));
  6324. // return count($receiptList);
  6325. // }
  6326. /**
  6327. * 格式化excel文件为数组
  6328. * @param unknown_type $file_url
  6329. * @param unknown_type $mcid
  6330. */
  6331. function _format_excel_to_array($file_url = "") {
  6332. if (! file_exists ( $file_url ))
  6333. return array ();
  6334. Doo::loadClass ( 'PHPExcel' );
  6335. $PHPExcel = new PHPExcel ();
  6336. $PHPReader = new PHPExcel_Reader_Excel2007 ();
  6337. if (! $PHPReader->canRead ( $file_url )) {
  6338. $PHPReader = new PHPExcel_Reader_Excel5 ();
  6339. if (! $PHPReader->canRead ( $file_url )) {
  6340. echo 'no Excel';
  6341. return;
  6342. }
  6343. }
  6344. $PHPExcel = $PHPReader->load ( $file_url );
  6345. /**
  6346. * 读取excel文件中的第一个工作表
  6347. */
  6348. $currentSheet = $PHPExcel->getSheet ( 0 );
  6349. /**
  6350. * 取得最大的列号
  6351. */
  6352. $allColumn = $currentSheet->getHighestColumn ();
  6353. /**
  6354. * 取得一共有多少行
  6355. */
  6356. $allRow = $currentSheet->getHighestRow ();
  6357. $excel_array = array ();
  6358. for($currentRow = 2; $currentRow <= $allRow; $currentRow ++) {
  6359. $excel_column = array ();
  6360. // 后期改进
  6361. if ($allColumn == 'AM')
  6362. $allColumn = 'Z';
  6363. /**
  6364. * 从第A列开始输出
  6365. */
  6366. for($currentColumn = 'A'; $currentColumn <= $allColumn; $currentColumn ++) {
  6367. $val = $currentSheet->getCellByColumnAndRow ( ord ( $currentColumn ) - 65, $currentRow )->getValue ();
  6368. /**
  6369. * ord()将字符转为十进制数 iconv ( 'utf-8', 'gb2312',
  6370. */
  6371. $val = "'" . addslashes ( $val ) . "'";
  6372. if ($currentColumn == 'A')
  6373. $excel_column ['key_num'] = $val;
  6374. elseif ($currentColumn == 'C')
  6375. $excel_column ['product'] = $val;
  6376. elseif ($currentColumn == 'D') {
  6377. $val = str_replace ( "'", "", $val );
  6378. $excel_column ['make_day'] = $this->excelTime ( $val );
  6379. } elseif ($currentColumn == 'E') {
  6380. $val = str_replace ( "'", "", $val );
  6381. $excel_column ['alloted_time'] = $this->excelTime ( $val );
  6382. } elseif ($currentColumn == 'F') {
  6383. $val = str_replace ( "'", "", $val );
  6384. $excel_column ['version'] = $val;
  6385. } elseif ($currentColumn == 'B') {
  6386. $val = str_replace ( "'", "", $val );
  6387. $excel_column ['SerialNumber'] = $val;
  6388. }
  6389. }
  6390. array_push ( $excel_array, $excel_column );
  6391. }
  6392. return $excel_array;
  6393. }
  6394. function excelTime($date, $time = false) {
  6395. if (function_exists ( 'GregorianToJD' )) {
  6396. if (is_numeric ( $date )) {
  6397. $jd = GregorianToJD ( 1, 1, 1970 );
  6398. $gregorian = JDToGregorian ( $jd + intval ( $date ) - 25569 );
  6399. $date = explode ( '/', $gregorian );
  6400. $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" : '');
  6401. return $date_str;
  6402. }
  6403. } else {
  6404. $date = $date > 25568 ? $date + 1 : 25569;
  6405. /* There was a bug if Converting date before 1-1-1970 (tstamp 0) */
  6406. $ofs = (70 * 365 + 17 + 2) * 86400;
  6407. $date = date ( "Y-m-d", ($date * 86400) - $ofs ) . ($time ? " 00:00:00" : '');
  6408. }
  6409. return $date;
  6410. }
  6411. function _GetFileEXT($filename) {
  6412. $pics = explode ( '.', $filename );
  6413. $num = count ( $pics );
  6414. return $pics [$num - 1];
  6415. }
  6416. /**
  6417. * 获取get或者POST值
  6418. * @param string $name 属性名称
  6419. * @return fixed 值
  6420. */
  6421. function get_args($name) {
  6422. if (isset ( $_GET [$name] )) {
  6423. if (is_array ( $_GET [$name] ))
  6424. return $_GET [$name];
  6425. else {
  6426. return addslashes ( $_GET [$name] );
  6427. }
  6428. } elseif (isset ( $_POST [$name] )) {
  6429. if (is_array ( $_POST [$name] ))
  6430. return $_POST [$name];
  6431. else {
  6432. return addslashes ( $_POST [$name] );
  6433. }
  6434. } else {
  6435. return false;
  6436. }
  6437. }
  6438. function get_previous($on_page = 1) {
  6439. return $on_page != 0 ? $on_page - 1 : $on_page;
  6440. }
  6441. /**
  6442. * 获得分页数据
  6443. * @param unknown_type $table
  6444. * @param unknown_type $condition
  6445. * @param unknown_type $on_page
  6446. * @param unknown_type $page_size
  6447. */
  6448. function get_Tpage($table = "", $condition = "", $on_page = 1, $page_size = 20, $action = "", $tagSQL) {
  6449. $page_c = "";
  6450. $page ['previous'] = $this->get_previous ( $on_page );
  6451. $page ['on_page'] = $on_page;
  6452. $total_count = $this->get_table_Tcount ( $table, $condition, $tagSQL );
  6453. $total = intval ( $total_count / $page_size );
  6454. $page ['total_page'] = ($total_count % $page_size) == 0 ? $total : $total + 1;
  6455. $page ['total_data'] = $total_count;
  6456. $page ['next'] = $on_page == $page ['total_page'] ? $page ['total_page'] : $on_page + 1;
  6457. $i = 1;
  6458. $page_max = 1;
  6459. if ($on_page > 10) {
  6460. $page_max = intval ( $on_page / 10 ) + 1;
  6461. $i = intval ( $on_page / 10 ) * 10 - 1;
  6462. }
  6463. $page ['page'] = $page_c;
  6464. $page ['lower'] = (-- $on_page) * $page_size;
  6465. return $page;
  6466. }
  6467. /**
  6468. * 获得分页数据
  6469. * @param unknown_type $table
  6470. * @param unknown_type $condition
  6471. * @param unknown_type $on_page
  6472. * @param unknown_type $page_size
  6473. */
  6474. function get_page($table = "", $condition = "", $on_page = 1, $page_size = 20, $action = "", $get = "", $other = "page", $staffid = "", $search, $tooltip, $cateid, $tagSQL) {
  6475. $page_c = "";
  6476. $page ['previous'] = $this->get_previous ( $on_page );
  6477. $page ['on_page'] = $on_page;
  6478. $total_count = $this->get_table_count ( $table, $condition, $staffid, $search, $tooltip, $cateid, $tagSQL );
  6479. $total = intval ( $total_count / $page_size );
  6480. $page ['total_page'] = ($total_count % $page_size) == 0 ? $total : $total + 1;
  6481. $page ['total_data'] = $total_count;
  6482. $page ['next'] = $on_page == $page ['total_page'] ? $page ['total_page'] : $on_page + 1;
  6483. $i = 1;
  6484. $page_max = 1;
  6485. if ($on_page > 10) {
  6486. $page_max = intval ( $on_page / 10 ) + 1;
  6487. $i = intval ( $on_page / 10 ) * 10 - 1;
  6488. }
  6489. for(; $i <= $page ['total_page']; $i ++) {
  6490. if ($i == $on_page) {
  6491. if ($other == "page")
  6492. $page_c .= '<a href="javascript:void(0);" class="current">' . $i . '</a>';
  6493. else
  6494. $page_c .= '&nbsp;<span class="current">' . $i . '</span>&nbsp;';
  6495. } else if ($other == "page")
  6496. $page_c .= '<a href="' . $action . $i . $get . '" class="paginate">' . $i . '</a>';
  6497. else
  6498. $page_c .= '&nbsp;<a href="' . $action . $i . $get . '" class="paginate">' . $i . '</a>&nbsp;';
  6499. if ($i == (10 * $page_max))
  6500. break;
  6501. }
  6502. $page ['page'] = $page_c;
  6503. $page ['lower'] = (-- $on_page) * $page_size;
  6504. return $page;
  6505. }
  6506. /**
  6507. * 获取总页数
  6508. * @param unknown_type $table
  6509. * @param unknown_type $condition
  6510. */
  6511. public function get_table_Tcount($table = "", $condition = "", $tagSQL) {
  6512. if ($tagSQL)
  6513. $sql = "select count(*) as count from CLD_tagCompanyNexus as a left join CLD_company as b on (a.company=b.cid ) where " . $condition;
  6514. else
  6515. $sql = "select count(*) as count from CLD_company where " . $condition;
  6516. $query = Doo::db ()->query ( $sql );
  6517. $result = $query->fetch ();
  6518. return $result ['count'];
  6519. }
  6520. /**
  6521. * 获取总页数
  6522. * @param unknown_type $table
  6523. * @param unknown_type $condition
  6524. */
  6525. public function get_table_count($table = "", $condition = "", $staffid = "", $search, $tooltip, $cateid, $tagSQL) {
  6526. // $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  6527. // echo $staffid;die;
  6528. //
  6529. if (! empty ( $staffid )) {
  6530. // $staffid="and a.sid= '".$staffid."'"; " . $table . " as a left join on (a.cid=b.cid ".$staffid.")
  6531. $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;
  6532. } else {
  6533. if (strlen ( $condition ) == 1 || empty ( $condition ))
  6534. $sql = "select count(*) as count from CLD_client as a " . $condition;
  6535. else
  6536. $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;
  6537. }
  6538. if (! empty ( $search ))
  6539. $sql = "select count(*) as count from CLD_client as a where 1 " . $condition;
  6540. if (! empty ( $tooltip )) {
  6541. $condition = str_replace ( "a.", "c.", $condition );
  6542. if ($tagSQL)
  6543. $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;
  6544. else
  6545. $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;
  6546. }
  6547. // echo $sql;
  6548. $query = Doo::db ()->query ( $sql );
  6549. $result = $query->fetch ();
  6550. return $result ['count'];
  6551. }
  6552. /**
  6553. * 生成token
  6554. * @return string
  6555. */
  6556. function set_token() {
  6557. $str = md5 ( uniqid ( md5 ( microtime ( true ) ), true ) ); // 生成一个不会重复的字符串
  6558. $str = sha1 ( $str ); // 加密
  6559. return $str;
  6560. }
  6561. }
  6562. ?>