  <br>
  <table border=1 cellspacing=1 cellpadding=2 width=760 style="border: 1px inset;">
  <form action="controllers/inputController.php" method="post" name="invoiceform" id="invoiceform">
  <input name="invoice_pkey" id="invoice_pkey" type="hidden" value="<?=$invoice_data['invoice_pkey'];?>">
  <input name="invoice_projectpkey" id="invoice_projectpkey" type="hidden" value="<?=$invoice_data['invoice_projectpkey'];?>">
  <input name="invoice_popkeylist" id="invoice_popkeylist" type="hidden" value="<?=$invoice_data['invoice_popkeylist'];?>">
  <input name="invoice_dopkeylist" id="invoice_dopkeylist" type="hidden" value="<?=$invoice_data['invoice_dopkeylist'];?>">
  <tr valign=top>
  <td valign=top width=150 class=formlabel>Invoice No *</td>
  <td valign=top width=610 class=formvalue>
  <input name="invoice_no" id="invoice_no" type="text" value="<?=$invoice_data['invoice_no'];?>" maxlength=40 style="width: 180px;">
  </td>
  </tr>
  <tr valign=top>
  <td valign=top width=150 class=formlabel>S/O No</td>
  <td valign=top width=610 class=formvalue>
  <input name="invoice_sono" id="invoice_sono" type="text" value="<?=$invoice_data['invoice_sono'];?>" maxlength=40 style="width: 180px;">
  </td>
  </tr>
  <tr valign=top>
  <td valign=top width=150 class=formlabel>Invoice Date *</td>
  <td valign=top width=610 class=formvalue>
  <input name="invoice_date" id="invoice_date" type="text" value="<?=unconverttounixslash($invoice_data['invoice_date']);?>" maxlength=10 style="width: 90px;" onKeypress="dateOnly();">&nbsp;&nbsp;<i>(dd/mm/yyyy)</i>
  </td>
  </tr>
  <tr valign=top>
  <td valign=top width=150 class=formlabel>Terms</td>
  <td valign=top width=610 class=formvalue>
  <input name="invoice_terms" id="invoice_terms" type="text" value="<?=$invoice_data['invoice_terms'];?>" maxlength=3 style="width: 90px;" onKeypress="integerOnly();"> Days
  </td>
  </tr>
  <tr valign=top>
  <td valign=top width=150 class=formlabel>Salesman's Name</td>
  <td valign=top width=610 class=formvalue>
  <input name="invoice_salesman" id="invoice_salesman" type="text" value="<?=$invoice_data['invoice_salesman'];?>" maxlength=200 style="width: 360px;">
  </td>
  </tr>
  <tr valign=top>
  <td valign=top width=150 class=formlabel>Currency</td>
  <td valign=top width=610 class=formvalue>
  <input name="invoice_currency" id="invoice_currency" type="text" value="<?=$invoice_data['invoice_currency'];?>" maxlength=40 style="width: 360px;">
  </td>
  </tr>
  <tr valign=top>
  <td valign=top width=150 class=formlabel>Customer No</td>
  <td valign=top width=610 class=formvalue>
  <input name="invoice_customerno" id="invoice_customerno" type="text" value="<?=$invoice_data['invoice_customerno'];?>" maxlength=40 style="width: 360px;">
  </td>
  </tr>
  <input name="job" id="job" type="hidden" value="">
  </form>
  </table>

  <? if ($pubtask=="edit") { ?>

  <br>

  <table border=1 cellspacing=1 cellpadding=2 width=920 style="border: 1px inset;">
  <tr valign=top>
  <td valign=top width=40 class=listheader>Item</td>
  <td valign=top width=360 class=listheader>Description</td>
  <td valign=top width=100 class=listheader>Unit</td>
  <td valign=top width=100 class=listheader>Qty</td>
  <td valign=top width=100 class=listheader>Rate</td>
  <td valign=top width=140 class=listheader>Amount</td>
  <td valign=top width=80 class=listheader>Options</td>
  </tr>

  <? foreach($item_list as $myitem) { ?>

    <tr valign=top>
    <td valign=top width=40 class=listnumber><?=$myitem['item_no'];?>&nbsp;</td>
    <td valign=top width=360 class=listcontent><?=unescape($myitem['item_description']);?>&nbsp;</td>
    <td valign=top width=100 class=listcontent><?=$myitem['item_unit'];?>&nbsp;</td>
    <td valign=top width=100 class=listcontentnumeric><?=number_format($myitem['item_quantity'],4);?></td>
    <td valign=top width=100 class=listcontentnumeric><?=number_format($myitem['item_rate'],2);?></td>
    <td valign=top width=140 class=listcontentnumeric><?=number_format(($myitem['item_quantity']*$myitem['item_rate']),2);?>&nbsp;</td>
    <td valign=top width=80 class=listcontent>
    <? if ($myitem['item_status']==4) { ?>
      <i>Cancelled</i>
    <? } else { ?>
      <a href="index.php?module=invoice&task=viewitem&invoiceid=<?=$invoice_data['invoice_pkey'];?>&itemid=<?=$myitem['item_pkey'];?>"><img src="gfx/options/b_view.png" border=0 alt="View"></a>
      <? if (($pubuseraccess['access_invoice_edit']==1)||($pubuserrole>=2)) { ?>
        <a href="index.php?module=invoice&task=edititem&invoiceid=<?=$invoice_data['invoice_pkey'];?>&itemid=<?=$myitem['item_pkey'];?>"><img src="gfx/options/b_edit.png" border=0 alt="Edit"></a>
        <a href="index.php?module=invoice&task=deleteitem&invoiceid<?=$invoice_data['invoice_pkey'];?>&itemid=<?=$myitem['item_pkey'];?>"><img src="gfx/options/b_drop.png" border=0 alt="Delete"></a>
      <? } ?>
    <? } ?>
    </td>
    </tr>

  <? } ?>

  </table>

  <button name="additem" id="additem" type="button" onClick="invoice_button_additem('<?=$invoice_data['invoice_pkey'];?>');">&nbsp;<img src="gfx/options/b_add.png" class="actionbutton">&nbsp;&nbsp;Add Item&nbsp;</button>

  <? } ?>

  <script type="text/javascript">

  function selectTrade() {
    window.open('views/ibox_selecttrade.php','selectwindow', 'menubar=0,toolbar=0,scrollbars=0,resizable=0,location=0,width=960,height=600');
    //location.href='index.php?module=crawler&task=spisearch';
  }

  function validateForm() {

    var isvalid=true;
    var errmsg="";
    var invoiceno=document.getElementById('invoice_no');
    var invoicedate=document.getElementById('invoice_date');

    if ((invoiceno.value=="")||(invoicedate.value=="")) {	//||(pono.value=="")) {
      errmsg='Invoice No and ate must be specified!\n';
      isvalid=false;
    }
    if (isvalid==false) alert('Error:\n'+errmsg);
    return isvalid;

  }

  </script>
