<?

/*
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][174];
	$BrowserTitle = $MsgText[9][174];
	$LocationBar = '<a href="'.$IndexURL.'">'.$MsgText[0][1].'</a> > <a href="' . $MainURL . '/options.html">'.$MsgText[0][4].'</a> > '.$MsgText[9][174];
			
	if ($LoggedIn == 'y') {
		
		ReadPermissions();
		Global $Permissions;
		
		if ($Permissions[905] == 'y') {
		
					
			$PaymentMethods[1] = $MsgText[9][176];
			$PaymentMethods[2] = $MsgText[9][177];
			$PaymentMethods[3] = $MsgText[9][178];
			
			
			if ($Arguments3 == '') {
			
				$PageContents = '<form><b>'.$MsgText[9][179].':</b><br><br><input type="button" value="'.$MsgText[9][180].'" onClick="window.location=\''.$MainURL.'/admin/store-orders/new_open.html\'" style="'.$FormStyle.'"></form><br><script>

function LookupOrder() {
	var OrderID = document.forms["OrderLookup"].elements["OrderID"].value;
	var OrderIDSplit = OrderID.split("-");
	if (OrderIDSplit[0] > 0) {
		window.location="'.$MainURL.'/admin/store-orderdetails/"+OrderIDSplit[0]+".html";
	}
	else {
		alert("'.$MsgText[9][181].'");
	}
}

</script><br><form name="OrderLookup" onSubmit="LookupOrder(); return false;"><b>'.$MsgText[9][182].':</b><br><br>('.$MsgText[9][183].')<br><br><input type="text" name="OrderID" size="8" style="'.$FormStyle.'" onClick="document.forms[\'OrderLookup\'].elements[\'LookupButton\'].focus(); document.forms[\'OrderLookup\'].elements[\'OrderID\'].focus();"> <input type="button" name="LookupButton" value="'.$MsgText[9][184].'" style="'.$FormStyle.'" onClick="LookupOrder();"></form>

				<br><script>

function LookupPeriod() {
	window.location="'.$MainURL.'/admin/store-orders/period/"+document.forms["OrdersPeriod"].elements["Periods"].value+".html";
}

</script><br><form name="OrdersPeriod"><b>'.$MsgText[9][185].':</b><br><br><select name="Periods" style="'.$FormStyle.'">
	<option value="1"> '.$MsgText[9][188].'</option>
	<option value="2"> '.$MsgText[9][189].'</option>
	<option value="3"> '.$MsgText[9][190].'</option>
	<option value="4"> '.$MsgText[9][191].'</option>
	<option value="5"> '.$MsgText[9][192].'</option>
	<option value="6"> '.$MsgText[9][193].'</option>
	<option value="7"> '.$MsgText[9][194].'</option>
</select>
 <input type="button" name="PeriodsButton" value="'.$MsgText[9][195].'" style="'.$FormStyle.'" onClick="LookupPeriod();"></form>
';
			
			} // end if $Arguments3 == ''
			else if ($Arguments3 == 'new_open') {
			
				$PageTitle = '<img src="'.$ImagesURL.'/admin/admincp_ecom.gif" width="20" height="21" align="middle"> '.$MsgText[9][180];
				$BrowserTitle = $MsgText[9][180];
				$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][180];
			
					
				$PageContents .= '<br><br>';
			
				
				$PageContents .= '<table width="100%" border="0" cellpadding="3" cellspacing="0"><tr><td><font face="'.$FontFace.'" size="'.$FontSize.'"><b>'.$MsgText[9][196].'</b></font></td><td align="center"><font face="'.$FontFace.'" size="'.$FontSize.'"><b>'.$MsgText[9][197].'</b></font></td><td align="center"><font face="'.$FontFace.'" size="'.$FontSize.'"><b>'.$MsgText[9][198].'</b></font></td><td align="center"><font face="'.$FontFace.'" size="'.$FontSize.'"><b>'.$MsgText[9][199].'</b></font></td><td align="center"><font face="'.$FontFace.'" size="'.$FontSize.'"><b>'.$MsgText[9][200].'</b></font></td><td align="center"><font face="'.$FontFace.'" size="'.$FontSize.'"><b>'.$MsgText[9][201].'</b></font></td></tr>';
			
			
				$query = "select * from `".$Settings['DBPrefix']."ec-Orders` where OrderStatus='a' and ShippedDate<1 order by DateCode asc";
				$result = mysql_query($query) or die (mysql_error());
				while ($row = mysql_fetch_array($result)) {
				
					$query2 = "select * from `".$Settings['DBPrefix']."ec-Addresses` where RecordNumber=".$row['BillingAddress']."  limit 1";
					$result2 = mysql_query($query2) or die (mysql_error());
					$row2 = mysql_fetch_array($result2);
					
					$query3 = "select * from `".$Settings['DBPrefix']."core-Users` where RecordNumber=".$row['Account']."  limit 1";
					$result3 = mysql_query($query3) or die (mysql_error());
					$row3 = mysql_fetch_array($result3);
				
					
					$CustomerInfo = $row2['FirstName'].' '.$row2['LastName'].'<br>'.$row3['Email'];
				
						
					if ($row['PaymentReceived'] > 0) {
						$Paid = '<font color="#008800">'.$MsgText[0][118].'</font>';
					}
					else {
						$Paid = '<font color="#ff0000">'.$MsgText[0][119].'</font>';
					}
					
					
					if ($row['ShippedDate'] > 0) {
						$Shipped = '<font color="#008800">'.$MsgText[0][118].'</font>';
					}
					else {
						$Shipped = '<font color="#ff0000">'.$MsgText[0][119].'</font>';
					}
					
				
					$PageContents .= '<tr><td><font face="'.$FontFace.'" size="'.$FontSize.'">'.$row['RecordNumber'].'-'.$row['OrderID'].'</font></td><td align="center"><font face="'.$FontFace.'" size="'.$FontSize.'">'.date('M j, Y',$row['DateCode']).'<br>'.date('g:ia',$row['DateCode']).'</font></td><td align="center"><font face="'.$FontFace.'" size="'.$FontSize.'">'.$Paid.'</font></td><td align="center"><font face="'.$FontFace.'" size="'.$FontSize.'">'.$Shipped.'</font></td><td align="center"><font face="'.$FontFace.'" size="'.$FontSize.'">'.$CustomerInfo.'</font></td><td align="center"><font face="'.$FontFace.'" size="'.$FontSize.'"><a href="'.$MainURL.'/admin/store-orderdetails/'.$row['RecordNumber'].'.html">'.$MsgText[9][201].'</a></font></td></tr>';
				
				}
			
			
				$PageContents .= '</table>';
				
				
			} // end if $Arguments3 == 'new_open'
			else if ($Arguments3 == 'period') {
			
				if ($Arguments4 == '1') {
					$PeriodTitle = $MsgText[9][202];
					$query = "select * from `".$Settings['DBPrefix']."ec-Orders` where DateCode>='".mktime(0,0,0,date('n',GetTimestamp()),date('j',GetTimestamp()),date('Y',GetTimestamp()))."' order by DateCode asc";
				}
				else if ($Arguments4 == '2') {
					$PeriodTitle = $MsgText[9][203];
					$query = "select * from `".$Settings['DBPrefix']."ec-Orders` where DateCode>='".(GetTimestamp()-(60*60*24))."' order by DateCode asc";
				}
				else if ($Arguments4 == '3') {
					$PeriodTitle = $MsgText[9][204];
					$query = "select * from `".$Settings['DBPrefix']."ec-Orders` where DateCode>='".(mktime(0,0,0,date('n',GetTimestamp()),date('j',GetTimestamp()),date('Y',GetTimestamp()))-(60*60*24))."' and DateCode<'".mktime(0,0,0,date('n',GetTimestamp()),date('j',GetTimestamp()),date('Y',GetTimestamp()))."' order by DateCode asc";
				}
				else if ($Arguments4 == '4') {
					$PeriodTitle = $MsgText[9][205];
					$query = "select * from `".$Settings['DBPrefix']."ec-Orders` where DateCode>='".(mktime(0,0,0,date('n',GetTimestamp()),date('j',GetTimestamp()),date('Y',GetTimestamp()))-(60*60*24*7))."' order by DateCode asc";
				}
				else if ($Arguments4 == '5') {
					$PeriodTitle = $MsgText[9][206];
					$query = "select * from `".$Settings['DBPrefix']."ec-Orders` where DateCode>='".mktime(0,0,0,date('n',GetTimestamp()),1,date('Y',GetTimestamp()))."' order by DateCode asc";
				}
				else if ($Arguments4 == '6') {
					$PeriodTitle = $MsgText[9][207];
					$query = "select * from `".$Settings['DBPrefix']."ec-Orders` where DateCode>='".(mktime(0,0,0,date('n',GetTimestamp()),date('j',GetTimestamp()),date('Y',GetTimestamp()))-(60*60*24*30))."' order by DateCode asc";
				}
				else if ($Arguments4 == '7') {
					$PeriodTitle = $MsgText[9][194];
					$query = "select * from `".$Settings['DBPrefix']."ec-Orders` order by DateCode asc";
				}
			
				$PageTitle = '<img src="'.$ImagesURL.'/admin/admincp_ecom.gif" width="20" height="21" align="middle"> '.$PeriodTitle;
				$BrowserTitle = $PeriodTitle;
				$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> > '.$PeriodTitle;
			
					
				$PageContents .= '<br>';
			
				
				$PageContents .= '<table width="100%" border="0" cellpadding="3" cellspacing="0"><tr><td><font face="'.$FontFace.'" size="'.$FontSize.'"><b>'.$MsgText[9][196].'</b></font></td><td align="center"><font face="'.$FontFace.'" size="'.$FontSize.'"><b>'.$MsgText[9][197].'</b></font></td><td align="center"><font face="'.$FontFace.'" size="'.$FontSize.'"><b>'.$MsgText[9][198].'</b></font></td><td align="center"><font face="'.$FontFace.'" size="'.$FontSize.'"><b>'.$MsgText[9][199].'</b></font></td><td align="center"><font face="'.$FontFace.'" size="'.$FontSize.'"><b>'.$MsgText[9][200].'</b></font></td><td align="center"><font face="'.$FontFace.'" size="'.$FontSize.'"><b>'.$MsgText[9][201].'</b></font></td></tr>';
			
			
				
				$result = mysql_query($query) or die (mysql_error());
				if (mysql_num_rows($result) > 0) {
				while ($row = mysql_fetch_array($result)) {
				
					$query2 = "select * from `".$Settings['DBPrefix']."ec-Addresses` where RecordNumber=".$row['BillingAddress']."  limit 1";
					$result2 = mysql_query($query2) or die (mysql_error());
					$row2 = mysql_fetch_array($result2);
					
					$query3 = "select * from `".$Settings['DBPrefix']."core-Users` where RecordNumber=".$row['Account']."  limit 1";
					$result3 = mysql_query($query3) or die (mysql_error());
					$row3 = mysql_fetch_array($result3);
				
					
					$CustomerInfo = $row2['FirstName'].' '.$row2['LastName'].'<br>'.$row3['Email'];
				
						
					if ($row['PaymentReceived'] > 0) {
						$Paid = '<font color="#008800">'.$MsgText[0][118].'</font>';
					}
					else {
						$Paid = '<font color="#ff0000">'.$MsgText[0][119].'</font>';
					}
					
					
					if ($row['ShippedDate'] > 0) {
						$Shipped = '<font color="#008800">'.$MsgText[0][118].'</font>';
					}
					else {
						$Shipped = '<font color="#ff0000">'.$MsgText[0][119].'</font>';
					}
					
				
					$PageContents .= '<tr><td><font face="'.$FontFace.'" size="'.$FontSize.'">'.$row['RecordNumber'].'-'.$row['OrderID'].'</font></td><td align="center"><font face="'.$FontFace.'" size="'.$FontSize.'">'.date('M j, Y',$row['DateCode']).'<br>'.date('g:ia',$row['DateCode']).'</font></td><td align="center"><font face="'.$FontFace.'" size="'.$FontSize.'">'.$Paid.'</font></td><td align="center"><font face="'.$FontFace.'" size="'.$FontSize.'">'.$Shipped.'</font></td><td align="center"><font face="'.$FontFace.'" size="'.$FontSize.'">'.$CustomerInfo.'</font></td><td align="center"><font face="'.$FontFace.'" size="'.$FontSize.'"><a href="'.$MainURL.'/admin/store-orderdetails/'.$row['RecordNumber'].'.html">'.$MsgText[9][201].'</a></font></td></tr>';
				
				} // end while
						
				$PageContents .= '</table>';
				
				} // end if rows found
				else {
					
					$PageContents = '<br>'.$MsgText[9][208];
					
				}
				
				
			} // end if $Arguments3 == 'period'
		
		
		}
		else {
		
			$PageContents = $MsgText[0][97];
		
		}

	}
	else {
	
		RedirectToLogin();
	
	}

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




?>
