From dad530edb4862d2ed7edbdda3dd09d57355d72ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mu=C3=B1oz=20Garcia?= <73303506+danimu03@users.noreply.github.com> Date: Fri, 4 Jun 2021 09:13:27 +0200 Subject: [PATCH] updates --- panel_admin/includes/formAddPromotion.php | 21 +++++++++++++++------ panel_admin/includes/formEditPromotion.php | 16 ++++++++++++---- panel_admin/panelAdmin.php | 9 +++++++-- 3 files changed, 34 insertions(+), 12 deletions(-) diff --git a/panel_admin/includes/formAddPromotion.php b/panel_admin/includes/formAddPromotion.php index 4bcdad4..f1374c7 100644 --- a/panel_admin/includes/formAddPromotion.php +++ b/panel_admin/includes/formAddPromotion.php @@ -32,7 +32,7 @@ class formAddPromotion extends Form{
'.$errorTittle.'
'.$errorDescription.'
'.$errorCode.'
-
'.$errorActive.'
+
'.$errorActive.'
Imagen promocional:
@@ -67,11 +67,19 @@ class formAddPromotion extends Form{ $result['code'] = "El idioma no es válido"; } - $active = $this->test_input($datos['active']) ?? null; + $active = strtolower($this->test_input($datos['active'])) ?? null; //|| !mb_ereg_match(self::HTML5_EMAIL_REGEXP, $description) - if ( $active>1 ||$active<0 ) { - $result['active'] = "La descripcion no es válida"; + if ( strcmp($active,"si") == 0 || strcmp($active,"no") == 0) { + if ( strcmp($active,"si") == 0 ) { + $boolean = 0; + } + else { + $boolean = 1; + } } + else { + $result['active'] = "El valor activo debe ser si/no"; + } if (count($result) === 0) { $bd = new Promotion_DAO("complucine"); @@ -113,7 +121,7 @@ class formAddPromotion extends Form{ // $result['img'] = 'Error al mover el archivo'; //} //$nombreBd = str_replace("_", " ", $nombre); - $bd->createPromotion(null, $tittle,$description,$code,$active, $nombreBd); + $bd->createPromotion(null, $tittle,$description,$code,$boolean, $nombreBd); $_SESSION['message'] = "
@@ -131,7 +139,8 @@ class formAddPromotion extends Form{ }else { $result['img'] = 'El archivo tiene un nombre o tipo no soportado'; } - } else { + } + else { $result['img'] = 'Error al subir el archivo.'; } diff --git a/panel_admin/includes/formEditPromotion.php b/panel_admin/includes/formEditPromotion.php index cf95db2..62867f5 100644 --- a/panel_admin/includes/formEditPromotion.php +++ b/panel_admin/includes/formEditPromotion.php @@ -74,11 +74,19 @@ class formEditPromotion extends Form{ $result['code'] = "El idioma no es válido"; } - $active = $this->test_input($datos['active']) ?? null; + $active = strtolower($this->test_input($datos['active'])) ?? null; //|| !mb_ereg_match(self::HTML5_EMAIL_REGEXP, $description) - if ( $active>1 ||$active<0 ) { - $result['active'] = "La descripcion no es válida"; + if ( strcmp($active,"si") == 0 || strcmp($active,"no") == 0) { + if ( strcmp($active,"si") == 0 ) { + $boolean = 0; + } + else { + $boolean = 1; + } } + else { + $result['active'] = "El valor activo debe ser si/no"; + } if (count($result) === 0) { $bd = new Promotion_DAO("complucine"); @@ -118,7 +126,7 @@ class formEditPromotion extends Form{ // $result['img'] = 'Error al mover el archivo'; //} //$nombreBd = str_replace("_", " ", $nombre); - $bd->editPromotion($id, $tittle,$description,$code,$active, $nombreBd); + $bd->editPromotion($id, $tittle,$description,$code,$boolean, $nombreBd); $_SESSION['message'] = "
diff --git a/panel_admin/panelAdmin.php b/panel_admin/panelAdmin.php index 3c46d8b..f98e7aa 100644 --- a/panel_admin/panelAdmin.php +++ b/panel_admin/panelAdmin.php @@ -382,7 +382,12 @@ $tittles[$key] = $value->getTittle(); $descriptions[$key] = $value->getDescription(); $codes[$key] = $value->getCode(); - $actives[$key] = $value->getActive(); + if ($value->getActive() == 0) { + $actives[$key] = "si"; + } + else{ + $actives[$key] = "no"; + } } $reply= "
@@ -395,7 +400,7 @@
  • Editar
  • Eliminar
  • "; - + for($i = 0; $i < count($promos); $i++){ $reply.= '
  • '. $ids[$i] .'