Jump to content

Update header invoice only for new invoices


ABWebSolutions

Recommended Posts

Hi,

I need to change the header of the invoice but I need the invoices that have already been created to remain with the old header.

While now if the customer consults or downloads an invoice already created in the previous months it does not display the old header but displays the new one and this is not good.

Is there a way to block the old heading for invoices already created and to enter the new heading only for the invoices that will be created?

I also noticed that the communications sent previously also change the logo, is it possible to do something?

Let me know something as soon as possible because by tomorrow 1st January 2021 I will have to change the header of the invoice.

Thank you and happy new year!

Link to comment
Share on other sites

Hi Kian and happy new year! Thanks for the answer but i don't know how edit the file, could you help you tell me the exact code that i must put into it?

in practice I would like to keep the old logo and header for invoices issued until 31 December 2020 and starting today 1 January 2021 invoices can be issued with the new logo and new header.

can you help me? If it's not that simple to do I'm willing to pay, it's very important for me to be able to solve this problem as soon as possible by today.

Let me know, thanks for your availability and have a nice day

Link to comment
Share on other sites

in invoicepdf.tpl, you could change the code at the beginning of the template file from...

<?php

# Logo
$logoFilename = 'placeholder.png';
if (file_exists(ROOTDIR . '/assets/img/logo.png')) {
    $logoFilename = 'logo.png';
} elseif (file_exists(ROOTDIR . '/assets/img/logo.jpg')) {
    $logoFilename = 'logo.jpg';
}
$pdf->Image(ROOTDIR . '/assets/img/' . $logoFilename, 15, 25, 75);

to...

<?php

$invoicedate = date('Y-m-d',strtotime($date));
	
# Logo
$logoFilename = 'placeholder.png';
if ($invoicedate < '2021-01-01') {
	if (file_exists(ROOTDIR . '/assets/img/oldlogo.png')) {
		$logoFilename = 'oldlogo.png';
	} elseif (file_exists(ROOTDIR . '/assets/img/oldlogo.jpg')) {
		$logoFilename = 'oldlogo.jpg';
	}
} else {
		if (file_exists(ROOTDIR . '/assets/img/logo.png')) {
		$logoFilename = 'logo.png';
	} elseif (file_exists(ROOTDIR . '/assets/img/logo.jpg')) {
		$logoFilename = 'logo.jpg';
	}
}
$pdf->Image(ROOTDIR . '/assets/img/' . $logoFilename, 15, 25, 75);

and then invoices created before today (1st Jan 2021) would use the old invoice (oldlogo.png or oldlogo.jpg - if using a different file update the code), invoices from today onwards will use logo.png / logo.jpg

Link to comment
Share on other sites

Hi Brian! Thanks for the answer, however, I should also change the header and not just the logo.

For the Italian laws the registration is the most important thing.

In practice I would like to change the header from for example:

SOCIETY 1 BY MARIO ROSSI to COMPANY 2 BY PAOLO BIANCHI

Therefore, as for the logo, also in this case, all invoices issued before January 1st 2021 must have the same heading as COMPANY 1 DI MARIO ROSSI and all invoices issued from January 1st 2021 must be registered as COMPANY 2 DI PAOLO BIANCHI

For me it is really important to be able to solve the problem by today, let me know how I could be able to solve it, in case it is difficult I ask you if you can do it and if so at what cost.

Thanks a lot for your availability, let me know

Link to comment
Share on other sites

into setup > general settings > general > there is the field "pay to next" where if i edit the informations, all the invoice are modified.

 

FOR THE INVOICE CREATED UNTIL OF THE 31/12/2020 I WANT SEE:

MARIO ROSSI
Partita Iva 00000000000
via Torino, 1 - 10100
TORINO (TO) - Italia

Operazione effettuata ai sensi dell’art. 1, commi da 54 a 89, della Legge 190/2014 
così come modificato dalla Legge 208/2015 e dalla Legge 145/2018.

– Regime Forfettario –
Non soggetto a ritenuta d’acconto (art.1, comma 67 Legge 190/2014) Imposta di bollo assolta su originale

__________

FOR THE INVOICE CREATED FROM THE 01/01/2021 I WANT SEE:

PAOLO BIANCHI
Partita Iva 11111111111
via Genova, 2 - 10100
GENOVA (GE) - Italia

Operazione effettuata ai sensi dell’art. 1, commi da 54 a 89, della Legge 190/2014 
così come modificato dalla Legge 208/2015 e dalla Legge 145/2018.

– Regime Forfettario –
Non soggetto a ritenuta d’acconto (art.1, comma 67 Legge 190/2014) Imposta di bollo assolta su originale

__________

 

Let me know, thanks really for the collaboration!

 

Link to comment
Share on other sites

then I would suggest this...

<?php

$invoicedate = date('Y-m-d',strtotime($date));
	
