fee_controller.php 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452
  1. <?php
  2. /*
  3. * @description: 费用管理控制类 @Author: CP @Date: 2020-11-11 17:51:05 @FilePath: \cld\protected\controller\fee\fee_controller.php
  4. */
  5. require "protected/services/fee_service.php";
  6. require "protected/services/region_service.php";
  7. require "protected/services/office_service.php";
  8. require "protected/class/comm_cld.php";
  9. class fee_controller extends DooController {
  10. private $staff;
  11. private $verifyId;
  12. private $executeId;
  13. private $feeService;
  14. private $regionService;
  15. private $officeService;
  16. public function beforeRun($resource, $action) {
  17. $this->accessAuth ( $resource, $action );
  18. }
  19. function __construct() {
  20. $this->session ();
  21. $this->feeService = new fee_service ();
  22. $this->regionService = new region_service ();
  23. $this->officeService = new office_service ();
  24. }
  25. // 访问权限-费用管理
  26. private function accessAuth($resource, $action) {
  27. Doo::loadClass ( 'XDeode' );
  28. $XDeode = new XDeode ( 5 );
  29. $sid = $XDeode->decode ( $_COOKIE ["staff"] );
  30. // 1.单独判断公司汇总的访问权限
  31. if ($action == 'companyCategoryCollect') {
  32. Doo::loadModel ( "receiptAuthorityManage" );
  33. $invoiceCompanyManage = new receiptAuthorityManage ();
  34. $icm = $invoiceCompanyManage->getInvoiceCMByStaff ( $sid );
  35. if (empty ( $icm ))
  36. die ( 'illegal request-无权访问该页面' );
  37. }
  38. // 2.获得登陆用户信息
  39. Doo::loadModel ( 'cld/staff_cld' );
  40. $staff = new staff_cld ();
  41. $this->staff = $staff->Get ( $sid );
  42. // 3.是否有权限访问
  43. $accessModular = 'RECEIPTS';
  44. if (empty ( $this->staff ['cldAccessArray'] )) {
  45. die ( 'illegal request-无权访问费用页面,向总部申请权限' );
  46. } else {
  47. if (in_array ( $accessModular, $this->staff ['cldAccessArray'] )) {
  48. if (Doo::acl ()->isAllowed ( $accessModular, $resource, $action )) {
  49. $flag = true;
  50. } else {
  51. $flag = false;
  52. }
  53. } else {
  54. die ( 'illegal request-无权访问费用页面' );
  55. }
  56. }
  57. if (! $flag)
  58. die ( 'illegal request-无权访问费用页面' );
  59. }
  60. // 登陆判定
  61. private function session() {
  62. if (isset ( $_COOKIE ["staff"] )) {
  63. if (! empty ( $_COOKIE ["staff"] )) {
  64. Doo::loadModel ( 'staff' );
  65. Doo::loadModel ( 'verify' );
  66. $verify = new verify ();
  67. $staff = new staff ();
  68. Doo::loadModel ( "execute" );
  69. $execute = new execute ();
  70. $verifyList = $verify->find ( array (
  71. 'select' => 'staff',
  72. 'asArray' => true
  73. ) );
  74. $list = array ();
  75. // 判断角色的审批权限
  76. foreach ( $verifyList as $key => $value ) {
  77. $ver = json_decode ( $value ['staff'] );
  78. foreach ( $ver as $k => $v ) {
  79. if ($v [1] == 'ROLE') {
  80. $roleList = json_decode ( $v [3] );
  81. foreach ( $roleList as $t => $g ) {
  82. $gList = explode ( "_", $g );
  83. array_push ( $list, $gList [0] );
  84. // print_r($list);
  85. }
  86. } else
  87. array_push ( $list, $v [0] );
  88. }
  89. }
  90. // 判断执行人的审批权限
  91. $executeList = $execute->find ( array (
  92. 'where' => 'mold !="日常收支"',
  93. 'select' => 'staff',
  94. 'asArray' => true
  95. ) );
  96. $list2 = array ();
  97. foreach ( $executeList as $key => $value ) {
  98. $ver = json_decode ( $value ['staff'] );
  99. foreach ( $ver as $k => $v ) {
  100. array_push ( $list2, $v [0] );
  101. }
  102. }
  103. $eidList = file_get_contents ( "protected/config/execute/execute.ini" );
  104. $eidList = array_filter ( explode ( ",", $eidList ) );
  105. $this->executeId = array_merge ( $list2, $eidList );
  106. // print_r($this->executeId);
  107. $this->verifyId = $list;
  108. // $this->staff = $staff->getUserByIdList ( $_COOKIE ["staff"] );
  109. return "/";
  110. }
  111. }
  112. Doo::loadCore ( 'uri/DooUriRouter' );
  113. $router = new DooUriRouter ();
  114. $routeRs = $router->execute ( Doo::app ()->route, Doo::conf ()->SUBFOLDER );
  115. if ($routeRs ['1'] != "login") {
  116. header ( 'Content-Type:text/html;charset=utf-8' );
  117. @header ( "Location: /login" );
  118. }
  119. }
  120. // 构建申请报销单页面
  121. public function GetViewReceiptCreate() {
  122. // 请求
  123. $data ['action'] = "/receipt/create";
  124. // 费用 项目细则
  125. $accountItem = $this->feeService->GetAccountItem ();
  126. $data ['accountItem'] = json_encode ( $accountItem );
  127. // 地区
  128. $region = $this->regionService->GetRegionTwo ();
  129. $data ['region'] = json_encode ( $region );
  130. // 审批
  131. $data ['verify'] = json_encode ( $this->feeService->GetVerify () );
  132. // 办事处
  133. $data ['office'] = $this->officeService->GetAll ();
  134. // 默认办事处
  135. $data ['officeId'] = $this->staff ['cid'];
  136. // 附件
  137. $data ['enclosurList'] = array ();
  138. $data ['staff'] = $this->staff;
  139. $data ['verifyId'] = $this->verifyId;
  140. $data ['executeId'] = $this->executeId;
  141. $data ['receiptMemu'] = 'saeaBorad';
  142. $data ['memu'] = "receipt";
  143. $this->render ( "/fee/create/receipt", $data );
  144. }
  145. // 编辑保险单
  146. public function GetViewReceiptEdit() {
  147. $receiptId = isset ( $this->params ['receiptId'] ) ? $this->params ['receiptId'] : '';
  148. if (empty ( $receiptId )) {
  149. die ( 'illegal request-请求参数错误,重新请求' );
  150. }
  151. $receiptId = GetDecryptId ( $receiptId );
  152. $detail = $this->feeService->GetReceipt ( $receiptId );
  153. // 附件相关
  154. Doo::loadModel ( 'enclosur' );
  155. $enclosur = new enclosur ();
  156. $data ['enclosurList'] = $enclosur->getEnclosurByRid ( $detail ['rid'] );
  157. // 费用 项目细则
  158. $accountItem = $this->feeService->GetAccountItem ();
  159. $data ['accountItem'] = json_encode ( $accountItem );
  160. // 报销单数据
  161. $data ['data'] = json_encode ( $this->makeReceiptEdiData ( $detail, $accountItem, $this->feeService->GetVerify () ) );
  162. // 请求
  163. $data ['action'] = "/receipt/edit";
  164. // 地区
  165. $region = $this->regionService->GetRegionTwo ();
  166. $data ['region'] = json_encode ( $region );
  167. // 审批
  168. $data ['verify'] = "[]";
  169. // 办事处
  170. $data ['office'] = $this->officeService->GetAll ();
  171. // 默认办事处
  172. $data ['officeId'] = $detail ['cid'];
  173. $data ['receiptId'] = $detail ['receiptId'];
  174. $data ['staff'] = $this->staff;
  175. $data ['verifyId'] = $this->verifyId;
  176. $data ['executeId'] = $this->executeId;
  177. $data ['receiptMemu'] = 'saeaBorad';
  178. $data ['memu'] = "receipt";
  179. $this->render ( "/fee/create/receipt", $data );
  180. }
  181. // 创建报销单
  182. public function PostReceiptCreate() {
  183. // 1.获得参数
  184. $data = array (
  185. "officeData" => get_args ( 'officeData' ),
  186. "traveData" => get_args ( 'traveData' ),
  187. "trainData" => get_args ( 'trainData' ),
  188. "enclosurFiles" => get_args ( 'enclosurFiles' ),
  189. "verifyId" => get_args ( 'verifyId' ),
  190. "officeId" => get_args ( 'officeId' ),
  191. "remittanceName" => get_args ( 'remittanceName' ),
  192. "remittanceBankType" => get_args ( 'remittanceBankType' ),
  193. "bankName" => get_args ( 'bankName' ),
  194. "bankNumber" => get_args ( 'bankNumber' ),
  195. "coupletNumber" => get_args ( 'coupletNumber' )
  196. );
  197. // 2.参数校验
  198. $data = $this->feeService->ValidRuleReceiptCreate ( $data );
  199. // 3.具体数据处理
  200. $msg = $this->feeService->ReceiptCreate ( $data, $this->staff );
  201. return "/saeaBorad";
  202. }
  203. // 更新报销单
  204. public function PostReceiptEdit() {
  205. // 1.获得参数
  206. $data = array (
  207. "receiptId" => get_args ( 'receiptId' ),
  208. "officeData" => get_args ( 'officeData' ),
  209. "traveData" => get_args ( 'traveData' ),
  210. "trainData" => get_args ( 'trainData' ),
  211. "enclosurFiles" => get_args ( 'enclosurFiles' ),
  212. "verifyId" => get_args ( 'verifyId' ),
  213. "officeId" => get_args ( 'officeId' ),
  214. "remittanceName" => get_args ( 'remittanceName' ),
  215. "remittanceBankType" => get_args ( 'remittanceBankType' ),
  216. "bankName" => get_args ( 'bankName' ),
  217. "bankNumber" => get_args ( 'bankNumber' ),
  218. "coupletNumber" => get_args ( 'coupletNumber' )
  219. );
  220. // 2.参数校验
  221. $data = $this->feeService->ValidRuleReceiptCreate ( $data );
  222. // 3.具体数据处理
  223. $msg = $this->feeService->ReceiptEdi ( $data, $this->staff );
  224. return "/saeaBorad";
  225. }
  226. // 创建借款报销单
  227. public function GetViewLoanReceiptCreate() {
  228. $receiptId = isset ( $this->params ['receiptId'] ) ? $this->params ['receiptId'] : '';
  229. if (empty ( $receiptId )) {
  230. die ( 'illegal request-请求参数错误,重新请求' );
  231. }
  232. $data ['receiptId'] = $receiptId;
  233. $receiptId = GetDecryptId ( $receiptId );
  234. $detail = $this->feeService->GetReceipt ( $receiptId );
  235. // 设置借款信息
  236. $loan = $this->feeService->GetLoanReceipt ( $detail ['loanRid'] );
  237. $data ['loan'] = $loan;
  238. // 费用 项目细则
  239. $accountItem = $this->feeService->GetAccountItem ();
  240. $data ['accountItem'] = json_encode ( $accountItem );
  241. // 报销单数据
  242. if ($detail ['status'] != 7) {
  243. $detail ['verify'] = '';
  244. }
  245. $data ['data'] = json_encode ( $this->makeReceiptEdiData ( $detail, $accountItem, $this->feeService->GetVerify () ) );
  246. // 地区
  247. $region = $this->regionService->GetRegionTwo ();
  248. $data ['region'] = json_encode ( $region );
  249. // 审批
  250. $data ['verify'] = json_encode ( $this->feeService->GetVerify () );
  251. // 办事处
  252. $data ['office'] = $this->officeService->GetAll ();
  253. // 默认办事处
  254. $data ['officeId'] = $this->staff ['cid'];
  255. // 附件
  256. $data ['enclosurList'] = array ();
  257. // 请求
  258. $data ['action'] = "/loan/receipt/edit";
  259. $data ['staff'] = $this->staff;
  260. $data ['verifyId'] = $this->verifyId;
  261. $data ['executeId'] = $this->executeId;
  262. $data ['receiptMemu'] = 'saeaBorad';
  263. $data ['memu'] = "receipt";
  264. $this->render ( "/fee/create/receipt", $data );
  265. }
  266. // 保存借款报销单
  267. public function PostLoanReceiptEdit() {
  268. // 1.获得参数
  269. $data = array (
  270. "receiptId" => get_args ( 'receiptId' ),
  271. "officeData" => get_args ( 'officeData' ),
  272. "traveData" => get_args ( 'traveData' ),
  273. "trainData" => get_args ( 'trainData' ),
  274. "enclosurFiles" => get_args ( 'enclosurFiles' ),
  275. "verifyId" => get_args ( 'verifyId' ),
  276. "officeId" => get_args ( 'officeId' ),
  277. "remittanceName" => get_args ( 'remittanceName' ),
  278. "remittanceBankType" => get_args ( 'remittanceBankType' ),
  279. "bankName" => get_args ( 'bankName' ),
  280. "bankNumber" => get_args ( 'bankNumber' ),
  281. "coupletNumber" => get_args ( 'coupletNumber' )
  282. );
  283. // 2.参数校验
  284. $data = $this->feeService->ValidRuleReceiptCreate ( $data );
  285. // 3.处理借款报销单数据
  286. $msg = $this->feeService->LoanReceiptEdi ( $data ['receiptId'] );
  287. // 4.具体数据处理
  288. $msg = $this->feeService->ReceiptEdi ( $data, $this->staff );
  289. return "/saeaBorad";
  290. }
  291. // 审批页面
  292. public function GetViewReceiptApproval() {
  293. $receiptId = isset ( $this->params ['receiptId'] ) ? $this->params ['receiptId'] : '';
  294. if (empty ( $receiptId )) {
  295. die ( 'illegal request-请求参数错误,重新请求' );
  296. }
  297. $receiptId = GetDecryptId ( $receiptId );
  298. $detail = $this->feeService->GetReceipt ( $receiptId );
  299. // 设置借款信息
  300. if (!empty($detail ['loanRid'])){
  301. $loan = $this->feeService->GetLoanReceipt ( $detail ['loanRid'] );
  302. $data ['loan'] = $loan;
  303. }
  304. // $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  305. // $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  306. // $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  307. $data['receipt']=$detail;
  308. $data ['staff'] = $this->staff;
  309. $data ['verifyId'] = $this->verifyId;
  310. $data ['executeId'] = $this->executeId;
  311. $data ['receiptMemu'] = 'saeaBorad';
  312. $data ['memu'] = "receipt";
  313. $this->render ( "/fee/approval/receipt", $data );
  314. }
  315. // 构造页面数据
  316. private function makeReceiptEdiData($data, $accountItem, $verify) {
  317. $officeJson = array (
  318. "id" => 0,
  319. "name" => "办事处相关费用",
  320. "show" => false,
  321. "anchor" => "officeAnchor",
  322. "active" => false,
  323. "daily" => $accountItem ['daily'],
  324. "other" => $accountItem ['other'],
  325. "officeExplain" => array (
  326. 0 => array (
  327. "officeExplain" => ""
  328. )
  329. )
  330. );
  331. if (! empty ( $data ['officeJson'] )) {
  332. $officeJson = json_decode ( $data ['officeJson'], true );
  333. }
  334. $traveJson = array (
  335. "id" => 1,
  336. "name" => "差旅相关费用",
  337. "show" => false,
  338. "anchor" => "traveAnchor",
  339. "active" => false,
  340. "trave" => $accountItem ['trave'],
  341. "traveList" => array (),
  342. "traveExplain" => array (
  343. 0 => array (
  344. "traveExplain" => ""
  345. )
  346. )
  347. );
  348. if (! empty ( $data ['traveJson'] )) {
  349. $traveJson = json_decode ( $data ['traveJson'], true );
  350. }
  351. $trainJson = array (
  352. "id" => 2,
  353. "name" => "内部培训费用",
  354. "show" => false,
  355. "anchor" => "trainAnchor",
  356. "active" => false,
  357. "train" => $accountItem ['train'],
  358. "trainExplain" => array (
  359. 0 => array (
  360. "trainExplain" => ""
  361. )
  362. )
  363. );
  364. if (! empty ( $data ['trainJson'] )) {
  365. $trainJson = json_decode ( $data ['trainJson'], true );
  366. }
  367. return array (
  368. "receiptTypeMenu" => array (
  369. 0 => $officeJson,
  370. 1 => $traveJson,
  371. 2 => $trainJson
  372. ),
  373. "verify" => $verify,
  374. "verifyId" => $data ['verify'],
  375. "remittanceBankType" => 0,
  376. "enclosurFiles" => array (),
  377. "aletMsg" => '',
  378. "displayStsates" => 'none'
  379. );
  380. }
  381. }
  382. ?>