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/exchange2/exchange/templates/originator_application_form_c_etr.html
<AJDF:output>include file="header.html"</AJDF:output>
<script type="text/javascript" src="<AJDF:output>'/js/jquery.ui.core.js'|siteUrl</AJDF:output>"></script>
<script type="text/javascript" src="<AJDF:output>'/js/ui.datepicker.js'|siteUrl</AJDF:output>"></script>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td align="left" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
              <tr>
                <td align="center" valign="top">&nbsp;</td>
              </tr>
              <tr>
                <td class="login_bg" align="left" valign="middle"><table width="100%" border="0" cellpadding="0" cellspacing="0">

				<tr>
					<td align="left" valign="top" class="login_bg_t">Exchange Trade Centre | Create Organisation Application Form</td>
					<td width="" align="left" valign="middle" class="txt_11">Originator Organisation ID: <AJDF:output>$smarty.session.user.org_ref_id</AJDF:output>  </td>
                    <td class="txt_11" align="right"><AJDF:output>include file='originator_top_dashboard_links.html'</AJDF:output></td>
				</tr>
			</table></td>
              </tr>
              <tr>
                <td align="center" valign="top" class="about_c" id="tool"><table width="100%" border="0" cellspacing="5" cellpadding="5">
                    <tr>
                      <td width="18%" align="left" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                          <tr>
                            <td align="left" valign="top">
                            	<AJDF:output>include file='left_sidebar_small.html'</AJDF:output></td>
                          </tr>
                        </table></td>
                        <td align="right" width="82%" valign="top" id="tool">
                            <form name="form" action="index.php?do=saveapplication6&type=creditor" 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">ETR Invoice Upload</td>
                                    </tr>
                                    <tr>
                                        <td colspan="3">
                                            <table cellspacing="0" cellpadding="0" border="0" width="100%" >
                                                <tr>
                                                    <td>
                                                        <AJDF:output>if !empty($result)</AJDF:output>
                                                        <div class="success-msgbox">
                                                            <AJDF:output>$result</AJDF:output>
                                                        </div>
                                                        <AJDF:output>/if</AJDF:output>

                                                        <AJDF:output>if !empty($error_message)</AJDF:output>
                                                        <div class="error-msgbox">
                                                            <AJDF:output>$error_message</AJDF:output>
                                                        </div>
                                                        <AJDF:output>/if</AJDF:output>

                                                    </td>
                                                </tr>
                                            </table>
                                        </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;"><AJDF:output>$clearSweepOut</AJDF:output></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="<AJDF:output>$help.1.content</AJDF:output>" 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="<AJDF:output>$help.2.content</AJDF:output>" class="under">(?)</a> &nbsp;&nbsp;&nbsp;
                                            <br/>
              <span style="color:#FF0000;">
                <AJDF:output>$messages.inv_type</AJDF:output>
                </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">Upload 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" style="width:300px;" onchange="loadFields(this.value);calCurrencyRate(this.value);">
                                                        <option value="">Select creditor </option>
                                                        <AJDF:output>foreach from=$debtor key=myId item=i</AJDF:output>
                                                        <option payment_discount="<AJDF:output>$i.payment_discount</AJDF:output>" currency="<AJDF:output>$i.currency_code</AJDF:output>" payment_cycle="<AJDF:output>$i.average_payment_cycle</AJDF:output>" value="<AJDF:output>$i.invoice_id</AJDF:output>"  <AJDF:output>if $i.invoice_id eq $values.debtor_id</AJDF:output>selected="selected"<AJDF:output>/if</AJDF:output> ><AJDF:output>$i.debtor_name</AJDF:output></option>
                                                        <AJDF:output>/foreach</AJDF:output>
                                                    </select>

                                                    &nbsp;<a href="javascript:void(0);" title="<AJDF:output>$help.0.content</AJDF:output>" class="under">(?)</a>
                                                    <br /><span style="color:#FF0000;">
                      <AJDF:output>$messages.debtor_id</AJDF:output>
                    <AJDF:output>$messages.invoice</AJDF:output>
                  </span></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" width="28%">Payment Discount :</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="<AJDF:output>$values.payment_discount</AJDF:output>" name="payment_discount" id="payment_discount">
                                                        % &nbsp;<a href="javascript:void(0);" title="Enter a value for Payment discount" class="under">(?)</a> <br/>
                            <span style="color:#FF0000;">
                                <AJDF:output>$messages.payment_discount</AJDF:output>
                            </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="<AJDF:output>$help.20.content</AJDF:output>" class="under">(?)</a> <br/>
                            <span style="color:#FF0000;">
                            <AJDF:output>$messages.country_id</AJDF:output></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="<AJDF:output>$values.face_value</AJDF:output>" name="face_value" id="face_value" style="text-align:right;">
                                            &nbsp;<a href="javascript:void(0);" title="<AJDF:output>$help.4.content</AJDF:output>" class="under">(?)</a>
                                            <br/>
              <span style="color:#FF0000;">
              <AJDF:output>$messages.face_value</AJDF:output></span></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="<AJDF:output>$values.invoice_date</AJDF:output>" name="invoice_date" id="invoice_date" class="text_dd_code clsBlurs" tabindex="8" size="2" maxlength="2">
                                                        &nbsp;
                                                        <input type="text" value="<AJDF:output>$values.invoice_month</AJDF:output>" 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="<AJDF:output>$values.invoice_year</AJDF:output>">
                                                        &nbsp;<a href="javascript:void(0);" title="<AJDF:output>$help.6.content</AJDF:output>" 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());

                                                                //alert(invoice_date+' '+invoice_month+' '+invoice_year);

                                                                if(invoice_date !='' && invoice_month !='' || invoice_year !='' ){
                                                                    if( (invoice_date > 0 && invoice_date < 31) && (invoice_month > 0 && invoice_month < 13)){
                                                                        var terms = Number($("#debtor_id option:selected").attr('payment_cycle'));

                                                                        if(terms == '') { terms = 2; }
                                                                        //var currDate =

                                                                        $.post(
                                                                                "?do=getNextDate",
                                                                                {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: "<AJDF:output>'/images/calender_month.png'|siteUrl</AJDF:output>",
                                                                    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();
                                                                        calculatePaymentCycle();
                                                                    }
                                                                });

                                                                $(".clsBlurs").bind('blur',function(){
                                                                    generateDate();
                                                                    calculatePaymentCycle();
                                                                });

                                                                $("#payment").bind('blur keyup',function(){
                                                                    //generateDate();
                                                                    calculatePaymentCycle();
                                                                });
                                                            });
                                                        </script>
                                                    </div>
                                                </div>
                                                <div class="clear_div"></div>
                                            </div>
                                        </div>
                                            &nbsp;
                                            <br/>
              <span style="color:#FF0000;">
              <AJDF:output>$messages.invoice_date</AJDF:output></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="<AJDF:output>$values.ex_date</AJDF:output>">
                                                        &nbsp;
                                                        <input type="text" maxlength="2" size="2" tabindex="12" class="text_dd_code" id="ex_month" name="ex_month" value="<AJDF:output>$values.ex_month</AJDF:output>">
                                                        &nbsp;
                                                        <input type="text" maxlength="4" size="4" tabindex="13" class="text_c_code" id="ex_year" name="ex_year" value="<AJDF:output>$values.ex_year</AJDF:output>">
                                                        &nbsp;<a href="javascript:void(0);" title="<AJDF:output>$help.21.content</AJDF:output>" class="under">(?)</a>
                                                        <script>
                                                            //For Date Picker
                                                            $(function() {
                                                                $( "#ex_year" ).datepicker({
                                                                    minDate: -365,
                                                                    showOn: "button",
                                                                    buttonImage: "<AJDF:output>'/images/calender_month.png'|siteUrl</AJDF:output>",
                                                                    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 style="color:#FF0000;">
              <AJDF:output>$messages.ex_date</AJDF:output></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"><input type="text" tabindex="14" class="text_b" value="<AJDF:output>$values.po</AJDF:output>" name="po" id="po">
                                            &nbsp;<a href="javascript:void(0);" title="<AJDF:output>$help.8.content</AJDF:output>" class="under">(?)</a> <br/>
             <span style="color:#FF0000;">
               <AJDF:output>$messages.po</AJDF:output></span></td>
                                    </tr>

                                    <tr class="salestype1">
                                        <td <AJDF:output>if ($orgDetails.etr_pod_mandatory eq '1')</AJDF:output> align="center" valign="middle" class="txt_11_red" <AJDF:output>/if</AJDF:output> ><AJDF:output>if ($orgDetails.etr_pod_mandatory eq '1')</AJDF:output>*<AJDF:output>else</AJDF:output>&nbsp;<AJDF:output>/if</AJDF:output></td>
                                        <td align="left" valign="middle">Attach PoD : </td>
                                        <td align="left" valign="top">
                                            <div style="float:left;" id="file_po_block">

                                                <AJDF:output>if $values.pofile eq ''</AJDF:output>
                                                <label  class="btn btn-yellow btn-default js-file-upload"
                                                        data-name="file_po"
                                                        data-accept=".pdf"
                                                        data-action="?do=saveapplication1_1"
                                                        data-tabindex="15">Attach PoD
                                                </label>
                                                <!--<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="creditor"/>-->
                                                <AJDF:output>else</AJDF:output>
                                                Use View button to view File
                                                <AJDF:output>/if</AJDF:output>

                                                <input type="hidden" name="pofile" id="pofile" value="<AJDF:output>$values.pofile</AJDF:output>" />
                                                <input type="hidden" name="poflag" id="poflag" value="" />
                                                <AJDF:output>if $values.pofile !=''</AJDF:output>
                                                <a href="../<AJDF:output>$values.pofile</AJDF:output>" class="viewlink" target="_blank" style="border:1px solid #000; padding:1px 5px;">View</a>
                                                <AJDF:output>/if</AJDF:output>
                                                &nbsp;<a href="javascript:void(0);" id="file_po_help" style="margin: 10px; display: inline-block;" title="<AJDF:output>$help.10.content</AJDF:output>" class="under">(?)</a>
                                            </div>
                                            <div style="float:left; width:300px; margin-left:0px;"><a href="javascript:void(0);" onclick="javascript:window.open('<AJDF:output>'/exchange-help/originator/invoice'|tokenUrl</AJDF:output>','','scrollbars=yes,width=1000,height=800');" class="Clstr_hints">Learn more about Purchase Order [PO] numbers</a>
                                                <a href="javascript:void(0);" title="<AJDF:output>$help.11.content</AJDF:output>" class="under">(?)</a>
                                            </div>
                                            <br/><br/>
                <span style="color:#FF0000;float:left;clear:both;">
                  <AJDF:output>$messages.pofile</AJDF:output>
                </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="<AJDF:output>$values.invoice_no</AJDF:output>" name="invoice_no" id="invoice_no">
                                            &nbsp;<a href="javascript:void(0);" title="<AJDF:output>$help.9.content</AJDF:output>" class="under">(?)</a> <br/>
             <span style="color:#FF0000;">
               <AJDF:output>$messages.invoice_no</AJDF:output></span></td>
                                    </tr>


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

                                                <AJDF:output>if $values.invoicefile eq ''</AJDF:output>
                                                <label  class="btn btn-yellow btn-default js-file-upload"
                                                        data-name="file_invoice"
                                                        data-accept=".pdf"
                                                        data-action="?do=saveapplication1_1"
                                                        data-tabindex="17">Attach Invoice
                                                </label>
                                                <!--<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="creditor"/>-->
                                                <AJDF:output>else</AJDF:output>
                                                Use View button to view File
                                                <AJDF:output>/if</AJDF:output>

                                                <input type="hidden" name="invoicefile" id="invoicefile" value="<AJDF:output>$values.invoicefile</AJDF:output>" />
                                                <input type="hidden" name="invoiceflag" id="invoiceflag" value="" />
                                                <AJDF:output>if $values.invoicefile !=''</AJDF:output>
                                                <a href="../<AJDF:output>$values.invoicefile</AJDF:output>" class="viewlink" target="_blank" style="border:1px solid #000; padding:1px 5px;">View</a>
                                                <AJDF:output>/if</AJDF:output>
                                                &nbsp;<a href="javascript:void(0);" title="<AJDF:output>$help.12.content</AJDF:output>" style="margin: 10px; display: inline-block;" id="file_invoice_help" class="under">(?)</a>
                                            </div>

                                            <div style="float:left; width:400px; margin-left:0px;"><a href="javascript:void(0);" onclick="javascript:window.open('<AJDF:output>'/exchange-help/originator/invoice'|tokenUrl</AJDF:output>','','scrollbars=yes,width=1000,height=800');" class="Clstr_hints">Learn more about Attaching Invoices</a>
                                                <a href="javascript:void(0);" title="<AJDF:output>$help.13.content</AJDF:output>" class="under">(?)</a>
                                            </div>


                                            <br/>
              <span style="color:#FF0000;float:left;clear:both;">
                <AJDF:output>$messages.invoicefile</AJDF:output>
                </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">c-ETR Loan Terms: </td>
                                        <td align="left" valign="top">
                                            <div class="text_b_terms" style="width:608px;height:200px;color:#555;overflow-y:scroll;text-align:justify; background:#FFF;">
                                                <AJDF:output>$etr_loan_terms</AJDF:output>
                                            </div>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td align="center" valign="top" colspan="3">
                                            <input type="button" value="Back" class="login_bttn" onclick="location.href='index.php?do=application6&id=<AJDF:output>$smarty.session.org_id</AJDF:output>&from=6'">
                                            <input type="hidden" name="debtor_type" value="creditor">
                                            <input type="submit" tabindex="19"  class="login_bttn" value="Save" name="save"/>
                                            <input type="button" value="<AJDF:output>if !isset($skip_button_name)</AJDF:output>Skip<AJDF:output>else</AJDF:output><AJDF:output>$skip_button_name</AJDF:output><AJDF:output>/if</AJDF:output>" class="login_bttn" onclick="location.href='index.php?do=saveapplication6&skip=1'">
                                        </td>
                                    </tr>
                                    <tr>
                                        <td colspan="3"  id="clsAckNots">&nbsp;</td>
                                    </tr>
                                    </tbody>

                                </table>
                            </form>
                        </td>
                    </tr>
                  </table></td>
              </tr>
            </table></td>
        </tr>
        <tr>
          <td align="left" valign="top">&nbsp;</td>
        </tr>
      </table>
<script type="text/javascript" src="<AJDF:output>'/js/jquery.form.js'|siteUrl</AJDF:output>"></script>
<script type="text/javascript">
    var jsInputFiles = $('.js-file-upload');

    jsInputFiles.each(function () {
        var $btn = $(this),
                accept = $btn.attr('data-accept'),
                name = $btn.attr('data-name'),
                tabindex = $btn.attr('data-tabindex'),
                $form = $('<form method="POST" ecntype="multipart/form-data" action="' + $btn.attr('data-action') + '"></form>');

        $btn.after($form);

        $form
                .addClass('js-form-file-upload')
                .append($btn)
                .append('<div class="progress"><div class="bar">0%</div></div>')
                .append('<div class="form-result"></div>');

        $btn.append('<input type="file" name="document" style="display: none"/>');

        var $input = $btn.find('input[type=file]'),
                $progress = $form.find('.progress'),
                $progressBar = $progress.find('.bar'),
                $formResult = $form.find('.form-result');

        if (accept) {
            $input.attr('accept', accept);
        }

        if (name) {
            $input.attr('name', name);
            $("#" + name + "_help").insertAfter('label[data-name="' + name + '"]');
        }

        if (tabindex) {
            $input.attr('tabindex', tabindex);
        }

        $form.ajaxForm({
            beforeSend: function() {
                $progress.css('visibility', 'visible');
            },
            uploadProgress: function(event, position, total, percentComplete) {
                var percentVal = percentComplete + '%';
                $progressBar.width(percentVal).html(percentVal);
            },
            success: function() {
                var percentVal = '100%';
                $progressBar.width(percentVal).html(percentVal);
            },
            complete: function(xhr) {
                $formResult.html(xhr.responseText);
            }
        });

        // bind submit handler to form
        $input.on('change', function () {
            $(this).appendTo('#' + $(this).attr('name') + '_block');
            $form.submit();
            return false;
        });
    });
</script>
<style>
    ol.styled {
        margin: 15px 0 15px 30px;
    }
    ol.styled li {
        margin: 5px 0 ;
        list-style: decimal;
        text-align: justify;
        list-style-position: outside;
    }
    .btn-yellow {
        height: 36px;
        min-width: 200px;
        line-height: 36px;
        font-size: 14px;
        display: inline-block;
        padding: 0 10px;
        text-align: center;
        font-weight: bold;
        color: #191919;
        border: 0;
        cursor: pointer;
        -webkit-border-radius: 5px;
        -moz-border-radius: 5px;
        border-radius: 5px;
        -webkit-box-sizing: border-box;
        -moz-box-sizing: border-box;
        box-sizing: border-box;
        -webkit-box-shadow: 1px 1px 1px 0 #502a01,inset -1px -1px 1px 0 #904701,inset 2px 2px 1px 0 #fede77;
        -moz-box-shadow: 1px 1px 1px 0 #502a01,inset -1px -1px 1px 0 #904701,inset 2px 2px 1px 0 #fede77;
        box-shadow: 1px 1px 1px 0 #502a01,inset -1px -1px 1px 0 #904701,inset 2px 2px 1px 0 #fede77;
        background: #ffe600;
        background: -moz-linear-gradient(top,#ffda1e 0,#ffe600 100%);
        background: -webkit-gradient(linear,left top,left bottom,color-stop(0%,#ffda1e),color-stop(100%,#ffe600));
        background: -webkit-linear-gradient(top,#ffda1e 0,#ffe600 100%);
        background: -o-linear-gradient(top,#ffda1e 0,#ffe600 100%);
        background: -ms-linear-gradient(top,#ffda1e 0,#ffe600 100%);
        background: linear-gradient(to bottom,#ffda1e 0,#ffe600 100%);
        filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffda1e',endColorstr='#ffe600',GradientType=0);
    }
    .btn-yellow:active {
        -webkit-box-shadow: inset -1px -1px 1px 0 #904701,inset 2px 2px 1px 0 #502a01;
        -moz-box-shadow: inset -1px -1px 1px 0 #904701,inset 2px 2px 1px 0 #502a01;
        box-shadow: inset -1px -1px 1px 0 #904701,inset 2px 2px 1px 0 #502a01;
        position: relative;
        top: 1px;
    }
    .js-file-upload {
        position: relative;
        overflow: hidden;
        cursor: pointer
    }
    .js-file-upload input[type=file] {
        position: absolute;
        top: 0;
        right: 0;
        margin: 0;
        padding: 0;
        font-size: 100px;
        cursor: pointer;
        opacity: 0;
        filter: alpha(opacity=0)
    }

    .progress {
        height: 24px;
        overflow: hidden;
        background-color: #dedede;
        border-radius: 4px;
        -webkit-box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
        box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1)
    }

    .progress .bar {
        float: left;
        width: 0;
        height: 100%;
        font-size: 14px;
        line-height: 22px;
        color: #fff;
        text-align: center;
        background-color: #36a1c2;
        -webkit-box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.15);
        box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.15);
        -webkit-transition: width .3s ease;
        -o-transition: width .3s ease;
        transition: width .3s ease
    }

    .js-form-file-upload {
        margin: 20px 0 0 0
    }

    .js-form-file-upload + .js-form-file-upload {
        margin: 0
    }

    .js-form-file-upload .btn {
        vertical-align: top
    }

    .js-form-file-upload .progress {
        display: inline-block;
        margin: 7px 15px;
        width: 200px;
        height: 25px;
        visibility: hidden;
        vertical-align: top
    }

    .js-form-file-upload .progress .bar {
        line-height: 25px;
        font-weight: bold
    }

    .js-form-file-upload .form-error {
        margin: 5px 0;
        font-size: 90%;
        color: red
    }
</style>
<script>

    function replacePlaceHolder(placeHolder,value)
    {
        $('.text_b_terms').html($('.text_b_terms').html().replace(new  RegExp('<'+placeHolder+'>.*?</'+placeHolder+'>','g'),'<'+placeHolder+'>'+value+'</'+placeHolder+'>'));
    }

    $('document').ready(function(){
        $('#debtor_id').change(function(){
            var active_debtor=$('#debtor_id option:selected');
            $('#payment_discount').val(active_debtor.attr('payment_discount'));
            replacePlaceHolder('currency',active_debtor.attr('currency'));
            calculatePaymentCycle();
        })
    })

    $("#face_value").bind('change',function(){

        calCurrencyRate($('#debtor_id').val());

        replacePlaceHolder('facevalue',addCommas($(this).val()));

        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 calCurrencyRate(val)
    {
        $.post(
                "?do=calcurrencyrate",
                {id:val},
                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');
        //Document type
        var type = $(this).attr('dtype');
        var postData = {'type':type};


        if($('#'+filename).val()!=''){
            if(viewlinks != 'undefined') viewlinks.remove();
            $('<img>',{
                src:'<AJDF:output>'/images/loading1.gif'|siteUrl</AJDF:output>',
                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(); // <-- important

        return false;

    });

    function loadFields(str)
    {
        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());

                        $('#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"
            );

        }

        return false;
    }

    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;
    }

    <AJDF:output>if !empty($messages)</AJDF:output>
    var debtor = '<AJDF:output>$values.debtor_id</AJDF:output>';
    loadFields(debtor);
    <AJDF:output>/if</AJDF:output>


    <AJDF:output>if $values.debtor_id ne ''</AJDF:output>
    calCurrencyRate('<AJDF:output>$values.debtor_id</AJDF:output>');
    replacePlaceHolder('facevalue',addCommas($('#face_value').val()));
    replacePlaceHolder('currency',$('#debtor_id option:selected').attr('currency'));
    calculatePaymentCycle();
    <AJDF:output>/if</AJDF:output>

    function calculatePaymentCycle()
    {
        if (($('#invoice_date').val()>=1 && $('#invoice_date').val()<=31) && ($('#invoice_month').val()>=1 && $('#invoice_month').val()<=12) && ($('#invoice_year').val()>0))
        {
            var invoice_date = new Date($('#invoice_year').val(),($('#invoice_month').val()-1),$('#invoice_date').val());
            invoice_date.setDate(invoice_date.getDate()+parseInt($('#debtor_id option:selected').attr('payment_cycle')));
            replacePlaceHolder('payment_cycle',invoice_date.getDate()+'-'+(invoice_date.getMonth()+1)+'-'+invoice_date.getFullYear());
        }
    }

</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}

</style>
<AJDF:output>include file="footer.html"</AJDF:output>