diff --git a/application/controllers/Debug.php b/application/controllers/Debug.php index 585a1a556..dc652037b 100644 --- a/application/controllers/Debug.php +++ b/application/controllers/Debug.php @@ -111,6 +111,7 @@ class Debug extends CI_Controller $data['sota_update'] = $this->cron_model->cron('update_update_sota')->row(); $data['wwff_update'] = $this->cron_model->cron('update_update_wwff')->row(); $data['tle_update'] = $this->cron_model->cron('update_update_tle')->row(); + $data['hon_update'] = $this->cron_model->cron('update_update_hamsofnote')->row(); $data['page_title'] = __("Debug"); diff --git a/application/controllers/Update.php b/application/controllers/Update.php index 2ed5ce49e..27984437a 100644 --- a/application/controllers/Update.php +++ b/application/controllers/Update.php @@ -490,12 +490,18 @@ class Update extends CI_Controller { } public function update_hamsofnote() { - $this->load->model('Update_model'); - $bodyData['hamsofnote'] = $this->Update_model->update_hams_of_note(); - $data['page_title'] = __("Update of Hams of Note"); - $this->load->view('interface_assets/header', $data); - $this->load->view('update/hamsofnote', $bodyData); - $this->load->view('interface_assets/footer'); + $this->load->model('cron_model'); + $this->cron_model->set_last_run($this->router->class.'_'.$this->router->method); + $this->load->model('Update_model'); + $bodyData['hamsofnote'] = $this->Update_model->update_hams_of_note(); + if ($this->session->userdata('user_type') == '99') { + $data['page_title'] = __("Update of Hams of Note"); + $this->load->view('interface_assets/header', $data); + $this->load->view('update/hamsofnote', $bodyData); + $this->load->view('interface_assets/footer'); + } else { + echo $bodyData['hamsofnote']; + } } function version_check() { diff --git a/application/migrations/239_add_hams_of_note.php b/application/migrations/239_add_hams_of_note.php index 1eb092f00..7366ccd19 100644 --- a/application/migrations/239_add_hams_of_note.php +++ b/application/migrations/239_add_hams_of_note.php @@ -42,11 +42,35 @@ class Migration_add_hams_of_note extends CI_Migration $this->dbforge->create_table('hams_of_note'); $this->db->query("ALTER TABLE hams_of_note ADD INDEX `callsign` (`callsign`)"); } + + if ($this->chk4cron('update_update_hon') == 0) { + $data = array( + array( + 'id' => 'update_update_hamsofnote', + 'enabled' => '0', + 'status' => 'disabled', + 'description' => 'Update Hams Of Notes', + 'function' => 'index.php/update/update_hamsofnote', + 'expression' => '30 1 * * 1', + 'last_run' => null, + 'next_run' => null + )); + $this->db->insert_batch('cron', $data); + } } public function down() { + if ($this->chk4cron('update_update_hamsofnote') > 0) { + $this->db->query("delete from cron where id='update_update_hamsofnote'"); + } if ($this->db->table_exists('hams_of_note')) { $this->dbforge->drop_table('hams_of_note'); } } + + function chk4cron($cronkey) { + $query = $this->db->query("select count(id) as cid from cron where id=?",$cronkey); + $row = $query->row(); + return $row->cid ?? 0; + } } diff --git a/application/views/debug/index.php b/application/views/debug/index.php index f4c6232d5..f5afac2f1 100644 --- a/application/views/debug/index.php +++ b/application/views/debug/index.php @@ -554,11 +554,16 @@ last_run ?? __("never"); ?> - + last_run ?? __("never"); ?> + + + last_run ?? __("never"); ?> + +