PDA

View Full Version : PHP Invoicing script



billbenson
02-04-2012, 02:27 PM
For quotes, receipts, and invoices I currently generate an html form via php / mysql which I copy and paste into an email. If the customer requires a pdf I copy it into an email and print to a pdf file instead of to the printer.

I'm having a couple of problems. Since I usually send this out in html emails, more and more spam filters are stripping off html so it looks like gibberish.

Also its labor intensive. You might say what's the big deal fo copying it and converting it to pdf and sending it. IMO if I do something over and over, automating it makes sense.An extra 5 minutes when the phone is ringing adds up over time and its one more place for an error to occur.

There is a php library that creates a pdf file. My host doesn't have it. I escalated it with my host. We'll see if its something they will add.

As all of my information is in a mysql database, I'm not interested in 3rd party solutions as I'm trying to make a one click solution that interfaces with my database.

Text invoices don't appear to be a good solution as the formatting options aren't very good. Maybe there is something here that I can do with tabs that would work?

Anybody have any suggestions?

MyITGuy
02-05-2012, 09:49 PM
Why are you not generating the PDF to begin with and attaching this to an e-mail with text in the body that recaps the amount due and thanking them for their business?

Regarding the creating PDF's, what methods are you looking to utilize? There may be some alternatives (I'll see if I can find them)

vangogh
02-06-2012, 11:54 AM
I think PDF would be a good option too and it can be done with PHP. Why not use a billing and invoicing application or service. There are plenty of programs available and lots of services online to take care of everything for you. Otherwise I would look into creating a PDF invoice and adding that capability to your script.

billbenson
02-06-2012, 12:02 PM
Why are you not generating the PDF to begin with and attaching this to an e-mail with text in the body that recaps the amount due and thanking them for their business?

Regarding the creating PDF's, what methods are you looking to utilize? There may be some alternatives (I'll see if I can find them)

I don't generate a pdf to begin with because it takes more time and the number of customers that strip it off is still pretty low. I see the issue as a problem though and would prefer to send the document as a pdf.

