|  | @@ -48,24 +48,10 @@ class ReceiptController extends DooController {
 | 
	
		
			
				|  |  |  		
 | 
	
		
			
				|  |  |  		Doo::loadModel('receipt');
 | 
	
		
			
				|  |  |  		$receipt=new receipt();
 | 
	
		
			
				|  |  | -		Doo::loadModel('verify');
 | 
	
		
			
				|  |  | -//		$verify=new verify();
 | 
	
		
			
				|  |  | -//		
 | 
	
		
			
				|  |  | -//		//user verify ID
 | 
	
		
			
				|  |  | -//		$vidList=array();
 | 
	
		
			
				|  |  | -//		$verifyDetail=$verify->find(array('where'=>'staff like "%\"'.$this->staff[0]['sid'].'\"%"','asArray'=>true));
 | 
	
		
			
				|  |  | -//		foreach ($verifyDetail as $key=>$value){
 | 
	
		
			
				|  |  | -//			array_push($vidList, $value['vid']);
 | 
	
		
			
				|  |  | -//		}
 | 
	
		
			
				|  |  | -//		$vid=implode(",", $vidList);
 | 
	
		
			
				|  |  | -//		if(empty($verifyDetail))
 | 
	
		
			
				|  |  | -//			$vid=0;
 | 
	
		
			
				|  |  | -		
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  		$dateCondition=" and Year(date) =".$year;	
 | 
	
		
			
				|  |  | -		//$approvalCondition=' and verifyStaff not like "%\"'.$this->staff[0]['sid'].'\":{%" ';
 | 
	
		
			
				|  |  | -			
 | 
	
		
			
				|  |  | -		//$receiptList=$receipt->find(array('where'=>'verify in('.$vid.') and status='.$status.$dateCondition.$approvalCondition,'desc'=>'rid','asArray'=>true));
 | 
	
		
			
				|  |  | -		$approvalCondition=' and nowStaff like "%'.$this->staff[0]['sid'].'%" ';
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +		$approvalCondition=' and (nowStaff like "%,'.$this->staff[0]['sid'].'%" or nowStaff like "%'.$this->staff[0]['sid'].',%" or nowStaff='.$this->staff[0]['sid'].' ) ';
 | 
	
		
			
				|  |  |  		$receiptList=$receipt->find(array('where'=>' status='.$status.$dateCondition.$approvalCondition,'desc'=>'rid','asArray'=>true));
 | 
	
		
			
				|  |  |  		
 | 
	
		
			
				|  |  |  		return count($receiptList);
 | 
	
	
		
			
				|  | @@ -2293,7 +2279,7 @@ class ReceiptController extends DooController {
 | 
	
		
			
				|  |  |  		$Lcategory=new L_category();
 | 
	
		
			
				|  |  |  		
 | 
	
		
			
				|  |  |  		//user verify ID
 | 
	
		
			
				|  |  | -		$verifyDetail=$verify->find(array('where'=>'staff like "%\"'.$this->staff[0]['sid'].'%"','asArray'=>true));
 | 
	
		
			
				|  |  | +$verifyDetail=$verify->find(array('where'=>' (staff not like "%\"'.$this->staff[0]['sid'].'\",\"ROLE%") and (staff like "%[\"'.$this->staff[0]['sid'].'\",%" or staff like "%\"'.$this->staff[0]['sid'].'\_%" )','asArray'=>true));
 | 
	
		
			
				|  |  |  		foreach ($verifyDetail as $key=>$value){
 | 
	
		
			
				|  |  |  			array_push($vidList, $value['vid']);
 | 
	
		
			
				|  |  |  		}
 | 
	
	
		
			
				|  | @@ -2323,7 +2309,7 @@ class ReceiptController extends DooController {
 | 
	
		
			
				|  |  |  		$approvalCondition=" and status=".$status;
 | 
	
		
			
				|  |  |  		if($status==2){
 | 
	
		
			
				|  |  |  			//查找角色审批人
 | 
	
		
			
				|  |  | -			$approvalCondition=' and status='.$status.' and nowStaff like "%'.$this->staff[0]['sid'].'%" ';
 | 
	
		
			
				|  |  | +			$approvalCondition=' and status='.$status.' and (nowStaff like "%,'.$this->staff[0]['sid'].'%" or nowStaff like "%'.$this->staff[0]['sid'].',%" or nowStaff='.$this->staff[0]['sid'].' )';
 | 
	
		
			
				|  |  |  		}
 | 
	
		
			
				|  |  |  		
 | 
	
		
			
				|  |  |  		if($status==5){//and verifyStaff like "%\"'.$this->staff[0]['sid'].'\":{%"
 | 
	
	
		
			
				|  | @@ -2341,11 +2327,12 @@ class ReceiptController extends DooController {
 | 
	
		
			
				|  |  |  			
 | 
	
		
			
				|  |  |  			$receiptList=$receipt->find(array('where'=>'status!=5  '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')'
 | 
	
		
			
				|  |  |  			,'limit'=>$pageinfo ['lower'].','.$page_size,'desc'=>'rid','asArray'=>true));
 | 
	
		
			
				|  |  | +			//echo 'status!=5  '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
 | 
	
		
			
				|  |  |  		}else
 | 
	
		
			
				|  |  |  		$receiptList=$receipt->find(array('where'=>'status!=5 '.$dateCondition.$cateCondition.$staffCondition.$approvalCondition.' and verify in ('.$vid.')'
 | 
	
		
			
				|  |  |  		,'desc'=>'rid','asArray'=>true));
 | 
	
		
			
				|  |  |  		
 | 
	
		
			
				|  |  | -		$rLRes=$receipt->find(array('where'=>'status=2 and nowStaff like "%'.$this->staff[0]['sid'].'%" '.$cateCondition.$staffCondition
 | 
	
		
			
				|  |  | +		$rLRes=$receipt->find(array('where'=>'status=2 and (nowStaff like "%,'.$this->staff[0]['sid'].'%" or nowStaff like "%'.$this->staff[0]['sid'].',%" or nowStaff='.$this->staff[0]['sid'].' )'.$cateCondition.$staffCondition
 | 
	
		
			
				|  |  |  		,'desc'=>'rid','asArray'=>true));
 | 
	
		
			
				|  |  |  		
 | 
	
		
			
				|  |  |  		//echo '1 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
 | 
	
	
		
			
				|  | @@ -4447,7 +4434,7 @@ class ReceiptController extends DooController {
 | 
	
		
			
				|  |  |  		
 | 
	
		
			
				|  |  |  		if (!empty($rid)){
 | 
	
		
			
				|  |  |  			
 | 
	
		
			
				|  |  | -			$rLRes=$receipt->find(array('where'=>'status=2 and nowStaff like "%'.$this->staff[0]['sid'].'%" and rid!='.$rid
 | 
	
		
			
				|  |  | +			$rLRes=$receipt->find(array('where'=>'status=2 and (nowStaff like "%,'.$this->staff[0]['sid'].'%" or nowStaff like "%'.$this->staff[0]['sid'].',%" or nowStaff='.$this->staff[0]['sid'].' ) and rid!='.$rid
 | 
	
		
			
				|  |  |  		,'asArray'=>true));
 | 
	
		
			
				|  |  |  		 echo json_encode(array('status'=>1,'receipt'=>$rLRes[0]));die; 	
 | 
	
		
			
				|  |  |  		}
 | 
	
	
		
			
				|  | @@ -5427,7 +5414,7 @@ class ReceiptController extends DooController {
 | 
	
		
			
				|  |  |  		
 | 
	
		
			
				|  |  |  		if($status==2){
 | 
	
		
			
				|  |  |  			//查找角色审批人
 | 
	
		
			
				|  |  | -			$approvalCondition=' and nowStaff like "%'.$this->staff[0]['sid'].'%" ';
 | 
	
		
			
				|  |  | +			$approvalCondition=' and (nowStaff like "%,'.$this->staff[0]['sid'].'%" or nowStaff like "%'.$this->staff[0]['sid'].',%" or nowStaff='.$this->staff[0]['sid'].' ) ';
 | 
	
		
			
				|  |  |  		}
 | 
	
		
			
				|  |  |  		$ap="";
 | 
	
		
			
				|  |  |  		if($status==4){
 | 
	
	
		
			
				|  | @@ -8529,6 +8516,164 @@ class ReceiptController extends DooController {
 | 
	
		
			
				|  |  |  		$this->render ( "/admin/saeaStaffCollectDetail", $data );
 | 
	
		
			
				|  |  |  	}
 | 
	
		
			
				|  |  |  	
 | 
	
		
			
				|  |  | +	function BUGFLAG(){
 | 
	
		
			
				|  |  | +		$status=isset($this->params['status'])&&is_numeric($this->params['status'])?$this->params['status']:0;
 | 
	
		
			
				|  |  | +		$year=$this->get_args('year')?$this->get_args('year'):date('Y');
 | 
	
		
			
				|  |  | +		$month=$this->get_args('month')?$this->get_args('month'):"";
 | 
	
		
			
				|  |  | +		$cid=$this->get_args('cid')?$this->get_args('cid'):0;
 | 
	
		
			
				|  |  | +		$sid=$this->get_args('sid')?$this->get_args('sid'):0;
 | 
	
		
			
				|  |  | +		
 | 
	
		
			
				|  |  | +		if (empty($status))
 | 
	
		
			
				|  |  | +			$status=$this->get_args('status')&&is_numeric($this->get_args('status'))?$this->get_args('status'):0;
 | 
	
		
			
				|  |  | +			
 | 
	
		
			
				|  |  | +		$page_size=12;	
 | 
	
		
			
				|  |  | +		$page = isset($this->params ['page'])&&is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;	
 | 
	
		
			
				|  |  | +			
 | 
	
		
			
				|  |  | +		$vidList=array();
 | 
	
		
			
				|  |  | +		$button=0;
 | 
	
		
			
				|  |  | +		
 | 
	
		
			
				|  |  | +		Doo::loadModel('verify');
 | 
	
		
			
				|  |  | +		$verify=new verify();
 | 
	
		
			
				|  |  | +		Doo::loadModel('receipt');
 | 
	
		
			
				|  |  | +		$receipt=new receipt();
 | 
	
		
			
				|  |  | +		Doo::loadModel('staff');
 | 
	
		
			
				|  |  | +		$staff=new staff();
 | 
	
		
			
				|  |  | +		Doo::loadModel('L_category');
 | 
	
		
			
				|  |  | +		$Lcategory=new L_category();
 | 
	
		
			
				|  |  | +		
 | 
	
		
			
				|  |  | +		
 | 
	
		
			
				|  |  | +			$dateCondition=" and Year(date) =".$year;
 | 
	
		
			
				|  |  | +		
 | 
	
		
			
				|  |  | +		if(!empty($month))
 | 
	
		
			
				|  |  | +			$dateCondition=" and Year(date) =".$year." and Month(date) = ".$month;		
 | 
	
		
			
				|  |  | +			
 | 
	
		
			
				|  |  | +		$categoryList=$Lcategory->find(array('asArray'=>true));	
 | 
	
		
			
				|  |  | +		$staffList=$staff->find(array('where'=>'cid='.$cid,'asArray'=>true));
 | 
	
		
			
				|  |  | +		$cateCondition="";$staffCondition="";$approvalCondition="";
 | 
	
		
			
				|  |  | +		if (!empty($cid))
 | 
	
		
			
				|  |  | +			$cateCondition=' and cid='.$cid;
 | 
	
		
			
				|  |  | +		if(!empty($sid)){
 | 
	
		
			
				|  |  | +			$staffCondition=' and staff='.$sid;
 | 
	
		
			
				|  |  | +			$cateCondition="";
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +		
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +		$approvalCondition=" and status=".$status;
 | 
	
		
			
				|  |  | +		if($status==2){
 | 
	
		
			
				|  |  | +			//查找角色审批人
 | 
	
		
			
				|  |  | +			$approvalCondition=' and status='.$status.' and (nowStaff like "%,'.$this->staff[0]['sid'].'%" or nowStaff like "%'.$this->staff[0]['sid'].',%" or nowStaff='.$this->staff[0]['sid'].' )';
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +		
 | 
	
		
			
				|  |  | +		if($status==5){//and verifyStaff like "%\"'.$this->staff[0]['sid'].'\":{%"
 | 
	
		
			
				|  |  | +			$approvalCondition=' and status=2  ';
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +		
 | 
	
		
			
				|  |  | +		if($status==1){
 | 
	
		
			
				|  |  | +			$approvalCondition=' and (status='.$status.' or status=6)  ';
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +		
 | 
	
		
			
				|  |  | +		//nowStaff like "%'.$this->staff[0]['sid'].'%"
 | 
	
		
			
				|  |  | +		$pageinfo['page']=array('previous'=>'');
 | 
	
		
			
				|  |  | +		if ($status==0){
 | 
	
		
			
				|  |  | +			$pageinfo=$this->get_page("CLD_receipt", $dateCondition.$cateCondition.$staffCondition.'  and status!=5', $page, $page_size, "approvalExpenses","","");	
 | 
	
		
			
				|  |  | +			
 | 
	
		
			
				|  |  | +			$receiptList=$receipt->find(array('where'=>'status!=5  '.$dateCondition.$cateCondition.$staffCondition
 | 
	
		
			
				|  |  | +			,'limit'=>$pageinfo ['lower'].','.$page_size,'desc'=>'rid','asArray'=>true));
 | 
	
		
			
				|  |  | +			//echo 'status!=5  '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
 | 
	
		
			
				|  |  | +		}else
 | 
	
		
			
				|  |  | +		$receiptList=$receipt->find(array('where'=>'status!=5 '.$dateCondition.$cateCondition.$staffCondition.$approvalCondition
 | 
	
		
			
				|  |  | +		,'desc'=>'rid','asArray'=>true));
 | 
	
		
			
				|  |  | +		
 | 
	
		
			
				|  |  | +		$rLRes=$receipt->find(array('where'=>'status=2 and (nowStaff like "%,'.$this->staff[0]['sid'].'%" or nowStaff like "%'.$this->staff[0]['sid'].',%" or nowStaff='.$this->staff[0]['sid'].' )'.$cateCondition.$staffCondition
 | 
	
		
			
				|  |  | +		,'desc'=>'rid','asArray'=>true));
 | 
	
		
			
				|  |  | +		
 | 
	
		
			
				|  |  | +		//echo '1 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
 | 
	
		
			
				|  |  | +		//print_r($pageinfo);
 | 
	
		
			
				|  |  | +		
 | 
	
		
			
				|  |  | +		$Locate=0;
 | 
	
		
			
				|  |  | +		
 | 
	
		
			
				|  |  | +		foreach ($receiptList as $key=>$value){
 | 
	
		
			
				|  |  | +			$receiptList[$key]['Locate']=$Locate;$Locate++;
 | 
	
		
			
				|  |  | +			$receiptList[$key]['reviseDetail']=array();
 | 
	
		
			
				|  |  | +			if (!empty($value['reviseDetail']))
 | 
	
		
			
				|  |  | +				$receiptList[$key]['reviseDetail']=json_decode($value['reviseDetail'],true);
 | 
	
		
			
				|  |  | +			$receiptList[$key]['accountItem']=json_decode($value['accountItem'],true);
 | 
	
		
			
				|  |  | +			$categoryDetil=$Lcategory->getOne(array('where'=>'cid='.$value['cid'],'asArray'=>true));
 | 
	
		
			
				|  |  | +			$receiptList[$key]['category']=$categoryDetil['title'];
 | 
	
		
			
				|  |  | +			$verifyList=$verify->getOne(array('where'=>'vid='.$value['verify'],'asArray'=>true));
 | 
	
		
			
				|  |  | +			$verifyList=json_decode($verifyList['staff'],true);//status opinion
 | 
	
		
			
				|  |  | +			$verifyStaff=json_decode($value['verifyStaff'],true);
 | 
	
		
			
				|  |  | +			foreach ($verifyList as $k=>$v){
 | 
	
		
			
				|  |  | +				//init verifyStaff
 | 
	
		
			
				|  |  | +				$verifyList[$k]['date']="";
 | 
	
		
			
				|  |  | +				$verifyList[$k]['opinion']="";
 | 
	
		
			
				|  |  | +				$verifyList[$k]['status']="";
 | 
	
		
			
				|  |  | +				if (empty($verifyStaff)){
 | 
	
		
			
				|  |  | +					$verifyList[$k]['date']="";
 | 
	
		
			
				|  |  | +					$verifyList[$k]['opinion']="";
 | 
	
		
			
				|  |  | +					if ($v[0]==$this->staff[0]['sid']){
 | 
	
		
			
				|  |  | +						$verifyList[$k]['status']=4;
 | 
	
		
			
				|  |  | +						$button=4;
 | 
	
		
			
				|  |  | +					}
 | 
	
		
			
				|  |  | +				}else{
 | 
	
		
			
				|  |  | +					$flag=true;
 | 
	
		
			
				|  |  | +					foreach ($verifyStaff as $m=>$u){
 | 
	
		
			
				|  |  | +						if ($v[0]==$m){
 | 
	
		
			
				|  |  | +							$verifyList[$k]['date']=$u['date'];
 | 
	
		
			
				|  |  | +							$verifyList[$k]['opinion']=$u['opinion'];
 | 
	
		
			
				|  |  | +							$verifyList[$k]['status']=$u['status'];
 | 
	
		
			
				|  |  | +							$flag=false;
 | 
	
		
			
				|  |  | +							break;
 | 
	
		
			
				|  |  | +						}
 | 
	
		
			
				|  |  | +//						elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
 | 
	
		
			
				|  |  | +//						if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
 | 
	
		
			
				|  |  | +//						if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
 | 
	
		
			
				|  |  | +					}
 | 
	
		
			
				|  |  | +					if($flag){//检测可编辑
 | 
	
		
			
				|  |  | +						if($v[0]==$this->staff[0]['sid']){
 | 
	
		
			
				|  |  | +							$verifyList[$k]['status']=4;$button=4;
 | 
	
		
			
				|  |  | +						}
 | 
	
		
			
				|  |  | +					}
 | 
	
		
			
				|  |  | +				}
 | 
	
		
			
				|  |  | +			}
 | 
	
		
			
				|  |  | +			$receiptList[$key]['verifyList']=$verifyList;
 | 
	
		
			
				|  |  | +			$receiptList[$key]['staffDetail']=$staff->getOne(array('where'=>'sid='.$value['staff'],'asArray'=>true));
 | 
	
		
			
				|  |  | +			$receiptList[$key]['button']=$button;
 | 
	
		
			
				|  |  | +			$receiptList[$key]['nowStaffArray']=explode(',',$value['nowStaff']); 
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +		//print_r($receiptList);die;
 | 
	
		
			
				|  |  | +		//$data['verifyDetail']=$verifyDetail;
 | 
	
		
			
				|  |  | +		
 | 
	
		
			
				|  |  | +		$mothHtml="";
 | 
	
		
			
				|  |  | +		for($i=1;$i<=12;$i++){
 | 
	
		
			
				|  |  | +			if($month==$i)
 | 
	
		
			
				|  |  | +				$mothHtml.='<option selected value="'.$i.'">'.$i.'月</option>';
 | 
	
		
			
				|  |  | +			else
 | 
	
		
			
				|  |  | +				$mothHtml.='<option value="'.$i.'">'.$i.'月</option>';
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +		$data['mothHtml']=$mothHtml;
 | 
	
		
			
				|  |  | +		
 | 
	
		
			
				|  |  | +		$data['page']=$pageinfo;
 | 
	
		
			
				|  |  | +		$data['receiptList']=$receiptList;
 | 
	
		
			
				|  |  | +		$data['receiptApprovalCount']=count($rLRes);
 | 
	
		
			
				|  |  | +		$data['status']=$status;
 | 
	
		
			
				|  |  | +		$data['year']=$year;
 | 
	
		
			
				|  |  | +		$data['categoryList']=$categoryList;
 | 
	
		
			
				|  |  | +		$data['staffList']=$staffList;
 | 
	
		
			
				|  |  | +		$data['cid']=$cid;
 | 
	
		
			
				|  |  | +		$data['sid']=$sid;
 | 
	
		
			
				|  |  | +		
 | 
	
		
			
				|  |  | +		//print_r($receiptList);
 | 
	
		
			
				|  |  | +		
 | 
	
		
			
				|  |  | +		$data['memu']="receipt";
 | 
	
		
			
				|  |  | +		$data['staff']=$this->staff;
 | 
	
		
			
				|  |  | +		$data['receiptMemu']='approvalExpenses';
 | 
	
		
			
				|  |  | +		$data['verifyId']=$this->verifyId;
 | 
	
		
			
				|  |  | +		
 | 
	
		
			
				|  |  | +		$data['executeId']=$this->executeId;
 | 
	
		
			
				|  |  | +		$this->render ( "/admin/FALG", $data );
 | 
	
		
			
				|  |  | +	}
 | 
	
		
			
				|  |  | +	
 | 
	
		
			
				|  |  |  	function ajaxGetReceiptOrder(){
 | 
	
		
			
				|  |  |  		$receiptOrder=$this->get_args('receiptOrder')?$this->get_args('receiptOrder'):"";
 | 
	
		
			
				|  |  |  		
 |