File: //www/exchange0old/exchange/templates/creditor_trade_update_draft.html
<AJDF:output>include file="header.html"</AJDF:output>
<script type="text/javascript" src="<AJDF:output>$smarty.session.base_url</AJDF:output>/js/jquery.ui.core.js"></script>
<script type="text/javascript" src="<AJDF:output>$smarty.session.base_url</AJDF:output>/js/ui.datepicker.js"></script>
<script type="text/javascript" src="<AJDF:output>'/js/jquery.form.js'|siteUrl</AJDF:output>"></script>
<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"> </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: <AJDF:output>$smarty.session.user.org_ref_id</AJDF:output> </td>
<td align="right" width="" valign="middle" class="txt_11"><AJDF:output>include file='originator_top_dashboard_links.html'</AJDF:output></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"><AJDF:output>include file='left_sidebar.html'</AJDF:output></td>
<td align="right" width="82%" valign="top" id="tool">
<form name="form" action="index.php?do=saverevolvingdraft&id=<AJDF:output>$smarty.get.id</AJDF:output>" 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 <span style="float:right;margin-right:5px;text-decoration:none;"><a class="login_bttn" href="javascript:deleteTrade();">Delete A Trade</a></span></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" style="font-size: 14px; background-color: #f54579">
<AJDF:output>$error_message</AJDF:output>
</div>
<AJDF:output>/if</AJDF:output>
</tr>
</table>
</td>
</tr>
<tr>
<td align="center" valign="top" class="txt_11_red" width="2"> </td>
<td align="left" valign="top" width="33%"> </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>
<AJDF:output>if ($rejectTrade == 2)</AJDF:output>
<tr>
<td align="center" valign="top" class="txt_11_red" width="2"> </td>
<td align="left" valign="top" width="33%"> </td>
<td align="left" valign="top" width="70%"><div class="success-msgbox"><b style="font-size:11px;">Trade Rejected because: </b><AJDF:output>$rejectMsg</AJDF:output></div></td>
</tr>
<AJDF:output>/if</AJDF:output>
<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 <AJDF:output>if $values.inv_type eq '1'</AJDF:output>checked="true"<AJDF:output>/if</AJDF:output>>
Single Invoice <a href="javascript:void(0);" title="<AJDF:output>$help.1.content</AJDF:output>" class="under">(?)</a>
<input type="radio" value="2" tabindex="2" name="inv_type" id="inv_type" <AJDF:output>if $values.inv_type eq '2'</AJDF:output>checked="true"<AJDF:output>/if</AJDF:output>>
Multiple Invoices <a href="javascript:void(0);" title="<AJDF:output>$help.2.content</AJDF:output>" class="under">(?)</a>
<br/>
<span style="color:#FF0000;">
<AJDF:output>$messages.inv_type</AJDF:output>
</span></td>
</tr>
<tr>
<td colspan="3"> </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" 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>" country="<AJDF:output>$i.country_id</AJDF:output>" value="<AJDF:output>$i.invoice_id</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>
<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>
<AJDF:output>if !empty($orpa_list)</AJDF:output>
<tr>
<td colspan="3"> </td>
</tr>
<tr>
<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;">
<option selected disabled value="">Select b-ETR</option>
<AJDF:output>foreach from=$orpa_list item=orpa</AJDF:output>
<option value="<AJDF:output>$orpa.id</AJDF:output>" data-available="<AJDF:output> $orpa.amount-$orpa.c_etr_amount</AJDF:output>" data-attr-discount="<AJDF:output>$orpa.c_etr_early_payment_discount|number_format:2</AJDF:output>"
<AJDF:output>if $values.orpa_id == $orpa.id</AJDF:output>
selected
<AJDF:output>/if</AJDF:output>
>
<AJDF:output>$orpa.reference</AJDF:output> - <AJDF:output>$orpa.orpa_date</AJDF:output> Available: EUR <AJDF:output> $orpa.amount-$orpa.c_etr_amount|number_format:2 </AJDF:output>
</option>
<AJDF:output>/foreach</AJDF:output>
<option value="" data-attr-discount="0.00"
<AJDF:output>if $values.orpa_id === ""</AJDF:output>
selected
<AJDF:output>/if</AJDF:output>
>Without b-ETR</option>
</select>
<a href="javascript:void(0);" title="<AJDF:output>$help.0.content</AJDF:output>" class="under">(?)</a>
<br /><span style="color:#FF0000;"><AJDF:output>$messages.orpa_id</AJDF:output></span>
</td>
</tr>
</table>
</td>
</tr><tr>
<td colspan="3"> </td>
</tr>
<tr class="<AJDF:output>if empty($messages.unscheduled_cetr)</AJDF:output>none<AJDF:output>/if</AJDF:output>">
<td align="center" valign="top" class="txt_11_red">*</td>
<td align="left" valign="top">Unscheduled c-ETR</td>
<td align="left" valign="top">
<input type="checkbox" name="unscheduled_cetr" id="unscheduled_cetr"
<AJDF:output>if empty($messages.unscheduled_cetr)</AJDF:output>disabled<AJDF:output>/if</AJDF:output>
<AJDF:output>if $values.unscheduled_cetr</AJDF:output>checked<AJDF:output>/if</AJDF:output>>
<br /><span style="color:#FF0000;"><AJDF:output>$messages.unscheduled_cetr</AJDF:output></span>
</td>
</tr>
<AJDF:output>/if</AJDF:output>
<tr>
<td colspan="3"> </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">
% <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> </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="" />
<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"> </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;">
<a href="javascript:void(0);" title="<AJDF:output>$help.4.content</AJDF:output>" class="under">(?)</a>
<span class="red_11" style="padding-left:50px;">Learn More about trading strategies <a href="javascript:void(0);" onclick="javascript:window.open('<AJDF:output>'/exchange-help/originator/strategies'|tokenUrl</AJDF:output>','','scrollbars=yes,width=1000,height=800');" style="color:#0033FF; text-decoration:underline; font-size:11px;">here</a></span> <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">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;"> </td>
<td width="75%" align="left"> <input type="hidden" id="totalFaceValue" />
<a href="javascript:void(0);" title="<AJDF:output>$help.22.content</AJDF:output>" class="under">(?)</a></td>
</tr>
</table>
</td>
</tr>
<tr>
<td colspan="3"> </td>
</tr>
<tr class="none vat_included_row">
<td align="center" valign="top"></td>
<td align="left" valign="top">VAT included :</td>
<td align="left" valign="top">
<input type="checkbox" id="vat_included" name="vat_included" <AJDF:output>if $values.vat_included</AJDF:output>checked<AJDF:output>/if</AJDF:output> disabled>
</td>
</tr>
<tr class="none vat_included_row">
<td colspan="3"> </td>
</tr>
<tr>
<td align="center" valign="top" class="txt_11_red">*</td>
<td align="left" valign="top" id="selface">Invoice Date : <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">
<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">
<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>">
<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());
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; }
$.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>
<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>">
<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>">
<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>">
<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"> </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">
<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="top" 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> <AJDF:output>/if</AJDF:output></td>
<td align="left" valign="top">Attach PoD : </td>
<td align="left" valign="top">
<div style="float:left;">
<AJDF:output>if $smarty.session.pofile eq ''</AJDF:output>
<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|storage:"c-purchase-orders"</AJDF:output>" class="viewlink" target="_blank" style="border:1px solid #000; padding:1px 5px;">View</a>
<AJDF:output>/if</AJDF:output>
<a href="javascript:void(0);" 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"> </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">
<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="top" class="txt_11_red">*</td>
<td align="left" valign="top">Attach Invoice : </td>
<td align="left" valign="top">
<div style="float:left;">
<AJDF:output>if $smarty.session.invoicefile eq ''</AJDF:output>
<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|storage:"c-etr-invoices"</AJDF:output>" class="viewlink" target="_blank" style="border:1px solid #000; padding:1px 5px;">View</a>
<AJDF:output>/if</AJDF:output>
<a href="javascript:void(0);" title="<AJDF:output>$help.12.content</AJDF:output>" 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"> </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="submit" tabindex="19" class="login_bttn" value="Submit" name="submits"/>
<input type="hidden" name="debtor_type" value="creditor">
<input type="submit" tabindex="19" class="login_bttn" value="Save" name="save"/> <a href="javascript:void(0);" title="<AJDF:output>$help.15.content</AJDF:output>" class="under" style="padding-right:60px;">(?)</a>
</td>
</tr>
<tr>
<td colspan="3" id="clsAckNots"> </td>
</tr>
</tbody>
</table>
</form>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td align="left" valign="top"> </td>
</tr>
</tbody>
</table>
<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'),
o_etr_field = $('#orpa_list option:selected');
o_etr_discount_value = o_etr_field.attr('data-attr-discount');
payment_discount_value = (o_etr_discount_value && o_etr_discount_value != '0.00')
? o_etr_field.attr('data-attr-discount')
: active_debtor.attr('payment_discount');
$('#payment_discount').val(payment_discount_value);
replacePlaceHolder('currency',active_debtor.attr('currency'));
replacePlaceHolder('payment_cycle',active_debtor.attr('payment_cycle'));
checkVatIncluded();
})
})
$(document).ready(function(){
calCurrencyRate($('#debtor_id').val());
});
$("#face_value").bind('keyup keypress blur 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);
}
checkUnscheduled();
});
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,type:'creditor',orpa_id:$('#orpa_list').val()},
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"
);
}
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 $values.debtor_id ne ''</AJDF:output>
var debtor = '<AJDF:output>$values.debtor_id</AJDF:output>';
loadFields(debtor);
calCurrencyRate(debtor);
replacePlaceHolder('facevalue',addCommas($('#face_value').val()));
var active_debtor=$('#debtor_id option:selected');
replacePlaceHolder('currency',active_debtor.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', formatDate(invoice_date));
}
}
function formatDate(date) {
var dd = date.getDate();
if (dd < 10) dd = '0' + dd;
var mm = date.getMonth() + 1;
if (mm < 10) mm = '0' + mm;
var yy = date.getFullYear();
return yy + '-' + mm + '-' + dd;
}
function deleteTrade()
{
id = '<AJDF:output>$smarty.get.id</AJDF:output>';
if(confirm("Are you sure want to delete this trade?"))
{
window.location = "?do=deletetrade&id="+id+"&view=rev";
}
}
function checkUnscheduled() {
var availableValue = $('#orpa_list option:selected').data('available'),
faceValue = parseFloat($('#face_value').val().replace(",", ".")),
difValue = availableValue - faceValue;
if (difValue < 0 || availableValue <= 0) {
showUnscheduledCheckbox(true);
} else {
showUnscheduledCheckbox(false);
}
}
function showUnscheduledCheckbox(show) {
var checkbox = $('#unscheduled_cetr');
if (show) {
checkbox.prop("disabled", false);
checkbox.closest('tr').removeClass('none');
} else {
checkbox.prop("disabled", true);
checkbox.closest('tr').addClass('none');
}
}
function checkVatIncluded() {
var country = $('#debtor_id option:selected').attr('country');
if (country == 104) {
showVatIncluded(true);
} else {
showVatIncluded(false);
}
}
function showVatIncluded(show) {
var checkbox = $('#vat_included'),
vat_included_row = $('.vat_included_row');
if (show) {
checkbox.prop("disabled", false);
vat_included_row.removeClass('none');
} else {
checkbox.prop("disabled", true);
vat_included_row.addClass('none');
}
}
checkVatIncluded();
$('#orpa_list').on('change', function () {
checkUnscheduled();
loadFields($('#debtor_id').val());
});
<AJDF:output>if empty($messages.unscheduled_cetr)</AJDF:output>checkUnscheduled();<AJDF:output>/if</AJDF:output>
</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;
}
</style>
<AJDF:output>include file="footer.html"</AJDF:output>