Skip to content

Commit

Permalink
...
Browse files Browse the repository at this point in the history
  • Loading branch information
marcio1002 committed Jul 23, 2020
1 parent 9e1fdab commit 8c1f8b7
Show file tree
Hide file tree
Showing 12 changed files with 121 additions and 152 deletions.
1 change: 1 addition & 0 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
*/
$router->group("user");
$router->get("/","Router:indexUser");
$router->get("/listaprodutos","Router:listProduct");

/**
* @namespace Controller
Expand Down
54 changes: 27 additions & 27 deletions src/Controllers/Company/AccountManagerCompany.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,33 @@ public function __construct()
$this->safety = new Safety();
}

public function createAccount($param): void
{
try {
$this->emp->fantasy = filter_var($param['fantasy'], FILTER_SANITIZE_STRING, FILTER_FLAG_EMPTY_STRING_NULL);
$this->emp->reason = filter_var($param['reason'], FILTER_SANITIZE_STRING, FILTER_FLAG_EMPTY_STRING_NULL);
$this->emp->cnpj = preg_replace("/\D/", "", filter_var($param['cnpj'], FILTER_SANITIZE_STRING, FILTER_FLAG_EMPTY_STRING_NULL));
$this->emp->email = filter_var($param['email'], FILTER_SANITIZE_STRING, FILTER_FLAG_EMPTY_STRING_NULL);
$this->emp->contact = preg_replace("/\D/", "", filter_var($param['contact'], FILTER_SANITIZE_STRING, FILTER_FLAG_EMPTY_STRING_NULL));
$this->emp->passwd = filter_var($param['passwd'], FILTER_SANITIZE_STRING, FILTER_FLAG_EMPTY_STRING_NULL);
$this->emp->typePackage = filter_var($param['plano'], FILTER_SANITIZE_STRING, FILTER_FLAG_EMPTY_STRING_NULL);
$this->emp->cep = filter_var($param['cep'], FILTER_SANITIZE_STRING, FILTER_FLAG_EMPTY_STRING_NULL);
$this->emp->uf = filter_var($param['uf'], FILTER_SANITIZE_STRING, FILTER_FLAG_EMPTY_STRING_NULL);
$this->emp->address = filter_var($param['address'], FILTER_SANITIZE_STRING, FILTER_FLAG_EMPTY_STRING_NULL);
$this->emp->locality = filter_var($param['locality'], FILTER_SANITIZE_STRING, FILTER_FLAG_EMPTY_STRING_NULL);
$this->emp->statusAccount = PersonLegal::ENABLED;
$this->emp->createAt();

if ($this->handling->createAccountPersonLegal($this->emp)) {
echo json_encode(["error" => false, "status" => DataException::NOT_CONTENT, "msg" => "Ok"]);
} else {
echo json_encode(["error" => true, "status" => DataException::NOT_FOUND, "msg" => "Not Imprements"]);
}
} catch (DataException $ex) {
header("{$_SERVER["SERVER_PROTOCOL"]} {$ex->getCode()} server error");
}
}

public function listenCompanyPro(): void
{
try {
Expand Down Expand Up @@ -53,33 +80,6 @@ public function listenInfoCompany(int $id): ?array
}
}

public function createAccount($param): void
{
try {
$this->emp->fantasy = filter_var($param['fantasy'], FILTER_SANITIZE_STRING, FILTER_FLAG_EMPTY_STRING_NULL);
$this->emp->reason = filter_var($param['reason'], FILTER_SANITIZE_STRING, FILTER_FLAG_EMPTY_STRING_NULL);
$this->emp->cnpj = preg_replace("/\D/", "", filter_var($param['cnpj'], FILTER_SANITIZE_STRING, FILTER_FLAG_EMPTY_STRING_NULL));
$this->emp->email = filter_var($param['email'], FILTER_SANITIZE_STRING, FILTER_FLAG_EMPTY_STRING_NULL);
$this->emp->contact = preg_replace("/\D/", "", filter_var($param['contact'], FILTER_SANITIZE_STRING, FILTER_FLAG_EMPTY_STRING_NULL));
$this->emp->passwd = filter_var($param['passwd'], FILTER_SANITIZE_STRING, FILTER_FLAG_EMPTY_STRING_NULL);
$this->emp->typePackage = filter_var($param['plano'], FILTER_SANITIZE_STRING, FILTER_FLAG_EMPTY_STRING_NULL);
$this->emp->cep = filter_var($param['cep'], FILTER_SANITIZE_STRING, FILTER_FLAG_EMPTY_STRING_NULL);
$this->emp->uf = filter_var($param['uf'], FILTER_SANITIZE_STRING, FILTER_FLAG_EMPTY_STRING_NULL);
$this->emp->address = filter_var($param['address'], FILTER_SANITIZE_STRING, FILTER_FLAG_EMPTY_STRING_NULL);
$this->emp->locality = filter_var($param['locality'], FILTER_SANITIZE_STRING, FILTER_FLAG_EMPTY_STRING_NULL);
$this->emp->statusAccount = PersonLegal::ENABLED;
$this->emp->createAt();

if ($this->handling->createAccountPersonLegal($this->emp)) {
echo json_encode(["error" => false, "status" => DataException::NOT_CONTENT, "msg" => "Ok"]);
} else {
echo json_encode(["error" => true, "status" => DataException::NOT_FOUND, "msg" => "Not Imprements"]);
}
} catch (DataException $ex) {
header("{$_SERVER["SERVER_PROTOCOL"]} {$ex->getCode()} server error");
}
}

public function updateCompany($param): void
{
try{
Expand Down
7 changes: 1 addition & 6 deletions src/ControllersServices/Company/CompanyHandling.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,26 +45,21 @@ public function createPayment(Pagamento $emp,int $type): bool
switch($type) {
case 1:
$columns = "tipo_pg, cod_trans, status, carrinho_id, created";
$quant = 5;
break;
case 2:
$columns = "tipo_pg, cod_trans, status, link_boleto,carrinho_id, created";
$quant = 6;
break;
case 3:
$columns = "tipo_pg, cod_trans, status, link_db_online,carrinho_id, created";
$quant = 6;
break;
}

$this->sql->open();
return $this->sql
->add("pagamento",$columns,$quant)
->add("pagamento",$columns,count($emp->getAll()))
->prepareParam($emp->getAll())
->execNotRowSql();



}catch(DataException $ex){
throw $ex;
}finally {
Expand Down
2 changes: 1 addition & 1 deletion src/ControllersServices/Product/ProductHandling.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public function searchProd(Product $prod): ?array
return $this->sql
->show(
"produto AS p INNER JOIN empresa AS e ON p.id_empresa = e.id_empresa",
"p.*, e.id_empresa,e.fantasia, e.cnpj,e.email,e.contato,e.cidade, e.endereco,e.uf",
"p.*, e.id_empresa,e.fantasia, e.cnpj,e.email,e.contato,e.cidade, e.endereco,e.uf,e.imagem",
"e.id_empresa = ?",
6
)
Expand Down
1 change: 1 addition & 0 deletions src/Views/User/_theme.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
"js/bootstrap",
"js/alertify",
"js/apis",
"js/manipulation"
]);

echo "<script>
Expand Down
89 changes: 4 additions & 85 deletions src/Views/User/index.php

Large diffs are not rendered by default.

24 changes: 24 additions & 0 deletions src/Views/User/listProduct.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php
require_once __DIR__ . "/../../../vendor/autoload.php";
use Ecomais\Web\Bundles;

$this->layout("_theme", ["title" => "EcoMais - My Home"]);

$this->start("css");
echo Bundles::renderCss(["css/dataTable"]);
$this->stop();
?>
<div class="col-12 p-4 bg-dark">
<div class="col-4 mx-auto my-auto rounded bg-transparent" id="logoCompany" style="max-height: 400px;">
</div>
</div>
<div class="col-12 bg-light">
<div id="list-product" class="col-11 m-auto py-4 bg-transparent"></div>
</div>
<?php
$this->start("scripts");
echo Bundles::renderJs(["js/dataTable"]);
?>

<script src=<?= renderUrl("/src/assets/js/product/list-product.js")?> ></script>
<?php $this->stop()?>
4 changes: 2 additions & 2 deletions src/Views/registerCompany.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
$svgCeta = "<svg class='bi bi-caret-right-fill' width='1em' height='1em' viewBox='0 0 16 16' fill='currentColor' xmlns='http://www.w3.org/2000/svg'><path d='M12.14 8.753l-5.482 4.796c-.646.566-1.658.106-1.658-.753V3.204a1 1 0 0 1 1.659-.753l5.48 4.796a1 1 0 0 1 0 1.506z'/></svg>";

if (!empty($code)) {

//ignore o problema o vscode não encontro o objeto mas ele existe
if ($data = $google->getData($code)) {
$name = "value='{$data->getName()}'";
$email = "value='{$data->getEmail()}'";
Expand All @@ -35,7 +35,7 @@
?>

<div class="container">
<div class="row">
<div class="row py-5">
<div class=" col-xl-6 col-lg-6 col-md-10 m-xl-0 m-lg-0 m-md-auto col-sm-12">
<div class="card mb-3" id="formCompany">
<div class="card-header">
Expand Down
8 changes: 7 additions & 1 deletion src/Web/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,15 @@ public function perfilCompany(): void
/**
* @group User
*/
public function indexUser()
public function indexUser(): void
{
$this->directory("User");
echo $this->view->render("index");
}

