MT#5879 Delete works

Left:
 resend invoice to email form
 separated interface for generation without filter by filter by contact/contract id
Known issues:
 tooltip makes table to flick. But not on the last button in column.
 seems like fnDraw takes data from localstorage - although invoice deleted -
 it is still shown in datatables.
ipeshinskaya/InvoiceTemplate5
Irina Peshinskaya 12 years ago committed by Victor Seva
parent 70ae0c01c9
commit cdd05a1df1

@ -8,9 +8,7 @@ use Moose::Util::TypeConstraints;
use DateTime;
use DateTime::Format::Strptime;
use NGCP::Panel::Utils::DateTime;
has '+widget_wrapper' => ( default => 'Bootstrap' );
has_field 'submitid' => ( type => 'Hidden' );
sub build_render_list {[qw/submitid fields actions/]}
sub build_form_element_class { [qw/form-horizontal/] }
@ -29,20 +27,10 @@ has_field 'submitid' => ( type => 'Hidden' );
# table_titles => ['#', 'First Name', 'Last Name', 'Email'],
# table_fields => ['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'),
required => 1,
has_field 'invoice_id' => (
type => 'Integer',
required => 0,
);
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)->truncate(to=>'day'),
required => 1,
);
has_field 'save' => (
type => 'Button',
value => 'Generate',
@ -58,7 +46,7 @@ has_field 'client_contract_id' => (
has_block 'fields' => (
tag => 'div',
class => [qw/modal-body/],
render_list => [qw/start end client_contract_id/],
render_list => [qw/invoice_id client_contract_id/],
);
has_block 'actions' => (
@ -69,29 +57,6 @@ has_block 'actions' => (
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;

@ -208,8 +208,8 @@ sub getContactInfo{
}
sub getBillingProfile{
my $self = shift;
my (%params) = @_;
my ($client_contract_id, $stime, $etime) = @params{qw/client_contract_id stime etime/};
my ($params) = @_;
my ($client_contract_id, $stime, $etime) = @$params{qw/client_contract_id stime etime/};
#select distinct billing_profiles.*
#from billing_mappings
#inner join billing_profiles on billing_mappings.billing_profile_id=billing_profiles.id
@ -395,7 +395,8 @@ sub getInvoiceProviderClients{
'me.reseller_id' => $provider_contact_id, #$client_contract_id - contract of the client
],
'-exists' => $self->schema->resultset('billing_mappings')->search({
'contract.contact_id' => \' = me.id',
#here rely on join generated by datatables
'contract.id' => \' = contracts.id',
'product.class' => [ "sipaccount", "pbxaccount" ],
#'-and' => [
# 'start_date' => [ -or =>

@ -85,8 +85,8 @@ function applyClientFilter(table,tr,contact_id){
{ name => 'contracts.status', title => c.loc('Status'), search => 1 },
];
helper.dt_buttons = [
{ 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 client filter.' },
{ name => c.loc('Generate invoice'), uri => 'javascript:void(0);', onclick => "fetch_into(\\'invoice_generate_form\\', \\'" _ c.uri_for_action('/invoice/invoice_generate', [ provider.id]) _ "\\',\\'item=invoice_generate&client_contract_id='+full.contracts_id+'\\',function(){modalFormScript();});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 client filter.' },
];
helper.identifier = 'provider_client_list_ajax';
helper.ajax_uri = c.uri_for_action( '/invoice/ajax_datatables_data', [ provider.id, 'provider_client_list' ] ) ;
@ -129,7 +129,7 @@ function applyClientFilter(table,tr,contact_id){
{ name => 'contract_balances.free_time_balance', title => c.loc('Free Time balance')},
];
helper.dt_buttons = [
{ name = c.loc('Delete'), uri = "javascript:fetch_into(\\'messages\\', \\'" _ c.uri_for_action('/invoice/invoice_delete', [ provider.id ] ) _ "\\',\\'invoice_id='+full.contract_balances_invoice_id+'\\',function(){" _ helper.id_from_name _ "_table.fnDraw();});void(0);", class = 'btn-small btn-secondary', icon = 'icon-trash' },
{ name = c.loc('Delete'), uri = "javascript:fetch_into(\\'messages\\', \\'" _ c.uri_for_action('/invoice/invoice_delete', [ provider.id ] ) _ "\\',\\'invoice_id='+full.contract_balances_invoice_id+'\\',function(){\$(\\'#" _ helper.id_from_name _ "_table\\').DataTable().fnDraw();});void(0);", class = 'btn-small btn-secondary', icon = 'icon-trash' },
{ name = c.loc('View invoice PDF'), uri = "javascript:window.open(\\'/invoice/data/' + full.contract_balances_invoice_id + '\\',\\'_blank\\');void(0);", class = 'btn-small btn-primary', icon = 'icon-edit' },
];
helper.identifier = 'invoice_list_data_ajax';

Loading…
Cancel
Save