add name and date on sign propal

This commit is contained in:
Anthony Berton
2023-02-25 01:54:13 +01:00
parent 70f2d25e71
commit 5e8fc026cb
2 changed files with 16 additions and 2 deletions

View File

@@ -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)."',";

View File

@@ -548,7 +548,7 @@ print '<tr><td class="center">';
if ($action == "dosign" && empty($cancel)) {
print '<div class="tablepublicpayment">';
print '<input type="button" class="buttonDelete small" id="clearsignature" value="'.$langs->trans("ClearSignature").'">';
print '<input type="text" class="" id="onlinesignname" name="onlinesignname" placeholder="'.$langs->trans("Lastname").'">';
print '<input type="text" class="" id="name" placeholder="'.$langs->trans("Lastname").'">';
print '<div id="signature" style="border:solid;"></div>';
print '</div>';
// 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);