InvoiceController.php 136 KB

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