InvoiceController.php 36 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105
  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. private $INVOICEKEY = "APPROVAL";
  12. function __construct() {
  13. if (isset ( $_COOKIE ["staff"] )) {
  14. if (! empty ( $_COOKIE ["staff"] )) {
  15. Doo::loadModel ( 'staff' );
  16. $staff = new staff ();
  17. Doo::loadModel ( "invoiceManage" );
  18. $invoiceManage = new invoiceManage ();
  19. // $invoiceManage
  20. $this->staff = $staff->getUserByIdList ( $_COOKIE ["staff"] );
  21. return "/";
  22. }
  23. }
  24. Doo::loadCore ( 'uri/DooUriRouter' );
  25. $router = new DooUriRouter ();
  26. $routeRs = $router->execute ( Doo::app ()->route, Doo::conf ()->SUBFOLDER );
  27. if ($routeRs ['1'] != "login") {
  28. header ( 'Content-Type:text/html;charset=utf-8' );
  29. @header ( "Location: /login" );
  30. }
  31. }
  32. function invoice() {
  33. Doo::loadModel ( 'invoice' );
  34. $invoice = new invoice ();
  35. Doo::loadModel ( 'express' );
  36. $express = new express ();
  37. $expressList = $express->getExpressByAll ();
  38. $invoiceList = $invoice->getMyInvoice ( $_COOKIE ["staff"] );
  39. $data ['expressList'] = $expressList;
  40. $data ['invoiceList'] = $invoiceList;
  41. $data ['memu'] = "invoice";
  42. $data ['staff'] = $this->staff;
  43. $data ['receiptMemu'] = 'invoice';
  44. $this->render ( "/admin/invoice", $data );
  45. }
  46. function invoiceAdd() {
  47. Doo::loadModel ( 'L_category' );
  48. $lCategory = new L_category ();
  49. $category = $lCategory->find ( array (
  50. 'asArray' => true
  51. ) );
  52. $data ['category'] = $category;
  53. $data ['memu'] = "invoice";
  54. $data ['staff'] = $this->staff;
  55. $data ['receiptMemu'] = 'invoice';
  56. $this->render ( "/admin/invoiceAdd", $data );
  57. }
  58. /**
  59. * 提交一份开票申请,并记录下操作日志
  60. *
  61. * @since 1.0.0
  62. * @var integer cid 办事处ID
  63. * @var integer invoiceType 发票类型
  64. * @var integer doPost 是否邮寄
  65. * @var integer invoicePrice 开票金额
  66. * @var string invoiceElement 开票内容
  67. * @var string invoiceTitle 发票抬头
  68. * @var string invoiceCompany 单位名称
  69. * @var string TIN 纳税人识别码
  70. * @var string address 注册地址
  71. * @var string phone 注册电话
  72. * @var string bank 开户银行
  73. * @var string bankAccount 银行账户
  74. * @var string recipients 收件人
  75. * @var string recipientsPhone 收件人手机/电话
  76. * @var string recipientsAddress 收件地址
  77. * @var string mailItems 邮寄物品
  78. * @var string remark 备注
  79. * @return string 返回跳转开票主页路径
  80. */
  81. function invoiceAddDo() {
  82. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  83. $invoiceType = $this->get_args ( 'invoiceType' ) && is_numeric ( $this->get_args ( 'invoiceType' ) ) ? $this->get_args ( 'invoiceType' ) : 0;
  84. $doPost = $this->get_args ( 'doPost' ) && is_numeric ( $this->get_args ( 'doPost' ) ) ? $this->get_args ( 'doPost' ) : 0;
  85. $invoicePrice = $this->get_args ( 'invoicePrice' ) ? $this->get_args ( 'invoicePrice' ) : "";
  86. $invoiceElement = $this->get_args ( 'invoiceElement' ) ? $this->get_args ( 'invoiceElement' ) : "";
  87. $invoiceTitle = $this->get_args ( 'invoiceTitle' ) ? $this->get_args ( 'invoiceTitle' ) : "";
  88. $invoiceCompany = $this->get_args ( 'invoiceCompany' ) ? $this->get_args ( 'invoiceCompany' ) : "";
  89. $TIN = $this->get_args ( 'TIN' ) ? $this->get_args ( 'TIN' ) : "";
  90. $address = $this->get_args ( 'address' ) ? $this->get_args ( 'address' ) : "";
  91. $phone = $this->get_args ( 'phone' ) ? $this->get_args ( 'phone' ) : "";
  92. $bank = $this->get_args ( 'bank' ) ? $this->get_args ( 'bank' ) : "";
  93. $bankAccount = $this->get_args ( 'bankAccount' ) ? $this->get_args ( 'bankAccount' ) : "";
  94. $recipients = $this->get_args ( 'recipients' ) ? $this->get_args ( 'recipients' ) : "";
  95. $recipientsPhone = $this->get_args ( 'recipientsPhone' ) ? $this->get_args ( 'recipientsPhone' ) : "";
  96. $recipientsAddress = $this->get_args ( 'recipientsAddress' ) ? $this->get_args ( 'recipientsAddress' ) : "";
  97. $mailItems = $this->get_args ( 'mailItems' ) ? $this->get_args ( 'mailItems' ) : "";
  98. $remark = $this->get_args ( 'remark' ) ? $this->get_args ( 'remark' ) : "";
  99. if (! empty ( $cid ) && ! empty ( $invoicePrice ) && ! empty ( $invoiceElement )) {
  100. Doo::loadModel ( 'invoice' );
  101. $invoice = new invoice ();
  102. Doo::loadModel ( 'L_category' );
  103. $lCategory = new L_category ();
  104. Doo::loadModel ( 'invoiceManage' );
  105. $invoiceManage = new invoiceManage ();
  106. Doo::loadModel ( 'invoiceOperationLog' );
  107. $invoiceOperationLog = new invoiceOperationLog ();
  108. $categoryDetil = $lCategory->getOne ( array (
  109. 'SELECT' => 'title',
  110. 'where' => 'cid=' . $cid,
  111. 'asArray' => true
  112. ) );
  113. $invoiceManageList = $invoiceManage->getInvoiceByAll ();
  114. $invoiceManageDetail = $invoiceManage->getInvoiceByMold ( "发票审批" );
  115. $moldManage = array ();
  116. foreach ( $invoiceManageList as $key => $value ) {
  117. if ($value ['mold'] == '发票打印')
  118. $moldManage [$value ['mold']] = $value ['staffList'];
  119. elseif ($value ['mold'] == '发票邮寄')
  120. $moldManage [$value ['mold']] = $value ['staffList'];
  121. elseif ($value ['mold'] == '发票退票')
  122. $moldManage [$value ['mold']] = $value ['staffList'];
  123. }
  124. $item = array (
  125. 'cid' => $cid,
  126. 'categoryName' => $categoryDetil ['title'],
  127. 'invoiceElement' => $invoiceElement,
  128. 'invoicePrice' => $invoicePrice,
  129. 'invoiceType' => $invoiceType,
  130. 'doPost' => $doPost,
  131. 'status' => 1,
  132. 'invoiceSerial' => "#F" . date ( "Ymd" ) . mt_rand ( 1000, 9999 ),
  133. 'date' => date ( "Y-m-d H:i:s" ),
  134. 'updateTime' => date ( "Y-m-d H:i:s" ),
  135. 'sid' => $this->staff [0] ['sid'],
  136. 'userName' => $this->staff [0] ['username'],
  137. 'invoiceManage' => $invoiceManageDetail ['staff'],
  138. 'pendingApprovals' => $invoiceManageDetail ['staffList'] [0] [0],
  139. 'moldManage' => json_encode ( $moldManage ),
  140. 'remark' => $remark
  141. );
  142. if ($invoiceType == 0)
  143. $item += array (
  144. 'invoiceTitle' => $invoiceTitle
  145. );
  146. else {
  147. $item += array (
  148. 'invoiceCompany' => $invoiceCompany,
  149. 'TIN' => $TIN,
  150. 'address' => $address,
  151. 'phone' => $phone,
  152. 'bank' => $bank,
  153. 'bankAccount' => $bankAccount
  154. );
  155. }
  156. if ($doPost == 1) {
  157. $item += array (
  158. 'recipients' => $recipients,
  159. 'recipientsPhone' => $recipientsPhone,
  160. 'recipientsAddress' => $recipientsAddress,
  161. 'mailItems' => $mailItems
  162. );
  163. }
  164. $iid = $invoice->addInvoice ( $item );
  165. $item = array (
  166. 'date' => date ( "Y-m-d H:i:s" ),
  167. 'operation' => "创建",
  168. 'status' => 1,
  169. 'img' => $this->staff [0] ['avatar'],
  170. 'username' => $this->staff [0] ['username'],
  171. 'uid' => $this->staff [0] ['sid'],
  172. 'category' => $this->staff [0] ['category'],
  173. 'iid' => $iid
  174. );
  175. $invoiceOperationLog->setInvoiceOperationLog ( $item );
  176. $item = array (
  177. 'date' => date ( "Y-m-d H:i:s" ),
  178. 'operation' => "提交审批",
  179. 'status' => 1,
  180. 'img' => $this->staff [0] ['avatar'],
  181. 'username' => $this->staff [0] ['username'],
  182. 'uid' => $this->staff [0] ['sid'],
  183. 'category' => $this->staff [0] ['category'],
  184. 'iid' => $iid
  185. );
  186. $invoiceOperationLog->setInvoiceOperationLog ( $item );
  187. }
  188. return "/invoice";
  189. }
  190. function invoiceEdit() {
  191. Doo::loadClass ( 'XDeode' );
  192. $XDeode = new XDeode ( 5 );
  193. $iid = isset ( $this->params ['iid'] ) ? $this->params ['iid'] : "";
  194. $iid = $XDeode->decode ( $iid );
  195. if (! is_numeric ( $iid ))
  196. die ( 'illegal request' );
  197. Doo::loadModel ( 'invoice' );
  198. $invoice = new invoice ();
  199. Doo::loadModel ( 'invoiceOperationLog' );
  200. $invoiceOperationLog = new invoiceOperationLog ();
  201. $invoiceDetail = $invoice->getInvoiceByIid ( $iid );
  202. $operation = $invoiceOperationLog->getInvoiceOperationByDropped ( $iid );
  203. $data ['operation'] = $operation;
  204. $data ['invoiceDetail'] = $invoiceDetail;
  205. $data ['memu'] = "invoice";
  206. $data ['staff'] = $this->staff;
  207. $data ['receiptMemu'] = 'invoiceApproval';
  208. $this->render ( "/admin/invoiceEdit", $data );
  209. }
  210. /**
  211. * 重新编辑退回的发票
  212. * @return string
  213. */
  214. function invoiceEditDo() {
  215. $iidKey = $this->get_args ( 'iidKey' ) ? $this->get_args ( 'iidKey' ) : '';
  216. Doo::loadModel ( 'invoice' );
  217. $invoice = new invoice ();
  218. $iid = $invoice->authcode ( $iidKey );
  219. if (! empty ( $iid ) && ! is_numeric ( $iid ))
  220. die ( 'illegal request' );
  221. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  222. $invoiceType = $this->get_args ( 'invoiceType' ) && is_numeric ( $this->get_args ( 'invoiceType' ) ) ? $this->get_args ( 'invoiceType' ) : 0;
  223. $doPost = $this->get_args ( 'doPost' ) && is_numeric ( $this->get_args ( 'doPost' ) ) ? $this->get_args ( 'doPost' ) : 0;
  224. $invoicePrice = $this->get_args ( 'invoicePrice' ) ? $this->get_args ( 'invoicePrice' ) : "";
  225. $invoiceElement = $this->get_args ( 'invoiceElement' ) ? $this->get_args ( 'invoiceElement' ) : "";
  226. $invoiceTitle = $this->get_args ( 'invoiceTitle' ) ? $this->get_args ( 'invoiceTitle' ) : "";
  227. $invoiceCompany = $this->get_args ( 'invoiceCompany' ) ? $this->get_args ( 'invoiceCompany' ) : "";
  228. $TIN = $this->get_args ( 'TIN' ) ? $this->get_args ( 'TIN' ) : "";
  229. $address = $this->get_args ( 'address' ) ? $this->get_args ( 'address' ) : "";
  230. $phone = $this->get_args ( 'phone' ) ? $this->get_args ( 'phone' ) : "";
  231. $bank = $this->get_args ( 'bank' ) ? $this->get_args ( 'bank' ) : "";
  232. $bankAccount = $this->get_args ( 'bankAccount' ) ? $this->get_args ( 'bankAccount' ) : "";
  233. $recipients = $this->get_args ( 'recipients' ) ? $this->get_args ( 'recipients' ) : "";
  234. $recipientsPhone = $this->get_args ( 'recipientsPhone' ) ? $this->get_args ( 'recipientsPhone' ) : "";
  235. $recipientsAddress = $this->get_args ( 'recipientsAddress' ) ? $this->get_args ( 'recipientsAddress' ) : "";
  236. $mailItems = $this->get_args ( 'mailItems' ) ? $this->get_args ( 'mailItems' ) : "";
  237. $remark = $this->get_args ( 'remark' ) ? $this->get_args ( 'remark' ) : "";
  238. if (! empty ( $cid ) && ! empty ( $invoicePrice ) && ! empty ( $invoiceElement ) && ! empty ( $iid )) {
  239. Doo::loadModel ( 'invoiceManage' );
  240. $invoiceManage = new invoiceManage ();
  241. Doo::loadModel ( 'invoiceOperationLog' );
  242. $invoiceOperationLog = new invoiceOperationLog ();
  243. $cid = explode ( ':', $cid );
  244. $invoiceManageList = $invoiceManage->getInvoiceByAll ();
  245. $invoiceManageDetail = $invoiceManage->getInvoiceByMold ( "发票审批" );
  246. $moldManage = array ();
  247. foreach ( $invoiceManageList as $key => $value ) {
  248. if ($value ['mold'] == '发票打印')
  249. $moldManage [$value ['mold']] = $value ['staffList'];
  250. elseif ($value ['mold'] == '发票邮寄')
  251. $moldManage [$value ['mold']] = $value ['staffList'];
  252. elseif ($value ['mold'] == '发票打印')
  253. $moldManage [$value ['mold']] = $value ['staffList'];
  254. }
  255. $item = array (
  256. 'iid' => $iid,
  257. 'cid' => $cid [0],
  258. 'categoryName' => $cid [1],
  259. 'invoiceElement' => $invoiceElement,
  260. 'invoicePrice' => $invoicePrice,
  261. 'invoiceType' => $invoiceType,
  262. 'doPost' => $doPost,
  263. 'status' => 1,
  264. 'updateTime' => date ( "Y-m-d H:i:s" ),
  265. 'remark' => $remark
  266. );
  267. if ($invoiceType == 0)
  268. $item += array (
  269. 'invoiceTitle' => $invoiceTitle
  270. );
  271. else {
  272. $item += array (
  273. 'invoiceCompany' => $invoiceCompany,
  274. 'TIN' => $TIN,
  275. 'address' => $address,
  276. 'phone' => $phone,
  277. 'bank' => $bank,
  278. 'bankAccount' => $bankAccount
  279. );
  280. }
  281. if ($doPost == 1) {
  282. $item += array (
  283. 'recipients' => $recipients,
  284. 'recipientsPhone' => $recipientsPhone,
  285. 'recipientsAddress' => $recipientsAddress,
  286. 'mailItems' => $mailItems
  287. );
  288. }
  289. $invoice->setInvoiceByCondition ( $item );
  290. $item = array (
  291. 'date' => date ( "Y-m-d H:i:s" ),
  292. 'operation' => "重新提交审批",
  293. 'status' => 1,
  294. 'img' => $this->staff [0] ['avatar'],
  295. 'username' => $this->staff [0] ['username'],
  296. 'uid' => $this->staff [0] ['sid'],
  297. 'category' => $this->staff [0] ['category'],
  298. 'iid' => $iid
  299. );
  300. $invoiceOperationLog->setInvoiceOperationLog ( $item );
  301. }
  302. return "/invoice";
  303. }
  304. /**
  305. * 终止开票
  306. */
  307. function invoiceDroppedDo() {
  308. $droppedIidKey = $this->get_args ( 'droppedIidKey' ) ? $this->get_args ( 'droppedIidKey' ) : '';
  309. Doo::loadModel ( 'invoice' );
  310. $invoice = new invoice ();
  311. Doo::loadModel ( 'invoiceOperationLog' );
  312. $invoiceOperationLog = new invoiceOperationLog ();
  313. $iid = $invoice->authcode ( $droppedIidKey );
  314. if (! empty ( $iid ) && ! is_numeric ( $iid ))
  315. die ( 'illegal request' );
  316. $item = array (
  317. 'iid' => $iid,
  318. 'status' => 4,
  319. 'updateTime' => date ( "Y-m-d H:i:s" )
  320. );
  321. $invoice->setInvoiceByCondition ( $item );
  322. $item = array (
  323. 'date' => date ( "Y-m-d H:i:s" ),
  324. 'operation' => '终止了开票',
  325. 'status' => 4,
  326. 'img' => $this->staff [0] ['avatar'],
  327. 'username' => $this->staff [0] ['username'],
  328. 'uid' => $this->staff [0] ['sid'],
  329. 'category' => $this->staff [0] ['category'],
  330. 'iid' => $iid
  331. );
  332. $invoiceOperationLog->setInvoiceOperationLog ( $item );
  333. return "/invoice";
  334. }
  335. /**
  336. * 申请退票
  337. */
  338. function invoiceUntreadDo() {
  339. $untreadIidKey = $this->get_args ( 'untreadIidKey' ) ? $this->get_args ( 'untreadIidKey' ) : '';
  340. $untreadReason = $this->get_args ( 'untreadReason' ) ? $this->get_args ( 'untreadReason' ) : "";
  341. $untreadPost = $this->get_args ( 'untreadPost' ) ? $this->get_args ( 'untreadPost' ) : "";
  342. $untreadCompany = $this->get_args ( 'untreadCompany' ) ? $this->get_args ( 'untreadCompany' ) : "";
  343. $untreadNumber = $this->get_args ( 'untreadNumber' ) ? $this->get_args ( 'untreadNumber' ) : "";
  344. $untreadItems = $this->get_args ( 'untreadItems' ) ? $this->get_args ( 'untreadItems' ) : "";
  345. Doo::loadModel ( 'invoice' );
  346. $invoice = new invoice ();
  347. Doo::loadModel ( 'invoiceOperationLog' );
  348. $invoiceOperationLog = new invoiceOperationLog ();
  349. $iid = $invoice->authcode ( $untreadIidKey );
  350. if (! empty ( $iid ) && ! is_numeric ( $iid ))
  351. die ( 'illegal request' );
  352. $item = array (
  353. 'iid' => $iid,
  354. 'untreadStatus' => 1,
  355. 'untreadReason' => $untreadReason,
  356. 'untreadPost' => $untreadPost,
  357. 'updateTime' => date ( "Y-m-d H:i:s" )
  358. );
  359. if ($untreadPost == 1) {
  360. $item += array (
  361. 'untreadCompany' => $untreadCompany,
  362. 'untreadNumber' => $untreadNumber,
  363. 'untreadItems' => $untreadItems
  364. );
  365. }
  366. $invoice->setInvoiceByCondition ( $item );
  367. $item = array (
  368. 'date' => date ( "Y-m-d H:i:s" ),
  369. 'operation' => '申请退票',
  370. 'status' => 7,
  371. 'img' => $this->staff [0] ['avatar'],
  372. 'username' => $this->staff [0] ['username'],
  373. 'uid' => $this->staff [0] ['sid'],
  374. 'category' => $this->staff [0] ['category'],
  375. 'iid' => $iid
  376. );
  377. $invoiceOperationLog->setInvoiceOperationLog ( $item );
  378. return "/invoice";
  379. }
  380. /**
  381. * 删除已终止的开票
  382. */
  383. function invoiceDelDo() {
  384. Doo::loadClass ( 'XDeode' );
  385. $XDeode = new XDeode ( 5 );
  386. Doo::loadModel ( 'invoice' );
  387. $invoice = new invoice ();
  388. Doo::loadModel ( 'invoiceOperationLog' );
  389. $invoiceOperationLog = new invoiceOperationLog ();
  390. $iid = isset ( $this->params ['iid'] ) ? $this->params ['iid'] : "";
  391. $iid = $XDeode->decode ( $iid );
  392. if (! is_numeric ( $iid ))
  393. die ( 'illegal request' );
  394. $invoiceDetail = $invoice->getMyInvoice ( $_COOKIE ["staff"], $iid );
  395. if (empty ( $invoiceDetail ))
  396. die ( 'illegal request' );
  397. $item = array (
  398. 'iid' => $iid,
  399. 'isDelete' => 1,
  400. 'updateTime' => date ( "Y-m-d H:i:s" )
  401. );
  402. $invoice->setInvoiceByCondition ( $item );
  403. $item = array (
  404. 'date' => date ( "Y-m-d H:i:s" ),
  405. 'operation' => '删除了已终止的发票',
  406. 'status' => 4,
  407. 'img' => $this->staff [0] ['avatar'],
  408. 'username' => $this->staff [0] ['username'],
  409. 'uid' => $this->staff [0] ['sid'],
  410. 'category' => $this->staff [0] ['category'],
  411. 'iid' => $iid
  412. );
  413. $invoiceOperationLog->setInvoiceOperationLog ( $item );
  414. return "/invoice";
  415. }
  416. function invoiceApproval() {
  417. Doo::loadModel ( 'invoice' );
  418. $invoice = new invoice ();
  419. Doo::loadClass ( 'XDeode' );
  420. $XDeode = new XDeode ( 5 );
  421. Doo::loadModel ( 'staff' );
  422. $staff = new staff ();
  423. $invoiceList = $invoice->find ( array (
  424. 'where' => 'status=1 and pendingApprovals=' . $this->staff [0] ['sid'],
  425. 'desc' => 'iid',
  426. 'asArray' => true
  427. ) );
  428. foreach ( $invoiceList as $key => $value ) {
  429. $invoiceList [$key] ['iidKey'] = $XDeode->encode ( $value ['iid'] );
  430. $lastApprover = json_decode ( $value ['processApprovals'], true );
  431. if (! empty ( $lastApprover )) {
  432. $lastApproverKey = array_keys ( $lastApprover );
  433. $lastApprover = end ( $lastApprover );
  434. $staffDetail = $staff->getOne ( array (
  435. 'where' => 'sid=' . end ( $lastApproverKey ),
  436. 'asArray' => true
  437. ) );
  438. $lastApprover ['username'] = $staffDetail ['username'];
  439. }
  440. $invoiceList [$key] ['lastApprover'] = $lastApprover;
  441. }
  442. $data ['invoiceList'] = $invoiceList;
  443. $data ['memu'] = "invoice";
  444. $data ['staff'] = $this->staff;
  445. $data ['receiptMemu'] = 'invoiceApproval';
  446. $this->render ( "/admin/invoiceApproval", $data );
  447. }
  448. function invoiceDetail() {
  449. Doo::loadClass ( 'XDeode' );
  450. $XDeode = new XDeode ( 5 );
  451. $iid = isset ( $this->params ['iid'] ) ? $this->params ['iid'] : "";
  452. $iid = $XDeode->decode ( $iid );
  453. if (! is_numeric ( $iid ))
  454. die ( 'illegal request' );
  455. Doo::loadModel ( 'invoice' );
  456. $invoice = new invoice ();
  457. Doo::loadModel ( 'invoiceOperationLog' );
  458. $invoiceOperationLog = new invoiceOperationLog ();
  459. $invoiceDetail = $invoice->getOne ( array (
  460. 'where' => 'status=1 and pendingApprovals=' . $this->staff [0] ['sid'] . ' and iid=' . $iid,
  461. 'asArray' => true
  462. ) );
  463. $invoiceOperationLogList = $invoiceOperationLog->getInvoiceOperationLogByIid ( $iid );
  464. $data ['invoiceDetail'] = $invoiceDetail;
  465. $data ['invoiceOperationLogList'] = $invoiceOperationLogList;
  466. $data ['INVOICEKEY'] = $invoice->authcode ( $invoiceDetail ['iid'], '' );
  467. $data ['memu'] = "invoice";
  468. $data ['staff'] = $this->staff;
  469. $data ['receiptMemu'] = 'invoiceApproval';
  470. $this->render ( "/admin/invoiceApprovalDetail", $data );
  471. }
  472. /**
  473. * 对发票进行审批,其中操作有终止,退回,同意动作。操作成功并记录下操作日志
  474. *
  475. * @since 1.0.0
  476. * @var integer iid 开票ID 已加密
  477. * @var integer status 发票审批状态
  478. * @var integer opintion 审批发票的意见
  479. * @return string 如操作成功返回审批首页
  480. */
  481. function invoiceApprovalDo() {
  482. Doo::loadModel ( 'invoice' );
  483. $invoice = new invoice ();
  484. $iid = $this->get_args ( 'invoiceKey' ) ? $this->get_args ( 'invoiceKey' ) : "";
  485. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  486. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  487. $iid = $invoice->authcode ( $iid );
  488. if (! is_numeric ( $iid ))
  489. die ( 'illegal request' );
  490. if (! empty ( $iid ) && ! empty ( $status ) && ! empty ( $opinion )) {
  491. if (! ($status == 2 || $status == 3 || $status == 4))
  492. die ( 'illegal request' );
  493. Doo::loadModel ( 'invoiceOperationLog' );
  494. $invoiceOperationLog = new invoiceOperationLog ();
  495. $invoiceDetail = $invoice->getOne ( array (
  496. 'where' => 'status=1 and iid=' . $iid . ' and pendingApprovals=' . $this->staff [0] ['sid'],
  497. 'asArray' => true
  498. ) );
  499. if (empty ( $invoiceDetail ))
  500. die ( 'illegal request' );
  501. $processApprovals = json_decode ( $invoiceDetail ['processApprovals'], true );
  502. $invoiceManage = json_decode ( $invoiceDetail ['invoiceManage'], true );
  503. if ($status == 3) {
  504. $invoice->status = $status;
  505. $item = array (
  506. 'operation' => $opinion
  507. );
  508. } else {
  509. if (empty ( $processApprovals )) {
  510. $processApprovals = array (
  511. $this->staff [0] ['sid'] => array (
  512. 'date' => date ( "Y-m-d H:i:s" ),
  513. 'opinion' => $opinion,
  514. 'status' => $status
  515. )
  516. );
  517. if ($status != 4 && isset ( $invoiceManage [1] ))
  518. $invoice->pendingApprovals = $invoiceManage [1] [0];
  519. $invoice->processApprovals = json_encode ( $processApprovals );
  520. } else {
  521. $processApprovals [$this->staff [0] ['sid']] = array (
  522. 'date' => date ( "Y-m-d H:i:s" ),
  523. 'opinion' => $opinion,
  524. 'status' => $status
  525. );
  526. $pendingApprovals = 0;
  527. foreach ( $invoiceManage as $key => $value ) {
  528. if ($value [0] == $this->staff [0] ['sid']) {
  529. if (isset ( $invoiceManage [$key + 1] ))
  530. $pendingApprovals = $invoiceManage [$key + 1] [0];
  531. break;
  532. }
  533. }
  534. if ($status != 4 && ! empty ( $pendingApprovals ))
  535. $invoice->pendingApprovals = $pendingApprovals;
  536. $invoice->processApprovals = json_encode ( $processApprovals );
  537. }
  538. $item = array (
  539. 'operation' => $opinion
  540. );
  541. if (count ( $processApprovals ) == count ( $invoiceManage ) && $status != 4) {
  542. $invoice->status = $status;
  543. $invoice->pendingApprovals = 0;
  544. } elseif ($status == 4) {
  545. $invoice->status = $status;
  546. $item = array (
  547. 'operation' => $opinion
  548. );
  549. }
  550. }
  551. $invoice->updateTime = date ( "Y-m-d H:i:s" );
  552. $invoice->update ( array (
  553. 'where' => 'iid=' . $iid
  554. ) );
  555. $item += array (
  556. 'date' => date ( "Y-m-d H:i:s" ),
  557. 'img' => $this->staff [0] ['avatar'],
  558. 'username' => $this->staff [0] ['username'],
  559. 'uid' => $this->staff [0] ['sid'],
  560. 'category' => $this->staff [0] ['category'],
  561. 'status' => $status,
  562. 'iid' => $iid
  563. );
  564. $invoiceOperationLog->setInvoiceOperationLog ( $item );
  565. return '/invoiceApproval';
  566. }
  567. die ( 'illegal request' );
  568. }
  569. /**
  570. * 展示需要打印的发票数据
  571. *
  572. * @since 1.0.0
  573. */
  574. function invoicePrint() {
  575. Doo::loadModel ( 'invoice' );
  576. $invoice = new invoice ();
  577. Doo::loadClass ( 'XDeode' );
  578. $XDeode = new XDeode ( 5 );
  579. Doo::loadModel ( 'staff' );
  580. $staff = new staff ();
  581. $toPrint = $invoice->getPrintInvoiceByManage ( $this->staff [0] ['sid'], 0 );
  582. $printed = $invoice->getPrintInvoiceByManage ( $this->staff [0] ['sid'], 1 );
  583. foreach ( $toPrint as $key => $value ) {
  584. $toPrint [$key] ['iidKey'] = $XDeode->encode ( $value ['iid'] );
  585. $lastApprover = json_decode ( $value ['processApprovals'], true );
  586. if (! empty ( $lastApprover )) {
  587. $lastApproverKey = array_keys ( $lastApprover );
  588. $lastApprover = end ( $lastApprover );
  589. $staffDetail = $staff->getOne ( array (
  590. 'where' => 'sid=' . end ( $lastApproverKey ),
  591. 'asArray' => true
  592. ) );
  593. $lastApprover ['username'] = $staffDetail ['username'];
  594. }
  595. $toPrint [$key] ['lastApprover'] = $lastApprover;
  596. }
  597. foreach ( $printed as $key => $value ) {
  598. $printed [$key] ['iidKey'] = $XDeode->encode ( $value ['iid'] );
  599. $lastApprover = json_decode ( $value ['processApprovals'], true );
  600. if (! empty ( $lastApprover )) {
  601. $lastApproverKey = array_keys ( $lastApprover );
  602. $lastApprover = end ( $lastApprover );
  603. $staffDetail = $staff->getOne ( array (
  604. 'where' => 'sid=' . end ( $lastApproverKey ),
  605. 'asArray' => true
  606. ) );
  607. $lastApprover ['username'] = $staffDetail ['username'];
  608. }
  609. $printed [$key] ['lastApprover'] = $lastApprover;
  610. }
  611. $data ['printed'] = $printed;
  612. $data ['toPrint'] = $toPrint;
  613. $data ['memu'] = "invoice";
  614. $data ['staff'] = $this->staff;
  615. $data ['receiptMemu'] = 'invoicePrint';
  616. $this->render ( "/admin/invoicePrint", $data );
  617. }
  618. /**
  619. * 展示发票打印的详情页面
  620. *
  621. * @since 1.0.0
  622. */
  623. function invoicePrintDetail() {
  624. Doo::loadClass ( 'XDeode' );
  625. $XDeode = new XDeode ( 5 );
  626. $iid = isset ( $this->params ['iid'] ) ? $this->params ['iid'] : "";
  627. $iid = $XDeode->decode ( $iid );
  628. if (! is_numeric ( $iid ))
  629. die ( 'illegal request' );
  630. Doo::loadModel ( 'invoice' );
  631. $invoice = new invoice ();
  632. Doo::loadModel ( 'invoiceOperationLog' );
  633. $invoiceOperationLog = new invoiceOperationLog ();
  634. $invoiceDetail = $invoice->getPrintInvoiceByManage ( $this->staff [0] ['sid'], 0, $iid );
  635. // if (empty ( $invoiceDetail ))
  636. // die ( 'illegal request' );
  637. $invoiceOperationLogList = $invoiceOperationLog->getInvoiceOperationLogByIid ( $iid );
  638. $data ['invoiceDetail'] = $invoiceDetail;
  639. $data ['invoiceOperationLogList'] = $invoiceOperationLogList;
  640. $data ['INVOICEKEY'] = $invoice->authcode ( $invoiceDetail ['iid'], '' );
  641. $data ['memu'] = "invoice";
  642. $data ['staff'] = $this->staff;
  643. $data ['receiptMemu'] = 'invoicePrint';
  644. $this->render ( "/admin/invoicePrintDetail", $data );
  645. }
  646. /**
  647. * 填写票号并完成打印
  648. * @since 1.0.0
  649. */
  650. function invoicePrintDo() {
  651. Doo::loadModel ( 'invoice' );
  652. $invoice = new invoice ();
  653. $iid = $this->get_args ( 'invoiceKey' ) ? $this->get_args ( 'invoiceKey' ) : "";
  654. $invoiceNo = $this->get_args ( 'invoiceNo' ) ? $this->get_args ( 'invoiceNo' ) : "";
  655. $iid = $invoice->authcode ( $iid );
  656. if (! is_numeric ( $iid ))
  657. die ( 'illegal request' );
  658. if (! empty ( $iid ) && ! empty ( $invoiceNo )) {
  659. Doo::loadModel ( 'invoiceOperationLog' );
  660. $invoiceOperationLog = new invoiceOperationLog ();
  661. $invoicePrintDetail = $invoice->getInvoiceByPrint ( $iid );
  662. if (empty ( $invoicePrintDetail ))
  663. die ( 'illegal request' );
  664. $item = array (
  665. 'iid' => $iid,
  666. 'printStatus' => 1,
  667. 'updateTime' => date ( "Y-m-d H:i:s" ),
  668. 'printTime' => date ( "Y-m-d H:i:s" ),
  669. 'invoiceNo' => $invoiceNo
  670. );
  671. $invoice->setInvoiceByCondition ( $item );
  672. $item = array (
  673. 'date' => date ( "Y-m-d H:i:s" ),
  674. 'operation' => $invoiceNo,
  675. 'status' => 5,
  676. 'img' => $this->staff [0] ['avatar'],
  677. 'username' => $this->staff [0] ['username'],
  678. 'uid' => $this->staff [0] ['sid'],
  679. 'category' => $this->staff [0] ['category'],
  680. 'iid' => $iid
  681. );
  682. $invoiceOperationLog->setInvoiceOperationLog ( $item );
  683. return "/invoicePrint";
  684. }
  685. }
  686. /**
  687. * 需要邮寄的发票
  688. * @since 1.0.0
  689. */
  690. function invoicePost() {
  691. Doo::loadModel ( 'invoice' );
  692. $invoice = new invoice ();
  693. Doo::loadModel ( 'express' );
  694. $express = new express ();
  695. $invoicePost = $invoice->getPostByInvoice ();
  696. $invoicePosted = $invoice->getPostByInvoice ( 1 );
  697. $expressList = $express->getExpressByAll ();
  698. $data ['expressList'] = $expressList;
  699. $data ['invoicePost'] = $invoicePost;
  700. $data ['invoicePosted'] = $invoicePosted;
  701. $data ['memu'] = "invoice";
  702. $data ['staff'] = $this->staff;
  703. $data ['receiptMemu'] = 'invoicePost';
  704. $this->render ( "/admin/invoicePost", $data );
  705. }
  706. /**
  707. * 添加发票邮寄信息
  708. */
  709. function invoiceExpressAddDo() {
  710. Doo::loadModel ( 'invoice' );
  711. $invoice = new invoice ();
  712. $iid = $this->get_args ( 'iidKey' ) ? $this->get_args ( 'iidKey' ) : "";
  713. $expressCompany = $this->get_args ( 'express' ) ? $this->get_args ( 'express' ) : "";
  714. $expressNumber = $this->get_args ( 'nu' ) ? $this->get_args ( 'nu' ) : "";
  715. $actualItems = $this->get_args ( 'actualItems' ) ? $this->get_args ( 'actualItems' ) : "";
  716. $iid = $iid = $invoice->authcode ( $iid );
  717. if (! is_numeric ( $iid ) && empty ( $expressCompany ) && empty ( $expressNumber ) && empty ( $actualItems ))
  718. die ( 'illegal request' );
  719. $item = array (
  720. 'iid' => $iid,
  721. 'postStatus' => 1,
  722. 'updateTime' => date ( "Y-m-d H:i:s" ),
  723. 'postTime' => date ( "Y-m-d H:i:s" ),
  724. 'expressCompany' => $expressCompany,
  725. 'expressNumber' => $expressNumber,
  726. 'actualItems' => $actualItems,
  727. 'poster' => $staff [0] ['username']
  728. );
  729. $invoice->setInvoiceByCondition ( $item );
  730. return '/invoicePost';
  731. }
  732. /**
  733. * 退票处理页面
  734. */
  735. function invoiceUntread() {
  736. Doo::loadModel ( 'invoice' );
  737. $invoice = new invoice ();
  738. $untreadInvoice = $invoice->getInvoiceByUntreadStatus ( 1 );
  739. $establishedInvoice = $invoice->getInvoiceByUntreadStatus ( 2 );
  740. $data ['untreadInvoice'] = $untreadInvoice;
  741. $data ['establishedInvoice'] = $establishedInvoice;
  742. $data ['memu'] = "invoice";
  743. $data ['staff'] = $this->staff;
  744. $data ['receiptMemu'] = 'invoiceUntread';
  745. $this->render ( "/admin/invoiceUntread", $data );
  746. }
  747. /**
  748. * 确认收到退回的发票,开票状态为退回
  749. */
  750. function invoiceUntreadEstablishedDo() {
  751. $untreadIidKey = $this->get_args ( 'untreadIidKey' ) ? $this->get_args ( 'untreadIidKey' ) : '';
  752. Doo::loadModel ( 'invoice' );
  753. $invoice = new invoice ();
  754. Doo::loadModel ( 'invoiceOperationLog' );
  755. $invoiceOperationLog = new invoiceOperationLog ();
  756. $iid = $invoice->authcode ( $untreadIidKey );
  757. if (! empty ( $iid ) && ! is_numeric ( $iid ))
  758. die ( 'illegal request' );
  759. $item = array (
  760. 'iid' => $iid,
  761. 'untreadStatus' => 2,
  762. 'updateTime' => date ( "Y-m-d H:i:s" )
  763. );
  764. $invoice->setInvoiceByCondition ( $item );
  765. $item = array (
  766. 'date' => date ( "Y-m-d H:i:s" ),
  767. 'operation' => '已确认退票',
  768. 'status' => 6,
  769. 'img' => $this->staff [0] ['avatar'],
  770. 'username' => $this->staff [0] ['username'],
  771. 'uid' => $this->staff [0] ['sid'],
  772. 'category' => $this->staff [0] ['category'],
  773. 'iid' => $iid
  774. );
  775. $invoiceOperationLog->setInvoiceOperationLog ( $item );
  776. return "/invoiceUntread";
  777. }
  778. function invoiceReceivables() {
  779. Doo::loadModel ( 'L_category' );
  780. $lCategory = new L_category ();
  781. Doo::loadModel('staff');
  782. $staff=new staff();
  783. $category = $lCategory->getCategory ();
  784. $staffList = $staff->getStaffByCid($this->staff[0]['cid']);
  785. $data ['staffList'] = $staffList;
  786. $data ['category'] = $category;
  787. $data ['memu'] = "invoice";
  788. $data ['staff'] = $this->staff;
  789. $data ['receiptMemu'] = 'invoiceReceivables';
  790. $this->render ( "/admin/invoiceReceivables", $data );
  791. }
  792. /**
  793. * 录入收款数据
  794. * @return string
  795. */
  796. function invoiceReceivablesDo() {
  797. $receivablesPrice = $this->get_args ( 'receivablesPrice' ) ? $this->get_args ( 'receivablesPrice' ) : "";
  798. $receivablesMessage = $this->get_args ( 'receivablesMessage' ) ? $this->get_args ( 'receivablesMessage' ) : "";
  799. $receivablesBank = $this->get_args ( 'receivablesBank' ) ? $this->get_args ( 'receivablesBank' ) : "";
  800. $receivablesDate = $this->get_args ( 'receivablesDate' ) ? $this->get_args ( 'receivablesDate' ) : "";
  801. $receivablesCategory = $this->get_args ( 'receivablesCategory' ) ? $this->get_args ( 'receivablesCategory' ) : "";
  802. $receivablesStaff = $this->get_args ( 'receivablesStaff' ) ? $this->get_args ( 'receivablesStaff' ) : "";
  803. Doo::loadModel ( 'invoiceReceivables' );
  804. $invoiceReceivables = new invoiceReceivables ();
  805. if (! empty ( $receivablesPrice ) && ! empty ( $receivablesMessage ) && ! empty ( $receivablesBank ) && ! empty ( $receivablesDate ) && ! empty ( $receivablesCategory ) && ! empty ( $receivablesStaff )) {
  806. $item = array (
  807. 'receivablesPrice' =>$receivablesPrice,
  808. 'receivablesMessage' =>$receivablesMessage,
  809. 'receivablesSerial' =>"#SK" . date ( "Ymd" ) . mt_rand ( 1000, 9999 ),
  810. 'receivablesBank' =>$receivablesBank,
  811. 'receivablesDate' =>$receivablesDate,
  812. 'inputStaff' =>$this->staff[0]['username'],
  813. 'receivablesCategory' =>$receivablesCategory,
  814. 'receivablesStaff' => $receivablesStaff
  815. );
  816. $irid = $invoiceReceivables->addInvoiceReceivables( $item );
  817. }
  818. return "/invoiceReceivables";
  819. }
  820. /**
  821. * 收款认领页面-包括公共认领 办事处认领 最近已认领数据
  822. */
  823. function invoiceReceivablesClaim(){
  824. Doo::loadModel ( 'invoiceReceivables' );
  825. $invoiceReceivables = new invoiceReceivables ();
  826. $receivablesList=$invoiceReceivables->getInvoiceReceivablesByClaim($this->staff[0]['cid']);
  827. $data ['receivablesList'] = $receivablesList;
  828. $data ['memu'] = "invoice";
  829. $data ['staff'] = $this->staff;
  830. $data ['receiptMemu'] = 'invoiceReceivablesClaim';
  831. $this->render ( "/admin/invoiceReceivablesClaim", $data );
  832. }
  833. /**
  834. * 管理员录入的收款 ,确认认领到谁的名下
  835. */
  836. function invoiceReceivablesAscription(){
  837. $irid = $this->get_args ( 'key' ) ? $this->get_args ( 'key' ) : "";
  838. Doo::loadModel ( 'invoiceReceivables' );
  839. $invoiceReceivables = new invoiceReceivables ();
  840. $detail=$invoiceReceivables->getInvoiceReceivablesByIrid($irid);
  841. if (!empty($detail)&&$detail['receivablesStaff']=='PUBLIC'){
  842. $item = array (
  843. 'irid' =>$detail['irid'],
  844. 'receivablesCategory' =>$this->staff[0]['cid'].":".$this->staff[0]['category'],
  845. 'receivablesStaff' => $this->staff[0]['sid']."-".$this->staff[0]['username'],
  846. 'confirmTime' => date ( "Y-m-d H:i:s" ),
  847. 'source' =>1
  848. );
  849. $invoiceReceivables->setInvoiceReceivablesByCondition( $item );
  850. }
  851. return "/invoiceReceivablesClaim";
  852. }
  853. /**
  854. *
  855. */
  856. function invoiceMyReceivables(){
  857. Doo::loadModel ( 'invoiceReceivables' );
  858. $invoiceReceivables = new invoiceReceivables ();
  859. $list=$invoiceReceivables->getInvoiceReceivablesByClaim($this->staff[0]['cid'],$this->staff[0]['sid']);
  860. $data ['list'] = $list;
  861. $data ['memu'] = "invoice";
  862. $data ['staff'] = $this->staff;
  863. $data ['receiptMemu'] = 'invoiceMyReceivables';
  864. $this->render ( "/admin/invoiceMyReceivables", $data );
  865. }
  866. /**
  867. * 获得与我有关可收款的发票
  868. */
  869. function ajaxGetInvoiceByStaff(){
  870. $irid = $this->get_args ( 'key' ) ? $this->get_args ( 'key' ) : "";
  871. Doo::loadModel ( 'invoice' );
  872. $invoice = new invoice ();
  873. $list=$invoice->getInvoiceByReceivables($this->staff[0]['sid']);
  874. echo json_encode ( array (
  875. 'status' => 1,
  876. 'list' => $list
  877. ) );
  878. }
  879. /**
  880. * 获取一条收款信息
  881. */
  882. function ajaxGetInvoiceReceivables(){
  883. $irid = $this->get_args ( 'key' ) ? $this->get_args ( 'key' ) : "";
  884. Doo::loadModel ( 'invoiceReceivables' );
  885. $invoiceReceivables = new invoiceReceivables ();
  886. $detail=$invoiceReceivables->getInvoiceReceivablesByIrid($irid);
  887. echo json_encode ( array (
  888. 'status' => 1,
  889. 'detail' => $detail
  890. ) );
  891. }
  892. /**
  893. * 异步获取办事处用户
  894. */
  895. function ajaxGetStaffByCategory() {
  896. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : "";
  897. Doo::loadModel('staff');
  898. $staff=new staff();
  899. if ($cid=="PUBLIC"){
  900. echo json_encode ( array (
  901. 'status' => 1,
  902. 'html' => '<option value="PUBLIC">办事处待认领款项</option>'
  903. ) );
  904. die ();
  905. }
  906. if (! is_numeric ( $cid )) {
  907. echo json_encode ( array (
  908. 'status' => 0,
  909. 'msg' => 'illegal request'
  910. ) );
  911. die ();
  912. }
  913. $staffList = $staff->getStaffByCid($cid);
  914. $html='<option value="PUBLIC">办事处待认领款项</option>';
  915. foreach ($staffList as $key=>$value){
  916. $html.='<option value="'.$value['sid'].'-'.$value['username'].'">'.$value['category'].'-'.$value['username'].'</option>';
  917. }
  918. echo json_encode ( array (
  919. 'status' => 1,
  920. 'html' => $html
  921. ) );
  922. }
  923. /**
  924. * 异步获取一条发票的邮寄信息
  925. */
  926. function ajaxGetInvoicePostDetail() {
  927. $iid = $this->get_args ( 'iidKey' ) ? $this->get_args ( 'iidKey' ) : "";
  928. Doo::loadModel ( 'invoice' );
  929. $invoice = new invoice ();
  930. $iid = $invoice->authcode ( $iid );
  931. if (! is_numeric ( $iid )) {
  932. echo json_encode ( array (
  933. 'status' => 0,
  934. 'msg' => 'illegal request'
  935. ) );
  936. die ();
  937. }
  938. $select = "iid,recipients,recipientsPhone,recipientsAddress,mailItems,expressCompany,expressNumber,actualItems";
  939. $invoiceDetail = $invoice->getInvoiceByIid ( $iid, $select );
  940. echo json_encode ( array (
  941. 'status' => 1,
  942. 'invoiceDetail' => $invoiceDetail
  943. ) );
  944. }
  945. function _GetFileEXT($filename) {
  946. $pics = explode ( '.', $filename );
  947. $num = count ( $pics );
  948. return $pics [$num - 1];
  949. }
  950. /**
  951. * 获取get或者POST值
  952. *
  953. * @param string $name 属性名称
  954. * @return fixed 值
  955. */
  956. function get_args($name) {
  957. if (isset ( $_GET [$name] )) {
  958. if (is_array ( $_GET [$name] ))
  959. return $_GET [$name];
  960. else
  961. return addslashes ( $_GET [$name] );
  962. } elseif (isset ( $_POST [$name] )) {
  963. if (is_array ( $_POST [$name] ))
  964. return $_POST [$name];
  965. else
  966. return addslashes ( $_POST [$name] );
  967. } else
  968. return false;
  969. }
  970. }
  971. ?>