MT#5879 Cleanup invoice template editing. WIP.

Fetching default template from file works.
TBD: saving, viewing from saved, previewing PDF.
mr3.3.1
Andreas Granig 12 years ago
parent b6533b1a1f
commit a88724c0c4

@ -32,7 +32,7 @@ sub template_list :Chained('/') :PathPart('invoicetemplate') :CaptureArgs(0) :Do
{ name => 'is_active', search => 1, title => $c->loc('Active') },
]);
$c->stash->{template} = 'invoice/template_list.tt';
$c->stash(template => 'invoice/template_list.tt');
}
sub root :Chained('template_list') :PathPart('') :Args(0) {
@ -253,6 +253,43 @@ sub delete :Chained('base') :PathPart('delete') {
NGCP::Panel::Utils::Navigation::back_or($c, $c->uri_for('/invoicetemplate'));
}
sub edit_content :Chained('base') :PathPart('editcontent') :Args(0) {
my ($self, $c) = @_;
$c->stash(template => 'invoice/template.tt');
}
sub get_content_ajax :Chained('base') :PathPart('editcontent/get/ajax') :Args(0) {
my ($self, $c, @args) = @_;
my $tmpl = $c->stash->{tmpl};
my $content;
if($tmpl->base64_saved) {
$content = $tmpl->base64_saved;
} else {
my $default = 'invoice/default/invoice_template_svg.tt';
my $t = Template->new({
ENCODING => 'UTF-8',
RELATIVE => 1,
INCLUDE_PATH => './share/templates:/usr/share/ngcp-panel/templates',
});
try {
$content = $t->context->insert($default);
} catch($e) {
# TODO: handle error!
$c->log->error("failed to load default invoice template: $e");
return;
}
}
$c->response->content_type('text/html');
$c->response->body($content);
}
__PACKAGE__->meta->make_immutable;
1;

@ -1,85 +0,0 @@
package NGCP::Panel::Form::Invoice::Basic;
use Sipwise::Base;
use HTML::FormHandler::Moose;
#extends qw/HTML::FormHandler NGCP::Panel::Form::ValidatorBase/;
extends 'NGCP::Panel::Form::ValidatorBase';
use Moose::Util::TypeConstraints;
use DateTime;
use DateTime::Format::Strptime;
has_field 'submitid' => ( type => 'Hidden' );
sub build_render_list {[qw/submitid fields actions/]}
sub build_form_element_class { [qw/form-horizontal/] }
has_field 'submitid' => ( type => 'Hidden' );
#has_field 'contract.id' => (
# type => '+NGCP::Panel::Field::DataTable',
# label => 'Client',
# do_label => 0,
# do_wrapper => 0,
# required => 1,
# template => 'helpers/datatables_field.tt',
# ajax_src => '/contact/ajax_noreseller',
# table_titles => ['#', 'First Name', 'Last Name', 'Email'],
# table_fields => ['id', 'firstname', 'lastname', 'email'],
#);
has_field 'invoice_id' => (
type => 'Integer',
required => 0,
);
has_field 'save' => (
type => 'Button',
value => 'Generate',
element_class => [qw/btn btn-primary/],
do_label => 0,
);
has_field 'client_contract_id' => (
type => 'Hidden',
required => 0,
);
has_block 'fields' => (
tag => 'div',
class => [qw/modal-body/],
render_list => [qw/invoice_id client_contract_id/],
);
has_block 'actions' => (
tag => 'div',
class => [qw/modal-footer/],
render_list => [qw/save/],
);
sub validate {
my $self = shift;
}
1;
=head1 NAME
NGCP::Panel::Form::InvoiceTemplate
=head1 DESCRIPTION
Form to modify an invoice template.
=head1 METHODS
=head1 AUTHOR
Irina Peshinskaya
=head1 LICENSE
This library is free software. You can redistribute it and/or modify
it under the same terms as Perl itself.
=cut
# vim: set tabstop=4 expandtab:

@ -1,119 +0,0 @@
package NGCP::Panel::Form::Invoice::Generate;
use HTML::FormHandler::Moose;
extends 'NGCP::Panel::Form::ValidatorBase';
use DateTime;
use DateTime::Format::Strptime;
use NGCP::Panel::Utils::DateTime;
has_field 'submitid' => ( type => 'Hidden' );
has '+widget_wrapper' => ( default => 'Bootstrap' );
sub build_render_list {[qw/submitid fields actions/]}
sub build_form_element_class { [qw/form-horizontal/] }
has_field 'client_contract_id' => (
is => 'rw',
type => '+NGCP::Panel::Field::DataTable',
label => 'Contract',
#name => 'client_contract_id',
do_label => 0,
do_wrapper => 0,
required => 1,
template => 'helpers/datatables_field.tt',
#we will set it in controller
#ajax_src => $c->uri_for_action( '/invoice/ajax_datatables_data', [ $self->provider_id, 'invoice_list_data' ],
ajax_src => '',
table_titles => ['Contract Id', 'First Name', 'Last Name', 'Email'],
table_fields => ['contracts.id', 'firstname', 'lastname', 'email'],
);
has_field 'start' => (
type => '+NGCP::Panel::Field::DatePicker',
label => 'Start Date',
default => NGCP::Panel::Utils::DateTime::current_local()->truncate(to => 'month')->ymd,
required => 1,
);
has_field 'end' => (
type => '+NGCP::Panel::Field::DatePicker',
label => 'End Date',
default => NGCP::Panel::Utils::DateTime::current_local()->truncate(to => 'month')->add( months => 1)->subtract(seconds=>1)->ymd,
required => 1,
);
has_field 'save' => (
type => 'Button',
value => 'Generate',
element_class => [qw/btn btn-primary/],
do_label => 0,
);
#has_field 'client_contract_id_hidden' => (
# type => 'Hidden',
# required => 1,
#);
has_block 'fields' => (
tag => 'div',
class => [qw/modal-body/],
render_list => [qw/start end client_contract_id/],
);
has_block 'actions' => (
tag => 'div',
class => [qw/modal-footer/],
render_list => [qw/save/],
);
sub validate {
my $self = shift;
my $start = $self->field('start');
my $end = $self->field('end');
my $parser = DateTime::Format::Strptime->new(
#pattern => '%Y-%m-%d %H:%M:%S',
pattern => '%Y-%m-%d',
);
my $sdate = $parser->parse_datetime($start->value);
unless($sdate) {
$start->add_error("Invalid date format, must be YYYY-MM-DD hh:mm:ss");
}
my $edate = $parser->parse_datetime($end->value);
unless($edate) {
$end->add_error("Invalid date format, must be YYYY-MM-DD hh:mm:ss");
}
#unless(DateTime->compare($sdate, $edate) == -1) {
# my $err_msg = 'End time must be later than start time';
# $start->add_error($err_msg);
# $end->add_error($err_msg);
#}
#if(!$self->backend->checkSipPbxAccount()){
#}
}
1;
=head1 NAME
NGCP::Panel::Form::InvoiceTemplate
=head1 DESCRIPTION
Form to modify an invoice template.
=head1 METHODS
=head1 AUTHOR
Irina Peshinskaya
=head1 LICENSE
This library is free software. You can redistribute it and/or modify
it under the same terms as Perl itself.
=cut
# vim: set tabstop=4 expandtab:

@ -1,59 +0,0 @@
package NGCP::Panel::Form::Invoice::Send;
use HTML::FormHandler::Moose;
extends 'NGCP::Panel::Form::ValidatorBase';
has_field 'submitid' => ( type => 'Hidden' );
has '+widget_wrapper' => ( default => 'Bootstrap' );
sub build_render_list {[qw/submitid fields actions/]}
sub build_form_element_class { [qw/form-horizontal/] }
has_field 'email' => (
type => 'Text',
label => 'Emails',
required => 1,
);
has_field 'save' => (
type => 'Button',
value => 'Send',
element_class => [qw/btn btn-primary/],
do_label => 0,
);
has_block 'fields' => (
tag => 'div',
class => [qw/modal-body/],
render_list => [qw/email/],
);
has_block 'actions' => (
tag => 'div',
class => [qw/modal-footer/],
render_list => [qw/save/],
);
1;
=head1 NAME
NGCP::Panel::Form::InvoiceTemplate
=head1 DESCRIPTION
Form to modify an invoice template.
=head1 METHODS
=head1 AUTHOR
Irina Peshinskaya
=head1 LICENSE
This library is free software. You can redistribute it and/or modify
it under the same terms as Perl itself.
=cut
# vim: set tabstop=4 expandtab:

@ -1,129 +0,0 @@
package NGCP::Panel::Form::Invoice::Template;
use HTML::FormHandler::Moose;
extends 'NGCP::Panel::Form::ValidatorBase';
use Moose::Util::TypeConstraints;
use HTML::FormHandler::Widget::Block::Bootstrap;
enum 'TemplateType' => [ qw/svg html/ ];#html
enum 'TemplateTypeOutput' => [ qw/svg html pdf json svgzip htmlzip pdfzip/ ];#html
enum 'TemplateViewMode' => [ qw/raw parsed both/ ];
enum 'TemplateSourceState' => [ qw/saved previewed default/ ];
#no Moose::Util::TypeConstraints;
has '+widget_wrapper' => ( default => 'Bootstrap' );
has '+use_fields_for_input_without_param' => ( default => 1 );
sub build_render_list {[qw/fields actions/]}
sub build_form_element_class { [qw/form-horizontal/] }
has_field 'submitid' => ( type => 'Hidden' );
has_field 'tt_type' => (
type => 'Text',
required => 1,
default => 'svg',
apply => [
{ type => 'TemplateType' },
],
);
has_field 'tt_output_type' => (
type => 'Text',
required => 1,
default => 'svg',
apply => [
{ type => 'TemplateTypeOutput' },
],
);
has_field 'tt_viewmode' => (
type => 'Text',
required => 0,
apply => [ 'TemplateViewMode' ],
#check => [ qw/raw parsed/ ],
default => 'parsed',
);
has_field 'tt_sourcestate' => (
type => 'Text',
required => 1,
default => 'saved',
apply => [ 'TemplateSourceState' ],
#check => [ qw/saved previewed/ ],
);
has_field 'tt_string' => (
type => 'Text',
#default => \&
#apply => [ { check => \&validate_tt_string } ],
required => 0,
);
has_field 'provider_id' => (
type => 'Hidden',
#default => \&
#apply => [ { check => \&validate_tt_string } ],
required => 1,
);
has_field 'tt_id' => (
type => 'Hidden',
#default => \&
#apply => [ { check => \&validate_tt_string } ],
required => 0,
);
has_field 'name' => (
type => 'Text',
#default => '',
#apply => [ { check => \&validate_tt_string } ],
required => 1,
);
has_field 'is_active' => (
type => 'Checkbox',
default => '0',
#apply => [ { check => \&validate_tt_string } ],
required => 0,
);
has_field 'save' => (
type => 'Button',
value => 'Save',
element_class => [qw/btn btn-primary/],
label => '',
);
has_block 'fields' => (
tag => 'div',
class => [qw/modal-body/],
render_list => [qw/name tt_id is_active submitid provider_id/],
);
has_block 'actions' => (
tag => 'div',
class => [qw/modal-footer/],
render_list => [qw/save/],
);
1;
=head1 NAME
NGCP::Panel::Form::InvoiceTemplate
=head1 DESCRIPTION
Form to modify an invoice template.
=head1 METHODS
=head1 AUTHOR
Irina Peshinskaya
=head1 LICENSE
This library is free software. You can redistribute it and/or modify
it under the same terms as Perl itself.
=cut
# vim: set tabstop=4 expandtab:

@ -38,20 +38,20 @@ template_variables.description.import({
});
IF 1 || !provider;
DEFAULT provider.company='Providercompany Inc';
DEFAULT provider.street='Providerstreet 99';
DEFAULT provider.city='Providercity';
DEFAULT provider.postcode='12345';
DEFAULT provider.country='Providercountry';
DEFAULT provider.comregnum='12345';
DEFAULT provider.iban='1234567890ABC';
DEFAULT provider.bic='ABCDEFG1234';
DEFAULT provider.vat='XY1234567';
DEFAULT provider.email='provider@example.org';
DEFAULT provider.phone='+1 234 567890';
DEFAULT provider.mobile='+1 234 567890';
DEFAULT provider.faxnumber='+1 234 567890';
DEFAULT provider.city='Provider City';
DEFAULT provider.company='Provider Gmbh.';
DEFAULT provider.country='Provider-Country';
DEFAULT provider.email='office@provider.com';
DEFAULT provider.fax='+1 650 1234566';
DEFAULT provider.fn='305595';
DEFAULT provider.iban='1234567890ABC';
DEFAULT provider.mobile='+1 650 1234568';
DEFAULT provider.phone='+1 650 1234567';
DEFAULT provider.postcode='65104';
DEFAULT provider.street='Provider Street';
DEFAULT provider.url='http://www.provider.com/';
DEFAULT provider.vat='UATAA1234AA1234';
ELSE;
FOREACH i in ['bic','city','company','country','email','fax','fn','iban','mobile','phone','postcode','street','url','vat'];
TRY;
@ -73,15 +73,16 @@ template_variables.description.import({
});
IF !client.id;
DEFAULT client.firstname='Firstname';
DEFAULT client.lastname='Lastname';
DEFAULT client.street='Clientstreet 12/3/45';
DEFAULT client.city='Clientcity';
DEFAULT client.postcode='98765';
DEFAULT client.country='Clientcountry';
DEFAULT client.id=Math.int(Math.rand(999999))|format('%06d');
DEFAULT client.iban='AT1234567890';
DEFAULT client.bic='ABCDEFG1234';
DEFAULT client.city='Client City';
DEFAULT client.country='Client-Country';
DEFAULT client.title='Herr Dipl. Ing (FH)';
DEFAULT client.firstname='Client Firstname';
DEFAULT client.id=Math.int(Math.rand(999999))|format('%06d');
DEFAULT client.lastname='Client-Lastname Sr.';
DEFAULT client.postcode='65104';
DEFAULT client.sepa='AT1234567890';
DEFAULT client.street='Client Street';
DEFAULT client.vatid='AA1234';
END;
@ -89,7 +90,7 @@ END;
template_variables.description.import({
bp => {
'name' => 'Billing Profile name',
'interval_charge' => 'Recurring fee for invoice period',
'interval_charge' => 'Constant fee for invoice period.',
}
});
@ -109,9 +110,9 @@ DEFAULT bp.fraud_interval_notify = '';
DEFAULT bp.fraud_daily_limit = '';
DEFAULT bp.fraud_daily_lock = '';
DEFAULT bp.fraud_daily_notify = '';
DEFAULT bp.currency = 'USD';
DEFAULT bp.vat_rate = '20';
DEFAULT bp.vat_included = 0;
DEFAULT bp.currency = '';
DEFAULT bp.vat_rate = '';
DEFAULT bp.vat_included = '';
END;
invoice_details_zones = [];
@ -158,4 +159,4 @@ IF !invoice_details_zones.size();
i = i + 1;
END;
END;
%]
%]

