  <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="supplierform" id="supplierform">
  <input name="supplier_pkey" id="supplier_pkey" type="hidden" value="<?=$supplier_data['supplier_pkey'];?>">
  <input name="supplier_approved" id="supplier_approved" type="hidden" value="<?=$supplier_data['supplier_approved'];?>">
  <input name="supplier_status" id="supplier_status" type="hidden" value="<?=$supplier_data['supplier_status'];?>">
  <input name="supplier_pic" id="supplier_pic" type="hidden" value="<?=$supplier_data['supplier_pic'];?>">
  <input name="supplier_picphone" id="supplier_picphone" type="hidden" value="<?=$supplier_data['supplier_picphone'];?>">
  <tr valign=top>
  <td valign=top width=150 class=formlabel>Registration No</td>
  <td valign=top width=610 class=formvalue>
  <input name="supplier_regid" id="supplier_regid" type="text" value="<? if (($supplier_data['supplier_regid']=="")||($supplier_data['supplier_regid']=="0")) { echo "[Auto]"; } else { echo idstr($supplier_data['supplier_regid']); } ?>" <? if ($supplier_data['supplier_regid']=="") echo "readonly"; ?> maxlength=10 style="width: 180px;" onKeypress="integerOnly();">
  </td>
  </tr>
  <tr valign=top>
  <td valign=top width=150 class=formlabel>Registration Date</td>
  <td valign=top width=610 class=formvalue>
  <input name="supplier_regdate" id="supplier_regdate" type="text" value="<?=unconverttounixslash($supplier_data['supplier_regdate']);?>" 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>
  </td>
  </tr>
  <tr valign=top>
  <td valign=top width=150 class=formlabel>Company No</td>
  <td valign=top width=610 class=formvalue>
  <input name="supplier_regno" id="supplier_regno" type="text" value="<?=$supplier_data['supplier_regno'];?>" maxlength=20 style="width: 180px;">
  </td>
  </tr>
  <tr valign=top>
  <td valign=top width=150 class=formlabel>Supplier Name</td>
  <td valign=top width=610 class=formvalue>
  <input name="supplier_name" id="supplier_name" type="text" value="<?=$supplier_data['supplier_name'];?>" maxlength=200 style="width: 360px;">
  </td>
  </tr>
  <tr valign=top>
  <td valign=top width=150 class=formlabel>Address</td>
  <td valign=top width=610 class=formvalue>
  <textarea name="supplier_address" id="supplier_address" rows=5 cols=55><?=$supplier_data['supplier_address'];?></textarea>
  </td>
  </tr>
  <tr valign=top>
  <td valign=top width=150 class=formlabel>Phone No</td>
  <td valign=top width=610 class=formvalue>
  <input name="supplier_phone" id="supplier_phone" type="text" value="<?=$supplier_data['supplier_phone'];?>" maxlength=40 style="width: 180px;">
  </td>
  </tr>
  <tr valign=top>
  <td valign=top width=150 class=formlabel>Fax No</td>
  <td valign=top width=610 class=formvalue>
  <input name="supplier_fax" id="supplier_fax" type="text" value="<?=$supplier_data['supplier_fax'];?>" maxlength=40 style="width: 180px;">
  </td>
  </tr>
  <tr valign=top>
  <td valign=top width=150 class=formlabel>Email</td>
  <td valign=top width=610 class=formvalue>
  <input name="supplier_email" id="supplier_email" type="text" value="<?=$supplier_data['supplier_email'];?>" maxlength=200 style="width: 360px;">
  </td>
  </tr>
  <tr valign=top>
  <td valign=top width=150 class=formlabel>Company Director(s)</td>
  <td valign=top width=610 class=formvalue>
  <input name="supplier_directors" id="supplier_directors" type="text" value="<?=$supplier_data['supplier_directors'];?>" style="width: 360px;">
  </td>
  </tr>
  </table>

  <br>
  <table border=1 cellspacing=1 cellpadding=2 width=760 style="border: 1px inset;">
  <tr valign=top>
  <td valign=top width=150 class=formlabel>Credit Terms</td>
  <td valign=top width=610 class=formvalue>
  <input name="supplier_ct" id="supplier_ct" type="text" value="<?=$supplier_data['supplier_ct'];?>" maxlength=200 style="width: 360px;">
  </td>
  </tr>
  <tr valign=top>
  <td valign=top width=150 class=formlabel>Nature of Business</td>
  <td valign=top width=610 class=formvalue>
  <select name="supplier_nob" id="supplier_nob" style="width: 360px;">
  <option value="" selected>--Select Nature of Business--</option>
  <option value="MANUFACTURER" <? if (strtoupper($supplier_data['supplier_nob'])=="MANUFACTURER") echo "selected"; ?>>MANUFACTURER</option>
  <option value="TRADING" <? if (strtoupper($supplier_data['supplier_nob'])=="TRADING") echo "selected"; ?>>TRADING</option>
  <option value="OTHERS" <? if (strtoupper($supplier_data['supplier_nob'])=="OTHERS") echo "selected"; ?>>OTHERS</option>
  </select>
  <!--<input name="supplier_nob" id="supplier_nob" type="text" value="<?=$supplier_data['supplier_nob'];?>" maxlength=200 style="width: 360px;">-->
  </td>
  </tr>
  <tr valign=top>
  <td valign=top width=150 class=formlabel>Products</td>
  <td valign=top width=610 class=formvalue>
  <input name="supplier_products" id="supplier_products" type="text" value="<?=$supplier_data['supplier_products'];?>" maxlength=200 style="width: 360px;">
  </td>
  </tr>
  <tr valign=top>
  <td valign=top width=150 class=formlabel>Bank Guarantee Ratio</td>
  <td valign=top width=610 class=formvalue>
  1:<input name="supplier_bgratio" id="supplier_bgratio" type="text" value="<?=$supplier_data['supplier_bgratio'];?>" maxlength=4 style="width: 168px;" onkeypress="decimalOnly();">
  </td>
  </tr>
  <tr valign=top>
  <td valign=top width=150 class=formlabel>Personal Guarantee</td>
  <td valign=top width=610 class=formvalue>
  <input name="supplier_personalamount" id="supplier_personalamount" type="text" value="<?=number_format($supplier_data['supplier_personalamount'],2);?>" maxlength=21 style="width: 180px;" onkeypress="decimalOnly();">
  </td>
  </tr>
  </table>

  <br>
  <table border=1 cellspacing=1 cellpadding=2 width=760 style="border: 1px inset;">
  <tr valign=top>
  <td valign=top width=760 colspan=6 class=formvalue><b>Contact Information</b></td>
  </tr>
  <tr valign=top>
  <td valign=top width=240 class=formlabel>Name</td>
  <td valign=top width=180 class=formlabel>Designation</td>
  <td valign=top width=130 class=formlabel>Contact No</td>
  <td valign=top width=150 class=formlabel>Email</td>
  <td valign=top width=40 class=formlabel>Main</td>
  <td valign=top width=20 class=formlabel>&nbsp;</td>
  </tr>

  <? for ($i=0;$i<=2;$i++) { ?>

    <? $contact_data = $contact_list[$i]; ?>

    <tr valign=top>
    <input name="contact_pkey<?=$i;?>" id="contact_pkey<?=$i;?>" type="hidden" value="<?=$contact_data['contact_pkey'];?>">
    <input name="contact_supplierpkey<?=$i;?>" id="contact_supplierpkey<?=$i;?>" type="hidden" value="<?=$contact_data['contact_supplierpkey'];?>">
    <td valign=top width=240 class=formvalue><input name="contact_name<?=$i;?>" id="contact_name<?=$i;?>" type="text" value="<?=$contact_data['contact_name'];?>" maxlength=200 style="width: 230px;"></td>
    <td valign=top width=180 class=formvalue><input name="contact_designation<?=$i;?>" id="contact_designation<?=$i;?>" type="text" value="<?=$contact_data['contact_designation'];?>" maxlength=200 style="width: 170px;"></td>
    <td valign=top width=130 class=formvalue><input name="contact_phone<?=$i;?>" id="contact_phone<?=$i;?>" type="text" value="<?=$contact_data['contact_phone'];?>" maxlength=40 style="width: 120px;"></td>
    <td valign=top width=150 class=formvalue><input name="contact_email<?=$i;?>" id="contact_email<?=$i;?>" type="text" value="<?=$contact_data['contact_email'];?>" maxlength=200 style="width: 140px;"></td>
    <td valign=top width=40 class=formvalue style="text-align: center;"><input name="contact_main" id="contact_main<?=$i;?>" type="radio" value="<?=$i+1;?>" <? if ($contact_data['contact_main']==1) echo "checked"; ?>></td>
    <td valign=top width=20 class=formvalue><img src="gfx/options/b_drop.png" title="Remove" alt="Remove" style="cursor: pointer;" onClick="removeContact('<?=$i;?>');"></td>
    </tr>

  <? } ?>

  </table>

  <br>
  <table border=1 cellspacing=1 cellpadding=2 width=760 style="border: 1px inset;">
  <tr valign=top>
  <td valign=top width=760 colspan=5 class=formvalue><b>Bank Guarantees</b></td>
  </tr>
  <tr valign=top>
  <td valign=top width=190 class=formlabel>Project Name</td>
  <td valign=top width=150 class=formlabel>Amount</td>
  <td valign=top width=130 class=formlabel>Start Date</td>
  <td valign=top width=130 class=formlabel>End Date</td>
  <td valign=top width=140 class=formlabel>Bank Name</td>
  <td valign=top width=20 class=formlabel>&nbsp;</td>
  </tr>

  <? for ($i=0;$i<=4;$i++) { ?>

    <? $bg_data = $bg_list[$i]; ?>

    <tr valign=top>
    <input name="bg_pkey<?=$i;?>" id="bg_pkey<?=$i;?>" type="hidden" value="<?=$bg_data['bg_pkey'];?>">
    <input name="bg_supplierpkey<?=$i;?>" id="bg_supplierpkey<?=$i;?>" type="hidden" value="<?=$bg_data['bg_supplierpkey'];?>">
    <td valign=top width=190 class=formvalue><input name="bg_projectname<?=$i;?>" id="bg_projectname<?=$i;?>" type="text" value="<?=$bg_data['bg_projectname'];?>" maxlength=200 style="width: 180px;"></td>
    <td valign=top width=150 class=formvalue><input name="bg_bankamount<?=$i;?>" id="bg_bankamount<?=$i;?>" type="text" value="<?=number_format($bg_data['bg_bankamount'],2);?>" maxlength=21 style="width: 140px; text-align: right;" onkeypress="decimalOnly();"></td>
    <td valign=top width=130 class=formvalue><input name="bg_startdate<?=$i;?>" id="bg_startdate<?=$i;?>" type="text" value="<?=unconverttounixslash($bg_data['bg_startdate']);?>" maxlength=10 style="width: 90px;" onkeypress="dateOnly();">
    <a href="javascript:cal<?=$i+2;?>1.popup();"><img src="images/icon/cal.gif" width="16" height="16" border="0" alt="Click to select date"></a>
    </td>
    <td valign=top width=130 class=formvalue><input name="bg_enddate<?=$i;?>" id="bg_enddate<?=$i;?>" type="text" value="<?=unconverttounixslash($bg_data['bg_enddate']);?>" maxlength=10 style="width: 90px;" onkeypress="dateOnly();">
    <a href="javascript:cal<?=$i+2;?>2.popup();"><img src="images/icon/cal.gif" width="16" height="16" border="0" alt="Click to select date"></a>
    </td>
    <td valign=top width=140 class=formvalue><input name="bg_bankname<?=$i;?>" id="bg_bankname<?=$i;?>" type="text" value="<?=$bg_data['bg_bankname'];?>" maxlength=200 style="width: 130px;"></td>
    <td valign=top width=20 class=formvalue><img src="gfx/options/b_drop.png" title="Remove" alt="Remove" style="cursor: pointer;" onClick="removeBG('<?=$i;?>');"></td>
    </tr>

  <? } ?>

  <input name="job" id="job" type="hidden" value="">
  </form>
  </table>

  <script language="javascript">
    var cal1 = new calendar1(document.forms['supplierform'].elements['supplier_regdate']);
    cal1.year_scroll = true;
    cal1.time_comp = false;
    var cal21 = new calendar1(document.forms['supplierform'].elements['bg_startdate0']);
    cal21.year_scroll = true;
    cal21.time_comp = false;
    var cal22 = new calendar1(document.forms['supplierform'].elements['bg_enddate0']);
    cal22.year_scroll = true;
    cal22.time_comp = false;
    var cal31 = new calendar1(document.forms['supplierform'].elements['bg_startdate1']);
    cal31.year_scroll = true;
    cal31.time_comp = false;
    var cal32 = new calendar1(document.forms['supplierform'].elements['bg_enddate1']);
    cal32.year_scroll = true;
    cal32.time_comp = false;
    var cal41 = new calendar1(document.forms['supplierform'].elements['bg_startdate2']);
    cal41.year_scroll = true;
    cal41.time_comp = false;
    var cal42 = new calendar1(document.forms['supplierform'].elements['bg_enddate2']);
    cal42.year_scroll = true;
    cal42.time_comp = false;
    var cal51 = new calendar1(document.forms['supplierform'].elements['bg_startdate3']);
    cal51.year_scroll = true;
    cal51.time_comp = false;
    var cal52 = new calendar1(document.forms['supplierform'].elements['bg_enddate3']);
    cal52.year_scroll = true;
    cal52.time_comp = false;
    var cal61 = new calendar1(document.forms['supplierform'].elements['bg_startdate4']);
    cal61.year_scroll = true;
    cal61.time_comp = false;
    var cal62 = new calendar1(document.forms['supplierform'].elements['bg_enddate4']);
    cal62.year_scroll = true;
    cal62.time_comp = false;
  </script>

  <script type="text/javascript">

  function removeContact(cno) {

    var objname=document.getElementById('contact_name'+cno);
    objname.value="";
    var objdesignation=document.getElementById('contact_designation'+cno);
    objdesignation.value="";
    var objphone=document.getElementById('contact_phone'+cno);
    objphone.value="";
    var objemail=document.getElementById('contact_email'+cno);
    objemail.value="";
    var objmain=document.getElementById('contact_main'+cno);
    objmain.checked=false;

  }

  function removeBG(bgno) {

    var objname=document.getElementById('bg_projectname'+bgno);
    objname.value="";
    var objamount=document.getElementById('bg_bankamount'+bgno);
    objamount.value="0.00";
    var objstart=document.getElementById('bg_startdate'+bgno);
    objstart.value="";
    var objend=document.getElementById('bg_enddate'+bgno);
    objend.value="";
    var objbank=document.getElementById('bg_bankname'+bgno);
    objbank.value="";

  }

  function validateForm() {

    var isvalid=true;
    var errmsg="";
    var supplierregid=document.getElementById('supplier_regid');
    var suppliername=document.getElementById('supplier_name');

    if ((supplierregid.value=="")||(suppliername.value=="")) {
      errmsg='Supplier Registration No and Name must be specified!\n';
      isvalid=false;
    }
    if (isvalid==false) alert('Error:\n'+errmsg);
    return isvalid;

  }

  </script>
