sisgroup Posted October 13, 2007 Share Posted October 13, 2007 Hi all, is there a template file within the WHMCS file that i can edit to make me invoice look a little more sexy looking? 0 Quote Link to comment Share on other sites More sharing options...
jonathanjab Posted October 16, 2007 Share Posted October 16, 2007 For the PDF, you'll need to get down-and-dirty with PHP as it's managed in includes/pdfconfig.php by manipulating the FPDF class. It isn't done using a Smarty Template like the rest of the site. 0 Quote Link to comment Share on other sites More sharing options...
sisgroup Posted October 16, 2007 Author Share Posted October 16, 2007 Ahhh poop i wonder if this can be made a request for Matt to make it a little more simple to edit maybe make it a Smarty in the next version 0 Quote Link to comment Share on other sites More sharing options...
jonathanjab Posted October 16, 2007 Share Posted October 16, 2007 The problem with that is that Smarty is for the HTML 'language', and PDF's are built around Postscript. You'd need a convert, and, although they do exist, most are not particularly good. It took me about 2-3 hours, but it's quite simple so long as you know a little PHP and you draw out what you want first. The measurements (X, Y or Width/Height) are in millimeters and the fpdf documentation contains all you need to know. 0 Quote Link to comment Share on other sites More sharing options...
sisgroup Posted October 16, 2007 Author Share Posted October 16, 2007 would you recermend any good HTML to Postscript coverters? 0 Quote Link to comment Share on other sites More sharing options...
jonathanjab Posted October 16, 2007 Share Posted October 16, 2007 I can't, as I've never used any of them (although the one that comes with Kayako is particularly bad). However, without re-coding, they won't work with WHMCS as WHMCS relies works with the FPDF class - WHMCS creates the class, sets up the basics and then runs pdfconfig.php, within which you put on the contents on the page before the running returns to WHMCS and it handles the rest (finalizing and retuning the PDF to the client, or adding it to the e-mail). 0 Quote Link to comment Share on other sites More sharing options...
sisgroup Posted October 16, 2007 Author Share Posted October 16, 2007 Oh i see, This is what im looking to do is add some text right at the bottom of the invoice not sure if this is at all possible with the current version on WHMCS? 0 Quote Link to comment Share on other sites More sharing options...
jonathanjab Posted October 16, 2007 Share Posted October 16, 2007 It depends on how you want to do it. If you're looked to just add some text to the end, you could use Ln() and Write() to put in some gaps and then 'Write' the text. If you're looking to fix it at the bottom of the page (e.g. Terms of Payment), then you may want to use SetXY() and MultiCell(), where SetXY() will position the top-left of the box, and MultiCell() to set the width and write the text: $pdf->SetXY(80,255); # Set Location $pdf->SetFont('', '', 6.5); # Use 6.5pt Text $pdf->MultiCell(110, 3, "Your text can go here\n\nand be split over lines", 0, 'J'); # Add Text 0 Quote Link to comment Share on other sites More sharing options...
sisgroup Posted October 16, 2007 Author Share Posted October 16, 2007 This is what i have done but its not displaying the text on the PDF invoice i have added the above code to the very bottom of my pdfconfig.php file labled "# My Addition" <?php # Logo $pdf->Image(dirname(__FILE__).'/../images/logo.jpg',15,10,50); # Company Details $pdf->SetFont('Arial','',13); $pdf->Cell(0,6,$companyname,0,1,'R'); $pdf->SetFont('Arial','',; for ( $i = 0; $i <= 4; $i += 1) { $pdf->Cell(0,4,trim($companyaddress[$i]),0,1,'R'); } $pdf->Ln(5); # Header Bar $invoiceprefix = $_LANG["invoicenumber"]; /* ** This code should be uncommented for EU companies using the sequential invoice numbering so that when unpaid it is shown as a proforma invoice ** if ($status!="Paid") { $invoiceprefix = $_LANG["proformainvoicenumber"]; } */ $pdf->SetFont('Arial','B',15); $pdf->SetFillColor(239); $pdf->Cell(0,8,$invoiceprefix.$invoicenum,0,1,'L','1'); $pdf->SetFont('Arial','',10); $pdf->Cell(0,6,$_LANG["invoicesdatecreated"].': '.$datecreated.'',0,1,'L','1'); $pdf->Cell(0,6,$_LANG["invoicesdatedue"].': '.$duedate.'',0,1,'L','1'); $pdf->Ln(10); # Clients Details $pdf->Cell(0,4,$_LANG["invoicesinvoicedto"],0,1); $pdf->SetFont('Arial','',; if ($clientsdetails["companyname"]) { $pdf->Cell(0,4,$clientsdetails["companyname"],0,1,'L'); $pdf->Cell(0,4,$_LANG["invoicesattn"].": ".$clientsdetails["firstname"]." ".$clientsdetails["lastname"],0,1,'L'); } else { $pdf->Cell(0,4,$clientsdetails["firstname"]." ".$clientsdetails["lastname"],0,1,'L'); } $pdf->SetFont('Arial','',; $pdf->Cell(0,4,$clientsdetails["address1"],0,1,'L'); if ($clientsdetails["address2"]) { $pdf->Cell(0,4,$clientsdetails["address2"],0,1,'L'); } $pdf->Cell(0,4,$clientsdetails["city"].", ".$clientsdetails["state"].", ".$clientsdetails["postcode"],0,1,'L'); $pdf->Cell(0,4,$clientsdetails["country"],0,1,'L'); $pdf->Ln(10); $pdf->SetDrawColor(200); $pdf->SetFont('Arial','B',10); $pdf->SetFillColor(239); $pdf->Cell(148,7,$_LANG["invoicesdescription"],1,0,'C','1'); $pdf->Cell(40,7,$_LANG["invoicesamount"],1,0,'C','1'); $pdf->Ln(); $pdf->SetFont('Arial','',10); foreach ($invoiceitems AS $item) { if (strlen($item["description"])>85) { $pdf->Cell(148,6,substr($item["description"],0,85),1); $pdf->Cell(40,6,$currencysymbol.$item["amount"],1,0,'C'); $pdf->Ln(); $pdf->Cell(148,6,substr($item["description"],85),1); $pdf->Cell(40,6,"",1,0,'C'); } else { $pdf->Cell(148,6,$item["description"],1); $pdf->Cell(40,6,$currencysymbol.$item["amount"],1,0,'C'); } $pdf->Ln(); } $pdf->SetFont('Arial','B',10); $pdf->Cell(148,7,$_LANG["invoicessubtotal"].":",1,0,'R','1'); $pdf->Cell(40,7,$currencysymbol.$subtotal,1,0,'C','1'); $pdf->Ln(); if ($CONFIG["TaxEnabled"]) { $pdf->Cell(148,7,$taxrate."% ".$_LANG["invoicestax"].":",1,0,'R','1'); $pdf->Cell(40,7,$currencysymbol.$tax,1,0,'C','1'); $pdf->Ln(); } $pdf->Cell(148,7,$_LANG["invoicescredit"].":",1,0,'R','1'); $pdf->Cell(40,7,$currencysymbol.$credit,1,0,'C','1'); $pdf->Ln(); $pdf->Cell(148,7,$_LANG["invoicestotal"].":",1,0,'R','1'); $pdf->Cell(40,7,$currencysymbol.$total,1,0,'C','1'); $pdf->Ln(); $pdf->Ln(); if ($notes) { $pdf->SetFont('Arial','',; $pdf->MultiCell(188,5,$_LANG["invoicesnotes"].": $notes"); } if ($status=="Cancelled") { $pdf->SetXY(80,80); $statustext = $_LANG["invoicescancelled"]; } elseif ($status=="Unpaid") { $pdf->SetXY(120,80); $statustext = $_LANG["invoicesunpaid"]; } elseif ($status=="Paid") { $pdf->SetXY(120,80); $statustext = $_LANG["invoicespaid"]; } $pdf->SetFont('Arial','B',40); $pdf->SetTextColor(245); $pdf->Write(5,strtoupper($statustext)); # Footer $pdf->SetMargins(15, 27, 15); // left, top, right $pdf->SetAutoPageBreak(TRUE, 25); // TRUE, margin down $pdf->SetFooterMargin(10); $pdf->SetFooterFont(array('arial', '', ); // @array font, type (B, I, BI), size $pdf->SetFooterData($CONFIG["Domain"] . " - ".$_LANG["page"]." {pg} / {nb}"); $pdf->setPrintHeader(false); $pdf->setPrintFooter(true); # My addition $pdf->SetXY(80,255); # Set Location $pdf->SetFont('', '', 6.5); # Use 6.5pt Text $pdf->MultiCell(110, 3, "Your text can go here\n\nand be split over lines", 0, 'J'); ?> 0 Quote Link to comment Share on other sites More sharing options...
jonathanjab Posted October 16, 2007 Share Posted October 16, 2007 Try moving your addition to just above the '#Footer' bit. 0 Quote Link to comment Share on other sites More sharing options...
sisgroup Posted October 16, 2007 Author Share Posted October 16, 2007 ok now i see the txt but its a very light gray and hard to read can i change that? 0 Quote Link to comment Share on other sites More sharing options...
jonathanjab Posted October 16, 2007 Share Posted October 16, 2007 That's being controlled by the $pdf->SetTextColor(245); command above (all commands that write text after this command will have a light-grey color). To revert back to black, add $pdf->SetTextColor(0); just before the text you're writing. 0 Quote Link to comment Share on other sites More sharing options...
sisgroup Posted October 16, 2007 Author Share Posted October 16, 2007 Is there a way i can move the txt up the page a little as its sitting at the bottom 0 Quote Link to comment Share on other sites More sharing options...
jonathanjab Posted October 16, 2007 Share Posted October 16, 2007 Change the second part of the SetXY() statement - the first is the X (how far from the left-hand-side) and the second is the Y (how far from the top). 0 Quote Link to comment Share on other sites More sharing options...
apollo1 Posted October 16, 2007 Share Posted October 16, 2007 Good thread. Hopefully there will be a feature implemented in the future to make it easier to add and format some lines of text to the PDF invoice. 0 Quote Link to comment Share on other sites More sharing options...
jonathanjab Posted October 16, 2007 Share Posted October 16, 2007 I can understand some peoples concerns - having to work with PHP to manipulate the content isn't easy for some people, but I like the raw control available by directly working with FPDF as we've managed to create a PDF invoice that's an exact copy of our paper version, including letterhead. 0 Quote Link to comment Share on other sites More sharing options...
brianoz Posted October 19, 2007 Share Posted October 19, 2007 I can't, as I've never used any of them (although the one that comes with Kayako is particularly bad). However, without re-coding, they won't work with WHMCS as WHMCS relies works with the FPDF class - WHMCS creates the class, sets up the basics and then runs pdfconfig.php, within which you put on the contents on the page before the running returns to WHMCS and it handles the rest (finalizing and retuning the PDF to the client, or adding it to the e-mail). Not true; there are fpdf libraries around on the net - I think in the fpdf site itself - that convert from HTML to PDF. I'm not sure how fine grained the control is, and I know it will never be as good a control as writing in FPDF itself. One converter is here: http://html2fpdf.sourceforge.net/ 0 Quote Link to comment Share on other sites More sharing options...
jonathanjab Posted October 20, 2007 Share Posted October 20, 2007 However, like I said, WHMCS relies of FPDF, and HTML2PDF in an extension of FPDF, and requires custom coding in order to support HTML. You can't just drop it in. However, it may be possible to create your own copy of the FPDF class, apply the HTML2PDF extension, create a new $pdf instance, and then directly create the HTML in the pdfconfig.php class, which you can pass to your new class. In theory, when $pdf is returned to WHMCS it'll work with the functions from the parent class, unbeknown that it's working on a derivate, and may make it easer. I've done something similar by creating my own copy of the FPDF class (with a number of extensions), called it JPDF and then set $pdf = new JPDF(); WHMCS hasn't had a problem with it and it works fine. 0 Quote Link to comment Share on other sites More sharing options...
minadreapta Posted November 3, 2007 Share Posted November 3, 2007 could you share this modified class and an example of pdfconfg.php please? am i asking too much? i am not a php expert but i would like a prettier invoice for my customers. thanks. 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.