MainController.php 223 KB

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