<?php
/*
  $Id: products_expected.php,v 1.29 2002/03/17 17:52:23 harley_vb Exp $

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

  Copyright (c) 2002 osCommerce

  Released under the GNU General Public License
  
  mod MaxiShop Total B2B v 1.0 by Z. Maciej "Miki" Bajkowski http://www.maxishop.prv.pl
*/

 require('includes/application_top.php');

 // tep_db_query("update " . TABLE_PRODUCTS . " set products_date_available = '' where to_days(now()) > to_days(products_date_available)");
?>
<!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">
<script language="javascript" src="includes/general.js"></script>
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF" onload="SetFocus();">
<!-- 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 width="100%"><table border="0" width="100%" cellspacing="0" cellpadding="0">
          <tr>
            <td class="pageHeading"><?php echo HEADING_TITLE; ?></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><table border="0" width="100%" cellspacing="0" cellpadding="0">
          <tr>
                <td valign="top"><?php
// include('includes/application_top.php');
// category drop down
$sql3 = mysql_query("SELECT categories_id, categories_name FROM categories_description ORDER BY categories_name");
?>
<?php
if ($action == "category") {
    echo "<form name=\"update\" method=\"post\" action=\"".$_SERVER["PHP_SELF"]."?action=update_prices\">";
    echo "<table>";
    echo "<tr><th>"; echo TEXT_PRODUCTS_MODEL; echo "</th><th>"; echo TEXT_PRODUCTS; echo "</th><th>";echo TEXT_PRODUCTS_PRICE_INFO; echo "</th><th>"; echo TEXT_DISCOUNT; echo "</th></tr><tr>";
    $result = mysql_query("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");
    if ($row = mysql_fetch_array($result)) {
        do {
            echo "<td align=\"center\">".$row["products_id"]."</td>\n";
            echo "<td>".$row["products_name"]."</td>\n";
            echo "<td align=\"center\"><input type=\"text\" name=\"product_new_price[".$row['products_id']."]\" value={$row['products_price']}></td>\n";
	    echo "<td align=\"center\"><input type=\"text\" name=\"product_new_discount[".$row['products_id']."]\" value={$row['products_discount']}></td>\n";
            echo "</tr>\n";
        }
        while($row = mysql_fetch_array($result));
    }
    echo "</table>\n";
    echo "<br><input type=\"submit\" value="; echo TEXT_UPDATE_PRICES; echo ">";
    echo "</form>";
}
?>
<?php
if ($action == "update_prices") {
    foreach($HTTP_POST_VARS['product_new_price'] as $id => $new_price) {
    $product_discount = $HTTP_POST_VARS['product_new_discount'][$id];
        mysql_query("UPDATE products SET products_price=$new_price, products_discount=$product_discount WHERE products_id=$id");
	}
    $random = date("U");
    echo "<p><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"2\"><b>"; echo TEXT_UPDATE_DONE_HEADING; echo "</b></font></p>";
    echo "<p><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"2\">"; echo TEXT_UPDATE_DONE; echo "</p>";
    echo "<p><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"2\">"; echo TEXT_LINK_CLICK; echo "<b><a href=\"$PHP_SELF?$random\">"; echo TEXT_LINK_HERE; echo "</b></a>"; echo TEXT_LINK_CATEGORIES; echo "</font></p>";
    exit;
}
?>
<style type="text/css">
<!--
th {  font-family: Verdana, Arial, Helvetica, sans-serif; font-size: x-small; background-color: #eeeeee}
table {  border: #666666; 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>
<body bgcolor="#FFFFFF">
  <table>
    <tr> 
      <th><? echo TEXT_CHOOSE_CATEGORY ?></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>
</form><br>
                </td>
<?php
  $heading = array();
  $contents = array();
  if (is_object($pInfo)) {
    $heading[] = array('text' => '<b>' . $pInfo->products_name . '</b>');

    $contents[] = array('align' => 'center', 'text' => '<a href="' . tep_href_link(FILENAME_CATEGORIES, 'pID=' . $pInfo->products_id . '&action=new_product') . '">' . tep_image_button('button_edit.gif', IMAGE_EDIT) . '</a>');
    $contents[] = array('text' => '<br>' . TEXT_INFO_DATE_EXPECTED . ' ' . tep_date_short($pInfo->products_date_available));
  }

  if ( (tep_not_null($heading)) && (tep_not_null($contents)) ) {
    echo '            <td width="25%" valign="top">' . "\n";

    $box = new box;
    echo $box->infoBox($heading, $contents);

    echo '            </td>' . "\n";
  }
?>
          </tr>
        </table></td>
      </tr>
    </table></td>
<!-- body_text_eof //-->
  </tr>
</table>
<!-- body_eof //-->

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