InvoiceController.php 142 KB

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