Support A2Billing :

provided by Star2Billing S.L.

Support A2Billing :
It is currently Thu Dec 14, 2017 12:44 am
Predictive Dialer


All times are UTC




Post new topic Reply to topic  [ 21 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: how to generate PDF invoices with A2B1.4.1
PostPosted: Sat Aug 08, 2009 6:10 pm 
Offline

Joined: Tue Mar 17, 2009 4:00 pm
Posts: 153
Location: Where the sun shines
Hello

I know this function has been removed from 1.4, but I still believe this is greatly needed... I did a bit of work, and here is a solution - fairly easy in my pow !!!

given that this feature has been removed after 1.3.4, and that I am not sure of how much support I can provide (I'll do my best anyway !), I am not proposing to integrate this in the main code of A2B... also, it seems that dompdf is evolving constantly, and I am not sure as how to maintain this dependency.

enjoy...

J.

How does it work:
I've modified A2B_invoice_view.pdf to output all text to a file (using a class ob_filewriter that I did not write myself...).
Then, at the end, I convert this html data to pdf and display it !

How to:

1. download this bit of code: http://codeutopia.net/files/obfw.txt
and save it in the customer directory, under the name 'obfw.php'
make sure that the ownership & rights are the same as a2b

2. download DOMPDF version 0.5.1 :
http://dompdf.googlecode.com/files/dompdf-0.5.1.zip
install under var/www/html (at the same location as a2billing)
with a dirname 'dompdf' -
make sure that the ownership & rights are the same as a2b

3. alter var/www/html/a2billing/customer/A2B_invoice_view.pdf as follows
(line # refer to rev 2293)

line 7: add
include ("./obfw.php");
require_once("../../dompdf/dompdf_config.inc.php");

line 43 (before: $smarty->display('main.tpl'); )
add:
if($popup_select)
{
$obfilename="/tmp/invoice".date("YmdHis").".html";
$obfw = new OB_FileWriter($obfilename);
$obfw->start();
}

at the very end, add:
if($popup_select){
$obfw->end();
$bp = getcwd();
$dompdf = new DOMPDF();
$dompdf->load_html_file($obfilename);
$dompdf->set_base_path($bp);
$dompdf->set_paper("a4");
$dompdf->render();
unlink ($obfilename);
$options = array ('Attachment' => 0);
$dompdf->stream("invoice.pdf",$options);

}


Now, this should work only IF YOU USE A2B CUSTOMER UI IN ENGLISH

To get it working in other languages (that use the , as decimal separator - french for instance), you need a bit of extra work:
go to the dompdf/lib directory
and edit class.pdf.php
then replace in the code all the %f format with %F (note that there is mostly %.3f and some other, so just dont simply search for %f)
save... and you should be good (alternatively, PM me and I'll email the corrected file)


if something goes wrong, check first the logs (var/log/httpd/error_log), and if you cant find whats wrong, then post a reply on this topic !


Top
 Profile  
 
 Post subject: Re: how to generate PDF invoices with A2B1.4.1
PostPosted: Mon Aug 10, 2009 5:52 pm 
Offline

Joined: Sun Mar 12, 2006 2:49 pm
Posts: 954
Location: Barcelona
It could be a nice feature to have but I would advice to do it in a way that this will not overload the server.
Those PDF generation can be very costly in resources and give the perms to the user to trigger it can be harmful.

I would love to see a features that will generate the PDF for the last 30 days keep them on the server and remove old ones automatically.

Yours,
/Areski


Top
 Profile  
 
 Post subject: Re: how to generate PDF invoices with A2B1.4.1
PostPosted: Mon Aug 10, 2009 6:29 pm 
Offline

Joined: Tue Mar 17, 2009 4:00 pm
Posts: 153
Location: Where the sun shines
Areski,

re: resources... On my task list, pretty high, is to see the possibility to implement DB replication between the core A2B server and another server, at relatively modest cpu/bandwitdh cost - this would allow more security, obviously, reporting could be done like crazy with no risk to impact the rating engine, and would hide a bit more the A2B rating server from the public. should i be sucessful, I will post the results !

re: pdf generation. I would also prefer generating the pdf & storing them. I dont like the fact that the invoice is regenerated from the db values each time (for instance, say you change the template, then any previous will use the new template, while the customer actually received the invoice with a different template). I wouldnt be surprised also that some legal requirement ask for that, in some countries at least. This is also on my task list, not as high....

to achieve this, I am thinking taking the A2B_invoice_view.php, make some funky branch at the beginning that will detect if it is runing from CLI or web, and, from CLI, connect to the DB - from there process the invoice as in web mode (to ensure consistency) - and at the end, generate plainly the output. more to come....


J.


Top
 Profile  
 
 Post subject: Re: how to generate PDF invoices with A2B1.4.1
PostPosted: Mon Aug 10, 2009 6:36 pm 
Offline

Joined: Sun Mar 12, 2006 2:49 pm
Posts: 954
Location: Barcelona
Thanks for the clearance!

Quote:
re: resources... On my task list, pretty high, is to see the possibility to implement DB replication between the core A2B server and another server, at relatively modest cpu/bandwitdh cost - this would allow more security, obviously, reporting could be done like crazy with no risk to impact the rating engine, and would hide a bit more the A2B rating server from the public. should i be sucessful, I will post the results !


I would agree on this for many different reasons and I will suppose this will be appropriate for your scale, but most of the a2b users will not invest into a 2 servers solution, so if we can do it good in a way it does not request an extra box we should try keeping this direction.


Cheers,
/Areski


Top
 Profile  
 
 Post subject: Re: how to generate PDF invoices with A2B1.4.1
PostPosted: Mon Aug 10, 2009 6:44 pm 
Offline

Joined: Tue Mar 17, 2009 4:00 pm
Posts: 153
Location: Where the sun shines
well... I cant really afford 2 boxes either.... but I have a web site, hosted by 1&1 (15€/year...) and I'll see if I can host the customer part on this hosting - that is definitely my preferred design !

j.


Top
 Profile  
 
 Post subject: Re: how to generate PDF invoices with A2B1.4.1
PostPosted: Wed Sep 02, 2009 1:30 pm 
Offline

Joined: Mon Oct 01, 2007 10:44 pm
Posts: 230
Location: Bovey, Devon, UK
cerien wrote:
Areski,

re: pdf generation. I would also prefer generating the pdf & storing them. I dont like the fact that the invoice is regenerated from the db values each time (for instance, say you change the template, then any previous will use the new template, while the customer actually received the invoice with a different template). I wouldnt be surprised also that some legal requirement ask for that, in some countries at least. This is also on my task list, not as high....
J.


Yup, this is a serious problem and breaks Euro accounting rules. In the UK VAT is going to change yet again shortly. This means all historical invoices will be wrong. VAT value needs to stored and not recalculated.


Top
 Profile  
 
 Post subject: Re: how to generate PDF invoices with A2B1.4.1
PostPosted: Wed Sep 02, 2009 2:15 pm 
Offline

Joined: Tue Mar 17, 2009 4:00 pm
Posts: 153
Location: Where the sun shines
From the top of my head, the VAT rate is stored, but not the amount - so the VAT change should not impact you. However, for manipulating the invoices (reports, collections, etc...), having to recalcultate with the stored rate makes life more complicated !

j.


Top
 Profile  
 
 Post subject: Re: how to generate PDF invoices with A2B1.4.1
PostPosted: Sun Nov 01, 2009 12:10 pm 
Offline
User avatar

Joined: Sat Mar 28, 2009 5:50 am
Posts: 96
I have installed dompdf and added the code but cant see any pdf generated, where do i insert the second half of code ?

Thanks


Top
 Profile  
 
 Post subject: Re: how to generate PDF invoices with A2B1.4.1
PostPosted: Sun Nov 01, 2009 12:45 pm 
Offline
User avatar

Joined: Sat Mar 28, 2009 5:50 am
Posts: 96
here is the error from php log

Code:
PHP Fatal error:  require_once() [<a href='function.require'>function.require</a>]: Failed opening required '/var/www/html/dompdf/include/domdocument.cls.php' (include_path='.:/usr/share/pear:/usr/share/php') in /var/www/html/dompdf/dompdf_config.inc.php on line 194, referer: http://10.1.1.15/billing/admin/Public/A2B_invoice_view_cdr.php?id=9&curr=


Top
 Profile  
 
 Post subject: Re: how to generate PDF invoices with A2B1.4.1
PostPosted: Sun Nov 01, 2009 3:24 pm 
Offline

Joined: Tue Mar 17, 2009 4:00 pm
Posts: 153
Location: Where the sun shines
Hi

on some distros, you need to install php-xml

that should solve your issue !

KR
J.


Top
 Profile  
 
 Post subject: Re: how to generate PDF invoices with A2B1.4.1
PostPosted: Mon Nov 02, 2009 11:38 am 
Offline
User avatar

Joined: Sat Mar 28, 2009 5:50 am
Posts: 96
I have centos 5.3 and php-xml is installed.


Top
 Profile  
 
 Post subject: Re: how to generate PDF invoices with A2B1.4.1
PostPosted: Mon Nov 02, 2009 3:40 pm 
Offline

Joined: Tue Mar 17, 2009 4:00 pm
Posts: 153
Location: Where the sun shines
strange ! I also have a centos 5.3 box and ran into the same issue - I solved it by installing php-xml

did you restart the http server after installing php-xml ? this is required !

j.


Top
 Profile  
 
 Post subject: Re: how to generate PDF invoices with A2B1.4.1
PostPosted: Mon Nov 02, 2009 7:35 pm 
Offline
User avatar

Joined: Sat Mar 28, 2009 5:50 am
Posts: 96
Good catch! It's working fine now.

Thanks!


Top
 Profile  
 
 Post subject: Re: how to generate PDF invoices with A2B1.4.1
PostPosted: Mon Nov 02, 2009 7:51 pm 
Offline

Joined: Tue Mar 17, 2009 4:00 pm
Posts: 153
Location: Where the sun shines
glad to hear that... your're actually quite lucky, I just switch to a Centos box recently, and found out this issue last wednesday !


Top
 Profile  
 
 Post subject: Re: how to generate PDF invoices with A2B1.4.1
PostPosted: Tue Dec 15, 2009 3:11 am 
Offline

Joined: Sat May 10, 2008 4:19 pm
Posts: 132
Location: Wilmington, DE
Hello All,

I installed the PDF invoice printing patch as per directions above and got a blank page when I clicked on the "Print Invoice" icon. I then tried to install php-xml and got the following error:
Code:
Resolving Dependencies
--> Running transaction check
---> Package php-xml.i386 0:5.1.6-23.2.el5_3 set to be updated
--> Processing Dependency: php-common = 5.1.6-23.2.el5_3 for package: php-xml
--> Finished Dependency Resolution
php-xml-5.1.6-23.2.el5_3.i386 from base has depsolving problems
  --> Missing Dependency: php-common = 5.1.6-23.2.el5_3 is needed by package php-xml-5.1.6-23.2.el5_3.i386 (base)

Packages skipped because of dependency problems:
    php-xml-5.1.6-23.2.el5_3.i386 from base

Still can't get the invoice to display. I'm running CentOS 5.4 with Asterisk 1.4.26.3 and A2B 1.4.2.1.

Some help would be appreciated.

Thanks,

Robin A.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 21 posts ]  Go to page 1, 2  Next
Hosted Voice Broadcast


All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group