MainController.php 234 KB

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