diff --git a/application/controllers/Cron.php b/application/controllers/Cron.php index 74b99f0e1..827bcdcd1 100644 --- a/application/controllers/Cron.php +++ b/application/controllers/Cron.php @@ -137,12 +137,12 @@ class cron extends CI_Controller { redirect('dashboard'); } - $id = xss_clean($this->input->post('id',true)); - $description = xss_clean($this->input->post('description',true)); - $expression = xss_clean($this->input->post('expression',true)); - $enabled = xss_clean($this->input->post('enabled',true)); + $id = xss_clean($this->input->post('cron_id',true)); + $description = xss_clean($this->input->post('cron_description',true)); + $expression = xss_clean($this->input->post('cron_expression',true)); + $enabled = xss_clean($this->input->post('cron_enabled',true)); - $this->cron_model->update_cron($id, $description, $expression, $enabled); + $this->cron_model->edit_cron($id, $description, $expression, $enabled); } diff --git a/application/models/Cron_model.php b/application/models/Cron_model.php index a367e4c86..2b55711f7 100644 --- a/application/models/Cron_model.php +++ b/application/models/Cron_model.php @@ -68,4 +68,18 @@ class Cron_model extends CI_Model $this->set_modified($cron); } + + function edit_cron($id, $description, $expression, $enabled) { + + $data = array ( + 'description' => $description, + 'expression' => $expression, + 'enabled' => ($enabled === 'true' ? 1 : 0) + ); + + $this->db->where('id', $id); + $this->db->update('cron', $data); + + $this->set_modified($id); + } } diff --git a/application/views/cron/edit.php b/application/views/cron/edit.php index 5f7c10f10..cc1ec5ca2 100644 --- a/application/views/cron/edit.php +++ b/application/views/cron/edit.php @@ -22,7 +22,7 @@ Enabled
- enabled ?? '0') { + enabled ?? '0') { echo 'checked'; } ?>>
@@ -31,7 +31,7 @@ Description - + @@ -72,7 +72,7 @@ diff --git a/assets/js/sections/cron.js b/assets/js/sections/cron.js index a48466634..709abc52e 100644 --- a/assets/js/sections/cron.js +++ b/assets/js/sections/cron.js @@ -58,12 +58,10 @@ function init_datatable() { function modalEventListener() { $('#edit_cron_expression_custom').on('input change',function(e){ - console.log('changed custom'); humanReadableInEditDialog() }); $('#edit_cron_expression_dropdown').change(function() { - console.log('changed dropdown'); humanReadableInEditDialog() }); } @@ -93,10 +91,11 @@ function editCronDialog(e) { } function editCron() { - var $cron_id = ''; - var $cron_description = ''; - var $cron_expression = ''; - var $cron_enabled = ''; + var $cron_id = $('#edit_cron_id').val(); + var $cron_description = $('#edit_cron_description').val(); + var $cron_expression = $('#edit_cron_expression_custom').val(); + var $cron_enabled = $('#edit_' + $cron_id).is(':checked') ? '1' : '0'; + $.ajax({ url: base_url + 'index.php/cron/edit', method: 'POST', @@ -105,7 +104,13 @@ function editCron() { cron_description: $cron_description, cron_expression: $cron_expression, cron_enabled: $cron_enabled - } + }, + success: function (data) { + reloadCrons(); + console.log('edit success'); + }, + error: function (data) { + }, }); }