InvoiceController.php 112 KB

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