<?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";
include $server_inc."/invoice_functions.php";

if (phpversion()<="4.0.6") { $_POST=$HTTP_POST_VARS; }
if (isset($_POST['submit']))
	{
	if (trim($uid)==0) { $e0=true; unset($uid); }
	if (!isset($e0))
		{
		if (!isset($iid)) { $invoice_number=grab_invoice_number(); }

		if (isset($iid)) { $query="update "; }
		else { $query="insert "; $query.="into "; }
			
		$query.="invoice ";
		$query.="set ";
		$query.="uid='".addslashes(trim($uid))."', ";


		list($m, $d, $Y)=explode("/", $due_date);
		$query.="due_date='".mktime(0, 0, 0, $m, $d, $Y)."', ";

		$query.="txn_id='".addslashes(trim($txn_id))."', ";
		$query.="charge_tax='".addslashes(trim($charge_tax))."', ";
		$query.="tax_type='".addslashes(trim($tax_type))."', ";
		$query.="status='".addslashes(trim($status))."', ";
		
		if ($status==1) { if (!isset($date_paid)) { $query.="date_paid='".time()."', "; } }
		else { $query.="date_paid='', "; }

		$query.="invoice_terms='".addslashes(trim($invoice_terms))."', ";
		$query.="payment_method='".addslashes(trim($payment_method))."', ";
		$query.="additional_information='".addslashes(trim($additional_information))."', ";
		if (!isset($iid)) 
			{ 
			$query.="invoice_number='".addslashes(trim($invoice_number))."', ";
			$query.="created='".time()."', "; 
			}	
		
		$total_cost=0;
		$invoice_details="";
		while (@list($key, $value)=@each($item)) 
			{ 
			$query0="select ";
			$query0.="service_name, ";				// 0
			$query0.="service_description, ";		// 1
			$query0.="service_show_description, ";	// 2
			$query0.="service_cost ";				// 3
			$query0.="from ";
			$query0.="invoice_service ";
			$query0.="where ";
			$query0.="srid='".addslashes(trim($value))."'";

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

			$service_name=stripslashes(trim($rs0[0]));
			$service_description=base64_encode(stripslashes(trim($rs0[1])));
			$service_show_description=stripslashes(trim($rs0[2]));
			$service_cost=stripslashes(trim($rs0[3]));
			
			$invoice_details.=$value."@";	
			$invoice_details.=$qty[$value]."@";	
			$invoice_details.=$service_name."@";
			$invoice_details.=$service_description."@";
			$invoice_details.=$service_show_description."@";
			$invoice_details.=$service_cost."|";

			$total_cost+=($service_cost*$qty[$value]);
			}
		
		if ($invoice_details=="") { $err_nothing_chosen=true; }
		else
			{
			# if (!isset($total_due_today)) { $query.="total_due_today='".addslashes(trim($total_due_today))."', "; }
			# else { 
			$query.="total_due_today='".addslashes(trim($total_cost))."', ";
			$query.="invoice_details='".addslashes(trim($invoice_details))."', ";
			$query.="invoice_type='1'";
			
			if (isset($iid)) { $query.="where iid='".addslashes(trim($iid))."'"; }
			
			mysql_query($query);
			
			if (!isset($iid)) { $iid=mysql_insert_id(); } 

			$done=true;
			}
		}
	}

