Location: PHPKode > scripts > PHP Online Invoice System > php-online-invoice-system/invoice_history.php
<?
/*
 * Exemplar Web hosting
 * http://www.exemplar.biz
 *
 * Title: PHP Online Invoice System
 * Version: 2.0
 * Author: Exemplar
 * Date: 01-01-2006
 *
*/
include "header.php";
echo " <br><h1>Invoice History</h1>";

?>
<form method="post" name=form1 action="invoice_history.php">
<table width="350" align="center" border="0"><tr>
<td width="100%">Start Date: <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=''" /> <font class="small">Oldest date first</font>
<script type="text/javascript">
    Calendar.setup({
        inputField     :    "invdate",
        ifFormat       :    "%Y-%m-%d",
        button         :    "f_trigger_c",
        align          :    "Tl",
        singleClick    :    true
    });
</script><br>

End Date: &nbsp;<input type="text" name="invdate2" id="invdate2">
<img src="img.gif" id="f_trigger_d"
     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     :    "invdate2",
        ifFormat       :    "%Y-%m-%d",
        button         :    "f_trigger_d",
        align          :    "Tl",
        singleClick    :    true
    });
</script>
</td></tr>
<tr><td align="center" width="100%">
<input type="Submit" name="update" value="Submit Invoice Date"></form>
</td></tr></table>
<br><br>

<?

if($update){
echo "<br><br>Your search was for $invdate to $invdate2";
$hdate = "BETWEEN($invdate,$invdate2)";
$result = mysql_query("SELECT invoices.*, clients.*
FROM invoices,clients
WHERE invoices.clientid = clients.clientid && invoices.date > '$hdate'
ORDER BY id",$db);
$result2 = mysql_query("SELECT sum(total) AS sum FROM invoices WHERE date >'.$hdate.'");
$sum = mysql_result($result2,0,"sum");
}else if($submit){
echo "<br><br>Your search was for $invdate";
$result = mysql_query("SELECT invoices.*, clients.*
FROM invoices,clients
WHERE invoices.clientid = clients.clientid && invoices.date > '$invdate'
ORDER BY id",$db);
$result2 = mysql_query("SELECT sum(total) AS sum FROM invoices WHERE date >'.$invdate.'");
$sum = mysql_result($result2,0,"sum");
}
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>";
}


if ($sum == 1){
echo "<tr><td colspan=4></td><td align=right>Total: $0</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>";



include "footer.php";

?>
Return current item: PHP Online Invoice System