parent
088ca06ea7
commit
63c52f3180
@ -0,0 +1,52 @@
|
||||
[% USE Dumper %]
|
||||
[% USE format %]
|
||||
[% money_format = format('%.2f') %]
|
||||
[% write_access = 1 %]
|
||||
|
||||
[%PROCESS 'helpers/datatables_vars.tt'
|
||||
no_auto_helper = 1
|
||||
-%]
|
||||
[%PROCESS 'helpers/modal.tt' -%]
|
||||
[%mf_helper = {
|
||||
ajax_load => 1,
|
||||
ajax_list_refresh => 'template',
|
||||
}%]
|
||||
[%modal_script( m = mf_helper )%]
|
||||
|
||||
[% site_config.title = c.loc('Invoice template for [_1]', provider.name ) -%]
|
||||
|
||||
|
||||
<script type="text/javascript" src="/js/libs/svg-edit/embedapi.js"></script>
|
||||
<script type="text/javascript" src="/js/background.js"></script>
|
||||
<script type="text/javascript" src="/js/jquery.loadJSON.js"></script>
|
||||
<script type="text/javascript" src="/js/jquery.serializeObject.js"></script>
|
||||
<script type="text/javascript" src="/js/modalAjax.js"></script>
|
||||
<script type="text/javascript" src="/js/invoice_template.js"></script>
|
||||
[%PROCESS "invoice/uri_wrapper_js.tt"%]
|
||||
|
||||
|
||||
<div class="row">
|
||||
<span>
|
||||
<a class="btn btn-primary btn-large" href="[% c.uri_for('/back') %]"><i class="icon-arrow-left"></i> [% c.loc('Back') %]</a>
|
||||
</span>
|
||||
|
||||
<span>
|
||||
<a class="btn btn-primary btn-large" href="[%- c.uri_for_action("/invoice/invoice_list", [provider.id]) -%]">[% c.loc('Invoices')%] <i class="icon-edit"></i></a>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
[% IF reseller.first.status != "active" -%]
|
||||
[%messages.unshift( c.loc('Reseller is <b>[_1]</b>', reseller.first.status) ); %]
|
||||
[% END -%]
|
||||
<div class="row" id="messages">
|
||||
[%PROCESS 'helpers/ajax_messages.tt' -%]
|
||||
</div>
|
||||
|
||||
|
||||
<div class="ngcp-separator"></div>
|
||||
[% back_created = 1 -%]
|
||||
|
||||
|
||||
<div id="template_editor_form">
|
||||
[%PROCESS 'invoice/template_editor_form_alt.tt' %]
|
||||
</div>
|
||||
@ -0,0 +1,106 @@
|
||||
[%# USE FillInForm %]
|
||||
<script>
|
||||
function formToUri(q){
|
||||
return q+'?'+$('form[id=template_editor]').serialize();
|
||||
}
|
||||
function formSerialize(){
|
||||
return $('form[id=template_editor]').serialize();
|
||||
}
|
||||
function getTtIdVal(){
|
||||
return $('form[id=template_editor] :input[name=tt_id]').val();
|
||||
}
|
||||
</script>
|
||||
<form name="template_editor" id="template_editor" action="[%- c.uri_for_action('/invoice/template_view', [provider.id]) -%]" class="form-horizontal" enctype="multipart/form-data" method="post">
|
||||
<input type="hidden" name="tt_id" value="[%tt_id%]">
|
||||
<input type="hidden" name="provider_id" value="[%provider.id%]">
|
||||
<span>
|
||||
<a class="btn btn-primary btn-small" href="javascript:
|
||||
var previewWindow = window.open('','_blank');
|
||||
previewWindow.blur;
|
||||
saveTemplate({
|
||||
provider_id:'[%provider.id%]',
|
||||
tt_id: getTtIdVal(),
|
||||
},
|
||||
function(httpResponse, q, data) {
|
||||
previewWindow.location.href = uriForAction({
|
||||
tt_sourcestate: 'saved',
|
||||
tt_output_type : 'pdf',
|
||||
tt_id: getTtIdVal(),
|
||||
provider_id: '[%provider.id%]',});
|
||||
previewWindow.focus;
|
||||
}
|
||||
);
|
||||
void(0);">[% c.loc('Preview')%] <i class="icon-edit"></i></a>
|
||||
</span>
|
||||
<span id="load_saved_control">
|
||||
<a class="btn btn-secondary btn-small" data-confirm="[%c.loc('Overwrite changes');%]" href="javascript:fetchInvoiceTemplateData({
|
||||
tt_sourcestate: 'saved',
|
||||
tt_id: getTtIdVal(),
|
||||
provider_id: '[%provider.id%]',
|
||||
});void(0);" cancel-hide="1">[% c.loc('Discard Changes')%] <i class="icon-edit"></i></a>
|
||||
</span>
|
||||
<span>
|
||||
<a class="btn btn-primary btn-small" onclick="
|
||||
//alert('tt_id='+getTtIdVal()+';');
|
||||
saveTemplate({
|
||||
provider_id: '[%provider.id%]',
|
||||
tt_id: getTtIdVal(),
|
||||
});void(0);">[% c.loc('Save template')%] <i class="icon-disk"></i></a>
|
||||
</span>
|
||||
[%IF viewmode == 'development' %]
|
||||
<div class="ngcp-separator"></div>
|
||||
<span>
|
||||
<a class="btn btn-secondary btn-small" data-confirm="[%c.loc('Overwrite changes');%]" href="javascript:fetchInvoiceTemplateData({
|
||||
tt_sourcestate: 'default',
|
||||
tt_id: getTtIdVal(),
|
||||
provider_id: '[%provider.id%]',
|
||||
});void(0);" cancel-hide="1">[% c.loc('Load default')%] <i class="icon-edit"></i></a>
|
||||
</span>
|
||||
|
||||
<span id="load_previewed_control" style="display:none;visibility:hidden;">
|
||||
<a class="btn btn-secondary btn-small" data-confirm="[%c.loc('Overwrite changes');%]" href="javascript:fetchInvoiceTemplateData({
|
||||
tt_sourcestate: 'previewed',
|
||||
tt_id: getTtIdVal(),
|
||||
provider_id: '[%provider.id%]',
|
||||
});void(0);" cancel-hide="1">[% c.loc('Load previewed')%] <i class="icon-edit"></i></a>
|
||||
</span>
|
||||
<div class="ngcp-separator"></div>
|
||||
<span>
|
||||
<a class="btn btn-primary btn-small" href="javascript:window.open(uriForAction({
|
||||
tt_sourcestate: 'previewed',
|
||||
tt_output_type : 'svg',
|
||||
tt_id: getTtIdVal(),
|
||||
provider_id: '[%provider.id%]',
|
||||
}),'_blank');void(0);">[% c.loc('Previewed SVG')%] <i class="icon-edit"></i></a>
|
||||
</span>
|
||||
<span>
|
||||
<a class="btn btn-primary btn-small" href="javascript:window.open(uriForAction({
|
||||
tt_sourcestate: 'saved',
|
||||
tt_output_type : 'svg',
|
||||
tt_id: getTtIdVal(),
|
||||
provider_id: '[%provider.id%]',
|
||||
}),'_blank');void(0);">[% c.loc('Saved SVG')%] <i class="icon-edit"></i></a>
|
||||
</span>
|
||||
<span>
|
||||
<a class="btn btn-primary btn-small" href="javascript:window.open(uriForAction({
|
||||
tt_sourcestate: 'saved',
|
||||
tt_output_type : 'pdf',
|
||||
tt_id: getTtIdVal(),
|
||||
provider_id: '[%provider.id%]',
|
||||
}),'_blank');void(0);">[% c.loc('Saved PDF')%] <i class="icon-edit"></i></a>
|
||||
</span>
|
||||
[%END%]
|
||||
[%initial = 'saved'%]
|
||||
<div class="ngcp-separator"></div>
|
||||
<iframe
|
||||
type="text/html"
|
||||
src="/js/libs/svg-edit/svg-editor.htm" id="svgedit" onload="
|
||||
init_embed();
|
||||
fetchSvgToEditor({
|
||||
tt_viewmode: 'raw',
|
||||
tt_sourcestate: '[%initial%]',
|
||||
provider_id: '[%provider.id%]',
|
||||
tt_id: getTtIdVal(),
|
||||
});" width="1300px" height="1500px" style="border-width:0px;"></iframe>
|
||||
</div>
|
||||
</form>
|
||||
@ -0,0 +1,54 @@
|
||||
[% USE Dumper %]
|
||||
[% USE format %]
|
||||
[% money_format = format('%.2f') %]
|
||||
[% IF !c.user.read_only && (c.user.roles == 'admin' || c.user.roles == 'reseller') -%]
|
||||
[% write_access = 1 %]
|
||||
[%END%]
|
||||
<script>
|
||||
var staticContainerId='template_list';
|
||||
</script>
|
||||
[%IF template_list.size %]
|
||||
<table class="table table-bordered table-striped table-highlight table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>[% c.loc('Active') %]</th>
|
||||
<th>[% c.loc('Id') %]</th>
|
||||
<th>[% c.loc('Name') %]</th>
|
||||
<th>[% c.loc('Type') %]</th>
|
||||
<th class="ngcp-actions-column"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
[% FOR template IN template_list -%]
|
||||
[%# Dumper.dump_html(template_list.as_query)%]
|
||||
[%# Dumper.dump_html(template)%]
|
||||
<tr class="sw_action_row" data-id="[%template.get_column('id')%]">
|
||||
<td style="font-size: 20px;">[%IF template.get_column('is_active') > 0; '✓'; END%]</td><!--✓-->
|
||||
<td>[% template.get_column('id') %]</td>
|
||||
<td>[% template.get_column('name') %]</td>
|
||||
<td>[% template.get_column('type') %]</td>
|
||||
<td class="ngcp-actions-column">
|
||||
<div class="sw_actions">
|
||||
[% IF write_access -%]
|
||||
<a class="btn btn-small btn-primary"
|
||||
onclick="fetch_into('template_info_form', '[%- c.uri_for_action("/invoice/template_info", [provider.id]) -%]','item=template_info&tt_id=[%template.get_column('id')%]',function(){modalFormScript();});void(0);
|
||||
">
|
||||
<i class="icon-edit"></i> [% c.loc('Edit template info') %]
|
||||
</a>
|
||||
<a class="btn btn-small btn-primary" href="[%- c.uri_for_action("/invoice/template_alt", [reseller.first.id, template.get_column('id')]) -%]">
|
||||
<i class="icon-edit"></i> [% c.loc('Edit template') %]
|
||||
</a>
|
||||
<a class="btn btn-small btn-secondary ngcp-noback-button" data-confirm="Delete"
|
||||
href="javascript:fetch_into(staticContainerId, '[%- c.uri_for_action("/invoice/template_delete", [provider.id, template.get_column('id')]) -%]','',function(){ refreshMessagesAjax();mainWrapperInit();});void(0);" cancel-hide="1">
|
||||
<i class="icon-trash"></i> [% c.loc('Delete') %]
|
||||
</a>
|
||||
[%END%]
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
[%END%]
|
||||
</tbody>
|
||||
</table>
|
||||
[%END%]
|
||||
|
||||
|
||||
@ -0,0 +1,38 @@
|
||||
<script type="text/javascript">
|
||||
var uriForAction = function( data, type ){
|
||||
//we can think about getting URIs via ajax )
|
||||
//also we can think about more regular wrapper for all uri used in datatables
|
||||
var q_template;
|
||||
switch(type){
|
||||
case 'template_previewed':
|
||||
//q_template = '[%- c.uri_for_action("/invoice/template_view", ['provider_id','svg','parsed','previewed','svg','tt_id']) -%]';
|
||||
q_template = '[%- c.uri_for_action("/invoice/template_view", ['provider_id']) -%]'+'/svg/parsed/previewed/svg/tt_id';
|
||||
break;
|
||||
case 'template_saved':
|
||||
//q_template = '[%- c.uri_for_action("/invoice/template_view", ['provider_id','svg','parsed','saved','svg','tt_id']) -%]';
|
||||
q_template = '[%- c.uri_for_action("/invoice/template_view", ['provider_id']) -%]'+'/svg/parsed/saved/tt_output_type/tt_id';
|
||||
break;
|
||||
case 'template_list':
|
||||
q_template = '[%- c.uri_for_action("/invoice/template_list", ['provider_id']) -%]';
|
||||
break;
|
||||
case 'messages':
|
||||
q_template = '[%- c.uri_for_action("/invoice/messages") -%]';
|
||||
break;
|
||||
case 'template':
|
||||
default:
|
||||
//q_template = '[%- c.uri_for_action("/invoice/template_view", ['provider_id','tt_type','tt_viewmode','tt_sourcestate','tt_output_type','tt_id']) -%]';
|
||||
q_template = '[%- c.uri_for_action("/invoice/template_view", ['provider_id']) -%]'+'/tt_type/tt_viewmode/tt_sourcestate/tt_output_type/tt_id';
|
||||
break;
|
||||
}
|
||||
if(!data.tt_id){data.tt_id = '';}
|
||||
if(!data.tt_type){data.tt_type = 'svg';}
|
||||
if(!data.tt_output_type){data.tt_output_type = 'svg';}
|
||||
if(!data.tt_viewmode){data.tt_viewmode = 'both';}
|
||||
var params = ['provider_id','tt_id','tt_type','tt_output_type','tt_viewmode','tt_sourcestate'];
|
||||
params.forEach(function(key){
|
||||
q_template=q_template.replace(key,data[key]);
|
||||
});
|
||||
q_template=q_template.replace(/\/+$/,'');
|
||||
return q_template;
|
||||
}
|
||||
</script>
|
||||
Loading…
Reference in new issue