InvoiceController.php 142 KB

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