/** * Loop through month by month, and pull any data for that month. * If there's nothing for that month, then blank it */ protected function getyearly($year) { $params = $this->formfilter(); $all_finances = array(); $months = StatsData::GetMonthsInRange('January ' . $year, 'December ' . $year); foreach ($months as $month) { $date_filter = array("DATE_FORMAT(p.submitdate, '%Y%m') = '" . date('Ym', $month) . "'"); $this_filter = array_merge($date_filter, $params); $data = PIREPData::getIntervalData($this_filter); if (!$data) { $data = new stdClass(); $data->ym = date('Y-m', $month); $data->timestamp = $month; $data->total = 0; $data->revenue = 0; $data->gross = 0; $data->fuelprice = 0; $data->price = 0; $data->expenses = 0; $data->pilotpay = 0; } else { $data = FinanceData::calculateFinances($data[0]); } $all_finances[] = $data; } return $all_finances; }
/** * Get internal data for the past $interval months, including the * total number of PIREPS and revenue * * @param array $where_params Any specific conditions to search on * @param int $interval The interval, in months * @return mixed This is the return value description * */ public static function getIntervalDataByMonth($where_params, $interval = '6') { $date_clause = "DATE_SUB(NOW(), INTERVAL {$interval} MONTH) <= p.submitdate"; /* See if this array already exists */ if (!is_array($where_params)) { $where_params = array($date_clause); } else { $where_params[] = $date_clause; } $data = self::getIntervalData($where_params); if (!$data) { return array(); } foreach ($data as $month) { $month = FinanceData::calculateFinances($month); } return $data; }