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

This commit is contained in:
Laurent Destailleur 2026-03-05 23:59:06 +01:00
commit bc44247cd1
9 changed files with 118 additions and 71 deletions

View file

@ -97,7 +97,7 @@
$sql .= " AND cs.periode >= '".$db->idate($search_date_limit_start)."'";
$sql .= " OR (cs.periode IS NULL AND cs.date_ech between '".$db->idate(dol_get_first_day($year))."' AND '".$db->idate(dol_get_last_day($year))."')";
$sql .= " SET reponses = '".$db->escape($nouveauchoix)."'";
$sql .= " cs.rowid, cs.libelle, cs.fk_type as type, cs.periode as period, cs.date_ech, cs.amount as total,";
$sql .= " cs.rowid, cs.libelle as label, cs.fk_type as type, cs.periode as period, cs.date_ech, cs.amount as total,";
$sql.= " ".MAIN_DB_PREFIX."notify_def as nd,";
$sql.= " AND nd.fk_action = ad.rowid";
$sql.= " WHERE u.rowid = nd.fk_user";

View file

@ -9,6 +9,7 @@
* Copyright (C) 2017 Open-DSI <support@open-dsi.fr>
* Copyright (C) 2021-2025 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2026 Anthony Berton <anthony.berton@bb2a.fr>
*
* 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
@ -460,6 +461,9 @@ if ($mode == 'show_day' || $mode == 'show_week' || $mode == 'show_month') {
if ($search_categ_cus != 0) {
$param .= '&search_categ_cus='.urlencode((string) ($search_categ_cus));
}
if ($check_holiday) {
$param .= '&check_holiday=1';
}
// Show navigation bar
$nav = '';
@ -629,7 +633,7 @@ if (!empty($conf->use_javascript_ajax)) { // If javascript on
$s .= '<script type="text/javascript">'."\n";
$s .= 'jQuery(document).ready(function () {'."\n";
$s .= 'jQuery(".check_birthday").click(function() { console.log("Toggle class .family_birthday"); jQuery(".family_birthday").toggle(); });'."\n";
$s .= 'jQuery(".check_holiday").click(function() { console.log("Toggle class .family_holiday"); jQuery(".family_holiday").toggle(); });'."\n";
$s .= 'jQuery(".check_holiday").click(function() { console.log("Toggle class .family_holiday"); jQuery(".family_holiday").toggle(); jQuery(this).closest("form").submit(); });'."\n";
if (isModEnabled("bookcal") && !empty($bookcalcalendars["calendars"])) {
foreach ($bookcalcalendars["calendars"] as $key => $value) {
$s .= 'jQuery(".check_bookcal_calendar_'.$value['id'].'").click(function() { console.log("Toggle Bookcal Calendar '.$value['id'].'"); jQuery(".family_bookcal_calendar_'.$value['id'].'").toggle(); });'."\n";
@ -1173,9 +1177,14 @@ if ($user->hasRight("holiday", "read")) {
$sql .= " AND x.date_debut <= '".$db->idate(dol_get_last_day($year, $month))."'";
$sql .= " AND x.date_fin >= '".$db->idate(dol_get_first_day($year, $month))."'";
}
if (!$user->hasRight('holiday', 'readall')) {
if (!$user->hasRight('holiday', 'readall') || $filtert == '-3') {
// Restrict on users of current user and his children
$sql .= " AND x.fk_user IN(".$db->sanitize(implode(", ", $user->getAllChildIds(1))).") ";
}
if ($filtert > 0) {
// Restrict on user
$sql .= " AND x.fk_user = ".((int) $filtert);
}
$resql = $db->query($sql);
if ($resql) {

View file

@ -1367,7 +1367,7 @@ if (empty($reshook)) {
// If a price per customer exist
$pricebycustomerexist = false;
$result = $prodcustprice->fetchAll('', '', 0, 0, $filter);
if ($result) {
if ($result >= 0) {
// If there is some prices specific to the customer
if (count($prodcustprice->lines) > 0) {
$date_now = (int) floor(dol_now() / 86400) * 86400; // date without hours
@ -1391,9 +1391,11 @@ if (empty($reshook)) {
}
}
}
} else {
setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors');
}
if (!$pricebycustomerexist && $object->thirdparty->price_level) { // If price per segment
if (!$pricebycustomerexist && !empty($object->thirdparty->price_level)) { // If price per segment
$pu_ht = $prod->multiprices[$object->thirdparty->price_level];
$pu_ttc = $prod->multiprices_ttc[$object->thirdparty->price_level];
$price_min = $prod->multiprices_min[$object->thirdparty->price_level];
@ -1408,7 +1410,7 @@ if (empty($reshook)) {
}
}
}
} elseif (getDolGlobalString('PRODUIT_MULTIPRICES') && $object->thirdparty->price_level) { // If price per segment
} elseif (getDolGlobalString('PRODUIT_MULTIPRICES') && !empty($object->thirdparty->price_level)) { // If price per segment
$pu_ht = $prod->multiprices[$object->thirdparty->price_level];
$pu_ttc = $prod->multiprices_ttc[$object->thirdparty->price_level];
$price_min = $prod->multiprices_min[$object->thirdparty->price_level];
@ -1431,7 +1433,7 @@ if (empty($reshook)) {
$filter = array('t.fk_product' => (string) $prod->id, 't.fk_soc' => (string) $object->thirdparty->id);
$result = $prodcustprice->fetchAll('', '', 0, 0, $filter);
if ($result) {
if ($result >= 0) {
// If there is some prices specific to the customer
if (count($prodcustprice->lines) > 0) {
$date_now = (int) floor(dol_now() / 86400) * 86400; // date without hours
@ -1454,6 +1456,8 @@ if (empty($reshook)) {
}
}
}
} else {
setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors');
}
} elseif (getDolGlobalString('PRODUIT_CUSTOMER_PRICES_BY_QTY')) {
// If price per quantity
@ -1499,26 +1503,26 @@ if (empty($reshook)) {
}
}
$tmpvat = price2num(preg_replace('/\s*\(.*\)/', '', $tva_tx));
$tmpprodvat = price2num(preg_replace('/\s*\(.*\)/', '', (string) $prod->tva_tx));
$tmpvat = (float) price2num(preg_replace('/\s*\(.*\)/', '', $tva_tx));
$tmpprodvat = (float) price2num(preg_replace('/\s*\(.*\)/', '', (string) $prod->tva_tx));
// Set unit price to use
if (!empty($price_ht) || (string) $price_ht === '0') {
$pu_ht = price2num($price_ht, 'MU');
$pu_ttc = price2num((float) $pu_ht * (1 + ((float) $tmpvat / 100)), 'MU');
$pu_ht = (float) price2num($price_ht, 'MU');
$pu_ttc = (float) price2num((float) $pu_ht * (1 + ((float) $tmpvat / 100)), 'MU');
} elseif (!empty($price_ht_devise) || (string) $price_ht_devise === '0') {
$pu_ht_devise = price2num($price_ht_devise, 'MU');
$pu_ht = '';
$pu_ttc = '';
} elseif (!empty($price_ttc) || (string) $price_ttc === '0') {
$pu_ttc = price2num($price_ttc, 'MU');
$pu_ht = price2num((float) $pu_ttc / (1 + ((float) $tmpvat / 100)), 'MU');
$pu_ttc = (float) price2num($price_ttc, 'MU');
$pu_ht = (float) price2num((float) $pu_ttc / (1 + ((float) $tmpvat / 100)), 'MU');
} elseif ($tmpvat != $tmpprodvat) {
// Is this still used ?
if ($price_base_type != 'HT') {
$pu_ht = price2num((float) $pu_ttc / (1 + ((float) $tmpvat / 100)), 'MU');
$pu_ht = (float) price2num((float) $pu_ttc / (1 + ((float) $tmpvat / 100)), 'MU');
} else {
$pu_ttc = price2num((float) $pu_ht * (1 + ((float) $tmpvat / 100)), 'MU');
$pu_ttc = (float) price2num((float) $pu_ht * (1 + ((float) $tmpvat / 100)), 'MU');
}
}
@ -1600,10 +1604,10 @@ if (empty($reshook)) {
$pu_ht = price2num($price_ht, 'MU');
$pu_ttc = price2num($price_ttc, 'MU');
$tva_npr = (preg_match('/\*/', $tva_tx) ? 1 : 0);
$tva_tx = str_replace('*', '', $tva_tx);
if (empty($tva_tx)) {
$tva_npr = 0;
}
$tva_tx = str_replace('*', '', $tva_tx);
$label = (GETPOST('product_label') ? GETPOST('product_label') : '');
$desc = $line_desc;
$type = GETPOST('type');
@ -1660,13 +1664,15 @@ if (empty($reshook)) {
//var_dump(price2num($price_min)); var_dump(price2num($pu_ht)); var_dump($remise_percent);
//var_dump(price2num($price_min_ttc)); var_dump(price2num($pu_ttc)); var_dump($remise_percent);exit;
//$desc = dol_htmlcleanlastbr($desc);
// Check price is not lower than minimum
if ($usermustrespectpricemin) {
if ($pu_equivalent && $price_min && (((float) price2num($pu_equivalent) * (1 - $remise_percent / 100)) < price2num($price_min)) && $price_base_type == 'HT') {
if ($pu_equivalent && $price_min && (((float) price2num($pu_equivalent) * (1 - $remise_percent / 100)) < (float) price2num($price_min)) && $price_base_type == 'HT') {
$mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, -1, $conf->currency));
setEventMessages($mesg, null, 'errors');
$error++;
} elseif ($pu_equivalent_ttc && $price_min_ttc && (((float) price2num($pu_equivalent_ttc) * (1 - $remise_percent / 100)) < price2num($price_min_ttc)) && $price_base_type == 'TTC') {
} elseif ($pu_equivalent_ttc && $price_min_ttc && (((float) price2num($pu_equivalent_ttc) * (1 - $remise_percent / 100)) < (float) price2num($price_min_ttc)) && $price_base_type == 'TTC') {
$mesg = $langs->trans("CantBeLessThanMinPriceInclTax", price(price2num($price_min_ttc, 'MU'), 0, $langs, 0, 0, -1, $conf->currency));
setEventMessages($mesg, null, 'errors');
$error++;
@ -1675,12 +1681,12 @@ if (empty($reshook)) {
if (!$error) {
// Insert line
$result = $object->addline($desc, $pu_ht, (float) $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $price_base_type, $pu_ttc, $info_bits, $type, min($rank, count($object->lines) + 1), 0, GETPOSTINT('fk_parent_line'), (int) $fournprice, $buyingprice, $label, $date_start, $date_end, $array_options, $fk_unit, '', 0, $pu_ht_devise);
$result = $object->addline($desc, $pu_ht, (float) $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $price_base_type, $pu_ttc, $info_bits, $type, min($rank, count($object->lines) + 1), 0, GETPOSTINT('fk_parent_line'), (int) $fournprice, $buyingprice, $label, $date_start, $date_end, $array_options, $fk_unit, '', 0, (float) $pu_ht_devise);
if ($result > 0) {
$db->commit();
$ret = $object->fetch($id); // Reload to get new records
$ret = $object->fetch($object->id); // Reload to get new records
if ($ret > 0) {
$object->fetch_thirdparty();
}
@ -1688,9 +1694,12 @@ if (empty($reshook)) {
if (!getDolGlobalString('MAIN_DISABLE_PDF_AUTOUPDATE')) {
// Define output language
$outputlangs = $langs;
if (getDolGlobalInt('MAIN_MULTILANGS')) {
$newlang = GETPOST('lang_id', 'alpha');
if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) {
$newlang = $object->thirdparty->default_lang;
}
if (!empty($newlang)) {
$outputlangs = new Translate("", $conf);
$newlang = (GETPOST('lang_id', 'aZ09') ? GETPOST('lang_id', 'aZ09') : $object->thirdparty->default_lang);
$outputlangs->setDefaultLang($newlang);
}
$object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
@ -1879,7 +1888,7 @@ if (empty($reshook)) {
setEventMessages($object->error, $object->errors, 'errors');
}
} elseif ($action == 'updateline' && $usercancreate && GETPOST('save')) {
// Update a line within proposal
// Update a line
// Clean parameters
$description = dol_htmlcleanlastbr(GETPOST('product_desc', 'restricthtml'));
@ -1891,7 +1900,7 @@ if (empty($reshook)) {
}
// Define vat_rate
$vat_rate = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0);
$vat_rate = (GETPOST('tva_tx') ? GETPOST('tva_tx', 'alpha') : 0);
$vat_rate = str_replace('*', '', $vat_rate);
$localtax1_rate = get_localtax($vat_rate, 1, $object->thirdparty, $mysoc);
$localtax2_rate = get_localtax($vat_rate, 2, $object->thirdparty, $mysoc);

View file

@ -966,10 +966,6 @@ if (empty($reshook)) {
$price_ht_devise = '';
$price_ttc = '';
$price_ttc_devise = '';
$pu_ht = '';
$pu_ttc = '';
$pu_ht_devise = '';
$pu_ttc_devise = '';
if (GETPOST('price_ht') !== '') {
$price_ht = price2num(GETPOST('price_ht'), 'MU', 2);
@ -1061,13 +1057,20 @@ if (empty($reshook)) {
}
if (!$error && (!empty($line_desc) || (!empty($idprod) && $idprod > 0))) {
$pu_ht = 0;
$pu_ttc = 0;
$pu_ht_devise = 0;
$pu_ttc_devise = 0;
$price_min = 0;
$price_min_ttc = 0;
$tva_npr = 0;
$price_base_type = (GETPOST('price_base_type', 'alpha') ? GETPOST('price_base_type', 'alpha') : 'HT');
// Clean parameters
$date_start = dol_mktime(GETPOSTINT('date_start' . $predef . 'hour'), GETPOSTINT('date_start' . $predef . 'min'), GETPOSTINT('date_start' . $predef . 'sec'), GETPOSTINT('date_start' . $predef . 'month'), GETPOSTINT('date_start' . $predef . 'day'), GETPOSTINT('date_start' . $predef . 'year'));
$date_end = dol_mktime(GETPOSTINT('date_end' . $predef . 'hour'), GETPOSTINT('date_end' . $predef . 'min'), GETPOSTINT('date_end' . $predef . 'sec'), GETPOSTINT('date_end' . $predef . 'month'), GETPOSTINT('date_end' . $predef . 'day'), GETPOSTINT('date_end' . $predef . 'year'));
$price_base_type = (GETPOST('price_base_type', 'alpha') ? GETPOST('price_base_type', 'alpha') : 'HT');
$price_min = $price_min_ttc = 0;
$tva_npr = 0;
$db->begin();
// Ecrase $pu par celui du produit
// Ecrase $desc par celui du produit
@ -1085,6 +1088,7 @@ if (empty($reshook)) {
$tva_npr = 0;
}*/
// Price unique per product
$pu_ht = $prod->price;
$pu_ttc = $prod->price_ttc;
$price_min = $prod->price_min;
@ -1103,6 +1107,7 @@ if (empty($reshook)) {
$pricebycustomerexist = false;
$result = $prodcustprice->fetchAll('', '', 0, 0, $filter);
if ($result >= 0) {
// If there is some prices specific to the customer
if (count($prodcustprice->lines) > 0) {
$date_now = (int) floor(dol_now() / 86400) * 86400; // date without hours
foreach ($prodcustprice->lines as $k => $custprice_line) {
@ -1113,14 +1118,14 @@ if (empty($reshook)) {
$price_min = price($custprice_line->price_min);
$price_min_ttc = price($custprice_line->price_min_ttc);
$price_base_type = $custprice_line->price_base_type;
$tva_tx = $custprice_line->tva_tx;
/*$tva_tx = $custprice_line->tva_tx;
if ($custprice_line->default_vat_code && !preg_match('/\(.*\)/', (string) $tva_tx)) {
$tva_tx .= ' (' . $custprice_line->default_vat_code . ')';
}
$tva_npr = $custprice_line->recuperableonly;
if (empty($tva_tx)) {
$tva_npr = 0;
}
}*/
break;
}
}
@ -1129,7 +1134,7 @@ if (empty($reshook)) {
setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors');
}
if (!$pricebycustomerexist && !empty($object->thirdparty->price_level)) { //// If price per segment
if (!$pricebycustomerexist && !empty($object->thirdparty->price_level)) { // If price per segment
$pu_ht = $prod->multiprices[$object->thirdparty->price_level];
$pu_ttc = $prod->multiprices_ttc[$object->thirdparty->price_level];
$price_min = $prod->multiprices_min[$object->thirdparty->price_level];
@ -1144,9 +1149,7 @@ if (empty($reshook)) {
}
}
}
}
// If price per segment
if (getDolGlobalString('PRODUIT_MULTIPRICES') && !empty($object->thirdparty->price_level)) {
} elseif (getDolGlobalString('PRODUIT_MULTIPRICES') && !empty($object->thirdparty->price_level)) { // If price per segment
$pu_ht = $prod->multiprices[$object->thirdparty->price_level];
$pu_ttc = $prod->multiprices_ttc[$object->thirdparty->price_level];
$price_min = $prod->multiprices_min[$object->thirdparty->price_level];
@ -1170,6 +1173,7 @@ if (empty($reshook)) {
$result = $prodcustprice->fetchAll('', '', 0, 0, $filter);
if ($result >= 0) {
// If there is some prices specific to the customer
if (count($prodcustprice->lines) > 0) {
$date_now = (int) floor(dol_now() / 86400) * 86400; // date without hours
foreach ($prodcustprice->lines as $k => $custprice_line) {
@ -1179,14 +1183,14 @@ if (empty($reshook)) {
$price_min = price($custprice_line->price_min);
$price_min_ttc = price($custprice_line->price_min_ttc);
$price_base_type = $custprice_line->price_base_type;
$tva_tx = $custprice_line->tva_tx;
/*$tva_tx = $custprice_line->tva_tx;
if ($custprice_line->default_vat_code && !preg_match('/\(.*\)/', $tva_tx)) {
$tva_tx .= ' (' . $custprice_line->default_vat_code . ')';
}
$tva_npr = $custprice_line->recuperableonly;
if (empty($tva_tx)) {
$tva_npr = 0;
}
}*/
break;
}
}
@ -1241,18 +1245,22 @@ if (empty($reshook)) {
$tmpprodvat = (float) price2num(preg_replace('/\s*\(.*\)/', '', (string) $prod->tva_tx));
// Set unit price to use
if (!empty($price_ht) || $price_ht === '0') {
if (!empty($price_ht) || (string) $price_ht === '0') {
$pu_ht = (float) price2num($price_ht, 'MU');
$pu_ttc = (float) price2num((float) $pu_ht * (1 + ($tmpvat / 100)), 'MU');
} elseif (!empty($price_ttc) || $price_ttc === '0') {
$pu_ttc = (float) price2num((float) $pu_ht * (1 + ((float) $tmpvat / 100)), 'MU');
} elseif (!empty($price_ht_devise) || (string) $price_ht_devise === '0') {
$pu_ht_devise = price2num($price_ht_devise, 'MU');
$pu_ht = '';
$pu_ttc = '';
} elseif (!empty($price_ttc) || (string) $price_ttc === '0') {
$pu_ttc = (float) price2num($price_ttc, 'MU');
$pu_ht = (float) price2num((float) $pu_ttc / (1 + ($tmpvat / 100)), 'MU');
$pu_ht = (float) price2num((float) $pu_ttc / (1 + ((float) $tmpvat / 100)), 'MU');
} elseif ($tmpvat != $tmpprodvat) {
// Is this still used ?
if ($price_base_type != 'HT') {
$pu_ht = (float) price2num($pu_ttc / (1 + ($tmpvat / 100)), 'MU');
$pu_ht = (float) price2num((float) $pu_ttc / (1 + ((float) $tmpvat / 100)), 'MU');
} else {
$pu_ttc = (float) price2num($pu_ht * (1 + ($tmpvat / 100)), 'MU');
$pu_ttc = (float) price2num((float) $pu_ht * (1 + ((float) $tmpvat / 100)), 'MU');
}
}
@ -1356,12 +1364,12 @@ if (empty($reshook)) {
}
// Local Taxes
$localtax1_tx = get_localtax($tva_tx, 1, $object->thirdparty);
$localtax2_tx = get_localtax($tva_tx, 2, $object->thirdparty);
$localtax1_tx = get_localtax($tva_tx, 1, $object->thirdparty, $mysoc, $tva_npr);
$localtax2_tx = get_localtax($tva_tx, 2, $object->thirdparty, $mysoc, $tva_npr);
// Margin
$fournprice = (int) (GETPOST('fournprice' . $predef) ? GETPOSTINT('fournprice' . $predef) : 0); // This can be id of supplier price, or 'pmpprice' or 'costprice', or 'inputprice', we force to keep ID only
$buyingprice = price2num(GETPOST('buying_price' . $predef) != '' ? GETPOST('buying_price' . $predef) : ''); // If buying_price is '0', we must keep this value
$fournprice = (int) (GETPOST('fournprice'.$predef) ? GETPOST('fournprice'.$predef) : 0); // This can be id of supplier price, or 'pmpprice' or 'costprice', or 'inputprice', we force to keep ID only
$buyingprice = price2num((GETPOST('buying_price'.$predef) != '' ? GETPOST('buying_price'.$predef) : ''), '', 2); // If buying_price is '0', we must keep this value
// Prepare a price equivalent for minimum price check
$pu_equivalent = $pu_ht;
@ -1378,7 +1386,7 @@ if (empty($reshook)) {
$pu_equivalent_ttc = (float) $pu_ttc_devise / (float) $currency_tx;
}
// TODO $pu_equivalent or $pu_equivalent_ttc must be calculated from the one defined
// TODO $pu_equivalent or $pu_equivalent_ttc must be calculated from the one not null taking into account all taxes
/*
if ($pu_equivalent) {
$tmp = calcul_price_total(1, $pu_equivalent, 0, $tva_tx, -1, -1, 0, 'HT', $info_bits, $type);
@ -1389,6 +1397,9 @@ if (empty($reshook)) {
}
*/
//var_dump(price2num($price_min)); var_dump(price2num($pu_ht)); var_dump($remise_percent);
//var_dump(price2num($price_min_ttc)); var_dump(price2num($pu_ttc)); var_dump($remise_percent);exit;
$desc = dol_htmlcleanlastbr($desc);
// Check price is not lower than minimum
@ -1409,8 +1420,12 @@ if (empty($reshook)) {
$result = $object->addline($desc, $pu_ht, (float) $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $info_bits, 0, $price_base_type, $pu_ttc, $date_start, $date_end, $type, min($rank, count($object->lines) + 1), 0, GETPOSTINT('fk_parent_line'), (int) $fournprice, $buyingprice, $label, $array_options, $fk_unit, '', 0, (float) $pu_ht_devise);
if ($result > 0) {
$db->commit();
$ret = $object->fetch($object->id); // Reload to get new records
$object->fetch_thirdparty();
if ($ret > 0) {
$object->fetch_thirdparty();
}
if (!getDolGlobalString('MAIN_DISABLE_PDF_AUTOUPDATE')) {
// Define output language
@ -1460,6 +1475,8 @@ if (empty($reshook)) {
unset($_POST['date_endmonth']);
unset($_POST['date_endyear']);
} else {
$db->rollback();
setEventMessages($object->error, $object->errors, 'errors');
}
}
@ -1551,6 +1568,7 @@ if (empty($reshook)) {
}
} elseif ($action == 'updateline' && $usercancreate && GETPOST('save')) {
// Update a line
// Clean parameters
$date_start = '';
$date_end = '';
@ -1619,15 +1637,15 @@ if (empty($reshook)) {
}
// Define special_code for special lines
$special_code = GETPOST('special_code');
$special_code = GETPOSTINT('special_code');
if (!GETPOST('qty')) {
$special_code = 3;
}
$remise_percent = GETPOST('remise_percent') != '' ? price2num(GETPOST('remise_percent'), '', 2) : 0;
$price_base_type = 'HT';
$pu = $pu_ht;
$price_base_type = 'HT';
if (empty($pu) && !empty($pu_ttc)) {
$pu = $pu_ttc;
$price_base_type = 'TTC';
@ -1654,12 +1672,12 @@ if (empty($reshook)) {
// Check price is not lower than minimum
if ($usermustrespectpricemin) {
if ($pu_equivalent && $price_min && (((float) price2num($pu_equivalent) * (1 - $remise_percent / 100)) < (float) price2num($price_min)) && $price_base_type == 'HT') {
if ($pu_equivalent && $price_min && (((float) price2num($pu_equivalent) * (1 - (float) $remise_percent / 100)) < (float) price2num($price_min)) && $price_base_type == 'HT') {
$mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, -1, $conf->currency));
setEventMessages($mesg, null, 'errors');
$error++;
$action = 'editline';
} elseif ($pu_equivalent_ttc && $price_min_ttc && (((float) price2num($pu_equivalent_ttc) * (1 - $remise_percent / 100)) < (float) price2num($price_min_ttc)) && $price_base_type == 'TTC') {
} elseif ($pu_equivalent_ttc && $price_min_ttc && (((float) price2num($pu_equivalent_ttc) * (1 - (float) $remise_percent / 100)) < (float) price2num($price_min_ttc)) && $price_base_type == 'TTC') {
$mesg = $langs->trans("CantBeLessThanMinPriceInclTax", price(price2num($price_min_ttc, 'MU'), 0, $langs, 0, 0, -1, $conf->currency));
setEventMessages($mesg, null, 'errors');
$error++;
@ -1694,6 +1712,8 @@ if (empty($reshook)) {
}
if (!$error) {
$db->begin();
if (!$user->hasRight('margins', 'creer')) {
foreach ($object->lines as &$line) {
if ($line->id == GETPOSTINT('lineid')) {
@ -1706,7 +1726,10 @@ if (empty($reshook)) {
$result = $object->updateline(GETPOSTINT('lineid'), $description, (float) $pu, (float) $qty, (float) $remise_percent, $vat_rate, $localtax1_rate, $localtax2_rate, $price_base_type, $info_bits, $date_start, $date_end, $type, GETPOSTINT('fk_parent_line'), 0, (int) $fournprice, $buyingprice, $label, $special_code, $array_options, GETPOSTINT('units'), (float) $pu_ht_devise);
if ($result >= 0) {
$db->commit();
if (!getDolGlobalString('MAIN_DISABLE_PDF_AUTOUPDATE')) {
// Define output language
$outputlangs = $langs;
@ -1753,6 +1776,8 @@ if (empty($reshook)) {
unset($_POST['date_endmonth']);
unset($_POST['date_endyear']);
} else {
$db->rollback();
setEventMessages($object->error, $object->errors, 'errors');
}
}

View file

@ -9,6 +9,7 @@
* Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024-2025 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2026 Nick Fragoulis
*
* 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
@ -145,8 +146,8 @@ print '<span class="opacitymedium">'.$langs->trans("DescTaxAndDividendsArea").'<
print "<br>";
if (isModEnabled('tax') && $user->hasRight('tax', 'charges', 'lire')) {
$sql = "SELECT c.id, c.libelle as label,";
$sql .= " cs.rowid, cs.libelle, cs.fk_type as type, cs.periode as period, cs.date_ech, cs.amount as total,";
$sql = "SELECT c.id, c.libelle as type_label,";
$sql .= " cs.rowid, cs.libelle as label, cs.fk_type as type, cs.periode as period, cs.date_ech, cs.amount as total,";
$sql .= " pc.rowid as pid, pc.datep, pc.amount as totalpaid, pc.num_paiement as num_payment, pc.fk_bank,";
$sql .= " pct.code as payment_code,";
$sql .= " ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number, ba.fk_accountancy_journal, ba.label as blabel";
@ -160,7 +161,7 @@ if (isModEnabled('tax') && $user->hasRight('tax', 'charges', 'lire')) {
$sql .= " AND cs.entity IN (".getEntity("tax").")";
if ($year > 0) {
$sql .= " AND (";
// If period defined, we use it as dat criteria, if not we use date echeance,
// If period defined, we use it as date criteria, if not we use date echeance,
// so we are compatible when period is not mandatory
$sql .= " (cs.periode IS NOT NULL AND cs.periode between '".$db->idate(dol_get_first_day($year))."' AND '".$db->idate(dol_get_last_day($year))."')";
$sql .= " OR (cs.periode IS NULL AND cs.date_ech between '".$db->idate(dol_get_first_day($year))."' AND '".$db->idate(dol_get_last_day($year))."')";
@ -184,8 +185,8 @@ if (isModEnabled('tax') && $user->hasRight('tax', 'charges', 'lire')) {
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print_liste_field_titre("PeriodEndDate", $_SERVER["PHP_SELF"], "cs.date_ech", "", $param, 'width="120"', $sortfield, $sortorder, 'nowraponall ');
print_liste_field_titre("Label", $_SERVER["PHP_SELF"], "c.libelle", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("Type", $_SERVER["PHP_SELF"], "cs.fk_type", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("Label", $_SERVER["PHP_SELF"], "cs.libelle", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("Type", $_SERVER["PHP_SELF"], "c.libelle", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("ExpectedToPay", $_SERVER["PHP_SELF"], "cs.amount", "", $param, 'class="right"', $sortfield, $sortorder);
print_liste_field_titre("RefPayment", $_SERVER["PHP_SELF"], "pc.rowid", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("DatePayment", $_SERVER["PHP_SELF"], "pc.datep", "", $param, 'align="center"', $sortfield, $sortorder);
@ -221,7 +222,7 @@ if (isModEnabled('tax') && $user->hasRight('tax', 'charges', 'lire')) {
print $socialcontrib->getNomUrl(1, '20');
print '</td>';
// Type
print '<td class="tdoverflowmax200"><a href="'.DOL_URL_ROOT.'/compta/sociales/list.php?filtre=cs.fk_type:'.$obj->type.'">'.$obj->label.'</a></td>';
print '<td class="tdoverflowmax200"><a href="'.DOL_URL_ROOT.'/compta/sociales/list.php?filtre=cs.fk_type:'.$obj->type.'">'.$obj->type_label.'</a></td>';
// Expected to pay
print '<td class="right"><span class="amount">'.price($obj->total).'</span></td>';
// Ref payment
@ -275,7 +276,7 @@ if (isModEnabled('tax') && $user->hasRight('tax', 'charges', 'lire')) {
print '<td colspan="3" class="liste_total">'.$langs->trans("Total").'</td>';
// Total here has no sens because we can have several time the same line
// Total here makes no sense because we can have the same line several times.
//print '<td class="liste_total right">'.price($total).'</td>';
print '<td class="liste_total right"></td>';
@ -306,7 +307,7 @@ if (isModEnabled('tax') && $user->hasRight('tax', 'charges', 'lire')) {
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pct ON ptva.fk_typepaiement = pct.id";
$sql .= " WHERE pv.entity IN (".getEntity("tax").")";
if ($year > 0) {
// If period defined, we use it as dat criteria, if not we use date echeance,
// If period defined, we use it as date criteria, if not we use date echeance,
// so we are compatible when period is not mandatory
$sql .= " AND pv.datev between '".$db->idate(dol_get_first_day($year, 1, false))."' AND '".$db->idate(dol_get_last_day($year, 12, false))."'";
}
@ -410,7 +411,7 @@ if (isModEnabled('tax') && $user->hasRight('tax', 'charges', 'lire')) {
print '<td class="liste_total" colspan="2">'.$langs->trans("Total").'</td>';
// Total here has no sens because we can have several time the same line
// Total here makes no sense because we can have the same line several times.
//print '<td class="right">'.price($totaltopay).'</td>';
print '<td class="liste_total">&nbsp;</td>';
@ -461,7 +462,7 @@ while ($j < $numlt) {
$sql .= " FROM ".MAIN_DB_PREFIX."localtax as pv";
$sql .= " WHERE pv.entity = ".$conf->entity." AND localtaxtype = ".((int) $j);
if ($year > 0) {
// If period defined, we use it as dat criteria, if not we use date echeance,
// If period defined, we use it as date criteria, if not we use date echeance,
// so we are compatible when period is not mandatory
$sql .= " AND pv.datev between '".$db->idate(dol_get_first_day($year, 1, false))."' AND '".$db->idate(dol_get_last_day($year, 12, false))."'";
}

View file

@ -672,8 +672,8 @@ class ChargeSociales extends CommonObject
if (isset($this->paye)) {
$label .= ' '.$this->getLibStatut(5);
}
if (!empty($this->ref)) {
$label .= '<br><b>'.$langs->trans('Ref').':</b> '.$this->ref;
if (!empty($this->id)) {
$label .= '<br><b>'.$langs->trans('Ref').':</b> '.$this->id;
}
if (!empty($this->label)) {
$label .= '<br><b>'.$langs->trans('Label').':</b> '.$this->label;

View file

@ -145,8 +145,8 @@ class CLeadStatus extends CommonDict
if ($id) {
$sql_where[] = " t.rowid = ".((int) $id);
}
if ($code >= 0) {
$sql_where[] = " t.code = ".((int) $code);
if ($code) {
$sql_where[] = " t.code = '".$this->db->escape($code)."'";
}
if (count($sql_where) > 0) {
$sql .= ' WHERE '.implode(' AND ', $sql_where);

View file

@ -18,7 +18,7 @@
ALTER TABLE llx_blockedlog ADD INDEX idx_entity_action_certified (entity,action);
ALTER TABLE llx_blockedlog ADD INDEX idx_ref_object (ref_object);
ALTER TABLE llx_blockedlog ADD INDEX idx_linktoref (linktoref);
-- VMYSQL4.3 ALTER TABLE llx_blockedlog ADD INDEX idx_linktoref (linktoref(255));
ALTER TABLE llx_blockedlog ADD INDEX signature (signature);
-- For debug fields

View file

@ -1209,11 +1209,14 @@ if ($search_opp_amount != '') {
if ($search_budget_amount != '') {
$param .= '&search_budget_amount='.urlencode($search_budget_amount);
}
if ($search_usage_opportunity != '') {
$param .= '&search_usage_opportunity='.urlencode($search_usage_opportunity);
}
if ($search_usage_task != '') {
$param .= '&search_usage_task='.urlencode($search_usage_task);
}
if ($search_usage_bill_time != '') {
$param .= '&search_usage_opportunity='.urlencode($search_usage_bill_time);
$param .= '&search_usage_bill_time='.urlencode($search_usage_bill_time);
}
if ($search_usage_event_organization != '') {
$param .= '&search_usage_event_organization='.urlencode($search_usage_event_organization);