InvoiceController.php 134 KB

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