|
@@ -227,7 +227,9 @@ class ReceiptExtendController extends DooController {
|
|
|
'invoiceArriveAmount' => '0.00',
|
|
|
'RIAmount' => '0.00',
|
|
|
'invoiceTotalAmount' => '0.00',
|
|
|
- 'invoiceCompanyAmount' => '0.00'
|
|
|
+ 'invoiceCompanyAmount' => '0.00',
|
|
|
+ 'invoiceArriveAmountM'=>'0.00',
|
|
|
+ 'invoiceCompanyAmountM'=>'0.00'
|
|
|
);
|
|
|
if ($receiptDetail ['invoiceTrainId'] != 0) {
|
|
|
$invoiceTrainingDetail = $invoiceTraining->getInvoiceTrainingByItid ( $receiptDetail ['invoiceTrainId'] );
|
|
@@ -287,7 +289,11 @@ class ReceiptExtendController extends DooController {
|
|
|
|
|
|
$payment = $sum + $RIAmount - $categoryActualExpenditure;
|
|
|
$data ['payment'] = sprintf ( "%.2f", $payment );
|
|
|
-
|
|
|
+ $data ['paymentAbs']=sprintf ( "%.2f",abs($payment));
|
|
|
+
|
|
|
+ Doo::loadClass ( 'authcode.func' );
|
|
|
+ $data ['paymentAuthCode'] = authcode($payment,'');
|
|
|
+
|
|
|
$data ['total'] = sprintf ( "%.2f", $aiData ['total'] );
|
|
|
$data ['aiCount'] = count ( $aiData ['dataList'] ) + 5;
|
|
|
$data ['aiList'] = $aiData ['dataList'];
|
|
@@ -445,7 +451,7 @@ class ReceiptExtendController extends DooController {
|
|
|
$data ['summaryJson'] =URLEncode(json_encode($summaryJson));
|
|
|
$data ['aiListJson'] =URLEncode(json_encode($data ['aiList']));
|
|
|
|
|
|
-
|
|
|
+ $data['inputDate']=date ( "Y-m-d H:i:s" );
|
|
|
|
|
|
$data ['memu'] = "receipt";
|
|
|
$data ['staff'] = $this->staff;
|
|
@@ -554,7 +560,7 @@ class ReceiptExtendController extends DooController {
|
|
|
$data ['showType'] = $showType;
|
|
|
$receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
|
|
|
|
|
|
- $invoiceList = $invoiceTrainingDetail = array ();
|
|
|
+ $invoiceList = $invoiceTrainingDetail = array ('invoiceTotalAmount'=>0,'invoiceArriveAmount'=>0);
|
|
|
if ($receiptDetail ['invoiceTrainId'] != 0) {
|
|
|
$invoiceList = $invoice->getInvoicePrintedByItid ( $receiptDetail ['invoiceTrainId'] );
|
|
|
$invoiceTrainingDetail = $invoiceTraining->getInvoiceTrainingByItid ( $receiptDetail ['invoiceTrainId'] );
|
|
@@ -996,6 +1002,26 @@ class ReceiptExtendController extends DooController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ //执行人是否是最后一位
|
|
|
+ $executeCopy = json_decode ( $receiptDetail ['executeCopy'], true );
|
|
|
+ $executeStaff = json_decode ( $receiptDetail ['executeStaff'], true );
|
|
|
+ $executePrimary=count($executeCopy)-1;
|
|
|
+ $lastOne=true;
|
|
|
+ if($executePrimary!=count($executeStaff)){
|
|
|
+ $lastOne=false;
|
|
|
+ }
|
|
|
+ $data['lastOne']=$lastOne;
|
|
|
+ // 是否写入过流水
|
|
|
+ $accountType = 0;
|
|
|
+ if ($receiptDetail ['Rtype'] == 3) {
|
|
|
+ $accountType = 12;
|
|
|
+ }
|
|
|
+ Doo::loadModel ( 'wasteBook' );
|
|
|
+ $wasteBook = new wasteBook ();
|
|
|
+ $wbDetail = $wasteBook->getWateBookByAD ( $accountType, $receiptDetail ['rid'] );
|
|
|
+ $data ['wbDetail'] = $wbDetail;
|
|
|
+
|
|
|
+
|
|
|
$data ['button2'] = $button2;
|
|
|
$data ['executeList'] = $executeList;
|
|
|
|
|
@@ -1047,6 +1073,55 @@ class ReceiptExtendController extends DooController {
|
|
|
'asArray' => true
|
|
|
) );
|
|
|
|
|
|
+ //计算汇款金额
|
|
|
+ // 收入合计
|
|
|
+ Doo::loadModel ( 'invoiceTraining' );
|
|
|
+ $invoiceTraining = new invoiceTraining ();
|
|
|
+ $invoiceTrainingDetail = array (
|
|
|
+ 'invoiceArriveAmount' => '0.00',
|
|
|
+ 'RIAmount' => '0.00',
|
|
|
+ 'invoiceTotalAmount' => '0.00',
|
|
|
+ 'invoiceCompanyAmount' => '0.00',
|
|
|
+ 'invoiceArriveAmountM'=>'0.00',
|
|
|
+ 'invoiceCompanyAmountM'=>'0.00'
|
|
|
+ );
|
|
|
+ if ($receiptDetail ['invoiceTrainId'] != 0) {
|
|
|
+ $invoiceTrainingDetail = $invoiceTraining->getInvoiceTrainingByItid ( $receiptDetail['invoiceTrainId'] );
|
|
|
+ }
|
|
|
+ $invoiceArriveAmount = $RIAmount = 0;
|
|
|
+ if (! empty ( $invoiceTrainingDetail )) {
|
|
|
+ $invoiceArriveAmount = $invoiceTrainingDetail ['invoiceArriveAmount'];
|
|
|
+ $RIAmount = $invoiceTrainingDetail ['RIAmount'];
|
|
|
+ }
|
|
|
+
|
|
|
+ // 备用金
|
|
|
+ $sum = 0;
|
|
|
+ if (! empty ( $receiptDetail ['trainLoanRid'] )) {
|
|
|
+ $receiptLoanDetailBak = $receipt->getReceiptByRid ( $receiptDetail ['trainLoanRid'] );
|
|
|
+ $sum = $receiptLoanDetailBak ['sum'];
|
|
|
+ }
|
|
|
+
|
|
|
+ // 支出项金额详情
|
|
|
+ // 项目金额合计
|
|
|
+ Doo::loadModel ( 'RItem' );
|
|
|
+ $RItem = new RItem ();
|
|
|
+ Doo::loadModel ( 'accountItem' );
|
|
|
+ $accountItem = new accountItem ();
|
|
|
+ // 讲师获得
|
|
|
+ Doo::loadModel ( 'RILecturer' );
|
|
|
+ $RILecturer = new RILecturer ();
|
|
|
+ $RItemList = $RItem->getRItemByRid ( $rid );
|
|
|
+ $RILecturerList = $RILecturer->getRILecturerByRid ( $rid );
|
|
|
+ // 支出项金额详情
|
|
|
+ $aiData = $accountItem->getTrainingDetail ( $RItemList, $RILecturerList, $invoiceArriveAmount );
|
|
|
+ $categoryActualExpenditure = $aiData ['total'] - $aiData ['categoryActualExpenditure'];
|
|
|
+
|
|
|
+ $payment = $sum + $RIAmount - $categoryActualExpenditure;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
$nslist = explode ( ',', $receiptDetail ['nowStaff'] );
|
|
|
$nsflag = true;
|
|
|
foreach ( $nslist as $value ) {
|
|
@@ -1474,6 +1549,10 @@ class ReceiptExtendController extends DooController {
|
|
|
// 微信企业号通知
|
|
|
// $this->setWXMsg ( $rid, 1 );
|
|
|
}
|
|
|
+
|
|
|
+ //汇款金额
|
|
|
+ $receipt->amount=$payment;
|
|
|
+
|
|
|
$receipt->update ( array (
|
|
|
'where' => ' rid = ' . $rid
|
|
|
) );
|
|
@@ -1952,9 +2031,12 @@ class ReceiptExtendController extends DooController {
|
|
|
$ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : '';
|
|
|
$bank = $this->get_args ( 'bank' ) ? $this->get_args ( 'bank' ) : "";
|
|
|
|
|
|
- $amountTrain = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : '';
|
|
|
+ $amountTrain = $this->get_args ( 'amount' ) ? $this->get_args ( 'amount' ) : '';
|
|
|
$expensesType = $this->get_args ( 'expensesType' ) ? $this->get_args ( 'expensesType' ) : "";
|
|
|
|
|
|
+ $inputDate = $this->get_args ( 'inputDate' ) ? $this->get_args ( 'inputDate' ) : date ( "Y-m-d H:i:s" );
|
|
|
+ $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : "";
|
|
|
+
|
|
|
$actionType = $this->get_args ( 'actionType' ) ? $this->get_args ( 'actionType' ) : "";
|
|
|
if (! empty ( $actionType )) {
|
|
|
if ($actionType != 'NOTRAIN')
|
|
@@ -1995,8 +2077,19 @@ class ReceiptExtendController extends DooController {
|
|
|
} elseif ($rinfo ['Rtype'] == 2) {
|
|
|
$accountType = 4;
|
|
|
$expensesType='EXPENDITURE';
|
|
|
- } elseif ($rinfo ['Rtype'] == 3) {
|
|
|
+ } elseif ($rinfo ['Rtype'] == 3) {//培训班结算 收支类型
|
|
|
$accountType = 12;
|
|
|
+ Doo::loadClass ( 'authcode.func' );
|
|
|
+ $amountTrain=authcode($amountTrain);
|
|
|
+ if(!is_numeric ( $amountTrain )) {
|
|
|
+ die('illegal request--payType');
|
|
|
+ }
|
|
|
+
|
|
|
+ if($amountTrain>=0){
|
|
|
+ $expensesType='INCOME';
|
|
|
+ }else{
|
|
|
+ $expensesType='EXPENDITURE';
|
|
|
+ }
|
|
|
$amount=$amountTrain;
|
|
|
}
|
|
|
|
|
@@ -2059,7 +2152,8 @@ class ReceiptExtendController extends DooController {
|
|
|
'cid' => $rinfo ['category'] [0] ['cid'],
|
|
|
'name' => $rinfo ['staffDetail'] ['username'],
|
|
|
'sid' => $rinfo ['staffDetail'] ['sid'],
|
|
|
- 'inputDate' => date ( "Y-m-d H:i:s" )
|
|
|
+ 'inputDate' => $inputDate,
|
|
|
+ 'remarks'=>$remarks
|
|
|
);
|
|
|
$wasteBook->setAccountBookStatistics ( $item );
|
|
|
}
|
|
@@ -2070,7 +2164,14 @@ class ReceiptExtendController extends DooController {
|
|
|
return '/receiptTrain/implement/' . $XDeode->encode ( $rid ) . '.html?trainEdiType=COLLECT';
|
|
|
} elseif ($actionType == 'NOTRAIN') {
|
|
|
$XDeode = new XDeode ( 5 );
|
|
|
- return "/implement/" . $XDeode->encode ( $rid ) . ".html";
|
|
|
+ if ($rinfo['Rtype']==1){
|
|
|
+ return "/implement/loan/" . $XDeode->encode ( $rid ) . ".html";
|
|
|
+ }elseif($rinfo['Rtype']==0){
|
|
|
+ return "/implement/receipt/" . $XDeode->encode ( $rid ) . ".html";
|
|
|
+ }elseif($rinfo['Rtype']==2){
|
|
|
+ return "/implement/public/" . $XDeode->encode ( $rid ) . ".html";
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -2087,10 +2188,14 @@ class ReceiptExtendController extends DooController {
|
|
|
foreach ($receiptList as $key=>$value){
|
|
|
$receiptList[$key]['balance']='';
|
|
|
if($value['Rtype']==1){
|
|
|
- if($value['isBK']==1){
|
|
|
- $receiptList[$key]['balance']=$value['sum']-=$value['loanSum'];
|
|
|
- }
|
|
|
+ $receiptList[$key]['balance']=$value['sum']-=$value['loanSum'];
|
|
|
+ $receiptList[$key]['balanceABS']=abs($receiptList[$key]['balance']);
|
|
|
+ }elseif($value['Rtype']==3){
|
|
|
+ $payment=$this->_getReceiptTrainPayment($value['invoiceTrainId'],$value['trainLoanRid'],$value['rid']);
|
|
|
+ $receiptList[$key]['payment']=$payment;
|
|
|
+ $receiptList[$key]['paymentABS']=abs($payment);
|
|
|
}
|
|
|
+ $receiptList[$key]['amountABS']=abs($value['amount']);
|
|
|
}
|
|
|
|
|
|
|
|
@@ -2107,6 +2212,55 @@ class ReceiptExtendController extends DooController {
|
|
|
$this->render ( "/receipt/receiptWasteBook", $data );
|
|
|
}
|
|
|
|
|
|
+ function _getReceiptTrainPayment($invoiceTrainId,$trainLoanRid,$rid){
|
|
|
+ // 收入合计
|
|
|
+ Doo::loadModel ( 'invoiceTraining' );
|
|
|
+ $invoiceTraining = new invoiceTraining ();
|
|
|
+ Doo::loadModel ( 'receipt' );
|
|
|
+ $receipt = new receipt ();
|
|
|
+ $invoiceTrainingDetail = array (
|
|
|
+ 'invoiceArriveAmount' => '0.00',
|
|
|
+ 'RIAmount' => '0.00',
|
|
|
+ 'invoiceTotalAmount' => '0.00',
|
|
|
+ 'invoiceCompanyAmount' => '0.00',
|
|
|
+ 'invoiceArriveAmountM'=>'0.00',
|
|
|
+ 'invoiceCompanyAmountM'=>'0.00'
|
|
|
+ );
|
|
|
+ if ($invoiceTrainId != 0) {
|
|
|
+ $invoiceTrainingDetail = $invoiceTraining->getInvoiceTrainingByItid ( $invoiceTrainId );
|
|
|
+ }
|
|
|
+ $invoiceArriveAmount = $RIAmount = 0;
|
|
|
+ if (! empty ( $invoiceTrainingDetail )) {
|
|
|
+ $invoiceArriveAmount = $invoiceTrainingDetail ['invoiceArriveAmount'];
|
|
|
+ $RIAmount = $invoiceTrainingDetail ['RIAmount'];
|
|
|
+ }
|
|
|
+
|
|
|
+ // 备用金
|
|
|
+ $sum = 0;
|
|
|
+ if (! empty ( $value ['trainLoanRid'] )) {
|
|
|
+ $receiptLoanDetailBak = $receipt->getReceiptByRid ( trainLoanRid );
|
|
|
+ $sum = $receiptLoanDetailBak ['sum'];
|
|
|
+ }
|
|
|
+
|
|
|
+ // 支出项金额详情
|
|
|
+ // 项目金额合计
|
|
|
+ Doo::loadModel ( 'RItem' );
|
|
|
+ $RItem = new RItem ();
|
|
|
+ Doo::loadModel ( 'accountItem' );
|
|
|
+ $accountItem = new accountItem ();
|
|
|
+ // 讲师获得
|
|
|
+ Doo::loadModel ( 'RILecturer' );
|
|
|
+ $RILecturer = new RILecturer ();
|
|
|
+ $RItemList = $RItem->getRItemByRid ($rid );
|
|
|
+ $RILecturerList = $RILecturer->getRILecturerByRid ( $rid );
|
|
|
+ // 支出项金额详情
|
|
|
+ $aiData = $accountItem->getTrainingDetail ( $RItemList, $RILecturerList, $invoiceArriveAmount );
|
|
|
+ $categoryActualExpenditure = $aiData ['total'] - $aiData ['categoryActualExpenditure'];
|
|
|
+
|
|
|
+ $payment = $sum + $RIAmount - $categoryActualExpenditure;
|
|
|
+ return $payment;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 费用流水新增
|
|
|
*/
|
|
@@ -2116,24 +2270,29 @@ class ReceiptExtendController extends DooController {
|
|
|
die ( 'illegal request--ridKey' );
|
|
|
}
|
|
|
|
|
|
+ $receivedBank = $this->get_args ( 'receivedBank' ) ? $this->get_args ( 'receivedBank' ) : "";
|
|
|
+ $receivedRemarks = $this->get_args ( 'receivedRemarks' ) ? $this->get_args ( 'receivedRemarks' ) : "";
|
|
|
+ $receivedInputDate = $this->get_args ( 'receivedInputDate' ) ? $this->get_args ( 'receivedInputDate' ) : date ( "Y-m-d H:i:s" );
|
|
|
+ $amountTrain = $this->get_args ( 'paymentAuthCode' ) ? $this->get_args ( 'paymentAuthCode' ) : '';
|
|
|
+
|
|
|
+ if ( empty ( $receivedBank )) {
|
|
|
+ die ( 'illegal request--Bank' );
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /*
|
|
|
$expensesType = $this->get_args ( 'expensesType' ) ? $this->get_args ( 'expensesType' ) : "";
|
|
|
$expenditureBank = $this->get_args ( 'expenditureBank' ) ? $this->get_args ( 'expenditureBank' ) : "";
|
|
|
$expenditurePrice = $this->get_args ( 'expenditurePrice' ) ? $this->get_args ( 'expenditurePrice' ) : "";
|
|
|
$expenditureRemarks = $this->get_args ( 'expenditureRemarks' ) ? $this->get_args ( 'expenditureRemarks' ) : "";
|
|
|
$expenditureInputDate = $this->get_args ( 'expenditureInputDate' ) ? $this->get_args ( 'expenditureInputDate' ) : date ( "Y-m-d H:i:s" );
|
|
|
-
|
|
|
- $receivedBank = $this->get_args ( 'receivedBank' ) ? $this->get_args ( 'receivedBank' ) : "";
|
|
|
$receivedPrice = $this->get_args ( 'receivedPrice' ) ? $this->get_args ( 'receivedPrice' ) : "";
|
|
|
- $receivedRemarks = $this->get_args ( 'receivedRemarks' ) ? $this->get_args ( 'receivedRemarks' ) : "";
|
|
|
- $receivedInputDate = $this->get_args ( 'receivedInputDate' ) ? $this->get_args ( 'receivedInputDate' ) : date ( "Y-m-d H:i:s" );
|
|
|
-
|
|
|
- $expenditurePrice=str_replace(',','',$expenditurePrice);
|
|
|
- $receivedPrice=str_replace(',','',$receivedPrice);
|
|
|
-
|
|
|
- if (empty ( $expenditureBank ) || empty ( $receivedBank )) {
|
|
|
+
|
|
|
+ if (empty ( $expenditureBank ) || empty ( $receivedBank )) {
|
|
|
die ( 'illegal request--Bank' );
|
|
|
}
|
|
|
-
|
|
|
+ $expenditurePrice=str_replace(',','',$expenditurePrice);
|
|
|
+ $receivedPrice=str_replace(',','',$receivedPrice);
|
|
|
if ($expensesType == "INCOME") {
|
|
|
if(!is_numeric($receivedPrice)){
|
|
|
die ( 'illegal request--receivedPrice' );
|
|
@@ -2143,6 +2302,7 @@ class ReceiptExtendController extends DooController {
|
|
|
die ( 'illegal request--expenditurePrice' );
|
|
|
}
|
|
|
}
|
|
|
+ */
|
|
|
|
|
|
Doo::loadClass ( 'XDeode' );
|
|
|
$XDeode = new XDeode ( 5 );
|
|
@@ -2155,8 +2315,10 @@ class ReceiptExtendController extends DooController {
|
|
|
if (empty ( $detail )) {
|
|
|
die ( 'illegal request--noData' );
|
|
|
}
|
|
|
+ $amount=$detail['amount'];
|
|
|
|
|
|
$accountType = '';
|
|
|
+ /*
|
|
|
if ($detail ['Rtype'] == 1) {
|
|
|
if (! empty ( $detail ['accountItem'] ))
|
|
|
$accountType = 2;
|
|
@@ -2169,7 +2331,60 @@ class ReceiptExtendController extends DooController {
|
|
|
} elseif ($detail ['Rtype'] == 3) {
|
|
|
$accountType = 12;
|
|
|
}
|
|
|
+ */
|
|
|
+
|
|
|
+ if ($detail ['Rtype'] == 0) {
|
|
|
+ $accountType = 3;
|
|
|
+ $expensesType='EXPENDITURE';
|
|
|
+ } elseif ($detail ['Rtype'] == 1) {
|
|
|
+ if (! empty ( $rinfo ['accountItem'] )){
|
|
|
+ $accountType = 2;
|
|
|
+ if ($amount>=0){
|
|
|
+ $expensesType='EXPENDITURE';
|
|
|
+ }else{
|
|
|
+ $expensesType='INCOME';
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ $accountType = 1;
|
|
|
+ $expensesType='EXPENDITURE';
|
|
|
+ }
|
|
|
+ } elseif ($detail ['Rtype'] == 2) {
|
|
|
+ $accountType = 4;
|
|
|
+ $expensesType='EXPENDITURE';
|
|
|
+ } elseif ($detail ['Rtype'] == 3) {//培训班结算 收支类型
|
|
|
+ $accountType = 12;
|
|
|
+ Doo::loadClass ( 'authcode.func' );
|
|
|
+ $amountTrain=authcode($amountTrain);
|
|
|
+ if(!is_numeric ( $amountTrain )) {
|
|
|
+ die('illegal request--payType');
|
|
|
+ }
|
|
|
+
|
|
|
+ if($amountTrain>=0){
|
|
|
+ $expensesType='INCOME';
|
|
|
+ }else{
|
|
|
+ $expensesType='EXPENDITURE';
|
|
|
+ }
|
|
|
+ $amount=$amountTrain;
|
|
|
+ }
|
|
|
+
|
|
|
+ //汇款金额正数
|
|
|
+ $amount=abs($amount);
|
|
|
+ //$accountType = 12;
|
|
|
+ $accountBank = $receivedBank;
|
|
|
+ $inputDate = $receivedInputDate;
|
|
|
+ if ($expensesType == "INCOME") {
|
|
|
+ $expensesTypeWaste = 1;
|
|
|
+ $accountPriceShow = $accountPrice = $amount;
|
|
|
+ } elseif ($expensesType == "EXPENDITURE") {
|
|
|
+ $expensesTypeWaste = 2;
|
|
|
+ $accountPriceShow = $amount;
|
|
|
+ $accountPrice = - $amount;
|
|
|
+ } else {
|
|
|
+ die ( 'illegal request--expensesType' );
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
+ /*
|
|
|
$accountPriceShow = $accountPrice = 0;
|
|
|
$expensesTypeWaste = 0;
|
|
|
$accountBank = '';
|
|
@@ -2189,22 +2404,24 @@ class ReceiptExtendController extends DooController {
|
|
|
} else {
|
|
|
die ( 'illegal request--expensesType' );
|
|
|
}
|
|
|
+ */
|
|
|
|
|
|
$receipt = new receipt ();
|
|
|
- $receipt->amount = $accountPriceShow;
|
|
|
+ $receipt->amount = $accountPrice;
|
|
|
$receipt->update ( array (
|
|
|
'where' => 'rid=' . $rid
|
|
|
) );
|
|
|
|
|
|
+
|
|
|
// 更新借款汇款金额
|
|
|
if ($accountType == 1) {
|
|
|
Doo::loadModel ( 'loanReceipt' );
|
|
|
$loanReceipt = new loanReceipt ();
|
|
|
- $loanReceipt->amount = $accountPriceShow;
|
|
|
+ $loanReceipt->amount = $accountPrice;
|
|
|
|
|
|
$loanReceipt->update ( array (
|
|
|
'where' => ' rid = ' . $detail ['loanRid']
|
|
|
- ) );
|
|
|
+ ));
|
|
|
}
|
|
|
|
|
|
// 公司流水记录
|