/html/ecommerce.php
PHP | 413 lines | 337 code | 53 blank | 23 comment | 36 complexity | c67379ccbac299ca89b919b1d7ed3b92 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1, MPL-2.0-no-copyleft-exception
- <? /* license
-
- BilugCMS (http://www.bilug.it) - Content Management System for dynamic web sites
- Copyright (C) 2005-2008 Federico Villa and Alessio Loro Piana
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 2 of the License.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-
- For reference, contact bilugcms@vilnet.it
-
-
- license */ ?>
- <?php
- switch( $lingua_query ) {
- case 'it':
- $ECOMMERCE_FOTOLINGUA = 'Foto';
- $ECOMMERCE_PREZZOLINGUA = 'Prezzo';
- $ECOMMERCE_DISPONIBILITALINGUA = 'Disponibilità:';
- $ECOMMERCE_ARTICOLOLINGUA = 'Articolo:';
- $ECOMMERCE_PRODUTTORELINGUA = 'Produttore:';
- $ECOMMERCE_CODICELINGUA = 'Codice:';
- $ECOMMERCE_RIGUARDACARRELLOLINGUA = 'Riguarda carrello';
- $ECOMMERCE_TUTTILINGUA = 'Tutti';
- $ECOMMERCE_NUMEROARTICOLILINGUA = 'Numero Articoli:';
- $ECOMMERCE_NESSUNARTICOLOPRESENTELINGUA = 'Nessun articolo presente';
- $ECOMMERCE_CERCALINGUA = 'Cerca';
- $ECOMMERCE_INIZIOLINGUA = 'inizio';
- $ECOMMERCE_FINELINGUA = 'fine';
- $ECOMMERCE_SUCCESSIVOLINGUA = 'successivo';
- $ECOMMERCE_PRECEDENTELINGUA = 'precedente';
- break;
- case 'en':
- $ECOMMERCE_FOTOLINGUA = 'Photo:';
- $ECOMMERCE_PREZZOLINGUA = 'Price:';
- $ECOMMERCE_DISPONIBILITALINGUA = 'Availability:';
- $ECOMMERCE_ARTICOLOLINGUA = 'Article:';
- $ECOMMERCE_PRODUTTORELINGUA = 'Producer:';
- $ECOMMERCE_CODICELINGUA = 'Product key:';
- $ECOMMERCE_RIGUARDACARRELLOLINGUA = 'Review cart';
- $ECOMMERCE_TUTTILINGUA = 'All';
- $ECOMMERCE_NUMEROARTICOLILINGUA = 'Number of Articles:';
- $ECOMMERCE_NESSUNARTICOLOPRESENTELINGUA = 'No available items';
- $ECOMMERCE_CERCALINGUA = 'Search';
- $ECOMMERCE_INIZIOLINGUA = 'start';
- $ECOMMERCE_FINELINGUA = 'end';
- $ECOMMERCE_SUCCESSIVOLINGUA = 'next';
- $ECOMMERCE_PRECEDENTELINGUA = 'previous';
- break;
- case 'fr':
- $ECOMMERCE_FOTOLINGUA = 'Photos';
- $ECOMMERCE_PREZZOLINGUA ='Prix';
- $ECOMMERCE_DISPONIBILITALINGUA = 'Disponibilité:';
- $ECOMMERCE_ARTICOLOLINGUA = 'Article:';
- $ECOMMERCE_PRODUTTORELINGUA = 'Fabricant:';
- $ECOMMERCE_CODICELINGUA = 'Code:';
- $ECOMMERCE_RIGUARDACARRELLOLINGUA = 'Rapporter au panier';
- $ECOMMERCE_TUTTILINGUA = 'Tout';
- $ECOMMERCE_NUMEROARTICOLILINGUA = 'Nombre d'articles:';
- $ECOMMERCE_NESSUNARTICOLOPRESENTELINGUA = 'Exemplaires disponibles';
- $ECOMMERCE_CERCALINGUA = 'Rechercher';
- $ECOMMERCE_INIZIOLINGUA = 'départ';
- $ECOMMERCE_FINELINGUA = 'fin';
- $ECOMMERCE_SUCCESSIVOLINGUA = 'suivant';
- $ECOMMERCE_PRECEDENTELINGUA = 'précédent';
- break;
- case 'de':
- $ECOMMERCE_FOTOLINGUA = 'Fotos';
- $ECOMMERCE_PREZZOLINGUA = 'Preis';
- $ECOMMERCE_DISPONIBILITALINGUA = 'Verfügbarkeit:';
- $ECOMMERCE_ARTICOLOLINGUA = 'Artikel:';
- $ECOMMERCE_PRODUTTORELINGUA = 'Hersteller:';
- $ECOMMERCE_CODICELINGUA = 'Code:';
- $ECOMMERCE_RIGUARDACARRELLOLINGUA = 'Beziehen Warenkorb';
- $ECOMMERCE_TUTTILINGUA = 'Jeder';
- $ECOMMERCE_NUMEROARTICOLILINGUA = 'Anzahl der Artikel:';
- $ECOMMERCE_NESSUNARTICOLOPRESENTELINGUA = 'Keine artikel verfügbar';
- $ECOMMERCE_CERCALINGUA = 'Suchen';
- $ECOMMERCE_INIZIOLINGUA = 'anfang';
- $ECOMMERCE_FINELINGUA = 'ende';
- $ECOMMERCE_SUCCESSIVOLINGUA = 'nächste';
- $ECOMMERCE_PRECEDENTELINGUA = 'früher';
- break;
- case 'es':
- $ECOMMERCE_FOTOLINGUA = 'Fotos';
- $ECOMMERCE_PREZZOLINGUA = 'Precio';
- $ECOMMERCE_DISPONIBILITALINGUA = 'Disponibilidad:';
- $ECOMMERCE_ARTICOLOLINGUA = 'ArtÃculo:';
- $ECOMMERCE_PRODUTTORELINGUA = 'Fabricante:';
- $ECOMMERCE_CODICELINGUA = 'Código:';
- $ECOMMERCE_RIGUARDACARRELLOLINGUA = 'Saludos cesta';
- $ECOMMERCE_TUTTILINGUA = 'Todo';
- $ECOMMERCE_NUMEROARTICOLILINGUA = 'Número de artÃculos:';
- $ECOMMERCE_NESSUNARTICOLOPRESENTELINGUA = 'No hay datos disponibles';
- $ECOMMERCE_CERCALINGUA = 'Buscar';
- $ECOMMERCE_INIZIOLINGUA = 'comienzo';
- $ECOMMERCE_FINELINGUA = 'final';
- $ECOMMERCE_SUCCESSIVOLINGUA = 'siguiente';
- $ECOMMERCE_PRECEDENTELINGUA = 'anterior';
- break;
- case 'pt':
- $ECOMMERCE_FOTOLINGUA = 'Fotos';
- $ECOMMERCE_PREZZOLINGUA = 'Preço';
- $ECOMMERCE_DISPONIBILITALINGUA = 'Disponibilidade:';
- $ECOMMERCE_ARTICOLOLINGUA = 'Artigo:';
- $ECOMMERCE_PRODUTTORELINGUA = 'Fabricante:';
- $ECOMMERCE_CODICELINGUA = 'Código:';
- $ECOMMERCE_RIGUARDACARRELLOLINGUA = 'Relacionar ao carrinho';
- $ECOMMERCE_TUTTILINGUA = 'Todo';
- $ECOMMERCE_NUMEROARTICOLILINGUA = 'N&ucute;mero de artigos:';
- $ECOMMERCE_NESSUNARTICOLOPRESENTELINGUA = 'Não h´ itens disponíveis';
- $ECOMMERCE_CERCALINGUA = 'Pesquisar';
- $ECOMMERCE_INIZIOLINGUA = 'começando';
- $ECOMMERCE_FINELINGUA = 'final';
- $ECOMMERCE_SUCCESSIVOLINGUA = 'seguido';
- $ECOMMERCE_PRECEDENTELINGUA = 'anterior';
- break;
- }
- ?>
- <?php
- if ( !isset( $_GET["categoria"] ) OR $_GET["categoria"] == '' ) {
- // Controllo se la home page e una pagina statica
- $homepage = "SELECT id FROM parametri WHERE valore = './html/ecommerce.php' AND nomecampo = '_CORPO' LIMIT 1";
- $rshomepage = mysql_query( $homepage );
- $home = mysql_num_rows( $rshomepage );
- }
-
- if ( isset( $_GET["categoria"] ) )
- $cat = (int)mysql_real_escape_string( $_GET["categoria"] );
- else
- $cat = $ecommerce_statica;
-
- ?>
-
-
- <script type="text/javascript">
-
- function link_produttore( produttore, link ) {
- if ( produttore != '-' && produttore != '' )
- window.location = link + 'produttore-' + produttore + '/';
- else
- window.location = link;
- }
-
- </script>
-
-
-
- <?php
-
- $prod = ( isset( $_GET["prod"] ) ) ? $_GET["prod"] : '';
- $prod = str_replace( '-', ' ', $prod );
- $ind = (int)$_GET["ind"];
-
- $ris = $_GET["ris"];
-
- // controllo se la sessione e riservata o meno...
- if ( @$ris == 'no' ) $_SESSION['riservato'] = 'no';
-
- // Numero di articoli da visualizzare per ogni pagina
- $page=10;
-
- $pos = ( $ind == "" ) ? 0 : $ind;
-
- if ( $cat > 0 ) {
- $sql = "SELECT categoria FROM ecommercecategoria WHERE id = $cat AND id_lingua = $id_lingua LIMIT 1";
- $rssql = mysql_query( $sql );
- $h_cat = mysql_result( $rssql, 0, 0 );
-
- $v_id_cat = '';
- id_categorie_ecommerce( $cat, $v_id_cat );
- $v_id_cat .= ",$cat";
-
- $categorie = substr( $v_id_cat, 1 );
-
- $ric_cat = " AND e.categoria IN ( $categorie ) ";
- }
-
- if ( isset($_SESSION['arearis']) AND $_SESSION['arearis'] > 0 ) {
- $idut = $_SESSION['arearis'];
-
- // query estrazione stringa elenco articoli associati ad ogni utente
- $sql = "SELECT articoli FROM ecommerceris WHERE ID = '$idut' LIMIT 1";
- $rssql = mysql_query($sql);
- $articoli_ris = mysql_result($rssql, 0, 0);
- $articoli_ris = substr($articoli_ris, 1, strlen($articoli_ris)-2);
-
- $ric_ris = " AND e.riservato = 1 AND e.id IN ($articoli_ris)";
- }
- else {
- $ric_ris = " AND e.riservato = 0";
- }
-
- $ric_prod = ( isset( $prod ) AND $prod != "" ) ? " AND produttore = '$prod' " : "";
-
- $select = "e.id, e.titolo, e.prezzo, e.foto, e.spedizione, e.quantita, e.prezzo_intero, e.colore, e.taglia, e.riservato, e.produttore, e.codice";
-
- if( !isset( $_POST['cerca'] ) ) { //query di estrazione articoli -> se categoria vuota allora estraggo tutto
- $query = "
- SELECT $select
- FROM ecommerce e
- INNER JOIN ecommercecategoria ec ON ec.id = e.categoria
- WHERE 1 $ric_ris $ric_cat $ric_prod AND ec.id_lingua = $id_lingua
- ORDER BY e.titolo
- ";
- $ris = mysql_query( $query );
- $max = mysql_num_rows( $ris );
-
- $query .= " LIMIT $pos, $page";
- }
- else {
- $parola = apici( $_POST['parola'] );
- $inizio = substr($parola,0,1);
- $h_cat = "$ECOMMERCE_CERCALINGUA \"".$parola."\"";
-
- $query = "
- SELECT $select
- FROM ecommerce e
- INNER JOIN ecommercecategoria ec ON ec.id = e.categoria
- WHERE 1 $ric_ris AND ec.id_lingua = $id_lingua AND (
- e.codice = '$parola' OR
- e.categoria LIKE '%$parola%' OR
- e.titolo LIKE '%$parola%' OR
- e.produttore LIKE '%$parola%'
- )
- ";
- $ris = mysql_query( $query );
- $max = mysql_num_rows( $ris );
-
- $query .= " LIMIT $pos, $page";
- }
-
- $ris = mysql_query( $query );
-
- if ( $h_cat == '' ) {
- breadcrumbs( array(
- 'Home' => _URLSITO,
- 'E-commerce' => ''
- ) );
-
- $h_cat = 'E-commerce ' . _SITO;
- }
- else {
- breadcrumbs( array(
- 'Home' => _URLSITO,
- 'E-commerce' => _URLSITO.'/ecommerce/',
- $h_cat => ''
- ) );
- }
-
- echo "<h1><div>$h_cat</div></h1>";
- echo "<div class=\"contenitore contenitore-ecommerce\">";
-
- $link_prod = ( $cat <= 0 ) ? rurl( 0, 'ecommerce' ) : rurl( $cat, 'ecommerce-categorie' );
-
- echo "
- <div id=\"sel_produttore\">$ECOMMERCE_PRODUTTORELINGUA
- <select name=\"prod\" onchange=\"link_produttore( this.value, '$link_prod' );\">
- <option value=\"\">$ECOMMERCE_TUTTILINGUA</option>
- <option value=\"-\">-----------------------------------------</option>";
- if ( $cat <= 0 )
- $sqlprod = "SELECT e.produttore, e.riservato FROM ecommerce e WHERE 1 $ric_ris GROUP BY e.produttore ORDER BY e.produttore ASC";
- else
- $sqlprod = "SELECT e.produttore, e.riservato FROM ecommerce e WHERE 1 $ric_ris $ric_cat GROUP BY e.produttore ORDER BY e.produttore ASC";
- $rssqlprod = mysql_query( $sqlprod );
- while( $row = mysql_fetch_array( $rssqlprod ) ) {
- $value = rurl_rewrite2( $row[0] );
- if ( strtolower( $row[0] ) == strtolower( $prod ) )
- echo "<option value=\"$value\" selected=\"selected\">$row[0]</option>";
- else
- echo "<option value=\"$value\">$row[0]</option>";
- }
- echo " </select>
- </div>
- ";
-
- $link = rurl( 0, 'ecommerce-dettaglio-carrello' );
- echo"
- <div class=\"carrello\">
- <a href=\"$link\">$ECOMMERCE_RIGUARDACARRELLOLINGUA
- <img src=\""._URLSITO."/img/carrello.png\" class=\"ecomico\"></a>
- </div>
- <div class=\"azzerafloat\"></div>
- ";
- Nav($cat,$max,$pos,$page,$prod);
- ?>
-
-
- <div class="celle-ecommerce celle-intestazioni">
- <div class="cella"><?=$ECOMMERCE_FOTOLINGUA?></div>
- <div class="cella"><?=$ECOMMERCE_ARTICOLOLINGUA?></div>
- <div class="cella"><?=$ECOMMERCE_PREZZOLINGUA?> €</div>
- <div class="cella"><?=$ECOMMERCE_DISPONIBILITALINGUA?></div>
- <div class="azzerafloat"></div>
- </div>
-
-
- <?php
- while($art=mysql_fetch_row($ris)) {?>
-
- <div class="celle-ecommerce celle-articoli">
- <div class="cella">
- <?php
- $link = rurl( $art[0], 'ecommerce-dettaglio' );
- if ( $art[3] == "" )
- $src = _URLSITO . "/custom/archivio/images/standard.jpg";
- elseif ( strpos( $art[3], array( 'http://', 'https://' ) ) === false )
- $src = $art[3];
- else {
- $fototrunk = strrpos($art[3],"/");
- $fototrunk = $fototrunk + 1;
- $art[3] = substr($art[3], $fototrunk);
- $art[3] = substr($art[3], 0, strlen($art[3])-1);
- $src = _URLSITO . "/custom/archivio/images/$art[3]";
- }
-
- echo "<a href=\"$link\" title=\"$art[1]\"><img src=\"$src\" alt=\"$art[1]\" class=\"ecomsec\"></a>";
- ?>
- </div>
- <div class="cella">
- <?php $link = rurl( $art[0], 'ecommerce-dettaglio' ); ?>
- <h3>
- <a href="<?=$link?>"><?=$art[1]?></a>
- <?=adm_link('ecommerce', $art[0])?>
- </h3>
- <h4><?=$ECOMMERCE_PRODUTTORELINGUA?> <?=$art[10]?></h4>
- <h4><?=$ECOMMERCE_CODICELINGUA?> <?=$art[11]?></h4>
- <?php if ( $art[7] != '' ) : ?><h5>Colore: <?=$art[7]?></h5><?php endif; ?>
- <?php if ( $art[8] != '' ) : ?><h5>Taglia: <?=$art[8]?></h5><?php endif; ?>
- </div>
- <div class="cella">
- <?php
- $prezzo = number_format($art[2], 2, ',', '.');
-
- if ( $art[6] > $art[2] )
- echo "<span style=\"text-decoration:line-through; color: red;\">".number_format($art[6], 2, ',', '.')." €<br /></span><br />";
-
- echo "$prezzo €";
- ?>
- </div>
- <div class="cella">
- <?=$art[5]?>
- </div>
-
- <div class="azzerafloat"></div>
- </div>
- <?php
- }
-
- Nav($cat,$max,$pos,$page,$prod);
-
- $link = rurl( 0, 'ecommerce-dettaglio-carrello' );
- echo"
- <div class=\"carrello\">
- <a href=\"$link\">$ECOMMERCE_RIGUARDACARRELLOLINGUA
- <img src=\""._URLSITO."/img/carrello.png\" class=\"ecomico\"></a>
- </div>
- <div class=\"azzerafloat\"></div>
- ";
-
- echo "</div>";
- ?>
-
-
- <?php
-
- function Nav( $cat, $max, $pos, $pag, $prod ) {
- global $ECOMMERCE_NUMEROARTICOLILINGUA;
- global $ECOMMERCE_NESSUNARTICOLOPRESENTELINGUA;
- global $ECOMMERCE_INIZIOLINGUA;
- global $ECOMMERCE_PRECEDENTELINGUA;
- global $ECOMMERCE_SUCCESSIVOLINGUA;
- global $ECOMMERCE_FINELINGUA;
-
- echo "<div class=\"navigazione\">";
- echo ( $max != 0 ) ? "<div class=\"numero-articoli\">$ECOMMERCE_NUMEROARTICOLILINGUA $max</div>" : "<div class=\"numero-articoli\">$ECOMMERCE_NESSUNARTICOLOPRESENTELINGUA</div>";
-
- if ( $pos > 0 OR $max > ( $pos + $pag ) ) {
- $link = rurl( $cat, 'ecommerce-categorie' );
- if ( $prod != '' ) $link .= "produttore-$prod/";
- echo "<div class=\"numero-pagina\">";
- if ( $pos > 0 ) {
- echo "<div class=\"precedente\">";
- $link1 = $link . "indice-0/";
- echo "<a href=\"$link1\"><< $ECOMMERCE_INIZIOLINGUA</a> ";
- $link2 = $link . "indice-".($pos-$pag)."/";
- echo "<a href=\"$link2\">< $ECOMMERCE_PRECEDENTELINGUA</a> ";
- echo "</div>";
- }
- if ( $max > $pos + $pag ) {
- echo "<div class=\"successivo\">";
- $link1 = $link . "indice-".($pos+$pag)."/";
- echo "<a href=\"$link1\">$ECOMMERCE_SUCCESSIVOLINGUA ></a>";
- $link2 = $link . "indice-".($max-$pag)."/";
- echo "<a href=\"$link2\">$ECOMMERCE_FINELINGUA >></a>";
- echo "</div>";
- }
- echo "<div class=\"azzerafloat\"></div>";
- echo "</div>";
- }
- echo "</div>";
- }
-
- ?>
-