From 2b21266a389305b214eb89af827116dbe69c5e5d Mon Sep 17 00:00:00 2001 From: Jose Gonzalez Date: Thu, 26 Mar 2020 12:17:28 +0100 Subject: [PATCH] WIP: At this point, PEN form is operative and functional --- .../modules/private_enterprise_numbers.php | 52 +++++++++---------- .../include/ajax/wizardSetup.ajax.php | 40 +++++++++----- .../include/class/ConfigPEN.class.php | 12 +++-- 3 files changed, 59 insertions(+), 45 deletions(-) diff --git a/pandora_console/godmode/modules/private_enterprise_numbers.php b/pandora_console/godmode/modules/private_enterprise_numbers.php index 71cc7b1dc4..6c660fee4a 100644 --- a/pandora_console/godmode/modules/private_enterprise_numbers.php +++ b/pandora_console/godmode/modules/private_enterprise_numbers.php @@ -45,11 +45,6 @@ try { diff --git a/pandora_console/include/ajax/wizardSetup.ajax.php b/pandora_console/include/ajax/wizardSetup.ajax.php index c8c296d922..072da2b606 100644 --- a/pandora_console/include/ajax/wizardSetup.ajax.php +++ b/pandora_console/include/ajax/wizardSetup.ajax.php @@ -53,10 +53,10 @@ $pen_id_np = get_parameter('pen_id'); $pen_number = get_parameter('pen_number'); $pen_manufacturer = get_parameter('pen_manufacturer'); $pen_description = get_parameter('pen_description'); - // Set the variables needed here. -$configPEN = new ConfigPEN(); -$output = ''; +$configPEN = new ConfigPEN(); +$message = ''; +$output = ''; // Let's do something. // First, get the current data. $actual_pen = db_get_row('tpen', 'pen', $pen_number); @@ -74,12 +74,12 @@ switch ($action) { ] ); if ($work === false) { - $output = ui_print_error_message(__('Error inserting new PEN')); + $message = ui_print_error_message(__('Error inserting new PEN'), '', true); } else { - $output = $configPEN->createMainTable(); + $message = ui_print_success_message(__('PEN added in DB'), '', true); } } else { - $output = ui_print_error_message(sprintf(__('The PEN %s exists already'), $pen_number)); + $message = ui_print_error_message(sprintf(__('The PEN %s exists already'), $pen_number)); } break; @@ -100,12 +100,12 @@ switch ($action) { ); if ($work === false) { - $output = ui_print_error_message(__('Error updating data')); + $message = ui_print_error_message(__('Error updating data')); } else { - $output = ui_print_success_message(__('PEN updated in DB')); + $message = ui_print_success_message(__('PEN updated in DB')); } } else { - $output = ui_print_error_message(__('No changes applied')); + $message = ui_print_error_message(__('No changes applied')); } break; @@ -116,9 +116,10 @@ switch ($action) { 'tpen', ['pen' => $pen_number] ); - $output = $configPEN->createMainTable(); + + $message = ui_print_success_message(__('PEN deleted in DB'), '', true); } else { - $output = ui_print_error_message(__('Something goes wrong. Please, retry')); + $message = ui_print_error_message(__('Something goes wrong. Please, retry'), '', true); } break; @@ -127,5 +128,20 @@ switch ($action) { break; } +// Make the data for return +$output = html_print_div( + [ + 'id' => 'ajax_message_show', + 'content' => $message, + ] +); + +$output .= html_print_div( + [ + 'id' => 'ajax_main_table', + 'content' => $configPEN->createMainTable(), + ] +); // Return data. -return $output; +echo $output; +// return $output; diff --git a/pandora_console/include/class/ConfigPEN.class.php b/pandora_console/include/class/ConfigPEN.class.php index bf3c799e0f..6dc0853624 100644 --- a/pandora_console/include/class/ConfigPEN.class.php +++ b/pandora_console/include/class/ConfigPEN.class.php @@ -159,7 +159,7 @@ class ConfigPEN extends HTML ] ); - ui_pagination($countPENs, false, $this->offset); + $output = ui_pagination($countPENs, false, $this->offset, 0, true); // Create the table with Module Block list. $table = new StdClasS(); $table->class = 'databox data'; @@ -206,7 +206,7 @@ class ConfigPEN extends HTML true, [ 'title' => 'Edit', - 'onclick' => 'javascript:modifyPENLine(event)', + 'onclick' => 'modifyPENLine(event)', ] ); $data[4] .= html_print_input_image( @@ -217,7 +217,7 @@ class ConfigPEN extends HTML true, [ 'title' => 'Delete PEN', - 'onclick' => 'if (confirm(\''.__('Are you sure?').'\')) deletePEN(event);', + 'onclick' => 'if (confirm(\''.sprintf(__('Are you sure to remove the PEN: %s?'), $row['pen']).'\')) deletePEN(event);', ] ); @@ -239,14 +239,16 @@ class ConfigPEN extends HTML true, [ 'title' => 'Add new PEN', - 'onclick' => 'javascript:addNewPEN()', + 'onclick' => 'addNewPEN()', ] ); // Add last line. array_push($table->data, $data); // Return the entire table. - return html_print_table($table, true); + $output .= html_print_table($table, true); + // $output = 'mis huevos morenos'; + return $output; }