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

This commit is contained in:
Laurent Destailleur (aka Eldy) 2025-02-05 11:10:51 +01:00
commit 3ad51f2a19
10 changed files with 91 additions and 54 deletions

View File

@ -91,7 +91,7 @@ $tablib[32] = "DictionaryAccountancyCategory";
// Requests to extract data
$tabsql = array();
$tabsql[32] = "SELECT a.rowid as rowid, a.code as code, a.label, a.range_account, a.category_type, a.formula, a.position as position, a.fk_country as country_id, c.code as country_code, c.label as country, a.active FROM ".MAIN_DB_PREFIX."c_accounting_category as a, ".MAIN_DB_PREFIX."c_country as c WHERE a.fk_country=c.rowid and c.active=1";
$tabsql[32] = "SELECT a.rowid as rowid, a.code as code, a.label, a.range_account, a.category_type, a.formula, a.position as position, a.fk_country as country_id, c.code as country_code, c.label as country, a.active FROM ".MAIN_DB_PREFIX."c_accounting_category as a, ".MAIN_DB_PREFIX."c_country as c WHERE a.fk_country=c.rowid AND c.active=1 AND a.entity IN (".getEntity('c_accounting_category').")";
// Criteria to sort dictionaries
$tabsqlsort = array();
@ -103,11 +103,11 @@ $tabfield[32] = "code,label,range_account,category_type,formula,position,country
// Name of editing fields for record modification
$tabfieldvalue = array();
$tabfieldvalue[32] = "code,label,range_account,category_type,formula,position,country_id";
$tabfieldvalue[32] = "code,label,range_account,category_type,formula,position,country_id,entity";
// Name of the fields in the table for inserting a record
$tabfieldinsert = array();
$tabfieldinsert[32] = "code,label,range_account,category_type,formula,position,fk_country";
$tabfieldinsert[32] = "code,label,range_account,category_type,formula,position,fk_country,entity";
// Name of the rowid if the field is not of type autoincrement
// Example: "" if id field is "rowid" and has autoincrement on

View File