if (isset($iid))
	{
	$query1="select ";
	$query1.="uid, ";						// 0
	$query1.="due_date, ";					// 1
	$query1.="payment_method, ";			// 2
	$query1.="additional_information, ";	// 3
	$query1.="invoice_details, ";			// 4
	$query1.="created, ";					// 5
	$query1.="invoice_number, ";			// 6
	$query1.="invoice_terms, ";				// 7
	$query1.="total_due_today, ";			// 8
	$query1.="charge_tax, ";				// 9
	$query1.="status, ";					// 10
	$query1.="date_paid, ";					// 11
	$query1.="tax_type, ";					// 12
	$query1.="txn_id ";						// 13
	$query1.="from ";
	$query1.="invoice ";
	$query1.="where ";
	$query1.="iid='".addslashes(trim($iid))."'";

	$rs1=mysql_fetch_row(mysql_query($query1));

	$uid=stripslashes(trim($rs1[0]));
	$due_date=date("m/d/Y", stripslashes(trim($rs1[1])));
	$payment_method=stripslashes(trim($rs1[2]));
	$additional_information=stripslashes(trim($rs1[3]));
	$invoice_details=stripslashes(trim($rs1[4]));
	$created=date("m/d/Y", stripslashes(trim($rs1[5])));
	$invoice_number=stripslashes(trim($rs1[6]));
	$invoice_terms=stripslashes(trim($rs1[7]));
	$total_due_today=stripslashes(trim($rs1[8]));
	$charge_tax=stripslashes(trim($rs1[9]));
	$invoice_status=stripslashes(trim($rs1[10]));
	$date_paid=stripslashes(trim($rs1[11]));
	$tax_type=stripslashes(trim($rs1[12]));
	$txn_id=stripslashes(trim($rs1[13]));
	}

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."'>
			".((isset($iid))?"<input type='hidden' name='iid' value='".$iid."'>":"")."
			".((isset($p))?"<input type='hidden' name='p' value='".$p."'>":"")."
			".((isset($pg))?"<input type='hidden' name='pg' value='".$pg."'>":"")."
			<table width='100%' cellpadding='2' cellspacing='0' border='0'>
				<tr>
					<td colspan='2' align='left' valign='top'><img src='".$http_images."/menu_arrow.gif'> <a href='".$http_admin."/invoice.php?sid=".$sid."'>Invoice Home</a> &gt; 
	");

if (isset($p))
	{
	if ($p==0)
		{
		echo "[ <a href='".$http_admin."/invoice_pending.php?sid=".$sid."".((isset($pg))?"&pg=".$pg."":"")."'><font color='#990000'>Back to the unpaid billable service view</font></a> ]";
		}
	else if ($p==1)
		{
		echo "[ <a href='".$http_admin."/invoice_paid.php?sid=".$sid."".((isset($pg))?"&pg=".$pg."":"")."'><font color='#990000'>Back to the paid billable service view</font></a> ]";
		}
	else if ($p==70)
		{
		echo "[ <a href='".$http_admin."/invoice_non_hosting_client_summary.php?sid=".$sid."&uid=".$uid."".((isset($pg))?"&pg=".$pg."":"")."'><font color='#990000'>Back to the non hosting client billable service view</font></a> ]";
		}
	else
		{
		echo "[ <a href='".$http_admin."/invoice_past_due.php?sid=".$sid."".((isset($pg))?"&pg=".$pg."":"")."'><font color='#990000'>Back to the past due billable service view</font></a> ]";
		}
	}
else if (isset($iid))
	{
	echo "[ <a href='".$http_admin."/invoice_create.php?sid=".$sid."&iid=".$iid."".((isset($pg))?"&pg=".$pg."":"")."'><font color='#990000'>Edit billable service invoice</font></a> ]";
	}
else
	{
	echo "[ <a href='".$http_admin."/invoice_create.php?sid=".$sid."".((isset($pg))?"&pg=".$pg."":"")."'><font color='#990000'>Create billable service invoice</font></a> ]";
	}
