This commit is contained in:
Laurent Destailleur (aka Eldy) 2025-02-05 11:16:03 +01:00
commit d97a91b83e
11 changed files with 72 additions and 37 deletions

View File

@ -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

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>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
*
* 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');

View File

@ -117,12 +117,12 @@ class AccountancyImport
/**
* Compute direction
* Compute direction
*
* @param array<array{val:null|int|float|string,type:int<-1,1>}> $arrayrecord Array of read values: [fieldpos] => (['val']=>val, ['type']=>-1=null,0=blank,1=string), [fieldpos+1]...
* @param array<string,string> $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 "";
}
/**

View File

@ -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');

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>
@ -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';

View File

@ -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"';

View File

@ -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 = '<div style="display: flex; align-items: center; justify-content: flex-end; padding-right: 150px">';
@ -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') {

View File

@ -103,7 +103,7 @@ if (!getDolGlobalString('EXPENSEREPORT_DISABLE_ATTACHMENT_ON_LINES')) {
print '<div class="photoref backgroundblank">';
// 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 '</div>';
if (empty($urlforhref) || empty($thumbshown)) {

View File

@ -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) {

View File

@ -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

View File

@ -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");
}