diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index 3bf5cf908a3..aa304daedb2 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -231,8 +231,8 @@ class CMailFile { global $conf, $dolibarr_main_data_root, $user; - dol_syslog("CMailFile::CMailfile: charset=".$conf->file->character_set_client." from=$from, to=$to, addr_cc=$addr_cc, addr_bcc=$addr_bcc, errors_to=$errors_to, replyto=$replyto trackid=$trackid sendcontext=$sendcontext"); - dol_syslog("CMailFile::CMailfile: subject=".$subject.", deliveryreceipt=".$deliveryreceipt.", msgishtml=".$msgishtml, LOG_DEBUG); + dol_syslog("CMailFile::CMailFile: charset=".$conf->file->character_set_client." from=$from, to=$to, addr_cc=$addr_cc, addr_bcc=$addr_bcc, errors_to=$errors_to, replyto=$replyto trackid=$trackid sendcontext=$sendcontext"); + dol_syslog("CMailFile::CMailFile: subject=".$subject.", deliveryreceipt=".$deliveryreceipt.", msgishtml=".$msgishtml, LOG_DEBUG); // Clean values of $mimefilename_list @@ -288,12 +288,12 @@ class CMailFile $this->alternative_boundary = 'mul_'.dol_hash(uniqid("dolibarr3"), '3'); // Force md5 hash (does not contain special chars) if (empty($subject)) { - dol_syslog("CMailFile::CMailfile: Try to send an email with empty subject"); + dol_syslog("CMailFile::CMailFile: Try to send an email with empty subject"); $this->error = 'ErrorSubjectIsRequired'; return; } if (empty($msg)) { - dol_syslog("CMailFile::CMailfile: Try to send an email with empty body"); + dol_syslog("CMailFile::CMailFile: Try to send an email with empty body"); $msg = '.'; // Avoid empty message (with empty message content, you will see a multipart structure) } @@ -320,7 +320,7 @@ class CMailFile if (getDolGlobalString('MAIN_MAIL_FORCE_CONTENT_TYPE_TO_HTML')) { $this->msgishtml = 1; // To force to send everything with content type html. } - dol_syslog("CMailFile::CMailfile: msgishtml=".$this->msgishtml, LOG_DEBUG); + dol_syslog("CMailFile::CMailFile: msgishtml=".$this->msgishtml, LOG_DEBUG); // Detect images if ($this->msgishtml) { @@ -338,7 +338,7 @@ class CMailFile } $findimg = $this->findHtmlImages($dolibarr_main_data_root_images.'/medias'); if ($findimg < 0) { - dol_syslog("CMailFile::CMailfile: Error on findHtmlImages"); + dol_syslog("CMailFile::CMailFile: Error on findHtmlImages"); $this->error = 'ErrorInAddAttachmentsImageBaseOnMedia'; return; } @@ -350,7 +350,7 @@ class CMailFile // It modifies ->html and complete ->html_images $resultImageData = $this->findHtmlImagesIsSrcData($upload_dir_tmp); if ($resultImageData < 0) { - dol_syslog("CMailFile::CMailfile: Error on findHtmlImagesInSrcData code=".$resultImageData." upload_dir_tmp=".$upload_dir_tmp); + dol_syslog("CMailFile::CMailFile: Error on findHtmlImagesInSrcData code=".$resultImageData." upload_dir_tmp=".$upload_dir_tmp); $this->error = 'ErrorInAddAttachmentsImageBaseIsSrcData'; return; } @@ -375,7 +375,7 @@ class CMailFile // We complete the array of cid_list $cid_list[$posindice] = $this->html_images[$i]['cid']; } - dol_syslog("CMailFile::CMailfile: html_images[$i]['name']=".$this->html_images[$i]['name'], LOG_DEBUG); + dol_syslog("CMailFile::CMailFile: html_images[$i]['name']=".$this->html_images[$i]['name'], LOG_DEBUG); } } } @@ -388,7 +388,7 @@ class CMailFile foreach ($filename_list as $i => $val) { if ($filename_list[$i]) { $this->atleastonefile = 1; - dol_syslog("CMailFile::CMailfile: filename_list[$i]=".$filename_list[$i].", mimetype_list[$i]=".$mimetype_list[$i]." mimefilename_list[$i]=".$mimefilename_list[$i]." cid_list[$i]=".(empty($cid_list[$i]) ? '' : $cid_list[$i]), LOG_DEBUG); + dol_syslog("CMailFile::CMailFile: filename_list[$i]=".$filename_list[$i].", mimetype_list[$i]=".$mimetype_list[$i]." mimefilename_list[$i]=".$mimefilename_list[$i]." cid_list[$i]=".(empty($cid_list[$i]) ? '' : $cid_list[$i]), LOG_DEBUG); } } } @@ -513,7 +513,7 @@ class CMailFile } } - dol_syslog("CMailFile::CMailfile: sendmode=".$this->sendmode." addr_bcc=$addr_bcc, replyto=$replyto", LOG_DEBUG); + dol_syslog("CMailFile::CMailFile: sendmode=".$this->sendmode." addr_bcc=$addr_bcc, replyto=$replyto", LOG_DEBUG); // We set all data according to chose sending method. // We also set a value for ->msgid @@ -2043,7 +2043,7 @@ class CMailFile /** * Search images into html message and init array this->images_encoded if found - * This is called in the CMailfile constructor but only if MAIN_MAIL_ADD_INLINE_IMAGES_IF_IN_MEDIAS is set (Off by default) + * This is called in the CMailFile constructor but only if MAIN_MAIL_ADD_INLINE_IMAGES_IF_IN_MEDIAS is set (Off by default) * * @param string $images_dir Path to store physical images files. For example $dolibarr_main_data_root.'/medias' * @return int >0 if OK, <0 if KO @@ -2131,7 +2131,7 @@ class CMailFile /** * Search images with src="data:image..." format into html message. * If we find some, we create them on disk. - * This is called in the CMailfile constructor. + * This is called in the CMailFile constructor. * * @param string $images_dir Location of where to store physically images files. For example $dolibarr_main_data_root.'/medias' * @return int >0 if OK, <0 if KO diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 8368a5f58cb..701a05d8046 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -4402,7 +4402,7 @@ function dol_print_email($email, $contactid = 0, $socid = 0, $addlink = 0, $max } $newemail .= ''; - include_once DOL_DOCUMENT_ROOT.'/core/class/CMailfile.class.php'; + include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; $emailonly = CMailFile::getValidAddress($email, 2); if ($showinvalid && !isValidEmail($emailonly)) { $langs->load("errors"); @@ -4434,7 +4434,7 @@ function dol_print_email($email, $contactid = 0, $socid = 0, $addlink = 0, $max } else { $newemail = ($withpicto ? img_picto($langs->trans("EMail") . ' : ' . $email, (is_numeric($withpicto) ? 'email' : $withpicto), 'class="paddingrightonly"') : '') . $newemail; - include_once DOL_DOCUMENT_ROOT.'/core/class/CMailfile.class.php'; + include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; $emailonly = CMailFile::getValidAddress($email, 2); if ($showinvalid && !isValidEmail($emailonly)) { $langs->load("errors"); diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 8d73144e3e3..3b3d33b3059 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -388,8 +388,6 @@ function pdfGetHeightForHtmlContent(&$pdf, $htmlcontent) */ function pdfBuildThirdpartyName($thirdparty, Translate $outputlangs, $includealias = 0) { - global $conf; - // Recipient name $socname = ''; @@ -421,7 +419,6 @@ function pdfBuildThirdpartyName($thirdparty, Translate $outputlangs, $includeali return $outputlangs->convToOutputCharset((string) $socname); } - /** * Return a string with full address formatted for output on PDF documents * @@ -769,6 +766,52 @@ function pdf_pagehead(&$pdf, $outputlangs, $page_height) } +/** + * Show header of page for PDF generation + * + * @param TCPDF $pdf Object PDF + * @param Translate $outputlangs Object lang for output + * @param float $page_height Height of page + * @param Facture $object Object invoice + * @param int $w Width for text + * @param int $posx Pos x + * @param int $posy Pos y + * @return void + */ +function pdfWriteBlockedLogSignature(&$pdf, $outputlangs, $page_height, $object, &$w, &$posx, &$posy) +{ + global $db; + + // Transaction ID + include_once DOL_DOCUMENT_ROOT.'/blockedlog/lib/blockedlog.lib.php'; + + if (isALNERunningVersion() && isModEnabled('blockedlog')) { + if ($object->status > $object::STATUS_DRAFT) { + $unalterablelogid = 'UNDEFINED'; + $sql = "SELECT signature FROM ".MAIN_DB_PREFIX."blockedlog"; + $sql .= " WHERE action = 'BILL_VALIDATE' AND element = 'facture' AND ref_object = '".$db->escape($object->ref)."'"; + $sql .= $db->order('rowid', 'DESC'); + $sql .= $db->plimit(1); + + $resql = $db->query($sql); + if ($resql) { + $obj = $db->fetch_object($resql); + if ($obj) { + $unalterablelogid = $obj->signature; + } + } + + if ($unalterablelogid != 'UNDEFINED') { + $posy += 5; + $pdf->SetXY($posx, $posy); + $pdf->SetTextColor(0, 0, 60); + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("SignatureID")." : ".dol_trunc(strtoupper($unalterablelogid), 10), '', 'R'); + } + } + } +} + + /** * Return array of possible substitutions for PDF content (without external module substitutions). * diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index 36b47b3f31c..680fef9806a 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -390,6 +390,7 @@ class pdf_crabe extends ModelePDFFactures // Do not take into account lines of the type “deposit.” $is_deposit = false; + $reg = array(); if (preg_match('/^\((.*)\)$/', $object->lines[$i]->desc, $reg)) { if ($reg[1] == 'DEPOSIT') { $is_deposit = true; @@ -2189,11 +2190,14 @@ class pdf_crabe extends ModelePDFFactures $pdf->MultiCell($w, 3, $title, '', 'R'); - $pdf->SetFont('', 'B', $default_font_size); + $pdf->SetFont('', '', $default_font_size - 2); + + pdfWriteBlockedLogSignature($pdf, $outputlangs, $this->page_hauteur, $object, $w, $posx, $posy); /* $posy += 5; $pdf->SetXY($posx, $posy); + $pdf->SetFont('', 'B', $default_font_size); $pdf->SetTextColor(0, 0, 60); $textref = $outputlangs->transnoentities("Ref")." : ".$outputlangs->convToOutputCharset($object->ref); if ($object->status == $object::STATUS_DRAFT) { diff --git a/htdocs/core/modules/facture/doc/pdf_octopus.modules.php b/htdocs/core/modules/facture/doc/pdf_octopus.modules.php index 7443564a9c8..71e3a6dba65 100644 --- a/htdocs/core/modules/facture/doc/pdf_octopus.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_octopus.modules.php @@ -2402,7 +2402,6 @@ class pdf_octopus extends ModelePDFFactures $pdf->SetFont('', 'B', $default_font_size + 3); $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $subtitle = ""; $title = $outputlangs->transnoentities("PdfInvoiceTitle"); if ($object->type == 1) { $title = $outputlangs->transnoentities("InvoiceReplacement"); @@ -2418,8 +2417,7 @@ class pdf_octopus extends ModelePDFFactures } if ($this->situationinvoice) { $outputlangs->loadLangs(array("other")); - $title = $outputlangs->transnoentities("PDFInvoiceSituation"); - $subtitle = $outputlangs->transnoentities("PDFSituationTitle", (string) $object->situation_counter); + $title = $outputlangs->transnoentities("PDFInvoiceSituation") . " (#".((int) $object->situation_counter).")"; } if (getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) { $title .= ' - '; @@ -2445,25 +2443,22 @@ class pdf_octopus extends ModelePDFFactures } $pdf->MultiCell($w, 3, $title, '', 'R'); - if (!empty($subtitle)) { - $pdf->SetFont('', 'B', $default_font_size); - $pdf->SetXY($posx, $posy + 5); - $pdf->MultiCell($w, 6, $subtitle, '', 'R'); - $posy += 2; - } - $pdf->SetFont('', 'B', $default_font_size); + $pdf->SetFont('', '', $default_font_size - 2); + + pdfWriteBlockedLogSignature($pdf, $outputlangs, $this->page_hauteur, $object, $w, $posx, $posy); /* - $posy += 5; - $pdf->SetXY($posx, $posy); - $pdf->SetTextColor(0, 0, 60); - $textref = $outputlangs->transnoentities("Ref")." : ".$outputlangs->convToOutputCharset($object->ref); - if ($object->status == $object::STATUS_DRAFT) { - $pdf->SetTextColor(128, 0, 0); - $textref .= ' - '.$outputlangs->transnoentities("NotValidated"); - } - $pdf->MultiCell($w, 4, $textref, '', 'R');*/ + $posy += 5; + $pdf->SetXY($posx, $posy); + $pdf->SetTextColor(0, 0, 60); + $pdf->SetFont('', 'B', $default_font_size); + $textref = $outputlangs->transnoentities("Ref")." : ".$outputlangs->convToOutputCharset($object->ref); + if ($object->status == $object::STATUS_DRAFT) { + $pdf->SetTextColor(128, 0, 0); + $textref .= ' - '.$outputlangs->transnoentities("NotValidated"); + } + $pdf->MultiCell($w, 4, $textref, '', 'R');*/ $posy += 3; $pdf->SetFont('', '', $default_font_size - 2); diff --git a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php index 971c4d6872f..cc2ffaafb47 100644 --- a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php @@ -2542,18 +2542,21 @@ class pdf_sponge extends ModelePDFFactures $posy += 2; } - $pdf->SetFont('', 'B', $default_font_size); + $pdf->SetFont('', '', $default_font_size - 2); + + pdfWriteBlockedLogSignature($pdf, $outputlangs, $this->page_hauteur, $object, $w, $posx, $posy); /* - $posy += 5; - $pdf->SetXY($posx, $posy); - $pdf->SetTextColor(0, 0, 60); - $textref = $outputlangs->transnoentities("Ref")." : ".$outputlangs->convToOutputCharset($object->ref); - if ($object->status == $object::STATUS_DRAFT) { - $pdf->SetTextColor(128, 0, 0); - $textref .= ' - '.$outputlangs->transnoentities("NotValidated"); - } - $pdf->MultiCell($w, 4, $textref, '', 'R');*/ + $posy += 5; + $pdf->SetXY($posx, $posy); + $pdf->SetTextColor(0, 0, 60); + $pdf->SetFont('', 'B', $default_font_size); + $textref = $outputlangs->transnoentities("Ref")." : ".$outputlangs->convToOutputCharset($object->ref); + if ($object->status == $object::STATUS_DRAFT) { + $pdf->SetTextColor(128, 0, 0); + $textref .= ' - '.$outputlangs->transnoentities("NotValidated"); + } + $pdf->MultiCell($w, 4, $textref, '', 'R');*/ $posy += 3; $pdf->SetFont('', '', $default_font_size - 2); diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index cdd9e4894b7..9a2230482d6 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -709,7 +709,7 @@ Module2700Desc=Use online Gravatar service (www.gravatar.com) to show photo of u Module2800Desc=FTP Client Module2900Name=GeoIPMaxmind Module2900Desc=GeoIP Maxmind conversions capabilities -Module3200Name=Unalterable Archives +Module3200Name=Unalterable Logs and Archives Module3200Desc=Enable an unalterable log of business events. Events are archived in real-time. The log is a read-only table of chained events that can be exported. This module may be mandatory for some countries. Module3300Name=Module Builder Module3300Desc=A RAD (Rapid Application Development - low-code and no-code) tool to help developers or advanced users to build their own module/application. @@ -1034,7 +1034,7 @@ Permission2515=Setup documents directories Permission2610=Generate/modify users API key Permission2801=Use FTP client in read mode (browse and download only) Permission2802=Use FTP client in write mode (delete or upload files) -Permission3201=Read archived events and fingerprints +Permission3201=Read Unalterable Logs and signature Permission3301=Generate new modules Permission4001=Read skill/job/position Permission4002=Create/modify skill/job/position diff --git a/htdocs/langs/en_US/cashdesk.lang b/htdocs/langs/en_US/cashdesk.lang index 127fbdccad2..6953aa32c96 100644 --- a/htdocs/langs/en_US/cashdesk.lang +++ b/htdocs/langs/en_US/cashdesk.lang @@ -172,7 +172,6 @@ PrintOn=Print on printer %s SentToPrinter=Sent to printer FailedToSendToPrinter=Failed to send to printer TemporaryReceipt=Temporary -SignatureID=Signature ID CashRegisterAlertFR=Warning: According to French law, when using a Point Of Sale system, you must make a cash control every day, every month and every year. Cash controls are done manually from the menu %s - %s. CashRegisterAlertFR2=Every cash control is recorded into the Unalterable Log. KitchenPrinter=Kitchen printer diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index c7daa5bb7ec..d833a66116d 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -1411,3 +1411,4 @@ AddThisPageToBookmarks = Add current page to bookmarks EditBookmarks = List/edit bookmarks Why=Why since=since +SignatureID=Signature diff --git a/htdocs/takepos/receipt.php b/htdocs/takepos/receipt.php index 8bafe0addf3..d7624fc7f2b 100644 --- a/htdocs/takepos/receipt.php +++ b/htdocs/takepos/receipt.php @@ -261,7 +261,7 @@ if (isALNERunningVersion() || !getDolGlobalString('TAKEPOS_HIDE_DATE_OF_PRINTING } // Transaction ID if (isALNERunningVersion() && isModEnabled('blockedlog')) { - if ($object->status == $object::STATUS_CLOSED) { + if ($object->status > $object::STATUS_DRAFT) { $unalterablelogid = 'UNDEFINED'; $sql = "SELECT signature FROM ".MAIN_DB_PREFIX."blockedlog"; $sql .= " WHERE action = 'BILL_VALIDATE' AND element = 'facture' AND ref_object = '".$db->escape($object->ref)."'"; @@ -377,7 +377,7 @@ if ($object->status == $object::STATUS_CLOSED) { if (getDolGlobalString('TAKEPOS_TICKET_VAT_GROUPPED')) { $vat_groups = array(); foreach ($object->lines as $line) { - if (!array_key_exists($line->tva_tx, $vat_groups)) { + if (!array_key_exists((string) $line->tva_tx, $vat_groups)) { $vat_groups[(string) $line->tva_tx] = 0; } $vat_groups[(string) $line->tva_tx] += $line->total_tva;