Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Signature is not apply correctly on document #26596

Open
homer8173 opened this issue Nov 14, 2023 · 24 comments
Open

Signature is not apply correctly on document #26596

homer8173 opened this issue Nov 14, 2023 · 24 comments
Labels
Bug This is a bug (something does not work as expected)

Comments

@homer8173
Copy link
Contributor

Signature doesn't care about PROPOSAL_FREE_TEXT

$object->generateDocument($defaulttemplate, $langs);

you can have PDF with a signature on the legals

@homer8173 homer8173 added the Bug This is a bug (something does not work as expected) label Dec 5, 2023
@PascalB67
Copy link

Hi, ((in Dolibarr 18.03)
I take advantage of the post,
The signature is at the bottom of the contract page (On 2 pages it's OK).
Only:
-the customer signature is at the bottom left and not on the right.
-the entered name and time information are not included.
Best regards

@18info
Copy link

18info commented Jan 5, 2024

Hello!

Seen on Dolibarr 18.0.3 and 18.0.4

I confirm what @PascalB67 wrote, but I'll add to it:

  • I never seen in change logs an item about the ability to sign on line for the two parts. I discover it when I saw the customer signature on my box
  • I asked again to the customer to sign after I suppressed the pdf and sign it by myself before him. He received a pdf with mine but my sign was replaced (I have now a pdf for each signature).
  • After the second signing it's not locked. The customer can sign multiple times and Dolibarr add a pdf each time
  • There's no notification item on signing event. Like for proposal, it will be really useful.

Best regards,

@PascalB67
Copy link

Thank you for your clarification, I modified the location of the signature in the code, on occasion I will look to override this.

Yes, on the other hand, as a development, a message warning of the signature would be a good idea, even essential.

Best regards

@18info
Copy link

18info commented Jan 5, 2024

Thank you too.
Could you write here when the PR will be integrated please?
(It will be useful for me to know in which version it will be corrected.)

Best regards,

@18info
Copy link

18info commented Jan 5, 2024

Yes, on the other hand, as a development, a message warning of the signature would be a good idea, even essential.

We have already an issue arround this: no email sent when proposal is signed online #20204

@PascalB67
Copy link

Thank you but nothing in 18.03 maybe en 18.04 ... ?

@18info
Copy link

18info commented Jan 5, 2024

Welcome. No change with the .4

@simogeo
Copy link

simogeo commented Mar 11, 2024

Hi ,I'm using dolibarr 19 with same issue here .... any news ? thanks

@18info
Copy link

18info commented Mar 15, 2024

Hello,
Please, elaborate. Did you reproduce what I described on the 01.05?
Have a good'day

@simogeo
Copy link

simogeo commented Mar 15, 2024

Thanks for your reply @18info

This is how I process :

  1. copy / paste the link from the contract page - see screenshot
  2. share the link with the customer who sign it. The signature is always on the left block (but should be on the right part - customer block)
  3. whatever as administrator I sign the document before or after, It does just overwrite the signature if already there

contract page

Thanks for your help

@PascalB67 do you have any workaround to share ?

@18info
Copy link

18info commented Mar 18, 2024

Hello!
ok, same problem between contacts and propals. I'm going to try to reproduce on my side quickly.

Apart of, You could use e-mail models with the following var in the body to share the online sign link by email through Dolibarr (w/o copy/paste) : __ONLINE_SIGN_URL__ (like for propal ; Conf / Emails / Email models).

Apologies for the lag.

@simogeo
Copy link

simogeo commented Mar 18, 2024

Hello! ok, same problem between contacts and propals. I'm going to try to reproduce on my side quickly.

I think I should be able to fix it but I have no time to inquire on my side right now. And by the way, a fix form the repo would be much better.

Apart of, You could use e-mail models with the following var in the body to share the online sign link by email through Dolibarr (w/o copy/paste) : __ONLINE_SIGN_URL__ (like for propal ; Conf / Emails / Email models).

That, I did already.

Apologies for the lag.

No worries. Thanks !

@18info
Copy link

18info commented Mar 18, 2024

On 19.0.0, confirmed using the exact names of the two signatories (to answer the question I was asking myself: could the problem be linked to the name given at the signature?). The second signature always replace the first and it's always on the left.

I'm going to upgrade to 19.0.1, read the change-log and test again.

@18info
Copy link

18info commented Mar 18, 2024

Bug confirmed on 19.0.1 too.
There doesn't seem to be anything about this in the chang-log.

@simogeo
Copy link

simogeo commented Mar 18, 2024

Thanks for your contribution @18info

Yes, probably a naming issue !? Was it working well on a previous version ?

@homer8173
Copy link
Contributor Author

homer8173 commented Mar 18, 2024

Hello,
PROPOSAL_FREE_TEXT has never worked with signature. The bug is here since the beginning of the signature functionality.

@18info
Copy link

18info commented Mar 18, 2024

Thanks for your contribution @18info

You're welcome :)

Yes, probably a naming issue !? Was it working well on a previous version ?

It seems to be not about naming issue.
For contracts, my older is dated 2022.01.01, it didn't work as well as the renewal in 2023.
± identical for proposals

@homer8173
Copy link
Contributor Author

I just opened the code of the online sign, it take the last page of the document en place the sign there.

there is no notification for contract and intervention.

i suggest to store within the PDF the location of the signature :
`// Définir les métadonnées
$metadata = array(
'SignatureZone' => array(
'x' => 50, // Coordonnée x de la zone de signature
'y' => 50, // Coordonnée y de la zone de signature
'width' => 100, // Largeur de la zone de signature
'height' => 50 // Hauteur de la zone de signature
)
);

// Convertir le tableau de métadonnées en chaîne JSON
$metadata_json = json_encode($metadata);

// Définir les métadonnées dans le document PDF
$pdf->setMetadata($metadata_json);`

and to retrive it later when we open the document :

`
// Récupérer les métadonnées
$metadata_json = $pdf->getMetadata();

// Décoder les métadonnées JSON en tableau associatif
$metadata = json_decode($metadata_json, true);

// Vérifier si les métadonnées contiennent les informations sur la zone de signature
if (isset($metadata['SignatureZone'])) {
// Extraire les informations sur la zone de signature
$signature_zone = $metadata['SignatureZone'];
$x = $signature_zone['x'];
$y = $signature_zone['y'];
$width = $signature_zone['width'];
$height = $signature_zone['height'];

// Utilisez ces informations pour placer la signature dans le document PDF
// Par exemple :
// $pdf->Image('chemin/vers/image_signature.png', $x, $y, $width, $height);

} `

@18info
Copy link

18info commented Mar 19, 2024

Hello!
Many thanks for for this.
Are the name and date included in?
PR?

@simogeo
Copy link

simogeo commented Mar 23, 2024

Hi everyone, here is a fix that works well for me.

  1. Prepare your PNG file including signature. Size should be 720x180px and upload it to /dolibarr/documents/contract/signature.png
  2. In /htdocs/core/onlineSign.php, replace the dolPrintSignatureImage() function by this new version :
/**
 * Output the signature file
 *
 * @param 	TCPDF 		$pdf		PDF handler
 * @param	Translate	$langs		Language
 * @param	array		$params		Array of params
 * @return	void
 */
function dolPrintSignatureImage(TCPDF $pdf, $langs, $params)
{
       global $conf;

	$default_font_size = pdf_getPDFFontSize($langs);	// Must be after pdf_getInstance
	$default_font = pdf_getPDFFont($langs);	// Must be
	$xforimgstart = $params['xforimgstart'];
	$yforimgstart = $params['yforimgstart'];
	$wforimg = $params['wforimg'];

       // contractor part
	$name ='Put your name here';
	$file = $conf->contrat->dir_output.'/signature.png';
	$offset = 100; // X offset for customer
	$pdf->SetXY($xforimgstart, $yforimgstart + round($wforimg / 4) - 1);
	$pdf->SetFont($default_font, '', $default_font_size - 2);
	$pdf->SetTextColor(80, 80, 80);
	$pdf->MultiCell($wforimg, 4, $langs->trans("Signature") . ': ' . dol_print_date(dol_now(), "day", false, $langs, true). ' - '. $name, 0, 'L');
	// The size of your image should be be 720x180px 
	$pdf->Image($file, $xforimgstart, $yforimgstart, 80, round(80 / 4));
	
       // customer part
	$pdf->SetXY($xforimgstart + $offset, $yforimgstart + round($wforimg / 4) - 1);
	$pdf->SetFont($default_font, '', $default_font_size - 2);
	$pdf->SetTextColor(80, 80, 80);
	$pdf->MultiCell($wforimg, 4, $langs->trans("Signature") . ': ' . dol_print_date(dol_now(), "day", false, $langs, true). ' - '.$params['online_sign_name'], 0, 'L');
	$pdf->Image($params['pathtoimage'], $xforimgstart + $offset, $yforimgstart, $wforimg, round($wforimg / 4));

	return;
}
  1. You can change the $name var value or set an empty string. It should works out of the box. If not, you can play with $offset value ...
  2. Send your contract to your customers !

@18info
Copy link

18info commented Apr 10, 2024

Hello!
Thank you very² much @simogeo !

It could be really really useful to have the ability to do it for each user trough the webUI.
What do you think about a new issue as feature request?

@simogeo
Copy link

simogeo commented Apr 10, 2024

@18info : sure ! I let you create the feature request and refer to the workaround I've proposed if useful

@18info
Copy link

18info commented Apr 10, 2024

@simogeo 👌 (need few days to)

@18info
Copy link

18info commented Apr 12, 2024

@simogeo Done!
Feel free to feed or correct it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug This is a bug (something does not work as expected)
Projects
None yet
Development

No branches or pull requests

4 participants