CopyOfinvoice_service.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. class invoice_service {
  3. private $invoiceTraining;
  4. private $invoice;
  5. private $XDeode;
  6. function __construct() {
  7. Doo::loadClass ( 'XDeode' );
  8. $this->XDeode = new XDeode ( 9 );
  9. $this->XDeode5 = new XDeode ( 5 );
  10. Doo::loadModel ( 'cld/invoice_training_cld' );
  11. $this->invoiceTraining = new invoice_training_cld ();
  12. Doo::loadModel ( 'cld/invoice_cld' );
  13. $this->invoice = new invoice_cld ();
  14. }
  15. /* 获得办事处和创建的 培训班发票 */
  16. public function getTrainByCategoryStaff($status, $categoryIdString, $staffId) {
  17. Doo::loadModel ( 'staff' );
  18. $staff = new staff ();
  19. Doo::loadModel ( 'L_category' );
  20. $lCategory = new L_category ();
  21. // 1.获得培训班
  22. $list = $this->invoiceTraining->getStatusByCategoryStaff ( $status, $categoryIdString, $staffId );
  23. // 2.获得培训班发票总数-
  24. foreach ( $list as $key => $value ) {
  25. $list [$key] ['trainingKey'] = $this->XDeode5->encode ( $value ['itid'] );
  26. $detail = $staff->getStaffBySid ( $value ['creator'] );
  27. $list [$key] ['staff'] = $detail;
  28. $detail = $lCategory->getCategoryById ( $value ['cid'] );
  29. $list [$key] ['category'] = $detail;
  30. // 每个培训班发票总数和金额,入账总数
  31. $invoiceList = $this->invoice->GetTrainByUnFinish ( $value ['itid'] );
  32. $list[$key]['invoiceTotal']=count($invoiceList);
  33. $priceTotle=0;
  34. $BalancePriceTotle=0;
  35. foreach ($invoiceList as $k=>$v){
  36. $priceTotle+=$v['invoicePrice'];
  37. if($v['status']==2&&$v['untreadStatus']==3){
  38. $BalancePriceTotle+=$v['invoiceBalance'];
  39. }else{
  40. $BalancePriceTotle+=$v['invoicePrice'];
  41. }
  42. }
  43. $list[$key]['invoiceTotalAmount']=$priceTotle;
  44. $list[$key]['invoiceArriveAmount']=$priceTotle-$BalancePriceTotle;
  45. $list[$key]['arriveSchedule']=0;
  46. if($list[$key]['invoiceTotal']!=0){
  47. $list[$key]['arriveSchedule']=round ( $list [$key] ['invoiceArriveAmount'] / $list [$key] ['invoiceTotalAmount'] * 100, 2 );
  48. }
  49. }
  50. return $list;
  51. // print_r ( $list );
  52. // die ();
  53. }
  54. }
  55. ?>