Location: PHPKode > scripts > PHP Online Invoice System > php-online-invoice-system/menu.php
<?
/*
 * Exemplar Web hosting
 * http://www.exemplar.biz
 *
 * Title: PHP Online Invoice System
 * Version: 2.0
 * Author: Exemplar
 * Date: 01-01-2006
 *
*/
session_start();
if(!session_is_registered("client_id"))
{
header("Location: index.php");
exit;
}

if ($client_name !== 'admin')
{
include "client_header.php";

$url_access=$_SERVER['REQUEST_URI'] ;

$isql = "INSERT INTO client_access (clientid,client_name,fname,lname,ipaddr,date,timein,url_viewed,isloggedin)
VALUES ('$client_id','$client_name','$fname','$lname','$remoteaddr','$date_in','$time_in','$url_access','$cisloggedin')";
$result = mysql_query($isql);
?>
<h2><br>Hello <b>
  <?=$client_name?>

  Here are your invoices:
  </b></h2>

<?

$result = mysql_query("SELECT * FROM invoices WHERE clientid = '$client_id' ORDER BY id",$db);

echo "<p><table border=1 cellspacing=0 cellpadding=2 bordercolor=#000000 width=90%>";
echo "<tr align=top>
<td class=topHeadrow5><b>Inv. #</b></td>
<td class=topHeadrow5><b>Invoice Date</b></td>
<td class=topHeadrow5><b>Due Date</b></td>
<td class=topHeadrow5><b>Total</b></td>
<td class=topHeadrow5><b>Status</b></td>
<td class=topHeadrow5>&nbsp;</td></tr>";

while ($row = mysql_fetch_array($result))
{
	$id = $row["id"];
	$date = $row["date"];
	$bill_date = $row["bill_date"];
	$due_date = $row["due_date"];
	$paid_date = $row["paid_date"];
	$dateshow = fixDate($date);
	$dateshow1 = fixDate($bill_date);
	$dateshow2 = fixDate($due_date);
	$dateshow3 = fixDate($paid_date);
	$total = $row["total"];
	$status = $row["status"];

if ($alternate == "1") {
	$color = "#ffffff";
	$alternate = "2";
	}
	else {
	$color = "#c0c0c0";
	$alternate = "1";
	}

echo "<tr valign=top bgcolor=$color><td>$id</td><td>$dateshow</td><td>$dateshow2</td><td align=right>$currency$total</td>";
if($status == "paid"){
echo "<td bgcolor=#33cc33>$status</td>";
}else{
echo "<td>$status</td>";
}
echo "<td>[ <a href='invoice.php?id=$id'>view</a> ] [ <a target=_blank href='invoice_print.php?id=$id'>Print</a> ]</td></tr>";
}
echo "</table>";
//-------------------------------------------------Begin Admin-------------------------------------------------
}
elseif ($client_name == 'admin')
{
include "header.php";

$url_access=$_SERVER['REQUEST_URI'] ;

?>
<h2><br>Hello <b>
  <?=$client_name?>

  Here are your invoices:
  </b></h2>

<?
echo " This is the $dayofyear2 day of the year.<br>";
echo " Showing Invoices from $ytd";
if ($menusort1 = $menusort1) {
$result = mysql_query("SELECT invoices.*, clients.*
FROM invoices,clients
WHERE invoices.clientid = clients.clientid && invoices.date >'$ytd'
ORDER BY $menusort1 ASC",$db);

}
if ($menusort = $menusort) {
$result = mysql_query("SELECT invoices.*, clients.*
FROM invoices,clients
WHERE invoices.clientid = clients.clientid && invoices.date >'$ytd'
ORDER BY $menusort DESC",$db);

}
if (!$menusort and !$menusort1) {
$result = mysql_query("SELECT invoices.*, clients.*
FROM invoices,clients
WHERE invoices.clientid = clients.clientid && invoices.date >'$ytd'
ORDER BY id",$db);
}
echo "<p><table border=1 cellspacing=0 cellpadding=2 bordercolor=#000000 width=95%>";
echo "<tr align=top>
<td class=topHeadrow5><b>INV <a href='menu.php?menusort=id'><img class=arrows src=images/dn_arrow.gif></a><a href='menu.php?menusort1=id'><img class=arrows src=images/up_arrow.gif></a></b></td>
<td class=topHeadrow5><b>Name <a href='menu.php?menusort=name'><img class=arrows src=images/dn_arrow.gif></a><a href='menu.php?menusort1=name'><img class=arrows src=images/up_arrow.gif></a></b></td>
<td class=topHeadrow5><b>Invoice Date <a href='menu.php?menusort=date'><img class=arrows src=images/dn_arrow.gif></a><a href='menu.php?menusort1=date'><img class=arrows src=images/up_arrow.gif></a></b></td>
<td class=topHeadrow5><b>Due Date <a href='menu.php?menusort=due_date'><img class=arrows src=images/dn_arrow.gif></a><a href='menu.php?menusort1=due_date'><img class=arrows src=images/up_arrow.gif></a></b></td>
<td class=topHeadrow5><b>Total <a href='menu.php?menusort=total'><img class=arrows src=images/dn_arrow.gif></a><a href='menu.php?menusort1=total'><img class=arrows src=images/up_arrow.gif></a></b></td>
<td class=topHeadrow5><b>Status <a href='menu.php?menusort=status'><img class=arrows src=images/dn_arrow.gif></a><a href='menu.php?menusort1=status'><img class=arrows src=images/up_arrow.gif></a></b></td>
<td class=topHeadrow5>&nbsp;</td>
<td class=topHeadrow5>&nbsp;</td>
<td class=topHeadrow5>&nbsp;</td>
<td class=topHeadrow5>&nbsp;</td></tr>";

while ($row = mysql_fetch_array($result))
{
	$id = $row["id"];
	$clientid = $row["clientid"];
	$name = $row["name"];
	$date = $row["date"];
	$bill_date = $row["bill_date"];
	$due_date = $row["due_date"];
	$paid_date = $row["paid_date"];
	$dateshow = fixDate($date);
	$dateshow1 = fixDate($bill_date);
	$dateshow2 = fixDate($due_date);
	$dateshow3 = fixDate($paid_date);
	$shipping = $row["shipping"];
	$total = $row["total"];
	$status = $row["status"];


if ($alternate == "1") {
	$color = "#ffffff";
	$alternate = "2";
	}
	else {
	$color = "#e5e5e5";
	$alternate = "1";
	}

echo "<tr valign=top bgcolor=$color>
<td width=10>$id</td><td>$name</td>
<td>$dateshow</td><td>$dateshow2</td>
<td align=right>$currency$total</td>";
if ($status == 'pending') {
echo "<td  bgcolor=$color>$status</td>";

} else {
echo "<td class=rowviewinv >$status</td>";
}
if ($status == 'pending') {
echo "<td>[ <a href='admin_invoice.php?id=$id'>view / change status</a> ]</td>";
}
else {
echo "<td class=rowviewinv>[ <a class=inv_links href='admin_invoice.php?id=$id'>view</a> ]</td>";
}
if ($status == 'pending') {
echo "<td>[ <a href='notifyclient.php?id=$id&clientid=$clientid'>notify client</a> ]</td>";
} else {
echo "<td class=rowviewinv>[ Paid $dateshow3 ]</td>";
}

echo "<td>[ <a href='edit_invoice.php?id=$id'>edit</a> ]</td><td>[ <a href='delete_invoice.php?id=$id' onClick=\"return confirm('Are you sure?')\">delete</a> ]</td></tr>";
}
$result = mysql_query("SELECT sum(total) AS sum FROM invoices WHERE date >'.$ytd.'");
$sum = mysql_result($result,0,"sum");

if ($sum == 1){
echo "<tr><td colspan=4></td><td align=right>Total: $currency0</td><td colspan=5></td></tr>";
}else{
echo "<tr><td colspan=4></td><td align=right>Total: <font face=Verdana size=1 color=red>$currency$sum</font></td><td colspan=5></td></tr>";
}
echo "</table>";

?>
<p align="center"><font class="medBold">You can review Invoices from previous dates by selecting from the calendar icons. Invoices above are for <?php print (date("Y")); ?>.
</font></p>
<form method="post" name=form1 action="invoice_history.php">
<input type="text" name="invdate" id="invdate">
<img src="img.gif" id="f_trigger_c"
     style="cursor: pointer; border: 1px solid red;"
     title="Date selector"
     onmouseover="this.style.background='red';"
     onmouseout="this.style.background=''" />
<script type="text/javascript">
    Calendar.setup({
        inputField     :    "invdate",
        ifFormat       :    "%Y-%m-%d",
        button         :    "f_trigger_c",
        align          :    "Tl",
        singleClick    :    true
    });
</script>
<input type="Submit" name="submit" value="Submit Invoice Date"></form>
<?
}
include "footer.php";
?>
Return current item: PHP Online Invoice System