  <script type="text/javascript" src="calendar1.js"></script>
  <br>
  <table border=1 cellspacing=1 cellpadding=2 width=760 style="border: 1px inset;">
  <form action="controllers/inputController.php" method="post" name="poform" id="poform">
  <input name="po_pkey" id="po_pkey" type="hidden" value="<?=$po_data['po_pkey'];?>">
  <input name="po_projectpkey" id="po_projectpkey" type="hidden" value="<?=$mro_data['mro_projectpkey'];?>">
  <input name="po_mropkey" id="po_mropkey" type="hidden" value="<?=$mro_data['mro_pkey'];?>">
  <input name="po_itqpkey" id="po_itqpkey" type="hidden" value="<?=$itq_data['itq_pkey'];?>">
  <input name="po_literaltotal" id="po_literaltotal" type="hidden" value="">
  <tr valign=top>
  <td valign=top width=150 class=formlabel>Supplier *</td>
  <td valign=top width=610 class=formvalue>
  <select name="po_supplierpkey" id="po_supplierpkey" style="width: 360px;">
  <? $objsupplierpkey=$po_data['po_supplierpkey']; ?>
  <? $objitqpkey=$itq_data['itq_pkey']; ?>
  <? include_once('views/object-selectsupplier-byitq.tpl'); ?>
  </select>
  </td>
  </tr>
  <tr valign=top>
  <td valign=top width=150 class=formlabel>Attn</td>
  <td valign=top width=610 class=formvalue>
  <input name="po_attn" id="po_attn" type="text" value="<?=$po_data['po_attn'];?>" maxlength=200 style="width: 360px;">
  </td>
  </tr>
  <tr valign=top>
  <td valign=top width=150 class=formlabel>PO No</td>
  <td valign=top width=610 class=formvalue>
  <input name="po_no" id="po_no" type="text" value="<? if (($po_data['po_no']=="")||($po_data['po_no']=="0")) { echo "[Auto]"; } else { echo poidstr($po_data['po_no'],$po_data['po_revno']); } ?>" readonly maxlength=8 style="width: 90px;" onKeypress="integerOnly();">
  </td>
  </tr>
  <tr valign=top>
  <td valign=top width=150 class=formlabel>PO Date *</td>
  <td valign=top width=610 class=formvalue>
  <input name="po_date" id="po_date" type="text" value="<?=unconverttounixslash($po_data['po_date']);?>" maxlength=10 style="width: 90px;" onKeypress="dateOnly();">
  <a href="javascript:cal1.popup();"><img src="images/icon/cal.gif" width="16" height="16" border="0" alt="Click to select date"></a>&nbsp;&nbsp;<i>(dd/mm/yyyy)</i>
  </td>
  </tr>
  <tr valign=top>
  <td valign=top width=150 class=formlabel>Credit Terms</td>
  <td valign=top width=610 class=formvalue>
  <input name="po_top" id="po_top" type="text" value="<?=$po_data['po_top'];?>" maxlength=3 style="width: 90px;" onKeypress="integerOnly();"> Days
  </td>
  </tr>
  <!--
  <tr valign=top>
  <td valign=top width=150 class=formlabel>Literal Total</td>
  <td valign=top width=610 class=formvalue>
  <input name="po_literaltotal" id="po_literaltotal" type="text" value="<?=$po_data['po_literaltotal'];?>" style="width: 360px;">
  </td>
  </tr>
  -->
  <tr valign=top>
  <td valign=top width=150 class=formlabel>C/O</td>
  <td valign=top width=610 class=formvalue>
  <input name="po_co" id="po_co" type="text" value="<?=$po_data['po_co'];?>" style="width: 360px;">
  </td>
  </tr>
  <tr valign=top>
  <td valign=top width=150 class=formlabel>Project Personnel</td>
  <td valign=top width=610 class=formvalue>
  <select name="po_personnelpkey" id="po_personnelpkey" style="width: 360px;">
  <? $objpersonnelpkey=$po_data['po_personnelpkey']; ?>
  <? include_once('views/object-selectpersonnel.tpl'); ?>
  </select>
  </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=po&task=viewitem&poid=<?=$po_data['po_pkey'];?>&itemid=<?=$myitem['item_pkey'];?>"><img src="gfx/options/b_view.png" border=0 alt="View"></a>
      <? if (($pubuseraccess['access_po_edit']==1)||($pubuserrole>=2)) { ?>
        <a href="index.php?module=po&task=edititem&poid=<?=$po_data['po_pkey'];?>&itemid=<?=$myitem['item_pkey'];?>"><img src="gfx/options/b_edit.png" border=0 alt="Edit"></a>
        <a href="index.php?module=po&task=deleteitem&poid<?=$po_data['po_pkey'];?>&itemid=<?=$myitem['item_pkey'];?>"><img src="gfx/options/b_drop.png" border=0 alt="Delete"></a>
      <? } ?>
    <? } ?>
    </td>
    </tr>

  <? } ?>

  </table>

  <!-- at this point, PO is already approved and finalised so don't allow adding of items! -->
  <!--<button name="additem" id="additem" type="button" onClick="po_button_additem('<?=$po_data['po_pkey'];?>');">&nbsp;<img src="gfx/options/b_add.png" class="actionbutton">&nbsp;&nbsp;Add Item&nbsp;</button>-->

  <? } ?>

  <script language="javascript">
    var cal1 = new calendar1(document.forms['poform'].elements['po_date']);
    cal1.year_scroll = true;
    cal1.time_comp = false;
  </script>

  <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 posupplier=document.getElementById('po_supplierpkey');
    //var pono=document.getElementById('po_no');
    var podate=document.getElementById('po_date');

    if ((posupplier.value=="")||(podate.value=="")) {	//||(pono.value=="")) {
      errmsg='Supplier, PO No, and PO Date must be specified!\n';
      isvalid=false;
    }
    if (isvalid==false) alert('Error:\n'+errmsg);
    return isvalid;

  }

  function selectSubcons() {

    var poda=document.getElementById('po_debitaccount');
    if (poda.value=="remarks") {
      window.open('views/ibox_selectsubcons.php','selectwindow', 'menubar=0,toolbar=0,scrollbars=1,resizable=0,location=0,width=960,height=600');
    }

  }

  function selectSubcons2(subcons) {

    window.open('views/ibox_selectsubcons.php?subcons='+subcons,'selectwindow', 'menubar=0,toolbar=0,scrollbars=1,resizable=0,location=0,width=600,height=600');
    // 960

  }

  </script>
