diff --git a/htdocs/core/ajax/onlineSign.php b/htdocs/core/ajax/onlineSign.php index 47a7a2b6f13..c3fd2e75cf8 100644 --- a/htdocs/core/ajax/onlineSign.php +++ b/htdocs/core/ajax/onlineSign.php @@ -59,6 +59,7 @@ $signature = GETPOST('signaturebase64'); $ref = GETPOST('ref', 'aZ09'); $mode = GETPOST('mode', 'aZ09'); // 'proposal', ... $SECUREKEY = GETPOST("securekey"); // Secure key +$online_sign_name = GETPOST("onlinesignname"); $error = 0; $response = ""; @@ -103,6 +104,10 @@ if ($action == "importSignature") { $upload_dir = !empty($conf->propal->multidir_output[$object->entity])?$conf->propal->multidir_output[$object->entity]:$conf->propal->dir_output; $upload_dir .= '/'.dol_sanitizeFileName($object->ref).'/'; + $default_font_size = pdf_getPDFFontSize($langs); // Must be after pdf_getInstance + $default_font = pdf_getPDFFont($langs); // Must be after pdf_getInstance + $langs->loadLangs(array("main", "companies")); + $date = dol_print_date(dol_now(), "%Y%m%d%H%M%S"); $filename = "signatures/".$date."_signature.png"; if (!is_dir($upload_dir."signatures/")) { @@ -167,7 +172,14 @@ if ($action == "importSignature") { $yforimgstart = (empty($s['h']) ? 240 : $s['h'] - 60); $wforimg = $s['w'] - 20 - $xforimgstart; + $pdf->SetXY($xforimgstart, $yforimgstart + round($wforimg / 4) - 4); + $pdf->SetFont($default_font, '', $default_font_size); + $pdf->MultiCell($wforimg, 4, $langs->trans("DateSigning").': '.dol_print_date(dol_now(), "daytext", false, $langs, true), 0, 'L'); + $pdf->SetXY($xforimgstart, $yforimgstart + round($wforimg / 4)); + $pdf->MultiCell($wforimg, 4, $langs->trans("Lastname").': '.$online_sign_name, 0, 'L'); + $pdf->Image($upload_dir.$filename, $xforimgstart, $yforimgstart, $wforimg, round($wforimg / 4)); + //$pdf->Close(); $pdf->Output($newpdffilename, "F"); @@ -187,7 +199,6 @@ if ($action == "importSignature") { $db->begin(); $online_sign_ip = getUserRemoteIP(); - $online_sign_name = ''; // TODO Ask name on form to sign $sql = "UPDATE ".MAIN_DB_PREFIX."propal"; $sql .= " SET fk_statut = ".((int) $object::STATUS_SIGNED).", note_private = '".$db->escape($object->note_private)."',"; diff --git a/htdocs/public/onlinesign/newonlinesign.php b/htdocs/public/onlinesign/newonlinesign.php index a19d0f1fc7b..ac88f7b638f 100644 --- a/htdocs/public/onlinesign/newonlinesign.php +++ b/htdocs/public/onlinesign/newonlinesign.php @@ -548,7 +548,7 @@ print ''; if ($action == "dosign" && empty($cancel)) { print '
'; print ''; - print ''; + print ''; print '
'; print '
'; // Do not use class="reposition" here: It breaks the submit and there is a message on top to say it's ok, so going back top is better. @@ -569,6 +569,7 @@ if ($action == "dosign" && empty($cancel)) { console.log("We click on button sign"); $("#signbutton").val(\''.dol_escape_js($langs->transnoentities('PleaseBePatient')).'\'); var signature = $("#signature").jSignature("getData", "image"); + var name = document.getElementById("name").value; $.ajax({ type: "POST", url: "'.DOL_URL_ROOT.'/core/ajax/onlineSign.php", @@ -577,6 +578,7 @@ if ($action == "dosign" && empty($cancel)) { "action" : "importSignature", "token" : \''.newToken().'\', "signaturebase64" : signature, + "onlinesignname" : name, "ref" : \''.dol_escape_js($REF).'\', "securekey" : \''.dol_escape_js($SECUREKEY).'\', "mode" : \''.dol_escape_htmltag($source).'\', @@ -598,6 +600,7 @@ if ($action == "dosign" && empty($cancel)) { $("#clearsignature").on("click",function(){ $("#signature").jSignature("clear"); $("#signbutton").attr("disabled",true); + // document.getElementById("onlinesignname").value = ""; }); $("#signbutton").attr("disabled",true);