<?

/*
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
*/



	// ========================================================================================
	
	// ========================================================================================
	
	$PageTitle = '<img src="'.$ImagesURL.'/admin/admincp_ecom.gif" width="20" height="21" align="middle"> '.$MsgText[9][209];
	$BrowserTitle = $MsgText[9][209];
	$LocationBar = '<a href="'.$IndexURL.'">'.$MsgText[0][1].'</a> > <a href="' . $MainURL . '/options.html">'.$MsgText[0][4].'</a> > <a href="'.$MainURL.'/admin/store-orders.html">'.$MsgText[9][174].'</a> > '.$MsgText[9][209];
	
	if ($LoggedIn == 'y') {
		
		ReadPermissions();
		Global $Permissions;
		
		if ($Permissions[905] == 'y') {
		
									
			$query = "select * from `".$Settings['DBPrefix']."ec-Orders` where RecordNumber='".intval($Arguments3)."' limit 1";
			$result = mysql_query($query) or die (mysql_error());
			$row = mysql_fetch_array($result);
			
			
			$PaymentMethods[1] = $MsgText[9][176];
			$PaymentMethods[2] = $MsgText[9][177];
			$PaymentMethods[3] = $MsgText[9][178];
			$PaymentMethods[4] = $MsgText[9][364];
			
			
			if ($Arguments4 == 'record_payment') {
			
				$PageContents = '<br><b>'.$MsgText[9][210].':</b><br><br>';
			
			
				if ($row['PaymentReceived'] < 1) {
				
					$PaymentMethodSelected[$row['PaymentMethod']] = ' checked';
					
					for ($d = 1; $d <= 31; $d++) {
					
						$DaySelected[date('j',GetTimestamp())] = ' selected';
					
						if ($d < 10) {
							$DaysSelect .= '<option value="'.$d.'"'.$DaySelected[$d].'> &nbsp;&nbsp;'.$d.'</option>';
						}
						else {
							$DaysSelect .= '<option value="'.$d.'"'.$DaySelected[$d].'> '.$d.'</option>';
						}
					}
					
					$MonthSelected[date('n',GetTimestamp())] = ' selected';
					
					if (date('G',GetTimestamp()) >= 12) {
						$AmPmSelected[2] = ' selected';
					}
					else {
						$AmPmSelected[1] = ' selected';
					}
					
					$CurrentYear = date('Y',GetTimestamp());
					for ($y = 2004; $y <= 2010; $y++) {
						if ($CurrentYear == $y) {
							$YearsSelect .= '<option value="'.$y.'" selected> '.$y.'</option>';
						}
						else {
							$YearsSelect .= '<option value="'.$y.'"> '.$y.'</option>';
						}
					}
					
					$HoursSelect = '<option value="0"> 12</option>';
					for ($h = 1; $h <= 11; $h++) {
						
						$HourSelected[date('g',GetTimestamp())] = ' selected'; 
					
						if ($h < 10) {
							$HoursSelect .= '<option value="'.$h.'"'.$HourSelected[$h].'> &nbsp;&nbsp;'.$h.'</option>';
						}
						else {
							$HoursSelect .= '<option value="'.$h.'"'.$HourSelected[$h].'> '.$h.'</option>';
						}
					}
					
					for ($m = 0; $m <= 59; $m++) {
					
						$MinuteSelected[intval(date('i',GetTimestamp()))] = ' selected';
						
						if ($m < 10) {
							$MinutesSelect .= '<option value="'.$m.'"'.$MinuteSelected[$m].'> 0'.$m.'</option>';
						}
						else {
							$MinutesSelect .= '<option value="'.$m.'"'.$MinuteSelected[$m].'> '.$m.'</option>';
						}
					}
					
					
					if ($row['PaymentMethod'] != '3') {
						$NotifyCustomerChecked = ' checked';
					}
				
				
					$PageContents .= '<br><form action="'.$MainURL.'/admin/store-orders-modify-save" method="post">
					<input type="hidden" name="OrderID" value="'.intval($Arguments3).'">
					<input type="hidden" name="OrderAction" value="record_payment">

					
					<b>'.$MsgText[9][211].':</b><br>
					<input type="radio" name="PaymentMethod" value="1" onClick="UpdateSelection(\'1\')"'.$PaymentMethodSelected[1].'> <b>'.$PaymentMethods[1].'</b><br><div id="div_1"><table width="500" border="0" cellpadding="0" cellspacing="0"><tr><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td><td width="100%"><font face="'.$FontFace.'" size="'.$FontSize.'"><br>'.$MsgText[9][212].' ('.$MsgText[0][418].'):<br><input type="text" name="PaymentDetails_1" size="25" style="'.$FormStyle.'"><br><br>'.$MsgText[9][213].' ('.$MsgText[0][418].'):<br><input type="text" name="PaymentDetails2_1" size="25" style="'.$FormStyle.'"></font></td></tr></table></div><br>
					
					<input type="radio" name="PaymentMethod" value="4" onClick="UpdateSelection(\'4\')"'.$PaymentMethodSelected[4].'> <b>'.$PaymentMethods[4].'</b><br><div id="div_4"><table width="500" border="0" cellpadding="0" cellspacing="0"><tr><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td><td width="100%"><font face="'.$FontFace.'" size="'.$FontSize.'"><br>'.$MsgText[9][212].' ('.$MsgText[0][418].'):<br><input type="text" name="PaymentDetails_2" size="25" style="'.$FormStyle.'"></font></td></tr></table></div><br>

					<input type="radio" name="PaymentMethod" value="2" onClick="UpdateSelection(\'2\')"'.$PaymentMethodSelected[2].'> <b>'.$PaymentMethods[2].'</b><br><div id="div_2"><table width="500" border="0" cellpadding="0" cellspacing="0"><tr><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td><td width="100%"><font face="'.$FontFace.'" size="'.$FontSize.'"><br>'.$MsgText[9][214].' ('.$MsgText[0][418].'):<br><input type="text" name="PaymentDetails_2" size="25" style="'.$FormStyle.'"><br><br>'.$MsgText[9][215].' ('.$MsgText[0][418].'):<br><input type="text" name="PaymentDetails2_2" size="25" style="'.$FormStyle.'"></font></td></tr></table></div><br>

					<input type="radio" name="PaymentMethod" value="3" onClick="UpdateSelection(\'3\')"'.$PaymentMethodSelected[3].'> <b>'.$PaymentMethods[3].'</b><br><div id="div_3"><table width="500" border="0" cellpadding="0" cellspacing="0"><tr><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td><td width="100%"><font face="'.$FontFace.'" size="'.$FontSize.'"><br>'.$MsgText[9][216].' ('.$MsgText[0][418].'):<br><input type="text" name="PaymentDetails_3" size="25" style="'.$FormStyle.'"><br><br>'.$MsgText[9][217].' ('.$MsgText[0][418].'):<br><input type="text" name="PaymentDetails2_3" size="25" style="'.$FormStyle.'"></font></td></tr></table></div><br>


					<br><br>
					
					<b>'.$MsgText[9][218].':</b><br>
					
					<select name="Month" style="'.$FormStyle.'"><option value="1"'.$MonthSelected[1].'> '.$MsgText[0][284].'</option><option value="2"'.$MonthSelected[2].'> '.$MsgText[0][285].'</option><option value="3"'.$MonthSelected[3].'> '.$MsgText[0][286].'</option><option value="4"'.$MonthSelected[4].'> '.$MsgText[0][287].'</option><option value="5"'.$MonthSelected[5].'> '.$MsgText[0][288].'</option><option value="6"'.$MonthSelected[6].'> '.$MsgText[0][289].'</option><option value="7"'.$MonthSelected[7].'> '.$MsgText[0][290].'</option><option value="8"'.$MonthSelected[8].'> '.$MsgText[0][291].'</option><option value="9"'.$MonthSelected[9].'> '.$MsgText[0][292].'</option><option value="10"'.$MonthSelected[10].'> '.$MsgText[0][293].'</option><option value="11"'.$MonthSelected[11].'> '.$MsgText[0][294].'</option><option value="12"'.$MonthSelected[12].'> '.$MsgText[0][295].'</option></select>&nbsp;<select name="Day" style="'.$FormStyle.'">'.$DaysSelect.'</select>&nbsp;<select name="Year" style="'.$FormStyle.'">'.$YearsSelect.'</select> @ <select name="Hour" style="'.$FormStyle.'">'.$HoursSelect.'</select>:<select name="Minute" style="'.$FormStyle.'">'.$MinutesSelect.'</select>&nbsp;<select name="AmPm" style="'.$FormStyle.'"><option value="am"'.$AmPmSelected[1].'> AM</option><option value="pm"'.$AmPmSelected[2].'> PM</option></select>


					<br><br><br><br><input type="checkbox" name="NotifyCustomer" value="y"'.$NotifyCustomerChecked.'> <b>'.$MsgText[9][219].'</b> '.$MsgText[9][220].'
					
					<br><br><br><br>
					
					<input type="submit" value="'.$MsgText[9][210].'" style="'.$FormStyle.'">

</form>



	<script>
		var LastSelection = "'.$row['PaymentMethod'].'";
		var ElementID = "";
			
		ElementID = document.getElementById("div_1");
		ElementID.style.display = "none"
		ElementID = document.getElementById("div_2");
		ElementID.style.display = "none"
		ElementID = document.getElementById("div_3");
		ElementID.style.display = "none"
		ElementID = document.getElementById("div_4");
		ElementID.style.display = "none"
		
		ElementID = document.getElementById("div_"+LastSelection);
		ElementID.style.display = ""
			
		function UpdateSelection(NewSelection) {
	  
		 	ElementID = document.getElementById("div_"+LastSelection);
			ElementID.style.display = "none"
		
		  	ElementID = document.getElementById("div_"+NewSelection);
			ElementID.style.display = ""
	  
	  		LastSelection = NewSelection;
		}
	</script>';
				
				}
				else {
			
					$PageContents = '<br><br>'.$MsgText[9][221];
			
				}
							
			} // end if $Arguments4 == 'record_payment'	
			
			else if ($Arguments4 == 'mark_shipped') {
			
				$PageContents = '<br><b>'.$MsgText[9][222].':</b>';
			
			
				if ($row['ShippedDate'] < 1) {
														
					for ($d = 1; $d <= 31; $d++) {
					
						$DaySelected[date('j',GetTimestamp())] = ' selected';
					
						if ($d < 10) {
							$DaysSelect .= '<option value="'.$d.'"'.$DaySelected[$d].'> &nbsp;&nbsp;'.$d.'</option>';
						}
						else {
							$DaysSelect .= '<option value="'.$d.'"'.$DaySelected[$d].'> '.$d.'</option>';
						}
					}
					
					$MonthSelected[date('n',GetTimestamp())] = ' selected';
					
					if (date('G',GetTimestamp()) >= 12) {
						$AmPmSelected[2] = ' selected';
					}
					else {
						$AmPmSelected[1] = ' selected';
					}
					
					$CurrentYear = date('Y',GetTimestamp());
					for ($y = 2004; $y <= 2010; $y++) {
						if ($CurrentYear == $y) {
							$YearsSelect .= '<option value="'.$y.'" selected> '.$y.'</option>';
						}
						else {
							$YearsSelect .= '<option value="'.$y.'"> '.$y.'</option>';
						}
					}
					
					$HoursSelect = '<option value="0"> 12</option>';
					for ($h = 1; $h <= 11; $h++) {
						
						$HourSelected[date('g',GetTimestamp())] = ' selected'; 
					
						if ($h < 10) {
							$HoursSelect .= '<option value="'.$h.'"'.$HourSelected[$h].'> &nbsp;&nbsp;'.$h.'</option>';
						}
						else {
							$HoursSelect .= '<option value="'.$h.'"'.$HourSelected[$h].'> '.$h.'</option>';
						}
					}
					
					for ($m = 0; $m <= 59; $m++) {
					
						$MinuteSelected[intval(date('i',GetTimestamp()))] = ' selected';
						
						if ($m < 10) {
							$MinutesSelect .= '<option value="'.$m.'"'.$MinuteSelected[$m].'> 0'.$m.'</option>';
						}
						else {
							$MinutesSelect .= '<option value="'.$m.'"'.$MinuteSelected[$m].'> '.$m.'</option>';
						}
					}
					
					
					$NotifyCustomerChecked = ' checked';
									
				
					$PageContents .= '<form action="'.$MainURL.'/admin/store-orders-modify-save" method="post">
					<input type="hidden" name="OrderID" value="'.intval($Arguments3).'">
					<input type="hidden" name="OrderAction" value="mark_shipped">

					<font face="'.$FontFace.'" size="'.$FontSize.'">'.$MsgText[9][223].' ('.$MsgText[0][418].'):<br><input type="text" name="ShippingDetails" size="25" style="'.$FormStyle.'"><br><br>'.$MsgText[9][224].' ('.$MsgText[0][418].'):<br><input type="text" name="ShippingDetails2" size="25" style="'.$FormStyle.'"></font>

					<br><br><br>
					
					<b>'.$MsgText[9][225].':</b><br>
					
					<select name="Month" style="'.$FormStyle.'"><option value="1"'.$MonthSelected[1].'> '.$MsgText[0][284].'</option><option value="2"'.$MonthSelected[2].'> '.$MsgText[0][285].'</option><option value="3"'.$MonthSelected[3].'> '.$MsgText[0][286].'</option><option value="4"'.$MonthSelected[4].'> '.$MsgText[0][287].'</option><option value="5"'.$MonthSelected[5].'> '.$MsgText[0][288].'</option><option value="6"'.$MonthSelected[6].'> '.$MsgText[0][289].'</option><option value="7"'.$MonthSelected[7].'> '.$MsgText[0][290].'</option><option value="8"'.$MonthSelected[8].'> '.$MsgText[0][291].'</option><option value="9"'.$MonthSelected[9].'> '.$MsgText[0][292].'</option><option value="10"'.$MonthSelected[10].'> '.$MsgText[0][293].'</option><option value="11"'.$MonthSelected[11].'> '.$MsgText[0][294].'</option><option value="12"'.$MonthSelected[12].'> '.$MsgText[0][295].'</option></select>&nbsp;<select name="Day" style="'.$FormStyle.'">'.$DaysSelect.'</select>&nbsp;<select name="Year" style="'.$FormStyle.'">'.$YearsSelect.'</select> @ <select name="Hour" style="'.$FormStyle.'">'.$HoursSelect.'</select>:<select name="Minute" style="'.$FormStyle.'">'.$MinutesSelect.'</select>&nbsp;<select name="AmPm" style="'.$FormStyle.'"><option value="am"'.$AmPmSelected[1].'> AM</option><option value="pm"'.$AmPmSelected[2].'> PM</option></select>


					<br><br><br><br><input type="checkbox" name="NotifyCustomer" value="y"'.$NotifyCustomerChecked.'> <b>'.$MsgText[9][219].'</b> '.$MsgText[9][226].'
					
					<br><br><br><br>
					
					<input type="submit" value="'.$MsgText[9][222].'" style="'.$FormStyle.'"></form>';
				
				}
				else {
			
					$PageContents = '<br><br>'.$MsgText[9][227];
			
				}
							
			} // end if $Arguments4 == 'mark_shipped'
			
		
		
		}
		else {
		
			$PageContents = $MsgText[0][97];
		
		}

	}
	else {
	
		RedirectToLogin();
	
	}

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




?>
