D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
var
/
www
/
html
/
idoso
/
adm
/
app
/
gre
/
Models
/
Filename :
GreListarFatura.php
back
Copy
<?php namespace App\gre\Models; if (!defined('URL')) { header("Location: /"); exit(); } /** * Description of GrsListarContr * * @copyright (c) year, Carlos Marques - CM */ class GreListarFatura { private $Dados; private $Resultado; private $PageId; private $LimiteResultado = 10; private $ResultadoPg; function getResultadoPg() { return $this->ResultadoPg; } public function listarFat($PageId = null, $Dados = null) { $this->PageId = (int) $PageId; $this->Dados = $Dados; if( $_SESSION['filial']<>0){ $this->Dados['gre_filial_id'] = $_SESSION['filial']; } // var_dump($this->Dados['gre_unidade_id']); if(isset($this->Dados['gre_filial_id'])) { $this->Dados['gre_filial_id'] = trim($this->Dados['gre_filial_id']); if(!empty($this->Dados['gre_filial_id'])){ $this->pesquisarFiliCod(); return $this->Resultado; }else{ $this->listarCadastrar(); } } } private function pesquisarFiliCod() { $paginacao = new \App\adms\Models\helper\AdmsPaginacao(URLADM . 'consulta-fatura/listar', '?gre_filial_id='.$this->Dados['gre_filial_id']); $paginacao->condicao($this->PageId, $this->LimiteResultado); $paginacao->paginacao("SELECT COUNT(id) AS num_result FROM gre_filial where gre_empr_princ_id = ". $_SESSION['id_user']); $this->ResultadoPg = $paginacao->getResultado(); if(!isset($this->Dados['docto'])){ $this->Dados['docto'] = 0; } $listarFat = new \App\adms\Models\helper\AdmsRead(); $listarFat->fullRead("SELECT docto id, date_format(fat.anomes, '%d/%m/%Y') mesano, fat.gre_empr_princ_id, case when fat.tipo_fechamento = 'M' then 'MANUAL' else 'MENSAL' end tipo_fechamento, fat.gre_filial_id, forma.nome forma_nome, format((fat.valor_fatura),2, 'de_DE') valor_total, fat.gre_residente_id, filial.nome_fantasia filial_nome, res.nome resid_nome, fat.gre_status_fat_id, stat.nome nome_stat, cr.cor cor_cr, (select count(*) from gre_cab_fatura f WHERE f.gre_empr_princ_id = :empr_id and f.gre_filial_id = :filial_id and f.gre_status_fat_id in (4)) analise FROM gre_cab_fatura fat join gre_forma_pagamento forma on forma.id = fat.gre_forma_pagto_id join gre_filial filial on filial.id = fat.gre_filial_id join gre_residente res on res.id = fat.gre_residente_id INNER JOIN gre_status_fat stat ON stat.id= fat.gre_status_fat_id INNER JOIN adms_cors cr ON cr.id=stat.adms_cor_id WHERE fat.gre_empr_princ_id = :empr_id and fat.gre_filial_id = :filial_id and fat.gre_status_fat_id in (2,3,4) and docto > :docto_id ORDER BY fat.anomes desc, docto, res.nome", "empr_id={$_SESSION['id_user']}&filial_id={$this->Dados['gre_filial_id']}&docto_id={$this->Dados['docto']}"); $this->Resultado = $listarFat->getResultado(); } public function listarCadastrar() { $listar = new \App\adms\Models\helper\AdmsRead(); if( $_SESSION['filial']==0){ $listar->fullRead("SELECT filial.id id_filial, filial.nome_fantasia nome_filial FROM gre_filial filial where filial.gre_empr_princ_id =". $_SESSION['id_user'] . " ORDER BY filial.id"); }else{ $listar->fullRead("SELECT filial.id id_filial, filial.nome_fantasia nome_filial FROM gre_filial filial where filial.gre_empr_princ_id =". $_SESSION['id_user'] . " AND filial.id = ". $_SESSION['filial']); } $registro['filial'] = $listar->getResultado(); $listar->fullRead("SELECT id id_stat, nome nome_stat FROM gre_status_fat order by ordem"); $registro['stat'] = $listar->getResultado(); $listar->fullRead("SELECT fat.gre_filial_id, date_format(max(fat.anomes), '%Y-%m-%d' ) data_fat, date_format(max(fat.anomes), '%d/%m/%Y' ) data_fat_i FROM gre_cab_fatura fat WHERE fat.gre_status_fat_id in (2,3,4) and fat.gre_empr_princ_id = " . $_SESSION['id_user'] . " group by fat.gre_filial_id"); $registro['datas'] = $listar->getResultado(); $this->Resultado = ['filial' => $registro['filial'], 'stat' => $registro['stat'],'datas' => $registro['datas']]; // var_dump($this->Resultado); return $this->Resultado; } }