PageRenderTime 47ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/html/ecommerce.php

https://code.google.com/p/bilugcms/
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
  1. <? /* license
  2. BilugCMS (http://www.bilug.it) - Content Management System for dynamic web sites
  3. Copyright (C) 2005-2008 Federico Villa and Alessio Loro Piana
  4. This program is free software: you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation, either version 2 of the License.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. For reference, contact bilugcms@vilnet.it
  14. license */ ?>
  15. <?php
  16. switch( $lingua_query ) {
  17. case 'it':
  18. $ECOMMERCE_FOTOLINGUA = 'Foto';
  19. $ECOMMERCE_PREZZOLINGUA = 'Prezzo';
  20. $ECOMMERCE_DISPONIBILITALINGUA = 'Disponibilit&agrave;:';
  21. $ECOMMERCE_ARTICOLOLINGUA = 'Articolo:';
  22. $ECOMMERCE_PRODUTTORELINGUA = 'Produttore:';
  23. $ECOMMERCE_CODICELINGUA = 'Codice:';
  24. $ECOMMERCE_RIGUARDACARRELLOLINGUA = 'Riguarda carrello';
  25. $ECOMMERCE_TUTTILINGUA = 'Tutti';
  26. $ECOMMERCE_NUMEROARTICOLILINGUA = 'Numero Articoli:';
  27. $ECOMMERCE_NESSUNARTICOLOPRESENTELINGUA = 'Nessun articolo presente';
  28. $ECOMMERCE_CERCALINGUA = 'Cerca';
  29. $ECOMMERCE_INIZIOLINGUA = 'inizio';
  30. $ECOMMERCE_FINELINGUA = 'fine';
  31. $ECOMMERCE_SUCCESSIVOLINGUA = 'successivo';
  32. $ECOMMERCE_PRECEDENTELINGUA = 'precedente';
  33. break;
  34. case 'en':
  35. $ECOMMERCE_FOTOLINGUA = 'Photo:';
  36. $ECOMMERCE_PREZZOLINGUA = 'Price:';
  37. $ECOMMERCE_DISPONIBILITALINGUA = 'Availability:';
  38. $ECOMMERCE_ARTICOLOLINGUA = 'Article:';
  39. $ECOMMERCE_PRODUTTORELINGUA = 'Producer:';
  40. $ECOMMERCE_CODICELINGUA = 'Product key:';
  41. $ECOMMERCE_RIGUARDACARRELLOLINGUA = 'Review cart';
  42. $ECOMMERCE_TUTTILINGUA = 'All';
  43. $ECOMMERCE_NUMEROARTICOLILINGUA = 'Number of Articles:';
  44. $ECOMMERCE_NESSUNARTICOLOPRESENTELINGUA = 'No available items';
  45. $ECOMMERCE_CERCALINGUA = 'Search';
  46. $ECOMMERCE_INIZIOLINGUA = 'start';
  47. $ECOMMERCE_FINELINGUA = 'end';
  48. $ECOMMERCE_SUCCESSIVOLINGUA = 'next';
  49. $ECOMMERCE_PRECEDENTELINGUA = 'previous';
  50. break;
  51. case 'fr':
  52. $ECOMMERCE_FOTOLINGUA = 'Photos';
  53. $ECOMMERCE_PREZZOLINGUA ='Prix';
  54. $ECOMMERCE_DISPONIBILITALINGUA = 'Disponibilit&eacute;:';
  55. $ECOMMERCE_ARTICOLOLINGUA = 'Article:';
  56. $ECOMMERCE_PRODUTTORELINGUA = 'Fabricant:';
  57. $ECOMMERCE_CODICELINGUA = 'Code:';
  58. $ECOMMERCE_RIGUARDACARRELLOLINGUA = 'Rapporter au panier';
  59. $ECOMMERCE_TUTTILINGUA = 'Tout';
  60. $ECOMMERCE_NUMEROARTICOLILINGUA = 'Nombre d&#39;articles:';
  61. $ECOMMERCE_NESSUNARTICOLOPRESENTELINGUA = 'Exemplaires disponibles';
  62. $ECOMMERCE_CERCALINGUA = 'Rechercher';
  63. $ECOMMERCE_INIZIOLINGUA = 'd&eacute;part';
  64. $ECOMMERCE_FINELINGUA = 'fin';
  65. $ECOMMERCE_SUCCESSIVOLINGUA = 'suivant';
  66. $ECOMMERCE_PRECEDENTELINGUA = 'pr&eacute;c&eacute;dent';
  67. break;
  68. case 'de':
  69. $ECOMMERCE_FOTOLINGUA = 'Fotos';
  70. $ECOMMERCE_PREZZOLINGUA = 'Preis';
  71. $ECOMMERCE_DISPONIBILITALINGUA = 'Verf&uuml;gbarkeit:';
  72. $ECOMMERCE_ARTICOLOLINGUA = 'Artikel:';
  73. $ECOMMERCE_PRODUTTORELINGUA = 'Hersteller:';
  74. $ECOMMERCE_CODICELINGUA = 'Code:';
  75. $ECOMMERCE_RIGUARDACARRELLOLINGUA = 'Beziehen Warenkorb';
  76. $ECOMMERCE_TUTTILINGUA = 'Jeder';
  77. $ECOMMERCE_NUMEROARTICOLILINGUA = 'Anzahl der Artikel:';
  78. $ECOMMERCE_NESSUNARTICOLOPRESENTELINGUA = 'Keine artikel verf&uuml;gbar';
  79. $ECOMMERCE_CERCALINGUA = 'Suchen';
  80. $ECOMMERCE_INIZIOLINGUA = 'anfang';
  81. $ECOMMERCE_FINELINGUA = 'ende';
  82. $ECOMMERCE_SUCCESSIVOLINGUA = 'n&auml;chste';
  83. $ECOMMERCE_PRECEDENTELINGUA = 'fr&uuml;her';
  84. break;
  85. case 'es':
  86. $ECOMMERCE_FOTOLINGUA = 'Fotos';
  87. $ECOMMERCE_PREZZOLINGUA = 'Precio';
  88. $ECOMMERCE_DISPONIBILITALINGUA = 'Disponibilidad:';
  89. $ECOMMERCE_ARTICOLOLINGUA = 'Artículo:';
  90. $ECOMMERCE_PRODUTTORELINGUA = 'Fabricante:';
  91. $ECOMMERCE_CODICELINGUA = 'C&oacute;digo:';
  92. $ECOMMERCE_RIGUARDACARRELLOLINGUA = 'Saludos cesta';
  93. $ECOMMERCE_TUTTILINGUA = 'Todo';
  94. $ECOMMERCE_NUMEROARTICOLILINGUA = 'N&uacute;mero de artículos:';
  95. $ECOMMERCE_NESSUNARTICOLOPRESENTELINGUA = 'No hay datos disponibles';
  96. $ECOMMERCE_CERCALINGUA = 'Buscar';
  97. $ECOMMERCE_INIZIOLINGUA = 'comienzo';
  98. $ECOMMERCE_FINELINGUA = 'final';
  99. $ECOMMERCE_SUCCESSIVOLINGUA = 'siguiente';
  100. $ECOMMERCE_PRECEDENTELINGUA = 'anterior';
  101. break;
  102. case 'pt':
  103. $ECOMMERCE_FOTOLINGUA = 'Fotos';
  104. $ECOMMERCE_PREZZOLINGUA = 'Pre&ccedil;o';
  105. $ECOMMERCE_DISPONIBILITALINGUA = 'Disponibilidade:';
  106. $ECOMMERCE_ARTICOLOLINGUA = 'Artigo:';
  107. $ECOMMERCE_PRODUTTORELINGUA = 'Fabricante:';
  108. $ECOMMERCE_CODICELINGUA = 'C&oacute;digo:';
  109. $ECOMMERCE_RIGUARDACARRELLOLINGUA = 'Relacionar ao carrinho';
  110. $ECOMMERCE_TUTTILINGUA = 'Todo';
  111. $ECOMMERCE_NUMEROARTICOLILINGUA = 'N&ucute;mero de artigos:';
  112. $ECOMMERCE_NESSUNARTICOLOPRESENTELINGUA = 'N&atilde;o h&acute; itens dispon&iacute;veis';
  113. $ECOMMERCE_CERCALINGUA = 'Pesquisar';
  114. $ECOMMERCE_INIZIOLINGUA = 'come&ccedil;ando';
  115. $ECOMMERCE_FINELINGUA = 'final';
  116. $ECOMMERCE_SUCCESSIVOLINGUA = 'seguido';
  117. $ECOMMERCE_PRECEDENTELINGUA = 'anterior';
  118. break;
  119. }
  120. ?>
  121. <?php
  122. if ( !isset( $_GET["categoria"] ) OR $_GET["categoria"] == '' ) {
  123. // Controllo se la home page e una pagina statica
  124. $homepage = "SELECT id FROM parametri WHERE valore = './html/ecommerce.php' AND nomecampo = '_CORPO' LIMIT 1";
  125. $rshomepage = mysql_query( $homepage );
  126. $home = mysql_num_rows( $rshomepage );
  127. }
  128. if ( isset( $_GET["categoria"] ) )
  129. $cat = (int)mysql_real_escape_string( $_GET["categoria"] );
  130. else
  131. $cat = $ecommerce_statica;
  132. ?>
  133. <script type="text/javascript">
  134. function link_produttore( produttore, link ) {
  135. if ( produttore != '-' && produttore != '' )
  136. window.location = link + 'produttore-' + produttore + '/';
  137. else
  138. window.location = link;
  139. }
  140. </script>
  141. <?php
  142. $prod = ( isset( $_GET["prod"] ) ) ? $_GET["prod"] : '';
  143. $prod = str_replace( '-', ' ', $prod );
  144. $ind = (int)$_GET["ind"];
  145. $ris = $_GET["ris"];
  146. // controllo se la sessione e riservata o meno...
  147. if ( @$ris == 'no' ) $_SESSION['riservato'] = 'no';
  148. // Numero di articoli da visualizzare per ogni pagina
  149. $page=10;
  150. $pos = ( $ind == "" ) ? 0 : $ind;
  151. if ( $cat > 0 ) {
  152. $sql = "SELECT categoria FROM ecommercecategoria WHERE id = $cat AND id_lingua = $id_lingua LIMIT 1";
  153. $rssql = mysql_query( $sql );
  154. $h_cat = mysql_result( $rssql, 0, 0 );
  155. $v_id_cat = '';
  156. id_categorie_ecommerce( $cat, $v_id_cat );
  157. $v_id_cat .= ",$cat";
  158. $categorie = substr( $v_id_cat, 1 );
  159. $ric_cat = " AND e.categoria IN ( $categorie ) ";
  160. }
  161. if ( isset($_SESSION['arearis']) AND $_SESSION['arearis'] > 0 ) {
  162. $idut = $_SESSION['arearis'];
  163. // query estrazione stringa elenco articoli associati ad ogni utente
  164. $sql = "SELECT articoli FROM ecommerceris WHERE ID = '$idut' LIMIT 1";
  165. $rssql = mysql_query($sql);
  166. $articoli_ris = mysql_result($rssql, 0, 0);
  167. $articoli_ris = substr($articoli_ris, 1, strlen($articoli_ris)-2);
  168. $ric_ris = " AND e.riservato = 1 AND e.id IN ($articoli_ris)";
  169. }
  170. else {
  171. $ric_ris = " AND e.riservato = 0";
  172. }
  173. $ric_prod = ( isset( $prod ) AND $prod != "" ) ? " AND produttore = '$prod' " : "";
  174. $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";
  175. if( !isset( $_POST['cerca'] ) ) { //query di estrazione articoli -> se categoria vuota allora estraggo tutto
  176. $query = "
  177. SELECT $select
  178. FROM ecommerce e
  179. INNER JOIN ecommercecategoria ec ON ec.id = e.categoria
  180. WHERE 1 $ric_ris $ric_cat $ric_prod AND ec.id_lingua = $id_lingua
  181. ORDER BY e.titolo
  182. ";
  183. $ris = mysql_query( $query );
  184. $max = mysql_num_rows( $ris );
  185. $query .= " LIMIT $pos, $page";
  186. }
  187. else {
  188. $parola = apici( $_POST['parola'] );
  189. $inizio = substr($parola,0,1);
  190. $h_cat = "$ECOMMERCE_CERCALINGUA \"".$parola."\"";
  191. $query = "
  192. SELECT $select
  193. FROM ecommerce e
  194. INNER JOIN ecommercecategoria ec ON ec.id = e.categoria
  195. WHERE 1 $ric_ris AND ec.id_lingua = $id_lingua AND (
  196. e.codice = '$parola' OR
  197. e.categoria LIKE '%$parola%' OR
  198. e.titolo LIKE '%$parola%' OR
  199. e.produttore LIKE '%$parola%'
  200. )
  201. ";
  202. $ris = mysql_query( $query );
  203. $max = mysql_num_rows( $ris );
  204. $query .= " LIMIT $pos, $page";
  205. }
  206. $ris = mysql_query( $query );
  207. if ( $h_cat == '' ) {
  208. breadcrumbs( array(
  209. 'Home' => _URLSITO,
  210. 'E-commerce' => ''
  211. ) );
  212. $h_cat = 'E-commerce ' . _SITO;
  213. }
  214. else {
  215. breadcrumbs( array(
  216. 'Home' => _URLSITO,
  217. 'E-commerce' => _URLSITO.'/ecommerce/',
  218. $h_cat => ''
  219. ) );
  220. }
  221. echo "<h1><div>$h_cat</div></h1>";
  222. echo "<div class=\"contenitore contenitore-ecommerce\">";
  223. $link_prod = ( $cat <= 0 ) ? rurl( 0, 'ecommerce' ) : rurl( $cat, 'ecommerce-categorie' );
  224. echo "
  225. <div id=\"sel_produttore\">$ECOMMERCE_PRODUTTORELINGUA
  226. <select name=\"prod\" onchange=\"link_produttore( this.value, '$link_prod' );\">
  227. <option value=\"\">$ECOMMERCE_TUTTILINGUA</option>
  228. <option value=\"-\">-----------------------------------------</option>";
  229. if ( $cat <= 0 )
  230. $sqlprod = "SELECT e.produttore, e.riservato FROM ecommerce e WHERE 1 $ric_ris GROUP BY e.produttore ORDER BY e.produttore ASC";
  231. else
  232. $sqlprod = "SELECT e.produttore, e.riservato FROM ecommerce e WHERE 1 $ric_ris $ric_cat GROUP BY e.produttore ORDER BY e.produttore ASC";
  233. $rssqlprod = mysql_query( $sqlprod );
  234. while( $row = mysql_fetch_array( $rssqlprod ) ) {
  235. $value = rurl_rewrite2( $row[0] );
  236. if ( strtolower( $row[0] ) == strtolower( $prod ) )
  237. echo "<option value=\"$value\" selected=\"selected\">$row[0]</option>";
  238. else
  239. echo "<option value=\"$value\">$row[0]</option>";
  240. }
  241. echo " </select>
  242. </div>
  243. ";
  244. $link = rurl( 0, 'ecommerce-dettaglio-carrello' );
  245. echo"
  246. <div class=\"carrello\">
  247. <a href=\"$link\">$ECOMMERCE_RIGUARDACARRELLOLINGUA
  248. <img src=\""._URLSITO."/img/carrello.png\" class=\"ecomico\"></a>
  249. </div>
  250. <div class=\"azzerafloat\"></div>
  251. ";
  252. Nav($cat,$max,$pos,$page,$prod);
  253. ?>
  254. <div class="celle-ecommerce celle-intestazioni">
  255. <div class="cella"><?=$ECOMMERCE_FOTOLINGUA?></div>
  256. <div class="cella"><?=$ECOMMERCE_ARTICOLOLINGUA?></div>
  257. <div class="cella"><?=$ECOMMERCE_PREZZOLINGUA?> &euro;</div>
  258. <div class="cella"><?=$ECOMMERCE_DISPONIBILITALINGUA?></div>
  259. <div class="azzerafloat"></div>
  260. </div>
  261. <?php
  262. while($art=mysql_fetch_row($ris)) {?>
  263. <div class="celle-ecommerce celle-articoli">
  264. <div class="cella">
  265. <?php
  266. $link = rurl( $art[0], 'ecommerce-dettaglio' );
  267. if ( $art[3] == "" )
  268. $src = _URLSITO . "/custom/archivio/images/standard.jpg";
  269. elseif ( strpos( $art[3], array( 'http://', 'https://' ) ) === false )
  270. $src = $art[3];
  271. else {
  272. $fototrunk = strrpos($art[3],"/");
  273. $fototrunk = $fototrunk + 1;
  274. $art[3] = substr($art[3], $fototrunk);
  275. $art[3] = substr($art[3], 0, strlen($art[3])-1);
  276. $src = _URLSITO . "/custom/archivio/images/$art[3]";
  277. }
  278. echo "<a href=\"$link\" title=\"$art[1]\"><img src=\"$src\" alt=\"$art[1]\" class=\"ecomsec\"></a>";
  279. ?>
  280. </div>
  281. <div class="cella">
  282. <?php $link = rurl( $art[0], 'ecommerce-dettaglio' ); ?>
  283. <h3>
  284. <a href="<?=$link?>"><?=$art[1]?></a>
  285. <?=adm_link('ecommerce', $art[0])?>
  286. </h3>
  287. <h4><?=$ECOMMERCE_PRODUTTORELINGUA?> <?=$art[10]?></h4>
  288. <h4><?=$ECOMMERCE_CODICELINGUA?> <?=$art[11]?></h4>
  289. <?php if ( $art[7] != '' ) : ?><h5>Colore: <?=$art[7]?></h5><?php endif; ?>
  290. <?php if ( $art[8] != '' ) : ?><h5>Taglia: <?=$art[8]?></h5><?php endif; ?>
  291. </div>
  292. <div class="cella">
  293. <?php
  294. $prezzo = number_format($art[2], 2, ',', '.');
  295. if ( $art[6] > $art[2] )
  296. echo "<span style=\"text-decoration:line-through; color: red;\">".number_format($art[6], 2, ',', '.')." &euro;<br /></span><br />";
  297. echo "$prezzo &euro;";
  298. ?>
  299. </div>
  300. <div class="cella">
  301. <?=$art[5]?>
  302. </div>
  303. <div class="azzerafloat"></div>
  304. </div>
  305. <?php
  306. }
  307. Nav($cat,$max,$pos,$page,$prod);
  308. $link = rurl( 0, 'ecommerce-dettaglio-carrello' );
  309. echo"
  310. <div class=\"carrello\">
  311. <a href=\"$link\">$ECOMMERCE_RIGUARDACARRELLOLINGUA
  312. <img src=\""._URLSITO."/img/carrello.png\" class=\"ecomico\"></a>
  313. </div>
  314. <div class=\"azzerafloat\"></div>
  315. ";
  316. echo "</div>";
  317. ?>
  318. <?php
  319. function Nav( $cat, $max, $pos, $pag, $prod ) {
  320. global $ECOMMERCE_NUMEROARTICOLILINGUA;
  321. global $ECOMMERCE_NESSUNARTICOLOPRESENTELINGUA;
  322. global $ECOMMERCE_INIZIOLINGUA;
  323. global $ECOMMERCE_PRECEDENTELINGUA;
  324. global $ECOMMERCE_SUCCESSIVOLINGUA;
  325. global $ECOMMERCE_FINELINGUA;
  326. echo "<div class=\"navigazione\">";
  327. echo ( $max != 0 ) ? "<div class=\"numero-articoli\">$ECOMMERCE_NUMEROARTICOLILINGUA $max</div>" : "<div class=\"numero-articoli\">$ECOMMERCE_NESSUNARTICOLOPRESENTELINGUA</div>";
  328. if ( $pos > 0 OR $max > ( $pos + $pag ) ) {
  329. $link = rurl( $cat, 'ecommerce-categorie' );
  330. if ( $prod != '' ) $link .= "produttore-$prod/";
  331. echo "<div class=\"numero-pagina\">";
  332. if ( $pos > 0 ) {
  333. echo "<div class=\"precedente\">";
  334. $link1 = $link . "indice-0/";
  335. echo "<a href=\"$link1\">&lt;&lt; $ECOMMERCE_INIZIOLINGUA</a> ";
  336. $link2 = $link . "indice-".($pos-$pag)."/";
  337. echo "<a href=\"$link2\">&lt; $ECOMMERCE_PRECEDENTELINGUA</a> ";
  338. echo "</div>";
  339. }
  340. if ( $max > $pos + $pag ) {
  341. echo "<div class=\"successivo\">";
  342. $link1 = $link . "indice-".($pos+$pag)."/";
  343. echo "<a href=\"$link1\">$ECOMMERCE_SUCCESSIVOLINGUA &gt;</a>";
  344. $link2 = $link . "indice-".($max-$pag)."/";
  345. echo "<a href=\"$link2\">$ECOMMERCE_FINELINGUA &gt;&gt;</a>";
  346. echo "</div>";
  347. }
  348. echo "<div class=\"azzerafloat\"></div>";
  349. echo "</div>";
  350. }
  351. echo "</div>";
  352. }
  353. ?>