computerwitness Posted November 3, 2007 Share Posted November 3, 2007 Hi, I want to add the Payment Method information to my PDF invoice. For example, I have a Bank Transfer payment gateway. When looking at the Printable Invoice, the Bank transfer details are displayed. How do I get this information, in the same format, to display somewhere within my PDF? 0 Quote Link to comment Share on other sites More sharing options...
computerwitness Posted November 8, 2007 Author Share Posted November 8, 2007 No suggestions? 0 Quote Link to comment Share on other sites More sharing options...
isdoo Posted November 8, 2007 Share Posted November 8, 2007 You can add the information just above the footer in the template. I display all our payment options in the footer for invoices that are unpaid - if the invoice is cancelled this then changes to a cancellation notice, and if they have paid it displays a notice of thanks for their payment. I have done the same for the plain print version. There is a post on here with some suggestions on how to display the text. In order to display alternatives you need to use an if statement - you can copy the if statement and alter it to your own wishes from higher up in the pdf template. The reason I display all options is because although the invoice maybe set to say Bank Transfer, the client may with to pay be cheque or credit card. 0 Quote Link to comment Share on other sites More sharing options...
PPH Posted November 8, 2007 Share Posted November 8, 2007 You can add the information just above the footer in the template. I display all our payment options in the footer for invoices that are unpaid - if the invoice is cancelled this then changes to a cancellation notice, and if they have paid it displays a notice of thanks for their payment. I have done the same for the plain print version. There is a post on here with some suggestions on how to display the text. In order to display alternatives you need to use an if statement - you can copy the if statement and alter it to your own wishes from higher up in the pdf template. The reason I display all options is because although the invoice maybe set to say Bank Transfer, the client may with to pay be cheque or credit card. And to help users that find this post by searching as well as the original poster, you could add the if code to your post? 0 Quote Link to comment Share on other sites More sharing options...
isdoo Posted November 9, 2007 Share Posted November 9, 2007 The if code is already in the template and is used to display Paid, unpaid & cancelled in large letters - I do not have the code in front of me otherwise I would have posted sorry. 0 Quote Link to comment Share on other sites More sharing options...
a.borg Posted November 11, 2007 Share Posted November 11, 2007 Hi, I put together some code for it. This code should go in the pdfconfig.php file located in the "includes" folder. Keep in mind to backup ur old file, just in case. There are 2 diffrent ways to use it. You can select to show the wire information if the payment is unpayed or chose to show it all the time(recommeded). You change this on the first line like this: $ShowOnPayed = "1"; //This is gonna show the wire information all the time. $ShowOnPayed = "0"; //This is only gonna show the wire information when the invoice is unpayed. You change the texts location by changing line 146 and line 147. Line 146 is ordinate (standard is 75) Line 147 is abscissa (standard is 50) If you wish to change the space between the lines change the value of the variable $linebreaks on line 148 Enjoy Best regards, Alexander Borg <?php $ShowOnPayed = "1"; // 1 Shows the bankinformation even if the invoice is payed || 0 Shows the bankinformation only if the invoice isn't payed function wire_analize($payed) { if($status=="Cancelled" OR $status=="Paid") { $InvoiceActive = 0; } else { $InvoiceActive = 1; } if ($payed==1) { return true; // true } elseif ($InvoiceActive==0 && $payed==0) { return false; // false } elseif ($InvoiceActive==1 && $payed==0) { return true; // false } } # 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'); //wire_print(); $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)); ///////----Wire transfer if(wire_analize($ShowOnPayed)) { $query = "SELECT * FROM tblpaymentgateways WHERE gateway = 'banktransfer' && setting = 'instructions'"; $result = mysql_query($query); while ($data = mysql_fetch_array($result)) { $pdf->SetTextColor(0); $pdf->SetFont('Arial','',; $wireinfo = explode("\n", $data['value']); $ordinate = 75; $abscissa = 50; $linebreaks = 3; for ( $i = 0; $i <= count($wireinfo); $i += 1) { $pdf->SetXY($abscissa,$ordinate); $pdf->Write(5,trim($wireinfo[$i])); $ordinate = $ordinate + $linebreaks; } } //$pdf->Write(5,mysql_error()); (debugging) } //else //returns false(debugging) //{ // $pdf->SetTextColor(0); // $pdf->SetFont('Arial','',; // $pdf->SetXY(50,80); // $pdf->Write(5,"Failed"); //} //////----Wire Transfer # 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); ?> Report any bugs in here. I might work further on this when I have some time over for it. 0 Quote Link to comment Share on other sites More sharing options...
computerwitness Posted November 27, 2007 Author Share Posted November 27, 2007 Hi, This has been a huge help. I'll play about with positioning of the text etc later. Only thing though is that the bank details now display on ALL pdf invoices, regardless of the selected payment method. How can I restrict it so that this only displays the wire transfer details when the relevant payment method is selected within the invoice options? Thanks 0 Quote Link to comment Share on other sites More sharing options...
computerwitness Posted November 27, 2007 Author Share Posted November 27, 2007 Hi, Further to my previous post, what I would REALLY like, is for it to show the Payment Method & Instructions regardless of which Payment Method was Selected. E.g. If Payment Method = Bank Transfer, Then Display would show "Payment Method: Bank Transfer Name" and the associated payment instructions. If Payment Method = Mail In Payment, then display would show "Payment Method: Mail In Payment Name" and the associated payment instructions. Is this possible? Much more complex? 0 Quote Link to comment Share on other sites More sharing options...
isdoo Posted November 27, 2007 Share Posted November 27, 2007 Bear in mind - just because the account is set to say credit card, it doesn't mean that the client wouldn't prefer to pay via bank transfer - I prefer to include all items on mine - of course if the invoice is paid or cancelled then the message changes. 0 Quote Link to comment Share on other sites More sharing options...
nibblesmctwitch Posted November 28, 2007 Share Posted November 28, 2007 I put the code below in my pdf config and i don't see any thing on the invoice. Did i miss sonthing? Hi, I put together some code for it. This code should go in the pdfconfig.php file located in the "includes" folder. Keep in mind to backup ur old file, just in case. There are 2 diffrent ways to use it. You can select to show the wire information if the payment is unpayed or chose to show it all the time(recommeded). You change this on the first line like this: $ShowOnPayed = "1"; //This is gonna show the wire information all the time. $ShowOnPayed = "0"; //This is only gonna show the wire information when the invoice is unpayed. You change the texts location by changing line 146 and line 147. Line 146 is ordinate (standard is 75) Line 147 is abscissa (standard is 50) If you wish to change the space between the lines change the value of the variable $linebreaks on line 148 Enjoy Best regards, Alexander Borg <?php$ShowOnPayed = "1"; // 1 Shows the bankinformation even if the invoice is payed || 0 Shows the bankinformation only if the invoice isn't payed function wire_analize($payed) { if($status=="Cancelled" OR $status=="Paid") { $InvoiceActive = 0; } else { $InvoiceActive = 1; } if ($payed==1) { return true; // true } elseif ($InvoiceActive==0 && $payed==0) { return false; // false } elseif ($InvoiceActive==1 && $payed==0) { return true; // false } } ///////----Wire transferif(wire_analize($ShowOnPayed)){ $query = "SELECT * FROM tblpaymentgateways WHERE gateway = 'banktransfer' && setting = 'instructions'"; $result = mysql_query($query); while ($data = mysql_fetch_array($result)) { $pdf->SetTextColor(0); $pdf->SetFont('Arial','',; $wireinfo = explode("\n", $data['value']); $ordinate = 75; $abscissa = 50; $linebreaks = 3; for ( $i = 0; $i <= count($wireinfo); $i += 1) { $pdf->SetXY($abscissa,$ordinate); $pdf->Write(5,trim($wireinfo[$i])); $ordinate = $ordinate + $linebreaks; } } //$pdf->Write(5,mysql_error()); (debugging)} //else //returns false(debugging)//{ // $pdf->SetTextColor(0);// $pdf->SetFont('Arial','',;// $pdf->SetXY(50,80);// $pdf->Write(5,"Failed");//} //////----Wire Transfer 0 Quote Link to comment Share on other sites More sharing options...
computerwitness Posted November 30, 2007 Author Share Posted November 30, 2007 Do you have the Bank Transfer payment gateway activated within your configuration? 0 Quote Link to comment Share on other sites More sharing options...
a.borg Posted December 16, 2007 Share Posted December 16, 2007 I'm gonna look into this within a day or two. Sorry for the delay, I've had quite a few projects on my own. Hi, Further to my previous post, what I would REALLY like, is for it to show the Payment Method & Instructions regardless of which Payment Method was Selected. E.g. If Payment Method = Bank Transfer, Then Display would show "Payment Method: Bank Transfer Name" and the associated payment instructions. If Payment Method = Mail In Payment, then display would show "Payment Method: Mail In Payment Name" and the associated payment instructions. Is this possible? Much more complex? 0 Quote Link to comment Share on other sites More sharing options...
isdoo Posted December 16, 2007 Share Posted December 16, 2007 If this is of any use, this is the code that I wrote.... # Payment info at the bottom... if ($status=="Cancelled") { $pdf->SetXY(10,231); $pdf->SetTextColor(0, 0, 205); $pdf->SetFont('Arial', 'B', 6.5); # Use 6.5pt Text $pdf->MultiCell(180, 3, "Invoice Cancelled:", 0, 'J'); $pdf->SetFont('Arial', '', 6.5); # Use 6.5pt Text $pdf->MultiCell(180, 3, "We have cancelled your invoice number $invoicenum.\n\nIf you have any queries, please email......", 0, 'J'); } elseif ($status=="Unpaid") { $pdf->SetXY(10,231); # Set Location $pdf->SetTextColor(0, 0, 205); $pdf->SetFont('Arial', 'B', 6.5); # Use 6.5pt Text $pdf->MultiCell(180, 3, "Paying by Bank Transfer:", 0, 'J'); $pdf->SetFont('Arial', '', 6.5); # Use 6.5pt Text $pdf->MultiCell(180, 3, "bank details\nSort code: go\nAccount Number: here\nAccount Name: ...", 0, 'J'); $pdf->SetFont('Arial', '', 6.5); # Use 6.5pt Text $pdf->MultiCell(180, 3, "Please quote invoice number as unique reference.\nPlease send an email notification of your bank transfer to ..... advising us of the following: Payer's Name; Date of payment; Amount; Invoice Number(s) so that we can allocate your payment to the correct invoice(s).", 0, 'J'); $pdf->SetFont('Arial', 'B', 6.5); # Use 6.5pt Text $pdf->MultiCell(180, 3, "\nPaying by Cheque:", 0, 'J'); $pdf->SetFont('Arial', '', 6.5); # Use 6.5pt Text $pdf->MultiCell(180, 3, "Cheques should be made payable to '.....' and sent to .......\nPlease write your name, company name (if applicable) and invoice number(s) on the rear.", 0, 'J'); $pdf->SetFont('Arial', 'B', 6.5); # Use 6.5pt Text $pdf->MultiCell(180, 3, "\nPaying Online:", 0, 'J'); $pdf->SetFont('Arial', '', 6.5); # Use 6.5pt Text $pdf->MultiCell(180, 3, "You can make payment by credit card using the billing system at http://www.domain.com/.....", 0, 'J'); } elseif ($status=="Paid") { $pdf->SetXY(10,231); $pdf->SetTextColor(0, 0, 205); $pdf->SetFont('Arial', 'B', 6.5); # Use 6.5pt Text $pdf->MultiCell(180, 3, "Thank you for your payment:", 0, 'J'); $pdf->SetFont('Arial', '', 6.5); # Use 6.5pt Text $pdf->MultiCell(180, 3, "Many thanks for your payment, which we have credited to your invoice number $invoicenum. \n\nIf you have any queries on your account please email ......", 0, 'J'); } This goes above # Footer in pdfconfig.php 0 Quote Link to comment Share on other sites More sharing options...
a.borg Posted December 16, 2007 Share Posted December 16, 2007 Fixed some bugs and added the request by computerwitness. If the instructions empty in the database, the output is gonna be: Payment gateway: GATEWAYNAME. I'm only aware of wire and pay by mail using the instructions's column. <?php $ShowOnPayed = "1"; // 1 Shows the bankinformation even if the invoice is payed || 0 Shows the bankinformation only if the invoice isn't payed function wire_analize($payed, $status) { if($status=="Cancelled" OR $status=="Paid") { $InvoiceActive = 0; } else { $InvoiceActive = 1; } if ($payed==1) { return true; // true } elseif ($InvoiceActive==0 && $payed==0) { return false; // false } elseif ($InvoiceActive==1 && $payed==0) { return true; // false } } # 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'); //wire_print(); $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)); ///////----Wire transfer if(wire_analize($ShowOnPayed, $status)) { $query = "SELECT gateway1.value AS instructions, gateway2.value AS name FROM tblinvoices left join tblpaymentgateways gateway1 ON gateway1.gateway = tblinvoices.paymentmethod && gateway1.setting = 'instructions' left join tblpaymentgateways gateway2 ON gateway2.gateway = tblinvoices.paymentmethod && gateway2.setting = 'name' WHERE ( tblinvoices.invoicenum = '".$invoicenum."' OR tblinvoices.id = '".$invoicenum."' )"; $result = mysql_query($query); while ($data = mysql_fetch_assoc($result)) { $gatewayName = $data['name']; $gatewayInstructions = $data['instructions']; } $paymentGateways = "Payment gateway: ".$gatewayName."\n"; $paymentGateways .= $gatewayInstructions; $pdf->SetTextColor(0); $pdf->SetFont('Arial','',; $gatewayinfo = explode("\n", $paymentGateways); $ordinate = 75; $abscissa = 50; $linebreaks = 3; for ( $i = 0; $i <= count($gatewayinfo); $i += 1) { $pdf->SetXY($abscissa,$ordinate); $pdf->Write(5,trim($gatewayinfo[$i])); $ordinate = $ordinate + $linebreaks; } } //////----Wire Transfer # 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); ?> 0 Quote Link to comment Share on other sites More sharing options...
Terra Posted April 16, 2008 Share Posted April 16, 2008 Just to say thanks to isdoo - worked a treat! I removed the if/else statement to show info at all times, and works perfectly. Many thanks! Edith 0 Quote Link to comment Share on other sites More sharing options...
craigge Posted May 7, 2008 Share Posted May 7, 2008 Isdoo, This is great! just what I needed, thanks a bunch Mr-E 0 Quote Link to comment Share on other sites More sharing options...
SilverNodashi Posted May 14, 2008 Share Posted May 14, 2008 Fixed some bugs and added the request by computerwitness. If the instructions empty in the database, the output is gonna be: Payment gateway: GATEWAYNAME.I'm only aware of wire and pay by mail using the instructions's column. <?php $ShowOnPayed = "1"; // 1 Shows the bankinformation even if the invoice is payed || 0 Shows the bankinformation only if the invoice isn't payed function wire_analize($payed, $status) { if($status=="Cancelled" OR $status=="Paid") { $InvoiceActive = 0; } else { $InvoiceActive = 1; } if ($payed==1) { return true; // true } elseif ($InvoiceActive==0 && $payed==0) { return false; // false } elseif ($InvoiceActive==1 && $payed==0) { return true; // false } } # 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'); //wire_print(); $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)); ///////----Wire transfer if(wire_analize($ShowOnPayed, $status)) { $query = "SELECT gateway1.value AS instructions, gateway2.value AS name FROM tblinvoices left join tblpaymentgateways gateway1 ON gateway1.gateway = tblinvoices.paymentmethod && gateway1.setting = 'instructions' left join tblpaymentgateways gateway2 ON gateway2.gateway = tblinvoices.paymentmethod && gateway2.setting = 'name' WHERE ( tblinvoices.invoicenum = '".$invoicenum."' OR tblinvoices.id = '".$invoicenum."' )"; $result = mysql_query($query); while ($data = mysql_fetch_assoc($result)) { $gatewayName = $data['name']; $gatewayInstructions = $data['instructions']; } $paymentGateways = "Payment gateway: ".$gatewayName."\n"; $paymentGateways .= $gatewayInstructions; $pdf->SetTextColor(0); $pdf->SetFont('Arial','',; $gatewayinfo = explode("\n", $paymentGateways); $ordinate = 75; $abscissa = 50; $linebreaks = 3; for ( $i = 0; $i <= count($gatewayinfo); $i += 1) { $pdf->SetXY($abscissa,$ordinate); $pdf->Write(5,trim($gatewayinfo[$i])); $ordinate = $ordinate + $linebreaks; } } //////----Wire Transfer # 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); ?> Althought this works well, it doesnt' work well in the space where it prints out. So, can it not instead be put right at the bottom, just above #footer? I've moved the code to above the #footer, but it still prints out next to the "Invoiced To" field, above the product info, which in our case doesn't look good, since I need to put in a lot of text in that small box. 0 Quote Link to comment Share on other sites More sharing options...
eugenevdm Posted May 19, 2008 Share Posted May 19, 2008 We are using a bank draft system (called Debit Orders in the UK and SA) and this post really helped me. The problem we had is our debit orders only gets processed at the end of the month and every time we sent out invoices (14 days before due date) all our regular customers got irate saying why are they receiving these Unpaid Invoices. For people who are looking to just figure out how to determine the payment method use these four lines of code: $query = "SELECT paymentmethod FROM tblinvoices WHERE tblinvoices.id = $invoicenum"; $result = mysql_query($query); $data = mysql_fetch_row($result); $paymentmethod = $data[0]; Hopefully someone from WHMCS will see this post and maybe implement a $paymentmethod variable that we can use directly instead of reverting to sql. 0 Quote Link to comment Share on other sites More sharing options...
dutchnet Posted May 19, 2008 Share Posted May 19, 2008 Hi, It would be even better to be able to prevent WHMCS to send payment reminders for certain payment methods. We use direct debet as well and people get very very annoyed with the reminders about payments being overdue. We tend to charge their accounts only once a month but invoices are send 30 days before being due with reminders being send 14 days and 7 days before due date. Customers with direct debet account thus receive the invoice and 2 reminders for no reason at all. 0 Quote Link to comment Share on other sites More sharing options...
eugenevdm Posted May 19, 2008 Share Posted May 19, 2008 Hi, It would be even better to be able to prevent WHMCS to send payment reminders for certain payment methods. We use direct debet as well and people get very very annoyed with the reminders about payments being overdue. We tend to charge their accounts only once a month but invoices are send 30 days before being due with reminders being send 14 days and 7 days before due date. Customers with direct debet account thus receive the invoice and 2 reminders for no reason at all. Yippee someone who is in the same dilemma as me. We have exactly the same problem. We really would like to turn off overdue reminders depending on the payment method. Our workaround was to change the first, second, and third overdue notices to 41, 50, and 60 days after the due date. The reasoning was that we process our debit orders on the 25th of the month and about 41 days would have passed before we are able to mark them as paid (e.g. customer gets a service on the 26th of this month, and mark as paid will happen on the 5th of the month following next month). The risk we now have is that we are letting ALL our customers use our services with up to 60 days before they are suspended. This is going to be a huge problem later on and is already unearthing some worms. dutchnet, WHMCS is very open to 'feature requests'. I have approached them already regarding this issue, but because they thought it might only affect a small WHMCS user population they saw it as a custom development and put it on hold. If you could maybe approach them as ask for similar functionality at least there would be some weight behind the request. 0 Quote Link to comment Share on other sites More sharing options...
ausloki Posted June 10, 2008 Share Posted June 10, 2008 Did anything eventuate from this in the mainstream distribution or only customer customisation attemptes ? 0 Quote Link to comment Share on other sites More sharing options...
eugenevdm Posted June 10, 2008 Share Posted June 10, 2008 As far as I know there are only customer customisation attempts. See here if you want an overview of the mainstream road map: http://dev.whmcs.com/ 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.