InvoiceController.php 123 KB

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