InvoiceController.php 105 KB

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