Merge branch '20.0' of git@github.com:Dolibarr/dolibarr.git into 20.0

This commit is contained in:
Laurent Destailleur 2025-01-10 15:18:57 +01:00
commit be936243df
18 changed files with 71 additions and 120 deletions

View file

@ -441,7 +441,7 @@ WARNING:
--------
The following changes may create regressions for some external modules, but were necessary to make Dolibarr better:
* If a filter is defined into and extrafields "Select from a table", this filter MUST use the Universai Search Filter syntax (field:=:value) instead of field=value.
* If a filter is defined into an extrafield, this filter MUST use the Universai Search Filter syntax (field:=:value) instead of th eunsecured SQL code field=value.
See https://wiki.dolibarr.org/index.php?title=Universal_Search_Filter_Syntax
* The parameter $filter of methods fetchAll() does not accept array of SQL commands but must be a string of an Universal Search Filter syntax.
See https://wiki.dolibarr.org/index.php?title=Universal_Search_Filter_Syntax

View file

@ -393,100 +393,6 @@ LOCK TABLES `llx_adherent_type_extrafields` WRITE;
/*!40000 ALTER TABLE `llx_adherent_type_extrafields` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `llx_advanced_extrafields`
--
DROP TABLE IF EXISTS `llx_advanced_extrafields`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `llx_advanced_extrafields` (
`rowid` int(11) NOT NULL AUTO_INCREMENT,
`tms` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`entity` int(11) NOT NULL DEFAULT '1',
`elementtype` varchar(64) NOT NULL,
`name` varchar(64) NOT NULL,
`label` varchar(64) NOT NULL,
`format` varchar(8) NOT NULL,
`fieldsize` int(11) DEFAULT NULL,
`maxlength` int(11) DEFAULT NULL,
`options` varchar(255) DEFAULT NULL,
`rang` int(11) DEFAULT NULL,
PRIMARY KEY (`rowid`),
UNIQUE KEY `idx_advanced_extrafields_name` (`elementtype`,`entity`,`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `llx_advanced_extrafields`
--
LOCK TABLES `llx_advanced_extrafields` WRITE;
/*!40000 ALTER TABLE `llx_advanced_extrafields` DISABLE KEYS */;
/*!40000 ALTER TABLE `llx_advanced_extrafields` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `llx_advanced_extrafields_options`
--
DROP TABLE IF EXISTS `llx_advanced_extrafields_options`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `llx_advanced_extrafields_options` (
`rowid` int(11) NOT NULL AUTO_INCREMENT,
`tms` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`fk_extrafields` int(11) NOT NULL,
`value` varchar(255) NOT NULL,
`rang` int(11) DEFAULT NULL,
PRIMARY KEY (`rowid`),
KEY `idx_advanced_extrafields_options_fk_advanced_extrafields` (`fk_extrafields`),
CONSTRAINT `fk_advanced_extrafields_options_fk_advanced_extrafields` FOREIGN KEY (`fk_extrafields`) REFERENCES `llx_advanced_extrafields` (`rowid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `llx_advanced_extrafields_options`
--
LOCK TABLES `llx_advanced_extrafields_options` WRITE;
/*!40000 ALTER TABLE `llx_advanced_extrafields_options` DISABLE KEYS */;
/*!40000 ALTER TABLE `llx_advanced_extrafields_options` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `llx_advanced_extrafields_values`
--
DROP TABLE IF EXISTS `llx_advanced_extrafields_values`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `llx_advanced_extrafields_values` (
`rowid` int(11) NOT NULL AUTO_INCREMENT,
`tms` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`entity` int(11) NOT NULL DEFAULT '1',
`datec` datetime DEFAULT NULL,
`datem` datetime DEFAULT NULL,
`fk_element` int(11) NOT NULL,
`fk_extrafields` int(11) NOT NULL,
`value` varchar(255) DEFAULT NULL,
`fk_user_create` int(11) DEFAULT NULL,
`fk_user_modif` int(11) DEFAULT NULL,
PRIMARY KEY (`rowid`),
KEY `idx_advanced_extrafields_values_fk_advanced_extrafields` (`fk_extrafields`,`entity`),
CONSTRAINT `fk_advanced_extrafields_values_fk_advanced_extrafields` FOREIGN KEY (`fk_extrafields`) REFERENCES `llx_advanced_extrafields` (`rowid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `llx_advanced_extrafields_values`
--
LOCK TABLES `llx_advanced_extrafields_values` WRITE;
/*!40000 ALTER TABLE `llx_advanced_extrafields_values` DISABLE KEYS */;
/*!40000 ALTER TABLE `llx_advanced_extrafields_values` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `llx_bank`
--

View file

@ -450,6 +450,10 @@ if ($resql) {
print '<br>';
$parameters = array('chartofaccounts' => $chartofaccounts, 'permissiontoadd' => $permissiontoadd, 'permissiontodelete' => $permissiontodelete);
$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $accounting, $action); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;

View file

@ -2873,7 +2873,7 @@ if (empty($reshook)) {
$percent = $line->get_prev_progress($object->id);
}
if ((float) $all_progress < (float) $percent) {
$mesg = $langs->trans("Line").' '.$i.' : '.$langs->trans("CantBeLessThanMinPercent");
$mesg = $langs->trans("Line").' '.$line->rang.' : '.$langs->trans("CantBeLessThanMinPercent");
setEventMessages($mesg, null, 'warnings');
$result = -1;
} else {

View file

@ -444,7 +444,7 @@ if (isModEnabled('don') && $user->hasRight('don', 'lire')) {
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<th colspan="2">'.$langs->trans("BoxTitleLastModifiedDonations", $max);
print '<a href="'.DOL_URL_ROOT.'/don/list.php?sortfield=f.tms&sortorder=desc"><span class="badge marginleftonly">...</span></a>';
print '<a href="'.DOL_URL_ROOT.'/don/list.php?sortfield=d.tms&sortorder=desc"><span class="badge marginleftonly">...</span></a>';
print '</th>';
print '<th class="right">'.$langs->trans("AmountTTC").'</th>';
print '<th class="right">'.$langs->trans("DateModificationShort").'</th>';

View file

@ -1087,7 +1087,7 @@ function purgeSessions($mysessionid)
$sessValues = file_get_contents($fullpath); // get raw session data
if (preg_match('/dol_login/i', $sessValues) && // limit to dolibarr session
preg_match('/dol_entity\|s:([0-9]+):"('.$conf->entity.')"/i', $sessValues) && // limit to current entity
(preg_match('/dol_entity\|i:('.$conf->entity.')/', $sessValues) || preg_match('/dol_entity\|s:([0-9]+):"('.$conf->entity.')"/i', $sessValues)) && // limit to current entity
preg_match('/dol_company\|s:([0-9]+):"(' . getDolGlobalString('MAIN_INFO_SOCIETE_NOM').')"/i', $sessValues)) { // limit to company name
$tmp = explode('_', $file);
$idsess = $tmp[1];

View file

@ -231,7 +231,11 @@ class pdf_standard_asset extends ModelePDFAsset
// Set path to the background PDF File
if (getDolGlobalString('MAIN_ADD_PDF_BACKGROUND')) {
$pagecount = $pdf->setSourceFile($conf->mycompany->multidir_output[$object->entity].'/' . getDolGlobalString('MAIN_ADD_PDF_BACKGROUND'));
$logodir = $conf->mycompany->dir_output;
if (!empty($conf->mycompany->multidir_output[$object->entity])) {
$logodir = $conf->mycompany->multidir_output[$object->entity];
}
$pagecount = $pdf->setSourceFile($logodir .'/' . getDolGlobalString('MAIN_ADD_PDF_BACKGROUND'));
$tplidx = $pdf->importPage(1);
}

View file

@ -57,7 +57,7 @@ class mod_commande_marbre extends ModeleNumRefCommandes
{
global $conf, $mysoc;
if ((float) $conf->global->MAIN_VERSION_LAST_INSTALL >= 16.0 && $mysoc->country_code != 'FR') {
if ((float) getDolGlobalString('MAIN_VERSION_LAST_INSTALL') >= 16.0 && $mysoc->country_code != 'FR') {
$this->prefix = 'SO'; // We use correct standard code "SO = Sale Order"
}
}

View file

@ -282,7 +282,11 @@ class pdf_eagle_proforma extends ModelePDFStockTransfer
$pdf->SetFont(pdf_getPDFFont($outputlangs));
// Set path to the background PDF File
if (!getDolGlobalString('MAIN_DISABLE_FPDI') && getDolGlobalString('MAIN_ADD_PDF_BACKGROUND')) {
$pagecount = $pdf->setSourceFile($conf->mycompany->multidir_output[$object->entity].'/' . getDolGlobalString('MAIN_ADD_PDF_BACKGROUND'));
$logodir = $conf->mycompany->dir_output;
if (!empty($conf->mycompany->multidir_output[$object->entity])) {
$logodir = $conf->mycompany->multidir_output[$object->entity];
}
$pagecount = $pdf->setSourceFile($logodir .'/' . getDolGlobalString('MAIN_ADD_PDF_BACKGROUND'));
$tplidx = $pdf->importPage(1);
}

View file

@ -251,7 +251,11 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
$pdf->SetFont(pdf_getPDFFont($outputlangs));
// Set path to the background PDF File
if (getDolGlobalString('MAIN_ADD_PDF_BACKGROUND')) {
$pagecount = $pdf->setSourceFile($conf->mycompany->multidir_output[$object->entity].'/' . getDolGlobalString('MAIN_ADD_PDF_BACKGROUND'));
$logodir = $conf->mycompany->dir_output;
if (!empty($conf->mycompany->multidir_output[$object->entity])) {
$logodir = $conf->mycompany->multidir_output[$object->entity];
}
$pagecount = $pdf->setSourceFile($logodir .'/' . getDolGlobalString('MAIN_ADD_PDF_BACKGROUND'));
$tplidx = $pdf->importPage(1);
}

View file

@ -94,7 +94,11 @@ class InterfaceNotification extends DolibarrTriggers
dol_syslog("Trigger '".$this->name."' for action '".$action."' launched by ".__FILE__.". id=".$object->id);
$notify = new Notify($this->db);
$notify->send($action, $object);
$resultSend = $notify->send($action, $object);
if ($resultSend < 0) {
$this->errors = array_merge($this->errors, $notify->errors);
return $resultSend;
}
return 1;
}

View file

@ -3245,7 +3245,7 @@ class Product extends CommonObject
$sql .= " AND c.fk_soc = ".((int) $socid);
}
if ($filtrestatut != '') {
$sql .= " AND c.fk_statut in (".$this->db->sanitize($filtrestatut).")";
$sql .= " AND c.fk_statut IN (".$this->db->sanitize($filtrestatut).")";
}
$result = $this->db->query($sql);
@ -3278,7 +3278,7 @@ class Product extends CommonObject
}
// If stock decrease is on invoice validation, the theoretical stock continue to
// count the orders to ship in theoretical stock when some are already removed by invoice validation.
// count the orders lines in theoretical stock when some are already removed by invoice validation.
if ($forVirtualStock && getDolGlobalString('STOCK_CALCULATE_ON_BILL')) {
if (getDolGlobalString('DECREASE_ONLY_UNINVOICEDPRODUCTS')) {
// If option DECREASE_ONLY_UNINVOICEDPRODUCTS is on, we make a compensation but only if order not yet invoice.
@ -5986,22 +5986,40 @@ class Product extends CommonObject
$this->stock_theorique = $this->stock_reel + $stock_inproduction;
// $weBillOrderOrShipmentReception is set to 'order' or 'shipmentreception'. it will be used to know how to make virtual stock
// calculation when we have a stock increase or decrease on billing. Do we have to count orders to bill or shipment/reception to bill ?
$weBillOrderOrShipmentReception = getDolGlobalString('STOCK_DO_WE_BILL_ORDER_OR_SHIPMENTECEPTION_FOR_VIRTUALSTOCK', 'order');
// Stock decrease mode
if (getDolGlobalString('STOCK_CALCULATE_ON_SHIPMENT') || getDolGlobalString('STOCK_CALCULATE_ON_SHIPMENT_CLOSE')) {
$this->stock_theorique -= ($stock_commande_client - $stock_sending_client);
} elseif (getDolGlobalString('STOCK_CALCULATE_ON_VALIDATE_ORDER')) {
$this->stock_theorique += 0;
} elseif (getDolGlobalString('STOCK_CALCULATE_ON_BILL')) {
if (getDolGlobalString('STOCK_CALCULATE_ON_VALIDATE_ORDER_INCLUDE_DRAFT')) { // By default, draft means "does not exist", so we do not include them by default, except if option is on
$tmpnewprod = dol_clone($this, 1);
$result = $tmpnewprod->load_stats_commande(0, '0', 1); // Get qty in draft orders
$this->stock_theorique += $tmpnewprod->stats_commande['qty'];
}
} elseif (getDolGlobalString('STOCK_CALCULATE_ON_BILL') && $weBillOrderOrShipmentReception == 'order') {
$this->stock_theorique -= $stock_commande_client;
} elseif (getDolGlobalString('STOCK_CALCULATE_ON_BILL') && $weBillOrderOrShipmentReception == 'shipmentreception') {
$this->stock_theorique -= ($stock_commande_client - $stock_sending_client);
}
// Stock Increase mode
if (getDolGlobalString('STOCK_CALCULATE_ON_RECEPTION') || getDolGlobalString('STOCK_CALCULATE_ON_RECEPTION_CLOSE')) {
$this->stock_theorique += ($stock_commande_fournisseur - $stock_reception_fournisseur);
} elseif (getDolGlobalString('STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER')) {
} elseif (getDolGlobalString('STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER')) { // This option is similar to STOCK_CALCULATE_ON_RECEPTION_CLOSE but when module Reception is not enabled
$this->stock_theorique += ($stock_commande_fournisseur - $stock_reception_fournisseur);
} elseif (getDolGlobalString('STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER')) {
} elseif (getDolGlobalString('STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER')) { // Warning: stock change "on approval", not on validation !
if (getDolGlobalString('STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER_INCLUDE_DRAFT')) { // By default, draft means "does not exist", so we do not include them by default, except if option is on
$tmpnewprod = dol_clone($this, 1);
$result = $tmpnewprod->load_stats_commande_fournisseur(0, '0', 1); // Get qty in draft orders
$this->stock_theorique += $this->stats_commande_fournisseur['qty'];
}
$this->stock_theorique -= $stock_reception_fournisseur;
} elseif (getDolGlobalString('STOCK_CALCULATE_ON_SUPPLIER_BILL')) {
} elseif (getDolGlobalString('STOCK_CALCULATE_ON_SUPPLIER_BILL') && $weBillOrderOrShipmentReception == 'order') {
$this->stock_theorique += $stock_commande_fournisseur;
} elseif (getDolGlobalString('STOCK_CALCULATE_ON_SUPPLIER_BILL') && $weBillOrderOrShipmentReception == 'shipmentreception') {
$this->stock_theorique += ($stock_commande_fournisseur - $stock_reception_fournisseur);
}

View file

@ -274,7 +274,7 @@ class Inventory extends CommonObject
// Scan existing stock to prefill the inventory
$sql = "SELECT ps.rowid, ps.fk_entrepot as fk_warehouse, ps.fk_product, ps.reel,";
if (isModEnabled('productbatch')) {
$sql .= " pb.batch as batch, pb.qty as qty,";
$sql .= " COALESCE(pb.batch, '') as batch, pb.qty as qty,";
} else {
$sql .= " '' as batch, 0 as qty,";
}
@ -297,7 +297,9 @@ class Inventory extends CommonObject
if (!empty($include_sub_warehouse) && getDolGlobalInt('INVENTORY_INCLUDE_SUB_WAREHOUSE')) {
$TChildWarehouses = array();
$this->getChildWarehouse($this->fk_warehouse, $TChildWarehouses);
$sql .= " OR ps.fk_entrepot IN (".$this->db->sanitize(implode(',', $TChildWarehouses)).")";
if (!empty($TChildWarehouses)) {
$sql .= " OR ps.fk_entrepot IN (" . $this->db->sanitize(implode(',', $TChildWarehouses)) . ")";
}
}
$sql .= ')';
}

View file

@ -852,7 +852,10 @@ $arrayofmassactions = array(
//'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
);
if ($user->hasRight($rightskey, 'creer')) {
$arrayofmassactions['preupdateprice'] = img_picto('', 'edit', 'class="pictofixedwidth"').$langs->trans("UpdatePrice");
if (getDolGlobalString('PRODUCT_PRICE_UNIQ') || getDolGlobalString('PRODUIT_CUSTOMER_PRICES')) {
$arrayofmassactions['preupdateprice'] = img_picto('', 'edit', 'class="pictofixedwidth"').$langs->trans("UpdatePrice");
}
$arrayofmassactions['switchonsalestatus'] = img_picto('', 'stop-circle', 'class="pictofixedwidth"').$langs->trans("SwitchOnSaleStatus");
$arrayofmassactions['switchonpurchasestatus'] = img_picto('', 'stop-circle', 'class="pictofixedwidth"').$langs->trans("SwitchOnPurchaseStatus");
}

View file

@ -542,7 +542,7 @@ if ($id > 0 || $ref) {
$variants = $object->hasVariants();
$object->load_stock();
$object->load_stock(); // This include the load_virtual_stock()
$title = $langs->trans('ProductServiceCard');
$helpurl = '';

View file

@ -729,11 +729,13 @@ class Reception extends CommonObject
$this->fetch_origin();
if ($this->origin_object instanceof CommonObject && empty($this->origin_object->lines)) {
$res = $this->origin_object->fetch_lines();
if ($this->origin_object instanceof CommandeFournisseur) {
$this->commandeFournisseur = $this->origin_object; // deprecated
} else {
$this->commandeFournisseur = null; // deprecated
$this->commandeFournisseur = null; // deprecated
if ($res < 0) {
return $res;
}
} elseif ($this->origin_object instanceof CommandeFournisseur && empty($this->origin_object->lines)) {
$res = $this->origin_object->fetch_lines();
$this->commandeFournisseur = $this->origin_object; // deprecated
if ($res < 0) {
return $res;
}

View file

@ -3295,7 +3295,7 @@ if (!GETPOST('hide_websitemenu')) {
print '<span class="valignmiddle disabled opacitymedium">'.img_picto($langs->trans($text_off), 'switch_on').'</span>';
}
} else {
print ajax_object_onoff($websitepage, 'status', 'status', 'Online', 'Offline', array(), 'valignmiddle inline-block'.(empty($websitepage->id) ? ' opacitymedium disabled' : ''), 'statuswebsitepage', 1, 'pageid='.$websitepage->id);
print ajax_object_onoff($websitepage, 'status', 'status', 'Online', 'Offline', array(), 'valignmiddle inline-block'.(empty($websitepage->id) ? ' opacitymedium disabled' : ''), 'statuswebsitepage', 1, 'website='.urlencode($website->ref).'&pageid='.((int) $websitepage->id));
}
//print '</div>';
print '</span>';

View file

@ -235,7 +235,7 @@ if (is_array($object->lines) && (count($object->lines) > 0)) {
exit(1);
}
}
$user->getrights();
$user->getrights('', 1); // We force rights reload to have the correct permissions for user in the entity we just switched in
}
// Reload langs