InvoiceController.php 129 KB

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