<?php
  include_once "conexao.php";

class ClienteClass
{
    private $con;
    private $pdo;


    private $cliId;
    private $cliNomeRazao;
    private $cliFantasia;
    private $cliCpfCnpj;
    private $cliTipo;
    private $cliDataNascimento;
    private $cliSexo;
    private $cliRg;
    private $cliOrgaoEmissor;
    private $cliDataEmissaoRg;
    private $cliEmail;
    private $cliTelefone;
    private $cliNomePai;
    private $cliNomeMae;
    private $cliEstadoCivil;
    private $cliPpe;

    private $cliLogradouro;
    private $cliNumero;
    private $cliComplemento;
    private $cliBairro;
    private $cliCidade;
    private $cliEstado;
    private $cliCep;

    private $cliDataAlteracao;
    private $cliStatus;

    private $cliSelfie;
    private $cliDocFrente;
    private $cliDocVerso;
    private $cliCompEndereco;

    private $cliDeviceId;

    private $cliSenha;

    private $cliLoginBio;

    private $cliPushId;

    private $cliPercentMatch;

    private $retorno;
    private $mensagemRetorno;

    public function __construct()
    {
        $this->con = new Conexao();
        $this->pdo = $this->con->getConexao();
    }

    public function getClientePorId()
    {
        $id = $this->getCliId();

        $sql = "select * from cliente 
                where cli_id =:id";
        $resultado = $this->pdo->prepare($sql);
        $resultado->bindParam(":id", $id, PDO::PARAM_INT);
        $resultado->execute();

        if ($resultado){
            $this->setRetorno("OK");
            $this->setMensagemRetorno("");
        }else{
            $this->setRetorno("ERRO");
            $this->setMensagemRetorno("Não encontrado Cliente com este ID.");
        }

        return $resultado;
    }


    public function getClientePorCpf()
    {
        $cpf = $this->getCliCpfCnpj();

        $sql = "select * from cliente 
                where cli_cpfcnpj =:cpf ";
        $resultado = $this->pdo->prepare($sql);
        $resultado->bindParam(":cpf", $cpf, PDO::PARAM_STR);
        $resultado->execute();

        /*if ($resultado){
            $this->setRetorno("OK");
            $this->setMensagemRetorno("");
        }else{
            $this->setRetorno("ERRO");
            $this->setMensagemRetorno("Não encontrado Cliente com este ID.");
        }*/

        return $resultado;
    }

    public function getClientePorCpfEmail()
    {
        $cpf = $this->getCliCpfCnpj();
        $email = $this->getCliEmail();

        $sql = "select * from cliente 
                where cli_cpfcnpj =:cpf and cli_email =:email";
        $resultado = $this->pdo->prepare($sql);
        $resultado->bindParam(":cpf", $cpf, PDO::PARAM_STR);
        $resultado->bindParam(":email", $email, PDO::PARAM_STR);
        $resultado->execute();

        if ($resultado){
            $this->setRetorno("OK");
            $this->setMensagemRetorno("");
        }else{
            $this->setRetorno("ERRO");
            $this->setMensagemRetorno("Não encontrado Cliente com este ID.");
        }

        return $resultado;
    }

    public function getClientePorTelefone()
    {
        $telefone = $this->getCliTelefone();

        $sql = "select * from cliente 
                where cli_telefone =:telefone";
        $resultado = $this->pdo->prepare($sql);
        $resultado->bindParam(":telefone", $telefone, PDO::PARAM_STR);
        $resultado->execute();

        if ($resultado){
            $this->setRetorno("OK");
            $this->setMensagemRetorno("");
        }else{
            $this->setRetorno("ERRO");
            $this->setMensagemRetorno("Não encontrado Cliente com este ID.");
        }

        return $resultado;
    }

    public function getClientePorDeviceId()
    {
        $deviceId = $this->getCliDeviceId();


        $sql = "select * from cliente 
                where cli_deviceid =:deviceId";
        $resultado = $this->pdo->prepare($sql);
        $resultado->bindParam(":deviceId", $deviceId, PDO::PARAM_STR);
        $resultado->execute();

        if ($resultado){
            $this->setRetorno("OK");
            $this->setMensagemRetorno("");
        }else{
            $this->setRetorno("ERRO");
            $this->setMensagemRetorno("Não encontrado Cliente com este ID.");
        }

        return $resultado;
    }

    public function alteraDispositivo()
    {
        $codCliente = $this->getCliId();
        $idDevice = $this->getCliDeviceId();

        $sql = "update cliente set cli_deviceid =:id 
                where cli_id =:cliId";
        $resultado = $this->pdo->prepare($sql);
        $resultado->bindParam(":id", $idDevice, PDO::PARAM_STR);
        $resultado->bindParam(":cliId", $codCliente, PDO::PARAM_INT);
        $resultado->execute();

        return $resultado;
    }