@ -1,5 +1,5 @@
<?php
/* Copyright (C) 2013-2024 Alexandre Spangaro <aspangaro@easya.solutions>
/* Copyright (C) 2013-2025 Alexandre Spangaro <alexandre@inovea-conseil.com>
*
* 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
@ -123,7 +123,7 @@ if ($result) {
$newcardbutton = empty($hookmanager->resPrint) ? '' : $hookmanager->resPrint;
if (empty($reshook)) {
$newcardbutton .= dolGetButtonTitle($langs->trans('NewFiscalYear'), '', 'fa fa-plus-circle', 'fiscalyear_card.php?action=create', '', $user->hasRight('accounting', 'fiscalyear', 'write'));
$newcardbutton .= dolGetButtonTitle($langs->trans('NewFiscalYear'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/accountancy/admin/fiscalyear_card.php?action=create', '', $user->hasRight('accounting', 'fiscalyear', 'write'));
}
$title = $langs->trans('AccountingPeriods');

View File

@ -116,12 +116,12 @@ class AccountancyImport
/**
* Compute direction
* Compute direction
*
* @param array $arrayrecord Array of read values: [fieldpos] => (['val']=>val, ['type']=>-1=null,0=blank,1=string), [fieldpos+1]...
* @param array $listfields Fields list to add
* @param int $record_key Record key
* @return string Value
* @return string Value D or C or ""
*/
public function computeDirection(&$arrayrecord, $listfields, $record_key)
{
@ -135,10 +135,10 @@ class AccountancyImport
$sens = 'C';
}
return "'" . $this->db->escape($sens) . "'";
return $sens;
}
return "''";
return "";
}
/**

View File

@ -1278,18 +1278,36 @@ if (!$error && ($action == 'updateprice' && $confirm == 'yes') && $permissiontoa
$result = $object->fetch($toselectid);
//var_dump($contcats);exit;
if ($result > 0) {
if ($obj->price_base_type == 'TTC') {
$newprice = $object->price_ttc * (100 + $pricepercentage) / 100;
$minprice = $object->price_min_ttc;
} else {
$newprice = $object->price * (100 + $pricepercentage) / 100;
$minprice = $object->price_min;
}
$res = $object->updatePrice($newprice, $obj->price_base_type, $user, $object->tva_tx, $minprice, 0, $object->tva_npr, 0, 0, array(), $object->default_vat_code);
if ($res > 0) {
$nbok++;
} else {
setEventMessages($object->error, $object->errors, 'errors');
if (getDolGlobalString('PRODUCT_PRICE_UNIQ')
|| getDolGlobalString('PRODUIT_CUSTOMER_PRICES')) {
if ($object->price_base_type == 'TTC') {
$newprice = $object->price_ttc * (100 + $pricepercentage) / 100;
$minprice = $object->price_min_ttc;
} else {
$newprice = $object->price * (100 + $pricepercentage) / 100;
$minprice = $object->price_min;
}
$res = $object->updatePrice($newprice, $object->price_base_type, $user, $object->tva_tx, $minprice, 0, $object->tva_npr, 0, 0, array(), $object->default_vat_code);
if ($res > 0) {
$nbok++;
} else {
setEventMessages($object->error, $object->errors, 'errors');
}
} elseif (getDolGlobalString('PRODUIT_MULTIPRICES')) {
$maxlevel = getDolGlobalInt('PRODUIT_MULTIPRICES_LIMIT');
for ($level = 1; $level <= $malevel; $level++) {
if ($object->price_base_type == 'TTC') {
$newprice = $object->multiprices_ttc[$level] * (100 + $pricepercentage) / 100;
$minprice = $object->multiprices_min_ttc[$level];
} else {
$newprice = $object->multiprices[$level] * (100 + $pricepercentage) / 100;
$minprice = $object->multiprices_min[$level];
}
$res = $object->updatePrice($newprice, $object->price_base_type, $user, $object->tva_tx, $minprice, $level, $object->tva_npr, 0, 0, array(), $object->default_vat_code);
if ($res > 0) {
$nbok++;
}
}
}
} else {
setEventMessages($object->error, $object->errors, 'errors');

View File

@ -1,5 +1,5 @@
<?php
/* Copyright (C) 2014-2020 Alexandre Spangaro <aspangaro@open-dsi.fr>
/* Copyright (C) 2014-2025 Alexandre Spangaro <alexandre@inovea-conseil.com>
* Copyright (C) 2020 OScss-Shop <support@oscss-shop.fr>
* Copyright (C) 2023-2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
@ -407,11 +407,11 @@ class Fiscalyear extends CommonObject
// phpcs:enable
if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
global $langs;
//$langs->load("mymodule@mymodule");
$this->labelStatus[self::STATUS_OPEN] = $langs->transnoentitiesnoconv('Draft');
$this->labelStatus[self::STATUS_CLOSED] = $langs->transnoentitiesnoconv('Enabled');
$this->labelStatusShort[self::STATUS_OPEN] = $langs->transnoentitiesnoconv('Enabled');
$this->labelStatusShort[self::STATUS_CLOSED] = $langs->transnoentitiesnoconv('Disabled');
$this->labelStatus[self::STATUS_OPEN] = $langs->transnoentitiesnoconv('FiscalYearOpened');
$this->labelStatus[self::STATUS_CLOSED] = $langs->transnoentitiesnoconv('FiscalYearClosed');
$this->labelStatusShort[self::STATUS_OPEN] = $langs->transnoentitiesnoconv('FiscalYearOpenedShort');
$this->labelStatusShort[self::STATUS_CLOSED] = $langs->transnoentitiesnoconv('FiscalYearClosedShort');
}
$statusType = 'status4';

View File

@ -382,7 +382,7 @@ class FormTicket
// Type of Ticket
print '<tr><td class="titlefield"><span class="fieldrequired"><label for="selecttype_code">'.$langs->trans("TicketTypeRequest").'</span></label></td><td>';
$this->selectTypesTickets($type_code, 'type_code', '', 2, 1, 0, 0, 'minwidth200 maxwidth500');
$this->selectTypesTickets((GETPOST('type_code', 'alpha') ? GETPOST('type_code', 'alpha') : $this->type_code), 'type_code', '', 2, 'ifone', 0, 0, 'minwidth200 maxwidth500');
print '</td></tr>';
// Group => Category
@ -391,12 +391,12 @@ class FormTicket
if ($public) {
$filter = '(public:=:1)';
}
$this->selectGroupTickets($category_code, 'category_code', $filter, 2, 1, 0, 0, 'minwidth200 maxwidth500');
$this->selectGroupTickets($category_code, 'category_code', $filter, 2, 'ifone', 0, 0, 'minwidth200 maxwidth500');
print '</td></tr>';
// Severity => Priority
print '<tr><td><span class="fieldrequired"><label for="selectseverity_code">'.$langs->trans("TicketSeverity").'</span></label></td><td>';
$this->selectSeveritiesTickets($severity_code, 'severity_code', '', 2, 1, 0, 0, 'minwidth200 maxwidth500');
$this->selectSeveritiesTickets($severity_code, 'severity_code', '', 2, 'ifone', 0, 0, 'minwidth200 maxwidth500');
print '</td></tr>';
if (isModEnabled('knowledgemanagement')) {
@ -758,8 +758,8 @@ class FormTicket
* @param string|array $selected Id of preselected field or array of Ids
* @param string $htmlname Nom de la zone select
* @param string $filtertype To filter on field type in llx_c_ticket_type (array('code'=>xx,'label'=>zz))
* @param int $format 0=id+libelle, 1=code+code, 2=code+libelle, 3=id+code
* @param int $empty 1=peut etre vide, 0 sinon
* @param int $format 0=id+label, 1=code+code, 2=code+label, 3=id+code
* @param int|string $empty 1 = can be empty or 'string' to show the string as the empty value, 0 = can't be empty, 'ifone' = can be empty but autoselected if there is one only
* @param int $noadmininfo 0=Add admin info, 1=Disable admin info
* @param int $maxlength Max length of label
* @param string $morecss More CSS
@ -785,7 +785,7 @@ class FormTicket
print '<select id="select'.$htmlname.'" class="flat minwidth100'.($morecss ? ' '.$morecss : '').'" name="'.$htmlname.($multiselect ? '[]' : '').'"'.($multiselect ? ' multiple' : '').'>';
if ($empty && !$multiselect) {
print '<option value="">&nbsp;</option>';
print '<option value="">'.((is_numeric($empty) || $empty == 'ifone') ? '&nbsp;' : $empty).'</option>';
}
if (is_array($ticketstat->cache_types_tickets) && count($ticketstat->cache_types_tickets)) {
@ -823,6 +823,8 @@ class FormTicket
print ' selected="selected"';
} elseif ($arraytypes['use_default'] == "1" && empty($selected) && !$multiselect) {
print ' selected="selected"';
} elseif (count($ticketstat->cache_types_tickets) == 1 && (!$empty || $empty == 'ifone')) { // If only 1 choice, we autoselect it
print ' selected="selected"';
}
print '>';
@ -881,10 +883,10 @@ class FormTicket
$ticketstat = new Ticket($this->db);
$ticketstat->loadCacheCategoriesTickets($publicgroups ? 1 : -1); // get list of active ticket groups
if ($use_multilevel <= 0) {
if ($use_multilevel <= 0) { // Only one combo list to select the group of ticket (default)
print '<select id="select'.$htmlname.'" class="flat minwidth100'.($morecss ? ' '.$morecss : '').'" name="'.$htmlname.'">';
if ($empty) {
print '<option value="">&nbsp;</option>';
print '<option value="">'.((is_numeric($empty) || $empty == 'ifone') ? '&nbsp;' : $empty).'</option>';
}
if (is_array($ticketstat->cache_category_tickets) && count($ticketstat->cache_category_tickets)) {
@ -929,9 +931,9 @@ class FormTicket
print ' selected="selected"';
} elseif (isset($selected) && $selected == $id) {
print ' selected="selected"';
} elseif ($arraycategories['use_default'] == "1" && empty($selected)) {
} elseif ($arraycategories['use_default'] == "1" && empty($selected) && (!$empty || $empty == 'ifone')) {
print ' selected="selected"';
} elseif (count($ticketstat->cache_category_tickets) == 1) { // If only 1 choice, we autoselect it
} elseif (count($ticketstat->cache_category_tickets) == 1 && (!$empty || $empty == 'ifone')) { // If only 1 choice, we autoselect it
print ' selected="selected"';
}
@ -1209,14 +1211,14 @@ class FormTicket
/**
* Return html list of ticket severitys (priorities)
*
* @param string $selected Id severity pre-selected
* @param string $htmlname Name of the select area
* @param string $filtertype To filter on field type in llx_c_ticket_severity (array('code'=>xx,'label'=>zz))
* @param int $format 0 = id+label, 1 = code+code, 2 = code+label, 3 = id+code
* @param int $empty 1 = can be empty, 0 = or not
* @param int $noadmininfo 0 = add admin info, 1 = disable admin info
* @param int $maxlength Max length of label
* @param string $morecss More CSS
* @param string $selected Id severity pre-selected
* @param string $htmlname Name of the select area
* @param string $filtertype To filter on field type in llx_c_ticket_severity (array('code'=>xx,'label'=>zz))
* @param int $format 0 = id+label, 1 = code+code, 2 = code+label, 3 = id+code
* @param int|string $empty 1 = can be empty or 'string' to show the string as the empty value, 0 = can't be empty, 'ifone' = can be empty but autoselected if there is one only
* @param int $noadmininfo 0 = add admin info, 1 = disable admin info
* @param int $maxlength Max length of label
* @param string $morecss More CSS
* @return void
*/
public function selectSeveritiesTickets($selected = '', $htmlname = 'ticketseverity', $filtertype = '', $format = 0, $empty = 0, $noadmininfo = 0, $maxlength = 0, $morecss = '')
@ -1237,7 +1239,7 @@ class FormTicket
print '<select id="select'.$htmlname.'" class="flat minwidth100'.($morecss ? ' '.$morecss : '').'" name="'.$htmlname.'">';
if ($empty) {
print '<option value="">&nbsp;</option>';
print '<option value="">'.((is_numeric($empty) || $empty == 'ifone') ? '&nbsp;' : $empty).'</option>';
}
if (is_array($conf->cache['severity_tickets']) && count($conf->cache['severity_tickets'])) {
@ -1273,7 +1275,9 @@ class FormTicket
print ' selected="selected"';
} elseif (isset($selected) && $selected == $id) {
print ' selected="selected"';
} elseif ($arrayseverities['use_default'] == "1" && empty($selected)) {
} elseif ($arrayseverities['use_default'] == "1" && empty($selected) && (!$empty || $empty == 'ifone')) {
print ' selected="selected"';
} elseif (count($ticketstat->cache_severity_tickets) == 1 && (!$empty || $empty == 'ifone')) { // If only 1 choice, we autoselect it
print ' selected="selected"';
}

View File

@ -103,7 +103,11 @@ if ($massaction == 'preaffecttag' && isModEnabled('category')) {
}
}
if ($massaction == 'preupdateprice') {
if ($massaction == 'preupdateprice'
&& (getDolGlobalString('PRODUCT_PRICE_UNIQ')
|| getDolGlobalString('PRODUIT_CUSTOMER_PRICES')
|| getDolGlobalString('PRODUIT_MULTIPRICES')
)) {
$formquestion = array();
$valuefield = '<div style="display: flex; align-items: center; justify-content: flex-end; padding-right: 150px">';
@ -117,7 +121,12 @@ if ($massaction == 'preupdateprice') {
'value' => $valuefield
);
print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmUpdatePrice"), $langs->trans("ConfirmUpdatePriceQuestion", count($toselect)), "updateprice", $formquestion, 1, 0, 200, 500, 1);
$descConfirmPreUpdatePrice=$langs->trans("ConfirmUpdatePriceQuestion", count($toselect));
if (getDolGlobalString('PRODUIT_MULTIPRICES')) {
$descConfirmPreUpdatePrice=$langs->trans("ConfirmUpdatePriceQuestion", count($toselect)*getDolGlobalInt('PRODUIT_MULTIPRICES_LIMIT') .' ('.$langs->transnoentities('PricingRule').', '.$langs->transnoentities('MultiPricesNumPrices').')');
}
print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmUpdatePrice"), $descConfirmPreUpdatePrice, "updateprice", $formquestion, 1, 0, 200, 500, 1);
}
if ($massaction == 'presetsupervisor') {

View File

@ -2383,7 +2383,7 @@ class CommandeFournisseur extends CommonOrder
$main = $this->db->prefix().'commande_fournisseurdet';
if (!$error) {
$sql1 = "UPDATE ".$this->db->prefix()."commandedet SET fk_commandefourndet = NULL WHERE fk_commandefourndet IN (SELECT rowid FROM ".$main." WHERE fk_commande = ".((int) $this->id).")";
$sql1 = "UPDATE ".$this->db->prefix()."commandedet SET fk_commandefourndet = NULL WHERE fk_commandefourndet IN (SELECT rowid FROM ".$this->db->sanitize($main)." WHERE fk_commande = ".((int) $this->id).")";
dol_syslog(__METHOD__." linked order lines", LOG_DEBUG);
if (!$this->db->query($sql1)) {
$error++;
@ -2394,7 +2394,7 @@ class CommandeFournisseur extends CommonOrder
if (!$error) {
$ef = $main."_extrafields";
$sql = "DELETE FROM $ef WHERE fk_object IN (SELECT rowid FROM $main WHERE fk_commande = ".((int) $this->id).")";
$sql = "DELETE FROM ".$this->db->sanitize($ef)." WHERE fk_object IN (SELECT rowid FROM ".$this->db->sanitize($main)." WHERE fk_commande = ".((int) $this->id).")";
dol_syslog(get_class($this)."::delete extrafields lines", LOG_DEBUG);
if (!$this->db->query($sql)) {
$this->error = $this->db->lasterror();
@ -2404,7 +2404,7 @@ class CommandeFournisseur extends CommonOrder
}
if (!$error) {
$sql = "DELETE FROM ".$this->db->prefix()."commande_fournisseurdet WHERE fk_commande =".((int) $this->id);
$sql = "DELETE FROM ".$this->db->prefix()."commande_fournisseurdet WHERE fk_commande = ".((int) $this->id);
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
if (!$this->db->query($sql)) {
$this->error = $this->db->lasterror();
@ -2414,7 +2414,7 @@ class CommandeFournisseur extends CommonOrder
}
if (!$error) {
$sql = "DELETE FROM ".$this->db->prefix()."commande_fournisseur WHERE rowid =".((int) $this->id);
$sql = "DELETE FROM ".$this->db->prefix()."commande_fournisseur WHERE rowid = ".((int) $this->id);
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
if ($resql = $this->db->query($sql)) {
if ($this->db->affected_rows($resql) < 1) {

View File

@ -277,6 +277,10 @@ ImportDataset_tax_contrib=Social/fiscal taxes
ImportDataset_tax_vat=VAT payments
ErrorBankAccountNotFound=Error: Bank account not found
FiscalPeriod=Accounting period
FiscalYearOpened=Fiscal year opened
FiscalYearClosed=Fiscal year closed
FiscalYearOpenedShort=Opened
FiscalYearClosedShort=Closed
ListSocialContributionAssociatedProject=List of social contributions associated with the project
DeleteFromCat=Remove from accounting group
AccountingAffectation=Accounting assignment

View File

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