Jump to content

Please help with custom client fields in invoice


wonderland

Recommended Posts

Hello,

 

I did look through wiki and almost found everything I need , except one small thing.

 

I'm using this code in invoicepdf.tpl

if ($clientsdetails["customfields1"]) {

       $pdf->Cell(0,6,$clientsdetails["customfields1"],0,1,'L');

   }

 

Which surely enough displays fieldvalue of customfield1

 

But I would like to display fieldname : fieldvalue

 

How could I do this ?

Link to comment
Share on other sites

This question has been asked many times, to most this is difficult... Maybe a forum mod can can move this post to "Tips and Tricks"

 

Place this code at the top (under the <?php) of the invoicepdf.tpl

$result22a = mysql_query("SELECT `tblcustomfields`.`fieldname` , `tblcustomfieldsvalues`.`value` FROM tblcustomfields, tblcustomfieldsvalues WHERE `tblcustomfields`.`id` = `tblcustomfieldsvalues`.`fieldid` AND `tblcustomfields`.`type` = 'client' AND `tblcustomfieldsvalues`.`relid` = {$clientsdetails['userid']}");
while ($data22a = mysql_fetch_assoc($result22a)){
   $clientsdetails["customfields"]["{$data22a["fieldname"]}"]["fieldname"] = $data22a["fieldname"];
   $clientsdetails["customfields"]["{$data22a["fieldname"]}"]["value"] = $data22a["value"];
}

As an example the array will be added to the clientsdetails array like this

Array
(
   [userid] => 1
   [id] => 1
   [firstname] => Test
   [lastname] => Tester
   [companyname] => 
   [email] => REMOVED
   [address1] => REMOVED
   [address2] => 
   [city] => REMOVED
   [state] => Queensland
   [postcode] => 4280
   [country] => Australia
   [countryname] => Australia
   [phonenumber] => 0123456789
   [notes] => You have unpaid invoices... pay now to avoid suspension of your account
   [password] => REMOVED
   [currency] => 1
   [defaultgateway] => banktransfer
   [cctype] => 
   [cclastfour] => 
   [securityqid] => 0
   [securityqans] => 
   [groupid] => 0
   [status] => Active
   [credit] => 0.00
   [taxexempt] => 
   [latefeeoveride] => 
   [overideduenotices] => 
   [separateinvoices] => 
   [disableautocc] => 
   [language] => english
   [lastlogin] => Date: 21/01/2012 15:05<br>IP Address: xxx.xxx.xxx.xxx<br>Host: xxx.xxx.xxx.xxx
   [customfields1] => 14123145125
   [customfields2] => 
   [billingcid] => 0
   [customfields] => Array
       (
           [ABN] => Array
               (
                   [fieldname] => ABN
                   [value] => 14123145125
               )

           [Recieve Marketing Emails] => Array
               (
                   [fieldname] => Recieve Marketing Emails
                   [value] => 
               )

       )

)

Then use it like this (going from the customfields array output above)

if ($clientsdetails["customfields"]["ABN"]) {
   $pdf->Cell(0,6,$clientsdetails["customfields"]["ABN"]["fieldname"]." : ".$clientsdetails["customfields"]["ABN"]["value"] ,0,1,'L'); 
}

Hope this has helped someone.

Edited by sparky
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated