InvoiceController.php 96 KB

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