<?PHP
include "../inc/var.php";
include "../inc/connect.php";
# include $server_inc."/whm_functions.php";
include $server_inc."/client_functions.php";
include $server_inc."/login_functions.php";

if (phpversion()<="4.0.6") { $_POST=$HTTP_POST_VARS; }
if (isset($_POST['submit']))
	{
	$query="update ";
	$query.="invoice_config ";
	$query.="set ";
	$query.="logo_path='".addslashes(trim($logo_path))."', ";
	$query.="company_contact='".addslashes(trim($company_contact))."', ";
	$query.="payable_to='".addslashes(trim($payable_to))."', ";
	$query.="invoice_number='".addslashes(trim($invoice_number))."'";

	mysql_query($query);
	}

$query0="select ";
$query0.="logo_path, ";
$query0.="company_contact, ";
$query0.="payable_to, ";
$query0.="invoice_number ";
$query0.="from ";
$query0.="invoice_config ";
$query0.="limit 0, 1";

$rs0=mysql_fetch_row(mysql_query($query0));

$logo_path=stripslashes(trim($rs0[0]));
$company_contact=stripslashes(trim($rs0[1]));
$payable_to=stripslashes(trim($rs0[2]));
$invoice_number=stripslashes(trim($rs0[3]));

include $server_admin_inc."/header.php";

echo("
	<table width='725' cellpadding='0' cellspacing='0' border='0'>
		<tr>
			<td width='1%' align='left' valign='top'><img src='".$http_images."/space.gif' width='15' height='375'></td>
			<td width='99%' align='left' valign='top'>
			<form action='".$PHP_SELF."' method='POST'>
			<input type='hidden' name='sid' value='".$sid."'>
			<table width='100%' cellpadding='2' cellspacing='0' border='0'>
				<tr>
					<td colspan='2' align='left' valign='top'><img src='".$http_images."/menu_arrow.gif'><b>Configure Invoice Module</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[<a href='".$http_admin."/index2.php?sid=".trim($sid)."'><font color='#990000'>Back</font></a>]</td>
				</tr>
				<tr>
					<td colspan='2' align='left' valign='top'><hr color='#F0EFED'></td>
				</tr>
				<tr>
					<td width='25%' align='left' valign='top'>&nbsp;<img src='".$http_images."/error_arrow.gif'>Invoices Start at:</td>
					<td width='75%' align='left' valign='top'><input size='4' maxlength='255' ".$input_style." type='text' name='invoice_number' value='".$invoice_number."'>&nbsp;&nbsp;<font color='#990000'>We suggest you set this value once and don't change it to prevent duplicate invoice numbers.</font></td>
				</tr>
				<tr>
					<td colspan='2' align='left' valign='top'><img src='".$http_image."/space.gif' width='1' height='12'></td>
				</tr>
				<tr>
					<td width='25%' align='left' valign='top'>&nbsp;<img src='".$http_images."/error_arrow.gif'>Default Payee:</td>
					<td width='75%' align='left' valign='top'><input size='50' maxlength='255' ".$input_style." type='text' name='payable_to' value='".$payable_to."'></td>
				</tr>
				<tr>
					<td colspan='2' align='left' valign='top'><img src='".$http_image."/space.gif' width='1' height='12'></td>
				</tr>
				<tr>
					<td width='25%' align='left' valign='top'>&nbsp;<img src='".$http_images."/error_arrow.gif'>Company Contact Info:</td>
					<td width='75%' align='left' valign='top'><textarea name='company_contact' ".$input_style." rows='4' cols='50'>".$company_contact."</textarea></td>
				</tr>
				<tr>
					<td colspan='2' align='left' valign='top'><img src='".$http_image."/space.gif' width='1' height='12'></td>
				</tr>
				<tr>
					<td width='25%' align='left' valign='top'>&nbsp;<img src='".$http_images."/error_arrow.gif'>Custom Invoice Logo:</td>
					<td width='75%' align='left' valign='top'><input ".$input_style." type='text' name='logo_path' size='50' maxlength='255' value='".$logo_path."'>&nbsp;&nbsp;<font color='#990000'>ex.&nbsp;http://yoursite.com/yourlogo.gif</font></td>
				</tr>
		");
if (trim($logo_path)!="")
	{
	echo("
				<tr>
					<td colspan='2' align='left' valign='top'><img src='".$http_image."/space.gif' width='1' height='12'></td>
				</tr>
				<tr>
					<td width='25%' align='left' valign='top'>&nbsp;<img src='".$http_images."/error_arrow.gif'>Current Logo:</td>
					<td width='75%' align='left' valign='top'><img src='".$logo_path."'></td>
				</tr>
		");
	}
echo("
				<tr>
					<td colspan='2' align='left' valign='top'><img src='".$http_image."/space.gif' width='1' height='12'></td>
				</tr>
				<tr>
					<td width='25%' align='left' valign='top'>&nbsp;<img src='".$http_images."/space.gif' width='1' height='8'></td>
					<td width='75%' align='left' valign='top'></td>
				</tr>
				<tr>
					<td width='25%' align='left' valign='top'></td>
					<td width='75%' align='left' valign='top'><input ".$button_style." type='submit' name='submit' value='Save Changes'></td>
				</tr>
			</table>
			</form>
			</td>
		</tr>
	</table>
	");
include $server_admin_inc."/footer.php";
mysql_close($dblink);
?>