<div class="help">
    <h2>{{ 'File information'|trans }}</h2>
</div>

<table class="tableStatic wide">
    <tbody>
        <tr class="noborder">
            <td>{{ 'Filename'|trans }}:</td>
            <td>{{ service.filename  }}</td>
        </tr>

        <tr>
            <td>{{ 'Location'|trans }}:</td>
            <td>{{ service.path }}</td>
        </tr>
        
        <tr>
            <td>{{ 'Downloads'|trans }}:</td>
            <td>{{ service.downloads }}</td>
        </tr>
    </tbody>
    <tfoot>
        <tr>
            <td colspan="2"></td>
        </tr>
    </tfoot>
</table>

<div class="help">
    <h2>{{ 'Upload new file for this order'|trans }}</h2>
    <p>{{ 'Use this function to update existing order file. Client will be able to download new file from client area'|trans }}</p>
</div>

<form method="post" action="" class="mainForm" enctype="multipart/form-data" target="uploadframe" id="bb-upload-form">
<fieldset>
    
    <div class="rowElem">
        <label>{{ 'Upload new file'|trans }}:</label>
        <div class="formRight noborder">
            <input type="file" name="file_data" id="file_data">
        </div>
        <div class="fix"></div>
    </div>

    <input type="submit" value="{{ 'Upload'|trans }}" class="greyishBtn submitForm" id="bb-upload-button"/>
</fieldset>

<input type="hidden" name="order_id" value="{{ order.id }}">
</form>

<script type="text/javascript">
$(function() {
    $('body').append('<iframe id="uploadframe" name="uploadframe" style="display:none" />');
    $('#bb-upload-form').submit(function(){
        $(this).attr('action', bb.restUrl('admin/servicedownloadable/update'));
        iframe = $('#uploadframe').load(function () {
            response = iframe.contents().find('body');
            data = $.parseJSON(response.text());
            if(data.error) {
                bb.error(data.error.message, data.error.code);
            }
            if(data.result) {
                bb.msg('File was uploaded');
            }
            setTimeout(function (){	response.html(''); }, 1);
        });
    });
});
</script>