function getSearchOptions()
 {
     $tab = array();
     $tab['common'] = self::getTypeName(2);
     $tab[1]['table'] = $this->table;
     $tab[1]['field'] = 'registration_number';
     $tab[1]['name'] = __('Administrative number');
     $tab[1]['datatype'] = 'string';
     $tab[2]['table'] = $this->table;
     $tab[2]['field'] = 'id';
     $tab[2]['name'] = __('ID');
     $tab[2]['massiveaction'] = false;
     $tab[2]['datatype'] = 'number';
     $tab[34]['table'] = $this->table;
     $tab[34]['field'] = 'realname';
     $tab[34]['name'] = __('Surname');
     $tab[34]['datatype'] = 'string';
     $tab[9]['table'] = $this->table;
     $tab[9]['field'] = 'firstname';
     $tab[9]['name'] = __('First name');
     $tab[9]['datatype'] = 'string';
     $tab[5]['table'] = 'glpi_useremails';
     $tab[5]['field'] = 'email';
     $tab[5]['name'] = _n('Email', 'Emails', 2);
     $tab[5]['datatype'] = 'email';
     $tab[5]['joinparams'] = array('jointype' => 'child');
     $tab[5]['forcegroupby'] = true;
     $tab[5]['massiveaction'] = false;
     $tab += Location::getSearchOptionsToAdd();
     $tab[6]['table'] = $this->table;
     $tab[6]['field'] = 'phone';
     $tab[6]['name'] = __('Phone');
     $tab[6]['datatype'] = 'string';
     $tab[10]['table'] = $this->table;
     $tab[10]['field'] = 'phone2';
     $tab[10]['name'] = __('Phone 2');
     $tab[10]['datatype'] = 'string';
     $tab[11]['table'] = $this->table;
     $tab[11]['field'] = 'mobile';
     $tab[11]['name'] = __('Mobile phone');
     $tab[11]['datatype'] = 'string';
     // FROM employee
     $tab[4313]['table'] = 'glpi_plugin_resources_employers';
     $tab[4313]['field'] = 'completename';
     $tab[4313]['name'] = PluginResourcesEmployer::getTypeName(1);
     $tab[4313]['datatype'] = 'dropdown';
     $tab[4314]['table'] = 'glpi_plugin_resources_clients';
     $tab[4314]['field'] = 'name';
     $tab[4314]['name'] = PluginResourcesClient::getTypeName(1);
     $tab[4314]['datatype'] = 'dropdown';
     // FROM resources
     $tab[4315]['table'] = 'glpi_plugin_resources_contracttypes';
     $tab[4315]['field'] = 'name';
     $tab[4315]['name'] = PluginResourcesContractType::getTypeName(1);
     $tab[4315]['datatype'] = 'dropdown';
     $tab[4316]['table'] = 'glpi_plugin_resources_managers';
     $tab[4316]['field'] = 'name';
     $tab[4316]['name'] = __('Resource manager', 'resources');
     $tab[4316]['searchtype'] = 'contains';
     $tab[4316]['datatype'] = 'dropdown';
     $tab[4317]['table'] = 'glpi_plugin_resources_resources';
     $tab[4317]['field'] = 'date_begin';
     $tab[4317]['name'] = __('Arrival date', 'resources');
     $tab[4317]['datatype'] = 'date';
     $tab[4318]['table'] = 'glpi_plugin_resources_resources';
     $tab[4318]['field'] = 'date_end';
     $tab[4318]['name'] = __('Departure date', 'resources');
     $tab[4318]['datatype'] = 'date';
     $tab[4319]['table'] = 'glpi_plugin_resources_departments';
     $tab[4319]['field'] = 'name';
     $tab[4319]['name'] = PluginResourcesDepartment::getTypeName(1);
     $tab[4319]['datatype'] = 'dropdown';
     $tab[4320]['table'] = 'glpi_plugin_resources_resourcestates';
     $tab[4320]['field'] = 'name';
     $tab[4320]['name'] = PluginResourcesResourceState::getTypeName(1);
     $tab[4320]['datatype'] = 'dropdown';
     return $tab;
 }
 /** 
  * show for PDF the resources associated with a device
  * 
  * @param $ID of the device
  * @param $itemtype : type of the device
  * 
  */
 static function PdfFromItems($pdf, $item)
 {
     global $DB, $CFG_GLPI;
     $pdf->setColumnsSize(100);
     $pdf->displayTitle('<b>' . __('Associated Human Resource', 'resources') . '</b>');
     $ID = $item->getField('id');
     $itemtype = get_Class($item);
     $canread = $item->can($ID, 'r');
     $canedit = $item->can($ID, 'w');
     $PluginResourcesResource = new PluginResourcesResource();
     $query = "SELECT `glpi_plugin_resources_resources`.* " . " FROM `glpi_plugin_resources_resources_items`,`glpi_plugin_resources_resources` " . " LEFT JOIN `glpi_entities` ON (`glpi_entities`.`id` = `glpi_plugin_resources_resources`.`entities_id`) " . " WHERE `glpi_plugin_resources_resources_items`.`items_id` = '" . $ID . "' \n         AND `glpi_plugin_resources_resources_items`.`itemtype` = '" . $itemtype . "' \n         AND `glpi_plugin_resources_resources_items`.`plugin_resources_resources_id` = `glpi_plugin_resources_resources`.`id` " . getEntitiesRestrictRequest(" AND ", "glpi_plugin_resources_resources", '', '', $PluginResourcesResource->maybeRecursive());
     $result = $DB->query($query);
     $number = $DB->numrows($result);
     if (!$number) {
         $pdf->displayLine(__('No item found'));
     } else {
         if (Session::isMultiEntitiesMode()) {
             $pdf->setColumnsSize(14, 14, 14, 14, 14, 14, 16);
             $pdf->displayTitle('<b><i>' . __('Name'), __('Entity'), __('Location'), PluginResourcesContractType::getTypeName(1), PluginResourcesDepartment::getTypeName(1), __('Arrival date', 'resources'), __('Departure date', 'resources') . '</i></b>');
         } else {
             $pdf->setColumnsSize(17, 17, 17, 17, 17, 17);
             $pdf->displayTitle('<b><i>' . __('Name'), __('Location'), PluginResourcesContractType::getTypeName(1), PluginResourcesDepartment::getTypeName(1), __('Arrival date', 'resources'), __('Departure date', 'resources') . '</i></b>');
         }
         while ($data = $DB->fetch_array($result)) {
             $resourcesID = $data["id"];
             if (Session::isMultiEntitiesMode()) {
                 $pdf->setColumnsSize(14, 14, 14, 14, 14, 14, 16);
                 $pdf->displayLine($data["name"], Html::clean(Dropdown::getDropdownName("glpi_entities", $data['entities_id'])), Html::clean(Dropdown::getDropdownName("glpi_locations", $data["locations_id"])), Html::clean(Dropdown::getDropdownName("glpi_plugin_resources_contracttypes", $data["plugin_resources_contracttypes_id"])), Html::clean(Dropdown::getDropdownName("glpi_plugin_resources_departments", $data["plugin_resources_departments_id"])), Html::convDate($data["date_begin"]), Html::convDate($data["date_end"]));
             } else {
                 $pdf->setColumnsSize(17, 17, 17, 17, 17, 17);
                 $pdf->displayLine($data["name"], Html::clean(Dropdown::getDropdownName("glpi_locations", $data["locations_id"])), Html::clean(Dropdown::getDropdownName("glpi_plugin_resources_contracttypes", $data["plugin_resources_contracttypes_id"])), Html::clean(Dropdown::getDropdownName("glpi_plugin_resources_departments", $data["plugin_resources_departments_id"])), Html::convDate($data["date_begin"]), Html::convDate($data["date_end"]));
             }
         }
     }
 }
 /**
  * Show for PDF an resources
  *
  * @param $pdf object for the output
  * @param $ID of the resources
  */
 function show_PDF($pdf)
 {
     $pdf->setColumnsSize(50, 50);
     $col1 = '<b>' . __('ID') . ' ' . $this->fields['id'] . '</b>';
     if (isset($this->fields["date_declaration"])) {
         $users_id_recipient = new User();
         $users_id_recipient->getFromDB($this->fields["users_id_recipient"]);
         $col2 = __('Request date') . ' : ' . Html::convDateTime($this->fields["date_declaration"]) . ' ' . __('Requester') . ' ' . $users_id_recipient->getName();
     } else {
         $col2 = '';
     }
     $pdf->displayTitle($col1, $col2);
     $pdf->displayLine('<b><i>' . __('Name') . ' :</i></b> ' . $this->fields['name'], '<b><i>' . __('First name') . ' :</i></b> ' . $this->fields['firstname']);
     $pdf->displayLine('<b><i>' . __('Location') . ' :</i></b> ' . Html::clean(Dropdown::getDropdownName('glpi_locations', $this->fields['locations_id'])), '<b><i>' . PluginResourcesContractType::getTypeName(1) . ' :</i></b> ' . Html::clean(Dropdown::getDropdownName('glpi_plugin_resources_contracttypes', $this->fields['plugin_resources_contracttypes_id'])));
     $pdf->displayLine('<b><i>' . __('Resource manager', 'resources') . ' :</i></b> ' . Html::clean(getusername($this->fields["users_id"])), '<b><i>' . PluginResourcesDepartment::getTypeName(1) . ' :</i></b> ' . Html::clean(Dropdown::getDropdownName('glpi_plugin_resources_departments', $this->fields["plugin_resources_departments_id"])));
     $pdf->displayLine('<b><i>' . __('Arrival date', 'resources') . ' :</i></b> ' . Html::convDate($this->fields["date_begin"]), '<b><i>' . __('Departure date', 'resources') . ' :</i></b> ' . Html::convDate($this->fields["date_end"]));
     $pdf->setColumnsSize(100);
     $pdf->displayText('<b><i>' . __('Description') . ' :</i></b>', $this->fields['comment']);
     $pdf->displaySpace();
 }
 function getActions()
 {
     $actions = array();
     $actions['requiredfields_name']['name'] = __('Name');
     $actions['requiredfields_name']['type'] = "yesonly";
     $actions['requiredfields_name']['force_actions'] = array('assign');
     $actions['requiredfields_name']['type'] = "yesonly";
     $actions['requiredfields_firstname']['name'] = __('First name');
     $actions['requiredfields_firstname']['type'] = "yesonly";
     $actions['requiredfields_firstname']['force_actions'] = array('assign');
     $actions['requiredfields_locations_id']['name'] = __('Location');
     $actions['requiredfields_locations_id']['type'] = "yesonly";
     $actions['requiredfields_locations_id']['force_actions'] = array('assign');
     $actions['requiredfields_users_id']['name'] = __('Resource manager', 'resources');
     $actions['requiredfields_users_id']['type'] = "yesonly";
     $actions['requiredfields_users_id']['force_actions'] = array('assign');
     $actions['requiredfields_plugin_resources_departments_id']['name'] = PluginResourcesDepartment::getTypeName(1);
     $actions['requiredfields_plugin_resources_departments_id']['type'] = "yesonly";
     $actions['requiredfields_plugin_resources_departments_id']['force_actions'] = array('assign');
     $actions['requiredfields_date_begin']['name'] = __('Arrival date', 'resources');
     $actions['requiredfields_date_begin']['type'] = "yesonly";
     $actions['requiredfields_date_begin']['force_actions'] = array('assign');
     $actions['requiredfields_date_end']['name'] = __('Departure date', 'resources');
     $actions['requiredfields_date_end']['type'] = "yesonly";
     $actions['requiredfields_date_end']['force_actions'] = array('assign');
     $actions['requiredfields_quota']['name'] = __('Quota', 'resources');
     $actions['requiredfields_quota']['type'] = "yesonly";
     $actions['requiredfields_quota']['force_actions'] = array('assign');
     if (plugin_resources_haveRight('dropdown_public', 'w')) {
         $actions['requiredfields_plugin_resources_resourcesituations_id']['name'] = PluginResourcesResourceSituation::getTypeName(1);
         $actions['requiredfields_plugin_resources_resourcesituations_id']['type'] = "yesonly";
         $actions['requiredfields_plugin_resources_resourcesituations_id']['force_actions'] = array('assign');
         $actions['requiredfields_plugin_resources_ranks_id']['name'] = PluginResourcesRank::getTypeName(1);
         $actions['requiredfields_plugin_resources_ranks_id']['type'] = "yesonly";
         $actions['requiredfields_plugin_resources_ranks_id']['force_actions'] = array('assign');
     }
     return $actions;
 }
 function getTags()
 {
     $tags = array('resource.id' => 'ID', 'resource.name' => __('Name'), 'resource.firstname' => __('First name'), 'resource.type' => PluginResourcesContractType::getTypeName(1), 'resource.quota' => __('Quota', 'resources'), 'resource.situation' => PluginResourcesResourceSituation::getTypeName(1), 'resource.contractnature' => PluginResourcesContractNature::getTypeName(1), 'resource.rank' => PluginResourcesRank::getTypeName(1), 'resource.speciality' => PluginResourcesResourceSpeciality::getTypeName(1), 'resource.users' => __('Resource manager', 'resources'), 'resource.usersrecipient' => __('Requester'), 'resource.datedeclaration' => __('Request date'), 'resource.datebegin' => __('Arrival date', 'resources'), 'resource.dateend' => __('Departure date', 'resources'), 'resource.department' => PluginResourcesDepartment::getTypeName(1), 'resource.location' => __('Location'), 'resource.comment' => __('Description'), 'resource.usersleaving' => __('Informant of leaving', 'resources'), 'resource.leaving' => __('Declared as leaving', 'resources'), 'resource.leavingreason' => PluginResourcesLeavingReason::getTypeName(1), 'resource.helpdesk' => __('Associable to a ticket'), 'resource.action_user' => __('Last updater'), 'update.name' => __('Name'), 'update.firstname' => __('First name'), 'update.type' => PluginResourcesContractType::getTypeName(1), 'update.quota' => __('Quota', 'resources'), 'update.situation' => PluginResourcesResourceSituation::getTypeName(1), 'update.contractnature' => PluginResourcesContractNature::getTypeName(1), 'update.rank' => PluginResourcesRank::getTypeName(1), 'update.speciality' => PluginResourcesResourceSpeciality::getTypeName(1), 'update.users' => __('Resource manager', 'resources'), 'update.usersrecipient' => __('Requester'), 'update.datedeclaration' => __('Request date'), 'update.datebegin' => __('Arrival date', 'resources'), 'update.dateend' => __('Departure date', 'resources'), 'update.department' => PluginResourcesDepartment::getTypeName(1), 'update.status' => PluginResourcesResourceState::getTypeName(1), 'update.location' => __('Location'), 'update.comment' => __('Description'), 'update.usersleaving' => __('Informant of leaving', 'resources'), 'update.leaving' => __('Declared as leaving', 'resources'), 'update.leavingreason' => PluginResourcesLeavingReason::getTypeName(1), 'update.helpdesk' => __('Associable to a ticket'), 'task.name' => __('Name'), 'task.type' => __('Type'), 'task.users' => __('Technician'), 'task.groups' => __('Group'), 'task.datebegin' => __('Begin date'), 'task.dateend' => __('End date'), 'task.planned' => __('Used for planning', 'resources'), 'task.realtime' => __('Effective duration', 'resources'), 'task.finished' => __('Carried out task', 'resources'), 'task.comment' => __('Description'));
     foreach ($tags as $tag => $label) {
         $this->addTagToList(array('tag' => $tag, 'label' => $label, 'value' => true));
     }
     $this->addTagToList(array('tag' => 'resource', 'label' => __('At creation, update, removal of a resource', 'resources'), 'value' => false, 'foreach' => true, 'events' => array('new', 'update', 'delete', 'report', 'newresting', 'updateresting', 'deleteresting', 'newholiday', 'updateholiday', 'deleteholiday')));
     $this->addTagToList(array('tag' => 'updates', 'label' => __('Modified fields', 'resources'), 'value' => false, 'foreach' => true, 'events' => array('update', 'updateresting', 'updateholiday')));
     $this->addTagToList(array('tag' => 'tasks', 'label' => __('At creation, update, removal of a task', 'resources'), 'value' => false, 'foreach' => true, 'events' => array('newtask', 'updatetask', 'deletetask')));
     asort($this->tag_descriptions);
 }
