$values['new'] = 1; } else { if (isset($_POST["second_step_update"])) { $values['new'] = 0; } } $values["requiredfields"] = 1; $_SESSION["MESSAGE_AFTER_REDIRECT"] = "<h3><span class='red'>" . __('Required fields are not filled. Please try again.', 'resources') . "</span></h3>"; Html::displayMessageAfterRedirect(); $resource->wizardSecondForm($_POST["id"], $values); } else { if ($resource->canCreate() && isset($_POST["second_step"])) { $newID = $resource->add($_POST); } else { if ($resource->canCreate() && isset($_POST["second_step_update"])) { $resource->update($_POST); $newID = $_POST["id"]; } } //if employee right : next step if ($newID) { $wizard_employee = PluginResourcesContractType::checkWizardSetup($newID, "use_employee_wizard"); $wizard_need = PluginResourcesContractType::checkWizardSetup($newID, "use_need_wizard"); $wizard_picture = PluginResourcesContractType::checkWizardSetup($newID, "use_picture_wizard"); if ($employee->canCreate()) { if ($wizard_employee) { $employee->wizardThirdForm($newID); } elseif ($wizard_need) { $choice->wizardFourForm($newID); } elseif ($wizard_picture) { $values = array();
function plugin_pre_item_update_resources($item) { if (!isset($item->input["_UpdateFromResource_"])) { $restrict = "`itemtype` = '" . get_class($item) . "'\n AND `items_id` = '" . $item->getField('id') . "'"; $items = getAllDatasFromTable("glpi_plugin_resources_resources_items", $restrict); if (!empty($items)) { foreach ($items as $device) { $PluginResourcesResource = new PluginResourcesResource(); $PluginResourcesResource->GetfromDB($device["plugin_resources_resources_id"]); if (isset($PluginResourcesResource->fields["locations_id"]) && isset($item->input["locations_id"])) { if ($item->input["locations_id"] != 0 && $PluginResourcesResource->fields["locations_id"] != $item->input["locations_id"]) { $values = array(); $values["id"] = $device["plugin_resources_resources_id"]; $values["locations_id"] = $item->input["locations_id"]; $values["withtemplate"] = 0; $values["_UpdateFromUser_"] = 1; $PluginResourcesResource->update($values); Session::addMessageAfterRedirect(__("Modification of the associated resource's location", "resources"), true); } } } } } }
if (isset($_POST["removeresources"]) && $_POST["plugin_resources_resources_id"] != 0) { $date = date("Y-m-d H:i:s"); $CronTask = new CronTask(); $CronTask->getFromDBbyName("PluginResourcesEmployment", "ResourcesLeaving"); $input["id"] = $_POST["plugin_resources_resources_id"]; $input["date_end"] = $_POST["date_end"]; if ($_POST["date_end"] < $date || $CronTask->fields["state"] == CronTask::STATE_DISABLE) { $input["is_leaving"] = "1"; } else { $input["is_leaving"] = "0"; } $input["plugin_resources_leavingreasons_id"] = $_POST["plugin_resources_leavingreasons_id"]; $input["withtemplate"] = "0"; $input["users_id_recipient_leaving"] = Session::getLoginUserID(); $input['send_notification'] = 1; $resource->update($input); //test it $resource->getFromDB($_POST["plugin_resources_resources_id"]); $resources_checklist = PluginResourcesChecklist::checkIfChecklistExist($_POST["plugin_resources_resources_id"]); if (!$resources_checklist) { $checklistconfig->addChecklistsFromRules($resource, PluginResourcesChecklist::RESOURCES_CHECKLIST_OUT); } Session::addMessageAfterRedirect(__('Declaration of resource leaving OK', 'resources')); Html::back(); } else { if ($resource->canView() || Session::haveRight("config", "w")) { //show remove resource form $resource->showResourcesToRemove(); } } if ($_SESSION['glpiactiveprofile']['interface'] == 'central') {
function updateComment($values) { $resource = new PluginResourcesResource(); $resource->getFromDB($values['plugin_resources_resources_id']); $comment = $values['comment']; $comment = Html::cleanPostForTextArea($comment); $resource->update(array('id' => $values['plugin_resources_resources_id'], 'comment' => addslashes($comment))); $_SESSION['plugin_ressources_' . $values['plugin_resources_resources_id'] . '_comment'] = $comment; }