';
$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.='
';
$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.='
';$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='
';
}
$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']='
';
$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='
';
}
$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=$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='
';
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.='