HEX
Server: Apache/2.2.15 (CentOS)
System: Linux ip-10-0-2-146.eu-west-1.compute.internal 2.6.32-754.35.1.el6.centos.plus.x86_64 #1 SMP Sat Nov 7 11:33:42 UTC 2020 x86_64
User: root (0)
PHP: 5.6.40
Disabled: NONE
Upload Files
File: /www/exchange0old/exchange/cache/%%AB^ABC^ABC1994D%%revolving_trade.html.php
<?php /* Smarty version 2.6.19, created on 2024-06-17 08:18:50
         compiled from revolving_trade.html */ ?>
<?php require_once(SMARTY_CORE_DIR . 'core.load_plugins.php');
smarty_core_load_plugins(array('plugins' => array(array('modifier', 'siteUrl', 'revolving_trade.html', 4, false),array('modifier', 'storage', 'revolving_trade.html', 394, false),array('modifier', 'tokenUrl', 'revolving_trade.html', 398, false),)), $this); ?>
<?php $_smarty_tpl_vars = $this->_tpl_vars;
$this->_smarty_include(array('smarty_include_tpl_file' => "header.html", 'smarty_include_vars' => array()));
$this->_tpl_vars = $_smarty_tpl_vars;
unset($_smarty_tpl_vars);
 ?>
<script type="text/javascript" src="<?php echo $_SESSION['base_url']; ?>
/js/jquery.ui.core.js"></script>
<script type="text/javascript" src="<?php echo $_SESSION['base_url']; ?>
/js/ui.datepicker.js"></script>
<script type="text/javascript" src="<?php echo ((is_array($_tmp='/js/jquery.form.js')) ? $this->_run_mod_handler('siteUrl', true, $_tmp) : smarty_modifier_siteUrl($_tmp)); ?>
"></script>
<link type="text/css" href="<?php echo ((is_array($_tmp='/css/bootstrap.min.css')) ? $this->_run_mod_handler('siteUrl', true, $_tmp) : smarty_modifier_siteUrl($_tmp)); ?>
" rel="stylesheet" />
<table cellspacing="0" cellpadding="0" border="0" width="100%">
  <tbody>
  <tr>
  <td align="left" valign="top">
  
  <table cellspacing="0" cellpadding="0" border="0" width="100%">
    <tbody> 
    
    <tr>
      <td align="center" valign="top">&nbsp;</td>
    </tr>
    <tr>
      <td align="left" valign="middle" class="login_bg"><table cellspacing="0" cellpadding="0" border="0" width="100%">
          <tbody>
            <tr>
              <td align="left" width="" valign="middle" class="login_bg_t">Exchange Trade Centre | Single Invoice</td>
              <td width="" align="left" valign="middle" class="txt_11">Originator Organisation ID: <?php echo $_SESSION['user']['org_ref_id']; ?>
  </td>
              <td align="right" width="" valign="middle" class="txt_11"><?php $_smarty_tpl_vars = $this->_tpl_vars;
$this->_smarty_include(array('smarty_include_tpl_file' => 'originator_top_dashboard_links.html', 'smarty_include_vars' => array()));
$this->_tpl_vars = $_smarty_tpl_vars;
unset($_smarty_tpl_vars);
 ?></td>
            </tr>
          </tbody>
        </table>
       </td>
       </tr>
    <tr> 
    
    <td align="center" valign="top" class="about_c">
    
    <table cellspacing="5" cellpadding="5" border="0" width="100%">
      <tbody>
      
      <tr>
      
      <td align="left" width="18%" valign="top"><?php $_smarty_tpl_vars = $this->_tpl_vars;
$this->_smarty_include(array('smarty_include_tpl_file' => 'left_sidebar.html', 'smarty_include_vars' => array()));
$this->_tpl_vars = $_smarty_tpl_vars;
unset($_smarty_tpl_vars);
 ?></td>
      <td align="right" width="82%" valign="top"  id="tool">
      
      <form name="form" action="index.php?do=saverevolvingtrade" id="opentrade" method="post" enctype="multipart/form-data">
        <table cellspacing="2" cellpadding="3" border="0" width="100%" class="hdr_center">
          <tbody>
            <tr>
              <td align="left" valign="top" class="inves_top1" colspan="3">Revolving ETR Invoice Upload</td>
            </tr>
          
          <tr>
            <td colspan="3"> 
                   <table cellspacing="0" cellpadding="0" border="0" width="100%" >
                        <tr>
                            <td>
                                <?php if (! empty ( $this->_tpl_vars['result'] )): ?>
                                <div class="success-msgbox">
                                <?php echo $this->_tpl_vars['result']; ?>

                                </div>
                                <?php endif; ?>
                                
                                <?php if (! empty ( $this->_tpl_vars['error_message'] )): ?>
                                <div class="error-msgbox"  style="font-size: 14px; background-color: #f54579">
                                <?php echo $this->_tpl_vars['error_message']; ?>

                                </div>
                                <?php endif; ?>
                            </td>
                        </tr>
              		</table>
              </td>
          </tr>

        <tr>
            <td>&nbsp;</td>
            <td align="left" valign="top">&nbsp;</td>
            <td align="left" valign="top"></td>
        </tr>

          <tr>
            <td align="center" valign="top" class="txt_11_red" width="2">&nbsp;</td>
            <td align="left" valign="top" width="33%">&nbsp;</td>
            <td align="left" valign="top" width="70%"><div class="error-msgbox" >
                                Submit Trades before <b style="color:#FF0000;font-size:11px;"><?php echo $this->_tpl_vars['clearSweepOut']; ?>