    public function listarTodos()
    {
        $sql = "select * from cliente 
                order by cli_nomerazao";
        $resultado = $this->pdo->prepare($sql);
        $resultado->execute();

        if ($resultado){
            $this->setRetorno("OK");
            $this->setMensagemRetorno("");
        }else{
            $this->setRetorno("ERRO");
            $this->setMensagemRetorno("Lista Vazia.");
        }

        return $resultado;
    }

    public function listarAtivos()
    {
        $sql = "select * from cliente where cli_status = 'ATIVO'
                order by cli_nomerazao";
        $resultado = $this->pdo->prepare($sql);
        $resultado->execute();

        if ($resultado){
            $this->setRetorno("OK");
            $this->setMensagemRetorno("");
        }else{
            $this->setRetorno("ERRO");
            $this->setMensagemRetorno("Lista Vazia.");
        }

        return $resultado;
    }

    public function inserir()
    {
        $nome = $this->getCliNomeRazao();
        $fantasia = $this->getCliFantasia();
        $cpfCnpj = $this->getCliCpfCnpj();
        $tipo = $this->getCliTipo();
        $dataNascimento = null;
        if (!empty($this->getCliDataNascimento()))
        {
            $dataNascimento = date('Y-m-d', strtotime($this->getCliDataNascimento()));
        }
        $sexo = $this->getCliSexo();
        $rg = $this->getCliRg();
        $orgaoEmissor = $this->getCliOrgaoEmissor();
        $dataEmissaoRg = null;
        if (!empty($this->getCliDataEmissaoRg()))
        {
            $dataEmissaoRg = date('Y-m-d', strtotime($this->getCliDataEmissaoRg()));
        }
        $email = $this->getCliEmail();
        $telefone = $this->getCliTelefone();
        $nomePai = $this->getCliNomePai();
        $nomeMae = $this->getCliNomeMae();
        $estadoCivil = $this->getCliEstadoCivil();
        $ppe = $this->getCliPpe();

        $rua = $this->getCliLogradouro();
        $numero = $this->getCliNumero();
        $compl = $this->getCliComplemento();
        $bairro = $this->getCliBairro();
        $cidade = $this->getCliCidade();
        $estado = $this->getCliEstado();
        $cep = $this->getCliCep();

        $selfie = $this->getCliSelfie();
        $docFrente = $this->getCliDocFrente();
        $docVerso = $this->getCliDocVerso();
        $compEndereco = $this->getCliCompEndereco();

        $deviceId = $this->getCliDeviceId();

        $percentMatch = $this->getCliPercentMatch();

        $status = 'AGUARDANDO';

        if ($tipo == 'PESSOA FÍSICA'){
            $sql = "insert into cliente (cli_nomerazao, cli_cpfcnpj, cli_tipo, 
                    cli_datanascimento, cli_sexo, cli_rg, cli_orgaoemissor,
                    cli_dataemissaorg, cli_email, cli_telefone, cli_nomepai, cli_nomemae, cli_estadocivil,
                    cli_logradouro, cli_numero, cli_complemento, cli_bairro,
                    cli_cidade, cli_estado, cli_cep, cli_status, cli_selfie, cli_docfrente, cli_docverso, cli_compendereco,
                    cli_deviceid, cli_ppe)
                    values(:nome,:cpf, :tipo, :dataNascimento, :sexo,
                    :rg, :orgaoEmissor, :dataEmissaorg, :email, :telefone, :nomePai, :nomeMae, :estadoCivil,
                    :rua, :numero, :compl, :bairro, :cidade, :estado, :cep, :status, :selfie, :docfrente,
                    :docverso, :compendereco, :deviceId, :ppe) ";
            $resultado = $this->pdo->prepare($sql);
            $resultado->bindParam(":nome", $nome, PDO::PARAM_STR);
            $resultado->bindParam(":cpf", $cpfCnpj, PDO::PARAM_STR);
            $resultado->bindParam(":tipo", $tipo, PDO::PARAM_STR);
            $resultado->bindParam(":dataNascimento", $dataNascimento);
            $resultado->bindParam(":sexo", $sexo, PDO::PARAM_STR);
            $resultado->bindParam(":rg", $rg, PDO::PARAM_STR);
            $resultado->bindParam(":orgaoEmissor", $orgaoEmissor, PDO::PARAM_STR);
            $resultado->bindParam(":dataEmissaorg", $dataEmissaoRg);
            $resultado->bindParam(":email", $email, PDO::PARAM_STR);
            $resultado->bindParam(":telefone", $telefone, PDO::PARAM_STR);
            $resultado->bindParam(":nomePai", $nomePai, PDO::PARAM_STR);
            $resultado->bindParam(":nomeMae", $nomeMae, PDO::PARAM_STR);
            $resultado->bindParam(":estadoCivil", $estadoCivil, PDO::PARAM_STR);
            $resultado->bindParam(":ppe", $ppe, PDO::PARAM_STR);
            $resultado->bindParam(":rua", $rua, PDO::PARAM_STR);
            $resultado->bindParam(":numero", $numero, PDO::PARAM_STR);
            $resultado->bindParam(":compl", $compl, PDO::PARAM_STR);
            $resultado->bindParam(":bairro", $bairro, PDO::PARAM_STR);
            $resultado->bindParam(":cidade", $cidade, PDO::PARAM_STR);
            $resultado->bindParam(":estado", $estado, PDO::PARAM_STR);
            $resultado->bindParam(":cep", $cep, PDO::PARAM_STR);

            $resultado->bindParam(":selfie", $selfie, PDO::PARAM_STR);
            $resultado->bindParam(":docfrente", $docFrente, PDO::PARAM_STR);
            $resultado->bindParam(":docverso", $docVerso, PDO::PARAM_STR);
            $resultado->bindParam(":compendereco", $compEndereco, PDO::PARAM_STR);

            $resultado->bindParam(":deviceId", $deviceId, PDO::PARAM_STR);

            $resultado->bindParam(":status", $status, PDO::PARAM_STR);

            $resultado->execute();
        }else{
            $sql = "insert into cliente (cli_nomerazao, cli_fantasia, cli_cpfcnpj, cli_tipo, 
                    cli_email, cli_telefone, cli_logradouro, cli_numero, cli_complemento, cli_bairro,
                    cli_cidade, cli_estado, cli_cep, cli_status, cli_selfie, cli_docfrente, cli_docverso, cli_compendereco)
                    values(:nome, :fantasia, :cpf, :tipo,
                    :email, :telefone, :rua, :numero, :compl, :bairro, :cidade, :estado, :cep,
                    :status, :selfie, :docfrente, :docverso, :compendereco) ";
            $resultado = $this->pdo->prepare($sql);
            $resultado->bindParam(":nome", $nome, PDO::PARAM_STR);
            $resultado->bindParam(":fantasia", $fantasia, PDO::PARAM_STR);
            $resultado->bindParam(":cpf", $cpfCnpj, PDO::PARAM_STR);
            $resultado->bindParam(":tipo", $tipo, PDO::PARAM_STR);
            $resultado->bindParam(":email", $email, PDO::PARAM_STR);
            $resultado->bindParam(":telefone", $telefone, PDO::PARAM_STR);

            $resultado->bindParam(":rua", $rua, PDO::PARAM_STR);
            $resultado->bindParam(":numero", $numero, PDO::PARAM_STR);
            $resultado->bindParam(":compl", $compl, PDO::PARAM_STR);
            $resultado->bindParam(":bairro", $bairro, PDO::PARAM_STR);
            $resultado->bindParam(":cidade", $cidade, PDO::PARAM_STR);
            $resultado->bindParam(":estado", $estado, PDO::PARAM_STR);
            $resultado->bindParam(":cep", $cep, PDO::PARAM_STR);

            $resultado->bindParam(":selfie", $selfie, PDO::PARAM_STR);
            $resultado->bindParam(":docfrente", $docFrente, PDO::PARAM_STR);
            $resultado->bindParam(":docverso", $docVerso, PDO::PARAM_STR);
            $resultado->bindParam(":compendereco", $compEndereco, PDO::PARAM_STR);

            $resultado->bindParam(":status", $status, PDO::PARAM_STR);

            $resultado->execute();
        }

        if ($resultado){
            $this->setCliId($this->pdo->lastInsertId());
            $this->setRetorno("OK");
            $this->setMensagemRetorno("");
        }else{
            $this->setRetorno("ERRO");
            $this->setMensagemRetorno("Ocorreu um erro durante a inserção de dados.");
        }

        return $resultado;
    }

    public function editar()
    {
        $id = $this->getCliId();
        $nome = $this->getCliNomeRazao();
        $fantasia = $this->getCliFantasia();
        $cpfCnpj = $this->getCliCpfCnpj();
        $tipo = $this->getCliTipo();
        $dataNascimento = null;
        if (!empty($this->getCliDataNascimento()))
        {
            $dataNascimento = date('Y-m-d', strtotime($this->getCliDataNascimento()));
        }
        $sexo = $this->getCliSexo();
        $rg = $this->getCliRg();
        $orgaoEmissor = $this->getCliOrgaoEmissor();
        $dataEmissaoRg = null;
        if (!empty($this->getCliDataEmissaoRg()))
        {
            $dataEmissaoRg = date('Y-m-d', strtotime($this->getCliDataEmissaoRg()));
        }

        $telefone = $this->getCliTelefone();
        $nomePai = $this->getCliNomePai();
        $nomeMae = $this->getCliNomeMae();
        $estadoCivil = $this->getCliEstadoCivil();

        $rua = $this->getCliLogradouro();
        $numero = $this->getCliNumero();
        $compl = $this->getCliComplemento();
        $bairro = $this->getCliBairro();
        $cidade = $this->getCliCidade();
        $estado = $this->getCliEstado();
        $cep = $this->getCliCep();
        $ppe = $this->getCliPpe();

        $status = $this->getCliStatus();

        if ($tipo == 'PESSOA FÍSICA'){
            $sql = "update cliente set cli_nomerazao =:nome, cli_cpfcnpj =:cpf, cli_tipo =:tipo, 
                    cli_datanascimento =:dataNascimento,
                    cli_sexo =:sexo, cli_rg =:rg, cli_orgaoemissor =:orgaoEmissor,
                    cli_dataemissaorg =:dataEmissaorg, cli_telefone =:telefone, cli_nomepai =:nomePai, 
                    cli_nomemae =:nomeMae, cli_estadocivil =:estadoCivil,
                    cli_dataalteracao = current_timestamp(), cli_logradouro =:rua, cli_numero =:numero, 
                    cli_complemento = :compl, cli_bairro = :bairro,
                    cli_cidade =:cidade, cli_estado =:estado, cli_cep =:cep, cli_status =:status, cli_ppe =:ppe
                    where cli_id =:id ";
            $resultado = $this->pdo->prepare($sql);
            $resultado->bindParam(":id", $id, PDO::PARAM_INT);
            $resultado->bindParam(":nome", $nome, PDO::PARAM_STR);
            $resultado->bindParam(":cpf", $cpfCnpj, PDO::PARAM_STR);
            $resultado->bindParam(":tipo", $tipo, PDO::PARAM_STR);
            $resultado->bindParam(":dataNascimento", $dataNascimento);
            $resultado->bindParam(":sexo", $sexo, PDO::PARAM_STR);
            $resultado->bindParam(":rg", $rg, PDO::PARAM_STR);
            $resultado->bindParam(":orgaoEmissor", $orgaoEmissor, PDO::PARAM_STR);
            $resultado->bindParam(":dataEmissaorg", $dataEmissaoRg);
            $resultado->bindParam(":telefone", $telefone, PDO::PARAM_STR);
            $resultado->bindParam(":nomePai", $nomePai, PDO::PARAM_STR);
            $resultado->bindParam(":nomeMae", $nomeMae, PDO::PARAM_STR);
            $resultado->bindParam(":estadoCivil", $estadoCivil, PDO::PARAM_STR);
            $resultado->bindParam(":rua", $rua, PDO::PARAM_STR);
            $resultado->bindParam(":numero", $numero, PDO::PARAM_STR);
            $resultado->bindParam(":compl", $compl, PDO::PARAM_STR);
            $resultado->bindParam(":bairro", $bairro, PDO::PARAM_STR);
            $resultado->bindParam(":cidade", $cidade, PDO::PARAM_STR);
            $resultado->bindParam(":estado", $estado, PDO::PARAM_STR);
            $resultado->bindParam(":cep", $cep, PDO::PARAM_STR);
            $resultado->bindParam(":status", $status, PDO::PARAM_STR);
            $resultado->bindParam(":ppe", $ppe, PDO::PARAM_STR);
            $resultado->execute();
        }else{
            $sql = "update cliente set cli_nomerazao =:nome, cli_fantasia =:fantasia, cli_cpfcnpj =:cpf, 
                    cli_tipo =:tipo, cli_telefone =:telefone,  
                    cli_logradouro =:rua, cli_numero =:numero, 
                    cli_complemento = :compl, cli_bairro = :bairro,
                    cli_cidade =:cidade, cli_estado =:estado, cli_cep =:cep, cli_status =:status
                    where cli_id =:id ";
            $resultado = $this->pdo->prepare($sql);
            $resultado->bindParam(":id", $id, PDO::PARAM_INT);
            $resultado->bindParam(":nome", $nome, PDO::PARAM_STR);
            $resultado->bindParam(":fantasia", $fantasia, PDO::PARAM_STR);
            $resultado->bindParam(":cpf", $cpfCnpj, PDO::PARAM_STR);
            $resultado->bindParam(":tipo", $tipo, PDO::PARAM_STR);
            $resultado->bindParam(":telefone", $telefone, PDO::PARAM_STR);
            $resultado->bindParam(":rua", $rua, PDO::PARAM_STR);
            $resultado->bindParam(":numero", $numero, PDO::PARAM_STR);
            $resultado->bindParam(":compl", $compl, PDO::PARAM_STR);
            $resultado->bindParam(":bairro", $bairro, PDO::PARAM_STR);
            $resultado->bindParam(":cidade", $cidade, PDO::PARAM_STR);
            $resultado->bindParam(":estado", $estado, PDO::PARAM_STR);
            $resultado->bindParam(":cep", $cep, PDO::PARAM_STR);
            $resultado->bindParam(":status", $status, PDO::PARAM_STR);
            $resultado->execute();
        }

        if ($resultado){
            $this->setRetorno("OK");
            $this->setMensagemRetorno("");
        }else{
            $this->setRetorno("ERRO");
            $this->setMensagemRetorno("Ocorreu um erro durante a alteração de dados.");
        }

        return $resultado;
    }

    public function alterarEndereco()
    {
        $id = $this->getCliId();

        $rua = $this->getCliLogradouro();
        $numero = $this->getCliNumero();
        $compl = $this->getCliComplemento();
        $bairro = $this->getCliBairro();
        $cidade = $this->getCliCidade();
        $estado = $this->getCliEstado();
        $cep = $this->getCliCep();

            $sql = "update cliente set  cli_logradouro =:rua, cli_numero =:numero, 
                    cli_complemento = :compl, cli_bairro = :bairro,
                    cli_cidade =:cidade, cli_estado =:estado, cli_cep =:cep
                    where cli_id =:id ";
            $resultado = $this->pdo->prepare($sql);
            $resultado->bindParam(":id", $id, PDO::PARAM_INT);
            $resultado->bindParam(":rua", $rua, PDO::PARAM_STR);
            $resultado->bindParam(":numero", $numero, PDO::PARAM_STR);
            $resultado->bindParam(":compl", $compl, PDO::PARAM_STR);
            $resultado->bindParam(":bairro", $bairro, PDO::PARAM_STR);
            $resultado->bindParam(":cidade", $cidade, PDO::PARAM_STR);
            $resultado->bindParam(":estado", $estado, PDO::PARAM_STR);
            $resultado->bindParam(":cep", $cep, PDO::PARAM_STR);
            $resultado->execute();

        if ($resultado){
            $this->setRetorno("OK");
            $this->setMensagemRetorno("");
        }else{
            $this->setRetorno("ERRO");
            $this->setMensagemRetorno("Ocorreu um erro durante a alteração de dados.");
        }

        return $resultado;
    }

    public function criarAcesso()
    {
        $codCliente = $this->getCliId();
        $email = $this->getCliEmail();
        $nome = $this->getCliNomeRazao();
        $telefone = "55".$this->getCliTelefone();
        $senha = random_int(100000,999999);
        $senhaSegura = sha1($senha);

        $sql= "update cliente set cli_senha =:senha, cli_status = 'ATIVO', cli_alterasenha = 1 
                where cli_id =:id";
        $resultado = $this->pdo->prepare($sql);
        $resultado->bindParam(":id", $codCliente, PDO::PARAM_INT);
        $resultado->bindParam(":senha", $senhaSegura, PDO::PARAM_STR);
        $resultado->execute();

        if ($resultado){
            $this->setRetorno("OK");
            $this->setMensagemRetorno("");


        }else{
            $this->setRetorno("ERRO");
            $this->setMensagemRetorno("Ocorreu um erro durante a criação de senha.");
        }

        return $resultado;
    }

    public function esqueciSenha()
    {
        $codCliente = $this->getCliId();
        $email = $this->getCliEmail();
        $nome = $this->getCliNomeRazao();
        $senha = random_int(100000,999999);
        $senhaSegura = sha1($senha);

        $sql= "update cliente set cli_senha =:senha, cli_alterasenha = 1, cli_loginbio = 0 
                where cli_id =:id";
        $resultado = $this->pdo->prepare($sql);
        $resultado->bindParam(":id", $codCliente, PDO::PARAM_INT);
        $resultado->bindParam(":senha", $senhaSegura, PDO::PARAM_STR);
        $resultado->execute();

        if ($resultado){
            $this->setRetorno("OK");
            $this->setMensagemRetorno("");

        }else{
            $this->setRetorno("ERRO");
            $this->setMensagemRetorno("Ocorreu um erro durante a criação de senha.");
        }

        return $resultado;
    }

    public function login()
    {
        $cpf = $this->getCliCpfCnpj();
        $senha = $this->getCliSenha();
        $senhaSegura = sha1($senha);

        $sql = "select * from cliente where cli_cpfcnpj =:cpf and cli_senha =:senha and cli_status = 'ATIVO' ";

        $resultado = $this->pdo->prepare($sql);
        $resultado->bindParam(":cpf", $cpf, PDO::PARAM_STR);
        $resultado->bindParam(":senha", $senhaSegura, PDO::PARAM_STR);
        $resultado->execute();

        if ($resultado->rowCount() > 0){
            $this->setRetorno("OK");
            $this->setMensagemRetorno("");
        }else{
            $this->setRetorno("ERRO");
            $this->setMensagemRetorno("Ocorreu um erro durante a tentativa Login.");
        }

        return $resultado;

    }

    public function loginIdDevice()
    {
        $idDevice = $this->getCliDeviceId();

        $sql = "select * from cliente where cli_deviceid =:id and cli_status ='ATIVO'";

        $resultado = $this->pdo->prepare($sql);
        $resultado->bindParam(":id", $idDevice, PDO::PARAM_STR);
        $resultado->execute();

        if ($resultado->rowCount() > 0){
            $this->setRetorno("OK");
            $this->setMensagemRetorno("");
        }else{
            $this->setRetorno("ERRO");
            $this->setMensagemRetorno("Ocorreu um erro durante a tentativa Login.");
        }

        return $resultado;

    }

    public function alteraLoginBio()
    {
        $codCliente = $this->getCliId();
        $status = $this->getCliLoginBio();

        $sql = "update cliente set cli_loginbio =:status where cli_id =:id";

        $resultado = $this->pdo->prepare($sql);
        $resultado->bindParam(":id", $codCliente, PDO::PARAM_INT);
        $resultado->bindParam(":status", $status, PDO::PARAM_INT);
        $resultado->execute();

        return $resultado;
    }

    public function alteraSenha()
    {
        $codCliente = $this->getCliId();
        $idDevice = $this->getCliDeviceId();
        $senha = $this->getCliSenha();
        $senhaSegura = sha1($senha);

        $sql = "update cliente set cli_senha =:senha, cli_alterasenha = 0 where cli_id =:id and cli_deviceid =:deviceId";

        $resultado = $this->pdo->prepare($sql);
        $resultado->bindParam(":id", $codCliente, PDO::PARAM_INT);
        $resultado->bindParam(":senha", $senhaSegura, PDO::PARAM_STR);
        $resultado->bindParam(":deviceId", $idDevice, PDO::PARAM_STR);
        $resultado->execute();

        return $resultado;
    }

    public function gravaPushId()
    {
        $idDevice = $this->getCliDeviceId();
        $pushId = $this->getCliPushId();

        $sql = "update cliente set cli_pushid =:pushid where cli_deviceid =:id";

        $resultado = $this->pdo->prepare($sql);
        $resultado->bindParam(":id", $idDevice, PDO::PARAM_STR);
        $resultado->bindParam(":pushid", $pushId, PDO::PARAM_STR);
        $resultado->execute();

        return $resultado;
    }

    public function alteraSeqImagem()
    {
        $codCliente = $this->getCliId();
        $sequencia = $this->getCliSeqImagem();

        $sql = "update cliente set cli_seqimagem =:sequencia where cli_id =:id";

        $resultado = $this->pdo->prepare($sql);
        $resultado->bindParam(":id", $codCliente, PDO::PARAM_INT);
        $resultado->bindParam(":sequencia", $sequencia, PDO::PARAM_INT);
        $resultado->execute();

        return $resultado;
    }

    /**
     * @return mixed
     */
    public function getCliId()
    {
        return $this->cliId;
    }

    /**
     * @param mixed $cliId
     */
    public function setCliId($cliId)
    {
        $this->cliId = $cliId;
    }

    /**
     * @return mixed
     */
    public function getCliNomeRazao()
    {
        return $this->cliNomeRazao;
    }

    /**
     * @param mixed $cliNomeRazao
     */
    public function setCliNomeRazao($cliNomeRazao)
    {
        $this->cliNomeRazao = $cliNomeRazao;
    }

    /**
     * @return mixed
     */
    public function getCliFantasia()
    {
        return $this->cliFantasia;
    }

    /**
     * @param mixed $cliFantasia
     */
    public function setCliFantasia($cliFantasia)
    {
        $this->cliFantasia = $cliFantasia;
    }

    /**
     * @return mixed
     */
    public function getCliCpfCnpj()
    {
        return $this->cliCpfCnpj;
    }

    /**
     * @param mixed $cliCpfCnpj
     */
    public function setCliCpfCnpj($cliCpfCnpj)
    {
        $this->cliCpfCnpj = $cliCpfCnpj;
    }

    /**
     * @return mixed
     */
    public function getCliTipo()
    {
        return $this->cliTipo;
    }

    /**
     * @param mixed $cliTipo
     */
    public function setCliTipo($cliTipo)
    {
        $this->cliTipo = $cliTipo;
    }

    /**
     * @return mixed
     */
    public function getCliDataNascimento()
    {
        return $this->cliDataNascimento;
    }

    /**
     * @param mixed $cliDataNascimento
     */
    public function setCliDataNascimento($cliDataNascimento)
    {
        $this->cliDataNascimento = $cliDataNascimento;
    }

    /**
     * @return mixed
     */
    public function getCliSexo()
    {
        return $this->cliSexo;
    }

    /**
     * @param mixed $cliSexo
     */
    public function setCliSexo($cliSexo)
    {
        $this->cliSexo = $cliSexo;
    }

    /**
     * @return mixed
     */
    public function getCliRg()
    {
        return $this->cliRg;
    }

    /**
     * @param mixed $cliRg
     */
    public function setCliRg($cliRg)
    {
        $this->cliRg = $cliRg;
    }

    /**
     * @return mixed
     */
    public function getCliOrgaoEmissor()
    {
        return $this->cliOrgaoEmissor;
    }

    /**
     * @param mixed $cliOrgaoEmissor
     */
    public function setCliOrgaoEmissor($cliOrgaoEmissor)
    {
        $this->cliOrgaoEmissor = $cliOrgaoEmissor;
    }

    /**
     * @return mixed
     */
    public function getCliDataEmissaoRg()
    {
        return $this->cliDataEmissaoRg;
    }

    /**
     * @param mixed $cliDataEmissaoRg
     */
    public function setCliDataEmissaoRg($cliDataEmissaoRg)
    {
        $this->cliDataEmissaoRg = $cliDataEmissaoRg;
    }

    /**
     * @return mixed
     */
    public function getCliEmail()
    {
        return $this->cliEmail;
    }

    /**
     * @param mixed $cliEmail
     */
    public function setCliEmail($cliEmail)
    {
        $this->cliEmail = $cliEmail;
    }

    /**
     * @return mixed
     */
    public function getCliTelefone()
    {
        return $this->cliTelefone;
    }

    /**
     * @param mixed $cliTelefone
     */
    public function setCliTelefone($cliTelefone)
    {
        $this->cliTelefone = $cliTelefone;
    }

    /**
     * @return mixed
     */
    public function getCliNomePai()
    {
        return $this->cliNomePai;
    }

    /**
     * @param mixed $cliNomePai
     */
    public function setCliNomePai($cliNomePai)
    {
        $this->cliNomePai = $cliNomePai;
    }

    /**
     * @return mixed
     */
    public function getCliNomeMae()
    {
        return $this->cliNomeMae;
    }

    /**
     * @param mixed $cliNomeMae
     */
    public function setCliNomeMae($cliNomeMae)
    {
        $this->cliNomeMae = $cliNomeMae;
    }

    /**
     * @return mixed
     */
    public function getCliEstadoCivil()
    {
        return $this->cliEstadoCivil;
    }

    /**
     * @param mixed $cliEstadoCivil
     */
    public function setCliEstadoCivil($cliEstadoCivil)
    {
        $this->cliEstadoCivil = $cliEstadoCivil;
    }

    /**
     * @return mixed
     */
    public function getCliPpe()
    {
        return $this->cliPpe;
    }

    /**
     * @param mixed $cliPpe
     */
    public function setCliPpe($cliPpe)
    {
        $this->cliPpe = $cliPpe;
    }

    /**
     * @return mixed
     */
    public function getCliLogradouro()
    {
        return $this->cliLogradouro;
    }

    /**
     * @param mixed $cliLogradouro
     */
    public function setCliLogradouro($cliLogradouro)
    {
        $this->cliLogradouro = $cliLogradouro;
    }

    /**
     * @return mixed
     */
    public function getCliNumero()
    {
        return $this->cliNumero;
    }

    /**
     * @param mixed $cliNumero
     */
    public function setCliNumero($cliNumero)
    {
        $this->cliNumero = $cliNumero;
    }

    /**
     * @return mixed
     */
    public function getCliComplemento()
    {
        return $this->cliComplemento;
    }

    /**
     * @param mixed $cliComplemento
     */
    public function setCliComplemento($cliComplemento)
    {
        $this->cliComplemento = $cliComplemento;
    }

    /**
     * @return mixed
     */
    public function getCliBairro()
    {
        return $this->cliBairro;
    }

    /**
     * @param mixed $cliBairro
     */
    public function setCliBairro($cliBairro)
    {
        $this->cliBairro = $cliBairro;
    }

    /**
     * @return mixed
     */
    public function getCliCidade()
    {
        return $this->cliCidade;
    }

    /**
     * @param mixed $cliCidade
     */
    public function setCliCidade($cliCidade)
    {
        $this->cliCidade = $cliCidade;
    }

    /**
     * @return mixed
     */
    public function getCliEstado()
    {
        return $this->cliEstado;
    }

    /**
     * @param mixed $cliEstado
     */
    public function setCliEstado($cliEstado)
    {
        $this->cliEstado = $cliEstado;
    }

    /**
     * @return mixed
     */
    public function getCliCep()
    {
        return $this->cliCep;
    }

    /**
     * @param mixed $cliCep
     */
    public function setCliCep($cliCep)
    {
        $this->cliCep = $cliCep;
    }

    /**
     * @return mixed
     */
    public function getCliDataAlteracao()
    {
        return $this->cliDataAlteracao;
    }

    /**
     * @param mixed $cliDataAlteracao
     */
    public function setCliDataAlteracao($cliDataAlteracao)
    {
        $this->cliDataAlteracao = $cliDataAlteracao;
    }

    /**
     * @return mixed
     */
    public function getCliStatus()
    {
        return $this->cliStatus;
    }

    /**
     * @param mixed $cliStatus
     */
    public function setCliStatus($cliStatus)
    {
        $this->cliStatus = $cliStatus;
    }

    /**
     * @return mixed
     */
    public function getCliSelfie()
    {
        return $this->cliSelfie;
    }

    /**
     * @param mixed $cliSelfie
     */
    public function setCliSelfie($cliSelfie)
    {
        $this->cliSelfie = $cliSelfie;
    }

    /**
     * @return mixed
     */
    public function getCliDocFrente()
    {
        return $this->cliDocFrente;
    }

    /**
     * @param mixed $cliDocFrente
     */
    public function setCliDocFrente($cliDocFrente)
    {
        $this->cliDocFrente = $cliDocFrente;
    }

    /**
     * @return mixed
     */
    public function getCliDocVerso()
    {
        return $this->cliDocVerso;
    }

    /**
     * @param mixed $cliDocVerso
     */
    public function setCliDocVerso($cliDocVerso)
    {
        $this->cliDocVerso = $cliDocVerso;
    }

    /**
     * @return mixed
     */
    public function getCliCompEndereco()
    {
        return $this->cliCompEndereco;
    }

    /**
     * @param mixed $cliCompEndereco
     */
    public function setCliCompEndereco($cliCompEndereco)
    {
        $this->cliCompEndereco = $cliCompEndereco;
    }

    /**
     * @return mixed
     */
    public function getCliDeviceId()
    {
        return $this->cliDeviceId;
    }

    /**
     * @param mixed $cliDeviceId
     */
    public function setCliDeviceId($cliDeviceId)
    {
        $this->cliDeviceId = $cliDeviceId;
    }

    /**
     * @return mixed
     */
    public function getCliSenha()
    {
        return $this->cliSenha;
    }

    /**
     * @param mixed $cliSenha
     */
    public function setCliSenha($cliSenha)
    {
        $this->cliSenha = $cliSenha;
    }

    /**
     * @return mixed
     */
    public function getCliLoginBio()
    {
        return $this->cliLoginBio;
    }

    /**
     * @param mixed $cliLoginBio
     */
    public function setCliLoginBio($cliLoginBio)
    {
        $this->cliLoginBio = $cliLoginBio;
    }

    /**
     * @return mixed
     */
    public function getCliPushId()
    {
        return $this->cliPushId;
    }

    /**
     * @param mixed $cliPushId
     */
    public function setCliPushId($cliPushId)
    {
        $this->cliPushId = $cliPushId;
    }

    /**
     * @return mixed
     */
    public function getRetorno()
    {
        return $this->retorno;
    }

    /**
     * @param mixed $retorno
     */
    public function setRetorno($retorno)
    {
        $this->retorno = $retorno;
    }

    /**
     * @return mixed
     */
    public function getMensagemRetorno()
    {
        return $this->mensagemRetorno;
    }

    /**
     * @param mixed $mensagemRetorno
     */
    public function setMensagemRetorno($mensagemRetorno)
    {
        $this->mensagemRetorno = $mensagemRetorno;
    }

    /**
     * @return mixed
     */
    public function getCliPercentMatch()
    {
        return $this->cliPercentMatch;
    }

    /**
     * @param mixed $cliPercentMatch
     */
    public function setCliPercentMatch($cliPercentMatch)
    {
        $this->cliPercentMatch = $cliPercentMatch;
    }


}