# Logo
$logoFilename = 'placeholder.png';
if ($invoicedate < '2021-01-01') {
	if (file_exists(ROOTDIR . '/assets/img/oldlogo.png')) {
		$logoFilename = 'oldlogo.png';
	} elseif (file_exists(ROOTDIR . '/assets/img/oldlogo.jpg')) {
		$logoFilename = 'oldlogo.jpg';
	}
	$companyaddress = array('MARIO ROSSI','Partita Iva 00000000000','via Torino, 1 - 10100','TORINO (TO) - Italia,','','Operazione effettuata ai sensi dell’art. 1, commi da 54 a 89, della Legge 190/2014','così come modificato dalla Legge 208/2015 e dallaLegge 145/2018.','','– Regime Forfettario –','Non soggetto a ritenuta d’acconto (art.1, comma 67 Legge 190/2014) Imposta di bollo assolta su originale');
} else {
		if (file_exists(ROOTDIR . '/assets/img/logo.png')) {
		$logoFilename = 'logo.png';
	} elseif (file_exists(ROOTDIR . '/assets/img/logo.jpg')) {
		$logoFilename = 'logo.jpg';
	}
}
$pdf->Image(ROOTDIR . '/assets/img/' . $logoFilename, 15, 25, 75);

invoices before today should show the old logo and old company details, any invoice created from today onwards should show new logo and the text from the Pay To field in general settings.

Link to comment
Share on other sites

thank you for your cooperation, you are really top!

 

now it works if I try to view or download the invoice in pdf on the backend side but unfortunately it still doesn't work if you click on "view as customer".

 

In practice, if the customer accesses his customer area (frontend), he always displays the invoice with the new logo and the new header even if it was issued before January 1, 2021.

 

For me, the fundamental thing is to have my customer view and download the correct invoice independently.

 

Otherwise I risk that for example a customer of mine who bought a service in October, if he downloads the invoice now from his customer area, he will see the new owner and this is not good by the law, it is illegal! 😞

 

Can you tell me how I can make the same change for the invoice that is displayed as a customer?

 

Also I have another small problem of little importance ... in practice the old logo that I uploaded is disproportionate and it looks very large, how can I resize it?

 

Thank you very much for your cooperation, I look forward to receiving your communications.

 

Thanks again and good evening!

Link to comment
Share on other sites

Hi, someone could help me also to payment?

For me it’s really important edit also the invoice view from customer (and not only the pdf invoice) how can i do?

Else if isn’t possibile i Ask you how can disable the view and the download of the invoices for my customer.

Let me know something please, it’s really urgent, else i can’t sell the service and create the invoices....

Thanks for the collaboration! Andrea

Link to comment
Share on other sites

14 hours ago, ABWebSolutions said:

now it works if I try to view or download the invoice in pdf on the backend side but unfortunately it still doesn't work if you click on "view as customer".

well that would need a different solution.

14 hours ago, ABWebSolutions said:

Can you tell me how I can make the same change for the invoice that is displayed as a customer?

use an action hook...

<?php

# ViewInvoice Change Logo Hook
# Written by brian!

function hook_view_invoice_change_logo($vars) {
	
	$invoicedate = date('Y-m-d',strtotime($vars['date']));
	if ($invoicedate < '2021-01-01') {
		$oldlogopath = $vars['systemurl'].'assets/img/oldlogo.png';
		$oldpayto = "MARIO ROSSI<br />Partita Iva 00000000000<br />via Torino, 1 - 10100<br />TORINO (TO) - Italia,<br /><br />Operazione effettuata ai sensi dell’art. 1, commi da 54 a 89, della Legge 190/2014<br />così come modificato dalla Legge 208/2015 e dallaLegge 145/2018.<br /><br />– Regime Forfettario –<br />Non soggetto a ritenuta d’acconto (art.1, comma 67 Legge 190/2014) Imposta di bollo assolta su originale')";
		return array("logo" => $oldlogopath, "payto" => $oldpayto);
	}
}
add_hook('ClientAreaPageViewInvoice', 1, 'hook_view_invoice_change_logo');

so create a .php file in /includes/hooks, call it invoicelogo.php (or whatever), paste the above code into it and save - when users view invoices from before this year, they should see the old logo and payto details...

you don't necessarily need to use the same image files for the PDF and HTML invoices - they can be resized and different versions used in each.p91OVRY.png

14 hours ago, ABWebSolutions said:

Also I have another small problem of little importance ... in practice the old logo that I uploaded is disproportionate and it looks very large, how can I resize it?

in invoicepdf.tpl, use....

<?php

$invoicedate = date('Y-m-d',strtotime($date));
	
