getAll($baoyangsql); for ($x=0; $xgetRow($sqllei); if($reslei['leijicount']==null){ $leijicount=0; } else{ $leijicount=$reslei['leijicount']; } $baoresult[$x]['leijicount']=$leijicount; //当月台数 $date = date('Y-m-d'); //当前时间 $firstday = date('Y-m-01', strtotime($date)); $sqldang="select sum(tai_count) as dangyuecount from ranking where name='$name' and sign_date>'$firstday'"; $resdang=$conn->getRow($sqldang); if($resdang['dangyuecount']==null){ $dangyuecount=0; } else{ $dangyuecount=$resdang['dangyuecount']; } $baoresult[$x]['dangyuecount']=$dangyuecount; //查询目标台数 $sqltarget="select sum(tai) as mubiaocount from target where name='$name' and type = '保養'"; $restarget=$conn->getRow($sqltarget); if($restarget['mubiaocount']==null){ $mubiaocount=0; $baoresult[$x]['mubiaocount']= $mubiaocount; $baoresult[$x]['leijidachenglv']= 100; $baoresult[$x]['mubiaolv']= 3; if($leijicount==0){ $baoresult[$x]['leijilv']= 3; }else{ $baoresult[$x]['leijilv']= 100; } } else{ $mubiaocount=$restarget['mubiaocount']; $baoresult[$x]['mubiaocount']= $mubiaocount; $baoresult[$x]['leijidachenglv']= intval($leijicount/$mubiaocount*100); if($leijicount>$mubiaocount){ $leijilv=100; $mubiaolv=intval($mubiaocount/$leijicount*100); }else{ $mubiaolv=100; $leijilv=intval($leijicount/$mubiaocount*100); if($leijilv==0){ $leijilv=3; } } if ($mubiaolv == 0){ $mubiaolv = 3; } if ($leijilv == 0){ $leijilv = 3; } $baoresult[$x]['mubiaolv']= $mubiaolv; $baoresult[$x]['leijilv']= $leijilv; } // //查询员工入职是否三个月内 $sqljoindate="select joindate from target where name='$name'"; $resjoindate=$conn->getRow($sqljoindate); if($resjoindate){ $threemonth=strtotime("-0 year -3 month -0 day"); $joindate=strtotime($resjoindate['joindate']); if($threemonth-$joindate<0){ $baoresult[$x]['isnew']= 1; }else{ $baoresult[$x]['isnew']= 0; } } //查询详细数据 $sqldang="select * from ranking where name='$name' order by id desc "; $detail=$conn->getAll($sqldang); $baoresult[$x]['detail']= $detail; } //按照累计达成率排序 $sort=array_column($baoresult,'leijidachenglv'); array_multisort($sort,SORT_DESC,$baoresult); $page=$_REQUEST['page']; if(empty($page)){ $page=1; $offset=0; }else{ $offset=($page-1)*5; } $choosearray=array_slice($baoresult,$offset,5); $result['list']=$choosearray; //查询总数 $baoyangsqlcount="select DISTINCT(name) from target where type = '保養'"; $baoresultcount=$conn->getAll($baoyangsqlcount); $result['currenpage']=$page; $result['total']=sizeof($baoresultcount); $result['page']=ceil(sizeof($baoresultcount)/5); //} echo json_encode($result); } }catch (Exception $e) { die($e->getMessage()); } ?>