Atualizando abas documentos

This commit is contained in:
Kenio 2025-08-21 20:50:53 -03:00
parent dfefc7367f
commit 04c08eef95
2 changed files with 73 additions and 14 deletions

View file

@ -107,7 +107,7 @@ 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, ? int $companyId)
public function All(? int $start, ? int $max, ? int $documentsCategorysId, ? string $tag, ? string $label, ? bolean $companyId)
{
/** Parametros de entrada */
$this->start = $start;
@ -131,9 +131,13 @@ class Documents
}
/** Se houver um cliente informado, crio o filtro de consulta */
if($this->companyId > 0){
if($this->companyId === true){
$this->and = " and d.company_id = {$this->companyId}";
$this->and = " and company_id is not null";
} elseif ($this->companyId === false) {
$this->and = " and company_id is null";
}
/** Consulta SQL */
@ -153,7 +157,7 @@ class Documents
from documents d
left join companies c on d.company_id = c.company_id
left join documents_categorys dc on d.documents_categorys_id = dc.documents_categorys_id
where d.company_id is not null ';
where d.documents_id is not null ';
$this->sql .= $this->and;
@ -172,7 +176,7 @@ class Documents
}
/** Conta a quantidades de registros */
public function Count(? int $documentsCategorysId, ? string $tag, ? string $label, ? int $companyId)
public function Count(? int $documentsCategorysId, ? string $tag, ? string $label, ? bolean $companyId)
{
/** Parametros de entraa */
$this->documentsCategorysId = $documentsCategorysId;
@ -189,15 +193,19 @@ class Documents
}
/** Se houver um cliente informado, crio o filtro de consulta */
if($this->companyId > 0){
if($this->companyId === true){
$this->and = " and company_id = {$this->companyId}";
$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
where company_id is not null
where documents_id is not null
'.$this->and;
/** Preparo o SQL para execução */

View file

@ -6,9 +6,6 @@ use vendor\model\Documents;
use vendor\model\DocumentsCategorys;
use vendor\controller\documents\DocumentsValidate;
error_reporting(E_ALL);
ini_set('display_errors', 'On');
/** Verifica se o token de acesso é válido */
if($Main->verifyToken()){
@ -33,7 +30,8 @@ if($Main->verifyToken()){
$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, null);
$NumberRecords = $Documents->Count((int)$documentsCategorysId, (string)$tag, (string)$label, true);
$NumberRecords += $Documents->Count((int)$documentsCategorysId, (string)$tag, (string)$label, false);
/** Cores do card */
$colors = [ 'success', 'info', 'warning', 'danger', 'secondary'];
@ -120,7 +118,7 @@ if($Main->verifyToken()){
<?php
/** Consulta os usuário cadastrados*/
$DocumentsResult = $Documents->All($start, $max, (int)$documentsCategorysId, (string)$tag, (string)$label, null);
$DocumentsResult = $Documents->All($start, $max, (int)$documentsCategorysId, (string)$tag, (string)$label, true);
foreach($DocumentsResult as $DocumentsKey => $Result){
?>
@ -153,7 +151,60 @@ if($Main->verifyToken()){
</div>
</div>
<div class="tab-pane fade " id="pills-2" role="tabpanel" aria-labelledby="pills-2-tab">
kkkkk
<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"></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
/** 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>
<?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>
</div>
</div>
</div>
</div>