dolibarr 24.0.0-beta
newonlinesign.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2006-2017 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2009-2012 Regis Houssin <regis.houssin@inodbox.com>
5 * Copyright (C) 2023 anthony Berton <anthony.berton@bb2a.fr>
6 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
7 * Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 3 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 */
22
32if (!defined('NOLOGIN')) {
33 define("NOLOGIN", 1); // This means this output page does not require to be logged.
34}
35if (!defined('NOCSRFCHECK')) {
36 define("NOCSRFCHECK", 1); // We accept to go on this page from external web site.
37}
38if (!defined('NOIPCHECK')) {
39 define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip
40}
41if (!defined('NOBROWSERNOTIF')) {
42 define('NOBROWSERNOTIF', '1');
43}
44
45// For MultiCompany module.
46// Do not use GETPOST here, function is not defined and define must be done before including main.inc.php
47// Because 2 entities can have the same ref.
48$entity = (!empty($_GET['entity']) ? (int) $_GET['entity'] : (!empty($_POST['entity']) ? (int) $_POST['entity'] : 1));
49if (is_numeric($entity)) {
50 define("DOLENTITY", $entity);
51}
52
53// Load Dolibarr environment
54require '../../main.inc.php';
65require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
66require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php';
67require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
68require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
69require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
70require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php';
71
72// Load translation files
73$langs->loadLangs(array("main", "other", "dict", "bills", "companies", "errors", "members", "paybox", "stripe", "propal", "commercial"));
74
75// Security check
76// No check on module enabled. Done later according to $validpaymentmethod
77
78// Get parameters
79$action = GETPOST('action', 'aZ09');
80$cancel = GETPOST('cancel', 'alpha');
81$confirm = GETPOST('confirm', 'alpha');
82
83
84$refusepropal = GETPOST('refusepropal', 'alpha');
85$message = GETPOST('message', 'aZ09');
86
87// Input are:
88// type ('invoice','order','contractline'),
89// id (object id),
90// amount (required if id is empty),
91// tag (a free text, required if type is empty)
92// currency (iso code)
93
94$suffix = GETPOST("suffix", 'aZ09');
95$source = (string) GETPOST("source", 'alpha');
96$ref = $REF = GETPOST("ref", 'alpha');
97$urlok = '';
98$urlko = '';
99
100
101if ($source == '') {
102 $source = 'proposal';
103}
104if (!empty($refusepropal)) {
105 $action = "refusepropal";
106}
107
108// Define $urlwithroot
109//$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root));
110//$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
111$urlwithroot = DOL_MAIN_URL_ROOT; // This is to use same domain name than current. For Paypal payment, we can use internal URL like localhost.
112
113
114// Complete urls for post treatment
115$SECUREKEY = GETPOST("securekey"); // Secure key
116
117if (!empty($source)) {
118 $urlok .= 'source='.urlencode($source).'&';
119 $urlko .= 'source='.urlencode($source).'&';
120}
121if (!empty($REF)) {
122 $urlok .= 'ref='.urlencode($REF).'&';
123 $urlko .= 'ref='.urlencode($REF).'&';
124}
125if (!empty($SECUREKEY)) {
126 $urlok .= 'securekey='.urlencode($SECUREKEY).'&';
127 $urlko .= 'securekey='.urlencode($SECUREKEY).'&';
128}
129if (!empty($entity)) {
130 $urlok .= 'entity='.urlencode((string) ($entity)).'&';
131 $urlko .= 'entity='.urlencode((string) ($entity)).'&';
132}
133$urlok = preg_replace('/&$/', '', $urlok); // Remove last &
134$urlko = preg_replace('/&$/', '', $urlko); // Remove last &
135
136$creditor = $mysoc->name;
137
138$type = $source;
139if (!$action) {
140 if ($source && !$ref) {
141 httponly_accessforbidden($langs->trans('ErrorBadParameters')." - ref missing", 400, 1);
142 }
143}
144
145global $dolibarr_main_instance_unique_id;
146$defaultsalt = substr(dol_hash('dolibarr'.$dolibarr_main_instance_unique_id, 'sha256'), 0, 32); // Fallback if no specific salt was set
147
148// Check securitykey
149$securekeyseed = '';
150if ($source == 'proposal') {
151 $securekeyseed = getDolGlobalString('PROPOSAL_ONLINE_SIGNATURE_SECURITY_TOKEN', $defaultsalt);
152} elseif ($source == 'contract') {
153 $securekeyseed = getDolGlobalString('CONTRACT_ONLINE_SIGNATURE_SECURITY_TOKEN', $defaultsalt);
154} elseif ($source == 'fichinter') {
155 $securekeyseed = getDolGlobalString('FICHINTER_ONLINE_SIGNATURE_SECURITY_TOKEN', $defaultsalt);
156} elseif ($source == 'societe_rib') {
157 $securekeyseed = getDolGlobalString('SOCIETE_RIB_ONLINE_SIGNATURE_SECURITY_TOKEN', $defaultsalt);
158}
159if (!dol_verifyHash($securekeyseed.$type.$ref.(isModEnabled('multicompany') ? $entity : ''), $SECUREKEY, 'hash')) {
160 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);
161}
162
163if ($source == 'proposal') {
164 require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
165 $object = new Propal($db);
166 $result = $object->fetch(0, $ref, '', $entity);
167} elseif ($source == 'contract') {
168 require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
169 $object = new Contrat($db);
170 $result = $object->fetch(0, $ref);
171} elseif ($source == 'fichinter') {
172 require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php';
173 $object = new Fichinter($db);
174 $result = $object->fetch(0, $ref);
175} elseif ($source == 'societe_rib') {
176 require_once DOL_DOCUMENT_ROOT.'/societe/class/companybankaccount.class.php';
178 $result = $object->fetch(0, $ref);
179} elseif ($source == 'expedition') {
180 require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php';
181 $object = new Expedition($db);
182 $result = $object->fetch(0, $ref);
183} else {
184 httponly_accessforbidden($langs->trans('ErrorBadParameters')." - Bad value for source. Value not supported.", 400, 1);
185}
186
187// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
188$hookmanager->initHooks(array('onlinesign'));
189
190$error = 0;
191
192
193/*
194 * Actions
195 */
196
197if ($action == 'confirm_refusepropal' && $confirm == 'yes') { // Test on permission not required here. Public form. Security checked on the securekey and on mitigation
198 $db->begin();
199
200 $sql = "UPDATE ".MAIN_DB_PREFIX."propal";
201 $sql .= " SET fk_statut = ".((int) $object::STATUS_NOTSIGNED).", note_private = '".$db->escape($object->note_private)."', date_signature = '".$db->idate(dol_now())."'";
202 $sql .= " WHERE rowid = ".((int) $object->id);
203
204 dol_syslog(__FILE__, LOG_DEBUG);
205 $resql = $db->query($sql);
206 if (!$resql) {
207 $error++;
208 }
209
210 if (!$error) {
211 $db->commit();
212
213 $message = 'refused';
214 setEventMessages("PropalRefused", null, 'warnings');
215 if (method_exists($object, 'call_trigger')) {
216 $object->context = array('closedfromonlinesignature' => 'closedfromonlinesignature');
217 $result = $object->call_trigger('PROPAL_CLOSE_REFUSED', $user);
218 if ($result < 0) {
219 $error++;
220 }
221 }
222 } else {
223 $db->rollback();
224 }
225
226 $object->fetch(0, $ref);
227}
228
229// $action == "dosign" is handled later...
230
231
232/*
233 * View
234 */
235
236$form = new Form($db);
237
238$head = '';
239if (getDolGlobalString('MAIN_SIGN_CSS_URL')) {
240 $head = '<link rel="stylesheet" type="text/css" href="' . getDolGlobalString('MAIN_SIGN_CSS_URL').'?lang='.$langs->defaultlang.'">'."\n";
241}
242
243$conf->dol_hide_topmenu = 1;
244$conf->dol_hide_leftmenu = 1;
245
246$title = $langs->trans("OnlineSignature");
247
248$replacemainarea = (empty($conf->dol_hide_leftmenu) ? '<div>' : '').'<div>';
249llxHeader($head, $title, '', '', 0, 0, '', '', '', 'onlinepaymentbody', $replacemainarea, 1);
250
251htmlPrintOnlineHeader($mysoc, $langs, 1, '', 'ONLINE_SIGN_IMAGE_PUBLIC_INTERFACE', 'ONLINE_SIGN_LOGO_'.$suffix, 'ONLINE_SIGN_LOGO');
252
253if ($action == 'refusepropal') {
254 print $form->formconfirm($_SERVER["PHP_SELF"].'?ref='.urlencode($ref).'&securekey='.urlencode($SECUREKEY).(isModEnabled('multicompany') ? '&entity='.$entity : ''), $langs->trans('RefusePropal'), $langs->trans('ConfirmRefusePropal', $object->ref), 'confirm_refusepropal', '', '', 1);
255}
256
257// Check link validity for param 'source' to avoid use of the examples as value
258if (/* $source !== '' :never empty && */ in_array($ref, array('member_ref', 'contractline_ref', 'invoice_ref', 'order_ref', 'proposal_ref', ''))) {
259 $langs->load("errors");
260 dol_print_error_email('BADREFINONLINESIGNFORM', $langs->trans("ErrorBadLinkSourceSetButBadValueForRef", $source, $ref));
261 // End of page
262 llxFooter();
263 $db->close();
264 exit;
265}
266
267print '<span id="dolpaymentspan"></span>'."\n";
268print '<div class="center">'."\n";
269print '<form id="dolpaymentform" class="center" name="paymentform" action="'.$_SERVER["PHP_SELF"].'" method="POST">'."\n";
270print '<input type="hidden" name="token" value="'.newToken().'">'."\n";
271print '<input type="hidden" name="action" value="dosign">'."\n";
272print '<input type="hidden" name="tag" value="'.GETPOST("tag", 'alpha').'">'."\n";
273print '<input type="hidden" name="suffix" value="'.GETPOST("suffix", 'alpha').'">'."\n";
274print '<input type="hidden" name="securekey" value="'.$SECUREKEY.'">'."\n";
275print '<input type="hidden" name="entity" value="'.$entity.'" />';
276print '<input type="hidden" name="page_y" value="" />';
277print '<input type="hidden" name="source" value="'.$source.'" />';
278print '<input type="hidden" name="ref" value="'.$ref.'" />';
279print "\n";
280print '<!-- Form to sign -->'."\n";
281
282if ($source == 'proposal' && getDolGlobalString('PROPOSAL_IMAGE_PUBLIC_SIGN')) {
283 print '<div class="backimagepublicproposalsign">';
284 print '<img id="idPROPOSAL_IMAGE_PUBLIC_INTERFACE" src="' . getDolGlobalString('PROPOSAL_IMAGE_PUBLIC_SIGN').'">';
285 print '</div>';
286}
287
288print '<table id="dolpublictable" summary="Payment form" class="center">'."\n";
289
290// Output introduction text
291$text = '';
292if (getDolGlobalString('ONLINE_SIGN_NEWFORM_TEXT')) {
293 $reg = array();
294 if (preg_match('/^\‍((.*)\‍)$/', $conf->global->ONLINE_SIGN_NEWFORM_TEXT, $reg)) {
295 $text .= $langs->trans($reg[1])."<br>\n";
296 } else {
297 $text .= getDolGlobalString('ONLINE_SIGN_NEWFORM_TEXT') . "<br>\n";
298 }
299 $text = '<tr><td align="center"><br>'.$text.'<br></td></tr>'."\n";
300}
301if (empty($text)) {
302 if ($source == 'proposal') {
303 $text .= '<tr><td class="textpublicpayment"><br><strong>'.$langs->trans("WelcomeOnOnlineSignaturePageProposal", $mysoc->name).'</strong></td></tr>'."\n";
304 $text .= '<tr><td class="textpublicpayment small opacitymedium">'.$langs->trans("ThisScreenAllowsYouToSignDocFromProposal", $creditor).'<br><br></td></tr>'."\n";
305 } elseif ($source == 'contract') {
306 $text .= '<tr><td class="textpublicpayment"><br><strong>'.$langs->trans("WelcomeOnOnlineSignaturePageContract", $mysoc->name).'</strong></td></tr>'."\n";
307 $text .= '<tr><td class="textpublicpayment small opacitymedium">'.$langs->trans("ThisScreenAllowsYouToSignDocFromContract", $creditor).'<br><br></td></tr>'."\n";
308 } elseif ($source == 'fichinter') {
309 $text .= '<tr><td class="textpublicpayment"><br><strong>'.$langs->trans("WelcomeOnOnlineSignaturePageFichinter", $mysoc->name).'</strong></td></tr>'."\n";
310 $text .= '<tr><td class="textpublicpayment small opacitymedium">'.$langs->trans("ThisScreenAllowsYouToSignDocFromFichinter", $creditor).'<br><br></td></tr>'."\n";
311 } elseif ($source == 'expedition') {
312 $text .= '<tr><td class="textpublicpayment"><br><strong>'.$langs->trans("WelcomeOnOnlineSignaturePageExpedition", $mysoc->name).'</strong></td></tr>'."\n";
313 $text .= '<tr><td class="textpublicpayment small opacitymedium">'.$langs->trans("ThisScreenAllowsYouToSignDocFromExpedition", $creditor).'<br><br></td></tr>'."\n";
314 } else {
315 $text .= '<tr><td class="textpublicpayment"><br><strong>'.$langs->trans("WelcomeOnOnlineSignaturePage".dol_ucfirst($source), $mysoc->name).'</strong></td></tr>'."\n";
316 $text .= '<tr><td class="textpublicpayment small opacitymedium">'.$langs->trans("ThisScreenAllowsYouToSignDocFrom".dol_ucfirst($source), $creditor).'<br><br></td></tr>'."\n";
317 }
318}
319print $text;
320
321// Output payment summary form
322print '<tr><td align="center">';
323print '<table with="100%" id="tablepublicpayment">';
324if ($source == 'proposal') {
325 print '<tr><td colspan="2" class="left small opacitymedium">'.$langs->trans("ThisIsInformationOnDocumentToSignProposal").'<br><br></td></tr>'."\n";
326} elseif ($source == 'contract') {
327 print '<tr><td colspan="2" class="left small opacitymedium">'.$langs->trans("ThisIsInformationOnDocumentToSignContract").'<br><br></td></tr>'."\n";
328} elseif ($source == 'fichinter') {
329 print '<tr><td colspan="2" class="left small opacitymedium">'.$langs->trans("ThisIsInformationOnDocumentToSignFichinter").'<br><br></td></tr>'."\n";
330} elseif ($source == 'expedition') {
331 print '<tr><td colspan="2" class="left small opacitymedium">'.$langs->trans("ThisIsInformationOnDocumentToSignExpedition").'<br><br></td></tr>'."\n";
332} else {
333 print '<tr><td colspan="2" class="left small opacitymedium">'.$langs->trans("ThisIsInformationOnDocumentToSign".dol_ucfirst($source)).'<br><br></td></tr>'."\n";
334}
335$found = false;
336$error = 0;
337
338// Signature on commercial proposal
339if ($source == 'proposal') {
340 $found = true;
341 $langs->load("proposal");
342
343 $result = $object->fetch_thirdparty($object->socid);
344
345 // Creditor
346 print '<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans("Creditor");
347 print '</td><td class="CTableRow2">';
348 print img_picto('', 'company', 'class="pictofixedwidth"');
349 print '<b>'.$creditor.'</b>';
350 print '<input type="hidden" name="creditor" value="'.$creditor.'">';
351 print '</td></tr>'."\n";
352
353 // Debitor
354 print '<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans("ThirdParty");
355 print '</td><td class="CTableRow2">';
356 print img_picto('', 'company', 'class="pictofixedwidth"');
357 print '<b>'.$object->thirdparty->name.'</b>';
358 print '</td></tr>'."\n";
359
360 // Amount
361
362 $amount = '<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans("Amount");
363 $amount .= '</td><td class="CTableRow2">';
364 $amount .= '<b>'.price($object->total_ttc, 0, $langs, 1, -1, -1, getDolCurrency()).'</b>';
365 if ($object->multicurrency_code != getDolCurrency()) {
366 $amount .= ' ('.price($object->multicurrency_total_ttc, 0, $langs, 1, -1, -1, $object->multicurrency_code).')';
367 }
368 $amount .= '</td></tr>'."\n";
369
370 // Call Hook amountPropalSign
371 $parameters = array('source' => $source);
372 $reshook = $hookmanager->executeHooks('amountPropalSign', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
373 if (empty($reshook)) {
374 $amount .= $hookmanager->resPrint;
375 } elseif ($reshook > 0) {
376 $amount = $hookmanager->resPrint;
377 }
378
379 print $amount;
380
381 // Object
382 $text = '<b>'.$langs->trans("SignatureProposalRef", $object->ref).'</b>';
383 print '<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans("Designation");
384 print '</td><td class="CTableRow2">'.$text;
385
386 $last_main_doc_file = $object->last_main_doc;
387
388 if ($object->status == $object::STATUS_VALIDATED) {
389 $object->last_main_doc = preg_replace('/_signed-(\d+)/', '', $object->last_main_doc); // We want to be sure to not work on the signed version
390
391 if (empty($last_main_doc_file) || !dol_is_file(DOL_DATA_ROOT.'/'.$object->last_main_doc)) {
392 // It seems document has never been generated, or was generated and then deleted.
393 // So we try to regenerate it with its default template.
394 $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.
395 $object->generateDocument($defaulttemplate, $langs);
396 }
397
398 $directdownloadlink = $object->getLastMainDocLink('proposal');
399 if ($directdownloadlink) {
400 print '<br><a href="'.$directdownloadlink.'">';
401 print img_mime($object->last_main_doc, '');
402 print $langs->trans("DownloadDocument").'</a>';
403 }
404 } else {
405 if ($object->status == $object::STATUS_NOTSIGNED) {
406 $directdownloadlink = $object->getLastMainDocLink('proposal');
407 if ($directdownloadlink) {
408 print '<br><a href="'.$directdownloadlink.'">';
409 print img_mime($last_main_doc_file, '');
410 print $langs->trans("DownloadDocument").'</a>';
411 }
412 } elseif ($object->status == $object::STATUS_SIGNED || $object->status == $object::STATUS_BILLED) {
413 if (preg_match('/_signed-(\d+)/', $last_main_doc_file)) { // If the last main doc has been signed
414 $last_main_doc_file_not_signed = preg_replace('/_signed-(\d+)/', '', $last_main_doc_file);
415
416 $datefilesigned = dol_filemtime($last_main_doc_file);
417 $datefilenotsigned = dol_filemtime($last_main_doc_file_not_signed);
418
419 if (empty($datefilenotsigned) || $datefilesigned > $datefilenotsigned) { // If file signed is more recent
420 $directdownloadlink = $object->getLastMainDocLink('proposal');
421 if ($directdownloadlink) {
422 print '<br><a href="'.$directdownloadlink.'">';
423 print img_mime($object->last_main_doc, '');
424 print $langs->trans("DownloadDocument").'</a>';
425 }
426 }
427 }
428 }
429 }
430
431 print '<input type="hidden" name="source" value="'.GETPOST("source", 'alpha').'">';
432 print '<input type="hidden" name="ref" value="'.$object->ref.'">';
433 print '</td></tr>'."\n";
434} elseif ($source == 'contract') { // Signature on contract
435 $found = true;
436 $langs->load("contract");
437
438 $result = $object->fetch_thirdparty($object->socid);
439
440 // Proposer
441 print '<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans("Proposer");
442 print '</td><td class="CTableRow2">';
443 print img_picto('', 'company', 'class="pictofixedwidth"');
444 print '<b>'.$creditor.'</b>';
445 print '<input type="hidden" name="creditor" value="'.$creditor.'">';
446 print '</td></tr>'."\n";
447
448 // Target
449 print '<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans("ThirdParty");
450 print '</td><td class="CTableRow2">';
451 print img_picto('', 'company', 'class="pictofixedwidth"');
452 print '<b>'.$object->thirdparty->name.'</b>';
453 print '</td></tr>'."\n";
454
455 // Object
456 $text = '<b>'.$langs->trans("SignatureContractRef", $object->ref).'</b>';
457 print '<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans("Designation");
458 print '</td><td class="CTableRow2">'.$text;
459
460 $last_main_doc_file = $object->last_main_doc;
461
462 if (empty($last_main_doc_file) || !dol_is_file(DOL_DATA_ROOT.'/'.$object->last_main_doc)) {
463 // It seems document has never been generated, or was generated and then deleted.
464 // So we try to regenerate it with its default template.
465 $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.
466 $object->generateDocument($defaulttemplate, $langs);
467 }
468
469 $directdownloadlink = $object->getLastMainDocLink('contract');
470 if ($directdownloadlink) {
471 print '<br><a href="'.$directdownloadlink.'">';
472 print img_mime($object->last_main_doc, '');
473 if ($message == "signed") {
474 print $langs->trans("DownloadSignedDocument").'</a>';
475 } else {
476 print $langs->trans("DownloadDocument").'</a>';
477 }
478 }
479
480
481 print '<input type="hidden" name="source" value="'.GETPOST("source", 'alpha').'">';
482 print '<input type="hidden" name="ref" value="'.$object->ref.'">';
483 print '</td></tr>'."\n";
484} elseif ($source == 'fichinter') {
485 // Signature on fichinter
486 $found = true;
487 $langs->load("interventions");
488
489 $result = $object->fetch_thirdparty($object->socid);
490
491 // Proposer
492 print '<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans("Proposer");
493 print '</td><td class="CTableRow2">';
494 print img_picto('', 'company', 'class="pictofixedwidth"');
495 print '<b>'.$creditor.'</b>';
496 print '<input type="hidden" name="creditor" value="'.$creditor.'">';
497 print '</td></tr>'."\n";
498
499 // Target
500 print '<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans("ThirdParty");
501 print '</td><td class="CTableRow2">';
502 print img_picto('', 'company', 'class="pictofixedwidth"');
503 print '<b>'.$object->thirdparty->name.'</b>';
504 print '</td></tr>'."\n";
505
506 // Object
507 $text = '<b>'.$langs->trans("SignatureFichinterRef", $object->ref).'</b>';
508 print '<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans("Designation");
509 print '</td><td class="CTableRow2">'.$text;
510
511 $last_main_doc_file = $object->last_main_doc;
512
513 if (empty($last_main_doc_file) || !dol_is_file(DOL_DATA_ROOT.'/'.$object->last_main_doc)) {
514 // It seems document has never been generated, or was generated and then deleted.
515 // So we try to regenerate it with its default template.
516 $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.
517 $object->generateDocument($defaulttemplate, $langs);
518 }
519
520 $directdownloadlink = $object->getLastMainDocLink('fichinter');
521 if ($directdownloadlink) {
522 print '<br><a href="'.$directdownloadlink.'">';
523 print img_mime($object->last_main_doc, '');
524 if ($message == "signed") {
525 print $langs->trans("DownloadSignedDocument").'</a>';
526 } else {
527 print $langs->trans("DownloadDocument").'</a>';
528 }
529 }
530 print '<input type="hidden" name="source" value="'.GETPOST("source", 'alpha').'">';
531 print '<input type="hidden" name="ref" value="'.$object->ref.'">';
532 print '</td></tr>'."\n";
533} elseif ($source == 'societe_rib') {
534 $found = true;
535 $langs->loadLangs(array("companies", "commercial", "withdrawals"));
536
537 $result = $object->fetch_thirdparty();
538
539 // Proposer
540 print '<tr class="CTableRow2"><td class="CTableRow2">' . $langs->trans("CreditorName");
541 print '</td><td class="CTableRow2">';
542 print img_picto('', 'company', 'class="pictofixedwidth"');
543 print '<b>' . $creditor . '</b>';
544 print '<input type="hidden" name="creditor" value="' . $creditor . '">';
545 print '</td></tr>' . "\n";
546
547 // Target
548 print '<tr class="CTableRow2"><td class="CTableRow2">' . $langs->trans("ThirdParty");
549 print '</td><td class="CTableRow2">';
550 print img_picto('', 'company', 'class="pictofixedwidth"');
551 print '<b>' . $object->thirdparty->name . '</b>';
552 print '</td></tr>' . "\n";
553
554 // Object
555 $text = '<b>' . $langs->trans("Signature" . dol_ucfirst($source) . "Ref", $object->ref) . '</b>';
556 print '<tr class="CTableRow2"><td class="CTableRow2">' . $langs->trans("Designation");
557 print '</td><td class="CTableRow2">' . $text;
558
559 $last_main_doc_file = $object->last_main_doc;
560 $diroutput = $conf->societe->multidir_output[$object->thirdparty->entity].'/'
561 .dol_sanitizeFileName((string) $object->thirdparty->id).'/';
562 if ((empty($last_main_doc_file) ||
563 !dol_is_file($diroutput
564 .$langs->transnoentitiesnoconv("SepaMandateShort").' '.$object->id."-".dol_sanitizeFileName($object->rum).".pdf"))
565 && $message != "signed") {
566 // It seems document has never been generated, or was generated and then deleted.
567 // So we try to regenerate it with its default template.
568 //$defaulttemplate = 'sepamandate';
569 $defaulttemplate = getDolGlobalString("BANKADDON_PDF");
570
571 $object->setDocModel($user, $defaulttemplate);
572 $moreparams = array(
573 'use_companybankid' => $object->id,
574 'force_dir_output' => $diroutput
575 );
576 $result = $object->thirdparty->generateDocument($defaulttemplate, $langs, 0, 0, 0, $moreparams);
577 $object->last_main_doc = $object->thirdparty->last_main_doc;
578 }
579 $directdownloadlink = $object->getLastMainDocLink('company');
580 if ($directdownloadlink) {
581 print '<br><a href="'.$directdownloadlink.'">';
582 print img_mime($object->last_main_doc, '');
583 if ($message == "signed") {
584 print $langs->trans("DownloadSignedDocument").'</a>';
585 } else {
586 print $langs->trans("DownloadDocument").'</a>';
587 }
588 }
589} elseif ($source == 'expedition') {
590 // Signature on expedition
591 $found = true;
592 $langs->load("interventions");
593
594 $result = $object->fetch_thirdparty($object->socid);
595
596 // Proposer
597 print '<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans("Proposer");
598 print '</td><td class="CTableRow2">';
599 print img_picto('', 'company', 'class="pictofixedwidth"');
600 print '<b>'.$creditor.'</b>';
601 print '<input type="hidden" name="creditor" value="'.$creditor.'">';
602 print '</td></tr>'."\n";
603
604 // Target
605 print '<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans("ThirdParty");
606 print '</td><td class="CTableRow2">';
607 print img_picto('', 'company', 'class="pictofixedwidth"');
608 print '<b>'.$object->thirdparty->name.'</b>';
609 print '</td></tr>'."\n";
610
611 // Object
612 $text = '<b>'.$langs->trans("SignatureFichinterRef", $object->ref).'</b>';
613 print '<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans("Designation");
614 print '</td><td class="CTableRow2">'.$text;
615
616 $last_main_doc_file = $object->last_main_doc;
617 if (empty($last_main_doc_file) || !dol_is_file(DOL_DATA_ROOT.'/'.$object->last_main_doc)) {
618 // It seems document has never been generated, or was generated and then deleted.
619 // So we try to regenerate it with its default template.
620 $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.
621 $object->generateDocument($defaulttemplate, $langs);
622 }
623 $directdownloadlink = $object->getLastMainDocLink('', 0, 0);
624 if ($directdownloadlink) {
625 print '<br><a href="'.$directdownloadlink.'">';
626 print img_mime($object->last_main_doc, '');
627 if ($message == "signed") {
628 print $langs->trans("DownloadSignedDocument").'</a>';
629 } else {
630 print $langs->trans("DownloadDocument").'</a>';
631 }
632 }
633 print '<input type="hidden" name="source" value="'.GETPOST("source", 'alpha').'">';
634 print '<input type="hidden" name="ref" value="'.$object->ref.'">';
635 print '</td></tr>'."\n";
636} else {
637 $found = true;
638 $langs->load('companies');
639
640 if (!empty($object->socid) || !empty($object->fk_soc)) {
641 $result = $object->fetch_thirdparty();
642 }
643
644 // Proposer
645 print '<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans("Proposer");
646 print '</td><td class="CTableRow2">';
647 print img_picto('', 'company', 'class="pictofixedwidth"');
648 print '<b>'.$creditor.'</b>';
649 print '<input type="hidden" name="creditor" value="'.$creditor.'">';
650 print '</td></tr>'."\n";
651
652 // Target
653 print '<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans("ThirdParty");
654 print '</td><td class="CTableRow2">';
655 print img_picto('', 'company', 'class="pictofixedwidth"');
656 print '<b>'.$object->thirdparty->name.'</b>';
657 print '</td></tr>'."\n";
658
659 // Object
660 $text = '<b>'.$langs->trans("Signature".dol_ucfirst($source)."Ref", $object->ref).'</b>';
661 print '<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans("Designation");
662 print '</td><td class="CTableRow2">'.$text;
663
664 $last_main_doc_file = $object->last_main_doc;
665
666 if (empty($last_main_doc_file) || !dol_is_file(DOL_DATA_ROOT.'/'.$object->last_main_doc)) {
667 // It seems document has never been generated, or was generated and then deleted.
668 // So we try to regenerate it with its default template.
669 $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.
670 $object->generateDocument($defaulttemplate, $langs);
671 }
672
673 $directdownloadlink = $object->getLastMainDocLink($source);
674 if ($directdownloadlink) {
675 print '<br><a href="'.$directdownloadlink.'">';
676 print img_mime($object->last_main_doc, '');
677 if ($message == "signed") {
678 print $langs->trans("DownloadSignedDocument").'</a>';
679 } else {
680 print $langs->trans("DownloadDocument").'</a>';
681 }
682 }
683}
684
685// Call Hook addFormSign
686$parameters = array('source' => $source);
687$reshook = $hookmanager->executeHooks('addFormSign', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
688
689if (!$found && !$mesg) {
690 $mesg = $langs->transnoentitiesnoconv("ErrorBadParameters");
691}
692
693if ($mesg) {
694 print '<tr><td class="center" colspan="2"><br><div class="warning">'.dol_escape_htmltag($mesg).'</div></td></tr>'."\n";
695}
696
697print '</table>'."\n";
698print "\n";
699
700if ($action != 'dosign') {
701 if ($found && !$error) {
702 // We are in a management option and no error
703 } else {
704 dol_print_error_email('ERRORNEWONLINESIGN');
705 }
706} else {
707 // Print
708}
709
710print '</td></tr>'."\n";
711print '<tr><td class="center">';
712
713
714if ($action == "dosign" && empty($cancel)) {
715 // Show the field to sign
716 print '<div class="tablepublicpayment">';
717 print '<input type="text" class="paddingleftonly marginleftonly paddingright marginrightonly marginbottomonly borderbottom" id="name" placeholder="'.$langs->trans("Lastname").'" spellcheck="false" autofocus>';
718 print '<div id="signature" style="border:solid;"></div>';
719 print '</div>';
720 print '<input type="button" class="small noborderall cursorpointer buttonreset" id="clearsignature" value="'.$langs->trans("ClearSignature").'">';
721
722 // 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.
723 print '<div>';
724 print '<input type="button" class="button butActionSign marginleftonly marginrightonly" id="signbutton" value="'.$langs->trans("Sign").'">';
725 print '<input type="submit" class="button butActionDelete marginleftonly marginrightonly" name="cancel" value="'.$langs->trans("Cancel").'">';
726 print '</div>';
727
728 // Define $urlwithroot
729 $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
730 $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
731 //$urlwithroot = DOL_MAIN_URL_ROOT; // This is to use same domain name than current. For Paypal payment, we can use internal URL like localhost.
732 // TODO Replace DOL_URL_ROOT with $urlwithroot ?
733
734 // Add js code managed into the div #signature
735 $urltogo = $_SERVER["PHP_SELF"].'?ref='.urlencode($ref).'&source='.urlencode($source).'&message=signed&securekey='.urlencode($SECUREKEY).(isModEnabled('multicompany') ? '&entity='.(int) $entity : '');
736 print '<script language="JavaScript" type="text/javascript" src="'.DOL_URL_ROOT.'/public/includes/jquery/plugins/jSignature/jSignature.js"></script>
737 <script type="text/javascript">
738 $(document).ready(function() {
739 $("#signature").jSignature({ color:"#000", lineWidth:0, '.(empty($conf->dol_optimize_smallscreen) ? '' : 'width: 280, ').'height: 180});
740
741 $("#signature").on("change",function(){
742 $("#clearsignature").css("display","");
743 $("#signbutton").attr("disabled",false);
744 if(!$._data($("#signbutton")[0], "events")){
745 $("#signbutton").on("click",function(){
746 console.log("We click on button sign");
747 document.body.style.cursor = \'wait\';
748 var signature = $("#signature").jSignature("getData", "image");
749 var name = document.getElementById("name").value;
750 $.ajax({
751 type: "POST",
752 url: \''.DOL_URL_ROOT.'/core/ajax/onlineSign.php\',
753 dataType: "text",
754 data: {
755 "action" : \'importSignature\',
756 "token" : \''.newToken().'\',
757 "signaturebase64" : signature,
758 "onlinesignname" : name,
759 "ref" : \''.dol_escape_js($REF).'\',
760 "securekey" : \''.dol_escape_js($SECUREKEY).'\',
761 "mode" : \''.dol_escape_js($source).'\',
762 "entity" : \''.dol_escape_js((string) $entity).'\',
763 },
764 success: function(response) {
765 if (response.trim() === "success") {
766 console.log("Success on saving signature");
767 window.location.replace(\''.dol_escape_js($urltogo).'\');
768 } else {
769 document.body.style.cursor = \'auto\';
770 console.error(response);
771 alert("Error on calling the core/ajax/onlineSign.php. See console log.");
772 }
773 },
774 error: function(response) {
775 document.body.style.cursor = \'auto\';
776 console.error(response);
777 alert("Error on calling the core/ajax/onlineSign.php. "+response.responseText);
778 }
779 });
780 });
781 }
782 });
783
784 $("#clearsignature").on("click",function(){
785 $("#signature").jSignature("clear");
786 $("#signbutton").attr("disabled",true);
787 // document.getElementById("onlinesignname").value = "";
788 });
789
790 $("#signbutton").attr("disabled",true);
791 });
792 </script>';
793} else {
794 if ($source == 'proposal') {
795 if ($object->status == $object::STATUS_SIGNED) {
796 print '<br>';
797 if ($message == 'signed') {
798 print img_picto('', 'check', '', 0, 0, 0, '', 'size2x').'<br>';
799 print '<span class="ok">'.$langs->trans("PropalSigned").'</span>';
800 } else {
801 print img_picto('', 'check', '', 0, 0, 0, '', 'size2x').'<br>';
802 print '<span class="ok">'.$langs->trans("PropalAlreadySigned").'</span>';
803 }
804 } elseif ($object->status == $object::STATUS_NOTSIGNED) {
805 print '<br>';
806 if ($message == 'refused') {
807 print img_picto('', 'cross', '', 0, 0, 0, '', 'size2x').'<br>';
808 print '<span class="ok">'.$langs->trans("PropalRefused").'</span>';
809 } else {
810 print img_picto('', 'cross', '', 0, 0, 0, '', 'size2x').'<br>';
811 print '<span class="warning">'.$langs->trans("PropalAlreadyRefused").'</span>';
812 }
813 } else {
814 print '<input type="submit" class="butAction butActionSign small wraponsmartphone marginbottomonly marginleftonly marginrightonly reposition" value="'.$langs->trans("SignPropal").'">';
815 print '<input name="refusepropal" type="submit" class="butActionDelete small wraponsmartphone marginbottomonly marginleftonly marginrightonly reposition" value="'.$langs->trans("RefusePropal").'">';
816 }
817 } elseif ($source == 'contract') {
818 if ($message == 'signed') {
819 print '<span class="ok">'.$langs->trans("ContractSigned").'</span>';
820 } else {
821 print '<input type="submit" class="butAction butActionSign small wraponsmartphone marginbottomonly marginleftonly marginrightonly reposition" value="'.$langs->trans("SignContract").'">';
822 }
823 } elseif ($source == 'fichinter') {
824 if ($message == 'signed') {
825 print '<span class="ok">'.$langs->trans("FichinterSigned").'</span>';
826 } else {
827 print '<input type="submit" class="butAction butActionSign small wraponsmartphone marginbottomonly marginleftonly marginrightonly reposition" value="'.$langs->trans("SignFichinter").'">';
828 }
829 } elseif ($source == 'expedition') {
830 if ($message == 'signed' || $object->signed_status == Expedition::$SIGNED_STATUSES['STATUS_SIGNED_SENDER']) {
831 print '<span class="ok">'.$langs->trans("ExpeditionSigned").'</span>';
832 } else {
833 print '<input type="submit" class="butAction butActionSign small wraponsmartphone marginbottomonly marginleftonly marginrightonly reposition" value="'.$langs->trans("SignExpedition").'">';
834 }
835 } else {
836 if ($message == 'signed') {
837 print '<span class="ok">'.$langs->trans(dol_ucfirst($source)."Signed").'</span>';
838 } else {
839 print '<input type="submit" class="butAction butActionSign small wraponsmartphone marginbottomonly marginleftonly marginrightonly reposition" value="'.$langs->trans("Sign".dol_ucfirst($source)).'">';
840 }
841 }
842}
843print '</td></tr>'."\n";
844print '</table>'."\n";
845
846print '</form>'."\n";
847print '</div>'."\n";
848print '<br>';
849
850
852
853llxFooter('', 'public');
854
855$db->close();
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
global $dolibarr_main_url_root
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:91
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:73
$object ref
Definition info.php:90
Class to manage bank accounts description of third parties.
Class to manage generation of HTML components Only common components must be here.
Class to manage proposals.
htmlPrintOnlineHeader($mysoc, $langs, $showlogo=1, $alttext='', $subimageconst='', $altlogo1='', $altlogo2='')
Show the header of a company in HTML public pages.
htmlPrintOnlineFooter($fromcompany, $langs, $addformmessage=0, $suffix='', $object=null)
Show footer of company in HTML public pages.
global $mysoc
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
dol_filemtime($pathoffile)
Return time of a file.
dol_is_file($pathoffile)
Return if path is a file.
dol_now($mode='gmt')
Return date for now.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
dol_ucfirst($string, $encoding="UTF-8")
Convert first character of the first word of a string to upper.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
img_mime($file, $titlealt='', $morecss='')
Show MIME img of a file.
dol_escape_js($stringtoescape, $mode=0, $noescapebackslashn=0)
Returns text escaped for inclusion into JavaScript code.
getDolCurrency()
Return the main currency ('EUR', 'USD', ...)
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_print_error_email($prefixcode, $errormessage='', $errormessages=array(), $morecss='error', $email='')
Show a public email and error code to contact if technical error.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
print $langs trans("Show") . '< td style="' . $timeColor . '" align="center"> s</td > badge status0 badge status4 badge status3 Error badge status8< td align="center">< span class="badge ' . $badge . '"></span ></td >< td align="center">< a href="#" class="button button-small" onclick="openLogModal(this)" data-req="' . dol_escape_htmltag($reqSafe) . '" data-res="' . dol_escape_htmltag($resSafe) . '" data-err="' . dol_escape_htmltag($errSafe) . '">< span class="fa fa-search-plus"></span ></a ></td ></tr >< tr >< td colspan="' . $colspan . '" class="opacitymedium"></td ></tr ></table ></div ></form > logModal none logModal none s a JSON string
buildzip.php
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition repair.php:133
httponly_accessforbidden($message='1', $http_response_code=403, $stringalreadysanitized=0)
Show a message to say access is forbidden and stop program.
dol_hash($chain, $type='0', $nosalt=0, $mode=0)
Returns a hash (non reversible encryption) of a string.
dol_verifyHash($chain, $hash, $type='0')
Compute a hash and compare it to the given one For backward compatibility reasons,...