InvoiceController.php 136 KB

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