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

This commit is contained in:
Laurent Destailleur
2025-11-03 13:57:49 +01:00
5 changed files with 50 additions and 25 deletions

View File

@@ -334,6 +334,7 @@ class Invoices extends DolibarrApi
* *
* @throws RestException 400 * @throws RestException 400
* @throws RestException 401 * @throws RestException 401
* @throws RestException 403 Access not allowed for login
* @throws RestException 404 * @throws RestException 404
* @throws RestException 405 * @throws RestException 405
*/ */
@@ -350,6 +351,9 @@ class Invoices extends DolibarrApi
if (empty($orderid)) { if (empty($orderid)) {
throw new RestException(400, 'Order ID is mandatory'); throw new RestException(400, 'Order ID is mandatory');
} }
if (!DolibarrApi::_checkAccessToResource('commande', $orderid)) {
throw new RestException(403, 'Access not allowed on order for login '.DolibarrApiAccess::$user->login);
}
$order = new Commande($this->db); $order = new Commande($this->db);
$result = $order->fetch($orderid); $result = $order->fetch($orderid);

View File

@@ -754,6 +754,11 @@ while ($i < $imaxinloop) {
} }
} }
// Fields from hook
$parameters = array('arrayfields'=>$arrayfields, 'obj'=>$objp, 'i'=>$i, 'totalarray'=>&$totalarray);
$reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
// Status // Status
if (!empty($arrayfields['p.statut']['checked'])) { if (!empty($arrayfields['p.statut']['checked'])) {
print '<td class="right">'; print '<td class="right">';

View File

@@ -1339,6 +1339,40 @@ jQuery(document).ready(function() {
}); });
// Code to manage the js for combo list with dependencies (called by extrafields_view.tpl.php)
function showOptions(child_list, parent_list) {
var parentInput = $("select[name="+parent_list+"]");
if (parentInput.length === 0) { // when parent extra-field is in view mode and the child is edited directly on card (on line edit)
parentInput = $("input[name="+parent_list+"]");
}
if (parentInput.length > 0) {
var val = parentInput.val();
var parentVal = parent_list + ":" + val;
if (val > 0) {
$("select[name=\""+child_list+"\"] option[parent]").prop("disabled", true).hide(); // hide not work with select2 element so disabled it
$("select[name=\""+child_list+"\"] option[parent=\""+parentVal+"\"]").prop('disabled', false).show(); // show not work with select2 element so enabled it
} else {
$("select[name=\""+child_list+"\"] option").prop("disabled", false).show(); // show not work with select2 element so enabled it
}
}
}
function setListDependencies() {
console.log("setListDependencies");
jQuery("select option[parent]").parent().each(function() {
var child_list = $(this).attr("name");
var parent = $(this).find("option[parent]:first").attr("parent");
var infos = parent.split(":");
var parent_list = infos[0];
showOptions(child_list, parent_list);
/* Activate the handler to call showOptions on each future change */
$("select[name=\""+parent_list+"\"]").change(function() {
showOptions(child_list, parent_list);
});
});
}
<?php <?php
if (!getDolGlobalString('MAIN_DISABLE_SELECT2_FOCUS_PROTECTION') && !defined('DISABLE_SELECT2_FOCUS_PROTECTION')) { if (!getDolGlobalString('MAIN_DISABLE_SELECT2_FOCUS_PROTECTION') && !defined('DISABLE_SELECT2_FOCUS_PROTECTION')) {
?> ?>

View File

@@ -266,6 +266,7 @@ if (empty($reshook) && !empty($object->table_element) && isset($extrafields->att
//var_dump($tmpkeyextra.'-'.$value.'-'.$object->table_element); //var_dump($tmpkeyextra.'-'.$value.'-'.$object->table_element);
print $extrafields->showOutputField($tmpkeyextra, $value, '', $object->table_element); print $extrafields->showOutputField($tmpkeyextra, $value, '', $object->table_element);
print '<input type="hidden" value="' . $value . '" name="options_' . $tmpkeyextra . '" id="options_' . $tmpkeyextra . '"/>'; // it's needed when to get parent value when extra-field list depend on parent extra-field list
} }
print '</td>'; print '</td>';
@@ -280,31 +281,6 @@ if (empty($reshook) && !empty($object->table_element) && isset($extrafields->att
print ' print '
<script> <script>
jQuery(document).ready(function() { jQuery(document).ready(function() {
function showOptions(child_list, parent_list)
{
var val = $("select[name="+parent_list+"]").val();
var parentVal = parent_list + ":" + val;
if(val > 0) {
$("select[name=\""+child_list+"\"] option[parent]").hide();
$("select[name=\""+child_list+"\"] option[parent=\""+parentVal+"\"]").show();
} else {
$("select[name=\""+child_list+"\"] option").show();
}
}
function setListDependencies() {
jQuery("select option[parent]").parent().each(function() {
var child_list = $(this).attr("name");
var parent = $(this).find("option[parent]:first").attr("parent");
var infos = parent.split(":");
var parent_list = infos[0];
showOptions(child_list, parent_list);
/* Activate the handler to call showOptions on each future change */
$("select[name=\""+parent_list+"\"]").change(function() {
showOptions(child_list, parent_list);
});
});
}
setListDependencies(); setListDependencies();
}); });
</script>'."\n"; </script>'."\n";

View File

@@ -707,6 +707,11 @@ while ($i < $imaxinloop) {
} }
} }
// Fields from hook
$parameters = array('arrayfields'=>$arrayfields, 'obj'=>$objp, 'i'=>$i, 'totalarray'=>&$totalarray);
$reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
print '<td class="nowrap center">'; print '<td class="nowrap center">';
if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
@@ -724,6 +729,7 @@ while ($i < $imaxinloop) {
print '</tr>'."\n"; print '</tr>'."\n";
} }
$i++; $i++;
} }