From 4908e9064a2cde184cab99577f080426e11e954d Mon Sep 17 00:00:00 2001 From: Kenio de Souza Date: Sat, 9 Aug 2025 11:38:06 -0300 Subject: [PATCH] =?UTF-8?q?Atualizando=20sa=C3=ADdas?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../financial_outputs_save.php | 12 +- vendor/model/FinancialOutputs.class copy.php | 413 ------------------ vendor/model/FinancialOutputs.class.php | 58 +-- 3 files changed, 32 insertions(+), 451 deletions(-) delete mode 100644 vendor/model/FinancialOutputs.class copy.php diff --git a/vendor/action/financial_outputs/financial_outputs_save.php b/vendor/action/financial_outputs/financial_outputs_save.php index da89f36..994ad1a 100644 --- a/vendor/action/financial_outputs/financial_outputs_save.php +++ b/vendor/action/financial_outputs/financial_outputs_save.php @@ -47,7 +47,17 @@ try{ } else { /** Salva o registro junto ao banco de dados */ - if($FinancialOutputs->Save($FinancialOutputsValidate->getFinancialOutputsId(), $FinancialOutputsValidate->getClientsId(), $FinancialOutputsValidate->getDescription(), $FinancialOutputsValidate->getFixed(), $FinancialOutputsValidate->getDuration(), $FinancialOutputsValidate->getStartDate(), $FinancialOutputsValidate->getOutputValue(), $FinancialOutputsValidate->getEnddate(), $FinancialOutputsValidate->getFinancialAccountsId(), $FinancialOutputsValidate->getActive(), $FinancialOutputsValidate->getFinancialCategoriesId())){ + if($FinancialOutputs->Save($FinancialOutputsValidate->getFinancialOutputsId(), + $FinancialOutputsValidate->getClientsId(), + $FinancialOutputsValidate->getDescription(), + $FinancialOutputsValidate->getFixed(), + $FinancialOutputsValidate->getDuration(), + $FinancialOutputsValidate->getStartDate(), + $FinancialOutputsValidate->getOutputValue(), + $FinancialOutputsValidate->getEnddate(), + $FinancialOutputsValidate->getFinancialAccountsId(), + $FinancialOutputsValidate->getActive(), + $FinancialOutputsValidate->getFinancialCategoriesId())){ /** Informa o resultado positivo **/ $result = [ diff --git a/vendor/model/FinancialOutputs.class copy.php b/vendor/model/FinancialOutputs.class copy.php deleted file mode 100644 index 61b2222..0000000 --- a/vendor/model/FinancialOutputs.class copy.php +++ /dev/null @@ -1,413 +0,0 @@ -connection = new Mysql(); - } - - /** Carrega os campos de uma tabela */ - public function Describe() - { - - /** Consulta SQL */ - $this->sql = "describe financial_outputs"; - - /** Preparo o SQL para execução */ - $this->stmt = $this->connection->connect()->prepare($this->sql); - - /** Executo o SQL */ - $this->stmt->execute(); - - /** Retorno o resultado */ - $this->field = $this->stmt->fetchAll(\PDO::FETCH_OBJ); - - /** Declara o objeto */ - $resultDescribe = new \stdClass(); - $Field = ''; - - /** Lista os campos da tabela para objetos */ - foreach($this->field as $UsersKey => $Result){ - - /** Pega o nome do Field/Campo */ - $Field = $Result->Field; - - /** Carrega os objetos como null */ - $resultDescribe->$Field = null; - - } - - /** Retorna os campos declarados como vazios */ - return $resultDescribe; - - } - - /** Lista os registros do banco de dados com limitação */ - public function Get(int $financialOutputsId) - { - - /** Parametros de entrada */ - $this->financialOutputsId = $financialOutputsId; - - /** Consulta SQL */ - $this->sql = 'select financial_outputs_id, - company_id, - clients_id, - users_id, - financial_accounts_id, - financial_categories_id, - description, - fixed, - duration, - start_date, - end_date, - output_value, - active - from financial_outputs - where financial_outputs_id = '.$this->financialOutputsId; - - /** Preparo o SQL para execução */ - $this->stmt = $this->connection->connect()->prepare($this->sql); - - /** Preencho os parâmetros do SQL */ - //$this->stmt->bindParam(':financial_outputs_id', $this->financialoutputsId); - - /** Executo o SQL */ - $this->stmt->execute(); - - /** Retorno o resultado */ - return $this->stmt->fetchObject(); - - } - - - /** Lista todos os egistros do banco com ou sem paginação*/ - public function All(int $start, int $max) - { - /** Parametros de entrada */ - $this->start = $start; - $this->max = $max; - - /** Verifico se há paginação */ - if($this->max){ - $this->limit = "limit $this->start, $this->max"; - } - - /** Consulta SQL */ - $this->sql = 'select financial_outputs_id, - company_id, - clients_id, - users_id, - financial_accounts_id, - financial_categories_id, - description, - fixed, - duration, - start_date, - end_date, - output_value, - active - from financial_outputs '. $this->limit; - - /** Preparo o SQL para execução */ - $this->stmt = $this->connection->connect()->prepare($this->sql); - - /** Executo o SQL */ - $this->stmt->execute(); - - /** Retorno o resultado */ - return $this->stmt->fetchAll(\PDO::FETCH_OBJ); - - } - - /** Conta a quantidades de registros */ - public function Count() - { - /** Consulta SQL */ - $this->sql = 'select count(financial_outputs_id) as qtde - from financial_outputs - where company_id = :company_id'; - - /** Preparo o SQL para execução */ - $this->stmt = $this->connection->connect()->prepare($this->sql); - - /** Preencho os parâmetros do SQL */ - $this->stmt->bindParam(':company_id', $_SESSION['USERSCOMPANYID']); - - /** Executo o SQL */ - $this->stmt->execute(); - - /** Retorno o resultado */ - return $this->stmt->fetchObject(); - - } - - /** Insere um novo registro no banco */ - public function Save(int $financialOutputsId, int $clientsId, string $description, int $fixed, int $duration, string $startDate, float $outputValue, string $endDate, int $financialAccountsId, string $active, int $financialCategoriesId) - { - - - /** Parametros */ - $this->financialOutputsId = $financialOutputsId; - $this->clientsId = $clientsId > 0 ? $clientsId : null; - $this->description = $description; - $this->fixed = $fixed; - $this->duration = $duration; - $this->startDate = $startDate; - $this->outputValue = $outputValue; - $this->endDate = $endDate; - $this->financialAccountsId = $financialAccountsId; - $this->active = $active; - $this->financialCategoriesId = $financialCategoriesId; - - - /** Verifica se o ID do registro foi informado */ - if($this->financialOutputsId > 0){ - - /** Consulta SQL */ - $this->sql = 'update financial_outputs set clients_id = :clients_id, - description = :description, - fixed = :fixed, - duration = :duration, - start_date = :start_date, - output_value = :output_value, - end_date = :end_date, - financial_accounts_id = :financial_accounts_id, - financial_categories_id = :financial_categories_id, - active = :active - where financial_outputs_id = :financial_outputs_id'; - - }else{//Se o ID não foi informado, grava-se um novo registro - - /** Consulta SQL */ - $this->sql = 'insert into financial_outputs(company_id, - clients_id, - users_id, - description, - fixed, - duration, - start_date, - output_value, - end_date, - financial_accounts_id, - financial_categories_id, - active - ) values (:company_id, - :clients_id, - :users_id, - :description, - :fixed, - :duration, - :start_date, - :output_value, - :end_date, - :financial_accounts_id, - :financial_categories_id, - :active)'; - - } - - - - /** Preparo o sql para receber os valores */ - echo $this->stmt = $this->connection->connect()->prepare((string)$this->sql); - exit; - - /** Preencho os parâmetros do SQL */ - - /** Verifica se não é uma edição */ - if($this->financialOutputsId == 0){ - - $this->stmt->bindParam('users_id', $_SESSION['USERSID']);/** Informa o usuário responsável pelo novo cliente cadastrado */ - $this->stmt->bindParam('company_id', $_SESSION['USERSCOMPANYID']);/** Informa a qual empresa pertence o cliente */ - - }else{ - - $this->stmt->bindParam('financial_outputs_id', $this->financialOutputsId); - } - - $this->stmt->bindParam('clients_id', $this->clientsId); - $this->stmt->bindParam('financial_accounts_id', $this->financialAccountsId); - $this->stmt->bindParam('financial_categories_id', $this->financialCategoriesId); - $this->stmt->bindParam('description', $this->description); - $this->stmt->bindParam('fixed', $this->fixed); - $this->stmt->bindParam('duration', $this->duration); - $this->stmt->bindParam('start_date', $this->startDate); - $this->stmt->bindParam('output_value', $this->outputValue); - $this->stmt->bindParam('end_date', $this->endDate); - $this->stmt->bindParam('active', $this->active); - - /** Executo o SQL */ - - /** Caso a transação tenha sido bem sucedida, gravo a movimentação */ - if($this->stmt->execute()){ - - /** Recupera o ID da última transação */ - $this->lastid = $this->connection->connect()->lastInsertId(); - - /** Verifica se o último ID foi retornado */ - if($this->lastid > 0){ - - /** Trata a data do agendamento do movimento de entrada */ - $this->movementDateScheduled = strtotime($this->startDate); - - /** Inicio do loop para cadastro de movimentação */ - /** Efetuo o cadastro de movimentação de acordo com a entrada informada */ - for($i=0; $i<$this->duration; $i++){ - - $this->movementDateScheduled = ( $i == 0 ? $this->startDate : date("Y-m-d", mktime(0,0,0, (date('m', strtotime($this->startDate))+$i), date('d', strtotime($this->startDate)), date('Y', strtotime($this->startDate)))) ); - - - /** Consulta SQL */ - $this->sql = 'insert into financial_movements(financial_accounts_id, - financial_outputs_id, - users_id, - company_id, - clients_id, - description, - movement_value, - movement_date_scheduled - ) values (:financial_accounts_id, - :financial_outputs_id, - :users_id, - :company_id, - :clients_id, - :description, - :movement_value, - :movement_date_scheduled)'; - - - /** Preparo o sql para receber os valores */ - $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 cliente cadastrado */ - $this->stmt->bindParam('company_id', $_SESSION['USERSCOMPANYID']);/** Informa a qual empresa pertence o cliente */ - $this->stmt->bindParam('financial_accounts_id', $this->financialAccountsId); - $this->stmt->bindParam('financial_outputs_id', $this->lastid); - $this->stmt->bindParam('clients_id', $this->clientsId); - $this->stmt->bindParam('description', $this->description); - $this->stmt->bindParam('movement_value', $this->outputValue); - $this->stmt->bindParam('movement_date_scheduled', $this->movementDateScheduled); - - /** Executo o SQL */ - - /** Caso ocorra algum erro na transação,excluo a entrada e seus respectivos agendamentos */ - if(!$this->stmt->execute()){ - - - /** Exclui a entrada */ - $this->Delete($this->lastid); - - /** Exclui possiveis agendamentos efetuados */ - $this->DeleteMovements($this->lastid); - - return false; - break; - } - - }/** Fim do loop para cadastro de movimentação */ - - /** Caso não ocorra erros, informo como bem sucedido */ - return true; - - }else{/** Caso falhe o cadastro da transação, informo */ - - return false; - } - - }else{/** Caso falhe o cadastro da transação, informo */ - - return false; - } - - } - - /** Deleta um determinado registro no banco de dados */ - function Delete(int $financialOutputsId) - { - /** Parametros de entrada */ - $this->financialOutputsId = $financialOutputsId; - - /** Consulta SQL */ - $this->sql = 'delete from financial_outputs - where financial_outputs_id = :financial_outputs_id'; - - /** Preparo o sql para receber os valores */ - $this->stmt = $this->connection->connect()->prepare($this->sql); - - /** Preencho os parâmetros do SQL */ - $this->stmt->bindParam('financial_outputs_id', $this->financialOutputsId); - - /** Executo o SQL */ - return $this->stmt->execute(); - - } - - /** Deleta um determinado registro no banco de dados */ - function DeleteMovements(int $financialOutputsId) - { - /** Parametros de entrada */ - $this->financialOutputsId = $financialOutputsId; - - /** Consulta SQL */ - $this->sql = 'delete from financial_movements - where financial_outputs_id = :financial_outputs_id'; - - /** Preparo o sql para receber os valores */ - $this->stmt = $this->connection->connect()->prepare($this->sql); - - /** Preencho os parâmetros do SQL */ - $this->stmt->bindParam('financial_outputs_id', $this->financialOutputsId); - - /** Executo o SQL */ - return $this->stmt->execute(); - - } - - /** Fecha uma conexão aberta anteriormente com o banco de dados */ - function __destruct() - { - $this->connection = null; - } -} diff --git a/vendor/model/FinancialOutputs.class.php b/vendor/model/FinancialOutputs.class.php index 8428305..e10eea4 100644 --- a/vendor/model/FinancialOutputs.class.php +++ b/vendor/model/FinancialOutputs.class.php @@ -26,7 +26,6 @@ class FinancialOutputs private $financialOutputsId = null; private $financialCategoriesId = null; private $companyId = null; - private $clientsId = null; private $usersId = null; private $description = null; private $fixed = null; @@ -92,8 +91,7 @@ class FinancialOutputs /** Consulta SQL */ $this->sql = 'select financial_outputs_id, company_id, - clients_id, - users_id, + user_id, financial_accounts_id, financial_categories_id, description, @@ -136,8 +134,7 @@ class FinancialOutputs /** Consulta SQL */ $this->sql = 'select financial_outputs_id, company_id, - clients_id, - users_id, + user_id, financial_accounts_id, financial_categories_id, description, @@ -165,15 +162,11 @@ class FinancialOutputs { /** Consulta SQL */ $this->sql = 'select count(financial_outputs_id) as qtde - from financial_outputs - where company_id = :company_id'; + from financial_outputs'; /** Preparo o SQL para execução */ $this->stmt = $this->connection->connect()->prepare($this->sql); - /** Preencho os parâmetros do SQL */ - $this->stmt->bindParam(':company_id', $_SESSION['USERSCOMPANYID']); - /** Executo o SQL */ $this->stmt->execute(); @@ -205,7 +198,7 @@ class FinancialOutputs if($this->financialOutputsId > 0){ /** Consulta SQL */ - $this->sql = 'update financial_outputs set clients_id = :clients_id, + $this->sql = 'update financial_outputs set company_id = :company_id, description = :description, fixed = :fixed, duration = :duration, @@ -222,7 +215,7 @@ class FinancialOutputs /** Preencho os parâmetros do SQL */ $this->stmt->bindParam('financial_outputs_id', $this->financialOutputsId); - $this->stmt->bindParam('clients_id', $this->clientsId); + $this->stmt->bindParam('company_id', $this->clientsId); $this->stmt->bindParam('financial_accounts_id', $this->financialAccountsId); $this->stmt->bindParam('financial_categories_id', $this->financialCategoriesId); $this->stmt->bindParam('description', $this->description); @@ -251,17 +244,15 @@ class FinancialOutputs /** Consulta SQL */ $this->sql = 'insert into financial_movements(financial_accounts_id, financial_outputs_id, - users_id, + user_id, company_id, - clients_id, description, movement_value, movement_date_scheduled ) values (:financial_accounts_id, :financial_outputs_id, - :users_id, + :user_id, :company_id, - :clients_id, :description, :movement_value, :movement_date_scheduled)'; @@ -271,11 +262,10 @@ class FinancialOutputs $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 cliente cadastrado */ - $this->stmt->bindParam('company_id', $_SESSION['USERSCOMPANYID']);/** Informa a qual empresa pertence o cliente */ + $this->stmt->bindParam('user_id', $_SESSION['USERSID']);/** Informa o usuário responsável pelo novo cliente cadastrado */ + $this->stmt->bindParam('company_id', $this->companyId);/** Informa a qual empresa pertence o cliente */ $this->stmt->bindParam('financial_accounts_id', $this->financialAccountsId); $this->stmt->bindParam('financial_outputs_id', $this->financialOutputsId); - $this->stmt->bindParam('clients_id', $this->clientsId); $this->stmt->bindParam('description', $this->description); $this->stmt->bindParam('movement_value', $this->outputValue); $this->stmt->bindParam('movement_date_scheduled', $this->movementDateScheduled); @@ -311,9 +301,8 @@ class FinancialOutputs }else{//Se o ID não foi informado, grava-se um novo registro /** Consulta SQL */ - $this->sql = 'insert into financial_outputs(company_id, - clients_id, - users_id, + $this->sql = 'insert into financial_outputs(company_id, + user_id, description, fixed, duration, @@ -323,9 +312,8 @@ class FinancialOutputs financial_accounts_id, financial_categories_id, active - ) values (:company_id, - :clients_id, - :users_id, + ) values (:company_id, + :user_id, :description, :fixed, :duration, @@ -340,9 +328,8 @@ class FinancialOutputs $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 cliente cadastrado */ - $this->stmt->bindParam('company_id', $_SESSION['USERSCOMPANYID']);/** Informa a qual empresa pertence o cliente */ - $this->stmt->bindParam('clients_id', $this->clientsId); + $this->stmt->bindParam('user_id', $_SESSION['USERSID']);/** Informa o usuário responsável pelo novo cliente cadastrado */ + $this->stmt->bindParam('company_id', $this->companyId);/** Informa a qual empresa pertence o cliente */ $this->stmt->bindParam('financial_accounts_id', $this->financialAccountsId); $this->stmt->bindParam('financial_categories_id', $this->financialCategoriesId); $this->stmt->bindParam('description', $this->description); @@ -377,17 +364,15 @@ class FinancialOutputs /** Consulta SQL */ $this->sql = 'insert into financial_movements(financial_accounts_id, financial_outputs_id, - users_id, - company_id, - clients_id, + user_id, + company_id, description, movement_value, movement_date_scheduled ) values (:financial_accounts_id, :financial_outputs_id, - :users_id, - :company_id, - :clients_id, + :user_id, + :company_id, :description, :movement_value, :movement_date_scheduled)'; @@ -397,11 +382,10 @@ class FinancialOutputs $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 cliente cadastrado */ - $this->stmt->bindParam('company_id', $_SESSION['USERSCOMPANYID']);/** Informa a qual empresa pertence o cliente */ + $this->stmt->bindParam('user_id', $_SESSION['USERSID']);/** Informa o usuário responsável pelo novo cliente cadastrado */ + $this->stmt->bindParam('company_id', $this->companyId);/** Informa a qual empresa pertence o cliente */ $this->stmt->bindParam('financial_accounts_id', $this->financialAccountsId); $this->stmt->bindParam('financial_outputs_id', $this->lastid); - $this->stmt->bindParam('clients_id', $this->clientsId); $this->stmt->bindParam('description', $this->description); $this->stmt->bindParam('movement_value', $this->outputValue); $this->stmt->bindParam('movement_date_scheduled', $this->movementDateScheduled);