0 AND (`date` BETWEEN '$Previous' AND '$today') ORDER BY `date`, `report_for_invoice_daily`.`id` ASC"); if (mysqli_num_rows($get_report_for_invoice_daily_sql) > 0) { while ($row_report_for_invoice_daily = mysqli_fetch_assoc($get_report_for_invoice_daily_sql)) { if(!array_key_exists($row_report_for_invoice_daily['date'], $data)){ $data[$row_report_for_invoice_daily['date']] = array(); } $data[$row_report_for_invoice_daily['date']][$row_report_for_invoice_daily['id']] = $row_report_for_invoice_daily['total']; } } $all = array( 'last' => array(), 'now' => array() ); $exit_15 = array( 'last' => array(), 'now' => array() ); $exit_7 = array( 'last' => array(), 'now' => array() ); $exit_29 = array( 'last' => array(), 'now' => array() ); $exit_6 = array( 'last' => array(), 'now' => array() ); $count = 1; foreach ($data as $key => $value) { if($count <= 7) { array_push($all['last'], round($data[$key]['2']+$data[$key]['3']+$data[$key]['4']+$data[$key]['5'],2)); array_push($exit_15['last'], round($data[$key]['2'],2)); array_push($exit_7['last'], round($data[$key]['3'],2)); array_push($exit_29['last'], round($data[$key]['4'],2)); array_push($exit_6['last'], round($data[$key]['5'],2)); } else { array_push($all['now'], round($data[$key]['2']+$data[$key]['3']+$data[$key]['4']+$data[$key]['5'],2)); array_push($exit_15['now'], round($data[$key]['2'],2)); array_push($exit_7['now'], round($data[$key]['3'],2)); array_push($exit_29['now'], round($data[$key]['4'],2)); array_push($exit_6['now'], round($data[$key]['5'],2)); } $count++; } function get_deg(int $old, int $new) { global $get_old_new; if ($old > $new) { return round((($old - $new)/$old)*100,2); } elseif ($old < $new) { return round((($new - $old)/$old)*100,2); } else { return 0; } } function get_deg_arrow(int $old, int $new) { global $get_old_new; if ($old > $new) { return 'down'; } elseif ($old < $new) { return 'up'; } else { return ''; } } ?>