Substituindo a classe ClientsProducts para ProductsCompanies
This commit is contained in:
parent
f4704c0924
commit
10b16327a8
2 changed files with 32 additions and 32 deletions
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* Classe ClientProducts.class.php
|
||||
* Classe ProductsCompanies.class.php
|
||||
* @filesource
|
||||
* @autor Kenio de Souza
|
||||
* @copyright Copyright 2023 - Souza Consultoria Tecnológica
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
/** Defino o local onde esta a classe */
|
||||
namespace vendor\model;
|
||||
|
||||
class ClientProducts
|
||||
class ProductsCompanies
|
||||
{
|
||||
/** Declaro as vaiavéis da classe */
|
||||
private $connection = null;
|
||||
|
|
@ -55,7 +55,7 @@ class ClientProducts
|
|||
{
|
||||
|
||||
/** Consulta SQL */
|
||||
$this->sql = "describe client_products";
|
||||
$this->sql = "describe products_companies";
|
||||
|
||||
/** Preparo o SQL para execução */
|
||||
$this->stmt = $this->connection->connect()->prepare($this->sql);
|
||||
|
|
@ -94,7 +94,7 @@ class ClientProducts
|
|||
$this->clientProductId = $clientProductId;
|
||||
|
||||
/** Consulta SQL */
|
||||
$this->sql = 'select * from client_products
|
||||
$this->sql = 'select * from products_companies
|
||||
where client_product_id = :client_product_id';
|
||||
|
||||
/** Preparo o SQL para execução */
|
||||
|
|
@ -120,23 +120,23 @@ class ClientProducts
|
|||
/** Consulta SQL */
|
||||
$this->sql = 'select cp.client_product_id,
|
||||
cp.products_id,
|
||||
cp.clients_id,
|
||||
cp.company_id,
|
||||
cp.description,
|
||||
p.description as product,
|
||||
p.reference,
|
||||
cp.readjustment,
|
||||
cp.product_value,
|
||||
cp.maturity
|
||||
from client_products cp
|
||||
from products_companies cp
|
||||
left join products p on cp.products_id = p.products_id
|
||||
where cp.clients_id = :clients_id
|
||||
where cp.company_id = :company_id
|
||||
and cp.status = \'A\'';
|
||||
|
||||
/** Preparo o SQL para execução */
|
||||
$this->stmt = $this->connection->connect()->prepare($this->sql);
|
||||
|
||||
/** Preencho os parâmetros do SQL */
|
||||
$this->stmt->bindParam(':clients_id', $this->clientsId);
|
||||
$this->stmt->bindParam(':company_id', $this->clientsId);
|
||||
|
||||
/** Executo o SQL */
|
||||
$this->stmt->execute();
|
||||
|
|
@ -172,8 +172,8 @@ class ClientProducts
|
|||
$this->dateEnd = (date('Y')+1).'-'.$this->month[$this->readjustment].'-01';
|
||||
|
||||
/** Consulta SQL */
|
||||
$this->sql = 'select distinct(c.clients_id),
|
||||
c.users_id,
|
||||
$this->sql = 'select distinct(c.company_id),
|
||||
c.user_id,
|
||||
c.company_id,
|
||||
c.reference,
|
||||
c.client_name,
|
||||
|
|
@ -197,14 +197,14 @@ class ClientProducts
|
|||
c.contract_type,
|
||||
c.contract_date,
|
||||
cp.maturity,
|
||||
(select cp.maturity from client_products cp where cp.clients_id = c.clients_id limit 0, 1) as due_date
|
||||
from clients c
|
||||
left join client_products cp on c.clients_id = cp.clients_id
|
||||
(select cp.maturity from client_products cp where cp.company_id = c.company_id limit 0, 1) as due_date
|
||||
from companies c
|
||||
left join products_companies pc on c.company_id = pc.company_id
|
||||
where cp.readjustment = :readjustment
|
||||
and (select count(fm.financial_movements_id)
|
||||
from financial_movements fm
|
||||
where fm.movement_date_scheduled between \''.$this->dateStart.'\' and \''.$this->dateEnd.'\'
|
||||
and fm.clients_id = c.clients_id) = 0
|
||||
and fm.company_id = c.company_id) = 0
|
||||
order by cp.maturity asc';
|
||||
|
||||
/** Preparo o SQL para execução */
|
||||
|
|
@ -230,13 +230,13 @@ class ClientProducts
|
|||
|
||||
/** Consulta SQL */
|
||||
$this->sql = 'select count(client_product_id) as qtde
|
||||
from client_products where clients_id = :clients_id ';
|
||||
from client_products 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(':clients_id', $this->clientsId);
|
||||
$this->stmt->bindParam(':company_id', $this->clientsId);
|
||||
|
||||
/** Executo o SQL */
|
||||
$this->stmt->execute();
|
||||
|
|
@ -271,7 +271,7 @@ class ClientProducts
|
|||
$this->sql = 'update client_products set products_id = :products_id,
|
||||
date_contract = :date_contract,
|
||||
date_update = CURRENT_TIMESTAMP,
|
||||
users_id_update = :users_id_update,
|
||||
user_id_update = :user_id_update,
|
||||
description = :description,
|
||||
readjustment = :readjustment,
|
||||
product_value = :product_value,
|
||||
|
|
@ -282,18 +282,18 @@ class ClientProducts
|
|||
|
||||
/** Consulta SQL */
|
||||
$this->sql = 'insert into client_products(client_product_id,
|
||||
clients_id,
|
||||
company_id,
|
||||
products_id,
|
||||
users_id_create,
|
||||
user_id_create,
|
||||
date_contract,
|
||||
description,
|
||||
readjustment,
|
||||
product_value,
|
||||
maturity
|
||||
) values (:client_product_id,
|
||||
:clients_id,
|
||||
:company_id,
|
||||
:products_id,
|
||||
:users_id_create,
|
||||
:user_id_create,
|
||||
:date_contract,
|
||||
:description,
|
||||
:readjustment,
|
||||
|
|
@ -316,12 +316,12 @@ class ClientProducts
|
|||
|
||||
if($this->clientProductId > 0){
|
||||
|
||||
$this->stmt->bindParam('users_id_update', $this->usersIdUpdate);
|
||||
$this->stmt->bindParam('user_id_update', $this->usersIdUpdate);
|
||||
|
||||
}else{
|
||||
|
||||
$this->stmt->bindParam('users_id_create', $this->usersIdCreate);
|
||||
$this->stmt->bindParam('clients_id', $this->clientsId);
|
||||
$this->stmt->bindParam('user_id_create', $this->usersIdCreate);
|
||||
$this->stmt->bindParam('company_id', $this->clientsId);
|
||||
}
|
||||
|
||||
/** Executo o SQL */
|
||||
|
|
@ -339,7 +339,7 @@ class ClientProducts
|
|||
/** Consulta SQL */
|
||||
$this->sql = 'update client_products set status = \'E\',
|
||||
date_delete = CURRENT_TIMESTAMP,
|
||||
users_id_delete = :users_id_delete
|
||||
user_id_delete = :user_id_delete
|
||||
where client_product_id = :client_product_id';
|
||||
|
||||
/** Preparo o sql para receber os valores */
|
||||
|
|
@ -347,7 +347,7 @@ class ClientProducts
|
|||
|
||||
/** Preencho os parâmetros do SQL */
|
||||
$this->stmt->bindParam('client_product_id', $this->clientProductId);
|
||||
$this->stmt->bindParam('users_id_delete', $this->usersIdDelete);
|
||||
$this->stmt->bindParam('user_id_delete', $this->usersIdDelete);
|
||||
|
||||
/** Executo o SQL */
|
||||
return $this->stmt->execute();
|
||||
|
|
@ -365,14 +365,14 @@ class ClientProducts
|
|||
|
||||
/** Consulta SQL */
|
||||
$this->sql = 'update client_products set product_value = :product_value
|
||||
where clients_id = :clients_id
|
||||
where company_id = :company_id
|
||||
and products_id = :products_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('clients_id', $this->clientsId);
|
||||
$this->stmt->bindParam('company_id', $this->clientsId);
|
||||
$this->stmt->bindParam('products_id', $this->productsId);
|
||||
$this->stmt->bindParam('product_value', $this->productValue);
|
||||
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
/** Importação de classes */
|
||||
use vendor\model\Schedules;
|
||||
use vendor\model\ClientProducts;
|
||||
use vendor\model\ProductsCompanies;
|
||||
use vendor\model\FinancialMovements;
|
||||
|
||||
try{
|
||||
|
|
@ -17,7 +17,7 @@ try{
|
|||
|
||||
/** Instânciamento de classes */
|
||||
$Schedules = new Schedules();
|
||||
$ClientProducts = new ClientProducts();
|
||||
$ProductsCompanies = new ProductsCompanies();
|
||||
$FinancialMovements = new FinancialMovements();
|
||||
|
||||
/** Consulta as saídas pendentes */
|
||||
|
|
@ -363,8 +363,8 @@ try{
|
|||
<?php
|
||||
|
||||
/** Consulta os clientes que estão no mês do reajuste */
|
||||
$ClientProductsResult = $ClientProducts->Readjustment($month[date('m')]);
|
||||
foreach($ClientProductsResult as $ClientsKey => $Result){
|
||||
$ProductsCompaniesResult = $ProductsCompanies->Readjustment($month[date('m')]);
|
||||
foreach($ProductsCompaniesResult as $ClientsKey => $Result){
|
||||
?>
|
||||
|
||||
<tr>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue