dolibarr 25.0.0-alpha
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
100if ($source == '') {
101 $source = 'proposal';
102}
103if (!empty($refusepropal)) {
104 $action = "refusepropal";
105}
106
107// Define $urlwithroot
108//$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root));
109//$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
110$urlwithroot = DOL_MAIN_URL_ROOT; // This is to use same domain name than current. For Paypal payment, we can use internal URL like localhost.
111
112
113// Complete urls for post treatment
114$SECUREKEY = GETPOST("securekey"); // Secure key
115
116if (!empty($source)) {
117 $urlok .= 'source='.urlencode($source).'&';
118 $urlko .= 'source='.urlencode($source).'&';
119}
120if (!empty($REF)) {
121 $urlok .= 'ref='.urlencode($REF).'&';
122 $urlko .= 'ref='.urlencode($REF).'&';
123}
124if (!empty($SECUREKEY)) {
125 $urlok .= 'securekey='.urlencode($SECUREKEY).'&';
126 $urlko .= 'securekey='.urlencode($SECUREKEY).'&';
127}
128if (!empty($entity)) {
129 $urlok .= 'entity='.urlencode((string) ($entity)).'&';
130 $urlko .= 'entity='.urlencode((string) ($entity)).'&';
131}
132$urlok = preg_replace('/&$/', '', $urlok); // Remove last &
133$urlko = preg_replace('/&$/', '', $urlko); // Remove last &
134
135$creditor = $mysoc->name;
136
137$type = $source;
138if (!$action) {
139 if ($source && !$ref) {
140 httponly_accessforbidden($langs->trans('ErrorBadParameters')." - ref missing", 400, 1);
141 }
142}
143
144global $dolibarr_main_instance_unique_id;
145$defaultsalt = substr(dol_hash('dolibarr'.$dolibarr_main_instance_unique_id, 'sha256'), 0, 32); // Fallback if no specific salt was set
146
147// Check securitykey
148$securekeyseed = '';
149if ($source == 'proposal') {
150 $securekeyseed = getDolGlobalString('PROPOSAL_ONLINE_SIGNATURE_SECURITY_TOKEN', $defaultsalt);
151} elseif ($source == 'contract') {
152 $securekeyseed = getDolGlobalString('CONTRACT_ONLINE_SIGNATURE_SECURITY_TOKEN', $defaultsalt);
153} elseif ($source == 'fichinter') {
154 $securekeyseed = getDolGlobalString('FICHINTER_ONLINE_SIGNATURE_SECURITY_TOKEN', $defaultsalt);
155} elseif ($source == 'societe_rib') {
156 $securekeyseed = getDolGlobalString('SOCIETE_RIB_ONLINE_SIGNATURE_SECURITY_TOKEN', $defaultsalt);
157} else {
158 $securekeyseed = getDolGlobalString(dol_strtoupper((string) $source).'_ONLINE_SIGNATURE_SECURITY_TOKEN', $defaultsalt);
159}
160if (!dol_verifyHash($securekeyseed.$type.$ref.(isModEnabled('multicompany') ? $entity : ''), $SECUREKEY, 'hash')) {
161 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);
162}
163
164if ($source == 'proposal') {
165 require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
166 $object = new Propal($db);
167 $result = $object->fetch(0, $ref, '', $entity);
168} elseif ($source == 'contract') {
169 require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
170 $object = new Contrat($db);
171 $result = $object->fetch(0, $ref);
172} elseif ($source == 'fichinter') {
173 require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php';
174 $object = new Fichinter($db);
175 $result = $object->fetch(0, $ref);
176} elseif ($source == 'societe_rib') {
177 require_once DOL_DOCUMENT_ROOT.'/societe/class/companybankaccount.class.php';
179 $result = $object->fetch(0, $ref);
180} elseif ($source == 'expedition') {
181 require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php';
182 $object = new Expedition($db);
183 $result = $object->fetch(0, $ref);
184} else {
185 httponly_accessforbidden($langs->trans('ErrorBadParameters')." - Bad value for source. Value not supported.", 400, 1);
186}
187
188// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
189$hookmanager->initHooks(array('onlinesign'));
190
191$error = 0;
192
193
194/*
195 * Actions
196 */
197
198if ($action == 'confirm_refusepropal' && $confirm == 'yes') { // Test on permission not required here. Public form. Security checked on the securekey and on mitigation
199 $db->begin();
200
201 $sql = "UPDATE ".MAIN_DB_PREFIX."propal";
202 $sql .= " SET fk_statut = ".((int) $object::STATUS_NOTSIGNED).", note_private = '".$db->escape($object->note_private)."', date_signature = '".$db->idate(dol_now())."'";
203 $sql .= " WHERE rowid = ".((int) $object->id);
204
205 dol_syslog(__FILE__, LOG_DEBUG);
206 $resql = $db->query($sql);
207 if (!$resql) {
208 $error++;
209 }
210
211 if (!$error) {
212 $db->commit();
213
214 $message = 'refused';
215 setEventMessages("PropalRefused", null, 'warnings');
216 if (method_exists($object, 'call_trigger')) {
217 $object->context = array('closedfromonlinesignature' => 'closedfromonlinesignature');
218 $result = $object->call_trigger('PROPAL_CLOSE_REFUSED', $user);
219 if ($result < 0) {
220 $error++;
221 }
222 }
223 } else {
224 $db->rollback();
225 }
226
227 $object->fetch(0, $ref);
228}
229
230// $action == "dosign" is handled later...
231
232
233/*
234 * View
235 */
236
237$form = new Form($db);
238
239$head = '';
240if (getDolGlobalString('MAIN_SIGN_CSS_URL')) {
241 $head = '<link rel="stylesheet" type="text/css" href="' . getDolGlobalString('MAIN_SIGN_CSS_URL').'?lang='.$langs->defaultlang.'">'."\n";
242}
243
244$conf->dol_hide_topmenu = 1;
245$conf->dol_hide_leftmenu = 1;
246
247$title = $langs->trans("OnlineSignature");
248
249$replacemainarea = (empty($conf->dol_hide_leftmenu) ? '<div>' : '').'<div>';
250llxHeader($head, $title, '', '', 0, 0, '', '', '', 'onlinepaymentbody', $replacemainarea, 1);
251
252htmlPrintOnlineHeader($mysoc, $langs, 1, '', 'ONLINE_SIGN_IMAGE_PUBLIC_INTERFACE', 'ONLINE_SIGN_LOGO_'.$suffix, 'ONLINE_SIGN_LOGO');
253
254if ($action == 'refusepropal') {
255 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);
256}
257
258// Check link validity for param 'source' to avoid use of the examples as value
259if (/* $source !== '' :never empty && */ in_array($ref, array('member_ref', 'contractline_ref', 'invoice_ref', 'order_ref', 'proposal_ref', ''))) {
260 $langs->load("errors");
261 dol_print_error_email('BADREFINONLINESIGNFORM', $langs->trans("ErrorBadLinkSourceSetButBadValueForRef", $source, $ref));
262 // End of page
263 llxFooter();
264 $db->close();
265 exit;
266}
267
268print '<span id="dolpaymentspan"></span>'."\n";
269print '<div class="center">'."\n";
270print '<form id="dolpaymentform" class="center" name="paymentform" action="'.$_SERVER["PHP_SELF"].'" method="POST">'."\n";
271print '<input type="hidden" name="token" value="'.newToken().'">'."\n";
272print '<input type="hidden" name="action" value="dosign">'."\n";
273print '<input type="hidden" name="tag" value="'.GETPOST("tag", 'alpha').'">'."\n";
274print '<input type="hidden" name="suffix" value="'.GETPOST("suffix", 'alpha').'">'."\n";
275print '<input type="hidden" name="securekey" value="'.$SECUREKEY.'">'."\n";
276print '<input type="hidden" name="entity" value="'.$entity.'" />';
277print '<input type="hidden" name="page_y" value="" />';
278print '<input type="hidden" name="source" value="'.$source.'" />';
279print '<input type="hidden" name="ref" value="'.$ref.'" />';
280print "\n";
281print '<!-- Form to sign -->'."\n";
282
283if ($source == 'proposal' && getDolGlobalString('PROPOSAL_IMAGE_PUBLIC_SIGN')) {
284 print '<div class="backimagepublicproposalsign">';
285 print '<img id="idPROPOSAL_IMAGE_PUBLIC_INTERFACE" src="' . getDolGlobalString('PROPOSAL_IMAGE_PUBLIC_SIGN').'">';
286 print '</div>';
287}
288
289print '<table id="dolpublictable" summary="Payment form" class="center">'."\n";
290
291// Output introduction text
292$text = '';
293if (getDolGlobalString('ONLINE_SIGN_NEWFORM_TEXT')) {
294 $reg = array();
295 if (preg_match('/^\‍((.*)\‍)$/', $conf->global->ONLINE_SIGN_NEWFORM_TEXT, $reg)) {
296 $text .= $langs->trans($reg[1])."<br>\n";
297 } else {
298 $text .= getDolGlobalString('ONLINE_SIGN_NEWFORM_TEXT') . "<br>\n";
299 }
300 $text = '<tr><td align="center"><br>'.$text.'<br></td></tr>'."\n";
301}
302if (empty($text)) {
303 if ($source == 'proposal') {
304 $text .= '<tr><td class="textpublicpayment"><br><strong>'.$langs->trans("WelcomeOnOnlineSignaturePageProposal", $mysoc->name).'</strong></td></tr>'."\n";
305 $text .= '<tr><td class="textpublicpayment small opacitymedium">'.$langs->trans("ThisScreenAllowsYouToSignDocFromProposal", $creditor).'<br><br></td></tr>'."\n";
306 } elseif ($source == 'contract') {
307 $text .= '<tr><td class="textpublicpayment"><br><strong>'.$langs->trans("WelcomeOnOnlineSignaturePageContract", $mysoc->name).'</strong></td></tr>'."\n";
308 $text .= '<tr><td class="textpublicpayment small opacitymedium">'.$langs->trans("ThisScreenAllowsYouToSignDocFromContract", $creditor).'<br><br></td></tr>'."\n";
309 } elseif ($source == 'fichinter') {
310 $text .= '<tr><td class="textpublicpayment"><br><strong>'.$langs->trans("WelcomeOnOnlineSignaturePageFichinter", $mysoc->name).'</strong></td></tr>'."\n";
311 $text .= '<tr><td class="textpublicpayment small opacitymedium">'.$langs->trans("ThisScreenAllowsYouToSignDocFromFichinter", $creditor).'<br><br></td></tr>'."\n";
312 } elseif ($source == 'expedition') {
313 $text .= '<tr><td class="textpublicpayment"><br><strong>'.$langs->trans("WelcomeOnOnlineSignaturePageExpedition", $mysoc->name).'</strong></td></tr>'."\n";
314 $text .= '<tr><td class="textpublicpayment small opacitymedium">'.$langs->trans("ThisScreenAllowsYouToSignDocFromExpedition", $creditor).'<br><br></td></tr>'."\n";
315 } else {
316 $text .= '<tr><td class="textpublicpayment"><br><strong>'.$langs->trans("WelcomeOnOnlineSignaturePage".dol_ucfirst($source), $mysoc->name).'</strong></td></tr>'."\n";
317 $text .= '<tr><td class="textpublicpayment small opacitymedium">'.$langs->trans("ThisScreenAllowsYouToSignDocFrom".dol_ucfirst($source), $creditor).'<br><br></td></tr>'."\n";
318 }
319}
320print $text;
321
322// Output payment summary form
323print '<tr><td align="center">';
324print '<table with="100%" id="tablepublicpayment">';
325if ($source == 'proposal') {
326 print '<tr><td colspan="2" class="left small opacitymedium">'.$langs->trans("ThisIsInformationOnDocumentToSignProposal").'<br><br></td></tr>'."\n";
327} elseif ($source == 'contract') {
328 print '<tr><td colspan="2" class="left small opacitymedium">'.$langs->trans("ThisIsInformationOnDocumentToSignContract").'<br><br></td></tr>'."\n";
329} elseif ($source == 'fichinter') {
330 print '<tr><td colspan="2" class="left small opacitymedium">'.$langs->trans("ThisIsInformationOnDocumentToSignFichinter").'<br><br></td></tr>'."\n";
331} elseif ($source == 'expedition') {
332 print '<tr><td colspan="2" class="left small opacitymedium">'.$langs->trans("ThisIsInformationOnDocumentToSignExpedition").'<br><br></td></tr>'."\n";
333} else {
334 print '<tr><td colspan="2" class="left small opacitymedium">'.$langs->trans("ThisIsInformationOnDocumentToSign".dol_ucfirst($source)).'<br><br></td></tr>'."\n";
335}
336$found = false;
337$error = 0;
338
339// Signature on commercial proposal
340if ($source == 'proposal') {
341 $found = true;
342 $langs->load("proposal");
343
344 $result = $object->fetch_thirdparty($object->socid);
345
346 // Creditor
347 print '<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans("Creditor");
348 print '</td><td class="CTableRow2">';
349 print img_picto('', 'company', 'class="pictofixedwidth"');
350 print '<b>'.$creditor.'</b>';
351 print '<input type="hidden" name="creditor" value="'.$creditor.'">';
352 print '</td></tr>'."\n";
353
354 // Debitor
355 print '<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans("ThirdParty");
356 print '</td><td class="CTableRow2">';
357 print img_picto('', 'company', 'class="pictofixedwidth"');
358 print '<b>'.$object->thirdparty->name.'</b>';
359 print '</td></tr>'."\n";
360
361 // Amount
362
363 $amount = '<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans("Amount");
364 $amount .= '</td><td class="CTableRow2">';
365 $amount .= '<b>'.price($object->total_ttc, 0, $langs, 1, -1, -1, getDolCurrency()).'</b>';
366 if ($object->multicurrency_code != getDolCurrency()) {
367 $amount .= ' ('.price($object->multicurrency_total_ttc, 0, $langs, 1, -1, -1, $object->multicurrency_code).')';
368 }
369 $amount .= '</td></tr>'."\n";
370
371 // Call Hook amountPropalSign
372 $parameters = array('source' => $source);
373 $reshook = $hookmanager->executeHooks('amountPropalSign', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
374 if (empty($reshook)) {
375 $amount .= $hookmanager->resPrint;
376 } elseif ($reshook > 0) {
377 $amount = $hookmanager->resPrint;
378 }
379
380 print $amount;
381
382 // Object
383 $text = '<b>'.$langs->trans("SignatureProposalRef", $object->ref).'</b>';
384 print '<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans("Designation");
385 print '</td><td class="CTableRow2">'.$text;
386
387 $last_main_doc_file = $object->last_main_doc;
388
389 if ($object->status == $object::STATUS_VALIDATED) {
390 $object->last_main_doc = preg_replace('/_signed-(\d+)/', '', $object->last_main_doc); // We want to be sure to not work on the signed version
391
392 if (empty($last_main_doc_file) || !dol_is_file(DOL_DATA_ROOT.'/'.$object->last_main_doc)) {
393 // It seems document has never been generated, or was generated and then deleted.
394 // So we try to regenerate it with its default template.
395 $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.
396 $object->generateDocument($defaulttemplate, $langs);
397 }
398
399 $directdownloadlink = $object->getLastMainDocLink('proposal');
400 if ($directdownloadlink) {
401 print '<br><a href="'.$directdownloadlink.'">';
402 print img_mime($object->last_main_doc, '');
403 print $langs->trans("DownloadDocument").'</a>';
404 }
405 } else {
406 if ($object->status == $object::STATUS_NOTSIGNED) {
407 $directdownloadlink = $object->getLastMainDocLink('proposal');
408 if ($directdownloadlink) {
409 print '<br><a href="'.$directdownloadlink.'">';
410 print img_mime($last_main_doc_file, '');
411 print $langs->trans("DownloadDocument").'</a>';
412 }
413 } elseif ($object->status == $object::STATUS_SIGNED || $object->status == $object::STATUS_BILLED) {
414 if (preg_match('/_signed-(\d+)/', $last_main_doc_file)) { // If the last main doc has been signed
415 $last_main_doc_file_not_signed = preg_replace('/_signed-(\d+)/', '', $last_main_doc_file);
416
417 $datefilesigned = dol_filemtime($last_main_doc_file);
418 $datefilenotsigned = dol_filemtime($last_main_doc_file_not_signed);
419
420 if (empty($datefilenotsigned) || $datefilesigned > $datefilenotsigned) { // If file signed is more recent
421 $directdownloadlink = $object->getLastMainDocLink('proposal');
422 if ($directdownloadlink) {
423 print '<br><a href="'.$directdownloadlink.'">';
424 print img_mime($object->last_main_doc, '');
425 print $langs->trans("DownloadDocument").'</a>';
426 }
427 }
428 }
429 }
430 }
431
432 print '<input type="hidden" name="source" value="'.GETPOST("source", 'alpha').'">';
433 print '<input type="hidden" name="ref" value="'.$object->ref.'">';
434 print '</td></tr>'."\n";
435} elseif ($source == 'contract') { // Signature on contract
436 $found = true;
437 $langs->load("contract");
438
439 $result = $object->fetch_thirdparty($object->socid);
440
441 // Proposer
442 print '<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans("Proposer");
443 print '</td><td class="CTableRow2">';
444 print img_picto('', 'company', 'class="pictofixedwidth"');
445 print '<b>'.$creditor.'</b>';
446 print '<input type="hidden" name="creditor" value="'.$creditor.'">';
447 print '</td></tr>'."\n";
448
449 // Target
450 print '<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans("ThirdParty");
451 print '</td><td class="CTableRow2">';
452 print img_picto('', 'company', 'class="pictofixedwidth"');
453 print '<b>'.$object->thirdparty->name.'</b>';
454 print '</td></tr>'."\n";
455
456 // Object
457 $text = '<b>'.$langs->trans("SignatureContractRef", $object->ref).'</b>';
458 print '<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans("Designation");
459 print '</td><td class="CTableRow2">'.$text;
460
461 $last_main_doc_file = $object->last_main_doc;
462
463 if (empty($last_main_doc_file) || !dol_is_file(DOL_DATA_ROOT.'/'.$object->last_main_doc)) {
464 // It seems document has never been generated, or was generated and then deleted.
465 // So we try to regenerate it with its default template.
466 $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.
467 $object->generateDocument($defaulttemplate, $langs);
468 }
469
470 $directdownloadlink = $object->getLastMainDocLink('contract');
471 if ($directdownloadlink) {
472 print '<br><a href="'.$directdownloadlink.'">';
473 print img_mime($object->last_main_doc, '');
474 if ($message == "signed") {
475 print $langs->trans("DownloadSignedDocument").'</a>';
476 } else {
477 print $langs->trans("DownloadDocument").'</a>';
478 }
479 }
480
481
482 print '<input type="hidden" name="source" value="'.GETPOST("source", 'alpha').'">';
483 print '<input type="hidden" name="ref" value="'.$object->ref.'">';
484 print '</td></tr>'."\n";
485} elseif ($source == 'fichinter') {
486 // Signature on fichinter
487 $found = true;
488 $langs->load("interventions");
489
490 $result = $object->fetch_thirdparty($object->socid);
491
492 // Proposer
493 print '<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans("Proposer");
494 print '</td><td class="CTableRow2">';
495 print img_picto('', 'company', 'class="pictofixedwidth"');
496 print '<b>'.$creditor.'</b>';
497 print '<input type="hidden" name="creditor" value="'.$creditor.'">';
498 print '</td></tr>'."\n";
499
500 // Target
501 print '<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans("ThirdParty");
502 print '</td><td class="CTableRow2">';
503 print img_picto('', 'company', 'class="pictofixedwidth"');
504 print '<b>'.$object->thirdparty->name.'</b>';
505 print '</td></tr>'."\n";
506
507 // Object
508 $text = '<b>'.$langs->trans("SignatureFichinterRef", $object->ref).'</b>';
509 print '<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans("Designation");
510 print '</td><td class="CTableRow2">'.$text;
511
512 $last_main_doc_file = $object->last_main_doc;
513
514 if (empty($last_main_doc_file) || !dol_is_file(DOL_DATA_ROOT.'/'.$object->last_main_doc)) {
515 // It seems document has never been generated, or was generated and then deleted.
516 // So we try to regenerate it with its default template.
517 $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.
518 $object->generateDocument($defaulttemplate, $langs);
519 }
520
521 $directdownloadlink = $object->getLastMainDocLink('fichinter');
522 if ($directdownloadlink) {
523 print '<br><a href="'.$directdownloadlink.'">';
524 print img_mime($object->last_main_doc, '');
525 if ($message == "signed") {
526 print $langs->trans("DownloadSignedDocument").'</a>';
527 } else {
528 print $langs->trans("DownloadDocument").'</a>';
529 }
530 }
531 print '<input type="hidden" name="source" value="'.GETPOST("source", 'alpha').'">';
532 print '<input type="hidden" name="ref" value="'.$object->ref.'">';
533 print '</td></tr>'."\n";
534} elseif ($source == 'societe_rib') {
535 $found = true;
536 $langs->loadLangs(array("companies", "commercial", "withdrawals"));
537
538 $result = $object->fetch_thirdparty();
539
540 // Proposer
541 print '<tr class="CTableRow2"><td class="CTableRow2">' . $langs->trans("CreditorName");
542 print '</td><td class="CTableRow2">';
543 print img_picto('', 'company', 'class="pictofixedwidth"');
544 print '<b>' . $creditor . '</b>';
545 print '<input type="hidden" name="creditor" value="' . $creditor . '">';
546 print '</td></tr>' . "\n";
547
548 // Target
549 print '<tr class="CTableRow2"><td class="CTableRow2">' . $langs->trans("ThirdParty");
550 print '</td><td class="CTableRow2">';
551 print img_picto('', 'company', 'class="pictofixedwidth"');
552 print '<b>' . $object->thirdparty->name . '</b>';
553 print '</td></tr>' . "\n";
554
555 // Object
556 $text = '<b>' . $langs->trans("Signature" . dol_ucfirst($source) . "Ref", $object->ref) . '</b>';
557 print '<tr class="CTableRow2"><td class="CTableRow2">' . $langs->trans("Designation");
558 print '</td><td class="CTableRow2">' . $text;
559
560 $last_main_doc_file = $object->last_main_doc;
561 $diroutput = $conf->societe->multidir_output[$object->thirdparty->entity].'/'
562 .dol_sanitizeFileName((string) $object->thirdparty->id).'/';
563 if ((empty($last_main_doc_file) ||
564 !dol_is_file($diroutput
565 .$langs->transnoentitiesnoconv("SepaMandateShort").' '.$object->id."-".dol_sanitizeFileName($object->rum).".pdf"))
566 && $message != "signed") {
567 // It seems document has never been generated, or was generated and then deleted.
568 // So we try to regenerate it with its default template.
569 //$defaulttemplate = 'sepamandate';
570 $defaulttemplate = getDolGlobalString("BANKADDON_PDF");
571
572 $object->setDocModel($user, $defaulttemplate);
573 $moreparams = array(
574 'use_companybankid' => $object->id,
575 'force_dir_output' => $diroutput
576 );
577 $result = $object->thirdparty->generateDocument($defaulttemplate, $langs, 0, 0, 0, $moreparams);
578 $object->last_main_doc = $object->thirdparty->last_main_doc;
579 }
580 $directdownloadlink = $object->getLastMainDocLink('company');
581 if ($directdownloadlink) {
582 print '<br><a href="'.$directdownloadlink.'">';
583 print img_mime($object->last_main_doc, '');
584 if ($message == "signed") {
585 print $langs->trans("DownloadSignedDocument").'</a>';
586 } else {
587 print $langs->trans("DownloadDocument").'</a>';
588 }
589 }
590} elseif ($source == 'expedition') {
591 // Signature on expedition
592 $found = true;
593 $langs->load("interventions");
594
595 $result = $object->fetch_thirdparty($object->socid);
596
597 // Proposer
598 print '<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans("Proposer");
599 print '</td><td class="CTableRow2">';
600 print img_picto('', 'company', 'class="pictofixedwidth"');
601 print '<b>'.$creditor.'</b>';
602 print '<input type="hidden" name="creditor" value="'.$creditor.'">';
603 print '</td></tr>'."\n";
604
605 // Target
606 print '<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans("ThirdParty");
607 print '</td><td class="CTableRow2">';
608 print img_picto('', 'company', 'class="pictofixedwidth"');
609 print '<b>'.$object->thirdparty->name.'</b>';
610 print '</td></tr>'."\n";
611
612 // Object
613 $text = '<b>'.$langs->trans("SignatureFichinterRef", $object->ref).'</b>';
614 print '<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans("Designation");
615 print '</td><td class="CTableRow2">'.$text;
616
617 $last_main_doc_file = $object->last_main_doc;
618 if (empty($last_main_doc_file) || !dol_is_file(DOL_DATA_ROOT.'/'.$object->last_main_doc)) {
619 // It seems document has never been generated, or was generated and then deleted.
620 // So we try to regenerate it with its default template.
621 $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.
622 $object->generateDocument($defaulttemplate, $langs);
623 }
624 $directdownloadlink = $object->getLastMainDocLink('', 0, 0);
625 if ($directdownloadlink) {
626 print '<br><a href="'.$directdownloadlink.'">';
627 print img_mime($object->last_main_doc, '');
628 if ($message == "signed") {
629 print $langs->trans("DownloadSignedDocument").'</a>';
630 } else {
631 print $langs->trans("DownloadDocument").'</a>';
632 }
633 }
634 print '<input type="hidden" name="source" value="'.GETPOST("source", 'alpha').'">';
635 print '<input type="hidden" name="ref" value="'.$object->ref.'">';
636 print '</td></tr>'."\n";
637} else {
638 $found = true;
639 $langs->load('companies');
640
641 if (!empty($object->socid) || !empty($object->fk_soc)) {
642 $result = $object->fetch_thirdparty();
643 }
644
645 // Proposer
646 print '<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans("Proposer");
647 print '</td><td class="CTableRow2">';
648 print img_picto('', 'company', 'class="pictofixedwidth"');
649 print '<b>'.$creditor.'</b>';
650 print '<input type="hidden" name="creditor" value="'.$creditor.'">';
651 print '</td></tr>'."\n";
652
653 // Target
654 print '<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans("ThirdParty");
655 print '</td><td class="CTableRow2">';
656 print img_picto('', 'company', 'class="pictofixedwidth"');
657 print '<b>'.$object->thirdparty->name.'</b>';
658 print '</td></tr>'."\n";
659
660 // Object
661 $text = '<b>'.$langs->trans("Signature".dol_ucfirst($source)."Ref", $object->ref).'</b>';
662 print '<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans("Designation");
663 print '</td><td class="CTableRow2">'.$text;
664
665 $last_main_doc_file = $object->last_main_doc;
666
667 if (empty($last_main_doc_file) || !dol_is_file(DOL_DATA_ROOT.'/'.$object->last_main_doc)) {
668 // It seems document has never been generated, or was generated and then deleted.
669 // So we try to regenerate it with its default template.
670 $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.
671 $object->generateDocument($defaulttemplate, $langs);
672 }
673
674 $directdownloadlink = $object->getLastMainDocLink($source);
675 if ($directdownloadlink) {
676 print '<br><a href="'.$directdownloadlink.'">';
677 print img_mime($object->last_main_doc, '');
678 if ($message == "signed") {
679 print $langs->trans("DownloadSignedDocument").'</a>';
680 } else {
681 print $langs->trans("DownloadDocument").'</a>';
682 }
683 }
684}
685
686// Call Hook addFormSign
687$parameters = array('source' => $source);
688$reshook = $hookmanager->executeHooks('addFormSign', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
689
690if (!$found) {
691 print '<tr><td class="center" colspan="2"><br><div class="warning">'.dol_escape_htmltag($langs->transnoentitiesnoconv("ErrorBadParameters")).'</div></td></tr>'."\n";
692}
693
694print '</table>'."\n";
695print "\n";
696
697if ($action != 'dosign') {
698 if ($found && !$error) {
699 // We are in a management option and no error
700 } else {
701 dol_print_error_email('ERRORNEWONLINESIGN');
702 }
703} else {
704 // Print
705}
706
707print '</td></tr>'."\n";
708print '<tr><td class="center">';
709
710
711if ($action == "dosign" && empty($cancel)) {
712 // Show the field to sign
713 print '<div class="tablepublicpayment">';
714 print '<input type="text" class="paddingleftonly marginleftonly paddingright marginrightonly marginbottomonly borderbottom" id="name" placeholder="'.$langs->trans("Lastname").'" spellcheck="false" autofocus>';
715 print '<div id="signature" style="border:solid;"></div>';
716 print '</div>';
717 print '<input type="button" class="small noborderall cursorpointer buttonreset" id="clearsignature" value="'.$langs->trans("ClearSignature").'">';
718
719 // 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.
720 print '<div>';
721 print '<input type="button" class="button butActionSign marginleftonly marginrightonly" id="signbutton" value="'.$langs->trans("Sign").'">';
722 print '<input type="submit" class="button butActionDelete marginleftonly marginrightonly" name="cancel" value="'.$langs->trans("Cancel").'">';
723 print '</div>';
724
725 // Define $urlwithroot
726 $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
727 $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
728 //$urlwithroot = DOL_MAIN_URL_ROOT; // This is to use same domain name than current. For Paypal payment, we can use internal URL like localhost.
729 // TODO Replace DOL_URL_ROOT with $urlwithroot ?
730
731 // Add js code managed into the div #signature
732 $urltogo = $_SERVER["PHP_SELF"].'?ref='.urlencode($ref).'&source='.urlencode($source).'&message=signed&securekey='.urlencode($SECUREKEY).(isModEnabled('multicompany') ? '&entity='.(int) $entity : '');
733 print '<script language="JavaScript" type="text/javascript" src="'.DOL_URL_ROOT.'/public/includes/jquery/plugins/jSignature/jSignature.js"></script>
734 <script type="text/javascript">
735 $(document).ready(function() {
736 $("#signature").jSignature({ color:"#000", lineWidth:0, '.(empty($conf->dol_optimize_smallscreen) ? '' : 'width: 280, ').'height: 180});
737
738 $("#signature").on("change",function(){
739 $("#clearsignature").css("display","");
740 $("#signbutton").attr("disabled",false);
741 if(!$._data($("#signbutton")[0], "events")){
742 $("#signbutton").on("click",function(){
743 console.log("We click on button sign");
744 document.body.style.cursor = \'wait\';
745 var signature = $("#signature").jSignature("getData", "image");
746 var name = document.getElementById("name").value;
747 $.ajax({
748 type: "POST",
749 url: \''.DOL_URL_ROOT.'/core/ajax/onlineSign.php\',
750 dataType: "text",
751 data: {
752 "action" : \'importSignature\',
753 "token" : \''.newToken().'\',
754 "signaturebase64" : signature,
755 "onlinesignname" : name,
756 "ref" : \''.dol_escape_js($REF).'\',
757 "securekey" : \''.dol_escape_js($SECUREKEY).'\',
758 "mode" : \''.dol_escape_js($source).'\',
759 "entity" : \''.dol_escape_js((string) $entity).'\',
760 },
761 success: function(response) {
762 if (response.trim() === "success") {
763 console.log("Success on saving signature");
764 window.location.replace(\''.dol_escape_js($urltogo).'\');
765 } else {
766 document.body.style.cursor = \'auto\';
767 console.error(response);
768 alert("Error on calling the core/ajax/onlineSign.php. See console log.");
769 }
770 },
771 error: function(response) {
772 document.body.style.cursor = \'auto\';
773 console.error(response);
774 alert("Error on calling the core/ajax/onlineSign.php. "+response.responseText);
775 }
776 });
777 });
778 }
779 });
780
781 $("#clearsignature").on("click",function(){
782 $("#signature").jSignature("clear");
783 $("#signbutton").attr("disabled",true);
784 // document.getElementById("onlinesignname").value = "";
785 });
786
787 $("#signbutton").attr("disabled",true);
788 });
789 </script>';
790} else {
791 if ($source == 'proposal') {
792 if ($object->status == $object::STATUS_SIGNED) {
793 print '<br>';
794 if ($message == 'signed') {
795 print img_picto('', 'check', '', 0, 0, 0, '', 'size2x').'<br>';
796 print '<span class="ok">'.$langs->trans("PropalSigned").'</span>';
797 } else {
798 print img_picto('', 'check', '', 0, 0, 0, '', 'size2x').'<br>';
799 print '<span class="ok">'.$langs->trans("PropalAlreadySigned").'</span>';
800 }
801 } elseif ($object->status == $object::STATUS_NOTSIGNED) {
802 print '<br>';
803 if ($message == 'refused') {
804 print img_picto('', 'cross', '', 0, 0, 0, '', 'size2x').'<br>';
805 print '<span class="ok">'.$langs->trans("PropalRefused").'</span>';
806 } else {
807 print img_picto('', 'cross', '', 0, 0, 0, '', 'size2x').'<br>';
808 print '<span class="warning">'.$langs->trans("PropalAlreadyRefused").'</span>';
809 }
810 } else {
811 print '<input type="submit" class="butAction butActionSign small wraponsmartphone marginbottomonly marginleftonly marginrightonly reposition" value="'.$langs->trans("SignPropal").'">';
812 print '<input name="refusepropal" type="submit" class="butActionDelete small wraponsmartphone marginbottomonly marginleftonly marginrightonly reposition" value="'.$langs->trans("RefusePropal").'">';
813 }
814 } elseif ($source == 'contract') {
815 if ($message == 'signed') {
816 print '<span class="ok">'.$langs->trans("ContractSigned").'</span>';
817 } else {
818 print '<input type="submit" class="butAction butActionSign small wraponsmartphone marginbottomonly marginleftonly marginrightonly reposition" value="'.$langs->trans("SignContract").'">';
819 }
820 } elseif ($source == 'fichinter') {
821 if ($message == 'signed') {
822 print '<span class="ok">'.$langs->trans("FichinterSigned").'</span>';
823 } else {
824 print '<input type="submit" class="butAction butActionSign small wraponsmartphone marginbottomonly marginleftonly marginrightonly reposition" value="'.$langs->trans("SignFichinter").'">';
825 }
826 } elseif ($source == 'expedition') {
827 if ($message == 'signed' || $object->signed_status == Expedition::$SIGNED_STATUSES['STATUS_SIGNED_SENDER']) {
828 print '<span class="ok">'.$langs->trans("ExpeditionSigned").'</span>';
829 } else {
830 print '<input type="submit" class="butAction butActionSign small wraponsmartphone marginbottomonly marginleftonly marginrightonly reposition" value="'.$langs->trans("SignExpedition").'">';
831 }
832 } else {
833 if ($message == 'signed') {
834 print '<span class="ok">'.$langs->trans(dol_ucfirst($source)."Signed").'</span>';
835 } else {
836 print '<input type="submit" class="butAction butActionSign small wraponsmartphone marginbottomonly marginleftonly marginrightonly reposition" value="'.$langs->trans("Sign".dol_ucfirst($source)).'">';
837 }
838 }
839}
840print '</td></tr>'."\n";
841print '</table>'."\n";
842
843print '</form>'."\n";
844print '</div>'."\n";
845print '<br>';
846
847
849
850llxFooter('', 'public');
851
852$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.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
dol_strtoupper($string, $encoding="UTF-8")
Convert a string to upper.
getDolCurrency()
Return the main currency ('EUR', 'USD', ...)
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,...