Jump to content

change title on pdf attachment email


durangod

Recommended Posts

I have changed the actual pdf attachment, but how do you change the actual text that shows in the pdf email.

 

The attachment email has a title (subject), when you click on it, then it will open the pdf. But the subject of that email, where is that created.

 

Its not in invoicepdf, its not in lang, its not in the template. So where are the attachements email titles formed at? Is it in the actual email php files?

 

thanks

Link to comment
Share on other sites

well i'm confused as to whether you're talking about an invoice pdf or a pdf attachment sent with another email. :twisted:

 

your first port of call should be email templates - that's where all the email subjects are defined.

 

setup -> email templates

Edited by brian!
Link to comment
Share on other sites

ok thanks brian, yeah im talking about the pdf invoice attatchment email. When you pay a invoice you get the Invoice Payment Confirmation email and along with that is a pdf attachment. Its the subject on that attachment email that im referring to. It shows the invoice number as the subject and i need to change that number.

 

I didnt see it in the templates earlier but now that i have some rest behind me ill take another sharper eyed look.

 

Thanks... ;)

 

- - - Updated - - -

 

no attachment email there, i have already done the payment confirmation. I just need the attachment email.

Link to comment
Share on other sites

yeah i used merge fields to take care of the invoice number mod i needed to do from my hook.. but that did not affect the subject of the attachment, just the payment confirm.

 

yeah the invoice number is in the subject which i need to change also with merge fields if i can.

 

- - - Updated - - -

 

i guess im expecting to see something pop up in the attachments block at the top... maybe thats not how it works lol..

Link to comment
Share on other sites

No not the filename, i dont need to change the name of the pdf file unless the filename is used as the subject. I did some testing yesterday and it appears that what i need is hardcoded. I thought at first i might be able to do an if else in the lang file to manipulate the number but since the number is tied directly into the seqencial numbering {NUMBER} it overwrites what i do so not much i can do on that front.

 

This is one of the reasons that i am being forced to convert this into a full mod. My project was all done for the client nicely wrapped up and perfect until this last tiny little item called a email subject. So what im having to do is turn this into a full fledge addon which will allow for more features and allow us to be able to uncheck the item in admin setup invoices about allowing pdf invoices with invoice emails. And at the same time replacing that with our own invoice process which will allow us to set our own subject or none at all..

 

All of this work for one little subject line that WHMCS didnt allow us access to.... lol I do get excited sometimes when i think oh wait i can do it this way, and then sadly i realize nope that wont work either, dang lol.... :)

Link to comment
Share on other sites

When a invoice is paid there is a Invoice Payment Confirmation email that goes out and attached to that email is the pdf invoice. You can turn that off as per what brian was talking about in the admin by unchecking that item. But i dont need to turn it off.

 

There is a subject line on that attachement that has the invoice number, that is what i need to change. Its the attachment subject line itself. If you want to test it just create and invoice and mark it paid and youll see the email and the attachment the comes with it.

 

What i did was i hooked the invoice out and the paid invoice in order to change the number as per what my client needed. But i cant change the subject because that come directly from the seq input and not the db is suspect. If it came from the db tblinvoices then i would have no issue but it does not. So i have no access to that as its internally formated. I hope that explains it.

Link to comment
Share on other sites

I really don't get what you mean by the "Attachment subject"? What subject?

 

You have an email and it has a subject... attacheched to that email you get a file and it can only have a name xxx.pdf, which also you can change.

 

Are you talking about the PDF file settings which you can see if you open the PDF file and take a look at the info?

 

Are you trying to enable some sort of sequential numbering for some of your clients without enabling the "Sequential Paid Invoice Numbering" option for your whole WHMCS system? Can't see a single reason for you to do that but ok... :lol:

Link to comment
Share on other sites

because his accountant wants all invoices to be a certain way beyond what we can do with the seq input.

 

For example the accountant wants paid paypal only to have WH14-PP-102 and paid everything else to have WH14-102

 

I have already finished with all the hooks and everything in order to do the email, invoice and database in such a way to meet clients specs. But the invoice itself has WH14-PP-102 but the subject is WH14-102 and that wont work for the client.

 

The reason is that the subject or filename or however WHMCS does it or wherever the data orginates, it seems like it comes directly and is formated directly from the seq input WH14-{NUMBER} in admin and it does not allow me to manipulate it outside of that.

 

Title subject filename whatever you want to call the thing that sits in the subject line of the attachement, thats what i need to change. And you cant change the filename other than via the tblinvoice field or the seq name in admin and neighter of those will work to accomplish this. There is no hook for that and so i did everything else via a hook but cant do that with one.

 

Does that make better since. I feel very strong that the function that creates the filename or subject is in an encrypted file.

 

here is a pic to help explain what i mean.

 

invoicesample.jpg

 

- - - Updated - - -

 

So what im saying is that i changed the invoice number on the invoice itself, and it didnt change that subject, so that subject or filename has to come from another source other than via hook or via tblinvoice field. Because everything else is perfect but that is still static and wont change.

 