</b> to receive <a href="javascript:void(0);" onclick="javascript:window.open('/faq#tomnext','','scrollbars=yes,width=1000,height=800');" style="color:#0033FF;text-decoration:underline;font-size:11px;">TomNext</a> Purchase Payment
                                </div></td>
          </tr>

          <tr class="salestype1" style="display:none;">
            <td align="center" valign="top" class="txt_11_red" width="2">*</td>
            <td align="left" valign="top" width="33%">Invoice Type :</td>
            <td align="left" valign="top" width="70%"><input type="radio" value="1" name="inv_type" id="inv_type" tabindex="1" checked>
              &nbsp;Single Invoice&nbsp;<a href="javascript:void(0);" title="<?php echo $this->_tpl_vars['help']['1']['content']; ?>
" class="under">(?)</a> &nbsp;&nbsp;&nbsp;
              <input type="radio" value="2" tabindex="2" name="inv_type" id="inv_type">
              &nbsp; Multiple Invoices&nbsp;<a href="javascript:void(0);" title="<?php echo $this->_tpl_vars['help']['2']['content']; ?>
" class="under">(?)</a> &nbsp;&nbsp;&nbsp;
                <br/>
              <span class="error_row">
                <?php echo $this->_tpl_vars['messages']['inv_type']; ?>

                </span></td>
          </tr>

          <tr>
            <td colspan="2">&nbsp;</td>
            <td>
                <input type="hidden" name="ldc_premium" disabled>
                <span class="error_row"></span>
            </td>
          </tr>

          <tr>
            <td align="center" valign="top" class="txt_11_red">*</td>
            <td align="left" valign="top">Upload Revolving ETR invoice for :</td>
            <td align="left" valign="top"><table cellpadding="3" cellspacing="0" border="0" width="100%">
                <tr>
                  <td>
                  	<select name="debtor_id" tabindex="4" id="debtor_id" class="cmb_bx1 select-revolving-etr-invoice-debtor" style="width:300px;" onchange="loadFields(this.value, $(this));calCurrencyRate(this.value);">
                    	<option value="">Select debtor </option>
                        <?php $_from = $this->_tpl_vars['debtor']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)):
    foreach ($_from as $this->_tpl_vars['myId'] => $this->_tpl_vars['i']):
?>
                            <option data-debtor-id="<?php echo $this->_tpl_vars['i']['debtor_id']; ?>
" value="<?php echo $this->_tpl_vars['i']['invoice_id']; ?>
"  <?php if ($this->_tpl_vars['i']['invoice_id'] == $this->_tpl_vars['values']['debtor_id']): ?>selected="selected"<?php endif; ?> ><?php echo $this->_tpl_vars['i']['debtor_name']; ?>
</option>
                        <?php endforeach; endif; unset($_from); ?>
                  </select>
                  
                  &nbsp;<a href="javascript:void(0);" title="<?php echo $this->_tpl_vars['help']['0']['content']; ?>
" class="under">(?)</a> &nbsp;&nbsp;<a href="?do=createdebtor&trade=2" class="Clstr_hints">Add a new counterparty</a>&nbsp;<a href="javascript:void(0);" title="<?php echo $this->_tpl_vars['help']['19']['content']; ?>
" class="under">(?)</a> 
                  <br /><span class="error_row">
                  	<?php echo $this->_tpl_vars['messages']['debtor_id']; ?>

                    <?php echo $this->_tpl_vars['messages']['invoice']; ?>

                  </span></td>
                </tr>
              </table></td>
          </tr>

            <tr class="orpa_list">
                <td align="center" valign="top" class="txt_11_red">*</td>
                <td align="left" valign="top">Select b-ETR :</td>
                <td align="left" valign="top">
                    <table cellpadding="3" cellspacing="0" border="0" width="100%">
                        <tr>
                            <td>
                                <select name="orpa_id" tabindex="4" id="orpa_list" class="cmb_bx1" style="width:300px;">
                                </select>
                                &nbsp;<a href="javascript:void(0);" title="<?php echo $this->_tpl_vars['help']['0']['content']; ?>
" class="under">(?)</a>
                                <br /><span class="error_row"><?php echo $this->_tpl_vars['messages']['orpa_id']; ?>
</span>
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
            <tr>
                <td colspan="3">&nbsp;</td>
            </tr>

            <tr class="row-etr-deliver-to">
                <td align="center" valign="top" class="txt_11_red"></td>
                <td align="left" valign="top" width="28%">Deliver NoA to:</td>
                <td align="left" valign="top" width="70%">
                    <select name="etr_deliver_to_debtor_contact" class="select-etr-deliver-to cmb_bx1"></select>
                                <br /><span class="error_row"><?php echo $this->_tpl_vars['messages']['etr_deliver_to_debtor_contact']; ?>
</span>
                </td>
            </tr>

            <tr>
                <td colspan="3">&nbsp;</td>
            </tr>
          <tr>
                            <td align="center" valign="top" class="txt_11_red">*</td>
                            <td align="left" valign="top" width="28%">Payment Terms :</td>
                            <td align="left" valign="top" width="70%">
                              <table width="100%" border="0" cellspacing="0" cellpadding="0">
                                  <tr>
                                    <td>
                                        <input type="text" maxlength="4" tabindex="5" size="2" class="text_c_code" value="<?php echo $this->_tpl_vars['values']['payment']; ?>