echo("
					</td>
				</tr>
				<tr>
					<td colspan='2' align='left' valign='top'><hr color='#F0EFED'></td>
				</tr>
			</table>
	");

if (isset($err_nothing_chosen))
	{
	echo("
		<table width='725' cellpadding='2' cellspacing='0' border='0'>
			<tr>
				<td align='left' valign='top'><img src='".$http_images."/error_arrow.gif'> <font color='#990000'>You must choose at least 1 billable object to continue.</font></td>
			</tr>
			<tr>
				<td align='left' valign='top'><hr align='left' valign='top' color='#F0EFED' width='725'></td>
			</tr>
		</table>
		");
	}
if (isset($done))
	{
	echo("
		<table width='725' cellpadding='2' cellspacing='0' border='0'>
			<tr>
				<td align='left' valign='top'><font color='#990000'>The invoice was edited successfully!</font></td>
			</tr>
			<tr>
				<td align='left' valign='top'>
		");
	if (isset($p))
		{
		if ($p==0)
			{
			echo "<img src='".$http_images."/error_arrow.gif'><a href='".$http_admin."/invoice_pending.php?sid=".$sid."".((isset($pg))?"&pg=".$pg."":"")."'>Back to the unpaid billable service view</a>";
			}
		else if ($p==1)
			{
			echo "<img src='".$http_images."/error_arrow.gif'><a href='".$http_admin."/invoice_paid.php?sid=".$sid."".((isset($pg))?"&pg=".$pg."":"")."'>Back to the paid billable service view</a>";
			}
		else if ($p==70)
			{
			echo "<img src='".$http_images."/error_arrow.gif'><a href='".$http_admin."/invoice_non_hosting_client_summary.php?sid=".$sid."&uid=".$uid."".((isset($pg))?"&pg=".$pg."":"")."'>Back to the non hosting client billable service view.</a>";
			}
		else
			{
			echo "<img src='".$http_images."/error_arrow.gif'><a href='".$http_admin."/invoice_past_due.php?sid=".$sid."".((isset($pg))?"&pg=".$pg."":"")."'>Back to the past due billable service view</a>";
			}
		}
	else if (isset($iid))
		{
		echo "<img src='".$http_images."/error_arrow.gif'><a href='".$http_admin."/invoice_create.php?sid=".$sid."&iid=".$iid."".((isset($pg))?"&pg=".$pg."":"")."'>Edit billable service invoice</a>";
		}
	else
		{
		echo "<img src='".$http_images."/error_arrow.gif'><a href='".$http_admin."/invoice_create.php?sid=".$sid."".((isset($pg))?"&pg=".$pg."":"")."'>Create a billable service invoice</a>";
		}
	echo("
				</td>
			</tr>
			<tr>
				<td align='left' valign='top'><img src='".$http_images."/error_arrow.gif'><a href='".$http_admin."/invoice.php?sid=".$sid."'>Go back to the main invoice view</a>.</td>
			</tr>
			<tr>
				<td align='left' valign='top'><img src='".$http_images."/error_arrow.gif'>Make edits to <b>this invoice</b> below:</td>
			</tr>
			<tr>
				<td align='left' valign='top'><hr align='left' valign='top' color='#F0EFED' width='725'></td>
			</tr>
		</table>
		");
	}
echo "<table width='100%' cellpadding='2' cellspacing='0' border='0'>";
if (isset($e0))
	{
	echo("
				<tr>
					<td colspan='2' align='left' valign='top'><font color='#990000'>Please <b>choose a client</b> to continue.</font></td>
				</tr>
				<tr>
					<td colspan='2' align='left' valign='top'><hr color='#F0EFED'></td>
				</tr>
		");
	}
echo("
				<tr>
					<td width='25%' align='left' valign='top'>&nbsp;Invoice Goes To:</td>
					<td width='75%' align='left' valign='top'>
	");
if (isset($uid))
	{
	$row0=mysql_query("select uid, first_name, last_name, zip_code from user where status='0' order by first_name asc");
	while ($rs0=mysql_fetch_row($row0)) 
		{ 
		if ($uid==$rs0[0]) 
			{ 
			echo "<b>".stripslashes($rs0[1])." ".stripslashes($rs0[2])." - ".stripslashes($rs0[3])."</b>"; 
			echo "<input type='hidden' name='uid' value='".$rs0[0]."'>";
			} 
		}
	}
else
	{
	echo("				
						<select name='uid' ".$input_style." onChange=\"window.open(this.options[this.selectedIndex].value, '_top')\">
				<option value='#'".((isset($uid))?"".((trim($uid)=="0")?" selected":"")."":" selected").">Choose Client</option>
				<option value='".$http_admin."/invoice_add_new_client.php?sid=".$sid."'>A New Client</option>
		");
	$row0=mysql_query("select uid, first_name, last_name, zip_code from user where status='0' order by first_name asc");
	while ($rs0=mysql_fetch_row($row0))
		{
		echo"<option value='".$http_admin."/invoice_create.php?sid=".$sid."&uid=".$rs0[0]."'".((isset($uid))?"".(($uid==$rs0[0])?" selected":"")."":"").">".stripslashes($rs0[1])." ".stripslashes($rs0[2])." - ".stripslashes($rs0[3])."</option>\n";
		}
	echo("
			</select>
		");
	}
echo("	
					</td>
				</tr>
				<tr>
					<td colspan='2' align='left' valign='top'><img src='".$http_image."/space.gif' width='1' height='6'></td>
				</tr>
		".((isset($uid))?"<input type='hidden' name='uid' value='".$uid."'>":"<input type='hidden' name='uid' value='0'>")."
	");
if (isset($iid))
	{
	echo("
				<tr>
					<td width='25%' align='left' valign='top'>&nbsp;Invoice Number:</td>
					<td width='75%' align='left' valign='top'>".$invoice_number."</td>
				</tr>
				<tr>
					<td colspan='2' align='left' valign='top'><img src='".$http_image."/space.gif' width='1' height='6'></td>
				</tr>
				<tr>
					<td width='25%' align='left' valign='top'>&nbsp;Invoice Created:</td>
					<td width='75%' align='left' valign='top'>".$created."</td>
				</tr>
				<tr>
					<td colspan='2' align='left' valign='top'><img src='".$http_image."/space.gif' width='1' height='6'></td>
				</tr>
				<tr>
					<td width='25%' align='left' valign='top'>&nbsp;Date Invoice is Due by:</td>
					<td width='75%' align='left' valign='top'>
		");
	if ($invoice_terms==0) { echo "<font color='#990000'><i>Upon Receipt</i></font>"; }
	else
		{
		$m=date("m", $rs1[5]);
		$d=date("d", $rs1[5]);
		$y=date("Y", $rs1[5]);
		echo date("m/d/Y", mktime(0, 0, 0, $m, ($d+$invoice_terms), $y));
		}
	echo("
					</td>
				</tr>
				<tr>
					<td colspan='2' align='left' valign='top'><img src='".$http_image."/space.gif' width='1' height='6'></td>
				</tr>
				<tr>
					<td width='20%' align='left' valign='middle'>&nbsp;Invoice Status: </td>
					<td width='80%' align='left' valign='middle'><select name='status' ".$input_style.">
	");

$state=invoice_status_select($invoice_status);
$count=(substr_count($state, "|")-1);
$array=explode("|", $state);
for ($i=0; $i<=$count; $i++)
	{
	list($id, $state)=explode("@", $array[$i]);
	if ($id==$invoice_status&&$id==1) { $paid=true; }
	echo "<option value='".$id."'".(($id==$invoice_status)?" selected":"").">".$state."</option>";
	}

echo("
					</select></td>
				</tr>
		");
	}
if (isset($paid))
	{
	echo("
				<tr>
					<td colspan='2' align='left' valign='top'><img src='".$http_image."/space.gif' width='1' height='6'></td>
				</tr>
				<tr>
					<td width='25%' align='left' valign='top'>&nbsp;Invoice Paid On:</td>
					<td width='75%' align='left' valign='top'>".date("m/d/Y", $date_paid)."<input type='hidden' name='date_paid' value='".$date_paid."'></td>
				</tr>
				<tr>
					<td colspan='2' align='left' valign='top'><img src='".$http_image."/space.gif' width='1' height='6'></td>
				</tr>
				<tr>
					<td width='25%' align='left' valign='top'>&nbsp;Transaction ID:</td>
					<td width='75%' align='left' valign='top'><input ".$input_style." size='14' maxlength='255' type='text' name='txn_id' value='".((trim($txn_id)=="")?"None":"".$txn_id."")."'></td>
				</tr>
		");
	}
echo("
				<tr>
					<td colspan='2' align='left' valign='top'><img src='".$http_image."/space.gif' width='1' height='6'></td>
				</tr>
				<tr>
					<td width='25%' align='left' valign='top'>&nbsp;% to Charge Tax or VAT?</td>
					<td width='75%' align='left' valign='top'><input ".$input_style." size='4' maxlength='4' type='text' name='charge_tax' value='".((isset($charge_tax))?"".(($charge_tax<0)?"":"".sprintf("%01.2f", $charge_tax)."")."":"")."'> <b>%</b> <font color='#990000'>Leave blank of no, otherwise enter a percentage. <b>ex. 0.06%</b></font></td>
				</tr>
				<tr>
					<td colspan='2' align='left' valign='top'><img src='".$http_image."/space.gif' width='1' height='6'></td>
				</tr>
				<tr>
					<td width='25%' align='left' valign='top'>&nbsp;Display Tax/VAT, if Applicable:</td>
					<td width='75%' align='left' valign='top'>
					<table width='75' cellpadding='0' cellspacing='0' border='0'>
						<tr>
							<td><input type='radio' name='tax_type' value='Tax'".((isset($tax_type))?"".(($tax_type=="Tax")?" checked":"")."":" checked")." id='tax'></td>
							<td><label for='tax'>Tax</label></td>
							<td><img src='".$http_images."/space.gif' width='12' height='1'></td>
							<td><input type='radio' name='tax_type' value='VAT'".((isset($tax_type))?"".(($tax_type=="VAT")?" checked":"")."":"")." id='vat'></td>
							<td><label for='vat'>VAT</label></td>
						</tr>
					</table>
					</td>
				</tr>
	");
if (isset($iid))
	{
	echo("
				<tr>
					<td colspan='2' align='left' valign='top'><img src='".$http_image."/space.gif' width='1' height='6'></td>
				</tr>
				<tr>
					<td width='25%' align='left' valign='top'>&nbsp;Invoice Amount:</td>
					<td width='75%' align='left' valign='top'><font color='#990000'><b>".$currency."".sprintf("%01.2f", $total_due_today)." ".$currency_type."</b></font></td>
				</tr>
		");
	if ($charge_tax>0)
		{
		echo("
				<tr>
					<td colspan='2' align='left' valign='top'><img src='".$http_image."/space.gif' width='1' height='6'></td>
				</tr>
				<tr>
					<td width='25%' align='left' valign='top'>&nbsp;Invoice Amount w/ Tax:</td>
					<td width='75%' align='left' valign='top'><font color='#990000'><b>".$currency."".sprintf("%01.2f", ($total_due_today+($total_due_today*$charge_tax)))." ".$currency_type."</b></font></td>
				</tr>
				");
		}
	}
echo("
				<tr>
					<td colspan='2' align='left' valign='top'><img src='".$http_image."/space.gif' width='1' height='6'></td>
				</tr>
				<tr>
					<td width='25%' align='left' valign='top'>&nbsp;Invoice Terms:</td>
					<td width='75%' align='left' valign='top'><select name='invoice_terms' ".$input_style.">
					<option value='0'".((isset($invoice_terms))?"".(($invoice_terms=="0")?" selected":"")."":"").">Upon Receipt</option>
					<option value='30'".((isset($invoice_terms))?"".(($invoice_terms=="30")?" selected":"")."":"").">30 Days</option>
					<option value='60'".((isset($invoice_terms))?"".(($invoice_terms=="60")?" selected":"")."":"").">60 Days</option>
					<option value='90'".((isset($invoice_terms))?"".(($invoice_terms=="90")?" selected":"")."":"").">90 Days</option>
					<option value='120'".((isset($invoice_terms))?"".(($invoice_terms=="120")?" selected":"")."":"").">120 Days</option>
					</select></td>
				</tr>
				<tr>
					<td colspan='2' align='left' valign='top'><img src='".$http_image."/space.gif' width='1' height='6'></td>
				</tr>
				<tr>
					<td width='25%' align='left' valign='top'>&nbsp;Payment Method:</td>
					<td width='75%' align='left' valign='top'><select name='payment_method' ".$input_style.">
				");
			$row1=mysql_query("select pid, name from payment_process where status='1'");
			while ($rs1=mysql_fetch_row($row1))
				{
				echo "<option value='".$rs1[0]."'".((isset($payment_method))?"".(($payment_method==$rs1[0])?" selected":"")."":"").">".stripslashes(trim(str_replace(" Future Pay", "", $rs1[1])))."</option>\n";
				}
			echo("
					</select></td>
				</tr>
				<tr>
					<td colspan='2' align='left' valign='top'><img src='".$http_image."/space.gif' width='1' height='6'></td>
				</tr>
				<tr>
					<td width='25%' align='left' valign='top'>&nbsp;Additional Information:</td>
					<td width='75%' align='left' valign='top'><textarea name='additional_information' ".$input_style." rows='4' cols='50'>".$additional_information."</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 colspan='2' align='left' valign='top'>&nbsp;Available Billable Objects:</td>
				</tr>
				<tr>
					<td colspan='2' align='left' valign='top'>
					<table width='100%' border='0' cellspacing='1' cellpadding='2'>
						<tr>
							<td width='10%' align='center' valign='middle' bgcolor='#E5E7E9'><b>Include</b></td>
							<td width='10%' align='left' valign='middle' bgcolor='#E5E7E9'>&nbsp;<b>QTY</b></td>
							<td width='65%' align='left' valign='middle' bgcolor='#E5E7E9'>&nbsp;<b>Service Name</b></td>
							<td width='15%' align='left' valign='middle' bgcolor='#E5E7E9'>&nbsp;<b>Service Cost</b></td>
						</tr>
						");

					$x=1;
					$y=1;
					$query="select ";
					$query.="srid, ";						// 0
					$query.="service_name, ";				// 1
					$query.="service_description, ";		// 2
					$query.="service_show_description, ";	// 3
					$query.="service_cost ";				// 4
					$query.="from invoice_service ";
					$query.="order by service_name asc";

					$row=mysql_query($query);
					while ($rs=mysql_fetch_row($row))
						{
						$srid=stripslashes(trim($rs[0]));
						$service_name=stripslashes(trim($rs[1]));
						$service_description=stripslashes(trim($rs[2]));
						$service_show_description=stripslashes(trim($rs[3]));
						$service_cost=stripslashes(trim($rs[4]));
						
						# parse out the invoice details
						$count=(substr_count($invoice_details, "|")-1);
						$array=explode("|", $invoice_details);
						for ($i=0; $i<=$count; $i++)
							{
							list($stored_srid, $stored_qty)=explode("@", $array[$i]);
							if ($stored_srid==$srid) { $match=true; $qty_bit=$stored_qty; break; }
							else
								{
								unset($stored_srid);
								unset($stored_qty);
								}
							}

						if ($y==1) {$bgcolor="#F2F4F6"; $y=0;} else {$bgcolor="#ECEEF0"; $y=1;}
						echo("
							<tr>
								<td align='center' valign='middle' bgcolor='#E5E7E9'><input type='checkbox' name='item[]' value='".$srid."'".((isset($match))?" checked":"")."></td>
								<td align='left' valign='middle' bgcolor='".$bgcolor."'>&nbsp;<input ".$input_style." type='text' name='qty[".$srid."]' size='8' maxlength='10' value='".((isset($qty_bit))?"".$qty_bit."":"1")."'></td>
								<td align='left' valign='middle' bgcolor='".$bgcolor."'>&nbsp;
							");

						unset($stored_srid);
						unset($stored_qty);
						unset($qty_bit);
						unset($match);

						if ($service_show_description==1)
							{
							$service_title=preg_replace("/[^A-Za-z0-9 ]/", "", strip_tags($rs[1]));
							$service_description=preg_replace("/[^A-Za-z0-9 ]/", "", strip_tags($service_description));
							echo "<A HREF='javascript:void(0)' class='cleanlink3' onmouseover=\"return overlib('".$service_description."', CAPTION, '".stripslashes($service_title)."');\" onmouseout='nd();'>".stripslashes($rs[1])."</a>";
							}
						else { echo stripslashes($rs[1]); }

						echo("
								</td>
								<td align='left' valign='middle' bgcolor='".$bgcolor."'>&nbsp;".$currency."".sprintf("%01.2f", $service_cost)."&nbsp;".$currency_type."</td>
							</tr>
							");
						$x++;
						}
			echo("
						</table>
					</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."/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='".((isset($iid))?"Edit":"Create")." Invoice Now'></td>
				</tr>
			</table>
			</form>
			</td>
		</tr>
	</table>
	");
include $server_admin_inc."/footer.php";
mysql_close($dblink);
?>