InvoiceController.php 102 KB

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