InvoiceController.php 129 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725
  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. public function beforeRun($resource, $action) {
  17. Doo::loadModel ( "invoiceManage" );
  18. $invoiceManage = new invoiceManage ();
  19. Doo::loadClass ( 'XDeode' );
  20. $XDeode = new XDeode ( 5 );
  21. $sid = $XDeode->decode ( $_COOKIE ["staff"] );
  22. header ( 'Content-Type:text/html;charset=utf-8' );
  23. $moldList = $invoiceManage->getInvoiceByStaff ( $sid );
  24. if (empty ( $moldList )) {
  25. $flag = false;
  26. $uGroups = 'ordinary';
  27. if (Doo::acl ()->isAllowed ( $uGroups, $resource, $action )) {
  28. $flag = true;
  29. }
  30. } else {
  31. $flag = false;
  32. array_push ( $moldList, array (
  33. 'mold' => 'ordinary'
  34. ) );
  35. foreach ( $moldList as $value ) {
  36. // echo $value['mold'];
  37. // echo $action;
  38. if (Doo::acl ()->isAllowed ( $value ['mold'], $resource, $action )) {
  39. $flag = true;
  40. break;
  41. }
  42. }
  43. }
  44. /*
  45. * Doo::acl()->isAllowed($uGroups['groups'], $resource, $action);
  46. */
  47. // var_dump($flag) ;
  48. if (! $flag)
  49. die ( 'illegal request' );
  50. }
  51. function __construct() {
  52. if (isset ( $_COOKIE ["staff"] )) {
  53. if (! empty ( $_COOKIE ["staff"] )) {
  54. Doo::loadModel ( 'staff' );
  55. $staff = new staff ();
  56. $uriPartsOrig = explode ( '/', $_SERVER ['REQUEST_URI'] );
  57. $this->ACTION = $uriPartsOrig [1];
  58. $this->data ['new'] = $this->isInvoiceNew ();
  59. $this->staff = $staff->getUserByIdList ( $_COOKIE ["staff"] );
  60. return "/";
  61. }
  62. }
  63. Doo::loadCore ( 'uri/DooUriRouter' );
  64. $router = new DooUriRouter ();
  65. $routeRs = $router->execute ( Doo::app ()->route, Doo::conf ()->SUBFOLDER );
  66. if ($routeRs ['1'] != "login") {
  67. header ( 'Content-Type:text/html;charset=utf-8' );
  68. @header ( "Location: /login" );
  69. }
  70. }
  71. function invoice() {
  72. Doo::loadModel ( 'invoice' );
  73. $invoice = new invoice ();
  74. Doo::loadModel ( 'express' );
  75. $express = new express ();
  76. Doo::loadModel ( 'invoiceReceivables' );
  77. $invoiceReceivables = new invoiceReceivables ();
  78. Doo::loadModel ( 'invoiceStatistics' );
  79. $invoiceStatistics = new invoiceStatistics ();
  80. $isMonth = $invoiceStatistics->getStatisticsByMonth ();
  81. $year = date ( "Y" );
  82. $tmp_date = date ( "Ym" );
  83. $tmp_year = substr ( $tmp_date, 0, 4 );
  84. $tmp_mon = substr ( $tmp_date, 4, 2 );
  85. $tmp_forwardmonth = mktime ( 0, 0, 0, $tmp_mon - 1, 1, $tmp_year );
  86. $fm_forward_month = date ( "m", $tmp_forwardmonth );
  87. $path = SITE_PATH . $this->INVOICECOLLECTPATH . "invoiceCollect_" . $year . "_" . $fm_forward_month . ".htm";
  88. $htm = $this->showCache ( $path );
  89. Doo::loadClass ( 'XDeode' );
  90. $XDeode = new XDeode ( 5 );
  91. $sid = $XDeode->decode ( $_COOKIE ["staff"] );
  92. $expressList = $express->getExpressByAll ();
  93. $invoiceList = $invoice->getMyInvoice ( $sid );
  94. // $list = $invoiceReceivables->getInvoiceReceivablesByClaim ( $this->staff [0] ['cid'], $this->staff [0] ['sid'] );
  95. $sql = 'status=2 and untreadStatus=3 and sid=' . $sid;
  96. $list = $invoice->getInvoiceByUntreadStatusPage ( 4, $sql );
  97. // print_r($list);
  98. $this->data ['isMonth'] = $isMonth;
  99. $this->data ['htm'] = $htm;
  100. $this->data ['expressList'] = $expressList;
  101. $this->data ['invoiceList'] = $invoiceList;
  102. $this->data ['receivablesList'] = $list;
  103. $this->data ['memu'] = "invoice";
  104. $this->data ['staff'] = $this->staff;
  105. $this->data ['receiptMemu'] = 'invoice';
  106. $this->render ( "/admin/invoice", $this->data );
  107. }
  108. function invoiceAdd() {
  109. Doo::loadModel ( 'L_category' );
  110. $lCategory = new L_category ();
  111. $category = $lCategory->find ( array (
  112. 'asArray' => true
  113. ) );
  114. $this->data ['category'] = $category;
  115. $this->data ['memu'] = "invoice";
  116. $this->data ['staff'] = $this->staff;
  117. $this->data ['receiptMemu'] = 'invoice';
  118. $this->render ( "/admin/invoiceAdd", $this->data );
  119. }
  120. /**
  121. * 提交一份开票申请,并记录下操作日志
  122. *
  123. * @since 1.0.0
  124. * @var integer cid 办事处ID
  125. * @var integer invoiceType 发票类型
  126. * @var integer doPost 是否邮寄
  127. * @var integer invoicePrice 开票金额
  128. * @var string invoiceElement 开票内容
  129. * @var string invoiceTitle 发票抬头
  130. * @var string invoiceCompany 单位名称
  131. * @var string TIN 纳税人识别码
  132. * @var string address 注册地址
  133. * @var string phone 注册电话
  134. * @var string bank 开户银行
  135. * @var string bankAccount 银行账户
  136. * @var string recipients 收件人
  137. * @var string recipientsPhone 收件人手机/电话
  138. * @var string recipientsAddress 收件地址
  139. * @var string mailItems 邮寄物品
  140. * @var string remark 备注
  141. * @return string 返回跳转开票主页路径
  142. */
  143. function invoiceAddDo() {
  144. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  145. $invoiceType = $this->get_args ( 'invoiceType' ) && is_numeric ( $this->get_args ( 'invoiceType' ) ) ? $this->get_args ( 'invoiceType' ) : 0;
  146. $doPost = $this->get_args ( 'doPost' ) && is_numeric ( $this->get_args ( 'doPost' ) ) ? $this->get_args ( 'doPost' ) : 0;
  147. $invoicePrice = $this->get_args ( 'invoicePrice' ) ? $this->get_args ( 'invoicePrice' ) : "";
  148. $invoiceElement = $this->get_args ( 'invoiceElement' ) ? $this->get_args ( 'invoiceElement' ) : "";
  149. $invoiceTitle = $this->get_args ( 'invoiceTitle' ) ? $this->get_args ( 'invoiceTitle' ) : "";
  150. $invoiceCompany = $this->get_args ( 'invoiceCompany' ) ? $this->get_args ( 'invoiceCompany' ) : "";
  151. $TIN = $this->get_args ( 'TIN' ) ? $this->get_args ( 'TIN' ) : "";
  152. $address = $this->get_args ( 'address' ) ? $this->get_args ( 'address' ) : "";
  153. $phone = $this->get_args ( 'phone' ) ? $this->get_args ( 'phone' ) : "";
  154. $bank = $this->get_args ( 'bank' ) ? $this->get_args ( 'bank' ) : "";
  155. $bankAccount = $this->get_args ( 'bankAccount' ) ? $this->get_args ( 'bankAccount' ) : "";
  156. $recipients = $this->get_args ( 'recipients' ) ? $this->get_args ( 'recipients' ) : "";
  157. $recipientsPhone = $this->get_args ( 'recipientsPhone' ) ? $this->get_args ( 'recipientsPhone' ) : "";
  158. $recipientsAddress = $this->get_args ( 'recipientsAddress' ) ? $this->get_args ( 'recipientsAddress' ) : "";
  159. $remark = $this->get_args ( 'remark' ) ? $this->get_args ( 'remark' ) : "";
  160. $TINT = $this->get_args ( 'TINT' ) ? $this->get_args ( 'TINT' ) : "";
  161. $addressT = $this->get_args ( 'addressT' ) ? $this->get_args ( 'addressT' ) : "";
  162. $phoneT = $this->get_args ( 'phoneT' ) ? $this->get_args ( 'phoneT' ) : "";
  163. $bankT = $this->get_args ( 'bankT' ) ? $this->get_args ( 'bankT' ) : "";
  164. $bankAccountT = $this->get_args ( 'bankAccountT' ) ? $this->get_args ( 'bankAccountT' ) : "";
  165. $softLock = $this->get_args ( 'softLock' ) ? $this->get_args ( 'softLock' ) : 0;
  166. $softLockNum = $this->get_args ( 'softLockNum' ) ? $this->get_args ( 'softLockNum' ) : 0;
  167. $contract = $this->get_args ( 'contract' ) ? $this->get_args ( 'contract' ) : 0;
  168. $contractNum = $this->get_args ( 'contractNum' ) ? $this->get_args ( 'contractNum' ) : 0;
  169. $instructions = $this->get_args ( 'instructions' ) ? $this->get_args ( 'instructions' ) : 0;
  170. $instructionsNum = $this->get_args ( 'instructionsNum' ) ? $this->get_args ( 'instructionsNum' ) : 0;
  171. $remittance = $this->get_args ( 'remittance' ) ? $this->get_args ( 'remittance' ) : 0;
  172. $mailItems = $this->get_args ( 'mailItems' ) ? $this->get_args ( 'mailItems' ) : "";
  173. // echo $softLock;die;
  174. /*
  175. * $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;
  176. */
  177. if (! empty ( $cid ) && ! empty ( $invoicePrice ) && ! empty ( $invoiceElement )) {
  178. Doo::loadModel ( 'invoice' );
  179. $invoice = new invoice ();
  180. Doo::loadModel ( 'L_category' );
  181. $lCategory = new L_category ();
  182. Doo::loadModel ( 'invoiceManage' );
  183. $invoiceManage = new invoiceManage ();
  184. Doo::loadModel ( 'invoiceOperationLog' );
  185. $invoiceOperationLog = new invoiceOperationLog ();
  186. Doo::loadModel ( 'invoiceStatistics' );
  187. $invoiceStatistics = new invoiceStatistics ();
  188. $categoryDetil = $lCategory->getOne ( array (
  189. 'SELECT' => 'title',
  190. 'where' => 'cid=' . $cid,
  191. 'asArray' => true
  192. ) );
  193. $invoiceManageList = $invoiceManage->getInvoiceByAll ();
  194. $invoiceManageDetail = $invoiceManage->getInvoiceByMold ( "发票审批" );
  195. $moldManage = array ();
  196. foreach ( $invoiceManageList as $key => $value ) {
  197. if ($value ['mold'] == '发票打印')
  198. $moldManage [$value ['mold']] = $value ['staffList'];
  199. elseif ($value ['mold'] == '发票邮寄')
  200. $moldManage [$value ['mold']] = $value ['staffList'];
  201. elseif ($value ['mold'] == '发票退票')
  202. $moldManage [$value ['mold']] = $value ['staffList'];
  203. }
  204. $item = array (
  205. 'cid' => $cid,
  206. 'categoryName' => $categoryDetil ['title'],
  207. 'invoiceElement' => $invoiceElement,
  208. 'invoicePrice' => $invoicePrice,
  209. 'invoiceType' => $invoiceType,
  210. 'doPost' => $doPost,
  211. 'status' => 1,
  212. 'invoiceSerial' => "#F" . date ( "Ymd" ) . mt_rand ( 1000, 9999 ),
  213. 'date' => date ( "Y-m-d H:i:s" ),
  214. 'updateTime' => date ( "Y-m-d H:i:s" ),
  215. 'sid' => $this->staff [0] ['sid'],
  216. 'userName' => $this->staff [0] ['username'],
  217. 'invoiceManage' => $invoiceManageDetail ['staff'],
  218. 'pendingApprovals' => $invoiceManageDetail ['staffList'] [0] [0],
  219. 'moldManage' => json_encode ( $moldManage ),
  220. 'remark' => $remark
  221. );
  222. if ($invoiceType == 0)
  223. $item += array (
  224. 'invoiceTitle' => $invoiceTitle,
  225. 'TIN' => $TINT,
  226. 'address' => $addressT,
  227. 'phone' => $phoneT,
  228. 'bank' => $bankT,
  229. 'bankAccount' => $bankAccountT
  230. );
  231. else {
  232. $item += array (
  233. 'invoiceCompany' => $invoiceCompany,
  234. 'TIN' => $TIN,
  235. 'address' => $address,
  236. 'phone' => $phone,
  237. 'bank' => $bank,
  238. 'bankAccount' => $bankAccount
  239. );
  240. }
  241. if ($doPost == 1) {
  242. $mailList = array (
  243. 'invoice' => 1,
  244. 'mailItems' => $mailItems
  245. );
  246. if (! empty ( $softLock ))
  247. $mailList += array (
  248. 'softLock' => $softLockNum
  249. );
  250. else
  251. $mailList += array (
  252. 'softLock' => 0
  253. );
  254. if (! empty ( $contract ))
  255. $mailList += array (
  256. 'contract' => $contractNum
  257. );
  258. else
  259. $mailList += array (
  260. 'contract' => 0
  261. );
  262. if (! empty ( $instructions ))
  263. $mailList += array (
  264. 'instructions' => $instructionsNum
  265. );
  266. else
  267. $mailList += array (
  268. 'instructions' => 0
  269. );
  270. if (! empty ( $remittance ))
  271. $mailList += array (
  272. 'remittance' => $remittance
  273. );
  274. else
  275. $mailList += array (
  276. 'remittance' => ''
  277. );
  278. $mailString = '发票x1,备注:' . $mailItems;
  279. if (! empty ( $softLock ))
  280. $mailString .= ',软件锁x' . $softLockNum;
  281. if (! empty ( $contract ))
  282. $mailString .= ',合同x' . $contractNum;
  283. if (! empty ( $instructions ))
  284. $mailString .= ',说明书x' . $instructionsNum;
  285. if (! empty ( $remittance ))
  286. $mailString .= ',汇款账号单';
  287. $item += array (
  288. 'recipients' => $recipients,
  289. 'recipientsPhone' => $recipientsPhone,
  290. 'recipientsAddress' => $recipientsAddress,
  291. 'mailItems' => $mailString,
  292. 'mailItemsJson' => json_encode ( $mailList )
  293. );
  294. }
  295. $iid = $invoice->addInvoice ( $item );
  296. $item = array (
  297. 'date' => date ( "Y-m-d H:i:s" ),
  298. 'operation' => "创建",
  299. 'status' => 1,
  300. 'img' => $this->staff [0] ['avatar'],
  301. 'username' => $this->staff [0] ['username'],
  302. 'uid' => $this->staff [0] ['sid'],
  303. 'category' => $this->staff [0] ['category'],
  304. 'iid' => $iid
  305. );
  306. $invoiceOperationLog->setInvoiceOperationLog ( $item );
  307. $item = array (
  308. 'date' => date ( "Y-m-d H:i:s" ),
  309. 'operation' => "提交审批",
  310. 'status' => 1,
  311. 'img' => $this->staff [0] ['avatar'],
  312. 'username' => $this->staff [0] ['username'],
  313. 'uid' => $this->staff [0] ['sid'],
  314. 'category' => $this->staff [0] ['category'],
  315. 'iid' => $iid
  316. );
  317. $invoiceOperationLog->setInvoiceOperationLog ( $item );
  318. $item = array (
  319. 'date' => date ( "Y-m-d H:i:s" ),
  320. 'priceClass' => 1,
  321. 'cid' => $this->staff [0] ['cid'],
  322. 'staff' => $this->staff [0] ['sid'],
  323. 'invoicePrice' => $invoicePrice
  324. );
  325. $invoiceStatistics->setInvoiceStatisticsByCondition ( $item );
  326. }
  327. return "/invoice";
  328. }
  329. function invoiceEdit() {
  330. Doo::loadClass ( 'XDeode' );
  331. $XDeode = new XDeode ( 5 );
  332. $iid = isset ( $this->params ['iid'] ) ? $this->params ['iid'] : "";
  333. $iid = $XDeode->decode ( $iid );
  334. if (! is_numeric ( $iid ))
  335. die ( 'illegal request' );
  336. Doo::loadModel ( 'invoice' );
  337. $invoice = new invoice ();
  338. Doo::loadModel ( 'invoiceOperationLog' );
  339. $invoiceOperationLog = new invoiceOperationLog ();
  340. $invoiceDetail = $invoice->getInvoiceByIid ( $iid );
  341. $operation = $invoiceOperationLog->getInvoiceOperationByDropped ( $iid );
  342. $invoiceDetail ['mailItemsJson'] = json_decode ( $invoiceDetail ['mailItemsJson'], true );
  343. $this->data ['operation'] = $operation;
  344. $this->data ['invoiceDetail'] = $invoiceDetail;
  345. $this->data ['memu'] = "invoice";
  346. $this->data ['staff'] = $this->staff;
  347. $this->data ['receiptMemu'] = 'invoice';
  348. $this->render ( "/admin/invoiceEdit", $this->data );
  349. }
  350. /**
  351. * 重新编辑退回的发票
  352. * @return string
  353. */
  354. function invoiceEditDo() {
  355. $iidKey = $this->get_args ( 'iidKey' ) ? $this->get_args ( 'iidKey' ) : '';
  356. Doo::loadModel ( 'invoice' );
  357. $invoice = new invoice ();
  358. $iid = $invoice->authcode ( $iidKey );
  359. if (! empty ( $iid ) && ! is_numeric ( $iid ))
  360. die ( 'illegal request' );
  361. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  362. $invoiceType = $this->get_args ( 'invoiceType' ) && is_numeric ( $this->get_args ( 'invoiceType' ) ) ? $this->get_args ( 'invoiceType' ) : 0;
  363. $doPost = $this->get_args ( 'doPost' ) && is_numeric ( $this->get_args ( 'doPost' ) ) ? $this->get_args ( 'doPost' ) : 0;
  364. $invoicePrice = $this->get_args ( 'invoicePrice' ) ? $this->get_args ( 'invoicePrice' ) : "";
  365. $invoiceElement = $this->get_args ( 'invoiceElement' ) ? $this->get_args ( 'invoiceElement' ) : "";
  366. $invoiceTitle = $this->get_args ( 'invoiceTitle' ) ? $this->get_args ( 'invoiceTitle' ) : "";
  367. $invoiceCompany = $this->get_args ( 'invoiceCompany' ) ? $this->get_args ( 'invoiceCompany' ) : "";
  368. $TIN = $this->get_args ( 'TIN' ) ? $this->get_args ( 'TIN' ) : "";
  369. $address = $this->get_args ( 'address' ) ? $this->get_args ( 'address' ) : "";
  370. $phone = $this->get_args ( 'phone' ) ? $this->get_args ( 'phone' ) : "";
  371. $bank = $this->get_args ( 'bank' ) ? $this->get_args ( 'bank' ) : "";
  372. $bankAccount = $this->get_args ( 'bankAccount' ) ? $this->get_args ( 'bankAccount' ) : "";
  373. $recipients = $this->get_args ( 'recipients' ) ? $this->get_args ( 'recipients' ) : "";
  374. $recipientsPhone = $this->get_args ( 'recipientsPhone' ) ? $this->get_args ( 'recipientsPhone' ) : "";
  375. $recipientsAddress = $this->get_args ( 'recipientsAddress' ) ? $this->get_args ( 'recipientsAddress' ) : "";
  376. $mailItems = $this->get_args ( 'mailItems' ) ? $this->get_args ( 'mailItems' ) : "";
  377. $remark = $this->get_args ( 'remark' ) ? $this->get_args ( 'remark' ) : "";
  378. $TINT = $this->get_args ( 'TINT' ) ? $this->get_args ( 'TINT' ) : "";
  379. $addressT = $this->get_args ( 'addressT' ) ? $this->get_args ( 'addressT' ) : "";
  380. $phoneT = $this->get_args ( 'phoneT' ) ? $this->get_args ( 'phoneT' ) : "";
  381. $bankT = $this->get_args ( 'bankT' ) ? $this->get_args ( 'bankT' ) : "";
  382. $bankAccountT = $this->get_args ( 'bankAccountT' ) ? $this->get_args ( 'bankAccountT' ) : "";
  383. $softLock = $this->get_args ( 'softLock' ) ? $this->get_args ( 'softLock' ) : 0;
  384. $softLockNum = $this->get_args ( 'softLockNum' ) ? $this->get_args ( 'softLockNum' ) : 0;
  385. $contract = $this->get_args ( 'contract' ) ? $this->get_args ( 'contract' ) : 0;
  386. $contractNum = $this->get_args ( 'contractNum' ) ? $this->get_args ( 'contractNum' ) : 0;
  387. $instructions = $this->get_args ( 'instructions' ) ? $this->get_args ( 'instructions' ) : 0;
  388. $instructionsNum = $this->get_args ( 'instructionsNum' ) ? $this->get_args ( 'instructionsNum' ) : 0;
  389. $remittance = $this->get_args ( 'remittance' ) ? $this->get_args ( 'remittance' ) : 0;
  390. if (! empty ( $cid ) && ! empty ( $invoicePrice ) && ! empty ( $invoiceElement ) && ! empty ( $iid )) {
  391. Doo::loadModel ( 'invoiceManage' );
  392. $invoiceManage = new invoiceManage ();
  393. Doo::loadModel ( 'invoiceOperationLog' );
  394. $invoiceOperationLog = new invoiceOperationLog ();
  395. $cid = explode ( ':', $cid );
  396. $invoiceManageList = $invoiceManage->getInvoiceByAll ();
  397. $invoiceManageDetail = $invoiceManage->getInvoiceByMold ( "发票审批" );
  398. $moldManage = array ();
  399. foreach ( $invoiceManageList as $key => $value ) {
  400. if ($value ['mold'] == '发票打印')
  401. $moldManage [$value ['mold']] = $value ['staffList'];
  402. elseif ($value ['mold'] == '发票邮寄')
  403. $moldManage [$value ['mold']] = $value ['staffList'];
  404. elseif ($value ['mold'] == '发票打印')
  405. $moldManage [$value ['mold']] = $value ['staffList'];
  406. }
  407. $item = array (
  408. 'iid' => $iid,
  409. 'cid' => $cid [0],
  410. 'categoryName' => $cid [1],
  411. 'invoiceElement' => $invoiceElement,
  412. 'invoicePrice' => $invoicePrice,
  413. 'invoiceType' => $invoiceType,
  414. 'doPost' => $doPost,
  415. 'status' => 1,
  416. 'updateTime' => date ( "Y-m-d H:i:s" ),
  417. 'remark' => $remark
  418. );
  419. if ($invoiceType == 0)
  420. $item += array (
  421. 'invoiceTitle' => $invoiceTitle,
  422. 'TIN' => $TINT,
  423. 'address' => $addressT,
  424. 'phone' => $phoneT,
  425. 'bank' => $bankT,
  426. 'bankAccount' => $bankAccountT
  427. );
  428. else {
  429. $item += array (
  430. 'invoiceCompany' => $invoiceCompany,
  431. 'TIN' => $TIN,
  432. 'address' => $address,
  433. 'phone' => $phone,
  434. 'bank' => $bank,
  435. 'bankAccount' => $bankAccount
  436. );
  437. }
  438. if ($doPost == 1) {
  439. $mailList = array (
  440. 'invoice' => 1,
  441. 'mailItems' => $mailItems
  442. );
  443. if (! empty ( $softLock ))
  444. $mailList += array (
  445. 'softLock' => $softLockNum
  446. );
  447. else
  448. $mailList += array (
  449. 'softLock' => '0'
  450. );
  451. if (! empty ( $contract ))
  452. $mailList += array (
  453. 'contract' => $contractNum
  454. );
  455. else
  456. $mailList += array (
  457. 'contract' => '0'
  458. );
  459. if (! empty ( $instructions ))
  460. $mailList += array (
  461. 'instructions' => $instructionsNum
  462. );
  463. else
  464. $mailList += array (
  465. 'instructions' => '0'
  466. );
  467. if (! empty ( $remittance ))
  468. $mailList += array (
  469. 'remittance' => $remittance
  470. );
  471. else
  472. $mailList += array (
  473. 'remittance' => ''
  474. );
  475. $mailString = '发票x1,备注:' . $mailItems;
  476. if (! empty ( $softLock ))
  477. $mailString .= ',软件锁x' . $softLockNum;
  478. if (! empty ( $contract ))
  479. $mailString .= ',合同x' . $contractNum;
  480. if (! empty ( $instructions ))
  481. $mailString .= ',说明书x' . $instructionsNum;
  482. if (! empty ( $remittance ))
  483. $mailString .= ',汇款账号单';
  484. $item += array (
  485. 'recipients' => $recipients,
  486. 'recipientsPhone' => $recipientsPhone,
  487. 'recipientsAddress' => $recipientsAddress,
  488. 'mailItems' => $mailString,
  489. 'mailItemsJson' => json_encode ( $mailList )
  490. );
  491. }
  492. $invoice->setInvoiceByCondition ( $item );
  493. $item = array (
  494. 'date' => date ( "Y-m-d H:i:s" ),
  495. 'operation' => "重新提交审批",
  496. 'status' => 1,
  497. 'img' => $this->staff [0] ['avatar'],
  498. 'username' => $this->staff [0] ['username'],
  499. 'uid' => $this->staff [0] ['sid'],
  500. 'category' => $this->staff [0] ['category'],
  501. 'iid' => $iid
  502. );
  503. $invoiceOperationLog->setInvoiceOperationLog ( $item );
  504. }
  505. return "/invoice";
  506. }
  507. /**
  508. * 终止开票
  509. */
  510. function invoiceDroppedDo() {
  511. $droppedIidKey = $this->get_args ( 'droppedIidKey' ) ? $this->get_args ( 'droppedIidKey' ) : '';
  512. Doo::loadModel ( 'invoice' );
  513. $invoice = new invoice ();
  514. Doo::loadModel ( 'invoiceOperationLog' );
  515. $invoiceOperationLog = new invoiceOperationLog ();
  516. $iid = $invoice->authcode ( $droppedIidKey );
  517. if (! empty ( $iid ) && ! is_numeric ( $iid ))
  518. die ( 'illegal request' );
  519. $item = array (
  520. 'iid' => $iid,
  521. 'status' => 4,
  522. 'updateTime' => date ( "Y-m-d H:i:s" )
  523. );
  524. $invoice->setInvoiceByCondition ( $item );
  525. $item = array (
  526. 'date' => date ( "Y-m-d H:i:s" ),
  527. 'operation' => '终止了开票',
  528. 'status' => 4,
  529. 'img' => $this->staff [0] ['avatar'],
  530. 'username' => $this->staff [0] ['username'],
  531. 'uid' => $this->staff [0] ['sid'],
  532. 'category' => $this->staff [0] ['category'],
  533. 'iid' => $iid
  534. );
  535. $invoiceOperationLog->setInvoiceOperationLog ( $item );
  536. return "/invoice";
  537. }
  538. /**
  539. * 申请退票 --需求变更 废弃
  540. */
  541. function invoiceUntreadDo() {
  542. $untreadIidKey = $this->get_args ( 'untreadIidKey' ) ? $this->get_args ( 'untreadIidKey' ) : '';
  543. $untreadReason = $this->get_args ( 'untreadReason' ) ? $this->get_args ( 'untreadReason' ) : "";
  544. $untreadPost = $this->get_args ( 'untreadPost' ) ? $this->get_args ( 'untreadPost' ) : "";
  545. $untreadCompany = $this->get_args ( 'untreadCompany' ) ? $this->get_args ( 'untreadCompany' ) : "";
  546. $untreadNumber = $this->get_args ( 'untreadNumber' ) ? $this->get_args ( 'untreadNumber' ) : "";
  547. $untreadItems = $this->get_args ( 'untreadItems' ) ? $this->get_args ( 'untreadItems' ) : "";
  548. Doo::loadModel ( 'invoice' );
  549. $invoice = new invoice ();
  550. Doo::loadModel ( 'invoiceOperationLog' );
  551. $invoiceOperationLog = new invoiceOperationLog ();
  552. Doo::loadModel ( 'invoiceReceivables' );
  553. $invoiceReceivables = new invoiceReceivables ();
  554. $iid = $invoice->authcode ( $untreadIidKey );
  555. if (! empty ( $iid ) && ! is_numeric ( $iid ))
  556. die ( 'illegal request' );
  557. $lt = $invoiceReceivables->getInvoiceReceivablesByIid ( $untreadIidKey );
  558. if (! empty ( $lt )) {
  559. header ( 'Content-Type:text/html;charset=utf-8' );
  560. die ( '该发票有收款绑定,请先移除!' );
  561. }
  562. $item = array (
  563. 'iid' => $iid,
  564. 'untreadStatus' => 1,
  565. 'untreadReason' => $untreadReason,
  566. 'untreadPost' => $untreadPost,
  567. 'updateTime' => date ( "Y-m-d H:i:s" )
  568. );
  569. if ($untreadPost == 1) {
  570. $item += array (
  571. 'untreadCompany' => $untreadCompany,
  572. 'untreadNumber' => $untreadNumber,
  573. 'untreadItems' => $untreadItems
  574. );
  575. }
  576. $invoice->setInvoiceByCondition ( $item );
  577. $item = array (
  578. 'date' => date ( "Y-m-d H:i:s" ),
  579. 'operation' => '申请退票',
  580. 'status' => 7,
  581. 'img' => $this->staff [0] ['avatar'],
  582. 'username' => $this->staff [0] ['username'],
  583. 'uid' => $this->staff [0] ['sid'],
  584. 'category' => $this->staff [0] ['category'],
  585. 'iid' => $iid
  586. );
  587. $invoiceOperationLog->setInvoiceOperationLog ( $item );
  588. return "/invoice";
  589. }
  590. /**
  591. * 删除已终止的开票
  592. */
  593. function invoiceDelDo() {
  594. Doo::loadClass ( 'XDeode' );
  595. $XDeode = new XDeode ( 5 );
  596. Doo::loadModel ( 'invoice' );
  597. $invoice = new invoice ();
  598. Doo::loadModel ( 'invoiceOperationLog' );
  599. $invoiceOperationLog = new invoiceOperationLog ();
  600. Doo::loadClass ( 'XDeode' );
  601. $XDeode = new XDeode ( 5 );
  602. $sid = $XDeode->decode ( $_COOKIE ["staff"] );
  603. $iid = isset ( $this->params ['iid'] ) ? $this->params ['iid'] : "";
  604. $iid = $XDeode->decode ( $iid );
  605. if (! is_numeric ( $iid ))
  606. die ( 'illegal request' );
  607. $invoiceDetail = $invoice->getMyInvoice ( $sid, $iid );
  608. if (empty ( $invoiceDetail ))
  609. die ( 'illegal request' );
  610. $item = array (
  611. 'iid' => $iid,
  612. 'isDelete' => 1,
  613. 'updateTime' => date ( "Y-m-d H:i:s" )
  614. );
  615. $invoice->setInvoiceByCondition ( $item );
  616. $item = array (
  617. 'date' => date ( "Y-m-d H:i:s" ),
  618. 'operation' => '删除了已终止的发票',
  619. 'status' => 4,
  620. 'img' => $this->staff [0] ['avatar'],
  621. 'username' => $this->staff [0] ['username'],
  622. 'uid' => $this->staff [0] ['sid'],
  623. 'category' => $this->staff [0] ['category'],
  624. 'iid' => $iid
  625. );
  626. $invoiceOperationLog->setInvoiceOperationLog ( $item );
  627. return "/invoice";
  628. }
  629. function invoiceApproval() {
  630. Doo::loadModel ( 'invoice' );
  631. $invoice = new invoice ();
  632. Doo::loadClass ( 'XDeode' );
  633. $XDeode = new XDeode ( 5 );
  634. Doo::loadModel ( 'staff' );
  635. $staff = new staff ();
  636. $invoiceList = $invoice->find ( array (
  637. 'where' => 'status=1 and pendingApprovals=' . $this->staff [0] ['sid'],
  638. 'desc' => 'iid',
  639. 'asArray' => true
  640. ) );
  641. foreach ( $invoiceList as $key => $value ) {
  642. $invoiceList [$key] ['iidKey'] = $XDeode->encode ( $value ['iid'] );
  643. $lastApprover = json_decode ( $value ['processApprovals'], true );
  644. if (! empty ( $lastApprover )) {
  645. $lastApproverKey = array_keys ( $lastApprover );
  646. $lastApprover = end ( $lastApprover );
  647. $staffDetail = $staff->getOne ( array (
  648. 'where' => 'sid=' . end ( $lastApproverKey ),
  649. 'asArray' => true
  650. ) );
  651. $lastApprover ['username'] = $staffDetail ['username'];
  652. }
  653. $invoiceList [$key] ['lastApprover'] = $lastApprover;
  654. }
  655. $ilist = $invoice->getInvoiceByProcessStatus ();
  656. // print_r($ilist);
  657. $this->data ['invoiceList'] = $invoiceList;
  658. $this->data ['ilist'] = $ilist;
  659. $this->data ['memu'] = "invoice";
  660. $this->data ['staff'] = $this->staff;
  661. $this->data ['receiptMemu'] = 'invoiceApproval';
  662. $this->render ( "/admin/invoiceApproval", $this->data );
  663. }
  664. function invoiceDetail() {
  665. Doo::loadClass ( 'XDeode' );
  666. $XDeode = new XDeode ( 5 );
  667. $iid = isset ( $this->params ['iid'] ) ? $this->params ['iid'] : "";
  668. $iid = $XDeode->decode ( $iid );
  669. if (! is_numeric ( $iid ))
  670. die ( 'illegal request' );
  671. Doo::loadModel ( 'invoice' );
  672. $invoice = new invoice ();
  673. Doo::loadModel ( 'invoiceOperationLog' );
  674. $invoiceOperationLog = new invoiceOperationLog ();
  675. $invoiceDetail = $invoice->getOne ( array (
  676. 'where' => 'status=1 and pendingApprovals=' . $this->staff [0] ['sid'] . ' and iid=' . $iid,
  677. 'asArray' => true
  678. ) );
  679. $invoiceOperationLogList = $invoiceOperationLog->getInvoiceOperationLogByIid ( $iid );
  680. $this->data ['invoiceDetail'] = $invoiceDetail;
  681. $this->data ['invoiceOperationLogList'] = $invoiceOperationLogList;
  682. $this->data ['INVOICEKEY'] = $invoice->authcode ( $invoiceDetail ['iid'], '' );
  683. $this->data ['memu'] = "invoice";
  684. $this->data ['staff'] = $this->staff;
  685. $this->data ['receiptMemu'] = 'invoiceApproval';
  686. $this->render ( "/admin/invoiceApprovalDetail", $this->data );
  687. }
  688. /**
  689. * 对发票进行审批,其中操作有终止,退回,同意动作。操作成功并记录下操作日志
  690. *
  691. * @since 1.0.0
  692. * @var integer iid 开票ID 已加密
  693. * @var integer status 发票审批状态
  694. * @var integer opintion 审批发票的意见
  695. * @return string 如操作成功返回审批首页
  696. */
  697. function invoiceApprovalDo() {
  698. Doo::loadModel ( 'invoice' );
  699. $invoice = new invoice ();
  700. $iid = $this->get_args ( 'invoiceKey' ) ? $this->get_args ( 'invoiceKey' ) : "";
  701. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  702. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  703. $iid = $invoice->authcode ( $iid );
  704. if (! is_numeric ( $iid ))
  705. die ( 'illegal request' );
  706. if (! empty ( $iid ) && ! empty ( $status ) && ! empty ( $opinion )) {
  707. if (! ($status == 2 || $status == 3 || $status == 4))
  708. die ( 'illegal request' );
  709. Doo::loadModel ( 'invoiceOperationLog' );
  710. $invoiceOperationLog = new invoiceOperationLog ();
  711. $invoiceDetail = $invoice->getOne ( array (
  712. 'where' => 'status=1 and iid=' . $iid . ' and pendingApprovals=' . $this->staff [0] ['sid'],
  713. 'asArray' => true
  714. ) );
  715. if (empty ( $invoiceDetail ))
  716. die ( 'illegal request' );
  717. $processApprovals = json_decode ( $invoiceDetail ['processApprovals'], true );
  718. $invoiceManage = json_decode ( $invoiceDetail ['invoiceManage'], true );
  719. if ($status == 3) {
  720. $invoice->status = $status;
  721. $item = array (
  722. 'operation' => $opinion
  723. );
  724. } else {
  725. if (empty ( $processApprovals )) {
  726. $processApprovals = array (
  727. $this->staff [0] ['sid'] => array (
  728. 'date' => date ( "Y-m-d H:i:s" ),
  729. 'opinion' => $opinion,
  730. 'status' => $status
  731. )
  732. );
  733. if ($status != 4 && isset ( $invoiceManage [1] ))
  734. $invoice->pendingApprovals = $invoiceManage [1] [0];
  735. $invoice->processApprovals = json_encode ( $processApprovals );
  736. } else {
  737. $processApprovals [$this->staff [0] ['sid']] = array (
  738. 'date' => date ( "Y-m-d H:i:s" ),
  739. 'opinion' => $opinion,
  740. 'status' => $status
  741. );
  742. $pendingApprovals = 0;
  743. foreach ( $invoiceManage as $key => $value ) {
  744. if ($value [0] == $this->staff [0] ['sid']) {
  745. if (isset ( $invoiceManage [$key + 1] ))
  746. $pendingApprovals = $invoiceManage [$key + 1] [0];
  747. break;
  748. }
  749. }
  750. if ($status != 4 && ! empty ( $pendingApprovals ))
  751. $invoice->pendingApprovals = $pendingApprovals;
  752. $invoice->processApprovals = json_encode ( $processApprovals );
  753. }
  754. $item = array (
  755. 'operation' => $opinion
  756. );
  757. if (count ( $processApprovals ) == count ( $invoiceManage ) && $status != 4) {
  758. $invoice->status = $status;
  759. $invoice->pendingApprovals = 0;
  760. } elseif ($status == 4) {
  761. $invoice->status = $status;
  762. $item = array (
  763. 'operation' => $opinion
  764. );
  765. }
  766. }
  767. $invoice->updateTime = date ( "Y-m-d H:i:s" );
  768. $invoice->update ( array (
  769. 'where' => 'iid=' . $iid
  770. ) );
  771. $item += array (
  772. 'date' => date ( "Y-m-d H:i:s" ),
  773. 'img' => $this->staff [0] ['avatar'],
  774. 'username' => $this->staff [0] ['username'],
  775. 'uid' => $this->staff [0] ['sid'],
  776. 'category' => $this->staff [0] ['category'],
  777. 'status' => $status,
  778. 'iid' => $iid
  779. );
  780. $invoiceOperationLog->setInvoiceOperationLog ( $item );
  781. return '/invoiceApproval';
  782. }
  783. die ( 'illegal request' );
  784. }
  785. /**
  786. * 展示需要打印的发票数据
  787. *
  788. * @since 1.0.0
  789. */
  790. function invoicePrint() {
  791. Doo::loadModel ( 'invoice' );
  792. $invoice = new invoice ();
  793. Doo::loadClass ( 'XDeode' );
  794. $XDeode = new XDeode ( 5 );
  795. Doo::loadModel ( 'staff' );
  796. $staff = new staff ();
  797. $toPrint = $invoice->getPrintInvoiceByManage ( $this->staff [0] ['sid'], 0 );
  798. $printed = $invoice->getPrintInvoiceByManage ( $this->staff [0] ['sid'], 1 );
  799. foreach ( $toPrint as $key => $value ) {
  800. $toPrint [$key] ['iidKey'] = $XDeode->encode ( $value ['iid'] );
  801. $lastApprover = json_decode ( $value ['processApprovals'], true );
  802. if (! empty ( $lastApprover )) {
  803. $lastApproverKey = array_keys ( $lastApprover );
  804. $lastApprover = end ( $lastApprover );
  805. $staffDetail = $staff->getOne ( array (
  806. 'where' => 'sid=' . end ( $lastApproverKey ),
  807. 'asArray' => true
  808. ) );
  809. $lastApprover ['username'] = $staffDetail ['username'];
  810. }
  811. $toPrint [$key] ['lastApprover'] = $lastApprover;
  812. }
  813. foreach ( $printed as $key => $value ) {
  814. $printed [$key] ['iidKey'] = $XDeode->encode ( $value ['iid'] );
  815. $lastApprover = json_decode ( $value ['processApprovals'], true );
  816. if (! empty ( $lastApprover )) {
  817. $lastApproverKey = array_keys ( $lastApprover );
  818. $lastApprover = end ( $lastApprover );
  819. $staffDetail = $staff->getOne ( array (
  820. 'where' => 'sid=' . end ( $lastApproverKey ),
  821. 'asArray' => true
  822. ) );
  823. $lastApprover ['username'] = $staffDetail ['username'];
  824. }
  825. $printed [$key] ['lastApprover'] = $lastApprover;
  826. }
  827. $this->data ['printed'] = $printed;
  828. $this->data ['toPrint'] = $toPrint;
  829. $this->data ['memu'] = "invoice";
  830. $this->data ['staff'] = $this->staff;
  831. $this->data ['receiptMemu'] = 'invoicePrint';
  832. $this->render ( "/admin/invoicePrint", $this->data );
  833. }
  834. /**
  835. * 展示发票打印的详情页面
  836. *
  837. * @since 1.0.0
  838. */
  839. function invoicePrintDetail() {
  840. Doo::loadClass ( 'XDeode' );
  841. $XDeode = new XDeode ( 5 );
  842. $iid = isset ( $this->params ['iid'] ) ? $this->params ['iid'] : "";
  843. $iid = $XDeode->decode ( $iid );
  844. if (! is_numeric ( $iid ))
  845. die ( 'illegal request' );
  846. Doo::loadModel ( 'invoice' );
  847. $invoice = new invoice ();
  848. Doo::loadModel ( 'invoiceOperationLog' );
  849. $invoiceOperationLog = new invoiceOperationLog ();
  850. $invoiceDetail = $invoice->getPrintInvoiceByManage ( $this->staff [0] ['sid'], 0, $iid );
  851. // if (empty ( $invoiceDetail ))
  852. // die ( 'illegal request' );
  853. $invoiceOperationLogList = $invoiceOperationLog->getInvoiceOperationLogByIid ( $iid );
  854. $this->data ['invoiceDetail'] = $invoiceDetail;
  855. $this->data ['invoiceOperationLogList'] = $invoiceOperationLogList;
  856. $this->data ['INVOICEKEY'] = $invoice->authcode ( $invoiceDetail ['iid'], '' );
  857. $this->data ['memu'] = "invoice";
  858. $this->data ['staff'] = $this->staff;
  859. $this->data ['receiptMemu'] = 'invoicePrint';
  860. $this->render ( "/admin/invoicePrintDetail", $this->data );
  861. }
  862. /**
  863. * 填写票号并完成打印
  864. * @since 1.0.0
  865. */
  866. function invoicePrintDo() {
  867. Doo::loadModel ( 'invoice' );
  868. $invoice = new invoice ();
  869. $iid = $this->get_args ( 'invoiceKey' ) ? $this->get_args ( 'invoiceKey' ) : "";
  870. $invoiceNo = $this->get_args ( 'invoiceNo' ) ? $this->get_args ( 'invoiceNo' ) : "";
  871. $iid = $invoice->authcode ( $iid );
  872. if (! is_numeric ( $iid ))
  873. die ( 'illegal request' );
  874. if (! empty ( $iid ) && ! empty ( $invoiceNo )) {
  875. Doo::loadModel ( 'invoiceOperationLog' );
  876. $invoiceOperationLog = new invoiceOperationLog ();
  877. $invoicePrintDetail = $invoice->getInvoiceByPrint ( $iid );
  878. if (empty ( $invoicePrintDetail ))
  879. die ( 'illegal request' );
  880. $item = array (
  881. 'iid' => $iid,
  882. 'printStatus' => 1,
  883. 'updateTime' => date ( "Y-m-d H:i:s" ),
  884. 'printer'=> $this->staff [0] ['username'],
  885. 'printTime' => date ( "Y-m-d H:i:s" ),
  886. 'invoiceNo' => $invoiceNo
  887. );
  888. $invoice->setInvoiceByCondition ( $item );
  889. $item = array (
  890. 'date' => date ( "Y-m-d H:i:s" ),
  891. 'operation' => $invoiceNo,
  892. 'status' => 5,
  893. 'img' => $this->staff [0] ['avatar'],
  894. 'username' => $this->staff [0] ['username'],
  895. 'uid' => $this->staff [0] ['sid'],
  896. 'category' => $this->staff [0] ['category'],
  897. 'iid' => $iid
  898. );
  899. $invoiceOperationLog->setInvoiceOperationLog ( $item );
  900. return "/invoicePrint";
  901. }
  902. }
  903. /**
  904. * 需要邮寄的发票
  905. * @since 1.0.0
  906. */
  907. function invoicePost() {
  908. Doo::loadModel ( 'invoice' );
  909. $invoice = new invoice ();
  910. Doo::loadModel ( 'express' );
  911. $express = new express ();
  912. $invoicePost = $invoice->getPostByInvoice ();
  913. $invoicePosted = $invoice->getPostByInvoice ( 1 );
  914. $expressList = $express->getExpressByAll ();
  915. $this->data ['expressList'] = $expressList;
  916. $this->data ['invoicePost'] = $invoicePost;
  917. $this->data ['invoicePosted'] = $invoicePosted;
  918. $this->data ['memu'] = "invoice";
  919. $this->data ['staff'] = $this->staff;
  920. $this->data ['receiptMemu'] = 'invoicePost';
  921. $this->render ( "/admin/invoicePost", $this->data );
  922. }
  923. /**
  924. * 添加发票邮寄信息
  925. */
  926. function invoiceExpressAddDo() {
  927. Doo::loadModel ( 'invoice' );
  928. $invoice = new invoice ();
  929. $iid = $this->get_args ( 'iidKey' ) ? $this->get_args ( 'iidKey' ) : "";
  930. $expressCompany = $this->get_args ( 'express' ) ? $this->get_args ( 'express' ) : "";
  931. $expressNumber = $this->get_args ( 'nu' ) ? $this->get_args ( 'nu' ) : "";
  932. $actualItems = $this->get_args ( 'actualItems' ) ? $this->get_args ( 'actualItems' ) : "";
  933. $iid = $iid = $invoice->authcode ( $iid );
  934. if (! is_numeric ( $iid ) && empty ( $expressCompany ) && empty ( $expressNumber ) && empty ( $actualItems ))
  935. die ( 'illegal request' );
  936. $item = array (
  937. 'iid' => $iid,
  938. 'postStatus' => 1,
  939. 'updateTime' => date ( "Y-m-d H:i:s" ),
  940. 'postTime' => date ( "Y-m-d H:i:s" ),
  941. 'expressCompany' => $expressCompany,
  942. 'expressNumber' => $expressNumber,
  943. 'actualItems' => $actualItems,
  944. 'poster' => $this->staff [0] ['username']
  945. );
  946. $invoice->setInvoiceByCondition ( $item );
  947. // $this->setWXMsg ( $iid, 41 );
  948. return '/invoicePost';
  949. }
  950. function invoiceExpressUpdateDo() {
  951. Doo::loadModel ( 'invoice' );
  952. $invoice = new invoice ();
  953. $action = $this->get_args ( 'action' ) ? $this->get_args ( 'action' ) : "";
  954. $iid = $this->get_args ( 'iidKey' ) ? $this->get_args ( 'iidKey' ) : "";
  955. $expressCompany = $this->get_args ( 'express' ) ? $this->get_args ( 'express' ) : "";
  956. $expressNumber = $this->get_args ( 'nu' ) ? $this->get_args ( 'nu' ) : "";
  957. $actualItems = $this->get_args ( 'actualItems' ) ? $this->get_args ( 'actualItems' ) : "";
  958. $iid = $invoice->authcode ( $iid );
  959. if (! is_numeric ( $iid ) && empty ( $expressCompany ) && empty ( $expressNumber ) && empty ( $actualItems ))
  960. die ( 'illegal request' );
  961. $item = array (
  962. 'iid' => $iid,
  963. 'updateTime' => date ( "Y-m-d H:i:s" ),
  964. 'expressCompany' => $expressCompany,
  965. 'expressNumber' => $expressNumber,
  966. 'actualItems' => $actualItems,
  967. 'poster' => $this->staff [0] ['username']
  968. );
  969. $invoice->setInvoiceByCondition ( $item );
  970. return $action;
  971. }
  972. /**
  973. * 退票处理页面
  974. */
  975. function invoiceUntread() {
  976. Doo::loadModel ( 'invoice' );
  977. $invoice = new invoice ();
  978. $untreadInvoice = $invoice->getInvoiceByUntreadStatus ( 1 );
  979. $establishedInvoice = $invoice->getInvoiceByUntreadStatus ( 2 );
  980. $this->data ['untreadInvoice'] = $untreadInvoice;
  981. $this->data ['establishedInvoice'] = $establishedInvoice;
  982. $this->data ['memu'] = "invoice";
  983. $this->data ['staff'] = $this->staff;
  984. $this->data ['receiptMemu'] = 'invoiceUntread';
  985. $this->render ( "/admin/invoiceUntread", $this->data );
  986. }
  987. /**
  988. * 确认收到退回的发票,开票状态为退回
  989. */
  990. function invoiceUntreadEstablishedDo() {
  991. $untreadIidKey = $this->get_args ( 'untreadIidKey' ) ? $this->get_args ( 'untreadIidKey' ) : '';
  992. Doo::loadModel ( 'invoice' );
  993. $invoice = new invoice ();
  994. Doo::loadModel ( 'invoiceOperationLog' );
  995. $invoiceOperationLog = new invoiceOperationLog ();
  996. $iid = $invoice->authcode ( $untreadIidKey );
  997. if (! empty ( $iid ) && ! is_numeric ( $iid ))
  998. die ( 'illegal request' );
  999. $item = array (
  1000. 'iid' => $iid,
  1001. 'untreadStatus' => 2,
  1002. 'updateTime' => date ( "Y-m-d H:i:s" )
  1003. );
  1004. $invoice->setInvoiceByCondition ( $item );
  1005. $item = array (
  1006. 'date' => date ( "Y-m-d H:i:s" ),
  1007. 'operation' => '已确认退票',
  1008. 'status' => 6,
  1009. 'img' => $this->staff [0] ['avatar'],
  1010. 'username' => $this->staff [0] ['username'],
  1011. 'uid' => $this->staff [0] ['sid'],
  1012. 'category' => $this->staff [0] ['category'],
  1013. 'iid' => $iid
  1014. );
  1015. $invoiceOperationLog->setInvoiceOperationLog ( $item );
  1016. return "/invoiceUntread";
  1017. }
  1018. function invoiceReceivables() {
  1019. $invoiceTC = $this->get_args ( 'invoiceTC' ) ? $this->get_args ( 'invoiceTC' ) : '';
  1020. Doo::loadModel ( 'L_category' );
  1021. $lCategory = new L_category ();
  1022. Doo::loadModel ( 'staff' );
  1023. $staff = new staff ();
  1024. Doo::loadModel ( 'invoiceReceivables' );
  1025. $invoiceReceivables = new invoiceReceivables ();
  1026. Doo::loadModel ( 'invoice' );
  1027. $invoice = new invoice ();
  1028. Doo::loadClass ( 'XDeode' );
  1029. $XDeode = new XDeode ( 5 );
  1030. $category = $lCategory->getCategory ();
  1031. $staffList = $staff->getStaffByCid ( $this->staff [0] ['cid'] );
  1032. $receivablesList = $invoiceReceivables->getInvoiceReceivablesByNew ();
  1033. // 获取未入账发票
  1034. $invoiceUnAccount = $invoice->getInvoiceByUnAccount ( $invoiceTC );
  1035. foreach ( $invoiceUnAccount as $key => $value ) {
  1036. $invoiceUnAccount [$key] ['iidKey'] = $XDeode->encode ( $value ['iid'] );
  1037. $lastApprover = json_decode ( $value ['processApprovals'], true );
  1038. if (! empty ( $lastApprover )) {
  1039. $lastApproverKey = array_keys ( $lastApprover );
  1040. $lastApprover = end ( $lastApprover );
  1041. $staffDetail = $staff->getOne ( array (
  1042. 'where' => 'sid=' . end ( $lastApproverKey ),
  1043. 'asArray' => true
  1044. ) );
  1045. $lastApprover ['username'] = $staffDetail ['username'];
  1046. }
  1047. $invoiceUnAccount [$key] ['lastApprover'] = $lastApprover;
  1048. }
  1049. $receivablesInput=$invoiceReceivables->getInvoiceReceivablesByInput();
  1050. //print_r($receivablesInput);
  1051. $this->data ['receivablesInput'] = $receivablesInput;
  1052. $this->data ['year'] = date ( 'Y' );
  1053. $this->data ['invoiceUnAccount'] = $invoiceUnAccount;
  1054. $this->data ['receivablesList'] = $receivablesList;
  1055. $this->data ['staffList'] = $staffList;
  1056. $this->data ['category'] = $category;
  1057. $this->data ['memu'] = "invoice";
  1058. $this->data ['staff'] = $this->staff;
  1059. $this->data ['receiptMemu'] = 'invoiceReceivables';
  1060. $this->render ( "/admin/invoiceReceivables", $this->data );
  1061. }
  1062. /**
  1063. * 新添加收款直接入账发票
  1064. */
  1065. function invoiceCompareClaimPrice() {
  1066. // 收款录入
  1067. $iidKey = $this->get_args ( 'iidKey' ) ? $this->get_args ( 'iidKey' ) : "";
  1068. $receivablesPrice = $this->get_args ( 'receivablesPrice' ) ? $this->get_args ( 'receivablesPrice' ) : "";
  1069. $receivablesMessage = $this->get_args ( 'receivablesMessage' ) ? $this->get_args ( 'receivablesMessage' ) : "";
  1070. $receivablesBank = $this->get_args ( 'receivablesBank' ) ? $this->get_args ( 'receivablesBank' ) : "";
  1071. $receivablesDate = $this->get_args ( 'receivablesDate' ) ? $this->get_args ( 'receivablesDate' ) : "";
  1072. if (! empty ( $receivablesPrice ) && ! empty ( $receivablesMessage ) && ! empty ( $receivablesBank ) && ! empty ( $receivablesDate ) && ! empty ( $iidKey )) {
  1073. Doo::loadModel ( 'invoiceReceivables' );
  1074. $invoiceReceivables = new invoiceReceivables ();
  1075. Doo::loadModel ( 'invoiceROLog' );
  1076. $invoiceROLog = new invoiceROLog ();
  1077. Doo::loadModel ( 'invoiceStatistics' );
  1078. $invoiceStatistics = new invoiceStatistics ();
  1079. Doo::loadModel ( 'invoice' );
  1080. $invoice = new invoice ();
  1081. Doo::loadClass ( 'XDeode' );
  1082. $XDeode = new XDeode ( 5 );
  1083. Doo::loadModel ( 'invoiceOperationLog' );
  1084. $invoiceOperationLog = new invoiceOperationLog ();
  1085. $iidKey = $XDeode->decode ( $iidKey );
  1086. $invoiceDetail = $invoice->getInvoiceByIid ( $iidKey );
  1087. $receivablesSerial="#SK" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  1088. // 收款录入 并绑定发票
  1089. Doo::db ()->beginTransaction ();
  1090. $item = array (
  1091. 'bindStatus' => 1,
  1092. 'iid' => $invoiceDetail ['iid'],
  1093. 'bindDate' => date ( "Y-m-d H:i:s" ),
  1094. 'receivablesPrice' => $receivablesPrice,
  1095. 'receivablesMessage' => $receivablesMessage,
  1096. 'receivablesSerial' => $receivablesSerial,
  1097. 'receivablesBank' => $receivablesBank,
  1098. 'receivablesDate' => $receivablesDate,
  1099. 'inputStaff' => $this->staff [0] ['username'],
  1100. 'date' => date ( "Y-m-d" ),
  1101. 'receivablesCategory' => $invoiceDetail ['cid'] . ':' . $invoiceDetail ['categoryName'],
  1102. 'receivablesStaff' => $invoiceDetail ['sid'] . '-' . $invoiceDetail ['userName'],
  1103. 'confirmTime' => date ( "Y-m-d H:i:s" )
  1104. );
  1105. $irid = $invoiceReceivables->addInvoiceReceivables ( $item );
  1106. $item = array ();
  1107. // 收款操作日志
  1108. $item = array (
  1109. 'operation' => $this->staff [0] ['username'] . " 转入 " . $invoiceDetail ['userName']
  1110. );
  1111. $item += array (
  1112. 'date' => date ( "Y-m-d" ),
  1113. 'status' => 1,
  1114. 'img' => $this->staff [0] ['avatar'],
  1115. 'username' => $this->staff [0] ['username'],
  1116. 'uid' => $this->staff [0] ['sid'],
  1117. 'category' => $this->staff [0] ['category'],
  1118. 'irid' => $irid
  1119. );
  1120. $invoiceROLog->setInvoiceROLog ( $item );
  1121. // 收款统计
  1122. $item = array (
  1123. 'date' => date ( "Y-m-d H:i:s" ),
  1124. 'priceClass' => 2,
  1125. 'irid' => $irid,
  1126. 'cid' => $invoiceDetail ['cid'],
  1127. 'staff' => $invoiceDetail ['sid'],
  1128. 'receivablesPrice' => $receivablesPrice
  1129. );
  1130. $invoiceStatistics->setInvoiceStatisticsByCondition ( $item );
  1131. // 收款 入 发票
  1132. $detail = $invoiceDetail;
  1133. $iridString = "";
  1134. if (empty ( $detail ['irid'] ))
  1135. $iridString = $irid;
  1136. else
  1137. $iridString = $detail ['irid'] . ',' . $irid;
  1138. $item = array (
  1139. 'irid' => $iridString,
  1140. 'bindTime' => date ( "Y-m-d H:i:s" ),
  1141. 'updateTime' => date ( "Y-m-d H:i:s" ),
  1142. 'iid' => $detail ['iid']
  1143. );
  1144. $invoice->setInvoiceByCondition ( $item );
  1145. // 操作日志
  1146. $item = array (
  1147. 'date' => date ( "Y-m-d H:i:s" ),
  1148. 'operation' => "收款入账" . $receivablesSerial . "到发票" . $detail ['invoiceSerial'],
  1149. 'status' => 8,
  1150. 'img' => $this->staff [0] ['avatar'],
  1151. 'username' => $this->staff [0] ['username'],
  1152. 'uid' => $this->staff [0] ['sid'],
  1153. 'category' => $this->staff [0] ['category'],
  1154. 'iid' => $detail ['iid']
  1155. );
  1156. $invoiceOperationLog->setInvoiceOperationLog ( $item );
  1157. Doo::db ()->commit ();
  1158. }
  1159. return '/invoiceReceivables';
  1160. }
  1161. /**
  1162. * 检索未入账发票数据
  1163. */
  1164. function sir() {
  1165. }
  1166. /**
  1167. * 录入收款数据
  1168. * @return string
  1169. */
  1170. function invoiceReceivablesDo() {
  1171. $receivablesPrice = $this->get_args ( 'receivablesPrice' ) ? $this->get_args ( 'receivablesPrice' ) : "";
  1172. $receivablesMessage = $this->get_args ( 'receivablesMessage' ) ? $this->get_args ( 'receivablesMessage' ) : "";
  1173. $receivablesBank = $this->get_args ( 'receivablesBank' ) ? $this->get_args ( 'receivablesBank' ) : "";
  1174. $receivablesDate = $this->get_args ( 'receivablesDate' ) ? $this->get_args ( 'receivablesDate' ) : "";
  1175. $receivablesCategory = $this->get_args ( 'receivablesCategory' ) ? $this->get_args ( 'receivablesCategory' ) : "";
  1176. $receivablesStaff = $receivablesStaff2 = $this->get_args ( 'receivablesStaff' ) ? $this->get_args ( 'receivablesStaff' ) : "";
  1177. Doo::loadModel ( 'invoiceReceivables' );
  1178. $invoiceReceivables = new invoiceReceivables ();
  1179. Doo::loadModel ( 'invoiceROLog' );
  1180. $invoiceROLog = new invoiceROLog ();
  1181. Doo::loadModel ( 'invoiceStatistics' );
  1182. $invoiceStatistics = new invoiceStatistics ();
  1183. if (! empty ( $receivablesPrice ) && ! empty ( $receivablesMessage ) && ! empty ( $receivablesBank ) && ! empty ( $receivablesDate ) && ! empty ( $receivablesCategory ) && ! empty ( $receivablesStaff )) {
  1184. $item = array (
  1185. 'receivablesPrice' => $receivablesPrice,
  1186. 'receivablesMessage' => $receivablesMessage,
  1187. 'receivablesSerial' => "#SK" . date ( "Ymd" ) . mt_rand ( 1000, 9999 ),
  1188. 'receivablesBank' => $receivablesBank,
  1189. 'receivablesDate' => $receivablesDate,
  1190. 'inputStaff' => $this->staff [0] ['username'],
  1191. 'date' => date ( "Y-m-d" ),
  1192. 'receivablesCategory' => $receivablesCategory,
  1193. 'receivablesStaff' => $receivablesStaff
  1194. );
  1195. if ($receivablesCategory != 'PUBLIC' && $receivablesStaff != 'PUBLIC') {
  1196. $item += array (
  1197. 'confirmTime' => date ( "Y-m-d H:i:s" ),
  1198. 'inputType' => 1
  1199. );
  1200. }
  1201. $irid = $invoiceReceivables->addInvoiceReceivables ( $item );
  1202. $item = array ();
  1203. // 收款操作日志
  1204. if ($receivablesCategory == 'PUBLIC' && $receivablesStaff == 'PUBLIC')
  1205. $item = array (
  1206. 'operation' => $this->staff [0] ['username'] . " 转入 公共待认领款项 "
  1207. );
  1208. elseif ($receivablesCategory != 'PUBLIC' && $receivablesStaff == 'PUBLIC')
  1209. $item = array (
  1210. 'operation' => $this->staff [0] ['username'] . "转入 办事处待认领款项"
  1211. );
  1212. elseif ($receivablesCategory != 'PUBLIC' && $receivablesStaff != 'PUBLIC') {
  1213. $receivablesStaff = explode ( '-', $receivablesStaff );
  1214. $item = array (
  1215. 'operation' => $this->staff [0] ['username'] . " 转入 " . $receivablesStaff [1]
  1216. );
  1217. }
  1218. $item += array (
  1219. 'date' => date ( "Y-m-d" ),
  1220. 'status' => 1,
  1221. 'img' => $this->staff [0] ['avatar'],
  1222. 'username' => $this->staff [0] ['username'],
  1223. 'uid' => $this->staff [0] ['sid'],
  1224. 'category' => $this->staff [0] ['category'],
  1225. 'irid' => $irid
  1226. );
  1227. $invoiceROLog->setInvoiceROLog ( $item );
  1228. $item = array (
  1229. 'date' => date ( "Y-m-d H:i:s" ),
  1230. 'priceClass' => 2,
  1231. 'irid' => $irid,
  1232. 'receivablesPrice' => $receivablesPrice
  1233. );
  1234. if ($receivablesCategory != 'PUBLIC') {
  1235. $receivablesCategory = explode ( ":", $receivablesCategory );
  1236. $item += array (
  1237. 'cid' => $receivablesCategory [0]
  1238. );
  1239. }
  1240. if ($receivablesStaff2 != 'PUBLIC') {
  1241. $receivablesStaff = explode ( "-", $receivablesStaff2 );
  1242. $item += array (
  1243. 'staff' => $receivablesStaff [0]
  1244. );
  1245. }
  1246. $invoiceStatistics->setInvoiceStatisticsByCondition ( $item );
  1247. }
  1248. return "/invoiceReceivables";
  1249. }
  1250. /**
  1251. * 收款认领页面-包括公共认领 办事处认领 最近已认领数据
  1252. */
  1253. function invoiceReceivablesClaim() {
  1254. Doo::loadModel ( 'invoiceReceivables' );
  1255. $invoiceReceivables = new invoiceReceivables ();
  1256. $receivablesList = $invoiceReceivables->getInvoiceReceivablesByClaim ( $this->staff [0] ['cid'],$this->staff [0] ['sid'] );
  1257. $this->data ['receivablesList'] = $receivablesList;
  1258. $this->data ['memu'] = "invoice";
  1259. $this->data ['staff'] = $this->staff;
  1260. $this->data ['receiptMemu'] = 'invoiceReceivablesClaim';
  1261. $this->render ( "/admin/invoiceReceivablesClaim", $this->data );
  1262. }
  1263. /**
  1264. * 更新收款相关数据
  1265. */
  1266. function invoiceReceivablesUpdateClaim() {
  1267. $receivablesPrice = $this->get_args ( 'receivablesPrice' ) ? $this->get_args ( 'receivablesPrice' ) : "";
  1268. $receivablesMessage = $this->get_args ( 'receivablesMessage' ) ? $this->get_args ( 'receivablesMessage' ) : "";
  1269. $receivablesBank = $this->get_args ( 'receivablesBank' ) ? $this->get_args ( 'receivablesBank' ) : "";
  1270. $receivablesDate = $this->get_args ( 'receivablesDate' ) ? $this->get_args ( 'receivablesDate' ) : "";
  1271. $receivablesCategory = $this->get_args ( 'receivablesCategory' ) ? $this->get_args ( 'receivablesCategory' ) : "";
  1272. $receivablesStaff = $receivablesStaff2 = $this->get_args ( 'receivablesStaff' ) ? $this->get_args ( 'receivablesStaff' ) : "";
  1273. $claimKey = $this->get_args ( 'claimKey' ) ? $this->get_args ( 'claimKey' ) : "";
  1274. if (empty ( $claimKey ))
  1275. die ( 'illegal request' );
  1276. Doo::loadModel ( 'invoiceReceivables' );
  1277. $invoiceReceivables = new invoiceReceivables ();
  1278. Doo::loadModel ( 'invoiceROLog' );
  1279. $invoiceROLog = new invoiceROLog ();
  1280. $con = ' and iid=0 and bindStatus=0'; // and receivablesCategory!="PUBLIC" and receivablesStaff!="PUBLIC"
  1281. $detail = $invoiceReceivables->getInvoiceReceivablesByIrid ( $claimKey, $con );
  1282. if (empty ( $detail ))
  1283. die ( 'illegal request' );
  1284. $invoiceReceivables = new invoiceReceivables ();
  1285. $item = array (
  1286. 'irid' => $detail ['irid']
  1287. );
  1288. if ($receivablesCategory != 'PUBLIC' && $receivablesStaff != 'PUBLIC') {
  1289. $item += array (
  1290. 'confirmTime' => date ( "Y-m-d H:i:s" )
  1291. );
  1292. }
  1293. if (! empty ( $receivablesCategory ))
  1294. $item += array (
  1295. 'receivablesCategory' => $receivablesCategory
  1296. );
  1297. if (! empty ( $receivablesStaff ))
  1298. $item += array (
  1299. 'receivablesStaff' => $receivablesStaff
  1300. );
  1301. if (! empty ( $receivablesPrice ))
  1302. $item += array (
  1303. 'receivablesPrice' => $receivablesPrice
  1304. );
  1305. if (! empty ( $receivablesMessage ))
  1306. $item += array (
  1307. 'receivablesMessage' => $receivablesMessage
  1308. );
  1309. if (! empty ( $receivablesBank ))
  1310. $item += array (
  1311. 'receivablesBank' => $receivablesBank
  1312. );
  1313. if (! empty ( $receivablesDate ))
  1314. $item += array (
  1315. 'receivablesDate' => $receivablesDate
  1316. );
  1317. $invoiceReceivables->setInvoiceReceivablesByCondition ( $item );
  1318. // 收款操作日志
  1319. $item = array ();
  1320. if ($receivablesCategory == 'PUBLIC' && $receivablesStaff == 'PUBLIC')
  1321. $item = array (
  1322. 'operation' => $this->staff [0] ['username'] . " 转入 公共待认领款项 "
  1323. );
  1324. elseif ($receivablesCategory != 'PUBLIC' && $receivablesStaff == 'PUBLIC')
  1325. $item = array (
  1326. 'operation' => $this->staff [0] ['username'] . "转入 办事处待认领款项"
  1327. );
  1328. elseif ($receivablesCategory != 'PUBLIC' && $receivablesStaff != 'PUBLIC') {
  1329. $receivablesStaff = explode ( '-', $receivablesStaff );
  1330. $item = array (
  1331. 'operation' => $this->staff [0] ['username'] . " 转入 " . $receivablesStaff [1]
  1332. );
  1333. }
  1334. $item += array (
  1335. 'date' => date ( "Y-m-d" ),
  1336. 'status' => 1,
  1337. 'img' => $this->staff [0] ['avatar'],
  1338. 'username' => $this->staff [0] ['username'],
  1339. 'uid' => $this->staff [0] ['sid'],
  1340. 'category' => $this->staff [0] ['category'],
  1341. 'irid' => $detail ['irid']
  1342. );
  1343. $invoiceROLog->setInvoiceROLog ( $item );
  1344. return '/invoiceReceivablesAS';
  1345. }
  1346. function invoiceReceivablesDelete() {
  1347. $claimKey = $this->get_args ( 'claimKey' ) ? $this->get_args ( 'claimKey' ) : "";
  1348. if (empty ( $claimKey ))
  1349. die ( 'illegal request' );
  1350. Doo::loadModel ( 'invoiceReceivables' );
  1351. $invoiceReceivables = new invoiceReceivables ();
  1352. $con = ' and iid=0 and bindStatus=0 and receivablesStaff="PUBLIC"';
  1353. $detail = $invoiceReceivables->getInvoiceReceivablesByIrid ( $claimKey, $con );
  1354. if (empty ( $detail ))
  1355. die ( 'illegal request' );
  1356. $invoiceReceivables->delInvoiceReceivablesByIrid ( $detail ['irid'] );
  1357. return '/invoiceReceivablesAS';
  1358. }
  1359. /**
  1360. * 管理员录入的收款 ,确认认领到谁的名下.统计收款金额
  1361. */
  1362. function invoiceReceivablesAscription() {
  1363. $irid = $this->get_args ( 'key' ) ? $this->get_args ( 'key' ) : "";
  1364. $recepitTitleMark = $this->get_args ( 'recepitTitleMark' ) ? $this->get_args ( 'recepitTitleMark' ) : "";
  1365. Doo::loadModel ( 'invoiceReceivables' );
  1366. $invoiceReceivables = new invoiceReceivables ();
  1367. Doo::loadModel ( 'invoiceROLog' );
  1368. $invoiceROLog = new invoiceROLog ();
  1369. Doo::loadModel ( 'invoiceStatistics' );
  1370. $invoiceStatistics = new invoiceStatistics ();
  1371. $detail = $invoiceReceivables->getInvoiceReceivablesByIrid ( $irid );
  1372. if (! empty ( $detail ) && $detail ['receivablesStaff'] == 'PUBLIC'&&!empty($recepitTitleMark)) {
  1373. $item = array (
  1374. 'irid' => $detail ['irid'],
  1375. 'receivablesCategory' => $this->staff [0] ['cid'] . ":" . $this->staff [0] ['category'],
  1376. 'receivablesStaff' => $this->staff [0] ['sid'] . "-" . $this->staff [0] ['username'],
  1377. 'confirmTime' => date ( "Y-m-d H:i:s" ),
  1378. 'recepitTitleMark' => $recepitTitleMark,
  1379. 'source' => 1
  1380. );
  1381. $invoiceReceivables->setInvoiceReceivablesByCondition ( $item );
  1382. $item = array (
  1383. 'date' => date ( "Y-m-d" ),
  1384. 'operation' => $this->staff [0] ['username'] . " 认领 ",
  1385. 'status' => 2,
  1386. 'img' => $this->staff [0] ['avatar'],
  1387. 'username' => $this->staff [0] ['username'],
  1388. 'uid' => $this->staff [0] ['sid'],
  1389. 'category' => $this->staff [0] ['category'],
  1390. 'irid' => $irid
  1391. );
  1392. $invoiceROLog->setInvoiceROLog ( $item );
  1393. $item = array (
  1394. 'cid' => $this->staff [0] ['cid'],
  1395. 'staff' => $this->staff [0] ['sid']
  1396. );
  1397. $invoiceStatistics->updateInvoiceStatisticsByIrid ( $item, $detail ['irid'] );
  1398. }
  1399. return "/invoiceReceivablesClaim";
  1400. }
  1401. /**
  1402. */
  1403. function invoiceMyReceivables() {
  1404. Doo::loadModel ( 'invoiceReceivables' );
  1405. $invoiceReceivables = new invoiceReceivables ();
  1406. Doo::loadModel ( 'invoiceStatistics' );
  1407. $invoiceStatistics = new invoiceStatistics ();
  1408. $isMonth = $invoiceStatistics->getStatisticsByMonth ();
  1409. $year = date ( "Y" );
  1410. $tmp_date = date ( "Ym" );
  1411. $tmp_year = substr ( $tmp_date, 0, 4 );
  1412. $tmp_mon = substr ( $tmp_date, 4, 2 );
  1413. $tmp_forwardmonth = mktime ( 0, 0, 0, $tmp_mon - 1, 1, $tmp_year );
  1414. $fm_forward_month = date ( "m", $tmp_forwardmonth );
  1415. $path = SITE_PATH . $this->INVOICECOLLECTPATH . "invoiceCollect_" . $year . "_" . $fm_forward_month . ".htm";
  1416. $htm = $this->showCache ( $path );
  1417. $list = $invoiceReceivables->getInvoiceReceivablesByClaim ( $this->staff [0] ['cid'], $this->staff [0] ['sid'] );
  1418. $this->data ['isMonth'] = $isMonth;
  1419. $this->data ['htm'] = $htm;
  1420. $this->data ['list'] = $list;
  1421. $this->data ['memu'] = "invoice";
  1422. $this->data ['staff'] = $this->staff;
  1423. $this->data ['receiptMemu'] = 'invoiceMyReceivables';
  1424. $this->render ( "/admin/invoiceMyReceivables", $this->data );
  1425. }
  1426. /**
  1427. * 收款绑定发票 ,一个收款只能绑定一个发票
  1428. */
  1429. function invoiceBindReceivables() {
  1430. $claimKey = $this->get_args ( 'key' ) ? $this->get_args ( 'key' ) : "";
  1431. $invoiceKey = $this->get_args ( 'invoiceKey' ) ? $this->get_args ( 'invoiceKey' ) : "";
  1432. Doo::loadModel ( 'invoice' );
  1433. $invoice = new invoice ();
  1434. Doo::loadModel ( 'invoiceReceivables' );
  1435. $invoiceReceivables = new invoiceReceivables ();
  1436. Doo::loadModel ( 'invoiceOperationLog' );
  1437. $invoiceOperationLog = new invoiceOperationLog ();
  1438. if (empty ( $invoiceKey ) || empty ( $claimKey ))
  1439. die ( 'illegal request' );
  1440. $detail = $invoice->getInvoiceByIid ( $invoiceKey );
  1441. $detailM = $invoiceReceivables->getInvoiceReceivablesByIrid ( $claimKey );
  1442. if (empty ( $detail ) && empty ( $detailM ))
  1443. die ( 'illegal request' );
  1444. if(!empty($detail['irid']))
  1445. die ( 'illegal request' );
  1446. // if ($detailM ['receivablesPrice'] >= $detail ['invoicePrice']) {
  1447. // $price = $detailM ['receivablesPrice'] - $detail ['invoicePrice'];
  1448. // die ( '<p>收款金额超出开票金额 ¥' . $price . '元,请谨慎操作</p><a href="/invoiceMyReceivables">返回</a>' );
  1449. // }
  1450. $item = array (
  1451. 'irid' => $detailM ['irid'],
  1452. 'bindStatus' => 1,
  1453. 'iid' => $detail ['iid'],
  1454. 'bindDate' => date ( "Y-m-d H:i:s" )
  1455. );
  1456. $invoiceReceivables->setInvoiceReceivablesByCondition ( $item );
  1457. $iridString = "";
  1458. if (empty ( $detail ['irid'] ))
  1459. $iridString = $detailM ['irid'];
  1460. else
  1461. $iridString = $detail ['irid'] . ',' . $detailM ['irid'];
  1462. $item = array (
  1463. 'iid' => $detail ['iid'],
  1464. 'irid' => $iridString
  1465. );
  1466. $invoice->setInvoiceByCondition ( $item );
  1467. // 操作日志
  1468. $item = array (
  1469. 'date' => date ( "Y-m-d H:i:s" ),
  1470. 'operation' => "收款" . $detailM ['receivablesSerial'] . "入账到发票" . $detail ['invoiceSerial'],
  1471. 'status' => 8,
  1472. 'img' => $this->staff [0] ['avatar'],
  1473. 'username' => $this->staff [0] ['username'],
  1474. 'uid' => $this->staff [0] ['sid'],
  1475. 'category' => $this->staff [0] ['category'],
  1476. 'iid' => $detail ['iid']
  1477. );
  1478. $invoiceOperationLog->setInvoiceOperationLog ( $item );
  1479. return "/invoiceReceivables";
  1480. }
  1481. /**
  1482. * 发票收款完成--需求更变 废弃
  1483. */
  1484. function invoiceEnterReceivables() {
  1485. $invoiceKey = $this->get_args ( 'key' ) ? $this->get_args ( 'key' ) : "";
  1486. // $invoiceClaim = $this->get_args ( 'invoiceClaim' ) ? $this->get_args ( 'invoiceClaim' ) : "";
  1487. Doo::loadModel ( 'invoice' );
  1488. $invoice = new invoice ();
  1489. Doo::loadModel ( 'invoiceOperationLog' );
  1490. $invoiceOperationLog = new invoiceOperationLog ();
  1491. Doo::loadModel ( 'invoiceStatistics' );
  1492. $invoiceStatistics = new invoiceStatistics ();
  1493. Doo::loadModel ( 'invoiceReceivables' );
  1494. $invoiceReceivables = new invoiceReceivables ();
  1495. $detail = $invoice->getInvoiceByIid ( $invoiceKey );
  1496. if (empty ( $detail ))
  1497. die ( 'illegal request' );
  1498. if (empty ( $detail ['irid'] ))
  1499. die ( 'illegal request' );
  1500. $item = array (
  1501. 'untreadStatus' => 3,
  1502. 'updateTime' => date ( "Y-m-d H:i:s" ),
  1503. 'iid' => $detail ['iid']
  1504. );
  1505. $invoice->setInvoiceByCondition ( $item );
  1506. // 操作日志
  1507. $item = array (
  1508. 'date' => date ( "Y-m-d H:i:s" ),
  1509. 'operation' => "发票" . $detail ['invoiceSerial'] . "收款完成",
  1510. 'status' => 9,
  1511. 'img' => $this->staff [0] ['avatar'],
  1512. 'username' => $this->staff [0] ['username'],
  1513. 'uid' => $this->staff [0] ['sid'],
  1514. 'category' => $this->staff [0] ['category'],
  1515. 'iid' => $detail ['iid']
  1516. );
  1517. $invoiceOperationLog->setInvoiceOperationLog ( $item );
  1518. $list = $invoiceReceivables->getInvoiceReceivablesInIridString ( $detail ['irid'] );
  1519. $accountPrice = 0;
  1520. foreach ( $list as $key => $value ) {
  1521. $accountPrice += $value ['receivablesPrice'];
  1522. }
  1523. $item = array (
  1524. 'date' => date ( "Y-m-d H:i:s" ),
  1525. 'priceClass' => 3,
  1526. 'cid' => $this->staff [0] ['cid'],
  1527. 'staff' => $this->staff [0] ['sid'],
  1528. 'accountPrice' => $accountPrice
  1529. );
  1530. $invoiceStatistics->setInvoiceStatisticsByCondition ( $item );
  1531. return "/invoice";
  1532. }
  1533. function invoiceAggregate() {
  1534. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  1535. Doo::loadModel ( 'invoiceStatistics' );
  1536. $invoiceStatistics = new invoiceStatistics ();
  1537. Doo::loadModel ( 'L_category' );
  1538. $Lcategory = new L_category ();
  1539. $isList = $invoiceStatistics->getInvoiceStatisticsByYear ( $year );
  1540. $LcategoryList = $Lcategory->getCategory ();
  1541. // print_r($isList);
  1542. $html = ""; // $invoicePriceCategory=0;$receivablesPriceCategory=0;$accountPriceCategory=0;
  1543. foreach ( $LcategoryList as $key => $value ) {
  1544. $html .= '<tr><th><a href="/invoiceAggregateCategory/' . $value ['cidKey'] . '">' . $value ['title'] . '</a></th>';
  1545. $month = 1;
  1546. $invoicePriceYear = 0;
  1547. $receivablesPriceYear = 0;
  1548. $accountPriceYear = 0;
  1549. for(; $month <= 12; $month ++) {
  1550. $flag = true;
  1551. foreach ( $isList ['statisticsMonthCid'] as $k => $v ) {
  1552. if ($value ['cid'] == $v ['cid'] && $month == $v ['month']) {
  1553. $html .= '<td class="taR">¥' . $v ['invoicePrice'] . '</td>
  1554. <td class="taR">¥' . $v ['receivablesPrice'] . '</td>
  1555. <td class="taR"><b>¥' . $v ['accountPrice'] . '</b></td>
  1556. ';
  1557. $invoicePriceYear += $v ['invoicePrice'];
  1558. $receivablesPriceYear += $v ['receivablesPrice'];
  1559. $accountPriceYear += $v ['accountPrice'];
  1560. $flag = false;
  1561. break;
  1562. }
  1563. }
  1564. if ($flag)
  1565. $html .= '<td class="taR"></td>
  1566. <td class="taR"></td>
  1567. <td class="taR"><b></b></td>
  1568. ';
  1569. }
  1570. $html .= '<td class="taR colRed">' . $invoicePriceYear . '</td>
  1571. <td class="taR colOrange">' . $receivablesPriceYear . '</td>
  1572. <td class="taR colGreen"><b>' . $accountPriceYear . '</b></td>
  1573. ';
  1574. $html .= '</tr>';
  1575. }
  1576. $html .= '<tr><th><b class="colGreen">月合计</b></th>';
  1577. $invoicePriceYear = 0;
  1578. $receivablesPriceYear = 0;
  1579. $accountPriceYear = 0;
  1580. for($month = 1; $month <= 12; $month ++) {
  1581. $flag = true;
  1582. foreach ( $isList ['statisticsMonth'] as $k => $v ) {
  1583. if ($month == $v ['month']) {
  1584. $html .= '<td class="taR">¥' . $v ['invoicePrice'] . '</td>
  1585. <td class="taR">¥' . $v ['receivablesPrice'] . '</td>
  1586. <td class="taR"><b>¥' . $v ['accountPrice'] . '</b></td>
  1587. ';
  1588. $invoicePriceYear += $v ['invoicePrice'];
  1589. $receivablesPriceYear += $v ['receivablesPrice'];
  1590. $accountPriceYear += $v ['accountPrice'];
  1591. $flag = false;
  1592. break;
  1593. }
  1594. if ($flag)
  1595. $html .= '<td class="taR"></td>
  1596. <td class="taR"></td>
  1597. <td class="taR"><b></b></td>
  1598. ';
  1599. }
  1600. }
  1601. $html .= '<td class="taR colRed">' . $invoicePriceYear . '</td>
  1602. <td class="taR colOrange">' . $receivablesPriceYear . '</td>
  1603. <td class="taR colGreen"><b>' . $accountPriceYear . '</b></td>
  1604. ';
  1605. $html .= '</tr>';
  1606. $this->data ['html'] = $html;
  1607. $this->data ['LcategoryList'] = $LcategoryList;
  1608. $this->data ['isList'] = $isList;
  1609. $this->data ['year'] = $year;
  1610. $this->data ['memu'] = "invoice";
  1611. $this->data ['staff'] = $this->staff;
  1612. $this->data ['receiptMemu'] = 'invoiceAggregate';
  1613. $this->render ( "/admin/invoiceAggregate", $this->data );
  1614. }
  1615. function invoiceAggregateStaff() {
  1616. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  1617. Doo::loadModel ( 'invoiceStatistics' );
  1618. $invoiceStatistics = new invoiceStatistics ();
  1619. Doo::loadModel ( 'L_category' );
  1620. $Lcategory = new L_category ();
  1621. $toteList = $invoiceStatistics->getInvoiceStatisticsByTote ( $year );
  1622. $staffList = $invoiceStatistics->getInvoiceStatisticsByStaff ( $year );
  1623. $cStaff = $Lcategory->getCategoryStaff ();
  1624. $html = '';
  1625. foreach ( $cStaff as $key => $value ) {
  1626. $categoryFir = true;
  1627. foreach ( $value ['staff'] as $k => $v ) {
  1628. if ($categoryFir) {
  1629. $width = count ( $value ['staff'] ) + 1;
  1630. $html .= '<tr><th rowspan="' . $width . '">' . $value ['title'] . ' </th>';
  1631. $categoryFir = false;
  1632. } else
  1633. $html .= '<tr>';
  1634. $html .= '<th>' . $v ['username'] . '</th>';
  1635. $invoicePriceStaffYear = 0;
  1636. $receivablesPriceStaffYear = 0;
  1637. $accountPriceStaffYear = 0;
  1638. for($month = 1; $month <= 12; $month ++) {
  1639. $flag = true;
  1640. foreach ( $staffList ['statisticsMonthStaff'] as $sl => $slv ) {
  1641. if ($v ['sid'] == $slv ['staff'] && $month == $slv ['month']) {
  1642. $html .= '<td class="taR">¥' . $slv ['invoicePrice'] . '</td>
  1643. <td class="taR">¥' . $slv ['receivablesPrice'] . '</td>
  1644. <td class="taR"><b>¥' . $slv ['accountPrice'] . '</b></td>
  1645. ';
  1646. $invoicePriceStaffYear += $slv ['invoicePrice'];
  1647. $receivablesPriceStaffYear += $slv ['receivablesPrice'];
  1648. $accountPriceStaffYear += $slv ['accountPrice'];
  1649. $flag = false;
  1650. break;
  1651. }
  1652. }
  1653. if ($flag)
  1654. $html .= '<td class="taR"></td>
  1655. <td class="taR"></td>
  1656. <td class="taR"><b></b></td>
  1657. ';
  1658. }
  1659. $html .= '<td class="taR colRed">' . $invoicePriceStaffYear . '</td>
  1660. <td class="taR colOrange">' . $receivablesPriceStaffYear . '</td>
  1661. <td class="taR colGreen"><b>' . $accountPriceStaffYear . '</b></td>
  1662. ';
  1663. }
  1664. $html .= '</tr>';
  1665. // 小计
  1666. if (! empty ( $value ['staff'] )) {
  1667. $html .= '<tr><th class="taR">小计</th>';
  1668. $invoicePriceStaffYear = 0;
  1669. $receivablesPriceStaffYear = 0;
  1670. $accountPriceStaffYear = 0;
  1671. for($month = 1; $month <= 12; $month ++) {
  1672. $flag = true;
  1673. foreach ( $staffList ['statisticsMonthCid'] as $smc => $smcv ) {
  1674. if ($value ['cid'] == $smcv ['cid'] && $month == $slv ['month']) {
  1675. $html .= '<td class="taR">¥' . $smcv ['invoicePrice'] . '</td>
  1676. <td class="taR">¥' . $smcv ['receivablesPrice'] . '</td>
  1677. <td class="taR"><b>¥' . $smcv ['accountPrice'] . '</b></td>
  1678. ';
  1679. $invoicePriceStaffYear += $slv ['invoicePrice'];
  1680. $receivablesPriceStaffYear += $slv ['receivablesPrice'];
  1681. $accountPriceStaffYear += $slv ['accountPrice'];
  1682. $flag = false;
  1683. break;
  1684. }
  1685. }
  1686. if ($flag)
  1687. $html .= '<td class="taR"></td>
  1688. <td class="taR"></td>
  1689. <td class="taR"><b></b></td>
  1690. ';
  1691. }
  1692. $html .= '<td class="taR colRed">' . $invoicePriceStaffYear . '</td>
  1693. <td class="taR colOrange">' . $receivablesPriceStaffYear . '</td>
  1694. <td class="taR colGreen"><b>' . $accountPriceStaffYear . '</b></td>
  1695. ';
  1696. $html .= '</tr>';
  1697. }
  1698. }
  1699. $html .= '<tr class="warning"><th colspan="2"><b class="colGreen" >月合计</b></th>';
  1700. $invoicePriceYear = 0;
  1701. $receivablesPriceYear = 0;
  1702. $accountPriceYear = 0;
  1703. for($month = 1; $month <= 12; $month ++) {
  1704. $flag = true;
  1705. foreach ( $staffList ['statisticsMonth'] as $k => $v ) {
  1706. if ($month == $v ['month']) {
  1707. $html .= '<td class="taR colRed">¥' . $v ['invoicePrice'] . '</td>
  1708. <td class="taR colOrange">¥' . $v ['receivablesPrice'] . '</td>
  1709. <td class="taR colGreen"><b>¥' . $v ['accountPrice'] . '</b></td>
  1710. ';
  1711. $invoicePriceYear += $v ['invoicePrice'];
  1712. $receivablesPriceYear += $v ['receivablesPrice'];
  1713. $accountPriceYear += $v ['accountPrice'];
  1714. $flag = false;
  1715. break;
  1716. }
  1717. if ($flag)
  1718. $html .= '<td class="taR"></td>
  1719. <td class="taR"></td>
  1720. <td class="taR"><b></b></td>
  1721. ';
  1722. }
  1723. }
  1724. $html .= '<td class="taR colRed">' . $invoicePriceYear . '</td>
  1725. <td class="taR colOrange">' . $receivablesPriceYear . '</td>
  1726. <td class="taR colGreen"><b>' . $accountPriceYear . '</b></td>
  1727. ';
  1728. $html .= '</tr>';
  1729. $this->data ['html'] = $html;
  1730. $this->data ['isList'] = $toteList;
  1731. $this->data ['year'] = $year;
  1732. $this->data ['memu'] = "invoice";
  1733. $this->data ['staff'] = $this->staff;
  1734. $this->data ['receiptMemu'] = 'invoiceAggregate';
  1735. $this->render ( "/admin/invoiceAggregateStaff", $this->data );
  1736. }
  1737. function invoiceAggregateCategory() {
  1738. Doo::loadClass ( 'XDeode' );
  1739. $XDeode = new XDeode ( 5 );
  1740. $cid = $cidKey = isset ( $this->params ['cid'] ) ? $this->params ['cid'] : "";
  1741. $cid = $XDeode->decode ( $cid );
  1742. if (! is_numeric ( $cid ))
  1743. die ( 'illegal request' );
  1744. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  1745. Doo::loadModel ( 'invoiceStatistics' );
  1746. $invoiceStatistics = new invoiceStatistics ();
  1747. Doo::loadModel ( 'staff' );
  1748. $staff = new staff ();
  1749. $list = $staff->getStaffByCid ( $cid );
  1750. $isCategory = $invoiceStatistics->getInvoiceStatisticsByStaff ( $year, $cid );
  1751. $toteList = $invoiceStatistics->getInvoiceStatisticsByTote ( $year, $cid );
  1752. if (empty ( $list ))
  1753. die ( '该办事处没有成员' );
  1754. $htmlA = $htmlB = $htmlC = $html = '';
  1755. foreach ( $list as $key => $value ) {
  1756. $htmlA = '<tr><th rowspan="3">' . $value ['username'] . '</th><th class="taC">开票</th>';
  1757. $htmlB = '<tr><th class="taC">收款</th>';
  1758. $htmlC = '<tr><th class="taC">入账</th>';
  1759. $invoicePriceStaffYear = 0;
  1760. $receivablesPriceStaffYear = 0;
  1761. $accountPriceStaffYear = 0;
  1762. for($month = 1; $month <= 12; $month ++) {
  1763. $flag = true;
  1764. foreach ( $isCategory ['statisticsMonthStaff'] as $k => $v ) {
  1765. if ($value ['sid'] == $v ['staff'] && $month == $v ['month']) {
  1766. $htmlA .= '<td class="taR">¥' . $v ['invoicePrice'] . '</td>';
  1767. $htmlB .= '<td class="taR">¥' . $v ['receivablesPrice'] . '</td>';
  1768. $htmlC .= '<td class="taR"><b>¥' . $v ['accountPrice'] . '</b></td>';
  1769. $invoicePriceStaffYear += $v ['invoicePrice'];
  1770. $receivablesPriceStaffYear += $v ['receivablesPrice'];
  1771. $accountPriceStaffYear += $v ['accountPrice'];
  1772. $flag = false;
  1773. break;
  1774. }
  1775. }
  1776. if ($flag) {
  1777. $htmlA .= '<td class="taR">-</td>';
  1778. $htmlB .= '<td class="taR">-</td>';
  1779. $htmlC .= '<td class="taR"><b>-</b></td>';
  1780. }
  1781. }
  1782. $htmlA .= '<td class="taR colRed">' . $invoicePriceStaffYear . '</td>';
  1783. $htmlB .= '<td class="taR colOrange">' . $receivablesPriceStaffYear . '</td>';
  1784. $htmlC .= '<td class="taR colGreen"><b>' . $accountPriceStaffYear . '</b></td>';
  1785. $htmlA .= '</tr>';
  1786. $htmlB .= '</tr>';
  1787. $htmlC .= '</tr>';
  1788. $html .= $htmlA . $htmlB . $htmlC;
  1789. }
  1790. $htmlA = $htmlB = $htmlC = "";
  1791. $htmlA = '<tr><th rowspan="3">月合计</th><th class="taC">开票</th>';
  1792. $htmlB = '<tr><th class="taC">收款</th>';
  1793. $htmlC = '<tr><th class="taC">入账</th>';
  1794. $invoicePriceStaffYear = 0;
  1795. $receivablesPriceStaffYear = 0;
  1796. $accountPriceStaffYear = 0;
  1797. for($month = 1; $month <= 12; $month ++) {
  1798. $flag = true;
  1799. foreach ( $isCategory ['statisticsMonth'] as $k => $v ) {
  1800. if ($month == $v ['month']) {
  1801. $htmlA .= '<td class="taR colRed">¥' . $v ['invoicePrice'] . '</td>';
  1802. $htmlB .= '<td class="taR colOrange">¥' . $v ['receivablesPrice'] . '</td>';
  1803. $htmlC .= '<td class="taR colGreen"><b>¥' . $v ['accountPrice'] . '</b></td>';
  1804. $invoicePriceStaffYear += $v ['invoicePrice'];
  1805. $receivablesPriceStaffYear += $v ['receivablesPrice'];
  1806. $accountPriceStaffYear += $v ['accountPrice'];
  1807. $flag = false;
  1808. break;
  1809. }
  1810. }
  1811. if ($flag) {
  1812. $htmlA .= '<td class="taR">-</td>';
  1813. $htmlB .= '<td class="taR">-</td>';
  1814. $htmlC .= '<td class="taR"><b>-</b></td>';
  1815. }
  1816. }
  1817. $htmlA .= '<td class="taR colRed">' . $invoicePriceStaffYear . '</td>';
  1818. $htmlB .= '<td class="taR colOrange">' . $receivablesPriceStaffYear . '</td>';
  1819. $htmlC .= '<td class="taR colGreen"><b>' . $accountPriceStaffYear . '</b></td>';
  1820. $htmlA .= '</tr>';
  1821. $htmlB .= '</tr>';
  1822. $htmlC .= '</tr>';
  1823. $html .= $htmlA . $htmlB . $htmlC;
  1824. $this->data ['html'] = $html;
  1825. $this->data ['cidKey'] = $cidKey;
  1826. $this->data ['slist'] = $list;
  1827. $this->data ['isList'] = $toteList;
  1828. $this->data ['year'] = $year;
  1829. $this->data ['memu'] = "invoice";
  1830. $this->data ['staff'] = $this->staff;
  1831. $this->data ['receiptMemu'] = 'invoiceAggregate';
  1832. $this->render ( "/admin/invoiceAggregateCategory", $this->data );
  1833. }
  1834. function invoiceAchieve() {
  1835. Doo::loadModel ( 'invoice' );
  1836. $invoice = new invoice ();
  1837. Doo::loadClass ( 'XDeode' );
  1838. $XDeode = new XDeode ( 5 );
  1839. $sid = $XDeode->decode ( $_COOKIE ["staff"] );
  1840. $MebSea = isset ( $this->params ['MebSea'] ) ? urldecode ( $this->params ['MebSea'] ) : '';
  1841. $page_size = 18;
  1842. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  1843. $date = isset ( $this->params ['date'] ) ? $this->params ['date'] : 'MONTHO';
  1844. $get = "/" . $date;
  1845. $con = '';
  1846. if ($date == 'MONTHO')
  1847. $con = ' and updateTime>DATE_SUB(CURDATE(), INTERVAL 1 MONTH)';
  1848. elseif ($date == 'MONTHT')
  1849. $con = ' and updateTime>DATE_SUB(CURDATE(), INTERVAL 3 MONTH)';
  1850. elseif ($date == 'MONTHY')
  1851. $con = ' and updateTime>DATE_SUB(CURDATE(), INTERVAL 1 YEAR)';
  1852. if (! empty ( $MebSea )) {
  1853. $con .= ' and ( invoiceTitle like "%' . $MebSea . '%" or invoiceCompany like "%' . $MebSea . '%" or invoicePrice like "%' . $MebSea . '%" )';
  1854. $get .= "/" . $MebSea;
  1855. }
  1856. $pageinfo ['page'] = array (
  1857. 'previous' => ''
  1858. );
  1859. $sql = 'status=2 and untreadStatus=3 and sid=' . $sid . $con;
  1860. $pageinfo = $this->get_page ( "CLD_invoice", $sql, $page, $page_size, "invoiceAchieve", $get, "" );
  1861. $limit = $pageinfo ['lower'] . ',' . $page_size;
  1862. $list = $invoice->getInvoiceByUntreadStatusPage ( $limit, $sql );
  1863. // print_r($pageinfo);
  1864. $this->data ['MebSeaEn'] = $MebSea;
  1865. $this->data ['MebSea'] = urlencode ( $MebSea );
  1866. $this->data ['get'] = $get;
  1867. $this->data ['page'] = $pageinfo;
  1868. $this->data ['list'] = $list;
  1869. $this->data ['date'] = $date;
  1870. $this->data ['memu'] = "invoice";
  1871. $this->data ['staff'] = $this->staff;
  1872. $this->data ['receiptMemu'] = 'invoice';
  1873. $this->render ( "/admin/invoiceAchieve", $this->data );
  1874. }
  1875. function invoiceReceivablesAchieve() {
  1876. Doo::loadModel ( 'invoiceReceivables' );
  1877. $invoiceReceivables = new invoiceReceivables ();
  1878. Doo::loadClass ( 'XDeode' );
  1879. $XDeode = new XDeode ( 5 );
  1880. $sid = $XDeode->decode ( $_COOKIE ["staff"] );
  1881. $MebSea = isset ( $this->params ['MebSea'] ) ? urldecode ( $this->params ['MebSea'] ) : '';
  1882. $page_size = 1;
  1883. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  1884. $date = isset ( $this->params ['date'] ) ? $this->params ['date'] : 'MONTHO';
  1885. $get = "/" . $date;
  1886. $con = '';
  1887. if ($date == 'MONTHO')
  1888. $con = ' and bindDate>DATE_SUB(CURDATE(), INTERVAL 1 MONTH)';
  1889. elseif ($date == 'MONTHT')
  1890. $con = ' and bindDate>DATE_SUB(CURDATE(), INTERVAL 3 MONTH)';
  1891. elseif ($date == 'MONTHY')
  1892. $con = ' and bindDate>DATE_SUB(CURDATE(), INTERVAL 1 YEAR)';
  1893. if (! empty ( $MebSea )) {
  1894. $con .= ' and ( receivablesMessage like "%' . $MebSea . '%" or receivablesPrice like "%' . $MebSea . '%" )';
  1895. $get .= "/" . $MebSea;
  1896. }
  1897. $pageinfo ['page'] = array (
  1898. 'previous' => ''
  1899. );
  1900. $sql = " bindStatus=1 and receivablesStaff like '" . $sid . "_%' " . $con;
  1901. $pageinfo = $this->get_page ( "CLD_invoiceReceivables", $sql, $page, $page_size, "invoiceReceivablesAchieve", $get, "" );
  1902. $limit = $pageinfo ['lower'] . ',' . $page_size;
  1903. $list = $invoiceReceivables->getReceivablesByUntreadStatusPage ( $limit, $sql );
  1904. // print_r($pageinfo);
  1905. $this->data ['MebSeaEn'] = $MebSea;
  1906. $this->data ['MebSea'] = urlencode ( $MebSea );
  1907. $this->data ['get'] = $get;
  1908. $this->data ['page'] = $pageinfo;
  1909. $this->data ['list'] = $list;
  1910. $this->data ['date'] = $date;
  1911. $this->data ['memu'] = "invoice";
  1912. $this->data ['staff'] = $this->staff;
  1913. $this->data ['receiptMemu'] = 'invoiceMyReceivables';
  1914. $this->render ( "/admin/invoiceReceivablesAchieve", $this->data );
  1915. }
  1916. function invoiceReceivablesAS() {
  1917. Doo::loadModel ( 'invoiceReceivables' );
  1918. $invoiceReceivables = new invoiceReceivables ();
  1919. $MebSea = isset ( $this->params ['MebSea'] ) ? addslashes ( urldecode ( $this->params ['MebSea'] ) ) : '';
  1920. $page_size = 12;
  1921. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  1922. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : 'All';
  1923. $year = isset ( $this->params ['year'] ) && is_numeric ( $this->params ['year'] ) ? $this->params ['year'] : date ( 'Y' );
  1924. $month = isset ( $this->params ['month'] ) && is_numeric ( $this->params ['month'] ) ? $this->params ['month'] : "All";
  1925. $con = "Year(date) =" . $year;
  1926. if ($month != "All")
  1927. $con = "Year(date) =" . $year . " and Month(date) = " . $month;
  1928. if ($status == 'Unclaimed')
  1929. $con .= ' and bindStatus=0';
  1930. elseif ($status == 'Credited')
  1931. $con .= ' and bindStatus=1';
  1932. $get = "/" . $status . "/" . $year . "/" . $month;
  1933. if (! empty ( $MebSea )) {
  1934. $con .= ' and ( receivablesMessage like "%' . $MebSea . '%" or receivablesPrice like "%' . $MebSea . '%" )';
  1935. $get .= "/" . $MebSea;
  1936. }
  1937. $pageinfo ['page'] = array (
  1938. 'previous' => ''
  1939. );
  1940. $pageinfo = $this->get_page ( "CLD_invoiceReceivables", $con, $page, $page_size, "invoiceReceivablesAS", $get, "" );
  1941. $limit = $pageinfo ['lower'] . ',' . $page_size;
  1942. $list = $invoiceReceivables->getReceivablesByUntreadStatusPage ( $limit, $con );
  1943. // print_r($pageinfo);
  1944. $mothHtml = "";
  1945. for($i = 1; $i <= 12; $i ++) {
  1946. if ($month == $i)
  1947. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  1948. else
  1949. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  1950. }
  1951. $this->data ['MebSeaEn'] = $MebSea;
  1952. $this->data ['MebSea'] = urlencode ( $MebSea );
  1953. $this->data ['mothHtml'] = $mothHtml;
  1954. $this->data ['year'] = $year;
  1955. $this->data ['month'] = $month;
  1956. $this->data ['page'] = $pageinfo;
  1957. $this->data ['get'] = $get;
  1958. $this->data ['list'] = $list;
  1959. $this->data ['status'] = $status;
  1960. $this->data ['memu'] = "invoice";
  1961. $this->data ['staff'] = $this->staff;
  1962. $this->data ['receiptMemu'] = 'invoiceReceivables';
  1963. $this->render ( "/admin/invoiceReceivablesAS", $this->data );
  1964. }
  1965. function invoiceApprovalAchieve() {
  1966. Doo::loadModel ( 'invoice' );
  1967. $invoice = new invoice ();
  1968. $MebSea = isset ( $this->params ['MebSea'] ) ? urldecode ( $this->params ['MebSea'] ) : '';
  1969. $page_size = 2;
  1970. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  1971. $date = isset ( $this->params ['date'] ) ? $this->params ['date'] : 'MONTHO';
  1972. $get = "/" . $date;
  1973. $con = '';
  1974. if ($date == 'MONTHO')
  1975. $con = ' and updateTime>DATE_SUB(CURDATE(), INTERVAL 1 MONTH)';
  1976. elseif ($date == 'MONTHT')
  1977. $con = ' and updateTime>DATE_SUB(CURDATE(), INTERVAL 3 MONTH)';
  1978. elseif ($date == 'MONTHY')
  1979. $con = ' and updateTime>DATE_SUB(CURDATE(), INTERVAL 1 YEAR)';
  1980. if (! empty ( $MebSea )) {
  1981. $con .= ' and ( invoiceTitle like "%' . $MebSea . '%" or invoiceCompany like "%' . $MebSea . '%" or invoicePrice like "%' . $MebSea . '%" )';
  1982. $get .= "/" . $MebSea;
  1983. }
  1984. $pageinfo ['page'] = array (
  1985. 'previous' => ''
  1986. );
  1987. $sql = '(status=1 or status=3 or status=4) and processApprovals!=""' . $con;
  1988. $pageinfo = $this->get_page ( "CLD_invoice", $sql, $page, $page_size, "invoiceApprovalAchieve", $get, "" );
  1989. $limit = $pageinfo ['lower'] . ',' . $page_size;
  1990. $list = $invoice->getInvoiceByUntreadStatusPage ( $limit, $sql );
  1991. // print_r($list);
  1992. $this->data ['MebSeaEn'] = $MebSea;
  1993. $this->data ['MebSea'] = urlencode ( $MebSea );
  1994. $this->data ['get'] = $get;
  1995. $this->data ['page'] = $pageinfo;
  1996. $this->data ['list'] = $list;
  1997. $this->data ['date'] = $date;
  1998. $this->data ['memu'] = "invoice";
  1999. $this->data ['staff'] = $this->staff;
  2000. $this->data ['receiptMemu'] = 'invoiceApproval';
  2001. $this->render ( "/admin/invoiceApprovalAchieve", $this->data );
  2002. }
  2003. function invoiceTAchieve() {
  2004. Doo::loadModel ( 'invoice' );
  2005. $invoice = new invoice ();
  2006. Doo::loadClass ( 'XDeode' );
  2007. $XDeode = new XDeode ( 5 );
  2008. Doo::loadModel ( 'staff' );
  2009. $staff = new staff ();
  2010. $MebSea = isset ( $this->params ['MebSea'] ) ? urldecode ( $this->params ['MebSea'] ) : '';
  2011. $page_size = 2;
  2012. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  2013. $date = isset ( $this->params ['date'] ) ? $this->params ['date'] : 'MONTHO';
  2014. $get = "/" . $date;
  2015. $con = '';
  2016. if ($date == 'MONTHO')
  2017. $con = ' and updateTime>DATE_SUB(CURDATE(), INTERVAL 1 MONTH)';
  2018. elseif ($date == 'MONTHT')
  2019. $con = ' and updateTime>DATE_SUB(CURDATE(), INTERVAL 3 MONTH)';
  2020. elseif ($date == 'MONTHY')
  2021. $con = ' and updateTime>DATE_SUB(CURDATE(), INTERVAL 1 YEAR)';
  2022. if (! empty ( $MebSea )) {
  2023. $con .= ' and ( invoiceTitle like "%' . $MebSea . '%" or invoiceCompany like "%' . $MebSea . '%" or invoicePrice like "%' . $MebSea . '%" )';
  2024. $get .= "/" . $MebSea;
  2025. }
  2026. $pageinfo ['page'] = array (
  2027. 'previous' => ''
  2028. );
  2029. $sql = "";
  2030. $action = "";
  2031. if ($this->ACTION == 'invoicePrintAchieve') {
  2032. $sql = "status=2 and printStatus=1 and moldManage like '%[\"" . $this->staff [0] ['sid'] . "\",%'" . $con;
  2033. $action = "invoicePrintAchieve";
  2034. } elseif ($this->ACTION == 'invoicePostAchieve') {
  2035. // and untreadStatus=0
  2036. $sql = "postStatus=1 and doPost=1 and status=2 and isDelete=0" . $con;
  2037. $action = "invoicePostAchieve";
  2038. } elseif ($this->ACTION == 'invoiceUntreadAchieve') {
  2039. $sql = " printStatus=1 and untreadStatus=2 and status=2 " . $con;
  2040. $action = "invoiceUntreadAchieve";
  2041. }
  2042. $pageinfo = $this->get_page ( "CLD_invoice", $sql, $page, $page_size, $action, $get, "" );
  2043. $limit = $pageinfo ['lower'] . ',' . $page_size;
  2044. $list = $invoice->getInvoiceByUntreadStatusPage ( $limit, $sql );
  2045. $this->data ['MebSeaEn'] = $MebSea;
  2046. $this->data ['MebSea'] = urlencode ( $MebSea );
  2047. $this->data ['get'] = $get;
  2048. $this->data ['page'] = $pageinfo;
  2049. $this->data ['date'] = $date;
  2050. $this->data ['memu'] = "invoice";
  2051. $this->data ['staff'] = $this->staff;
  2052. if ($this->ACTION == 'invoicePrintAchieve') {
  2053. foreach ( $list as $key => $value ) {
  2054. $list [$key] ['iidKey'] = $XDeode->encode ( $value ['iid'] );
  2055. $lastApprover = json_decode ( $value ['processApprovals'], true );
  2056. if (! empty ( $lastApprover )) {
  2057. $lastApproverKey = array_keys ( $lastApprover );
  2058. $lastApprover = end ( $lastApprover );
  2059. $staffDetail = $staff->getOne ( array (
  2060. 'where' => 'sid=' . end ( $lastApproverKey ),
  2061. 'asArray' => true
  2062. ) );
  2063. $lastApprover ['username'] = $staffDetail ['username'];
  2064. }
  2065. $list [$key] ['lastApprover'] = $lastApprover;
  2066. }
  2067. $this->data ['receiptMemu'] = 'invoicePrint';
  2068. $this->data ['list'] = $list;
  2069. $this->render ( "/admin/invoicePrintAchieve", $this->data );
  2070. } elseif ($this->ACTION == 'invoicePostAchieve') {
  2071. Doo::loadModel ( 'express' );
  2072. $express = new express ();
  2073. $expressList = $express->getExpressByAll ();
  2074. $this->data ['expressList'] = $expressList;
  2075. $this->data ['receiptMemu'] = 'invoicePost';
  2076. $this->data ['list'] = $list;
  2077. $this->render ( "/admin/invoicePostAchieve", $this->data );
  2078. } elseif ($this->ACTION == 'invoiceUntreadAchieve') {
  2079. $this->data ['receiptMemu'] = 'invoiceUntread';
  2080. $this->data ['list'] = $list;
  2081. $this->render ( "/admin/invoiceUntreadAchieve", $this->data );
  2082. }
  2083. }
  2084. /**
  2085. * 获得与我有关可收款的发票
  2086. */
  2087. function ajaxGetInvoiceByStaff() {
  2088. $irid = $this->get_args ( 'key' ) ? $this->get_args ( 'key' ) : "";
  2089. Doo::loadModel ( 'invoice' );
  2090. $invoice = new invoice ();
  2091. $list = $invoice->getInvoiceByReceivables ( $this->staff [0] ['sid'] );
  2092. $html = "";
  2093. $i = 1;
  2094. foreach ( $list as $key => $value ) {
  2095. $html .= '<tr>
  2096. <td>' . $value ['invoiceElement'] . '</td>
  2097. <td>¥' . $value ['invoicePrice'] . '</td>';
  2098. if (! empty ( $value ['invoiceType'] )) {
  2099. $html .= '<td>增值税专用发票</td>
  2100. <td>' . $value ['invoiceCompany'] . '</td>';
  2101. } else {
  2102. $html .= '<td>增值税普通发票</td>
  2103. <td>' . $value ['invoiceTitle'] . '</td>';
  2104. }
  2105. $html .= '<td><label><input type="radio" node-Claim="true_' . $i . '" p-data="' . $value ['iidKey'] . '" name="invoiceClaim"> 使用Ta</label></td></tr>
  2106. <script>
  2107. $(\'input[node-Claim="true_' . $i . '"]\').click(function() {
  2108. var invoiceKey= $(this).attr("p-data");
  2109. var claimKey=$("input[name=\'key\']").val();
  2110. $("p[node-msg=\"true\"]").hide();
  2111. var url = "/ajaxCompareInvoicePrice";
  2112. $.ajax({
  2113. url : url,
  2114. type : "post",
  2115. cache : false,
  2116. dataType : "json",
  2117. data : {
  2118. claimKey : claimKey,
  2119. invoiceKey:invoiceKey
  2120. },
  2121. global : true,
  2122. success : function(data) {
  2123. $("input[name=\'invoiceKey\']").val("' . $value ['iidKey'] . '");
  2124. if (data.status == 1) {
  2125. $("p[node-msg=\"true\"]").html("收款金额超出开票金额 ¥"+data.price+"元,请谨慎操作。");
  2126. $("p[node-msg=\"true\"]").show();
  2127. }
  2128. },
  2129. error : function(err) {
  2130. }
  2131. });
  2132. });
  2133. </script>
  2134. ';
  2135. $i ++;
  2136. }
  2137. echo json_encode ( array (
  2138. 'status' => 1,
  2139. 'html' => $html
  2140. ) );
  2141. }
  2142. /**
  2143. * 获取一条收款信息
  2144. */
  2145. function ajaxGetInvoiceReceivables() {
  2146. $irid = $this->get_args ( 'key' ) ? $this->get_args ( 'key' ) : "";
  2147. Doo::loadModel ( 'invoiceReceivables' );
  2148. $invoiceReceivables = new invoiceReceivables ();
  2149. $detail = $invoiceReceivables->getInvoiceReceivablesByIrid ( $irid );
  2150. echo json_encode ( array (
  2151. 'status' => 1,
  2152. 'detail' => $detail
  2153. ) );
  2154. }
  2155. /**
  2156. * 异步获取办事处用户
  2157. */
  2158. function ajaxGetStaffByCategory() {
  2159. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : "";
  2160. Doo::loadModel ( 'staff' );
  2161. $staff = new staff ();
  2162. if ($cid == "PUBLIC") {
  2163. echo json_encode ( array (
  2164. 'status' => 1,
  2165. 'html' => '<option value="PUBLIC">办事处待认领款项</option>'
  2166. ) );
  2167. die ();
  2168. }
  2169. if (! is_numeric ( $cid )) {
  2170. echo json_encode ( array (
  2171. 'status' => 0,
  2172. 'msg' => 'illegal request'
  2173. ) );
  2174. die ();
  2175. }
  2176. $staffList = $staff->getStaffByCid ( $cid );
  2177. $html = '<option value="PUBLIC">办事处待认领款项</option>';
  2178. foreach ( $staffList as $key => $value ) {
  2179. $html .= '<option value="' . $value ['sid'] . '-' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  2180. }
  2181. echo json_encode ( array (
  2182. 'status' => 1,
  2183. 'html' => $html
  2184. ) );
  2185. }
  2186. /**
  2187. * 异步获取一条发票的邮寄信息
  2188. */
  2189. function ajaxGetInvoicePostDetail() {
  2190. $iid = $this->get_args ( 'iidKey' ) ? $this->get_args ( 'iidKey' ) : "";
  2191. Doo::loadModel ( 'invoice' );
  2192. $invoice = new invoice ();
  2193. $iid = $invoice->authcode ( $iid );
  2194. Doo::loadModel ( 'express' );
  2195. $express = new express ();
  2196. $expressList = $express->getExpressByAll ();
  2197. if (! is_numeric ( $iid )) {
  2198. echo json_encode ( array (
  2199. 'status' => 0,
  2200. 'msg' => 'illegal request'
  2201. ) );
  2202. die ();
  2203. }
  2204. $select = "iid,recipients,recipientsPhone,recipientsAddress,mailItems,expressCompany,expressNumber,actualItems";
  2205. $invoiceDetail = $invoice->getInvoiceByIid ( $iid, $select );
  2206. $html = "";
  2207. foreach ( $expressList as $key => $value ) {
  2208. if ($value ['company'] == $invoiceDetail ['expressCompany'])
  2209. $html .= '<option selected value="' . $value ['company'] . ':' . $value ['com'] . '">' . $value ['company'] . '</option>';
  2210. else
  2211. $html .= '<option value="' . $value ['company'] . ':' . $value ['com'] . '">' . $value ['company'] . '</option>';
  2212. }
  2213. $invoiceDetail ['eaHtml'] = $html;
  2214. echo json_encode ( array (
  2215. 'status' => 1,
  2216. 'invoiceDetail' => $invoiceDetail
  2217. ) );
  2218. }
  2219. /**
  2220. * --需求变更 废弃
  2221. */
  2222. function ajaxCompareClaimPrice() {
  2223. $irid = $this->get_args ( 'irid' ) ? $this->get_args ( 'irid' ) : "";
  2224. $invoiceKey = $this->get_args ( 'invoiceKey' ) ? $this->get_args ( 'invoiceKey' ) : "";
  2225. Doo::loadModel ( 'invoice' );
  2226. $invoice = new invoice ();
  2227. Doo::loadModel ( 'invoiceReceivables' );
  2228. $invoiceReceivables = new invoiceReceivables ();
  2229. Doo::loadModel ( 'invoiceOperationLog' );
  2230. $invoiceOperationLog = new invoiceOperationLog ();
  2231. $detail = $invoice->getInvoiceByIid ( $invoiceKey );
  2232. $detailM = $invoiceReceivables->getInvoiceReceivablesByIrid ( $irid );
  2233. if (empty ( $detail ) || empty ( $detailM )) {
  2234. echo json_encode ( array (
  2235. 'status' => 2,
  2236. 'msg' => '非法请求,请重新登录'
  2237. ) );
  2238. die ();
  2239. }
  2240. $iridString = "";
  2241. if (empty ( $detail ['irid'] ))
  2242. $iridString = $detailM ['irid'];
  2243. else
  2244. $iridString = $detail ['irid'] . ',' . $detailM ['irid'];
  2245. $item = array (
  2246. 'irid' => $iridString,
  2247. 'bindTime' => date ( "Y-m-d H:i:s" ),
  2248. 'updateTime' => date ( "Y-m-d H:i:s" ),
  2249. 'iid' => $detail ['iid']
  2250. );
  2251. $invoice->setInvoiceByCondition ( $item );
  2252. // 操作日志
  2253. $item = array (
  2254. 'date' => date ( "Y-m-d H:i:s" ),
  2255. 'operation' => "收款入账" . $detailM ['receivablesSerial'] . "到发票" . $detail ['invoiceSerial'],
  2256. 'status' => 8,
  2257. 'img' => $this->staff [0] ['avatar'],
  2258. 'username' => $this->staff [0] ['username'],
  2259. 'uid' => $this->staff [0] ['sid'],
  2260. 'category' => $this->staff [0] ['category'],
  2261. 'iid' => $detail ['iid']
  2262. );
  2263. $invoiceOperationLog->setInvoiceOperationLog ( $item );
  2264. $item = array (
  2265. 'iid' => $detail ['iid'],
  2266. 'irid' => $detailM ['irid'],
  2267. 'bindDate' => date ( "Y-m-d H:i:s" ),
  2268. 'bindStatus' => 1
  2269. );
  2270. $invoiceReceivables->setInvoiceReceivablesByCondition ( $item );
  2271. $price = 0;
  2272. $priceStatus = 0;
  2273. $isReceivables = 0;
  2274. $invoiceReceivables = new invoiceReceivables ();
  2275. $list = $invoiceReceivables->getInvoiceReceivablesInIridString ( $iridString );
  2276. if (! empty ( $list ))
  2277. $isReceivables = 1;
  2278. $receivablesPrice = 0;
  2279. foreach ( $list as $key => $value ) {
  2280. $receivablesPrice += $value ['receivablesPrice'];
  2281. }
  2282. if ($receivablesPrice > $detail ['invoicePrice']) {
  2283. $price = $receivablesPrice - $detail ['invoicePrice'];
  2284. $priceStatus = 1;
  2285. } elseif ($receivablesPrice < $detail ['invoicePrice']) {
  2286. $price = $detail ['invoicePrice'] - $receivablesPrice;
  2287. $priceStatus = 2;
  2288. }
  2289. echo json_encode ( array (
  2290. 'status' => 1,
  2291. 'html' => '<tr><td>¥' . $detailM ['receivablesPrice'] . '</td><td>' . $detailM ['receivablesMessage'] . '</td><td>' . $detailM ['receivablesBank'] . '</td>
  2292. <td>' . $detailM ['receivablesDate'] . '</td><td><a node-remove="Da' . $detailM ['iridKey'] . '" href="javascript:void(0);">移除</a></td></tr>
  2293. <script>
  2294. $(\'a[node-remove="Da' . $detailM ['iridKey'] . '"]\').click(function() {
  2295. var invoiceKey=$("input[name=\'key\']").val();
  2296. var irid= $(this).attr("p-data");
  2297. var iridKey="' . $detailM ["iridEn"] . '";
  2298. var element=($(this));
  2299. $("p[node-loading=\"true\"]").show();
  2300. $("p[node-loading=\"true\"]").html("移除处理中...");
  2301. $("p[node-msg=\"true2\"]").hide();
  2302. $("p[node-msg=\"true\"]").hide();
  2303. var url = "/ajaxReceivablesRemove";
  2304. $.ajax({
  2305. url : url,
  2306. type : "post",
  2307. cache : false,
  2308. dataType : "json",
  2309. data : {
  2310. key : iridKey,
  2311. invoiceKey:invoiceKey
  2312. },
  2313. global : true,
  2314. success : function(data) {
  2315. $("input[name=\'invoiceKey\']").val("' . $detailM ['iridEn'] . '");
  2316. if (data.status == 1) {
  2317. $(element).parent().parent().remove();
  2318. $("tbody[data-invoice=\"myReceivables\"]").append(data.html);
  2319. $("p[node-loading=\"true\"]").hide();
  2320. if(data.priceStatus == 1){
  2321. $("p[node-msg=\"true\"]").html("收款金额超出开票金额 ¥"+data.price+"元,请谨慎操作。");
  2322. $("p[node-msg=\"true\"]").show();
  2323. }else if(data.priceStatus == 2&& data.isReceivables != 0){
  2324. $("p[node-msg=\"true\"]").html("收款金额少于开票金额 ¥"+data.price+"元,请谨慎操作。");
  2325. $("p[node-msg=\"true\"]").show();
  2326. }
  2327. }else if(data.status == 2){
  2328. $("p[node-loading=\"true\"]").html(data.msg);
  2329. }
  2330. },
  2331. error : function(err) {
  2332. }
  2333. });
  2334. });
  2335. </script>
  2336. ',
  2337. 'price' => $price,
  2338. 'priceStatus' => $priceStatus,
  2339. 'isReceivables' => $isReceivables
  2340. ) );
  2341. }
  2342. /**
  2343. * 从发票中移除已经入账的收款 --需求变更 废弃
  2344. */
  2345. function ajaxReceivablesRemove() {
  2346. $iridKey = $this->get_args ( 'key' ) ? $this->get_args ( 'key' ) : "";
  2347. $invoiceKey = $this->get_args ( 'invoiceKey' ) ? $this->get_args ( 'invoiceKey' ) : "";
  2348. Doo::loadModel ( 'invoice' );
  2349. $invoice = new invoice ();
  2350. Doo::loadModel ( 'invoiceReceivables' );
  2351. $invoiceReceivables = new invoiceReceivables ();
  2352. Doo::loadModel ( 'invoiceOperationLog' );
  2353. $invoiceOperationLog = new invoiceOperationLog ();
  2354. $detail = $invoice->getInvoiceByIid ( $invoiceKey );
  2355. $detailM = $invoiceReceivables->getInvoiceReceivablesByIrid ( $iridKey );
  2356. // echo $detail['irid']."<br/>";
  2357. $invoiceIrid = explode ( ",", $detail ['irid'] );
  2358. foreach ( $invoiceIrid as $key => $value ) {
  2359. if ($value == $detailM ['irid'])
  2360. unset ( $invoiceIrid [$key] );
  2361. }
  2362. $invoiceIrid = implode ( ",", $invoiceIrid );
  2363. // echo $invoiceIrid."ddd";
  2364. // print_r($invoiceIrid);
  2365. $item = array (
  2366. 'irid' => $invoiceIrid,
  2367. 'iid' => $detail ['iid']
  2368. );
  2369. $invoice->setInvoiceByCondition ( $item );
  2370. $item = array (
  2371. 'iid' => 0,
  2372. 'irid' => $detailM ['irid'],
  2373. 'bindDate' => '',
  2374. 'bindStatus' => 0
  2375. );
  2376. $invoiceReceivables->setInvoiceReceivablesByCondition ( $item );
  2377. // 操作日志
  2378. $item = array (
  2379. 'date' => date ( "Y-m-d H:i:s" ),
  2380. 'operation' => "收款移除" . $detailM ['receivablesSerial'],
  2381. 'status' => 10,
  2382. 'img' => $this->staff [0] ['avatar'],
  2383. 'username' => $this->staff [0] ['username'],
  2384. 'uid' => $this->staff [0] ['sid'],
  2385. 'category' => $this->staff [0] ['category'],
  2386. 'iid' => $detail ['iid']
  2387. );
  2388. $invoiceOperationLog->setInvoiceOperationLog ( $item );
  2389. $price = 0;
  2390. $priceStatus = 0;
  2391. $isReceivables = 0;
  2392. $invoiceReceivables = new invoiceReceivables ();
  2393. $list = $invoiceReceivables->getInvoiceReceivablesInIridString ( $invoiceIrid );
  2394. if (! empty ( $list ))
  2395. $isReceivables = 1;
  2396. $receivablesPrice = 0;
  2397. foreach ( $list as $key => $value ) {
  2398. $receivablesPrice += $value ['receivablesPrice'];
  2399. }
  2400. if ($receivablesPrice > $detail ['invoicePrice']) {
  2401. $price = $receivablesPrice - $detail ['invoicePrice'];
  2402. $priceStatus = 1;
  2403. } elseif ($receivablesPrice < $detail ['invoicePrice']) {
  2404. $price = $detail ['invoicePrice'] - $receivablesPrice;
  2405. $priceStatus = 2;
  2406. }
  2407. echo json_encode ( array (
  2408. 'status' => 1,
  2409. 'html' => '<tr id="' . $detailM ['receivablesSerial'] . '" >
  2410. <td>¥' . $detailM ['receivablesPrice'] . '</td>
  2411. <td>' . $detailM ['receivablesMessage'] . '</td>
  2412. <td>' . $detailM ['receivablesBank'] . '</td>
  2413. <td>' . $detailM ['receivablesDate'] . '</td><td>
  2414. <a href="javascript:void(0)" node-Claim="true_' . $detailM ['iridKey'] . '" p-data="' . $detailM ['iridEn'] . '" name="invoiceClaim" class="button">入账</a>
  2415. </td></tr>
  2416. <script>
  2417. $(\'a[node-Claim="true_' . $detailM ['iridKey'] . '"]\').click(function() {
  2418. var invoiceKey=$("input[name=\'key\']").val();
  2419. var irid= $(this).attr("p-data");
  2420. var element=($(this));
  2421. $("p[node-loading=\"true\"]").show();
  2422. $("p[node-loading=\"true\"]").html("入账处理中...");
  2423. $("p[node-msg=\"true2\"]").hide();
  2424. $("p[node-msg=\"true\"]").hide();
  2425. var url = "/ajaxCompareClaimPrice";
  2426. $.ajax({
  2427. url : url,
  2428. type : "post",
  2429. cache : false,
  2430. dataType : "json",
  2431. data : {
  2432. irid : irid,
  2433. invoiceKey:invoiceKey
  2434. },
  2435. global : true,
  2436. success : function(data) {
  2437. $("input[name=\'invoiceKey\']").val("' . $detailM ['iridEn'] . '");
  2438. if (data.status == 1) {
  2439. $(element).parent().parent().remove();
  2440. $("tbody[box-enter=\"true\"]").append(data.html);
  2441. $("p[node-loading=\"true\"]").hide();
  2442. if(data.priceStatus == 1){
  2443. $("p[node-msg=\"true\"]").html("收款金额超出开票金额 ¥"+data.price+"元,请谨慎操作。");
  2444. $("p[node-msg=\"true\"]").show();
  2445. }else if(data.priceStatus == 2&& data.isReceivables != 0){
  2446. $("p[node-msg=\"true\"]").html("收款金额少于开票金额 ¥"+data.price+"元,请谨慎操作。");
  2447. $("p[node-msg=\"true\"]").show();
  2448. }
  2449. }else if(data.status == 2){
  2450. $("p[node-loading=\"true\"]").html(data.msg);
  2451. }
  2452. },
  2453. error : function(err) {
  2454. }
  2455. });
  2456. });
  2457. </script>
  2458. ',
  2459. 'price' => $price,
  2460. 'priceStatus' => $priceStatus,
  2461. 'isReceivables' => $isReceivables
  2462. ) );
  2463. }
  2464. /**
  2465. * 我的收款中 选择哪个发票入账,进行金额判断
  2466. */
  2467. function ajaxCompareInvoicePrice() {
  2468. $claimKey = $this->get_args ( 'claimKey' ) ? $this->get_args ( 'claimKey' ) : "";
  2469. $invoiceKey = $this->get_args ( 'invoiceKey' ) ? $this->get_args ( 'invoiceKey' ) : "";
  2470. Doo::loadModel ( 'invoice' );
  2471. $invoice = new invoice ();
  2472. Doo::loadModel ( 'invoiceReceivables' );
  2473. $invoiceReceivables = new invoiceReceivables ();
  2474. $detail = $invoice->getInvoiceByIid ( $invoiceKey );
  2475. $keyList = explode ( ';', $claimKey );
  2476. $receivablesPrice = 0;
  2477. foreach ( $keyList as $key => $value ) {
  2478. $detailM = $invoiceReceivables->getInvoiceReceivablesByIrid ( $value );
  2479. $receivablesPrice += $detailM ['receivablesPrice'];
  2480. }
  2481. if ($receivablesPrice > $detail ['invoicePrice']) {
  2482. $price = $receivablesPrice - $detail ['invoicePrice'];
  2483. echo json_encode ( array (
  2484. 'status' => 1,
  2485. 'price' => $price
  2486. ) );
  2487. } else
  2488. echo json_encode ( array (
  2489. 'status' => 2
  2490. ) );
  2491. }
  2492. /*
  2493. * 获得与我有关收款数据 --需求变更 废弃
  2494. */
  2495. function ajaxGetReceivalblesByStaff() {
  2496. $iid = $this->get_args ( 'key' ) ? $this->get_args ( 'key' ) : "";
  2497. Doo::loadModel ( 'invoiceReceivables' );
  2498. $invoiceReceivables = new invoiceReceivables ();
  2499. Doo::loadModel ( 'invoice' );
  2500. $invoice = new invoice ();
  2501. $detail = $invoice->getInvoiceByIid ( $iid );
  2502. $list = $invoiceReceivables->getInvoiceReceivablesByClaim ( $this->staff [0] ['cid'], $this->staff [0] ['sid'] );
  2503. $html = "";
  2504. $i = 1;
  2505. foreach ( $list ['myClaim'] as $key => $value ) {
  2506. $html .= '<tr id="' . $value ['receivablesSerial'] . '" >
  2507. <td>¥' . $value ['receivablesPrice'] . '</td>
  2508. <td>' . $value ['receivablesMessage'] . '</td>
  2509. <td>' . $value ['receivablesBank'] . '</td>
  2510. <td>' . $value ['receivablesDate'] . '</td>';
  2511. $html .= '<td>
  2512. <a href="javascript:void(0)" node-Claim="true_' . $i . '" p-data="' . $value ['iidKey'] . '" name="invoiceClaim" class="button">入账</a>
  2513. </td></tr>
  2514. <script>
  2515. $(\'a[node-Claim="true_' . $i . '"]\').click(function() {
  2516. var invoiceKey=$("input[name=\'key\']").val();
  2517. var irid= $(this).attr("p-data");
  2518. var element=($(this));
  2519. $("p[node-loading=\"true\"]").show();
  2520. $("p[node-loading=\"true\"]").html("入账处理中...");
  2521. $("p[node-msg=\"true2\"]").hide();
  2522. $("p[node-msg=\"true\"]").hide();
  2523. var url = "/ajaxCompareClaimPrice";
  2524. $.ajax({
  2525. url : url,
  2526. type : "post",
  2527. cache : false,
  2528. dataType : "json",
  2529. data : {
  2530. irid : irid,
  2531. invoiceKey:invoiceKey
  2532. },
  2533. global : true,
  2534. success : function(data) {
  2535. $("input[name=\'invoiceKey\']").val("' . $value ['iidKey'] . '");
  2536. if (data.status == 1) {
  2537. $(element).parent().parent().remove();
  2538. $("tbody[box-enter=\"true\"]").append(data.html);
  2539. $("p[node-loading=\"true\"]").hide();
  2540. if(data.priceStatus == 1){
  2541. $("p[node-msg=\"true\"]").html("收款金额超出开票金额 ¥"+data.price+"元,请谨慎操作。");
  2542. $("p[node-msg=\"true\"]").show();
  2543. }else if(data.priceStatus == 2&& data.isReceivables != 0){
  2544. $("p[node-msg=\"true\"]").html("收款金额少于开票金额 ¥"+data.price+"元,请谨慎操作。");
  2545. $("p[node-msg=\"true\"]").show();
  2546. }
  2547. }else if(data.status == 2){
  2548. $("p[node-loading=\"true\"]").html(data.msg);
  2549. }
  2550. },
  2551. error : function(err) {
  2552. }
  2553. });
  2554. });
  2555. </script>
  2556. ';
  2557. $i ++;
  2558. }
  2559. $html2 = "";
  2560. $list2 = $invoiceReceivables->getInvoiceReceivablesByIid ( $iid, 1 );
  2561. foreach ( $list2 as $key => $value ) {
  2562. $html2 .= '<tr id="' . $value ['receivablesSerial'] . '" >
  2563. <td>¥' . $value ['receivablesPrice'] . '</td>
  2564. <td>' . $value ['receivablesMessage'] . '</td>
  2565. <td>' . $value ['receivablesBank'] . '</td>
  2566. <td>' . $value ['receivablesDate'] . '</td>';
  2567. $html2 .= '<td>
  2568. <a href="javascript:void(0)" node-remove="Da' . $value ['iridKey'] . '" >移除</a>
  2569. </td></tr>
  2570. <script>
  2571. $(\'a[node-remove="Da' . $value ['iridKey'] . '"]\').click(function() {
  2572. var invoiceKey=$("input[name=\'key\']").val();
  2573. var irid= $(this).attr("p-data");
  2574. var iridKey="' . $value ["iidKey"] . '";
  2575. var element=($(this));
  2576. $("p[node-loading=\"true\"]").show();
  2577. $("p[node-loading=\"true\"]").html("移除处理中...");
  2578. $("p[node-msg=\"true2\"]").hide();
  2579. $("p[node-msg=\"true\"]").hide();
  2580. var url = "/ajaxReceivablesRemove";
  2581. $.ajax({
  2582. url : url,
  2583. type : "post",
  2584. cache : false,
  2585. dataType : "json",
  2586. data : {
  2587. key : iridKey,
  2588. invoiceKey:invoiceKey
  2589. },
  2590. global : true,
  2591. success : function(data) {
  2592. $("input[name=\'invoiceKey\']").val("' . $value ['iidKey'] . '");
  2593. if (data.status == 1) {
  2594. $(element).parent().parent().remove();
  2595. $("tbody[data-invoice=\"myReceivables\"]").append(data.html);
  2596. $("p[node-loading=\"true\"]").hide();
  2597. if(data.priceStatus == 1){
  2598. $("p[node-msg=\"true\"]").html("收款金额超出开票金额 ¥"+data.price+"元,请谨慎操作。");
  2599. $("p[node-msg=\"true\"]").show();
  2600. }else if(data.priceStatus == 2&& data.isReceivables != 0){
  2601. $("p[node-msg=\"true\"]").html("收款金额少于开票金额 ¥"+data.price+"元,请谨慎操作。");
  2602. $("p[node-msg=\"true\"]").show();
  2603. }
  2604. }else if(data.status == 2){
  2605. $("p[node-loading=\"true\"]").html(data.msg);
  2606. }
  2607. },
  2608. error : function(err) {
  2609. }
  2610. });
  2611. });
  2612. </script>
  2613. ';
  2614. $i ++;
  2615. }
  2616. $price = 0;
  2617. $priceStatus = 0;
  2618. $isReceivables = 0;
  2619. $list = $invoiceReceivables->getInvoiceReceivablesInIridString ( $detail ['irid'] );
  2620. if (! empty ( $list ))
  2621. $isReceivables = 1;
  2622. $receivablesPrice = 0;
  2623. foreach ( $list as $key => $value ) {
  2624. $receivablesPrice += $value ['receivablesPrice'];
  2625. }
  2626. if ($receivablesPrice > $detail ['invoicePrice']) {
  2627. $price = $receivablesPrice - $detail ['invoicePrice'];
  2628. $priceStatus = 1;
  2629. } elseif ($receivablesPrice < $detail ['invoicePrice']) {
  2630. $price = $detail ['invoicePrice'] - $receivablesPrice;
  2631. $priceStatus = 2;
  2632. }
  2633. echo json_encode ( array (
  2634. 'status' => 1,
  2635. 'html' => $html,
  2636. 'html2' => $html2,
  2637. 'price' => $price,
  2638. 'priceStatus' => $priceStatus,
  2639. 'isReceivables' => $isReceivables
  2640. ) );
  2641. }
  2642. function ajaxGetInvoiceInfoByType() {
  2643. $type = $this->get_args ( 'type' ) ? $this->get_args ( 'type' ) : "";
  2644. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  2645. if (empty ( $serial )) {
  2646. echo json_encode ( array (
  2647. 'status' => 2,
  2648. 'msg' => 'illegal request'
  2649. ) );
  2650. die ();
  2651. }
  2652. if ($type == 'INVOICE') {
  2653. Doo::loadModel ( 'invoice' );
  2654. $invoice = new invoice ();
  2655. Doo::loadModel ( 'invoiceOperationLog' );
  2656. $invoiceOperationLog = new invoiceOperationLog ();
  2657. $detail = $invoice->getInvoiceByIsid ( $serial, $this->staff [0] ['sid'] );
  2658. $invoiceOperationLogList = $invoiceOperationLog->getInvoiceOperationLogByIid ( $detail ['iid'] );
  2659. if (empty ( $detail ))
  2660. $html = '';
  2661. else {
  2662. $html = '
  2663. <div class="modal-dialog modal-lg">
  2664. <div class="modal-content"><div class="modal-header"><h3>发票单详情</h3></div>
  2665. <div class="modal-body saeaList"><table class="table table-bordered table-condensed"><tbody>
  2666. <tr>
  2667. <th class="taC" width="150">开票流水号</th><td>' . $detail ['invoiceSerial'] . '</td>
  2668. <th class="taC" width="150">提交时间</th><td>' . $detail ['date'] . '</td>
  2669. </tr>
  2670. <tr>
  2671. <th class="taC" width="150">所在办事处</th><td>' . $detail ['categoryName'] . '(' . $detail ['userName'] . ')</td>
  2672. <th class="taC" width="150">备注</th><td>' . $detail ['remark'] . '</td>
  2673. </tr>
  2674. <tr>
  2675. <th class="taC">开票金额</th><td><b class="colOrange" style="font-size:18px">¥' . $detail ['invoicePrice'] . '</b></td>
  2676. <th class="taC">开票内容</th><td>' . $detail ['invoiceElement'] . '</td>
  2677. </tr></tbody></table>';
  2678. if ($detail ['invoiceType'] == 0)
  2679. $html .= '<table class="table table-bordered table-condensed"><tbody>
  2680. <tr><th colspan="4" class="taC">增值税普通发票</th></tr><tr>
  2681. <th class="taC" width="150">发票抬头</th><td >' . $detail ['invoiceTitle'] . '</td>
  2682. <th class="taC" width="150">纳税人识别码</th><td>' . $detail ['TIN'] . '</td>
  2683. </tr>';
  2684. else
  2685. $html .= '<table class="table table-bordered table-condensed"><tbody>
  2686. <tr><th colspan="4" class="taC">增值税专用发票</th></tr><tr>
  2687. <th class="taC" width="150">单位名称</th><td>' . $detail ['invoiceCompany'] . '</td>
  2688. <th class="taC" width="150">纳税人识别码</th><td>' . $detail ['TIN'] . '</td></tr>
  2689. ';
  2690. $html .= '<tr>
  2691. <th class="taC">注册地址</th><td>' . $detail ['address'] . '</td>
  2692. <th class="taC">注册电话</th><td>' . $detail ['phone'] . '</td>
  2693. </tr>
  2694. <tr>
  2695. <th class="taC">开户银行</th><td>' . $detail ['bankAccount'] . '</td>
  2696. <th class="taC">银行账户</th><td>' . $detail ['bank'] . '</td>
  2697. </tr></tbody></table>';
  2698. if ($detail ['doPost'] == 1)
  2699. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th colspan="4" class="taC">邮寄信息</th></tr><tr>
  2700. <th class="taC" width="150">收件人</th><td>' . $detail ['recipients'] . '</td>
  2701. <th class="taC" width="150">收件人手机/电话</th><td>' . $detail ['recipientsPhone'] . '</td>
  2702. </tr><tr>
  2703. <th class="taC" width="150">收件地址</th><td colspan="3">' . $detail ['recipientsAddress'] . '</td>
  2704. </tr><tr>
  2705. <th class="taC" width="150">邮寄物品</th><td colspan="3">' . $detail ['mailItems'] . '</td>
  2706. </tr></tbody></table>';
  2707. if (! empty ( $invoiceOperationLogList )) {
  2708. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th width="60%" class="taC">审批流程</th></tr><tr><td>';
  2709. foreach ( $invoiceOperationLogList as $key => $value ) {
  2710. if ($value ['status'] == 1 || $value ['status'] == 2 || $value ['status'] == 3 || $value ['status'] == 4) {
  2711. $html .= '<blockquote><p><span class="colGray">' . $value ['date'] . '</span>&nbsp;
  2712. ' . $value ['category'] . '-' . $value ['username'] . '&nbsp;';
  2713. if ($value ['status'] == 2) {
  2714. $html .= '<span class="colGreen">同意</span>';
  2715. } elseif ($value ['status'] == 3) {
  2716. $html .= '<span class="colOrange">退回</span>';
  2717. } elseif ($value ['status'] == 5) {
  2718. $html .= '<span class="colGreen">打印</span>';
  2719. }
  2720. $html .= $value ['operation'] . '</p></blockquote>';
  2721. }
  2722. }
  2723. $html .= '</td></tr></tbody></table>';
  2724. }
  2725. $html .= '</div><div class="modal-footer"><a href="#" class="button btn-gray" data-dismiss="modal" aria-hidden="true">关闭</a></div></div></div>';
  2726. }
  2727. echo json_encode ( array (
  2728. 'status' => 1,
  2729. 'html' => $html
  2730. ) );
  2731. die ();
  2732. } elseif ($type == 'RECEIVABLES') {
  2733. Doo::loadModel ( 'invoiceReceivables' );
  2734. $invoiceReceivables = new invoiceReceivables ();
  2735. $detail = $invoiceReceivables->getInvoiceReceivablesByIrsid ( $serial, $this->staff [0] ['sid'] );
  2736. if (empty ( $detail ))
  2737. $html = '';
  2738. else {
  2739. $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">
  2740. <tbody><tr>
  2741. <th class="taC">收款流水号</th><td>' . $detail ['receivablesSerial'] . '</td>
  2742. <th class="taC">录入收款</th><td>' . $detail ['inputStaff'] . ' ' . $detail ['date'] . '</td>
  2743. </tr><tr>
  2744. <th class="taC">收款金额</th><td><b>¥' . $detail ['receivablesPrice'] . '</b></td>
  2745. <th class="taC">收款信息</th><td>' . $detail ['receivablesMessage'] . '</td>
  2746. </tr>
  2747. <tr>
  2748. <th class="taC">收款银行</th><td>' . $detail ['receivablesBank'] . '</td>
  2749. <th class="taC">银行到帐</th><td>' . $detail ['receivablesDate'] . '</td>
  2750. </tr>
  2751. <tr>
  2752. <th class="taC">认领收款</th><td colspan="3">' . $detail ['inputStaff'] . ' 转入 ' . $detail ['username'] . ' ' . $detail ['bindDate'] . '</td>
  2753. </tr>
  2754. </tbody></table></div><div class="modal-footer"><a href="#" class="button btn-gray" data-dismiss="modal" aria-hidden="true">关闭</a></div></div></div>';
  2755. }
  2756. echo json_encode ( array (
  2757. 'status' => 1,
  2758. 'html' => $html
  2759. ) );
  2760. die ();
  2761. } elseif ($type == 'IRTC') {
  2762. Doo::loadModel ( 'invoice' );
  2763. $invoice = new invoice ();
  2764. Doo::loadModel ( 'invoiceOperationLog' );
  2765. $invoiceOperationLog = new invoiceOperationLog ();
  2766. $detail = $invoice->getInvoiceByIsid ( $serial, $this->staff [0] ['sid'] );
  2767. $invoiceOperationLogList = $invoiceOperationLog->getInvoiceOperationLogByIid ( $detail ['iid'] );
  2768. if (empty ( $detail ))
  2769. $html = '';
  2770. else {
  2771. $html = '
  2772. <table class="table table-bordered table-condensed"><tbody>
  2773. <tr>
  2774. <th class="taC" width="150">开票流水号</th><td>' . $detail ['invoiceSerial'] . '</td>
  2775. <th class="taC" width="150">提交时间</th><td>' . $detail ['date'] . '</td>
  2776. </tr>
  2777. <tr>
  2778. <th class="taC" width="150">所在办事处</th><td>' . $detail ['categoryName'] . '(' . $detail ['userName'] . ')</td>
  2779. <th class="taC" width="150">备注</th><td>' . $detail ['remark'] . '</td>
  2780. </tr>
  2781. <tr>
  2782. <th class="taC">开票金额</th><td><b class="colOrange" style="font-size:18px">¥' . $detail ['invoicePrice'] . '</b></td>
  2783. <th class="taC">开票内容</th><td>' . $detail ['invoiceElement'] . '</td>
  2784. </tr></tbody></table>';
  2785. if ($detail ['invoiceType'] == 0)
  2786. $html .= '<table class="table table-bordered table-condensed"><tbody>
  2787. <tr><th colspan="4" class="taC">增值税普通发票</th></tr><tr>
  2788. <th class="taC" width="150">发票抬头</th><td >' . $detail ['invoiceTitle'] . '</td>
  2789. <th class="taC" width="150">纳税人识别码</th><td>' . $detail ['TIN'] . '</td>
  2790. </tr>';
  2791. else
  2792. $html .= '<table class="table table-bordered table-condensed"><tbody>
  2793. <tr><th colspan="4" class="taC">增值税专用发票</th></tr><tr>
  2794. <th class="taC" width="150">单位名称</th><td>' . $detail ['invoiceCompany'] . '</td>
  2795. <th class="taC" width="150">纳税人识别码</th><td>' . $detail ['TIN'] . '</td></tr>
  2796. ';
  2797. $html .= '<tr>
  2798. <th class="taC">注册地址</th><td>' . $detail ['address'] . '</td>
  2799. <th class="taC">注册电话</th><td>' . $detail ['phone'] . '</td>
  2800. </tr>
  2801. <tr>
  2802. <th class="taC">开户银行</th><td>' . $detail ['bankAccount'] . '</td>
  2803. <th class="taC">银行账户</th><td>' . $detail ['bank'] . '</td>
  2804. </tr></tbody></table>';
  2805. if ($detail ['doPost'] == 1)
  2806. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th colspan="4" class="taC">邮寄信息</th></tr><tr>
  2807. <th class="taC" width="150">收件人</th><td>' . $detail ['recipients'] . '</td>
  2808. <th class="taC" width="150">收件人手机/电话</th><td>' . $detail ['recipientsPhone'] . '</td>
  2809. </tr><tr>
  2810. <th class="taC" width="150">收件地址</th><td colspan="3">' . $detail ['recipientsAddress'] . '</td>
  2811. </tr><tr>
  2812. <th class="taC" width="150">邮寄物品</th><td colspan="3">' . $detail ['mailItems'] . '</td>
  2813. </tr></tbody></table>';
  2814. if (! empty ( $invoiceOperationLogList )) {
  2815. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th width="60%" class="taC">审批流程</th></tr><tr><td>';
  2816. foreach ( $invoiceOperationLogList as $key => $value ) {
  2817. if ($value ['status'] == 1 || $value ['status'] == 2 || $value ['status'] == 3 || $value ['status'] == 4) {
  2818. $html .= '<blockquote><p><span class="colGray">' . $value ['date'] . '</span>&nbsp;
  2819. ' . $value ['category'] . '-' . $value ['username'] . '&nbsp;';
  2820. if ($value ['status'] == 2) {
  2821. $html .= '<span class="colGreen">同意</span>';
  2822. } elseif ($value ['status'] == 3) {
  2823. $html .= '<span class="colOrange">退回</span>';
  2824. } elseif ($value ['status'] == 5) {
  2825. $html .= '<span class="colGreen">打印</span>';
  2826. }
  2827. $html .= $value ['operation'] . '</p></blockquote>';
  2828. }
  2829. }
  2830. $html .= '</td></tr></tbody></table>';
  2831. }
  2832. }
  2833. echo json_encode ( array (
  2834. 'status' => 1,
  2835. 'html' => $html,
  2836. 'iidKey' => $serial
  2837. ) );
  2838. die ();
  2839. }
  2840. }
  2841. function ajaxGetInvoiceReceivablesByStaff() {
  2842. $postData = $this->get_args ( 'postData' ) ? $this->get_args ( 'postData' ) : "";
  2843. if (empty ( $postData )) {
  2844. echo json_encode ( array (
  2845. 'status' => 2,
  2846. 'msg' => 'illegal request'
  2847. ) );
  2848. die ();
  2849. }
  2850. Doo::loadModel ( 'invoiceReceivables' );
  2851. $invoiceReceivables = new invoiceReceivables ();
  2852. $detail = $invoiceReceivables->getInvoiceReceivablesByIrid ( $postData );
  2853. if (empty ( $detail )) {
  2854. echo json_encode ( array (
  2855. 'status' => 2,
  2856. 'msg' => 'illegal request'
  2857. ) );
  2858. die ();
  2859. }
  2860. Doo::loadModel ( 'L_category' );
  2861. $lCategory = new L_category ();
  2862. Doo::loadModel ( 'staff' );
  2863. $staff = new staff ();
  2864. $staffList = $staff->getStaffByCid ( $detail ['cid'] );
  2865. $category = $lCategory->getCategory ();
  2866. $categoryHtml = '<option post-data="PUBLIC" value="PUBLIC" >公共待认领款项</option>';
  2867. $staffHtml = '<option value="PUBLIC">办事处待认领款项</option>';
  2868. foreach ( $category as $key => $value ) {
  2869. $categoryHtml .= '<option post-data="' . $value ['cid'] . '" value="' . $value ['cid'] . ':' . $value ['title'] . '" >' . $value ['title'] . '</option>';
  2870. if ($value ['cid'] == $detail ['cid'])
  2871. $categoryHtml .= '<option selected post-data="' . $value ['cid'] . '" value="' . $value ['cid'] . ':' . $value ['title'] . '" >' . $value ['title'] . '</option>';
  2872. }
  2873. foreach ( $staffList as $key => $value ) {
  2874. $staffHtml .= '<option value="' . $value ['sid'] . '-' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  2875. if ($value ['sid'] == $detail ['sid'])
  2876. $staffHtml .= '<option selected value="' . $value ['sid'] . '-' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  2877. }
  2878. $rbankHtml = '<option value="广发银行珠海分行柠溪支行">广发银行珠海分行柠溪支行</option>';
  2879. echo json_encode ( array (
  2880. 'status' => 1,
  2881. 'categoryHtml' => $categoryHtml,
  2882. 'staffHtml' => $staffHtml,
  2883. 'rbankHtml' => $rbankHtml,
  2884. 'detail' => $detail
  2885. ) );
  2886. }
  2887. function ajaxGetInvoiceReceivablesByIrid(){
  2888. $irid = $this->get_args ( 'irid' ) ? $this->get_args ( 'irid' ) : "";
  2889. if (empty ( $irid )) {
  2890. echo json_encode ( array (
  2891. 'status' => 2,
  2892. 'msg' => 'illegal request'
  2893. ) );
  2894. die ();
  2895. }
  2896. Doo::loadModel ( 'invoiceReceivables' );
  2897. $invoiceReceivables = new invoiceReceivables ();
  2898. Doo::loadModel ( 'invoice' );
  2899. $invoice = new invoice ();
  2900. $detail=$invoiceReceivables->getInvoiceReceivablesByIrid($irid);
  2901. $invoiceDetail=$invoice->getInvoiceByTitle($detail['recepitTitleMark'],'EXACTLY'," and status=2 and printStatus=1 and irid='' ");//
  2902. $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>
  2903. <tr>
  2904. <td><b>¥'.$detail['receivablesPrice'].'</b></td>
  2905. <td>'.$detail['receivablesMessage'].'</td>
  2906. <td>'.$detail['receivablesBank'].'<br>'.$detail['receivablesDate'].'</td>
  2907. <td>'.$detail['title'].'-'.$detail['username'].'<br>'.$detail['confirmTime'].'</td>
  2908. <td>'.$detail['recepitTitleMark'].'</td>
  2909. </tr></tbody></table>';
  2910. $isInvoice=false;$invoiceHtml='';
  2911. if(empty($invoiceDetail)){
  2912. $isInvoice=true;
  2913. }else{
  2914. $invoiceHtml='<table class="table table-bordered table-condensed">
  2915. <thead><tr><th>开票单位(抬头)</th><th>开票金额</th><th>提交开票</th><th>出票</th><th>开票流水号</th><th width="80">入账</th></tr></thead><tbody><tr>';
  2916. if (! empty ( $invoiceDetail ['invoiceType'] )) {
  2917. $invoiceHtml .= '<td>' . $invoiceDetail ['invoiceCompany'] . '</td>';
  2918. } else {
  2919. $invoiceHtml .= '<td>' . $invoiceDetail ['invoiceTitle'] . '</td>';
  2920. }
  2921. if (! empty ( $invoiceDetail ['invoiceType'] )) {
  2922. $invoiceHtml .= '<td>' . $invoiceDetail ['invoicePrice'] . '专</td>';
  2923. } else {
  2924. $invoiceHtml .= '<td>' . $invoiceDetail ['invoicePrice'] . '</td>';
  2925. }
  2926. $invoiceHtml.='
  2927. <td>' . $invoiceDetail ['categoryName'].$invoiceDetail ['userName'] . ' ' . $invoiceDetail ['date']. '</td>
  2928. <td>' . $invoiceDetail ['printer']. ' ' . $invoiceDetail ['printTime']. '</td>
  2929. <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>
  2930. </tr>
  2931. ';
  2932. $invoiceHtml.='</tbody></table>
  2933. <script>
  2934. $(\'a[bind-receivables="ir' . $invoiceDetail ['iidKeyXD'] . '"]\').click(function() {
  2935. $("input[name=\'invoiceKey\']").val("'.$invoiceDetail ['iidKey'].'");
  2936. var invoiceKey=$("input[name=\'invoiceKey\']").val();
  2937. if(invoiceKey==""){
  2938. alert("入账错误,请重新刷新页面");
  2939. return false;
  2940. }
  2941. if(window.confirm("确定入账吗?")){
  2942. $("#IBR").submit();
  2943. }else{
  2944. return false;
  2945. }
  2946. });
  2947. </script>
  2948. ';
  2949. }
  2950. echo json_encode ( array (
  2951. 'status' => 1,
  2952. 'irkey'=>$detail['iridEn'],
  2953. 'receivablesHtml' => $receivablesHtml,
  2954. 'isInvoice'=>$isInvoice,
  2955. 'invoiceHtml' => $invoiceHtml
  2956. ) );
  2957. }
  2958. function ajaxGetInvoiceReceivablesByTitle(){
  2959. $title = $this->get_args ( 'title' ) ? $this->get_args ( 'title' ) : "";
  2960. if (empty ( $title )) {
  2961. echo json_encode ( array (
  2962. 'status' => 2,
  2963. 'msg' => 'illegal request'
  2964. ) );
  2965. die ();
  2966. }
  2967. Doo::loadModel ( 'invoice' );
  2968. $invoice = new invoice ();
  2969. $invoiceDetail=$invoice->getInvoiceByTitle($title,'EXACTLY'," and status=2 and printStatus=1 and irid='' ");
  2970. $invoiceHtml='';
  2971. if(!empty($invoiceDetail)){
  2972. $invoiceHtml='<table class="table table-bordered table-condensed">
  2973. <thead><tr><th>开票单位(抬头)</th><th>开票金额</th><th>提交开票</th><th>出票</th><th>开票流水号</th><th width="80">入账</th></tr></thead><tbody><tr>';
  2974. if (! empty ( $invoiceDetail ['invoiceType'] )) {
  2975. $invoiceHtml .= '<td>' . $invoiceDetail ['invoiceCompany'] . '</td>';
  2976. } else {
  2977. $invoiceHtml .= '<td>' . $invoiceDetail ['invoiceTitle'] . '</td>';
  2978. }
  2979. if (! empty ( $invoiceDetail ['invoiceType'] )) {
  2980. $invoiceHtml .= '<td>' . $invoiceDetail ['invoicePrice'] . '专</td>';
  2981. } else {
  2982. $invoiceHtml .= '<td>' . $invoiceDetail ['invoicePrice'] . '</td>';
  2983. }
  2984. $invoiceHtml.='
  2985. <td>' . $invoiceDetail ['categoryName'].$invoiceDetail ['userName'] . ' ' . $invoiceDetail ['date']. '</td>
  2986. <td>' . $invoiceDetail ['printer']. ' ' . $invoiceDetail ['printTime']. '</td>
  2987. <td>' . $invoiceDetail ['invoiceSerial']. '</td><td><a class="button btn-block" bind-receivables="ir'.$invoiceDetail ['iidKeyXD'].'" data-ikey="'.$invoiceDetail ['iidKey'].'" href="#">入账</a></td>
  2988. </tr>
  2989. ';
  2990. $invoiceHtml.='</tbody></table>
  2991. <script>
  2992. $(\'a[bind-receivables="ir' . $invoiceDetail ['iidKeyXD'] . '"]\').click(function() {
  2993. $("input[name=\'invoiceKey\']").val("'.$invoiceDetail ['iidKey'].'");
  2994. var invoiceKey=$("input[name=\'invoiceKey\']").val();
  2995. if(invoiceKey==""){
  2996. alert("入账错误,请重新刷新页面");
  2997. return false;
  2998. }
  2999. if(window.confirm("确定入账吗?")){
  3000. $("#IBR").submit();
  3001. }else{
  3002. return false;
  3003. }
  3004. });
  3005. </script>
  3006. ';
  3007. }
  3008. echo json_encode ( array (
  3009. 'status' => 1,
  3010. 'invoiceHtml' => $invoiceHtml
  3011. ) );
  3012. }
  3013. function _GetFileEXT($filename) {
  3014. $pics = explode ( '.', $filename );
  3015. $num = count ( $pics );
  3016. return $pics [$num - 1];
  3017. }
  3018. function showCache($path = "") {
  3019. if (file_exists ( $path )) {
  3020. $htm = file_get_contents ( $path );
  3021. } else {
  3022. Doo::loadModel ( 'invoiceStatistics' );
  3023. $invoiceStatistics = new invoiceStatistics ();
  3024. $isBriefly = $invoiceStatistics->getBrieflyStatistics ();
  3025. $htm = '<tr><th class="taC">' . $isBriefly ['statisticsMonth'] [0] ['month'] . '月累计开票</th>
  3026. <td>¥' . $isBriefly ['statisticsMonth'] [0] ['invoicePrice'] . '</td>
  3027. <th class="taC">' . $isBriefly ['statisticsMonth'] [0] ['month'] . '月累计入账</th>
  3028. <td>¥' . $isBriefly ['statisticsMonth'] [0] ['accountPrice'] . '</td></tr>';
  3029. /*
  3030. * '<tr><th class="taC">今年累计开票</th><td>¥' . $isBriefly ['statisticsYear'] [0] ['invoicePrice'] . '</td> <th class="taC">今年累计入账</th><td>¥' . $isBriefly ['statisticsYear'] [0] ['accountPrice'] . '</td></tr>';
  3031. */
  3032. file_put_contents ( $path, $htm, FILE_APPEND );
  3033. }
  3034. return $htm;
  3035. }
  3036. /**
  3037. * 获取get或者POST值
  3038. *
  3039. * @param string $name 属性名称
  3040. * @return fixed 值
  3041. */
  3042. function get_args($name) {
  3043. if (isset ( $_GET [$name] )) {
  3044. if (is_array ( $_GET [$name] ))
  3045. return $_GET [$name];
  3046. else
  3047. return addslashes ( $_GET [$name] );
  3048. } elseif (isset ( $_POST [$name] )) {
  3049. if (is_array ( $_POST [$name] ))
  3050. return $_POST [$name];
  3051. else
  3052. return addslashes ( $_POST [$name] );
  3053. } else
  3054. return false;
  3055. }
  3056. function SafeFilter(&$arr) {
  3057. $ra = Array (
  3058. '/([\x00-\x08,\x0b-\x0c,\x0e-\x19])/',
  3059. '/script/',
  3060. '/javascript/',
  3061. '/vbscript/',
  3062. '/expression/',
  3063. '/applet/',
  3064. '/meta/',
  3065. '/xml/',
  3066. '/blink/',
  3067. '/link/',
  3068. '/style/',
  3069. '/embed/',
  3070. '/object/',
  3071. '/frame/',
  3072. '/layer/',
  3073. '/title/',
  3074. '/bgsound/',
  3075. '/base/',
  3076. '/onload/',
  3077. '/onunload/',
  3078. '/onchange/',
  3079. '/onsubmit/',
  3080. '/onreset/',
  3081. '/onselect/',
  3082. '/onblur/',
  3083. '/onfocus/',
  3084. '/onabort/',
  3085. '/onkeydown/',
  3086. '/onkeypress/',
  3087. '/onkeyup/',
  3088. '/onclick/',
  3089. '/ondblclick/',
  3090. '/onmousedown/',
  3091. '/onmousemove/',
  3092. '/onmouseout/',
  3093. '/onmouseover/',
  3094. '/onmouseup/',
  3095. '/onunload/'
  3096. );
  3097. if (is_array ( $arr )) {
  3098. foreach ( $arr as $key => $value ) {
  3099. if (! is_array ( $value )) {
  3100. if (! get_magic_quotes_gpc ()) // 不对magic_quotes_gpc转义过的字符使用addslashes(),避免双重转义。
  3101. {
  3102. $value = addslashes ( $value ); // 给单引号(')、双引号(")、反斜线(\)与 NUL(NULL 字符)加上反斜线转义
  3103. }
  3104. $value = preg_replace ( $ra, '', $value ); // 删除非打印字符,粗暴式过滤xss可疑字符串
  3105. $arr [$key] = htmlentities ( strip_tags ( $value ) ); // 去除 HTML 和 PHP 标记并转换为 HTML 实体
  3106. } else {
  3107. SafeFilter ( $arr [$key] );
  3108. }
  3109. }
  3110. }
  3111. }
  3112. /**
  3113. * Escape String
  3114. *
  3115. * @access public
  3116. * @param string
  3117. * @param bool whether or not the string will be used in a LIKE condition
  3118. * @return string
  3119. */
  3120. function escape_str($str, $like = FALSE) {
  3121. if (is_array ( $str )) {
  3122. foreach ( $str as $key => $val ) {
  3123. $str [$key] = $this->escape_str ( $val, $like );
  3124. }
  3125. return $str;
  3126. }
  3127. var_dump ( Doo::db ()->getDbObject () );
  3128. die ();
  3129. if (function_exists ( 'mysql_real_escape_string' ) and is_resource ( Doo::db ()->getDbObject () )) { // Doo::db ()->getDbObject()
  3130. $str = mysql_real_escape_string ( $str, Doo::db ()->getDbObject () );
  3131. } elseif (function_exists ( 'mysql_escape_string' )) {
  3132. $str = mysql_escape_string ( $str );
  3133. } else {
  3134. $str = addslashes ( $str );
  3135. }
  3136. // escape LIKE condition wildcards
  3137. if ($like === TRUE) {
  3138. $str = str_replace ( array (
  3139. '%',
  3140. '_'
  3141. ), array (
  3142. '\\%',
  3143. '\\_'
  3144. ), $str );
  3145. }
  3146. return $str;
  3147. }
  3148. /**
  3149. * 获得分页数据
  3150. * @param unknown_type $table
  3151. * @param unknown_type $condition
  3152. * @param unknown_type $on_page
  3153. * @param unknown_type $page_size
  3154. */
  3155. function get_page($table = "", $condition = "", $on_page = 1, $page_size = 20, $action = "", $get = "", $other = "page") {
  3156. $page_c = "";
  3157. $page ['previous'] = $this->get_previous ( $on_page );
  3158. $page ['on_page'] = $on_page;
  3159. $total_count = $this->get_table_count ( $table, $condition );
  3160. $total = intval ( $total_count / $page_size );
  3161. $page ['total_page'] = ($total_count % $page_size) == 0 ? $total : $total + 1;
  3162. $page ['total_data'] = $total_count;
  3163. $page ['next'] = $on_page == $page ['total_page'] ? $page ['total_page'] : $on_page + 1;
  3164. $i = 1;
  3165. $page_max = 1;
  3166. $page_width = 3;
  3167. if ($on_page >= $page_width) {
  3168. $page_max = intval ( $on_page / $page_width ) + 1;
  3169. $i = intval ( $on_page / $page_width ) * $page_width - 1;
  3170. }
  3171. for(; $i <= $page ['total_page']; $i ++) {
  3172. if ($i == $on_page)
  3173. $page_c .= '<li class="active"><a href="javascript:void(0)">' . $i . '</a></li>';
  3174. else
  3175. $page_c .= '<li><a href="/' . $action . '/' . $i . $get . '">' . $i . '</a></li>';
  3176. if ($i == ($page_width * $page_max))
  3177. break;
  3178. }
  3179. $page ['page'] = $page_c;
  3180. $page ['lower'] = (-- $on_page) * $page_size;
  3181. return $page;
  3182. }
  3183. /**
  3184. * 获取上一页
  3185. * @param unknown_type $on_page
  3186. */
  3187. function get_previous($on_page = 1) {
  3188. return $on_page != 0 ? $on_page - 1 : $on_page;
  3189. }
  3190. /**
  3191. * 获取总页数
  3192. * @param unknown_type $table
  3193. * @param unknown_type $condition
  3194. */
  3195. public function get_table_count($table = "", $condition = "") {
  3196. // $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  3197. $sql = "select count(*) as count from " . $table . " where " . $condition;
  3198. // echo $sql;die;
  3199. $query = Doo::db ()->query ( $sql );
  3200. $result = $query->fetch ();
  3201. return $result ['count'];
  3202. }
  3203. function isInvoiceNew($type = "GLOBAL") {
  3204. Doo::loadModel ( 'invoice' );
  3205. $invoice = new invoice ();
  3206. Doo::loadModel ( 'invoiceReceivables' );
  3207. $invoiceReceivables = new invoiceReceivables ();
  3208. Doo::loadModel ( 'staff' );
  3209. $staff = new staff ();
  3210. $st = $staff->getUserByIdList ( $_COOKIE ["staff"] );
  3211. // 我的发票待处理
  3212. $pendingInvoice = $invoice->getOne ( array (
  3213. 'where' => "(status=3 or status=4 or (status=2 and printStatus=1 and untreadStatus=0 ) or (status=2 and printStatus=1 and untreadStatus=2 ) ) and isDelete=0 and sid=" . $st [0] ['sid'],
  3214. 'desc' => 'iid',
  3215. 'asArray' => TRUE
  3216. ) );
  3217. // 我的收款待入账
  3218. $myClaim = $invoiceReceivables->getOne ( array (
  3219. 'where' => " receivablesStaff like '" . $st [0] ['sid'] . "-%' and receivablesCategory like '" . $st [0] ['cid'] . ":%' and bindStatus=0",
  3220. 'desc' => 'irid',
  3221. 'asArray' => TRUE
  3222. ) );
  3223. // 发票审批
  3224. $approval = $invoice->getOne ( array (
  3225. 'where' => 'status=1 and pendingApprovals=' . $st [0] ['sid'],
  3226. 'desc' => 'iid',
  3227. 'asArray' => true
  3228. ) );
  3229. // 发票邮寄
  3230. $post = $invoice->getOne ( array (
  3231. 'where' => "postStatus=0 and doPost=1 and status=2",
  3232. 'asArray' => TRUE
  3233. ) );
  3234. // 发票打印
  3235. $print = $invoice->getOne ( array (
  3236. 'where' => "status=2 and printStatus=0 and moldManage like '%[\"" . $st [0] ['sid'] . "\",%'",
  3237. 'desc' => 'iid',
  3238. 'asArray' => TRUE
  3239. ) );
  3240. // 发票退票
  3241. $untread = $invoice->getOne ( array (
  3242. 'where' => " printStatus=1 and untreadStatus=1 and status=2 ",
  3243. 'asArray' => TRUE
  3244. ) );
  3245. $new = array (
  3246. 'GLOBAL' => FALSE,
  3247. 'pendingInvoice' => FALSE,
  3248. 'myClaim' => FALSE,
  3249. 'approval' => FALSE,
  3250. 'post' => FALSE,
  3251. 'print' => FALSE,
  3252. 'untread' => FALSE
  3253. );
  3254. if (! empty ( $pendingInvoice ) || ! empty ( $myClaim ) || ! empty ( $approval ) || ! empty ( $post ) || ! empty ( $print ) || ! empty ( $untread ))
  3255. $new ['GLOBAL'] = TRUE;
  3256. if (! empty ( $pendingInvoice ))
  3257. $new ['pendingInvoice'] = TRUE;
  3258. if (! empty ( $myClaim ))
  3259. $new ['myClaim'] = TRUE;
  3260. if (! empty ( $approval ))
  3261. $new ['approval'] = TRUE;
  3262. if (! empty ( $post ))
  3263. $new ['post'] = TRUE;
  3264. if (! empty ( $print ))
  3265. $new ['print'] = TRUE;
  3266. if (! empty ( $untread ))
  3267. $new ['untread'] = TRUE;
  3268. return $new;
  3269. }
  3270. function setWXMsg($rid, $uid) {
  3271. Doo::loadModel ( 'invoice' );
  3272. $invoice = new invoice ();
  3273. $receiptDetail = $invoice->getOne ( array (
  3274. 'where' => 'iid=' . $rid,
  3275. 'asArray' => true
  3276. ) );
  3277. if (! empty ( $receiptDetail )) {
  3278. Doo::loadModel ( 'staff' );
  3279. $staff = new staff ();
  3280. $staffmsg = $staff->getOne ( array (
  3281. 'where' => "sid='" . $uid . "'",
  3282. 'asArray' => TRUE
  3283. ) );
  3284. if (! empty ( $staffmsg ['wxid'] )) {
  3285. require_once (SITE_PATH . '/protected/class/client.php');
  3286. $client = new client ( 'http://m.cld.smartcost.com.cn/' );
  3287. $user = $staffmsg ['wxid'];
  3288. $receiptName = '费用';
  3289. $msg = '';
  3290. // switch ($receiptDetail ['Rtype']) {
  3291. // case 0 :
  3292. // $receiptName = '报销';
  3293. // break;
  3294. // case 1 :
  3295. // $receiptName = '借款';
  3296. // break;
  3297. // case 2 :
  3298. // $receiptName = '对公汇款';
  3299. // break;
  3300. // }
  3301. // 单位名称 金额 开票内容 已邮寄,顺丰 123123213
  3302. switch (2) {
  3303. case 1 :
  3304. $msg = '太好了,您的' . $receiptName . ' ' . $receiptDetail ['invoiceElement'] . ',¥' . $receiptDetail ['invoicePrice'] . ',已同意支付。';
  3305. break;
  3306. case 2 :
  3307. $msg = '注意,您的' . $receiptName . ' ' . $receiptDetail ['invoiceElement'] . ',¥' . $receiptDetail ['invoicePrice'] . ',已被撤回,请及时处理。';
  3308. break;
  3309. case 3 :
  3310. $msg = '很遗憾,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已被终止。';
  3311. break;
  3312. }
  3313. $result = $client->SendMsg ( $user, $msg, 'text' );
  3314. }
  3315. }
  3316. }
  3317. }
  3318. ?>