This commit is contained in:
Kenio 2025-07-17 15:23:43 -03:00
parent 5f1c8e3b22
commit 01b700ecfb
2 changed files with 21 additions and 6 deletions

View file

@ -19,7 +19,8 @@ try{
$version = isset($_POST['version']) ? (int)filter_input(INPUT_POST,'version', FILTER_SANITIZE_SPECIAL_CHARS) : 0;
$versionRelease = isset($_POST['version_release']) ? (int)filter_input(INPUT_POST,'version_release', FILTER_SANITIZE_SPECIAL_CHARS) : 0;
$productsId = isset($_POST['product_id']) ? (int)filter_input(INPUT_POST,'product_id', FILTER_SANITIZE_SPECIAL_CHARS) : 0;
$productsTypeId = isset($_POST['product_type_id']) ? (int)filter_input(INPUT_POST,'product_type_id', FILTER_SANITIZE_SPECIAL_CHARS) : 0;
$productsTypeId = isset($_POST['product_type_id']) ? (int)filter_input(INPUT_POST,'product_type_id', FILTER_SANITIZE_SPECIAL_CHARS) : 0;
$userId = (int)$_SESSION['USERSID'];
/** Validando os campos de entrada */
@ -45,7 +46,13 @@ try{
} else {
/** Efetua um novo cadastro ou salva os novos dados */
if ($Products->Save($ProductsValidate->getProductsId(), $ProductsValidate->getProdutctsTypeId(), $ProductsValidate->getDescription(), $ProductsValidate->getReference(), $ProductsValidate->getVersion(), $ProductsValidate->getVersionRelease())){
if ($Products->Save($ProductsValidate->getProductsId(),
$ProductsValidate->getProdutctsTypeId(),
$ProductsValidate->getDescription(),
$ProductsValidate->getReference(),
$ProductsValidate->getVersion(),
$ProductsValidate->getVersionRelease(),
$userId)){
/** Prepara a mensagem de retorno - sucesso */
$message = '<div class="alert alert-success" role="alert">'.($ProductsValidate->getProductsId() > 0 ? 'Cadastro atualizado com sucesso' : 'Cadastro efetuado com sucesso').'</div>';

View file

@ -32,6 +32,7 @@ class Products
private $version = null;
private $version_release = null;
private $productsTypeId = null;
private $userId = null;
/** Construtor da classe */
function __construct()
@ -166,7 +167,13 @@ class Products
}
/** Insere um novo registro no banco */
public function Save(int $productId, int $productsTypeId, string $description, string $reference, int $version, int $versionRelease)
public function Save(int $productId,
int $productsTypeId,
string $description,
string $reference,
int $version,
int $versionRelease,
int $userId)
{
@ -177,6 +184,7 @@ class Products
$this->reference = $reference;
$this->version = $version;
$this->versionRelease = $versionRelease;
$this->userId = $userId;
/** Verifica se o ID do registro foi informado */
@ -206,13 +214,13 @@ class Products
/** Consulta SQL */
$this->sql = 'insert into products(product_type_id,
description,
users_id,
user_id,
reference,
version,
version_release
) values (:product_type_id,
:description,
:users_id,
:user_id,
:reference,
:version,
:version_release)';
@ -221,7 +229,7 @@ class Products
$this->stmt = $this->connection->connect()->prepare($this->sql);
/** Preencho os parâmetros do SQL */
$this->stmt->bindParam('users_id', $_SESSION['USERSID']);/** Informa o usuário responsável pelo novo produto cadastrado */
$this->stmt->bindParam('user_id', $this->userId);/** Informa o usuário responsável pelo novo produto cadastrado */
$this->stmt->bindParam('product_type_id', $this->productsTypeId);
$this->stmt->bindParam('description', $this->description);
$this->stmt->bindParam('reference', $this->reference);