Invoice Management in a PHP Invoicing System - Finishing the Invoice Page (
Page 2 of 6 )
The rest of the page looks like this:
<tr valign="top" class="tblheadings">
<td width="9%"><strong>Invoice # </strong></td>
<td width="14%"><strong>Client Name </strong></td>
<td width="8%"><strong>Status</strong></td>
<td width="11%"><strong>Date Issued </strong></td>
<td width="11%"><strong>Total(excl VAT)</strong></td>
<td width="13%"><strong>Total(incl VAT)</strong></td>
<td width="20%"><strong> Action </strong></td>
</tr>
<?
if($num_invoice > 0){
while($invoice = mysql_fetch_assoc($result_invoice)){
?>
<tr valign="top" class="tblinfo">
<td><?=$invoice['invno'];?></td>
<td><?=$invoice['name'];?></td>
<td><? if($td > $invoice['duedate']){
echo "<font color=\"#FF0000\">Overdue</font>";
$email="yes";
}else{
echo $invoice['status'];}
?></td>
<td><?=$invoice['idate'];?></td>
<? $query_invdetails = "SELECT * FROM clientinv WHERE
finv='".$invoice['invno']."'";
if(!$result_invdetails= mysql_query($query_invdetails)){
echo mysql_error();
}else{
$num_invdetails = mysql_num_rows($result_invdetails);
$invdetails=mysql_fetch_assoc($result_invdetails);}
?>
<td>£<?=$invdetails['totxVAT'];?></td>
<td>£<?=$invdetails['totwVAT'];?></td>
<td><a href="invView.php?iid=<?=$invoice['invno']?>">View </a> |<a
href="delinvoice.php?iid=<?=$invoice['invno']?>">Delete</a> <a href="edInv.php?
iid=<?=$invoice['invno']?>">Update</a> <? if($td > $invoice['duedate']){
echo "<img src=\"images/RedFlag.gif\" height = \"10\"/>";
}
?>
<? if(isset($email)){?>
<a href="emailInv.php?iid=<?=$invoice['invno']?>">Email
Reminder</a>
<? }?>
<a href="pdf.php?cid=<?=$invoice['cid']?>"><img
src="images/pdf.gif" width="18" height="18" border="0"/></a></td>
</tr>
<? }
}else{ ?>
<tr>
<td colspan="7"><p>No invoices available at present.</p></td>
</tr>
<? }?>
</table>
So, what is happening here? Basically, we are creating a table that will list all the invoices based on the results from the query. In other words, part of the table will be dynamically generated. The first section of the table shows the headings of the different columns. The columns that we want listed are:
- Invoice number.
- Client name.
- Status – Shows if a invoice is paid or unpaid.
- Date issued.
- Total (excluding VAT).
- Total (including VAT) .
- Action - Actions that can be taken, which include viewing, updating or deleting a invoice.
The headings are created by the following HTML code:
<tr valign="top" class="tblheadings">
<td width="9%"><strong>Invoice # </strong></td>
<td width="14%"><strong>Client Name </strong></td>
<td width="8%"><strong>Status</strong></td>
<td width="11%"><strong>Date Issued </strong></td>
<td width="11%"><strong>Total(excl VAT)</strong></td>
<td width="13%"><strong>Total(incl VAT)</strong></td>
<td width="20%"><strong> Action </strong></td>
</tr>