" name="payment" id="payment">
                                        Days&nbsp;<a href="javascript:void(0);" title="<?php echo $this->_tpl_vars['help']['5']['content']; ?>
" class="under">(?)</a> <br/>
                                        <span class="error_row"> 
                                            <?php echo $this->_tpl_vars['messages']['payment']; ?>

                                        </span>
                                    </td>
                                    <td>&nbsp;</td>
                                    <td>Currency :</td>
                                    <td>

                                      <input type="text" class="text_b_small1" tabindex="6" id="currency_country_id" style="width:130px;background-color:#C0C0C0;" readonly="true" value="" />

                                      <input type="hidden" name="country_id" id="country_id" value=""  />

                                       &nbsp; <span id="cur_face_value" ></span><a href="javascript:void(0);" title="<?php echo $this->_tpl_vars['help']['20']['content']; ?>
" class="under">(?)</a> <br/>
                                        <span class="error_row"> 
                                        <?php echo $this->_tpl_vars['messages']['country_id']; ?>
</span>
                                  </td>
                                  </tr>
                                </table>
                            </td>
                          </tr>

          <tr>
            <td colspan="3">&nbsp;</td>
          </tr>

          <tr class="salestype1">
            <td align="center" valign="top" class="txt_11_red">*</td>
            <td align="left" valign="top" id="selface"><strong>Face Value : </strong></td>
            <td align="left" valign="top"><input type="text" tabindex="7" class="text_b_small1" value="<?php echo $this->_tpl_vars['values']['face_value']; ?>
" name="face_value" id="face_value" style="text-align:right;">
              &nbsp;<a href="javascript:void(0);" title="<?php echo $this->_tpl_vars['help']['4']['content']; ?>
" class="under">(?)</a>
              <br/>
              <span class="error_row"> 
              <?php echo $this->_tpl_vars['messages']['face_value']; ?>
</span></td>
          </tr>
          <tr>
            <td align="center" valign="top" class="txt_11_red">&nbsp;</td>
            <td align="left" valign="top">Remaining Value: </td>
            <td align="left" valign="top">
            	<table width="100%" border="0" cellspacing="0" cellpadding="0">
                  <tr>
                    <td id="remainValue" width="18.4%" align="right" style="color:#555555;">&nbsp;</td>
                    <td width="75%" align="left">&nbsp;<input type="hidden" id="totalFaceValue" />
                    <a href="javascript:void(0);" title="<?php echo $this->_tpl_vars['help']['18']['content']; ?>
" class="under">(?)</a></td>
                  </tr>
                </table>
           </td>
          </tr>
          <tr>
            <td colspan="3">&nbsp;</td>
          </tr>
          <tr>
            <td align="center" valign="top" class="txt_11_red">*</td>
            <td align="left" valign="top" id="selface">Invoice Date :&nbsp; <span class="txt_11_cute">(DD/MM/YYYY)</span></td>
            <td align="left" valign="top" width="75%"><div id="body_tag">
                      <div class="search_all" id="search_all_id">
                        <div class="search_element1">
                          <div class="city_div">
                            <input type="text" value="<?php echo $this->_tpl_vars['values']['invoice_date']; ?>
" name="invoice_date" id="invoice_date" class="text_dd_code clsBlurs" tabindex="8" size="2" maxlength="2">
                            &nbsp;
                            <input type="text" value="<?php echo $this->_tpl_vars['values']['invoice_month']; ?>
" name="invoice_month" id="invoice_month" class="text_dd_code clsBlurs" tabindex="9" size="2" maxlength="2">
                            &nbsp;
                            <input type="text" maxlength="4" size="4" tabindex="10" class="text_c_code clsBlurs" id="invoice_year" name="invoice_year" value="<?php echo $this->_tpl_vars['values']['invoice_year']; ?>
">
                            &nbsp;<a href="javascript:void(0);" title="<?php echo $this->_tpl_vars['help']['6']['content']; ?>
" class="under">(?)</a>
                            <script>
								function generateDate()
                                {
									var invoice_date = Number($("#invoice_date").val());
									var invoice_month = Number($("#invoice_month").val());
									var invoice_year = Number($("#invoice_year").val());
								
									if(invoice_date !='' && invoice_month !='' || invoice_year !='' )
                                    {
										if( (invoice_date > 0 && invoice_date <= 31) && (invoice_month > 0 && invoice_month < 13))
                                        {
											var terms = Number($("#payment").val());
											
											if(terms == '') { terms = 2; }
											  
                                              $.post(
												  "?do=getNextDate&rand="+Math.random(),
												  {date:invoice_date,month:invoice_month,year:invoice_year,payment:terms},
												  function(responseText){
													responseText = responseText.split("-");
													
													$("#ex_date").val(responseText[0]);
													$("#ex_month").val(responseText[1]);
													$("#ex_year").val(responseText[2]);
												
												});
										}
									}
									
								}
								//For Date Picker
								  $(function() {
									$( "#invoice_year" ).datepicker({
									  minDate: -365,
									  maxDate: "+0D",
									  showOn: "button",
									  buttonImage: "<?php echo ((is_array($_tmp='/images/calender_month.png')) ? $this->_run_mod_handler('siteUrl', true, $_tmp) : smarty_modifier_siteUrl($_tmp)); ?>
",
									  buttonImageOnly: true,
									  onSelect: function( selectedDate ) {
										var i =0;selDate = selectedDate.split('/');var dates = new Array("invoice_month","invoice_date","invoice_year");
										
										for(i = 0; i <=2; i++){
										  $( "#"+dates[i] ).val(selDate[i]);
										}
									  },
									  onClose:function( selectedDate ) {
										 generateDate(); 
									  }
									  
									});
									
								   $(".clsBlurs").bind('blur',function(){
																	   
										generateDate();
										
									});
								   
								   $("#payment").bind('blur keyup',function(){
																	   
										generateDate();
										
									});
								
									
								  });
            				</script>
                          </div>
                        </div>
                        <div class="clear_div"></div>
                      </div>
                    </div>
              &nbsp;
              <br/>
              <span class="error_row"> 
              <?php echo $this->_tpl_vars['messages']['invoice_date']; ?>
