MainController.php 232 KB

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