FIX online signature, better error management.
This commit is contained in:
parent
a0d56b6db7
commit
61739cc338
@ -122,28 +122,44 @@ if ($action == "importSignature") {
|
||||
}
|
||||
|
||||
if (!$error) {
|
||||
$newpdffilename = $upload_dir.$ref."_signed-".$date.".pdf";
|
||||
// Defined modele of doc
|
||||
$directdownloadlink = $object->getLastMainDocLink('proposal');
|
||||
|
||||
$pdf = pdf_getInstance();
|
||||
$pdf->Open();
|
||||
$pdf->AddPage();
|
||||
$pagecount = $pdf->setSourceFile($upload_dir.$ref.".pdf"); // original PDF
|
||||
if (preg_match('/\.pdf/i', $directdownloadlink)) {
|
||||
$newpdffilename = $upload_dir.$ref."_signed-".$date.".pdf";
|
||||
$sourcefile = $upload_dir.$ref.".pdf";
|
||||
|
||||
for ($i=1;$i<($pagecount+1);$i++) {
|
||||
if ($i>1) $pdf->AddPage();
|
||||
$tppl=$pdf->importPage($i);
|
||||
$pdf->useTemplate($tppl);
|
||||
if (dol_is_file($sourcefile)) {
|
||||
$pdf = pdf_getInstance();
|
||||
$pdf->Open();
|
||||
$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.
|
||||
$pdf->Close();
|
||||
$pdf->Output($newpdffilename, "F");
|
||||
|
||||
if (!$error) {
|
||||
$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_name = ''; // TODO Ask name on form to sign
|
||||
|
||||
|
||||
@ -941,7 +941,8 @@ abstract class CommonObject
|
||||
// Add entry into index
|
||||
if ($initsharekey) {
|
||||
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->filename = $filename;
|
||||
|
||||
@ -321,6 +321,13 @@ if ($source == 'proposal') {
|
||||
print '<tr class="CTableRow2"><td class="CTableRow2 tdtop">'.$langs->trans("Designation");
|
||||
print '</td><td class="CTableRow2">'.$text;
|
||||
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');
|
||||
if ($directdownloadlink) {
|
||||
print '<br><a href="'.$directdownloadlink.'">';
|
||||
|
||||
Loading…
Reference in New Issue
Block a user