InvoiceController.php 288 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829
  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. // 单独判断办事处汇总的访问权限 invoiceAggregateCategoryDetail,invoiceAggregateStaffDetail
  65. if ($action == 'invoiceAggregateCategoryDetail' || $action == 'invoiceAggregateStaffDetail') {
  66. Doo::loadModel ( "invoiceCategoryManage" );
  67. $invoiceCategoryManage = new invoiceCategoryManage ();
  68. $icm = $invoiceCategoryManage->getInvoiceCMByStaff ( $sid );
  69. if (empty ( $icm ))
  70. die ( 'illegal request' );
  71. }
  72. // 单独判断应收款访问权限
  73. if ($action == 'invoiceAggregateCompanyDetail') {
  74. Doo::loadModel ( "invoiceCompanyManage" );
  75. $invoiceCompanyManage = new invoiceCompanyManage ();
  76. $icm = $invoiceCompanyManage->getInvoiceCMByStaff ( $sid );
  77. if (empty ( $icm ))
  78. die ( 'illegal request' );
  79. }
  80. if (! $flag)
  81. die ( 'illegal request' );
  82. }
  83. function __construct() {
  84. if (isset ( $_COOKIE ["staff"] )) {
  85. if (! empty ( $_COOKIE ["staff"] )) {
  86. Doo::loadModel ( 'staff' );
  87. $staff = new staff ();
  88. $uriPartsOrig = explode ( '/', $_SERVER ['REQUEST_URI'] );
  89. $this->ACTION = $uriPartsOrig [1];
  90. $this->data ['new'] = $this->isInvoiceNew ();
  91. $this->staff = $staff->getUserByIdList ( $_COOKIE ["staff"] );
  92. return "/";
  93. }
  94. }
  95. Doo::loadCore ( 'uri/DooUriRouter' );
  96. $router = new DooUriRouter ();
  97. $routeRs = $router->execute ( Doo::app ()->route, Doo::conf ()->SUBFOLDER );
  98. if ($routeRs ['1'] != "login") {
  99. header ( 'Content-Type:text/html;charset=utf-8' );
  100. @header ( "Location: /login" );
  101. }
  102. }
  103. function testSend() {
  104. // 测试根据规则发送信息 普通发送
  105. // $pendingApprovalsSid = 41;
  106. // Doo::loadModel ( 'staff' );
  107. // $staff = new staff ();
  108. // $username2 = $staff->getOne ( array ( 'select' => 'wxid', 'where' => 'sid=' . $pendingApprovalsSid, 'asArray' => TRUE ) );
  109. // // 发送微信审批通知
  110. // $title2 = '[通知]用户提交了一条开票申请,快到“我的发票”中查看,给用户确认审批。';
  111. // $this->msgSend ( '', $title2, '', $username2 ['wxid'], $pendingApprovalsSid, 'approval' );
  112. // Doo::loadModel ( 'staff' );
  113. // $staff = new staff ();
  114. // $toparty = $this->getToparty ( '广东办' );
  115. // $wxList = array ();
  116. // if (! empty ( $toparty )) {
  117. // $userList = $this->getUserByToparty ( $toparty );
  118. // $userCon = implode ( ',', $userList );
  119. // // echo $userCon;
  120. // $sidList = $staff->getStaffByWxid ( $userCon );
  121. // foreach ( $sidList as $key => $value ) {
  122. // $falg = $this->isSendNotification ( $value ['sid'], 'receivables' );
  123. // if ($falg) {
  124. // array_push ( $wxList, $value ['wxid'] );
  125. // }
  126. // }
  127. // $wxString = implode ( '|', $wxList );
  128. // print_r ( $wxList );
  129. // echo $wxString;
  130. // }
  131. // 测试发送
  132. /*
  133. * //$toparty = $this->getWxidByCategory( $receivablesCategory [1] ); $toparty = $this->getToparty ( $receivablesCategory [1] ); $msg = '[通知]财务录入了一笔待认领款项,快到“我的收款”中查看,确认是否是您的客户给您打款了。'; if ($toparty != 0) $this->msgSendToparty ( $msg, '', '', $toparty, 'text' );
  134. */
  135. // print_r ( $userList );
  136. // $msTouser='caipin|outaozhen';
  137. // $toparty = $this->getToparty ( $receivablesCategory [1] );
  138. // $title2 = '[通知]财务录入了一笔待认领款项,快到“我的收款”中查看,确认是否是您的客户给您打款了。';
  139. // $hfreult = $this->msgSend ( '', $title2, '', 'outaozhen' );
  140. // $toparty= $this->getToparty('广东办');
  141. // $msg = '[通知]财务录入了一笔待认领款项,快到“我的收款”中查看,确认是否是您的客户给您打款了。';
  142. // $toparty = 26;
  143. // $msg = '';
  144. // $url = 'http://m.cld.smartcost.com.cn/invoicePrintDetail/1.html';
  145. // $hfreult = $this->msgSendToparty ( $msg, '', '', $toparty,'text' );
  146. }
  147. function invoice() {
  148. Doo::loadModel ( 'invoice' );
  149. $invoice = new invoice ();
  150. Doo::loadModel ( 'express' );
  151. $express = new express ();
  152. $expressList = $express->getExpressByAll ();
  153. $this->data ['expressList'] = $expressList;
  154. // Doo::loadModel ( 'invoiceReceivables' );
  155. // $invoiceReceivables = new invoiceReceivables ();
  156. // $list = $invoiceReceivables->getInvoiceReceivablesByClaim ( $this->staff [0] ['cid'], $this->staff [0] ['sid'] );
  157. Doo::loadClass ( 'XDeode' );
  158. $XDeode = new XDeode ( 5 );
  159. $sid = $XDeode->decode ( $_COOKIE ["staff"] );
  160. Doo::loadModel ( 'invoiceStatistics' );
  161. $invoiceStatistics = new invoiceStatistics ();
  162. $isMonth = $invoiceStatistics->getStatisticsByMonth ( $sid );
  163. // 缓存统计结果
  164. $year = date ( "Y" );
  165. $tmp_date = date ( "Ym" );
  166. $tmp_year = substr ( $tmp_date, 0, 4 );
  167. $tmp_mon = substr ( $tmp_date, 4, 2 );
  168. $tmp_forwardmonth = mktime ( 0, 0, 0, $tmp_mon - 1, 1, $tmp_year );
  169. $fm_forward_month = date ( "m", $tmp_forwardmonth );
  170. $path = SITE_PATH . $this->INVOICECOLLECTPATH . "invoiceCollect_" . $year . "_" . $fm_forward_month . "_" . $sid . ".htm";
  171. if (is_file ( $path ))
  172. $htm = file_get_contents ( $path );
  173. else
  174. $htm = $this->showCache ( $path, $sid );
  175. $invoiceList = $invoice->getMyInvoice ( $sid );
  176. $sql = 'status=2 and printStatus=1 and irid!="" and sid=' . $sid;
  177. $list = $invoice->getInvoiceByUntreadStatusPage ( 4, $sql );
  178. // 我的待入账发票 and irid='' and ( (doPost=1 and postStatus=1) or doPost=0 )
  179. $sql = "status=2 and printStatus=1 and untreadStatus=0 and isDelete=0 and sid=" . $sid;
  180. $myInvoiceUnAccount = $invoice->getInvoiceByUntreadStatusPage ( 4, $sql );
  181. // print_r($myInvoiceUnAccount);
  182. $this->data ['isMonth'] = $isMonth;
  183. $this->data ['htm'] = $htm;
  184. $this->data ['invoiceList'] = $invoiceList;
  185. $this->data ['receivablesList'] = $list;
  186. $this->data ['myInvoiceUnAccount'] = $myInvoiceUnAccount;
  187. $this->data ['memu'] = "invoice";
  188. $this->data ['staff'] = $this->staff;
  189. $this->data ['receiptMemu'] = 'invoice';
  190. $this->render ( "/admin/invoice", $this->data );
  191. }
  192. function invoiceExpress() {
  193. $expressCom = isset ( $this->params ['expressCom'] ) ? $this->params ['expressCom'] : "";
  194. $expressNumber = isset ( $this->params ['expressNumber'] ) ? $this->params ['expressNumber'] : "";
  195. $this->data ['expressCom'] = $expressCom;
  196. $this->data ['expressNumber'] = $expressNumber;
  197. $this->render ( "/admin/invoiceExpress", $this->data );
  198. }
  199. function invoiceAdd() {
  200. Doo::loadModel ( 'L_category' );
  201. $lCategory = new L_category ();
  202. $category = $lCategory->find ( array (
  203. 'asArray' => true
  204. ) );
  205. $this->data ['category'] = $category;
  206. $this->data ['memu'] = "invoice";
  207. $this->data ['staff'] = $this->staff;
  208. $this->data ['receiptMemu'] = 'invoice';
  209. $this->render ( "/admin/invoiceAdd", $this->data );
  210. }
  211. /**
  212. * 提交一份开票申请,并记录下操作日志
  213. *
  214. * @since 1.0.0
  215. * @var integer cid 办事处ID
  216. * @var integer invoiceType 发票类型
  217. * @var integer doPost 是否邮寄
  218. * @var integer invoicePrice 开票金额
  219. * @var string invoiceElement 开票内容
  220. * @var string invoiceTitle 发票抬头
  221. * @var string invoiceCompany 单位名称
  222. * @var string TIN 纳税人识别码
  223. * @var string address 注册地址
  224. * @var string phone 注册电话
  225. * @var string bank 开户银行
  226. * @var string bankAccount 银行账户
  227. * @var string recipients 收件人
  228. * @var string recipientsPhone 收件人手机/电话
  229. * @var string recipientsAddress 收件地址
  230. * @var string mailItems 邮寄物品
  231. * @var string remark 备注
  232. * @return string 返回跳转开票主页路径
  233. */
  234. function invoiceAddDo() {
  235. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  236. $invoiceType = $this->get_args ( 'invoiceType' ) && is_numeric ( $this->get_args ( 'invoiceType' ) ) ? $this->get_args ( 'invoiceType' ) : 0;
  237. $doPost = $this->get_args ( 'doPost' ) && is_numeric ( $this->get_args ( 'doPost' ) ) ? $this->get_args ( 'doPost' ) : 0;
  238. $invoicePrice = $this->get_args ( 'invoicePrice' ) ? $this->get_args ( 'invoicePrice' ) : "";
  239. $invoiceQuantity = $this->get_args ( 'invoiceQuantity' ) && is_numeric ( $this->get_args ( 'invoiceQuantity' ) ) ? $this->get_args ( 'invoiceQuantity' ) : 0;
  240. $invoiceUnitPrice = $this->get_args ( 'invoiceUnitPrice' ) && is_numeric ( $this->get_args ( 'invoiceUnitPrice' ) ) ? $this->get_args ( 'invoiceUnitPrice' ) : 0;
  241. $invoiceElement = $this->get_args ( 'invoiceElement' ) ? $this->get_args ( 'invoiceElement' ) : "";
  242. $invoiceTitle = $this->get_args ( 'invoiceTitle' ) ? $this->get_args ( 'invoiceTitle' ) : "";
  243. $invoiceCompany = $this->get_args ( 'invoiceCompany' ) ? $this->get_args ( 'invoiceCompany' ) : "";
  244. $TIN = $this->get_args ( 'TIN' ) ? $this->get_args ( 'TIN' ) : "";
  245. $address = $this->get_args ( 'address' ) ? $this->get_args ( 'address' ) : "";
  246. $phone = $this->get_args ( 'phone' ) ? $this->get_args ( 'phone' ) : "";
  247. $bank = $this->get_args ( 'bank' ) ? $this->get_args ( 'bank' ) : "";
  248. $bankAccount = $this->get_args ( 'bankAccount' ) ? $this->get_args ( 'bankAccount' ) : "";
  249. $recipients = $this->get_args ( 'recipients' ) ? $this->get_args ( 'recipients' ) : "";
  250. $recipientsPhone = $this->get_args ( 'recipientsPhone' ) ? $this->get_args ( 'recipientsPhone' ) : "";
  251. $recipientsAddress = $this->get_args ( 'recipientsAddress' ) ? $this->get_args ( 'recipientsAddress' ) : "";
  252. $remark = $this->get_args ( 'remark' ) ? $this->get_args ( 'remark' ) : "";
  253. $TINT = $this->get_args ( 'TINT' ) ? $this->get_args ( 'TINT' ) : "";
  254. $addressT = $this->get_args ( 'addressT' ) ? $this->get_args ( 'addressT' ) : "";
  255. $phoneT = $this->get_args ( 'phoneT' ) ? $this->get_args ( 'phoneT' ) : "";
  256. $bankT = $this->get_args ( 'bankT' ) ? $this->get_args ( 'bankT' ) : "";
  257. $bankAccountT = $this->get_args ( 'bankAccountT' ) ? $this->get_args ( 'bankAccountT' ) : "";
  258. $softLock = $this->get_args ( 'softLock' ) ? $this->get_args ( 'softLock' ) : 0;
  259. $softLockNum = $this->get_args ( 'softLockNum' ) ? $this->get_args ( 'softLockNum' ) : 0;
  260. $contract = $this->get_args ( 'contract' ) ? $this->get_args ( 'contract' ) : 0;
  261. $contractNum = $this->get_args ( 'contractNum' ) ? $this->get_args ( 'contractNum' ) : 0;
  262. $instructions = $this->get_args ( 'instructions' ) ? $this->get_args ( 'instructions' ) : 0;
  263. $instructionsNum = $this->get_args ( 'instructionsNum' ) ? $this->get_args ( 'instructionsNum' ) : 0;
  264. $remittance = $this->get_args ( 'remittance' ) ? $this->get_args ( 'remittance' ) : 0;
  265. $mailItems = $this->get_args ( 'mailItems' ) ? $this->get_args ( 'mailItems' ) : "";
  266. /*
  267. * $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;
  268. */
  269. if (empty ( $this->staff [0] ))
  270. die ( 'illegal request' );
  271. if (! empty ( $cid ) && ! empty ( $invoiceQuantity ) && ! empty ( $invoiceUnitPrice ) && ! empty ( $invoiceElement )) {
  272. Doo::loadModel ( 'invoice' );
  273. $invoice = new invoice ();
  274. Doo::loadModel ( 'L_category' );
  275. $lCategory = new L_category ();
  276. Doo::loadModel ( 'invoiceManage' );
  277. $invoiceManage = new invoiceManage ();
  278. Doo::loadModel ( 'invoiceOperationLog' );
  279. $invoiceOperationLog = new invoiceOperationLog ();
  280. $categoryDetil = $lCategory->getOne ( array (
  281. 'SELECT' => 'title',
  282. 'where' => 'cid=' . $cid,
  283. 'asArray' => true
  284. ) );
  285. $invoicePrice = $invoiceQuantity * $invoiceUnitPrice;
  286. $invoiceManageList = $invoiceManage->getInvoiceByAll ();
  287. $invoiceManageDetail = $invoiceManage->getInvoiceByMold ( "发票审批" );
  288. // print_r(current($invoiceManageDetail ['staffList']));
  289. // die;
  290. $moldManage = array ();
  291. foreach ( $invoiceManageList as $key => $value ) {
  292. if ($value ['mold'] == '发票打印')
  293. $moldManage [$value ['mold']] = $value ['staffList'];
  294. elseif ($value ['mold'] == '发票邮寄')
  295. $moldManage [$value ['mold']] = $value ['staffList'];
  296. elseif ($value ['mold'] == '发票退票')
  297. $moldManage [$value ['mold']] = $value ['staffList'];
  298. }
  299. $pendingApprovalsSid = current ( $invoiceManageDetail ['staffList'] ) [0];
  300. $item = array (
  301. 'cid' => $cid,
  302. 'categoryName' => $categoryDetil ['title'],
  303. 'invoiceElement' => $invoiceElement,
  304. 'invoiceQuantity' => $invoiceQuantity,
  305. 'invoiceUnitPrice' => $invoiceUnitPrice,
  306. 'invoicePrice' => $invoicePrice,
  307. 'invoiceType' => $invoiceType,
  308. 'doPost' => $doPost,
  309. 'status' => 1,
  310. 'invoiceSerial' => "#F" . date ( "Ymd" ) . mt_rand ( 1000, 9999 ),
  311. 'date' => date ( "Y-m-d H:i:s" ),
  312. 'updateTime' => date ( "Y-m-d H:i:s" ),
  313. 'sid' => $this->staff [0] ['sid'],
  314. 'userName' => $this->staff [0] ['username'],
  315. 'invoiceManage' => $invoiceManageDetail ['staff'],
  316. 'pendingApprovals' => $pendingApprovalsSid,
  317. 'moldManage' => json_encode ( $moldManage ),
  318. 'remark' => $remark
  319. );
  320. if ($invoiceType == 0)
  321. $item += array (
  322. 'invoiceTitle' => $invoiceTitle,
  323. 'TIN' => $TINT,
  324. 'address' => $addressT,
  325. 'phone' => $phoneT,
  326. 'bank' => $bankT,
  327. 'bankAccount' => $bankAccountT
  328. );
  329. else {
  330. $item += array (
  331. 'invoiceCompany' => $invoiceCompany,
  332. 'TIN' => $TIN,
  333. 'address' => $address,
  334. 'phone' => $phone,
  335. 'bank' => $bank,
  336. 'bankAccount' => $bankAccount
  337. );
  338. }
  339. if ($doPost == 1) {
  340. $mailList = array (
  341. 'invoice' => 1,
  342. 'mailItems' => $mailItems
  343. );
  344. if (! empty ( $softLock ))
  345. $mailList += array (
  346. 'softLock' => $softLockNum
  347. );
  348. else
  349. $mailList += array (
  350. 'softLock' => 0
  351. );
  352. if (! empty ( $contract ))
  353. $mailList += array (
  354. 'contract' => $contractNum
  355. );
  356. else
  357. $mailList += array (
  358. 'contract' => 0
  359. );
  360. if (! empty ( $instructions ))
  361. $mailList += array (
  362. 'instructions' => $instructionsNum
  363. );
  364. else
  365. $mailList += array (
  366. 'instructions' => 0
  367. );
  368. if (! empty ( $remittance ))
  369. $mailList += array (
  370. 'remittance' => $remittance
  371. );
  372. else
  373. $mailList += array (
  374. 'remittance' => ''
  375. );
  376. $mailString = '发票x1,备注:' . $mailItems;
  377. if (! empty ( $softLock ))
  378. $mailString .= ',软件锁x' . $softLockNum;
  379. if (! empty ( $contract ))
  380. $mailString .= ',合同x' . $contractNum;
  381. if (! empty ( $instructions ))
  382. $mailString .= ',说明书x' . $instructionsNum;
  383. if (! empty ( $remittance ))
  384. $mailString .= ',汇款账号单';
  385. $item += array (
  386. 'recipients' => $recipients,
  387. 'recipientsPhone' => $recipientsPhone,
  388. 'recipientsAddress' => $recipientsAddress,
  389. 'mailItems' => $mailString,
  390. 'mailItemsJson' => json_encode ( $mailList )
  391. );
  392. }
  393. $iid = $invoice->addInvoice ( $item );
  394. $item = array (
  395. 'date' => date ( "Y-m-d H:i:s" ),
  396. 'operation' => "创建",
  397. 'status' => 1,
  398. 'img' => $this->staff [0] ['avatar'],
  399. 'username' => $this->staff [0] ['username'],
  400. 'uid' => $this->staff [0] ['sid'],
  401. 'category' => $this->staff [0] ['category'],
  402. 'iid' => $iid
  403. );
  404. $invoiceOperationLog->setInvoiceOperationLog ( $item );
  405. $item = array (
  406. 'date' => date ( "Y-m-d H:i:s" ),
  407. 'operation' => "提交审批",
  408. 'status' => 1,
  409. 'img' => $this->staff [0] ['avatar'],
  410. 'username' => $this->staff [0] ['username'],
  411. 'uid' => $this->staff [0] ['sid'],
  412. 'category' => $this->staff [0] ['category'],
  413. 'iid' => $iid
  414. );
  415. $invoiceOperationLog->setInvoiceOperationLog ( $item );
  416. Doo::loadModel ( 'staff' );
  417. $staff = new staff ();
  418. $username2 = $staff->getOne ( array (
  419. 'select' => 'wxid',
  420. 'where' => 'sid=' . $pendingApprovalsSid,
  421. 'asArray' => TRUE
  422. ) );
  423. // 发送微信审批通知
  424. $title2 = '[通知]用户提交了一条开票申请,快到“我的发票”中查看,给用户确认审批。';
  425. $this->msgSend ( '', $title2, '', $username2 ['wxid'], $pendingApprovalsSid, 'approval' );
  426. }
  427. return "/invoice";
  428. }
  429. function invoiceEdit() {
  430. Doo::loadClass ( 'XDeode' );
  431. $XDeode = new XDeode ( 5 );
  432. $iid = isset ( $this->params ['iid'] ) ? $this->params ['iid'] : "";
  433. $iid = $XDeode->decode ( $iid );
  434. if (! is_numeric ( $iid ))
  435. die ( 'illegal request' );
  436. Doo::loadModel ( 'invoice' );
  437. $invoice = new invoice ();
  438. Doo::loadModel ( 'invoiceOperationLog' );
  439. $invoiceOperationLog = new invoiceOperationLog ();
  440. $invoiceDetail = $invoice->getInvoiceByIid ( $iid );
  441. $operation = $invoiceOperationLog->getInvoiceOperationByDropped ( $iid );
  442. $invoiceDetail ['mailItemsJson'] = json_decode ( $invoiceDetail ['mailItemsJson'], true );
  443. $this->data ['operation'] = $operation;
  444. $this->data ['invoiceDetail'] = $invoiceDetail;
  445. $this->data ['memu'] = "invoice";
  446. $this->data ['staff'] = $this->staff;
  447. $this->data ['receiptMemu'] = 'invoice';
  448. $this->render ( "/admin/invoiceEdit", $this->data );
  449. }
  450. /**
  451. * 重新编辑退回的发票
  452. * @return string
  453. */
  454. function invoiceEditDo() {
  455. $iidKey = $this->get_args ( 'iidKey' ) ? $this->get_args ( 'iidKey' ) : '';
  456. Doo::loadModel ( 'invoice' );
  457. $invoice = new invoice ();
  458. $iid = $invoice->authcode ( $iidKey );
  459. if (! empty ( $iid ) && ! is_numeric ( $iid ))
  460. die ( 'illegal request' );
  461. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  462. $invoiceType = $this->get_args ( 'invoiceType' ) && is_numeric ( $this->get_args ( 'invoiceType' ) ) ? $this->get_args ( 'invoiceType' ) : 0;
  463. $doPost = $this->get_args ( 'doPost' ) && is_numeric ( $this->get_args ( 'doPost' ) ) ? $this->get_args ( 'doPost' ) : 0;
  464. $invoicePrice = $this->get_args ( 'invoicePrice' ) ? $this->get_args ( 'invoicePrice' ) : "";
  465. $invoiceQuantity = $this->get_args ( 'invoiceQuantity' ) && is_numeric ( $this->get_args ( 'invoiceQuantity' ) ) ? $this->get_args ( 'invoiceQuantity' ) : 0;
  466. $invoiceUnitPrice = $this->get_args ( 'invoiceUnitPrice' ) && is_numeric ( $this->get_args ( 'invoiceUnitPrice' ) ) ? $this->get_args ( 'invoiceUnitPrice' ) : 0;
  467. $invoiceElement = $this->get_args ( 'invoiceElement' ) ? $this->get_args ( 'invoiceElement' ) : "";
  468. $invoiceTitle = $this->get_args ( 'invoiceTitle' ) ? $this->get_args ( 'invoiceTitle' ) : "";
  469. $invoiceCompany = $this->get_args ( 'invoiceCompany' ) ? $this->get_args ( 'invoiceCompany' ) : "";
  470. $TIN = $this->get_args ( 'TIN' ) ? $this->get_args ( 'TIN' ) : "";
  471. $address = $this->get_args ( 'address' ) ? $this->get_args ( 'address' ) : "";
  472. $phone = $this->get_args ( 'phone' ) ? $this->get_args ( 'phone' ) : "";
  473. $bank = $this->get_args ( 'bank' ) ? $this->get_args ( 'bank' ) : "";
  474. $bankAccount = $this->get_args ( 'bankAccount' ) ? $this->get_args ( 'bankAccount' ) : "";
  475. $recipients = $this->get_args ( 'recipients' ) ? $this->get_args ( 'recipients' ) : "";
  476. $recipientsPhone = $this->get_args ( 'recipientsPhone' ) ? $this->get_args ( 'recipientsPhone' ) : "";
  477. $recipientsAddress = $this->get_args ( 'recipientsAddress' ) ? $this->get_args ( 'recipientsAddress' ) : "";
  478. $mailItems = $this->get_args ( 'mailItems' ) ? $this->get_args ( 'mailItems' ) : "";
  479. $remark = $this->get_args ( 'remark' ) ? $this->get_args ( 'remark' ) : "";
  480. $TINT = $this->get_args ( 'TINT' ) ? $this->get_args ( 'TINT' ) : "";
  481. $addressT = $this->get_args ( 'addressT' ) ? $this->get_args ( 'addressT' ) : "";
  482. $phoneT = $this->get_args ( 'phoneT' ) ? $this->get_args ( 'phoneT' ) : "";
  483. $bankT = $this->get_args ( 'bankT' ) ? $this->get_args ( 'bankT' ) : "";
  484. $bankAccountT = $this->get_args ( 'bankAccountT' ) ? $this->get_args ( 'bankAccountT' ) : "";
  485. $softLock = $this->get_args ( 'softLock' ) ? $this->get_args ( 'softLock' ) : 0;
  486. $softLockNum = $this->get_args ( 'softLockNum' ) ? $this->get_args ( 'softLockNum' ) : 0;
  487. $contract = $this->get_args ( 'contract' ) ? $this->get_args ( 'contract' ) : 0;
  488. $contractNum = $this->get_args ( 'contractNum' ) ? $this->get_args ( 'contractNum' ) : 0;
  489. $instructions = $this->get_args ( 'instructions' ) ? $this->get_args ( 'instructions' ) : 0;
  490. $instructionsNum = $this->get_args ( 'instructionsNum' ) ? $this->get_args ( 'instructionsNum' ) : 0;
  491. $remittance = $this->get_args ( 'remittance' ) ? $this->get_args ( 'remittance' ) : 0;
  492. if (! empty ( $cid ) && ! empty ( $invoiceQuantity ) && ! empty ( $invoiceUnitPrice ) && ! empty ( $invoiceElement ) && ! empty ( $iid )) {
  493. Doo::loadModel ( 'invoiceManage' );
  494. $invoiceManage = new invoiceManage ();
  495. Doo::loadModel ( 'invoiceOperationLog' );
  496. $invoiceOperationLog = new invoiceOperationLog ();
  497. $cid = explode ( ':', $cid );
  498. $invoiceManageList = $invoiceManage->getInvoiceByAll ();
  499. $invoiceManageDetail = $invoiceManage->getInvoiceByMold ( "发票审批" );
  500. $moldManage = array ();
  501. foreach ( $invoiceManageList as $key => $value ) {
  502. if ($value ['mold'] == '发票打印')
  503. $moldManage [$value ['mold']] = $value ['staffList'];
  504. elseif ($value ['mold'] == '发票邮寄')
  505. $moldManage [$value ['mold']] = $value ['staffList'];
  506. elseif ($value ['mold'] == '发票打印')
  507. $moldManage [$value ['mold']] = $value ['staffList'];
  508. }
  509. $invoicePrice = $invoiceQuantity * $invoiceUnitPrice;
  510. $item = array (
  511. 'iid' => $iid,
  512. 'cid' => $cid [0],
  513. 'categoryName' => $cid [1],
  514. 'invoiceElement' => $invoiceElement,
  515. 'invoiceQuantity' => $invoiceQuantity,
  516. 'invoiceUnitPrice' => $invoiceUnitPrice,
  517. 'invoicePrice' => $invoicePrice,
  518. 'invoiceType' => $invoiceType,
  519. 'doPost' => $doPost,
  520. 'status' => 1,
  521. 'updateTime' => date ( "Y-m-d H:i:s" ),
  522. 'remark' => $remark
  523. );
  524. if ($invoiceType == 0)
  525. $item += array (
  526. 'invoiceTitle' => $invoiceTitle,
  527. 'TIN' => $TINT,
  528. 'address' => $addressT,
  529. 'phone' => $phoneT,
  530. 'bank' => $bankT,
  531. 'bankAccount' => $bankAccountT
  532. );
  533. else {
  534. $item += array (
  535. 'invoiceCompany' => $invoiceCompany,
  536. 'TIN' => $TIN,
  537. 'address' => $address,
  538. 'phone' => $phone,
  539. 'bank' => $bank,
  540. 'bankAccount' => $bankAccount
  541. );
  542. }
  543. if ($doPost == 1) {
  544. $mailList = array (
  545. 'invoice' => 1,
  546. 'mailItems' => $mailItems
  547. );
  548. if (! empty ( $softLock ))
  549. $mailList += array (
  550. 'softLock' => $softLockNum
  551. );
  552. else
  553. $mailList += array (
  554. 'softLock' => '0'
  555. );
  556. if (! empty ( $contract ))
  557. $mailList += array (
  558. 'contract' => $contractNum
  559. );
  560. else
  561. $mailList += array (
  562. 'contract' => '0'
  563. );
  564. if (! empty ( $instructions ))
  565. $mailList += array (
  566. 'instructions' => $instructionsNum
  567. );
  568. else
  569. $mailList += array (
  570. 'instructions' => '0'
  571. );
  572. if (! empty ( $remittance ))
  573. $mailList += array (
  574. 'remittance' => $remittance
  575. );
  576. else
  577. $mailList += array (
  578. 'remittance' => ''
  579. );
  580. $mailString = '发票x1,备注:' . $mailItems;
  581. if (! empty ( $softLock ))
  582. $mailString .= ',软件锁x' . $softLockNum;
  583. if (! empty ( $contract ))
  584. $mailString .= ',合同x' . $contractNum;
  585. if (! empty ( $instructions ))
  586. $mailString .= ',说明书x' . $instructionsNum;
  587. if (! empty ( $remittance ))
  588. $mailString .= ',汇款账号单';
  589. $item += array (
  590. 'recipients' => $recipients,
  591. 'recipientsPhone' => $recipientsPhone,
  592. 'recipientsAddress' => $recipientsAddress,
  593. 'mailItems' => $mailString,
  594. 'mailItemsJson' => json_encode ( $mailList )
  595. );
  596. }
  597. $invoice->setInvoiceByCondition ( $item );
  598. $item = array (
  599. 'date' => date ( "Y-m-d H:i:s" ),
  600. 'operation' => "重新提交审批",
  601. 'status' => 1,
  602. 'img' => $this->staff [0] ['avatar'],
  603. 'username' => $this->staff [0] ['username'],
  604. 'uid' => $this->staff [0] ['sid'],
  605. 'category' => $this->staff [0] ['category'],
  606. 'iid' => $iid
  607. );
  608. $invoiceOperationLog->setInvoiceOperationLog ( $item );
  609. }
  610. return "/invoice";
  611. }
  612. /**
  613. * 培训班
  614. */
  615. function invoiceTraining() {
  616. Doo::loadModel ( 'L_category' );
  617. $lCategory = new L_category ();
  618. Doo::loadModel ( 'invoiceTraining' );
  619. $invoiceTraining = new invoiceTraining ();
  620. $itTodoList = $invoiceTraining->getInvoiceTrainingByTodo ( '', $this->staff [0] ['cid'], $this->staff [0] ['sid'] );
  621. $itedList = $invoiceTraining->getInvoiceTrainingByStatus ( 2, '', $this->staff [0] ['cid'], $this->staff [0] ['sid'] );
  622. $category = $lCategory->getCategory ();
  623. $itid = array ();
  624. foreach ( $itTodoList as $value ) {
  625. array_push ( $itid, $value ['itid'] );
  626. }
  627. foreach ( $itedList as $value ) {
  628. array_push ( $itid, $value ['itid'] );
  629. }
  630. $itid = implode ( ',', $itid );
  631. $this->data ['itStatist'] = $invoiceTraining->getInvoiceTrainStatistics ( $itid );
  632. // print_r($itTodoList);
  633. $this->data ['trainCount'] = count ( $itTodoList ) + count ( $itedList );
  634. $this->data ['itTodoList'] = $itTodoList;
  635. $this->data ['itedList'] = $itedList;
  636. $this->data ['category'] = $category;
  637. $this->data ['memu'] = "invoice";
  638. $this->data ['staff'] = $this->staff;
  639. $this->data ['receiptMemu'] = 'invoiceTraining';
  640. $this->render ( "/admin/invoiceTraining", $this->data );
  641. }
  642. /**
  643. * 创建培训班
  644. */
  645. function invoiceTrainingAdd() {
  646. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  647. $trainName = $this->get_args ( 'trainName' ) ? $this->get_args ( 'trainName' ) : "";
  648. $trainDate = $this->get_args ( 'trainDate' ) ? $this->get_args ( 'trainDate' ) : "";
  649. if (empty ( $this->staff [0] ))
  650. die ( 'illegal request' );
  651. if (! empty ( $cid ) && ! empty ( $trainName ) && ! empty ( $trainDate )) {
  652. Doo::loadModel ( 'invoiceTraining' );
  653. $invoiceTraining = new invoiceTraining ();
  654. Doo::loadModel ( 'invoice' );
  655. $invoice = new invoice ();
  656. Doo::loadModel ( 'L_category' );
  657. $lCategory = new L_category ();
  658. Doo::loadModel ( 'invoiceManage' );
  659. $invoiceManage = new invoiceManage ();
  660. Doo::loadModel ( 'invoiceOperationLog' );
  661. $invoiceOperationLog = new invoiceOperationLog ();
  662. $item = array (
  663. 'cid' => $cid,
  664. 'trainName' => $trainName,
  665. 'trainDate' => $trainDate,
  666. 'creator' => $this->staff [0] ['sid'],
  667. 'creatorDate' => date ( "Y-m-d H:i:s" )
  668. );
  669. $itid = $invoiceTraining->addInvoiceTraining ( $item );
  670. }
  671. return "/invoiceTraining";
  672. }
  673. /**
  674. * 删除培训班
  675. */
  676. function invoiceTrainingDelDo() {
  677. $itid = $this->get_args ( 'trainingKey' ) ? $this->get_args ( 'trainingKey' ) : "";
  678. if (! empty ( $itid )) {
  679. Doo::loadModel ( 'invoiceTraining' );
  680. $invoiceTraining = new invoiceTraining ();
  681. $invoiceTraining->delInvoiceTrainingByItid ( $itid );
  682. }
  683. return "/invoiceTraining";
  684. }
  685. /**
  686. * 培训班详情
  687. */
  688. function invoiceTrainingDetail() {
  689. $trainStatus = $this->get_args ( 'trainStatus' ) ? $this->get_args ( 'trainStatus' ) : "ALL";
  690. $itid = isset ( $this->params ['trainingKey'] ) ? $this->params ['trainingKey'] : "";
  691. Doo::loadModel ( 'invoiceTraining' );
  692. $invoiceTraining = new invoiceTraining ();
  693. Doo::loadModel ( 'invoiceStore' );
  694. $invoiceStore = new invoiceStore ();
  695. if (empty ( $itid ))
  696. die ( 'illegal request' );
  697. $detail = $invoiceTraining->getInvoiceTrainingByItid ( $itid );
  698. $isList = $invoiceStore->getinvoiceStoreByItid ( $itid );
  699. // print_r($isList);
  700. $trainlist = array ();
  701. foreach ( $isList as $key => $value ) {
  702. $irDetail = array ();
  703. if ($value ['apStatus'] == 1) {
  704. // array_push ( $irDetail, '' );
  705. array_push ( $irDetail, '<input class="hide" disabled type="checkbox" >' );
  706. } else {
  707. array_push ( $irDetail, '<input type="checkbox" class="hide" id="' . $value ['storeKey'] . '" name="isBox" value="' . $value ['storeKey'] . '" > <a href="/invoiceStoreEdit/' . $value ['storeKey'] . '.html">编辑</a>
  708. <a href="#confirm" onclick="invoiceStoreApproval(\'' . $value ['storeKey'] . '\')" data-toggle="modal">提交审批</a>
  709. <a href="#del" node-iStore="del" data-key="' . $value ['storeKey'] . '" onclick="invoiceStoreDel(\'' . $value ['storeKey'] . '\')" data-toggle="modal" class="colRed">移除</a>' );
  710. }
  711. array_push ( $irDetail, $value ['invoiceSerial'] );
  712. if ($value ['invoiceType'] == 1)
  713. array_push ( $irDetail, $value ['invoiceCompany'] );
  714. else
  715. array_push ( $irDetail, $value ['invoiceTitle'] );
  716. array_push ( $irDetail, $value ['TIN'] );
  717. array_push ( $irDetail, $value ['userName'] );
  718. if (empty ( $value ['mailItems'] ) && $value ['apStatus'] != 1) {
  719. array_push ( $irDetail, '<a href="#confirm-erro" onclick="invoiceStoreMail(\'' . $value ['storeKey'] . '\')" data-toggle="modal">设置邮寄物品</a>' );
  720. } else
  721. array_push ( $irDetail, $value ['mailItems'] );
  722. array_push ( $irDetail, $value ['recipientsAddress'] . $value ['recipients'] . $value ['recipientsPhone'] );
  723. array_push ( $irDetail, $value ['address'] . $value ['phone'] );
  724. array_push ( $irDetail, $value ['bank'] . $value ['bankAccount'] );
  725. array_push ( $irDetail, $value ['invoiceElement'] );
  726. array_push ( $irDetail, $value ['invoiceQuantity'] );
  727. array_push ( $irDetail, $value ['invoiceUnitPrice'] );
  728. if ($value ['invoiceType'] == 1)
  729. array_push ( $irDetail, '¥' . $value ['invoicePrice'] . '<sup>专</sup>' );
  730. else
  731. array_push ( $irDetail, '¥' . $value ['invoicePrice'] );
  732. array_push ( $irDetail, $value ['remark'] );
  733. if ($value ['status'] == 1)
  734. array_push ( $irDetail, '审批中' );
  735. elseif ($value ['status'] == 2 && $value ['printStatus'] == 1)
  736. array_push ( $irDetail, '已出票' );
  737. elseif ($value ['status'] == 2 && $value ['printStatus'] == 1 && $value ['printStatus'] != 'irid' && ($value ['untreadStatus'] == 3 || $value ['untreadStatus'] == 0))
  738. array_push ( $irDetail, '已入账' );
  739. else
  740. array_push ( $irDetail, '' );
  741. array_push ( $irDetail, $value ['invoiceNo'] );
  742. array_push ( $irDetail, $value ['printTime'] );
  743. $html = '';
  744. foreach ( $value ['invoiceReceivables'] as $value ) {
  745. $html .= '&nbsp;<a href="#billing" node-invoice="INFO" data-type="receivables" data-iskey="' . $value [2] . '" data-toggle="modal">' . $value [1] . '</a>';
  746. }
  747. array_push ( $irDetail, $html );
  748. array_push ( $trainlist, $irDetail );
  749. }
  750. $trainlistJson = json_encode ( $trainlist );
  751. if (empty ( $detail ))
  752. die ( 'illegal request' );
  753. $this->data ['trainStatus'] = $trainStatus;
  754. $this->data ['itid'] = $itid;
  755. $this->data ['trainlistJson'] = $trainlistJson;
  756. $this->data ['iTrainDetail'] = $detail;
  757. $this->data ['memu'] = "invoice";
  758. $this->data ['staff'] = $this->staff;
  759. $this->data ['receiptMemu'] = 'invoiceTraining';
  760. $this->render ( "/admin/invoiceTrainingDetail", $this->data );
  761. }
  762. /**
  763. * 上传培训班发票
  764. * @return string
  765. */
  766. function invoiceTrainingUpload() {
  767. $POST_MAX_SIZE = ini_get ( 'post_max_size' );
  768. $unit = strtoupper ( substr ( $POST_MAX_SIZE, - 1 ) );
  769. $multiplier = ($unit == 'M' ? 1048576 : ($unit == 'K' ? 1024 : ($unit == 'G' ? 1073741824 : 1)));
  770. if (( int ) $_SERVER ['CONTENT_LENGTH'] > $multiplier * ( int ) $POST_MAX_SIZE && $POST_MAX_SIZE) {
  771. header ( "HTTP/1.1 500 Internal Server Error" );
  772. echo "POST exceeded maximum allowed size.";
  773. exit ( 0 );
  774. }
  775. // Settings
  776. $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)
  777. $upload_name = "Filedata";
  778. $max_file_size_in_bytes = 2147483647; // 2GB in bytes
  779. $extension_whitelist = array (
  780. "doc",
  781. "txt",
  782. "jpg",
  783. "gif",
  784. "png"
  785. ); // Allowed file extensions
  786. $valid_chars_regex = '.A-Z0-9_ !@#$%^&()+={}\[\]\',~`-'; // Characters allowed in the file name (in a Regular Expression format)
  787. // Other variables
  788. $MAX_FILENAME_LENGTH = 260;
  789. $file_name = "";
  790. $file_extension = "";
  791. $uploadErrors = array (
  792. 0 => "文件上传成功",
  793. 1 => "上传的文件超过了 php.ini 文件中的 upload_max_filesize directive 里的设置",
  794. 2 => "上传的文件超过了 HTML form 文件中的 MAX_FILE_SIZE directive 里的设置",
  795. 3 => "上传的文件仅为部分文件",
  796. 4 => "没有文件上传",
  797. 6 => "缺少临时文件夹"
  798. );
  799. $nk = time ();
  800. $file_name = $nk . '.' . $this->_GetFileEXT ( $_FILES [$upload_name] ['name'] ); // preg_replace('/[^'.$valid_chars_regex.']|\.+$/i', "", basename($_FILES[$upload_name]['name']));
  801. if (! @move_uploaded_file ( $_FILES [$upload_name] ["tmp_name"], $save_path . $file_name )) {
  802. echo "文件无法保存.";
  803. exit ( 0 );
  804. }
  805. // Return output to the browser (only supported by SWFUpload for Flash Player 9)
  806. echo json_encode ( array (
  807. 'filename' => $file_name,
  808. 'id' => $nk
  809. ) );
  810. exit ( 0 );
  811. }
  812. /**
  813. * 导入发票临时仓库
  814. */
  815. function invoiceStoreImport() {
  816. // include Doo::conf ()->BASE_PATH . 'diagnostic/debug.php';
  817. $trainingKey = $this->get_args ( 'trainingKey' ) ? $this->get_args ( 'trainingKey' ) : "";
  818. $path = $this->get_args ( 'trainName' ) ? $this->get_args ( 'trainName' ) : "";
  819. if ($path != "" && ! empty ( $trainingKey )) {
  820. Doo::loadModel ( 'invoiceStore' );
  821. Doo::loadModel ( 'staff' );
  822. $staff = new staff ();
  823. Doo::loadModel ( 'invoiceTraining' );
  824. $invoiceTraining = new invoiceTraining ();
  825. Doo::loadClass ( 'XDeode' );
  826. $XDeode = new XDeode ( 5 );
  827. $itid = $XDeode->decode ( $trainingKey );
  828. $exlArray = $this->formatExcelToArrayTrain ( DOO::conf ()->SITE_PATH . "upload/invoiceTraining/" . $path );
  829. $userName = $this->staff [0] ['username'];
  830. $sDetail = $staff->getStaffByName ( $userName );
  831. // die('sdd');
  832. // 可以优化
  833. foreach ( $exlArray as $key => $value ) {
  834. // 开票
  835. $invoice = new invoiceStore ();
  836. $invoice->trainId = $itid;
  837. $invoice->invoiceType = 0;
  838. if ($value ['invoiceType'] == '专' || $value ['invoiceType'] == '专票')
  839. $invoice->invoiceType = 1;
  840. $invoice->invoiceQuantity = $value ['invoiceQuantity'];
  841. $invoice->invoiceUnitPrice = $value ['invoiceUnitPrice'];
  842. $invoice->invoicePrice = $value ['invoiceQuantity'] * $value ['invoiceUnitPrice'];
  843. $invoice->invoiceTitle = $value ['invoiceTitle'];
  844. if ($value ['invoiceType'] == '专' || $value ['invoiceType'] == '专票')
  845. $invoice->invoiceCompany = $value ['invoiceTitle'];
  846. $invoice->userName = $userName;
  847. $invoice->sid = $sDetail ['sid'];
  848. $invoice->cid = $sDetail ['cid'];
  849. $invoice->categoryName = $sDetail ['category'];
  850. $invoice->invoiceElement = $value ['invoiceElement'];
  851. $invoice->remark = $value ['remark'];
  852. // $invoice->date = $value ['date'];
  853. // $invoice->printTime = $value ['date'];
  854. $invoice->ipSource = 1;
  855. $invoice->printStatus = 1;
  856. $invoice->status = 2;
  857. $invoice->postStatus = 1;
  858. $invoice->untreadStatus = 0;
  859. // $invoice->invoiceSerial = "#F" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  860. $invoice->TIN = $value ['TIN'];
  861. $invoice->address = $value ['address'];
  862. $invoice->phone = $value ['phone'];
  863. $invoice->bank = $value ['bank'];
  864. $invoice->bankAccount = $value ['bankAccount'];
  865. $invoice->recipientsAddress = $value ['recipientsAddress'];
  866. $invoice->recipients = $value ['recipients'];
  867. $invoice->recipientsPhone = $value ['recipientsPhone'];
  868. $iid = $invoice->insert ();
  869. }
  870. // 加入发票总数量
  871. $item = array (
  872. 'itid' => $itid,
  873. 'invoiceTotal' => count ( $exlArray )
  874. );
  875. $invoiceTraining->setInvoiceTrainByCondition ( $item );
  876. return '/invoiceTrainingDetail/' . $trainingKey . ".html";
  877. }
  878. echo 'no file';
  879. }
  880. /**
  881. * 编辑仓库里的发票
  882. */
  883. function invoiceStoreEdit() {
  884. Doo::loadClass ( 'XDeode' );
  885. $XDeode = new XDeode ( 5 );
  886. $iid = isset ( $this->params ['storeKey'] ) ? $this->params ['storeKey'] : "";
  887. $iid = $XDeode->decode ( $iid );
  888. if (! is_numeric ( $iid ))
  889. die ( 'illegal request' );
  890. Doo::loadModel ( 'invoiceStore' );
  891. $invoiceStore = new invoiceStore ();
  892. $invoiceDetail = $invoiceStore->getInvoiceStoreByIsid ( $iid );
  893. // print_r($invoiceDetail);
  894. $invoiceDetail ['mailItemsJson'] = json_decode ( $invoiceDetail ['mailItemsJson'], true );
  895. $this->data ['invoiceDetail'] = $invoiceDetail;
  896. $this->data ['memu'] = "invoice";
  897. $this->data ['staff'] = $this->staff;
  898. $this->data ['receiptMemu'] = 'invoiceTraining';
  899. $this->render ( "/admin/invoiceStoreEdit", $this->data );
  900. }
  901. function invoiceStoreEditDo() {
  902. $storeKey = $this->get_args ( 'storeKey' ) ? $this->get_args ( 'storeKey' ) : '';
  903. $trainKey = $this->get_args ( 'trainKey' ) ? $this->get_args ( 'trainKey' ) : '';
  904. Doo::loadModel ( 'invoiceStore' );
  905. $invoice = new invoiceStore ();
  906. Doo::loadClass ( 'XDeode' );
  907. $XDeode = new XDeode ( 5 );
  908. $iid = $XDeode->decode ( $storeKey );
  909. if (! empty ( $iid ) && ! is_numeric ( $iid ))
  910. die ( 'illegal request' );
  911. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  912. $invoiceType = $this->get_args ( 'invoiceType' ) && is_numeric ( $this->get_args ( 'invoiceType' ) ) ? $this->get_args ( 'invoiceType' ) : 0;
  913. $doPost = $this->get_args ( 'doPost' ) && is_numeric ( $this->get_args ( 'doPost' ) ) ? $this->get_args ( 'doPost' ) : 0;
  914. $invoicePrice = $this->get_args ( 'invoicePrice' ) ? $this->get_args ( 'invoicePrice' ) : "";
  915. $invoiceQuantity = $this->get_args ( 'invoiceQuantity' ) && is_numeric ( $this->get_args ( 'invoiceQuantity' ) ) ? $this->get_args ( 'invoiceQuantity' ) : 0;
  916. $invoiceUnitPrice = $this->get_args ( 'invoiceUnitPrice' ) && is_numeric ( $this->get_args ( 'invoiceUnitPrice' ) ) ? $this->get_args ( 'invoiceUnitPrice' ) : 0;
  917. $invoiceElement = $this->get_args ( 'invoiceElement' ) ? $this->get_args ( 'invoiceElement' ) : "";
  918. $invoiceTitle = $this->get_args ( 'invoiceTitle' ) ? $this->get_args ( 'invoiceTitle' ) : "";
  919. $invoiceCompany = $this->get_args ( 'invoiceCompany' ) ? $this->get_args ( 'invoiceCompany' ) : "";
  920. $TIN = $this->get_args ( 'TIN' ) ? $this->get_args ( 'TIN' ) : "";
  921. $address = $this->get_args ( 'address' ) ? $this->get_args ( 'address' ) : "";
  922. $phone = $this->get_args ( 'phone' ) ? $this->get_args ( 'phone' ) : "";
  923. $bank = $this->get_args ( 'bank' ) ? $this->get_args ( 'bank' ) : "";
  924. $bankAccount = $this->get_args ( 'bankAccount' ) ? $this->get_args ( 'bankAccount' ) : "";
  925. $recipients = $this->get_args ( 'recipients' ) ? $this->get_args ( 'recipients' ) : "";
  926. $recipientsPhone = $this->get_args ( 'recipientsPhone' ) ? $this->get_args ( 'recipientsPhone' ) : "";
  927. $recipientsAddress = $this->get_args ( 'recipientsAddress' ) ? $this->get_args ( 'recipientsAddress' ) : "";
  928. $mailItems = $this->get_args ( 'mailItems' ) ? $this->get_args ( 'mailItems' ) : "";
  929. $remark = $this->get_args ( 'remark' ) ? $this->get_args ( 'remark' ) : "";
  930. $TINT = $this->get_args ( 'TINT' ) ? $this->get_args ( 'TINT' ) : "";
  931. $addressT = $this->get_args ( 'addressT' ) ? $this->get_args ( 'addressT' ) : "";
  932. $phoneT = $this->get_args ( 'phoneT' ) ? $this->get_args ( 'phoneT' ) : "";
  933. $bankT = $this->get_args ( 'bankT' ) ? $this->get_args ( 'bankT' ) : "";
  934. $bankAccountT = $this->get_args ( 'bankAccountT' ) ? $this->get_args ( 'bankAccountT' ) : "";
  935. $softLock = $this->get_args ( 'softLock' ) ? $this->get_args ( 'softLock' ) : 0;
  936. $softLockNum = $this->get_args ( 'softLockNum' ) ? $this->get_args ( 'softLockNum' ) : 0;
  937. $contract = $this->get_args ( 'contract' ) ? $this->get_args ( 'contract' ) : 0;
  938. $contractNum = $this->get_args ( 'contractNum' ) ? $this->get_args ( 'contractNum' ) : 0;
  939. $instructions = $this->get_args ( 'instructions' ) ? $this->get_args ( 'instructions' ) : 0;
  940. $instructionsNum = $this->get_args ( 'instructionsNum' ) ? $this->get_args ( 'instructionsNum' ) : 0;
  941. $remittance = $this->get_args ( 'remittance' ) ? $this->get_args ( 'remittance' ) : 0;
  942. if (! empty ( $cid ) && ! empty ( $invoiceQuantity ) && ! empty ( $invoiceUnitPrice ) && ! empty ( $invoiceElement ) && ! empty ( $iid )) {
  943. $cid = explode ( ':', $cid );
  944. $invoicePrice = $invoiceQuantity * $invoiceUnitPrice;
  945. $item = array (
  946. 'isid' => $iid,
  947. 'cid' => $cid [0],
  948. 'categoryName' => $cid [1],
  949. 'invoiceElement' => $invoiceElement,
  950. 'invoiceQuantity' => $invoiceQuantity,
  951. 'invoiceUnitPrice' => $invoiceUnitPrice,
  952. 'invoicePrice' => $invoicePrice,
  953. 'invoiceType' => $invoiceType,
  954. 'doPost' => $doPost,
  955. 'status' => 1,
  956. 'updateTime' => date ( "Y-m-d H:i:s" ),
  957. 'remark' => $remark
  958. );
  959. if ($invoiceType == 0)
  960. $item += array (
  961. 'invoiceTitle' => $invoiceTitle,
  962. 'TIN' => $TINT,
  963. 'address' => $addressT,
  964. 'phone' => $phoneT,
  965. 'bank' => $bankT,
  966. 'bankAccount' => $bankAccountT
  967. );
  968. else {
  969. $item += array (
  970. 'invoiceCompany' => $invoiceCompany,
  971. 'TIN' => $TIN,
  972. 'address' => $address,
  973. 'phone' => $phone,
  974. 'bank' => $bank,
  975. 'bankAccount' => $bankAccount
  976. );
  977. }
  978. if ($doPost == 1) {
  979. $mailList = array (
  980. 'invoice' => 1,
  981. 'mailItems' => $mailItems
  982. );
  983. if (! empty ( $softLock ))
  984. $mailList += array (
  985. 'softLock' => $softLockNum
  986. );
  987. else
  988. $mailList += array (
  989. 'softLock' => '0'
  990. );
  991. if (! empty ( $contract ))
  992. $mailList += array (
  993. 'contract' => $contractNum
  994. );
  995. else
  996. $mailList += array (
  997. 'contract' => '0'
  998. );
  999. if (! empty ( $instructions ))
  1000. $mailList += array (
  1001. 'instructions' => $instructionsNum
  1002. );
  1003. else
  1004. $mailList += array (
  1005. 'instructions' => '0'
  1006. );
  1007. if (! empty ( $remittance ))
  1008. $mailList += array (
  1009. 'remittance' => $remittance
  1010. );
  1011. else
  1012. $mailList += array (
  1013. 'remittance' => ''
  1014. );
  1015. $mailString = '发票x1,备注:' . $mailItems;
  1016. if (! empty ( $softLock ))
  1017. $mailString .= ',软件锁x' . $softLockNum;
  1018. if (! empty ( $contract ))
  1019. $mailString .= ',合同x' . $contractNum;
  1020. if (! empty ( $instructions ))
  1021. $mailString .= ',说明书x' . $instructionsNum;
  1022. if (! empty ( $remittance ))
  1023. $mailString .= ',汇款账号单';
  1024. $item += array (
  1025. 'recipients' => $recipients,
  1026. 'recipientsPhone' => $recipientsPhone,
  1027. 'recipientsAddress' => $recipientsAddress,
  1028. 'mailItems' => $mailString,
  1029. 'mailItemsJson' => json_encode ( $mailList )
  1030. );
  1031. }
  1032. $invoice->setInvoiceStoreByCondition ( $item );
  1033. }
  1034. return "/invoiceTrainingDetail/" . $trainKey . ".html";
  1035. }
  1036. /**
  1037. *
  1038. * @return string
  1039. */
  1040. function invoiceStoreDelete() {
  1041. Doo::loadClass ( 'XDeode' );
  1042. $XDeode = new XDeode ( 5 );
  1043. $trainKey = $this->get_args ( 'trainKey' ) ? $this->get_args ( 'trainKey' ) : '';
  1044. $iStoreKey = $this->get_args ( 'iStoreKey' ) ? $this->get_args ( 'iStoreKey' ) : 0;
  1045. $isid = $XDeode->decode ( $iStoreKey );
  1046. $itid = $XDeode->decode ( $trainKey );
  1047. if (! is_numeric ( $isid ))
  1048. die ( 'illegal request' );
  1049. Doo::loadModel ( 'invoiceStore' );
  1050. $invoiceStore = new invoiceStore ();
  1051. $invoiceStore->delete ( array (
  1052. 'where' => 'isid=' . $isid,
  1053. 'limit' => 1
  1054. ) );
  1055. Doo::loadModel ( 'invoiceTraining' );
  1056. $invoiceTraining = new invoiceTraining ();
  1057. $itDetail = $invoiceTraining->getInvoiceTrainingByItid ( $trainKey );
  1058. $item = array (
  1059. 'itid' => $itid,
  1060. 'invoiceTotal' => $itDetail ['invoiceTotal'] - 1
  1061. );
  1062. $invoiceTraining->setInvoiceTrainByCondition ( $item );
  1063. return "/invoiceTrainingDetail/" . $trainKey . ".html";
  1064. }
  1065. /**
  1066. * 批量删除库里发票
  1067. */
  1068. function invoiceStoreBatchDelete() {
  1069. Doo::loadClass ( 'XDeode' );
  1070. $XDeode = new XDeode ( 5 );
  1071. $trainKey = $this->get_args ( 'trainKey' ) ? $this->get_args ( 'trainKey' ) : '';
  1072. $storeKey = $this->get_args ( 'storeKey' ) ? $this->get_args ( 'storeKey' ) : '';
  1073. $tid = $XDeode->decode ( $trainKey );
  1074. if (! is_numeric ( $tid ) && ! empty ( $storeKey ))
  1075. die ( 'illegal request' );
  1076. Doo::loadModel ( 'invoiceStore' );
  1077. $isidKeyList = explode ( ',', $storeKey );
  1078. $isidList = array ();
  1079. foreach ( $isidKeyList as $value ) {
  1080. $isid = $XDeode->decode ( $value );
  1081. if (! empty ( $isid ) && is_numeric ( $isid ))
  1082. array_push ( $isidList, $isid );
  1083. }
  1084. $isidString = implode ( ',', $isidList );
  1085. $invoiceStore = new invoiceStore ();
  1086. $isList = $invoiceStore->getInvoiceStoreInIsid ( $isidString, 'isid,apStatus' );
  1087. $isidList = array ();
  1088. foreach ( $isList as $key => $value ) {
  1089. if ($value ['apStatus'] == 0)
  1090. array_push ( $isidList, $value ['isid'] );
  1091. }
  1092. $isidString = implode ( ',', $isidList );
  1093. // print_r($isList);
  1094. // echo $isidString;
  1095. $invoiceStore = new invoiceStore ();
  1096. $invoiceStore->delete ( array (
  1097. 'where' => "isid in ( " . $isidString . ")",
  1098. 'asArray' => TRUE
  1099. ) );
  1100. Doo::loadModel ( 'invoiceTraining' );
  1101. $invoiceTraining = new invoiceTraining ();
  1102. $itDetail = $invoiceTraining->getInvoiceTrainingByItid ( $trainKey );
  1103. $item = array (
  1104. 'itid' => $tid,
  1105. 'invoiceTotal' => $itDetail ['invoiceTotal'] - count ( $isidList )
  1106. );
  1107. $invoiceTraining->setInvoiceTrainByCondition ( $item );
  1108. // echo $tid;
  1109. // echo $storeKey;
  1110. return "/invoiceTrainingDetail/" . $trainKey . ".html";
  1111. }
  1112. /**
  1113. * 仓库发票提交审批
  1114. * @return string
  1115. */
  1116. function invoiceStoreApproval() {
  1117. Doo::loadClass ( 'XDeode' );
  1118. $XDeode = new XDeode ( 5 );
  1119. $trainKey = $this->get_args ( 'trainKey' ) ? $this->get_args ( 'trainKey' ) : '';
  1120. $iStoreKey = $this->get_args ( 'storeKey' ) ? $this->get_args ( 'storeKey' ) : 0;
  1121. $isid = $XDeode->decode ( $iStoreKey );
  1122. $trainId = $XDeode->decode ( $trainKey );
  1123. if (! is_numeric ( $isid ))
  1124. die ( 'illegal request' );
  1125. Doo::loadModel ( 'invoiceStore' );
  1126. Doo::loadModel ( 'invoice' );
  1127. $invoice = new invoice ();
  1128. // 加入限制必须填写入开票内容和邮寄物品
  1129. $invoiceStore = new invoiceStore ();
  1130. $isDetail = $invoiceStore->getInvoiceStoreByIsid ( $isid, 'isid,trainId ,invoiceElement,mailItemsJson' );
  1131. if (empty ( $isDetail ['invoiceElement'] ) || empty ( $isDetail ['mailItemsJson'] )) {
  1132. header ( 'Content-Type:text/html;charset=utf-8' );
  1133. die ( 'illegal request! 请设置开票内容或邮寄物品' );
  1134. }
  1135. // 拷贝插入一条发票数据
  1136. $invoiceStore = new invoiceStore ();
  1137. $iid = $invoiceStore->setInvoiceStoreToApproval ( $isid );
  1138. $invoiceStore = new invoiceStore ();
  1139. $item = array (
  1140. 'isid' => $isid,
  1141. 'iid' => $iid,
  1142. 'apStatus' => 1
  1143. );
  1144. $invoiceStore->setInvoiceStoreByCondition ( $item );
  1145. Doo::loadModel ( 'invoiceManage' );
  1146. $invoiceManage = new invoiceManage ();
  1147. Doo::loadModel ( 'invoiceOperationLog' );
  1148. $invoiceOperationLog = new invoiceOperationLog ();
  1149. $invoiceManageList = $invoiceManage->getInvoiceByAll ();
  1150. $invoiceManageDetail = $invoiceManage->getInvoiceByMold ( "发票审批" );
  1151. $moldManage = array ();
  1152. foreach ( $invoiceManageList as $key => $value ) {
  1153. if ($value ['mold'] == '发票打印')
  1154. $moldManage [$value ['mold']] = $value ['staffList'];
  1155. elseif ($value ['mold'] == '发票邮寄')
  1156. $moldManage [$value ['mold']] = $value ['staffList'];
  1157. elseif ($value ['mold'] == '发票退票')
  1158. $moldManage [$value ['mold']] = $value ['staffList'];
  1159. }
  1160. $pendingApprovalsSid = current ( $invoiceManageDetail ['staffList'] ) [0];
  1161. $item = array (
  1162. 'iid' => $iid,
  1163. 'invoiceSerial' => "#F" . date ( "Ymd" ) . mt_rand ( 1000, 9999 ),
  1164. 'date' => date ( "Y-m-d H:i:s" ),
  1165. 'status' => 1,
  1166. 'updateTime' => date ( "Y-m-d H:i:s" ),
  1167. 'trainId' => $trainId,
  1168. 'invoiceManage' => $invoiceManageDetail ['staff'],
  1169. 'moldManage' => json_encode ( $moldManage ),
  1170. 'pendingApprovals' => $pendingApprovalsSid
  1171. );
  1172. $invoice->setInvoiceByCondition ( $item );
  1173. Doo::loadModel ( 'invoiceTraining' );
  1174. $invoiceTraining = new invoiceTraining ();
  1175. $item = array (
  1176. 'itid' => $trainId,
  1177. 'submitStatus' => 1
  1178. );
  1179. $invoiceTraining->setInvoiceTrainByCondition ( $item );
  1180. $item = array (
  1181. 'date' => date ( "Y-m-d H:i:s" ),
  1182. 'operation' => "创建",
  1183. 'status' => 1,
  1184. 'img' => $this->staff [0] ['avatar'],
  1185. 'username' => $this->staff [0] ['username'],
  1186. 'uid' => $this->staff [0] ['sid'],
  1187. 'category' => $this->staff [0] ['category'],
  1188. 'iid' => $iid
  1189. );
  1190. $invoiceOperationLog->setInvoiceOperationLog ( $item );
  1191. $item = array (
  1192. 'date' => date ( "Y-m-d H:i:s" ),
  1193. 'operation' => "提交审批",
  1194. 'status' => 1,
  1195. 'img' => $this->staff [0] ['avatar'],
  1196. 'username' => $this->staff [0] ['username'],
  1197. 'uid' => $this->staff [0] ['sid'],
  1198. 'category' => $this->staff [0] ['category'],
  1199. 'iid' => $iid
  1200. );
  1201. $invoiceOperationLog->setInvoiceOperationLog ( $item );
  1202. Doo::loadModel ( 'staff' );
  1203. $staff = new staff ();
  1204. $username2 = $staff->getOne ( array (
  1205. 'select' => 'wxid',
  1206. 'where' => 'sid=' . $pendingApprovalsSid,
  1207. 'asArray' => TRUE
  1208. ) );
  1209. // 发送微信审批通知
  1210. $title2 = '[通知]用户提交了一条开票申请,快到“我的发票”中查看,给用户确认审批。';
  1211. $this->msgSend ( '', $title2, '', $username2 ['wxid'], $pendingApprovalsSid, 'approval' );
  1212. return "/invoiceTrainingDetail/" . $trainKey . ".html";
  1213. }
  1214. /**
  1215. * 批量提交发票
  1216. * @return string
  1217. */
  1218. function invoiceStoreBatchApproval() {
  1219. Doo::loadClass ( 'XDeode' );
  1220. $XDeode = new XDeode ( 5 );
  1221. $trainKey = $this->get_args ( 'trainKey' ) ? $this->get_args ( 'trainKey' ) : '';
  1222. $storeKey = $this->get_args ( 'storeKey' ) ? $this->get_args ( 'storeKey' ) : 0;
  1223. $trainId = $XDeode->decode ( $trainKey );
  1224. $isidKeyList = explode ( ',', $storeKey );
  1225. $isidList = array ();
  1226. foreach ( $isidKeyList as $value ) {
  1227. $isid = $XDeode->decode ( $value );
  1228. if (! empty ( $isid ) && is_numeric ( $isid ))
  1229. array_push ( $isidList, $isid );
  1230. }
  1231. $isidString = implode ( ',', $isidList );
  1232. if (! is_numeric ( $trainId ))
  1233. die ( 'illegal request' );
  1234. Doo::loadModel ( 'invoiceStore' );
  1235. Doo::loadModel ( 'invoice' );
  1236. // 判断哪些已经加入审批过
  1237. // 加入限制必须填写入开票内容和邮寄物品
  1238. $invoiceStore = new invoiceStore ();
  1239. $isList = $invoiceStore->getInvoiceStoreInIsid ( $isidString, 'isid,trainId ,invoiceElement,mailItemsJson' );
  1240. foreach ( $isList as $key => $value ) {
  1241. if (empty ( $value ['invoiceElement'] ) || empty ( $value ['mailItemsJson'] )) {
  1242. header ( 'Content-Type:text/html;charset=utf-8' );
  1243. die ( 'illegal request! 请设置开票内容或邮寄物品' );
  1244. }
  1245. }
  1246. // 拷贝插入一条发票数据
  1247. $invoiceStore = new invoiceStore ();
  1248. $invoiceStore->setInvoiceStoreBatchToApproval ( $isidString );
  1249. $invoiceStore = new invoiceStore ();
  1250. $item = array (
  1251. 'apStatus' => 1
  1252. );
  1253. $invoiceStore->setInvoiceStoreByCondition ( $item, $isidString );
  1254. // 获得正式发票ID
  1255. $invoice = new invoice ();
  1256. $iidList = $invoice->getInvoiceByIstoreid ( $isidString, 'iid,isid' );
  1257. $sqlList = array ();
  1258. $iidString = '';
  1259. $iida = array ();
  1260. foreach ( $iidList as $key => $value ) {
  1261. $sqlList [$value ['isid']] = $value ['iid'];
  1262. array_push ( $iida, $value ['iid'] );
  1263. }
  1264. $iidString = implode ( ',', $iida );
  1265. $ids = implode ( ',', array_keys ( $sqlList ) );
  1266. $sql = "UPDATE CLD_invoiceStore SET iid = CASE isid ";
  1267. foreach ( $sqlList as $id => $ordinal ) {
  1268. $sql .= sprintf ( "WHEN %d THEN %d ", $id, $ordinal );
  1269. }
  1270. $sql .= "END WHERE isid IN ($ids)";
  1271. $invoiceStore = new invoiceStore ();
  1272. $invoiceStore->UpdateBatchInvoiceStore ( $sql );
  1273. Doo::loadModel ( 'invoiceManage' );
  1274. $invoiceManage = new invoiceManage ();
  1275. $invoiceManageList = $invoiceManage->getInvoiceByAll ();
  1276. $invoiceManageDetail = $invoiceManage->getInvoiceByMold ( "发票审批" );
  1277. $moldManage = array ();
  1278. foreach ( $invoiceManageList as $key => $value ) {
  1279. if ($value ['mold'] == '发票打印')
  1280. $moldManage [$value ['mold']] = $value ['staffList'];
  1281. elseif ($value ['mold'] == '发票邮寄')
  1282. $moldManage [$value ['mold']] = $value ['staffList'];
  1283. elseif ($value ['mold'] == '发票退票')
  1284. $moldManage [$value ['mold']] = $value ['staffList'];
  1285. }
  1286. $pendingApprovalsSid = current ( $invoiceManageDetail ['staffList'] ) [0];
  1287. // 批量更新发票信息
  1288. $item = array (
  1289. 'date' => date ( "Y-m-d H:i:s" ),
  1290. 'status' => 1,
  1291. 'updateTime' => date ( "Y-m-d H:i:s" ),
  1292. 'trainId' => $trainId,
  1293. 'invoiceManage' => $invoiceManageDetail ['staff'],
  1294. 'moldManage' => json_encode ( $moldManage ),
  1295. 'pendingApprovals' => $pendingApprovalsSid
  1296. );
  1297. $invoice = new invoice ();
  1298. $invoice->BatchInvoiceByCondition ( $item, $iidString );
  1299. // 批量更新发票序列号
  1300. $sqlList = array ();
  1301. foreach ( $iida as $value ) {
  1302. $sqlList [$value] = "#F" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  1303. }
  1304. $ids = implode ( ',', array_keys ( $sqlList ) );
  1305. $sql = "UPDATE CLD_invoice SET invoiceSerial = CASE iid ";
  1306. foreach ( $sqlList as $id => $ordinal ) {
  1307. $sql .= sprintf ( "WHEN %d THEN '%s' ", $id, $ordinal );
  1308. }
  1309. $sql .= "END WHERE iid IN ($ids)";
  1310. $invoiceStore = new invoiceStore ();
  1311. $invoiceStore->UpdateBatchInvoiceStore ( $sql );
  1312. // 批量生产操作日志
  1313. Doo::loadModel ( 'invoiceOperationLog' );
  1314. $sqlList = array ();
  1315. foreach ( $iida as $key => $value ) {
  1316. $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 . '"),
  1317. ("' . 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 . '") ';
  1318. array_push ( $sqlList, $sql );
  1319. }
  1320. $iolSql = implode ( ',', $sqlList );
  1321. $sql = "INSERT INTO `CLD_invoiceOperationLog` (`date`, `operation`, `status`, `img`, `username`, `uid`, `category`, `iid`) VALUES " . $iolSql;
  1322. $invoiceOperationLog = new invoiceOperationLog ();
  1323. $invoiceOperationLog->setInvoiceOperationLogBySql ( $sql );
  1324. Doo::loadModel ( 'invoiceTraining' );
  1325. $invoiceTraining = new invoiceTraining ();
  1326. $item = array (
  1327. 'itid' => $trainId,
  1328. 'submitStatus' => 1
  1329. );
  1330. $invoiceTraining->setInvoiceTrainByCondition ( $item );
  1331. Doo::loadModel ( 'staff' );
  1332. $staff = new staff ();
  1333. $username2 = $staff->getOne ( array (
  1334. 'select' => 'wxid',
  1335. 'where' => 'sid=' . $pendingApprovalsSid,
  1336. 'asArray' => TRUE
  1337. ) );
  1338. // 发送微信审批通知
  1339. $title2 = '[通知]用户提交了一条开票申请,快到“我的发票”中查看,给用户确认审批。';
  1340. $this->msgSend ( '', $title2, '', $username2 ['wxid'], $pendingApprovalsSid, 'approval' );
  1341. return "/invoiceTrainingDetail/" . $trainKey . ".html";
  1342. }
  1343. /**
  1344. */
  1345. function invoiceStoreMailItemSet() {
  1346. $softLock = $this->get_args ( 'softLock' ) ? $this->get_args ( 'softLock' ) : 0;
  1347. $softLockNum = $this->get_args ( 'softLockNum' ) ? $this->get_args ( 'softLockNum' ) : 0;
  1348. $contract = $this->get_args ( 'contract' ) ? $this->get_args ( 'contract' ) : 0;
  1349. $contractNum = $this->get_args ( 'contractNum' ) ? $this->get_args ( 'contractNum' ) : 0;
  1350. $instructions = $this->get_args ( 'instructions' ) ? $this->get_args ( 'instructions' ) : 0;
  1351. $instructionsNum = $this->get_args ( 'instructionsNum' ) ? $this->get_args ( 'instructionsNum' ) : 0;
  1352. $remittance = $this->get_args ( 'remittance' ) ? $this->get_args ( 'remittance' ) : 0;
  1353. $mailItems = $this->get_args ( 'mailItems' ) ? $this->get_args ( 'mailItems' ) : "";
  1354. $recipients = $this->get_args ( 'recipients' ) ? $this->get_args ( 'recipients' ) : "";
  1355. $recipientsPhone = $this->get_args ( 'recipientsPhone' ) ? $this->get_args ( 'recipientsPhone' ) : "";
  1356. $recipientsAddress = $this->get_args ( 'recipientsAddress' ) ? $this->get_args ( 'recipientsAddress' ) : "";
  1357. Doo::loadClass ( 'XDeode' );
  1358. $XDeode = new XDeode ( 5 );
  1359. $trainKey = $this->get_args ( 'trainKey' ) ? $this->get_args ( 'trainKey' ) : '';
  1360. $storeKey = $this->get_args ( 'storeKey' ) ? $this->get_args ( 'storeKey' ) : '';
  1361. $isid = $XDeode->decode ( $storeKey );
  1362. $trainId = $XDeode->decode ( $trainKey );
  1363. if (! is_numeric ( $isid ))
  1364. die ( 'illegal request' );
  1365. Doo::loadModel ( 'invoiceStore' );
  1366. $invoiceStore = new invoiceStore ();
  1367. $mailList = array (
  1368. 'invoice' => 1,
  1369. 'mailItems' => $mailItems
  1370. );
  1371. if (! empty ( $softLock ))
  1372. $mailList += array (
  1373. 'softLock' => $softLockNum
  1374. );
  1375. else
  1376. $mailList += array (
  1377. 'softLock' => 0
  1378. );
  1379. if (! empty ( $contract ))
  1380. $mailList += array (
  1381. 'contract' => $contractNum
  1382. );
  1383. else
  1384. $mailList += array (
  1385. 'contract' => 0
  1386. );
  1387. if (! empty ( $instructions ))
  1388. $mailList += array (
  1389. 'instructions' => $instructionsNum
  1390. );
  1391. else
  1392. $mailList += array (
  1393. 'instructions' => 0
  1394. );
  1395. if (! empty ( $remittance ))
  1396. $mailList += array (
  1397. 'remittance' => $remittance
  1398. );
  1399. else
  1400. $mailList += array (
  1401. 'remittance' => ''
  1402. );
  1403. $mailString = '发票x1,备注:' . $mailItems;
  1404. if (! empty ( $softLock ))
  1405. $mailString .= ',软件锁x' . $softLockNum;
  1406. if (! empty ( $contract ))
  1407. $mailString .= ',合同x' . $contractNum;
  1408. if (! empty ( $instructions ))
  1409. $mailString .= ',说明书x' . $instructionsNum;
  1410. if (! empty ( $remittance ))
  1411. $mailString .= ',汇款账号单';
  1412. $item = array (
  1413. 'isid' => $isid,
  1414. 'doPost' => 1,
  1415. 'mailItems' => $mailString,
  1416. 'mailItemsJson' => json_encode ( $mailList )
  1417. );
  1418. $invoiceStore->setInvoiceStoreByCondition ( $item );
  1419. return "/invoiceTrainingDetail/" . $trainKey . ".html";
  1420. }
  1421. /**
  1422. * 批量设置邮寄物品
  1423. */
  1424. function invoiceStoreBatchMailItemSet() {
  1425. $softLock = $this->get_args ( 'softLock' ) ? $this->get_args ( 'softLock' ) : 0;
  1426. $softLockNum = $this->get_args ( 'softLockNum' ) ? $this->get_args ( 'softLockNum' ) : 0;
  1427. $contract = $this->get_args ( 'contract' ) ? $this->get_args ( 'contract' ) : 0;
  1428. $contractNum = $this->get_args ( 'contractNum' ) ? $this->get_args ( 'contractNum' ) : 0;
  1429. $instructions = $this->get_args ( 'instructions' ) ? $this->get_args ( 'instructions' ) : 0;
  1430. $instructionsNum = $this->get_args ( 'instructionsNum' ) ? $this->get_args ( 'instructionsNum' ) : 0;
  1431. $remittance = $this->get_args ( 'remittance' ) ? $this->get_args ( 'remittance' ) : 0;
  1432. $mailItems = $this->get_args ( 'mailItems' ) ? $this->get_args ( 'mailItems' ) : "";
  1433. $recipients = $this->get_args ( 'recipients' ) ? $this->get_args ( 'recipients' ) : "";
  1434. $recipientsPhone = $this->get_args ( 'recipientsPhone' ) ? $this->get_args ( 'recipientsPhone' ) : "";
  1435. $recipientsAddress = $this->get_args ( 'recipientsAddress' ) ? $this->get_args ( 'recipientsAddress' ) : "";
  1436. Doo::loadClass ( 'XDeode' );
  1437. $XDeode = new XDeode ( 5 );
  1438. $trainKey = $this->get_args ( 'trainKey' ) ? $this->get_args ( 'trainKey' ) : '';
  1439. $storeKey = $this->get_args ( 'storeKey' ) ? $this->get_args ( 'storeKey' ) : '';
  1440. $isidKeyList = explode ( ',', $storeKey );
  1441. $isidList = array ();
  1442. foreach ( $isidKeyList as $value ) {
  1443. $isid = $XDeode->decode ( $value );
  1444. if (! empty ( $isid ) && is_numeric ( $isid ))
  1445. array_push ( $isidList, $isid );
  1446. }
  1447. $isidString = implode ( ',', $isidList );
  1448. $trainId = $XDeode->decode ( $trainKey );
  1449. if (! is_numeric ( $isid ))
  1450. die ( 'illegal request' );
  1451. Doo::loadModel ( 'invoiceStore' );
  1452. $invoiceStore = new invoiceStore ();
  1453. $mailList = array (
  1454. 'invoice' => 1,
  1455. 'mailItems' => $mailItems
  1456. );
  1457. if (! empty ( $softLock ))
  1458. $mailList += array (
  1459. 'softLock' => $softLockNum
  1460. );
  1461. else
  1462. $mailList += array (
  1463. 'softLock' => 0
  1464. );
  1465. if (! empty ( $contract ))
  1466. $mailList += array (
  1467. 'contract' => $contractNum
  1468. );
  1469. else
  1470. $mailList += array (
  1471. 'contract' => 0
  1472. );
  1473. if (! empty ( $instructions ))
  1474. $mailList += array (
  1475. 'instructions' => $instructionsNum
  1476. );
  1477. else
  1478. $mailList += array (
  1479. 'instructions' => 0
  1480. );
  1481. if (! empty ( $remittance ))
  1482. $mailList += array (
  1483. 'remittance' => $remittance
  1484. );
  1485. else
  1486. $mailList += array (
  1487. 'remittance' => ''
  1488. );
  1489. $mailString = '发票x1,备注:' . $mailItems;
  1490. if (! empty ( $softLock ))
  1491. $mailString .= ',软件锁x' . $softLockNum;
  1492. if (! empty ( $contract ))
  1493. $mailString .= ',合同x' . $contractNum;
  1494. if (! empty ( $instructions ))
  1495. $mailString .= ',说明书x' . $instructionsNum;
  1496. if (! empty ( $remittance ))
  1497. $mailString .= ',汇款账号单';
  1498. $item = array (
  1499. 'doPost' => 1,
  1500. 'mailItems' => $mailString,
  1501. 'mailItemsJson' => json_encode ( $mailList )
  1502. );
  1503. $invoiceStore->setInvoiceStoreByCondition ( $item, $isidString );
  1504. return "/invoiceTrainingDetail/" . $trainKey . ".html";
  1505. }
  1506. /**
  1507. * 废弃
  1508. */
  1509. function ajaxGetMailItemByIstore() {
  1510. Doo::loadClass ( 'XDeode' );
  1511. $XDeode = new XDeode ( 5 );
  1512. $storeKey = $this->get_args ( 'storeKey' ) ? $this->get_args ( 'storeKey' ) : '';
  1513. $isid = $XDeode->decode ( $storeKey );
  1514. if (! is_numeric ( $isid ))
  1515. die ( 'illegal request' );
  1516. Doo::loadModel ( 'invoiceStore' );
  1517. $invoiceStore = new invoiceStore ();
  1518. $isDetail = $invoiceStore->getInvoiceStoreByIsid ( $isid );
  1519. $isDetail ['mailItemsJson'] = json_decode ( $isDetail ['mailItemsJson'], true );
  1520. echo json_encode ( $isDetail ['mailItemsJson'] );
  1521. exit ();
  1522. }
  1523. /**
  1524. * 终止开票
  1525. */
  1526. function invoiceDroppedDo() {
  1527. $droppedIidKey = $this->get_args ( 'droppedIidKey' ) ? $this->get_args ( 'droppedIidKey' ) : '';
  1528. Doo::loadModel ( 'invoice' );
  1529. $invoice = new invoice ();
  1530. Doo::loadModel ( 'invoiceOperationLog' );
  1531. $invoiceOperationLog = new invoiceOperationLog ();
  1532. $iid = $invoice->authcode ( $droppedIidKey );
  1533. if (! empty ( $iid ) && ! is_numeric ( $iid ))
  1534. die ( 'illegal request' );
  1535. $item = array (
  1536. 'iid' => $iid,
  1537. 'status' => 4,
  1538. 'updateTime' => date ( "Y-m-d H:i:s" )
  1539. );
  1540. $invoice->setInvoiceByCondition ( $item );
  1541. $item = array (
  1542. 'date' => date ( "Y-m-d H:i:s" ),
  1543. 'operation' => '终止了开票',
  1544. 'status' => 4,
  1545. 'img' => $this->staff [0] ['avatar'],
  1546. 'username' => $this->staff [0] ['username'],
  1547. 'uid' => $this->staff [0] ['sid'],
  1548. 'category' => $this->staff [0] ['category'],
  1549. 'iid' => $iid
  1550. );
  1551. $invoiceOperationLog->setInvoiceOperationLog ( $item );
  1552. return "/invoice";
  1553. }
  1554. /**
  1555. * 更新退票的邮寄信息
  1556. */
  1557. function invoiceUntreadMailDo() {
  1558. $untreadIidKey = $this->get_args ( 'untreadIidKey' ) ? $this->get_args ( 'untreadIidKey' ) : '';
  1559. $untreadCompany = $this->get_args ( 'untreadCompany' ) ? $this->get_args ( 'untreadCompany' ) : "";
  1560. $untreadNumber = $this->get_args ( 'untreadNumber' ) ? $this->get_args ( 'untreadNumber' ) : "";
  1561. $untreadItems = $this->get_args ( 'untreadItems' ) ? $this->get_args ( 'untreadItems' ) : "";
  1562. Doo::loadModel ( 'invoice' );
  1563. $invoice = new invoice ();
  1564. $iid = $invoice->authcode ( $untreadIidKey );
  1565. if (! empty ( $iid ) && ! is_numeric ( $iid ))
  1566. die ( 'illegal request' );
  1567. $item = array (
  1568. 'iid' => $iid,
  1569. 'untreadCompany' => $untreadCompany,
  1570. 'untreadNumber' => $untreadNumber,
  1571. 'untreadItems' => $untreadItems
  1572. );
  1573. $invoice->setInvoiceByCondition ( $item );
  1574. return "/invoice";
  1575. }
  1576. /**
  1577. * 申请退票 --
  1578. */
  1579. function invoiceUntreadDo() {
  1580. $untreadIidKey = $this->get_args ( 'untreadIidKey' ) ? $this->get_args ( 'untreadIidKey' ) : '';
  1581. $untreadReason = $this->get_args ( 'untreadReason' ) ? $this->get_args ( 'untreadReason' ) : "";
  1582. $untreadPost = $this->get_args ( 'untreadPost' ) ? $this->get_args ( 'untreadPost' ) : "";
  1583. Doo::loadModel ( 'invoice' );
  1584. $invoice = new invoice ();
  1585. Doo::loadModel ( 'invoiceOperationLog' );
  1586. $invoiceOperationLog = new invoiceOperationLog ();
  1587. Doo::loadModel ( 'invoiceReceivables' );
  1588. $invoiceReceivables = new invoiceReceivables ();
  1589. $iid = $invoice->authcode ( $untreadIidKey );
  1590. if (! empty ( $iid ) && ! is_numeric ( $iid ))
  1591. die ( 'illegal request' );
  1592. /*
  1593. * 需求变革 有绑定收款也可以退票 $lt = $invoiceReceivables->getInvoiceReceivablesByIid ( $untreadIidKey ); if (! empty ( $lt )) { header ( 'Content-Type:text/html;charset=utf-8' ); die ( '该发票有收款绑定,请先移除!' ); }
  1594. */
  1595. $item = array (
  1596. 'iid' => $iid,
  1597. 'untreadStatus' => 1,
  1598. 'untreadReason' => $untreadReason,
  1599. 'untreadPost' => $untreadPost,
  1600. 'updateTime' => date ( "Y-m-d H:i:s" )
  1601. );
  1602. $invoice->setInvoiceByCondition ( $item );
  1603. $item = array (
  1604. 'date' => date ( "Y-m-d H:i:s" ),
  1605. 'operation' => '申请退票',
  1606. 'status' => 7,
  1607. 'img' => $this->staff [0] ['avatar'],
  1608. 'username' => $this->staff [0] ['username'],
  1609. 'uid' => $this->staff [0] ['sid'],
  1610. 'category' => $this->staff [0] ['category'],
  1611. 'iid' => $iid
  1612. );
  1613. $invoiceOperationLog->setInvoiceOperationLog ( $item );
  1614. return "/invoice";
  1615. }
  1616. /**
  1617. * 删除已终止的开票
  1618. */
  1619. function invoiceDelDo() {
  1620. Doo::loadModel ( 'invoice' );
  1621. $invoice = new invoice ();
  1622. Doo::loadModel ( 'invoiceOperationLog' );
  1623. $invoiceOperationLog = new invoiceOperationLog ();
  1624. Doo::loadClass ( 'XDeode' );
  1625. $XDeode = new XDeode ( 5 );
  1626. $sid = $XDeode->decode ( $_COOKIE ["staff"] );
  1627. $iid = isset ( $this->params ['iid'] ) ? $this->params ['iid'] : "";
  1628. $iid = $XDeode->decode ( $iid );
  1629. Doo::loadModel ( 'invoiceStore' );
  1630. $invoiceStore = new invoiceStore ();
  1631. if (! is_numeric ( $iid ))
  1632. die ( 'illegal request' );
  1633. $invoiceDetail = $invoice->getMyInvoice ( $sid, $iid );
  1634. if (empty ( $invoiceDetail ))
  1635. die ( 'illegal request' );
  1636. $item = array (
  1637. 'iid' => $iid,
  1638. 'isDelete' => 1,
  1639. 'updateTime' => date ( "Y-m-d H:i:s" )
  1640. );
  1641. $invoice->setInvoiceByCondition ( $item );
  1642. $item = array (
  1643. 'date' => date ( "Y-m-d H:i:s" ),
  1644. 'operation' => '删除了已终止的发票',
  1645. 'status' => 4,
  1646. 'img' => $this->staff [0] ['avatar'],
  1647. 'username' => $this->staff [0] ['username'],
  1648. 'uid' => $this->staff [0] ['sid'],
  1649. 'category' => $this->staff [0] ['category'],
  1650. 'iid' => $iid
  1651. );
  1652. $invoiceOperationLog->setInvoiceOperationLog ( $item );
  1653. // 删除培训班发票仓库里的发票
  1654. $invoiceStore->delInvoiceStoreByIsid ( $invoiceDetail ['isid'] );
  1655. return "/invoice";
  1656. }
  1657. function invoiceApproval() {
  1658. Doo::loadModel ( 'invoice' );
  1659. $invoice = new invoice ();
  1660. Doo::loadClass ( 'XDeode' );
  1661. $XDeode = new XDeode ( 5 );
  1662. Doo::loadModel ( 'staff' );
  1663. $staff = new staff ();
  1664. $invoiceList = $invoice->find ( array (
  1665. 'where' => 'status=1 and pendingApprovals=' . $this->staff [0] ['sid'],
  1666. 'desc' => 'iid',
  1667. 'limit' => 10,
  1668. 'asArray' => true
  1669. ) );
  1670. foreach ( $invoiceList as $key => $value ) {
  1671. $invoiceList [$key] ['iidKey'] = $XDeode->encode ( $value ['iid'] );
  1672. $lastApprover = json_decode ( $value ['processApprovals'], true );
  1673. if (! empty ( $lastApprover )) {
  1674. $lastApproverKey = array_keys ( $lastApprover );
  1675. $lastApprover = end ( $lastApprover );
  1676. $staffDetail = $staff->getOne ( array (
  1677. 'where' => 'sid=' . end ( $lastApproverKey ),
  1678. 'asArray' => true
  1679. ) );
  1680. $lastApprover ['username'] = $staffDetail ['username'];
  1681. }
  1682. $invoiceList [$key] ['lastApprover'] = $lastApprover;
  1683. }
  1684. $ilist = $invoice->getInvoiceByProcessStatus ();
  1685. foreach ( $ilist as $key => $value ) {
  1686. $ilist [$key] ['iidKey'] = $XDeode->encode ( $value ['iid'] );
  1687. $lastApprover = json_decode ( $value ['processApprovals'], true );
  1688. if (! empty ( $lastApprover )) {
  1689. $lastApproverKey = array_keys ( $lastApprover );
  1690. $lastApprover = end ( $lastApprover );
  1691. $staffDetail = $staff->getOne ( array (
  1692. 'where' => 'sid=' . end ( $lastApproverKey ),
  1693. 'asArray' => true
  1694. ) );
  1695. $lastApprover ['username'] = $staffDetail ['username'];
  1696. }
  1697. $ilist [$key] ['lastApprover'] = $lastApprover;
  1698. }
  1699. // print_r($ilist);
  1700. $this->data ['invoiceList'] = $invoiceList;
  1701. $this->data ['ilist'] = $ilist;
  1702. $this->data ['memu'] = "invoice";
  1703. $this->data ['staff'] = $this->staff;
  1704. $this->data ['receiptMemu'] = 'invoiceApproval';
  1705. $this->render ( "/admin/invoiceApproval", $this->data );
  1706. }
  1707. function invoiceDetail() {
  1708. Doo::loadClass ( 'XDeode' );
  1709. $XDeode = new XDeode ( 5 );
  1710. $iid = isset ( $this->params ['iid'] ) ? $this->params ['iid'] : "";
  1711. $iid = $XDeode->decode ( $iid );
  1712. if (! is_numeric ( $iid ))
  1713. die ( 'illegal request' );
  1714. Doo::loadModel ( 'invoice' );
  1715. $invoice = new invoice ();
  1716. Doo::loadModel ( 'invoiceOperationLog' );
  1717. $invoiceOperationLog = new invoiceOperationLog ();
  1718. $invoiceDetail = $invoice->getOne ( array (
  1719. 'where' => 'status=1 and pendingApprovals=' . $this->staff [0] ['sid'] . ' and iid=' . $iid,
  1720. 'asArray' => true
  1721. ) );
  1722. if (empty ( $invoiceDetail ))
  1723. die ( 'illegal request' );
  1724. $invoiceOperationLogList = $invoiceOperationLog->getInvoiceOperationLogByIid ( $iid );
  1725. $this->data ['invoiceDetail'] = $invoiceDetail;
  1726. $this->data ['invoiceOperationLogList'] = $invoiceOperationLogList;
  1727. $this->data ['INVOICEKEY'] = $invoice->authcode ( $invoiceDetail ['iid'], '' );
  1728. $this->data ['memu'] = "invoice";
  1729. $this->data ['staff'] = $this->staff;
  1730. $this->data ['receiptMemu'] = 'invoiceApproval';
  1731. $this->render ( "/admin/invoiceApprovalDetail", $this->data );
  1732. }
  1733. /**
  1734. * 对发票进行审批,其中操作有终止,退回,同意动作。操作成功并记录下操作日志
  1735. *
  1736. * @since 1.0.0
  1737. * @var integer iid 开票ID 已加密
  1738. * @var integer status 发票审批状态
  1739. * @var integer opintion 审批发票的意见
  1740. * @return string 如操作成功返回审批首页
  1741. */
  1742. function invoiceApprovalDo() {
  1743. Doo::loadModel ( 'invoice' );
  1744. $invoice = new invoice ();
  1745. $iid = $this->get_args ( 'invoiceKey' ) ? $this->get_args ( 'invoiceKey' ) : "";
  1746. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  1747. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  1748. $divApproval = $this->get_args ( 'divApproval' ) ? $this->get_args ( 'divApproval' ) : "";
  1749. $iid = $invoice->authcode ( $iid );
  1750. if (! is_numeric ( $iid ))
  1751. die ( 'illegal request' );
  1752. // && ! empty ( $opinion )
  1753. if (! empty ( $iid ) && ! empty ( $status )) {
  1754. if (! ($status == 2 || $status == 3 || $status == 4))
  1755. die ( 'illegal request' );
  1756. Doo::loadModel ( 'invoiceOperationLog' );
  1757. $invoiceOperationLog = new invoiceOperationLog ();
  1758. $invoiceDetail = $invoice->getOne ( array (
  1759. 'where' => 'status=1 and iid=' . $iid . ' and pendingApprovals=' . $this->staff [0] ['sid'],
  1760. 'asArray' => true
  1761. ) );
  1762. if (empty ( $invoiceDetail ))
  1763. die ( 'illegal request' );
  1764. $processApprovals = json_decode ( $invoiceDetail ['processApprovals'], true );
  1765. $invoiceManage = json_decode ( $invoiceDetail ['invoiceManage'], true );
  1766. if ($status == 3) {
  1767. $invoice->status = $status;
  1768. $item = array (
  1769. 'operation' => $opinion
  1770. );
  1771. } else {
  1772. if (empty ( $processApprovals )) {
  1773. $processApprovals = array (
  1774. $this->staff [0] ['sid'] => array (
  1775. 'date' => date ( "Y-m-d H:i:s" ),
  1776. 'opinion' => $opinion,
  1777. 'status' => $status
  1778. )
  1779. );
  1780. // var_dump(next($invoiceManage));
  1781. $nextInvoiceManage = next ( $invoiceManage );
  1782. // print_r($nextInvoiceManage);
  1783. if ($status != 4 && $nextInvoiceManage !== false)
  1784. $invoice->pendingApprovals = $nextInvoiceManage [0];
  1785. $invoice->processApprovals = json_encode ( $processApprovals );
  1786. // var_dump($invoice);
  1787. // print_r($invoiceManage);
  1788. } else {
  1789. $processApprovals [$this->staff [0] ['sid']] = array (
  1790. 'date' => date ( "Y-m-d H:i:s" ),
  1791. 'opinion' => $opinion,
  1792. 'status' => $status
  1793. );
  1794. $pendingApprovals = 0;
  1795. foreach ( $invoiceManage as $key => $value ) {
  1796. if ($value [0] == $this->staff [0] ['sid']) {
  1797. if (isset ( $invoiceManage [$key + 1] ))
  1798. $pendingApprovals = $invoiceManage [$key + 1] [0];
  1799. break;
  1800. }
  1801. }
  1802. if ($status != 4 && ! empty ( $pendingApprovals ))
  1803. $invoice->pendingApprovals = $pendingApprovals;
  1804. $invoice->processApprovals = json_encode ( $processApprovals );
  1805. }
  1806. $item = array (
  1807. 'operation' => $opinion
  1808. );
  1809. if (count ( $processApprovals ) == count ( $invoiceManage ) && $status != 4) {
  1810. $invoice->status = $status;
  1811. $invoice->pendingApprovals = 0;
  1812. $invoice->approvalTime = date ( "Y-m-d H:i:s" );
  1813. } elseif ($status == 4) {
  1814. $invoice->status = $status;
  1815. $item = array (
  1816. 'operation' => $opinion
  1817. );
  1818. }
  1819. }
  1820. $invoice->updateTime = date ( "Y-m-d H:i:s" );
  1821. $invoice->update ( array (
  1822. 'where' => 'iid=' . $iid
  1823. ) );
  1824. $item += array (
  1825. 'date' => date ( "Y-m-d H:i:s" ),
  1826. 'img' => $this->staff [0] ['avatar'],
  1827. 'username' => $this->staff [0] ['username'],
  1828. 'uid' => $this->staff [0] ['sid'],
  1829. 'category' => $this->staff [0] ['category'],
  1830. 'status' => $status,
  1831. 'iid' => $iid
  1832. );
  1833. $invoiceOperationLog->setInvoiceOperationLog ( $item );
  1834. if (empty ( $divApproval ))
  1835. return '/invoiceApproval';
  1836. else
  1837. return '/invoiceApprovalAchieve/PEND';
  1838. }
  1839. die ( 'illegal request' );
  1840. }
  1841. /**
  1842. * 展示需要打印的发票数据
  1843. *
  1844. * @since 1.0.0
  1845. */
  1846. function invoicePrint() {
  1847. Doo::loadModel ( 'invoice' );
  1848. $invoice = new invoice ();
  1849. Doo::loadClass ( 'XDeode' );
  1850. $XDeode = new XDeode ( 5 );
  1851. Doo::loadModel ( 'staff' );
  1852. $staff = new staff ();
  1853. $toPrint = $invoice->getPrintInvoiceByManage ( $this->staff [0] ['sid'], 0 );
  1854. $printed = $invoice->getPrintInvoiceByManage ( $this->staff [0] ['sid'], 1 );
  1855. foreach ( $toPrint as $key => $value ) {
  1856. $toPrint [$key] ['iidKey'] = $XDeode->encode ( $value ['iid'] );
  1857. $lastApprover = json_decode ( $value ['processApprovals'], true );
  1858. if (! empty ( $lastApprover )) {
  1859. $lastApproverKey = array_keys ( $lastApprover );
  1860. $lastApprover = end ( $lastApprover );
  1861. $staffDetail = $staff->getOne ( array (
  1862. 'where' => 'sid=' . end ( $lastApproverKey ),
  1863. 'asArray' => true
  1864. ) );
  1865. $lastApprover ['username'] = $staffDetail ['username'];
  1866. }
  1867. $toPrint [$key] ['lastApprover'] = $lastApprover;
  1868. }
  1869. foreach ( $printed as $key => $value ) {
  1870. $printed [$key] ['iidKey'] = $XDeode->encode ( $value ['iid'] );
  1871. $lastApprover = json_decode ( $value ['processApprovals'], true );
  1872. if (! empty ( $lastApprover )) {
  1873. $lastApproverKey = array_keys ( $lastApprover );
  1874. $lastApprover = end ( $lastApprover );
  1875. $staffDetail = $staff->getOne ( array (
  1876. 'where' => 'sid=' . end ( $lastApproverKey ),
  1877. 'asArray' => true
  1878. ) );
  1879. $lastApprover ['username'] = $staffDetail ['username'];
  1880. }
  1881. $printed [$key] ['lastApprover'] = $lastApprover;
  1882. }
  1883. $this->data ['printed'] = $printed;
  1884. $this->data ['toPrint'] = $toPrint;
  1885. $this->data ['memu'] = "invoice";
  1886. $this->data ['staff'] = $this->staff;
  1887. $this->data ['receiptMemu'] = 'invoicePrint';
  1888. $this->render ( "/admin/invoicePrint", $this->data );
  1889. }
  1890. /**
  1891. * 展示发票打印的详情页面
  1892. *
  1893. * @since 1.0.0
  1894. */
  1895. function invoicePrintDetail() {
  1896. Doo::loadClass ( 'XDeode' );
  1897. $XDeode = new XDeode ( 5 );
  1898. $iid = isset ( $this->params ['iid'] ) ? $this->params ['iid'] : "";
  1899. $iid = $XDeode->decode ( $iid );
  1900. if (! is_numeric ( $iid ))
  1901. die ( 'illegal request' );
  1902. Doo::loadModel ( 'invoice' );
  1903. $invoice = new invoice ();
  1904. Doo::loadModel ( 'invoiceOperationLog' );
  1905. $invoiceOperationLog = new invoiceOperationLog ();
  1906. Doo::loadModel ( 'invoicePaper' );
  1907. $invoicePaper = new invoicePaper ();
  1908. $invoiceDetail = $invoice->getPrintInvoiceByManage ( $this->staff [0] ['sid'], 0, $iid );
  1909. if (empty ( $invoiceDetail ))
  1910. die ( 'illegal request' );
  1911. $invoicePaperList = $invoicePaper->getInvoicePaperByInvoiceType ( $invoiceDetail ['invoiceType'] );
  1912. $invoiceOperationLogList = $invoiceOperationLog->getInvoiceOperationLogByIid ( $iid );
  1913. $this->data ['invoicePaperList'] = $invoicePaperList;
  1914. $this->data ['invoiceDetail'] = $invoiceDetail;
  1915. $this->data ['invoiceOperationLogList'] = $invoiceOperationLogList;
  1916. $this->data ['INVOICEKEY'] = $invoice->authcode ( $invoiceDetail ['iid'], '' );
  1917. $this->data ['memu'] = "invoice";
  1918. $this->data ['staff'] = $this->staff;
  1919. $this->data ['receiptMemu'] = 'invoicePrint';
  1920. $this->render ( "/admin/invoicePrintDetail", $this->data );
  1921. }
  1922. /**
  1923. * 所有待打印 发票
  1924. */
  1925. function invoicePrintStayAchieve() {
  1926. Doo::loadModel ( 'invoice' );
  1927. $invoice = new invoice ();
  1928. Doo::loadClass ( 'XDeode' );
  1929. $XDeode = new XDeode ( 5 );
  1930. Doo::loadModel ( 'staff' );
  1931. $staff = new staff ();
  1932. $MebSea = $this->get_args ( 'MebSea' ) ? urldecode ( $this->get_args ( 'MebSea' ) ) : "";
  1933. $invoiceType = $this->get_args ( 'invoiceType' ) ? $this->get_args ( 'invoiceType' ) : "ALL";
  1934. $invoiceTrain = $this->get_args ( 'invoiceTrain' ) ? $this->get_args ( 'invoiceTrain' ) : "ALL";
  1935. $invoiceTrainName = $this->get_args ( 'invoiceTrainName' ) ? $this->get_args ( 'invoiceTrainName' ) : "ALL";
  1936. Doo::loadModel ( 'invoiceTraining' );
  1937. $invoiceTraining = new invoiceTraining ();
  1938. $trainList = $invoiceTraining->getInvoiceTrainingBySubmitStatus ();
  1939. $page_size = 12;
  1940. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  1941. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : "ALL";
  1942. // $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : "ALL";
  1943. $get = "/" . $status;
  1944. $con = ' and status=2 ';
  1945. if ($status == 'TOPRINT')
  1946. $con = ' and status=2 and printStatus=0 ';
  1947. elseif ($status == 'PRINTED')
  1948. $con = ' and status=2 and printStatus=1';
  1949. if ($invoiceType == 'ORDINARY')
  1950. $con .= ' and invoiceType=0 ';
  1951. elseif ($invoiceType == 'SPECIAL')
  1952. $con .= ' and invoiceType=1 ';
  1953. if ($invoiceTrain == 'ORDINARY')
  1954. $con .= ' and trainId=0 ';
  1955. elseif ($invoiceTrain == 'TRAIN')
  1956. $con .= ' and trainId!=0 ';
  1957. if ($invoiceTrainName != 'ALL') {
  1958. $trainId = $XDeode->decode ( $invoiceTrainName );
  1959. if (is_numeric ( $trainId ))
  1960. $con .= ' and trainId =' . $trainId;
  1961. }
  1962. $date = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "";
  1963. $dateArr = explode ( ':', $date );
  1964. $D1 = '';
  1965. $D2 = '';
  1966. if (! empty ( $date )) {
  1967. $D1 = $dateArr [0];
  1968. $D2 = $dateArr [1];
  1969. }
  1970. if (! empty ( $D1 ) && ! empty ( $D2 ) && ! empty ( $date ))
  1971. $con .= ' and printTime BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
  1972. if (! empty ( $MebSea )) {
  1973. $con .= ' and ( invoiceTitle like "%' . $MebSea . '%" or invoiceCompany like "%' . $MebSea . '%" or invoicePrice like "%' . $MebSea . '%" or invoiceNo like "%' . $MebSea . '%" )';
  1974. }
  1975. $pageinfo ['page'] = array (
  1976. 'previous' => ''
  1977. );
  1978. $get .= "?date=" . urlencode ( $date ) . "&MebSea=" . urlencode ( $MebSea );
  1979. $sql = " (untreadStatus=0 or untreadStatus=3) and moldManage like '%[\"" . $this->staff [0] ['sid'] . "\",%'" . $con;
  1980. $action = "invoicePrintStayAchieve";
  1981. $pageinfo = $this->get_page ( "CLD_invoice", $sql, $page, $page_size, $action, $get, "" );
  1982. $limit = $pageinfo ['lower'] . ',' . $page_size;
  1983. $list = $invoice->getInvoiceByUntreadStatusPage ( $limit, $sql, 'desc', 5 );
  1984. $this->data ['trainList'] = $trainList;
  1985. $this->data ['invoiceType'] = $invoiceType;
  1986. $this->data ['invoiceTrain'] = $invoiceTrain;
  1987. $this->data ['invoiceTrainName'] = $invoiceTrainName;
  1988. $this->data ['MebSeaEn'] = $MebSea;
  1989. $this->data ['MebSea'] = urlencode ( $MebSea );
  1990. $this->data ['get'] = $get;
  1991. $this->data ['page'] = $pageinfo;
  1992. $this->data ['date'] = $date;
  1993. $this->data ['status'] = $status;
  1994. $this->data ['memu'] = "invoice";
  1995. $this->data ['staff'] = $this->staff;
  1996. foreach ( $list as $key => $value ) {
  1997. $list [$key] ['iidKey'] = $XDeode->encode ( $value ['iid'] );
  1998. $lastApprover = json_decode ( $value ['processApprovals'], true );
  1999. if (! empty ( $lastApprover )) {
  2000. $lastApproverKey = array_keys ( $lastApprover );
  2001. $lastApprover = end ( $lastApprover );
  2002. $staffDetail = $staff->getOne ( array (
  2003. 'where' => 'sid=' . end ( $lastApproverKey ),
  2004. 'asArray' => true
  2005. ) );
  2006. $lastApprover ['username'] = $staffDetail ['username'];
  2007. }
  2008. $list [$key] ['lastApprover'] = $lastApprover;
  2009. }
  2010. $this->data ['receiptMemu'] = 'invoicePrint';
  2011. $this->data ['list'] = $list;
  2012. $this->render ( "/admin/invoicePrintStayAchieve", $this->data );
  2013. }
  2014. /**
  2015. * 填写票号并完成打印
  2016. * @since 1.0.0
  2017. */
  2018. function invoicePrintDo() {
  2019. Doo::loadModel ( 'invoice' );
  2020. $invoice = new invoice ();
  2021. $iid = $this->get_args ( 'invoiceKey' ) ? $this->get_args ( 'invoiceKey' ) : "";
  2022. $invoiceNo = $this->get_args ( 'invoiceNo' ) ? $this->get_args ( 'invoiceNo' ) : "";
  2023. $invoicePrintType = $this->get_args ( 'invoicePrintType' ) ? $this->get_args ( 'invoicePrintType' ) : "";
  2024. $iid = $invoice->authcode ( $iid );
  2025. if (! is_numeric ( $iid ))
  2026. die ( 'illegal request' );
  2027. if (! empty ( $iid ) && ! empty ( $invoiceNo )) {
  2028. Doo::loadModel ( 'invoiceOperationLog' );
  2029. $invoiceOperationLog = new invoiceOperationLog ();
  2030. Doo::loadModel ( 'invoiceStatistics' );
  2031. $invoiceStatistics = new invoiceStatistics ();
  2032. $XDeode = new XDeode ( 5 );
  2033. Doo::loadModel ( 'invoicePaper' );
  2034. $invoicePaper = new invoicePaper ();
  2035. $invoicePrintDetail = $invoice->getInvoiceByPrint ( $iid );
  2036. if (empty ( $invoicePrintDetail ))
  2037. die ( 'illegal request' );
  2038. //
  2039. $ipid = $XDeode->decode ( $invoiceNo );
  2040. $paperDetail = $invoicePaper->getInvoicePaperByIpid ( $ipid );
  2041. if (empty ( $paperDetail ))
  2042. die ( 'illegal request' );
  2043. $invoicePaper = new invoicePaper ();
  2044. $item = array (
  2045. 'iid' => $iid,
  2046. 'ipid' => $ipid
  2047. );
  2048. $invoicePaper->setInvoicePaperByCondition ( $item );
  2049. $item = array (
  2050. 'iid' => $iid,
  2051. 'printStatus' => 1,
  2052. 'updateTime' => date ( "Y-m-d H:i:s" ),
  2053. 'printer' => $this->staff [0] ['username'],
  2054. 'printTime' => date ( "Y-m-d H:i:s" ),
  2055. 'invoiceNo' => $paperDetail ['invoiceNo']
  2056. );
  2057. $invoice->setInvoiceByCondition ( $item );
  2058. $item = array (
  2059. 'date' => date ( "Y-m-d H:i:s" ),
  2060. 'operation' => '打印发票号:' . $paperDetail ['invoiceNo'],
  2061. 'status' => 5,
  2062. 'img' => $this->staff [0] ['avatar'],
  2063. 'username' => $this->staff [0] ['username'],
  2064. 'uid' => $this->staff [0] ['sid'],
  2065. 'category' => $this->staff [0] ['category'],
  2066. 'iid' => $iid
  2067. );
  2068. $invoiceOperationLog->setInvoiceOperationLog ( $item );
  2069. // 去统计--负票不汇总
  2070. if ($invoicePrintDetail ['untreadStatus'] != 4) {
  2071. $item = array (
  2072. 'date' => date ( "Y-m-d H:i:s" ),
  2073. 'priceClass' => 1,
  2074. 'cid' => $invoicePrintDetail ['cid'],
  2075. 'staff' => $invoicePrintDetail ['sid'],
  2076. 'invoicePrice' => $invoicePrintDetail ['invoicePrice']
  2077. );
  2078. $invoiceStatistics->setInvoiceStatisticsByCondition ( $item );
  2079. }
  2080. // 发送通知信息到微信-去除
  2081. // $this->setWXMsg($iid,'PRINT');
  2082. // 申请人获取微信通知
  2083. Doo::loadModel ( 'staff' );
  2084. $staff = new staff ();
  2085. Doo::loadClass ( 'XDeode' );
  2086. $XDeode = new XDeode ( 5 );
  2087. $username2 = $staff->getOne ( array (
  2088. 'select' => 'wxid',
  2089. 'where' => 'sid=' . $invoicePrintDetail ['sid'],
  2090. 'asArray' => TRUE
  2091. ) );
  2092. $title2 = '[结果]您的发票' . $invoicePrintDetail ['invoiceSerial'] . '完成打印';
  2093. $msg = '';
  2094. $url = 'http://m.cld.smartcost.com.cn/invoicePrintDetail/' . $XDeode->encode ( $invoicePrintDetail ['iid'] ) . '.html';
  2095. $hfreult = $this->msgSend ( $msg, $title2, $url, $username2 ['wxid'], $invoicePrintDetail ['sid'], 'print' );
  2096. if (empty ( $invoicePrintType ))
  2097. return "/invoicePrint";
  2098. else
  2099. return "/invoicePrintStayAchieve";
  2100. }
  2101. }
  2102. /**
  2103. * 需要邮寄的发票
  2104. * @since 1.0.0
  2105. */
  2106. function invoicePost() {
  2107. Doo::loadModel ( 'invoice' );
  2108. $invoice = new invoice ();
  2109. Doo::loadModel ( 'express' );
  2110. $express = new express ();
  2111. $invoicePost = $invoice->getPostByInvoice ();
  2112. $invoicePosted = $invoice->getPostByInvoice ( 1 );
  2113. $expressList = $express->getExpressByAll ();
  2114. $invoicePostExpress = "";
  2115. if (isset ( $_COOKIE ["invoicePostExpress"] ))
  2116. $invoicePostExpress = $_COOKIE ["invoicePostExpress"];
  2117. $this->data ['invoicePostExpress'] = $invoicePostExpress;
  2118. $this->data ['expressList'] = $expressList;
  2119. $this->data ['invoicePost'] = $invoicePost;
  2120. $this->data ['invoicePosted'] = $invoicePosted;
  2121. $this->data ['memu'] = "invoice";
  2122. $this->data ['staff'] = $this->staff;
  2123. $this->data ['receiptMemu'] = 'invoicePost';
  2124. $this->render ( "/admin/invoicePost", $this->data );
  2125. }
  2126. /**
  2127. * 添加发票邮寄信息
  2128. */
  2129. function invoiceExpressAddDo() {
  2130. Doo::loadModel ( 'invoice' );
  2131. $invoice = new invoice ();
  2132. $iid = $this->get_args ( 'iidKey' ) ? $this->get_args ( 'iidKey' ) : "";
  2133. $expressCompany = $this->get_args ( 'express' ) ? $this->get_args ( 'express' ) : "";
  2134. $expressNumber = $this->get_args ( 'nu' ) ? $this->get_args ( 'nu' ) : "";
  2135. $actualItems = $this->get_args ( 'actualItems' ) ? $this->get_args ( 'actualItems' ) : "";
  2136. $iid = $iid = $invoice->authcode ( $iid );
  2137. if (! is_numeric ( $iid ) && empty ( $expressCompany ) && empty ( $expressNumber ) && empty ( $actualItems ))
  2138. die ( 'illegal request' );
  2139. $invoicePrintDetail = $invoice->getInvoiceByIid ( $iid );
  2140. setcookie ( 'invoicePostExpress', $expressNumber );
  2141. $item = array (
  2142. 'iid' => $iid,
  2143. 'postStatus' => 1,
  2144. 'updateTime' => date ( "Y-m-d H:i:s" ),
  2145. 'postTime' => date ( "Y-m-d H:i:s" ),
  2146. 'expressCompany' => $expressCompany,
  2147. 'expressNumber' => $expressNumber,
  2148. 'actualItems' => $actualItems,
  2149. 'poster' => $this->staff [0] ['username']
  2150. );
  2151. $invoice->setInvoiceByCondition ( $item );
  2152. // 微信通知-去掉
  2153. // $this->setWXMsg ( $iid );
  2154. Doo::loadModel ( 'staff' );
  2155. $staff = new staff ();
  2156. Doo::loadClass ( 'XDeode' );
  2157. $XDeode = new XDeode ( 5 );
  2158. $username2 = $staff->getOne ( array (
  2159. 'select' => 'wxid',
  2160. 'where' => 'sid=' . $invoicePrintDetail ['sid'],
  2161. 'asArray' => TRUE
  2162. ) );
  2163. $title2 = '[结果]您的发票' . $invoicePrintDetail ['invoiceSerial'] . '已邮寄';
  2164. $expCom = explode ( ":", $invoicePrintDetail ['expressCompany'] );
  2165. if (empty ( $expCom ))
  2166. $expCom [0] = '';
  2167. $msg = $expCom [0] . ':' . $invoicePrintDetail ['expressNumber'] . '';
  2168. $url = 'https://m.kuaidi100.com/result.jsp?nu=' . $invoicePrintDetail ['expressNumber'];
  2169. $hfreult = $this->msgSend ( $msg, $title2, $url, $username2 ['wxid'], $invoicePrintDetail ['sid'], 'print' );
  2170. return '/invoicePost';
  2171. }
  2172. function invoiceExpressUpdateDo() {
  2173. Doo::loadModel ( 'invoice' );
  2174. $invoice = new invoice ();
  2175. $action = $this->get_args ( 'action' ) ? $this->get_args ( 'action' ) : "";
  2176. $iid = $this->get_args ( 'iidKey' ) ? $this->get_args ( 'iidKey' ) : "";
  2177. $expressCompany = $this->get_args ( 'express' ) ? $this->get_args ( 'express' ) : "";
  2178. $expressNumber = $this->get_args ( 'nu' ) ? $this->get_args ( 'nu' ) : "";
  2179. $actualItems = $this->get_args ( 'actualItems' ) ? $this->get_args ( 'actualItems' ) : "";
  2180. $iid = $invoice->authcode ( $iid );
  2181. if (! is_numeric ( $iid ) && empty ( $expressCompany ) && empty ( $expressNumber ) && empty ( $actualItems ))
  2182. die ( 'illegal request' );
  2183. $item = array (
  2184. 'iid' => $iid,
  2185. 'updateTime' => date ( "Y-m-d H:i:s" ),
  2186. 'expressCompany' => $expressCompany,
  2187. 'expressNumber' => $expressNumber,
  2188. 'actualItems' => $actualItems,
  2189. 'poster' => $this->staff [0] ['username']
  2190. );
  2191. $invoice->setInvoiceByCondition ( $item );
  2192. return $action;
  2193. }
  2194. /**
  2195. * 可退票管理
  2196. */
  2197. function invoiceUntreadIsAchieve() {
  2198. Doo::loadModel ( 'invoice' );
  2199. $invoice = new invoice ();
  2200. Doo::loadClass ( 'XDeode' );
  2201. $XDeode = new XDeode ( 5 );
  2202. $MebSea = $this->get_args ( 'MebSea' ) ? $this->get_args ( 'MebSea' ) : "";
  2203. $page_size = 18;
  2204. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  2205. $date = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "";
  2206. $get = "?date=" . urlencode ( $date ) . "&MebSea=" . urlencode ( $MebSea );
  2207. $dateArr = explode ( ':', $date );
  2208. $D1 = '';
  2209. $D2 = '';
  2210. if (! empty ( $date )) {
  2211. $D1 = $dateArr [0];
  2212. $D2 = $dateArr [1];
  2213. }
  2214. $con = '';
  2215. if (! empty ( $D1 ) && ! empty ( $D2 ))
  2216. $con = ' and bindTime BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
  2217. // if ($date == 'MONTHO')
  2218. // $con = ' and updateTime>DATE_SUB(CURDATE(), INTERVAL 1 MONTH)';
  2219. // elseif ($date == 'MONTHT')
  2220. // $con = ' and updateTime>DATE_SUB(CURDATE(), INTERVAL 3 MONTH)';
  2221. // elseif ($date == 'MONTHY')
  2222. // $con = ' and updateTime>DATE_SUB(CURDATE(), INTERVAL 1 YEAR)';
  2223. if (! empty ( $MebSea )) {
  2224. $con .= ' and ( invoiceTitle like "%' . $MebSea . '%" or invoiceCompany like "%' . $MebSea . '%" or invoicePrice like "%' . $MebSea . '%" )';
  2225. }
  2226. $pageinfo ['page'] = array (
  2227. 'previous' => ''
  2228. );
  2229. // printStatus=1 and
  2230. $sql = " (untreadStatus=0 or untreadStatus=3) and status=2 and sid=" . $this->staff [0] ['sid'] . $con;
  2231. $action = "invoiceUntreadIsAchieve";
  2232. $pageinfo = $this->get_page ( "CLD_invoice", $sql, $page, $page_size, $action, $get, "" );
  2233. $limit = $pageinfo ['lower'] . ',' . $page_size;
  2234. $list = $invoice->getInvoiceByUntreadStatusPage ( $limit, $sql );
  2235. // print_r($list);
  2236. $this->data ['MebSeaEn'] = $MebSea;
  2237. // $this->data ['MebSea'] = urlencode ( $MebSea );
  2238. $this->data ['get'] = $get;
  2239. $this->data ['page'] = $pageinfo;
  2240. $this->data ['date'] = $date;
  2241. $this->data ['list'] = $list;
  2242. $this->data ['memu'] = "invoice";
  2243. $this->data ['staff'] = $this->staff;
  2244. $this->data ['receiptMemu'] = 'invoice';
  2245. $this->render ( "/admin/invoiceUntreadIsAchieve", $this->data );
  2246. }
  2247. /**
  2248. * 退票处理页面
  2249. */
  2250. function invoiceUntread() {
  2251. Doo::loadModel ( 'invoice' );
  2252. $invoice = new invoice ();
  2253. $untreadInvoice = $invoice->getInvoiceByUntreadStatus ( 1 );
  2254. $establishedInvoice = $invoice->getInvoiceByUntreadStatus ( 2 );
  2255. foreach ( $establishedInvoice as $key => $value ) {
  2256. // months
  2257. $lossDate = strtotime ( "+1 month", strtotime ( $value ['OperationLog'] ['date'] ) );
  2258. $nowDate = strtotime ( 'now' );
  2259. $establishedInvoice [$key] ['lossShow'] = false;
  2260. if ($lossDate < $nowDate)
  2261. $establishedInvoice [$key] ['lossShow'] = true;
  2262. }
  2263. $this->data ['untreadInvoice'] = $untreadInvoice;
  2264. $this->data ['establishedInvoice'] = $establishedInvoice;
  2265. $this->data ['memu'] = "invoice";
  2266. $this->data ['staff'] = $this->staff;
  2267. $this->data ['receiptMemu'] = 'invoiceUntread';
  2268. $this->render ( "/admin/invoiceUntread", $this->data );
  2269. }
  2270. /**
  2271. * 确认收到退回的发票,开票状态为退回 //收款状态解绑,公司统计扣除入账额度
  2272. */
  2273. function invoiceUntreadEstablishedDo() {
  2274. $untreadIidKey = $this->get_args ( 'untreadIidKey' ) ? $this->get_args ( 'untreadIidKey' ) : '';
  2275. Doo::loadModel ( 'invoice' );
  2276. $invoice = new invoice ();
  2277. Doo::loadModel ( 'invoiceOperationLog' );
  2278. $invoiceOperationLog = new invoiceOperationLog ();
  2279. Doo::loadModel ( 'invoiceReceivables' );
  2280. Doo::loadModel ( 'invoiceStatistics' );
  2281. $iid = $invoice->authcode ( $untreadIidKey );
  2282. if (! empty ( $iid ) && ! is_numeric ( $iid ))
  2283. die ( 'illegal request' );
  2284. $invoiceDetails = $invoice->getInvoiceByIid ( $iid );
  2285. if ($invoiceDetails ['untreadStatus'] != 1)
  2286. die ( 'illegal request' );
  2287. $item = array (
  2288. 'iid' => $iid,
  2289. // 'irid'=>'',
  2290. 'untreadStatus' => 2,
  2291. 'updateTime' => date ( "Y-m-d H:i:s" )
  2292. );
  2293. $invoice->setInvoiceByCondition ( $item );
  2294. $item = array (
  2295. 'date' => date ( "Y-m-d H:i:s" ),
  2296. 'operation' => '已确认退票',
  2297. 'status' => 6,
  2298. 'img' => $this->staff [0] ['avatar'],
  2299. 'username' => $this->staff [0] ['username'],
  2300. 'uid' => $this->staff [0] ['sid'],
  2301. 'category' => $this->staff [0] ['category'],
  2302. 'iid' => $iid
  2303. );
  2304. $invoiceOperationLog->setInvoiceOperationLog ( $item );
  2305. // 收款解绑以及入账扣除 收款扣除
  2306. if (! empty ( $invoiceDetails ['irid'] )) {
  2307. $iridList = explode ( ',', $invoiceDetails ['irid'] );
  2308. foreach ( $iridList as $value ) {
  2309. $invoiceReceivables = new invoiceReceivables ();
  2310. $irDetails = $invoiceReceivables->getOne ( array (
  2311. 'where' => " irid=" . $value . ' and bindStatus=1',
  2312. 'asArray' => TRUE
  2313. ) );
  2314. $item = array (
  2315. 'irid' => $value,
  2316. 'bindStatus' => 0,
  2317. 'untreadStatus' => 1,
  2318. 'untreadStaff' => $invoiceDetails ['userName'],
  2319. 'unbundlingTime' => date ( "Y-m-d H:i:s" ),
  2320. 'iid' => 0
  2321. );
  2322. $invoiceReceivables->setInvoiceReceivablesByCondition ( $item );
  2323. if (! empty ( $irDetails )) {
  2324. // 扣除入账
  2325. $invoiceStatistics = new invoiceStatistics ();
  2326. $item = array (
  2327. 'date' => date ( 'Y-m-d', strtotime ( $irDetails ['receivablesDate'] ) ),
  2328. 'priceClass' => 3,
  2329. 'cid' => $invoiceDetails ['cid'],
  2330. 'staff' => $invoiceDetails ['sid'],
  2331. 'accountPrice' => - $irDetails ['receivablesPrice']
  2332. );
  2333. $invoiceStatistics->setInvoiceStatisticsByCondition ( $item );
  2334. // 扣除收款
  2335. $invoiceStatistics = new invoiceStatistics ();
  2336. $item = array (
  2337. 'date' => date ( 'Y-m-d', strtotime ( $irDetails ['receivablesDate'] ) ),
  2338. 'priceClass' => 2,
  2339. 'cid' => $invoiceDetails ['cid'],
  2340. 'staff' => $invoiceDetails ['sid'],
  2341. 'irid' => $irDetails ['irid'],
  2342. 'receivablesPrice' => - $irDetails ['receivablesPrice']
  2343. );
  2344. $invoiceStatistics->setInvoiceStatisticsByCondition ( $item );
  2345. }
  2346. }
  2347. }
  2348. return "/invoiceUntread";
  2349. }
  2350. /**
  2351. * 建立负票,关联原来发票
  2352. */
  2353. function invoiceLossDo() {
  2354. $iidKey = $this->get_args ( 'iidKey' ) ? $this->get_args ( 'iidKey' ) : "";
  2355. if (! empty ( $iidKey )) {
  2356. Doo::loadClass ( 'XDeode' );
  2357. $XDeode = new XDeode ( 5 );
  2358. Doo::loadModel ( 'invoice' );
  2359. $invoice = new invoice ();
  2360. Doo::loadModel ( 'invoiceOperationLog' );
  2361. $invoiceOperationLog = new invoiceOperationLog ();
  2362. $iidKey = $XDeode->decode ( $iidKey );
  2363. $invoiceDetail = $invoice->getInvoiceByIid ( $iidKey );
  2364. // 拷贝插入一条发票数据
  2365. $iid = $invoice->setInvoiceLoss ( $iidKey );
  2366. // 更新负票
  2367. $invoiceSerial = "#F" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  2368. $invoice = new invoice ();
  2369. $item = array (
  2370. 'iid' => $iid,
  2371. 'sid' => $this->staff [0] ['sid'],
  2372. 'userName' => $this->staff [0] ['username'],
  2373. 'cid' => $this->staff [0] ['cid'],
  2374. 'categoryName' => $this->staff [0] ['category'],
  2375. 'invoiceQuantity' => - $invoiceDetail ['invoiceQuantity'],
  2376. 'invoicePrice' => - $invoiceDetail ['invoicePrice'],
  2377. 'invoiceSerial' => $invoiceSerial,
  2378. 'invoiceNo' => '',
  2379. 'printStatus' => 0,
  2380. 'untreadStatus' => 4,
  2381. // 关联发票号
  2382. 'lossIid' => $invoiceDetail ['iid']
  2383. );
  2384. $invoice->setInvoiceByCondition ( $item );
  2385. // 更新原发票
  2386. $invoice = new invoice ();
  2387. $item = array (
  2388. 'iid' => $invoiceDetail ['iid'],
  2389. 'lossIid' => $iid
  2390. );
  2391. $invoice->setInvoiceByCondition ( $item );
  2392. // 操作日志
  2393. $item = array (
  2394. 'date' => date ( "Y-m-d H:i:s" ),
  2395. 'operation' => "创建负票" . $invoiceSerial,
  2396. 'status' => 12,
  2397. 'img' => $this->staff [0] ['avatar'],
  2398. 'username' => $this->staff [0] ['username'],
  2399. 'uid' => $this->staff [0] ['sid'],
  2400. 'category' => $this->staff [0] ['category'],
  2401. 'iid' => $iid
  2402. );
  2403. $invoiceOperationLog->setInvoiceOperationLog ( $item );
  2404. // print_r($invoiceDetail);
  2405. // echo $iid;die;
  2406. }
  2407. return '/invoiceUntread';
  2408. }
  2409. /**
  2410. * 上传银行到账 收款文件
  2411. */
  2412. function invoiceReceivablesBankUpload() {
  2413. $POST_MAX_SIZE = ini_get ( 'post_max_size' );
  2414. $unit = strtoupper ( substr ( $POST_MAX_SIZE, - 1 ) );
  2415. $multiplier = ($unit == 'M' ? 1048576 : ($unit == 'K' ? 1024 : ($unit == 'G' ? 1073741824 : 1)));
  2416. if (( int ) $_SERVER ['CONTENT_LENGTH'] > $multiplier * ( int ) $POST_MAX_SIZE && $POST_MAX_SIZE) {
  2417. header ( "HTTP/1.1 500 Internal Server Error" );
  2418. echo "POST exceeded maximum allowed size.";
  2419. exit ( 0 );
  2420. }
  2421. // Settings
  2422. $save_path = DOO::conf ()->SITE_PATH . "upload/invoiceReceivablesBank/"; // The path were we will save the file (getcwd() may not be reliable and should be tested in your environment)
  2423. $upload_name = "Filedata";
  2424. $file_name = "";
  2425. $nk = time ();
  2426. $file_name = $nk . '.' . $this->_GetFileEXT ( $_FILES [$upload_name] ['name'] ); // preg_replace('/[^'.$valid_chars_regex.']|\.+$/i', "", basename($_FILES[$upload_name]['name']));
  2427. if (! @move_uploaded_file ( $_FILES [$upload_name] ["tmp_name"], $save_path . $file_name )) {
  2428. echo "文件无法保存.";
  2429. exit ( 0 );
  2430. }
  2431. echo json_encode ( array (
  2432. 'filename' => $file_name,
  2433. 'id' => $nk
  2434. ) );
  2435. exit ( 0 );
  2436. }
  2437. /**
  2438. * 解析银行到账收款execl并导入库中
  2439. */
  2440. function invoiceReceivablesImport() {
  2441. $path = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  2442. if ($path != "") {
  2443. Doo::loadModel ( 'invoiceReceivables' );
  2444. $invoiceReceivables = new invoiceReceivables ();
  2445. Doo::loadClass ( 'invoice.func' );
  2446. Doo::loadModel ( 'invoiceROLog' );
  2447. $invoiceROLog = new invoiceROLog ();
  2448. Doo::loadModel ( 'invoiceStatistics' );
  2449. $invoiceStatistics = new invoiceStatistics ();
  2450. $exlArray = formatExcelToArrayBank ( DOO::conf ()->SITE_PATH . "upload/invoiceReceivablesBank/" . $path );
  2451. $bankBatchNumber = 'BBN_' . time ();
  2452. Doo::db ()->beginTransaction ();
  2453. // 批量存储收款--由于必须获得收款ID,
  2454. $sql = 'INSERT INTO CLD_invoiceReceivables (OriginalPrice,receivablesPrice, receivablesMessage,receivablesSerial,receivablesBank,receivablesDate,inputStaff,date,receivablesCategory,receivablesStaff,bankBatchNumber,recepitTitleMark)
  2455. VALUES ';
  2456. $date = date ( "Y-m-d" );
  2457. $receivablesList = array ();
  2458. foreach ( $exlArray as $key => $value ) {
  2459. $receivablesSql = '(' . $value ["receivablesPrice"] . ',' . $value ["receivablesPrice"] . ',"' . $value ["receivablesMessage"] . '",' . '"#SK' . date ( "Ymd" ) . mt_rand ( 1000, 9999 ) . '","' . $value ["receivablesBank"] . '","' . $value ["receivablesDate"] . '","' . $this->staff [0] ['username'] . '","' . $date . '","PUBLIC","PUBLIC","' . $bankBatchNumber . '","' . $value ["receivablesMessage"] . '")';
  2460. array_push ( $receivablesList, $receivablesSql );
  2461. }
  2462. $sql = $sql . implode ( ',', $receivablesList );
  2463. // echo $sql;
  2464. Doo::db ()->query ( $sql );
  2465. // 批量存储收款统计
  2466. // 获得刚刚导入数据的irid组-缺少办事处和人员
  2467. $iridList = $invoiceReceivables->getInvoiceReceivablesByBBN ( $bankBatchNumber );
  2468. // 没有irid 回滚所有操作
  2469. if (empty ( $iridList )) {
  2470. Doo::db ()->rollBack ();
  2471. header ( 'Content-Type:text/html;charset=utf-8' );
  2472. die ( '文档或数据不正确,请重新<a href="/invoiceReceivables">上传</a>.' );
  2473. }
  2474. $sql = 'INSERT INTO CLD_invoiceStatistics (date, priceClass,irid,receivablesPrice)
  2475. VALUES ';
  2476. $statisticsList = array ();
  2477. foreach ( $iridList as $value ) {
  2478. $statisticsSql = '("' . $date . '",2,' . $value ['irid'] . ',' . $value ["receivablesPrice"] . ')';
  2479. array_push ( $statisticsList, $statisticsSql );
  2480. }
  2481. $sql = $sql . implode ( ',', $statisticsList );
  2482. Doo::db ()->query ( $sql );
  2483. // 批量存储操作日志
  2484. $sql = 'INSERT INTO CLD_invoiceROLog (operation, date,status,img, username,uid,category,irid)
  2485. VALUES ';
  2486. $ROLogList = array ();
  2487. foreach ( $iridList as $value ) {
  2488. $ROLogSql = '("' . $this->staff [0] ['username'] . ' 转入 公共待认领款项","' . $date . '",1,"' . $this->staff [0] ['avatar'] . '","' . $this->staff [0] ['username'] . '","' . $this->staff [0] ['sid'] . '","' . $this->staff [0] ['category'] . '","' . $value ['irid'] . '")';
  2489. array_push ( $ROLogList, $ROLogSql );
  2490. }
  2491. $sql = $sql . implode ( ',', $ROLogList );
  2492. Doo::db ()->query ( $sql );
  2493. Doo::db ()->commit ();
  2494. return "/invoiceReceivables";
  2495. }
  2496. echo 'no file';
  2497. }
  2498. function invoiceReceivables() {
  2499. $invoiceTC = $this->get_args ( 'invoiceTC' ) ? $this->get_args ( 'invoiceTC' ) : '';
  2500. Doo::loadModel ( 'L_category' );
  2501. $lCategory = new L_category ();
  2502. Doo::loadModel ( 'staff' );
  2503. $staff = new staff ();
  2504. Doo::loadModel ( 'invoiceReceivables' );
  2505. $invoiceReceivables = new invoiceReceivables ();
  2506. Doo::loadModel ( 'invoice' );
  2507. $invoice = new invoice ();
  2508. Doo::loadClass ( 'XDeode' );
  2509. $XDeode = new XDeode ( 5 );
  2510. $category = $lCategory->getCategory ();
  2511. $staffList = $staff->getStaffByCid ( $this->staff [0] ['cid'] );
  2512. $sql = 'bindStatus=1 and iid!=0';
  2513. $receivablesList = $invoiceReceivables->getInvoiceReceivablesByNew ( 4, $sql );
  2514. // 获取未入账发票
  2515. $invoiceUnAccount = $invoice->getInvoiceByUnAccount ( $invoiceTC );
  2516. $invoiceExistAccount = $invoice->getInvoiceByUnAccount ( '', true );
  2517. foreach ( $invoiceUnAccount as $key => $value ) {
  2518. $invoiceUnAccount [$key] ['iidKey'] = $XDeode->encode ( $value ['iid'] );
  2519. $lastApprover = json_decode ( $value ['processApprovals'], true );
  2520. if (! empty ( $lastApprover )) {
  2521. $lastApproverKey = array_keys ( $lastApprover );
  2522. $lastApprover = end ( $lastApprover );
  2523. $staffDetail = $staff->getOne ( array (
  2524. 'where' => 'sid=' . end ( $lastApproverKey ),
  2525. 'asArray' => true
  2526. ) );
  2527. $lastApprover ['username'] = $staffDetail ['username'];
  2528. }
  2529. $invoiceUnAccount [$key] ['lastApprover'] = $lastApprover;
  2530. }
  2531. foreach ( $invoiceExistAccount as $key => $value ) {
  2532. $irList = $invoiceReceivables->getInvoiceReceivablesInIridString ( $value ['irid'] );
  2533. if (empty ( $irList ))
  2534. $irList [0] ['sumPrice'] = 0;
  2535. $balance = $value ['invoicePrice'] - $irList [0] ['sumPrice'];
  2536. $invoiceExistAccount [$key] ['existAccount'] = $irList [0] ['sumPrice'];
  2537. $invoiceExistAccount [$key] ['balance'] = $balance;
  2538. }
  2539. $receivablesInput = $invoiceReceivables->getInvoiceReceivablesByInput ();
  2540. $halfList = $invoiceReceivables->getInvoiceReceivablesByHalf ();
  2541. $this->data ['halfList'] = $halfList;
  2542. $this->data ['halfCount'] = count ( $halfList );
  2543. // print_r($receivablesList);
  2544. $this->data ['receivablesDate'] = date ( "Y-m-d" );
  2545. $this->data ['ieaCount'] = count ( $invoiceExistAccount );
  2546. $this->data ['invoiceExistAccount'] = $invoiceExistAccount;
  2547. $this->data ['receivablesInput'] = $receivablesInput;
  2548. $this->data ['year'] = date ( 'Y' );
  2549. $this->data ['invoiceUnAccount'] = $invoiceUnAccount;
  2550. $this->data ['receivablesList'] = $receivablesList;
  2551. $this->data ['staffList'] = $staffList;
  2552. $this->data ['category'] = $category;
  2553. $this->data ['memu'] = "invoice";
  2554. $this->data ['staff'] = $this->staff;
  2555. $this->data ['receiptMemu'] = 'invoiceReceivables';
  2556. $this->render ( "/admin/invoiceReceivables", $this->data );
  2557. }
  2558. /**
  2559. * 设置收款认领地区
  2560. */
  2561. function setInvoiceReceivablesClaim() {
  2562. $iridKey = $this->get_args ( 'iridKey' ) ? $this->get_args ( 'iridKey' ) : "";
  2563. $receivablesCategory = $this->get_args ( 'receivablesCategory' ) ? $this->get_args ( 'receivablesCategory' ) : "";
  2564. $action = $this->get_args ( 'action' ) ? $this->get_args ( 'action' ) : "";
  2565. if (! empty ( $iridKey ) && ! empty ( $receivablesCategory )) {
  2566. Doo::loadModel ( 'invoiceReceivables' );
  2567. $invoiceReceivables = new invoiceReceivables ();
  2568. Doo::loadClass ( 'XDeode' );
  2569. $XDeode = new XDeode ( 5 );
  2570. Doo::loadModel ( 'invoiceROLog' );
  2571. $invoiceROLog = new invoiceROLog ();
  2572. $irid = $XDeode->decode ( $iridKey );
  2573. $irDetail = $invoiceReceivables->getInvoiceReceivablesByIrid ( $irid );
  2574. if (empty ( $irDetail ))
  2575. die ( 'illegal request' );
  2576. $item = array (
  2577. 'irid' => $irid,
  2578. 'receivablesCategory' => $receivablesCategory
  2579. );
  2580. if ($receivablesCategory != 'PUBLIC') {
  2581. $item += array (
  2582. 'confirmTime' => date ( "Y-m-d H:i:s" ),
  2583. 'inputType' => 1
  2584. );
  2585. }
  2586. $invoiceReceivables = new invoiceReceivables ();
  2587. $invoiceReceivables->setInvoiceReceivablesByCondition ( $item );
  2588. // 收款操作日志
  2589. $item = array (
  2590. 'operation' => $this->staff [0] ['username'] . " 转入 公共待认领款项 ",
  2591. 'date' => date ( "Y-m-d" ),
  2592. 'status' => 1,
  2593. 'img' => $this->staff [0] ['avatar'],
  2594. 'username' => $this->staff [0] ['username'],
  2595. 'uid' => $this->staff [0] ['sid'],
  2596. 'category' => $this->staff [0] ['category'],
  2597. 'irid' => $irid
  2598. );
  2599. $invoiceROLog->setInvoiceROLog ( $item );
  2600. if (empty ( $action ))
  2601. return '/invoiceReceivables';
  2602. else
  2603. return "/invoiceReceivablesAS";
  2604. }
  2605. die ( 'illegal request' );
  2606. }
  2607. /**
  2608. * 新添加收款直接入账发票
  2609. */
  2610. function invoiceCompareClaimPrice() {
  2611. // 收款录入
  2612. $iidKey = $this->get_args ( 'iidKey' ) ? $this->get_args ( 'iidKey' ) : "";
  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. if (! empty ( $receivablesPrice ) && ! empty ( $receivablesMessage ) && ! empty ( $receivablesBank ) && ! empty ( $receivablesDate ) && ! empty ( $iidKey )) {
  2618. Doo::loadModel ( 'invoiceReceivables' );
  2619. $invoiceReceivables = new invoiceReceivables ();
  2620. Doo::loadModel ( 'invoiceROLog' );
  2621. $invoiceROLog = new invoiceROLog ();
  2622. Doo::loadModel ( 'invoiceStatistics' );
  2623. Doo::loadModel ( 'invoice' );
  2624. $invoice = new invoice ();
  2625. Doo::loadClass ( 'XDeode' );
  2626. $XDeode = new XDeode ( 5 );
  2627. Doo::loadModel ( 'invoiceOperationLog' );
  2628. $invoiceOperationLog = new invoiceOperationLog ();
  2629. $iidKey = $XDeode->decode ( $iidKey );
  2630. $invoiceDetail = $invoice->getInvoiceByIid ( $iidKey );
  2631. if (! ($invoiceDetail ['status'] == 2 && $invoiceDetail ['printStatus'] == 1 && $invoiceDetail ['untreadStatus'] == 0))
  2632. die ( 'illegal request' );
  2633. $receivablesSerial = "#SK" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  2634. // 收款录入 并绑定发票
  2635. Doo::db ()->beginTransaction ();
  2636. $bindStatus = 0;
  2637. if ($receivablesPrice <= $invoiceDetail ['invoicePrice'])
  2638. $bindStatus = 1;
  2639. $item = array (
  2640. 'bindStatus' => $bindStatus,
  2641. 'iid' => $invoiceDetail ['iid'],
  2642. 'bindPrice' => $invoiceDetail ['invoicePrice'],
  2643. 'bindDate' => date ( "Y-m-d H:i:s" ),
  2644. 'receivablesPrice' => $receivablesPrice,
  2645. 'OriginalPrice' => $receivablesPrice,
  2646. 'receivablesMessage' => $receivablesMessage,
  2647. 'receivablesSerial' => $receivablesSerial,
  2648. 'receivablesBank' => $receivablesBank,
  2649. 'receivablesDate' => $receivablesDate,
  2650. 'inputStaff' => $this->staff [0] ['username'],
  2651. 'accountClerk' => $this->staff [0] ['username'],
  2652. 'date' => date ( "Y-m-d" ),
  2653. 'receivablesCategory' => $invoiceDetail ['cid'] . ':' . $invoiceDetail ['categoryName'],
  2654. 'receivablesStaff' => $invoiceDetail ['sid'] . '-' . $invoiceDetail ['userName'],
  2655. 'confirmTime' => date ( "Y-m-d H:i:s" )
  2656. );
  2657. $irid = $invoiceReceivables->addInvoiceReceivables ( $item );
  2658. $item = array ();
  2659. // 收款操作日志
  2660. $item = array (
  2661. 'operation' => $this->staff [0] ['username'] . " 转入 " . $invoiceDetail ['userName']
  2662. );
  2663. $item += array (
  2664. 'date' => date ( "Y-m-d" ),
  2665. 'status' => 1,
  2666. 'img' => $this->staff [0] ['avatar'],
  2667. 'username' => $this->staff [0] ['username'],
  2668. 'uid' => $this->staff [0] ['sid'],
  2669. 'category' => $this->staff [0] ['category'],
  2670. 'irid' => $irid
  2671. );
  2672. $invoiceROLog->setInvoiceROLog ( $item );
  2673. // 收款统计
  2674. $invoiceStatistics = new invoiceStatistics ();
  2675. $item = array (
  2676. 'date' => $receivablesDate,
  2677. 'priceClass' => 2,
  2678. 'irid' => $irid,
  2679. 'cid' => $invoiceDetail ['cid'],
  2680. 'staff' => $invoiceDetail ['sid'],
  2681. 'receivablesPrice' => $receivablesPrice
  2682. );
  2683. $invoiceStatistics->setInvoiceStatisticsByCondition ( $item );
  2684. // 收款 入 发票
  2685. $detail = $invoiceDetail;
  2686. $iridString = "";
  2687. if (empty ( $detail ['irid'] ))
  2688. $iridString = $irid;
  2689. else
  2690. $iridString = $detail ['irid'] . ',' . $irid;
  2691. $item = array (
  2692. 'irid' => $iridString,
  2693. 'bindTime' => date ( "Y-m-d H:i:s" ),
  2694. 'updateTime' => date ( "Y-m-d H:i:s" ),
  2695. 'iid' => $detail ['iid']
  2696. );
  2697. $invoiceReceivables = new invoiceReceivables ();
  2698. $sum = $invoiceReceivables->getSumOfReceivablesPrice ( $iridString );
  2699. if ($detail ['invoicePrice'] <= $sum)
  2700. $item += array (
  2701. 'untreadStatus' => 3
  2702. );
  2703. $invoice->setInvoiceByCondition ( $item );
  2704. // 操作日志
  2705. $item = array (
  2706. 'date' => date ( "Y-m-d H:i:s" ),
  2707. 'operation' => "收款入账" . $receivablesSerial . "到发票" . $detail ['invoiceSerial'],
  2708. 'status' => 8,
  2709. 'img' => $this->staff [0] ['avatar'],
  2710. 'username' => $this->staff [0] ['username'],
  2711. 'uid' => $this->staff [0] ['sid'],
  2712. 'category' => $this->staff [0] ['category'],
  2713. 'iid' => $detail ['iid']
  2714. );
  2715. $invoiceOperationLog->setInvoiceOperationLog ( $item );
  2716. // 入账汇总
  2717. $invoiceStatistics = new invoiceStatistics ();
  2718. // $list = $invoiceReceivables->getInvoiceReceivablesInIridString ( $iridString );
  2719. // $accountPrice = 0;
  2720. // foreach ( $list as $key => $value ) {
  2721. // $accountPrice += $value ['receivablesPrice'];
  2722. // }
  2723. $item = array (
  2724. 'date' => $receivablesDate,
  2725. 'priceClass' => 3,
  2726. 'cid' => $invoiceDetail ['cid'],
  2727. 'staff' => $invoiceDetail ['sid'],
  2728. 'accountPrice' => $receivablesPrice
  2729. );
  2730. $invoiceStatistics->setInvoiceStatisticsByCondition ( $item );
  2731. Doo::db ()->commit ();
  2732. }
  2733. return '/invoiceReceivables';
  2734. }
  2735. /**
  2736. * 检索未入账发票数据 function sir() { }
  2737. */
  2738. /**
  2739. * 录入收款数据
  2740. * @return string
  2741. */
  2742. function invoiceReceivablesDo() {
  2743. $receivablesPrice = $this->get_args ( 'receivablesPrice' ) ? $this->get_args ( 'receivablesPrice' ) : "";
  2744. $receivablesMessage = $this->get_args ( 'receivablesMessage' ) ? $this->get_args ( 'receivablesMessage' ) : "";
  2745. $receivablesBank = $this->get_args ( 'receivablesBank' ) ? $this->get_args ( 'receivablesBank' ) : "";
  2746. $receivablesDate = $this->get_args ( 'receivablesDate' ) ? $this->get_args ( 'receivablesDate' ) : "";
  2747. $receivablesCategory = $this->get_args ( 'receivablesCategory' ) ? $this->get_args ( 'receivablesCategory' ) : "";
  2748. $receivablesStaff = $receivablesStaff2 = $this->get_args ( 'receivablesStaff' ) ? $this->get_args ( 'receivablesStaff' ) : "";
  2749. Doo::loadModel ( 'invoiceReceivables' );
  2750. $invoiceReceivables = new invoiceReceivables ();
  2751. Doo::loadModel ( 'invoiceROLog' );
  2752. $invoiceROLog = new invoiceROLog ();
  2753. Doo::loadModel ( 'invoiceStatistics' );
  2754. $invoiceStatistics = new invoiceStatistics ();
  2755. if (! empty ( $receivablesPrice ) && ! empty ( $receivablesMessage ) && ! empty ( $receivablesBank ) && ! empty ( $receivablesDate ) && ! empty ( $receivablesCategory ) && ! empty ( $receivablesStaff )) {
  2756. $item = array (
  2757. 'receivablesPrice' => $receivablesPrice,
  2758. 'OriginalPrice' => $receivablesPrice,
  2759. 'receivablesMessage' => $receivablesMessage,
  2760. 'receivablesSerial' => "#SK" . date ( "Ymd" ) . mt_rand ( 1000, 9999 ),
  2761. 'receivablesBank' => $receivablesBank,
  2762. 'receivablesDate' => $receivablesDate,
  2763. 'inputStaff' => $this->staff [0] ['username'],
  2764. 'date' => date ( "Y-m-d" ),
  2765. 'receivablesCategory' => $receivablesCategory,
  2766. 'receivablesStaff' => $receivablesStaff
  2767. );
  2768. if ($receivablesCategory != 'PUBLIC') {
  2769. $item += array (
  2770. 'confirmTime' => date ( "Y-m-d H:i:s" ),
  2771. 'inputType' => 1
  2772. );
  2773. }
  2774. $irid = $invoiceReceivables->addInvoiceReceivables ( $item );
  2775. $item = array ();
  2776. // 收款操作日志
  2777. if ($receivablesCategory == 'PUBLIC' && $receivablesStaff == 'PUBLIC')
  2778. $item = array (
  2779. 'operation' => $this->staff [0] ['username'] . " 转入 公共待认领款项 "
  2780. );
  2781. elseif ($receivablesCategory != 'PUBLIC' && $receivablesStaff == 'PUBLIC')
  2782. $item = array (
  2783. 'operation' => $this->staff [0] ['username'] . "转入 办事处待认领款项"
  2784. );
  2785. elseif ($receivablesCategory != 'PUBLIC' && $receivablesStaff != 'PUBLIC') {
  2786. $receivablesStaff = explode ( '-', $receivablesStaff );
  2787. $item = array (
  2788. 'operation' => $this->staff [0] ['username'] . " 转入 " . $receivablesStaff [1]
  2789. );
  2790. }
  2791. $item += array (
  2792. 'date' => date ( "Y-m-d" ),
  2793. 'status' => 1,
  2794. 'img' => $this->staff [0] ['avatar'],
  2795. 'username' => $this->staff [0] ['username'],
  2796. 'uid' => $this->staff [0] ['sid'],
  2797. 'category' => $this->staff [0] ['category'],
  2798. 'irid' => $irid
  2799. );
  2800. $invoiceROLog->setInvoiceROLog ( $item );
  2801. $item = array (
  2802. 'date' => $receivablesDate,
  2803. 'priceClass' => 2,
  2804. 'irid' => $irid,
  2805. 'receivablesPrice' => $receivablesPrice
  2806. );
  2807. if ($receivablesCategory != 'PUBLIC') {
  2808. $receivablesCategory = explode ( ":", $receivablesCategory );
  2809. $item += array (
  2810. 'cid' => $receivablesCategory [0]
  2811. );
  2812. }
  2813. if ($receivablesStaff2 != 'PUBLIC') {
  2814. $receivablesStaff = explode ( "-", $receivablesStaff2 );
  2815. $item += array (
  2816. 'staff' => $receivablesStaff [0]
  2817. );
  2818. }
  2819. $invoiceStatistics->setInvoiceStatisticsByCondition ( $item );
  2820. $toparty = $this->getWxidByCategory ( $receivablesCategory [1] );
  2821. // $toparty = $this->getToparty ( $receivablesCategory [1] );
  2822. $msg = '[通知]财务录入了一笔待认领款项,快到“我的收款”中查看,确认是否是您的客户给您打款了。';
  2823. if ($toparty != 0)
  2824. $this->msgSendToparty ( $msg, '', '', $toparty, 'text' );
  2825. }
  2826. return "/invoiceReceivables";
  2827. }
  2828. /**
  2829. * 收款认领页面-包括公共认领 办事处认领 最近已认领数据
  2830. */
  2831. function invoiceReceivablesClaim() {
  2832. Doo::loadModel ( 'invoiceReceivables' );
  2833. $invoiceReceivables = new invoiceReceivables ();
  2834. $receivablesList = $invoiceReceivables->getInvoiceReceivablesByClaim ( $this->staff [0] ['cid'], $this->staff [0] ['sid'] );
  2835. $this->data ['receivablesList'] = $receivablesList;
  2836. $this->data ['memu'] = "invoice";
  2837. $this->data ['staff'] = $this->staff;
  2838. $this->data ['receiptMemu'] = 'invoiceReceivablesClaim';
  2839. $this->render ( "/admin/invoiceReceivablesClaim", $this->data );
  2840. }
  2841. function invoiceReceivablesTitleMarkSet() {
  2842. $iridKey = $this->get_args ( 'iridKey' ) ? $this->get_args ( 'iridKey' ) : "";
  2843. $recepitTitleMark = $this->get_args ( 'recepitTitleMark' ) ? $this->get_args ( 'recepitTitleMark' ) : "";
  2844. if (empty ( $iridKey ) || empty ( $recepitTitleMark ))
  2845. die ( 'illegal request' );
  2846. Doo::loadModel ( 'invoiceReceivables' );
  2847. $invoiceReceivables = new invoiceReceivables ();
  2848. Doo::loadClass ( 'XDeode' );
  2849. $XDeode = new XDeode ( 5 );
  2850. $irid = $XDeode->decode ( $iridKey );
  2851. if (! is_numeric ( $irid ))
  2852. die ( 'illegal request' );
  2853. $invoiceReceivables->recepitTitleMark = $recepitTitleMark;
  2854. $invoiceReceivables->update ( array (
  2855. 'where' => 'irid = ' . $irid
  2856. ) );
  2857. return '/invoiceReceivablesClaim';
  2858. }
  2859. /**
  2860. * 更新收款相关数据
  2861. */
  2862. function invoiceReceivablesUpdateClaim() {
  2863. $receivablesPrice = $this->get_args ( 'receivablesPrice' ) ? $this->get_args ( 'receivablesPrice' ) : "";
  2864. $receivablesMessage = $this->get_args ( 'receivablesMessage' ) ? $this->get_args ( 'receivablesMessage' ) : "";
  2865. $receivablesBank = $this->get_args ( 'receivablesBank' ) ? $this->get_args ( 'receivablesBank' ) : "";
  2866. $receivablesDate = $this->get_args ( 'receivablesDate' ) ? $this->get_args ( 'receivablesDate' ) : "";
  2867. $receivablesCategory = $this->get_args ( 'receivablesCategory' ) ? $this->get_args ( 'receivablesCategory' ) : "";
  2868. $receivablesStaff = $receivablesStaff2 = $this->get_args ( 'receivablesStaff' ) ? $this->get_args ( 'receivablesStaff' ) : "";
  2869. $claimKey = $this->get_args ( 'claimKey' ) ? $this->get_args ( 'claimKey' ) : "";
  2870. if (empty ( $claimKey ))
  2871. die ( 'illegal request' );
  2872. Doo::loadModel ( 'invoiceReceivables' );
  2873. $invoiceReceivables = new invoiceReceivables ();
  2874. Doo::loadModel ( 'invoiceROLog' );
  2875. $invoiceROLog = new invoiceROLog ();
  2876. $con = ' and iid=0 and bindStatus=0'; // and receivablesCategory!="PUBLIC" and receivablesStaff!="PUBLIC"
  2877. $detail = $invoiceReceivables->getInvoiceReceivablesByIrid ( $claimKey, $con );
  2878. if (empty ( $detail ))
  2879. die ( 'illegal request' );
  2880. $invoiceReceivables = new invoiceReceivables ();
  2881. $item = array (
  2882. 'irid' => $detail ['irid']
  2883. );
  2884. if ($receivablesCategory != 'PUBLIC' && $receivablesStaff != 'PUBLIC') {
  2885. $item += array (
  2886. 'confirmTime' => date ( "Y-m-d H:i:s" )
  2887. );
  2888. }
  2889. if (! empty ( $receivablesCategory ))
  2890. $item += array (
  2891. 'receivablesCategory' => $receivablesCategory
  2892. );
  2893. if (! empty ( $receivablesStaff ))
  2894. $item += array (
  2895. 'receivablesStaff' => $receivablesStaff
  2896. );
  2897. if (! empty ( $receivablesPrice ))
  2898. $item += array (
  2899. 'receivablesPrice' => $receivablesPrice
  2900. );
  2901. if (! empty ( $receivablesMessage ))
  2902. $item += array (
  2903. 'receivablesMessage' => $receivablesMessage
  2904. );
  2905. if (! empty ( $receivablesBank ))
  2906. $item += array (
  2907. 'receivablesBank' => $receivablesBank
  2908. );
  2909. if (! empty ( $receivablesDate ))
  2910. $item += array (
  2911. 'receivablesDate' => $receivablesDate
  2912. );
  2913. $invoiceReceivables->setInvoiceReceivablesByCondition ( $item );
  2914. // 收款操作日志
  2915. $item = array ();
  2916. if ($receivablesCategory == 'PUBLIC' && $receivablesStaff == 'PUBLIC')
  2917. $item = array (
  2918. 'operation' => $this->staff [0] ['username'] . " 转入 公共待认领款项 "
  2919. );
  2920. elseif ($receivablesCategory != 'PUBLIC' && $receivablesStaff == 'PUBLIC')
  2921. $item = array (
  2922. 'operation' => $this->staff [0] ['username'] . "转入 办事处待认领款项"
  2923. );
  2924. elseif ($receivablesCategory != 'PUBLIC' && $receivablesStaff != 'PUBLIC') {
  2925. $receivablesStaff = explode ( '-', $receivablesStaff );
  2926. $item = array (
  2927. 'operation' => $this->staff [0] ['username'] . " 转入 " . $receivablesStaff [1]
  2928. );
  2929. }
  2930. $item += array (
  2931. 'date' => date ( "Y-m-d" ),
  2932. 'status' => 1,
  2933. 'img' => $this->staff [0] ['avatar'],
  2934. 'username' => $this->staff [0] ['username'],
  2935. 'uid' => $this->staff [0] ['sid'],
  2936. 'category' => $this->staff [0] ['category'],
  2937. 'irid' => $detail ['irid']
  2938. );
  2939. $invoiceROLog->setInvoiceROLog ( $item );
  2940. return '/invoiceReceivablesAS';
  2941. }
  2942. function invoiceReceivablesDelete() {
  2943. $claimKey = $this->get_args ( 'claimKey' ) ? $this->get_args ( 'claimKey' ) : "";
  2944. $skll = $this->get_args ( 'skll' ) ? $this->get_args ( 'skll' ) : "";
  2945. if ($skll!='删除到款')
  2946. die ( 'illegal request' );
  2947. if (empty ( $claimKey ))
  2948. die ( 'illegal request' );
  2949. Doo::loadModel ( 'invoiceReceivables' );
  2950. $invoiceReceivables = new invoiceReceivables ();
  2951. $con = ' and iid=0 and bindStatus=0 and receivablesStaff="PUBLIC"';
  2952. $detail = $invoiceReceivables->getInvoiceReceivablesByIrid ( $claimKey, $con );
  2953. if (empty ( $detail ))
  2954. die ( 'illegal request' );
  2955. $invoiceReceivables->delInvoiceReceivablesByIrid ( $detail ['irid'] );
  2956. //扣除收款汇总信息 汇总
  2957. Doo::loadModel ( 'invoiceStatistics' );
  2958. $invoiceStatistics = new invoiceStatistics ();
  2959. $item = array (
  2960. 'date' => $detail['receivablesDate'],
  2961. 'priceClass' => 2,
  2962. 'irid' => $detail['irid'],
  2963. 'receivablesPrice' => -$detail['receivablesPrice']
  2964. );
  2965. if ($detail['receivablesCategory'] != 'PUBLIC') {
  2966. $receivablesCategory = explode ( ":", $detail['receivablesCategory'] );
  2967. $item += array (
  2968. 'cid' => $receivablesCategory [0]
  2969. );
  2970. }
  2971. if ($detail['receivablesStaff'] != 'PUBLIC') {
  2972. $receivablesStaff = explode ( "-", $detail['receivablesStaff'] );
  2973. $item += array (
  2974. 'staff' => $receivablesStaff [0]
  2975. );
  2976. }
  2977. $invoiceStatistics->setInvoiceStatisticsByCondition ( $item );
  2978. return '/invoiceReceivablesAS';
  2979. }
  2980. /**
  2981. * 管理员录入的收款 ,确认认领到谁的名下.统计收款金额
  2982. */
  2983. function invoiceReceivablesAscription() {
  2984. $irid = $this->get_args ( 'key' ) ? $this->get_args ( 'key' ) : "";
  2985. $recepitTitleMark = $this->get_args ( 'recepitTitleMark' ) ? $this->get_args ( 'recepitTitleMark' ) : "";
  2986. Doo::loadModel ( 'invoiceReceivables' );
  2987. $invoiceReceivables = new invoiceReceivables ();
  2988. Doo::loadModel ( 'invoiceROLog' );
  2989. $invoiceROLog = new invoiceROLog ();
  2990. Doo::loadModel ( 'invoiceStatistics' );
  2991. $invoiceStatistics = new invoiceStatistics ();
  2992. $detail = $invoiceReceivables->getInvoiceReceivablesByIrid ( $irid );
  2993. if (! empty ( $detail ) && $detail ['receivablesStaff'] == 'PUBLIC' && ! empty ( $recepitTitleMark )) {
  2994. $item = array (
  2995. 'irid' => $detail ['irid'],
  2996. 'receivablesCategory' => $this->staff [0] ['cid'] . ":" . $this->staff [0] ['category'],
  2997. 'receivablesStaff' => $this->staff [0] ['sid'] . "-" . $this->staff [0] ['username'],
  2998. 'confirmTime' => date ( "Y-m-d H:i:s" ),
  2999. 'recepitTitleMark' => $recepitTitleMark,
  3000. 'source' => 1
  3001. );
  3002. $invoiceReceivables->setInvoiceReceivablesByCondition ( $item );
  3003. $item = array (
  3004. 'date' => date ( "Y-m-d" ),
  3005. 'operation' => $this->staff [0] ['username'] . " 认领 ",
  3006. 'status' => 2,
  3007. 'img' => $this->staff [0] ['avatar'],
  3008. 'username' => $this->staff [0] ['username'],
  3009. 'uid' => $this->staff [0] ['sid'],
  3010. 'category' => $this->staff [0] ['category'],
  3011. 'irid' => $irid
  3012. );
  3013. $invoiceROLog->setInvoiceROLog ( $item );
  3014. $item = array (
  3015. 'cid' => $this->staff [0] ['cid'],
  3016. 'staff' => $this->staff [0] ['sid']
  3017. );
  3018. $invoiceStatistics->updateInvoiceStatisticsByIrid ( $item, $detail ['irid'], 2 );
  3019. }
  3020. return "/invoiceReceivablesClaim";
  3021. }
  3022. /**
  3023. */
  3024. function invoiceMyReceivables() {
  3025. Doo::loadModel ( 'invoiceReceivables' );
  3026. $invoiceReceivables = new invoiceReceivables ();
  3027. Doo::loadModel ( 'invoiceStatistics' );
  3028. $invoiceStatistics = new invoiceStatistics ();
  3029. $isMonth = $invoiceStatistics->getStatisticsByMonth ( $this->staff [0] ['sid'] );
  3030. $year = date ( "Y" );
  3031. $tmp_date = date ( "Ym" );
  3032. $tmp_year = substr ( $tmp_date, 0, 4 );
  3033. $tmp_mon = substr ( $tmp_date, 4, 2 );
  3034. $tmp_forwardmonth = mktime ( 0, 0, 0, $tmp_mon - 1, 1, $tmp_year );
  3035. $fm_forward_month = date ( "m", $tmp_forwardmonth );
  3036. $path = SITE_PATH . $this->INVOICECOLLECTPATH . "invoiceCollect_" . $year . "_" . $fm_forward_month . ".htm";
  3037. $htm = $this->showCache ( $path );
  3038. $list = $invoiceReceivables->getInvoiceReceivablesByClaim ( $this->staff [0] ['cid'], $this->staff [0] ['sid'] );
  3039. $this->data ['isMonth'] = $isMonth;
  3040. $this->data ['htm'] = $htm;
  3041. $this->data ['list'] = $list;
  3042. $this->data ['memu'] = "invoice";
  3043. $this->data ['staff'] = $this->staff;
  3044. $this->data ['receiptMemu'] = 'invoiceMyReceivables';
  3045. $this->render ( "/admin/invoiceMyReceivables", $this->data );
  3046. }
  3047. /**
  3048. * 纸票管理
  3049. */
  3050. function invoicePaper() {
  3051. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 'ALL';
  3052. $invoiceType = $this->get_args ( 'invoiceType' ) ? $this->get_args ( 'invoiceType' ) : "ALL";
  3053. $date = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "";
  3054. $this->data ['dateString'] = $date;
  3055. $this->data ['status'] = $status;
  3056. $this->data ['invoiceType'] = $invoiceType;
  3057. $this->data ['memu'] = "invoice";
  3058. $this->data ['staff'] = $this->staff;
  3059. $this->data ['receiptMemu'] = 'invoicePaper';
  3060. $this->render ( "/admin/invoicePaper", $this->data );
  3061. }
  3062. /**
  3063. * 获得纸票分页数据
  3064. */
  3065. function ajaxGetinvoicePaperAchieve() {
  3066. Doo::loadModel ( 'invoicePaper' );
  3067. $invoicePaper = new invoicePaper ();
  3068. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 'ALL';
  3069. $invoiceType = $this->get_args ( 'invoiceType' ) ? $this->get_args ( 'invoiceType' ) : "ALL";
  3070. $invoiceTrain = $this->get_args ( 'invoiceTrain' ) ? $this->get_args ( 'invoiceTrain' ) : "ORDINARY";
  3071. $date = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "";
  3072. $page = $this->get_args ( 'start' ) && is_numeric ( $this->get_args ( 'start' ) ) ? $this->get_args ( 'start' ) : 0;
  3073. $draw = $this->get_args ( 'draw' ) && is_numeric ( $this->get_args ( 'draw' ) ) ? $this->get_args ( 'draw' ) : 1;
  3074. $length = $this->get_args ( 'length' ) && is_numeric ( $this->get_args ( 'length' ) ) ? $this->get_args ( 'length' ) : 10;
  3075. $MebSea = $this->get_args ( 'search' );
  3076. $MebSea = $MebSea ['value'];
  3077. $page_size = $length;
  3078. $con = '';
  3079. if ($status == 'ALL')
  3080. $con = ' where 1 ';
  3081. elseif ($status == 'PRINTED')
  3082. $con = ' where b.isDelete=0 and b.status=2 and b.untreadStatus=0 and b.printStatus=1 ';
  3083. elseif ($status == 'UNPRINT')
  3084. $con = ' where b.isDelete=0 and b.status=2 and b.untreadStatus=0 and b.printStatus=0 ';
  3085. elseif ($status == 'TICKET')
  3086. $con = ' where b.isDelete=0 and b.untreadStatus=2';
  3087. if ($invoiceType == 'ORDINARY')
  3088. $con .= ' and a.invoiceType=0 ';
  3089. elseif ($invoiceType == 'SPECIAL')
  3090. $con .= ' and a.invoiceType=1 ';
  3091. $dateArr = explode ( ':', $date );
  3092. $D1 = $dateString = '';
  3093. $D2 = '';
  3094. if (! empty ( $date )) {
  3095. $D1 = $dateArr [0];
  3096. if (isset ( $dateArr [1] ))
  3097. $D2 = $dateArr [1];
  3098. else
  3099. $D2 = '';
  3100. $dateString = $D1 . " : " . $D2;
  3101. }
  3102. if (! empty ( $D1 ) && ! empty ( $D2 ))
  3103. $con .= ' and b.printTime BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
  3104. elseif (! empty ( $D1 ) && empty ( $D2 ))
  3105. $con .= ' and b.printTime like "%' . $D1 . '%" ';
  3106. if (! empty ( $MebSea ))
  3107. $con .= ' and ( b.invoiceTitle like "%' . $MebSea . '%" or b.invoiceCompany like "%' . $MebSea . '%" or a.invoiceNo like "%' . $MebSea . '%" )';
  3108. $invoiceTotal = $invoicePaper->getInvoicePaperCount ();
  3109. $sql = ' ' . $con;
  3110. $limit = $page . ',' . $page_size;
  3111. $list = $invoicePaper->getInvoicePaper ( $limit, $sql, 'desc' );
  3112. $paperList = array ();
  3113. foreach ( $list as $key => $value ) {
  3114. $irDetail = array ();
  3115. if ($value ['iid'] == 0)
  3116. array_push ( $irDetail, '<a href="javascript:if(window.confirm(\'确认删除?\'))window.location=\'/invoicePaperDel/' . $value ['ipidKey'] . '\'" >删除</a>' );
  3117. else
  3118. array_push ( $irDetail, '' );
  3119. array_push ( $irDetail, $value ['invoiceCode'] );
  3120. array_push ( $irDetail, $value ['invoiceNo'] );
  3121. array_push ( $irDetail, '<a href="#approvalInvice" onclick="nodeInvoice(\'' . $value ['iidKey'] . '\')" data-toggle="modal">' . $value ['invoiceSerial'] . '</a>' );
  3122. if ($value ['invoiceType'] == 1)
  3123. array_push ( $irDetail, $value ['invoiceCompany'] );
  3124. else
  3125. array_push ( $irDetail, $value ['invoiceTitle'] );
  3126. if ($value ['invoiceType'] == 1)
  3127. array_push ( $irDetail, '¥' . $value ['invoicePrice'] . '<sup>专</sup>' );
  3128. else
  3129. array_push ( $irDetail, '¥' . $value ['invoicePrice'] );
  3130. array_push ( $irDetail, $value ['invoiceElement'] );
  3131. array_push ( $irDetail, $value ['categoryName'] . '-' . $value ['userName'] );
  3132. array_push ( $irDetail, $value ['printTime'] );
  3133. array_push ( $paperList, $irDetail );
  3134. }
  3135. // $approvalListJson = json_encode ( $approvalList );
  3136. $recordsFiltered = $invoiceTotal;
  3137. echo json_encode ( array (
  3138. "draw" => intval ( $draw ),
  3139. "recordsTotal" => intval ( $invoiceTotal ),
  3140. "recordsFiltered" => intval ( $recordsFiltered ),
  3141. "data" => $paperList
  3142. ), JSON_UNESCAPED_UNICODE );
  3143. }
  3144. function invoicePaperDel() {
  3145. $ipidKey = isset ( $this->params ['ipidKey'] ) ? $this->params ['ipidKey'] : "";
  3146. $XDeode = new XDeode ( 5 );
  3147. $ipid = $XDeode->decode ( $ipidKey );
  3148. if (empty ( $ipid ))
  3149. die ( 'illegal request' );
  3150. Doo::loadModel ( 'invoicePaper' );
  3151. $invoicePaper = new invoicePaper ();
  3152. $invoicePaper->delete ( array (
  3153. 'where' => 'ipid=' . $ipid . ' and iid=0',
  3154. 'limit' => 1
  3155. ) );
  3156. return '/invoicePaper';
  3157. }
  3158. /**
  3159. * 添加纸质发票号
  3160. */
  3161. function invoicePaperAdd() {
  3162. $invoiceType = $this->get_args ( 'invoiceType' ) && is_numeric ( $this->get_args ( 'invoiceType' ) ) ? $this->get_args ( 'invoiceType' ) : '0';
  3163. $invoiceCode = $this->get_args ( 'invoiceCode' ) ? $this->get_args ( 'invoiceCode' ) : "";
  3164. $invoiceNoStart = $this->get_args ( 'invoiceNoStart' ) && is_numeric ( $this->get_args ( 'invoiceNoStart' ) ) ? $this->get_args ( 'invoiceNoStart' ) : 0;
  3165. $invoiceNoTotal = $this->get_args ( 'invoiceNoTotal' ) && is_numeric ( $this->get_args ( 'invoiceNoTotal' ) ) ? $this->get_args ( 'invoiceNoTotal' ) : 0;
  3166. if ($invoiceType != '' && ! empty ( $invoiceCode ) && ! empty ( $invoiceNoStart ) && ! empty ( $invoiceNoTotal )) {
  3167. $sum = $invoiceNoStart + $invoiceNoTotal;
  3168. if (empty ( $sum ))
  3169. die ( 'illegal request' );
  3170. Doo::db ()->beginTransaction ();
  3171. // 批量存储纸质发票
  3172. $date = date ( "Y-m-d H:i:s" );
  3173. $sql = 'INSERT INTO CLD_invoicePaper (invoiceType, invoiceCode,invoiceNo,date)
  3174. VALUES ';
  3175. $paperList = array ();
  3176. for($invoiceNoStart; $invoiceNoStart <= $sum - 1; $invoiceNoStart ++) {
  3177. $paperSql = '(' . $invoiceType . ',"' . $invoiceCode . '","' . $invoiceNoStart . '","' . $date . '")';
  3178. array_push ( $paperList, $paperSql );
  3179. }
  3180. if (empty ( $paperList ))
  3181. die ( 'illegal request' );
  3182. $sql = $sql . implode ( ',', $paperList );
  3183. Doo::db ()->query ( $sql );
  3184. Doo::db ()->commit ();
  3185. return 'invoicePaper';
  3186. }
  3187. die ( 'illegal request' );
  3188. }
  3189. /**
  3190. * 收款绑定发票 ,一个收款只能绑定一个发票
  3191. */
  3192. function invoiceBindReceivables() {
  3193. $claimKey = $this->get_args ( 'key' ) ? $this->get_args ( 'key' ) : "";
  3194. $invoiceKey = $this->get_args ( 'invoiceKey' ) ? $this->get_args ( 'invoiceKey' ) : "";
  3195. Doo::loadModel ( 'invoice' );
  3196. $invoice = new invoice ();
  3197. Doo::loadModel ( 'invoiceReceivables' );
  3198. $invoiceReceivables = new invoiceReceivables ();
  3199. Doo::loadModel ( 'invoiceOperationLog' );
  3200. $invoiceOperationLog = new invoiceOperationLog ();
  3201. if (empty ( $invoiceKey ) || empty ( $claimKey ))
  3202. die ( 'illegal request' );
  3203. $detail = $invoice->getInvoiceByIid ( $invoiceKey );
  3204. $detailM = $invoiceReceivables->getInvoiceReceivablesByIrid ( $claimKey );
  3205. if (empty ( $detail ) && empty ( $detailM ))
  3206. die ( 'illegal request' );
  3207. if ($detail ['untreadStatus'] == 3)
  3208. die ( 'illegal request' );
  3209. // 修改 绑定状态改为 金额
  3210. $invoiceReceivables = new invoiceReceivables ();
  3211. $invoicePrice = $detail ['invoicePrice'] + $detailM ['bindPrice'];
  3212. if ($detailM ['receivablesPrice'] > $invoicePrice) {
  3213. $item = array (
  3214. 'bindPrice' => $invoicePrice
  3215. );
  3216. } elseif ($detailM ['receivablesPrice'] <= $invoicePrice) {
  3217. $item = array (
  3218. 'bindPrice' => $invoicePrice,
  3219. 'bindStatus' => 1,
  3220. 'bindDate' => date ( "Y-m-d H:i:s" )
  3221. );
  3222. } else {
  3223. die ( 'illegal request' );
  3224. }
  3225. if ($detailM ['iid'] == 0) {
  3226. $item += array (
  3227. 'iid' => $detail ['iid']
  3228. );
  3229. } else {
  3230. $iidExtend = explode ( ',', $detailM ['iidExtend'] );
  3231. array_push ( $iidExtend, $detail ['iid'] );
  3232. $item += array (
  3233. 'iidExtend' => implode ( ',', $iidExtend )
  3234. );
  3235. }
  3236. $item += array (
  3237. 'irid' => $detailM ['irid'],
  3238. 'accountClerk' => $this->staff [0] ['username']
  3239. );
  3240. // 如何没有人收款 则自动绑定收款
  3241. if ($detailM ['receivablesCategory'] == 'PUBLIC' || $detailM ['receivablesStaff'] == 'PUBLIC') {
  3242. $item += array (
  3243. 'receivablesCategory' => $detail ['cid'] . ':' . $detail ['categoryName'],
  3244. 'receivablesStaff' => $detail ['sid'] . '-' . $detail ['userName']
  3245. );
  3246. }
  3247. $invoiceReceivables->setInvoiceReceivablesByCondition ( $item );
  3248. $iridString = "";
  3249. if (empty ( $detail ['irid'] ))
  3250. $iridString = $detailM ['irid'];
  3251. else
  3252. $iridString = $detail ['irid'] . ',' . $detailM ['irid'];
  3253. $item = array (
  3254. 'iid' => $detail ['iid'],
  3255. 'irid' => $iridString
  3256. );
  3257. $invoiceReceivables = new invoiceReceivables ();
  3258. $sum = $invoiceReceivables->getSumOfReceivablesPrice ( $iridString );
  3259. if ($detail ['invoicePrice'] <= $sum)
  3260. $item += array (
  3261. 'untreadStatus' => 3,
  3262. 'bindTime' => date ( "Y-m-d H:i:s" )
  3263. );
  3264. // print_r($item);
  3265. // echo $sum;die;
  3266. $invoice->setInvoiceByCondition ( $item );
  3267. // 操作日志
  3268. $item = array (
  3269. 'date' => date ( "Y-m-d H:i:s" ),
  3270. 'operation' => "收款" . $detailM ['receivablesSerial'] . "入账到发票" . $detail ['invoiceSerial'],
  3271. 'status' => 8,
  3272. 'img' => $this->staff [0] ['avatar'],
  3273. 'username' => $this->staff [0] ['username'],
  3274. 'uid' => $this->staff [0] ['sid'],
  3275. 'category' => $this->staff [0] ['category'],
  3276. 'iid' => $detail ['iid']
  3277. );
  3278. $invoiceOperationLog->setInvoiceOperationLog ( $item );
  3279. Doo::loadModel ( 'invoiceStatistics' );
  3280. $invoiceStatistics = new invoiceStatistics ();
  3281. $item = array (
  3282. 'date' => $detailM ['receivablesDate'],
  3283. 'priceClass' => 3,
  3284. 'cid' => $detail ['cid'],
  3285. 'staff' => $detail ['sid'],
  3286. 'accountPrice' => $detailM ['receivablesPrice']
  3287. );
  3288. $invoiceStatistics->setInvoiceStatisticsByCondition ( $item );
  3289. return "/invoiceReceivables";
  3290. }
  3291. /**
  3292. * 核销 动作,确认入账统计 发票收款完成--需求更变 废弃 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"; }
  3293. */
  3294. function invoiceAggregate() {
  3295. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  3296. Doo::loadModel ( 'invoiceStatistics' );
  3297. $invoiceStatistics = new invoiceStatistics ();
  3298. Doo::loadModel ( 'L_category' );
  3299. $Lcategory = new L_category ();
  3300. $isList = $invoiceStatistics->getInvoiceStatisticsByYear ( $year );
  3301. $LcategoryList = $Lcategory->getCategory ();
  3302. // print_r($isList);
  3303. $html = ""; // $invoicePriceCategory=0;$receivablesPriceCategory=0;$accountPriceCategory=0;
  3304. foreach ( $LcategoryList as $key => $value ) {
  3305. $html .= '<tr><th><a href="/invoiceAggregateCategory/' . $value ['cidKey'] . '">' . $value ['title'] . '</a></th>';
  3306. $month = 1;
  3307. $invoicePriceYear = 0;
  3308. $receivablesPriceYear = 0;
  3309. $accountPriceYear = 0;
  3310. for(; $month <= 12; $month ++) {
  3311. $flag = true;
  3312. foreach ( $isList ['statisticsMonthCid'] as $k => $v ) {
  3313. if ($value ['cid'] == $v ['cid'] && $month == $v ['month']) {
  3314. $html .= '<td class="taR">¥' . $v ['invoicePrice'] . '</td>
  3315. <td class="taR">¥' . $v ['receivablesPrice'] . '</td>
  3316. <td class="taR"><b>¥' . $v ['accountPrice'] . '</b></td>
  3317. ';
  3318. $invoicePriceYear += $v ['invoicePrice'];
  3319. $receivablesPriceYear += $v ['receivablesPrice'];
  3320. $accountPriceYear += $v ['accountPrice'];
  3321. $flag = false;
  3322. break;
  3323. }
  3324. }
  3325. if ($flag)
  3326. $html .= '<td class="taR"></td>
  3327. <td class="taR"></td>
  3328. <td class="taR"><b></b></td>
  3329. ';
  3330. }
  3331. $html .= '<td class="taR colRed">' . $invoicePriceYear . '</td>
  3332. <td class="taR colOrange">' . $receivablesPriceYear . '</td>
  3333. <td class="taR colGreen"><b>' . $accountPriceYear . '</b></td>
  3334. ';
  3335. $html .= '</tr>';
  3336. }
  3337. $html .= '<tr><th><b class="colGreen">月合计</b></th>';
  3338. $invoicePriceYear = 0;
  3339. $receivablesPriceYear = 0;
  3340. $accountPriceYear = 0;
  3341. for($month = 1; $month <= 12; $month ++) {
  3342. $flag = true;
  3343. foreach ( $isList ['statisticsMonth'] as $k => $v ) {
  3344. if ($month == $v ['month']) {
  3345. $html .= '<td class="taR">¥' . $v ['invoicePrice'] . '</td>
  3346. <td class="taR">¥' . $v ['receivablesPrice'] . '</td>
  3347. <td class="taR"><b>¥' . $v ['accountPrice'] . '</b></td>
  3348. ';
  3349. $invoicePriceYear += $v ['invoicePrice'];
  3350. $receivablesPriceYear += $v ['receivablesPrice'];
  3351. $accountPriceYear += $v ['accountPrice'];
  3352. $flag = false;
  3353. break;
  3354. }
  3355. }
  3356. if ($flag) {
  3357. $html .= '<td class="taR"></td>
  3358. <td class="taR"></td>
  3359. <td class="taR"><b></b></td>
  3360. ';
  3361. }
  3362. }
  3363. $html .= '<td class="taR colRed">' . $invoicePriceYear . '</td>
  3364. <td class="taR colOrange">' . $receivablesPriceYear . '</td>
  3365. <td class="taR colGreen"><b>' . $accountPriceYear . '</b></td>
  3366. ';
  3367. $html .= '</tr>';
  3368. // print_r($isList);
  3369. $this->data ['html'] = $html;
  3370. $this->data ['LcategoryList'] = $LcategoryList;
  3371. $this->data ['isList'] = $isList;
  3372. $this->data ['year'] = $year;
  3373. $this->data ['memu'] = "invoice";
  3374. $this->data ['staff'] = $this->staff;
  3375. $this->data ['receiptMemu'] = 'invoiceAggregate';
  3376. $this->render ( "/admin/invoiceAggregate", $this->data );
  3377. }
  3378. function invoiceAggregateStaff() {
  3379. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  3380. Doo::loadModel ( 'invoiceStatistics' );
  3381. $invoiceStatistics = new invoiceStatistics ();
  3382. Doo::loadModel ( 'L_category' );
  3383. $Lcategory = new L_category ();
  3384. $toteList = $invoiceStatistics->getInvoiceStatisticsByTote ( $year );
  3385. $staffList = $invoiceStatistics->getInvoiceStatisticsByStaff ( $year );
  3386. $cStaff = $Lcategory->getCategoryStaff ();
  3387. $html = '';
  3388. foreach ( $cStaff as $key => $value ) {
  3389. $categoryFir = true;
  3390. foreach ( $value ['staff'] as $k => $v ) {
  3391. if ($categoryFir) {
  3392. $width = count ( $value ['staff'] ) + 1;
  3393. $html .= '<tr><th rowspan="' . $width . '">' . $value ['title'] . ' </th>';
  3394. $categoryFir = false;
  3395. } else
  3396. $html .= '<tr>';
  3397. $html .= '<th>' . $v ['username'] . '</th>';
  3398. $invoicePriceStaffYear = 0;
  3399. $receivablesPriceStaffYear = 0;
  3400. $accountPriceStaffYear = 0;
  3401. for($month = 1; $month <= 12; $month ++) {
  3402. $flag = true;
  3403. foreach ( $staffList ['statisticsMonthStaff'] as $sl => $slv ) {
  3404. if ($v ['sid'] == $slv ['staff'] && $month == $slv ['month']) {
  3405. $html .= '<td class="taR">¥' . $slv ['invoicePrice'] . '</td>
  3406. <td class="taR">¥' . $slv ['receivablesPrice'] . '</td>
  3407. <td class="taR"><b>¥' . $slv ['accountPrice'] . '</b></td>
  3408. ';
  3409. $invoicePriceStaffYear += $slv ['invoicePrice'];
  3410. $receivablesPriceStaffYear += $slv ['receivablesPrice'];
  3411. $accountPriceStaffYear += $slv ['accountPrice'];
  3412. $flag = false;
  3413. break;
  3414. }
  3415. }
  3416. if ($flag)
  3417. $html .= '<td class="taR"></td>
  3418. <td class="taR"></td>
  3419. <td class="taR"><b></b></td>
  3420. ';
  3421. }
  3422. $html .= '<td class="taR colRed">' . $invoicePriceStaffYear . '</td>
  3423. <td class="taR colOrange">' . $receivablesPriceStaffYear . '</td>
  3424. <td class="taR colGreen"><b>' . $accountPriceStaffYear . '</b></td>
  3425. ';
  3426. }
  3427. $html .= '</tr>';
  3428. // 小计
  3429. if (! empty ( $value ['staff'] )) {
  3430. $html .= '<tr><th class="taR">小计</th>';
  3431. $invoicePriceStaffYear = 0;
  3432. $receivablesPriceStaffYear = 0;
  3433. $accountPriceStaffYear = 0;
  3434. for($month = 1; $month <= 12; $month ++) {
  3435. $flag = true;
  3436. foreach ( $staffList ['statisticsMonthCid'] as $smc => $smcv ) {
  3437. if ($value ['cid'] == $smcv ['cid'] && $month == $slv ['month']) {
  3438. $html .= '<td class="taR">¥' . $smcv ['invoicePrice'] . '</td>
  3439. <td class="taR">¥' . $smcv ['receivablesPrice'] . '</td>
  3440. <td class="taR"><b>¥' . $smcv ['accountPrice'] . '</b></td>
  3441. ';
  3442. $invoicePriceStaffYear += $slv ['invoicePrice'];
  3443. $receivablesPriceStaffYear += $slv ['receivablesPrice'];
  3444. $accountPriceStaffYear += $slv ['accountPrice'];
  3445. $flag = false;
  3446. break;
  3447. }
  3448. }
  3449. if ($flag)
  3450. $html .= '<td class="taR"></td>
  3451. <td class="taR"></td>
  3452. <td class="taR"><b></b></td>
  3453. ';
  3454. }
  3455. $html .= '<td class="taR colRed">' . $invoicePriceStaffYear . '</td>
  3456. <td class="taR colOrange">' . $receivablesPriceStaffYear . '</td>
  3457. <td class="taR colGreen"><b>' . $accountPriceStaffYear . '</b></td>
  3458. ';
  3459. $html .= '</tr>';
  3460. }
  3461. }
  3462. $html .= '<tr class="warning"><th colspan="2"><b class="colGreen" >月合计</b></th>';
  3463. $invoicePriceYear = 0;
  3464. $receivablesPriceYear = 0;
  3465. $accountPriceYear = 0;
  3466. for($month = 1; $month <= 12; $month ++) {
  3467. $flag = true;
  3468. foreach ( $staffList ['statisticsMonth'] as $k => $v ) {
  3469. if ($month == $v ['month']) {
  3470. $html .= '<td class="taR colRed">¥' . $v ['invoicePrice'] . '</td>
  3471. <td class="taR colOrange">¥' . $v ['receivablesPrice'] . '</td>
  3472. <td class="taR colGreen"><b>¥' . $v ['accountPrice'] . '</b></td>
  3473. ';
  3474. $invoicePriceYear += $v ['invoicePrice'];
  3475. $receivablesPriceYear += $v ['receivablesPrice'];
  3476. $accountPriceYear += $v ['accountPrice'];
  3477. $flag = false;
  3478. break;
  3479. }
  3480. }
  3481. if ($flag)
  3482. $html .= '<td class="taR"></td>
  3483. <td class="taR"></td>
  3484. <td class="taR"><b></b></td>
  3485. ';
  3486. }
  3487. $html .= '<td class="taR colRed">' . $invoicePriceYear . '</td>
  3488. <td class="taR colOrange">' . $receivablesPriceYear . '</td>
  3489. <td class="taR colGreen"><b>' . $accountPriceYear . '</b></td>
  3490. ';
  3491. $html .= '</tr>';
  3492. $this->data ['html'] = $html;
  3493. $this->data ['isList'] = $toteList;
  3494. $this->data ['year'] = $year;
  3495. $this->data ['memu'] = "invoice";
  3496. $this->data ['staff'] = $this->staff;
  3497. $this->data ['receiptMemu'] = 'invoiceAggregate';
  3498. $this->render ( "/admin/invoiceAggregateStaff", $this->data );
  3499. }
  3500. function invoiceAggregateCategory() {
  3501. Doo::loadClass ( 'XDeode' );
  3502. $XDeode = new XDeode ( 5 );
  3503. $cid = $cidKey = isset ( $this->params ['cid'] ) ? $this->params ['cid'] : "";
  3504. $cid = $XDeode->decode ( $cid );
  3505. if (! is_numeric ( $cid ))
  3506. die ( 'illegal request' );
  3507. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  3508. Doo::loadModel ( 'invoiceStatistics' );
  3509. $invoiceStatistics = new invoiceStatistics ();
  3510. Doo::loadModel ( 'staff' );
  3511. $staff = new staff ();
  3512. $list = $staff->getStaffByCid ( $cid );
  3513. $isCategory = $invoiceStatistics->getInvoiceStatisticsByStaff ( $year, $cid );
  3514. $toteList = $invoiceStatistics->getInvoiceStatisticsByTote ( $year, $cid );
  3515. if (empty ( $list ))
  3516. die ( '该办事处没有成员' );
  3517. $htmlA = $htmlB = $htmlC = $html = '';
  3518. foreach ( $list as $key => $value ) {
  3519. $htmlA = '<tr><th rowspan="3">' . $value ['username'] . '</th><th class="taC">开票</th>';
  3520. $htmlB = '<tr><th class="taC">收款</th>';
  3521. $htmlC = '<tr><th class="taC">入账</th>';
  3522. $invoicePriceStaffYear = 0;
  3523. $receivablesPriceStaffYear = 0;
  3524. $accountPriceStaffYear = 0;
  3525. for($month = 1; $month <= 12; $month ++) {
  3526. $flag = true;
  3527. foreach ( $isCategory ['statisticsMonthStaff'] as $k => $v ) {
  3528. if ($value ['sid'] == $v ['staff'] && $month == $v ['month']) {
  3529. $htmlA .= '<td class="taR">¥' . $v ['invoicePrice'] . '</td>';
  3530. $htmlB .= '<td class="taR">¥' . $v ['receivablesPrice'] . '</td>';
  3531. $htmlC .= '<td class="taR"><b>¥' . $v ['accountPrice'] . '</b></td>';
  3532. $invoicePriceStaffYear += $v ['invoicePrice'];
  3533. $receivablesPriceStaffYear += $v ['receivablesPrice'];
  3534. $accountPriceStaffYear += $v ['accountPrice'];
  3535. $flag = false;
  3536. break;
  3537. }
  3538. }
  3539. if ($flag) {
  3540. $htmlA .= '<td class="taR">-</td>';
  3541. $htmlB .= '<td class="taR">-</td>';
  3542. $htmlC .= '<td class="taR"><b>-</b></td>';
  3543. }
  3544. }
  3545. $htmlA .= '<td class="taR colRed">' . $invoicePriceStaffYear . '</td>';
  3546. $htmlB .= '<td class="taR colOrange">' . $receivablesPriceStaffYear . '</td>';
  3547. $htmlC .= '<td class="taR colGreen"><b>' . $accountPriceStaffYear . '</b></td>';
  3548. $htmlA .= '</tr>';
  3549. $htmlB .= '</tr>';
  3550. $htmlC .= '</tr>';
  3551. $html .= $htmlA . $htmlB . $htmlC;
  3552. }
  3553. $htmlA = $htmlB = $htmlC = "";
  3554. $htmlA = '<tr><th rowspan="3">月合计</th><th class="taC">开票</th>';
  3555. $htmlB = '<tr><th class="taC">收款</th>';
  3556. $htmlC = '<tr><th class="taC">入账</th>';
  3557. $invoicePriceStaffYear = 0;
  3558. $receivablesPriceStaffYear = 0;
  3559. $accountPriceStaffYear = 0;
  3560. for($month = 1; $month <= 12; $month ++) {
  3561. $flag = true;
  3562. foreach ( $isCategory ['statisticsMonth'] as $k => $v ) {
  3563. if ($month == $v ['month']) {
  3564. $htmlA .= '<td class="taR colRed">¥' . $v ['invoicePrice'] . '</td>';
  3565. $htmlB .= '<td class="taR colOrange">¥' . $v ['receivablesPrice'] . '</td>';
  3566. $htmlC .= '<td class="taR colGreen"><b>¥' . $v ['accountPrice'] . '</b></td>';
  3567. $invoicePriceStaffYear += $v ['invoicePrice'];
  3568. $receivablesPriceStaffYear += $v ['receivablesPrice'];
  3569. $accountPriceStaffYear += $v ['accountPrice'];
  3570. $flag = false;
  3571. break;
  3572. }
  3573. }
  3574. if ($flag) {
  3575. $htmlA .= '<td class="taR">-</td>';
  3576. $htmlB .= '<td class="taR">-</td>';
  3577. $htmlC .= '<td class="taR"><b>-</b></td>';
  3578. }
  3579. }
  3580. $htmlA .= '<td class="taR colRed">' . $invoicePriceStaffYear . '</td>';
  3581. $htmlB .= '<td class="taR colOrange">' . $receivablesPriceStaffYear . '</td>';
  3582. $htmlC .= '<td class="taR colGreen"><b>' . $accountPriceStaffYear . '</b></td>';
  3583. $htmlA .= '</tr>';
  3584. $htmlB .= '</tr>';
  3585. $htmlC .= '</tr>';
  3586. $html .= $htmlA . $htmlB . $htmlC;
  3587. $this->data ['html'] = $html;
  3588. $this->data ['cidKey'] = $cidKey;
  3589. $this->data ['slist'] = $list;
  3590. $this->data ['isList'] = $toteList;
  3591. $this->data ['year'] = $year;
  3592. $this->data ['memu'] = "invoice";
  3593. $this->data ['staff'] = $this->staff;
  3594. $this->data ['receiptMemu'] = 'invoiceAggregate';
  3595. $this->render ( "/admin/invoiceAggregateCategory", $this->data );
  3596. }
  3597. /**
  3598. * 办事处汇总信息
  3599. */
  3600. function invoiceAggregateCategoryDetail() {
  3601. $cidKey = $this->get_args ( 'cidKey' ) ? $this->get_args ( 'cidKey' ) : '';
  3602. Doo::loadClass ( 'XDeode' );
  3603. $XDeode = new XDeode ( 5 );
  3604. Doo::loadModel ( 'invoiceStatistics' );
  3605. $invoiceStatistics = new invoiceStatistics ();
  3606. Doo::loadModel ( 'L_category' );
  3607. $category = new L_category ();
  3608. Doo::loadModel ( 'invoice' );
  3609. $invoice = new invoice ();
  3610. Doo::loadModel ( 'staff' );
  3611. $staff = new staff ();
  3612. Doo::loadModel ( "invoiceCategoryManage" );
  3613. $invoiceCategoryManage = new invoiceCategoryManage ();
  3614. $imcStaff = $invoiceCategoryManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  3615. $cidList = array ();
  3616. foreach ( $imcStaff as $key => $value ) {
  3617. array_push ( $cidList, $value ['cid'] );
  3618. if (empty ( $cidKey ))
  3619. $cidKey = $XDeode->encode ( $value ['cid'] );
  3620. }
  3621. $categoryList = $category->getCategoryInCid ( implode ( ',', $cidList ) );
  3622. $cid = $XDeode->decode ( $cidKey );
  3623. $month = date ( "m", strtotime ( "-1 month" ) );
  3624. $redis = new Redis ();
  3625. $redis->connect ( '127.0.0.1', '6379' );
  3626. $redisKey = ''; // date('Y-m-d').'_iacd_'.$cid;
  3627. $redisValue = ''; // $redis->lrange($redisKey, 0, -1);
  3628. if (empty ( $redisValue )) {
  3629. $isMC = $invoiceStatistics->getInvoiceStatistiscsMothByCategory ( $cid );
  3630. $schedule = $invoice->getInvoiceScheduleByCid ( $cid );
  3631. // 获得办事处人员下的汇总
  3632. $slist = $staff->getStaffByCid ( $cid );
  3633. $ismsbMonth = $invoiceStatistics->getISMSByCategoryByMonth ( $cid, $month ); // 上一个月的汇总
  3634. $ismsb = $invoiceStatistics->getISMSByCategory ( $cid ); // 当月汇总
  3635. $ISAS = $invoiceStatistics->getISASByCategory ( $cid ); // 全部汇总
  3636. $scheduleStaff = $invoice->getInvoiceScheduleByCidGroupSid ( $cid ); // 完成度
  3637. foreach ( $slist as $key => $value ) {
  3638. $slist [$key] ['invoicePrice'] = 0;
  3639. $slist [$key] ['receivablesPrice'] = 0;
  3640. $slist [$key] ['accountPrice'] = 0;
  3641. $slist [$key] ['invoiceAllPrice'] = 0;
  3642. $slist [$key] ['receivablesAllPrice'] = 0;
  3643. $slist [$key] ['accountAllPrice'] = 0;
  3644. $slist [$key] ['schedule'] = 0;
  3645. $slist [$key] ['invoiceMonthPrice'] = 0;
  3646. $slist [$key] ['receivablesMonthPrice'] = 0;
  3647. $slist [$key] ['accountMonthPrice'] = 0;
  3648. foreach ( $ismsbMonth as $y => $l ) {
  3649. if ($value ['sid'] == $l ['staff']) {
  3650. $slist [$key] ['invoiceMonthPrice'] = $l ['invoicePrice'];
  3651. $slist [$key] ['receivablesMonthPrice'] = $l ['receivablesPrice'];
  3652. $slist [$key] ['accountMonthPrice'] = $l ['accountPrice'];
  3653. }
  3654. }
  3655. foreach ( $ismsb as $k => $v ) {
  3656. if ($value ['sid'] == $v ['staff']) {
  3657. $slist [$key] ['invoicePrice'] = $v ['invoicePrice'];
  3658. $slist [$key] ['receivablesPrice'] = $v ['receivablesPrice'];
  3659. $slist [$key] ['accountPrice'] = $v ['accountPrice'];
  3660. }
  3661. }
  3662. foreach ( $ISAS as $e => $a ) {
  3663. if ($value ['sid'] == $a ['staff']) {
  3664. $slist [$key] ['invoiceAllPrice'] = $a ['invoicePrice'];
  3665. $slist [$key] ['receivablesAllPrice'] = $a ['receivablesPrice'];
  3666. $slist [$key] ['accountAllPrice'] = $a ['accountPrice'];
  3667. }
  3668. }
  3669. if (isset ( $scheduleStaff [$value ['sid']] ))
  3670. $slist [$key] ['schedule'] = $scheduleStaff [$value ['sid']];
  3671. }
  3672. $this->data ['cidKey'] = $cidKey;
  3673. $schedule = ( int ) ($schedule * 100);
  3674. $this->data ['slist'] = $slist;
  3675. $this->data ['isMC'] = $isMC;
  3676. $this->data ['schedule'] = $schedule;
  3677. $slist = json_encode ( $slist );
  3678. $isMC = json_encode ( $isMC );
  3679. $schedule = json_encode ( $schedule );
  3680. $redis->lpush ( $redisKey, $slist );
  3681. $redis->lpush ( $redisKey, $isMC );
  3682. $redis->lpush ( $redisKey, $schedule );
  3683. } else {
  3684. $this->data ['cidKey'] = $cidKey;
  3685. $this->data ['slist'] = json_decode ( $redisValue [2], true );
  3686. $this->data ['isMC'] = json_decode ( $redisValue [1], true );
  3687. $this->data ['schedule'] = json_decode ( $redisValue [0], true );
  3688. }
  3689. $this->data ['month'] = $month;
  3690. $this->data ['categoryList'] = $categoryList;
  3691. $this->data ['memu'] = "invoice";
  3692. $this->data ['staff'] = $this->staff;
  3693. $this->data ['receiptMemu'] = 'invoiceAggregateCategoryDetail';
  3694. $this->render ( "/admin/invoiceAggregateCategoryDetail", $this->data );
  3695. }
  3696. /**
  3697. * 办事处人员汇总详情
  3698. */
  3699. function invoiceAggregateStaffDetail() {
  3700. $sidKey = $this->get_args ( 'sidKey' ) ? $this->get_args ( 'sidKey' ) : '';
  3701. // $sidKey = isset ( $this->params ['sidKey'] ) ? $this->params ['sidKey'] : '';
  3702. Doo::loadClass ( 'XDeode' );
  3703. $XDeode = new XDeode ( 5 );
  3704. Doo::loadModel ( 'invoice' );
  3705. $invoice = new invoice ();
  3706. Doo::loadModel ( 'staff' );
  3707. $staff = new staff ();
  3708. Doo::loadModel ( "invoiceCategoryManage" );
  3709. $invoiceCategoryManage = new invoiceCategoryManage ();
  3710. $sid = $XDeode->decode ( $sidKey );
  3711. $imcStaff = $invoiceCategoryManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  3712. $cidList = array ();
  3713. foreach ( $imcStaff as $key => $value ) {
  3714. array_push ( $cidList, $value ['cid'] );
  3715. if (empty ( $cidKey ))
  3716. $cidKey = $XDeode->encode ( $value ['cid'] );
  3717. }
  3718. $cidString = implode ( ',', $cidList );
  3719. $staffList = $staff->getStaffInCid ( $cidString );
  3720. $staffDetail = $staff->getStaffBySid ( $sid );
  3721. $MebSea = $this->get_args ( 'MebSea' ) ? $this->get_args ( 'MebSea' ) : "";
  3722. $page_size = 18;
  3723. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  3724. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : 'All';
  3725. $BeginDate = date ( 'Y-m-01', strtotime ( date ( "Y-m-d" ) ) );
  3726. $endDate = date ( 'Y-m-d', strtotime ( "$BeginDate +1 month -1 day" ) );
  3727. $date = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : $BeginDate . " : " . $endDate;
  3728. $dateArr = explode ( ':', $date );
  3729. $D1 = '';
  3730. $D2 = '';
  3731. if (! empty ( $date )) {
  3732. $D1 = $dateArr [0] . " 00:00:00 ";
  3733. if (isset ( $dateArr [1] ))
  3734. $D2 = $dateArr [1] . " 23:59:59 ";
  3735. else
  3736. $D2 = $dateArr [0] . " 23:59:59 "; // date ( "Y-m-d" );
  3737. // $D2 = $dateArr [1];
  3738. }
  3739. $con = ' status=2 ';
  3740. if (! empty ( $D1 ) && ! empty ( $D2 ))
  3741. $con .= ' and printTime BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
  3742. if ($status == 'UNRECORD')
  3743. $con .= ' and printStatus=1 and untreadStatus=0';
  3744. elseif ($status == 'RECORD')
  3745. $con .= ' and printStatus=1 and untreadStatus=3';
  3746. elseif ($status == 'BOUNCED')
  3747. $con .= ' and untreadStatus=2';
  3748. elseif ($status == 'PARTRECORD')
  3749. $con .= ' and untreadStatus=0 and printStatus=1 and irid!=""';
  3750. elseif ($status == 'All') {
  3751. $con .= ' and ( untreadStatus=2 or untreadStatus=0 or untreadStatus=3 )';
  3752. }
  3753. $con .= ' and sid=' . $sid;
  3754. $get = "/" . $status . "?date=" . urlencode ( $date ) . "&MebSea=" . urlencode ( $MebSea ) . "&sidKey=" . urlencode ( $sidKey );
  3755. if (! empty ( $MebSea )) {
  3756. $con .= ' and ( invoiceTitle like "%' . $MebSea . '%" or invoiceCompany like "%' . $MebSea . '%" )';
  3757. }
  3758. $pageinfo ['page'] = array (
  3759. 'previous' => ''
  3760. );
  3761. $pageinfo = $this->get_page ( "CLD_invoice", $con, $page, $page_size, "invoiceAggregateStaffDetail", $get, "" );
  3762. $limit = $pageinfo ['lower'] . ',' . $page_size;
  3763. $list = $invoice->getInvoiceByUntreadStatusPage ( $limit, $con );
  3764. $this->data ['staffDetail'] = $staffDetail;
  3765. $this->data ['staffList'] = $staffList;
  3766. $this->data ['MebSeaEn'] = $MebSea;
  3767. $this->data ['MebSea'] = urlencode ( $MebSea );
  3768. $this->data ['date'] = $date;
  3769. $this->data ['page'] = $pageinfo;
  3770. $this->data ['get'] = $get;
  3771. $this->data ['list'] = $list;
  3772. $this->data ['status'] = $status;
  3773. $this->data ['sidKey'] = $sidKey;
  3774. $this->data ['memu'] = "invoice";
  3775. $this->data ['staff'] = $this->staff;
  3776. $this->data ['receiptMemu'] = 'invoiceAggregateCategoryDetail';
  3777. $this->render ( "/admin/invoiceAggregateStaffDetail", $this->data );
  3778. }
  3779. /**
  3780. * 办事处人员汇总收款情
  3781. */
  3782. function invoiceAggregateStaffReceivablesDetail() {
  3783. $sidKey = $this->get_args ( 'sidKey' ) ? $this->get_args ( 'sidKey' ) : '';
  3784. // include Doo::conf ()->BASE_PATH . 'diagnostic/debug.php';
  3785. Doo::loadModel ( 'invoiceReceivables' );
  3786. $invoiceReceivables = new invoiceReceivables ();
  3787. Doo::loadModel ( 'staff' );
  3788. $staff = new staff ();
  3789. Doo::loadModel ( "invoiceCategoryManage" );
  3790. $invoiceCategoryManage = new invoiceCategoryManage ();
  3791. Doo::loadClass ( 'XDeode' );
  3792. $XDeode = new XDeode ( 5 );
  3793. $sid = $XDeode->decode ( $sidKey );
  3794. $staffDetail = $staff->getStaffBySid ( $sid );
  3795. $imcStaff = $invoiceCategoryManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  3796. $cidList = array ();
  3797. foreach ( $imcStaff as $key => $value ) {
  3798. array_push ( $cidList, $value ['cid'] );
  3799. if (empty ( $cidKey ))
  3800. $cidKey = $XDeode->encode ( $value ['cid'] );
  3801. }
  3802. $cidString = implode ( ',', $cidList );
  3803. $staffList = $staff->getStaffInCid ( $cidString );
  3804. $MebSea = $this->get_args ( 'MebSea' ) ? $this->get_args ( 'MebSea' ) : "";
  3805. $timeType = $this->get_args ( 'timeType' ) ? $this->get_args ( 'timeType' ) : "CREATE";
  3806. $page_size = 10;
  3807. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  3808. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : 'All';
  3809. if ($timeType == "BINDOTP") {
  3810. $status = 'Credited';
  3811. }
  3812. $BeginDate = date ( 'Y-m-01', strtotime ( date ( "Y-m-d" ) ) );
  3813. $endDate = date ( 'Y-m-d', strtotime ( "$BeginDate +1 month -1 day" ) );
  3814. $date = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : $BeginDate . " : " . $endDate;
  3815. $dateArr = explode ( ':', $date );
  3816. $D1 = '';
  3817. $D2 = '';
  3818. if (! empty ( $date )) {
  3819. $D1 = $dateArr [0] . " 00:00:00 ";
  3820. if (isset ( $dateArr [1] ))
  3821. $D2 = $dateArr [1] . " 23:59:59 ";
  3822. else
  3823. $D2 = $dateArr [0] . " 23:59:59 "; // date ( "Y-m-d" );
  3824. }
  3825. $con = ' a.receivablesStaff like "%' . $staffDetail ['username'] . '%" ';
  3826. $descField = 'a.bindDate';
  3827. if ($timeType == 'CREATE')
  3828. $descField = 'a.date';
  3829. if (! empty ( $D1 ) && ! empty ( $D2 ))
  3830. $con .= ' and ' . $descField . ' BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
  3831. elseif (! empty ( $D1 ) && empty ( $D2 ))
  3832. $con .= ' and ' . $descField . ' like "%' . $D1 . '%" ';
  3833. if ($status == 'Unclaimed')
  3834. $con .= ' and a.bindStatus=0';
  3835. elseif ($status == 'Credited')
  3836. $con .= ' and a.bindStatus=1';
  3837. elseif ($status == 'Claim')
  3838. $con .= ' and a.bindStatus=0 and a.receivablesStaff="PUBLIC"';
  3839. elseif ($status == 'BBN')
  3840. $con .= ' and a.bindPrice>a.receivablesPrice';
  3841. $get = "/" . $status . "?date=" . urlencode ( $date ) . "&MebSea=" . urlencode ( $MebSea ) . "&sidKey=" . urlencode ( $sidKey );
  3842. if (! empty ( $MebSea )) {
  3843. $con .= ' and ( a.receivablesMessage like "%' . $MebSea . '%" or a.receivablesPrice like "%' . $MebSea . '%" )';
  3844. }
  3845. $pageinfo ['page'] = array (
  3846. 'previous' => ''
  3847. );
  3848. $sql = 'select group_concat(b.invoiceSerial) as invoiceSerial ,group_concat(b.iid) as invoiceId
  3849. from CLD_invoiceReceivables as a left join CLD_invoice as b on
  3850. find_in_set(b.iid,a.iidExtend) or a.iid=b.iid
  3851. where ' . $con . ' group by a.irid ';
  3852. $pageinfo = $this->getPageBySql ( $sql, $page, $page_size, "invoiceAggregateStaffReceivablesDetail", $get, "" );
  3853. $limit = $pageinfo ['lower'] . ',' . $page_size;
  3854. $list = $invoiceReceivables->getInvoiceReceivablesByConditionPage ( $limit, $con, 'desc', 'printTime' );
  3855. foreach ( $list as $key => $value ) {
  3856. $list [$key] ['category'] = '';
  3857. if ($value ['receivablesCategory'] != 'PUBLIC') {
  3858. $receivablesCategory = explode ( ":", $value ['receivablesCategory'] );
  3859. $list [$key] ['category'] = $receivablesCategory [1];
  3860. }
  3861. }
  3862. // print_r($list);
  3863. $this->data ['staffDetail'] = $staffDetail;
  3864. $this->data ['sidKey'] = $sidKey;
  3865. $this->data ['staffList'] = $staffList;
  3866. $this->data ['timeType'] = $timeType;
  3867. $this->data ['MebSeaEn'] = $MebSea;
  3868. $this->data ['MebSea'] = urlencode ( $MebSea );
  3869. $this->data ['date'] = $date;
  3870. $this->data ['page'] = $pageinfo;
  3871. $this->data ['get'] = $get;
  3872. $this->data ['list'] = $list;
  3873. $this->data ['status'] = $status;
  3874. $this->data ['memu'] = "invoice";
  3875. $this->data ['staff'] = $this->staff;
  3876. $this->data ['receiptMemu'] = 'invoiceAggregateCategoryDetail';
  3877. $this->render ( "/admin/invoiceAggregateStaffReceivablesDetail", $this->data );
  3878. }
  3879. function invoiceAchieve() {
  3880. Doo::loadModel ( 'invoice' );
  3881. $invoice = new invoice ();
  3882. Doo::loadClass ( 'XDeode' );
  3883. $XDeode = new XDeode ( 5 );
  3884. $sid = $XDeode->decode ( $_COOKIE ["staff"] );
  3885. $MebSea = isset ( $this->params ['MebSea'] ) ? urldecode ( $this->params ['MebSea'] ) : '';
  3886. $page_size = 18;
  3887. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  3888. $date = isset ( $this->params ['date'] ) ? $this->params ['date'] : 'MONTHO';
  3889. $get = "/" . $date;
  3890. $con = '';
  3891. if ($date == 'MONTHO')
  3892. $con = ' and updateTime>DATE_SUB(CURDATE(), INTERVAL 1 MONTH)';
  3893. elseif ($date == 'MONTHT')
  3894. $con = ' and updateTime>DATE_SUB(CURDATE(), INTERVAL 3 MONTH)';
  3895. elseif ($date == 'MONTHY')
  3896. $con = ' and updateTime>DATE_SUB(CURDATE(), INTERVAL 1 YEAR)';
  3897. if (! empty ( $MebSea )) {
  3898. $con .= ' and ( invoiceTitle like "%' . $MebSea . '%" or invoiceCompany like "%' . $MebSea . '%" or invoicePrice like "%' . $MebSea . '%" )';
  3899. $get .= "/" . $MebSea;
  3900. }
  3901. $pageinfo ['page'] = array (
  3902. 'previous' => ''
  3903. );
  3904. $sql = 'status=2 and printStatus=1 and irid!="" and ( untreadStatus=3 or untreadStatus=0 ) and sid=' . $sid . $con;
  3905. $pageinfo = $this->get_page ( "CLD_invoice", $sql, $page, $page_size, "invoiceAchieve", $get, "" );
  3906. $limit = $pageinfo ['lower'] . ',' . $page_size;
  3907. $list = $invoice->getInvoiceByUntreadStatusPage ( $limit, $sql );
  3908. // print_r($pageinfo);
  3909. $this->data ['MebSeaEn'] = $MebSea;
  3910. $this->data ['MebSea'] = urlencode ( $MebSea );
  3911. $this->data ['get'] = $get;
  3912. $this->data ['page'] = $pageinfo;
  3913. $this->data ['list'] = $list;
  3914. $this->data ['date'] = $date;
  3915. $this->data ['memu'] = "invoice";
  3916. $this->data ['staff'] = $this->staff;
  3917. $this->data ['receiptMemu'] = 'invoice';
  3918. $this->render ( "/admin/invoiceAchieve", $this->data );
  3919. }
  3920. function invoiceMyUnAccountAchieve() {
  3921. Doo::loadModel ( 'invoice' );
  3922. $invoice = new invoice ();
  3923. Doo::loadClass ( 'XDeode' );
  3924. $XDeode = new XDeode ( 5 );
  3925. Doo::loadModel ( 'staff' );
  3926. $staff = new staff ();
  3927. $sid = $XDeode->decode ( $_COOKIE ["staff"] );
  3928. $MebSea = $this->get_args ( 'MebSea' ) ? $this->get_args ( 'MebSea' ) : "";
  3929. $page_size = 18;
  3930. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  3931. $date = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "";
  3932. $get = "?date=" . urlencode ( $date ) . "&MebSea=" . urlencode ( $MebSea );
  3933. $dateArr = explode ( ':', $date );
  3934. $D1 = '';
  3935. $D2 = '';
  3936. if (! empty ( $date )) {
  3937. $D1 = $dateArr [0];
  3938. $D2 = $dateArr [1];
  3939. }
  3940. $con = '';
  3941. if (! empty ( $D1 ) && ! empty ( $D2 ))
  3942. $con = ' and printTime BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
  3943. if (! empty ( $MebSea )) {
  3944. $con .= ' and ( invoiceTitle like "%' . $MebSea . '%" or invoiceCompany like "%' . $MebSea . '%" or invoicePrice like "%' . $MebSea . '%" )';
  3945. }
  3946. $pageinfo ['page'] = array (
  3947. 'previous' => ''
  3948. );
  3949. // and irid='' and ( (doPost=1 and postStatus=1) or doPost=0 )
  3950. $sql = " status=2 and printStatus=1 and untreadStatus=0 and isDelete=0 and sid= " . $sid . $con;
  3951. $action = "invoiceMyUnAccountAchieve";
  3952. $pageinfo = $this->get_page ( "CLD_invoice", $sql, $page, $page_size, $action, $get, "" );
  3953. $limit = $pageinfo ['lower'] . ',' . $page_size;
  3954. $list = $invoice->getInvoiceByUntreadStatusPage ( $limit, $sql );
  3955. Doo::loadModel ( 'express' );
  3956. $express = new express ();
  3957. $expressList = $express->getExpressByAll ();
  3958. $this->data ['expressList'] = $expressList;
  3959. // print_r($list);
  3960. $this->data ['MebSeaEn'] = $MebSea;
  3961. $this->data ['get'] = $get;
  3962. $this->data ['page'] = $pageinfo;
  3963. $this->data ['date'] = $date;
  3964. $this->data ['list'] = $list;
  3965. $this->data ['memu'] = "invoice";
  3966. $this->data ['staff'] = $this->staff;
  3967. $this->data ['receiptMemu'] = 'invoice';
  3968. $this->render ( "/admin/invoiceMyUnAccountAchieve", $this->data );
  3969. }
  3970. function invoiceReceivablesAchieve() {
  3971. Doo::loadModel ( 'invoiceReceivables' );
  3972. $invoiceReceivables = new invoiceReceivables ();
  3973. Doo::loadClass ( 'XDeode' );
  3974. $XDeode = new XDeode ( 5 );
  3975. $sid = $XDeode->decode ( $_COOKIE ["staff"] );
  3976. $MebSea = isset ( $this->params ['MebSea'] ) ? urldecode ( $this->params ['MebSea'] ) : '';
  3977. $page_size = 12;
  3978. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  3979. $date = isset ( $this->params ['date'] ) ? $this->params ['date'] : 'MONTHO';
  3980. $get = "/" . $date;
  3981. $con = '';
  3982. if ($date == 'MONTHO')
  3983. $con = ' and bindDate>DATE_SUB(CURDATE(), INTERVAL 1 MONTH)';
  3984. elseif ($date == 'MONTHT')
  3985. $con = ' and bindDate>DATE_SUB(CURDATE(), INTERVAL 3 MONTH)';
  3986. elseif ($date == 'MONTHY')
  3987. $con = ' and bindDate>DATE_SUB(CURDATE(), INTERVAL 1 YEAR)';
  3988. if (! empty ( $MebSea )) {
  3989. $con .= ' and ( receivablesMessage like "%' . $MebSea . '%" or receivablesPrice like "%' . $MebSea . '%" )';
  3990. $get .= "/" . $MebSea;
  3991. }
  3992. $pageinfo ['page'] = array (
  3993. 'previous' => ''
  3994. );
  3995. $sql = " bindStatus=1 and receivablesStaff like '" . $sid . "_%' " . $con;
  3996. $pageinfo = $this->get_page ( "CLD_invoiceReceivables", $sql, $page, $page_size, "invoiceReceivablesAchieve", $get, "" );
  3997. $limit = $pageinfo ['lower'] . ',' . $page_size;
  3998. $list = $invoiceReceivables->getReceivablesByUntreadStatusPage ( $limit, $sql );
  3999. // print_r($pageinfo);
  4000. $this->data ['MebSeaEn'] = $MebSea;
  4001. $this->data ['MebSea'] = urlencode ( $MebSea );
  4002. $this->data ['get'] = $get;
  4003. $this->data ['page'] = $pageinfo;
  4004. $this->data ['list'] = $list;
  4005. $this->data ['date'] = $date;
  4006. $this->data ['memu'] = "invoice";
  4007. $this->data ['staff'] = $this->staff;
  4008. $this->data ['receiptMemu'] = 'invoiceMyReceivables';
  4009. $this->render ( "/admin/invoiceReceivablesAchieve", $this->data );
  4010. }
  4011. /**
  4012. * 收款解绑
  4013. */
  4014. function invoiceUnBundLing() {
  4015. $unBundKey = $this->get_args ( 'unBundKey' ) ? $this->get_args ( 'unBundKey' ) : '';
  4016. $iidKey = $this->get_args ( 'iidKey' ) ? $this->get_args ( 'iidKey' ) : '';
  4017. Doo::loadModel ( 'invoice' );
  4018. $invoice = new invoice ();
  4019. Doo::loadModel ( 'invoiceReceivables' );
  4020. $invoiceReceivables = new invoiceReceivables ();
  4021. Doo::loadModel ( 'invoiceOperationLog' );
  4022. $invoiceOperationLog = new invoiceOperationLog ();
  4023. Doo::loadModel ( 'invoiceROLog' );
  4024. $invoiceROLog = new invoiceROLog ();
  4025. Doo::loadModel ( 'invoiceStatistics' );
  4026. Doo::loadClass ( 'XDeode' );
  4027. $XDeode = new XDeode ( 5 );
  4028. if (empty ( $iidKey ))
  4029. die ( 'illegal request' );
  4030. $iid = $XDeode->decode ( $iidKey );
  4031. $irid = $invoice->authcode ( $unBundKey );
  4032. if ((! empty ( $irid ) && ! is_numeric ( $irid )) || (! empty ( $iid ) && ! is_numeric ( $iid )))
  4033. die ( 'illegal request' );
  4034. $irDetails = $invoiceReceivables->getInvoiceReceivablesByIrid ( $irid );
  4035. $invoiceDetails = $invoice->getInvoiceByIid ( $iid );
  4036. if (empty ( $irDetails ) || empty ( $invoiceDetails ) || (empty ( $irDetails ['iid'] ) && empty ( $irDetails ['iidExtend'] )) || $invoiceDetails ['untreadStatus'] == 2)
  4037. die ( 'illegal request' );
  4038. // 收款
  4039. $item = array (
  4040. 'irid' => $irDetails ['irid'],
  4041. 'bindPrice' => $irDetails ['bindPrice'] - $invoiceDetails ['invoicePrice'],
  4042. 'bindStatus' => 0
  4043. );
  4044. if ($irDetails ['iid'] == $iid)
  4045. $item += array (
  4046. 'iid' => 0
  4047. );
  4048. else {
  4049. $iidExtend = explode ( ',', $irDetails ['iidExtend'] );
  4050. foreach ( $iidExtend as $key => $value ) {
  4051. if ($value == $iid)
  4052. unset ( $iidExtend [$key] );
  4053. }
  4054. $iidExtend = implode ( ',', $iidExtend );
  4055. $item += array (
  4056. 'iidExtend' => $iidExtend
  4057. );
  4058. }
  4059. $invoiceReceivables->setInvoiceReceivablesByCondition ( $item );
  4060. // 收款操作日志
  4061. $item = array (
  4062. 'operation' => $this->staff [0] ['username'] . " 解绑 " . $irDetails ['receivablesSerial'],
  4063. 'date' => date ( "Y-m-d" ),
  4064. 'status' => 3,
  4065. 'img' => $this->staff [0] ['avatar'],
  4066. 'username' => $this->staff [0] ['username'],
  4067. 'uid' => $this->staff [0] ['sid'],
  4068. 'category' => $this->staff [0] ['category'],
  4069. 'irid' => $irid
  4070. );
  4071. $invoiceROLog->setInvoiceROLog ( $item );
  4072. // 扣除入账统计金额
  4073. $invoiceStatistics = new invoiceStatistics ();
  4074. $item = array (
  4075. 'date' => date ( 'Y-m-d', strtotime ( $irDetails ['receivablesDate'] ) ),
  4076. 'priceClass' => 3,
  4077. 'cid' => $invoiceDetails ['cid'],
  4078. 'staff' => $invoiceDetails ['sid'],
  4079. 'accountPrice' => - $irDetails ['receivablesPrice']
  4080. );
  4081. $invoiceStatistics->setInvoiceStatisticsByCondition ( $item );
  4082. // 扣除收款统计金额
  4083. $invoiceStatistics = new invoiceStatistics ();
  4084. $item = array (
  4085. 'date' => date ( 'Y-m-d', strtotime ( $irDetails ['receivablesDate'] ) ),
  4086. 'priceClass' => 2,
  4087. 'cid' => $invoiceDetails ['cid'],
  4088. 'staff' => $invoiceDetails ['sid'],
  4089. 'irid' => $irDetails ['irid'],
  4090. 'receivablesPrice' => - $irDetails ['receivablesPrice']
  4091. );
  4092. $invoiceStatistics->setInvoiceStatisticsByCondition ( $item );
  4093. // 发票解绑去收款ID
  4094. $iridString = $invoiceDetails ['irid'];
  4095. if (! empty ( $invoiceDetails ['irid'] )) {
  4096. $list = explode ( ',', $invoiceDetails ['irid'] );
  4097. foreach ( $list as $key => $value ) {
  4098. if ($value == $irDetails ['irid']) {
  4099. unset ( $list [$key] );
  4100. break;
  4101. }
  4102. }
  4103. $iridString = implode ( ",", $list );
  4104. }
  4105. $item = array (
  4106. 'iid' => $invoiceDetails ['iid'],
  4107. 'irid' => $iridString,
  4108. 'updateTime' => date ( "Y-m-d H:i:s" )
  4109. );
  4110. if ($invoiceDetails ['untreadStatus'] == 3)
  4111. $item += array (
  4112. 'untreadStatus' => 0
  4113. );
  4114. $invoice->setInvoiceByCondition ( $item );
  4115. $item = array (
  4116. 'date' => date ( "Y-m-d H:i:s" ),
  4117. 'operation' => '解绑 收款 ' . $irDetails ['receivablesSerial'],
  4118. 'status' => 11,
  4119. 'img' => $this->staff [0] ['avatar'],
  4120. 'username' => $this->staff [0] ['username'],
  4121. 'uid' => $this->staff [0] ['sid'],
  4122. 'category' => $this->staff [0] ['category'],
  4123. 'iid' => $invoiceDetails ['iid']
  4124. );
  4125. $invoiceOperationLog->setInvoiceOperationLog ( $item );
  4126. return "/invoiceReceivablesAS";
  4127. }
  4128. /**
  4129. * 或者该收款下的所以发票
  4130. */
  4131. function ajaxGetInvoiceReceivablesByInvoice() {
  4132. $irid = $this->get_args ( 'postData' ) ? $this->get_args ( 'postData' ) : '';
  4133. Doo::loadModel ( 'invoice' );
  4134. $invoice = new invoice ();
  4135. Doo::loadModel ( 'invoiceReceivables' );
  4136. $invoiceReceivables = new invoiceReceivables ();
  4137. $irid = $invoice->authcode ( $irid );
  4138. if (! empty ( $irid ) && ! is_numeric ( $irid ))
  4139. die ( 'illegal request' );
  4140. $irDetails = $invoiceReceivables->getInvoiceReceivablesByIrid ( $irid );
  4141. $iidString = $irDetails ['iid'];
  4142. $iidExtend = array_filter ( explode ( ',', $irDetails ['iidExtend'] ) );
  4143. if (! empty ( $irDetails ['iidExtend'] ))
  4144. $iidString .= ',' . implode ( ',', $iidExtend );
  4145. $invoiceList = $invoice->getInvoiceInIid ( $iidString, 'iid,invoiceSerial,invoicePrice,invoiceTitle,invoiceCompany,invoiceElement' );
  4146. $html = "";
  4147. foreach ( $invoiceList as $key => $value ) {
  4148. $title = $value ['invoiceTitle'];
  4149. if (! empty ( $value ['invoiceCompany'] ))
  4150. $title = $value ['invoiceCompany'];
  4151. $html .= '<tr><td>' . $value ['invoiceSerial'] . '</td><td>¥' . $value ['invoicePrice'] . '</td><td>' . $title . '</td><td>' . $value ['invoiceElement'] . '</td><td><input type="radio" name="iidKey" value="' . $value ['iidKey'] . '"></td></tr>';
  4152. }
  4153. echo json_encode ( array (
  4154. 'status' => 1,
  4155. 'html' => $html
  4156. ) );
  4157. }
  4158. /**
  4159. * 发票管理
  4160. */
  4161. function invoiceAS() {
  4162. Doo::loadModel ( 'invoice' );
  4163. $invoice = new invoice ();
  4164. Doo::loadModel ( 'invoiceReceivables' );
  4165. $invoiceReceivables = new invoiceReceivables ();
  4166. $MebSea = $this->get_args ( 'MebSea' ) ? $this->get_args ( 'MebSea' ) : "";
  4167. $page_size = 18;
  4168. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  4169. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : 'All';
  4170. $date = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "";
  4171. $dateArr = explode ( ':', $date );
  4172. $D1 = '';
  4173. $D2 = '';
  4174. if (! empty ( $date )) {
  4175. $D1 = $dateArr [0] . " 00:00:00 ";
  4176. if (isset ( $dateArr [1] ))
  4177. $D2 = $dateArr [1] . " 23:59:59 ";
  4178. else
  4179. $D2 = $dateArr [0] . " 23:59:59 "; // date ( "Y-m-d" );
  4180. // $D2 = $dateArr [1];
  4181. }
  4182. $con = ' status=2 ';
  4183. if (! empty ( $D1 ) && ! empty ( $D2 ))
  4184. $con .= ' and printTime BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
  4185. if ($status == 'UNRECORD')
  4186. $con .= ' and printStatus=1 and untreadStatus=0';
  4187. elseif ($status == 'RECORD')
  4188. $con .= ' and printStatus=1 and untreadStatus=3';
  4189. elseif ($status == 'BOUNCED')
  4190. $con .= ' and untreadStatus=2';
  4191. elseif ($status == 'PARTRECORD')
  4192. $con .= ' and untreadStatus=0 and printStatus=1 and irid!=""';
  4193. elseif ($status == 'All') {
  4194. $con .= ' and ( untreadStatus=2 or untreadStatus=0 or untreadStatus=3 )';
  4195. }
  4196. $get = "/" . $status . "?date=" . urlencode ( $date ) . "&MebSea=" . urlencode ( $MebSea );
  4197. if (! empty ( $MebSea )) {
  4198. $con .= ' and ( invoiceTitle like "%' . $MebSea . '%" or invoiceCompany like "%' . $MebSea . '%" or invoiceNo like "%' . $MebSea . '%" )';
  4199. }
  4200. $pageinfo ['page'] = array (
  4201. 'previous' => ''
  4202. );
  4203. $pageinfo = $this->get_page ( "CLD_invoice", $con, $page, $page_size, "invoiceAS", $get, "" );
  4204. $limit = $pageinfo ['lower'] . ',' . $page_size;
  4205. $list = $invoice->getInvoiceByUntreadStatusPage ( $limit, $con );
  4206. $this->data ['MebSeaEn'] = $MebSea;
  4207. $this->data ['MebSea'] = urlencode ( $MebSea );
  4208. $this->data ['date'] = $date;
  4209. $this->data ['page'] = $pageinfo;
  4210. $this->data ['get'] = $get;
  4211. $this->data ['list'] = $list;
  4212. $this->data ['status'] = $status;
  4213. $this->data ['memu'] = "invoice";
  4214. $this->data ['staff'] = $this->staff;
  4215. $this->data ['receiptMemu'] = 'invoiceReceivables';
  4216. $this->render ( "/admin/invoiceAS", $this->data );
  4217. }
  4218. /**
  4219. * 收款管理
  4220. */
  4221. function invoiceReceivablesAS() {
  4222. Doo::loadModel ( 'invoiceReceivables' );
  4223. $invoiceReceivables = new invoiceReceivables ();
  4224. Doo::loadModel ( 'L_category' );
  4225. $lCategory = new L_category ();
  4226. $category = $lCategory->getCategory ();
  4227. $MebSea = $this->get_args ( 'MebSea' ) ? $this->get_args ( 'MebSea' ) : "";
  4228. $timeType = $this->get_args ( 'timeType' ) ? $this->get_args ( 'timeType' ) : "CREATE";
  4229. $page_size = 10;
  4230. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  4231. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : 'All';
  4232. $date = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "";
  4233. $dateArr = explode ( ':', $date );
  4234. $D1 = '';
  4235. $D2 = '';
  4236. if (! empty ( $date )) {
  4237. $D1 = $dateArr [0]; // ." 00:00:00 ";
  4238. if (isset ( $dateArr [1] ))
  4239. $D2 = $dateArr [1]; // ." 23:59:59 ";
  4240. else
  4241. $D2 = $dateArr [0]; // ." 23:59:59 ";//date ( "Y-m-d" );
  4242. }
  4243. $descField = 'a.receivablesDate';
  4244. if ($timeType == 'CREATE')
  4245. $descField = 'a.date';
  4246. $con = '1';
  4247. if (! empty ( $D1 ) && ! empty ( $D2 ))
  4248. $con .= ' and ' . $descField . ' BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
  4249. elseif (! empty ( $D1 ) && empty ( $D2 ))
  4250. $con .= ' and ' . $descField . ' like "%' . $D1 . '%" ';
  4251. if ($status == 'Unclaimed')
  4252. $con .= ' and a.bindStatus=0';
  4253. elseif ($status == 'Credited')
  4254. $con .= ' and a.bindStatus=1';
  4255. elseif ($status == 'Claim')
  4256. $con .= ' and a.bindStatus=0 and a.receivablesStaff="PUBLIC"';
  4257. elseif ($status == 'BBN')
  4258. $con .= ' and a.bankBatchNumber!=""';
  4259. elseif ($status == 'REFUND')
  4260. $con .= ' and ( (a.bindStatus=0 and a.refundLog!="" ) or a.bindStatus=2)';
  4261. $get = "/" . $status . "?date=" . urlencode ( $date ) . "&MebSea=" . urlencode ( $MebSea );
  4262. if (! empty ( $MebSea )) {
  4263. $con .= ' and ( a.receivablesMessage like "%' . $MebSea . '%" or a.receivablesPrice like "%' . $MebSea . '%" )';
  4264. }
  4265. $pageinfo ['page'] = array (
  4266. 'previous' => ''
  4267. );
  4268. $sql = 'select group_concat(b.invoiceSerial) as invoiceSerial ,group_concat(b.iid) as invoiceId
  4269. from CLD_invoiceReceivables as a left join CLD_invoice as b on
  4270. find_in_set(b.iid,a.iidExtend) or a.iid=b.iid
  4271. where ' . $con . ' group by a.irid ';
  4272. $pageinfo = $this->getPageBySql ( $sql, $page, $page_size, "invoiceReceivablesAS", $get, "" );
  4273. $limit = $pageinfo ['lower'] . ',' . $page_size;
  4274. $list = $invoiceReceivables->getInvoiceReceivablesByConditionPage ( $limit, $con, 'desc', $descField );
  4275. foreach ( $list as $key => $value ) {
  4276. $list [$key] ['category'] = '';
  4277. if ($value ['receivablesCategory'] != 'PUBLIC') {
  4278. $receivablesCategory = explode ( ":", $value ['receivablesCategory'] );
  4279. $list [$key] ['category'] = $receivablesCategory [1];
  4280. }
  4281. }
  4282. // print_r($list);
  4283. $this->data ['category'] = $category;
  4284. $this->data ['timeType'] = $timeType;
  4285. $this->data ['MebSeaEn'] = $MebSea;
  4286. $this->data ['MebSea'] = urlencode ( $MebSea );
  4287. $this->data ['date'] = $date;
  4288. $this->data ['page'] = $pageinfo;
  4289. $this->data ['get'] = $get;
  4290. $this->data ['list'] = $list;
  4291. $this->data ['status'] = $status;
  4292. $this->data ['memu'] = "invoice";
  4293. $this->data ['staff'] = $this->staff;
  4294. $this->data ['receiptMemu'] = 'invoiceReceivables';
  4295. $this->render ( "/admin/invoiceReceivablesAS", $this->data );
  4296. }
  4297. /**
  4298. * 删除一条收款
  4299. */
  4300. function delInvoiceReceivables() {
  4301. $iridKey = $this->get_args ( 'iridKey' ) ? $this->get_args ( 'iridKey' ) : "";
  4302. if (empty ( $iridKey ))
  4303. die ( 'illegal request' );
  4304. Doo::loadClass ( 'XDeode' );
  4305. $XDeode = new XDeode ( 5 );
  4306. $irid = $XDeode->decode ( $iridKey );
  4307. Doo::loadModel ( 'invoiceReceivables' );
  4308. $invoiceReceivables = new invoiceReceivables ();
  4309. $detail = $invoiceReceivables->getInvoiceReceivablesByIrid ( $irid );
  4310. if (empty ( $detail ))
  4311. die ( 'illegal request' );
  4312. $invoiceReceivables->delInvoiceReceivablesByIrid ( $detail ['irid'] );
  4313. //扣除收款汇总信息 汇总
  4314. Doo::loadModel ( 'invoiceStatistics' );
  4315. $invoiceStatistics = new invoiceStatistics ();
  4316. $item = array (
  4317. 'date' => $detail['receivablesDate'],
  4318. 'priceClass' => 2,
  4319. 'irid' => $detail['irid'],
  4320. 'receivablesPrice' => -$detail['receivablesPrice']
  4321. );
  4322. if ($detail['receivablesCategory'] != 'PUBLIC') {
  4323. $receivablesCategory = explode ( ":", $detail['receivablesCategory'] );
  4324. $item += array (
  4325. 'cid' => $receivablesCategory [0]
  4326. );
  4327. }
  4328. if ($detail['receivablesStaff'] != 'PUBLIC') {
  4329. $receivablesStaff = explode ( "-", $detail['receivablesStaff'] );
  4330. $item += array (
  4331. 'staff' => $receivablesStaff [0]
  4332. );
  4333. }
  4334. $invoiceStatistics->setInvoiceStatisticsByCondition ( $item );
  4335. return '/invoiceReceivablesAS';
  4336. }
  4337. /**
  4338. * 添加退款信息
  4339. */
  4340. function setInvoiceReceivablesRefund() {
  4341. $iridKey = $this->get_args ( 'iridKey' ) ? $this->get_args ( 'iridKey' ) : '';
  4342. $refundType = $this->get_args ( 'refundType' ) && is_numeric ( $this->get_args ( 'refundType' ) ) ? $this->get_args ( 'refundType' ) : '0';
  4343. $refundCompany = $this->get_args ( 'refundCompany' ) ? $this->get_args ( 'refundCompany' ) : "";
  4344. $refundNumber = $this->get_args ( 'refundNumber' ) ? $this->get_args ( 'refundNumber' ) : "";
  4345. $refundPrice = $this->get_args ( 'refundPrice' ) ? $this->get_args ( 'refundPrice' ) : "";
  4346. if($refundPrice<0)
  4347. die ( 'illegal request' );
  4348. if (! empty ( $iridKey ) && ! empty ( $refundCompany ) && ! empty ( $refundNumber ) && ! empty ( $refundPrice )) {
  4349. Doo::loadModel ( 'invoiceReceivables' );
  4350. $invoiceReceivables = new invoiceReceivables ();
  4351. Doo::loadModel ( 'invoiceRefund' );
  4352. $invoiceRefund = new invoiceRefund ();
  4353. $irid = $invoiceReceivables->authcode ( $iridKey );
  4354. $irDetail = $invoiceReceivables->getInvoiceReceivablesByIrid ( $irid );
  4355. $invoiceReceivables = new invoiceReceivables ();
  4356. $refundLog = $this->staff [0] ['username'] . ' 退款 <b class="colRed">¥' . $refundPrice . '</b>
  4357. <br/><a href="#refunded" onclick="getRefundByDetail(\'' . $iridKey . '\')" data-toggle="modal">退款信息</a> <br/>' . date ( "Y-m-d H:i:s" ) . '
  4358. ';
  4359. $item = array (
  4360. 'irid' => $irid,
  4361. 'refundCompany' => $refundCompany,
  4362. 'refundNumber' => $refundNumber,
  4363. 'refundPrice' => $refundPrice,
  4364. 'refundLog' => $refundLog
  4365. );
  4366. if ($refundType == 1) {
  4367. $item += array (
  4368. 'refundType' => $refundType,
  4369. 'receivablesPrice' => $refundPrice,
  4370. 'bindStatus' => 2
  4371. );
  4372. } elseif ($refundType == 0 && $irDetail ['receivablesPrice'] <= $refundPrice) {
  4373. $item += array (
  4374. 'refundType' => 1,
  4375. 'receivablesPrice' => $irDetail ['receivablesPrice'] -$refundPrice,
  4376. 'bindStatus' => 2
  4377. );
  4378. } else {
  4379. $item += array (
  4380. 'refundType' => $refundType,
  4381. 'receivablesPrice' => $irDetail ['receivablesPrice'] - $refundPrice
  4382. );
  4383. }
  4384. $invoiceReceivables->setInvoiceReceivablesByCondition ( $item );
  4385. // 添加退款记录
  4386. $item = array (
  4387. 'irid' => $irid,
  4388. 'refundType' => $refundType,
  4389. 'refundCompany' => $refundCompany,
  4390. 'refundNumber' => $refundNumber,
  4391. 'refundPrice' => $refundPrice,
  4392. 'refundLog' => $refundLog,
  4393. 'date' => date ( "Y-m-d H:i:s" )
  4394. );
  4395. $invoiceRefund->addInvoiceRefund ( $item );
  4396. //扣除收款汇总信息 汇总
  4397. Doo::loadModel ( 'invoiceStatistics' );
  4398. $invoiceStatistics = new invoiceStatistics ();
  4399. $item = array (
  4400. 'date' => $irDetail['receivablesDate'],
  4401. 'priceClass' => 2,
  4402. 'irid' => $irDetail['irid'],
  4403. 'receivablesPrice' => -$refundPrice
  4404. );
  4405. if ($irDetail['receivablesCategory'] != 'PUBLIC') {
  4406. $receivablesCategory = explode ( ":", $irDetail['receivablesCategory'] );
  4407. $item += array (
  4408. 'cid' => $receivablesCategory [0]
  4409. );
  4410. }
  4411. if ($irDetail['receivablesStaff'] != 'PUBLIC') {
  4412. $receivablesStaff = explode ( "-", $irDetail['receivablesStaff'] );
  4413. $item += array (
  4414. 'staff' => $receivablesStaff [0]
  4415. );
  4416. }
  4417. $invoiceStatistics->setInvoiceStatisticsByCondition ( $item );
  4418. return '/invoiceReceivablesAS';
  4419. }
  4420. die ( 'illegal request' );
  4421. }
  4422. /**
  4423. * 获得收款退款信息
  4424. */
  4425. function getRefundByDetail() {
  4426. $iridKey = $this->get_args ( 'iridKey' ) ? $this->get_args ( 'iridKey' ) : '';
  4427. Doo::loadModel ( 'invoiceReceivables' );
  4428. $invoiceReceivables = new invoiceReceivables ();
  4429. if (! empty ( $iridKey )) {
  4430. $irid = $invoiceReceivables->authcode ( $iridKey );
  4431. $irDetail = $invoiceReceivables->getInvoiceReceivablesByIrid ( $irid );
  4432. echo json_encode ( array (
  4433. 'status' => 1,
  4434. 'irDetail' => $irDetail
  4435. ) );
  4436. die ();
  4437. }
  4438. echo json_encode ( array (
  4439. 'status' => 2
  4440. ) );
  4441. }
  4442. /**
  4443. * 根据收款序列号获得收款退款信息
  4444. */
  4445. function ajaxGetInvoiceReceivablesBySerial() {
  4446. $receivablesSerial = $this->get_args ( 'receivablesSerial' ) ? $this->get_args ( 'receivablesSerial' ) : '';
  4447. if (! empty ( $receivablesSerial )) {
  4448. Doo::loadModel ( 'invoiceReceivables' );
  4449. $invoiceReceivables = new invoiceReceivables ();
  4450. $irDetail = $invoiceReceivables->getInvoiceReceivablesBySerial ( $receivablesSerial, ' and refundLog=""' );
  4451. $html = '';
  4452. if (! empty ( $irDetail ))
  4453. $html = '<td><b>¥' . $irDetail ['receivablesPrice'] . '</b></td>
  4454. <td>' . $irDetail ['receivablesMessage'] . '</td>
  4455. <td>' . $irDetail ['receivablesBank'] . '<br>' . $irDetail ['receivablesDate'] . '</td>
  4456. <td>' . $irDetail ['title'] . '-' . $irDetail ['username'] . '<br>' . $irDetail ['confirmTime'] . '</td>
  4457. <td>' . $irDetail ['recepitTitleMark'] . '
  4458. <input type="hidden" name="iridKey" id="iridKey" value="' . $irDetail ['iridKey'] . '">
  4459. </td>';
  4460. echo json_encode ( array (
  4461. 'status' => 1,
  4462. 'html' => $html,
  4463. 'irDetail' => $irDetail
  4464. ) );
  4465. die ();
  4466. }
  4467. echo json_encode ( array (
  4468. 'status' => 2
  4469. ) );
  4470. }
  4471. /**
  4472. * 绑定新收款
  4473. */
  4474. function relationNewInvoiceReceivables() {
  4475. $iridKeyOld = $this->get_args ( 'iridKeyOld' ) ? $this->get_args ( 'iridKeyOld' ) : '';
  4476. $iridKey = $this->get_args ( 'iridKey' ) ? $this->get_args ( 'iridKey' ) : '';
  4477. if (! empty ( $iridKeyOld ) && ! empty ( $iridKey )) {
  4478. Doo::loadModel ( 'invoiceReceivables' );
  4479. $invoiceReceivables = new invoiceReceivables ();
  4480. Doo::loadClass ( 'XDeode' );
  4481. $XDeode = new XDeode ( 5 );
  4482. $irid = $XDeode->decode ( $iridKey );
  4483. $iridOld = $invoiceReceivables->authcode ( $iridKeyOld );
  4484. echo $irid . 'bbb' . $iridOld;
  4485. $oldIrDetail = $invoiceReceivables->getInvoiceReceivablesByIrid ( $iridOld );
  4486. $IrDetail = $invoiceReceivables->getInvoiceReceivablesByIrid ( $irid );
  4487. if (empty ( $oldIrDetail ) || empty ( $IrDetail ))
  4488. die ( 'illegal request' );
  4489. $relationLog = $this->staff [0] ['username'] . ' 关联新款 <a href="#billing" onclick="invoiceReceivblesDivShow(\'' . $iridKey . '\',\'receivables\')" data-toggle="modal">' . $IrDetail ['receivablesSerial'] . '</a>
  4490. <br/>' . date ( "Y-m-d H:i:s" ) . '
  4491. ';
  4492. $invoiceReceivables = new invoiceReceivables ();
  4493. $item = array (
  4494. 'irid' => $iridOld,
  4495. 'relationIrid' => $irid,
  4496. 'relationLog' => $relationLog
  4497. );
  4498. $invoiceReceivables->setInvoiceReceivablesByCondition ( $item );
  4499. return '/invoiceReceivablesAS';
  4500. }
  4501. die ( 'illegal request' );
  4502. }
  4503. // function invoiceApprovalAchieve() {
  4504. // Doo::loadModel ( 'invoice' );
  4505. // $invoice = new invoice ();
  4506. // $MebSea = isset ( $this->params ['MebSea'] ) ? urldecode ( $this->params ['MebSea'] ) : '';
  4507. // $page_size = 12;
  4508. // $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  4509. // $date = isset ( $this->params ['date'] ) ? $this->params ['date'] : 'MONTHO';
  4510. // $get = "/" . $date;
  4511. // $con = '';
  4512. // if ($date == 'MONTHO')
  4513. // $con = ' and approvalTime>DATE_SUB(CURDATE(), INTERVAL 1 MONTH)';
  4514. // elseif ($date == 'MONTHT')
  4515. // $con = ' and approvalTime>DATE_SUB(CURDATE(), INTERVAL 3 MONTH)';
  4516. // elseif ($date == 'MONTHY')
  4517. // $con = ' and approvalTime>DATE_SUB(CURDATE(), INTERVAL 1 YEAR)';
  4518. // if (! empty ( $MebSea )) {
  4519. // $con .= ' and ( invoiceTitle like "%' . $MebSea . '%" or invoiceCompany like "%' . $MebSea . '%" or invoicePrice like "%' . $MebSea . '%" )';
  4520. // $get .= "/" . $MebSea;
  4521. // }
  4522. // $pageinfo ['page'] = array (
  4523. // 'previous' => ''
  4524. // );
  4525. // $sql = '(status=1 or status=2 or status=3 or status=4) and processApprovals!=""' . $con; // echo $sql;
  4526. // $pageinfo = $this->get_page ( "CLD_invoice", $sql, $page, $page_size, "invoiceApprovalAchieve", $get, "" );
  4527. // $limit = $pageinfo ['lower'] . ',' . $page_size;
  4528. // $list = $invoice->getInvoiceByUntreadStatusPage ( $limit, $sql, 'desc', 2 );
  4529. // // print_r($list);
  4530. // $this->data ['MebSeaEn'] = $MebSea;
  4531. // $this->data ['MebSea'] = urlencode ( $MebSea );
  4532. // $this->data ['get'] = $get;
  4533. // $this->data ['page'] = $pageinfo;
  4534. // $this->data ['list'] = $list;
  4535. // $this->data ['date'] = $date;
  4536. // $this->data ['memu'] = "invoice";
  4537. // $this->data ['staff'] = $this->staff;
  4538. // $this->data ['receiptMemu'] = 'invoiceApproval';
  4539. // $this->render ( "/admin/invoiceApprovalAchieve", $this->data );
  4540. // }
  4541. /**
  4542. * 获得审批发票的信息以及审批页面
  4543. */
  4544. function ajaxGetInvoiceApprovalDetail() {
  4545. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  4546. if (empty ( $serial )) {
  4547. echo json_encode ( array (
  4548. 'status' => 2,
  4549. 'msg' => 'illegal request'
  4550. ) );
  4551. die ();
  4552. }
  4553. Doo::loadModel ( 'invoice' );
  4554. $invoice = new invoice ();
  4555. Doo::loadModel ( 'invoiceOperationLog' );
  4556. $invoiceOperationLog = new invoiceOperationLog ();
  4557. $detail = $invoice->getInvoiceByIsid ( $serial, $this->staff [0] ['sid'] );
  4558. $invoiceOperationLogList = $invoiceOperationLog->getInvoiceOperationLogByIid ( $detail ['iid'] );
  4559. if (empty ( $detail ))
  4560. $html = '';
  4561. else {
  4562. $html = '
  4563. <form action="/invoiceApprovalDo" method="post" name="invoiceApproval" class="nice-validator n-yellow" novalidate="novalidate">
  4564. <input type="hidden" name="invoiceKey" value="' . $detail ['iidKeyXD'] . '">
  4565. <input type="hidden" name="status" value="">
  4566. <input type="hidden" name="divApproval" value="divApproval">
  4567. <div class="modal-dialog modal-lg">
  4568. <div class="modal-content"><div class="modal-header"><h3>发票审批详情</h3></div>
  4569. <div class="modal-body saeaList"><table class="table table-bordered table-condensed"><tbody>
  4570. <tr>
  4571. <th class="taC" width="150">发票审批</th><td><textarea name="opinion" style="width:98%" placeholder="在这写下您的审批意见,选填。"></textarea></td>
  4572. </tr>
  4573. <tr>
  4574. <th class="taC" width="150">开票流水号</th><td>' . $detail ['invoiceSerial'] . '</td>
  4575. <th class="taC" width="150">提交时间</th><td>' . $detail ['date'] . '</td>
  4576. </tr>
  4577. <tr>
  4578. <th class="taC" width="150">所在办事处</th><td>' . $detail ['categoryName'] . '(' . $detail ['userName'] . ')</td>
  4579. <th class="taC" width="150">开票内容</th><td>' . $detail ['invoiceElement'] . '</td>
  4580. </tr>
  4581. <tr>
  4582. <th class="taC">发票备注</th><td colspan="3">' . $detail ['remark'] . '
  4583. </td>
  4584. </tr>
  4585. <tr>
  4586. <th class="taC" width="150">数量</th><td><b>' . $detail ['invoiceQuantity'] . '</b></td>
  4587. <th class="taC">单价</th><td><b>¥' . $detail ['invoiceUnitPrice'] . '</b></td>
  4588. </tr>
  4589. <tr>
  4590. <th class="taC">开票金额</th><td colspan="3"><b class="colOrange" style="font-size:18px">¥' . $detail ['invoicePrice'] . '</b></td>
  4591. </tr></tbody></table>';
  4592. if ($detail ['invoiceType'] == 0)
  4593. $html .= '<table class="table table-bordered table-condensed"><tbody>
  4594. <tr><th colspan="4" class="taC">增值税普通发票</th></tr><tr>
  4595. <th class="taC" width="150">发票抬头</th><td >' . $detail ['invoiceTitle'] . '</td>
  4596. <th class="taC" width="150">纳税人识别码</th><td>' . $detail ['TIN'] . '</td>
  4597. </tr>';
  4598. else
  4599. $html .= '<table class="table table-bordered table-condensed"><tbody>
  4600. <tr><th colspan="4" class="taC">增值税专用发票</th></tr><tr>
  4601. <th class="taC" width="150">单位名称</th><td>' . $detail ['invoiceCompany'] . '</td>
  4602. <th class="taC" width="150">纳税人识别码</th><td>' . $detail ['TIN'] . '</td></tr>
  4603. ';
  4604. $html .= '<tr>
  4605. <th class="taC">注册地址</th><td>' . $detail ['address'] . '</td>
  4606. <th class="taC">注册电话</th><td>' . $detail ['phone'] . '</td>
  4607. </tr>
  4608. <tr>
  4609. <th class="taC">开户银行</th><td>' . $detail ['bank'] . '</td>
  4610. <th class="taC">银行账号</th><td>' . $detail ['bankAccount'] . '</td>
  4611. </tr></tbody></table>';
  4612. if ($detail ['doPost'] == 1) {
  4613. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th colspan="4" class="taC">邮寄信息</th></tr><tr>
  4614. <th class="taC" width="150">收件人</th><td>' . $detail ['recipients'] . '</td>
  4615. <th class="taC" width="150">收件人手机/电话</th><td>' . $detail ['recipientsPhone'] . '</td>
  4616. </tr><tr>
  4617. <th class="taC" width="150">收件地址</th><td colspan="3">' . $detail ['recipientsAddress'] . '</td>
  4618. </tr><tr>
  4619. <th class="taC" width="150">邮寄物品</th><td colspan="3">' . $detail ['mailItems'] . '</td>
  4620. </tr>
  4621. ';
  4622. if ($detail ['expressCom'] == 'SF')
  4623. $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>';
  4624. else
  4625. $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>';
  4626. $html .= '</tbody></table>';
  4627. }
  4628. if (! empty ( $invoiceOperationLogList )) {
  4629. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th width="60%" class="taC">审批流程</th></tr><tr><td>';
  4630. foreach ( $invoiceOperationLogList as $key => $value ) {
  4631. if ($value ['status'] == 1 || $value ['status'] == 2 || $value ['status'] == 3 || $value ['status'] == 4) {
  4632. $html .= '<blockquote><p><span class="colGray">' . $value ['date'] . '</span>&nbsp;
  4633. ' . $value ['category'] . '-' . $value ['username'] . '&nbsp;';
  4634. if ($value ['status'] == 2) {
  4635. $html .= '<span class="colGreen">同意</span>';
  4636. } elseif ($value ['status'] == 3) {
  4637. $html .= '<span class="colOrange">退回</span>';
  4638. } elseif ($value ['status'] == 5) {
  4639. $html .= '<span class="colGreen">打印</span>';
  4640. } elseif ($value ['status'] == 4) {
  4641. $html .= '<span class="colRed">终止</span>';
  4642. }
  4643. $html .= $value ['operation'] . '</p></blockquote>';
  4644. }
  4645. }
  4646. $html .= '</td></tr></tbody></table>';
  4647. }
  4648. $html .= '</div><div class="modal-footer">
  4649. <a href="javascript:void(0)" node-approval="approval" diss-data="2" class="button btn-done" data-placement="top" data-toggle="ctooltip" >同意</a>
  4650. <a href="javascript:void(0)" node-approval="approval" diss-data="3" class="button btn-back" data-placement="top" data-toggle="ctooltip" data-original-title="上报人修改后重新审批">退回</a>
  4651. <a href="javascript:void(0)" node-approval="approval" diss-data="4" class="button btn-undone" data-placement="top" data-toggle="ctooltip" data-original-title="终止发票申请">终止</a>
  4652. <a href="#" class="button btn-gray" data-dismiss="modal" aria-hidden="true">关闭</a></div></div></div>
  4653. </form>
  4654. <script type="text/javascript">
  4655. $("a[node-approval^=\'approval\']").click(function() {
  4656. $("input[name=\'status\']").val($(this).attr("diss-data"));
  4657. $("form[name=\'invoiceApproval\']").submit();
  4658. });
  4659. </script>
  4660. ';
  4661. }
  4662. echo json_encode ( array (
  4663. 'status' => 1,
  4664. 'html' => $html
  4665. ) );
  4666. die ();
  4667. }
  4668. /**
  4669. * 获得审批发票分页数据
  4670. */
  4671. function ajaxGetinvoiceApprovalAchieve() {
  4672. Doo::loadModel ( 'invoice' );
  4673. $invoice = new invoice ();
  4674. Doo::loadModel ( 'staff' );
  4675. $staff = new staff ();
  4676. Doo::loadClass ( 'XDeode' );
  4677. $XDeode = new XDeode ( 5 );
  4678. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 'ALL';
  4679. $invoiceType = $this->get_args ( 'invoiceType' ) ? $this->get_args ( 'invoiceType' ) : "ALL";
  4680. $invoiceTrain = $this->get_args ( 'invoiceTrain' ) ? $this->get_args ( 'invoiceTrain' ) : "ALL";
  4681. $invoiceTrainName = $this->get_args ( 'invoiceTrainName' ) ? $this->get_args ( 'invoiceTrainName' ) : "ALL";
  4682. $date = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "";
  4683. $page = $this->get_args ( 'start' ) && is_numeric ( $this->get_args ( 'start' ) ) ? $this->get_args ( 'start' ) : 0;
  4684. $draw = $this->get_args ( 'draw' ) && is_numeric ( $this->get_args ( 'draw' ) ) ? $this->get_args ( 'draw' ) : 1;
  4685. $length = $this->get_args ( 'length' ) && is_numeric ( $this->get_args ( 'length' ) ) ? $this->get_args ( 'length' ) : 10;
  4686. $MebSea = $this->get_args ( 'search' );
  4687. $MebSea = $MebSea ['value'];
  4688. $page_size = $length;
  4689. $con = '';
  4690. if ($status == 'ALL')
  4691. $con = ' (status=1 or status=2 or status=3 or status=4) and isDelete=0 ';
  4692. elseif ($status == 'PEND')
  4693. $con = ' isDelete=0 and status=1';
  4694. elseif ($status == 'APPROVED')
  4695. $con = ' isDelete=0 and status=2';
  4696. if ($invoiceType == 'ORDINARY')
  4697. $con .= ' and invoiceType=0 ';
  4698. elseif ($invoiceType == 'SPECIAL')
  4699. $con .= ' and invoiceType=1 ';
  4700. if ($invoiceTrain == 'ORDINARY')
  4701. $con .= ' and trainId=0 ';
  4702. elseif ($invoiceTrain == 'TRAIN')
  4703. $con .= ' and trainId!=0 ';
  4704. if ($invoiceTrainName != 'ALL') {
  4705. $trainId = $XDeode->decode ( $invoiceTrainName );
  4706. if (is_numeric ( $trainId ))
  4707. $con .= ' and trainId =' . $trainId;
  4708. }
  4709. $dateArr = explode ( ':', $date );
  4710. $D1 = $dateString = '';
  4711. $D2 = '';
  4712. if (! empty ( $date )) {
  4713. $D1 = $dateArr [0];
  4714. if (isset ( $dateArr [1] ))
  4715. $D2 = $dateArr [1];
  4716. else
  4717. $D2 = '';
  4718. $dateString = $D1 . " : " . $D2;
  4719. }
  4720. if (! empty ( $D1 ) && ! empty ( $D2 ))
  4721. $con .= ' and approvalTime BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
  4722. elseif (! empty ( $D1 ) && empty ( $D2 ))
  4723. $con .= ' and approvalTime like "%' . $D1 . '%" ';
  4724. if (! empty ( $MebSea ))
  4725. $con .= ' and ( invoiceTitle like "%' . $MebSea . '%" or invoiceCompany like "%' . $MebSea . '%" or invoicePrice like "%' . $MebSea . '%" or invoiceSerial like "%' . $MebSea . '%" )';
  4726. // /
  4727. $pageinfo ['page'] = array (
  4728. 'previous' => ''
  4729. );
  4730. $sql = ' ' . $con;
  4731. $pageinfo = $this->get_page ( "CLD_invoice", $sql, $page, $page_size, "invoiceApprovalAchieve", '', "" );
  4732. $limit = $page . ',' . $page_size;
  4733. $list = $invoice->getInvoiceByUntreadStatusPage ( $limit, $sql, 'desc', 2 );
  4734. $approvalList = array ();
  4735. $html = '
  4736. <script type="text/javascript">
  4737. </script>
  4738. ';
  4739. foreach ( $list as $key => $value ) {
  4740. $irDetail = array ();
  4741. if ($value ['status'] == 1 && $value ['pendingApprovals'] == $this->staff [0] ['sid']) {
  4742. array_push ( $irDetail, '<a href="#approvalInvice" onclick="nodeInvoiceApproval(\'' . $value ['iidKeyK'] . '\')" data-toggle="modal">审批发票</a>' );
  4743. } else
  4744. array_push ( $irDetail, '' );
  4745. array_push ( $irDetail, '<a href="#approvalInvice" onclick="nodeInvoice(\'' . $value ['iidKeyK'] . '\')" data-toggle="modal">' . $value ['invoiceSerial'] . '</a>' );
  4746. if ($value ['invoiceType'] == 1)
  4747. array_push ( $irDetail, $value ['invoiceCompany'] );
  4748. else
  4749. array_push ( $irDetail, $value ['invoiceTitle'] );
  4750. array_push ( $irDetail, $value ['TIN'] );
  4751. array_push ( $irDetail, $value ['address'] . $value ['phone'] );
  4752. array_push ( $irDetail, $value ['bank'] . $value ['bankAccount'] );
  4753. array_push ( $irDetail, $value ['remark'] );
  4754. array_push ( $irDetail, $value ['invoiceElement'] );
  4755. array_push ( $irDetail, $value ['invoiceQuantity'] );
  4756. array_push ( $irDetail, $value ['invoiceUnitPrice'] );
  4757. if ($value ['invoiceType'] == 1)
  4758. array_push ( $irDetail, '¥' . $value ['invoicePrice'] . '<sup>专</sup>' );
  4759. else
  4760. array_push ( $irDetail, '¥' . $value ['invoicePrice'] );
  4761. array_push ( $irDetail, $value ['recipients'] . $value ['recipientsPhone'] );
  4762. array_push ( $irDetail, $value ['recipientsAddress'] );
  4763. array_push ( $irDetail, $value ['mailItems'] );
  4764. array_push ( $irDetail, $value ['userName'] . '&nbsp;' . $value ['date'] );
  4765. $fchtml = $value ['OL'] ['operation'];
  4766. if (count ( $list ) == $page_size)
  4767. $fchtml = $value ['OL'] ['operation'] . $html;
  4768. // 最后的审批意见
  4769. array_push ( $irDetail, $fchtml );
  4770. if ($value ['status'] == 2)
  4771. array_push ( $irDetail, '<span class="colGreen">同意</span>' . $value ['OL'] ['username'] . $value ['OL'] ['date'] );
  4772. elseif ($value ['status'] == 3)
  4773. array_push ( $irDetail, '<span class="colOrange">退回</span>' . $value ['OL'] ['username'] . $value ['OL'] ['date'] );
  4774. elseif ($value ['status'] == 4)
  4775. array_push ( $irDetail, '<span class="colRed">终止</span>' . $value ['OL'] ['username'] . $value ['OL'] ['date'] );
  4776. else
  4777. array_push ( $irDetail, '' );
  4778. array_push ( $approvalList, $irDetail );
  4779. }
  4780. // $approvalListJson = json_encode ( $approvalList );
  4781. $recordsFiltered = $pageinfo ['total_data'];
  4782. echo json_encode ( array (
  4783. "draw" => intval ( $draw ),
  4784. "recordsTotal" => intval ( $pageinfo ['total_data'] ),
  4785. "recordsFiltered" => intval ( $recordsFiltered ),
  4786. "data" => $approvalList
  4787. ), JSON_UNESCAPED_UNICODE );
  4788. }
  4789. /**
  4790. * 审批发票查看更多--重构
  4791. */
  4792. function invoiceApprovalAchieve() {
  4793. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : 'ALL';
  4794. $invoiceType = $this->get_args ( 'invoiceType' ) ? $this->get_args ( 'invoiceType' ) : "ALL";
  4795. $invoiceTrain = $this->get_args ( 'invoiceTrain' ) ? $this->get_args ( 'invoiceTrain' ) : "ALL";
  4796. $invoiceTrainName = $this->get_args ( 'invoiceTrainName' ) ? $this->get_args ( 'invoiceTrainName' ) : "ALL";
  4797. $date = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "";
  4798. Doo::loadModel ( 'invoiceTraining' );
  4799. $invoiceTraining = new invoiceTraining ();
  4800. $trainList = $invoiceTraining->getInvoiceTrainingBySubmitStatus ();
  4801. $this->data ['trainList'] = $trainList;
  4802. $this->data ['dateString'] = $date;
  4803. $this->data ['status'] = $status;
  4804. $this->data ['invoiceType'] = $invoiceType;
  4805. $this->data ['invoiceTrain'] = $invoiceTrain;
  4806. $this->data ['invoiceTrainName'] = $invoiceTrainName;
  4807. $this->data ['memu'] = "invoice";
  4808. $this->data ['staff'] = $this->staff;
  4809. $this->data ['receiptMemu'] = 'invoiceApproval';
  4810. $this->render ( "/admin/invoiceApprovalAchieve", $this->data );
  4811. }
  4812. function invoiceTAchieve() {
  4813. Doo::loadModel ( 'invoice' );
  4814. $invoice = new invoice ();
  4815. Doo::loadClass ( 'XDeode' );
  4816. $XDeode = new XDeode ( 5 );
  4817. Doo::loadModel ( 'staff' );
  4818. $staff = new staff ();
  4819. $MebSea = isset ( $this->params ['MebSea'] ) ? urldecode ( $this->params ['MebSea'] ) : '';
  4820. $page_size = 12;
  4821. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  4822. $date = isset ( $this->params ['date'] ) ? $this->params ['date'] : 'MONTHO';
  4823. $invoiceType = $this->get_args ( 'invoiceType' ) ? $this->get_args ( 'invoiceType' ) : "ALL";
  4824. $invoiceTrain = $this->get_args ( 'invoiceTrain' ) ? $this->get_args ( 'invoiceTrain' ) : "ALL";
  4825. $invoiceTrainName = $this->get_args ( 'invoiceTrainName' ) ? $this->get_args ( 'invoiceTrainName' ) : "ALL";
  4826. Doo::loadModel ( 'invoiceTraining' );
  4827. $invoiceTraining = new invoiceTraining ();
  4828. $trainList = $invoiceTraining->getInvoiceTrainingBySubmitStatus ();
  4829. $get = "/" . $date;
  4830. $con = '';
  4831. if ($date == 'MONTHO')
  4832. $con = ' and updateTime>DATE_SUB(CURDATE(), INTERVAL 1 MONTH)';
  4833. elseif ($date == 'MONTHT')
  4834. $con = ' and updateTime>DATE_SUB(CURDATE(), INTERVAL 3 MONTH)';
  4835. elseif ($date == 'MONTHY')
  4836. $con = ' and updateTime>DATE_SUB(CURDATE(), INTERVAL 1 YEAR)';
  4837. if ($invoiceType == 'ORDINARY')
  4838. $con .= ' and invoiceType=0 ';
  4839. elseif ($invoiceType == 'SPECIAL')
  4840. $con .= ' and invoiceType=1 ';
  4841. if ($invoiceTrain == 'ORDINARY')
  4842. $con .= ' and trainId=0 ';
  4843. elseif ($invoiceTrain == 'TRAIN')
  4844. $con .= ' and trainId!=0 ';
  4845. if ($invoiceTrainName != 'ALL') {
  4846. $trainId = $XDeode->decode ( $invoiceTrainName );
  4847. if (is_numeric ( $trainId ))
  4848. $con .= ' and trainId =' . $trainId;
  4849. }
  4850. if (! empty ( $MebSea )) {
  4851. $con .= ' and ( invoiceTitle like "%' . $MebSea . '%" or invoiceCompany like "%' . $MebSea . '%" or invoicePrice like "%' . $MebSea . '%" )';
  4852. $get .= "/" . $MebSea;
  4853. }
  4854. $pageinfo ['page'] = array (
  4855. 'previous' => ''
  4856. );
  4857. $sql = "";
  4858. $action = "";
  4859. if ($this->ACTION == 'invoicePrintAchieve') {
  4860. $sql = "status=2 and printStatus=1 and moldManage like '%[\"" . $this->staff [0] ['sid'] . "\",%'" . $con;
  4861. $action = "invoicePrintAchieve";
  4862. } elseif ($this->ACTION == 'invoicePostAchieve') {
  4863. // and untreadStatus=0
  4864. $sql = "postStatus=1 and doPost=1 and status=2 and isDelete=0" . $con;
  4865. $action = "invoicePostAchieve";
  4866. } elseif ($this->ACTION == 'invoiceUntreadAchieve') { // printStatus=1 and
  4867. $sql = " untreadStatus=2 and status=2 " . $con;
  4868. $action = "invoiceUntreadAchieve";
  4869. }
  4870. $pageinfo = $this->get_page ( "CLD_invoice", $sql, $page, $page_size, $action, $get, "" );
  4871. $limit = $pageinfo ['lower'] . ',' . $page_size;
  4872. $this->data ['MebSeaEn'] = $MebSea;
  4873. $this->data ['MebSea'] = urlencode ( $MebSea );
  4874. $this->data ['get'] = $get;
  4875. $this->data ['page'] = $pageinfo;
  4876. $this->data ['trainList'] = $trainList;
  4877. $this->data ['invoiceType'] = $invoiceType;
  4878. $this->data ['invoiceTrain'] = $invoiceTrain;
  4879. $this->data ['invoiceTrainName'] = $invoiceTrainName;
  4880. $this->data ['date'] = $date;
  4881. $this->data ['memu'] = "invoice";
  4882. $this->data ['staff'] = $this->staff;
  4883. if ($this->ACTION == 'invoicePrintAchieve') {
  4884. $list = $invoice->getInvoiceByUntreadStatusPage ( $limit, $sql, 'desc', 5 );
  4885. $this->data ['receiptMemu'] = 'invoicePrint';
  4886. $this->data ['list'] = $list;
  4887. $this->render ( "/admin/invoicePrintAchieve", $this->data );
  4888. } elseif ($this->ACTION == 'invoicePostAchieve') {
  4889. $list = $invoice->getInvoiceByUntreadStatusPage ( $limit, $sql );
  4890. Doo::loadModel ( 'express' );
  4891. $express = new express ();
  4892. $expressList = $express->getExpressByAll ();
  4893. $this->data ['expressList'] = $expressList;
  4894. $this->data ['receiptMemu'] = 'invoicePost';
  4895. $this->data ['list'] = $list;
  4896. $this->render ( "/admin/invoicePostAchieve", $this->data );
  4897. } elseif ($this->ACTION == 'invoiceUntreadAchieve') {
  4898. $list = $invoice->getInvoiceByUntreadStatusPage ( $limit, $sql );
  4899. $this->data ['receiptMemu'] = 'invoiceUntread';
  4900. $this->data ['list'] = $list;
  4901. $this->render ( "/admin/invoiceUntreadAchieve", $this->data );
  4902. }
  4903. }
  4904. /**
  4905. * 公司应收款
  4906. */
  4907. function invoiceAggregateCompanyDetail() {
  4908. $sidKey = $this->get_args ( 'sidKey' ) ? $this->get_args ( 'sidKey' ) : '';
  4909. $cidKey = $this->get_args ( 'cidKey' ) ? $this->get_args ( 'cidKey' ) : '';
  4910. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : 'ALL';
  4911. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  4912. $invoiceElement = $this->get_args ( 'invoiceElement' ) ? $this->get_args ( 'invoiceElement' ) : "";
  4913. Doo::loadClass ( 'XDeode' );
  4914. $XDeode = new XDeode ( 5 );
  4915. Doo::loadModel ( 'invoice' );
  4916. $invoice = new invoice ();
  4917. Doo::loadModel ( 'staff' );
  4918. $staff = new staff ();
  4919. Doo::loadModel ( "invoiceCompanyManage" );
  4920. $invoiceCompanyManage = new invoiceCompanyManage ();
  4921. Doo::loadModel ( 'L_category' );
  4922. $category = new L_category ();
  4923. $sid = '';
  4924. if (! empty ( $sidKey ))
  4925. $sid = $XDeode->decode ( $sidKey );
  4926. $staffDetail = $staff->getStaffBySid ( $sid );
  4927. $cid = '';
  4928. if (! empty ( $cidKey ))
  4929. $cid = $XDeode->decode ( $cidKey );
  4930. $imcStaff = $invoiceCompanyManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  4931. $cidList = array ();
  4932. foreach ( $imcStaff as $key => $value ) {
  4933. array_push ( $cidList, $value ['cid'] );
  4934. }
  4935. $categoryList = $category->getCategoryInCid ( implode ( ',', $cidList ) );
  4936. $cidString = implode ( ',', $cidList );
  4937. if (empty ( $cid ))
  4938. $staffList = $staff->getStaffInCid ( $cidString );
  4939. else
  4940. $staffList = $staff->getStaffByCid ( $cid ); //
  4941. $MebSea = $this->get_args ( 'MebSea' ) ? $this->get_args ( 'MebSea' ) : "";
  4942. $page_size = 25;
  4943. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  4944. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : 'All';
  4945. $con = ' status=2 and untreadStatus!=2 ';
  4946. $statisticsCon = '';
  4947. if (! empty ( $year ) && is_numeric ( $year ))
  4948. $con .= ' and Year(printTime)=' . $year . '';
  4949. if (! empty ( $month ) && is_numeric ( $month ))
  4950. $con .= ' and Month(printTime)="' . $month . '" ';
  4951. if ($status == 'UNRECORD')
  4952. $con .= ' and printStatus=1 and untreadStatus=0';
  4953. elseif ($status == 'RECORD')
  4954. $con .= ' and printStatus=1 and untreadStatus=3';
  4955. elseif ($status == 'BOUNCED')
  4956. $con .= ' and untreadStatus=2';
  4957. elseif ($status == 'PARTRECORD')
  4958. $con .= ' and untreadStatus=0 and printStatus=1 and irid!=""';
  4959. elseif ($status == 'All') {
  4960. $con .= ' and printStatus=1 and ( untreadStatus=0 or untreadStatus=3 )';
  4961. }
  4962. if (! empty ( $sid ) && is_numeric ( $sid ))
  4963. $con .= ' and sid=' . $sid;
  4964. if (! empty ( $cid ) && is_numeric ( $cid ))
  4965. $con .= ' and cid=' . $cid;
  4966. else
  4967. $con .= ' and cid in (' . $cidString . ')';
  4968. // 开票内容筛选
  4969. if (! empty ( $invoiceElement ) && $invoiceElement != 'ALL') {
  4970. $con .= ' and invoiceElement="' . $invoiceElement . '"';
  4971. }
  4972. $get = "/" . $status . "?cidKey=" . $cidKey . "&sidKey=" . $sidKey . "&year=" . $year . "&month=" . $month . "&invoiceElement=" . $invoiceElement;
  4973. if (! empty ( $MebSea )) {
  4974. $con .= ' and ( invoiceTitle like "%' . $MebSea . '%" or invoiceCompany like "%' . $MebSea . '%" )';
  4975. }
  4976. $pageinfo ['page'] = array (
  4977. 'previous' => ''
  4978. );
  4979. $pageinfo = $this->get_page ( "CLD_invoice", $con, $page, $page_size, "invoiceAggregateCompanyDetail", $get, "" );
  4980. $limit = $pageinfo ['lower'] . ',' . $page_size;
  4981. // 应收款合计
  4982. $ics = $invoice->getInvoiceCompanyStatistics ( $con );
  4983. $list = $invoice->getInvoiceByUntreadStatusPage ( $limit, $con );
  4984. $monthHtml = "";
  4985. if ($year != "ALL") {
  4986. for($i = 1; $i <= 12; $i ++) {
  4987. if ($i == $month)
  4988. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  4989. else
  4990. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  4991. }
  4992. }
  4993. $this->data ['monthHtml'] = $monthHtml;
  4994. $this->data ['year'] = $year;
  4995. $this->data ['month'] = $month;
  4996. $this->data ['ics'] = $ics;
  4997. $this->data ['cidKey'] = $cidKey;
  4998. $this->data ['sid'] = $sid;
  4999. $this->data ['staffDetail'] = $staffDetail;
  5000. $this->data ['staffList'] = $staffList;
  5001. $this->data ['MebSeaEn'] = $MebSea;
  5002. $this->data ['MebSea'] = urlencode ( $MebSea );
  5003. $this->data ['invoiceDetail'] = array (
  5004. 'invoiceElement' => $invoiceElement
  5005. );
  5006. $this->data ['page'] = $pageinfo;
  5007. $this->data ['get'] = $get;
  5008. $this->data ['list'] = $list;
  5009. $this->data ['status'] = $status;
  5010. $this->data ['categoryList'] = $categoryList;
  5011. $this->data ['memu'] = "invoice";
  5012. $this->data ['staff'] = $this->staff;
  5013. $this->data ['receiptMemu'] = 'invoiceAggregateCompanyDetail';
  5014. $this->render ( "/admin/invoiceAggregateCompanyDetail", $this->data );
  5015. }
  5016. /**
  5017. * 获取一条收款信息
  5018. */
  5019. function ajaxGetInvoiceReceivables() {
  5020. $irid = $this->get_args ( 'key' ) ? $this->get_args ( 'key' ) : "";
  5021. Doo::loadModel ( 'invoiceReceivables' );
  5022. $invoiceReceivables = new invoiceReceivables ();
  5023. $detail = $invoiceReceivables->getInvoiceReceivablesByIrid ( $irid );
  5024. echo json_encode ( array (
  5025. 'status' => 1,
  5026. 'detail' => $detail
  5027. ) );
  5028. }
  5029. /**
  5030. * 异步获取办事处用户
  5031. */
  5032. function ajaxGetStaffByCategory() {
  5033. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : "";
  5034. Doo::loadModel ( 'staff' );
  5035. $staff = new staff ();
  5036. if ($cid == "PUBLIC") {
  5037. echo json_encode ( array (
  5038. 'status' => 1,
  5039. 'html' => '<option value="PUBLIC">办事处待认领款项</option>'
  5040. ) );
  5041. die ();
  5042. }
  5043. if (! is_numeric ( $cid )) {
  5044. echo json_encode ( array (
  5045. 'status' => 0,
  5046. 'msg' => 'illegal request'
  5047. ) );
  5048. die ();
  5049. }
  5050. $staffList = $staff->getStaffByCid ( $cid );
  5051. $html = '<option value="PUBLIC">办事处待认领款项</option>';
  5052. foreach ( $staffList as $key => $value ) {
  5053. $html .= '<option value="' . $value ['sid'] . '-' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  5054. }
  5055. echo json_encode ( array (
  5056. 'status' => 1,
  5057. 'html' => $html
  5058. ) );
  5059. }
  5060. /**
  5061. * 异步获取一条发票的邮寄信息
  5062. */
  5063. function ajaxGetInvoicePostDetail() {
  5064. $iid = $this->get_args ( 'iidKey' ) ? $this->get_args ( 'iidKey' ) : "";
  5065. Doo::loadModel ( 'invoice' );
  5066. $invoice = new invoice ();
  5067. $iid = $invoice->authcode ( $iid );
  5068. Doo::loadModel ( 'express' );
  5069. $express = new express ();
  5070. $expressList = $express->getExpressByAll ();
  5071. if (! is_numeric ( $iid )) {
  5072. echo json_encode ( array (
  5073. 'status' => 0,
  5074. 'msg' => 'illegal request'
  5075. ) );
  5076. die ();
  5077. }
  5078. $select = "iid,recipients,recipientsPhone,recipientsAddress,mailItems,expressCompany,expressNumber,actualItems";
  5079. $invoiceDetail = $invoice->getInvoiceByIid ( $iid, $select );
  5080. $html = "";
  5081. foreach ( $expressList as $key => $value ) {
  5082. if ($value ['company'] == $invoiceDetail ['expressCompany'])
  5083. $html .= '<option selected value="' . $value ['company'] . ':' . $value ['com'] . '">' . $value ['company'] . '</option>';
  5084. else
  5085. $html .= '<option value="' . $value ['company'] . ':' . $value ['com'] . '">' . $value ['company'] . '</option>';
  5086. }
  5087. $invoiceDetail ['eaHtml'] = $html;
  5088. echo json_encode ( array (
  5089. 'status' => 1,
  5090. 'invoiceDetail' => $invoiceDetail
  5091. ) );
  5092. }
  5093. /**
  5094. *
  5095. * @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 ) ); }
  5096. */
  5097. /**
  5098. *
  5099. * @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 ) ); }
  5100. */
  5101. /**
  5102. * 我的收款中 选择哪个发票入账,进行金额判断
  5103. */
  5104. function ajaxCompareInvoicePrice() {
  5105. $claimKey = $this->get_args ( 'claimKey' ) ? $this->get_args ( 'claimKey' ) : "";
  5106. $invoiceKey = $this->get_args ( 'invoiceKey' ) ? $this->get_args ( 'invoiceKey' ) : "";
  5107. Doo::loadModel ( 'invoice' );
  5108. $invoice = new invoice ();
  5109. Doo::loadModel ( 'invoiceReceivables' );
  5110. $invoiceReceivables = new invoiceReceivables ();
  5111. $detail = $invoice->getInvoiceByIid ( $invoiceKey );
  5112. $keyList = explode ( ';', $claimKey );
  5113. $receivablesPrice = 0;
  5114. foreach ( $keyList as $key => $value ) {
  5115. $detailM = $invoiceReceivables->getInvoiceReceivablesByIrid ( $value );
  5116. $receivablesPrice += $detailM ['receivablesPrice'];
  5117. }
  5118. if ($receivablesPrice > $detail ['invoicePrice']) {
  5119. $price = $receivablesPrice - $detail ['invoicePrice'];
  5120. echo json_encode ( array (
  5121. 'status' => 1,
  5122. 'price' => $price
  5123. ) );
  5124. } else
  5125. echo json_encode ( array (
  5126. 'status' => 2
  5127. ) );
  5128. }
  5129. /**
  5130. * 获得打印发票
  5131. */
  5132. function ajaxGetInvoiceInfoByPrint() {
  5133. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  5134. if (empty ( $serial )) {
  5135. echo json_encode ( array (
  5136. 'status' => 2,
  5137. 'msg' => 'illegal request'
  5138. ) );
  5139. die ();
  5140. }
  5141. Doo::loadModel ( 'invoice' );
  5142. $invoice = new invoice ();
  5143. Doo::loadModel ( 'invoiceOperationLog' );
  5144. $invoiceOperationLog = new invoiceOperationLog ();
  5145. $detail = $invoice->getInvoiceByIsid ( $serial, $this->staff [0] ['sid'] );
  5146. $invoiceOperationLogList = $invoiceOperationLog->getInvoiceOperationLogByIid ( $detail ['iid'] );
  5147. Doo::loadModel ( 'invoicePaper' );
  5148. $invoicePaper = new invoicePaper ();
  5149. $invoicePaperList = $invoicePaper->getInvoicePaperByInvoiceType ( $detail ['invoiceType'] );
  5150. if (empty ( $detail ))
  5151. $html = '';
  5152. else {
  5153. $html = '
  5154. <form action="/invoicePrintDo" method="post" name="invoicePrint" class="nice-validator n-yellow" onSubmit="return checkPrintForm()" novalidate="novalidate">
  5155. <input type="hidden" name="invoiceKey" value="' . $detail ['iidKeyXD'] . '">
  5156. <input type="hidden" name="invoicePrintType" value="invoicePrintType">
  5157. <div class="modal-dialog modal-lg">
  5158. <div class="modal-content"><div class="modal-header"><h3>发票单详情</h3></div>
  5159. <div class="modal-body saeaList">
  5160. <table class="table table-bordered table-condensed"><tbody>
  5161. <tr>
  5162. <th class="taC" width="150">开票流水号</th><td>' . $detail ['invoiceSerial'] . '</td>
  5163. <th class="taC" width="150">提交时间</th><td>' . $detail ['date'] . '</td>
  5164. </tr>
  5165. <tr>
  5166. <th class="taC" width="150">所在办事处</th><td>' . $detail ['categoryName'] . '(' . $detail ['userName'] . ')</td>
  5167. <th class="taC" width="150">开票内容</th><td>' . $detail ['invoiceElement'] . '</td>
  5168. </tr>
  5169. <tr>
  5170. <th class="taC">发票备注</th><td colspan="3">' . $detail ['remark'] . '
  5171. </td>
  5172. </tr>
  5173. <tr>
  5174. <th class="taC" width="150">数量</th><td><b>' . $detail ['invoiceQuantity'] . '</b></td>
  5175. <th class="taC">单价</th><td><b>¥' . $detail ['invoiceUnitPrice'] . '</b></td>
  5176. </tr>
  5177. <tr>
  5178. <th class="taC">开票金额</th><td colspan="3"><b class="colOrange" style="font-size:18px">¥' . $detail ['invoicePrice'] . '</b></td>
  5179. </tr></tbody></table>';
  5180. if ($detail ['invoiceType'] == 0)
  5181. $html .= '<table class="table table-bordered table-condensed"><tbody>
  5182. <tr><th colspan="4" class="taC">增值税普通发票</th></tr><tr>
  5183. <th class="taC" width="150">发票抬头</th><td >' . $detail ['invoiceTitle'] . '</td>
  5184. <th class="taC" width="150">纳税人识别码</th><td>' . $detail ['TIN'] . '</td>
  5185. </tr>';
  5186. else
  5187. $html .= '<table class="table table-bordered table-condensed"><tbody>
  5188. <tr><th colspan="4" class="taC">增值税专用发票</th></tr><tr>
  5189. <th class="taC" width="150">单位名称</th><td>' . $detail ['invoiceCompany'] . '</td>
  5190. <th class="taC" width="150">纳税人识别码</th><td>' . $detail ['TIN'] . '</td></tr>
  5191. ';
  5192. $html .= '<tr>
  5193. <th class="taC">注册地址</th><td>' . $detail ['address'] . '</td>
  5194. <th class="taC">注册电话</th><td>' . $detail ['phone'] . '</td>
  5195. </tr>
  5196. <tr>
  5197. <th class="taC">开户银行</th><td>' . $detail ['bank'] . '</td>
  5198. <th class="taC">银行账号</th><td>' . $detail ['bankAccount'] . '</td>
  5199. </tr></tbody></table>';
  5200. if ($detail ['doPost'] == 1)
  5201. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th colspan="4" class="taC">邮寄信息</th></tr><tr>
  5202. <th class="taC" width="150">收件人</th><td>' . $detail ['recipients'] . '</td>
  5203. <th class="taC" width="150">收件人手机/电话</th><td>' . $detail ['recipientsPhone'] . '</td>
  5204. </tr><tr>
  5205. <th class="taC" width="150">收件地址</th><td colspan="3">' . $detail ['recipientsAddress'] . '</td>
  5206. </tr><tr>
  5207. <th class="taC" width="150">邮寄物品</th><td colspan="3">' . $detail ['mailItems'] . '</td>
  5208. </tr></tbody></table>';
  5209. if (! empty ( $invoiceOperationLogList )) {
  5210. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th width="60%" class="taC">审批流程</th><th class="taC">发票打印</th></tr><tr><td>';
  5211. foreach ( $invoiceOperationLogList as $key => $value ) {
  5212. if ($value ['status'] == 1 || $value ['status'] == 2 || $value ['status'] == 3 || $value ['status'] == 4) {
  5213. $html .= '<blockquote><p><span class="colGray">' . $value ['date'] . '</span>&nbsp;
  5214. ' . $value ['category'] . '-' . $value ['username'] . '&nbsp;';
  5215. if ($value ['status'] == 2) {
  5216. $html .= '<span class="colGreen">同意</span>';
  5217. } elseif ($value ['status'] == 3) {
  5218. $html .= '<span class="colOrange">退回</span>';
  5219. } elseif ($value ['status'] == 5) {
  5220. $html .= '<span class="colGreen">打印</span>';
  5221. } elseif ($value ['status'] == 4) {
  5222. $html .= '<span class="colRed">终止</span>';
  5223. }
  5224. $html .= $value ['operation'] . '</p></blockquote>';
  5225. }
  5226. }
  5227. $html .= '</td>
  5228. <td><span class="colRed">*</span>
  5229. <select name="invoiceNo" id="invoiceNo" style="width:97%">';
  5230. foreach ( $invoicePaperList as $key => $value ) {
  5231. $html .= '<option value="' . $value ['ipidKey'] . '">No.' . $value ['invoiceNo'] . '</option>';
  5232. }
  5233. $html .= '</select>
  5234. <span class="red" id="p-msg"></span>
  5235. </td>
  5236. </tr></tbody></table>';
  5237. }
  5238. $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>
  5239. </div></div></form>
  5240. <link rel=stylesheet href="' . WEB_SITE_GLOBAL . 'css/jquery.validator.css">
  5241. <script type="text/javascript" src="' . WEB_SITE_GLOBAL . 'js/jquery.validator.min.js"></script>
  5242. <script type="text/javascript" src="' . WEB_SITE_GLOBAL . 'js/zh-CN.js"></script>
  5243. <script src="' . WEB_SITE_GLOBAL . 'js/invoice.validator.js"></script>
  5244. ';
  5245. }
  5246. echo json_encode ( array (
  5247. 'status' => 1,
  5248. 'html' => $html
  5249. ) );
  5250. die ();
  5251. }
  5252. /**
  5253. * @ 获得与我有关收款数据 --需求变更 废弃 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 ) ); }
  5254. */
  5255. function ajaxGetInvoiceInfoByType() {
  5256. $type = $this->get_args ( 'type' ) ? $this->get_args ( 'type' ) : "";
  5257. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  5258. $loss = $this->get_args ( 'loss' ) ? $this->get_args ( 'loss' ) : false;
  5259. if (empty ( $serial )) {
  5260. echo json_encode ( array (
  5261. 'status' => 2,
  5262. 'msg' => 'illegal request'
  5263. ) );
  5264. die ();
  5265. }
  5266. if ($type == 'INVOICE') {
  5267. Doo::loadModel ( 'invoice' );
  5268. $invoice = new invoice ();
  5269. Doo::loadModel ( 'invoiceOperationLog' );
  5270. $invoiceOperationLog = new invoiceOperationLog ();
  5271. $detail = $invoice->getInvoiceByIsid ( $serial, $this->staff [0] ['sid'] );
  5272. $invoiceOperationLogList = $invoiceOperationLog->getInvoiceOperationLogByIid ( $detail ['iid'] );
  5273. if (empty ( $detail ))
  5274. $html = '';
  5275. else {
  5276. $html = '
  5277. <div class="modal-dialog modal-lg">
  5278. <div class="modal-content"><div class="modal-header"><h3>发票单详情</h3></div>
  5279. <div class="modal-body saeaList"><table class="table table-bordered table-condensed"><tbody>
  5280. <tr>
  5281. <th class="taC" width="150">开票流水号</th><td>' . $detail ['invoiceSerial'] . '</td>
  5282. <th class="taC" width="150">提交时间</th><td>' . $detail ['date'] . '</td>
  5283. </tr>
  5284. <tr>
  5285. <th class="taC" width="150">所在办事处</th><td>' . $detail ['categoryName'] . '(' . $detail ['userName'] . ')</td>
  5286. <th class="taC" width="150">开票内容</th><td>' . $detail ['invoiceElement'] . '</td>
  5287. </tr>
  5288. <tr>
  5289. <th class="taC">发票备注</th><td colspan="3">' . $detail ['remark'] . '
  5290. </td>
  5291. </tr>
  5292. <tr>
  5293. <th class="taC" width="150">数量</th><td><b>' . $detail ['invoiceQuantity'] . '</b></td>
  5294. <th class="taC">单价</th><td><b>¥' . $detail ['invoiceUnitPrice'] . '</b></td>
  5295. </tr>
  5296. <tr>
  5297. <th class="taC">开票金额</th><td colspan="3"><b class="colOrange" style="font-size:18px">¥' . $detail ['invoicePrice'] . '</b></td>
  5298. </tr></tbody></table>';
  5299. if ($detail ['invoiceType'] == 0)
  5300. $html .= '<table class="table table-bordered table-condensed"><tbody>
  5301. <tr><th colspan="4" class="taC">增值税普通发票</th></tr><tr>
  5302. <th class="taC" width="150">发票抬头</th><td >' . $detail ['invoiceTitle'] . '</td>
  5303. <th class="taC" width="150">纳税人识别码</th><td>' . $detail ['TIN'] . '</td>
  5304. </tr>';
  5305. else
  5306. $html .= '<table class="table table-bordered table-condensed"><tbody>
  5307. <tr><th colspan="4" class="taC">增值税专用发票</th></tr><tr>
  5308. <th class="taC" width="150">单位名称</th><td>' . $detail ['invoiceCompany'] . '</td>
  5309. <th class="taC" width="150">纳税人识别码</th><td>' . $detail ['TIN'] . '</td></tr>
  5310. ';
  5311. $html .= '<tr>
  5312. <th class="taC">注册地址</th><td>' . $detail ['address'] . '</td>
  5313. <th class="taC">注册电话</th><td>' . $detail ['phone'] . '</td>
  5314. </tr>
  5315. <tr>
  5316. <th class="taC">开户银行</th><td>' . $detail ['bank'] . '</td>
  5317. <th class="taC">银行账号</th><td>' . $detail ['bankAccount'] . '</td>
  5318. </tr></tbody></table>';
  5319. if ($detail ['doPost'] == 1) {
  5320. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th colspan="4" class="taC">邮寄信息</th></tr><tr>
  5321. <th class="taC" width="150">收件人</th><td>' . $detail ['recipients'] . '</td>
  5322. <th class="taC" width="150">收件人手机/电话</th><td>' . $detail ['recipientsPhone'] . '</td>
  5323. </tr><tr>
  5324. <th class="taC" width="150">收件地址</th><td colspan="3">' . $detail ['recipientsAddress'] . '</td>
  5325. </tr><tr>
  5326. <th class="taC" width="150">邮寄物品</th><td colspan="3">' . $detail ['mailItems'] . '</td>
  5327. </tr>
  5328. ';
  5329. if ($detail ['expressCom'] == 'SF')
  5330. $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>';
  5331. else
  5332. $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>';
  5333. $html .= '</tbody></table>';
  5334. }
  5335. if (! empty ( $invoiceOperationLogList )) {
  5336. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th width="60%" class="taC">审批流程</th></tr><tr><td>';
  5337. foreach ( $invoiceOperationLogList as $key => $value ) {
  5338. if ($value ['status'] == 1 || $value ['status'] == 2 || $value ['status'] == 3 || $value ['status'] == 4) {
  5339. $html .= '<blockquote><p><span class="colGray">' . $value ['date'] . '</span>&nbsp;
  5340. ' . $value ['category'] . '-' . $value ['username'] . '&nbsp;';
  5341. if ($value ['status'] == 2) {
  5342. $html .= '<span class="colGreen">同意</span>';
  5343. } elseif ($value ['status'] == 3) {
  5344. $html .= '<span class="colOrange">退回</span>';
  5345. } elseif ($value ['status'] == 5) {
  5346. $html .= '<span class="colGreen">打印</span>';
  5347. } elseif ($value ['status'] == 4) {
  5348. $html .= '<span class="colRed">终止</span>';
  5349. }
  5350. $html .= $value ['operation'] . '</p></blockquote>';
  5351. }
  5352. }
  5353. $html .= '</td></tr></tbody></table>';
  5354. }
  5355. $html .= '</div><div class="modal-footer"><a href="#" class="button btn-gray" data-dismiss="modal" aria-hidden="true">关闭</a></div></div></div>';
  5356. }
  5357. echo json_encode ( array (
  5358. 'status' => 1,
  5359. 'html' => $html
  5360. ) );
  5361. die ();
  5362. } elseif ($type == 'RECEIVABLES') {
  5363. Doo::loadModel ( 'invoiceReceivables' );
  5364. $invoiceReceivables = new invoiceReceivables ();
  5365. Doo::loadModel ( 'invoiceRefund' );
  5366. $invoiceRefund = new invoiceRefund ();
  5367. $detail = $invoiceReceivables->getInvoiceReceivablesByIrsid ( $serial );
  5368. $ireList = $invoiceRefund->getInvoiceRefundIrid ( $detail ['irid'] );
  5369. if (empty ( $detail ))
  5370. $html = '';
  5371. else {
  5372. $html = '<div class="modal-dialog modal-lg"><div class="modal-content"><div class="modal-header"><h3>收款单详情</h3></div><div class="modal-body saeaList">
  5373. <table class="table table-bordered table-condensed">
  5374. <tbody><tr>
  5375. <th class="taC">收款流水号</th><td>' . $detail ['receivablesSerial'] . '</td>
  5376. <th class="taC">录入收款</th><td>' . $detail ['inputStaff'] . ' ' . $detail ['date'] . '</td>
  5377. </tr><tr>
  5378. <th class="taC">收款金额</th><td><b>¥' . $detail ['receivablesPrice'] . '</b></td>
  5379. <th class="taC">收款信息</th><td>' . $detail ['receivablesMessage'] . '</td>
  5380. </tr>
  5381. <tr>
  5382. <th class="taC">收款银行</th><td>' . $detail ['receivablesBank'] . '</td>
  5383. <th class="taC">银行到账</th><td>' . $detail ['receivablesDate'] . '</td>
  5384. </tr>
  5385. <tr>
  5386. <th class="taC">认领收款</th><td colspan="3">' . $detail ['inputStaff'] . ' 转入 ' . $detail ['username'] . ' ' . $detail ['confirmTime'] . '</td>
  5387. </tr>
  5388. </tbody></table>';
  5389. if (! empty ( $ireList )) {
  5390. $html .= '
  5391. <table class="table table-bordered table-condensed"><tbody><tr><th class="taC" colspan="2">退款记录</th></tr>';
  5392. foreach ( $ireList as $key => $value ) {
  5393. $refundLogList=explode("<br/>",$value['refundLog']);
  5394. $html .= '
  5395. <tr>
  5396. <th class="taC">退款单位名称</th><td>' . $value ['refundCompany'] . '</td>
  5397. </tr>
  5398. <tr>
  5399. <th class="taC">退款的账号</th><td>' . $value ['refundNumber'] . '</td>
  5400. </tr>
  5401. <tr>
  5402. <th class="taC">退款金额</th><td class="colRed">¥' . $value ['refundPrice'] . '</td>
  5403. </tr>
  5404. <tr>
  5405. <th class="taC">退款</th><td>' . $refundLogList [0].$refundLogList [2] . '</td>
  5406. </tr>
  5407. ';
  5408. }
  5409. }
  5410. $html .= '</tbody></table></div><div class="modal-footer"><a href="#" class="button btn-gray" data-dismiss="modal" aria-hidden="true">关闭</a></div></div></div>';
  5411. }
  5412. echo json_encode ( array (
  5413. 'status' => 1,
  5414. 'html' => $html
  5415. ) );
  5416. die ();
  5417. } elseif ($type == 'IRTC') {
  5418. Doo::loadModel ( 'invoice' );
  5419. $invoice = new invoice ();
  5420. Doo::loadModel ( 'invoiceOperationLog' );
  5421. $invoiceOperationLog = new invoiceOperationLog ();
  5422. Doo::loadModel ( 'invoiceReceivables' );
  5423. $invoiceReceivables = new invoiceReceivables ();
  5424. $detail = $invoice->getInvoiceByIsid ( $serial, $this->staff [0] ['sid'] );
  5425. $invoiceOperationLogList = $invoiceOperationLog->getInvoiceOperationLogByIid ( $detail ['iid'] );
  5426. if (empty ( $detail ))
  5427. $html = '';
  5428. else {
  5429. $receivablesPriceedHtml = '';
  5430. $receivablesPrice = $detail ['invoicePrice'];
  5431. if (! empty ( $detail ['irid'] )) {
  5432. $irList = $invoiceReceivables->getInvoiceReceivablesInIridString ( $detail ['irid'] );
  5433. if (empty ( $irList ))
  5434. $irList [0] ['sumPrice'] = 0;
  5435. $balance = $detail ['invoicePrice'] - $irList [0] ['sumPrice'];
  5436. $receivablesPriceedHtml = '<table class="table table-bordered table-condensed"><tbody><tr>
  5437. <th class="taC">已入账金额</th><td><b class="colGreen" style="font-size:18px">¥' . $irList [0] ['sumPrice'] . '</b></td>
  5438. <th class="taC">剩余入账金额</th><td><b class="colRed" style="font-size:18px">¥' . $balance . '</b></td>
  5439. </tr></tbody></table>';
  5440. $receivablesPrice = $balance;
  5441. }
  5442. if ($loss)
  5443. $detail ['invoicePrice'] = - $detail ['invoicePrice'];
  5444. $html = $receivablesPriceedHtml . '
  5445. <table class="table table-bordered table-condensed"><tbody>
  5446. <tr>
  5447. <th class="taC" width="150">开票流水号</th><td>' . $detail ['invoiceSerial'] . '</td>
  5448. <th class="taC" width="150">提交时间</th><td>' . $detail ['date'] . '</td>
  5449. </tr>
  5450. <tr>
  5451. <th class="taC" width="150">所在办事处</th><td>' . $detail ['categoryName'] . '(' . $detail ['userName'] . ')</td>
  5452. <th class="taC" width="150">开票内容</th><td>' . $detail ['invoiceElement'] . '</td>
  5453. </tr>
  5454. <tr>
  5455. <th class="taC" width="150">发票备注</th><td colspan="3">' . $detail ['remark'] . '</td>
  5456. </tr>
  5457. <tr>
  5458. <th class="taC" width="150">数量</th><td><b>' . $detail ['invoiceQuantity'] . '</b></td>
  5459. <th class="taC">单价</th><td><b>¥' . $detail ['invoiceUnitPrice'] . '</b></td>
  5460. </tr>
  5461. <tr>
  5462. <th class="taC">开票金额</th><td colspan="3"><b class="colOrange" style="font-size:18px">¥' . $detail ['invoicePrice'] . '</b></td>
  5463. </tr></tbody></table>';
  5464. if ($detail ['invoiceType'] == 0) {
  5465. $html .= '<table class="table table-bordered table-condensed"><tbody>
  5466. <tr><th colspan="4" class="taC">增值税普通发票</th></tr><tr>
  5467. <th class="taC" width="150">发票抬头</th><td >' . $detail ['invoiceTitle'] . '</td>
  5468. <th class="taC" width="150">纳税人识别码</th><td>' . $detail ['TIN'] . '</td>
  5469. </tr>';
  5470. $receivablesMessage = $detail ['invoiceTitle'];
  5471. } else {
  5472. $html .= '<table class="table table-bordered table-condensed"><tbody>
  5473. <tr><th colspan="4" class="taC">增值税专用发票</th></tr><tr>
  5474. <th class="taC" width="150">单位名称</th><td>' . $detail ['invoiceCompany'] . '</td>
  5475. <th class="taC" width="150">纳税人识别码</th><td>' . $detail ['TIN'] . '</td></tr>
  5476. ';
  5477. $receivablesMessage = $detail ['invoiceCompany'];
  5478. }
  5479. $html .= '<tr>
  5480. <th class="taC">注册地址</th><td>' . $detail ['address'] . '</td>
  5481. <th class="taC">注册电话</th><td>' . $detail ['phone'] . '</td>
  5482. </tr>
  5483. <tr>
  5484. <th class="taC">开户银行</th><td>' . $detail ['bankAccount'] . '</td>
  5485. <th class="taC">银行账号</th><td>' . $detail ['bank'] . '</td>
  5486. </tr></tbody></table>';
  5487. if ($detail ['doPost'] == 1)
  5488. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th colspan="4" class="taC">邮寄信息</th></tr><tr>
  5489. <th class="taC" width="150">收件人</th><td>' . $detail ['recipients'] . '</td>
  5490. <th class="taC" width="150">收件人手机/电话</th><td>' . $detail ['recipientsPhone'] . '</td>
  5491. </tr><tr>
  5492. <th class="taC" width="150">收件地址</th><td colspan="3">' . $detail ['recipientsAddress'] . '</td>
  5493. </tr><tr>
  5494. <th class="taC" width="150">邮寄物品</th><td colspan="3">' . $detail ['mailItems'] . '</td>
  5495. </tr></tbody></table>';
  5496. if (! empty ( $invoiceOperationLogList )) {
  5497. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th width="60%" class="taC">审批流程</th></tr><tr><td>';
  5498. foreach ( $invoiceOperationLogList as $key => $value ) {
  5499. if ($value ['status'] == 1 || $value ['status'] == 2 || $value ['status'] == 3 || $value ['status'] == 4) {
  5500. $html .= '<blockquote><p><span class="colGray">' . $value ['date'] . '</span>&nbsp;
  5501. ' . $value ['category'] . '-' . $value ['username'] . '&nbsp;';
  5502. if ($value ['status'] == 2) {
  5503. $html .= '<span class="colGreen">同意</span>';
  5504. } elseif ($value ['status'] == 3) {
  5505. $html .= '<span class="colOrange">退回</span>';
  5506. } elseif ($value ['status'] == 5) {
  5507. $html .= '<span class="colGreen">打印</span>';
  5508. }
  5509. $html .= $value ['operation'] . '</p></blockquote>';
  5510. }
  5511. }
  5512. $html .= '</td></tr></tbody></table>';
  5513. }
  5514. }
  5515. echo json_encode ( array (
  5516. 'status' => 1,
  5517. 'html' => $html,
  5518. 'receivablesPrice' => $receivablesPrice,
  5519. 'receivablesMessage' => $receivablesMessage,
  5520. 'receivablesDate' => date ( "Y-m-d" ),
  5521. 'iidKey' => $serial
  5522. ) );
  5523. die ();
  5524. }
  5525. }
  5526. function ajaxGetInvoiceReceivablesByStaff() {
  5527. $postData = $this->get_args ( 'postData' ) ? $this->get_args ( 'postData' ) : "";
  5528. if (empty ( $postData )) {
  5529. echo json_encode ( array (
  5530. 'status' => 2,
  5531. 'msg' => 'illegal request'
  5532. ) );
  5533. die ();
  5534. }
  5535. Doo::loadModel ( 'invoiceReceivables' );
  5536. $invoiceReceivables = new invoiceReceivables ();
  5537. $detail = $invoiceReceivables->getInvoiceReceivablesByIrid ( $postData );
  5538. if (empty ( $detail )) {
  5539. echo json_encode ( array (
  5540. 'status' => 2,
  5541. 'msg' => 'illegal request'
  5542. ) );
  5543. die ();
  5544. }
  5545. Doo::loadModel ( 'L_category' );
  5546. $lCategory = new L_category ();
  5547. Doo::loadModel ( 'staff' );
  5548. $staff = new staff ();
  5549. $staffList = $staff->getStaffByCid ( $detail ['cid'] );
  5550. $category = $lCategory->getCategory ();
  5551. $categoryHtml = '<option post-data="PUBLIC" value="PUBLIC" >公共待认领款项</option>';
  5552. $staffHtml = '<option value="PUBLIC">办事处待认领款项</option>';
  5553. foreach ( $category as $key => $value ) {
  5554. $categoryHtml .= '<option post-data="' . $value ['cid'] . '" value="' . $value ['cid'] . ':' . $value ['title'] . '" >' . $value ['title'] . '</option>';
  5555. if ($value ['cid'] == $detail ['cid'])
  5556. $categoryHtml .= '<option selected post-data="' . $value ['cid'] . '" value="' . $value ['cid'] . ':' . $value ['title'] . '" >' . $value ['title'] . '</option>';
  5557. }
  5558. foreach ( $staffList as $key => $value ) {
  5559. $staffHtml .= '<option value="' . $value ['sid'] . '-' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  5560. if ($value ['sid'] == $detail ['sid'])
  5561. $staffHtml .= '<option selected value="' . $value ['sid'] . '-' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  5562. }
  5563. $rbankHtml = '<option value="广发银行珠海分行柠溪支行">广发银行珠海分行柠溪支行</option>';
  5564. echo json_encode ( array (
  5565. 'status' => 1,
  5566. 'categoryHtml' => $categoryHtml,
  5567. 'staffHtml' => $staffHtml,
  5568. 'rbankHtml' => $rbankHtml,
  5569. 'detail' => $detail
  5570. ) );
  5571. }
  5572. function ajaxGetInvoiceReceivablesByIrid() {
  5573. $irid = $this->get_args ( 'irid' ) ? $this->get_args ( 'irid' ) : "";
  5574. if (empty ( $irid )) {
  5575. echo json_encode ( array (
  5576. 'status' => 2,
  5577. 'msg' => 'illegal request'
  5578. ) );
  5579. die ();
  5580. }
  5581. Doo::loadModel ( 'invoiceReceivables' );
  5582. $invoiceReceivables = new invoiceReceivables ();
  5583. Doo::loadModel ( 'invoice' );
  5584. $invoice = new invoice ();
  5585. $detail = $invoiceReceivables->getInvoiceReceivablesByIrid ( $irid ); // 入账完成 待定 and postStatus=1
  5586. $flag = true;
  5587. $invoiceDetail = $invoice->getInvoiceByTitle ( $detail ['recepitTitleMark'], 'EXACTLY', " and status=2 and printStatus=1 and untreadStatus=0 ", $flag ); //
  5588. $bakDetail = array ();
  5589. if ($flag === false) {
  5590. array_push ( $bakDetail, $invoiceDetail );
  5591. $invoiceDetail = $bakDetail;
  5592. }
  5593. $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>
  5594. <tr>
  5595. <td><b>¥' . $detail ['receivablesPrice'] . '</b></td>
  5596. <td>' . $detail ['receivablesMessage'] . '</td>
  5597. <td>' . $detail ['receivablesBank'] . '<br>' . $detail ['receivablesDate'] . '</td>
  5598. <td>' . $detail ['title'] . '-' . $detail ['username'] . '<br>' . $detail ['confirmTime'] . '</td>
  5599. <td>' . $detail ['recepitTitleMark'] . '</td>
  5600. </tr></tbody></table>';
  5601. $isInvoice = false;
  5602. $invoiceHtml = '';
  5603. if (empty ( $invoiceDetail )) {
  5604. $isInvoice = true;
  5605. } else {
  5606. $invoiceHtml = '<table class="table table-bordered table-condensed">
  5607. <thead><tr><th>开票单位(抬头)</th><th>开票金额</th><th>提交开票</th><th>出票</th><th>开票流水号</th><th width="80">入账</th></tr></thead><tbody>';
  5608. foreach ( $invoiceDetail as $key => $value ) {
  5609. $invoiceHtml .= '<tr>';
  5610. if (! empty ( $value ['invoiceType'] )) {
  5611. $invoiceHtml .= '<td>' . $value ['invoiceCompany'] . '</td>';
  5612. } else {
  5613. $invoiceHtml .= '<td>' . $value ['invoiceTitle'] . '</td>';
  5614. }
  5615. if (! empty ( $value ['invoiceType'] )) {
  5616. $invoiceHtml .= '<td>' . $value ['invoicePrice'] . '专</td>';
  5617. } else {
  5618. $invoiceHtml .= '<td>' . $value ['invoicePrice'] . '</td>';
  5619. }
  5620. $invoiceHtml .= '
  5621. <td>' . $value ['categoryName'] . $value ['userName'] . ' ' . $value ['date'] . '</td>
  5622. <td>' . $value ['printer'] . ' ' . $value ['printTime'] . '</td>
  5623. <td>' . $value ['invoiceSerial'] . '</td><td><a class="button btn-block" bind-receivables="ir" data-ikey="' . $value ['iidKey'] . '" href="javascript:void(0)">入账</a></td>
  5624. </tr>
  5625. ';
  5626. $irList = $invoiceReceivables->getInvoiceReceivablesInIridString ( $value ['irid'] );
  5627. if (empty ( $irList ))
  5628. $irList [0] ['sumPrice'] = 0;
  5629. $balance = $value ['invoicePrice'] - $irList [0] ['sumPrice'];
  5630. $priceString = '';
  5631. if ($balance < $detail ['receivablesPrice']) {
  5632. $priceString = '收款金额超过开票金额,';
  5633. }
  5634. if ($balance > $detail ['receivablesPrice']) {
  5635. $priceString = '收款金额低于开票金额,';
  5636. }
  5637. }
  5638. $invoiceHtml .= '
  5639. <script>
  5640. $(\'a[bind-receivables^="ir"]\').click(function() {
  5641. var data = $(this).attr("data-ikey");
  5642. $("input[name=\'invoiceKey\']").val(data);
  5643. var invoiceKey=data;
  5644. if(invoiceKey==""){
  5645. alert("入账错误,请重新刷新页面");
  5646. return false;
  5647. }
  5648. if(window.confirm("' . $priceString . '确定入账吗?")){
  5649. $("#IBR").submit();
  5650. }else{
  5651. return false;
  5652. }
  5653. });
  5654. </script>
  5655. ';
  5656. $invoiceHtml .= '</tbody></table>';
  5657. }
  5658. echo json_encode ( array (
  5659. 'status' => 1,
  5660. 'irkey' => $detail ['iridEn'],
  5661. 'receivablesHtml' => $receivablesHtml,
  5662. 'isInvoice' => $isInvoice,
  5663. 'invoiceHtml' => $invoiceHtml
  5664. ) );
  5665. }
  5666. function ajaxGetInvoiceReceivablesByTitle() {
  5667. $title = $this->get_args ( 'title' ) ? $this->get_args ( 'title' ) : "";
  5668. if (empty ( $title )) {
  5669. echo json_encode ( array (
  5670. 'status' => 2,
  5671. 'msg' => 'illegal request'
  5672. ) );
  5673. die ();
  5674. }
  5675. Doo::loadModel ( 'invoice' );
  5676. $invoice = new invoice ();
  5677. $invoiceDetail = $invoice->getInvoiceByTitle ( $title, 'FUZZY', " and status=2 and printStatus=1 and untreadStatus=0 and irid='' ", true );
  5678. $invoiceHtml = '';
  5679. if (! empty ( $invoiceDetail )) {
  5680. $invoiceHtml = '<table class="table table-bordered table-condensed">
  5681. <thead><tr><th>开票单位(抬头)</th><th>开票金额</th><th>提交开票</th><th>出票</th><th>开票流水号</th><th width="80">入账</th></tr></thead><tbody><tr>';
  5682. foreach ( $invoiceDetail as $key => $value ) {
  5683. if (! empty ( $value ['invoiceType'] )) {
  5684. $invoiceHtml .= '<td>' . $value ['invoiceCompany'] . '</td>';
  5685. } else {
  5686. $invoiceHtml .= '<td>' . $value ['invoiceTitle'] . '</td>';
  5687. }
  5688. if (! empty ( $value ['invoiceType'] )) {
  5689. $invoiceHtml .= '<td>' . $value ['invoicePrice'] . '专</td>';
  5690. } else {
  5691. $invoiceHtml .= '<td>' . $value ['invoicePrice'] . '</td>';
  5692. }
  5693. $invoiceHtml .= '
  5694. <td>' . $value ['categoryName'] . $value ['userName'] . ' ' . $value ['date'] . '</td>
  5695. <td>' . $value ['printer'] . ' ' . $value ['printTime'] . '</td>
  5696. <td>' . $value ['invoiceSerial'] . '</td><td><a class="button btn-block" bind-receivables="ir' . $value ['iidKeyXD'] . '" data-ikey="' . $value ['iidKey'] . '" href="#">入账</a></td>
  5697. </tr>
  5698. ';
  5699. }
  5700. $invoiceHtml .= '</tbody></table>
  5701. <script>
  5702. $(\'a[bind-receivables^="ir"]\').click(function() {
  5703. var data = $(this).attr("data-ikey");
  5704. $("input[name=\'invoiceKey\']").val(data);
  5705. var invoiceKey=$("input[name=\'invoiceKey\']").val();
  5706. if(invoiceKey==""){
  5707. alert("入账错误,请重新刷新页面");
  5708. return false;
  5709. }
  5710. if(window.confirm("确定入账吗?")){
  5711. $("#IBR").submit();
  5712. }else{
  5713. return false;
  5714. }
  5715. });
  5716. </script>
  5717. ';
  5718. }
  5719. echo json_encode ( array (
  5720. 'status' => 1,
  5721. 'invoiceHtml' => $invoiceHtml
  5722. ) );
  5723. }
  5724. function ajaxInvoicePushNotice() {
  5725. Doo::loadModel ( 'invoice' );
  5726. $invoice = new invoice ();
  5727. $approval = $invoice->getOne ( array (
  5728. 'where' => 'status=1 and pendingApprovals=' . $this->staff [0] ['sid'],
  5729. 'desc' => 'iid',
  5730. 'asArray' => true
  5731. ) );
  5732. $isNotice = false;
  5733. if (! empty ( $approval ))
  5734. $isNotice = true;
  5735. $response = array (
  5736. 'error' => 0,
  5737. 'isNotice' => $isNotice
  5738. );
  5739. echo json_encode ( $response );
  5740. exit ();
  5741. }
  5742. public function ajaxCheckInvoiceNoUniqueness() {
  5743. $invoiceNo = $this->get_args ( 'invoiceNo' ) ? $this->get_args ( 'invoiceNo' ) : "";
  5744. Doo::loadModel ( 'invoice' );
  5745. $invoice = new invoice ();
  5746. if (! empty ( $invoiceNo )) {
  5747. Doo::loadModel ( 'invoicePaper' );
  5748. $invoicePaper = new invoicePaper ();
  5749. Doo::loadClass ( 'XDeode' );
  5750. $XDeode = new XDeode ( 5 );
  5751. $ipid = $XDeode->decode ( $invoiceNo );
  5752. $paperDetail = $invoicePaper->getInvoicePaperByIpid ( $ipid );
  5753. $info = $invoice->getOne ( array (
  5754. 'where' => "invoiceNo = '" . $paperDetail ['invoiceNo'] . "'",
  5755. 'asArray' => TRUE
  5756. ) );
  5757. if (! empty ( $info )) {
  5758. echo json_encode ( array (
  5759. 'error' => '发票号已存在'
  5760. ) );
  5761. die ();
  5762. } else
  5763. echo json_encode ( array (
  5764. 'ok' => '可以使用!'
  5765. ) );
  5766. die ();
  5767. }
  5768. }
  5769. function ajaxCheckInvoicePrice() {
  5770. $receivablesPrice = $this->get_args ( 'receivablesPrice' ) && is_numeric ( $this->get_args ( 'receivablesPrice' ) ) ? $this->get_args ( 'receivablesPrice' ) : "";
  5771. $iidKey = $this->get_args ( 'iidKey' ) ? $this->get_args ( 'iidKey' ) : "";
  5772. Doo::loadModel ( 'invoice' );
  5773. $invoice = new invoice ();
  5774. Doo::loadModel ( 'invoiceReceivables' );
  5775. $invoiceReceivables = new invoiceReceivables ();
  5776. Doo::loadClass ( 'XDeode' );
  5777. $XDeode = new XDeode ( 5 );
  5778. if (! empty ( $receivablesPrice ) && ! empty ( $iidKey )) {
  5779. $iidKey = $XDeode->decode ( $iidKey );
  5780. $info = $invoice->getInvoiceByIid ( $iidKey );
  5781. $irList = $invoiceReceivables->getInvoiceReceivablesInIridString ( $info ['irid'] );
  5782. if (empty ( $irList ))
  5783. $irList [0] ['sumPrice'] = 0;
  5784. $balance = $info ['invoicePrice'] - $irList [0] ['sumPrice'];
  5785. if ($balance < $receivablesPrice) {
  5786. echo json_encode ( array (
  5787. 'error' => '收款金额超过开票金额。'
  5788. ) );
  5789. die ();
  5790. }
  5791. if ($balance > $receivablesPrice) {
  5792. echo json_encode ( array (
  5793. 'error' => '收款金额低于开票金额。'
  5794. ) );
  5795. die ();
  5796. }
  5797. }
  5798. }
  5799. /**
  5800. * 旧输入导入
  5801. */
  5802. function importInvoice() {
  5803. $emsg = isset ( $this->params ['emsg'] ) ? $this->params ['emsg'] : "";
  5804. $data ['emsg'] = "";
  5805. if ($emsg != "")
  5806. $data ['emsg'] = "请填写完整的数据";
  5807. $data ['time'] = time ();
  5808. $this->render ( "/admin/invoiceImport", $data );
  5809. }
  5810. function uploadInvoice() {
  5811. // move_uploaded_file($_FILES['Filedata']['tmp_name'], "/upload/".$_FILES['Filedata']['name']);
  5812. if (isset ( $_FILES ['Filedata'] ['name'] )) {
  5813. $file = $_FILES ['Filedata'] ['tmp_name'];
  5814. $error = false;
  5815. if (! is_uploaded_file ( $file )) {
  5816. $error = '400 Bad Request';
  5817. }
  5818. if ($error) {
  5819. header ( 'HTTP/1.0 ' . $error );
  5820. die ( 'Error ' . $error );
  5821. } else {
  5822. include (DOO::conf ()->SITE_PATH . 'protected/plugin/io.han.php');
  5823. $this->IoHandler = new IoHandler ();
  5824. $pics = explode ( '.', $_FILES ['Filedata'] ['name'] );
  5825. // $filedir=$_POST['time'];
  5826. // 调用定义物理路径
  5827. $t = DOO::conf ()->SITE_PATH . "upload/invoice/";
  5828. $this->IoHandler->MakeDir ( $t );
  5829. $filename = $this->_GetFileEXT ( $_FILES ['Filedata'] ['name'] );
  5830. if ($filename != 'xlsx')
  5831. return "";
  5832. // $upload_dir = $t."/".time().rand(10,100).".".$filename;
  5833. $upload_file = iconv ( "UTF-8", "GB2312", $_FILES ["Filedata"] ["name"] );
  5834. $upload_dir = $t . "/" . $upload_file;
  5835. $k = move_uploaded_file ( $file, $upload_dir );
  5836. if ($k) {
  5837. $m = round ( $_FILES ['Filedata'] ['size'] / 1024 / 1024, 2 );
  5838. echo $pics [0] . "." . $filename . "#" . $m . "#" . $_FILES ['Filedata'] ['size'];
  5839. }
  5840. }
  5841. }
  5842. }
  5843. function importInvoiceDo() {
  5844. $path = $this->get_args ( 'path' ) ? $this->get_args ( 'path' ) : "";
  5845. if ($path != "") {
  5846. Doo::loadModel ( 'invoice' );
  5847. Doo::loadModel ( 'staff' );
  5848. $staff = new staff ();
  5849. Doo::loadModel ( 'invoiceStatistics' );
  5850. Doo::loadModel ( 'invoiceOperationLog' );
  5851. echo DOO::conf ()->SITE_PATH . "upload/invoice/" . iconv ( "UTF-8", "GB2312", $path );
  5852. $exlArray = $this->_format_excel_to_array ( DOO::conf ()->SITE_PATH . "upload/invoice/" . $path );
  5853. // print_r ( $exlArray );
  5854. // die ();
  5855. // echo json_encode($exlArray);die;
  5856. foreach ( $exlArray as $key => $value ) {
  5857. // 开票
  5858. $invoice = new invoice ();
  5859. $invoice->invoiceNo = $value ['invoiceNo'];
  5860. $invoice->invoiceType = 0;
  5861. if ($value ['invoiceType'] == '专')
  5862. $invoice->invoiceType = 1;
  5863. $invoice->invoicePrice = $value ['invoicePrice'];
  5864. $invoice->invoiceQuantity = 1;
  5865. $invoice->invoiceUnitPrice = $value ['invoicePrice'];
  5866. $invoice->invoiceTitle = $value ['invoiceTitle'];
  5867. if ($value ['invoiceType'] == '专')
  5868. $invoice->invoiceCompany = $value ['invoiceTitle'];
  5869. $invoice->userName = $value ['userName'];
  5870. $sDetail = $staff->getStaffByName ( $value ['userName'] );
  5871. $invoice->sid = $sDetail ['sid'];
  5872. $invoice->cid = $sDetail ['cid'];
  5873. $invoice->categoryName = $sDetail ['category'];
  5874. $invoice->invoiceElement = $value ['invoiceElement'];
  5875. $invoice->remark = $value ['remark'];
  5876. $invoice->date = $value ['date'];
  5877. $invoice->printTime = $value ['date'];
  5878. $invoice->ipSource = 1;
  5879. $invoice->printStatus = 1;
  5880. $invoice->status = 2;
  5881. $invoice->postStatus = 1;
  5882. $invoice->untreadStatus = 0;
  5883. $invoice->invoiceSerial = "#F" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  5884. $iid = $invoice->insert ();
  5885. // 汇总
  5886. $invoiceStatistics = new invoiceStatistics ();
  5887. //
  5888. $item = array (
  5889. 'date' => $value ['date'],
  5890. 'priceClass' => 1,
  5891. 'cid' => $sDetail ['cid'],
  5892. 'staff' => $sDetail ['sid'],
  5893. 'invoicePrice' => $value ['invoicePrice']
  5894. );
  5895. $invoiceStatistics->setInvoiceStatisticsByCondition ( $item );
  5896. $invoiceOperationLog = new invoiceOperationLog ();
  5897. $item = array (
  5898. 'date' => date ( "Y-m-d H:i:s" ),
  5899. 'operation' => date ( "Y-m-d" ) . " 导入",
  5900. 'status' => 1,
  5901. 'img' => $sDetail ['avatar'],
  5902. 'username' => $sDetail ['username'],
  5903. 'uid' => $sDetail ['sid'],
  5904. 'category' => $sDetail ['category'],
  5905. 'iid' => $iid
  5906. );
  5907. $invoiceOperationLog->setInvoiceOperationLog ( $item );
  5908. }
  5909. return '/importInvoice?count=' . count ( $exlArray );
  5910. // return "/keyonline";
  5911. }
  5912. echo 'no file';
  5913. }
  5914. function importInvoiceReceivables() {
  5915. $emsg = isset ( $this->params ['emsg'] ) ? $this->params ['emsg'] : "";
  5916. $data ['emsg'] = "";
  5917. if ($emsg != "")
  5918. $data ['emsg'] = "请填写完整的数据";
  5919. $data ['time'] = time ();
  5920. $this->render ( "/admin/invoiceReceivablesImport", $data );
  5921. }
  5922. // 导入入账数据
  5923. function importInvoiceReceivablesDo() {
  5924. $path = $this->get_args ( 'path' ) ? $this->get_args ( 'path' ) : "";
  5925. // include Doo::conf ()->BASE_PATH . 'diagnostic/debug.php';
  5926. if ($path != "") {
  5927. Doo::loadModel ( 'invoiceReceivables' );
  5928. Doo::loadModel ( 'invoice' );
  5929. Doo::loadModel ( 'staff' );
  5930. $staff = new staff ();
  5931. Doo::loadModel ( 'invoiceStatistics' );
  5932. // echo DOO::conf ()->SITE_PATH . "upload/invoice/" . iconv ( "UTF-8", "GB2312", $path );
  5933. $exlArray = $this->_format_excel_to_array ( DOO::conf ()->SITE_PATH . "upload/invoice/" . iconv ( "UTF-8", "GB2312", $path ), 'invoiceReceivables' );
  5934. // print_r ( $exlArray );
  5935. // die ();
  5936. // echo json_encode($exlArray);die;
  5937. foreach ( $exlArray as $key => $value ) {
  5938. // 收款
  5939. $invoiceReceivables = new invoiceReceivables ();
  5940. $invoice = new invoice ();
  5941. $invoiceReceivables->bindStatus = 1;
  5942. $invoiceReceivables->receivablesPrice = $value ['receivablesPrice'];
  5943. $invoiceReceivables->receivablesMessage = $value ['receivablesMessage'];
  5944. $invoiceReceivables->receivablesBank = $value ['receivablesBank'];
  5945. $invoiceReceivables->receivablesDate = $value ['receivablesDate'];
  5946. $sDetail = $staff->getStaffByName ( $value ['receivablesStaff'] );
  5947. $invoiceReceivables->receivablesCategory = $sDetail ['cid'] . ':' . $sDetail ['category'];
  5948. $invoiceReceivables->receivablesStaff = $sDetail ['sid'] . '-' . $sDetail ['username'];
  5949. $invoiceReceivables->receivablesSerial = "#SK" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  5950. $invoiceReceivables->sourcePrice = $value ['sourcePrice'];
  5951. $iDetail = $invoice->getInvoiceByInvoiceNo ( $value ['invoiceNo'] );
  5952. $invoiceReceivables->iid = $iDetail ['iid'];
  5953. $irid = $invoiceReceivables->insert ();
  5954. // 发票绑定收款
  5955. $detail = $iDetail;
  5956. $iridString = "";
  5957. if (empty ( $detail ['irid'] ))
  5958. $iridString = $irid;
  5959. else
  5960. $iridString = $detail ['irid'] . ',' . $irid;
  5961. $item = array (
  5962. 'irid' => $iridString,
  5963. 'iid' => $detail ['iid']
  5964. );
  5965. $invoice->setInvoiceByCondition ( $item );
  5966. // 汇总
  5967. $invoiceStatistics = new invoiceStatistics ();
  5968. // 扣除入账统计金额
  5969. $item = array (
  5970. 'date' => $value ['receivablesDate'],
  5971. 'priceClass' => 3,
  5972. 'cid' => $sDetail ['cid'],
  5973. 'staff' => $sDetail ['sid'],
  5974. // 'irid' => $irid,
  5975. 'accountPrice' => $value ['receivablesPrice']
  5976. );
  5977. $invoiceStatistics->setInvoiceStatisticsByCondition ( $item );
  5978. }
  5979. return '/importInvoiceReceivables?count=' . count ( $exlArray );
  5980. echo 'data count ' . count ( $exlArray );
  5981. die ();
  5982. // return "/keyonline";
  5983. }
  5984. echo 'no file';
  5985. }
  5986. function formatExcelToArrayTrain($file_url = "") {
  5987. if (! file_exists ( $file_url )) {
  5988. return array ();
  5989. }
  5990. // Doo::loadClass ( 'PHPExcel' );
  5991. Doo::loadClass ( 'PHPExcel1.7.9/PHPExcel' );
  5992. $PHPExcel = new PHPExcel ();
  5993. $PHPReader = new PHPExcel_Reader_Excel2007 ();
  5994. if (! $PHPReader->canRead ( $file_url )) {
  5995. $PHPReader = new PHPExcel_Reader_Excel5 ();
  5996. if (! $PHPReader->canRead ( $file_url )) {
  5997. echo 'no Excel';
  5998. return;
  5999. }
  6000. }
  6001. $PHPExcel = $PHPReader->load ( $file_url );
  6002. /* * 读取excel文件中的第一个工作表 */
  6003. $currentSheet = $PHPExcel->getSheet ( 0 );
  6004. /* * 取得最大的列号 */
  6005. $allColumn = $currentSheet->getHighestColumn ();
  6006. /* * 取得一共有多少行 */
  6007. $allRow = $currentSheet->getHighestRow ();
  6008. $excel_array = array ();
  6009. // die($file_url);
  6010. $conk = 2;
  6011. for($currentRow = $conk; $currentRow <= $allRow; $currentRow ++) {
  6012. $excel_column = array ();
  6013. // 后期改进
  6014. if ($allColumn == 'AM')
  6015. $allColumn = 'Z';
  6016. /* * 从第A列开始输出 */
  6017. for($currentColumn = 'A'; $currentColumn <= $allColumn; $currentColumn ++) {
  6018. $val = $currentSheet->getCellByColumnAndRow ( ord ( $currentColumn ) - 65, $currentRow )->getValue ();
  6019. if ($val instanceof PHPExcel_RichText)
  6020. $val = $val->__toString ();
  6021. /* * ord()将字符转为十进制数 iconv ( 'utf-8', 'gb2312', */
  6022. // $val = "'" . addslashes ( $val ) . "'";
  6023. if ($currentColumn == 'A') {
  6024. $excel_column ['invoiceTitle'] = $val;
  6025. } elseif ($currentColumn == 'B')
  6026. $excel_column ['invoiceType'] = $val;
  6027. elseif ($currentColumn == 'C') {
  6028. $excel_column ['TIN'] = $val;
  6029. } elseif ($currentColumn == 'D') {
  6030. $excel_column ['address'] = $val;
  6031. } elseif ($currentColumn == 'E') {
  6032. $excel_column ['phone'] = $val;
  6033. } elseif ($currentColumn == 'F') {
  6034. $excel_column ['bank'] = $val;
  6035. } elseif ($currentColumn == 'G') {
  6036. $excel_column ['bankAccount'] = $val;
  6037. } elseif ($currentColumn == 'H') {
  6038. $excel_column ['invoiceElement'] = $val;
  6039. } elseif ($currentColumn == 'I') {
  6040. $excel_column ['invoiceQuantity'] = $val;
  6041. } elseif ($currentColumn == 'J') {
  6042. $excel_column ['invoiceUnitPrice'] = $val;
  6043. } elseif ($currentColumn == 'K') {
  6044. $excel_column ['remark'] = $val;
  6045. } elseif ($currentColumn == 'L') {
  6046. $excel_column ['recipientsAddress'] = $val;
  6047. } elseif ($currentColumn == 'M') {
  6048. $excel_column ['recipients'] = $val;
  6049. } elseif ($currentColumn == 'N') {
  6050. $excel_column ['recipientsPhone'] = $val;
  6051. }
  6052. }
  6053. if (! empty ( $excel_column ['invoiceTitle'] ) && ! empty ( $excel_column ['invoiceQuantity'] ) && ! empty ( $excel_column ['invoiceUnitPrice'] ))
  6054. array_push ( $excel_array, $excel_column );
  6055. }
  6056. return $excel_array;
  6057. }
  6058. /**
  6059. * 格式化excel文件为数组
  6060. * @param unknown_type $file_url
  6061. * @param unknown_type $mcid
  6062. */
  6063. function _format_excel_to_array($file_url = "", $sType = "") {
  6064. if (! file_exists ( $file_url )) {
  6065. return array ();
  6066. }
  6067. Doo::loadClass ( 'PHPExcel' );
  6068. // Doo::loadClass ( 'PHPExcel1.7.9/PHPExcel' );
  6069. $PHPExcel = new PHPExcel ();
  6070. $PHPReader = new PHPExcel_Reader_Excel2007 ();
  6071. if (! $PHPReader->canRead ( $file_url )) {
  6072. $PHPReader = new PHPExcel_Reader_Excel5 ();
  6073. if (! $PHPReader->canRead ( $file_url )) {
  6074. echo 'no Excel';
  6075. return;
  6076. }
  6077. }
  6078. $PHPExcel = $PHPReader->load ( $file_url );
  6079. /* * 读取excel文件中的第一个工作表 */
  6080. $currentSheet = $PHPExcel->getSheet ( 0 );
  6081. /* * 取得最大的列号 */
  6082. $allColumn = $currentSheet->getHighestColumn ();
  6083. /* * 取得一共有多少行 */
  6084. $allRow = $currentSheet->getHighestRow ();
  6085. $excel_array = array ();
  6086. // die($file_url);
  6087. $conk = 2;
  6088. for($currentRow = $conk; $currentRow <= $allRow; $currentRow ++) {
  6089. $excel_column = array ();
  6090. // 后期改进
  6091. if ($allColumn == 'AM')
  6092. $allColumn = 'Z';
  6093. /* * 从第A列开始输出 */
  6094. for($currentColumn = 'A'; $currentColumn <= $allColumn; $currentColumn ++) {
  6095. $val = $currentSheet->getCellByColumnAndRow ( ord ( $currentColumn ) - 65, $currentRow )->getValue ();
  6096. if ($val instanceof PHPExcel_RichText)
  6097. $val = $val->__toString ();
  6098. /* * ord()将字符转为十进制数 iconv ( 'utf-8', 'gb2312', */
  6099. // $val = "'" . addslashes ( $val ) . "'";
  6100. if ($sType == 'invoiceReceivables') {
  6101. if ($currentColumn == 'A')
  6102. $excel_column ['invoiceNo'] = $val;
  6103. elseif ($currentColumn == 'B')
  6104. $excel_column ['receivablesPrice'] = $val;
  6105. elseif ($currentColumn == 'C') {
  6106. $excel_column ['receivablesMessage'] = $val;
  6107. } elseif ($currentColumn == 'D') {
  6108. $excel_column ['receivablesBank'] = $val;
  6109. } elseif ($currentColumn == 'E') {
  6110. $excel_column ['receivablesDate'] = $this->excelTime ( $val );
  6111. } elseif ($currentColumn == 'F') {
  6112. $excel_column ['receivablesStaff'] = $val;
  6113. } elseif ($currentColumn == 'G') {
  6114. $excel_column ['sourcePrice'] = $val;
  6115. }
  6116. } elseif ($sType == "invoiceTrain") {
  6117. if ($currentColumn == 'A') {
  6118. $excel_column ['invoiceTitle'] = $val;
  6119. } elseif ($currentColumn == 'B')
  6120. $excel_column ['invoiceType'] = $val;
  6121. elseif ($currentColumn == 'C') {
  6122. $excel_column ['TIN'] = $val;
  6123. } elseif ($currentColumn == 'D') {
  6124. $excel_column ['address'] = $val;
  6125. } elseif ($currentColumn == 'E') {
  6126. $excel_column ['phone'] = $val;
  6127. } elseif ($currentColumn == 'F') {
  6128. $excel_column ['bank'] = $val;
  6129. } elseif ($currentColumn == 'G') {
  6130. $excel_column ['bankAccount'] = $val;
  6131. } elseif ($currentColumn == 'H') {
  6132. $excel_column ['invoiceElement'] = $val;
  6133. } elseif ($currentColumn == 'I') {
  6134. $excel_column ['invoiceQuantity'] = $val;
  6135. } elseif ($currentColumn == 'J') {
  6136. $excel_column ['invoiceUnitPrice'] = $val;
  6137. } elseif ($currentColumn == 'K') {
  6138. $excel_column ['remark'] = $val;
  6139. } elseif ($currentColumn == 'L') {
  6140. $excel_column ['recipientsAddress'] = $val;
  6141. } elseif ($currentColumn == 'M') {
  6142. $excel_column ['recipients'] = $val;
  6143. } elseif ($currentColumn == 'N') {
  6144. $excel_column ['recipientsPhone'] = $val;
  6145. }
  6146. } else {
  6147. if ($currentColumn == 'A')
  6148. $excel_column ['invoiceNo'] = $val;
  6149. elseif ($currentColumn == 'B')
  6150. $excel_column ['invoiceType'] = $val;
  6151. elseif ($currentColumn == 'C') {
  6152. $excel_column ['invoicePrice'] = $val;
  6153. } elseif ($currentColumn == 'D') {
  6154. $excel_column ['invoiceTitle'] = $val;
  6155. } elseif ($currentColumn == 'E') {
  6156. $excel_column ['userName'] = $val;
  6157. } elseif ($currentColumn == 'F') {
  6158. $excel_column ['categoryName'] = $val;
  6159. } elseif ($currentColumn == 'G') {
  6160. $excel_column ['invoiceElement'] = $val;
  6161. } elseif ($currentColumn == 'H') {
  6162. $excel_column ['remark'] = $val;
  6163. } elseif ($currentColumn == 'I') {
  6164. $excel_column ['date'] = $this->excelTime ( $val );
  6165. }
  6166. }
  6167. }
  6168. array_push ( $excel_array, $excel_column );
  6169. }
  6170. return $excel_array;
  6171. }
  6172. function excelTime($date, $time = false) {
  6173. if (function_exists ( 'GregorianToJD' )) {
  6174. if (is_numeric ( $date )) {
  6175. $jd = GregorianToJD ( 1, 1, 1970 );
  6176. $gregorian = JDToGregorian ( $jd + intval ( $date ) - 25569 );
  6177. $date = explode ( '/', $gregorian );
  6178. $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" : '');
  6179. return $date_str;
  6180. }
  6181. } else {
  6182. $date = $date > 25568 ? $date + 1 : 25569;
  6183. /* There was a bug if Converting date before 1-1-1970 (tstamp 0) */
  6184. $ofs = (70 * 365 + 17 + 2) * 86400;
  6185. $date = date ( "Y-m-d", ($date * 86400) - $ofs ) . ($time ? " 00:00:00" : '');
  6186. }
  6187. return $date;
  6188. }
  6189. /**
  6190. * 旧输入导入
  6191. */
  6192. function _GetFileEXT($filename) {
  6193. $pics = explode ( '.', $filename );
  6194. $num = count ( $pics );
  6195. return $pics [$num - 1];
  6196. }
  6197. function showCache($path = "", $sid = 0) {
  6198. // if (file_exists ( $path )) {
  6199. // $htm = file_get_contents ( $path );
  6200. // } else {
  6201. Doo::loadModel ( 'invoiceStatistics' );
  6202. $invoiceStatistics = new invoiceStatistics ();
  6203. $isBriefly = $invoiceStatistics->getBrieflyStatistics ( $sid );
  6204. $htm = '<tr><th class="taC">' . $isBriefly ['statisticsMonth'] [0] ['month'] . '月累计开票</th>
  6205. <td>¥' . $isBriefly ['statisticsMonth'] [0] ['invoicePrice'] . '</td>
  6206. <th class="taC">' . $isBriefly ['statisticsMonth'] [0] ['month'] . '月累计入账</th>
  6207. <td>¥' . $isBriefly ['statisticsMonth'] [0] ['accountPrice'] . '</td></tr>';
  6208. /*
  6209. * '<tr><th class="taC">今年累计开票</th><td>¥' . $isBriefly ['statisticsYear'] [0] ['invoicePrice'] . '</td> <th class="taC">今年累计入账</th><td>¥' . $isBriefly ['statisticsYear'] [0] ['accountPrice'] . '</td></tr>';
  6210. */
  6211. file_put_contents ( $path, $htm );
  6212. // }
  6213. return $htm;
  6214. }
  6215. /**
  6216. * 获取get或者POST值
  6217. *
  6218. * @param string $name 属性名称
  6219. * @return fixed 值
  6220. */
  6221. function get_args($name) {
  6222. if (isset ( $_GET [$name] )) {
  6223. if (is_array ( $_GET [$name] ))
  6224. return $_GET [$name];
  6225. else
  6226. return addslashes ( $_GET [$name] );
  6227. } elseif (isset ( $_POST [$name] )) {
  6228. if (is_array ( $_POST [$name] ))
  6229. return $_POST [$name];
  6230. else
  6231. return addslashes ( $_POST [$name] );
  6232. } else
  6233. return false;
  6234. }
  6235. function SafeFilter(&$arr) {
  6236. $ra = Array (
  6237. '/([\x00-\x08,\x0b-\x0c,\x0e-\x19])/',
  6238. '/script/',
  6239. '/javascript/',
  6240. '/vbscript/',
  6241. '/expression/',
  6242. '/applet/',
  6243. '/meta/',
  6244. '/xml/',
  6245. '/blink/',
  6246. '/link/',
  6247. '/style/',
  6248. '/embed/',
  6249. '/object/',
  6250. '/frame/',
  6251. '/layer/',
  6252. '/title/',
  6253. '/bgsound/',
  6254. '/base/',
  6255. '/onload/',
  6256. '/onunload/',
  6257. '/onchange/',
  6258. '/onsubmit/',
  6259. '/onreset/',
  6260. '/onselect/',
  6261. '/onblur/',
  6262. '/onfocus/',
  6263. '/onabort/',
  6264. '/onkeydown/',
  6265. '/onkeypress/',
  6266. '/onkeyup/',
  6267. '/onclick/',
  6268. '/ondblclick/',
  6269. '/onmousedown/',
  6270. '/onmousemove/',
  6271. '/onmouseout/',
  6272. '/onmouseover/',
  6273. '/onmouseup/',
  6274. '/onunload/'
  6275. );
  6276. if (is_array ( $arr )) {
  6277. foreach ( $arr as $key => $value ) {
  6278. if (! is_array ( $value )) {
  6279. if (! get_magic_quotes_gpc ()) // 不对magic_quotes_gpc转义过的字符使用addslashes(),避免双重转义。
  6280. {
  6281. $value = addslashes ( $value ); // 给单引号(')、双引号(")、反斜线(\)与 NUL(NULL 字符)加上反斜线转义
  6282. }
  6283. $value = preg_replace ( $ra, '', $value ); // 删除非打印字符,粗暴式过滤xss可疑字符串
  6284. $arr [$key] = htmlentities ( strip_tags ( $value ) ); // 去除 HTML 和 PHP 标记并转换为 HTML 实体
  6285. } else {
  6286. SafeFilter ( $arr [$key] );
  6287. }
  6288. }
  6289. }
  6290. }
  6291. /**
  6292. * Escape String
  6293. *
  6294. * @access public
  6295. * @param string
  6296. * @param bool whether or not the string will be used in a LIKE condition
  6297. * @return string
  6298. */
  6299. function escape_str($str, $like = FALSE) {
  6300. if (is_array ( $str )) {
  6301. foreach ( $str as $key => $val ) {
  6302. $str [$key] = $this->escape_str ( $val, $like );
  6303. }
  6304. return $str;
  6305. }
  6306. var_dump ( Doo::db ()->getDbObject () );
  6307. die ();
  6308. if (function_exists ( 'mysql_real_escape_string' ) and is_resource ( Doo::db ()->getDbObject () )) { // Doo::db ()->getDbObject()
  6309. $str = mysql_real_escape_string ( $str, Doo::db ()->getDbObject () );
  6310. } elseif (function_exists ( 'mysql_escape_string' )) {
  6311. $str = mysql_escape_string ( $str );
  6312. } else {
  6313. $str = addslashes ( $str );
  6314. }
  6315. // escape LIKE condition wildcards
  6316. if ($like === TRUE) {
  6317. $str = str_replace ( array (
  6318. '%',
  6319. '_'
  6320. ), array (
  6321. '\\%',
  6322. '\\_'
  6323. ), $str );
  6324. }
  6325. return $str;
  6326. }
  6327. /**
  6328. * 获得分页数据
  6329. * @param unknown_type $table
  6330. * @param unknown_type $condition
  6331. * @param unknown_type $on_page
  6332. * @param unknown_type $page_size
  6333. */
  6334. function get_page($table = "", $condition = "", $on_page = 1, $page_size = 20, $action = "", $get = "", $other = "page") {
  6335. $page_c = "";
  6336. $page ['previous'] = $this->get_previous ( $on_page );
  6337. $page ['on_page'] = $on_page;
  6338. $total_count = $this->get_table_count ( $table, $condition );
  6339. $total = intval ( $total_count / $page_size );
  6340. $page ['total_page'] = ($total_count % $page_size) == 0 ? $total : $total + 1;
  6341. $page ['total_data'] = $total_count;
  6342. $page ['next'] = $on_page == $page ['total_page'] ? $page ['total_page'] : $on_page + 1;
  6343. $i = 1;
  6344. $page_max = 1;
  6345. $page_width = 3;
  6346. if ($on_page >= $page_width) {
  6347. $page_max = intval ( $on_page / $page_width ) + 1;
  6348. $i = intval ( $on_page / $page_width ) * $page_width - 1;
  6349. }
  6350. for(; $i <= $page ['total_page']; $i ++) {
  6351. if ($i == $on_page)
  6352. $page_c .= '<li class="active"><a href="javascript:void(0)">' . $i . '</a></li>';
  6353. else
  6354. $page_c .= '<li><a href="/' . $action . '/' . $i . $get . '">' . $i . '</a></li>';
  6355. if ($i == ($page_width * $page_max))
  6356. break;
  6357. }
  6358. $page ['page'] = $page_c;
  6359. $page ['lower'] = (-- $on_page) * $page_size;
  6360. return $page;
  6361. }
  6362. /**
  6363. * 获取上一页
  6364. * @param unknown_type $on_page
  6365. */
  6366. function get_previous($on_page = 1) {
  6367. return $on_page != 0 ? $on_page - 1 : $on_page;
  6368. }
  6369. /**
  6370. * 获取总页数
  6371. * @param unknown_type $table
  6372. * @param unknown_type $condition
  6373. */
  6374. public function get_table_count($table = "", $condition = "") {
  6375. // $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  6376. $sql = "select count(*) as count from " . $table . " where " . $condition;
  6377. // echo $sql;die;
  6378. $query = Doo::db ()->query ( $sql );
  6379. $result = $query->fetch ();
  6380. return $result ['count'];
  6381. }
  6382. /**
  6383. * 获得分页数据
  6384. * @param unknown_type $table
  6385. * @param unknown_type $condition
  6386. * @param unknown_type $on_page
  6387. * @param unknown_type $page_size
  6388. */
  6389. function getPageBySql($sql = "", $on_page = 1, $page_size = 20, $action = "", $get = "", $other = "page") {
  6390. $page_c = "";
  6391. $page ['previous'] = $this->get_previous ( $on_page );
  6392. $page ['on_page'] = $on_page;
  6393. $total_count = $this->getTableCountBySql ( $sql );
  6394. $total = intval ( $total_count / $page_size );
  6395. $page ['total_page'] = ($total_count % $page_size) == 0 ? $total : $total + 1;
  6396. $page ['total_data'] = $total_count;
  6397. $page ['next'] = $on_page == $page ['total_page'] ? $page ['total_page'] : $on_page + 1;
  6398. $i = 1;
  6399. $page_max = 1;
  6400. $page_width = 3;
  6401. if ($on_page >= $page_width) {
  6402. $page_max = intval ( $on_page / $page_width ) + 1;
  6403. $i = intval ( $on_page / $page_width ) * $page_width - 1;
  6404. }
  6405. for(; $i <= $page ['total_page']; $i ++) {
  6406. if ($i == $on_page)
  6407. $page_c .= '<li class="active"><a href="javascript:void(0)">' . $i . '</a></li>';
  6408. else
  6409. $page_c .= '<li><a href="/' . $action . '/' . $i . $get . '">' . $i . '</a></li>';
  6410. if ($i == ($page_width * $page_max))
  6411. break;
  6412. }
  6413. $page ['page'] = $page_c;
  6414. $page ['lower'] = (-- $on_page) * $page_size;
  6415. return $page;
  6416. }
  6417. /**
  6418. * 获得总页数 sql
  6419. * @param string $type
  6420. * @return boolean[]
  6421. */
  6422. public function getTableCountBySql($sql = "") {
  6423. $query = Doo::db ()->query ( $sql );
  6424. $result = $query->fetchAll ();
  6425. return count ( $result );
  6426. }
  6427. function isInvoiceNew($type = "GLOBAL") {
  6428. Doo::loadModel ( 'invoice' );
  6429. $invoice = new invoice ();
  6430. Doo::loadModel ( 'invoiceReceivables' );
  6431. $invoiceReceivables = new invoiceReceivables ();
  6432. Doo::loadModel ( 'staff' );
  6433. $staff = new staff ();
  6434. $st = $staff->getUserByIdList ( $_COOKIE ["staff"] );
  6435. // 我的发票待处理
  6436. $pendingInvoice = $invoice->getOne ( array ( // or (status=2 and printStatus=1 and untreadStatus=0 ) or (status=2 and printStatus=1 and untreadStatus=2 )
  6437. 'where' => "(status=3 or status=4) and isDelete=0 and sid=" . $st [0] ['sid'],
  6438. 'desc' => 'iid',
  6439. 'asArray' => TRUE
  6440. ) );
  6441. // 我的收款待入账
  6442. /*
  6443. * $myClaim = $invoiceReceivables->getOne ( array ( 'where' => " receivablesStaff like '" . $st [0] ['sid'] . "-%' and receivablesCategory like '" . $st [0] ['cid'] . ":%' and bindStatus=0", 'desc' => 'irid', 'asArray' => TRUE ) );
  6444. */
  6445. // 发票审批
  6446. $approval = $invoice->getOne ( array (
  6447. 'where' => 'status=1 and pendingApprovals=' . $st [0] ['sid'],
  6448. 'desc' => 'iid',
  6449. 'asArray' => true
  6450. ) );
  6451. // 发票邮寄
  6452. $post = $invoice->getOne ( array (
  6453. 'where' => "postStatus=0 and printStatus=1 and isDelete=0 and doPost=1 and status=2",
  6454. 'asArray' => TRUE
  6455. ) );
  6456. // 发票打印
  6457. $print = $invoice->getOne ( array (
  6458. 'where' => "status=2 and printStatus=0 and untreadStatus=0 and moldManage like '%[\"" . $st [0] ['sid'] . "\",%'",
  6459. 'desc' => 'iid',
  6460. 'asArray' => TRUE
  6461. ) );
  6462. // 发票退票 printStatus=1 and
  6463. $untread = $invoice->getOne ( array (
  6464. 'where' => " untreadStatus=1 and status=2 ",
  6465. 'asArray' => TRUE
  6466. ) );
  6467. $new = array (
  6468. 'GLOBAL' => FALSE,
  6469. 'pendingInvoice' => FALSE,
  6470. // 'myClaim' => FALSE,
  6471. 'approval' => FALSE,
  6472. 'post' => FALSE,
  6473. 'print' => FALSE,
  6474. 'untread' => FALSE
  6475. );
  6476. // || ! empty ( $myClaim )
  6477. if (! empty ( $pendingInvoice ) || ! empty ( $approval ) || ! empty ( $post ) || ! empty ( $print ) || ! empty ( $untread ))
  6478. $new ['GLOBAL'] = TRUE;
  6479. if (! empty ( $pendingInvoice ))
  6480. $new ['pendingInvoice'] = TRUE;
  6481. // if (! empty ( $myClaim ))
  6482. // $new ['myClaim'] = TRUE;
  6483. if (! empty ( $approval ))
  6484. $new ['approval'] = TRUE;
  6485. if (! empty ( $post ))
  6486. $new ['post'] = TRUE;
  6487. if (! empty ( $print ))
  6488. $new ['print'] = TRUE;
  6489. if (! empty ( $untread ))
  6490. $new ['untread'] = TRUE;
  6491. return $new;
  6492. }
  6493. function setWXMsg($rid, $typeMsg = '') {
  6494. Doo::loadModel ( 'invoice' );
  6495. $invoice = new invoice ();
  6496. $invoiceDetail = $invoice->getOne ( array (
  6497. 'where' => 'iid=' . $rid,
  6498. 'asArray' => true
  6499. ) );
  6500. if (! empty ( $invoiceDetail )) {
  6501. Doo::loadModel ( 'staff' );
  6502. $staff = new staff ();
  6503. $staffmsg = $staff->getOne ( array (
  6504. 'where' => "sid='" . $invoiceDetail ['sid'] . "'",
  6505. 'asArray' => TRUE
  6506. ) );
  6507. if (! empty ( $staffmsg ['wxid'] )) {
  6508. require_once (SITE_PATH . '/protected/class/client.php');
  6509. $client = new client ( 'http://m.cld.smartcost.com.cn/' );
  6510. $user = $staffmsg ['wxid'];
  6511. $expCom = explode ( ":", $invoiceDetail ['expressCompany'] );
  6512. if (empty ( $expCom ))
  6513. $expCom [0] = '';
  6514. $msg = "";
  6515. if (empty ( $typeMsg ))
  6516. $msg = '太好了,您的发票' . $invoiceDetail ['invoiceSerial'] . ' 已邮寄 ' . $expCom [0] . ' ,快递号: <a href="https://m.kuaidi100.com/result.jsp?nu=' . $invoiceDetail ['expressNumber'] . '" >' . $invoiceDetail ['expressNumber'] . '</a>';
  6517. elseif ($typeMsg == "PRINT")
  6518. $msg = '太好了,您的发票已打印完成。';
  6519. $result = $client->SendMsg ( $user, $msg, 'text' );
  6520. }
  6521. }
  6522. }
  6523. /**
  6524. * 获取微信部门
  6525. * @param string $category
  6526. * @return number|mixed
  6527. */
  6528. function getToparty($category = '') {
  6529. $token = $this->getAccessToken (); //
  6530. $result = json_decode ( $this->httpGet ( "https://qyapi.weixin.qq.com/cgi-bin/department/list?access_token={$token}&id=5" ), true );
  6531. $toparty = 0;
  6532. foreach ( $result ['department'] as $key => $value ) {
  6533. if ($value ['name'] == $category)
  6534. $toparty = $value ['id'];
  6535. }
  6536. return $toparty;
  6537. }
  6538. /**
  6539. * 获得某部门下的用户
  6540. * @param string $toparty
  6541. */
  6542. function getUserByToparty($toparty = '') {
  6543. $token = $this->getAccessToken (); //
  6544. $result = json_decode ( $this->httpGet ( "https://qyapi.weixin.qq.com/cgi-bin/user/simplelist?access_token={$token}&department_id={$toparty}" ), true );
  6545. $userList = array ();
  6546. foreach ( $result ['userlist'] as $key => $value ) {
  6547. array_push ( $userList, "'" . $value ['userid'] . "'" );
  6548. }
  6549. return $userList;
  6550. }
  6551. function msgSendToparty($msg, $title, $url, $toparty, $text = '') {
  6552. $token = $this->getAccessToken ();
  6553. if ($text == 'text') {
  6554. $data = '{
  6555. "touser": "' . $toparty . '",
  6556. "toparty": "",
  6557. "totag": "",
  6558. "msgtype": "text",
  6559. "agentid": 1000002,
  6560. "text": {
  6561. "content": "' . $msg . '"
  6562. },
  6563. "safe":0
  6564. }';
  6565. }
  6566. $result = json_decode ( $this->httpPOST ( "https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token={$token}", $data ) );
  6567. if ($result->errmsg != 'ok') {
  6568. return 0;
  6569. } else {
  6570. return 1;
  6571. }
  6572. }
  6573. /**
  6574. * 获得可以发送微信用户列表
  6575. * @param string $category
  6576. * @return string
  6577. */
  6578. function getWxidByCategory($category = "") {
  6579. if (empty ( $category ))
  6580. return "";
  6581. Doo::loadModel ( 'staff' );
  6582. $staff = new staff ();
  6583. $toparty = $this->getToparty ( $category );
  6584. $wxList = array ();
  6585. $wxString = "";
  6586. if (! empty ( $toparty )) {
  6587. $userList = $this->getUserByToparty ( $toparty );
  6588. $userCon = implode ( ',', $userList );
  6589. // echo $userCon;
  6590. $sidList = $staff->getStaffByWxid ( $userCon );
  6591. foreach ( $sidList as $key => $value ) {
  6592. $falg = $this->isSendNotification ( $value ['sid'], 'receivables' );
  6593. if ($falg) {
  6594. array_push ( $wxList, $value ['wxid'] );
  6595. }
  6596. }
  6597. $wxString = implode ( '|', $wxList );
  6598. }
  6599. return $wxString;
  6600. }
  6601. /**
  6602. * 读取发送信息规则判断是否需要发送
  6603. * @param number $sid
  6604. * @param string $sendType
  6605. * @return boolean
  6606. */
  6607. function isSendNotification($sid = 0, $sendType = '') {
  6608. Doo::loadModel ( "notificationConf" );
  6609. $notificationConf = new notificationConf ();
  6610. $detail = $notificationConf->getNotificationConfBySid ( $sid );
  6611. $conf = array ();
  6612. $sendFlag = true;
  6613. if (! empty ( $detail )) {
  6614. $conf = json_decode ( $detail ['conf'], true );
  6615. if (! empty ( $sendType )) {
  6616. if (isset ( $conf [$sendType] )) {
  6617. if ($conf [$sendType] == "CLOSE")
  6618. $sendFlag = false;
  6619. elseif ($conf [$sendType] == "Weekend") {
  6620. $day = date ( "w" );
  6621. if (1 <= $day && 5 >= $day)
  6622. $sendFlag = false;
  6623. } elseif ($conf [$sendType] == "OneToFriday") {
  6624. $day = date ( "w" );
  6625. if (0 == $day || 6 == $day)
  6626. $sendFlag = false;
  6627. }
  6628. }
  6629. } else
  6630. $sendFlag = false;
  6631. }
  6632. return $sendFlag;
  6633. }
  6634. /**
  6635. * 根据规则发送信息
  6636. * @param unknown $msg
  6637. * @param unknown $title
  6638. * @param unknown $url
  6639. * @param unknown $user
  6640. * @param string $text
  6641. * @return number
  6642. */
  6643. private function msgSend($msg, $title, $url, $user, $sid = 0, $sendType = '') {
  6644. $token = $this->getAccessToken ();
  6645. $falg = $this->isSendNotification ( $sid, $sendType );
  6646. // if ($text == 'text') {
  6647. // $data = '{
  6648. // "touser": "' . $user . '",
  6649. // "toparty": "",
  6650. // "totag": "",
  6651. // "msgtype": "text",
  6652. // "agentid": 1000002,
  6653. // "text": {
  6654. // "content": "' . $msg . '"
  6655. // },
  6656. // "safe":0
  6657. // }';
  6658. // } else {
  6659. $data = '{
  6660. "touser": "' . $user . '",
  6661. "toparty": "",
  6662. "totag": "",
  6663. "msgtype": "news",
  6664. "agentid": 1000002,
  6665. "news": {
  6666. "articles":[
  6667. {
  6668. "title": "' . $title . '",
  6669. "description": "' . $msg . '",
  6670. "url": "' . $url . '",
  6671. "picurl": ""
  6672. }
  6673. ]
  6674. }
  6675. }';
  6676. // }
  6677. if ($falg) {
  6678. $result = json_decode ( $this->httpPOST ( "https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token={$token}", $data ) );
  6679. if ($result->errmsg != 'ok') {
  6680. return 0;
  6681. } else {
  6682. return 1;
  6683. }
  6684. } else
  6685. return 0;
  6686. }
  6687. private function getAccessToken() {
  6688. // access_token 应该全局存储与更新,以下代码以写入到文件中做示例
  6689. // $file = './access_token.txt';
  6690. // $data = json_decode ( file_get_contents ( $file ) );
  6691. // if ($data->expire_time < time () or ! $data->expire_time) {
  6692. // 如果是企业号用以下URL获取access_token
  6693. $url = "https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=$this->appId&corpsecret=$this->appSecret";
  6694. // $url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=$this->appId&secret=$this->appSecret";
  6695. $res = json_decode ( $this->httpGet ( $url ) );
  6696. $access_token = $res->access_token;
  6697. // echo $access_token;
  6698. // if ($access_token) {
  6699. // $data->expire_time = time () + 7000;
  6700. // $data->access_token = $access_token;
  6701. // $fp = fopen ( $file, "w" );
  6702. // fwrite ( $fp, json_encode ( $data ) );
  6703. // fclose ( $fp );
  6704. // }
  6705. // } else {
  6706. // $access_token = $data->access_token;
  6707. // }
  6708. return $access_token;
  6709. }
  6710. private function httpGet($url) {
  6711. $curl = curl_init ();
  6712. curl_setopt ( $curl, CURLOPT_RETURNTRANSFER, true );
  6713. curl_setopt ( $curl, CURLOPT_TIMEOUT, 500 );
  6714. // 为保证第三方服务器与微信服务器之间数据传输的安全性,所有微信接口采用https方式调用,必须使用下面2行代码打开ssl安全校验。
  6715. // 如果在部署过程中代码在此处验证失败,请到 http://curl.haxx.se/ca/cacert.pem 下载新的证书判别文件。
  6716. curl_setopt ( $curl, CURLOPT_SSL_VERIFYPEER, true );
  6717. curl_setopt ( $curl, CURLOPT_SSL_VERIFYHOST, false );
  6718. curl_setopt ( $curl, CURLOPT_URL, $url );
  6719. $res = curl_exec ( $curl );
  6720. curl_close ( $curl );
  6721. return $res;
  6722. }
  6723. private function httpPost($url, $data) {
  6724. $curl = curl_init ();
  6725. curl_setopt ( $curl, CURLOPT_RETURNTRANSFER, true );
  6726. curl_setopt ( $curl, CURLOPT_TIMEOUT, 500 );
  6727. // 为保证第三方服务器与微信服务器之间数据传输的安全性,所有微信接口采用https方式调用,必须使用下面2行代码打开ssl安全校验。
  6728. // 如果在部署过程中代码在此处验证失败,请到 http://curl.haxx.se/ca/cacert.pem 下载新的证书判别文件。
  6729. curl_setopt ( $curl, CURLOPT_SSL_VERIFYPEER, true );
  6730. curl_setopt ( $curl, CURLOPT_SSL_VERIFYHOST, false );
  6731. curl_setopt ( $curl, CURLOPT_URL, $url );
  6732. curl_setopt ( $curl, CURLOPT_POST, 1 );
  6733. curl_setopt ( $curl, CURLOPT_POSTFIELDS, $data );
  6734. $res = curl_exec ( $curl );
  6735. curl_close ( $curl );
  6736. return $res;
  6737. }
  6738. }
  6739. ?>