</span></td>
          </tr>


           <tr>
            <td align="center" valign="top" class="txt_11_red">*</td>
            <td align="left" valign="top" id="selface"><strong>Expected Date : </strong><span class="txt_11_cute">(DD/MM/YYYY)</span></td>
            <td align="left" valign="top" width="75%"><div id="body_tag">
                      <div id="search_all_id" class="search_all">
                        <div class="search_element1">
                          <div class="city_div">
                            <input type="text" maxlength="2" size="2" tabindex="11" class="text_dd_code" id="ex_date" name="ex_date" value="<?php echo $this->_tpl_vars['values']['ex_date']; ?>
">
                            &nbsp;
                            <input type="text" maxlength="2" size="2" tabindex="12" class="text_dd_code" id="ex_month" name="ex_month" value="<?php echo $this->_tpl_vars['values']['ex_month']; ?>
">
                            &nbsp;
                            <input type="text" maxlength="4" size="4" tabindex="13" class="text_c_code" id="ex_year" name="ex_year" value="<?php echo $this->_tpl_vars['values']['ex_year']; ?>
">
                            &nbsp;<a href="javascript:void(0);" title="<?php echo $this->_tpl_vars['help']['7']['content']; ?>
" class="under">(?)</a>
                            <script>
            //For Date Picker
              $(function() {
                $( "#ex_year" ).datepicker({
                  minDate: -365,
                  showOn: "button",
                  buttonImage: "<?php echo ((is_array($_tmp='/images/calender_month.png')) ? $this->_run_mod_handler('siteUrl', true, $_tmp) : smarty_modifier_siteUrl($_tmp)); ?>
",
                  buttonImageOnly: true,
                  onSelect: function( selectedDate ) {
                    var i =0;selDate = selectedDate.split('/');var dates = new Array("ex_month","ex_date","ex_year");
                    for(i = 0; i <=2; i++){
                      $( "#"+dates[i] ).val(selDate[i]);
                    }
                  }
                });
              });
            </script>
                          </div>
                        </div>
                        <div class="clear_div"></div>
                      </div>
                    </div>
              <br/>
              <span class="error_row"> 
              <?php echo $this->_tpl_vars['messages']['ex_date']; ?>
</span></td>
          </tr>


          <tr>
            <td colspan="3">&nbsp;</td>
          </tr>


          
         <tr class="salestype1">
           <td align="center" valign="top" class="txt_11_red">*</td>
           <td align="left" valign="top">PoD : </td>
           <td align="left" valign="top">
               <select name="po_no" tabindex="4" id="po_no" class="cmb_bx1" disabled>
               </select>
               <input type="text" tabindex="14" class="text_b" value="<?php echo $this->_tpl_vars['values']['po']; ?>
" name="po" id="po">
             &nbsp;<a href="javascript:void(0);" title="<?php echo $this->_tpl_vars['help']['8']['content']; ?>
" class="under">(?)</a> <br/>
             <span class="error_row"> 
               <?php echo $this->_tpl_vars['messages']['po']; ?>
</span></td>
         </tr>

        <tr class="salestype1">
            
            <td 
                <?php if (( $this->_tpl_vars['orgDetails']['etr_pod_mandatory'] == '1' )): ?> 
                align="center" valign="top" class="txt_11_red" 
                <?php endif; ?> >
                <?php if (( $this->_tpl_vars['orgDetails']['etr_pod_mandatory'] == '1' )): ?>
                *
                <?php else: ?>
                &nbsp;
                <?php endif; ?>
            </td>
            <td align="left" valign="top">Attach PoD :</td>
            <td align="left" valign="top">
              <div style="float:left;">

                <?php if ($this->_tpl_vars['values']['pofile'] == ''): ?>
                <input type="file" class="browse" value="" tabindex="15" style="width:auto;" name="file_po" id="file_po" accept=".pdf">
                <input type="button" name="savefile" id="savepofile" class="savefile" alt="file_po" title="pofile" value="Save" data-flag="poflag" style="border:1px solid #000; padding:0px 5px;" dtype="debtor" />
                <?php else: ?>
                Use View button to view File
                <?php endif; ?>

                <input type="hidden" name="pofile" id="pofile" value="<?php echo $this->_tpl_vars['values']['pofile']; ?>