public function listProduct(): void
{
$this->directory("User");
echo $this->view->render("listProduct");
}
}
14 changes: 7 additions & 7 deletions src/assets/js/product/list-product.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
$(function () {
alertify.set('notifier', 'position', 'top-right');

/* <div id="list-product" class="col-11 m-auto p-2"></div> */

function createTable() {
$("#list-product").append(`<table id="table" class="table table-striped table-bordered bg-dark text-white" style="width:100%"></table>`);
$("#list-product #table").append(`<thead id="thead" class="thead bg-light text-red-wine font-weight-bold"></thead>`);
Expand All @@ -19,17 +17,19 @@ $(function () {
success: (res) => {
if (res && !res.error) {
if (res.data) {
$("#logoCompany").append(`<img class="img-fluid w-100" src="${res.data[0].imagem}" alt="logo do(a) tenda-atacado">`);
$("#table #thead").append(`
<tr>
<th>Nome</th>
<th>Preço</th>
<th>Marca</th>
<th>Descrição</th>
<th>Quanti.</th>
<th>Preço</th>
<th>Quantidade</th>
<th>Inicio promoção</th>
<th>Fim promoção</th>
</tr>
`);

res.data.forEach((val, index) => {
$("#table #tbody").append(`
<tr data-id="${val.id_produto}" >
Expand All @@ -40,17 +40,17 @@ $(function () {
<td>${val.quantidade}</td>
<td><span class="badge badge-info font-size-1em">${formatDate(val.periodo_inicio)}</span></td>
<td><span class="badge badge-info font-size-1em">${formatDate(val.periodo_fim)}</span></td>
</tr>`)
</tr>`);
});
$("#list-product #table").dataTable({
"language": {
"sEmptyTable": "Nenhum registro encontrado",
"sEmptyTable": "Nenhum produto encontrado",
"sInfo": "Mostrando de _START_ até _END_ total de _TOTAL_ registros",
"sInfoEmpty": "Mostrando 0 até 0 de 0 registros",
"sLengthMenu": "_MENU_ resultados por página",
"sLoadingRecords": "Carregando...",
"sProcessing": "Processando...",
"sZeroRecords": "Nenhum registro encontrado",
"sZeroRecords": "Nenhum produto encontrado",
"sSearch": "Pesquisar",
"oPaginate": {
"sNext": "Próximo",
Expand Down
46 changes: 46 additions & 0 deletions src/assets/js/user/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 8c1f8b7

Please sign in to comment.