| 
					
				 | 
			
			
				@@ -9,9 +9,7 @@ class InvoiceController extends DooController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	public $executeId; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	public static $NEW = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	public static $NEW2 = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	private $INVOICEKEY="APPROVAL"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	function __construct() {  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		if(isset($_COOKIE["staff"])){ 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -124,8 +122,7 @@ class InvoiceController extends DooController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		$mailItems=$this->get_args('mailItems')?$this->get_args('mailItems'):""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		$remark=$this->get_args('remark')?$this->get_args('remark'):""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		//&&!empty($invoiceTitle)&&!empty($invoiceCompany)&&!empty($TIN)&&!empty($address) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		//   &&!empty($phone)&&!empty($bank)&&!empty($bankAccount)&&!empty($recipients)&&!empty($recipientsPhone)&&!empty($recipientsAddress) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		if(!empty($cid)&&!empty($invoicePrice)&&!empty($invoiceElement)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			Doo::loadModel('invoice'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			$invoice=new invoice(); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -182,6 +179,9 @@ class InvoiceController extends DooController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		$invoiceManage=new invoiceManage(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		$invoiceList=$invoice->find(array('where'=>'status=1 and pendingApprovals='.$this->staff[0]['sid'],'asArray'=>true)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		foreach ($invoiceList as $key=>$value){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			$invoiceList[$key]['iidKey']=base64_encode($value['iid']); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		$data['invoiceList']=$invoiceList; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -195,14 +195,15 @@ class InvoiceController extends DooController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	function invoiceDetail(){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		$iid=isset($this->params['iid'])&&is_numeric($this->params['iid'])?$this->params['iid']:0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		$iid=isset($this->params['iid'])?$this->params['iid']:""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		$iid=base64_decode($iid); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		Doo::loadModel('invoice'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		$invoice=new invoice(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		Doo::loadModel('invoiceManage'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		$invoiceManage=new invoiceManage(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		$invoiceDetail=$invoice->getOne(array('where'=>'status=1 and pendingApprovals='.$this->staff[0]['sid'],'asArray'=>true)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		$invoiceDetail=$invoice->getOne(array('where'=>'status=1 and pendingApprovals='.$this->staff[0]['sid'].' and iid='.$iid,'asArray'=>true)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		$invoiceManageDetail=$invoiceManage->getOne(array('SELECT'=>'title','where'=>'mold="发票审批"','asArray'=>true)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -211,6 +212,7 @@ class InvoiceController extends DooController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		$data['invoiceDetail']=$invoiceDetail; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		$data['INVOICEKEY']=$this->authcode($invoiceDetail['iid'],''); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		$data['memu']="invoice"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		$data['staff']=$this->staff; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		$data['receiptMemu']='invoiceApproval'; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -219,6 +221,27 @@ class InvoiceController extends DooController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		$this->render ( "/admin/invoiceApprovalDetail", $data ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	function invoiceApprovalDo(){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		$iid=$this->get_args('iid')?$this->get_args('iid'):""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		$status=$this->get_args('status')&&is_numeric($this->get_args('status'))?$this->get_args('status'):0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		$opinion=$this->get_args('opinion')?$this->get_args('opinion'):""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		if (!empty($iid)&&!empty($status)&&!empty($opinion)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			if (!($status==2||$status==3||$status==4)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				die('illegal request'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			Doo::loadModel('invoice'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			$invoice=new invoice(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			$iid=$this->authcode($iid); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			$invoice->getOne(array('where'=>'status=1 and iid='.$iid.' and pendingApprovals='.$this->staff[0]['sid'],'asArray'=>true)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			echo $iid.$status.$opinion; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	private function getExeCount(){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		Doo::loadModel('receipt'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		$receipt=new receipt(); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -272,67 +295,62 @@ class InvoiceController extends DooController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-function num_to_rmb($num){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        $c1 = "零壹贰叁肆伍陆柒捌玖"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        $c2 = "分角元拾佰仟万拾佰仟亿"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        //精确到分后面就不要了,所以只留两个小数位 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        $num = round($num, 2);  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        //将数字转化为整数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        $num = $num * 100; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        if (strlen($num) > 10) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                return "金额太大,请检查"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        }  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        $i = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        $c = ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        while (1) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                if ($i == 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        //获取最后一位数字 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        $n = substr($num, strlen($num)-1, 1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        $n = $num % 10; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                //每次将最后一位数字转化为中文 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                $p1 = substr($c1, 3 * $n, 3); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                $p2 = substr($c2, 3 * $i, 3); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                if ($n != '0' || ($n == '0' && ($p2 == '亿' || $p2 == '万' || $p2 == '元'))) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        $c = $p1 . $p2 . $c; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        $c = $p1 . $c; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                $i = $i + 1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                //去掉数字最后一位了 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                $num = $num / 10; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                $num = (int)$num; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                //结束循环 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                if ($num == 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                }  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        $j = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        $slen = strlen($c); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        while ($j < $slen) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                //utf8一个汉字相当3个字符 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                $m = substr($c, $j, 6); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                //处理数字中很多0的情况,每次循环去掉一个汉字“零” 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                if ($m == '零元' || $m == '零万' || $m == '零亿' || $m == '零零') { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        $left = substr($c, 0, $j); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        $right = substr($c, $j + 3); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        $c = $left . $right; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        $j = $j-3; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        $slen = $slen-3; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                }  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                $j = $j + 3; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        }  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        //这个是为了去掉类似23.0中最后一个“零”字 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        if (substr($c, strlen($c)-3, 3) == '零') { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                $c = substr($c, 0, strlen($c)-3); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        //将处理的汉字加上“整” 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        if (empty($c)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                return "零元整"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                return $c . "整"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+/** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ * 加密或解密指定字符串 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ * @param string $string 要加密或解密的字符串 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ * @param string $operation 当取值为'DECODE'时表示解密,否则为加密 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ * @param string $key 加解密的key 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ * @param $expiry 超时值 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ * */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+function authcode($string, $operation = 'DECODE', $key = '', $expiry = 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	$ckey_length = 4; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	if (! $key) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		$key = $this->INVOICEKEY; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	$key = md5 ( $key ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	$keya = md5 ( substr ( $key, 0, 16 ) ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	$keyb = md5 ( substr ( $key, 16, 16 ) ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	$keyc = $ckey_length ? ($operation == 'DECODE' ? substr ( $string, 0, $ckey_length ) : substr ( md5 ( microtime () ), - $ckey_length )) : ''; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	$cryptkey = $keya . md5 ( $keya . $keyc ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	$key_length = strlen ( $cryptkey ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	$string = $operation == 'DECODE' ? base64_decode ( substr ( $string, $ckey_length ) ) : sprintf ( '%010d', $expiry ? $expiry + time () : 0 ) . substr ( md5 ( $string . $keyb ), 0, 16 ) . $string; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	$string_length = strlen ( $string ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	$result = ''; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	$box = range ( 0, 255 ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	$rndkey = array (); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	for($i = 0; $i <= 255; $i ++) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		$rndkey [$i] = ord ( $cryptkey [$i % $key_length] ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	for($j = $i = 0; $i < 256; $i ++) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		$j = ($j + $box [$i] + $rndkey [$i]) % 256; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		$tmp = $box [$i]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		$box [$i] = $box [$j]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		$box [$j] = $tmp; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	for($a = $j = $i = 0; $i < $string_length; $i ++) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		$a = ($a + 1) % 256; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		$j = ($j + $box [$a]) % 256; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		$tmp = $box [$a]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		$box [$a] = $box [$j]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		$box [$j] = $tmp; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		$result .= chr ( ord ( $string [$i] ) ^ ($box [($box [$a] + $box [$j]) % 256]) ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	if ($operation == 'DECODE') { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		if ((substr ( $result, 0, 10 ) == 0 || substr ( $result, 0, 10 ) - time () > 0) && substr ( $result, 10, 16 ) == substr ( md5 ( substr ( $result, 26 ) . $keyb ), 0, 16 )) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			return substr ( $result, 26 ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		} else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			return ''; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	} else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		return $keyc . str_replace ( '=', '', base64_encode ( $result ) ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 |