InvoiceController.php 132 KB

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