<?
header('Access-Control-Allow-Origin:*'); 
if (empty($dduser)){
    exit();	
}
dd_session_start();
 

$page = !($_POST['page'])?'1':intval($_POST['page']);
$pagesize=$_REQUEST['limit']?$_REQUEST['limit']:20;  
$frmnum=($page-1)*$pagesize;

$count=diffBetweenTwoDays($_POST['sdate'],$_POST['edate']);
$count=$count+1;
$list=[];
for ($x=$frmnum; $x<$frmnum+$pagesize; $x++) {
     $date=date("Y-m-d",strtotime("-".$x." day",strtotime($_POST['edate'])));
     $data=app("total")->order_total($date,$date);
     $data['date']=$date;

     $data['yicost']=app("income")->yiCost($date,$_POST['hhr'],$_POST['yg']);
     $data['salary']=app("monthsalary")->ymonthPrice($date,$_POST['hhr'],$_POST['yg']);
     $data['income_hhr']=round($data['profit_hhr']-$data['yicost']-$data['salary']-$data['profit_yg'],2);
     $list[]=$data;
     if ($x>=($count-1))
        break;
}
$other=app("total")->order_total($_POST['sdate'],$_POST['edate']);

$other['yicost']=app("income")->totalYiCost($_POST['sdate'],$_POST['edate'],$_POST['hhr'],$_POST['yg']);

$other['salary']=app("monthsalary")->totalYmonthPrice($_POST['sdate'],$_POST['edate'],$_POST['hhr'],$_POST['yg']);
$other['income_hhr']=round($other['profit_hhr']-$other['yicost']-$other['salary']-$other['profit_yg'],2);
// $list=$duoduo->select_all($table,'*','`'.$title.'` like "%'.$q.'%" '.$where.' order by '.$by.' limit '.$frmnum.','.$pagesize);


json(0,"",$list,$count,$other);

?>