diff --git a/lib/NGCP/Panel/Form/Invoice/Basic.pm b/lib/NGCP/Panel/Form/Invoice/Basic.pm index 1bc4330a51..43a178b8e4 100644 --- a/lib/NGCP/Panel/Form/Invoice/Basic.pm +++ b/lib/NGCP/Panel/Form/Invoice/Basic.pm @@ -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; diff --git a/lib/NGCP/Panel/Model/DB/InvoiceTemplate.pm b/lib/NGCP/Panel/Model/DB/InvoiceTemplate.pm index 920cd48af3..a70146b843 100644 --- a/lib/NGCP/Panel/Model/DB/InvoiceTemplate.pm +++ b/lib/NGCP/Panel/Model/DB/InvoiceTemplate.pm @@ -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 => diff --git a/share/templates/invoice/list.tt b/share/templates/invoice/list.tt index f72d2f62d3..58991316c2 100644 --- a/share/templates/invoice/list.tt +++ b/share/templates/invoice/list.tt @@ -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';