<?

/*
FlexCMS (http://www.flexcms.com)
Flexible, Powerful, Affordable.

Contents of this file are protected by the copyright
notice found at http://www.flexcms.com/flex/pages/copyright.html,
and its usage is subject to the terms of the licensing agreement 
available at http://www.flexcms.com/flex/pages/license.html
*/



	// ========================================================================================
	
	// ========================================================================================
		
	
	if ($LoggedIn == 'y') {
		
		ReadPermissions();
		Global $Permissions;
		
		if ($Permissions[901] == 'y') {
		
		
			$query = "select * from `".$Settings['DBPrefix']."ec-Settings`";
			$result = mysql_query($query) or die (mysql_error());
			while ($row = mysql_fetch_array($result)) {
				$ecSettings[$row['Name']] = $row['Value'];
			}
		
			if ($ecSettings['PriceDecimals'] == '') {
				$ecSettings['PriceDecimals'] = 2;
			}
			
			if ($ecSettings['DecimalSymbol'] == '') {
				$ecSettings['DecimalSymbol'] = '.';
			}
			
			if ($ecSettings['ThousandsSep'] == '') {
				$ecSettings['ThousandsSep'] = '.';
			}
			
			
			if ($ecSettings['CurrencyLocation'] == '' || $ecSettings['CurrencyLocation'] == 'b') {
				if ($ecSettings['Currency'] == '') {
					$CurrencyBefore = '$';
				}
				else {
					$CurrencyBefore = $ecSettings['Currency'];
				}
			}
			else {
				if ($ecSettings['Currency'] == '') {
					$CurrencyAfter = '$';
				}
				else {
					$CurrencyAfter = $ecSettings['Currency'];
				}
			}
			
			
			
			function FormatBoxValue($RawNumber, $DecimalPlaces) {
			
				Global $ecSettings;
			
				$FormattedPrice = '';
				if ($RawNumber > 0) {
					$FormattedPrice = number_format($RawNumber,$DecimalPlaces,$ecSettings['DecimalSymbol'],$ecSettings['ThousandsSep']);
				}
						
				return $FormattedPrice;
			}
		
		
		
			$query5 = "select * from `".$Settings['DBPrefix']."ec-Items` WHERE RecordNumber='".intval($Arguments3)."' limit 1";
			$result5 = mysql_query($query5) or die (mysql_error());
			$row5 = mysql_fetch_array($result5);
			
			$Option1Checked[$row5['Option1']] = ' checked';
			$Option2Checked[$row5['Option2']] = ' checked';
			
			
			$query4 = "select * from `".$Settings['DBPrefix']."ec-Products` WHERE RecordNumber='".$row5['Product']."' limit 1";
			$result4 = mysql_query($query4) or die (mysql_error());
			$row4 = mysql_fetch_array($result4);
			
			
			$query = "select * from `".$Settings['DBPrefix']."ec-Items` WHERE Product='".$row5['Product']."' ORDER BY Option1 ASC, Option2 ASC";
			$result = mysql_query($query) or die (mysql_error());
			while ($row = mysql_fetch_array($result)) {
				if ($row['Option1'] != '' && $Option1Printed[$row['Option1']] != 'y') {
					$Option1List .= '<input type="radio" name="Option1" value="'.str_replace('"','&#34;',$row['Option1']).'"'.$Option1Checked[$row['Option1']].'> '.$row['Option1'].'<br>';
					$Option1Printed[$row['Option1']] = 'y';
				}
				if ($row['Option2'] != '' && $Option2Printed[$row['Option2']] != 'y') {
					$Option2List .= '<input type="radio" name="Option2" value="'.str_replace('"','&#34;',$row['Option2']).'"'.$Option2Checked[$row['Option2']].'> '.$row['Option2'].'<br>';
					$Option2Printed[$row['Option2']] = 'y';
				}
			}
			
			
			for ($i = 1; $i <= 10; $i++) {
				if ($row5['Price'.$i] == 0.00) {
					$row5['Price'.$i] = '';
				}
				if ($row5['PriceQty'.$i] == 0) {
					$row5['PriceQty'.$i] = '';
				}
			
				if ($i == 1) {
					$QtyBox = '1';
				}
				else {
					$QtyBox = '<input type="text" name="PriceQty'.$i.'" size="4" value="'.FormatBoxValue($row5['PriceQty'.$i],0).'" style="'.$FormStyle.'">';
				}
				$PriceQtyBoxes .= '<tr><td>&nbsp;</td><td align="center"><font face="'.$FontFace.'" size="'.$FontSize.'">'.$QtyBox.'</td><td>&nbsp;</td><td align="center"><font face="'.$FontFace.'" size="'.$FontSize.'"><b>'.$CurrencyBefore.'</b>&nbsp;<input type="text" name="Price'.$i.'" size="7" value="'.FormatBoxValue($row5['Price'.$i],$ecSettings['PriceDecimals']).'" style="'.$FormStyle.'">&nbsp;<b>'.$CurrencyAfter.'</b></td></tr>';
			}
			
			if ($row4['Option1Title'] != '') {
				$Option1Title = $row4['Option1Title'];
			}
			else {
				$Option1Title = $MsgText[9][50];
			}
			
			if ($row4['Option2Title'] != '') {
				$Option2Title = $row4['Option2Title'];
			}
			else {
				$Option2Title = $MsgText[9][51];
			}
			
			
			if ($row5['Stock'] == -1) {
				$row5['Stock'] = '';
			}
			

			$PageContents .= '<form name="PostForm" action="'.$MainURL.'/admin/store-items_edit_save" method="post"><input type="hidden" name="ItemIDToEdit" value="'.$Arguments3.'"><input type="hidden" name="ProductID" value="'.$row5['Product'].'"><b>'.$MsgText[9][42].':</b> ('.$MsgText[0][418].')<br><input type="text" name="ItemID" size="40" style="'.$FormStyle.'" value="'.$row5['ItemID'].'"><br><font size="1">('.$MsgText[9][25].')</font><br><br><b>'.$Option1Title.':</b> ('.$MsgText[0][418].')<br>'.$Option1List.'<input type="radio" name="Option1" value=""> '.$MsgText[9][71].': <input type="text" name="NewOption1" size="20" style="'.$FormStyle.'"><br><br><b>'.$Option2Title.':</b> ('.$MsgText[0][418].')<br>'.$Option2List.'<input type="radio" name="Option2" value=""> '.$MsgText[9][71].': <input type="text" name="NewOption2" size="20" style="'.$FormStyle.'"><br><br><b>'.$MsgText[9][58].':</b> ('.$MsgText[9][59].')<br>
<table border="0" cellpadding="2" cellspacing="0">
    <tr>
      <td width="20"><img src="'.$ImagesURL.'/admin/spacer.gif" width="20" height="1" alt="" border="0"></td>
      <td align="center"><font face="'.$FontFace.'" size="'.$FontSize.'"><b>'.$MsgText[9][60].'</b></font></td>
      <td width="10"><img src="'.$ImagesURL.'/admin/spacer.gif" width="10" height="1" alt="" border="0"></td>
      <td align="center"><font face="'.$FontFace.'" size="'.$FontSize.'"><b>'.$MsgText[9][61].'</b></font></td>
    </tr>
    '.$PriceQtyBoxes.'
</table><font size="1"><b>'.$MsgText[9][62].':</b> '.$MsgText[9][63].'<br></font>
<br><b>'.$MsgText[9][33].':</b> ('.$MsgText[0][418].')<br>
<b>'.$CurrencyBefore.'</b> <input type="text" name="ComparePrice" size="7" value="'.FormatBoxValue($row5['ComparePrice'],$ecSettings['PriceDecimals']).'" style="'.$FormStyle.'"> <b>'.$CurrencyAfter.'</b>
<br><br><br>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
    <tr>
      <td width="170"><font face="'.$FontFace.'" size="2"><b>'.$MsgText[9][34].':</b><br><input type="text" name="ShippingWeight" size="6" style="'.$FormStyle.'" value="'.$row5['ShippingWeight'].'">lbs&nbsp;<input type="text" name="ShippingWeightOz" size="1" style="'.$FormStyle.'">oz</td>
	  <td><font face="'.$FontFace.'" size="2">('.$MsgText[9][35].')</td>
    </tr>
</table><br>
<font face="'.$FontFace.'" size="2"><b>'.$MsgText[9][38].':</b><br><b>'.$CurrencyBefore.'</b> <input type="text" name="AdditionalShipping" size="5" style="'.$FormStyle.'" value="'.FormatBoxValue($row5['AdditionalShipping'],$ecSettings['PriceDecimals']).'"> <b>'.$CurrencyAfter.'</b> ('.$MsgText[0][418].')</font>

<br><br><br>
<b>'.$MsgText[9][36].':</b><br>
<input type="text" name="ProductInventory" size="5" style="'.$FormStyle.'" value="'.$row5['Stock'].'"> ('.$MsgText[0][418].')

<br><br><br><input type="checkbox" name="DeleteItem" value="yes"> '.$MsgText[9][69].'<br><br><br><br><input type="submit" value="'.$MsgText[0][123].'" style="'.$FormStyle.'"></form>';
		
		
			$PageTitle = '<img src="'.$ImagesURL.'/admin/admincp_ecom.gif" width="20" height="21" align="middle"> '.$MsgText[9][70];
			$BrowserTitle = $MsgText[9][70];
			$LocationBar = '<a href="'.$IndexURL.'">'.$MsgText[0][1].'</a> > <a href="' . $MainURL . '/options.html">'.$MsgText[0][4].'</a> > <a href="'.$MainURL.'/admin/store-products.html">'.$MsgText[9][3].'</a> > <a href="'.$MainURL.'/admin/store-products_edit/'.$row5['Product'].'.html">'.$MsgText[9][39].'</a> > '.$MsgText[9][70];
		
		
		}
		else {
		
			$PageContents = $MsgText[0][97];
		
		}

	}
	else {
	
		RedirectToLogin();
	
	}

	// ========================================================================================




?>
