                


<?php
//-->-->-->-->-->-->-->-->
  
   require '/usr50/home/retrovox/public_html/manage/php-lib/fnRetrovoxParseXml.php';

   $sDataPath = '/usr50/home/retrovox/public_html/product-data';

   $iCurrentProductId = 0;
   $iMaximumProductId = 0;
   $iNewProductId = 0;
   $sExtractedId = '';    //-- to get the product-id from the file name

   //-- find the maximum product-id value so that a new product-id
   //-- can be generated for the new product.
   $dh  = opendir($sDataPath);
   while (false !== ($sMemberFileName = readdir($dh)))
   {
      $sExtractedId = 
        str_replace('.xml', '', str_replace('product-', '', $sMemberFileName));
      if (is_numeric($sExtractedId))
      {
        $iCurrentProductId = $sExtractedId;

        //-- for debugging 
        //echo "$iCurrentProductId <br> \n";
        if ($iCurrentProductId > $iMaximumProductId)
        {
           $iMaximumProductId = $iCurrentProductId;
        } //-- if
      } //-- if is product data file
   } //-- while more files

   $iNewProductId = $iMaximumProductId + 1;
   $aaProductData['product-id'] = $iNewProductId;

   $aaProductData['short-description'] = '';
   $aaProductData['long-description'] =  '';
   $aaProductData['product-name'] =  '';
   $aaProductData['product-size'] =  '';
   $aaProductData['order'] =  '';
   $aaProductData['price'] =  '';
   $aaProductData['weight'] =  '';
   $aaProductData['image-file'] =  '';
   $aaProductData['thumbnail-image-file'] =  '';
   $aaProductData['shipping-charge'] =  '';

   $sFilePath = "$sDataPath/product-$sProductId.xml";


//--<--<--<--<--<
?>

<HTML>
<HEAD>
   <TITLE>Add a Retrovox Product</TITLE>
</HEAD>


<body>

 <center>
   <a href = '/'>
   <img src = "/Images/retrovox150.jpg" 
        alt = 'home' width = '150' height = '81'  align = 'bottom'>
   </a><br>
   <form method = 'post' 
         action = 'http://www.retrovox.com.au/manage/add-product.php'>
   <table  border = "1">
<?php
//-->-->-->-->-->-->-->-->
   echo "
        <tr>
	  <td><strong><em>product-id</em></strong></td>
	  <td>".$aaProductData['product-id'].
	  "<input type = 'hidden' name = 'product-id' 
	         value = '".$aaProductData['product-id']."'></td>
	</tr>
	 \n";
  
   foreach ($aaProductData as $key => $value)
   {
      if (($key != 'long-description') && ($key != 'product-id'))
      {
        echo "
        <tr>
	  <td><strong><em>$key</em></strong></td>
	  <td><input type = 'text' name = '$key' value = \"$value\">
	  </td>
	</tr>
	 \n";
      }

   } //-- foreach

   echo "
        <tr>
	  <td><strong><em>long-description</em></strong></td>
	  <td><textarea name = 'long-description' cols = '40' rows = '3'>".
	  $aaProductData['long-description']."</textarea></td>
	</tr>
	 \n";
//--<--<--<--<--<--<--<--<
?>
   <tr><td>
     <input type = 'submit' value = 'S a v e    T h e    C h a n g e s'>
   </td></tr>
   </table>
   </form>
  </center>
  <ol type = 'a'>

  </ol>
</body>
</html>
                