diff --git a/ChangeLog b/ChangeLog
index d6c8e1c9e98..17adbf2a813 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -217,7 +217,7 @@ Following changes may create regressions for some external modules, but were nec
***** ChangeLog for 17.0.2 compared to 17.0.1 *****
-
+FIX : Add hidden conf to add extrafields in canelle template : INVOICE_ADD_EXTRAFIELD_IN_NOTE
FIX: #24414
FIX: #24798 Deleting member subscription is not possible
FIX: add a test for updating date on task update in tab time consummed pro…
diff --git a/dev/initdemo/mysqldump_dolibarr_17.0.0.sql b/dev/initdemo/mysqldump_dolibarr_17.0.0.sql
index 71c7c8e50ea..c4af061da20 100644
--- a/dev/initdemo/mysqldump_dolibarr_17.0.0.sql
+++ b/dev/initdemo/mysqldump_dolibarr_17.0.0.sql
@@ -1976,7 +1976,11 @@ CREATE TABLE `llx_c_holiday_types` (
LOCK TABLES `llx_c_holiday_types` WRITE;
/*!40000 ALTER TABLE `llx_c_holiday_types` DISABLE KEYS */;
-INSERT INTO `llx_c_holiday_types` VALUES (1,'LEAVE_SICK','Sick leave',0,0,0.00000,NULL,1,NULL),(2,'LEAVE_OTHER','Other leave',0,0,0.00000,NULL,1,NULL),(3,'LEAVE_PAID','Paid vacation',1,7,0.00000,NULL,1,NULL),(4,'LEAVE_RTT_FR','RTT',1,7,0.83000,1,0,NULL),(5,'LEAVE_PAID_FR','Paid vacation',1,30,2.08334,1,0,NULL);
+INSERT INTO `llx_c_holiday_types` VALUES (1,'LEAVE_SICK','Sick leave',0,0,0.00000,NULL,0,1,NULL);
+INSERT INTO `llx_c_holiday_types` VALUES (2,'LEAVE_OTHER','Other leave',0,0,0.00000,NULL,0,1,NULL);
+INSERT INTO `llx_c_holiday_types` VALUES (3,'LEAVE_PAID','Paid vacation',1,7,0.00000,NULL,0,1,NULL);
+INSERT INTO `llx_c_holiday_types` VALUES (4,'LEAVE_RTT_FR','RTT',1,7,0.83000,1,0,0,NULL);
+INSERT INTO `llx_c_holiday_types` VALUES (5,'LEAVE_PAID_FR','Paid vacation',1,30,2.08334,1,0,0,NULL);
/*!40000 ALTER TABLE `llx_c_holiday_types` ENABLE KEYS */;
UNLOCK TABLES;
diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php
index bc11bc8e4b1..b815a673d13 100644
--- a/htdocs/comm/propal/card.php
+++ b/htdocs/comm/propal/card.php
@@ -1690,9 +1690,18 @@ if ($action == 'create') {
print load_fiche_titre($langs->trans("NewProp"), '', 'propal');
+ $cond_reglement_id = $mode_reglement_id = 0;
+
$soc = new Societe($db);
if ($socid > 0) {
$res = $soc->fetch($socid);
+
+ if (GETPOSTINT('cond_reglement_id') == 0) {
+ $cond_reglement_id = $soc->cond_reglement_id;
+ }
+ if (GETPOSTINT('mode_reglement_id') == 0) {
+ $mode_reglement_id = $soc->mode_reglement_id;
+ }
}
// Load objectsrc
@@ -1764,6 +1773,15 @@ if ($action == 'create') {
}
}
+ // when payment term is empty (means not override by payment mode form a other object, like third-party), try to use default value
+ if (empty($cond_reglement_id)) {
+ $cond_reglement_id = GETPOST("cond_reglement_id", 'int');
+ }
+ // when payment mode is empty (means not override by payment mode form a other object, like third-party), try to use default value
+ if (empty($mode_reglement_id)) {
+ $mode_reglement_id = GETPOST("mode_reglement_id", 'int');
+ }
+
//Warehouse default if null
if ($soc->fk_warehouse > 0) {
$warehouse_id = $soc->fk_warehouse;
@@ -1868,15 +1886,13 @@ if ($action == 'create') {
print '
'.$langs->trans('PaymentConditionsShort').'
';
print img_picto('', 'payment', 'class="pictofixedwidth"');
// at last resort we take the payment term id which may be filled by default values set (if not getpostisset)
- $paymentTermId = (GETPOSTISSET('cond_reglement_id') && GETPOST('cond_reglement_id', 'int') != 0) ? GETPOST('cond_reglement_id', 'int') : (!empty($soc->cond_reglement_id) ? $soc->cond_reglement_id : GETPOST('cond_reglement_id', 'int'));
- print $form->getSelectConditionsPaiements($paymentTermId, 'cond_reglement_id', 1, 1, 0, '', (GETPOSTISSET('cond_reglement_id_deposit_percent') ? GETPOST('cond_reglement_id_deposit_percent', 'alpha') : $soc->deposit_percent));
+ print $form->getSelectConditionsPaiements($cond_reglement_id, 'cond_reglement_id', 1, 1, 0, '', (GETPOSTISSET('cond_reglement_id_deposit_percent') ? GETPOST('cond_reglement_id_deposit_percent', 'alpha') : $soc->deposit_percent));
print '
';
diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php
index b703340be37..cc773dcf6de 100644
--- a/htdocs/product/class/product.class.php
+++ b/htdocs/product/class/product.class.php
@@ -3101,11 +3101,12 @@ class Product extends CommonObject
if (!empty($conf->global->DECREASE_ONLY_UNINVOICEDPRODUCTS)) {
// If option DECREASE_ONLY_UNINVOICEDPRODUCTS is on, we make a compensation but only if order not yet invoice.
$adeduire = 0;
- $sql = "SELECT sum(fd.qty) as count FROM ".$this->db->prefix()."facturedet as fd ";
- $sql .= " JOIN ".$this->db->prefix()."facture as f ON fd.fk_facture = f.rowid ";
+ $sql = "SELECT SUM(".$this->db->ifsql('f.type=2', -1, 1)." * fd.qty) as count FROM ".$this->db->prefix()."facturedet as fd ";
+ $sql .= " JOIN ".$this->db->prefix()."facture as f ON fd.fk_facture = f.rowid";
$sql .= " JOIN ".$this->db->prefix()."element_element as el ON ((el.fk_target = f.rowid AND el.targettype = 'facture' AND sourcetype = 'commande') OR (el.fk_source = f.rowid AND el.targettype = 'commande' AND sourcetype = 'facture'))";
- $sql .= " JOIN ".$this->db->prefix()."commande as c ON el.fk_source = c.rowid ";
+ $sql .= " JOIN ".$this->db->prefix()."commande as c ON el.fk_source = c.rowid";
$sql .= " WHERE c.fk_statut IN (".$this->db->sanitize($filtrestatut).") AND c.facture = 0 AND fd.fk_product = ".((int) $this->id);
+
dol_syslog(__METHOD__.":: sql $sql", LOG_NOTICE);
$resql = $this->db->query($sql);
if ($resql) {
@@ -3122,11 +3123,12 @@ class Product extends CommonObject
// For every order having invoice already validated we need to decrease stock cause it's in physical stock
$adeduire = 0;
- $sql = 'SELECT sum(fd.qty) as count FROM '.MAIN_DB_PREFIX.'facturedet as fd ';
- $sql .= ' JOIN '.MAIN_DB_PREFIX.'facture as f ON fd.fk_facture = f.rowid ';
- $sql .= ' JOIN '.MAIN_DB_PREFIX."element_element as el ON ((el.fk_target = f.rowid AND el.targettype = 'facture' AND sourcetype = 'commande') OR (el.fk_source = f.rowid AND el.targettype = 'commande' AND sourcetype = 'facture'))";
- $sql .= ' JOIN '.MAIN_DB_PREFIX.'commande as c ON el.fk_source = c.rowid ';
- $sql .= ' WHERE c.fk_statut IN ('.$this->db->sanitize($filtrestatut).') AND f.fk_statut > '.Facture::STATUS_DRAFT.' AND fd.fk_product = '.((int) $this->id);
+ $sql = "SELECT sum(".$this->db->ifsql('f.type=2', -1, 1)." * fd.qty) as count FROM ".MAIN_DB_PREFIX."facturedet as fd ";
+ $sql .= " JOIN ".MAIN_DB_PREFIX."facture as f ON fd.fk_facture = f.rowid";
+ $sql .= " JOIN ".MAIN_DB_PREFIX."element_element as el ON ((el.fk_target = f.rowid AND el.targettype = 'facture' AND sourcetype = 'commande') OR (el.fk_source = f.rowid AND el.targettype = 'commande' AND sourcetype = 'facture'))";
+ $sql .= " JOIN ".MAIN_DB_PREFIX."commande as c ON el.fk_source = c.rowid";
+ $sql .= " WHERE c.fk_statut IN (".$this->db->sanitize($filtrestatut).") AND f.fk_statut > ".Facture::STATUS_DRAFT." AND fd.fk_product = ".((int) $this->id);
+
dol_syslog(__METHOD__.":: sql $sql", LOG_NOTICE);
$resql = $this->db->query($sql);
if ($resql) {
@@ -3134,6 +3136,9 @@ class Product extends CommonObject
$obj = $this->db->fetch_object($resql);
$adeduire += $obj->count;
}
+ } else {
+ $this->error = $this->db->error();
+ return -1;
}
$this->stats_commande['qty'] -= $adeduire;
diff --git a/htdocs/product/stock/card.php b/htdocs/product/stock/card.php
index 1fcd4e11792..5baf343556e 100644
--- a/htdocs/product/stock/card.php
+++ b/htdocs/product/stock/card.php
@@ -201,7 +201,7 @@ if (empty($reshook)) {
$object->label = GETPOST("libelle");
$object->fk_parent = GETPOST("fk_parent");
$object->fk_project = GETPOST('projectid');
- $object->description = GETPOST("desc");
+ $object->description = GETPOST("desc", 'restricthtml');
$object->statut = GETPOST("statut");
$object->lieu = GETPOST("lieu");
$object->address = GETPOST("address");
diff --git a/htdocs/product/stock/list.php b/htdocs/product/stock/list.php
index 03e718b2c0b..4ac1aadc20f 100644
--- a/htdocs/product/stock/list.php
+++ b/htdocs/product/stock/list.php
@@ -270,17 +270,17 @@ if (!empty($searchCategoryWarehouseList)) {
$listofcategoryid = '';
foreach ($searchCategoryWarehouseList as $searchCategoryWarehouse) {
if (intval($searchCategoryWarehouse) == -2) {
- $searchCategoryWarehouseSqlList[] = "NOT EXISTS (SELECT ck.fk_warehouse FROM ".MAIN_DB_PREFIX."categorie_warehouse as ck WHERE p.rowid = ck.fk_warehouse)";
+ $searchCategoryWarehouseSqlList[] = " NOT EXISTS (SELECT ck.fk_warehouse FROM ".MAIN_DB_PREFIX."categorie_warehouse as ck WHERE t.rowid = ck.fk_warehouse)";
} elseif (intval($searchCategoryWarehouse) > 0) {
if ($searchCategoryWarehouseOperator == 0) {
- $searchCategoryWarehouseSqlList[] = " EXISTS (SELECT ck.fk_warehouse FROM ".MAIN_DB_PREFIX."categorie_warehouse as ck WHERE p.rowid = ck.fk_warehouse AND ck.fk_categorie = ".((int) $searchCategoryWarehouse).")";
+ $searchCategoryWarehouseSqlList[] = " EXISTS (SELECT ck.fk_warehouse FROM ".MAIN_DB_PREFIX."categorie_warehouse as ck WHERE t.rowid = ck.fk_warehouse AND ck.fk_categorie = ".((int) $searchCategoryWarehouse).")";
} else {
$listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryWarehouse);
}
}
}
if ($listofcategoryid) {
- $searchCategoryWarehouseSqlList[] = " EXISTS (SELECT ck.fk_warehouse FROM ".MAIN_DB_PREFIX."categorie_warehouse as ck WHERE p.rowid = ck.fk_warehouse AND ck.fk_categorie IN (".$db->sanitize($listofcategoryid)."))";
+ $searchCategoryWarehouseSqlList[] = " EXISTS (SELECT ck.fk_warehouse FROM ".MAIN_DB_PREFIX."categorie_warehouse as ck WHERE t.rowid = ck.fk_warehouse AND ck.fk_categorie IN (".$db->sanitize($listofcategoryid)."))";
}
if ($searchCategoryWarehouseOperator == 1) {
if (!empty($searchCategoryWarehouseSqlList)) {
diff --git a/htdocs/product/stock/replenish.php b/htdocs/product/stock/replenish.php
index 039c6ff9e4a..9fabf33fee7 100644
--- a/htdocs/product/stock/replenish.php
+++ b/htdocs/product/stock/replenish.php
@@ -579,7 +579,7 @@ print ''.$langs->trans("ReplenishmentStatusDesc").'<
//$link = ''.$langs->trans("MenuNewWarehouse").'';
-if (empty($fk_warhouse) && !empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE)) {
+if (empty($fk_entrepot) && !empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE)) {
print ''.$langs->trans("ReplenishmentStatusDescPerWarehouse").''."\n";
}
print '
';
diff --git a/htdocs/product/stock/stockatdate.php b/htdocs/product/stock/stockatdate.php
index 7d9fce8aa48..0e16bf8d68b 100644
--- a/htdocs/product/stock/stockatdate.php
+++ b/htdocs/product/stock/stockatdate.php
@@ -145,8 +145,9 @@ if ($date && $dateIsValid) { // Avoid heavy sql if mandatory date is not defined
$sql .= " SUM(ps.reel) AS stock";
$sql .= " FROM ".MAIN_DB_PREFIX."product_stock as ps";
$sql .= ", ".MAIN_DB_PREFIX."entrepot as w";
+ $sql .= ", ".MAIN_DB_PREFIX."product as p";
$sql .= " WHERE w.entity IN (".getEntity('stock').")";
- $sql .= " AND w.rowid = ps.fk_entrepot";
+ $sql .= " AND w.rowid = ps.fk_entrepot AND p.rowid = ps.fk_product";
if (!empty($conf->global->ENTREPOT_EXTRA_STATUS) && count($warehouseStatus)) {
$sql .= " AND w.statut IN (".$db->sanitize(implode(',', $warehouseStatus)).")";
}
@@ -156,6 +157,12 @@ if ($date && $dateIsValid) { // Avoid heavy sql if mandatory date is not defined
if (! empty($search_fk_warehouse)) {
$sql .= " AND ps.fk_entrepot IN (".$db->sanitize(join(",", $search_fk_warehouse)).")";
}
+ if ($search_ref) {
+ $sql .= natural_search("p.ref", $search_ref);
+ }
+ if ($search_nom) {
+ $sql .= natural_search("p.label", $search_nom);
+ }
$sql .= " GROUP BY fk_product, fk_entrepot";
//print $sql;
@@ -195,8 +202,9 @@ if ($date && $dateIsValid) {
$sql = "SELECT sm.fk_product, sm.fk_entrepot, SUM(sm.value) AS stock, COUNT(sm.rowid) AS nbofmovement";
$sql .= " FROM ".MAIN_DB_PREFIX."stock_mouvement as sm";
$sql .= ", ".MAIN_DB_PREFIX."entrepot as w";
+ $sql .= ", ".MAIN_DB_PREFIX."product as p";
$sql .= " WHERE w.entity IN (".getEntity('stock').")";
- $sql .= " AND w.rowid = sm.fk_entrepot";
+ $sql .= " AND w.rowid = sm.fk_entrepot AND p.rowid = sm.fk_product ";
if (!empty($conf->global->ENTREPOT_EXTRA_STATUS) && count($warehouseStatus)) {
$sql .= " AND w.statut IN (".$db->sanitize(implode(',', $warehouseStatus)).")";
}
@@ -211,7 +219,14 @@ if ($date && $dateIsValid) {
if (!empty($search_fk_warehouse)) {
$sql .= " AND sm.fk_entrepot IN (".$db->sanitize(join(",", $search_fk_warehouse)).")";
}
+ if ($search_ref) {
+ $sql .= " AND p.ref LIKE '%".$db->escape($search_ref)."%' ";
+ }
+ if ($search_nom) {
+ $sql .= " AND p.label LIKE '%".$db->escape($search_nom)."%' ";
+ }
$sql .= " GROUP BY sm.fk_product, sm.fk_entrepot";
+
$resql = $db->query($sql);
if ($resql) {
diff --git a/htdocs/product/traduction.php b/htdocs/product/traduction.php
index ba4dc956d08..80fbfb69bf0 100644
--- a/htdocs/product/traduction.php
+++ b/htdocs/product/traduction.php
@@ -1,8 +1,9 @@
* Copyright (C) 2007 Rodolphe Quiedeville
- * Copyright (C) 2010-2012 Destailleur Laurent
- * Copyright (C) 2014 Henry Florian
+ * Copyright (C) 2010-2012 Destailleur Laurent
+ * Copyright (C) 2014 Henry Florian
+ * Copyright (C) 2023 Benjamin Falière
*
* 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
@@ -136,6 +137,8 @@ if (empty($reshook)) {
$object->label = GETPOST("libelle-" . $key);
$object->description = dol_htmlcleanlastbr(GETPOST("desc-" . $key, 'restricthtml'));
$object->other = dol_htmlcleanlastbr(GETPOST("other-" . $key, 'restricthtml'));
+
+ $object->update($object->id, $user);
} else {
$object->multilangs[$key]["label"] = GETPOST("libelle-" . $key);
$object->multilangs[$key]["description"] = dol_htmlcleanlastbr(GETPOST("desc-" . $key, 'restricthtml'));
diff --git a/htdocs/projet/activity/perday.php b/htdocs/projet/activity/perday.php
index 9c4e47037c2..ff29924edec 100644
--- a/htdocs/projet/activity/perday.php
+++ b/htdocs/projet/activity/perday.php
@@ -485,7 +485,7 @@ print img_picto('', 'projecttask', 'class="pictofixedwidth"');
$formproject->selectTasks($socid ? $socid : -1, $taskid, 'taskid', 32, 0, '-- '.$langs->trans("ChooseANotYetAssignedTask").' --', 1, 0, 0, '', '', 'all', $usertoprocess);
print '';
print ' ';
-print $formcompany->selectTypeContact($object, '', 'type', 'internal', 'rowid', 0, 'maxwidth150onsmartphone');
+print $formcompany->selectTypeContact($object, '', 'type', 'internal', 'position', 0, 'maxwidth150onsmartphone');
print '';
print '';
diff --git a/htdocs/projet/activity/permonth.php b/htdocs/projet/activity/permonth.php
index bff135b713f..481652a5349 100644
--- a/htdocs/projet/activity/permonth.php
+++ b/htdocs/projet/activity/permonth.php
@@ -399,7 +399,7 @@ print img_picto('', 'projecttask', 'class="pictofixedwidth"');
$formproject->selectTasks($socid ? $socid : -1, $taskid, 'taskid', 32, 0, '-- '.$langs->trans("ChooseANotYetAssignedTask").' --', 1);
print '';
print ' ';
-print $formcompany->selectTypeContact($object, '', 'type', 'internal', 'rowid', 0, 'maxwidth150onsmartphone');
+print $formcompany->selectTypeContact($object, '', 'type', 'internal', 'position', 0, 'maxwidth150onsmartphone');
print '';
print '';
diff --git a/htdocs/projet/activity/perweek.php b/htdocs/projet/activity/perweek.php
index 1d3a6ef3c2c..daf1dd0ac7b 100644
--- a/htdocs/projet/activity/perweek.php
+++ b/htdocs/projet/activity/perweek.php
@@ -499,7 +499,7 @@ print img_picto('', 'projecttask', 'class="pictofixedwidth"');
$formproject->selectTasks($socid ? $socid : -1, $taskid, 'taskid', 32, 0, '-- '.$langs->trans("ChooseANotYetAssignedTask").' --', 1, 0, 0, '', '', 'all', $usertoprocess);
print '';
print ' ';
-print $formcompany->selectTypeContact($object, '', 'type', 'internal', 'rowid', 0, 'maxwidth150onsmartphone');
+print $formcompany->selectTypeContact($object, '', 'type', 'internal', 'position', 0, 'maxwidth150onsmartphone');
print '';
print '';
diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php
index c281ea45e22..b5153689158 100644
--- a/htdocs/projet/card.php
+++ b/htdocs/projet/card.php
@@ -777,7 +777,7 @@ if ($action == 'create' && $user->rights->projet->creer) {
}
// Budget
- print '