InvoiceController.php 90 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656
  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. // 收款操作日志
  916. if ($receivablesCategory == 'PUBLIC' && $receivablesStaff == 'PUBLIC')
  917. $item = array (
  918. 'operation' => $this->staff [0] ['username'] . " 转入 公共待认领款项 "
  919. );
  920. elseif ($receivablesCategory != 'PUBLIC' && $receivablesStaff == 'PUBLIC')
  921. $item = array (
  922. 'operation' => $this->staff [0] ['username'] . "转入 办事处待认领款项"
  923. );
  924. elseif ($receivablesCategory != 'PUBLIC' && $receivablesStaff != 'PUBLIC') {
  925. $receivablesStaff = explode ( '-', $receivablesStaff );
  926. $item = array (
  927. 'operation' => $this->staff [0] ['username'] . " 转入 " . $receivablesStaff [1]
  928. );
  929. }
  930. $item += array (
  931. 'date' => date ( "Y-m-d" ),
  932. 'status' => 1,
  933. 'img' => $this->staff [0] ['avatar'],
  934. 'username' => $this->staff [0] ['username'],
  935. 'uid' => $this->staff [0] ['sid'],
  936. 'category' => $this->staff [0] ['category'],
  937. 'irid' => $irid
  938. );
  939. $invoiceROLog->setInvoiceROLog ( $item );
  940. $item = array (
  941. 'date' => date ( "Y-m-d H:i:s" ),
  942. 'priceClass' => 2,
  943. 'irid' => $irid,
  944. 'receivablesPrice' => $receivablesPrice
  945. );
  946. if ($receivablesCategory != 'PUBLIC') {
  947. $receivablesCategory = explode ( ":", $receivablesCategory );
  948. $item += array (
  949. 'cid' => $receivablesCategory [0]
  950. );
  951. }
  952. if ($receivablesStaff2 != 'PUBLIC') {
  953. $receivablesStaff = explode ( "-", $receivablesStaff2 );
  954. $item += array (
  955. 'staff' => $receivablesStaff [0]
  956. );
  957. }
  958. $invoiceStatistics->setInvoiceStatisticsByCondition ( $item );
  959. }
  960. return "/invoiceReceivables";
  961. }
  962. /**
  963. * 收款认领页面-包括公共认领 办事处认领 最近已认领数据
  964. */
  965. function invoiceReceivablesClaim() {
  966. Doo::loadModel ( 'invoiceReceivables' );
  967. $invoiceReceivables = new invoiceReceivables ();
  968. $receivablesList = $invoiceReceivables->getInvoiceReceivablesByClaim ( $this->staff [0] ['cid'] );
  969. $this->data ['receivablesList'] = $receivablesList;
  970. $this->data ['memu'] = "invoice";
  971. $this->data ['staff'] = $this->staff;
  972. $this->data ['receiptMemu'] = 'invoiceReceivablesClaim';
  973. $this->render ( "/admin/invoiceReceivablesClaim", $this->data );
  974. }
  975. /**
  976. * 管理员录入的收款 ,确认认领到谁的名下.统计收款金额
  977. */
  978. function invoiceReceivablesAscription() {
  979. $irid = $this->get_args ( 'key' ) ? $this->get_args ( 'key' ) : "";
  980. Doo::loadModel ( 'invoiceReceivables' );
  981. $invoiceReceivables = new invoiceReceivables ();
  982. Doo::loadModel ( 'invoiceROLog' );
  983. $invoiceROLog = new invoiceROLog ();
  984. Doo::loadModel ( 'invoiceStatistics' );
  985. $invoiceStatistics = new invoiceStatistics ();
  986. $detail = $invoiceReceivables->getInvoiceReceivablesByIrid ( $irid );
  987. if (! empty ( $detail ) && $detail ['receivablesStaff'] == 'PUBLIC') {
  988. $item = array (
  989. 'irid' => $detail ['irid'],
  990. 'receivablesCategory' => $this->staff [0] ['cid'] . ":" . $this->staff [0] ['category'],
  991. 'receivablesStaff' => $this->staff [0] ['sid'] . "-" . $this->staff [0] ['username'],
  992. 'confirmTime' => date ( "Y-m-d H:i:s" ),
  993. 'source' => 1
  994. );
  995. $invoiceReceivables->setInvoiceReceivablesByCondition ( $item );
  996. $item = array (
  997. 'date' => date ( "Y-m-d" ),
  998. 'operation' => $this->staff [0] ['username'] . " 认领 ",
  999. 'status' => 2,
  1000. 'img' => $this->staff [0] ['avatar'],
  1001. 'username' => $this->staff [0] ['username'],
  1002. 'uid' => $this->staff [0] ['sid'],
  1003. 'category' => $this->staff [0] ['category'],
  1004. 'irid' => $irid
  1005. );
  1006. $invoiceROLog->setInvoiceROLog ( $item );
  1007. $item = array (
  1008. 'cid' => $this->staff [0] ['cid'],
  1009. 'staff' => $this->staff [0] ['sid']
  1010. );
  1011. $invoiceStatistics->updateInvoiceStatisticsByIrid ( $item, $detail ['irid'] );
  1012. }
  1013. return "/invoiceReceivablesClaim";
  1014. }
  1015. /**
  1016. */
  1017. function invoiceMyReceivables() {
  1018. Doo::loadModel ( 'invoiceReceivables' );
  1019. $invoiceReceivables = new invoiceReceivables ();
  1020. Doo::loadModel ( 'invoiceStatistics' );
  1021. $invoiceStatistics = new invoiceStatistics ();
  1022. $isMonth = $invoiceStatistics->getStatisticsByMonth ();
  1023. $year = date ( "Y" );
  1024. $tmp_date = date ( "Ym" );
  1025. $tmp_year = substr ( $tmp_date, 0, 4 );
  1026. $tmp_mon = substr ( $tmp_date, 4, 2 );
  1027. $tmp_forwardmonth = mktime ( 0, 0, 0, $tmp_mon - 1, 1, $tmp_year );
  1028. $fm_forward_month = date ( "m", $tmp_forwardmonth );
  1029. $path = SITE_PATH . $this->INVOICECOLLECTPATH . "invoiceCollect_" . $year . "_" . $fm_forward_month . ".htm";
  1030. $htm = $this->showCache ( $path );
  1031. $list = $invoiceReceivables->getInvoiceReceivablesByClaim ( $this->staff [0] ['cid'], $this->staff [0] ['sid'] );
  1032. $this->data ['isMonth'] = $isMonth;
  1033. $this->data ['htm'] = $htm;
  1034. $this->data ['list'] = $list;
  1035. $this->data ['memu'] = "invoice";
  1036. $this->data ['staff'] = $this->staff;
  1037. $this->data ['receiptMemu'] = 'invoiceMyReceivables';
  1038. $this->render ( "/admin/invoiceMyReceivables", $this->data );
  1039. }
  1040. /**
  1041. * 收款绑定发票 ,一个收款只能绑定一个发票
  1042. */
  1043. function invoiceBindReceivables() {
  1044. $claimKey = $this->get_args ( 'key' ) ? $this->get_args ( 'key' ) : "";
  1045. $invoiceKey = $this->get_args ( 'invoiceKey' ) ? $this->get_args ( 'invoiceKey' ) : "";
  1046. Doo::loadModel ( 'invoice' );
  1047. $invoice = new invoice ();
  1048. Doo::loadModel ( 'invoiceReceivables' );
  1049. $invoiceReceivables = new invoiceReceivables ();
  1050. Doo::loadModel ( 'invoiceOperationLog' );
  1051. $invoiceOperationLog = new invoiceOperationLog ();
  1052. if (empty ( $invoiceKey ) || empty ( $claimKey ))
  1053. die ( 'illegal request' );
  1054. $detail = $invoice->getInvoiceByIid ( $invoiceKey );
  1055. $detailM = $invoiceReceivables->getInvoiceReceivablesByIrid ( $claimKey );
  1056. if (empty ( $detail ) && empty ( $detailM ))
  1057. die ( 'illegal request' );
  1058. // if ($detailM ['receivablesPrice'] >= $detail ['invoicePrice']) {
  1059. // $price = $detailM ['receivablesPrice'] - $detail ['invoicePrice'];
  1060. // die ( '<p>收款金额超出开票金额 ¥' . $price . '元,请谨慎操作</p><a href="/invoiceMyReceivables">返回</a>' );
  1061. // }
  1062. $item = array (
  1063. 'irid' => $detailM ['irid'],
  1064. 'bindStatus' => 1,
  1065. 'iid' => $detail ['iid'],
  1066. 'bindDate' => date ( "Y-m-d H:i:s" )
  1067. );
  1068. $invoiceReceivables->setInvoiceReceivablesByCondition ( $item );
  1069. $iridString = "";
  1070. if (empty ( $detail ['irid'] ))
  1071. $iridString = $detailM ['irid'];
  1072. else
  1073. $iridString = $detail ['irid'] . ',' . $detailM ['irid'];
  1074. $item = array (
  1075. 'iid' => $detail ['iid'],
  1076. 'irid' => $iridString
  1077. );
  1078. $invoice->setInvoiceByCondition ( $item );
  1079. // 操作日志
  1080. $item = array (
  1081. 'date' => date ( "Y-m-d H:i:s" ),
  1082. 'operation' => "收款" . $detailM ['receivablesSerial'] . "入账到发票" . $detail ['invoiceSerial'],
  1083. 'status' => 8,
  1084. 'img' => $this->staff [0] ['avatar'],
  1085. 'username' => $this->staff [0] ['username'],
  1086. 'uid' => $this->staff [0] ['sid'],
  1087. 'category' => $this->staff [0] ['category'],
  1088. 'iid' => $detail ['iid']
  1089. );
  1090. $invoiceOperationLog->setInvoiceOperationLog ( $item );
  1091. return "/invoiceMyReceivables";
  1092. }
  1093. /**
  1094. * 发票收款完成
  1095. */
  1096. function invoiceEnterReceivables() {
  1097. $invoiceKey = $this->get_args ( 'key' ) ? $this->get_args ( 'key' ) : "";
  1098. // $invoiceClaim = $this->get_args ( 'invoiceClaim' ) ? $this->get_args ( 'invoiceClaim' ) : "";
  1099. Doo::loadModel ( 'invoice' );
  1100. $invoice = new invoice ();
  1101. Doo::loadModel ( 'invoiceOperationLog' );
  1102. $invoiceOperationLog = new invoiceOperationLog ();
  1103. Doo::loadModel ( 'invoiceStatistics' );
  1104. $invoiceStatistics = new invoiceStatistics ();
  1105. Doo::loadModel ( 'invoiceReceivables' );
  1106. $invoiceReceivables = new invoiceReceivables ();
  1107. $detail = $invoice->getInvoiceByIid ( $invoiceKey );
  1108. if (empty ( $detail ))
  1109. die ( 'illegal request' );
  1110. $item = array (
  1111. 'untreadStatus' => 3,
  1112. 'updateTime' => date ( "Y-m-d H:i:s" ),
  1113. 'iid' => $detail ['iid']
  1114. );
  1115. $invoice->setInvoiceByCondition ( $item );
  1116. // 操作日志
  1117. $item = array (
  1118. 'date' => date ( "Y-m-d H:i:s" ),
  1119. 'operation' => "发票" . $detail ['invoiceSerial'] . "收款完成",
  1120. 'status' => 9,
  1121. 'img' => $this->staff [0] ['avatar'],
  1122. 'username' => $this->staff [0] ['username'],
  1123. 'uid' => $this->staff [0] ['sid'],
  1124. 'category' => $this->staff [0] ['category'],
  1125. 'iid' => $detail ['iid']
  1126. );
  1127. $invoiceOperationLog->setInvoiceOperationLog ( $item );
  1128. $list = $invoiceReceivables->getInvoiceReceivablesInIridString ( $detail ['irid'] );
  1129. $accountPrice = 0;
  1130. foreach ( $list as $key => $value ) {
  1131. $accountPrice += $value ['receivablesPrice'];
  1132. }
  1133. $item = array (
  1134. 'date' => date ( "Y-m-d H:i:s" ),
  1135. 'priceClass' => 3,
  1136. 'cid' => $this->staff [0] ['cid'],
  1137. 'staff' => $this->staff [0] ['sid'],
  1138. 'accountPrice' => $accountPrice
  1139. );
  1140. $invoiceStatistics->setInvoiceStatisticsByCondition ( $item );
  1141. return "/invoice";
  1142. }
  1143. function invoiceAggregate() {
  1144. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  1145. Doo::loadModel ( 'invoiceStatistics' );
  1146. $invoiceStatistics = new invoiceStatistics ();
  1147. Doo::loadModel ( 'L_category' );
  1148. $Lcategory = new L_category ();
  1149. $isList = $invoiceStatistics->getInvoiceStatisticsByYear ( $year );
  1150. $LcategoryList = $Lcategory->getCategory ();
  1151. // print_r($isList);
  1152. $html = ""; // $invoicePriceCategory=0;$receivablesPriceCategory=0;$accountPriceCategory=0;
  1153. foreach ( $LcategoryList as $key => $value ) {
  1154. $html .= '<tr><th><a href="/invoiceAggregateCategory/' . $value ['cidKey'] . '">' . $value ['title'] . '</a></th>';
  1155. $month = 1;
  1156. $invoicePriceYear = 0;
  1157. $receivablesPriceYear = 0;
  1158. $accountPriceYear = 0;
  1159. for(; $month <= 12; $month ++) {
  1160. $flag = true;
  1161. foreach ( $isList ['statisticsMonthCid'] as $k => $v ) {
  1162. if ($value ['cid'] == $v ['cid'] && $month == $v ['month']) {
  1163. $html .= '<td class="taR">¥' . $v ['invoicePrice'] . '</td>
  1164. <td class="taR">¥' . $v ['receivablesPrice'] . '</td>
  1165. <td class="taR"><b>¥' . $v ['accountPrice'] . '</b></td>
  1166. ';
  1167. $invoicePriceYear += $v ['invoicePrice'];
  1168. $receivablesPriceYear += $v ['receivablesPrice'];
  1169. $accountPriceYear += $v ['accountPrice'];
  1170. $flag = false;
  1171. break;
  1172. }
  1173. }
  1174. if ($flag)
  1175. $html .= '<td class="taR"></td>
  1176. <td class="taR"></td>
  1177. <td class="taR"><b></b></td>
  1178. ';
  1179. }
  1180. $html .= '<td class="taR colRed">' . $invoicePriceYear . '</td>
  1181. <td class="taR colOrange">' . $receivablesPriceYear . '</td>
  1182. <td class="taR colGreen"><b>' . $accountPriceYear . '</b></td>
  1183. ';
  1184. $html .= '</tr>';
  1185. }
  1186. $html .= '<tr><th><b class="colGreen">月合计</b></th>';
  1187. $invoicePriceYear = 0;
  1188. $receivablesPriceYear = 0;
  1189. $accountPriceYear = 0;
  1190. for($month = 1; $month <= 12; $month ++) {
  1191. $flag = true;
  1192. foreach ( $isList ['statisticsMonth'] as $k => $v ) {
  1193. if ($month == $v ['month']) {
  1194. $html .= '<td class="taR">¥' . $v ['invoicePrice'] . '</td>
  1195. <td class="taR">¥' . $v ['receivablesPrice'] . '</td>
  1196. <td class="taR"><b>¥' . $v ['accountPrice'] . '</b></td>
  1197. ';
  1198. $invoicePriceYear += $v ['invoicePrice'];
  1199. $receivablesPriceYear += $v ['receivablesPrice'];
  1200. $accountPriceYear += $v ['accountPrice'];
  1201. $flag = false;
  1202. break;
  1203. }
  1204. if ($flag)
  1205. $html .= '<td class="taR"></td>
  1206. <td class="taR"></td>
  1207. <td class="taR"><b></b></td>
  1208. ';
  1209. }
  1210. }
  1211. $html .= '<td class="taR colRed">' . $invoicePriceYear . '</td>
  1212. <td class="taR colOrange">' . $receivablesPriceYear . '</td>
  1213. <td class="taR colGreen"><b>' . $accountPriceYear . '</b></td>
  1214. ';
  1215. $html .= '</tr>';
  1216. $this->data ['html'] = $html;
  1217. $this->data ['LcategoryList'] = $LcategoryList;
  1218. $this->data ['isList'] = $isList;
  1219. $this->data ['year'] = $year;
  1220. $this->data ['memu'] = "invoice";
  1221. $this->data ['staff'] = $this->staff;
  1222. $this->data ['receiptMemu'] = 'invoiceAggregate';
  1223. $this->render ( "/admin/invoiceAggregate", $this->data );
  1224. }
  1225. function invoiceAggregateStaff() {
  1226. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  1227. Doo::loadModel ( 'invoiceStatistics' );
  1228. $invoiceStatistics = new invoiceStatistics ();
  1229. Doo::loadModel ( 'L_category' );
  1230. $Lcategory = new L_category ();
  1231. $toteList = $invoiceStatistics->getInvoiceStatisticsByTote ( $year );
  1232. $staffList = $invoiceStatistics->getInvoiceStatisticsByStaff ( $year );
  1233. $cStaff = $Lcategory->getCategoryStaff ();
  1234. $html = '';
  1235. foreach ( $cStaff as $key => $value ) {
  1236. $categoryFir = true;
  1237. foreach ( $value ['staff'] as $k => $v ) {
  1238. if ($categoryFir) {
  1239. $width = count ( $value ['staff'] ) + 1;
  1240. $html .= '<tr><th rowspan="' . $width . '">' . $value ['title'] . ' </th>';
  1241. $categoryFir = false;
  1242. } else
  1243. $html .= '<tr>';
  1244. $html .= '<th>' . $v ['username'] . '</th>';
  1245. $invoicePriceStaffYear = 0;
  1246. $receivablesPriceStaffYear = 0;
  1247. $accountPriceStaffYear = 0;
  1248. for($month = 1; $month <= 12; $month ++) {
  1249. $flag = true;
  1250. foreach ( $staffList ['statisticsMonthStaff'] as $sl => $slv ) {
  1251. if ($v ['sid'] == $slv ['staff'] && $month == $slv ['month']) {
  1252. $html .= '<td class="taR">¥' . $slv ['invoicePrice'] . '</td>
  1253. <td class="taR">¥' . $slv ['receivablesPrice'] . '</td>
  1254. <td class="taR"><b>¥' . $slv ['accountPrice'] . '</b></td>
  1255. ';
  1256. $invoicePriceStaffYear += $slv ['invoicePrice'];
  1257. $receivablesPriceStaffYear += $slv ['receivablesPrice'];
  1258. $accountPriceStaffYear += $slv ['accountPrice'];
  1259. $flag = false;
  1260. break;
  1261. }
  1262. }
  1263. if ($flag)
  1264. $html .= '<td class="taR"></td>
  1265. <td class="taR"></td>
  1266. <td class="taR"><b></b></td>
  1267. ';
  1268. }
  1269. $html .= '<td class="taR colRed">' . $invoicePriceStaffYear . '</td>
  1270. <td class="taR colOrange">' . $receivablesPriceStaffYear . '</td>
  1271. <td class="taR colGreen"><b>' . $accountPriceStaffYear . '</b></td>
  1272. ';
  1273. }
  1274. $html .= '</tr>';
  1275. // 小计
  1276. if (! empty ( $value ['staff'] )) {
  1277. $html .= '<tr><th class="taR">小计</th>';
  1278. $invoicePriceStaffYear = 0;
  1279. $receivablesPriceStaffYear = 0;
  1280. $accountPriceStaffYear = 0;
  1281. for($month = 1; $month <= 12; $month ++) {
  1282. $flag = true;
  1283. foreach ( $staffList ['statisticsMonthCid'] as $smc => $smcv ) {
  1284. if ($value ['cid'] == $smcv ['cid'] && $month == $slv ['month']) {
  1285. $html .= '<td class="taR">¥' . $smcv ['invoicePrice'] . '</td>
  1286. <td class="taR">¥' . $smcv ['receivablesPrice'] . '</td>
  1287. <td class="taR"><b>¥' . $smcv ['accountPrice'] . '</b></td>
  1288. ';
  1289. $invoicePriceStaffYear += $slv ['invoicePrice'];
  1290. $receivablesPriceStaffYear += $slv ['receivablesPrice'];
  1291. $accountPriceStaffYear += $slv ['accountPrice'];
  1292. $flag = false;
  1293. break;
  1294. }
  1295. }
  1296. if ($flag)
  1297. $html .= '<td class="taR"></td>
  1298. <td class="taR"></td>
  1299. <td class="taR"><b></b></td>
  1300. ';
  1301. }
  1302. $html .= '<td class="taR colRed">' . $invoicePriceStaffYear . '</td>
  1303. <td class="taR colOrange">' . $receivablesPriceStaffYear . '</td>
  1304. <td class="taR colGreen"><b>' . $accountPriceStaffYear . '</b></td>
  1305. ';
  1306. $html .= '</tr>';
  1307. }
  1308. }
  1309. $html .= '<tr class="warning"><th colspan="2"><b class="colGreen" >月合计</b></th>';
  1310. $invoicePriceYear = 0;
  1311. $receivablesPriceYear = 0;
  1312. $accountPriceYear = 0;
  1313. for($month = 1; $month <= 12; $month ++) {
  1314. $flag = true;
  1315. foreach ( $staffList ['statisticsMonth'] as $k => $v ) {
  1316. if ($month == $v ['month']) {
  1317. $html .= '<td class="taR colRed">¥' . $v ['invoicePrice'] . '</td>
  1318. <td class="taR colOrange">¥' . $v ['receivablesPrice'] . '</td>
  1319. <td class="taR colGreen"><b>¥' . $v ['accountPrice'] . '</b></td>
  1320. ';
  1321. $invoicePriceYear += $v ['invoicePrice'];
  1322. $receivablesPriceYear += $v ['receivablesPrice'];
  1323. $accountPriceYear += $v ['accountPrice'];
  1324. $flag = false;
  1325. break;
  1326. }
  1327. if ($flag)
  1328. $html .= '<td class="taR"></td>
  1329. <td class="taR"></td>
  1330. <td class="taR"><b></b></td>
  1331. ';
  1332. }
  1333. }
  1334. $html .= '<td class="taR colRed">' . $invoicePriceYear . '</td>
  1335. <td class="taR colOrange">' . $receivablesPriceYear . '</td>
  1336. <td class="taR colGreen"><b>' . $accountPriceYear . '</b></td>
  1337. ';
  1338. $html .= '</tr>';
  1339. $this->data ['html'] = $html;
  1340. $this->data ['isList'] = $toteList;
  1341. $this->data ['year'] = $year;
  1342. $this->data ['memu'] = "invoice";
  1343. $this->data ['staff'] = $this->staff;
  1344. $this->data ['receiptMemu'] = 'invoiceAggregate';
  1345. $this->render ( "/admin/invoiceAggregateStaff", $this->data );
  1346. }
  1347. function invoiceAggregateCategory() {
  1348. Doo::loadClass ( 'XDeode' );
  1349. $XDeode = new XDeode ( 5 );
  1350. $cid = $cidKey = isset ( $this->params ['cid'] ) ? $this->params ['cid'] : "";
  1351. $cid = $XDeode->decode ( $cid );
  1352. if (! is_numeric ( $cid ))
  1353. die ( 'illegal request' );
  1354. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  1355. Doo::loadModel ( 'invoiceStatistics' );
  1356. $invoiceStatistics = new invoiceStatistics ();
  1357. Doo::loadModel ( 'staff' );
  1358. $staff = new staff ();
  1359. $list = $staff->getStaffByCid ( $cid );
  1360. $isCategory = $invoiceStatistics->getInvoiceStatisticsByStaff ( $year, $cid );
  1361. $toteList = $invoiceStatistics->getInvoiceStatisticsByTote ( $year, $cid );
  1362. if (empty ( $list ))
  1363. die ( '该办事处没有成员' );
  1364. $htmlA = $htmlB = $htmlC = $html = '';
  1365. foreach ( $list as $key => $value ) {
  1366. $htmlA = '<tr><th rowspan="3">' . $value ['username'] . '</th><th class="taC">开票</th>';
  1367. $htmlB = '<tr><th class="taC">收款</th>';
  1368. $htmlC = '<tr><th class="taC">入账</th>';
  1369. $invoicePriceStaffYear = 0;
  1370. $receivablesPriceStaffYear = 0;
  1371. $accountPriceStaffYear = 0;
  1372. for($month = 1; $month <= 12; $month ++) {
  1373. $flag = true;
  1374. foreach ( $isCategory ['statisticsMonthStaff'] as $k => $v ) {
  1375. if ($value ['sid'] == $v ['staff'] && $month == $v ['month']) {
  1376. $htmlA .= '<td class="taR">¥' . $v ['invoicePrice'] . '</td>';
  1377. $htmlB .= '<td class="taR">¥' . $v ['receivablesPrice'] . '</td>';
  1378. $htmlC .= '<td class="taR"><b>¥' . $v ['accountPrice'] . '</b></td>';
  1379. $invoicePriceStaffYear += $v ['invoicePrice'];
  1380. $receivablesPriceStaffYear += $v ['receivablesPrice'];
  1381. $accountPriceStaffYear += $v ['accountPrice'];
  1382. $flag = false;
  1383. break;
  1384. }
  1385. }
  1386. if ($flag) {
  1387. $htmlA .= '<td class="taR">-</td>';
  1388. $htmlB .= '<td class="taR">-</td>';
  1389. $htmlC .= '<td class="taR"><b>-</b></td>';
  1390. }
  1391. }
  1392. $htmlA .= '<td class="taR colRed">' . $invoicePriceStaffYear . '</td>';
  1393. $htmlB .= '<td class="taR colOrange">' . $receivablesPriceStaffYear . '</td>';
  1394. $htmlC .= '<td class="taR colGreen"><b>' . $accountPriceStaffYear . '</b></td>';
  1395. $htmlA .= '</tr>';
  1396. $htmlB .= '</tr>';
  1397. $htmlC .= '</tr>';
  1398. $html .= $htmlA . $htmlB . $htmlC;
  1399. }
  1400. $htmlA = $htmlB = $htmlC = "";
  1401. $htmlA = '<tr><th rowspan="3">月合计</th><th class="taC">开票</th>';
  1402. $htmlB = '<tr><th class="taC">收款</th>';
  1403. $htmlC = '<tr><th class="taC">入账</th>';
  1404. $invoicePriceStaffYear = 0;
  1405. $receivablesPriceStaffYear = 0;
  1406. $accountPriceStaffYear = 0;
  1407. for($month = 1; $month <= 12; $month ++) {
  1408. $flag = true;
  1409. foreach ( $isCategory ['statisticsMonth'] as $k => $v ) {
  1410. if ($month == $v ['month']) {
  1411. $htmlA .= '<td class="taR colRed">¥' . $v ['invoicePrice'] . '</td>';
  1412. $htmlB .= '<td class="taR colOrange">¥' . $v ['receivablesPrice'] . '</td>';
  1413. $htmlC .= '<td class="taR colGreen"><b>¥' . $v ['accountPrice'] . '</b></td>';
  1414. $invoicePriceStaffYear += $v ['invoicePrice'];
  1415. $receivablesPriceStaffYear += $v ['receivablesPrice'];
  1416. $accountPriceStaffYear += $v ['accountPrice'];
  1417. $flag = false;
  1418. break;
  1419. }
  1420. }
  1421. if ($flag) {
  1422. $htmlA .= '<td class="taR">-</td>';
  1423. $htmlB .= '<td class="taR">-</td>';
  1424. $htmlC .= '<td class="taR"><b>-</b></td>';
  1425. }
  1426. }
  1427. $htmlA .= '<td class="taR colRed">' . $invoicePriceStaffYear . '</td>';
  1428. $htmlB .= '<td class="taR colOrange">' . $receivablesPriceStaffYear . '</td>';
  1429. $htmlC .= '<td class="taR colGreen"><b>' . $accountPriceStaffYear . '</b></td>';
  1430. $htmlA .= '</tr>';
  1431. $htmlB .= '</tr>';
  1432. $htmlC .= '</tr>';
  1433. $html .= $htmlA . $htmlB . $htmlC;
  1434. $this->data ['html'] = $html;
  1435. $this->data ['cidKey'] = $cidKey;
  1436. $this->data ['slist'] = $list;
  1437. $this->data ['isList'] = $toteList;
  1438. $this->data ['year'] = $year;
  1439. $this->data ['memu'] = "invoice";
  1440. $this->data ['staff'] = $this->staff;
  1441. $this->data ['receiptMemu'] = 'invoiceAggregate';
  1442. $this->render ( "/admin/invoiceAggregateCategory", $this->data );
  1443. }
  1444. function invoiceAchieve() {
  1445. Doo::loadModel ( 'invoice' );
  1446. $invoice = new invoice ();
  1447. $MebSea = isset($this->params ['MebSea']) ? urldecode($this->params ['MebSea']) : '';
  1448. $page_size=1;
  1449. $page = isset($this->params ['page'])&&is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  1450. $date = isset($this->params ['date']) ? $this->params ['date'] : 'MONTHO';
  1451. $get="/".$date;
  1452. $con='';
  1453. if ($date=='MONTHO')
  1454. $con=' and updateTime>DATE_SUB(CURDATE(), INTERVAL 1 MONTH)';
  1455. elseif ($date=='MONTHT')
  1456. $con=' and updateTime>DATE_SUB(CURDATE(), INTERVAL 3 MONTH)';
  1457. elseif ($date=='MONTHY')
  1458. $con=' and updateTime>DATE_SUB(CURDATE(), INTERVAL 1 YEAR)';
  1459. if (!empty($MebSea)){
  1460. $con.=' and ( invoiceTitle like "%'.$MebSea.'%" or invoiceCompany like "%'.$MebSea.'%" or invoicePrice like "%'.$MebSea.'%" )';
  1461. $get.="/".$MebSea;
  1462. }
  1463. $pageinfo['page']=array('previous'=>'');
  1464. $sql='status=2 and untreadStatus=3 and sid='.$_COOKIE ["staff"].$con;
  1465. $pageinfo=$this->get_page("CLD_invoice", $sql, $page, $page_size, "invoiceAchieve",$get,"");
  1466. $limit=$pageinfo ['lower'].','.$page_size;
  1467. $list=$invoice->getInvoiceByUntreadStatusPage($limit,$_COOKIE ["staff"],$con);
  1468. //print_r($pageinfo);
  1469. $this->data['MebSeaEn']=$MebSea;
  1470. $this->data['MebSea']=urlencode($MebSea);
  1471. $this->data['get']=$get;
  1472. $this->data['page']=$pageinfo;
  1473. $this->data ['list'] = $list;
  1474. $this->data ['date']=$date;
  1475. $this->data ['memu'] = "invoice";
  1476. $this->data ['staff'] = $this->staff;
  1477. $this->data ['receiptMemu'] = 'invoice';
  1478. $this->render ( "/admin/invoiceAchieve", $this->data );
  1479. }
  1480. function invoiceReceivablesAchieve() {
  1481. Doo::loadModel ( 'invoiceReceivables' );
  1482. $invoiceReceivables = new invoiceReceivables ();
  1483. $MebSea = isset($this->params ['MebSea']) ? urldecode($this->params ['MebSea']) : '';
  1484. $page_size=1;
  1485. $page = isset($this->params ['page'])&&is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  1486. $date = isset($this->params ['date']) ? $this->params ['date'] : 'MONTHO';
  1487. $get="/".$date;
  1488. $con='';
  1489. if ($date=='MONTHO')
  1490. $con=' and bindDate>DATE_SUB(CURDATE(), INTERVAL 1 MONTH)';
  1491. elseif ($date=='MONTHT')
  1492. $con=' and bindDate>DATE_SUB(CURDATE(), INTERVAL 3 MONTH)';
  1493. elseif ($date=='MONTHY')
  1494. $con=' and bindDate>DATE_SUB(CURDATE(), INTERVAL 1 YEAR)';
  1495. if (!empty($MebSea)){
  1496. $con.=' and ( receivablesMessage like "%'.$MebSea.'%" or receivablesPrice like "%'.$MebSea.'%" )';
  1497. $get.="/".$MebSea;
  1498. }
  1499. $pageinfo['page']=array('previous'=>'');
  1500. $sql=" bindStatus=1 and receivablesStaff like '" . $_COOKIE ["staff"] . "_%' ".$con;
  1501. $pageinfo=$this->get_page("CLD_invoiceReceivables", $sql, $page, $page_size, "invoiceReceivablesAchieve",$get,"");
  1502. $limit=$pageinfo ['lower'].','.$page_size;
  1503. $list=$invoiceReceivables->getReceivablesByUntreadStatusPage($limit,$sql);
  1504. //print_r($pageinfo);
  1505. $this->data['MebSeaEn']=$MebSea;
  1506. $this->data['MebSea']=urlencode($MebSea);
  1507. $this->data['get']=$get;
  1508. $this->data['page']=$pageinfo;
  1509. $this->data ['list'] = $list;
  1510. $this->data ['date']=$date;
  1511. $this->data ['memu'] = "invoice";
  1512. $this->data ['staff'] = $this->staff;
  1513. $this->data ['receiptMemu'] = 'invoiceMyReceivables';
  1514. $this->render ( "/admin/invoiceReceivablesAchieve", $this->data );
  1515. }
  1516. function invoiceReceivablesAS() {
  1517. Doo::loadModel ( 'invoiceReceivables' );
  1518. $invoiceReceivables = new invoiceReceivables ();
  1519. $MebSea = isset($this->params ['MebSea']) ? urldecode($this->params ['MebSea']) : '';
  1520. $page_size=1;
  1521. $page = isset($this->params ['page'])&&is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  1522. $status = isset($this->params ['status']) ? $this->params ['status'] : 'All';
  1523. $year=isset($this->params ['year'])&&is_numeric ( $this->params ['year'] )?$this->params ['year']:date('Y');
  1524. $month=isset($this->params ['month'])&&is_numeric ( $this->params ['month'] )?$this->params ['month']:"All";
  1525. $con="Year(date) =".$year;
  1526. if($month!="All")
  1527. $con="Year(date) =".$year." and Month(date) = ".$month;
  1528. if ($status=='Unclaimed')
  1529. $con.=' and bindStatus=0';
  1530. elseif ($status=='Credited')
  1531. $con.=' and bindStatus=1';
  1532. $get="/".$status."/".$year."/".$month;
  1533. if (!empty($MebSea)){
  1534. $con.=' and ( receivablesMessage like "%'.$MebSea.'%" or receivablesPrice like "%'.$MebSea.'%" )';
  1535. $get.="/".$MebSea;
  1536. }
  1537. $pageinfo['page']=array('previous'=>'');
  1538. $pageinfo=$this->get_page("CLD_invoiceReceivables", $con, $page, $page_size, "invoiceReceivablesAS",$get,"");
  1539. $limit=$pageinfo ['lower'].','.$page_size;
  1540. $list=$invoiceReceivables->getReceivablesByUntreadStatusPage($limit,$con);
  1541. //print_r($pageinfo);
  1542. $mothHtml="";
  1543. for($i=1;$i<=12;$i++){
  1544. if($month==$i)
  1545. $mothHtml.='<option selected value="'.$i.'">'.$i.'月</option>';
  1546. else
  1547. $mothHtml.='<option value="'.$i.'">'.$i.'月</option>';
  1548. }
  1549. $this->data['MebSeaEn']=$MebSea;
  1550. $this->data['MebSea']=urlencode($MebSea);
  1551. $this->data['mothHtml']=$mothHtml;
  1552. $this->data['year']=$year;
  1553. $this->data['month']=$month;
  1554. $this->data['page']=$pageinfo;
  1555. $this->data['get']=$get;
  1556. $this->data ['list'] = $list;
  1557. $this->data ['status']=$status;
  1558. $this->data ['memu'] = "invoice";
  1559. $this->data ['staff'] = $this->staff;
  1560. $this->data ['receiptMemu'] = 'invoiceReceivables';
  1561. $this->render ( "/admin/invoiceReceivablesAS", $this->data );
  1562. }
  1563. /**
  1564. * 获得与我有关可收款的发票
  1565. */
  1566. function ajaxGetInvoiceByStaff() {
  1567. $irid = $this->get_args ( 'key' ) ? $this->get_args ( 'key' ) : "";
  1568. Doo::loadModel ( 'invoice' );
  1569. $invoice = new invoice ();
  1570. $list = $invoice->getInvoiceByReceivables ( $this->staff [0] ['sid'] );
  1571. $html = "";
  1572. $i = 1;
  1573. foreach ( $list as $key => $value ) {
  1574. $html .= '<tr>
  1575. <td>' . $value ['invoiceElement'] . '</td>
  1576. <td>¥' . $value ['invoicePrice'] . '</td>';
  1577. if (! empty ( $value ['invoiceType'] )) {
  1578. $html .= '<td>增值税专用发票</td>
  1579. <td>' . $value ['invoiceCompany'] . '</td>';
  1580. } else {
  1581. $html .= '<td>增值税普通发票</td>
  1582. <td>' . $value ['invoiceTitle'] . '</td>';
  1583. }
  1584. $html .= '<td><label><input type="radio" node-Claim="true_' . $i . '" p-data="' . $value ['iidKey'] . '" name="invoiceClaim"> 使用Ta</label></td></tr>
  1585. <script>
  1586. $(\'input[node-Claim="true_' . $i . '"]\').click(function() {
  1587. var invoiceKey= $(this).attr("p-data");
  1588. var claimKey=$("input[name=\'key\']").val();
  1589. $("p[node-msg=\"true\"]").hide();
  1590. var url = "/ajaxCompareInvoicePrice";
  1591. $.ajax({
  1592. url : url,
  1593. type : "post",
  1594. cache : false,
  1595. dataType : "json",
  1596. data : {
  1597. claimKey : claimKey,
  1598. invoiceKey:invoiceKey
  1599. },
  1600. global : true,
  1601. success : function(data) {
  1602. $("input[name=\'invoiceKey\']").val("' . $value ['iidKey'] . '");
  1603. if (data.status == 1) {
  1604. $("p[node-msg=\"true\"]").html("收款金额超出开票金额 ¥"+data.price+"元,请谨慎操作。");
  1605. $("p[node-msg=\"true\"]").show();
  1606. }
  1607. },
  1608. error : function(err) {
  1609. }
  1610. });
  1611. });
  1612. </script>
  1613. ';
  1614. $i ++;
  1615. }
  1616. echo json_encode ( array (
  1617. 'status' => 1,
  1618. 'html' => $html
  1619. ) );
  1620. }
  1621. /**
  1622. * 获取一条收款信息
  1623. */
  1624. function ajaxGetInvoiceReceivables() {
  1625. $irid = $this->get_args ( 'key' ) ? $this->get_args ( 'key' ) : "";
  1626. Doo::loadModel ( 'invoiceReceivables' );
  1627. $invoiceReceivables = new invoiceReceivables ();
  1628. $detail = $invoiceReceivables->getInvoiceReceivablesByIrid ( $irid );
  1629. echo json_encode ( array (
  1630. 'status' => 1,
  1631. 'detail' => $detail
  1632. ) );
  1633. }
  1634. /**
  1635. * 异步获取办事处用户
  1636. */
  1637. function ajaxGetStaffByCategory() {
  1638. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : "";
  1639. Doo::loadModel ( 'staff' );
  1640. $staff = new staff ();
  1641. if ($cid == "PUBLIC") {
  1642. echo json_encode ( array (
  1643. 'status' => 1,
  1644. 'html' => '<option value="PUBLIC">办事处待认领款项</option>'
  1645. ) );
  1646. die ();
  1647. }
  1648. if (! is_numeric ( $cid )) {
  1649. echo json_encode ( array (
  1650. 'status' => 0,
  1651. 'msg' => 'illegal request'
  1652. ) );
  1653. die ();
  1654. }
  1655. $staffList = $staff->getStaffByCid ( $cid );
  1656. $html = '<option value="PUBLIC">办事处待认领款项</option>';
  1657. foreach ( $staffList as $key => $value ) {
  1658. $html .= '<option value="' . $value ['sid'] . '-' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  1659. }
  1660. echo json_encode ( array (
  1661. 'status' => 1,
  1662. 'html' => $html
  1663. ) );
  1664. }
  1665. /**
  1666. * 异步获取一条发票的邮寄信息
  1667. */
  1668. function ajaxGetInvoicePostDetail() {
  1669. $iid = $this->get_args ( 'iidKey' ) ? $this->get_args ( 'iidKey' ) : "";
  1670. Doo::loadModel ( 'invoice' );
  1671. $invoice = new invoice ();
  1672. $iid = $invoice->authcode ( $iid );
  1673. if (! is_numeric ( $iid )) {
  1674. echo json_encode ( array (
  1675. 'status' => 0,
  1676. 'msg' => 'illegal request'
  1677. ) );
  1678. die ();
  1679. }
  1680. $select = "iid,recipients,recipientsPhone,recipientsAddress,mailItems,expressCompany,expressNumber,actualItems";
  1681. $invoiceDetail = $invoice->getInvoiceByIid ( $iid, $select );
  1682. echo json_encode ( array (
  1683. 'status' => 1,
  1684. 'invoiceDetail' => $invoiceDetail
  1685. ) );
  1686. }
  1687. function ajaxCompareClaimPrice() {
  1688. $irid = $this->get_args ( 'irid' ) ? $this->get_args ( 'irid' ) : "";
  1689. $invoiceKey = $this->get_args ( 'invoiceKey' ) ? $this->get_args ( 'invoiceKey' ) : "";
  1690. Doo::loadModel ( 'invoice' );
  1691. $invoice = new invoice ();
  1692. Doo::loadModel ( 'invoiceReceivables' );
  1693. $invoiceReceivables = new invoiceReceivables ();
  1694. Doo::loadModel ( 'invoiceOperationLog' );
  1695. $invoiceOperationLog = new invoiceOperationLog ();
  1696. $detail = $invoice->getInvoiceByIid ( $invoiceKey );
  1697. $detailM = $invoiceReceivables->getInvoiceReceivablesByIrid ( $irid );
  1698. if (empty ( $detail ) || empty ( $detailM )) {
  1699. echo json_encode ( array (
  1700. 'status' => 2,
  1701. 'msg' => '非法请求,请重新登录'
  1702. ) );
  1703. die ();
  1704. }
  1705. $iridString = "";
  1706. if (empty ( $detail ['irid'] ))
  1707. $iridString = $detailM ['irid'];
  1708. else
  1709. $iridString = $detail ['irid'] . ',' . $detailM ['irid'];
  1710. $item = array (
  1711. 'irid' => $iridString,
  1712. 'bindTime' => date ( "Y-m-d H:i:s" ),
  1713. 'updateTime' => date ( "Y-m-d H:i:s" ),
  1714. 'iid' => $detail ['iid']
  1715. );
  1716. $invoice->setInvoiceByCondition ( $item );
  1717. // 操作日志
  1718. $item = array (
  1719. 'date' => date ( "Y-m-d H:i:s" ),
  1720. 'operation' => "收款入账" . $detailM ['receivablesSerial'] . "到发票" . $detail ['invoiceSerial'],
  1721. 'status' => 8,
  1722. 'img' => $this->staff [0] ['avatar'],
  1723. 'username' => $this->staff [0] ['username'],
  1724. 'uid' => $this->staff [0] ['sid'],
  1725. 'category' => $this->staff [0] ['category'],
  1726. 'iid' => $detail ['iid']
  1727. );
  1728. $invoiceOperationLog->setInvoiceOperationLog ( $item );
  1729. $item = array (
  1730. 'iid' => $detail ['iid'],
  1731. 'irid' => $detailM ['irid'],
  1732. 'bindDate' => date ( "Y-m-d H:i:s" ),
  1733. 'bindStatus' => 1
  1734. );
  1735. $invoiceReceivables->setInvoiceReceivablesByCondition ( $item );
  1736. $price = 0;
  1737. $priceStatus = 0;$isReceivables=0;
  1738. $invoiceReceivables = new invoiceReceivables ();
  1739. $list = $invoiceReceivables->getInvoiceReceivablesInIridString ( $iridString );
  1740. if (!empty($list))
  1741. $isReceivables=1;
  1742. $receivablesPrice = 0;
  1743. foreach ( $list as $key => $value ) {
  1744. $receivablesPrice += $value ['receivablesPrice'];
  1745. }
  1746. if ($receivablesPrice > $detail ['invoicePrice']) {
  1747. $price = $receivablesPrice - $detail ['invoicePrice'];
  1748. $priceStatus = 1;
  1749. }elseif($receivablesPrice < $detail ['invoicePrice']){
  1750. $price = $detail ['invoicePrice']-$receivablesPrice;
  1751. $priceStatus = 2;
  1752. }
  1753. echo json_encode ( array (
  1754. 'status' => 1,
  1755. 'html' => '<tr><td>¥' . $detailM ['receivablesPrice'] . '</td><td>' . $detailM ['receivablesMessage'] . '</td><td>' . $detailM ['receivablesBank'] . '</td>
  1756. <td>' . $detailM ['receivablesDate'] . '</td><td><a node-remove="Da' . $detailM ['iridKey'] . '" href="javascript:void(0);">移除</a></td></tr>
  1757. <script>
  1758. $(\'a[node-remove="Da' . $detailM ['iridKey'] . '"]\').click(function() {
  1759. var invoiceKey=$("input[name=\'key\']").val();
  1760. var irid= $(this).attr("p-data");
  1761. var iridKey="' . $detailM ["iridEn"] . '";
  1762. var element=($(this));
  1763. $("p[node-loading=\"true\"]").show();
  1764. $("p[node-loading=\"true\"]").html("移除处理中...");
  1765. $("p[node-msg=\"true2\"]").hide();
  1766. $("p[node-msg=\"true\"]").hide();
  1767. var url = "/ajaxReceivablesRemove";
  1768. $.ajax({
  1769. url : url,
  1770. type : "post",
  1771. cache : false,
  1772. dataType : "json",
  1773. data : {
  1774. key : iridKey,
  1775. invoiceKey:invoiceKey
  1776. },
  1777. global : true,
  1778. success : function(data) {
  1779. $("input[name=\'invoiceKey\']").val("' . $detailM ['iridEn'] . '");
  1780. if (data.status == 1) {
  1781. $(element).parent().parent().remove();
  1782. $("tbody[data-invoice=\"myReceivables\"]").append(data.html);
  1783. $("p[node-loading=\"true\"]").hide();
  1784. if(data.priceStatus == 1){
  1785. $("p[node-msg=\"true\"]").html("收款金额超出开票金额 ¥"+data.price+"元,请谨慎操作。");
  1786. $("p[node-msg=\"true\"]").show();
  1787. }else if(data.priceStatus == 2&& data.isReceivables != 0){
  1788. $("p[node-msg=\"true\"]").html("收款金额少于开票金额 ¥"+data.price+"元,请谨慎操作。");
  1789. $("p[node-msg=\"true\"]").show();
  1790. }
  1791. }else if(data.status == 2){
  1792. $("p[node-loading=\"true\"]").html(data.msg);
  1793. }
  1794. },
  1795. error : function(err) {
  1796. }
  1797. });
  1798. });
  1799. </script>
  1800. ',
  1801. 'price' => $price,
  1802. 'priceStatus' => $priceStatus,
  1803. 'isReceivables'=>$isReceivables
  1804. ) );
  1805. }
  1806. /**
  1807. * 从发票中移除已经入账的收款
  1808. */
  1809. function ajaxReceivablesRemove() {
  1810. $iridKey = $this->get_args ( 'key' ) ? $this->get_args ( 'key' ) : "";
  1811. $invoiceKey = $this->get_args ( 'invoiceKey' ) ? $this->get_args ( 'invoiceKey' ) : "";
  1812. Doo::loadModel ( 'invoice' );
  1813. $invoice = new invoice ();
  1814. Doo::loadModel ( 'invoiceReceivables' );
  1815. $invoiceReceivables = new invoiceReceivables ();
  1816. Doo::loadModel ( 'invoiceOperationLog' );
  1817. $invoiceOperationLog = new invoiceOperationLog ();
  1818. $detail = $invoice->getInvoiceByIid ( $invoiceKey );
  1819. $detailM = $invoiceReceivables->getInvoiceReceivablesByIrid ( $iridKey );
  1820. // echo $detail['irid']."<br/>";
  1821. $invoiceIrid = explode ( ",", $detail ['irid'] );
  1822. foreach ( $invoiceIrid as $key => $value ) {
  1823. if ($value == $detailM ['irid'])
  1824. unset ( $invoiceIrid [$key] );
  1825. }
  1826. $invoiceIrid = implode ( ",", $invoiceIrid );
  1827. // echo $invoiceIrid."ddd";
  1828. // print_r($invoiceIrid);
  1829. $item = array (
  1830. 'irid' => $invoiceIrid,
  1831. 'iid' => $detail ['iid']
  1832. );
  1833. $invoice->setInvoiceByCondition ( $item );
  1834. $item = array (
  1835. 'iid' => 0,
  1836. 'irid' => $detailM ['irid'],
  1837. 'bindDate' => '',
  1838. 'bindStatus' => 0
  1839. );
  1840. $invoiceReceivables->setInvoiceReceivablesByCondition ( $item );
  1841. // 操作日志
  1842. $item = array (
  1843. 'date' => date ( "Y-m-d H:i:s" ),
  1844. 'operation' => "收款移除" . $detailM ['receivablesSerial'],
  1845. 'status' => 10,
  1846. 'img' => $this->staff [0] ['avatar'],
  1847. 'username' => $this->staff [0] ['username'],
  1848. 'uid' => $this->staff [0] ['sid'],
  1849. 'category' => $this->staff [0] ['category'],
  1850. 'iid' => $detail ['iid']
  1851. );
  1852. $invoiceOperationLog->setInvoiceOperationLog ( $item );
  1853. $price = 0;
  1854. $priceStatus = 0;$isReceivables=0;
  1855. $invoiceReceivables = new invoiceReceivables ();
  1856. $list = $invoiceReceivables->getInvoiceReceivablesInIridString ( $invoiceIrid );
  1857. if (!empty($list))
  1858. $isReceivables=1;
  1859. $receivablesPrice = 0;
  1860. foreach ( $list as $key => $value ) {
  1861. $receivablesPrice += $value ['receivablesPrice'];
  1862. }
  1863. if ($receivablesPrice > $detail ['invoicePrice']) {
  1864. $price = $receivablesPrice - $detail ['invoicePrice'];
  1865. $priceStatus = 1;
  1866. }elseif($receivablesPrice < $detail ['invoicePrice']){
  1867. $price = $detail ['invoicePrice']-$receivablesPrice;
  1868. $priceStatus = 2;
  1869. }
  1870. echo json_encode ( array (
  1871. 'status' => 1,
  1872. 'html' => '<tr id="' . $detailM ['receivablesSerial'] . '" >
  1873. <td>¥' . $detailM ['receivablesPrice'] . '</td>
  1874. <td>' . $detailM ['receivablesMessage'] . '</td>
  1875. <td>' . $detailM ['receivablesBank'] . '</td>
  1876. <td>' . $detailM ['receivablesDate'] . '</td><td>
  1877. <a href="javascript:void(0)" node-Claim="true_' . $detailM ['iridKey'] . '" p-data="' . $detailM ['iridEn'] . '" name="invoiceClaim" class="button">入账</a>
  1878. </td></tr>
  1879. <script>
  1880. $(\'a[node-Claim="true_' . $detailM ['iridKey'] . '"]\').click(function() {
  1881. var invoiceKey=$("input[name=\'key\']").val();
  1882. var irid= $(this).attr("p-data");
  1883. var element=($(this));
  1884. $("p[node-loading=\"true\"]").show();
  1885. $("p[node-loading=\"true\"]").html("入账处理中...");
  1886. $("p[node-msg=\"true2\"]").hide();
  1887. $("p[node-msg=\"true\"]").hide();
  1888. var url = "/ajaxCompareClaimPrice";
  1889. $.ajax({
  1890. url : url,
  1891. type : "post",
  1892. cache : false,
  1893. dataType : "json",
  1894. data : {
  1895. irid : irid,
  1896. invoiceKey:invoiceKey
  1897. },
  1898. global : true,
  1899. success : function(data) {
  1900. $("input[name=\'invoiceKey\']").val("' . $detailM ['iridEn'] . '");
  1901. if (data.status == 1) {
  1902. $(element).parent().parent().remove();
  1903. $("tbody[box-enter=\"true\"]").append(data.html);
  1904. $("p[node-loading=\"true\"]").hide();
  1905. if(data.priceStatus == 1){
  1906. $("p[node-msg=\"true\"]").html("收款金额超出开票金额 ¥"+data.price+"元,请谨慎操作。");
  1907. $("p[node-msg=\"true\"]").show();
  1908. }else if(data.priceStatus == 2&& data.isReceivables != 0){
  1909. $("p[node-msg=\"true\"]").html("收款金额少于开票金额 ¥"+data.price+"元,请谨慎操作。");
  1910. $("p[node-msg=\"true\"]").show();
  1911. }
  1912. }else if(data.status == 2){
  1913. $("p[node-loading=\"true\"]").html(data.msg);
  1914. }
  1915. },
  1916. error : function(err) {
  1917. }
  1918. });
  1919. });
  1920. </script>
  1921. ',
  1922. 'price' => $price,
  1923. 'priceStatus' => $priceStatus ,
  1924. 'isReceivables'=>$isReceivables
  1925. ) );
  1926. }
  1927. /**
  1928. * 我的收款中 选择哪个发票入账,进行金额判断
  1929. */
  1930. function ajaxCompareInvoicePrice() {
  1931. $claimKey = $this->get_args ( 'claimKey' ) ? $this->get_args ( 'claimKey' ) : "";
  1932. $invoiceKey = $this->get_args ( 'invoiceKey' ) ? $this->get_args ( 'invoiceKey' ) : "";
  1933. Doo::loadModel ( 'invoice' );
  1934. $invoice = new invoice ();
  1935. Doo::loadModel ( 'invoiceReceivables' );
  1936. $invoiceReceivables = new invoiceReceivables ();
  1937. $detail = $invoice->getInvoiceByIid ( $invoiceKey );
  1938. $keyList = explode ( ';', $claimKey );
  1939. $receivablesPrice = 0;
  1940. foreach ( $keyList as $key => $value ) {
  1941. $detailM = $invoiceReceivables->getInvoiceReceivablesByIrid ( $value );
  1942. $receivablesPrice += $detailM ['receivablesPrice'];
  1943. }
  1944. if ($receivablesPrice > $detail ['invoicePrice']) {
  1945. $price = $receivablesPrice - $detail ['invoicePrice'];
  1946. echo json_encode ( array (
  1947. 'status' => 1,
  1948. 'price' => $price
  1949. ) );
  1950. } else
  1951. echo json_encode ( array (
  1952. 'status' => 2
  1953. ) );
  1954. }
  1955. /*
  1956. * 获得与我有关收款数据
  1957. */
  1958. function ajaxGetReceivalblesByStaff() {
  1959. $iid = $this->get_args ( 'key' ) ? $this->get_args ( 'key' ) : "";
  1960. Doo::loadModel ( 'invoiceReceivables' );
  1961. $invoiceReceivables = new invoiceReceivables ();
  1962. Doo::loadModel ( 'invoice' );
  1963. $invoice = new invoice ();
  1964. $detail = $invoice->getInvoiceByIid ( $iid );
  1965. $list = $invoiceReceivables->getInvoiceReceivablesByClaim ( $this->staff [0] ['cid'], $this->staff [0] ['sid'] );
  1966. $html = "";
  1967. $i = 1;
  1968. foreach ( $list ['myClaim'] as $key => $value ) {
  1969. $html .= '<tr id="' . $value ['receivablesSerial'] . '" >
  1970. <td>¥' . $value ['receivablesPrice'] . '</td>
  1971. <td>' . $value ['receivablesMessage'] . '</td>
  1972. <td>' . $value ['receivablesBank'] . '</td>
  1973. <td>' . $value ['receivablesDate'] . '</td>';
  1974. $html .= '<td>
  1975. <a href="javascript:void(0)" node-Claim="true_' . $i . '" p-data="' . $value ['iidKey'] . '" name="invoiceClaim" class="button">入账</a>
  1976. </td></tr>
  1977. <script>
  1978. $(\'a[node-Claim="true_' . $i . '"]\').click(function() {
  1979. var invoiceKey=$("input[name=\'key\']").val();
  1980. var irid= $(this).attr("p-data");
  1981. var element=($(this));
  1982. $("p[node-loading=\"true\"]").show();
  1983. $("p[node-loading=\"true\"]").html("入账处理中...");
  1984. $("p[node-msg=\"true2\"]").hide();
  1985. $("p[node-msg=\"true\"]").hide();
  1986. var url = "/ajaxCompareClaimPrice";
  1987. $.ajax({
  1988. url : url,
  1989. type : "post",
  1990. cache : false,
  1991. dataType : "json",
  1992. data : {
  1993. irid : irid,
  1994. invoiceKey:invoiceKey
  1995. },
  1996. global : true,
  1997. success : function(data) {
  1998. $("input[name=\'invoiceKey\']").val("' . $value ['iidKey'] . '");
  1999. if (data.status == 1) {
  2000. $(element).parent().parent().remove();
  2001. $("tbody[box-enter=\"true\"]").append(data.html);
  2002. $("p[node-loading=\"true\"]").hide();
  2003. if(data.priceStatus == 1){
  2004. $("p[node-msg=\"true\"]").html("收款金额超出开票金额 ¥"+data.price+"元,请谨慎操作。");
  2005. $("p[node-msg=\"true\"]").show();
  2006. }else if(data.priceStatus == 2&& data.isReceivables != 0){
  2007. $("p[node-msg=\"true\"]").html("收款金额少于开票金额 ¥"+data.price+"元,请谨慎操作。");
  2008. $("p[node-msg=\"true\"]").show();
  2009. }
  2010. }else if(data.status == 2){
  2011. $("p[node-loading=\"true\"]").html(data.msg);
  2012. }
  2013. },
  2014. error : function(err) {
  2015. }
  2016. });
  2017. });
  2018. </script>
  2019. ';
  2020. $i ++;
  2021. }
  2022. $html2 = "";
  2023. $list2 = $invoiceReceivables->getInvoiceReceivablesByIid ( $iid, 1 );
  2024. foreach ( $list2 as $key => $value ) {
  2025. $html2 .= '<tr id="' . $value ['receivablesSerial'] . '" >
  2026. <td>¥' . $value ['receivablesPrice'] . '</td>
  2027. <td>' . $value ['receivablesMessage'] . '</td>
  2028. <td>' . $value ['receivablesBank'] . '</td>
  2029. <td>' . $value ['receivablesDate'] . '</td>';
  2030. $html2 .= '<td>
  2031. <a href="javascript:void(0)" node-remove="Da' . $value ['iridKey'] . '" >移除</a>
  2032. </td></tr>
  2033. <script>
  2034. $(\'a[node-remove="Da' . $value ['iridKey'] . '"]\').click(function() {
  2035. var invoiceKey=$("input[name=\'key\']").val();
  2036. var irid= $(this).attr("p-data");
  2037. var iridKey="' . $value ["iidKey"] . '";
  2038. var element=($(this));
  2039. $("p[node-loading=\"true\"]").show();
  2040. $("p[node-loading=\"true\"]").html("移除处理中...");
  2041. $("p[node-msg=\"true2\"]").hide();
  2042. $("p[node-msg=\"true\"]").hide();
  2043. var url = "/ajaxReceivablesRemove";
  2044. $.ajax({
  2045. url : url,
  2046. type : "post",
  2047. cache : false,
  2048. dataType : "json",
  2049. data : {
  2050. key : iridKey,
  2051. invoiceKey:invoiceKey
  2052. },
  2053. global : true,
  2054. success : function(data) {
  2055. $("input[name=\'invoiceKey\']").val("' . $value ['iidKey'] . '");
  2056. if (data.status == 1) {
  2057. $(element).parent().parent().remove();
  2058. $("tbody[data-invoice=\"myReceivables\"]").append(data.html);
  2059. $("p[node-loading=\"true\"]").hide();
  2060. if(data.priceStatus == 1){
  2061. $("p[node-msg=\"true\"]").html("收款金额超出开票金额 ¥"+data.price+"元,请谨慎操作。");
  2062. $("p[node-msg=\"true\"]").show();
  2063. }else if(data.priceStatus == 2&& data.isReceivables != 0){
  2064. $("p[node-msg=\"true\"]").html("收款金额少于开票金额 ¥"+data.price+"元,请谨慎操作。");
  2065. $("p[node-msg=\"true\"]").show();
  2066. }
  2067. }else if(data.status == 2){
  2068. $("p[node-loading=\"true\"]").html(data.msg);
  2069. }
  2070. },
  2071. error : function(err) {
  2072. }
  2073. });
  2074. });
  2075. </script>
  2076. ';
  2077. $i ++;
  2078. }
  2079. $price = 0;
  2080. $priceStatus = 0;$isReceivables=0;
  2081. $list = $invoiceReceivables->getInvoiceReceivablesInIridString ( $detail ['irid'] );
  2082. if (!empty($list))
  2083. $isReceivables=1;
  2084. $receivablesPrice = 0;
  2085. foreach ( $list as $key => $value ) {
  2086. $receivablesPrice += $value ['receivablesPrice'];
  2087. }
  2088. if ($receivablesPrice > $detail ['invoicePrice']) {
  2089. $price = $receivablesPrice - $detail ['invoicePrice'];
  2090. $priceStatus = 1;
  2091. }elseif($receivablesPrice < $detail ['invoicePrice']){
  2092. $price = $detail ['invoicePrice']-$receivablesPrice;
  2093. $priceStatus = 2;
  2094. }
  2095. echo json_encode ( array (
  2096. 'status' => 1,
  2097. 'html' => $html,
  2098. 'html2' => $html2,
  2099. 'price' => $price,
  2100. 'priceStatus' => $priceStatus,
  2101. 'isReceivables'=>$isReceivables
  2102. ) );
  2103. }
  2104. function ajaxGetInvoiceInfoByType() {
  2105. $type = $this->get_args ( 'type' ) ? $this->get_args ( 'type' ) : "";
  2106. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  2107. if (empty ( $serial )) {
  2108. echo json_encode ( array (
  2109. 'status' => 2,
  2110. 'msg' => 'illegal request'
  2111. ) );
  2112. die ();
  2113. }
  2114. if ($type == 'INVOICE') {
  2115. Doo::loadModel ( 'invoice' );
  2116. $invoice = new invoice ();
  2117. $detail = $invoice->getInvoiceByIsid ( $serial, $this->staff [0] ['sid'] );
  2118. if (empty ( $detail ))
  2119. $html = '';
  2120. else {
  2121. $html = '
  2122. <div class="modal-dialog modal-lg">
  2123. <div class="modal-content"><div class="modal-header"><h3>发票单详情</h3></div>
  2124. <div class="modal-body saeaList"><table class="table table-bordered table-condensed"><tbody>
  2125. <tr>
  2126. <th class="taC" width="150">开票流水号</th><td>' . $detail ['invoiceSerial'] . '</td>
  2127. <th class="taC" width="150">提交时间</th><td>' . $detail ['date'] . '</td>
  2128. </tr>
  2129. <tr>
  2130. <th class="taC" width="150">所在办事处</th><td>' . $detail ['categoryName'] . '(' . $detail ['userName'] . ')</td>
  2131. <th class="taC" width="150">备注</th><td>' . $detail ['remark'] . '</td>
  2132. </tr>
  2133. <tr>
  2134. <th class="taC">开票金额</th><td><b class="colOrange" style="font-size:18px">¥' . $detail ['invoicePrice'] . '</b></td>
  2135. <th class="taC">开票内容</th><td>' . $detail ['invoiceElement'] . '</td>
  2136. </tr></tbody></table>';
  2137. if ($detail ['invoiceType'] == 0)
  2138. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th colspan="4" class="taC">增值税普通发票</th></tr><tr>
  2139. <th class="taC" width="150">发票抬头</th><td colspan="3">' . $detail ['invoiceTitle'] . '</td></tr></tbody></table>';
  2140. else
  2141. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th colspan="4" class="taC">增值税专用发票</th></tr><tr>
  2142. <th class="taC" width="150">单位名称</th><td>' . $detail ['invoiceCompany'] . '</td>
  2143. <th class="taC" width="150">纳税人识别码</th><td>' . $detail ['TIN'] . '</td></tr><tr>
  2144. <th class="taC">注册地址</th><td>' . $detail ['address'] . '</td>
  2145. <th class="taC">注册电话</th><td>' . $detail ['phone'] . '</td>
  2146. </tr><tr>
  2147. <th class="taC">开户银行</th><td>' . $detail ['bankAccount'] . '</td>
  2148. <th class="taC">银行账户</th><td>' . $detail ['bank'] . '</td>
  2149. </tr></tbody></table>';
  2150. if ($detail ['doPost'] == 1)
  2151. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th colspan="4" class="taC">邮寄信息</th></tr><tr>
  2152. <th class="taC" width="150">收件人</th><td>' . $detail ['recipients'] . '</td>
  2153. <th class="taC" width="150">收件人手机/电话</th><td>' . $detail ['recipientsPhone'] . '</td>
  2154. </tr><tr>
  2155. <th class="taC" width="150">收件地址</th><td colspan="3">' . $detail ['recipientsAddress'] . '</td>
  2156. </tr><tr>
  2157. <th class="taC" width="150">邮寄物品</th><td colspan="3">' . $detail ['mailItems'] . '</td>
  2158. </tr></tbody></table>';
  2159. $html .= '</div><div class="modal-footer"><a href="#" class="button btn-gray" data-dismiss="modal" aria-hidden="true">关闭</a></div></div></div>';
  2160. }
  2161. echo json_encode ( array (
  2162. 'status' => 1,
  2163. 'html' => $html
  2164. ) );
  2165. die ();
  2166. } elseif ($type == 'RECEIVABLES') {
  2167. Doo::loadModel ( 'invoiceReceivables' );
  2168. $invoiceReceivables = new invoiceReceivables ();
  2169. $detail = $invoiceReceivables->getInvoiceReceivablesByIrsid ( $serial, $this->staff [0] ['sid'] );
  2170. if (empty ( $detail ))
  2171. $html = '';
  2172. else {
  2173. $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">
  2174. <tbody><tr>
  2175. <th class="taC">收款流水号</th><td>' . $detail ['receivablesSerial'] . '</td>
  2176. <th class="taC">录入收款</th><td>' . $detail ['inputStaff'] . ' ' . $detail ['date'] . '</td>
  2177. </tr><tr>
  2178. <th class="taC">收款金额</th><td><b>¥' . $detail ['receivablesPrice'] . '</b></td>
  2179. <th class="taC">收款信息</th><td>' . $detail ['receivablesMessage'] . '</td>
  2180. </tr>
  2181. <tr>
  2182. <th class="taC">收款银行</th><td>' . $detail ['receivablesBank'] . '</td>
  2183. <th class="taC">银行到帐</th><td>' . $detail ['receivablesDate'] . '</td>
  2184. </tr>
  2185. <tr>
  2186. <th class="taC">认领收款</th><td colspan="3">' . $detail ['inputStaff'] . ' 转入 ' . $detail ['username'] . ' ' . $detail ['bindDate'] . '</td>
  2187. </tr>
  2188. </tbody></table></div><div class="modal-footer"><a href="#" class="button btn-gray" data-dismiss="modal" aria-hidden="true">关闭</a></div></div></div>';
  2189. }
  2190. echo json_encode ( array (
  2191. 'status' => 1,
  2192. 'html' => $html
  2193. ) );
  2194. die ();
  2195. }
  2196. }
  2197. function _GetFileEXT($filename) {
  2198. $pics = explode ( '.', $filename );
  2199. $num = count ( $pics );
  2200. return $pics [$num - 1];
  2201. }
  2202. function showCache($path = "") {
  2203. if (file_exists ( $path )) {
  2204. $htm = file_get_contents ( $path );
  2205. } else {
  2206. Doo::loadModel ( 'invoiceStatistics' );
  2207. $invoiceStatistics = new invoiceStatistics ();
  2208. $isBriefly = $invoiceStatistics->getBrieflyStatistics ();
  2209. $htm = '<tr><th class="taC">' . $isBriefly ['statisticsMonth'] [0] ['month'] . '月累计开票</th>
  2210. <td>¥' . $isBriefly ['statisticsMonth'] [0] ['invoicePrice'] . '</td>
  2211. <th class="taC">' . $isBriefly ['statisticsMonth'] [0] ['month'] . '月累计入账</th>
  2212. <td>¥' . $isBriefly ['statisticsMonth'] [0] ['accountPrice'] . '</td></tr>';
  2213. /*
  2214. * '<tr><th class="taC">今年累计开票</th><td>¥' . $isBriefly ['statisticsYear'] [0] ['invoicePrice'] . '</td> <th class="taC">今年累计入账</th><td>¥' . $isBriefly ['statisticsYear'] [0] ['accountPrice'] . '</td></tr>';
  2215. */
  2216. file_put_contents ( $path, $htm, FILE_APPEND );
  2217. }
  2218. return $htm;
  2219. }
  2220. /**
  2221. * 获取get或者POST值
  2222. *
  2223. * @param string $name 属性名称
  2224. * @return fixed 值
  2225. */
  2226. function get_args($name) {
  2227. if (isset ( $_GET [$name] )) {
  2228. if (is_array ( $_GET [$name] ))
  2229. return $_GET [$name];
  2230. else
  2231. return addslashes ( $_GET [$name] );
  2232. } elseif (isset ( $_POST [$name] )) {
  2233. if (is_array ( $_POST [$name] ))
  2234. return $_POST [$name];
  2235. else
  2236. return addslashes ( $_POST [$name] );
  2237. } else
  2238. return false;
  2239. }
  2240. /**
  2241. * 获得分页数据
  2242. * @param unknown_type $table
  2243. * @param unknown_type $condition
  2244. * @param unknown_type $on_page
  2245. * @param unknown_type $page_size
  2246. */
  2247. function get_page($table = "", $condition = "", $on_page = 1, $page_size = 20, $action = "", $get = "", $other = "page") {
  2248. $page_c = "";
  2249. $page ['previous'] = $this->get_previous ( $on_page );
  2250. $page ['on_page'] = $on_page;
  2251. $total_count = $this->get_table_count ( $table, $condition );
  2252. $total = intval ( $total_count / $page_size );
  2253. $page ['total_page'] = ($total_count % $page_size) == 0 ? $total : $total + 1;
  2254. $page ['total_data'] = $total_count;
  2255. $page ['next'] = $on_page == $page ['total_page'] ? $page ['total_page'] : $on_page + 1;
  2256. $i = 1;
  2257. $page_max = 1;
  2258. $page_width=3;
  2259. if ($on_page >= $page_width) {
  2260. $page_max = intval ( $on_page / $page_width ) + 1;
  2261. $i = intval ( $on_page / $page_width ) * $page_width - 1;
  2262. }
  2263. for(; $i <= $page ['total_page']; $i ++) {
  2264. if ($i == $on_page)
  2265. $page_c .= '<li class="active"><a href="javascript:void(0)">' . $i . '</a></li>';
  2266. else
  2267. $page_c .= '<li><a href="/' . $action .'/'. $i . $get . '">' . $i . '</a></li>';
  2268. if ($i == ($page_width * $page_max))
  2269. break;
  2270. }
  2271. $page ['page'] = $page_c;
  2272. $page ['lower'] = (-- $on_page) * $page_size;
  2273. return $page;
  2274. }
  2275. /**
  2276. * 获取上一页
  2277. * @param unknown_type $on_page
  2278. */
  2279. function get_previous($on_page = 1) {
  2280. return $on_page != 0 ? $on_page - 1 : $on_page;
  2281. }
  2282. /**
  2283. * 获取总页数
  2284. * @param unknown_type $table
  2285. * @param unknown_type $condition
  2286. */
  2287. public function get_table_count($table = "", $condition = "") {
  2288. //$sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  2289. $sql = "select count(*) as count from " . $table . " where " . $condition;
  2290. //echo $sql;die;
  2291. $query = Doo::db ()->query ( $sql );
  2292. $result = $query->fetch ();
  2293. return $result ['count'];
  2294. }
  2295. function isInvoiceNew($type = "GLOBAL") {
  2296. Doo::loadModel ( 'invoice' );
  2297. $invoice = new invoice ();
  2298. Doo::loadModel ( 'invoiceReceivables' );
  2299. $invoiceReceivables = new invoiceReceivables ();
  2300. Doo::loadModel ( 'staff' );
  2301. $staff = new staff ();
  2302. $st = $staff->getUserByIdList ( $_COOKIE ["staff"] );
  2303. // 我的发票待处理
  2304. $pendingInvoice = $invoice->getOne ( array (
  2305. '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"],
  2306. 'desc' => 'iid',
  2307. 'asArray' => TRUE
  2308. ) );
  2309. // 我的收款待入账
  2310. $myClaim = $invoiceReceivables->getOne ( array (
  2311. 'where' => " receivablesStaff like '" . $_COOKIE ["staff"] . "-%' and receivablesCategory like '" . $st [0] ['cid'] . ":%' and bindStatus=0",
  2312. 'desc' => 'irid',
  2313. 'asArray' => TRUE
  2314. ) );
  2315. // 发票审批
  2316. $approval = $invoice->getOne ( array (
  2317. 'where' => 'status=1 and pendingApprovals=' . $_COOKIE ["staff"],
  2318. 'desc' => 'iid',
  2319. 'asArray' => true
  2320. ) );
  2321. // 发票邮寄
  2322. $post = $invoice->getOne ( array (
  2323. 'where' => "postStatus=0 and doPost=1 and status=2",
  2324. 'asArray' => TRUE
  2325. ) );
  2326. // 发票打印
  2327. $print = $invoice->getOne ( array (
  2328. 'where' => "status=2 and printStatus=0 and moldManage like '%[\"" . $_COOKIE ["staff"] . "\",%'",
  2329. 'desc' => 'iid',
  2330. 'asArray' => TRUE
  2331. ) );
  2332. // 发票退票
  2333. $untread = $invoice->getOne ( array (
  2334. 'where' => " printStatus=1 and untreadStatus=1 and status=2 ",
  2335. 'asArray' => TRUE
  2336. ) );
  2337. $new = array (
  2338. 'GLOBAL' => FALSE,
  2339. 'pendingInvoice' => FALSE,
  2340. 'myClaim' => FALSE,
  2341. 'approval' => FALSE,
  2342. 'post' => FALSE,
  2343. 'print' => FALSE,
  2344. 'untread' => FALSE
  2345. );
  2346. if (! empty ( $pendingInvoice ) || ! empty ( $myClaim ) || ! empty ( $approval ) || ! empty ( $post ) || ! empty ( $print ) || ! empty ( $untread ))
  2347. $new ['GLOBAL'] = TRUE;
  2348. if (! empty ( $pendingInvoice ))
  2349. $new ['pendingInvoice'] = TRUE;
  2350. if (! empty ( $myClaim ))
  2351. $new ['myClaim'] = TRUE;
  2352. if (! empty ( $approval ))
  2353. $new ['approval'] = TRUE;
  2354. if (! empty ( $post ))
  2355. $new ['post'] = TRUE;
  2356. if (! empty ( $print ))
  2357. $new ['print'] = TRUE;
  2358. if (! empty ( $untread ))
  2359. $new ['untread'] = TRUE;
  2360. return $new ;
  2361. }
  2362. }
  2363. ?>