public function getModelConfigImposto($id){
        $sql = "SELECT 
		CONFIG_IMPOSTO_ID,
		NOME_TABELA,
		COALESCE(ISS,0) AS ISS,
		COALESCE(INSS,0) AS INSS,
		COALESCE(PIS,0) AS PIS,
		COALESCE(COFINS,0) AS COFINS,
		COALESCE(CSLL,0) AS CSLL,
		COALESCE(IRPJ,0) AS IRPJ,
		COALESCE(RETENCAO_FONTE,'N') AS RETENCAO_FONTE  
		FROM CONFIG_IMPOSTO  
		WHERE CONFIG_IMPOSTO.CONFIG_IMPOSTO_ID =".$id;
        $rs = parent::execute_query($sql);
        while($row = ibase_fetch_assoc($rs)){
            $this->CONFIG_IMPOSTO_ID = $row['CONFIG_IMPOSTO_ID'];
            $this->NOME_TABELA = $row['NOME_TABELA'];
            $this->ISS = $row['ISS'];
            $this->PIS = $row['PIS'];
            $this->INSS= $row['INSS'];
            $this->COFINS = $row['COFINS'];
            $this->CSll = $row['CSLL'];
            $this->IRPJ = $row['IRPJ'];
            $this->RENTENCAO_FONTE = $row['RETENCAO_FONTE'];
            $this->SYNC = $rs['SYNC'];
        }
        return  $this;
    }
    public function Limpa($EmpresaId) {

	$Sql = "SELECT * FROM REL_EMP_FUNCIONARIO_FUNCAO WHERE EMPRESA_ID = " . $EmpresaId;

	$Result = parent::execute_query($Sql);

	while ($Linha = parent::criaObjetoConsulta($Result)){
	    $VerificaRelFunc = "SELECT * FROM REALIZACAO_EXAME WHERE FUNCIONARIO_ID = " . $Linha->FUNCIONARIO_ID;
	    if (!parent::QuantidadeLinhasConsulta($VerificaRelFunc)) {
		$DeletaRel = "DELETE FROM REL_EMP_FUNCIONARIO_FUNCAO WHERE FUNCIONARIO_ID = $Linha->FUNCIONARIO_ID AND EMPRESA_ID = " . $EmpresaId;
		parent::execute_query($DeletaRel);
		$DeleteContato = "DELETE FROM CONTATO WHERE CONTATO_ID = " . $this->IdContato($Linha->FUNCIONARIO_ID);
		parent::execute_query($DeleteContato);
		$DeletaEndereco = "DELETE FROM ENDERECO WHERE ENDERECO_ID = " . $this->IdEndereco($Linha->FUNCIONARIO_ID);
		parent::execute_query($DeletaEndereco);
		$DeletaFuncionario = "DELETE FROM FUNCIONARIO WHERE FUNCIONARIO_ID = " . $Linha->FUNCIONARIO_ID;
		parent::execute_query($DeletaFuncionario);
	    } else {
		$VerificaRel = "SELECT * FROM REL_ESF_EXAME WHERE EMPRESA_ID = " . $Linha->EMPRESA_ID . " AND SETOR_ID =  $Linha->SETOR_ID" . "AND FUNCAO_ID = " . $Linha->FUNCAO_ID;

		$VerificaRisco = "SELECT * FROM REL_ESF_RISCO WHERE EMPRESA_ID = " . $Linha->EMPRESA_ID . " AND SETOR_ID =  $Linha->SETOR_ID" . "AND FUNCAO_ID = " . $Linha->FUNCAO_ID;

		$VerificaRealizacao = "SELECT * FROM REALIZACAO_EXAME WHERE FUNCAO_ID = " . $Linha->FUNCAO_ID . " AND SETOR_ID = " . $Linha->SETOR_ID;

		if ((!parent::QuantidadeLinhasConsulta($VerificaRel)) AND ( !parent::QuantidadeLinhasConsulta($VerificaRisco))AND ( !parent::QuantidadeLinhasConsulta($VerificaRealizacao))) {
		     $SqlDeletaFuncoesVazias = "DELETE FROM REL_EMPRESA_SETOR_FUNCAO WHERE FUNCAO_ID = " . $Linha->FUNCAO_ID . " AND SETOR_ID = " . $Linha->SETOR_ID . " AND EMPRESA_ID = $EmpresaId";
		    //echo "<br>" . $VerificaRel;
		    //echo "<br>" . $VerificaRisco;
	
		    parent::execute_query($SqlDeletaFuncoesVazias);
		}
	    }
	}
    }
    public function getTodos() {
	
	$sql = parent::execute_query("SELECT
					FILIAL_ID,
					FILIAL_PADRAO,
					NOME_FILIAL
					FROM FILIAL
					WHERE  FILIAL_PADRAO IS NOT NULL
					UNION
					SELECT
					FILIAL_ID,
					FILIAL_PADRAO,
					NOME_FILIAL
					FROM FILIAL
					WHERE  FILIAL_PADRAO IS NULL
					ORDER BY 2 DESC,  3");

	$ListaFilial = array();

	while ($linha = parent::criaObjetoConsulta($sql)){
	    $DadosFilial = new ModelFilial();
	    $DadosFilial->setCodFilial($linha->FILIAL_ID);
	    $DadosFilial->setNomeFilial($linha->NOME_FILIAL);
	    $DadosFilial->setFilialPadrao($linha->FILIAL_PADRAO);
	    array_push($ListaFilial, $DadosFilial);
	}
	return $ListaFilial;
    }
    public function getTodos($CodForma = false, $TipoForma = false) {

	$StringIn = !$CodForma ? "" : "AND F_FORMA_PAGAMENTO IN ($CodForma)";
	$StringInTipo = !$TipoForma ? "" : "AND F_TIPO_FORMA = '$TipoForma'";

	$sql = parent::execute_query("SELECT * FROM F_FORMA_PAGAMENTO WHERE (1=1) $StringIn  $StringInTipo ORDER BY FORMA_PAGAMENTO");

	$ListaFormas = array();

	while ($linha = parent::criaObjetoConsulta($sql)){
	    $dadosFormaPagamento = new ModelFormaPagamento();
	    $dadosFormaPagamento->setF_FORMA_PAGAMENTO_ID($linha->F_FORMA_PAGAMENTO_ID);
	    $dadosFormaPagamento->setFORMA_PAGAMENTO($linha->FORMA_PAGAMENTO);
	    $dadosFormaPagamento->setF_TIPO_FORMA($linha->F_TIPO_FORMA);
	    array_push($ListaFormas, $dadosFormaPagamento);
	}
	return $ListaFormas;
    }
    public function getTodos($tipo, $Cod = false) {

	$In = !$Cod ? "" : "AND GRUPO_CAIXA_ID = $Cod";

	$StrQuerye = "SELECT * FROM GRUPO_CAIXA WHERE (TIPO = 'AB' OR TIPO = '$tipo') AND (STATUS !=0 OR STATUS IS NULL) $In ORDER BY GRUPO";

	$sql = parent::execute_query($StrQuerye);

	$listaGrupoCaixa = array();

	while ($linha = parent::criaObjetoConsulta($sql)){
	    $dadosConta = new ModelGrupoCaixa();
	    $dadosConta->setId_grupo_caixa($linha->GRUPO_CAIXA_ID);
	    $dadosConta->setNome_grupo($linha->GRUPO);
	    $dadosConta->setValor_padrao($linha->VALOR_PADRAO);
	    array_push($listaGrupoCaixa, $dadosConta);
	}
	return $listaGrupoCaixa;
    }
    public function ListaPlanoContas($tipo, $Cod = false) {

	$In = !$Cod ? "" : "AND SUBCATEGORIA_ID = $Cod";


	$ListaPlanoContas = array();

	if ($sql = parent::execute_query("SELECT * FROM SUBCATEGORIA  WHERE (TIPO = 'AB' OR TIPO = '$tipo') AND (STATUS !=0 OR STATUS IS NULL) $In  ORDER BY SUBCATEGORIA")) {

	    while ($linha = parent::criaObjetoConsulta($sql)){
		$dadosConta = new ModelPlanoContas();
		$dadosConta->setCategoriaId($linha->SUBCATEGORIA_ID);
		$dadosConta->setCodigo($linha->CODIGO);
		$dadosConta->setSubCategoriaId($linha->SUBCATEGORIA_ID);
		$dadosConta->setSubCategoriaDescricao($linha->SUBCATEGORIA);

		array_push($ListaPlanoContas, $dadosConta);
	    }
	}
	return $ListaPlanoContas;
    }
Пример #7
0
    public function TermosAtestado() {

	$query = "SELECT
		    ITEN.ATESTADO_ITEM_ID,
		    ITEN.ATESTADO_ID,
		    ITEN.TERMO,
		    ITEN.ORDEM
		    FROM ATESTADO
		    INNER JOIN ATESTADO_ITEM ITEN ON  (ATESTADO.ATESTADO_ID = ITEN.ATESTADO_ID)
		    ORDER BY ITEN.ATESTADO_ID;";

	$result = parent::execute_query($query);

	while ($linha = parent::criaObjetoConsulta($result)){

	    $Cod = $linha->ATESTADO_ITEM_ID;
	    $TipoLaudo = $linha->ATESTADO_ID;
	    $Termo = $linha->TERMO;
	    $Ordem = $linha->ORDEM;

	   ECHO $sql = "INSERT INTO "
		    . "TIPO_LAUDO_ITEM "
		    . "("
		    . "TIPO_LAUDO_ITEM_ID, "
		    . "TIPO_LAUDO_ID, "
		    . "ORDEM, "
		    . "TERMO, "
		    . "SYNC"
		    . ") "
		    . "VALUES "
		    . "("
		    . "$Cod, "
		    . "$TipoLaudo, "
		    . "$Ordem, "
		    . "'$Termo', "
		    . "'N'"
		    . ");" .
		    "<br>";
	}
    }
    public function VerificaEmpersasAgrupamento($ListaLancamentos) {

	$ArrayEmpresas = Array();
	foreach ($ListaLancamentos as $contas){
	    if (!in_array($contas->getEMPRESA_ID(), $ArrayEmpresas)) {
		array_push($ArrayEmpresas, $contas->getEMPRESA_ID());
	    }
	}


	if (count($ArrayEmpresas) > 1) {
	    $StringIn = "";
	    for ($i = 0; $i < count($ArrayEmpresas); $i++){
		$StringIn .= $ArrayEmpresas[$i] . ",";
	    }
	    $StringIn = substr($StringIn, 0, -1);
	    $Sql = "SELECT DISTINCT EMP.GRUPO_EMPRESA_ID
					FROM EMPRESA EMP
					WHERE EMP.EMPRESA_ID IN ($StringIn)
					AND  EMP.GRUPO_EMPRESA_ID IS NOT NULL";
	    $TotalGrupos = parent::QuantidadeLinhasConsulta($Sql);

	    if ($TotalGrupos > 1 OR $TotalGrupos == 0) {
		$this->setMotivoErro("Para agrupar lançamentos de empresas distintas, todas empresas devem pertencer ao mesmo grupo");
		return false;
	    }
	}

	return true;
    }
Пример #9
0
    public function BuscaOperacoesID($IdLancamentos) {
	$sql = "SELECT * FROM F_DEPOSITO_SAQUE "
		. "INNER JOIN U"
		. "WHERE F_DEPOSITO_SAQUE_ID IN ($IdLancamentos)";
	if ($result = parent::execute_query($sql)) {
	    $ListaOperacoes = array();

	    while ($linha = parent::criaObjetoConsulta($result)){
		$dadosOperacoes = new ModelBanco();
		$dadosOperacoes->setVALOR_OPERACAO($linha->VALOR);
		$dadosOperacoes->setDATA_OPERACAO($linha->DATA_OPERACAO);
		$dadosOperacoes->setUSUARIO_OPERACAO($linha->CHAVE_USER);


		array_push($ListaEvolucaoConta, $dadosOperacoes);
	    }
	    return $ListaOperacoes;
	}
	return false;
    }
    public function ListaConfiguracaoFechamento() {

	$Sql = "SELECT
		DISTINCT
		CF.NOME_TABELA,
		CF.CONFIG_FECHAMENTO_ID
		FROM  EMPRESA EMP
		INNER JOIN F_FECHAMENTO_FATURA FF ON (FF.EMPRESA_ID = EMP.EMPRESA_ID)
		INNER JOIN CONFIG_FECHAMENTO CF ON (CF.CONFIG_FECHAMENTO_ID = EMP.CONFIG_FECHAMENTO_ID)";

	$LinhaConfiguracao = array();

	$Result = parent::execute_query($Sql);

	while ($linha = parent::criaObjetoConsulta($Result)){
	    $ModelPencendias = new ModelPendencias();
	    $ModelPencendias->setIDConfiguracaoFechamento($linha->CONFIG_FECHAMENTO_ID);
	    $ModelPencendias->setNomeConfiguracaoFechamento($linha->NOME_TABELA);
	    array_push($LinhaConfiguracao, $ModelPencendias);
	}
	return $LinhaConfiguracao;
    }
Пример #11
0
    public function DadosImpostoFromCR($Id) {
	$retorno = array();
	
	$Sql = "SELECT 
		IMP.F_IMPOSTO_ID,
		IMP.ISS,
		IMP.INSS,
		IMP.PIS,
		IMP.COFINS,
		IMP.CSLL,
		IMP.IRPJ,
		IMP.RENTENCAO_FONTE
		FROM F_LANCA_CR CR
		INNER JOIN F_LANCA_CR2 CR2 ON (CR2.F_LANCA_CR_ID = CR.F_LANCA_CR_ID)
		INNER JOIN  F_REL_F_LANCA_CR2_F_IMPOSTO RELIMP ON (RELIMP.F_LANCA_CR2_ID = CR2.F_LANCA_CR2_ID)
		INNER JOIN F_IMPOSTO IMP ON (IMP.F_IMPOSTO_ID = RELIMP.F_IMPOSTO_ID)
		WHERE CR.F_LANCA_CR_ID = $Id
		  AND CR2.ACAO_FATURAR = 'S'
		  AND CR2.ACAO_CANCELAR IS NULL";
	$rs = parent::execute_query($Sql);
	while ($rows = ibase_fetch_assoc($rs)){
	    array_push($retorno, $rows);
	}
	return $retorno;
    }
    /**
     * @return string
     */
    Public function ImpressaoComprovanteFaturamento() {

	$Dados = new ModellancaCrBd();

	$StatusLancamento = $Dados->RecuperaCampo("F_STATUS_FINANCEIRO_ID", "F_LANCA_CR", "F_LANCA_CR_ID", $this->getCodLancamento());

	/* if ($StatusLancamento != 2) {
	  $this->setMotivoErro("Lançamento não encontra-se faturado");
	  return false;
	  } */

	$ManipulaBanco = new ManipulaBanco();
	$AssinaturaImagem = "../../include/img/" . $ManipulaBanco->RecuperaCampo("ASSINATURA_RECIBO_IMAGEM", "PARAMETRO", 1, 1);
	$AssinaturaNome = $ManipulaBanco->RecuperaCampo("ASSINATURA_RECIBO_NOME", "PARAMETRO", 1, 1);


	$Dados = $InformacoesImpressao = $Dados->DadosLancamento($this->getCodLancamento(), false, false, 2)[0];

	$Mora = (float) $Dados->getVlrMora();
	$Multa = (float) $Dados->getVlrMulta();
	$VlrImposto = (float) $Dados->getVlrImposto();
	$ValorFatura = (float) $Dados->getValor();
	$ValorDesconto = (float) $Dados->getVlrDescontoFatura();
	$Encargos = number_format(($Mora + $Multa), 2);

	$modelImposto = new ModelImposto();

	$DadosImposto = $modelImposto->DadosImpostoFromCR($Dados->getConta_receber_id());

	$ISS = 0.00;
	$INSS = 0.00;
	$PIS = 0.00;
	$COFINS = 0.00;
	$CSLL = 0.00;
	$IRPJ = 0.00;
	$totalImposto = 0.00;
	$PISS = 0.00;
	$PINSS = 0.00;
	$PPIS = 0.00;
	$PCOFINS = 0.00;
	$PCSLL = 0.00;
	$PIRPJ = 0.00;

	$ValorDesconto = (float) !empty($ValorDesconto) ? $ValorDesconto : 0.00;

	$DadosImposto = $DadosImposto[0];
	//Calculo Imposto
	$Dados->getValor();
	$ValorAnterior = (float) (($ValorFatura + ($VlrImposto + $ValorDesconto) - ($Mora + $Multa)));
	$Outros = 0.00;
	$ISS = number_format(($DadosImposto['ISS'] * $ValorAnterior / 100), 2);
	$INSS = number_format(($DadosImposto['INSS'] * $ValorAnterior / 100), 2);
	$PIS = number_format(($DadosImposto['PIS'] * $ValorAnterior / 100), 2);
	$COFINS = number_format(($DadosImposto['COFINS'] * $ValorAnterior / 100), 2);
	$CSLL = number_format(($DadosImposto['CSLL'] * $ValorAnterior / 100), 2);
	$IRPJ = number_format(($DadosImposto['IRPJ'] * $ValorAnterior / 100), 2);
	$totalImposto = number_format(($ISS + $INSS + $PIS + $COFINS + $CSLL + $IRPJ), 2);
	$PISS = $DadosImposto['ISS'];
	$PINSS = $DadosImposto['INSS'];
	$PPIS = $DadosImposto['PIS'];
	$PCOFINS = $DadosImposto['COFINS'];
	$PCSLL = $DadosImposto['CSLL'];
	$PIRPJ = $DadosImposto['IRPJ'];

	if ($totalImposto == 0) {
	    $totalImposto = number_format($Dados->getVlrImposto(), 2);
	    $Outros = $Dados->getVlrImposto();
	}
	$Outros = number_format($Outros, 2);

	$VlrLiquido = (float) ($ValorAnterior - $totalImposto - $ValorDesconto + ($Mora + $Multa));

	$StrDescricao = "<br><br><br><b>RECEBI DE </b>" . $Dados->getRazao_social_cli() . " </b><br><br>"
		. "<b>A IMPORTÂNCIA DE </b> " . parent::escreverValorMoeda($Dados->getValor()) . "</b><br><br>"
		. "<b>REFERENTE A </b>" . $Dados->getCentroReceita() . "<br><br><br>"
		. "";
	$impostos = "
				<tr >
					<td width='33%' style='font-size: 08pt'>ISS</td>
					<td width='33%' align='center' style='font-size: 08pt'>" . $PISS . "%</td>
					<td width='33%' align='right' style='font-size: 08pt'>" . $ISS . "</td>
				</tr>
				<tr>
					<td width='33%' style='font-size: 08pt'>INSS</td>
					<td width='33%' style='font-size: 08pt' align='center'>" . $PINSS . "%</td>
					<td width='33%' style='font-size: 08pt' align='right'>$INSS</td>
				</tr>
				<tr>
					<td width='33%' style='font-size: 08pt'>PIS</td>
					<td width='33%' style='font-size: 08pt'align='center'>" . $PPIS . "%</td>
					<td width='33%' style='font-size: 08pt' align='right'>$PIS</td>
				</tr>
				<tr>
					<td width='33%' style='font-size: 08pt'>COFINS</td>
					<td width='33%' align='center' style='font-size: 08pt'>" . $PCOFINS . "%</td>
					<td width='33%' align='right' style='font-size: 08pt'>$COFINS</td>
				</tr>
				<tr>
					<td width='33%' style='font-size: 08pt'>CSLL</td>
					<td width='33%' style='font-size: 08pt' align='center' >" . $PCSLL . "%</td>
					<td width='33%' style='font-size: 08pt' align='right'>$CSLL</td>
				</tr>
				<tr>
					<td width='33%' style='font-size: 08pt'>IRPJ</td>
					<td width='33%' align='center' style='font-size: 08pt'>" . $PIRPJ . "%</td>
					<td width='33%' align='right' style='font-size: 08pt'>$IRPJ</td>
				</tr>			
				<tr>
					<td width='33%' style='font-size: 08pt'>Outros</td>
					<td width='33%' align='center' style='font-size: 08pt'>-</td>
					<td width='33%' align='right' style='font-size: 08pt'>$Outros</td>
				</tr>";

	$HtmlPrimeiraVia = '
    <head>
	<meta charset="utf-8">
	<title>COMPROVANTE DE FATURAMENTO</title>
	<style>
		td{
			font-size: 9pt;
		};
		
		
	</style>
    </head>
    <body>
	<table cellspacing="0" cellpadding="0"  width="657"  border=1 style="border-collapse: collapse; font-size:9pt">
	    <tr>
		<td align=center> 
			<img src="' . $this->getLogoClinica() . '" width="200" height="80">
		</td>
		<td colspan=2> 
			
			
			<div align="center">
			<span style="font-size:9pt;" align="center" >
			  ' . $this->getCabecalho() . '
			</span>
			</div>	
		</td>
	    <tr>
	    <tr>
		<td align="center" bgcolor="#B7B6B6" colspan=3 style="font-size:9pt;">COMPROVANTE DE FATURAMENTO  - 1º VIA - VALOR(R$) ' . number_format($Dados->getValor(), 2) . '</td>
	    <tr>

	   
	    </tr>
	    <tr>
		<td colspan=3 align="left" style="font-size:9pt">
		<div style="float: left; width: 30%;margin-bottom: 10px;margin-top: 10px">

			<table  width="10%" style="border-style: ridge;border-color: #080808;border-width: 1px">
				<tbody>
					<tr>
						<td colspan="2" bgcolor="#B7B6B6"><b>Valor Bruto</b></td>
						<td colspan="1" bgcolor="#B7B6B6">R$' . number_format($ValorAnterior, 2) . '</td>
					</tr>
					<tr>
						<td><b>Imposto</b></td>
						<td><b>%</b></td>
						<td align="right"><b>Valor</b></td>
					</tr>
					' . $impostos . '
					<tr>
						<td colspan="2" bgcolor="#ffb6c1">Impostos</td>
						<td colspan="1" align="right" bgcolor="#ffb6c1">R$ ' . number_format($totalImposto, 2) . '</td>
					</tr>
					<tr>
						<td colspan="2" bgcolor="#f5f5dc"><b>Decontos</b></td>
						<td colspan="1" align="right" bgcolor="#f5f5dc">R$ ' . number_format($ValorDesconto, 2) . '</td>
					</tr>
					<tr>
						<td colspan="2" bgcolor="#F08080"><b>Encargos</b></td>
						<td colspan="1" align="right" bgcolor="#F08080">R$ ' . $Encargos . '</td>
					</tr>
					<tr>
						<td colspan="2" bgcolor="#7fffd4"><b>Vlr líquido </b></td>
						<td colspan="1" bgcolor="#7fffd4" align="right">R$' . number_format($VlrLiquido, 2) . '</td>
					</tr>
				</tbody>
			</table>
		</div>
		<div style="float: right; width: 70%;">
			' . $StrDescricao . '
		</div>
		</td>
	    </tr>	
	       <tr style="height:27.25pt" >
		<td colspan=1 align=center>	
			<strong><span style="font-size:08pt; ">CIDADE</span></strong>
		    <p style="margin-bottom:0pt; line-height:normal;">
		
			<span style="font-size:08pt">' . $this->getCidadeClinica() . ' / ' . $this->getUfClinica() . '-' . date('d/m/Y') . '</span>
		    </p>
		</td>
		<td colspan=2 align=center>
			<img src="' . $AssinaturaImagem . '" width="140" height="40">
		    <hr align="center" width="350" style="line-height:1">
		    <p style="line-height:0" align="center">  ' . $AssinaturaNome . '</p>
		</td>
	    </tr>
	</table>
	<div align=center  style="font-size:09pt";>
	</div>
    </body>';

	$HtmlSegundaVia = '

    <head>
	<meta charset="utf-8">
	<title>COMPROVANTE DE FATURAMENTO</title>
    </head>
    <body>
	<table cellspacing="0" cellpadding="0"  width="657"  border=1 style="border-collapse: collapse; font-size:10pt">
	    <tr>
		<td align=center> 
			<img src="' . $this->getLogoClinica() . '" width="200" height="80">
		</td>
		<td colspan=2> 
			
			
			<div align="center">
			<span style="font-size:9pt;" align="center" >
			   ' . $this->getCabecalho() . '
			</span>
			</div>	
		</td>
	    <tr>
	    <tr>
		<td align="center" bgcolor="#B7B6B6" colspan=3 style="font-size:9pt;">COMPROVANTE DE FATURAMENTO - 2º VIA  VALOR(R$) ' . number_format($Dados->getValor(), 2) . '</td>
	    <tr>
	   
	    </tr>
	    <tr>
		<td colspan=2 align="left" style="font-size:9pt">
		<div style="float: left; width: 30%;margin-bottom: 10px;margin-top: 10px">
			<table  width="10%" style="border-style: ridge;border-color: #080808;border-width: 1px">
				<tbody>
					<tr>
						<td colspan="2" bgcolor="#B7B6B6"><b>Valor Bruto</b></td>
						<td colspan="1" bgcolor="#B7B6B6">R$' . number_format($ValorAnterior, 2) . '</td>
					</tr>
					<tr>
						<td><b>Imposto</b></td>
						<td><b>%</b></td>
						<td align="right"><b>Valor</b></td>
					</tr>
					' . $impostos . '
					<tr>
						<td colspan="2" bgcolor="#ffb6c1">Impostos</td>
						<td colspan="1" align="right" bgcolor="#ffb6c1">R$ ' . number_format($totalImposto, 2) . '</td>
					</tr>
					<tr>
						<td colspan="2" bgcolor="#f5f5dc"><b>Decontos</b></td>
						<td colspan="1" align="right" bgcolor="#f5f5dc">R$ ' . number_format($ValorDesconto, 2) . '</td>
					</tr>
					
					<tr>
						<td colspan="2" bgcolor="#F08080"><b>Encargos</b></td>
						<td colspan="1" align="right" bgcolor="#F08080">R$ ' . $Encargos . '</td>
					</tr>
					<tr>
						<td colspan="2" bgcolor="#7fffd4"><b>Vlr líquido </b></td>
						<td colspan="1" bgcolor="#7fffd4" align="right">R$' . number_format($VlrLiquido, 2) . '</td>
					</tr>
				</tbody>
			</table>
		</div>
		<div style="float: right; width: 70%;">
			' . $StrDescricao . '
		</div>
		</td>
	    </tr>
	       <tr style="height:27.25pt" >
		<td colspan=1 align=center>	
			<strong><span style="font-size:08pt; ">CIDADE</span></strong>
		    <p style="margin-bottom:0pt; line-height:normal;">
		
			<span style="font-size:08pt">' . $this->getCidadeClinica() . ' / ' . $this->getUfClinica() . '-' . date('d/m/Y') . '</span>
		    </p>
		</td>
		<td colspan=2 align=center>
			<img src="' . $AssinaturaImagem . '" width="140" height="40">
		    <hr align="center" width="350" style="line-height:1">
		    <p style="line-height:0" align="center">  ' . $AssinaturaNome . '</p>
		</td>
	    </tr>
	</table>
	<div align=center  style="font-size:09pt";>
	</div>
    </body>';



	$Html = $HtmlPrimeiraVia . "<br>--------------------------------------------------------------------------------------------------------------------------<br>" . $HtmlSegundaVia;

	$this->setHtmlRecibo($Html);
	return $Html;
    }
      public function InformacoesRecebimento($IdCr) {

	$Sql = "SELECT
		EMP.EMPRESA_ID,
		CR.F_LANCA_CR_ID,			
		F_LANCA_CR2.VALOR,	
		RAZAO_SOCIAL,		
		DATA_VENCIMENTO,				
		NUM_PARCELA,
		COD_PARCELAMENTO_PAI,
		F_LANCA_CR2_ID,
		(SELECT COUNT(COD_PARCELAMENTO) FROM F_LANCA_CR WHERE COD_PARCELAMENTO = CR.COD_PARCELAMENTO) AS TOTAL_PARCELAS,
		BANCO.BANCO_ID AS COD_CC, 
		BANCO.VALOR_MULTA,
		BANCO.VALOR_JURO,
		NUMERO_NF
		FROM  F_LANCA_CR CR
		INNER JOIN F_LANCA_CR2  ON (F_LANCA_CR2.F_LANCA_CR2_ID = (SELECT MAX(CR2.F_LANCA_CR2_ID) FROM F_LANCA_CR2 CR2 WHERE CR2.F_LANCA_CR_ID = CR.F_LANCA_CR_ID))
		LEFT JOIN EMPRESA  EMP ON (CR.EMPRESA_ID = EMP.EMPRESA_ID)
		INNER JOIN BANCO ON (CR.BANCO_ID = BANCO.BANCO_ID)
		WHERE CR.F_LANCA_CR_ID = $IdCr";

	$lista = array();

	$Result = parent::execute_query($Sql);

	while ($linha = parent::criaObjetoConsulta($Result)){
	    $contaReceber = new ModellancaCrBd();
	    $contaReceber->setId_cliente($linha->EMPRESA_ID);
	    $contaReceber->setConta_receber_id($linha->F_LANCA_CR_ID);
	    $contaReceber->setValor($linha->VALOR);
	    $contaReceber->setRazao_social_cli($linha->RAZAO_SOCIAL);
	    $contaReceber->setData_vencimento($linha->DATA_VENCIMENTO);
	    $contaReceber->setCodFilho($linha->F_LANCA_CR2_ID);
	    $contaReceber->setCodParcela($linha->NUM_PARCELA);
	    $contaReceber->setTotalParcelas($linha->TOTAL_PARCELAS);
	    $contaReceber->setVlrMora($linha->VALOR_JURO);
	    $contaReceber->setVlrMulta($linha->VALOR_MULTA);
	    $contaReceber->setCodContaCorrente($linha->COD_CC);
	    $contaReceber->setNumeroNF($linha->NUMERO_NF);

	    array_push($lista, $contaReceber);
	}
	return $lista;
    }
    private function GerenciaTransacaoOperacao() {

	$Cfiltro = new ModelFiltro();

	//Grava o filtro anterior
	$Cfiltro->GravaFiltrosUsuario($_SESSION["id_usuario"], "FILTRO_CR", $this->getSqlFiltroAnterior(), $this->getLabelAnterior(), $this->getTransacao());

	if (!$this->getStatusOperacao()) {
	    parent::gravaTrasacao($this->getTransacao());
	    return true;
	}

	parent::rollbackTransacao($this->getTransacao());
	return false;
    }
Пример #15
0
    public function BaixaCr() {
	$CR = new ModellancaCrBd();
	$Data = new Data();
	$String = new CString();

	$sql = "SELECT * FROM CONTA_RECEBER WHERE VALOR IS NOT NULL AND DT_VENCIMENTO IS NOT NULL";

	if ($result = parent::execute_query($sql)) {

	    $CR = new ModellancaCrBd();
	    $Data = new Data();
	    $String = new CString();

	    while ($linha = parent::criaObjetoConsulta($result)){

		$linha->CONTA_RECEBER_ID;
		$linha->GRUPO_ID;
		$linha->NOME_CONTA;
		$linha->EMPRESA_ID;
		$linha->TIPO_DOCUMENTO;
		$linha->NUMERO_DOCUMENTO;
		$linha->DT_VENCIMENTO;
		$linha->VALOR;
		$linha->REPLICAR_MESES;
		$linha->LANCAMENTO_AUTOMATICO;
		$linha->STATUS;
		$linha->OBSERVACAO;
		$linha->DATA_INCLUSAO;
		$linha->DESCONTO;
		$linha->ACRESCIMO;
		$linha->NUMERO_DOCUMENTO_RECEBIMENTO;
		$linha->OBSERVACAO_RECEBIMENTO;
		$linha->VALOR_RECEBIDO;
		$linha->ORIGEM_CONTA_RECEBER_ID;
		$linha->SYNC;
		$linha->CONTA_BAIXA;
		$linha->DT_RECEBIMENTO;
		$linha->FORMA_PAGAMENTO;
		$linha->NUMERO_FATURA;
		$linha->FATURADO;
		$linha->PAGO;
		$linha->BANCO_ID;
		$linha->FILIAL_ID;
		$linha->CENTRO_CUSTO_ID;
		$linha->NUMERO_PARCELA;
		$linha->UCIDUSER;
		$linha->UCIDUSER_BAIXA;
		$linha->DATA_BAIXA;

		$linha->CONTA_RECEBER_ID;

		if ((trim($linha->PAGO)) == "S") {
		    $id_cr = parent::RecuperaCampo("F_LANCA_CR_ID", "F_LANCA_CR", "ID_INTEGRACAO", $linha->CONTA_RECEBER_ID);

		    if ($CR->EfetuaRecebimento(2, $id_cr, 0.00, $linha->VALOR_RECEBIDO, 0.00, $linha->UCIDUSER_BAIXA, $linha->DT_RECEBIMENTO, $linha->OBSERVACAO_RECEBIMENTO, $linha->DT_VENCIMENTO, false, false, false)) {
			break;
			return false;
		    }
		}
	    }
	}
    }
    private function RealizaInclusaoCp() {

	$Data = new Data();
	$this->setInsereDespesaCp(false);

	if ($this->getUltimaDataLancamento()) {
	    $this->setDiasUltimoLancamento($Data->DiasEntreDatas($this->getUltimaDataLancamento(), date('Y-m-d')));
	} else {
	    $this->setDiasUltimoLancamento(-1);
	}

	$ModelCp = new ModelLancaCpBd();

	$String = new CString();

	$Valor = Array();
	array_push($Valor, 'R$ ' . str_replace('.', ",", $this->getValor()));

	$DataVencimento = Array();
	array_push($DataVencimento, $Data->convertDataBrasileira($this->DataProximoVencimento()));
	if ($this->getInsereDespesaCp()) {
	    if ($ModelCp->GravaContasPagar('', $this->getFornecedorId(), $_SESSION["id_usuario"], date('Y-m-d'), $DataVencimento, $Valor, $this->getDescricao(), $this->getBancoId(), 1, parent::RecuperaCampo("FILIAL_ID", "FILIAL", "FILIAL_PADRAO", "'S'"), $this->getSubCategoriaId(), $this->getGrupoCaixaId(), $String, $this->getFormaPagamentoId(), 'NULL', 'NULL', $this->getDespesaFixaId())) {
		
	    }
	}
	$this->setUltimaDataLancamento(null);
    }
    public function VerificaCodigoItemOit($IdLaudo) {

	$MyParametro = $_SESSION["MyParametroIdUsuario"];

	$Sql = "SELECT LAUDO_ITEM_ID
		FROM laudo_item
		INNER JOIN tipo_laudo ON (laudo_item.TIPO_LAUDO_ID = tipo_laudo.TIPO_LAUDO_ID)
		WHERE LAUDO_ID = $IdLaudo
		AND laudo_item.MY_PARAMETRO_ID = $MyParametro
		AND tipo_laudo.MY_PARAMETRO_ID = $MyParametro
		AND tipo_laudo = 'RXOIT'";

	$Query = parent::query($Sql);

	if ($Query->rowCount()) {
	    $linha = $Query->fetchObject();
	    return $linha->LAUDO_ITEM_ID;
	}
	return false;
    }
Пример #18
0
    public function VerificaPercentualImpostoFatura($CodEmp) {

	//Verifica se a tabela tem valor de imposto
	$sql = "SELECT E.CONFIG_IMPOSTO_ID FROM EMPRESA E WHERE E.EMPRESA_ID = $CodEmp";
	$result = parent::execute_query($sql);
	$linha = parent::criaObjetoConsulta($result);

	if ($linha->CONFIG_IMPOSTO_ID >= 1) {

	    $CodTabelaImposto = $linha->CONFIG_IMPOSTO_ID;

	    //Verifica se a tabela retem imposto
	    if (trim(parent::RecuperaCampo("RETENCAO_FONTE", "CONFIG_IMPOSTO", "CONFIG_IMPOSTO_ID", $CodTabelaImposto)) == "S") {

		$SqlCalculaImpostoTotal = "SELECT SUM(COALESCE(ISS,0)+COALESCE(INSS,0)+COALESCE(PIS,0)+COALESCE(COFINS,0)+COALESCE(CSLL,0)+COALESCE(IRPJ,0)) AS TOTAL
					    FROM
					    CONFIG_IMPOSTO CI
					    WHERE CI.CONFIG_IMPOSTO_ID = $CodTabelaImposto";
		$ResultCalculaImpostoTotal = parent::execute_query($SqlCalculaImpostoTotal);
		$LinhaCalculaImpostoTotal = parent::criaObjetoConsulta($ResultCalculaImpostoTotal);

		return (float) $LinhaCalculaImpostoTotal->TOTAL;
	    }
	    return (float) 0.00;
	}
	return (float) 0.00;
    }
    public function ContasPagasMes($mes, $ano, $ultimaDia) {
	$sql = "SELECT SUM(F_LANCA_CP2.VALOR) AS CP
		FROM F_LANCA_CP CP
		INNER JOIN F_LANCA_CP2  ON (F_LANCA_CP2.F_LANCA_CP2_ID = (SELECT MAX(F_LANCA_CP2.F_LANCA_CP2_ID) FROM F_LANCA_CP2 WHERE F_LANCA_CP2.F_LANCA_CP = CP.F_LANCA_CP_ID)) 
		WHERE F_LANCA_CP2.DATA_PAGAMENTO BETWEEN '$ano-$mes-01' AND '$ano-$mes-$ultimaDia' AND ACAO_BAIXAR = 'S' AND ACAO_CANCELAR_PAGAMENTO IS NULL";
	$result = parent::execute_query($sql);
	$linha = parent::criaObjetoConsulta($result);

	return $linha->CP;
    }
Пример #20
0
require_once("../cr/ModelPendencias.php");
require_once("../cr/ModellancaCrBd.php");
require_once("../../include/CData.php");
require_once("./CImpressao.php");
require_once ("../../include/header.php");
require_once '../../include/CString.php';

//Instancias
$data = new Data();

$CString = new CString();

$objImpressao = unserialize($_SESSION["Pendencias"]);

$Cbanco = new ManipulaBanco();

$ListaPendencia = $objImpressao->GetLista();
// $controlador->SomaValorFatura($pendencias->getCodFechamentoSigmo())
$CodFechamento = "";
?>  
<body onload="window.print();">
    <div class="container" align="center" style="width:700px;">
	<?php
	foreach ($ListaPendencia as $pendencias){
	    ?>
            <table border="1" class="tabela table-hover table-responsive">
		<?php
		if ($pendencias->getCodFechamentoSigmo() != $CodFechamento) {

Пример #21
0
    Public function AtualizaDadosRemessa($transacaoAtiva, $codigoSequencial, $CodConta, $NomeArquivo) {

	$data_atual = date("Y-m-d H:i:s");
	$id_usuario = $_SESSION["id_usuario"];
	//Insere os dados da remessa gerada
	$SequencialRemessa = parent::incrementaGenerator("GEN_F_GERACAO_REMESSA_ID");

	$sql_atualiza_dados_remessa = "
		INSERT INTO F_GERACAO_REMESSA 
		(
			F_GERACAO_REMESSA_ID,
			DATA_GERACAO,
			NOME_ARQUIVO, 
			CODIGO_REMESSA, 
			CHAVE_USER
		)
		VALUES 
		(
		 $SequencialRemessa,
		'$data_atual', "
		. "'$NomeArquivo', "
		. "'$codigoSequencial', "
		. "$id_usuario
		)";
	if (parent::execute_query_trans($transacaoAtiva, $sql_atualiza_dados_remessa)) {
	    if (parent::gravaTrasacao($transacaoAtiva)) {
		return TRUE;
	    } else {
		parent::rollbackTransacao($transacaoAtiva);
		return FALSE;
	    }
	}
    }
    public function ServicosEmpresa($CodEmpresa = false, $CodServico = false) {

	$CodEmpresa = !$CodEmpresa ? "" : "AND REL.EMPRESA_ID = $CodEmpresa";
	$CodServico = !$CodServico ? "" : "AND REL.SERVICO_ID = $CodServico";

	$SqlListaServicoEmpresa = "SELECT S.*,
				    REL.VALOR AS VALOR_EMPRESA,
				    E.RAZAO_SOCIAL,
				    E.STS_CONVENIO,
				    S.VALOR
				    FROM SERVICO S
				    INNER JOIN REL_SERVICO_EMPRESA REL ON (REL.SERVICO_ID = S.SERVICO_ID)
				    INNER JOIN EMPRESA E ON (E.EMPRESA_ID = REL.EMPRESA_ID)
				    $CodEmpresa	
				    $CodServico "
		. "ORDER BY NOME";

	$sql = parent::execute_query($SqlListaServicoEmpresa);

	$ListaServicos = array();

	while ($linha = parent::criaObjetoConsulta($sql)){
	    $DadosServico = new ModelServicos();

	    $DadosServico->setSERVICO_ID($linha->SERVICO_ID);
	    $DadosServico->setGRUPO_CAIXA_ID($linha->GRUPO_CAIXA_ID);
	    $DadosServico->setSUBCATEGORIA_ID($linha->SUBCATEGORIA_ID);
	    $DadosServico->setNOME($linha->NOME);
	    $DadosServico->setVALOR($linha->VALOR_EMPRESA);
	    $DadosServico->setSTS_CONVENIO($linha->STS_CONVENIO);
	    $DadosServico->setRAZAO_SOCIAL($linha->RAZAO_SOCIAL);

	    array_push($ListaServicos, $DadosServico);
	}
	return $ListaServicos;
    }
Пример #23
0
    public function GravaFiltroRemessa($Filtro = "FILTRO_REMESSA") {
	if ($Filtro == "FILTRO_REMESSA") {
	    $bd = new ManipulaBanco();
	    $Datas = new Data();
	    $banco = !empty($_POST['banco']) ? " = " . $_POST['banco'] : 'IS NOT NULL';
	    $data_ini = !empty($_POST['data_ini_filtro']) ? $Datas->convertDataSql($_POST['data_ini_filtro']) : date('Y-m-d', strtotime("-15 days"));
	    $data_fim = !empty($_POST['data_fim_filtro']) ? $Datas->convertDataSql($_POST['data_fim_filtro']) : date('Y-m-d', strtotime("+30 days"));

	    $sql_filtro = "SELECT       CR.F_LANCA_CR_ID, 
					NOME_CONTA, VALOR, 
					EMP.EMPRESA_ID, 
					EMP.RAZAO_SOCIAL,
					EMP.NOME_FANTASIA, 
					EMP.CNPJ,  
					EMP.CPF,
					EMP.TIPO_PESSOA AS PF_PJ,
					COR_STATUS,
					STATUS.F_STATUS_FINANCEIRO_ID,
					STATUS.NOME_STATUS, 
					DATA_VENCIMENTO, 
					ACAO_FATURAR, 
					ACAO_EDITAR, 
					ACAO_CANCELAR, 
					F_LANCA_CR2_ID, 
					SUBSTRING(DATA_FATURAMENTO FROM 1 FOR 10) AS DATA_FATURAMENTO,
					BANCO.NOME,
					PARAMETRO.RAZAO_SOCIAL AS RAZAO_SOCIAL_HEADER,
					PARAMETRO.CNPJ AS CNPJ_CEDENTE,
					BANCO.BANCO_ID AS COD_CC,
					BANCO.CODIGO_CEDENTE_BANCO AS CODIGO_CEDENTE_HEADER,
					BANCO.NUMERO_SEQUENCIAL AS SEQUENCIAL,
					BANCO.CARTEIRA_COBRANCA AS CARTEIRA_HEADER,
					BANCO.AGENCIA AS AGENCIA,
					BANCO.DIGITO_AGENCIA AS DIG_AGENCIA_HEADER,
					BANCO.CONTA AS CONTA_HEADER,
					BANCO.DIGITO_CONTA DIG_CONTA_HEADER,
					BANCO.VALOR_MULTA MULTA_CONTA,
					BANCO.VALOR_JURO MORA_CONTA,
					BANCO.RESP_EMISSAO_BOLETO,
					BANCO.DIAS_PROTESTO,
					BANCO.CONVENIO,
					ENDE.ENDERECO AS END_SACADO,
					ENDE.NUMERO AS NUMERO_END_SACADO,
					ENDE.BAIRRO AS BAIRRO_END_SACADO,
					ENDE.CEP AS CEP_SACADO,
					ENDE.CIDADE AS CIDADE_SACADO,
					UF.SIGLA AS UF,
					CASE
					WHEN F_LANCA_CR2.ACAO_CANCELAR = " . '"' . 'S' . '"' . "
					THEN " . '"' . 'CANCELAMENTO' . '"' . "
					ELSE " . '"' . 'REGISTRO' . '"' . "
					END AS NOME_OCORRENCIA,
					CASE
					WHEN F_LANCA_CR2.ACAO_CANCELAR = " . '"' . 'S' . '"' . "
					THEN 02
					ELSE 01
					END AS CODIGO_OCORRENCIA
					FROM  F_LANCA_CR CR 
					INNER JOIN F_LANCA_CR2  ON (F_LANCA_CR2.F_LANCA_CR2_ID = (SELECT MAX(F_LANCA_CR2.F_LANCA_CR2_ID) FROM F_LANCA_CR2 WHERE F_LANCA_CR2.F_LANCA_CR_ID = CR.F_LANCA_CR_ID))
					INNER JOIN F_STATUS_FINANCEIRO STATUS ON (STATUS.F_STATUS_FINANCEIRO_ID = CR.F_STATUS_FINANCEIRO_ID)
					INNER JOIN EMPRESA  EMP ON (CR.EMPRESA_ID = EMP.EMPRESA_ID)
					INNER JOIN GRUPO_CAIXA GRUPO ON (GRUPO.GRUPO_CAIXA_ID = CR.GRUPO_CAIXA)
					INNER JOIN BANCO ON (CR.BANCO_ID = BANCO.BANCO_ID)
					INNER JOIN PARAMETRO ON(PARAMETRO.PARAMETRO_ID = 1)
					INNER JOIN ENDERECO ENDE ON (EMP.ENDERECO_ID = ENDE.ENDERECO_ID)
					INNER JOIN ESTADO UF ON (UF.ESTADO_ID = ENDE.ESTADO_ID)
					INNER JOIN F_FORMA_PAGAMENTO FP ON (FP.F_FORMA_PAGAMENTO_ID = CR.F_FORMA_PAGAMENTO_ID)
					WHERE BANCO.BANCO_ID $banco
					AND REMESSA_GERADA IS NULL
					AND FP.F_TIPO_FORMA = " . '"' . 'BO' . '"' . "
					AND (DATA_FATURAMENTO BETWEEN " . '"' . $data_ini . ' 00:00:01"' . ' AND ' . '"' . $data_fim . ' 23:59:59"' . ")
					AND (DATA_VENCIMENTO >= " . '"' . date('Y-m-d') . '"' . ")    
					AND CR.F_STATUS_FINANCEIRO_ID = 2";

	    //Gera a Label de exibição dos filtros
	    $BancoLabel = !empty($_POST['banco']) ? $bd->RecuperaCampo("NOME", "BANCO", "BANCO_ID", $_POST['banco']) : 'Todas os bancos';

	    $detalheFiltro = " Exibindo Período de "
		    . $Datas->convertDataBrasileira($data_ini) . " até " . $Datas->convertDataBrasileira($data_fim) .
		    " Banco = $BancoLabel Forma Pagamento = BOLETO - Somente títulos não vencidos ";


	    $gravaFiltro = (new ModelFiltro())->GravaFiltrosUsuario($_SESSION["id_usuario"], $Filtro, $sql_filtro, $detalheFiltro);

	    return $gravaFiltro;
	}
	return false;
    }
        public function DadosPagamento($idCp) {
	$sql = "SELECT
		CP.F_LANCA_CP_ID,
		F_LANCA_CP2_ID,
		NOME_FANTASIA,
		RAZAO_SOCIAL,
		CP.FORNECEDOR_ID,
		CP.RESUMO,
		STATUS.NOME_STATUS,
		F_LANCA_CP2.VALOR,
		CP.F_STATUS_FINANCEIRO_CP_ID,
		VALOR,
		F_LANCA_CP2.DATA_VENCIMENTO,
		COR_STATUS,
		NOME_STATUS,
		CP.FORNECEDOR_ID,
		SUBCATEGORIA_ID,
		COD_FILIAL_ID,
		GRUPO_CAIXA,
		BANCO_ID,
		F_FORMA_PAGAMENTO_ID,
		(SELECT COUNT(COD_PARCELAMENTO) FROM F_LANCA_CP WHERE COD_PARCELAMENTO = CP.COD_PARCELAMENTO) AS TOTAL_PARCELAS,
		F_LANCA_CP2.NUM_PARCELA,
		NUMERO_NF,
		NUM_CHEQUE,
		GRUPO.GRUPO AS NOME_GRUPO
		FROM F_LANCA_CP CP
		INNER JOIN F_LANCA_CP2  ON (F_LANCA_CP2.F_LANCA_CP2_ID = (SELECT MAX(F_LANCA_CP2.F_LANCA_CP2_ID) FROM F_LANCA_CP2 WHERE F_LANCA_CP2.F_LANCA_CP = CP.F_LANCA_CP_ID))
		INNER JOIN F_STATUS_FINANCEIRO_CP  STATUS ON (STATUS.F_STATUS_FINANCEIRO_CP_ID = CP.F_STATUS_FINANCEIRO_CP_ID)
		LEFT JOIN FORNECEDOR  ON (FORNECEDOR.FORNECEDOR_ID = CP.FORNECEDOR_ID)
		LEFT JOIN GRUPO_CAIXA GRUPO ON (GRUPO.GRUPO_CAIXA_ID = CP.GRUPO_CAIXA)
		WHERE CP.F_LANCA_CP_ID = $idCp";

	$DadosConta = null;
	$result = parent::execute_query($sql);

	if ($result) {
	    $linha = parent::criaObjetoConsulta($result);
	    $DadosConta = new ModelLancaCpBd();
	    $DadosConta->setIdCp($linha->F_LANCA_CP_ID);
	    $DadosConta->setIdNomeFantasiForConta($linha->NOME_FANTASIA);
	    $DadosConta->setRazaoSocialFor($linha->RAZAO_SOCIAL);
	    $DadosConta->setCodFornecedor($linha->FORNECEDOR_ID);
	    $DadosConta->setValor($linha->VALOR);
	    $DadosConta->setResumo($linha->RESUMO);
	    $DadosConta->setDataVencimentoConta($linha->DATA_VENCIMENTO);
	    $DadosConta->setCodStatusConta($linha->F_STATUS_FINANCEIRO_CP_ID);
	    $DadosConta->setCorStatus($linha->COR_STATUS);
	    $DadosConta->setNomeStatusConta($linha->NOME_STATUS);
	    $DadosConta->setCodFilho($linha->F_LANCA_CP2_ID);
	    $DadosConta->setCodFornecedor($linha->FORNECEDOR_ID);
	    $DadosConta->setIdContaCorrente($linha->BANCO_ID);
	    $DadosConta->setCodFilial($linha->COD_FILIAL_ID);
	    $DadosConta->setCodCategoria($linha->SUBCATEGORIA_ID);
	    $DadosConta->setCodCentroDespesa($linha->GRUPO_CAIXA);
	    $DadosConta->setNumParcela($linha->NUM_PARCELA);
	    $DadosConta->setTotalParcelas($linha->TOTAL_PARCELAS);
	    $DadosConta->setFormaPagamento($linha->F_FORMA_PAGAMENTO_ID);
	    $DadosConta->setNumeroNF($linha->NUMERO_NF);
	    $DadosConta->setNumCheque($linha->NUM_CHEQUE);
	    $DadosConta->setCentroDespesa($linha->NOME_GRUPO);
	}
	return $DadosConta;
    }
Пример #25
0
    public function DadosBoleto($codBoleto) {

	$sql = "SELECT CLI.RAZAO_SOCIAL AS RAZAO_SOCIAL_SACADO,
		CASE
		WHEN CLI.CPF IS NULL AND CLI.CNPJ IS NULL
		THEN '999.999.999-99'
		WHEN CLI.CNPJ IS NULL
		THEN CLI.CPF
		WHEN CLI.CPF IS NULL
		THEN CLI.CNPJ
		END  AS DOCUMENTO_SACADO,
		ENDE.ENDERECO AS ENDERECO_SACADO,
		ENDE.CEP AS CEP_SACADO,
		UF.ESTADO AS UF_SACADO,
		UF.SIGLA AS SIGLA_UF_SACADO,
		CEDENTE.RAZAO_SOCIAL AS RAZAO_SOCIAL_CEDENTE,
		CEDENTE.CNPJ AS CNPJ_CEDENTE,
		CEDENTE.ENDERECO AS ENDERECO_CEDENTE,
		CEDENTE.CEP AS CEP_CEDENTE,
		UF_CEDENTE.ESTADO AS UF_CEDENTE,
		UF_CEDENTE.SIGLA AS SIGLA_UF_CEDENTE ,
		F_LANCA_CR2.DATA_VENCIMENTO,
		F_LANCA_CR2.VALOR, 
		F_LANCA_CR2.F_LANCA_CR2_ID,
		CC.AGENCIA,
		CC.CARTEIRA_COBRANCA,
		CC.CONTA,
		CC.DIGITO_CONTA AS DIGITO_VERIFICADOR_CONTA,
		CC.DIGITO_AGENCIA AS DIGITO_VERIFICADOR_AGENCIA,
		CC.CONVENIO,
		F_LANCA_CR2.DESCRICAO_BOLETO,
		CC.INSTRUCAO_01,
		CC.INSTRUCAO_02,
		(SELECT LOGOMARCA FROM PARAMETRO) AS LOGO_CEDENTE,
		CAST((F_LANCA_CR2.VALOR * CC.VALOR_MULTA /100) AS NUMERIC(15,2)) AS VLR_MULTA,
		CAST((F_LANCA_CR2.VALOR * CC.VALOR_MULTA /100 / 30) AS NUMERIC(15,2)) AS VLR_MORA
		FROM
		F_LANCA_CR CR
		INNER JOIN F_LANCA_CR2  ON (F_LANCA_CR2.F_LANCA_CR2_ID = (SELECT MAX(F_LANCA_CR2.F_LANCA_CR2_ID) FROM F_LANCA_CR2 WHERE F_LANCA_CR2.F_LANCA_CR_ID = CR.F_LANCA_CR_ID))
		INNER JOIN FILIAL CEDENTE ON (CEDENTE.FILIAL_ID = CR.COD_FILIAL_ID)
		INNER JOIN EMPRESA CLI ON (CR.EMPRESA_ID = CLI.EMPRESA_ID)
		INNER JOIN ENDERECO ENDE ON (CLI.ENDERECO_ID = ENDE.ENDERECO_ID)
		INNER JOIN ESTADO UF ON (UF.ESTADO_ID = ENDE.ESTADO_ID)
		INNER JOIN ESTADO UF_CEDENTE ON (UF_CEDENTE.ESTADO_ID = CEDENTE.ESTADO_ID)
		INNER JOIN BANCO CC ON (CC.BANCO_ID = CR.BANCO_ID)
		WHERE CR.F_LANCA_CR_ID = $codBoleto";

	$result = parent::execute_query($sql);


	if ($linha = parent::criaObjetoConsulta($result)) {

	    $dadosBoleto = new ModelBoleto();


	    $dadosBoleto->setRAZAO_SOCIAL_SACADO($linha->RAZAO_SOCIAL_SACADO);
	    $dadosBoleto->setDOCUMENTO_SACADO($linha->DOCUMENTO_SACADO);
	    $dadosBoleto->setENDERECO_SACADO($linha->ENDERECO_SACADO);
	    $dadosBoleto->setCEP_SACADO($linha->CEP_SACADO);
	    $dadosBoleto->setUF_SACADO($linha->UF_SACADO);
	    $dadosBoleto->setSIGLA_UF_SACADO($linha->SIGLA_UF_SACADO);
	    $dadosBoleto->setRAZAO_SOCIAL_CEDENTE($linha->RAZAO_SOCIAL_CEDENTE);
	    $dadosBoleto->setCNPJ_CEDENTE($linha->CNPJ_CEDENTE);
	    $dadosBoleto->setENDERECO_CEDENTE($linha->ENDERECO_CEDENTE);
	    $dadosBoleto->setCEP_CEDENTE($linha->CEP_CEDENTE);
	    $dadosBoleto->setUF_CEDENTE($linha->UF_CEDENTE);
	    $dadosBoleto->setSIGLA_UF_CEDENTE($linha->SIGLA_UF_CEDENTE);
	    $dadosBoleto->setDATA_VENCIMENTO($linha->DATA_VENCIMENTO);
	    $dadosBoleto->setVALOR($linha->VALOR);
	    $dadosBoleto->setF_LANCA_CR_ID2($linha->F_LANCA_CR2_ID);
	    $dadosBoleto->setAGENCIA($linha->AGENCIA);
	    $dadosBoleto->setCARTEIRA_COBRANCA($linha->CARTEIRA_COBRANCA);
	    $dadosBoleto->setCONTA($linha->CONTA);
	    $dadosBoleto->setDIGITO_VERIFICADOR_CONTA($linha->DIGITO_VERIFICADOR_CONTA);
	    $dadosBoleto->setDIGITO_VERIFICADOR_AGENCIA($linha->DIGITO_VERIFICADOR_AGENCIA);
	    $dadosBoleto->setDESCRICAO_BOLETO($linha->DESCRICAO_BOLETO);
	    $dadosBoleto->setINSTRUCAO_1($linha->INSTRUCAO_01);
	    $dadosBoleto->setLOGO_CEDENTE($linha->LOGO_CEDENTE);
	    $dadosBoleto->setVALOR_CALCULADO_MORA($linha->VLR_MORA);
	    $dadosBoleto->setVALOR_CALCULADO_MULTA($linha->VLR_MULTA);
	    $dadosBoleto->setCONVENIO($linha->CONVENIO);

	    return $dadosBoleto;
	} else {
	    return FALSE;
	}
    }
Пример #26
0
    private function NomeArquivo() {

	$String = new CString();

	$Banco = new ManipulaBanco();

	$TipoLaudo = $Banco->RecuperaCampo("TIPO_LAUDO", "tipo_laudo", "TIPO_LAUDO_ID", $this->getTipoLaudo());

	if ($TipoLaudo === "RXOIT")
	    $Ext = ".DOCX";
	else
	    $Ext = ".PDF";

	$NomeArquivo = $String->removerAcento($this->getFuncionario()) . "_" . $String->removerAcento($this->getNomeLaudo()) . "_" . $this->getMyLaudoItemId() . "$Ext";

	$this->setNomeLaudoGerado($NomeArquivo);
    }
    public function AtualizaPermissoesUsuario($arrayValores, $Usuario) {
	$trans = parent:: criaTransacao();
	$String = new CString();
	$Usuario = $String->descriptografa($Usuario);
	$erro = false;

	$sql = "DELETE FROM F_REL_USUARIO_ACESSO_MENU WHERE CHAVE_USER = $Usuario";
	if (parent::execute_query_trans($trans, $sql)) {
	    for ($i = 0; $i < count($arrayValores); $i++){
		$sqlInsert = "INSERT INTO F_REL_USUARIO_ACESSO_MENU (CHAVE_USER, F_ACESSO_MENU_ID) VALUES ($Usuario," . $String->descriptografa($arrayValores[$i]) . ")";
		if (!parent::execute_query_trans($trans, $sqlInsert)) {
		    $erro = true;
		    break;
		}
	    }
	} else {
	    $erro = true;
	}
	if (!$erro) {
	    parent::gravaTrasacao($trans);
	    return true;
	} else {
	    parent::rollbackTransacao($trans);
	    return false;
	}
    }
    public function FornecedorContasPagar() {

	$sql = parent::execute_query("SELECT
					DISTINCT
					FORNECEDOR_ID,
					RAZAO_SOCIAL,
					CNPJ,
					NOME_FANTASIA
					FROM F_LANCA_CP CP
					INNER JOIN FORNECEDOR  ON (FORNECEDOR.FORNECEDOR_ID = CP.FORNECEDOR_ID)");
	$listaForCp = array();

	while ($linha = parent::criaObjetoConsulta($sql)){
	    $DadosFornecedor = new ModelFornecedor();
	    $DadosFornecedor->setIdFornecedor($linha->FORNECEDOR_ID);
	    $DadosFornecedor->setCnpjFor($linha->CNPJ);
	    $DadosFornecedor->setNomeFantasiaFor($linha->NOME_FANTASIA);
	    $DadosFornecedor->setRazaoSocialFor($linha->NOME_FANTASIA);

	    array_push($listaForCp, $DadosFornecedor);
	}
	return $listaForCp;
    }
    public function filtro($dados) {

	switch ($this->filtro){

	    case "CP_PagamentosCentroDespesa" :
		$dataInicial = empty($dados['data_ini_filtro']) ? $this->dataInicial : $this->data->convertDataSql($dados['data_ini_filtro']);
		$dataFinal = empty($dados['data_fim_filtro']) ? $this->dataFinal : $this->data->convertDataSql($dados['data_fim_filtro']);
		$empresa = $dados['pesquisaCliente'];
		$filial = $dados['filial'];
		if ($dados['dataPesquisa'] == 1) {
		    $where = "AND DATA_VENCIMENTO BETWEEN ''$dataInicial''  AND ''$dataFinal''";
		} else if ($dados['dataPesquisa'] == 2) {
		    $where = "AND DATA_PAGAMENTO BETWEEN ''$dataInicial''  AND ''$dataFinal''";
		} else {
		    $where = "AND DATA_VENCIMENTO BETWEEN ''$dataInicial''  AND ''$dataFinal''";
		}
		$centroDespesa = $dados['centro_despesa'];

		if (!empty($centroDespesa)) {
		    $where .= "AND GRUPO.grupo_caixa_id = $centroDespesa";
		}
		if (!empty($empresa)) {
		    $where .= "AND fornecedor.fornecedor_id = $empresa";
		}
		if (!empty($filial)) {
		    $where .= " AND F.FILIAL_ID = $filial";
		}


		$this->XML = "<report>
<attr value=\"table_type\">custom</attr>
<attr value=\"tables\"><attr value=\"0\">SQL_CR_RecebidoPeriodo</attr>
</attr>
<attr value=\"miscellaneous\"><attr value=\"type\">stepped</attr>
<attr value=\"print_friendly\">true</attr>
<attr value=\"lines_num\">30</attr>
</attr>
<attr value=\"settings\"><attr value=\"name\">CR_RecebidoPeriodo</attr>
<attr value=\"title\">Recebimentos no Periodo</attr>
<attr value=\"status\">public</attr>
</attr>
<attr value=\"owner\">admin</attr>
<attr value=\"tmp_active\"></attr>
<attr value=\"table_name\">SQL_CR_RecebidoPeriodo</attr>
<attr value=\"short_table_name\"></attr>
<attr value=\"sql\">
SELECT   
            F_LANCA_CP2_ID,
            F_LANCA_CP2.VALOR,
            (
                SELECT *
                FROM SP_CONVERTER_CARACTER(BANCO.NOME)
            )   AS NOME_CONTA,
            (
                SELECT *
                FROM SP_CONVERTER_CARACTER(SUBCATEGORIA.SUBCATEGORIA)
            )   AS SUBCATEGORIA,
            (
                SELECT *
                FROM SP_CONVERTER_CARACTER(GRUPO.GRUPO)
            )   AS CENTRO_DESPESA,
            (
                SELECT *
                FROM SP_CONVERTER_CARACTER(FORNECEDOR.RAZAO_SOCIAL)
            )   AS RAZAO_SOCIAL,
	    (
		SELECT *
		FROM SP_CONVERTER_CARACTER(F.NOME_FILIAL)
	    )   AS NOME_FILIAL,
    SUBSTRING(CP.RESUMO FROM 1 FOR 20)  AS RESUMO,
           DATA_VENCIMENTO,
           DATA_PAGAMENTO
            FROM   F_LANCA_CP CP
            INNER JOIN F_LANCA_CP2  ON (F_LANCA_CP2.F_LANCA_CP2_ID = (SELECT MAX
	    (F_LANCA_CP2.F_LANCA_CP2_ID) FROM F_LANCA_CP2 WHERE F_LANCA_CP2.F_LANCA_CP = CP.F_LANCA_CP_ID))
            INNER JOIN F_STATUS_FINANCEIRO_CP   STATUS ON (STATUS.F_STATUS_FINANCEIRO_CP_ID = CP.F_STATUS_FINANCEIRO_CP_ID)
            INNER JOIN BANCO ON (BANCO.BANCO_ID = CP.BANCO_ID)
            LEFT JOIN FORNECEDOR  ON (FORNECEDOR.FORNECEDOR_ID = CP.FORNECEDOR_ID)
            LEFT JOIN SUBCATEGORIA ON (CP.SUBCATEGORIA_ID = SUBCATEGORIA.SUBCATEGORIA_ID)
            LEFT JOIN GRUPO_CAIXA GRUPO ON (GRUPO.GRUPO_CAIXA_ID = CP.GRUPO_CAIXA)
	    INNER JOIN FILIAL F ON (F.FILIAL_ID = CP.COD_FILIAL_ID)
            WHERE  (CP.F_STATUS_FINANCEIRO_CP_ID = 2) $where
</attr>
<attr value=\"sql_preview\">SELECT   
            F_LANCA_CP2_ID,
            F_LANCA_CP2.VALOR,
            (
                SELECT *
                FROM SP_CONVERTER_CARACTER(BANCO.NOME)
            )   AS NOME_CONTA,
            (
                SELECT *
                FROM SP_CONVERTER_CARACTER(SUBCATEGORIA.SUBCATEGORIA)
            )   AS SUBCATEGORIA,
            (
                SELECT *
                FROM SP_CONVERTER_CARACTER(GRUPO.GRUPO)
            )   AS CENTRO_DESPESA,
            (
                SELECT *
                FROM SP_CONVERTER_CARACTER(FORNECEDOR.RAZAO_SOCIAL)
            )   AS RAZAO_SOCIAL,
    SUBSTRING(CP.RESUMO FROM 1 FOR 20)  AS RESUMO,
           DATA_VENCIMENTO,
           DATA_PAGAMENTO
            FROM   F_LANCA_CP CP
            INNER JOIN F_LANCA_CP2  ON (F_LANCA_CP2.F_LANCA_CP2_ID = (SELECT MAX
	    (F_LANCA_CP2.F_LANCA_CP2_ID) FROM F_LANCA_CP2 WHERE F_LANCA_CP2.F_LANCA_CP = CP.F_LANCA_CP_ID))
            INNER JOIN F_STATUS_FINANCEIRO_CP   STATUS ON (STATUS.F_STATUS_FINANCEIRO_CP_ID = CP.F_STATUS_FINANCEIRO_CP_ID)
            INNER JOIN BANCO ON (BANCO.BANCO_ID = CP.BANCO_ID)
            LEFT JOIN FORNECEDOR  ON (FORNECEDOR.FORNECEDOR_ID = CP.FORNECEDOR_ID)
            LEFT JOIN SUBCATEGORIA ON (CP.SUBCATEGORIA_ID = SUBCATEGORIA.SUBCATEGORIA_ID)
            LEFT JOIN GRUPO_CAIXA GRUPO ON (GRUPO.GRUPO_CAIXA_ID = CP.GRUPO_CAIXA)
            WHERE  (CP.F_STATUS_FINANCEIRO_CP_ID = 2) $where
		</attr>
<attr value=\"where\"></attr>
<attr value=\"order_by\"> 
ORDER BY &quot;RAZAO_SOCIAL&quot; ASC</attr>
<attr value=\"order_by_preview\"></attr>
<attr value=\"group_by\"></attr>
<attr value=\"group_fields\"><attr value=\"0\"><attr value=\"name\">Summary</attr>
<attr value=\"cross_table\">false</attr>
<attr value=\"sps\">true</attr>
<attr value=\"sds\">true</attr>
<attr value=\"sgs\">true</attr>
<attr value=\"sum_x\">true</attr>
<attr value=\"sum_y\">true</attr>
<attr value=\"sum_total\">true</attr>
</attr>
</attr>
<attr value=\"totals\"><attr value=\"SQL_CR_RecebidoPeriodo_COD\"><attr value=\"name\">COD</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Cod</attr>
<attr value=\"show\">true</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">false</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
<attr value=\"SQL_CR_RecebidoPeriodo_RAZAO_SOCIAL\"><attr value=\"name\">RAZAO_SOCIAL</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Razao Social</attr>
<attr value=\"show\">true</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">false</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
<attr value=\"SQL_CR_RecebidoPeriodo_RESUMO\"><attr value=\"name\">RESUMO</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Resumo</attr>
<attr value=\"show\">true</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">false</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
<attr value=\"SQL_CR_RecebidoPeriodo_VALOR\"><attr value=\"name\">VALOR</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Valor</attr>
<attr value=\"show\">true</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">true</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">true</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\">Currency</attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
<attr value=\"SQL_CR_RecebidoPeriodo_DATA_VENCIMENTO\"><attr value=\"name\">DATA_VENCIMENTO</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Dt. Vencimento</attr>
<attr value=\"show\">true</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">false</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
<attr value=\"SQL_CR_RecebidoPeriodo_DATA_RECEBIMENTO\"><attr value=\"name\">DATA_RECEBIMENTO</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Dt. Recebimento</attr>
<attr value=\"show\">true</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">false</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
<attr value=\"SQL_CR_RecebidoPeriodo_NOME_CONTA\"><attr value=\"name\">NOME_CONTA</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Conta</attr>
<attr value=\"show\">true</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">false</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
<attr value=\"SQL_CR_RecebidoPeriodo_SUBCATEGORIA\"><attr value=\"name\">SUBCATEGORIA</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">SUBCATEGORIA</attr>
<attr value=\"show\">false</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">false</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
<attr value=\"SQL_CR_RecebidoPeriodo_NOME_FILIAL\"><attr value=\"name\">NOME_FILIAL</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Filial</attr>
<attr value=\"show\">true</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">false</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
</attr>
<attr value=\"sort_fields\"><attr value=\"0\"><attr value=\"name\">RAZAO_SOCIAL</attr>
<attr value=\"desc\">false</attr>
</attr>
</attr>
<attr value=\"permissions\"><attr value=\"0\"><attr value=\"id\">Guest</attr>
<attr value=\"name\">Guest</attr>
<attr value=\"view\">false</attr>
<attr value=\"edit\">false</attr>
</attr>
<attr value=\"1\"><attr value=\"id\">admin</attr>
<attr value=\"name\">admin</attr>
<attr value=\"view\">false</attr>
<attr value=\"edit\">false</attr>
</attr>
</attr>
<attr value=\"style_editor\"><attr value=\"status\">success</attr>
</attr>
</report>";
		//var_dump("UPDATE \"webreports\" SET \"webreports\".\"rpt_content\" = '".$this->XML."'");

		parent::execute_query("UPDATE \"webreports\" SET \"webreports\".\"rpt_content\" = '" . $this->XML . "'WHERE \"webreports\".\"rpt_name\" ='CP_PagamentosCentroDespesa'");
		//parent::gravaQueryArquivo("UPDATE \"webreports\" SET \"webreports\".\"rpt_content\" = '".$this->XML."' \"WHERE \"webreports\".\"rpt_name\" =\"CP_PagamentosCentroDespesa\"");
		break;
	    case "CR_RecebidoPeriodo":
		$dataInicial = empty($dados['data_ini_filtro']) ? $this->dataInicial : $this->data->convertDataSql($dados['data_ini_filtro']);
		$dataFinal = empty($dados['data_fim_filtro']) ? $this->dataFinal : $this->data->convertDataSql($dados['data_fim_filtro']);
		$conta = $dados['contaCliente'];
		$filial = $dados['filial'];
		if ($dados['dataPesquisa'] == 1) {
		    $where = "AND DATA_VENCIMENTO BETWEEN ''$dataInicial''  AND ''$dataFinal''";
		} else if ($dados['dataPesquisa'] == 2) {
		    $where = " AND DATA_RECEBIMENTO BETWEEN ''$dataInicial''  AND ''$dataFinal''";
		} else {
		    $where = " AND DATA_VENCIMENTO BETWEEN ''$dataInicial''  AND ''$dataFinal''";
		}
		if (!empty($conta)) {
		    $where .= " AND CR.banco_id = $conta";
		}
		if (!empty($filial)) {
		    $where .= " AND F.FILIAL_ID = $filial";
		}


		$this->XML = "<report>
<attr value=\"table_type\">custom</attr>
<attr value=\"tables\"><attr value=\"0\">SQL_CR_RecebidoPeriodo</attr>
</attr>
<attr value=\"miscellaneous\"><attr value=\"type\">stepped</attr>
<attr value=\"print_friendly\">true</attr>
<attr value=\"lines_num\">30</attr>
</attr>
<attr value=\"settings\"><attr value=\"name\">CR_RecebidoPeriodo</attr>
<attr value=\"title\">Recebimentos no Periodo</attr>
<attr value=\"status\">public</attr>
</attr>
<attr value=\"owner\">admin</attr>
<attr value=\"tmp_active\"></attr>
<attr value=\"table_name\">SQL_CR_RecebidoPeriodo</attr>
<attr value=\"short_table_name\"></attr>
<attr value=\"sql\">SELECT   
        VALOR,
        COD_PARCELAMENTO AS COD,
        SUBSTRING(NOME_CONTA FROM 1 FOR 25)RESUMO,
        (
          SELECT *
           FROM SP_CONVERTER_CARACTER(SUBCATEGORIA.SUBCATEGORIA)
         ) AS SUBCATEGORIA,
         (
          SELECT *
            FROM SP_CONVERTER_CARACTER(EMP.RAZAO_SOCIAL)
         ) AS RAZAO_SOCIAL,
         (
          SELECT *
            FROM SP_CONVERTER_CARACTER(BANCO.NOME)
         ) AS NOME_CONTA,
         (
          SELECT *
          FROM SP_CONVERTER_CARACTER(F.NOME_FILIAL)
          )   AS NOME_FILIAL,
        DATA_VENCIMENTO,
       DATA_RECEBIMENTO
                FROM  F_LANCA_CR CR
                INNER JOIN F_LANCA_CR2  ON (F_LANCA_CR2.F_LANCA_CR2_ID = (SELECT MAX(CR2.F_LANCA_CR2_ID) FROM F_LANCA_CR2 CR2 WHERE CR2.F_LANCA_CR_ID = CR.F_LANCA_CR_ID))
                INNER JOIN F_STATUS_FINANCEIRO STATUS ON (STATUS.F_STATUS_FINANCEIRO_ID = CR.F_STATUS_FINANCEIRO_ID)
                LEFT JOIN EMPRESA  EMP ON (CR.EMPRESA_ID = EMP.EMPRESA_ID)
                LEFT JOIN SUBCATEGORIA ON (CR.SUBCATEGORIA_ID = SUBCATEGORIA.SUBCATEGORIA_ID)
                LEFT JOIN GRUPO_CAIXA GRUPO ON (GRUPO.GRUPO_CAIXA_ID = CR.GRUPO_CAIXA)
                INNER JOIN BANCO ON (CR.BANCO_ID = BANCO.BANCO_ID)
                INNER JOIN FILIAL F ON (F.FILIAL_ID = CR.COD_FILIAL_ID)
                WHERE CR.F_REF_LANCAMENTO_AGRUPADO IS NULL
                AND (STATUS.F_STATUS_FINANCEIRO_ID = 3) $where</attr>
<attr value=\"sql_preview\">SELECT   
        VALOR,
        COD_PARCELAMENTO AS COD,
        SUBSTRING(NOME_CONTA FROM 1 FOR 25)RESUMO,
        (
          SELECT *
           FROM SP_CONVERTER_CARACTER(SUBCATEGORIA.SUBCATEGORIA)
         ) AS SUBCATEGORIA,
         (
          SELECT *
            FROM SP_CONVERTER_CARACTER(EMP.RAZAO_SOCIAL)
         ) AS RAZAO_SOCIAL,
         (
          SELECT *
            FROM SP_CONVERTER_CARACTER(BANCO.NOME)
         ) AS NOME_CONTA,
         (
          SELECT *
          FROM SP_CONVERTER_CARACTER(F.NOME_FILIAL)
          )   AS NOME_FILIAL,
        DATA_VENCIMENTO,
       DATA_RECEBIMENTO
                FROM  F_LANCA_CR CR
                INNER JOIN F_LANCA_CR2  ON (F_LANCA_CR2.F_LANCA_CR2_ID = (SELECT MAX(CR2.F_LANCA_CR2_ID) FROM F_LANCA_CR2 CR2 WHERE CR2.F_LANCA_CR_ID = CR.F_LANCA_CR_ID))
                INNER JOIN F_STATUS_FINANCEIRO STATUS ON (STATUS.F_STATUS_FINANCEIRO_ID = CR.F_STATUS_FINANCEIRO_ID)
                LEFT JOIN EMPRESA  EMP ON (CR.EMPRESA_ID = EMP.EMPRESA_ID)
                LEFT JOIN SUBCATEGORIA ON (CR.SUBCATEGORIA_ID = SUBCATEGORIA.SUBCATEGORIA_ID)
                LEFT JOIN GRUPO_CAIXA GRUPO ON (GRUPO.GRUPO_CAIXA_ID = CR.GRUPO_CAIXA)
                INNER JOIN BANCO ON (CR.BANCO_ID = BANCO.BANCO_ID)
                INNER JOIN FILIAL F ON (F.FILIAL_ID = CR.COD_FILIAL_ID)
                WHERE CR.F_REF_LANCAMENTO_AGRUPADO IS NULL
                AND (STATUS.F_STATUS_FINANCEIRO_ID = 3) $where</attr>
<attr value=\"where\"></attr>
<attr value=\"order_by\"> 
ORDER BY &quot;RAZAO_SOCIAL&quot; ASC</attr>
<attr value=\"order_by_preview\"></attr>
<attr value=\"group_by\"></attr>
<attr value=\"group_fields\"><attr value=\"0\"><attr value=\"name\">Summary</attr>
<attr value=\"cross_table\">false</attr>
<attr value=\"sps\">true</attr>
<attr value=\"sds\">true</attr>
<attr value=\"sgs\">true</attr>
<attr value=\"sum_x\">true</attr>
<attr value=\"sum_y\">true</attr>
<attr value=\"sum_total\">true</attr>
</attr>
</attr>
<attr value=\"totals\"><attr value=\"SQL_CR_RecebidoPeriodo_COD\"><attr value=\"name\">COD</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Cod</attr>
<attr value=\"show\">true</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">false</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
<attr value=\"SQL_CR_RecebidoPeriodo_RAZAO_SOCIAL\"><attr value=\"name\">RAZAO_SOCIAL</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Razao Social</attr>
<attr value=\"show\">true</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">false</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
<attr value=\"SQL_CR_RecebidoPeriodo_RESUMO\"><attr value=\"name\">RESUMO</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Resumo</attr>
<attr value=\"show\">true</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">false</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
<attr value=\"SQL_CR_RecebidoPeriodo_VALOR\"><attr value=\"name\">VALOR</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Valor</attr>
<attr value=\"show\">true</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">true</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">true</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\">Currency</attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
<attr value=\"SQL_CR_RecebidoPeriodo_DATA_VENCIMENTO\"><attr value=\"name\">DATA_VENCIMENTO</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Dt. Vencimento</attr>
<attr value=\"show\">true</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">false</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
<attr value=\"SQL_CR_RecebidoPeriodo_DATA_RECEBIMENTO\"><attr value=\"name\">DATA_RECEBIMENTO</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Dt. Recebimento</attr>
<attr value=\"show\">true</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">false</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
<attr value=\"SQL_CR_RecebidoPeriodo_NOME_CONTA\"><attr value=\"name\">NOME_CONTA</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Conta</attr>
<attr value=\"show\">true</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">false</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
<attr value=\"SQL_CR_RecebidoPeriodo_SUBCATEGORIA\"><attr value=\"name\">SUBCATEGORIA</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">SUBCATEGORIA</attr>
<attr value=\"show\">false</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">false</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
<attr value=\"SQL_CR_RecebidoPeriodo_NOME_FILIAL\"><attr value=\"name\">NOME_FILIAL</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Filial</attr>
<attr value=\"show\">true</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">false</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
</attr>
<attr value=\"sort_fields\"><attr value=\"0\"><attr value=\"name\">RAZAO_SOCIAL</attr>
<attr value=\"desc\">false</attr>
</attr>
</attr>
<attr value=\"permissions\"><attr value=\"0\"><attr value=\"id\">Guest</attr>
<attr value=\"name\">Guest</attr>
<attr value=\"view\">false</attr>
<attr value=\"edit\">false</attr>
</attr>
<attr value=\"1\"><attr value=\"id\">admin</attr>
<attr value=\"name\">admin</attr>
<attr value=\"view\">false</attr>
<attr value=\"edit\">false</attr>
</attr>
</attr>
<attr value=\"style_editor\"><attr value=\"status\">success</attr>
</attr>
</report>";
		parent::execute_query("UPDATE \"webreports\" SET \"webreports\".\"rpt_content\" = '" . $this->XML . "'WHERE \"webreports\".\"rpt_name\" ='CR_RecebidoPeriodo'");
		break;
	    case "CR_VencerPeriodo":
		$dataInicial = empty($dados['data_ini_filtro']) ? $this->dataInicial : $this->data->convertDataSql($dados['data_ini_filtro']);
		$dataFinal = empty($dados['data_fim_filtro']) ? $this->dataFinal : $this->data->convertDataSql($dados['data_fim_filtro']);
		$conta = $dados['contaCliente'];
		$cliente = $dados['pesquisaCliente'];
		$status = $dados['status_filtro'];
		$filial = $dados['filial'];
		$where = "AND DATA_VENCIMENTO BETWEEN ''$dataInicial''  AND ''$dataFinal''";
		if (!empty($status)) {
		    $where .= "AND STATUS.f_status_financeiro_id= $status";
		}
		if (!empty($cliente)) {
		    $where .=" AND EMP.empresa_id = $cliente ";
		}
		if (!empty($conta)) {
		    $where .="AND  BANCO.BANCO_ID = $conta";
		}
		if (!empty($filial)) {
		    $where .= " AND F.FILIAL_ID = $filial";
		}


		$this->XML = "<report>
<attr value=\"table_type\">custom</attr>
<attr value=\"tables\"><attr value=\"0\">SQL_CR_VencerPeriodo</attr>
</attr>
<attr value=\"miscellaneous\"><attr value=\"type\">stepped</attr>
<attr value=\"print_friendly\">true</attr>
<attr value=\"lines_num\">30</attr>
</attr>
<attr value=\"settings\"><attr value=\"name\">CR_VencerPeriodo</attr>
<attr value=\"title\">Contas a Vencer no Periodo</attr>
<attr value=\"status\">public</attr>
</attr>
<attr value=\"owner\">admin</attr>
<attr value=\"tmp_active\"></attr>
<attr value=\"table_name\">SQL_CR_VencerPeriodo</attr>
<attr value=\"short_table_name\"></attr>
<attr value=\"sql\">SELECT   
        VALOR,
        COD_PARCELAMENTO AS COD,
        STATUS.NOME_STATUS,
        SUBSTRING(NOME_CONTA FROM 1 FOR 25) RESUMO,
        (
          SELECT *
           FROM SP_CONVERTER_CARACTER(SUBCATEGORIA.SUBCATEGORIA)
         ) AS SUBCATEGORIA,
         (
          SELECT *
            FROM SP_CONVERTER_CARACTER(EMP.RAZAO_SOCIAL)
         ) AS RAZAO_SOCIAL,
         (
          SELECT *
            FROM SP_CONVERTER_CARACTER(BANCO.NOME)
         ) AS NOME_CONTA,
         (
          SELECT *
          FROM SP_CONVERTER_CARACTER(F.NOME_FILIAL)
          )   AS NOME_FILIAL,
        DATA_VENCIMENTO,
        DATA_RECEBIMENTO,
        GRUPO.GRUPO
                FROM  F_LANCA_CR CR
                INNER JOIN F_LANCA_CR2  ON (F_LANCA_CR2.F_LANCA_CR2_ID = (SELECT MAX(CR2.F_LANCA_CR2_ID) FROM F_LANCA_CR2 CR2 WHERE CR2.F_LANCA_CR_ID = CR.F_LANCA_CR_ID))
                INNER JOIN F_STATUS_FINANCEIRO STATUS ON (STATUS.F_STATUS_FINANCEIRO_ID = CR.F_STATUS_FINANCEIRO_ID)
                LEFT JOIN EMPRESA  EMP ON (CR.EMPRESA_ID = EMP.EMPRESA_ID)
                LEFT JOIN SUBCATEGORIA ON (CR.SUBCATEGORIA_ID = SUBCATEGORIA.SUBCATEGORIA_ID)
                LEFT JOIN GRUPO_CAIXA GRUPO ON (GRUPO.GRUPO_CAIXA_ID = CR.GRUPO_CAIXA)
                INNER JOIN BANCO ON (CR.BANCO_ID = BANCO.BANCO_ID)
                INNER JOIN FILIAL F ON (F.FILIAL_ID = CR.COD_FILIAL_ID)
                WHERE CR.F_REF_LANCAMENTO_AGRUPADO IS NULL
                AND (STATUS.F_STATUS_FINANCEIRO_ID = 1 OR STATUS.F_STATUS_FINANCEIRO_ID = 2) $where</attr>
<attr value=\"sql_preview\">SELECT   
        VALOR,
        COD_PARCELAMENTO AS COD,
        STATUS.NOME_STATUS,
        SUBSTRING(NOME_CONTA FROM 1 FOR 25) RESUMO,
        (
          SELECT *
           FROM SP_CONVERTER_CARACTER(SUBCATEGORIA.SUBCATEGORIA)
         ) AS SUBCATEGORIA,
         (
          SELECT *
            FROM SP_CONVERTER_CARACTER(EMP.RAZAO_SOCIAL)
         ) AS RAZAO_SOCIAL,
         (
          SELECT *
            FROM SP_CONVERTER_CARACTER(BANCO.NOME)
         ) AS NOME_CONTA,
         (
          SELECT *
          FROM SP_CONVERTER_CARACTER(F.NOME_FILIAL)
          )   AS NOME_FILIAL,
        DATA_VENCIMENTO,
        DATA_RECEBIMENTO,
        GRUPO.GRUPO
                FROM  F_LANCA_CR CR
                INNER JOIN F_LANCA_CR2  ON (F_LANCA_CR2.F_LANCA_CR2_ID = (SELECT MAX(CR2.F_LANCA_CR2_ID) FROM F_LANCA_CR2 CR2 WHERE CR2.F_LANCA_CR_ID = CR.F_LANCA_CR_ID))
                INNER JOIN F_STATUS_FINANCEIRO STATUS ON (STATUS.F_STATUS_FINANCEIRO_ID = CR.F_STATUS_FINANCEIRO_ID)
                LEFT JOIN EMPRESA  EMP ON (CR.EMPRESA_ID = EMP.EMPRESA_ID)
                LEFT JOIN SUBCATEGORIA ON (CR.SUBCATEGORIA_ID = SUBCATEGORIA.SUBCATEGORIA_ID)
                LEFT JOIN GRUPO_CAIXA GRUPO ON (GRUPO.GRUPO_CAIXA_ID = CR.GRUPO_CAIXA)
                INNER JOIN BANCO ON (CR.BANCO_ID = BANCO.BANCO_ID)
                INNER JOIN FILIAL F ON (F.FILIAL_ID = CR.COD_FILIAL_ID)
                WHERE CR.F_REF_LANCAMENTO_AGRUPADO IS NULL
                AND (STATUS.F_STATUS_FINANCEIRO_ID = 1 OR STATUS.F_STATUS_FINANCEIRO_ID = 2) $where</attr>
<attr value=\"where\"></attr>
<attr value=\"order_by\"> 
ORDER BY &quot;RAZAO_SOCIAL&quot; ASC</attr>
<attr value=\"order_by_preview\"></attr>
<attr value=\"group_by\"></attr>
<attr value=\"group_fields\"><attr value=\"0\"><attr value=\"name\">Summary</attr>
<attr value=\"cross_table\">false</attr>
<attr value=\"sps\">true</attr>
<attr value=\"sds\">true</attr>
<attr value=\"sgs\">true</attr>
<attr value=\"sum_x\">true</attr>
<attr value=\"sum_y\">true</attr>
<attr value=\"sum_total\">true</attr>
</attr>
</attr>
<attr value=\"totals\"><attr value=\"SQL_CR_VencerPeriodo_COD\"><attr value=\"name\">COD</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Cod</attr>
<attr value=\"show\">true</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">false</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
<attr value=\"SQL_CR_VencerPeriodo_RAZAO_SOCIAL\"><attr value=\"name\">RAZAO_SOCIAL</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Razao Social</attr>
<attr value=\"show\">true</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">false</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
<attr value=\"SQL_CR_VencerPeriodo_RESUMO\"><attr value=\"name\">RESUMO</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Resumo</attr>
<attr value=\"show\">true</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">false</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
<attr value=\"SQL_CR_VencerPeriodo_VALOR\"><attr value=\"name\">VALOR</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Valor</attr>
<attr value=\"show\">true</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">true</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
<attr value=\"SQL_CR_VencerPeriodo_DATA_VENCIMENTO\"><attr value=\"name\">DATA_VENCIMENTO</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Dt. Vencimento</attr>
<attr value=\"show\">true</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">false</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
<attr value=\"SQL_CR_VencerPeriodo_NOME_STATUS\"><attr value=\"name\">NOME_STATUS</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Status</attr>
<attr value=\"show\">true</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">false</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
<attr value=\"SQL_CR_VencerPeriodo_NOME_CONTA\"><attr value=\"name\">NOME_CONTA</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Conta Previsao</attr>
<attr value=\"show\">true</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">false</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
<attr value=\"SQL_CR_VencerPeriodo_SUBCATEGORIA\"><attr value=\"name\">SUBCATEGORIA</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">SUBCATEGORIA</attr>
<attr value=\"show\">false</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">false</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
<attr value=\"SQL_CR_VencerPeriodo_DATA_RECEBIMENTO\"><attr value=\"name\">DATA_RECEBIMENTO</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">DATA_RECEBIMENTO</attr>
<attr value=\"show\">false</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">false</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
<attr value=\"SQL_CR_VencerPeriodo_GRUPO\"><attr value=\"name\">GRUPO</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Centro Receita</attr>
<attr value=\"show\">true</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">false</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
<attr value=\"SQL_CR_VencerPeriodo_NOME_FILIAL\"><attr value=\"name\">NOME_FILIAL</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Filial</attr>
<attr value=\"show\">true</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">false</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
</attr>
<attr value=\"sort_fields\"><attr value=\"0\"><attr value=\"name\">RAZAO_SOCIAL</attr>
<attr value=\"desc\">false</attr>
</attr>
</attr>
</report>";
		parent::execute_query("UPDATE \"webreports\" SET \"webreports\".\"rpt_content\" = '" . $this->XML . "'WHERE \"webreports\".\"rpt_name\" ='CR_VencerPeriodo'");
		//parent::gravaQueryArquivo("UPDATE \"webreports\" SET \"webreports\".\"rpt_content\" = '".$this->XML."' \"WHERE \"webreports\".\"rpt_name\" =\"CR_VencerPeriodo\"");
		break;
	    case "CR_RecebimentosCategoria":
		$dataInicial = empty($dados['data_ini_filtro']) ? $this->dataInicial : $this->data->convertDataSql($dados['data_ini_filtro']);
		$dataFinal = empty($dados['data_fim_filtro']) ? $this->dataFinal : $this->data->convertDataSql($dados['data_fim_filtro']);
		$conta = $dados['contaCliente'];
		$cliente = $dados['pesquisaCliente'];
		$subCategoria = $dados['subCategoria'];
		$filial = $dados['filial'];
		if ($dados['dataPesquisa'] == 1) {
		    $where = "AND DATA_VENCIMENTO BETWEEN ''$dataInicial''  AND ''$dataFinal''";
		} else if ($dados['dataPesquisa'] == 2) {
		    $where = "AND DATA_RECEBIMENTO BETWEEN ''$dataInicial''  AND ''$dataFinal''";
		} else {
		    $where = "AND DATA_VENCIMENTO BETWEEN ''$dataInicial''  AND ''$dataFinal''";
		}
		if (!empty($cliente)) {
		    $where .=" AND EMP.empresa_id = $cliente ";
		}
		if (!empty($conta)) {
		    $where .="AND  BANCO.BANCO_ID = $conta";
		}
		if (!empty($subCategoria)) {
		    $where .=" AND SUBCATEGORIA.SUBCATEGORIA_ID = $subCategoria";
		}
		if (!empty($filial)) {
		    $where .= " AND F.FILIAL_ID = $filial";
		}

		$this->XML = "<report>
<attr value=\"table_type\">custom</attr>
<attr value=\"tables\"><attr value=\"0\">SQL_CR_RecebimentosCategoria</attr>
</attr>
<attr value=\"group_fields\"><attr value=\"0\"><attr value=\"name\">SUBCATEGORIA</attr>
<attr value=\"int_type\">0</attr>
<attr value=\"ss\">true</attr>
<attr value=\"group_order\">1</attr>
<attr value=\"group_type\">x</attr>
<attr value=\"color1\">CCCCCC</attr>
<attr value=\"color2\">ADADAD</attr>
</attr>
<attr value=\"1\"><attr value=\"name\">Summary</attr>
<attr value=\"cross_table\">false</attr>
<attr value=\"sps\">true</attr>
<attr value=\"sds\">true</attr>
<attr value=\"sgs\">true</attr>
<attr value=\"sum_x\">true</attr>
<attr value=\"sum_y\">true</attr>
<attr value=\"sum_total\">true</attr>
</attr>
</attr>
<attr value=\"totals\"><attr value=\"SQL_CR_RecebimentosCategoria_SUBCATEGORIA\"><attr value=\"name\">SUBCATEGORIA</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Categoria</attr>
<attr value=\"show\">true</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">false</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
<attr value=\"SQL_CR_RecebimentosCategoria_COD\"><attr value=\"name\">COD</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Cod</attr>
<attr value=\"show\">true</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">false</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
<attr value=\"SQL_CR_RecebimentosCategoria_RAZAO_SOCIAL\"><attr value=\"name\">RAZAO_SOCIAL</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Razao Social</attr>
<attr value=\"show\">true</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">false</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
<attr value=\"SQL_CR_RecebimentosCategoria_RESUMO\"><attr value=\"name\">RESUMO</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Resumo</attr>
<attr value=\"show\">true</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">false</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
<attr value=\"SQL_CR_RecebimentosCategoria_VALOR\"><attr value=\"name\">VALOR</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Valor</attr>
<attr value=\"show\">true</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">true</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">true</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\">Currency</attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
<attr value=\"SQL_CR_RecebimentosCategoria_DATA_VENCIMENTO\"><attr value=\"name\">DATA_VENCIMENTO</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Dt. Vencimento</attr>
<attr value=\"show\">true</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">false</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
<attr value=\"SQL_CR_RecebimentosCategoria_DATA_RECEBIMENTO\"><attr value=\"name\">DATA_RECEBIMENTO</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Dt. Recebimento</attr>
<attr value=\"show\">true</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">false</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
<attr value=\"SQL_CR_RecebimentosCategoria_NOME_CONTA\"><attr value=\"name\">NOME_CONTA</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Conta</attr>
<attr value=\"show\">true</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">false</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
<attr value=\"SQL_CR_RecebimentosCategoria_NOME_STATUS\"><attr value=\"name\">NOME_STATUS</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">NOME_STATUS</attr>
<attr value=\"show\">false</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">false</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
<attr value=\"SQL_CR_RecebimentosCategoria_NOME_FILIAL\"><attr value=\"name\">NOME_FILIAL</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Filial</attr>
<attr value=\"show\">true</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">false</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
</attr>
<attr value=\"sort_fields\"><attr value=\"0\"><attr value=\"name\">SUBCATEGORIA</attr>
<attr value=\"desc\">false</attr>
</attr>
<attr value=\"1\"><attr value=\"name\">RAZAO_SOCIAL</attr>
<attr value=\"desc\">false</attr>
</attr>
</attr>
<attr value=\"miscellaneous\"><attr value=\"type\">stepped</attr>
<attr value=\"print_friendly\">true</attr>
<attr value=\"lines_num\">30</attr>
</attr>
<attr value=\"settings\"><attr value=\"name\">CR_RecebimentosCategoria</attr>
<attr value=\"title\">Recebimentos no Periodo (Agrupado por Categoria)</attr>
<attr value=\"status\">public</attr>
</attr>
<attr value=\"owner\">admin</attr>
<attr value=\"tmp_active\"></attr>
<attr value=\"table_name\">SQL_CR_RecebimentosCategoria</attr>
<attr value=\"short_table_name\"></attr>
<attr value=\"sql\">SELECT   
        VALOR,
        COD_PARCELAMENTO AS COD,
        STATUS.NOME_STATUS,
        SUBSTRING(NOME_CONTA FROM 1 FOR 25) RESUMO,
        (
          SELECT *
           FROM SP_CONVERTER_CARACTER(SUBCATEGORIA.SUBCATEGORIA)
         ) AS SUBCATEGORIA,
         (
          SELECT *
            FROM SP_CONVERTER_CARACTER(EMP.RAZAO_SOCIAL)
         ) AS RAZAO_SOCIAL,
         (
          SELECT *
            FROM SP_CONVERTER_CARACTER(BANCO.NOME)
         ) AS NOME_CONTA,
         (
            SELECT *
            FROM SP_CONVERTER_CARACTER(F.NOME_FILIAL)
         )   AS NOME_FILIAL,
        DATA_VENCIMENTO,
       DATA_RECEBIMENTO
                FROM  F_LANCA_CR CR
                INNER JOIN F_LANCA_CR2  ON (F_LANCA_CR2.F_LANCA_CR2_ID = (SELECT MAX(CR2.F_LANCA_CR2_ID) FROM F_LANCA_CR2 CR2 WHERE CR2.F_LANCA_CR_ID = CR.F_LANCA_CR_ID))
                INNER JOIN F_STATUS_FINANCEIRO STATUS ON (STATUS.F_STATUS_FINANCEIRO_ID = CR.F_STATUS_FINANCEIRO_ID)
                LEFT JOIN EMPRESA  EMP ON (CR.EMPRESA_ID = EMP.EMPRESA_ID)
                LEFT JOIN SUBCATEGORIA ON (CR.SUBCATEGORIA_ID = SUBCATEGORIA.SUBCATEGORIA_ID)
                LEFT JOIN GRUPO_CAIXA GRUPO ON (GRUPO.GRUPO_CAIXA_ID = CR.GRUPO_CAIXA)
                INNER JOIN BANCO ON (CR.BANCO_ID = BANCO.BANCO_ID)
                INNER JOIN FILIAL F ON (F.FILIAL_ID = CR.COD_FILIAL_ID)
                WHERE CR.F_REF_LANCAMENTO_AGRUPADO IS NULL
                AND (STATUS.F_STATUS_FINANCEIRO_ID = 3) $where</attr>
<attr value=\"sql_preview\">SELECT   
        VALOR,
        COD_PARCELAMENTO AS COD,
        STATUS.NOME_STATUS,
        SUBSTRING(NOME_CONTA FROM 1 FOR 25) RESUMO,
        (
          SELECT *
           FROM SP_CONVERTER_CARACTER(SUBCATEGORIA.SUBCATEGORIA)
         ) AS SUBCATEGORIA,
         (
          SELECT *
            FROM SP_CONVERTER_CARACTER(EMP.RAZAO_SOCIAL)
         ) AS RAZAO_SOCIAL,
         (
          SELECT *
            FROM SP_CONVERTER_CARACTER(BANCO.NOME)
         ) AS NOME_CONTA,
         (
            SELECT *
            FROM SP_CONVERTER_CARACTER(F.NOME_FILIAL)
         )   AS NOME_FILIAL,
        DATA_VENCIMENTO,
       DATA_RECEBIMENTO
                FROM  F_LANCA_CR CR
                INNER JOIN F_LANCA_CR2  ON (F_LANCA_CR2.F_LANCA_CR2_ID = (SELECT MAX(CR2.F_LANCA_CR2_ID) FROM F_LANCA_CR2 CR2 WHERE CR2.F_LANCA_CR_ID = CR.F_LANCA_CR_ID))
                INNER JOIN F_STATUS_FINANCEIRO STATUS ON (STATUS.F_STATUS_FINANCEIRO_ID = CR.F_STATUS_FINANCEIRO_ID)
                LEFT JOIN EMPRESA  EMP ON (CR.EMPRESA_ID = EMP.EMPRESA_ID)
                LEFT JOIN SUBCATEGORIA ON (CR.SUBCATEGORIA_ID = SUBCATEGORIA.SUBCATEGORIA_ID)
                LEFT JOIN GRUPO_CAIXA GRUPO ON (GRUPO.GRUPO_CAIXA_ID = CR.GRUPO_CAIXA)
                INNER JOIN BANCO ON (CR.BANCO_ID = BANCO.BANCO_ID)
                INNER JOIN FILIAL F ON (F.FILIAL_ID = CR.COD_FILIAL_ID)
                WHERE CR.F_REF_LANCAMENTO_AGRUPADO IS NULL
                AND (STATUS.F_STATUS_FINANCEIRO_ID = 3) $where</attr>
<attr value=\"where\"></attr>
<attr value=\"order_by\"> 
ORDER BY &quot;SUBCATEGORIA&quot; ASC, &quot;RAZAO_SOCIAL&quot; ASC</attr>
<attr value=\"order_by_preview\"></attr>
<attr value=\"group_by\"></attr>
<attr value=\"style_editor\"><attr value=\"status\">success</attr>
</attr>
</report>
";
		parent::execute_query("UPDATE \"webreports\" SET \"webreports\".\"rpt_content\" = '" . $this->XML . "'WHERE \"webreports\".\"rpt_name\" ='CR_RecebimentosCategoria'");
		break;
	    case "CR_RecebimentosEmpresa":

		$dataInicial = empty($dados['data_ini_filtro']) ? $this->dataInicial : $this->data->convertDataSql($dados['data_ini_filtro']);
		$dataFinal = empty($dados['data_fim_filtro']) ? $this->dataFinal : $this->data->convertDataSql($dados['data_fim_filtro']);
		$conta = $dados['contaCliente'];
		$cliente = $dados['pesquisaCliente'];
		$filial = $dados['filial'];
		if ($dados['dataPesquisa'] == 1) {
		    $where = "AND DATA_VENCIMENTO BETWEEN ''$dataInicial''  AND ''$dataFinal''";
		} else if ($dados['dataPesquisa'] == 2) {
		    $where = "AND DATA_RECEBIMENTO BETWEEN ''$dataInicial''  AND ''$dataFinal''";
		} else {
		    $where = "AND DATA_VENCIMENTO BETWEEN ''$dataInicial''  AND ''$dataFinal''";
		}
		if (!empty($cliente)) {
		    $where .=" AND EMP.empresa_id = $cliente ";
		}
		if (!empty($conta)) {
		    $where .="AND  BANCO.BANCO_ID = $conta";
		}
		if (!empty($filial)) {
		    $where .= " AND F.FILIAL_ID = $filial";
		}
		$where;
		$this->XML = "<report>
<attr value=\"table_type\">custom</attr>
<attr value=\"tables\"><attr value=\"0\">SQL_CR_RecebimentosEmpresa</attr>
</attr>
<attr value=\"group_fields\"><attr value=\"0\"><attr value=\"name\">RAZAO_SOCIAL</attr>
<attr value=\"int_type\">0</attr>
<attr value=\"ss\">true</attr>
<attr value=\"group_order\">1</attr>
<attr value=\"group_type\">x</attr>
<attr value=\"color1\">CCCCCC</attr>
<attr value=\"color2\">ADADAD</attr>
</attr>
<attr value=\"1\"><attr value=\"name\">Summary</attr>
<attr value=\"cross_table\">false</attr>
<attr value=\"sps\">true</attr>
<attr value=\"sds\">true</attr>
<attr value=\"sgs\">true</attr>
<attr value=\"sum_x\">true</attr>
<attr value=\"sum_y\">true</attr>
<attr value=\"sum_total\">true</attr>
</attr>
</attr>
<attr value=\"totals\"><attr value=\"SQL_CR_RecebimentosEmpresa_RAZAO_SOCIAL\"><attr value=\"name\">RAZAO_SOCIAL</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Razao Social</attr>
<attr value=\"show\">true</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">false</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
<attr value=\"SQL_CR_RecebimentosEmpresa_COD\"><attr value=\"name\">COD</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Cod</attr>
<attr value=\"show\">true</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">false</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
<attr value=\"SQL_CR_RecebimentosEmpresa_RESUMO\"><attr value=\"name\">RESUMO</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Resumo</attr>
<attr value=\"show\">true</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">false</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
<attr value=\"SQL_CR_RecebimentosEmpresa_VALOR\"><attr value=\"name\">VALOR</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Valor</attr>
<attr value=\"show\">true</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">true</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">true</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\">Currency</attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
<attr value=\"SQL_CR_RecebimentosEmpresa_DATA_VENCIMENTO\"><attr value=\"name\">DATA_VENCIMENTO</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Dt. Vencimento</attr>
<attr value=\"show\">true</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">false</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
<attr value=\"SQL_CR_RecebimentosEmpresa_DATA_RECEBIMENTO\"><attr value=\"name\">DATA_RECEBIMENTO</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Dt. Recebimento</attr>
<attr value=\"show\">true</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">false</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
<attr value=\"SQL_CR_RecebimentosEmpresa_NOME_CONTA\"><attr value=\"name\">NOME_CONTA</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Conta</attr>
<attr value=\"show\">true</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">false</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
<attr value=\"SQL_CR_RecebimentosEmpresa_NOME_STATUS\"><attr value=\"name\">NOME_STATUS</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">NOME_STATUS</attr>
<attr value=\"show\">false</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">false</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
<attr value=\"SQL_CR_RecebimentosEmpresa_SUBCATEGORIA\"><attr value=\"name\">SUBCATEGORIA</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">SUBCATEGORIA</attr>
<attr value=\"show\">false</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">false</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
<attr value=\"SQL_CR_RecebimentosEmpresa_NOME_FILIAL\"><attr value=\"name\">NOME_FILIAL</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Filial</attr>
<attr value=\"show\">true</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">false</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
</attr>
<attr value=\"sort_fields\"><attr value=\"0\"><attr value=\"name\">RAZAO_SOCIAL</attr>
<attr value=\"desc\">false</attr>
</attr>
<attr value=\"1\"><attr value=\"name\">RESUMO</attr>
<attr value=\"desc\">false</attr>
</attr>
</attr>
<attr value=\"miscellaneous\"><attr value=\"type\">stepped</attr>
<attr value=\"print_friendly\">true</attr>
<attr value=\"lines_num\">30</attr>
</attr>
<attr value=\"settings\"><attr value=\"name\">CR_RecebimentosEmpresa</attr>
<attr value=\"title\">Recebimentos no Periodo (Agrupado por Empresa)</attr>
<attr value=\"status\">public</attr>
</attr>
<attr value=\"owner\">admin</attr>
<attr value=\"tmp_active\"></attr>
<attr value=\"table_name\">SQL_CR_RecebimentosEmpresa</attr>
<attr value=\"short_table_name\"></attr>
<attr value=\"sql\">SELECT   
        VALOR,
        COD_PARCELAMENTO AS COD,
        STATUS.NOME_STATUS,
        SUBSTRING(NOME_CONTA FROM 1 FOR 25) RESUMO,
        (
          SELECT *
           FROM SP_CONVERTER_CARACTER(SUBCATEGORIA.SUBCATEGORIA)
         ) AS SUBCATEGORIA,
         (
          SELECT *
            FROM SP_CONVERTER_CARACTER(EMP.RAZAO_SOCIAL)
         ) AS RAZAO_SOCIAL,
         (
          SELECT *
            FROM SP_CONVERTER_CARACTER(BANCO.NOME)
         ) AS NOME_CONTA,
         (
            SELECT *
            FROM SP_CONVERTER_CARACTER(F.NOME_FILIAL)
         )  AS NOME_FILIAL,
        DATA_VENCIMENTO,
        DATA_RECEBIMENTO
                FROM  F_LANCA_CR CR
                INNER JOIN F_LANCA_CR2  ON (F_LANCA_CR2.F_LANCA_CR2_ID = (SELECT MAX(CR2.F_LANCA_CR2_ID) FROM F_LANCA_CR2 CR2 WHERE CR2.F_LANCA_CR_ID = CR.F_LANCA_CR_ID))
                INNER JOIN F_STATUS_FINANCEIRO STATUS ON (STATUS.F_STATUS_FINANCEIRO_ID = CR.F_STATUS_FINANCEIRO_ID)
                LEFT JOIN EMPRESA  EMP ON (CR.EMPRESA_ID = EMP.EMPRESA_ID)
                LEFT JOIN SUBCATEGORIA ON (CR.SUBCATEGORIA_ID = SUBCATEGORIA.SUBCATEGORIA_ID)
                LEFT JOIN GRUPO_CAIXA GRUPO ON (GRUPO.GRUPO_CAIXA_ID = CR.GRUPO_CAIXA)
                INNER JOIN BANCO ON (CR.BANCO_ID = BANCO.BANCO_ID)
                INNER JOIN FILIAL F ON (F.FILIAL_ID = CR.COD_FILIAL_ID)
                WHERE CR.F_REF_LANCAMENTO_AGRUPADO IS NULL
                AND (STATUS.F_STATUS_FINANCEIRO_ID = 3) $where</attr>
<attr value=\"sql_preview\">SELECT   
        VALOR,
        COD_PARCELAMENTO AS COD,
        STATUS.NOME_STATUS,
        SUBSTRING(NOME_CONTA FROM 1 FOR 25) RESUMO,
        (
          SELECT *
           FROM SP_CONVERTER_CARACTER(SUBCATEGORIA.SUBCATEGORIA)
         ) AS SUBCATEGORIA,
         (
          SELECT *
            FROM SP_CONVERTER_CARACTER(EMP.RAZAO_SOCIAL)
         ) AS RAZAO_SOCIAL,
         (
          SELECT *
            FROM SP_CONVERTER_CARACTER(BANCO.NOME)
         ) AS NOME_CONTA,
         (
            SELECT *
            FROM SP_CONVERTER_CARACTER(F.NOME_FILIAL)
         )  AS NOME_FILIAL,
        DATA_VENCIMENTO,
        DATA_RECEBIMENTO
                FROM  F_LANCA_CR CR
                INNER JOIN F_LANCA_CR2  ON (F_LANCA_CR2.F_LANCA_CR2_ID = (SELECT MAX(CR2.F_LANCA_CR2_ID) FROM F_LANCA_CR2 CR2 WHERE CR2.F_LANCA_CR_ID = CR.F_LANCA_CR_ID))
                INNER JOIN F_STATUS_FINANCEIRO STATUS ON (STATUS.F_STATUS_FINANCEIRO_ID = CR.F_STATUS_FINANCEIRO_ID)
                LEFT JOIN EMPRESA  EMP ON (CR.EMPRESA_ID = EMP.EMPRESA_ID)
                LEFT JOIN SUBCATEGORIA ON (CR.SUBCATEGORIA_ID = SUBCATEGORIA.SUBCATEGORIA_ID)
                LEFT JOIN GRUPO_CAIXA GRUPO ON (GRUPO.GRUPO_CAIXA_ID = CR.GRUPO_CAIXA)
                INNER JOIN BANCO ON (CR.BANCO_ID = BANCO.BANCO_ID)
                INNER JOIN FILIAL F ON (F.FILIAL_ID = CR.COD_FILIAL_ID)
                WHERE CR.F_REF_LANCAMENTO_AGRUPADO IS NULL
                AND (STATUS.F_STATUS_FINANCEIRO_ID = 3) $where</attr>
<attr value=\"where\"></attr>
<attr value=\"order_by\"> 
ORDER BY &quot;RAZAO_SOCIAL&quot; ASC, &quot;RESUMO&quot; ASC</attr>
<attr value=\"order_by_preview\"></attr>
<attr value=\"group_by\"></attr>
</report>";
		parent::execute_query("UPDATE \"webreports\" SET \"webreports\".\"rpt_content\" = '" . $this->XML . "'WHERE \"webreports\".\"rpt_name\" ='CR_RecebimentosEmpresa'");
		BREAK;
	    case "CR_PagamentosCentroReceita":
		$dataInicial = empty($dados['data_ini_filtro']) ? $this->dataInicial : $this->data->convertDataSql($dados['data_ini_filtro']);
		$dataFinal = empty($dados['data_fim_filtro']) ? $this->dataFinal : $this->data->convertDataSql($dados['data_fim_filtro']);
		$conta = $dados['contaCliente'];
		$cliente = $dados['pesquisaCliente'];
		$centroReceita = $dados['centroReceita'];
		$filial = $dados['filial'];
		if ($dados['dataPesquisa'] == 1) {
		    $where = "AND DATA_VENCIMENTO BETWEEN ''$dataInicial''  AND ''$dataFinal''";
		} else if ($dados['dataPesquisa'] == 2) {
		    $where = "AND DATA_RECEBIMENTO BETWEEN ''$dataInicial''  AND ''$dataFinal''";
		} else {
		    $where = "AND DATA_VENCIMENTO BETWEEN ''$dataInicial''  AND ''$dataFinal''";
		}
		if (!empty($cliente)) {
		    $where .=" AND EMP.empresa_id = $cliente ";
		}
		if (!empty($conta)) {
		    $where .="AND  BANCO.BANCO_ID = $conta";
		}
		if (!empty($centroReceita)) {
		    $where .= "AND GRUPO.grupo_caixa_id = $centroReceita";
		}
		if (!empty($filial)) {
		    $where .= "AND F.FILIAL_ID = $filial";
		}
		$this->XML = "<report>
<attr value=\"table_type\">custom</attr>
<attr value=\"tables\"><attr value=\"0\">SQL_CR_RecebidoPeriodo</attr>
</attr>
<attr value=\"miscellaneous\"><attr value=\"type\">stepped</attr>
<attr value=\"print_friendly\">true</attr>
<attr value=\"lines_num\">30</attr>
</attr>
<attr value=\"settings\"><attr value=\"name\">CR_RecebidoPeriodo</attr>
<attr value=\"title\">Recebimentos no Periodo</attr>
<attr value=\"status\">public</attr>
</attr>
<attr value=\"owner\">admin</attr>
<attr value=\"tmp_active\"></attr>
<attr value=\"table_name\">SQL_CR_RecebidoPeriodo</attr>
<attr value=\"short_table_name\"></attr>
<attr value=\"sql\">SELECT   
        VALOR,
        COD_PARCELAMENTO AS COD,
        SUBSTRING(NOME_CONTA FROM 1 FOR 25)RESUMO,
        (
          SELECT *
           FROM SP_CONVERTER_CARACTER(SUBCATEGORIA.SUBCATEGORIA)
         ) AS SUBCATEGORIA,
         (
          SELECT *
            FROM SP_CONVERTER_CARACTER(EMP.RAZAO_SOCIAL)
         ) AS RAZAO_SOCIAL,
         (
          SELECT *
            FROM SP_CONVERTER_CARACTER(BANCO.NOME)
         ) AS NOME_CONTA,
         (
          SELECT *
          FROM SP_CONVERTER_CARACTER(F.NOME_FILIAL)
          )   AS NOME_FILIAL,
        DATA_VENCIMENTO,
       DATA_RECEBIMENTO
                FROM  F_LANCA_CR CR
                INNER JOIN F_LANCA_CR2  ON (F_LANCA_CR2.F_LANCA_CR2_ID = (SELECT MAX(CR2.F_LANCA_CR2_ID) FROM F_LANCA_CR2 CR2 WHERE CR2.F_LANCA_CR_ID = CR.F_LANCA_CR_ID))
                INNER JOIN F_STATUS_FINANCEIRO STATUS ON (STATUS.F_STATUS_FINANCEIRO_ID = CR.F_STATUS_FINANCEIRO_ID)
                LEFT JOIN EMPRESA  EMP ON (CR.EMPRESA_ID = EMP.EMPRESA_ID)
                LEFT JOIN SUBCATEGORIA ON (CR.SUBCATEGORIA_ID = SUBCATEGORIA.SUBCATEGORIA_ID)
                LEFT JOIN GRUPO_CAIXA GRUPO ON (GRUPO.GRUPO_CAIXA_ID = CR.GRUPO_CAIXA)
                INNER JOIN BANCO ON (CR.BANCO_ID = BANCO.BANCO_ID)
                INNER JOIN FILIAL F ON (F.FILIAL_ID = CR.COD_FILIAL_ID)
                WHERE CR.F_REF_LANCAMENTO_AGRUPADO IS NULL
                AND (STATUS.F_STATUS_FINANCEIRO_ID = 3) $where</attr>
<attr value=\"sql_preview\">SELECT   
        VALOR,
        COD_PARCELAMENTO AS COD,
        SUBSTRING(NOME_CONTA FROM 1 FOR 25)RESUMO,
        (
          SELECT *
           FROM SP_CONVERTER_CARACTER(SUBCATEGORIA.SUBCATEGORIA)
         ) AS SUBCATEGORIA,
         (
          SELECT *
            FROM SP_CONVERTER_CARACTER(EMP.RAZAO_SOCIAL)
         ) AS RAZAO_SOCIAL,
         (
          SELECT *
            FROM SP_CONVERTER_CARACTER(BANCO.NOME)
         ) AS NOME_CONTA,
         (
          SELECT *
          FROM SP_CONVERTER_CARACTER(F.NOME_FILIAL)
          )   AS NOME_FILIAL,
        DATA_VENCIMENTO,
       DATA_RECEBIMENTO
                FROM  F_LANCA_CR CR
                INNER JOIN F_LANCA_CR2  ON (F_LANCA_CR2.F_LANCA_CR2_ID = (SELECT MAX(CR2.F_LANCA_CR2_ID) FROM F_LANCA_CR2 CR2 WHERE CR2.F_LANCA_CR_ID = CR.F_LANCA_CR_ID))
                INNER JOIN F_STATUS_FINANCEIRO STATUS ON (STATUS.F_STATUS_FINANCEIRO_ID = CR.F_STATUS_FINANCEIRO_ID)
                LEFT JOIN EMPRESA  EMP ON (CR.EMPRESA_ID = EMP.EMPRESA_ID)
                LEFT JOIN SUBCATEGORIA ON (CR.SUBCATEGORIA_ID = SUBCATEGORIA.SUBCATEGORIA_ID)
                LEFT JOIN GRUPO_CAIXA GRUPO ON (GRUPO.GRUPO_CAIXA_ID = CR.GRUPO_CAIXA)
                INNER JOIN BANCO ON (CR.BANCO_ID = BANCO.BANCO_ID)
                INNER JOIN FILIAL F ON (F.FILIAL_ID = CR.COD_FILIAL_ID)
                WHERE CR.F_REF_LANCAMENTO_AGRUPADO IS NULL
                AND (STATUS.F_STATUS_FINANCEIRO_ID = 3) $where</attr>
<attr value=\"where\"></attr>
<attr value=\"order_by\"> 
ORDER BY &quot;RAZAO_SOCIAL&quot; ASC</attr>
<attr value=\"order_by_preview\"></attr>
<attr value=\"group_by\"></attr>
<attr value=\"group_fields\"><attr value=\"0\"><attr value=\"name\">Summary</attr>
<attr value=\"cross_table\">false</attr>
<attr value=\"sps\">true</attr>
<attr value=\"sds\">true</attr>
<attr value=\"sgs\">true</attr>
<attr value=\"sum_x\">true</attr>
<attr value=\"sum_y\">true</attr>
<attr value=\"sum_total\">true</attr>
</attr>
</attr>
<attr value=\"totals\"><attr value=\"SQL_CR_RecebidoPeriodo_COD\"><attr value=\"name\">COD</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Cod</attr>
<attr value=\"show\">true</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">false</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
<attr value=\"SQL_CR_RecebidoPeriodo_RAZAO_SOCIAL\"><attr value=\"name\">RAZAO_SOCIAL</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Razao Social</attr>
<attr value=\"show\">true</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">false</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
<attr value=\"SQL_CR_RecebidoPeriodo_RESUMO\"><attr value=\"name\">RESUMO</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Resumo</attr>
<attr value=\"show\">true</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">false</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
<attr value=\"SQL_CR_RecebidoPeriodo_VALOR\"><attr value=\"name\">VALOR</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Valor</attr>
<attr value=\"show\">true</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">true</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">true</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\">Currency</attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
<attr value=\"SQL_CR_RecebidoPeriodo_DATA_VENCIMENTO\"><attr value=\"name\">DATA_VENCIMENTO</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Dt. Vencimento</attr>
<attr value=\"show\">true</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">false</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
<attr value=\"SQL_CR_RecebidoPeriodo_DATA_RECEBIMENTO\"><attr value=\"name\">DATA_RECEBIMENTO</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Dt. Recebimento</attr>
<attr value=\"show\">true</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">false</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
<attr value=\"SQL_CR_RecebidoPeriodo_NOME_CONTA\"><attr value=\"name\">NOME_CONTA</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Conta</attr>
<attr value=\"show\">true</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">false</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
<attr value=\"SQL_CR_RecebidoPeriodo_SUBCATEGORIA\"><attr value=\"name\">SUBCATEGORIA</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">SUBCATEGORIA</attr>
<attr value=\"show\">false</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">false</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
<attr value=\"SQL_CR_RecebidoPeriodo_NOME_FILIAL\"><attr value=\"name\">NOME_FILIAL</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Filial</attr>
<attr value=\"show\">true</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">false</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
</attr>
<attr value=\"sort_fields\"><attr value=\"0\"><attr value=\"name\">RAZAO_SOCIAL</attr>
<attr value=\"desc\">false</attr>
</attr>
</attr>
<attr value=\"permissions\"><attr value=\"0\"><attr value=\"id\">Guest</attr>
<attr value=\"name\">Guest</attr>
<attr value=\"view\">false</attr>
<attr value=\"edit\">false</attr>
</attr>
<attr value=\"1\"><attr value=\"id\">admin</attr>
<attr value=\"name\">admin</attr>
<attr value=\"view\">false</attr>
<attr value=\"edit\">false</attr>
</attr>
</attr>
<attr value=\"style_editor\"><attr value=\"status\">success</attr>
</attr>
</report>";
		parent::execute_query("UPDATE \"webreports\" SET \"webreports\".\"rpt_content\" = '" . $this->XML . "'WHERE \"webreports\".\"rpt_name\" ='CR_PagamentosCentroReceita'");
		parent::gravaQueryArquivo("UPDATE \"webreports\" SET \"webreports\".\"rpt_content\" = '" . $this->XML . "' \"WHERE \"webreports\".\"rpt_name\" =\"CR_PagamentosCentroReceita\"");
		break;
	    case "CP_PagamentosPeriodo":
		$dataInicial = empty($dados['data_ini_filtro']) ? $this->dataInicial : $this->data->convertDataSql($dados['data_ini_filtro']);
		$dataFinal = empty($dados['data_fim_filtro']) ? $this->dataFinal : $this->data->convertDataSql($dados['data_fim_filtro']);
		$conta = $dados['contaCliente'];
		$cliente = $dados['pesquisaCliente'];
		$filial = $dados['filial'];
		if ($dados['dataPesquisa'] == 1) {
		    $where = "AND DATA_VENCIMENTO BETWEEN ''$dataInicial''  AND ''$dataFinal''";
		} else if ($dados['dataPesquisa'] == 2) {
		    $where = "AND DATA_PAGAMENTO BETWEEN ''$dataInicial''  AND ''$dataFinal''";
		} else {
		    $where = "AND DATA_VENCIMENTO BETWEEN ''$dataInicial''  AND ''$dataFinal''";
		}

		if (!empty($cliente)) {
		    $where .=" AND fornecedor.fornecedor_id = $cliente ";
		}
		if (!empty($conta)) {
		    $where .="AND  BANCO.BANCO_ID = $conta";
		}
		if (!empty($filial)) {
		    $where .= " AND F.FILIAL_ID = $filial";
		}
		$this->XML = "<report>
<attr value=\"table_type\">custom</attr>
<attr value=\"tables\"><attr value=\"0\">SQL_CP_PagamentosPeriodo</attr>
</attr>
<attr value=\"miscellaneous\"><attr value=\"type\">stepped</attr>
<attr value=\"print_friendly\">true</attr>
<attr value=\"lines_num\">30</attr>
</attr>
<attr value=\"settings\"><attr value=\"name\">CP_PagamentosPeriodo</attr>
<attr value=\"title\">Contas Pagas no Periodo</attr>
<attr value=\"status\">public</attr>
</attr>
<attr value=\"owner\">admin</attr>
<attr value=\"tmp_active\"></attr>
<attr value=\"table_name\">SQL_CP_PagamentosPeriodo</attr>
<attr value=\"short_table_name\"></attr>
<attr value=\"sql\">SELECT   
            COD_PARCELAMENTO AS F_LANCA_CP2_ID,
            F_LANCA_CP2.VALOR,
            (
                SELECT *
                FROM SP_CONVERTER_CARACTER(BANCO.NOME)
            )   AS NOME_CONTA,
            (
                SELECT *
                FROM SP_CONVERTER_CARACTER(SUBCATEGORIA.SUBCATEGORIA)
            )   AS SUBCATEGORIA,
            (
                SELECT *
                FROM SP_CONVERTER_CARACTER(FORNECEDOR.RAZAO_SOCIAL)
            )   AS RAZAO_SOCIAL,
            (
            SELECT *
            FROM SP_CONVERTER_CARACTER(F.NOME_FILIAL)
            )   AS NOME_FILIAL,
           (SUBSTRING(CP.RESUMO FROM 1 FOR 20)) AS RESUMO,
         DATA_VENCIMENTO,
         DATA_PAGAMENTO
            FROM   F_LANCA_CP CP
            INNER JOIN F_LANCA_CP2  ON (F_LANCA_CP2.F_LANCA_CP2_ID = (SELECT MAX(F_LANCA_CP2.F_LANCA_CP2_ID) FROM F_LANCA_CP2 WHERE F_LANCA_CP2.F_LANCA_CP = CP.F_LANCA_CP_ID))
            INNER JOIN F_STATUS_FINANCEIRO_CP   STATUS ON (STATUS.F_STATUS_FINANCEIRO_CP_ID = CP.F_STATUS_FINANCEIRO_CP_ID)
            INNER JOIN BANCO ON (BANCO.BANCO_ID = CP.BANCO_ID)
            LEFT JOIN FORNECEDOR  ON (FORNECEDOR.FORNECEDOR_ID = CP.FORNECEDOR_ID)
            LEFT JOIN SUBCATEGORIA ON (CP.SUBCATEGORIA_ID = SUBCATEGORIA.SUBCATEGORIA_ID)
            LEFT JOIN GRUPO_CAIXA GRUPO ON (GRUPO.GRUPO_CAIXA_ID = CP.GRUPO_CAIXA)
            INNER JOIN FILIAL F ON (F.filial_id = CP.cod_filial_id)
            WHERE  (CP.F_STATUS_FINANCEIRO_CP_ID = 2) $where</attr>
<attr value=\"sql_preview\">SELECT   
            COD_PARCELAMENTO AS F_LANCA_CP2_ID,
            F_LANCA_CP2.VALOR,
            (
                SELECT *
                FROM SP_CONVERTER_CARACTER(BANCO.NOME)
            )   AS NOME_CONTA,
            (
                SELECT *
                FROM SP_CONVERTER_CARACTER(SUBCATEGORIA.SUBCATEGORIA)
            )   AS SUBCATEGORIA,
            (
                SELECT *
                FROM SP_CONVERTER_CARACTER(FORNECEDOR.RAZAO_SOCIAL)
            )   AS RAZAO_SOCIAL,
            (
            SELECT *
            FROM SP_CONVERTER_CARACTER(F.NOME_FILIAL)
            )   AS NOME_FILIAL,
           (SUBSTRING(CP.RESUMO FROM 1 FOR 20)) AS RESUMO,
         DATA_VENCIMENTO,
         DATA_PAGAMENTO
            FROM   F_LANCA_CP CP
            INNER JOIN F_LANCA_CP2  ON (F_LANCA_CP2.F_LANCA_CP2_ID = (SELECT MAX(F_LANCA_CP2.F_LANCA_CP2_ID) FROM F_LANCA_CP2 WHERE F_LANCA_CP2.F_LANCA_CP = CP.F_LANCA_CP_ID))
            INNER JOIN F_STATUS_FINANCEIRO_CP   STATUS ON (STATUS.F_STATUS_FINANCEIRO_CP_ID = CP.F_STATUS_FINANCEIRO_CP_ID)
            INNER JOIN BANCO ON (BANCO.BANCO_ID = CP.BANCO_ID)
            LEFT JOIN FORNECEDOR  ON (FORNECEDOR.FORNECEDOR_ID = CP.FORNECEDOR_ID)
            LEFT JOIN SUBCATEGORIA ON (CP.SUBCATEGORIA_ID = SUBCATEGORIA.SUBCATEGORIA_ID)
            LEFT JOIN GRUPO_CAIXA GRUPO ON (GRUPO.GRUPO_CAIXA_ID = CP.GRUPO_CAIXA)
            INNER JOIN FILIAL F ON (F.filial_id = CP.cod_filial_id)
            WHERE  (CP.F_STATUS_FINANCEIRO_CP_ID = 2) $where</attr>
<attr value=\"where\"></attr>
<attr value=\"order_by\"> 
ORDER BY &quot;F_LANCA_CP2_ID&quot; ASC</attr>
<attr value=\"order_by_preview\"></attr>
<attr value=\"group_by\"></attr>
<attr value=\"style_editor\"><attr value=\"status\">success</attr>
</attr>
<attr value=\"group_fields\"><attr value=\"0\"><attr value=\"name\">Summary</attr>
<attr value=\"cross_table\">false</attr>
<attr value=\"sps\">false</attr>
<attr value=\"sds\">true</attr>
<attr value=\"sgs\">true</attr>
<attr value=\"sum_x\">true</attr>
<attr value=\"sum_y\">true</attr>
<attr value=\"sum_total\">true</attr>
</attr>
</attr>
<attr value=\"totals\"><attr value=\"SQL_CP_PagamentosPeriodo_F_LANCA_CP2_ID\"><attr value=\"name\">F_LANCA_CP2_ID</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Cod</attr>
<attr value=\"show\">true</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">false</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
<attr value=\"SQL_CP_PagamentosPeriodo_VALOR\"><attr value=\"name\">VALOR</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Valor</attr>
<attr value=\"show\">true</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">true</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">true</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\">Currency</attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
<attr value=\"SQL_CP_PagamentosPeriodo_NOME_CONTA\"><attr value=\"name\">NOME_CONTA</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Conta</attr>
<attr value=\"show\">true</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">false</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
<attr value=\"SQL_CP_PagamentosPeriodo_SUBCATEGORIA\"><attr value=\"name\">SUBCATEGORIA</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Categoria</attr>
<attr value=\"show\">true</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">false</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
<attr value=\"SQL_CP_PagamentosPeriodo_RAZAO_SOCIAL\"><attr value=\"name\">RAZAO_SOCIAL</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Fornecedor</attr>
<attr value=\"show\">true</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">false</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
<attr value=\"SQL_CP_PagamentosPeriodo_RESUMO\"><attr value=\"name\">RESUMO</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Resumo</attr>
<attr value=\"show\">true</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">false</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
<attr value=\"SQL_CP_PagamentosPeriodo_DATA_VENCIMENTO\"><attr value=\"name\">DATA_VENCIMENTO</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Dt. Vencimento</attr>
<attr value=\"show\">true</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">false</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
<attr value=\"SQL_CP_PagamentosPeriodo_DATA_PAGAMENTO\"><attr value=\"name\">DATA_PAGAMENTO</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Dt. Pagamento</attr>
<attr value=\"show\">true</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">false</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
<attr value=\"SQL_CP_PagamentosPeriodo_NOME_FILIAL\"><attr value=\"name\">NOME_FILIAL</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Filial</attr>
<attr value=\"show\">true</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">false</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
</attr>
<attr value=\"sort_fields\"><attr value=\"0\"><attr value=\"name\">F_LANCA_CP2_ID</attr>
<attr value=\"desc\">false</attr>
</attr>
</attr>
</report>";
		parent::execute_query("UPDATE \"webreports\" SET \"webreports\".\"rpt_content\" = '" . $this->XML . "'WHERE \"webreports\".\"rpt_name\" ='CP_PagamentosPeriodo'");
		//parent::gravaQueryArquivo("UPDATE \"webreports\" SET \"webreports\".\"rpt_content\" = '".$this->XML."' \"WHERE \"webreports\".\"rpt_name\" =\"CP_PagamentosPeriodo\"");
		break;
	    case "CP_VencerPeriodo":
		$dataInicial = empty($dados['data_ini_filtro']) ? $this->dataInicial : $this->data->convertDataSql($dados['data_ini_filtro']);
		$dataFinal = empty($dados['data_fim_filtro']) ? $this->dataFinal : $this->data->convertDataSql($dados['data_fim_filtro']);
		$conta = $dados['contaCliente'];
		$cliente = $dados['pesquisaCliente'];
		$where = "AND DATA_VENCIMENTO BETWEEN ''$dataInicial''  AND ''$dataFinal''";
		$filial = $dados['filial'];
		if (!empty($cliente)) {
		    $where .=" AND fornecedor.fornecedor_id = $cliente ";
		}
		if (!empty($conta)) {
		    $where .="AND  BANCO.BANCO_ID = $conta";
		}
		if (!empty($filial)) {
		    $where .= " AND F.FILIAL_ID = $filial";
		}

		$this->XML = "<report>
<attr value=\"table_type\">custom</attr>
<attr value=\"tables\"><attr value=\"0\">SQL_CP_VencerPeriodo</attr>
</attr>
<attr value=\"group_fields\"><attr value=\"0\"><attr value=\"name\">Summary</attr>
<attr value=\"cross_table\">false</attr>
<attr value=\"sps\">true</attr>
<attr value=\"sds\">true</attr>
<attr value=\"sgs\">true</attr>
<attr value=\"sum_x\">true</attr>
<attr value=\"sum_y\">true</attr>
<attr value=\"sum_total\">true</attr>
</attr>
</attr>
<attr value=\"totals\"><attr value=\"SQL_CP_VencerPeriodo_F_LANCA_CP2_ID\"><attr value=\"name\">F_LANCA_CP2_ID</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Cod</attr>
<attr value=\"show\">true</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">false</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
<attr value=\"SQL_CP_VencerPeriodo_RAZAO_SOCIAL\"><attr value=\"name\">RAZAO_SOCIAL</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Fornecedor</attr>
<attr value=\"show\">true</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">false</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
<attr value=\"SQL_CP_VencerPeriodo_RESUMO\"><attr value=\"name\">RESUMO</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Resumo</attr>
<attr value=\"show\">true</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">false</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
<attr value=\"SQL_CP_VencerPeriodo_VALOR\"><attr value=\"name\">VALOR</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Valor</attr>
<attr value=\"show\">true</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">true</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">true</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\">Currency</attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
<attr value=\"SQL_CP_VencerPeriodo_DATA_VENCIMENTO\"><attr value=\"name\">DATA_VENCIMENTO</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Dt. Vencimento</attr>
<attr value=\"show\">true</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">false</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
<attr value=\"SQL_CP_VencerPeriodo_NOME_CONTA\"><attr value=\"name\">NOME_CONTA</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Conta Previsao</attr>
<attr value=\"show\">true</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">false</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
<attr value=\"SQL_CP_VencerPeriodo_SUBCATEGORIA\"><attr value=\"name\">SUBCATEGORIA</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Categoria</attr>
<attr value=\"show\">false</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">false</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
<attr value=\"SQL_CP_VencerPeriodo_GRUPO\"><attr value=\"name\">GRUPO</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Centro Despesa</attr>
<attr value=\"show\">true</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">false</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
<attr value=\"SQL_CP_VencerPeriodo_NOME_FILIAL\"><attr value=\"name\">NOME_FILIAL</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Filial</attr>
<attr value=\"show\">true</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">false</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
</attr>
<attr value=\"sort_fields\"><attr value=\"0\"><attr value=\"name\">RAZAO_SOCIAL</attr>
<attr value=\"desc\">false</attr>
</attr>
</attr>
<attr value=\"miscellaneous\"><attr value=\"type\">stepped</attr>
<attr value=\"print_friendly\">true</attr>
<attr value=\"lines_num\">30</attr>
</attr>
<attr value=\"settings\"><attr value=\"name\">CP_VencerPeriodo</attr>
<attr value=\"title\">Contas a Pagar no Periodo</attr>
<attr value=\"status\">public</attr>
</attr>
<attr value=\"owner\">admin</attr>
<attr value=\"tmp_active\"></attr>
<attr value=\"table_name\">SQL_CP_VencerPeriodo</attr>
<attr value=\"short_table_name\"></attr>
<attr value=\"sql\">SELECT   
            COD_PARCELAMENTO AS F_LANCA_CP2_ID,
            F_LANCA_CP2.VALOR,
            (
                SELECT *
                FROM SP_CONVERTER_CARACTER(BANCO.NOME)
            )   AS NOME_CONTA,
            (
                SELECT *
                FROM SP_CONVERTER_CARACTER(SUBCATEGORIA.SUBCATEGORIA)
            )   AS SUBCATEGORIA,
            (
                SELECT *
                FROM SP_CONVERTER_CARACTER(FORNECEDOR.RAZAO_SOCIAL)
            )   AS RAZAO_SOCIAL,
            (
                SELECT *
                FROM SP_CONVERTER_CARACTER(F.NOME_FILIAL)
             )   AS NOME_FILIAL,
             GRUPO.GRUPO,
            SUBSTRING(CP.RESUMO FROM 1 FOR 20) AS RESUMO,
            DATA_VENCIMENTO
            FROM   F_LANCA_CP CP
            INNER JOIN F_LANCA_CP2  ON (F_LANCA_CP2.F_LANCA_CP2_ID = (SELECT MAX(F_LANCA_CP2.F_LANCA_CP2_ID) FROM F_LANCA_CP2 WHERE F_LANCA_CP2.F_LANCA_CP = CP.F_LANCA_CP_ID))
            INNER JOIN F_STATUS_FINANCEIRO_CP   STATUS ON (STATUS.F_STATUS_FINANCEIRO_CP_ID = CP.F_STATUS_FINANCEIRO_CP_ID)
            INNER JOIN BANCO ON (BANCO.BANCO_ID = CP.BANCO_ID)
            LEFT JOIN FORNECEDOR  ON (FORNECEDOR.FORNECEDOR_ID = CP.FORNECEDOR_ID)
            LEFT JOIN SUBCATEGORIA ON (CP.SUBCATEGORIA_ID = SUBCATEGORIA.SUBCATEGORIA_ID)
            LEFT JOIN GRUPO_CAIXA GRUPO ON (GRUPO.GRUPO_CAIXA_ID = CP.GRUPO_CAIXA)
            INNER JOIN FILIAL F ON (F.FILIAL_ID = CP.COD_FILIAL_ID)
            WHERE  (CP.F_STATUS_FINANCEIRO_CP_ID = 1) $where</attr>
<attr value=\"sql_preview\">SELECT   
            COD_PARCELAMENTO AS F_LANCA_CP2_ID,
            F_LANCA_CP2.VALOR,
            (
                SELECT *
                FROM SP_CONVERTER_CARACTER(BANCO.NOME)
            )   AS NOME_CONTA,
            (
                SELECT *
                FROM SP_CONVERTER_CARACTER(SUBCATEGORIA.SUBCATEGORIA)
            )   AS SUBCATEGORIA,
            (
                SELECT *
                FROM SP_CONVERTER_CARACTER(FORNECEDOR.RAZAO_SOCIAL)
            )   AS RAZAO_SOCIAL,
            (
                SELECT *
                FROM SP_CONVERTER_CARACTER(F.NOME_FILIAL)
             )   AS NOME_FILIAL,
             GRUPO.GRUPO,
            SUBSTRING(CP.RESUMO FROM 1 FOR 20) AS RESUMO,
            DATA_VENCIMENTO
            FROM   F_LANCA_CP CP
            INNER JOIN F_LANCA_CP2  ON (F_LANCA_CP2.F_LANCA_CP2_ID = (SELECT MAX(F_LANCA_CP2.F_LANCA_CP2_ID) FROM F_LANCA_CP2 WHERE F_LANCA_CP2.F_LANCA_CP = CP.F_LANCA_CP_ID))
            INNER JOIN F_STATUS_FINANCEIRO_CP   STATUS ON (STATUS.F_STATUS_FINANCEIRO_CP_ID = CP.F_STATUS_FINANCEIRO_CP_ID)
            INNER JOIN BANCO ON (BANCO.BANCO_ID = CP.BANCO_ID)
            LEFT JOIN FORNECEDOR  ON (FORNECEDOR.FORNECEDOR_ID = CP.FORNECEDOR_ID)
            LEFT JOIN SUBCATEGORIA ON (CP.SUBCATEGORIA_ID = SUBCATEGORIA.SUBCATEGORIA_ID)
            LEFT JOIN GRUPO_CAIXA GRUPO ON (GRUPO.GRUPO_CAIXA_ID = CP.GRUPO_CAIXA)
            INNER JOIN FILIAL F ON (F.FILIAL_ID = CP.COD_FILIAL_ID)
            WHERE  (CP.F_STATUS_FINANCEIRO_CP_ID = 1) $where</attr>
<attr value=\"where\"></attr>
<attr value=\"order_by\"> 
ORDER BY &quot;RAZAO_SOCIAL&quot; ASC</attr>
<attr value=\"order_by_preview\"></attr>
<attr value=\"group_by\"></attr>
<attr value=\"permissions\"><attr value=\"0\"><attr value=\"id\">Guest</attr>
<attr value=\"name\">Guest</attr>
<attr value=\"view\">false</attr>
<attr value=\"edit\">false</attr>
</attr>
<attr value=\"1\"><attr value=\"id\">admin</attr>
<attr value=\"name\">admin</attr>
<attr value=\"view\">false</attr>
<attr value=\"edit\">false</attr>
</attr>
</attr>
</report>
";

		parent::execute_query("UPDATE \"webreports\" SET \"webreports\".\"rpt_content\" = '" . $this->XML . "'WHERE \"webreports\".\"rpt_name\" ='CP_VencerPeriodo'");
		break;
	    case "CP_PagamentosCategoria":
		$dataInicial = empty($dados['data_ini_filtro']) ? $this->dataInicial : $this->data->convertDataSql($dados['data_ini_filtro']);
		$dataFinal = empty($dados['data_fim_filtro']) ? $this->dataFinal : $this->data->convertDataSql($dados['data_fim_filtro']);
		$conta = $dados['contaCliente'];
		$cliente = $dados['pesquisaCliente'];
		$subCategoria = $dados['subCategoria'];
		if ($dados['dataPesquisa'] == 1) {
		    $where = "AND DATA_VENCIMENTO BETWEEN ''$dataInicial''  AND ''$dataFinal''";
		} else if ($dados['dataPesquisa'] == 2) {
		    $where = "AND DATA_PAGAMENTO BETWEEN ''$dataInicial''  AND ''$dataFinal''";
		} else {
		    $where = "AND DATA_VENCIMENTO BETWEEN ''$dataInicial''  AND ''$dataFinal''";
		}
		if (!empty($cliente)) {
		    $where .=" AND fornecedor.fornecedor_id = $cliente ";
		}
		if (!empty($conta)) {
		    $where .="AND  BANCO.BANCO_ID = $conta";
		}
		if (!empty($subCategoria)) {
		    $where .=" AND SUBCATEGORIA.SUBCATEGORIA_ID = $subCategoria";
		}
		$this->XML = "<report>
<attr value=\"table_type\">custom</attr>
<attr value=\"tables\"><attr value=\"0\">SQL_CP_PagamentosCategoria</attr>
</attr>
<attr value=\"group_fields\"><attr value=\"0\"><attr value=\"name\">SUBCATEGORIA</attr>
<attr value=\"int_type\">0</attr>
<attr value=\"ss\">true</attr>
<attr value=\"group_order\">1</attr>
<attr value=\"group_type\">x</attr>
<attr value=\"color1\">CCCCCC</attr>
<attr value=\"color2\">ADADAD</attr>
</attr>
<attr value=\"1\"><attr value=\"name\">Summary</attr>
<attr value=\"cross_table\">false</attr>
<attr value=\"sps\">true</attr>
<attr value=\"sds\">true</attr>
<attr value=\"sgs\">true</attr>
<attr value=\"sum_x\">true</attr>
<attr value=\"sum_y\">true</attr>
<attr value=\"sum_total\">true</attr>
</attr>
</attr>
<attr value=\"totals\"><attr value=\"SQL_CP_PagamentosCategoria_SUBCATEGORIA\"><attr value=\"name\">SUBCATEGORIA</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Categoria</attr>
<attr value=\"show\">true</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">false</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
<attr value=\"SQL_CP_PagamentosCategoria_F_LANCA_CP2_ID\"><attr value=\"name\">F_LANCA_CP2_ID</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Cod</attr>
<attr value=\"show\">false</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">false</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
<attr value=\"SQL_CP_PagamentosCategoria_VALOR\"><attr value=\"name\">VALOR</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Valor</attr>
<attr value=\"show\">true</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">true</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">true</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\">Currency</attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
<attr value=\"SQL_CP_PagamentosCategoria_NOME_CONTA\"><attr value=\"name\">NOME_CONTA</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Conta</attr>
<attr value=\"show\">true</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">false</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
<attr value=\"SQL_CP_PagamentosCategoria_RAZAO_SOCIAL\"><attr value=\"name\">RAZAO_SOCIAL</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Fornecedor</attr>
<attr value=\"show\">true</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">false</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
<attr value=\"SQL_CP_PagamentosCategoria_RESUMO\"><attr value=\"name\">RESUMO</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Resumo</attr>
<attr value=\"show\">true</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">false</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
<attr value=\"SQL_CP_PagamentosCategoria_DATA_VENCIMENTO\"><attr value=\"name\">DATA_VENCIMENTO</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Dt.Vencimento</attr>
<attr value=\"show\">true</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">false</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
<attr value=\"SQL_CP_PagamentosCategoria_DATA_PAGAMENTO\"><attr value=\"name\">DATA_PAGAMENTO</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Dt .Pagamento</attr>
<attr value=\"show\">true</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">false</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
<attr value=\"SQL_CP_PagamentosCategoria_NOME_FILIAL\"><attr value=\"name\">NOME_FILIAL</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Filial</attr>
<attr value=\"show\">true</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">false</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
</attr>
<attr value=\"sort_fields\"><attr value=\"0\"><attr value=\"name\">SUBCATEGORIA</attr>
<attr value=\"desc\">false</attr>
</attr>
<attr value=\"1\"><attr value=\"name\">DATA_VENCIMENTO</attr>
<attr value=\"desc\">false</attr>
</attr>
<attr value=\"2\"><attr value=\"name\">RAZAO_SOCIAL</attr>
<attr value=\"desc\">false</attr>
</attr>
</attr>
<attr value=\"miscellaneous\"><attr value=\"type\">stepped</attr>
<attr value=\"print_friendly\">true</attr>
<attr value=\"lines_num\">30</attr>
</attr>
<attr value=\"settings\"><attr value=\"name\">CP_PagamentosCategoria</attr>
<attr value=\"title\">Pagamentos Efetuados no Periodo (Agrupado por Categoria)</attr>
<attr value=\"status\">public</attr>
</attr>
<attr value=\"owner\">admin</attr>
<attr value=\"tmp_active\"></attr>
<attr value=\"table_name\">SQL_CP_PagamentosCategoria</attr>
<attr value=\"short_table_name\"></attr>
<attr value=\"sql\">SELECT   
            COD_PARCELAMENTO AS F_LANCA_CP2_ID,
            F_LANCA_CP2.VALOR,
            (
                SELECT *
                FROM SP_CONVERTER_CARACTER(BANCO.NOME)
            )   AS NOME_CONTA,
            (
                SELECT *
                FROM SP_CONVERTER_CARACTER(SUBCATEGORIA.SUBCATEGORIA)
            )   AS SUBCATEGORIA,
            (
                SELECT *
                FROM SP_CONVERTER_CARACTER(FORNECEDOR.RAZAO_SOCIAL)
            )   AS RAZAO_SOCIAL,
              SUBSTRING(CP.RESUMO FROM 1 FOR 20)AS RESUMO,
         DATA_VENCIMENTO,
         (
                SELECT *
                FROM SP_CONVERTER_CARACTER(F.NOME_FILIAL)
            )   AS NOME_FILIAL,
       DATA_PAGAMENTO
            FROM   F_LANCA_CP CP
            INNER JOIN F_LANCA_CP2  ON (F_LANCA_CP2.F_LANCA_CP2_ID = (SELECT MAX(F_LANCA_CP2.F_LANCA_CP2_ID) FROM F_LANCA_CP2 WHERE F_LANCA_CP2.F_LANCA_CP = CP.F_LANCA_CP_ID))
            INNER JOIN F_STATUS_FINANCEIRO_CP   STATUS ON (STATUS.F_STATUS_FINANCEIRO_CP_ID = CP.F_STATUS_FINANCEIRO_CP_ID)
            INNER JOIN BANCO ON (BANCO.BANCO_ID = CP.BANCO_ID)
            LEFT JOIN FORNECEDOR  ON (FORNECEDOR.FORNECEDOR_ID = CP.FORNECEDOR_ID)
            LEFT JOIN SUBCATEGORIA ON (CP.SUBCATEGORIA_ID = SUBCATEGORIA.SUBCATEGORIA_ID)
            LEFT JOIN GRUPO_CAIXA GRUPO ON (GRUPO.GRUPO_CAIXA_ID = CP.GRUPO_CAIXA)
            INNER JOIN FILIAL F ON (F.FILIAL_ID = CP.COD_FILIAL_ID)
            WHERE  (CP.F_STATUS_FINANCEIRO_CP_ID = 2) $where</attr>
<attr value=\"sql_preview\">SELECT   
            COD_PARCELAMENTO AS F_LANCA_CP2_ID,
            F_LANCA_CP2.VALOR,
            (
                SELECT *
                FROM SP_CONVERTER_CARACTER(BANCO.NOME)
            )   AS NOME_CONTA,
            (
                SELECT *
                FROM SP_CONVERTER_CARACTER(SUBCATEGORIA.SUBCATEGORIA)
            )   AS SUBCATEGORIA,
            (
                SELECT *
                FROM SP_CONVERTER_CARACTER(FORNECEDOR.RAZAO_SOCIAL)
            )   AS RAZAO_SOCIAL,
              SUBSTRING(CP.RESUMO FROM 1 FOR 20)AS RESUMO,
         DATA_VENCIMENTO,
         (
                SELECT *
                FROM SP_CONVERTER_CARACTER(F.NOME_FILIAL)
            )   AS NOME_FILIAL,
       DATA_PAGAMENTO
            FROM   F_LANCA_CP CP
            INNER JOIN F_LANCA_CP2  ON (F_LANCA_CP2.F_LANCA_CP2_ID = (SELECT MAX(F_LANCA_CP2.F_LANCA_CP2_ID) FROM F_LANCA_CP2 WHERE F_LANCA_CP2.F_LANCA_CP = CP.F_LANCA_CP_ID))
            INNER JOIN F_STATUS_FINANCEIRO_CP   STATUS ON (STATUS.F_STATUS_FINANCEIRO_CP_ID = CP.F_STATUS_FINANCEIRO_CP_ID)
            INNER JOIN BANCO ON (BANCO.BANCO_ID = CP.BANCO_ID)
            LEFT JOIN FORNECEDOR  ON (FORNECEDOR.FORNECEDOR_ID = CP.FORNECEDOR_ID)
            LEFT JOIN SUBCATEGORIA ON (CP.SUBCATEGORIA_ID = SUBCATEGORIA.SUBCATEGORIA_ID)
            LEFT JOIN GRUPO_CAIXA GRUPO ON (GRUPO.GRUPO_CAIXA_ID = CP.GRUPO_CAIXA)
            INNER JOIN FILIAL F ON (F.FILIAL_ID = CP.COD_FILIAL_ID)
            WHERE  (CP.F_STATUS_FINANCEIRO_CP_ID = 2) $where</attr>
<attr value=\"where\"></attr>
<attr value=\"order_by\"> 
ORDER BY &quot;SUBCATEGORIA&quot; ASC, &quot;DATA_VENCIMENTO&quot; ASC, &quot;RAZAO_SOCIAL&quot; ASC</attr>
<attr value=\"order_by_preview\"></attr>
<attr value=\"group_by\"></attr>
<attr value=\"permissions\"><attr value=\"0\"><attr value=\"id\">Guest</attr>
<attr value=\"name\">Guest</attr>
<attr value=\"view\">false</attr>
<attr value=\"edit\">false</attr>
</attr>
<attr value=\"1\"><attr value=\"id\">admin</attr>
<attr value=\"name\">admin</attr>
<attr value=\"view\">false</attr>
<attr value=\"edit\">false</attr>
</attr>
</attr>
<attr value=\"style_editor\"><attr value=\"status\">success</attr>
</attr>
</report>
";
		parent::execute_query("UPDATE \"webreports\" SET \"webreports\".\"rpt_content\" = '" . $this->XML . "'WHERE \"webreports\".\"rpt_name\" ='CP_PagamentosCategoria'");
		break;
	    case "CP_PagamentosFornecedor":
		$dataInicial = empty($dados['data_ini_filtro']) ? $this->dataInicial : $this->data->convertDataSql($dados['data_ini_filtro']);
		$dataFinal = empty($dados['data_fim_filtro']) ? $this->dataFinal : $this->data->convertDataSql($dados['data_fim_filtro']);
		$conta = $dados['contaCliente'];
		$cliente = $dados['pesquisaCliente'];
		$filial = $dados['filial'];
		if ($dados['dataPesquisa'] == 1) {
		    $where = "AND DATA_VENCIMENTO BETWEEN ''$dataInicial''  AND ''$dataFinal''";
		} else if ($dados['dataPesquisa'] == 2) {
		    $where = "AND DATA_PAGAMENTO BETWEEN ''$dataInicial''  AND ''$dataFinal''";
		} else {
		    $where = "AND DATA_VENCIMENTO BETWEEN ''$dataInicial''  AND ''$dataFinal''";
		}
		if (!empty($cliente)) {
		    $where .=" AND fornecedor.fornecedor_id = $cliente ";
		}
		if (!empty($conta)) {
		    $where .="AND  BANCO.BANCO_ID = $conta";
		}
		if (!empty($filial)) {
		    $where .= " AND F.FILIAL_ID = $filial";
		}
		$this->XML = "<report>
<attr value=\"table_type\">custom</attr>
<attr value=\"tables\"><attr value=\"0\">SQL_CP_PagamentosFornecedor</attr>
</attr>
<attr value=\"group_fields\"><attr value=\"0\"><attr value=\"name\">RAZAO_SOCIAL</attr>
<attr value=\"int_type\">0</attr>
<attr value=\"ss\">true</attr>
<attr value=\"group_order\">1</attr>
<attr value=\"group_type\">x</attr>
<attr value=\"color1\">CCCCCC</attr>
<attr value=\"color2\">ADADAD</attr>
</attr>
<attr value=\"1\"><attr value=\"name\">Summary</attr>
<attr value=\"cross_table\">false</attr>
<attr value=\"sps\">true</attr>
<attr value=\"sds\">true</attr>
<attr value=\"sgs\">true</attr>
<attr value=\"sum_x\">true</attr>
<attr value=\"sum_y\">true</attr>
<attr value=\"sum_total\">true</attr>
</attr>
</attr>
<attr value=\"totals\"><attr value=\"SQL_CP_PagamentosFornecedor_RAZAO_SOCIAL\"><attr value=\"name\">RAZAO_SOCIAL</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Razao Social</attr>
<attr value=\"show\">true</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">false</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
<attr value=\"SQL_CP_PagamentosFornecedor_F_LANCA_CP2_ID\"><attr value=\"name\">F_LANCA_CP2_ID</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Cod</attr>
<attr value=\"show\">true</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">false</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
<attr value=\"SQL_CP_PagamentosFornecedor_RESUMO\"><attr value=\"name\">RESUMO</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Resumo</attr>
<attr value=\"show\">true</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">false</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
<attr value=\"SQL_CP_PagamentosFornecedor_VALOR\"><attr value=\"name\">VALOR</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Valor</attr>
<attr value=\"show\">true</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">true</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">true</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\">Currency</attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
<attr value=\"SQL_CP_PagamentosFornecedor_DATA_VENCIMENTO\"><attr value=\"name\">DATA_VENCIMENTO</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Dt. Vencimento</attr>
<attr value=\"show\">true</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">false</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
<attr value=\"SQL_CP_PagamentosFornecedor_DATA_PAGAMENTO\"><attr value=\"name\">DATA_PAGAMENTO</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Dt. Pagamento</attr>
<attr value=\"show\">true</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">false</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
<attr value=\"SQL_CP_PagamentosFornecedor_NOME_CONTA\"><attr value=\"name\">NOME_CONTA</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Conta</attr>
<attr value=\"show\">true</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">false</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
<attr value=\"SQL_CP_PagamentosFornecedor_SUBCATEGORIA\"><attr value=\"name\">SUBCATEGORIA</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">SUBCATEGORIA</attr>
<attr value=\"show\">false</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">false</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
<attr value=\"SQL_CP_PagamentosFornecedor_NOME_FILIAL\"><attr value=\"name\">NOME_FILIAL</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Filial</attr>
<attr value=\"show\">true</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">false</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
</attr>
<attr value=\"sort_fields\"><attr value=\"0\"><attr value=\"name\">RAZAO_SOCIAL</attr>
<attr value=\"desc\">false</attr>
</attr>
<attr value=\"1\"><attr value=\"name\">RESUMO</attr>
<attr value=\"desc\">false</attr>
</attr>
</attr>
<attr value=\"miscellaneous\"><attr value=\"type\">stepped</attr>
<attr value=\"print_friendly\">true</attr>
<attr value=\"lines_num\">30</attr>
</attr>
<attr value=\"settings\"><attr value=\"name\">CP_PagamentosFornecedor</attr>
<attr value=\"title\">Pagamentos Efetuados no Periodo (Agrupado por Fornecedor)</attr>
<attr value=\"status\">public</attr>
</attr>
<attr value=\"owner\">admin</attr>
<attr value=\"tmp_active\"></attr>
<attr value=\"table_name\">SQL_CP_PagamentosFornecedor</attr>
<attr value=\"short_table_name\"></attr>
<attr value=\"sql\">SELECT   
            COD_PARCELAMENTO AS F_LANCA_CP2_ID,
            F_LANCA_CP2.VALOR,
            (
                SELECT *
                FROM SP_CONVERTER_CARACTER(BANCO.NOME)
            )   AS NOME_CONTA,
            (
                SELECT *
                FROM SP_CONVERTER_CARACTER(SUBCATEGORIA.SUBCATEGORIA)
            )   AS SUBCATEGORIA,
            (
                SELECT *
                FROM SP_CONVERTER_CARACTER(FORNECEDOR.RAZAO_SOCIAL)
            )   AS RAZAO_SOCIAL,
            (
                SELECT *
                FROM SP_CONVERTER_CARACTER(F.NOME_FILIAL)
             )   AS NOME_FILIAL,
        SUBSTRING(CP.RESUMO FROM 1 FOR 20)AS RESUMO,
         DATA_VENCIMENTO,
         DATA_PAGAMENTO
            FROM   F_LANCA_CP CP
            INNER JOIN F_LANCA_CP2  ON (F_LANCA_CP2.F_LANCA_CP2_ID = (SELECT MAX(F_LANCA_CP2.F_LANCA_CP2_ID) FROM F_LANCA_CP2 WHERE F_LANCA_CP2.F_LANCA_CP = CP.F_LANCA_CP_ID))
            INNER JOIN F_STATUS_FINANCEIRO_CP   STATUS ON (STATUS.F_STATUS_FINANCEIRO_CP_ID = CP.F_STATUS_FINANCEIRO_CP_ID)
            INNER JOIN BANCO ON (BANCO.BANCO_ID = CP.BANCO_ID)
            LEFT JOIN FORNECEDOR  ON (FORNECEDOR.FORNECEDOR_ID = CP.FORNECEDOR_ID)
            LEFT JOIN SUBCATEGORIA ON (CP.SUBCATEGORIA_ID = SUBCATEGORIA.SUBCATEGORIA_ID)
            LEFT JOIN GRUPO_CAIXA GRUPO ON (GRUPO.GRUPO_CAIXA_ID = CP.GRUPO_CAIXA)
            INNER JOIN FILIAL F ON (F.FILIAL_ID = CP.COD_FILIAL_ID)
            WHERE  (CP.F_STATUS_FINANCEIRO_CP_ID = 2) $where</attr>
<attr value=\"sql_preview\">SELECT   
            COD_PARCELAMENTO AS F_LANCA_CP2_ID,
            F_LANCA_CP2.VALOR,
            (
                SELECT *
                FROM SP_CONVERTER_CARACTER(BANCO.NOME)
            )   AS NOME_CONTA,
            (
                SELECT *
                FROM SP_CONVERTER_CARACTER(SUBCATEGORIA.SUBCATEGORIA)
            )   AS SUBCATEGORIA,
            (
                SELECT *
                FROM SP_CONVERTER_CARACTER(FORNECEDOR.RAZAO_SOCIAL)
            )   AS RAZAO_SOCIAL,
            (
                SELECT *
                FROM SP_CONVERTER_CARACTER(F.NOME_FILIAL)
             )   AS NOME_FILIAL,
        SUBSTRING(CP.RESUMO FROM 1 FOR 20)AS RESUMO,
         DATA_VENCIMENTO,
         DATA_PAGAMENTO
            FROM   F_LANCA_CP CP
            INNER JOIN F_LANCA_CP2  ON (F_LANCA_CP2.F_LANCA_CP2_ID = (SELECT MAX(F_LANCA_CP2.F_LANCA_CP2_ID) FROM F_LANCA_CP2 WHERE F_LANCA_CP2.F_LANCA_CP = CP.F_LANCA_CP_ID))
            INNER JOIN F_STATUS_FINANCEIRO_CP   STATUS ON (STATUS.F_STATUS_FINANCEIRO_CP_ID = CP.F_STATUS_FINANCEIRO_CP_ID)
            INNER JOIN BANCO ON (BANCO.BANCO_ID = CP.BANCO_ID)
            LEFT JOIN FORNECEDOR  ON (FORNECEDOR.FORNECEDOR_ID = CP.FORNECEDOR_ID)
            LEFT JOIN SUBCATEGORIA ON (CP.SUBCATEGORIA_ID = SUBCATEGORIA.SUBCATEGORIA_ID)
            LEFT JOIN GRUPO_CAIXA GRUPO ON (GRUPO.GRUPO_CAIXA_ID = CP.GRUPO_CAIXA)
            INNER JOIN FILIAL F ON (F.FILIAL_ID = CP.COD_FILIAL_ID)
            WHERE  (CP.F_STATUS_FINANCEIRO_CP_ID = 2) $where</attr>
<attr value=\"where\"></attr>
<attr value=\"order_by\"> 
ORDER BY &quot;RAZAO_SOCIAL&quot; ASC, &quot;RESUMO&quot; ASC</attr>
<attr value=\"order_by_preview\"></attr>
<attr value=\"group_by\"></attr>
</report>
";
		parent::execute_query("UPDATE \"webreports\" SET \"webreports\".\"rpt_content\" = '" . $this->XML . "'WHERE \"webreports\".\"rpt_name\" ='CP_PagamentosFornecedor'");
		break;

	    case "FAT_ResumoFechamento":
		$dataInicial = empty($dados['data_ini_filtro']) ? $this->dataInicial : $this->data->convertDataSql($dados['data_ini_filtro']);
		$dataFinal = empty($dados['data_fim_filtro']) ? $this->dataFinal : $this->data->convertDataSql($dados['data_fim_filtro']);
		$OrderBy = $dados['ordem'];
		$TabelaFechamento = $dados['tabelaFechamento'];

		$where = " AND FF.STATUS_FINANCEIRO = ''P'' AND (CAST(DATA_FECHAMENTO AS DATE)) BETWEEN ''$dataInicial''  AND ''$dataFinal''";

		if (isset($dados['ordem'])) {
		    if ($dados['ordem'] == 1) {
			$OrderBy = " ORDER BY EMP.RAZAO_SOCIAL ";
		    } else {
			$OrderBy = " ORDER BY NUMERO_FATURA_SIGMO ";
		    }
		}
		if ($TabelaFechamento > 0) {
		    $where .= "AND EMP.CONFIG_FECHAMENTO_ID = $TabelaFechamento";
		}



		$this->XML = "<report>
<attr value=\"table_type\">custom</attr>
<attr value=\"tables\"><attr value=\"0\">SQL_CR_ResumoFechamento</attr>
</attr>
<attr value=\"group_fields\"><attr value=\"0\"><attr value=\"name\">Summary</attr>
<attr value=\"cross_table\">false</attr>
<attr value=\"sps\">true</attr>
<attr value=\"sds\">true</attr>
<attr value=\"sgs\">true</attr>
<attr value=\"sum_x\">true</attr>
<attr value=\"sum_y\">true</attr>
<attr value=\"sum_total\">true</attr>
</attr>
</attr>
<attr value=\"totals\"><attr value=\"SQL_CR_ResumoFechamento_NUMERO_FATURA_SIGMO\"><attr value=\"name\">NUMERO_FATURA_SIGMO</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Nº Fechamento</attr>
<attr value=\"show\">true</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">false</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
<attr value=\"SQL_CR_ResumoFechamento_RAZAO_SOCIAL\"><attr value=\"name\">RAZAO_SOCIAL</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Razão Social</attr>
<attr value=\"show\">true</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">false</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
<attr value=\"SQL_CR_ResumoFechamento_TOTAL\"><attr value=\"name\">TOTAL</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Valor</attr>
<attr value=\"show\">true</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">true</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
<attr value=\"SQL_CR_ResumoFechamento_OBSERVACAO\"><attr value=\"name\">OBSERVACAO</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Obs</attr>
<attr value=\"show\">true</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">false</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
</attr>
<attr value=\"sort_fields\"><attr value=\"0\"><attr value=\"name\">RAZAO_SOCIAL</attr>
<attr value=\"desc\">false</attr>
</attr>
</attr>
<attr value=\"miscellaneous\"><attr value=\"type\">stepped</attr>
<attr value=\"print_friendly\">true</attr>
<attr value=\"lines_num\">30</attr>
</attr>
<attr value=\"settings\"><attr value=\"name\">FAT_ResumoFechamento</attr>
<attr value=\"title\">Resumo Faturamento</attr>
<attr value=\"status\">public</attr>
</attr>
<attr value=\"owner\">admin</attr>
<attr value=\"tmp_active\"></attr>
<attr value=\"table_name\">SQL_CR_ResumoFechamento</attr>
<attr value=\"short_table_name\"></attr>
<attr value=\"sql\">SELECT
DISTINCT
FF.NUMERO_FATURA_SIGMO,
CASE WHEN EMP.GRUPO_EMPRESA_ID IS NOT NULL  AND   EMPRESA_PADRAO_EMISSAO_BOLETO IS NOT NULL
       THEN
          (
          SELECT *
          FROM SP_CONVERTER_CARACTER((SELECT RAZAO_SOCIAL FROM EMPRESA WHERE EMPRESA_ID  =  EMPRESA_PADRAO_EMISSAO_BOLETO))
          )
       ELSE
       (
         SELECT *
         FROM SP_CONVERTER_CARACTER(EMP.RAZAO_SOCIAL)
        )

END AS RAZAO_SOCIAL ,


CASE WHEN EMP.GRUPO_EMPRESA_ID IS NOT NULL  AND   EMPRESA_PADRAO_EMISSAO_BOLETO IS NOT NULL
       THEN (SELECT SUM(VALOR_PERIODO) FROM F_FECHAMENTO_FATURA WHERE NUMERO_FATURA_SIGMO = FF.NUMERO_FATURA_SIGMO)
       ELSE
       FF.VALOR_PERIODO
END AS TOTAL,
FF.OBSERVACAO
FROM
F_FECHAMENTO_FATURA FF
INNER JOIN EMPRESA EMP ON (FF.EMPRESA_ID = EMP.EMPRESA_ID)
LEFT  JOIN CONFIG_FECHAMENTO CONF ON (CONF.CONFIG_FECHAMENTO_ID = EMP.CONFIG_FECHAMENTO_ID)
LEFT  JOIN GRUPO_EMPRESA GRUPO ON (GRUPO.GRUPO_EMPRESA_ID = EMP.GRUPO_EMPRESA_ID)  
LEFT  JOIN CONFIG_FECHAMENTO CONFIG_GRUPO ON (CONFIG_GRUPO.CONFIG_FECHAMENTO_ID = CONF.CONFIG_FECHAMENTO_ID)
WHERE 1=1 $where
$OrderBy</attr>
<attr value=\"sql_preview\">SELECT
DISTINCT
FF.NUMERO_FATURA_SIGMO,
CASE WHEN EMP.GRUPO_EMPRESA_ID IS NOT NULL  AND   EMPRESA_PADRAO_EMISSAO_BOLETO IS NOT NULL
       THEN
          (
          SELECT *
          FROM SP_CONVERTER_CARACTER((SELECT RAZAO_SOCIAL FROM EMPRESA WHERE EMPRESA_ID  =  EMPRESA_PADRAO_EMISSAO_BOLETO))
          )
       ELSE
       (
         SELECT *
         FROM SP_CONVERTER_CARACTER(EMP.RAZAO_SOCIAL)
        )

END AS RAZAO_SOCIAL ,
CASE WHEN EMP.GRUPO_EMPRESA_ID IS NOT NULL  AND   EMPRESA_PADRAO_EMISSAO_BOLETO IS NOT NULL
       THEN (SELECT SUM(VALOR_PERIODO) FROM F_FECHAMENTO_FATURA WHERE NUMERO_FATURA_SIGMO = FF.NUMERO_FATURA_SIGMO)
       ELSE
       FF.VALOR_PERIODO
END AS TOTAL,
FF.OBSERVACAO
FROM
F_FECHAMENTO_FATURA FF
INNER JOIN EMPRESA EMP ON (FF.EMPRESA_ID = EMP.EMPRESA_ID)
LEFT  JOIN CONFIG_FECHAMENTO CONF ON (CONF.CONFIG_FECHAMENTO_ID = EMP.CONFIG_FECHAMENTO_ID)
LEFT  JOIN GRUPO_EMPRESA GRUPO ON (GRUPO.GRUPO_EMPRESA_ID = EMP.GRUPO_EMPRESA_ID)  
LEFT  JOIN CONFIG_FECHAMENTO CONFIG_GRUPO ON (CONFIG_GRUPO.CONFIG_FECHAMENTO_ID = CONF.CONFIG_FECHAMENTO_ID)
WHERE 1=1 $where
$OrderBy </attr>
<attr value=\"where\"></attr>
<attr value=\"order_by\"> 
ORDER BY &quot;RAZAO_SOCIAL&quot; ASC</attr>
<attr value=\"order_by_preview\"></attr>
<attr value=\"group_by\"></attr>
<attr value=\"permissions\"><attr value=\"0\"><attr value=\"id\">Guest</attr>
<attr value=\"name\">Guest</attr>
<attr value=\"view\">false</attr>
<attr value=\"edit\">false</attr>
</attr>
<attr value=\"1\"><attr value=\"id\">admin</attr>
<attr value=\"name\">admin</attr>
<attr value=\"view\">false</attr>
<attr value=\"edit\">false</attr>
</attr>
</attr>
</report>";
		parent::execute_query("UPDATE \"webreports\" SET \"webreports\".\"rpt_content\" = '" . $this->XML . "'WHERE \"webreports\".\"rpt_name\" ='FAT_ResumoFechamento'");
		break;

	    case "FAT_NumeroFatura":
		$dataInicial = empty($dados['data_ini_filtro']) ? $this->dataInicial : $this->data->convertDataSql($dados['data_ini_filtro']);
		$dataFinal = empty($dados['data_fim_filtro']) ? $this->dataFinal : $this->data->convertDataSql($dados['data_fim_filtro']);
		$TabelaFechamento = $dados['tabelaFechamento'];

		$where = " AND  F_LANCA_CR2.DATA_VENCIMENTO BETWEEN ''$dataInicial''  AND ''$dataFinal'' ";

		if ($TabelaFechamento > 0) {
		    $where .= " AND EMP.CONFIG_FECHAMENTO_ID = $TabelaFechamento ";
		}



		$this->XML = "<report>
<attr value=\"table_type\">custom</attr>
<attr value=\"tables\"><attr value=\"0\">SQL_CR_NumeroFatura</attr>
</attr>
<attr value=\"miscellaneous\"><attr value=\"type\">stepped</attr>
<attr value=\"print_friendly\">true</attr>
<attr value=\"lines_num\">30</attr>
</attr>
<attr value=\"settings\"><attr value=\"name\">FAT_NumeroFatura</attr>
<attr value=\"title\">Faturas SIGMO</attr>
<attr value=\"status\">public</attr>
</attr>
<attr value=\"owner\">admin</attr>
<attr value=\"tmp_active\"></attr>
<attr value=\"table_name\">SQL_CR_NumeroFatura</attr>
<attr value=\"short_table_name\"></attr>
<attr value=\"sql\">SELECT   
        VALOR,
        COD_PARCELAMENTO AS COD,
        (
          SELECT *
           FROM SP_CONVERTER_CARACTER(SUBCATEGORIA.SUBCATEGORIA)
         ) AS SUBCATEGORIA,
         (
          SELECT *
            FROM SP_CONVERTER_CARACTER(EMP.RAZAO_SOCIAL)
         ) AS RAZAO_SOCIAL,
        DATA_VENCIMENTO,
        DATA_RECEBIMENTO,
        CR.NUMERO_FATURA_SIGMO
                FROM  F_LANCA_CR CR
                INNER JOIN F_LANCA_CR2  ON (F_LANCA_CR2.F_LANCA_CR2_ID = (SELECT MAX(CR2.F_LANCA_CR2_ID) FROM F_LANCA_CR2 CR2 WHERE CR2.F_LANCA_CR_ID = CR.F_LANCA_CR_ID))
                INNER JOIN F_STATUS_FINANCEIRO STATUS ON (STATUS.F_STATUS_FINANCEIRO_ID = CR.F_STATUS_FINANCEIRO_ID)
                LEFT JOIN EMPRESA  EMP ON (CR.EMPRESA_ID = EMP.EMPRESA_ID)
                LEFT JOIN SUBCATEGORIA ON (CR.SUBCATEGORIA_ID = SUBCATEGORIA.SUBCATEGORIA_ID)
                LEFT JOIN GRUPO_CAIXA GRUPO ON (GRUPO.GRUPO_CAIXA_ID = CR.GRUPO_CAIXA)
                INNER JOIN BANCO ON (CR.BANCO_ID = BANCO.BANCO_ID)
                INNER JOIN FILIAL F ON (F.FILIAL_ID = CR.COD_FILIAL_ID)
                WHERE CR.F_REF_LANCAMENTO_AGRUPADO IS NULL
                AND CR.NUMERO_FATURA_SIGMO IS NOT NULL
		$where
                GROUP BY
                CR.NUMERO_FATURA_SIGMO,
                EMP.RAZAO_SOCIAL,
                COD_PARCELAMENTO,
                DATA_VENCIMENTO,
                DATA_RECEBIMENTO,
                VALOR,
                SUBCATEGORIA.SUBCATEGORIA
		ORDER BY  CR.NUMERO_FATURA_SIGMO
</attr>
<attr value=\"sql_preview\">SELECT   
        VALOR,
        COD_PARCELAMENTO AS COD,
        (
          SELECT *
           FROM SP_CONVERTER_CARACTER(SUBCATEGORIA.SUBCATEGORIA)
         ) AS SUBCATEGORIA,
         (
          SELECT *
            FROM SP_CONVERTER_CARACTER(EMP.RAZAO_SOCIAL)
         ) AS RAZAO_SOCIAL,
        DATA_VENCIMENTO,
        DATA_RECEBIMENTO,
        CR.NUMERO_FATURA_SIGMO
                FROM  F_LANCA_CR CR
                INNER JOIN F_LANCA_CR2  ON (F_LANCA_CR2.F_LANCA_CR2_ID = (SELECT MAX(CR2.F_LANCA_CR2_ID) FROM F_LANCA_CR2 CR2 WHERE CR2.F_LANCA_CR_ID = CR.F_LANCA_CR_ID))
                INNER JOIN F_STATUS_FINANCEIRO STATUS ON (STATUS.F_STATUS_FINANCEIRO_ID = CR.F_STATUS_FINANCEIRO_ID)
                LEFT JOIN EMPRESA  EMP ON (CR.EMPRESA_ID = EMP.EMPRESA_ID)
                LEFT JOIN SUBCATEGORIA ON (CR.SUBCATEGORIA_ID = SUBCATEGORIA.SUBCATEGORIA_ID)
                LEFT JOIN GRUPO_CAIXA GRUPO ON (GRUPO.GRUPO_CAIXA_ID = CR.GRUPO_CAIXA)
                INNER JOIN BANCO ON (CR.BANCO_ID = BANCO.BANCO_ID)
                INNER JOIN FILIAL F ON (F.FILIAL_ID = CR.COD_FILIAL_ID)
                WHERE CR.F_REF_LANCAMENTO_AGRUPADO IS NULL
                AND CR.NUMERO_FATURA_SIGMO IS NOT NULL
		$where
                GROUP BY
                CR.NUMERO_FATURA_SIGMO,
                EMP.RAZAO_SOCIAL,
                COD_PARCELAMENTO,
                DATA_VENCIMENTO,
                DATA_RECEBIMENTO,
                VALOR,
                SUBCATEGORIA.SUBCATEGORIA
		ORDER BY CR.NUMERO_FATURA_SIGMO
</attr>
<attr value=\"where\"></attr>
<attr value=\"order_by\"> 
ORDER BY &quot;NUMERO_FATURA_SIGMO&quot; ASC, &quot;RAZAO_SOCIAL&quot; ASC</attr>
<attr value=\"order_by_preview\"></attr>
<attr value=\"group_by\"></attr>
<attr value=\"group_fields\"><attr value=\"0\"><attr value=\"name\">NUMERO_FATURA_SIGMO</attr>
<attr value=\"int_type\">0</attr>
<attr value=\"ss\">true</attr>
<attr value=\"group_order\">1</attr>
<attr value=\"group_type\">x</attr>
<attr value=\"color1\">CCCCCC</attr>
<attr value=\"color2\">ADADAD</attr>
</attr>
<attr value=\"1\"><attr value=\"name\">Summary</attr>
<attr value=\"cross_table\">false</attr>
<attr value=\"sps\">false</attr>
<attr value=\"sds\">true</attr>
<attr value=\"sgs\">true</attr>
<attr value=\"sum_x\">true</attr>
<attr value=\"sum_y\">true</attr>
<attr value=\"sum_total\">true</attr>
</attr>
</attr>
<attr value=\"totals\"><attr value=\"SQL_CR_NumeroFatura_NUMERO_FATURA_SIGMO\"><attr value=\"name\">NUMERO_FATURA_SIGMO</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Fatura</attr>
<attr value=\"show\">true</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">false</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
<attr value=\"SQL_CR_NumeroFatura_COD\"><attr value=\"name\">COD</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Cod</attr>
<attr value=\"show\">true</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">false</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
<attr value=\"SQL_CR_NumeroFatura_RAZAO_SOCIAL\"><attr value=\"name\">RAZAO_SOCIAL</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Empresa</attr>
<attr value=\"show\">true</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">false</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
<attr value=\"SQL_CR_NumeroFatura_DATA_VENCIMENTO\"><attr value=\"name\">DATA_VENCIMENTO</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Dt. Vencimento</attr>
<attr value=\"show\">true</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">false</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
<attr value=\"SQL_CR_NumeroFatura_DATA_RECEBIMENTO\"><attr value=\"name\">DATA_RECEBIMENTO</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Dt. Recebimento</attr>
<attr value=\"show\">true</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">false</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
<attr value=\"SQL_CR_NumeroFatura_SUBCATEGORIA\"><attr value=\"name\">SUBCATEGORIA</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Categoria</attr>
<attr value=\"show\">true</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">false</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
<attr value=\"SQL_CR_NumeroFatura_VALOR\"><attr value=\"name\">VALOR</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Valor</attr>
<attr value=\"show\">true</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">true</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
</attr>
<attr value=\"sort_fields\"><attr value=\"0\"><attr value=\"name\">NUMERO_FATURA_SIGMO</attr>
<attr value=\"desc\">false</attr>
</attr>
<attr value=\"1\"><attr value=\"name\">RAZAO_SOCIAL</attr>
<attr value=\"desc\">false</attr>
</attr>
</attr>
<attr value=\"permissions\"><attr value=\"0\"><attr value=\"id\">Guest</attr>
<attr value=\"name\">Guest</attr>
<attr value=\"view\">false</attr>
<attr value=\"edit\">false</attr>
</attr>
<attr value=\"1\"><attr value=\"id\">admin</attr>
<attr value=\"name\">admin</attr>
<attr value=\"view\">false</attr>
<attr value=\"edit\">false</attr>
</attr>
</attr>
</report>";
		parent::execute_query("UPDATE \"webreports\" SET \"webreports\".\"rpt_content\" = '" . $this->XML . "'WHERE \"webreports\".\"rpt_name\" ='FAT_NumeroFatura'");
		break;
	    case "CR_RecebimentosFormaPagamento":
		$dataInicial = empty($dados['data_ini_filtro']) ? $this->dataInicial : $this->data->convertDataSql($dados['data_ini_filtro']);
		$dataFinal = empty($dados['data_fim_filtro']) ? $this->dataFinal : $this->data->convertDataSql($dados['data_fim_filtro']);
		$conta = $dados['contaCliente'];
		$cliente = $dados['pesquisaCliente'];
		$formaPagamento = $dados['formaPagamento'];
		$filial = $dados['filial'];
		
		if ($dados['dataPesquisa'] == 1) {
		    $where = "AND DATA_VENCIMENTO BETWEEN ''$dataInicial''  AND ''$dataFinal''";
		} else if ($dados['dataPesquisa'] == 2) {
		    $where = "AND DATA_RECEBIMENTO BETWEEN ''$dataInicial''  AND ''$dataFinal''";
		} else {
		    $where = "AND DATA_VENCIMENTO BETWEEN ''$dataInicial''  AND ''$dataFinal''";
		}
		if (!empty($cliente)) {
		    $where .=" AND EMP.EMPRESA_ID = $cliente ";
		}
		if (!empty($conta)) {
		    $where .="AND  BANCO.BANCO_ID = $conta";
		}
		if (!empty($subCategoria)) {
		    $where .=" AND CP.F_FORMA_PAGAMENTO_ID = $formaPagamento";
		}
		if (!empty($filial)) {
		    $where .= " AND F.FILIAL_ID = $filial";
		}

		$this->XML = "<report>
<attr value=\"table_type\">custom</attr>
<attr value=\"tables\"><attr value=\"0\">SQL_CR_RecebimentosFormaPagamento</attr>
</attr>
<attr value=\"miscellaneous\"><attr value=\"type\">stepped</attr>
<attr value=\"print_friendly\">true</attr>
<attr value=\"lines_num\">30</attr>
</attr>
<attr value=\"settings\"><attr value=\"name\">CR_RecebimentosFormaPagamento</attr>
<attr value=\"title\">Recebimentos (Agrupado por Forma de Pagamento)</attr>
<attr value=\"status\">public</attr>
</attr>
<attr value=\"owner\">admin</attr>
<attr value=\"tmp_active\"></attr>
<attr value=\"table_name\">SQL_CR_RecebimentosFormaPagamento</attr>
<attr value=\"short_table_name\"></attr>
<attr value=\"sql\">SELECT
        VALOR,
        F_LANCA_CR2_ID AS COD,
        STATUS.NOME_STATUS,
        SUBSTRING(NOME_CONTA FROM 1 FOR 25) RESUMO,
        (
          SELECT *
           FROM SP_CONVERTER_CARACTER(SUBCATEGORIA.SUBCATEGORIA)
         ) AS SUBCATEGORIA,
         (
          SELECT *
           FROM SP_CONVERTER_CARACTER(FP.FORMA_PAGAMENTO)
         ) AS FORMA_PAGAMENTO,
         (
          SELECT *
            FROM SP_CONVERTER_CARACTER(EMP.RAZAO_SOCIAL)
         ) AS RAZAO_SOCIAL,
         (
          SELECT *
            FROM SP_CONVERTER_CARACTER(BANCO.NOME)
         ) AS NOME_CONTA,
          (
          SELECT *
            FROM SP_CONVERTER_CARACTER(FILIAL.NOME_FILIAL)
         ) AS NOME_FILIAL,
        DATA_VENCIMENTO,
       DATA_RECEBIMENTO
                FROM  F_LANCA_CR CR
                INNER JOIN F_LANCA_CR2  ON (F_LANCA_CR2.F_LANCA_CR2_ID = (SELECT MAX(CR2.F_LANCA_CR2_ID) FROM F_LANCA_CR2 CR2 WHERE CR2.F_LANCA_CR_ID = CR.F_LANCA_CR_ID))
                INNER JOIN F_STATUS_FINANCEIRO STATUS ON (STATUS.F_STATUS_FINANCEIRO_ID = CR.F_STATUS_FINANCEIRO_ID)
                LEFT JOIN EMPRESA  EMP ON (CR.EMPRESA_ID = EMP.EMPRESA_ID)
                LEFT JOIN SUBCATEGORIA ON (CR.SUBCATEGORIA_ID = SUBCATEGORIA.SUBCATEGORIA_ID)
                LEFT JOIN GRUPO_CAIXA GRUPO ON (GRUPO.GRUPO_CAIXA_ID = CR.GRUPO_CAIXA)
                INNER JOIN BANCO ON (CR.BANCO_ID = BANCO.BANCO_ID)
                INNER JOIN F_FORMA_PAGAMENTO FP ON (FP.F_FORMA_PAGAMENTO_ID = CR.F_FORMA_PAGAMENTO_ID)
                INNER JOIN FILIAL ON (FILIAL.FILIAL_ID = CR.COD_FILIAL_ID)
                WHERE CR.F_AGRUPAMENTO_CR_ID IS NULL
                AND (STATUS.F_STATUS_FINANCEIRO_ID = 3) 
		$where </attr>
<attr value=\"sql_preview\">SELECT
        VALOR,
        F_LANCA_CR2_ID AS COD,
        STATUS.NOME_STATUS,
        SUBSTRING(NOME_CONTA FROM 1 FOR 25) RESUMO,
        (
          SELECT *
           FROM SP_CONVERTER_CARACTER(SUBCATEGORIA.SUBCATEGORIA)
         ) AS SUBCATEGORIA,
         (
          SELECT *
           FROM SP_CONVERTER_CARACTER(FP.FORMA_PAGAMENTO)
         ) AS FORMA_PAGAMENTO,
         (
          SELECT *
            FROM SP_CONVERTER_CARACTER(EMP.RAZAO_SOCIAL)
         ) AS RAZAO_SOCIAL,
         (
          SELECT *
            FROM SP_CONVERTER_CARACTER(BANCO.NOME)
         ) AS NOME_CONTA,
          (
          SELECT *
            FROM SP_CONVERTER_CARACTER(FILIAL.NOME_FILIAL)
         ) AS NOME_FILIAL,
        DATA_VENCIMENTO,
       DATA_RECEBIMENTO
                FROM  F_LANCA_CR CR
                INNER JOIN F_LANCA_CR2  ON (F_LANCA_CR2.F_LANCA_CR2_ID = (SELECT MAX(CR2.F_LANCA_CR2_ID) FROM F_LANCA_CR2 CR2 WHERE CR2.F_LANCA_CR_ID = CR.F_LANCA_CR_ID))
                INNER JOIN F_STATUS_FINANCEIRO STATUS ON (STATUS.F_STATUS_FINANCEIRO_ID = CR.F_STATUS_FINANCEIRO_ID)
                LEFT JOIN EMPRESA  EMP ON (CR.EMPRESA_ID = EMP.EMPRESA_ID)
                LEFT JOIN SUBCATEGORIA ON (CR.SUBCATEGORIA_ID = SUBCATEGORIA.SUBCATEGORIA_ID)
                LEFT JOIN GRUPO_CAIXA GRUPO ON (GRUPO.GRUPO_CAIXA_ID = CR.GRUPO_CAIXA)
                INNER JOIN BANCO ON (CR.BANCO_ID = BANCO.BANCO_ID)
                INNER JOIN F_FORMA_PAGAMENTO FP ON (FP.F_FORMA_PAGAMENTO_ID = CR.F_FORMA_PAGAMENTO_ID)
                INNER JOIN FILIAL ON (FILIAL.FILIAL_ID = CR.COD_FILIAL_ID)
                WHERE CR.F_AGRUPAMENTO_CR_ID IS NULL
                AND (STATUS.F_STATUS_FINANCEIRO_ID = 3) 
		$where </attr>
<attr value=\"where\"></attr>
<attr value=\"order_by\"> 
ORDER BY &quot;FORMA_PAGAMENTO&quot; ASC, &quot;RAZAO_SOCIAL&quot; ASC, &quot;DATA_VENCIMENTO&quot; ASC</attr>
<attr value=\"order_by_preview\"></attr>
<attr value=\"group_by\"></attr>
<attr value=\"group_fields\"><attr value=\"0\"><attr value=\"name\">FORMA_PAGAMENTO</attr>
<attr value=\"int_type\">0</attr>
<attr value=\"ss\">true</attr>
<attr value=\"group_order\">1</attr>
<attr value=\"group_type\">x</attr>
<attr value=\"color1\">EEEEEE</attr>
<attr value=\"color2\">CACACA</attr>
</attr>
<attr value=\"1\"><attr value=\"name\">Summary</attr>
<attr value=\"cross_table\">false</attr>
<attr value=\"sps\">true</attr>
<attr value=\"sds\">true</attr>
<attr value=\"sgs\">true</attr>
<attr value=\"sum_x\">true</attr>
<attr value=\"sum_y\">true</attr>
<attr value=\"sum_total\">true</attr>
</attr>
</attr>
<attr value=\"totals\"><attr value=\"SQL_CR_RecebimentosFormaPagamento_FORMA_PAGAMENTO\"><attr value=\"name\">FORMA_PAGAMENTO</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Forma Pagamento</attr>
<attr value=\"show\">true</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">false</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
<attr value=\"SQL_CR_RecebimentosFormaPagamento_COD\"><attr value=\"name\">COD</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Cod</attr>
<attr value=\"show\">true</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">false</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
<attr value=\"SQL_CR_RecebimentosFormaPagamento_RAZAO_SOCIAL\"><attr value=\"name\">RAZAO_SOCIAL</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Razao Social</attr>
<attr value=\"show\">true</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">false</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
<attr value=\"SQL_CR_RecebimentosFormaPagamento_RESUMO\"><attr value=\"name\">RESUMO</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Resumo</attr>
<attr value=\"show\">true</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">false</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
<attr value=\"SQL_CR_RecebimentosFormaPagamento_VALOR\"><attr value=\"name\">VALOR</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Valor</attr>
<attr value=\"show\">true</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">true</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
<attr value=\"SQL_CR_RecebimentosFormaPagamento_DATA_VENCIMENTO\"><attr value=\"name\">DATA_VENCIMENTO</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Dt. Vencimento</attr>
<attr value=\"show\">true</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">false</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
<attr value=\"SQL_CR_RecebimentosFormaPagamento_DATA_RECEBIMENTO\"><attr value=\"name\">DATA_RECEBIMENTO</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Dt. Recebimento</attr>
<attr value=\"show\">true</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">false</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
<attr value=\"SQL_CR_RecebimentosFormaPagamento_NOME_CONTA\"><attr value=\"name\">NOME_CONTA</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Conta</attr>
<attr value=\"show\">true</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">false</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
<attr value=\"SQL_CR_RecebimentosFormaPagamento_NOME_FILIAL\"><attr value=\"name\">NOME_FILIAL</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Filial</attr>
<attr value=\"show\">true</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">false</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
<attr value=\"SQL_CR_RecebimentosFormaPagamento_NOME_STATUS\"><attr value=\"name\">NOME_STATUS</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">NOME_STATUS</attr>
<attr value=\"show\">false</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">false</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
<attr value=\"SQL_CR_RecebimentosFormaPagamento_SUBCATEGORIA\"><attr value=\"name\">SUBCATEGORIA</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">SUBCATEGORIA</attr>
<attr value=\"show\">false</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">false</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
</attr>
<attr value=\"sort_fields\"><attr value=\"0\"><attr value=\"name\">FORMA_PAGAMENTO</attr>
<attr value=\"desc\">false</attr>
</attr>
<attr value=\"1\"><attr value=\"name\">RAZAO_SOCIAL</attr>
<attr value=\"desc\">false</attr>
</attr>
<attr value=\"2\"><attr value=\"name\">DATA_VENCIMENTO</attr>
<attr value=\"desc\">false</attr>
</attr>
</attr>
<attr value=\"permissions\"><attr value=\"0\"><attr value=\"id\">Guest</attr>
<attr value=\"name\">Guest</attr>
<attr value=\"view\">false</attr>
<attr value=\"edit\">false</attr>
</attr>
<attr value=\"1\"><attr value=\"id\">admin</attr>
<attr value=\"name\">admin</attr>
<attr value=\"view\">false</attr>
<attr value=\"edit\">false</attr>
</attr>
</attr>
</report>";
		parent::execute_query("UPDATE \"webreports\" SET \"webreports\".\"rpt_content\" = '" . $this->XML . "'WHERE \"webreports\".\"rpt_name\" ='CR_RecebimentosFormaPagamento'");
		break;
		
		 case "CP_PagamentosFormaPagamento":
		$dataInicial = empty($dados['data_ini_filtro']) ? $this->dataInicial : $this->data->convertDataSql($dados['data_ini_filtro']);
		$dataFinal = empty($dados['data_fim_filtro']) ? $this->dataFinal : $this->data->convertDataSql($dados['data_fim_filtro']);
		$conta = $dados['contaCliente'];
		$cliente = $dados['pesquisaFornecedor'];
		$formaPagamento = $dados['formaPagamento'];
		$filial = $dados['filial'];
		
		if ($dados['dataPesquisa'] == 1) {
		    $where = "AND DATA_VENCIMENTO BETWEEN ''$dataInicial''  AND ''$dataFinal''";
		} else if ($dados['dataPesquisa'] == 2) {
		    $where = "AND DATA_RECEBIMENTO BETWEEN ''$dataInicial''  AND ''$dataFinal''";
		} else {
		    $where = "AND DATA_VENCIMENTO BETWEEN ''$dataInicial''  AND ''$dataFinal''";
		}
		if (!empty($cliente)) {
		    $where .=" AND FORNECEDOR.FORNECEDOR_ID = $cliente ";
		}
		if (!empty($conta)) {
		    $where .="AND  BANCO.BANCO_ID = $conta";
		}
		if (!empty($formaPagamento)) {
		    $where .=" AND FP.F_FORMA_PAGAMENTO_ID = $formaPagamento";
		}
		if (!empty($filial)) {
		    $where .= " AND F.FILIAL_ID = $filial";
		}

		$this->XML = "<report>
<attr value=\"table_type\">custom</attr>
<attr value=\"tables\"><attr value=\"0\">SQL_CP_PagamentosFormaPagamento</attr>
</attr>
<attr value=\"group_fields\"><attr value=\"0\"><attr value=\"name\">FORMA_PAGAMENTO</attr>
<attr value=\"int_type\">0</attr>
<attr value=\"ss\">true</attr>
<attr value=\"group_order\">1</attr>
<attr value=\"group_type\">x</attr>
<attr value=\"color1\">EEEEEE</attr>
<attr value=\"color2\">CACACA</attr>
</attr>
<attr value=\"1\"><attr value=\"name\">Summary</attr>
<attr value=\"cross_table\">false</attr>
<attr value=\"sps\">true</attr>
<attr value=\"sds\">true</attr>
<attr value=\"sgs\">true</attr>
<attr value=\"sum_x\">true</attr>
<attr value=\"sum_y\">true</attr>
<attr value=\"sum_total\">true</attr>
</attr>
</attr>
<attr value=\"totals\"><attr value=\"SQL_CP_PagamentosFormaPagamento_FORMA_PAGAMENTO\"><attr value=\"name\">FORMA_PAGAMENTO</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Forma Pagamento</attr>
<attr value=\"show\">true</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">false</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
<attr value=\"SQL_CP_PagamentosFormaPagamento_COD_PARCELAMENTO\"><attr value=\"name\">COD_PARCELAMENTO</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Cod</attr>
<attr value=\"show\">true</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">false</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
<attr value=\"SQL_CP_PagamentosFormaPagamento_RAZAO_SOCIAL\"><attr value=\"name\">RAZAO_SOCIAL</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Razao Social</attr>
<attr value=\"show\">true</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">false</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
<attr value=\"SQL_CP_PagamentosFormaPagamento_RESUMO\"><attr value=\"name\">RESUMO</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Resumo</attr>
<attr value=\"show\">true</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">false</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
<attr value=\"SQL_CP_PagamentosFormaPagamento_VALOR\"><attr value=\"name\">VALOR</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Valor</attr>
<attr value=\"show\">true</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">true</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
<attr value=\"SQL_CP_PagamentosFormaPagamento_F_LANCA_CP2_ID\"><attr value=\"name\">F_LANCA_CP2_ID</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Cod</attr>
<attr value=\"show\">false</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">false</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
<attr value=\"SQL_CP_PagamentosFormaPagamento_DATA_VENCIMENTO\"><attr value=\"name\">DATA_VENCIMENTO</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Dt. Vencimento</attr>
<attr value=\"show\">true</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">false</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
<attr value=\"SQL_CP_PagamentosFormaPagamento_DATA_PAGAMENTO\"><attr value=\"name\">DATA_PAGAMENTO</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Dt. Recebimento</attr>
<attr value=\"show\">true</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">false</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
<attr value=\"SQL_CP_PagamentosFormaPagamento_NOME_CONTA\"><attr value=\"name\">NOME_CONTA</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Conta</attr>
<attr value=\"show\">true</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">false</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
<attr value=\"SQL_CP_PagamentosFormaPagamento_NOME_FILIAL\"><attr value=\"name\">NOME_FILIAL</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">Filial</attr>
<attr value=\"show\">true</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">false</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
<attr value=\"SQL_CP_PagamentosFormaPagamento_SUBCATEGORIA\"><attr value=\"name\">SUBCATEGORIA</attr>
<attr value=\"table\"></attr>
<attr value=\"label\">SUBCATEGORIA</attr>
<attr value=\"show\">false</attr>
<attr value=\"min\">false</attr>
<attr value=\"max\">false</attr>
<attr value=\"sum\">false</attr>
<attr value=\"avg\">false</attr>
<attr value=\"curr\">false</attr>
<attr value=\"search\"></attr>
<attr value=\"view_format\"></attr>
<attr value=\"edit_format\">Text field</attr>
<attr value=\"display_field\"></attr>
<attr value=\"linkfield\"></attr>
<attr value=\"show_thumbnail\"></attr>
<attr value=\"need_encode\"></attr>
<attr value=\"thumbnail\"></attr>
<attr value=\"listformatobj_imgwidth\">0</attr>
<attr value=\"listformatobj_imgheight\">0</attr>
<attr value=\"listformatobj_filename\"></attr>
<attr value=\"lookupobj_lookuptype\">0</attr>
<attr value=\"editformatobj_lookupobj_customdispaly\"></attr>
<attr value=\"editformatobj_lookupobj_table\"></attr>
<attr value=\"editformatobj_lookupobj_where\"></attr>
</attr>
</attr>
<attr value=\"sort_fields\"><attr value=\"0\"><attr value=\"name\">FORMA_PAGAMENTO</attr>
<attr value=\"desc\">false</attr>
</attr>
<attr value=\"1\"><attr value=\"name\">RAZAO_SOCIAL</attr>
<attr value=\"desc\">false</attr>
</attr>
<attr value=\"2\"><attr value=\"name\">DATA_VENCIMENTO</attr>
<attr value=\"desc\">false</attr>
</attr>
</attr>
<attr value=\"miscellaneous\"><attr value=\"type\">stepped</attr>
<attr value=\"print_friendly\">true</attr>
<attr value=\"lines_num\">30</attr>
</attr>
<attr value=\"settings\"><attr value=\"name\">CP_PagamentosFormaPagamento</attr>
<attr value=\"title\">Pagamentos  (Agrupado por Forma de Pagamento)</attr>
<attr value=\"status\">public</attr>
</attr>
<attr value=\"owner\">admin</attr>
<attr value=\"tmp_active\"></attr>
<attr value=\"table_name\">SQL_CP_PagamentosFormaPagamento</attr>
<attr value=\"short_table_name\"></attr>
<attr value=\"sql\">SELECT   
            F_LANCA_CP2_ID,
            F_LANCA_CP2.VALOR,
            (
                SELECT *
                FROM SP_CONVERTER_CARACTER(BANCO.NOME)
            )   AS NOME_CONTA,
            (
                SELECT *
                FROM SP_CONVERTER_CARACTER(SUBCATEGORIA.SUBCATEGORIA)
            )   AS SUBCATEGORIA,
            (
                SELECT *
                FROM SP_CONVERTER_CARACTER(FORNECEDOR.RAZAO_SOCIAL)
            )   AS RAZAO_SOCIAL,
             (
                SELECT *
                FROM SP_CONVERTER_CARACTER(FILIAL.NOME_FILIAL)
            )   AS NOME_FILIAL,
              (
                SELECT *
                FROM SP_CONVERTER_CARACTER(FP.FORMA_PAGAMENTO)
            )   AS FORMA_PAGAMENTO,
             CP.COD_PARCELAMENTO,
              SUBSTRING(CP.RESUMO FROM 1 FOR 20)AS RESUMO,
         DATA_VENCIMENTO,
       DATA_PAGAMENTO
            FROM   F_LANCA_CP CP
            INNER JOIN F_LANCA_CP2  ON (F_LANCA_CP2.F_LANCA_CP2_ID = (SELECT MAX(F_LANCA_CP2.F_LANCA_CP2_ID) FROM F_LANCA_CP2 WHERE F_LANCA_CP2.F_LANCA_CP = CP.F_LANCA_CP_ID))
            INNER JOIN F_STATUS_FINANCEIRO_CP   STATUS ON (STATUS.F_STATUS_FINANCEIRO_CP_ID = CP.F_STATUS_FINANCEIRO_CP_ID)
            INNER JOIN BANCO ON (BANCO.BANCO_ID = CP.BANCO_ID)
            LEFT JOIN FORNECEDOR  ON (FORNECEDOR.FORNECEDOR_ID = CP.FORNECEDOR_ID)
            LEFT JOIN SUBCATEGORIA ON (CP.SUBCATEGORIA_ID = SUBCATEGORIA.SUBCATEGORIA_ID)
            LEFT JOIN GRUPO_CAIXA GRUPO ON (GRUPO.GRUPO_CAIXA_ID = CP.GRUPO_CAIXA)
            INNER JOIN FILIAL ON (CP.COD_FILIAL_ID = FILIAL.FILIAL_ID)
            INNER JOIN F_FORMA_PAGAMENTO FP ON (FP.F_FORMA_PAGAMENTO_ID = CP.F_FORMA_PAGAMENTO_ID)
            WHERE  (CP.F_STATUS_FINANCEIRO_CP_ID = 2) $where</attr>
<attr value=\"sql_preview\">SELECT   
            F_LANCA_CP2_ID,
            F_LANCA_CP2.VALOR,
            (
                SELECT *
                FROM SP_CONVERTER_CARACTER(BANCO.NOME)
            )   AS NOME_CONTA,
            (
                SELECT *
                FROM SP_CONVERTER_CARACTER(SUBCATEGORIA.SUBCATEGORIA)
            )   AS SUBCATEGORIA,
            (
                SELECT *
                FROM SP_CONVERTER_CARACTER(FORNECEDOR.RAZAO_SOCIAL)
            )   AS RAZAO_SOCIAL,
             (
                SELECT *
                FROM SP_CONVERTER_CARACTER(FILIAL.NOME_FILIAL)
            )   AS NOME_FILIAL,
              (
                SELECT *
                FROM SP_CONVERTER_CARACTER(FP.FORMA_PAGAMENTO)
            )   AS FORMA_PAGAMENTO,
             CP.COD_PARCELAMENTO,
              SUBSTRING(CP.RESUMO FROM 1 FOR 20)AS RESUMO,
         DATA_VENCIMENTO,
       DATA_PAGAMENTO
            FROM   F_LANCA_CP CP
            INNER JOIN F_LANCA_CP2  ON (F_LANCA_CP2.F_LANCA_CP2_ID = (SELECT MAX(F_LANCA_CP2.F_LANCA_CP2_ID) FROM F_LANCA_CP2 WHERE F_LANCA_CP2.F_LANCA_CP = CP.F_LANCA_CP_ID))
            INNER JOIN F_STATUS_FINANCEIRO_CP   STATUS ON (STATUS.F_STATUS_FINANCEIRO_CP_ID = CP.F_STATUS_FINANCEIRO_CP_ID)
            INNER JOIN BANCO ON (BANCO.BANCO_ID = CP.BANCO_ID)
            LEFT JOIN FORNECEDOR  ON (FORNECEDOR.FORNECEDOR_ID = CP.FORNECEDOR_ID)
            LEFT JOIN SUBCATEGORIA ON (CP.SUBCATEGORIA_ID = SUBCATEGORIA.SUBCATEGORIA_ID)
            LEFT JOIN GRUPO_CAIXA GRUPO ON (GRUPO.GRUPO_CAIXA_ID = CP.GRUPO_CAIXA)
            INNER JOIN FILIAL ON (CP.COD_FILIAL_ID = FILIAL.FILIAL_ID)
            INNER JOIN F_FORMA_PAGAMENTO FP ON (FP.F_FORMA_PAGAMENTO_ID = CP.F_FORMA_PAGAMENTO_ID)
            WHERE  (CP.F_STATUS_FINANCEIRO_CP_ID = 2) $where </attr>
<attr value=\"where\"></attr>
<attr value=\"order_by\"> 
ORDER BY &quot;FORMA_PAGAMENTO&quot; ASC, &quot;RAZAO_SOCIAL&quot; ASC, &quot;DATA_VENCIMENTO&quot; ASC</attr>
<attr value=\"order_by_preview\"></attr>
<attr value=\"group_by\"></attr>
<attr value=\"permissions\"><attr value=\"0\"><attr value=\"id\">Guest</attr>
<attr value=\"name\">Guest</attr>
<attr value=\"view\">false</attr>
<attr value=\"edit\">false</attr>
</attr>
<attr value=\"1\"><attr value=\"id\">admin</attr>
<attr value=\"name\">admin</attr>
<attr value=\"view\">false</attr>
<attr value=\"edit\">false</attr>
</attr>
</attr>
</report>";
		parent::execute_query("UPDATE \"webreports\" SET \"webreports\".\"rpt_content\" = '" . $this->XML . "'WHERE \"webreports\".\"rpt_name\" ='CP_PagamentosFormaPagamento'");
		break;
	}
    }
Пример #30
0
    public function ListaUsuario() {
	$sql = "SELECT * FROM UCTABUSERS WHERE UCLOGIN != 'ADMIN' ORDER BY UCUSERNAME";

	$listaUsuario = array();

	if ($result = parent::execute_query($sql)) {

	    while ($linha = parent::criaObjetoConsulta($result)){
		$DadosUsuario = new Musuario();
		$DadosUsuario->setId($linha->CHAVE_USER);
		$DadosUsuario->setNome($linha->UCUSERNAME);
		$DadosUsuario->setLogin($linha->UCLOGIN);
		array_push($listaUsuario, $DadosUsuario);
	    }
	}
	return $listaUsuario;
    }