Location: PHPKode > projects > Computer Service Company Database > SOLOCMS/dogbert/invoice.php
<? include ('db.php'); ?>
<? include ('header.php'); ?>

<!-- ####################################### -->
<?php 



	 
// grabs the list of clients for the drop down box where you select which client to attach the invoice to

	 $sql = "SELECT id, firstname, lastname FROM results ORDER BY lastname ASC";
     $res_cat = mysql_query($sql); // handle to category set

//if delete is clicked

if(isset($_GET['del'])) {
		
		echo "<center>Are you sure you want to delete that entry ? 
		<BR>
		<a href=\"invoice.php?delete=yes&del=" . $_GET['del'] . "\">Yes</a><BR>
		<a href=\"invoice.php?delete=no\">No</a>
		</center>";
		
		if ($delete == "yes"){
		mysql_query("DELETE FROM invoice WHERE id = '" . $_GET['del'] . "'");
		echo "<meta HTTP-EQUIV=refresh content=0;url=invoice.php?view=list>";
		}
		elseif ($delete == "no") {echo "<meta HTTP-EQUIV=refresh content=0;url=invoice.php?view=list>";}
	}?>
<?

 //create a new invoice in this part      

    if (($_GET['action'] == "new") || ($_POST['action'] == "new"))

    { 
?> 

<form action="invoice.php" method="post" name="newinvoice"> <input type="hidden" name="action" value="new">
<? // form is not submitted grab the info for the choose invoice dropdownbox.  Need to change this to a search feature but it works for now
    if (empty($_POST)) {  
?>
<table width="400" border="0" align="center">
  <tr>
    <td><p align="center" class="invoice"> Choose Client to Create Invoice For<br>
<form action="invoice.php?action=new" method="POST">
	 <select name="clientid">
	 <option value="">-</option>
     <?php while ($row = mysql_fetch_assoc($res_cat)) { ?>         
     <option value="<?php echo $row['id']; ?>"><?php echo $row['lastname']; ?> - <?php echo $row['firstname']; ?></option>		  
     <?php } ?>
     </select>
            <input type="submit" name="clientbut" value="Create Invoice">
</form>
</p></td>
  </tr>
</table>

<? } 
else {
?>
<p align="center" class="invoice">Create Invoice For: <?php $result4 = mysql_query("SELECT * FROM results WHERE id = $clientid");

        $row4 = mysql_fetch_assoc($result4); 
echo "$row4[lastname]  $row4[firstname] $row4[company]"; ?></p>
<p align="center" class="invoice">Date: 
  <SCRIPT LANGUAGE="JavaScript" ID="js1">
var cal1 = new CalendarPopup();
</SCRIPT>
<INPUT TYPE="text" NAME="date1" VALUE="" SIZE=25>
<A HREF="#" onClick="cal1.select(document.forms[0].date1,'anchor1','yyyy-MM-dd'); return false;" TITLE="cal1.select(document.forms[0].date1,'anchor1','yyyy-MM-dd'); return false;" NAME="anchor1" ID="anchor1">Select</A>

</p>
<p align="center" class="invoice">Labor:</p>
    <table border="0" align="center" cellpadding="0" cellspacing="2" class="invoice"> 
         <tr> 

          <td width="75">Client Id:</td> 

          <td width="360"><input type="text" name="clientid" size="5" maxlength="10" value="<? echo "$clientid" ?>"> 

         </td> 

         </tr> 
         <tr> 

          <td width="75">Flat Rate:</td> 

          <td width="360"><input type="text" name="flatrate" size="5" maxlength="10"> 

         </td> 

         </tr> 
    
         <tr> 

          <td width="75">Rate:</td> 

          <td width="360"><input type="text" name="rate" size="5" maxlength="10" value="<?php echo $row4['standard_rate']; ?>" > 

         </td> 

         </tr> 
         <tr> 

          <td width="75" bgcolor="#CCCCCC">Hours:</td> 

          <td width="360" bgcolor="#CCCCCC"><input type="text" name="hours" size="5" maxlength="10"> 

         </td> 

         </tr> 
         <tr> 

          <td width="75" bgcolor="#CCCCCC">Discount:</td> 

          <td width="360" bgcolor="#CCCCCC"><input type="text" name="discount" size="5" maxlength="10"> 

         </td> 

         </tr> 
		              <tr valign="top"> 

          <td width="75">Comments:</td> 

          <td width="360"><textarea name="comment" rows="5" cols="90"></textarea>
          <a href="javascript:x();" onmousedown="putit('&lt;b&gt;', 'comment', 'newinvoice', '&lt;/b&gt;');">Bold</a>
	<br>
	<a href="javascript:x();" onmousedown="putit('&lt;br&gt;', 'comment', 'newinvoice', '&nbsp');">New Line</a>
<br>
	<a href="javascript:x();" onmousedown="putit('&lt;ul&gt;&lt;li&gt;&lt;/li&gt;', 'comment', 'newinvoice', '&lt;li&gt;&lt;/li&gt;&lt;li&gt;&lt;/li&gt;&lt;/ul&gt;');">List</a></td> 

          
         </tr> 
  </table>
<p align="center" class="invoice">Hardware:</p>
  <table width="750" border="0" align="center" class="invoice">
    <tr>
      <td width="75">QTY</td>
      <td>Description</td>
      <td width="149">Unit Cost </td>
      <td width="149">Our Cost </td>
    </tr>
    <tr>
      <td><input type="text" name="qty1" size="5" maxlength="10"> </td>
      <td><input type="text" name="hwtext1" size="80" maxlength="500"> </td>
      <td><input type="text" name="unitcost1" size="6" maxlength="20"> </td>
      <td><input type="text" name="solocost1" size="6" maxlength="20"> </td>
    </tr>
    <tr>
      <td><input type="text" name="qty2" size="5" maxlength="10"> </td>
      <td><input type="text" name="hwtext2" size="80" maxlength="500"> </td>
      <td><input type="text" name="unitcost2" size="6" maxlength="20"> </td>
      <td><input type="text" name="solocost2" size="6" maxlength="20"> </td>
    </tr>
    <tr>
      <td><input type="text" name="qty3" size="5" maxlength="10"> </td>
      <td><input type="text" name="hwtext3" size="80" maxlength="500"> </td>
      <td><input type="text" name="unitcost3" size="6" maxlength="20"> </td>
      <td><input type="text" name="solocost3" size="6" maxlength="20"> </td>
    </tr>
    <tr>
      <td><input type="text" name="qty4" size="5" maxlength="10"> </td>
      <td><input type="text" name="hwtext4" size="80" maxlength="500"> </td>
      <td><input type="text" name="unitcost4" size="6" maxlength="20"> </td>
      <td><input type="text" name="solocost4" size="6" maxlength="20"> </td>
    </tr>
    <tr>
      <td><input type="text" name="qty5" size="5" maxlength="10"> </td>
      <td><input type="text" name="hwtext5" size="80" maxlength="500"> </td>
      <td><input type="text" name="unitcost5" size="6" maxlength="20"> </td>
      <td><input type="text" name="solocost5" size="6" maxlength="20"> </td>
    </tr>
    <tr>
      <td><input type="text" name="qty6" size="5" maxlength="10"> </td>
      <td><input type="text" name="hwtext6" size="80" maxlength="500"> </td>
      <td><input type="text" name="unitcost6" size="6" maxlength="20"> </td>
      <td><input type="text" name="solocost6" size="6" maxlength="20"> </td>
    </tr>

  </table>

  <p align="center">Deposit: <input type="text" name="deposit" size="5" maxlength="10"></p>
  <p align="center"> <input type="submit" name="submit" value="Create Invoice"></p>

</form> 

<?php

//if new invoice form is submitted do this stuff:

        if (isset($_POST['submit'])) 

        { 
			echo "<meta HTTP-EQUIV=refresh content=0;url=invoice.php?view=list>";
//Grab the submitted data			
			$clientid = ($_POST['clientid']) ;
		
			$deposit = ($_POST['deposit']) ;

            $discount = ($_POST['discount']) / 100;

            $rate = ($_POST['rate']);
            
			$flatrate = ($_POST['flatrate']);
            
			$date = ($_POST['date1']);

            $hours = ($_POST['hours']);
			
            $qty1 = ($_POST['qty1']);

            $qty2 = ($_POST['qty2']);
            
			$qty3 = ($_POST['qty3']);

            $qty4 = ($_POST['qty4']);
            
			$qty5 = ($_POST['qty5']);

            $qty6 = ($_POST['qty6']);
               
            $hwtext1 = ($_POST['hwtext1']);

            $hwtext2 = ($_POST['hwtext2']);
            
			$hwtext3 = ($_POST['hwtext3']);

            $hwtext4 = ($_POST['hwtext4']);
            
			$hwtext5 = ($_POST['hwtext5']);

            $hwtext6 = ($_POST['hwtext6']);

            $solocost1 = ($_POST['solocost1']);

            $solocost2 = ($_POST['solocost2']);
            
			$solocost3 = ($_POST['solocost3']);

            $solocost4 = ($_POST['solocost4']);
            
			$solocost5 = ($_POST['solocost5']);

            $solocost6 = ($_POST['solocost6']);

            $unitcost1 = ($_POST['unitcost1']);

            $unitcost2 = ($_POST['unitcost2']);
            
			$unitcost3 = ($_POST['unitcost3']);

            $unitcost4 = ($_POST['unitcost4']);
            
			$unitcost5 = ($_POST['unitcost5']);

            $unitcost6 = ($_POST['unitcost6']);

            $comment = ($_POST['comment']);

            $tax = ($HWtaxrate + 1);
			
			$hwsubtotal = (($qty1 * $unitcost1) + ($qty2 * $unitcost2) + ($qty3 * $unitcost3) + ($qty4 * $unitcost4) + ($qty5 * $unitcost5) + ($qty6 * $unitcost6));
			
			$discounttotal = ($flatrate + ($rate * $hours)) * $discount;
			$total = ((($flatrate + ($rate * $hours)) - $discounttotal) + ($hwsubtotal * $tax));
				
// Insert the submitted data to the database           
			mysql_query("INSERT INTO invoice (discount, clientid, deposit, flatrate, rate, qty1, qty2, qty3, qty4, qty5, qty6, solocost1, solocost2, solocost3, solocost4, solocost5, solocost6, hwtext1, hwtext2, hwtext3, hwtext4, hwtext5, hwtext6, unitcost1, unitcost2, unitcost3, unitcost4, unitcost5, unitcost6, hours, comment, tax, total, date) VALUES ('$discount','$clientid', '$deposit', '$flatrate', '$rate', '$qty1', '$qty2', '$qty3', '$qty4','$qty5', '$qty6', '$solocost1', '$solocost2', '$solocost3', '$solocost4','$solocost5', '$solocost6','$hwtext1', '$hwtext2', '$hwtext3', '$hwtext4','$hwtext5', '$hwtext6','$unitcost1', '$unitcost2', '$unitcost3', '$unitcost4','$unitcost5', '$unitcost6','$hours', '$comment', '$tax', '$total', '$date')");        
	
		
        } 



    } }