The reason i cant use the seq number input for paid is because i have to use a dif seq number for paid, so along with my hooks i have a pp counter just for paid pp invoices.

Edited by durangod
Link to comment
Share on other sites

yes sir i already have that implemented and yet that filename does not change, which is why i was saying that it has to come from a secured function someplace.

 

that screen shot was from my third party email client, and i dont know where that name comes from.

 

I did a search of the avail vars, took me quite a while to find it but i think its part of the $DATA array, but im not 100% because i cant see what it does i just know there is a data invoicenum

 

 

i already have this in my invoicepdf.tpl file

 

 


/* 
********************************************************************
mod by icodemods.com for client to show custom invoice format
********************************************************************
*/

    $ppaltext = "PP-";

   //get values from table
    $getValue = "SELECT `paymentmethod` FROM `tblinvoices` WHERE `invoicenum` = '$invoicenum'";
    $res = mysql_query($getValue) or die(mysql_error());
    $results = mysql_fetch_row($res);
    $pay = $results[0];

     if($pay == "paypal")
     {
       $parts = explode('-',$invoicenum);
       $invoicenum = $parts[0]."-".$ppaltext.$parts[1]; 
      }//close if

//mod end
//###################################################################################

Edited by durangod
Link to comment
Share on other sites

Ok...

 

Add this to your PDF invoice template, after that modification of yours:

 

$_LANG['invoicefilename'] = $invoicenum;

 

There's really no reason why that shouldn't work for you. I'm using seq. invoice numbering for years now and i have no problems with that.

 

A simple if else statement keeps my attachment names in check.

 

If Paid -> $_LANG['invoicefilename'] = proforma-invoice-number

Else -> $_LANG['invoicefilename'] = seq-invoice-number+whatever i want

Link to comment
Share on other sites

  • 2 weeks later...

unfortunately that didnt work all that came out was this WH14-pp-2WH14-2 the first part is right but then it does it again.

 

Anyway i did a list of the pdf array object and took me some time but i think i found it..

 

I believe its called [title:protected]

 

i tried to set a var to $pdf->[title:protected] but it could not find it..

 

i know that it is

 

$pdf-> something

 

because thats what i did the print r on i traced it back in the object (2200 lines long) to the beginning and it is part of the first element.. so i know its address is

$pdf-> something

 

but im not sure how to get the value.. i assume since its protected there has to be a pdf function that is used to grasp the value but i have no clue what that might be.. maybe Cell i dont know..

 

Anyone know how to get the value of a pdf array on a protected element?

 

update...

 

i did find this http://fpdf.org/en/doc/

 

Text did not work

 

so i did an object listing on the avail vars and found several that could be it.

 

Im thinking the only way to do this is to set everything i can find including the vars to a number 1 - 9 and see which one comes up on the title.

 

I still think its the $pdf -> title:protected but i have no idea how to grab that value from a pdf format object

 

$pdf->[title:protected] or $pdf->[title] does not work

Edited by durangod
Link to comment
Share on other sites

This is soooooo frustrating, one tiny little title is causing so much headache. I did change those values and its none of those items either. So now im sifting thru array outputs line by line to find something.

 

 

well after a week of looking for this thing i think i finally found it.... its called $data['invoicenum'] i think, well im fairly sure as some of the vars close by in the listing are for pdf type stuff. But im not sure i can even get to it or modify it as its hard coded. Due to the vars around it im fairly cofident this is it but im not sure where it comes from or how its created but from the looks of it i would be very suprised if it was not. LOL of course i have been wrong now how many times lol...

 

and its not the $data thats in the pdf file at the top, thats a dif format array and it does ot have invoicenum in it.

 

sure it might be easier to tell the client its just not possible to change the filename but i dont believe that. And until i exhaust every possibility im not going to do that.

Edited by durangod
Link to comment
Share on other sites

The protected title var is nothing more that the PDF file title attribute.

 

If the problem you're facing is only that your email software shows the wrong name for your PDF attachments, than it's quite obvious that the e-mail software reads the PDF Title attribute and displays it as your file description.

 

PDF filename != PDF Title attribute. You can set the attribute yourself.

 

All you need to do is: $pdf->SetTitle("WHATEVER, COME ON DUDE!");

 

If that's the case, you should make your questions much simpler and more to the point :)

Link to comment
Share on other sites

no that was not it, the reason is that the title/filename is set after the tplinvoice file runs, and i tested that by setting the title and filename best i could via sorting thru tons and tons of vars available, and then it changed after that file ran.

 

However i did figure it out finally, i need some dance music lol..... and it was by accident that i figured it out. It has to do with using the right hook at the right time. dance dance dance :!:

Link to comment
Share on other sites

if you run InvoicePaid and EmailPreSend hooks together even if you use 1 and 2 order many times if you are updating records you will get a race condition as the new value will not yet be posted before you call it. That is what i set out to fix. In the process i changed my hook to InvoicePaidPreEmail which sets things up nicely and actually also just happens to set the var i needed for the title/filename call. So when i tested it actually all works now perfectly.

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