aumento prezzi generalizzato

Postate qui discussioni di carattere generale riguardo a problemi di installazione e configurazione di osCommerce

Moderatore: mod Generali

Rispondi
albyzx6
membro Junior
membro Junior
Messaggi: 13
Iscritto il: 30/03/2003, 1:00
Località: Italy

aumento prezzi generalizzato

Messaggio da albyzx6 »

Hi all :D
Ho la necessità di aumentare del 5% tutti i prezzi relativi ad una precisa categoria di prodotti ...
Avete qualche suggerimento/idea ?

Grazie in anticipo
BluEdoG
membro Master
membro Master
Messaggi: 1064
Iscritto il: 25/05/2003, 0:00
Località: italia
Contatta:

Messaggio da BluEdoG »

prova con questo, da infilare nella dir admin.

Codice: Seleziona tutto


<?php
/*
  $Id: aumento.php,v 1.29 2003/04/28 15:32:22 hpdl Exp $

  osCommerce, Open Source E-Commerce Solutions
  http://www.oscommerce.com

  Copyright (c) 2002 osCommerce
  author: Michele Gobbi
  email: michele.gobbi@inwind.it
  updated by BluEdoG - info@bluedog.it

  Released under the GNU General Public License
*/

  require('includes/application_top.php');

  require(DIR_WS_CLASSES . 'currencies.php');
  $currencies = new currencies();




// category drop down
$sql3 = mysql_query("SELECT categories_id, categories_name FROM categories_description ORDER BY categories_name");







?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<title><?php echo TITLE; ?></title>
<link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
<style type="text/css">
<!--
th {  font-family: Verdana, Arial, Helvetica, sans-serif; font-size: x-small; background-color: #eeeeee}
/*table {  border: #666666; border-style: dashed; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px}*/
/*td {  font-family: Verdana, Arial, Helvetica, sans-serif; font-size: xx-small; padding-top: 3px; padding-bottom: 3px; padding-left: 5px}*/
td.left {  font-family: Verdana, Arial, Helvetica, sans-serif; font-size: xx-small; padding-top: 3px; padding-bottom: 3px; padding-left: 5px; text-align: right; padding-right: 16px}

-->
</style>
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF">
<!-- header //-->
<?php require(DIR_WS_INCLUDES . 'header.php'); ?>
<!-- header_eof //-->

<!-- body //-->
<table border="0" width="100%" cellspacing="2" cellpadding="2">
  <tr>
    <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="1" cellpadding="1" class="columnLeft">
<!-- left_navigation //-->
<?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>
<!-- left_navigation_eof //-->
        </table></td>
<!-- body_text //-->
    <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
      <tr>
        <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
          <tr>
            <td class="pageHeading"><?php echo "Aggiornamento prezzi per Categoria" ?></td>
            <td class="pageHeading" align="right"><?php echo tep_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td align="left">
<?
if ($action == "category") {
    $res=mysql_query("select * from categories_description where categories_id=$option");
    $row = mysql_fetch_array($res);
    $titolo=$row[2];
    echo "<h1>".$titolo."</h1>";
    echo "<form name=\"update\" method=\"post\" action=\"".$_SERVER["PHP_SELF"]."?action=update_prices\">";
    echo "<table>";
    echo "<tr><td> Incremento fisso: </td><td><input type=\"text\" name=\"fisso\" style='text-align: right;'/> <b>€</b>   (p.e. 10: verranno aumentati tutti i prezzi di 10 euro)</td></tr>";
    echo "<tr><td> Incremento percentuale: </td><td><input type=\"text\" name=\"percentuale\"  style='text-align: right;'/><b>%</b>  (p.e. 10: verranno aumentati tutti i prezzi del 10%)</td></tr>";
    echo "</table>\n";
    echo "<br><input type=\"submit\" value=\"Aggiorna i prezzi\">";
    echo "<input type=\"hidden\" name=\"option\" value=\"$option\" />";
    echo "</form><hr>";
}
if ($action == "update_prices") {
    $qry="SELECT * FROM products, products_description, products_to_categories WHERE products_to_categories.categories_id = $option AND products_to_categories.products_id = products.products_id AND products.products_id = products_description.products_id";
    $res = mysql_query($qry);
    while ($arr=mysql_fetch_array($res)) {
      $prezzo=$arr["products_price"];
      $articolo=$arr["products_name"];
      $id=$arr["products_id"];
      if ($fisso!="") {
        $tot=$prezzo+$fisso;
        //echo $articolo." --> ".$prezzo."+ $fisso = ".$tot."<br>";
      } else
      if ($percentuale!="") {
        $tot=round($prezzo/100*$percentuale+$prezzo, 2);
        //echo $articolo." --> ".$prezzo."+ $percentuale% = ".$tot."<br>";
      }
      mysql_query("UPDATE products SET products_price=$tot WHERE products_id=$id");
    }
    echo "<h3>Prezzi aggiornati!!</h3>";
}

?>
          <table>
            <tr> 
              <th>Scegli la categoria da aggiornare</td>
            </tr>
            <tr>
              <td>
              <?php
              if(mysql_num_rows($sql3)) {
                  while($row = mysql_fetch_row($sql3)) {
                      print("<a href=\"".$_SERVER["PHP_SELF"]."?action=category&option={$row[0]}\">$row[1]</a><br>");
                  }
              }
              ?>
              </td>
            </tr>
          </table>

        </td>
      </tr>
    </table></td>
<!-- body_text_eof //-->
  </tr>
</table>
<!-- body_eof //-->

<!-- footer //-->
<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
<!-- footer_eof //-->
</body>
</html>
<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>

saluti, Caneblu
[ www.caneblu.com ]
albyzx6
membro Junior
membro Junior
Messaggi: 13
Iscritto il: 30/03/2003, 1:00
Località: Italy

Messaggio da albyzx6 »

grazie per la fast reply, domani lo testo e ti faccio sapere

cya 8)
Rispondi