diff --git a/vendor/model/FinancialMovements.class.php b/vendor/model/FinancialMovements.class.php index 8e47821..f097132 100644 --- a/vendor/model/FinancialMovements.class.php +++ b/vendor/model/FinancialMovements.class.php @@ -29,7 +29,7 @@ class FinancialMovements private $financialOutputsId = null; private $usersId = null; private $companyId = null; - private $clientsId = null; + private $companyId = null; private $movementValue = null; private $movementValuePaid = null; private $movementValueFees = null; @@ -45,7 +45,7 @@ class FinancialMovements private $and = null; private $movementDatePaid = null; private $field = null; - private $clientBudgetsId = null; + private $companiesBudgetsId = null; private $description = null; private $reference = null; private $financialConsolidationsId = null; @@ -209,7 +209,6 @@ class FinancialMovements fm.financial_outputs_id, fm.users_id, fm.company_id, - fm.clients_id, fm.description, fm.movement_value, fm.movement_value_paid, @@ -226,8 +225,8 @@ class FinancialMovements u.name_last, u.email from financial_movements fm - left join clients c on fm.clients_id = c.clients_id - left join users u on c.clients_id = u.clients_id + left join companies c on fm.company_id = c.company_id + left join users u on c.company_id = u.company_id where fm.company_id = :company_id and fm.movement_date_scheduled = date_format(current_date()+ '.$delay.', \'%Y-%m-%d\')'; @@ -283,11 +282,11 @@ class FinancialMovements } /** Localiza os registros de um determinado orçamento */ - public function GetBudgets(int $clientBudgetsId) + public function GetBudgets(int $companiesBudgetsId) { /** Parametros de entrada */ - $this->clientBudgetsId = $clientBudgetsId; + $this->companiesBudgetsId = $companiesBudgetsId; /** Consulta SQL */ $this->sql = 'select fm.financial_movements_id, @@ -296,7 +295,6 @@ class FinancialMovements fm.financial_outputs_id, fm.users_id, fm.company_id, - fm.clients_id, fm.description, fm.movement_value, fm.movement_value_paid, @@ -310,7 +308,7 @@ class FinancialMovements c.reference as reference_client, fc.reference from financial_movements fm - left join clients c on fm.clients_id = c.clients_id + left join companies c on fm.company_id = c.company_id left join client_budgets cb on fm.client_budgets_id = cb.client_budgets_id left join financial_categories fc on cb.financial_categories_id = fc.financial_categories_id where fm.client_budgets_id = :client_budgets_id @@ -320,7 +318,7 @@ class FinancialMovements $this->stmt = $this->connection->connect()->prepare($this->sql); /** Preencho os parâmetros do SQL */ - $this->stmt->bindParam(':client_budgets_id', $this->clientBudgetsId); + $this->stmt->bindParam(':client_budgets_id', $this->companiesBudgetsId); /** Executo o SQL */ $this->stmt->execute(); @@ -356,7 +354,6 @@ class FinancialMovements fm.financial_consolidations_id, fm.users_id, fm.company_id, - fm.clients_id, fm.description, fm.movement_value, fm.movement_value_paid, @@ -378,7 +375,7 @@ class FinancialMovements u.name_last, u.email from financial_movements fm - left join clients c on fm.clients_id = c.clients_id + left join companies c on fm.company_id = c.company_id left join financial_consolidations fc on fm.financial_consolidations_id = fc.financial_consolidations_id left join users u on fc.users_id = u.users_id where fm.reference = :reference'; @@ -424,7 +421,6 @@ class FinancialMovements fm.financial_outputs_id, fm.users_id, fm.company_id, - fm.clients_id, fm.description, fm.movement_value, fm.movement_value_paid, @@ -441,22 +437,20 @@ class FinancialMovements u.name_last, (select name_first from users where users_id = fm.movement_user_confirmed) as user_confirmed_name_first, (select name_last from users where users_id = fm.movement_user_confirmed) as user_confirmed_name_last, - c.company_name, - c.document, - cl.fantasy_name, - cl.document, - cl.zip_code, - cl.adress, - cl.number, - cl.complement, - cl.district, - cl.city, - cl.state_initials, - cl.email + c.name_business, + c.cnpj as document, + c.name_fantasy, + c.cep, + c.adress, + c.number, + c.complement, + c.district, + (select name from cities where city_id = c.city_id) as city, + (select name from states where city_id = c.city_id) as state, + c.email from financial_movements fm left join users u on fm.users_id = u.users_id left join company c on fm.company_id = c.company_id - left join clients cl on fm.clients_id = cl.clients_id where fm.financial_movements_id = :financial_movements_id'; /** Preparo o SQL para execução */ @@ -488,7 +482,6 @@ class FinancialMovements fm.financial_consolidations_id, fm.users_id, fm.company_id, - fm.clients_id, fm.client_budgets_id, fm.users_id_update, fm.description, @@ -508,9 +501,9 @@ class FinancialMovements fm.print, fm.movement_previous, fm.sicoob_response, - c.fantasy_name + c.name_fantasy from financial_movements fm - left join clients c on fm.clients_id = c.clients_id + left join company c on fm.company_id = c.company_id where fm.financial_consolidations_id = :financial_consolidations_id'; /** Preparo o SQL para execução */ @@ -542,7 +535,6 @@ class FinancialMovements fm.financial_outputs_id, fm.users_id, fm.company_id, - fm.clients_id, fm.description, fm.movement_value, fm.movement_value_paid, @@ -557,7 +549,7 @@ class FinancialMovements fm.sicoob_response, c.fantasy_name from financial_movements fm - left join clients c on fm.clients_id = c.clients_id + left join companies c on fm.company_id = c.company_id where fm.reference = :reference'; /** Preparo o SQL para execução */ @@ -636,7 +628,6 @@ class FinancialMovements fm.financial_outputs_id, fm.users_id, fm.company_id, - fm.clients_id, fm.description, fm.movement_value, fm.movement_value_paid, @@ -650,7 +641,7 @@ class FinancialMovements c.fantasy_name, c.contract_type from financial_movements fm - left join clients c on fm.clients_id = c.clients_id + left join companies c on fm.company_id = c.company_id where fm.company_id = :company_id and fm.description like concat(\'%\', :description, \'%\')'; @@ -689,7 +680,6 @@ class FinancialMovements fm.financial_outputs_id, fm.users_id, fm.company_id, - fm.clients_id, fm.description, fm.movement_value, fm.movement_value_paid, @@ -710,7 +700,7 @@ class FinancialMovements u.name_first, u.name_last from financial_movements fm - left join clients c on fm.clients_id = c.clients_id + left join companies c on fm.company_id = c.company_id left join client_budgets_commissions cbc on fm.financial_movements_id = cbc.financial_movements_id left join users u on cbc.users_id = u.users_id where fm.company_id = :company_id @@ -840,7 +830,7 @@ class FinancialMovements /** Consulta SQL */ $this->sql = 'select count(fm.financial_movements_id) as qtde from financial_movements fm - left join clients c on fm.clients_id = c.clients_id + left join companies c on fm.company_id = c.company_id where fm.company_id = :company_id and fm.movement_date_cancel is null'; @@ -1010,7 +1000,6 @@ class FinancialMovements fm.financial_outputs_id, fm.users_id, fm.company_id, - fm.clients_id, fm.description, fm.movement_value, fm.movement_value_paid, @@ -1025,7 +1014,7 @@ class FinancialMovements c.fantasy_name, c.contract_type from financial_movements fm - left join clients c on fm.clients_id = c.clients_id + left join companies c on fm.company_id = c.company_id WHERE fm.company_id = :company_id and fm.movement_date_paid is null and fm.status = 1 @@ -1059,7 +1048,6 @@ class FinancialMovements fm.financial_outputs_id, fm.users_id, fm.company_id, - fm.clients_id, fm.description, fm.movement_value, fm.movement_value_paid, @@ -1074,7 +1062,7 @@ class FinancialMovements c.fantasy_name, c.contract_type from financial_movements fm - left join clients c on fm.clients_id = c.clients_id + left join companies c on fm.company_id = c.company_id WHERE fm.company_id = :company_id and fm.sicoob_response is not null and fm.movement_date_paid is null @@ -1098,7 +1086,7 @@ class FinancialMovements } /** Insere um novo registro no banco */ - public function InsertMovements(int $financialAccountsId, int $financialEntriesId, int $financialOutputsId, int $clientsId, float $movementValue, string $movementDateScheduled, ? string $reference, ? string $description) + public function InsertMovements(int $financialAccountsId, int $financialEntriesId, int $financialOutputsId, int $companyId, float $movementValue, string $movementDateScheduled, ? string $reference, ? string $description) { @@ -1106,7 +1094,7 @@ class FinancialMovements $this->financialAccountsId = $financialAccountsId; $this->financialEntriesId = $financialEntriesId; $this->financialOutputsId = $financialOutputsId; - $this->clientsId = $clientsId; + $this->companyId = $companyId; $this->movementValue = $movementValue; $this->movementDateScheduled = $movementDateScheduled; $this->reference = $reference; @@ -1118,7 +1106,6 @@ class FinancialMovements financial_outputs_id, users_id, company_id, - clients_id, movement_value, movement_date_scheduled, reference, @@ -1128,7 +1115,6 @@ class FinancialMovements :financial_outputs_id, :users_id, :company_id, - :clients_id, :movement_value, :movement_date_scheduled, :reference, @@ -1144,7 +1130,6 @@ class FinancialMovements $this->stmt->bindParam('financial_accounts_id', $this->financialAccountsId); $this->stmt->bindParam('financial_entries_id', $this->financialEntriesId); $this->stmt->bindParam('financial_outputs_id', $this->financialOutputsId); - $this->stmt->bindParam('clients_id', $this->clientsId); $this->stmt->bindParam('movement_value', $this->movementValue); $this->stmt->bindParam('movement_date_scheduled', $this->movementDateScheduled); $this->stmt->bindParam('reference', $this->reference);