D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
var
/
www
/
html
/
idoso
/
adm
/
app
/
gre
/
Models
/
Filename :
GreListarFaturaConferencia.php
back
Copy
<?php namespace App\gre\Models; if (!defined('URL')) { header("Location: /"); exit(); } /** * Description of GrsListarContr * * @copyright (c) year, Carlos Marques - CM */ class GreListarFaturaConferencia { 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; // echo '<pre>'; // var_dump($this->Dados); // echo '</pre>'; if(isset($this->Dados['data_fecha'])){ $part = explode("@",$this->Dados['data_fecha']); // var_dump($part[0]); // var_dump($part[1]); // var_dump($part[2]); if(!empty($part[0])){ $this->pesquisarFiliCod(); return $this->Resultado; }else{ $this->listarCadastrar(); } }else{ //die; 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() { // echo '<pre>'; //var_dump($this->Dados); // echo '</pre>'; $listarFat = new \App\adms\Models\helper\AdmsRead(); if(!isset($this->Dados['data_fecha'])) { $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 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 = 8 ORDER BY fat.anomes desc, res.nome", "empr_id={$_SESSION['id_user']}&filial_id={$this->Dados['gre_filial_id']}"); }else{ $part = explode("@",$this->Dados['data_fecha']); $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 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.anomes = :anomes and fat.gre_status_fat_id = 8 ORDER BY fat.anomes desc, res.nome", "empr_id={$_SESSION['id_user']}&anomes={$part[0]}"); } $this->Resultado = $listarFat->getResultado(); // var_dump ($this->Resultado[0]); } public function listarCadastrar() { $listar = new \App\adms\Models\helper\AdmsRead(); if( $_SESSION['filial']==0){ $listar->fullRead("SELECT filial.data_prox_fechamento, filial.data_ult_lanca_dia,filial.id id_filial, concat(date_format(filial.data_prox_fechamento, '%m/%Y'), ' - ', filial.nome_fantasia) nome_filial FROM gre_filial filial inner join gre_empresa empr on empr.id = filial.gre_empr_princ_id where filial.gre_empr_princ_id = ". $_SESSION['id_user'] ." and empr.tipo_fechamento <> 2 and filial.data_ult_fechamento < curdate() ORDER BY filial.id"); }else{ $listar->fullRead("SELECT filial.data_prox_fechamento,filial.data_ult_lanca_dia,filial.id id_filial, concat(date_format(filial.data_prox_fechamento, '%m/%Y'), ' - ', filial.nome_fantasia) nome_filial FROM gre_filial filial inner join gre_empresa empr on empr.id = filial.gre_empr_princ_id where filial.gre_empr_princ_id =". $_SESSION['id_user'] . " AND filial.id = ". $_SESSION['filial']." and empr.tipo_fechamento <> 2 and filial.data_ult_fechamento < curdate() ORDER BY filial.id"); } $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 = 8 and fat.gre_empr_princ_id = " . $_SESSION['id_user'] . " group by fat.gre_filial_id"); $registro['datas'] = $listar->getResultado(); $listar = new \App\adms\Models\helper\AdmsRead(); $listar->fullRead("select concat(fat.anomes,'@',contr.data_prox_fechamento,'@',contr.dia_pagamento,'@',f.id) data_fecha, concat(date_format(contr.data_prox_fechamento, '%d/%m/%Y'), ' - ', f.nome_fantasia) contr_data FROM gre_contratante contr inner join gre_cab_fatura fat on fat.gre_empr_princ_id = contr.gre_empr_princ_id and fat.gre_filial_id = contr.gre_filial_id and fat.gre_contratante_id = contr.id inner join gre_filial f on f.id = contr.gre_filial_id inner join gre_empresa empr on contr.gre_empr_princ_id = empr.id where contr.gre_empr_princ_id = ".$_SESSION['id_user']. " and empr.tipo_fechamento = 2 and contr.data_ult_fechamento < curdate() and fat.gre_status_fat_id = 8 group by fat.anomes,contr.data_prox_fechamento, contr.dia_pagamento,f.id, f.nome_fantasia;"); $registro['contr'] = $listar->getResultado(); $this->Resultado = ['filial' => $registro['filial'], 'contr' => $registro['contr'], 'stat' => $registro['stat'],'datas' => $registro['datas']]; // var_dump($this->Resultado); return $this->Resultado; } }