" />
                 <input type="hidden" name="poflag" id="poflag" value="" />
                <?php if ($this->_tpl_vars['values']['pofile'] != ''): ?>
                  <a href="<?php echo ((is_array($_tmp=$this->_tpl_vars['values']['pofile'])) ? $this->_run_mod_handler('storage', true, $_tmp, "d-purchase-orders") : smarty_modifier_storage($_tmp, "d-purchase-orders")); ?>
" class="viewlink" target="_blank" style="border:1px solid #000; padding:1px 5px;">View</a>
                <?php endif; ?>
                &nbsp;<a href="javascript:void(0);" title="<?php echo $this->_tpl_vars['help']['10']['content']; ?>
" class="under">(?)</a>
                </div>
                 <div style="float:left; width:300px; margin-left:0px;"><a href="javascript:void(0);" onclick="javascript:window.open('<?php echo ((is_array($_tmp='/exchange-help/originator/invoice')) ? $this->_run_mod_handler('tokenUrl', true, $_tmp) : smarty_modifier_tokenUrl($_tmp)); ?>
','','scrollbars=yes,width=1000,height=800');" class="Clstr_hints">Learn more about Purchase Order [PO] numbers</a>
                <a href="javascript:void(0);" title="<?php echo $this->_tpl_vars['help']['11']['content']; ?>
" class="under">(?)</a>
                </div>
                 <br/><br/>
                <span class="error_row" style="color:#FF0000;float:left;clear:both;">
                  <?php echo $this->_tpl_vars['messages']['pofile']; ?>

                </span>
            </td>
          </tr>

          <tr>
            <td colspan="3">&nbsp;</td>
          </tr>

         <tr class="salestype1">
           <td align="center" valign="top" class="txt_11_red">*</td>
           <td align="left" valign="top">Invoice No : </td>
           <td align="left" valign="top"><input type="text" tabindex="16" class="text_b" value="<?php echo $this->_tpl_vars['values']['invoice_no']; ?>
" name="invoice_no" id="invoice_no">
             &nbsp;<a href="javascript:void(0);" title="<?php echo $this->_tpl_vars['help']['9']['content']; ?>
" class="under">(?)</a> <br/>
             <span class="error_row"> 
               <?php echo $this->_tpl_vars['messages']['invoice_no']; ?>
</span></td>
         </tr>

           
          <tr class="salestype1">
            <td align="center" valign="top" class="txt_11_red">*</td>
            <td align="left" valign="top">Attach Invoice : </td>
            <td align="left" valign="top">
              <div style="float:left;">

                <?php if ($this->_tpl_vars['values']['invoicefile'] == ''): ?>
                <input type="file" class="browse" value="" tabindex="17" style="width:auto;" name="file_invoice" id="file_invoice" accept=".pdf">
                <input type="button" name="savefile" id="saveinvoicefile" class="savefile" alt="file_invoice" title="invoicefile" value="Save" data-flag="invoiceflag" style="border:1px solid #000; padding:0px 5px;" dtype="debtor"/>
                <?php else: ?>
                Use View button to view File
                <?php endif; ?>

                <input type="hidden" name="invoicefile" id="invoicefile" value="<?php echo $this->_tpl_vars['values']['invoicefile']; ?>
" />
                 <input type="hidden" name="invoiceflag" id="invoiceflag" value="" />
                <?php if ($this->_tpl_vars['values']['invoicefile'] != ''): ?>
                <a href="<?php echo ((is_array($_tmp=$this->_tpl_vars['values']['invoicefile'])) ? $this->_run_mod_handler('storage', true, $_tmp, "d-etr-invoices") : smarty_modifier_storage($_tmp, "d-etr-invoices")); ?>
" class="viewlink" target="_blank" style="border:1px solid #000; padding:1px 5px;">View</a>
                <?php endif; ?>
                &nbsp;<a href="javascript:void(0);" title="<?php echo $this->_tpl_vars['help']['12']['content']; ?>
" class="under">(?)</a>
                </div>

              <div style="float:left; width:400px; margin-left:0px;"><a href="javascript:void(0);" onclick="javascript:window.open('<?php echo ((is_array($_tmp='/exchange-help/originator/invoice')) ? $this->_run_mod_handler('tokenUrl', true, $_tmp) : smarty_modifier_tokenUrl($_tmp)); ?>
','','scrollbars=yes,width=1000,height=800');" class="Clstr_hints">Learn more about Attaching Invoices</a>
                <a href="javascript:void(0);" title="<?php echo $this->_tpl_vars['help']['13']['content']; ?>
" class="under">(?)</a>
                </div>
              
          
              <br/>
              <span class="error_row" style="color:#FF0000;float:left;clear:both;">
                <?php echo $this->_tpl_vars['messages']['invoicefile']; ?>

                </span>
              </td>
          </tr>
          <tr>
            <td colspan="3">&nbsp;</td>
          </tr>
          <tr>
            <td colspan="3">
                <input type="hidden" name="requested_document" disabled>
                <span class="error_row"></span>
            </td>
          </tr>
            <?php $_from = $this->_tpl_vars['requestedDocuments']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)):
    foreach ($_from as $this->_tpl_vars['requestedDocument']):
?>
            <tr>
                <td colspan="3">
                    <table class="table table-hover table-striped table-responsive" style="margin: 0;">
                        <tbody id="requested_documents_list"><tr>
                            <td colspan="3" style="padding: 0!important;">
                                <table class="table table-hover table-striped table-responsive" style="margin: 0;">
                                    <tbody>
                                    <tr>
                                        <td colspan="4">
                                            <b><?php echo $this->_tpl_vars['requestedDocument']['name']; ?>
