Skip to content

Commit

Permalink
Prevented the creation of events that use unavailable resources
Browse files Browse the repository at this point in the history
  • Loading branch information
Elisée Chemin authored and dbeniamine committed Oct 10, 2024
1 parent 1940ce6 commit 1ac5b2b
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions htdocs/comm/action/card.php
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,9 @@
$action = 'create';
}

// Checking resource availability if the config doesn't allow overlap
if (!empty($_SESSION['assignedtoresource']) && getDolGlobalString('RESOURCE_USED_IN_EVENT_CHECK')) {
$assigned_ressources = json_decode($_SESSION['assignedtoresource'], true);

// Checking resource availability if the config doesn't allow overlap
if (!$error && !empty($_SESSION['assignedtoresource']) && getDolGlobalString('RESOURCE_USED_IN_EVENT_CHECK')) {
Expand Down Expand Up @@ -564,7 +567,21 @@
$categories = GETPOST('categories', 'array');
$object->setCategories($categories);


if (!empty($_SESSION['assignedtoresource'])) {
$assignedtoresource = json_decode($_SESSION['assignedtoresource'], true);

foreach ($assignedtoresource as $resource_id => $resource){
// hardcoding dolresource might be a problem later on
// add_element_resource(id, type, busy, mandatory) -> 1 on sucess or 0

Check failure on line 576 in htdocs/comm/action/card.php

View workflow job for this annotation

GitHub Actions / pre-commit / pre-commit

sucess ==> success
if (!$object->add_element_resource($resource_id, "dolresource", 1, (int) $resource['mandatory'])){
dol_syslog("An Error occured in add_element_resource: '" . $object->error . "'", LOG_ERR);

Check failure on line 578 in htdocs/comm/action/card.php

View workflow job for this annotation

GitHub Actions / pre-commit / pre-commit

occured ==> occurred
};
}
}

unset($_SESSION['assignedtouser']);
unset($_SESSION['assignedtoresource']);

$moreparam = '';
if ($user->id != $object->userownerid) {
Expand Down

0 comments on commit 1ac5b2b

Please sign in to comment.