";
include $path;
die ();
}
}
private function cacheFile($path) {
$content = ob_get_contents ();
$fp = fopen ( $path, "w" );
fwrite ( $fp, $content );
fclose ( $fp );
}
private function collectHtml($receiptCollectList = array(), $itemCategory = "日常相关费用", $classType = "b") {
$collectHtml = "";
$sumPrice = 0.00;
for($i = 1; $i <= 12; $i ++) {
$falg = true;
foreach ( $receiptCollectList as $key => $value ) {
if ($value ['itemCategory'] == $itemCategory && $value ['month'] == $i) {
$sumPrice += $value ['price'];
if ($classType == "b") {
$collectHtml .= '
¥' . $value ['price'] . ' | ';
$falg = false;
break;
} else {
$collectHtml .= '¥' . $value ['price'] . ' | ';
$falg = false;
break;
}
}
}
if ($falg)
$collectHtml .= '- | ';
}
$collectHtml .= '¥' . $sumPrice . ' | ';
return $collectHtml;
}
public function beforeRun($resource, $action) {
Doo::loadClass ( 'XDeode' );
$XDeode = new XDeode ( 5 );
$sid = $XDeode->decode ( $_COOKIE ["staff"] );
// 单独判断公司汇总的访问权限
if ($action == 'companyCategoryCollect') {
Doo::loadModel ( "receiptAuthorityManage" );
$invoiceCompanyManage = new receiptAuthorityManage ();
$icm = $invoiceCompanyManage->getInvoiceCMByStaff ( $sid );
if (empty ( $icm ))
die ( 'illegal request' );
}
Doo::loadModel ( 'staff' );
$staff = new staff ();
$detail = $staff->getStaffBySid ( $_COOKIE ["staff"] );
$accessModular = 'RECEIPTSEXTEND'; // 是否已经开放的方法
$accessAuthority = 'RECEIPTS';
if (empty ( $detail ['cldAccessArray'] ))
die ( 'illegal request' );
else {
if (in_array ( $accessAuthority, $detail ['cldAccessArray'] )) {
if (Doo::acl ()->isAllowed ( $accessModular, $resource, $action )) {
$flag = true;
} else {
$flag = false;
}
} else {
die ( 'illegal request' );
}
}
if (! $flag)
die ( 'illegal request' );
}
function __construct() {
if (isset ( $_COOKIE ["staff"] )) {
if (! empty ( $_COOKIE ["staff"] )) {
Doo::loadModel ( 'staff' );
Doo::loadModel ( 'verify' );
$verify = new verify ();
$staff = new staff ();
Doo::loadModel ( "execute" );
$execute = new execute ();
$verifyList = $verify->find ( array (
'select' => 'staff',
'asArray' => true
) );
$list = array ();
// 判断角色的审批权限
foreach ( $verifyList as $key => $value ) {
$ver = json_decode ( $value ['staff'] );
foreach ( $ver as $k => $v ) {
if ($v [1] == 'ROLE') {
$roleList = json_decode ( $v [3] );
foreach ( $roleList as $t => $g ) {
$gList = explode ( "_", $g );
array_push ( $list, $gList [0] );
// print_r($list);
}
} else
array_push ( $list, $v [0] );
}
}
// 判断执行人的审批权限
$executeList = $execute->find ( array (
'where'=>'mold !="日常收支"',
'select' => 'staff',
'asArray' => true
) );
$list2 = array ();
foreach ( $executeList as $key => $value ) {
$ver = json_decode ( $value ['staff'] );
foreach ( $ver as $k => $v ) {
array_push ( $list2, $v [0] );
}
}
//print_r($executeList);
$eidList = file_get_contents ( "protected/config/execute/execute.ini" );
$eidList = array_filter ( explode ( ",", $eidList ) );
$this->executeId = array_merge ( $list2, $eidList );
$this->verifyId = $list;
$this->staff = $staff->getUserByIdList ( $_COOKIE ["staff"] );
// 检测用户信息完成
$this->data ['isStaffCompleteMsg'] = false;
$detail = $staff->checkStaffInfoIsComplete ( $_COOKIE ["staff"] );
if (! empty ( $detail ))
$this->data ['isStaffCompleteMsg'] = true;
return "/";
}
}
Doo::loadCore ( 'uri/DooUriRouter' );
$router = new DooUriRouter ();
$routeRs = $router->execute ( Doo::app ()->route, Doo::conf ()->SUBFOLDER );
if ($routeRs ['1'] != "login") {
header ( 'Content-Type:text/html;charset=utf-8' );
@header ( "Location: /login" );
}
}
/**
* 查看审批培训班结算
*/
function receiptTrain() {
$showType = isset ( $this->params ['showType'] ) ? $this->params ['showType'] : '';
$ridKey = isset ( $this->params ['ridKey'] ) ? $this->params ['ridKey'] : '';
$trainEdiType = $this->get_args ( 'trainEdiType' ) ? $this->get_args ( 'trainEdiType' ) : "INFO";
Doo::loadClass ( 'XDeode' );
$XDeode = new XDeode ( 7 );
$rid = $XDeode->decode ( $ridKey );
if (! is_numeric ( $rid ))
die ( 'illegal request' );
Doo::loadModel ( 'receipt' );
$receipt = new receipt ();
Doo::loadModel ( 'receiptTraining' );
$receiptTraining = new receiptTraining ();
$receiptDetail = $receipt->getReceiptByRid ( $rid );
// 如有已入账已收款的发票,自动取消办事处已收款
// Doo::loadModel ( 'RIExtend' );
// $RIExtend = new RIExtend ();
// $RIExtendList=$RIExtend->getRIExtendByRid($rid);
// if (!empty($RIExtendList)){
// foreach ($RIExtenreceiptTrainRevenuedList as $key=>$value){
// $RIExtend = new RIExtend ();
// $RIExtend->delete(array (
// 'where' => 'iid=' . $value['iid'],
// 'limit' => 1
// ));
// }
// }
$data ['receiptMemu'] = 'expenses';
if ($showType == 'approval') {
$data ['receiptMemu'] = 'approvalExpenses';
// if ($receiptDetail ['status'] != 2)
// die ();
} elseif ($showType == 'implement') {
$data ['receiptMemu'] = 'implement';
// if (! ($receiptDetail ['status'] == 1 || $receiptDetail ['status'] == 6))
// die ();
}
$data ['showType'] = $showType;
$receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
// 汇总表合计
// 收入合计
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'] );
}
// print_r($invoiceTrainingDetail);
$invoiceArriveAmount = $RIAmount = 0;
if (! empty ( $invoiceTrainingDetail )) {
$invoiceArriveAmount = $invoiceTrainingDetail ['invoiceArriveAmount'];
$RIAmount = $invoiceTrainingDetail ['RIAmount'];
}
$data ['invoiceTrainingDetail'] = $invoiceTrainingDetail;
// 支出项目
Doo::loadModel ( 'accountItem' );
$accountItem = new accountItem ();
// 项目金额合计
Doo::loadModel ( 'RItem' );
$RItem = new RItem ();
// 讲师获得
Doo::loadModel ( 'RILecturer' );
$RILecturer = new RILecturer ();
$RItemList = $RItem->getRItemByRid ( $rid );
$RILecturerList = $RILecturer->getRILecturerByRid ( $rid );
// 支出项金额详情
$aiData = $accountItem->getTrainingDetail ( $RItemList, $RILecturerList, $invoiceArriveAmount );
// 利润
$profit = $invoiceArriveAmount - $aiData ['total'];
$companyProfit = $profit * 0.6;
$categoryProfit = $profit * 0.4;
$data ['profit'] = sprintf ( "%.2f", $profit );
$data ['companyProfit'] = sprintf ( "%.2f", $companyProfit );
$data ['categoryProfit'] = sprintf ( "%.2f", $categoryProfit );
// 发票利润
$data ['invoiceProfit'] = $invoiceTrainingDetail ['invoiceTotalAmount'] - $aiData ['total'];
// 发票公司利润
$invoiceCompanyProfit = $data ['invoiceProfit'] * 0.6;
$data ['invoiceCompanyProfit'] = sprintf ( "%.2f", $invoiceCompanyProfit );
// 办事处利润
$invoiceCategoryProfit = $data ['invoiceProfit'] * 0.4;
$data ['invoiceCategoryProfit'] = sprintf ( "%.2f", $invoiceCategoryProfit );
// print_r($aiData['dataList']);
$categoryActualExpenditure = $aiData ['total'] - $aiData ['categoryActualExpenditure'];
$data ['categoryActualExpenditure'] = sprintf ( "%.2f", $categoryActualExpenditure );
// 备用金
$sum = 0;
$data ['receiptLoanDetail'] = array (
'sum' => '0.00'
);
if (! empty ( $receiptDetail ['trainLoanRid'] )) {
$receiptLoanList = $receipt->getReceiptInRid ( $receiptDetail ['trainLoanRid'] );
foreach ($receiptLoanList as $key=>$value){
$sum+=$value['sum'];
}
$data ['receiptLoanDetail'] = array (
'sum' => $sum
);
//$data ['receiptLoanDetail'] = $receipt->getReceiptByRid ( $receiptDetail ['trainLoanRid'] );
//$sum = $data ['receiptLoanDetail'] ['sum'];
}
$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'];
// 占比计算
if ($invoiceArriveAmount != 0) {
$data ['totalProportion'] = sprintf ( "%.2f", $aiData ['total'] / $invoiceArriveAmount * 100 );
$data ['profitProportion'] = sprintf ( "%.2f", $profit / $invoiceArriveAmount * 100 ); // number_format ( $profit / $invoiceArriveAmount, 2, '.', '' ) * 100;
$data ['sumProportion'] = sprintf ( "%.2f", $sum / $invoiceArriveAmount * 100 ); // number_format ( $sum / $invoiceArriveAmount, 2, '.', '' ) * 100;
$data ['invoiceTotalAmountProportion'] = sprintf ( "%.2f", $data ['invoiceTrainingDetail'] ['invoiceCompanyAmount'] / $invoiceArriveAmount * 100 );
$data ['RIAmountProportion'] = sprintf ( "%.2f", $data ['invoiceTrainingDetail'] ['RIAmount'] / $invoiceArriveAmount * 100 );
$data ['companyProfitProportion'] = sprintf ( "%.2f", $companyProfit / $invoiceArriveAmount * 100 );
$data ['categoryProportion'] = sprintf ( "%.2f", $categoryProfit / $invoiceArriveAmount * 100 );
$data ['categoryActualExpenditureProportion'] = sprintf ( "%.2f", $categoryActualExpenditure / $invoiceArriveAmount * 100 );
$data ['paymentProportion'] = sprintf ( "%.2f", $payment / $invoiceArriveAmount * 100 );
} else {
$data ['totalProportion'] = $data ['profitProportion'] = $data ['sumProportion'] = $data ['invoiceTotalAmountProportion'] = $data ['RIAmountProportion'] = $data ['companyProfitProportion'] = $data ['categoryActualExpenditureProportion'] = $data ['paymentProportion'] = $data ['categoryProportion'] = 0;
}
// 发票金额占比计算
if ($invoiceTrainingDetail ['invoiceTotalAmount'] != 0) {
// 支出
$data ['invoicetotalProportion'] = sprintf ( "%.2f", $aiData ['total'] / $invoiceTrainingDetail ['invoiceTotalAmount'] * 100 );
// 利润
$data ['invoiceprofitProportion'] = sprintf ( "%.2f", $data ['invoiceProfit'] / $invoiceTrainingDetail ['invoiceTotalAmount'] * 100 );
// 公司利润
$data ['invoicecompanyProfitProportion'] = sprintf ( "%.2f", $invoiceCompanyProfit / $invoiceTrainingDetail ['invoiceTotalAmount'] * 100 );
// 办事处利润
$data ['invoicecategoryProportion'] = sprintf ( "%.2f", $invoiceCategoryProfit / $invoiceTrainingDetail ['invoiceTotalAmount'] * 100 );
// 公司收款
$data ['invoiceTotalAmountProportionB'] = sprintf ( "%.2f", $data ['invoiceTrainingDetail'] ['invoiceCompanyAmount'] / $invoiceTrainingDetail ['invoiceTotalAmount'] * 100 );
// 备用金
$data ['invoicesumProportion'] = sprintf ( "%.2f", $sum / $invoiceTrainingDetail ['invoiceTotalAmount'] * 100 );
// 办事处收款
$data ['invoiceRIAmountProportion'] = sprintf ( "%.2f", $data ['invoiceTrainingDetail'] ['RIAmount'] / $invoiceTrainingDetail ['invoiceTotalAmount'] * 100 );
// 办事处实际支出
$data ['ICAEP'] = sprintf ( "%.2f", $categoryActualExpenditure / $invoiceTrainingDetail ['invoiceTotalAmount'] * 100 );
// 付总部款
$data ['invoicepaymentProportion'] = sprintf ( "%.2f", $payment / $invoiceTrainingDetail ['invoiceTotalAmount'] * 100 );
} else {
$data ['invoiceprofitProportion'] = $data ['invoiceRIAmountProportion'] = $data ['invoicetotalProportion'] = $data ['invoiceTotalAmountProportionB'] = $data ['invoicesumProportion'] = $data ['ICAEP'] = $data ['invoicepaymentProportion'] = $data ['invoicecompanyProfitProportion'] = $data ['invoicecategoryProportion'] = 0;
}
// 是否写入过流水
$accountType = 0;
if ($receiptDetail ['Rtype'] == 0) {
$accountType = 3;
} elseif ($receiptDetail ['Rtype'] == 1) {
if ($receiptDetail ['Rtype'] == 0) {
$accountType = 1;
} elseif ($receiptDetail ['Rtype'] == 1) {
$accountType = 2;
}
} elseif ($receiptDetail ['Rtype'] == 2) {
$accountType = 4;
} elseif ($receiptDetail ['Rtype'] == 3) {
$accountType = 12;
}
Doo::loadModel ( 'wasteBook' );
$wasteBook = new wasteBook ();
$wbDetail = $wasteBook->getWateBookByAD ( $accountType, $receiptDetail ['rid'] );
$data ['wbDetail'] = $wbDetail;
// 讲师人数
Doo::loadModel ( 'RILecturer' );
$RILecturer = new RILecturer ();
$RILecturerList = $RILecturer->getRILecturerByRid ( $rid );
$data ['lectureCount'] = count ( $RILecturerList );
// 审批组
Doo::loadModel ( 'verify' );
$verify = new verify ();
$veList = $verify->getVerifyByAll ();
// 办事处
Doo::loadModel ( 'L_category' );
$lCategory = new L_category ();
$data ['category'] = $lCategory->getCategory ();
$data ['receiptTrainingDetail'] = $receiptTrainingDetail;
$data ['receiptDetail'] = $receiptDetail;
$data ['veList'] = $veList;
$data ['trainEdiType'] = $trainEdiType;
$data ['ridKey'] = $ridKey;
$summaryJson = array (
0 => array (
'invoiceTotalAmount' => $data ['invoiceTrainingDetail'] ['invoiceTotalAmount'],
'invoiceArriveAmount' => $data ['invoiceTrainingDetail'] ['invoiceArriveAmount']
),
1 => array (
'1' => $data ['total'],
'2' => $data ['invoicetotalProportion'] . '%',
'3' => $data ['total'],
'4' => $data ['totalProportion'] . '%'
),
2 => array (
'1' => $data ['invoiceProfit'],
'2' => $data ['invoiceprofitProportion'] . '%',
'3' => $data ['profit'],
'4' => $data ['profitProportion'] . '%'
),
3 => array (
'1' => $data ['invoiceCompanyProfit'],
'2' => $data ['invoicecompanyProfitProportion'] . '%',
'3' => $data ['companyProfit'],
'4' => $data ['companyProfitProportion'] . '%'
),
4 => array (
'1' => $data ['invoiceCategoryProfit'],
'2' => $data ['invoicecategoryProportion'] . '%',
'3' => $data ['categoryProfit'],
'4' => $data ['categoryProportion'] . '%'
),
5 => array (
'1' =>$data ['invoiceTrainingDetail'] ['invoiceCompanyAmount'],
'2' => $data ['invoiceTotalAmountProportionB'] . '%',
'3' => $data ['invoiceTrainingDetail'] ['invoiceCompanyAmount'],
'4' => $data ['invoiceTotalAmountProportion'] . '%'
),
6 => array (
'1' =>$data ['receiptLoanDetail'] ['sum'],
'2' => $data ['invoicesumProportion'] . '%',
'3' => $data ['receiptLoanDetail'] ['sum'],
'4' => $data ['sumProportion'] . '%'
),
7 => array (
'1' =>$data ['invoiceTrainingDetail'] ['RIAmount'],
'2' => $data ['invoiceRIAmountProportion'] . '%',
'3' => $data ['invoiceTrainingDetail'] ['RIAmount'],
'4' => $data ['RIAmountProportion'] . '%'
),
8 => array (
'1' =>$data ['categoryActualExpenditure'],
'2' => $data ['ICAEP'] . '%',
'3' => $data ['categoryActualExpenditure'] ,
'4' => $data ['categoryActualExpenditureProportion'] . '%'
),
9 => array (
'1' =>$data ['payment'],
'2' => $data ['invoicepaymentProportion'] . '%',
'3' => $data ['payment'] ,
'4' => $data ['paymentProportion'] . '%'
),
10 => array (
'participants' =>$data ['receiptTrainingDetail'] ['participants'],
'lectureCount' => $data ['lectureCount'] ,
),
11=>array(
'total'=>$data ['total'],
'totalProportion'=>$data ['totalProportion']
),
);
$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;
$data ['verifyId'] = $this->verifyId;
$data ['executeId'] = $this->executeId;
$this->render ( "/receipt/receiptTrain", $data );
}
/**
* 培训班借款
*/
function receiptTrainLoan() {
$showType = isset ( $this->params ['showType'] ) ? $this->params ['showType'] : '';
$ridKey = isset ( $this->params ['ridKey'] ) ? $this->params ['ridKey'] : '';
Doo::loadClass ( 'XDeode' );
$XDeode = new XDeode ( 7 );
$rid = $XDeode->decode ( $ridKey );
if (! is_numeric ( $rid ))
die ( 'illegal request' );
Doo::loadModel ( 'receipt' );
$receipt = new receipt ();
Doo::loadModel ( 'receiptTraining' );
$receiptTraining = new receiptTraining ();
Doo::loadModel ( 'verify' );
$verify = new verify ();
$receiptDetail = $receipt->getReceiptByRid ( $rid );
$data ['receiptMemu'] = 'expenses';
if ($showType == 'approval') {
$data ['receiptMemu'] = 'approvalExpenses';
// if ($receiptDetail ['status'] != 2)
// die ();
} elseif ($showType == 'implement') {
$data ['receiptMemu'] = 'implement';
// if (! ($receiptDetail ['status'] == 1 || $receiptDetail ['status'] == 6))
// die ();
}
$data ['showType'] = $showType;
$receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
// 借款详情HTML
// 获得借款信息
$receiptLoanHtml = '';
if (! empty ( $receiptDetail ['trainLoanRid'] )) {
$receiptLoanList = $receipt->getReceiptInRid ( $receiptDetail ['trainLoanRid'] );
foreach ($receiptLoanList as $key=>$value){
// 获得某费用单审批信息
$verifylist = $verify->getVerifyByRid ( $value ['rid'] );
Doo::loadClass ( 'receipt.func' );
$extendHtml = '';
$receiptLoanHtml .= _getReceiptLoanHtml ( $value, $verifylist, $extendHtml );
}
}
$data ['receiptLoanHtml'] = $receiptLoanHtml;
$data ['receiptTrainingDetail'] = $receiptTrainingDetail;
$data ['receiptDetail'] = $receiptDetail;
$data ['trainEdiType'] = "LOAN";
$data ['ridKey'] = $ridKey;
$data ['memu'] = "receipt";
$data ['staff'] = $this->staff;
$data ['verifyId'] = $this->verifyId;
$data ['executeId'] = $this->executeId;
$this->render ( "/receipt/receiptTrainLoan", $data );
}
/**
* 培训班结算 ---开票
*/
function receiptTrainInvoice() {
$showType = isset ( $this->params ['showType'] ) ? $this->params ['showType'] : '';
$ridKey = isset ( $this->params ['ridKey'] ) ? $this->params ['ridKey'] : '';
Doo::loadClass ( 'XDeode' );
$XDeode = new XDeode ( 7 );
$rid = $XDeode->decode ( $ridKey );
if (! is_numeric ( $rid ))
die ( 'illegal request' );
Doo::loadModel ( 'receipt' );
$receipt = new receipt ();
Doo::loadModel ( 'receiptTraining' );
$receiptTraining = new receiptTraining ();
Doo::loadModel ( 'invoice' );
$invoice = new invoice ();
Doo::loadModel ( 'invoiceTraining' );
$invoiceTraining = new invoiceTraining ();
$receiptDetail = $receipt->getReceiptByRid ( $rid );
$data ['receiptMemu'] = 'expenses';
if ($showType == 'approval') {
$data ['receiptMemu'] = 'approvalExpenses';
// if ($receiptDetail ['status'] != 2)
// die ();
} elseif ($showType == 'implement') {
$data ['receiptMemu'] = 'implement';
// if (! ($receiptDetail ['status'] == 1 || $receiptDetail ['status'] == 6))
// die ();
}
$data ['showType'] = $showType;
$receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
$invoiceList = $invoiceTrainingDetail = array ('invoiceTotalAmount'=>0,'invoiceArriveAmount'=>0);
if ($receiptDetail ['invoiceTrainId'] != 0) {
$invoiceList = $invoice->getInvoicePrintedByItid ( $receiptDetail ['invoiceTrainId'] );
$invoiceTrainingDetail = $invoiceTraining->getInvoiceTrainingByItid ( $receiptDetail ['invoiceTrainId'] );
}
//收款是否完成更新状态
//$RIC=$invoiceTrainingDetail['RIAmount']+$invoiceTrainingDetail['invoiceCompanyAmount'];
if ($invoiceTrainingDetail['invoiceTotalAmount']<=$invoiceTrainingDetail['invoiceArriveAmount']&&$receiptDetail['paidStatus']==0){
$receipt = new receipt ();
$itemData = array (
'rid' => $rid,
'paidStatus' => 1,
);
$receipt->setReceiptByCondition($itemData);
}
// print_r($invoiceList);
$data ['invoiceList'] = $invoiceList;
$data ['invoiceTrainingDetail'] = $invoiceTrainingDetail;
$data ['receiptTrainingDetail'] = $receiptTrainingDetail;
$data ['receiptDetail'] = $receiptDetail;
$data ['trainEdiType'] = "INVOICE";
$data ['ridKey'] = $ridKey;
$data ['memu'] = "receipt";
$data ['staff'] = $this->staff;
$data ['verifyId'] = $this->verifyId;
$data ['executeId'] = $this->executeId;
$this->render ( "/receipt/receiptTrainInvoice", $data );
}
/**
* 培训班结算
*/
function receiptTrainItem() {
$showType = isset ( $this->params ['showType'] ) ? $this->params ['showType'] : '';
$ridKey = isset ( $this->params ['ridKey'] ) ? $this->params ['ridKey'] : '';
$name = $this->get_args ( 'name' ) ? $this->get_args ( 'name' ) : '';
Doo::loadClass ( 'XDeode' );
$XDeode = new XDeode ( 7 );
$rid = $XDeode->decode ( $ridKey );
if (! is_numeric ( $rid ))
die ( 'illegal request' );
Doo::loadModel ( 'receipt' );
$receipt = new receipt ();
Doo::loadModel ( 'receiptTraining' );
$receiptTraining = new receiptTraining ();
Doo::loadModel ( 'RItem' );
$RItem = new RItem ();
Doo::loadModel ( 'accountItem' );
$accountItem = new accountItem ();
$receiptDetail = $receipt->getReceiptByRid ( $rid );
$data ['receiptMemu'] = 'expenses';
if ($showType == 'approval') {
$data ['receiptMemu'] = 'approvalExpenses';
// if ($receiptDetail ['status'] != 2)
// die ();
} elseif ($showType == 'implement') {
$data ['receiptMemu'] = 'implement';
// if (! ($receiptDetail ['status'] == 1 || $receiptDetail ['status'] == 6))
// die ();
}
$data ['showType'] = $showType;
$receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
$RItemList = $RItem->getRItemByRid ( $rid,$name );
$aiList = $accountItem->getAccountBookByCategory ( '培训班费用' );
// print_r($RItemList);
$data ['name'] = $name;
$data ['RItemList'] = $RItemList;
$data ['aiList'] = $aiList;
$data ['receiptTrainingDetail'] = $receiptTrainingDetail;
$data ['receiptDetail'] = $receiptDetail;
$data ['trainEdiType'] = "ITEM";
$data ['ridKey'] = $ridKey;
$data ['memu'] = "receipt";
$data ['staff'] = $this->staff;
$data ['verifyId'] = $this->verifyId;
$data ['executeId'] = $this->executeId;
$this->render ( "/receipt/receiptTrainItem", $data );
}
/**
* 培训班结算-讲师
*/
function receiptTrainLecturer() {
$showType = isset ( $this->params ['showType'] ) ? $this->params ['showType'] : '';
$ridKey = isset ( $this->params ['ridKey'] ) ? $this->params ['ridKey'] : '';
Doo::loadClass ( 'XDeode' );
$XDeode = new XDeode ( 7 );
$rid = $XDeode->decode ( $ridKey );
if (! is_numeric ( $rid ))
die ( 'illegal request' );
Doo::loadModel ( 'receipt' );
$receipt = new receipt ();
Doo::loadModel ( 'receiptTraining' );
$receiptTraining = new receiptTraining ();
Doo::loadModel ( 'RILecturer' );
$RILecturer = new RILecturer ();
Doo::loadModel ( 'lecturer' );
$lecturer = new lecturer ();
$receiptDetail = $receipt->getReceiptByRid ( $rid );
$data ['receiptMemu'] = 'expenses';
if ($showType == 'approval') {
$data ['receiptMemu'] = 'approvalExpenses';
// if ($receiptDetail ['status'] != 2)
// die ();
} elseif ($showType == 'implement') {
$data ['receiptMemu'] = 'implement';
// if (! ($receiptDetail ['status'] == 1 || $receiptDetail ['status'] == 6))
// die ();
}
$data ['showType'] = $showType;
$receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
$RILecturerList = $RILecturer->getRILecturerByRid ( $rid );
$lecturerList = $lecturer->getLecturerAll ();
$INSIDEhtml = $OUTSIDEhtml = '';
foreach ( $lecturerList as $key => $value ) {
if ($value ['ltype'] == 'INSIDE') {
$INSIDEhtml .= '';
} elseif ($value ['ltype'] == 'OUTSIDE') {
$OUTSIDEhtml .= '';
}
}
$data ['INSIDEhtml'] = $INSIDEhtml;
$data ['OUTSIDEhtml'] = $OUTSIDEhtml;
// print_r($RItemList);
$data ['RILecturerList'] = $RILecturerList;
$data ['receiptTrainingDetail'] = $receiptTrainingDetail;
$data ['receiptDetail'] = $receiptDetail;
$data ['trainEdiType'] = "LECTURER";
$data ['ridKey'] = $ridKey;
$data ['memu'] = "receipt";
$data ['staff'] = $this->staff;
$data ['verifyId'] = $this->verifyId;
$data ['executeId'] = $this->executeId;
$this->render ( "/receipt/receiptTrainLecturer", $data );
}
/**
* 培训班结算编辑-协助
*/
function receiptTrainAssistEdi() {
$ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
Doo::loadClass ( 'XDeode' );
$XDeode = new XDeode ( 7 );
$rid = $XDeode->decode ( $ridKey );
if (! is_numeric ( $rid ))
die ( 'illegal request' );
Doo::loadModel ( 'receipt' );
$receipt = new receipt ();
Doo::loadModel ( 'receiptTraining' );
$receiptTraining = new receiptTraining ();
Doo::loadModel ( 'RAssist' );
$RAssist = new RAssist ();
Doo::loadModel ( 'staff' );
$staff = new staff ();
$receiptDetail = $receipt->getReceiptByRid ( $rid );
if (! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4))
die ();
$receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
$RAssistList = $RAssist->getRAssistByRid ( $rid );
$assistStaffList = $staff->getStaffByCid ( $this->staff [0] ['cid'] );
// print_r($RAssistList);
$data ['$assistStaffList'] = $assistStaffList;
$data ['RAssistList'] = $RAssistList;
$data ['receiptTrainingDetail'] = $receiptTrainingDetail;
$data ['receiptDetail'] = $receiptDetail;
$data ['trainEdiType'] = "ASSIST";
$data ['ridKey'] = $ridKey;
$data ['memu'] = "receipt";
$data ['staff'] = $this->staff;
$data ['receiptMemu'] = 'saeaBorad';
$data ['verifyId'] = $this->verifyId;
$data ['executeId'] = $this->executeId;
$this->render ( "/receipt/receiptTrainAssistEdi", $data );
}
/**
* 添加协助人
*/
function receiptTrainAssistAddDo() {
$ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
$sidKey = $this->get_args ( 'sidKey' ) ? $this->get_args ( 'sidKey' ) : "";
if (! empty ( $ridKey ) && ! empty ( $sidKey )) {
Doo::loadClass ( 'XDeode' );
$XDeode = new XDeode ( 5 );
Doo::loadModel ( 'RAssist' );
$RAssist = new RAssist ();
$rid = $XDeode->decode ( $ridKey );
$sid = $XDeode->decode ( $sidKey );
if (! is_numeric ( $rid ) || ! is_numeric ( $sid )) {
die ( 'illegal request' );
}
$RAssist->rid = $rid;
$RAssist->sid = $sid;
$RAssist->date = date ( "Y-m-d" );
$RAssist->insert ();
$XDeode = new XDeode ( 7 );
return '/receiptTrainAssistEdi/' . $XDeode->encode ( $rid ) . '.html';
} else
die ( 'illegal request' );
}
/**
* 删除协作人
*/
function receiptTrainAssistDelDo() {
$aidKey = isset ( $this->params ['aidKey'] ) ? $this->params ['aidKey'] : '';
$ridKey = isset ( $this->params ['ridKey'] ) ? $this->params ['ridKey'] : '';
Doo::loadClass ( 'XDeode' );
$XDeode = new XDeode ( 5 );
$aid = $XDeode->decode ( $aidKey );
$rid = $XDeode->decode ( $ridKey );
if (! is_numeric ( $aid )) {
die ( 'illegal request--id' );
}
Doo::loadModel ( 'RAssist' );
$RAssist = new RAssist ();
$RAssist->delete ( array (
'where' => 'aid=' . $aid
) );
$XDeode = new XDeode ( 7 );
return '/receiptTrainAssistEdi/' . $XDeode->encode ( $rid ) . '.html';
}
/*
* 培训班结算-审批
*/
function receiptTrainApproval() {
$showType = isset ( $this->params ['showType'] ) ? $this->params ['showType'] : '';
$ridKey = isset ( $this->params ['ridKey'] ) ? $this->params ['ridKey'] : '';
Doo::loadClass ( 'XDeode' );
$XDeode = new XDeode ( 7 );
$rid = $XDeode->decode ( $ridKey );
if (! is_numeric ( $rid ))
die ( 'illegal request' );
Doo::loadModel ( 'receipt' );
$receipt = new receipt ();
Doo::loadModel ( 'receiptTraining' );
$receiptTraining = new receiptTraining ();
Doo::loadModel ( 'lecturer' );
$lecturer = new lecturer ();
$receiptDetail = $receipt->getReceiptByRid ( $rid );
// 是否有权访问
if ($showType != 'info') {
if (! in_array ( $this->staff [0] ['sid'], $this->verifyId )) {
die ( 'illegal request-verifyId' );
}
}
// 用户的访问页面类型
$data ['receiptMemu'] = 'expenses';
if ($showType == 'approval') {
$data ['receiptMemu'] = 'approvalExpenses';
// if ($receiptDetail ['status'] != 2)
// die ();
}
$data ['showType'] = $showType;
$receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
// 获取审批日志
Doo::loadModel ( 'receiptLog' );
$receiptLog = new receiptLog ();
// echo $rid;
$rlList = $receiptLog->find ( array (
'where' => 'rid=' . $rid,
'asc' => 'rlid',
'asArray' => true
) );
$data ['rlList'] = $rlList;
// 审批组
Doo::loadModel ( 'verify' );
$verify = new verify ();
$verifyList = $verify->getOne ( array (
'where' => 'vid=' . $receiptDetail ['verify'],
'asArray' => true
) );
$verifyList = json_decode ( $verifyList ['staff'], true );
$verifyStaff = json_decode ( $receiptDetail ['verifyStaff'], true );
$verifyList = $this->fnGetReceiptApprovalProcess ( $verifyList, $verifyStaff );
$data ['verifyList'] = $verifyList ['verifyList'];
// print_r($verifyList['verifyList']);
$data ['receiptTrainingDetail'] = $receiptTrainingDetail;
$data ['receiptDetail'] = $receiptDetail;
$data ['trainEdiType'] = "APPROVAL";
$data ['ridKey'] = $ridKey;
$data ['memu'] = "receipt";
$data ['staff'] = $this->staff;
$data ['verifyId'] = $this->verifyId;
$data ['executeId'] = $this->executeId;
if ($showType == 'approval') {
$this->render ( "/receipt/receiptTrainApproval", $data );
} else {
$this->render ( "/receipt/receiptTrainApprovalInfo", $data );
}
}
/**
* 培训班结算--执行
*/
function receiptTrainImplement() {
$showType = isset ( $this->params ['showType'] ) ? $this->params ['showType'] : 'implement';
$ridKey = isset ( $this->params ['ridKey'] ) ? $this->params ['ridKey'] : '';
Doo::loadClass ( 'XDeode' );
$XDeode = new XDeode ( 7 );
$rid = $XDeode->decode ( $ridKey );
if (! is_numeric ( $rid ))
die ( 'illegal request' );
Doo::loadModel ( 'receipt' );
$receipt = new receipt ();
Doo::loadModel ( 'receiptTraining' );
$receiptTraining = new receiptTraining ();
Doo::loadModel ( 'lecturer' );
$lecturer = new lecturer ();
$receiptDetail = $receipt->getReceiptByRid ( $rid );
// 是否有权访问
if (! in_array ( $this->staff [0] ['sid'], $this->executeId )) {
die ( 'illegal request' );
}
// 用户的访问页面类型
$data ['receiptMemu'] = 'implement';
// if (! ($receiptDetail ['status'] == 1 || $receiptDetail ['status'] == 6)) {
// die ();
// }
$data ['showType'] = $showType;
$receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
// 获取审批日志
Doo::loadModel ( 'receiptLog' );
$receiptLog = new receiptLog ();
// echo $rid;
$rlList = $receiptLog->find ( array (
'where' => 'rid=' . $rid,
'asc' => 'rlid',
'asArray' => true
) );
$data ['rlList'] = $rlList;
// 审批组
Doo::loadModel ( 'verify' );
$verify = new verify ();
$verifyList = $verify->getOne ( array (
'where' => 'vid=' . $receiptDetail ['verify'],
'asArray' => true
) );
$verifyList = json_decode ( $verifyList ['staff'], true );
$verifyStaff = json_decode ( $receiptDetail ['verifyStaff'], true );
$verifyList = $this->fnGetReceiptApprovalProcess ( $verifyList, $verifyStaff );
$data ['verifyList'] = $verifyList ['verifyList'];
// print_r($verifyList['verifyList']);
// 执行组
$executeList = json_decode ( $receiptDetail ['executeCopy'], true );
$executeStaff = array ();
if (! empty ( $receiptDetail ['executeStaff'] )) {
$executeStaff = json_decode ( $receiptDetail ['executeStaff'], true );
}
$button2 = 0;
if (isset ( $executeList )) {
foreach ( $executeList as $op => $lo ) {
$executeList [$op] ['date'] = "";
$executeList [$op] ['opinion'] = "";
$executeList [$op] ['status'] = "";
foreach ( $executeStaff as $m => $u ) {
if ($lo [0] == $m) {
$executeList [$op] ['date'] = $u ['date'];
$executeList [$op] ['opinion'] = $u ['opinion'];
$executeList [$op] ['status'] = $u ['status'];
break;
}
}
if ($this->staff [0] ['sid'] == $lo [0] && empty ( $executeList [$op] ['status'] )) {
$button2 = 1;
$executeList [$op] ['status'] = 4;
}
}
}
//执行人是否是最后一位
$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;
$data ['receiptTrainingDetail'] = $receiptTrainingDetail;
$data ['receiptDetail'] = $receiptDetail;
$data ['trainEdiType'] = "implement";
$data ['ridKey'] = $ridKey;
$data ['memu'] = "receipt";
$data ['staff'] = $this->staff;
$data ['verifyId'] = $this->verifyId;
$data ['executeId'] = $this->executeId;
$this->render ( "/receipt/receiptTrainImplement", $data );
}
function receiptTrainApprovalDo() {
$opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
$statusKey = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : '';
$ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : '';
if (! empty ( $ridKey ) && ! empty ( $statusKey )) {
Doo::loadClass ( 'XDeode' );
$XDeode = new XDeode ( 5 );
$rid = $XDeode->decode ( $ridKey );
if ($statusKey == 'AGREE') {
$status = 1;
} elseif ($statusKey == 'END') {
$status = 3;
} else {
die ( 'illegal request--status' );
}
Doo::loadModel ( "verify" );
$verify = new verify ();
Doo::loadModel ( "receiptDetail" );
$receiptDetailObj = new receiptDetail ();
Doo::loadModel ( "itemStatistics" );
Doo::loadModel ( "statistics" );
$statistics = new statistics ();
$itemStatistics = new itemStatistics ();
Doo::loadModel ( "receipt" );
$receipt = new receipt ();
$receiptDetail = $receipt->getOne ( array (
'where' => 'rid=' . $rid . ' and status=2 ',
'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'] )) {
$receiptLoanList = $receipt->getReceiptInRid ( $receiptDetail ['trainLoanRid'] );
foreach ($receiptLoanList as $key=>$value){
$sum+=$value['sum'];
}
// $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 ) {
if ($value == $this->staff ['0'] ['sid']) {
$nsflag = false;
break;
}
}
// 该用户是否能审批
if (empty ( $receiptDetail ) || $nsflag)
return "/approvalExpenses/pendApproval";
$verifyDetail = $verify->getOne ( array (
'where' => ' vid =' . $receiptDetail ['verify'],
'asArray' => true
) );
$verifyString = $verifyDetail ['staff'];
$verifyDetail = json_decode ( $verifyDetail ['staff'], true );
$verifyStaff = json_decode ( $receiptDetail ['verifyStaff'], true );
if (empty ( $opinion )) {
if ($status == 3)
$opinion = "终止";
else
$opinion = "同意支付";
}
$nowStaff = 0;
$nowStaffList = array ();
if (empty ( $verifyStaff )) {
// 还需加入是否已经进入角色审批
if ($verifyDetail [0] [1] == 'ROLE') {
$vStaffString = json_decode ( $verifyDetail [0] [3] );
foreach ( $vStaffString as $key => $value ) {
$staffK = explode ( "_", $value );
if ($staffK [0] != $this->staff [0] ['sid'])
array_push ( $nowStaffList, $staffK [0] );
}
// print_r($verifyDetail);
// die;
if (! empty ( $nowStaffList )) {
$nowStaff = implode ( ',', $nowStaffList );
$verifyStaff = array (
$this->staff [0] ['sid'] . "_R" => array (
'date' => date ( 'Y-m-d' ),
'opinion' => $opinion,
'status' => $status,
'nextStaff' => $verifyDetail [0] [0],
'ROLE' => 1
)
);
} else {
$nowStaff = $verifyDetail [1] [0];
$verifyStaff = array (
$this->staff [0] ['sid'] . "_R" => array (
'date' => date ( 'Y-m-d' ),
'opinion' => $opinion,
'status' => $status,
'nextStaff' => $verifyDetail [1] [0]
)
);
}
} else {
if ($verifyDetail [1] [1] == 'ROLE') {
$vStaffString = json_decode ( $verifyDetail [1] [3] );
// echo "dd";
foreach ( $vStaffString as $key => $value ) {
$staffK = explode ( "_", $value );
array_push ( $nowStaffList, $staffK [0] );
}
$nowStaff = implode ( ',', $nowStaffList );
$verifyStaff = array (
$this->staff [0] ['sid'] => array (
'date' => date ( 'Y-m-d' ),
'opinion' => $opinion,
'status' => $status,
'nextStaff' => $verifyDetail [1] [0],
'ROLE' => 1
)
);
} else {
$nowStaff = $verifyDetail [1] [0];
$verifyStaff = array (
$this->staff [0] ['sid'] => array (
'date' => date ( 'Y-m-d' ),
'opinion' => $opinion,
'status' => $status,
'nextStaff' => $verifyDetail [1] [0]
)
);
}
}
if ($status == 3)
$verifyStaff = array (
'final' => $status,
$this->staff [0] ['sid'] => array (
'date' => date ( 'Y-m-d' ),
'opinion' => $opinion,
'status' => $status
)
);
$vStaffString = json_encode ( $verifyStaff );
$receipt->nowStaff = $nowStaff;
$receipt->verifyStaff = $vStaffString;
} else {
$VS = end ( $verifyStaff );
// 非角色审批
if (! array_key_exists ( $this->staff [0] ['sid'], $verifyStaff ) && ! isset ( $VS ['ROLE'] )) {
$nextStaff = 0;
$roleSTF = false;
foreach ( $verifyDetail as $key => $value ) {
if ($value [0] == $this->staff [0] ['sid'] && $value [1] != 'ROLE') {
if (isset ( $verifyDetail [$key + 1] )) {
$nextStaff = $verifyDetail [$key + 1] [0];
if ($verifyDetail [$key + 1] [1] == 'ROLE')
$roleSTF = true;
}
break;
}
}
if (! $roleSTF) {
$nowStaff = $nextStaff;
$verifyStaff [$this->staff [0] ['sid']] = array (
'date' => date ( 'Y-m-d' ),
'opinion' => $opinion,
'status' => $status,
'nextStaff' => $nextStaff
);
} else {
// 获取角色下的所有用户ID
$nowStaffList = array ();
foreach ( $verifyDetail as $vfk ) {
if ($vfk [1] == 'ROLE') {
$vStaffString = json_decode ( $vfk [3] );
foreach ( $vStaffString as $key => $value ) {
$staffK = explode ( "_", $value );
array_push ( $nowStaffList, $staffK [0] );
}
}
}
$nowStaff = implode ( ',', $nowStaffList );
$verifyStaff [$this->staff [0] ['sid']] = array (
'date' => date ( 'Y-m-d' ),
'opinion' => $opinion,
'status' => $status,
'nextStaff' => $nextStaff,
'ROLE' => 0
);
}
if ($status == 3) {
$verifyStaff ['final'] = $status;
$verifyStaff [$this->staff [0] ['sid']] = array (
'date' => date ( 'Y-m-d' ),
'opinion' => $opinion,
'status' => $status
);
}
$vStaffString = json_encode ( $verifyStaff );
$receipt->nowStaff = $nowStaff;
$receipt->verifyStaff = $vStaffString;
}
// 角色审批
if (isset ( $VS ['ROLE'] )) {
// 找出角色人 当前审批角色组
$verifyJSStaff = array ();
$nowStaffList2 = array ();
foreach ( $verifyDetail as $key => $value ) {
if ($value [1] == 'ROLE' && $value [0] == $VS ['nextStaff']) {
$verifyJSStaff = json_decode ( $value [3] );
foreach ( $verifyJSStaff as $m ) {
$staffK = explode ( "_", $m );
array_push ( $nowStaffList2, $staffK [0] );
}
// print_r($nowStaffList2);
}
}
$RoleVerifyStaff = array ();
foreach ( $verifyStaff as $key => $value ) {
if (isset ( $value ['ROLE'] ) && $value ['ROLE'] == 1 && $VS ['nextStaff'] == $value ['nextStaff']) {
foreach ( $nowStaffList2 as $m ) {
if ($key == $m . "_R")
$RoleVerifyStaff [$key] = $value;
}
}
}
$jsCount = count ( $verifyJSStaff ) - 1; // echo $jsCount;die;
if ($jsCount == count ( $RoleVerifyStaff )) { // 或者
// 下一个审批人ID
$nextStaff = 0;
$falg = false;
foreach ( $verifyDetail as $key => $value ) {
if ($value [0] == $VS ['nextStaff'] && $value [1] == 'ROLE') {
if (isset ( $verifyDetail [$key + 1] ) && $verifyDetail [$key + 1] [1] == 'ROLE') {
$falg = true;
$vStaffString = json_decode ( $verifyDetail [$key + 1] [3] );
$nowStaffList = array ();
foreach ( $vStaffString as $v ) {
$staffK = explode ( "_", $v );
array_push ( $nowStaffList, $staffK [0] );
}
$nowStaff = implode ( ',', $nowStaffList );
$nextStaff = $verifyDetail [$key + 1] [0];
} elseif (isset ( $verifyDetail [$key + 1] )) {
$nextStaff = $verifyDetail [$key + 1] [0];
$nowStaff = $nextStaff;
} else
$nowStaff = '';
break;
}
}
if ($falg)
$verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
'date' => date ( 'Y-m-d' ),
'opinion' => $opinion,
'status' => $status,
'nextStaff' => $nextStaff,
'ROLE' => 1
);
else
$verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
'date' => date ( 'Y-m-d' ),
'opinion' => $opinion,
'status' => $status,
'nextStaff' => $nextStaff
);
// print_r($verifyStaff);
// echo $nowStaff;die;
} else { // 进入下一个角色或者审批人
// echo str_replace($this->staff[0]['sid'], '', $receiptDetail['nowStaff']);
//
$nowStaff = str_replace ( $this->staff [0] ['sid'], '', $receiptDetail ['nowStaff'] );
$verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
'date' => date ( 'Y-m-d' ),
'opinion' => $opinion,
'status' => $status,
'nextStaff' => $VS ['nextStaff'],
'ROLE' => 1
);
// print_r($verifyStaff);
// die;
}
if ($status == 3) {
$verifyStaff ['final'] = $status;
$verifyStaff [$this->staff [0] ['sid']] = array (
'date' => date ( 'Y-m-d' ),
'opinion' => $opinion,
'status' => $status
);
}
$vStaffString = json_encode ( $verifyStaff );
$receipt->verifyStaff = $vStaffString;
$receipt->nowStaff = $nowStaff;
}
// print_r($verifyStaff);die;
}
// print_r($verifyDetail);
$roleKey = 0;
$roleId = 0;
$verifyDetailCopy = array ();
foreach ( $verifyDetail as $k => $v ) {
if ($v [1] == 'ROLE') {
$roleId = $v [0];
$roleVerify = json_decode ( $v [3], true );
$roleKey = $k;
$roleArray = array ();
foreach ( $roleVerify as $o => $p ) {
$staffID = explode ( '_', $p );
$exp = array (
0 => $staffID [0],
1 => $staffID [1]
);
array_push ( $roleArray, $exp );
}
$verifyDetailCopy [$v [0]] = $roleArray;
}
}
// print_r($verifyDetail);
foreach ( $verifyDetailCopy as $k => $v ) {
foreach ( $verifyDetail as $m => $n ) {
if ($n [0] == $k) {
array_splice ( $verifyDetail, $m, 1, $v );
}
}
}
Doo::loadModel ( "receiptLog" );
$receiptLog = new receiptLog ();
// 审批日志
if (! isset ( $verifyStaff ['final'] )) {
if (! empty ( $roleId )) {
Doo::loadModel ( "role" );
$role = new role ();
$roleInfo = $role->getOne ( array (
'where' => 'rid=' . $roleId,
'asArray' => true
) );
$receiptLog->rolename = $roleInfo ['name'];
}
$receiptLog->username = $this->staff [0] ['username'];
$receiptLog->uid = $this->staff [0] ['sid'];
$receiptLog->date = date ( "Y-m-d" );
$receiptLog->opinion = $opinion;
$receiptLog->img = $this->staff [0] ['avatar'];
$receiptLog->status = 1;
$receiptLog->rid = $rid;
$receiptLog->insert ();
}
if (isset ( $verifyStaff ['final'] )) { // rDetail
$receipt->verifyBreakup = $verifyString;
$receipt->status = 3;
$receiptDetailObj->status = 3;
$receiptDetailObj->update ( array (
'where' => 'rid=' . $rid
) );
if (! empty ( $roleId )) {
Doo::loadModel ( "role" );
$role = new role ();
$roleInfo = $role->getOne ( array (
'where' => 'rid=' . $roleId,
'asArray' => true
) );
$receiptLog->rolename = $roleInfo ['name'];
}
$receiptLog->username = $this->staff [0] ['username'];
$receiptLog->uid = $this->staff [0] ['sid'];
$receiptLog->date = date ( "Y-m-d" );
$receiptLog->opinion = $opinion;
$receiptLog->img = $this->staff [0] ['avatar'];
$receiptLog->status = 3;
$receiptLog->rid = $rid;
$receiptLog->insert ();
// 微信企业号通知
// $this->setWXMsg ( $rid, 3 );
} elseif (count ( $verifyStaff ) == count ( $verifyDetail )) { // 要修改 角色的数量
$receipt->status = 1;
$reviseSum = 0;
$receipt->verifyBreakup = $verifyString;
$receiptDetailObj = new receiptDetail ();
$receiptDetailObj->status = 1;
$receiptDetailObj->pastDate = date ( "Y-m-d" );
$receiptDetailObj->update ( array (
'where' => 'rid=' . $rid
) );
$dateArray = explode ( "-", $receiptDetail ['date'] );
$dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
$stat = $statistics->getOne ( array (
'where' => 'staff=' . $receiptDetail ['staff'] . $dateCondition,
'asArray' => true
) );
if (empty ( $stat )) {
$statistics->date = $receiptDetail ['date'];
$statistics->cid = $receiptDetail ['cid']; // $this->staff[0]['cid'];
$statistics->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
$statistics->agPrice = $receiptDetail ['sum'];
$statistics->rePrice = $reviseSum;
$statistics->insert ();
} else {
$statistics->agPrice = $stat ['agPrice'] + $receiptDetail ['sum'];
$statistics->rePrice = $stat ['rePrice'] + $reviseSum;
$statistics->update ( array (
'where' => 'sid=' . $stat ['sid']
) );
}
$dateArray = explode ( "-", $receiptDetail ['date'] );
$dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
$accountItem = json_decode ( $receiptDetail ['accountItem'], true );
foreach ( $accountItem ['cSum'] as $key => $value ) {
if ($key == "trainSum") {
$iStatistics = $itemStatistics->getOne ( array (
'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->TRAIN . '"' . $dateCondition,
'asArray' => true
) );
if (empty ( $iStatistics )) {
$itemStatistics->cid = $receiptDetail ['cid'];
$itemStatistics->staff = $receiptDetail ['staff'];
$itemStatistics->price = $receiptDetail ['sum'];
$itemStatistics->itemCategory = $this->TRAIN;
$itemStatistics->date = $receiptDetail ['date'];
$itemStatistics->insert ();
} else {
if (! empty ( $value )) {
$itemStatistics->price = $receiptDetail ['sum'] + $iStatistics ['price'];
$itemStatistics->update ( array (
'where' => 'sid=' . $iStatistics ['sid']
) );
}
}
}
}
$receipt->pastDate = date ( "Y-m-d" );
// 微信企业号通知
// $this->setWXMsg ( $rid, 1 );
}
//汇款金额
$receipt->amount=$payment;
$receipt->update ( array (
'where' => ' rid = ' . $rid
) );
}
return "/approvalExpenses/pendApproval";
}
/**
* 培训班结算--撤回
*/
function receiptTrainApprovalBackDo() {
$ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : '';
$opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
if (! empty ( $ridKey )) {
Doo::loadClass ( 'XDeode' );
$XDeode = new XDeode ( 5 );
$rid = $XDeode->decode ( $ridKey );
// 操作记录
Doo::loadModel ( "receipt" );
$receipt = new receipt ();
Doo::loadModel ( "receiptLog" );
$receiptLog = new receiptLog ();
Doo::loadModel ( "verify" );
$verify = new verify ();
$receiptInfo = $receipt->getOne ( array (
'where' => 'rid=' . $rid . ' and status=2',
'asArray' => true
) );
if (empty ( $receiptInfo )) {
echo json_encode ( array (
'status' => 2
) );
die ();
}
$vr = $verify->getOne ( array (
'where' => 'vid=' . $receiptInfo ['verify'],
'asArray' => true
) );
$jd = json_decode ( $vr ['staff'] );
$roleId = 0;
foreach ( $jd as $key => $value ) {
if ($value [1] == 'ROLE') {
$pos = strpos ( $value [3], $this->staff [0] ['sid'] );
if ($pos !== false) {
$roleId = $value [0];
}
}
}
// 审批日志
// echo $roleId;die;
if (! empty ( $roleId )) {
Doo::loadModel ( "role" );
$role = new role ();
$roleInfo = $role->getOne ( array (
'where' => 'rid=' . $roleId,
'asArray' => true
) );
$receiptLog->rolename = $roleInfo ['name'];
}
$receiptLog->username = $this->staff [0] ['username'];
$receiptLog->uid = $this->staff [0] ['sid'];
$receiptLog->date = date ( "Y-m-d" );
$receiptLog->opinion = $opinion;
$receiptLog->img = $this->staff [0] ['avatar'];
$receiptLog->status = 4;
$receiptLog->rid = $rid;
$receiptLog->insert ();
$receipt->status = 4;
$receipt->update ( array (
'where' => 'rid=' . $rid
) );
// 微信企业号通知
$this->setWXMsg ( $rid, 2 );
echo json_encode ( array (
'status' => 1
) );
die ();
}
echo json_encode ( array (
'status' => 2
) );
die ();
}
function receiptTrainItemEdiDo(){
$ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
$riidKey = $this->get_args ( 'riidKey' ) ? $this->get_args ( 'riidKey' ) : "";
// 支出项信息
$item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
$price = $this->get_args ( 'price' ) ? $this->get_args ( 'price' ) : 0;
$date = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "";
$inputer = $this->get_args ( 'inputer' ) ? $this->get_args ( 'inputer' ) : "";
$describe = $this->get_args ( 'describe' ) ? $this->get_args ( 'describe' ) : "";
$payType = isset ( $this->params ['payType'] ) ? $this->params ['payType'] : '';
Doo::loadClass ( 'XDeode' );
$XDeode = new XDeode ( 5 );
$rid = $XDeode->decode ( $ridKey );
$riid = $XDeode->decode ( $riidKey );
if (! is_numeric ( $rid ) || ! is_numeric ( $riid )) {
die ( 'illegal request--id' );
}
Doo::loadModel ( 'receipt' );
$receipt = new receipt ();
Doo::loadModel ( 'RItem' );
$RItem = new RItem ();
Doo::loadModel ( 'receiptDetail' );
$rDetail = $receipt->getReceiptByRid ( $rid );
if (! ($rDetail ['status'] == 5 || $rDetail ['status'] == 4 || $rDetail ['status'] == 2)) {
die ( 'illegal request-status' );
}
$detail = $RItem->getRItemByRiid ( $riid );
if (empty ( $detail )) {
die ( 'illegal request-dataError' );
}
//创建人可以删除协助人
if(!($rDetail['staff']==$this->staff [0] ['sid'])){
if (! ($this->staff [0] ['sid'] == $detail ['createrId'] || $this->staff [0] ['username'] == $detail ['creater'])) {
die ( 'illegal request-sidError' );
}
}
if ( ! empty ( $item ) && is_numeric( $price ) && ! empty ( $date ) && ! empty ( $inputer )) {
//--------------------移除支出信息
$this->_receiptTrainItemDel($RItem, $rDetail, $riid, $rid, $detail, $receipt);
//---------------------添加支出信息
$receiptDetail = new receiptDetail ();
$receipt = new receipt ();
$RItem = new RItem ();
$order = array (
"\r\n",
"\n",
"\r"
);
$replace = '
';
$describe = str_replace ( $order, $replace, $describe );
$itemData = array (
'rid' => $rid,
'item' => $item,
'price' => $price,
'date' => $date,
'inputer' => $inputer,
'identifying'=>$detail['identifying'],
'describe' => $describe,
'creater' => $this->staff['0']['username'],
'createrId' => $this->staff['0']['sid'],
'creatDate' => date ( "Y-m-d H:i:s" )
);
if($payType=='company'){
$itemData += array (
'payType' => 1
);
}
$RItem->addRItem($itemData, $receipt, $receiptDetail, $rid, $item, $price, $payType);
$XDeode = new XDeode ( 7 );
if($payType=='company'){
return '/receiptTrainItem/approval/' . $XDeode->encode ( $rid ) . '.html';
}else{
return '/receiptTrainItemEdi/' . $XDeode->encode ( $rid ) . '.html';
}
}else
die ( 'illegal request-dataError' );
}
//移除培训班结算-支出列
private function _receiptTrainItemDel($RItem,$rDetail,$riid,$rid,$detail,$receipt){
$RItem->delete ( array (
'where' => 'riid=' . $riid
) );
// 更新费用合计金额
$rInfo = $receipt->getReceiptByRid ( $rid );
$receipt = new receipt ();
$receipt->sum = $rDetail ['sum'] - $detail ['price'];
$receipt->update ( array (
'where' => 'rid=' . $rid
) );
Doo::loadModel ( 'receiptDetail' );
$receiptDetail = new receiptDetail ();
$rdInfo = $receiptDetail->getReceiptDetailByRIC ( $rid, $detail ['item'], '培训班费用' );
$receiptDetail = new receiptDetail ();
$rdInfo ['price'] -= $detail ['price'];
$receiptDetail->price = $rdInfo ['price'];
$receiptDetail->update ( array (
'where' => 'rid=' . $rid . ' and item like "' . $detail ['item'] . '" and itemCategory like "培训班费用"'
) );
//汇总金额--提交审批之后有 支出项时 需要更新汇总
if($detail['payType']==1){
Doo::loadModel ( "statistics" );
$statistics = new statistics ();
$dateArray = explode ( "-", $rInfo ['date'] );
$dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
$stat = $statistics->getOne ( array (
'where' => 'staff=' . $rInfo ['staff'] . $dateCondition,
'asArray' => true
) );
if (!empty($stat)){
$statistics->rePrice = $stat ['rePrice'] - $detail['price'];
$statistics->update ( array (
'where' => 'sid=' . $stat ['sid']
) );
}
}
}
/**
* 移除培训班结算-支出列
*/
function receiptTrainItemDelDo() {
$riidKey = isset ( $this->params ['riidKey'] ) ? $this->params ['riidKey'] : '';
$ridKey = isset ( $this->params ['ridKey'] ) ? $this->params ['ridKey'] : '';
Doo::loadClass ( 'XDeode' );
$XDeode = new XDeode ( 5 );
$rid = $XDeode->decode ( $ridKey );
$riid = $XDeode->decode ( $riidKey );
if (! is_numeric ( $rid ) || ! is_numeric ( $riid )) {
die ( 'illegal request--id' );
}
Doo::loadModel ( 'receipt' );
$receipt = new receipt ();
Doo::loadModel ( 'RItem' );
$RItem = new RItem ();
$rDetail = $receipt->getReceiptByRid ( $rid );
if (! ($rDetail ['status'] == 5 || $rDetail ['status'] == 4 || $rDetail ['status'] == 2)) {
die ( 'illegal request-status' );
}
$detail = $RItem->getRItemByRiid ( $riid );
if (empty ( $detail )) {
die ( 'illegal request-dataError' );
}
if (! ($this->staff [0] ['sid'] == $detail ['createrId'] || $this->staff [0] ['username'] == $detail ['creater'])) {
die ( 'illegal request-sidError' );
}
$this->_receiptTrainItemDel($RItem, $rDetail, $riid, $rid, $detail, $receipt);
$XDeode = new XDeode ( 7 );
if ($rDetail ['status'] == 2) {
return '/receiptTrainItem/approval/' . $XDeode->encode ( $rid ) . '.html';
} else {
return '/receiptTrainItemEdi/' . $XDeode->encode ( $rid ) . '.html';
}
}
/**
* 生成对冲收款
*/
function invoiceReceivablesStrikeAddDo() {
$iidKey = $this->get_args ( 'iidKey' ) ? $this->get_args ( 'iidKey' ) : '';
$ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : '';
if (empty ( $iidKey ) || empty ( $ridKey )) {
die ( 'illegal request--idKey' );
}
Doo::loadClass ( 'XDeode' );
$XDeode = new XDeode ( 5 );
$XDeode7 = new XDeode ( 7 );
$iid = $XDeode->decode ( $iidKey );
$rid = $XDeode7->decode ( $ridKey );
Doo::loadModel ( 'invoiceReceivables' );
$invoiceReceivables = new invoiceReceivables ();
Doo::loadModel ( 'invoice' );
$invoice = new invoice ();
Doo::loadModel ( 'invoiceTraining' );
$invoiceTraining = new invoiceTraining ();
Doo::loadModel ( 'invoiceOperationLog' );
$invoiceOperationLog = new invoiceOperationLog ();
Doo::loadModel ( 'receipt' );
$receipt = new receipt ();
Doo::loadModel ( 'receiptTraining' );
$receiptTraining = new receiptTraining ();
$detail = $invoice->getInvoiceByIid ( $iid );
$invoiceTrainingDetail = $invoiceTraining->getInvoiceTrainingByItid ( $detail ['trainId'] );
$receiptDetail = $receipt->getReceiptByRid ( $rid );
$receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
if (empty ( $invoiceTrainingDetail ) || empty ( $detail ) || $detail ['untreadStatus'] == 3 || ! empty ( $detail ['irid'] )) {
die ( 'illegal request--trainId-status-irid' );
}
// 'receivablesCategory' => $this->staff [0] ['cid'] . ":" . $this->staff [0] ['category'],
// 'receivablesStaff' => $this->staff [0] ['sid'] . "-" . $this->staff [0] ['username'],
// 添加收款
$item = array (
'iid' => $detail ['iid'],
'bindStatus' => 1,
'bindPrice' => $detail ['invoicePrice'],
'inputStaff' => $this->staff [0] ['username'],
'source' => 2,
'bindDate' => date ( "Y-m-d" ),
'confirmTime' => date ( "Y-m-d H:i:s" ),
'receivablesPrice' => $detail ['invoicePrice'],
'OriginalPrice' => $detail ['invoicePrice'],
'receivablesMessage' => $receiptTrainingDetail ['trainName'] . '冲账',
'receivablesSerial' => "#SK" . date ( "Ymd" ) . mt_rand ( 1000, 9999 ),
'receivablesBank' => '财务录入',
'receivablesDate' => date ( "Y-m-d" ),
'inputStaff' => $this->staff [0] ['username'],
'date' => date ( "Y-m-d" ),
'receivablesCategory' => $detail ['cid'] . ":" . $detail ['categoryName'],
'receivablesStaff' => $detail ['sid'] . "-" . $detail ['userName']
);
$irid = $invoiceReceivables->addInvoiceReceivables ( $item );
// 更新发票绑定收款
$iridString = "";
if (empty ( $detail ['irid'] ))
$iridString = $irid;
else
$iridString = $detail ['irid'] . ',' . $irid;
$item = array (
'iid' => $detail ['iid'],
'irid' => $iridString,
'untreadStatus' => 3,
'bindTime' => date ( "Y-m-d H:i:s" )
);
$invoice->setInvoiceByCondition ( $item );
// 在是对冲收款 确保已收款不被删除
// Doo::loadModel ( 'RIExtend' );
// $RIExtend = new RIExtend ();
// 操作日志
$item = array (
'date' => date ( "Y-m-d H:i:s" ),
'operation' => "收款" . $invoiceTrainingDetail ['receivablesSerial'] . "入账到发票" . $detail ['invoiceSerial'],
'status' => 8,
'img' => $this->staff [0] ['avatar'],
'username' => $this->staff [0] ['username'],
'uid' => $this->staff [0] ['sid'],
'category' => $this->staff [0] ['category'],
'iid' => $detail ['iid']
);
$invoiceOperationLog->setInvoiceOperationLog ( $item );
// 是否加入统计--冲账不需要加入汇总
return '/receiptTrainInvoice/approval/' . $ridKey . '.html';
}
/**
* 培训班结算--执行
*/
function receiptTrainImplementDo() {
$ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : '';
$implementOpinions = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
if (! empty ( $ridKey )) {
Doo::loadModel ( 'receipt' );
$receipt = new receipt ();
Doo::loadModel ( 'wasteBook' );
$wasteBook = new wasteBook ();
Doo::loadClass ( 'XDeode' );
$XDeode = new XDeode ( 5 );
$rid = $XDeode->decode ( $ridKey );
$rinfo = $receipt->getReceiptByRid ( $rid );
if (empty ( $rinfo )) {
die ( 'illegal request--rid' );
}
$accountType = '';
if ($rinfo ['Rtype'] == 1) {
if ($rinfo ['loanRid'] != 0)
$accountType = 2;
else
$accountType = 1;
} elseif ($rinfo ['Rtype'] == 2) {
$accountType = 4;
} elseif ($rinfo ['Rtype'] == 0) {
$accountType = 3;
} elseif ($rinfo ['Rtype'] == 3) {
$accountType = 12;
}
if (empty ( $accountType ))
die ( 'illegal request' );
$executeCopy = json_decode ( $rinfo ['executeCopy'], true );
$executeStaff = json_decode ( $rinfo ['executeStaff'], true );
if (empty ( $executeStaff )) {
$executeStaff = array (
$this->staff [0] ['sid'] => array (
'date' => date ( 'Y-m-d' ),
'opinion' => $implementOpinions,
'status' => 1
)
);
} else {
$executeStaff [$this->staff [0] ['sid']] = array (
'date' => date ( 'Y-m-d' ),
'opinion' => $implementOpinions,
'status' => 1
);
}
if (count ( $executeStaff ) == count ( $executeCopy )) {
// 费用执行没有
$wbDetail = $wasteBook->getWateBookByAD ( $accountType, $rinfo ['rid'] );
if (empty ( $wbDetail )) {
die ( 'illegal request--wate' );
}
$receipt->executeStaff = json_encode ( $executeStaff );
$receipt->status = 8;
if ($rinfo ['Rtype'] == 1 && $rinfo ['isBK'] == 1 && $rinfo ['status'] == 1)
$receipt->status = 9;
if ($rinfo ['status'] == 6) {
$receipt->loanDate = date ( "Y-m-d" );
}
$receipt->executeDate = date ( "Y-m-d" );
} else {
$receipt->executeStaff = json_encode ( $executeStaff );
}
$receipt->update ( array (
'where' => 'rid=' . $rid
) );
return '/hisImplement/train';
}
die ( 'illegal request-dataError' );
}
/**
* 生成执行流水
*/
function receiptTrainImplementWateDo() {
$ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : '';
$bank = $this->get_args ( 'bank' ) ? $this->get_args ( 'bank' ) : "";
$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')
die ( 'illegal request--errorActionType' );
}
if (! empty ( $ridKey )) {
Doo::loadModel ( 'receipt' );
$receipt = new receipt ();
Doo::loadModel ( 'wasteBook' );
$wasteBook = new wasteBook ();
Doo::loadClass ( 'XDeode' );
$XDeode = new XDeode ( 5 );
$rid = $XDeode->decode ( $ridKey );
$rinfo = $receipt->getReceiptByRid ( $rid );
$amount=$rinfo['amount'];
if (empty ( $rinfo )) {
die ( 'illegal request--noData' );
}
$accountType = '';
if ($rinfo ['Rtype'] == 0) {
$accountType = 3;
$expensesType='EXPENDITURE';
} elseif ($rinfo ['Rtype'] == 1) {
if (! empty ( $rinfo ['accountItem'] )){
$accountType = 2;
if ($amount>=0){
$expensesType='EXPENDITURE';
}else{
$expensesType='INCOME';
}
}else{
$accountType = 1;
$expensesType='EXPENDITURE';
}
} elseif ($rinfo ['Rtype'] == 2) {
$accountType = 4;
$expensesType='EXPENDITURE';
} 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;
}
if (empty ( $accountType )) {
die ( 'illegal request--accountType' );
}
if (empty ( $bank ) || (! ($bank == 'CGBDeposit' || $bank == 'ICBCDeposit' || $bank == 'HUADeposit' || $bank == 'PersonalDeposit'))) {
die ( 'illegal request--Bank' );
}
if($accountType==12){
$receipt->amount = $amount;
$receipt->update ( array (
'where' => 'rid=' . $rid
) );
}
/*
// 更新借款汇款金额
if ($accountType == 1) {
Doo::loadModel ( 'loanReceipt' );
$loanReceipt = new loanReceipt ();
$loanReceipt->amount = $amount;
$loanReceipt->update ( array (
'where' => ' rid = ' . $rinfo ['loanRid']
) );
}
*/
//汇款金额正数
$amount=abs($amount);
// $accountType = 12;
$accountBank = $bank;
if ($expensesType == "INCOME") {
$expensesTypeWaste = 1;
$accountPriceShow = $accountPrice = $amount;
} elseif ($expensesType == "EXPENDITURE") {
$expensesTypeWaste = 2;
$accountPriceShow = $amount;
$accountPrice = - $amount;
} else {
die ( 'illegal request--expensesType' );
}
// 公司流水记录
$abDetail = $wasteBook->getAccountBookByAid ( $expensesTypeWaste, $accountType, $rid );
// 银行
if (empty ( $abDetail )) {
$item = array (
'dataID' => $rid,
'expensesType' => $expensesTypeWaste,
'accountType' => $accountType,
'accountPriceShow' => $accountPriceShow,
'accountPrice' => $accountPrice,
'accountBank' => $accountBank,
'category' => $rinfo ['category'] [0] ['title'],
'cid' => $rinfo ['category'] [0] ['cid'],
'name' => $rinfo ['staffDetail'] ['username'],
'sid' => $rinfo ['staffDetail'] ['sid'],
'inputDate' => $inputDate,
'remarks'=>$remarks
);
$wasteBook->setAccountBookStatistics ( $item );
}
}
if (empty ( $actionType )) {
$XDeode = new XDeode ( 7 );
return '/receiptTrain/implement/' . $XDeode->encode ( $rid ) . '.html?trainEdiType=COLLECT';
} elseif ($actionType == 'NOTRAIN') {
$XDeode = new XDeode ( 5 );
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";
}
}
}
/**
* 费用流水
*/
function receiptWasteBook() {
Doo::loadClass ( 'XDeode' );
$XDeode = new XDeode ( 5 );
Doo::loadModel ( 'receipt' );
$receipt = new receipt ();
$receiptList = $receipt->getReceiptByWaste ();
foreach ($receiptList as $key=>$value){
$receiptList[$key]['balance']='';
if($value['Rtype']==1){
$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']);
}
$data ['inputDate'] = date ( "Y-m-d H:i:s" );
$data ['receiptList'] = $receiptList;
$data ['memu'] = "receipt";
$data ['staff'] = $this->staff;
$data ['receiptMemu'] = 'receiptWasteBook';
$data ['verifyId'] = $this->verifyId;
$data ['executeId'] = $this->executeId;
$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 ( $trainLoanRid )) {
$receiptLoanList = $receipt->getReceiptInRid ( $trainLoanRid );
foreach ($receiptLoanList as $key=>$value){
$sum+=$value['sum'];
}
// $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;
}
/**
* 费用流水新增
*/
function receiptWasteBookAddDo() {
$ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
if (empty ( $ridKey )) {
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" );
$receivedPrice = $this->get_args ( 'receivedPrice' ) ? $this->get_args ( 'receivedPrice' ) : "";
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' );
}
} elseif ($expensesType == "EXPENDITURE") {
if(!is_numeric($expenditurePrice)){
die ( 'illegal request--expenditurePrice' );
}
}
*/
Doo::loadClass ( 'XDeode' );
$XDeode = new XDeode ( 5 );
$rid = $XDeode->decode ( $ridKey );
Doo::loadModel ( 'receipt' );
$receipt = new receipt ();
$detail = $receipt->getReceiptByRid ( $rid );
if (empty ( $detail )) {
die ( 'illegal request--noData' );
}
$amount=$detail['amount'];
$accountType = '';
/*
if ($detail ['Rtype'] == 1) {
if (! empty ( $detail ['accountItem'] ))
$accountType = 2;
else
$accountType = 1;
} elseif ($detail ['Rtype'] == 2) {
$accountType = 4;
} elseif ($detail ['Rtype'] == 0) {
$accountType = 3;
} 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 = '';
$inputDate = date ( "Y-m-d H:i:s" );
if ($expensesType == "INCOME") {
$expensesTypeWaste = 1;
$accountPriceShow = $receivedPrice;
$accountPrice = $receivedPrice;
$accountBank = $receivedBank;
$inputDate = $receivedInputDate;
} elseif ($expensesType == "EXPENDITURE") {
$expensesTypeWaste = 2;
$accountPriceShow = $expenditurePrice;
$accountPrice = - $expenditurePrice;
$accountBank = $expenditureBank;
$inputDate = $expenditureInputDate;
} else {
die ( 'illegal request--expensesType' );
}
*/
$receipt = new receipt ();
$receipt->amount = $accountPrice;
$receipt->update ( array (
'where' => 'rid=' . $rid
) );
// 更新借款汇款金额
if ($accountType == 1) {
Doo::loadModel ( 'loanReceipt' );
$loanReceipt = new loanReceipt ();
$loanReceipt->amount = $accountPrice;
$loanReceipt->update ( array (
'where' => ' rid = ' . $detail ['loanRid']
));
}
// 公司流水记录
Doo::loadModel ( 'wasteBook' );
$wasteBook = new wasteBook ();
$abDetail = $wasteBook->getAccountBookByAid ( $expensesTypeWaste, $accountType, $rid );
// 银行
if (empty ( $abDetail )) {
$item = array (
'dataID' => $rid,
'expensesType' => $expensesTypeWaste,
'accountType' => $accountType,
'accountPriceShow' => $accountPriceShow,
'accountPrice' => $accountPrice,
'accountBank' => $accountBank,
'category' => $detail ['category'] [0] ['title'],
'cid' => $detail ['category'] [0] ['cid'],
'name' => $detail ['staffDetail'] ['username'],
'sid' => $detail ['staffDetail'] ['sid'],
'inputDate' => $inputDate
);
$wasteBook->setAccountBookStatistics ( $item );
}
return '/receiptWasteBook';
}
/**
* 培训班结算营收总计
*/
function receiptTrainRevenue(){
//include Doo::conf ()->BASE_PATH . 'diagnostic/debug.php';
Doo::loadModel ( 'receipt' );
$receipt = new receipt ();
//获得可查看的办事处
Doo::loadModel ( "receiptTrainManage" );
$invoiceCategoryManage = new receiptTrainManage ();
$imcStaff = $invoiceCategoryManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
if(empty($imcStaff)){
die ( 'illegal request--Insufficient Permissions' );
}
$cidList = array ();
foreach ( $imcStaff as $key => $value ) {
array_push ( $cidList, $value ['cid'] );
}
$cidString=implode ( ',', $cidList );
//初始化收款数据
$where=" where a.status not in (3,4,5) and a.Rtype=3 and a.trainId!=0 and paidStatus=0 and invoiceTrainId!=0 ";
$sql="select invoiceTrainId,rid
from CLD_receipt as a
".$where." and a.cid in (".$cidString.") ";
$receipt->initReceiptTrainRevenue($sql);
$unpaid=$receipt->getReceiptTrainByPaid(0,5,$cidString);
$paid=$receipt->getReceiptTrainByPaid(1,5,$cidString);
$MonthPriceList=$receipt->getReceiptTrainByYearChart($cidString);
$income=$month=$pay=$profit=array();
for ($i=1;$i<=12;$i++){
$flag=true;
array_push($month,date("Y").'-'.$i);
foreach ($MonthPriceList as $key=>$value){
if($key==$i){
$flag=false;
array_push($income,$value['ITprice']);
array_push($pay,$value['RIprice']);
array_push($profit,$value['ITprice']-$value['RIprice']);
}
}
if ($flag){
array_push($income,0);
array_push($pay,0);
array_push($profit,0);
}
}
$data ['income'] =json_encode ( $income );
$data ['pay'] =json_encode ( $pay );
$data ['profit'] =json_encode ( $profit );
$data ['month'] =json_encode ( $month );
$data ['paid'] = $paid;
$data ['unpaid'] = $unpaid;
$data ['memu'] = "receipt";
$data ['staff'] = $this->staff;
//var_dump( $this->executeId) ;
//die;
$data ['receiptMemu'] = 'receiptTrainRevenue';
$data ['verifyId'] = $this->verifyId;
$data ['executeId'] = $this->executeId;
$this->render ( "/receipt/receiptTrainRevenue", $data );
}
/**
* 所有培训班结算
*/
function receiptTrainRevenueAchieve(){
//$paid = $this->get_args ( 'paid' ) ? $this->get_args ( 'paid' ) : '';
$paid =isset ( $this->params ['paid'] ) ? $this->params ['paid'] : 'ALL';
$cidKey = $this->get_args ( 'cidKey' ) ? $this->get_args ( 'cidKey' ) : '';
$page_size = 12;
$page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
$trainEndDate = $this->get_args ( 'trainEndDate' ) ? $this->get_args ( 'trainEndDate' ) : "";
$get='/'.$paid ;//= "?date=" . urlencode ( $date ) . "&MebSea=" . urlencode ( $MebSea );
Doo::loadModel ( 'receipt' );
$receipt = new receipt ();
Doo::loadModel ( 'L_category' );
$Lcategory = new L_category ();
Doo::loadClass ( 'XDeode' );
$XDeode = new XDeode ( 5 );
$cidSql=$cid='';
if(!empty($cidKey)){
$cid = $XDeode->decode ( $cidKey );
$cidSql=" and a.cid=".$cid." ";
}
//获得可查看的办事处
Doo::loadModel ( "receiptTrainManage" );
$invoiceCategoryManage = new receiptTrainManage ();
$imcStaff = $invoiceCategoryManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
$cidList = array ();
foreach ( $imcStaff as $key => $value ) {
array_push ( $cidList, $value ['cid'] );
}
if(!empty($cid)&&!in_array($cid, $cidList)){
die("illegal request-cid");
}
$cidString=implode ( ',', $cidList );
$categoryList = $Lcategory->getCategoryInCid ( $cidString );
$psSql='';$paidKey='';
if(!empty($paid)&&$paid!="ALL"){
if ($paid=='UNPAID'){
$paidKey='0';
}elseif($paid=='PAID'){
$paidKey='1';
}
$psSql=" and a.paidStatus=".$paidKey." ";
}
$dateArr = explode ( ':', $trainEndDate );
$D1 = $dateString = '';
$D2 = '';
if (! empty ( $trainEndDate )) {
$D1 = $dateArr [0];
if (isset ( $dateArr [1] ))
$D2 = $dateArr [1];
else
$D2 = '';
$dateString = $D1 . ":" . $D2;
}
$dateSql='';
if (! empty ( $D1 ) && ! empty ( $D2 )){
$dateSql = ' and trainEndDate BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
}elseif (! empty ( $D1 ) && empty ( $D2 )){
$dateSql = ' and trainEndDate like "%' . $D1 . '%" ';
}
$selectCount=" count(*) as count ";
$where=" where a.status not in (3,4,5) and a.Rtype=3 and a.trainId!=0 and invoiceTrainId!=0 ".$psSql;
$sql = "select ".$selectCount."
from CLD_receipt as a left JOIN CLD_receiptTraining as b on (a.trainId=b.rtid)
".$where." and a.cid in (".$cidString.") ".$cidSql.$dateSql;
$action="receiptTrainRevenueAchieve";
$pageinfo = $this->get_page ( $sql, $page, $page_size, $action, $get, "" );
$limit = $pageinfo ['lower'] . ',' . $page_size;
$rtpa=$receipt->getReceiptTrainByPaidAll($paidKey,$cid,$dateSql,$limit,$cidString,$where);
//金额合计功能
$sql="select invoiceTrainId,rid
from CLD_receipt as a
".$where." and a.cid in (".$cidString.") ";
$receiptTrainPriceList=$receipt->getReceiptTrainSumByItid($sql);
$data ['receiptTrainPriceList']=$receiptTrainPriceList;
$data ['dateString']=$dateString;
$data ['cidKey']=$cidKey;
$data ['categoryList'] =$categoryList;
$data ['paid'] = $paid;
$data ['get'] = $get;
$data ['page'] = $pageinfo;
$data ['onpage'] = $page;
$data ['rtpa'] = $rtpa;
$data ['memu'] = "receipt";
$data ['staff'] = $this->staff;
$data ['receiptMemu'] = 'receiptTrainRevenue';
$data ['verifyId'] = $this->verifyId;
$data ['executeId'] = $this->executeId;
$this->render ( "/receipt/receiptTrainRevenueAchieve", $data );
}
/*
* 全年办事处汇总明细
*/
function receiptSummaryStatisticsByAgency(){
$cidIn = $this->get_args ( 'cidIn' ) ? $this->get_args ( 'cidIn' ) : '12,10,9';
$year=2019; //= $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date('Y');
$sectionHtml=$sectionItemHtml='';
if(!empty($cidIn)){
Doo::loadModel ( 'receiptDetail' );
$receiptDetail = new receiptDetail ();
Doo::loadModel ( 'accountItem' );
$accountItem = new accountItem ();
Doo::loadModel ( 'L_category' );
$category = new L_category ();
$aiList=$accountItem->getCategory();
$aiAllList=$accountItem->getAccountItem();
$list=$receiptDetail->getReceiptDetailByYear($cidIn,$year);
$cidArray=explode(',', $cidIn);
$dataSummary=array();
foreach ($cidArray as $cak=>$cav){
$dataSummary[$cav]=array();
for($month=1;$month<=12;$month++){
foreach ($aiList as $aik=>$aiv){
$dataSummary[$cav][$month][$aiv['category']]=array();
}
$dataSummary[$cav][$month]['报销金额调整']=array();
}
}
foreach ($list as $key=>$value){
array_push($dataSummary[$value['cid']][$value['month']][$value['itemCategory']], $value);
}
//print_r($dataSummary);die;
Doo::loadClass ( 'receipt.func' );
//构建数据html
$cglist=$category->getCategoryInCid($cidIn);
$summaryDateHtml=_getReceiptSummaryHtml($cglist,$aiAllList,$dataSummary,$year);
//构建栏目展示Html
foreach ($aiAllList as $key=>$value){
//栏目
$sectionCount=count($value)+1;
$sectionHtml.=''.$key.' | ';
//栏目细则
$sectionItemHtml.='合计 | ';
foreach ($value as $k=>$v){
$sectionItemHtml.=''.$v['name'].' | ';
}
}
}
//办事处显示设置
$categoryList=$category->getCategory();
$selectedSummary=file_get_contents("protected/config/receipt/summary.conf.ini");
$selectedSummary=explode(',', $selectedSummary);
foreach ($categoryList as $key=>$value){
$categoryList[$key]['checked']='';
foreach ($selectedSummary as $v){
if($value['cidKey']==$v){
$categoryList[$key]['checked']='checked';
break;
}
}
}
//年份展示
Doo::loadClass ( 'date.func' );
$dateHtml=_getDateHtml($year);
$summarData=json_encode($dataSummary);
$data['summarData']=$summarData;
$data['categoryList']=$categoryList;
$data['dateHtml']=$dateHtml;
$data['sectionHtml']=$sectionHtml;
$data['sectionItemHtml']=$sectionItemHtml;
$data['summaryDateHtml']=$summaryDateHtml;
$data ['memu'] = "receipt";
$data ['staff'] = $this->staff;
$data ['receiptMemu'] = 'receiptTrainRevenue';
$data ['verifyId'] = $this->verifyId;
$data ['executeId'] = $this->executeId;
$this->render ( "/receipt/receiptSummaryStatisticsByAgency", $data );
}
//设置办事处展示明细
function setSummaryCategory(){
$cidKey= $this->get_args ( 'cidKey' ) ? $this->get_args ( 'cidKey' ) : "";
$cidKey=implode(',', $cidKey);
file_put_contents ( "protected/config/receipt/summary.conf.ini", $cidKey);
return '/receiptSummaryStatisticsByAgency';
}
//导出excel
function exportReceiptSummaryExcel(){
$summaryData= $this->get_args ( 'summaryData' ) ? $this->get_args ( 'summaryData' ) : "";
if(!empty($summaryData)){
print_r($summaryData);
}
die ( 'illegal request--excel Data null' );
}
function exportReceiptTrainExcel() {
$rtidKey = $this->get_args ( 'rtidKey' ) ? $this->get_args ( 'rtidKey' ) : "";
$ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
$summaryJson = $this->get_args ( 'summaryJson' ) ? $this->get_args ( 'summaryJson' ) : "";
$aiListJson = $this->get_args ( 'aiListJson' ) ? $this->get_args ( 'aiListJson' ) : "";
Doo::loadClass ( 'XDeode' );
$XDeode = new XDeode ( 7 );
$rid = $XDeode->decode ( $ridKey );
if (! is_numeric ( $rid ))
die ( 'illegal request' );
Doo::loadModel ( 'receipt' );
$receipt = new receipt ();
Doo::loadModel ( 'receiptTraining' );
$receiptTraining = new receiptTraining ();
$receiptDetail = $receipt->getReceiptByRid ( $rid );
$receiptTrainDetail = $receiptTraining->getReceiptTrainingByRtid ( $rtidKey );
$summary=json_decode(urldecode($summaryJson), true);
$aiList=json_decode(urldecode($aiListJson), true);
//借款相关
$receiptLoanDetail=array();
if (! empty ( $receiptDetail ['trainLoanRid'] )) {
$receiptLoanDetail = $receipt->getReceiptInRid ( $receiptDetail ['trainLoanRid'] );
}
//收入
Doo::loadModel ( 'invoice' );
$invoice = new invoice ();
Doo::loadModel ( 'invoiceTraining' );
$invoiceTraining = new invoiceTraining ();
$invoiceList = $invoice->getInvoicePrintedByItid ( $receiptDetail ['invoiceTrainId'] );
$invoiceTrainingDetail = $invoiceTraining->getInvoiceTrainingByItid ( $receiptDetail ['invoiceTrainId'] );
//支出
Doo::loadModel ( 'RItem' );
$RItem = new RItem ();
$RItemList = $RItem->getRItemByRid ( $rid );
//讲师
Doo::loadModel ( 'RILecturer' );
$RILecturer = new RILecturer ();
$RILecturerList = $RILecturer->getRILecturerByRid ( $rid );
Doo::loadClass ( 'receipt.func' );
excelData ( $receiptTrainDetail, $receiptDetail, $summary, $aiList,$receiptLoanDetail,$invoiceList,$RItemList,$RILecturerList,$invoiceTrainingDetail );
}
/**
* 获得审批流程
*/
private function fnGetReceiptApprovalProcess($verifyList = array(), $verifyStaff = array()) {
Doo::loadModel ( 'role' );
$role = new role ();
Doo::loadModel ( 'staff' );
$staff = new staff ();
$flag = true;
$roleKey = $button = 0;
$endStaffArray = array ();
$roleArrayCopy = array ();
foreach ( $verifyList as $k => $v ) {
if ($v [1] == 'ROLE') {
if (! empty ( $verifyStaff )) {
$endStaffArray = end ( $verifyStaff );
if ($v [0] == $endStaffArray ['nextStaff']) {
$roleId = $v [0];
}
}
$roleVerify = json_decode ( $v [3], true );
$roleKey = $k;
$roleArray = array ();
$rolename = $role->getOne ( array (
'where' => 'rid=' . $v [0],
'asArray' => true
) );
foreach ( $roleVerify as $o => $p ) {
$staffID = explode ( '_', $p );
$staffInfo = $staff->getOne ( array (
'where' => 'sid=' . $staffID [0],
'asArray' => true
) );
// print_r($staffID);
$exp = array (
0 => $staffInfo ['sid'],
1 => $staffID [1],
2 => $staffInfo ['avatar'],
'date' => '',
'date' => '',
'opinion' => '',
'status' => '',
'rolename' => $rolename ['name']
);
array_push ( $roleArray, $exp );
}
$roleArrayCopy [$v [0]] = $roleArray;
// $verifyList[$k]['roleArray']=$roleArray;
}
// print_r($roleArray);
$verifyList [$k] ['date'] = "";
$verifyList [$k] ['opinion'] = "";
$verifyList [$k] ['status'] = "";
if (empty ( $verifyStaff )) {
$verifyList [$k] ['date'] = "";
$verifyList [$k] ['opinion'] = "";
if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
$verifyList [$k] ['status'] = 4;
$button = 4;
$flag = false;
}
} else {
foreach ( $verifyStaff as $m => $u ) {
if ($v [0] == $m) {
$verifyList [$k] ['date'] = $u ['date'];
$verifyList [$k] ['opinion'] = $u ['opinion'];
$verifyList [$k] ['status'] = $u ['status'];
$flag = false;
break;
}
}
$endStaffArray = end ( $verifyStaff );
if (isset ( $endStaffArray ['ROLE'] )) {
} else {
$endKey = key ( $verifyStaff );
if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
$button = 4;
$verifyList [$k] ['status'] = 4;
}
}
}
}
$rolename ['name'] = '';
if (! empty ( $roleId )) {
Doo::loadModel ( 'role' );
$role = new role ();
$rolename = $role->getOne ( array (
'where' => 'rid=' . $roleId,
'asArray' => true
) );
}
if (! empty ( $verifyStaff ))
$endStaffArray = end ( $verifyStaff );
$KOP = false;
foreach ( $roleArrayCopy as $P => $A ) {
foreach ( $A as $MKI => $AVL ) {
if (! empty ( $verifyStaff )) {
// &&$rolename['rid']==$endStaffArray['nextStaff']
if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
$button = 4;
$roleArrayCopy [$P] [$MKI] ['status'] = 4;
}
foreach ( $verifyStaff as $m => $u ) {
$AVLFK = $AVL [0] . '_R';
// echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '
';
if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
$roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
$roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
$roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
break;
}
}
} else {
if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
$button = 4;
$roleArrayCopy [$P] [$MKI] ['status'] = 4;
}
}
// $roleArray[$MKI]['rolename']=$rolename['name'];
$KOP = true;
}
}
foreach ( $roleArrayCopy as $k => $v ) {
foreach ( $verifyList as $m => $n ) {
if ($n [0] == $k) {
array_splice ( $verifyList, $m, 1, $v );
}
}
}
return array (
'verifyList' => $verifyList,
'isApproval' => $button
);
}
function _GetFileEXT($filename) {
$pics = explode ( '.', $filename );
$num = count ( $pics );
return $pics [$num - 1];
}
/**
* 获取get或者POST值
* @param string $name 属性名称
* @return fixed 值
*/
function get_args($name) {
if (isset ( $_GET [$name] )) {
if (is_array ( $_GET [$name] ))
return $_GET [$name];
else
return addslashes ( $_GET [$name] );
} elseif (isset ( $_POST [$name] )) {
if (is_array ( $_POST [$name] ))
return $_POST [$name];
else
return addslashes ( $_POST [$name] );
} else
return false;
}
function num_to_rmb($num) {
$c1 = "零壹贰叁肆伍陆柒捌玖";
$c2 = "分角元拾佰仟万拾佰仟亿";
// 精确到分后面就不要了,所以只留两个小数位
$num = round ( $num, 2 );
// 将数字转化为整数
$num = $num * 100;
if (strlen ( $num ) > 10) {
return "金额太大,请检查";
}
$i = 0;
$c = "";
while ( 1 ) {
if ($i == 0) {
// 获取最后一位数字
$n = substr ( $num, strlen ( $num ) - 1, 1 );
} else {
$n = $num % 10;
}
// 每次将最后一位数字转化为中文
$p1 = substr ( $c1, 3 * $n, 3 );
$p2 = substr ( $c2, 3 * $i, 3 );
if ($n != '0' || ($n == '0' && ($p2 == '亿' || $p2 == '万' || $p2 == '元'))) {
$c = $p1 . $p2 . $c;
} else {
$c = $p1 . $c;
}
$i = $i + 1;
// 去掉数字最后一位了
$num = $num / 10;
// echo $num.'';
$num = ( int ) $num;
// $num =floor($num);
// $num = round ( $num, 0, PHP_ROUND_HALF_DOWN );
// echo $num.'';
// 结束循环
if ($num == 0) {
break;
}
}
// echo $c.'';
$j = 0;
$slen = strlen ( $c );
while ( $j < $slen ) {
// utf8一个汉字相当3个字符
$m = substr ( $c, $j, 6 );
// 处理数字中很多0的情况,每次循环去掉一个汉字“零”
if ($m == '零元' || $m == '零万' || $m == '零亿' || $m == '零零') {
$left = substr ( $c, 0, $j );
$right = substr ( $c, $j + 3 );
$c = $left . $right;
$j = $j - 3;
$slen = $slen - 3;
}
$j = $j + 3;
}
// 这个是为了去掉类似23.0中最后一个“零”字
if (substr ( $c, strlen ( $c ) - 3, 3 ) == '零') {
$c = substr ( $c, 0, strlen ( $c ) - 3 );
}
// 将处理的汉字加上“整”
if (empty ( $c )) {
return "零元整";
} else {
return $c . "整";
}
}
/**
* 获得分页数据
* @param unknown_type $table
* @param unknown_type $condition
* @param unknown_type $on_page
* @param unknown_type $page_size
*/
function get_page($sql = "", $on_page = 1, $page_size = 20, $action = "", $get = "", $other = "page") {
$page_c = "";
$page ['previous'] = $this->get_previous ( $on_page );
$page ['on_page'] = $on_page;
$total_count = $this->get_table_count ( $sql );
$total = intval ( $total_count / $page_size );
$page ['total_page'] = ($total_count % $page_size) == 0 ? $total : $total + 1;
$page ['total_data'] = $total_count;
$page ['next'] = $on_page == $page ['total_page'] ? $page ['total_page'] : $on_page + 1;
$i = 1;
$page_max = 1;
$page_width = 3;
if ($on_page >= $page_width) {
$page_max = intval ( $on_page / $page_width ) + 1;
$i = intval ( $on_page / $page_width ) * $page_width - 1;
}
for(; $i <= $page ['total_page']; $i ++) {
if ($i == $on_page)
$page_c .= '' . $i . '';
else
$page_c .= '' . $i . '';
if ($i == ($page_width * $page_max))
break;
}
$page ['page'] = $page_c;
$page ['lower'] = (-- $on_page) * $page_size;
return $page;
}
/**
* 获取总页数
* @param unknown_type $table
* @param unknown_type $condition
*/
public function get_table_count($sql="") {
// $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
$query = Doo::db ()->query ( $sql );
$result = $query->fetch ();
return $result ['count'];
}
/**
* 获取上一页
* @param unknown_type $on_page
*/
function get_previous($on_page = 1) {
return $on_page != 0 ? $on_page - 1 : $on_page;
}
}
?>