"./?state=mp");
        parent::__construct('formEditPromotion', $op);
    }
	protected function generaCamposFormulario($datos, $errores = array()){
       
        // Se generan los mensajes de error si existen.
        $htmlErroresGlobales = self::generaListaErroresGlobales($errores);
		$errorId = self::createMensajeError($errores, 'id', 'span', array('class' => 'error'));
        $errorTittle = self::createMensajeError($errores, 'tittle', 'span', array('class' => 'error'));
        $errorDescription = self::createMensajeError($errores, 'description', 'span', array('class' => 'error'));
        $errorCode = self::createMensajeError($errores, 'code', 'span', array('class' => 'error'));
		$errorActive = self::createMensajeError($errores, 'active', 'span', array('class' => 'error'));
		//$errorImage = self::createMensajeError($errores, 'image', 'span', array('class' => 'error'));
		$html = '
				';
        return $html;
    }
	protected function procesaFormulario($datos){
        $result = array();
        
        $id =  $this->test_input($_POST['id']) ?? null;
        if (is_null($id)) {
			$result['id'] = "La promoción seleccionada no existe.";
		}
        $tittle = $this->test_input($datos['tittle']) ?? null;
        if ( empty($tittle) ) {
            $result['tittle'] = "El título no es válido";
        }
        $description = $this->test_input($datos['description']) ?? null;
        if ( empty($description)) {
            $result['description'] = "La descripcion no es válida";
        }
        
        $code = $this->test_input($datos['code']) ?? null;
        if ( empty($code)  ) {
            $result['code'] = "El idioma no es válido";
        }
		$active = $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 (count($result) === 0) {
        	$bd = new Promotion_DAO("complucine");
			//FALTARIA SUBIR LA IMAGEN
			$exist = $bd-> promotionData($id);
			if(mysqli_num_rows($exist) == 1){
				$bd->editPromotion($id, $tittle,$description,$code,$active);
				$_SESSION['message'] = "
										
										
											
												 Operacion realizada con exito 
												 Se ha modificado la promocion correctamente en la base de datos.
												
											 
										 
										
									 
									";
				$result = './?state=mp';
			}
			else{
				
                $result[] =  "La promocion seleccionada no existe.";
			}
			$exist->free();
		}
		return $result;
	}
}
?>