</b>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>Document amount</td>
                                        <td>
                                            <input id="requested_document_amount_<?php echo $this->_tpl_vars['requestedDocument']['id']; ?>
" type="text" class="text_b" name="requested_document[<?php echo $this->_tpl_vars['requestedDocument']['id']; ?>
][amount]">
                                            <br>
                                            <span class="error_row"></span>
                                        </td>
                                        <td>Document attachment <sup class="txt_12_red">*</sup></td>
                                        <td>
                                            <input id="requested_document_file_<?php echo $this->_tpl_vars['requestedDocument']['id']; ?>
" type="file" class="text_b" name="requested_document[<?php echo $this->_tpl_vars['requestedDocument']['id']; ?>
][file]">
                                            <br>
                                            <span class="error_row"></span>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td colspan="4"></td>
                                    </tr>
                                    </tbody>
                                </table>
                            </td>
                        </tr></tbody>
                    </table>
                </td>
            </tr>
            <?php endforeach; endif; unset($_from); ?>
            <tr class="none">
                <td colspan="3">
                    <input type="hidden" name="new_document_id">
                    <table>
                        <tbody>
                        <tr id="new_po_copy">
                            <td colspan="3" style="padding: 0!important;">
                                <table class="table table-hover table-striped table-responsive" style="margin: 0;">
                                    <tbody>
                                    <tr>
                                        <td colspan="4">
                                            <b>New document</b>
                                            <!--<button onclick="deletePo(null, $(this), null);return false;" class="btn btn-default btn-sm" title="Delete">
                                                <i class="glyphicon glyphicon-remove-sign"></i>
                                            </button>-->
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>Document name <sup class="txt_12_red">*</sup></td>
                                        <td>
                                            <input id="new_document_name" type="text" class="text_b" name="new_document[name][]" disabled/>
                                            <br/>
                                            <span class="error_row"></span>
                                        </td>
                                        <td>Document amount</td>
                                        <td>
                                            <input id="new_document_amount" type="text" class="text_b" name="new_document[amount][]" disabled/>
                                            <br/>
                                            <span class="error_row"></span>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>Document attachment <sup class="txt_12_red">*</sup></td>
                                        <td>
                                            <input id="new_document_file" type="file" class="text_b" name="new_document[file][]" disabled/>
                                            <br/>
                                            <span class="error_row"></span>
                                        </td>
                                        <td></td>
                                        <td></td>
                                    </tr>
                                    <tr>
                                        <td colspan="4"></td>
                                    </tr>
                                    </tbody>
                                </table>
                            </td>
                        </tr>
                        </tbody>
                    </table>
                </td>
            </tr>
            <tr>
                <td colspan="3">
                    <table class="table table-hover table-striped table-responsive" style="margin: 0;">
                        <tbody id="po_list"></tbody>
                    </table>
                </td>
            </tr>
            <!--<tr>
                <td></td>
                <td>
                    <button type="button" class="btn btn-info" style="cursor: pointer;"
                            onclick="addNewPoLine();return false;">Add other document
                    </button>
                </td>
                <td></td>
            </tr>-->
          <tr class="row2">
            <td align="center" valign="top" colspan="3"><input tabindex="18"  type="checkbox" value="1" name="debx" id="debx"<?php if (( $this->_tpl_vars['values']['debx'] == 1 )): ?> checked <?php endif; ?>>
              &nbsp; Use <a href="javascript:void(0);" onclick="javascript:window.open('<?php echo ((is_array($_tmp='/exchange-help/collection')) ? $this->_run_mod_handler('tokenUrl', true, $_tmp) : smarty_modifier_tokenUrl($_tmp)); ?>
','','scrollbars=yes,width=1000,height=800');" style="color:#0033FF; text-decoration:underline;">ETR Collection Service</a> for this invoice:&nbsp;<a href="javascript:void(0);" title="<?php echo $this->_tpl_vars['help']['14']['content']; ?>
" class="under">(?)</a></td>
          </tr>
          <tr>
            <td align="center" valign="top" colspan="3">
                <input type="submit" tabindex="19"  class="login_bttn" value="Save" name="save" id="btn-etr-save"/>&nbsp;<a href="javascript:void(0);" title="<?php echo $this->_tpl_vars['help']['15']['content']; ?>
" class="under" style="padding-right:60px;">(?)</a>
              	<?php if (( $this->_tpl_vars['orgDetails']['etr_auto_submit'] == '1' )): ?>
            		<input type="submit" tabindex="20"  class="mem_bttn_long" value="Submit & Automatic Send" id="btn-etr-submit-auto" name="submits" />&nbsp;<a href="javascript:void(0);" title="<?php echo $this->_tpl_vars['help']['16']['content']; ?>
" class="under" class="under" style="padding-right:40px;">(?)</a>
                <?php endif; ?>
            
                <?php if (( $this->_tpl_vars['orgDetails']['etr_manual_submit'] == '1' )): ?>
              		<input type="submit" tabindex="21"  class="mem_bttn_long" value="Submit & Manual Send" id="btn-etr-submit-manual" name="manualsubmits">&nbsp;<a href="javascript:void(0);" title="<?php echo $this->_tpl_vars['help']['17']['content']; ?>
