浏览代码

no message

caipin 8 年之前
父节点
当前提交
c880d4522f
共有 1 个文件被更改,包括 100 次插入100 次删除
  1. 100 100
      protected/controller/InvoiceController.php

+ 100 - 100
protected/controller/InvoiceController.php

@@ -10,26 +10,26 @@ class InvoiceController extends DooController {
 	public static $NEW = 0;
 	public static $NEW2 = 0;
 	private $INVOICEKEY="APPROVAL";
-	
-	function __construct() { 
+
+	function __construct() {
 		if(isset($_COOKIE["staff"])){
-			
+
 			if(!empty($_COOKIE["staff"])){
-			
+
 				Doo::loadModel ( 'staff' );
 				Doo::loadModel('verify');
 				$verify=new verify();
 				$staff = new staff ();
 				Doo::loadModel("execute");
 				$execute=new execute();
-				
+				//2222
 				$verifyList=$verify->find(array('select'=>'staff','asArray'=>true));
 				$list=array();
-				
+
 				//判断角色的审批权限
 				foreach ($verifyList as $key=>$value){
 					$ver=json_decode($value['staff']);
-					
+
 					foreach ($ver as $k=>$v){
 						if ($v[1]=='ROLE'){
 							$roleList=json_decode($v[3]);
@@ -42,23 +42,23 @@ class InvoiceController extends DooController {
 							array_push($list, $v[0]);
 					}
 				}
-				
+
 				//判断执行人的审批权限
 				$executeList=$execute->find(array('select'=>'staff','asArray'=>true));
 				$list2=array();
 				foreach ($executeList as $key=>$value){
 					$ver=json_decode($value['staff']);
-					
+
 					foreach ($ver as $k=>$v){
 						array_push($list2, $v[0]);
 					}
 				}
-				
+
 				$eidList=file_get_contents("protected/config/execute/execute.ini");
 				$eidList=array_filter(explode(",", $eidList));
-				
+
 				$this->executeId= array_merge($list2,$eidList);
-				
+
 				$this->verifyId=$list;
 				$this->staff=$staff->getUserByIdList($_COOKIE["staff"]);
 				ReceiptController::$NEW= $this->getReceiptCount();
@@ -66,19 +66,19 @@ class InvoiceController extends DooController {
 				return "/";
 			}
 		}
-		
+
 		Doo::loadCore ( 'uri/DooUriRouter' );
 		$router = new DooUriRouter ();
 		$routeRs = $router->execute ( Doo::app ()->route, Doo::conf ()->SUBFOLDER );
-			
+
 		if($routeRs['1']!="login"){
 			header ( 'Content-Type:text/html;charset=utf-8' );
 			@header ( "Location: /login"  );
 		}
 	}
-	
+
 	function invoice(){
-		
+
 		$data['memu']="invoice";
 		$data['staff']=$this->staff;
 		$data['receiptMemu']='invoice';
@@ -86,15 +86,15 @@ class InvoiceController extends DooController {
 		$data['executeId']=$this->executeId;
 		$this->render ( "/admin/invoice", $data );
 	}
-	
+
 	function invoiceAdd(){
 		Doo::loadModel('L_category');
 		$lCategory=new L_category();
-		
+
 		$category=$lCategory->find(array('asArray'=>true));
-		
+
 		$data['category']=$category;
-		
+
 		$data['memu']="invoice";
 		$data['staff']=$this->staff;
 		$data['receiptMemu']='invoice';
@@ -102,7 +102,7 @@ class InvoiceController extends DooController {
 		$data['executeId']=$this->executeId;
 		$this->render ( "/admin/invoiceAdd", $data );
 	}
-	
+
 	function invoiceAddDo(){
 		$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;
@@ -119,10 +119,10 @@ class InvoiceController extends DooController {
 		$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'):"";
-		
+
 		$mailItems=$this->get_args('mailItems')?$this->get_args('mailItems'):"";
 		$remark=$this->get_args('remark')?$this->get_args('remark'):"";
-		
+
 		if(!empty($cid)&&!empty($invoicePrice)&&!empty($invoiceElement)){
 			Doo::loadModel('invoice');
 			$invoice=new invoice();
@@ -130,32 +130,32 @@ class InvoiceController extends DooController {
 			$lCategory=new L_category();
 			Doo::loadModel('invoiceManage');
 			$invoiceManage=new invoiceManage();
-			
+
 			$categoryDetil=$lCategory->getOne(array('SELECT'=>'title','where'=>'cid='.$cid,'asArray'=>true));
 			$invoiceManageDetail=$invoiceManage->getOne(array('SELECT'=>'title','where'=>'mold="发票审批"','asArray'=>true));
-			
+
 			$invoice->cid=$cid;
 			$invoice->categoryName=$categoryDetil['title'];
 			$invoice->invoiceElement=$invoiceElement;
 			$invoice->invoicePrice=$invoicePrice;
-			
+
 			$invoice->invoiceType=$invoiceType;
 			if ($invoiceType==0)
-				$invoice->invoiceTitle=$invoiceTitle;	
+				$invoice->invoiceTitle=$invoiceTitle;
 			elseif ($invoiceType==1){
-				$invoice->invoiceTitle=$invoiceCompany;	
-				$invoice->TIN=$TIN;	
-				$invoice->address=$address;	
-				$invoice->phone=$phone;	
-				$invoice->bank=$bank;	
-				$invoice->bankAccount=$$bankAccount;	
+				$invoice->invoiceTitle=$invoiceCompany;
+				$invoice->TIN=$TIN;
+				$invoice->address=$address;
+				$invoice->phone=$phone;
+				$invoice->bank=$bank;
+				$invoice->bankAccount=$$bankAccount;
 			}
-			
+
 			$invoice->doPost=$doPost;
 			if ($doPost==1){
 				$invoice->recipients=$recipients;
 				$invoice->recipientsPhone=$recipientsPhone;
-				$invoice->recipientsAddress=$recipientsAddress;	
+				$invoice->recipientsAddress=$recipientsAddress;
 			}
 			$invoice->status=1;
 			$invoice->invoiceSerial="#F".date("Ymd").mt_rand(1000,9999);
@@ -167,26 +167,26 @@ class InvoiceController extends DooController {
 			$invoice->pendingApprovals=$staffId[0][0];
 			$invoice->insert();
 		}
-		
+
 		return "/invoice";
 	}
-	
+
 	function invoiceApproval(){
-		
+
 		Doo::loadModel('invoice');
 		$invoice=new invoice();
 		Doo::loadModel('invoiceManage');
 		$invoiceManage=new invoiceManage();
 		Doo::loadClass('XDeode');
 		$XDeode=new XDeode(5);
-		
+
 		$invoiceList=$invoice->find(array('where'=>'status=1 and pendingApprovals='.$this->staff[0]['sid'],'asArray'=>true));
 		foreach ($invoiceList as $key=>$value){
 			$invoiceList[$key]['iidKey']=$XDeode->encode($value['iid']);//base64_encode($value['iid']);
 		}
-		
+
 		$data['invoiceList']=$invoiceList;
-		
+
 		$data['memu']="invoice";
 		$data['staff']=$this->staff;
 		$data['receiptMemu']='invoiceApproval';
@@ -194,29 +194,29 @@ class InvoiceController extends DooController {
 		$data['executeId']=$this->executeId;
 		$this->render ( "/admin/invoiceApproval", $data );
 	}
-	
+
 	function invoiceDetail(){
 		Doo::loadClass('XDeode');
 		$XDeode=new XDeode(5);
-		
+
 		$iid=isset($this->params['iid'])?$this->params['iid']:"";
 		$iid=$XDeode->decode($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'].' and iid='.$iid,'asArray'=>true));
-		
+
 		$invoiceManageDetail=$invoiceManage->getOne(array('SELECT'=>'title','where'=>'mold="发票审批"','asArray'=>true));
-		
+
 		$a=json_decode($invoiceManageDetail['staff']);
-		
-		
+
+
 		$data['invoiceDetail']=$invoiceDetail;
-		
+
 		$data['INVOICEKEY']=$this->authcode($invoiceDetail['iid'],'');
 		$data['memu']="invoice";
 		$data['staff']=$this->staff;
@@ -225,26 +225,26 @@ class InvoiceController extends DooController {
 		$data['executeId']=$this->executeId;
 		$this->render ( "/admin/invoiceApprovalDetail", $data );
 	}
-	
+
 	function invoiceApprovalDo(){
 		$iid=$this->get_args('invoiceKey')?$this->get_args('invoiceKey'):"";
 		$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);
 			$invoiceDetail=$invoice->getOne(array('where'=>'status=1 and iid='.$iid.' and pendingApprovals='.$this->staff[0]['sid'],'asArray'=>true));
 			if (empty($invoiceDetail))
 				die('illegal request');
 
-			$processApprovals=json_decode($invoiceDetail['processApprovals'],true);	
-			$invoiceManage=json_decode($invoiceDetail['invoiceManage'],true);	
-			
+			$processApprovals=json_decode($invoiceDetail['processApprovals'],true);
+			$invoiceManage=json_decode($invoiceDetail['invoiceManage'],true);
+
 			$invoice->status=$status;
 			if ($status==3){
 				//操作日志
@@ -257,17 +257,17 @@ class InvoiceController extends DooController {
 						$invoice->pendingApprovals=$invoiceManage[1][0];
 					$invoice->processApprovals=$processApprovals;
 				}else{
-					
+
 					$processApprovals[$this->staff[0]['sid']]=array('date'=>date('Y-m-d'),'opinion'=>$opinion,'status'=>$status);
 					if($status!=4)
 						$invoice->pendingApprovals=$invoiceManage[1][0];
-						
+
 					$invoice->processApprovals=$processApprovals;
 				}
-			}	
-			
+			}
+
 			print_r($processApprovals);
-			
+
 			//$invoice->
 			/*
 			if (isset($verifyStaff['final'])){//rDetail
@@ -275,18 +275,18 @@ class InvoiceController extends DooController {
 				$receipt->status=3;
 				$receiptDetailObj->status=3;
 				$receiptDetailObj->update(array('where'=>'rid='.$rid));
-				
-				
-				
-				
+
+
+
+
 				if (!empty($roleId)){
 					Doo::loadModel("role");
 					$role=new role();
 					$roleInfo=$role->getOne(array('where'=>'rid='.$roleId,'asArray'=>true));
-					
+
 					$receiptLog->rolename=$roleInfo['name'];
 				}
-				
+
 				$receiptLog->username=$this->staff[0]['username'];
 				$receiptLog->uid=$this->staff[0]['sid'];
 				$receiptLog->date=date("Y-m-d");
@@ -295,14 +295,14 @@ class InvoiceController extends DooController {
 				$receiptLog->status=3;
 				$receiptLog->rid=$rid;
 				$receiptLog->insert();
-				
-				
+
+
 			}elseif(count($verifyStaff)==count($verifyDetail)){//要修改 角色的数量
 				$receipt->status=1;$reviseSum=0;
 				$receipt->verifyBreakup=$verifyString;
 				if(!empty($receiptDetail['reviseDetail'])){//statistics item rDetail
 					$reviseDetail=json_decode($receiptDetail['reviseDetail'],true);
-					
+
 					foreach ($reviseDetail as $key=>$value){
 						$receiptDetailObj=new receiptDetail();
 						$receiptDetailObj->staff=$receiptDetail['staff'];// $this->staff[0]['sid'];
@@ -316,7 +316,7 @@ class InvoiceController extends DooController {
 						$receiptDetailObj->insert();
 						$reviseSum+=$value['price'];
 					}
-					
+
 					$itemStatistics=new itemStatistics();
 					$itemStatistics->cid=$receiptDetail['cid'];//$this->staff[0]['cid'];
 					$itemStatistics->staff=$receiptDetail['staff'];//$this->staff[0]['sid'];
@@ -329,7 +329,7 @@ class InvoiceController extends DooController {
 				$receiptDetailObj->status=1;
 				$receiptDetailObj->pastDate=date("Y-m-d");
 				$receiptDetailObj->update(array('where'=>'rid='.$rid));
-				
+
 				$dateArray=explode("-", $receiptDetail['date']);
 				$dateCondition=" and Year(date) =".$dateArray[0]." and Month(date) = ".$dateArray[1];
 				$stat=$statistics->getOne(array('where'=>'staff='.$receiptDetail['staff'].$dateCondition,'asArray'=>true));
@@ -345,9 +345,9 @@ class InvoiceController extends DooController {
 					$statistics->rePrice=$stat['rePrice']+$reviseSum;
 					$statistics->update(array('where'=>'sid='.$stat['sid']));
 				}
-				
+
 				$dateArray=explode("-", $receiptDetail['date']);
-				$dateCondition=" and Year(date) =".$dateArray[0]." and Month(date) = ".$dateArray[1];	
+				$dateCondition=" and Year(date) =".$dateArray[0]." and Month(date) = ".$dateArray[1];
 				$accountItem=json_decode($receiptDetail['accountItem'],true);
 				foreach ($accountItem['cSum'] as $key=>$value){
 				if($key=="agencySum"){
@@ -414,46 +414,46 @@ class InvoiceController extends DooController {
 			}
 				$receipt->pastDate=date("Y-m-d");
 			}
-				
+
 				*/
-				
-				
+
+
 			echo $iid.$status.$opinion;
-			
+
 		}
 	}
-	
+
 	private function getExeCount(){
 		Doo::loadModel('receipt');
 		$receipt=new receipt();
 		$receiptList=$receipt->find(array('where'=>'(executeCopy like \'%["'.$this->staff[0]['sid'].'%\' and executeStaff NOT LIKE \'%'.$this->staff[0]['sid'].'%\' ) and (status=1 or status=6)','desc'=>'rid','asArray'=>true));
-		
+
 		return count($receiptList);
 	}
-	
+
 	private function getReceiptCount(){
-		
+
 		$status=2;
 		$year=date('Y');
-		
+
 		Doo::loadModel('receipt');
 		$receipt=new receipt();
 		Doo::loadModel('verify');
 
-		$dateCondition=" and Year(date) =".$year;	
-		
+		$dateCondition=" and Year(date) =".$year;
+
 		$approvalCondition=' and nowStaff like "%'.$this->staff[0]['sid'].'%" ';
 		$receiptList=$receipt->find(array('where'=>' status='.$status.$dateCondition.$approvalCondition,'desc'=>'rid','asArray'=>true));
-		
+
 		return count($receiptList);
 	}
-	
+
 	function _GetFileEXT($filename) {
 		$pics = explode ( '.', $filename );
 		$num = count ( $pics );
 		return $pics [$num - 1];
 	}
-    
+
 	/**
 	 * 获取get或者POST值
 	 * @param string $name 属性名称
@@ -463,19 +463,19 @@ class InvoiceController extends DooController {
 		if (isset ( $_GET [$name] )) {
 			if (is_array ( $_GET [$name] ))
 				return $_GET [$name];
-			else 
+			else
 				return addslashes ( $_GET [$name] );
-				
+
 		} elseif (isset ( $_POST [$name] )) {
 			if (is_array ( $_POST [$name] ))
 				return $_POST [$name];
-			else 
+			else
 				return addslashes ( $_POST [$name] );
 		} else
 			return false;
 	}
 
-	
+
 /**
  * 加密或解密指定字符串
  * @param string $string 要加密或解密的字符串
@@ -492,28 +492,28 @@ function authcode($string, $operation = 'DECODE', $key = '', $expiry = 0) {
 	$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;
@@ -522,7 +522,7 @@ function authcode($string, $operation = 'DECODE', $key = '', $expiry = 0) {
 		$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 );