This commit is contained in:
Kenio 2025-07-16 16:50:17 -03:00
parent 2dd03d01f1
commit ee5d22cb74
2 changed files with 74 additions and 63 deletions

View file

@ -13,53 +13,49 @@ try{
$Companies = new Companies();
$CompaniesValidate = new CompaniesValidate();
/** Parametros de entrada */
$type = isset($_POST['type']) ? (string)filter_input(INPUT_POST, 'type', FILTER_SANITIZE_SPECIAL_CHARS) : '';
$student = isset($_POST['student']) ? (string)filter_input(INPUT_POST, 'student', FILTER_SANITIZE_SPECIAL_CHARS) : '';
$companyId = isset($_POST['company_id']) ? (int)filter_input(INPUT_POST, 'company_id', FILTER_SANITIZE_NUMBER_INT) : 0;
$cityId = isset($_POST['city_id']) ? (int)filter_input(INPUT_POST, 'city_id', FILTER_SANITIZE_NUMBER_INT) : 0;
$stateId = isset($_POST['state_id']) ? (int)filter_input(INPUT_POST, 'state_id', FILTER_SANITIZE_SPECIAL_CHARS) : 0;
$nameBusiness = isset($_POST['name_business']) ? (string)filter_input(INPUT_POST, 'name_business', FILTER_SANITIZE_SPECIAL_CHARS) : '';
$nameFantasy = isset($_POST['name_fantasy']) ? (string)filter_input(INPUT_POST, 'name_fantasy', FILTER_SANITIZE_SPECIAL_CHARS) : '';
$cnpj = isset($_POST['cnpj']) ? (string)filter_input(INPUT_POST, 'cnpj', FILTER_SANITIZE_SPECIAL_CHARS) : '';
$cep = isset($_POST['cep']) ? (string)filter_input(INPUT_POST, 'cep', FILTER_SANITIZE_SPECIAL_CHARS) : '';
$adress = isset($_POST['adress']) ? (string)filter_input(INPUT_POST, 'adress', FILTER_SANITIZE_SPECIAL_CHARS) : '';
$number = isset($_POST['number']) ? (string)filter_input(INPUT_POST, 'number', FILTER_SANITIZE_SPECIAL_CHARS) : '';
$complement = isset($_POST['complement']) ? (string)filter_input(INPUT_POST, 'complement', FILTER_SANITIZE_SPECIAL_CHARS) : '';
$district = isset($_POST['district']) ? (string)filter_input(INPUT_POST, 'district', FILTER_SANITIZE_SPECIAL_CHARS) : '';
$active = isset($_POST['active']) ? (string)filter_input(INPUT_POST, 'active', FILTER_SANITIZE_SPECIAL_CHARS) : '';
$reference = isset($_POST['reference']) ? (string)filter_input(INPUT_POST, 'reference', FILTER_SANITIZE_SPECIAL_CHARS) : '';
$responsible = isset($_POST['responsible']) ? (string)filter_input(INPUT_POST, 'responsible', FILTER_SANITIZE_SPECIAL_CHARS) : '';
$type = isset($_POST['type']) ? (string)filter_input(INPUT_POST, 'type', FILTER_SANITIZE_SPECIAL_CHARS) : '';
$nameBusiness = isset($_POST['name_business']) ? (string)filter_input(INPUT_POST, 'name_business', FILTER_SANITIZE_SPECIAL_CHARS) : '';
$nameFantasy = isset($_POST['name_fantasy']) ? (string)filter_input(INPUT_POST, 'name_fantasy', FILTER_SANITIZE_SPECIAL_CHARS) : '';
$reference = isset($_POST['reference']) ? (string)filter_input(INPUT_POST, 'reference', FILTER_SANITIZE_SPECIAL_CHARS) : '';
$cnpj = isset($_POST['cnpj']) ? (string)filter_input(INPUT_POST, 'cnpj', FILTER_SANITIZE_SPECIAL_CHARS) : '';
$cep = isset($_POST['cep']) ? (string)filter_input(INPUT_POST, 'cep', FILTER_SANITIZE_SPECIAL_CHARS) : '';
$adress = isset($_POST['adress']) ? (string)filter_input(INPUT_POST, 'adress', FILTER_SANITIZE_SPECIAL_CHARS) : '';
$number = isset($_POST['number']) ? (string)filter_input(INPUT_POST, 'number', FILTER_SANITIZE_SPECIAL_CHARS) : '';
$complement = isset($_POST['complement']) ? (string)filter_input(INPUT_POST, 'complement', FILTER_SANITIZE_SPECIAL_CHARS) : '';
$district = isset($_POST['district']) ? (string)filter_input(INPUT_POST, 'district', FILTER_SANITIZE_SPECIAL_CHARS) : '';
$cityId = isset($_POST['city_id']) ? (int)filter_input(INPUT_POST, 'city_id', FILTER_SANITIZE_NUMBER_INT) : 0;
$stateId = isset($_POST['state_id']) ? (int)filter_input(INPUT_POST, 'state_id', FILTER_SANITIZE_SPECIAL_CHARS) : 0;
$active = isset($_POST['active']) ? (string)filter_input(INPUT_POST, 'active', FILTER_SANITIZE_SPECIAL_CHARS) : '';
$responsible = isset($_POST['responsible']) ? (string)filter_input(INPUT_POST, 'responsible', FILTER_SANITIZE_SPECIAL_CHARS) : '';
$responsibleDocument = isset($_POST['responsible_document']) ? (string)filter_input(INPUT_POST, 'responsible_document', FILTER_SANITIZE_SPECIAL_CHARS) : '';
$email = isset($_POST['email']) ? (string)filter_input(INPUT_POST, 'email', FILTER_SANITIZE_SPECIAL_CHARS) : '';
$contractDate = isset($_POST['contract_date']) ? (string)filter_input(INPUT_POST, 'contract_date', FILTER_SANITIZE_SPECIAL_CHARS) : '';
$computers = isset($_POST['computers']) ? (int)filter_input(INPUT_POST, 'computers', FILTER_SANITIZE_NUMBER_INT) : '';
$servers = isset($_POST['servers']) ? (int)filter_input(INPUT_POST, 'servers', FILTER_SANITIZE_NUMBER_INT) : '';
$userId = $_SESSION['USERSID'];
$email = isset($_POST['email']) ? (string)filter_input(INPUT_POST, 'email', FILTER_SANITIZE_SPECIAL_CHARS) : '';
$contractDate = isset($_POST['contract_date']) ? (string)filter_input(INPUT_POST, 'contract_date', FILTER_SANITIZE_SPECIAL_CHARS) : 0;
$computers = isset($_POST['computers']) ? (int)filter_input(INPUT_POST, 'computers', FILTER_SANITIZE_NUMBER_INT) : 0;
$servers = isset($_POST['servers']) ? (int)filter_input(INPUT_POST, 'servers', FILTER_SANITIZE_NUMBER_INT) : 0;
$companyId = isset($_POST['company_id']) ? (int)filter_input(INPUT_POST, 'company_id', FILTER_SANITIZE_SPECIAL_CHARS) : 0;
$userId = $_SESSION['USERSID'];
/** Validando os campos de entrada */
$CompaniesValidate->setType($type);
$CompaniesValidate->setStudent($student);
$CompaniesValidate->setCompanyId($companyId);
$CompaniesValidate->setNameBusiness($nameBusiness);
$CompaniesValidate->setNameFantasy($nameFantasy);
$CompaniesValidate->setUserId($userId);
$CompaniesValidate->setCnpj($cnpj);
$CompaniesValidate->setCep($cep);
$CompaniesValidate->setAdress($adress);
$CompaniesValidate->setNumber($number);
$CompaniesValidate->setComplement($complement);
$CompaniesValidate->setDistrict($district);
$CompaniesValidate->setCityId($cityId);
$CompaniesValidate->setStateId($stateId);
$CompaniesValidate->setActive($active);
$CompaniesValidate->setReference($reference);
$CompaniesValidate->setResponsible($responsible);
$CompaniesValidate->setResponsibleDocument($responsibleDocument);
$CompaniesValidate->setEmail($email);
$CompaniesValidate->setContractDate($contractDate);
$CompaniesValidate->setComputers($computers);
$CompaniesValidate->setServers($servers);
$ClientBudgetsValidate->setType($type);
$ClientBudgetsValidate->setNameBusiness($nameBusiness);
$ClientBudgetsValidate->setNameFantasy($nameFantasy);
$ClientBudgetsValidate->setReference($reference);
$ClientBudgetsValidate->setCnpj($cnpj);
$ClientBudgetsValidate->setCep($cep);
$ClientBudgetsValidate->setAdress($adress);
$ClientBudgetsValidate->setNumber($number);
$ClientBudgetsValidate->setComplement($complement);
$ClientBudgetsValidate->setDistrict($district);
$ClientBudgetsValidate->setCityId($cityId);
$ClientBudgetsValidate->setStateId($stateId);
$ClientBudgetsValidate->setActive($active);
$ClientBudgetsValidate->setResponsible($responsible);
$ClientBudgetsValidate->setResponsibleDocument($responsibleDocument);
$ClientBudgetsValidate->setEmail($email);
$ClientBudgetsValidate->setContractDate($contractDate);
$ClientBudgetsValidate->setComputers($computers);
$ClientBudgetsValidate->setServers($servers);
$ClientBudgetsValidate->setcompanyId($companyId);
/** Verifica se não existem erros a serem informados,
* caso não haja erro(s) salvo os dados do cliente ou
@ -90,7 +86,6 @@ try{
$CompaniesValidate->getStudent(),
$CompaniesValidate->getResponsible(),
$CompaniesValidate->getEmail(),
'',
$CompaniesValidate->getReference(),
$CompaniesValidate->getResponsibleDocument(),
$CompaniesValidate->getContractDate(),

View file

@ -157,34 +157,50 @@ class Companies
}
/** Insere um novo registro no banco */
public function Save(int $companyId,
string $nameBusiness,
string $nameFantasy,
string $cnpj,
string $cep,
string $adress,
string $number,
string $complement,
string $district,
string $cityId,
string $stateId,
string $active,
int $userId)
public function Save($companyId,
$nameBusiness,
$nameFantasy,
$cnpj,
$cep,
$adress,
$number,
$complement,
$district,
$cityId,
$stateId,
$active,
$type,
$responsible,
$email,
$reference,
$responsibleDocument,
$contractDate,
$computers,
$servers,
$userId)
{
/** Parametros */
$this->companyId = $companyId;
$this->nameBusiness = $nameBusiness;
$this->nameBusiness = $nameBusiness;
$this->nameFantasy = $nameFantasy;
$this->cnpj = $cnpj;
$this->cep = $cep;
$this->adress = $adress;
$this->adress = $adress;
$this->number = $number;
$this->complement = $complement;
$this->district = $district;
$this->cityId = $cityId;
$this->stateId = $stateId;
$this->active = $active;
$this->stateId = $stateId;
$this->active = $active;
$this->type = $type;
$this->responsible = $responsible;
$this->email = $email;
$this->reference = $reference;
$this->responsibleDocument = $responsibleDocument;
$this->contractDate = $contractDate;
$this->computers = $computers;
$this->servers = $servers;
$this->userId = $userId;
/** Verifica se o ID do registro foi informado */