function showSpecificMassiveActionsParameters($input = array())
 {
     $PluginResourcesChecklist = new PluginResourcesChecklist();
     $PluginResourcesContractType = new PluginResourcesContractType();
     switch ($input['action']) {
         case "Generate_Rule":
             $PluginResourcesChecklist->dropdownChecklistType("checklist_type", $_SESSION["glpiactive_entity"]);
             echo " ";
             RuleCriteria::dropdownConditions("PluginResourcesRuleChecklist", array('criterion' => 'plugin_resources_contracttypes_id', 'allow_conditions' => array(Rule::PATTERN_IS, Rule::PATTERN_IS_NOT)));
             echo " ";
             $PluginResourcesContractType->dropdownContractType("plugin_resources_contracttypes_id");
             echo " ";
             echo "<input type=\"submit\" name=\"massiveaction\" class=\"submit\" value='" . _sx('button', 'Post') . "'>";
             return true;
             break;
         case "Transfert":
             Dropdown::show('Entity');
             echo "&nbsp;<input type=\"submit\" name=\"massiveaction\" class=\"submit\" value='" . _sx('button', 'Post') . "'>";
             return true;
             break;
         default:
             return parent::showSpecificMassiveActionsParameters($input);
             break;
     }
     return false;
 }
Exemple #2
0
 function showCentral($who)
 {
     global $DB, $CFG_GLPI;
     echo "<table class='tab_cadre_central'><tr><td>";
     if ($this->canView()) {
         $who = Session::getLoginUserID();
         if (Session::isMultiEntitiesMode()) {
             $colsup = 1;
         } else {
             $colsup = 0;
         }
         $ASSIGN = "";
         if ($who > 0) {
             $ASSIGN = " AND ((`" . $this->getTable() . "`.`users_id` = '{$who}')";
         }
         //if ($who_group>0) {
         $ASSIGN .= " OR (`" . $this->getTable() . "`.`groups_id` IN (SELECT `groups_id` \n                                                      FROM `glpi_groups_users` \n                                                      WHERE `users_id` = '{$who}') )";
         //}
         $query = "SELECT `" . $this->getTable() . "`.`id` AS plugin_resources_tasks_id, `" . $this->getTable() . "`.`name` AS name_task, `" . $this->getTable() . "`.`plugin_resources_tasktypes_id` AS plugin_resources_tasktypes_id,`" . $this->getTable() . "`.`is_deleted` AS is_deleted, ";
         $query .= "`" . $this->getTable() . "`.`users_id` AS users_id_task, `glpi_plugin_resources_resources`.`id` as id, `glpi_plugin_resources_resources`.`name` AS name, `glpi_plugin_resources_resources`.`firstname` AS firstname, `glpi_plugin_resources_resources`.`entities_id`, `glpi_plugin_resources_resources`.`users_id` as users_id ";
         $query .= " FROM `" . $this->getTable() . "`,`glpi_plugin_resources_resources` ";
         $query .= " WHERE `glpi_plugin_resources_resources`.`is_template` = '0' \n                  AND `glpi_plugin_resources_resources`.`is_deleted` = '0' \n                  AND `" . $this->getTable() . "`.`is_deleted` = '0' \n                  AND `" . $this->getTable() . "`.`is_finished` = '0' \n                  AND `" . $this->getTable() . "`.`plugin_resources_resources_id` = `glpi_plugin_resources_resources`.`id` \n                  {$ASSIGN} ) ";
         // Add Restrict to current entities
         $PluginResourcesResource = new PluginResourcesResource();
         $itemtable = "glpi_plugin_resources_resources";
         if ($PluginResourcesResource->isEntityAssign()) {
             $LINK = " AND ";
             $query .= getEntitiesRestrictRequest($LINK, $itemtable);
         }
         $query .= " ORDER BY `glpi_plugin_resources_resources`.`name` DESC LIMIT 10;";
         $result = $DB->query($query);
         $number = $DB->numrows($result);
         if ($number > 0) {
             echo "<div align='center'><table class='tab_cadre' width='100%'>";
             echo "<tr><th colspan='" . (7 + $colsup) . "'>" . PluginResourcesResource::getTypeName(2) . ": " . __('Tasks in progress', 'resources') . " <a href='" . $CFG_GLPI["root_doc"] . "/plugins/resources/front/task.php?contains%5B0%5D=0&field%5B0%5D=9&sort=1&is_deleted=0&start=0'>" . __('All') . "</a></th></tr>";
             echo "<tr><th>" . __('Name') . "</th>";
             if (Session::isMultiEntitiesMode()) {
                 echo "<th>" . __('Entity') . "</th>";
             }
             echo "<th>" . PluginResourcesTaskType::getTypeName(2) . "</th>";
             echo "<th>" . __('Planning') . "</th>";
             echo "<th>" . PluginResourcesResource::getTypeName(1) . "</th>";
             echo "<th>" . __('Resource manager', 'resources') . "</th>";
             echo "<th>" . __('User') . "</th>";
             echo "</tr>";
             while ($data = $DB->fetch_array($result)) {
                 echo "<tr class='tab_bg_1" . ($data["is_deleted"] == '1' ? "_2" : "") . "'>";
                 echo "<td class='center'><a href='" . $CFG_GLPI["root_doc"] . "/plugins/resources/front/task.form.php?id=" . $data["plugin_resources_tasks_id"] . "'>" . $data["name_task"];
                 if ($_SESSION["glpiis_ids_visible"]) {
                     echo " (" . $data["plugin_resources_tasks_id"] . ")";
                 }
                 echo "</a></td>";
                 if (Session::isMultiEntitiesMode()) {
                     echo "<td class='center'>" . Dropdown::getDropdownName("glpi_entities", $data['entities_id']) . "</td>";
                 }
                 echo "<td class='center'>" . Dropdown::getDropdownName("glpi_plugin_resources_tasktypes", $data["plugin_resources_tasktypes_id"]) . "</td>";
                 echo "<td align='center'>";
                 $restrict = " `plugin_resources_tasks_id` = '" . $data['plugin_resources_tasks_id'] . "' ";
                 $plans = getAllDatasFromTable("glpi_plugin_resources_taskplannings", $restrict);
                 if (!empty($plans)) {
                     foreach ($plans as $plan) {
                         echo Html::convDateTime($plan["begin"]) . "&nbsp;->&nbsp;" . Html::convDateTime($plan["end"]);
                     }
                 } else {
                     _e('None');
                 }
                 echo "</td>";
                 echo "<td class='center'><a href='" . $CFG_GLPI["root_doc"] . "/plugins/resources/front/resource.form.php?id=" . $data["id"] . "'>" . $data["name"] . " " . $data["firstname"];
                 if ($_SESSION["glpiis_ids_visible"]) {
                     echo " (" . $data["id"] . ")";
                 }
                 echo "</a></td>";
                 echo "<td class='center'>" . getUserName($data["users_id"]) . "</td>";
                 echo "<td class='center'>" . getUserName($data["users_id_task"]) . "</td>";
                 echo "</tr>";
             }
             echo "</table></div><br>";
         }
     }
     $PluginResourcesChecklist = new PluginResourcesChecklist();
     $PluginResourcesChecklist->showOnCentral(false);
     echo "<br>";
     $PluginResourcesChecklist->showOnCentral(true);
     echo "</td></tr></table>";
 }
    $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') {
    Html::footer();
} else {
    Html::helpFooter();
--------------------------------------------------------------------------
*/
include '../../../inc/includes.php';
if (!isset($_GET["id"])) {
    $_GET["id"] = "";
}
if (!isset($_GET["plugin_resources_contracttypes_id"])) {
    $_GET["plugin_resources_contracttypes_id"] = 0;
}
if (!isset($_GET["checklist_type"])) {
    $_GET["checklist_type"] = 0;
}
if (!isset($_GET["plugin_resources_resources_id"])) {
    $_GET["plugin_resources_resources_id"] = -1;
}
$checklist = new PluginResourcesChecklist();
//from central
//update checklist
if (isset($_POST["add"])) {
    $checklist->add($_POST);
    Html::back();
} else {
    if (isset($_POST["update"])) {
        if ($checklist->canCreate()) {
            $checklist->update($_POST);
        }
        Html::back();
    } else {
        $checklist->checkGlobal("r");
        Html::header(PluginResourcesResource::getTypeName(2), '', "plugins", "resources");
        $options = array('checklist_type' => $_GET["checklist_type"], 'plugin_resources_contracttypes_id' => $_GET["plugin_resources_contracttypes_id"], 'plugin_resources_resources_id' => $_GET["plugin_resources_resources_id"]);
Exemple #5
0
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with Resources. If not, see <http://www.gnu.org/licenses/>.
--------------------------------------------------------------------------
*/
include '../../../inc/includes.php';
if (!isset($_GET["id"])) {
    $_GET["id"] = "";
}
if (!isset($_GET["withtemplate"])) {
    $_GET["withtemplate"] = "";
}
$resource = new PluginResourcesResource();
$checklist = new PluginResourcesChecklist();
$checklistconfig = new PluginResourcesChecklistconfig();
$employee = new PluginResourcesEmployee();
$choice = new PluginResourcesChoice();
$resource_item = new PluginResourcesResource_Item();
$cat = new PluginResourcesTicketCategory();
$task = new PluginResourcesTask();
/////////////////////////////////resource from helpdesk///////////////////////////////
if (isset($_POST["resend"])) {
    $resource->reSendResourceCreation($_POST);
    $resource->redirectToList();
    //from helpdesk
    //add items needs of a resource
} else {
    if (isset($_POST["addhelpdeskitem"])) {
        if ($_POST['plugin_resources_choiceitems_id'] > 0 && $_POST['plugin_resources_resources_id'] > 0) {
 /**
  * Return a value associated with a pattern associated to a criteria to display it
  *
  * @param $ID the given criteria
  * @param $condition condition used
  * @param $pattern the pattern
  **/
 function getCriteriaDisplayPattern($ID, $condition, $pattern)
 {
     if ($condition == Rule::PATTERN_IS || $condition == Rule::PATTERN_IS_NOT) {
         $crit = $this->getCriteria($ID);
         if (isset($crit['type'])) {
             switch ($crit['type']) {
                 case "dropdownChecklistType":
                     $PluginResourcesChecklist = new PluginResourcesChecklist();
                     return $PluginResourcesChecklist->getChecklistType($pattern);
                 case "dropdownContractType":
                     $PluginResourcesContractType = new PluginResourcesContractType();
                     return $PluginResourcesContractType->getContractTypeName($pattern);
             }
         }
     }
     return $pattern;
 }
Exemple #7
0
 function showForm($ID, $options = array())
 {
     if (!Session::haveRight("profile", "r")) {
         return false;
     }
     $prof = new Profile();
     if ($ID) {
         $this->getFromDBByProfile($ID);
         $prof->getFromDB($ID);
     }
     $this->showFormHeader($options);
     echo "<tr class='tab_bg_2'>";
     echo "<th colspan='4'>" . sprintf(__('%1$s - %2$s'), __('Rights management', 'resources'), $prof->fields["name"]) . "</th>";
     echo "</tr>";
     echo "<tr class='tab_bg_2'>";
     echo "<td>" . PluginResourcesResource::getTypeName(2) . "</td><td>";
     Profile::dropdownNoneReadWrite("resources", $this->fields["resources"], 1, 1, 1);
     echo "</td>";
     echo "<td>" . PluginResourcesTask::getTypeName(2) . "</td><td>";
     if ($prof->fields['interface'] != 'helpdesk') {
         Profile::dropdownNoneReadWrite("task", $this->fields["task"], 1, 1, 1);
     } else {
         _e('No access');
         // No access;
     }
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_2'>";
     echo "<td>" . PluginResourcesChecklist::getTypeName(2) . "</td><td>";
     if ($prof->fields['interface'] != 'helpdesk') {
         Profile::dropdownNoneReadWrite("checklist", $this->fields["checklist"], 1, 1, 1);
     } else {
         _e('No access');
         // No access;
     }
     echo "</td>";
     echo "<td>" . PluginResourcesEmployee::getTypeName(2) . "</td><td>";
     Profile::dropdownNoneReadWrite("employee", $this->fields["employee"], 1, 1, 1);
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_2'>";
     echo "<td>" . __('All resources access', 'resources') . "</td><td>";
     Profile::dropdownNoneReadWrite("all", $this->fields["all"], 1, 0, 1);
     echo "</td>";
     echo "<td>" . __('Associable items to a ticket') . " - " . PluginResourcesResource::getTypeName(2) . "</td><td>";
     if ($prof->fields['create_ticket']) {
         Dropdown::showYesNo("open_ticket", $this->fields["open_ticket"]);
     } else {
         echo Dropdown::getYesNo(0);
     }
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_2'>";
     echo "<th colspan='4' class='center b'>" . __('Service company management', 'resources') . "</th>";
     echo "</tr>";
     echo "<tr class='tab_bg_2'>";
     echo "<td>" . PluginResourcesResourceResting::getTypeName(2) . "</td><td>";
     Profile::dropdownNoneReadWrite("resting", $this->fields["resting"], 1, 0, 1);
     echo "</td>";
     echo "<td>" . PluginResourcesResourceHoliday::getTypeName(2) . "</td><td>";
     Profile::dropdownNoneReadWrite("holiday", $this->fields["holiday"], 1, 0, 1);
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_2'>";
     echo "<th colspan='4' class='center b'>" . __('Public service management', 'resources') . "</th>";
     echo "</tr>";
     echo "<tr class='tab_bg_2'>";
     echo "<td>" . PluginResourcesEmployment::getTypeName(2) . "</td><td>";
     Profile::dropdownNoneReadWrite("employment", $this->fields["employment"], 1, 1, 1);
     echo "</td>";
     echo "<td>" . PluginResourcesBudget::getTypeName(2) . ":</td><td>";
     Profile::dropdownNoneReadWrite("budget", $this->fields["budget"], 1, 1, 1);
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_2'>";
     echo "<td>" . __('Dropdown management', 'resources') . "</td><td>";
     Profile::dropdownNoneReadWrite("dropdown_public", $this->fields["dropdown_public"], 1, 1, 1);
     echo "</td><td></td><td></td>";
     echo "</tr>";
     echo "<input type='hidden' name='id' value=" . $this->fields["id"] . ">";
     $options['candel'] = false;
     $this->showFormButtons($options);
 }
 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);
         }
     }
 }
 function getDatasForTemplate($event, $options = array())
 {
     global $CFG_GLPI, $DB;
     if ($event == 'AlertExpiredTasks') {
         $this->datas['##resource.entity##'] = Dropdown::getDropdownName('glpi_entities', $options['entities_id']);
         $this->datas['##lang.resource.entity##'] = __('Entity');
         $this->datas['##resource.action##'] = __('List of not finished tasks', 'resources');
         $this->datas['##lang.task.name##'] = __('Name');
         $this->datas['##lang.task.type##'] = __('Type');
         $this->datas['##lang.task.users##'] = __('Technician');
         $this->datas['##lang.task.groups##'] = __('Group');
         $this->datas['##lang.task.datebegin##'] = __('Begin date');
         $this->datas['##lang.task.dateend##'] = __('End date');
         $this->datas['##lang.task.planned##'] = __('Used for planning', 'resources');
         $this->datas['##lang.task.realtime##'] = __('Effective duration', 'resources');
         $this->datas['##lang.task.finished##'] = __('Carried out task', 'resources');
         $this->datas['##lang.task.comment##'] = __('Comments');
         $this->datas['##lang.task.resource##'] = PluginResourcesResource::getTypeName(1);
         foreach ($options['tasks'] as $id => $task) {
             $tmp = array();
             $tmp['##task.name##'] = $task['name'];
             $tmp['##task.type##'] = Dropdown::getDropdownName('glpi_plugin_resources_tasktypes', $task['plugin_resources_tasktypes_id']);
             $tmp['##task.users##'] = Html::clean(getUserName($task['users_id']));
             $tmp['##task.groups##'] = Dropdown::getDropdownName('glpi_groups', $task['groups_id']);
             $restrict = " `plugin_resources_tasks_id` = '" . $task['id'] . "' ";
             $plans = getAllDatasFromTable("glpi_plugin_resources_taskplannings", $restrict);
             if (!empty($plans)) {
                 foreach ($plans as $plan) {
                     $tmp['##task.datebegin##'] = Html::convDateTime($plan["begin"]);
                     $tmp['##task.dateend##'] = Html::convDateTime($plan["end"]);
                 }
             } else {
                 $tmp['##task.datebegin##'] = '';
                 $tmp['##task.dateend##'] = '';
             }
             $tmp['##task.planned##'] = '';
             $tmp['##task.finished##'] = Dropdown::getYesNo($task['is_finished']);
             $tmp['##task.realtime##'] = Ticket::getActionTime($task["actiontime"]);
             $comment = stripslashes(str_replace(array('\\r\\n', '\\n', '\\r'), "<br/>", $task['comment']));
             $tmp['##task.comment##'] = Html::clean($comment);
             $tmp['##task.resource##'] = Dropdown::getDropdownName('glpi_plugin_resources_resources', $task['plugin_resources_resources_id']);
             $this->datas['tasks'][] = $tmp;
         }
     } else {
         if ($event == 'AlertLeavingResources') {
             $this->datas['##resource.entity##'] = Dropdown::getDropdownName('glpi_entities', $options['entities_id']);
             $this->datas['##lang.resource.entity##'] = __('Entity');
             $this->datas['##resource.action##'] = __('These resources have normally left the company', 'resources');
             $this->datas['##lang.resource.id##'] = "ID";
             $this->datas['##lang.resource.name##'] = __('Name');
             $this->datas['##lang.resource.firstname##'] = __('First name');
             $this->datas['##lang.resource.type##'] = PluginResourcesContractType::getTypeName(1);
             $this->datas['##lang.resource.users##'] = __('Resource manager', 'resources');
             $this->datas['##lang.resource.usersrecipient##'] = __('Requester');
             $this->datas['##lang.resource.datedeclaration##'] = __('Request date');
             $this->datas['##lang.resource.datebegin##'] = __('Arrival date', 'resources');
             $this->datas['##lang.resource.dateend##'] = __('Departure date', 'resources');
             $this->datas['##lang.resource.department##'] = PluginResourcesDepartment::getTypeName(1);
             $this->datas['##lang.resource.status##'] = PluginResourcesResourceState::getTypeName(1);
             $this->datas['##lang.resource.location##'] = __('Location');
             $this->datas['##lang.resource.comment##'] = __('Description');
             $this->datas['##lang.resource.usersleaving##'] = __('Informant of leaving', 'resources');
             $this->datas['##lang.resource.leaving##'] = __('Declared as leaving', 'resources');
             $this->datas['##lang.resource.leavingreason##'] = PluginResourcesLeavingReason::getTypeName(1);
             $this->datas['##lang.resource.helpdesk##'] = __('Associable to a ticket');
             $this->datas['##lang.resource.url##'] = __('URL');
             foreach ($options['resources'] as $id => $resource) {
                 $tmp = array();
                 $tmp['##resource.name##'] = $resource['name'];
                 $tmp['##resource.firstname##'] = $resource['firstname'];
                 $tmp['##resource.type##'] = Dropdown::getDropdownName('glpi_plugin_resources_contracttypes', $resource['plugin_resources_contracttypes_id']);
                 $tmp['##resource.users##'] = Html::clean(getUserName($resource['users_id']));
                 $tmp['##resource.usersrecipient##'] = Html::clean(getUserName($resource['users_id_recipient']));
                 $tmp['##resource.datedeclaration##'] = Html::convDateTime($resource['date_declaration']);
                 $tmp['##resource.datebegin##'] = Html::convDateTime($resource['date_begin']);
                 $tmp['##resource.dateend##'] = Html::convDateTime($resource['date_end']);
                 $tmp['##resource.department##'] = Dropdown::getDropdownName('glpi_plugin_resources_departments', $resource['plugin_resources_departments_id']);
                 $tmp['##resource.status##'] = Dropdown::getDropdownName('glpi_plugin_resources_resourcestates', $resource['plugin_resources_resourcestates_id']);
                 $tmp['##resource.location##'] = Dropdown::getDropdownName('glpi_locations', $resource['locations_id']);
                 $comment = stripslashes(str_replace(array('\\r\\n', '\\n', '\\r'), "<br/>", $resource['comment']));
                 $tmp['##resource.comment##'] = Html::clean($comment);
                 $tmp['##resource.usersleaving##'] = Html::clean(getUserName($resource['users_id_recipient_leaving']));
                 $tmp['##resource.leaving##'] = Dropdown::getYesNo($resource['is_leaving']);
                 $tmp['##resource.leavingreason##'] = Dropdown::getDropdownName('glpi_plugin_resources_leavingreasons', $resource['plugin_resources_leavingreasons_id']);
                 $tmp['##resource.helpdesk##'] = Dropdown::getYesNo($resource['is_helpdesk_visible']);
                 $tmp['##resource.url##'] = urldecode($CFG_GLPI["url_base"] . "/index.php?redirect=plugin_resources_" . $resource['id']);
                 $this->datas['resources'][] = $tmp;
             }
         } else {
             if ($event == 'AlertArrivalChecklists' || $event == 'AlertLeavingChecklists') {
                 $this->datas['##checklist.entity##'] = Dropdown::getDropdownName('glpi_entities', $options['entities_id']);
                 $this->datas['##lang.checklist.entity##'] = __('Entity');
                 if ($event == 'AlertArrivalChecklists') {
                     $checklist_type = PluginResourcesChecklist::RESOURCES_CHECKLIST_IN;
                     $this->datas['##checklist.action##'] = __('Actions to do on these new resources', 'resources');
                     $this->datas['##lang.checklist.title##'] = __('New resource - checklist needs to verificated', 'resources');
                 } else {
                     $checklist_type = PluginResourcesChecklist::RESOURCES_CHECKLIST_OUT;
                     $this->datas['##checklist.action##'] = __('Actions to do on these leaving resources', 'resources');
                     $this->datas['##lang.checklist.title##'] = __('Leaving resource - checklist needs to verificated', 'resources');
                 }
                 $this->datas['##lang.checklist.title2##'] = __('Checklist needs to verificated', 'resources');
                 $this->datas['##lang.checklist.id##'] = "ID";
                 $this->datas['##lang.checklist.name##'] = __('Name');
                 $this->datas['##lang.checklist.firstname##'] = __('First name');
                 $this->datas['##lang.checklist.type##'] = PluginResourcesContractType::getTypeName(1);
                 $this->datas['##lang.checklist.users##'] = __('Resource manager', 'resources');
                 $this->datas['##lang.checklist.usersrecipient##'] = __('Requester');
                 $this->datas['##lang.checklist.datedeclaration##'] = __('Request date');
                 $this->datas['##lang.checklist.datebegin##'] = __('Arrival date', 'resources');
                 $this->datas['##lang.checklist.dateend##'] = __('Departure date', 'resources');
                 $this->datas['##lang.checklist.department##'] = PluginResourcesDepartment::getTypeName(1);
                 $this->datas['##lang.checklist.status##'] = PluginResourcesResourceState::getTypeName(1);
                 $this->datas['##lang.checklist.location##'] = __('Location');
                 $this->datas['##lang.checklist.comment##'] = __('Description');
                 $this->datas['##lang.checklist.usersleaving##'] = __('Informant of leaving', 'resources');
                 $this->datas['##lang.checklist.leaving##'] = __('Declared as leaving', 'resources');
                 //         $this->datas['##lang.checklist.leavingreason##'] = PluginResourcesLeavingReason::getTypeName(1);
                 $this->datas['##lang.checklist.helpdesk##'] = __('Associable to a ticket');
                 $this->datas['##lang.checklist.url##'] = "URL";
                 foreach ($options['checklists'] as $id => $checklist) {
                     $tmp = array();
                     $tmp['##checklist.id##'] = $checklist['plugin_resources_resources_id'];
                     $tmp['##checklist.name##'] = $checklist['resource_name'];
                     $tmp['##checklist.firstname##'] = $checklist['resource_firstname'];
                     $tmp['##checklist.type##'] = Dropdown::getDropdownName('glpi_plugin_resources_contracttypes', $checklist['plugin_resources_contracttypes_id']);
                     $tmp['##checklist.users##'] = Html::clean(getUserName($checklist['users_id']));
                     $tmp['##checklist.usersrecipient##'] = Html::clean(getUserName($checklist['users_id_recipient']));
                     $tmp['##checklist.datedeclaration##'] = Html::convDateTime($checklist['date_declaration']);
                     $tmp['##checklist.datebegin##'] = Html::convDateTime($checklist['date_begin']);
                     $tmp['##checklist.dateend##'] = Html::convDateTime($checklist['date_end']);
                     $tmp['##checklist.department##'] = Dropdown::getDropdownName('glpi_plugin_resources_departments', $checklist['plugin_resources_departments_id']);
                     $tmp['##checklist.status##'] = Dropdown::getDropdownName('glpi_plugin_resources_resourcestates', $checklist['plugin_resources_resourcestates_id']);
                     $tmp['##checklist.location##'] = Dropdown::getDropdownName('glpi_locations', $checklist['locations_id']);
                     $comment = stripslashes(str_replace(array('\\r\\n', '\\n', '\\r'), "<br/>", $checklist['comment']));
                     $tmp['##checklist.comment##'] = Html::clean($comment);
                     $tmp['##checklist.usersleaving##'] = Html::clean(getUserName($checklist['users_id_recipient_leaving']));
                     $tmp['##checklist.leaving##'] = Dropdown::getYesNo($checklist['is_leaving']);
                     //            $tmp['##checklist.leavingreason##'] = Dropdown::getDropdownName('glpi_plugin_resources_leavingreasons',
                     //                                                   $checklist['plugin_resources_leavingreasons_id']);
                     $tmp['##checklist.helpdesk##'] = Dropdown::getYesNo($checklist['is_helpdesk_visible']);
                     $tmp['##checklist.url##'] = urldecode($CFG_GLPI["url_base"] . "/index.php?redirect=plugin_resources_" . $checklist['plugin_resources_resources_id']);
                     $query = PluginResourcesChecklist::queryListChecklists($checklist['plugin_resources_resources_id'], $checklist_type);
                     $tmp['##tasklist.name##'] = '';
                     foreach ($DB->request($query) as $data) {
                         $tmp['##tasklist.name##'] .= $data["name"];
                         if ($_SESSION["glpiis_ids_visible"] == 1) {
                             $tmp['##tasklist.name##'] .= " (" . $data["id"] . ")";
                         }
                         $tmp['##tasklist.name##'] .= "\n";
                     }
                     $this->datas['checklists'][] = $tmp;
                 }
             } else {
                 if ($event == 'LeavingResource') {
                     $this->datas['##resource.entity##'] = Dropdown::getDropdownName('glpi_entities', $this->obj->getField('entities_id'));
                     $this->datas['##lang.resource.entity##'] = __('Entity');
                     $this->datas['##lang.resource.title##'] = __('A resource has been declared leaving', 'resources');
                     $this->datas['##lang.resource.title2##'] = __('Please check the leaving checklist of the resource', 'resources');
                     $this->datas['##lang.resource.id##'] = "ID";
                     $this->datas['##resource.id##'] = $this->obj->getField("id");
                     $this->datas['##lang.resource.name##'] = __('Name');
                     $this->datas['##resource.name##'] = $this->obj->getField("name");
                     $this->datas['##lang.resource.firstname##'] = __('First name');
                     $this->datas['##resource.firstname##'] = $this->obj->getField("firstname");
                     $this->datas['##lang.resource.type##'] = PluginResourcesContractType::getTypeName(1);
                     $this->datas['##resource.type##'] = Dropdown::getDropdownName('glpi_plugin_resources_contracttypes', $this->obj->getField('plugin_resources_contracttypes_id'));
                     $this->datas['##lang.resource.situation##'] = PluginResourcesResourceSituation::getTypeName(1);
                     $this->datas['##resource.situation##'] = Dropdown::getDropdownName('glpi_plugin_resources_resourcesituations', $this->obj->getField('plugin_resources_resourcesituations_id'));
                     $this->datas['##lang.resource.contractnature##'] = PluginResourcesContractNature::getTypeName(1);
                     $this->datas['##resource.contractnature##'] = Dropdown::getDropdownName('glpi_plugin_resources_contractnatures', $this->obj->getField('plugin_resources_contractnatures_id'));
                     $this->datas['##lang.resource.quota##'] = __('Quota', 'resources');
                     $this->datas['##resource.quota##'] = $this->obj->getField('quota');
                     $this->datas['##lang.resource.department##'] = PluginResourcesDepartment::getTypeName(1);
                     $this->datas['##resource.department##'] = Dropdown::getDropdownName('glpi_plugin_resources_departments', $this->obj->getField('plugin_resources_departments_id'));
                     $this->datas['##lang.resource.rank##'] = PluginResourcesRank::getTypeName(1);
                     $this->datas['##resource.rank##'] = Dropdown::getDropdownName('glpi_plugin_resources_ranks', $this->obj->getField('plugin_resources_ranks_id'));
                     $this->datas['##lang.resource.speciality##'] = PluginResourcesResourceSpeciality::getTypeName(1);
                     $this->datas['##resource.speciality##'] = Dropdown::getDropdownName('glpi_plugin_resources_resourcespecialities', $this->obj->getField('plugin_resources_resourcespecialities_id'));
                     $this->datas['##lang.resource.status##'] = PluginResourcesResourceState::getTypeName(1);
                     $this->datas['##resource.status##'] = Dropdown::getDropdownName('glpi_plugin_resources_resourcestates', $this->obj->getField('plugin_resources_resourcestates_id'));
                     $this->datas['##lang.resource.users##'] = __('Resource manager', 'resources');
                     $this->datas['##resource.users##'] = Html::clean(getUserName($this->obj->getField("users_id")));
                     $this->datas['##lang.resource.usersrecipient##'] = __('Requester');
                     $this->datas['##resource.usersrecipient##'] = Html::clean(getUserName($this->obj->getField("users_id_recipient")));
                     $this->datas['##lang.resource.datedeclaration##'] = __('Request date');
                     $this->datas['##resource.datedeclaration##'] = Html::convDate($this->obj->getField('date_declaration'));
                     $this->datas['##lang.resource.datebegin##'] = __('Arrival date', 'resources');
                     $this->datas['##resource.datebegin##'] = Html::convDate($this->obj->getField('date_begin'));
                     $this->datas['##lang.resource.dateend##'] = __('Departure date', 'resources');
                     $this->datas['##resource.dateend##'] = Html::convDate($this->obj->getField('date_end'));
                     $this->datas['##lang.resource.location##'] = __('Location');
                     $this->datas['##resource.location##'] = Dropdown::getDropdownName('glpi_locations', $this->obj->getField('locations_id'));
                     $this->datas['##lang.resource.helpdesk##'] = __('Associable to a ticket');
                     $this->datas['##resource.helpdesk##'] = Dropdown::getYesNo($this->obj->getField('is_helpdesk_visible'));
                     $this->datas['##lang.resource.leaving##'] = __('Declared as leaving', 'resources');
                     $this->datas['##resource.leaving##'] = Dropdown::getYesNo($this->obj->getField('is_leaving'));
                     $this->datas['##lang.resource.leavingreason##'] = PluginResourcesLeavingReason::getTypeName(1);
                     $this->datas['##resource.leavingreason##'] = Dropdown::getDropdownName('glpi_plugin_resources_leavingreasons', $this->obj->getField('plugin_resources_leavingreasons_id'));
                     $this->datas['##lang.resource.usersleaving##'] = __('Informant of leaving', 'resources');
                     $this->datas['##resource.usersleaving##'] = Html::clean(getUserName($this->obj->getField('users_id_recipient_leaving')));
                     $this->datas['##lang.resource.comment##'] = __('Description');
                     $comment = stripslashes(str_replace(array('\\r\\n', '\\n', '\\r'), "<br/>", $this->obj->getField("comment")));
                     $this->datas['##resource.comment##'] = Html::clean($comment);
                     $this->datas['##lang.resource.url##'] = "URL";
                     $this->datas['##resource.url##'] = urldecode($CFG_GLPI["url_base"] . "/index.php?redirect=plugin_resources_" . $this->obj->getField("id"));
                     $this->datas['##lang.resource.badge##'] = " ";
                     if (isset($this->target_object->input['checkbadge'])) {
                         if (!empty($this->target_object->input['checkbadge'])) {
                             $this->datas['##lang.resource.badge##'] = __('Thanks to recover his badges', 'resources');
                         } else {
                             $this->datas['##lang.resource.badge##'] = " ";
                         }
                     }
                 } else {
                     $events = $this->getAllEvents();
                     $this->datas['##lang.resource.title##'] = $events[$event];
                     $this->datas['##resource.action_user##'] = getUserName(Session::getLoginUserID());
                     $this->datas['##lang.resource.entity##'] = __('Entity');
                     $this->datas['##resource.entity##'] = Dropdown::getDropdownName('glpi_entities', $this->obj->getField('entities_id'));
                     $this->datas['##resource.id##'] = $this->obj->getField("id");
                     $this->datas['##lang.resource.name##'] = __('Name');
                     $this->datas['##resource.name##'] = $this->obj->getField("name");
                     $this->datas['##lang.resource.firstname##'] = __('First name');
                     $this->datas['##resource.firstname##'] = $this->obj->getField("firstname");
                     $this->datas['##lang.resource.type##'] = PluginResourcesContractType::getTypeName(1);
                     $this->datas['##resource.type##'] = Dropdown::getDropdownName('glpi_plugin_resources_contracttypes', $this->obj->getField('plugin_resources_contracttypes_id'));
                     $this->datas['##lang.resource.situation##'] = PluginResourcesResourceSituation::getTypeName(1);
                     $this->datas['##resource.situation##'] = Dropdown::getDropdownName('glpi_plugin_resources_resourcesituations', $this->obj->getField('plugin_resources_resourcesituations_id'));
                     $this->datas['##lang.resource.contractnature##'] = PluginResourcesContractNature::getTypeName(1);
                     $this->datas['##resource.contractnature##'] = Dropdown::getDropdownName('glpi_plugin_resources_contractnatures', $this->obj->getField('plugin_resources_contractnatures_id'));
                     $this->datas['##lang.resource.quota##'] = __('Quota', 'resources');
                     $this->datas['##resource.quota##'] = $this->obj->getField('quota');
                     $this->datas['##lang.resource.users##'] = __('Resource manager', 'resources');
                     $this->datas['##resource.users##'] = Html::clean(getUserName($this->obj->getField("users_id")));
                     $this->datas['##lang.resource.usersrecipient##'] = __('Requester');
                     $this->datas['##resource.usersrecipient##'] = Html::clean(getUserName($this->obj->getField("users_id_recipient")));
                     $this->datas['##lang.resource.datedeclaration##'] = __('Request date');
                     $this->datas['##resource.datedeclaration##'] = Html::convDate($this->obj->getField('date_declaration'));
                     $this->datas['##lang.resource.datebegin##'] = __('Arrival date', 'resources');
                     $this->datas['##resource.datebegin##'] = Html::convDate($this->obj->getField('date_begin'));
                     $this->datas['##lang.resource.dateend##'] = __('Departure date', 'resources');
                     $this->datas['##resource.dateend##'] = Html::convDate($this->obj->getField('date_end'));
                     $this->datas['##lang.resource.department##'] = PluginResourcesDepartment::getTypeName(1);
                     $this->datas['##resource.department##'] = Dropdown::getDropdownName('glpi_plugin_resources_departments', $this->obj->getField('plugin_resources_departments_id'));
                     $this->datas['##lang.resource.rank##'] = PluginResourcesRank::getTypeName(1);
                     $this->datas['##resource.rank##'] = Dropdown::getDropdownName('glpi_plugin_resources_ranks', $this->obj->getField('plugin_resources_ranks_id'));
                     $this->datas['##lang.resource.speciality##'] = PluginResourcesResourceSpeciality::getTypeName(1);
                     $this->datas['##resource.speciality##'] = Dropdown::getDropdownName('glpi_plugin_resources_resourcespecialities', $this->obj->getField('plugin_resources_resourcespecialities_id'));
                     $this->datas['##lang.resource.status##'] = PluginResourcesResourceState::getTypeName(1);
                     $this->datas['##resource.status##'] = Dropdown::getDropdownName('glpi_plugin_resources_resourcestates', $this->obj->getField('plugin_resources_resourcestates_id'));
                     $this->datas['##lang.resource.location##'] = __('Location');
                     $this->datas['##resource.location##'] = Dropdown::getDropdownName('glpi_locations', $this->obj->getField('locations_id'));
                     $this->datas['##lang.resource.comment##'] = __('Description');
                     $comment = stripslashes(str_replace(array('\\r\\n', '\\n', '\\r'), "<br/>", $this->obj->getField("comment")));
                     $this->datas['##resource.comment##'] = Html::clean($comment);
                     $this->datas['##lang.resource.usersleaving##'] = __('Informant of leaving', 'resources');
                     $this->datas['##resource.usersleaving##'] = Html::clean(getUserName($this->obj->getField("users_id_recipient_leaving")));
                     $this->datas['##lang.resource.leaving##'] = __('Declared as leaving', 'resources');
                     $this->datas['##resource.leaving##'] = Dropdown::getYesNo($this->obj->getField('is_leaving'));
                     $this->datas['##lang.resource.leavingreason##'] = PluginResourcesLeavingReason::getTypeName(1);
                     $this->datas['##resource.leavingreason##'] = Dropdown::getDropdownName('glpi_plugin_resources_leavingreasons', $this->obj->getField('plugin_resources_leavingreasons_id'));
                     $this->datas['##lang.resource.helpdesk##'] = __('Associable to a ticket');
                     $this->datas['##resource.helpdesk##'] = Dropdown::getYesNo($this->obj->getField('is_helpdesk_visible'));
                     $this->datas['##lang.resource.url##'] = "URL";
                     $this->datas['##resource.url##'] = urldecode($CFG_GLPI["url_base"] . "/index.php?redirect=plugin_resources_" . $this->obj->getField("id"));
                     if ($event == 'report') {
                         $this->datas['##lang.resource.creationtitle##'] = __('Creation report of the human resource', 'resources');
                         $this->datas['##resource.login##'] = "";
                         $this->datas['##resource.email##'] = "";
                         $restrict = "`itemtype` = 'User' \n                        AND `plugin_resources_resources_id` = '" . $this->obj->getField("id") . "'";
                         $items = getAllDatasFromTable("glpi_plugin_resources_resources_items", $restrict);
                         if (!empty($items)) {
                             foreach ($items as $item) {
                                 $user = new User();
                                 $user->getFromDB($item["items_id"]);
                                 $this->datas['##resource.login##'] = $user->fields["name"];
                                 $this->datas['##resource.email##'] = $user->getDefaultEmail();
                             }
                         }
                         $this->datas['##lang.resource.login##'] = __('Login');
                         $this->datas['##lang.resource.creation##'] = __('Informations of the created user', 'resources');
                         $this->datas['##lang.resource.datecreation##'] = __('Creation Date');
                         $this->datas['##resource.datecreation##'] = Html::convDate(date("Y-m-d"));
                         $this->datas['##lang.resource.email##'] = __('Email');
                         $this->datas['##lang.resource.informationtitle##'] = __('Additional informations', 'resources');
                         $PluginResourcesReportConfig = new PluginResourcesReportConfig();
                         $PluginResourcesReportConfig->getFromDB($options['reports_id']);
                         $this->datas['##lang.resource.informations##'] = __('Information', 'Informations', 2);
                         $information = stripslashes(str_replace(array('\\r\\n', '\\n', '\\r'), "<br>", $PluginResourcesReportConfig->fields['information']));
                         $this->datas['##resource.informations##'] = Html::clean(nl2br($information));
                         $this->datas['##lang.resource.commentaires##'] = __('Comments');
                         $commentaire = stripslashes(str_replace(array('\\r\\n', '\\n', '\\r'), "<br>", $PluginResourcesReportConfig->fields['comment']));
                         $this->datas['##resource.commentaires##'] = Html::clean(nl2br($commentaire));
                     }
                     if ($event == 'newresting' || $event == 'updateresting' || $event == 'deleteresting') {
                         $this->datas['##lang.resource.restingtitle##'] = __('Non contract period management', 'resources');
                         $this->datas['##lang.resource.resting##'] = __('Detail of non contract period', 'resources');
                         $this->datas['##lang.resource.datecreation##'] = __('Creation date');
                         $this->datas['##resource.datecreation##'] = Html::convDate(date("Y-m-d"));
                         $PluginResourcesResourceResting = new PluginResourcesResourceResting();
                         $PluginResourcesResourceResting->getFromDB($options['resting_id']);
                         $this->datas['##lang.resource.location##'] = __('Agency concerned');
                         $this->datas['##resource.location##'] = Dropdown::getDropdownName('glpi_locations', $PluginResourcesResourceResting->fields['locations_id']);
                         $this->datas['##lang.resource.home##'] = __('At home');
                         $this->datas['##resource.home##'] = Dropdown::getYesNo($PluginResourcesResourceResting->fields['at_home']);
                         $this->datas['##lang.resource.datebegin##'] = __('Begin date');
                         $this->datas['##resource.datebegin##'] = Html::convDate($PluginResourcesResourceResting->fields['date_begin']);
                         $this->datas['##lang.resource.dateend##'] = __('End date');
                         $this->datas['##resource.dateend##'] = Html::convDate($PluginResourcesResourceResting->fields['date_end']);
                         $this->datas['##lang.resource.informationtitle##'] = __('Additional informations', 'resources');
                         $this->datas['##lang.resource.commentaires##'] = __('Comments');
                         $commentaire = stripslashes(str_replace(array('\\r\\n', '\\n', '\\r'), "<br>", $PluginResourcesResourceResting->fields['comment']));
                         $this->datas['##resource.commentaires##'] = Html::clean(nl2br($commentaire));
                         $this->datas['##lang.resource.openby##'] = __('Reported by', 'resources');
                         $this->datas['##resource.openby##'] = Html::clean(getUserName(Session::getLoginUserID()));
                         if (isset($options['oldvalues']) && !empty($options['oldvalues'])) {
                             $this->target_object->oldvalues = $options['oldvalues'];
                         }
                     }
                     if ($event == 'newholiday' || $event == 'updateholiday' || $event == 'deleteholiday') {
                         $this->datas['##lang.resource.holidaytitle##'] = __('Forced holiday management', 'resources');
                         $this->datas['##lang.resource.holiday##'] = __('Detail of the forced holiday', 'resources');
                         $this->datas['##lang.resource.datecreation##'] = __('Creation date');
                         $this->datas['##resource.datecreation##'] = Html::convDate(date("Y-m-d"));
                         $PluginResourcesResourceHoliday = new PluginResourcesResourceHoliday();
                         $PluginResourcesResourceHoliday->getFromDB($options['holiday_id']);
                         $this->datas['##lang.resource.datebegin##'] = __('Begin date');
                         $this->datas['##resource.datebegin##'] = Html::convDate($PluginResourcesResourceHoliday->fields['date_begin']);
                         $this->datas['##lang.resource.dateend##'] = __('End date');
                         $this->datas['##resource.dateend##'] = Html::convDate($PluginResourcesResourceHoliday->fields['date_end']);
                         $this->datas['##lang.resource.informationtitle##'] = __('Additional informations', 'resources');
                         $this->datas['##lang.resource.commentaires##'] = __('Comments');
                         $commentaire = stripslashes(str_replace(array('\\r\\n', '\\n', '\\r'), "<br>", $PluginResourcesResourceHoliday->fields['comment']));
                         $this->datas['##resource.commentaires##'] = Html::clean(nl2br($commentaire));
                         $this->datas['##lang.resource.openby##'] = __('Reported by', 'resources');
                         $this->datas['##resource.openby##'] = Html::clean(getUserName(Session::getLoginUserID()));
                         if (isset($options['oldvalues']) && !empty($options['oldvalues'])) {
                             $this->target_object->oldvalues = $options['oldvalues'];
                         }
                     }
                     //old values infos
                     if (isset($this->target_object->oldvalues) && !empty($this->target_object->oldvalues) && ($event == 'update' || $event == 'updateresting' || $event == 'updateholiday')) {
                         $this->datas['##lang.update.title##'] = __('Modified fields', 'resources');
                         $tmp = array();
                         if (isset($this->target_object->oldvalues['name'])) {
                             if (empty($this->target_object->oldvalues['name'])) {
                                 $tmp['##update.name##'] = "---";
                             } else {
                                 $tmp['##update.name##'] = $this->target_object->oldvalues['name'];
                             }
                         }
                         if (isset($this->target_object->oldvalues['firstname'])) {
                             if (empty($this->target_object->oldvalues['firstname'])) {
                                 $tmp['##update.firstname##'] = "---";
                             } else {
                                 $tmp['##update.firstname##'] = $this->target_object->oldvalues['firstname'];
                             }
                         }
                         if (isset($this->target_object->oldvalues['plugin_resources_contracttypes_id'])) {
                             if (empty($this->target_object->oldvalues['plugin_resources_contracttypes_id'])) {
                                 $tmp['##update.type##'] = "---";
                             } else {
                                 $tmp['##update.type##'] = Dropdown::getDropdownName('glpi_plugin_resources_contracttypes', $this->target_object->oldvalues['plugin_resources_contracttypes_id']);
                             }
                         }
                         if (isset($this->target_object->oldvalues['users_id'])) {
                             if (empty($this->target_object->oldvalues['users_id'])) {
                                 $tmp['##update.users##'] = "---";
                             } else {
                                 $tmp['##update.users##'] = Html::clean(getUserName($this->target_object->oldvalues['users_id']));
                             }
                         }
                         if (isset($this->target_object->oldvalues['users_id_recipient'])) {
                             if (empty($this->target_object->oldvalues['users_id_recipient'])) {
                                 $tmp['##update.usersrecipient##'] = "---";
                             } else {
                                 $tmp['##update.usersrecipient##'] = Html::clean(getUserName($this->target_object->oldvalues['users_id_recipient']));
                             }
                         }
                         if (isset($this->target_object->oldvalues['date_declaration'])) {
                             if (empty($this->target_object->oldvalues['date_declaration'])) {
                                 $tmp['##update.datedeclaration##'] = "---";
                             } else {
                                 $tmp['##update.datedeclaration##'] = Html::convDate($this->target_object->oldvalues['date_declaration']);
                             }
                         }
                         if (isset($this->target_object->oldvalues['date_begin'])) {
                             if (empty($this->target_object->oldvalues['date_begin'])) {
                                 $tmp['##update.datebegin##'] = "---";
                             } else {
                                 $tmp['##update.datebegin##'] = Html::convDate($this->target_object->oldvalues['date_begin']);
                             }
                         }
                         if (isset($this->target_object->oldvalues['date_end'])) {
                             if (empty($this->target_object->oldvalues['date_end'])) {
                                 $tmp['##update.dateend##'] = "---";
                             } else {
                                 $tmp['##update.dateend##'] = Html::convDate($this->target_object->oldvalues['date_end']);
                             }
                         }
                         if (isset($this->target_object->oldvalues['quota'])) {
                             if (empty($this->target_object->oldvalues['quota'])) {
                                 $tmp['##update.quota##'] = "---";
                             } else {
                                 $tmp['##update.quota##'] = $this->target_object->oldvalues['quota'];
                             }
                         }
                         if (isset($this->target_object->oldvalues['plugin_resources_departments_id'])) {
                             if (empty($this->target_object->oldvalues['plugin_resources_departments_id'])) {
                                 $tmp['##update.department##'] = "---";
                             } else {
                                 $tmp['##update.department##'] = Dropdown::getDropdownName('glpi_plugin_resources_departments', $this->target_object->oldvalues['plugin_resources_departments_id']);
                             }
                         }
                         if (isset($this->target_object->oldvalues['plugin_resources_resourcestates_id'])) {
                             if (empty($this->target_object->oldvalues['plugin_resources_resourcestates_id'])) {
                                 $tmp['##update.status##'] = "---";
                             } else {
                                 $tmp['##update.status##'] = Dropdown::getDropdownName('glpi_plugin_resources_resourcestates', $this->target_object->oldvalues['plugin_resources_resourcestates_id']);
                             }
                         }
                         if (isset($this->target_object->oldvalues['plugin_resources_resourcesituations_id'])) {
                             if (empty($this->target_object->oldvalues['plugin_resources_resourcesituations_id'])) {
                                 $tmp['##update.situation##'] = "---";
                             } else {
                                 $tmp['##update.situation##'] = Dropdown::getDropdownName('glpi_plugin_resources_resourcesituations', $this->target_object->oldvalues['plugin_resources_resourcesituations_id']);
                             }
                         }
                         if (isset($this->target_object->oldvalues['plugin_resources_contractnatures_id'])) {
                             if (empty($this->target_object->oldvalues['plugin_resources_contractnatures_id'])) {
                                 $tmp['##update.contractnature##'] = "---";
                             } else {
                                 $tmp['##update.contractnature##'] = Dropdown::getDropdownName('glpi_plugin_resources_contractnatures', $this->target_object->oldvalues['plugin_resources_contractnatures_id']);
                             }
                         }
                         if (isset($this->target_object->oldvalues['plugin_resources_ranks_id'])) {
                             if (empty($this->target_object->oldvalues['plugin_resources_ranks_id'])) {
                                 $tmp['##update.rank##'] = "---";
                             } else {
                                 $tmp['##update.rank##'] = Dropdown::getDropdownName('glpi_plugin_resources_ranks', $this->target_object->oldvalues['plugin_resources_ranks_id']);
                             }
                         }
                         if (isset($this->target_object->oldvalues['plugin_resources_resourcespecialities_id'])) {
                             if (empty($this->target_object->oldvalues['plugin_resources_resourcespecialities_id'])) {
                                 $tmp['##update.speciality##'] = "---";
                             } else {
                                 $tmp['##update.speciality##'] = Dropdown::getDropdownName('glpi_plugin_resources_resourcespecialities', $this->target_object->oldvalues['plugin_resources_resourcespecialities_id']);
                             }
                         }
                         if (isset($this->target_object->oldvalues['locations_id'])) {
                             if (empty($this->target_object->oldvalues['locations_id'])) {
                                 $tmp['##update.location##'] = "---";
                             } else {
                                 $tmp['##update.location##'] = Dropdown::getDropdownName('glpi_locations', $this->target_object->oldvalues['locations_id']);
                             }
                         }
                         if (isset($this->target_object->oldvalues['comment'])) {
                             if (empty($this->target_object->oldvalues['comment'])) {
                                 $tmp['##update.comment##'] = "---";
                             } else {
                                 $comment = stripslashes(str_replace(array('\\r\\n', '\\n', '\\r'), "<br/>", $this->target_object->oldvalues['comment']));
                                 $tmp['##update.comment##'] = Html::clean($comment);
                             }
                         }
                         if (isset($this->target_object->oldvalues['users_id_recipient_leaving'])) {
                             if (empty($this->target_object->oldvalues['users_id_recipient_leaving'])) {
                                 $tmp['##update.usersleaving##'] = "---";
                             } else {
                                 $tmp['##update.usersleaving##'] = Html::clean(getUserName($this->target_object->oldvalues['users_id_recipient_leaving']));
                             }
                         }
                         if (isset($this->target_object->oldvalues['is_leaving'])) {
                             if (empty($this->target_object->oldvalues['is_leaving'])) {
                                 $tmp['##update.leaving##'] = "---";
                             } else {
                                 $tmp['##update.leaving##'] = Dropdown::getYesNo($this->target_object->oldvalues['is_leaving']);
                             }
                         }
                         if (isset($this->target_object->oldvalues['plugin_resources_leavingreasons_id'])) {
                             if (empty($this->target_object->oldvalues['plugin_resources_leavingreasons_id'])) {
                                 $tmp['##update.leavingreason##'] = "---";
                             } else {
                                 $tmp['##update.leavingreason##'] = Dropdown::getDropdownName('glpi_plugin_resources_leavingreasons', $this->target_object->oldvalues['plugin_resources_leavingreasons_id']);
                             }
                         }
                         if (isset($this->target_object->oldvalues['is_helpdesk_visible'])) {
                             if (empty($this->target_object->oldvalues['is_helpdesk_visible'])) {
                                 $tmp['##update.helpdesk##'] = "---";
                             } else {
                                 $tmp['##update.helpdesk##'] = Dropdown::getYesNo($this->target_object->oldvalues['is_helpdesk_visible']);
                             }
                         }
                         if (isset($this->target_object->oldvalues['at_home'])) {
                             if (empty($this->target_object->oldvalues['at_home'])) {
                                 $tmp['##update.home##'] = "---";
                             } else {
                                 $tmp['##update.home##'] = Dropdown::getYesNo($this->target_object->oldvalues['at_home']);
                             }
                         }
                         $this->datas['updates'][] = $tmp;
                     }
                     //task infos
                     $restrict = "`plugin_resources_resources_id`='" . $this->obj->getField('id') . "' AND `is_deleted` = 0";
                     if (isset($options['tasks_id']) && $options['tasks_id']) {
                         $restrict .= " AND `glpi_plugin_resources_tasks`.`id` = '" . $options['tasks_id'] . "'";
                     }
                     $restrict .= " ORDER BY `name` DESC";
                     $tasks = getAllDatasFromTable('glpi_plugin_resources_tasks', $restrict);
                     $this->datas['##lang.task.title##'] = __('Associated tasks', 'resources');
                     $this->datas['##lang.task.name##'] = __('Name');
                     $this->datas['##lang.task.type##'] = __('Type');
                     $this->datas['##lang.task.users##'] = __('Technician');
                     $this->datas['##lang.task.groups##'] = __('Group');
                     $this->datas['##lang.task.datebegin##'] = __('Begin date');
                     $this->datas['##lang.task.dateend##'] = __('End date');
                     $this->datas['##lang.task.planned##'] = __('Used for planning', 'resources');
                     $this->datas['##lang.task.realtime##'] = __('Effective duration', 'resources');
                     $this->datas['##lang.task.finished##'] = __('Carried out task', 'resources');
                     $this->datas['##lang.task.comment##'] = __('Description');
                     foreach ($tasks as $task) {
                         $tmp = array();
                         $tmp['##task.name##'] = $task['name'];
                         $tmp['##task.type##'] = Dropdown::getDropdownName('glpi_plugin_resources_tasktypes', $task['plugin_resources_tasktypes_id']);
                         $tmp['##task.users##'] = Html::clean(getUserName($task['users_id']));
                         $tmp['##task.groups##'] = Dropdown::getDropdownName('glpi_groups', $task['groups_id']);
                         $restrict = " `plugin_resources_tasks_id` = '" . $task['id'] . "' ";
                         $plans = getAllDatasFromTable("glpi_plugin_resources_taskplannings", $restrict);
                         if (!empty($plans)) {
                             foreach ($plans as $plan) {
                                 $tmp['##task.datebegin##'] = Html::convDateTime($plan["begin"]);
                                 $tmp['##task.dateend##'] = Html::convDateTime($plan["end"]);
                             }
                         } else {
                             $tmp['##task.datebegin##'] = '';
                             $tmp['##task.dateend##'] = '';
                         }
                         $tmp['##task.planned##'] = '';
                         $tmp['##task.finished##'] = Dropdown::getYesNo($task['is_finished']);
                         $tmp['##task.realtime##'] = Ticket::getActionTime($task["actiontime"]);
                         $comment = stripslashes(str_replace(array('\\r\\n', '\\n', '\\r'), "<br/>", $task['comment']));
                         $tmp['##task.comment##'] = Html::clean($comment);
                         $this->datas['tasks'][] = $tmp;
                     }
                 }
             }
         }
     }
 }
Exemple #10
0
function plugin_resources_MassiveActionsProcess($data)
{
    global $DB;
    $nbok = 0;
    $nbnoright = 0;
    $nbko = 0;
    $res = array('ok' => 0, 'ko' => 0, 'noright' => 0);
    $messageKo = "";
    $messageOk = "";
    $resourceItem = new PluginResourcesResource_Item();
    switch ($data['action']) {
        case "plugin_resources_add_item":
            foreach ($data["item"] as $key => $val) {
                if ($val == 1) {
                    $input = array('plugin_resources_resources_id' => $data['plugin_resources_resources_id'], 'items_id' => $key, 'itemtype' => $data['itemtype']);
                    if ($resourceItem->can(-1, 'w', $input)) {
                        if ($resourceItem->add($input)) {
                            $res['ok']++;
                        } else {
                            $res['ko']++;
                        }
                    } else {
                        $res['noright']++;
                    }
                }
            }
            break;
        case "plugin_resources_generate_resources":
            if (sizeof($data['item']) > 0) {
                foreach ($data['item'] as $userId => $val) {
                    $user = new User();
                    $user->getFromDB($userId);
                    $resource = new PluginResourcesResource();
                    $query = "WHERE name='" . $user->fields['realname'] . "' AND firstname='" . $user->fields['firstname'] . "' ";
                    $resource->getFromDBByQuery($query);
                    if (!isset($resource->fields['id']) || $resource->fields['id'] <= 0) {
                        $resource->fields['entities_id'] = $_SESSION['glpiactive_entity'];
                        $resource->fields['name'] = isset($user->fields['realname']) ? $user->fields['realname'] : '';
                        $resource->fields['firstname'] = isset($user->fields['firstname']) ? $user->fields['firstname'] : '';
                        $resource->fields['plugin_resources_contracttypes_id'] = $data['plugin_resources_contracttypes_id'];
                        $resource->fields['users_id_recipient'] = Session::getLoginUserID();
                        $resource->fields['users_id'] = $data["users_id_recipient"];
                        $resource->fields['date_declaration'] = date('Y-m-d');
                        $resource->fields['date_begin'] = null;
                        $resource->fields['date_end'] = null;
                        $resource->fields['plugin_resources_departments_id'] = $data['plugin_resources_departments_id'];
                        $resource->fields['locations_id'] = 0;
                        $resource->fields['is_leaving'] = 0;
                        $resource->fields['users_id_recipient_leaving'] = 0;
                        $resource->fields['comment'] = '';
                        $resource->fields['notepad'] = '';
                        $resource->fields['is_template'] = 0;
                        $resource->fields['template_name'] = '';
                        $resource->fields['is_deleted'] = 0;
                        $resource->fields['is_helpdesk_visible'] = 1;
                        $resource->fields['date_mod'] = date('Y-m-d');
                        $resource->fields['plugin_resources_resourcestates_id'] = 0;
                        $resource->fields['picture'] = null;
                        $resource->fields['is_recursive'] = 0;
                        $resource->fields['quota'] = 1;
                        $resource->fields['plugin_resources_resourcesituations_id'] = 0;
                        $resource->fields['plugin_resources_contractnatures_id'] = 0;
                        $resource->fields['plugin_resources_ranks_id'] = 0;
                        $resource->fields['plugin_resources_resourcespecialities_id'] = 0;
                        $resource->fields['plugin_resources_leavingreasons_id'] = 0;
                        if ($resourceItem->can(-1, 'w', $input)) {
                            $idResource = $resource->add($resource->fields);
                            if ($idResource) {
                                $resource->fields['id'] = $idResource;
                                if (isset($resourceItem->fields['id'])) {
                                    unset($resourceItem->fields['id']);
                                }
                                $resourceItem->fields['plugin_resources_resources_id'] = $idResource;
                                $resourceItem->fields['items_id'] = $user->fields['id'];
                                $resourceItem->fields['itemtype'] = $data['itemtype'];
                                $resourceItem->fields['comment'] = null;
                                $idResourceItem = $resourceItem->add($resourceItem->fields);
                                if ($idResourceItem) {
                                    // Cochage des checklist en mode "JOB DONE"
                                    $pChecklist = new PluginResourcesChecklist();
                                    $query = "UPDATE " . $pChecklist->getTable() . " SET `is_checked`=1 WHERE `plugin_resources_resources_id`=" . $idResource;
                                    if ($DB->query($query)) {
                                        $res['ok']++;
                                        $messageOk .= $user->fields['realname'] . " " . $user->fields['firstname'] . "<br/>";
                                    } else {
                                        $res['ko']++;
                                    }
                                } else {
                                    $res['ko']++;
                                    $messageKo .= $user->fields['realname'] . " " . $user->fields['firstname'] . "<br/>";
                                    $resource->delete($resource->fields, 1);
                                }
                            } else {
                                $res['ko']++;
                            }
                        } else {
                            $res['noright']++;
                        }
                    } else {
                        $messageKo .= $user->fields['realname'] . " " . $user->fields['firstname'] . "<br/>";
                        $res['ko']++;
                    }
                }
            }
            break;
    }
    if ($res['ko'] != 0) {
        if ($res['ko'] > 1) {
            $messageKo = _n("This resource aldready exists", "These resources aldready exist", 2, "resources") . ":<br/>" . $messageKo;
        } else {
            $messageKo = _n("This resource aldready exists", "These resources aldready exist", 1, "resources") . ":<br/>" . $messageKo;
        }
        Session::addMessageAfterRedirect($messageKo, true, ERROR);
    }
    if ($res['ok'] > 0) {
        if ($res['ok'] > 1) {
            $messageOk = _n("This resource has been added", "These resources have been added", 2, "resources") . ":<br/>" . $messageOk;
        } else {
            $messageOk = _n("This resource has been added", "These resources have been added", 1, "resources") . ":<br/>" . $messageOk;
        }
        Session::addMessageAfterRedirect($messageOk, true, INFO);
    }
    return $res;
}
LICENSE

This file is part of Resources.

Resources is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

Resources is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with Resources. If not, see <http://www.gnu.org/licenses/>.
--------------------------------------------------------------------------
*/
include '../../../inc/includes.php';
header("Content-Type: text/html; charset=UTF-8");
Html::header_nocache();
Session::checkLoginUser();
$item = new PluginResourcesChecklist();
if (isset($_POST["plugin_resources_contracttypes_id"]) && isset($_POST["checklist_type"])) {
    $options = array('target' => $_POST["target"], 'plugin_resources_contracttypes_id' => $_POST["plugin_resources_contracttypes_id"], 'checklist_type' => $_POST["checklist_type"], 'plugin_resources_resources_id' => $_POST["plugin_resources_resources_id"]);
    $item->showForm($_POST["id"], $options);
} else {
    _e("You don't have permission to perform this action.");
}
Html::ajaxFooter();