InvoiceController.php 99 KB

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