computers.wheneva Posted April 20, 2011 Share Posted April 20, 2011 Hi All We are currently busy customising our pdf template, but would like to know if the following is possible. Firstly is there a list avaialbe of all the fieldnames that are available under $clientdetails['fieldname']. I have looked at http://wiki.whmcs.com/PDF_Invoice_Customisationbut only shows the basic ones and clientsdetails["fieldname"] - etc... Secondly how is there a way of retrieving the registered domain name into your template, not the product description just the domain name eg. http://www.somedomain.tld, we have tried different combinations for example ($clientdetails['domain'], {'domain_name'}, $domain and so forth but not sucessfull. Thirdly how to you run the mySQL Statements within the invoicepdf.tpl file we have tried but keeps on returning with a Response Code #42 or #49. Herewith a sample of the SQL Statment $conn = mysql_connect("localhost","username","password"); $sql = mysql_query('SELECT * FROM tblclients',$conn) Thanking all in advance Computers Wheneva http://www.wheneva.co.za 0 Quote Link to comment Share on other sites More sharing options...
sohouk Posted April 20, 2011 Share Posted April 20, 2011 As far as I know, the fields available to the PDF invoice are the same as the regular invoice in viewinvoice.tpl. I can't find any docs that confirm this (Matt / John?), but I have copied them below for ease. In relation to getting data out, then this should be useful. http://www.fpdf.org/en/script/script10.php BTW, ($clientdetails['domain'], {'domain_name'}, seems wrong. The domain name is in a differing table and should be referenced using the domain ID. Trevor Invoice fields for viewinvoice.tpl: Remember that any entries in the language.txt file are also available to use (handy for messages) The specific ones I have noted are as follows: userid id firstname lastname companyname email address1 address2 city state postcode country countryname phonenumber notes password currency cctype cclastfour securityqid securityqans groupid status credit taxexemp latefeeoveride overideduenotices separateinvoices disableautocc language lastlogin Outputs the Date a <br> and then the IP Address customfields n billingcid id (This is the item ID) type (Domain / Hosting etc) relid description (Description text) amount 0 Quote Link to comment Share on other sites More sharing options...
computers.wheneva Posted April 21, 2011 Author Share Posted April 21, 2011 thanks for the reply, but all the listed fields above are entered as $clientsdetails["fieldname"] or are some of them direct requests. SQL Questions +-+ is this possible $con = mysql_connect($serv,$user,$pass); if (!$con){die('Could not connect: ' . mysql_error());} mysql_select_db($db, $con); $result = mysql_query("SELECT tblinvoices.invoicenum, tblorders.ordernum, tbldomains.domain FROM tblinvoices, tbldomains, tblorders WHERE tblinvoices.id = $invoicenum GROUP BY tblinvoices.userid"); while($row = mysql_fetch_array($result)) {$pdf->Text(163, 26, $row['ordernum']);$pdf->Ln(1);} mysql_close($con); 0 Quote Link to comment Share on other sites More sharing options...
sohouk Posted April 21, 2011 Share Posted April 21, 2011 The list represents the variables available to the viewinvoice.tpl template and includes not only client details, but invoice items and amounts. As I mentioned, I am not certain they are all available in the pdf invoice, but it’s likely to be the case. The SQL looks about right - though I have little knowledge about Sql stuff). The best way is to simply test it Rather than mess up the pdf invoice template, you should back it up and then make any changes (maybe on a separate page of the invoice out of the way of the working stuff) A good way is to put all your SQL stuff in a separate file and call that from the pdf template Put include("myquerysql.php"); in the template somewhere before the data. This file should contain your sql stuff. $con = mysql_connect($serv,$user,$pass); if (!$con){die('Could not connect: ' . mysql_error());} mysql_select_db($db, $con); $result = mysql_query("SELECT tblinvoices.invoicenum, tblorders.ordernum, tbldomains.domain FROM tblinvoices, tbldomains, tblorders WHERE tblinvoices.id = $invoicenum GROUP BY tblinvoices.userid"); while($row = mysql_fetch_array($result)) {$pdf->Text(163, 26, $row['ordernum']);$pdf->Ln(1);} mysql_close($con); Then, if it all goes wrong you just have to comment out the mysqlquery.php line Trevor 0 Quote Link to comment Share on other sites More sharing options...
tohms Posted May 29, 2011 Share Posted May 29, 2011 Remember that any entries in the language.txt file are also available to use (handy for messages) Do you have more infos on this? 0 Quote Link to comment Share on other sites More sharing options...
sohouk Posted May 29, 2011 Share Posted May 29, 2011 The use of the language file is one of the fundamental blocks of Smarty and the template system. Essentially, providing you specify the file (and this is done for you by WHMCS in the templates), you just reference that value in that file using the Smarty braces. So, if in the language file you have; myownlittlemessage = "Hello World" then in your template, the tag {$LANG.myownlittlemessage} will extract the value of the language file and display 'Hello World' Look at any of the .tpl files and you will see that where it says {$LANG.xxxxxxxxx}, the actual page is displaying the text from the language file. If you only ever use one language then its not such an issue, but it does make keeping templates very easy as you only have to change one value in the language file, but you can re-use it over again in many templates. Trevor 0 Quote Link to comment Share on other sites More sharing options...
tohms Posted May 30, 2011 Share Posted May 30, 2011 Ah that's what you've meant. 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.