MainController.php 262 KB

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