invoice.php 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  1. <?php
  2. Doo::loadCore ( 'db/DooModel' );
  3. /**
  4. * 发票审批相关信息及其操作业务逻辑
  5. * @author CP.
  6. * @version 1.0
  7. * @namespace invoice
  8. * @package invoiceModel
  9. */
  10. class invoice extends DooModel {
  11. /**
  12. *
  13. * @var integer $iid 发票ID
  14. */
  15. public $iid;
  16. /**
  17. *
  18. * @var integer $status 审批状态
  19. */
  20. public $status;
  21. /**
  22. *
  23. * @var string $invoiceManage 当前审批组人员
  24. */
  25. public $printStatus;
  26. public $postStatus;
  27. public $invoiceManage;
  28. /**
  29. *
  30. * @var string $pendingApprovals 当前需要审批的人
  31. */
  32. public $pendingApprovals;
  33. /**
  34. *
  35. * @var string $processApprovals 已经审批过的人员
  36. */
  37. public $processApprovals;
  38. /**
  39. *
  40. * @var string $invoiceSerial 发票单号
  41. */
  42. public $invoiceSerial;
  43. /**
  44. *
  45. * @var integer $invoicePrice 发票金额
  46. */
  47. public $invoicePrice;
  48. /**
  49. * 管理组人员:发票打印,
  50. * @var unknown
  51. */
  52. public $moldManage;
  53. /**
  54. *
  55. * @var integer $cid 办事处ID
  56. */
  57. public $cid;
  58. /**
  59. *
  60. * @var string $categoryName 办事处名称
  61. */
  62. public $categoryName;
  63. /**
  64. *
  65. * @var integer $sid 提交发票人ID
  66. */
  67. public $sid;
  68. /**
  69. *
  70. * @var string $userName 提交人名字
  71. */
  72. public $userName;
  73. /**
  74. *
  75. * @var string $remark 备注
  76. */
  77. public $remark;
  78. /**
  79. *
  80. * @var string $invoiceElement 发票内容
  81. */
  82. public $invoiceElement;
  83. /**
  84. *
  85. * @var string $invoiceType 发票类型
  86. */
  87. public $invoiceType;
  88. /**
  89. *
  90. * @var string $invoiceTitle 发票抬头
  91. */
  92. public $invoiceTitle;
  93. /**
  94. *
  95. * @var string $invoiceCompany 开票公司
  96. */
  97. public $invoiceCompany;
  98. /**
  99. *
  100. * @var string $invoiceNo 发票号
  101. */
  102. public $invoiceNo;
  103. /**
  104. *
  105. * @var string $TIN 纳税人识别码
  106. */
  107. public $TIN;
  108. /**
  109. *
  110. * @var string $address 注册地址
  111. */
  112. public $address;
  113. /**
  114. *
  115. * @var string $phone 电话
  116. */
  117. public $phone;
  118. /**
  119. *
  120. * @var string $bank 开户银行
  121. */
  122. public $bank;
  123. /**
  124. *
  125. * @var string $bankAccount 银行账户
  126. */
  127. public $bankAccount;
  128. /**
  129. *
  130. * @var integer $doPost 邮寄
  131. */
  132. public $doPost;
  133. /**
  134. *
  135. * @var string $recipients 收件人
  136. */
  137. public $recipients;
  138. /**
  139. *
  140. * @var string $recipientsPhone 收件人电话
  141. */
  142. public $recipientsPhone;
  143. /**
  144. *
  145. * @var string $recipientsAddress 收件地址
  146. */
  147. public $recipientsAddress;
  148. /**
  149. *
  150. * @var string $mailItems 邮寄物品
  151. */
  152. public $mailItems;
  153. public $expressCompany;
  154. public $expressNumber;
  155. public $actualItems;
  156. /**
  157. *
  158. * @var date $date 提交时间
  159. */
  160. public $date;
  161. /**
  162. *
  163. * @var date $updateTime 更新时间
  164. */
  165. public $updateTime;
  166. /**
  167. *
  168. * @var date $printTime 打印时间
  169. */
  170. public $printTime;
  171. public $_table = 'CLD_invoice';
  172. public $_primarykey = 'iid';
  173. public $_fields = array (
  174. 'iid',
  175. 'invoiceManage',
  176. 'pendingApprovals',
  177. 'processApprovals',
  178. 'invoiceSerial',
  179. 'status',
  180. 'printStatus',
  181. 'postStatus',
  182. 'invoicePrice',
  183. 'moldManage',
  184. 'cid',
  185. 'categoryName',
  186. 'remark',
  187. 'invoiceElement',
  188. 'invoiceType',
  189. 'invoiceTitle',
  190. 'invoiceCompany',
  191. 'invoiceNo',
  192. 'TIN',
  193. 'address',
  194. 'phone',
  195. 'bank',
  196. 'bankAccount',
  197. 'doPost',
  198. 'recipients',
  199. 'recipientsPhone',
  200. 'recipientsAddress',
  201. 'mailItems',
  202. 'expressCompany',
  203. 'expressNumber',
  204. 'actualItems',
  205. 'sid',
  206. 'userName',
  207. 'date',
  208. 'updateTime',
  209. 'printTime'
  210. );
  211. /**
  212. * 根据发票ID获取一条发票数据
  213. * @param number $iid 发票ID
  214. * @param number $select 需要获取的字段,为空获取全部数据
  215. * @return array|array() 返回发票数据
  216. */
  217. public function getInvoiceByIid($iid = 0, $select = "") {
  218. $condition = array (
  219. 'where' => "iid=" . $iid,
  220. 'asArray' => TRUE
  221. );
  222. if (! empty ( $select ))
  223. $condition += array (
  224. 'select' => $select
  225. );
  226. $Detail = array ();
  227. if (is_numeric ( $iid ) && ! empty ( $iid ))
  228. $Detail = $this->getOne ( $condition );
  229. return $Detail;
  230. }
  231. /**
  232. * 获取单个可以打印的发票数据
  233. * @param number $iid 发票id
  234. * @param number $select 需要获取的字段,为空获取全部数据
  235. * @return array|array() 返回发票数据
  236. */
  237. public function getInvoiceByPrint($iid = 0, $select = "") {
  238. $condition = array (
  239. 'where' => "iid= '" . $iid . "' and status=2",
  240. 'asArray' => TRUE
  241. );
  242. if (! empty ( $select ))
  243. $condition += array (
  244. 'select' => $select
  245. );
  246. $detail = array ();
  247. if (! empty ( $iid ) && is_numeric ( $iid ))
  248. $detail = $this->getOne ( $condition );
  249. return $detail;
  250. }
  251. /**
  252. * 添加一个发票并进入审批状态
  253. * @param array $item 发票相关数据
  254. * @return number 返回发票ID
  255. */
  256. public function addInvoice($item = array()) {
  257. $lid = 0;
  258. if (is_array ( $item ) && ! empty ( $item )) {
  259. foreach ( $item as $key => $value ) {
  260. $this->$key = $value;
  261. }
  262. $lid = $this->insert ();
  263. }
  264. return $lid;
  265. }
  266. /**
  267. * 记录发票号并完成打印
  268. * @param array $item 发票号和完成打印状态数据
  269. * @return number 返回发票ID
  270. */
  271. public function setPrintByInvoice($item = array()) {
  272. $lid = 0;
  273. if (is_array ( $item ) && ! empty ( $item )) {
  274. foreach ( $item as $key => $value ) {
  275. $this->$key = $value;
  276. }
  277. $lid = $this->update ();
  278. }
  279. return $lid;
  280. }
  281. /**
  282. * 根据管理组和发票当前状态获得打印发票数据;其中当iid为空时获取所有发票数据,反之获取1条数据
  283. * @param number $sid 管理组人员ID
  284. * @param number $status 状态 为0时获取可以打印数据,为1时获取已经完成打印数据
  285. * @param number $iid 发票ID
  286. * @return array|array() 返回所有发票数据,当iid有值时返回一条数据
  287. */
  288. public function getPrintInvoiceByManage($sid = 0, $status = 0, $iid = 0) {
  289. $list = array ();
  290. if (! empty ( $sid ) && empty ( $iid ))
  291. $list = $this->find ( array (
  292. 'where' => "status=2 and printStatus=" . $status . " and moldManage like '%[\"" . $sid . "\",%'",
  293. 'desc' => 'iid',
  294. 'asArray' => TRUE
  295. ) );
  296. elseif (! empty ( $sid ) && ! empty ( $iid ))
  297. $list = $this->getOne ( array (
  298. 'where' => "status=2 and printStatus=" . $status . " and moldManage like '%[\"" . $sid . "\",%' and iid=" . $iid,
  299. 'asArray' => TRUE
  300. ) );
  301. return $list;
  302. }
  303. /**
  304. * 待修改 获取待处理发票的数据 其中包括退回`终止
  305. * @return unknown
  306. */
  307. public function getPendingByInvoice() {
  308. $list = $this->find ( array (
  309. 'where' => "status=3 or status=4",
  310. 'asArray' => TRUE
  311. ) );
  312. return $list;
  313. }
  314. /**
  315. * 获取需要邮寄的发票
  316. * @return array
  317. */
  318. public function getPostByInvoice() {
  319. $list = $this->find ( array (
  320. 'where' => "postStatus=0 and doPost=1 and status=2",
  321. 'asArray' => TRUE
  322. ) );
  323. return $list;
  324. }
  325. /**
  326. * 获取已经邮寄过的发票
  327. * @return array
  328. */
  329. public function getPostedByInvoice() {
  330. $list = $this->find ( array (
  331. 'where' => "postStatus=1 and doPost=1 and status=2",
  332. 'asArray' => TRUE
  333. ) );
  334. return $list;
  335. }
  336. }
  337. ?>