Online pdf contract signature
This commit is contained in:
parent
36f7a14067
commit
30c3543d20
@ -152,9 +152,18 @@ if ($action == 'updateMask') {
|
||||
} else {
|
||||
setEventMessages($langs->trans("Error"), null, 'errors');
|
||||
}
|
||||
} elseif ($action == "allowonlinesign") {
|
||||
if (!dolibarr_set_const($db, "CONTRACT_ALLOW_ONLINESIGN", $value, 0, 'int', $conf->entity)) {
|
||||
$error++;
|
||||
}
|
||||
} elseif ($action == "allowexternaldownload") {
|
||||
if (!dolibarr_set_const($db, "CONTRACT_ALLOW_EXTERNAL_DOWNLOAD", $value, 0, 'int', $conf->entity)) {
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
@ -469,6 +478,37 @@ print $form->selectyesno("activate_hideClosedServiceByDefault", (!empty($conf->g
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
// Allow online signing
|
||||
print '<tr class="oddeven">';
|
||||
print '<td>'.$langs->trans("AllowOnlineSign").'</td>';
|
||||
print '<td class="center">';
|
||||
if ($conf->global->CONTRACT_ALLOW_ONLINESIGN) {
|
||||
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=allowonlinesign&token='.newToken().'&value=0">';
|
||||
print img_picto($langs->trans("Activited"), 'switch_on');
|
||||
print '</a>';
|
||||
} else {
|
||||
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=allowonlinesign&token='.newToken().'&value=1">';
|
||||
print img_picto($langs->trans("Disabled"), 'switch_off');
|
||||
print '</a>';
|
||||
}
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
// Allow external download
|
||||
print '<tr class="oddeven">';
|
||||
print '<td>'.$langs->trans("AllowExternalDownload").'</td>';
|
||||
print '<td class="center">';
|
||||
if ($conf->global->CONTRACT_ALLOW_EXTERNAL_DOWNLOAD) {
|
||||
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=allowexternaldownload&token='.newToken().'&value=0">';
|
||||
print img_picto($langs->trans("Activited"), 'switch_on');
|
||||
print '</a>';
|
||||
} else {
|
||||
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=allowexternaldownload&token='.newToken().'&value=1">';
|
||||
print img_picto($langs->trans("Disabled"), 'switch_off');
|
||||
print '</a>';
|
||||
}
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
print '</table>';
|
||||
|
||||
print $form->buttonsSaveCancel("Save", '');
|
||||
|
||||
@ -2207,11 +2207,10 @@ if ($action == 'create') {
|
||||
$somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
|
||||
|
||||
// Show online signature link
|
||||
$useonlinesignature = 1;
|
||||
|
||||
if ($object->statut != Contrat::STATUS_DRAFT && $useonlinesignature) {
|
||||
if ($object->statut != Contrat::STATUS_DRAFT && $conf->global->CONTRACT_ALLOW_ONLINESIGN) {
|
||||
print '<br><!-- Link to sign -->';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/signature.lib.php';
|
||||
|
||||
print showOnlineSignatureUrl('contract', $object->ref).'<br>';
|
||||
}
|
||||
|
||||
|
||||
@ -663,7 +663,7 @@ class Contrat extends CommonObject
|
||||
$sql .= " fk_user_author,";
|
||||
$sql .= " fk_projet as fk_project,";
|
||||
$sql .= " fk_commercial_signature, fk_commercial_suivi,";
|
||||
$sql .= " note_private, note_public, model_pdf, extraparams";
|
||||
$sql .= " note_private, note_public, model_pdf, last_main_doc, extraparams";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."contrat";
|
||||
if (!$id) {
|
||||
$sql .= " WHERE entity IN (".getEntity('contract').")";
|
||||
@ -717,7 +717,7 @@ class Contrat extends CommonObject
|
||||
|
||||
$this->socid = $obj->fk_soc;
|
||||
$this->fk_soc = $obj->fk_soc;
|
||||
|
||||
$this->last_main_doc = $obj->last_main_doc;
|
||||
$this->extraparams = (array) json_decode($obj->extraparams, true);
|
||||
|
||||
$this->db->free($resql);
|
||||
|
||||
@ -224,6 +224,95 @@ if ($action == "importSignature") {
|
||||
$response = "error sql";
|
||||
}
|
||||
}
|
||||
} elseif ($mode == 'contract') {
|
||||
require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
|
||||
$object = new Contrat($db);
|
||||
$object->fetch(0, $ref);
|
||||
|
||||
$upload_dir = !empty($conf->contrat->multidir_output[$object->entity])?$conf->contrat->multidir_output[$object->entity]:$conf->contrat->dir_output;
|
||||
$upload_dir .= '/'.dol_sanitizeFileName($object->ref).'/';
|
||||
|
||||
$date = dol_print_date(dol_now(), "%Y%m%d%H%M%S");
|
||||
$filename = "signatures/".$date."_signature.png";
|
||||
if (!is_dir($upload_dir."signatures/")) {
|
||||
if (!dol_mkdir($upload_dir."signatures/")) {
|
||||
$response ="Error mkdir. Failed to create dir ".$upload_dir."signatures/";
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$error) {
|
||||
$return = file_put_contents($upload_dir.$filename, $data);
|
||||
if ($return == false) {
|
||||
$error++;
|
||||
$response = 'Error file_put_content: failed to create signature file.';
|
||||
}
|
||||
}
|
||||
|
||||
if (!$error) {
|
||||
// Defined modele of doc
|
||||
$last_main_doc_file = $object->last_main_doc;
|
||||
$directdownloadlink = $object->getLastMainDocLink('contrat'); // url to download the $object->last_main_doc
|
||||
if (preg_match('/\.pdf/i', $last_main_doc_file)) {
|
||||
// TODO Use the $last_main_doc_file to defined the $newpdffilename and $sourcefile
|
||||
$newpdffilename = $upload_dir.$ref."_signed-".$date.".pdf";
|
||||
$sourcefile = $upload_dir.$ref.".pdf";
|
||||
|
||||
if (dol_is_file($sourcefile)) {
|
||||
// We build the new PDF
|
||||
$pdf = pdf_getInstance();
|
||||
if (class_exists('TCPDF')) {
|
||||
$pdf->setPrintHeader(false);
|
||||
$pdf->setPrintFooter(false);
|
||||
}
|
||||
$pdf->SetFont(pdf_getPDFFont($langs));
|
||||
|
||||
if (getDolGlobalString('MAIN_DISABLE_PDF_COMPRESSION')) {
|
||||
$pdf->SetCompression(false);
|
||||
}
|
||||
|
||||
|
||||
//$pdf->Open();
|
||||
$pagecount = $pdf->setSourceFile($sourcefile); // original PDF
|
||||
$s = array(); // Array with size of each page. Exemple array(w'=>210, 'h'=>297);
|
||||
for ($i=1; $i<($pagecount+1); $i++) {
|
||||
try {
|
||||
$tppl = $pdf->importPage($i);
|
||||
$s = $pdf->getTemplatesize($tppl);
|
||||
$pdf->AddPage($s['h'] > $s['w'] ? 'P' : 'L');
|
||||
$pdf->useTemplate($tppl);
|
||||
} catch (Exception $e) {
|
||||
dol_syslog("Error when manipulating some PDF by onlineSign: ".$e->getMessage(), LOG_ERR);
|
||||
$response = $e->getMessage();
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
|
||||
// A signature image file is 720 x 180 (ratio 1/4) but we use only the size into PDF
|
||||
// TODO Get position of box from PDF template
|
||||
$xforimgstart = 5;
|
||||
$yforimgstart = (empty($s['h']) ? 240 : $s['h'] - 65);
|
||||
$wforimg = $s['w']/2 - $xforimgstart;
|
||||
|
||||
$pdf->Image($upload_dir.$filename, $xforimgstart, $yforimgstart, $wforimg, round($wforimg / 4));
|
||||
//$pdf->Close();
|
||||
$pdf->Output($newpdffilename, "F");
|
||||
|
||||
// Index the new file and update the last_main_doc property of object.
|
||||
$object->indexFile($newpdffilename, 1);
|
||||
}
|
||||
if (!$error) {
|
||||
$response = "success";
|
||||
}
|
||||
} elseif (preg_match('/\.odt/i', $last_main_doc_file)) {
|
||||
// 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.
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$error++;
|
||||
|
||||
@ -5608,7 +5608,7 @@ abstract class CommonObject
|
||||
if ($this->element == 'product' && !empty($conf->global->PRODUCT_ALLOW_EXTERNAL_DOWNLOAD)) {
|
||||
$setsharekey = true;
|
||||
}
|
||||
if ($this->element == 'contrat' && !empty($conf->global->CONTRACT_ALLOW_EXTERNAL_DOWNLOAD)) {
|
||||
if ($this->element == 'contrat' && !empty($conf->global->CONTRACT_ALLOW_EXTERNAL_DOWNLOAD) && !empty($conf->global->CONTRACT_ALLOW_ONLINESIGN)) {
|
||||
$setsharekey = true;
|
||||
}
|
||||
if ($this->element == 'supplier_proposal' && !empty($conf->global->SUPPLIER_PROPOSAL_ALLOW_EXTERNAL_DOWNLOAD)) {
|
||||
|
||||
@ -78,7 +78,6 @@ function getOnlineSignatureUrl($mode, $type, $ref = '', $localorexternal = 1)
|
||||
|
||||
if ($type == 'proposal') {
|
||||
$securekeyseed = isset($conf->global->PROPOSAL_ONLINE_SIGNATURE_SECURITY_TOKEN) ? $conf->global->PROPOSAL_ONLINE_SIGNATURE_SECURITY_TOKEN : '';
|
||||
|
||||
$out = $urltouse.'/public/onlinesign/newonlinesign.php?source=proposal&ref='.($mode ? '<span style="color: #666666">' : '');
|
||||
if ($mode == 1) {
|
||||
$out .= 'proposal_ref';
|
||||
@ -116,6 +115,21 @@ function getOnlineSignatureUrl($mode, $type, $ref = '', $localorexternal = 1)
|
||||
$out .= '&hashp='.$hashp;
|
||||
}
|
||||
}*/
|
||||
} elseif ($type == 'contract') {
|
||||
$securekeyseed = isset($conf->global->CONTRACT_ONLINE_SIGNATURE_SECURITY_TOKEN) ? $conf->global->CONTRACT_ONLINE_SIGNATURE_SECURITY_TOKEN : '';
|
||||
$out = $urltouse.'/public/onlinesign/newonlinesign.php?source=contract&ref='.($mode ? '<span style="color: #666666">' : '');
|
||||
if ($mode == 1) {
|
||||
$out .= 'contract_ref';
|
||||
}
|
||||
if ($mode == 0) {
|
||||
$out .= urlencode($ref);
|
||||
}
|
||||
$out .= ($mode ? '</span>' : '');
|
||||
if ($mode == 1) {
|
||||
$out .= "hash('".$securekeyseed."' + '".$type."' + contract_ref)";
|
||||
} else {
|
||||
$out .= '&securekey='.dol_hash($securekeyseed.$type.$ref.(!isModEnabled('multicompany') ? '' : $object->entity), '0');
|
||||
}
|
||||
}
|
||||
|
||||
// For multicompany
|
||||
|
||||
@ -74,8 +74,12 @@ StatusProsp=Prospect status
|
||||
DraftPropals=Draft commercial proposals
|
||||
NoLimit=No limit
|
||||
ToOfferALinkForOnlineSignature=Link for online signature
|
||||
WelcomeOnOnlineSignaturePage=Welcome to the page to accept commercial proposals from %s
|
||||
ThisScreenAllowsYouToSignDocFrom=This screen allow you to accept and sign, or refuse, a quote/commercial proposal
|
||||
ThisIsInformationOnDocumentToSign=This is information on document to accept or refuse
|
||||
WelcomeOnOnlineSignaturePageProposal=Welcome to the page to accept commercial proposals from %s
|
||||
WelcomeOnOnlineSignaturePageContract=Welcome to %s Contract PDF Signing Page
|
||||
ThisScreenAllowsYouToSignDocFromProposal=This screen allow you to accept and sign, or refuse, a quote/commercial proposal
|
||||
ThisScreenAllowsYouToSignDocFromContract=This screen allow you to sign contract on PDF format online.
|
||||
ThisIsInformationOnDocumentToSignProposal=This is information on document to accept or refuse
|
||||
ThisIsInformationOnDocumentToSignContract=This is information on contract to sign
|
||||
SignatureProposalRef=Signature of quote/commercial proposal %s
|
||||
SignatureContractRef=Signature of contract %s
|
||||
FeatureOnlineSignDisabled=Feature for online signing disabled or document generated before the feature was enabled
|
||||
|
||||
@ -101,6 +101,8 @@ TypeContact_contrat_external_BILLING=Billing customer contact
|
||||
TypeContact_contrat_external_CUSTOMER=Follow-up customer contact
|
||||
TypeContact_contrat_external_SALESREPSIGN=Signing contract customer contact
|
||||
HideClosedServiceByDefault=Hide closed services by default
|
||||
AllowOnlineSign=Allow online signing
|
||||
AllowExternalDownload=Allow external download
|
||||
ShowClosedServices=Show Closed Services
|
||||
HideClosedServices=Hide Closed Services
|
||||
UserStartingService=User starting service
|
||||
|
||||
@ -103,11 +103,13 @@ IdProposal=Proposal ID
|
||||
IdProduct=Product ID
|
||||
LineBuyPriceHT=Buy Price Amount net of tax for line
|
||||
SignPropal=Accept proposal
|
||||
SignContract=Sign contract
|
||||
RefusePropal=Refuse proposal
|
||||
Sign=Sign
|
||||
NoSign=Refuse
|
||||
PropalAlreadySigned=Proposal already accepted
|
||||
PropalAlreadyRefused=Proposal already refused
|
||||
PropalSigned=Proposal accepted
|
||||
ContractSigned=Contract signed
|
||||
PropalRefused=Proposal refused
|
||||
ConfirmRefusePropal=Are you sure you want to refuse this commercial proposal?
|
||||
|
||||
@ -74,8 +74,12 @@ StatusProsp=Status prospection
|
||||
DraftPropals=Propositions brouillons
|
||||
NoLimit=Pas de limite
|
||||
ToOfferALinkForOnlineSignature=Lien pour signature en ligne
|
||||
WelcomeOnOnlineSignaturePage=Bienvenue sur la page pour accepter les propositions commerciales de %s
|
||||
ThisScreenAllowsYouToSignDocFrom=Cet écran vous permet d'accepter et signer en ligne, ou de refuser, le devis ou la proposition commerciale
|
||||
ThisIsInformationOnDocumentToSign=Voici les informations sur le document à accepter ou refuser
|
||||
WelcomeOnOnlineSignaturePageProposal=Bienvenue sur la page pour accepter les propositions commerciales de %s
|
||||
WelcomeOnOnlineSignaturePageContract=Bienvenue sur la page de signature en ligne de contrats au format PDF de %s
|
||||
ThisScreenAllowsYouToSignDocFromProposal=Cet écran vous permet d'accepter et signer en ligne, ou de refuser, le devis ou la proposition commerciale
|
||||
ThisScreenAllowsYouToSignDocFromContract=Cet écran vous permet de signer en ligne des contrats au format PDF.
|
||||
ThisIsInformationOnDocumentToSignProposal=Voici les informations sur le document à accepter ou refuser
|
||||
ThisIsInformationOnDocumentToSignContract=Voici les informations sur le contrat a signer
|
||||
SignatureProposalRef=Signature du devis ou proposition commerciale %s
|
||||
SignatureContractRef=Signature du contrat %s
|
||||
FeatureOnlineSignDisabled=Fonctionnalité pour la signature en ligne désactivée ou document généré avant l'activation de la fonctionnalité
|
||||
|
||||
@ -100,5 +100,7 @@ TypeContact_contrat_external_BILLING=Contact client facturation contrat
|
||||
TypeContact_contrat_external_CUSTOMER=Contact client suivi contrat
|
||||
TypeContact_contrat_external_SALESREPSIGN=Contact client signataire contrat
|
||||
HideClosedServiceByDefault=Masquer les services fermés par défaut
|
||||
AllowOnlineSign=Autoriser la signature en ligne
|
||||
AllowExternalDownload=Autoriser le téléchargement externe
|
||||
ShowClosedServices=Afficher les services fermés
|
||||
HideClosedServices=Masquer les services fermés
|
||||
|
||||
@ -47,7 +47,7 @@ SendPropalByMail=Envoyer proposition commerciale par email
|
||||
DatePropal=Date de proposition
|
||||
DateEndPropal=Date de fin de validité
|
||||
ValidityDuration=Durée de validité
|
||||
SetAcceptedRefused=Accepter/Refuser
|
||||
SetAcceptedRefused=Accepter/Refuser
|
||||
ErrorPropalNotFound=Propale %s inexistante
|
||||
AddToDraftProposals=Ajouter à proposition brouillon
|
||||
NoDraftProposals=Pas de propositions brouillons
|
||||
@ -103,11 +103,13 @@ IdProposal=ID de la proposition commerciale
|
||||
IdProduct=ID produit
|
||||
LineBuyPriceHT=Prix d'achat HT de la ligne
|
||||
SignPropal=Accepter la proposition
|
||||
SignContract=Signer le contrat
|
||||
RefusePropal=Refuser la proposition
|
||||
Sign=Signer
|
||||
NoSign=Mettre à Non signé
|
||||
PropalAlreadySigned=Proposition déjà acceptée
|
||||
PropalAlreadyRefused=Proposition déjà refusée
|
||||
PropalSigned=Proposition acceptée
|
||||
ContractSigned=Contrat signé
|
||||
PropalRefused=Proposition refusée
|
||||
ConfirmRefusePropal=Êtes-vous sûr de vouloir refuser cette proposition ?
|
||||
|
||||
@ -79,6 +79,7 @@ $suffix = GETPOST("suffix", 'aZ09');
|
||||
$source = GETPOST("source", 'alpha');
|
||||
$ref = $REF = GETPOST("ref", 'alpha');
|
||||
|
||||
|
||||
if (empty($source)) {
|
||||
$source = 'proposal';
|
||||
}
|
||||
@ -128,8 +129,9 @@ if (!$action) {
|
||||
$securekeyseed = '';
|
||||
if ($source == 'proposal') {
|
||||
$securekeyseed = getDolGlobalString('PROPOSAL_ONLINE_SIGNATURE_SECURITY_TOKEN');
|
||||
} elseif ($source == 'contract') {
|
||||
$securekeyseed = getDolGlobalString('CONTRACT_ONLINE_SIGNATURE_SECURITY_TOKEN');
|
||||
}
|
||||
|
||||
if (!dol_verifyHash($securekeyseed.$type.$ref.(isModEnabled('multicompany') ? $entity : ''), $SECUREKEY, '0')) {
|
||||
httponly_accessforbidden('Bad value for securitykey. Value provided '.dol_escape_htmltag($SECUREKEY).' does not match expected value for ref='.dol_escape_htmltag($ref), 403, 1);
|
||||
}
|
||||
@ -138,6 +140,10 @@ if ($source == 'proposal') {
|
||||
require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
|
||||
$object = new Propal($db);
|
||||
$result= $object->fetch(0, $ref, '', $entity);
|
||||
} elseif ($source == 'contract') {
|
||||
require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
|
||||
$object = new Contrat($db);
|
||||
$result= $object->fetch(0, $ref);
|
||||
} else {
|
||||
httponly_accessforbidden($langs->trans('ErrorBadParameters')." - Bad value for source", 400, 1);
|
||||
}
|
||||
@ -278,16 +284,24 @@ if (!empty($conf->global->ONLINE_SIGN_NEWFORM_TEXT)) {
|
||||
$text = '<tr><td align="center"><br>'.$text.'<br></td></tr>'."\n";
|
||||
}
|
||||
if (empty($text)) {
|
||||
$text .= '<tr><td class="textpublicpayment"><br><strong>'.$langs->trans("WelcomeOnOnlineSignaturePage", $mysoc->name).'</strong></td></tr>'."\n";
|
||||
$text .= '<tr><td class="textpublicpayment opacitymedium">'.$langs->trans("ThisScreenAllowsYouToSignDocFrom", $creditor).'<br><br></td></tr>'."\n";
|
||||
if ($source == 'proposal') {
|
||||
$text .= '<tr><td class="textpublicpayment"><br><strong>'.$langs->trans("WelcomeOnOnlineSignaturePageProposal", $mysoc->name).'</strong></td></tr>'."\n";
|
||||
$text .= '<tr><td class="textpublicpayment opacitymedium">'.$langs->trans("ThisScreenAllowsYouToSignDocFromProposal", $creditor).'<br><br></td></tr>'."\n";
|
||||
} elseif ($source == 'contract') {
|
||||
$text .= '<tr><td class="textpublicpayment"><br><strong>'.$langs->trans("WelcomeOnOnlineSignaturePageContract", $mysoc->name).'</strong></td></tr>'."\n";
|
||||
$text .= '<tr><td class="textpublicpayment opacitymedium">'.$langs->trans("ThisScreenAllowsYouToSignDocFromContract", $creditor).'<br><br></td></tr>'."\n";
|
||||
}
|
||||
}
|
||||
print $text;
|
||||
|
||||
// Output payment summary form
|
||||
print '<tr><td align="center">';
|
||||
print '<table with="100%" id="tablepublicpayment">';
|
||||
print '<tr><td align="left" colspan="2" class="opacitymedium">'.$langs->trans("ThisIsInformationOnDocumentToSign").' :</td></tr>'."\n";
|
||||
|
||||
if ($source == 'proposal') {
|
||||
print '<tr><td align="left" colspan="2" class="opacitymedium">'.$langs->trans("ThisIsInformationOnDocumentToSignProposal").' :</td></tr>'."\n";
|
||||
} elseif ($source == 'contract') {
|
||||
print '<tr><td align="left" colspan="2" class="opacitymedium">'.$langs->trans("ThisIsInformationOnDocumentToSignContract").' :</td></tr>'."\n";
|
||||
}
|
||||
$found = false;
|
||||
$error = 0;
|
||||
|
||||
@ -370,8 +384,53 @@ if ($source == 'proposal') {
|
||||
print '<input type="hidden" name="source" value="'.GETPOST("source", 'alpha').'">';
|
||||
print '<input type="hidden" name="ref" value="'.$object->ref.'">';
|
||||
print '</td></tr>'."\n";
|
||||
}
|
||||
} elseif ($source == 'contract') { // Signature on contract
|
||||
$found = true;
|
||||
$langs->load("contract");
|
||||
|
||||
$result = $object->fetch_thirdparty($object->socid);
|
||||
|
||||
// Proposer
|
||||
print '<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans("Proposer");
|
||||
print '</td><td class="CTableRow2">';
|
||||
print img_picto('', 'company', 'class="pictofixedwidth"');
|
||||
print '<b>'.$creditor.'</b>';
|
||||
print '<input type="hidden" name="creditor" value="'.$creditor.'">';
|
||||
print '</td></tr>'."\n";
|
||||
|
||||
// Target
|
||||
print '<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans("ThirdParty");
|
||||
print '</td><td class="CTableRow2">';
|
||||
print img_picto('', 'company', 'class="pictofixedwidth"');
|
||||
print '<b>'.$object->thirdparty->name.'</b>';
|
||||
print '</td></tr>'."\n";
|
||||
|
||||
// Object
|
||||
$text = '<b>'.$langs->trans("SignatureContractRef", $object->ref).'</b>';
|
||||
print '<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans("Designation");
|
||||
print '</td><td class="CTableRow2">'.$text;
|
||||
|
||||
$last_main_doc_file = $object->last_main_doc;
|
||||
|
||||
if (empty($last_main_doc_file) || !dol_is_file(DOL_DATA_ROOT.'/'.$object->last_main_doc)) {
|
||||
// It seems document has never been generated, or was generated and then 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('contract');
|
||||
if ($directdownloadlink) {
|
||||
print '<br><a href="'.$directdownloadlink.'">';
|
||||
print img_mime($object->last_main_doc, '');
|
||||
print $langs->trans("DownloadDocument").'</a>';
|
||||
}
|
||||
|
||||
|
||||
print '<input type="hidden" name="source" value="'.GETPOST("source", 'alpha').'">';
|
||||
print '<input type="hidden" name="ref" value="'.$object->ref.'">';
|
||||
print '</td></tr>'."\n";
|
||||
}
|
||||
|
||||
|
||||
if (!$found && !$mesg) {
|
||||
@ -436,7 +495,7 @@ if ($action == "dosign" && empty($cancel)) {
|
||||
success: function(response) {
|
||||
if(response == "success"){
|
||||
console.log("Success on saving signature");
|
||||
window.location.replace("'.$_SERVER["PHP_SELF"].'?ref='.urlencode($ref).'&message=signed&securekey='.urlencode($SECUREKEY).(isModEnabled('multicompany')?'&entity='.$entity:'').'");
|
||||
window.location.replace("'.$_SERVER["PHP_SELF"].'?ref='.urlencode($ref).'&source='.urlencode($source).'&message=signed&securekey='.urlencode($SECUREKEY).(isModEnabled('multicompany')?'&entity='.$entity:'').'");
|
||||
}else{
|
||||
console.error(response);
|
||||
}
|
||||
@ -474,6 +533,12 @@ if ($action == "dosign" && empty($cancel)) {
|
||||
print '<input type="submit" class="butAction small wraponsmartphone marginbottomonly marginleftonly marginrightonly reposition" value="'.$langs->trans("SignPropal").'">';
|
||||
print '<input name="refusepropal" type="submit" class="butActionDelete small wraponsmartphone marginbottomonly marginleftonly marginrightonly reposition" value="'.$langs->trans("RefusePropal").'">';
|
||||
}
|
||||
} elseif ($source == 'contract') {
|
||||
if ($message == 'signed') {
|
||||
print '<span class="ok">'.$langs->trans("ContractSigned").'</span>';
|
||||
} else {
|
||||
print '<input type="submit" class="butAction small wraponsmartphone marginbottomonly marginleftonly marginrightonly reposition" value="'.$langs->trans("SignContract").'">';
|
||||
}
|
||||
}
|
||||
}
|
||||
print '</td></tr>'."\n";
|
||||
|
||||
Loading…
Reference in New Issue
Block a user