FIX online signature, better error management.
This commit is contained in:
parent
a0d56b6db7
commit
61739cc338
@ -122,28 +122,44 @@ if ($action == "importSignature") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!$error) {
|
if (!$error) {
|
||||||
$newpdffilename = $upload_dir.$ref."_signed-".$date.".pdf";
|
// Defined modele of doc
|
||||||
|
$directdownloadlink = $object->getLastMainDocLink('proposal');
|
||||||
|
|
||||||
$pdf = pdf_getInstance();
|
if (preg_match('/\.pdf/i', $directdownloadlink)) {
|
||||||
$pdf->Open();
|
$newpdffilename = $upload_dir.$ref."_signed-".$date.".pdf";
|
||||||
$pdf->AddPage();
|
$sourcefile = $upload_dir.$ref.".pdf";
|
||||||
$pagecount = $pdf->setSourceFile($upload_dir.$ref.".pdf"); // original PDF
|
|
||||||
|
|
||||||
for ($i=1;$i<($pagecount+1);$i++) {
|
if (dol_is_file($sourcefile)) {
|
||||||
if ($i>1) $pdf->AddPage();
|
$pdf = pdf_getInstance();
|
||||||
$tppl=$pdf->importPage($i);
|
$pdf->Open();
|
||||||
$pdf->useTemplate($tppl);
|
$pdf->AddPage();
|
||||||
|
$pagecount = $pdf->setSourceFile($sourcefile); // original PDF
|
||||||
|
|
||||||
|
for ($i=1; $i<($pagecount+1); $i++) {
|
||||||
|
if ($i>1) $pdf->AddPage();
|
||||||
|
$tppl=$pdf->importPage($i);
|
||||||
|
$pdf->useTemplate($tppl);
|
||||||
|
}
|
||||||
|
|
||||||
|
$pdf->Image($upload_dir.$filename, 129, 239.6, 60, 15); // FIXME Position will be wrong with non A4 format. Use a value from width and height of page minus relative offset.
|
||||||
|
$pdf->Close();
|
||||||
|
$pdf->Output($newpdffilename, "F");
|
||||||
|
|
||||||
|
// Index the new file and update the last_main_doc property of object.
|
||||||
|
$object->indexFile($newpdffilename, 1);
|
||||||
|
}
|
||||||
|
} elseif (preg_match('/\.odt/i', $directdownloadlink)) {
|
||||||
|
// Adding signature on .ODT not yet supported
|
||||||
|
// TODO
|
||||||
|
} else {
|
||||||
|
// Document format not supported to insert online signature.
|
||||||
|
// We should just create an image file with the signature.
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$pdf->Image($upload_dir.$filename, 129, 239.6, 60, 15); // FIXME Position will be wrong with non A4 format. Use a value from width and height of page minus relative offset.
|
if (!$error) {
|
||||||
$pdf->Close();
|
|
||||||
$pdf->Output($newpdffilename, "F");
|
|
||||||
|
|
||||||
$db->begin();
|
$db->begin();
|
||||||
|
|
||||||
// Index the new file and update the last_main_doc property of object.
|
|
||||||
$object->indexFile($newpdffilename, 1);
|
|
||||||
|
|
||||||
$online_sign_ip = getUserRemoteIP();
|
$online_sign_ip = getUserRemoteIP();
|
||||||
$online_sign_name = ''; // TODO Ask name on form to sign
|
$online_sign_name = ''; // TODO Ask name on form to sign
|
||||||
|
|
||||||
|
|||||||
@ -941,7 +941,8 @@ abstract class CommonObject
|
|||||||
// Add entry into index
|
// Add entry into index
|
||||||
if ($initsharekey) {
|
if ($initsharekey) {
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
|
||||||
// TODO We can't, we dont' have full path of file, only last_main_doc adn ->element, so we must rebuild full path first
|
|
||||||
|
// TODO We can't, we dont' have full path of file, only last_main_doc and ->element, so we must first rebuild full path $destfull
|
||||||
/*
|
/*
|
||||||
$ecmfile->filepath = $rel_dir;
|
$ecmfile->filepath = $rel_dir;
|
||||||
$ecmfile->filename = $filename;
|
$ecmfile->filename = $filename;
|
||||||
|
|||||||
@ -321,6 +321,13 @@ if ($source == 'proposal') {
|
|||||||
print '<tr class="CTableRow2"><td class="CTableRow2 tdtop">'.$langs->trans("Designation");
|
print '<tr class="CTableRow2"><td class="CTableRow2 tdtop">'.$langs->trans("Designation");
|
||||||
print '</td><td class="CTableRow2">'.$text;
|
print '</td><td class="CTableRow2">'.$text;
|
||||||
if ($object->status == $object::STATUS_VALIDATED) {
|
if ($object->status == $object::STATUS_VALIDATED) {
|
||||||
|
if (empty($object->last_main_doc) || !dol_is_file(DOL_DATA_ROOT.'/'.$object->last_main_doc)) {
|
||||||
|
// It seems document has never been generated, or was generated and the deleted.
|
||||||
|
// So we try to regenerate it with its default template.
|
||||||
|
$defaulttemplate = ''; // We force the use an empty string instead of $object->model_pdf to be sure to use a "main" default template and not the last one used.
|
||||||
|
$object->generateDocument($defaulttemplate, $langs);
|
||||||
|
}
|
||||||
|
|
||||||
$directdownloadlink = $object->getLastMainDocLink('proposal');
|
$directdownloadlink = $object->getLastMainDocLink('proposal');
|
||||||
if ($directdownloadlink) {
|
if ($directdownloadlink) {
|
||||||
print '<br><a href="'.$directdownloadlink.'">';
|
print '<br><a href="'.$directdownloadlink.'">';
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user