@ -1,5 +1,5 @@
<!--{[%PROCESS 'invoice/invoice_template_lorem.tt' -%]}-->
<!--{[%PROCESS 'invoice/invoice_template_aux.tt' -%]}-->
<!--{[%PROCESS 'invoice/default/invoice_template_lorem.tt' -%]}-->
<!--{[%PROCESS 'invoice/default/invoice_template_aux.tt' -%]}-->
<!--{[%money_format = format('%.2f') %]}-->
<!--{[%row_vertical_interval = 10 -%]}-->
<!--{[%alltitlepages = 2 -%]}-->
@ -34,17 +34,13 @@
<g y="0" x="0" width="841" height="595" id="titlepage_1" display="none">
<title>TitlePage_1</title>
<text x="65" y="155" class="ps00 ps20">[%provider.company%], [%provider.street%], [%provider.postcode%] [% provider.city%], [%provider.country%]</text>
[% IF client.company -%]
<text x="65" y="177" class="ps00 ps23">[%client.company%]</text>
[% ELSE -%]
<text x="65" y="155" class="ps00 ps20">[%provider.company%][%if(', ', provider.postcode _ ' ' _ provider.city ) %][%if(', ', provider.street )%]</text>
<text x="65" y="165" class="ps00 ps23">[%client.title%]</text>
<text x="65" y="177" class="ps00 ps23">[%client.firstname%] [%client.lastname%]</text>
[% END -%]
<text x="65" y="189" class="ps00 ps23">[%client.street%]</text>
<text x="65" y="201" class="ps00 ps23">[%client.postcode%] [%client.city%]</text>
<text x="65" y="213" class="ps00 ps23">[%client.country%]</text>
<text x="65" y="249" class="ps00 ps23">Contract Owner: [% client.company ? client.company : client.firstname _ ' ' _ client.lastname%]</text>
<text x="65" y="249" class="ps00 ps23">Anschlussinhaber: [%client.firstname%] [%client.lastname%]</text>
<text x="400" y="155" class="ps00 ps21">Rechnung</text>
<text x="400" y="170" class="ps00 ps22">Rechnungsnummer</text>
@ -299,21 +295,6 @@
<!--{[%END-%]}-->
<!--{[%MACRO bgpage( page, pagelocal, pageslocalnum ) BLOCK-%]}-->
<!--page-->
<g id="bgpage_1" display="none">
<title>Background_Data</title>
<!--{[%IF page >= alltitlepages %]}-->
<text x="65" y="165" class="ps00 ps23">[%client.title%]</text>
<text x="65" y="177" class="ps00 ps23">[%client.firstname%] [%client.lastname%]</text>
<text x="65" y="189" class="ps00 ps23">[%client.street%]</text>
<text x="65" y="201" class="ps00 ps23">[%client.postcode%] [%client.city%]</text>
<text x="65" y="247" class="ps00 ps23">Kunde [%client.id%]</text>
<text x="540" y="120" class="ps00 ps20" text-anchor="end">Seite [%page%]</text>
<text x="550" y="225" class="ps00 ps23" text-anchor="end">Datum [%date.format(datenow.value,'%d.%m.%Y')%]</text>
<!--{[%END%]}-->
</g>
<!--/page-->
<!--page-->
<g id="bgpage_2">
<title>Background</title>

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 27 KiB

