Fetching default template from file works. TBD: saving, viewing from saved, previewing PDF.mr3.3.1
parent
b6533b1a1f
commit
a88724c0c4
@ -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:
|
||||
|
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'-%]
|
||||
|
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,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>
|
||||
@ -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…
Reference in new issue