|  | @@ -86,6 +86,13 @@ class InvoiceController extends DooController {
 | 
	
		
			
				|  |  |  		}
 | 
	
		
			
				|  |  |  	}
 | 
	
		
			
				|  |  |  	function invoice() {
 | 
	
		
			
				|  |  | +		Doo::loadModel ( 'invoice' );
 | 
	
		
			
				|  |  | +		$invoice = new invoice ();
 | 
	
		
			
				|  |  | +		
 | 
	
		
			
				|  |  | +		$pendingInvoice = $invoice->getPendingByInvoice ();
 | 
	
		
			
				|  |  | +		
 | 
	
		
			
				|  |  | +		$data ['pendingInvoice'] = $pendingInvoice;
 | 
	
		
			
				|  |  | +		
 | 
	
		
			
				|  |  |  		$data ['memu'] = "invoice";
 | 
	
		
			
				|  |  |  		$data ['staff'] = $this->staff;
 | 
	
		
			
				|  |  |  		$data ['receiptMemu'] = 'invoice';
 | 
	
	
		
			
				|  | @@ -115,7 +122,6 @@ class InvoiceController extends DooController {
 | 
	
		
			
				|  |  |  	 * 提交一份开票申请,并记录下操作日志
 | 
	
		
			
				|  |  |  	 *
 | 
	
		
			
				|  |  |  	 * @since 1.0.0
 | 
	
		
			
				|  |  | -	 *       
 | 
	
		
			
				|  |  |  	 * @var integer cid 办事处ID
 | 
	
		
			
				|  |  |  	 * @var integer invoiceType 发票类型
 | 
	
		
			
				|  |  |  	 * @var integer doPost 是否邮寄
 | 
	
	
		
			
				|  | @@ -214,11 +220,23 @@ class InvoiceController extends DooController {
 | 
	
		
			
				|  |  |  			
 | 
	
		
			
				|  |  |  			$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 );
 | 
	
	
		
			
				|  | @@ -229,8 +247,6 @@ class InvoiceController extends DooController {
 | 
	
		
			
				|  |  |  	function invoiceApproval() {
 | 
	
		
			
				|  |  |  		Doo::loadModel ( 'invoice' );
 | 
	
		
			
				|  |  |  		$invoice = new invoice ();
 | 
	
		
			
				|  |  | -		Doo::loadModel ( 'invoiceManage' );
 | 
	
		
			
				|  |  | -		$invoiceManage = new invoiceManage ();
 | 
	
		
			
				|  |  |  		Doo::loadClass ( 'XDeode' );
 | 
	
		
			
				|  |  |  		$XDeode = new XDeode ( 5 );
 | 
	
		
			
				|  |  |  		Doo::loadModel ( 'staff' );
 | 
	
	
		
			
				|  | @@ -278,16 +294,17 @@ class InvoiceController extends DooController {
 | 
	
		
			
				|  |  |  		
 | 
	
		
			
				|  |  |  		Doo::loadModel ( 'invoice' );
 | 
	
		
			
				|  |  |  		$invoice = new invoice ();
 | 
	
		
			
				|  |  | -		// Doo::loadModel('invoiceManage');
 | 
	
		
			
				|  |  | -		// $invoiceManage=new invoiceManage();
 | 
	
		
			
				|  |  | +		Doo::loadModel ( 'invoiceOperationLog' );
 | 
	
		
			
				|  |  | +		$invoiceOperationLog = new invoiceOperationLog ();
 | 
	
		
			
				|  |  |  		
 | 
	
		
			
				|  |  |  		$invoiceDetail = $invoice->getOne ( array (
 | 
	
		
			
				|  |  |  				'where' => 'status=1 and pendingApprovals=' . $this->staff [0] ['sid'] . ' and iid=' . $iid,
 | 
	
		
			
				|  |  |  				'asArray' => true 
 | 
	
		
			
				|  |  |  		) );
 | 
	
		
			
				|  |  | +		$invoiceOperationLogList = $invoiceOperationLog->getInvoiceOperationLogByIid ( $iid );
 | 
	
		
			
				|  |  |  		
 | 
	
		
			
				|  |  |  		$data ['invoiceDetail'] = $invoiceDetail;
 | 
	
		
			
				|  |  | -		
 | 
	
		
			
				|  |  | +		$data ['invoiceOperationLogList'] = $invoiceOperationLogList;
 | 
	
		
			
				|  |  |  		$data ['INVOICEKEY'] = $this->authcode ( $invoiceDetail ['iid'], '' );
 | 
	
		
			
				|  |  |  		$data ['memu'] = "invoice";
 | 
	
		
			
				|  |  |  		$data ['staff'] = $this->staff;
 | 
	
	
		
			
				|  | @@ -301,7 +318,6 @@ class InvoiceController extends DooController {
 | 
	
		
			
				|  |  |  	 * 对发票进行审批,其中操作有终止,退回,同意动作。操作成功并记录下操作日志
 | 
	
		
			
				|  |  |  	 *
 | 
	
		
			
				|  |  |  	 * @since 1.0.0
 | 
	
		
			
				|  |  | -	 *       
 | 
	
		
			
				|  |  |  	 * @var integer iid 开票ID 已加密
 | 
	
		
			
				|  |  |  	 * @var integer status 发票审批状态
 | 
	
		
			
				|  |  |  	 * @var integer opintion 审批发票的意见
 | 
	
	
		
			
				|  | @@ -394,6 +410,7 @@ class InvoiceController extends DooController {
 | 
	
		
			
				|  |  |  					'img' => $this->staff [0] ['avatar'],
 | 
	
		
			
				|  |  |  					'username' => $this->staff [0] ['username'],
 | 
	
		
			
				|  |  |  					'uid' => $this->staff [0] ['sid'],
 | 
	
		
			
				|  |  | +					'category' => $this->staff [0] ['category'],
 | 
	
		
			
				|  |  |  					'status' => $status,
 | 
	
		
			
				|  |  |  					'iid' => $iid 
 | 
	
		
			
				|  |  |  			);
 | 
	
	
		
			
				|  | @@ -403,6 +420,173 @@ class InvoiceController extends DooController {
 | 
	
		
			
				|  |  |  		}
 | 
	
		
			
				|  |  |  		die ( 'illegal request' );
 | 
	
		
			
				|  |  |  	}
 | 
	
		
			
				|  |  | +	
 | 
	
		
			
				|  |  | +	/**
 | 
	
		
			
				|  |  | +	 * 展示需要打印的发票数据
 | 
	
		
			
				|  |  | +	 *
 | 
	
		
			
				|  |  | +	 * @since 1.0.0
 | 
	
		
			
				|  |  | +	 */
 | 
	
		
			
				|  |  | +	function invoicePrint() {
 | 
	
		
			
				|  |  | +		Doo::loadModel ( 'invoice' );
 | 
	
		
			
				|  |  | +		$invoice = new invoice ();
 | 
	
		
			
				|  |  | +		Doo::loadClass ( 'XDeode' );
 | 
	
		
			
				|  |  | +		$XDeode = new XDeode ( 5 );
 | 
	
		
			
				|  |  | +		Doo::loadModel ( 'staff' );
 | 
	
		
			
				|  |  | +		$staff = new staff ();
 | 
	
		
			
				|  |  | +		
 | 
	
		
			
				|  |  | +		$toPrint = $invoice->find ( array (
 | 
	
		
			
				|  |  | +				'where' => 'status=2 ',
 | 
	
		
			
				|  |  | +				'desc' => 'iid',
 | 
	
		
			
				|  |  | +				'asArray' => true 
 | 
	
		
			
				|  |  | +		) );
 | 
	
		
			
				|  |  | +		
 | 
	
		
			
				|  |  | +		$printed = $invoice->find ( array (
 | 
	
		
			
				|  |  | +				'where' => 'status=5 ',
 | 
	
		
			
				|  |  | +				'desc' => 'iid',
 | 
	
		
			
				|  |  | +				'asArray' => true 
 | 
	
		
			
				|  |  | +		) );
 | 
	
		
			
				|  |  | +		
 | 
	
		
			
				|  |  | +		foreach ( $toPrint as $key => $value ) {
 | 
	
		
			
				|  |  | +			$toPrint [$key] ['iidKey'] = $XDeode->encode ( $value ['iid'] );
 | 
	
		
			
				|  |  | +			
 | 
	
		
			
				|  |  | +			$lastApprover = json_decode ( $value ['processApprovals'], true );
 | 
	
		
			
				|  |  | +			if (! empty ( $lastApprover )) {
 | 
	
		
			
				|  |  | +				$lastApproverKey = array_keys ( $lastApprover );
 | 
	
		
			
				|  |  | +				$lastApprover = end ( $lastApprover );
 | 
	
		
			
				|  |  | +				
 | 
	
		
			
				|  |  | +				$staffDetail = $staff->getOne ( array (
 | 
	
		
			
				|  |  | +						'where' => 'sid=' . end ( $lastApproverKey ),
 | 
	
		
			
				|  |  | +						'asArray' => true 
 | 
	
		
			
				|  |  | +				) );
 | 
	
		
			
				|  |  | +				$lastApprover ['username'] = $staffDetail ['username'];
 | 
	
		
			
				|  |  | +			}
 | 
	
		
			
				|  |  | +			$toPrint [$key] ['lastApprover'] = $lastApprover;
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +		
 | 
	
		
			
				|  |  | +		foreach ( $printed as $key => $value ) {
 | 
	
		
			
				|  |  | +			$printed [$key] ['iidKey'] = $XDeode->encode ( $value ['iid'] );
 | 
	
		
			
				|  |  | +			
 | 
	
		
			
				|  |  | +			$lastApprover = json_decode ( $value ['processApprovals'], true );
 | 
	
		
			
				|  |  | +			if (! empty ( $lastApprover )) {
 | 
	
		
			
				|  |  | +				$lastApproverKey = array_keys ( $lastApprover );
 | 
	
		
			
				|  |  | +				$lastApprover = end ( $lastApprover );
 | 
	
		
			
				|  |  | +				
 | 
	
		
			
				|  |  | +				$staffDetail = $staff->getOne ( array (
 | 
	
		
			
				|  |  | +						'where' => 'sid=' . end ( $lastApproverKey ),
 | 
	
		
			
				|  |  | +						'asArray' => true 
 | 
	
		
			
				|  |  | +				) );
 | 
	
		
			
				|  |  | +				$lastApprover ['username'] = $staffDetail ['username'];
 | 
	
		
			
				|  |  | +			}
 | 
	
		
			
				|  |  | +			$printed [$key] ['lastApprover'] = $lastApprover;
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +		
 | 
	
		
			
				|  |  | +		$data ['printed'] = $printed;
 | 
	
		
			
				|  |  | +		$data ['toPrint'] = $toPrint;
 | 
	
		
			
				|  |  | +		
 | 
	
		
			
				|  |  | +		$data ['memu'] = "invoice";
 | 
	
		
			
				|  |  | +		$data ['staff'] = $this->staff;
 | 
	
		
			
				|  |  | +		$data ['receiptMemu'] = 'invoicePrint';
 | 
	
		
			
				|  |  | +		$data ['verifyId'] = $this->verifyId;
 | 
	
		
			
				|  |  | +		$data ['executeId'] = $this->executeId;
 | 
	
		
			
				|  |  | +		$this->render ( "/admin/invoicePrint", $data );
 | 
	
		
			
				|  |  | +	}
 | 
	
		
			
				|  |  | +	/**
 | 
	
		
			
				|  |  | +	 * 展示发票打印的详情页面
 | 
	
		
			
				|  |  | +	 *
 | 
	
		
			
				|  |  | +	 * @since 1.0.0
 | 
	
		
			
				|  |  | +	 */
 | 
	
		
			
				|  |  | +	function invoicePrintDetail() {
 | 
	
		
			
				|  |  | +		Doo::loadClass ( 'XDeode' );
 | 
	
		
			
				|  |  | +		$XDeode = new XDeode ( 5 );
 | 
	
		
			
				|  |  | +		
 | 
	
		
			
				|  |  | +		$iid = isset ( $this->params ['iid'] ) ? $this->params ['iid'] : "";
 | 
	
		
			
				|  |  | +		$iid = $XDeode->decode ( $iid );
 | 
	
		
			
				|  |  | +		if (! is_numeric ( $iid ))
 | 
	
		
			
				|  |  | +			die ( 'illegal request' );
 | 
	
		
			
				|  |  | +		
 | 
	
		
			
				|  |  | +		Doo::loadModel ( 'invoice' );
 | 
	
		
			
				|  |  | +		$invoice = new invoice ();
 | 
	
		
			
				|  |  | +		Doo::loadModel ( 'invoiceOperationLog' );
 | 
	
		
			
				|  |  | +		$invoiceOperationLog = new invoiceOperationLog ();
 | 
	
		
			
				|  |  | +		
 | 
	
		
			
				|  |  | +		$invoiceDetail = $invoice->getOne ( array (
 | 
	
		
			
				|  |  | +				'where' => 'status=2 and iid=' . $iid,
 | 
	
		
			
				|  |  | +				'asArray' => true 
 | 
	
		
			
				|  |  | +		) );
 | 
	
		
			
				|  |  | +		
 | 
	
		
			
				|  |  | +		$invoiceOperationLogList = $invoiceOperationLog->getInvoiceOperationLogByIid ( $iid );
 | 
	
		
			
				|  |  | +		
 | 
	
		
			
				|  |  | +		$data ['invoiceDetail'] = $invoiceDetail;
 | 
	
		
			
				|  |  | +		$data ['invoiceOperationLogList'] = $invoiceOperationLogList;
 | 
	
		
			
				|  |  | +		$data ['INVOICEKEY'] = $this->authcode ( $invoiceDetail ['iid'], '' );
 | 
	
		
			
				|  |  | +		$data ['memu'] = "invoice";
 | 
	
		
			
				|  |  | +		$data ['staff'] = $this->staff;
 | 
	
		
			
				|  |  | +		$data ['receiptMemu'] = 'invoicePrint';
 | 
	
		
			
				|  |  | +		$data ['verifyId'] = $this->verifyId;
 | 
	
		
			
				|  |  | +		$data ['executeId'] = $this->executeId;
 | 
	
		
			
				|  |  | +		$this->render ( "/admin/invoicePrintDetail", $data );
 | 
	
		
			
				|  |  | +	}
 | 
	
		
			
				|  |  | +	/**
 | 
	
		
			
				|  |  | +	 * 填写票号并完成打印
 | 
	
		
			
				|  |  | +	 * @since 1.0.0
 | 
	
		
			
				|  |  | +	 */
 | 
	
		
			
				|  |  | +	function invoicePrintDo() {
 | 
	
		
			
				|  |  | +		$iid = $this->get_args ( 'invoiceKey' ) ? $this->get_args ( 'invoiceKey' ) : "";
 | 
	
		
			
				|  |  | +		$invoiceNo = $this->get_args ( 'invoiceNo' ) ? $this->get_args ( 'invoiceNo' ) : "";
 | 
	
		
			
				|  |  | +		$iid = $this->authcode ( $iid );
 | 
	
		
			
				|  |  | +		if (! is_numeric ( $iid ))
 | 
	
		
			
				|  |  | +			die ( 'illegal request' );
 | 
	
		
			
				|  |  | +		if (! empty ( $iid ) && ! empty ( $invoiceNo )) {
 | 
	
		
			
				|  |  | +			
 | 
	
		
			
				|  |  | +			Doo::loadModel ( 'invoice' );
 | 
	
		
			
				|  |  | +			$invoice = new invoice ();
 | 
	
		
			
				|  |  | +			Doo::loadModel ( 'invoiceOperationLog' );
 | 
	
		
			
				|  |  | +			$invoiceOperationLog = new invoiceOperationLog ();
 | 
	
		
			
				|  |  | +			
 | 
	
		
			
				|  |  | +			$invoicePrintDetail = $invoice->getInvoiceByPrint ( $iid );
 | 
	
		
			
				|  |  | +			if (empty ( $invoicePrintDetail ))
 | 
	
		
			
				|  |  | +				die ( 'illegal request' );
 | 
	
		
			
				|  |  | +			$item = array (
 | 
	
		
			
				|  |  | +					'iid' => $iid,
 | 
	
		
			
				|  |  | +					'status' => 5,
 | 
	
		
			
				|  |  | +					'updateTime'=>date ( "Y-m-d H:i:s" ),
 | 
	
		
			
				|  |  | +					'printTime'=>date ( "Y-m-d H:i:s" ),
 | 
	
		
			
				|  |  | +					'invoiceNo' => $invoiceNo 
 | 
	
		
			
				|  |  | +			);
 | 
	
		
			
				|  |  | +			$invoice->setPrintByInvoice ( $item );
 | 
	
		
			
				|  |  | +			$item = array (
 | 
	
		
			
				|  |  | +					'date' => date ( "Y-m-d H:i:s" ),
 | 
	
		
			
				|  |  | +					'operation' => $invoiceNo,
 | 
	
		
			
				|  |  | +					'status' => 5,
 | 
	
		
			
				|  |  | +					'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 "/invoicePrint";
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +	}
 | 
	
		
			
				|  |  | +	/**
 | 
	
		
			
				|  |  | +	 * 需要邮寄的发票
 | 
	
		
			
				|  |  | +	 * @since 1.0.0
 | 
	
		
			
				|  |  | +	 */
 | 
	
		
			
				|  |  | +	function invoicePost() {
 | 
	
		
			
				|  |  | +		Doo::loadModel ( 'invoice' );
 | 
	
		
			
				|  |  | +		$invoice = new invoice ();
 | 
	
		
			
				|  |  | +		
 | 
	
		
			
				|  |  | +		$invoicePost=$invoice->getPostByInvoice();
 | 
	
		
			
				|  |  | +		
 | 
	
		
			
				|  |  | +		$data ['invoicePost'] = $invoicePost;
 | 
	
		
			
				|  |  | +		
 | 
	
		
			
				|  |  | +		$data ['memu'] = "invoice";
 | 
	
		
			
				|  |  | +		$data ['staff'] = $this->staff;
 | 
	
		
			
				|  |  | +		$data ['receiptMemu'] = 'invoicePost';
 | 
	
		
			
				|  |  | +		$data ['verifyId'] = $this->verifyId;
 | 
	
		
			
				|  |  | +		$data ['executeId'] = $this->executeId;
 | 
	
		
			
				|  |  | +		$this->render ( "/admin/invoicePost", $data );
 | 
	
		
			
				|  |  | +	}
 | 
	
		
			
				|  |  |  	private function getExeCount() {
 | 
	
		
			
				|  |  |  		Doo::loadModel ( 'receipt' );
 | 
	
		
			
				|  |  |  		$receipt = new receipt ();
 | 
	
	
		
			
				|  | @@ -442,8 +626,7 @@ class InvoiceController extends DooController {
 | 
	
		
			
				|  |  |  	/**
 | 
	
		
			
				|  |  |  	 * 获取get或者POST值
 | 
	
		
			
				|  |  |  	 *
 | 
	
		
			
				|  |  | -	 * @param string $name
 | 
	
		
			
				|  |  | -	 *        	属性名称
 | 
	
		
			
				|  |  | +	 * @param string $name 属性名称
 | 
	
		
			
				|  |  |  	 * @return fixed 值
 | 
	
		
			
				|  |  |  	 */
 | 
	
		
			
				|  |  |  	function get_args($name) {
 | 
	
	
		
			
				|  | @@ -464,13 +647,10 @@ class InvoiceController extends DooController {
 | 
	
		
			
				|  |  |  	/**
 | 
	
		
			
				|  |  |  	 * 加密或解密指定字符串
 | 
	
		
			
				|  |  |  	 *
 | 
	
		
			
				|  |  | -	 * @param string $string
 | 
	
		
			
				|  |  | -	 *        	要加密或解密的字符串
 | 
	
		
			
				|  |  | -	 * @param string $operation
 | 
	
		
			
				|  |  | -	 *        	当取值为'DECODE'时表示解密,否则为加密
 | 
	
		
			
				|  |  | -	 * @param string $key
 | 
	
		
			
				|  |  | -	 *        	加解密的key
 | 
	
		
			
				|  |  | -	 * @param $expiry 超时值        	
 | 
	
		
			
				|  |  | +	 * @param string $string 要加密或解密的字符串
 | 
	
		
			
				|  |  | +	 * @param string $operation 当取值为'DECODE'时表示解密,否则为加密
 | 
	
		
			
				|  |  | +	 * @param string $key 加解密的key
 | 
	
		
			
				|  |  | +	 * @param $expiry 超时值
 | 
	
		
			
				|  |  |  	 *
 | 
	
		
			
				|  |  |  	 */
 | 
	
		
			
				|  |  |  	function authcode($string, $operation = 'DECODE', $key = '', $expiry = 0) {
 |