diff --git a/htdocs/accountancy/admin/categories_list.php b/htdocs/accountancy/admin/categories_list.php index b937d9c89bd..45bb66e8d23 100644 --- a/htdocs/accountancy/admin/categories_list.php +++ b/htdocs/accountancy/admin/categories_list.php @@ -99,7 +99,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(); @@ -111,11 +111,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 diff --git a/htdocs/accountancy/admin/fiscalyear.php b/htdocs/accountancy/admin/fiscalyear.php index dae6e786fca..f163ca00544 100644 --- a/htdocs/accountancy/admin/fiscalyear.php +++ b/htdocs/accountancy/admin/fiscalyear.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2013-2025 Alexandre Spangaro * Copyright (C) 2024 Frédéric France * * This program is free software; you can redistribute it and/or modify @@ -133,7 +133,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'); diff --git a/htdocs/accountancy/class/accountancyimport.class.php b/htdocs/accountancy/class/accountancyimport.class.php index 11c9f9c82d4..4394a0eac2a 100644 --- a/htdocs/accountancy/class/accountancyimport.class.php +++ b/htdocs/accountancy/class/accountancyimport.class.php @@ -117,12 +117,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) { @@ -139,7 +139,7 @@ class AccountancyImport return $sens; } - return "''"; + return ""; } /** diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index e5a191b8135..62280a7cce2 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -1358,18 +1358,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'); diff --git a/htdocs/core/class/fiscalyear.class.php b/htdocs/core/class/fiscalyear.class.php index 571b2b1fda3..9bc2935b2a2 100644 --- a/htdocs/core/class/fiscalyear.class.php +++ b/htdocs/core/class/fiscalyear.class.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2014-2025 Alexandre Spangaro * Copyright (C) 2020 OScss-Shop * Copyright (C) 2023-2024 Frédéric France * Copyright (C) 2024 MDW @@ -406,11 +406,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'; diff --git a/htdocs/core/class/html.formticket.class.php b/htdocs/core/class/html.formticket.class.php index 80370cd324e..27f45a9ecab 100644 --- a/htdocs/core/class/html.formticket.class.php +++ b/htdocs/core/class/html.formticket.class.php @@ -1042,7 +1042,7 @@ 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 && (!$empty || $empty == 'ifone')) { // If only 1 choice, we autoselect it print ' selected="selected"'; @@ -1386,7 +1386,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"'; } elseif (count($conf->cache['severity_tickets']) == 1 && (!$empty || $empty == 'ifone')) { // If only 1 choice, we autoselect it print ' selected="selected"'; diff --git a/htdocs/core/tpl/massactions_pre.tpl.php b/htdocs/core/tpl/massactions_pre.tpl.php index 5b6da9dc1de..eee6cda2b3d 100644 --- a/htdocs/core/tpl/massactions_pre.tpl.php +++ b/htdocs/core/tpl/massactions_pre.tpl.php @@ -133,7 +133,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 = '
'; @@ -147,7 +151,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') { diff --git a/htdocs/expensereport/tpl/expensereport_linktofile.tpl.php b/htdocs/expensereport/tpl/expensereport_linktofile.tpl.php index c565fe32894..df5f1d6cf70 100644 --- a/htdocs/expensereport/tpl/expensereport_linktofile.tpl.php +++ b/htdocs/expensereport/tpl/expensereport_linktofile.tpl.php @@ -103,7 +103,7 @@ if (!getDolGlobalString('EXPENSEREPORT_DISABLE_ATTACHMENT_ON_LINES')) { print '
'; // TODO: Check that $minifile has a proper value here (set in true part of if, not else part). - print $thumbshown ? $thumbshown : ($minifile ? img_mime($minifile) : null); + print $thumbshown ? $thumbshown : (empty($minifile) ? '' : img_mime($minifile)); print '
'; if (empty($urlforhref) || empty($thumbshown)) { diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 837a21b9bb2..3bf206313c9 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -2462,7 +2462,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++; @@ -2473,7 +2473,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(); @@ -2483,7 +2483,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(); @@ -2493,7 +2493,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) { diff --git a/htdocs/langs/en_US/compta.lang b/htdocs/langs/en_US/compta.lang index 0e88b2ab2f5..723bb8cf0ae 100644 --- a/htdocs/langs/en_US/compta.lang +++ b/htdocs/langs/en_US/compta.lang @@ -283,6 +283,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 diff --git a/htdocs/product/list.php b/htdocs/product/list.php index b83d3a871ba..aa378d1c85c 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -648,7 +648,7 @@ if ($search_accountancy_code_buy_intra) { if ($search_accountancy_code_buy_export) { $sql .= natural_search($alias_product_perentity . '.accountancy_code_buy_export', clean_account($search_accountancy_code_buy_export)); } -if (getDolGlobalString('PRODUCT_USE_UNITS') && $search_units && $search_units != '-1') { +if (getDolGlobalString('PRODUCT_USE_UNITS') && !empty($search_units) && $search_units != '-1' && $search_units !== 'none') { $sql .= natural_search('cu.rowid', $search_units); } @@ -874,7 +874,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"); }