"; include $path;die; } } private function cacheFile($path){ $content = ob_get_contents(); $fp = fopen($path, "w"); fwrite($fp, $content); fclose($fp); } private function getReceiptCount(){ $status=2; $year=date('Y'); 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)); return count($receiptList); } private function collectHtml($receiptCollectList=array(),$itemCategory="日常相关费用",$classType="b"){ $collectHtml="";$sumPrice=0.00; for ($i=1;$i<=12;$i++){ $falg=true; foreach ($receiptCollectList as $key=>$value){ if($value['itemCategory']==$itemCategory&&$value['month']==$i){ $sumPrice+=$value['price']; if ($classType=="b"){ $collectHtml.='¥'.$value['price'].'';$falg=false;break; }else{ $collectHtml.='¥'.$value['price'].'';$falg=false;break; } } } if ($falg) $collectHtml.='-'; } $collectHtml.='¥'.$sumPrice.''; return $collectHtml; } function __construct() { if(isset($_COOKIE["staff"])){ if(!empty($_COOKIE["staff"])){ Doo::loadModel ( 'staff' ); Doo::loadModel('verify'); $verify=new verify(); $staff = new staff (); $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){ array_push($list, $v[0]); } } $this->verifyId=$list; $this->staff=$staff->getUserByIdList($_COOKIE["staff"]); self::$NEW= $this->getReceiptCount(); 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 myReceipt(){ //all approval past withdraw $item=isset($this->params['item'])?$this->params['item']:""; if(empty($item)) $item=$this->get_args('item')?$this->get_args('item'):""; $year=$this->get_args('year')?$this->get_args('year'):date("Y"); $moth=$this->get_args('moth')?$this->get_args('moth'):""; Doo::loadModel('receipt'); $receipt=new receipt(); //pre-loaded if(!empty($item)&&($item=="past"||$item=="withdraw")){ //have cache $path=SITE_PATH.$this->MYREVEIPTCACHEPATH.$item."_".$year.".htmls"; if(!empty($moth))//yearPage $path=SITE_PATH.$this->MYREVEIPTCACHEPATH.$item."_".$year."_".$moth.".htmls"; $this->showCache($path); } Doo::loadModel('L_category'); $Lcategory=new L_category(); Doo::loadModel('verify'); Doo::loadModel('statistics'); $statistics=new statistics(); $verify=new verify(); $condition=" and status!=4 "; if($item=="approval") $condition=" and status=2 "; elseif ($item=="withdraw") $condition=" and status=3 "; elseif ($item=="past") $condition=" and status=1 "; $dateCondition=" and Year(date) =".$year; if(!empty($moth)){ $dateCondition=" and Year(date) =".$year." and Month(date) = ".$moth; $stList=$statistics->getOne(array('select'=>'rePrice ,agPrice','where'=>' staff='.$this->staff[0]['sid'].$dateCondition,'asArray'=>true)); }else $stList=$statistics->statisticsByYear($year,$this->staff[0]['sid']); if(empty($stList)) $stList=array('rePrice'=>0,'agPrice'=>0); $data['stList']=array('rePrice'=>$stList['rePrice'],'agPrice'=>$stList['agPrice'],'skPrice'=>($stList['rePrice']-$stList['agPrice'])); $receiptList=$receipt->find(array('where'=>'staff='.$this->staff[0]['sid'].$condition.$dateCondition,'desc'=>'rid','asArray'=>true)); foreach ($receiptList as $key=>$vlaue){ $receiptList[$key]['accountItem']=json_decode($vlaue['accountItem'],true); $categoryDetil=$Lcategory->getOne(array('where'=>'cid='.$vlaue['cid'],'asArray'=>true)); $receiptList[$key]['category']=$categoryDetil['title']; $verifyList=$verify->getOne(array('where'=>'vid='.$vlaue['verify'],'asArray'=>true)); $verifyList=json_decode($verifyList['staff']);//status opinion $verifyStaff=json_decode($vlaue['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; }else{ foreach ($verifyStaff as $m=>$u){ if ($v[0]==$m){ $verifyList[$k]['date']=$u['date']; $verifyList[$k]['opinion']=$u['opinion']; $verifyList[$k]['status']=$u['status']; break; } } } } $receiptList[$key]['verifyList']=$verifyList; } //print_r($receiptList);die; $mothHtml=""; for($i=1;$i<=12;$i++){ if($moth==$i) $mothHtml.=''; else $mothHtml.=''; } $data['mothHtml']=$mothHtml; $data['receiptList']=$receiptList; $data['memu']="receipt"; $data['staff']=$this->staff; $data['receiptMemu']='receipt'; $data['verifyId']=$this->verifyId; $data['item']=$item; $data['year']=$year; if(!empty($item)&&($item=="past"||$item=="withdraw")){ //sufficient condition to generate cache if(empty($moth)&&($yearfind(array('where'=>'staff='.$this->staff[0]['sid'].' and (status=2 or status=4) and Year(date) ='.$year,'asArray'=>true)); if(empty($receiptList)){ //generated files ob_start(); $this->render ( "/admin/saea_myList", $data ); $this->cacheFile($path);die; // $content = ob_get_contents(); // $fp = fopen($path, "w"); // fwrite($fp, $content); // fclose($fp); } }elseif (!empty($moth)&&($year<=date("Y"))&&($mothfind(array('where'=>'staff='.$this->staff[0]['sid'].' and (status=2 or status=4) and Year(date) ='.$year.' and Month(date) ='.$moth,'asArray'=>true)); if(empty($receiptList)){ //generated files ob_start(); $this->render ( "/admin/saea_myList", $data ); $this->cacheFile($path);die; } } } $this->render ( "/admin/saea_myList", $data ); } function saeaCreate(){ Doo::loadModel('accountItem'); Doo::loadModel('verify'); Doo::loadModel('receipt'); Doo::loadModel('L_category'); $lCategory=new L_category(); $receipt=new receipt(); $verify=new verify(); $accountItem=new accountItem(); // $receiptDetail=$receipt->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and status=4','asArray'=>true)); // if(!empty($receiptDetail)) // return "/referReceipt/".$receiptDetail['rid']; $acItem=$accountItem->find(array('asArray'=>true)); $veList=$verify->find(array('asArray'=>true)); foreach ($veList as $key=>$value){ $veList[$key]['staff']=json_decode($value['staff']); } $data['category']=$lCategory->find(array('asArray'=>true)); $data['veList']=$veList; $data['acItem']=$acItem; $data['memu']="receipt"; $data['staff']=$this->staff; $data['receiptMemu']='saeaCreate'; $data['verifyId']=$this->verifyId; $this->render ( "/admin/saea_create", $data ); } function addReceipt(){ $agency=$this->get_args('agency'); $travel=$this->get_args('travel'); $train=$this->get_args('train'); $other=$this->get_args('other'); $verify=$this->get_args('verify')&&is_numeric($this->get_args('verify'))?$this->get_args('verify'):0; $cid=$this->get_args('cid')&&is_numeric($this->get_args('cid'))?$this->get_args('cid'):0; $explanation=$this->get_args('explanation')?$this->get_args('explanation'):""; if(!empty($verify)&&!empty($cid)&&!empty($explanation)){ Doo::loadModel('receipt'); Doo::loadModel('receiptDetail'); Doo::loadModel('accountItem'); $accountItem=new accountItem(); $receipt=new receipt(); // $receiptDetail=$receipt->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and status=4','asArray'=>true)); // if(!empty($receiptDetail)) // return "/referReceipt/".$receiptDetail['rid']; $aItem=$accountItem->find(array('asArray'=>true)); $accountJson[$this->AGENCY]=$accountJson[$this->TRAVEL]=$accountJson[$this->TRAIN]=$accountJson[$this->OTHER]=array(); $ag=$tr=$ta=$ot=0; $sum=$agencySum=$travelSum=$trainSum=$otherSum=0; foreach ($aItem as $key=>$value){ if ($value['category']==$this->AGENCY){ if (is_numeric($agency[$ag])&&$agency[$ag]!=0){ array_push($accountJson[$this->AGENCY], array('aid'=>$value['aid'],'name'=>$value['name'],'price'=>number_format($agency[$ag], 2, '.', ''))); $sum+=$agency[$ag];$agencySum+=$agency[$ag]; } $ag++; } if($value['category']==$this->TRAVEL){ if (is_numeric($travel[$tr])&&$travel[$tr]!=0){ array_push($accountJson[$this->TRAVEL], array('aid'=>$value['aid'],'name'=>$value['name'],'price'=>number_format($travel[$tr], 2, '.', ''))); $sum+=$travel[$tr];$travelSum+=$travel[$tr]; } $tr++; } if($value['category']==$this->TRAIN){ if (is_numeric($train[$ta])&&$train[$ta]!=0){ array_push($accountJson[$this->TRAIN], array('aid'=>$value['aid'],'name'=>$value['name'],'price'=>number_format($train[$ta], 2, '.', ''))); $sum+=$train[$ta];$trainSum+=$train[$ta]; } $ta++; } if($value['category']==$this->OTHER){ if (is_numeric($other[$ot])&&$other[$ot]!=0){ array_push($accountJson[$this->OTHER], array('aid'=>$value['aid'],'name'=>$value['name'],'price'=>number_format($other[$ot], 2, '.', ''))); $sum+=$other[$ot];$otherSum+=$other[$ot]; } $ot++; } } $accountJson['cSum']=array('agencySum'=>number_format($agencySum, 2, '.', ''),'travelSum'=>number_format($travelSum, 2, '.', ''),'trainSum'=>number_format($trainSum, 2, '.', ''),'otherSum'=>number_format($otherSum, 2, '.', '')); //报销单 $receipt->accountItem=json_encode($accountJson); $receipt->staff=$this->staff[0]['sid']; $receipt->sum=number_format($sum, 2, '.', ''); $receipt->date=date("Y-m-d"); $receipt->cid=$cid; $receipt->status=4; $receipt->verify=$verify; $receipt->receiptOrder="#B".date("Ymd").mt_rand(1000,9999); $receipt->explanation=$explanation; $rid=$receipt->insert(); //报销详情 foreach ($accountJson[$this->AGENCY] as $key=>$value){ $receiptDetail=new receiptDetail(); $receiptDetail->staff=$this->staff[0]['sid']; $receiptDetail->item=$value['name']; $receiptDetail->itemCategory=$this->AGENCY; $receiptDetail->price=number_format($value['price'], 2, '.', ''); $receiptDetail->date=date("Y-m-d"); $receiptDetail->cid=$cid; $receiptDetail->rid=$rid; $receiptDetail->status=4; $receiptDetail->insert(); } foreach ($accountJson[$this->TRAVEL] as $key=>$value){ $receiptDetail=new receiptDetail(); $receiptDetail->staff=$this->staff[0]['sid']; $receiptDetail->item=$value['name']; $receiptDetail->itemCategory=$this->TRAVEL; $receiptDetail->price=number_format($value['price'], 2, '.', ''); $receiptDetail->date=date("Y-m-d"); $receiptDetail->cid=$cid; $receiptDetail->rid=$rid; $receiptDetail->status=4; $receiptDetail->insert(); } foreach ($accountJson[$this->TRAIN] as $key=>$value){ $receiptDetail=new receiptDetail(); $receiptDetail->staff=$this->staff[0]['sid']; $receiptDetail->item=$value['name']; $receiptDetail->itemCategory=$this->TRAIN; $receiptDetail->price=number_format($value['price'], 2, '.', ''); $receiptDetail->date=date("Y-m-d"); $receiptDetail->cid=$cid; $receiptDetail->rid=$rid; $receiptDetail->status=4; $receiptDetail->insert(); } foreach ($accountJson[$this->OTHER] as $key=>$value){ $receiptDetail=new receiptDetail(); $receiptDetail->staff=$this->staff[0]['sid']; $receiptDetail->item=$value['name']; $receiptDetail->itemCategory=$this->OTHER; $receiptDetail->price=number_format($value['price'], 2, '.', ''); $receiptDetail->date=date("Y-m-d"); $receiptDetail->cid=$cid; $receiptDetail->rid=$rid; $receiptDetail->status=4; $receiptDetail->insert(); } return "/referReceipt/".$rid; } return "/saeaCreate"; } function referReceipt(){ //$rid=isset($this->params['rid'])&&is_numeric($this->params['rid'])?$this->params['rid']:0; Doo::loadModel('receipt'); Doo::loadModel('verify'); $verify=new verify(); $receipt=new receipt(); Doo::loadModel('L_category'); $lCategory=new L_category(); $receiptDetail=$receipt->find(array('where'=>'staff='.$this->staff[0]['sid'].' and status=4 ','asArray'=>true)); if(empty($receiptDetail)) return "/addReceipt"; foreach ($receiptDetail as $key=>$value){ $receiptDetail[$key]['accountItem']=json_decode($value['accountItem'],true); $veList=$verify->getOne(array('where'=>'vid='.$value['verify'],'asArray'=>true)); $v=json_decode($veList['staff']); array_push($v[0], $veList['description']); $receiptDetail[$key]['staff']=$v; $category=$lCategory->getOne(array('where'=>'cid='.$value['cid'],'asArray'=>true)); $receiptDetail[$key]['category']=$category['title']; } $data['receiptDetail']=$receiptDetail; $data['memu']="receipt"; $data['staff']=$this->staff; $data['receiptMemu']='saeaCreate'; $data['verifyId']=$this->verifyId; $this->render ( "/admin/saea_confirm", $data ); } function editReceipt(){ //edit status 4 $rid=isset($this->params['rid'])&&is_numeric($this->params['rid'])?$this->params['rid']:0; //echo $rid; Doo::loadModel('accountItem'); Doo::loadModel('verify'); Doo::loadModel('receipt'); $receipt=new receipt(); $verify=new verify(); $accountItem=new accountItem(); Doo::loadModel('L_category'); $lCategory=new L_category(); $receiptDetail=$receipt->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and status=4 and rid='.$rid,'asArray'=>true)); if(empty($receiptDetail)) return "/saeaCreate"; $acItem=$accountItem->find(array('asArray'=>true)); $veList=$verify->find(array('asArray'=>true)); foreach ($veList as $key=>$value){ $veList[$key]['staff']=json_decode($value['staff']); } //配置编辑信息 $accountItemList=json_decode($receiptDetail['accountItem'],true); foreach ($acItem as $key=>$value){ foreach ($accountItemList[$this->AGENCY] as $k=>$v){ if($acItem[$key]['category']==$this->AGENCY&&$acItem[$key]['name']==$v['name']){ $acItem[$key]['price']=$v['price']; } } foreach ($accountItemList[$this->TRAIN] as $k=>$v){ if($acItem[$key]['category']==$this->TRAIN&&$acItem[$key]['name']==$v['name']){ $acItem[$key]['price']=$v['price']; } } foreach ($accountItemList[$this->TRAVEL] as $k=>$v){ if($acItem[$key]['category']==$this->TRAVEL&&$acItem[$key]['name']==$v['name']){ $acItem[$key]['price']=$v['price']; } } foreach ($accountItemList[$this->OTHER] as $k=>$v){ if($acItem[$key]['category']==$this->OTHER&&$acItem[$key]['name']==$v['name']){ $acItem[$key]['price']=$v['price']; } } } $data['category']=$lCategory->find(array('asArray'=>true)); $data['cSum']=$accountItemList['cSum']; $data['sum']=$receiptDetail['sum']; $data['receiptDetail']=$receiptDetail; $data['veList']=$veList; $data['acItem']=$acItem; $data['memu']="receipt"; $data['staff']=$this->staff; $data['receiptMemu']='saeaCreate'; $data['verify']=$receiptDetail['verify']; $data['verifyId']=$this->verifyId; $data['rid']=$rid; $this->render ( "/admin/saea_edit", $data ); } function updateReceipt(){ $agency=$this->get_args('agency'); $travel=$this->get_args('travel'); $train=$this->get_args('train'); $other=$this->get_args('other'); $verify=$this->get_args('verify')&&is_numeric($this->get_args('verify'))?$this->get_args('verify'):0; $explanation=$this->get_args('explanation')?$this->get_args('explanation'):""; $cid=$this->get_args('cid')&&is_numeric($this->get_args('cid'))?$this->get_args('cid'):0; $rid=$this->get_args('rid')&&is_numeric($this->get_args('rid'))?$this->get_args('rid'):0; if(!empty($verify)&&!empty($explanation)){ Doo::loadModel('receipt'); Doo::loadModel('receiptDetail'); Doo::loadModel('accountItem'); $accountItem=new accountItem(); $receipt=new receipt(); $receiptDetail=$receipt->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and status=4 and rid='.$rid,'asArray'=>true)); if(empty($receiptDetail)) return "/saeaCreate"; $aItem=$accountItem->find(array('asArray'=>true)); $accountJson[$this->AGENCY]=$accountJson[$this->TRAVEL]=$accountJson[$this->TRAIN]=$accountJson[$this->OTHER]=array(); $ag=$tr=$ta=$ot=0; $sum=$agencySum=$travelSum=$trainSum=$otherSum=0; foreach ($aItem as $key=>$value){ if ($value['category']==$this->AGENCY){ if (is_numeric($agency[$ag])&&$agency[$ag]!=0){ array_push($accountJson[$this->AGENCY], array('aid'=>$value['aid'],'name'=>$value['name'],'price'=>number_format($agency[$ag], 2, '.', ''))); $sum+=$agency[$ag];$agencySum+=$agency[$ag]; } $ag++; } if($value['category']==$this->TRAVEL){ if (is_numeric($travel[$tr])&&$travel[$tr]!=0){ array_push($accountJson[$this->TRAVEL], array('aid'=>$value['aid'],'name'=>$value['name'],'price'=>number_format($travel[$tr], 2, '.', ''))); $sum+=$travel[$tr];$travelSum+=$travel[$tr]; } $tr++; } if($value['category']==$this->TRAIN){ if (is_numeric($train[$ta])&&$train[$ta]!=0){ array_push($accountJson[$this->TRAIN], array('aid'=>$value['aid'],'name'=>$value['name'],'price'=>number_format($train[$ta], 2, '.', ''))); $sum+=$train[$ta];$trainSum+=$train[$ta]; } $ta++; } if($value['category']==$this->OTHER){ if (is_numeric($other[$ot])&&$other[$ot]!=0){ array_push($accountJson[$this->OTHER], array('aid'=>$value['aid'],'name'=>$value['name'],'price'=>number_format($other[$ot], 2, '.', ''))); $sum+=$other[$ot];$otherSum+=$other[$ot]; } $ot++; } } $accountJson['cSum']=array('agencySum'=>number_format($agencySum, 2, '.', ''),'travelSum'=>number_format($travelSum, 2, '.', ''),'trainSum'=>number_format($trainSum, 2, '.', ''),'otherSum'=>number_format($otherSum, 2, '.', '')); //报销单 $rid=$receipt->rid=$receiptDetail['rid']; $receipt->accountItem=json_encode($accountJson); $receipt->staff=$this->staff[0]['sid']; $receipt->sum=number_format($sum, 2, '.', ''); $receipt->date=date("Y-m-d"); $receipt->cid=$cid; $receipt->status=4; $receipt->verify=$verify; $receipt->explanation=$explanation; $receipt->update(); $receiptDetail=new receiptDetail(); $receiptDetail->delete(array('where'=>'rid='.$rid)); //报销详情 foreach ($accountJson[$this->AGENCY] as $key=>$value){ $receiptDetail=new receiptDetail(); $receiptDetail->staff=$this->staff[0]['sid']; $receiptDetail->item=$value['name']; $receiptDetail->itemCategory=$this->AGENCY; $receiptDetail->price=number_format($value['price'], 2, '.', ''); $receiptDetail->date=date("Y-m-d"); $receiptDetail->cid=$cid; $receiptDetail->rid=$rid; $receiptDetail->status=4; $receiptDetail->insert(); } foreach ($accountJson[$this->TRAVEL] as $key=>$value){ $receiptDetail=new receiptDetail(); $receiptDetail->staff=$this->staff[0]['sid']; $receiptDetail->item=$value['name']; $receiptDetail->itemCategory=$this->TRAVEL; $receiptDetail->price=number_format($value['price'], 2, '.', ''); $receiptDetail->date=date("Y-m-d"); $receiptDetail->cid=$cid; $receiptDetail->rid=$rid; $receiptDetail->status=4; $receiptDetail->insert(); } foreach ($accountJson[$this->TRAIN] as $key=>$value){ $receiptDetail=new receiptDetail(); $receiptDetail->staff=$this->staff[0]['sid']; $receiptDetail->item=$value['name']; $receiptDetail->itemCategory=$this->TRAIN; $receiptDetail->price=number_format($value['price'], 2, '.', ''); $receiptDetail->date=date("Y-m-d"); $receiptDetail->cid=$cid; $receiptDetail->rid=$rid; $receiptDetail->status=4; $receiptDetail->insert(); } foreach ($accountJson[$this->OTHER] as $key=>$value){ $receiptDetail=new receiptDetail(); $receiptDetail->staff=$this->staff[0]['sid']; $receiptDetail->item=$value['name']; $receiptDetail->itemCategory=$this->OTHER; $receiptDetail->price=number_format($value['price'], 2, '.', ''); $receiptDetail->date=date("Y-m-d"); $receiptDetail->cid=$cid; $receiptDetail->rid=$rid; $receiptDetail->status=4; $receiptDetail->insert(); } return "/referReceipt/".$rid; } return "/editReceipt/1"; } function approvedReceipt(){ $rid=isset($this->params['rid'])&&is_numeric($this->params['rid'])?$this->params['rid']:0; Doo::loadModel('receipt'); Doo::loadModel('receiptDetail'); $receipt=new receipt(); $receiptDetail=new receiptDetail(); Doo::loadModel('statistics'); Doo::loadModel('itemStatistics'); $statistics=new statistics(); $itemStatistics=new itemStatistics(); $receiptDetailList=$receipt->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and status=4 and rid='.$rid,'asArray'=>true)); if(empty($receiptDetailList)) return "/saeaCreate"; $receipt->rid=$receiptDetailList['rid']; $receipt->status=2; $receipt->update(); $receiptDetail->status=2; $receiptDetail->update(array('where'=>'rid='.$receiptDetailList['rid'])); //statistics item $dateArray=explode("-", $receiptDetailList['date']); $dateCondition=" and Year(date) =".$dateArray[0]." and Month(date) = ".$dateArray[1]; $accountItem=json_decode($receiptDetailList['accountItem'],true); //print_r($accountItem['cSum']['agencySum']);die; // foreach ($accountItem['cSum'] as $key=>$value){ // if($key=="agencySum"){ // $iStatistics=$itemStatistics->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and itemCategory="'.$this->AGENCY.'"'.$dateCondition,'asArray'=>true)); // if(empty($iStatistics)){ // $itemStatistics->cid=$this->staff[0]['cid']; // $itemStatistics->staff=$this->staff[0]['sid']; // $itemStatistics->price=$value; // $itemStatistics->itemCategory=$this->AGENCY; // $itemStatistics->date=date("Y-m-d"); // $itemStatistics->insert(); // }else{ // if (!empty($value)){ // $itemStatistics->price=$value+$iStatistics['price']; // $itemStatistics->update(array('where'=>'sid='.$iStatistics['sid'])); // } // } // }elseif($key=="travelSum"){ // $iStatistics=$itemStatistics->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and itemCategory="'.$this->TRAVEL.'"'.$dateCondition,'asArray'=>true)); // if(empty($iStatistics)){ // $itemStatistics->cid=$this->staff[0]['cid']; // $itemStatistics->staff=$this->staff[0]['sid']; // $itemStatistics->price=$value; // $itemStatistics->itemCategory=$this->TRAVEL; // $itemStatistics->date=date("Y-m-d"); // $itemStatistics->insert(); // }else{ // if (!empty($value)){ // $itemStatistics->price=$value+$iStatistics['price']; // $itemStatistics->update(array('where'=>'sid='.$iStatistics['sid'])); // } // } // }elseif($key=="trainSum"){ // $iStatistics=$itemStatistics->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and itemCategory="'.$this->TRAIN.'"'.$dateCondition,'asArray'=>true)); // if(empty($iStatistics)){ // $itemStatistics->cid=$this->staff[0]['cid']; // $itemStatistics->staff=$this->staff[0]['sid']; // $itemStatistics->price=$value; // $itemStatistics->itemCategory=$this->TRAIN; // $itemStatistics->date=date("Y-m-d"); // $itemStatistics->insert(); // }else{ // if (!empty($value)){ // $itemStatistics->price=$value+$iStatistics['price']; // $itemStatistics->update(array('where'=>'sid='.$iStatistics['sid'])); // } // } // }elseif($key=="otherSum"){ // $iStatistics=$itemStatistics->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and itemCategory="'.$this->OTHER.'"'.$dateCondition,'asArray'=>true)); // if(empty($iStatistics)){ // $itemStatistics->cid=$this->staff[0]['cid']; // $itemStatistics->staff=$this->staff[0]['sid']; // $itemStatistics->price=$value; // $itemStatistics->itemCategory=$this->OTHER; // $itemStatistics->date=date("Y-m-d"); // $itemStatistics->insert(); // }else{ // if (!empty($value)){ // $itemStatistics->price=$value+$iStatistics['price']; // $itemStatistics->update(array('where'=>'sid='.$iStatistics['sid'])); // } // } // } // } $stat=$statistics->getOne(array('where'=>'staff='.$this->staff[0]['sid'].$dateCondition,'asArray'=>true)); if(empty($stat)){ $statistics->date=date("Y-m-d"); $statistics->cid=$this->staff[0]['cid']; $statistics->staff=$this->staff[0]['sid']; $statistics->agPrice=0; $statistics->rePrice=$accountItem['cSum']['agencySum']+$accountItem['cSum']['travelSum']+$accountItem['cSum']['trainSum']+$accountItem['cSum']['otherSum']; $statistics->insert(); }else{ $statistics->rePrice=$stat['rePrice']+$accountItem['cSum']['agencySum']+$accountItem['cSum']['travelSum']+$accountItem['cSum']['trainSum']+$accountItem['cSum']['otherSum']; $statistics->update(array('where'=>'sid='.$stat['sid'])); } return "/myReceipt"; } function approval(){ $status=isset($this->params['status'])?$this->params['status']:''; $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')?$this->get_args('status'):2; $vidList=array(); $button=0; Doo::loadModel('verify'); Doo::loadModel('receipt'); Doo::loadModel('staff'); $staff=new staff(); $receipt=new receipt(); $verify=new verify(); Doo::loadModel('L_category'); $Lcategory=new L_category(); //user verify ID $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; 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=""; } if($status==2) $approvalCondition=' and verifyStaff not like "%\"'.$this->staff[0]['sid'].'\":{%" '; $ap=""; if($status==4){ $ap=4;$status=2; $approvalCondition=' and verifyStaff like "%\"'.$this->staff[0]['sid'].'\":{%" '; } //get Receipt By verifyID status 2 $receiptList=$receipt->find(array('where'=>'verify in('.$vid.') and status='.$status.$dateCondition.$cateCondition.$staffCondition.$approvalCondition,'desc'=>'rid','asArray'=>true)); $Locate=0; if($ap==4) $status=4; 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; } //print_r($receiptList);die; //$data['verifyDetail']=$verifyDetail; $mothHtml=""; for($i=1;$i<=12;$i++){ if($month==$i) $mothHtml.=''; else $mothHtml.=''; } $data['mothHtml']=$mothHtml; $data['receiptList']=$receiptList; $data['receiptApprovalCount']=count($receiptList); $data['status']=$status; $data['year']=$year; $data['categoryList']=$categoryList; $data['staffList']=$staffList; $data['cid']=$cid; $data['sid']=$sid; $data['ap']=$ap; $data['memu']="receipt"; $data['staff']=$this->staff; $data['receiptMemu']='approval'; $data['verifyId']=$this->verifyId; $this->render ( "/admin/saea_reportList", $data ); } function remittance(){ $year=$this->get_args('year')?$this->get_args('year'):date('Y'); $month=$this->get_args('month')?$this->get_args('month'):""; Doo::loadModel('receipt'); $receipt=new receipt(); Doo::loadModel('staff'); $staff=new staff(); $dateCondition=" and Year(pastDate) =".$year; if(!empty($month)) $dateCondition=" and Year(pastDate) =".$year." and Month(pastDate) = ".$month; //get Receipt By verifyID status 1 $receiptList=$receipt->find(array('select'=>'sum(sum) as sum,staff,pastDate','where'=>' status=1'.$dateCondition,'desc'=>'pastDate','groupby'=>'staff,pastDate','asArray'=>true)); $dateList=$receipt->find(array('select'=>'pastDate','where'=>' status=1'.$dateCondition,'desc'=>'pastDate','groupby'=>'pastDate','asArray'=>true)); $dataList=array(); foreach ($dateList as $d=>$a){ $dataList[$a['pastDate']]=array();$daySum=0; foreach ($receiptList as $key=>$value){ if($a['pastDate']==$value['pastDate']){ $oderList=$receipt->find(array('select'=>'receiptOrder','where'=>' status=1 and staff='.$value['staff'].' and pastDate=\''.$a['pastDate'].'\'','asArray'=>true)); $list=array(); foreach ($oderList as $v){ array_push($list, $v['receiptOrder']); } $receiptList[$key]['receiptOrder']=implode(",", $list); $sinfo=$staff->getOne(array('select'=>'username ','where'=>' sid='.$value['staff'],'asArray'=>true)); $receiptList[$key]['username']=$sinfo['username']; $daySum+=$value['sum']; array_push($dataList[$a['pastDate']], $receiptList[$key]); } $dataList[$a['pastDate']]['9999999']=number_format($daySum,2); } } //print_r($dataList);die; $data['dataList']=$dataList; $mothHtml=""; for($i=1;$i<=12;$i++){ if($month==$i) $mothHtml.=''; else $mothHtml.=''; } $data['year']=$year; $data['mothHtml']=$mothHtml; $data['memu']="receipt"; $data['staff']=$this->staff; $data['receiptMemu']='approval'; $data['verifyId']=$this->verifyId; $this->render ( "/admin/saeaReportListPay", $data ); } function revocationAdjustment(){ $sid=isset($this->params['sid'])&&is_numeric($this->params['sid'])?$this->params['sid']:0; $price=isset($this->params['price'])&&is_numeric($this->params['price'])?$this->params['price']:-99999; $rid=isset($this->params['rid'])&&is_numeric($this->params['rid'])?$this->params['rid']:0; if ((!empty($sid))&&($price!=-99999)&&(!empty($rid))){ Doo::loadModel('receipt'); $receipt=new receipt(); $receiptDetail=$receipt->getOne(array('where'=>'rid='.$rid,'asArray'=>true)); if (empty($receiptDetail['reviseDetail'])) return "/approval"; $reviseDetail=json_decode($receiptDetail['reviseDetail'],true); $RD=array(); foreach ($reviseDetail as $key=>$value){ if ($value['price']==$price&&$value['sid']==$sid) continue; array_push($RD, $value); } $reviseDetailString=json_encode($RD); $receipt->reviseDetail=$reviseDetailString; $receipt->sum=$receiptDetail['sum']+$price; $receipt->update(array('where'=>'rid='.$rid)); } return "/approval"; } function updateApprovalReceipt(){ $opinion=$this->get_args('opinion')?$this->get_args('opinion'):""; $status=$this->get_args('status')&&is_numeric($this->get_args('status'))?$this->get_args('status'):0; $rid=$this->get_args('rid')&&is_numeric($this->get_args('rid'))?$this->get_args('rid'):0; $Locate=$this->get_args('Locate')&&is_numeric($this->get_args('Locate'))?$this->get_args('Locate'):0; if(!empty($rid)){ Doo::loadModel("receipt"); Doo::loadModel("verify"); Doo::loadModel("receiptDetail"); $receiptDetailObj=new receiptDetail(); Doo::loadModel("itemStatistics"); Doo::loadModel("statistics"); $statistics=new statistics(); $itemStatistics=new itemStatistics(); $verify=new verify(); $receipt=new receipt(); $receiptDetail=$receipt->getOne(array('where'=>'rid='.$rid.' and status=2 ','asArray'=>true)); if (empty($receiptDetail)) return "/approval"; $verifyStaff=json_decode($receiptDetail['verifyStaff'],true); if(empty($opinion)){ if ($status==3) $opinion="退回"; else $opinion="同意支付"; } if(empty($verifyStaff)){ $verifyStaff=array($this->staff[0]['sid']=>array('date'=>date('Y-m-d'),'opinion'=>$opinion,'status'=>$status)); if($status==3) $verifyStaff=array('final'=>$status,$this->staff[0]['sid']=>array('date'=>date('Y-m-d'),'opinion'=>$opinion,'status'=>$status)); $vStaffString=json_encode($verifyStaff); $receipt->verifyStaff=$vStaffString; }else{ if (!array_key_exists($this->staff[0]['sid'],$verifyStaff)){ $verifyStaff[$this->staff[0]['sid']]=array('date'=>date('Y-m-d'),'opinion'=>$opinion,'status'=>$status); if($status==3){ $verifyStaff['final']=$status; $verifyStaff[$this->staff[0]['sid']]=array('date'=>date('Y-m-d'),'opinion'=>$opinion,'status'=>$status); } $vStaffString=json_encode($verifyStaff); $receipt->verifyStaff=$vStaffString; } } $verifyDetail=$verify->getOne(array('where'=>' vid ='.$receiptDetail['verify'],'asArray'=>true)); $verifyDetail=json_decode($verifyDetail['staff'],true); if (isset($verifyStaff['final'])){//rDetail $receipt->status=3; $receiptDetailObj->status=3; $receiptDetailObj->update(array('where'=>'rid='.$rid)); }elseif(count($verifyStaff)==count($verifyDetail)){ $receipt->status=1; if(!empty($receiptDetail['reviseDetail'])){//statistics item rDetail $reviseDetail=json_decode($receiptDetail['reviseDetail'],true); $reviseSum=0; foreach ($reviseDetail as $key=>$value){ $receiptDetailObj=new receiptDetail(); $receiptDetailObj->staff=$receiptDetail['staff'];// $this->staff[0]['sid']; $receiptDetailObj->item=$value['description']; $receiptDetailObj->itemCategory="报销金额调整"; $receiptDetailObj->price=$value['price']; $receiptDetailObj->date=$receiptDetail['date']; $receiptDetailObj->cid=$this->staff[0]['cid']; $receiptDetailObj->rid=$rid; $receiptDetailObj->status=1; $receiptDetailObj->insert(); $reviseSum+=$value['price']; } $itemStatistics=new itemStatistics(); $itemStatistics->cid=$receiptDetail['cid'];//$this->staff[0]['cid']; $itemStatistics->staff=$receiptDetail['staff'];//$this->staff[0]['sid']; $itemStatistics->price=$reviseSum; $itemStatistics->itemCategory="报销金额调整"; $itemStatistics->date=$receiptDetail['date']; $itemStatistics->insert(); } $receiptDetailObj=new receiptDetail(); $receiptDetailObj->status=1; $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)); if(empty($stat)){ $statistics->date=$receiptDetail['date']; $statistics->cid=$receiptDetail['cid'];//$this->staff[0]['cid']; $statistics->staff=$receiptDetail['staff'];//$this->staff[0]['sid']; $statistics->agPrice=$receiptDetail['sum']; $statistics->rePrice=$reviseSum; $statistics->insert(); }else{ $statistics->agPrice=$stat['agPrice']+$receiptDetail['sum']; $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]; $accountItem=json_decode($receiptDetail['accountItem'],true); foreach ($accountItem['cSum'] as $key=>$value){ if($key=="agencySum"){ $iStatistics=$itemStatistics->getOne(array('where'=>'staff='.$receiptDetail['staff'].' and itemCategory="'.$this->AGENCY.'"'.$dateCondition,'asArray'=>true)); if(empty($iStatistics)){ $itemStatistics->cid=$receiptDetail['cid'];; $itemStatistics->staff=$receiptDetail['staff']; $itemStatistics->price=$value; $itemStatistics->itemCategory=$this->AGENCY; $itemStatistics->date=$receiptDetail['date']; $itemStatistics->insert(); }else{ if (!empty($value)){ $itemStatistics->price=$value+$iStatistics['price']; $itemStatistics->update(array('where'=>'sid='.$iStatistics['sid'])); } } }elseif($key=="travelSum"){ $iStatistics=$itemStatistics->getOne(array('where'=>'staff='.$receiptDetail['staff'].' and itemCategory="'.$this->TRAVEL.'"'.$dateCondition,'asArray'=>true)); if(empty($iStatistics)){ $itemStatistics->cid=$receiptDetail['cid']; $itemStatistics->staff=$receiptDetail['staff']; $itemStatistics->price=$value; $itemStatistics->itemCategory=$this->TRAVEL; $itemStatistics->date=$receiptDetail['date']; $itemStatistics->insert(); }else{ if (!empty($value)){ $itemStatistics->price=$value+$iStatistics['price']; $itemStatistics->update(array('where'=>'sid='.$iStatistics['sid'])); } } }elseif($key=="trainSum"){ $iStatistics=$itemStatistics->getOne(array('where'=>'staff='.$receiptDetail['staff'].' and itemCategory="'.$this->TRAIN.'"'.$dateCondition,'asArray'=>true)); if(empty($iStatistics)){ $itemStatistics->cid=$receiptDetail['cid']; $itemStatistics->staff=$receiptDetail['staff']; $itemStatistics->price=$value; $itemStatistics->itemCategory=$this->TRAIN; $itemStatistics->date=$receiptDetail['date']; $itemStatistics->insert(); }else{ if (!empty($value)){ $itemStatistics->price=$value+$iStatistics['price']; $itemStatistics->update(array('where'=>'sid='.$iStatistics['sid'])); } } }elseif($key=="otherSum"){ $iStatistics=$itemStatistics->getOne(array('where'=>'staff='.$receiptDetail['staff'].' and itemCategory="'.$this->OTHER.'"'.$dateCondition,'asArray'=>true)); if(empty($iStatistics)){ $itemStatistics->cid=$receiptDetail['cid']; $itemStatistics->staff=$receiptDetail['staff']; $itemStatistics->price=$value; $itemStatistics->itemCategory=$this->OTHER; $itemStatistics->date=$receiptDetail['date']; $itemStatistics->insert(); }else{ if (!empty($value)){ $itemStatistics->price=$value+$iStatistics['price']; $itemStatistics->update(array('where'=>'sid='.$iStatistics['sid'])); } } } } $receipt->pastDate=date("Y-m-d"); } $receipt->update(array('where'=>'rid='.$rid)); return "/approval#".$Locate; } } function revisePrice(){ $description=$this->get_args('description')?$this->get_args('description'):""; $price=$this->get_args('price')&&is_numeric($this->get_args('price'))?$this->get_args('price'):0; $rid=$this->get_args('rid')&&is_numeric($this->get_args('rid'))?$this->get_args('rid'):0; if (!empty($rid)){ Doo::loadModel("receipt"); $receipt=new receipt(); $receiptDetail=$receipt->getOne(array('where'=>'rid='.$rid.' and status=2 ','asArray'=>true)); if (empty($receiptDetail)) return "/approval"; $reviseDetail=array(); if (empty($receiptDetail['reviseDetail'])){ array_push($reviseDetail, array('sid'=>$this->staff[0]['sid'],'name'=>$this->staff[0]['username'],'description'=>$description,'price'=>$price)); $reviseDetailString=json_encode($reviseDetail); $receipt->reviseDetail=$reviseDetailString; $receipt->revisePrice=$price; $receipt->sum=bcadd($receiptDetail['sum'],$price,2); }else{ $reviseDetail=json_decode($receiptDetail['reviseDetail'],true); array_push($reviseDetail,array('sid'=>$this->staff[0]['sid'],'name'=>$this->staff[0]['username'],'description'=>$description,'price'=>$price)); $reviseDetailString=json_encode($reviseDetail); $receipt->reviseDetail=$reviseDetailString; $receipt->revisePrice=round($price,2)+round($receiptDetail['revisePrice'],2); $receipt->sum=bcadd($receiptDetail['sum'],$price,2); } $receipt->update(array('where'=>'rid='.$rid)); } return "/approval"; } function personalCollect(){ $year=$this->get_args('year')?$this->get_args('year'):date("Y"); $path=SITE_PATH.$this->PERSONALCOLLECTCACHEPATH."personalCollect_".$year.".htmls"; $this->showCache($path); Doo::loadModel("receiptDetail"); Doo::loadModel("itemStatistics"); Doo::loadModel('statistics'); $statistics=new statistics(); $itemStatistics=new itemStatistics(); $receiptDetail=new receiptDetail(); $receiptCollectList=$receiptDetail->find(array('select'=>'staff,sum(price) as price,itemCategory,Month(date) as month', 'where'=>'staff='.$this->staff[0]['sid']." and status=1 and Year(date)=".$year,'groupby'=>'itemCategory,Month(date)','asArray'=>true)); $data['itemStatisticsList']=$itemStatistics->find(array('where'=>'staff='.$this->staff[0]['sid'],'asArray'=>true)); //create collect html $collectArray=array('日常相关费用'=>array(),'差旅相关费用'=>array(),'培训班费用'=>array(),'其他'=>array()); $adjustment=array(); $collectHtml=$this->collectHtml($receiptCollectList,'日常相关费用'); array_push($collectArray['日常相关费用'], $collectHtml); $collectHtml=$this->collectHtml($receiptCollectList,'差旅相关费用'); array_push($collectArray['差旅相关费用'], $collectHtml); $collectHtml=$this->collectHtml($receiptCollectList,'培训班费用'); array_push($collectArray['培训班费用'], $collectHtml); $collectHtml=$this->collectHtml($receiptCollectList,'其他'); array_push($collectArray['其他'], $collectHtml); $data['collectArray']=$collectArray; //statistics html $stList=$statistics->statisticsByYear($year,$this->staff[0]['sid']); if(empty($stList)) $stList=array('rePrice'=>0,'agPrice'=>0); $data['stList']=array('rePrice'=>$stList['rePrice'],'agPrice'=>$stList['agPrice'],'skPrice'=>($stList['rePrice']-$stList['agPrice'])); //Adjustment price html $collectHtml=$this->collectHtml($receiptCollectList,'报销金额调整'); array_push($adjustment, $collectHtml); $data['adjustment']=$adjustment; //total price html $collectHtml="";$total=0; for ($i=1;$i<=12;$i++){ $sumPrice=0; foreach ($receiptCollectList as $key=>$value){ if($value['month']==$i){ $sumPrice+=$value['price']; } } if ($sumPrice==0) $collectHtml.='-'; else $collectHtml.='¥'.$sumPrice.''; $total+=$sumPrice; } $collectHtml.='¥'.$total.''; $data['totalPrice']=$collectHtml; $data['year']=$year; $data['totalYear']=$total; $data['memu']="receipt"; $data['staff']=$this->staff; $data['receiptMemu']='personalCollect'; $data['verifyId']=$this->verifyId; //year staff status 2,4 if($yearfind(array('where'=>'staff='.$this->staff[0]['sid'].' and (status=2 or status=4) and Year(date) ='.$year,'asArray'=>true)); if(empty($receiptList)){ ob_start(); $this->render ( "/admin/saea_slist_collect", $data ); $this->cacheFile($path);die; } } $this->render ( "/admin/saea_slist_collect", $data ); } function personalCollectDetail(){ $year=$this->get_args('year')?$this->get_args('year'):date("Y"); $path=SITE_PATH.$this->PERSONALCOLLECTCACHEPATH."personalCollectDetail_".$year.".htmls"; $this->showCache($path); Doo::loadModel("receiptDetail"); Doo::loadModel("itemStatistics"); Doo::loadModel('statistics'); Doo::loadModel('accountItem'); $accountItem=new accountItem(); $statistics=new statistics(); $itemStatistics=new itemStatistics(); $receiptDetail=new receiptDetail(); $receiptCollectList=$receiptDetail->find(array('select'=>'staff,item,sum(price) as price,itemCategory,Month(date) as month', 'where'=>'staff='.$this->staff[0]['sid']." and status=1 and Year(date)=".$year,'groupby'=>'item,Month(date)','asArray'=>true)); $accountList=$accountItem->find(array('asArray'=>true)); //create CollectDetail HTML $collectHtml=array(); foreach ($accountList as $key=>$value){ $html="";$asum=0; for ($i=1;$i<=12;$i++){ $falg=true; foreach ($receiptCollectList as $v) { if($value['category']==$v['itemCategory']&&$v['item']==$value['name']&&$i==$v['month']){ $asum+=$v['price']; $html.='¥'.$v['price'].'';$falg=false;break; } } if($falg) $html.='-'; } $html.='¥'.$asum.''; $collectHtml[$value['category']][$value['name']]=$html; } $data['collectHtml']=$collectHtml; //create Adjustment price html $receiptCollectList=$receiptDetail->find(array('select'=>'staff,sum(price) as price,itemCategory,Month(date) as month', 'where'=>'staff='.$this->staff[0]['sid']." and status=1 and Year(date)=".$year,'groupby'=>'itemCategory,Month(date)','asArray'=>true)); $adjustment=array();$collectArray=array('日常相关费用'=>array(),'差旅相关费用'=>array(),'培训班费用'=>array(),'其他'=>array()); $collectHtml=$this->collectHtml($receiptCollectList,'日常相关费用','b'); array_push($collectArray['日常相关费用'], $collectHtml); $collectHtml=$this->collectHtml($receiptCollectList,'差旅相关费用','b'); array_push($collectArray['差旅相关费用'], $collectHtml); $collectHtml=$this->collectHtml($receiptCollectList,'培训班费用','b'); array_push($collectArray['培训班费用'], $collectHtml); $collectHtml=$this->collectHtml($receiptCollectList,'其他','b'); array_push($collectArray['其他'], $collectHtml); $collectHtml=$this->collectHtml($receiptCollectList,'报销金额调整'); array_push($adjustment, $collectHtml); //total price html $collectHtml="";$total=0; for ($i=1;$i<=12;$i++){ $sumPrice=0; foreach ($receiptCollectList as $key=>$value){ if($value['month']==$i){ $sumPrice+=$value['price']; } } if ($sumPrice==0) $collectHtml.='-'; else $collectHtml.='¥'.$sumPrice.''; $total+=$sumPrice; } $collectHtml.='¥'.$total.''; //statistics html $stList=$statistics->statisticsByYear($year,$this->staff[0]['sid']); if(empty($stList)) $stList=array('rePrice'=>0,'agPrice'=>0); $data['stList']=array('rePrice'=>$stList['rePrice'],'agPrice'=>$stList['agPrice'],'skPrice'=>($stList['rePrice']-$stList['agPrice'])); $data['collectArray']=$collectArray; $data['adjustment']=$adjustment; $data['totalPrice']=$collectHtml; $data['totalYear']=$total; $data['year']=$year; $data['memu']="receipt"; $data['staff']=$this->staff; $data['receiptMemu']='personalCollect'; $data['verifyId']=$this->verifyId; //year staff status 2,4 if($yearfind(array('where'=>'staff='.$this->staff[0]['sid'].' and (status=2 or status=4) and Year(date) ='.$year,'asArray'=>true)); if(empty($receiptList)){ ob_start(); $this->render ( "/admin/saeaCollectArticles", $data ); $this->cacheFile($path);die; } } $this->render ( "/admin/saeaCollectArticles", $data ); } function companyCategoryCollect(){ $year=$this->get_args('year')?$this->get_args('year'):date("Y"); $path=SITE_PATH.$this->CATEGORYCOLLECTPATH."categoryCollect_".$year.".htmls"; $this->showCache($path); Doo::loadModel('L_category'); Doo::loadModel('itemStatistics'); Doo::loadModel('statistics'); $statistics=new statistics(); $Lcategory=new L_category(); $itemStatistics=new itemStatistics(); $LcategoryList=$Lcategory->find(array('asArray'=>true));//'staff='.$this->staff[0]['sid']." and $itemStatisticsList=$itemStatistics->find(array('select'=>'cid,staff,sum(price) as price,itemCategory,Month(date) as month', 'where'=>" Year(date)=".$year,'groupby'=>'cid,Month(date)','asArray'=>true)); //ceatre companyCollectHtml foreach ($LcategoryList as $value){ $html="";$asum=0; for ($i=1;$i<=12;$i++){ $falg=true; foreach ($itemStatisticsList as $v){ if($value['cid']==$v['cid']&&$i==$v['month']){ $asum+=$v['price']; $html.='¥'.$v['price'].'';$falg=false;break; } } if($falg) $html.='-'; } $html.='¥'.$asum.''; $collectHtml[$value['title']]=array('html'=>$html,'cid'=>$value['cid']); } $data['companyHtml']=$collectHtml; //total price html $collectHtml="";$total=0; for ($i=1;$i<=12;$i++){ $sumPrice=0; foreach ($itemStatisticsList as $key=>$value){ if($value['month']==$i){ $sumPrice+=$value['price']; } } if ($sumPrice==0) $collectHtml.='-'; else $collectHtml.='¥'.$sumPrice.''; $total+=$sumPrice; } $collectHtml.='¥'.$total.''; $data['companyTotalHtml']=$collectHtml; $data['total']=$total; //statistics html $stList=$statistics->statisticsByComPanyYear($year,$this->staff[0]['sid']); if(empty($stList)) $stList=array('rePrice'=>0,'agPrice'=>0); $data['stList']=array('rePrice'=>$stList['rePrice'],'agPrice'=>$stList['agPrice'],'skPrice'=>($stList['rePrice']-$stList['agPrice'])); $data['year']=$year; $data['memu']="receipt"; $data['staff']=$this->staff; $data['receiptMemu']='companyCategoryCollect'; $data['verifyId']=$this->verifyId; //year staff status 2,4 if($yearfind(array('where'=>'Year(date) ='.$year.' and (status=2 or status=4)','asArray'=>true)); if(empty($receiptList)){ ob_start(); $this->render ( "/admin/saeaCompanyCollect", $data ); $this->cacheFile($path);die; } } $this->render ( "/admin/saeaCompanyCollect", $data ); } function categoryCollectDetail(){ $year=$this->get_args('year')?$this->get_args('year'):date("Y"); $cid=isset($this->params['cid'])&&is_numeric($this->params['cid'])?$this->params['cid']:0; $path=SITE_PATH.$this->CATEGORYCOLLECTPATH."categoryCollectDetail_".$year."_".$cid.".htmls"; $this->showCache($path); Doo::loadModel('statistics'); $statistics=new statistics(); Doo::loadModel("receiptDetail"); $receiptDetail=new receiptDetail(); Doo::loadModel('L_category'); $Lcategory=new L_category(); Doo::loadModel('accountItem'); $accountItem=new accountItem(); $LcategoryList=$Lcategory->find(array('asArray'=>true)); if ($cid==0){ $cid=$this->get_args('cid')?$this->get_args('cid'):0; if ($cid==0) $cid=$LcategoryList[0]['cid']; } $data['LcategoryList']=$LcategoryList; $receiptCollectList=$receiptDetail->find(array('select'=>'staff,item,sum(price) as price,itemCategory,Month(date) as month', 'where'=>'cid='.$cid." and status=1 and Year(date)=".$year,'groupby'=>'item,Month(date)','asArray'=>true)); $accountList=$accountItem->find(array('asArray'=>true)); //create CollectDetail HTML $collectHtml=array(); foreach ($accountList as $key=>$value){ $html="";$asum=0; for ($i=1;$i<=12;$i++){ $falg=true; foreach ($receiptCollectList as $v) { if($value['category']==$v['itemCategory']&&$v['item']==$value['name']&&$i==$v['month']){ $asum+=$v['price']; $html.='¥'.$v['price'].'';$falg=false;break; } } if($falg) $html.='-'; } $html.='¥'.$asum.''; $collectHtml[$value['category']][$value['name']]=$html; } $data['collectHtml']=$collectHtml; //create Adjustment price html $receiptCollectList=$receiptDetail->find(array('select'=>'staff,sum(price) as price,itemCategory,Month(date) as month', 'where'=>'cid='.$cid." and status=1 and Year(date)=".$year,'groupby'=>'itemCategory,Month(date)','asArray'=>true)); $adjustment=array();$collectArray=array('日常相关费用'=>array(),'差旅相关费用'=>array(),'培训班费用'=>array(),'其他'=>array()); $collectHtml=$this->collectHtml($receiptCollectList,'日常相关费用','b'); array_push($collectArray['日常相关费用'], $collectHtml); $collectHtml=$this->collectHtml($receiptCollectList,'差旅相关费用','b'); array_push($collectArray['差旅相关费用'], $collectHtml); $collectHtml=$this->collectHtml($receiptCollectList,'培训班费用','b'); array_push($collectArray['培训班费用'], $collectHtml); $collectHtml=$this->collectHtml($receiptCollectList,'其他','b'); array_push($collectArray['其他'], $collectHtml); $data['collectArray']=$collectArray; $collectHtml=$this->collectHtml($receiptCollectList,'报销金额调整'); array_push($adjustment, $collectHtml); $data['adjustment']=$adjustment; //total price html $collectHtml="";$total=0; for ($i=1;$i<=12;$i++){ $sumPrice=0; foreach ($receiptCollectList as $key=>$value){ if($value['month']==$i){ $sumPrice+=$value['price']; } } if ($sumPrice==0) $collectHtml.='-'; else $collectHtml.='¥'.$sumPrice.''; $total+=$sumPrice; } $collectHtml.='¥'.$total.''; //statistics html $stList=$statistics->statisticsByCid($year,$cid); if(empty($stList)) $stList=array('rePrice'=>0,'agPrice'=>0); $data['stList']=array('rePrice'=>$stList['rePrice'],'agPrice'=>$stList['agPrice'],'skPrice'=>($stList['rePrice']-$stList['agPrice'])); $data['totalYear']=$total; $data['year']=$year; $data['cid']=$cid; $data['memu']="receipt"; $data['staff']=$this->staff; $data['receiptMemu']='companyCategoryCollect'; $data['verifyId']=$this->verifyId; //year staff status 2,4 if($yearfind(array('where'=>'Year(date) ='.$year.' and cid ='.$cid.' and (status=2 or status=4)','asArray'=>true)); if(empty($receiptList)){ ob_start(); $this->render ( "/admin/saeaCategoryCollectDetail", $data ); $this->cacheFile($path);die; } } $this->render ( "/admin/saeaCategoryCollectDetail", $data ); } function staffCollect(){ $year=$this->get_args('year')?$this->get_args('year'):date("Y"); $path=SITE_PATH.$this->STAFFCOLLECTPATH."staffCollect_".$year."_.htmls"; //$this->showCache($path); Doo::loadModel('statistics'); $statistics=new statistics(); Doo::loadModel("receiptDetail"); $receiptDetail=new receiptDetail(); Doo::loadModel('L_category'); $Lcategory=new L_category(); Doo::loadModel('accountItem'); $accountItem=new accountItem(); Doo::loadModel('staff'); $staff=new staff(); Doo::loadModel('itemStatistics'); $itemStatistics=new itemStatistics(); /* $stList=$statistics->getOne(array('select'=>'sum(rePrice) as rePrice,sum(agPrice) as agPrice', 'where'=>" Year(date)=".$year,'groupby'=>'Month(date)','asArray'=>true)); if(empty($stList)) $stList=array('rePrice'=>0,'agPrice'=>0); $data['stList']=array('rePrice'=>$stList['rePrice'],'agPrice'=>$stList['agPrice'],'skPrice'=>($stList['rePrice']-$stList['agPrice'])); */ //statistics html $stList=$statistics->statisticsByComPanyYear($year,$this->staff[0]['sid']); if(empty($stList)) $stList=array('rePrice'=>0,'agPrice'=>0); $data['stList']=array('rePrice'=>$stList['rePrice'],'agPrice'=>$stList['agPrice'],'skPrice'=>($stList['rePrice']-$stList['agPrice'])); //--- $staffList=$staff->find(array('where'=>'username !="admin"','asArray'=>true)); $LcategoryList=$Lcategory->find(array('asArray'=>true));//'staff='.$this->staff[0]['sid']." and $itemStatisticsList=$itemStatistics->find(array('select'=>'cid,staff,sum(price) as price,itemCategory,Month(date) as month', 'where'=>" Year(date)=".$year,'groupby'=>'staff,Month(date)','asArray'=>true)); $categoryList=$staff->find(array('select'=>'COUNT(*) as count,cid,category','where'=>'username !="admin"','groupby'=>'cid','asArray'=>true)); //ceatre companyCollectHtml foreach ($categoryList as $vlu){ $count=$vlu['count']+1; $html=''.$vlu['category'].''; $m1=0;$m2=0;$m3=0;$m4=0;$m5=0;$m6=0;$m7=0;$m8=0;$m9=0;$m10=0;$m11=0;$m12=0;$m13=0; foreach ($staffList as $value){ if ($vlu['cid']==$value['cid']){ $html.=''.$value['username'].''; $asum=0; for ($i=1;$i<=12;$i++){ $falg=true; foreach ($itemStatisticsList as $v){ if($value['sid']==$v['staff']&&$i==$v['month']){ if ($v['month']==1) $m1+=$v['price']; if ($v['month']==2) $m2+=$v['price']; if ($v['month']==3) $m3+=$v['price']; if ($v['month']==4) $m4+=$v['price']; if ($v['month']==5) $m5+=$v['price']; if ($v['month']==6) $m6+=$v['price']; if ($v['month']==7) $m7+=$v['price']; if ($v['month']==8) $m8+=$v['price']; if ($v['month']==9) $m9+=$v['price']; if ($v['month']==10) $m10+=$v['price']; if ($v['month']==11) $m11+=$v['price']; if ($v['month']==12) $m12+=$v['price']; $asum+=$v['price']; $html.='¥'.$v['price'].'';$falg=false;break; } } if($falg) $html.='-'; } $m13+=$asum; $html.='¥'.$asum.''; $collectHtml[$value['username']]=array('html'=>$html,'sid'=>$value['sid']); $html=""; } } $hl='小计¥'.$m1.'¥'.$m2.'¥'.$m3.'¥'.$m4.'¥'.$m5.' ¥'.$m6.'¥'.$m7.'¥'.$m8.'¥'.$m9.'¥'.$m10.'¥'.$m11.' ¥'.$m12.'¥'.$m13.''; $collectHtml[$vlu['cid']]=array('html'=>$hl,'sid'=>''); } $data['companyHtml']=$collectHtml; //total price html $collectHtml="";$total=0; for ($i=1;$i<=12;$i++){ $sumPrice=0; foreach ($itemStatisticsList as $key=>$value){ if($value['month']==$i){ $sumPrice+=$value['price']; } } if ($sumPrice==0) $collectHtml.='-'; else $collectHtml.='¥'.$sumPrice.''; $total+=$sumPrice; } $collectHtml.='¥'.$total.''; $data['companyTotalHtml']=$collectHtml; $data['total']=$total; $data['year']=$year; $data['memu']="receipt"; $data['staff']=$this->staff; $data['receiptMemu']='companyCategoryCollect'; $data['verifyId']=$this->verifyId; if ($year<=date("Y")){ Doo::loadModel('receipt'); $receipt=new receipt(); $receiptList=$receipt->find(array('where'=>'(status=2 or status=4) and Year(date) ='.$year,'asArray'=>true)); if(empty($receiptList)){ //generated files ob_start(); $this->render ( "/admin/saeaStaffCollectB", $data ); $this->cacheFile($path);die; } } $this->render ( "/admin/saeaStaffCollectB", $data ); } function staffCollectBak(){ $year=$this->get_args('year')?$this->get_args('year'):date("Y"); $month=$this->get_args('month')?$this->get_args('month'):1; $path=SITE_PATH.$this->STAFFCOLLECTPATH."staffCollect_".$year."_".$month.".htmls"; $this->showCache($path); Doo::loadModel('statistics'); $statistics=new statistics(); Doo::loadModel("receiptDetail"); $receiptDetail=new receiptDetail(); Doo::loadModel('L_category'); $Lcategory=new L_category(); Doo::loadModel('accountItem'); $accountItem=new accountItem(); Doo::loadModel('staff'); $staff=new staff(); Doo::loadModel('itemStatistics'); $itemStatistics=new itemStatistics(); $itemStatisticsList=$itemStatistics->find(array('select'=>'cid,staff,sum(price) as price,itemCategory,Month(date) as month', 'where'=>'Month(date)='.$month." and Year(date)=".$year,'groupby'=>'staff,itemCategory,Month(date)','asArray'=>true)); $itemCategoryList=$itemStatistics->find(array('select'=>'cid,staff,sum(price) as price,itemCategory,Month(date) as month', 'where'=>'Month(date)='.$month." and Year(date)=".$year,'groupby'=>'cid,itemCategory,Month(date)','asArray'=>true)); $LcategoryList=$Lcategory->find(array('asArray'=>true)); $staffList=$staff->find(array('asArray'=>true)); $htmlArray=array(); foreach ($LcategoryList as $value){ $htmlArray[$value['title']]=array(); foreach ($staffList as $v){ if($value['cid']==$v['cid']){ $html="";$falg=true;$staffSumPrice=0; foreach ($itemStatisticsList as $a){ if($v['sid']==$a['staff']&&$a['itemCategory']=="日常相关费用"){ if(empty($a['price'])){ $html.='-';$falg=false;break; }else{ $staffSumPrice+=$a['price']; $html.='¥'.$a['price'].'';$falg=false;break; } } } if ($falg){ $html.='-';$falg=true; } $falg=true; foreach ($itemStatisticsList as $a){ if($v['sid']==$a['staff']&&$a['itemCategory']=="差旅相关费用"){ if(empty($a['price'])){ $html.='-';$falg=false;break; }else{ $staffSumPrice+=$a['price']; $html.='¥'.$a['price'].'';$falg=false;break; } } } if ($falg){ $html.='-';$falg=true; } $falg=true; foreach ($itemStatisticsList as $a){ if($v['sid']==$a['staff']&&$a['itemCategory']=="培训班费用"){ if(empty($a['price'])){ $html.='-';$falg=false;break; }else{ $staffSumPrice+=$a['price']; $html.='¥'.$a['price'].'';$falg=false;break; } } } if ($falg){ $html.='-';$falg=true; } $falg=true; foreach ($itemStatisticsList as $a){ if($v['sid']==$a['staff']&&$a['itemCategory']=="其他"){ if(!empty($a['price'])){ $staffSumPrice+=$a['price']; $html.='¥'.$a['price'].'';$falg=false;break; }else{ $html.='-';$falg=false;break; } } } if ($falg){ $html.='-';$falg=true; } $falg=true; foreach ($itemStatisticsList as $a){ if($v['sid']==$a['staff']&&$a['itemCategory']=="报销金额调整"){ if(!empty($a['price'])){ $staffSumPrice+=$a['price']; $html.='¥'.$a['price'].'';$falg=false;break; }else{ $html.='-';$falg=false;break; } } } if ($falg){ $html.='-';$falg=true; } $html.='¥'.$staffSumPrice.''; $htmlArray[$value['title']][$v['username']]=$html; } } /*-- ---*/ //合计费用 $cateHtml="";$catePrice=0;$cateFalg=true; foreach ($itemCategoryList as $l){ if($value['cid']==$l['cid']&&$l['itemCategory']=="日常相关费用"){ if(empty($l['price'])){ $cateHtml.='-';$cateFalg=false;break; }else{ $catePrice+=$l['price']; $cateHtml.='¥'.$l['price'].'';$cateFalg=false;break; } } } if ($cateFalg){ $cateHtml.='-';$cateFalg=true; } $cateFalg=true; foreach ($itemCategoryList as $l){ if($value['cid']==$l['cid']&&$l['itemCategory']=="差旅相关费用"){ if(empty($l['price'])){ $cateHtml.='-';$cateFalg=false;break; }else{ $catePrice+=$l['price']; $cateHtml.='¥'.$l['price'].'';$cateFalg=false;break; } } } if ($cateFalg){ $cateHtml.='-';$cateFalg=true; } $cateFalg=true; foreach ($itemCategoryList as $l){ if($value['cid']==$l['cid']&&$l['itemCategory']=="培训班费用"){ if(empty($l['price'])){ $cateHtml.='-';$cateFalg=false;break; }else{ $catePrice+=$l['price']; $cateHtml.='¥'.$l['price'].'';$cateFalg=false;break; } } } if ($cateFalg){ $cateHtml.='-';$cateFalg=true; } $cateFalg=true; foreach ($itemCategoryList as $l){ if($value['cid']==$l['cid']&&$l['itemCategory']=="其他"){ if(empty($l['price'])){ $cateHtml.='-';$cateFalg=false;break; }else{ $catePrice+=$l['price']; $cateHtml.='¥'.$l['price'].'';$cateFalg=false;break; } } } if ($cateFalg){ $cateHtml.='-';$cateFalg=true; } $cateFalg=true; foreach ($itemCategoryList as $l){ if($value['cid']==$l['cid']&&$l['itemCategory']=="报销金额调整"){ if(empty($l['price'])){ $cateHtml.='-';$cateFalg=false;break; }else{ $catePrice+=$l['price']; $cateHtml.='¥'.$l['price'].'';$cateFalg=false;break; } } } if ($cateFalg){ $cateHtml.='-';$cateFalg=true; } $cateHtml.='¥'.$catePrice.''; $htmlArray[$value['title']]['合计']=$cateHtml; /*-- ---*/ } //print_r($htmlArray);die; $data['htmlArray']=$htmlArray; //statistics html $stList=$statistics->getOne(array('select'=>'sum(rePrice) as rePrice,sum(agPrice) as agPrice', 'where'=>'Month(date)='.$month." and Year(date)=".$year,'groupby'=>'Month(date)','asArray'=>true)); if(empty($stList)) $stList=array('rePrice'=>0,'agPrice'=>0); $data['stList']=array('rePrice'=>$stList['rePrice'],'agPrice'=>$stList['agPrice'],'skPrice'=>($stList['rePrice']-$stList['agPrice'])); $monthHtml=""; for ($i=1;$i<=12;$i++){ if ($i==$month) $monthHtml.=''; else $monthHtml.=''; } $data['monthHtml']=$monthHtml; $data['year']=$year; $data['month']=$month; $data['memu']="receipt"; $data['staff']=$this->staff; $data['receiptMemu']='companyCategoryCollect'; $data['verifyId']=$this->verifyId; if (!empty($month)&&($year<=date("Y"))&&($monthfind(array('where'=>'(status=2 or status=4) and Year(date) ='.$year.' and Month(date) ='.$month,'asArray'=>true)); if(empty($receiptList)){ //generated files ob_start(); $this->render ( "/admin/saeaStaffCollect", $data ); $this->cacheFile($path);die; } } $this->render ( "/admin/saeaStaffCollect", $data ); } function staffCollectMonthDetail(){ $year=$this->get_args('year')?$this->get_args('year'):""; $month=$this->get_args('month')?$this->get_args('month'):""; if(!$year) $year=isset($this->params['year'])?$this->params['year']:date("Y"); if(!$month) $month=isset($this->params['month'])?$this->params['month']:1; Doo::loadModel('staff'); $staff=new staff(); Doo::loadModel("receiptDetail"); $receiptDetail=new receiptDetail(); Doo::loadModel('accountItem'); $accountItem=new accountItem(); Doo::loadModel('statistics'); $statistics=new statistics(); Doo::loadModel('L_category'); $lCategory=new L_category(); $staffList=$staff->find(array('where'=>'username!="admin"','asArray'=>true)); $categoryList=$staff->find(array('select'=>'COUNT(*) as count,cid,category','where'=>'username !="admin"','groupby'=>'cid','asArray'=>true)); $list=array(); foreach ($categoryList as $vlu){ //$html=''.$v['category'].''; $r1=0;$r2=0;$r3=0;$r4=0;$r5=0;$r6=0;$r7=0;$r8=0;$r9=0;$r10=0;$r11=0;$r12=0;$r13=0; $c1=0;$c2=0;$c3=0;$c4=0;$c5=0;$c6=0; $p1=0;$p2=0;$p3=0;$p4=0;$p5=0;$p6=0;$p7=0;$p8=0;$p9=0; $t1=0;$t2=0;$t3=0;$t4=0;$t5=0; $s1=0; $m1=0; foreach ($staffList as $value){ if ($vlu['cid']==$value['cid']){ $receiptCollectList=$receiptDetail->find(array('select'=>'staff,item,sum(price) as price,itemCategory,Month(date) as month', 'where'=>'staff='.$value['sid']." and status=1 and Year(date)=".$year.' and Month(date)='.$month,'groupby'=>'item,Month(date),itemCategory','asArray'=>true)); if(!empty($receiptCollectList)){ $receiptL=array('日常相关费用'=>array(),'差旅相关费用'=>array(),'培训班费用'=>array(),'其他'=>array()); $html=""; $psum=0; $item=array('市内交通费','市内出租费','办事处房租','电话费','水费','电费','办公费用','邮寄费','其他费用','车辆费用','广告费','团队建设费'); foreach ($item as $va){ $falg=true; foreach ($receiptCollectList as $v){ if($v['itemCategory']=='日常相关费用'){ if($v['item']==$va){ if ($va=='市内交通费') $r1+=$v['price']; if ($va=='市内出租费') $r2+=$v['price']; if ($va=='办事处房租') $r3+=$v['price']; if ($va=='电话费') $r4+=$v['price']; if ($va=='水费') $r5+=$v['price']; if ($va=='电费') $r6+=$v['price']; if ($va=='办公费用') $r7+=$v['price']; if ($va=='邮寄费') $r8+=$v['price']; if ($va=='其他费用') $r9+=$v['price']; if ($va=='车辆费用') $r10+=$v['price']; if ($va=='广告费') $r11+=$v['price']; if ($va=='团队建设费') $r13+=$v['price']; $psum+=$v['price']; $html.=''.$v['price'].'';$falg=false;break; } } } if($falg) $html.='-'; } $r12+=$psum; if(!empty($psum)) $psum='¥'.$psum.''; else $psum='-'; $receiptL['日常相关费用']=$psum.$html; /*-----------------------------------*/ $html=""; $psum=0; $item=array('往来交通费','市内交通费','出差住宿费','出差补助','其他费用'); foreach ($item as $va){ $falg=true; foreach ($receiptCollectList as $v){ if($v['itemCategory']=='差旅相关费用'){ if($v['item']==$va){ if ($va=='往来交通费') $c1+=$v['price']; if ($va=='市内交通费') $c2+=$v['price']; if ($va=='出差住宿费') $c3+=$v['price']; if ($va=='出差补助') $c4+=$v['price']; if ($va=='其他费用') $c5+=$v['price']; $psum+=$v['price']; $html.=''.$v['price'].'';$falg=false;break; } } } if($falg) $html.='-'; } $c6+=$psum; if(!empty($psum)) $psum='¥'.$psum.''; else $psum='-'; $receiptL['差旅相关费用']=$psum.$html; /*-------------------------------------*/ $html=""; $psum=0; $item=array('场租费','薪酬','住宿费','交通费','餐饮费','办公费','公关费','其他'); foreach ($item as $va){ $falg=true; foreach ($receiptCollectList as $v){ if($v['itemCategory']=='培训班费用'){ if($v['item']==$va){ if ($va=='场租费') $p1+=$v['price']; if ($va=='薪酬') $p2+=$v['price']; if ($va=='住宿费') $p3+=$v['price']; if ($va=='交通费') $p4+=$v['price']; if ($va=='餐饮费') $p5+=$v['price']; if ($va=='办公费') $p6+=$v['price']; if ($va=='公关费') $p7+=$v['price']; if ($va=='其他') $p8+=$v['price']; $psum+=$v['price']; $html.=''.$v['price'].'';$falg=false;break; } } } if($falg) $html.='-'; } $p9+=$psum; if(!empty($psum)) $psum='¥'.$psum.''; else $psum='-'; $receiptL['培训班费用']=$psum.$html; /*-------------------------------------*/ $html=""; $psum=0; $item=array('公关费','广告费','借款','可自加费用'); foreach ($item as $va){ $falg=true; foreach ($receiptCollectList as $v){ if($v['itemCategory']=='其他'){ if($v['item']==$va){ if ($va=='公关费') $t1+=$v['price']; if ($va=='广告费') $t2+=$v['price']; if ($va=='借款') $t3+=$v['price']; if ($va=='可自加费用') $t4+=$v['price']; $psum+=$v['price']; $html.=''.$v['price'].'';$falg=false;break; } } } if($falg) $html.='-'; } $t5+=$psum; if(!empty($psum)) $psum='¥'.$psum.''; else $psum='-'; $receiptL['其他']=$psum.$html; /*-------------------------------------*/ $html=""; $psum=0; foreach ($receiptCollectList as $v){ if($v['itemCategory']=='报销金额调整'){ if (!empty($v['price'])){ $psum+=$v['price']; } } } $s1+=$psum; if(!empty($psum)) $psum='¥'.$psum.''; else $psum='-'; $receiptL['报销金额调整']=$psum.$html; }else{ $receiptL['日常相关费用']='----- --------'; $receiptL['差旅相关费用']='-- ----'; $receiptL['培训班费用']='----- ----'; $receiptL['其他']='-----'; $receiptL['报销金额调整']='-'; } $monthStaffPrice=$receiptDetail->find(array('select'=>'staff,item,sum(price) as price,itemCategory,Month(date) as month', 'where'=>'staff='.$value['sid']." and status=1 and Year(date)=".$year.' and Month(date)='.$month,'asArray'=>true)); if(!empty($monthStaffPrice[0]['price'])){ $m1+=$monthStaffPrice[0]['price']; $receiptL['monthStaffPrice']='¥'.$monthStaffPrice[0]['price'].''; }else $receiptL['monthStaffPrice']='-'; $list[$value['username']]=$receiptL; } } $receiptL['日常相关费用']=''.$r12.''.$r1.''.$r2.''.$r3.''.$r4.''.$r5.' '.$r6.''.$r7.''.$r8.''.$r9.''.$r10.''.$r11.''.$r13.''; $receiptL['差旅相关费用']=''.$c6.''.$c1.' '.$c2.''.$c3.''.$c4.''.$c5.''; $receiptL['培训班费用']=''.$p9.''.$p1.''.$p2.''.$p3.''.$p4.' '.$p5.''.$p6.''.$p7.''.$p8.''; $receiptL['其他']=''.$t5.''.$t1.''.$t2.''.$t3.''.$t4.''; $receiptL['报销金额调整']=''.$s1.''; $receiptL['monthStaffPrice']='¥'.$m1.''; $list[''.$vlu['category'].'小计']=$receiptL; } $data['list']=$list; $receiptCollectList=$receiptDetail->find(array('select'=>'staff,item,sum(price) as price,itemCategory,Month(date) as month', 'where'=>" status=1 and Year(date)=".$year.' and Month(date)='.$month,'groupby'=>'item,Month(date),itemCategory','asArray'=>true)); $data['monthPriceHtml']=$this->_getMonthCollectDetail($receiptCollectList); //statistics html $stList=$statistics->getOne(array('select'=>'sum(rePrice) as rePrice,sum(agPrice) as agPrice', 'where'=>'Month(date)='.$month." and Year(date)=".$year,'groupby'=>'Month(date)','asArray'=>true)); if(empty($stList)) $stList=array('rePrice'=>0,'agPrice'=>0); $data['stList']=array('rePrice'=>$stList['rePrice'],'agPrice'=>$stList['agPrice'],'skPrice'=>($stList['rePrice']-$stList['agPrice'])); $monthHtml=""; for ($i=1;$i<=12;$i++){ if ($i==$month) $monthHtml.=''; else $monthHtml.=''; } $data['monthHtml']=$monthHtml; $data['year']=$year; $data['month']=$month; $data['memu']="receipt"; $data['staff']=$this->staff; $data['receiptMemu']='companyCategoryCollect'; $data['verifyId']=$this->verifyId; $this->render ( "/admin/staffCollectMonthDetail", $data ); //$this->render ( "/admin/saeaStaffCollectDetail", $data ); } function staffCollectMonthDetail2(){ $year=$this->get_args('year')?$this->get_args('year'):""; $month=$this->get_args('month')?$this->get_args('month'):""; if(!$year) $year=isset($this->params['year'])?$this->params['year']:date("Y"); if(!$month) $month=isset($this->params['month'])?$this->params['month']:1; Doo::loadModel('staff'); $staff=new staff(); Doo::loadModel("receiptDetail"); $receiptDetail=new receiptDetail(); Doo::loadModel('accountItem'); $accountItem=new accountItem(); Doo::loadModel('statistics'); $statistics=new statistics(); Doo::loadModel('L_category'); $lCategory=new L_category(); $staffList=$staff->find(array('where'=>'username!="admin"','asArray'=>true)); $categoryList=$staff->find(array('select'=>'COUNT(*) as count,cid,category','where'=>'username !="admin"','groupby'=>'cid','asArray'=>true)); $list=array(); foreach ($categoryList as $vlu){ //$html=''.$v['category'].''; $r1=0;$r2=0;$r3=0;$r4=0;$r5=0;$r6=0;$r7=0;$r8=0;$r9=0;$r10=0;$r11=0;$r12=0;$r13=0; $c1=0;$c2=0;$c3=0;$c4=0;$c5=0;$c6=0; $p1=0;$p2=0;$p3=0;$p4=0;$p5=0;$p6=0;$p7=0;$p8=0;$p9=0; $t1=0;$t2=0;$t3=0;$t4=0;$t5=0; $s1=0; $m1=0; foreach ($staffList as $value){ if ($vlu['cid']==$value['cid']){ $receiptCollectList=$receiptDetail->find(array('select'=>'staff,item,sum(price) as price,itemCategory,Month(date) as month', 'where'=>'staff='.$value['sid']." and status=1 and Year(date)=".$year.' and Month(date)='.$month,'groupby'=>'item,Month(date),itemCategory','asArray'=>true)); if(!empty($receiptCollectList)){ $receiptL=array('日常相关费用'=>array(),'差旅相关费用'=>array(),'培训班费用'=>array(),'其他'=>array()); $html=""; $psum=0; $item=array('市内交通费','市内出租费','办事处房租','电话费','水费','电费','办公费用','邮寄费','其他费用','车辆费用','广告费','团队建设费'); foreach ($item as $va){ $falg=true; foreach ($receiptCollectList as $v){ if($v['itemCategory']=='日常相关费用'){ if($v['item']==$va){ if ($va=='市内交通费') $r1+=$v['price']; if ($va=='市内出租费') $r2+=$v['price']; if ($va=='办事处房租') $r3+=$v['price']; if ($va=='电话费') $r4+=$v['price']; if ($va=='水费') $r5+=$v['price']; if ($va=='电费') $r6+=$v['price']; if ($va=='办公费用') $r7+=$v['price']; if ($va=='邮寄费') $r8+=$v['price']; if ($va=='其他费用') $r9+=$v['price']; if ($va=='车辆费用') $r10+=$v['price']; if ($va=='广告费') $r11+=$v['price']; if ($va=='团队建设费') $r13+=$v['price']; $psum+=$v['price']; $html.=''.$v['price'].'';$falg=false;break; } } } if($falg) $html.='-'; } $r12+=$psum; if(!empty($psum)) $psum='¥'.$psum.''; else $psum='-'; $receiptL['日常相关费用']=$psum.$html; /*-----------------------------------*/ $html=""; $psum=0; $item=array('往来交通费','市内交通费','出差住宿费','出差补助','其他费用'); foreach ($item as $va){ $falg=true; foreach ($receiptCollectList as $v){ if($v['itemCategory']=='差旅相关费用'){ if($v['item']==$va){ if ($va=='往来交通费') $c1+=$v['price']; if ($va=='市内交通费') $c2+=$v['price']; if ($va=='出差住宿费') $c3+=$v['price']; if ($va=='出差补助') $c4+=$v['price']; if ($va=='其他费用') $c5+=$v['price']; $psum+=$v['price']; $html.=''.$v['price'].'';$falg=false;break; } } } if($falg) $html.='-'; } $c6+=$psum; if(!empty($psum)) $psum='¥'.$psum.''; else $psum='-'; $receiptL['差旅相关费用']=$psum.$html; /*-------------------------------------*/ $html=""; $psum=0; $item=array('场租费','薪酬','住宿费','交通费','餐饮费','办公费','公关费','其他'); foreach ($item as $va){ $falg=true; foreach ($receiptCollectList as $v){ if($v['itemCategory']=='培训班费用'){ if($v['item']==$va){ if ($va=='场租费') $p1+=$v['price']; if ($va=='薪酬') $p2+=$v['price']; if ($va=='住宿费') $p3+=$v['price']; if ($va=='交通费') $p4+=$v['price']; if ($va=='餐饮费') $p5+=$v['price']; if ($va=='办公费') $p6+=$v['price']; if ($va=='公关费') $p7+=$v['price']; if ($va=='其他') $p8+=$v['price']; $psum+=$v['price']; $html.=''.$v['price'].'';$falg=false;break; } } } if($falg) $html.='-'; } $p9+=$psum; if(!empty($psum)) $psum='¥'.$psum.''; else $psum='-'; $receiptL['培训班费用']=$psum.$html; /*-------------------------------------*/ $html=""; $psum=0; $item=array('公关费','广告费','借款','可自加费用'); foreach ($item as $va){ $falg=true; foreach ($receiptCollectList as $v){ if($v['itemCategory']=='其他'){ if($v['item']==$va){ if ($va=='公关费') $t1+=$v['price']; if ($va=='广告费') $t2+=$v['price']; if ($va=='借款') $t3+=$v['price']; if ($va=='可自加费用') $t4+=$v['price']; $psum+=$v['price']; $html.=''.$v['price'].'';$falg=false;break; } } } if($falg) $html.='-'; } $t5+=$psum; if(!empty($psum)) $psum='¥'.$psum.''; else $psum='-'; $receiptL['其他']=$psum.$html; /*-------------------------------------*/ $html=""; $psum=0; foreach ($receiptCollectList as $v){ if($v['itemCategory']=='报销金额调整'){ if (!empty($v['price'])){ $psum+=$v['price']; } } } $s1+=$psum; if(!empty($psum)) $psum='¥'.$psum.''; else $psum='-'; $receiptL['报销金额调整']=$psum.$html; }else{ $receiptL['日常相关费用']='----- --------'; $receiptL['差旅相关费用']='-- ----'; $receiptL['培训班费用']='----- ----'; $receiptL['其他']='-----'; $receiptL['报销金额调整']='-'; } $monthStaffPrice=$receiptDetail->find(array('select'=>'staff,item,sum(price) as price,itemCategory,Month(date) as month', 'where'=>'staff='.$value['sid']." and status=1 and Year(date)=".$year.' and Month(date)='.$month,'asArray'=>true)); if(!empty($monthStaffPrice[0]['price'])){ $m1+=$monthStaffPrice[0]['price']; $receiptL['monthStaffPrice']='¥'.$monthStaffPrice[0]['price'].''; }else $receiptL['monthStaffPrice']='-'; $list[$value['username']]=$receiptL; } } $receiptL['日常相关费用']=''.$r12.''.$r1.''.$r2.''.$r3.''.$r4.''.$r5.' '.$r6.''.$r7.''.$r8.''.$r9.''.$r10.''.$r11.''.$r13.''; $receiptL['差旅相关费用']=''.$c6.''.$c1.' '.$c2.''.$c3.''.$c4.''.$c5.''; $receiptL['培训班费用']=''.$p9.''.$p1.''.$p2.''.$p3.''.$p4.' '.$p5.''.$p6.''.$p7.''.$p8.''; $receiptL['其他']=''.$t5.''.$t1.''.$t2.''.$t3.''.$t4.''; $receiptL['报销金额调整']=''.$s1.''; $receiptL['monthStaffPrice']='¥'.$m1.''; $list[''.$vlu['category'].'小计']=$receiptL; } $data['list']=$list; $receiptCollectList=$receiptDetail->find(array('select'=>'staff,item,sum(price) as price,itemCategory,Month(date) as month', 'where'=>" status=1 and Year(date)=".$year.' and Month(date)='.$month,'groupby'=>'item,Month(date),itemCategory','asArray'=>true)); $data['monthPriceHtml']=$this->_getMonthCollectDetail($receiptCollectList); //statistics html $stList=$statistics->getOne(array('select'=>'sum(rePrice) as rePrice,sum(agPrice) as agPrice', 'where'=>'Month(date)='.$month." and Year(date)=".$year,'groupby'=>'Month(date)','asArray'=>true)); if(empty($stList)) $stList=array('rePrice'=>0,'agPrice'=>0); $data['stList']=array('rePrice'=>$stList['rePrice'],'agPrice'=>$stList['agPrice'],'skPrice'=>($stList['rePrice']-$stList['agPrice'])); $monthHtml=""; for ($i=1;$i<=12;$i++){ if ($i==$month) $monthHtml.=''; else $monthHtml.=''; } $data['monthHtml']=$monthHtml; $data['year']=$year; $data['month']=$month; $data['memu']="receipt"; $data['staff']=$this->staff; $data['receiptMemu']='companyCategoryCollect'; $data['verifyId']=$this->verifyId; $this->render ( "/admin/staffCollectMonthDetail2", $data ); //$this->render ( "/admin/saeaStaffCollectDetail", $data ); } function companyMonthCollectDetail(){ $year=$this->get_args('year')?$this->get_args('year'):""; $month=$this->get_args('month')?$this->get_args('month'):""; if(!$year) $year=isset($this->params['year'])?$this->params['year']:date("Y"); if(!$month) $month=isset($this->params['month'])?$this->params['month']:1; Doo::loadModel('staff'); $staff=new staff(); Doo::loadModel("receiptDetail"); $receiptDetail=new receiptDetail(); Doo::loadModel('accountItem'); $accountItem=new accountItem(); Doo::loadModel('statistics'); $statistics=new statistics(); Doo::loadModel('L_category'); $lCategory=new L_category(); $staffList=$staff->find(array('where'=>'username!="admin"','asArray'=>true)); $categoryList=$lCategory->find(array('asArray'=>true)); $list=array(); foreach ($categoryList as $value){ $receiptCollectList=$receiptDetail->find(array('select'=>'staff,item,sum(price) as price,itemCategory,Month(date) as month', 'where'=>'cid='.$value['cid']." and status=1 and Year(date)=".$year.' and Month(date)='.$month,'groupby'=>'item,Month(date),itemCategory','asArray'=>true)); if(!empty($receiptCollectList)){ $receiptL=array('日常相关费用'=>array(),'差旅相关费用'=>array(),'培训班费用'=>array(),'其他'=>array()); $html=""; $psum=0; $item=array('市内交通费','市内出租费','办事处房租','电话费','水费','电费','办公费用','邮寄费','其他费用','车辆费用','广告费','团队建设费'); foreach ($item as $va){ $falg=true; foreach ($receiptCollectList as $v){ if($v['itemCategory']=='日常相关费用'){ if($v['item']==$va){ $psum+=$v['price']; $html.=''.$v['price'].'';$falg=false;break; } } } if($falg) $html.='-'; } if(!empty($psum)) $psum='¥'.$psum.''; else $psum='-'; $receiptL['日常相关费用']=$psum.$html; /*-----------------------------------*/ $html=""; $psum=0; $item=array('往来交通费','市内交通费','出差住宿费','出差补助','其他费用'); foreach ($item as $va){ $falg=true; foreach ($receiptCollectList as $v){ if($v['itemCategory']=='差旅相关费用'){ if($v['item']==$va){ $psum+=$v['price']; $html.=''.$v['price'].'';$falg=false;break; } } } if($falg) $html.='-'; } if(!empty($psum)) $psum='¥'.$psum.''; else $psum='-'; $receiptL['差旅相关费用']=$psum.$html; /*-------------------------------------*/ $html=""; $psum=0; $item=array('场租费','薪酬','住宿费','交通费','餐饮费','办公费','公关费','其他'); foreach ($item as $va){ $falg=true; foreach ($receiptCollectList as $v){ if($v['itemCategory']=='培训班费用'){ if($v['item']==$va){ $psum+=$v['price']; $html.=''.$v['price'].'';$falg=false;break; } } } if($falg) $html.='-'; } if(!empty($psum)) $psum='¥'.$psum.''; else $psum='-'; $receiptL['培训班费用']=$psum.$html; /*-------------------------------------*/ $html=""; $psum=0; $item=array('公关费','广告费','借款','可自加费用'); foreach ($item as $va){ $falg=true; foreach ($receiptCollectList as $v){ if($v['itemCategory']=='其他'){ if($v['item']==$va){ $psum+=$v['price']; $html.=''.$v['price'].'';$falg=false;break; } } } if($falg) $html.='-'; } if(!empty($psum)) $psum='¥'.$psum.''; else $psum='-'; $receiptL['其他']=$psum.$html; /*-------------------------------------*/ $html=""; $psum=0; foreach ($receiptCollectList as $v){ if($v['itemCategory']=='报销金额调整'){ if (!empty($v['price'])) $psum+=$v['price']; } } if(!empty($psum)) $psum='¥'.$psum.''; else $psum='-'; $receiptL['报销金额调整']=$psum.$html; }else{ $receiptL['日常相关费用']='------- ------'; $receiptL['差旅相关费用']='-- ----'; $receiptL['培训班费用']='----- ----'; $receiptL['其他']='-----'; $receiptL['报销金额调整']='-'; } $monthStaffPrice=$receiptDetail->find(array('select'=>'staff,item,sum(price) as price,itemCategory,Month(date) as month', 'where'=>'cid='.$value['cid']." and status=1 and Year(date)=".$year.' and Month(date)='.$month,'asArray'=>true)); if(!empty($monthStaffPrice[0]['price'])) $receiptL['monthStaffPrice']='¥'.$monthStaffPrice[0]['price'].''; else $receiptL['monthStaffPrice']='-'; $list[$value['title']]=$receiptL; } $data['list']=$list; $receiptCollectList=$receiptDetail->find(array('select'=>'staff,item,sum(price) as price,itemCategory,Month(date) as month', 'where'=>" status=1 and Year(date)=".$year.' and Month(date)='.$month,'groupby'=>'item,Month(date),itemCategory','asArray'=>true)); $data['monthPriceHtml']=$this->_getMonthCollectDetail($receiptCollectList); //statistics html $stList=$statistics->getOne(array('select'=>'sum(rePrice) as rePrice,sum(agPrice) as agPrice', 'where'=>'Month(date)='.$month." and Year(date)=".$year,'groupby'=>'Month(date)','asArray'=>true)); if(empty($stList)) $stList=array('rePrice'=>0,'agPrice'=>0); $data['stList']=array('rePrice'=>$stList['rePrice'],'agPrice'=>$stList['agPrice'],'skPrice'=>($stList['rePrice']-$stList['agPrice'])); $monthHtml=""; for ($i=1;$i<=12;$i++){ if ($i==$month) $monthHtml.=''; else $monthHtml.=''; } $data['monthHtml']=$monthHtml; $data['year']=$year; $data['month']=$month; $data['memu']="receipt"; $data['staff']=$this->staff; $data['receiptMemu']='companyCategoryCollect'; $data['verifyId']=$this->verifyId; $this->render ( "/admin/companyMonthCollectDetail", $data ); } function staffCollectDetail(){ $year=$this->get_args('year')?$this->get_args('year'):date("Y"); $staffname=$this->get_args('username')?$this->get_args('username'):""; $pcid=$this->get_args('category')?$this->get_args('category'):""; if(!$staffname){ $staffname=isset($this->params['staffname'])?$this->params['staffname']:""; $staffname= urldecode($staffname); } Doo::loadModel('staff'); $staff=new staff(); Doo::loadModel("receiptDetail"); $receiptDetail=new receiptDetail(); Doo::loadModel('accountItem'); $accountItem=new accountItem(); Doo::loadModel('statistics'); $statistics=new statistics(); Doo::loadModel('L_category'); $lCategory=new L_category(); $staffList=$staff->find(array('asArray'=>true)); $stHtml='';$stTitle="";$staffId=0;$cid=0;$ocid=0; foreach ($staffList as $value){ if ($value['username']==$staffname&&$value['username']!='admin'){ $stTitle=$value['category'].'-'.$value['username']; $staffId=$value['sid']; $cid=$value['cid']; $ocid=$value['cid']; if (!empty($value['othercid'])) $cid=$value['cid'].','.$value['othercid']; $stHtml.=''; }elseif ($value['username']!='admin') $stHtml.=''; } $data['lCategoryHtml']=$lCategory->find(array('where'=>'cid in('.$cid.')','asArray'=>true)); if(empty($pcid)) $pcid=$ocid; $data['ocid']=$pcid; $path=SITE_PATH.$this->STAFFCOLLECTPATH."staffCollectDetail_".$year."_".$staffId.".htmls"; $this->showCache($path); // $receiptCollectList=$receiptDetail->find(array('select'=>'staff,item,sum(price) as price,itemCategory,Month(date) as month', 'where'=>'staff='.$staffId." and cid=".$pcid." and status=1 and Year(date)=".$year,'groupby'=>'item,Month(date),itemCategory','asArray'=>true)); $accountList=$accountItem->find(array('asArray'=>true)); //create CollectDetail HTML $collectHtml=array(); foreach ($accountList as $key=>$value){ $html="";$asum=0; for ($i=1;$i<=12;$i++){ $falg=true; foreach ($receiptCollectList as $v) { if($value['category']==$v['itemCategory']&&$v['item']==$value['name']&&$i==$v['month']){ $asum+=$v['price']; $html.='¥'.$v['price'].'';$falg=false;break; } } if($falg) $html.='-'; } $html.='¥'.$asum.''; $collectHtml[$value['category']][$value['name']]=$html; } $data['collectHtml']=$collectHtml; //create Adjustment price html $receiptCollectList=$receiptDetail->find(array('select'=>'staff,sum(price) as price,itemCategory,Month(date) as month', 'where'=>'staff='.$staffId." and cid=".$pcid." and status=1 and Year(date)=".$year,'groupby'=>'itemCategory,Month(date)','asArray'=>true)); $adjustment=array();$collectArray=array('日常相关费用'=>array(),'差旅相关费用'=>array(),'培训班费用'=>array(),'其他'=>array()); $collectHtml=$this->collectHtml($receiptCollectList,'日常相关费用','b'); array_push($collectArray['日常相关费用'], $collectHtml); $collectHtml=$this->collectHtml($receiptCollectList,'差旅相关费用','b'); array_push($collectArray['差旅相关费用'], $collectHtml); $collectHtml=$this->collectHtml($receiptCollectList,'培训班费用','b'); array_push($collectArray['培训班费用'], $collectHtml); $collectHtml=$this->collectHtml($receiptCollectList,'其他','b'); array_push($collectArray['其他'], $collectHtml); $data['collectArray']=$collectArray; $collectHtml=$this->collectHtml($receiptCollectList,'报销金额调整'); array_push($adjustment, $collectHtml); $data['adjustment']=$adjustment; //total price html $collectHtml="";$total=0; for ($i=1;$i<=12;$i++){ $sumPrice=0; foreach ($receiptCollectList as $key=>$value){ if($value['month']==$i){ $sumPrice+=$value['price']; } } if ($sumPrice==0) $collectHtml.='-'; else $collectHtml.='¥'.$sumPrice.''; $total+=$sumPrice; } $collectHtml.='¥'.$total.''; //statistics html $stList=$statistics->statisticsByYear($year,$staffId); if(empty($stList)) $stList=array('rePrice'=>0,'agPrice'=>0); $data['stList']=array('rePrice'=>$stList['rePrice'],'agPrice'=>$stList['agPrice'],'skPrice'=>($stList['rePrice']-$stList['agPrice'])); $data['totalPrice']=$collectHtml; $data['totalYear']=$total; $data['stHtml']=$stHtml; $data['year']=$year; $data['stTitle']=$stTitle; $data['memu']="receipt"; $data['staff']=$this->staff; $data['receiptMemu']='companyCategoryCollect'; $data['verifyId']=$this->verifyId; if ($yearfind(array('where'=>'staff='.$staffId.' and (status=2 or status=4) and Year(date) ='.$year,'asArray'=>true)); if(empty($receiptList)){ //generated files ob_start(); $this->render ( "/admin/saeaStaffCollectDetail", $data ); $this->cacheFile($path);die; } } $this->render ( "/admin/saeaStaffCollectDetail", $data ); } function _getMonthCollectDetail($receiptCollectList){ if(!empty($receiptCollectList)){ $receiptL=array('日常相关费用'=>array(),'差旅相关费用'=>array(),'培训班费用'=>array(),'其他'=>array()); $html=""; $psum=0; $item=array('市内交通费','市内出租费','办事处房租','电话费','水费','电费','办公费用','邮寄费','其他费用','车辆费用','广告费','团队建设费'); foreach ($item as $value){ $falg=true; foreach ($receiptCollectList as $v){ if($v['itemCategory']=='日常相关费用'){ if($v['item']==$value){ $psum+=$v['price']; $html.=''.$v['price'].'';$falg=false;break; } } } if($falg) $html.='-'; } if(!empty($psum)) $psum='¥'.$psum.''; else $psum='-'; $receiptL['日常相关费用']=$psum.$html; /*-----------------------------------*/ $html=""; $psum=0; $item=array('往来交通费','市内交通费','出差住宿费','出差补助','其他费用'); foreach ($item as $value){ $falg=true; foreach ($receiptCollectList as $v){ if($v['itemCategory']=='差旅相关费用'){ if($v['item']==$value){ $psum+=$v['price']; $html.=''.$v['price'].'';$falg=false;break; } } } if($falg) $html.='-'; } if(!empty($psum)) $psum='¥'.$psum.''; else $psum='-'; $receiptL['差旅相关费用']=$psum.$html; /*-------------------------------------*/ $html=""; $psum=0; $item=array('场租费','薪酬','住宿费','交通费','餐饮费','办公费','公关费','其他'); foreach ($item as $value){ $falg=true; foreach ($receiptCollectList as $v){ if($v['itemCategory']=='培训班费用'){ if($v['item']==$value){ $psum+=$v['price']; $html.=''.$v['price'].'';$falg=false;break; } } } if($falg) $html.='-'; } if(!empty($psum)) $psum='¥'.$psum.''; else $psum='-'; $receiptL['培训班费用']=$psum.$html; /*-------------------------------------*/ $html=""; $psum=0; $item=array('公关费','广告费','借款','可自加费用'); foreach ($item as $value){ $falg=true; foreach ($receiptCollectList as $v){ if($v['itemCategory']=='其他'){ if($v['item']==$value){ $psum+=$v['price']; $html.=''.$v['price'].'';$falg=false;break; } } } if($falg) $html.='-'; } if(!empty($psum)) $psum='¥'.$psum.''; else $psum='-'; $receiptL['其他']=$psum.$html; /*-------------------------------------*/ $html=""; $psum=0; foreach ($receiptCollectList as $v){ if($v['itemCategory']=='报销金额调整'){ if (!empty($v['price'])) $psum+=$v['price']; } } if(!empty($psum)) $psum='¥'.$psum.''; else $psum='-'; $receiptL['报销金额调整']=$psum.$html; }else{ $receiptL['日常相关费用']='------- ------'; $receiptL['差旅相关费用']='-- ----'; $receiptL['培训班费用']='----- ----'; $receiptL['其他']='-----'; $receiptL['报销金额调整']='-'; } return $receiptL; } function eMail(){ Doo::loadModel('staff'); $staff=new staff(); Doo::loadModel('receipt'); $receipt=new receipt(); Doo::loadModel('L_category'); $Lcategory=new L_category(); Doo::loadModel("verify"); $verify=new verify(); $staffList=$staff->find(array('asArray'=>true)); foreach ($staffList as $key=>$value){ if($value['username']!='admin'){ //提交人 $receiptList=$receipt->find(array('where'=>'staff='.$value['sid'].' and status=1 and notice=0','asArray'=>true)); if(!empty($receiptList)){ $html='
CLD 邮件提醒

