diff --git a/vendor/model/FinancialMovements.class.php b/vendor/model/FinancialMovements.class.php index b154070..9352956 100644 --- a/vendor/model/FinancialMovements.class.php +++ b/vendor/model/FinancialMovements.class.php @@ -968,26 +968,21 @@ class FinancialMovements } /** Conta a quantidades de registros não pagos */ - public function CountNotPaid(int $companyId) + public function CountNotPaid() { - - /** Parametros de entrada */ - $this->companyId = $companyId; /** Consulta SQL */ - $this->sql = 'SELECT count(fm.financial_movements_id) as qtde + $this->sql = 'SELECT COUNT(fm.financial_movements_id) AS qtde FROM financial_movements fm - WHERE fm.company_id = :company_id - and fm.sicoob_response is not null - and fm.movement_date_paid is null - and fm.status = 1'; + WHERE fm.financial_entries_id > 0 + AND fm.sicoob_response IS NOT NULL + AND fm.movement_date_paid IS NULL + AND fm.status = 1 + AND fm.movement_date_scheduled <= CURRENT_DATE'; /** 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', $this->companyId);/** Informa a qual empresa pertence o cliente */ - + /** Executo o SQL */ $this->stmt->execute(); @@ -996,6 +991,49 @@ class FinancialMovements } + /** Lista todos os registros do banco com ou sem paginação*/ + public function AllNotPaid() + { + /** Consulta SQL */ + $this->sql = 'SELECT fm.financial_movements_id, + fm.financial_accounts_id, + fm.financial_entries_id, + fm.financial_outputs_id, + fm.user_id, + fm.company_id, + fm.description, + fm.movement_value, + fm.movement_value_paid, + fm.movement_value_fees, + fm.movement_date, + fm.movement_date_scheduled, + fm.movement_date_paid, + fm.reference as movement_reference, + fm.status, + fm.sicoob_response, + c.reference, + c.name_fantasy, + c.contract_type + FROM financial_movements fm + LEFT JOIN companies c ON fm.company_id = c.company_id + WHERE fm.financial_entries_id > 0 + AND fm.sicoob_response IS NOT NULL + AND fm.movement_date_paid IS NULL + AND fm.status = 1 + AND fm.movement_date_scheduled <= CURRENT_DATE + ORDER BY fm.movement_date_scheduled ASC'; + + /** 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 não pagos */ public function CountNotify(int $companyId, string $financialMovementsId) { @@ -1074,56 +1112,7 @@ class FinancialMovements return $this->stmt->fetchAll(\PDO::FETCH_OBJ); } - - /** Lista todos os registros do banco com ou sem paginação*/ - public function AllNotPaid(int $companyId) - { - /** Parametros de entrada */ - $this->companyId = $companyId; - - /** Consulta SQL */ - $this->sql = 'select fm.financial_movements_id, - fm.financial_accounts_id, - fm.financial_entries_id, - fm.financial_outputs_id, - fm.user_id, - fm.company_id, - fm.description, - fm.movement_value, - fm.movement_value_paid, - fm.movement_value_fees, - fm.movement_date, - fm.movement_date_scheduled, - fm.movement_date_paid, - fm.reference as movement_reference, - fm.status, - fm.sicoob_response, - c.reference, - c.name_fantasy, - c.contract_type - from financial_movements fm - 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 - and fm.status = 1 - and month(fm.movement_date_scheduled) < '.(date('m')+1).' - and year(fm.movement_date_scheduled) < '.(date('Y')+1).' - order by fm.movement_date_scheduled asc'; - - /** 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', $this->companyId);/** Informa a qual empresa pertence o cliente */ - /** Executo o SQL */ - $this->stmt->execute(); - - /** Retorno o resultado */ - return $this->stmt->fetchAll(\PDO::FETCH_OBJ); - - } /** Insere um novo registro no banco */ public function InsertMovements(int $financialAccountsId, diff --git a/vendor/view/financial_movements/financial_movements_notpaid_datagrid.php b/vendor/view/financial_movements/financial_movements_notpaid_datagrid.php index 1fdf2c8..6b804e7 100644 --- a/vendor/view/financial_movements/financial_movements_notpaid_datagrid.php +++ b/vendor/view/financial_movements/financial_movements_notpaid_datagrid.php @@ -11,14 +11,8 @@ try{ /** Instânciamento de classes */ $FinancialMovements = new FinancialMovements(); - /** Carrega as configurações de paginação */ - $config = $Main->LoadConfigPublic(); - - /** Parametros de filtro por company */ - $companyId = isset($_SESSION['USERSCOMPANYID']) ? $_SESSION['USERSCOMPANYID'] : 0; - /** Consulta a quantidade de registros */ - $NumberRecords = $FinancialMovements->CountNotPaid($companyId)->qtde; + $NumberRecords = $FinancialMovements->CountNotPaid()->qtde; /** Controles */ $total = null;