public function get_wallboard_past_stats($center = "GAB") { $last_month = GAB\Debtsolv::get_referral_count($center, date("01-m-Y", strtotime("Last Month")), date("t-m-Y", strtotime("Last Month"))); $this_month = GAB\Debtsolv::get_referral_count($center, date("01-m-Y"), date("t-m-Y"), 3600); $this_week = GAB\Debtsolv::get_referral_count($center, date("d-m-Y", strtotime("monday this week")), date("d-m-Y"), 300); // Return the array $this->response(array('last_month' => array('referrals' => $last_month['referrals'], 'pack_out' => $last_month['pack_outs'], 'pack_out_percentage' => $last_month['referrals'] == 0 ? 0 : number_format($last_month['pack_outs'] / $last_month['referrals'] * 100, 2), 'pack_out_value' => number_format($last_month['pack_outs_value'], 2)), 'this_month' => array('referrals' => $this_month['referrals'], 'pack_out' => $this_month['pack_outs'], 'pack_out_percentage' => $this_month['referrals'] == 0 ? 0 : number_format($this_month['pack_outs'] / $this_month['referrals'] * 100, 2), 'pack_out_value' => number_format($this_month['pack_outs_value'], 2)), 'this_week' => array('referrals' => $this_week['referrals'], 'pack_out' => $this_week['pack_outs'], 'pack_out_percentage' => $this_week['referrals'] == 0 ? 0 : number_format($this_week['pack_outs'] / $this_week['referrals'] * 100, 2), 'pack_out_value' => number_format($this_week['pack_outs_value'], 2)))); }