Merge branch 'ent-5575-wizard-de-modulos-y-recon-by-steps' of brutus.artica.es:artica/pandorafms into ent-5575-wizard-de-modulos-y-recon-by-steps

Merge to get the new code
This commit is contained in:
Jose Gonzalez 2020-03-27 12:18:17 +01:00
commit a150417ad3
1 changed files with 40 additions and 9 deletions

View File

@ -400,18 +400,24 @@ class ConfigPEN extends HTML
$inputs = []; $inputs = [];
$arguments = [
'name' => 'pen',
'type' => 'number',
'value' => $values['pen'],
'required' => true,
'return' => true,
'size' => 50,
];
if ((bool) $values['pen']) {
$arguments['disabled'] = true;
}
$inputs[] = [ $inputs[] = [
'label' => __('PEN'), 'label' => __('PEN'),
'class' => 'flex-row', 'class' => 'flex-row',
'id' => 'div-pen', 'id' => 'div-pen',
'arguments' => [ 'arguments' => $arguments,
'name' => 'pen',
'type' => 'number',
'value' => $values['pen'],
'required' => true,
'return' => true,
'size' => 50,
],
]; ];
$inputs[] = [ $inputs[] = [
@ -477,7 +483,7 @@ class ConfigPEN extends HTML
/** /**
* Add a manufacturer to private enterprise numbers. * Add or update a manufacturer to private enterprise numbers.
* *
* @return void * @return void
*/ */
@ -486,6 +492,7 @@ class ConfigPEN extends HTML
$pen = get_parameter('pen', 0); $pen = get_parameter('pen', 0);
$manufacturer = get_parameter('manufacturer', ''); $manufacturer = get_parameter('manufacturer', '');
$description = get_parameter('description', ''); $description = get_parameter('description', '');
$is_new = (bool) get_parameter('is_new', false);
if (empty($pen)) { if (empty($pen)) {
$error = __('PEN is required.'); $error = __('PEN is required.');
@ -506,6 +513,15 @@ class ConfigPEN extends HTML
if ($current === false) { if ($current === false) {
// New. // New.
if ($is_new === false) {
echo json_encode(
[
'error' => __('This PEN definition does not exist'),
]
);
exit;
}
$rs = db_process_sql_insert( $rs = db_process_sql_insert(
'tpen', 'tpen',
[ [
@ -517,6 +533,15 @@ class ConfigPEN extends HTML
$str = __('created'); $str = __('created');
} else { } else {
// Update. // Update.
if ($is_new === true) {
echo json_encode(
[
'error' => __('This PEN definition already exists'),
]
);
exit;
}
$rs = db_process_sql_update( $rs = db_process_sql_update(
'tpen', 'tpen',
[ [
@ -656,9 +681,11 @@ function showForm(id) {
var btn_ok_text = "<?php echo __('OK'); ?>"; var btn_ok_text = "<?php echo __('OK'); ?>";
var btn_cancel_text = "<?php echo __('Cancel'); ?>"; var btn_cancel_text = "<?php echo __('Cancel'); ?>";
var title = "<?php echo __('Register new manufacturer'); ?>"; var title = "<?php echo __('Register new manufacturer'); ?>";
var is_new = 1;
if (id) { if (id) {
btn_ok_text = "<?php echo __('Update'); ?>"; btn_ok_text = "<?php echo __('Update'); ?>";
title = "<?php echo __('Update'); ?> " + id; title = "<?php echo __('Update'); ?> " + id;
is_new = 0;
} }
load_modal({ load_modal({
target: $("#modal"), target: $("#modal"),
@ -675,6 +702,10 @@ function showForm(id) {
{ {
name: "pen", name: "pen",
value: id value: id
},
{
name: 'is_new',
value: is_new
} }
], ],
onshow: { onshow: {