<?php
final class DModelWsceoCadastroEmpresa extends Model {

  public function consultarEmpresa(){

    $this->load->type('tipofuturaserver');

    $sql = "SELECT * FROM CADASTRO WHERE CHK_EMPRESA = '".Type_DsimDnaoServer::Tp_Sim."' and STATUS = ".Type_CadastroStatus::TpCadSt_Ativo." ";

    $result = $this->wsceo->getConsultaFromSql($sql);

    if ($this->wsceo->getError()) {
        return $this->wsceo->getError();
    }

    return $result ;

  }

  public function consultarEmpresaFidelidade(){

    $this->load->type('tipofuturaserver');

    $sql = "SELECT
              sf.*,
              (c.razao_social) as razao_social,
              (c.id) as empresa_id
            FROM SYS_FIDELIDADE sf
            LEFT JOIN CADASTRO c ON (c.id = sf.fk_empresa and c.CHK_EMPRESA = '".Type_DsimDnaoServer::Tp_Sim."' and c.STATUS = ".Type_CadastroStatus::TpCadSt_Ativo.") ";

    $result = $this->wsceo->getConsultaFromSql($sql);

    if ($this->wsceo->getError()) {
        return $this->wsceo->getError();
    }

    return $result ;

  }

}