Hi,'.$value['username'].'

美好的一天从今天开始,您需要关注以下事项:

以下报销单完成了审批,等着收款吧:

'; foreach ($receiptList as $k=>$v){ $category=$Lcategory->getOne(array('where'=>'cid='.$v['cid'],'asArray'=>true)); $html.=' '; } $html.='

'.$v['receiptOrder'].'

'.$category['title'].'

¥'.$v['sum'].'元

'.$v['date'].'
立即登录

'; if(filter_var($value['email'], FILTER_VALIDATE_EMAIL)){ $this->SMail($value['email'], "CLD提醒您,您的报销单已同意支付", $html); $this->SMail('1971614655@qq.com', "CLD提醒您,您的报销单已同意支付", $html); $this->SMail('cpthought@vip.qq.com', "CLD提醒您,您的报销单已同意支付", $html); $receipt=new receipt(); $receipt->notice=1; $receipt->update(array('where'=>'staff='.$value['sid'].' and status=1 and notice=0')); } } //审批人 $verifyList=$verify->find(array('where'=>" staff like '%[\"".$value['sid']."\",%'",'asArray'=>true)); $html='
CLD 邮件提醒

Hi,'.$value['username'].'

美好的一天从今天开始,您需要关注以下事项:

以下报销单需要您的审批:

'; foreach ($verifyList as $k=>$v){ $receiptList=$receipt->find(array('where'=>"verify=".$v['vid']." and status=2 and verifyStaff not like '%{\"".$value['sid']."\":%'",'asArray'=>true)); foreach ($receiptList as $r=>$l){ $category=$Lcategory->getOne(array('where'=>'cid='.$l['cid'],'asArray'=>true)); $staffDetile=$staff->getOne(array('where'=>'sid='.$l['staff'],'asArray'=>true)); $html.=' '; } } $html.='

'.$l['receiptOrder'].'

'.$category['title'].'-'.$staffDetile['username'].'

¥'.$l['sum'].'元

'.$l['date'].'
立即登录

'; if((filter_var($value['email'], FILTER_VALIDATE_EMAIL))&&(!empty($verifyList))&&(!empty($receiptList))){ $this->SMail($value['email'], "CLD提醒您,有需要你审批的报销单", $html); // $receipt=new receipt(); // $receipt->notice=1; // $receipt->update(array('where'=>'staff='.$value['sid'].' and status=1 and notice=0')); } } } } // Email发送函数 function SMail($toemail, $subject, $contents) { Doo::loadClass('class.phpmailer'); $mail = new PHPMailer(); $mail->From = "postmaster@support.zhzdwk.com"; //发送邮箱全名 $mail->FromName = "=?UTF-8?B?" . base64_encode("CLD") . "?="; //发送人昵称 $mail->Username = "postmaster@websupport.sendcloud.org"; //用户名 $mail->Password = "cDO1GjtY1seH"; //密码 $mail->CharSet = "UTF8"; $mail->SMTPAuth = true; $mail->Host = "smtpcloud.sohu.com"; //邮件主机的smtp地址 $mail->Mailer = "smtp"; $mail->Port = 25; $mail->Subject = "=?UTF-8?B?" . base64_encode($subject) . "?="; $mail->MsgHTML($contents); $mail->AddAddress($toemail); $mail->CharSet = "UTF-8"; return $mail->Send(); } /** * 获取get或者POST值 * @param string $name 属性名称 * @return fixed 值 */ function get_args($name) { if (isset ( $_GET [$name] )) { if (is_array ( $_GET [$name] )) return $_GET [$name]; else return addslashes ( $_GET [$name] ); } elseif (isset ( $_POST [$name] )) { if (is_array ( $_POST [$name] )) return $_POST [$name]; else return addslashes ( $_POST [$name] ); } else return false; } } ?>