|  | @@ -90,7 +90,7 @@ class InvoiceExtendController extends DooController {
 | 
												
													
														
															|  |  		$detail = $staff->getStaffBySid ( $_COOKIE ["staff"] );
 |  |  		$detail = $staff->getStaffBySid ( $_COOKIE ["staff"] );
 | 
												
													
														
															|  |  		
 |  |  		
 | 
												
													
														
															|  |  		$accessModular = 'INVOICEEXTEND';
 |  |  		$accessModular = 'INVOICEEXTEND';
 | 
												
													
														
															|  | -		$accessAuthority='INVOICE';
 |  | 
 | 
												
													
														
															|  | 
 |  | +		$accessAuthority = 'INVOICE';
 | 
												
													
														
															|  |  		if (empty ( $detail ['cldAccessArray'] ))
 |  |  		if (empty ( $detail ['cldAccessArray'] ))
 | 
												
													
														
															|  |  			die ( 'illegal request' );
 |  |  			die ( 'illegal request' );
 | 
												
													
														
															|  |  		else {
 |  |  		else {
 | 
												
											
												
													
														
															|  | @@ -156,22 +156,22 @@ class InvoiceExtendController extends DooController {
 | 
												
													
														
															|  |  			
 |  |  			
 | 
												
													
														
															|  |  			$iid = $XDeode->decode ( $iidKey );
 |  |  			$iid = $XDeode->decode ( $iidKey );
 | 
												
													
														
															|  |  			
 |  |  			
 | 
												
													
														
															|  | -			$invoiceDetail=$invoice->getInvoiceByIid($iid);
 |  | 
 | 
												
													
														
															|  | -			if(empty($invoiceDetail)){
 |  | 
 | 
												
													
														
															|  | 
 |  | +			$invoiceDetail = $invoice->getInvoiceByIid ( $iid );
 | 
												
													
														
															|  | 
 |  | +			if (empty ( $invoiceDetail )) {
 | 
												
													
														
															|  |  				die ( 'illegal request-invoiceData NULL' );
 |  |  				die ( 'illegal request-invoiceData NULL' );
 | 
												
													
														
															|  |  			}
 |  |  			}
 | 
												
													
														
															|  |  			$trainId = $XDeode->decode ( $trainId );
 |  |  			$trainId = $XDeode->decode ( $trainId );
 | 
												
													
														
															|  |  			
 |  |  			
 | 
												
													
														
															|  | -			$itDetail=$invoiceTraining->getInvoiceTrainingByItid($trainId);
 |  | 
 | 
												
													
														
															|  | 
 |  | +			$itDetail = $invoiceTraining->getInvoiceTrainingByItid ( $trainId );
 | 
												
													
														
															|  |  			
 |  |  			
 | 
												
													
														
															|  |  			$st = '';
 |  |  			$st = '';
 | 
												
													
														
															|  |  			if ($settlementType == 'SOFTWARE') {
 |  |  			if ($settlementType == 'SOFTWARE') {
 | 
												
													
														
															|  |  				$st = 0;
 |  |  				$st = 0;
 | 
												
													
														
															|  |  				$trainId = 0;
 |  |  				$trainId = 0;
 | 
												
													
														
															|  | -				$operation=' 结算方式 改 软件销售';
 |  | 
 | 
												
													
														
															|  | 
 |  | +				$operation = ' 结算方式 改 软件销售';
 | 
												
													
														
															|  |  			} elseif ($settlementType == 'TRAINING') {
 |  |  			} elseif ($settlementType == 'TRAINING') {
 | 
												
													
														
															|  |  				$st = 1;
 |  |  				$st = 1;
 | 
												
													
														
															|  | -				$operation=' 结算方式 改 '.$itDetail['trainName'];
 |  | 
 | 
												
													
														
															|  | 
 |  | +				$operation = ' 结算方式 改 ' . $itDetail ['trainName'];
 | 
												
													
														
															|  |  				if (empty ( $trainId ) && ! is_numeric ( $trainId )) {
 |  |  				if (empty ( $trainId ) && ! is_numeric ( $trainId )) {
 | 
												
													
														
															|  |  					die ( 'illegal request-trainingIdError' );
 |  |  					die ( 'illegal request-trainingIdError' );
 | 
												
													
														
															|  |  				}
 |  |  				}
 | 
												
											
												
													
														
															|  | @@ -179,33 +179,32 @@ class InvoiceExtendController extends DooController {
 | 
												
													
														
															|  |  				die ( 'illegal request-settlementError' );
 |  |  				die ( 'illegal request-settlementError' );
 | 
												
													
														
															|  |  			}
 |  |  			}
 | 
												
													
														
															|  |  			
 |  |  			
 | 
												
													
														
															|  | -			$invoice->settlementType=$st;
 |  | 
 | 
												
													
														
															|  | -			$invoice->trainId=$trainId;
 |  | 
 | 
												
													
														
															|  | 
 |  | +			$invoice->settlementType = $st;
 | 
												
													
														
															|  | 
 |  | +			$invoice->trainId = $trainId;
 | 
												
													
														
															|  |  			
 |  |  			
 | 
												
													
														
															|  | -			$invoice->update(array (
 |  | 
 | 
												
													
														
															|  | -				'where' => 'iid = ' . $iid 
 |  | 
 | 
												
													
														
															|  | -			));
 |  | 
 | 
												
													
														
															|  | 
 |  | +			$invoice->update ( array (
 | 
												
													
														
															|  | 
 |  | +					'where' => 'iid = ' . $iid 
 | 
												
													
														
															|  | 
 |  | +			) );
 | 
												
													
														
															|  |  			
 |  |  			
 | 
												
													
														
															|  |  			Doo::loadModel ( 'invoiceStore' );
 |  |  			Doo::loadModel ( 'invoiceStore' );
 | 
												
													
														
															|  |  			$invoiceStore = new invoiceStore ();
 |  |  			$invoiceStore = new invoiceStore ();
 | 
												
													
														
															|  |  			
 |  |  			
 | 
												
													
														
															|  | -			//重置结算方式的相关数据 
 |  | 
 | 
												
													
														
															|  | -			$isSuccess=$invoiceStore->delete ( array (
 |  | 
 | 
												
													
														
															|  | -				'where' => 'iid=' . $iid,
 |  | 
 | 
												
													
														
															|  | -				'limit' => 1 
 |  | 
 | 
												
													
														
															|  | 
 |  | +			// 重置结算方式的相关数据
 | 
												
													
														
															|  | 
 |  | +			$isSuccess = $invoiceStore->delete ( array (
 | 
												
													
														
															|  | 
 |  | +					'where' => 'iid=' . $iid,
 | 
												
													
														
															|  | 
 |  | +					'limit' => 1 
 | 
												
													
														
															|  |  			) );
 |  |  			) );
 | 
												
													
														
															|  |  			
 |  |  			
 | 
												
													
														
															|  | -// 			if($isSuccess){
 |  | 
 | 
												
													
														
															|  | -// 				$detailIT = $invoiceTraining->getInvoiceTrainingByItid ( $invoiceDetail['trainId'] );
 |  | 
 | 
												
													
														
															|  | -// 				if (!empty($detailIT)){
 |  | 
 | 
												
													
														
															|  | -// 				$item = array (
 |  | 
 | 
												
													
														
															|  | -// 						'itid' => $invoiceDetail['trainId'],
 |  | 
 | 
												
													
														
															|  | -// 						'invoiceTotal' => $detailIT ['invoiceTotal'] - 1,
 |  | 
 | 
												
													
														
															|  | -// 				);
 |  | 
 | 
												
													
														
															|  | -// 				$itid = $invoiceTraining->setInvoiceTrainByCondition ( $item );
 |  | 
 | 
												
													
														
															|  | -// 				}
 |  | 
 | 
												
													
														
															|  | -// 			}
 |  | 
 | 
												
													
														
															|  | -			
 |  | 
 | 
												
													
														
															|  | 
 |  | +			// if($isSuccess){
 | 
												
													
														
															|  | 
 |  | +			// $detailIT = $invoiceTraining->getInvoiceTrainingByItid ( $invoiceDetail['trainId'] );
 | 
												
													
														
															|  | 
 |  | +			// if (!empty($detailIT)){
 | 
												
													
														
															|  | 
 |  | +			// $item = array (
 | 
												
													
														
															|  | 
 |  | +			// 'itid' => $invoiceDetail['trainId'],
 | 
												
													
														
															|  | 
 |  | +			// 'invoiceTotal' => $detailIT ['invoiceTotal'] - 1,
 | 
												
													
														
															|  | 
 |  | +			// );
 | 
												
													
														
															|  | 
 |  | +			// $itid = $invoiceTraining->setInvoiceTrainByCondition ( $item );
 | 
												
													
														
															|  | 
 |  | +			// }
 | 
												
													
														
															|  | 
 |  | +			// }
 | 
												
													
														
															|  |  			
 |  |  			
 | 
												
													
														
															|  |  			// 如果是培训班结算 创建培训班发票到培训班备份中
 |  |  			// 如果是培训班结算 创建培训班发票到培训班备份中
 | 
												
													
														
															|  |  			if (! empty ( $st ) && $st == 1) {
 |  |  			if (! empty ( $st ) && $st == 1) {
 | 
												
											
												
													
														
															|  | @@ -214,19 +213,18 @@ class InvoiceExtendController extends DooController {
 | 
												
													
														
															|  |  						'isid' => $isid,
 |  |  						'isid' => $isid,
 | 
												
													
														
															|  |  						'ipSource' => 1,
 |  |  						'ipSource' => 1,
 | 
												
													
														
															|  |  						'apStatus' => 1,
 |  |  						'apStatus' => 1,
 | 
												
													
														
															|  | -						'iid' => $iid
 |  | 
 | 
												
													
														
															|  | 
 |  | +						'iid' => $iid 
 | 
												
													
														
															|  |  				);
 |  |  				);
 | 
												
													
														
															|  |  				$invoiceStore->setInvoiceStoreByCondition ( $itemIS );
 |  |  				$invoiceStore->setInvoiceStoreByCondition ( $itemIS );
 | 
												
													
														
															|  | -			
 |  | 
 | 
												
													
														
															|  | 
 |  | +				
 | 
												
													
														
															|  |  				// 更新培训班总数量
 |  |  				// 更新培训班总数量
 | 
												
													
														
															|  |  				$item = array (
 |  |  				$item = array (
 | 
												
													
														
															|  |  						'itid' => $trainId,
 |  |  						'itid' => $trainId,
 | 
												
													
														
															|  | -						'submitStatus' => 1
 |  | 
 | 
												
													
														
															|  | 
 |  | +						'submitStatus' => 1 
 | 
												
													
														
															|  |  				);
 |  |  				);
 | 
												
													
														
															|  |  				$itid = $invoiceTraining->setInvoiceTrainByCondition ( $item );
 |  |  				$itid = $invoiceTraining->setInvoiceTrainByCondition ( $item );
 | 
												
													
														
															|  |  			}
 |  |  			}
 | 
												
													
														
															|  |  			
 |  |  			
 | 
												
													
														
															|  | -			
 |  | 
 | 
												
													
														
															|  |  			Doo::loadModel ( 'invoiceOperationLog' );
 |  |  			Doo::loadModel ( 'invoiceOperationLog' );
 | 
												
													
														
															|  |  			$invoiceOperationLog = new invoiceOperationLog ();
 |  |  			$invoiceOperationLog = new invoiceOperationLog ();
 | 
												
													
														
															|  |  			
 |  |  			
 | 
												
											
												
													
														
															|  | @@ -246,359 +244,486 @@ class InvoiceExtendController extends DooController {
 | 
												
													
														
															|  |  		}
 |  |  		}
 | 
												
													
														
															|  |  		return "/invoiceApprovalAchieve";
 |  |  		return "/invoiceApprovalAchieve";
 | 
												
													
														
															|  |  	}
 |  |  	}
 | 
												
													
														
															|  | -
 |  | 
 | 
												
													
														
															|  | -	function invoiceUntreadAdd(){
 |  | 
 | 
												
													
														
															|  | -        session_start ();
 |  | 
 | 
												
													
														
															|  | -        Doo::loadClass ( 'XDeode' );
 |  | 
 | 
												
													
														
															|  | -        $XDeode = new XDeode ( 5 );
 |  | 
 | 
												
													
														
															|  | -
 |  | 
 | 
												
													
														
															|  | -        $iidKey = isset ( $this->params ['iidKey'] ) ? $this->params ['iidKey'] : "";
 |  | 
 | 
												
													
														
															|  | -        $iid = $XDeode->decode ( $iidKey );
 |  | 
 | 
												
													
														
															|  | -        if (! is_numeric ( $iid ))
 |  | 
 | 
												
													
														
															|  | -            die ( 'illegal request' );
 |  | 
 | 
												
													
														
															|  | -
 |  | 
 | 
												
													
														
															|  | -        Doo::loadModel ( 'invoice' );
 |  | 
 | 
												
													
														
															|  | -        $invoice = new invoice ();
 |  | 
 | 
												
													
														
															|  | -        Doo::loadModel ( 'invoiceOperationLog' );
 |  | 
 | 
												
													
														
															|  | -        $invoiceOperationLog = new invoiceOperationLog ();
 |  | 
 | 
												
													
														
															|  | -
 |  | 
 | 
												
													
														
															|  | -        $invoiceDetail = $invoice->getInvoiceByIid ( $iid );
 |  | 
 | 
												
													
														
															|  | -        $operation = $invoiceOperationLog->getInvoiceOperationByDropped ( $iid );
 |  | 
 | 
												
													
														
															|  | -        //获得继承发票金额合计
 |  | 
 | 
												
													
														
															|  | -        $restrictPrice=$invoiceDetail['invoicePrice'];
 |  | 
 | 
												
													
														
															|  | -        if (!empty($invoiceDetail['inheritIid'])){
 |  | 
 | 
												
													
														
															|  | -            $restrictList=$invoice->getInvoiceInIid($invoiceDetail['inheritIid']);
 |  | 
 | 
												
													
														
															|  | -            foreach ($restrictList as $key=>$value){
 |  | 
 | 
												
													
														
															|  | -                $restrictPrice-=$value['invoicePrice'];
 |  | 
 | 
												
													
														
															|  | -            }
 |  | 
 | 
												
													
														
															|  | -        }
 |  | 
 | 
												
													
														
															|  | -        if ($restrictPrice<0){
 |  | 
 | 
												
													
														
															|  | -            $restrictPrice=0;
 |  | 
 | 
												
													
														
															|  | -        }
 |  | 
 | 
												
													
														
															|  | -
 |  | 
 | 
												
													
														
															|  | -        $invoiceDetail ['mailItemsJson'] = json_decode ( $invoiceDetail ['mailItemsJson'], true );
 |  | 
 | 
												
													
														
															|  | -
 |  | 
 | 
												
													
														
															|  | -        $token = $this->set_token ();
 |  | 
 | 
												
													
														
															|  | -        $_SESSION ['token_' . $this->staff [0] ['sidKey']] = $token;
 |  | 
 | 
												
													
														
															|  | -        $this->data ['token'] = $token;
 |  | 
 | 
												
													
														
															|  | -
 |  | 
 | 
												
													
														
															|  | -        $this->data ['restrictPrice'] = floatval($restrictPrice);
 |  | 
 | 
												
													
														
															|  | -        $this->data ['operation'] = $operation;
 |  | 
 | 
												
													
														
															|  | -        $this->data ['invoiceDetail'] = $invoiceDetail;
 |  | 
 | 
												
													
														
															|  | -        $this->data ['memu'] = "invoice";
 |  | 
 | 
												
													
														
															|  | -        $this->data ['staff'] = $this->staff;
 |  | 
 | 
												
													
														
															|  | -        $this->data ['receiptMemu'] = 'invoice';
 |  | 
 | 
												
													
														
															|  | -        $this->render ( "/invoice/invoiceUntreadAdd", $this->data );
 |  | 
 | 
												
													
														
															|  | -    }
 |  | 
 | 
												
													
														
															|  | -
 |  | 
 | 
												
													
														
															|  | -    function invoiceUntreadAddDo(){
 |  | 
 | 
												
													
														
															|  | -
 |  | 
 | 
												
													
														
															|  | -        $iidKey = $this->get_args ( 'iidKey' ) ? $this->get_args ( 'iidKey' ) : "";
 |  | 
 | 
												
													
														
															|  | -        Doo::loadModel ( 'invoice' );
 |  | 
 | 
												
													
														
															|  | -        $invoice = new invoice ();
 |  | 
 | 
												
													
														
															|  | -        $iid = $invoice->authcode ( $iidKey );
 |  | 
 | 
												
													
														
															|  | -        if (! empty ( $iid ) && ! is_numeric ( $iid ))
 |  | 
 | 
												
													
														
															|  | -            die ( 'illegal request' );
 |  | 
 | 
												
													
														
															|  | -
 |  | 
 | 
												
													
														
															|  | -        $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
 |  | 
 | 
												
													
														
															|  | -        $invoiceType = $this->get_args ( 'invoiceType' ) && is_numeric ( $this->get_args ( 'invoiceType' ) ) ? $this->get_args ( 'invoiceType' ) : 0;
 |  | 
 | 
												
													
														
															|  | -        $doPost = $this->get_args ( 'doPost' ) && is_numeric ( $this->get_args ( 'doPost' ) ) ? $this->get_args ( 'doPost' ) : 0;
 |  | 
 | 
												
													
														
															|  | -        // $invoicePrice = $this->get_args ( 'invoicePrice' ) ? $this->get_args ( 'invoicePrice' ) : "";
 |  | 
 | 
												
													
														
															|  | -
 |  | 
 | 
												
													
														
															|  | -        $invoiceQuantity = $this->get_args ( 'invoiceQuantity' ) && is_numeric ( $this->get_args ( 'invoiceQuantity' ) ) ? $this->get_args ( 'invoiceQuantity' ) : 0;
 |  | 
 | 
												
													
														
															|  | -        $invoiceUnitPrice = $this->get_args ( 'invoiceUnitPrice' ) && is_numeric ( $this->get_args ( 'invoiceUnitPrice' ) ) ? $this->get_args ( 'invoiceUnitPrice' ) : 0;
 |  | 
 | 
												
													
														
															|  | -
 |  | 
 | 
												
													
														
															|  | -        $invoiceElement = $this->get_args ( 'invoiceElement' ) ? $this->get_args ( 'invoiceElement' ) : "";
 |  | 
 | 
												
													
														
															|  | -        $invoiceTitle = $this->get_args ( 'invoiceTitle' ) ? $this->get_args ( 'invoiceTitle' ) : "";
 |  | 
 | 
												
													
														
															|  | -        $invoiceCompany = $this->get_args ( 'invoiceCompany' ) ? $this->get_args ( 'invoiceCompany' ) : "";
 |  | 
 | 
												
													
														
															|  | -        $TIN = $this->get_args ( 'TIN' ) ? $this->get_args ( 'TIN' ) : "";
 |  | 
 | 
												
													
														
															|  | -        $address = $this->get_args ( 'address' ) ? $this->get_args ( 'address' ) : "";
 |  | 
 | 
												
													
														
															|  | -        $phone = $this->get_args ( 'phone' ) ? $this->get_args ( 'phone' ) : "";
 |  | 
 | 
												
													
														
															|  | -        $bank = $this->get_args ( 'bank' ) ? $this->get_args ( 'bank' ) : "";
 |  | 
 | 
												
													
														
															|  | -        $bankAccount = $this->get_args ( 'bankAccount' ) ? $this->get_args ( 'bankAccount' ) : "";
 |  | 
 | 
												
													
														
															|  | -        $recipients = $this->get_args ( 'recipients' ) ? $this->get_args ( 'recipients' ) : "";
 |  | 
 | 
												
													
														
															|  | -        $recipientsPhone = $this->get_args ( 'recipientsPhone' ) ? $this->get_args ( 'recipientsPhone' ) : "";
 |  | 
 | 
												
													
														
															|  | -        $recipientsAddress = $this->get_args ( 'recipientsAddress' ) ? $this->get_args ( 'recipientsAddress' ) : "";
 |  | 
 | 
												
													
														
															|  | -
 |  | 
 | 
												
													
														
															|  | -        $remark = $this->get_args ( 'remark' ) ? $this->get_args ( 'remark' ) : "";
 |  | 
 | 
												
													
														
															|  | -
 |  | 
 | 
												
													
														
															|  | -        $TINT = $this->get_args ( 'TINT' ) ? $this->get_args ( 'TINT' ) : "";
 |  | 
 | 
												
													
														
															|  | -        $addressT = $this->get_args ( 'addressT' ) ? $this->get_args ( 'addressT' ) : "";
 |  | 
 | 
												
													
														
															|  | -        $phoneT = $this->get_args ( 'phoneT' ) ? $this->get_args ( 'phoneT' ) : "";
 |  | 
 | 
												
													
														
															|  | -        $bankT = $this->get_args ( 'bankT' ) ? $this->get_args ( 'bankT' ) : "";
 |  | 
 | 
												
													
														
															|  | -        $bankAccountT = $this->get_args ( 'bankAccountT' ) ? $this->get_args ( 'bankAccountT' ) : "";
 |  | 
 | 
												
													
														
															|  | -
 |  | 
 | 
												
													
														
															|  | -        $softLock = $this->get_args ( 'softLock' ) ? $this->get_args ( 'softLock' ) : 0;
 |  | 
 | 
												
													
														
															|  | -        $softLockNum = $this->get_args ( 'softLockNum' ) ? $this->get_args ( 'softLockNum' ) : 0;
 |  | 
 | 
												
													
														
															|  | -        $contract = $this->get_args ( 'contract' ) ? $this->get_args ( 'contract' ) : 0;
 |  | 
 | 
												
													
														
															|  | -        $contractNum = $this->get_args ( 'contractNum' ) ? $this->get_args ( 'contractNum' ) : 0;
 |  | 
 | 
												
													
														
															|  | -        $instructions = $this->get_args ( 'instructions' ) ? $this->get_args ( 'instructions' ) : 0;
 |  | 
 | 
												
													
														
															|  | -        $instructionsNum = $this->get_args ( 'instructionsNum' ) ? $this->get_args ( 'instructionsNum' ) : 0;
 |  | 
 | 
												
													
														
															|  | -        $remittance = $this->get_args ( 'remittance' ) ? $this->get_args ( 'remittance' ) : 0;
 |  | 
 | 
												
													
														
															|  | -
 |  | 
 | 
												
													
														
															|  | -        $mailItems = $this->get_args ( 'mailItems' ) ? $this->get_args ( 'mailItems' ) : "";
 |  | 
 | 
												
													
														
															|  | -
 |  | 
 | 
												
													
														
															|  | -        $token = $this->get_args ( 'token' ) ? $this->get_args ( 'token' ) : "";
 |  | 
 | 
												
													
														
															|  | -        if (empty ( $token )) {
 |  | 
 | 
												
													
														
															|  | -            die ( 'illegal request-token' );
 |  | 
 | 
												
													
														
															|  | -        } else {
 |  | 
 | 
												
													
														
															|  | -            session_start ();
 |  | 
 | 
												
													
														
															|  | -            if ($_SESSION ['token_' . $this->staff [0] ['sidKey']] != $token) {
 |  | 
 | 
												
													
														
															|  | -                header ( 'Content-Type:text/html;charset=utf-8' );
 |  | 
 | 
												
													
														
															|  | -                die ( '请勿重复申请发票' );
 |  | 
 | 
												
													
														
															|  | -            } else {
 |  | 
 | 
												
													
														
															|  | -                $_SESSION ['token_' . $this->staff [0] ['sidKey']] = '';
 |  | 
 | 
												
													
														
															|  | -            }
 |  | 
 | 
												
													
														
															|  | -        }
 |  | 
 | 
												
													
														
															|  | -
 |  | 
 | 
												
													
														
															|  | -        $temporary = $invoiceQuantity * $invoiceUnitPrice;
 |  | 
 | 
												
													
														
															|  | -        if ($invoiceType == 1) {
 |  | 
 | 
												
													
														
															|  | -            if ($temporary > 10000) {
 |  | 
 | 
												
													
														
															|  | -                header ( 'Content-Type:text/html;charset=utf-8' );
 |  | 
 | 
												
													
														
															|  | -                die ( '专用发票总金额暂时不能超过10000.00(一万)元。' );
 |  | 
 | 
												
													
														
															|  | -                // die ( 'illegal request-Please priceError' );
 |  | 
 | 
												
													
														
															|  | -            }
 |  | 
 | 
												
													
														
															|  | -        }
 |  | 
 | 
												
													
														
															|  | -
 |  | 
 | 
												
													
														
															|  | -        if (empty ( $this->staff [0] ))
 |  | 
 | 
												
													
														
															|  | -            die ( 'illegal request-Please login' );
 |  | 
 | 
												
													
														
															|  | -
 |  | 
 | 
												
													
														
															|  | -        if (! empty ( $cid ) && ! empty ( $invoiceQuantity ) && ! empty ( $invoiceUnitPrice ) && ! empty ( $invoiceElement ) ) {
 |  | 
 | 
												
													
														
															|  | -
 |  | 
 | 
												
													
														
															|  | -            Doo::loadModel ( 'L_category' );
 |  | 
 | 
												
													
														
															|  | -            $lCategory = new L_category ();
 |  | 
 | 
												
													
														
															|  | -            Doo::loadModel ( 'invoiceManage' );
 |  | 
 | 
												
													
														
															|  | -            $invoiceManage = new invoiceManage ();
 |  | 
 | 
												
													
														
															|  | -            Doo::loadModel ( 'invoiceOperationLog' );
 |  | 
 | 
												
													
														
															|  | -            $invoiceOperationLog = new invoiceOperationLog ();
 |  | 
 | 
												
													
														
															|  | -
 |  | 
 | 
												
													
														
															|  | -            Doo::loadClass ( 'XDeode' );
 |  | 
 | 
												
													
														
															|  | -            $XDeode = new XDeode ( 5 );
 |  | 
 | 
												
													
														
															|  | -
 |  | 
 | 
												
													
														
															|  | -
 |  | 
 | 
												
													
														
															|  | -            $categoryDetil = $lCategory->getOne ( array (
 |  | 
 | 
												
													
														
															|  | -                'SELECT' => 'title',
 |  | 
 | 
												
													
														
															|  | -                'where' => 'cid=' . $cid,
 |  | 
 | 
												
													
														
															|  | -                'asArray' => true
 |  | 
 | 
												
													
														
															|  | -            ) );
 |  | 
 | 
												
													
														
															|  | -
 |  | 
 | 
												
													
														
															|  | -            $invoicePrice = $invoiceQuantity * $invoiceUnitPrice;
 |  | 
 | 
												
													
														
															|  | -
 |  | 
 | 
												
													
														
															|  | -            $invoiceManageList = $invoiceManage->getInvoiceByAll ();
 |  | 
 | 
												
													
														
															|  | -            $invoiceManageDetail = $invoiceManage->getInvoiceByMold ( "发票审批" );
 |  | 
 | 
												
													
														
															|  | -            // print_r(current($invoiceManageDetail ['staffList']));
 |  | 
 | 
												
													
														
															|  | -            // die;
 |  | 
 | 
												
													
														
															|  | -
 |  | 
 | 
												
													
														
															|  | -            $moldManage = array ();
 |  | 
 | 
												
													
														
															|  | -            foreach ( $invoiceManageList as $key => $value ) {
 |  | 
 | 
												
													
														
															|  | -                if ($value ['mold'] == '发票打印')
 |  | 
 | 
												
													
														
															|  | -                    $moldManage [$value ['mold']] = $value ['staffList'];
 |  | 
 | 
												
													
														
															|  | -                elseif ($value ['mold'] == '发票邮寄')
 |  | 
 | 
												
													
														
															|  | -                    $moldManage [$value ['mold']] = $value ['staffList'];
 |  | 
 | 
												
													
														
															|  | -                elseif ($value ['mold'] == '发票退票')
 |  | 
 | 
												
													
														
															|  | -                    $moldManage [$value ['mold']] = $value ['staffList'];
 |  | 
 | 
												
													
														
															|  | -            }
 |  | 
 | 
												
													
														
															|  | -
 |  | 
 | 
												
													
														
															|  | -            $pendingApprovalsSid = current ( $invoiceManageDetail ['staffList'] ) [0];
 |  | 
 | 
												
													
														
															|  | -
 |  | 
 | 
												
													
														
															|  | -            //培训班ID--新增关联-发票关系  发票IID关联
 |  | 
 | 
												
													
														
															|  | -            $invoice = new invoice ();
 |  | 
 | 
												
													
														
															|  | -            $invoiceDetail=$invoice->getInvoiceByIid($iid);
 |  | 
 | 
												
													
														
															|  | -            //退票后,重新开票金额的限制
 |  | 
 | 
												
													
														
															|  | -            $restrictPrice=$invoiceDetail['invoicePrice'];
 |  | 
 | 
												
													
														
															|  | -            if (!empty($invoiceDetail['inheritIid'])){
 |  | 
 | 
												
													
														
															|  | -                $restrictList=$invoice->getInvoiceInIid($invoiceDetail['inheritIid']);
 |  | 
 | 
												
													
														
															|  | -                foreach ($restrictList as $key=>$value){
 |  | 
 | 
												
													
														
															|  | -                    $restrictPrice-=$value['invoicePrice'];
 |  | 
 | 
												
													
														
															|  | -                }
 |  | 
 | 
												
													
														
															|  | -            }
 |  | 
 | 
												
													
														
															|  | -            if ($restrictPrice<0){
 |  | 
 | 
												
													
														
															|  | -                header ( 'Content-Type:text/html;charset=utf-8' );
 |  | 
 | 
												
													
														
															|  | -                die ( '开票金额超出原退票金额-0' );
 |  | 
 | 
												
													
														
															|  | -            }else{
 |  | 
 | 
												
													
														
															|  | -                if($restrictPrice<$temporary){
 |  | 
 | 
												
													
														
															|  | -                    header ( 'Content-Type:text/html;charset=utf-8' );
 |  | 
 | 
												
													
														
															|  | -                    die ( '开票金额超出原退票金额-1' );
 |  | 
 | 
												
													
														
															|  | -                }
 |  | 
 | 
												
													
														
															|  | -            }
 |  | 
 | 
												
													
														
															|  | -
 |  | 
 | 
												
													
														
															|  | -            $trainId=$invoiceDetail['trainId'];
 |  | 
 | 
												
													
														
															|  | -            $st = 1;
 |  | 
 | 
												
													
														
															|  | -            if (empty ( $trainId ) && ! is_numeric ( $trainId )) {
 |  | 
 | 
												
													
														
															|  | -                die ( 'illegal request-trainingIdError' );
 |  | 
 | 
												
													
														
															|  | -            }
 |  | 
 | 
												
													
														
															|  | -
 |  | 
 | 
												
													
														
															|  | -            $invoice = new invoice ();
 |  | 
 | 
												
													
														
															|  | -            $item = array (
 |  | 
 | 
												
													
														
															|  | -                'cid' => $cid,
 |  | 
 | 
												
													
														
															|  | -                'categoryName' => $categoryDetil ['title'],
 |  | 
 | 
												
													
														
															|  | -                'invoiceElement' => $invoiceElement,
 |  | 
 | 
												
													
														
															|  | -
 |  | 
 | 
												
													
														
															|  | -                'invoiceQuantity' => $invoiceQuantity,
 |  | 
 | 
												
													
														
															|  | -                'invoiceUnitPrice' => $invoiceUnitPrice,
 |  | 
 | 
												
													
														
															|  | -
 |  | 
 | 
												
													
														
															|  | -                'invoicePrice' => $invoicePrice,
 |  | 
 | 
												
													
														
															|  | -                'invoiceType' => $invoiceType,
 |  | 
 | 
												
													
														
															|  | -                'settlementType' => $st,
 |  | 
 | 
												
													
														
															|  | -                'doPost' => $doPost,
 |  | 
 | 
												
													
														
															|  | -                'status' => 1,
 |  | 
 | 
												
													
														
															|  | -                'invoiceSerial' => "#F" . date('Ymd') . str_pad(mt_rand(1, 99999), 5, '0', STR_PAD_LEFT),
 |  | 
 | 
												
													
														
															|  | -                'date' => date ( "Y-m-d H:i:s" ),
 |  | 
 | 
												
													
														
															|  | -                'updateTime' => date ( "Y-m-d H:i:s" ),
 |  | 
 | 
												
													
														
															|  | -                'sid' => $this->staff [0] ['sid'],
 |  | 
 | 
												
													
														
															|  | -                'userName' => $this->staff [0] ['username'],
 |  | 
 | 
												
													
														
															|  | -                'invoiceManage' => $invoiceManageDetail ['staff'],
 |  | 
 | 
												
													
														
															|  | -                'pendingApprovals' => $pendingApprovalsSid,
 |  | 
 | 
												
													
														
															|  | -                'moldManage' => json_encode ( $moldManage ),
 |  | 
 | 
												
													
														
															|  | -                'remark' => $remark,
 |  | 
 | 
												
													
														
															|  | -                'trainId' => $trainId,
 |  | 
 | 
												
													
														
															|  | -                'parentUntreadIid'=>$trainId
 |  | 
 | 
												
													
														
															|  | -            );
 |  | 
 | 
												
													
														
															|  | -            if ($invoiceType == 0)
 |  | 
 | 
												
													
														
															|  | -                $item += array (
 |  | 
 | 
												
													
														
															|  | -                    'invoiceTitle' => $invoiceTitle,
 |  | 
 | 
												
													
														
															|  | -                    'TIN' => $TINT,
 |  | 
 | 
												
													
														
															|  | -                    'address' => $addressT,
 |  | 
 | 
												
													
														
															|  | -                    'phone' => $phoneT,
 |  | 
 | 
												
													
														
															|  | -                    'bank' => $bankT,
 |  | 
 | 
												
													
														
															|  | -                    'bankAccount' => $bankAccountT
 |  | 
 | 
												
													
														
															|  | -                );
 |  | 
 | 
												
													
														
															|  | -            else {
 |  | 
 | 
												
													
														
															|  | -                $item += array (
 |  | 
 | 
												
													
														
															|  | -                    'invoiceCompany' => $invoiceCompany,
 |  | 
 | 
												
													
														
															|  | -                    'TIN' => $TIN,
 |  | 
 | 
												
													
														
															|  | -                    'address' => $address,
 |  | 
 | 
												
													
														
															|  | -                    'phone' => $phone,
 |  | 
 | 
												
													
														
															|  | -                    'bank' => $bank,
 |  | 
 | 
												
													
														
															|  | -                    'bankAccount' => $bankAccount
 |  | 
 | 
												
													
														
															|  | -                );
 |  | 
 | 
												
													
														
															|  | -            }
 |  | 
 | 
												
													
														
															|  | -            if ($doPost == 1) {
 |  | 
 | 
												
													
														
															|  | -                $mailList = array (
 |  | 
 | 
												
													
														
															|  | -                    'invoice' => 1,
 |  | 
 | 
												
													
														
															|  | -                    'mailItems' => $mailItems
 |  | 
 | 
												
													
														
															|  | -                );
 |  | 
 | 
												
													
														
															|  | -                if (! empty ( $softLock ))
 |  | 
 | 
												
													
														
															|  | -                    $mailList += array (
 |  | 
 | 
												
													
														
															|  | -                        'softLock' => $softLockNum
 |  | 
 | 
												
													
														
															|  | -                    );
 |  | 
 | 
												
													
														
															|  | -                else
 |  | 
 | 
												
													
														
															|  | -                    $mailList += array (
 |  | 
 | 
												
													
														
															|  | -                        'softLock' => 0
 |  | 
 | 
												
													
														
															|  | -                    );
 |  | 
 | 
												
													
														
															|  | -                if (! empty ( $contract ))
 |  | 
 | 
												
													
														
															|  | -                    $mailList += array (
 |  | 
 | 
												
													
														
															|  | -                        'contract' => $contractNum
 |  | 
 | 
												
													
														
															|  | -                    );
 |  | 
 | 
												
													
														
															|  | -                else
 |  | 
 | 
												
													
														
															|  | -                    $mailList += array (
 |  | 
 | 
												
													
														
															|  | -                        'contract' => 0
 |  | 
 | 
												
													
														
															|  | -                    );
 |  | 
 | 
												
													
														
															|  | -                if (! empty ( $instructions ))
 |  | 
 | 
												
													
														
															|  | -                    $mailList += array (
 |  | 
 | 
												
													
														
															|  | -                        'instructions' => $instructionsNum
 |  | 
 | 
												
													
														
															|  | -                    );
 |  | 
 | 
												
													
														
															|  | -                else
 |  | 
 | 
												
													
														
															|  | -                    $mailList += array (
 |  | 
 | 
												
													
														
															|  | -                        'instructions' => 0
 |  | 
 | 
												
													
														
															|  | -                    );
 |  | 
 | 
												
													
														
															|  | -                if (! empty ( $remittance ))
 |  | 
 | 
												
													
														
															|  | -                    $mailList += array (
 |  | 
 | 
												
													
														
															|  | -                        'remittance' => $remittance
 |  | 
 | 
												
													
														
															|  | -                    );
 |  | 
 | 
												
													
														
															|  | -                else
 |  | 
 | 
												
													
														
															|  | -                    $mailList += array (
 |  | 
 | 
												
													
														
															|  | -                        'remittance' => ''
 |  | 
 | 
												
													
														
															|  | -                    );
 |  | 
 | 
												
													
														
															|  | -
 |  | 
 | 
												
													
														
															|  | -                $mailString = '发票x1张,备注:' . $mailItems;
 |  | 
 | 
												
													
														
															|  | -                if (! empty ( $softLock ))
 |  | 
 | 
												
													
														
															|  | -                    $mailString .= ',软件锁x' . $softLockNum . '个';
 |  | 
 | 
												
													
														
															|  | -                if (! empty ( $contract ))
 |  | 
 | 
												
													
														
															|  | -                    $mailString .= ',合同x' . $contractNum . '份';
 |  | 
 | 
												
													
														
															|  | -                if (! empty ( $instructions ))
 |  | 
 | 
												
													
														
															|  | -                    $mailString .= ',说明书x' . $instructionsNum . '本';
 |  | 
 | 
												
													
														
															|  | -                if (! empty ( $remittance ))
 |  | 
 | 
												
													
														
															|  | -                    $mailString .= ',汇款账号单(张)';
 |  | 
 | 
												
													
														
															|  | -
 |  | 
 | 
												
													
														
															|  | -                $item += array (
 |  | 
 | 
												
													
														
															|  | -                    'recipients' => $recipients,
 |  | 
 | 
												
													
														
															|  | -                    'recipientsPhone' => $recipientsPhone,
 |  | 
 | 
												
													
														
															|  | -                    'recipientsAddress' => $recipientsAddress,
 |  | 
 | 
												
													
														
															|  | -                    'mailItems' => $mailString,
 |  | 
 | 
												
													
														
															|  | -                    'mailItemsJson' => json_encode ( $mailList )
 |  | 
 | 
												
													
														
															|  | -                );
 |  | 
 | 
												
													
														
															|  | -            }
 |  | 
 | 
												
													
														
															|  | -            $iid = $invoice->addInvoice ( $item );
 |  | 
 | 
												
													
														
															|  | -
 |  | 
 | 
												
													
														
															|  | -            $invoice = new invoice ();
 |  | 
 | 
												
													
														
															|  | -            if (!empty($invoiceDetail['inheritIid'])){
 |  | 
 | 
												
													
														
															|  | -                $inheritIid=$invoiceDetail['inheritIid'].','.$iid;
 |  | 
 | 
												
													
														
															|  | -            }else{
 |  | 
 | 
												
													
														
															|  | -                $inheritIid=$iid;
 |  | 
 | 
												
													
														
															|  | -            }
 |  | 
 | 
												
													
														
															|  | -
 |  | 
 | 
												
													
														
															|  | -            $item = array (
 |  | 
 | 
												
													
														
															|  | -                'iid' => $invoiceDetail['iid'],
 |  | 
 | 
												
													
														
															|  | -                'inheritIid' => $inheritIid
 |  | 
 | 
												
													
														
															|  | -            );
 |  | 
 | 
												
													
														
															|  | -            $invoice->setInvoiceByCondition($item);
 |  | 
 | 
												
													
														
															|  | -
 |  | 
 | 
												
													
														
															|  | -
 |  | 
 | 
												
													
														
															|  | -            // 如果是培训班结算 创建培训班发票到培训班备份中
 |  | 
 | 
												
													
														
															|  | -            if (! empty ( $st ) && $st == 1) {
 |  | 
 | 
												
													
														
															|  | -                Doo::loadModel ( 'invoiceStore' );
 |  | 
 | 
												
													
														
															|  | -                $invoiceStore = new invoiceStore ();
 |  | 
 | 
												
													
														
															|  | -                Doo::loadModel ( 'invoiceTraining' );
 |  | 
 | 
												
													
														
															|  | -                $invoiceTraining = new invoiceTraining ();
 |  | 
 | 
												
													
														
															|  | -
 |  | 
 | 
												
													
														
															|  | -                $isid = $invoiceStore->setInvoiceToInvoiceStore ( $iid );
 |  | 
 | 
												
													
														
															|  | -                $itemIS = array (
 |  | 
 | 
												
													
														
															|  | -                    'isid' => $isid,
 |  | 
 | 
												
													
														
															|  | -                    'ipSource' => 1,
 |  | 
 | 
												
													
														
															|  | -                    'apStatus' => 1,
 |  | 
 | 
												
													
														
															|  | -                    'iid' => $iid
 |  | 
 | 
												
													
														
															|  | -                );
 |  | 
 | 
												
													
														
															|  | -                $invoiceStore->setInvoiceStoreByCondition ( $itemIS );
 |  | 
 | 
												
													
														
															|  | -
 |  | 
 | 
												
													
														
															|  | -                // 更新培训班总数量
 |  | 
 | 
												
													
														
															|  | -                $detailIT = $invoiceTraining->getInvoiceTrainingByItid ( $trainId );
 |  | 
 | 
												
													
														
															|  | -                $item = array (
 |  | 
 | 
												
													
														
															|  | -                    'itid' => $trainId,
 |  | 
 | 
												
													
														
															|  | -                    'invoiceTotal' => $detailIT ['invoiceTotal'] + 1,
 |  | 
 | 
												
													
														
															|  | -                    'submitStatus' => 1
 |  | 
 | 
												
													
														
															|  | -                );
 |  | 
 | 
												
													
														
															|  | -                $itid = $invoiceTraining->setInvoiceTrainByCondition ( $item );
 |  | 
 | 
												
													
														
															|  | -            }
 |  | 
 | 
												
													
														
															|  | -
 |  | 
 | 
												
													
														
															|  | -            // 操作日志
 |  | 
 | 
												
													
														
															|  | -            $item = array (
 |  | 
 | 
												
													
														
															|  | -                'date' => date ( "Y-m-d H:i:s" ),
 |  | 
 | 
												
													
														
															|  | -                'operation' => "创建",
 |  | 
 | 
												
													
														
															|  | -                'status' => 1,
 |  | 
 | 
												
													
														
															|  | -                'img' => $this->staff [0] ['avatar'],
 |  | 
 | 
												
													
														
															|  | -                'username' => $this->staff [0] ['username'],
 |  | 
 | 
												
													
														
															|  | -                'uid' => $this->staff [0] ['sid'],
 |  | 
 | 
												
													
														
															|  | -                'category' => $this->staff [0] ['category'],
 |  | 
 | 
												
													
														
															|  | -                'iid' => $iid
 |  | 
 | 
												
													
														
															|  | -            );
 |  | 
 | 
												
													
														
															|  | -            $invoiceOperationLog->setInvoiceOperationLog ( $item );
 |  | 
 | 
												
													
														
															|  | -            $item = array (
 |  | 
 | 
												
													
														
															|  | -                'date' => date ( "Y-m-d H:i:s" ),
 |  | 
 | 
												
													
														
															|  | -                'operation' => "提交审批",
 |  | 
 | 
												
													
														
															|  | -                'status' => 1,
 |  | 
 | 
												
													
														
															|  | -                'img' => $this->staff [0] ['avatar'],
 |  | 
 | 
												
													
														
															|  | -                'username' => $this->staff [0] ['username'],
 |  | 
 | 
												
													
														
															|  | -                'uid' => $this->staff [0] ['sid'],
 |  | 
 | 
												
													
														
															|  | -                'category' => $this->staff [0] ['category'],
 |  | 
 | 
												
													
														
															|  | -                'iid' => $iid
 |  | 
 | 
												
													
														
															|  | -            );
 |  | 
 | 
												
													
														
															|  | -            $invoiceOperationLog->setInvoiceOperationLog ( $item );
 |  | 
 | 
												
													
														
															|  | -
 |  | 
 | 
												
													
														
															|  | -        }
 |  | 
 | 
												
													
														
															|  | -        return "/invoiceUntreadED";
 |  | 
 | 
												
													
														
															|  | -    }
 |  | 
 | 
												
													
														
															|  | -
 |  | 
 | 
												
													
														
															|  | 
 |  | +	function invoiceUntreadAdd() {
 | 
												
													
														
															|  | 
 |  | +		session_start ();
 | 
												
													
														
															|  | 
 |  | +		Doo::loadClass ( 'XDeode' );
 | 
												
													
														
															|  | 
 |  | +		$XDeode = new XDeode ( 5 );
 | 
												
													
														
															|  | 
 |  | +		
 | 
												
													
														
															|  | 
 |  | +		$iidKey = isset ( $this->params ['iidKey'] ) ? $this->params ['iidKey'] : "";
 | 
												
													
														
															|  | 
 |  | +		$iid = $XDeode->decode ( $iidKey );
 | 
												
													
														
															|  | 
 |  | +		if (! is_numeric ( $iid ))
 | 
												
													
														
															|  | 
 |  | +			die ( 'illegal request' );
 | 
												
													
														
															|  | 
 |  | +		
 | 
												
													
														
															|  | 
 |  | +		Doo::loadModel ( 'invoice' );
 | 
												
													
														
															|  | 
 |  | +		$invoice = new invoice ();
 | 
												
													
														
															|  | 
 |  | +		Doo::loadModel ( 'invoiceOperationLog' );
 | 
												
													
														
															|  | 
 |  | +		$invoiceOperationLog = new invoiceOperationLog ();
 | 
												
													
														
															|  | 
 |  | +		
 | 
												
													
														
															|  | 
 |  | +		$invoiceDetail = $invoice->getInvoiceByIid ( $iid );
 | 
												
													
														
															|  | 
 |  | +		$operation = $invoiceOperationLog->getInvoiceOperationByDropped ( $iid );
 | 
												
													
														
															|  | 
 |  | +		// 获得继承发票金额合计
 | 
												
													
														
															|  | 
 |  | +		$restrictPrice = $invoiceDetail ['invoicePrice'];
 | 
												
													
														
															|  | 
 |  | +		if (! empty ( $invoiceDetail ['inheritIid'] )) {
 | 
												
													
														
															|  | 
 |  | +			$restrictList = $invoice->getInvoiceInIid ( $invoiceDetail ['inheritIid'] );
 | 
												
													
														
															|  | 
 |  | +			foreach ( $restrictList as $key => $value ) {
 | 
												
													
														
															|  | 
 |  | +				$restrictPrice -= $value ['invoicePrice'];
 | 
												
													
														
															|  | 
 |  | +			}
 | 
												
													
														
															|  | 
 |  | +		}
 | 
												
													
														
															|  | 
 |  | +		if ($restrictPrice < 0) {
 | 
												
													
														
															|  | 
 |  | +			$restrictPrice = 0;
 | 
												
													
														
															|  | 
 |  | +		}
 | 
												
													
														
															|  | 
 |  | +		
 | 
												
													
														
															|  | 
 |  | +		$invoiceDetail ['mailItemsJson'] = json_decode ( $invoiceDetail ['mailItemsJson'], true );
 | 
												
													
														
															|  | 
 |  | +		
 | 
												
													
														
															|  | 
 |  | +		$token = $this->set_token ();
 | 
												
													
														
															|  | 
 |  | +		$_SESSION ['token_' . $this->staff [0] ['sidKey']] = $token;
 | 
												
													
														
															|  | 
 |  | +		$this->data ['token'] = $token;
 | 
												
													
														
															|  | 
 |  | +		
 | 
												
													
														
															|  | 
 |  | +		$this->data ['restrictPrice'] = floatval ( $restrictPrice );
 | 
												
													
														
															|  | 
 |  | +		$this->data ['operation'] = $operation;
 | 
												
													
														
															|  | 
 |  | +		$this->data ['invoiceDetail'] = $invoiceDetail;
 | 
												
													
														
															|  | 
 |  | +		$this->data ['memu'] = "invoice";
 | 
												
													
														
															|  | 
 |  | +		$this->data ['staff'] = $this->staff;
 | 
												
													
														
															|  | 
 |  | +		$this->data ['receiptMemu'] = 'invoice';
 | 
												
													
														
															|  | 
 |  | +		$this->render ( "/invoice/invoiceUntreadAdd", $this->data );
 | 
												
													
														
															|  | 
 |  | +	}
 | 
												
													
														
															|  | 
 |  | +	function invoiceUntreadAddDo() {
 | 
												
													
														
															|  | 
 |  | +		$iidKey = $this->get_args ( 'iidKey' ) ? $this->get_args ( 'iidKey' ) : "";
 | 
												
													
														
															|  | 
 |  | +		Doo::loadModel ( 'invoice' );
 | 
												
													
														
															|  | 
 |  | +		$invoice = new invoice ();
 | 
												
													
														
															|  | 
 |  | +		$iid = $invoice->authcode ( $iidKey );
 | 
												
													
														
															|  | 
 |  | +		if (! empty ( $iid ) && ! is_numeric ( $iid ))
 | 
												
													
														
															|  | 
 |  | +			die ( 'illegal request' );
 | 
												
													
														
															|  | 
 |  | +		
 | 
												
													
														
															|  | 
 |  | +		$cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
 | 
												
													
														
															|  | 
 |  | +		$invoiceType = $this->get_args ( 'invoiceType' ) && is_numeric ( $this->get_args ( 'invoiceType' ) ) ? $this->get_args ( 'invoiceType' ) : 0;
 | 
												
													
														
															|  | 
 |  | +		$doPost = $this->get_args ( 'doPost' ) && is_numeric ( $this->get_args ( 'doPost' ) ) ? $this->get_args ( 'doPost' ) : 0;
 | 
												
													
														
															|  | 
 |  | +		// $invoicePrice = $this->get_args ( 'invoicePrice' ) ? $this->get_args ( 'invoicePrice' ) : "";
 | 
												
													
														
															|  | 
 |  | +		
 | 
												
													
														
															|  | 
 |  | +		$invoiceQuantity = $this->get_args ( 'invoiceQuantity' ) && is_numeric ( $this->get_args ( 'invoiceQuantity' ) ) ? $this->get_args ( 'invoiceQuantity' ) : 0;
 | 
												
													
														
															|  | 
 |  | +		$invoiceUnitPrice = $this->get_args ( 'invoiceUnitPrice' ) && is_numeric ( $this->get_args ( 'invoiceUnitPrice' ) ) ? $this->get_args ( 'invoiceUnitPrice' ) : 0;
 | 
												
													
														
															|  | 
 |  | +		
 | 
												
													
														
															|  | 
 |  | +		$invoiceElement = $this->get_args ( 'invoiceElement' ) ? $this->get_args ( 'invoiceElement' ) : "";
 | 
												
													
														
															|  | 
 |  | +		$invoiceTitle = $this->get_args ( 'invoiceTitle' ) ? $this->get_args ( 'invoiceTitle' ) : "";
 | 
												
													
														
															|  | 
 |  | +		$invoiceCompany = $this->get_args ( 'invoiceCompany' ) ? $this->get_args ( 'invoiceCompany' ) : "";
 | 
												
													
														
															|  | 
 |  | +		$TIN = $this->get_args ( 'TIN' ) ? $this->get_args ( 'TIN' ) : "";
 | 
												
													
														
															|  | 
 |  | +		$address = $this->get_args ( 'address' ) ? $this->get_args ( 'address' ) : "";
 | 
												
													
														
															|  | 
 |  | +		$phone = $this->get_args ( 'phone' ) ? $this->get_args ( 'phone' ) : "";
 | 
												
													
														
															|  | 
 |  | +		$bank = $this->get_args ( 'bank' ) ? $this->get_args ( 'bank' ) : "";
 | 
												
													
														
															|  | 
 |  | +		$bankAccount = $this->get_args ( 'bankAccount' ) ? $this->get_args ( 'bankAccount' ) : "";
 | 
												
													
														
															|  | 
 |  | +		$recipients = $this->get_args ( 'recipients' ) ? $this->get_args ( 'recipients' ) : "";
 | 
												
													
														
															|  | 
 |  | +		$recipientsPhone = $this->get_args ( 'recipientsPhone' ) ? $this->get_args ( 'recipientsPhone' ) : "";
 | 
												
													
														
															|  | 
 |  | +		$recipientsAddress = $this->get_args ( 'recipientsAddress' ) ? $this->get_args ( 'recipientsAddress' ) : "";
 | 
												
													
														
															|  | 
 |  | +		
 | 
												
													
														
															|  | 
 |  | +		$remark = $this->get_args ( 'remark' ) ? $this->get_args ( 'remark' ) : "";
 | 
												
													
														
															|  | 
 |  | +		
 | 
												
													
														
															|  | 
 |  | +		$TINT = $this->get_args ( 'TINT' ) ? $this->get_args ( 'TINT' ) : "";
 | 
												
													
														
															|  | 
 |  | +		$addressT = $this->get_args ( 'addressT' ) ? $this->get_args ( 'addressT' ) : "";
 | 
												
													
														
															|  | 
 |  | +		$phoneT = $this->get_args ( 'phoneT' ) ? $this->get_args ( 'phoneT' ) : "";
 | 
												
													
														
															|  | 
 |  | +		$bankT = $this->get_args ( 'bankT' ) ? $this->get_args ( 'bankT' ) : "";
 | 
												
													
														
															|  | 
 |  | +		$bankAccountT = $this->get_args ( 'bankAccountT' ) ? $this->get_args ( 'bankAccountT' ) : "";
 | 
												
													
														
															|  | 
 |  | +		
 | 
												
													
														
															|  | 
 |  | +		$softLock = $this->get_args ( 'softLock' ) ? $this->get_args ( 'softLock' ) : 0;
 | 
												
													
														
															|  | 
 |  | +		$softLockNum = $this->get_args ( 'softLockNum' ) ? $this->get_args ( 'softLockNum' ) : 0;
 | 
												
													
														
															|  | 
 |  | +		$contract = $this->get_args ( 'contract' ) ? $this->get_args ( 'contract' ) : 0;
 | 
												
													
														
															|  | 
 |  | +		$contractNum = $this->get_args ( 'contractNum' ) ? $this->get_args ( 'contractNum' ) : 0;
 | 
												
													
														
															|  | 
 |  | +		$instructions = $this->get_args ( 'instructions' ) ? $this->get_args ( 'instructions' ) : 0;
 | 
												
													
														
															|  | 
 |  | +		$instructionsNum = $this->get_args ( 'instructionsNum' ) ? $this->get_args ( 'instructionsNum' ) : 0;
 | 
												
													
														
															|  | 
 |  | +		$remittance = $this->get_args ( 'remittance' ) ? $this->get_args ( 'remittance' ) : 0;
 | 
												
													
														
															|  | 
 |  | +		
 | 
												
													
														
															|  | 
 |  | +		$mailItems = $this->get_args ( 'mailItems' ) ? $this->get_args ( 'mailItems' ) : "";
 | 
												
													
														
															|  | 
 |  | +		
 | 
												
													
														
															|  | 
 |  | +		$token = $this->get_args ( 'token' ) ? $this->get_args ( 'token' ) : "";
 | 
												
													
														
															|  | 
 |  | +		if (empty ( $token )) {
 | 
												
													
														
															|  | 
 |  | +			die ( 'illegal request-token' );
 | 
												
													
														
															|  | 
 |  | +		} else {
 | 
												
													
														
															|  | 
 |  | +			session_start ();
 | 
												
													
														
															|  | 
 |  | +			if ($_SESSION ['token_' . $this->staff [0] ['sidKey']] != $token) {
 | 
												
													
														
															|  | 
 |  | +				header ( 'Content-Type:text/html;charset=utf-8' );
 | 
												
													
														
															|  | 
 |  | +				die ( '请勿重复申请发票' );
 | 
												
													
														
															|  | 
 |  | +			} else {
 | 
												
													
														
															|  | 
 |  | +				$_SESSION ['token_' . $this->staff [0] ['sidKey']] = '';
 | 
												
													
														
															|  | 
 |  | +			}
 | 
												
													
														
															|  | 
 |  | +		}
 | 
												
													
														
															|  | 
 |  | +		
 | 
												
													
														
															|  | 
 |  | +		$temporary = $invoiceQuantity * $invoiceUnitPrice;
 | 
												
													
														
															|  | 
 |  | +		if ($invoiceType == 1) {
 | 
												
													
														
															|  | 
 |  | +			if ($temporary > 10000) {
 | 
												
													
														
															|  | 
 |  | +				header ( 'Content-Type:text/html;charset=utf-8' );
 | 
												
													
														
															|  | 
 |  | +				die ( '专用发票总金额暂时不能超过10000.00(一万)元。' );
 | 
												
													
														
															|  | 
 |  | +				// die ( 'illegal request-Please priceError' );
 | 
												
													
														
															|  | 
 |  | +			}
 | 
												
													
														
															|  | 
 |  | +		}
 | 
												
													
														
															|  | 
 |  | +		
 | 
												
													
														
															|  | 
 |  | +		if (empty ( $this->staff [0] ))
 | 
												
													
														
															|  | 
 |  | +			die ( 'illegal request-Please login' );
 | 
												
													
														
															|  | 
 |  | +		
 | 
												
													
														
															|  | 
 |  | +		if (! empty ( $cid ) && ! empty ( $invoiceQuantity ) && ! empty ( $invoiceUnitPrice ) && ! empty ( $invoiceElement )) {
 | 
												
													
														
															|  | 
 |  | +			
 | 
												
													
														
															|  | 
 |  | +			Doo::loadModel ( 'L_category' );
 | 
												
													
														
															|  | 
 |  | +			$lCategory = new L_category ();
 | 
												
													
														
															|  | 
 |  | +			Doo::loadModel ( 'invoiceManage' );
 | 
												
													
														
															|  | 
 |  | +			$invoiceManage = new invoiceManage ();
 | 
												
													
														
															|  | 
 |  | +			Doo::loadModel ( 'invoiceOperationLog' );
 | 
												
													
														
															|  | 
 |  | +			$invoiceOperationLog = new invoiceOperationLog ();
 | 
												
													
														
															|  | 
 |  | +			
 | 
												
													
														
															|  | 
 |  | +			Doo::loadClass ( 'XDeode' );
 | 
												
													
														
															|  | 
 |  | +			$XDeode = new XDeode ( 5 );
 | 
												
													
														
															|  | 
 |  | +			
 | 
												
													
														
															|  | 
 |  | +			$categoryDetil = $lCategory->getOne ( array (
 | 
												
													
														
															|  | 
 |  | +					'SELECT' => 'title',
 | 
												
													
														
															|  | 
 |  | +					'where' => 'cid=' . $cid,
 | 
												
													
														
															|  | 
 |  | +					'asArray' => true 
 | 
												
													
														
															|  | 
 |  | +			) );
 | 
												
													
														
															|  | 
 |  | +			
 | 
												
													
														
															|  | 
 |  | +			$invoicePrice = $invoiceQuantity * $invoiceUnitPrice;
 | 
												
													
														
															|  | 
 |  | +			
 | 
												
													
														
															|  | 
 |  | +			$invoiceManageList = $invoiceManage->getInvoiceByAll ();
 | 
												
													
														
															|  | 
 |  | +			$invoiceManageDetail = $invoiceManage->getInvoiceByMold ( "发票审批" );
 | 
												
													
														
															|  | 
 |  | +			// print_r(current($invoiceManageDetail ['staffList']));
 | 
												
													
														
															|  | 
 |  | +			// die;
 | 
												
													
														
															|  | 
 |  | +			
 | 
												
													
														
															|  | 
 |  | +			$moldManage = array ();
 | 
												
													
														
															|  | 
 |  | +			foreach ( $invoiceManageList as $key => $value ) {
 | 
												
													
														
															|  | 
 |  | +				if ($value ['mold'] == '发票打印')
 | 
												
													
														
															|  | 
 |  | +					$moldManage [$value ['mold']] = $value ['staffList'];
 | 
												
													
														
															|  | 
 |  | +				elseif ($value ['mold'] == '发票邮寄')
 | 
												
													
														
															|  | 
 |  | +					$moldManage [$value ['mold']] = $value ['staffList'];
 | 
												
													
														
															|  | 
 |  | +				elseif ($value ['mold'] == '发票退票')
 | 
												
													
														
															|  | 
 |  | +					$moldManage [$value ['mold']] = $value ['staffList'];
 | 
												
													
														
															|  | 
 |  | +			}
 | 
												
													
														
															|  | 
 |  | +			
 | 
												
													
														
															|  | 
 |  | +			$pendingApprovalsSid = current ( $invoiceManageDetail ['staffList'] ) [0];
 | 
												
													
														
															|  | 
 |  | +			
 | 
												
													
														
															|  | 
 |  | +			// 培训班ID--新增关联-发票关系 发票IID关联
 | 
												
													
														
															|  | 
 |  | +			$invoice = new invoice ();
 | 
												
													
														
															|  | 
 |  | +			$invoiceDetail = $invoice->getInvoiceByIid ( $iid );
 | 
												
													
														
															|  | 
 |  | +			// 退票后,重新开票金额的限制
 | 
												
													
														
															|  | 
 |  | +			$restrictPrice = $invoiceDetail ['invoicePrice'];
 | 
												
													
														
															|  | 
 |  | +			if (! empty ( $invoiceDetail ['inheritIid'] )) {
 | 
												
													
														
															|  | 
 |  | +				$restrictList = $invoice->getInvoiceInIid ( $invoiceDetail ['inheritIid'] );
 | 
												
													
														
															|  | 
 |  | +				foreach ( $restrictList as $key => $value ) {
 | 
												
													
														
															|  | 
 |  | +					$restrictPrice -= $value ['invoicePrice'];
 | 
												
													
														
															|  | 
 |  | +				}
 | 
												
													
														
															|  | 
 |  | +			}
 | 
												
													
														
															|  | 
 |  | +			if ($restrictPrice < 0) {
 | 
												
													
														
															|  | 
 |  | +				header ( 'Content-Type:text/html;charset=utf-8' );
 | 
												
													
														
															|  | 
 |  | +				die ( '开票金额超出原退票金额-0' );
 | 
												
													
														
															|  | 
 |  | +			} else {
 | 
												
													
														
															|  | 
 |  | +				if ($restrictPrice < $temporary) {
 | 
												
													
														
															|  | 
 |  | +					header ( 'Content-Type:text/html;charset=utf-8' );
 | 
												
													
														
															|  | 
 |  | +					die ( '开票金额超出原退票金额-1' );
 | 
												
													
														
															|  | 
 |  | +				}
 | 
												
													
														
															|  | 
 |  | +			}
 | 
												
													
														
															|  | 
 |  | +			
 | 
												
													
														
															|  | 
 |  | +			$trainId = $invoiceDetail ['trainId'];
 | 
												
													
														
															|  | 
 |  | +			$st = 1;
 | 
												
													
														
															|  | 
 |  | +			if (empty ( $trainId ) && ! is_numeric ( $trainId )) {
 | 
												
													
														
															|  | 
 |  | +				die ( 'illegal request-trainingIdError' );
 | 
												
													
														
															|  | 
 |  | +			}
 | 
												
													
														
															|  | 
 |  | +			
 | 
												
													
														
															|  | 
 |  | +			$invoice = new invoice ();
 | 
												
													
														
															|  | 
 |  | +			$item = array (
 | 
												
													
														
															|  | 
 |  | +					'cid' => $cid,
 | 
												
													
														
															|  | 
 |  | +					'categoryName' => $categoryDetil ['title'],
 | 
												
													
														
															|  | 
 |  | +					'invoiceElement' => $invoiceElement,
 | 
												
													
														
															|  | 
 |  | +					
 | 
												
													
														
															|  | 
 |  | +					'invoiceQuantity' => $invoiceQuantity,
 | 
												
													
														
															|  | 
 |  | +					'invoiceUnitPrice' => $invoiceUnitPrice,
 | 
												
													
														
															|  | 
 |  | +					
 | 
												
													
														
															|  | 
 |  | +					'invoicePrice' => $invoicePrice,
 | 
												
													
														
															|  | 
 |  | +					'invoiceType' => $invoiceType,
 | 
												
													
														
															|  | 
 |  | +					'settlementType' => $st,
 | 
												
													
														
															|  | 
 |  | +					'doPost' => $doPost,
 | 
												
													
														
															|  | 
 |  | +					'status' => 1,
 | 
												
													
														
															|  | 
 |  | +					'invoiceSerial' => "#F" . date ( 'Ymd' ) . str_pad ( mt_rand ( 1, 99999 ), 5, '0', STR_PAD_LEFT ),
 | 
												
													
														
															|  | 
 |  | +					'date' => date ( "Y-m-d H:i:s" ),
 | 
												
													
														
															|  | 
 |  | +					'updateTime' => date ( "Y-m-d H:i:s" ),
 | 
												
													
														
															|  | 
 |  | +					'sid' => $this->staff [0] ['sid'],
 | 
												
													
														
															|  | 
 |  | +					'userName' => $this->staff [0] ['username'],
 | 
												
													
														
															|  | 
 |  | +					'invoiceManage' => $invoiceManageDetail ['staff'],
 | 
												
													
														
															|  | 
 |  | +					'pendingApprovals' => $pendingApprovalsSid,
 | 
												
													
														
															|  | 
 |  | +					'moldManage' => json_encode ( $moldManage ),
 | 
												
													
														
															|  | 
 |  | +					'remark' => $remark,
 | 
												
													
														
															|  | 
 |  | +					'trainId' => $trainId,
 | 
												
													
														
															|  | 
 |  | +					'parentUntreadIid' => $trainId 
 | 
												
													
														
															|  | 
 |  | +			);
 | 
												
													
														
															|  | 
 |  | +			if ($invoiceType == 0)
 | 
												
													
														
															|  | 
 |  | +				$item += array (
 | 
												
													
														
															|  | 
 |  | +						'invoiceTitle' => $invoiceTitle,
 | 
												
													
														
															|  | 
 |  | +						'TIN' => $TINT,
 | 
												
													
														
															|  | 
 |  | +						'address' => $addressT,
 | 
												
													
														
															|  | 
 |  | +						'phone' => $phoneT,
 | 
												
													
														
															|  | 
 |  | +						'bank' => $bankT,
 | 
												
													
														
															|  | 
 |  | +						'bankAccount' => $bankAccountT 
 | 
												
													
														
															|  | 
 |  | +				);
 | 
												
													
														
															|  | 
 |  | +			else {
 | 
												
													
														
															|  | 
 |  | +				$item += array (
 | 
												
													
														
															|  | 
 |  | +						'invoiceCompany' => $invoiceCompany,
 | 
												
													
														
															|  | 
 |  | +						'TIN' => $TIN,
 | 
												
													
														
															|  | 
 |  | +						'address' => $address,
 | 
												
													
														
															|  | 
 |  | +						'phone' => $phone,
 | 
												
													
														
															|  | 
 |  | +						'bank' => $bank,
 | 
												
													
														
															|  | 
 |  | +						'bankAccount' => $bankAccount 
 | 
												
													
														
															|  | 
 |  | +				);
 | 
												
													
														
															|  | 
 |  | +			}
 | 
												
													
														
															|  | 
 |  | +			if ($doPost == 1) {
 | 
												
													
														
															|  | 
 |  | +				$mailList = array (
 | 
												
													
														
															|  | 
 |  | +						'invoice' => 1,
 | 
												
													
														
															|  | 
 |  | +						'mailItems' => $mailItems 
 | 
												
													
														
															|  | 
 |  | +				);
 | 
												
													
														
															|  | 
 |  | +				if (! empty ( $softLock ))
 | 
												
													
														
															|  | 
 |  | +					$mailList += array (
 | 
												
													
														
															|  | 
 |  | +							'softLock' => $softLockNum 
 | 
												
													
														
															|  | 
 |  | +					);
 | 
												
													
														
															|  | 
 |  | +				else
 | 
												
													
														
															|  | 
 |  | +					$mailList += array (
 | 
												
													
														
															|  | 
 |  | +							'softLock' => 0 
 | 
												
													
														
															|  | 
 |  | +					);
 | 
												
													
														
															|  | 
 |  | +				if (! empty ( $contract ))
 | 
												
													
														
															|  | 
 |  | +					$mailList += array (
 | 
												
													
														
															|  | 
 |  | +							'contract' => $contractNum 
 | 
												
													
														
															|  | 
 |  | +					);
 | 
												
													
														
															|  | 
 |  | +				else
 | 
												
													
														
															|  | 
 |  | +					$mailList += array (
 | 
												
													
														
															|  | 
 |  | +							'contract' => 0 
 | 
												
													
														
															|  | 
 |  | +					);
 | 
												
													
														
															|  | 
 |  | +				if (! empty ( $instructions ))
 | 
												
													
														
															|  | 
 |  | +					$mailList += array (
 | 
												
													
														
															|  | 
 |  | +							'instructions' => $instructionsNum 
 | 
												
													
														
															|  | 
 |  | +					);
 | 
												
													
														
															|  | 
 |  | +				else
 | 
												
													
														
															|  | 
 |  | +					$mailList += array (
 | 
												
													
														
															|  | 
 |  | +							'instructions' => 0 
 | 
												
													
														
															|  | 
 |  | +					);
 | 
												
													
														
															|  | 
 |  | +				if (! empty ( $remittance ))
 | 
												
													
														
															|  | 
 |  | +					$mailList += array (
 | 
												
													
														
															|  | 
 |  | +							'remittance' => $remittance 
 | 
												
													
														
															|  | 
 |  | +					);
 | 
												
													
														
															|  | 
 |  | +				else
 | 
												
													
														
															|  | 
 |  | +					$mailList += array (
 | 
												
													
														
															|  | 
 |  | +							'remittance' => '' 
 | 
												
													
														
															|  | 
 |  | +					);
 | 
												
													
														
															|  | 
 |  | +				
 | 
												
													
														
															|  | 
 |  | +				$mailString = '发票x1张,备注:' . $mailItems;
 | 
												
													
														
															|  | 
 |  | +				if (! empty ( $softLock ))
 | 
												
													
														
															|  | 
 |  | +					$mailString .= ',软件锁x' . $softLockNum . '个';
 | 
												
													
														
															|  | 
 |  | +				if (! empty ( $contract ))
 | 
												
													
														
															|  | 
 |  | +					$mailString .= ',合同x' . $contractNum . '份';
 | 
												
													
														
															|  | 
 |  | +				if (! empty ( $instructions ))
 | 
												
													
														
															|  | 
 |  | +					$mailString .= ',说明书x' . $instructionsNum . '本';
 | 
												
													
														
															|  | 
 |  | +				if (! empty ( $remittance ))
 | 
												
													
														
															|  | 
 |  | +					$mailString .= ',汇款账号单(张)';
 | 
												
													
														
															|  | 
 |  | +				
 | 
												
													
														
															|  | 
 |  | +				$item += array (
 | 
												
													
														
															|  | 
 |  | +						'recipients' => $recipients,
 | 
												
													
														
															|  | 
 |  | +						'recipientsPhone' => $recipientsPhone,
 | 
												
													
														
															|  | 
 |  | +						'recipientsAddress' => $recipientsAddress,
 | 
												
													
														
															|  | 
 |  | +						'mailItems' => $mailString,
 | 
												
													
														
															|  | 
 |  | +						'mailItemsJson' => json_encode ( $mailList ) 
 | 
												
													
														
															|  | 
 |  | +				);
 | 
												
													
														
															|  | 
 |  | +			}
 | 
												
													
														
															|  | 
 |  | +			$iid = $invoice->addInvoice ( $item );
 | 
												
													
														
															|  | 
 |  | +			
 | 
												
													
														
															|  | 
 |  | +			$invoice = new invoice ();
 | 
												
													
														
															|  | 
 |  | +			if (! empty ( $invoiceDetail ['inheritIid'] )) {
 | 
												
													
														
															|  | 
 |  | +				$inheritIid = $invoiceDetail ['inheritIid'] . ',' . $iid;
 | 
												
													
														
															|  | 
 |  | +			} else {
 | 
												
													
														
															|  | 
 |  | +				$inheritIid = $iid;
 | 
												
													
														
															|  | 
 |  | +			}
 | 
												
													
														
															|  | 
 |  | +			
 | 
												
													
														
															|  | 
 |  | +			$item = array (
 | 
												
													
														
															|  | 
 |  | +					'iid' => $invoiceDetail ['iid'],
 | 
												
													
														
															|  | 
 |  | +					'inheritIid' => $inheritIid 
 | 
												
													
														
															|  | 
 |  | +			);
 | 
												
													
														
															|  | 
 |  | +			$invoice->setInvoiceByCondition ( $item );
 | 
												
													
														
															|  | 
 |  | +			
 | 
												
													
														
															|  | 
 |  | +			// 如果是培训班结算 创建培训班发票到培训班备份中
 | 
												
													
														
															|  | 
 |  | +			if (! empty ( $st ) && $st == 1) {
 | 
												
													
														
															|  | 
 |  | +				Doo::loadModel ( 'invoiceStore' );
 | 
												
													
														
															|  | 
 |  | +				$invoiceStore = new invoiceStore ();
 | 
												
													
														
															|  | 
 |  | +				Doo::loadModel ( 'invoiceTraining' );
 | 
												
													
														
															|  | 
 |  | +				$invoiceTraining = new invoiceTraining ();
 | 
												
													
														
															|  | 
 |  | +				
 | 
												
													
														
															|  | 
 |  | +				$isid = $invoiceStore->setInvoiceToInvoiceStore ( $iid );
 | 
												
													
														
															|  | 
 |  | +				$itemIS = array (
 | 
												
													
														
															|  | 
 |  | +						'isid' => $isid,
 | 
												
													
														
															|  | 
 |  | +						'ipSource' => 1,
 | 
												
													
														
															|  | 
 |  | +						'apStatus' => 1,
 | 
												
													
														
															|  | 
 |  | +						'iid' => $iid 
 | 
												
													
														
															|  | 
 |  | +				);
 | 
												
													
														
															|  | 
 |  | +				$invoiceStore->setInvoiceStoreByCondition ( $itemIS );
 | 
												
													
														
															|  | 
 |  | +				
 | 
												
													
														
															|  | 
 |  | +				// 更新培训班总数量
 | 
												
													
														
															|  | 
 |  | +				$detailIT = $invoiceTraining->getInvoiceTrainingByItid ( $trainId );
 | 
												
													
														
															|  | 
 |  | +				$item = array (
 | 
												
													
														
															|  | 
 |  | +						'itid' => $trainId,
 | 
												
													
														
															|  | 
 |  | +						'invoiceTotal' => $detailIT ['invoiceTotal'] + 1,
 | 
												
													
														
															|  | 
 |  | +						'submitStatus' => 1 
 | 
												
													
														
															|  | 
 |  | +				);
 | 
												
													
														
															|  | 
 |  | +				$itid = $invoiceTraining->setInvoiceTrainByCondition ( $item );
 | 
												
													
														
															|  | 
 |  | +			}
 | 
												
													
														
															|  | 
 |  | +			
 | 
												
													
														
															|  | 
 |  | +			// 操作日志
 | 
												
													
														
															|  | 
 |  | +			$item = array (
 | 
												
													
														
															|  | 
 |  | +					'date' => date ( "Y-m-d H:i:s" ),
 | 
												
													
														
															|  | 
 |  | +					'operation' => "创建",
 | 
												
													
														
															|  | 
 |  | +					'status' => 1,
 | 
												
													
														
															|  | 
 |  | +					'img' => $this->staff [0] ['avatar'],
 | 
												
													
														
															|  | 
 |  | +					'username' => $this->staff [0] ['username'],
 | 
												
													
														
															|  | 
 |  | +					'uid' => $this->staff [0] ['sid'],
 | 
												
													
														
															|  | 
 |  | +					'category' => $this->staff [0] ['category'],
 | 
												
													
														
															|  | 
 |  | +					'iid' => $iid 
 | 
												
													
														
															|  | 
 |  | +			);
 | 
												
													
														
															|  | 
 |  | +			$invoiceOperationLog->setInvoiceOperationLog ( $item );
 | 
												
													
														
															|  | 
 |  | +			$item = array (
 | 
												
													
														
															|  | 
 |  | +					'date' => date ( "Y-m-d H:i:s" ),
 | 
												
													
														
															|  | 
 |  | +					'operation' => "提交审批",
 | 
												
													
														
															|  | 
 |  | +					'status' => 1,
 | 
												
													
														
															|  | 
 |  | +					'img' => $this->staff [0] ['avatar'],
 | 
												
													
														
															|  | 
 |  | +					'username' => $this->staff [0] ['username'],
 | 
												
													
														
															|  | 
 |  | +					'uid' => $this->staff [0] ['sid'],
 | 
												
													
														
															|  | 
 |  | +					'category' => $this->staff [0] ['category'],
 | 
												
													
														
															|  | 
 |  | +					'iid' => $iid 
 | 
												
													
														
															|  | 
 |  | +			);
 | 
												
													
														
															|  | 
 |  | +			$invoiceOperationLog->setInvoiceOperationLog ( $item );
 | 
												
													
														
															|  | 
 |  | +		}
 | 
												
													
														
															|  | 
 |  | +		return "/invoiceUntreadED";
 | 
												
													
														
															|  | 
 |  | +	}
 | 
												
													
														
															|  | 
 |  | +	
 | 
												
													
														
															|  | 
 |  | +	//发票作废
 | 
												
													
														
															|  | 
 |  | +	function invoiceInvalid() {
 | 
												
													
														
															|  | 
 |  | +		$invalidId = $this->get_args ( 'invalidId' ) ? $this->get_args ( 'invalidId' ) : "";
 | 
												
													
														
															|  | 
 |  | +		$date = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "MONTHO";
 | 
												
													
														
															|  | 
 |  | +		
 | 
												
													
														
															|  | 
 |  | +		Doo::loadModel ( 'invoice' );
 | 
												
													
														
															|  | 
 |  | +		$invoice = new invoice ();
 | 
												
													
														
															|  | 
 |  | +		Doo::loadClass ( 'XDeode' );
 | 
												
													
														
															|  | 
 |  | +		$XDeode = new XDeode ( 5 );
 | 
												
													
														
															|  | 
 |  | +		Doo::loadModel ( 'invoiceStatistics' );
 | 
												
													
														
															|  | 
 |  | +		
 | 
												
													
														
															|  | 
 |  | +		$iid = $XDeode->decode ( $invalidId );
 | 
												
													
														
															|  | 
 |  | +		if (! is_numeric ( $iid )){
 | 
												
													
														
															|  | 
 |  | +			die ( 'illegal request-id' );
 | 
												
													
														
															|  | 
 |  | +		}
 | 
												
													
														
															|  | 
 |  | +		
 | 
												
													
														
															|  | 
 |  | +		$invoiceDetail = $invoice->getInvoiceByIid ( $iid );
 | 
												
													
														
															|  | 
 |  | +		if (empty ( $invoiceDetail )){
 | 
												
													
														
															|  | 
 |  | +			die ( 'illegal request-emptyData' );
 | 
												
													
														
															|  | 
 |  | +		}
 | 
												
													
														
															|  | 
 |  | +		
 | 
												
													
														
															|  | 
 |  | +		if ( $invoiceDetail['untreadStatus']==2&&$invoiceDetail['status']==2&&$invoiceDetail['isDelete']==0&&$invoiceDetail['invalid']==0 ){
 | 
												
													
														
															|  | 
 |  | +			$invoice = new invoice ();
 | 
												
													
														
															|  | 
 |  | +			$invoice->iid = $iid;
 | 
												
													
														
															|  | 
 |  | +			$invoice->invalid = 1;
 | 
												
													
														
															|  | 
 |  | +			$invoice->update ();
 | 
												
													
														
															|  | 
 |  | +			
 | 
												
													
														
															|  | 
 |  | +			$invoiceStatistics = new invoiceStatistics ();
 | 
												
													
														
															|  | 
 |  | +			$item = array (
 | 
												
													
														
															|  | 
 |  | +					'date' => $invoiceDetail['date'] ,
 | 
												
													
														
															|  | 
 |  | +					'priceClass' => 1,
 | 
												
													
														
															|  | 
 |  | +					'cid' => $invoiceDetail ['cid'],
 | 
												
													
														
															|  | 
 |  | +					'staff' => $invoiceDetail ['sid'],
 | 
												
													
														
															|  | 
 |  | +					'invoicePrice' => -$invoiceDetail ['invoicePrice']
 | 
												
													
														
															|  | 
 |  | +			);
 | 
												
													
														
															|  | 
 |  | +			$invoiceStatistics->setInvoiceStatisticsByCondition ( $item );
 | 
												
													
														
															|  | 
 |  | +			
 | 
												
													
														
															|  | 
 |  | +			return "/invoiceUntreadAchieve/1/".$date;
 | 
												
													
														
															|  | 
 |  | +		}else{
 | 
												
													
														
															|  | 
 |  | +			die ( 'illegal request-status' );
 | 
												
													
														
															|  | 
 |  | +		}
 | 
												
													
														
															|  | 
 |  | +	}
 | 
												
													
														
															|  | 
 |  | +	
 | 
												
													
														
															|  | 
 |  | +	//发票撤销作废
 | 
												
													
														
															|  | 
 |  | +	function invoiceUndoInvalid() {
 | 
												
													
														
															|  | 
 |  | +		$invalidId = $this->get_args ( 'invalidId' ) ? $this->get_args ( 'invalidId' ) : "";
 | 
												
													
														
															|  | 
 |  | +		$date = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "MONTHO";
 | 
												
													
														
															|  | 
 |  | +		Doo::loadModel ( 'invoice' );
 | 
												
													
														
															|  | 
 |  | +		$invoice = new invoice ();
 | 
												
													
														
															|  | 
 |  | +		Doo::loadClass ( 'XDeode' );
 | 
												
													
														
															|  | 
 |  | +		$XDeode = new XDeode ( 5 );
 | 
												
													
														
															|  | 
 |  | +		
 | 
												
													
														
															|  | 
 |  | +		Doo::loadModel ( 'invoiceStatistics' );
 | 
												
													
														
															|  | 
 |  | +		
 | 
												
													
														
															|  | 
 |  | +		$iid = $XDeode->decode ( $invalidId );
 | 
												
													
														
															|  | 
 |  | +		if (! is_numeric ( $iid )){
 | 
												
													
														
															|  | 
 |  | +			die ( 'illegal request-id' );
 | 
												
													
														
															|  | 
 |  | +		}
 | 
												
													
														
															|  | 
 |  | +		
 | 
												
													
														
															|  | 
 |  | +		$invoiceDetail = $invoice->getInvoiceByIid ( $iid );
 | 
												
													
														
															|  | 
 |  | +		if (empty ( $invoiceDetail )){
 | 
												
													
														
															|  | 
 |  | +			die ( 'illegal request-emptyData' );
 | 
												
													
														
															|  | 
 |  | +		}
 | 
												
													
														
															|  | 
 |  | +		if ( $invoiceDetail['untreadStatus']==2&&$invoiceDetail['status']==2&&$invoiceDetail['isDelete']==0&&$invoiceDetail['invalid']==1 ){
 | 
												
													
														
															|  | 
 |  | +			$invoice = new invoice ();
 | 
												
													
														
															|  | 
 |  | +			$invoice->iid = $iid;
 | 
												
													
														
															|  | 
 |  | +			$invoice->invalid = 0;
 | 
												
													
														
															|  | 
 |  | +			$invoice->update ();
 | 
												
													
														
															|  | 
 |  | +			
 | 
												
													
														
															|  | 
 |  | +			$invoiceStatistics = new invoiceStatistics ();
 | 
												
													
														
															|  | 
 |  | +			$item = array (
 | 
												
													
														
															|  | 
 |  | +					'date' => $invoiceDetail['date'] ,
 | 
												
													
														
															|  | 
 |  | +					'priceClass' => 1,
 | 
												
													
														
															|  | 
 |  | +					'cid' => $invoiceDetail ['cid'],
 | 
												
													
														
															|  | 
 |  | +					'staff' => $invoiceDetail ['sid'],
 | 
												
													
														
															|  | 
 |  | +					'invoicePrice' => $invoiceDetail ['invoicePrice']
 | 
												
													
														
															|  | 
 |  | +			);
 | 
												
													
														
															|  | 
 |  | +			$invoiceStatistics->setInvoiceStatisticsByCondition ( $item );
 | 
												
													
														
															|  | 
 |  | +			
 | 
												
													
														
															|  | 
 |  | +			return "/invoiceUntreadAchieve/1/".$date;
 | 
												
													
														
															|  | 
 |  | +		}else{
 | 
												
													
														
															|  | 
 |  | +			die ( 'illegal request-status' );
 | 
												
													
														
															|  | 
 |  | +		}
 | 
												
													
														
															|  | 
 |  | +	}
 | 
												
													
														
															|  | 
 |  | +	
 | 
												
													
														
															|  | 
 |  | +	//发票坏账
 | 
												
													
														
															|  | 
 |  | +	function invoiceBadDebt(){
 | 
												
													
														
															|  | 
 |  | +		$invalidId = $this->get_args ( 'iidKey' ) ? $this->get_args ( 'iidKey' ) : "";
 | 
												
													
														
															|  | 
 |  | +		$status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : "";
 | 
												
													
														
															|  | 
 |  | +		Doo::loadModel ( 'invoice' );
 | 
												
													
														
															|  | 
 |  | +		$invoice = new invoice ();
 | 
												
													
														
															|  | 
 |  | +		Doo::loadClass ( 'XDeode' );
 | 
												
													
														
															|  | 
 |  | +		$XDeode = new XDeode ( 5 );
 | 
												
													
														
															|  | 
 |  | +		
 | 
												
													
														
															|  | 
 |  | +		
 | 
												
													
														
															|  | 
 |  | +		
 | 
												
													
														
															|  | 
 |  | +		$iid = $XDeode->decode ( $invalidId );
 | 
												
													
														
															|  | 
 |  | +		if (! is_numeric ( $iid )){
 | 
												
													
														
															|  | 
 |  | +			die ( 'illegal request-id' );
 | 
												
													
														
															|  | 
 |  | +		}
 | 
												
													
														
															|  | 
 |  | +		
 | 
												
													
														
															|  | 
 |  | +		$invoiceDetail = $invoice->getInvoiceByIid ( $iid );
 | 
												
													
														
															|  | 
 |  | +		if (empty ( $invoiceDetail )){
 | 
												
													
														
															|  | 
 |  | +			die ( 'illegal request-emptyData' );
 | 
												
													
														
															|  | 
 |  | +		}
 | 
												
													
														
															|  | 
 |  | +		if ($invoiceDetail['untreadStatus']==0&&$invoiceDetail['status']==2&&$invoiceDetail['isDelete']==0&&$invoiceDetail['badDebt']==0 ){
 | 
												
													
														
															|  | 
 |  | +			$invoice = new invoice ();
 | 
												
													
														
															|  | 
 |  | +			$invoice->iid = $iid;
 | 
												
													
														
															|  | 
 |  | +			$invoice->badDebt = 1;
 | 
												
													
														
															|  | 
 |  | +			$invoice->update ();
 | 
												
													
														
															|  | 
 |  | +				
 | 
												
													
														
															|  | 
 |  | +// 			Doo::loadModel ( 'invoiceStatistics' );
 | 
												
													
														
															|  | 
 |  | +// 			$invoiceStatistics = new invoiceStatistics ();
 | 
												
													
														
															|  | 
 |  | +// 			$item = array (
 | 
												
													
														
															|  | 
 |  | +// 					'date' => $invoiceDetail['date'] ,
 | 
												
													
														
															|  | 
 |  | +// 					'priceClass' => 1,
 | 
												
													
														
															|  | 
 |  | +// 					'cid' => $invoiceDetail ['cid'],
 | 
												
													
														
															|  | 
 |  | +// 					'staff' => $invoiceDetail ['sid'],
 | 
												
													
														
															|  | 
 |  | +// 					'invoicePrice' => $invoiceDetail ['invoicePrice']
 | 
												
													
														
															|  | 
 |  | +// 			);
 | 
												
													
														
															|  | 
 |  | +// 			$invoiceStatistics->setInvoiceStatisticsByCondition ( $item );
 | 
												
													
														
															|  | 
 |  | +			
 | 
												
													
														
															|  | 
 |  | +			if(empty($status)){
 | 
												
													
														
															|  | 
 |  | +				return "/invoiceAS";
 | 
												
													
														
															|  | 
 |  | +			}else{
 | 
												
													
														
															|  | 
 |  | +				return "/invoiceAS/1/".$status;
 | 
												
													
														
															|  | 
 |  | +			}
 | 
												
													
														
															|  | 
 |  | +			
 | 
												
													
														
															|  | 
 |  | +		}else{
 | 
												
													
														
															|  | 
 |  | +			die ( 'illegal request-status' );
 | 
												
													
														
															|  | 
 |  | +		}
 | 
												
													
														
															|  | 
 |  | +	}
 | 
												
													
														
															|  | 
 |  | +	
 | 
												
													
														
															|  |  	/**
 |  |  	/**
 | 
												
													
														
															|  |  	 * 旧输入导入
 |  |  	 * 旧输入导入
 | 
												
													
														
															|  |  	 */
 |  |  	 */
 | 
												
											
												
													
														
															|  | @@ -1183,5 +1308,3 @@ class InvoiceExtendController extends DooController {
 | 
												
													
														
															|  |  		return $res;
 |  |  		return $res;
 | 
												
													
														
															|  |  	}
 |  |  	}
 | 
												
													
														
															|  |  }
 |  |  }
 | 
												
													
														
															|  | -
 |  | 
 | 
												
													
														
															|  | -?>
 |  | 
 |