D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
var
/
www
/
html
/
rosario
/
adm
/
app
/
gre
/
Models
/
Filename :
ModPsaudeUtiAutorizaListar.php
back
Copy
<?php namespace App\gre\Models; if (!defined('URL')) { header("Location: /"); exit(); } /** * Description of ModPsaudeUtiAutorizaListar * * @copyright (c) year, Carlos Marques - CM */ class ModPsaudeUtiAutorizaListar { private $Dados; private $Resultado; private $PageId; private $DadosExcel; public function listarPsaudeUti($PageId = null, $Dados = null) { $this->PageId = (int) $PageId; $this->DadosExcel = filter_input_array(INPUT_GET, FILTER_DEFAULT); if(isset($this->DadosExcel['opcao'])){ $this->Dados['tipo_cli'] = $this->DadosExcel['tipo_cli']; $this->Dados['tipo_prod'] = $this->DadosExcel['tipo_prod']; $this->Dados['mesano'] = $this->DadosExcel['mesano']; $this->pesquisarPsaude(); return $this->Resultado; }else{ $this->Dados = filter_input_array(INPUT_POST, FILTER_DEFAULT); } //var_dump($this->Dados); if(isset($this->Dados['ListPsaudeUti'])){ $this->pesquisarPsaude(); return $this->Resultado; }else{ $this->listarCadastrar(); } } private function pesquisarPsaude() { $listarSelect = new \App\gre\Models\ModPsaudeMedListar(); $this->Dados['select'] = $listarSelect->listarCadastrar(); $listPsaude = new \App\adms\Models\helper\AdmsRead(); if ( $this->Dados['tipo_cli'] == 0) { if($this->Dados['tipo_prod'] == 0) { $listPsaude->fullRead("select date_format(max(c.created), '%d/%m/%Y') data_inclusao, c.cpf, max(c.tipo_id) tipo_id, 0 tipo_cli, 0 tipo_prod, 'TODOS' tipo_cli_nome_sel, 'TODOS' tipo_pro_nome_sel, :mesano mesano, MASK(lpad(c.cpf,11,0), '###.###.###-##') cpfi, MASK(lpad(max(c.celular1),11,0), '(##) #####-####') celular, max(e.nome) empr_nome, max(c.nome) titu_nome, max(t.nome) tipo_cli_nome from ps_cliente c left join ps_tipo_cliente t on t.id = c.tipo_id left join ps_empresa_convenio e on e.cod_empresa = c.empr_convenio_id where c.sit_programa = 1 and c.cpf not in (select m.cpf from ps_movimento m where date_format(m.data_mov, '%Y-%m' ) = :mesano) group by c.cpf ORDER BY empr_nome, titu_nome", "mesano={$this->Dados['mesano']}"); }else{ $listPsaude->fullRead("select date_format(max(c.created), '%d/%m/%Y') data_inclusao, c.cpf, max(c.tipo_id) tipo_id, 0 tipo_cli, :tipo_prod tipo_prod, :mesano mesano, 'TODOS' tipo_cli_nome_sel, (select max(tp.nome) from ps_tipo_produto tp where tp.id = :tipo_prod) tipo_pro_nome_sel, MASK(lpad(c.cpf,11,0), '###.###.###-##') cpfi, MASK(lpad(max(c.celular1),11,0), '(##) ####.####') celular, max(e.nome) empr_nome, max(c.nome) titu_nome, max(t.nome) tipo_cli_nome from ps_cliente c left join ps_tipo_cliente t on t.id = c.tipo_id left join ps_empresa_convenio e on e.cod_empresa = c.empr_convenio_id where c.sit_programa = 1 and c.cpf not in (select m.cpf from ps_movimento m where date_format(m.data_mov, '%Y-%m' ) = :mesano and m.tipo_produto = :tipo_prod) group by c.cpf ORDER BY empr_nome, titu_nome", "tipo_prod={$this->Dados['tipo_prod']}"."&mesano={$this->Dados['mesano']}"); } }else{ if($this->Dados['tipo_prod'] == 0) { $listPsaude->fullRead("select date_format(max(c.created), '%d/%m/%Y') data_inclusao, c.cpf, max(c.tipo_id) tipo_id, :tipo_cli tipo_cli, 0 tipo_prod, :mesano mesano, max(t.nome) tipo_cli_nome_sel, 'TODOS' tipo_pro_nome_sel, MASK(lpad(c.cpf,11,0), '###.###.###-##') cpfi, MASK(lpad(max(c.celular1),11,0), '(##) ####.####') celular, max(e.nome) empr_nome, max(c.nome) titu_nome, max(t.nome) tipo_cli_nome from ps_cliente c left join ps_tipo_cliente t on t.id = c.tipo_id left join ps_empresa_convenio e on e.cod_empresa = c.empr_convenio_id where c.sit_programa = 1 and c.tipo_id = :tipo_cli and c.cpf not in (select m.cpf from ps_movimento m where date_format(m.data_mov, '%Y-%m' ) = :mesano) group by c.cpf ORDER BY empr_nome, titu_nome", "tipo_cli={$this->Dados['tipo_cli']}"."&mesano={$this->Dados['mesano']}"); }else{ $listPsaude->fullRead("select date_format(max(c.created), '%d/%m/%Y') data_inclusao, c.cpf, max(c.tipo_id) tipo_id, :tipo_cli tipo_cli, :tipo_prod tipo_prod, :mesano mesano, max(t.nome) tipo_cli_nome_sel, max(tp.nome) tipo_pro_nome_sel, MASK(lpad(c.cpf,11,0), '###.###.###-##') cpfi, MASK(lpad(max(c.celular1),11,0), '(##) ####.####') celular, max(e.nome) empr_nome, max(c.nome) titu_nome, max(t.nome) tipo_cli_nome from ps_cliente c left join ps_tipo_cliente t on t.id = c.tipo_id left join ps_tipo_produto tp on tp.id = :tipo_prod left join ps_empresa_convenio e on e.cod_empresa = c.empr_convenio_id where c.sit_programa = 1 and c.tipo_id = :tipo_cli and c.cpf not in (select m.cpf from ps_movimento m where date_format(m.data_mov, '%Y-%m' ) = :mesano and m.tipo_produto = :tipo_prod) group by c.cpf ORDER BY empr_nome, titu_nome", "tipo_cli={$this->Dados['tipo_cli']}"."&tipo_prod={$this->Dados['tipo_prod']}"."&mesano={$this->Dados['mesano']}"); } } $this->Resultado = $listPsaude->getResultado(); //var_dump($this->Resultado); } public function listarCadastrar() { $listar = new \App\adms\Models\helper\AdmsRead(); $listar->fullRead("SELECT t.id id_tipo_cli, t.nome nome_tipo_cli from ps_tipo_cliente t ORDER BY t.id"); $registro['tipo_cli'] = $listar->getResultado(); $listar = new \App\adms\Models\helper\AdmsRead(); $listar->fullRead("SELECT t.id id_tipo_prod, t.nome nome_tipo_prod from ps_tipo_produto t ORDER BY t.id"); $registro['tipo_prod'] = $listar->getResultado(); $this->Resultado = ['tipo_cli' => $registro['tipo_cli'], 'tipo_prod' => $registro['tipo_prod']]; return $this->Resultado; } }