// List Invoices
elseif ($_GET['view'] == "list") 

    { ?><IFRAME onload="resizeMe(this)" id="main" scrolling=no height="50px" name="main" src="unpaidinvoices.php" frameborder="0" width="100%"></IFRAME>
<?
//set Invoice List sorting order ASC and DESC by ivoice id, date, clientid, and total price
if (!$direction = $_GET['direction'])  $direction = 'desc';

if (!isset($_GET['sort']) || !in_array($_GET['sort'], array('clientid', 'id', 'date', 'total'))) {
// set default sorting order
    $sort = 'date';
} else {
    $sort = $_GET['sort'];
}

if ($direction == 'asc')  $click_sort_direction = 'desc';
else $click_sort_direction = 'asc';

//Display Current Invoices
        echo "

        <p align=\"center\"><b>All Invoices</b></p><p>

        <table align=\"center\" border=\"1\" cellpadding=\"0\" cellspacing=\"3\">
                         <tr>"; ?>
						 
						 
<td><a href="<?=$_SERVER['PHP_SELF']?>?view=list&sort=clientid&direction=<?=$click_sort_direction?>"><b>Client Id</b></a></td>
<td><a href="<?=$_SERVER['PHP_SELF']?>?view=list&sort=id&direction=<?=$click_sort_direction?>"><b>Invoice</b></a></td>
<td><a href="<?=$_SERVER['PHP_SELF']?>?view=list&sort=date&direction=<?=$click_sort_direction?>"><b>Date</b></a></td>			
<td><a href="<?=$_SERVER['PHP_SELF']?>?view=list&sort=total&direction=<?=$click_sort_direction?>"><b>Total</b></a></td>			
<td><b>Print</b></td>
<td><b>Edit</b></td>			
<td>&nbsp;</td>			
			
	</tr>

<?
$result = mysql_query("SELECT * FROM invoice ORDER BY $sort $direction");



        while ($row = mysql_fetch_assoc($result)) 

        { 


        $result4 = mysql_query("SELECT * FROM results WHERE id = $row[clientid]");

        $row4 = mysql_fetch_assoc($result4); 
//checks whether the invoice has been paid.  If it has then it shows up in white if not background is red
if ($row['paid'] == "0")
{

            echo "

			<tr> 
            <td height=\"12px\" bgcolor=\"#F2B7A6\"><a href=\"client-edit.php?edit={$row['clientid']}\" target=\"_parent\">  {$row['clientid']} - {$row4['firstname']} {$row4['lastname']}</a></td>
            <td height=\"12px\" bgcolor=\"#F2B7A6\">{$row['id']}</td> "; ?>
			<td height="12px" bgcolor="#F2B7A6"><?php echo date('l, jS F Y',strtotime($row['date'])); ?></td>
			<? echo 
			
			"<td height=\"12px\" bgcolor=\"#F2B7A6\">{$row['total']}</td>
			<td height=\"12px\" bgcolor=\"#F2B7A6\"><form action=\"printinvoice.php\" method=\"POST\" target=\"_blank\"><input type=\"hidden\" name=\"invoice\" value =\"{$row['id']}\"><input type=\"submit\" name=\"submit\" value=\"Print Invoice\"></form></td>
            <td height=\"12px\" bgcolor=\"#F2B7A6\"><a href=\"invoice.php?edit={$row['id']}\"> Edit Invoice </a></td>
            <td height=\"12px\" bgcolor=\"#F2B7A6\"><a href=\"invoice.php?markpaid={$row['id']}\"> Mark Paid </a></td>

            </tr> 

";


 }// dont delete
else {echo "

			<tr> 
            <td height=\"12px\" ><a href=\"client-edit.php?edit={$row['clientid']}\" target=\"_parent\">  {$row['clientid']} - {$row4['firstname']} {$row4['lastname']}</a></td>
            <td height=\"12px\" >{$row['id']}</td> "; ?>
			<td height="12px" ><?php echo date('l, jS F Y',strtotime($row['date'])); ?></td>
			<? echo 
			
			"<td height=\"12px\" >{$row['total']}</td>
			<td height=\"12px\" ><form action=\"printinvoice.php\" method=\"POST\"><input type=\"hidden\" name=\"invoice\" value =\"{$row['id']}\"><input type=\"submit\" name=\"submit\" value=\"Print Invoice\"></form></td>
            <td height=\"12px\" ><a href=\"invoice.php?edit={$row['id']}\"> Edit Invoice </a></td>
            <td height=\"12px\" >&nbsp;</td>

            </tr> ";

       } } 



        echo "</table>"; 

    } 