You can see the method I want to use to generate a pdf at: PHP: PDF Functions - Manual (http://php.net/manual/en/ref.pdf.php)

My host came back and added in pdflib to php4.x on my site. Apparently there are issues with php 5.x and phplib. I'm going to be cutting over to WordPress shortly. Are there any issues with using php 4.x and the most resent versions of WordPress?

--------------------------------------------------------------------------------
Let me clarify why the the two or three minutes that it takes to send a quote as a pdf matters. Lets just take a simple quote as that has the least data entry.



Customer calls and wants a quote
I go to domain.com/create_quote.php; a program I wrote which creates a quote and enters the info into an online db
I fill in name, phone, email, and products wanted and hit submit.
I get a html quote on my browser
I copy and paste the quote to my email program, Thunderbird in this case, enter a subject and email address and hit send.
If I need to send a pdf I first need to copy the quote, put it into a word processor, save, navigate and attach the pdf quote.


This may sound fairly fast and streamlined. If I want to convert the quote to an order I simply add in the ship to and bill to info and generate a customer invoice and purchase order and email those in the same way to the customer and supplier (purchase order). Its all in the same database, I just flag it as an order now.

I can get 40 phone calls on a busy day and a bunch of email rfq's. I find the the faster I get a quote to the customer, the more likely it is to get an order. Frequently I get back to back calls. I'm not a good multi tasker. If I'm working on one quote, get a phone call, and another, and another its inefficient and very time consuming. I have to go back to the first one and figure out where I was, then the next etc.

So the idea is to use enter the quote information, use the php mail() function to send the quote with the attachment in one click.

MyITGuy
02-06-2012, 01:19 PM
My host came back and added in pdflib to php4.x on my site. Apparently there are issues with php 5.x and phplib. I'm going to be cutting over to WordPress shortly. Are there any issues with using php 4.x and the most resent versions of WordPress?

I would not recommend doing this.

First, WordPress has stopped supporting PHP4 since late 2010.
Second, reverting to an older version of PHP may expose you to additional security vulnerabilities that were corrected in later versions of PHP



I don't generate a pdf to begin with because it takes more time and the number of customers that strip it off is still pretty low. I see the issue as a problem though and would prefer to send the document as a pdf.

You can see the method I want to use to generate a pdf at: PHP: PDF Functions - Manual (http://php.net/manual/en/ref.pdf.php)


--------------------------------------------------------------------------------
Let me clarify why the the two or three minutes that it takes to send a quote as a pdf matters. Lets just take a simple quote as that has the least data entry.



Customer calls and wants a quote
I go to domain.com/create_quote.php; a program I wrote which creates a quote and enters the info into an online db
I fill in name, phone, email, and products wanted and hit submit.
I get a html quote on my browser
I copy and paste the quote to my email program, Thunderbird in this case, enter a subject and email address and hit send.
If I need to send a pdf I first need to copy the quote, put it into a word processor, save, navigate and attach the pdf quote.


This may sound fairly fast and streamlined. If I want to convert the quote to an order I simply add in the ship to and bill to info and generate a customer invoice and purchase order and email those in the same way to the customer and supplier (purchase order). Its all in the same database, I just flag it as an order now.

I can get 40 phone calls on a busy day and a bunch of email rfq's. I find the the faster I get a quote to the customer, the more likely it is to get an order. Frequently I get back to back calls. I'm not a good multi tasker. If I'm working on one quote, get a phone call, and another, and another its inefficient and very time consuming. I have to go back to the first one and figure out where I was, then the next etc.

So the idea is to use enter the quote information, use the php mail() function to send the quote with the attachment in one click.

As vangogh mentioned, why don't you look at an invoicing/billing application that you can customize to your needs, rather than building your own from scratch? For my webhosting operations I utilize WHMCS (WHMCS - The Complete Client Management, Billing & Support Solution (http://www.whmcs.com/)) which allows me to generate quotes, send invoices and etc from a point/click interface with a bunch of modules that can be integrated if I choose. This program set me back approximately $300, but is considerably cheaper when you look at the amount of time I would have spent to create something similar. Maybe you can find something similar for your system?

Regarding the library you want to use, most hosts won't install it since it's not free for commercial use and it carries a pretty hefty charge for the license ($1,000+). You may want to look into something like FPDF (http://www.fpdf.org/) which utilizes pure PHP code to generate your PDF's.

vangogh
02-06-2012, 01:27 PM
Bill as MyITGuy said WordPress no longer runs on PHP4 and it only opens you up to more security issues so don't have your host downgrade. If phplib has issues with php5 then look for something other than phplib.


but is considerably cheaper when you look at the amount of time I would have spent to create something similar.

Exactly what I was thinking when I suggested buying an application to handle this.

billbenson
02-06-2012, 02:59 PM
I don't want to use multiple applications as that slows the process and multiple propriety applications means a lot of db management to be sure everything matches. Your business and most on this forum don't have the volume of data that goes back and forth. How many quotes do you do a day? I could do 10 to 30 or so.

I don't want to spend time moving data from this application to another when one application, be it a php script can access one central db and do that. I't worth the programming time to me!

It sounds to me that I should set up a second site running php4 for creating my pdf files. I could do that locally as well.


but is considerably cheaper when you look at the amount of time I would have spent to create something similar.

Absolutely NO!

Nothing that integrates to a unique db.

I absolutely don't want to be creating cvs files to stick into other proprietary databases to create reports.

I want a ONE CLICK solution. I can't think of a solution other than writing one! With my skill, it would probable take 40 hours or so.

How much tiime over a year do you think you would spend moving data from application to application to get the report you want?

nealrm
02-06-2012, 04:28 PM
Bill,
I also send out invoices using a php script and MySQL. However, instead of send the HTML code, I just send a link to the invoice. The link goes to a PHP script that queries the database and returns an invoice. The customer can then use the print features in the browse to make a hard copy. I even formatted the page so when printed it has a tear off section for returning with the payment. It's not very hard to do, provided you only want an invoice and not an entire accounting system.

billbenson
02-06-2012, 04:46 PM
Neal, that's interesting. I run into purchasing offices that want it "this" way. Do you have large corporations that are willing to do it "your way"? That's the problem I have with your approach, but I have never tested it...

nealrm
02-06-2012, 05:03 PM
The only real issues I have are with some user that are ... let's say ... computer challenged. Some email programs or settings will prevent being able to just click on the link. You have to copy and paste the link into the browser.

I have not billed much to corporate offices, but I have seen the other side. Generally, if you have the right information they will work with you. With a little bit of formatting you should be able to produce a very standard format invoice. You can even setup multiple scripts to produce formats for specific needs or companies.

billbenson
02-06-2012, 05:52 PM
That certainly is by far the easiest approach Neal. I still want to impliment the pdf approach, but it may be somewhat pain it the butt ish. Worst thing that can happen is the link method doesn't work. One other issue as I'm thinking about it is the pc semi literate may not want to forward the link to others or understand that it can be done that way??

MyITGuy
02-06-2012, 06:16 PM
I don't want to use multiple applications as that slows the process and multiple propriety applications means a lot of db management to be sure everything matches. Your business and most on this forum don't have the volume of data that goes back and forth. How many quotes do you do a day? I could do 10 to 30 or so.

I don't want to spend time moving data from this application to another when one application, be it a php script can access one central db and do that. I't worth the programming time to me!

It sounds to me that I should set up a second site running php4 for creating my pdf files. I could do that locally as well.



Absolutely NO!

Nothing that integrates to a unique db.

I absolutely don't want to be creating cvs files to stick into other proprietary databases to create reports.

I want a ONE CLICK solution. I can't think of a solution other than writing one! With my skill, it would probable take 40 hours or so.

My business doesn't have the volume of data that goes back and forth? :shock: I'd have to disagree with you on that one! =D My system deals with thousands of updates and hundreds of MB of data transfers on a daily basis, most of which have been automated so I don't have to touch any of these items, and it works with several proprietary systems that I utilize as well!

I think I've brought this up elsewhere, but I'm more than happy to repeat myself. You say that it would take you 40 hours to create the application your mentioning. I ask, Do you not value your time? At least enough to see if there is a tool that is out there that you can customize that would make your life easier? To me, 40 hours is 6K worth of lost revenue alone, not even factoring in that if I spent this 40 hours on sales/prospecting that it could generate up to 20K+ in annual revenue...I'd have to assume that you're in the same position, and every hour you spend writing this application is lost revenue/annual sales potential.

I'd much rather spend a few hundred/thousand on a tool that has the essentials, and is something that I can customize to fit my needs rather than starting from scratch and building my own.



How much tiime over a year do you think you would spend moving data from application to application to get the report you want?
I don't spend any time moving data from one application to another...the system I utilize has API/processes already established to do this for me. I'm not talking a handful of applications either...I can name at least a dozen vendors I use that all tie back into my main billing/psa system.

lucas.bowser
02-06-2012, 06:34 PM
If you want to do what your talking about, don't have a link to a script that dynamically generates the html when requested unless your system has the ability to generate point in time invoices, i.e. how they looked exactly on the day they were issued. Instead, have a batch job that generates a static html page for each invoice, which will be stored on your server. That is the link you should be sending to your customer. Besides that, as your script changes and the look and feel of your invoice changes, you may not be able to recreate the original invoice you sent to the customer, which could be embarrassing if the customer wants to review all the versions of it with you.

billbenson
02-06-2012, 10:30 PM
To me, 40 hours is 6K worth of lost revenue alone, not even factoring in that if I spent this 40 hours on sales/prospecting that it could generate up to 20K+ in annual revenue...I'd have to assume that you're in the same position, and every hour you spend writing this application is lost revenue/annual sales potential.

@myitguy

The database is written and outputs the proper reports in html. Figuring out how to save it as a pdf file might take the 40 hours as I have never done that before and it would take some research.

Doing it the way Neal suggested would be a very easy piece of code to write.

One missed phone call, late quote etc could easily cost me the $6k you mention. Your assumption assumes I would be writing the script instead of answering the phone and taking orders. I write code in the evenings and weekends when the phone doesn't ring. 40 hours at two hours a pop in the evening is easily worth the time if it gets me a couple of missed orders a month.

@lucas
There is no real reason to create a static html page. You just need to be able to save all of the information with a date stamp for the order. If you look at most ecommerce programs, this is what they do. You can recreate the report (invoice, quote, whatever) at any time.

lucas.bowser
02-07-2012, 01:03 AM
I must admit that I don't look at many eCommerce scripts. However, Your invoices are legal documents that back up contracts, services, accounting transactions, etc... Though you can do what you say, it is still better when there is a dispute to have the original. This is how the invoice archival feature worked for an ERP system that I worked as a software engineer on. Could I regenerate an invoice from the database data? Sure. That was usually the quickest way to get it, but if there was a dispute with a customer, you wanted the original archived copy so there was no question whether or not the data or programming had changed.

nealrm
02-07-2012, 07:54 AM
I think that both the HTML and PHP ony methods are valid. Adding the PHP code to send the HTML to a file would not be difficult. The storage requirements of storing the HTML code would be minor. You could even store it within the same mySQL database if you wanted. I think this really is a matter of personnel preference. The original archived copy is still code, it is just HTML code vs PHP code. Legality I don't think there would be any difference between the two because both are very easy to change. Some customers might be confused if the format changed, but most would handle a format change. (of course some get confused if you tell them to hit "Any" key)

lucas.bowser
02-07-2012, 09:48 PM
So at the time we implemented our system, the legal requirement, per our lawyers, was either store the documents as a pdf or an image on some type of write once (i.e. CD-R) media. I believe the legal standards have evloved since that time to a softer your procedures and methods produce a document that is "likely to be the same as" standard. So it's not about how easy it is to change, but rather controls and procedures. Because code is constantly maintained, templates change and there can be corrections to invoices in a database, there is an easier argument to be made that a freshly regenerated invoice may not be the same as the original invoice.

While it's true that both examples are code, an html file is static code. It doesn't change unless someone changes the html file, whereas a link to a php script will generate html that could have changed for any number of reasons. For this reason, I would still have a preference for the static archived html file. And as you pointed out, the requirements to do it are trivial; a few lines of code and a little storage space.

billbenson
02-08-2012, 02:56 PM
That's interesting Lucas. Since what I'm thinking of doing would create a pdf and save it on the web server to be added to an email, that would accomplish saving it as a pdf anyway. Also, if I sent it out as an html document with a pdf attachment I would bcc myself on the email which would be another form of backup.

Since in the past I have been sending email invoices manually I have the email backup's for those.

kerrylinux
02-09-2012, 10:02 AM
I want a ONE CLICK solution. I can't think of a solution other than writing one!

I agree with MyITGuy that you might consider to use FPDF for your one-click solution. I've used it in the past to improve the look of PDF invoices VTigerCRM produces. It certainly takes time to learn about the functions, but the visual results you get will be worth your time. It's not so much the time you'll spend on coding but to get the layout right with the fpdf functions, I guess.

billbenson
02-09-2012, 02:34 PM
. It's not so much the time you'll spend on coding but to get the layout right with the fpdf functions, I guess.

Ya, that's why I said 40 hours for generating a pdf with php. It's finding the proper functions for making it look pretty. The basic create a pdf in php is very simple. I'll take a look at FPDF. Even though MyITGuy has a way of handling multiple applications, it makes no sense for me to scrap a system that works, research and get other applications and go to a multi application approach.

MyITGuy
02-09-2012, 04:50 PM
Ya, that's why I said 40 hours for generating a pdf with php. It's finding the proper functions for making it look pretty. The basic create a pdf in php is very simple. I'll take a look at FPDF. Even though MyITGuy has a way of handling multiple applications, it makes no sense for me to scrap a system that works, research and get other applications and go to a multi application approach.

FPDF doesn't have anything to do with the multiple applications part of the discussion, it's just a PHP Class you add a reference to in your your existing code to output the PDF (This addresses the issue where you're host wouldn't enable the PDF Library PDFlib due to the cost/incompatibility they referenced). Thier site also has examples which should help in finding the code you need.

billbenson
02-09-2012, 06:07 PM
FPDF doesn't have anything to do with the multiple applications part of the discussion, it's just a PHP Class you add a reference to in your your existing code to output the PDF (This addresses the issue where you're host wouldn't enable the PDF Library PDFlib due to the cost/incompatibility they referenced). Thier site also has examples which should help in finding the code you need.

Ohhhhhhhhhh. I misunderstood you. Just took a look at it. Looks like that should do exactly what I need! Thanks.

MyITGuy
02-09-2012, 06:52 PM
Ohhhhhhhhhh. I misunderstood you. Just took a look at it. Looks like that should do exactly what I need! Thanks.

No problem. I try to address the immediate concerns first (I.E. FPDF), but also take the long term outlook into consideration (I.E. Looking at an application that can fulfill your needs, but still provide the customization you may want/utilize).

Harold Mansfield
03-03-2012, 10:00 PM
I use a PHP, database backed script called Freelance Manager:
PHP Scripts - Freelance Manager | CodeCanyon (http://codecanyon.net/item/freelance-manager/1225423)

I believe it does everything that you want and makes tracking, projects, support tickets, billing and tasks easier for clients as well.
Payment support for Pay Pal, Authorize.net, Moneybookers, and Alert Pay. (All major credit and debit cards)

I installed it in about 5 minutes, (Customized it in about an hour) on a folder of my existing site and just link to it from the menu.
I have it on SSL, but it's not necessary. It merely provides the payment gateway so it doesn't store or process credit cards.
Clients can log in to pay, or you can send an invoice via email.
I love it!

PM me if you want to try it out from the client side. I have a dummy account created for demo purposes.

This one also looked promising, Ultimate Client Manager:
PHP Scripts - Ultimate Client Manager - Lite Edition | CodeCanyon (http://codecanyon.net/item/ultimate-client-manager-lite-edition/47626?WT.ac=search_item&WT.seg_1=search_item&WT.z_author=dtbaker)