<?php


/*

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

  Copyright (c) 2003 osCommerce
  
  osCommRes, Services Online
  http://www.oscommres.com

  Copyright (c) 2005 osCommRes

  Released under the GNU General Public License
*/
// Set flag that this is a parent file
	defined('_FEXEC') or die();
	
  $currencies = new currencies();
  // Loding DropDown Boxes Using Ajax
  //require(DIR_WS_CLASSES . 'payment.php');
  //include(DIR_WS_CLASSES . 'order.php');

 /* $orders_statuses = array();
  $orders_status_array = array();
  $orders_status_query = tep_db_query("select orders_status_id, orders_status_name from " . TABLE_ORDERS_STATUS . " where language_id = '" . (int)$languages_id . "'");
  while ($orders_status = tep_db_fetch_array($orders_status_query)) {
    $orders_statuses[] = array('id' => $orders_status['orders_status_id'],
                               'text' => $orders_status['orders_status_name']);
    $orders_status_array[$orders_status['orders_status_id']] = $orders_status['orders_status_name'];
  }*/
?>
<?php
  echo "new_product||";
  	// ############################################################################
	//   Get List of All Products
	// ############################################################################
		$result = tep_db_query("SELECT products_name, p.products_id, categories_name, ptc.categories_id FROM " . TABLE_PRODUCTS . " p LEFT JOIN " . TABLE_PRODUCTS_DESCRIPTION . " pd ON pd.products_id=p.products_id LEFT JOIN " . TABLE_PRODUCTS_TO_CATEGORIES . " ptc ON ptc.products_id=p.products_id LEFT JOIN " . TABLE_CATEGORIES_DESCRIPTION . " cd ON cd.categories_id=ptc.categories_id ORDER BY categories_name");
		$ProductList = array();
		while($row = tep_db_fetch_array($result))
		{
			extract($row,EXTR_PREFIX_ALL,"db");
			$ProductList[$db_categories_id][$db_products_id] = $db_products_name;
			$CategoryList[$db_categories_id] = $db_categories_name;
			$LastCategory = $db_categories_name;
		}
		// ksort($ProductList);
		$LastOptionTag = "";
		$ProductSelectOptions = "<option value='0'>Don't Add New Product" . $LastOptionTag . "\n";
		$ProductSelectOptions .= "<option value='0'>&nbsp;" . $LastOptionTag . "\n";
		foreach($ProductList as $Category => $Products)
		{
			$ProductSelectOptions .= "<option value='0'>$Category" . $LastOptionTag . "\n";
			$ProductSelectOptions .= "<option value='0'>---------------------------" . $LastOptionTag . "\n";
			asort($Products);
			foreach($Products as $Product_ID => $Product_Name)
			{
				$ProductSelectOptions .= "<option value='$Product_ID'> &nbsp; $Product_Name" . $LastOptionTag . "\n";
			}
			if($Category != $LastCategory)
			{
				$ProductSelectOptions .= "<option value='0'>&nbsp;" . $LastOptionTag . "\n";
				$ProductSelectOptions .= "<option value='0'>&nbsp;" . $LastOptionTag . "\n";
			}
		}

 ?>
<form name="new_product" method="post">
<table border="0" width="100%" cellspacing="2" cellpadding="2">
  <tr>
    <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="main"><B><?php echo ADDING_TITLE; ?></b> </td>
		<?php	print '<td id="show_product_save_icon_up" width=10% nowrap style="display:none" colspan=3 class="main" align="right" style="padding-left:10px;padding-right:10px;padding-top:3px;">' . tep_image(DIR_WS_IMAGES .  'template/img_savel.gif','Save','','',' id="save" style="cursor:pointer;" onclick="javascript:validateproductForm();"') .'&nbsp;
					<a href="javascript:do_page_fetch(\'ajx_close_product_new\');">' . tep_image(DIR_WS_IMAGES .  'template/img_closel.gif','Close') . '</a>
				   </td>';?>
	  </tr>
	</table></td>
  </tr>
<?php
	// ############################################################################
	//   Add Products Steps
	// ############################################################################
		print "<tr><td><table border='0' width=100%>\n";
		// Set Defaults
		// Step 1: Choose Product
			print "<tr>\n";
			print "<td class='dataTableContent' align='right'><b>STEP 1:</b></td><td class='dataTableContent' valign='top'>";
			$products_array = array();
			$products_array = tep_get_products_array_single();
			if(sizeof($products_array)<=0) echo 'Products Are Not Available';
			else echo tep_draw_products_select_menu('add_product_products_id',$products_array,$add_product_products_id,' id="add_product_products_id" onchange="javascript:do_page_fetch(\'new_product_step2\');"');
			print "</tr>\n";
            print "<tr><td colspan='3'>". tep_draw_separator('pixel_trans.gif','5','5'). "</td></tr>\n";
			print "<tr><td colspan='3' id='new_product_step2'></td></tr>";
			print "<tr><td colspan='3' id='product_submit'></td></tr>";
			print '<tr ><td id="show_product_save_icon_down" style="display:none" colspan=3 class="main" align="right" style="padding-left:10px;padding-right:10px;padding-top:3px;">' . tep_image(DIR_WS_IMAGES .  'template/img_savel.gif','Save','','',' id="save1" style="cursor:pointer;" onclick="javascript:validateproductForm();"') .'&nbsp;
					<a href="javascript:do_page_fetch(\'ajx_close_product_new\');">' . tep_image(DIR_WS_IMAGES .  'template/img_closel.gif','Close') . '</a>
				   </td></tr>';
	?>
    </table></td>
  </tr>
</table>
</form>