if (isset($_GET['markpaid']))
{
mysql_query("UPDATE invoice SET paid = '1' WHERE id = $_GET[markpaid]")or die("Your Error " . mysql_error());;
echo "<meta HTTP-EQUIV=refresh content=0;url=invoice.php?view=list>";

}

//Edit Invoice

    elseif (isset($_GET['edit'])) 

    { 


//when edited info is subbmitted do this
        if (isset($_POST['submit'])) 

        { 
//Grab Submitted data
            $clientid = ($_POST['clientid']);

            $rate = ($_POST['rate']);

            $deposit = ($_POST['deposit']);
            
			$flatrate = ($_POST['flatrate']);

            $hours = ($_POST['hours']);
			
            $qty1 = ($_POST['qty1']);

            $qty2 = ($_POST['qty2']);
            
			$qty3 = ($_POST['qty3']);

            $qty4 = ($_POST['qty4']);
            
			$qty5 = ($_POST['qty5']);

            $qty6 = ($_POST['qty6']);
               
            $solocost1 = ($_POST['solocost1']);

            $solocost2 = ($_POST['solocost2']);
            
			$solocost3 = ($_POST['solocost3']);

            $solocost4 = ($_POST['solocost4']);
            
			$solocost5 = ($_POST['solocost5']);

            $solocost6 = ($_POST['solocost6']);

            $hwtext1 = ($_POST['hwtext1']);

            $hwtext2 = ($_POST['hwtext2']);
            
			$hwtext3 = ($_POST['hwtext3']);

            $hwtext4 = ($_POST['hwtext4']);
            
			$hwtext5 = ($_POST['hwtext5']);

            $hwtext6 = ($_POST['hwtext6']);

            $unitcost1 = ($_POST['unitcost1']);

            $unitcost2 = ($_POST['unitcost2']);
            
			$unitcost3 = ($_POST['unitcost3']);

            $unitcost4 = ($_POST['unitcost4']);
            
			$unitcost5 = ($_POST['unitcost5']);

            $unitcost6 = ($_POST['unitcost6']);
            
			$paid = ($_POST['paid']);
			
            $discount = ($_POST['discount']) / 100;

            $comment = ($_POST['comment']);

            $tax = ($HWtaxrate + 1);
			
			$hwsubtotal = (($qty1 * $unitcost1) + ($qty2 * $unitcost2) + ($qty3 * $unitcost3) + ($qty4 * $unitcost4) + ($qty5 * $unitcost5) + ($qty6 * $unitcost6));
			
			$discounttotal = ($flatrate + ($rate * $hours)) * $discount;
			$total = ((($flatrate + ($rate * $hours)) - $discounttotal) + ($hwsubtotal * $tax));
				
//post to the Database      
            
			mysql_query("UPDATE invoice SET discount = '$discount', deposit = '$deposit', flatrate = '$flatrate', rate = '$rate', qty1 = '$qty1',  qty2 = '$qty2',qty3 = '$qty3',qty4 = '$qty4',qty5 = '$qty5',qty6 = '$qty6', solocost1 = '$solocost1',  solocost2 = '$solocost2',solocost3 = '$solocost3',solocost4 = '$solocost4',solocost5 = '$solocost5',solocost6 = '$solocost6', hwtext1 = '$hwtext1', hwtext2 = '$hwtext2', hwtext3 = '$hwtext3', hwtext4 = '$hwtext4', hwtext5 = '$hwtext5', hwtext6 = '$hwtext6', unitcost1 = '$unitcost1', unitcost2 = '$unitcost2', unitcost3 = '$unitcost3', unitcost4 = '$unitcost4', unitcost5 = '$unitcost5', unitcost6 = '$unitcost6', hours = '$hours', comment = '$comment', tax = $tax, paid = $paid, total = $total WHERE id = $_GET[edit] ");



            echo "<meta HTTP-EQUIV=refresh content=0;url=invoice.php?view=list>"; 

        } 

	 $sql = "SELECT id, lastname, firstname FROM results ORDER BY lastname DESC";
     $res_cat = mysql_query($sql); // handle to category set


        $result = mysql_query("SELECT * FROM invoice WHERE id = $_GET[edit]");

        $row = mysql_fetch_assoc($result); 
		$discountpercent = ($row['discount'] * 100);
// display invoice to be edited
        echo "

        <form action=\"invoice.php?edit=$_GET[edit]\" method=\"post\" name=\"editinvoice\">

        <p align=\"center\"><b>Edit Submission</b> </p>


        <table align=\"center\" border=\"0\" cellpadding=\"0\" cellspacing=\"2\"> 

         <tr> 

          <td width=\"100\">Client Id:</td> 

          <td width=\"360\">{$row['clientid']}
         </td> 

         </tr> 
         <tr> 

          <td width=\"100\">Flat Rate:</td> 

          <td width=\"360\"><input type=\"text\" name=\"flatrate\" size=\"60\" maxlength=\"100\" value=\"{$row['flatrate']}\"> 

         </td> 

         </tr> 

         <tr> 

          <td width=\"100\">Rate:</td> 

          <td width=\"360\"><input type=\"text\" name=\"rate\" size=\"60\" maxlength=\"100\" value=\"{$row['rate']}\"> 

         </td> 

         </tr> 

         <tr> 


          <td width=\"100\">Hours:</td> 

          <td width=\"360\"><input type=\"text\" name=\"hours\" size=\"60\" maxlength=\"100\" value=\"{$row['hours']}\"> 

         </td> 

         </tr> 
         <tr> 


          <td width=\"100\">Discount:</td> 

          <td width=\"360\"><input type=\"text\" name=\"discount\" size=\"60\" maxlength=\"100\" value=\"$discountpercent\"> 

         </td> 

         </tr> 
             <tr valign=top> 

          <td width=\"100\">Comments:<br><a href=\"javascript:x();\" onmousedown=\"putit('&lt;b&gt;', 'comment', 'editinvoice', '&lt;/b&gt;');\">Bold</a>
	<br>
	<a href=\"javascript:x();\" onmousedown=\"putit('&lt;br&gt;', 'comment', 'editinvoice', '&nbsp');\">New Line</a>
<br>
	<a href=\"javascript:x();\" onmousedown=\"putit('&lt;ul&gt;&lt;li&gt;&lt;/li&gt;', 'comment', 'editinvoice', '&lt;li&gt;&lt;/li&gt;&lt;/ul&gt;');\">List</a></td> 

          <td width=\"360\"><textarea name=\"comment\" rows=\"5\" cols=\"90\">{$row['comment']}</textarea></td>

         </td> 

         </tr> 

</table>
<table align=\"center\" border=\"0\" cellpadding=\"0\" cellspacing=\"2\">
          <tr>
            <td width=\"100\">QTY</td>
            <td width=\"529\">Description</td>
            <td width=\"120\">Unit Cost </td>
            <td width=\"120\">SOLO Cost </td>
          </tr>
          <tr>
            <td><input type=\"text\" name=\"qty1\" size=\"5\" maxlength=\"10\"value=\"{$row['qty1']}\"> </td>
            <td><input type=\"text\" name=\"hwtext1\" size=\"100\" maxlength=\"500\"value=\"{$row['hwtext1']}\"> </td>
            <td><input type=\"text\" name=\"unitcost1\" size=\"6\" maxlength=\"20\"value=\"{$row['unitcost1']}\"> </td>
            <td><input type=\"text\" name=\"solocost1\" size=\"6\" maxlength=\"20\"value=\"{$row['solocost1']}\"> </td>
          </tr>
          <tr>
            <td><input type=\"text\" name=\"qty2\" size=\"5\" maxlength=\"10\"value=\"{$row['qty2']}\"> </td>
            <td><input type=\"text\" name=\"hwtext2\" size=\"100\" maxlength=\"500\"value=\"{$row['hwtext2']}\"> </td>
            <td><input type=\"text\" name=\"unitcost2\" size=\"6\" maxlength=\"20\"value=\"{$row['unitcost2']}\"> </td>
             <td><input type=\"text\" name=\"solocost2\" size=\"6\" maxlength=\"20\"value=\"{$row['solocost2']}\"> </td>
         </tr>
		            <tr>
            <td><input type=\"text\" name=\"qty3\" size=\"5\" maxlength=\"10\"value=\"{$row['qty3']}\"> </td>
            <td><input type=\"text\" name=\"hwtext3\" size=\"100\" maxlength=\"500\"value=\"{$row['hwtext3']}\"> </td>
            <td><input type=\"text\" name=\"unitcost3\" size=\"6\" maxlength=\"20\"value=\"{$row['unitcost3']}\"> </td>
            <td><input type=\"text\" name=\"solocost3\" size=\"6\" maxlength=\"20\"value=\"{$row['solocost3']}\"> </td>
          </tr>
          <tr>
            <td><input type=\"text\" name=\"qty4\" size=\"5\" maxlength=\"10\"value=\"{$row['qty4']}\"> </td>
            <td><input type=\"text\" name=\"hwtext4\" size=\"100\" maxlength=\"500\"value=\"{$row['hwtext4']}\"> </td>
            <td><input type=\"text\" name=\"unitcost4\" size=\"6\" maxlength=\"20\"value=\"{$row['unitcost4']}\"> </td>
            <td><input type=\"text\" name=\"solocost4\" size=\"6\" maxlength=\"20\"value=\"{$row['solocost4']}\"> </td>
          </tr>
          <tr>
            <td><input type=\"text\" name=\"qty5\" size=\"5\" maxlength=\"10\"value=\"{$row['qty5']}\"> </td>
            <td><input type=\"text\" name=\"hwtext5\" size=\"100\" maxlength=\"500\"value=\"{$row['hwtext5']}\"> </td>
            <td><input type=\"text\" name=\"unitcost5\" size=\"6\" maxlength=\"20\"value=\"{$row['unitcost5']}\"> </td>
            <td><input type=\"text\" name=\"solocost5\" size=\"6\" maxlength=\"20\"value=\"{$row['solocost5']}\"> </td>
          </tr>
          <tr>
            <td><input type=\"text\" name=\"qty6\" size=\"5\" maxlength=\"10\"value=\"{$row['qty6']}\"> </td>
            <td><input type=\"text\" name=\"hwtext6\" size=\"100\" maxlength=\"500\"value=\"{$row['hwtext6']}\"> </td>
            <td><input type=\"text\" name=\"unitcost6\" size=\"6\" maxlength=\"20\"value=\"{$row['unitcost6']}\"> </td>
            <td><input type=\"text\" name=\"solocost6\" size=\"6\" maxlength=\"20\"value=\"{$row['solocost6']}\"> </td>
          </tr>
		           <tr> 


          <td width=\"100\">Deposit:</td> 

          <td width=\"360\"><input type=\"text\" name=\"deposit\" size=\"10\" maxlength=\"15\" value=\"{$row['deposit']}\"> 

         </td> 

         </tr> 

</table>
<table align=\"center\" border=\"0\" cellpadding=\"0\" cellspacing=\"2\">
             <tr valign=top> 

          <td width=\"100\">Total:</td> 

          <td width=\"360\">{$row['total']} - If you changed the values above this will change on submit</td>

         </td> 

         </tr> 
             <tr valign=top> 

          <td width=\"100\"><br>Paid:</td> ";
// Check whether invoice has been paid then sets the radio button to that value by default.  that way you dont accidentally forget whether it was paid or not.
		  
		  if ($row[paid] == "0") {
echo "
          <td width=\"360\"><br>
		  <input name=\"paid\" type=\"radio\" value=\"1\"> YES
		  <br>
		  <input name=\"paid\" type=\"radio\" value=\"0\" checked> NO</td>

         </td> 

         </tr> ";
}
else {echo " <td width=\"360\"><br>
		  <input name=\"paid\" type=\"radio\" value=\"1\"checked> YES
		  <br>
		  <input name=\"paid\" type=\"radio\" value=\"0\"> NO</td>

         </td> 

         </tr>

";
}

echo "        </table> 
<p align=\"center\"><input type=\"submit\" name=\"submit\" value=\"EDIT INVOICE\">
<a href=\"invoice.php?del={$row[id]}\"> Delete </a>
          </p>

        </form>";


    } 







?>
<? include ('navigation.php'); ?>
<? include ('footer.php'); ?>
Return current item: Computer Service Company Database