MainController.php 227 KB

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