InvoiceController.php 222 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994
  1. <?php
  2. /**
  3. * 开票功能控制器
  4. * @author CP
  5. * @version 1.0
  6. * @namespace invoice
  7. * @package invoiceController
  8. */
  9. class InvoiceController extends DooController {
  10. public $staff;
  11. public $NEW;
  12. public $data;
  13. private $INVOICEKEY = "APPROVAL";
  14. private $INVOICECOLLECTPATH = "protected/cache/invoiceCollect/";
  15. private $ACTION = '';
  16. private $appId = 'wx3ee46531947a1384';
  17. private $appSecret = 'awGWzy3J5q_96VXKBLA2BQ9RpiT0LiPXnkMF-xV6h5o'; // awGWzy3J5q_96VXKBLA2BXU6mVCGynPGD-sxUCsdNDE //'PeiQVH8tbQE7pM9pVO4AIPlX9FFNpwu7O6Iy6VFcAVtpjTA3Qn42dbNmktBFkUHo';
  18. public function beforeRun($resource, $action) {
  19. Doo::loadModel ( "invoiceManage" );
  20. $invoiceManage = new invoiceManage ();
  21. Doo::loadClass ( 'XDeode' );
  22. $XDeode = new XDeode ( 5 );
  23. $sid = $XDeode->decode ( $_COOKIE ["staff"] );
  24. header ( 'Content-Type:text/html;charset=utf-8' );
  25. $moldList = $invoiceManage->getInvoiceByStaff ( $sid );
  26. if (empty ( $moldList )) {
  27. $flag = false;
  28. $uGroups = 'ordinary';
  29. if (Doo::acl ()->isAllowed ( $uGroups, $resource, $action )) {
  30. $flag = true;
  31. }
  32. } else {
  33. $flag = false;
  34. array_push ( $moldList, array (
  35. 'mold' => 'ordinary'
  36. ) );
  37. // 删除审批人后-加入权限问题-暂时关闭
  38. $fileInvoice = file_get_contents ( "protected/config/invoice/invoice.ini" );
  39. $fiML = json_decode ( $fileInvoice, true );
  40. if (empty ( $fiML ))
  41. $fiML = array ();
  42. foreach ( $fiML as $key => $value ) {
  43. $sidList = explode ( ',', $value );
  44. foreach ( $sidList as $k => $v ) {
  45. if ($v == $sid) {
  46. array_push ( $moldList, array (
  47. 'mold' => $key
  48. ) );
  49. break;
  50. }
  51. }
  52. }
  53. foreach ( $moldList as $value ) {
  54. if (Doo::acl ()->isAllowed ( $value ['mold'], $resource, $action )) {
  55. $flag = true;
  56. break;
  57. }
  58. }
  59. }
  60. /*
  61. * Doo::acl()->isAllowed($uGroups['groups'], $resource, $action);
  62. */
  63. // var_dump($flag) ;
  64. if (! $flag)
  65. die ( 'illegal request' );
  66. }
  67. function __construct() {
  68. if (isset ( $_COOKIE ["staff"] )) {
  69. if (! empty ( $_COOKIE ["staff"] )) {
  70. Doo::loadModel ( 'staff' );
  71. $staff = new staff ();
  72. $uriPartsOrig = explode ( '/', $_SERVER ['REQUEST_URI'] );
  73. $this->ACTION = $uriPartsOrig [1];
  74. $this->data ['new'] = $this->isInvoiceNew ();
  75. $this->staff = $staff->getUserByIdList ( $_COOKIE ["staff"] );
  76. return "/";
  77. }
  78. }
  79. Doo::loadCore ( 'uri/DooUriRouter' );
  80. $router = new DooUriRouter ();
  81. $routeRs = $router->execute ( Doo::app ()->route, Doo::conf ()->SUBFOLDER );
  82. if ($routeRs ['1'] != "login") {
  83. header ( 'Content-Type:text/html;charset=utf-8' );
  84. @header ( "Location: /login" );
  85. }
  86. }
  87. function testSend() {
  88. // 测试根据规则发送信息 普通发送
  89. // $pendingApprovalsSid = 41;
  90. // Doo::loadModel ( 'staff' );
  91. // $staff = new staff ();
  92. // $username2 = $staff->getOne ( array ( 'select' => 'wxid', 'where' => 'sid=' . $pendingApprovalsSid, 'asArray' => TRUE ) );
  93. // // 发送微信审批通知
  94. // $title2 = '[通知]用户提交了一条开票申请,快到“我的发票”中查看,给用户确认审批。';
  95. // $this->msgSend ( '', $title2, '', $username2 ['wxid'], $pendingApprovalsSid, 'approval' );
  96. // Doo::loadModel ( 'staff' );
  97. // $staff = new staff ();
  98. // $toparty = $this->getToparty ( '广东办' );
  99. // $wxList = array ();
  100. // if (! empty ( $toparty )) {
  101. // $userList = $this->getUserByToparty ( $toparty );
  102. // $userCon = implode ( ',', $userList );
  103. // // echo $userCon;
  104. // $sidList = $staff->getStaffByWxid ( $userCon );
  105. // foreach ( $sidList as $key => $value ) {
  106. // $falg = $this->isSendNotification ( $value ['sid'], 'receivables' );
  107. // if ($falg) {
  108. // array_push ( $wxList, $value ['wxid'] );
  109. // }
  110. // }
  111. // $wxString = implode ( '|', $wxList );
  112. // print_r ( $wxList );
  113. // echo $wxString;
  114. // }
  115. // 测试发送
  116. /*
  117. * //$toparty = $this->getWxidByCategory( $receivablesCategory [1] ); $toparty = $this->getToparty ( $receivablesCategory [1] ); $msg = '[通知]财务录入了一笔待认领款项,快到“我的收款”中查看,确认是否是您的客户给您打款了。'; if ($toparty != 0) $this->msgSendToparty ( $msg, '', '', $toparty, 'text' );
  118. */
  119. // print_r ( $userList );
  120. // $msTouser='caipin|outaozhen';
  121. // $toparty = $this->getToparty ( $receivablesCategory [1] );
  122. // $title2 = '[通知]财务录入了一笔待认领款项,快到“我的收款”中查看,确认是否是您的客户给您打款了。';
  123. // $hfreult = $this->msgSend ( '', $title2, '', 'outaozhen' );
  124. // $toparty= $this->getToparty('广东办');
  125. // $msg = '[通知]财务录入了一笔待认领款项,快到“我的收款”中查看,确认是否是您的客户给您打款了。';
  126. // $toparty = 26;
  127. // $msg = '';
  128. // $url = 'http://m.cld.smartcost.com.cn/invoicePrintDetail/1.html';
  129. // $hfreult = $this->msgSendToparty ( $msg, '', '', $toparty,'text' );
  130. }
  131. function invoice() {
  132. Doo::loadModel ( 'invoice' );
  133. $invoice = new invoice ();
  134. Doo::loadModel ( 'express' );
  135. $express = new express ();
  136. $expressList = $express->getExpressByAll ();
  137. $this->data ['expressList'] = $expressList;
  138. // Doo::loadModel ( 'invoiceReceivables' );
  139. // $invoiceReceivables = new invoiceReceivables ();
  140. // $list = $invoiceReceivables->getInvoiceReceivablesByClaim ( $this->staff [0] ['cid'], $this->staff [0] ['sid'] );
  141. Doo::loadModel ( 'invoiceStatistics' );
  142. $invoiceStatistics = new invoiceStatistics ();
  143. $isMonth = $invoiceStatistics->getStatisticsByMonth ();
  144. $year = date ( "Y" );
  145. $tmp_date = date ( "Ym" );
  146. $tmp_year = substr ( $tmp_date, 0, 4 );
  147. $tmp_mon = substr ( $tmp_date, 4, 2 );
  148. $tmp_forwardmonth = mktime ( 0, 0, 0, $tmp_mon - 1, 1, $tmp_year );
  149. $fm_forward_month = date ( "m", $tmp_forwardmonth );
  150. $path = SITE_PATH . $this->INVOICECOLLECTPATH . "invoiceCollect_" . $year . "_" . $fm_forward_month . ".htm";
  151. $htm = $this->showCache ( $path );
  152. Doo::loadClass ( 'XDeode' );
  153. $XDeode = new XDeode ( 5 );
  154. $sid = $XDeode->decode ( $_COOKIE ["staff"] );
  155. $invoiceList = $invoice->getMyInvoice ( $sid );
  156. $sql = 'status=2 and printStatus=1 and irid!="" and sid=' . $sid;
  157. $list = $invoice->getInvoiceByUntreadStatusPage ( 4, $sql );
  158. // 我的待入账发票 and irid='' and ( (doPost=1 and postStatus=1) or doPost=0 )
  159. $sql = "status=2 and printStatus=1 and untreadStatus=0 and isDelete=0 and sid=" . $sid;
  160. $myInvoiceUnAccount = $invoice->getInvoiceByUntreadStatusPage ( 4, $sql );
  161. // print_r($myInvoiceUnAccount);
  162. $this->data ['isMonth'] = $isMonth;
  163. $this->data ['htm'] = $htm;
  164. $this->data ['invoiceList'] = $invoiceList;
  165. $this->data ['receivablesList'] = $list;
  166. $this->data ['myInvoiceUnAccount'] = $myInvoiceUnAccount;
  167. $this->data ['memu'] = "invoice";
  168. $this->data ['staff'] = $this->staff;
  169. $this->data ['receiptMemu'] = 'invoice';
  170. $this->render ( "/admin/invoice", $this->data );
  171. }
  172. function invoiceExpress() {
  173. $expressCom = isset ( $this->params ['expressCom'] ) ? $this->params ['expressCom'] : "";
  174. $expressNumber = isset ( $this->params ['expressNumber'] ) ? $this->params ['expressNumber'] : "";
  175. $this->data ['expressCom'] = $expressCom;
  176. $this->data ['expressNumber'] = $expressNumber;
  177. $this->render ( "/admin/invoiceExpress", $this->data );
  178. }
  179. function invoiceAdd() {
  180. Doo::loadModel ( 'L_category' );
  181. $lCategory = new L_category ();
  182. $category = $lCategory->find ( array (
  183. 'asArray' => true
  184. ) );
  185. $this->data ['category'] = $category;
  186. $this->data ['memu'] = "invoice";
  187. $this->data ['staff'] = $this->staff;
  188. $this->data ['receiptMemu'] = 'invoice';
  189. $this->render ( "/admin/invoiceAdd", $this->data );
  190. }
  191. /**
  192. * 提交一份开票申请,并记录下操作日志
  193. *
  194. * @since 1.0.0
  195. * @var integer cid 办事处ID
  196. * @var integer invoiceType 发票类型
  197. * @var integer doPost 是否邮寄
  198. * @var integer invoicePrice 开票金额
  199. * @var string invoiceElement 开票内容
  200. * @var string invoiceTitle 发票抬头
  201. * @var string invoiceCompany 单位名称
  202. * @var string TIN 纳税人识别码
  203. * @var string address 注册地址
  204. * @var string phone 注册电话
  205. * @var string bank 开户银行
  206. * @var string bankAccount 银行账户
  207. * @var string recipients 收件人
  208. * @var string recipientsPhone 收件人手机/电话
  209. * @var string recipientsAddress 收件地址
  210. * @var string mailItems 邮寄物品
  211. * @var string remark 备注
  212. * @return string 返回跳转开票主页路径
  213. */
  214. function invoiceAddDo() {
  215. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  216. $invoiceType = $this->get_args ( 'invoiceType' ) && is_numeric ( $this->get_args ( 'invoiceType' ) ) ? $this->get_args ( 'invoiceType' ) : 0;
  217. $doPost = $this->get_args ( 'doPost' ) && is_numeric ( $this->get_args ( 'doPost' ) ) ? $this->get_args ( 'doPost' ) : 0;
  218. $invoicePrice = $this->get_args ( 'invoicePrice' ) ? $this->get_args ( 'invoicePrice' ) : "";
  219. $invoiceQuantity = $this->get_args ( 'invoiceQuantity' ) && is_numeric ( $this->get_args ( 'invoiceQuantity' ) ) ? $this->get_args ( 'invoiceQuantity' ) : 0;
  220. $invoiceUnitPrice = $this->get_args ( 'invoiceUnitPrice' ) && is_numeric ( $this->get_args ( 'invoiceUnitPrice' ) ) ? $this->get_args ( 'invoiceUnitPrice' ) : 0;
  221. $invoiceElement = $this->get_args ( 'invoiceElement' ) ? $this->get_args ( 'invoiceElement' ) : "";
  222. $invoiceTitle = $this->get_args ( 'invoiceTitle' ) ? $this->get_args ( 'invoiceTitle' ) : "";
  223. $invoiceCompany = $this->get_args ( 'invoiceCompany' ) ? $this->get_args ( 'invoiceCompany' ) : "";
  224. $TIN = $this->get_args ( 'TIN' ) ? $this->get_args ( 'TIN' ) : "";
  225. $address = $this->get_args ( 'address' ) ? $this->get_args ( 'address' ) : "";
  226. $phone = $this->get_args ( 'phone' ) ? $this->get_args ( 'phone' ) : "";
  227. $bank = $this->get_args ( 'bank' ) ? $this->get_args ( 'bank' ) : "";
  228. $bankAccount = $this->get_args ( 'bankAccount' ) ? $this->get_args ( 'bankAccount' ) : "";
  229. $recipients = $this->get_args ( 'recipients' ) ? $this->get_args ( 'recipients' ) : "";
  230. $recipientsPhone = $this->get_args ( 'recipientsPhone' ) ? $this->get_args ( 'recipientsPhone' ) : "";
  231. $recipientsAddress = $this->get_args ( 'recipientsAddress' ) ? $this->get_args ( 'recipientsAddress' ) : "";
  232. $remark = $this->get_args ( 'remark' ) ? $this->get_args ( 'remark' ) : "";
  233. $TINT = $this->get_args ( 'TINT' ) ? $this->get_args ( 'TINT' ) : "";
  234. $addressT = $this->get_args ( 'addressT' ) ? $this->get_args ( 'addressT' ) : "";
  235. $phoneT = $this->get_args ( 'phoneT' ) ? $this->get_args ( 'phoneT' ) : "";
  236. $bankT = $this->get_args ( 'bankT' ) ? $this->get_args ( 'bankT' ) : "";
  237. $bankAccountT = $this->get_args ( 'bankAccountT' ) ? $this->get_args ( 'bankAccountT' ) : "";
  238. $softLock = $this->get_args ( 'softLock' ) ? $this->get_args ( 'softLock' ) : 0;
  239. $softLockNum = $this->get_args ( 'softLockNum' ) ? $this->get_args ( 'softLockNum' ) : 0;
  240. $contract = $this->get_args ( 'contract' ) ? $this->get_args ( 'contract' ) : 0;
  241. $contractNum = $this->get_args ( 'contractNum' ) ? $this->get_args ( 'contractNum' ) : 0;
  242. $instructions = $this->get_args ( 'instructions' ) ? $this->get_args ( 'instructions' ) : 0;
  243. $instructionsNum = $this->get_args ( 'instructionsNum' ) ? $this->get_args ( 'instructionsNum' ) : 0;
  244. $remittance = $this->get_args ( 'remittance' ) ? $this->get_args ( 'remittance' ) : 0;
  245. $mailItems = $this->get_args ( 'mailItems' ) ? $this->get_args ( 'mailItems' ) : "";
  246. /*
  247. * $mailList=array(); array_push($mailList, array('invoice'=>1)); array_push($mailList, array('mailItems'=>$mailItems)); if (!empty($softLock)) array_push($mailList, array('softLock'=>$softLockNum)); if (!empty($contract)) array_push($mailList, array('contract'=>$contractNum)); if (!empty($instructions)) array_push($mailList, array('instructions'=>$instructionsNum)); if (!empty($remittance)) array_push($mailList, array('remittance'=>$remittance)); echo json_encode($mailList) ; print_r($mailList); die;
  248. */
  249. if (empty ( $this->staff [0] ))
  250. die ( 'illegal request' );
  251. if (! empty ( $cid ) && ! empty ( $invoiceQuantity ) && ! empty ( $invoiceUnitPrice ) && ! empty ( $invoiceElement )) {
  252. Doo::loadModel ( 'invoice' );
  253. $invoice = new invoice ();
  254. Doo::loadModel ( 'L_category' );
  255. $lCategory = new L_category ();
  256. Doo::loadModel ( 'invoiceManage' );
  257. $invoiceManage = new invoiceManage ();
  258. Doo::loadModel ( 'invoiceOperationLog' );
  259. $invoiceOperationLog = new invoiceOperationLog ();
  260. $categoryDetil = $lCategory->getOne ( array (
  261. 'SELECT' => 'title',
  262. 'where' => 'cid=' . $cid,
  263. 'asArray' => true
  264. ) );
  265. $invoicePrice = $invoiceQuantity * $invoiceUnitPrice;
  266. $invoiceManageList = $invoiceManage->getInvoiceByAll ();
  267. $invoiceManageDetail = $invoiceManage->getInvoiceByMold ( "发票审批" );
  268. // print_r(current($invoiceManageDetail ['staffList']));
  269. // die;
  270. $moldManage = array ();
  271. foreach ( $invoiceManageList as $key => $value ) {
  272. if ($value ['mold'] == '发票打印')
  273. $moldManage [$value ['mold']] = $value ['staffList'];
  274. elseif ($value ['mold'] == '发票邮寄')
  275. $moldManage [$value ['mold']] = $value ['staffList'];
  276. elseif ($value ['mold'] == '发票退票')
  277. $moldManage [$value ['mold']] = $value ['staffList'];
  278. }
  279. $pendingApprovalsSid = current ( $invoiceManageDetail ['staffList'] ) [0];
  280. $item = array (
  281. 'cid' => $cid,
  282. 'categoryName' => $categoryDetil ['title'],
  283. 'invoiceElement' => $invoiceElement,
  284. 'invoiceQuantity' => $invoiceQuantity,
  285. 'invoiceUnitPrice' => $invoiceUnitPrice,
  286. 'invoicePrice' => $invoicePrice,
  287. 'invoiceType' => $invoiceType,
  288. 'doPost' => $doPost,
  289. 'status' => 1,
  290. 'invoiceSerial' => "#F" . date ( "Ymd" ) . mt_rand ( 1000, 9999 ),
  291. 'date' => date ( "Y-m-d H:i:s" ),
  292. 'updateTime' => date ( "Y-m-d H:i:s" ),
  293. 'sid' => $this->staff [0] ['sid'],
  294. 'userName' => $this->staff [0] ['username'],
  295. 'invoiceManage' => $invoiceManageDetail ['staff'],
  296. 'pendingApprovals' => $pendingApprovalsSid,
  297. 'moldManage' => json_encode ( $moldManage ),
  298. 'remark' => $remark
  299. );
  300. if ($invoiceType == 0)
  301. $item += array (
  302. 'invoiceTitle' => $invoiceTitle,
  303. 'TIN' => $TINT,
  304. 'address' => $addressT,
  305. 'phone' => $phoneT,
  306. 'bank' => $bankT,
  307. 'bankAccount' => $bankAccountT
  308. );
  309. else {
  310. $item += array (
  311. 'invoiceCompany' => $invoiceCompany,
  312. 'TIN' => $TIN,
  313. 'address' => $address,
  314. 'phone' => $phone,
  315. 'bank' => $bank,
  316. 'bankAccount' => $bankAccount
  317. );
  318. }
  319. if ($doPost == 1) {
  320. $mailList = array (
  321. 'invoice' => 1,
  322. 'mailItems' => $mailItems
  323. );
  324. if (! empty ( $softLock ))
  325. $mailList += array (
  326. 'softLock' => $softLockNum
  327. );
  328. else
  329. $mailList += array (
  330. 'softLock' => 0
  331. );
  332. if (! empty ( $contract ))
  333. $mailList += array (
  334. 'contract' => $contractNum
  335. );
  336. else
  337. $mailList += array (
  338. 'contract' => 0
  339. );
  340. if (! empty ( $instructions ))
  341. $mailList += array (
  342. 'instructions' => $instructionsNum
  343. );
  344. else
  345. $mailList += array (
  346. 'instructions' => 0
  347. );
  348. if (! empty ( $remittance ))
  349. $mailList += array (
  350. 'remittance' => $remittance
  351. );
  352. else
  353. $mailList += array (
  354. 'remittance' => ''
  355. );
  356. $mailString = '发票x1,备注:' . $mailItems;
  357. if (! empty ( $softLock ))
  358. $mailString .= ',软件锁x' . $softLockNum;
  359. if (! empty ( $contract ))
  360. $mailString .= ',合同x' . $contractNum;
  361. if (! empty ( $instructions ))
  362. $mailString .= ',说明书x' . $instructionsNum;
  363. if (! empty ( $remittance ))
  364. $mailString .= ',汇款账号单';
  365. $item += array (
  366. 'recipients' => $recipients,
  367. 'recipientsPhone' => $recipientsPhone,
  368. 'recipientsAddress' => $recipientsAddress,
  369. 'mailItems' => $mailString,
  370. 'mailItemsJson' => json_encode ( $mailList )
  371. );
  372. }
  373. $iid = $invoice->addInvoice ( $item );
  374. $item = array (
  375. 'date' => date ( "Y-m-d H:i:s" ),
  376. 'operation' => "创建",
  377. 'status' => 1,
  378. 'img' => $this->staff [0] ['avatar'],
  379. 'username' => $this->staff [0] ['username'],
  380. 'uid' => $this->staff [0] ['sid'],
  381. 'category' => $this->staff [0] ['category'],
  382. 'iid' => $iid
  383. );
  384. $invoiceOperationLog->setInvoiceOperationLog ( $item );
  385. $item = array (
  386. 'date' => date ( "Y-m-d H:i:s" ),
  387. 'operation' => "提交审批",
  388. 'status' => 1,
  389. 'img' => $this->staff [0] ['avatar'],
  390. 'username' => $this->staff [0] ['username'],
  391. 'uid' => $this->staff [0] ['sid'],
  392. 'category' => $this->staff [0] ['category'],
  393. 'iid' => $iid
  394. );
  395. $invoiceOperationLog->setInvoiceOperationLog ( $item );
  396. Doo::loadModel ( 'staff' );
  397. $staff = new staff ();
  398. $username2 = $staff->getOne ( array (
  399. 'select' => 'wxid',
  400. 'where' => 'sid=' . $pendingApprovalsSid,
  401. 'asArray' => TRUE
  402. ) );
  403. // 发送微信审批通知
  404. $title2 = '[通知]用户提交了一条开票申请,快到“我的发票”中查看,给用户确认审批。';
  405. $this->msgSend ( '', $title2, '', $username2 ['wxid'], $pendingApprovalsSid, 'approval' );
  406. }
  407. return "/invoice";
  408. }
  409. function invoiceEdit() {
  410. Doo::loadClass ( 'XDeode' );
  411. $XDeode = new XDeode ( 5 );
  412. $iid = isset ( $this->params ['iid'] ) ? $this->params ['iid'] : "";
  413. $iid = $XDeode->decode ( $iid );
  414. if (! is_numeric ( $iid ))
  415. die ( 'illegal request' );
  416. Doo::loadModel ( 'invoice' );
  417. $invoice = new invoice ();
  418. Doo::loadModel ( 'invoiceOperationLog' );
  419. $invoiceOperationLog = new invoiceOperationLog ();
  420. $invoiceDetail = $invoice->getInvoiceByIid ( $iid );
  421. $operation = $invoiceOperationLog->getInvoiceOperationByDropped ( $iid );
  422. $invoiceDetail ['mailItemsJson'] = json_decode ( $invoiceDetail ['mailItemsJson'], true );
  423. $this->data ['operation'] = $operation;
  424. $this->data ['invoiceDetail'] = $invoiceDetail;
  425. $this->data ['memu'] = "invoice";
  426. $this->data ['staff'] = $this->staff;
  427. $this->data ['receiptMemu'] = 'invoice';
  428. $this->render ( "/admin/invoiceEdit", $this->data );
  429. }
  430. /**
  431. * 重新编辑退回的发票
  432. * @return string
  433. */
  434. function invoiceEditDo() {
  435. $iidKey = $this->get_args ( 'iidKey' ) ? $this->get_args ( 'iidKey' ) : '';
  436. Doo::loadModel ( 'invoice' );
  437. $invoice = new invoice ();
  438. $iid = $invoice->authcode ( $iidKey );
  439. if (! empty ( $iid ) && ! is_numeric ( $iid ))
  440. die ( 'illegal request' );
  441. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  442. $invoiceType = $this->get_args ( 'invoiceType' ) && is_numeric ( $this->get_args ( 'invoiceType' ) ) ? $this->get_args ( 'invoiceType' ) : 0;
  443. $doPost = $this->get_args ( 'doPost' ) && is_numeric ( $this->get_args ( 'doPost' ) ) ? $this->get_args ( 'doPost' ) : 0;
  444. $invoicePrice = $this->get_args ( 'invoicePrice' ) ? $this->get_args ( 'invoicePrice' ) : "";
  445. $invoiceQuantity = $this->get_args ( 'invoiceQuantity' ) && is_numeric ( $this->get_args ( 'invoiceQuantity' ) ) ? $this->get_args ( 'invoiceQuantity' ) : 0;
  446. $invoiceUnitPrice = $this->get_args ( 'invoiceUnitPrice' ) && is_numeric ( $this->get_args ( 'invoiceUnitPrice' ) ) ? $this->get_args ( 'invoiceUnitPrice' ) : 0;
  447. $invoiceElement = $this->get_args ( 'invoiceElement' ) ? $this->get_args ( 'invoiceElement' ) : "";
  448. $invoiceTitle = $this->get_args ( 'invoiceTitle' ) ? $this->get_args ( 'invoiceTitle' ) : "";
  449. $invoiceCompany = $this->get_args ( 'invoiceCompany' ) ? $this->get_args ( 'invoiceCompany' ) : "";
  450. $TIN = $this->get_args ( 'TIN' ) ? $this->get_args ( 'TIN' ) : "";
  451. $address = $this->get_args ( 'address' ) ? $this->get_args ( 'address' ) : "";
  452. $phone = $this->get_args ( 'phone' ) ? $this->get_args ( 'phone' ) : "";
  453. $bank = $this->get_args ( 'bank' ) ? $this->get_args ( 'bank' ) : "";
  454. $bankAccount = $this->get_args ( 'bankAccount' ) ? $this->get_args ( 'bankAccount' ) : "";
  455. $recipients = $this->get_args ( 'recipients' ) ? $this->get_args ( 'recipients' ) : "";
  456. $recipientsPhone = $this->get_args ( 'recipientsPhone' ) ? $this->get_args ( 'recipientsPhone' ) : "";
  457. $recipientsAddress = $this->get_args ( 'recipientsAddress' ) ? $this->get_args ( 'recipientsAddress' ) : "";
  458. $mailItems = $this->get_args ( 'mailItems' ) ? $this->get_args ( 'mailItems' ) : "";
  459. $remark = $this->get_args ( 'remark' ) ? $this->get_args ( 'remark' ) : "";
  460. $TINT = $this->get_args ( 'TINT' ) ? $this->get_args ( 'TINT' ) : "";
  461. $addressT = $this->get_args ( 'addressT' ) ? $this->get_args ( 'addressT' ) : "";
  462. $phoneT = $this->get_args ( 'phoneT' ) ? $this->get_args ( 'phoneT' ) : "";
  463. $bankT = $this->get_args ( 'bankT' ) ? $this->get_args ( 'bankT' ) : "";
  464. $bankAccountT = $this->get_args ( 'bankAccountT' ) ? $this->get_args ( 'bankAccountT' ) : "";
  465. $softLock = $this->get_args ( 'softLock' ) ? $this->get_args ( 'softLock' ) : 0;
  466. $softLockNum = $this->get_args ( 'softLockNum' ) ? $this->get_args ( 'softLockNum' ) : 0;
  467. $contract = $this->get_args ( 'contract' ) ? $this->get_args ( 'contract' ) : 0;
  468. $contractNum = $this->get_args ( 'contractNum' ) ? $this->get_args ( 'contractNum' ) : 0;
  469. $instructions = $this->get_args ( 'instructions' ) ? $this->get_args ( 'instructions' ) : 0;
  470. $instructionsNum = $this->get_args ( 'instructionsNum' ) ? $this->get_args ( 'instructionsNum' ) : 0;
  471. $remittance = $this->get_args ( 'remittance' ) ? $this->get_args ( 'remittance' ) : 0;
  472. if (! empty ( $cid ) && ! empty ( $invoiceQuantity ) && ! empty ( $invoiceUnitPrice ) && ! empty ( $invoiceElement ) && ! empty ( $iid )) {
  473. Doo::loadModel ( 'invoiceManage' );
  474. $invoiceManage = new invoiceManage ();
  475. Doo::loadModel ( 'invoiceOperationLog' );
  476. $invoiceOperationLog = new invoiceOperationLog ();
  477. $cid = explode ( ':', $cid );
  478. $invoiceManageList = $invoiceManage->getInvoiceByAll ();
  479. $invoiceManageDetail = $invoiceManage->getInvoiceByMold ( "发票审批" );
  480. $moldManage = array ();
  481. foreach ( $invoiceManageList as $key => $value ) {
  482. if ($value ['mold'] == '发票打印')
  483. $moldManage [$value ['mold']] = $value ['staffList'];
  484. elseif ($value ['mold'] == '发票邮寄')
  485. $moldManage [$value ['mold']] = $value ['staffList'];
  486. elseif ($value ['mold'] == '发票打印')
  487. $moldManage [$value ['mold']] = $value ['staffList'];
  488. }
  489. $invoicePrice = $invoiceQuantity * $invoiceUnitPrice;
  490. $item = array (
  491. 'iid' => $iid,
  492. 'cid' => $cid [0],
  493. 'categoryName' => $cid [1],
  494. 'invoiceElement' => $invoiceElement,
  495. 'invoiceQuantity' => $invoiceQuantity,
  496. 'invoiceUnitPrice' => $invoiceUnitPrice,
  497. 'invoicePrice' => $invoicePrice,
  498. 'invoiceType' => $invoiceType,
  499. 'doPost' => $doPost,
  500. 'status' => 1,
  501. 'updateTime' => date ( "Y-m-d H:i:s" ),
  502. 'remark' => $remark
  503. );
  504. if ($invoiceType == 0)
  505. $item += array (
  506. 'invoiceTitle' => $invoiceTitle,
  507. 'TIN' => $TINT,
  508. 'address' => $addressT,
  509. 'phone' => $phoneT,
  510. 'bank' => $bankT,
  511. 'bankAccount' => $bankAccountT
  512. );
  513. else {
  514. $item += array (
  515. 'invoiceCompany' => $invoiceCompany,
  516. 'TIN' => $TIN,
  517. 'address' => $address,
  518. 'phone' => $phone,
  519. 'bank' => $bank,
  520. 'bankAccount' => $bankAccount
  521. );
  522. }
  523. if ($doPost == 1) {
  524. $mailList = array (
  525. 'invoice' => 1,
  526. 'mailItems' => $mailItems
  527. );
  528. if (! empty ( $softLock ))
  529. $mailList += array (
  530. 'softLock' => $softLockNum
  531. );
  532. else
  533. $mailList += array (
  534. 'softLock' => '0'
  535. );
  536. if (! empty ( $contract ))
  537. $mailList += array (
  538. 'contract' => $contractNum
  539. );
  540. else
  541. $mailList += array (
  542. 'contract' => '0'
  543. );
  544. if (! empty ( $instructions ))
  545. $mailList += array (
  546. 'instructions' => $instructionsNum
  547. );
  548. else
  549. $mailList += array (
  550. 'instructions' => '0'
  551. );
  552. if (! empty ( $remittance ))
  553. $mailList += array (
  554. 'remittance' => $remittance
  555. );
  556. else
  557. $mailList += array (
  558. 'remittance' => ''
  559. );
  560. $mailString = '发票x1,备注:' . $mailItems;
  561. if (! empty ( $softLock ))
  562. $mailString .= ',软件锁x' . $softLockNum;
  563. if (! empty ( $contract ))
  564. $mailString .= ',合同x' . $contractNum;
  565. if (! empty ( $instructions ))
  566. $mailString .= ',说明书x' . $instructionsNum;
  567. if (! empty ( $remittance ))
  568. $mailString .= ',汇款账号单';
  569. $item += array (
  570. 'recipients' => $recipients,
  571. 'recipientsPhone' => $recipientsPhone,
  572. 'recipientsAddress' => $recipientsAddress,
  573. 'mailItems' => $mailString,
  574. 'mailItemsJson' => json_encode ( $mailList )
  575. );
  576. }
  577. $invoice->setInvoiceByCondition ( $item );
  578. $item = array (
  579. 'date' => date ( "Y-m-d H:i:s" ),
  580. 'operation' => "重新提交审批",
  581. 'status' => 1,
  582. 'img' => $this->staff [0] ['avatar'],
  583. 'username' => $this->staff [0] ['username'],
  584. 'uid' => $this->staff [0] ['sid'],
  585. 'category' => $this->staff [0] ['category'],
  586. 'iid' => $iid
  587. );
  588. $invoiceOperationLog->setInvoiceOperationLog ( $item );
  589. }
  590. return "/invoice";
  591. }
  592. /**
  593. * 培训班
  594. */
  595. function invoiceTraining() {
  596. Doo::loadModel ( 'L_category' );
  597. $lCategory = new L_category ();
  598. Doo::loadModel ( 'invoiceTraining' );
  599. $invoiceTraining = new invoiceTraining ();
  600. $itTodoList = $invoiceTraining->getInvoiceTrainingByTodo ( '', $this->staff [0] ['cid'], $this->staff [0] ['sid']);
  601. $itedList = $invoiceTraining->getInvoiceTrainingByStatus ( 2, '', $this->staff [0] ['cid'], $this->staff [0] ['sid'] );
  602. $category = $lCategory->getCategory ();
  603. $itid = array ();
  604. foreach ( $itTodoList as $value ) {
  605. array_push ( $itid, $value ['itid'] );
  606. }
  607. foreach ( $itedList as $value ) {
  608. array_push ( $itid, $value ['itid'] );
  609. }
  610. $itid = implode ( ',', $itid );
  611. $this->data ['itStatist'] = $invoiceTraining->getInvoiceTrainStatistics ( $itid );
  612. // print_r($itTodoList);
  613. $this->data ['trainCount'] = count ( $itTodoList ) + count ( $itedList );
  614. $this->data ['itTodoList'] = $itTodoList;
  615. $this->data ['itedList'] = $itedList;
  616. $this->data ['category'] = $category;
  617. $this->data ['memu'] = "invoice";
  618. $this->data ['staff'] = $this->staff;
  619. $this->data ['receiptMemu'] = 'invoiceTraining';
  620. $this->render ( "/admin/invoiceTraining", $this->data );
  621. }
  622. /**
  623. * 创建培训班
  624. */
  625. function invoiceTrainingAdd() {
  626. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  627. $trainName = $this->get_args ( 'trainName' ) ? $this->get_args ( 'trainName' ) : "";
  628. $trainDate = $this->get_args ( 'trainDate' ) ? $this->get_args ( 'trainDate' ) : "";
  629. if (empty ( $this->staff [0] ))
  630. die ( 'illegal request' );
  631. if (! empty ( $cid ) && ! empty ( $trainName ) && ! empty ( $trainDate )) {
  632. Doo::loadModel ( 'invoiceTraining' );
  633. $invoiceTraining = new invoiceTraining ();
  634. Doo::loadModel ( 'invoice' );
  635. $invoice = new invoice ();
  636. Doo::loadModel ( 'L_category' );
  637. $lCategory = new L_category ();
  638. Doo::loadModel ( 'invoiceManage' );
  639. $invoiceManage = new invoiceManage ();
  640. Doo::loadModel ( 'invoiceOperationLog' );
  641. $invoiceOperationLog = new invoiceOperationLog ();
  642. $item = array (
  643. 'cid' => $cid,
  644. 'trainName' => $trainName,
  645. 'trainDate' => $trainDate,
  646. 'creator' => $this->staff [0] ['sid'],
  647. 'creatorDate' => date ( "Y-m-d H:i:s" )
  648. );
  649. $itid = $invoiceTraining->addInvoiceTraining ( $item );
  650. }
  651. return "/invoiceTraining";
  652. }
  653. /**
  654. * 删除培训班
  655. */
  656. function invoiceTrainingDelDo() {
  657. $itid = $this->get_args ( 'trainingKey' ) ? $this->get_args ( 'trainingKey' ) : "";
  658. if (! empty ( $itid )) {
  659. Doo::loadModel ( 'invoiceTraining' );
  660. $invoiceTraining = new invoiceTraining ();
  661. $invoiceTraining->delInvoiceTrainingByItid ( $itid );
  662. }
  663. return "/invoiceTraining";
  664. }
  665. /**
  666. * 培训班详情
  667. */
  668. function invoiceTrainingDetail() {
  669. $trainStatus = $this->get_args ( 'trainStatus' ) ? $this->get_args ( 'trainStatus' ) : "ALL";
  670. $itid = isset ( $this->params ['trainingKey'] ) ? $this->params ['trainingKey'] : "";
  671. Doo::loadModel ( 'invoiceTraining' );
  672. $invoiceTraining = new invoiceTraining ();
  673. Doo::loadModel ( 'invoiceStore' );
  674. $invoiceStore = new invoiceStore ();
  675. if (empty ( $itid ))
  676. die ( 'illegal request' );
  677. $detail = $invoiceTraining->getInvoiceTrainingByItid ( $itid );
  678. $isList = $invoiceStore->getinvoiceStoreByItid ( $itid );
  679. // print_r($isList);
  680. $trainlist = array ();
  681. foreach ( $isList as $key => $value ) {
  682. $irDetail = array ();
  683. if ($value ['apStatus'] == 1) {
  684. array_push ( $irDetail, '<input disabled type="checkbox">' );
  685. array_push ( $irDetail, '' );
  686. } else {
  687. array_push ( $irDetail, '<input type="checkbox" name="isBox" value="' . $value ['storeKey'] . '" >' );
  688. array_push ( $irDetail, '<a href="/invoiceStoreEdit/' . $value ['storeKey'] . '.html">编辑</a>
  689. <a href="#confirm" onclick="invoiceStoreApproval(\'' . $value ['storeKey'] . '\')" data-toggle="modal">提交审批</a>
  690. <a href="#del" node-iStore="del" data-key="' . $value ['storeKey'] . '" onclick="invoiceStoreDel(\'' . $value ['storeKey'] . '\')" data-toggle="modal" class="colRed">移除</a>' );
  691. }
  692. array_push ( $irDetail, $value ['invoiceSerial'] );
  693. if ($value ['invoiceType'] == 1)
  694. array_push ( $irDetail, $value ['invoiceCompany'] );
  695. else
  696. array_push ( $irDetail, $value ['invoiceTitle'] );
  697. array_push ( $irDetail, $value ['TIN'] );
  698. array_push ( $irDetail, $value ['address'] . $value ['phone'] );
  699. array_push ( $irDetail, $value ['bank'] . $value ['bankAccount'] );
  700. array_push ( $irDetail, $value ['invoiceElement'] );
  701. array_push ( $irDetail, $value ['invoiceQuantity'] );
  702. array_push ( $irDetail, $value ['invoiceUnitPrice'] );
  703. if ($value ['invoiceType'] == 1)
  704. array_push ( $irDetail, '¥' . $value ['invoicePrice'] . '<sup>专</sup>' );
  705. else
  706. array_push ( $irDetail, '¥' . $value ['invoicePrice'] );
  707. array_push ( $irDetail, $value ['remark'] );
  708. if (empty ( $value ['mailItems'] ))
  709. array_push ( $irDetail, '<a href="#confirm-erro" onclick="invoiceStoreMail(\'' . $value ['storeKey'] . '\')" data-toggle="modal">设置邮寄物品</a>' );
  710. else
  711. array_push ( $irDetail, $value ['mailItems'] );
  712. array_push ( $irDetail, $value ['recipientsAddress'] . $value ['recipients'] . $value ['recipientsPhone'] );
  713. if ($value ['status'] == 1)
  714. array_push ( $irDetail, '审批中' );
  715. elseif ($value ['status'] == 2 && $value ['printStatus'] == 1)
  716. array_push ( $irDetail, '已出票' );
  717. elseif ($value ['status'] == 2 && $value ['printStatus'] == 1 && $value ['printStatus'] != 'irid' && ($value ['untreadStatus'] == 3 || $value ['untreadStatus'] == 0))
  718. array_push ( $irDetail, '已入账' );
  719. else
  720. array_push ( $irDetail, '' );
  721. array_push ( $irDetail, $value ['invoiceNo'] );
  722. array_push ( $irDetail, $value ['printTime'] );
  723. $html = '';
  724. foreach ( $value ['invoiceReceivables'] as $value ) {
  725. $html .= '&nbsp;<a href="#billing" node-invoice="INFO" data-type="receivables" data-iskey="' . $value [2] . '" data-toggle="modal">' . $value [1] . '</a>';
  726. }
  727. array_push ( $irDetail, $html );
  728. array_push ( $trainlist, $irDetail );
  729. }
  730. $trainlistJson = json_encode ( $trainlist );
  731. if (empty ( $detail ))
  732. die ( 'illegal request' );
  733. $this->data ['trainStatus'] = $trainStatus;
  734. $this->data ['itid'] = $itid;
  735. $this->data ['trainlistJson'] = $trainlistJson;
  736. $this->data ['iTrainDetail'] = $detail;
  737. $this->data ['memu'] = "invoice";
  738. $this->data ['staff'] = $this->staff;
  739. $this->data ['receiptMemu'] = 'invoiceTraining';
  740. $this->render ( "/admin/invoiceTrainingDetail", $this->data );
  741. }
  742. /**
  743. * 上传培训班发票
  744. * @return string
  745. */
  746. function invoiceTrainingUpload() {
  747. $POST_MAX_SIZE = ini_get ( 'post_max_size' );
  748. $unit = strtoupper ( substr ( $POST_MAX_SIZE, - 1 ) );
  749. $multiplier = ($unit == 'M' ? 1048576 : ($unit == 'K' ? 1024 : ($unit == 'G' ? 1073741824 : 1)));
  750. if (( int ) $_SERVER ['CONTENT_LENGTH'] > $multiplier * ( int ) $POST_MAX_SIZE && $POST_MAX_SIZE) {
  751. header ( "HTTP/1.1 500 Internal Server Error" );
  752. echo "POST exceeded maximum allowed size.";
  753. exit ( 0 );
  754. }
  755. // Settings
  756. $save_path = DOO::conf ()->SITE_PATH . "upload/invoiceTraining/"; // The path were we will save the file (getcwd() may not be reliable and should be tested in your environment)
  757. $upload_name = "Filedata";
  758. $max_file_size_in_bytes = 2147483647; // 2GB in bytes
  759. $extension_whitelist = array (
  760. "doc",
  761. "txt",
  762. "jpg",
  763. "gif",
  764. "png"
  765. ); // Allowed file extensions
  766. $valid_chars_regex = '.A-Z0-9_ !@#$%^&()+={}\[\]\',~`-'; // Characters allowed in the file name (in a Regular Expression format)
  767. // Other variables
  768. $MAX_FILENAME_LENGTH = 260;
  769. $file_name = "";
  770. $file_extension = "";
  771. $uploadErrors = array (
  772. 0 => "文件上传成功",
  773. 1 => "上传的文件超过了 php.ini 文件中的 upload_max_filesize directive 里的设置",
  774. 2 => "上传的文件超过了 HTML form 文件中的 MAX_FILE_SIZE directive 里的设置",
  775. 3 => "上传的文件仅为部分文件",
  776. 4 => "没有文件上传",
  777. 6 => "缺少临时文件夹"
  778. );
  779. $nk = time ();
  780. $file_name = $nk . '.' . $this->_GetFileEXT ( $_FILES [$upload_name] ['name'] ); // preg_replace('/[^'.$valid_chars_regex.']|\.+$/i', "", basename($_FILES[$upload_name]['name']));
  781. if (! @move_uploaded_file ( $_FILES [$upload_name] ["tmp_name"], $save_path . $file_name )) {
  782. echo "文件无法保存.";
  783. exit ( 0 );
  784. }
  785. // Return output to the browser (only supported by SWFUpload for Flash Player 9)
  786. echo json_encode ( array (
  787. 'filename' => $file_name,
  788. 'id' => $nk
  789. ) );
  790. exit ( 0 );
  791. }
  792. /**
  793. * 导入发票临时仓库
  794. */
  795. function invoiceStoreImport() {
  796. $trainingKey = $this->get_args ( 'trainingKey' ) ? $this->get_args ( 'trainingKey' ) : "";
  797. $path = $this->get_args ( 'trainName' ) ? $this->get_args ( 'trainName' ) : "";
  798. if ($path != "" && ! empty ( $trainingKey )) {
  799. Doo::loadModel ( 'invoiceStore' );
  800. Doo::loadModel ( 'staff' );
  801. $staff = new staff ();
  802. Doo::loadModel ( 'invoiceTraining' );
  803. $invoiceTraining = new invoiceTraining ();
  804. Doo::loadClass ( 'XDeode' );
  805. $XDeode = new XDeode ( 5 );
  806. $itid = $XDeode->decode ( $trainingKey );
  807. $exlArray = $this->_format_excel_to_array ( DOO::conf ()->SITE_PATH . "upload/invoiceTraining/" . $path, 'invoiceTrain' );
  808. $userName=$this->staff [0] ['userName'];
  809. $sDetail = $staff->getStaffByName ( $userName );
  810. // 可以优化
  811. foreach ( $exlArray as $key => $value ) {
  812. // 开票
  813. $invoice = new invoiceStore ();
  814. $invoice->trainId = $itid;
  815. $invoice->invoiceType = 0;
  816. if ($value ['invoiceType'] == '专')
  817. $invoice->invoiceType = 1;
  818. $invoice->invoiceQuantity = $value ['invoiceQuantity'];
  819. $invoice->invoiceUnitPrice = $value ['invoiceUnitPrice'];
  820. $invoice->invoicePrice = $value ['invoiceQuantity'] * $value ['invoiceUnitPrice'];
  821. $invoice->invoiceTitle = $value ['invoiceTitle'];
  822. if ($value ['invoiceType'] == '专')
  823. $invoice->invoiceCompany = $value ['invoiceTitle'];
  824. $invoice->userName =$userName;
  825. $invoice->sid = $sDetail ['sid'];
  826. $invoice->cid = $sDetail ['cid'];
  827. $invoice->categoryName = $sDetail ['category'];
  828. $invoice->invoiceElement = $value ['invoiceElement'];
  829. $invoice->remark = $value ['remark'];
  830. $invoice->date = $value ['date'];
  831. $invoice->printTime = $value ['date'];
  832. $invoice->ipSource = 1;
  833. $invoice->printStatus = 1;
  834. $invoice->status = 2;
  835. $invoice->postStatus = 1;
  836. $invoice->untreadStatus = 0;
  837. $invoice->invoiceSerial = "#F" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  838. $invoice->TIN = $value ['TIN'];
  839. $invoice->address = $value ['address'];
  840. $invoice->phone = $value ['phone'];
  841. $invoice->bank = $value ['bank'];
  842. $invoice->bankAccount = $value ['bankAccount'];
  843. $invoice->recipientsAddress = $value ['recipientsAddress'];
  844. $invoice->recipients = $value ['recipients'];
  845. $invoice->recipientsPhone = $value ['recipientsPhone'];
  846. $iid = $invoice->insert ();
  847. }
  848. // 加入发票总数量
  849. $item = array (
  850. 'itid' => $itid,
  851. 'invoiceTotal' => count ( $exlArray )
  852. );
  853. $invoiceTraining->setInvoiceTrainByCondition ( $item );
  854. return '/invoiceTrainingDetail/' . $trainingKey . ".html";
  855. }
  856. echo 'no file';
  857. }
  858. /**
  859. * 编辑仓库里的发票
  860. */
  861. function invoiceStoreEdit() {
  862. Doo::loadClass ( 'XDeode' );
  863. $XDeode = new XDeode ( 5 );
  864. $iid = isset ( $this->params ['storeKey'] ) ? $this->params ['storeKey'] : "";
  865. $iid = $XDeode->decode ( $iid );
  866. if (! is_numeric ( $iid ))
  867. die ( 'illegal request' );
  868. Doo::loadModel ( 'invoiceStore' );
  869. $invoiceStore = new invoiceStore ();
  870. $invoiceDetail = $invoiceStore->getInvoiceStoreByIsid ( $iid );
  871. // print_r($invoiceDetail);
  872. $invoiceDetail ['mailItemsJson'] = json_decode ( $invoiceDetail ['mailItemsJson'], true );
  873. $this->data ['invoiceDetail'] = $invoiceDetail;
  874. $this->data ['memu'] = "invoice";
  875. $this->data ['staff'] = $this->staff;
  876. $this->data ['receiptMemu'] = 'invoiceTraining';
  877. $this->render ( "/admin/invoiceStoreEdit", $this->data );
  878. }
  879. function invoiceStoreEditDo() {
  880. $storeKey = $this->get_args ( 'storeKey' ) ? $this->get_args ( 'storeKey' ) : '';
  881. $trainKey = $this->get_args ( 'trainKey' ) ? $this->get_args ( 'trainKey' ) : '';
  882. Doo::loadModel ( 'invoiceStore' );
  883. $invoice = new invoiceStore ();
  884. Doo::loadClass ( 'XDeode' );
  885. $XDeode = new XDeode ( 5 );
  886. $iid = $XDeode->decode ( $storeKey );
  887. if (! empty ( $iid ) && ! is_numeric ( $iid ))
  888. die ( 'illegal request' );
  889. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  890. $invoiceType = $this->get_args ( 'invoiceType' ) && is_numeric ( $this->get_args ( 'invoiceType' ) ) ? $this->get_args ( 'invoiceType' ) : 0;
  891. $doPost = $this->get_args ( 'doPost' ) && is_numeric ( $this->get_args ( 'doPost' ) ) ? $this->get_args ( 'doPost' ) : 0;
  892. $invoicePrice = $this->get_args ( 'invoicePrice' ) ? $this->get_args ( 'invoicePrice' ) : "";
  893. $invoiceQuantity = $this->get_args ( 'invoiceQuantity' ) && is_numeric ( $this->get_args ( 'invoiceQuantity' ) ) ? $this->get_args ( 'invoiceQuantity' ) : 0;
  894. $invoiceUnitPrice = $this->get_args ( 'invoiceUnitPrice' ) && is_numeric ( $this->get_args ( 'invoiceUnitPrice' ) ) ? $this->get_args ( 'invoiceUnitPrice' ) : 0;
  895. $invoiceElement = $this->get_args ( 'invoiceElement' ) ? $this->get_args ( 'invoiceElement' ) : "";
  896. $invoiceTitle = $this->get_args ( 'invoiceTitle' ) ? $this->get_args ( 'invoiceTitle' ) : "";
  897. $invoiceCompany = $this->get_args ( 'invoiceCompany' ) ? $this->get_args ( 'invoiceCompany' ) : "";
  898. $TIN = $this->get_args ( 'TIN' ) ? $this->get_args ( 'TIN' ) : "";
  899. $address = $this->get_args ( 'address' ) ? $this->get_args ( 'address' ) : "";
  900. $phone = $this->get_args ( 'phone' ) ? $this->get_args ( 'phone' ) : "";
  901. $bank = $this->get_args ( 'bank' ) ? $this->get_args ( 'bank' ) : "";
  902. $bankAccount = $this->get_args ( 'bankAccount' ) ? $this->get_args ( 'bankAccount' ) : "";
  903. $recipients = $this->get_args ( 'recipients' ) ? $this->get_args ( 'recipients' ) : "";
  904. $recipientsPhone = $this->get_args ( 'recipientsPhone' ) ? $this->get_args ( 'recipientsPhone' ) : "";
  905. $recipientsAddress = $this->get_args ( 'recipientsAddress' ) ? $this->get_args ( 'recipientsAddress' ) : "";
  906. $mailItems = $this->get_args ( 'mailItems' ) ? $this->get_args ( 'mailItems' ) : "";
  907. $remark = $this->get_args ( 'remark' ) ? $this->get_args ( 'remark' ) : "";
  908. $TINT = $this->get_args ( 'TINT' ) ? $this->get_args ( 'TINT' ) : "";
  909. $addressT = $this->get_args ( 'addressT' ) ? $this->get_args ( 'addressT' ) : "";
  910. $phoneT = $this->get_args ( 'phoneT' ) ? $this->get_args ( 'phoneT' ) : "";
  911. $bankT = $this->get_args ( 'bankT' ) ? $this->get_args ( 'bankT' ) : "";
  912. $bankAccountT = $this->get_args ( 'bankAccountT' ) ? $this->get_args ( 'bankAccountT' ) : "";
  913. $softLock = $this->get_args ( 'softLock' ) ? $this->get_args ( 'softLock' ) : 0;
  914. $softLockNum = $this->get_args ( 'softLockNum' ) ? $this->get_args ( 'softLockNum' ) : 0;
  915. $contract = $this->get_args ( 'contract' ) ? $this->get_args ( 'contract' ) : 0;
  916. $contractNum = $this->get_args ( 'contractNum' ) ? $this->get_args ( 'contractNum' ) : 0;
  917. $instructions = $this->get_args ( 'instructions' ) ? $this->get_args ( 'instructions' ) : 0;
  918. $instructionsNum = $this->get_args ( 'instructionsNum' ) ? $this->get_args ( 'instructionsNum' ) : 0;
  919. $remittance = $this->get_args ( 'remittance' ) ? $this->get_args ( 'remittance' ) : 0;
  920. if (! empty ( $cid ) && ! empty ( $invoiceQuantity ) && ! empty ( $invoiceUnitPrice ) && ! empty ( $invoiceElement ) && ! empty ( $iid )) {
  921. $cid = explode ( ':', $cid );
  922. $invoicePrice = $invoiceQuantity * $invoiceUnitPrice;
  923. $item = array (
  924. 'isid' => $iid,
  925. 'cid' => $cid [0],
  926. 'categoryName' => $cid [1],
  927. 'invoiceElement' => $invoiceElement,
  928. 'invoiceQuantity' => $invoiceQuantity,
  929. 'invoiceUnitPrice' => $invoiceUnitPrice,
  930. 'invoicePrice' => $invoicePrice,
  931. 'invoiceType' => $invoiceType,
  932. 'doPost' => $doPost,
  933. 'status' => 1,
  934. 'updateTime' => date ( "Y-m-d H:i:s" ),
  935. 'remark' => $remark
  936. );
  937. if ($invoiceType == 0)
  938. $item += array (
  939. 'invoiceTitle' => $invoiceTitle,
  940. 'TIN' => $TINT,
  941. 'address' => $addressT,
  942. 'phone' => $phoneT,
  943. 'bank' => $bankT,
  944. 'bankAccount' => $bankAccountT
  945. );
  946. else {
  947. $item += array (
  948. 'invoiceCompany' => $invoiceCompany,
  949. 'TIN' => $TIN,
  950. 'address' => $address,
  951. 'phone' => $phone,
  952. 'bank' => $bank,
  953. 'bankAccount' => $bankAccount
  954. );
  955. }
  956. if ($doPost == 1) {
  957. $mailList = array (
  958. 'invoice' => 1,
  959. 'mailItems' => $mailItems
  960. );
  961. if (! empty ( $softLock ))
  962. $mailList += array (
  963. 'softLock' => $softLockNum
  964. );
  965. else
  966. $mailList += array (
  967. 'softLock' => '0'
  968. );
  969. if (! empty ( $contract ))
  970. $mailList += array (
  971. 'contract' => $contractNum
  972. );
  973. else
  974. $mailList += array (
  975. 'contract' => '0'
  976. );
  977. if (! empty ( $instructions ))
  978. $mailList += array (
  979. 'instructions' => $instructionsNum
  980. );
  981. else
  982. $mailList += array (
  983. 'instructions' => '0'
  984. );
  985. if (! empty ( $remittance ))
  986. $mailList += array (
  987. 'remittance' => $remittance
  988. );
  989. else
  990. $mailList += array (
  991. 'remittance' => ''
  992. );
  993. $mailString = '发票x1,备注:' . $mailItems;
  994. if (! empty ( $softLock ))
  995. $mailString .= ',软件锁x' . $softLockNum;
  996. if (! empty ( $contract ))
  997. $mailString .= ',合同x' . $contractNum;
  998. if (! empty ( $instructions ))
  999. $mailString .= ',说明书x' . $instructionsNum;
  1000. if (! empty ( $remittance ))
  1001. $mailString .= ',汇款账号单';
  1002. $item += array (
  1003. 'recipients' => $recipients,
  1004. 'recipientsPhone' => $recipientsPhone,
  1005. 'recipientsAddress' => $recipientsAddress,
  1006. 'mailItems' => $mailString,
  1007. 'mailItemsJson' => json_encode ( $mailList )
  1008. );
  1009. }
  1010. $invoice->setInvoiceStoreByCondition ( $item );
  1011. }
  1012. return "/invoiceTrainingDetail/" . $trainKey . ".html";
  1013. }
  1014. /**
  1015. *
  1016. * @return string
  1017. */
  1018. function invoiceStoreDelete() {
  1019. Doo::loadClass ( 'XDeode' );
  1020. $XDeode = new XDeode ( 5 );
  1021. $trainKey = $this->get_args ( 'trainKey' ) ? $this->get_args ( 'trainKey' ) : '';
  1022. $iStoreKey = $this->get_args ( 'iStoreKey' ) ? $this->get_args ( 'iStoreKey' ) : 0;
  1023. $isid = $XDeode->decode ( $iStoreKey );
  1024. $itid = $XDeode->decode ( $trainKey );
  1025. if (! is_numeric ( $isid ))
  1026. die ( 'illegal request' );
  1027. Doo::loadModel ( 'invoiceStore' );
  1028. $invoiceStore = new invoiceStore ();
  1029. $invoiceStore->delete ( array (
  1030. 'where' => 'isid=' . $isid,
  1031. 'limit' => 1
  1032. ) );
  1033. Doo::loadModel ( 'invoiceTraining' );
  1034. $invoiceTraining = new invoiceTraining ();
  1035. $itDetail = $invoiceTraining->getInvoiceTrainingByItid ( $trainKey );
  1036. $item = array (
  1037. 'itid' => $itid,
  1038. 'invoiceTotal' => $itDetail ['invoiceTotal'] - 1
  1039. );
  1040. $invoiceTraining->setInvoiceTrainByCondition ( $item );
  1041. return "/invoiceTrainingDetail/" . $trainKey . ".html";
  1042. }
  1043. /**
  1044. * 批量删除库里发票
  1045. */
  1046. function invoiceStoreBatchDelete() {
  1047. Doo::loadClass ( 'XDeode' );
  1048. $XDeode = new XDeode ( 5 );
  1049. $trainKey = $this->get_args ( 'trainKey' ) ? $this->get_args ( 'trainKey' ) : '';
  1050. $storeKey = $this->get_args ( 'storeKey' ) ? $this->get_args ( 'storeKey' ) : '';
  1051. $tid = $XDeode->decode ( $trainKey );
  1052. if (! is_numeric ( $tid ) && ! empty ( $storeKey ))
  1053. die ( 'illegal request' );
  1054. Doo::loadModel ( 'invoiceStore' );
  1055. $isidKeyList = explode ( ',', $storeKey );
  1056. $isidList = array ();
  1057. foreach ( $isidKeyList as $value ) {
  1058. $isid = $XDeode->decode ( $value );
  1059. if (! empty ( $isid ) && is_numeric ( $isid ))
  1060. array_push ( $isidList, $isid );
  1061. }
  1062. $isidString = implode ( ',', $isidList );
  1063. $invoiceStore = new invoiceStore ();
  1064. $isList = $invoiceStore->getInvoiceStoreInIsid ( $isidString, 'isid,apStatus' );
  1065. $isidList = array ();
  1066. foreach ( $isList as $key => $value ) {
  1067. if ($value ['apStatus'] == 0)
  1068. array_push ( $isidList, $value ['isid'] );
  1069. }
  1070. $isidString = implode ( ',', $isidList );
  1071. // print_r($isList);
  1072. // echo $isidString;
  1073. $invoiceStore = new invoiceStore ();
  1074. $invoiceStore->delete ( array (
  1075. 'where' => "isid in ( " . $isidString . ")",
  1076. 'asArray' => TRUE
  1077. ) );
  1078. Doo::loadModel ( 'invoiceTraining' );
  1079. $invoiceTraining = new invoiceTraining ();
  1080. $itDetail = $invoiceTraining->getInvoiceTrainingByItid ( $trainKey );
  1081. $item = array (
  1082. 'itid' => $tid,
  1083. 'invoiceTotal' => $itDetail ['invoiceTotal'] - count ( $isidList )
  1084. );
  1085. $invoiceTraining->setInvoiceTrainByCondition ( $item );
  1086. // echo $tid;
  1087. // echo $storeKey;
  1088. return "/invoiceTrainingDetail/" . $trainKey . ".html";
  1089. }
  1090. /**
  1091. * 仓库发票提交审批
  1092. * @return string
  1093. */
  1094. function invoiceStoreApproval() {
  1095. Doo::loadClass ( 'XDeode' );
  1096. $XDeode = new XDeode ( 5 );
  1097. $trainKey = $this->get_args ( 'trainKey' ) ? $this->get_args ( 'trainKey' ) : '';
  1098. $iStoreKey = $this->get_args ( 'storeKey' ) ? $this->get_args ( 'storeKey' ) : 0;
  1099. $isid = $XDeode->decode ( $iStoreKey );
  1100. $trainId = $XDeode->decode ( $trainKey );
  1101. if (! is_numeric ( $isid ))
  1102. die ( 'illegal request' );
  1103. Doo::loadModel ( 'invoiceStore' );
  1104. Doo::loadModel ( 'invoice' );
  1105. $invoice = new invoice ();
  1106. // 拷贝插入一条发票数据
  1107. $invoiceStore = new invoiceStore ();
  1108. $iid = $invoiceStore->setInvoiceStoreToApproval ( $isid );
  1109. $invoiceStore = new invoiceStore ();
  1110. $item = array (
  1111. 'isid' => $isid,
  1112. 'iid' => $iid,
  1113. 'apStatus' => 1
  1114. );
  1115. $invoiceStore->setInvoiceStoreByCondition ( $item );
  1116. Doo::loadModel ( 'invoiceManage' );
  1117. $invoiceManage = new invoiceManage ();
  1118. Doo::loadModel ( 'invoiceOperationLog' );
  1119. $invoiceOperationLog = new invoiceOperationLog ();
  1120. $invoiceManageList = $invoiceManage->getInvoiceByAll ();
  1121. $invoiceManageDetail = $invoiceManage->getInvoiceByMold ( "发票审批" );
  1122. $moldManage = array ();
  1123. foreach ( $invoiceManageList as $key => $value ) {
  1124. if ($value ['mold'] == '发票打印')
  1125. $moldManage [$value ['mold']] = $value ['staffList'];
  1126. elseif ($value ['mold'] == '发票邮寄')
  1127. $moldManage [$value ['mold']] = $value ['staffList'];
  1128. elseif ($value ['mold'] == '发票退票')
  1129. $moldManage [$value ['mold']] = $value ['staffList'];
  1130. }
  1131. $pendingApprovalsSid = current ( $invoiceManageDetail ['staffList'] ) [0];
  1132. $item = array (
  1133. 'iid' => $iid,
  1134. 'invoiceSerial' => "#F" . date ( "Ymd" ) . mt_rand ( 1000, 9999 ),
  1135. 'date' => date ( "Y-m-d H:i:s" ),
  1136. 'status' => 1,
  1137. 'updateTime' => date ( "Y-m-d H:i:s" ),
  1138. 'trainId' => $trainId,
  1139. 'invoiceManage' => $invoiceManageDetail ['staff'],
  1140. 'moldManage' => json_encode ( $moldManage ),
  1141. 'pendingApprovals' => $pendingApprovalsSid
  1142. );
  1143. $invoice->setInvoiceByCondition ( $item );
  1144. Doo::loadModel ( 'invoiceTraining' );
  1145. $invoiceTraining = new invoiceTraining ();
  1146. $item = array (
  1147. 'itid' => $trainId,
  1148. 'submitStatus' => 1
  1149. );
  1150. $invoiceTraining->setInvoiceTrainByCondition ( $item );
  1151. $item = array (
  1152. 'date' => date ( "Y-m-d H:i:s" ),
  1153. 'operation' => "创建",
  1154. 'status' => 1,
  1155. 'img' => $this->staff [0] ['avatar'],
  1156. 'username' => $this->staff [0] ['username'],
  1157. 'uid' => $this->staff [0] ['sid'],
  1158. 'category' => $this->staff [0] ['category'],
  1159. 'iid' => $iid
  1160. );
  1161. $invoiceOperationLog->setInvoiceOperationLog ( $item );
  1162. $item = array (
  1163. 'date' => date ( "Y-m-d H:i:s" ),
  1164. 'operation' => "提交审批",
  1165. 'status' => 1,
  1166. 'img' => $this->staff [0] ['avatar'],
  1167. 'username' => $this->staff [0] ['username'],
  1168. 'uid' => $this->staff [0] ['sid'],
  1169. 'category' => $this->staff [0] ['category'],
  1170. 'iid' => $iid
  1171. );
  1172. $invoiceOperationLog->setInvoiceOperationLog ( $item );
  1173. Doo::loadModel ( 'staff' );
  1174. $staff = new staff ();
  1175. $username2 = $staff->getOne ( array (
  1176. 'select' => 'wxid',
  1177. 'where' => 'sid=' . $pendingApprovalsSid,
  1178. 'asArray' => TRUE
  1179. ) );
  1180. // 发送微信审批通知
  1181. $title2 = '[通知]用户提交了一条开票申请,快到“我的发票”中查看,给用户确认审批。';
  1182. $this->msgSend ( '', $title2, '', $username2 ['wxid'], $pendingApprovalsSid, 'approval' );
  1183. return "/invoiceTrainingDetail/" . $trainKey . ".html";
  1184. }
  1185. /**
  1186. * 批量提交发票
  1187. * @return string
  1188. */
  1189. function invoiceStoreBatchApproval() {
  1190. Doo::loadClass ( 'XDeode' );
  1191. $XDeode = new XDeode ( 5 );
  1192. $trainKey = $this->get_args ( 'trainKey' ) ? $this->get_args ( 'trainKey' ) : '';
  1193. $storeKey = $this->get_args ( 'storeKey' ) ? $this->get_args ( 'storeKey' ) : 0;
  1194. $trainId = $XDeode->decode ( $trainKey );
  1195. $isidKeyList = explode ( ',', $storeKey );
  1196. $isidList = array ();
  1197. foreach ( $isidKeyList as $value ) {
  1198. $isid = $XDeode->decode ( $value );
  1199. if (! empty ( $isid ) && is_numeric ( $isid ))
  1200. array_push ( $isidList, $isid );
  1201. }
  1202. $isidString = implode ( ',', $isidList );
  1203. if (! is_numeric ( $trainId ))
  1204. die ( 'illegal request' );
  1205. Doo::loadModel ( 'invoiceStore' );
  1206. Doo::loadModel ( 'invoice' );
  1207. // 判断哪些已经加入审批过
  1208. // 拷贝插入一条发票数据
  1209. $invoiceStore = new invoiceStore ();
  1210. $invoiceStore->setInvoiceStoreBatchToApproval ( $isidString );
  1211. $invoiceStore = new invoiceStore ();
  1212. $item = array (
  1213. 'apStatus' => 1
  1214. );
  1215. $invoiceStore->setInvoiceStoreByCondition ( $item, $isidString );
  1216. // 获得正式发票ID
  1217. $invoice = new invoice ();
  1218. $iidList = $invoice->getInvoiceByIstoreid ( $isidString, 'iid,isid' );
  1219. $sqlList = array ();
  1220. $iidString = '';
  1221. $iida = array ();
  1222. foreach ( $iidList as $key => $value ) {
  1223. $sqlList [$value ['isid']] = $value ['iid'];
  1224. array_push ( $iida, $value ['iid'] );
  1225. }
  1226. $iidString = implode ( ',', $iida );
  1227. $ids = implode ( ',', array_keys ( $sqlList ) );
  1228. $sql = "UPDATE CLD_invoiceStore SET iid = CASE isid ";
  1229. foreach ( $sqlList as $id => $ordinal ) {
  1230. $sql .= sprintf ( "WHEN %d THEN %d ", $id, $ordinal );
  1231. }
  1232. $sql .= "END WHERE isid IN ($ids)";
  1233. $invoiceStore = new invoiceStore ();
  1234. $invoiceStore->UpdateBatchInvoiceStore ( $sql );
  1235. Doo::loadModel ( 'invoiceManage' );
  1236. $invoiceManage = new invoiceManage ();
  1237. $invoiceManageList = $invoiceManage->getInvoiceByAll ();
  1238. $invoiceManageDetail = $invoiceManage->getInvoiceByMold ( "发票审批" );
  1239. $moldManage = array ();
  1240. foreach ( $invoiceManageList as $key => $value ) {
  1241. if ($value ['mold'] == '发票打印')
  1242. $moldManage [$value ['mold']] = $value ['staffList'];
  1243. elseif ($value ['mold'] == '发票邮寄')
  1244. $moldManage [$value ['mold']] = $value ['staffList'];
  1245. elseif ($value ['mold'] == '发票退票')
  1246. $moldManage [$value ['mold']] = $value ['staffList'];
  1247. }
  1248. $pendingApprovalsSid = current ( $invoiceManageDetail ['staffList'] ) [0];
  1249. // 批量更新发票信息
  1250. $item = array (
  1251. 'date' => date ( "Y-m-d H:i:s" ),
  1252. 'status' => 1,
  1253. 'updateTime' => date ( "Y-m-d H:i:s" ),
  1254. 'trainId' => $trainId,
  1255. 'invoiceManage' => $invoiceManageDetail ['staff'],
  1256. 'moldManage' => json_encode ( $moldManage ),
  1257. 'pendingApprovals' => $pendingApprovalsSid
  1258. );
  1259. $invoice = new invoice ();
  1260. $invoice->BatchInvoiceByCondition ( $item, $iidString );
  1261. // 批量更新发票序列号
  1262. $sqlList = array ();
  1263. foreach ( $iida as $value ) {
  1264. $sqlList [$value] = "#F" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  1265. }
  1266. $ids = implode ( ',', array_keys ( $sqlList ) );
  1267. $sql = "UPDATE CLD_invoice SET invoiceSerial = CASE iid ";
  1268. foreach ( $sqlList as $id => $ordinal ) {
  1269. $sql .= sprintf ( "WHEN %d THEN '%s' ", $id, $ordinal );
  1270. }
  1271. $sql .= "END WHERE iid IN ($ids)";
  1272. $invoiceStore = new invoiceStore ();
  1273. $invoiceStore->UpdateBatchInvoiceStore ( $sql );
  1274. // 批量生产操作日志
  1275. Doo::loadModel ( 'invoiceOperationLog' );
  1276. $sqlList = array ();
  1277. foreach ( $iida as $key => $value ) {
  1278. $sql = '("' . date ( "Y-m-d H:i:s" ) . '","创建","1","' . $this->staff [0] ['avatar'] . '","' . $this->staff [0] ['username'] . '","' . $this->staff [0] ['sid'] . '","' . $this->staff [0] ['category'] . '","' . $value . '"),
  1279. ("' . date ( "Y-m-d H:i:s" ) . '","提交审批","1","' . $this->staff [0] ['avatar'] . '","' . $this->staff [0] ['username'] . '","' . $this->staff [0] ['sid'] . '","' . $this->staff [0] ['category'] . '","' . $value . '") ';
  1280. array_push ( $sqlList, $sql );
  1281. }
  1282. $iolSql = implode ( ',', $sqlList );
  1283. $sql = "INSERT INTO `CLD_invoiceOperationLog` (`date`, `operation`, `status`, `img`, `username`, `uid`, `category`, `iid`) VALUES " . $iolSql;
  1284. $invoiceOperationLog = new invoiceOperationLog ();
  1285. $invoiceOperationLog->setInvoiceOperationLogBySql ( $sql );
  1286. Doo::loadModel ( 'invoiceTraining' );
  1287. $invoiceTraining = new invoiceTraining ();
  1288. $item = array (
  1289. 'itid' => $trainId,
  1290. 'submitStatus' => 1
  1291. );
  1292. $invoiceTraining->setInvoiceTrainByCondition ( $item );
  1293. // Doo::loadModel ( 'invoiceOperationLog' );
  1294. // $item = array (
  1295. // 'date' => date ( "Y-m-d H:i:s" ),
  1296. // 'operation' => "创建",
  1297. // 'status' => 1,
  1298. // 'img' => $this->staff [0] ['avatar'],
  1299. // 'username' => $this->staff [0] ['username'],
  1300. // 'uid' => $this->staff [0] ['sid'],
  1301. // 'category' => $this->staff [0] ['category'],
  1302. // 'iid' => $iid
  1303. // );
  1304. // $invoiceOperationLog = new invoiceOperationLog ();
  1305. // $invoiceOperationLog->setInvoiceOperationLog ( $item ,$iidString);
  1306. // $item = array (
  1307. // 'date' => date ( "Y-m-d H:i:s" ),
  1308. // 'operation' => "提交审批",
  1309. // 'status' => 1,
  1310. // 'img' => $this->staff [0] ['avatar'],
  1311. // 'username' => $this->staff [0] ['username'],
  1312. // 'uid' => $this->staff [0] ['sid'],
  1313. // 'category' => $this->staff [0] ['category'],
  1314. // 'iid' => $iid
  1315. // );
  1316. // $invoiceOperationLog->setInvoiceOperationLog ( $item );
  1317. Doo::loadModel ( 'staff' );
  1318. $staff = new staff ();
  1319. $username2 = $staff->getOne ( array (
  1320. 'select' => 'wxid',
  1321. 'where' => 'sid=' . $pendingApprovalsSid,
  1322. 'asArray' => TRUE
  1323. ) );
  1324. // 发送微信审批通知
  1325. $title2 = '[通知]用户提交了一条开票申请,快到“我的发票”中查看,给用户确认审批。';
  1326. $this->msgSend ( '', $title2, '', $username2 ['wxid'], $pendingApprovalsSid, 'approval' );
  1327. return "/invoiceTrainingDetail/" . $trainKey . ".html";
  1328. }
  1329. /**
  1330. */
  1331. function invoiceStoreMailItemSet() {
  1332. $softLock = $this->get_args ( 'softLock' ) ? $this->get_args ( 'softLock' ) : 0;
  1333. $softLockNum = $this->get_args ( 'softLockNum' ) ? $this->get_args ( 'softLockNum' ) : 0;
  1334. $contract = $this->get_args ( 'contract' ) ? $this->get_args ( 'contract' ) : 0;
  1335. $contractNum = $this->get_args ( 'contractNum' ) ? $this->get_args ( 'contractNum' ) : 0;
  1336. $instructions = $this->get_args ( 'instructions' ) ? $this->get_args ( 'instructions' ) : 0;
  1337. $instructionsNum = $this->get_args ( 'instructionsNum' ) ? $this->get_args ( 'instructionsNum' ) : 0;
  1338. $remittance = $this->get_args ( 'remittance' ) ? $this->get_args ( 'remittance' ) : 0;
  1339. $mailItems = $this->get_args ( 'mailItems' ) ? $this->get_args ( 'mailItems' ) : "";
  1340. $recipients = $this->get_args ( 'recipients' ) ? $this->get_args ( 'recipients' ) : "";
  1341. $recipientsPhone = $this->get_args ( 'recipientsPhone' ) ? $this->get_args ( 'recipientsPhone' ) : "";
  1342. $recipientsAddress = $this->get_args ( 'recipientsAddress' ) ? $this->get_args ( 'recipientsAddress' ) : "";
  1343. Doo::loadClass ( 'XDeode' );
  1344. $XDeode = new XDeode ( 5 );
  1345. $trainKey = $this->get_args ( 'trainKey' ) ? $this->get_args ( 'trainKey' ) : '';
  1346. $storeKey = $this->get_args ( 'storeKey' ) ? $this->get_args ( 'storeKey' ) : '';
  1347. $isid = $XDeode->decode ( $storeKey );
  1348. $trainId = $XDeode->decode ( $trainKey );
  1349. if (! is_numeric ( $isid ))
  1350. die ( 'illegal request' );
  1351. Doo::loadModel ( 'invoiceStore' );
  1352. $invoiceStore = new invoiceStore ();
  1353. $mailList = array (
  1354. 'invoice' => 1,
  1355. 'mailItems' => $mailItems
  1356. );
  1357. if (! empty ( $softLock ))
  1358. $mailList += array (
  1359. 'softLock' => $softLockNum
  1360. );
  1361. else
  1362. $mailList += array (
  1363. 'softLock' => 0
  1364. );
  1365. if (! empty ( $contract ))
  1366. $mailList += array (
  1367. 'contract' => $contractNum
  1368. );
  1369. else
  1370. $mailList += array (
  1371. 'contract' => 0
  1372. );
  1373. if (! empty ( $instructions ))
  1374. $mailList += array (
  1375. 'instructions' => $instructionsNum
  1376. );
  1377. else
  1378. $mailList += array (
  1379. 'instructions' => 0
  1380. );
  1381. if (! empty ( $remittance ))
  1382. $mailList += array (
  1383. 'remittance' => $remittance
  1384. );
  1385. else
  1386. $mailList += array (
  1387. 'remittance' => ''
  1388. );
  1389. $mailString = '发票x1,备注:' . $mailItems;
  1390. if (! empty ( $softLock ))
  1391. $mailString .= ',软件锁x' . $softLockNum;
  1392. if (! empty ( $contract ))
  1393. $mailString .= ',合同x' . $contractNum;
  1394. if (! empty ( $instructions ))
  1395. $mailString .= ',说明书x' . $instructionsNum;
  1396. if (! empty ( $remittance ))
  1397. $mailString .= ',汇款账号单';
  1398. $item = array (
  1399. 'isid' => $isid,
  1400. 'doPost' => 1,
  1401. 'mailItems' => $mailString,
  1402. 'mailItemsJson' => json_encode ( $mailList )
  1403. );
  1404. $invoiceStore->setInvoiceStoreByCondition ( $item );
  1405. return "/invoiceTrainingDetail/" . $trainKey . ".html";
  1406. }
  1407. /**
  1408. * 批量设置邮寄物品
  1409. */
  1410. function invoiceStoreBatchMailItemSet() {
  1411. $softLock = $this->get_args ( 'softLock' ) ? $this->get_args ( 'softLock' ) : 0;
  1412. $softLockNum = $this->get_args ( 'softLockNum' ) ? $this->get_args ( 'softLockNum' ) : 0;
  1413. $contract = $this->get_args ( 'contract' ) ? $this->get_args ( 'contract' ) : 0;
  1414. $contractNum = $this->get_args ( 'contractNum' ) ? $this->get_args ( 'contractNum' ) : 0;
  1415. $instructions = $this->get_args ( 'instructions' ) ? $this->get_args ( 'instructions' ) : 0;
  1416. $instructionsNum = $this->get_args ( 'instructionsNum' ) ? $this->get_args ( 'instructionsNum' ) : 0;
  1417. $remittance = $this->get_args ( 'remittance' ) ? $this->get_args ( 'remittance' ) : 0;
  1418. $mailItems = $this->get_args ( 'mailItems' ) ? $this->get_args ( 'mailItems' ) : "";
  1419. $recipients = $this->get_args ( 'recipients' ) ? $this->get_args ( 'recipients' ) : "";
  1420. $recipientsPhone = $this->get_args ( 'recipientsPhone' ) ? $this->get_args ( 'recipientsPhone' ) : "";
  1421. $recipientsAddress = $this->get_args ( 'recipientsAddress' ) ? $this->get_args ( 'recipientsAddress' ) : "";
  1422. Doo::loadClass ( 'XDeode' );
  1423. $XDeode = new XDeode ( 5 );
  1424. $trainKey = $this->get_args ( 'trainKey' ) ? $this->get_args ( 'trainKey' ) : '';
  1425. $storeKey = $this->get_args ( 'storeKey' ) ? $this->get_args ( 'storeKey' ) : '';
  1426. $isidKeyList = explode ( ',', $storeKey );
  1427. $isidList = array ();
  1428. foreach ( $isidKeyList as $value ) {
  1429. $isid = $XDeode->decode ( $value );
  1430. if (! empty ( $isid ) && is_numeric ( $isid ))
  1431. array_push ( $isidList, $isid );
  1432. }
  1433. $isidString = implode ( ',', $isidList );
  1434. $trainId = $XDeode->decode ( $trainKey );
  1435. if (! is_numeric ( $isid ))
  1436. die ( 'illegal request' );
  1437. Doo::loadModel ( 'invoiceStore' );
  1438. $invoiceStore = new invoiceStore ();
  1439. $mailList = array (
  1440. 'invoice' => 1,
  1441. 'mailItems' => $mailItems
  1442. );
  1443. if (! empty ( $softLock ))
  1444. $mailList += array (
  1445. 'softLock' => $softLockNum
  1446. );
  1447. else
  1448. $mailList += array (
  1449. 'softLock' => 0
  1450. );
  1451. if (! empty ( $contract ))
  1452. $mailList += array (
  1453. 'contract' => $contractNum
  1454. );
  1455. else
  1456. $mailList += array (
  1457. 'contract' => 0
  1458. );
  1459. if (! empty ( $instructions ))
  1460. $mailList += array (
  1461. 'instructions' => $instructionsNum
  1462. );
  1463. else
  1464. $mailList += array (
  1465. 'instructions' => 0
  1466. );
  1467. if (! empty ( $remittance ))
  1468. $mailList += array (
  1469. 'remittance' => $remittance
  1470. );
  1471. else
  1472. $mailList += array (
  1473. 'remittance' => ''
  1474. );
  1475. $mailString = '发票x1,备注:' . $mailItems;
  1476. if (! empty ( $softLock ))
  1477. $mailString .= ',软件锁x' . $softLockNum;
  1478. if (! empty ( $contract ))
  1479. $mailString .= ',合同x' . $contractNum;
  1480. if (! empty ( $instructions ))
  1481. $mailString .= ',说明书x' . $instructionsNum;
  1482. if (! empty ( $remittance ))
  1483. $mailString .= ',汇款账号单';
  1484. $item = array (
  1485. 'doPost' => 1,
  1486. 'mailItems' => $mailString,
  1487. 'mailItemsJson' => json_encode ( $mailList )
  1488. );
  1489. $invoiceStore->setInvoiceStoreByCondition ( $item, $isidString );
  1490. return "/invoiceTrainingDetail/" . $trainKey . ".html";
  1491. }
  1492. /**
  1493. * 废弃
  1494. */
  1495. function ajaxGetMailItemByIstore() {
  1496. Doo::loadClass ( 'XDeode' );
  1497. $XDeode = new XDeode ( 5 );
  1498. $storeKey = $this->get_args ( 'storeKey' ) ? $this->get_args ( 'storeKey' ) : '';
  1499. $isid = $XDeode->decode ( $storeKey );
  1500. if (! is_numeric ( $isid ))
  1501. die ( 'illegal request' );
  1502. Doo::loadModel ( 'invoiceStore' );
  1503. $invoiceStore = new invoiceStore ();
  1504. $isDetail = $invoiceStore->getInvoiceStoreByIsid ( $isid );
  1505. $isDetail ['mailItemsJson'] = json_decode ( $isDetail ['mailItemsJson'], true );
  1506. echo json_encode ( $isDetail ['mailItemsJson'] );
  1507. exit ();
  1508. }
  1509. /**
  1510. * 终止开票
  1511. */
  1512. function invoiceDroppedDo() {
  1513. $droppedIidKey = $this->get_args ( 'droppedIidKey' ) ? $this->get_args ( 'droppedIidKey' ) : '';
  1514. Doo::loadModel ( 'invoice' );
  1515. $invoice = new invoice ();
  1516. Doo::loadModel ( 'invoiceOperationLog' );
  1517. $invoiceOperationLog = new invoiceOperationLog ();
  1518. $iid = $invoice->authcode ( $droppedIidKey );
  1519. if (! empty ( $iid ) && ! is_numeric ( $iid ))
  1520. die ( 'illegal request' );
  1521. $item = array (
  1522. 'iid' => $iid,
  1523. 'status' => 4,
  1524. 'updateTime' => date ( "Y-m-d H:i:s" )
  1525. );
  1526. $invoice->setInvoiceByCondition ( $item );
  1527. $item = array (
  1528. 'date' => date ( "Y-m-d H:i:s" ),
  1529. 'operation' => '终止了开票',
  1530. 'status' => 4,
  1531. 'img' => $this->staff [0] ['avatar'],
  1532. 'username' => $this->staff [0] ['username'],
  1533. 'uid' => $this->staff [0] ['sid'],
  1534. 'category' => $this->staff [0] ['category'],
  1535. 'iid' => $iid
  1536. );
  1537. $invoiceOperationLog->setInvoiceOperationLog ( $item );
  1538. return "/invoice";
  1539. }
  1540. /**
  1541. * 更新退票的邮寄信息
  1542. */
  1543. function invoiceUntreadMailDo() {
  1544. $untreadIidKey = $this->get_args ( 'untreadIidKey' ) ? $this->get_args ( 'untreadIidKey' ) : '';
  1545. $untreadCompany = $this->get_args ( 'untreadCompany' ) ? $this->get_args ( 'untreadCompany' ) : "";
  1546. $untreadNumber = $this->get_args ( 'untreadNumber' ) ? $this->get_args ( 'untreadNumber' ) : "";
  1547. $untreadItems = $this->get_args ( 'untreadItems' ) ? $this->get_args ( 'untreadItems' ) : "";
  1548. Doo::loadModel ( 'invoice' );
  1549. $invoice = new invoice ();
  1550. $iid = $invoice->authcode ( $untreadIidKey );
  1551. if (! empty ( $iid ) && ! is_numeric ( $iid ))
  1552. die ( 'illegal request' );
  1553. $item = array (
  1554. 'iid' => $iid,
  1555. 'untreadCompany' => $untreadCompany,
  1556. 'untreadNumber' => $untreadNumber,
  1557. 'untreadItems' => $untreadItems
  1558. );
  1559. $invoice->setInvoiceByCondition ( $item );
  1560. return "/invoice";
  1561. }
  1562. /**
  1563. * 申请退票 --
  1564. */
  1565. function invoiceUntreadDo() {
  1566. $untreadIidKey = $this->get_args ( 'untreadIidKey' ) ? $this->get_args ( 'untreadIidKey' ) : '';
  1567. $untreadReason = $this->get_args ( 'untreadReason' ) ? $this->get_args ( 'untreadReason' ) : "";
  1568. $untreadPost = $this->get_args ( 'untreadPost' ) ? $this->get_args ( 'untreadPost' ) : "";
  1569. Doo::loadModel ( 'invoice' );
  1570. $invoice = new invoice ();
  1571. Doo::loadModel ( 'invoiceOperationLog' );
  1572. $invoiceOperationLog = new invoiceOperationLog ();
  1573. Doo::loadModel ( 'invoiceReceivables' );
  1574. $invoiceReceivables = new invoiceReceivables ();
  1575. $iid = $invoice->authcode ( $untreadIidKey );
  1576. if (! empty ( $iid ) && ! is_numeric ( $iid ))
  1577. die ( 'illegal request' );
  1578. /*
  1579. * 需求变革 有绑定收款也可以退票 $lt = $invoiceReceivables->getInvoiceReceivablesByIid ( $untreadIidKey ); if (! empty ( $lt )) { header ( 'Content-Type:text/html;charset=utf-8' ); die ( '该发票有收款绑定,请先移除!' ); }
  1580. */
  1581. $item = array (
  1582. 'iid' => $iid,
  1583. 'untreadStatus' => 1,
  1584. 'untreadReason' => $untreadReason,
  1585. 'untreadPost' => $untreadPost,
  1586. 'updateTime' => date ( "Y-m-d H:i:s" )
  1587. );
  1588. $invoice->setInvoiceByCondition ( $item );
  1589. $item = array (
  1590. 'date' => date ( "Y-m-d H:i:s" ),
  1591. 'operation' => '申请退票',
  1592. 'status' => 7,
  1593. 'img' => $this->staff [0] ['avatar'],
  1594. 'username' => $this->staff [0] ['username'],
  1595. 'uid' => $this->staff [0] ['sid'],
  1596. 'category' => $this->staff [0] ['category'],
  1597. 'iid' => $iid
  1598. );
  1599. $invoiceOperationLog->setInvoiceOperationLog ( $item );
  1600. return "/invoice";
  1601. }
  1602. /**
  1603. * 删除已终止的开票
  1604. */
  1605. function invoiceDelDo() {
  1606. Doo::loadClass ( 'XDeode' );
  1607. $XDeode = new XDeode ( 5 );
  1608. Doo::loadModel ( 'invoice' );
  1609. $invoice = new invoice ();
  1610. Doo::loadModel ( 'invoiceOperationLog' );
  1611. $invoiceOperationLog = new invoiceOperationLog ();
  1612. Doo::loadClass ( 'XDeode' );
  1613. $XDeode = new XDeode ( 5 );
  1614. $sid = $XDeode->decode ( $_COOKIE ["staff"] );
  1615. $iid = isset ( $this->params ['iid'] ) ? $this->params ['iid'] : "";
  1616. $iid = $XDeode->decode ( $iid );
  1617. if (! is_numeric ( $iid ))
  1618. die ( 'illegal request' );
  1619. $invoiceDetail = $invoice->getMyInvoice ( $sid, $iid );
  1620. if (empty ( $invoiceDetail ))
  1621. die ( 'illegal request' );
  1622. $item = array (
  1623. 'iid' => $iid,
  1624. 'isDelete' => 1,
  1625. 'updateTime' => date ( "Y-m-d H:i:s" )
  1626. );
  1627. $invoice->setInvoiceByCondition ( $item );
  1628. $item = array (
  1629. 'date' => date ( "Y-m-d H:i:s" ),
  1630. 'operation' => '删除了已终止的发票',
  1631. 'status' => 4,
  1632. 'img' => $this->staff [0] ['avatar'],
  1633. 'username' => $this->staff [0] ['username'],
  1634. 'uid' => $this->staff [0] ['sid'],
  1635. 'category' => $this->staff [0] ['category'],
  1636. 'iid' => $iid
  1637. );
  1638. $invoiceOperationLog->setInvoiceOperationLog ( $item );
  1639. return "/invoice";
  1640. }
  1641. function invoiceApproval() {
  1642. Doo::loadModel ( 'invoice' );
  1643. $invoice = new invoice ();
  1644. Doo::loadClass ( 'XDeode' );
  1645. $XDeode = new XDeode ( 5 );
  1646. Doo::loadModel ( 'staff' );
  1647. $staff = new staff ();
  1648. $invoiceList = $invoice->find ( array (
  1649. 'where' => 'status=1 and pendingApprovals=' . $this->staff [0] ['sid'],
  1650. 'desc' => 'iid',
  1651. 'asArray' => true
  1652. ) );
  1653. foreach ( $invoiceList as $key => $value ) {
  1654. $invoiceList [$key] ['iidKey'] = $XDeode->encode ( $value ['iid'] );
  1655. $lastApprover = json_decode ( $value ['processApprovals'], true );
  1656. if (! empty ( $lastApprover )) {
  1657. $lastApproverKey = array_keys ( $lastApprover );
  1658. $lastApprover = end ( $lastApprover );
  1659. $staffDetail = $staff->getOne ( array (
  1660. 'where' => 'sid=' . end ( $lastApproverKey ),
  1661. 'asArray' => true
  1662. ) );
  1663. $lastApprover ['username'] = $staffDetail ['username'];
  1664. }
  1665. $invoiceList [$key] ['lastApprover'] = $lastApprover;
  1666. }
  1667. $ilist = $invoice->getInvoiceByProcessStatus ();
  1668. // print_r($ilist);
  1669. $this->data ['invoiceList'] = $invoiceList;
  1670. $this->data ['ilist'] = $ilist;
  1671. $this->data ['memu'] = "invoice";
  1672. $this->data ['staff'] = $this->staff;
  1673. $this->data ['receiptMemu'] = 'invoiceApproval';
  1674. $this->render ( "/admin/invoiceApproval", $this->data );
  1675. }
  1676. function invoiceDetail() {
  1677. Doo::loadClass ( 'XDeode' );
  1678. $XDeode = new XDeode ( 5 );
  1679. $iid = isset ( $this->params ['iid'] ) ? $this->params ['iid'] : "";
  1680. $iid = $XDeode->decode ( $iid );
  1681. if (! is_numeric ( $iid ))
  1682. die ( 'illegal request' );
  1683. Doo::loadModel ( 'invoice' );
  1684. $invoice = new invoice ();
  1685. Doo::loadModel ( 'invoiceOperationLog' );
  1686. $invoiceOperationLog = new invoiceOperationLog ();
  1687. $invoiceDetail = $invoice->getOne ( array (
  1688. 'where' => 'status=1 and pendingApprovals=' . $this->staff [0] ['sid'] . ' and iid=' . $iid,
  1689. 'asArray' => true
  1690. ) );
  1691. if (empty ( $invoiceDetail ))
  1692. die ( 'illegal request' );
  1693. $invoiceOperationLogList = $invoiceOperationLog->getInvoiceOperationLogByIid ( $iid );
  1694. $this->data ['invoiceDetail'] = $invoiceDetail;
  1695. $this->data ['invoiceOperationLogList'] = $invoiceOperationLogList;
  1696. $this->data ['INVOICEKEY'] = $invoice->authcode ( $invoiceDetail ['iid'], '' );
  1697. $this->data ['memu'] = "invoice";
  1698. $this->data ['staff'] = $this->staff;
  1699. $this->data ['receiptMemu'] = 'invoiceApproval';
  1700. $this->render ( "/admin/invoiceApprovalDetail", $this->data );
  1701. }
  1702. /**
  1703. * 对发票进行审批,其中操作有终止,退回,同意动作。操作成功并记录下操作日志
  1704. *
  1705. * @since 1.0.0
  1706. * @var integer iid 开票ID 已加密
  1707. * @var integer status 发票审批状态
  1708. * @var integer opintion 审批发票的意见
  1709. * @return string 如操作成功返回审批首页
  1710. */
  1711. function invoiceApprovalDo() {
  1712. Doo::loadModel ( 'invoice' );
  1713. $invoice = new invoice ();
  1714. $iid = $this->get_args ( 'invoiceKey' ) ? $this->get_args ( 'invoiceKey' ) : "";
  1715. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  1716. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  1717. $iid = $invoice->authcode ( $iid );
  1718. if (! is_numeric ( $iid ))
  1719. die ( 'illegal request' );
  1720. // && ! empty ( $opinion )
  1721. if (! empty ( $iid ) && ! empty ( $status )) {
  1722. if (! ($status == 2 || $status == 3 || $status == 4))
  1723. die ( 'illegal request' );
  1724. Doo::loadModel ( 'invoiceOperationLog' );
  1725. $invoiceOperationLog = new invoiceOperationLog ();
  1726. $invoiceDetail = $invoice->getOne ( array (
  1727. 'where' => 'status=1 and iid=' . $iid . ' and pendingApprovals=' . $this->staff [0] ['sid'],
  1728. 'asArray' => true
  1729. ) );
  1730. if (empty ( $invoiceDetail ))
  1731. die ( 'illegal request' );
  1732. $processApprovals = json_decode ( $invoiceDetail ['processApprovals'], true );
  1733. $invoiceManage = json_decode ( $invoiceDetail ['invoiceManage'], true );
  1734. if ($status == 3) {
  1735. $invoice->status = $status;
  1736. $item = array (
  1737. 'operation' => $opinion
  1738. );
  1739. } else {
  1740. if (empty ( $processApprovals )) {
  1741. $processApprovals = array (
  1742. $this->staff [0] ['sid'] => array (
  1743. 'date' => date ( "Y-m-d H:i:s" ),
  1744. 'opinion' => $opinion,
  1745. 'status' => $status
  1746. )
  1747. );
  1748. // var_dump(next($invoiceManage));
  1749. $nextInvoiceManage = next ( $invoiceManage );
  1750. // print_r($nextInvoiceManage);
  1751. if ($status != 4 && $nextInvoiceManage !== false)
  1752. $invoice->pendingApprovals = $nextInvoiceManage [0];
  1753. $invoice->processApprovals = json_encode ( $processApprovals );
  1754. // var_dump($invoice);
  1755. // print_r($invoiceManage);
  1756. } else {
  1757. $processApprovals [$this->staff [0] ['sid']] = array (
  1758. 'date' => date ( "Y-m-d H:i:s" ),
  1759. 'opinion' => $opinion,
  1760. 'status' => $status
  1761. );
  1762. $pendingApprovals = 0;
  1763. foreach ( $invoiceManage as $key => $value ) {
  1764. if ($value [0] == $this->staff [0] ['sid']) {
  1765. if (isset ( $invoiceManage [$key + 1] ))
  1766. $pendingApprovals = $invoiceManage [$key + 1] [0];
  1767. break;
  1768. }
  1769. }
  1770. if ($status != 4 && ! empty ( $pendingApprovals ))
  1771. $invoice->pendingApprovals = $pendingApprovals;
  1772. $invoice->processApprovals = json_encode ( $processApprovals );
  1773. }
  1774. $item = array (
  1775. 'operation' => $opinion
  1776. );
  1777. if (count ( $processApprovals ) == count ( $invoiceManage ) && $status != 4) {
  1778. $invoice->status = $status;
  1779. $invoice->pendingApprovals = 0;
  1780. } elseif ($status == 4) {
  1781. $invoice->status = $status;
  1782. $item = array (
  1783. 'operation' => $opinion
  1784. );
  1785. }
  1786. }
  1787. $invoice->updateTime = date ( "Y-m-d H:i:s" );
  1788. $invoice->update ( array (
  1789. 'where' => 'iid=' . $iid
  1790. ) );
  1791. $item += array (
  1792. 'date' => date ( "Y-m-d H:i:s" ),
  1793. 'img' => $this->staff [0] ['avatar'],
  1794. 'username' => $this->staff [0] ['username'],
  1795. 'uid' => $this->staff [0] ['sid'],
  1796. 'category' => $this->staff [0] ['category'],
  1797. 'status' => $status,
  1798. 'iid' => $iid
  1799. );
  1800. $invoiceOperationLog->setInvoiceOperationLog ( $item );
  1801. return '/invoiceApproval';
  1802. }
  1803. die ( 'illegal request' );
  1804. }
  1805. /**
  1806. * 展示需要打印的发票数据
  1807. *
  1808. * @since 1.0.0
  1809. */
  1810. function invoicePrint() {
  1811. Doo::loadModel ( 'invoice' );
  1812. $invoice = new invoice ();
  1813. Doo::loadClass ( 'XDeode' );
  1814. $XDeode = new XDeode ( 5 );
  1815. Doo::loadModel ( 'staff' );
  1816. $staff = new staff ();
  1817. $toPrint = $invoice->getPrintInvoiceByManage ( $this->staff [0] ['sid'], 0 );
  1818. $printed = $invoice->getPrintInvoiceByManage ( $this->staff [0] ['sid'], 1 );
  1819. foreach ( $toPrint as $key => $value ) {
  1820. $toPrint [$key] ['iidKey'] = $XDeode->encode ( $value ['iid'] );
  1821. $lastApprover = json_decode ( $value ['processApprovals'], true );
  1822. if (! empty ( $lastApprover )) {
  1823. $lastApproverKey = array_keys ( $lastApprover );
  1824. $lastApprover = end ( $lastApprover );
  1825. $staffDetail = $staff->getOne ( array (
  1826. 'where' => 'sid=' . end ( $lastApproverKey ),
  1827. 'asArray' => true
  1828. ) );
  1829. $lastApprover ['username'] = $staffDetail ['username'];
  1830. }
  1831. $toPrint [$key] ['lastApprover'] = $lastApprover;
  1832. }
  1833. foreach ( $printed as $key => $value ) {
  1834. $printed [$key] ['iidKey'] = $XDeode->encode ( $value ['iid'] );
  1835. $lastApprover = json_decode ( $value ['processApprovals'], true );
  1836. if (! empty ( $lastApprover )) {
  1837. $lastApproverKey = array_keys ( $lastApprover );
  1838. $lastApprover = end ( $lastApprover );
  1839. $staffDetail = $staff->getOne ( array (
  1840. 'where' => 'sid=' . end ( $lastApproverKey ),
  1841. 'asArray' => true
  1842. ) );
  1843. $lastApprover ['username'] = $staffDetail ['username'];
  1844. }
  1845. $printed [$key] ['lastApprover'] = $lastApprover;
  1846. }
  1847. $this->data ['printed'] = $printed;
  1848. $this->data ['toPrint'] = $toPrint;
  1849. $this->data ['memu'] = "invoice";
  1850. $this->data ['staff'] = $this->staff;
  1851. $this->data ['receiptMemu'] = 'invoicePrint';
  1852. $this->render ( "/admin/invoicePrint", $this->data );
  1853. }
  1854. /**
  1855. * 展示发票打印的详情页面
  1856. *
  1857. * @since 1.0.0
  1858. */
  1859. function invoicePrintDetail() {
  1860. Doo::loadClass ( 'XDeode' );
  1861. $XDeode = new XDeode ( 5 );
  1862. $iid = isset ( $this->params ['iid'] ) ? $this->params ['iid'] : "";
  1863. $iid = $XDeode->decode ( $iid );
  1864. if (! is_numeric ( $iid ))
  1865. die ( 'illegal request' );
  1866. Doo::loadModel ( 'invoice' );
  1867. $invoice = new invoice ();
  1868. Doo::loadModel ( 'invoiceOperationLog' );
  1869. $invoiceOperationLog = new invoiceOperationLog ();
  1870. $invoiceDetail = $invoice->getPrintInvoiceByManage ( $this->staff [0] ['sid'], 0, $iid );
  1871. if (empty ( $invoiceDetail ))
  1872. die ( 'illegal request' );
  1873. $invoiceOperationLogList = $invoiceOperationLog->getInvoiceOperationLogByIid ( $iid );
  1874. $this->data ['invoiceDetail'] = $invoiceDetail;
  1875. $this->data ['invoiceOperationLogList'] = $invoiceOperationLogList;
  1876. $this->data ['INVOICEKEY'] = $invoice->authcode ( $invoiceDetail ['iid'], '' );
  1877. $this->data ['memu'] = "invoice";
  1878. $this->data ['staff'] = $this->staff;
  1879. $this->data ['receiptMemu'] = 'invoicePrint';
  1880. $this->render ( "/admin/invoicePrintDetail", $this->data );
  1881. }
  1882. /**
  1883. * 所有待打印 发票
  1884. */
  1885. function invoicePrintStayAchieve() {
  1886. Doo::loadModel ( 'invoice' );
  1887. $invoice = new invoice ();
  1888. Doo::loadClass ( 'XDeode' );
  1889. $XDeode = new XDeode ( 5 );
  1890. Doo::loadModel ( 'staff' );
  1891. $staff = new staff ();
  1892. $MebSea = $this->get_args ( 'MebSea' ) ? urldecode ( $this->get_args ( 'MebSea' ) ) : "";
  1893. $page_size = 12;
  1894. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  1895. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : "ALL";
  1896. // $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : "ALL";
  1897. $get = "/" . $status;
  1898. $con = ' and status=2 ';
  1899. if ($status == 'TOPRINT')
  1900. $con = ' and status=2 and printStatus=0 ';
  1901. elseif ($status == 'PRINTED')
  1902. $con = ' and status=2 and printStatus=1';
  1903. $date = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "";
  1904. $dateArr = explode ( ':', $date );
  1905. $D1 = '';
  1906. $D2 = '';
  1907. if (! empty ( $date )) {
  1908. $D1 = $dateArr [0];
  1909. $D2 = $dateArr [1];
  1910. }
  1911. if (! empty ( $D1 ) && ! empty ( $D2 ) && ! empty ( $date ))
  1912. $con .= ' and printTime BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
  1913. if (! empty ( $MebSea )) {
  1914. $con .= ' and ( invoiceTitle like "%' . $MebSea . '%" or invoiceCompany like "%' . $MebSea . '%" or invoicePrice like "%' . $MebSea . '%" )';
  1915. }
  1916. $pageinfo ['page'] = array (
  1917. 'previous' => ''
  1918. );
  1919. $get .= "?date=" . urlencode ( $date ) . "&MebSea=" . urlencode ( $MebSea );
  1920. $sql = " (untreadStatus=0 or untreadStatus=3) and moldManage like '%[\"" . $this->staff [0] ['sid'] . "\",%'" . $con;
  1921. $action = "invoicePrintStayAchieve";
  1922. $pageinfo = $this->get_page ( "CLD_invoice", $sql, $page, $page_size, $action, $get, "" );
  1923. $limit = $pageinfo ['lower'] . ',' . $page_size;
  1924. $list = $invoice->getInvoiceByUntreadStatusPage ( $limit, $sql );
  1925. $this->data ['MebSeaEn'] = $MebSea;
  1926. $this->data ['MebSea'] = urlencode ( $MebSea );
  1927. $this->data ['get'] = $get;
  1928. $this->data ['page'] = $pageinfo;
  1929. $this->data ['date'] = $date;
  1930. $this->data ['status'] = $status;
  1931. $this->data ['memu'] = "invoice";
  1932. $this->data ['staff'] = $this->staff;
  1933. foreach ( $list as $key => $value ) {
  1934. $list [$key] ['iidKey'] = $XDeode->encode ( $value ['iid'] );
  1935. $lastApprover = json_decode ( $value ['processApprovals'], true );
  1936. if (! empty ( $lastApprover )) {
  1937. $lastApproverKey = array_keys ( $lastApprover );
  1938. $lastApprover = end ( $lastApprover );
  1939. $staffDetail = $staff->getOne ( array (
  1940. 'where' => 'sid=' . end ( $lastApproverKey ),
  1941. 'asArray' => true
  1942. ) );
  1943. $lastApprover ['username'] = $staffDetail ['username'];
  1944. }
  1945. $list [$key] ['lastApprover'] = $lastApprover;
  1946. }
  1947. $this->data ['receiptMemu'] = 'invoicePrint';
  1948. $this->data ['list'] = $list;
  1949. $this->render ( "/admin/invoicePrintStayAchieve", $this->data );
  1950. }
  1951. /**
  1952. * 填写票号并完成打印
  1953. * @since 1.0.0
  1954. */
  1955. function invoicePrintDo() {
  1956. Doo::loadModel ( 'invoice' );
  1957. $invoice = new invoice ();
  1958. $iid = $this->get_args ( 'invoiceKey' ) ? $this->get_args ( 'invoiceKey' ) : "";
  1959. $invoiceNo = $this->get_args ( 'invoiceNo' ) ? $this->get_args ( 'invoiceNo' ) : "";
  1960. $iid = $invoice->authcode ( $iid );
  1961. if (! is_numeric ( $iid ))
  1962. die ( 'illegal request' );
  1963. if (! empty ( $iid ) && ! empty ( $invoiceNo )) {
  1964. Doo::loadModel ( 'invoiceOperationLog' );
  1965. $invoiceOperationLog = new invoiceOperationLog ();
  1966. Doo::loadModel ( 'invoiceStatistics' );
  1967. $invoiceStatistics = new invoiceStatistics ();
  1968. // $info=$invoice->getOne(array('where'=>"invoiceNo = '".$invoiceNo."'",'asArray' => TRUE));
  1969. $invoicePrintDetail = $invoice->getInvoiceByPrint ( $iid );
  1970. if (empty ( $invoicePrintDetail ))
  1971. die ( 'illegal request' );
  1972. $item = array (
  1973. 'iid' => $iid,
  1974. 'printStatus' => 1,
  1975. 'updateTime' => date ( "Y-m-d H:i:s" ),
  1976. 'printer' => $this->staff [0] ['username'],
  1977. 'printTime' => date ( "Y-m-d H:i:s" ),
  1978. 'invoiceNo' => $invoiceNo
  1979. );
  1980. $invoice->setInvoiceByCondition ( $item );
  1981. $item = array (
  1982. 'date' => date ( "Y-m-d H:i:s" ),
  1983. 'operation' => $invoiceNo,
  1984. 'status' => 5,
  1985. 'img' => $this->staff [0] ['avatar'],
  1986. 'username' => $this->staff [0] ['username'],
  1987. 'uid' => $this->staff [0] ['sid'],
  1988. 'category' => $this->staff [0] ['category'],
  1989. 'iid' => $iid
  1990. );
  1991. $invoiceOperationLog->setInvoiceOperationLog ( $item );
  1992. // 去统计--负票不汇总
  1993. if ($invoicePrintDetail ['untreadStatus'] != 4) {
  1994. $item = array (
  1995. 'date' => date ( "Y-m-d H:i:s" ),
  1996. 'priceClass' => 1,
  1997. 'cid' => $invoicePrintDetail ['cid'],
  1998. 'staff' => $invoicePrintDetail ['sid'],
  1999. 'invoicePrice' => $invoicePrintDetail ['invoicePrice']
  2000. );
  2001. $invoiceStatistics->setInvoiceStatisticsByCondition ( $item );
  2002. }
  2003. // 发送通知信息到微信-去除
  2004. // $this->setWXMsg($iid,'PRINT');
  2005. // 申请人获取微信通知
  2006. Doo::loadModel ( 'staff' );
  2007. $staff = new staff ();
  2008. Doo::loadClass ( 'XDeode' );
  2009. $XDeode = new XDeode ( 5 );
  2010. $username2 = $staff->getOne ( array (
  2011. 'select' => 'wxid',
  2012. 'where' => 'sid=' . $invoicePrintDetail ['sid'],
  2013. 'asArray' => TRUE
  2014. ) );
  2015. $title2 = '[结果]您的发票' . $invoicePrintDetail ['invoiceSerial'] . '完成打印';
  2016. $msg = '';
  2017. $url = 'http://m.cld.smartcost.com.cn/invoicePrintDetail/' . $XDeode->encode ( $invoicePrintDetail ['iid'] ) . '.html';
  2018. $hfreult = $this->msgSend ( $msg, $title2, $url, $username2 ['wxid'], $invoicePrintDetail ['sid'], 'print' );
  2019. return "/invoicePrint";
  2020. }
  2021. }
  2022. /**
  2023. * 需要邮寄的发票
  2024. * @since 1.0.0
  2025. */
  2026. function invoicePost() {
  2027. Doo::loadModel ( 'invoice' );
  2028. $invoice = new invoice ();
  2029. Doo::loadModel ( 'express' );
  2030. $express = new express ();
  2031. $invoicePost = $invoice->getPostByInvoice ();
  2032. $invoicePosted = $invoice->getPostByInvoice ( 1 );
  2033. $expressList = $express->getExpressByAll ();
  2034. $this->data ['expressList'] = $expressList;
  2035. $this->data ['invoicePost'] = $invoicePost;
  2036. $this->data ['invoicePosted'] = $invoicePosted;
  2037. $this->data ['memu'] = "invoice";
  2038. $this->data ['staff'] = $this->staff;
  2039. $this->data ['receiptMemu'] = 'invoicePost';
  2040. $this->render ( "/admin/invoicePost", $this->data );
  2041. }
  2042. /**
  2043. * 添加发票邮寄信息
  2044. */
  2045. function invoiceExpressAddDo() {
  2046. Doo::loadModel ( 'invoice' );
  2047. $invoice = new invoice ();
  2048. $iid = $this->get_args ( 'iidKey' ) ? $this->get_args ( 'iidKey' ) : "";
  2049. $expressCompany = $this->get_args ( 'express' ) ? $this->get_args ( 'express' ) : "";
  2050. $expressNumber = $this->get_args ( 'nu' ) ? $this->get_args ( 'nu' ) : "";
  2051. $actualItems = $this->get_args ( 'actualItems' ) ? $this->get_args ( 'actualItems' ) : "";
  2052. $iid = $iid = $invoice->authcode ( $iid );
  2053. if (! is_numeric ( $iid ) && empty ( $expressCompany ) && empty ( $expressNumber ) && empty ( $actualItems ))
  2054. die ( 'illegal request' );
  2055. $invoicePrintDetail = $invoice->getInvoiceByIid ( $iid );
  2056. $item = array (
  2057. 'iid' => $iid,
  2058. 'postStatus' => 1,
  2059. 'updateTime' => date ( "Y-m-d H:i:s" ),
  2060. 'postTime' => date ( "Y-m-d H:i:s" ),
  2061. 'expressCompany' => $expressCompany,
  2062. 'expressNumber' => $expressNumber,
  2063. 'actualItems' => $actualItems,
  2064. 'poster' => $this->staff [0] ['username']
  2065. );
  2066. $invoice->setInvoiceByCondition ( $item );
  2067. // 微信通知-去掉
  2068. // $this->setWXMsg ( $iid );
  2069. Doo::loadModel ( 'staff' );
  2070. $staff = new staff ();
  2071. Doo::loadClass ( 'XDeode' );
  2072. $XDeode = new XDeode ( 5 );
  2073. $username2 = $staff->getOne ( array (
  2074. 'select' => 'wxid',
  2075. 'where' => 'sid=' . $invoicePrintDetail ['sid'],
  2076. 'asArray' => TRUE
  2077. ) );
  2078. $title2 = '[结果]您的发票' . $invoicePrintDetail ['invoiceSerial'] . '已邮寄';
  2079. $expCom = explode ( ":", $invoicePrintDetail ['expressCompany'] );
  2080. if (empty ( $expCom ))
  2081. $expCom [0] = '';
  2082. $msg = $expCom [0] . ':' . $invoicePrintDetail ['expressNumber'] . '';
  2083. $url = 'https://m.kuaidi100.com/result.jsp?nu=' . $invoicePrintDetail ['expressNumber'];
  2084. $hfreult = $this->msgSend ( $msg, $title2, $url, $username2 ['wxid'], $invoicePrintDetail ['sid'], 'print' );
  2085. return '/invoicePost';
  2086. }
  2087. function invoiceExpressUpdateDo() {
  2088. Doo::loadModel ( 'invoice' );
  2089. $invoice = new invoice ();
  2090. $action = $this->get_args ( 'action' ) ? $this->get_args ( 'action' ) : "";
  2091. $iid = $this->get_args ( 'iidKey' ) ? $this->get_args ( 'iidKey' ) : "";
  2092. $expressCompany = $this->get_args ( 'express' ) ? $this->get_args ( 'express' ) : "";
  2093. $expressNumber = $this->get_args ( 'nu' ) ? $this->get_args ( 'nu' ) : "";
  2094. $actualItems = $this->get_args ( 'actualItems' ) ? $this->get_args ( 'actualItems' ) : "";
  2095. $iid = $invoice->authcode ( $iid );
  2096. if (! is_numeric ( $iid ) && empty ( $expressCompany ) && empty ( $expressNumber ) && empty ( $actualItems ))
  2097. die ( 'illegal request' );
  2098. $item = array (
  2099. 'iid' => $iid,
  2100. 'updateTime' => date ( "Y-m-d H:i:s" ),
  2101. 'expressCompany' => $expressCompany,
  2102. 'expressNumber' => $expressNumber,
  2103. 'actualItems' => $actualItems,
  2104. 'poster' => $this->staff [0] ['username']
  2105. );
  2106. $invoice->setInvoiceByCondition ( $item );
  2107. return $action;
  2108. }
  2109. /**
  2110. * 可退票管理
  2111. */
  2112. function invoiceUntreadIsAchieve() {
  2113. Doo::loadModel ( 'invoice' );
  2114. $invoice = new invoice ();
  2115. Doo::loadClass ( 'XDeode' );
  2116. $XDeode = new XDeode ( 5 );
  2117. $MebSea = $this->get_args ( 'MebSea' ) ? $this->get_args ( 'MebSea' ) : "";
  2118. $page_size = 18;
  2119. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  2120. $date = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "";
  2121. $get = "?date=" . urlencode ( $date ) . "&MebSea=" . urlencode ( $MebSea );
  2122. $dateArr = explode ( ':', $date );
  2123. $D1 = '';
  2124. $D2 = '';
  2125. if (! empty ( $date )) {
  2126. $D1 = $dateArr [0];
  2127. $D2 = $dateArr [1];
  2128. }
  2129. $con = '';
  2130. if (! empty ( $D1 ) && ! empty ( $D2 ))
  2131. $con = ' and bindTime BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
  2132. // if ($date == 'MONTHO')
  2133. // $con = ' and updateTime>DATE_SUB(CURDATE(), INTERVAL 1 MONTH)';
  2134. // elseif ($date == 'MONTHT')
  2135. // $con = ' and updateTime>DATE_SUB(CURDATE(), INTERVAL 3 MONTH)';
  2136. // elseif ($date == 'MONTHY')
  2137. // $con = ' and updateTime>DATE_SUB(CURDATE(), INTERVAL 1 YEAR)';
  2138. if (! empty ( $MebSea )) {
  2139. $con .= ' and ( invoiceTitle like "%' . $MebSea . '%" or invoiceCompany like "%' . $MebSea . '%" or invoicePrice like "%' . $MebSea . '%" )';
  2140. }
  2141. $pageinfo ['page'] = array (
  2142. 'previous' => ''
  2143. );
  2144. // printStatus=1 and
  2145. $sql = " (untreadStatus=0 or untreadStatus=3) and status=2 and sid=" . $this->staff [0] ['sid'] . $con;
  2146. $action = "invoiceUntreadIsAchieve";
  2147. $pageinfo = $this->get_page ( "CLD_invoice", $sql, $page, $page_size, $action, $get, "" );
  2148. $limit = $pageinfo ['lower'] . ',' . $page_size;
  2149. $list = $invoice->getInvoiceByUntreadStatusPage ( $limit, $sql );
  2150. // print_r($list);
  2151. $this->data ['MebSeaEn'] = $MebSea;
  2152. // $this->data ['MebSea'] = urlencode ( $MebSea );
  2153. $this->data ['get'] = $get;
  2154. $this->data ['page'] = $pageinfo;
  2155. $this->data ['date'] = $date;
  2156. $this->data ['list'] = $list;
  2157. $this->data ['memu'] = "invoice";
  2158. $this->data ['staff'] = $this->staff;
  2159. $this->data ['receiptMemu'] = 'invoice';
  2160. $this->render ( "/admin/invoiceUntreadIsAchieve", $this->data );
  2161. }
  2162. /**
  2163. * 退票处理页面
  2164. */
  2165. function invoiceUntread() {
  2166. Doo::loadModel ( 'invoice' );
  2167. $invoice = new invoice ();
  2168. $untreadInvoice = $invoice->getInvoiceByUntreadStatus ( 1 );
  2169. $establishedInvoice = $invoice->getInvoiceByUntreadStatus ( 2 );
  2170. foreach ( $establishedInvoice as $key => $value ) {
  2171. // months
  2172. $lossDate = strtotime ( "+1 month", strtotime ( $value ['OperationLog'] ['date'] ) );
  2173. $nowDate = strtotime ( 'now' );
  2174. $establishedInvoice [$key] ['lossShow'] = false;
  2175. if ($lossDate < $nowDate)
  2176. $establishedInvoice [$key] ['lossShow'] = true;
  2177. }
  2178. $this->data ['untreadInvoice'] = $untreadInvoice;
  2179. $this->data ['establishedInvoice'] = $establishedInvoice;
  2180. $this->data ['memu'] = "invoice";
  2181. $this->data ['staff'] = $this->staff;
  2182. $this->data ['receiptMemu'] = 'invoiceUntread';
  2183. $this->render ( "/admin/invoiceUntread", $this->data );
  2184. }
  2185. /**
  2186. * 确认收到退回的发票,开票状态为退回 //收款状态解绑,公司统计扣除入账额度
  2187. */
  2188. function invoiceUntreadEstablishedDo() {
  2189. $untreadIidKey = $this->get_args ( 'untreadIidKey' ) ? $this->get_args ( 'untreadIidKey' ) : '';
  2190. Doo::loadModel ( 'invoice' );
  2191. $invoice = new invoice ();
  2192. Doo::loadModel ( 'invoiceOperationLog' );
  2193. $invoiceOperationLog = new invoiceOperationLog ();
  2194. Doo::loadModel ( 'invoiceReceivables' );
  2195. Doo::loadModel ( 'invoiceStatistics' );
  2196. $iid = $invoice->authcode ( $untreadIidKey );
  2197. if (! empty ( $iid ) && ! is_numeric ( $iid ))
  2198. die ( 'illegal request' );
  2199. $invoiceDetails = $invoice->getInvoiceByIid ( $iid );
  2200. if ($invoiceDetails ['untreadStatus'] != 1)
  2201. die ( 'illegal request' );
  2202. $item = array (
  2203. 'iid' => $iid,
  2204. // 'irid'=>'',
  2205. 'untreadStatus' => 2,
  2206. 'updateTime' => date ( "Y-m-d H:i:s" )
  2207. );
  2208. $invoice->setInvoiceByCondition ( $item );
  2209. $item = array (
  2210. 'date' => date ( "Y-m-d H:i:s" ),
  2211. 'operation' => '已确认退票',
  2212. 'status' => 6,
  2213. 'img' => $this->staff [0] ['avatar'],
  2214. 'username' => $this->staff [0] ['username'],
  2215. 'uid' => $this->staff [0] ['sid'],
  2216. 'category' => $this->staff [0] ['category'],
  2217. 'iid' => $iid
  2218. );
  2219. $invoiceOperationLog->setInvoiceOperationLog ( $item );
  2220. // 收款解绑以及入账扣除 收款扣除
  2221. if (! empty ( $invoiceDetails ['irid'] )) {
  2222. $iridList = explode ( ',', $invoiceDetails ['irid'] );
  2223. foreach ( $iridList as $value ) {
  2224. $invoiceReceivables = new invoiceReceivables ();
  2225. $irDetails = $invoiceReceivables->getOne ( array (
  2226. 'where' => " irid=" . $value . ' and bindStatus=1',
  2227. 'asArray' => TRUE
  2228. ) );
  2229. $item = array (
  2230. 'irid' => $value,
  2231. 'bindStatus' => 0,
  2232. 'untreadStatus' => 1,
  2233. 'untreadStaff' => $invoiceDetails ['userName'],
  2234. 'unbundlingTime' => date ( "Y-m-d H:i:s" ),
  2235. 'iid' => 0
  2236. );
  2237. $invoiceReceivables->setInvoiceReceivablesByCondition ( $item );
  2238. if (! empty ( $irDetails )) {
  2239. // 扣除入账
  2240. $invoiceStatistics = new invoiceStatistics ();
  2241. $item = array (
  2242. 'date' => date ( 'Y-m-d', strtotime ( $irDetails ['receivablesDate'] ) ),
  2243. 'priceClass' => 3,
  2244. 'cid' => $invoiceDetails ['cid'],
  2245. 'staff' => $invoiceDetails ['sid'],
  2246. 'accountPrice' => - $irDetails ['receivablesPrice']
  2247. );
  2248. $invoiceStatistics->setInvoiceStatisticsByCondition ( $item );
  2249. // 扣除收款
  2250. $invoiceStatistics = new invoiceStatistics ();
  2251. $item = array (
  2252. 'date' => date ( 'Y-m-d', strtotime ( $irDetails ['receivablesDate'] ) ),
  2253. 'priceClass' => 2,
  2254. 'cid' => $invoiceDetails ['cid'],
  2255. 'staff' => $invoiceDetails ['sid'],
  2256. 'irid' => $irDetails ['irid'],
  2257. 'receivablesPrice' => - $irDetails ['receivablesPrice']
  2258. );
  2259. $invoiceStatistics->setInvoiceStatisticsByCondition ( $item );
  2260. }
  2261. }
  2262. }
  2263. return "/invoiceUntread";
  2264. }
  2265. /**
  2266. * 建立负票,关联原来发票
  2267. */
  2268. function invoiceLossDo() {
  2269. $iidKey = $this->get_args ( 'iidKey' ) ? $this->get_args ( 'iidKey' ) : "";
  2270. if (! empty ( $iidKey )) {
  2271. Doo::loadClass ( 'XDeode' );
  2272. $XDeode = new XDeode ( 5 );
  2273. Doo::loadModel ( 'invoice' );
  2274. $invoice = new invoice ();
  2275. Doo::loadModel ( 'invoiceOperationLog' );
  2276. $invoiceOperationLog = new invoiceOperationLog ();
  2277. $iidKey = $XDeode->decode ( $iidKey );
  2278. $invoiceDetail = $invoice->getInvoiceByIid ( $iidKey );
  2279. // 拷贝插入一条发票数据
  2280. $iid = $invoice->setInvoiceLoss ( $iidKey );
  2281. // 更新负票
  2282. $invoiceSerial = "#F" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  2283. $invoice = new invoice ();
  2284. $item = array (
  2285. 'iid' => $iid,
  2286. 'sid' => $this->staff [0] ['sid'],
  2287. 'userName' => $this->staff [0] ['username'],
  2288. 'cid' => $this->staff [0] ['cid'],
  2289. 'categoryName' => $this->staff [0] ['category'],
  2290. 'invoiceQuantity' => - $invoiceDetail ['invoiceQuantity'],
  2291. 'invoicePrice' => - $invoiceDetail ['invoicePrice'],
  2292. 'invoiceSerial' => $invoiceSerial,
  2293. 'invoiceNo' => '',
  2294. 'printStatus' => 0,
  2295. 'untreadStatus' => 4,
  2296. // 关联发票号
  2297. 'lossIid' => $invoiceDetail ['iid']
  2298. );
  2299. $invoice->setInvoiceByCondition ( $item );
  2300. // 更新原发票
  2301. $invoice = new invoice ();
  2302. $item = array (
  2303. 'iid' => $invoiceDetail ['iid'],
  2304. 'lossIid' => $iid
  2305. );
  2306. $invoice->setInvoiceByCondition ( $item );
  2307. // 操作日志
  2308. $item = array (
  2309. 'date' => date ( "Y-m-d H:i:s" ),
  2310. 'operation' => "创建负票" . $invoiceSerial,
  2311. 'status' => 12,
  2312. 'img' => $this->staff [0] ['avatar'],
  2313. 'username' => $this->staff [0] ['username'],
  2314. 'uid' => $this->staff [0] ['sid'],
  2315. 'category' => $this->staff [0] ['category'],
  2316. 'iid' => $iid
  2317. );
  2318. $invoiceOperationLog->setInvoiceOperationLog ( $item );
  2319. // print_r($invoiceDetail);
  2320. // echo $iid;die;
  2321. }
  2322. return '/invoiceUntread';
  2323. }
  2324. function invoiceReceivables() {
  2325. $invoiceTC = $this->get_args ( 'invoiceTC' ) ? $this->get_args ( 'invoiceTC' ) : '';
  2326. Doo::loadModel ( 'L_category' );
  2327. $lCategory = new L_category ();
  2328. Doo::loadModel ( 'staff' );
  2329. $staff = new staff ();
  2330. Doo::loadModel ( 'invoiceReceivables' );
  2331. $invoiceReceivables = new invoiceReceivables ();
  2332. Doo::loadModel ( 'invoice' );
  2333. $invoice = new invoice ();
  2334. Doo::loadClass ( 'XDeode' );
  2335. $XDeode = new XDeode ( 5 );
  2336. $category = $lCategory->getCategory ();
  2337. $staffList = $staff->getStaffByCid ( $this->staff [0] ['cid'] );
  2338. $sql = 'bindStatus=1 and iid!=0';
  2339. $receivablesList = $invoiceReceivables->getInvoiceReceivablesByNew ( 4, $sql );
  2340. // 获取未入账发票
  2341. $invoiceUnAccount = $invoice->getInvoiceByUnAccount ( $invoiceTC );
  2342. $invoiceExistAccount = $invoice->getInvoiceByUnAccount ( '', true );
  2343. foreach ( $invoiceUnAccount as $key => $value ) {
  2344. $invoiceUnAccount [$key] ['iidKey'] = $XDeode->encode ( $value ['iid'] );
  2345. $lastApprover = json_decode ( $value ['processApprovals'], true );
  2346. if (! empty ( $lastApprover )) {
  2347. $lastApproverKey = array_keys ( $lastApprover );
  2348. $lastApprover = end ( $lastApprover );
  2349. $staffDetail = $staff->getOne ( array (
  2350. 'where' => 'sid=' . end ( $lastApproverKey ),
  2351. 'asArray' => true
  2352. ) );
  2353. $lastApprover ['username'] = $staffDetail ['username'];
  2354. }
  2355. $invoiceUnAccount [$key] ['lastApprover'] = $lastApprover;
  2356. }
  2357. foreach ( $invoiceExistAccount as $key => $value ) {
  2358. $irList = $invoiceReceivables->getInvoiceReceivablesInIridString ( $value ['irid'] );
  2359. if (empty ( $irList ))
  2360. $irList [0] ['sumPrice'] = 0;
  2361. $balance = $value ['invoicePrice'] - $irList [0] ['sumPrice'];
  2362. $invoiceExistAccount [$key] ['existAccount'] = $irList [0] ['sumPrice'];
  2363. $invoiceExistAccount [$key] ['balance'] = $balance;
  2364. }
  2365. $receivablesInput = $invoiceReceivables->getInvoiceReceivablesByInput ();
  2366. // print_r($receivablesList);
  2367. $this->data ['receivablesDate'] = date ( "Y-m-d" );
  2368. $this->data ['ieaCount'] = count ( $invoiceExistAccount );
  2369. $this->data ['invoiceExistAccount'] = $invoiceExistAccount;
  2370. $this->data ['receivablesInput'] = $receivablesInput;
  2371. $this->data ['year'] = date ( 'Y' );
  2372. $this->data ['invoiceUnAccount'] = $invoiceUnAccount;
  2373. $this->data ['receivablesList'] = $receivablesList;
  2374. $this->data ['staffList'] = $staffList;
  2375. $this->data ['category'] = $category;
  2376. $this->data ['memu'] = "invoice";
  2377. $this->data ['staff'] = $this->staff;
  2378. $this->data ['receiptMemu'] = 'invoiceReceivables';
  2379. $this->render ( "/admin/invoiceReceivables", $this->data );
  2380. }
  2381. /**
  2382. * 新添加收款直接入账发票
  2383. */
  2384. function invoiceCompareClaimPrice() {
  2385. // 收款录入
  2386. $iidKey = $this->get_args ( 'iidKey' ) ? $this->get_args ( 'iidKey' ) : "";
  2387. $receivablesPrice = $this->get_args ( 'receivablesPrice' ) ? $this->get_args ( 'receivablesPrice' ) : "";
  2388. $receivablesMessage = $this->get_args ( 'receivablesMessage' ) ? $this->get_args ( 'receivablesMessage' ) : "";
  2389. $receivablesBank = $this->get_args ( 'receivablesBank' ) ? $this->get_args ( 'receivablesBank' ) : "";
  2390. $receivablesDate = $this->get_args ( 'receivablesDate' ) ? $this->get_args ( 'receivablesDate' ) : "";
  2391. if (! empty ( $receivablesPrice ) && ! empty ( $receivablesMessage ) && ! empty ( $receivablesBank ) && ! empty ( $receivablesDate ) && ! empty ( $iidKey )) {
  2392. Doo::loadModel ( 'invoiceReceivables' );
  2393. $invoiceReceivables = new invoiceReceivables ();
  2394. Doo::loadModel ( 'invoiceROLog' );
  2395. $invoiceROLog = new invoiceROLog ();
  2396. Doo::loadModel ( 'invoiceStatistics' );
  2397. Doo::loadModel ( 'invoice' );
  2398. $invoice = new invoice ();
  2399. Doo::loadClass ( 'XDeode' );
  2400. $XDeode = new XDeode ( 5 );
  2401. Doo::loadModel ( 'invoiceOperationLog' );
  2402. $invoiceOperationLog = new invoiceOperationLog ();
  2403. $iidKey = $XDeode->decode ( $iidKey );
  2404. $invoiceDetail = $invoice->getInvoiceByIid ( $iidKey );
  2405. if (! ($invoiceDetail ['status'] == 2 && $invoiceDetail ['printStatus'] == 1 && $invoiceDetail ['untreadStatus'] == 0))
  2406. die ( 'illegal request' );
  2407. $receivablesSerial = "#SK" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  2408. // 收款录入 并绑定发票
  2409. Doo::db ()->beginTransaction ();
  2410. $item = array (
  2411. 'bindStatus' => 1,
  2412. 'iid' => $invoiceDetail ['iid'],
  2413. 'bindDate' => date ( "Y-m-d H:i:s" ),
  2414. 'receivablesPrice' => $receivablesPrice,
  2415. 'receivablesMessage' => $receivablesMessage,
  2416. 'receivablesSerial' => $receivablesSerial,
  2417. 'receivablesBank' => $receivablesBank,
  2418. 'receivablesDate' => $receivablesDate,
  2419. 'inputStaff' => $this->staff [0] ['username'],
  2420. 'accountClerk' => $this->staff [0] ['username'],
  2421. 'date' => date ( "Y-m-d" ),
  2422. 'receivablesCategory' => $invoiceDetail ['cid'] . ':' . $invoiceDetail ['categoryName'],
  2423. 'receivablesStaff' => $invoiceDetail ['sid'] . '-' . $invoiceDetail ['userName'],
  2424. 'confirmTime' => date ( "Y-m-d H:i:s" )
  2425. );
  2426. $irid = $invoiceReceivables->addInvoiceReceivables ( $item );
  2427. $item = array ();
  2428. // 收款操作日志
  2429. $item = array (
  2430. 'operation' => $this->staff [0] ['username'] . " 转入 " . $invoiceDetail ['userName']
  2431. );
  2432. $item += array (
  2433. 'date' => date ( "Y-m-d" ),
  2434. 'status' => 1,
  2435. 'img' => $this->staff [0] ['avatar'],
  2436. 'username' => $this->staff [0] ['username'],
  2437. 'uid' => $this->staff [0] ['sid'],
  2438. 'category' => $this->staff [0] ['category'],
  2439. 'irid' => $irid
  2440. );
  2441. $invoiceROLog->setInvoiceROLog ( $item );
  2442. // 收款统计
  2443. $invoiceStatistics = new invoiceStatistics ();
  2444. $item = array (
  2445. 'date' => $receivablesDate,
  2446. 'priceClass' => 2,
  2447. 'irid' => $irid,
  2448. 'cid' => $invoiceDetail ['cid'],
  2449. 'staff' => $invoiceDetail ['sid'],
  2450. 'receivablesPrice' => $receivablesPrice
  2451. );
  2452. $invoiceStatistics->setInvoiceStatisticsByCondition ( $item );
  2453. // 收款 入 发票
  2454. $detail = $invoiceDetail;
  2455. $iridString = "";
  2456. if (empty ( $detail ['irid'] ))
  2457. $iridString = $irid;
  2458. else
  2459. $iridString = $detail ['irid'] . ',' . $irid;
  2460. $item = array (
  2461. 'irid' => $iridString,
  2462. 'bindTime' => date ( "Y-m-d H:i:s" ),
  2463. 'updateTime' => date ( "Y-m-d H:i:s" ),
  2464. 'iid' => $detail ['iid']
  2465. );
  2466. $invoiceReceivables = new invoiceReceivables ();
  2467. $sum = $invoiceReceivables->getSumOfReceivablesPrice ( $iridString );
  2468. if ($detail ['invoicePrice'] <= $sum)
  2469. $item += array (
  2470. 'untreadStatus' => 3
  2471. );
  2472. $invoice->setInvoiceByCondition ( $item );
  2473. // 操作日志
  2474. $item = array (
  2475. 'date' => date ( "Y-m-d H:i:s" ),
  2476. 'operation' => "收款入账" . $receivablesSerial . "到发票" . $detail ['invoiceSerial'],
  2477. 'status' => 8,
  2478. 'img' => $this->staff [0] ['avatar'],
  2479. 'username' => $this->staff [0] ['username'],
  2480. 'uid' => $this->staff [0] ['sid'],
  2481. 'category' => $this->staff [0] ['category'],
  2482. 'iid' => $detail ['iid']
  2483. );
  2484. $invoiceOperationLog->setInvoiceOperationLog ( $item );
  2485. // 入账汇总
  2486. $invoiceStatistics = new invoiceStatistics ();
  2487. // $list = $invoiceReceivables->getInvoiceReceivablesInIridString ( $iridString );
  2488. // $accountPrice = 0;
  2489. // foreach ( $list as $key => $value ) {
  2490. // $accountPrice += $value ['receivablesPrice'];
  2491. // }
  2492. $item = array (
  2493. 'date' => $receivablesDate,
  2494. 'priceClass' => 3,
  2495. 'cid' => $invoiceDetail ['cid'],
  2496. 'staff' => $invoiceDetail ['sid'],
  2497. 'accountPrice' => $receivablesPrice
  2498. );
  2499. $invoiceStatistics->setInvoiceStatisticsByCondition ( $item );
  2500. Doo::db ()->commit ();
  2501. }
  2502. return '/invoiceReceivables';
  2503. }
  2504. /**
  2505. * 检索未入账发票数据 function sir() { }
  2506. */
  2507. /**
  2508. * 录入收款数据
  2509. * @return string
  2510. */
  2511. function invoiceReceivablesDo() {
  2512. $receivablesPrice = $this->get_args ( 'receivablesPrice' ) ? $this->get_args ( 'receivablesPrice' ) : "";
  2513. $receivablesMessage = $this->get_args ( 'receivablesMessage' ) ? $this->get_args ( 'receivablesMessage' ) : "";
  2514. $receivablesBank = $this->get_args ( 'receivablesBank' ) ? $this->get_args ( 'receivablesBank' ) : "";
  2515. $receivablesDate = $this->get_args ( 'receivablesDate' ) ? $this->get_args ( 'receivablesDate' ) : "";
  2516. $receivablesCategory = $this->get_args ( 'receivablesCategory' ) ? $this->get_args ( 'receivablesCategory' ) : "";
  2517. $receivablesStaff = $receivablesStaff2 = $this->get_args ( 'receivablesStaff' ) ? $this->get_args ( 'receivablesStaff' ) : "";
  2518. Doo::loadModel ( 'invoiceReceivables' );
  2519. $invoiceReceivables = new invoiceReceivables ();
  2520. Doo::loadModel ( 'invoiceROLog' );
  2521. $invoiceROLog = new invoiceROLog ();
  2522. Doo::loadModel ( 'invoiceStatistics' );
  2523. $invoiceStatistics = new invoiceStatistics ();
  2524. if (! empty ( $receivablesPrice ) && ! empty ( $receivablesMessage ) && ! empty ( $receivablesBank ) && ! empty ( $receivablesDate ) && ! empty ( $receivablesCategory ) && ! empty ( $receivablesStaff )) {
  2525. $item = array (
  2526. 'receivablesPrice' => $receivablesPrice,
  2527. 'receivablesMessage' => $receivablesMessage,
  2528. 'receivablesSerial' => "#SK" . date ( "Ymd" ) . mt_rand ( 1000, 9999 ),
  2529. 'receivablesBank' => $receivablesBank,
  2530. 'receivablesDate' => $receivablesDate,
  2531. 'inputStaff' => $this->staff [0] ['username'],
  2532. 'date' => date ( "Y-m-d" ),
  2533. 'receivablesCategory' => $receivablesCategory,
  2534. 'receivablesStaff' => $receivablesStaff
  2535. );
  2536. if ($receivablesCategory != 'PUBLIC') {
  2537. $item += array (
  2538. 'confirmTime' => date ( "Y-m-d H:i:s" ),
  2539. 'inputType' => 1
  2540. );
  2541. }
  2542. $irid = $invoiceReceivables->addInvoiceReceivables ( $item );
  2543. $item = array ();
  2544. // 收款操作日志
  2545. if ($receivablesCategory == 'PUBLIC' && $receivablesStaff == 'PUBLIC')
  2546. $item = array (
  2547. 'operation' => $this->staff [0] ['username'] . " 转入 公共待认领款项 "
  2548. );
  2549. elseif ($receivablesCategory != 'PUBLIC' && $receivablesStaff == 'PUBLIC')
  2550. $item = array (
  2551. 'operation' => $this->staff [0] ['username'] . "转入 办事处待认领款项"
  2552. );
  2553. elseif ($receivablesCategory != 'PUBLIC' && $receivablesStaff != 'PUBLIC') {
  2554. $receivablesStaff = explode ( '-', $receivablesStaff );
  2555. $item = array (
  2556. 'operation' => $this->staff [0] ['username'] . " 转入 " . $receivablesStaff [1]
  2557. );
  2558. }
  2559. $item += array (
  2560. 'date' => date ( "Y-m-d" ),
  2561. 'status' => 1,
  2562. 'img' => $this->staff [0] ['avatar'],
  2563. 'username' => $this->staff [0] ['username'],
  2564. 'uid' => $this->staff [0] ['sid'],
  2565. 'category' => $this->staff [0] ['category'],
  2566. 'irid' => $irid
  2567. );
  2568. $invoiceROLog->setInvoiceROLog ( $item );
  2569. $item = array (
  2570. 'date' => $receivablesDate,
  2571. 'priceClass' => 2,
  2572. 'irid' => $irid,
  2573. 'receivablesPrice' => $receivablesPrice
  2574. );
  2575. if ($receivablesCategory != 'PUBLIC') {
  2576. $receivablesCategory = explode ( ":", $receivablesCategory );
  2577. $item += array (
  2578. 'cid' => $receivablesCategory [0]
  2579. );
  2580. }
  2581. if ($receivablesStaff2 != 'PUBLIC') {
  2582. $receivablesStaff = explode ( "-", $receivablesStaff2 );
  2583. $item += array (
  2584. 'staff' => $receivablesStaff [0]
  2585. );
  2586. }
  2587. $invoiceStatistics->setInvoiceStatisticsByCondition ( $item );
  2588. $toparty = $this->getWxidByCategory ( $receivablesCategory [1] );
  2589. // $toparty = $this->getToparty ( $receivablesCategory [1] );
  2590. $msg = '[通知]财务录入了一笔待认领款项,快到“我的收款”中查看,确认是否是您的客户给您打款了。';
  2591. if ($toparty != 0)
  2592. $this->msgSendToparty ( $msg, '', '', $toparty, 'text' );
  2593. }
  2594. return "/invoiceReceivables";
  2595. }
  2596. /**
  2597. * 收款认领页面-包括公共认领 办事处认领 最近已认领数据
  2598. */
  2599. function invoiceReceivablesClaim() {
  2600. Doo::loadModel ( 'invoiceReceivables' );
  2601. $invoiceReceivables = new invoiceReceivables ();
  2602. $receivablesList = $invoiceReceivables->getInvoiceReceivablesByClaim ( $this->staff [0] ['cid'], $this->staff [0] ['sid'] );
  2603. $this->data ['receivablesList'] = $receivablesList;
  2604. $this->data ['memu'] = "invoice";
  2605. $this->data ['staff'] = $this->staff;
  2606. $this->data ['receiptMemu'] = 'invoiceReceivablesClaim';
  2607. $this->render ( "/admin/invoiceReceivablesClaim", $this->data );
  2608. }
  2609. /**
  2610. * 更新收款相关数据
  2611. */
  2612. function invoiceReceivablesUpdateClaim() {
  2613. $receivablesPrice = $this->get_args ( 'receivablesPrice' ) ? $this->get_args ( 'receivablesPrice' ) : "";
  2614. $receivablesMessage = $this->get_args ( 'receivablesMessage' ) ? $this->get_args ( 'receivablesMessage' ) : "";
  2615. $receivablesBank = $this->get_args ( 'receivablesBank' ) ? $this->get_args ( 'receivablesBank' ) : "";
  2616. $receivablesDate = $this->get_args ( 'receivablesDate' ) ? $this->get_args ( 'receivablesDate' ) : "";
  2617. $receivablesCategory = $this->get_args ( 'receivablesCategory' ) ? $this->get_args ( 'receivablesCategory' ) : "";
  2618. $receivablesStaff = $receivablesStaff2 = $this->get_args ( 'receivablesStaff' ) ? $this->get_args ( 'receivablesStaff' ) : "";
  2619. $claimKey = $this->get_args ( 'claimKey' ) ? $this->get_args ( 'claimKey' ) : "";
  2620. if (empty ( $claimKey ))
  2621. die ( 'illegal request' );
  2622. Doo::loadModel ( 'invoiceReceivables' );
  2623. $invoiceReceivables = new invoiceReceivables ();
  2624. Doo::loadModel ( 'invoiceROLog' );
  2625. $invoiceROLog = new invoiceROLog ();
  2626. $con = ' and iid=0 and bindStatus=0'; // and receivablesCategory!="PUBLIC" and receivablesStaff!="PUBLIC"
  2627. $detail = $invoiceReceivables->getInvoiceReceivablesByIrid ( $claimKey, $con );
  2628. if (empty ( $detail ))
  2629. die ( 'illegal request' );
  2630. $invoiceReceivables = new invoiceReceivables ();
  2631. $item = array (
  2632. 'irid' => $detail ['irid']
  2633. );
  2634. if ($receivablesCategory != 'PUBLIC' && $receivablesStaff != 'PUBLIC') {
  2635. $item += array (
  2636. 'confirmTime' => date ( "Y-m-d H:i:s" )
  2637. );
  2638. }
  2639. if (! empty ( $receivablesCategory ))
  2640. $item += array (
  2641. 'receivablesCategory' => $receivablesCategory
  2642. );
  2643. if (! empty ( $receivablesStaff ))
  2644. $item += array (
  2645. 'receivablesStaff' => $receivablesStaff
  2646. );
  2647. if (! empty ( $receivablesPrice ))
  2648. $item += array (
  2649. 'receivablesPrice' => $receivablesPrice
  2650. );
  2651. if (! empty ( $receivablesMessage ))
  2652. $item += array (
  2653. 'receivablesMessage' => $receivablesMessage
  2654. );
  2655. if (! empty ( $receivablesBank ))
  2656. $item += array (
  2657. 'receivablesBank' => $receivablesBank
  2658. );
  2659. if (! empty ( $receivablesDate ))
  2660. $item += array (
  2661. 'receivablesDate' => $receivablesDate
  2662. );
  2663. $invoiceReceivables->setInvoiceReceivablesByCondition ( $item );
  2664. // 收款操作日志
  2665. $item = array ();
  2666. if ($receivablesCategory == 'PUBLIC' && $receivablesStaff == 'PUBLIC')
  2667. $item = array (
  2668. 'operation' => $this->staff [0] ['username'] . " 转入 公共待认领款项 "
  2669. );
  2670. elseif ($receivablesCategory != 'PUBLIC' && $receivablesStaff == 'PUBLIC')
  2671. $item = array (
  2672. 'operation' => $this->staff [0] ['username'] . "转入 办事处待认领款项"
  2673. );
  2674. elseif ($receivablesCategory != 'PUBLIC' && $receivablesStaff != 'PUBLIC') {
  2675. $receivablesStaff = explode ( '-', $receivablesStaff );
  2676. $item = array (
  2677. 'operation' => $this->staff [0] ['username'] . " 转入 " . $receivablesStaff [1]
  2678. );
  2679. }
  2680. $item += array (
  2681. 'date' => date ( "Y-m-d" ),
  2682. 'status' => 1,
  2683. 'img' => $this->staff [0] ['avatar'],
  2684. 'username' => $this->staff [0] ['username'],
  2685. 'uid' => $this->staff [0] ['sid'],
  2686. 'category' => $this->staff [0] ['category'],
  2687. 'irid' => $detail ['irid']
  2688. );
  2689. $invoiceROLog->setInvoiceROLog ( $item );
  2690. return '/invoiceReceivablesAS';
  2691. }
  2692. function invoiceReceivablesDelete() {
  2693. $claimKey = $this->get_args ( 'claimKey' ) ? $this->get_args ( 'claimKey' ) : "";
  2694. if (empty ( $claimKey ))
  2695. die ( 'illegal request' );
  2696. Doo::loadModel ( 'invoiceReceivables' );
  2697. $invoiceReceivables = new invoiceReceivables ();
  2698. $con = ' and iid=0 and bindStatus=0 and receivablesStaff="PUBLIC"';
  2699. $detail = $invoiceReceivables->getInvoiceReceivablesByIrid ( $claimKey, $con );
  2700. if (empty ( $detail ))
  2701. die ( 'illegal request' );
  2702. $invoiceReceivables->delInvoiceReceivablesByIrid ( $detail ['irid'] );
  2703. return '/invoiceReceivablesAS';
  2704. }
  2705. /**
  2706. * 管理员录入的收款 ,确认认领到谁的名下.统计收款金额
  2707. */
  2708. function invoiceReceivablesAscription() {
  2709. $irid = $this->get_args ( 'key' ) ? $this->get_args ( 'key' ) : "";
  2710. $recepitTitleMark = $this->get_args ( 'recepitTitleMark' ) ? $this->get_args ( 'recepitTitleMark' ) : "";
  2711. Doo::loadModel ( 'invoiceReceivables' );
  2712. $invoiceReceivables = new invoiceReceivables ();
  2713. Doo::loadModel ( 'invoiceROLog' );
  2714. $invoiceROLog = new invoiceROLog ();
  2715. Doo::loadModel ( 'invoiceStatistics' );
  2716. $invoiceStatistics = new invoiceStatistics ();
  2717. $detail = $invoiceReceivables->getInvoiceReceivablesByIrid ( $irid );
  2718. if (! empty ( $detail ) && $detail ['receivablesStaff'] == 'PUBLIC' && ! empty ( $recepitTitleMark )) {
  2719. $item = array (
  2720. 'irid' => $detail ['irid'],
  2721. 'receivablesCategory' => $this->staff [0] ['cid'] . ":" . $this->staff [0] ['category'],
  2722. 'receivablesStaff' => $this->staff [0] ['sid'] . "-" . $this->staff [0] ['username'],
  2723. 'confirmTime' => date ( "Y-m-d H:i:s" ),
  2724. 'recepitTitleMark' => $recepitTitleMark,
  2725. 'source' => 1
  2726. );
  2727. $invoiceReceivables->setInvoiceReceivablesByCondition ( $item );
  2728. $item = array (
  2729. 'date' => date ( "Y-m-d" ),
  2730. 'operation' => $this->staff [0] ['username'] . " 认领 ",
  2731. 'status' => 2,
  2732. 'img' => $this->staff [0] ['avatar'],
  2733. 'username' => $this->staff [0] ['username'],
  2734. 'uid' => $this->staff [0] ['sid'],
  2735. 'category' => $this->staff [0] ['category'],
  2736. 'irid' => $irid
  2737. );
  2738. $invoiceROLog->setInvoiceROLog ( $item );
  2739. $item = array (
  2740. 'cid' => $this->staff [0] ['cid'],
  2741. 'staff' => $this->staff [0] ['sid']
  2742. );
  2743. $invoiceStatistics->updateInvoiceStatisticsByIrid ( $item, $detail ['irid'], 2 );
  2744. }
  2745. return "/invoiceReceivablesClaim";
  2746. }
  2747. /**
  2748. */
  2749. function invoiceMyReceivables() {
  2750. Doo::loadModel ( 'invoiceReceivables' );
  2751. $invoiceReceivables = new invoiceReceivables ();
  2752. Doo::loadModel ( 'invoiceStatistics' );
  2753. $invoiceStatistics = new invoiceStatistics ();
  2754. $isMonth = $invoiceStatistics->getStatisticsByMonth ();
  2755. $year = date ( "Y" );
  2756. $tmp_date = date ( "Ym" );
  2757. $tmp_year = substr ( $tmp_date, 0, 4 );
  2758. $tmp_mon = substr ( $tmp_date, 4, 2 );
  2759. $tmp_forwardmonth = mktime ( 0, 0, 0, $tmp_mon - 1, 1, $tmp_year );
  2760. $fm_forward_month = date ( "m", $tmp_forwardmonth );
  2761. $path = SITE_PATH . $this->INVOICECOLLECTPATH . "invoiceCollect_" . $year . "_" . $fm_forward_month . ".htm";
  2762. $htm = $this->showCache ( $path );
  2763. $list = $invoiceReceivables->getInvoiceReceivablesByClaim ( $this->staff [0] ['cid'], $this->staff [0] ['sid'] );
  2764. $this->data ['isMonth'] = $isMonth;
  2765. $this->data ['htm'] = $htm;
  2766. $this->data ['list'] = $list;
  2767. $this->data ['memu'] = "invoice";
  2768. $this->data ['staff'] = $this->staff;
  2769. $this->data ['receiptMemu'] = 'invoiceMyReceivables';
  2770. $this->render ( "/admin/invoiceMyReceivables", $this->data );
  2771. }
  2772. /**
  2773. * 收款绑定发票 ,一个收款只能绑定一个发票
  2774. */
  2775. function invoiceBindReceivables() {
  2776. $claimKey = $this->get_args ( 'key' ) ? $this->get_args ( 'key' ) : "";
  2777. $invoiceKey = $this->get_args ( 'invoiceKey' ) ? $this->get_args ( 'invoiceKey' ) : "";
  2778. Doo::loadModel ( 'invoice' );
  2779. $invoice = new invoice ();
  2780. Doo::loadModel ( 'invoiceReceivables' );
  2781. $invoiceReceivables = new invoiceReceivables ();
  2782. Doo::loadModel ( 'invoiceOperationLog' );
  2783. $invoiceOperationLog = new invoiceOperationLog ();
  2784. if (empty ( $invoiceKey ) || empty ( $claimKey ))
  2785. die ( 'illegal request' );
  2786. $detail = $invoice->getInvoiceByIid ( $invoiceKey );
  2787. $detailM = $invoiceReceivables->getInvoiceReceivablesByIrid ( $claimKey );
  2788. if (empty ( $detail ) && empty ( $detailM ))
  2789. die ( 'illegal request' );
  2790. if ($detail ['untreadStatus'] == 3)
  2791. die ( 'illegal request' );
  2792. // if ($detailM ['receivablesPrice'] >= $detail ['invoicePrice']) {
  2793. // $price = $detailM ['receivablesPrice'] - $detail ['invoicePrice'];
  2794. // die ( '<p>收款金额超出开票金额 ¥' . $price . '元,请谨慎操作</p><a href="/invoiceMyReceivables">返回</a>' );
  2795. // }
  2796. $invoiceReceivables = new invoiceReceivables ();
  2797. $item = array (
  2798. 'irid' => $detailM ['irid'],
  2799. 'bindStatus' => 1,
  2800. 'iid' => $detail ['iid'],
  2801. 'accountClerk' => $this->staff [0] ['username'],
  2802. 'bindDate' => date ( "Y-m-d H:i:s" )
  2803. );
  2804. $invoiceReceivables->setInvoiceReceivablesByCondition ( $item );
  2805. $iridString = "";
  2806. if (empty ( $detail ['irid'] ))
  2807. $iridString = $detailM ['irid'];
  2808. else
  2809. $iridString = $detail ['irid'] . ',' . $detailM ['irid'];
  2810. $item = array (
  2811. 'iid' => $detail ['iid'],
  2812. 'irid' => $iridString
  2813. );
  2814. $invoiceReceivables = new invoiceReceivables ();
  2815. $sum = $invoiceReceivables->getSumOfReceivablesPrice ( $iridString );
  2816. if ($detail ['invoicePrice'] <= $sum)
  2817. $item += array (
  2818. 'untreadStatus' => 3
  2819. );
  2820. // print_r($item);
  2821. // echo $sum;die;
  2822. $invoice->setInvoiceByCondition ( $item );
  2823. // 操作日志
  2824. $item = array (
  2825. 'date' => date ( "Y-m-d H:i:s" ),
  2826. 'operation' => "收款" . $detailM ['receivablesSerial'] . "入账到发票" . $detail ['invoiceSerial'],
  2827. 'status' => 8,
  2828. 'img' => $this->staff [0] ['avatar'],
  2829. 'username' => $this->staff [0] ['username'],
  2830. 'uid' => $this->staff [0] ['sid'],
  2831. 'category' => $this->staff [0] ['category'],
  2832. 'iid' => $detail ['iid']
  2833. );
  2834. $invoiceOperationLog->setInvoiceOperationLog ( $item );
  2835. Doo::loadModel ( 'invoiceStatistics' );
  2836. $invoiceStatistics = new invoiceStatistics ();
  2837. // $list = $invoiceReceivables->getInvoiceReceivablesInIridString ( $iridString );
  2838. // $accountPrice = 0;
  2839. // foreach ( $list as $key => $value ) {
  2840. // $accountPrice += $value ['receivablesPrice'];
  2841. // }
  2842. $item = array (
  2843. 'date' => $detailM ['receivablesDate'],
  2844. 'priceClass' => 3,
  2845. 'cid' => $detail ['cid'],
  2846. 'staff' => $detail ['sid'],
  2847. 'accountPrice' => $detailM ['receivablesPrice']
  2848. );
  2849. $invoiceStatistics->setInvoiceStatisticsByCondition ( $item );
  2850. return "/invoiceReceivables";
  2851. }
  2852. /**
  2853. * 核销 动作,确认入账统计 发票收款完成--需求更变 废弃 function invoiceEnterReceivables() { $invoiceKey = $this->get_args ( 'key' ) ? $this->get_args ( 'key' ) : ""; // $invoiceClaim = $this->get_args ( 'invoiceClaim' ) ? $this->get_args ( 'invoiceClaim' ) : ""; Doo::loadModel ( 'invoice' ); $invoice = new invoice (); Doo::loadModel ( 'invoiceOperationLog' ); $invoiceOperationLog = new invoiceOperationLog (); Doo::loadModel ( 'invoiceStatistics' ); $invoiceStatistics = new invoiceStatistics (); Doo::loadModel ( 'invoiceReceivables' ); $invoiceReceivables = new invoiceReceivables (); $detail = $invoice->getInvoiceByIid ( $invoiceKey ); if (empty ( $detail )) die ( 'illegal request' ); if (empty ( $detail ['irid'] )) die ( 'illegal request' ); $item = array ( 'untreadStatus' => 3, 'updateTime' => date ( "Y-m-d H:i:s" ), 'iid' => $detail ['iid'] ); $invoice->setInvoiceByCondition ( $item ); // 操作日志 $item = array ( 'date' => date ( "Y-m-d H:i:s" ), 'operation' => "发票" . $detail ['invoiceSerial'] . "收款完成", 'status' => 9, 'img' => $this->staff [0] ['avatar'], 'username' => $this->staff [0] ['username'], 'uid' => $this->staff [0] ['sid'], 'category' => $this->staff [0] ['category'], 'iid' => $detail ['iid'] ); $invoiceOperationLog->setInvoiceOperationLog ( $item ); $list = $invoiceReceivables->getInvoiceReceivablesInIridString ( $detail ['irid'] ); $accountPrice = 0; foreach ( $list as $key => $value ) { $accountPrice += $value ['receivablesPrice']; } $item = array ( 'date' => date ( "Y-m-d H:i:s" ), 'priceClass' => 3, 'cid' => $this->staff [0] ['cid'], 'staff' => $this->staff [0] ['sid'], 'accountPrice' => $accountPrice ); $invoiceStatistics->setInvoiceStatisticsByCondition ( $item ); return "/invoice"; }
  2854. */
  2855. function invoiceAggregate() {
  2856. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  2857. Doo::loadModel ( 'invoiceStatistics' );
  2858. $invoiceStatistics = new invoiceStatistics ();
  2859. Doo::loadModel ( 'L_category' );
  2860. $Lcategory = new L_category ();
  2861. $isList = $invoiceStatistics->getInvoiceStatisticsByYear ( $year );
  2862. $LcategoryList = $Lcategory->getCategory ();
  2863. // print_r($isList);
  2864. $html = ""; // $invoicePriceCategory=0;$receivablesPriceCategory=0;$accountPriceCategory=0;
  2865. foreach ( $LcategoryList as $key => $value ) {
  2866. $html .= '<tr><th><a href="/invoiceAggregateCategory/' . $value ['cidKey'] . '">' . $value ['title'] . '</a></th>';
  2867. $month = 1;
  2868. $invoicePriceYear = 0;
  2869. $receivablesPriceYear = 0;
  2870. $accountPriceYear = 0;
  2871. for(; $month <= 12; $month ++) {
  2872. $flag = true;
  2873. foreach ( $isList ['statisticsMonthCid'] as $k => $v ) {
  2874. if ($value ['cid'] == $v ['cid'] && $month == $v ['month']) {
  2875. $html .= '<td class="taR">¥' . $v ['invoicePrice'] . '</td>
  2876. <td class="taR">¥' . $v ['receivablesPrice'] . '</td>
  2877. <td class="taR"><b>¥' . $v ['accountPrice'] . '</b></td>
  2878. ';
  2879. $invoicePriceYear += $v ['invoicePrice'];
  2880. $receivablesPriceYear += $v ['receivablesPrice'];
  2881. $accountPriceYear += $v ['accountPrice'];
  2882. $flag = false;
  2883. break;
  2884. }
  2885. }
  2886. if ($flag)
  2887. $html .= '<td class="taR"></td>
  2888. <td class="taR"></td>
  2889. <td class="taR"><b></b></td>
  2890. ';
  2891. }
  2892. $html .= '<td class="taR colRed">' . $invoicePriceYear . '</td>
  2893. <td class="taR colOrange">' . $receivablesPriceYear . '</td>
  2894. <td class="taR colGreen"><b>' . $accountPriceYear . '</b></td>
  2895. ';
  2896. $html .= '</tr>';
  2897. }
  2898. $html .= '<tr><th><b class="colGreen">月合计</b></th>';
  2899. $invoicePriceYear = 0;
  2900. $receivablesPriceYear = 0;
  2901. $accountPriceYear = 0;
  2902. for($month = 1; $month <= 12; $month ++) {
  2903. $flag = true;
  2904. foreach ( $isList ['statisticsMonth'] as $k => $v ) {
  2905. if ($month == $v ['month']) {
  2906. $html .= '<td class="taR">¥' . $v ['invoicePrice'] . '</td>
  2907. <td class="taR">¥' . $v ['receivablesPrice'] . '</td>
  2908. <td class="taR"><b>¥' . $v ['accountPrice'] . '</b></td>
  2909. ';
  2910. $invoicePriceYear += $v ['invoicePrice'];
  2911. $receivablesPriceYear += $v ['receivablesPrice'];
  2912. $accountPriceYear += $v ['accountPrice'];
  2913. $flag = false;
  2914. break;
  2915. }
  2916. }
  2917. if ($flag) {
  2918. $html .= '<td class="taR"></td>
  2919. <td class="taR"></td>
  2920. <td class="taR"><b></b></td>
  2921. ';
  2922. }
  2923. }
  2924. $html .= '<td class="taR colRed">' . $invoicePriceYear . '</td>
  2925. <td class="taR colOrange">' . $receivablesPriceYear . '</td>
  2926. <td class="taR colGreen"><b>' . $accountPriceYear . '</b></td>
  2927. ';
  2928. $html .= '</tr>';
  2929. // print_r($isList);
  2930. $this->data ['html'] = $html;
  2931. $this->data ['LcategoryList'] = $LcategoryList;
  2932. $this->data ['isList'] = $isList;
  2933. $this->data ['year'] = $year;
  2934. $this->data ['memu'] = "invoice";
  2935. $this->data ['staff'] = $this->staff;
  2936. $this->data ['receiptMemu'] = 'invoiceAggregate';
  2937. $this->render ( "/admin/invoiceAggregate", $this->data );
  2938. }
  2939. function invoiceAggregateStaff() {
  2940. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  2941. Doo::loadModel ( 'invoiceStatistics' );
  2942. $invoiceStatistics = new invoiceStatistics ();
  2943. Doo::loadModel ( 'L_category' );
  2944. $Lcategory = new L_category ();
  2945. $toteList = $invoiceStatistics->getInvoiceStatisticsByTote ( $year );
  2946. $staffList = $invoiceStatistics->getInvoiceStatisticsByStaff ( $year );
  2947. $cStaff = $Lcategory->getCategoryStaff ();
  2948. $html = '';
  2949. foreach ( $cStaff as $key => $value ) {
  2950. $categoryFir = true;
  2951. foreach ( $value ['staff'] as $k => $v ) {
  2952. if ($categoryFir) {
  2953. $width = count ( $value ['staff'] ) + 1;
  2954. $html .= '<tr><th rowspan="' . $width . '">' . $value ['title'] . ' </th>';
  2955. $categoryFir = false;
  2956. } else
  2957. $html .= '<tr>';
  2958. $html .= '<th>' . $v ['username'] . '</th>';
  2959. $invoicePriceStaffYear = 0;
  2960. $receivablesPriceStaffYear = 0;
  2961. $accountPriceStaffYear = 0;
  2962. for($month = 1; $month <= 12; $month ++) {
  2963. $flag = true;
  2964. foreach ( $staffList ['statisticsMonthStaff'] as $sl => $slv ) {
  2965. if ($v ['sid'] == $slv ['staff'] && $month == $slv ['month']) {
  2966. $html .= '<td class="taR">¥' . $slv ['invoicePrice'] . '</td>
  2967. <td class="taR">¥' . $slv ['receivablesPrice'] . '</td>
  2968. <td class="taR"><b>¥' . $slv ['accountPrice'] . '</b></td>
  2969. ';
  2970. $invoicePriceStaffYear += $slv ['invoicePrice'];
  2971. $receivablesPriceStaffYear += $slv ['receivablesPrice'];
  2972. $accountPriceStaffYear += $slv ['accountPrice'];
  2973. $flag = false;
  2974. break;
  2975. }
  2976. }
  2977. if ($flag)
  2978. $html .= '<td class="taR"></td>
  2979. <td class="taR"></td>
  2980. <td class="taR"><b></b></td>
  2981. ';
  2982. }
  2983. $html .= '<td class="taR colRed">' . $invoicePriceStaffYear . '</td>
  2984. <td class="taR colOrange">' . $receivablesPriceStaffYear . '</td>
  2985. <td class="taR colGreen"><b>' . $accountPriceStaffYear . '</b></td>
  2986. ';
  2987. }
  2988. $html .= '</tr>';
  2989. // 小计
  2990. if (! empty ( $value ['staff'] )) {
  2991. $html .= '<tr><th class="taR">小计</th>';
  2992. $invoicePriceStaffYear = 0;
  2993. $receivablesPriceStaffYear = 0;
  2994. $accountPriceStaffYear = 0;
  2995. for($month = 1; $month <= 12; $month ++) {
  2996. $flag = true;
  2997. foreach ( $staffList ['statisticsMonthCid'] as $smc => $smcv ) {
  2998. if ($value ['cid'] == $smcv ['cid'] && $month == $slv ['month']) {
  2999. $html .= '<td class="taR">¥' . $smcv ['invoicePrice'] . '</td>
  3000. <td class="taR">¥' . $smcv ['receivablesPrice'] . '</td>
  3001. <td class="taR"><b>¥' . $smcv ['accountPrice'] . '</b></td>
  3002. ';
  3003. $invoicePriceStaffYear += $slv ['invoicePrice'];
  3004. $receivablesPriceStaffYear += $slv ['receivablesPrice'];
  3005. $accountPriceStaffYear += $slv ['accountPrice'];
  3006. $flag = false;
  3007. break;
  3008. }
  3009. }
  3010. if ($flag)
  3011. $html .= '<td class="taR"></td>
  3012. <td class="taR"></td>
  3013. <td class="taR"><b></b></td>
  3014. ';
  3015. }
  3016. $html .= '<td class="taR colRed">' . $invoicePriceStaffYear . '</td>
  3017. <td class="taR colOrange">' . $receivablesPriceStaffYear . '</td>
  3018. <td class="taR colGreen"><b>' . $accountPriceStaffYear . '</b></td>
  3019. ';
  3020. $html .= '</tr>';
  3021. }
  3022. }
  3023. $html .= '<tr class="warning"><th colspan="2"><b class="colGreen" >月合计</b></th>';
  3024. $invoicePriceYear = 0;
  3025. $receivablesPriceYear = 0;
  3026. $accountPriceYear = 0;
  3027. for($month = 1; $month <= 12; $month ++) {
  3028. $flag = true;
  3029. foreach ( $staffList ['statisticsMonth'] as $k => $v ) {
  3030. if ($month == $v ['month']) {
  3031. $html .= '<td class="taR colRed">¥' . $v ['invoicePrice'] . '</td>
  3032. <td class="taR colOrange">¥' . $v ['receivablesPrice'] . '</td>
  3033. <td class="taR colGreen"><b>¥' . $v ['accountPrice'] . '</b></td>
  3034. ';
  3035. $invoicePriceYear += $v ['invoicePrice'];
  3036. $receivablesPriceYear += $v ['receivablesPrice'];
  3037. $accountPriceYear += $v ['accountPrice'];
  3038. $flag = false;
  3039. break;
  3040. }
  3041. }
  3042. if ($flag)
  3043. $html .= '<td class="taR"></td>
  3044. <td class="taR"></td>
  3045. <td class="taR"><b></b></td>
  3046. ';
  3047. }
  3048. $html .= '<td class="taR colRed">' . $invoicePriceYear . '</td>
  3049. <td class="taR colOrange">' . $receivablesPriceYear . '</td>
  3050. <td class="taR colGreen"><b>' . $accountPriceYear . '</b></td>
  3051. ';
  3052. $html .= '</tr>';
  3053. $this->data ['html'] = $html;
  3054. $this->data ['isList'] = $toteList;
  3055. $this->data ['year'] = $year;
  3056. $this->data ['memu'] = "invoice";
  3057. $this->data ['staff'] = $this->staff;
  3058. $this->data ['receiptMemu'] = 'invoiceAggregate';
  3059. $this->render ( "/admin/invoiceAggregateStaff", $this->data );
  3060. }
  3061. function invoiceAggregateCategory() {
  3062. Doo::loadClass ( 'XDeode' );
  3063. $XDeode = new XDeode ( 5 );
  3064. $cid = $cidKey = isset ( $this->params ['cid'] ) ? $this->params ['cid'] : "";
  3065. $cid = $XDeode->decode ( $cid );
  3066. if (! is_numeric ( $cid ))
  3067. die ( 'illegal request' );
  3068. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  3069. Doo::loadModel ( 'invoiceStatistics' );
  3070. $invoiceStatistics = new invoiceStatistics ();
  3071. Doo::loadModel ( 'staff' );
  3072. $staff = new staff ();
  3073. $list = $staff->getStaffByCid ( $cid );
  3074. $isCategory = $invoiceStatistics->getInvoiceStatisticsByStaff ( $year, $cid );
  3075. $toteList = $invoiceStatistics->getInvoiceStatisticsByTote ( $year, $cid );
  3076. if (empty ( $list ))
  3077. die ( '该办事处没有成员' );
  3078. $htmlA = $htmlB = $htmlC = $html = '';
  3079. foreach ( $list as $key => $value ) {
  3080. $htmlA = '<tr><th rowspan="3">' . $value ['username'] . '</th><th class="taC">开票</th>';
  3081. $htmlB = '<tr><th class="taC">收款</th>';
  3082. $htmlC = '<tr><th class="taC">入账</th>';
  3083. $invoicePriceStaffYear = 0;
  3084. $receivablesPriceStaffYear = 0;
  3085. $accountPriceStaffYear = 0;
  3086. for($month = 1; $month <= 12; $month ++) {
  3087. $flag = true;
  3088. foreach ( $isCategory ['statisticsMonthStaff'] as $k => $v ) {
  3089. if ($value ['sid'] == $v ['staff'] && $month == $v ['month']) {
  3090. $htmlA .= '<td class="taR">¥' . $v ['invoicePrice'] . '</td>';
  3091. $htmlB .= '<td class="taR">¥' . $v ['receivablesPrice'] . '</td>';
  3092. $htmlC .= '<td class="taR"><b>¥' . $v ['accountPrice'] . '</b></td>';
  3093. $invoicePriceStaffYear += $v ['invoicePrice'];
  3094. $receivablesPriceStaffYear += $v ['receivablesPrice'];
  3095. $accountPriceStaffYear += $v ['accountPrice'];
  3096. $flag = false;
  3097. break;
  3098. }
  3099. }
  3100. if ($flag) {
  3101. $htmlA .= '<td class="taR">-</td>';
  3102. $htmlB .= '<td class="taR">-</td>';
  3103. $htmlC .= '<td class="taR"><b>-</b></td>';
  3104. }
  3105. }
  3106. $htmlA .= '<td class="taR colRed">' . $invoicePriceStaffYear . '</td>';
  3107. $htmlB .= '<td class="taR colOrange">' . $receivablesPriceStaffYear . '</td>';
  3108. $htmlC .= '<td class="taR colGreen"><b>' . $accountPriceStaffYear . '</b></td>';
  3109. $htmlA .= '</tr>';
  3110. $htmlB .= '</tr>';
  3111. $htmlC .= '</tr>';
  3112. $html .= $htmlA . $htmlB . $htmlC;
  3113. }
  3114. $htmlA = $htmlB = $htmlC = "";
  3115. $htmlA = '<tr><th rowspan="3">月合计</th><th class="taC">开票</th>';
  3116. $htmlB = '<tr><th class="taC">收款</th>';
  3117. $htmlC = '<tr><th class="taC">入账</th>';
  3118. $invoicePriceStaffYear = 0;
  3119. $receivablesPriceStaffYear = 0;
  3120. $accountPriceStaffYear = 0;
  3121. for($month = 1; $month <= 12; $month ++) {
  3122. $flag = true;
  3123. foreach ( $isCategory ['statisticsMonth'] as $k => $v ) {
  3124. if ($month == $v ['month']) {
  3125. $htmlA .= '<td class="taR colRed">¥' . $v ['invoicePrice'] . '</td>';
  3126. $htmlB .= '<td class="taR colOrange">¥' . $v ['receivablesPrice'] . '</td>';
  3127. $htmlC .= '<td class="taR colGreen"><b>¥' . $v ['accountPrice'] . '</b></td>';
  3128. $invoicePriceStaffYear += $v ['invoicePrice'];
  3129. $receivablesPriceStaffYear += $v ['receivablesPrice'];
  3130. $accountPriceStaffYear += $v ['accountPrice'];
  3131. $flag = false;
  3132. break;
  3133. }
  3134. }
  3135. if ($flag) {
  3136. $htmlA .= '<td class="taR">-</td>';
  3137. $htmlB .= '<td class="taR">-</td>';
  3138. $htmlC .= '<td class="taR"><b>-</b></td>';
  3139. }
  3140. }
  3141. $htmlA .= '<td class="taR colRed">' . $invoicePriceStaffYear . '</td>';
  3142. $htmlB .= '<td class="taR colOrange">' . $receivablesPriceStaffYear . '</td>';
  3143. $htmlC .= '<td class="taR colGreen"><b>' . $accountPriceStaffYear . '</b></td>';
  3144. $htmlA .= '</tr>';
  3145. $htmlB .= '</tr>';
  3146. $htmlC .= '</tr>';
  3147. $html .= $htmlA . $htmlB . $htmlC;
  3148. $this->data ['html'] = $html;
  3149. $this->data ['cidKey'] = $cidKey;
  3150. $this->data ['slist'] = $list;
  3151. $this->data ['isList'] = $toteList;
  3152. $this->data ['year'] = $year;
  3153. $this->data ['memu'] = "invoice";
  3154. $this->data ['staff'] = $this->staff;
  3155. $this->data ['receiptMemu'] = 'invoiceAggregate';
  3156. $this->render ( "/admin/invoiceAggregateCategory", $this->data );
  3157. }
  3158. function invoiceAchieve() {
  3159. Doo::loadModel ( 'invoice' );
  3160. $invoice = new invoice ();
  3161. Doo::loadClass ( 'XDeode' );
  3162. $XDeode = new XDeode ( 5 );
  3163. $sid = $XDeode->decode ( $_COOKIE ["staff"] );
  3164. $MebSea = isset ( $this->params ['MebSea'] ) ? urldecode ( $this->params ['MebSea'] ) : '';
  3165. $page_size = 18;
  3166. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  3167. $date = isset ( $this->params ['date'] ) ? $this->params ['date'] : 'MONTHO';
  3168. $get = "/" . $date;
  3169. $con = '';
  3170. if ($date == 'MONTHO')
  3171. $con = ' and updateTime>DATE_SUB(CURDATE(), INTERVAL 1 MONTH)';
  3172. elseif ($date == 'MONTHT')
  3173. $con = ' and updateTime>DATE_SUB(CURDATE(), INTERVAL 3 MONTH)';
  3174. elseif ($date == 'MONTHY')
  3175. $con = ' and updateTime>DATE_SUB(CURDATE(), INTERVAL 1 YEAR)';
  3176. if (! empty ( $MebSea )) {
  3177. $con .= ' and ( invoiceTitle like "%' . $MebSea . '%" or invoiceCompany like "%' . $MebSea . '%" or invoicePrice like "%' . $MebSea . '%" )';
  3178. $get .= "/" . $MebSea;
  3179. }
  3180. $pageinfo ['page'] = array (
  3181. 'previous' => ''
  3182. );
  3183. $sql = 'status=2 and printStatus=1 and irid!="" and ( untreadStatus=3 or untreadStatus=0 ) and sid=' . $sid . $con;
  3184. $pageinfo = $this->get_page ( "CLD_invoice", $sql, $page, $page_size, "invoiceAchieve", $get, "" );
  3185. $limit = $pageinfo ['lower'] . ',' . $page_size;
  3186. $list = $invoice->getInvoiceByUntreadStatusPage ( $limit, $sql );
  3187. // print_r($pageinfo);
  3188. $this->data ['MebSeaEn'] = $MebSea;
  3189. $this->data ['MebSea'] = urlencode ( $MebSea );
  3190. $this->data ['get'] = $get;
  3191. $this->data ['page'] = $pageinfo;
  3192. $this->data ['list'] = $list;
  3193. $this->data ['date'] = $date;
  3194. $this->data ['memu'] = "invoice";
  3195. $this->data ['staff'] = $this->staff;
  3196. $this->data ['receiptMemu'] = 'invoice';
  3197. $this->render ( "/admin/invoiceAchieve", $this->data );
  3198. }
  3199. function invoiceMyUnAccountAchieve() {
  3200. Doo::loadModel ( 'invoice' );
  3201. $invoice = new invoice ();
  3202. Doo::loadClass ( 'XDeode' );
  3203. $XDeode = new XDeode ( 5 );
  3204. Doo::loadModel ( 'staff' );
  3205. $staff = new staff ();
  3206. $sid = $XDeode->decode ( $_COOKIE ["staff"] );
  3207. $MebSea = $this->get_args ( 'MebSea' ) ? $this->get_args ( 'MebSea' ) : "";
  3208. $page_size = 18;
  3209. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  3210. $date = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "";
  3211. $get = "?date=" . urlencode ( $date ) . "&MebSea=" . urlencode ( $MebSea );
  3212. $dateArr = explode ( ':', $date );
  3213. $D1 = '';
  3214. $D2 = '';
  3215. if (! empty ( $date )) {
  3216. $D1 = $dateArr [0];
  3217. $D2 = $dateArr [1];
  3218. }
  3219. $con = '';
  3220. if (! empty ( $D1 ) && ! empty ( $D2 ))
  3221. $con = ' and printTime BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
  3222. if (! empty ( $MebSea )) {
  3223. $con .= ' and ( invoiceTitle like "%' . $MebSea . '%" or invoiceCompany like "%' . $MebSea . '%" or invoicePrice like "%' . $MebSea . '%" )';
  3224. }
  3225. $pageinfo ['page'] = array (
  3226. 'previous' => ''
  3227. );
  3228. // and irid='' and ( (doPost=1 and postStatus=1) or doPost=0 )
  3229. $sql = " status=2 and printStatus=1 and untreadStatus=0 and isDelete=0 and sid= " . $sid . $con;
  3230. $action = "invoiceMyUnAccountAchieve";
  3231. $pageinfo = $this->get_page ( "CLD_invoice", $sql, $page, $page_size, $action, $get, "" );
  3232. $limit = $pageinfo ['lower'] . ',' . $page_size;
  3233. $list = $invoice->getInvoiceByUntreadStatusPage ( $limit, $sql );
  3234. Doo::loadModel ( 'express' );
  3235. $express = new express ();
  3236. $expressList = $express->getExpressByAll ();
  3237. $this->data ['expressList'] = $expressList;
  3238. // print_r($list);
  3239. $this->data ['MebSeaEn'] = $MebSea;
  3240. $this->data ['get'] = $get;
  3241. $this->data ['page'] = $pageinfo;
  3242. $this->data ['date'] = $date;
  3243. $this->data ['list'] = $list;
  3244. $this->data ['memu'] = "invoice";
  3245. $this->data ['staff'] = $this->staff;
  3246. $this->data ['receiptMemu'] = 'invoice';
  3247. $this->render ( "/admin/invoiceMyUnAccountAchieve", $this->data );
  3248. }
  3249. function invoiceReceivablesAchieve() {
  3250. Doo::loadModel ( 'invoiceReceivables' );
  3251. $invoiceReceivables = new invoiceReceivables ();
  3252. Doo::loadClass ( 'XDeode' );
  3253. $XDeode = new XDeode ( 5 );
  3254. $sid = $XDeode->decode ( $_COOKIE ["staff"] );
  3255. $MebSea = isset ( $this->params ['MebSea'] ) ? urldecode ( $this->params ['MebSea'] ) : '';
  3256. $page_size = 1;
  3257. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  3258. $date = isset ( $this->params ['date'] ) ? $this->params ['date'] : 'MONTHO';
  3259. $get = "/" . $date;
  3260. $con = '';
  3261. if ($date == 'MONTHO')
  3262. $con = ' and bindDate>DATE_SUB(CURDATE(), INTERVAL 1 MONTH)';
  3263. elseif ($date == 'MONTHT')
  3264. $con = ' and bindDate>DATE_SUB(CURDATE(), INTERVAL 3 MONTH)';
  3265. elseif ($date == 'MONTHY')
  3266. $con = ' and bindDate>DATE_SUB(CURDATE(), INTERVAL 1 YEAR)';
  3267. if (! empty ( $MebSea )) {
  3268. $con .= ' and ( receivablesMessage like "%' . $MebSea . '%" or receivablesPrice like "%' . $MebSea . '%" )';
  3269. $get .= "/" . $MebSea;
  3270. }
  3271. $pageinfo ['page'] = array (
  3272. 'previous' => ''
  3273. );
  3274. $sql = " bindStatus=1 and receivablesStaff like '" . $sid . "_%' " . $con;
  3275. $pageinfo = $this->get_page ( "CLD_invoiceReceivables", $sql, $page, $page_size, "invoiceReceivablesAchieve", $get, "" );
  3276. $limit = $pageinfo ['lower'] . ',' . $page_size;
  3277. $list = $invoiceReceivables->getReceivablesByUntreadStatusPage ( $limit, $sql );
  3278. // print_r($pageinfo);
  3279. $this->data ['MebSeaEn'] = $MebSea;
  3280. $this->data ['MebSea'] = urlencode ( $MebSea );
  3281. $this->data ['get'] = $get;
  3282. $this->data ['page'] = $pageinfo;
  3283. $this->data ['list'] = $list;
  3284. $this->data ['date'] = $date;
  3285. $this->data ['memu'] = "invoice";
  3286. $this->data ['staff'] = $this->staff;
  3287. $this->data ['receiptMemu'] = 'invoiceMyReceivables';
  3288. $this->render ( "/admin/invoiceReceivablesAchieve", $this->data );
  3289. }
  3290. /**
  3291. * 收款解绑
  3292. */
  3293. function invoiceUnBundLing() {
  3294. $unBundKey = $this->get_args ( 'unBundKey' ) ? $this->get_args ( 'unBundKey' ) : '';
  3295. Doo::loadModel ( 'invoice' );
  3296. $invoice = new invoice ();
  3297. Doo::loadModel ( 'invoiceReceivables' );
  3298. $invoiceReceivables = new invoiceReceivables ();
  3299. Doo::loadModel ( 'invoiceOperationLog' );
  3300. $invoiceOperationLog = new invoiceOperationLog ();
  3301. Doo::loadModel ( 'invoiceROLog' );
  3302. $invoiceROLog = new invoiceROLog ();
  3303. Doo::loadModel ( 'invoiceStatistics' );
  3304. $irid = $invoice->authcode ( $unBundKey );
  3305. if (! empty ( $irid ) && ! is_numeric ( $irid ))
  3306. die ( 'illegal request' );
  3307. $irDetails = $invoiceReceivables->getInvoiceReceivablesByIrid ( $irid );
  3308. $invoiceDetails = $invoice->getInvoiceByIid ( $irDetails ['iid'] );
  3309. if (empty ( $irDetails ) || $irDetails ['bindStatus'] == 0 || $invoiceDetails ['untreadStatus'] == 2)
  3310. die ( 'illegal request' );
  3311. // 收款
  3312. $item = array (
  3313. 'irid' => $irDetails ['irid'],
  3314. 'bindStatus' => 0,
  3315. 'iid' => 0
  3316. );
  3317. $invoiceReceivables->setInvoiceReceivablesByCondition ( $item );
  3318. // 收款操作日志
  3319. $item = array (
  3320. 'operation' => $this->staff [0] ['username'] . " 解绑 " . $irDetails ['receivablesSerial'],
  3321. 'date' => date ( "Y-m-d" ),
  3322. 'status' => 3,
  3323. 'img' => $this->staff [0] ['avatar'],
  3324. 'username' => $this->staff [0] ['username'],
  3325. 'uid' => $this->staff [0] ['sid'],
  3326. 'category' => $this->staff [0] ['category'],
  3327. 'irid' => $irid
  3328. );
  3329. $invoiceROLog->setInvoiceROLog ( $item );
  3330. // 扣除入账统计金额
  3331. $invoiceStatistics = new invoiceStatistics ();
  3332. $item = array (
  3333. 'date' => date ( 'Y-m-d', strtotime ( $irDetails ['receivablesDate'] ) ),
  3334. 'priceClass' => 3,
  3335. 'cid' => $invoiceDetails ['cid'],
  3336. 'staff' => $invoiceDetails ['sid'],
  3337. 'accountPrice' => - $irDetails ['receivablesPrice']
  3338. );
  3339. $invoiceStatistics->setInvoiceStatisticsByCondition ( $item );
  3340. // 扣除收款统计金额
  3341. $invoiceStatistics = new invoiceStatistics ();
  3342. $item = array (
  3343. 'date' => date ( 'Y-m-d', strtotime ( $irDetails ['receivablesDate'] ) ),
  3344. 'priceClass' => 2,
  3345. 'cid' => $invoiceDetails ['cid'],
  3346. 'staff' => $invoiceDetails ['sid'],
  3347. 'irid' => $irDetails ['irid'],
  3348. 'receivablesPrice' => - $irDetails ['receivablesPrice']
  3349. );
  3350. $invoiceStatistics->setInvoiceStatisticsByCondition ( $item );
  3351. // 发票解绑去收款ID
  3352. $iridString = $invoiceDetails ['irid'];
  3353. if (! empty ( $invoiceDetails ['irid'] )) {
  3354. $list = explode ( ',', $invoiceDetails ['irid'] );
  3355. foreach ( $list as $key => $value ) {
  3356. if ($value == $irDetails ['irid']) {
  3357. unset ( $list [$key] );
  3358. break;
  3359. }
  3360. }
  3361. $iridString = implode ( ",", $list );
  3362. }
  3363. $item = array (
  3364. 'iid' => $invoiceDetails ['iid'],
  3365. 'irid' => $iridString,
  3366. 'updateTime' => date ( "Y-m-d H:i:s" )
  3367. );
  3368. if ($invoiceDetails ['untreadStatus'] == 3)
  3369. $item += array (
  3370. 'untreadStatus' => 0
  3371. );
  3372. $invoice->setInvoiceByCondition ( $item );
  3373. $item = array (
  3374. 'date' => date ( "Y-m-d H:i:s" ),
  3375. 'operation' => '解绑 收款 ' . $irDetails ['receivablesSerial'],
  3376. 'status' => 11,
  3377. 'img' => $this->staff [0] ['avatar'],
  3378. 'username' => $this->staff [0] ['username'],
  3379. 'uid' => $this->staff [0] ['sid'],
  3380. 'category' => $this->staff [0] ['category'],
  3381. 'iid' => $invoiceDetails ['iid']
  3382. );
  3383. $invoiceOperationLog->setInvoiceOperationLog ( $item );
  3384. return "/invoiceReceivablesAS";
  3385. }
  3386. /**
  3387. * 发票管理
  3388. */
  3389. function invoiceAS() {
  3390. Doo::loadModel ( 'invoice' );
  3391. $invoice = new invoice ();
  3392. Doo::loadModel ( 'invoiceReceivables' );
  3393. $invoiceReceivables = new invoiceReceivables ();
  3394. $MebSea = $this->get_args ( 'MebSea' ) ? $this->get_args ( 'MebSea' ) : "";
  3395. $page_size = 18;
  3396. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  3397. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : 'All';
  3398. $date = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "";
  3399. $dateArr = explode ( ':', $date );
  3400. $D1 = '';
  3401. $D2 = '';
  3402. if (! empty ( $date )) {
  3403. $D1 = $dateArr [0] . " 00:00:00 ";
  3404. if (isset ( $dateArr [1] ))
  3405. $D2 = $dateArr [1] . " 23:59:59 ";
  3406. else
  3407. $D2 = $dateArr [0] . " 23:59:59 "; // date ( "Y-m-d" );
  3408. // $D2 = $dateArr [1];
  3409. }
  3410. $con = ' status=2 ';
  3411. if (! empty ( $D1 ) && ! empty ( $D2 ))
  3412. $con .= ' and printTime BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
  3413. if ($status == 'UNRECORD')
  3414. $con .= ' and printStatus=1 and untreadStatus=0';
  3415. elseif ($status == 'RECORD')
  3416. $con .= ' and printStatus=1 and untreadStatus=3';
  3417. elseif ($status == 'BOUNCED')
  3418. $con .= ' and untreadStatus=2';
  3419. elseif ($status == 'PARTRECORD')
  3420. $con .= ' and untreadStatus=0 and printStatus=1 and irid!=""';
  3421. elseif ($status == 'All') {
  3422. $con .= ' and ( untreadStatus=2 or untreadStatus=0 or untreadStatus=3 )';
  3423. }
  3424. $get = "/" . $status . "?date=" . urlencode ( $date ) . "&MebSea=" . urlencode ( $MebSea );
  3425. if (! empty ( $MebSea )) {
  3426. $con .= ' and ( invoiceTitle like "%' . $MebSea . '%" or invoiceCompany like "%' . $MebSea . '%" )';
  3427. }
  3428. $pageinfo ['page'] = array (
  3429. 'previous' => ''
  3430. );
  3431. $pageinfo = $this->get_page ( "CLD_invoice", $con, $page, $page_size, "invoiceAS", $get, "" );
  3432. $limit = $pageinfo ['lower'] . ',' . $page_size;
  3433. $list = $invoice->getInvoiceByUntreadStatusPage ( $limit, $con );
  3434. // foreach ($list as $key=>$value){
  3435. // $list[$key]['rpSum']=0;
  3436. // if (!empty($value['irid']))
  3437. // $list[$key]['rpSum']=$invoiceReceivables->getSumOfReceivablesPrice($value['irid']);
  3438. // }
  3439. $this->data ['MebSeaEn'] = $MebSea;
  3440. $this->data ['MebSea'] = urlencode ( $MebSea );
  3441. $this->data ['date'] = $date;
  3442. $this->data ['page'] = $pageinfo;
  3443. $this->data ['get'] = $get;
  3444. $this->data ['list'] = $list;
  3445. $this->data ['status'] = $status;
  3446. $this->data ['memu'] = "invoice";
  3447. $this->data ['staff'] = $this->staff;
  3448. $this->data ['receiptMemu'] = 'invoiceReceivables';
  3449. $this->render ( "/admin/invoiceAS", $this->data );
  3450. }
  3451. /**
  3452. * 收款管理
  3453. */
  3454. function invoiceReceivablesAS() {
  3455. Doo::loadModel ( 'invoiceReceivables' );
  3456. $invoiceReceivables = new invoiceReceivables ();
  3457. $MebSea = $this->get_args ( 'MebSea' ) ? $this->get_args ( 'MebSea' ) : "";
  3458. $timeType = $this->get_args ( 'timeType' ) ? $this->get_args ( 'timeType' ) : "CREATE";
  3459. $page_size = 6;
  3460. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  3461. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : 'All';
  3462. $date = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "";
  3463. $dateArr = explode ( ':', $date );
  3464. $D1 = '';
  3465. $D2 = '';
  3466. if (! empty ( $date )) {
  3467. $D1 = $dateArr [0]; // ." 00:00:00 ";
  3468. if (isset ( $dateArr [1] ))
  3469. $D2 = $dateArr [1]; // ." 23:59:59 ";
  3470. else
  3471. $D2 = $dateArr [0]; // ." 23:59:59 ";//date ( "Y-m-d" );
  3472. }
  3473. $descField = 'receivablesDate';
  3474. if ($timeType == 'CREATE')
  3475. $descField = 'date';
  3476. $con = '1';
  3477. if (! empty ( $D1 ) && ! empty ( $D2 ))
  3478. $con .= ' and ' . $descField . ' BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
  3479. // echo $con;
  3480. if ($status == 'Unclaimed')
  3481. $con .= ' and bindStatus=0';
  3482. elseif ($status == 'Credited')
  3483. $con .= ' and bindStatus=1';
  3484. elseif ($status == 'Claim')
  3485. $con .= ' and bindStatus=0 and receivablesStaff="PUBLIC"';
  3486. $get = "/" . $status . "?date=" . urlencode ( $date ) . "&MebSea=" . urlencode ( $MebSea );
  3487. if (! empty ( $MebSea )) {
  3488. $con .= ' and ( receivablesMessage like "%' . $MebSea . '%" or receivablesPrice like "%' . $MebSea . '%" )';
  3489. }
  3490. $pageinfo ['page'] = array (
  3491. 'previous' => ''
  3492. );
  3493. $pageinfo = $this->get_page ( "CLD_invoiceReceivables", $con, $page, $page_size, "invoiceReceivablesAS", $get, "" );
  3494. $limit = $pageinfo ['lower'] . ',' . $page_size;
  3495. $list = $invoiceReceivables->getReceivablesByUntreadStatusPage ( $limit, $con, 'desc', $descField );
  3496. // print_r($list);
  3497. $this->data ['timeType'] = $timeType;
  3498. $this->data ['MebSeaEn'] = $MebSea;
  3499. $this->data ['MebSea'] = urlencode ( $MebSea );
  3500. $this->data ['date'] = $date;
  3501. $this->data ['page'] = $pageinfo;
  3502. $this->data ['get'] = $get;
  3503. $this->data ['list'] = $list;
  3504. $this->data ['status'] = $status;
  3505. $this->data ['memu'] = "invoice";
  3506. $this->data ['staff'] = $this->staff;
  3507. $this->data ['receiptMemu'] = 'invoiceReceivables';
  3508. $this->render ( "/admin/invoiceReceivablesAS", $this->data );
  3509. }
  3510. function invoiceApprovalAchieve() {
  3511. Doo::loadModel ( 'invoice' );
  3512. $invoice = new invoice ();
  3513. $MebSea = isset ( $this->params ['MebSea'] ) ? urldecode ( $this->params ['MebSea'] ) : '';
  3514. $page_size = 12;
  3515. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  3516. $date = isset ( $this->params ['date'] ) ? $this->params ['date'] : 'MONTHO';
  3517. $get = "/" . $date;
  3518. $con = '';
  3519. if ($date == 'MONTHO')
  3520. $con = ' and updateTime>DATE_SUB(CURDATE(), INTERVAL 1 MONTH)';
  3521. elseif ($date == 'MONTHT')
  3522. $con = ' and updateTime>DATE_SUB(CURDATE(), INTERVAL 3 MONTH)';
  3523. elseif ($date == 'MONTHY')
  3524. $con = ' and updateTime>DATE_SUB(CURDATE(), INTERVAL 1 YEAR)';
  3525. if (! empty ( $MebSea )) {
  3526. $con .= ' and ( invoiceTitle like "%' . $MebSea . '%" or invoiceCompany like "%' . $MebSea . '%" or invoicePrice like "%' . $MebSea . '%" )';
  3527. $get .= "/" . $MebSea;
  3528. }
  3529. $pageinfo ['page'] = array (
  3530. 'previous' => ''
  3531. );
  3532. $sql = '(status=1 or status=2 or status=3 or status=4) and processApprovals!=""' . $con; // echo $sql;
  3533. $pageinfo = $this->get_page ( "CLD_invoice", $sql, $page, $page_size, "invoiceApprovalAchieve", $get, "" );
  3534. $limit = $pageinfo ['lower'] . ',' . $page_size;
  3535. $list = $invoice->getInvoiceByUntreadStatusPage ( $limit, $sql, 'desc', 2 );
  3536. // print_r($list);
  3537. $this->data ['MebSeaEn'] = $MebSea;
  3538. $this->data ['MebSea'] = urlencode ( $MebSea );
  3539. $this->data ['get'] = $get;
  3540. $this->data ['page'] = $pageinfo;
  3541. $this->data ['list'] = $list;
  3542. $this->data ['date'] = $date;
  3543. $this->data ['memu'] = "invoice";
  3544. $this->data ['staff'] = $this->staff;
  3545. $this->data ['receiptMemu'] = 'invoiceApproval';
  3546. $this->render ( "/admin/invoiceApprovalAchieve", $this->data );
  3547. }
  3548. function invoiceTAchieve() {
  3549. Doo::loadModel ( 'invoice' );
  3550. $invoice = new invoice ();
  3551. Doo::loadClass ( 'XDeode' );
  3552. $XDeode = new XDeode ( 5 );
  3553. Doo::loadModel ( 'staff' );
  3554. $staff = new staff ();
  3555. $MebSea = isset ( $this->params ['MebSea'] ) ? urldecode ( $this->params ['MebSea'] ) : '';
  3556. $page_size = 12;
  3557. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  3558. $date = isset ( $this->params ['date'] ) ? $this->params ['date'] : 'MONTHO';
  3559. $get = "/" . $date;
  3560. $con = '';
  3561. if ($date == 'MONTHO')
  3562. $con = ' and updateTime>DATE_SUB(CURDATE(), INTERVAL 1 MONTH)';
  3563. elseif ($date == 'MONTHT')
  3564. $con = ' and updateTime>DATE_SUB(CURDATE(), INTERVAL 3 MONTH)';
  3565. elseif ($date == 'MONTHY')
  3566. $con = ' and updateTime>DATE_SUB(CURDATE(), INTERVAL 1 YEAR)';
  3567. if (! empty ( $MebSea )) {
  3568. $con .= ' and ( invoiceTitle like "%' . $MebSea . '%" or invoiceCompany like "%' . $MebSea . '%" or invoicePrice like "%' . $MebSea . '%" )';
  3569. $get .= "/" . $MebSea;
  3570. }
  3571. $pageinfo ['page'] = array (
  3572. 'previous' => ''
  3573. );
  3574. $sql = "";
  3575. $action = "";
  3576. if ($this->ACTION == 'invoicePrintAchieve') {
  3577. $sql = "status=2 and printStatus=1 and moldManage like '%[\"" . $this->staff [0] ['sid'] . "\",%'" . $con;
  3578. $action = "invoicePrintAchieve";
  3579. } elseif ($this->ACTION == 'invoicePostAchieve') {
  3580. // and untreadStatus=0
  3581. $sql = "postStatus=1 and doPost=1 and status=2 and isDelete=0" . $con;
  3582. $action = "invoicePostAchieve";
  3583. } elseif ($this->ACTION == 'invoiceUntreadAchieve') { // printStatus=1 and
  3584. $sql = " untreadStatus=2 and status=2 " . $con;
  3585. $action = "invoiceUntreadAchieve";
  3586. }
  3587. $pageinfo = $this->get_page ( "CLD_invoice", $sql, $page, $page_size, $action, $get, "" );
  3588. $limit = $pageinfo ['lower'] . ',' . $page_size;
  3589. $list = $invoice->getInvoiceByUntreadStatusPage ( $limit, $sql );
  3590. $this->data ['MebSeaEn'] = $MebSea;
  3591. $this->data ['MebSea'] = urlencode ( $MebSea );
  3592. $this->data ['get'] = $get;
  3593. $this->data ['page'] = $pageinfo;
  3594. $this->data ['date'] = $date;
  3595. $this->data ['memu'] = "invoice";
  3596. $this->data ['staff'] = $this->staff;
  3597. if ($this->ACTION == 'invoicePrintAchieve') {
  3598. foreach ( $list as $key => $value ) {
  3599. $list [$key] ['iidKey'] = $XDeode->encode ( $value ['iid'] );
  3600. $lastApprover = json_decode ( $value ['processApprovals'], true );
  3601. if (! empty ( $lastApprover )) {
  3602. $lastApproverKey = array_keys ( $lastApprover );
  3603. $lastApprover = end ( $lastApprover );
  3604. $staffDetail = $staff->getOne ( array (
  3605. 'where' => 'sid=' . end ( $lastApproverKey ),
  3606. 'asArray' => true
  3607. ) );
  3608. $lastApprover ['username'] = $staffDetail ['username'];
  3609. }
  3610. $list [$key] ['lastApprover'] = $lastApprover;
  3611. }
  3612. $this->data ['receiptMemu'] = 'invoicePrint';
  3613. $this->data ['list'] = $list;
  3614. $this->render ( "/admin/invoicePrintAchieve", $this->data );
  3615. } elseif ($this->ACTION == 'invoicePostAchieve') {
  3616. Doo::loadModel ( 'express' );
  3617. $express = new express ();
  3618. $expressList = $express->getExpressByAll ();
  3619. $this->data ['expressList'] = $expressList;
  3620. $this->data ['receiptMemu'] = 'invoicePost';
  3621. $this->data ['list'] = $list;
  3622. $this->render ( "/admin/invoicePostAchieve", $this->data );
  3623. } elseif ($this->ACTION == 'invoiceUntreadAchieve') {
  3624. $this->data ['receiptMemu'] = 'invoiceUntread';
  3625. $this->data ['list'] = $list;
  3626. $this->render ( "/admin/invoiceUntreadAchieve", $this->data );
  3627. }
  3628. }
  3629. /**
  3630. *
  3631. * @deprecated 获得与我有关可收款的发票 废弃 function ajaxGetInvoiceByStaff() { $irid = $this->get_args ( 'key' ) ? $this->get_args ( 'key' ) : ""; Doo::loadModel ( 'invoice' ); $invoice = new invoice (); $list = $invoice->getInvoiceByReceivables ( $this->staff [0] ['sid'] ); $html = ""; $i = 1; foreach ( $list as $key => $value ) { $html .= '<tr> <td>' . $value ['invoiceElement'] . '</td> <td>¥' . $value ['invoicePrice'] . '</td>'; if (! empty ( $value ['invoiceType'] )) { $html .= '<td>增值税专用发票</td> <td>' . $value ['invoiceCompany'] . '</td>'; } else { $html .= '<td>增值税普通发票</td> <td>' . $value ['invoiceTitle'] . '</td>'; } $html .= '<td><label><input type="radio" node-Claim="true_' . $i . '" p-data="' . $value ['iidKey'] . '" name="invoiceClaim"> 使用Ta</label></td></tr> <script> $(\'input[node-Claim="true_' . $i . '"]\').click(function() { var invoiceKey= $(this).attr("p-data"); var claimKey=$("input[name=\'key\']").val(); $("p[node-msg=\"true\"]").hide(); var url = "/ajaxCompareInvoicePrice"; $.ajax({ url : url, type : "post", cache : false, dataType : "json", data : { claimKey : claimKey, invoiceKey:invoiceKey }, global : true, success : function(data) { $("input[name=\'invoiceKey\']").val("' . $value ['iidKey'] . '"); if (data.status == 1) { $("p[node-msg=\"true\"]").html("收款金额超出开票金额 ¥"+data.price+"元,请谨慎操作。"); $("p[node-msg=\"true\"]").show(); } }, error : function(err) { } }); }); </script> '; $i ++; } echo json_encode ( array ( 'status' => 1, 'html' => $html ) ); }
  3632. */
  3633. /**
  3634. * 获取一条收款信息
  3635. */
  3636. function ajaxGetInvoiceReceivables() {
  3637. $irid = $this->get_args ( 'key' ) ? $this->get_args ( 'key' ) : "";
  3638. Doo::loadModel ( 'invoiceReceivables' );
  3639. $invoiceReceivables = new invoiceReceivables ();
  3640. $detail = $invoiceReceivables->getInvoiceReceivablesByIrid ( $irid );
  3641. echo json_encode ( array (
  3642. 'status' => 1,
  3643. 'detail' => $detail
  3644. ) );
  3645. }
  3646. /**
  3647. * 异步获取办事处用户
  3648. */
  3649. function ajaxGetStaffByCategory() {
  3650. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : "";
  3651. Doo::loadModel ( 'staff' );
  3652. $staff = new staff ();
  3653. if ($cid == "PUBLIC") {
  3654. echo json_encode ( array (
  3655. 'status' => 1,
  3656. 'html' => '<option value="PUBLIC">办事处待认领款项</option>'
  3657. ) );
  3658. die ();
  3659. }
  3660. if (! is_numeric ( $cid )) {
  3661. echo json_encode ( array (
  3662. 'status' => 0,
  3663. 'msg' => 'illegal request'
  3664. ) );
  3665. die ();
  3666. }
  3667. $staffList = $staff->getStaffByCid ( $cid );
  3668. $html = '<option value="PUBLIC">办事处待认领款项</option>';
  3669. foreach ( $staffList as $key => $value ) {
  3670. $html .= '<option value="' . $value ['sid'] . '-' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  3671. }
  3672. echo json_encode ( array (
  3673. 'status' => 1,
  3674. 'html' => $html
  3675. ) );
  3676. }
  3677. /**
  3678. * 异步获取一条发票的邮寄信息
  3679. */
  3680. function ajaxGetInvoicePostDetail() {
  3681. $iid = $this->get_args ( 'iidKey' ) ? $this->get_args ( 'iidKey' ) : "";
  3682. Doo::loadModel ( 'invoice' );
  3683. $invoice = new invoice ();
  3684. $iid = $invoice->authcode ( $iid );
  3685. Doo::loadModel ( 'express' );
  3686. $express = new express ();
  3687. $expressList = $express->getExpressByAll ();
  3688. if (! is_numeric ( $iid )) {
  3689. echo json_encode ( array (
  3690. 'status' => 0,
  3691. 'msg' => 'illegal request'
  3692. ) );
  3693. die ();
  3694. }
  3695. $select = "iid,recipients,recipientsPhone,recipientsAddress,mailItems,expressCompany,expressNumber,actualItems";
  3696. $invoiceDetail = $invoice->getInvoiceByIid ( $iid, $select );
  3697. $html = "";
  3698. foreach ( $expressList as $key => $value ) {
  3699. if ($value ['company'] == $invoiceDetail ['expressCompany'])
  3700. $html .= '<option selected value="' . $value ['company'] . ':' . $value ['com'] . '">' . $value ['company'] . '</option>';
  3701. else
  3702. $html .= '<option value="' . $value ['company'] . ':' . $value ['com'] . '">' . $value ['company'] . '</option>';
  3703. }
  3704. $invoiceDetail ['eaHtml'] = $html;
  3705. echo json_encode ( array (
  3706. 'status' => 1,
  3707. 'invoiceDetail' => $invoiceDetail
  3708. ) );
  3709. }
  3710. /**
  3711. *
  3712. * @deprecated --需求变更 废弃 function ajaxCompareClaimPrice() { $irid = $this->get_args ( 'irid' ) ? $this->get_args ( 'irid' ) : ""; $invoiceKey = $this->get_args ( 'invoiceKey' ) ? $this->get_args ( 'invoiceKey' ) : ""; Doo::loadModel ( 'invoice' ); $invoice = new invoice (); Doo::loadModel ( 'invoiceReceivables' ); $invoiceReceivables = new invoiceReceivables (); Doo::loadModel ( 'invoiceOperationLog' ); $invoiceOperationLog = new invoiceOperationLog (); $detail = $invoice->getInvoiceByIid ( $invoiceKey ); $detailM = $invoiceReceivables->getInvoiceReceivablesByIrid ( $irid ); if (empty ( $detail ) || empty ( $detailM )) { echo json_encode ( array ( 'status' => 2, 'msg' => '非法请求,请重新登录' ) ); die (); } $iridString = ""; if (empty ( $detail ['irid'] )) $iridString = $detailM ['irid']; else $iridString = $detail ['irid'] . ',' . $detailM ['irid']; $item = array ( 'irid' => $iridString, 'bindTime' => date ( "Y-m-d H:i:s" ), 'updateTime' => date ( "Y-m-d H:i:s" ), 'iid' => $detail ['iid'] ); $invoice->setInvoiceByCondition ( $item ); // 操作日志 $item = array ( 'date' => date ( "Y-m-d H:i:s" ), 'operation' => "收款入账" . $detailM ['receivablesSerial'] . "到发票" . $detail ['invoiceSerial'], 'status' => 8, 'img' => $this->staff [0] ['avatar'], 'username' => $this->staff [0] ['username'], 'uid' => $this->staff [0] ['sid'], 'category' => $this->staff [0] ['category'], 'iid' => $detail ['iid'] ); $invoiceOperationLog->setInvoiceOperationLog ( $item ); $item = array ( 'iid' => $detail ['iid'], 'irid' => $detailM ['irid'], 'bindDate' => date ( "Y-m-d H:i:s" ), 'bindStatus' => 1 ); $invoiceReceivables->setInvoiceReceivablesByCondition ( $item ); $price = 0; $priceStatus = 0; $isReceivables = 0; $invoiceReceivables = new invoiceReceivables (); $list = $invoiceReceivables->getInvoiceReceivablesInIridString ( $iridString ); if (! empty ( $list )) $isReceivables = 1; $receivablesPrice = 0; foreach ( $list as $key => $value ) { $receivablesPrice += $value ['receivablesPrice']; } if ($receivablesPrice > $detail ['invoicePrice']) { $price = $receivablesPrice - $detail ['invoicePrice']; $priceStatus = 1; } elseif ($receivablesPrice < $detail ['invoicePrice']) { $price = $detail ['invoicePrice'] - $receivablesPrice; $priceStatus = 2; } echo json_encode ( array ( 'status' => 1, 'html' => '<tr><td>¥' . $detailM ['receivablesPrice'] . '</td><td>' . $detailM ['receivablesMessage'] . '</td><td>' . $detailM ['receivablesBank'] . '</td> <td>' . $detailM ['receivablesDate'] . '</td><td><a node-remove="Da' . $detailM ['iridKey'] . '" href="javascript:void(0);">移除</a></td></tr> <script> $(\'a[node-remove="Da' . $detailM ['iridKey'] . '"]\').click(function() { var invoiceKey=$("input[name=\'key\']").val(); var irid= $(this).attr("p-data"); var iridKey="' . $detailM ["iridEn"] . '"; var element=($(this)); $("p[node-loading=\"true\"]").show(); $("p[node-loading=\"true\"]").html("移除处理中..."); $("p[node-msg=\"true2\"]").hide(); $("p[node-msg=\"true\"]").hide(); var url = "/ajaxReceivablesRemove"; $.ajax({ url : url, type : "post", cache : false, dataType : "json", data : { key : iridKey, invoiceKey:invoiceKey }, global : true, success : function(data) { $("input[name=\'invoiceKey\']").val("' . $detailM ['iridEn'] . '"); if (data.status == 1) { $(element).parent().parent().remove(); $("tbody[data-invoice=\"myReceivables\"]").append(data.html); $("p[node-loading=\"true\"]").hide(); if(data.priceStatus == 1){ $("p[node-msg=\"true\"]").html("收款金额超出开票金额 ¥"+data.price+"元,请谨慎操作。"); $("p[node-msg=\"true\"]").show(); }else if(data.priceStatus == 2&& data.isReceivables != 0){ $("p[node-msg=\"true\"]").html("收款金额少于开票金额 ¥"+data.price+"元,请谨慎操作。"); $("p[node-msg=\"true\"]").show(); } }else if(data.status == 2){ $("p[node-loading=\"true\"]").html(data.msg); } }, error : function(err) { } }); }); </script> ', 'price' => $price, 'priceStatus' => $priceStatus, 'isReceivables' => $isReceivables ) ); }
  3713. */
  3714. /**
  3715. *
  3716. * @deprecated 从发票中移除已经入账的收款 --需求变更 废弃 function ajaxReceivablesRemove() { $iridKey = $this->get_args ( 'key' ) ? $this->get_args ( 'key' ) : ""; $invoiceKey = $this->get_args ( 'invoiceKey' ) ? $this->get_args ( 'invoiceKey' ) : ""; Doo::loadModel ( 'invoice' ); $invoice = new invoice (); Doo::loadModel ( 'invoiceReceivables' ); $invoiceReceivables = new invoiceReceivables (); Doo::loadModel ( 'invoiceOperationLog' ); $invoiceOperationLog = new invoiceOperationLog (); $detail = $invoice->getInvoiceByIid ( $invoiceKey ); $detailM = $invoiceReceivables->getInvoiceReceivablesByIrid ( $iridKey ); // echo $detail['irid']."<br/>"; $invoiceIrid = explode ( ",", $detail ['irid'] ); foreach ( $invoiceIrid as $key => $value ) { if ($value == $detailM ['irid']) unset ( $invoiceIrid [$key] ); } $invoiceIrid = implode ( ",", $invoiceIrid ); // echo $invoiceIrid."ddd"; // print_r($invoiceIrid); $item = array ( 'irid' => $invoiceIrid, 'iid' => $detail ['iid'] ); $invoice->setInvoiceByCondition ( $item ); $item = array ( 'iid' => 0, 'irid' => $detailM ['irid'], 'bindDate' => '', 'bindStatus' => 0 ); $invoiceReceivables->setInvoiceReceivablesByCondition ( $item ); // 操作日志 $item = array ( 'date' => date ( "Y-m-d H:i:s" ), 'operation' => "收款移除" . $detailM ['receivablesSerial'], 'status' => 10, 'img' => $this->staff [0] ['avatar'], 'username' => $this->staff [0] ['username'], 'uid' => $this->staff [0] ['sid'], 'category' => $this->staff [0] ['category'], 'iid' => $detail ['iid'] ); $invoiceOperationLog->setInvoiceOperationLog ( $item ); $price = 0; $priceStatus = 0; $isReceivables = 0; $invoiceReceivables = new invoiceReceivables (); $list = $invoiceReceivables->getInvoiceReceivablesInIridString ( $invoiceIrid ); if (! empty ( $list )) $isReceivables = 1; $receivablesPrice = 0; foreach ( $list as $key => $value ) { $receivablesPrice += $value ['receivablesPrice']; } if ($receivablesPrice > $detail ['invoicePrice']) { $price = $receivablesPrice - $detail ['invoicePrice']; $priceStatus = 1; } elseif ($receivablesPrice < $detail ['invoicePrice']) { $price = $detail ['invoicePrice'] - $receivablesPrice; $priceStatus = 2; } echo json_encode ( array ( 'status' => 1, 'html' => '<tr id="' . $detailM ['receivablesSerial'] . '" > <td>¥' . $detailM ['receivablesPrice'] . '</td> <td>' . $detailM ['receivablesMessage'] . '</td> <td>' . $detailM ['receivablesBank'] . '</td> <td>' . $detailM ['receivablesDate'] . '</td><td> <a href="javascript:void(0)" node-Claim="true_' . $detailM ['iridKey'] . '" p-data="' . $detailM ['iridEn'] . '" name="invoiceClaim" class="button">入账</a> </td></tr> <script> $(\'a[node-Claim="true_' . $detailM ['iridKey'] . '"]\').click(function() { var invoiceKey=$("input[name=\'key\']").val(); var irid= $(this).attr("p-data"); var element=($(this)); $("p[node-loading=\"true\"]").show(); $("p[node-loading=\"true\"]").html("入账处理中..."); $("p[node-msg=\"true2\"]").hide(); $("p[node-msg=\"true\"]").hide(); var url = "/ajaxCompareClaimPrice"; $.ajax({ url : url, type : "post", cache : false, dataType : "json", data : { irid : irid, invoiceKey:invoiceKey }, global : true, success : function(data) { $("input[name=\'invoiceKey\']").val("' . $detailM ['iridEn'] . '"); if (data.status == 1) { $(element).parent().parent().remove(); $("tbody[box-enter=\"true\"]").append(data.html); $("p[node-loading=\"true\"]").hide(); if(data.priceStatus == 1){ $("p[node-msg=\"true\"]").html("收款金额超出开票金额 ¥"+data.price+"元,请谨慎操作。"); $("p[node-msg=\"true\"]").show(); }else if(data.priceStatus == 2&& data.isReceivables != 0){ $("p[node-msg=\"true\"]").html("收款金额少于开票金额 ¥"+data.price+"元,请谨慎操作。"); $("p[node-msg=\"true\"]").show(); } }else if(data.status == 2){ $("p[node-loading=\"true\"]").html(data.msg); } }, error : function(err) { } }); }); </script> ', 'price' => $price, 'priceStatus' => $priceStatus, 'isReceivables' => $isReceivables ) ); }
  3717. */
  3718. /**
  3719. * 我的收款中 选择哪个发票入账,进行金额判断
  3720. */
  3721. function ajaxCompareInvoicePrice() {
  3722. $claimKey = $this->get_args ( 'claimKey' ) ? $this->get_args ( 'claimKey' ) : "";
  3723. $invoiceKey = $this->get_args ( 'invoiceKey' ) ? $this->get_args ( 'invoiceKey' ) : "";
  3724. Doo::loadModel ( 'invoice' );
  3725. $invoice = new invoice ();
  3726. Doo::loadModel ( 'invoiceReceivables' );
  3727. $invoiceReceivables = new invoiceReceivables ();
  3728. $detail = $invoice->getInvoiceByIid ( $invoiceKey );
  3729. $keyList = explode ( ';', $claimKey );
  3730. $receivablesPrice = 0;
  3731. foreach ( $keyList as $key => $value ) {
  3732. $detailM = $invoiceReceivables->getInvoiceReceivablesByIrid ( $value );
  3733. $receivablesPrice += $detailM ['receivablesPrice'];
  3734. }
  3735. if ($receivablesPrice > $detail ['invoicePrice']) {
  3736. $price = $receivablesPrice - $detail ['invoicePrice'];
  3737. echo json_encode ( array (
  3738. 'status' => 1,
  3739. 'price' => $price
  3740. ) );
  3741. } else
  3742. echo json_encode ( array (
  3743. 'status' => 2
  3744. ) );
  3745. }
  3746. /**
  3747. * 获得打印发票
  3748. */
  3749. function ajaxGetInvoiceInfoByPrint() {
  3750. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  3751. if (empty ( $serial )) {
  3752. echo json_encode ( array (
  3753. 'status' => 2,
  3754. 'msg' => 'illegal request'
  3755. ) );
  3756. die ();
  3757. }
  3758. Doo::loadModel ( 'invoice' );
  3759. $invoice = new invoice ();
  3760. Doo::loadModel ( 'invoiceOperationLog' );
  3761. $invoiceOperationLog = new invoiceOperationLog ();
  3762. $detail = $invoice->getInvoiceByIsid ( $serial, $this->staff [0] ['sid'] );
  3763. $invoiceOperationLogList = $invoiceOperationLog->getInvoiceOperationLogByIid ( $detail ['iid'] );
  3764. if (empty ( $detail ))
  3765. $html = '';
  3766. else {
  3767. $html = '
  3768. <form action="/invoicePrintDo" method="post" name="invoicePrint" class="nice-validator n-yellow" onSubmit="return checkPrintForm()" novalidate="novalidate">
  3769. <input type="hidden" name="invoiceKey" value="'.$detail ['iidKeyXD'].'">
  3770. <div class="modal-dialog modal-lg">
  3771. <div class="modal-content"><div class="modal-header"><h3>发票单详情</h3></div>
  3772. <div class="modal-body saeaList">
  3773. <table class="table table-bordered table-condensed" style="margin:15px 0;">
  3774. <tbody>
  3775. <tr>
  3776. <th class="taC" >发票号</th><td><span class="colRed">*</span>No.<input name="invoiceNo" id="invoiceNo" value="" type="text" placeholder="输入发票号" aria-required="true" aria-invalid="true" class="n-invalid">
  3777. <span class="red" id="p-msg"></span>
  3778. </td>
  3779. </tr>
  3780. </tbody>
  3781. </table>
  3782. <table class="table table-bordered table-condensed"><tbody>
  3783. <tr>
  3784. <th class="taC" width="150">开票流水号</th><td>' . $detail ['invoiceSerial'] . '</td>
  3785. <th class="taC" width="150">提交时间</th><td>' . $detail ['date'] . '</td>
  3786. </tr>
  3787. <tr>
  3788. <th class="taC" width="150">所在办事处</th><td>' . $detail ['categoryName'] . '(' . $detail ['userName'] . ')</td>
  3789. <th class="taC" width="150">开票内容</th><td>' . $detail ['invoiceElement'] . '</td>
  3790. </tr>
  3791. <tr>
  3792. <th class="taC">发票备注</th><td colspan="3">' . $detail ['remark'] . '
  3793. </td>
  3794. </tr>
  3795. <tr>
  3796. <th class="taC" width="150">数量</th><td><b>' . $detail ['invoiceQuantity'] . '</b></td>
  3797. <th class="taC">单价</th><td><b>¥' . $detail ['invoiceUnitPrice'] . '</b></td>
  3798. </tr>
  3799. <tr>
  3800. <th class="taC">开票金额</th><td colspan="3"><b class="colOrange" style="font-size:18px">¥' . $detail ['invoicePrice'] . '</b></td>
  3801. </tr></tbody></table>';
  3802. if ($detail ['invoiceType'] == 0)
  3803. $html .= '<table class="table table-bordered table-condensed"><tbody>
  3804. <tr><th colspan="4" class="taC">增值税普通发票</th></tr><tr>
  3805. <th class="taC" width="150">发票抬头</th><td >' . $detail ['invoiceTitle'] . '</td>
  3806. <th class="taC" width="150">纳税人识别码</th><td>' . $detail ['TIN'] . '</td>
  3807. </tr>';
  3808. else
  3809. $html .= '<table class="table table-bordered table-condensed"><tbody>
  3810. <tr><th colspan="4" class="taC">增值税专用发票</th></tr><tr>
  3811. <th class="taC" width="150">单位名称</th><td>' . $detail ['invoiceCompany'] . '</td>
  3812. <th class="taC" width="150">纳税人识别码</th><td>' . $detail ['TIN'] . '</td></tr>
  3813. ';
  3814. $html .= '<tr>
  3815. <th class="taC">注册地址</th><td>' . $detail ['address'] . '</td>
  3816. <th class="taC">注册电话</th><td>' . $detail ['phone'] . '</td>
  3817. </tr>
  3818. <tr>
  3819. <th class="taC">开户银行</th><td>' . $detail ['bank'] . '</td>
  3820. <th class="taC">银行账号</th><td>' . $detail ['bankAccount'] . '</td>
  3821. </tr></tbody></table>';
  3822. if ($detail ['doPost'] == 1)
  3823. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th colspan="4" class="taC">邮寄信息</th></tr><tr>
  3824. <th class="taC" width="150">收件人</th><td>' . $detail ['recipients'] . '</td>
  3825. <th class="taC" width="150">收件人手机/电话</th><td>' . $detail ['recipientsPhone'] . '</td>
  3826. </tr><tr>
  3827. <th class="taC" width="150">收件地址</th><td colspan="3">' . $detail ['recipientsAddress'] . '</td>
  3828. </tr><tr>
  3829. <th class="taC" width="150">邮寄物品</th><td colspan="3">' . $detail ['mailItems'] . '</td>
  3830. </tr></tbody></table>';
  3831. if (! empty ( $invoiceOperationLogList )) {
  3832. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th width="60%" class="taC">审批流程</th></tr><tr><td>';
  3833. foreach ( $invoiceOperationLogList as $key => $value ) {
  3834. if ($value ['status'] == 1 || $value ['status'] == 2 || $value ['status'] == 3 || $value ['status'] == 4) {
  3835. $html .= '<blockquote><p><span class="colGray">' . $value ['date'] . '</span>&nbsp;
  3836. ' . $value ['category'] . '-' . $value ['username'] . '&nbsp;';
  3837. if ($value ['status'] == 2) {
  3838. $html .= '<span class="colGreen">同意</span>';
  3839. } elseif ($value ['status'] == 3) {
  3840. $html .= '<span class="colOrange">退回</span>';
  3841. } elseif ($value ['status'] == 5) {
  3842. $html .= '<span class="colGreen">打印</span>';
  3843. } elseif ($value ['status'] == 4) {
  3844. $html .= '<span class="colRed">终止</span>';
  3845. }
  3846. $html .= $value ['operation'] . '</p></blockquote>';
  3847. }
  3848. }
  3849. $html .= '</td></tr></tbody></table>';
  3850. }
  3851. $html .= '</div><div class="modal-footer"><button type="submit" class="button btn-green" data-toggle="modal">完成打印</button><a href="#" class="button btn-gray" data-dismiss="modal" aria-hidden="true">关闭</a></div>
  3852. </div></div></form>
  3853. <link rel=stylesheet href="'.WEB_SITE_GLOBAL.'css/jquery.validator.css">
  3854. <script type="text/javascript" src="'.WEB_SITE_GLOBAL.'js/jquery.validator.min.js"></script>
  3855. <script type="text/javascript" src="'.WEB_SITE_GLOBAL.'js/zh-CN.js"></script>
  3856. <script src="'.WEB_SITE_GLOBAL.'js/invoice.validator.js"></script>
  3857. ';
  3858. }
  3859. echo json_encode ( array (
  3860. 'status' => 1,
  3861. 'html' => $html
  3862. ) );
  3863. die ();
  3864. }
  3865. /**
  3866. * @ 获得与我有关收款数据 --需求变更 废弃 function ajaxGetReceivalblesByStaff() { $iid = $this->get_args ( 'key' ) ? $this->get_args ( 'key' ) : ""; Doo::loadModel ( 'invoiceReceivables' ); $invoiceReceivables = new invoiceReceivables (); Doo::loadModel ( 'invoice' ); $invoice = new invoice (); $detail = $invoice->getInvoiceByIid ( $iid ); $list = $invoiceReceivables->getInvoiceReceivablesByClaim ( $this->staff [0] ['cid'], $this->staff [0] ['sid'] ); $html = ""; $i = 1; foreach ( $list ['myClaim'] as $key => $value ) { $html .= '<tr id="' . $value ['receivablesSerial'] . '" > <td>¥' . $value ['receivablesPrice'] . '</td> <td>' . $value ['receivablesMessage'] . '</td> <td>' . $value ['receivablesBank'] . '</td> <td>' . $value ['receivablesDate'] . '</td>'; $html .= '<td> <a href="javascript:void(0)" node-Claim="true_' . $i . '" p-data="' . $value ['iidKey'] . '" name="invoiceClaim" class="button">入账</a> </td></tr> <script> $(\'a[node-Claim="true_' . $i . '"]\').click(function() { var invoiceKey=$("input[name=\'key\']").val(); var irid= $(this).attr("p-data"); var element=($(this)); $("p[node-loading=\"true\"]").show(); $("p[node-loading=\"true\"]").html("入账处理中..."); $("p[node-msg=\"true2\"]").hide(); $("p[node-msg=\"true\"]").hide(); var url = "/ajaxCompareClaimPrice"; $.ajax({ url : url, type : "post", cache : false, dataType : "json", data : { irid : irid, invoiceKey:invoiceKey }, global : true, success : function(data) { $("input[name=\'invoiceKey\']").val("' . $value ['iidKey'] . '"); if (data.status == 1) { $(element).parent().parent().remove(); $("tbody[box-enter=\"true\"]").append(data.html); $("p[node-loading=\"true\"]").hide(); if(data.priceStatus == 1){ $("p[node-msg=\"true\"]").html("收款金额超出开票金额 ¥"+data.price+"元,请谨慎操作。"); $("p[node-msg=\"true\"]").show(); }else if(data.priceStatus == 2&& data.isReceivables != 0){ $("p[node-msg=\"true\"]").html("收款金额少于开票金额 ¥"+data.price+"元,请谨慎操作。"); $("p[node-msg=\"true\"]").show(); } }else if(data.status == 2){ $("p[node-loading=\"true\"]").html(data.msg); } }, error : function(err) { } }); }); </script> '; $i ++; } $html2 = ""; $list2 = $invoiceReceivables->getInvoiceReceivablesByIid ( $iid, 1 ); foreach ( $list2 as $key => $value ) { $html2 .= '<tr id="' . $value ['receivablesSerial'] . '" > <td>¥' . $value ['receivablesPrice'] . '</td> <td>' . $value ['receivablesMessage'] . '</td> <td>' . $value ['receivablesBank'] . '</td> <td>' . $value ['receivablesDate'] . '</td>'; $html2 .= '<td> <a href="javascript:void(0)" node-remove="Da' . $value ['iridKey'] . '" >移除</a> </td></tr> <script> $(\'a[node-remove="Da' . $value ['iridKey'] . '"]\').click(function() { var invoiceKey=$("input[name=\'key\']").val(); var irid= $(this).attr("p-data"); var iridKey="' . $value ["iidKey"] . '"; var element=($(this)); $("p[node-loading=\"true\"]").show(); $("p[node-loading=\"true\"]").html("移除处理中..."); $("p[node-msg=\"true2\"]").hide(); $("p[node-msg=\"true\"]").hide(); var url = "/ajaxReceivablesRemove"; $.ajax({ url : url, type : "post", cache : false, dataType : "json", data : { key : iridKey, invoiceKey:invoiceKey }, global : true, success : function(data) { $("input[name=\'invoiceKey\']").val("' . $value ['iidKey'] . '"); if (data.status == 1) { $(element).parent().parent().remove(); $("tbody[data-invoice=\"myReceivables\"]").append(data.html); $("p[node-loading=\"true\"]").hide(); if(data.priceStatus == 1){ $("p[node-msg=\"true\"]").html("收款金额超出开票金额 ¥"+data.price+"元,请谨慎操作。"); $("p[node-msg=\"true\"]").show(); }else if(data.priceStatus == 2&& data.isReceivables != 0){ $("p[node-msg=\"true\"]").html("收款金额少于开票金额 ¥"+data.price+"元,请谨慎操作。"); $("p[node-msg=\"true\"]").show(); } }else if(data.status == 2){ $("p[node-loading=\"true\"]").html(data.msg); } }, error : function(err) { } }); }); </script> '; $i ++; } $price = 0; $priceStatus = 0; $isReceivables = 0; $list = $invoiceReceivables->getInvoiceReceivablesInIridString ( $detail ['irid'] ); if (! empty ( $list )) $isReceivables = 1; $receivablesPrice = 0; foreach ( $list as $key => $value ) { $receivablesPrice += $value ['receivablesPrice']; } if ($receivablesPrice > $detail ['invoicePrice']) { $price = $receivablesPrice - $detail ['invoicePrice']; $priceStatus = 1; } elseif ($receivablesPrice < $detail ['invoicePrice']) { $price = $detail ['invoicePrice'] - $receivablesPrice; $priceStatus = 2; } echo json_encode ( array ( 'status' => 1, 'html' => $html, 'html2' => $html2, 'price' => $price, 'priceStatus' => $priceStatus, 'isReceivables' => $isReceivables ) ); }
  3867. */
  3868. function ajaxGetInvoiceInfoByType() {
  3869. $type = $this->get_args ( 'type' ) ? $this->get_args ( 'type' ) : "";
  3870. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  3871. $loss = $this->get_args ( 'loss' ) ? $this->get_args ( 'loss' ) : false;
  3872. if (empty ( $serial )) {
  3873. echo json_encode ( array (
  3874. 'status' => 2,
  3875. 'msg' => 'illegal request'
  3876. ) );
  3877. die ();
  3878. }
  3879. if ($type == 'INVOICE') {
  3880. Doo::loadModel ( 'invoice' );
  3881. $invoice = new invoice ();
  3882. Doo::loadModel ( 'invoiceOperationLog' );
  3883. $invoiceOperationLog = new invoiceOperationLog ();
  3884. $detail = $invoice->getInvoiceByIsid ( $serial, $this->staff [0] ['sid'] );
  3885. $invoiceOperationLogList = $invoiceOperationLog->getInvoiceOperationLogByIid ( $detail ['iid'] );
  3886. if (empty ( $detail ))
  3887. $html = '';
  3888. else {
  3889. $html = '
  3890. <div class="modal-dialog modal-lg">
  3891. <div class="modal-content"><div class="modal-header"><h3>发票单详情</h3></div>
  3892. <div class="modal-body saeaList"><table class="table table-bordered table-condensed"><tbody>
  3893. <tr>
  3894. <th class="taC" width="150">开票流水号</th><td>' . $detail ['invoiceSerial'] . '</td>
  3895. <th class="taC" width="150">提交时间</th><td>' . $detail ['date'] . '</td>
  3896. </tr>
  3897. <tr>
  3898. <th class="taC" width="150">所在办事处</th><td>' . $detail ['categoryName'] . '(' . $detail ['userName'] . ')</td>
  3899. <th class="taC" width="150">开票内容</th><td>' . $detail ['invoiceElement'] . '</td>
  3900. </tr>
  3901. <tr>
  3902. <th class="taC">发票备注</th><td colspan="3">' . $detail ['remark'] . '
  3903. </td>
  3904. </tr>
  3905. <tr>
  3906. <th class="taC" width="150">数量</th><td><b>' . $detail ['invoiceQuantity'] . '</b></td>
  3907. <th class="taC">单价</th><td><b>¥' . $detail ['invoiceUnitPrice'] . '</b></td>
  3908. </tr>
  3909. <tr>
  3910. <th class="taC">开票金额</th><td colspan="3"><b class="colOrange" style="font-size:18px">¥' . $detail ['invoicePrice'] . '</b></td>
  3911. </tr></tbody></table>';
  3912. if ($detail ['invoiceType'] == 0)
  3913. $html .= '<table class="table table-bordered table-condensed"><tbody>
  3914. <tr><th colspan="4" class="taC">增值税普通发票</th></tr><tr>
  3915. <th class="taC" width="150">发票抬头</th><td >' . $detail ['invoiceTitle'] . '</td>
  3916. <th class="taC" width="150">纳税人识别码</th><td>' . $detail ['TIN'] . '</td>
  3917. </tr>';
  3918. else
  3919. $html .= '<table class="table table-bordered table-condensed"><tbody>
  3920. <tr><th colspan="4" class="taC">增值税专用发票</th></tr><tr>
  3921. <th class="taC" width="150">单位名称</th><td>' . $detail ['invoiceCompany'] . '</td>
  3922. <th class="taC" width="150">纳税人识别码</th><td>' . $detail ['TIN'] . '</td></tr>
  3923. ';
  3924. $html .= '<tr>
  3925. <th class="taC">注册地址</th><td>' . $detail ['address'] . '</td>
  3926. <th class="taC">注册电话</th><td>' . $detail ['phone'] . '</td>
  3927. </tr>
  3928. <tr>
  3929. <th class="taC">开户银行</th><td>' . $detail ['bank'] . '</td>
  3930. <th class="taC">银行账号</th><td>' . $detail ['bankAccount'] . '</td>
  3931. </tr></tbody></table>';
  3932. if ($detail ['doPost'] == 1){
  3933. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th colspan="4" class="taC">邮寄信息</th></tr><tr>
  3934. <th class="taC" width="150">收件人</th><td>' . $detail ['recipients'] . '</td>
  3935. <th class="taC" width="150">收件人手机/电话</th><td>' . $detail ['recipientsPhone'] . '</td>
  3936. </tr><tr>
  3937. <th class="taC" width="150">收件地址</th><td colspan="3">' . $detail ['recipientsAddress'] . '</td>
  3938. </tr><tr>
  3939. <th class="taC" width="150">邮寄物品</th><td colspan="3">' . $detail ['mailItems'] . '</td>
  3940. </tr>
  3941. ';
  3942. if ($detail ['expressCom']=='SF')
  3943. $html .= '<tr><th class="taC" width="150">快递单号</th><td colspan="3">' . $detail ['expressCompany'] . ' <a target="_blank" href="http://www.sf-express.com/cn/sc/dynamic_function/waybill/#search/bill-number/">' . $detail ['expressNumber'] . '</a> </td></tr>';
  3944. else
  3945. $html .= '<tr><th class="taC" width="150">快递单号</th><td colspan="3">' . $detail ['expressCompany'] . ' <a target="_blank" href="/invoiceExpress/'.$detail ['expressCom'].'/' . $detail ['expressNumber'] . '.html">' . $detail ['expressNumber'] . '</a> </td></tr>';
  3946. $html .= '</tbody></table>';
  3947. }
  3948. if (! empty ( $invoiceOperationLogList )) {
  3949. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th width="60%" class="taC">审批流程</th></tr><tr><td>';
  3950. foreach ( $invoiceOperationLogList as $key => $value ) {
  3951. if ($value ['status'] == 1 || $value ['status'] == 2 || $value ['status'] == 3 || $value ['status'] == 4) {
  3952. $html .= '<blockquote><p><span class="colGray">' . $value ['date'] . '</span>&nbsp;
  3953. ' . $value ['category'] . '-' . $value ['username'] . '&nbsp;';
  3954. if ($value ['status'] == 2) {
  3955. $html .= '<span class="colGreen">同意</span>';
  3956. } elseif ($value ['status'] == 3) {
  3957. $html .= '<span class="colOrange">退回</span>';
  3958. } elseif ($value ['status'] == 5) {
  3959. $html .= '<span class="colGreen">打印</span>';
  3960. } elseif ($value ['status'] == 4) {
  3961. $html .= '<span class="colRed">终止</span>';
  3962. }
  3963. $html .= $value ['operation'] . '</p></blockquote>';
  3964. }
  3965. }
  3966. $html .= '</td></tr></tbody></table>';
  3967. }
  3968. $html .= '</div><div class="modal-footer"><a href="#" class="button btn-gray" data-dismiss="modal" aria-hidden="true">关闭</a></div></div></div>';
  3969. }
  3970. echo json_encode ( array (
  3971. 'status' => 1,
  3972. 'html' => $html
  3973. ) );
  3974. die ();
  3975. } elseif ($type == 'RECEIVABLES') {
  3976. Doo::loadModel ( 'invoiceReceivables' );
  3977. $invoiceReceivables = new invoiceReceivables ();
  3978. //
  3979. $detail = $invoiceReceivables->getInvoiceReceivablesByIrsid ( $serial );
  3980. if (empty ( $detail ))
  3981. $html = '';
  3982. else {
  3983. $html = '<div class="modal-dialog modal-lg"><div class="modal-content"><div class="modal-header"><h3>收款单详情</h3></div><div class="modal-body saeaList"><table class="table table-bordered table-condensed">
  3984. <tbody><tr>
  3985. <th class="taC">收款流水号</th><td>' . $detail ['receivablesSerial'] . '</td>
  3986. <th class="taC">录入收款</th><td>' . $detail ['inputStaff'] . ' ' . $detail ['date'] . '</td>
  3987. </tr><tr>
  3988. <th class="taC">收款金额</th><td><b>¥' . $detail ['receivablesPrice'] . '</b></td>
  3989. <th class="taC">收款信息</th><td>' . $detail ['receivablesMessage'] . '</td>
  3990. </tr>
  3991. <tr>
  3992. <th class="taC">收款银行</th><td>' . $detail ['receivablesBank'] . '</td>
  3993. <th class="taC">银行到账</th><td>' . $detail ['receivablesDate'] . '</td>
  3994. </tr>
  3995. <tr>
  3996. <th class="taC">认领收款</th><td colspan="3">' . $detail ['inputStaff'] . ' 转入 ' . $detail ['username'] . ' ' . $detail ['bindDate'] . '</td>
  3997. </tr>
  3998. </tbody></table></div><div class="modal-footer"><a href="#" class="button btn-gray" data-dismiss="modal" aria-hidden="true">关闭</a></div></div></div>';
  3999. }
  4000. echo json_encode ( array (
  4001. 'status' => 1,
  4002. 'html' => $html
  4003. ) );
  4004. die ();
  4005. } elseif ($type == 'IRTC') {
  4006. Doo::loadModel ( 'invoice' );
  4007. $invoice = new invoice ();
  4008. Doo::loadModel ( 'invoiceOperationLog' );
  4009. $invoiceOperationLog = new invoiceOperationLog ();
  4010. Doo::loadModel ( 'invoiceReceivables' );
  4011. $invoiceReceivables = new invoiceReceivables ();
  4012. $detail = $invoice->getInvoiceByIsid ( $serial, $this->staff [0] ['sid'] );
  4013. $invoiceOperationLogList = $invoiceOperationLog->getInvoiceOperationLogByIid ( $detail ['iid'] );
  4014. if (empty ( $detail ))
  4015. $html = '';
  4016. else {
  4017. $receivablesPriceedHtml = '';
  4018. $receivablesPrice = $detail ['invoicePrice'];
  4019. if (! empty ( $detail ['irid'] )) {
  4020. $irList = $invoiceReceivables->getInvoiceReceivablesInIridString ( $detail ['irid'] );
  4021. if (empty ( $irList ))
  4022. $irList [0] ['sumPrice'] = 0;
  4023. $balance = $detail ['invoicePrice'] - $irList [0] ['sumPrice'];
  4024. $receivablesPriceedHtml = '<table class="table table-bordered table-condensed"><tbody><tr>
  4025. <th class="taC">已入账金额</th><td><b class="colGreen" style="font-size:18px">¥' . $irList [0] ['sumPrice'] . '</b></td>
  4026. <th class="taC">剩余入账金额</th><td><b class="colRed" style="font-size:18px">¥' . $balance . '</b></td>
  4027. </tr></tbody></table>';
  4028. $receivablesPrice = $balance;
  4029. }
  4030. if ($loss)
  4031. $detail ['invoicePrice'] = - $detail ['invoicePrice'];
  4032. $html = $receivablesPriceedHtml . '
  4033. <table class="table table-bordered table-condensed"><tbody>
  4034. <tr>
  4035. <th class="taC" width="150">开票流水号</th><td>' . $detail ['invoiceSerial'] . '</td>
  4036. <th class="taC" width="150">提交时间</th><td>' . $detail ['date'] . '</td>
  4037. </tr>
  4038. <tr>
  4039. <th class="taC" width="150">所在办事处</th><td>' . $detail ['categoryName'] . '(' . $detail ['userName'] . ')</td>
  4040. <th class="taC" width="150">开票内容</th><td>' . $detail ['invoiceElement'] . '</td>
  4041. </tr>
  4042. <tr>
  4043. <th class="taC" width="150">发票备注</th><td colspan="3">' . $detail ['remark'] . '</td>
  4044. </tr>
  4045. <tr>
  4046. <th class="taC" width="150">数量</th><td><b>' . $detail ['invoiceQuantity'] . '</b></td>
  4047. <th class="taC">单价</th><td><b>¥' . $detail ['invoiceUnitPrice'] . '</b></td>
  4048. </tr>
  4049. <tr>
  4050. <th class="taC">开票金额</th><td colspan="3"><b class="colOrange" style="font-size:18px">¥' . $detail ['invoicePrice'] . '</b></td>
  4051. </tr></tbody></table>';
  4052. if ($detail ['invoiceType'] == 0) {
  4053. $html .= '<table class="table table-bordered table-condensed"><tbody>
  4054. <tr><th colspan="4" class="taC">增值税普通发票</th></tr><tr>
  4055. <th class="taC" width="150">发票抬头</th><td >' . $detail ['invoiceTitle'] . '</td>
  4056. <th class="taC" width="150">纳税人识别码</th><td>' . $detail ['TIN'] . '</td>
  4057. </tr>';
  4058. $receivablesMessage = $detail ['invoiceTitle'];
  4059. } else {
  4060. $html .= '<table class="table table-bordered table-condensed"><tbody>
  4061. <tr><th colspan="4" class="taC">增值税专用发票</th></tr><tr>
  4062. <th class="taC" width="150">单位名称</th><td>' . $detail ['invoiceCompany'] . '</td>
  4063. <th class="taC" width="150">纳税人识别码</th><td>' . $detail ['TIN'] . '</td></tr>
  4064. ';
  4065. $receivablesMessage = $detail ['invoiceCompany'];
  4066. }
  4067. $html .= '<tr>
  4068. <th class="taC">注册地址</th><td>' . $detail ['address'] . '</td>
  4069. <th class="taC">注册电话</th><td>' . $detail ['phone'] . '</td>
  4070. </tr>
  4071. <tr>
  4072. <th class="taC">开户银行</th><td>' . $detail ['bankAccount'] . '</td>
  4073. <th class="taC">银行账号</th><td>' . $detail ['bank'] . '</td>
  4074. </tr></tbody></table>';
  4075. if ($detail ['doPost'] == 1)
  4076. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th colspan="4" class="taC">邮寄信息</th></tr><tr>
  4077. <th class="taC" width="150">收件人</th><td>' . $detail ['recipients'] . '</td>
  4078. <th class="taC" width="150">收件人手机/电话</th><td>' . $detail ['recipientsPhone'] . '</td>
  4079. </tr><tr>
  4080. <th class="taC" width="150">收件地址</th><td colspan="3">' . $detail ['recipientsAddress'] . '</td>
  4081. </tr><tr>
  4082. <th class="taC" width="150">邮寄物品</th><td colspan="3">' . $detail ['mailItems'] . '</td>
  4083. </tr></tbody></table>';
  4084. if (! empty ( $invoiceOperationLogList )) {
  4085. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th width="60%" class="taC">审批流程</th></tr><tr><td>';
  4086. foreach ( $invoiceOperationLogList as $key => $value ) {
  4087. if ($value ['status'] == 1 || $value ['status'] == 2 || $value ['status'] == 3 || $value ['status'] == 4) {
  4088. $html .= '<blockquote><p><span class="colGray">' . $value ['date'] . '</span>&nbsp;
  4089. ' . $value ['category'] . '-' . $value ['username'] . '&nbsp;';
  4090. if ($value ['status'] == 2) {
  4091. $html .= '<span class="colGreen">同意</span>';
  4092. } elseif ($value ['status'] == 3) {
  4093. $html .= '<span class="colOrange">退回</span>';
  4094. } elseif ($value ['status'] == 5) {
  4095. $html .= '<span class="colGreen">打印</span>';
  4096. }
  4097. $html .= $value ['operation'] . '</p></blockquote>';
  4098. }
  4099. }
  4100. $html .= '</td></tr></tbody></table>';
  4101. }
  4102. }
  4103. echo json_encode ( array (
  4104. 'status' => 1,
  4105. 'html' => $html,
  4106. 'receivablesPrice' => $receivablesPrice,
  4107. 'receivablesMessage' => $receivablesMessage,
  4108. 'receivablesDate' => date ( "Y-m-d" ),
  4109. 'iidKey' => $serial
  4110. ) );
  4111. die ();
  4112. }
  4113. }
  4114. function ajaxGetInvoiceReceivablesByStaff() {
  4115. $postData = $this->get_args ( 'postData' ) ? $this->get_args ( 'postData' ) : "";
  4116. if (empty ( $postData )) {
  4117. echo json_encode ( array (
  4118. 'status' => 2,
  4119. 'msg' => 'illegal request'
  4120. ) );
  4121. die ();
  4122. }
  4123. Doo::loadModel ( 'invoiceReceivables' );
  4124. $invoiceReceivables = new invoiceReceivables ();
  4125. $detail = $invoiceReceivables->getInvoiceReceivablesByIrid ( $postData );
  4126. if (empty ( $detail )) {
  4127. echo json_encode ( array (
  4128. 'status' => 2,
  4129. 'msg' => 'illegal request'
  4130. ) );
  4131. die ();
  4132. }
  4133. Doo::loadModel ( 'L_category' );
  4134. $lCategory = new L_category ();
  4135. Doo::loadModel ( 'staff' );
  4136. $staff = new staff ();
  4137. $staffList = $staff->getStaffByCid ( $detail ['cid'] );
  4138. $category = $lCategory->getCategory ();
  4139. $categoryHtml = '<option post-data="PUBLIC" value="PUBLIC" >公共待认领款项</option>';
  4140. $staffHtml = '<option value="PUBLIC">办事处待认领款项</option>';
  4141. foreach ( $category as $key => $value ) {
  4142. $categoryHtml .= '<option post-data="' . $value ['cid'] . '" value="' . $value ['cid'] . ':' . $value ['title'] . '" >' . $value ['title'] . '</option>';
  4143. if ($value ['cid'] == $detail ['cid'])
  4144. $categoryHtml .= '<option selected post-data="' . $value ['cid'] . '" value="' . $value ['cid'] . ':' . $value ['title'] . '" >' . $value ['title'] . '</option>';
  4145. }
  4146. foreach ( $staffList as $key => $value ) {
  4147. $staffHtml .= '<option value="' . $value ['sid'] . '-' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  4148. if ($value ['sid'] == $detail ['sid'])
  4149. $staffHtml .= '<option selected value="' . $value ['sid'] . '-' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  4150. }
  4151. $rbankHtml = '<option value="广发银行珠海分行柠溪支行">广发银行珠海分行柠溪支行</option>';
  4152. echo json_encode ( array (
  4153. 'status' => 1,
  4154. 'categoryHtml' => $categoryHtml,
  4155. 'staffHtml' => $staffHtml,
  4156. 'rbankHtml' => $rbankHtml,
  4157. 'detail' => $detail
  4158. ) );
  4159. }
  4160. function ajaxGetInvoiceReceivablesByIrid() {
  4161. $irid = $this->get_args ( 'irid' ) ? $this->get_args ( 'irid' ) : "";
  4162. if (empty ( $irid )) {
  4163. echo json_encode ( array (
  4164. 'status' => 2,
  4165. 'msg' => 'illegal request'
  4166. ) );
  4167. die ();
  4168. }
  4169. Doo::loadModel ( 'invoiceReceivables' );
  4170. $invoiceReceivables = new invoiceReceivables ();
  4171. Doo::loadModel ( 'invoice' );
  4172. $invoice = new invoice ();
  4173. $detail = $invoiceReceivables->getInvoiceReceivablesByIrid ( $irid ); // 入账完成 待定 and postStatus=1
  4174. $flag = true;
  4175. $invoiceDetail = $invoice->getInvoiceByTitle ( $detail ['recepitTitleMark'], 'EXACTLY', " and status=2 and printStatus=1 and untreadStatus=0 ", $flag ); //
  4176. $bakDetail = array ();
  4177. if ($flag === false) {
  4178. array_push ( $bakDetail, $invoiceDetail );
  4179. $invoiceDetail = $bakDetail;
  4180. }
  4181. $receivablesHtml = '<table class="table table-bordered table-condensed"><tbody><tr><th class="taC" width="70">收款金额</th><th class="taC">银行到账信息</th><th class="taC">银行/到账时间</th><th class="taC">收款认领</th><th class="taC">开票单位</th></tr>
  4182. <tr>
  4183. <td><b>¥' . $detail ['receivablesPrice'] . '</b></td>
  4184. <td>' . $detail ['receivablesMessage'] . '</td>
  4185. <td>' . $detail ['receivablesBank'] . '<br>' . $detail ['receivablesDate'] . '</td>
  4186. <td>' . $detail ['title'] . '-' . $detail ['username'] . '<br>' . $detail ['confirmTime'] . '</td>
  4187. <td>' . $detail ['recepitTitleMark'] . '</td>
  4188. </tr></tbody></table>';
  4189. $isInvoice = false;
  4190. $invoiceHtml = '';
  4191. if (empty ( $invoiceDetail )) {
  4192. $isInvoice = true;
  4193. } else {
  4194. $invoiceHtml = '<table class="table table-bordered table-condensed">
  4195. <thead><tr><th>开票单位(抬头)</th><th>开票金额</th><th>提交开票</th><th>出票</th><th>开票流水号</th><th width="80">入账</th></tr></thead><tbody>';
  4196. foreach ( $invoiceDetail as $key => $value ) {
  4197. $invoiceHtml .= '<tr>';
  4198. if (! empty ( $value ['invoiceType'] )) {
  4199. $invoiceHtml .= '<td>' . $value ['invoiceCompany'] . '</td>';
  4200. } else {
  4201. $invoiceHtml .= '<td>' . $value ['invoiceTitle'] . '</td>';
  4202. }
  4203. if (! empty ( $value ['invoiceType'] )) {
  4204. $invoiceHtml .= '<td>' . $value ['invoicePrice'] . '专</td>';
  4205. } else {
  4206. $invoiceHtml .= '<td>' . $value ['invoicePrice'] . '</td>';
  4207. }
  4208. $invoiceHtml .= '
  4209. <td>' . $value ['categoryName'] . $value ['userName'] . ' ' . $value ['date'] . '</td>
  4210. <td>' . $value ['printer'] . ' ' . $value ['printTime'] . '</td>
  4211. <td>' . $value ['invoiceSerial'] . '</td><td><a class="button btn-block" bind-receivables="ir" data-ikey="' . $value ['iidKey'] . '" href="javascript:void(0)">入账</a></td>
  4212. </tr>
  4213. ';
  4214. $irList = $invoiceReceivables->getInvoiceReceivablesInIridString ( $value ['irid'] );
  4215. if (empty ( $irList ))
  4216. $irList [0] ['sumPrice'] = 0;
  4217. $balance = $value ['invoicePrice'] - $irList [0] ['sumPrice'];
  4218. $priceString = '';
  4219. if ($balance < $detail ['receivablesPrice']) {
  4220. $priceString = '收款金额超过开票金额,';
  4221. }
  4222. if ($balance > $detail ['receivablesPrice']) {
  4223. $priceString = '收款金额低于开票金额,';
  4224. }
  4225. }
  4226. $invoiceHtml .= '
  4227. <script>
  4228. $(\'a[bind-receivables^="ir"]\').click(function() {
  4229. var data = $(this).attr("data-ikey");
  4230. $("input[name=\'invoiceKey\']").val(data);
  4231. var invoiceKey=data;
  4232. if(invoiceKey==""){
  4233. alert("入账错误,请重新刷新页面");
  4234. return false;
  4235. }
  4236. if(window.confirm("' . $priceString . '确定入账吗?")){
  4237. $("#IBR").submit();
  4238. }else{
  4239. return false;
  4240. }
  4241. });
  4242. </script>
  4243. ';
  4244. $invoiceHtml .= '</tbody></table>';
  4245. }
  4246. echo json_encode ( array (
  4247. 'status' => 1,
  4248. 'irkey' => $detail ['iridEn'],
  4249. 'receivablesHtml' => $receivablesHtml,
  4250. 'isInvoice' => $isInvoice,
  4251. 'invoiceHtml' => $invoiceHtml
  4252. ) );
  4253. }
  4254. function ajaxGetInvoiceReceivablesByTitle() {
  4255. $title = $this->get_args ( 'title' ) ? $this->get_args ( 'title' ) : "";
  4256. if (empty ( $title )) {
  4257. echo json_encode ( array (
  4258. 'status' => 2,
  4259. 'msg' => 'illegal request'
  4260. ) );
  4261. die ();
  4262. }
  4263. Doo::loadModel ( 'invoice' );
  4264. $invoice = new invoice ();
  4265. $invoiceDetail = $invoice->getInvoiceByTitle ( $title, 'EXACTLY', " and status=2 and printStatus=1 and untreadStatus=0 " );
  4266. $invoiceHtml = '';
  4267. if (! empty ( $invoiceDetail )) {
  4268. $invoiceHtml = '<table class="table table-bordered table-condensed">
  4269. <thead><tr><th>开票单位(抬头)</th><th>开票金额</th><th>提交开票</th><th>出票</th><th>开票流水号</th><th width="80">入账</th></tr></thead><tbody><tr>';
  4270. if (! empty ( $invoiceDetail ['invoiceType'] )) {
  4271. $invoiceHtml .= '<td>' . $invoiceDetail ['invoiceCompany'] . '</td>';
  4272. } else {
  4273. $invoiceHtml .= '<td>' . $invoiceDetail ['invoiceTitle'] . '</td>';
  4274. }
  4275. if (! empty ( $invoiceDetail ['invoiceType'] )) {
  4276. $invoiceHtml .= '<td>' . $invoiceDetail ['invoicePrice'] . '专</td>';
  4277. } else {
  4278. $invoiceHtml .= '<td>' . $invoiceDetail ['invoicePrice'] . '</td>';
  4279. }
  4280. $invoiceHtml .= '
  4281. <td>' . $invoiceDetail ['categoryName'] . $invoiceDetail ['userName'] . ' ' . $invoiceDetail ['date'] . '</td>
  4282. <td>' . $invoiceDetail ['printer'] . ' ' . $invoiceDetail ['printTime'] . '</td>
  4283. <td>' . $invoiceDetail ['invoiceSerial'] . '</td><td><a class="button btn-block" bind-receivables="ir' . $invoiceDetail ['iidKeyXD'] . '" data-ikey="' . $invoiceDetail ['iidKey'] . '" href="#">入账</a></td>
  4284. </tr>
  4285. ';
  4286. $invoiceHtml .= '</tbody></table>
  4287. <script>
  4288. $(\'a[bind-receivables="ir' . $invoiceDetail ['iidKeyXD'] . '"]\').click(function() {
  4289. $("input[name=\'invoiceKey\']").val("' . $invoiceDetail ['iidKey'] . '");
  4290. var invoiceKey=$("input[name=\'invoiceKey\']").val();
  4291. if(invoiceKey==""){
  4292. alert("入账错误,请重新刷新页面");
  4293. return false;
  4294. }
  4295. if(window.confirm("确定入账吗?")){
  4296. $("#IBR").submit();
  4297. }else{
  4298. return false;
  4299. }
  4300. });
  4301. </script>
  4302. ';
  4303. }
  4304. echo json_encode ( array (
  4305. 'status' => 1,
  4306. 'invoiceHtml' => $invoiceHtml
  4307. ) );
  4308. }
  4309. function ajaxInvoicePushNotice() {
  4310. Doo::loadModel ( 'invoice' );
  4311. $invoice = new invoice ();
  4312. $approval = $invoice->getOne ( array (
  4313. 'where' => 'status=1 and pendingApprovals=' . $this->staff [0] ['sid'],
  4314. 'desc' => 'iid',
  4315. 'asArray' => true
  4316. ) );
  4317. $isNotice = false;
  4318. if (! empty ( $approval ))
  4319. $isNotice = true;
  4320. $response = array (
  4321. 'error' => 0,
  4322. 'isNotice' => $isNotice
  4323. );
  4324. echo json_encode ( $response );
  4325. exit ();
  4326. }
  4327. public function ajaxCheckInvoiceNoUniqueness() {
  4328. $invoiceNo = $this->get_args ( 'invoiceNo' ) ? $this->get_args ( 'invoiceNo' ) : "";
  4329. Doo::loadModel ( 'invoice' );
  4330. $invoice = new invoice ();
  4331. if (! empty ( $invoiceNo )) {
  4332. $info = $invoice->getOne ( array (
  4333. 'where' => "invoiceNo = '" . $invoiceNo . "'",
  4334. 'asArray' => TRUE
  4335. ) );
  4336. if (! empty ( $info )) {
  4337. echo json_encode ( array (
  4338. 'error' => '发票号已存在'
  4339. ) );
  4340. die ();
  4341. } else
  4342. echo json_encode ( array (
  4343. 'ok' => '可以使用!'
  4344. ) );
  4345. die ();
  4346. }
  4347. }
  4348. function ajaxCheckInvoicePrice() {
  4349. $receivablesPrice = $this->get_args ( 'receivablesPrice' ) && is_numeric ( $this->get_args ( 'receivablesPrice' ) ) ? $this->get_args ( 'receivablesPrice' ) : "";
  4350. $iidKey = $this->get_args ( 'iidKey' ) ? $this->get_args ( 'iidKey' ) : "";
  4351. Doo::loadModel ( 'invoice' );
  4352. $invoice = new invoice ();
  4353. Doo::loadModel ( 'invoiceReceivables' );
  4354. $invoiceReceivables = new invoiceReceivables ();
  4355. Doo::loadClass ( 'XDeode' );
  4356. $XDeode = new XDeode ( 5 );
  4357. if (! empty ( $receivablesPrice ) && ! empty ( $iidKey )) {
  4358. $iidKey = $XDeode->decode ( $iidKey );
  4359. $info = $invoice->getInvoiceByIid ( $iidKey );
  4360. $irList = $invoiceReceivables->getInvoiceReceivablesInIridString ( $info ['irid'] );
  4361. if (empty ( $irList ))
  4362. $irList [0] ['sumPrice'] = 0;
  4363. $balance = $info ['invoicePrice'] - $irList [0] ['sumPrice'];
  4364. if ($balance < $receivablesPrice) {
  4365. echo json_encode ( array (
  4366. 'error' => '收款金额超过开票金额。'
  4367. ) );
  4368. die ();
  4369. }
  4370. if ($balance > $receivablesPrice) {
  4371. echo json_encode ( array (
  4372. 'error' => '收款金额低于开票金额。'
  4373. ) );
  4374. die ();
  4375. }
  4376. }
  4377. }
  4378. /**
  4379. * 旧输入导入
  4380. */
  4381. function importInvoice() {
  4382. $emsg = isset ( $this->params ['emsg'] ) ? $this->params ['emsg'] : "";
  4383. $data ['emsg'] = "";
  4384. if ($emsg != "")
  4385. $data ['emsg'] = "请填写完整的数据";
  4386. $data ['time'] = time ();
  4387. $this->render ( "/admin/invoiceImport", $data );
  4388. }
  4389. function uploadInvoice() {
  4390. // move_uploaded_file($_FILES['Filedata']['tmp_name'], "/upload/".$_FILES['Filedata']['name']);
  4391. if (isset ( $_FILES ['Filedata'] ['name'] )) {
  4392. $file = $_FILES ['Filedata'] ['tmp_name'];
  4393. $error = false;
  4394. if (! is_uploaded_file ( $file )) {
  4395. $error = '400 Bad Request';
  4396. }
  4397. if ($error) {
  4398. header ( 'HTTP/1.0 ' . $error );
  4399. die ( 'Error ' . $error );
  4400. } else {
  4401. include (DOO::conf ()->SITE_PATH . 'protected/plugin/io.han.php');
  4402. $this->IoHandler = new IoHandler ();
  4403. $pics = explode ( '.', $_FILES ['Filedata'] ['name'] );
  4404. // $filedir=$_POST['time'];
  4405. // 调用定义物理路径
  4406. $t = DOO::conf ()->SITE_PATH . "upload/invoice/";
  4407. $this->IoHandler->MakeDir ( $t );
  4408. $filename = $this->_GetFileEXT ( $_FILES ['Filedata'] ['name'] );
  4409. if ($filename != 'xlsx')
  4410. return "";
  4411. // $upload_dir = $t."/".time().rand(10,100).".".$filename;
  4412. $upload_file = iconv ( "UTF-8", "GB2312", $_FILES ["Filedata"] ["name"] );
  4413. $upload_dir = $t . "/" . $upload_file;
  4414. $k = move_uploaded_file ( $file, $upload_dir );
  4415. if ($k) {
  4416. $m = round ( $_FILES ['Filedata'] ['size'] / 1024 / 1024, 2 );
  4417. echo $pics [0] . "." . $filename . "#" . $m . "#" . $_FILES ['Filedata'] ['size'];
  4418. }
  4419. }
  4420. }
  4421. }
  4422. function importInvoiceDo() {
  4423. $path = $this->get_args ( 'path' ) ? $this->get_args ( 'path' ) : "";
  4424. if ($path != "") {
  4425. Doo::loadModel ( 'invoice' );
  4426. Doo::loadModel ( 'staff' );
  4427. $staff = new staff ();
  4428. Doo::loadModel ( 'invoiceStatistics' );
  4429. Doo::loadModel ( 'invoiceOperationLog' );
  4430. echo DOO::conf ()->SITE_PATH . "upload/invoice/" . iconv ( "UTF-8", "GB2312", $path );
  4431. $exlArray = $this->_format_excel_to_array ( DOO::conf ()->SITE_PATH . "upload/invoice/" . $path );
  4432. // print_r ( $exlArray );
  4433. // die ();
  4434. // echo json_encode($exlArray);die;
  4435. foreach ( $exlArray as $key => $value ) {
  4436. // 开票
  4437. $invoice = new invoice ();
  4438. $invoice->invoiceNo = $value ['invoiceNo'];
  4439. $invoice->invoiceType = 0;
  4440. if ($value ['invoiceType'] == '专')
  4441. $invoice->invoiceType = 1;
  4442. $invoice->invoicePrice = $value ['invoicePrice'];
  4443. $invoice->invoiceQuantity = 1;
  4444. $invoice->invoiceUnitPrice = $value ['invoicePrice'];
  4445. $invoice->invoiceTitle = $value ['invoiceTitle'];
  4446. if ($value ['invoiceType'] == '专')
  4447. $invoice->invoiceCompany = $value ['invoiceTitle'];
  4448. $invoice->userName = $value ['userName'];
  4449. $sDetail = $staff->getStaffByName ( $value ['userName'] );
  4450. $invoice->sid = $sDetail ['sid'];
  4451. $invoice->cid = $sDetail ['cid'];
  4452. $invoice->categoryName = $sDetail ['category'];
  4453. $invoice->invoiceElement = $value ['invoiceElement'];
  4454. $invoice->remark = $value ['remark'];
  4455. $invoice->date = $value ['date'];
  4456. $invoice->printTime = $value ['date'];
  4457. $invoice->ipSource = 1;
  4458. $invoice->printStatus = 1;
  4459. $invoice->status = 2;
  4460. $invoice->postStatus = 1;
  4461. $invoice->untreadStatus = 0;
  4462. $invoice->invoiceSerial = "#F" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  4463. $iid = $invoice->insert ();
  4464. // 汇总
  4465. $invoiceStatistics = new invoiceStatistics ();
  4466. //
  4467. $item = array (
  4468. 'date' => $value ['date'],
  4469. 'priceClass' => 1,
  4470. 'cid' => $sDetail ['cid'],
  4471. 'staff' => $sDetail ['sid'],
  4472. 'invoicePrice' => $value ['invoicePrice']
  4473. );
  4474. $invoiceStatistics->setInvoiceStatisticsByCondition ( $item );
  4475. $invoiceOperationLog = new invoiceOperationLog ();
  4476. $item = array (
  4477. 'date' => date ( "Y-m-d H:i:s" ),
  4478. 'operation' => date ( "Y-m-d" ) . " 导入",
  4479. 'status' => 1,
  4480. 'img' => $sDetail ['avatar'],
  4481. 'username' => $sDetail ['username'],
  4482. 'uid' => $sDetail ['sid'],
  4483. 'category' => $sDetail ['category'],
  4484. 'iid' => $iid
  4485. );
  4486. $invoiceOperationLog->setInvoiceOperationLog ( $item );
  4487. }
  4488. return '/importInvoice?count=' . count ( $exlArray );
  4489. // return "/keyonline";
  4490. }
  4491. echo 'no file';
  4492. }
  4493. function importInvoiceReceivables() {
  4494. $emsg = isset ( $this->params ['emsg'] ) ? $this->params ['emsg'] : "";
  4495. $data ['emsg'] = "";
  4496. if ($emsg != "")
  4497. $data ['emsg'] = "请填写完整的数据";
  4498. $data ['time'] = time ();
  4499. $this->render ( "/admin/invoiceReceivablesImport", $data );
  4500. }
  4501. // 导入入账数据
  4502. function importInvoiceReceivablesDo() {
  4503. $path = $this->get_args ( 'path' ) ? $this->get_args ( 'path' ) : "";
  4504. include Doo::conf ()->BASE_PATH . 'diagnostic/debug.php';
  4505. if ($path != "") {
  4506. Doo::loadModel ( 'invoiceReceivables' );
  4507. Doo::loadModel ( 'invoice' );
  4508. Doo::loadModel ( 'staff' );
  4509. $staff = new staff ();
  4510. Doo::loadModel ( 'invoiceStatistics' );
  4511. // echo DOO::conf ()->SITE_PATH . "upload/invoice/" . iconv ( "UTF-8", "GB2312", $path );
  4512. $exlArray = $this->_format_excel_to_array ( DOO::conf ()->SITE_PATH . "upload/invoice/" . iconv ( "UTF-8", "GB2312", $path ), 'invoiceReceivables' );
  4513. // print_r ( $exlArray );
  4514. // die ();
  4515. // echo json_encode($exlArray);die;
  4516. foreach ( $exlArray as $key => $value ) {
  4517. // 收款
  4518. $invoiceReceivables = new invoiceReceivables ();
  4519. $invoice = new invoice ();
  4520. $invoiceReceivables->bindStatus = 1;
  4521. $invoiceReceivables->receivablesPrice = $value ['receivablesPrice'];
  4522. $invoiceReceivables->receivablesMessage = $value ['receivablesMessage'];
  4523. $invoiceReceivables->receivablesBank = $value ['receivablesBank'];
  4524. $invoiceReceivables->receivablesDate = $value ['receivablesDate'];
  4525. $sDetail = $staff->getStaffByName ( $value ['receivablesStaff'] );
  4526. $invoiceReceivables->receivablesCategory = $sDetail ['cid'] . ':' . $sDetail ['category'];
  4527. $invoiceReceivables->receivablesStaff = $sDetail ['sid'] . '-' . $sDetail ['username'];
  4528. $invoiceReceivables->receivablesSerial = "#SK" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  4529. $invoiceReceivables->sourcePrice = $value ['sourcePrice'];
  4530. $iDetail = $invoice->getInvoiceByInvoiceNo ( $value ['invoiceNo'] );
  4531. $invoiceReceivables->iid = $iDetail ['iid'];
  4532. $irid = $invoiceReceivables->insert ();
  4533. // 发票绑定收款
  4534. $detail = $iDetail;
  4535. $iridString = "";
  4536. if (empty ( $detail ['irid'] ))
  4537. $iridString = $irid;
  4538. else
  4539. $iridString = $detail ['irid'] . ',' . $irid;
  4540. $item = array (
  4541. 'irid' => $iridString,
  4542. 'iid' => $detail ['iid']
  4543. );
  4544. $invoice->setInvoiceByCondition ( $item );
  4545. // 汇总
  4546. $invoiceStatistics = new invoiceStatistics ();
  4547. // 扣除入账统计金额
  4548. $item = array (
  4549. 'date' => $value ['receivablesDate'],
  4550. 'priceClass' => 3,
  4551. 'cid' => $sDetail ['cid'],
  4552. 'staff' => $sDetail ['sid'],
  4553. // 'irid' => $irid,
  4554. 'accountPrice' => $value ['receivablesPrice']
  4555. );
  4556. $invoiceStatistics->setInvoiceStatisticsByCondition ( $item );
  4557. }
  4558. return '/importInvoiceReceivables?count=' . count ( $exlArray );
  4559. echo 'data count ' . count ( $exlArray );
  4560. die ();
  4561. // return "/keyonline";
  4562. }
  4563. echo 'no file';
  4564. }
  4565. /**
  4566. * 格式化excel文件为数组
  4567. * @param unknown_type $file_url
  4568. * @param unknown_type $mcid
  4569. */
  4570. function _format_excel_to_array($file_url = "", $sType = "") {
  4571. if (! file_exists ( $file_url )) {
  4572. return array ();
  4573. }
  4574. Doo::loadClass ( 'PHPExcel' );
  4575. $PHPExcel = new PHPExcel ();
  4576. $PHPReader = new PHPExcel_Reader_Excel2007 ();
  4577. if (! $PHPReader->canRead ( $file_url )) {
  4578. $PHPReader = new PHPExcel_Reader_Excel5 ();
  4579. if (! $PHPReader->canRead ( $file_url )) {
  4580. echo 'no Excel';
  4581. return;
  4582. }
  4583. }
  4584. $PHPExcel = $PHPReader->load ( $file_url );
  4585. /* * 读取excel文件中的第一个工作表 */
  4586. $currentSheet = $PHPExcel->getSheet ( 0 );
  4587. /* * 取得最大的列号 */
  4588. $allColumn = $currentSheet->getHighestColumn ();
  4589. /* * 取得一共有多少行 */
  4590. $allRow = $currentSheet->getHighestRow ();
  4591. $excel_array = array ();
  4592. $conk = 2;
  4593. for($currentRow = $conk; $currentRow <= $allRow; $currentRow ++) {
  4594. $excel_column = array ();
  4595. // 后期改进
  4596. if ($allColumn == 'AM')
  4597. $allColumn = 'Z';
  4598. /* * 从第A列开始输出 */
  4599. for($currentColumn = 'A'; $currentColumn <= $allColumn; $currentColumn ++) {
  4600. $val = $currentSheet->getCellByColumnAndRow ( ord ( $currentColumn ) - 65, $currentRow )->getValue ();
  4601. if ($val instanceof PHPExcel_RichText)
  4602. $val = $val->__toString ();
  4603. /* * ord()将字符转为十进制数 iconv ( 'utf-8', 'gb2312', */
  4604. // $val = "'" . addslashes ( $val ) . "'";
  4605. if ($sType == 'invoiceReceivables') {
  4606. if ($currentColumn == 'A')
  4607. $excel_column ['invoiceNo'] = $val;
  4608. elseif ($currentColumn == 'B')
  4609. $excel_column ['receivablesPrice'] = $val;
  4610. elseif ($currentColumn == 'C') {
  4611. $excel_column ['receivablesMessage'] = $val;
  4612. } elseif ($currentColumn == 'D') {
  4613. $excel_column ['receivablesBank'] = $val;
  4614. } elseif ($currentColumn == 'E') {
  4615. $excel_column ['receivablesDate'] = $this->excelTime ( $val );
  4616. } elseif ($currentColumn == 'F') {
  4617. $excel_column ['receivablesStaff'] = $val;
  4618. } elseif ($currentColumn == 'G') {
  4619. $excel_column ['sourcePrice'] = $val;
  4620. }
  4621. } elseif ($sType == "invoiceTrain") {
  4622. if ($currentColumn == 'A')
  4623. $excel_column ['invoiceTitle'] = $val;
  4624. elseif ($currentColumn == 'B')
  4625. $excel_column ['invoiceType'] = $val;
  4626. elseif ($currentColumn == 'C') {
  4627. $excel_column ['TIN'] = $val;
  4628. } elseif ($currentColumn == 'D') {
  4629. $excel_column ['address'] = $val;
  4630. } elseif ($currentColumn == 'E') {
  4631. $excel_column ['phone'] = $val;
  4632. } elseif ($currentColumn == 'F') {
  4633. $excel_column ['bank'] = $val;
  4634. } elseif ($currentColumn == 'G') {
  4635. $excel_column ['bankAccount'] = $val;
  4636. } elseif ($currentColumn == 'H') {
  4637. $excel_column ['invoiceElement'] = $val;
  4638. } elseif ($currentColumn == 'I') {
  4639. $excel_column ['invoiceQuantity'] = $val;
  4640. } elseif ($currentColumn == 'J') {
  4641. $excel_column ['invoiceUnitPrice'] = $val;
  4642. } elseif ($currentColumn == 'K') {
  4643. $excel_column ['remark'] = $val;
  4644. } elseif ($currentColumn == 'L') {
  4645. $excel_column ['recipientsAddress'] = $val;
  4646. } elseif ($currentColumn == 'M') {
  4647. $excel_column ['recipients'] = $val;
  4648. } elseif ($currentColumn == 'N') {
  4649. $excel_column ['recipientsPhone'] = $val;
  4650. }
  4651. } else {
  4652. if ($currentColumn == 'A')
  4653. $excel_column ['invoiceNo'] = $val;
  4654. elseif ($currentColumn == 'B')
  4655. $excel_column ['invoiceType'] = $val;
  4656. elseif ($currentColumn == 'C') {
  4657. $excel_column ['invoicePrice'] = $val;
  4658. } elseif ($currentColumn == 'D') {
  4659. $excel_column ['invoiceTitle'] = $val;
  4660. } elseif ($currentColumn == 'E') {
  4661. $excel_column ['userName'] = $val;
  4662. } elseif ($currentColumn == 'F') {
  4663. $excel_column ['categoryName'] = $val;
  4664. } elseif ($currentColumn == 'G') {
  4665. $excel_column ['invoiceElement'] = $val;
  4666. } elseif ($currentColumn == 'H') {
  4667. $excel_column ['remark'] = $val;
  4668. } elseif ($currentColumn == 'I') {
  4669. $excel_column ['date'] = $this->excelTime ( $val );
  4670. }
  4671. }
  4672. }
  4673. array_push ( $excel_array, $excel_column );
  4674. }
  4675. return $excel_array;
  4676. }
  4677. function excelTime($date, $time = false) {
  4678. if (function_exists ( 'GregorianToJD' )) {
  4679. if (is_numeric ( $date )) {
  4680. $jd = GregorianToJD ( 1, 1, 1970 );
  4681. $gregorian = JDToGregorian ( $jd + intval ( $date ) - 25569 );
  4682. $date = explode ( '/', $gregorian );
  4683. $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" : '');
  4684. return $date_str;
  4685. }
  4686. } else {
  4687. $date = $date > 25568 ? $date + 1 : 25569;
  4688. /* There was a bug if Converting date before 1-1-1970 (tstamp 0) */
  4689. $ofs = (70 * 365 + 17 + 2) * 86400;
  4690. $date = date ( "Y-m-d", ($date * 86400) - $ofs ) . ($time ? " 00:00:00" : '');
  4691. }
  4692. return $date;
  4693. }
  4694. /**
  4695. * 旧输入导入
  4696. */
  4697. function _GetFileEXT($filename) {
  4698. $pics = explode ( '.', $filename );
  4699. $num = count ( $pics );
  4700. return $pics [$num - 1];
  4701. }
  4702. function showCache($path = "") {
  4703. // if (file_exists ( $path )) {
  4704. // $htm = file_get_contents ( $path );
  4705. // } else {
  4706. Doo::loadModel ( 'invoiceStatistics' );
  4707. $invoiceStatistics = new invoiceStatistics ();
  4708. $isBriefly = $invoiceStatistics->getBrieflyStatistics ();
  4709. $htm = '<tr><th class="taC">' . $isBriefly ['statisticsMonth'] [0] ['month'] . '月累计开票</th>
  4710. <td>¥' . $isBriefly ['statisticsMonth'] [0] ['invoicePrice'] . '</td>
  4711. <th class="taC">' . $isBriefly ['statisticsMonth'] [0] ['month'] . '月累计入账</th>
  4712. <td>¥' . $isBriefly ['statisticsMonth'] [0] ['accountPrice'] . '</td></tr>';
  4713. /*
  4714. * '<tr><th class="taC">今年累计开票</th><td>¥' . $isBriefly ['statisticsYear'] [0] ['invoicePrice'] . '</td> <th class="taC">今年累计入账</th><td>¥' . $isBriefly ['statisticsYear'] [0] ['accountPrice'] . '</td></tr>';
  4715. */
  4716. file_put_contents ( $path, $htm, FILE_APPEND );
  4717. // }
  4718. return $htm;
  4719. }
  4720. /**
  4721. * 获取get或者POST值
  4722. *
  4723. * @param string $name 属性名称
  4724. * @return fixed 值
  4725. */
  4726. function get_args($name) {
  4727. if (isset ( $_GET [$name] )) {
  4728. if (is_array ( $_GET [$name] ))
  4729. return $_GET [$name];
  4730. else
  4731. return addslashes ( $_GET [$name] );
  4732. } elseif (isset ( $_POST [$name] )) {
  4733. if (is_array ( $_POST [$name] ))
  4734. return $_POST [$name];
  4735. else
  4736. return addslashes ( $_POST [$name] );
  4737. } else
  4738. return false;
  4739. }
  4740. function SafeFilter(&$arr) {
  4741. $ra = Array (
  4742. '/([\x00-\x08,\x0b-\x0c,\x0e-\x19])/',
  4743. '/script/',
  4744. '/javascript/',
  4745. '/vbscript/',
  4746. '/expression/',
  4747. '/applet/',
  4748. '/meta/',
  4749. '/xml/',
  4750. '/blink/',
  4751. '/link/',
  4752. '/style/',
  4753. '/embed/',
  4754. '/object/',
  4755. '/frame/',
  4756. '/layer/',
  4757. '/title/',
  4758. '/bgsound/',
  4759. '/base/',
  4760. '/onload/',
  4761. '/onunload/',
  4762. '/onchange/',
  4763. '/onsubmit/',
  4764. '/onreset/',
  4765. '/onselect/',
  4766. '/onblur/',
  4767. '/onfocus/',
  4768. '/onabort/',
  4769. '/onkeydown/',
  4770. '/onkeypress/',
  4771. '/onkeyup/',
  4772. '/onclick/',
  4773. '/ondblclick/',
  4774. '/onmousedown/',
  4775. '/onmousemove/',
  4776. '/onmouseout/',
  4777. '/onmouseover/',
  4778. '/onmouseup/',
  4779. '/onunload/'
  4780. );
  4781. if (is_array ( $arr )) {
  4782. foreach ( $arr as $key => $value ) {
  4783. if (! is_array ( $value )) {
  4784. if (! get_magic_quotes_gpc ()) // 不对magic_quotes_gpc转义过的字符使用addslashes(),避免双重转义。
  4785. {
  4786. $value = addslashes ( $value ); // 给单引号(')、双引号(")、反斜线(\)与 NUL(NULL 字符)加上反斜线转义
  4787. }
  4788. $value = preg_replace ( $ra, '', $value ); // 删除非打印字符,粗暴式过滤xss可疑字符串
  4789. $arr [$key] = htmlentities ( strip_tags ( $value ) ); // 去除 HTML 和 PHP 标记并转换为 HTML 实体
  4790. } else {
  4791. SafeFilter ( $arr [$key] );
  4792. }
  4793. }
  4794. }
  4795. }
  4796. /**
  4797. * Escape String
  4798. *
  4799. * @access public
  4800. * @param string
  4801. * @param bool whether or not the string will be used in a LIKE condition
  4802. * @return string
  4803. */
  4804. function escape_str($str, $like = FALSE) {
  4805. if (is_array ( $str )) {
  4806. foreach ( $str as $key => $val ) {
  4807. $str [$key] = $this->escape_str ( $val, $like );
  4808. }
  4809. return $str;
  4810. }
  4811. var_dump ( Doo::db ()->getDbObject () );
  4812. die ();
  4813. if (function_exists ( 'mysql_real_escape_string' ) and is_resource ( Doo::db ()->getDbObject () )) { // Doo::db ()->getDbObject()
  4814. $str = mysql_real_escape_string ( $str, Doo::db ()->getDbObject () );
  4815. } elseif (function_exists ( 'mysql_escape_string' )) {
  4816. $str = mysql_escape_string ( $str );
  4817. } else {
  4818. $str = addslashes ( $str );
  4819. }
  4820. // escape LIKE condition wildcards
  4821. if ($like === TRUE) {
  4822. $str = str_replace ( array (
  4823. '%',
  4824. '_'
  4825. ), array (
  4826. '\\%',
  4827. '\\_'
  4828. ), $str );
  4829. }
  4830. return $str;
  4831. }
  4832. /**
  4833. * 获得分页数据
  4834. * @param unknown_type $table
  4835. * @param unknown_type $condition
  4836. * @param unknown_type $on_page
  4837. * @param unknown_type $page_size
  4838. */
  4839. function get_page($table = "", $condition = "", $on_page = 1, $page_size = 20, $action = "", $get = "", $other = "page") {
  4840. $page_c = "";
  4841. $page ['previous'] = $this->get_previous ( $on_page );
  4842. $page ['on_page'] = $on_page;
  4843. $total_count = $this->get_table_count ( $table, $condition );
  4844. $total = intval ( $total_count / $page_size );
  4845. $page ['total_page'] = ($total_count % $page_size) == 0 ? $total : $total + 1;
  4846. $page ['total_data'] = $total_count;
  4847. $page ['next'] = $on_page == $page ['total_page'] ? $page ['total_page'] : $on_page + 1;
  4848. $i = 1;
  4849. $page_max = 1;
  4850. $page_width = 3;
  4851. if ($on_page >= $page_width) {
  4852. $page_max = intval ( $on_page / $page_width ) + 1;
  4853. $i = intval ( $on_page / $page_width ) * $page_width - 1;
  4854. }
  4855. for(; $i <= $page ['total_page']; $i ++) {
  4856. if ($i == $on_page)
  4857. $page_c .= '<li class="active"><a href="javascript:void(0)">' . $i . '</a></li>';
  4858. else
  4859. $page_c .= '<li><a href="/' . $action . '/' . $i . $get . '">' . $i . '</a></li>';
  4860. if ($i == ($page_width * $page_max))
  4861. break;
  4862. }
  4863. $page ['page'] = $page_c;
  4864. $page ['lower'] = (-- $on_page) * $page_size;
  4865. return $page;
  4866. }
  4867. /**
  4868. * 获取上一页
  4869. * @param unknown_type $on_page
  4870. */
  4871. function get_previous($on_page = 1) {
  4872. return $on_page != 0 ? $on_page - 1 : $on_page;
  4873. }
  4874. /**
  4875. * 获取总页数
  4876. * @param unknown_type $table
  4877. * @param unknown_type $condition
  4878. */
  4879. public function get_table_count($table = "", $condition = "") {
  4880. // $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  4881. $sql = "select count(*) as count from " . $table . " where " . $condition;
  4882. // echo $sql;die;
  4883. $query = Doo::db ()->query ( $sql );
  4884. $result = $query->fetch ();
  4885. return $result ['count'];
  4886. }
  4887. function isInvoiceNew($type = "GLOBAL") {
  4888. Doo::loadModel ( 'invoice' );
  4889. $invoice = new invoice ();
  4890. Doo::loadModel ( 'invoiceReceivables' );
  4891. $invoiceReceivables = new invoiceReceivables ();
  4892. Doo::loadModel ( 'staff' );
  4893. $staff = new staff ();
  4894. $st = $staff->getUserByIdList ( $_COOKIE ["staff"] );
  4895. // 我的发票待处理
  4896. $pendingInvoice = $invoice->getOne ( array ( // or (status=2 and printStatus=1 and untreadStatus=0 ) or (status=2 and printStatus=1 and untreadStatus=2 )
  4897. 'where' => "(status=3 or status=4) and isDelete=0 and sid=" . $st [0] ['sid'],
  4898. 'desc' => 'iid',
  4899. 'asArray' => TRUE
  4900. ) );
  4901. // 我的收款待入账
  4902. /*
  4903. * $myClaim = $invoiceReceivables->getOne ( array ( 'where' => " receivablesStaff like '" . $st [0] ['sid'] . "-%' and receivablesCategory like '" . $st [0] ['cid'] . ":%' and bindStatus=0", 'desc' => 'irid', 'asArray' => TRUE ) );
  4904. */
  4905. // 发票审批
  4906. $approval = $invoice->getOne ( array (
  4907. 'where' => 'status=1 and pendingApprovals=' . $st [0] ['sid'],
  4908. 'desc' => 'iid',
  4909. 'asArray' => true
  4910. ) );
  4911. // 发票邮寄
  4912. $post = $invoice->getOne ( array (
  4913. 'where' => "postStatus=0 and printStatus=1 and isDelete=0 and doPost=1 and status=2",
  4914. 'asArray' => TRUE
  4915. ) );
  4916. // 发票打印
  4917. $print = $invoice->getOne ( array (
  4918. 'where' => "status=2 and printStatus=0 and untreadStatus=0 and moldManage like '%[\"" . $st [0] ['sid'] . "\",%'",
  4919. 'desc' => 'iid',
  4920. 'asArray' => TRUE
  4921. ) );
  4922. // 发票退票 printStatus=1 and
  4923. $untread = $invoice->getOne ( array (
  4924. 'where' => " untreadStatus=1 and status=2 ",
  4925. 'asArray' => TRUE
  4926. ) );
  4927. $new = array (
  4928. 'GLOBAL' => FALSE,
  4929. 'pendingInvoice' => FALSE,
  4930. // 'myClaim' => FALSE,
  4931. 'approval' => FALSE,
  4932. 'post' => FALSE,
  4933. 'print' => FALSE,
  4934. 'untread' => FALSE
  4935. );
  4936. // || ! empty ( $myClaim )
  4937. if (! empty ( $pendingInvoice ) || ! empty ( $approval ) || ! empty ( $post ) || ! empty ( $print ) || ! empty ( $untread ))
  4938. $new ['GLOBAL'] = TRUE;
  4939. if (! empty ( $pendingInvoice ))
  4940. $new ['pendingInvoice'] = TRUE;
  4941. // if (! empty ( $myClaim ))
  4942. // $new ['myClaim'] = TRUE;
  4943. if (! empty ( $approval ))
  4944. $new ['approval'] = TRUE;
  4945. if (! empty ( $post ))
  4946. $new ['post'] = TRUE;
  4947. if (! empty ( $print ))
  4948. $new ['print'] = TRUE;
  4949. if (! empty ( $untread ))
  4950. $new ['untread'] = TRUE;
  4951. return $new;
  4952. }
  4953. function setWXMsg($rid, $typeMsg = '') {
  4954. Doo::loadModel ( 'invoice' );
  4955. $invoice = new invoice ();
  4956. $invoiceDetail = $invoice->getOne ( array (
  4957. 'where' => 'iid=' . $rid,
  4958. 'asArray' => true
  4959. ) );
  4960. if (! empty ( $invoiceDetail )) {
  4961. Doo::loadModel ( 'staff' );
  4962. $staff = new staff ();
  4963. $staffmsg = $staff->getOne ( array (
  4964. 'where' => "sid='" . $invoiceDetail ['sid'] . "'",
  4965. 'asArray' => TRUE
  4966. ) );
  4967. if (! empty ( $staffmsg ['wxid'] )) {
  4968. require_once (SITE_PATH . '/protected/class/client.php');
  4969. $client = new client ( 'http://m.cld.smartcost.com.cn/' );
  4970. $user = $staffmsg ['wxid'];
  4971. $expCom = explode ( ":", $invoiceDetail ['expressCompany'] );
  4972. if (empty ( $expCom ))
  4973. $expCom [0] = '';
  4974. $msg = "";
  4975. if (empty ( $typeMsg ))
  4976. $msg = '太好了,您的发票' . $invoiceDetail ['invoiceSerial'] . ' 已邮寄 ' . $expCom [0] . ' ,快递号: <a href="https://m.kuaidi100.com/result.jsp?nu=' . $invoiceDetail ['expressNumber'] . '" >' . $invoiceDetail ['expressNumber'] . '</a>';
  4977. elseif ($typeMsg == "PRINT")
  4978. $msg = '太好了,您的发票已打印完成。';
  4979. $result = $client->SendMsg ( $user, $msg, 'text' );
  4980. }
  4981. }
  4982. }
  4983. /**
  4984. * 获取微信部门
  4985. * @param string $category
  4986. * @return number|mixed
  4987. */
  4988. function getToparty($category = '') {
  4989. $token = $this->getAccessToken (); //
  4990. $result = json_decode ( $this->httpGet ( "https://qyapi.weixin.qq.com/cgi-bin/department/list?access_token={$token}&id=5" ), true );
  4991. $toparty = 0;
  4992. foreach ( $result ['department'] as $key => $value ) {
  4993. if ($value ['name'] == $category)
  4994. $toparty = $value ['id'];
  4995. }
  4996. return $toparty;
  4997. }
  4998. /**
  4999. * 获得某部门下的用户
  5000. * @param string $toparty
  5001. */
  5002. function getUserByToparty($toparty = '') {
  5003. $token = $this->getAccessToken (); //
  5004. $result = json_decode ( $this->httpGet ( "https://qyapi.weixin.qq.com/cgi-bin/user/simplelist?access_token={$token}&department_id={$toparty}" ), true );
  5005. $userList = array ();
  5006. foreach ( $result ['userlist'] as $key => $value ) {
  5007. array_push ( $userList, "'" . $value ['userid'] . "'" );
  5008. }
  5009. return $userList;
  5010. }
  5011. function msgSendToparty($msg, $title, $url, $toparty, $text = '') {
  5012. $token = $this->getAccessToken ();
  5013. if ($text == 'text') {
  5014. $data = '{
  5015. "touser": "' . $toparty . '",
  5016. "toparty": "",
  5017. "totag": "",
  5018. "msgtype": "text",
  5019. "agentid": 1000002,
  5020. "text": {
  5021. "content": "' . $msg . '"
  5022. },
  5023. "safe":0
  5024. }';
  5025. }
  5026. $result = json_decode ( $this->httpPOST ( "https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token={$token}", $data ) );
  5027. if ($result->errmsg != 'ok') {
  5028. return 0;
  5029. } else {
  5030. return 1;
  5031. }
  5032. }
  5033. /**
  5034. * 获得可以发送微信用户列表
  5035. * @param string $category
  5036. * @return string
  5037. */
  5038. function getWxidByCategory($category = "") {
  5039. if (empty ( $category ))
  5040. return "";
  5041. Doo::loadModel ( 'staff' );
  5042. $staff = new staff ();
  5043. $toparty = $this->getToparty ( $category );
  5044. $wxList = array ();
  5045. $wxString = "";
  5046. if (! empty ( $toparty )) {
  5047. $userList = $this->getUserByToparty ( $toparty );
  5048. $userCon = implode ( ',', $userList );
  5049. // echo $userCon;
  5050. $sidList = $staff->getStaffByWxid ( $userCon );
  5051. foreach ( $sidList as $key => $value ) {
  5052. $falg = $this->isSendNotification ( $value ['sid'], 'receivables' );
  5053. if ($falg) {
  5054. array_push ( $wxList, $value ['wxid'] );
  5055. }
  5056. }
  5057. $wxString = implode ( '|', $wxList );
  5058. }
  5059. return $wxString;
  5060. }
  5061. /**
  5062. * 读取发送信息规则判断是否需要发送
  5063. * @param number $sid
  5064. * @param string $sendType
  5065. * @return boolean
  5066. */
  5067. function isSendNotification($sid = 0, $sendType = '') {
  5068. Doo::loadModel ( "notificationConf" );
  5069. $notificationConf = new notificationConf ();
  5070. $detail = $notificationConf->getNotificationConfBySid ( $sid );
  5071. $conf = array ();
  5072. $sendFlag = true;
  5073. if (! empty ( $detail )) {
  5074. $conf = json_decode ( $detail ['conf'], true );
  5075. if (! empty ( $sendType )) {
  5076. if (isset ( $conf [$sendType] )) {
  5077. if ($conf [$sendType] == "CLOSE")
  5078. $sendFlag = false;
  5079. elseif ($conf [$sendType] == "Weekend") {
  5080. $day = date ( "w" );
  5081. if (1 <= $day && 5 >= $day)
  5082. $sendFlag = false;
  5083. } elseif ($conf [$sendType] == "OneToFriday") {
  5084. $day = date ( "w" );
  5085. if (0 == $day || 6 == $day)
  5086. $sendFlag = false;
  5087. }
  5088. }
  5089. } else
  5090. $sendFlag = false;
  5091. }
  5092. return $sendFlag;
  5093. }
  5094. /**
  5095. * 根据规则发送信息
  5096. * @param unknown $msg
  5097. * @param unknown $title
  5098. * @param unknown $url
  5099. * @param unknown $user
  5100. * @param string $text
  5101. * @return number
  5102. */
  5103. private function msgSend($msg, $title, $url, $user, $sid = 0, $sendType = '') {
  5104. $token = $this->getAccessToken ();
  5105. $falg = $this->isSendNotification ( $sid, $sendType );
  5106. // if ($text == 'text') {
  5107. // $data = '{
  5108. // "touser": "' . $user . '",
  5109. // "toparty": "",
  5110. // "totag": "",
  5111. // "msgtype": "text",
  5112. // "agentid": 1000002,
  5113. // "text": {
  5114. // "content": "' . $msg . '"
  5115. // },
  5116. // "safe":0
  5117. // }';
  5118. // } else {
  5119. $data = '{
  5120. "touser": "' . $user . '",
  5121. "toparty": "",
  5122. "totag": "",
  5123. "msgtype": "news",
  5124. "agentid": 1000002,
  5125. "news": {
  5126. "articles":[
  5127. {
  5128. "title": "' . $title . '",
  5129. "description": "' . $msg . '",
  5130. "url": "' . $url . '",
  5131. "picurl": ""
  5132. }
  5133. ]
  5134. }
  5135. }';
  5136. // }
  5137. if ($falg) {
  5138. $result = json_decode ( $this->httpPOST ( "https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token={$token}", $data ) );
  5139. if ($result->errmsg != 'ok') {
  5140. return 0;
  5141. } else {
  5142. return 1;
  5143. }
  5144. } else
  5145. return 0;
  5146. }
  5147. private function getAccessToken() {
  5148. // access_token 应该全局存储与更新,以下代码以写入到文件中做示例
  5149. // $file = './access_token.txt';
  5150. // $data = json_decode ( file_get_contents ( $file ) );
  5151. // if ($data->expire_time < time () or ! $data->expire_time) {
  5152. // 如果是企业号用以下URL获取access_token
  5153. $url = "https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=$this->appId&corpsecret=$this->appSecret";
  5154. // $url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=$this->appId&secret=$this->appSecret";
  5155. $res = json_decode ( $this->httpGet ( $url ) );
  5156. $access_token = $res->access_token;
  5157. // echo $access_token;
  5158. // if ($access_token) {
  5159. // $data->expire_time = time () + 7000;
  5160. // $data->access_token = $access_token;
  5161. // $fp = fopen ( $file, "w" );
  5162. // fwrite ( $fp, json_encode ( $data ) );
  5163. // fclose ( $fp );
  5164. // }
  5165. // } else {
  5166. // $access_token = $data->access_token;
  5167. // }
  5168. return $access_token;
  5169. }
  5170. private function httpGet($url) {
  5171. $curl = curl_init ();
  5172. curl_setopt ( $curl, CURLOPT_RETURNTRANSFER, true );
  5173. curl_setopt ( $curl, CURLOPT_TIMEOUT, 500 );
  5174. // 为保证第三方服务器与微信服务器之间数据传输的安全性,所有微信接口采用https方式调用,必须使用下面2行代码打开ssl安全校验。
  5175. // 如果在部署过程中代码在此处验证失败,请到 http://curl.haxx.se/ca/cacert.pem 下载新的证书判别文件。
  5176. curl_setopt ( $curl, CURLOPT_SSL_VERIFYPEER, true );
  5177. curl_setopt ( $curl, CURLOPT_SSL_VERIFYHOST, false );
  5178. curl_setopt ( $curl, CURLOPT_URL, $url );
  5179. $res = curl_exec ( $curl );
  5180. curl_close ( $curl );
  5181. return $res;
  5182. }
  5183. private function httpPost($url, $data) {
  5184. $curl = curl_init ();
  5185. curl_setopt ( $curl, CURLOPT_RETURNTRANSFER, true );
  5186. curl_setopt ( $curl, CURLOPT_TIMEOUT, 500 );
  5187. // 为保证第三方服务器与微信服务器之间数据传输的安全性,所有微信接口采用https方式调用,必须使用下面2行代码打开ssl安全校验。
  5188. // 如果在部署过程中代码在此处验证失败,请到 http://curl.haxx.se/ca/cacert.pem 下载新的证书判别文件。
  5189. curl_setopt ( $curl, CURLOPT_SSL_VERIFYPEER, true );
  5190. curl_setopt ( $curl, CURLOPT_SSL_VERIFYHOST, false );
  5191. curl_setopt ( $curl, CURLOPT_URL, $url );
  5192. curl_setopt ( $curl, CURLOPT_POST, 1 );
  5193. curl_setopt ( $curl, CURLOPT_POSTFIELDS, $data );
  5194. $res = curl_exec ( $curl );
  5195. curl_close ( $curl );
  5196. return $res;
  5197. }
  5198. }
  5199. ?>