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

This commit is contained in:
Laurent Destailleur 2023-05-16 03:51:15 +02:00
commit a88df03513
5 changed files with 71 additions and 39 deletions

View file

@ -367,7 +367,7 @@ if ($action == 'update') {
$computedvalue,
(GETPOST('entitycurrentorall', 'alpha') ? 0 : ''),
GETPOST('langfile'),
GETPOST('enabled', 'alpha'),
GETPOST('enabled', 'nohtml'),
(GETPOST('totalizable', 'alpha') ? 1 : 0),
GETPOST('printable', 'alpha'),
array('css' => $css, 'cssview' => $cssview, 'csslist' => $csslist)

View file

@ -431,6 +431,9 @@ function restrictedArea(User $user, $features, $object = 0, $tableandshare = '',
if ($featureforlistofmodule == 'produit') {
$featureforlistofmodule = 'product';
}
if ($featureforlistofmodule == 'supplier_proposal') {
$featureforlistofmodule = 'supplierproposal';
}
if (!empty($user->socid) && !empty($conf->global->MAIN_MODULES_FOR_EXTERNAL) && !in_array($featureforlistofmodule, $listofmodules)) { // If limits on modules for external users, module must be into list of modules for external users
$readok = 0;
$nbko++;
@ -811,10 +814,13 @@ function checkUserAccessToObject($user, array $featuresarray, $object = 0, $tabl
$feature = 'projet_task';
}
if ($feature == 'payment_sc') {
$feature = "chargesociales";
}
$checkonentitydone = 0;
// Array to define rules of checks to do
$check = array('adherent', 'banque', 'bom', 'don', 'mrp', 'user', 'usergroup', 'payment', 'payment_supplier', 'product', 'produit', 'service', 'produit|service', 'categorie', 'resource', 'expensereport', 'holiday', 'salaries', 'website', 'recruitment'); // Test on entity only (Objects with no link to company)
$check = array('adherent', 'banque', 'bom', 'don', 'mrp', 'user', 'usergroup', 'payment', 'payment_supplier', 'product', 'produit', 'service', 'produit|service', 'categorie', 'resource', 'expensereport', 'holiday', 'salaries', 'website', 'recruitment','chargesociales'); // Test on entity only (Objects with no link to company)
$checksoc = array('societe'); // Test for object Societe
$checkother = array('contact', 'agenda', 'contrat'); // Test on entity + link to third party on field $dbt_keyfield. Allowed if link is empty (Ex: contacts...).
$checkproject = array('projet', 'project'); // Test for project object

View file

@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2010-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2012 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2018-2023 Frédéric France <frederic.france@netlogic.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
@ -143,7 +143,7 @@ $listofexamplesforlink = 'Societe:societe/class/societe.class.php<br>Contact:con
<input type="hidden" name="attrname" value="<?php echo $attrname; ?>">
<input type="hidden" name="action" value="update">
<input type="hidden" name="rowid" value="<?php echo (empty($rowid) ? '' : $rowid) ?>">
<input type="hidden" name="enabled" value="<?php echo $extrafields->attributes[$elementtype]['enabled'][$attrname]; ?>">
<input type="hidden" name="enabled" value="<?php echo dol_escape_htmltag($extrafields->attributes[$elementtype]['enabled'][$attrname]); ?>">
<?php print dol_get_fiche_head(); ?>

View file

@ -13,13 +13,28 @@ if (isset($totalarray['pos'])) {
while ($i < $totalarray['nbfield']) {
$i++;
if (!empty($totalarray['pos'][$i])) {
print '<td class="right">';
if (isset($totalarray['type']) && $totalarray['type'][$i] == 'duration') {
print (!empty($totalarray['val'][$totalarray['pos'][$i]])?convertSecondToTime($totalarray['val'][$totalarray['pos'][$i]], 'allhourmin'):0);
} else {
print price(!empty($totalarray['val'][$totalarray['pos'][$i]])?$totalarray['val'][$totalarray['pos'][$i]]:0);
switch ($totalarray['type'][$i]) {
case 'duration';
print '<td class="right">';
print (!empty($totalarray['val'][$totalarray['pos'][$i]])?convertSecondToTime($totalarray['val'][$totalarray['pos'][$i]], 'allhourmin'):0);
print '</td>';
break;
case 'string';
print '<td class="left">';
print (!empty($totalarray['val'][$totalarray['pos'][$i]]) ? $totalarray['val'][$totalarray['pos'][$i]] : '');
print '</td>';
break;
case 'stock';
print '<td class="right">';
print price2num(!empty($totalarray['val'][$totalarray['pos'][$i]]) ? $totalarray['val'][$totalarray['pos'][$i]] : 0, 'MS');
print '</td>';
break;
default;
print '<td class="right">';
print price(!empty($totalarray['val'][$totalarray['pos'][$i]])?$totalarray['val'][$totalarray['pos'][$i]]:0);
print '</td>';
break;
}
print '</td>';
} else {
if ($i == 1) {
if (is_null($limit) || $num < $limit) {

View file

@ -595,35 +595,60 @@ if ($action == 'create') {
print '<br>';
$totalarray = array();
$totalarray['val'] = array ();
$totalarray['pos'] = array ();
$totalarray['type'] = array ();
$totalarray['nbfield'] = 0;
// TODO Create $arrayfields with all fields to show
print '<table class="noborder centpercent">';
print "<tr class=\"liste_titre\">";
$parameters = array();
$parameters = array('totalarray' => &$totalarray);
$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
print_liste_field_titre("Product", "", "p.ref", "&amp;id=".$id, "", "", $sortfield, $sortorder);
print_liste_field_titre("Label", "", "p.label", "&amp;id=".$id, "", "", $sortfield, $sortorder);
print_liste_field_titre("NumberOfUnit", "", "ps.reel", "&amp;id=".$id, "", '', $sortfield, $sortorder, 'right ');
$totalarray['nbfield'] += 3;
$totalarray['pos'][$totalarray['nbfield']] = 'totalunit';
$totalarray['type'][$totalarray['nbfield']] = 'stock';
if (!empty($conf->global->PRODUCT_USE_UNITS)) {
print_liste_field_titre("Unit", "", "p.fk_unit", "&amp;id=".$id, "", 'align="left"', $sortfield, $sortorder);
$totalarray['nbfield']++;
$totalarray['pos'][$totalarray['nbfield']] = 'units';
$totalarray['type'][$totalarray['nbfield']] = 'string';
}
print_liste_field_titre($form->textwithpicto($langs->trans("AverageUnitPricePMPShort"), $langs->trans("AverageUnitPricePMPDesc")), "", "p.pmp", "&amp;id=".$id, "", '', $sortfield, $sortorder, 'right ');
$totalarray['nbfield']++;
print_liste_field_titre("EstimatedStockValueShort", "", "", "&amp;id=".$id, "", '', $sortfield, $sortorder, 'right ');
$totalarray['nbfield']++;
$totalarray['pos'][$totalarray['nbfield']] = 'totalvalue';
if (empty($conf->global->PRODUIT_MULTIPRICES)) {
print_liste_field_titre("SellPriceMin", "", "p.price", "&amp;id=".$id, "", '', $sortfield, $sortorder, 'right ');
$totalarray['nbfield']++;
}
if (empty($conf->global->PRODUIT_MULTIPRICES)) {
print_liste_field_titre("EstimatedStockValueSellShort", "", "", "&amp;id=".$id, "", '', $sortfield, $sortorder, 'right ');
$totalarray['nbfield']++;
$totalarray['pos'][$totalarray['nbfield']] = 'totalvaluesell';
}
if ($user->rights->stock->mouvement->creer) {
print_liste_field_titre('');
$totalarray['nbfield']++;
}
if ($user->rights->stock->creer) {
print_liste_field_titre('');
$totalarray['nbfield']++;
}
// Hook fields
$parameters = array('sortfield'=>$sortfield, 'sortorder'=>$sortorder);
$parameters = array('sortfield'=>$sortfield, 'sortorder'=>$sortorder, 'totalarray' => &$totalarray);
$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
print "</tr>\n";
@ -708,7 +733,7 @@ if ($action == 'create') {
//print '<td>'.dol_print_date($objp->datem).'</td>';
print '<tr class="oddeven">';
$parameters = array('obj'=>$objp);
$parameters = array('obj'=>$objp, 'totalarray' => &$totalarray);
$reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
@ -807,34 +832,20 @@ if ($action == 'create') {
}
$db->free($resql);
// Total
print '<tr class="liste_total"><td class="liste_total" colspan="2">'.$langs->trans("Total").'</td>';
print '<td class="liste_total right">';
$valtoshow = price2num($totalunit, 'MS');
if (empty($conf->global->PRODUCT_USE_UNITS) || $sameunits) {
print empty($valtoshow) ? '0' : $valtoshow;
}
print '</td>';
print '<td class="liste_total">';
if (empty($conf->global->PRODUCT_USE_UNITS) && $sameunits) {
print $langs->trans($productstatic->getLabelOfUnit());
}
print '</td>';
print '<td class="liste_total right">'.price(price2num($totalvalue, 'MT')).'</td>';
if (empty($conf->global->PRODUIT_MULTIPRICES)) {
print '<td class="liste_total">&nbsp;</td>';
print '<td class="liste_total right">'.price(price2num($totalvaluesell, 'MT')).'</td>';
$totalarray['val']['totalunit'] = $totalunit;
$totalarray['val']['totalvalue'] = price2num($totalvalue, 'MT');
$totalarray['val']['totalvaluesell'] = price2num($totalvaluesell, 'MT');
$totalarray['val']['units'] = $langs->trans($productstatic->getLabelOfUnit());
$parameters = array('totalarray' => &$totalarray);
// Note that $action and $object may have been modified by hook
$reshook = $hookmanager->executeHooks('printFieldListTotal', $parameters, $object);
if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors);
}
if ($user->rights->stock->mouvement->creer) {
print '<td class="liste_total">&nbsp;</td>';
}
if ($user->rights->stock->creer) {
print '<td class="liste_total">&nbsp;</td>';
}
print '</tr>';
// Show total line
include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
} else {
dol_print_error($db);
}