diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index a8dc5bf24955c..51bbdea02b9a8 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -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')) { @@ -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 + 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); + }; + } + } + unset($_SESSION['assignedtouser']); + unset($_SESSION['assignedtoresource']); $moreparam = ''; if ($user->id != $object->userownerid) {