Exemple #6
0
function plugin_resources_MassiveActionsDisplay($options = array())
{
    switch ($options['action']) {
        case "plugin_resources_add_item":
            if (in_array($options['itemtype'], PluginResourcesResource::getTypes())) {
                PluginResourcesResource::dropdown();
                echo "&nbsp;<input type=\"submit\" name=\"massiveaction\" class=\"submit\" value=\"" . _sx('button', 'Post') . "\" >";
            }
            break;
        case "plugin_resources_generate_resources":
            echo "<table class='tab_cadre'>";
            // ContractType
            echo "<tr>";
            echo "<td>" . __("Contract type") . "</td>";
            echo "<td>";
            PluginResourcesDepartment::getTypeName(1) . "</td><td>";
            Dropdown::show('PluginResourcesContractType', array('name' => "plugin_resources_contracttypes_id"));
            echo "</td>";
            echo "</tr>";
            echo "<tr>";
            // Recipient
            echo "<td>";
            echo __('Resource manager', 'resources') . "</td>";
            echo "<td width='70%'>";
            User::dropdown(array('name' => "users_id_recipient", 'entity' => $_SESSION['glpiactive_entity'], 'right' => 'all'));
            echo "<td>";
            echo "</tr>";
            // Department
            echo "<tr>";
            echo "<td>";
            echo PluginResourcesDepartment::getTypeName(1) . "</td><td>";
            Dropdown::show('PluginResourcesDepartment', array('name' => "plugin_resources_departments_id"));
            echo "</td>";
            echo "</tr>";
            echo "</table>";
            echo "&nbsp;<input type=\"submit\" name=\"massiveaction\" class=\"submit\" value=\"" . _sx('button', 'Post') . "\" >";
            break;
        default:
            break;
    }
    return "";
}