diff --git a/htdocs/admin/mails_senderprofile_list.php b/htdocs/admin/mails_senderprofile_list.php
index 95f57d5dfc5..a73b899dd00 100644
--- a/htdocs/admin/mails_senderprofile_list.php
+++ b/htdocs/admin/mails_senderprofile_list.php
@@ -416,7 +416,7 @@ if ($action != 'create') {
print '
| '.$langs->trans("Signature").' | ';
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
$doleditor = new DolEditor('signature', GETPOST('signature'), '', 138, 'dolibarr_notes', 'In', true, true, empty($conf->global->FCKEDITOR_ENABLE_USERSIGN) ? 0 : 1, ROWS_4, '90%');
diff --git a/htdocs/compta/paiement/card.php b/htdocs/compta/paiement/card.php
index 073365fa876..7c68a443feb 100644
--- a/htdocs/compta/paiement/card.php
+++ b/htdocs/compta/paiement/card.php
@@ -46,6 +46,11 @@ $action = GETPOST('action', 'aZ09');
$confirm = GETPOST('confirm', 'alpha');
$backtopage = GETPOST('backtopage', 'alpha');
+$socid = GETPOST('socid', 'int');
+if ($socid < 0) {
+ $socid = 0;
+}
+
$object = new Paiement($db);
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager->initHooks(array('paymentcard', 'globalcard'));
diff --git a/htdocs/compta/paiement/list.php b/htdocs/compta/paiement/list.php
index 658f2c150f1..6db18f6aa55 100644
--- a/htdocs/compta/paiement/list.php
+++ b/htdocs/compta/paiement/list.php
@@ -513,6 +513,7 @@ foreach ($arrayfields as $column) {
$i = 0;
$totalarray = array();
+$totalarray['nbfield'] = 0;
while ($i < min($num, $limit)) {
$objp = $db->fetch_object($resql);
@@ -620,7 +621,11 @@ while ($i < min($num, $limit)) {
$totalarray['nbfield']++;
}
$totalarray['pos'][$checkedCount] = 'amount';
- $totalarray['val']['amount'] += $objp->amount;
+ if (empty($totalarray['val']['amount'])) {
+ $totalarray['val']['amount'] = $objp->amount;
+ } else {
+ $totalarray['val']['amount'] += $objp->amount;
+ }
}
// Status
diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php
index b4eddcc252f..9d18fccf423 100644
--- a/htdocs/core/class/commondocgenerator.class.php
+++ b/htdocs/core/class/commondocgenerator.class.php
@@ -1279,7 +1279,7 @@ abstract class CommonDocGenerator
$extrafieldOptionsKey = $extrafieldsKeyPrefix.$extrafieldKey;
- // Load extrafiels if not allready does
+ // Load extra fields if they haven't been loaded already.
if (empty($this->extrafieldsCache)) {
$this->extrafieldsCache = new ExtraFields($this->db);
}
@@ -1605,7 +1605,7 @@ abstract class CommonDocGenerator
return 0;
}
- // Load extrafiels if not allready does
+ // Load extra fields if they haven't been loaded already.
if (empty($this->extrafieldsCache)) {
$this->extrafieldsCache = new ExtraFields($this->db);
}
@@ -1615,7 +1615,7 @@ abstract class CommonDocGenerator
$extrafields = $this->extrafieldsCache;
- if (!empty($extrafields->attributes[$object->table_element]) && is_array($extrafields->attributes[$object->table_element]['label'])) {
+ if (!empty($extrafields->attributes[$object->table_element]) && is_array($extrafields->attributes[$object->table_element]) && array_key_exists('label', $extrafields->attributes[$object->table_element]) && is_array($extrafields->attributes[$object->table_element]['label'])) {
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $label) {
// Dont display separator yet even is set to be displayed (not compatible yet)
if ($extrafields->attributes[$object->table_element]['type'][$key] == 'separate') {
diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php
index d1eb324cc7f..dd0ec988062 100644
--- a/htdocs/core/class/commoninvoice.class.php
+++ b/htdocs/core/class/commoninvoice.class.php
@@ -332,6 +332,7 @@ abstract class CommonInvoice extends CommonObject
$field = 'fk_facture';
$field2 = 'fk_paiement';
$field3 = ', p.ref_ext';
+ $field4 = ', p.fk_bank'; // Bank line id
$sharedentity = 'facture';
if ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier') {
$table = 'paiementfourn_facturefourn';
@@ -342,7 +343,7 @@ abstract class CommonInvoice extends CommonObject
$sharedentity = 'facture_fourn';
}
- $sql = "SELECT p.ref, pf.amount, pf.multicurrency_amount, p.fk_paiement, p.datep, p.num_paiement as num, t.code".$field3;
+ $sql = "SELECT p.ref, pf.amount, pf.multicurrency_amount, p.fk_paiement, p.datep, p.num_paiement as num, t.code".$field3 . $field4;
$sql .= " FROM ".$this->db->prefix().$table." as pf, ".$this->db->prefix().$table2." as p, ".$this->db->prefix()."c_paiement as t";
$sql .= " WHERE pf.".$field." = ".((int) $this->id);
$sql .= " AND pf.".$field2." = p.rowid";
@@ -363,6 +364,9 @@ abstract class CommonInvoice extends CommonObject
if (!empty($field3)) {
$tmp['ref_ext'] = $obj->ref_ext;
}
+ if (!empty($field4)) {
+ $tmp['fk_bank_line'] = $obj->fk_bank;
+ }
$retarray[] = $tmp;
$i++;
}
diff --git a/htdocs/core/modules/product/doc/pdf_standard.modules.php b/htdocs/core/modules/product/doc/pdf_standard.modules.php
index 8baef2ffa75..c8190a362f5 100644
--- a/htdocs/core/modules/product/doc/pdf_standard.modules.php
+++ b/htdocs/core/modules/product/doc/pdf_standard.modules.php
@@ -1,5 +1,6 @@
+/* Copyright (C) 2017 Laurent Destailleur
+ * Copyright (C) 2023 Anthony Berton
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -209,10 +210,10 @@ class pdf_standard extends ModelePDFProduct
$pdf->SetDrawColor(128, 128, 128);
$pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
- $pdf->SetSubject($outputlangs->transnoentities("Order"));
+ $pdf->SetSubject($outputlangs->transnoentities("Product"));
$pdf->SetCreator("Dolibarr ".DOL_VERSION);
$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
- $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Order")." ".$outputlangs->convToOutputCharset($object->thirdparty->name));
+ $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Product"));
if (getDolGlobalString('MAIN_DISABLE_PDF_COMPRESSION')) {
$pdf->SetCompression(false);
}
@@ -242,6 +243,53 @@ class pdf_standard extends ModelePDFProduct
$pdf->writeHTMLCell(190, 3, $this->marge_gauche, $tab_top, dol_htmlentitiesbr($object->label), 0, 1);
$nexY = $pdf->GetY();
+ // Show photo
+ if (getDolGlobalInt('PRODUCT_USE_OLD_PATH_FOR_PHOTO')) {
+ $pdir[0] = get_exdir($object->id, 2, 0, 0, $object, 'product').$object->id."/photos/";
+ $pdir[1] = get_exdir(0, 0, 0, 0, $object, 'product').dol_sanitizeFileName($object->ref).'/';
+ } else {
+ $pdir[0] = get_exdir(0, 0, 0, 0, $object, 'product'); // default
+ $pdir[1] = get_exdir($object->id, 2, 0, 0, $object, 'product').$object->id."/photos/"; // alternative
+ }
+
+ $arephoto = false;
+ foreach ($pdir as $midir) {
+ if (!$arephoto) {
+ if ($conf->entity != $object->entity) {
+ $dir = $conf->product->multidir_output[$object->entity].'/'.$midir; //Check repertories of current entities
+ } else {
+ $dir = $conf->product->dir_output.'/'.$midir; //Check repertory of the current product
+ }
+ foreach ($object->liste_photos($dir, 1) as $key => $obj) {
+ if (!getDolGlobalInt('CAT_HIGH_QUALITY_IMAGES')) { // If CAT_HIGH_QUALITY_IMAGES not defined, we use thumb if defined and then original photo
+ if ($obj['photo_vignette']) {
+ $filename = $obj['photo_vignette'];
+ } else {
+ $filename = $obj['photo'];
+ }
+ } else {
+ $filename = $obj['photo'];
+ }
+ $realpath = $dir.$filename;
+ $arephoto = true;
+ }
+ }
+ }
+ // Define size of image if we need it
+ $imglinesize = array();
+ if (!empty($realpath) && $arephoto) {
+ $imgsize = pdf_getSizeForImage($realpath);
+ $imgsizewidth = $imgsize['width'] + 20;
+ $imgsizeheight = $imgsize['height'] + 20;
+
+ $midelpage = ($this->page_largeur - $this->marge_gauche - $this->marge_droite) / 2;
+ $posxphoto = $midelpage + ($midelpage / 2) - ($imgsizewidth / 2);
+ $posyphoto = $tab_top - 1;
+ $pdf->Image($realpath, $posxphoto, $posyphoto, $imgsizewidth, $imgsizeheight, '', '', '', 2, 300); // Use 300 dpi
+ $nexyafterphoto = $tab_top + $imgsizeheight;
+ }
+
+ // Description
$pdf->SetFont('', '', $default_font_size);
$pdf->writeHTMLCell(190, 3, $this->marge_gauche, $nexY, dol_htmlentitiesbr($object->description), 0, 1);
$nexY = $pdf->GetY();
@@ -276,30 +324,22 @@ class pdf_standard extends ModelePDFProduct
$nexY = $pdf->GetY();
}
+ $tab_top = 88;
+ if (!empty($nexyafterphoto) && $nexyafterphoto > $tab_top) {
+ $tab_top = $nexyafterphoto;
+ }
+
// Show notes
// TODO There is no public note on product yet
$notetoshow = empty($object->note_public) ? '' : $object->note_public;
- if (!empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE)) {
- // Get first sale rep
- if (is_object($object->thirdparty)) {
- $salereparray = $object->thirdparty->getSalesRepresentatives($user);
- $salerepobj = new User($this->db);
- $salerepobj->fetch($salereparray[0]['id']);
- if (!empty($salerepobj->signature)) {
- $notetoshow = dol_concatdesc($notetoshow, $salerepobj->signature);
- }
- }
- }
if ($notetoshow) {
$substitutionarray = pdf_getSubstitutionArray($outputlangs, null, $object);
complete_substitutions_array($substitutionarray, $outputlangs, $object);
$notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs);
$notetoshow = convertBackOfficeMediasLinksToPublicLinks($notetoshow);
- $tab_top = 88;
-
$pdf->SetFont('', '', $default_font_size - 1);
- $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
+ $pdf->writeHTMLCell(190, 3, $this->marge_gauche - 1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
$nexY = $pdf->GetY();
$height_note = $nexY - $tab_top;
@@ -673,6 +713,9 @@ class pdf_standard extends ModelePDFProduct
{
global $conf, $langs, $hookmanager;
+ $ltrdirection = 'L';
+ if ($outputlangs->trans("DIRECTION") == 'rtl') $ltrdirection = 'R';
+
// Load traductions files required by page
$outputlangs->loadLangs(array("main", "propal", "companies", "bills", "orders"));
@@ -687,35 +730,48 @@ class pdf_standard extends ModelePDFProduct
pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
// Show Draft Watermark
- if ($object->statut == 0 && getDolGlobalString('COMMANDE_DRAFT_WATERMARK')) {
+ if ($object->statut == 0 && getDolGlobalString('PRODUCT_DRAFT_WATERMARK')) {
pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', getDolGlobalString('COMMANDE_DRAFT_WATERMARK'));
}
$pdf->SetTextColor(0, 0, 60);
$pdf->SetFont('', 'B', $default_font_size + 3);
+ $w = 100;
+
$posy = $this->marge_haute;
$posx = $this->page_largeur - $this->marge_droite - 100;
$pdf->SetXY($this->marge_gauche, $posy);
// Logo
- $logo = $conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
- if ($this->emetteur->logo) {
- if (is_readable($logo)) {
- $height = pdf_getHeightForLogo($logo);
- $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
+ if (!getDolGlobalInt('PDF_DISABLE_MYCOMPANY_LOGO')) {
+ if ($this->emetteur->logo) {
+ $logodir = $conf->mycompany->dir_output;
+ if (!empty($conf->mycompany->multidir_output[$object->entity])) {
+ $logodir = $conf->mycompany->multidir_output[$object->entity];
+ }
+ if (!getDolGlobalInt('MAIN_PDF_USE_LARGE_LOGO')) {
+ $logo = $logodir.'/logos/thumbs/'.$this->emetteur->logo_small;
+ } else {
+ $logo = $logodir.'/logos/'.$this->emetteur->logo;
+ }
+ if (is_readable($logo)) {
+ $height = pdf_getHeightForLogo($logo);
+ $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
+ } else {
+ $pdf->SetTextColor(200, 0, 0);
+ $pdf->SetFont('', 'B', $default_font_size - 2);
+ $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
+ $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
+ }
} else {
- $pdf->SetTextColor(200, 0, 0);
- $pdf->SetFont('', 'B', $default_font_size - 2);
- $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
- $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
+ $text = $this->emetteur->name;
+ $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, $ltrdirection);
}
- } else {
- $text = $this->emetteur->name;
- $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
}
+
$pdf->SetFont('', 'B', $default_font_size + 3);
$pdf->SetXY($posx, $posy);
$pdf->SetTextColor(0, 0, 60);
diff --git a/htdocs/includes/tcpdi/tcpdi_parser.php b/htdocs/includes/tcpdi/tcpdi_parser.php
index 13e9839f2b4..6d3cf789b6a 100644
--- a/htdocs/includes/tcpdi/tcpdi_parser.php
+++ b/htdocs/includes/tcpdi/tcpdi_parser.php
@@ -1373,7 +1373,7 @@ class tcpdi_parser {
return false;
} else {
$res = $this->_getPageRotation($obj[1][1]['/Parent']);
- if ($res[0] == PDF_TYPE_OBJECT)
+ if ($res && $res[0] == PDF_TYPE_OBJECT)
return $res[1];
return $res;
}
diff --git a/htdocs/langs/en_US/companies.lang b/htdocs/langs/en_US/companies.lang
index 911ba31bc25..e17c7bcb90e 100644
--- a/htdocs/langs/en_US/companies.lang
+++ b/htdocs/langs/en_US/companies.lang
@@ -503,3 +503,4 @@ TwoRecordsOfCompanyName=more than one record exists for this company, please con
CompanySection=Company section
ShowSocialNetworks=Show social networks
HideSocialNetworks=Hide social networks
+
diff --git a/htdocs/product/card.php b/htdocs/product/card.php
index ac465b16bd7..ba1bc47046f 100644
--- a/htdocs/product/card.php
+++ b/htdocs/product/card.php
@@ -93,7 +93,11 @@ $refalreadyexists = 0;
// Get parameters
$id = GETPOST('id', 'int');
-$ref = (GETPOSTISSET('ref') ? GETPOST('ref', 'alpha') : null);
+if (!empty($conf->global->MAIN_SECURITY_ALLOW_UNSECURED_REF_LABELS)) {
+ $ref = (GETPOSTISSET('ref') ? GETPOST('ref', 'nohtml') : null);
+} else {
+ $ref = (GETPOSTISSET('ref') ? GETPOST('ref', 'alpha') : null);
+}
$type = (GETPOSTISSET('type') ? GETPOST('type', 'int') : Product::TYPE_PRODUCT);
$action = (GETPOST('action', 'alpha') ? GETPOST('action', 'alpha') : 'view');
$cancel = GETPOST('cancel', 'alpha');
@@ -113,7 +117,11 @@ $accountancy_code_buy_export = GETPOST('accountancy_code_buy_export', 'alpha');
$checkmandatory = GETPOST('accountancy_code_buy_export', 'alpha');
// by default 'alphanohtml' (better security); hidden conf MAIN_SECURITY_ALLOW_UNSECURED_LABELS_WITH_HTML allows basic html
-$label_security_check = empty($conf->global->MAIN_SECURITY_ALLOW_UNSECURED_LABELS_WITH_HTML) ? 'alphanohtml' : 'restricthtml';
+if (!empty($conf->global->MAIN_SECURITY_ALLOW_UNSECURED_REF_LABELS)) {
+ $label_security_check = 'nohtml';
+} else {
+ $label_security_check = empty($conf->global->MAIN_SECURITY_ALLOW_UNSECURED_LABELS_WITH_HTML) ? 'alphanohtml' : 'restricthtml';
+}
if (!empty($user->socid)) {
$socid = $user->socid;
diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php
index 2a1ac8dc932..60de90d819d 100644
--- a/htdocs/product/class/product.class.php
+++ b/htdocs/product/class/product.class.php
@@ -572,7 +572,11 @@ class Product extends CommonObject
*/
public function check()
{
- $this->ref = dol_sanitizeFileName(stripslashes($this->ref));
+ if (!empty($conf->global->MAIN_SECURITY_ALLOW_UNSECURED_REF_LABELS)) {
+ $this->ref = trim($this->ref);
+ } else {
+ $this->ref = dol_sanitizeFileName(stripslashes($this->ref));
+ }
$err = 0;
if (dol_strlen(trim($this->ref)) == 0) {
@@ -604,7 +608,11 @@ class Product extends CommonObject
$error = 0;
// Clean parameters
- $this->ref = dol_sanitizeFileName(dol_string_nospecial(trim($this->ref)));
+ if (!empty($conf->global->MAIN_SECURITY_ALLOW_UNSECURED_REF_LABELS)) {
+ $this->ref = trim($this->ref);
+ } else {
+ $this->ref = dol_sanitizeFileName(dol_string_nospecial(trim($this->ref)));
+ }
$this->label = trim($this->label);
$this->price_ttc = price2num($this->price_ttc);
$this->price = price2num($this->price);
@@ -999,7 +1007,11 @@ class Product extends CommonObject
}
// Clean parameters
- $this->ref = dol_string_nospecial(trim($this->ref));
+ if (!empty($conf->global->MAIN_SECURITY_ALLOW_UNSECURED_REF_LABELS)) {
+ $this->ref = trim($this->ref);
+ } else {
+ $this->ref = dol_string_nospecial(trim($this->ref));
+ }
$this->label = trim($this->label);
$this->description = trim($this->description);
$this->note_private = (isset($this->note_private) ? trim($this->note_private) : null);
diff --git a/htdocs/public/onlinesign/newonlinesign.php b/htdocs/public/onlinesign/newonlinesign.php
index c47bbd7f734..cd793a91bfc 100644
--- a/htdocs/public/onlinesign/newonlinesign.php
+++ b/htdocs/public/onlinesign/newonlinesign.php
@@ -2,6 +2,7 @@
/* Copyright (C) 2001-2002 Rodolphe Quiedeville
* Copyright (C) 2006-2017 Laurent Destailleur
* Copyright (C) 2009-2012 Regis Houssin
+ * Copyright (C) 2023 anthony Berton
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -156,6 +157,8 @@ if ($source == 'proposal') {
httponly_accessforbidden($langs->trans('ErrorBadParameters')." - Bad value for source", 400, 1);
}
+// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
+$hookmanager->initHooks(array('onlinesign'));
/*
* Actions
@@ -346,10 +349,21 @@ if ($source == 'proposal') {
print ' |
'."\n";
// Amount
- print '