Exemplo n.º 1
0
 public function actionScheduleRegenerateReport()
 {
     // All reports are generated basing on data in UTC time.
     TimezoneWork::set('UTC');
     $return = array('ok' => 0);
     $schedule_processed_id = isset($_REQUEST['schedule_processed_id']) ? intval($_REQUEST['schedule_processed_id']) : null;
     if ($schedule_processed_id) {
         $data = ScheduleReportProcessed::getInfoForRegenerate($schedule_processed_id);
         if (!is_null($data)) {
             $reportType = null;
             switch ($data->ScheduleReportToStation->schedule_report->report_type) {
                 case 'bufr':
                     $reportType = 'Bufr';
                     break;
                 case 'synop':
                     $reportType = 'Synop';
                     break;
                 case 'metar':
                     $reportType = 'Metar';
                     break;
                 case 'speci':
                     $reportType = 'Speci';
                     break;
                 default:
                     $reportType = 'Export';
                     break;
             }
             $weather_report = WeatherReport::create($reportType);
             $weather_report->load($schedule_processed_id);
             if (!$weather_report->errors) {
                 $weather_report->generate();
                 $weather_report->prepareReportComplete();
                 $weather_report->saveProcess();
                 $return['ok'] = 1;
                 $return['report_string_initial'] = $weather_report->getReportComplete();
             } else {
                 $return['errors'] = $weather_report->errors;
             }
         }
     }
     print json_encode($return);
     CApplication::end();
 }