InvoiceController.php 172 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565
  1. <?php
  2. /**
  3. * 开票功能控制器
  4. * @author CP
  5. * @version 1.0
  6. * @namespace invoice
  7. * @package invoiceController
  8. */
  9. class InvoiceController extends DooController {
  10. public $staff;
  11. public $NEW;
  12. public $data;
  13. private $INVOICEKEY = "APPROVAL";
  14. private $INVOICECOLLECTPATH = "protected/cache/invoiceCollect/";
  15. private $ACTION = '';
  16. private $appId = 'wx3ee46531947a1384';
  17. private $appSecret = 'awGWzy3J5q_96VXKBLA2BQ9RpiT0LiPXnkMF-xV6h5o'; // awGWzy3J5q_96VXKBLA2BXU6mVCGynPGD-sxUCsdNDE //'PeiQVH8tbQE7pM9pVO4AIPlX9FFNpwu7O6Iy6VFcAVtpjTA3Qn42dbNmktBFkUHo';
  18. public function beforeRun($resource, $action) {
  19. Doo::loadModel ( "invoiceManage" );
  20. $invoiceManage = new invoiceManage ();
  21. Doo::loadClass ( 'XDeode' );
  22. $XDeode = new XDeode ( 5 );
  23. $sid = $XDeode->decode ( $_COOKIE ["staff"] );
  24. header ( 'Content-Type:text/html;charset=utf-8' );
  25. $moldList = $invoiceManage->getInvoiceByStaff ( $sid );
  26. if (empty ( $moldList )) {
  27. $flag = false;
  28. $uGroups = 'ordinary';
  29. if (Doo::acl ()->isAllowed ( $uGroups, $resource, $action )) {
  30. $flag = true;
  31. }
  32. } else {
  33. $flag = false;
  34. array_push ( $moldList, array (
  35. 'mold' => 'ordinary'
  36. ) );
  37. //删除审批人后-加入权限问题-暂时关闭
  38. $fileInvoice = file_get_contents ( "protected/config/invoice/invoice.ini" );
  39. $fiML=json_decode($fileInvoice,true);
  40. if (empty($fiML))
  41. $fiML=array();
  42. foreach ($fiML as $key=>$value){
  43. $sidList=explode(',',$value);
  44. foreach ($sidList as $k=>$v){
  45. if ($v==$sid){
  46. array_push ( $moldList, array (
  47. 'mold' => $key
  48. ) );
  49. break;
  50. }
  51. }
  52. }
  53. foreach ( $moldList as $value ) {
  54. if (Doo::acl ()->isAllowed ( $value ['mold'], $resource, $action )) {
  55. $flag = true;
  56. break;
  57. }
  58. }
  59. }
  60. /*
  61. * Doo::acl()->isAllowed($uGroups['groups'], $resource, $action);
  62. */
  63. // var_dump($flag) ;
  64. if (! $flag)
  65. die ( 'illegal request' );
  66. }
  67. function __construct() {
  68. if (isset ( $_COOKIE ["staff"] )) {
  69. if (! empty ( $_COOKIE ["staff"] )) {
  70. Doo::loadModel ( 'staff' );
  71. $staff = new staff ();
  72. $uriPartsOrig = explode ( '/', $_SERVER ['REQUEST_URI'] );
  73. $this->ACTION = $uriPartsOrig [1];
  74. $this->data ['new'] = $this->isInvoiceNew ();
  75. $this->staff = $staff->getUserByIdList ( $_COOKIE ["staff"] );
  76. return "/";
  77. }
  78. }
  79. Doo::loadCore ( 'uri/DooUriRouter' );
  80. $router = new DooUriRouter ();
  81. $routeRs = $router->execute ( Doo::app ()->route, Doo::conf ()->SUBFOLDER );
  82. if ($routeRs ['1'] != "login") {
  83. header ( 'Content-Type:text/html;charset=utf-8' );
  84. @header ( "Location: /login" );
  85. }
  86. }
  87. function testSend() {
  88. // $msTouser='caipin|outaozhen';
  89. $toparty = $this->getToparty ( $receivablesCategory [1] );
  90. $title2 = '[通知]财务录入了一笔待认领款项,快到“我的收款”中查看,确认是否是您的客户给您打款了。';
  91. //$hfreult = $this->msgSend ( '', $title2, '', 'outaozhen' );
  92. // $toparty= $this->getToparty('广东办');
  93. //$msg = '[通知]财务录入了一笔待认领款项,快到“我的收款”中查看,确认是否是您的客户给您打款了。';
  94. //$toparty = 26;
  95. // $msg = '';
  96. //$url = 'http://m.cld.smartcost.com.cn/invoicePrintDetail/1.html';
  97. // $hfreult = $this->msgSendToparty ( $msg, '', '', $toparty,'text' );
  98. }
  99. function invoice() {
  100. Doo::loadModel ( 'invoice' );
  101. $invoice = new invoice ();
  102. Doo::loadModel ( 'express' );
  103. $express = new express ();
  104. $expressList = $express->getExpressByAll ();
  105. $this->data ['expressList'] = $expressList;
  106. // Doo::loadModel ( 'invoiceReceivables' );
  107. // $invoiceReceivables = new invoiceReceivables ();
  108. // $list = $invoiceReceivables->getInvoiceReceivablesByClaim ( $this->staff [0] ['cid'], $this->staff [0] ['sid'] );
  109. Doo::loadModel ( 'invoiceStatistics' );
  110. $invoiceStatistics = new invoiceStatistics ();
  111. $isMonth = $invoiceStatistics->getStatisticsByMonth ();
  112. $year = date ( "Y" );
  113. $tmp_date = date ( "Ym" );
  114. $tmp_year = substr ( $tmp_date, 0, 4 );
  115. $tmp_mon = substr ( $tmp_date, 4, 2 );
  116. $tmp_forwardmonth = mktime ( 0, 0, 0, $tmp_mon - 1, 1, $tmp_year );
  117. $fm_forward_month = date ( "m", $tmp_forwardmonth );
  118. $path = SITE_PATH . $this->INVOICECOLLECTPATH . "invoiceCollect_" . $year . "_" . $fm_forward_month . ".htm";
  119. $htm = $this->showCache ( $path );
  120. Doo::loadClass ( 'XDeode' );
  121. $XDeode = new XDeode ( 5 );
  122. $sid = $XDeode->decode ( $_COOKIE ["staff"] );
  123. $invoiceList = $invoice->getMyInvoice ( $sid );
  124. $sql = 'status=2 and printStatus=1 and irid!="" and sid=' . $sid;
  125. $list = $invoice->getInvoiceByUntreadStatusPage ( 4, $sql );
  126. // 我的待入账发票 and irid='' and ( (doPost=1 and postStatus=1) or doPost=0 )
  127. $sql = "status=2 and printStatus=1 and untreadStatus=0 and isDelete=0 and sid=" . $sid;
  128. $myInvoiceUnAccount = $invoice->getInvoiceByUntreadStatusPage ( 4, $sql );
  129. // print_r($myInvoiceUnAccount);
  130. $this->data ['isMonth'] = $isMonth;
  131. $this->data ['htm'] = $htm;
  132. $this->data ['invoiceList'] = $invoiceList;
  133. $this->data ['receivablesList'] = $list;
  134. $this->data ['myInvoiceUnAccount'] = $myInvoiceUnAccount;
  135. $this->data ['memu'] = "invoice";
  136. $this->data ['staff'] = $this->staff;
  137. $this->data ['receiptMemu'] = 'invoice';
  138. $this->render ( "/admin/invoice", $this->data );
  139. }
  140. function invoiceAdd() {
  141. Doo::loadModel ( 'L_category' );
  142. $lCategory = new L_category ();
  143. $category = $lCategory->find ( array (
  144. 'asArray' => true
  145. ) );
  146. $this->data ['category'] = $category;
  147. $this->data ['memu'] = "invoice";
  148. $this->data ['staff'] = $this->staff;
  149. $this->data ['receiptMemu'] = 'invoice';
  150. $this->render ( "/admin/invoiceAdd", $this->data );
  151. }
  152. /**
  153. * 提交一份开票申请,并记录下操作日志
  154. *
  155. * @since 1.0.0
  156. * @var integer cid 办事处ID
  157. * @var integer invoiceType 发票类型
  158. * @var integer doPost 是否邮寄
  159. * @var integer invoicePrice 开票金额
  160. * @var string invoiceElement 开票内容
  161. * @var string invoiceTitle 发票抬头
  162. * @var string invoiceCompany 单位名称
  163. * @var string TIN 纳税人识别码
  164. * @var string address 注册地址
  165. * @var string phone 注册电话
  166. * @var string bank 开户银行
  167. * @var string bankAccount 银行账户
  168. * @var string recipients 收件人
  169. * @var string recipientsPhone 收件人手机/电话
  170. * @var string recipientsAddress 收件地址
  171. * @var string mailItems 邮寄物品
  172. * @var string remark 备注
  173. * @return string 返回跳转开票主页路径
  174. */
  175. function invoiceAddDo() {
  176. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  177. $invoiceType = $this->get_args ( 'invoiceType' ) && is_numeric ( $this->get_args ( 'invoiceType' ) ) ? $this->get_args ( 'invoiceType' ) : 0;
  178. $doPost = $this->get_args ( 'doPost' ) && is_numeric ( $this->get_args ( 'doPost' ) ) ? $this->get_args ( 'doPost' ) : 0;
  179. $invoicePrice = $this->get_args ( 'invoicePrice' ) ? $this->get_args ( 'invoicePrice' ) : "";
  180. $invoiceQuantity = $this->get_args ( 'invoiceQuantity' ) && is_numeric ( $this->get_args ( 'invoiceQuantity' ) ) ? $this->get_args ( 'invoiceQuantity' ) : 0;
  181. $invoiceUnitPrice = $this->get_args ( 'invoiceUnitPrice' ) && is_numeric ( $this->get_args ( 'invoiceUnitPrice' ) ) ? $this->get_args ( 'invoiceUnitPrice' ) : 0;
  182. $invoiceElement = $this->get_args ( 'invoiceElement' ) ? $this->get_args ( 'invoiceElement' ) : "";
  183. $invoiceTitle = $this->get_args ( 'invoiceTitle' ) ? $this->get_args ( 'invoiceTitle' ) : "";
  184. $invoiceCompany = $this->get_args ( 'invoiceCompany' ) ? $this->get_args ( 'invoiceCompany' ) : "";
  185. $TIN = $this->get_args ( 'TIN' ) ? $this->get_args ( 'TIN' ) : "";
  186. $address = $this->get_args ( 'address' ) ? $this->get_args ( 'address' ) : "";
  187. $phone = $this->get_args ( 'phone' ) ? $this->get_args ( 'phone' ) : "";
  188. $bank = $this->get_args ( 'bank' ) ? $this->get_args ( 'bank' ) : "";
  189. $bankAccount = $this->get_args ( 'bankAccount' ) ? $this->get_args ( 'bankAccount' ) : "";
  190. $recipients = $this->get_args ( 'recipients' ) ? $this->get_args ( 'recipients' ) : "";
  191. $recipientsPhone = $this->get_args ( 'recipientsPhone' ) ? $this->get_args ( 'recipientsPhone' ) : "";
  192. $recipientsAddress = $this->get_args ( 'recipientsAddress' ) ? $this->get_args ( 'recipientsAddress' ) : "";
  193. $remark = $this->get_args ( 'remark' ) ? $this->get_args ( 'remark' ) : "";
  194. $TINT = $this->get_args ( 'TINT' ) ? $this->get_args ( 'TINT' ) : "";
  195. $addressT = $this->get_args ( 'addressT' ) ? $this->get_args ( 'addressT' ) : "";
  196. $phoneT = $this->get_args ( 'phoneT' ) ? $this->get_args ( 'phoneT' ) : "";
  197. $bankT = $this->get_args ( 'bankT' ) ? $this->get_args ( 'bankT' ) : "";
  198. $bankAccountT = $this->get_args ( 'bankAccountT' ) ? $this->get_args ( 'bankAccountT' ) : "";
  199. $softLock = $this->get_args ( 'softLock' ) ? $this->get_args ( 'softLock' ) : 0;
  200. $softLockNum = $this->get_args ( 'softLockNum' ) ? $this->get_args ( 'softLockNum' ) : 0;
  201. $contract = $this->get_args ( 'contract' ) ? $this->get_args ( 'contract' ) : 0;
  202. $contractNum = $this->get_args ( 'contractNum' ) ? $this->get_args ( 'contractNum' ) : 0;
  203. $instructions = $this->get_args ( 'instructions' ) ? $this->get_args ( 'instructions' ) : 0;
  204. $instructionsNum = $this->get_args ( 'instructionsNum' ) ? $this->get_args ( 'instructionsNum' ) : 0;
  205. $remittance = $this->get_args ( 'remittance' ) ? $this->get_args ( 'remittance' ) : 0;
  206. $mailItems = $this->get_args ( 'mailItems' ) ? $this->get_args ( 'mailItems' ) : "";
  207. /*
  208. * $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;
  209. */
  210. if (empty ( $this->staff [0] ))
  211. die ( 'illegal request' );
  212. if (! empty ( $cid ) && ! empty ( $invoiceQuantity ) && ! empty ( $invoiceUnitPrice ) && ! empty ( $invoiceElement )) {
  213. Doo::loadModel ( 'invoice' );
  214. $invoice = new invoice ();
  215. Doo::loadModel ( 'L_category' );
  216. $lCategory = new L_category ();
  217. Doo::loadModel ( 'invoiceManage' );
  218. $invoiceManage = new invoiceManage ();
  219. Doo::loadModel ( 'invoiceOperationLog' );
  220. $invoiceOperationLog = new invoiceOperationLog ();
  221. $categoryDetil = $lCategory->getOne ( array (
  222. 'SELECT' => 'title',
  223. 'where' => 'cid=' . $cid,
  224. 'asArray' => true
  225. ) );
  226. $invoicePrice = $invoiceQuantity * $invoiceUnitPrice;
  227. $invoiceManageList = $invoiceManage->getInvoiceByAll ();
  228. $invoiceManageDetail = $invoiceManage->getInvoiceByMold ( "发票审批" );
  229. // print_r(current($invoiceManageDetail ['staffList']));
  230. // die;
  231. $moldManage = array ();
  232. foreach ( $invoiceManageList as $key => $value ) {
  233. if ($value ['mold'] == '发票打印')
  234. $moldManage [$value ['mold']] = $value ['staffList'];
  235. elseif ($value ['mold'] == '发票邮寄')
  236. $moldManage [$value ['mold']] = $value ['staffList'];
  237. elseif ($value ['mold'] == '发票退票')
  238. $moldManage [$value ['mold']] = $value ['staffList'];
  239. }
  240. $pendingApprovalsSid=current ( $invoiceManageDetail ['staffList'] ) [0];
  241. $item = array (
  242. 'cid' => $cid,
  243. 'categoryName' => $categoryDetil ['title'],
  244. 'invoiceElement' => $invoiceElement,
  245. 'invoiceQuantity' => $invoiceQuantity,
  246. 'invoiceUnitPrice' => $invoiceUnitPrice,
  247. 'invoicePrice' => $invoicePrice,
  248. 'invoiceType' => $invoiceType,
  249. 'doPost' => $doPost,
  250. 'status' => 1,
  251. 'invoiceSerial' => "#F" . date ( "Ymd" ) . mt_rand ( 1000, 9999 ),
  252. 'date' => date ( "Y-m-d H:i:s" ),
  253. 'updateTime' => date ( "Y-m-d H:i:s" ),
  254. 'sid' => $this->staff [0] ['sid'],
  255. 'userName' => $this->staff [0] ['username'],
  256. 'invoiceManage' => $invoiceManageDetail ['staff'],
  257. 'pendingApprovals' => $pendingApprovalsSid,
  258. 'moldManage' => json_encode ( $moldManage ),
  259. 'remark' => $remark
  260. );
  261. if ($invoiceType == 0)
  262. $item += array (
  263. 'invoiceTitle' => $invoiceTitle,
  264. 'TIN' => $TINT,
  265. 'address' => $addressT,
  266. 'phone' => $phoneT,
  267. 'bank' => $bankT,
  268. 'bankAccount' => $bankAccountT
  269. );
  270. else {
  271. $item += array (
  272. 'invoiceCompany' => $invoiceCompany,
  273. 'TIN' => $TIN,
  274. 'address' => $address,
  275. 'phone' => $phone,
  276. 'bank' => $bank,
  277. 'bankAccount' => $bankAccount
  278. );
  279. }
  280. if ($doPost == 1) {
  281. $mailList = array (
  282. 'invoice' => 1,
  283. 'mailItems' => $mailItems
  284. );
  285. if (! empty ( $softLock ))
  286. $mailList += array (
  287. 'softLock' => $softLockNum
  288. );
  289. else
  290. $mailList += array (
  291. 'softLock' => 0
  292. );
  293. if (! empty ( $contract ))
  294. $mailList += array (
  295. 'contract' => $contractNum
  296. );
  297. else
  298. $mailList += array (
  299. 'contract' => 0
  300. );
  301. if (! empty ( $instructions ))
  302. $mailList += array (
  303. 'instructions' => $instructionsNum
  304. );
  305. else
  306. $mailList += array (
  307. 'instructions' => 0
  308. );
  309. if (! empty ( $remittance ))
  310. $mailList += array (
  311. 'remittance' => $remittance
  312. );
  313. else
  314. $mailList += array (
  315. 'remittance' => ''
  316. );
  317. $mailString = '发票x1,备注:' . $mailItems;
  318. if (! empty ( $softLock ))
  319. $mailString .= ',软件锁x' . $softLockNum;
  320. if (! empty ( $contract ))
  321. $mailString .= ',合同x' . $contractNum;
  322. if (! empty ( $instructions ))
  323. $mailString .= ',说明书x' . $instructionsNum;
  324. if (! empty ( $remittance ))
  325. $mailString .= ',汇款账号单';
  326. $item += array (
  327. 'recipients' => $recipients,
  328. 'recipientsPhone' => $recipientsPhone,
  329. 'recipientsAddress' => $recipientsAddress,
  330. 'mailItems' => $mailString,
  331. 'mailItemsJson' => json_encode ( $mailList )
  332. );
  333. }
  334. $iid = $invoice->addInvoice ( $item );
  335. $item = array (
  336. 'date' => date ( "Y-m-d H:i:s" ),
  337. 'operation' => "创建",
  338. 'status' => 1,
  339. 'img' => $this->staff [0] ['avatar'],
  340. 'username' => $this->staff [0] ['username'],
  341. 'uid' => $this->staff [0] ['sid'],
  342. 'category' => $this->staff [0] ['category'],
  343. 'iid' => $iid
  344. );
  345. $invoiceOperationLog->setInvoiceOperationLog ( $item );
  346. $item = array (
  347. 'date' => date ( "Y-m-d H:i:s" ),
  348. 'operation' => "提交审批",
  349. 'status' => 1,
  350. 'img' => $this->staff [0] ['avatar'],
  351. 'username' => $this->staff [0] ['username'],
  352. 'uid' => $this->staff [0] ['sid'],
  353. 'category' => $this->staff [0] ['category'],
  354. 'iid' => $iid
  355. );
  356. $invoiceOperationLog->setInvoiceOperationLog ( $item );
  357. Doo::loadModel ( 'staff' );
  358. $staff = new staff ();
  359. $username2 = $staff->getOne ( array (
  360. 'select' => 'wxid',
  361. 'where' => 'sid=' . $pendingApprovalsSid,
  362. 'asArray' => TRUE
  363. ) );
  364. //发送微信审批通知
  365. $title2 = '[通知]用户提交了一条开票申请,快到“我的发票”中查看,给用户确认审批。';
  366. $this->msgSend ( '', $title2, '', $username2 ['wxid'] );
  367. }
  368. return "/invoice";
  369. }
  370. function invoiceEdit() {
  371. Doo::loadClass ( 'XDeode' );
  372. $XDeode = new XDeode ( 5 );
  373. $iid = isset ( $this->params ['iid'] ) ? $this->params ['iid'] : "";
  374. $iid = $XDeode->decode ( $iid );
  375. if (! is_numeric ( $iid ))
  376. die ( 'illegal request' );
  377. Doo::loadModel ( 'invoice' );
  378. $invoice = new invoice ();
  379. Doo::loadModel ( 'invoiceOperationLog' );
  380. $invoiceOperationLog = new invoiceOperationLog ();
  381. $invoiceDetail = $invoice->getInvoiceByIid ( $iid );
  382. $operation = $invoiceOperationLog->getInvoiceOperationByDropped ( $iid );
  383. $invoiceDetail ['mailItemsJson'] = json_decode ( $invoiceDetail ['mailItemsJson'], true );
  384. $this->data ['operation'] = $operation;
  385. $this->data ['invoiceDetail'] = $invoiceDetail;
  386. $this->data ['memu'] = "invoice";
  387. $this->data ['staff'] = $this->staff;
  388. $this->data ['receiptMemu'] = 'invoice';
  389. $this->render ( "/admin/invoiceEdit", $this->data );
  390. }
  391. /**
  392. * 重新编辑退回的发票
  393. * @return string
  394. */
  395. function invoiceEditDo() {
  396. $iidKey = $this->get_args ( 'iidKey' ) ? $this->get_args ( 'iidKey' ) : '';
  397. Doo::loadModel ( 'invoice' );
  398. $invoice = new invoice ();
  399. $iid = $invoice->authcode ( $iidKey );
  400. if (! empty ( $iid ) && ! is_numeric ( $iid ))
  401. die ( 'illegal request' );
  402. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  403. $invoiceType = $this->get_args ( 'invoiceType' ) && is_numeric ( $this->get_args ( 'invoiceType' ) ) ? $this->get_args ( 'invoiceType' ) : 0;
  404. $doPost = $this->get_args ( 'doPost' ) && is_numeric ( $this->get_args ( 'doPost' ) ) ? $this->get_args ( 'doPost' ) : 0;
  405. $invoicePrice = $this->get_args ( 'invoicePrice' ) ? $this->get_args ( 'invoicePrice' ) : "";
  406. $invoiceQuantity = $this->get_args ( 'invoiceQuantity' ) && is_numeric ( $this->get_args ( 'invoiceQuantity' ) ) ? $this->get_args ( 'invoiceQuantity' ) : 0;
  407. $invoiceUnitPrice = $this->get_args ( 'invoiceUnitPrice' ) && is_numeric ( $this->get_args ( 'invoiceUnitPrice' ) ) ? $this->get_args ( 'invoiceUnitPrice' ) : 0;
  408. $invoiceElement = $this->get_args ( 'invoiceElement' ) ? $this->get_args ( 'invoiceElement' ) : "";
  409. $invoiceTitle = $this->get_args ( 'invoiceTitle' ) ? $this->get_args ( 'invoiceTitle' ) : "";
  410. $invoiceCompany = $this->get_args ( 'invoiceCompany' ) ? $this->get_args ( 'invoiceCompany' ) : "";
  411. $TIN = $this->get_args ( 'TIN' ) ? $this->get_args ( 'TIN' ) : "";
  412. $address = $this->get_args ( 'address' ) ? $this->get_args ( 'address' ) : "";
  413. $phone = $this->get_args ( 'phone' ) ? $this->get_args ( 'phone' ) : "";
  414. $bank = $this->get_args ( 'bank' ) ? $this->get_args ( 'bank' ) : "";
  415. $bankAccount = $this->get_args ( 'bankAccount' ) ? $this->get_args ( 'bankAccount' ) : "";
  416. $recipients = $this->get_args ( 'recipients' ) ? $this->get_args ( 'recipients' ) : "";
  417. $recipientsPhone = $this->get_args ( 'recipientsPhone' ) ? $this->get_args ( 'recipientsPhone' ) : "";
  418. $recipientsAddress = $this->get_args ( 'recipientsAddress' ) ? $this->get_args ( 'recipientsAddress' ) : "";
  419. $mailItems = $this->get_args ( 'mailItems' ) ? $this->get_args ( 'mailItems' ) : "";
  420. $remark = $this->get_args ( 'remark' ) ? $this->get_args ( 'remark' ) : "";
  421. $TINT = $this->get_args ( 'TINT' ) ? $this->get_args ( 'TINT' ) : "";
  422. $addressT = $this->get_args ( 'addressT' ) ? $this->get_args ( 'addressT' ) : "";
  423. $phoneT = $this->get_args ( 'phoneT' ) ? $this->get_args ( 'phoneT' ) : "";
  424. $bankT = $this->get_args ( 'bankT' ) ? $this->get_args ( 'bankT' ) : "";
  425. $bankAccountT = $this->get_args ( 'bankAccountT' ) ? $this->get_args ( 'bankAccountT' ) : "";
  426. $softLock = $this->get_args ( 'softLock' ) ? $this->get_args ( 'softLock' ) : 0;
  427. $softLockNum = $this->get_args ( 'softLockNum' ) ? $this->get_args ( 'softLockNum' ) : 0;
  428. $contract = $this->get_args ( 'contract' ) ? $this->get_args ( 'contract' ) : 0;
  429. $contractNum = $this->get_args ( 'contractNum' ) ? $this->get_args ( 'contractNum' ) : 0;
  430. $instructions = $this->get_args ( 'instructions' ) ? $this->get_args ( 'instructions' ) : 0;
  431. $instructionsNum = $this->get_args ( 'instructionsNum' ) ? $this->get_args ( 'instructionsNum' ) : 0;
  432. $remittance = $this->get_args ( 'remittance' ) ? $this->get_args ( 'remittance' ) : 0;
  433. if (! empty ( $cid ) && ! empty ( $invoiceQuantity ) && ! empty ( $invoiceUnitPrice ) && ! empty ( $invoiceElement ) && ! empty ( $iid )) {
  434. Doo::loadModel ( 'invoiceManage' );
  435. $invoiceManage = new invoiceManage ();
  436. Doo::loadModel ( 'invoiceOperationLog' );
  437. $invoiceOperationLog = new invoiceOperationLog ();
  438. $cid = explode ( ':', $cid );
  439. $invoiceManageList = $invoiceManage->getInvoiceByAll ();
  440. $invoiceManageDetail = $invoiceManage->getInvoiceByMold ( "发票审批" );
  441. $moldManage = array ();
  442. foreach ( $invoiceManageList as $key => $value ) {
  443. if ($value ['mold'] == '发票打印')
  444. $moldManage [$value ['mold']] = $value ['staffList'];
  445. elseif ($value ['mold'] == '发票邮寄')
  446. $moldManage [$value ['mold']] = $value ['staffList'];
  447. elseif ($value ['mold'] == '发票打印')
  448. $moldManage [$value ['mold']] = $value ['staffList'];
  449. }
  450. $invoicePrice = $invoiceQuantity * $invoiceUnitPrice;
  451. $item = array (
  452. 'iid' => $iid,
  453. 'cid' => $cid [0],
  454. 'categoryName' => $cid [1],
  455. 'invoiceElement' => $invoiceElement,
  456. 'invoiceQuantity' => $invoiceQuantity,
  457. 'invoiceUnitPrice' => $invoiceUnitPrice,
  458. 'invoicePrice' => $invoicePrice,
  459. 'invoiceType' => $invoiceType,
  460. 'doPost' => $doPost,
  461. 'status' => 1,
  462. 'updateTime' => date ( "Y-m-d H:i:s" ),
  463. 'remark' => $remark
  464. );
  465. if ($invoiceType == 0)
  466. $item += array (
  467. 'invoiceTitle' => $invoiceTitle,
  468. 'TIN' => $TINT,
  469. 'address' => $addressT,
  470. 'phone' => $phoneT,
  471. 'bank' => $bankT,
  472. 'bankAccount' => $bankAccountT
  473. );
  474. else {
  475. $item += array (
  476. 'invoiceCompany' => $invoiceCompany,
  477. 'TIN' => $TIN,
  478. 'address' => $address,
  479. 'phone' => $phone,
  480. 'bank' => $bank,
  481. 'bankAccount' => $bankAccount
  482. );
  483. }
  484. if ($doPost == 1) {
  485. $mailList = array (
  486. 'invoice' => 1,
  487. 'mailItems' => $mailItems
  488. );
  489. if (! empty ( $softLock ))
  490. $mailList += array (
  491. 'softLock' => $softLockNum
  492. );
  493. else
  494. $mailList += array (
  495. 'softLock' => '0'
  496. );
  497. if (! empty ( $contract ))
  498. $mailList += array (
  499. 'contract' => $contractNum
  500. );
  501. else
  502. $mailList += array (
  503. 'contract' => '0'
  504. );
  505. if (! empty ( $instructions ))
  506. $mailList += array (
  507. 'instructions' => $instructionsNum
  508. );
  509. else
  510. $mailList += array (
  511. 'instructions' => '0'
  512. );
  513. if (! empty ( $remittance ))
  514. $mailList += array (
  515. 'remittance' => $remittance
  516. );
  517. else
  518. $mailList += array (
  519. 'remittance' => ''
  520. );
  521. $mailString = '发票x1,备注:' . $mailItems;
  522. if (! empty ( $softLock ))
  523. $mailString .= ',软件锁x' . $softLockNum;
  524. if (! empty ( $contract ))
  525. $mailString .= ',合同x' . $contractNum;
  526. if (! empty ( $instructions ))
  527. $mailString .= ',说明书x' . $instructionsNum;
  528. if (! empty ( $remittance ))
  529. $mailString .= ',汇款账号单';
  530. $item += array (
  531. 'recipients' => $recipients,
  532. 'recipientsPhone' => $recipientsPhone,
  533. 'recipientsAddress' => $recipientsAddress,
  534. 'mailItems' => $mailString,
  535. 'mailItemsJson' => json_encode ( $mailList )
  536. );
  537. }
  538. $invoice->setInvoiceByCondition ( $item );
  539. $item = array (
  540. 'date' => date ( "Y-m-d H:i:s" ),
  541. 'operation' => "重新提交审批",
  542. 'status' => 1,
  543. 'img' => $this->staff [0] ['avatar'],
  544. 'username' => $this->staff [0] ['username'],
  545. 'uid' => $this->staff [0] ['sid'],
  546. 'category' => $this->staff [0] ['category'],
  547. 'iid' => $iid
  548. );
  549. $invoiceOperationLog->setInvoiceOperationLog ( $item );
  550. }
  551. return "/invoice";
  552. }
  553. /**
  554. * 培训班
  555. */
  556. function invoiceTraining() {
  557. Doo::loadModel ( 'L_category' );
  558. $lCategory = new L_category ();
  559. Doo::loadModel ( 'invoiceTraining' );
  560. $invoiceTraining = new invoiceTraining ();
  561. $itList=$invoiceTraining->getInvoiceTrainingByStatus(0);
  562. $category = $lCategory->getCategory ();
  563. //print_r($itList);
  564. $this->data['itList']=$itList;
  565. $this->data ['category'] = $category;
  566. $this->data ['memu'] = "invoice";
  567. $this->data ['staff'] = $this->staff;
  568. $this->data ['receiptMemu'] = 'invoiceTraining';
  569. $this->render ( "/admin/invoiceTraining", $this->data );
  570. }
  571. /**
  572. * 创建培训班
  573. */
  574. function invoiceTrainingAdd() {
  575. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  576. $trainName = $this->get_args ( 'trainName' ) ? $this->get_args ( 'trainName' ) : "";
  577. $trainDate = $this->get_args ( 'trainDate' ) ? $this->get_args ( 'trainDate' ) : "";
  578. if (empty ( $this->staff [0] ))
  579. die ( 'illegal request' );
  580. if (! empty ( $cid ) && ! empty ( $trainName ) && ! empty ( $trainDate ) ) {
  581. Doo::loadModel ( 'invoiceTraining' );
  582. $invoiceTraining = new invoiceTraining ();
  583. Doo::loadModel ( 'invoice' );
  584. $invoice = new invoice ();
  585. Doo::loadModel ( 'L_category' );
  586. $lCategory = new L_category ();
  587. Doo::loadModel ( 'invoiceManage' );
  588. $invoiceManage = new invoiceManage ();
  589. Doo::loadModel ( 'invoiceOperationLog' );
  590. $invoiceOperationLog = new invoiceOperationLog ();
  591. $item = array (
  592. 'cid' => $cid,
  593. 'trainName' => $trainName,
  594. 'trainDate' => $trainDate,
  595. 'creator' => $this->staff [0]['sid'],
  596. 'creatorDate' => date ( "Y-m-d H:i:s" )
  597. );
  598. $itid = $invoiceTraining->addInvoiceTraining( $item );
  599. //统计相关
  600. // $item = array (
  601. // 'date' => date ( "Y-m-d H:i:s" ),
  602. // 'operation' => "创建",
  603. // 'status' => 1,
  604. // 'img' => $this->staff [0] ['avatar'],
  605. // 'username' => $this->staff [0] ['username'],
  606. // 'uid' => $this->staff [0] ['sid'],
  607. // 'category' => $this->staff [0] ['category'],
  608. // 'iid' => $iid
  609. // );
  610. // $invoiceOperationLog->setInvoiceOperationLog ( $item );
  611. // $item = array (
  612. // 'date' => date ( "Y-m-d H:i:s" ),
  613. // 'operation' => "提交审批",
  614. // 'status' => 1,
  615. // 'img' => $this->staff [0] ['avatar'],
  616. // 'username' => $this->staff [0] ['username'],
  617. // 'uid' => $this->staff [0] ['sid'],
  618. // 'category' => $this->staff [0] ['category'],
  619. // 'iid' => $iid
  620. // );
  621. // $invoiceOperationLog->setInvoiceOperationLog ( $item );
  622. }
  623. return "/invoiceTraining";
  624. }
  625. /**
  626. * 终止开票
  627. */
  628. function invoiceDroppedDo() {
  629. $droppedIidKey = $this->get_args ( 'droppedIidKey' ) ? $this->get_args ( 'droppedIidKey' ) : '';
  630. Doo::loadModel ( 'invoice' );
  631. $invoice = new invoice ();
  632. Doo::loadModel ( 'invoiceOperationLog' );
  633. $invoiceOperationLog = new invoiceOperationLog ();
  634. $iid = $invoice->authcode ( $droppedIidKey );
  635. if (! empty ( $iid ) && ! is_numeric ( $iid ))
  636. die ( 'illegal request' );
  637. $item = array (
  638. 'iid' => $iid,
  639. 'status' => 4,
  640. 'updateTime' => date ( "Y-m-d H:i:s" )
  641. );
  642. $invoice->setInvoiceByCondition ( $item );
  643. $item = array (
  644. 'date' => date ( "Y-m-d H:i:s" ),
  645. 'operation' => '终止了开票',
  646. 'status' => 4,
  647. 'img' => $this->staff [0] ['avatar'],
  648. 'username' => $this->staff [0] ['username'],
  649. 'uid' => $this->staff [0] ['sid'],
  650. 'category' => $this->staff [0] ['category'],
  651. 'iid' => $iid
  652. );
  653. $invoiceOperationLog->setInvoiceOperationLog ( $item );
  654. return "/invoice";
  655. }
  656. /**
  657. * 更新退票的邮寄信息
  658. */
  659. function invoiceUntreadMailDo() {
  660. $untreadIidKey = $this->get_args ( 'untreadIidKey' ) ? $this->get_args ( 'untreadIidKey' ) : '';
  661. $untreadCompany = $this->get_args ( 'untreadCompany' ) ? $this->get_args ( 'untreadCompany' ) : "";
  662. $untreadNumber = $this->get_args ( 'untreadNumber' ) ? $this->get_args ( 'untreadNumber' ) : "";
  663. $untreadItems = $this->get_args ( 'untreadItems' ) ? $this->get_args ( 'untreadItems' ) : "";
  664. Doo::loadModel ( 'invoice' );
  665. $invoice = new invoice ();
  666. $iid = $invoice->authcode ( $untreadIidKey );
  667. if (! empty ( $iid ) && ! is_numeric ( $iid ))
  668. die ( 'illegal request' );
  669. $item = array (
  670. 'iid' => $iid,
  671. 'untreadCompany' => $untreadCompany,
  672. 'untreadNumber' => $untreadNumber,
  673. 'untreadItems' => $untreadItems
  674. );
  675. $invoice->setInvoiceByCondition ( $item );
  676. return "/invoice";
  677. }
  678. /**
  679. * 申请退票 --
  680. */
  681. function invoiceUntreadDo() {
  682. $untreadIidKey = $this->get_args ( 'untreadIidKey' ) ? $this->get_args ( 'untreadIidKey' ) : '';
  683. $untreadReason = $this->get_args ( 'untreadReason' ) ? $this->get_args ( 'untreadReason' ) : "";
  684. $untreadPost = $this->get_args ( 'untreadPost' ) ? $this->get_args ( 'untreadPost' ) : "";
  685. Doo::loadModel ( 'invoice' );
  686. $invoice = new invoice ();
  687. Doo::loadModel ( 'invoiceOperationLog' );
  688. $invoiceOperationLog = new invoiceOperationLog ();
  689. Doo::loadModel ( 'invoiceReceivables' );
  690. $invoiceReceivables = new invoiceReceivables ();
  691. $iid = $invoice->authcode ( $untreadIidKey );
  692. if (! empty ( $iid ) && ! is_numeric ( $iid ))
  693. die ( 'illegal request' );
  694. /*
  695. * 需求变革 有绑定收款也可以退票 $lt = $invoiceReceivables->getInvoiceReceivablesByIid ( $untreadIidKey ); if (! empty ( $lt )) { header ( 'Content-Type:text/html;charset=utf-8' ); die ( '该发票有收款绑定,请先移除!' ); }
  696. */
  697. $item = array (
  698. 'iid' => $iid,
  699. 'untreadStatus' => 1,
  700. 'untreadReason' => $untreadReason,
  701. 'untreadPost' => $untreadPost,
  702. 'updateTime' => date ( "Y-m-d H:i:s" )
  703. );
  704. $invoice->setInvoiceByCondition ( $item );
  705. $item = array (
  706. 'date' => date ( "Y-m-d H:i:s" ),
  707. 'operation' => '申请退票',
  708. 'status' => 7,
  709. 'img' => $this->staff [0] ['avatar'],
  710. 'username' => $this->staff [0] ['username'],
  711. 'uid' => $this->staff [0] ['sid'],
  712. 'category' => $this->staff [0] ['category'],
  713. 'iid' => $iid
  714. );
  715. $invoiceOperationLog->setInvoiceOperationLog ( $item );
  716. return "/invoice";
  717. }
  718. /**
  719. * 删除已终止的开票
  720. */
  721. function invoiceDelDo() {
  722. Doo::loadClass ( 'XDeode' );
  723. $XDeode = new XDeode ( 5 );
  724. Doo::loadModel ( 'invoice' );
  725. $invoice = new invoice ();
  726. Doo::loadModel ( 'invoiceOperationLog' );
  727. $invoiceOperationLog = new invoiceOperationLog ();
  728. Doo::loadClass ( 'XDeode' );
  729. $XDeode = new XDeode ( 5 );
  730. $sid = $XDeode->decode ( $_COOKIE ["staff"] );
  731. $iid = isset ( $this->params ['iid'] ) ? $this->params ['iid'] : "";
  732. $iid = $XDeode->decode ( $iid );
  733. if (! is_numeric ( $iid ))
  734. die ( 'illegal request' );
  735. $invoiceDetail = $invoice->getMyInvoice ( $sid, $iid );
  736. if (empty ( $invoiceDetail ))
  737. die ( 'illegal request' );
  738. $item = array (
  739. 'iid' => $iid,
  740. 'isDelete' => 1,
  741. 'updateTime' => date ( "Y-m-d H:i:s" )
  742. );
  743. $invoice->setInvoiceByCondition ( $item );
  744. $item = array (
  745. 'date' => date ( "Y-m-d H:i:s" ),
  746. 'operation' => '删除了已终止的发票',
  747. 'status' => 4,
  748. 'img' => $this->staff [0] ['avatar'],
  749. 'username' => $this->staff [0] ['username'],
  750. 'uid' => $this->staff [0] ['sid'],
  751. 'category' => $this->staff [0] ['category'],
  752. 'iid' => $iid
  753. );
  754. $invoiceOperationLog->setInvoiceOperationLog ( $item );
  755. return "/invoice";
  756. }
  757. function invoiceApproval() {
  758. Doo::loadModel ( 'invoice' );
  759. $invoice = new invoice ();
  760. Doo::loadClass ( 'XDeode' );
  761. $XDeode = new XDeode ( 5 );
  762. Doo::loadModel ( 'staff' );
  763. $staff = new staff ();
  764. $invoiceList = $invoice->find ( array (
  765. 'where' => 'status=1 and pendingApprovals=' . $this->staff [0] ['sid'],
  766. 'desc' => 'iid',
  767. 'asArray' => true
  768. ) );
  769. foreach ( $invoiceList as $key => $value ) {
  770. $invoiceList [$key] ['iidKey'] = $XDeode->encode ( $value ['iid'] );
  771. $lastApprover = json_decode ( $value ['processApprovals'], true );
  772. if (! empty ( $lastApprover )) {
  773. $lastApproverKey = array_keys ( $lastApprover );
  774. $lastApprover = end ( $lastApprover );
  775. $staffDetail = $staff->getOne ( array (
  776. 'where' => 'sid=' . end ( $lastApproverKey ),
  777. 'asArray' => true
  778. ) );
  779. $lastApprover ['username'] = $staffDetail ['username'];
  780. }
  781. $invoiceList [$key] ['lastApprover'] = $lastApprover;
  782. }
  783. $ilist = $invoice->getInvoiceByProcessStatus ();
  784. // print_r($ilist);
  785. $this->data ['invoiceList'] = $invoiceList;
  786. $this->data ['ilist'] = $ilist;
  787. $this->data ['memu'] = "invoice";
  788. $this->data ['staff'] = $this->staff;
  789. $this->data ['receiptMemu'] = 'invoiceApproval';
  790. $this->render ( "/admin/invoiceApproval", $this->data );
  791. }
  792. function invoiceDetail() {
  793. Doo::loadClass ( 'XDeode' );
  794. $XDeode = new XDeode ( 5 );
  795. $iid = isset ( $this->params ['iid'] ) ? $this->params ['iid'] : "";
  796. $iid = $XDeode->decode ( $iid );
  797. if (! is_numeric ( $iid ))
  798. die ( 'illegal request' );
  799. Doo::loadModel ( 'invoice' );
  800. $invoice = new invoice ();
  801. Doo::loadModel ( 'invoiceOperationLog' );
  802. $invoiceOperationLog = new invoiceOperationLog ();
  803. $invoiceDetail = $invoice->getOne ( array (
  804. 'where' => 'status=1 and pendingApprovals=' . $this->staff [0] ['sid'] . ' and iid=' . $iid,
  805. 'asArray' => true
  806. ) );
  807. if (empty ( $invoiceDetail ))
  808. die ( 'illegal request' );
  809. $invoiceOperationLogList = $invoiceOperationLog->getInvoiceOperationLogByIid ( $iid );
  810. $this->data ['invoiceDetail'] = $invoiceDetail;
  811. $this->data ['invoiceOperationLogList'] = $invoiceOperationLogList;
  812. $this->data ['INVOICEKEY'] = $invoice->authcode ( $invoiceDetail ['iid'], '' );
  813. $this->data ['memu'] = "invoice";
  814. $this->data ['staff'] = $this->staff;
  815. $this->data ['receiptMemu'] = 'invoiceApproval';
  816. $this->render ( "/admin/invoiceApprovalDetail", $this->data );
  817. }
  818. /**
  819. * 对发票进行审批,其中操作有终止,退回,同意动作。操作成功并记录下操作日志
  820. *
  821. * @since 1.0.0
  822. * @var integer iid 开票ID 已加密
  823. * @var integer status 发票审批状态
  824. * @var integer opintion 审批发票的意见
  825. * @return string 如操作成功返回审批首页
  826. */
  827. function invoiceApprovalDo() {
  828. Doo::loadModel ( 'invoice' );
  829. $invoice = new invoice ();
  830. $iid = $this->get_args ( 'invoiceKey' ) ? $this->get_args ( 'invoiceKey' ) : "";
  831. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  832. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  833. $iid = $invoice->authcode ( $iid );
  834. if (! is_numeric ( $iid ))
  835. die ( 'illegal request' );
  836. // && ! empty ( $opinion )
  837. if (! empty ( $iid ) && ! empty ( $status )) {
  838. if (! ($status == 2 || $status == 3 || $status == 4))
  839. die ( 'illegal request' );
  840. Doo::loadModel ( 'invoiceOperationLog' );
  841. $invoiceOperationLog = new invoiceOperationLog ();
  842. $invoiceDetail = $invoice->getOne ( array (
  843. 'where' => 'status=1 and iid=' . $iid . ' and pendingApprovals=' . $this->staff [0] ['sid'],
  844. 'asArray' => true
  845. ) );
  846. if (empty ( $invoiceDetail ))
  847. die ( 'illegal request' );
  848. $processApprovals = json_decode ( $invoiceDetail ['processApprovals'], true );
  849. $invoiceManage = json_decode ( $invoiceDetail ['invoiceManage'], true );
  850. if ($status == 3) {
  851. $invoice->status = $status;
  852. $item = array (
  853. 'operation' => $opinion
  854. );
  855. } else {
  856. if (empty ( $processApprovals )) {
  857. $processApprovals = array (
  858. $this->staff [0] ['sid'] => array (
  859. 'date' => date ( "Y-m-d H:i:s" ),
  860. 'opinion' => $opinion,
  861. 'status' => $status
  862. )
  863. );
  864. // var_dump(next($invoiceManage));
  865. $nextInvoiceManage = next ( $invoiceManage );
  866. // print_r($nextInvoiceManage);
  867. if ($status != 4 && $nextInvoiceManage !== false)
  868. $invoice->pendingApprovals = $nextInvoiceManage [0];
  869. $invoice->processApprovals = json_encode ( $processApprovals );
  870. // var_dump($invoice);
  871. // print_r($invoiceManage);
  872. } else {
  873. $processApprovals [$this->staff [0] ['sid']] = array (
  874. 'date' => date ( "Y-m-d H:i:s" ),
  875. 'opinion' => $opinion,
  876. 'status' => $status
  877. );
  878. $pendingApprovals = 0;
  879. foreach ( $invoiceManage as $key => $value ) {
  880. if ($value [0] == $this->staff [0] ['sid']) {
  881. if (isset ( $invoiceManage [$key + 1] ))
  882. $pendingApprovals = $invoiceManage [$key + 1] [0];
  883. break;
  884. }
  885. }
  886. if ($status != 4 && ! empty ( $pendingApprovals ))
  887. $invoice->pendingApprovals = $pendingApprovals;
  888. $invoice->processApprovals = json_encode ( $processApprovals );
  889. }
  890. $item = array (
  891. 'operation' => $opinion
  892. );
  893. if (count ( $processApprovals ) == count ( $invoiceManage ) && $status != 4) {
  894. $invoice->status = $status;
  895. $invoice->pendingApprovals = 0;
  896. } elseif ($status == 4) {
  897. $invoice->status = $status;
  898. $item = array (
  899. 'operation' => $opinion
  900. );
  901. }
  902. }
  903. $invoice->updateTime = date ( "Y-m-d H:i:s" );
  904. $invoice->update ( array (
  905. 'where' => 'iid=' . $iid
  906. ) );
  907. $item += array (
  908. 'date' => date ( "Y-m-d H:i:s" ),
  909. 'img' => $this->staff [0] ['avatar'],
  910. 'username' => $this->staff [0] ['username'],
  911. 'uid' => $this->staff [0] ['sid'],
  912. 'category' => $this->staff [0] ['category'],
  913. 'status' => $status,
  914. 'iid' => $iid
  915. );
  916. $invoiceOperationLog->setInvoiceOperationLog ( $item );
  917. return '/invoiceApproval';
  918. }
  919. die ( 'illegal request' );
  920. }
  921. /**
  922. * 展示需要打印的发票数据
  923. *
  924. * @since 1.0.0
  925. */
  926. function invoicePrint() {
  927. Doo::loadModel ( 'invoice' );
  928. $invoice = new invoice ();
  929. Doo::loadClass ( 'XDeode' );
  930. $XDeode = new XDeode ( 5 );
  931. Doo::loadModel ( 'staff' );
  932. $staff = new staff ();
  933. $toPrint = $invoice->getPrintInvoiceByManage ( $this->staff [0] ['sid'], 0 );
  934. $printed = $invoice->getPrintInvoiceByManage ( $this->staff [0] ['sid'], 1 );
  935. foreach ( $toPrint as $key => $value ) {
  936. $toPrint [$key] ['iidKey'] = $XDeode->encode ( $value ['iid'] );
  937. $lastApprover = json_decode ( $value ['processApprovals'], true );
  938. if (! empty ( $lastApprover )) {
  939. $lastApproverKey = array_keys ( $lastApprover );
  940. $lastApprover = end ( $lastApprover );
  941. $staffDetail = $staff->getOne ( array (
  942. 'where' => 'sid=' . end ( $lastApproverKey ),
  943. 'asArray' => true
  944. ) );
  945. $lastApprover ['username'] = $staffDetail ['username'];
  946. }
  947. $toPrint [$key] ['lastApprover'] = $lastApprover;
  948. }
  949. foreach ( $printed as $key => $value ) {
  950. $printed [$key] ['iidKey'] = $XDeode->encode ( $value ['iid'] );
  951. $lastApprover = json_decode ( $value ['processApprovals'], true );
  952. if (! empty ( $lastApprover )) {
  953. $lastApproverKey = array_keys ( $lastApprover );
  954. $lastApprover = end ( $lastApprover );
  955. $staffDetail = $staff->getOne ( array (
  956. 'where' => 'sid=' . end ( $lastApproverKey ),
  957. 'asArray' => true
  958. ) );
  959. $lastApprover ['username'] = $staffDetail ['username'];
  960. }
  961. $printed [$key] ['lastApprover'] = $lastApprover;
  962. }
  963. $this->data ['printed'] = $printed;
  964. $this->data ['toPrint'] = $toPrint;
  965. $this->data ['memu'] = "invoice";
  966. $this->data ['staff'] = $this->staff;
  967. $this->data ['receiptMemu'] = 'invoicePrint';
  968. $this->render ( "/admin/invoicePrint", $this->data );
  969. }
  970. /**
  971. * 展示发票打印的详情页面
  972. *
  973. * @since 1.0.0
  974. */
  975. function invoicePrintDetail() {
  976. Doo::loadClass ( 'XDeode' );
  977. $XDeode = new XDeode ( 5 );
  978. $iid = isset ( $this->params ['iid'] ) ? $this->params ['iid'] : "";
  979. $iid = $XDeode->decode ( $iid );
  980. if (! is_numeric ( $iid ))
  981. die ( 'illegal request' );
  982. Doo::loadModel ( 'invoice' );
  983. $invoice = new invoice ();
  984. Doo::loadModel ( 'invoiceOperationLog' );
  985. $invoiceOperationLog = new invoiceOperationLog ();
  986. $invoiceDetail = $invoice->getPrintInvoiceByManage ( $this->staff [0] ['sid'], 0, $iid );
  987. if (empty ( $invoiceDetail ))
  988. die ( 'illegal request' );
  989. $invoiceOperationLogList = $invoiceOperationLog->getInvoiceOperationLogByIid ( $iid );
  990. $this->data ['invoiceDetail'] = $invoiceDetail;
  991. $this->data ['invoiceOperationLogList'] = $invoiceOperationLogList;
  992. $this->data ['INVOICEKEY'] = $invoice->authcode ( $invoiceDetail ['iid'], '' );
  993. $this->data ['memu'] = "invoice";
  994. $this->data ['staff'] = $this->staff;
  995. $this->data ['receiptMemu'] = 'invoicePrint';
  996. $this->render ( "/admin/invoicePrintDetail", $this->data );
  997. }
  998. /**
  999. * 填写票号并完成打印
  1000. * @since 1.0.0
  1001. */
  1002. function invoicePrintDo() {
  1003. Doo::loadModel ( 'invoice' );
  1004. $invoice = new invoice ();
  1005. $iid = $this->get_args ( 'invoiceKey' ) ? $this->get_args ( 'invoiceKey' ) : "";
  1006. $invoiceNo = $this->get_args ( 'invoiceNo' ) ? $this->get_args ( 'invoiceNo' ) : "";
  1007. $iid = $invoice->authcode ( $iid );
  1008. if (! is_numeric ( $iid ))
  1009. die ( 'illegal request' );
  1010. if (! empty ( $iid ) && ! empty ( $invoiceNo )) {
  1011. Doo::loadModel ( 'invoiceOperationLog' );
  1012. $invoiceOperationLog = new invoiceOperationLog ();
  1013. Doo::loadModel ( 'invoiceStatistics' );
  1014. $invoiceStatistics = new invoiceStatistics ();
  1015. // $info=$invoice->getOne(array('where'=>"invoiceNo = '".$invoiceNo."'",'asArray' => TRUE));
  1016. $invoicePrintDetail = $invoice->getInvoiceByPrint ( $iid );
  1017. if (empty ( $invoicePrintDetail ))
  1018. die ( 'illegal request' );
  1019. $item = array (
  1020. 'iid' => $iid,
  1021. 'printStatus' => 1,
  1022. 'updateTime' => date ( "Y-m-d H:i:s" ),
  1023. 'printer' => $this->staff [0] ['username'],
  1024. 'printTime' => date ( "Y-m-d H:i:s" ),
  1025. 'invoiceNo' => $invoiceNo
  1026. );
  1027. $invoice->setInvoiceByCondition ( $item );
  1028. $item = array (
  1029. 'date' => date ( "Y-m-d H:i:s" ),
  1030. 'operation' => $invoiceNo,
  1031. 'status' => 5,
  1032. 'img' => $this->staff [0] ['avatar'],
  1033. 'username' => $this->staff [0] ['username'],
  1034. 'uid' => $this->staff [0] ['sid'],
  1035. 'category' => $this->staff [0] ['category'],
  1036. 'iid' => $iid
  1037. );
  1038. $invoiceOperationLog->setInvoiceOperationLog ( $item );
  1039. // 去统计--负票不汇总
  1040. if ($invoicePrintDetail ['untreadStatus'] != 4) {
  1041. $item = array (
  1042. 'date' => date ( "Y-m-d H:i:s" ),
  1043. 'priceClass' => 1,
  1044. 'cid' => $invoicePrintDetail ['cid'],
  1045. 'staff' => $invoicePrintDetail ['sid'],
  1046. 'invoicePrice' => $invoicePrintDetail ['invoicePrice']
  1047. );
  1048. $invoiceStatistics->setInvoiceStatisticsByCondition ( $item );
  1049. }
  1050. // 发送通知信息到微信-去除
  1051. // $this->setWXMsg($iid,'PRINT');
  1052. // 申请人获取微信通知
  1053. Doo::loadModel ( 'staff' );
  1054. $staff = new staff ();
  1055. Doo::loadClass ( 'XDeode' );
  1056. $XDeode = new XDeode ( 5 );
  1057. $username2 = $staff->getOne ( array (
  1058. 'select' => 'wxid',
  1059. 'where' => 'sid=' . $invoicePrintDetail ['sid'],
  1060. 'asArray' => TRUE
  1061. ) );
  1062. $title2 = '[结果]您的发票' . $invoicePrintDetail ['invoiceSerial'] . '完成打印';
  1063. $msg = '';
  1064. $url = 'http://m.cld.smartcost.com.cn/invoicePrintDetail/' . $XDeode->encode ( $invoicePrintDetail ['iid'] ) . '.html';
  1065. $hfreult = $this->msgSend ( $msg, $title2, $url, $username2 ['wxid'] );
  1066. return "/invoicePrint";
  1067. }
  1068. }
  1069. /**
  1070. * 需要邮寄的发票
  1071. * @since 1.0.0
  1072. */
  1073. function invoicePost() {
  1074. Doo::loadModel ( 'invoice' );
  1075. $invoice = new invoice ();
  1076. Doo::loadModel ( 'express' );
  1077. $express = new express ();
  1078. $invoicePost = $invoice->getPostByInvoice ();
  1079. $invoicePosted = $invoice->getPostByInvoice ( 1 );
  1080. $expressList = $express->getExpressByAll ();
  1081. $this->data ['expressList'] = $expressList;
  1082. $this->data ['invoicePost'] = $invoicePost;
  1083. $this->data ['invoicePosted'] = $invoicePosted;
  1084. $this->data ['memu'] = "invoice";
  1085. $this->data ['staff'] = $this->staff;
  1086. $this->data ['receiptMemu'] = 'invoicePost';
  1087. $this->render ( "/admin/invoicePost", $this->data );
  1088. }
  1089. /**
  1090. * 添加发票邮寄信息
  1091. */
  1092. function invoiceExpressAddDo() {
  1093. Doo::loadModel ( 'invoice' );
  1094. $invoice = new invoice ();
  1095. $iid = $this->get_args ( 'iidKey' ) ? $this->get_args ( 'iidKey' ) : "";
  1096. $expressCompany = $this->get_args ( 'express' ) ? $this->get_args ( 'express' ) : "";
  1097. $expressNumber = $this->get_args ( 'nu' ) ? $this->get_args ( 'nu' ) : "";
  1098. $actualItems = $this->get_args ( 'actualItems' ) ? $this->get_args ( 'actualItems' ) : "";
  1099. $iid = $iid = $invoice->authcode ( $iid );
  1100. if (! is_numeric ( $iid ) && empty ( $expressCompany ) && empty ( $expressNumber ) && empty ( $actualItems ))
  1101. die ( 'illegal request' );
  1102. $invoicePrintDetail = $invoice->getInvoiceByIid ( $iid );
  1103. $item = array (
  1104. 'iid' => $iid,
  1105. 'postStatus' => 1,
  1106. 'updateTime' => date ( "Y-m-d H:i:s" ),
  1107. 'postTime' => date ( "Y-m-d H:i:s" ),
  1108. 'expressCompany' => $expressCompany,
  1109. 'expressNumber' => $expressNumber,
  1110. 'actualItems' => $actualItems,
  1111. 'poster' => $this->staff [0] ['username']
  1112. );
  1113. $invoice->setInvoiceByCondition ( $item );
  1114. // 微信通知-去掉
  1115. // $this->setWXMsg ( $iid );
  1116. Doo::loadModel ( 'staff' );
  1117. $staff = new staff ();
  1118. Doo::loadClass ( 'XDeode' );
  1119. $XDeode = new XDeode ( 5 );
  1120. $username2 = $staff->getOne ( array (
  1121. 'select' => 'wxid',
  1122. 'where' => 'sid=' . $invoicePrintDetail ['sid'],
  1123. 'asArray' => TRUE
  1124. ) );
  1125. $title2 = '[结果]您的发票' . $invoicePrintDetail ['invoiceSerial'] . '已邮寄';
  1126. $expCom = explode ( ":", $invoicePrintDetail ['expressCompany'] );
  1127. if (empty ( $expCom ))
  1128. $expCom [0] = '';
  1129. $msg = $expCom [0] . ':' . $invoicePrintDetail ['expressNumber'] . '';
  1130. $url = 'https://m.kuaidi100.com/result.jsp?nu=' . $invoicePrintDetail ['expressNumber'];
  1131. $hfreult = $this->msgSend ( $msg, $title2, $url, $username2 ['wxid'] );
  1132. return '/invoicePost';
  1133. }
  1134. function invoiceExpressUpdateDo() {
  1135. Doo::loadModel ( 'invoice' );
  1136. $invoice = new invoice ();
  1137. $action = $this->get_args ( 'action' ) ? $this->get_args ( 'action' ) : "";
  1138. $iid = $this->get_args ( 'iidKey' ) ? $this->get_args ( 'iidKey' ) : "";
  1139. $expressCompany = $this->get_args ( 'express' ) ? $this->get_args ( 'express' ) : "";
  1140. $expressNumber = $this->get_args ( 'nu' ) ? $this->get_args ( 'nu' ) : "";
  1141. $actualItems = $this->get_args ( 'actualItems' ) ? $this->get_args ( 'actualItems' ) : "";
  1142. $iid = $invoice->authcode ( $iid );
  1143. if (! is_numeric ( $iid ) && empty ( $expressCompany ) && empty ( $expressNumber ) && empty ( $actualItems ))
  1144. die ( 'illegal request' );
  1145. $item = array (
  1146. 'iid' => $iid,
  1147. 'updateTime' => date ( "Y-m-d H:i:s" ),
  1148. 'expressCompany' => $expressCompany,
  1149. 'expressNumber' => $expressNumber,
  1150. 'actualItems' => $actualItems,
  1151. 'poster' => $this->staff [0] ['username']
  1152. );
  1153. $invoice->setInvoiceByCondition ( $item );
  1154. return $action;
  1155. }
  1156. /**
  1157. * 可退票管理
  1158. */
  1159. function invoiceUntreadIsAchieve() {
  1160. Doo::loadModel ( 'invoice' );
  1161. $invoice = new invoice ();
  1162. Doo::loadClass ( 'XDeode' );
  1163. $XDeode = new XDeode ( 5 );
  1164. $MebSea = $this->get_args ( 'MebSea' ) ? $this->get_args ( 'MebSea' ) : "";
  1165. $page_size = 18;
  1166. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  1167. $date = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "";
  1168. $get = "?date=" . urlencode ( $date ) . "&MebSea=" . urlencode ( $MebSea );
  1169. $dateArr = explode ( ':', $date );
  1170. $D1 = '';
  1171. $D2 = '';
  1172. if (! empty ( $date )) {
  1173. $D1 = $dateArr [0];
  1174. $D2 = $dateArr [1];
  1175. }
  1176. $con = '';
  1177. if (! empty ( $D1 ) && ! empty ( $D2 ))
  1178. $con = ' and bindTime BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
  1179. // if ($date == 'MONTHO')
  1180. // $con = ' and updateTime>DATE_SUB(CURDATE(), INTERVAL 1 MONTH)';
  1181. // elseif ($date == 'MONTHT')
  1182. // $con = ' and updateTime>DATE_SUB(CURDATE(), INTERVAL 3 MONTH)';
  1183. // elseif ($date == 'MONTHY')
  1184. // $con = ' and updateTime>DATE_SUB(CURDATE(), INTERVAL 1 YEAR)';
  1185. if (! empty ( $MebSea )) {
  1186. $con .= ' and ( invoiceTitle like "%' . $MebSea . '%" or invoiceCompany like "%' . $MebSea . '%" or invoicePrice like "%' . $MebSea . '%" )';
  1187. }
  1188. $pageinfo ['page'] = array (
  1189. 'previous' => ''
  1190. );
  1191. // printStatus=1 and
  1192. $sql = " (untreadStatus=0 or untreadStatus=3) and status=2 and sid=" . $this->staff [0] ['sid'] . $con;
  1193. $action = "invoiceUntreadIsAchieve";
  1194. $pageinfo = $this->get_page ( "CLD_invoice", $sql, $page, $page_size, $action, $get, "" );
  1195. $limit = $pageinfo ['lower'] . ',' . $page_size;
  1196. $list = $invoice->getInvoiceByUntreadStatusPage ( $limit, $sql );
  1197. // print_r($list);
  1198. $this->data ['MebSeaEn'] = $MebSea;
  1199. // $this->data ['MebSea'] = urlencode ( $MebSea );
  1200. $this->data ['get'] = $get;
  1201. $this->data ['page'] = $pageinfo;
  1202. $this->data ['date'] = $date;
  1203. $this->data ['list'] = $list;
  1204. $this->data ['memu'] = "invoice";
  1205. $this->data ['staff'] = $this->staff;
  1206. $this->data ['receiptMemu'] = 'invoice';
  1207. $this->render ( "/admin/invoiceUntreadIsAchieve", $this->data );
  1208. }
  1209. /**
  1210. * 退票处理页面
  1211. */
  1212. function invoiceUntread() {
  1213. Doo::loadModel ( 'invoice' );
  1214. $invoice = new invoice ();
  1215. $untreadInvoice = $invoice->getInvoiceByUntreadStatus ( 1 );
  1216. $establishedInvoice = $invoice->getInvoiceByUntreadStatus ( 2 );
  1217. foreach ( $establishedInvoice as $key => $value ) {
  1218. // months
  1219. $lossDate = strtotime ( "+1 month", strtotime ( $value ['OperationLog'] ['date'] ) );
  1220. $nowDate = strtotime ( 'now' );
  1221. $establishedInvoice [$key] ['lossShow'] = false;
  1222. if ($lossDate < $nowDate)
  1223. $establishedInvoice [$key] ['lossShow'] = true;
  1224. }
  1225. $this->data ['untreadInvoice'] = $untreadInvoice;
  1226. $this->data ['establishedInvoice'] = $establishedInvoice;
  1227. $this->data ['memu'] = "invoice";
  1228. $this->data ['staff'] = $this->staff;
  1229. $this->data ['receiptMemu'] = 'invoiceUntread';
  1230. $this->render ( "/admin/invoiceUntread", $this->data );
  1231. }
  1232. /**
  1233. * 确认收到退回的发票,开票状态为退回 //收款状态解绑,公司统计扣除入账额度
  1234. */
  1235. function invoiceUntreadEstablishedDo() {
  1236. $untreadIidKey = $this->get_args ( 'untreadIidKey' ) ? $this->get_args ( 'untreadIidKey' ) : '';
  1237. Doo::loadModel ( 'invoice' );
  1238. $invoice = new invoice ();
  1239. Doo::loadModel ( 'invoiceOperationLog' );
  1240. $invoiceOperationLog = new invoiceOperationLog ();
  1241. Doo::loadModel ( 'invoiceReceivables' );
  1242. Doo::loadModel ( 'invoiceStatistics' );
  1243. $iid = $invoice->authcode ( $untreadIidKey );
  1244. if (! empty ( $iid ) && ! is_numeric ( $iid ))
  1245. die ( 'illegal request' );
  1246. $invoiceDetails = $invoice->getInvoiceByIid ( $iid );
  1247. if ($invoiceDetails ['untreadStatus'] != 1)
  1248. die ( 'illegal request' );
  1249. $item = array (
  1250. 'iid' => $iid,
  1251. // 'irid'=>'',
  1252. 'untreadStatus' => 2,
  1253. 'updateTime' => date ( "Y-m-d H:i:s" )
  1254. );
  1255. $invoice->setInvoiceByCondition ( $item );
  1256. $item = array (
  1257. 'date' => date ( "Y-m-d H:i:s" ),
  1258. 'operation' => '已确认退票',
  1259. 'status' => 6,
  1260. 'img' => $this->staff [0] ['avatar'],
  1261. 'username' => $this->staff [0] ['username'],
  1262. 'uid' => $this->staff [0] ['sid'],
  1263. 'category' => $this->staff [0] ['category'],
  1264. 'iid' => $iid
  1265. );
  1266. $invoiceOperationLog->setInvoiceOperationLog ( $item );
  1267. // 收款解绑以及入账扣除 收款扣除
  1268. if (! empty ( $invoiceDetails ['irid'] )) {
  1269. $iridList = explode ( ',', $invoiceDetails ['irid'] );
  1270. foreach ( $iridList as $value ) {
  1271. $invoiceReceivables = new invoiceReceivables ();
  1272. $irDetails = $invoiceReceivables->getOne ( array (
  1273. 'where' => " irid=" . $value . ' and bindStatus=1',
  1274. 'asArray' => TRUE
  1275. ) );
  1276. $item = array (
  1277. 'irid' => $value,
  1278. 'bindStatus' => 0,
  1279. 'untreadStatus' => 1,
  1280. 'untreadStaff' => $invoiceDetails ['userName'],
  1281. 'unbundlingTime' => date ( "Y-m-d H:i:s" ),
  1282. 'iid' => 0
  1283. );
  1284. $invoiceReceivables->setInvoiceReceivablesByCondition ( $item );
  1285. if (! empty ( $irDetails )) {
  1286. //扣除入账
  1287. $invoiceStatistics = new invoiceStatistics ();
  1288. $item = array (
  1289. 'date' => date ( 'Y-m-d', strtotime ( $irDetails ['receivablesDate'] ) ),
  1290. 'priceClass' => 3,
  1291. 'cid' => $invoiceDetails ['cid'],
  1292. 'staff' => $invoiceDetails ['sid'],
  1293. 'accountPrice' => - $irDetails ['receivablesPrice']
  1294. );
  1295. $invoiceStatistics->setInvoiceStatisticsByCondition ( $item );
  1296. //扣除收款
  1297. $invoiceStatistics = new invoiceStatistics ();
  1298. $item = array (
  1299. 'date' => date ( 'Y-m-d', strtotime ( $irDetails ['receivablesDate'] ) ),
  1300. 'priceClass' => 2,
  1301. 'cid' => $invoiceDetails ['cid'],
  1302. 'staff' => $invoiceDetails ['sid'],
  1303. 'irid'=>$irDetails ['irid'],
  1304. 'receivablesPrice' => - $irDetails ['receivablesPrice']
  1305. );
  1306. $invoiceStatistics->setInvoiceStatisticsByCondition ( $item );
  1307. }
  1308. }
  1309. }
  1310. return "/invoiceUntread";
  1311. }
  1312. /**
  1313. * 建立负票,关联原来发票
  1314. */
  1315. function invoiceLossDo() {
  1316. $iidKey = $this->get_args ( 'iidKey' ) ? $this->get_args ( 'iidKey' ) : "";
  1317. if (! empty ( $iidKey )) {
  1318. Doo::loadClass ( 'XDeode' );
  1319. $XDeode = new XDeode ( 5 );
  1320. Doo::loadModel ( 'invoice' );
  1321. $invoice = new invoice ();
  1322. Doo::loadModel ( 'invoiceOperationLog' );
  1323. $invoiceOperationLog = new invoiceOperationLog ();
  1324. $iidKey = $XDeode->decode ( $iidKey );
  1325. $invoiceDetail = $invoice->getInvoiceByIid ( $iidKey );
  1326. // 拷贝插入一条发票数据
  1327. $iid = $invoice->setInvoiceLoss ( $iidKey );
  1328. // 更新负票
  1329. $invoiceSerial = "#F" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  1330. $invoice = new invoice ();
  1331. $item = array (
  1332. 'iid' => $iid,
  1333. 'sid' => $this->staff [0] ['sid'],
  1334. 'userName' => $this->staff [0] ['username'],
  1335. 'cid' => $this->staff [0] ['cid'],
  1336. 'categoryName' => $this->staff [0] ['category'],
  1337. 'invoiceQuantity' => - $invoiceDetail ['invoiceQuantity'],
  1338. 'invoicePrice' => - $invoiceDetail ['invoicePrice'],
  1339. 'invoiceSerial' => $invoiceSerial,
  1340. 'invoiceNo' => '',
  1341. 'printStatus' => 0,
  1342. 'untreadStatus' => 4,
  1343. // 关联发票号
  1344. 'lossIid' => $invoiceDetail ['iid']
  1345. )
  1346. ;
  1347. $invoice->setInvoiceByCondition ( $item );
  1348. // 更新原发票
  1349. $invoice = new invoice ();
  1350. $item = array (
  1351. 'iid' => $invoiceDetail ['iid'],
  1352. 'lossIid' => $iid
  1353. )
  1354. ;
  1355. $invoice->setInvoiceByCondition ( $item );
  1356. // 操作日志
  1357. $item = array (
  1358. 'date' => date ( "Y-m-d H:i:s" ),
  1359. 'operation' => "创建负票" . $invoiceSerial,
  1360. 'status' => 12,
  1361. 'img' => $this->staff [0] ['avatar'],
  1362. 'username' => $this->staff [0] ['username'],
  1363. 'uid' => $this->staff [0] ['sid'],
  1364. 'category' => $this->staff [0] ['category'],
  1365. 'iid' => $iid
  1366. );
  1367. $invoiceOperationLog->setInvoiceOperationLog ( $item );
  1368. // print_r($invoiceDetail);
  1369. // echo $iid;die;
  1370. }
  1371. return '/invoiceUntread';
  1372. }
  1373. function invoiceReceivables() {
  1374. $invoiceTC = $this->get_args ( 'invoiceTC' ) ? $this->get_args ( 'invoiceTC' ) : '';
  1375. Doo::loadModel ( 'L_category' );
  1376. $lCategory = new L_category ();
  1377. Doo::loadModel ( 'staff' );
  1378. $staff = new staff ();
  1379. Doo::loadModel ( 'invoiceReceivables' );
  1380. $invoiceReceivables = new invoiceReceivables ();
  1381. Doo::loadModel ( 'invoice' );
  1382. $invoice = new invoice ();
  1383. Doo::loadClass ( 'XDeode' );
  1384. $XDeode = new XDeode ( 5 );
  1385. $category = $lCategory->getCategory ();
  1386. $staffList = $staff->getStaffByCid ( $this->staff [0] ['cid'] );
  1387. $sql = 'bindStatus=1 and iid!=0';
  1388. $receivablesList = $invoiceReceivables->getInvoiceReceivablesByNew ( 4, $sql );
  1389. // 获取未入账发票
  1390. $invoiceUnAccount = $invoice->getInvoiceByUnAccount ($invoiceTC);
  1391. $invoiceExistAccount = $invoice->getInvoiceByUnAccount ( '', true );
  1392. foreach ( $invoiceUnAccount as $key => $value ) {
  1393. $invoiceUnAccount [$key] ['iidKey'] = $XDeode->encode ( $value ['iid'] );
  1394. $lastApprover = json_decode ( $value ['processApprovals'], true );
  1395. if (! empty ( $lastApprover )) {
  1396. $lastApproverKey = array_keys ( $lastApprover );
  1397. $lastApprover = end ( $lastApprover );
  1398. $staffDetail = $staff->getOne ( array (
  1399. 'where' => 'sid=' . end ( $lastApproverKey ),
  1400. 'asArray' => true
  1401. ) );
  1402. $lastApprover ['username'] = $staffDetail ['username'];
  1403. }
  1404. $invoiceUnAccount [$key] ['lastApprover'] = $lastApprover;
  1405. }
  1406. foreach ( $invoiceExistAccount as $key => $value ) {
  1407. $irList = $invoiceReceivables->getInvoiceReceivablesInIridString ( $value ['irid'] );
  1408. if (empty ( $irList ))
  1409. $irList [0] ['sumPrice'] = 0;
  1410. $balance = $value ['invoicePrice'] - $irList [0] ['sumPrice'];
  1411. $invoiceExistAccount [$key] ['existAccount'] = $irList [0] ['sumPrice'];
  1412. $invoiceExistAccount [$key] ['balance'] = $balance;
  1413. }
  1414. $receivablesInput = $invoiceReceivables->getInvoiceReceivablesByInput ();
  1415. // print_r($receivablesList);
  1416. $this->data ['receivablesDate'] = date ( "Y-m-d" );
  1417. $this->data ['ieaCount'] = count ( $invoiceExistAccount );
  1418. $this->data ['invoiceExistAccount'] = $invoiceExistAccount;
  1419. $this->data ['receivablesInput'] = $receivablesInput;
  1420. $this->data ['year'] = date ( 'Y' );
  1421. $this->data ['invoiceUnAccount'] = $invoiceUnAccount;
  1422. $this->data ['receivablesList'] = $receivablesList;
  1423. $this->data ['staffList'] = $staffList;
  1424. $this->data ['category'] = $category;
  1425. $this->data ['memu'] = "invoice";
  1426. $this->data ['staff'] = $this->staff;
  1427. $this->data ['receiptMemu'] = 'invoiceReceivables';
  1428. $this->render ( "/admin/invoiceReceivables", $this->data );
  1429. }
  1430. /**
  1431. * 新添加收款直接入账发票
  1432. */
  1433. function invoiceCompareClaimPrice() {
  1434. // 收款录入
  1435. $iidKey = $this->get_args ( 'iidKey' ) ? $this->get_args ( 'iidKey' ) : "";
  1436. $receivablesPrice = $this->get_args ( 'receivablesPrice' ) ? $this->get_args ( 'receivablesPrice' ) : "";
  1437. $receivablesMessage = $this->get_args ( 'receivablesMessage' ) ? $this->get_args ( 'receivablesMessage' ) : "";
  1438. $receivablesBank = $this->get_args ( 'receivablesBank' ) ? $this->get_args ( 'receivablesBank' ) : "";
  1439. $receivablesDate = $this->get_args ( 'receivablesDate' ) ? $this->get_args ( 'receivablesDate' ) : "";
  1440. if (! empty ( $receivablesPrice ) && ! empty ( $receivablesMessage ) && ! empty ( $receivablesBank ) && ! empty ( $receivablesDate ) && ! empty ( $iidKey )) {
  1441. Doo::loadModel ( 'invoiceReceivables' );
  1442. $invoiceReceivables = new invoiceReceivables ();
  1443. Doo::loadModel ( 'invoiceROLog' );
  1444. $invoiceROLog = new invoiceROLog ();
  1445. Doo::loadModel ( 'invoiceStatistics' );
  1446. Doo::loadModel ( 'invoice' );
  1447. $invoice = new invoice ();
  1448. Doo::loadClass ( 'XDeode' );
  1449. $XDeode = new XDeode ( 5 );
  1450. Doo::loadModel ( 'invoiceOperationLog' );
  1451. $invoiceOperationLog = new invoiceOperationLog ();
  1452. $iidKey = $XDeode->decode ( $iidKey );
  1453. $invoiceDetail = $invoice->getInvoiceByIid ( $iidKey );
  1454. if (! ($invoiceDetail ['status'] == 2 && $invoiceDetail ['printStatus'] == 1 && $invoiceDetail ['untreadStatus'] == 0))
  1455. die ( 'illegal request' );
  1456. $receivablesSerial = "#SK" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  1457. // 收款录入 并绑定发票
  1458. Doo::db ()->beginTransaction ();
  1459. $item = array (
  1460. 'bindStatus' => 1,
  1461. 'iid' => $invoiceDetail ['iid'],
  1462. 'bindDate' => date ( "Y-m-d H:i:s" ),
  1463. 'receivablesPrice' => $receivablesPrice,
  1464. 'receivablesMessage' => $receivablesMessage,
  1465. 'receivablesSerial' => $receivablesSerial,
  1466. 'receivablesBank' => $receivablesBank,
  1467. 'receivablesDate' => $receivablesDate,
  1468. 'inputStaff' => $this->staff [0] ['username'],
  1469. 'accountClerk' => $this->staff [0] ['username'],
  1470. 'date' => date ( "Y-m-d" ),
  1471. 'receivablesCategory' => $invoiceDetail ['cid'] . ':' . $invoiceDetail ['categoryName'],
  1472. 'receivablesStaff' => $invoiceDetail ['sid'] . '-' . $invoiceDetail ['userName'],
  1473. 'confirmTime' => date ( "Y-m-d H:i:s" )
  1474. );
  1475. $irid = $invoiceReceivables->addInvoiceReceivables ( $item );
  1476. $item = array ();
  1477. // 收款操作日志
  1478. $item = array (
  1479. 'operation' => $this->staff [0] ['username'] . " 转入 " . $invoiceDetail ['userName']
  1480. );
  1481. $item += array (
  1482. 'date' => date ( "Y-m-d" ),
  1483. 'status' => 1,
  1484. 'img' => $this->staff [0] ['avatar'],
  1485. 'username' => $this->staff [0] ['username'],
  1486. 'uid' => $this->staff [0] ['sid'],
  1487. 'category' => $this->staff [0] ['category'],
  1488. 'irid' => $irid
  1489. );
  1490. $invoiceROLog->setInvoiceROLog ( $item );
  1491. // 收款统计
  1492. $invoiceStatistics = new invoiceStatistics ();
  1493. $item = array (
  1494. 'date' => $receivablesDate,
  1495. 'priceClass' => 2,
  1496. 'irid' => $irid,
  1497. 'cid' => $invoiceDetail ['cid'],
  1498. 'staff' => $invoiceDetail ['sid'],
  1499. 'receivablesPrice' => $receivablesPrice
  1500. );
  1501. $invoiceStatistics->setInvoiceStatisticsByCondition ( $item );
  1502. // 收款 入 发票
  1503. $detail = $invoiceDetail;
  1504. $iridString = "";
  1505. if (empty ( $detail ['irid'] ))
  1506. $iridString = $irid;
  1507. else
  1508. $iridString = $detail ['irid'] . ',' . $irid;
  1509. $item = array (
  1510. 'irid' => $iridString,
  1511. 'bindTime' => date ( "Y-m-d H:i:s" ),
  1512. 'updateTime' => date ( "Y-m-d H:i:s" ),
  1513. 'iid' => $detail ['iid']
  1514. );
  1515. $invoiceReceivables = new invoiceReceivables ();
  1516. $sum = $invoiceReceivables->getSumOfReceivablesPrice ( $iridString );
  1517. if ($detail ['invoicePrice'] <= $sum)
  1518. $item += array (
  1519. 'untreadStatus' => 3
  1520. );
  1521. $invoice->setInvoiceByCondition ( $item );
  1522. // 操作日志
  1523. $item = array (
  1524. 'date' => date ( "Y-m-d H:i:s" ),
  1525. 'operation' => "收款入账" . $receivablesSerial . "到发票" . $detail ['invoiceSerial'],
  1526. 'status' => 8,
  1527. 'img' => $this->staff [0] ['avatar'],
  1528. 'username' => $this->staff [0] ['username'],
  1529. 'uid' => $this->staff [0] ['sid'],
  1530. 'category' => $this->staff [0] ['category'],
  1531. 'iid' => $detail ['iid']
  1532. );
  1533. $invoiceOperationLog->setInvoiceOperationLog ( $item );
  1534. //入账汇总
  1535. $invoiceStatistics = new invoiceStatistics ();
  1536. // $list = $invoiceReceivables->getInvoiceReceivablesInIridString ( $iridString );
  1537. // $accountPrice = 0;
  1538. // foreach ( $list as $key => $value ) {
  1539. // $accountPrice += $value ['receivablesPrice'];
  1540. // }
  1541. $item = array (
  1542. 'date' => $receivablesDate,
  1543. 'priceClass' => 3,
  1544. 'cid' => $invoiceDetail ['cid'],
  1545. 'staff' => $invoiceDetail ['sid'],
  1546. 'accountPrice' => $receivablesPrice
  1547. );
  1548. $invoiceStatistics->setInvoiceStatisticsByCondition ( $item );
  1549. Doo::db ()->commit ();
  1550. }
  1551. return '/invoiceReceivables';
  1552. }
  1553. /**
  1554. * 检索未入账发票数据 function sir() { }
  1555. */
  1556. /**
  1557. * 录入收款数据
  1558. * @return string
  1559. */
  1560. function invoiceReceivablesDo() {
  1561. $receivablesPrice = $this->get_args ( 'receivablesPrice' ) ? $this->get_args ( 'receivablesPrice' ) : "";
  1562. $receivablesMessage = $this->get_args ( 'receivablesMessage' ) ? $this->get_args ( 'receivablesMessage' ) : "";
  1563. $receivablesBank = $this->get_args ( 'receivablesBank' ) ? $this->get_args ( 'receivablesBank' ) : "";
  1564. $receivablesDate = $this->get_args ( 'receivablesDate' ) ? $this->get_args ( 'receivablesDate' ) : "";
  1565. $receivablesCategory = $this->get_args ( 'receivablesCategory' ) ? $this->get_args ( 'receivablesCategory' ) : "";
  1566. $receivablesStaff = $receivablesStaff2 = $this->get_args ( 'receivablesStaff' ) ? $this->get_args ( 'receivablesStaff' ) : "";
  1567. Doo::loadModel ( 'invoiceReceivables' );
  1568. $invoiceReceivables = new invoiceReceivables ();
  1569. Doo::loadModel ( 'invoiceROLog' );
  1570. $invoiceROLog = new invoiceROLog ();
  1571. Doo::loadModel ( 'invoiceStatistics' );
  1572. $invoiceStatistics = new invoiceStatistics ();
  1573. if (! empty ( $receivablesPrice ) && ! empty ( $receivablesMessage ) && ! empty ( $receivablesBank ) && ! empty ( $receivablesDate ) && ! empty ( $receivablesCategory ) && ! empty ( $receivablesStaff )) {
  1574. $item = array (
  1575. 'receivablesPrice' => $receivablesPrice,
  1576. 'receivablesMessage' => $receivablesMessage,
  1577. 'receivablesSerial' => "#SK" . date ( "Ymd" ) . mt_rand ( 1000, 9999 ),
  1578. 'receivablesBank' => $receivablesBank,
  1579. 'receivablesDate' => $receivablesDate,
  1580. 'inputStaff' => $this->staff [0] ['username'],
  1581. 'date' => date ( "Y-m-d" ),
  1582. 'receivablesCategory' => $receivablesCategory,
  1583. 'receivablesStaff' => $receivablesStaff
  1584. );
  1585. if ($receivablesCategory != 'PUBLIC') {
  1586. $item += array (
  1587. 'confirmTime' => date ( "Y-m-d H:i:s" ),
  1588. 'inputType' => 1
  1589. );
  1590. }
  1591. $irid = $invoiceReceivables->addInvoiceReceivables ( $item );
  1592. $item = array ();
  1593. // 收款操作日志
  1594. if ($receivablesCategory == 'PUBLIC' && $receivablesStaff == 'PUBLIC')
  1595. $item = array (
  1596. 'operation' => $this->staff [0] ['username'] . " 转入 公共待认领款项 "
  1597. );
  1598. elseif ($receivablesCategory != 'PUBLIC' && $receivablesStaff == 'PUBLIC')
  1599. $item = array (
  1600. 'operation' => $this->staff [0] ['username'] . "转入 办事处待认领款项"
  1601. );
  1602. elseif ($receivablesCategory != 'PUBLIC' && $receivablesStaff != 'PUBLIC') {
  1603. $receivablesStaff = explode ( '-', $receivablesStaff );
  1604. $item = array (
  1605. 'operation' => $this->staff [0] ['username'] . " 转入 " . $receivablesStaff [1]
  1606. );
  1607. }
  1608. $item += array (
  1609. 'date' => date ( "Y-m-d" ),
  1610. 'status' => 1,
  1611. 'img' => $this->staff [0] ['avatar'],
  1612. 'username' => $this->staff [0] ['username'],
  1613. 'uid' => $this->staff [0] ['sid'],
  1614. 'category' => $this->staff [0] ['category'],
  1615. 'irid' => $irid
  1616. );
  1617. $invoiceROLog->setInvoiceROLog ( $item );
  1618. $item = array (
  1619. 'date' => $receivablesDate,
  1620. 'priceClass' => 2,
  1621. 'irid' => $irid,
  1622. 'receivablesPrice' => $receivablesPrice
  1623. );
  1624. if ($receivablesCategory != 'PUBLIC') {
  1625. $receivablesCategory = explode ( ":", $receivablesCategory );
  1626. $item += array (
  1627. 'cid' => $receivablesCategory [0]
  1628. );
  1629. }
  1630. if ($receivablesStaff2 != 'PUBLIC') {
  1631. $receivablesStaff = explode ( "-", $receivablesStaff2 );
  1632. $item += array (
  1633. 'staff' => $receivablesStaff [0]
  1634. );
  1635. }
  1636. $invoiceStatistics->setInvoiceStatisticsByCondition ( $item );
  1637. $toparty = $this->getToparty ( $receivablesCategory [1] );
  1638. $msg = '[通知]财务录入了一笔待认领款项,快到“我的收款”中查看,确认是否是您的客户给您打款了。';
  1639. if ($toparty != 0)
  1640. $this->msgSendToparty ( $msg, '', '', $toparty, 'text' );
  1641. }
  1642. return "/invoiceReceivables";
  1643. }
  1644. /**
  1645. * 收款认领页面-包括公共认领 办事处认领 最近已认领数据
  1646. */
  1647. function invoiceReceivablesClaim() {
  1648. Doo::loadModel ( 'invoiceReceivables' );
  1649. $invoiceReceivables = new invoiceReceivables ();
  1650. $receivablesList = $invoiceReceivables->getInvoiceReceivablesByClaim ( $this->staff [0] ['cid'], $this->staff [0] ['sid'] );
  1651. $this->data ['receivablesList'] = $receivablesList;
  1652. $this->data ['memu'] = "invoice";
  1653. $this->data ['staff'] = $this->staff;
  1654. $this->data ['receiptMemu'] = 'invoiceReceivablesClaim';
  1655. $this->render ( "/admin/invoiceReceivablesClaim", $this->data );
  1656. }
  1657. /**
  1658. * 更新收款相关数据
  1659. */
  1660. function invoiceReceivablesUpdateClaim() {
  1661. $receivablesPrice = $this->get_args ( 'receivablesPrice' ) ? $this->get_args ( 'receivablesPrice' ) : "";
  1662. $receivablesMessage = $this->get_args ( 'receivablesMessage' ) ? $this->get_args ( 'receivablesMessage' ) : "";
  1663. $receivablesBank = $this->get_args ( 'receivablesBank' ) ? $this->get_args ( 'receivablesBank' ) : "";
  1664. $receivablesDate = $this->get_args ( 'receivablesDate' ) ? $this->get_args ( 'receivablesDate' ) : "";
  1665. $receivablesCategory = $this->get_args ( 'receivablesCategory' ) ? $this->get_args ( 'receivablesCategory' ) : "";
  1666. $receivablesStaff = $receivablesStaff2 = $this->get_args ( 'receivablesStaff' ) ? $this->get_args ( 'receivablesStaff' ) : "";
  1667. $claimKey = $this->get_args ( 'claimKey' ) ? $this->get_args ( 'claimKey' ) : "";
  1668. if (empty ( $claimKey ))
  1669. die ( 'illegal request' );
  1670. Doo::loadModel ( 'invoiceReceivables' );
  1671. $invoiceReceivables = new invoiceReceivables ();
  1672. Doo::loadModel ( 'invoiceROLog' );
  1673. $invoiceROLog = new invoiceROLog ();
  1674. $con = ' and iid=0 and bindStatus=0'; // and receivablesCategory!="PUBLIC" and receivablesStaff!="PUBLIC"
  1675. $detail = $invoiceReceivables->getInvoiceReceivablesByIrid ( $claimKey, $con );
  1676. if (empty ( $detail ))
  1677. die ( 'illegal request' );
  1678. $invoiceReceivables = new invoiceReceivables ();
  1679. $item = array (
  1680. 'irid' => $detail ['irid']
  1681. );
  1682. if ($receivablesCategory != 'PUBLIC' && $receivablesStaff != 'PUBLIC') {
  1683. $item += array (
  1684. 'confirmTime' => date ( "Y-m-d H:i:s" )
  1685. );
  1686. }
  1687. if (! empty ( $receivablesCategory ))
  1688. $item += array (
  1689. 'receivablesCategory' => $receivablesCategory
  1690. );
  1691. if (! empty ( $receivablesStaff ))
  1692. $item += array (
  1693. 'receivablesStaff' => $receivablesStaff
  1694. );
  1695. if (! empty ( $receivablesPrice ))
  1696. $item += array (
  1697. 'receivablesPrice' => $receivablesPrice
  1698. );
  1699. if (! empty ( $receivablesMessage ))
  1700. $item += array (
  1701. 'receivablesMessage' => $receivablesMessage
  1702. );
  1703. if (! empty ( $receivablesBank ))
  1704. $item += array (
  1705. 'receivablesBank' => $receivablesBank
  1706. );
  1707. if (! empty ( $receivablesDate ))
  1708. $item += array (
  1709. 'receivablesDate' => $receivablesDate
  1710. );
  1711. $invoiceReceivables->setInvoiceReceivablesByCondition ( $item );
  1712. // 收款操作日志
  1713. $item = array ();
  1714. if ($receivablesCategory == 'PUBLIC' && $receivablesStaff == 'PUBLIC')
  1715. $item = array (
  1716. 'operation' => $this->staff [0] ['username'] . " 转入 公共待认领款项 "
  1717. );
  1718. elseif ($receivablesCategory != 'PUBLIC' && $receivablesStaff == 'PUBLIC')
  1719. $item = array (
  1720. 'operation' => $this->staff [0] ['username'] . "转入 办事处待认领款项"
  1721. );
  1722. elseif ($receivablesCategory != 'PUBLIC' && $receivablesStaff != 'PUBLIC') {
  1723. $receivablesStaff = explode ( '-', $receivablesStaff );
  1724. $item = array (
  1725. 'operation' => $this->staff [0] ['username'] . " 转入 " . $receivablesStaff [1]
  1726. );
  1727. }
  1728. $item += array (
  1729. 'date' => date ( "Y-m-d" ),
  1730. 'status' => 1,
  1731. 'img' => $this->staff [0] ['avatar'],
  1732. 'username' => $this->staff [0] ['username'],
  1733. 'uid' => $this->staff [0] ['sid'],
  1734. 'category' => $this->staff [0] ['category'],
  1735. 'irid' => $detail ['irid']
  1736. );
  1737. $invoiceROLog->setInvoiceROLog ( $item );
  1738. return '/invoiceReceivablesAS';
  1739. }
  1740. function invoiceReceivablesDelete() {
  1741. $claimKey = $this->get_args ( 'claimKey' ) ? $this->get_args ( 'claimKey' ) : "";
  1742. if (empty ( $claimKey ))
  1743. die ( 'illegal request' );
  1744. Doo::loadModel ( 'invoiceReceivables' );
  1745. $invoiceReceivables = new invoiceReceivables ();
  1746. $con = ' and iid=0 and bindStatus=0 and receivablesStaff="PUBLIC"';
  1747. $detail = $invoiceReceivables->getInvoiceReceivablesByIrid ( $claimKey, $con );
  1748. if (empty ( $detail ))
  1749. die ( 'illegal request' );
  1750. $invoiceReceivables->delInvoiceReceivablesByIrid ( $detail ['irid'] );
  1751. return '/invoiceReceivablesAS';
  1752. }
  1753. /**
  1754. * 管理员录入的收款 ,确认认领到谁的名下.统计收款金额
  1755. */
  1756. function invoiceReceivablesAscription() {
  1757. $irid = $this->get_args ( 'key' ) ? $this->get_args ( 'key' ) : "";
  1758. $recepitTitleMark = $this->get_args ( 'recepitTitleMark' ) ? $this->get_args ( 'recepitTitleMark' ) : "";
  1759. Doo::loadModel ( 'invoiceReceivables' );
  1760. $invoiceReceivables = new invoiceReceivables ();
  1761. Doo::loadModel ( 'invoiceROLog' );
  1762. $invoiceROLog = new invoiceROLog ();
  1763. Doo::loadModel ( 'invoiceStatistics' );
  1764. $invoiceStatistics = new invoiceStatistics ();
  1765. $detail = $invoiceReceivables->getInvoiceReceivablesByIrid ( $irid );
  1766. if (! empty ( $detail ) && $detail ['receivablesStaff'] == 'PUBLIC' && ! empty ( $recepitTitleMark )) {
  1767. $item = array (
  1768. 'irid' => $detail ['irid'],
  1769. 'receivablesCategory' => $this->staff [0] ['cid'] . ":" . $this->staff [0] ['category'],
  1770. 'receivablesStaff' => $this->staff [0] ['sid'] . "-" . $this->staff [0] ['username'],
  1771. 'confirmTime' => date ( "Y-m-d H:i:s" ),
  1772. 'recepitTitleMark' => $recepitTitleMark,
  1773. 'source' => 1
  1774. );
  1775. $invoiceReceivables->setInvoiceReceivablesByCondition ( $item );
  1776. $item = array (
  1777. 'date' => date ( "Y-m-d" ),
  1778. 'operation' => $this->staff [0] ['username'] . " 认领 ",
  1779. 'status' => 2,
  1780. 'img' => $this->staff [0] ['avatar'],
  1781. 'username' => $this->staff [0] ['username'],
  1782. 'uid' => $this->staff [0] ['sid'],
  1783. 'category' => $this->staff [0] ['category'],
  1784. 'irid' => $irid
  1785. );
  1786. $invoiceROLog->setInvoiceROLog ( $item );
  1787. $item = array (
  1788. 'cid' => $this->staff [0] ['cid'],
  1789. 'staff' => $this->staff [0] ['sid']
  1790. );
  1791. $invoiceStatistics->updateInvoiceStatisticsByIrid ( $item, $detail ['irid'],2 );
  1792. }
  1793. return "/invoiceReceivablesClaim";
  1794. }
  1795. /**
  1796. */
  1797. function invoiceMyReceivables() {
  1798. Doo::loadModel ( 'invoiceReceivables' );
  1799. $invoiceReceivables = new invoiceReceivables ();
  1800. Doo::loadModel ( 'invoiceStatistics' );
  1801. $invoiceStatistics = new invoiceStatistics ();
  1802. $isMonth = $invoiceStatistics->getStatisticsByMonth ();
  1803. $year = date ( "Y" );
  1804. $tmp_date = date ( "Ym" );
  1805. $tmp_year = substr ( $tmp_date, 0, 4 );
  1806. $tmp_mon = substr ( $tmp_date, 4, 2 );
  1807. $tmp_forwardmonth = mktime ( 0, 0, 0, $tmp_mon - 1, 1, $tmp_year );
  1808. $fm_forward_month = date ( "m", $tmp_forwardmonth );
  1809. $path = SITE_PATH . $this->INVOICECOLLECTPATH . "invoiceCollect_" . $year . "_" . $fm_forward_month . ".htm";
  1810. $htm = $this->showCache ( $path );
  1811. $list = $invoiceReceivables->getInvoiceReceivablesByClaim ( $this->staff [0] ['cid'], $this->staff [0] ['sid'] );
  1812. $this->data ['isMonth'] = $isMonth;
  1813. $this->data ['htm'] = $htm;
  1814. $this->data ['list'] = $list;
  1815. $this->data ['memu'] = "invoice";
  1816. $this->data ['staff'] = $this->staff;
  1817. $this->data ['receiptMemu'] = 'invoiceMyReceivables';
  1818. $this->render ( "/admin/invoiceMyReceivables", $this->data );
  1819. }
  1820. /**
  1821. * 收款绑定发票 ,一个收款只能绑定一个发票
  1822. */
  1823. function invoiceBindReceivables() {
  1824. $claimKey = $this->get_args ( 'key' ) ? $this->get_args ( 'key' ) : "";
  1825. $invoiceKey = $this->get_args ( 'invoiceKey' ) ? $this->get_args ( 'invoiceKey' ) : "";
  1826. Doo::loadModel ( 'invoice' );
  1827. $invoice = new invoice ();
  1828. Doo::loadModel ( 'invoiceReceivables' );
  1829. $invoiceReceivables = new invoiceReceivables ();
  1830. Doo::loadModel ( 'invoiceOperationLog' );
  1831. $invoiceOperationLog = new invoiceOperationLog ();
  1832. if (empty ( $invoiceKey ) || empty ( $claimKey ))
  1833. die ( 'illegal request' );
  1834. $detail = $invoice->getInvoiceByIid ( $invoiceKey );
  1835. $detailM = $invoiceReceivables->getInvoiceReceivablesByIrid ( $claimKey );
  1836. if (empty ( $detail ) && empty ( $detailM ))
  1837. die ( 'illegal request' );
  1838. if ($detail ['untreadStatus'] == 3)
  1839. die ( 'illegal request' );
  1840. // if ($detailM ['receivablesPrice'] >= $detail ['invoicePrice']) {
  1841. // $price = $detailM ['receivablesPrice'] - $detail ['invoicePrice'];
  1842. // die ( '<p>收款金额超出开票金额 ¥' . $price . '元,请谨慎操作</p><a href="/invoiceMyReceivables">返回</a>' );
  1843. // }
  1844. $item = array (
  1845. 'irid' => $detailM ['irid'],
  1846. 'bindStatus' => 1,
  1847. 'iid' => $detail ['iid'],
  1848. 'accountClerk' => $this->staff [0] ['username'],
  1849. 'bindDate' => date ( "Y-m-d H:i:s" )
  1850. );
  1851. $invoiceReceivables->setInvoiceReceivablesByCondition ( $item );
  1852. $iridString = "";
  1853. if (empty ( $detail ['irid'] ))
  1854. $iridString = $detailM ['irid'];
  1855. else
  1856. $iridString = $detail ['irid'] . ',' . $detailM ['irid'];
  1857. $item = array (
  1858. 'iid' => $detail ['iid'],
  1859. 'irid' => $iridString
  1860. );
  1861. $sum = $invoiceReceivables->getSumOfReceivablesPrice ( $iridString );
  1862. if ($detail ['invoicePrice'] <= $sum)
  1863. $item += array (
  1864. 'untreadStatus' => 3
  1865. );
  1866. $invoice->setInvoiceByCondition ( $item );
  1867. // 操作日志
  1868. $item = array (
  1869. 'date' => date ( "Y-m-d H:i:s" ),
  1870. 'operation' => "收款" . $detailM ['receivablesSerial'] . "入账到发票" . $detail ['invoiceSerial'],
  1871. 'status' => 8,
  1872. 'img' => $this->staff [0] ['avatar'],
  1873. 'username' => $this->staff [0] ['username'],
  1874. 'uid' => $this->staff [0] ['sid'],
  1875. 'category' => $this->staff [0] ['category'],
  1876. 'iid' => $detail ['iid']
  1877. );
  1878. $invoiceOperationLog->setInvoiceOperationLog ( $item );
  1879. Doo::loadModel ( 'invoiceStatistics' );
  1880. $invoiceStatistics = new invoiceStatistics ();
  1881. // $list = $invoiceReceivables->getInvoiceReceivablesInIridString ( $iridString );
  1882. // $accountPrice = 0;
  1883. // foreach ( $list as $key => $value ) {
  1884. // $accountPrice += $value ['receivablesPrice'];
  1885. // }
  1886. $item = array (
  1887. 'date' => $detailM['receivablesDate'],
  1888. 'priceClass' => 3,
  1889. 'cid' => $detail ['cid'],
  1890. 'staff' => $detail ['sid'],
  1891. 'accountPrice' => $detailM['receivablesPrice']
  1892. );
  1893. $invoiceStatistics->setInvoiceStatisticsByCondition ( $item );
  1894. return "/invoiceReceivables";
  1895. }
  1896. /**
  1897. * 核销 动作,确认入账统计 发票收款完成--需求更变 废弃 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"; }
  1898. */
  1899. function invoiceAggregate() {
  1900. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  1901. Doo::loadModel ( 'invoiceStatistics' );
  1902. $invoiceStatistics = new invoiceStatistics ();
  1903. Doo::loadModel ( 'L_category' );
  1904. $Lcategory = new L_category ();
  1905. $isList = $invoiceStatistics->getInvoiceStatisticsByYear ( $year );
  1906. $LcategoryList = $Lcategory->getCategory ();
  1907. // print_r($isList);
  1908. $html = ""; // $invoicePriceCategory=0;$receivablesPriceCategory=0;$accountPriceCategory=0;
  1909. foreach ( $LcategoryList as $key => $value ) {
  1910. $html .= '<tr><th><a href="/invoiceAggregateCategory/' . $value ['cidKey'] . '">' . $value ['title'] . '</a></th>';
  1911. $month = 1;
  1912. $invoicePriceYear = 0;
  1913. $receivablesPriceYear = 0;
  1914. $accountPriceYear = 0;
  1915. for(; $month <= 12; $month ++) {
  1916. $flag = true;
  1917. foreach ( $isList ['statisticsMonthCid'] as $k => $v ) {
  1918. if ($value ['cid'] == $v ['cid'] && $month == $v ['month']) {
  1919. $html .= '<td class="taR">¥' . $v ['invoicePrice'] . '</td>
  1920. <td class="taR">¥' . $v ['receivablesPrice'] . '</td>
  1921. <td class="taR"><b>¥' . $v ['accountPrice'] . '</b></td>
  1922. ';
  1923. $invoicePriceYear += $v ['invoicePrice'];
  1924. $receivablesPriceYear += $v ['receivablesPrice'];
  1925. $accountPriceYear += $v ['accountPrice'];
  1926. $flag = false;
  1927. break;
  1928. }
  1929. }
  1930. if ($flag)
  1931. $html .= '<td class="taR"></td>
  1932. <td class="taR"></td>
  1933. <td class="taR"><b></b></td>
  1934. ';
  1935. }
  1936. $html .= '<td class="taR colRed">' . $invoicePriceYear . '</td>
  1937. <td class="taR colOrange">' . $receivablesPriceYear . '</td>
  1938. <td class="taR colGreen"><b>' . $accountPriceYear . '</b></td>
  1939. ';
  1940. $html .= '</tr>';
  1941. }
  1942. $html .= '<tr><th><b class="colGreen">月合计</b></th>';
  1943. $invoicePriceYear = 0;
  1944. $receivablesPriceYear = 0;
  1945. $accountPriceYear = 0;
  1946. for($month = 1; $month <= 12; $month ++) {
  1947. $flag = true;
  1948. foreach ( $isList ['statisticsMonth'] as $k => $v ) {
  1949. if ($month == $v ['month']) {
  1950. $html .= '<td class="taR">¥' . $v ['invoicePrice'] . '</td>
  1951. <td class="taR">¥' . $v ['receivablesPrice'] . '</td>
  1952. <td class="taR"><b>¥' . $v ['accountPrice'] . '</b></td>
  1953. ';
  1954. $invoicePriceYear += $v ['invoicePrice'];
  1955. $receivablesPriceYear += $v ['receivablesPrice'];
  1956. $accountPriceYear += $v ['accountPrice'];
  1957. $flag = false;
  1958. break;
  1959. }
  1960. }
  1961. if ($flag) {
  1962. $html .= '<td class="taR"></td>
  1963. <td class="taR"></td>
  1964. <td class="taR"><b></b></td>
  1965. ';
  1966. }
  1967. }
  1968. $html .= '<td class="taR colRed">' . $invoicePriceYear . '</td>
  1969. <td class="taR colOrange">' . $receivablesPriceYear . '</td>
  1970. <td class="taR colGreen"><b>' . $accountPriceYear . '</b></td>
  1971. ';
  1972. $html .= '</tr>';
  1973. // print_r($isList);
  1974. $this->data ['html'] = $html;
  1975. $this->data ['LcategoryList'] = $LcategoryList;
  1976. $this->data ['isList'] = $isList;
  1977. $this->data ['year'] = $year;
  1978. $this->data ['memu'] = "invoice";
  1979. $this->data ['staff'] = $this->staff;
  1980. $this->data ['receiptMemu'] = 'invoiceAggregate';
  1981. $this->render ( "/admin/invoiceAggregate", $this->data );
  1982. }
  1983. function invoiceAggregateStaff() {
  1984. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  1985. Doo::loadModel ( 'invoiceStatistics' );
  1986. $invoiceStatistics = new invoiceStatistics ();
  1987. Doo::loadModel ( 'L_category' );
  1988. $Lcategory = new L_category ();
  1989. $toteList = $invoiceStatistics->getInvoiceStatisticsByTote ( $year );
  1990. $staffList = $invoiceStatistics->getInvoiceStatisticsByStaff ( $year );
  1991. $cStaff = $Lcategory->getCategoryStaff ();
  1992. $html = '';
  1993. foreach ( $cStaff as $key => $value ) {
  1994. $categoryFir = true;
  1995. foreach ( $value ['staff'] as $k => $v ) {
  1996. if ($categoryFir) {
  1997. $width = count ( $value ['staff'] ) + 1;
  1998. $html .= '<tr><th rowspan="' . $width . '">' . $value ['title'] . ' </th>';
  1999. $categoryFir = false;
  2000. } else
  2001. $html .= '<tr>';
  2002. $html .= '<th>' . $v ['username'] . '</th>';
  2003. $invoicePriceStaffYear = 0;
  2004. $receivablesPriceStaffYear = 0;
  2005. $accountPriceStaffYear = 0;
  2006. for($month = 1; $month <= 12; $month ++) {
  2007. $flag = true;
  2008. foreach ( $staffList ['statisticsMonthStaff'] as $sl => $slv ) {
  2009. if ($v ['sid'] == $slv ['staff'] && $month == $slv ['month']) {
  2010. $html .= '<td class="taR">¥' . $slv ['invoicePrice'] . '</td>
  2011. <td class="taR">¥' . $slv ['receivablesPrice'] . '</td>
  2012. <td class="taR"><b>¥' . $slv ['accountPrice'] . '</b></td>
  2013. ';
  2014. $invoicePriceStaffYear += $slv ['invoicePrice'];
  2015. $receivablesPriceStaffYear += $slv ['receivablesPrice'];
  2016. $accountPriceStaffYear += $slv ['accountPrice'];
  2017. $flag = false;
  2018. break;
  2019. }
  2020. }
  2021. if ($flag)
  2022. $html .= '<td class="taR"></td>
  2023. <td class="taR"></td>
  2024. <td class="taR"><b></b></td>
  2025. ';
  2026. }
  2027. $html .= '<td class="taR colRed">' . $invoicePriceStaffYear . '</td>
  2028. <td class="taR colOrange">' . $receivablesPriceStaffYear . '</td>
  2029. <td class="taR colGreen"><b>' . $accountPriceStaffYear . '</b></td>
  2030. ';
  2031. }
  2032. $html .= '</tr>';
  2033. // 小计
  2034. if (! empty ( $value ['staff'] )) {
  2035. $html .= '<tr><th class="taR">小计</th>';
  2036. $invoicePriceStaffYear = 0;
  2037. $receivablesPriceStaffYear = 0;
  2038. $accountPriceStaffYear = 0;
  2039. for($month = 1; $month <= 12; $month ++) {
  2040. $flag = true;
  2041. foreach ( $staffList ['statisticsMonthCid'] as $smc => $smcv ) {
  2042. if ($value ['cid'] == $smcv ['cid'] && $month == $slv ['month']) {
  2043. $html .= '<td class="taR">¥' . $smcv ['invoicePrice'] . '</td>
  2044. <td class="taR">¥' . $smcv ['receivablesPrice'] . '</td>
  2045. <td class="taR"><b>¥' . $smcv ['accountPrice'] . '</b></td>
  2046. ';
  2047. $invoicePriceStaffYear += $slv ['invoicePrice'];
  2048. $receivablesPriceStaffYear += $slv ['receivablesPrice'];
  2049. $accountPriceStaffYear += $slv ['accountPrice'];
  2050. $flag = false;
  2051. break;
  2052. }
  2053. }
  2054. if ($flag)
  2055. $html .= '<td class="taR"></td>
  2056. <td class="taR"></td>
  2057. <td class="taR"><b></b></td>
  2058. ';
  2059. }
  2060. $html .= '<td class="taR colRed">' . $invoicePriceStaffYear . '</td>
  2061. <td class="taR colOrange">' . $receivablesPriceStaffYear . '</td>
  2062. <td class="taR colGreen"><b>' . $accountPriceStaffYear . '</b></td>
  2063. ';
  2064. $html .= '</tr>';
  2065. }
  2066. }
  2067. $html .= '<tr class="warning"><th colspan="2"><b class="colGreen" >月合计</b></th>';
  2068. $invoicePriceYear = 0;
  2069. $receivablesPriceYear = 0;
  2070. $accountPriceYear = 0;
  2071. for($month = 1; $month <= 12; $month ++) {
  2072. $flag = true;
  2073. foreach ( $staffList ['statisticsMonth'] as $k => $v ) {
  2074. if ($month == $v ['month']) {
  2075. $html .= '<td class="taR colRed">¥' . $v ['invoicePrice'] . '</td>
  2076. <td class="taR colOrange">¥' . $v ['receivablesPrice'] . '</td>
  2077. <td class="taR colGreen"><b>¥' . $v ['accountPrice'] . '</b></td>
  2078. ';
  2079. $invoicePriceYear += $v ['invoicePrice'];
  2080. $receivablesPriceYear += $v ['receivablesPrice'];
  2081. $accountPriceYear += $v ['accountPrice'];
  2082. $flag = false;
  2083. break;
  2084. }
  2085. }
  2086. if ($flag)
  2087. $html .= '<td class="taR"></td>
  2088. <td class="taR"></td>
  2089. <td class="taR"><b></b></td>
  2090. ';
  2091. }
  2092. $html .= '<td class="taR colRed">' . $invoicePriceYear . '</td>
  2093. <td class="taR colOrange">' . $receivablesPriceYear . '</td>
  2094. <td class="taR colGreen"><b>' . $accountPriceYear . '</b></td>
  2095. ';
  2096. $html .= '</tr>';
  2097. $this->data ['html'] = $html;
  2098. $this->data ['isList'] = $toteList;
  2099. $this->data ['year'] = $year;
  2100. $this->data ['memu'] = "invoice";
  2101. $this->data ['staff'] = $this->staff;
  2102. $this->data ['receiptMemu'] = 'invoiceAggregate';
  2103. $this->render ( "/admin/invoiceAggregateStaff", $this->data );
  2104. }
  2105. function invoiceAggregateCategory() {
  2106. Doo::loadClass ( 'XDeode' );
  2107. $XDeode = new XDeode ( 5 );
  2108. $cid = $cidKey = isset ( $this->params ['cid'] ) ? $this->params ['cid'] : "";
  2109. $cid = $XDeode->decode ( $cid );
  2110. if (! is_numeric ( $cid ))
  2111. die ( 'illegal request' );
  2112. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  2113. Doo::loadModel ( 'invoiceStatistics' );
  2114. $invoiceStatistics = new invoiceStatistics ();
  2115. Doo::loadModel ( 'staff' );
  2116. $staff = new staff ();
  2117. $list = $staff->getStaffByCid ( $cid );
  2118. $isCategory = $invoiceStatistics->getInvoiceStatisticsByStaff ( $year, $cid );
  2119. $toteList = $invoiceStatistics->getInvoiceStatisticsByTote ( $year, $cid );
  2120. if (empty ( $list ))
  2121. die ( '该办事处没有成员' );
  2122. $htmlA = $htmlB = $htmlC = $html = '';
  2123. foreach ( $list as $key => $value ) {
  2124. $htmlA = '<tr><th rowspan="3">' . $value ['username'] . '</th><th class="taC">开票</th>';
  2125. $htmlB = '<tr><th class="taC">收款</th>';
  2126. $htmlC = '<tr><th class="taC">入账</th>';
  2127. $invoicePriceStaffYear = 0;
  2128. $receivablesPriceStaffYear = 0;
  2129. $accountPriceStaffYear = 0;
  2130. for($month = 1; $month <= 12; $month ++) {
  2131. $flag = true;
  2132. foreach ( $isCategory ['statisticsMonthStaff'] as $k => $v ) {
  2133. if ($value ['sid'] == $v ['staff'] && $month == $v ['month']) {
  2134. $htmlA .= '<td class="taR">¥' . $v ['invoicePrice'] . '</td>';
  2135. $htmlB .= '<td class="taR">¥' . $v ['receivablesPrice'] . '</td>';
  2136. $htmlC .= '<td class="taR"><b>¥' . $v ['accountPrice'] . '</b></td>';
  2137. $invoicePriceStaffYear += $v ['invoicePrice'];
  2138. $receivablesPriceStaffYear += $v ['receivablesPrice'];
  2139. $accountPriceStaffYear += $v ['accountPrice'];
  2140. $flag = false;
  2141. break;
  2142. }
  2143. }
  2144. if ($flag) {
  2145. $htmlA .= '<td class="taR">-</td>';
  2146. $htmlB .= '<td class="taR">-</td>';
  2147. $htmlC .= '<td class="taR"><b>-</b></td>';
  2148. }
  2149. }
  2150. $htmlA .= '<td class="taR colRed">' . $invoicePriceStaffYear . '</td>';
  2151. $htmlB .= '<td class="taR colOrange">' . $receivablesPriceStaffYear . '</td>';
  2152. $htmlC .= '<td class="taR colGreen"><b>' . $accountPriceStaffYear . '</b></td>';
  2153. $htmlA .= '</tr>';
  2154. $htmlB .= '</tr>';
  2155. $htmlC .= '</tr>';
  2156. $html .= $htmlA . $htmlB . $htmlC;
  2157. }
  2158. $htmlA = $htmlB = $htmlC = "";
  2159. $htmlA = '<tr><th rowspan="3">月合计</th><th class="taC">开票</th>';
  2160. $htmlB = '<tr><th class="taC">收款</th>';
  2161. $htmlC = '<tr><th class="taC">入账</th>';
  2162. $invoicePriceStaffYear = 0;
  2163. $receivablesPriceStaffYear = 0;
  2164. $accountPriceStaffYear = 0;
  2165. for($month = 1; $month <= 12; $month ++) {
  2166. $flag = true;
  2167. foreach ( $isCategory ['statisticsMonth'] as $k => $v ) {
  2168. if ($month == $v ['month']) {
  2169. $htmlA .= '<td class="taR colRed">¥' . $v ['invoicePrice'] . '</td>';
  2170. $htmlB .= '<td class="taR colOrange">¥' . $v ['receivablesPrice'] . '</td>';
  2171. $htmlC .= '<td class="taR colGreen"><b>¥' . $v ['accountPrice'] . '</b></td>';
  2172. $invoicePriceStaffYear += $v ['invoicePrice'];
  2173. $receivablesPriceStaffYear += $v ['receivablesPrice'];
  2174. $accountPriceStaffYear += $v ['accountPrice'];
  2175. $flag = false;
  2176. break;
  2177. }
  2178. }
  2179. if ($flag) {
  2180. $htmlA .= '<td class="taR">-</td>';
  2181. $htmlB .= '<td class="taR">-</td>';
  2182. $htmlC .= '<td class="taR"><b>-</b></td>';
  2183. }
  2184. }
  2185. $htmlA .= '<td class="taR colRed">' . $invoicePriceStaffYear . '</td>';
  2186. $htmlB .= '<td class="taR colOrange">' . $receivablesPriceStaffYear . '</td>';
  2187. $htmlC .= '<td class="taR colGreen"><b>' . $accountPriceStaffYear . '</b></td>';
  2188. $htmlA .= '</tr>';
  2189. $htmlB .= '</tr>';
  2190. $htmlC .= '</tr>';
  2191. $html .= $htmlA . $htmlB . $htmlC;
  2192. $this->data ['html'] = $html;
  2193. $this->data ['cidKey'] = $cidKey;
  2194. $this->data ['slist'] = $list;
  2195. $this->data ['isList'] = $toteList;
  2196. $this->data ['year'] = $year;
  2197. $this->data ['memu'] = "invoice";
  2198. $this->data ['staff'] = $this->staff;
  2199. $this->data ['receiptMemu'] = 'invoiceAggregate';
  2200. $this->render ( "/admin/invoiceAggregateCategory", $this->data );
  2201. }
  2202. function invoiceAchieve() {
  2203. Doo::loadModel ( 'invoice' );
  2204. $invoice = new invoice ();
  2205. Doo::loadClass ( 'XDeode' );
  2206. $XDeode = new XDeode ( 5 );
  2207. $sid = $XDeode->decode ( $_COOKIE ["staff"] );
  2208. $MebSea = isset ( $this->params ['MebSea'] ) ? urldecode ( $this->params ['MebSea'] ) : '';
  2209. $page_size = 18;
  2210. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  2211. $date = isset ( $this->params ['date'] ) ? $this->params ['date'] : 'MONTHO';
  2212. $get = "/" . $date;
  2213. $con = '';
  2214. if ($date == 'MONTHO')
  2215. $con = ' and updateTime>DATE_SUB(CURDATE(), INTERVAL 1 MONTH)';
  2216. elseif ($date == 'MONTHT')
  2217. $con = ' and updateTime>DATE_SUB(CURDATE(), INTERVAL 3 MONTH)';
  2218. elseif ($date == 'MONTHY')
  2219. $con = ' and updateTime>DATE_SUB(CURDATE(), INTERVAL 1 YEAR)';
  2220. if (! empty ( $MebSea )) {
  2221. $con .= ' and ( invoiceTitle like "%' . $MebSea . '%" or invoiceCompany like "%' . $MebSea . '%" or invoicePrice like "%' . $MebSea . '%" )';
  2222. $get .= "/" . $MebSea;
  2223. }
  2224. $pageinfo ['page'] = array (
  2225. 'previous' => ''
  2226. );
  2227. $sql = 'status=2 and printStatus=1 and ( untreadStatus=3 or untreadStatus=0 ) and sid=' . $sid . $con;
  2228. $pageinfo = $this->get_page ( "CLD_invoice", $sql, $page, $page_size, "invoiceAchieve", $get, "" );
  2229. $limit = $pageinfo ['lower'] . ',' . $page_size;
  2230. $list = $invoice->getInvoiceByUntreadStatusPage ( $limit, $sql );
  2231. // print_r($pageinfo);
  2232. $this->data ['MebSeaEn'] = $MebSea;
  2233. $this->data ['MebSea'] = urlencode ( $MebSea );
  2234. $this->data ['get'] = $get;
  2235. $this->data ['page'] = $pageinfo;
  2236. $this->data ['list'] = $list;
  2237. $this->data ['date'] = $date;
  2238. $this->data ['memu'] = "invoice";
  2239. $this->data ['staff'] = $this->staff;
  2240. $this->data ['receiptMemu'] = 'invoice';
  2241. $this->render ( "/admin/invoiceAchieve", $this->data );
  2242. }
  2243. function invoiceMyUnAccountAchieve() {
  2244. Doo::loadModel ( 'invoice' );
  2245. $invoice = new invoice ();
  2246. Doo::loadClass ( 'XDeode' );
  2247. $XDeode = new XDeode ( 5 );
  2248. Doo::loadModel ( 'staff' );
  2249. $staff = new staff ();
  2250. $sid = $XDeode->decode ( $_COOKIE ["staff"] );
  2251. $MebSea = $this->get_args ( 'MebSea' ) ? $this->get_args ( 'MebSea' ) : "";
  2252. $page_size = 18;
  2253. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  2254. $date = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "";
  2255. $get = "?date=" . urlencode ( $date ) . "&MebSea=" . urlencode ( $MebSea );
  2256. $dateArr = explode ( ':', $date );
  2257. $D1 = '';
  2258. $D2 = '';
  2259. if (! empty ( $date )) {
  2260. $D1 = $dateArr [0];
  2261. $D2 = $dateArr [1];
  2262. }
  2263. $con = '';
  2264. if (! empty ( $D1 ) && ! empty ( $D2 ))
  2265. $con = ' and printTime BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
  2266. if (! empty ( $MebSea )) {
  2267. $con .= ' and ( invoiceTitle like "%' . $MebSea . '%" or invoiceCompany like "%' . $MebSea . '%" or invoicePrice like "%' . $MebSea . '%" )';
  2268. }
  2269. $pageinfo ['page'] = array (
  2270. 'previous' => ''
  2271. );
  2272. // and irid='' and ( (doPost=1 and postStatus=1) or doPost=0 )
  2273. $sql = " status=2 and printStatus=1 and untreadStatus=0 and isDelete=0 and sid= " . $sid . $con;
  2274. $action = "invoiceMyUnAccountAchieve";
  2275. $pageinfo = $this->get_page ( "CLD_invoice", $sql, $page, $page_size, $action, $get, "" );
  2276. $limit = $pageinfo ['lower'] . ',' . $page_size;
  2277. $list = $invoice->getInvoiceByUntreadStatusPage ( $limit, $sql );
  2278. Doo::loadModel ( 'express' );
  2279. $express = new express ();
  2280. $expressList = $express->getExpressByAll ();
  2281. $this->data ['expressList'] = $expressList;
  2282. // print_r($list);
  2283. $this->data ['MebSeaEn'] = $MebSea;
  2284. $this->data ['get'] = $get;
  2285. $this->data ['page'] = $pageinfo;
  2286. $this->data ['date'] = $date;
  2287. $this->data ['list'] = $list;
  2288. $this->data ['memu'] = "invoice";
  2289. $this->data ['staff'] = $this->staff;
  2290. $this->data ['receiptMemu'] = 'invoice';
  2291. $this->render ( "/admin/invoiceMyUnAccountAchieve", $this->data );
  2292. }
  2293. function invoiceReceivablesAchieve() {
  2294. Doo::loadModel ( 'invoiceReceivables' );
  2295. $invoiceReceivables = new invoiceReceivables ();
  2296. Doo::loadClass ( 'XDeode' );
  2297. $XDeode = new XDeode ( 5 );
  2298. $sid = $XDeode->decode ( $_COOKIE ["staff"] );
  2299. $MebSea = isset ( $this->params ['MebSea'] ) ? urldecode ( $this->params ['MebSea'] ) : '';
  2300. $page_size = 1;
  2301. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  2302. $date = isset ( $this->params ['date'] ) ? $this->params ['date'] : 'MONTHO';
  2303. $get = "/" . $date;
  2304. $con = '';
  2305. if ($date == 'MONTHO')
  2306. $con = ' and bindDate>DATE_SUB(CURDATE(), INTERVAL 1 MONTH)';
  2307. elseif ($date == 'MONTHT')
  2308. $con = ' and bindDate>DATE_SUB(CURDATE(), INTERVAL 3 MONTH)';
  2309. elseif ($date == 'MONTHY')
  2310. $con = ' and bindDate>DATE_SUB(CURDATE(), INTERVAL 1 YEAR)';
  2311. if (! empty ( $MebSea )) {
  2312. $con .= ' and ( receivablesMessage like "%' . $MebSea . '%" or receivablesPrice like "%' . $MebSea . '%" )';
  2313. $get .= "/" . $MebSea;
  2314. }
  2315. $pageinfo ['page'] = array (
  2316. 'previous' => ''
  2317. );
  2318. $sql = " bindStatus=1 and receivablesStaff like '" . $sid . "_%' " . $con;
  2319. $pageinfo = $this->get_page ( "CLD_invoiceReceivables", $sql, $page, $page_size, "invoiceReceivablesAchieve", $get, "" );
  2320. $limit = $pageinfo ['lower'] . ',' . $page_size;
  2321. $list = $invoiceReceivables->getReceivablesByUntreadStatusPage ( $limit, $sql );
  2322. // print_r($pageinfo);
  2323. $this->data ['MebSeaEn'] = $MebSea;
  2324. $this->data ['MebSea'] = urlencode ( $MebSea );
  2325. $this->data ['get'] = $get;
  2326. $this->data ['page'] = $pageinfo;
  2327. $this->data ['list'] = $list;
  2328. $this->data ['date'] = $date;
  2329. $this->data ['memu'] = "invoice";
  2330. $this->data ['staff'] = $this->staff;
  2331. $this->data ['receiptMemu'] = 'invoiceMyReceivables';
  2332. $this->render ( "/admin/invoiceReceivablesAchieve", $this->data );
  2333. }
  2334. /**
  2335. * 收款解绑
  2336. */
  2337. function invoiceUnBundLing() {
  2338. $unBundKey = $this->get_args ( 'unBundKey' ) ? $this->get_args ( 'unBundKey' ) : '';
  2339. Doo::loadModel ( 'invoice' );
  2340. $invoice = new invoice ();
  2341. Doo::loadModel ( 'invoiceReceivables' );
  2342. $invoiceReceivables = new invoiceReceivables ();
  2343. Doo::loadModel ( 'invoiceOperationLog' );
  2344. $invoiceOperationLog = new invoiceOperationLog ();
  2345. Doo::loadModel ( 'invoiceROLog' );
  2346. $invoiceROLog = new invoiceROLog ();
  2347. Doo::loadModel ( 'invoiceStatistics' );
  2348. $irid = $invoice->authcode ( $unBundKey );
  2349. if (! empty ( $irid ) && ! is_numeric ( $irid ))
  2350. die ( 'illegal request' );
  2351. $irDetails = $invoiceReceivables->getInvoiceReceivablesByIrid ( $irid );
  2352. $invoiceDetails = $invoice->getInvoiceByIid ( $irDetails ['iid'] );
  2353. if (empty ( $irDetails ) || $irDetails ['bindStatus'] == 0 || $invoiceDetails ['untreadStatus'] == 2)
  2354. die ( 'illegal request' );
  2355. // 收款
  2356. $item = array (
  2357. 'irid' => $irDetails ['irid'],
  2358. 'bindStatus' => 0,
  2359. 'iid' => 0
  2360. );
  2361. $invoiceReceivables->setInvoiceReceivablesByCondition ( $item );
  2362. // 收款操作日志
  2363. $item = array (
  2364. 'operation' => $this->staff [0] ['username'] . " 解绑 " . $irDetails ['receivablesSerial'],
  2365. 'date' => date ( "Y-m-d" ),
  2366. 'status' => 3,
  2367. 'img' => $this->staff [0] ['avatar'],
  2368. 'username' => $this->staff [0] ['username'],
  2369. 'uid' => $this->staff [0] ['sid'],
  2370. 'category' => $this->staff [0] ['category'],
  2371. 'irid' => $irid
  2372. );
  2373. $invoiceROLog->setInvoiceROLog ( $item );
  2374. // 扣除入账统计金额
  2375. $invoiceStatistics = new invoiceStatistics ();
  2376. $item = array (
  2377. 'date' => date ( 'Y-m-d', strtotime ( $irDetails ['receivablesDate'] ) ),
  2378. 'priceClass' => 3,
  2379. 'cid' => $invoiceDetails ['cid'],
  2380. 'staff' => $invoiceDetails ['sid'],
  2381. 'accountPrice' => - $irDetails ['receivablesPrice']
  2382. );
  2383. $invoiceStatistics->setInvoiceStatisticsByCondition ( $item );
  2384. // 扣除收款统计金额
  2385. $invoiceStatistics = new invoiceStatistics ();
  2386. $item = array (
  2387. 'date' => date ( 'Y-m-d', strtotime ( $irDetails ['receivablesDate'] ) ),
  2388. 'priceClass' => 2,
  2389. 'cid' => $invoiceDetails ['cid'],
  2390. 'staff' => $invoiceDetails ['sid'],
  2391. 'irid'=>$irDetails ['irid'],
  2392. 'receivablesPrice' => - $irDetails ['receivablesPrice']
  2393. );
  2394. $invoiceStatistics->setInvoiceStatisticsByCondition ( $item );
  2395. // 发票解绑去收款ID
  2396. $iridString = $invoiceDetails ['irid'];
  2397. if (! empty ( $invoiceDetails ['irid'] )) {
  2398. $list = explode ( ',', $invoiceDetails ['irid'] );
  2399. foreach ( $list as $key => $value ) {
  2400. if ($value == $irDetails ['irid']) {
  2401. unset ( $list [$key] );
  2402. break;
  2403. }
  2404. }
  2405. $iridString = implode ( ",", $list );
  2406. }
  2407. $item = array (
  2408. 'iid' => $invoiceDetails ['iid'],
  2409. 'irid' => $iridString,
  2410. 'updateTime' => date ( "Y-m-d H:i:s" )
  2411. );
  2412. if ($invoiceDetails ['untreadStatus'] == 3)
  2413. $item += array (
  2414. 'untreadStatus' => 0
  2415. );
  2416. $invoice->setInvoiceByCondition ( $item );
  2417. $item = array (
  2418. 'date' => date ( "Y-m-d H:i:s" ),
  2419. 'operation' => '解绑 收款 ' . $irDetails ['receivablesSerial'],
  2420. 'status' => 11,
  2421. 'img' => $this->staff [0] ['avatar'],
  2422. 'username' => $this->staff [0] ['username'],
  2423. 'uid' => $this->staff [0] ['sid'],
  2424. 'category' => $this->staff [0] ['category'],
  2425. 'iid' => $invoiceDetails ['iid']
  2426. );
  2427. $invoiceOperationLog->setInvoiceOperationLog ( $item );
  2428. return "/invoiceReceivablesAS";
  2429. }
  2430. /**
  2431. * 发票管理
  2432. */
  2433. function invoiceAS() {
  2434. Doo::loadModel ( 'invoice' );
  2435. $invoice = new invoice ();
  2436. Doo::loadModel ( 'invoiceReceivables' );
  2437. $invoiceReceivables = new invoiceReceivables ();
  2438. $MebSea = $this->get_args ( 'MebSea' ) ? $this->get_args ( 'MebSea' ) : "";
  2439. $page_size = 18;
  2440. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  2441. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : 'All';
  2442. $date = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "";
  2443. $dateArr = explode ( ':', $date );
  2444. $D1 = '';
  2445. $D2 = '';
  2446. if (! empty ( $date )) {
  2447. $D1 = $dateArr [0];
  2448. $D2 = $dateArr [1];
  2449. }
  2450. $con = ' status=2 ';
  2451. if (! empty ( $D1 ) && ! empty ( $D2 ))
  2452. $con .= ' and date BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
  2453. if ($status == 'UNRECORD')
  2454. $con .= ' and printStatus=1 and untreadStatus=0';
  2455. elseif ($status == 'RECORD')
  2456. $con .= ' and printStatus=1 and untreadStatus=3';
  2457. elseif ($status == 'BOUNCED')
  2458. $con .= ' and untreadStatus=2';
  2459. elseif($status == 'PARTRECORD')
  2460. $con .= ' and untreadStatus=0 and printStatus=1 and irid!=""';
  2461. elseif ($status == 'All') {
  2462. $con .= ' and ( untreadStatus=2 or untreadStatus=0 or untreadStatus=3 )';
  2463. }
  2464. $get = "/" . $status . "?date=" . urlencode ( $date ) . "&MebSea=" . urlencode ( $MebSea );
  2465. if (! empty ( $MebSea )) {
  2466. $con .= ' and ( invoiceTitle like "%' . $MebSea . '%" or invoiceCompany like "%' . $MebSea . '%" )';
  2467. }
  2468. $pageinfo ['page'] = array (
  2469. 'previous' => ''
  2470. );
  2471. $pageinfo = $this->get_page ( "CLD_invoice", $con, $page, $page_size, "invoiceAS", $get, "" );
  2472. $limit = $pageinfo ['lower'] . ',' . $page_size;
  2473. $list = $invoice->getInvoiceByUntreadStatusPage ( $limit, $con );
  2474. // print_r($list);
  2475. // foreach ($list as $key=>$value){
  2476. // $list[$key]['rpSum']=0;
  2477. // if (!empty($value['irid']))
  2478. // $list[$key]['rpSum']=$invoiceReceivables->getSumOfReceivablesPrice($value['irid']);
  2479. // }
  2480. $this->data ['MebSeaEn'] = $MebSea;
  2481. $this->data ['MebSea'] = urlencode ( $MebSea );
  2482. $this->data ['date'] = $date;
  2483. $this->data ['page'] = $pageinfo;
  2484. $this->data ['get'] = $get;
  2485. $this->data ['list'] = $list;
  2486. $this->data ['status'] = $status;
  2487. $this->data ['memu'] = "invoice";
  2488. $this->data ['staff'] = $this->staff;
  2489. $this->data ['receiptMemu'] = 'invoiceReceivables';
  2490. $this->render ( "/admin/invoiceAS", $this->data );
  2491. }
  2492. /**
  2493. * 收款管理
  2494. */
  2495. function invoiceReceivablesAS() {
  2496. Doo::loadModel ( 'invoiceReceivables' );
  2497. $invoiceReceivables = new invoiceReceivables ();
  2498. $MebSea = $this->get_args ( 'MebSea' ) ? $this->get_args ( 'MebSea' ) : "";
  2499. $timeType = $this->get_args ( 'timeType' ) ? $this->get_args ( 'timeType' ) : "CREATE";
  2500. $page_size = 6;
  2501. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  2502. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : 'All';
  2503. $date = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "";
  2504. $dateArr = explode ( ':', $date );
  2505. $D1 = '';
  2506. $D2 = '';
  2507. if (! empty ( $date )) {
  2508. $D1 = $dateArr [0];
  2509. $D2 = $dateArr [1];
  2510. }
  2511. $con = '1';
  2512. if (! empty ( $D1 ) && ! empty ( $D2 ))
  2513. $con .= ' and date BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
  2514. $descField = 'bindDate';
  2515. if ($timeType == 'CREATE')
  2516. $descField = 'date';
  2517. if ($status == 'Unclaimed')
  2518. $con .= ' and bindStatus=0';
  2519. elseif ($status == 'Credited')
  2520. $con .= ' and bindStatus=1';
  2521. elseif ($status == 'Claim')
  2522. $con .= ' and bindStatus=0 and receivablesStaff="PUBLIC"';
  2523. $get = "/" . $status . "?date=" . urlencode ( $date ) . "&MebSea=" . urlencode ( $MebSea );
  2524. if (! empty ( $MebSea )) {
  2525. $con .= ' and ( receivablesMessage like "%' . $MebSea . '%" or receivablesPrice like "%' . $MebSea . '%" )';
  2526. }
  2527. $pageinfo ['page'] = array (
  2528. 'previous' => ''
  2529. );
  2530. $pageinfo = $this->get_page ( "CLD_invoiceReceivables", $con, $page, $page_size, "invoiceReceivablesAS", $get, "" );
  2531. $limit = $pageinfo ['lower'] . ',' . $page_size;
  2532. $list = $invoiceReceivables->getReceivablesByUntreadStatusPage ( $limit, $con, 'desc', $descField );
  2533. // print_r($list);
  2534. $this->data ['timeType'] = $timeType;
  2535. $this->data ['MebSeaEn'] = $MebSea;
  2536. $this->data ['MebSea'] = urlencode ( $MebSea );
  2537. $this->data ['date'] = $date;
  2538. $this->data ['page'] = $pageinfo;
  2539. $this->data ['get'] = $get;
  2540. $this->data ['list'] = $list;
  2541. $this->data ['status'] = $status;
  2542. $this->data ['memu'] = "invoice";
  2543. $this->data ['staff'] = $this->staff;
  2544. $this->data ['receiptMemu'] = 'invoiceReceivables';
  2545. $this->render ( "/admin/invoiceReceivablesAS", $this->data );
  2546. }
  2547. function invoiceApprovalAchieve() {
  2548. Doo::loadModel ( 'invoice' );
  2549. $invoice = new invoice ();
  2550. $MebSea = isset ( $this->params ['MebSea'] ) ? urldecode ( $this->params ['MebSea'] ) : '';
  2551. $page_size = 12;
  2552. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  2553. $date = isset ( $this->params ['date'] ) ? $this->params ['date'] : 'MONTHO';
  2554. $get = "/" . $date;
  2555. $con = '';
  2556. if ($date == 'MONTHO')
  2557. $con = ' and updateTime>DATE_SUB(CURDATE(), INTERVAL 1 MONTH)';
  2558. elseif ($date == 'MONTHT')
  2559. $con = ' and updateTime>DATE_SUB(CURDATE(), INTERVAL 3 MONTH)';
  2560. elseif ($date == 'MONTHY')
  2561. $con = ' and updateTime>DATE_SUB(CURDATE(), INTERVAL 1 YEAR)';
  2562. if (! empty ( $MebSea )) {
  2563. $con .= ' and ( invoiceTitle like "%' . $MebSea . '%" or invoiceCompany like "%' . $MebSea . '%" or invoicePrice like "%' . $MebSea . '%" )';
  2564. $get .= "/" . $MebSea;
  2565. }
  2566. $pageinfo ['page'] = array (
  2567. 'previous' => ''
  2568. );
  2569. $sql = '(status=1 or status=2 or status=3 or status=4) and processApprovals!=""' . $con; // echo $sql;
  2570. $pageinfo = $this->get_page ( "CLD_invoice", $sql, $page, $page_size, "invoiceApprovalAchieve", $get, "" );
  2571. $limit = $pageinfo ['lower'] . ',' . $page_size;
  2572. $list = $invoice->getInvoiceByUntreadStatusPage ( $limit, $sql );
  2573. // print_r($list);
  2574. $this->data ['MebSeaEn'] = $MebSea;
  2575. $this->data ['MebSea'] = urlencode ( $MebSea );
  2576. $this->data ['get'] = $get;
  2577. $this->data ['page'] = $pageinfo;
  2578. $this->data ['list'] = $list;
  2579. $this->data ['date'] = $date;
  2580. $this->data ['memu'] = "invoice";
  2581. $this->data ['staff'] = $this->staff;
  2582. $this->data ['receiptMemu'] = 'invoiceApproval';
  2583. $this->render ( "/admin/invoiceApprovalAchieve", $this->data );
  2584. }
  2585. function invoiceTAchieve() {
  2586. Doo::loadModel ( 'invoice' );
  2587. $invoice = new invoice ();
  2588. Doo::loadClass ( 'XDeode' );
  2589. $XDeode = new XDeode ( 5 );
  2590. Doo::loadModel ( 'staff' );
  2591. $staff = new staff ();
  2592. $MebSea = isset ( $this->params ['MebSea'] ) ? urldecode ( $this->params ['MebSea'] ) : '';
  2593. $page_size = 2;
  2594. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  2595. $date = isset ( $this->params ['date'] ) ? $this->params ['date'] : 'MONTHO';
  2596. $get = "/" . $date;
  2597. $con = '';
  2598. if ($date == 'MONTHO')
  2599. $con = ' and updateTime>DATE_SUB(CURDATE(), INTERVAL 1 MONTH)';
  2600. elseif ($date == 'MONTHT')
  2601. $con = ' and updateTime>DATE_SUB(CURDATE(), INTERVAL 3 MONTH)';
  2602. elseif ($date == 'MONTHY')
  2603. $con = ' and updateTime>DATE_SUB(CURDATE(), INTERVAL 1 YEAR)';
  2604. if (! empty ( $MebSea )) {
  2605. $con .= ' and ( invoiceTitle like "%' . $MebSea . '%" or invoiceCompany like "%' . $MebSea . '%" or invoicePrice like "%' . $MebSea . '%" )';
  2606. $get .= "/" . $MebSea;
  2607. }
  2608. $pageinfo ['page'] = array (
  2609. 'previous' => ''
  2610. );
  2611. $sql = "";
  2612. $action = "";
  2613. if ($this->ACTION == 'invoicePrintAchieve') {
  2614. $sql = "status=2 and printStatus=1 and moldManage like '%[\"" . $this->staff [0] ['sid'] . "\",%'" . $con;
  2615. $action = "invoicePrintAchieve";
  2616. } elseif ($this->ACTION == 'invoicePostAchieve') {
  2617. // and untreadStatus=0
  2618. $sql = "postStatus=1 and doPost=1 and status=2 and isDelete=0" . $con;
  2619. $action = "invoicePostAchieve";
  2620. } elseif ($this->ACTION == 'invoiceUntreadAchieve') { // printStatus=1 and
  2621. $sql = " untreadStatus=2 and status=2 " . $con;
  2622. $action = "invoiceUntreadAchieve";
  2623. }
  2624. $pageinfo = $this->get_page ( "CLD_invoice", $sql, $page, $page_size, $action, $get, "" );
  2625. $limit = $pageinfo ['lower'] . ',' . $page_size;
  2626. $list = $invoice->getInvoiceByUntreadStatusPage ( $limit, $sql );
  2627. $this->data ['MebSeaEn'] = $MebSea;
  2628. $this->data ['MebSea'] = urlencode ( $MebSea );
  2629. $this->data ['get'] = $get;
  2630. $this->data ['page'] = $pageinfo;
  2631. $this->data ['date'] = $date;
  2632. $this->data ['memu'] = "invoice";
  2633. $this->data ['staff'] = $this->staff;
  2634. if ($this->ACTION == 'invoicePrintAchieve') {
  2635. foreach ( $list as $key => $value ) {
  2636. $list [$key] ['iidKey'] = $XDeode->encode ( $value ['iid'] );
  2637. $lastApprover = json_decode ( $value ['processApprovals'], true );
  2638. if (! empty ( $lastApprover )) {
  2639. $lastApproverKey = array_keys ( $lastApprover );
  2640. $lastApprover = end ( $lastApprover );
  2641. $staffDetail = $staff->getOne ( array (
  2642. 'where' => 'sid=' . end ( $lastApproverKey ),
  2643. 'asArray' => true
  2644. ) );
  2645. $lastApprover ['username'] = $staffDetail ['username'];
  2646. }
  2647. $list [$key] ['lastApprover'] = $lastApprover;
  2648. }
  2649. $this->data ['receiptMemu'] = 'invoicePrint';
  2650. $this->data ['list'] = $list;
  2651. $this->render ( "/admin/invoicePrintAchieve", $this->data );
  2652. } elseif ($this->ACTION == 'invoicePostAchieve') {
  2653. Doo::loadModel ( 'express' );
  2654. $express = new express ();
  2655. $expressList = $express->getExpressByAll ();
  2656. $this->data ['expressList'] = $expressList;
  2657. $this->data ['receiptMemu'] = 'invoicePost';
  2658. $this->data ['list'] = $list;
  2659. $this->render ( "/admin/invoicePostAchieve", $this->data );
  2660. } elseif ($this->ACTION == 'invoiceUntreadAchieve') {
  2661. $this->data ['receiptMemu'] = 'invoiceUntread';
  2662. $this->data ['list'] = $list;
  2663. $this->render ( "/admin/invoiceUntreadAchieve", $this->data );
  2664. }
  2665. }
  2666. /**
  2667. *
  2668. * @deprecated 获得与我有关可收款的发票 废弃 function ajaxGetInvoiceByStaff() { $irid = $this->get_args ( 'key' ) ? $this->get_args ( 'key' ) : ""; Doo::loadModel ( 'invoice' ); $invoice = new invoice (); $list = $invoice->getInvoiceByReceivables ( $this->staff [0] ['sid'] ); $html = ""; $i = 1; foreach ( $list as $key => $value ) { $html .= '<tr> <td>' . $value ['invoiceElement'] . '</td> <td>¥' . $value ['invoicePrice'] . '</td>'; if (! empty ( $value ['invoiceType'] )) { $html .= '<td>增值税专用发票</td> <td>' . $value ['invoiceCompany'] . '</td>'; } else { $html .= '<td>增值税普通发票</td> <td>' . $value ['invoiceTitle'] . '</td>'; } $html .= '<td><label><input type="radio" node-Claim="true_' . $i . '" p-data="' . $value ['iidKey'] . '" name="invoiceClaim"> 使用Ta</label></td></tr> <script> $(\'input[node-Claim="true_' . $i . '"]\').click(function() { var invoiceKey= $(this).attr("p-data"); var claimKey=$("input[name=\'key\']").val(); $("p[node-msg=\"true\"]").hide(); var url = "/ajaxCompareInvoicePrice"; $.ajax({ url : url, type : "post", cache : false, dataType : "json", data : { claimKey : claimKey, invoiceKey:invoiceKey }, global : true, success : function(data) { $("input[name=\'invoiceKey\']").val("' . $value ['iidKey'] . '"); if (data.status == 1) { $("p[node-msg=\"true\"]").html("收款金额超出开票金额 ¥"+data.price+"元,请谨慎操作。"); $("p[node-msg=\"true\"]").show(); } }, error : function(err) { } }); }); </script> '; $i ++; } echo json_encode ( array ( 'status' => 1, 'html' => $html ) ); }
  2669. */
  2670. /**
  2671. * 获取一条收款信息
  2672. */
  2673. function ajaxGetInvoiceReceivables() {
  2674. $irid = $this->get_args ( 'key' ) ? $this->get_args ( 'key' ) : "";
  2675. Doo::loadModel ( 'invoiceReceivables' );
  2676. $invoiceReceivables = new invoiceReceivables ();
  2677. $detail = $invoiceReceivables->getInvoiceReceivablesByIrid ( $irid );
  2678. echo json_encode ( array (
  2679. 'status' => 1,
  2680. 'detail' => $detail
  2681. ) );
  2682. }
  2683. /**
  2684. * 异步获取办事处用户
  2685. */
  2686. function ajaxGetStaffByCategory() {
  2687. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : "";
  2688. Doo::loadModel ( 'staff' );
  2689. $staff = new staff ();
  2690. if ($cid == "PUBLIC") {
  2691. echo json_encode ( array (
  2692. 'status' => 1,
  2693. 'html' => '<option value="PUBLIC">办事处待认领款项</option>'
  2694. ) );
  2695. die ();
  2696. }
  2697. if (! is_numeric ( $cid )) {
  2698. echo json_encode ( array (
  2699. 'status' => 0,
  2700. 'msg' => 'illegal request'
  2701. ) );
  2702. die ();
  2703. }
  2704. $staffList = $staff->getStaffByCid ( $cid );
  2705. $html = '<option value="PUBLIC">办事处待认领款项</option>';
  2706. foreach ( $staffList as $key => $value ) {
  2707. $html .= '<option value="' . $value ['sid'] . '-' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  2708. }
  2709. echo json_encode ( array (
  2710. 'status' => 1,
  2711. 'html' => $html
  2712. ) );
  2713. }
  2714. /**
  2715. * 异步获取一条发票的邮寄信息
  2716. */
  2717. function ajaxGetInvoicePostDetail() {
  2718. $iid = $this->get_args ( 'iidKey' ) ? $this->get_args ( 'iidKey' ) : "";
  2719. Doo::loadModel ( 'invoice' );
  2720. $invoice = new invoice ();
  2721. $iid = $invoice->authcode ( $iid );
  2722. Doo::loadModel ( 'express' );
  2723. $express = new express ();
  2724. $expressList = $express->getExpressByAll ();
  2725. if (! is_numeric ( $iid )) {
  2726. echo json_encode ( array (
  2727. 'status' => 0,
  2728. 'msg' => 'illegal request'
  2729. ) );
  2730. die ();
  2731. }
  2732. $select = "iid,recipients,recipientsPhone,recipientsAddress,mailItems,expressCompany,expressNumber,actualItems";
  2733. $invoiceDetail = $invoice->getInvoiceByIid ( $iid, $select );
  2734. $html = "";
  2735. foreach ( $expressList as $key => $value ) {
  2736. if ($value ['company'] == $invoiceDetail ['expressCompany'])
  2737. $html .= '<option selected value="' . $value ['company'] . ':' . $value ['com'] . '">' . $value ['company'] . '</option>';
  2738. else
  2739. $html .= '<option value="' . $value ['company'] . ':' . $value ['com'] . '">' . $value ['company'] . '</option>';
  2740. }
  2741. $invoiceDetail ['eaHtml'] = $html;
  2742. echo json_encode ( array (
  2743. 'status' => 1,
  2744. 'invoiceDetail' => $invoiceDetail
  2745. ) );
  2746. }
  2747. /**
  2748. *
  2749. * @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 ) ); }
  2750. */
  2751. /**
  2752. *
  2753. * @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 ) ); }
  2754. */
  2755. /**
  2756. * 我的收款中 选择哪个发票入账,进行金额判断
  2757. */
  2758. function ajaxCompareInvoicePrice() {
  2759. $claimKey = $this->get_args ( 'claimKey' ) ? $this->get_args ( 'claimKey' ) : "";
  2760. $invoiceKey = $this->get_args ( 'invoiceKey' ) ? $this->get_args ( 'invoiceKey' ) : "";
  2761. Doo::loadModel ( 'invoice' );
  2762. $invoice = new invoice ();
  2763. Doo::loadModel ( 'invoiceReceivables' );
  2764. $invoiceReceivables = new invoiceReceivables ();
  2765. $detail = $invoice->getInvoiceByIid ( $invoiceKey );
  2766. $keyList = explode ( ';', $claimKey );
  2767. $receivablesPrice = 0;
  2768. foreach ( $keyList as $key => $value ) {
  2769. $detailM = $invoiceReceivables->getInvoiceReceivablesByIrid ( $value );
  2770. $receivablesPrice += $detailM ['receivablesPrice'];
  2771. }
  2772. if ($receivablesPrice > $detail ['invoicePrice']) {
  2773. $price = $receivablesPrice - $detail ['invoicePrice'];
  2774. echo json_encode ( array (
  2775. 'status' => 1,
  2776. 'price' => $price
  2777. ) );
  2778. } else
  2779. echo json_encode ( array (
  2780. 'status' => 2
  2781. ) );
  2782. }
  2783. /**
  2784. * @ 获得与我有关收款数据 --需求变更 废弃 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 ) ); }
  2785. */
  2786. function ajaxGetInvoiceInfoByType() {
  2787. $type = $this->get_args ( 'type' ) ? $this->get_args ( 'type' ) : "";
  2788. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  2789. $loss = $this->get_args ( 'loss' ) ? $this->get_args ( 'loss' ) : false;
  2790. if (empty ( $serial )) {
  2791. echo json_encode ( array (
  2792. 'status' => 2,
  2793. 'msg' => 'illegal request'
  2794. ) );
  2795. die ();
  2796. }
  2797. if ($type == 'INVOICE') {
  2798. Doo::loadModel ( 'invoice' );
  2799. $invoice = new invoice ();
  2800. Doo::loadModel ( 'invoiceOperationLog' );
  2801. $invoiceOperationLog = new invoiceOperationLog ();
  2802. $detail = $invoice->getInvoiceByIsid ( $serial, $this->staff [0] ['sid'] );
  2803. $invoiceOperationLogList = $invoiceOperationLog->getInvoiceOperationLogByIid ( $detail ['iid'] );
  2804. if (empty ( $detail ))
  2805. $html = '';
  2806. else {
  2807. $html = '
  2808. <div class="modal-dialog modal-lg">
  2809. <div class="modal-content"><div class="modal-header"><h3>发票单详情</h3></div>
  2810. <div class="modal-body saeaList"><table class="table table-bordered table-condensed"><tbody>
  2811. <tr>
  2812. <th class="taC" width="150">开票流水号</th><td>' . $detail ['invoiceSerial'] . '</td>
  2813. <th class="taC" width="150">提交时间</th><td>' . $detail ['date'] . '</td>
  2814. </tr>
  2815. <tr>
  2816. <th class="taC" width="150">所在办事处</th><td>' . $detail ['categoryName'] . '(' . $detail ['userName'] . ')</td>
  2817. <th class="taC" width="150">开票内容</th><td>' . $detail ['invoiceElement'] . '</td>
  2818. </tr>
  2819. <tr>
  2820. <th class="taC">发票备注</th><td colspan="3">' . $detail ['remark'] . '
  2821. </td>
  2822. </tr>
  2823. <tr>
  2824. <th class="taC" width="150">数量</th><td><b>' . $detail ['invoiceQuantity'] . '</b></td>
  2825. <th class="taC">单价</th><td><b>¥' . $detail ['invoiceUnitPrice'] . '</b></td>
  2826. </tr>
  2827. <tr>
  2828. <th class="taC">开票金额</th><td colspan="3"><b class="colOrange" style="font-size:18px">¥' . $detail ['invoicePrice'] . '</b></td>
  2829. </tr></tbody></table>';
  2830. if ($detail ['invoiceType'] == 0)
  2831. $html .= '<table class="table table-bordered table-condensed"><tbody>
  2832. <tr><th colspan="4" class="taC">增值税普通发票</th></tr><tr>
  2833. <th class="taC" width="150">发票抬头</th><td >' . $detail ['invoiceTitle'] . '</td>
  2834. <th class="taC" width="150">纳税人识别码</th><td>' . $detail ['TIN'] . '</td>
  2835. </tr>';
  2836. else
  2837. $html .= '<table class="table table-bordered table-condensed"><tbody>
  2838. <tr><th colspan="4" class="taC">增值税专用发票</th></tr><tr>
  2839. <th class="taC" width="150">单位名称</th><td>' . $detail ['invoiceCompany'] . '</td>
  2840. <th class="taC" width="150">纳税人识别码</th><td>' . $detail ['TIN'] . '</td></tr>
  2841. ';
  2842. $html .= '<tr>
  2843. <th class="taC">注册地址</th><td>' . $detail ['address'] . '</td>
  2844. <th class="taC">注册电话</th><td>' . $detail ['phone'] . '</td>
  2845. </tr>
  2846. <tr>
  2847. <th class="taC">开户银行</th><td>' . $detail ['bank'] . '</td>
  2848. <th class="taC">银行账号</th><td>' . $detail ['bankAccount'] . '</td>
  2849. </tr></tbody></table>';
  2850. if ($detail ['doPost'] == 1)
  2851. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th colspan="4" class="taC">邮寄信息</th></tr><tr>
  2852. <th class="taC" width="150">收件人</th><td>' . $detail ['recipients'] . '</td>
  2853. <th class="taC" width="150">收件人手机/电话</th><td>' . $detail ['recipientsPhone'] . '</td>
  2854. </tr><tr>
  2855. <th class="taC" width="150">收件地址</th><td colspan="3">' . $detail ['recipientsAddress'] . '</td>
  2856. </tr><tr>
  2857. <th class="taC" width="150">邮寄物品</th><td colspan="3">' . $detail ['mailItems'] . '</td>
  2858. </tr></tbody></table>';
  2859. if (! empty ( $invoiceOperationLogList )) {
  2860. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th width="60%" class="taC">审批流程</th></tr><tr><td>';
  2861. foreach ( $invoiceOperationLogList as $key => $value ) {
  2862. if ($value ['status'] == 1 || $value ['status'] == 2 || $value ['status'] == 3 || $value ['status'] == 4) {
  2863. $html .= '<blockquote><p><span class="colGray">' . $value ['date'] . '</span>&nbsp;
  2864. ' . $value ['category'] . '-' . $value ['username'] . '&nbsp;';
  2865. if ($value ['status'] == 2) {
  2866. $html .= '<span class="colGreen">同意</span>';
  2867. } elseif ($value ['status'] == 3) {
  2868. $html .= '<span class="colOrange">退回</span>';
  2869. } elseif ($value ['status'] == 5) {
  2870. $html .= '<span class="colGreen">打印</span>';
  2871. } elseif ($value ['status'] == 4) {
  2872. $html .= '<span class="colRed">终止</span>';
  2873. }
  2874. $html .= $value ['operation'] . '</p></blockquote>';
  2875. }
  2876. }
  2877. $html .= '</td></tr></tbody></table>';
  2878. }
  2879. $html .= '</div><div class="modal-footer"><a href="#" class="button btn-gray" data-dismiss="modal" aria-hidden="true">关闭</a></div></div></div>';
  2880. }
  2881. echo json_encode ( array (
  2882. 'status' => 1,
  2883. 'html' => $html
  2884. ) );
  2885. die ();
  2886. } elseif ($type == 'RECEIVABLES') {
  2887. Doo::loadModel ( 'invoiceReceivables' );
  2888. $invoiceReceivables = new invoiceReceivables ();
  2889. //
  2890. $detail = $invoiceReceivables->getInvoiceReceivablesByIrsid ( $serial );
  2891. if (empty ( $detail ))
  2892. $html = '';
  2893. else {
  2894. $html = '<div class="modal-dialog modal-lg"><div class="modal-content"><div class="modal-header"><h3>收款单详情</h3></div><div class="modal-body saeaList"><table class="table table-bordered table-condensed">
  2895. <tbody><tr>
  2896. <th class="taC">收款流水号</th><td>' . $detail ['receivablesSerial'] . '</td>
  2897. <th class="taC">录入收款</th><td>' . $detail ['inputStaff'] . ' ' . $detail ['date'] . '</td>
  2898. </tr><tr>
  2899. <th class="taC">收款金额</th><td><b>¥' . $detail ['receivablesPrice'] . '</b></td>
  2900. <th class="taC">收款信息</th><td>' . $detail ['receivablesMessage'] . '</td>
  2901. </tr>
  2902. <tr>
  2903. <th class="taC">收款银行</th><td>' . $detail ['receivablesBank'] . '</td>
  2904. <th class="taC">银行到账</th><td>' . $detail ['receivablesDate'] . '</td>
  2905. </tr>
  2906. <tr>
  2907. <th class="taC">认领收款</th><td colspan="3">' . $detail ['inputStaff'] . ' 转入 ' . $detail ['username'] . ' ' . $detail ['bindDate'] . '</td>
  2908. </tr>
  2909. </tbody></table></div><div class="modal-footer"><a href="#" class="button btn-gray" data-dismiss="modal" aria-hidden="true">关闭</a></div></div></div>';
  2910. }
  2911. echo json_encode ( array (
  2912. 'status' => 1,
  2913. 'html' => $html
  2914. ) );
  2915. die ();
  2916. } elseif ($type == 'IRTC') {
  2917. Doo::loadModel ( 'invoice' );
  2918. $invoice = new invoice ();
  2919. Doo::loadModel ( 'invoiceOperationLog' );
  2920. $invoiceOperationLog = new invoiceOperationLog ();
  2921. Doo::loadModel ( 'invoiceReceivables' );
  2922. $invoiceReceivables = new invoiceReceivables ();
  2923. $detail = $invoice->getInvoiceByIsid ( $serial, $this->staff [0] ['sid'] );
  2924. $invoiceOperationLogList = $invoiceOperationLog->getInvoiceOperationLogByIid ( $detail ['iid'] );
  2925. if (empty ( $detail ))
  2926. $html = '';
  2927. else {
  2928. $receivablesPriceedHtml = '';
  2929. $receivablesPrice = $detail ['invoicePrice'];
  2930. if (! empty ( $detail ['irid'] )) {
  2931. $irList = $invoiceReceivables->getInvoiceReceivablesInIridString ( $detail ['irid'] );
  2932. if (empty ( $irList ))
  2933. $irList [0] ['sumPrice'] = 0;
  2934. $balance = $detail ['invoicePrice'] - $irList [0] ['sumPrice'];
  2935. $receivablesPriceedHtml = '<table class="table table-bordered table-condensed"><tbody><tr>
  2936. <th class="taC">已入账金额</th><td><b class="colGreen" style="font-size:18px">¥' . $irList [0] ['sumPrice'] . '</b></td>
  2937. <th class="taC">剩余入账金额</th><td><b class="colRed" style="font-size:18px">¥' . $balance . '</b></td>
  2938. </tr></tbody></table>';
  2939. $receivablesPrice = $balance;
  2940. }
  2941. if ($loss)
  2942. $detail ['invoicePrice'] = - $detail ['invoicePrice'];
  2943. $html = $receivablesPriceedHtml . '
  2944. <table class="table table-bordered table-condensed"><tbody>
  2945. <tr>
  2946. <th class="taC" width="150">开票流水号</th><td>' . $detail ['invoiceSerial'] . '</td>
  2947. <th class="taC" width="150">提交时间</th><td>' . $detail ['date'] . '</td>
  2948. </tr>
  2949. <tr>
  2950. <th class="taC" width="150">所在办事处</th><td>' . $detail ['categoryName'] . '(' . $detail ['userName'] . ')</td>
  2951. <th class="taC" width="150">开票内容</th><td>' . $detail ['invoiceElement'] . '</td>
  2952. </tr>
  2953. <tr>
  2954. <th class="taC" width="150">发票备注</th><td colspan="3">' . $detail ['remark'] . '</td>
  2955. </tr>
  2956. <tr>
  2957. <th class="taC" width="150">数量</th><td><b>' . $detail ['invoiceQuantity'] . '</b></td>
  2958. <th class="taC">单价</th><td><b>¥' . $detail ['invoiceUnitPrice'] . '</b></td>
  2959. </tr>
  2960. <tr>
  2961. <th class="taC">开票金额</th><td colspan="3"><b class="colOrange" style="font-size:18px">¥' . $detail ['invoicePrice'] . '</b></td>
  2962. </tr></tbody></table>';
  2963. if ($detail ['invoiceType'] == 0) {
  2964. $html .= '<table class="table table-bordered table-condensed"><tbody>
  2965. <tr><th colspan="4" class="taC">增值税普通发票</th></tr><tr>
  2966. <th class="taC" width="150">发票抬头</th><td >' . $detail ['invoiceTitle'] . '</td>
  2967. <th class="taC" width="150">纳税人识别码</th><td>' . $detail ['TIN'] . '</td>
  2968. </tr>';
  2969. $receivablesMessage = $detail ['invoiceTitle'];
  2970. } else {
  2971. $html .= '<table class="table table-bordered table-condensed"><tbody>
  2972. <tr><th colspan="4" class="taC">增值税专用发票</th></tr><tr>
  2973. <th class="taC" width="150">单位名称</th><td>' . $detail ['invoiceCompany'] . '</td>
  2974. <th class="taC" width="150">纳税人识别码</th><td>' . $detail ['TIN'] . '</td></tr>
  2975. ';
  2976. $receivablesMessage = $detail ['invoiceCompany'];
  2977. }
  2978. $html .= '<tr>
  2979. <th class="taC">注册地址</th><td>' . $detail ['address'] . '</td>
  2980. <th class="taC">注册电话</th><td>' . $detail ['phone'] . '</td>
  2981. </tr>
  2982. <tr>
  2983. <th class="taC">开户银行</th><td>' . $detail ['bankAccount'] . '</td>
  2984. <th class="taC">银行账号</th><td>' . $detail ['bank'] . '</td>
  2985. </tr></tbody></table>';
  2986. if ($detail ['doPost'] == 1)
  2987. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th colspan="4" class="taC">邮寄信息</th></tr><tr>
  2988. <th class="taC" width="150">收件人</th><td>' . $detail ['recipients'] . '</td>
  2989. <th class="taC" width="150">收件人手机/电话</th><td>' . $detail ['recipientsPhone'] . '</td>
  2990. </tr><tr>
  2991. <th class="taC" width="150">收件地址</th><td colspan="3">' . $detail ['recipientsAddress'] . '</td>
  2992. </tr><tr>
  2993. <th class="taC" width="150">邮寄物品</th><td colspan="3">' . $detail ['mailItems'] . '</td>
  2994. </tr></tbody></table>';
  2995. if (! empty ( $invoiceOperationLogList )) {
  2996. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th width="60%" class="taC">审批流程</th></tr><tr><td>';
  2997. foreach ( $invoiceOperationLogList as $key => $value ) {
  2998. if ($value ['status'] == 1 || $value ['status'] == 2 || $value ['status'] == 3 || $value ['status'] == 4) {
  2999. $html .= '<blockquote><p><span class="colGray">' . $value ['date'] . '</span>&nbsp;
  3000. ' . $value ['category'] . '-' . $value ['username'] . '&nbsp;';
  3001. if ($value ['status'] == 2) {
  3002. $html .= '<span class="colGreen">同意</span>';
  3003. } elseif ($value ['status'] == 3) {
  3004. $html .= '<span class="colOrange">退回</span>';
  3005. } elseif ($value ['status'] == 5) {
  3006. $html .= '<span class="colGreen">打印</span>';
  3007. }
  3008. $html .= $value ['operation'] . '</p></blockquote>';
  3009. }
  3010. }
  3011. $html .= '</td></tr></tbody></table>';
  3012. }
  3013. }
  3014. echo json_encode ( array (
  3015. 'status' => 1,
  3016. 'html' => $html,
  3017. 'receivablesPrice' => $receivablesPrice,
  3018. 'receivablesMessage' => $receivablesMessage,
  3019. 'receivablesDate' => date ( "Y-m-d" ),
  3020. 'iidKey' => $serial
  3021. ) );
  3022. die ();
  3023. }
  3024. }
  3025. function ajaxGetInvoiceReceivablesByStaff() {
  3026. $postData = $this->get_args ( 'postData' ) ? $this->get_args ( 'postData' ) : "";
  3027. if (empty ( $postData )) {
  3028. echo json_encode ( array (
  3029. 'status' => 2,
  3030. 'msg' => 'illegal request'
  3031. ) );
  3032. die ();
  3033. }
  3034. Doo::loadModel ( 'invoiceReceivables' );
  3035. $invoiceReceivables = new invoiceReceivables ();
  3036. $detail = $invoiceReceivables->getInvoiceReceivablesByIrid ( $postData );
  3037. if (empty ( $detail )) {
  3038. echo json_encode ( array (
  3039. 'status' => 2,
  3040. 'msg' => 'illegal request'
  3041. ) );
  3042. die ();
  3043. }
  3044. Doo::loadModel ( 'L_category' );
  3045. $lCategory = new L_category ();
  3046. Doo::loadModel ( 'staff' );
  3047. $staff = new staff ();
  3048. $staffList = $staff->getStaffByCid ( $detail ['cid'] );
  3049. $category = $lCategory->getCategory ();
  3050. $categoryHtml = '<option post-data="PUBLIC" value="PUBLIC" >公共待认领款项</option>';
  3051. $staffHtml = '<option value="PUBLIC">办事处待认领款项</option>';
  3052. foreach ( $category as $key => $value ) {
  3053. $categoryHtml .= '<option post-data="' . $value ['cid'] . '" value="' . $value ['cid'] . ':' . $value ['title'] . '" >' . $value ['title'] . '</option>';
  3054. if ($value ['cid'] == $detail ['cid'])
  3055. $categoryHtml .= '<option selected post-data="' . $value ['cid'] . '" value="' . $value ['cid'] . ':' . $value ['title'] . '" >' . $value ['title'] . '</option>';
  3056. }
  3057. foreach ( $staffList as $key => $value ) {
  3058. $staffHtml .= '<option value="' . $value ['sid'] . '-' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  3059. if ($value ['sid'] == $detail ['sid'])
  3060. $staffHtml .= '<option selected value="' . $value ['sid'] . '-' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  3061. }
  3062. $rbankHtml = '<option value="广发银行珠海分行柠溪支行">广发银行珠海分行柠溪支行</option>';
  3063. echo json_encode ( array (
  3064. 'status' => 1,
  3065. 'categoryHtml' => $categoryHtml,
  3066. 'staffHtml' => $staffHtml,
  3067. 'rbankHtml' => $rbankHtml,
  3068. 'detail' => $detail
  3069. ) );
  3070. }
  3071. function ajaxGetInvoiceReceivablesByIrid() {
  3072. $irid = $this->get_args ( 'irid' ) ? $this->get_args ( 'irid' ) : "";
  3073. if (empty ( $irid )) {
  3074. echo json_encode ( array (
  3075. 'status' => 2,
  3076. 'msg' => 'illegal request'
  3077. ) );
  3078. die ();
  3079. }
  3080. Doo::loadModel ( 'invoiceReceivables' );
  3081. $invoiceReceivables = new invoiceReceivables ();
  3082. Doo::loadModel ( 'invoice' );
  3083. $invoice = new invoice ();
  3084. $detail = $invoiceReceivables->getInvoiceReceivablesByIrid ( $irid ); // 入账完成 待定 and postStatus=1
  3085. $invoiceDetail = $invoice->getInvoiceByTitle ( $detail ['recepitTitleMark'], 'EXACTLY', " and status=2 and printStatus=1 and untreadStatus=0 " ); //
  3086. $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>
  3087. <tr>
  3088. <td><b>¥' . $detail ['receivablesPrice'] . '</b></td>
  3089. <td>' . $detail ['receivablesMessage'] . '</td>
  3090. <td>' . $detail ['receivablesBank'] . '<br>' . $detail ['receivablesDate'] . '</td>
  3091. <td>' . $detail ['title'] . '-' . $detail ['username'] . '<br>' . $detail ['confirmTime'] . '</td>
  3092. <td>' . $detail ['recepitTitleMark'] . '</td>
  3093. </tr></tbody></table>';
  3094. $isInvoice = false;
  3095. $invoiceHtml = '';
  3096. if (empty ( $invoiceDetail )) {
  3097. $isInvoice = true;
  3098. } else {
  3099. $invoiceHtml = '<table class="table table-bordered table-condensed">
  3100. <thead><tr><th>开票单位(抬头)</th><th>开票金额</th><th>提交开票</th><th>出票</th><th>开票流水号</th><th width="80">入账</th></tr></thead><tbody><tr>';
  3101. if (! empty ( $invoiceDetail ['invoiceType'] )) {
  3102. $invoiceHtml .= '<td>' . $invoiceDetail ['invoiceCompany'] . '</td>';
  3103. } else {
  3104. $invoiceHtml .= '<td>' . $invoiceDetail ['invoiceTitle'] . '</td>';
  3105. }
  3106. if (! empty ( $invoiceDetail ['invoiceType'] )) {
  3107. $invoiceHtml .= '<td>' . $invoiceDetail ['invoicePrice'] . '专</td>';
  3108. } else {
  3109. $invoiceHtml .= '<td>' . $invoiceDetail ['invoicePrice'] . '</td>';
  3110. }
  3111. $invoiceHtml .= '
  3112. <td>' . $invoiceDetail ['categoryName'] . $invoiceDetail ['userName'] . ' ' . $invoiceDetail ['date'] . '</td>
  3113. <td>' . $invoiceDetail ['printer'] . ' ' . $invoiceDetail ['printTime'] . '</td>
  3114. <td>' . $invoiceDetail ['invoiceSerial'] . '</td><td><a class="button btn-block" bind-receivables="ir' . $invoiceDetail ['iidKeyXD'] . '" data-ikey="' . $invoiceDetail ['iidKey'] . '" href="javascript:void(0)">入账</a></td>
  3115. </tr>
  3116. ';
  3117. $irList = $invoiceReceivables->getInvoiceReceivablesInIridString ( $invoiceDetail ['irid'] );
  3118. if (empty($irList))
  3119. $irList [0] ['sumPrice']=0;
  3120. $balance = $invoiceDetail ['invoicePrice'] - $irList [0] ['sumPrice'];
  3121. $priceString = '';
  3122. if ($balance < $detail ['receivablesPrice']) {
  3123. $priceString = '收款金额超过开票金额,';
  3124. }
  3125. if ($balance > $detail ['receivablesPrice']) {
  3126. $priceString = '收款金额低于开票金额,';
  3127. }
  3128. $invoiceHtml .= '</tbody></table>
  3129. <script>
  3130. $(\'a[bind-receivables="ir' . $invoiceDetail ['iidKeyXD'] . '"]\').click(function() {
  3131. $("input[name=\'invoiceKey\']").val("' . $invoiceDetail ['iidKey'] . '");
  3132. var invoiceKey=$("input[name=\'invoiceKey\']").val();
  3133. if(invoiceKey==""){
  3134. alert("入账错误,请重新刷新页面");
  3135. return false;
  3136. }
  3137. if(window.confirm("' . $priceString . '确定入账吗?")){
  3138. $("#IBR").submit();
  3139. }else{
  3140. return false;
  3141. }
  3142. });
  3143. </script>
  3144. ';
  3145. }
  3146. echo json_encode ( array (
  3147. 'status' => 1,
  3148. 'irkey' => $detail ['iridEn'],
  3149. 'receivablesHtml' => $receivablesHtml,
  3150. 'isInvoice' => $isInvoice,
  3151. 'invoiceHtml' => $invoiceHtml
  3152. ) );
  3153. }
  3154. function ajaxGetInvoiceReceivablesByTitle() {
  3155. $title = $this->get_args ( 'title' ) ? $this->get_args ( 'title' ) : "";
  3156. if (empty ( $title )) {
  3157. echo json_encode ( array (
  3158. 'status' => 2,
  3159. 'msg' => 'illegal request'
  3160. ) );
  3161. die ();
  3162. }
  3163. Doo::loadModel ( 'invoice' );
  3164. $invoice = new invoice ();
  3165. $invoiceDetail = $invoice->getInvoiceByTitle ( $title, 'EXACTLY', " and status=2 and printStatus=1 and untreadStatus=0 " );
  3166. $invoiceHtml = '';
  3167. if (! empty ( $invoiceDetail )) {
  3168. $invoiceHtml = '<table class="table table-bordered table-condensed">
  3169. <thead><tr><th>开票单位(抬头)</th><th>开票金额</th><th>提交开票</th><th>出票</th><th>开票流水号</th><th width="80">入账</th></tr></thead><tbody><tr>';
  3170. if (! empty ( $invoiceDetail ['invoiceType'] )) {
  3171. $invoiceHtml .= '<td>' . $invoiceDetail ['invoiceCompany'] . '</td>';
  3172. } else {
  3173. $invoiceHtml .= '<td>' . $invoiceDetail ['invoiceTitle'] . '</td>';
  3174. }
  3175. if (! empty ( $invoiceDetail ['invoiceType'] )) {
  3176. $invoiceHtml .= '<td>' . $invoiceDetail ['invoicePrice'] . '专</td>';
  3177. } else {
  3178. $invoiceHtml .= '<td>' . $invoiceDetail ['invoicePrice'] . '</td>';
  3179. }
  3180. $invoiceHtml .= '
  3181. <td>' . $invoiceDetail ['categoryName'] . $invoiceDetail ['userName'] . ' ' . $invoiceDetail ['date'] . '</td>
  3182. <td>' . $invoiceDetail ['printer'] . ' ' . $invoiceDetail ['printTime'] . '</td>
  3183. <td>' . $invoiceDetail ['invoiceSerial'] . '</td><td><a class="button btn-block" bind-receivables="ir' . $invoiceDetail ['iidKeyXD'] . '" data-ikey="' . $invoiceDetail ['iidKey'] . '" href="#">入账</a></td>
  3184. </tr>
  3185. ';
  3186. $invoiceHtml .= '</tbody></table>
  3187. <script>
  3188. $(\'a[bind-receivables="ir' . $invoiceDetail ['iidKeyXD'] . '"]\').click(function() {
  3189. $("input[name=\'invoiceKey\']").val("' . $invoiceDetail ['iidKey'] . '");
  3190. var invoiceKey=$("input[name=\'invoiceKey\']").val();
  3191. if(invoiceKey==""){
  3192. alert("入账错误,请重新刷新页面");
  3193. return false;
  3194. }
  3195. if(window.confirm("确定入账吗?")){
  3196. $("#IBR").submit();
  3197. }else{
  3198. return false;
  3199. }
  3200. });
  3201. </script>
  3202. ';
  3203. }
  3204. echo json_encode ( array (
  3205. 'status' => 1,
  3206. 'invoiceHtml' => $invoiceHtml
  3207. ) );
  3208. }
  3209. function ajaxInvoicePushNotice() {
  3210. Doo::loadModel ( 'invoice' );
  3211. $invoice = new invoice ();
  3212. $approval = $invoice->getOne ( array (
  3213. 'where' => 'status=1 and pendingApprovals=' . $this->staff [0] ['sid'],
  3214. 'desc' => 'iid',
  3215. 'asArray' => true
  3216. ) );
  3217. $isNotice = false;
  3218. if (! empty ( $approval ))
  3219. $isNotice = true;
  3220. $response = array (
  3221. 'error' => 0,
  3222. 'isNotice' => $isNotice
  3223. );
  3224. echo json_encode ( $response );
  3225. exit ();
  3226. }
  3227. public function ajaxCheckInvoiceNoUniqueness() {
  3228. $invoiceNo = $this->get_args ( 'invoiceNo' ) ? $this->get_args ( 'invoiceNo' ) : "";
  3229. Doo::loadModel ( 'invoice' );
  3230. $invoice = new invoice ();
  3231. if (! empty ( $invoiceNo )) {
  3232. $info = $invoice->getOne ( array (
  3233. 'where' => "invoiceNo = '" . $invoiceNo . "'",
  3234. 'asArray' => TRUE
  3235. ) );
  3236. if (! empty ( $info )) {
  3237. echo json_encode ( array (
  3238. 'error' => '发票号已存在'
  3239. ) );
  3240. die ();
  3241. } else
  3242. echo json_encode ( array (
  3243. 'ok' => '可以使用!'
  3244. ) );
  3245. die ();
  3246. }
  3247. }
  3248. function ajaxCheckInvoicePrice() {
  3249. $receivablesPrice = $this->get_args ( 'receivablesPrice' ) && is_numeric ( $this->get_args ( 'receivablesPrice' ) ) ? $this->get_args ( 'receivablesPrice' ) : "";
  3250. $iidKey = $this->get_args ( 'iidKey' ) ? $this->get_args ( 'iidKey' ) : "";
  3251. Doo::loadModel ( 'invoice' );
  3252. $invoice = new invoice ();
  3253. Doo::loadModel ( 'invoiceReceivables' );
  3254. $invoiceReceivables = new invoiceReceivables ();
  3255. Doo::loadClass ( 'XDeode' );
  3256. $XDeode = new XDeode ( 5 );
  3257. if (! empty ( $receivablesPrice ) && ! empty ( $iidKey )) {
  3258. $iidKey = $XDeode->decode ( $iidKey );
  3259. $info = $invoice->getInvoiceByIid ( $iidKey );
  3260. $irList = $invoiceReceivables->getInvoiceReceivablesInIridString ( $info ['irid'] );
  3261. if (empty ( $irList ))
  3262. $irList [0] ['sumPrice'] = 0;
  3263. $balance = $info ['invoicePrice'] - $irList [0] ['sumPrice'];
  3264. if ($balance < $receivablesPrice) {
  3265. echo json_encode ( array (
  3266. 'error' => '收款金额超过开票金额。'
  3267. ) );
  3268. die ();
  3269. }
  3270. if ($balance > $receivablesPrice) {
  3271. echo json_encode ( array (
  3272. 'error' => '收款金额低于开票金额。'
  3273. ) );
  3274. die ();
  3275. }
  3276. }
  3277. }
  3278. /**
  3279. * 旧输入导入
  3280. */
  3281. function importInvoice() {
  3282. $emsg = isset ( $this->params ['emsg'] ) ? $this->params ['emsg'] : "";
  3283. $data ['emsg'] = "";
  3284. if ($emsg != "")
  3285. $data ['emsg'] = "请填写完整的数据";
  3286. $data ['time'] = time ();
  3287. $this->render ( "/admin/invoiceImport", $data );
  3288. }
  3289. function uploadInvoice() {
  3290. // move_uploaded_file($_FILES['Filedata']['tmp_name'], "/upload/".$_FILES['Filedata']['name']);
  3291. if (isset ( $_FILES ['Filedata'] ['name'] )) {
  3292. $file = $_FILES ['Filedata'] ['tmp_name'];
  3293. $error = false;
  3294. if (! is_uploaded_file ( $file )) {
  3295. $error = '400 Bad Request';
  3296. }
  3297. if ($error) {
  3298. header ( 'HTTP/1.0 ' . $error );
  3299. die ( 'Error ' . $error );
  3300. } else {
  3301. include (DOO::conf ()->SITE_PATH . 'protected/plugin/io.han.php');
  3302. $this->IoHandler = new IoHandler ();
  3303. $pics = explode ( '.', $_FILES ['Filedata'] ['name'] );
  3304. // $filedir=$_POST['time'];
  3305. // 调用定义物理路径
  3306. $t = DOO::conf ()->SITE_PATH . "upload/invoice/";
  3307. $this->IoHandler->MakeDir ( $t );
  3308. $filename = $this->_GetFileEXT ( $_FILES ['Filedata'] ['name'] );
  3309. if ($filename != 'xlsx')
  3310. return "";
  3311. // $upload_dir = $t."/".time().rand(10,100).".".$filename;
  3312. $upload_file = iconv ( "UTF-8", "GB2312", $_FILES ["Filedata"] ["name"] );
  3313. $upload_dir = $t . "/" . $upload_file;
  3314. $k = move_uploaded_file ( $file, $upload_dir );
  3315. if ($k) {
  3316. $m = round ( $_FILES ['Filedata'] ['size'] / 1024 / 1024, 2 );
  3317. echo $pics [0] . "." . $filename . "#" . $m . "#" . $_FILES ['Filedata'] ['size'];
  3318. }
  3319. }
  3320. }
  3321. }
  3322. function importInvoiceDo() {
  3323. $path = $this->get_args ( 'path' ) ? $this->get_args ( 'path' ) : "";
  3324. if ($path != "") {
  3325. Doo::loadModel ( 'invoice' );
  3326. Doo::loadModel ( 'staff' );
  3327. $staff = new staff ();
  3328. Doo::loadModel ( 'invoiceStatistics' );
  3329. Doo::loadModel ( 'invoiceOperationLog' );
  3330. echo DOO::conf ()->SITE_PATH . "upload/invoice/" . iconv ( "UTF-8", "GB2312", $path );
  3331. $exlArray = $this->_format_excel_to_array ( DOO::conf ()->SITE_PATH . "upload/invoice/" . $path );
  3332. // print_r ( $exlArray );
  3333. // die ();
  3334. // echo json_encode($exlArray);die;
  3335. foreach ( $exlArray as $key => $value ) {
  3336. // 开票
  3337. $invoice = new invoice ();
  3338. $invoice->invoiceNo = $value ['invoiceNo'];
  3339. $invoice->invoiceType = 0;
  3340. if ($value ['invoiceType'] == '专')
  3341. $invoice->invoiceType = 1;
  3342. $invoice->invoicePrice = $value ['invoicePrice'];
  3343. $invoice->invoiceQuantity = 1;
  3344. $invoice->invoiceUnitPrice = $value ['invoicePrice'];
  3345. $invoice->invoiceTitle = $value ['invoiceTitle'];
  3346. if ($value ['invoiceType'] == '专')
  3347. $invoice->invoiceCompany = $value ['invoiceTitle'];
  3348. $invoice->userName = $value ['userName'];
  3349. $sDetail = $staff->getStaffByName ( $value ['userName'] );
  3350. $invoice->sid = $sDetail ['sid'];
  3351. $invoice->cid = $sDetail ['cid'];
  3352. $invoice->categoryName = $sDetail ['category'];
  3353. $invoice->invoiceElement = $value ['invoiceElement'];
  3354. $invoice->remark = $value ['remark'];
  3355. $invoice->date = $value ['date'];
  3356. $invoice->printTime = $value ['date'];
  3357. $invoice->ipSource=1;
  3358. $invoice->printStatus = 1;
  3359. $invoice->status = 2;
  3360. $invoice->postStatus = 1;
  3361. $invoice->untreadStatus = 0;
  3362. $invoice->invoiceSerial = "#F" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  3363. $iid=$invoice->insert ();
  3364. // 汇总
  3365. $invoiceStatistics = new invoiceStatistics ();
  3366. //
  3367. $item = array (
  3368. 'date' => $value ['date'],
  3369. 'priceClass' => 1,
  3370. 'cid' => $sDetail ['cid'],
  3371. 'staff' => $sDetail ['sid'],
  3372. 'invoicePrice' => $value ['invoicePrice']
  3373. );
  3374. $invoiceStatistics->setInvoiceStatisticsByCondition ( $item );
  3375. $invoiceOperationLog = new invoiceOperationLog ();
  3376. $item = array (
  3377. 'date' => date ( "Y-m-d H:i:s" ),
  3378. 'operation' => date ( "Y-m-d" )." 导入",
  3379. 'status' => 1,
  3380. 'img' => $sDetail ['avatar'],
  3381. 'username' => $sDetail ['username'],
  3382. 'uid' => $sDetail ['sid'],
  3383. 'category' => $sDetail ['category'],
  3384. 'iid' => $iid
  3385. );
  3386. $invoiceOperationLog->setInvoiceOperationLog ( $item );
  3387. }
  3388. return '/importInvoice?count=' . count ( $exlArray );
  3389. // return "/keyonline";
  3390. }
  3391. echo 'no file';
  3392. }
  3393. function importInvoiceReceivables() {
  3394. $emsg = isset ( $this->params ['emsg'] ) ? $this->params ['emsg'] : "";
  3395. $data ['emsg'] = "";
  3396. if ($emsg != "")
  3397. $data ['emsg'] = "请填写完整的数据";
  3398. $data ['time'] = time ();
  3399. $this->render ( "/admin/invoiceReceivablesImport", $data );
  3400. }
  3401. // 导入入账数据
  3402. function importInvoiceReceivablesDo() {
  3403. $path = $this->get_args ( 'path' ) ? $this->get_args ( 'path' ) : "";
  3404. include Doo::conf ()->BASE_PATH . 'diagnostic/debug.php';
  3405. if ($path != "") {
  3406. Doo::loadModel ( 'invoiceReceivables' );
  3407. Doo::loadModel ( 'invoice' );
  3408. Doo::loadModel ( 'staff' );
  3409. $staff = new staff ();
  3410. Doo::loadModel ( 'invoiceStatistics' );
  3411. // echo DOO::conf ()->SITE_PATH . "upload/invoice/" . iconv ( "UTF-8", "GB2312", $path );
  3412. $exlArray = $this->_format_excel_to_array ( DOO::conf ()->SITE_PATH . "upload/invoice/" . iconv ( "UTF-8", "GB2312", $path ), 'invoiceReceivables' );
  3413. // print_r ( $exlArray );
  3414. // die ();
  3415. // echo json_encode($exlArray);die;
  3416. foreach ( $exlArray as $key => $value ) {
  3417. // 收款
  3418. $invoiceReceivables = new invoiceReceivables ();
  3419. $invoice = new invoice ();
  3420. $invoiceReceivables->bindStatus = 1;
  3421. $invoiceReceivables->receivablesPrice = $value ['receivablesPrice'];
  3422. $invoiceReceivables->receivablesMessage = $value ['receivablesMessage'];
  3423. $invoiceReceivables->receivablesBank = $value ['receivablesBank'];
  3424. $invoiceReceivables->receivablesDate = $value ['receivablesDate'];
  3425. $sDetail = $staff->getStaffByName ( $value ['receivablesStaff'] );
  3426. $invoiceReceivables->receivablesCategory = $sDetail ['cid'] . ':' . $sDetail ['category'];
  3427. $invoiceReceivables->receivablesStaff = $sDetail ['sid'] . '-' . $sDetail ['username'];
  3428. $invoiceReceivables->receivablesSerial = "#SK" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  3429. $invoiceReceivables->sourcePrice = $value ['sourcePrice'];
  3430. $iDetail = $invoice->getInvoiceByInvoiceNo ( $value ['invoiceNo'] );
  3431. $invoiceReceivables->iid = $iDetail ['iid'];
  3432. $irid = $invoiceReceivables->insert ();
  3433. // 发票绑定收款
  3434. $detail = $iDetail;
  3435. $iridString = "";
  3436. if (empty ( $detail ['irid'] ))
  3437. $iridString = $irid;
  3438. else
  3439. $iridString = $detail ['irid'] . ',' . $irid;
  3440. $item = array (
  3441. 'irid' => $iridString,
  3442. 'iid' => $detail ['iid']
  3443. );
  3444. $invoice->setInvoiceByCondition ( $item );
  3445. // 汇总
  3446. $invoiceStatistics = new invoiceStatistics ();
  3447. // 扣除入账统计金额
  3448. $item = array (
  3449. 'date' => $value ['receivablesDate'],
  3450. 'priceClass' => 3,
  3451. 'cid' => $sDetail ['cid'],
  3452. 'staff' => $sDetail ['sid'],
  3453. //'irid' => $irid,
  3454. 'accountPrice' => $value ['receivablesPrice']
  3455. );
  3456. $invoiceStatistics->setInvoiceStatisticsByCondition ( $item );
  3457. }
  3458. return '/importInvoiceReceivables?count=' . count ( $exlArray );
  3459. echo 'data count ' . count ( $exlArray );
  3460. die ();
  3461. // return "/keyonline";
  3462. }
  3463. echo 'no file';
  3464. }
  3465. /**
  3466. * 格式化excel文件为数组
  3467. * @param unknown_type $file_url
  3468. * @param unknown_type $mcid
  3469. */
  3470. function _format_excel_to_array($file_url = "", $sType = "") {
  3471. if (! file_exists ( $file_url )) {
  3472. return array ();
  3473. }
  3474. Doo::loadClass ( 'PHPExcel' );
  3475. $PHPExcel = new PHPExcel ();
  3476. $PHPReader = new PHPExcel_Reader_Excel2007 ();
  3477. if (! $PHPReader->canRead ( $file_url )) {
  3478. $PHPReader = new PHPExcel_Reader_Excel5 ();
  3479. if (! $PHPReader->canRead ( $file_url )) {
  3480. echo 'no Excel';
  3481. return;
  3482. }
  3483. }
  3484. $PHPExcel = $PHPReader->load ( $file_url );
  3485. /* * 读取excel文件中的第一个工作表 */
  3486. $currentSheet = $PHPExcel->getSheet ( 0 );
  3487. /* * 取得最大的列号 */
  3488. $allColumn = $currentSheet->getHighestColumn ();
  3489. /* * 取得一共有多少行 */
  3490. $allRow = $currentSheet->getHighestRow ();
  3491. $excel_array = array ();
  3492. $conk = 2;
  3493. for($currentRow = $conk; $currentRow <= $allRow; $currentRow ++) {
  3494. $excel_column = array ();
  3495. // 后期改进
  3496. if ($allColumn == 'AM')
  3497. $allColumn = 'Z';
  3498. /* * 从第A列开始输出 */
  3499. for($currentColumn = 'A'; $currentColumn <= $allColumn; $currentColumn ++) {
  3500. $val = $currentSheet->getCellByColumnAndRow ( ord ( $currentColumn ) - 65, $currentRow )->getValue ();
  3501. if ($val instanceof PHPExcel_RichText)
  3502. $val = $val->__toString ();
  3503. /* * ord()将字符转为十进制数 iconv ( 'utf-8', 'gb2312', */
  3504. // $val = "'" . addslashes ( $val ) . "'";
  3505. if ($sType == 'invoiceReceivables') {
  3506. if ($currentColumn == 'A')
  3507. $excel_column ['invoiceNo'] = $val;
  3508. elseif ($currentColumn == 'B')
  3509. $excel_column ['receivablesPrice'] = $val;
  3510. elseif ($currentColumn == 'C') {
  3511. $excel_column ['receivablesMessage'] = $val;
  3512. } elseif ($currentColumn == 'D') {
  3513. $excel_column ['receivablesBank'] = $val;
  3514. } elseif ($currentColumn == 'E') {
  3515. $excel_column ['receivablesDate'] = $this->excelTime ( $val );
  3516. } elseif ($currentColumn == 'F') {
  3517. $excel_column ['receivablesStaff'] = $val;
  3518. } elseif ($currentColumn == 'G') {
  3519. $excel_column ['sourcePrice'] = $val;
  3520. }
  3521. } else {
  3522. if ($currentColumn == 'A')
  3523. $excel_column ['invoiceNo'] = $val;
  3524. elseif ($currentColumn == 'B')
  3525. $excel_column ['invoiceType'] = $val;
  3526. elseif ($currentColumn == 'C') {
  3527. $excel_column ['invoicePrice'] = $val;
  3528. } elseif ($currentColumn == 'D') {
  3529. $excel_column ['invoiceTitle'] = $val;
  3530. } elseif ($currentColumn == 'E') {
  3531. $excel_column ['userName'] = $val;
  3532. } elseif ($currentColumn == 'F') {
  3533. $excel_column ['categoryName'] = $val;
  3534. } elseif ($currentColumn == 'G') {
  3535. $excel_column ['invoiceElement'] = $val;
  3536. } elseif ($currentColumn == 'H') {
  3537. $excel_column ['remark'] = $val;
  3538. } elseif ($currentColumn == 'I') {
  3539. $excel_column ['date'] = $this->excelTime ( $val );
  3540. }
  3541. }
  3542. }
  3543. array_push ( $excel_array, $excel_column );
  3544. }
  3545. return $excel_array;
  3546. }
  3547. function excelTime($date, $time = false) {
  3548. if (function_exists ( 'GregorianToJD' )) {
  3549. if (is_numeric ( $date )) {
  3550. $jd = GregorianToJD ( 1, 1, 1970 );
  3551. $gregorian = JDToGregorian ( $jd + intval ( $date ) - 25569 );
  3552. $date = explode ( '/', $gregorian );
  3553. $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" : '');
  3554. return $date_str;
  3555. }
  3556. } else {
  3557. $date = $date > 25568 ? $date + 1 : 25569;
  3558. /* There was a bug if Converting date before 1-1-1970 (tstamp 0) */
  3559. $ofs = (70 * 365 + 17 + 2) * 86400;
  3560. $date = date ( "Y-m-d", ($date * 86400) - $ofs ) . ($time ? " 00:00:00" : '');
  3561. }
  3562. return $date;
  3563. }
  3564. /**
  3565. * 旧输入导入
  3566. */
  3567. function _GetFileEXT($filename) {
  3568. $pics = explode ( '.', $filename );
  3569. $num = count ( $pics );
  3570. return $pics [$num - 1];
  3571. }
  3572. function showCache($path = "") {
  3573. // if (file_exists ( $path )) {
  3574. // $htm = file_get_contents ( $path );
  3575. // } else {
  3576. Doo::loadModel ( 'invoiceStatistics' );
  3577. $invoiceStatistics = new invoiceStatistics ();
  3578. $isBriefly = $invoiceStatistics->getBrieflyStatistics ();
  3579. $htm = '<tr><th class="taC">' . $isBriefly ['statisticsMonth'] [0] ['month'] . '月累计开票</th>
  3580. <td>¥' . $isBriefly ['statisticsMonth'] [0] ['invoicePrice'] . '</td>
  3581. <th class="taC">' . $isBriefly ['statisticsMonth'] [0] ['month'] . '月累计入账</th>
  3582. <td>¥' . $isBriefly ['statisticsMonth'] [0] ['accountPrice'] . '</td></tr>';
  3583. /*
  3584. * '<tr><th class="taC">今年累计开票</th><td>¥' . $isBriefly ['statisticsYear'] [0] ['invoicePrice'] . '</td> <th class="taC">今年累计入账</th><td>¥' . $isBriefly ['statisticsYear'] [0] ['accountPrice'] . '</td></tr>';
  3585. */
  3586. file_put_contents ( $path, $htm, FILE_APPEND );
  3587. // }
  3588. return $htm;
  3589. }
  3590. /**
  3591. * 获取get或者POST值
  3592. *
  3593. * @param string $name 属性名称
  3594. * @return fixed 值
  3595. */
  3596. function get_args($name) {
  3597. if (isset ( $_GET [$name] )) {
  3598. if (is_array ( $_GET [$name] ))
  3599. return $_GET [$name];
  3600. else
  3601. return addslashes ( $_GET [$name] );
  3602. } elseif (isset ( $_POST [$name] )) {
  3603. if (is_array ( $_POST [$name] ))
  3604. return $_POST [$name];
  3605. else
  3606. return addslashes ( $_POST [$name] );
  3607. } else
  3608. return false;
  3609. }
  3610. function SafeFilter(&$arr) {
  3611. $ra = Array (
  3612. '/([\x00-\x08,\x0b-\x0c,\x0e-\x19])/',
  3613. '/script/',
  3614. '/javascript/',
  3615. '/vbscript/',
  3616. '/expression/',
  3617. '/applet/',
  3618. '/meta/',
  3619. '/xml/',
  3620. '/blink/',
  3621. '/link/',
  3622. '/style/',
  3623. '/embed/',
  3624. '/object/',
  3625. '/frame/',
  3626. '/layer/',
  3627. '/title/',
  3628. '/bgsound/',
  3629. '/base/',
  3630. '/onload/',
  3631. '/onunload/',
  3632. '/onchange/',
  3633. '/onsubmit/',
  3634. '/onreset/',
  3635. '/onselect/',
  3636. '/onblur/',
  3637. '/onfocus/',
  3638. '/onabort/',
  3639. '/onkeydown/',
  3640. '/onkeypress/',
  3641. '/onkeyup/',
  3642. '/onclick/',
  3643. '/ondblclick/',
  3644. '/onmousedown/',
  3645. '/onmousemove/',
  3646. '/onmouseout/',
  3647. '/onmouseover/',
  3648. '/onmouseup/',
  3649. '/onunload/'
  3650. );
  3651. if (is_array ( $arr )) {
  3652. foreach ( $arr as $key => $value ) {
  3653. if (! is_array ( $value )) {
  3654. if (! get_magic_quotes_gpc ()) // 不对magic_quotes_gpc转义过的字符使用addslashes(),避免双重转义。
  3655. {
  3656. $value = addslashes ( $value ); // 给单引号(')、双引号(")、反斜线(\)与 NUL(NULL 字符)加上反斜线转义
  3657. }
  3658. $value = preg_replace ( $ra, '', $value ); // 删除非打印字符,粗暴式过滤xss可疑字符串
  3659. $arr [$key] = htmlentities ( strip_tags ( $value ) ); // 去除 HTML 和 PHP 标记并转换为 HTML 实体
  3660. } else {
  3661. SafeFilter ( $arr [$key] );
  3662. }
  3663. }
  3664. }
  3665. }
  3666. /**
  3667. * Escape String
  3668. *
  3669. * @access public
  3670. * @param string
  3671. * @param bool whether or not the string will be used in a LIKE condition
  3672. * @return string
  3673. */
  3674. function escape_str($str, $like = FALSE) {
  3675. if (is_array ( $str )) {
  3676. foreach ( $str as $key => $val ) {
  3677. $str [$key] = $this->escape_str ( $val, $like );
  3678. }
  3679. return $str;
  3680. }
  3681. var_dump ( Doo::db ()->getDbObject () );
  3682. die ();
  3683. if (function_exists ( 'mysql_real_escape_string' ) and is_resource ( Doo::db ()->getDbObject () )) { // Doo::db ()->getDbObject()
  3684. $str = mysql_real_escape_string ( $str, Doo::db ()->getDbObject () );
  3685. } elseif (function_exists ( 'mysql_escape_string' )) {
  3686. $str = mysql_escape_string ( $str );
  3687. } else {
  3688. $str = addslashes ( $str );
  3689. }
  3690. // escape LIKE condition wildcards
  3691. if ($like === TRUE) {
  3692. $str = str_replace ( array (
  3693. '%',
  3694. '_'
  3695. ), array (
  3696. '\\%',
  3697. '\\_'
  3698. ), $str );
  3699. }
  3700. return $str;
  3701. }
  3702. /**
  3703. * 获得分页数据
  3704. * @param unknown_type $table
  3705. * @param unknown_type $condition
  3706. * @param unknown_type $on_page
  3707. * @param unknown_type $page_size
  3708. */
  3709. function get_page($table = "", $condition = "", $on_page = 1, $page_size = 20, $action = "", $get = "", $other = "page") {
  3710. $page_c = "";
  3711. $page ['previous'] = $this->get_previous ( $on_page );
  3712. $page ['on_page'] = $on_page;
  3713. $total_count = $this->get_table_count ( $table, $condition );
  3714. $total = intval ( $total_count / $page_size );
  3715. $page ['total_page'] = ($total_count % $page_size) == 0 ? $total : $total + 1;
  3716. $page ['total_data'] = $total_count;
  3717. $page ['next'] = $on_page == $page ['total_page'] ? $page ['total_page'] : $on_page + 1;
  3718. $i = 1;
  3719. $page_max = 1;
  3720. $page_width = 3;
  3721. if ($on_page >= $page_width) {
  3722. $page_max = intval ( $on_page / $page_width ) + 1;
  3723. $i = intval ( $on_page / $page_width ) * $page_width - 1;
  3724. }
  3725. for(; $i <= $page ['total_page']; $i ++) {
  3726. if ($i == $on_page)
  3727. $page_c .= '<li class="active"><a href="javascript:void(0)">' . $i . '</a></li>';
  3728. else
  3729. $page_c .= '<li><a href="/' . $action . '/' . $i . $get . '">' . $i . '</a></li>';
  3730. if ($i == ($page_width * $page_max))
  3731. break;
  3732. }
  3733. $page ['page'] = $page_c;
  3734. $page ['lower'] = (-- $on_page) * $page_size;
  3735. return $page;
  3736. }
  3737. /**
  3738. * 获取上一页
  3739. * @param unknown_type $on_page
  3740. */
  3741. function get_previous($on_page = 1) {
  3742. return $on_page != 0 ? $on_page - 1 : $on_page;
  3743. }
  3744. /**
  3745. * 获取总页数
  3746. * @param unknown_type $table
  3747. * @param unknown_type $condition
  3748. */
  3749. public function get_table_count($table = "", $condition = "") {
  3750. // $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  3751. $sql = "select count(*) as count from " . $table . " where " . $condition;
  3752. // echo $sql;die;
  3753. $query = Doo::db ()->query ( $sql );
  3754. $result = $query->fetch ();
  3755. return $result ['count'];
  3756. }
  3757. function isInvoiceNew($type = "GLOBAL") {
  3758. Doo::loadModel ( 'invoice' );
  3759. $invoice = new invoice ();
  3760. Doo::loadModel ( 'invoiceReceivables' );
  3761. $invoiceReceivables = new invoiceReceivables ();
  3762. Doo::loadModel ( 'staff' );
  3763. $staff = new staff ();
  3764. $st = $staff->getUserByIdList ( $_COOKIE ["staff"] );
  3765. // 我的发票待处理
  3766. $pendingInvoice = $invoice->getOne ( array ( // or (status=2 and printStatus=1 and untreadStatus=0 ) or (status=2 and printStatus=1 and untreadStatus=2 )
  3767. 'where' => "(status=3 or status=4) and isDelete=0 and sid=" . $st [0] ['sid'],
  3768. 'desc' => 'iid',
  3769. 'asArray' => TRUE
  3770. ) );
  3771. // 我的收款待入账
  3772. /*
  3773. * $myClaim = $invoiceReceivables->getOne ( array ( 'where' => " receivablesStaff like '" . $st [0] ['sid'] . "-%' and receivablesCategory like '" . $st [0] ['cid'] . ":%' and bindStatus=0", 'desc' => 'irid', 'asArray' => TRUE ) );
  3774. */
  3775. // 发票审批
  3776. $approval = $invoice->getOne ( array (
  3777. 'where' => 'status=1 and pendingApprovals=' . $st [0] ['sid'],
  3778. 'desc' => 'iid',
  3779. 'asArray' => true
  3780. ) );
  3781. // 发票邮寄
  3782. $post = $invoice->getOne ( array (
  3783. 'where' => "postStatus=0 and printStatus=1 and isDelete=0 and doPost=1 and status=2",
  3784. 'asArray' => TRUE
  3785. ) );
  3786. // 发票打印
  3787. $print = $invoice->getOne ( array (
  3788. 'where' => "status=2 and printStatus=0 and untreadStatus=0 and moldManage like '%[\"" . $st [0] ['sid'] . "\",%'",
  3789. 'desc' => 'iid',
  3790. 'asArray' => TRUE
  3791. ) );
  3792. // 发票退票 printStatus=1 and
  3793. $untread = $invoice->getOne ( array (
  3794. 'where' => " untreadStatus=1 and status=2 ",
  3795. 'asArray' => TRUE
  3796. ) );
  3797. $new = array (
  3798. 'GLOBAL' => FALSE,
  3799. 'pendingInvoice' => FALSE,
  3800. // 'myClaim' => FALSE,
  3801. 'approval' => FALSE,
  3802. 'post' => FALSE,
  3803. 'print' => FALSE,
  3804. 'untread' => FALSE
  3805. );
  3806. // || ! empty ( $myClaim )
  3807. if (! empty ( $pendingInvoice ) || ! empty ( $approval ) || ! empty ( $post ) || ! empty ( $print ) || ! empty ( $untread ))
  3808. $new ['GLOBAL'] = TRUE;
  3809. if (! empty ( $pendingInvoice ))
  3810. $new ['pendingInvoice'] = TRUE;
  3811. // if (! empty ( $myClaim ))
  3812. // $new ['myClaim'] = TRUE;
  3813. if (! empty ( $approval ))
  3814. $new ['approval'] = TRUE;
  3815. if (! empty ( $post ))
  3816. $new ['post'] = TRUE;
  3817. if (! empty ( $print ))
  3818. $new ['print'] = TRUE;
  3819. if (! empty ( $untread ))
  3820. $new ['untread'] = TRUE;
  3821. return $new;
  3822. }
  3823. function setWXMsg($rid, $typeMsg = '') {
  3824. Doo::loadModel ( 'invoice' );
  3825. $invoice = new invoice ();
  3826. $invoiceDetail = $invoice->getOne ( array (
  3827. 'where' => 'iid=' . $rid,
  3828. 'asArray' => true
  3829. ) );
  3830. if (! empty ( $invoiceDetail )) {
  3831. Doo::loadModel ( 'staff' );
  3832. $staff = new staff ();
  3833. $staffmsg = $staff->getOne ( array (
  3834. 'where' => "sid='" . $invoiceDetail ['sid'] . "'",
  3835. 'asArray' => TRUE
  3836. ) );
  3837. if (! empty ( $staffmsg ['wxid'] )) {
  3838. require_once (SITE_PATH . '/protected/class/client.php');
  3839. $client = new client ( 'http://m.cld.smartcost.com.cn/' );
  3840. $user = $staffmsg ['wxid'];
  3841. $expCom = explode ( ":", $invoiceDetail ['expressCompany'] );
  3842. if (empty ( $expCom ))
  3843. $expCom [0] = '';
  3844. $msg = "";
  3845. if (empty ( $typeMsg ))
  3846. $msg = '太好了,您的发票' . $invoiceDetail ['invoiceSerial'] . ' 已邮寄 ' . $expCom [0] . ' ,快递号: <a href="https://m.kuaidi100.com/result.jsp?nu=' . $invoiceDetail ['expressNumber'] . '" >' . $invoiceDetail ['expressNumber'] . '</a>';
  3847. elseif ($typeMsg == "PRINT")
  3848. $msg = '太好了,您的发票已打印完成。';
  3849. $result = $client->SendMsg ( $user, $msg, 'text' );
  3850. }
  3851. }
  3852. }
  3853. function getToparty($category = '') {
  3854. $token = $this->getAccessToken (); //
  3855. $result = json_decode ( $this->httpGet ( "https://qyapi.weixin.qq.com/cgi-bin/department/list?access_token={$token}&id=5" ), true );
  3856. $toparty = 0;
  3857. foreach ( $result ['department'] as $key => $value ) {
  3858. if ($value ['name'] == $category)
  3859. $toparty = $value ['id'];
  3860. }
  3861. return $toparty;
  3862. }
  3863. function msgSendToparty($msg, $title, $url, $toparty, $text = '') {
  3864. $token = $this->getAccessToken ();
  3865. if ($text == 'text') {
  3866. $data = '{
  3867. "touser": "",
  3868. "toparty": "' . $toparty . '",
  3869. "totag": "",
  3870. "msgtype": "text",
  3871. "agentid": 1000002,
  3872. "text": {
  3873. "content": "' . $msg . '"
  3874. },
  3875. "safe":0
  3876. }';
  3877. }
  3878. $result = json_decode ( $this->httpPOST ( "https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token={$token}", $data ) );
  3879. if ($result->errmsg != 'ok') {
  3880. return 0;
  3881. } else {
  3882. return 1;
  3883. }
  3884. }
  3885. private function msgSend($msg, $title, $url, $user, $text = '') {
  3886. $token = $this->getAccessToken ();
  3887. if ($text == 'text') {
  3888. $data = '{
  3889. "touser": "' . $user . '",
  3890. "toparty": "",
  3891. "totag": "",
  3892. "msgtype": "text",
  3893. "agentid": 1000002,
  3894. "text": {
  3895. "content": "' . $msg . '"
  3896. },
  3897. "safe":0
  3898. }';
  3899. } else {
  3900. $data = '{
  3901. "touser": "' . $user . '",
  3902. "toparty": "",
  3903. "totag": "",
  3904. "msgtype": "news",
  3905. "agentid": 1000002,
  3906. "news": {
  3907. "articles":[
  3908. {
  3909. "title": "' . $title . '",
  3910. "description": "' . $msg . '",
  3911. "url": "' . $url . '",
  3912. "picurl": ""
  3913. }
  3914. ]
  3915. }
  3916. }';
  3917. }
  3918. $result = json_decode ( $this->httpPOST ( "https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token={$token}", $data ) );
  3919. if ($result->errmsg != 'ok') {
  3920. return 0;
  3921. } else {
  3922. return 1;
  3923. }
  3924. }
  3925. private function getAccessToken() {
  3926. // access_token 应该全局存储与更新,以下代码以写入到文件中做示例
  3927. // $file = './access_token.txt';
  3928. // $data = json_decode ( file_get_contents ( $file ) );
  3929. // if ($data->expire_time < time () or ! $data->expire_time) {
  3930. // 如果是企业号用以下URL获取access_token
  3931. $url = "https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=$this->appId&corpsecret=$this->appSecret";
  3932. // $url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=$this->appId&secret=$this->appSecret";
  3933. $res = json_decode ( $this->httpGet ( $url ) );
  3934. $access_token = $res->access_token;
  3935. // echo $access_token;
  3936. // if ($access_token) {
  3937. // $data->expire_time = time () + 7000;
  3938. // $data->access_token = $access_token;
  3939. // $fp = fopen ( $file, "w" );
  3940. // fwrite ( $fp, json_encode ( $data ) );
  3941. // fclose ( $fp );
  3942. // }
  3943. // } else {
  3944. // $access_token = $data->access_token;
  3945. // }
  3946. return $access_token;
  3947. }
  3948. private function httpGet($url) {
  3949. $curl = curl_init ();
  3950. curl_setopt ( $curl, CURLOPT_RETURNTRANSFER, true );
  3951. curl_setopt ( $curl, CURLOPT_TIMEOUT, 500 );
  3952. // 为保证第三方服务器与微信服务器之间数据传输的安全性,所有微信接口采用https方式调用,必须使用下面2行代码打开ssl安全校验。
  3953. // 如果在部署过程中代码在此处验证失败,请到 http://curl.haxx.se/ca/cacert.pem 下载新的证书判别文件。
  3954. curl_setopt ( $curl, CURLOPT_SSL_VERIFYPEER, true );
  3955. curl_setopt ( $curl, CURLOPT_SSL_VERIFYHOST, false );
  3956. curl_setopt ( $curl, CURLOPT_URL, $url );
  3957. $res = curl_exec ( $curl );
  3958. curl_close ( $curl );
  3959. return $res;
  3960. }
  3961. private function httpPost($url, $data) {
  3962. $curl = curl_init ();
  3963. curl_setopt ( $curl, CURLOPT_RETURNTRANSFER, true );
  3964. curl_setopt ( $curl, CURLOPT_TIMEOUT, 500 );
  3965. // 为保证第三方服务器与微信服务器之间数据传输的安全性,所有微信接口采用https方式调用,必须使用下面2行代码打开ssl安全校验。
  3966. // 如果在部署过程中代码在此处验证失败,请到 http://curl.haxx.se/ca/cacert.pem 下载新的证书判别文件。
  3967. curl_setopt ( $curl, CURLOPT_SSL_VERIFYPEER, true );
  3968. curl_setopt ( $curl, CURLOPT_SSL_VERIFYHOST, false );
  3969. curl_setopt ( $curl, CURLOPT_URL, $url );
  3970. curl_setopt ( $curl, CURLOPT_POST, 1 );
  3971. curl_setopt ( $curl, CURLOPT_POSTFIELDS, $data );
  3972. $res = curl_exec ( $curl );
  3973. curl_close ( $curl );
  3974. return $res;
  3975. }
  3976. }
  3977. ?>