diff --git a/ajax/dropdownResources.php b/ajax/dropdownResources.php
index 68d9094..6155d15 100644
--- a/ajax/dropdownResources.php
+++ b/ajax/dropdownResources.php
@@ -72,12 +72,19 @@
$plugin_resources_contracttypes_id = $_GET["plugin_resources_contracttypes_id"];
}
+$isNotLeavingOnly = false;
+if (isset($_GET['condition']) && isset($_GET['condition']['is_not_leaving_only'])) {
+ $isNotLeavingOnly = true;
+}
+
$result = Resource::getSqlSearchResult(
false,
$_GET["entity"],
$_GET['value2'],
$used,
- $_GET['searchText']
+ $_GET['searchText'],
+ false,
+ $isNotLeavingOnly,
);
$users = [];
diff --git a/ajax/leavingform.php b/ajax/leavingform.php
index 7664ae8..0fafd5c 100644
--- a/ajax/leavingform.php
+++ b/ajax/leavingform.php
@@ -114,7 +114,7 @@
echo __('Resource manager', 'resources');
echo "";
echo "
";
- User::dropdown(['name' => 'remove_manager', 'right' => 'all']);
+ User::dropdown(['name' => 'remove_manager', 'right' => 'all', 'value' => $resource->fields['users_id']]);
echo "
";
echo "";
}
diff --git a/ajax/validinformation.php b/ajax/validinformation.php
index 14afe21..22ac60b 100644
--- a/ajax/validinformation.php
+++ b/ajax/validinformation.php
@@ -151,7 +151,10 @@
}
}
-$ticket->fields["content"] = $content;
+if (substr_count($content, 'r
') > 1) {
+ $content = str_replace('r
', '
', $content);
+}
+$ticket->fields["content"] = addslashes($content);
$ticket->fields['users_id_recipient'] = Session::getLoginUserID();
$ticket->fields['_users_id_requester'] = Session::getLoginUserID();
@@ -161,140 +164,18 @@
unset($ticket->fields["id"]);
$ticket_id = $ticket->add($ticket->fields);
-$authLDAP = new AuthLDAP();
-$auth = $authLDAP->find();
-if (count($auth)) {
- $config = new Config();
- $configAD = new Adconfig();
- $config->getFromDB(1);
- $configAD->getFromDB(1);
- $configAD->fields = $configAD->prepareFields($configAD->fields);
- $canedit = $resource->can($resource->fields['id'], UPDATE);
- $entities_id = $resource->fields["entities_id"];
- $plugin_resources_contracttypes_id = $resource->fields["plugin_resources_contracttypes_id"];
- $rand = mt_rand();
- $enddate = $resource->getField("date_end");
-
- $linkAD = new LinkAd();
- $linkAD->getEmpty();
- $islink = $linkAD->getFromDBByCrit(["plugin_resources_resources_id" => $resource->getID()]);
-
- if (!$islink) {
- $ret = LinkAd::processLogin($resource);
- $linkAD->fields["login"] = $ret[0];
- $logAvailable = $ret[1];
-
- $mail = LinkAd::processMail($resource, $linkAD->fields["login"]);
- $linkAD->fields["mail"] = $mail;
- $role = Dropdown::getDropdownName(Role::getTable(), $resource->fields['plugin_resources_roles_id']);
- $linkAD->fields["role"] = $role;
- $service = Dropdown::getDropdownName(Service::getTable(), $resource->fields['plugin_resources_services_id']);
- $linkAD->fields["service"] = $service;
- $location = Dropdown::getDropdownName(Location::getTable(), $resource->fields['locations_id']);
- $linkAD->fields["location"] = $location;
- }
-
-
- $ID = $linkAD->getID();
- $value = [
- 'plugin_resources_resources_id' => $resource->fields['id'],
- 'tickets_id' => $ticket_id,
- 'plugin_resources_contracttypes_id' => $plugin_resources_contracttypes_id,
- 'entities_id' => $entities_id,
- 'enddate' => $enddate,
- 'id' => $ID,
- 'login' => $linkAD->fields["login"],
- 'department' => Dropdown::getDropdownName('glpi_plugin_resources_departments', $resource->getField("plugin_resources_departments_id")),
- 'glpi_plugin_resources_departments' => $resource->getField("plugin_resources_departments_id"),
- 'name' => $resource->getField("name"),
- 'firstname' => $resource->getField("firstname"),
- 'phone' => $resource->getField('phone'),
- 'mail' => $linkAD->fields["mail"],
- 'contract' => Dropdown::getDropdownName('glpi_plugin_resources_contracttypes', $resource->getField("plugin_resources_contracttypes_id")),
- 'glpi_plugin_resources_contracttypes' => $resource->getField("plugin_resources_contracttypes_id"),
- 'cellphone' => $resource->getField("cellphone"),
- 'role' => $resource->getField('plugin_resources_roles_id'),
- 'service' => $resource->getField('plugin_resources_services_id'),
- 'location' => $resource->getField('locations_id'),
- ];
-
- $linkad = new LinkAd();
-
- if (!$islink) {
-
- //Création
- $ldap = new LDAP();
- $res = $ldap->createUserAD($value);
- if($res){
- $value["action_done"] = 1;
- $linkad->add($value);
- $fup = new ITILFollowup();
-
- $toadd = ['type' => "new",
- 'items_id' => $value["ticket_id"],
- 'itemtype' => 'Ticket',
- 'is_private' => 1];
-
-
- $content = $DB->escape(sprintf(__('%1$s %2$s have been added in the LDAP directory','resources'),$value["firstname"],$value["name"]));
- $toadd["content"] = htmlentities($content,ENT_NOQUOTES);
-
- $fup->add($toadd);
- $message = __('the user has been added to the LDAP directory','resources');
- Session::addMessageAfterRedirect($message, false, INFO);
- }else{
- $message = __('the user has not been added to the LDAP directory','resources');
- Session::addMessageAfterRedirect($message, false, ERROR);
- }
- }
- else {
-
- //update
- $ldap = new LDAP();
- $linkad->getFromDB($value['id']);
- $value["login"] = $linkad->getField("login");
- $res = $ldap->updateUserAD($value);
- if($res[0]){
-
- $value["action_done"] = 1;
- $linkad->update($value);
- $fup = new ITILFollowup();
-
- $toadd = ['type' => "new",
- 'items_id' => $value["ticket_id"],
- 'itemtype' => 'Ticket',
- 'is_private' => 1];
-
- $content = $DB->escape(sprintf(__('%1$s %2$s have been updated in the LDAP directory','resources'),$value["firstname"],$value["name"]));
- $content .= __("Data changed",'resources')."
";
- foreach ($res[1] as $key => $oldData){
- $i =1;
- $nb =count($oldData);
- $content .= $key." : ";
- foreach ($oldData as $data){
- if($key == "accountexpires"){
- $time = $ldap->ldapTimeToUnixTime($data);
- $data = date('Y-m-d',$time);
- $data = Html::convDate($data);
-
- }
- $content.=$data;
- if($i<$nb){
- $content.=", ";
- }
- $i++;
- }
- $content .= "
";
-
- }
- $toadd["content"] = htmlentities($content,ENT_NOQUOTES);
-
- $fup->add($toadd);
- $message = __('the user has been updated to the LDAP directory','resources');
- Session::addMessageAfterRedirect($message, false, INFO);
- }else{
- $message = __('the user has not been updated to the LDAP directory','resources');
- Session::addMessageAfterRedirect($message, false, ERROR);
- }
- }
+if ($config->fields['use_module_duplicata_ticket'] && $config->fields['use_module_validation'] && $config->fields["send_second_ticket_validation"] && $config->fields["assignment_group_second_ticket"]) {
+ $ticket->fields['users_id_recipient'] = Session::getLoginUserID();
+ $ticket->fields['_users_id_requester'] = Session::getLoginUserID();
+ $ticket->fields["type"] = Ticket::DEMAND_TYPE;
+ $ticket->fields["entities_id"] = $_SESSION['glpiactive_entity'];
+ $ticket->fields['items_id'] = [Resource::class => [$resource->fields['id']]];
+ unset($ticket->fields["id"]);
+ $ticket_id = $ticket->add($ticket->fields);
+ $groupticket = new Group_Ticket();
+ $groupticket->fields['tickets_id'] = $ticket_id;
+ $groupticket->fields['groups_id'] = $config->fields["assignment_group_second_ticket"];
+ $groupticket->fields['type'] = CommonITILActor::ASSIGN;
+ unset($groupticket->fields["id"]);
+ $groupticket->add($groupticket->fields);
}
\ No newline at end of file
diff --git a/front/resource.form.php b/front/resource.form.php
index cc396f4..33cded4 100644
--- a/front/resource.form.php
+++ b/front/resource.form.php
@@ -210,6 +210,30 @@
//update resource
elseif (isset($_POST["update"])) {
$resource->check($_POST['id'], UPDATE);
+ $_POST['plugin_resources_profiletypes_id'] = $_SESSION["glpiactiveprofile"]['id'];
+ $_POST['plugin_resources_grouptypes_id'] = $_SESSION["glpigroups"];
+
+ $required = $resource->checkRequiredFields($_POST);
+
+ if (count($required) > 0) {
+ // Set default value...
+ foreach ($_POST as $key => $val) {
+ $values[$key] = $val;
+ }
+
+ // Clean text fields
+ $values['name'] = stripslashes($values['name']);
+
+ $values['target'] = Toolbox::getItemTypeFormURL('PluginResourcesWizard');
+ $values['withtemplate'] = $_POST["withtemplate"];
+
+
+ $values["requiredfields"] = 1;
+
+ Session::addMessageAfterRedirect(__("One or more mandatory fields are empty.", 'resources'), false, ERROR);
+
+ Html::back();
+ }
$old_is_leaving = $resource->fields['is_leaving'] ?? 0;
$resource->update($_POST);
if (isset($_POST['plugin_resources_employers_id'])) {
@@ -471,19 +495,35 @@
'firstname' => $resource->getField("firstname"),
'phone' => $resource->getField('phone'),
'mail' => $linkAD->fields["mail"],
- 'contract' => Dropdown::getDropdownName('glpi_plugin_resources_contracttypes', $resource->getField("plugin_resources_contracttypes_id")),
+ 'contract' => $resource->getField("plugin_resources_contracttypes_id") ? Dropdown::getDropdownName('glpi_plugin_resources_contracttypes', $resource->getField("plugin_resources_contracttypes_id")) : '',
'glpi_plugin_resources_contracttypes' => $resource->getField("plugin_resources_contracttypes_id"),
'cellphone' => $resource->getField("cellphone"),
- 'role' => $resource->getField('plugin_resources_roles_id'),
- 'service' => $resource->getField('plugin_resources_services_id'),
- 'location' => $resource->getField('locations_id'),
+ 'role' => $resource->getField('plugin_resources_roles_id') ? Dropdown::getDropdownName('glpi_plugin_resources_roles', $resource->getField('plugin_resources_roles_id')) : '',
+ 'glpi_plugin_resources_roles_id' => $resource->getField("plugin_resources_roles_id"),
+ 'service' => $resource->getField('plugin_resources_services_id') ? Dropdown::getDropdownName('glpi_plugin_resources_services', $resource->getField('plugin_resources_services_id')) : '',
+ 'glpi_plugin_resources_services_id' => $resource->getField("plugin_resources_services_id"),
+ 'location' => $resource->getField('locations_id') ? Dropdown::getDropdownName('glpi_locations', $resource->getField('locations_id')) : '',
+ 'glpi_locations_id' => $resource->getField("locations_id"),
+ 'function' => $resource->getField('plugin_resources_functions_id') ? Dropdown::getDropdownName('glpi_plugin_resources_functions', $resource->getField('plugin_resources_functions_id')) : '',
+ 'glpi_plugin_resources_functions_id' => $resource->getField("plugin_resources_functions_id"),
+ 'begindate' => $resource->getField("date_begin"),
];
$linkad = new LinkAd();
if (!$islink) {
- $message = __('the user has not been updated to the LDAP directory','resources');
- Session::addMessageAfterRedirect($message, false, ERROR);
+ //creation
+ $ldap = new LDAP();
+ $res = $ldap->createUserAD($value);
+ if ($res) {
+ $_POST["action_done"] = 1;
+ $linkad->add($value);
+ $message = __('the user has been added to the LDAP directory','resources');
+ Session::addMessageAfterRedirect($message, false, INFO);
+ }else{
+ $message = __('the user has not been added to the LDAP directory','resources');
+ Session::addMessageAfterRedirect($message, false, ERROR);
+ }
}
else {
@@ -505,10 +545,12 @@
}
}
+ Html::back();
+
} else if (isset($_POST["validOrderLeaving"])) {
$_POST["id"] = $_POST["plugin_resources_resources_id"];
unset($_POST["plugin_resources_resources_id"]);
- unset($_POST["date_declaration_leaving"]);
+ unset($_POST["date_end"]);
$resource->update($_POST);
$config = new Config();
@@ -547,105 +589,23 @@
unset($ticket->fields["id"]);
$ticket_id = $ticket->add($ticket->fields);
+ if ($config->fields['use_module_duplicata_ticket'] && $config->fields['use_module_departure_instruction'] && $config->fields["send_second_ticket_remove"] && $config->fields["assignment_group_second_ticket"]) {
+ $ticket->fields['users_id_recipient'] = Session::getLoginUserID();
+ $ticket->fields['_users_id_requester'] = Session::getLoginUserID();
+ $ticket->fields["type"] = Ticket::DEMAND_TYPE;
+ $ticket->fields["entities_id"] = $_SESSION['glpiactive_entity'];
+ $ticket->fields['items_id'] = [Resource::class => [$_POST['id']]];
+ unset($ticket->fields["id"]);
+ $ticket_id = $ticket->add($ticket->fields);
+ $groupticket = new Group_Ticket();
+ $groupticket->fields['tickets_id'] = $ticket_id;
+ $groupticket->fields['groups_id'] = $config->fields["assignment_group_second_ticket"];
+ $groupticket->fields['type'] = CommonITILActor::ASSIGN;
+ unset($groupticket->fields["id"]);
+ $groupticket->add($groupticket->fields);
+ }
- //Update AD
- $authLDAP = new AuthLDAP();
- $auth = $authLDAP->find();
- if (count($auth)) {
- $config = new Config();
- $configAD = new Adconfig();
- $config->getFromDB(1);
- $configAD->getFromDB(1);
- $configAD->fields = $configAD->prepareFields($configAD->fields);
- $canedit = $resource->can($resource->fields['id'], UPDATE);
- $entities_id = $resource->fields["entities_id"];
- $plugin_resources_contracttypes_id = $resource->fields["plugin_resources_contracttypes_id"];
- $rand = mt_rand();
- $enddate = $resource->getField("date_end");
-
- $linkAD = new LinkAd();
- $linkAD->getEmpty();
- $islink = $linkAD->getFromDBByCrit(["plugin_resources_resources_id" => $resource->getID()]);
-
- $ID = $linkAD->getID();
- $value = [
- 'plugin_resources_resources_id' => $resource->fields['id'],
- 'tickets_id' => $ticket_id,
- 'plugin_resources_contracttypes_id' => $plugin_resources_contracttypes_id,
- 'entities_id' => $entities_id,
- 'enddate' => $enddate,
- 'id' => $ID,
- 'login' => $linkAD->fields["login"],
- 'department' => Dropdown::getDropdownName('glpi_plugin_resources_departments', $resource->getField("plugin_resources_departments_id")),
- 'glpi_plugin_resources_departments' => $resource->getField("plugin_resources_departments_id"),
- 'name' => $resource->getField("name"),
- 'firstname' => $resource->getField("firstname"),
- 'phone' => $resource->getField('phone'),
- 'mail' => $linkAD->fields["mail"],
- 'contract' => Dropdown::getDropdownName('glpi_plugin_resources_contracttypes', $resource->getField("plugin_resources_contracttypes_id")),
- 'glpi_plugin_resources_contracttypes' => $resource->getField("plugin_resources_contracttypes_id"),
- 'cellphone' => $resource->getField("cellphone"),
- 'role' => $resource->getField('plugin_resources_roles_id'),
- 'service' => $resource->getField('plugin_resources_services_id'),
- 'location' => $resource->getField('locations_id'),
- ];
-
- $linkad = new LinkAd();
-
- if (!$islink) {
- $message = __('the user has not been updated to the LDAP directory', 'resources');
- Session::addMessageAfterRedirect($message, false, ERROR);
- } else {
- //update
- $ldap = new LDAP();
- $linkad->getFromDB($value['id']);
- $value["login"] = $linkad->getField("login");
- $res = $ldap->updateUserAD($value);
- if ($res[0]) {
-
- $value["action_done"] = 1;
- $linkad->update($value);
- $fup = new ITILFollowup();
-
- $toadd = ['type' => "new",
- 'items_id' => $value["ticket_id"],
- 'itemtype' => 'Ticket',
- 'is_private' => 1];
-
- $content = $DB->escape(sprintf(__('%1$s %2$s have been updated in the LDAP directory', 'resources'), $value["firstname"], $value["name"]));
- $content .= __("Data changed", 'resources') . "
";
- foreach ($res[1] as $key => $oldData) {
- $i = 1;
- $nb = count($oldData);
- $content .= $key . " : ";
- foreach ($oldData as $data) {
- if ($key == "accountexpires") {
- $time = $ldap->ldapTimeToUnixTime($data);
- $data = date('Y-m-d', $time);
- $data = Html::convDate($data);
-
- }
- $content .= $data;
- if ($i < $nb) {
- $content .= ", ";
- }
- $i++;
- }
- $content .= "
";
-
- }
- $toadd["content"] = htmlentities($content, ENT_NOQUOTES);
-
- $fup->add($toadd);
- $message = __('the user has been updated to the LDAP directory', 'resources');
- Session::addMessageAfterRedirect($message, false, INFO);
- } else {
- $message = __('the user has not been updated to the LDAP directory', 'resources');
- Session::addMessageAfterRedirect($message, false, ERROR);
- }
- }
- }
}
Html::back();
} else {
diff --git a/front/resource.remove.php b/front/resource.remove.php
index 33ef11a..fc0dd47 100644
--- a/front/resource.remove.php
+++ b/front/resource.remove.php
@@ -27,7 +27,9 @@
--------------------------------------------------------------------------
*/
-global $CFG_GLPI;
+global $CFG_GLPI, $DB;
+
+use GlpiPlugin\Resources\Adconfig;
use GlpiPlugin\Resources\Checklist;
use GlpiPlugin\Resources\Checklistconfig;
use GlpiPlugin\Resources\Config;
@@ -71,12 +73,16 @@
if (!isset($_POST["plugin_resources_leavingreasons_id"])) {
$_POST["plugin_resources_leavingreasons_id"] = 0;
}
+ $config = new Config();
$date = date("Y-m-d H:i:s");
$CronTask = new CronTask();
$CronTask->getFromDBbyName(Employment::class, "ResourcesLeaving");
$input["id"] = $_POST["plugin_resources_resources_id"];
$input["date_end"] = $_POST["date_end"];
+ if (!$config->fields['remove_at_midnight']) {
+ $input["date_end"] .=" 23:59:59";
+ }
$input["remove_manager"] = $_POST["remove_manager"] ?? 0;
if (($_POST["date_end"] < $date)
|| ($CronTask->fields["state"] == CronTask::STATE_DISABLE)) {
@@ -160,6 +166,9 @@
$ticket->fields['items_id'] = [Resource::class => [$input['id']]];
unset($ticket->fields["id"]);
$ticket->add($ticket->fields);
+
+
+
$linkad = new LinkAd();
if ($linkad->getFromDBByCrit(["plugin_resources_resources_id" => $input['id']])) {
$input2 = [];
@@ -174,7 +183,93 @@
&& $resource->input['send_notification'] == 1
) {
if ($CFG_GLPI["notifications_mailing"]) {
- NotificationEvent::raiseEvent("AlertLeavingRessourceManager", $resource);
+ $resource->playnotification($resource);
+ }
+ }
+ }
+
+ if ((new Adconfig())->fields['auth_id'] > 0) {
+ //Update AD
+ $authLDAP = new AuthLDAP();
+ $auth = $authLDAP->find();
+ if (count($auth)) {
+ $config = new Config();
+ $configAD = new Adconfig();
+ $config->getFromDB(1);
+ $configAD->getFromDB(1);
+ $configAD->fields = $configAD->prepareFields($configAD->fields);
+ $canedit = $resource->can($resource->fields['id'], UPDATE);
+ $entities_id = $resource->fields["entities_id"];
+ $plugin_resources_contracttypes_id = $resource->fields["plugin_resources_contracttypes_id"];
+ $rand = mt_rand();
+ $enddate = $resource->getField("date_end");
+
+ $linkAD = new LinkAd();
+ $linkAD->getEmpty();
+ $islink = $linkAD->getFromDBByCrit(["plugin_resources_resources_id" => $resource->getID()]);
+
+ $ID = $linkAD->getID();
+ $value = [
+ 'enddate' => $enddate,
+ 'id' => $ID,
+ 'login' => $linkAD->fields["login"],
+
+ ];
+
+ $linkad = new LinkAd();
+
+ if (!$islink) {
+ $message = __('the user has not been updated to the LDAP directory', 'resources');
+ Session::addMessageAfterRedirect($message, false, ERROR);
+ } else {
+
+ //update
+ $ldap = new LDAP();
+ $linkad->getFromDB($value['id']);
+ $value["login"] = $linkad->getField("login");
+ $res = $ldap->updateUserAD($value);
+ if ($res[0]) {
+
+ $value["action_done"] = 1;
+ $linkad->update($value);
+ $fup = new ITILFollowup();
+
+ $toadd = ['type' => "new",
+ 'items_id' => $value["ticket_id"],
+ 'itemtype' => 'Ticket',
+ 'is_private' => 1];
+
+ $content = $DB->escape(sprintf(__('%1$s %2$s have been updated in the LDAP directory', 'resources'), $value["firstname"], $value["name"]));
+ $content .= __("Data changed", 'resources') . "
";
+ foreach ($res[1] as $key => $oldData) {
+ $i = 1;
+ $nb = count($oldData);
+ $content .= $key . " : ";
+ foreach ($oldData as $data) {
+ if ($key == "accountexpires") {
+ $time = $ldap->ldapTimeToUnixTime($data);
+ $data = date('Y-m-d', $time);
+ $data = Html::convDate($data);
+
+ }
+ $content .= $data;
+ if ($i < $nb) {
+ $content .= ", ";
+ }
+ $i++;
+ }
+ $content .= "
";
+
+ }
+ $toadd["content"] = htmlentities($content, ENT_NOQUOTES);
+
+// $fup->add($toadd);
+ $message = __('the user has been updated to the LDAP directory', 'resources');
+ Session::addMessageAfterRedirect($message, false, INFO);
+ } else {
+ $message = __('the user has not been updated to the LDAP directory', 'resources');
+ Session::addMessageAfterRedirect($message, false, ERROR);
+ }
}
}
}
diff --git a/front/resource_item.list.php b/front/resource_item.list.php
index de5da36..36cb17d 100644
--- a/front/resource_item.list.php
+++ b/front/resource_item.list.php
@@ -73,7 +73,7 @@
}
Html::back();
} elseif (isset($_POST['updateSpecialRequirement'])) {
- if ($resource->canCreate()) {
+ if ($resource->canUpdate()) {
$_POST['id'] = $_POST['plugin_resources_resources_id'];
$resource->update($_POST);
}
diff --git a/front/wizard.form.php b/front/wizard.form.php
index 2a5231d..0fea161 100644
--- a/front/wizard.form.php
+++ b/front/wizard.form.php
@@ -71,6 +71,8 @@
}
if (isset($_POST["second_step"]) || isset($_GET["second_step"])) {
+ $_POST['plugin_resources_profiletypes_id'] = $_SESSION["glpiactiveprofile"]['id'];
+ $_POST['plugin_resources_grouptypes_id'] = $_SESSION["glpigroups"];
if (!isset($_POST["template"])) {
$_POST["template"] = $_GET["template"];
}
@@ -577,7 +579,28 @@
$wizard->wizardSecondStep($resources_id, $values);
}
} else {
- $wizard->wizardFirstStep();
+ $config = new \GlpiPlugin\Resources\Config();
+ if ($config->fields['hidden_first_form']) {
+ $resourcestemplate = new Resource();
+ $resourcestemplatedata = $resourcestemplate->find(['is_template' => 1]);
+ if (count($resourcestemplatedata) == 1) {
+ // Clean text fields
+ $values['name'] = stripslashes('');
+ $values['withtemplate'] = 2;
+ $values['new'] = 1;
+ $values["requiredfields"] = 1;
+ foreach ($resourcestemplatedata as $id => $resourcestemplatevalue) {
+ $values['template'] = $id;
+ }
+
+ $wizard->wizardSecondStep(0, $values);
+ } else {
+ $wizard->wizardFirstStep();
+ }
+ } else {
+ $wizard->wizardFirstStep();
+ }
+
}
if (Session::getCurrentInterface() != 'central'
diff --git a/hook.php b/hook.php
index dcbe289..8feb033 100644
--- a/hook.php
+++ b/hook.php
@@ -885,7 +885,9 @@ function plugin_resources_install()
$DB->runFile(PLUGIN_RESOURCES_DIR . "/install/sql/update-4.0.12.sql");
- $DB->runFile(PLUGIN_RESOURCES_DIR . "/install/sql/update-4.0.15.sql");
+ if (!$DB->fieldExists("glpi_plugin_resources_configs", "search_default_my_resources")) {
+ $DB->runFile(PLUGIN_RESOURCES_DIR . "/install/sql/update-4.0.15.sql");
+ }
$rep_files_resources = GLPI_PLUGIN_DOC_DIR . "/resources";
if (!is_dir($rep_files_resources)) {
diff --git a/install/sql/empty.sql b/install/sql/empty.sql
index 857ddd1..8e3f447 100644
--- a/install/sql/empty.sql
+++ b/install/sql/empty.sql
@@ -932,6 +932,22 @@ CREATE TABLE `glpi_plugin_resources_configs`
`default_assignment_group` int unsigned NOT NULL DEFAULT '0',
`text_ticket_validation` TEXT COLLATE utf8mb4_unicode_ci,
`hide_fieds_arrival_form` TEXT COLLATE utf8mb4_unicode_ci,
+ `search_default_my_resources` int unsigned NOT NULL default '1',
+ `hidden_first_form` tinyint NOT NULL default '0',
+ `needs_tab_access` tinyint NOT NULL default '0',
+ `assignment_group_second_ticket` int unsigned NOT NULL default '0',
+ `send_second_ticket_validation` tinyint NOT NULL default '0',
+ `view_notification_tab` tinyint NOT NULL default '0',
+ `view_needs_parts` varchar(255) NOT NULL DEFAULT '',
+ `freeze_form_after_validation` tinyint NOT NULL default '0',
+ `can_view_synchronisationAD` varchar(255) NOT NULL DEFAULT '',
+ `order_order` varchar(4) NOT NULL DEFAULT 'ASC',
+ `order_column` int unsigned NOT NULL default '1',
+ `send_second_ticket_remove` tinyint NOT NULL default '0',
+ `remove_at_midnight` tinyint NOT NULL default '1',
+ `use_module_validation` tinyint NOT NULL default '0',
+ `use_module_duplicata_ticket` tinyint NOT NULL default '0',
+ `use_module_departure_instruction` tinyint NOT NULL default '0',
PRIMARY KEY (`id`)
) ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4
@@ -1082,6 +1098,10 @@ CREATE TABLE `glpi_plugin_resources_adconfigs`
`mail_prefix` int unsigned NOT NULL DEFAULT '0',
`mail_suffix` varchar(255) NOT NULL DEFAULT '',
`fonctionAD` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT '',
+ `use_password_module` tinyint NOT NULL default '0',
+ `default_account_password` varchar(255) COLLATE utf8mb4_unicode_ci default '',
+ `format_default_account_password` int unsigned NOT NULL default '0',
+ `prefix_default_account_password` int unsigned NOT NULL default '0',
PRIMARY KEY (`id`)
) ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4
diff --git a/install/sql/update-4.0.15.sql b/install/sql/update-4.0.15.sql
index 833180c..abdf549 100644
--- a/install/sql/update-4.0.15.sql
+++ b/install/sql/update-4.0.15.sql
@@ -1 +1,21 @@
UPDATE glpi_notificationtemplates SET itemtype = 'GlpiPlugin\\Resources\\Resource' WHERE itemtype = 'PluginResourcesResource';
+ALTER TABLE glpi_plugin_resources_configs ADD COLUMN `search_default_my_resources` int unsigned NOT NULL default '1';
+ALTER TABLE glpi_plugin_resources_configs ADD COLUMN `hidden_first_form` tinyint NOT NULL default '0';
+ALTER TABLE glpi_plugin_resources_configs ADD COLUMN `needs_tab_access` tinyint NOT NULL default '0';
+ALTER TABLE glpi_plugin_resources_configs ADD COLUMN `assignment_group_second_ticket` int unsigned NOT NULL default '0';
+ALTER TABLE glpi_plugin_resources_configs ADD COLUMN `send_second_ticket_validation` tinyint NOT NULL default '0';
+ALTER TABLE glpi_plugin_resources_configs ADD COLUMN `view_notification_tab` tinyint NOT NULL default '0';
+ALTER TABLE glpi_plugin_resources_configs ADD COLUMN `view_needs_parts` varchar(255) NOT NULL DEFAULT '';
+ALTER TABLE glpi_plugin_resources_configs ADD COLUMN `freeze_form_after_validation` tinyint NOT NULL default '0';
+ALTER TABLE glpi_plugin_resources_configs ADD COLUMN `can_view_synchronisationAD` varchar(255) NOT NULL DEFAULT '';
+ALTER TABLE glpi_plugin_resources_configs ADD COLUMN `order_order` varchar(4) NOT NULL DEFAULT 'ASC';
+ALTER TABLE glpi_plugin_resources_configs ADD COLUMN `order_column` int unsigned NOT NULL default '1';
+ALTER TABLE glpi_plugin_resources_configs ADD COLUMN `send_second_ticket_remove` tinyint NOT NULL default '0';
+ALTER TABLE glpi_plugin_resources_configs ADD COLUMN `remove_at_midnight` tinyint NOT NULL default '1';
+ALTER TABLE glpi_plugin_resources_adconfigs ADD COLUMN `use_password_module` tinyint NOT NULL default '0';
+ALTER TABLE glpi_plugin_resources_adconfigs ADD COLUMN `default_account_password` varchar(255) COLLATE utf8mb4_unicode_ci default '';
+ALTER TABLE glpi_plugin_resources_configs ADD COLUMN `use_module_validation` tinyint NOT NULL default '0';
+ALTER TABLE glpi_plugin_resources_configs ADD COLUMN `use_module_duplicata_ticket` tinyint NOT NULL default '0';
+ALTER TABLE glpi_plugin_resources_configs ADD COLUMN `use_module_departure_instruction` tinyint NOT NULL default '0';
+ALTER TABLE glpi_plugin_resources_adconfigs ADD COLUMN `format_default_account_password` int unsigned NOT NULL default '0';
+ALTER TABLE glpi_plugin_resources_adconfigs ADD COLUMN `prefix_default_account_password` int unsigned NOT NULL default '0';
\ No newline at end of file
diff --git a/src/Adconfig.php b/src/Adconfig.php
index 7863eeb..ca7fb32 100644
--- a/src/Adconfig.php
+++ b/src/Adconfig.php
@@ -270,6 +270,60 @@ function showConfigForm()
Dropdown::showFromArray("second_form", $this->loginForm(), $option);
echo "";
echo "";
+
+ if ((new LDAP())->isSSLorTLSAD()) {
+ echo "| ".__("Password Creation",'resources')." |
";
+
+ echo "";
+ echo "| ";
+ echo __('Use Password creation module','resources');
+ echo " | ";
+ echo "";
+ Dropdown::showYesNo("use_password_module",$this->fields["use_password_module"]);
+ echo " | ";
+ if ($this->fields["use_password_module"]) {
+ echo "";
+ echo __('Format password', 'resources');
+ echo " | ";
+ echo "";
+ $formaDefaultPassword = [0 => Dropdown::EMPTY_VALUE, 1 => 'prefixe dynamique et suffixe statique', 2 => __('Statique default password ', 'resources')];
+ Dropdown::showFromArray('format_default_account_password', $formaDefaultPassword, ['value' => $this->fields["format_default_account_password"]]);
+ echo " | ";
+
+ if ($this->fields["format_default_account_password"] != 0) {
+ echo "
";
+ echo "";
+ if ($this->fields["format_default_account_password"] == 1) {
+ echo "| ";
+ echo __('Prefix','resources');
+ echo " | ";
+ echo "";
+ $suffixeDefaultPassword = [0 => Dropdown::EMPTY_VALUE,
+ 1 => __('First name initial (uppercase) + last name initial (lowercase) + arrival date (DDMMYYYY)', 'resources'),
+ 2 => __('First name initial (uppercase) + last name initial (lowercase)', 'resources')];
+ Dropdown::showFromArray('prefix_default_account_password', $suffixeDefaultPassword, ['value' => $this->fields["prefix_default_account_password"]]);
+ echo " | ";
+ }
+
+ echo "";
+ if ($this->fields["format_default_account_password"] == 2) {
+ echo __('Default password', 'resources');
+ } else {
+ echo __('Suffix','resources');
+ }
+
+ echo " | ";
+ echo "";
+ $option = ['value' => (new GLPIKey())->decrypt($this->fields["default_account_password"]), 'required' => true];
+ echo Html::input('default_account_password', $option);
+ echo " | ";
+ }
+
+
+ }
+ echo "
";
+ }
+
echo "| " . __("Mail Creation", 'resources') . " |
";
echo "";
@@ -565,6 +619,10 @@ function prepareInputForUpdate($input)
$input['password'] = '';
}
+ if (isset($input["default_account_password"])) {
+ $input["default_account_password"] = (new GLPIKey())->encrypt($input["default_account_password"]);
+ }
+
$input = $this->encodeSubtypes($input);
diff --git a/src/Choice.php b/src/Choice.php
index 3d6819f..31b3603 100644
--- a/src/Choice.php
+++ b/src/Choice.php
@@ -53,6 +53,8 @@ class Choice extends CommonDBTM
static $rightname = 'plugin_resources';
+ const TYPE_CHOICE = [1 => 'Element(s) to be affected', 2 => 'Specials requirements'];
+
/**
* @param int $nb
*
@@ -104,7 +106,11 @@ static function canCreate(): bool
*/
function getTabNameForItem(CommonGLPI $item, $withtemplate = 0)
{
- $wizard_need = ContractType::checkWizardSetup($item->getField('id'), "use_need_wizard");
+ $config = new Config();
+ $wizard_need = true;
+ if (!$config->fields['needs_tab_access']) {
+ $wizard_need = ContractType::checkWizardSetup($item->getField('id'), "use_need_wizard");
+ }
if ($item->getType() == Resource::class
&& $this->canView()
@@ -354,168 +360,192 @@ function showItemHelpdesk($plugin_resources_resources_id, $exist, $withtemplate
$restrict = ["plugin_resources_resources_id" => $plugin_resources_resources_id];
$dbu = new DbUtils();
$choices = $dbu->getAllDataFromTable($this->getTable(), $restrict);
+ $config = new Config();
+ $configchoice = json_decode($config->fields['view_needs_parts']);
+ $configchoice = is_array($configchoice) ? $configchoice : [];
$resource = new Resource();
$resource->getFromDB($plugin_resources_resources_id);
+ if (isset($resource->fields["entities_id"])) {
+ $input['entities_id'] = $resource->fields["entities_id"];
+ } else {
+ $input['entities_id'] = $_SESSION['glpiactive_entity'];
+ }
+ $input['plugin_resources_contracttypes_id'] = $resource->fields["plugin_resources_contracttypes_id"];
+ $input['plugin_resources_profiletypes_id'] = $_SESSION["glpiactiveprofile"]['id'];
+ $input['plugin_resources_grouptypes_id'] = $_SESSION["glpigroups"];
+ $input['plugin_resources_users_id'] = Session::getLoginUserID();
+ $input['plugin_resources_users_id_reel'] = $resource->fields['users_id'];
+
+ $readonly = $resource->getReadonlyFields($input);
+
$canedit = $resource->can($plugin_resources_resources_id, UPDATE)
&& $withtemplate < 2
&& $resource->fields["is_leaving"] != 1;
- if ($exist == 0) {
- echo "
";
+ echo "";
+ echo "| ";
+ echo __('Hidden first form when you have only one template', 'resources');
+ echo " | ";
+ echo "";
+ Dropdown::showYesNo('hidden_first_form', $this->fields['hidden_first_form']);
+ echo " | ";
+ echo "
";
+
echo "";
echo "| ";
echo __('Default contract template selected', 'resources');
@@ -375,6 +388,64 @@ function showWizardForm()
echo " |
";
}
+ echo "";
+ echo "| ";
+ echo __('Access the needs tab', 'resources');
+ echo " | ";
+ echo "";
+ Dropdown::showYesNo('needs_tab_access',$this->fields['needs_tab_access']);
+ echo " | ";
+ echo "
";
+
+ echo "";
+ echo "| ";
+ echo __('Can view notification tab', 'resources');
+ echo " | ";
+ echo "";
+ Dropdown::showYesNo('view_notification_tab',$this->fields['view_notification_tab']);
+ echo " | ";
+ echo "
";
+
+ echo "";
+ echo "| ";
+ echo __('On needs tab, view parts', 'resources');
+ echo " | ";
+ echo "";
+ $possible_values_choice = [];
+ foreach (Choice::TYPE_CHOICE as $id => $name) {
+ $possible_values_choice[$id] = __($name, 'resources');
+ }
+ $values = json_decode($this->fields['view_needs_parts']);
+ if (!is_array($values)) {
+ $values = [];
+ }
+ Dropdown::showFromArray("view_needs_parts",
+ $possible_values_choice,
+ ['values' => $values,
+ 'multiple' => 'multiples']);
+
+ echo " | ";
+ echo "
";
+
+ if ((new Adconfig())->fields['auth_id'] > 0 && $this->fields['use_module_validation']) {
+ echo "";
+ echo "| ";
+ echo __('Can view SynchronisationAD tab', 'resources');
+ echo " | ";
+ echo "";
+ $values = json_decode($this->fields['can_view_synchronisationAD']);
+ if (!is_array($values)) {
+ $values = [];
+ }
+ Dropdown::showFromArray("can_view_synchronisationAD",
+ $possible_values,
+ ['values' => $values,
+ 'multiple' => 'multiples']);
+
+ echo " | ";
+ echo "
";
+ }
+
echo "";
echo "| ";
echo Html::hidden('id', ['value' => 1]);
@@ -422,15 +493,6 @@ function showWorkflowForm()
echo " | ";
echo "
";
- echo "";
- echo "| ";
- echo __('Create a ticket with departure and instructions', 'resources');
- echo " | ";
- echo "";
- Dropdown::showYesNo("create_ticket_departure_instructions",$this->fields["create_ticket_departure_instructions"]);
- echo " | ";
- echo "
";
-
echo "";
echo "| ";
echo __('Category of departure ticket', 'resources');
@@ -510,26 +572,7 @@ function showWorkflowForm()
echo " | ";
echo "
";
- echo Ajax::createModalWindow(
- 'popupAvailablevariable',
- PLUGIN_RESOURCES_WEBDIR . '/front/modalavailablevariable.php',
- [
- 'title' => __('Are you sure?', 'resources'),
- 'reloadonclose' => false,
- 'width' => 1180,
- 'height' => 500,
- ]
- );
- echo "";
- echo "";
- echo __('Text in the resource creation ticket after validation', 'resources') . ' ';
- Html::requireJs('tinymce');
- echo "" . __("See variable available", "resources") . "";
- echo " | ";
- echo "";
- Html::textarea(['name' => 'text_ticket_validation','value' => $this->fields['text_ticket_validation']]);
- echo " | ";
- echo "
";
+
echo "";
echo "| ";
@@ -606,6 +649,151 @@ function showOtherForm()
echo " | ";
echo "
";
+ $optionSearch = [
+ 1 => __('Sales manager', 'resources'),
+ 0 => __('Resource manager', 'resources'),
+ ];
+ echo "";
+ echo "| ";
+ echo __('In element', 'resources'). ' "' . __('View my resources as a commercial', 'resources') . '" : ' . __('Search by default', 'resources');
+ echo " | ";
+ echo "";
+ Dropdown::showFromArray('search_default_my_resources',$optionSearch, ['value' => $this->fields['search_default_my_resources']]);
+ echo " | ";
+ echo "
";
+
+ $removeTimeChoice = ['0' => '23:59:59', '1' => '00:00:00'];
+ echo "";
+ echo "| ";
+ echo __('Time to remove ressource', 'resources');
+ echo " | ";
+ echo "";
+ Dropdown::showFromArray('remove_at_midnight',$removeTimeChoice ,['values' =>[$this->fields['remove_at_midnight']]]);
+ echo " | ";
+ echo "
";
+
+ $orderColumn = [1 => __('Name'), 5 => __('Arrival date', 'resources'),16 => __('Last update'), 31 => __('ID')];
+ $orderOrder = ['ASC' => __('Ascending', 'resources'), 'DESC' => __('Descending', 'resources')];
+ echo "";
+ echo "| ";
+ echo __('Order resources by', 'resources');
+ echo " | ";
+ echo "";
+ Dropdown::showFromArray('order_column',$orderColumn ,['values' =>[$this->fields['order_column']]]);
+ echo " ";
+ Dropdown::showFromArray('order_order',$orderOrder ,['values' =>[$this->fields['order_order']]]);
+ echo " | ";
+ echo "
";
+
+
+ echo "";
+ echo "| ";
+ echo __('Use validation module', 'resources');
+ echo " | ";
+ echo "";
+ Dropdown::showYesNo('use_module_validation',$this->fields['use_module_validation']);
+ echo " | ";
+ echo "
";
+
+ if ($this->fields['use_module_validation']) {
+ echo Ajax::createModalWindow(
+ 'popupAvailablevariable',
+ PLUGIN_RESOURCES_WEBDIR . '/front/modalavailablevariable.php',
+ [
+ 'title' => __('Are you sure?', 'resources'),
+ 'reloadonclose' => false,
+ 'width' => 1180,
+ 'height' => 500,
+ ]
+ );
+ echo "";
+ echo "";
+ echo __('Text in the resource creation ticket after validation', 'resources') . ' ';
+ Html::requireJs('tinymce');
+ echo "" . __("See variable available", "resources") . "";
+ echo " | ";
+ echo "";
+ Html::textarea(['name' => 'text_ticket_validation', 'value' => $this->fields['text_ticket_validation']]);
+ echo " | ";
+ echo "
";
+
+ echo "";
+ echo "| ";
+ echo __('Freeze the resource and special needs tabs after validation', 'resources');
+ echo " | ";
+ echo "";
+ Dropdown::showYesNo('freeze_form_after_validation', $this->fields['freeze_form_after_validation']);
+ echo " | ";
+ echo "
";
+
+ }
+
+ echo "";
+ echo "| ";
+ echo __('Use ticket duplication module', 'resources');
+ echo " | ";
+ echo "";
+ Dropdown::showYesNo('use_module_duplicata_ticket',$this->fields['use_module_duplicata_ticket']);
+ echo " | ";
+ echo "
";
+
+ if ($this->fields['use_module_duplicata_ticket']
+ && ($this->fields['use_module_validation'] || $this->fields['use_module_departure_instruction'])) {
+ echo "";
+ echo "| ";
+ echo __('Assignment group for the second ticket', 'resources');
+ echo " | ";
+ echo "";
+ Group::dropdown(['name' => 'assignment_group_second_ticket','value' => $this->fields['assignment_group_second_ticket']]);
+ echo " | ";
+ echo "
";
+
+
+ if ($this->fields['use_module_validation']) {
+ echo "";
+ echo "| ";
+ echo __('Send a second ticket after validating informations', 'resources');
+ echo " | ";
+ echo "";
+ Dropdown::showYesNo('send_second_ticket_validation', $this->fields['send_second_ticket_validation']);
+ echo " | ";
+ echo "
";
+ }
+
+ if ($this->fields['use_module_departure_instruction']) {
+ echo "";
+ echo "| ";
+ echo __('Send a second ticket for a departure after instruction', 'resources');
+ echo " | ";
+ echo "";
+ Dropdown::showYesNo('send_second_ticket_remove',$this->fields['send_second_ticket_remove']);
+ echo " | ";
+ echo "
";
+ }
+ }
+
+ echo "";
+ echo "| ";
+ echo __('Use departure instruction module', 'resources');
+ echo " | ";
+ echo "";
+ Dropdown::showYesNo('use_module_departure_instruction',$this->fields['use_module_departure_instruction']);
+ echo " | ";
+ echo "
";
+
+ if ($this->fields['use_module_departure_instruction']) {
+ echo "";
+ echo "";
+ echo "";
+ echo "| ";
+ echo __('Create a ticket with departure and instructions', 'resources');
+ echo " | ";
+ echo "";
+ Dropdown::showYesNo("create_ticket_departure_instructions",$this->fields["create_ticket_departure_instructions"]);
+ echo " | ";
+ echo "
";
+ }
+
echo "";
echo "| ";
echo Html::hidden('id', ['value' => 1]);
@@ -770,6 +958,12 @@ function encodeSubtypes($input)
if (!empty($input['sales_manager'])) {
$input['sales_manager'] = json_encode(array_values($input['sales_manager']));
}
+ if (!empty($input['view_needs_parts'])) {
+ $input['view_needs_parts'] = json_encode(array_values($input['view_needs_parts']));
+ }
+ if (!empty($input['can_view_synchronisationAD'])) {
+ $input['can_view_synchronisationAD'] = json_encode(array_values($input['can_view_synchronisationAD']));
+ }
return $input;
}
diff --git a/src/LDAP.php b/src/LDAP.php
index 3c88196..481671d 100644
--- a/src/LDAP.php
+++ b/src/LDAP.php
@@ -34,8 +34,10 @@
use Adldap\Models\ModelNotFoundException;
use AuthLDAP;
use CommonDBTM;
+use Exception;
use GLPIKey;
use Session;
+use Toolbox;
if (!defined('GLPI_ROOT')) {
die("Sorry. You can't access directly to this file");
@@ -285,6 +287,12 @@ public function existingUser($login)
return $find;
}
+ public function isSSLorTLSAD() {
+ $adConfig = new Adconfig();
+ $config = self::getConfig();
+ return $config['use_tls'] || $config['use_ssl'];
+ }
+
public function createUserAD($data)
{
$adConfig = new Adconfig();
@@ -334,6 +342,31 @@ public function createUserAD($data)
$user->fill($attributes);
if ($user->save()) {
+ if (($config['use_tls'] || $config['use_ssl']) && $adConfig->fields['use_password_module']) {
+ try {
+ $newPassword = '';
+ if($adConfig->fields['format_default_account_password'] == 1) {
+ $newPassword = strtoupper(substr($data["firstname"], 0, 1))
+ . strtolower(substr($data["name"], 0, 1));
+ if ($adConfig->fields['prefix_default_account_password'] == 1 && isset($data['begindate'])) {
+ $date = substr($data["begindate"], 0, 10);
+ $date = explode('-', $date);
+ $newPassword .= $date[2] .$date[1] . $date[0] ;
+ }
+ $newPassword .= (new GLPIKey())->decrypt($adConfig->fields['default_account_password']);
+
+ } elseif ($adConfig->fields['format_default_account_password'] == 2) {
+ $newPassword = (new GLPIKey())->decrypt($adConfig->fields['default_account_password']);
+ }
+ if ($newPassword != '') {
+ $user->changePassword('', $newPassword,true);
+ }
+ return true;
+ } catch (Exception $ex) {
+ Toolbox::logInFile('LDAPERROR', "Erreur LDAP : ". $ex->getMessage());
+ return false;
+ }
+ }
return true;
} else {
return false;
diff --git a/src/LeavingInformation.php b/src/LeavingInformation.php
index b95517d..5965ce7 100644
--- a/src/LeavingInformation.php
+++ b/src/LeavingInformation.php
@@ -575,6 +575,18 @@ public static function rawSearchOptionsToAdd($itemtype)
'jointype' => 'child',
],
];
+
+ $tab[] = [
+ 'id' => '171',
+ 'table' => LinkAd::getTable(),
+ 'field' => 'id',
+ 'name' => __('Link AD', 'resources'),
+ 'massiveaction' => false,
+ 'datatype' => 'bool',
+ 'joinparams' => [
+ 'jointype' => 'child'
+ ]
+ ];
}
return $tab;
diff --git a/src/Menu.php b/src/Menu.php
index 4fe45cb..c0208c7 100644
--- a/src/Menu.php
+++ b/src/Menu.php
@@ -145,6 +145,7 @@ public static function displayTabContentForItem(
$canseeemployment = Session::haveright('plugin_resources_employment', READ);
$canseebudget = Session::haveright('plugin_resources_budget', READ);
$canImport = Session::haveright('plugin_resources_import', READ);
+ $canAnnuaire = Session::haveright('plugin_resources_annuaire', READ);
if ($tabnum == self::RESOURCES_TAB) {
@@ -189,12 +190,14 @@ public static function displayTabContentForItem(
$actions_others = ['search' => ['pics' => PLUGIN_RESOURCES_WEBDIR . '/pics/resourcelist.png',
'title' => __('Search resources', 'resources'),
'url' => PLUGIN_RESOURCES_WEBDIR . '/front/resource.php?reset=reset'
- ],
- 'directory' => ['pics' => PLUGIN_RESOURCES_WEBDIR . '/pics/directory.png',
+ ]];
+
+ if ($canAnnuaire) {
+ $actions_others['directory'] = ['pics' => PLUGIN_RESOURCES_WEBDIR . '/pics/directory.png',
'title' => Directory::getTypeName(1),
'url' => PLUGIN_RESOURCES_WEBDIR . '/front/directory.php'
- ]
- ];
+ ];
+ }
$config = new Config();
if (!$config->fields["hide_view_commercial_resource"]) {
@@ -202,6 +205,9 @@ public static function displayTabContentForItem(
$opt = [];
$opt['reset'] = 'reset';
$opt['criteria'][0]['field'] = 27;
+ if (!$config->fields["search_default_my_resources"]) {
+ $opt['criteria'][0]['field'] = 4;
+ }
$opt['criteria'][0]['searchtype'] = 'equals';
$opt['criteria'][0]['value'] = Session::getLoginUserID();
$opt['criteria'][0]['link'] = 'AND';
@@ -215,8 +221,11 @@ public static function displayTabContentForItem(
];
}
- $title = __('Others actions', 'resources');
- self::showMenuBlock($title, "ti ti-list", $actions_others);
+ if (!empty($actions_others)) {
+ $title = __('Others actions', 'resources');
+ self::showMenuBlock($title, "ti ti-list", $actions_others);
+ }
+
}
return true;
diff --git a/src/NotificationTargetResource.php b/src/NotificationTargetResource.php
index 353df7d..44e88a5 100644
--- a/src/NotificationTargetResource.php
+++ b/src/NotificationTargetResource.php
@@ -473,6 +473,9 @@ public function addDataForTemplate($event, $options = [])
$this->data['##lang.resource.datebegin##'] = __('Arrival date', 'resources');
$this->data['##lang.resource.dateend##'] = __('Departure date', 'resources');
$this->data['##lang.resource.department##'] = Department::getTypeName(1);
+ $this->data['##lang.resource.service##'] = Service::getTypeName(1);
+ $this->data['##lang.resource.function##'] = ResourceFunction::getTypeName(1);
+ $this->data['##lang.resource.role##'] = Role::getTypeName(1);
$this->data['##lang.resource.habilitation##'] = Habilitation::getTypeName(1);
$this->data['##lang.resource.status##'] = ResourceState::getTypeName(1);
$this->data['##lang.resource.location##'] = __('Location');
@@ -502,6 +505,12 @@ public function addDataForTemplate($event, $options = [])
'glpi_plugin_resources_departments',
$resource['plugin_resources_departments_id']
);
+ $this->data['##resource.role##'] = Dropdown::getDropdownName('glpi_plugin_resources_roles',
+ $resource['plugin_resources_roles_id']);
+ $tmp['##resource.service##'] = Dropdown::getDropdownName('glpi_plugin_resources_services',
+ $resource['plugin_resources_services_id']);
+ $tmp['##resource.function##'] = Dropdown::getDropdownName('glpi_plugin_resources_functions',
+ $resource['plugin_resources_functions_id']);
$resourcehabilitation = new ResourceHabilitation();
$habilitations = $resourcehabilitation->find(['plugin_resources_resources_id' => $resource['id']]);
$tab = [];
@@ -700,6 +709,16 @@ public function addDataForTemplate($event, $options = [])
$this->obj->getField('plugin_resources_departments_id')
);
+ $this->data['##lang.resource.service##'] = Service::getTypeName(1);
+ $this->data['##lang.resource.function##'] = ResourceFunction::getTypeName(1);
+ $this->data['##resource.service##'] = Dropdown::getDropdownName('glpi_plugin_resources_services',
+ $this->obj->getField('plugin_resources_services_id'));
+ $this->data['##resource.function##'] = Dropdown::getDropdownName('glpi_plugin_resources_functions',
+ $this->obj->getField('plugin_resources_functions_id'));
+ $this->data['##lang.resource.role##'] = Role::getTypeName(1);
+ $this->data['##resource.role##'] = Dropdown::getDropdownName('glpi_plugin_resources_roles',
+ $this->obj->getField('plugin_resources_roles_id'));
+
$resourcehabilitation = new ResourceHabilitation();
$habilitations = $resourcehabilitation->find(['plugin_resources_resources_id' => $this->obj->getField('id')]
);
@@ -806,6 +825,9 @@ public function addDataForTemplate($event, $options = [])
$this->data['##lang.resource.contractnature##'] = ContractNature::getTypeName(1);
$this->data['##lang.resource.quota##'] = __('Quota', 'resources');
$this->data['##lang.resource.department##'] = Department::getTypeName(1);
+ $this->data['##lang.resource.service##'] = Service::getTypeName(1);
+ $this->data['##lang.resource.function##'] = ResourceFunction::getTypeName(1);
+ $this->data['##lang.resource.role##'] = Role::getTypeName(1);
$this->data['##lang.resource.habilitation##'] = Habilitation::getTypeName(1);
$this->data['##lang.resource.rank##'] = Rank::getTypeName(1);
$this->data['##lang.resource.speciality##'] = ResourceSpeciality::getTypeName(1);
@@ -855,6 +877,14 @@ public function addDataForTemplate($event, $options = [])
$resource['plugin_resources_departments_id']
);
+ $tmp['##resource.service##'] = Dropdown::getDropdownName('glpi_plugin_resources_services',
+ $resource['plugin_resources_services_id']);
+ $tmp['##resource.function##'] = Dropdown::getDropdownName('glpi_plugin_resources_functions',
+ $resource['plugin_resources_functions_id']);
+ $this->data['##resource.role##'] = Dropdown::getDropdownName('glpi_plugin_resources_roles',
+ $resource['plugin_resources_roles_id']);
+
+
$resourcehabilitation = new ResourceHabilitation();
$habilitations = $resourcehabilitation->find(['plugin_resources_resources_id' => $resource['id']]);
$tab = [];
@@ -985,6 +1015,17 @@ public function addDataForTemplate($event, $options = [])
$this->obj->getField('plugin_resources_departments_id')
);
+ $this->data['##lang.resource.service##'] = Service::getTypeName(1);
+ $this->data['##resource.service##'] = Dropdown::getDropdownName('glpi_plugin_resources_services',
+ $this->obj->getField('plugin_resources_services_id'));
+ $this->data['##lang.resource.function##'] = ResourceFunction::getTypeName(1);
+ $this->data['##resource.function##'] = Dropdown::getDropdownName('glpi_plugin_resources_functions',
+ $this->obj->getField('plugin_resources_functions_id'));
+ $this->data['##lang.resource.role##'] = Role::getTypeName(1);
+ $this->data['##resource.role##'] = Dropdown::getDropdownName('glpi_plugin_resources_roles',
+ $this->obj->getField('plugin_resources_roles_id'));
+
+
$this->data['##lang.resource.rank##'] = Rank::getTypeName(1);
$this->data['##resource.rank##'] = Dropdown::getDropdownName(
'glpi_plugin_resources_ranks',
@@ -1607,6 +1648,9 @@ public function getTags()
'resource.datebegin' => __('Arrival date', 'resources'),
'resource.dateend' => __('Departure date', 'resources'),
'resource.department' => Department::getTypeName(1),
+ 'resource.service' => Service::getTypeName(1),
+ 'resource.function' => ResourceFunction::getTypeName(1),
+ 'resource.role' => Role::getTypeName(1),
'resource.status' => ResourceState::getTypeName(1),
'resource.location' => __('Location'),
'resource.restingtitle' => __('Non contract period management', 'resources'),
diff --git a/src/Profile.php b/src/Profile.php
index 1ef8a80..6fb1eb4 100644
--- a/src/Profile.php
+++ b/src/Profile.php
@@ -94,6 +94,8 @@ public static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $
'plugin_resources_budget' => 0,
'plugin_resources_dropdown_public' => 0,
'plugin_resources_import' => 0,
+ 'plugin_resources_annuaire' => 0,
+ 'plugin_resources_validation' => 0,
'plugin_resources_open_ticket' => 0,
'plugin_resources_all' => 0,
'plugin_resources_leavinginformation' => 0,
@@ -123,6 +125,8 @@ public static function createFirstAccess($profiles_id)
'plugin_resources_budget' => ALLSTANDARDRIGHT,
'plugin_resources_dropdown_public' => ALLSTANDARDRIGHT,
'plugin_resources_import' => ALLSTANDARDRIGHT,
+ 'plugin_resources_annuaire' => ALLSTANDARDRIGHT,
+ 'plugin_resources_validation' => ALLSTANDARDRIGHT,
'plugin_resources_open_ticket' => 1,
'plugin_resources_all' => 1,
'plugin_resources_leavinginformation' => 1,
@@ -359,6 +363,24 @@ public static function getAllRights($all = true, $types = [])
CREATE => __('Create'),
PURGE => __('Purge')
]
+ ],
+ ['itemtype' => Directory::class,
+ 'label' => __('Annuaire', 'resources'),
+ 'field' => 'plugin_resources_annuaire',
+ 'type' => 'general',
+ 'rights' => [
+ READ => __('Read')
+ ]
+ ],
+ ['itemtype' => Resource_Validation::class,
+ 'label' => __('AD Synchronisation', 'resources'),
+ 'field' => 'plugin_resources_validation',
+ 'type' => 'general',
+ 'rights' => [
+ READ => __('Read'),
+ UPDATE => __('Update'),
+ CREATE => __('Create'),
+ ]
]
];
diff --git a/src/Resource.php b/src/Resource.php
index 7047507..9a60a41 100644
--- a/src/Resource.php
+++ b/src/Resource.php
@@ -332,6 +332,10 @@ public static function cleanForItem(CommonDBTM $item)
]);
}
+ public function playnotification($resource) {
+ NotificationEvent::raiseEvent("AlertLeavingRessourceManager", $resource);
+ }
+
/**
* Get Tab Name used for itemtype
*
@@ -384,6 +388,16 @@ public static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $
return true;
}
+ static function getDefaultSearchRequest() {
+
+ $config = new Config();
+ $search = ['sort' => $config->fields['order_column'],
+ 'order' => $config->fields['order_order'],];
+
+
+ return $search;
+ }
+
/**
* Get the Search options for the given Type
*
@@ -924,6 +938,8 @@ public function defineTabs($options = [])
{
$ong = [];
+ $config = new Config();
+
$this->addDefaultFormTab($ong);
$this->addStandardTab(Resource::class, $ong, $options);
if (Session::getCurrentInterface() == 'central') {
@@ -943,18 +959,29 @@ public function defineTabs($options = [])
}
$this->addStandardTab(Choice::class, $ong, $options);
- $this->addStandardTab(Resource_Validation::class, $ong, $options);
+ $canViewSynchroADView = json_decode($config->fields['can_view_synchronisationAD']);
+ $canViewSynchroADView = is_array($canViewSynchroADView) ? $canViewSynchroADView : [];
+
+ if ($config->fields['use_module_validation'] && ((!$this->fields['valid_resource_information'] && Session::getLoginUserID() == $this->fields['users_id']) ||
+ ($this->fields['valid_resource_information'] && in_array($_SESSION['glpiactiveprofile']['id'], $canViewSynchroADView)))
+ ) {
+ $this->addStandardTab(Resource_Validation::class, $ong, $options);
+ }
$this->addStandardTab(ResourceHabilitation::class, $ong, $options);
$this->addStandardTab(Employment::class, $ong, $options);
$this->addStandardTab(Employee::class, $ong, $options);
$this->addStandardTab(LeavingInformation::class, $ong, $options);
- $this->addStandardTab(Resource_Leaving::class, $ong, $options);
+ if ($config->fields['use_module_departure_instruction']) {
+ $this->addStandardTab(Resource_Leaving::class, $ong, $options);
+ }
$this->addStandardTab(Checklist::class, $ong, $options);
$this->addStandardTab(Task::class, $ong, $options);
if (Session::getCurrentInterface() == 'central') {
$this->addStandardTab(ResourceImport::class, $ong, $options);
- $this->addStandardTab(ReportConfig::class, $ong, $options);
+ if ($config->fields['view_notification_tab']) {
+ $this->addStandardTab(ReportConfig::class, $ong, $options);
+ }
$this->addStandardTab(Document_Item::class, $ong, $options);
if (!isset($options['withtemplate']) || empty($options['withtemplate'])) {
@@ -1163,6 +1190,8 @@ public function prepareInputForAdd($input)
if (!isset($input["is_template"])) {
if (!isset($input['force'])) {
$required = $this->checkRequiredFields($input);
+ $input['plugin_resources_profiletypes_id'] = $_SESSION["glpiactiveprofile"]['id'];
+ $input['plugin_resources_grouptypes_id'] = $_SESSION["glpigroups"];
if (count($required) > 0) {
Session::addMessageAfterRedirect(
@@ -1728,6 +1757,9 @@ public function showForm($ID, $options = [])
$options['formoptions'] = " enctype='multipart/form-data'";
$this->showFormHeader($options);
+ $config = new Config();
+
+
if (isset($this->fields["entities_id"])) {
$input['entities_id'] = $this->fields["entities_id"];
} else {
@@ -1736,6 +1768,8 @@ public function showForm($ID, $options = [])
$input['plugin_resources_contracttypes_id'] = $this->fields["plugin_resources_contracttypes_id"];
$input['plugin_resources_profiletypes_id'] = $_SESSION["glpiactiveprofile"]['id'];
$input['plugin_resources_grouptypes_id'] = $_SESSION["glpigroups"];
+ $input['plugin_resources_users_id'] = Session::getLoginUserID();
+ $input['plugin_resources_users_id_reel'] = $this->fields['users_id'];
$hidden = $this->getHiddenFields($input);
$readonly = $this->getReadonlyFields($input);
$required = $this->checkRequiredFields($input);
@@ -1945,12 +1979,14 @@ public function showForm($ID, $options = [])
echo " |
| " . ResourceState::getTypeName(1) . " | ";
echo "";
if (Session::getCurrentInterface() == 'central') {
+ $option = ['value' => $this->fields["plugin_resources_resourcestates_id"],
+ 'entity' => $this->fields["entities_id"]];
+ if (in_array('plugin_resources_resourcestates_id', $readonly)) {
+ $option['readonly'] = true;
+ }
Dropdown::show(
ResourceState::class,
- [
- 'value' => $this->fields["plugin_resources_resourcestates_id"],
- 'entity' => $this->fields["entities_id"],
- ]
+ $option
);
} else {
echo Dropdown::getDropdownName(
@@ -1964,12 +2000,15 @@ public function showForm($ID, $options = [])
1
) . " | ";
echo "";
+
+ $option = ['value' => $this->fields["plugin_resources_contracttypes_id"],
+ 'entity' => $this->fields["entities_id"]];
+ if (in_array('plugin_resources_contracttypes_id', $readonly)) {
+ $option['readonly'] = true;
+ }
Dropdown::show(
ContractType::class,
- [
- 'value' => $this->fields["plugin_resources_contracttypes_id"],
- 'entity' => $this->fields["entities_id"],
- ]
+ $option
);
echo " |
";
@@ -2384,10 +2423,12 @@ public function showForm($ID, $options = [])
'entity' => $this->fields["entities_id"],
'entity_sons' => true,
'right' => 'all'];
- if (in_array("users_id", $readonly)) {
+ if (in_array("users_id", $readonly)){
$option['readonly'] = true;
+ echo \User::dropdown($option);
+ } else {
+ \User::dropdown($option);
}
- \User::dropdown($option);
}
echo "";
@@ -2403,7 +2444,7 @@ public function showForm($ID, $options = [])
echo "";
$option = ['value' => $this->fields["date_begin"]];
if (in_array("date_begin", $readonly)) {
- $option['readonly'] = true;
+ $option['canedit'] = true;
}
Html::showDateField("date_begin", $option);
echo " | ";
@@ -2459,10 +2500,12 @@ public function showForm($ID, $options = [])
'entity' => $this->fields["entities_id"],
'entity_sons' => true,
'right' => 'all'];
- if (in_array("users_id_sales", $readonly)) {
+ if (in_array("users_id_sales", $readonly)){
$option['readonly'] = true;
+ echo \User::dropdown($option);
+ } else {
+ \User::dropdown($option);
}
- \User::dropdown($option);
}
echo "";
@@ -2495,13 +2538,17 @@ public function showForm($ID, $options = [])
$users_id_recipient = new \User();
$users_id_recipient->getFromDB($this->fields["users_id_recipient"]);
if ($this->canCreate() && Session::getCurrentInterface() == 'central') {
- \User::dropdown([
- 'value' => $this->fields["users_id_recipient"],
- 'name' => "users_id_recipient",
- 'entity' => $this->fields["entities_id"],
+ $option = ['value' => $this->fields["users_id_recipient"],
+ 'name' => "users_id_recipient",
+ 'entity' => $this->fields["entities_id"],
'entity_sons' => true,
- 'right' => 'all',
- ]);
+ 'right' => 'all'];
+ if (in_array('users_id_recipient', $readonly)) {
+ $option['readonly'] = true;
+ echo \User::dropdown($option);
+ } else {
+ \User::dropdown($option);
+ }
} else {
echo getUserName($this->fields["users_id_recipient"]);
}
@@ -2514,7 +2561,11 @@ public function showForm($ID, $options = [])
echo "" . __('Associable to a ticket') . " | ";
if (Session::getCurrentInterface() == 'central') {
- Dropdown::showYesNo('is_helpdesk_visible', $this->fields['is_helpdesk_visible']);
+ if (in_array('is_helpdesk_visible', $readonly)) {
+ Dropdown::showYesNo('is_helpdesk_visible', $this->fields['is_helpdesk_visible'], -1, ['readonly' => true]);
+ } else {
+ Dropdown::showYesNo('is_helpdesk_visible', $this->fields['is_helpdesk_visible']);
+ }
} else {
echo Dropdown::getDropdownName($this->getTable(), $this->fields["is_helpdesk_visible"]);
}
@@ -2551,7 +2602,11 @@ public function showForm($ID, $options = [])
. "";
}
} else {
- Dropdown::showYesNo("is_leaving", $this->fields["is_leaving"]);
+ if (in_array('is_leaving', $readonly)) {
+ Dropdown::showYesNo('is_leaving', $this->fields['is_leaving'], -1, ['readonly'=> true]);
+ } else {
+ Dropdown::showYesNo("is_leaving", $this->fields["is_leaving"]);
+ }
}
if ($ID != -1 && $options['withtemplate'] != 1 && $this->fields["is_leaving"] == 1
@@ -2607,7 +2662,11 @@ public function showForm($ID, $options = [])
echo Html::convDate($this->fields["date_end"]);
echo Html::hidden('date_end', ['value' => $this->fields["date_end"]]);
} else {
- Html::showDateField("date_end", ['value' => $this->fields["date_end"]]);
+ $option = ['value' => $this->fields["date_end"]];
+ if (in_array('date_end', $readonly)) {
+ $option['canedit'] = false;
+ }
+ Html::showDateField("date_end", $option);
}
echo " | ";
if ($tohide['date_end'] == "hidden") {
@@ -3246,7 +3305,8 @@ public static function getSqlSearchResult(
$value = 0,
$used = [],
$search = '',
- $showOnlyLinkedResources = false
+ $showOnlyLinkedResources = false,
+ $isNotLeavingOnly = false
) {
global $DB, $CFG_GLPI;
@@ -3257,9 +3317,14 @@ public static function getSqlSearchResult(
$dbu = new DbUtils();
- $where = " `glpi_plugin_resources_resources`.`is_deleted` = 0
- AND `glpi_plugin_resources_resources`.`is_leaving` = 0
- AND `glpi_plugin_resources_resources`.`is_template` = 0 ";
+ $where = " `glpi_plugin_resources_resources`.`is_deleted` = 0 ";
+ if (!$isNotLeavingOnly) {
+ $where .= " AND (`glpi_plugin_resources_resources`.`is_leaving` = 0 OR `glpi_plugin_resources_resources`.`date_end` > now())";
+ } else {
+ $where .= " AND `glpi_plugin_resources_resources`.`is_leaving` = 0 ";
+ }
+
+ $where .= " AND `glpi_plugin_resources_resources`.`is_template` = 0 ";
$where .= $dbu->getEntitiesRestrictRequest(
'AND',
@@ -3482,11 +3547,11 @@ public function showResourcesToRemove()
);
}
- $cond = [];
+ $cond = ['is_not_leaving_only' => 'is_not_leaving_only'];
if ($available_contracttype !== false && is_array($available_contracttype)) {
$available_contracttype[] = 0;
- $cond = ['plugin_resources_contracttypes_id' => $available_contracttype];
+ $cond['plugin_resources_contracttypes_id'] = $available_contracttype;
}
$rand = mt_rand();
self::dropdown([
diff --git a/src/Resource_Change.php b/src/Resource_Change.php
index 67c69e1..862d74b 100644
--- a/src/Resource_Change.php
+++ b/src/Resource_Change.php
@@ -78,6 +78,7 @@ class Resource_Change extends CommonDBTM
const CHANGE_RESOURCEROLE = 14;
const CHANGE_RESOURCEFUNCTION = 15;
const CHANGE_RESOURCETEAM = 16;
+ const CHANGE_NAME = 17;
/**
@@ -131,6 +132,7 @@ static function getAllActions($menu = false)
$actions[self::CHANGE_CONTRACTTYPE] = self::getNameActions(self::CHANGE_CONTRACTTYPE);
$actions[self::CHANGE_AGENCY] = self::getNameActions(self::CHANGE_AGENCY);
$actions[self::CHANGE_RESOURCEINFORMATIONS] = self::getNameActions(self::CHANGE_RESOURCEINFORMATIONS);
+ $actions[self::CHANGE_NAME] = self::getNameActions(self::CHANGE_NAME);
$actions[self::CHANGE_RESOURCECOMPANY] = self::getNameActions(self::CHANGE_RESOURCECOMPANY);
$actions[self::CHANGE_RESOURCEDEPARTMENT] = self::getNameActions(self::CHANGE_RESOURCEDEPARTMENT);
$actions[self::CHANGE_RESOURCEMATERIAL] = self::getNameActions(self::CHANGE_RESOURCEMATERIAL);
@@ -187,6 +189,8 @@ static function getNameActions($actions_id)
return __('Badge restitution', 'resources');
case self::CHANGE_RESOURCEINFORMATIONS:
return __(' Change information', 'resources');
+ case self::CHANGE_NAME :
+ return __(' Change name', 'resources');
case self::CHANGE_RESOURCECOMPANY:
return __('Change company', 'resources');
case self::CHANGE_RESOURCEDEPARTMENT:
@@ -574,8 +578,7 @@ static function setFieldByAction($action_id, $plugin_resources_resources_id)
$rand = mt_rand();
$option = [
'rand' => $rand,
- 'value' => $resource->fields["name"],
- 'onChange' => "javascript:this.value=this.value.toUpperCase(); plugin_resources_load_button_changeresources_information(); "
+ 'value' => $resource->fields["name"]
];
echo Html::input('name', $option);
echo "";
@@ -611,7 +614,8 @@ static function setFieldByAction($action_id, $plugin_resources_resources_id)
echo "$('input[name=\"date_end\"]').change(function() {
plugin_resources_load_button_changeresources_information();
});
- $('input[name=\"name\"]').change(function() {
+ $('input[name=\"name\"]').on(\"input\", function() {
+ this.value = this.value.toUpperCase();
plugin_resources_load_button_changeresources_information();
});";
echo "function plugin_resources_load_button_changeresources_information(){";
@@ -625,6 +629,38 @@ static function setFieldByAction($action_id, $plugin_resources_resources_id)
echo "";
echo "";
+ break;
+ case self::CHANGE_NAME :
+
+ echo "";
+
+
+ echo "";
+ echo "";
+ echo "";
+
break;
case self::CHANGE_RESOURCECOMPANY:
echo "";
@@ -1049,6 +1085,13 @@ function loadButtonChangeResources($action_id, $options)
$display = true;
}
+ break;
+ case self::CHANGE_NAME :
+ if (isset($options['name'])
+ && !empty($options['name'])) {
+ $display = true;
+ }
+
break;
case self::CHANGE_RESOURCECOMPANY:
if (isset($options['plugin_resources_employers_id'])
@@ -1294,6 +1337,18 @@ static function startingChange($plugin_resources_resources_id, $action_id, $opti
$input['firstname'] = isset($options['firstname']) ? $options['firstname'] : $resource->getField('firstname');
$input['date_end'] = $options['date_end'];
break;
+ case self::CHANGE_NAME :
+ $data['name'] = __("Change information for", 'resources') . " " .
+ Resource::getResourceName($plugin_resources_resources_id);
+ $data['content'] = __("Change information for", 'resources') . " " .
+ Resource::getResourceName($plugin_resources_resources_id) . "\n";
+ $data['content'] .= __("Current name of the resource", 'resources') . " : " .
+ $resource->getField('name') . "\n";
+ $data['content'] .= __("New resource name", 'resources') . " : " .
+ $options['name'] . "\n";
+
+ $input['name'] = $options['name'];
+ break;
case self::CHANGE_RESOURCECOMPANY:
$data['name'] = __("Change of company for", 'resources') . " " .
Resource::getResourceName($plugin_resources_resources_id);
diff --git a/src/Resource_Leaving.php b/src/Resource_Leaving.php
index 07a2158..8df7fca 100644
--- a/src/Resource_Leaving.php
+++ b/src/Resource_Leaving.php
@@ -102,11 +102,9 @@ static function canCreate(): bool
**/
function getTabNameForItem(CommonGLPI $item, $withtemplate = 0) {
- $wizard_need = ContractType::checkWizardSetup($item->getField('id'), "use_need_wizard");
if ($item->getType() == Resource::class
&& $this->canView()
- && $wizard_need
) {
return self::createTabEntry(self::getTypeName(2));
}
@@ -163,7 +161,7 @@ function showLeavingForm($plugin_resources_resources_id) {
echo "
| ";
echo __('Departure date', 'resources');
echo " | ";
- echo Html::input('date_declaration_leaving', ['value' => $resources->fields['date_declaration_leaving'], 'readonly' => true]);
+ echo Html::input('date_end', ['value' => $resources->fields['date_end'], 'readonly' => true]);
echo " |
";
echo "| ";
echo __('Order', 'resources');
@@ -173,7 +171,7 @@ function showLeavingForm($plugin_resources_resources_id) {
echo " |
";
echo "| ";
if (empty($resources->fields['remove_order'])) {
- echo Html::submit(_sx('button', 'Validate'), ['name' => 'validOrderLeaving', 'class' => 'btn btn-primary']);
+ echo Html::submit(_sx('button', __('Validate', 'resources')), ['name' => 'validOrderLeaving', 'class' => 'btn btn-primary']);
}
echo " |
";
echo "";
diff --git a/src/Resource_Validation.php b/src/Resource_Validation.php
index 2b89f1e..102b6d2 100644
--- a/src/Resource_Validation.php
+++ b/src/Resource_Validation.php
@@ -44,7 +44,7 @@
class Resource_Validation extends CommonDBTM
{
- static $rightname = 'plugin_resources';
+ static $rightname = 'plugin_resources_validation';
/**
* @param int $nb
@@ -53,8 +53,10 @@ class Resource_Validation extends CommonDBTM
*/
static function getTypeName($nb = 0)
{
-
- return __('Validation and AD Synchronization','resources');
+ if ($nb == 1) {
+ return __('Validation','resources');
+ }
+ return __('AD Synchronization','resources');
}
static function getIcon()
@@ -103,12 +105,12 @@ static function canCreate(): bool
**/
function getTabNameForItem(CommonGLPI $item, $withtemplate = 0) {
- $wizard_need = ContractType::checkWizardSetup($item->getField('id'), "use_need_wizard");
-
if ($item->getType() == Resource::class
&& $this->canView()
- && $wizard_need
) {
+ if (!$item->fields['valid_resource_information']) {
+ return self::createTabEntry(self::getTypeName(1));
+ }
return self::createTabEntry(self::getTypeName(2));
}
return '';
@@ -147,49 +149,47 @@ function showValidationForm($plugin_resources_resources_id) {
return false;
}
- if ($canedit) {
- if (!$resources->fields['valid_resource_information']) {
-
- echo Ajax::createModalWindow(
- 'popupAnswer',
- PLUGIN_RESOURCES_WEBDIR . '/front/modalvalidationinfo.php',
- [
- 'title' => __('Are you sure?', 'resources'),
- 'reloadonclose' => false,
- 'width' => 1180,
- 'height' => 500,
- ]
- );
-// echo "