/**
  * Show for PDF an webapplications
  *
  * @param $pdf object for the output
  * @param $ID of the webapplications
  **/
 function show_PDF($pdf)
 {
     global $LANG, $DB;
     $pdf->setColumnsSize(50, 50);
     $col1 = '<b>' . __('ID') . ' ' . $this->fields['id'] . '</b>';
     if (isset($this->fields["date_mod"])) {
         $col2 = printf(__('Last update on %s'), Html::convDateTime($this->fields["date_mod"]));
     } else {
         $col2 = '';
     }
     $pdf->displayTitle($col1, $col2);
     $pdf->displayLine('<b><i>' . __('Name') . ':</i></b> ' . $this->fields['name'], '<b><i>' . PluginWebapplicationsWebapplicationType::getTypeName(1) . ' :</i></b> ' . Html::clean(Dropdown::getDropdownName('glpi_plugin_webapplications_webapplicationtypes', $this->fields['plugin_webapplications_webapplicationtypes_id'])));
     $pdf->displayLine('<b><i>' . __('Technician in charge of the hardware') . ':</i></b> ' . getUserName($this->fields['users_id_tech']), '<b><i>' . __('Group in charge of the hardware') . ':</i></b> ' . Html::clean(Dropdown::getDropdownName('glpi_groups', $this->fields['groups_id_tech'])));
     $pdf->displayLine('<b><i>' . __('Location') . ':</i></b> ' . Html::clean(Dropdown::getDropdownName('glpi_locations', $this->fields['locations_id'])), '<b><i>' . PluginWebapplicationsWebapplicationServerType::getTypeName(1) . ':</i></b> ' . Html::clean(Dropdown::getDropdownName('glpi_plugin_webapplications_webapplicationservertypes', $this->fields["plugin_webapplications_webapplicationservertypes_id"])));
     $pdf->displayLine('<b><i>' . PluginWebapplicationsWebapplicationTechnic::getTypeName(1) . ' :</i></b> ' . Html::clean(Dropdown::getDropdownName('glpi_plugin_webapplications_webapplicationtechnics', $this->fields['plugin_webapplications_webapplicationtechnics_id'])), '<b><i>' . __('Version') . ':</i></b> ' . $this->fields['version']);
     $pdf->displayLine('<b><i>' . __('Supplier') . ':</i></b> ' . Html::clean(Dropdown::getDropdownName('glpi_suppliers', $this->fields['suppliers_id'])), '<b><i>' . __('Editor', 'webapplications') . ':</i></b> ' . Html::clean(Dropdown::getDropdownName('glpi_manufacturers', $this->fields["manufacturers_id"])));
     $pdf->displayLine('<b><i>' . __('URL') . ':</i></b> ' . $this->fields['address'], '');
     $pdf->setColumnsSize(100);
     $pdf->displayText('<b><i>' . __('Comments') . ':</i></b>', $this->fields['comment']);
     $pdf->displaySpace();
 }
 /**
  * show for PDF the webapplications associated with a device
  *
  * @param $pdf
  * @param $item
  *
  **/
 static function PdfFromItems(PluginPdfSimplePDF $pdf, CommonGLPI $item)
 {
     global $DB, $CFG_GLPI;
     $pdf->setColumnsSize(100);
     $pdf->displayTitle('<b>' . _n('Associated web application', 'Associated web applications', 2, 'webapplications') . '</b>');
     $ID = $item->getField('id');
     $itemtype = get_Class($item);
     $canread = $item->can($ID, READ);
     $canedit = $item->can($ID, UPDATE);
     $web = new PluginWebapplicationsWebapplication();
     $query = "SELECT `glpi_plugin_webapplications_webapplications`.* " . " FROM `glpi_plugin_webapplications_webapplications_items`,`glpi_plugin_webapplications_webapplications` " . " LEFT JOIN `glpi_entities` ON (`glpi_entities`.`id` = `glpi_plugin_webapplications_webapplications`.`entities_id`) " . " WHERE `glpi_plugin_webapplications_webapplications_items`.`items_id` = '" . $ID . "' \n         AND `glpi_plugin_webapplications_webapplications_items`.`itemtype` = '" . $itemtype . "' \n         AND `glpi_plugin_webapplications_webapplications_items`.`plugin_webapplications_webapplications_id` = `glpi_plugin_webapplications_webapplications`.`id` " . getEntitiesRestrictRequest(" AND ", "glpi_plugin_webapplications_webapplications", '', '', $web->maybeRecursive());
     $result = $DB->query($query);
     $number = $DB->numrows($result);
     if (!$number) {
         $pdf->displayLine(__('No item found'));
     } else {
         if (Session::isMultiEntitiesMode()) {
             $pdf->setColumnsSize(25, 25, 15, 15, 20);
             $pdf->displayTitle('<b><i>' . __('Name'), __('Entity'), __('Technician in charge of the hardware'), __('Group in charge of the hardware'), PluginWebapplicationsWebapplicationType::getTypeName(1) . '</i></b>');
         } else {
             $pdf->setColumnsSize(30, 30, 20, 20);
             $pdf->displayTitle('<b><i>' . __('Name'), __('Technician in charge of the hardware'), __('Group in charge of the hardware'), PluginWebapplicationsWebapplicationType::getTypeName(1) . '</i></b>');
         }
         while ($data = $DB->fetch_array($result)) {
             $webapplicationsID = $data["id"];
             if (Session::isMultiEntitiesMode()) {
                 $pdf->setColumnsSize(25, 25, 15, 15, 20);
                 $pdf->displayLine($data["name"], Html::clean(Dropdown::getDropdownName("glpi_entities", $data['entities_id'])), Html::clean(getUsername("glpi_users", $data["users_id_tech"])), Html::clean(Dropdown::getDropdownName("glpi_groups", $data["groups_id_tech"])), Html::clean(Dropdown::getDropdownName("glpi_plugin_webapplications_webapplicationtypes", $data["plugin_webapplications_webapplicationtypes_id"])));
             } else {
                 $pdf->setColumnsSize(50, 25, 25);
                 $pdf->displayLine($data["name"], Html::clean(getUsername("glpi_users", $data["users_id_tech"])), Html::clean(Dropdown::getDropdownName("glpi_groups", $data["groups_id_tech"])), Html::clean(Dropdown::getDropdownName("glpi_plugin_webapplications_webapplicationtypes", $data["plugin_webapplications_webapplicationtypes_id"])));
             }
         }
     }
 }
