function post_updateItem($history = 1) { global $CFG_GLPI; $PluginResourcesChecklist = new PluginResourcesChecklist(); if (isset($this->input["addchecklist"]) && $this->input["addchecklist"] == 1) { $PluginResourcesChecklist->deleteByCriteria(array('plugin_resources_resources_id' => $this->fields["id"])); $PluginResourcesChecklistconfig = new PluginResourcesChecklistconfig(); $PluginResourcesChecklistconfig->addChecklistsFromRules($this, PluginResourcesChecklist::RESOURCES_CHECKLIST_IN); $PluginResourcesChecklistconfig->addChecklistsFromRules($this, PluginResourcesChecklist::RESOURCES_CHECKLIST_OUT); } $status = "update"; if (isset($this->fields["is_leaving"]) && !empty($this->fields["is_leaving"])) { $status = "LeavingResource"; $PluginResourcesResource_Item = new PluginResourcesResource_Item(); $badge = $PluginResourcesResource_Item->searchAssociatedBadge($this->fields["id"]); if ($badge) { $this->input["checkbadge"] = 1; } //when a resource is leaving, current employment get default state if (isset($this->input['date_end'])) { $PluginResourcesEmployment = new PluginResourcesEmployment(); $default = PluginResourcesEmploymentState::getDefault(); // only current employment $restrict = "`plugin_resources_resources_id` = '" . $this->input["id"] . "'\n AND ((`begin_date` < '" . $this->input['date_end'] . "'\n OR `begin_date` IS NULL)\n AND (`end_date` > '" . $this->input['date_end'] . "'\n OR `end_date` IS NULL)) "; $employments = getAllDatasFromTable("glpi_plugin_resources_employments", $restrict); if (!empty($employments)) { foreach ($employments as $employment) { $values = array('plugin_resources_employmentstates_id' => $default, 'end_date' => $this->input['date_end'], 'id' => $employment['id']); $PluginResourcesEmployment->update($values); } } } } $picture = array(0 => "picture", 1 => "date_mod"); if (count($this->updates) && array_diff($this->updates, $picture) && isset($this->input["withtemplate"]) && $this->input["withtemplate"] != 1) { if ($CFG_GLPI["use_mailing"] && isset($this->input['send_notification']) && $this->input['send_notification'] == 1) { NotificationEvent::raiseEvent($status, $this); } } }