예제 #1
0
  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 ($_SESSION['glpiactiveprofile']['interface'] == 'central') {
    //from central
    Html::header(PluginResourcesResource::getTypeName(2), '', "plugins", "resources");
} else {
    //from helpdesk
    Html::helpHeader(PluginResourcesResource::getTypeName(2));
}
if (!isset($_GET["id"])) {
    $_GET["id"] = "";
}
$resting = new PluginResourcesResourceResting();
if (isset($_POST["addrestingresources"]) && $_POST["plugin_resources_resources_id"] != 0) {
    $resting->add($_POST);
    Html::back();
} else {
    if (isset($_POST["updaterestingresources"]) && $_POST["plugin_resources_resources_id"] != 0) {
        $resting->update($_POST);
        Html::back();
    } else {
        if (isset($_POST["deleterestingresources"]) && $_POST["plugin_resources_resources_id"] != 0) {
            $resting->delete($_POST, 1);
            $resting->redirectToList();
        } else {
            if ($resting->canView() || Session::haveRight("config", "w")) {
                $resting->showForm($_GET["id"], array());
            }
예제 #2
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 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;
                     }
                 }
             }
         }
     }
 }
예제 #4
0
 function cleanDBonPurge()
 {
     $temp = new PluginResourcesResource_Item();
     $temp->deleteByCriteria(array('plugin_resources_resources_id' => $this->fields['id']));
     $temp = new PluginResourcesChoice();
     $temp->deleteByCriteria(array('plugin_resources_resources_id' => $this->fields['id']));
     $temp = new PluginResourcesTask();
     $temp->deleteByCriteria(array('plugin_resources_resources_id' => $this->fields['id']), 1);
     $temp = new PluginResourcesEmployee();
     $temp->deleteByCriteria(array('plugin_resources_resources_id' => $this->fields['id']));
     $temp = new PluginResourcesReportConfig();
     $temp->deleteByCriteria(array('plugin_resources_resources_id' => $this->fields['id']));
     $temp = new PluginResourcesChecklist();
     $temp->deleteByCriteria(array('plugin_resources_resources_id' => $this->fields['id']));
     $temp = new PluginResourcesResourceResting();
     $temp->deleteByCriteria(array('plugin_resources_resources_id' => $this->fields['id']));
     $temp = new PluginResourcesResourceHoliday();
     $temp->deleteByCriteria(array('plugin_resources_resources_id' => $this->fields['id']));
 }
예제 #5
0
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';
if ($_SESSION['glpiactiveprofile']['interface'] == 'central') {
    //from central
    Html::header(PluginResourcesResource::getTypeName(2), '', "plugins", "resources");
} else {
    //from helpdesk
    Html::helpHeader(PluginResourcesResource::getTypeName(2));
}
$resting = new PluginResourcesResourceResting();
if ($resting->canView() || Session::haveRight("config", "w")) {
    Search::manageGetValues("PluginResourcesResourceResting");
    $resting->showGenericSearch($_GET);
    $resting->showMinimalList($_GET);
} else {
    Html::displayRightError();
}
if ($_SESSION['glpiactiveprofile']['interface'] == 'central') {
    Html::footer();
} else {
    Html::helpFooter();
}