Atualizando abas documentos
This commit is contained in:
parent
a91ef1e0a8
commit
f8bcb30ead
2 changed files with 96 additions and 160 deletions
28
vendor/model/Documents.class.php
vendored
28
vendor/model/Documents.class.php
vendored
|
|
@ -107,13 +107,12 @@ class Documents
|
|||
}
|
||||
|
||||
/** Lista todos os egistros do banco com ou sem paginação*/
|
||||
public function All(? int $start, ? int $max, ? int $documentsCategorysId, ? string $tag, ? string $label, ? bool $companyId)
|
||||
public function All(? int $start, ? int $max, ? int $documentsCategorysId, ? string $tag, ? string $label)
|
||||
{
|
||||
/** Parametros de entrada */
|
||||
$this->start = $start;
|
||||
$this->max = $max;
|
||||
$this->documentsCategorysId = $documentsCategorysId;
|
||||
$this->companyId = $companyId;
|
||||
$this->tag = $tag;
|
||||
$this->label = $label;
|
||||
$this->and = "";
|
||||
|
|
@ -128,17 +127,7 @@ class Documents
|
|||
/** Verifico se há paginação */
|
||||
if($this->max){
|
||||
$this->limit = "limit $this->start, $this->max";
|
||||
}
|
||||
|
||||
/** Se houver um cliente informado, crio o filtro de consulta */
|
||||
if($this->companyId === true){
|
||||
|
||||
$this->and = " and d.company_id is not null";
|
||||
|
||||
} elseif ($this->companyId === false) {
|
||||
|
||||
$this->and = " and d.company_id is null";
|
||||
}
|
||||
}
|
||||
|
||||
/** Consulta SQL */
|
||||
$this->sql = 'select d.documents_id,
|
||||
|
|
@ -176,13 +165,12 @@ class Documents
|
|||
}
|
||||
|
||||
/** Conta a quantidades de registros */
|
||||
public function Count(? int $documentsCategorysId, ? string $tag, ? string $label, ? bool $companyId)
|
||||
public function Count(? int $documentsCategorysId, ? string $tag, ? string $label)
|
||||
{
|
||||
/** Parametros de entraa */
|
||||
$this->documentsCategorysId = $documentsCategorysId;
|
||||
$this->tag = $tag;
|
||||
$this->label = $label;
|
||||
$this->companyId = $companyId;
|
||||
$this->and = "";
|
||||
|
||||
/** Se houver categoria informada, crio o filtro de consulta*/
|
||||
|
|
@ -192,16 +180,6 @@ class Documents
|
|||
$this->and .= " and json_search(tag, 'all', '".$this->tag."', null, '$.".$this->label."') is not null";
|
||||
}
|
||||
|
||||
/** Se houver um cliente informado, crio o filtro de consulta */
|
||||
if($this->companyId === true){
|
||||
|
||||
$this->and = " and company_id is not null";
|
||||
|
||||
} elseif ($this->companyId === false) {
|
||||
|
||||
$this->and = " and company_id is null";
|
||||
}
|
||||
|
||||
/** Consulta SQL */
|
||||
$this->sql = 'select count(documents_id) as qtde
|
||||
from documents
|
||||
|
|
|
|||
228
vendor/view/documents/documents_datagrid.php
vendored
228
vendor/view/documents/documents_datagrid.php
vendored
|
|
@ -29,9 +29,14 @@ if($Main->verifyToken()){
|
|||
$page = strtolower(isset($_POST['page']) ? (int)$Main->antiInjection( filter_input(INPUT_POST,'page', FILTER_SANITIZE_SPECIAL_CHARS) ) : 0);
|
||||
$max = isset($settings->{'app'}->{'datagrid'}->{'rows'}) ? $settings->{'app'}->{'datagrid'}->{'rows'} : 20;
|
||||
|
||||
/** Consulta a quantidade de registros */
|
||||
$NumberRecords += $Documents->Count((int)$documentsCategorysId, (string)$tag, (string)$label);
|
||||
|
||||
/** Cores do card */
|
||||
$colors = [ 'success', 'info', 'warning', 'danger', 'secondary'];
|
||||
|
||||
/** Verifico a quantidade de registros localizados */
|
||||
if ($NumberRecords > 0){ //Caso tenha registros cadastrados, carrego o layout
|
||||
|
||||
?>
|
||||
|
||||
|
|
@ -78,171 +83,124 @@ if($Main->verifyToken()){
|
|||
|
||||
<div class="card-body">
|
||||
|
||||
<ul class="nav nav-pills nav-fill" id="pills-tab" role="tablist">
|
||||
<li class="nav-item nav-link-pill mx-1 mb-2" role="presentation">
|
||||
<a class="nav-link active" id="pills-1-tab" data-toggle="pill" href="#pills-1" role="tab" aria-controls="pills-1" aria-selected="true">Documentos Clientes</a>
|
||||
</li>
|
||||
<form class="row" id="frmSearchDocuments">
|
||||
|
||||
<li class="nav-item nav-link-pill mx-1 mb-2" role="presentation">
|
||||
<a class="nav-link " id="pills-2-tab" data-toggle="pill" href="#pills-2" role="tab" aria-controls="pills-2" aria-selected="true">Documentos Gerais</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<div class="tab-content" id="pills-tabContent">
|
||||
<div class="tab-pane fade active show" id="pills-1" role="tabpanel" aria-labelledby="pills-1-tab">
|
||||
|
||||
<div class="table-responsive">
|
||||
|
||||
<table class="table table-bordered table-striped table-hover bg-white rounded shadow-sm table-sm" id="tableDocuments" width="100%" cellspacing="0">
|
||||
<div class="col-md">
|
||||
<div class="form-group">
|
||||
<!--<label for="active">Tipo: </label>-->
|
||||
<select class="form-control form-control w-100" id="type" name="type">
|
||||
<option value="" selected>Tipo</option>
|
||||
<?php
|
||||
|
||||
<thead>
|
||||
<tr >
|
||||
<th class="text-center">Nº</th>
|
||||
<th class="text-center">Data</th>
|
||||
<th class="text-center">Descrição</th>
|
||||
<th class="text-center">Cliente</th>
|
||||
<th class="text-center"></th>
|
||||
<th class="text-center"></th>
|
||||
<th class="text-center"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
|
||||
<?php
|
||||
|
||||
/** Conulta a quantidade de registros */
|
||||
$NumberRecords = $Documents->Count((int)$documentsCategorysId, (string)$tag, (string)$label, true);
|
||||
|
||||
/** Consulta os usuário cadastrados*/
|
||||
$DocumentsResult = $Documents->All($start, $max, (int)$documentsCategorysId, (string)$tag, (string)$label, true);
|
||||
foreach($DocumentsResult as $DocumentsKey => $Result){
|
||||
?>
|
||||
|
||||
<tr>
|
||||
<td class="text-center" width="60"><?php echo $Main->setZeros($Result->documents_id, 3);?></td>
|
||||
<td class="text-center" width="60"><?php echo date("d/m/Y", strtotime($Result->date_register));?></td>
|
||||
<td class="text-left"><?php echo $Result->description;?></td>
|
||||
<td class="text-left"><?php echo $Result->name_fantasy;?></td>
|
||||
<td class="text-center" width="20"><button type="button" class="btn btn-primary btn-sm" onclick="request('FOLDER=view&TABLE=documents&ACTION=documents_view&documents_id=<?php echo $Result->documents_id;?>', '#loadContent', true, '', '', '', 'Carregando informações do documento', 'blue', 'circle', 'sm', true)"><i class="fa fa-search-plus" aria-hidden="true"></i></button></td>
|
||||
<td class="text-center" width="20"><button type="button" class="btn btn-primary btn-sm" onclick="request('FOLDER=view&TABLE=documents&ACTION=documents_details&documents_id=<?php echo $Result->documents_id;?>', '#loadContent', true, '', '', '', 'Carregando informações do documento', 'blue', 'circle', 'sm', true)"><i class="fa fa-info" aria-hidden="true"></i></button></td>
|
||||
<td class="text-center" width="20"><button type="button" class="btn btn-primary btn-sm" onclick="request('FOLDER=view&TABLE=documents&ACTION=documents_form&documents_id=<?php echo $Result->documents_id;?>', '#loadContent', true, '', '', '', 'Preparando formulário', 'blue', 'circle', 'sm', true)"><i class="fas fa-edit mr-1"></i></button></td>
|
||||
</tr>
|
||||
|
||||
<?php } ?>
|
||||
|
||||
</tbody>
|
||||
|
||||
<tfoot>
|
||||
<tr>
|
||||
<td colspan="8">
|
||||
|
||||
<?php echo $Main->pagination($NumberRecords, $start, $max, $page, 'FOLDER=view&ACTION=documents_datagrid&TABLE=documents', 'Aguarde'); ?>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
|
||||
</table>
|
||||
|
||||
/** Consulta as categorias de documentos cadastradas*/
|
||||
$DocumentsCategorysResult = $DocumentsCategorys->All($start, $max);
|
||||
foreach($DocumentsCategorysResult as $DocumentsCategorysKey => $Result){
|
||||
?>
|
||||
<option value="<?php echo $Result->documents_categorys_id;?>" <?php echo (int)$documentsCategorysId === $Result->documents_categorys_id ? 'selected' : '';?>><?php echo $Result->description;?></option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="tab-pane fade " id="pills-2" role="tabpanel" aria-labelledby="pills-2-tab">
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
<div class="table-responsive">
|
||||
<div class="table-responsive">
|
||||
|
||||
<table class="table table-bordered table-striped table-hover bg-white rounded shadow-sm table-sm" id="tableDocuments" width="100%" cellspacing="0">
|
||||
|
||||
<thead>
|
||||
<tr >
|
||||
<th class="text-center">Nº</th>
|
||||
<th class="text-center">Data</th>
|
||||
<th class="text-center">Descrição</th>
|
||||
<th class="text-center">Cliente</th>
|
||||
<th class="text-center"></th>
|
||||
<th class="text-center"></th>
|
||||
<th class="text-center"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<table class="table table-bordered table-striped table-hover bg-white rounded shadow-sm table-sm" id="tableDocuments" width="100%" cellspacing="0">
|
||||
|
||||
<thead>
|
||||
<tr >
|
||||
<th class="text-center">Nº</th>
|
||||
<th class="text-center">Data</th>
|
||||
<th class="text-center">Descrição</th>
|
||||
<th class="text-center">Cliente</th>
|
||||
<th class="text-center"></th>
|
||||
<th class="text-center"></th>
|
||||
<th class="text-center"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
|
||||
<?php
|
||||
<tbody>
|
||||
|
||||
<?php
|
||||
|
||||
/** Conulta a quantidade de registros */
|
||||
$NumberRecords = $Documents->Count((int)$documentsCategorysId, (string)$tag, (string)$label, false);
|
||||
|
||||
/** Consulta os usuário cadastrados*/
|
||||
$DocumentsResult = $Documents->All($start, $max, (int)$documentsCategorysId, (string)$tag, (string)$label, false);
|
||||
foreach($DocumentsResult as $DocumentsKey => $Result){
|
||||
?>
|
||||
|
||||
<tr>
|
||||
<td class="text-center" width="60"><?php echo $Main->setZeros($Result->documents_id, 3);?></td>
|
||||
<td class="text-center" width="60"><?php echo date("d/m/Y", strtotime($Result->date_register));?></td>
|
||||
<td class="text-left"><?php echo $Result->description;?></td>
|
||||
<td class="text-left"><?php echo $Result->name_fantasy;?></td>
|
||||
<td class="text-center" width="20"><button type="button" class="btn btn-primary btn-sm" onclick="request('FOLDER=view&TABLE=documents&ACTION=documents_view&documents_id=<?php echo $Result->documents_id;?>', '#loadContent', true, '', '', '', 'Carregando informações do documento', 'blue', 'circle', 'sm', true)"><i class="fa fa-search-plus" aria-hidden="true"></i></button></td>
|
||||
<td class="text-center" width="20"><button type="button" class="btn btn-primary btn-sm" onclick="request('FOLDER=view&TABLE=documents&ACTION=documents_details&documents_id=<?php echo $Result->documents_id;?>', '#loadContent', true, '', '', '', 'Carregando informações do documento', 'blue', 'circle', 'sm', true)"><i class="fa fa-info" aria-hidden="true"></i></button></td>
|
||||
<td class="text-center" width="20"><button type="button" class="btn btn-primary btn-sm" onclick="request('FOLDER=view&TABLE=documents&ACTION=documents_form&documents_id=<?php echo $Result->documents_id;?>', '#loadContent', true, '', '', '', 'Preparando formulário', 'blue', 'circle', 'sm', true)"><i class="fas fa-edit mr-1"></i></button></td>
|
||||
</tr>
|
||||
/** Consulta os usuário cadastrados*/
|
||||
$DocumentsResult = $Documents->All($start, $max, (int)$documentsCategorysId, (string)$tag, (string)$label);
|
||||
foreach($DocumentsResult as $DocumentsKey => $Result){
|
||||
?>
|
||||
|
||||
<tr>
|
||||
<td class="text-center" width="60"><?php echo $Main->setZeros($Result->documents_id, 3);?></td>
|
||||
<td class="text-center" width="60"><?php echo date("d/m/Y", strtotime($Result->date_register));?></td>
|
||||
<td class="text-left"><?php echo $Result->description;?></td>
|
||||
<td class="text-left"><?php echo $Result->name_fantasy;?></td>
|
||||
<td class="text-center" width="20"><button type="button" class="btn btn-primary btn-sm" onclick="request('FOLDER=view&TABLE=documents&ACTION=documents_view&documents_id=<?php echo $Result->documents_id;?>', '#loadContent', true, '', '', '', 'Carregando informações do documento', 'blue', 'circle', 'sm', true)"><i class="fa fa-search-plus" aria-hidden="true"></i></button></td>
|
||||
<td class="text-center" width="20"><button type="button" class="btn btn-primary btn-sm" onclick="request('FOLDER=view&TABLE=documents&ACTION=documents_details&documents_id=<?php echo $Result->documents_id;?>', '#loadContent', true, '', '', '', 'Carregando informações do documento', 'blue', 'circle', 'sm', true)"><i class="fa fa-info" aria-hidden="true"></i></button></td>
|
||||
<td class="text-center" width="20"><button type="button" class="btn btn-primary btn-sm" onclick="request('FOLDER=view&TABLE=documents&ACTION=documents_form&documents_id=<?php echo $Result->documents_id;?>', '#loadContent', true, '', '', '', 'Preparando formulário', 'blue', 'circle', 'sm', true)"><i class="fas fa-edit mr-1"></i></button></td>
|
||||
</tr>
|
||||
|
||||
<?php } ?>
|
||||
|
||||
</tbody>
|
||||
<?php } ?>
|
||||
|
||||
</tbody>
|
||||
|
||||
<tfoot>
|
||||
<tr>
|
||||
<td colspan="8">
|
||||
<tfoot>
|
||||
<tr>
|
||||
<td colspan="8">
|
||||
|
||||
<?php echo $Main->pagination($NumberRecords, $start, $max, $page, 'FOLDER=view&ACTION=documents_datagrid&TABLE=documents', 'Aguarde'); ?>
|
||||
<?php echo $Main->pagination($NumberRecords, $start, $max, $page, 'FOLDER=view&ACTION=documents_datagrid&TABLE=documents', 'Aguarde'); ?>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
|
||||
</table>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
<?php
|
||||
|
||||
/** Aplicar recursos na tabela */
|
||||
$(document).ready(function(e) {
|
||||
}else{//Caso não tenha registros cadastrados, informo ?>
|
||||
|
||||
const documents_categorys_id = [];
|
||||
const description = [];
|
||||
|
||||
<?php
|
||||
<div class="col-lg-12">
|
||||
|
||||
/** Consulta as categorias de documentos cadastradas*/
|
||||
$DocumentsCategorysResult = $DocumentsCategorys->All(0, 0);
|
||||
foreach($DocumentsCategorysResult as $DocumentsCategorysKey => $Result){
|
||||
<!-- Informo -->
|
||||
<div class="card shadow mb-12">
|
||||
<div class="card-header py-3">
|
||||
<h6 class="m-0 font-weight-bold text-primary">Atenção</h6>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
|
||||
?>
|
||||
<div class="row">
|
||||
|
||||
documents_categorys_id.push("<?php echo $Result->documents_categorys_id;?>");
|
||||
description.push("<?php echo $Result->description;?>");
|
||||
<div class="col-md-8 text-right">
|
||||
<h4>Não foram cadastrados documentos.</h4>
|
||||
</div>
|
||||
|
||||
<?php } ?>
|
||||
<div class="col-md-4 text-right">
|
||||
|
||||
/** Modal de consulta */
|
||||
$('#btn-search').click(function(){
|
||||
<button type="button" class="btn btn-success btn-sm" onclick="request('FOLDER=view&TABLE=documents&ACTION=documents_form', '#loadContent', true, '', '', '', 'Preparando formulário', 'blue', 'circle', 'sm', true)">
|
||||
|
||||
formSearchDocs(documents_categorys_id, description);
|
||||
});
|
||||
<i class="fas fa-plus-circle mr-1"></i>Cadastrar novo documento
|
||||
|
||||
});
|
||||
</button>
|
||||
|
||||
</script>
|
||||
<?php
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<?php }
|
||||
|
||||
/** Caso o token de acesso seja inválido, informo */
|
||||
}else{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue