public function SQLS() { if (isset($_GET['veiculos']) && $_GET['veiculos'] != "") { $idsVeiculo = explode("_", $_GET['veiculos']); $idsQuery = ''; foreach ($idsVeiculo as $id) { $idsQuery .= ($idsQuery != '' ? ',' : '') . $id; } $this->_qtde_veiculos = count($idsVeiculo); $strSQL = "SELECT \n\t\t\t\t\t\t\tID, \n\t\t\t\t\t\t\tMARCA, \n\t\t\t\t\t\t\tMODELO, \n\t\t\t\t\t\t\tANO_FABRICACAO, \n\t\t\t\t\t\t\tANO_MODELO, \n\t\t\t\t\t\t\tVERSAO, \n\t\t\t\t\t\t\tCOR, \n\t\t\t\t\t\t\tCAMBIO, \n\t\t\t\t\t\t\tPORTAS, \n\t\t\t\t\t\t\tKM, \n\t\t\t\t\t\t\tFL_FOTO, \n\t\t\t\t\t\t\tFOTOS, \n\t\t\t\t\t\t\tCOMBUSTIVEL, \n\t\t\t\t\t\t\tPLACA, \n\t\t\t\t\t\t\tPRECO, \n\t\t\t\t\t\t\tNOME_LOJA, \n\t\t\t\t\t\t\tNOME_GRUPO, \n\t\t\t\t\t\t\tBAIRRO, \n\t\t\t\t\t\t\tCIDADE, \n\t\t\t\t\t\t\tTITULO, \n\t\t\t\t\t\t\tSIGLA_ESTADO, \n\t\t\t\t\t\t\tTELEFONE_CONTATO, \n\t\t\t\t\t\t\tACESSORIOS, \n\t\t\t\t\t\t\tEMAIL_CONTATO \n\t\t\t\t\t\tFROM \n\t\t\t\t\t\t\tveiculos \n\t\t\t\t\t\tWHERE \n\t\t\t\t\t\t\tID IN (" . $idsQuery . ")"; $conexao = new Model(); $this->_dados_veiculo = $conexao->hand($strSQL); $this->_titulo = 'Comparativo de Veículos (' . $_SERVER['HTTP_HOST'] . URL . ')'; $this->_dadosCompare = ''; foreach ($this->_dados_veiculo as $itens) { if ($this->_descricao != '') { $this->_descricao .= ', '; } if ($this->_compare != '') { $this->_compare .= '_'; } if ($this->_dadosCompare != '') { $this->_dadosCompare .= '|'; } $this->_descricao .= $itens->MARCA . " " . $itens->MODELO . " " . $itens->VERSAO . " - " . $itens->ANO_MODELO; $this->_compare .= $itens->ID; $this->_dadosCompare .= $itens->MARCA . ";" . $itens->MODELO . ";" . $itens->VERSAO . ";" . $itens->ANO_FABRICACAO . "/" . $itens->ANO_MODELO . ";" . $itens->PRECO; } $this->montaLinkModalEnvioCompare($this->_compare, $this->_dadosCompare, $this->_link_enviar, $this->_div_enviar, base64_encode($this->getLinkEnviar())); $this->_existe_veiculos = true; } }
public function exibirDestaquesInterna($button = '') { $strSQL = "SELECT\n\t\t\t\t\t\tID,\n\t\t\t\t\t\tMARCA,\n\t\t\t\t\t\tMODELO,\n\t\t\t\t\t\tVERSAO,\n\t\t\t\t\t\tANO_FABRICACAO AS ANO_FAB,\n\t\t\t\t\t\tANO_MODELO AS ANO_MOD,\n\t\t\t\t\t\tPRECO,\n\t\t\t\t\t\tFOTOS\n\t\t\t\t\tFROM\n\t\t\t\t\t\tveiculos\n\t\t\t\t\tWHERE\n\t\t\t\t\t\tFL_FOTO=1\n\t\t\t\t\tORDER BY RAND()\n\t\t\t\t\tLIMIT 0, 20"; $conexao = new Model(); $retVeiculos = $conexao->hand($strSQL); $i = 0; foreach ($retVeiculos as $veiculo) { $foto = $this->retornaFotos($veiculo->FOTOS); $versao = $veiculo->MARCA . ' ' . $veiculo->MODELO; $ano = $veiculo->ANO_FAB . '/' . $veiculo->ANO_MOD; $preco = $this->formataPrecoGeral($veiculo->PRECO); $link = URL . '/estoque/detalhes&veiculo=' . $veiculo->ID; if ($i == 0) { echo '<li>'; } echo "<article class='boxCarro'>"; echo "<img src='" . $this->getCaminhoFotos() . $foto[0]['med'] . "' width='100%'>"; echo '<div class="infoCarro">'; echo '<h1>' . $versao . '</h1>'; echo '<p class="ano">' . $ano . '</p>'; echo '<p class="preco">' . $preco . '</p>'; echo '<a class="btn btnSeminovos" href="' . $link . '">Detalhes do veículo</a>'; echo '</div>'; echo "</article>"; if ($i == 0) { $i++; } else { echo '</li>'; $i = 0; } } ?> <?php }
public function exibirSimilares() { /** * Defini o valor com 5000 a mais ou a menos do valor do carro atual */ $menos = $this->_dados_veiculo->PRECO - 5000; $mais = $this->_dados_veiculo->PRECO + 5000; /** * Faz o QUERY dos carros similares ao atual e limita a exibir 12 carros / AND QTD_FOTOS>0 */ $simConsulta = "SELECT\n\t\t\t\t\t\t\tID,\n\t\t\t\t\t\t\tMARCA,\n\t\t\t\t\t\t\tMODELO,\n\t\t\t\t\t\t\tANO_MODELO,\n\t\t\t\t\t\t\tPRECO,\n\t\t\t\t\t\t\tFOTOS,\n\t\t\t\t\t\t\tFL_FOTO\n\t\t\t\t\t\tFROM\n\t\t\t\t\t\t(\n\t\t\t\t\t\t\tSELECT\n\t\t\t\t\t\t\t\t*\n\t\t\t\t\t\t\tFROM veiculos\n\t\t\t\t\t\t\tGROUP BY MODELO\n\t\t\t\t\t\t\tORDER BY RAND()\n\t\t\t\t\t\t) veiculos\n\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\tPRECO > " . $menos . " AND\n\t\t\t\t\t\t\tPRECO < " . $mais . " AND\n\t\t\t\t\t\t\tPRECO > 10000 AND\n\t\t\t\t\t\t\tFL_FOTO = 1\n\t\t\t\t\t\tORDER BY RAND(),MARCA,MODELO,ANO_MODELO DESC\n\t\t\t\t\t\tLIMIT 12"; $conexao = new Model(); $retornoSimilares = $conexao->hand($simConsulta); $nItensSim = count($retornoSimilares); if ($nItensSim > 0) { ?> <div class="middle"> <div class="head"> <h3> <img src="<?php echo IMG; ?> buscador/icon.jpg" alt="icon" /> Você também pode se interessar nestes carros: </h3> </div> <!-- slide coding start--> <div class="modelo-slider"> <div class="erapido-album-carousel-prev modelo-prev-btn prev1"> </div> <div id="carousel1" class="erapido-album-carousel-modelo" > <div itemscope class="highslide-gallery"> <ul> <?php foreach ($retornoSimilares as $similares) { $imagem = IMG . "buscador/auto-slide-img.jpg"; if ($similares->FL_FOTO == 1) { $fotos = $this->retornaFotos($similares->FOTOS); $imagem = $this->getCaminhoFotos() . $fotos[0]['peq']; } ?> <li> <a href="detalhes&veiculo=<?php echo $similares->ID; ?> "> <img src="<?php echo $imagem; ?> " width="127" height="96" alt="#" /> </a> <?php echo htmlentities(utf8_decode($similares->MARCA)) . "<br />" . htmlentities(utf8_decode($similares->MODELO)) . "<br />" . $similares->ANO_MODELO; ?> <br /> <span><?php echo "R\$ " . number_format($similares->PRECO, 0, ",", "."); ?> </span> </li> <?php } ?> </ul> </div> </div> <div class="erapido-album-carousel-next modelo-next-btn next1"> </div> </div> <!-- slide coding ends--> </div> <?php } }
if (isset($_GET['loja']) && (int) $_GET['loja'] > 0) { $condicao .= (trim($condicao) != '' ? ' AND' : '') . ' ID_LOJA="' . $_GET['loja'] . '"'; } $marcas_principais = array(); $marcas_principais[] = "CHEVROLET"; $marcas_principais[] = "CITROEN"; $marcas_principais[] = "FIAT"; $marcas_principais[] = "FORD"; $marcas_principais[] = "HONDA"; $marcas_principais[] = "HYUNDAI"; $marcas_principais[] = "PEUGEOT"; $marcas_principais[] = "RENAULT"; $marcas_principais[] = "TOYOTA"; $marcas_principais[] = "VOLKSWAGEN"; $strSQL = "SELECT\n DISTINCT ID_MARCA,\n MARCA\n FROM\n veiculos\n " . (trim($condicao) != '' ? ' WHERE' . $condicao : '') . "\n ORDER BY MARCA ASC;"; $retMarcas = $conexao->hand($strSQL); $opt_marca_principal = array(); $opt_marca = array(); foreach ($retMarcas as $record) { $item_marca = utf8_decode($record->MARCA); if (in_array($item_marca, $marcas_prform_propostaincipais)) { $opt_marca_principal[] = "<option value='" . $record->ID_MARCA . "'>" . $item_marca . "</option>"; } else { $opt_marca[] = "<option value='" . $record->ID_MARCA . "'>" . $item_marca . "</option>"; } } if (count($opt_marca_principal) > 0) { foreach ($opt_marca_principal as $opt_principal) { echo $opt_principal; } if (count($opt_marca) > 0) {
public function retornaValor($tipo = 0) { $strSQL = "SELECT\n " . ($tipo > 0 ? "(P.PRECO+10000)" : "P.PRECO") . " AS PRECO\n FROM\n veiculos V\n INNER JOIN faixa_preco F ON F.FAIXA_PRECO=V.FAIXA_PRECO\n INNER JOIN preco_busca P ON (P.PRECO+1)=F.PRECO_INICIAL AND (P.PRECO<=F.PRECO_FINAL OR F.PRECO_FINAL=0)\n GROUP BY\n P.PRECO\n ORDER BY\n P.PRECO ASC;"; $conexao = new Model(); $retValor = $conexao->hand($strSQL); $arr_preco = array(); foreach ($retValor as $record) { $preco = array(); $preco["PRECO"] = $record->PRECO; $arr_preco[] = $preco; } if (count($arr_preco) > 0) { foreach ($arr_preco as $preco) { $ret .= '<option value="' . $preco["PRECO"] . '">' . number_format($preco["PRECO"], 0, ",", ".") . '</option>'; } } return $ret; }
public function SQLS() { $conexao = new Model(); $retorno = array(); $strSQLDestaque = $this->montaSQLSelectFrom("1_destaque", $this->_where, $this->_select_query); $strSQLDestaque .= $this->trataWhereDestaque($this->_where); $strSQLDestaque .= " ORDER BY FL_FOTO DESC, RAND() LIMIT 0,3;"; /* Retorna os veículos em destaque e o seu total */ $destaques['veiculos'] = $conexao->hand($strSQLDestaque); $destaques['total'] = count($destaques['veiculos']); $this->_destaques = (object) $destaques; if ($destaques['total'] > 0) { $str_id = ""; foreach ($destaques['veiculos'] as $id) { $str_id .= "," . $id; } if ($str_id != "") { $str_id = substr($str_id, 1); if ($this->_where != "") { $this->_where .= " AND "; } else { $this->_where .= " WHERE "; } $this->_where .= " ID NOT IN(" . $str_id . ")"; } } $strSQL = $this->montaSQLSelectFrom("2_normal", $this->_where, $this->_select_query); $strSQL .= $this->montaSQLOrder($this->_select_query, $this->_order); $strSQL .= $this->montaSQLLimit($this->_pag_atual_busca, $this->_gets['tpp']); /* Retorna os veículos e o seu total */ $veiculos['veiculos'] = $conexao->hand($strSQL); $veiculos['total'] = count($veiculos['veiculos']); $this->_veiculos = (object) $veiculos; }