diff --git a/lib/NGCP/Panel/Controller/InvoiceTemplate.pm b/lib/NGCP/Panel/Controller/InvoiceTemplate.pm index 6e60a0434c..850264949f 100644 --- a/lib/NGCP/Panel/Controller/InvoiceTemplate.pm +++ b/lib/NGCP/Panel/Controller/InvoiceTemplate.pm @@ -257,6 +257,7 @@ sub delete :Chained('base') :PathPart('delete') { sub edit_content :Chained('base') :PathPart('editcontent') :Args(0) { my ($self, $c) = @_; + $c->stash(NGCP::Panel::Utils::InvoiceTemplate::get_dummy_data()); $c->stash(template => 'invoice/template.tt'); } @@ -345,10 +346,10 @@ sub preview_content :Chained('base') :PathPart('editcontent/preview') :Args(0) { my $vars = {}; try { - my $no_fake = 0; - NGCP::Panel::Utils::InvoiceTemplate::preprocess_svg($no_fake, \$svg); - $t->process(\$svg, $vars, \$out) || do { + my $dummy = NGCP::Panel::Utils::Invoice::get_dummy_data(); + NGCP::Panel::Utils::InvoiceTemplate::preprocess_svg(\$svg); + $t->process(\$svg, $dummy, \$out) || do { my $error = $t->error(); my $msg = "error processing template, type=".$error->type.", info='".$error->info."'"; $c->log->error($msg); diff --git a/lib/NGCP/Panel/Utils/InvoiceTemplate.pm b/lib/NGCP/Panel/Utils/InvoiceTemplate.pm index 6b2d7c9985..3354fc69ea 100644 --- a/lib/NGCP/Panel/Utils/InvoiceTemplate.pm +++ b/lib/NGCP/Panel/Utils/InvoiceTemplate.pm @@ -40,7 +40,7 @@ sub svg_pdf { } sub preprocess_svg { - my($no_fake_data, $svg_ref) = @_; + my($svg_ref) = @_; my $xp = XML::XPath->new($$svg_ref); @@ -51,13 +51,6 @@ sub preprocess_svg { } } - if($no_fake_data) { - my $comment = $xp->find('/comment()[contains(.,"invoice_template_lorem.tt")]'); - foreach my $node($comment->get_nodelist) { - $node->getParentNode->removeChild($node); - } - } - my $comment = $xp->find('//comment()[normalize-space(.) = "{}" or normalize-space(.) = "{ }"]'); foreach my $node($comment->get_nodelist) { $node->getParentNode->removeChild($node); @@ -103,5 +96,85 @@ sub get_tt { return $tt; } +sub get_dummy_data { + return { + rescontact => { + gender => 'male', + firstname => 'Resellerfirst', + lastname => 'Resellerlast', + comregnum => 'COMREG1234567890', + company => 'Resellercompany Inc.', + street => 'Resellerstreet 12/3', + postcode => '12345', + city => 'Resellercity', + country => 'Resellercountry', + phonenumber => '+1234567890', + mobilenumber => '+2234567890', + faxnumber => '+3234567890', + iban => 'RESIBAN1234567890', + bic => 'RESBIC1234567890', + }, + customer => { + id => rand(10000)+10000, + external_id => 'Resext1234567890', + }, + custcontact => { + gender => 'male', + firstname => 'Customerfirst', + lastname => 'Customerlast', + comregnum => 'COMREG1234567890', + company => 'Customercompany Inc.', + street => 'Customerstreet 12/3', + postcode => '12345', + city => 'Customercity', + country => 'Customercountry', + phonenumber => '+4234567890', + mobilenumber => '+5234567890', + faxnumber => '+6234567890', + iban => 'CUSTIBAN1234567890', + bic => 'CUSTBIC1234567890', + }, + billprof => { + handle => 'BILPROF12345', + name => 'Test Billing Profile', + prepaid => 0, + interval_charge => 29.90, + interval_free_time => 2000, + interval_free_cash => 0, + interval_unit => 'month', + interval_count => 1, + currency => 'EUR', + vat_rate => 20, + vat_included => 0, + }, + invoice => { + year => '2014', + month => '01', + serial => '1234567', + }, + calls => [ + map {{ + start_time => time, + source_customer_cost => rand(1000), + duration => rand(7200) + 10, + destination_user_in => "1".$_."1234567890", + call_type => (qw/cfu cfb cft cfna/)[rand 4], + zone => "Zone $_", + zone_detail => "Detail $_", + }}(1 .. 100) + ], + zones => [ + map {{ + number => rand(200), + cost => rand(10000), + duration => rand(10000), + free_time => 0, + zone => "Zone $_", + zone_detail => "Detail $_", + }}(1 .. 15) + ], + }; +} + 1; # vim: set tabstop=4 expandtab: diff --git a/share/templates/invoice/default/invoice_template_lorem.tt b/share/templates/invoice/default/invoice_template_lorem.tt deleted file mode 100644 index b24a11f01a..0000000000 --- a/share/templates/invoice/default/invoice_template_lorem.tt +++ /dev/null @@ -1,162 +0,0 @@ -[% -USE Dumper; -USE Date; -USE Math; - -template_variables.description = {}; -template_variables.description.import({ - invoice => { - 'invoice_self' => 'Information about invoice.', - 'amount' => 'Invoice amount with already considered discount.', - } -}); - -IF !invoice.serial; -#info from db -DEFAULT invoice.month=date.format(date.now(),'%m'); -DEFAULT invoice.serial=Math.int(Math.rand(999999))|format('%06d'); -DEFAULT invoice.year=date.format(date.now(),'%y'); -#/info from db -DEFAULT invoice.amount='1200'; -DEFAULT invoice.amount_netto='1000'; -DEFAULT invoice.amount_payment='650'; -DEFAULT invoice.amount_vat='200'; -DEFAULT invoice.cloud_pbx_amount='921'; -DEFAULT invoice.debit='500'; -DEFAULT invoice.discount_service='10'; -DEFAULT invoice.discount_wire_transfer='40'; -DEFAULT invoice.serviceallowance='69'; -DEFAULT invoice.voice_termination_fees='10'; -END; - -template_variables.description.import({ - provider => { - 'provider_self' => 'Information about invoice issuer, reseller.', - 'bic' => 'BIC information of provider.', - 'city' => 'Provider city.', - } -}); - -IF 1 || !provider; - DEFAULT provider.bic='ABCDEFG1234'; - 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; - provider.${i} = provider.get_column(i); - CATCH; - provider.${i} = 'Provider' _ ucfirst(i); - END; - #IF !provider.${i}; - provider.${i} = 'Provider' _ ucfirst(i); - #END; - END; -END; - -template_variables.description.import({ - client => { - 'client_self' => 'Information about invoice receiver, customer.', - 'bic' => "Client's BIC.", - } -}); - -IF !client.id; -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; - - -template_variables.description.import({ - bp => { - 'name' => 'Billing Profile name', - 'interval_charge' => 'Constant fee for invoice period.', - } -}); - -IF !bp.id; -DEFAULT bp.name='Default Billing Profile'; -DEFAULT bp.interval_charge='125'; -DEFAULT bp.handle ='default'; -DEFAULT bp.prepaid = ''; -DEFAULT bp.interval_charge = ''; -DEFAULT bp.interval_free_time = ''; -DEFAULT bp.interval_free_cash = ''; -DEFAULT bp.interval_unit = ''; -DEFAULT bp.interval_count = ''; -DEFAULT bp.fraud_interval_limit = ''; -DEFAULT bp.fraud_interval_lock = ''; -DEFAULT bp.fraud_interval_notify = ''; -DEFAULT bp.fraud_daily_limit = ''; -DEFAULT bp.fraud_daily_lock = ''; -DEFAULT bp.fraud_daily_notify = ''; -DEFAULT bp.currency = ''; -DEFAULT bp.vat_rate = ''; -DEFAULT bp.vat_included = ''; -END; - -invoice_details_zones = []; -invoice_details_calls = []; - -template_variables.description.import({ - callsdata => { - 'callsdata_self' => 'Information about calls.', - 'start_time' => 'Call start time, Call will be included in invoice period, in which call started.', - } -}); -IF !invoice_details_calls.size(); - i=1; - WHILE i <= 44; - invoice_details_calls.push([i,{ - start_time => date.format(date.now(),'%s'), - source_customer_cost => i / 10, - duration => i * 10, - destination_user_in => '+1234567890', - call_type => 'call', - zone => 'Example Zone', - zone_detail => 'Default', - }]); - i = i + 1; - END; -END; -template_variables.description.import({ - zonesdata => { - 'zonesdata_self' => 'Information about zone fees.', - 'number' => 'Number of calls to the zone.', - } -}); -IF !invoice_details_zones.size(); - i=1; - WHILE i <= 45; - invoice_details_zones.push([i,{ - number => i * 2 , - cost => i / 10, - duration => i * 10, - free_time => i * 5, - zone => 'Example Zone', - zone_detail => 'Default', - }]); - i = i + 1; - END; -END; -%] \ No newline at end of file diff --git a/share/templates/invoice/default/invoice_template_svg.tt b/share/templates/invoice/default/invoice_template_svg.tt index 5dd0818eb8..e038c00f07 100644 --- a/share/templates/invoice/default/invoice_template_svg.tt +++ b/share/templates/invoice/default/invoice_template_svg.tt @@ -1,4 +1,3 @@ - diff --git a/share/templates/invoice/template_editor_form.tt b/share/templates/invoice/template_editor_form.tt index 6a07224d2c..a0cc74600e 100644 --- a/share/templates/invoice/template_editor_form.tt +++ b/share/templates/invoice/template_editor_form.tt @@ -57,34 +57,17 @@ function formSerialize(){ -[% -PROCESS 'invoice/default/invoice_template_lorem.tt'; -callsdata = invoice_details_calls.0.1; -zonesdata = invoice_details_zones.0.1; -%] -