function plugin_webapplications_getAddSearchOptions($itemtype)
{
    $sopt = array();
    if (in_array($itemtype, PluginWebapplicationsWebapplication::getTypes(true))) {
        if (Session::haveRight("plugin_webapplications", READ)) {
            $sopt[1310]['table'] = 'glpi_plugin_webapplications_webapplications';
            $sopt[1310]['field'] = 'name';
            $sopt[1310]['name'] = PluginWebapplicationsWebapplication::getTypeName(2) . " - " . __('Name');
            $sopt[1310]['forcegroupby'] = true;
            $sopt[1310]['datatype'] = 'itemlink';
            $sopt[1310]['massiveaction'] = false;
            $sopt[1310]['itemlink_type'] = 'PluginWebapplicationsWebapplication';
            $sopt[1310]['joinparams'] = array('beforejoin' => array('table' => 'glpi_plugin_webapplications_webapplications_items', 'joinparams' => array('jointype' => 'itemtype_item')));
            $sopt[1311]['table'] = 'glpi_plugin_webapplications_webapplicationtypes';
            $sopt[1311]['field'] = 'name';
            $sopt[1311]['name'] = PluginWebapplicationsWebapplication::getTypeName(2) . " - " . PluginWebapplicationsWebapplicationType::getTypeName(1);
            $sopt[1311]['forcegroupby'] = true;
            $sopt[1311]['datatype'] = 'dropdown';
            $sopt[1311]['massiveaction'] = false;
            $sopt[1311]['joinparams'] = array('beforejoin' => array(array('table' => 'glpi_plugin_webapplications_webapplications', 'joinparams' => $sopt[1310]['joinparams'])));
        }
    }
    return $sopt;
}