# Logo
$logoFilename = 'placeholder.png';
if ($invoicedate < '2021-01-01') {
	if (file_exists(ROOTDIR . '/assets/img/oldlogo.png')) {
		$logoFilename = 'oldlogo.png';
	} elseif (file_exists(ROOTDIR . '/assets/img/oldlogo.jpg')) {
		$logoFilename = 'oldlogo.jpg';
	}
	$companyaddress = array('MARIO ROSSI','Partita Iva 00000000000','via Torino, 1 - 10100','TORINO (TO) - Italia,','','Operazione effettuata ai sensi dell’art. 1, commi da 54 a 89, della Legge 190/2014','così come modificato dalla Legge 208/2015 e dallaLegge 145/2018.','','– Regime Forfettario –','Non soggetto a ritenuta d’acconto (art.1, comma 67 Legge 190/2014) Imposta di bollo assolta su originale');
  $pdf->Image(ROOTDIR . '/assets/img/' . $logoFilename, 15, 25, 75);
} else {
	if (file_exists(ROOTDIR . '/assets/img/logo.png')) {
		$logoFilename = 'logo.png';
	} elseif (file_exists(ROOTDIR . '/assets/img/logo.jpg')) {
		$logoFilename = 'logo.jpg';
	}
	$pdf->Image(ROOTDIR . '/assets/img/' . $logoFilename, 15, 25, 75);
}

those 3 numbers, 15,25,75 specify the x position (left->right), the y position (top->bottom) and width of the image in mm - so if you can decide how big the image should be in mm, and then where to position it to suit your design, you can work out what the three figures need to be - it might take you a few goes to get it right.

Link to comment
Share on other sites

thank you so much Brian, you were really great!

 

Now I see the changes on both the pdf invoice and the invoice displayed as a customer but I have a problem.

 

In practice, I can resize the invoice logos displayed in pdf using the command ($ pdf-> Image (ROOTDIR. '/ Assets / img /'. $ LogoFilename, 15, 25, 75);) but unfortunately the old and new logos of the invoices that appear as a customer are not resized and I don't know how to make the change, what can I do?

 

I also take this opportunity to ask you two more things:

 

1) As for the invoices, I would like to keep the communications sent by the system before January 1st 2020 with the old logo and the new communications with the new logo, is it possible?

 

2) I would also like to increase the size of the logo on the frontend side too because it looks small, what can I do? (see https://abwebsolutions.it/area-clienti/clientarea.php)

 

Thanks again for your cooperation, I wish you a happy new year!

Link to comment
Share on other sites

54 minutes ago, ABWebSolutions said:

In practice, I can resize the invoice logos displayed in pdf using the command ($ pdf-> Image (ROOTDIR. '/ Assets / img /'. $ LogoFilename, 15, 25, 75);) but unfortunately the old and new logos of the invoices that appear as a customer are not resized and I don't know how to make the change, what can I do?

for example, if you used the values 10,15,60 on your logo.png image (which seems to be 4176x3500px) - you should see the following...

tEs5Oeb.png

with 10,15,65 the width of the image would be larger...

zlWO6yR.png

it's just a case of playing with the values until you find those which suit your logo and PDF design.

1 hour ago, ABWebSolutions said:

1) As for the invoices, I would like to keep the communications sent by the system before January 1st 2020 with the old logo and the new communications with the new logo, is it possible?

if you're talking about emails, WHMCS doesn't store the headers/footers in the database, only the content of the emails.

if you sent an old invoice to a user, the invoice would use the old logo, but the email would use the new one.... possibly you could get around that by modifying the mail header in general settings, but that could get messy.

possibly what you should really have done, if you knew there were company changes like this, would have been to invest in a multi-brand addon module last year.

1 hour ago, ABWebSolutions said:

2) I would also like to increase the size of the logo on the frontend side too because it looks small, what can I do? (see https://abwebsolutions.it/area-clienti/clientarea.php)

the height of the logo if set using CSS and defaults to 50px...

J1jCrZc.png

as you're using the Six template, you can change it using CSS in a custom.css file

section#header .logo img { max-height: 100px !important; }

pwk9XUG.png

again, it's just a case of playing with the px value to get a suitable height for your logo.

Link to comment
Share on other sites

hi, thank you for all the information, I have practically solved almost all the problems but I still cannot resize the old logo (before January 1, 2021) relating to the invoice that is displayed as a customer. In practice, I correctly view the invoices in pdf with the old logo but I do not see the invoices displayed as a customer well. How can I solve? Thank you very much for everything, have a good evening!

Link to comment
Share on other sites

18 hours ago, ABWebSolutions said:

I have practically solved almost all the problems but I still cannot resize the old logo (before January 1, 2021) relating to the invoice that is displayed as a customer. 

for resizing the logo for the HTML invoice version, I would suggest resizing the image in a photo image program, e.g photoshop etc - if you use placeholder.png as your base, then your large logo will be resized to the same size...

Uh5iM7T.png

XdQhpcT.png

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