" class="under">(?)</a>
                <?php endif; ?>
            </td>
          </tr>
          
          <tr>
            <td align="center" valign="top" colspan="3">
              <a style="color:#0033FF; text-decoration:underline;font-weight:bold;" target="_blank" href="http://www.credebtexchange.com/blog/tips-help/save-etr-send" >Help me to decide what button to use here</a>

            </td>
          </tr>
          <tr>
            <td colspan="3"  id="clsAckNots">&nbsp;</td>
          </tr>
          </tbody>
          
        </table>
      </form>
      </td>
      
      </tr>
      
      </tbody>
      
    </table>
    </td>
    
    </tr>
     
    </tbody> 
    
  </table>
  </td>
  
  </tr>
  
  <tr>
    <td align="left" valign="top">&nbsp;</td>
  </tr>
  </tbody>
  
</table>
<script>


$("#face_value").bind('blur keyup',function(){
    calCurrencyRate($('#debtor_id').val());
});

function calCurrencyRate(val)
{
    $.post(
      "?do=calcurrencyrate",
      {id:val,rev:'1'},
      function(responseText){

        responseText = responseText.split("+");
        
        $("#currency_country_id").val(responseText[0]);
    });
}

function checkNoA(str){
	
	$.post(  
		"?do=getAckNotice",  
		{id: str},  
		function(responseText){
			if(responseText == '3'){
				$("#clsAckNot").hide(); 
				$("#clsAckNots").hide(); 
			}else{
				$("#clsAckNot").show(); 
				$("#clsAckNots").show(); 	
			}
		},  
		"html"  
	);  
	
}

$('.savefile').on('click',function(e){

  var thiss = $(this);
  var span = $(this).parents('td').first().find('span');
  var viewlinks = $(this).parents('td').first().find('.viewlink');
  var filename = $(this).attr('alt');
  var postname = '#'+$(this).attr('title');
  var flagname = $(this).data('flag');
  var fileid = $(this).attr('title');

  //Document type
  var type = $(this).attr('dtype');
  var postData = {'type':type};
  
  if($('#'+filename).val()!=''){
    if(viewlinks != 'undefined') viewlinks.remove();
    $('<img>',{
      src:'<?php echo ((is_array($_tmp='/images/loading1.gif')) ? $this->_run_mod_handler('siteUrl', true, $_tmp) : smarty_modifier_siteUrl($_tmp)); ?>
',
      height: '18',
      border:'0'
    }).insertAfter(thiss).css({'margin':'4px 10px 0 10px', 'vertical-align':'top'}).addClass('clsimg');
    
    $('#opentrade').ajaxSubmit({
      target: '#output' ,
      action:'index.php?do=fileupload',
      files_name: filename,
        data: postData,
      complete: function(xhr) {
          span.html('');
          $('#'+filename).val('');
          var data = $.parseJSON(xhr.responseText);
          if(!data || !data.success){
              span.html(data?data.message:'File Upload Error, Please Try Again');
              return;
          }

          $(postname).val(data.path);
          var anchors = '<a target="_blank" class="viewlink" href="'+data.url+'" style="border:1px solid #000; padding:1px 5px; margin-left:4px;">View</a>';
          $(anchors).insertAfter(thiss);
          $('#'+flagname).val('1');
      }
    });
    thiss.parents('td').first().find('.clsimg').remove();
    
  }
   e.preventDefault();
   
  return false;

});

function loadFields(str, $el)
{
	if(str !='')
    {
		$.post("?do=getfacevalue",{id:str,flag:0},  
			function(responseText)
            {
				var spl=responseText.split("::");

				var totalValue = Number(spl[0]);
				var faceValue  = Number($('#face_value').val());
				$('#totalFaceValue').val(totalValue);
				$('#remainValue').html('');
				$('#payment').val(spl[1]);
				totalValue1	= addCommas(totalValue.toFixed(2));
				$('#totalValue').html(totalValue1);
				if(faceValue > 0)
                {
					var remainValue = Number(totalValue - faceValue);
					remainValue	= addCommas(remainValue.toFixed(2));
					$('#remainValue').html(remainValue);
				}
                else
                {
					$('#remainValue').html(totalValue1);
				}
			},"html"  
		);

        debtor_id = $el.find('option:selected').attr('data-debtor-id');
        $.ajax({
            url: '?do=get_orpa_detr',
            type: 'post',
            data: {'debtor_id': debtor_id},
            success: function (data) {
                json_obj = $.parseJSON(data);
                if(json_obj.length) {
                    $('.orpa_list').show();
                    $content = '<option selected disabled value="0">Select b-ETR</option>';
                    $.each(json_obj, function (key, value) {
                        
                        text = (value.friendly_name)?(value.friendly_name + ' - ' + value.orpa_date):(value.reference + ' - ' + value.orpa_date);
                        
                        if (value.id == '<?php echo $this->_tpl_vars['values']['orpa_id']; ?>
') {
                            $content += '<option value="' + value.id + '" selected>' + text + '</option>';
                        } else {
                            $content += '<option value="' + value.id + '">' + text + '</option>';
                        }
                    });
                    $content += '<option value="" <?php if ($this->_tpl_vars['values']['orpa_id'] === "" || $this->_tpl_vars['values']['orpa_id'] === '0'): ?>selected<?php endif; ?>>Without b-ETR</option>';
                    $('#orpa_list').html($content).trigger('change');
                } else {
                    $('.orpa_list').hide();
                    $('#orpa_list').html('');
                }
            }
        });
	} else {
        $('.orpa_list').hide();
    }
	return false;
}
$('#orpa_list').on('change', function () {
    debtor_id = $('#debtor_id').find('option:selected').attr('data-debtor-id');
    orpa_id = $(this).val();
    po_input = $('#po');
    po_no_input = $('#po_no');
    po_file_line = $('#file_po').closest('tr');
    $.ajax({
        url: '?do=get_po_detr',
        type: 'post',
        data: {'debtor_id': debtor_id, 'orpa_id': orpa_id},
        success: function (data) {
            json_obj = data.length ? $.parseJSON(data) : '';
            if (json_obj.length) {
                content = '<option selected disabled value="0">Select PO</option>';
                $.each(json_obj, function (key, value) {
                    var txt = value.po_no + " | Avaliable "+value.currency_code+ " " + value.available_amount;
                    if (value.id == '<?php echo $this->_tpl_vars['values']['po_no']; ?>
') {
                        content += '<option value="' + value.id + '" selected>' + txt + '</option>';
                    } else {
                        content += '<option value="' + value.id + '">' + txt + '</option>';
                    }
                });
                po_input.hide();
                po_no_input.show().removeAttr('disabled').html(content);
                po_file_line.hide();
            }
            else {
                po_input.show();
                po_no_input.hide().attr('disabled', true);
                po_file_line.show();
            }
        }
    });
});
$('#face_value').on('keyup keypress blur change',function()
{									 
	var faceValue  = Number($(this).val());
	var totalValue  = Number($('#totalFaceValue').val());

	if(faceValue > 0 )
    {
		var remainValue = Number(totalValue - faceValue);

		remainValue	= addCommas(remainValue.toFixed(2));
		$('#remainValue').html(remainValue);
	}
    else
    {
		totalValue	= addCommas(totalValue.toFixed(2));
		$('#remainValue').html(totalValue);
	}
});


