Skip to content

Commit

Permalink
Merge branch '18.0' into 18_contract_stay_edit_line_on_failed_update
Browse files Browse the repository at this point in the history
  • Loading branch information
FHenry authored Jul 24, 2024
2 parents cd88f40 + 1495c9d commit 34680e8
Show file tree
Hide file tree
Showing 14 changed files with 106 additions and 49 deletions.
7 changes: 2 additions & 5 deletions htdocs/accountancy/bookkeeping/export.php
Original file line number Diff line number Diff line change
Expand Up @@ -1190,7 +1190,6 @@
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
$objectstatic = new Facture($db);
$objectstatic->fetch($line->fk_doc);
//$modulepart = 'facture';

$filename = dol_sanitizeFileName($line->doc_ref);
$filedir = $conf->facture->dir_output.'/'.dol_sanitizeFileName($line->doc_ref);
Expand All @@ -1202,19 +1201,17 @@
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
$objectstatic = new FactureFournisseur($db);
$objectstatic->fetch($line->fk_doc);
//$modulepart = 'invoice_supplier';

$filename = dol_sanitizeFileName($line->doc_ref);
$filedir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($line->fk_doc, 2, 0, 0, $objectstatic, $modulepart).dol_sanitizeFileName($line->doc_ref);
$subdir = get_exdir($objectstatic->id, 2, 0, 0, $objectstatic, $modulepart).dol_sanitizeFileName($line->doc_ref);
$filedir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($line->fk_doc, 2, 0, 0, $objectstatic, $objectstatic->element).dol_sanitizeFileName($line->doc_ref);
$subdir = get_exdir($objectstatic->id, 2, 0, 0, $objectstatic, $objectstatic->element).dol_sanitizeFileName($line->doc_ref);
$documentlink = $formfile->getDocumentsLink($objectstatic->element, $subdir, $filedir);
} elseif ($line->doc_type == 'expense_report') {
$langs->loadLangs(array('trips'));

require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
$objectstatic = new ExpenseReport($db);
$objectstatic->fetch($line->fk_doc);
//$modulepart = 'expensereport';

$filename = dol_sanitizeFileName($line->doc_ref);
$filedir = $conf->expensereport->dir_output.'/'.dol_sanitizeFileName($line->doc_ref);
Expand Down
34 changes: 29 additions & 5 deletions htdocs/accountancy/journal/bankjournal.php
Original file line number Diff line number Diff line change
Expand Up @@ -212,10 +212,11 @@
$tabtype = array();
$tabmoreinfo = array();

// Loop on each line into llx_bank table. For each line, we should get:
// Loop on each line into the llx_bank table. For each line, we should get:
// one line tabpay = line into bank
// one line for bank record = tabbq
// one line for thirdparty record = tabtp
// Note: tabcompany is used to store the subledger account
$i = 0;
while ($i < $num) {
$obj = $db->fetch_object($result);
Expand Down Expand Up @@ -263,7 +264,8 @@
);

// Set accountancy code for user
// $obj->accountancy_code is the accountancy_code of table u=user but it is defined only if a link with type 'user' exists)
// $obj->accountancy_code is the accountancy_code of table u=user (but it is defined only if
// a link with type 'user' exists and user as a subledger account)
$compta_user = (!empty($obj->accountancy_code) ? $obj->accountancy_code : '');

$tabuser[$obj->rowid] = array(
Expand Down Expand Up @@ -307,15 +309,25 @@
// get_url may return -1 which is not traversable
if (is_array($links) && count($links) > 0) {
$is_sc = false;
$is_expensereport = false;
foreach ($links as $v) {
if ($v['type'] == 'sc') {
$is_sc = true;
break;
}
if ($v['type'] == 'payment_expensereport') {
$is_expensereport = true;
break;
}
}

// Now loop on each link of record in bank (code similar to bankentries_list.php)
foreach ($links as $key => $val) {
if ($links[$key]['type'] == 'user' && !$is_sc) continue;
if ($links[$key]['type'] == 'user' && !$is_sc && !$is_expensereport) {
// We must avoid as much as possible this "continue". If we want to jump to next loop, it means we don't want to process
// the case the link is user (often because managed by hard coded code into another link), and we must avoid this.
continue;
}
if (in_array($links[$key]['type'], array('sc', 'payment_sc', 'payment', 'payment_supplier', 'payment_vat', 'payment_expensereport', 'banktransfert', 'payment_donation', 'member', 'payment_loan', 'payment_salary', 'payment_various'))) {
// So we excluded 'company' and 'user' here. We want only payment lines

Expand Down Expand Up @@ -364,13 +376,25 @@
$userstatic->lastname = $tabuser[$obj->rowid]['lastname'];
$userstatic->statut = $tabuser[$obj->rowid]['status'];
$userstatic->accountancy_code = $tabuser[$obj->rowid]['accountancy_code'];
// For a payment of social contribution, we have a link sc + user.
// but we already fill the $tabpay[$obj->rowid]["soclib"] in the line 'sc'.
// If we fill it here to, we must concat
if ($userstatic->id > 0) {
$tabpay[$obj->rowid]["soclib"] = $userstatic->getNomUrl(1, 'accountancy', 0);
if ($is_sc) {
$tabpay[$obj->rowid]["soclib"] .= ' '.$userstatic->getNomUrl(1, 'accountancy', 0);
} else {
$tabpay[$obj->rowid]["soclib"] = $userstatic->getNomUrl(1, 'accountancy', 0);
}
} else {
$tabpay[$obj->rowid]["soclib"] = '???'; // Should not happen, but happens with old data when id of user was not saved on expense report payment.
}

if ($compta_user) {
$tabtp[$obj->rowid][$compta_user] += $amounttouse;
if ($is_sc) {
//$tabcompany[$obj->rowid][$compta_user] += $amounttouse;
} else {
$tabtp[$obj->rowid][$compta_user] += $amounttouse;
}
}
} elseif ($links[$key]['type'] == 'sc') {
$chargestatic->id = $links[$key]['url_id'];
Expand Down
22 changes: 11 additions & 11 deletions htdocs/accountancy/journal/expensereportsjournal.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<?php
/* Copyright (C) 2007-2010 Laurent Destailleur <[email protected]>
* Copyright (C) 2007-2010 Jean Heimburger <[email protected]>
* Copyright (C) 2011 Juanjo Menent <[email protected]>
* Copyright (C) 2012 Regis Houssin <[email protected]>
* Copyright (C) 2013-2023 Alexandre Spangaro <[email protected]>
* Copyright (C) 2013-2016 Olivier Geffroy <[email protected]>
* Copyright (C) 2013-2016 Florian Henry <[email protected]>
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2018 Eric Seigne <[email protected]>
/* Copyright (C) 2007-2010 Laurent Destailleur <[email protected]>
* Copyright (C) 2007-2010 Jean Heimburger <[email protected]>
* Copyright (C) 2011 Juanjo Menent <[email protected]>
* Copyright (C) 2012 Regis Houssin <[email protected]>
* Copyright (C) 2013-2024 Alexandre Spangaro <[email protected]>
* Copyright (C) 2013-2016 Olivier Geffroy <[email protected]>
* Copyright (C) 2013-2016 Florian Henry <[email protected]>
* Copyright (C) 2018 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2018 Eric Seigne <[email protected]>
*
* 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
Expand Down Expand Up @@ -155,8 +155,8 @@

$vatdata = getTaxesFromId($obj->tva_tx.($obj->vat_src_code ? ' ('.$obj->vat_src_code.')' : ''), $mysoc, $mysoc, 0);
$compta_tva = (!empty($vatdata['accountancy_code_buy']) ? $vatdata['accountancy_code_buy'] : $account_vat);
$compta_localtax1 = (!empty($vatdata['accountancy_code_buy']) ? $vatdata['accountancy_code_buy'] : $cpttva);
$compta_localtax2 = (!empty($vatdata['accountancy_code_buy']) ? $vatdata['accountancy_code_buy'] : $cpttva);
$compta_localtax1 = (!empty($vatdata['accountancy_code_buy']) ? $vatdata['accountancy_code_buy'] : $account_vat);
$compta_localtax2 = (!empty($vatdata['accountancy_code_buy']) ? $vatdata['accountancy_code_buy'] : $account_vat);

// Define array to display all VAT rates that use this accounting account $compta_tva
if (price2num($obj->tva_tx) || !empty($obj->vat_src_code)) {
Expand Down
2 changes: 1 addition & 1 deletion htdocs/categories/traduction.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@

foreach ($object->multilangs as $key => $value) { // recording of new values in the object
$libelle = GETPOST('libelle-'.$key, 'alpha');
$desc = GETPOST('desc-'.$key);
$desc = GETPOST('desc-'.$key, 'restricthtml');

if (empty($libelle)) {
$error++;
Expand Down
4 changes: 3 additions & 1 deletion htdocs/comm/propal/class/propal.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1415,7 +1415,9 @@ public function createFromClone(User $user, $socid = 0, $forceentity = null, $up
}

// reset ref_client
$object->ref_client = '';
if (!getDolGlobalString('MAIN_KEEP_REF_CUSTOMER_ON_CLONING')) {
$object->ref_client = '';
}

// TODO Change product price if multi-prices
} else {
Expand Down
8 changes: 4 additions & 4 deletions htdocs/core/modules/expedition/doc/pdf_espadon.modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -847,11 +847,11 @@ protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs
$object->volume_units = $object->size_units * 3;
}

if ($totalWeight != '') {
$totalWeighttoshow = showDimensionInBestUnit($totalWeight, 0, "weight", $outputlangs);
if (!empty($totalWeight)) {
$totalWeighttoshow = showDimensionInBestUnit($totalWeight, 0, "weight", $outputlangs, -1, 'no', 1);
}
if ($totalVolume != '') {
$totalVolumetoshow = showDimensionInBestUnit($totalVolume, 0, "volume", $outputlangs);
if (!empty($totalVolume)) {
$totalVolumetoshow = showDimensionInBestUnit($totalVolume, 0, "volume", $outputlangs, -1, 'no', 1);
}
if ($object->trueWeight) {
$totalWeighttoshow = showDimensionInBestUnit($object->trueWeight, $object->weight_units, "weight", $outputlangs);
Expand Down
8 changes: 4 additions & 4 deletions htdocs/core/modules/expedition/doc/pdf_rouget.modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -734,11 +734,11 @@ protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs
$object->volume_units = $object->size_units * 3;
}

if ($totalWeight != '') {
$totalWeighttoshow = showDimensionInBestUnit($totalWeight, 0, "weight", $outputlangs);
if (!empty($totalWeight)) {
$totalWeighttoshow = showDimensionInBestUnit($totalWeight, 0, "weight", $outputlangs, -1, 'no', 1);
}
if ($totalVolume != '') {
$totalVolumetoshow = showDimensionInBestUnit($totalVolume, 0, "volume", $outputlangs);
if (!empty($totalVolume)) {
$totalVolumetoshow = showDimensionInBestUnit($totalVolume, 0, "volume", $outputlangs, -1, 'no', 1);
}
if (!empty($object->trueWeight)) {
$totalWeighttoshow = showDimensionInBestUnit($object->trueWeight, $object->weight_units, "weight", $outputlangs);
Expand Down
3 changes: 2 additions & 1 deletion htdocs/fourn/class/fournisseur.commande.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ public function fetch_lines($only_product = 0)
$sql = "SELECT l.rowid, l.fk_commande, l.ref as ref_supplier, l.fk_product, l.product_type, l.label, l.description, l.qty,";
$sql .= " l.vat_src_code, l.tva_tx, l.remise_percent, l.subprice,";
$sql .= " l.localtax1_tx, l. localtax2_tx, l.localtax1_type, l. localtax2_type, l.total_localtax1, l.total_localtax2,";
$sql .= " l.total_ht, l.total_tva, l.total_ttc, l.special_code, l.fk_parent_line, l.rang,";
$sql .= " l.total_ht, l.total_tva, l.total_ttc, l.info_bits, l.special_code, l.fk_parent_line, l.rang,";
$sql .= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.description as product_desc, p.tobatch as product_tobatch, p.barcode as product_barcode,";
$sql .= " l.fk_unit,";
$sql .= " l.date_start, l.date_end,";
Expand Down Expand Up @@ -633,6 +633,7 @@ public function fetch_lines($only_product = 0)
$line->multicurrency_total_tva = $objp->multicurrency_total_tva;
$line->multicurrency_total_ttc = $objp->multicurrency_total_ttc;

$line->info_bits = $objp->info_bits;
$line->special_code = $objp->special_code;
$line->fk_parent_line = $objp->fk_parent_line;

Expand Down
53 changes: 41 additions & 12 deletions htdocs/includes/restler/framework/Luracast/Restler/AutoLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,8 @@ private function loadLastResort($className, $loader = null)
return $this->loadThisLoader($className, $loader);
}
foreach ($loaders as $loader)
if (false !== $file = $this->loadThisLoader($className, $loader))
return $file;
if (false !== $file = $this->loadThisLoader($className, $loader))
return $file;

return false;
}
Expand All @@ -285,23 +285,52 @@ private function loadLastResort($className, $loader = null)
*/
private function loadThisLoader($className, $loader)
{
if (is_array($loader)
&& is_callable($loader)) {
$b = new $loader[0];
//avoid PHP Fatal error: Uncaught Error: Access to undeclared static property: Composer\\Autoload\\ClassLoader::$loader
//in case of multiple autoloader systems
if (property_exists($b, $loader[1])) {
if (false !== $file = $b::$loader[1]($className)
&& $this->exists($className, $b::$loader[1])) {
return $file;
}
}
} elseif (is_callable($loader)
&& false !== $file = $loader($className)
&& $this->exists($className, $loader)) {
return $file;
}
return false;

/* other code tested to reduce autoload conflict
$s = '';
if (is_array($loader)
&& is_callable($loader)) {
// @CHANGE DOL avoid autoload conflict
if (!preg_match('/LuraCast/', get_class($loader[0]))) {
return false;
}
$b = new $loader[0];
//avoid PHP Fatal error: Uncaught Error: Access to undeclared static property: Composer\\Autoload\\ClassLoader::$loader
// @CHANGE DOL avoid PHP Fatal error: Uncaught Error: Access to undeclared static property: Composer\\Autoload\\ClassLoader::$loader
//in case of multiple autoloader systems
if (property_exists($b, $loader[1])) {
if (false !== $file = $b::$loader[1]($className)
&& $this->exists($className, $b::$loader[1])) {
return $file;
}
&& $this->exists($className, $b::$loader[1])) {
return $file;
}
}
} elseif (is_callable($loader, false, $s)) {
// @CHANGE DOL avoid PHP infinite loop (detected when xdebug is on)
if ($s == 'Luracast\Restler\AutoLoader::__invoke') {
return false;
}
if (false !== ($file = $loader($className)) && $this->exists($className, $loader)) {
return $file;
}
} elseif (is_callable($loader)
&& false !== $file = $loader($className)
&& $this->exists($className, $loader)) {
return $file;
}
return false;
*/
}

/**
Expand Down Expand Up @@ -417,7 +446,7 @@ public function __invoke($className)
if (false !== $includeReference = $this->discover($className))
return $includeReference;

static::thereCanBeOnlyOne();
//static::thereCanBeOnlyOne();

if (false !== $includeReference = $this->loadAliases($className))
return $includeReference;
Expand All @@ -426,7 +455,7 @@ public function __invoke($className)
return $includeReference;

if (false !== $includeReference = $this->loadLastResort($className))
return $includeReference;
return $includeReference;

static::seen($className, true);
return null;
Expand Down
1 change: 1 addition & 0 deletions htdocs/main.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -1744,6 +1744,7 @@ function top_htmlhead($head, $title = '', $disablejs = 0, $disablehead = 0, $arr
}
// Refresh value of MAIN_IHM_PARAMS_REV before forging the parameter line.
if (GETPOST('dol_resetcache')) {
include_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
dolibarr_set_const($db, "MAIN_IHM_PARAMS_REV", getDolGlobalInt('MAIN_IHM_PARAMS_REV') + 1, 'chaine', 0, '', $conf->entity);
}

Expand Down
5 changes: 4 additions & 1 deletion htdocs/product/class/product.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@ class Product extends CommonObject
'facturedet' => array('name' => 'Invoice', 'parent' => 'facture', 'parentkey' => 'fk_facture'),
'contratdet' => array('name' => 'Contract', 'parent' => 'contrat', 'parentkey' => 'fk_contrat'),
'facture_fourn_det' => array('name' => 'SupplierInvoice', 'parent' => 'facture_fourn', 'parentkey' => 'fk_facture_fourn'),
'commande_fournisseurdet' => array('name' => 'SupplierOrder', 'parent' => 'commande_fournisseur', 'parentkey' => 'fk_commande')
'commande_fournisseurdet' => array('name' => 'SupplierOrder', 'parent' => 'commande_fournisseur', 'parentkey' => 'fk_commande'),
'mrp_production' => array('name' => 'Mo', 'parent' => 'mrp_mo', 'parentkey' => 'fk_mo' ),
'bom_bom' => array('name' => 'BOM'),
'bom_bomline' => array('name' => 'BOMLine', 'parent' => 'bom_bom', 'parentkey' => 'fk_bom'),
);

/**
Expand Down
2 changes: 1 addition & 1 deletion htdocs/product/stock/replenish.php
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@
$sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'product_stock as s ON p.rowid = s.fk_product';
$sql .= ' AND s.fk_entrepot IN (' . $db->sanitize($list_warehouse) . ')';

$list_warehouse_selected = ($fk_entrepot < 0 || empty($fk_entrepot)) ? '0' : $fk_entrepot;
$list_warehouse_selected = ($fk_entrepot < 0 || empty($fk_entrepot)) ? $list_warehouse : $fk_entrepot;
$sql .= ' AND s.fk_entrepot IN (' . $db->sanitize($list_warehouse_selected) . ')';


Expand Down
4 changes: 2 additions & 2 deletions htdocs/projet/element.php
Original file line number Diff line number Diff line change
Expand Up @@ -1278,8 +1278,8 @@
$filedir = $conf->fournisseur->commande->multidir_output[$element->entity].'/'.dol_sanitizeFileName($element->ref);
} elseif ($element_doc === 'invoice_supplier') {
$element_doc = 'facture_fournisseur';
$filename = get_exdir($element->id, 2, 0, 0, $element, 'product').dol_sanitizeFileName($element->ref);
$filedir = $conf->fournisseur->facture->multidir_output[$element->entity].'/'.get_exdir($element->id, 2, 0, 0, $element, 'invoice_supplier').dol_sanitizeFileName($element->ref);
$filename = get_exdir($element->id, 2, 0, 0, $element, 'invoice_supplier').dol_sanitizeFileName($element->ref);
$filedir = $conf->fournisseur->facture->multidir_output[$element->entity].'/'.$filename;
}

print '<div class="inline-block valignmiddle">';
Expand Down
2 changes: 1 addition & 1 deletion htdocs/public/project/new.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ function llxFooterVierge()

if (!$error) {
// Search thirdparty and set it if found to the new created project
$result = $thirdparty->fetch(0, '', '', '', '', '', '', '', '', '', $object->email);
$result = $thirdparty->fetch(0, '', '', '', '', '', '', '', '', '', GETPOST('email'));
if ($result > 0) {
$proj->socid = $thirdparty->id;
} else {
Expand Down

0 comments on commit 34680e8

Please sign in to comment.