@ -1,41 +0,0 @@
[%# USE Dumper %]
[% USE date %]
[% USE Math %]
[%# Dumper.dump(invoice_details_zones)%]
[%# invoice_details_zones.size%]
<table class="table table-bordered table-striped table-highlight table-hover">
<thead>
<tr>
<th>[% c.loc('Num') %]</th>
<th>[% c.loc('Start time') %]</th>
<th>[% c.loc('Duration') %]</th>
<th>[% c.loc('Destination') %]</th>
<th>[% c.loc('Type') %]</th>
<th>[% c.loc('Zone/Details') %]</th>
<th>[% c.loc('Cash') %]</th>
</tr>
</thead>
<tbody>
[%# Dumper.dump_html(invoice_details_zones.as_query)%]
[% FOR call IN invoice_details_calls -%]
[%IF call.1; row_number = call.0; call = call.1; END%]
[% total_duration = total_duration + call.get_column('duration') %]
[% total_cost = total_cost + call.get_column('source_customer_cost') / 100 %]
<tr class="sw_action_row">
<td>[% row_number %]</td>
<td><div class="pull-right">[% date.format(Math.int(call.get_column('start_time')),'%Y-%m-%d %H:%M:%S') %]</div></td>
<td><div class="pull-right">[% call.get_column('duration')|format('%.3f') %]</div></td>
<td><div class="pull-right">[% call.get_column('destination_user_in').replace('(.*?)\d{4}$','$1****') %][%#to mscro or view .replace('(.*?)\d{4}$','$1****') %]</div></td>
<td><div class="pull-right">[% call.get_column('call_type') %]</div></td>
<td>[% call.get_column('zone') _ '/' _ call.get_column('zone_detail') %]</td>
<td><div class="pull-right">[% money_format( call.get_column('source_customer_cost') / 100 ) %]</div></td>
</tr>
[%END%]
<tr>
<td colspan="2">[% c.loc('Total') %]</td>
<td><div class="pull-right">[% total_duration | format('%.3f') %]</div></td>
<td><div class="pull-right" colspan="4">[% money_format( total_cost ) %]</div></td>
</tr>
</tbody>
</table>

@ -1,42 +0,0 @@
[%# USE Dumper %]
[%# Dumper.dump(invoice_details_zones)%]
[%# invoice_details_zones.size%]
<table class="table table-bordered table-striped table-highlight table-hover">
<thead>
<tr>
<th>[% c.loc('Num') %]</th>
<th>[% c.loc('Zone/Details') %]</th>
<th>[% c.loc('Calls') %]</th>
<th>[% c.loc('Usage') %]</th>
<th>[% c.loc('Free time') %]</th>
<th>[% c.loc('Cash') %]</th>
<th class="ngcp-actions-column"></th>
</tr>
</thead>
<tbody>
[%# Dumper.dump_html(invoice_details_zones.as_query)%]
[% FOR call IN invoice_details_zones -%]
[%IF call.1; row_number = call.0; call = call.1; END%]
[% total_number = total_number + call.get_column('number') %]
[% total_duration = total_duration + call.get_column('duration') %]
[% total_free_time = total_free_time + call.get_column('free_time') %]
[% total_cost = total_cost + call.get_column('cost') %]
<tr class="sw_action_row">
<td>[% row_number %]</td>
<td>[% call.get_column('zone') _ '/' _ call.get_column('zone_detail') %]</td>
<td><div class="pull-right">[% call.get_column('number') %]</div></td>
<td><div class="pull-right">[% call.get_column('duration')|format('%.3f') %]</div></td>
<td><div class="pull-right">[% call.get_column('free_time')|format('%d') %]</div></td>
<td><div class="pull-right">[% money_format( call.get_column('cost') / 100 ) %]</div></td>
</tr>
[%END%]
<tr>
<td colspan="2">[% c.loc('Total') %]</td>
<td><div class="pull-right">[% total_number %]</div></td>
<td><div class="pull-right">[% total_duration | format('%.3f') %]</div></td>
<td><div class="pull-right">[% total_free_time | format('%d')%]</div></td>
<td><div class="pull-right">[% money_format( total_cost / 100 ) %]</div></td>
</tr>
</tbody>
</table>

@ -1,2 +0,0 @@
[%m.name = "Invoice Generation"%]
[%PROCESS 'helpers/ajax_form_modal.tt'-%]

@ -1,45 +0,0 @@
<table class="table table-bordered table-striped table-highlight table-hover">
<thead>
<tr>
[%#0 - now interface suppose preselected reseller%]
[%IF 0 && c.user.roles == 'admin' %]
<th>[% c.loc('Reseller') %]</th>
[%END%]
<th>[% c.loc('Customer #') %]</th>
<th>[% c.loc('Serial') %]</th>
<th>[% c.loc('Start') %]</th>
<th>[% c.loc('End') %]</th>
<th>[% c.loc('Cache Balance') %]</th>
<th>[% c.loc('Free time balance') %]</th>
<th class="ngcp-actions-column"></th>
</tr>
</thead>
<tbody>
[%# Dumper.dump_html(invoice_details_zones.as_query)%]
[%FOREACH invoice IN invoice_list -%]
<tr class="sw_action_row">
[%IF 0 && c.user.roles == 'admin' %]
<td>#[% invoice.get_column('reseller_id') %] [% invoice.get_column('reseller_name') %]</td>
[%END%]
<td>#[% invoice.get_column('client_contact_id') %]</td>
<td><div class="pull-right">[% invoice.get_column('serial')|format('%06d') %]</div></td>
<td>[% invoice.get_column('contract_balance_start') %]</td>
<td>[% invoice.get_column('contract_balance_end') %]</td>
<td><div class="pull-right">[% invoice.get_column('cash_balance') %]</div></td>
<td><div class="pull-right">[% invoice.get_column('free_time_balance') %]</div></td>
<td class="ngcp-actions-column"><div class="sw_actions"><a class="btn btn-small btn-primary" href="javascript:window.open('[%c.uri_for_action('/invoice/invoice_data',[invoice.get_column('invoice_id')])%]','_blank');void(0);">
<i class="icon-edit"></i> [% c.loc('View invoice') %]
</a>
</div></td>
</tr>
[%END%]
</tbody>
</table>

@ -1,2 +0,0 @@
[%m.name = "Send Invoice"%]
[%PROCESS 'helpers/ajax_form_modal.tt'-%]

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 28 KiB

@ -1,305 +0,0 @@
[% 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_callback => 'refreshInvoicesTable();'
}%]
[%modal_script( m = mf_helper )%]
[% site_config.title = c.loc('Invoices for [_1]', provider.name ) -%]
<script type="text/javascript" src="/js/background.js"></script>
<script type="text/javascript" src="/js/modalAjax.js"></script>
<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('/reseller/details', [provider.id]) %]">[% c.loc('Reseller details')%] <i class="icon-edit"></i></a>
</span-->
<span>
<a class="btn btn-primary btn-large" onclick="javascript:$(this).css('outline', 'none');generateInvoiceForm();void(0);">[% c.loc('Generate invoice')%] <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">
[%#here can be just initial messages state, but now it is the same with ajax messages, so there is no sense in repetition-%]
[%PROCESS 'helpers/ajax_messages.tt' -%]
</div>
<script>
function refreshInvoicesTable(){
invoicesTable = $('#invoice_list_data_ajax_table');
if(invoicesTable){
invoicesTable.dataTable().fnDraw();
}
}
function applyClientFilter(table,tr,contact_id){
var classSelected = 'ngcp_current_edit';
if(tr){
table = tr.closest('table');
if(tr.hasClass(classSelected) ) {
tr.removeClass(classSelected);
contact_id = '';
}
else {
table.find('tr.'+classSelected).removeClass(classSelected);
tr.addClass(classSelected);
}
}else{
//bigbutton "clear filter" code
if(table){
table.find('tr.'+classSelected).removeClass(classSelected);
}
contact_id = '';
}
localStorage.setItem('ngcp_dt.invoice_list_data_ajax_table.paramsJSON',JSON.stringify({'client_contact_id':contact_id}));
refreshInvoicesTable();
}
function generateInvoiceForm(contract_id, contact_id){
fetch_into(
'invoice_generate_form',
'[%c.uri_for_action("/invoice/invoice_generate", [ provider.id])%]',
'item=invoice_generate'
+(contract_id?'&client_contract_id='+contract_id:'')
+(contact_id?'&client_contact_id='+contact_id:''),
function(){modalFormScript();}
);
}
function sendInvoiceForm(invoice_id){
fetch_into(
'invoice_send_form',
'[%c.uri_for_action("/invoice/invoice_send", [ provider.id])%]',
'item=invoice_send&invoice_id='+invoice_id,
function(){modalFormScript();}
);
}
function deleteInvoice(invoice_id,table_name){
//alert('table_name='+table_name+';');
fetch_into('messages',
'[%c.uri_for_action("/invoice/invoice_delete", [ provider.id ] )%]',
'invoice_id='+invoice_id,
function(){$('#'+table_name).DataTable().fnDraw();}
);
}
//$(document).ready(function() {
// alert($('#toggle-accordions'));
// $('#toggle-accordions').trigger('click');
// $('#toggle-accordions').click();
//});
</script>
<div class="ngcp-separator"></div>
[% back_created = 1 -%]
<!--div class="accordion" id="invoice"-->
<!--div class="accordion-group">
<div class="accordion-heading">
<a class="accordion-toggle" data-toggle="collapse" data-parent="#invoice" href="#collapse_client_list">[% c.loc('Customers') %]</a>
</div>
<div class="accordion-body collapse" id="collapse_client_list">
<div class="accordion-inner">
[%#Dumper.dump_html(provider_client_list_ajax)%]
[%
clearHelper();
helper.name = c.loc('Customers');
helper.name_single = c.loc('customer');
helper.dt_columns = [
{ name => 'id', title => c.loc('Customer Contact Id'), search => 1},
{ name => 'contracts.id', title => c.loc('Customer Contract Id'), search => 1},
{ name => 'contracts.external_id', title => c.loc('External #'), search => 1 },
{ name => 'email', title => c.loc('Contact Email'), search => 1 },
{ name => 'contracts.billing_mappings.billing_profile.name', title => c.loc('Billing Profile'), search => 1 },
{ name => 'contracts.billing_mappings.product.name', title => c.loc('Product'), search => 1 },
{ name => 'contracts.status', title => c.loc('Status'), search => 1 },
];
helper.dt_buttons = [
{
name => c.loc('Generate invoice'),
uri => 'javascript:void(0);',
onclick => "generateInvoiceForm('+full.contracts_id+');void(0);",
class => 'btn-small btn-primary',
icon => 'icon-star'
},
{
name => c.loc('Filter invoices'),
uri=>'javascript:void(0);',
onclick => "applyClientFilter(\\'\\',\$(this).closest(\\'tr\\'),'+full.id+');",
class => 'btn-small btn-primary',
icon => 'icon-glass',
tooltip => 'Click twice to clear customer filter.'
},
];
helper.identifier = 'provider_client_list_ajax';
helper.ajax_uri = c.uri_for_action( '/invoice/ajax_datatables_data', [ provider.id, 'provider_client_list' ] ) ;
initHelperAuto();
PROCESS 'helpers/datatables.tt';
datatables.clients = {helper => {}};
datatables.clients.helper.import(helper);
-%]
[%#PROCESS 'invoice/invoice_list.tt' %]
</div>
</div>
</div-->
<!--div class="accordion-group">
<div class="accordion-heading">
<a class="accordion-toggle" data-toggle="collapse" data-parent="#invoice" href="#collapse_invoice_list">[% c.loc('Invoices') %]</a>
</div>
<div class="accordion-body collapse" id="collapse_invoice_list">
<div class="accordion-inner"-->
[%#, title => c.loc('Reseller #')%]
[%#, title => c.loc('Reseller name')%]
[%#Dumper.dump_html(invoice_list_ajax)%]
[%
clearHelper();
helper.name_single = c.loc('Invoices');
helper.name = c.loc('Invoices');
helper.identifier = 'invoice_list_data_ajax';
helper.dt_columns = [
{ name => 'contract_balances.contract.contact.reseller_id'},
{ name => 'contract_balances.contract.contact.reseller.name'},
{ name => 'contract_balances.contract.contact.id', title => c.loc('Customer'), search => 1},
{ name => 'contract_balances.contract.id', title => c.loc('Contract'), search => 1},
{ name => 'contract_balances.invoice_id', title => c.loc('Invoice Id'), search => 1},
{ name => 'contract_balances.invoice.serial', title => c.loc('Invoice #'), search => 1},
{ name => 'contract_balances.start', title => c.loc('Period Start'), search_from_epoch => 1, search_to_epoch => 1, search_use_datetime => 1 },
{ name => 'contract_balances.end', title => c.loc('Period End')},
{ name => 'contract_balances.cash_balance', title => c.loc('Cash balance')},
{ name => 'contract_balances.free_time_balance', title => c.loc('Free Time balance')},
];
helper.dt_buttons = [
{
name = c.loc('View invoice PDF'),
uri = "javascript:window.open(\\'" _ c.uri_for_action('/invoice/invoice_data', [ provider.id ] ) _ "/' + full.contract_balances_invoice_id + '\\',\\'_blank\\');void(0);",
class = 'btn-small btn-primary',
icon = 'icon-edit'
},
{
name = c.loc('Send invoice'),
uri => 'javascript:void(0);',
onclick => "sendInvoiceForm('+full.contract_balances_invoice_id+');void(0);",
class => 'btn-small btn-primary',
icon => 'icon-star'
attributes= ' cancel-hide="1"'
},
{
name = c.loc('Delete'),
uri = "javascript:deleteInvoice(\\''+full.contract_balances_invoice_id+'\\',\\'" _ helper.identifier _ "_table\\');void(0);",
class = 'btn-small btn-secondary',
icon = 'icon-trash',
attributes= ' cancel-hide="1"'
},
];
helper.ajax_uri = c.uri_for_action( '/invoice/ajax_datatables_data', [ provider.id, 'invoice_list_data' ] ) ;
initHelperAuto();
PROCESS 'helpers/datatables.tt';
datatables.invoices = {helper => {}};
datatables.invoices.helper.import(helper);
-%]
[%#PROCESS 'invoice/invoice_list.tt' %]
<!--/div>
</div>
</div-->
<!--div class="accordion-group">
<div class="accordion-heading">
<a class="accordion-toggle" data-toggle="collapse" data-parent="#customer_invoice" href="#collapse_invoice_details_zones">[% c.loc('Invoice Connection Fees') %]</a>
</div>
<div class="accordion-body collapse" id="collapse_invoice_details_zones">
<div class="accordion-inner" style="overflow:auto; height: 300px;">
[%
clearHelper();
helper.name = c.loc('Invoice Connection Fees');
helper.dt_columns = [
{ name => 'source_customer_billing_zones_history.zone', title => c.loc('Zone'), search=> 1 },
{ name => 'number', title => c.loc('Calls') },
{ name => 'duration', title => c.loc('Usage') },
{ name => 'free_time', title => c.loc('Free time') },
{ name => 'cost', title => c.loc('Amount EUR') },
];
helper.name_single = c.loc('Invoice Connections Records');
helper.identifier = 'invoice_details_zones_ajax';
helper.ajax_uri = c.uri_for_action( '/invoice/ajax_datatables_data', [ provider.id, 'invoice_details_zones' ] ) ;
initHelperAuto();
PROCESS 'helpers/datatables.tt';
-%]
[%PROCESS 'invoice/invoice_details_zones_list.tt' %]
</div>
</div>
</div>
<div class="accordion-group">
<div class="accordion-heading">
<a class="accordion-toggle" data-toggle="collapse" data-parent="#customer_invoice" href="#collapse_invoice_details_calls">[% c.loc('Invoice Calls') %]</a>
</div>
<div class="accordion-body collapse" id="collapse_invoice_details_calls">
<div class="accordion-inner" style="overflow:auto; height: 300px;">
<input type="button" value="qqqqqqq" onclick="
var oTable = $('#invoice_details_calls_ajax_table').dataTable();
alert( oTable );
var i;
obj = oTable.fnSettings();
obj = $('#invoice_details_calls_ajax_datepicker_start').datepicker();
for (i in obj){
alert('i='+i+'; o='+obj[i]+';');
}
//alert( $('#invoice_details_calls_ajax_datepicker_start').datepicker() );
//function(){return s(this[j.ext.iApiIndex])};
//oTable.fnSettings = function(){alert('j'+j+';iApiIndex'+j.ext.iApiIndex+';');return s(this[j.ext.iApiIndex])};
alert( oTable.fnSettings().oPreviousSearch.sSearch );//
oTable.fnClose();
">
[%
clearHelper();
helper.name = c.loc('Invoice Calls');
helper.dt_columns = [
{ name => 'start_time', title => c.loc('Start time'), search_from_epoch => 1, search_to_epoch=>1 },
{ name => 'duration', title => c.loc('Duration') },
{ name => 'destination_user', title => c.loc('Destination'), search => 1 },
{ name => 'call_type', title => c.loc('Type'), search => 1 },
{ name => 'source_customer_billing_zones_history.zone', title => c.loc('Zone'), search=> 1 },
{ name => 'source_customer_cost', title => c.loc('Amount EUR') },
];
helper.name_single = c.loc('Invoice calls');
helper.identifier = 'invoice_details_calls_ajax';
helper.id_from_name = 'start_time';
helper.ajax_uri = c.uri_for_action( '/invoice/ajax_datatables_data', [ provider.id, 'invoice_details_calls' ] ) ;
initHelperAuto();
PROCESS 'helpers/datatables.tt';
-%]
[%PROCESS 'invoice/invoice_details_calls_list.tt' %]
</div>
</div>
</div-->
<!--/div-->
<div id="invoice_generate_form">
</div>
<div id="invoice_send_form">
</div>

@ -1,19 +1,20 @@
[% USE Dumper %]
[% USE format %]
[% money_format = format('%.2f') %]
[% write_access = 1 %]
[%
USE format;
money_format = format('%.2f');
write_access = 1;
%]
[%PROCESS 'helpers/datatables_vars.tt'
no_auto_helper = 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 )%]
[%
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 ) -%]
[% site_config.title = c.loc('Invoice template [_1]', tmpl.name ) -%]
<script type="text/javascript" src="/js/libs/svg-edit/embedapi.js"></script>
@ -22,54 +23,13 @@
<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>
<script type="text/javascript">
var uriForAction = function( data, type ){
//also we can think about getting URIs via ajax )
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>
[% 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" onclick="$(this).css('outline', 'none');fetch_into('template_info_form', '[%- c.uri_for_action("/invoice/template_info", [provider.id]) -%]','item=template_info',function(){modalFormScript();});void(0);">[% c.loc('Create invoices template')%] <i class="icon-edit"></i></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" -%]
@ -79,20 +39,11 @@ var uriForAction = function( data, type ){
[%PROCESS 'helpers/ajax_messages.tt' -%]
</div>
<div class="ngcp-separator"></div>
[% back_created = 1 -%]
<div class="accordion-inner" style="overflow:auto; height:300px;" id="template_list">
[%PROCESS 'invoice/template_list.tt' %]
</div>
<!--with display:none only the opera works with svg, others cant operate geometry on start and fail with a lot of svg related errors-->
<div style="visibility:hidden;" id="template_editor_form">
<div id="template_editor_form">
[%PROCESS 'invoice/template_editor_form.tt' %]
</div>
<div id="template_info_form">
</div>
[% # vim: set tabstop=4 syntax=html expandtab: -%]

@ -1,49 +0,0 @@
[% 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>
</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>

@ -1,9 +0,0 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<script>
window.parent.window.svgEditor.processFile("[%IF 'import_img' == in.type%]data:[%out.image_content_mimetype%];base64,[%END%][%out.image_content_base64%]", "[%in.type%]");
</script>
</head><body></body>
</html>

@ -10,15 +10,33 @@ 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="">
<input type="hidden" name="provider_id" value="">
<form name="template_editor" id="template_editor" action="[% c.uri_for_action('/invoicetemplate/get_content_ajax', tmpl.id) -%]" class="form-horizontal" enctype="multipart/form-data" method="post">
<input type="hidden" name="tt_id" value="[% tt_id %]">
<span>
<a class="btn btn-primary btn-small" onclick="
savePreviewedAndShowParsed({
provider_id:'[%provider.id%]',
<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(),
});void(0);">[% c.loc('Refresh Preview')%] <i class="icon-refresh"></i></a>
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="
@ -26,15 +44,81 @@ function getTtIdVal(){
saveTemplate({
provider_id: '[%provider.id%]',
tt_id: getTtIdVal(),
});void(0);">[% c.loc('Save template')%] <i class="icon-disk"></i></a>
}, refreshMessagesAjax );void(0);">[% c.loc('Save template')%] <i class="icon-disk"></i></a>
</span>
<span id="load_saved_control" style="display:none;">
<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>
<div class="ngcp-separator"></div>
<span>
<a class="btn btn-primary btn-small" onclick="
var divId = '#template_variables_help';
$(divId).draggable({
handle: '.modal-header',
cursor: 'crosshair',
}).css('display','block').find($('.mod_close')).click(function(event) {
$(divId).css('display','none');
});
void(0);">[% c.loc('Show template variables')%] <i class="icon-info-sign"></i></a>
</span>
<style>
#template_variables_help{
display:none;
position:absolute;
top:150px;
left:100px;
width: 250px;
height: 500px;
}
.variablekey{
font-weight:bold;
color:#2222FF;
font-style:italic;
}
.variable{
font-weight:bold;
}
</style>
<div id="template_variables_help" class="modal ngcp-modal">
<div class="modal-header">
<h3>[%c.loc('Template variables')%]
<button type="button" class="close mod_close">×</button>
</h3>
</div>
[%
PROCESS 'invoice/default/invoice_template_lorem.tt';
callsdata = invoice_details_calls.0.1;
zonesdata = invoice_details_zones.0.1;
%]
<div style="overflow:auto;height:85%;">
[%
FOREACH varname IN ['client','provider','invoice','bp','callsdata','zonesdata'];
tooltipvarindex = varname _ '_self';
%]
<ul> <span class="variable" [%IF template_variables.description.${varname}.${tooltipvarindex}%] rel="tooltip" data-original-title="[% c.loc(template_variables.description.${varname}.${tooltipvarindex}) %]" [%END%]>[%varname%]</span>
[%
FOREACH key IN ${varname}.keys().sort();
IF !key.match('^_');
%]
<li [%IF template_variables.description.${varname}.${key}%] rel="tooltip" data-original-title="[% c.loc(template_variables.description.${varname}.${key}) %]" [%END%]>[% varname %].<span class="variablekey">[%key%]</span></li>
[%
END;
END;
%]
</ul>
[%
END;
%]
</div>
<div class="modal-footer">
<a class="mod_close btn btn-primary btn-small">[%c.loc('Close')%]</a>
</div>
</div>
[%IF viewmode == 'development' %]
<div class="ngcp-separator"></div>
<span>
@ -52,9 +136,7 @@ function getTtIdVal(){
provider_id: '[%provider.id%]',
});void(0);" cancel-hide="1">[% c.loc('Load previewed')%] <i class="icon-edit"></i></a>
</span>
[%END%]
<div class="ngcp-separator"></div>
[%IF viewmode == 'development' %]
<span>
<a class="btn btn-primary btn-small" href="javascript:window.open(uriForAction({
tt_sourcestate: 'previewed',
@ -63,16 +145,6 @@ function getTtIdVal(){
provider_id: '[%provider.id%]',
}),'_blank');void(0);">[% c.loc('Previewed SVG')%] <i class="icon-edit"></i></a>
</span>
[%END%]
<span>
<a class="btn btn-primary btn-small" href="javascript:window.open(uriForAction({
tt_sourcestate: 'previewed',
tt_output_type : 'pdf',
tt_id: getTtIdVal(),
provider_id: '[%provider.id%]',
}),'_blank');void(0);">[% c.loc('Previewed PDF')%] <i class="icon-edit"></i></a>
</span>
[%IF viewmode == 'development' %]
<span>
<a class="btn btn-primary btn-small" href="javascript:window.open(uriForAction({
tt_sourcestate: 'saved',
@ -90,7 +162,7 @@ function getTtIdVal(){
}),'_blank');void(0);">[% c.loc('Saved PDF')%] <i class="icon-edit"></i></a>
</span>
[%END%]
[%initial = 'default'%]
[%initial = 'saved'%]
<div class="ngcp-separator"></div>
<iframe
type="text/html"
@ -101,8 +173,6 @@ function getTtIdVal(){
tt_sourcestate: '[%initial%]',
provider_id: '[%provider.id%]',
tt_id: getTtIdVal(),
});" width="550px" height="750px" style="border-width:0px;"></iframe><iframe
src="[%- c.uri_for_action('/invoice/template_view', [provider.id]) -%]/svg/parsed/[%- initial -%]" id="svgpreview"
width="600px" height="750px" style="border-width:0px;"></iframe>
});" width="1300px" height="1500px" style="border-width:0px;"></iframe>
</div>
</form>
</form>

@ -1,179 +0,0 @@
[%# 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(),
}, refreshMessagesAjax );void(0);">[% c.loc('Save template')%] <i class="icon-disk"></i></a>
</span>
<div class="ngcp-separator"></div>
<span>
<a class="btn btn-primary btn-small" onclick="
var divId = '#template_variables_help';
$(divId).draggable({
handle: '.modal-header',
cursor: 'crosshair',
}).css('display','block').find($('.mod_close')).click(function(event) {
$(divId).css('display','none');
});
void(0);">[% c.loc('Show template variables')%] <i class="icon-info-sign"></i></a>
</span>
<style>
#template_variables_help{
display:none;
position:absolute;
top:150px;
left:100px;
width: 250px;
height: 500px;
}
.variablekey{
font-weight:bold;
color:#2222FF;
font-style:italic;
}
.variable{
font-weight:bold;
}
</style>
<div id="template_variables_help" class="modal ngcp-modal">
<div class="modal-header">
<h3>[%c.loc('Template variables')%]
<button type="button" class="close mod_close">×</button>
</h3>
</div>
[%
PROCESS 'invoice/invoice_template_lorem.tt';
callsdata = invoice_details_calls.0.1;
zonesdata = invoice_details_zones.0.1;
%]
<div style="overflow:auto;height:85%;">
[%
FOREACH varname IN ['client','provider','invoice','bp','callsdata','zonesdata'];
tooltipvarindex = varname _ '_self';
%]
<ul> <span class="variable" [%IF template_variables.description.${varname}.${tooltipvarindex}%] rel="tooltip" data-original-title="[% c.loc(template_variables.description.${varname}.${tooltipvarindex}) %]" [%END%]>[%varname%]</span>
[%
FOREACH key IN ${varname}.keys().sort();
IF !key.match('^_');
%]
<li [%IF template_variables.description.${varname}.${key}%] rel="tooltip" data-original-title="[% c.loc(template_variables.description.${varname}.${key}) %]" [%END%]>[% varname %].<span class="variablekey">[%key%]</span></li>
[%
END;
END;
%]
</ul>
[%
END;
%]
</div>
<div class="modal-footer">
<a class="mod_close btn btn-primary btn-small">[%c.loc('Close')%]</a>
</div>
</div>
[%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>

@ -1,2 +0,0 @@
[%m.name = "Invoice Template"%]
[%PROCESS 'helpers/ajax_form_modal.tt'-%]

@ -1,54 +0,0 @@
[% 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", [ template.get_column('reseller_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%]

@ -1,38 +1,25 @@
<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';
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';
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']) -%]';
q_template = '[%# c.uri_for_action("/invoice/template_list", ['provider_id']) -%]';
break;
case 'messages':
q_template = '[%- c.uri_for_action("/invoice/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';
q_template = '[% c.uri_for_action("/invoicetemplate/get_content_ajax", [tmpl.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>
[% # vim: set tabstop=4 syntax=html expandtab: -%]

Loading…
Cancel
Save