function addCommas(nStr)
{
	nStr += '';
	x = nStr.split('.');
	x1 = x[0];
	x2 = x.length > 1 ? '.' + x[1] : '';
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(x1)) {
		x1 = x1.replace(rgx, '$1' + ',' + '$2');
	}
	return x1 + x2;
}

<?php if (! empty ( $this->_tpl_vars['messages'] )): ?>
	var debtor = '<?php echo $this->_tpl_vars['values']['debtor_id']; ?>
';
//	loadFields(debtor);
<?php endif; ?>


<?php if ($this->_tpl_vars['values']['debtor_id'] != ''): ?>
calCurrencyRate('<?php echo $this->_tpl_vars['values']['debtor_id']; ?>
');
<?php endif; ?>

function addNewPoLine() {
    var
        $poList = $('#po_list'),
        $inputPoId = $('input[name=new_document_id]'),
        $lastPoId = Number($inputPoId.val()),
        $newPoId = $lastPoId ? $lastPoId + 1 : 1,
        $poLine = $('#new_po_copy').clone();
    $inputPoId.val($newPoId);
    $poLine.removeAttr('id');
    $poLine.find('#new_document_name')
        .attr('name', 'new_document[' + $newPoId + '][name]')
        .attr('id', 'new_document_name_' + $newPoId)
        .removeAttr('disabled');
    $poLine.find('#new_document_amount')
        .attr('name', 'new_document[' + $newPoId + '][amount]')
        .attr('id', 'new_document_amount_' + $newPoId)
        .removeAttr('disabled');
    $poLine.find('#new_document_file')
        .attr('name', 'new_document[' + $newPoId + '][file]')
        .attr('id', 'new_document_file_' + $newPoId)
        .removeAttr('disabled');
    $poList.append($poLine);
}


function deletePo(poId, tr, canRemove) {
    poLine = tr.closest('table').closest('tr');
    if (confirm('Do you want to delete this Document?')) {
        poLine.remove();
    }
}

var submitButton = undefined;
$('input[type="submit"]').on('click', function () {
    submitButton = $(this);
});
$('#opentrade').on('submit', function (e) {
    var form = $(this);
    form.find('span.error_row').each(function () {
        $(this).html('');
    });
    form.ajaxSubmit({
        success: function (data) {
            json_obj = $.parseJSON(data);
            if ($.isEmptyObject(json_obj)) {
                form.off('submit');
                submitButton.click();
            } else {
                $.each(json_obj, function (key, value) {
                    $('[name="' + key + '"]').closest('td').find('span').html(value);
                })
            }
        }
    });
    return false;
});

</script>
<style>

.clsrm td{
	line-height:normal;
	padding:0 !important;
}
.none{
	display:none;	
}
.Clstr_hints, .Clstr_hints:hover{
	font-size:10px !important;
}
.text_dd_code{
	width:15px;	
}

.hdr_center {padding: 1px}

.orpa_list {display: none}

.orpa_list>td {padding-top: 15px;}

#po_no {
    display: none;
    width: 300px;
}

.error_row {
    color: #ff0000;
}

input[type="file"] {
    display: inline-block;
}

</style>
<?php $_smarty_tpl_vars = $this->_tpl_vars;
$this->_smarty_include(array('smarty_include_tpl_file' => "footer.html", 'smarty_include_vars' => array()));
$this->_tpl_vars = $_smarty_tpl_vars;
unset($_smarty_tpl_vars);
 ?>