File: //www/exchange0old/exchange/templates/post_trade_documents.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>:: Credebt Exchange ::</title>
<link rel="stylesheet" href="/exchange/admin/css/stylesheet.css" type="text/css" />
<link type="text/css" href="/exchange/css/bootstrap.min.css?ver=2" rel="stylesheet" />
<script type="text/javascript" src="<AJDF:output>'/js/jquery.js'|siteUrl</AJDF:output>"></script>
<script type="text/javascript" src="/exchange/js/bootstrap-datepicker-1.7.min.js"></script>
<link type="text/css" href="/exchange/css/bootstrap-datepicker3.standalone.min.css" rel="stylesheet" />
<style type="text/css">
input[type="file"] {
display: inline-block;
}
</style>
</head>
<body style="background: none;">
<h4 style="color: #FFF;background: #555;margin: 0;padding: 15px 0 15px 0;">Post Trade Documents</h4>
<form action="index.php?do=post-trade-documents&invoice_id=<AJDF:output>$invoice_id</AJDF:output>" method="post" enctype="multipart/form-data" id="documents_form">
<table cellpadding="0" cellspacing="0" border="0" width="100%" class="table table-hover table-striped table-responsive">
<tbody>
<tr>
<td colspan="4" style="padding: 0!important;">
<table class="table table-hover table-striped table-responsive" style="margin: 0" border="1">
<tbody id="po_list">
<AJDF:output>foreach from=$documents item=document</AJDF:output>
<tr>
<td colspan="4" style="padding: 0!important;">
<table class="table table-hover table-striped table-responsive" style="margin: 0">
<tr>
<td colspan="4">
<b><AJDF:output>$document.name</AJDF:output> (Outstanding Days: <AJDF:output>$document.date_diff</AJDF:output>)</b>
</td>
</tr>
<tr>
<td>Requested Date <sup class="txt_12_red">*</sup></td>
<td>
<AJDF:output>$document.requested_date|date_format:"%Y-%m-%d"</AJDF:output>
</td>
<td>Expected Date <sup class="txt_12_red">*</sup></td>
<td>
<AJDF:output>$document.expected_date|date_format:"%Y-%m-%d"</AJDF:output>
</td>
</tr>
<tr>
<td>Document attachment <sup class="txt_12_red">*</sup></td>
<td>
<AJDF:output>assign var="fieldName" value="document[`$document.document_id`][file]"</AJDF:output>
<input type="file" class="browse" value="" style="width:auto;" name="<AJDF:output>$fieldName</AJDF:output>" <AJDF:output>if !$document.path</AJDF:output>data-attr="new_document_file"<AJDF:output> /if</AJDF:output>>
<AJDF:output>if $document.path</AJDF:output>
<input type="hidden" name="document[<AJDF:output>$document.document_id</AJDF:output>][exist_document]" value="1"/>
<button onclick="window.open('<AJDF:output>$document.path|storage:"debtor-documents"</AJDF:output>'); return false;"><span class="glyphicon glyphicon-search" aria-hidden="true"></span> View</button>
<AJDF:output> /if</AJDF:output>
<br/>
<span style="color:#FF0000;"> <AJDF:output>$Errors.$fieldName</AJDF:output></span>
</td>
<td>Document amount <sup class="txt_12_red">*</sup></td>
<td>
<AJDF:output>assign var="fieldName" value="document[`$document.document_id`][amount]"</AJDF:output>
<input type="text" class="text_b" name="<AJDF:output>$fieldName</AJDF:output>" value="<AJDF:output>$document.amount</AJDF:output>" />
<br/>
<span style="color:#FF0000;"> <AJDF:output>$Errors.$fieldName</AJDF:output></span>
</td>
</tr>
</table>
</td>
</tr>
<AJDF:output>/foreach</AJDF:output>
</tbody>
</table>
</td>
</tr>
<tr>
<td colspan="4" align="center">
<input name="save" value="Save " class="btn btn-primary" type="submit"
onclick="submitForm();return false;">
</td>
</tr>
</tbody>
</table>
</form>
<script>
function submitForm() {
var $form = $('#documents_form'),
$fileData = {};
$form.find('span').each(function () {
$(this).html('');
});
$('input[data-attr=new_document_file]').each(function () {
$fileData[$(this).attr('name')] = $(this).val();
});
$.ajax({
url: $form.attr('action'),
type: 'post',
data: $form.serialize() + '&' + $.param($fileData),
success: function (data) {
data = $.parseJSON(data);
console.log(data);
if(data.success){
$form.submit();
}else{
$.each(data.errors, function (key, value) {
$('[name="' + key + '"]').parent().find('span').html(value);
})
}
}
});
}
$(document).ready(function () {
$('.input-expected-date').datepicker({
format: "yyyy-mm-dd",
startDate: "0d",
todayHighlight: true
});
$('.input-orpa-date').datepicker({
endDate: "0d",
startDate: "-365d",
format: "yyyy-mm-dd",
todayHighlight: true
});
$('.input-po-date').datepicker({
startDate: "0d",
format: "yyyy-mm-dd",
todayHighlight: true
});
});
</script>
</body>
</html>