Atualizando companies_budgets_finanacial_entries.php
This commit is contained in:
parent
26727c0e61
commit
34d3c4f806
1 changed files with 47 additions and 53 deletions
100
vendor/model/FinancialEntries.class.php
vendored
100
vendor/model/FinancialEntries.class.php
vendored
|
|
@ -25,10 +25,9 @@ class FinancialEntries
|
|||
private $limit = null;
|
||||
private $financialEntriesId = null;
|
||||
private $companyId = null;
|
||||
private $clientsId = null;
|
||||
private $companyId = null;
|
||||
private $usersId = null;
|
||||
private $description = null;
|
||||
private $fixed = null;
|
||||
private $description = null; private $fixed = null;
|
||||
private $duration = null;
|
||||
private $startDate = null;
|
||||
private $entrieValue = null;
|
||||
|
|
@ -40,7 +39,7 @@ class FinancialEntries
|
|||
private $financialCategoriesId = null;
|
||||
private $field = null;
|
||||
private $next = null;
|
||||
private $clientBudgetsId = null;
|
||||
private $companiesBudgetsId = null;
|
||||
private $reference = null;
|
||||
private $clientBudgetsResult = null;
|
||||
private $lastEntriesId = null;
|
||||
|
|
@ -128,8 +127,8 @@ class FinancialEntries
|
|||
/** Consulta SQL */
|
||||
$this->sql = 'select financial_entries_id,
|
||||
company_id,
|
||||
clients_id,
|
||||
users_id,
|
||||
company_id,
|
||||
user_id,
|
||||
financial_accounts_id,
|
||||
description,
|
||||
fixed,
|
||||
|
|
@ -152,19 +151,19 @@ class FinancialEntries
|
|||
}
|
||||
|
||||
/** Localiza a entrada de um respectivo 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,
|
||||
fm.financial_accounts_id,
|
||||
fm.financial_entries_id,
|
||||
fm.financial_outputs_id,
|
||||
fm.users_id,
|
||||
fm.user_id,
|
||||
fm.company_id,
|
||||
fm.company_id,
|
||||
fm.clients_id,
|
||||
fm.description,
|
||||
fm.movement_value,
|
||||
fm.movement_value_paid,
|
||||
|
|
@ -178,16 +177,16 @@ class FinancialEntries
|
|||
c.reference as reference_client,
|
||||
fc.reference
|
||||
from financial_movements fm
|
||||
left join clients c on fm.clients_id = c.clients_id
|
||||
left join client_budgets cb on fm.client_budgets_id = cb.client_budgets_id
|
||||
left join clients c on fm.company_id = c.company_id
|
||||
left join client_budgets cb on fm.companies_budgets_id = cb.companies_budgets_id
|
||||
left join financial_categories fc on cb.financial_categories_id = fc.financial_categories_id
|
||||
where fm.client_budgets_id = :client_budgets_id';
|
||||
where fm.companies_budgets_id = :companies_budgets_id';
|
||||
|
||||
/** Preparo o SQL para execução */
|
||||
$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(':companies_budgets_id', $this->companiesBudgetsId);
|
||||
|
||||
/** Executo o SQL */
|
||||
$this->stmt->execute();
|
||||
|
|
@ -220,13 +219,13 @@ class FinancialEntries
|
|||
}
|
||||
|
||||
/** Insere um novo registro no banco */
|
||||
public function Create(int $financialEntriesId, int $clientsId, int $clientBudgetsId, string $description, int $fixed, int $duration, string $startDate, float $entrieValue, string $endDate, int $financialAccountsId, string $active, int $financialCategoriesId)
|
||||
public function Create(int $financialEntriesId, int $companyId, int $companiesBudgetsId, string $description, int $fixed, int $duration, string $startDate, float $entrieValue, string $endDate, int $financialAccountsId, string $active, int $financialCategoriesId)
|
||||
{
|
||||
|
||||
/** Parametros */
|
||||
$this->financialEntriesId = $financialEntriesId;
|
||||
$this->clientsId = $clientsId > 0 ? $clientsId : null;
|
||||
$this->clientBudgetsId = $clientBudgetsId;
|
||||
$this->companyId = $companyId > 0 ? $companyId : null;
|
||||
$this->companiesBudgetsId = $companiesBudgetsId;
|
||||
$this->description = $description;
|
||||
$this->fixed = $fixed;
|
||||
$this->duration = $duration;
|
||||
|
|
@ -239,9 +238,8 @@ class FinancialEntries
|
|||
|
||||
/** Consulta SQL */
|
||||
$this->sql = 'insert into financial_entries(company_id,
|
||||
clients_id,
|
||||
client_budgets_id,
|
||||
users_id,
|
||||
companies_budgets_id,
|
||||
user_id,
|
||||
description,
|
||||
fixed,
|
||||
duration,
|
||||
|
|
@ -251,10 +249,9 @@ class FinancialEntries
|
|||
financial_accounts_id,
|
||||
financial_categories_id,
|
||||
active
|
||||
) values (:company_id,
|
||||
:clients_id,
|
||||
:client_budgets_id,
|
||||
:users_id,
|
||||
) values (:company_id,
|
||||
:companies_budgets_id,
|
||||
:user_id,
|
||||
:description,
|
||||
:fixed,
|
||||
:duration,
|
||||
|
|
@ -269,10 +266,9 @@ class FinancialEntries
|
|||
$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('user_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('client_budgets_id', $this->clientBudgetsId);
|
||||
$this->stmt->bindParam('companies_budgets_id', $this->companiesBudgetsId);
|
||||
$this->stmt->bindParam('financial_accounts_id', $this->financialAccountsId);
|
||||
$this->stmt->bindParam('financial_categories_id', $this->financialCategoriesId);
|
||||
$this->stmt->bindParam('description', $this->description);
|
||||
|
|
@ -297,13 +293,13 @@ class FinancialEntries
|
|||
}
|
||||
|
||||
/** Insere um novo registro no banco */
|
||||
public function Save(int $financialEntriesId, int $clientsId, int $clientBudgetsId, string $description, int $fixed, int $duration, string $startDate, float $entrieValue, string $endDate, int $financialAccountsId, string $active, int $financialCategoriesId, ? string $reference)
|
||||
public function Save(int $financialEntriesId, int $companyId, int $companiesBudgetsId, string $description, int $fixed, int $duration, string $startDate, float $entrieValue, string $endDate, int $financialAccountsId, string $active, int $financialCategoriesId, ? string $reference)
|
||||
{
|
||||
|
||||
/** Parametros */
|
||||
$this->financialEntriesId = $financialEntriesId;
|
||||
$this->clientsId = $clientsId > 0 ? $clientsId : null;
|
||||
$this->clientBudgetsId = $clientBudgetsId;
|
||||
$this->companyId = $companyId > 0 ? $companyId : null;
|
||||
$this->companiesBudgetsId = $companiesBudgetsId;
|
||||
$this->description = $description;
|
||||
$this->fixed = $fixed;
|
||||
$this->duration = $duration;
|
||||
|
|
@ -320,7 +316,7 @@ class FinancialEntries
|
|||
if($this->financialEntriesId > 0){
|
||||
|
||||
/** Consulta SQL */
|
||||
$this->sql = 'update financial_entries set clients_id = :clients_id,
|
||||
$this->sql = 'update financial_entries set company_id = :company_id,
|
||||
description = :description,
|
||||
fixed = :fixed,
|
||||
duration = :duration,
|
||||
|
|
@ -340,7 +336,7 @@ class FinancialEntries
|
|||
|
||||
/** Preencho os parâmetros do SQL */
|
||||
$this->stmt->bindParam('financial_entries_id', $this->financialEntriesId);
|
||||
$this->stmt->bindParam('clients_id', $this->clientsId);
|
||||
$this->stmt->bindParam('company_id', $this->companyId);
|
||||
$this->stmt->bindParam('financial_accounts_id', $this->financialAccountsId);
|
||||
$this->stmt->bindParam('financial_categories_id', $this->financialCategoriesId);
|
||||
$this->stmt->bindParam('description', $this->description);
|
||||
|
|
@ -361,9 +357,8 @@ class FinancialEntries
|
|||
|
||||
/** Consulta SQL */
|
||||
$this->sql = 'insert into financial_entries(company_id,
|
||||
clients_id,
|
||||
client_budgets_id,
|
||||
users_id,
|
||||
companies_budgets_id,
|
||||
user_id,
|
||||
description,
|
||||
fixed,
|
||||
duration,
|
||||
|
|
@ -375,9 +370,9 @@ class FinancialEntries
|
|||
active,
|
||||
reference
|
||||
) values (:company_id,
|
||||
:clients_id,
|
||||
:client_budgets_id,
|
||||
:users_id,
|
||||
:company_id,
|
||||
:companies_budgets_id,
|
||||
:user_id,
|
||||
:description,
|
||||
:fixed,
|
||||
:duration,
|
||||
|
|
@ -393,10 +388,9 @@ class FinancialEntries
|
|||
$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('client_budgets_id', $this->clientBudgetsId);
|
||||
$this->stmt->bindParam('user_id', $_SESSION['USERSID']);/** Informa o usuário responsável pelo novo cliente cadastrado */
|
||||
$this->stmt->bindParam('company_id', $this->companyId);
|
||||
$this->stmt->bindParam('companies_budgets_id', $this->companiesBudgetsId);
|
||||
$this->stmt->bindParam('financial_accounts_id', $this->financialAccountsId);
|
||||
$this->stmt->bindParam('financial_categories_id', $this->financialCategoriesId);
|
||||
$this->stmt->bindParam('description', $this->description);
|
||||
|
|
@ -432,20 +426,20 @@ class FinancialEntries
|
|||
/** Consulta SQL */
|
||||
$this->sql = 'insert into financial_movements(financial_accounts_id,
|
||||
financial_entries_id,
|
||||
users_id,
|
||||
user_id,
|
||||
company_id,
|
||||
clients_id,
|
||||
client_budgets_id,
|
||||
company_id,
|
||||
companies_budgets_id,
|
||||
description,
|
||||
movement_value,
|
||||
movement_date_scheduled,
|
||||
reference
|
||||
) values (:financial_accounts_id,
|
||||
:financial_entries_id,
|
||||
:users_id,
|
||||
:user_id,
|
||||
:company_id,
|
||||
:clients_id,
|
||||
:client_budgets_id,
|
||||
:company_id,
|
||||
:companies_budgets_id,
|
||||
:description,
|
||||
:movement_value,
|
||||
:movement_date_scheduled,
|
||||
|
|
@ -456,12 +450,12 @@ class FinancialEntries
|
|||
$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_entries_id', $this->lastEntriesId);
|
||||
$this->stmt->bindParam('clients_id', $this->clientsId);
|
||||
$this->stmt->bindParam('client_budgets_id', $this->clientBudgetsId);
|
||||
$this->stmt->bindParam('company_id', $this->companyId);
|
||||
$this->stmt->bindParam('companies_budgets_id', $this->companiesBudgetsId);
|
||||
$this->stmt->bindParam('description', $this->next);
|
||||
$this->stmt->bindParam('movement_value', $this->entrieValue);
|
||||
$this->stmt->bindParam('movement_date_scheduled', $this->movementDateScheduled);
|
||||
|
|
@ -490,7 +484,7 @@ class FinancialEntries
|
|||
$this->lastid = $this->connection->connect()->lastInsertId();
|
||||
|
||||
/** carrega os dados do orçamento */
|
||||
$this->clientBudgetsResult = $this->GetBudgets($this->clientBudgetsId);
|
||||
$this->clientBudgetsResult = $this->GetBudgets($this->companiesBudgetsId);
|
||||
|
||||
/** Gera a referência da movimentação para gravar no boleto */
|
||||
$this->reference = $this->lastid.$this->clientBudgetsResult->reference.'/'.$this->clientBudgetsResult->reference_client.'-'.($i+1);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue