public function getInputForm($action = "new")
    {
        global $userid, $simbizctrl, $ctrl, $defaultorganization_id;
        $this->log->showLog(3, "Access Payment getInputForm()");
        if ($o->track1_id == "") {
            $o->track1_id = 0;
        }
        if ($o->track2_id == "") {
            $o->track2_id = 0;
        }
        if ($o->track3_id == "") {
            $o->track3_id = 0;
        }
        $track1option = $simbizctrl->getSelectTrack($this->track1_id, "Y", " AND trackheader_id =1");
        $track2option = $simbizctrl->getSelectTrack($this->track2_id, "Y", " AND trackheader_id =2");
        $track3option = $simbizctrl->getSelectTrack($this->track3_id, "Y", " AND trackheader_id =3");
        if ($action == "new") {
            include "../simbiz/class/Track.inc.php";
            $track = new Trackclass();
            $track_array = $track->getTrackName();
            $this->track1_name = $track_array['track1_name'];
            $this->track2_name = $track_array['track2_name'];
            $this->track3_name = $track_array['track3_name'];
            $this->bpartneraccounts_id = 0;
            $tableheader = "New Payment";
            $attnoption = "<option value='0'>Null</option>";
            $uidoption = $ctrl->getSelectUsers($userid);
            $termsoption = "<option value='0'>Null</option>";
            $addressoption = "<option value='0'>Null</option>";
            $currencyoption = "<option value='0'>Null</option>";
            $branchctrl = $ctrl->selectionOrganization($userid, $defaultorganization_id);
            $this->payment_id = 0;
            $this->document_no = $this->getNextNo();
            $this->document_date = date("Y-m-d", time());
            $this->exchangerate = 1;
            $this->subtotal = 0;
            $this->localamt = 0;
        } else {
            $tableheader = "Edit Payment";
            include_once "../simantz/class/SelectCtrl.inc.php";
            $ctrl = new SelectCtrl();
            include "../bpartner/class/BPSelectCtrl.inc.php";
            $bpctrl = new BPSelectCtrl();
            include "../bpartner/class/BPartner.php";
            $bp = new BPartner();
            $bpartner_id = $_REQUEST['bpartner_id'];
            $bp->fetchBpartnerData($bpartner_id);
            $addressxml = $bpctrl->getSelectAddress($this->address_id, "N", $o->bpartner_id);
            $termsxml = $bpctrl->getSelectTerms($this->terms_id, "N");
            $contactxml = $bpctrl->getSelectContacts($this->contacts_id, 'N', "", "", " and bpartner_id={$this->bpartner_id}");
            $currencyxml = $ctrl->getSelectCurrency($this->currency_id);
            $branchctrl = $ctrl->selectionOrganization($userid, $this->organization_id);
            $attnoption = $contactxml;
            $uidoption = $ctrl->getSelectUsers($this->preparedbyuid);
            $termsoption = $termsxml;
            $addressoption = $addressxml;
            $currencyoption = $currencyxml;
            // $branchoption="<option value='1'>HQ</option>";
        }
        $grid = $this->getGrid($this->payment_id);
        $html = <<<HTML
    <br/>
    <div id='centercontainer'>
    <div align="center" >
    <table style="width:990px;text-align: left; " >
        <tr><td align="left">{$this->addnewctrl}</td><td align="right">{$this->searchctrl}</td></tr></table>
{$noperm}

   
    <br/>
    <div id='errormsg' class='red' style='display:none'></div>
<form onsubmit='return false' method='post' name='frmPayment' id='frmPayment'  action='{$this->paymentfilename}'  enctype="multipart/form-data">
   <table style="text-align: left; width: 990px;" border="0" cellpadding="0" cellspacing="1"  class="searchformblock">
    <tbody>
        <tr>
        <td colspan="4" rowspan="1" align="center" id="idHeaderText" class="searchformheader" >{$tableheader}</td>
        </tr>
        <tr>
          <td class="head">Payment No</td>
          <td class="even"><input name='sppayment_prefix' id='sppayment_prefix' value='{$this->sppayment_prefix}'size='3'>
                            <input name='document_no' id='document_no'  value='{$this->document_no}' size='10'>
                    Branch <select id='organization_id' name='organization_id'>&nbsp; {$branchctrl}</select></td>
          <td class="head">Business Partner</td>
          <td class="even">
              <ntb:Combo id="cmbbpartner_id" Mode="classic" theme="{$nitobicombothemes}" InitialSearch="{$this->bpartner_name}" onselectevent="chooseBPartner();">
             <ntb:ComboTextBox Width="250px" DataFieldIndex=1 ></ntb:ComboTextBox>
             <ntb:ComboList Width="300px" Height="200px" DatasourceUrl="../simbiz/simbizlookup.php?action=searchbpartnercombo&showNull=Y" PageSize="25" >
             <ntb:ComboColumnDefinition Width="130px" DataFieldIndex=1 ></ntb:ComboColumnDefinition>
             <ntb:ComboMenu icon="images/add.gif" OnClickEvent="window.open('../bpartner/bpartner.php')" text=" &nbsp;Add product...">
             </ntb:ComboList>
            </ntb:Combo>
          </td>
     </tr>
     <tr>
        <td class="head">Date (YYYY-MM-DD)</td>
          <td class="even">
            <input id='document_date' name='document_date'  size='10'  value='{$this->document_date}'>
            <input id='btnpaymentdate' type='button' class='btndate' onclick="{$this->showCalendar}" value="Date"></td>
          <td class="head">Attn To </td>
          <td class="even"><select id='contacts_id' name='contacts_id' >{$attnoption}</select></td>
     </tr>
     <tr>
   
      <td class="head">Ref. No</td>
      <td class="even"><input id='ref_no' size='10' name='ref_no' value='{$this->ref_no}'></td>
     </tr>
     <tr>
         <td class="head">Prepared By</td>
         <td class="even"><select id='preparedbyuid' name='preparedbyuid'>{$uidoption}</select></td>
        <td class="head">Sales Agent</td>
         <td class="even"><input id='salesagentname'  name='salesagentname' value='{$this->salesagentname}'></td>
</tr>
<tr>
       <td class="head">Address</td>
       <td class="even"><select id='address_id' name='address_id' onchange=updateAddressText()>{$addressoption}</select><br/>
        <textarea id='address_text' name='address_text' cols='30' rows='3'>{$this->address_text}</textarea>
        </td>
         <td class="head">Currency</td>
          <td class="even">
                    <select id='currency_id' name='currency_id' onchange=comparecurrency()>{$currencyoption}</select> Exchange rate: MYR<input size='8' id='exchangerate' onchange=updateCurrency() value="{$this->exchangerate}" name="exchangerate"><br/>
     </td>
  <tr>
                 <td class="head" colspan='4'>
        <input name='save' onclick='saverecord(0)' type='submit' id='submit' value='Save'>
        <input name='save' onclick='saverecord(1);' type='submit' id='submit' value='Complete'>
        <input name='save' onclick='deleterecord()' type='submit' id='delete' value='Delete'>
        <input name='action' name='action' value='ajaxsave'  type="hidden">
        <input type="button" value="Reload" onclick=javascript:reloadPayment()>
        <input type="button" value="Receive All" onclick=javascript:receiveAll()>
            <input type="button" value="Preview" onclick=javascript:previewPayment()>
        <input name="track1_name" id="track1_name" type="hidden" value="{$this->track1_name}">
         <input name="track2_name" id="track2_name" type="hidden" value="{$this->track2_name}">
            <input name="track3_name"  id="track3_name" type="hidden" value="{$this->track3_name}">
        <input name='payment_id' id='payment_id'  value='{$this->payment_id}'  title='payment_id' type='hidden'>
        <input name='iscomplete'  id='iscomplete' value='{$this->iscomplete}'  title='iscomplete' type='hidden'>
        <input name='bpartneraccounts_id' id='bpartneraccounts_id' value='{$this->bpartneraccounts_id}' title='bpartneraccounts_id' type='hidden'>
            </td>
</td></tr>
<tr><td colspan='4'>
    <div id='detaildiv'>
    {$grid}
              <small>* Update payment detail via edit column Account, Paid Amt and following column, leave Paid Amt = 0 to delete particular payment detail</small>

           <div style="width:476px;text-align:right" >
                        <b style="text-align:right; height:30px; border-top: 1px solid #000; border-bottom: 3px double #000; width:300px">
             Total: <label id='lblsubtotal'><input id='subtotal' style="text-align:right"  size="10" name='subtotal' readonly="readonly" value='{$this->subtotal}'></label></b><br/>
              Outstanding : <label id='lbltotalgst'><input id='outstandingamt' size="10" style="text-align:right"  name='outstandingamt' readonly="readonly" value='{$this->outstandingamt}'></label>
            </div>

</div>
</td></tr>
 <td class="head">Description</td>
<td class="even" colspan='2'><textarea cols='70' rows='3' id='description'  name='description'>{$this->description}</textarea></td>
            <td rowspan="2"><br/><b>Tracking information</b>
            <div class="searchformblock" id="trackblock">
            {$this->track1_name}: <select name="track1_id" id="track1_id">{$track1option}</select><br/>
            {$this->track2_name}: <select name="track2_id" id="track1_id">{$track2option}</select><br/>
            {$this->track3_name}: <select name="track3_id" id="track1_id">{$track3option}</select><br/>
            </div></td>
</tr><tr>
   <td class="head">Note</td>
<td class="even" colspan='2'><textarea cols='70' rows='3' id='note'  name='note'>{$this->note}</textarea></td>
</tr></table>
</form>


HTML;
        return $html;
    }