getDropdownName() static public method

Returns the value of the dropdown from $table with ID $id.
static public getDropdownName ( $table, $id, $withcomment, $translate = true, $tooltip = true ) : string
$table the dropdown table from witch we want values on the select
$id id of the element to get
$withcomment give array with name and comment (default 0)
$translate (true by default)
$tooltip boolean (true by default) returns a tooltip, else returns only 'comment'
return string the value of the dropdown or   if not exists
 /**
  * Get all data needed for template processing
  **/
 function getDatasForTemplate($event, $options = array())
 {
     global $LANG, $CFG_GLPI;
     $this->datas['##contract.entity##'] = Dropdown::getDropdownName('glpi_entities', $options['entities_id']);
     $events = $this->getEvents();
     $this->datas['##contract.action##'] = $LANG['mailing'][39] . " - " . $events[$event];
     foreach ($options['contracts'] as $id => $contract) {
         $tmp = array();
         $tmp['##contract.name##'] = $contract['name'];
         $tmp['##contract.number##'] = $contract['num'];
         if ($contract['contracttypes_id']) {
             $tmp['##contract.type##'] = Dropdown::getDropdownName('glpi_contracttypes', $contract['contracttypes_id']);
         } else {
             $tmp['##contract.type##'] = "";
         }
         $tmp['##contract.time##'] = getWarrantyExpir($contract["begin_date"], $contract["duration"], $contract["notice"]);
         $tmp['##contract.url##'] = urldecode($CFG_GLPI["url_base"] . "/index.php?redirect=contract_" . $id);
         $this->datas['contracts'][] = $tmp;
     }
     $this->datas['##lang.contract.time##'] = $event == Alert::END ? $LANG['contract'][0] : $LANG['contract'][1];
     $this->getTags();
     foreach ($this->tag_descriptions[NotificationTarget::TAG_LANGUAGE] as $tag => $values) {
         if (!isset($this->datas[$tag])) {
             $this->datas[$tag] = $values['label'];
         }
     }
 }
 function getDatasForTemplate($event, $options = array())
 {
     global $CFG_GLPI;
     $this->datas['##notinfocom.entity##'] = Dropdown::getDropdownName('glpi_entities', $options['entities_id']);
     $this->datas['##lang.notinfocom.entity##'] = __('Entity');
     $events = $this->getAllEvents();
     $this->datas['##lang.notinfocom.title##'] = $events[$event];
     $this->datas['##lang.notinfocom.name##'] = __('Name');
     $this->datas['##lang.notinfocom.urlname##'] = __('URL');
     $this->datas['##lang.notinfocom.computertype##'] = __('Type');
     $this->datas['##lang.notinfocom.operatingsystem##'] = __('Operating system');
     $this->datas['##lang.notinfocom.state##'] = __('Status');
     $this->datas['##lang.notinfocom.location##'] = __('Location');
     $this->datas['##lang.notinfocom.urluser##'] = __('URL');
     $this->datas['##lang.notinfocom.urlgroup##'] = __('URL');
     $this->datas['##lang.notinfocom.user##'] = __('User');
     $this->datas['##lang.notinfocom.group##'] = __('Group');
     foreach ($options['notinfocoms'] as $id => $notinfocom) {
         $tmp = array();
         $tmp['##notinfocom.urlname##'] = urldecode($CFG_GLPI["url_base"] . "/index.php?redirect=computer_" . $notinfocom['id']);
         $tmp['##notinfocom.name##'] = $notinfocom['name'];
         $tmp['##notinfocom.computertype##'] = Dropdown::getDropdownName("glpi_computertypes", $notinfocom['computertypes_id']);
         $tmp['##notinfocom.operatingsystem##'] = Dropdown::getDropdownName("glpi_operatingsystems", $notinfocom['operatingsystems_id']);
         $tmp['##notinfocom.state##'] = Dropdown::getDropdownName("glpi_states", $notinfocom['states_id']);
         $tmp['##notinfocom.location##'] = Dropdown::getDropdownName("glpi_locations", $notinfocom['locations_id']);
         $tmp['##notinfocom.urluser##'] = urldecode($CFG_GLPI["url_base"] . "/index.php?redirect=user_" . $notinfocom['users_id']);
         $tmp['##notinfocom.urlgroup##'] = urldecode($CFG_GLPI["url_base"] . "/index.php?redirect=group_" . $notinfocom['groups_id']);
         $tmp['##notinfocom.user##'] = getUserName($notinfocom['users_id']);
         $tmp['##notinfocom.group##'] = Dropdown::getDropdownName("glpi_groups", $notinfocom['groups_id']);
         $tmp['##notinfocom.contact##'] = $notinfocom['contact'];
         $this->datas['notinfocoms'][] = $tmp;
     }
 }
Esempio n. 3
0
 static function pdfForTicket(PluginPdfSimplePDF $pdf, Ticket $job)
 {
     global $CFG_GLPI, $DB;
     $ID = $job->getField('id');
     //////////////followups///////////
     $query = "SELECT *\n                FROM `glpi_ticketcosts`\n                WHERE `tickets_id` = '{$ID}'\n                ORDER BY `begin_date`";
     $result = $DB->query($query);
     if (!$DB->numrows($result)) {
         $pdf->setColumnsSize(100);
         $pdf->displayLine(__('No ticket cost for this ticket', 'pdf'));
     } else {
         $pdf->setColumnsSize(60, 20, 20);
         $pdf->displayTitle("<b>" . TicketCost::getTypeName($DB->numrows($result)), __('Ticket duration'), CommonITILObject::getActionTime($job->fields['actiontime']) . "</b>");
         $pdf->setColumnsSize(20, 10, 10, 10, 10, 10, 10, 10, 10);
         $pdf->setColumnsAlign('center', 'center', 'center', 'left', 'right', 'right', 'right', 'right', 'right');
         $pdf->displayTitle("<b><i>" . __('Name') . "</i></b>", "<b><i>" . __('Begin date') . "</i></b>", "<b><i>" . __('End date') . "</i></b>", "<b><i>" . __('Budget') . "</i></b>", "<b><i>" . __('Duration') . "</i></b>", "<b><i>" . __('Time cost') . "</i></b>", "<b><i>" . __('Fixed cost') . "</i></b>", "<b><i>" . __('Material cost') . "</i></b>", "<b><i>" . __('Total cost') . "</i></b>");
         while ($data = $DB->fetch_array($result)) {
             $cost = TicketCost::computeTotalCost($data['actiontime'], $data['cost_time'], $data['cost_fixed'], $data['cost_material']);
             $pdf->displayLine($data['name'], Html::convDate($data['begin_date']), Html::convDate($data['end_date']), Dropdown::getDropdownName('glpi_budgets', $data['budgets_id']), CommonITILObject::getActionTime($data['actiontime']), Html::formatNumber($data['cost_time']), Html::formatNumber($data['cost_fixed']), Html::formatNumber($data['cost_material']), Html::formatNumber($cost));
             $total_time += $data['actiontime'];
             $total_costtime += $data['actiontime'] * $data['cost_time'] / HOUR_TIMESTAMP;
             $total_fixed += $data['cost_fixed'];
             $total_material += $data['cost_material'];
             $total += $cost;
         }
         $pdf->setColumnsSize(50, 10, 10, 10, 10, 10);
         $pdf->setColumnsAlign('right', 'right', 'right', 'right', 'right', 'right');
         $pdf->displayLine('<b>' . __('Total'), CommonITILObject::getActionTime($total_time), Html::formatNumber($total_costtime), Html::formatNumber($total_fixed), Html::formatNumber($total_material), Html::formatNumber($total));
     }
     $pdf->displaySpace();
 }
 function showForm($target)
 {
     global $DB;
     $rand = mt_rand();
     $query = "SELECT *\n                 FROM `" . $this->getTable() . "`\n                 ORDER BY `states_id` ASC ";
     if ($result = $DB->query($query)) {
         $number = $DB->numrows($result);
         if ($number != 0) {
             echo "<div align='center'><form method='post' name='massiveaction_form{$rand}' id='massiveaction_form{$rand}'  action=\"{$target}\">";
             echo "<table class='tab_cadre_fixe' cellpadding='5'>";
             echo "<tr>";
             echo "<th></th><th>" . _n('Status', 'Statuses', 2) . "</th>";
             echo "</tr>";
             while ($ligne = $DB->fetch_array($result)) {
                 $ID = $ligne["id"];
                 echo "<tr class='tab_bg_1'>";
                 echo "<td width='10' class='center'>";
                 echo "<input type='hidden' name='id' value='{$ID}'>";
                 echo "<input type='checkbox' name='item[{$ID}]' value='1'>";
                 echo "</td>";
                 echo "<td>" . Dropdown::getDropdownName("glpi_states", $ligne["states_id"]) . "</td>";
                 echo "</tr>";
             }
             Html::openArrowMassives("massiveaction_form{$rand}", true);
             Html::closeArrowMassives(array('delete_state' => __('Delete permanently')));
             echo "</table>";
             Html::closeForm();
             echo "</div>";
         }
     }
 }
 function displaySpecificTypeField($ID, $field = array())
 {
     global $CFG_GLPI;
     switch ($field['type']) {
         case 'groups':
             $groups = json_decode($this->fields[$field['name']], true);
             if (!empty($groups)) {
                 echo "<table class='tab_cadrehov' cellpadding='5'>";
                 foreach ($groups as $key => $val) {
                     echo "<tr class='tab_bg_1 center'>";
                     echo "<td>";
                     echo Dropdown::getDropdownName("glpi_groups", $val);
                     echo "</td>";
                     echo "<td>";
                     Html::showSimpleForm(Toolbox::getItemTypeFormURL('PluginTimelineticketConfig'), 'delete_groups', _x('button', 'Delete permanently'), array('delete_groups' => 'delete_groups', 'id' => $ID, '_groups_id_assign' => $val), $CFG_GLPI["root_doc"] . "/pics/delete.png");
                     echo " </td>";
                     echo "</tr>";
                 }
                 echo "</table>";
             } else {
                 _e('None');
             }
             break;
     }
 }
Esempio n. 6
0
 /**
  * Configuration form
  **/
 function showForm($id, $options = array())
 {
     $target = $this->getFormURL();
     if (isset($options['target'])) {
         $target = $options['target'];
     }
     if (!Session::haveRight("profile", "r")) {
         return false;
     }
     $canedit = Session::haveRight("profile", "w");
     $prof = new Profile();
     if ($id) {
         $this->getFromDB($id);
         $prof->getFromDB($id);
     }
     echo "<form action='" . $target . "' method='post'>";
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr><th colspan='2' class='center b'>" . sprintf(_('%1$s %2$s'), 'gestion Vip :', Dropdown::getDropdownName("glpi_groups", $this->fields["id"]));
     echo "</th></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>Groupe Vip</td><td>";
     Dropdown::showYesNo("isvip", $this->fields["isvip"]);
     echo "</td></tr>";
     if ($canedit) {
         echo "<tr class='tab_bg_2'>";
         echo "<td class='center' colspan='2'>";
         echo "<input type='hidden' name='id' value={$id}>";
         echo "<input type='submit' name='update_vip_group' value='Mettre à jour' class='submit'>";
         echo "</td></tr>";
     }
     echo "</table>";
     Html::closeForm();
 }
Esempio n. 7
0
 static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item)
 {
     global $DB, $CFG_GLPIG;
     if (!Session::haveRight("contract", "r")) {
         return false;
     }
     $type = $item->getType();
     $ID = $item->getField('id');
     $con = new Contract();
     $query = "SELECT *\n                FROM `glpi_contracts_items`\n                WHERE `glpi_contracts_items`.`items_id` = '" . $ID . "'\n                      AND `glpi_contracts_items`.`itemtype` = '" . $type . "'";
     $result = $DB->query($query);
     $number = $DB->numrows($result);
     $i = $j = 0;
     $pdf->setColumnsSize(100);
     if ($number > 0) {
         $pdf->displayTitle('<b>' . _N('Associated contract', 'Associated contracts', 2) . '</b>');
         $pdf->setColumnsSize(19, 19, 19, 16, 11, 16);
         $pdf->displayTitle(__('Name'), _x('phone', 'Number'), __('Contract type'), __('Supplier'), __('Start date'), __('Initial contract period'));
         $i++;
         while ($j < $number) {
             $cID = $DB->result($result, $j, "contracts_id");
             $assocID = $DB->result($result, $j, "id");
             if ($con->getFromDB($cID)) {
                 $pdf->displayLine(empty($con->fields["name"]) ? "(" . $con->fields["id"] . ")" : $con->fields["name"], $con->fields["num"], Html::clean(Dropdown::getDropdownName("glpi_contracttypes", $con->fields["contracttypes_id"])), str_replace("<br>", " ", $con->getSuppliersNames()), Html::convDate($con->fields["begin_date"]), sprintf(_n('%d month', '%d months', $con->fields["duration"]), $con->fields["duration"]));
             }
             $j++;
         }
     } else {
         $pdf->displayTitle("<b>" . __('No item found') . "</b>");
     }
     $pdf->displaySpace();
 }
 function getDatasForTemplate($event, $options = array())
 {
     global $CFG_GLPI, $DB;
     $this->datas['##notimported.entity##'] = Dropdown::getDropdownName('glpi_entities', $options['entities_id']);
     foreach ($options['notimported'] as $id => $item) {
         $tmp = array();
         $tmp['##notimported.name##'] = $item['name'];
         $tmp['##notimported.serial##'] = $item['serial'];
         $tmp['##notimported.entity##'] = Dropdown::getDropdownName('glpi_entities', $options['entities_id']);
         $tmp['##notimported.ocsid##'] = $item['ocsid'];
         $tmp['##notimported.deviceid##'] = $item['ocs_deviceid'];
         $tmp['##notimported.tag##'] = $item['tag'];
         $tmp['##notimported.ocsserver##'] = Dropdown::getDropdownName('glpi_plugin_ocsinventoryng_ocsservers', $item['ocsid']);
         $tmp['##notimported.reason##'] = PluginOcsinventoryngNotimportedcomputer::getReason($item['reason']);
         $url = $CFG_GLPI["url_base"] . "/index.php?redirect=plugin_ocsinventoryng_" . $item['id'];
         $tmp['##notimported.url##'] = urldecode($url);
         $this->datas['notimported'][] = $tmp;
     }
     $this->getTags();
     foreach ($this->tag_descriptions[NotificationTarget::TAG_LANGUAGE] as $tag => $values) {
         if (!isset($this->datas[$tag])) {
             $this->datas[$tag] = $values['label'];
         }
     }
 }
 static function pdfMain(PluginPdfSimplePDF $pdf, SoftwareLicense $license, $main = true, $cpt = true)
 {
     global $DB;
     $ID = $license->getField('id');
     $pdf->setColumnsSize(100);
     $entity = '';
     if (Session::isMultiEntitiesMode() && !$main) {
         $entity = ' (' . Html::clean(Dropdown::getDropdownName('glpi_entities', $license->fields['entities_id'])) . ')';
     }
     $pdf->displayTitle('<b><i>' . sprintf(__('%1$s: %2$s'), __('ID') . "</i>", $ID . "</b>" . $entity));
     $pdf->setColumnsSize(50, 50);
     $pdf->displayLine('<b><i>' . sprintf(__('%1$s: %2$s'), Software::getTypeName(1) . '</i></b>', Html::clean(Dropdown::getDropdownName('glpi_softwares', $license->fields['softwares_id']))), '<b><i>' . sprintf(__('%1$s: %2$s'), __('Type') . '</i></b>', Html::clean(Dropdown::getDropdownName('glpi_softwarelicensetypes', $license->fields['softwarelicensetypes_id']))));
     $pdf->displayLine('<b><i>' . sprintf(__('%1$s: %2$s'), __('Name') . '</i></b>', $license->fields['name']), '<b><i>' . sprintf(__('%1$s: %2$s'), __('Serial number') . '</i></b>', $license->fields['serial']));
     $pdf->displayLine('<b><i>' . sprintf(__('%1$s: %2$s'), __('Purchase version') . '</i></b>', Html::clean(Dropdown::getDropdownName('glpi_softwareversions', $license->fields['softwareversions_id_buy']))), '<b><i>' . sprintf(__('%1$s: %2$s'), __('Inventory number') . '</i></b>', $license->fields['otherserial']));
     $pdf->displayLine('<b><i>' . sprintf(__('%1$s: %2$s'), __('Version in use') . '</i></b>', Html::clean(Dropdown::getDropdownName('glpi_softwareversions', $license->fields['softwareversions_id_use']))), '<b><i>' . sprintf(__('%1$s: %2$s'), __('Expiration') . '</i></b>', Html::convDate($license->fields['expire'])));
     $col2 = '';
     if ($cpt) {
         $col2 = '<b><i>' . sprintf(__('%1$s: %2$s'), __('Affected computers') . '</i></b>', Computer_SoftwareLicense::countForLicense($ID));
     }
     $pdf->displayLine('<b><i>' . sprintf(__('%1$s: %2$s'), _x('quantity', 'Number') . '</i></b>', $license->fields['number'] > 0 ? $license->fields['number'] : __('Unlimited')), $col2);
     $pdf->setColumnsSize(100);
     PluginPdfCommon::mainLine($pdf, $license, 'comment');
     if ($main) {
         $pdf->displaySpace();
     }
 }
 function showForm()
 {
     global $DB;
     $query = "SELECT * FROM\n               `" . $this->getTable() . "`\n               ORDER BY `states_id` ASC";
     if ($result = $DB->query($query)) {
         $number = $DB->numrows($result);
         if ($number != 0) {
             echo "<form method='post' name='massiveaction_form' id='massiveaction_form' action='" . $this->getFormURL() . "'>";
             echo "<div align='center'>";
             echo "<table class='tab_cadre_fixe' cellpadding='5'>";
             echo "<tr>";
             echo "<th>" . __('Status') . "</th><th></th>";
             echo "</tr>";
             while ($ligne = $DB->fetch_array($result)) {
                 $ID = $ligne["id"];
                 echo "<tr class='tab_bg_1'>";
                 echo "<td width='10'>";
                 echo "<input type='checkbox' name='item[{$ID}]'";
                 if (isset($_POST['check']) && $_POST['check'] == 'all') {
                     echo " checked ";
                 }
                 echo ">";
                 echo "</td>";
                 echo "<td>" . Dropdown::getDropdownName("glpi_states", $ligne["states_id"]) . "</td>";
                 echo "</tr>";
             }
             echo "</table></div>";
             Html::openArrowMassives("massiveaction_form", true);
             Html::closeArrowMassives(array('delete_state' => _sx('button', 'Delete permanently')));
             Html::closeForm();
             echo "<div align='center'><form method='post' action='" . $this->getFormURL() . "'>";
             echo "<table class='tab_cadre_fixe' cellpadding='5'><tr ><th colspan='2'>";
             echo __('Disposal status', 'financialreports') . " : </th></tr>";
             echo "<tr class='tab_bg_1'><td>";
             Dropdown::show('State', array('name' => "states_id", 'value' => $ligne["states_id"]));
             echo "</td>";
             echo "<td>";
             echo "<div align='center'>";
             echo "<input type='submit' name='add_state' value='" . _sx('button', 'Post') . "' class='submit' >";
             echo "</div></td></tr>";
             echo "</table>";
             Html::closeForm();
             echo "</div>";
         } else {
             echo "<div align='center'><form method='post' action='" . $this->getFormURL() . "'>";
             echo "<table class='tab_cadre' cellpadding='5'><tr ><th colspan='2'>";
             echo __('Disposal status', 'financialreports') . " : </th></tr>";
             echo "<tr class='tab_bg_1'><td>";
             Dropdown::show('State', array('name' => "states_id"));
             echo "</td>";
             echo "<td>";
             echo "<div align='center'>";
             echo "<input type='submit' name='add_state' value='" . _sx('button', 'Post') . "' class='submit' >";
             echo "</div></td></tr>";
             echo "</table>";
             Html::closeForm();
             echo "</div>";
         }
     }
 }
 function getDatasForTemplate($event, $options = array())
 {
     global $CFG_GLPI;
     if ($event == 'AlertNotValidatedTypology') {
         $this->datas['##typology.entity##'] = Dropdown::getDropdownName('glpi_entities', $options['entities_id']);
         $this->datas['##lang.typology.entity##'] = __('Entity');
         $this->datas['##typology.action##'] = __('Elements not match with the typology', 'typology');
         $this->datas['##lang.typology.name##'] = PluginTypologyTypology::getTypeName(1);
         $this->datas['##lang.typology.itemtype##'] = __('Type');
         $this->datas['##lang.typology.items_id##'] = __('Name');
         $this->datas['##lang.typology.error##'] = __('Error');
         $this->datas['##lang.typology.url##'] = __('Link to the typology', 'typology');
         $this->datas['##lang.typology.itemurl##'] = __('Link to the element', 'typology');
         $this->datas['##lang.typology.itemuser##'] = __('User');
         $this->datas['##lang.typology.itemlocation##'] = __('Location');
         foreach ($options['items'] as $id => $item) {
             $tmp = array();
             $tmp['##typology.name##'] = $item['name'];
             $itemtype = new $item['itemtype']();
             $itemtype->getFromDB($item["items_id"]);
             $tmp['##typology.itemtype##'] = $itemtype->getTypeName();
             $tmp['##typology.items_id##'] = $itemtype->getName();
             $tmp['##typology.error##'] = PluginTypologyTypology_Item::displayErrors($item['error'], false);
             $tmp['##typology.url##'] = urldecode($CFG_GLPI["url_base"] . "/index.php?redirect=plugin_typology_" . $item['plugin_typology_typologies_id']);
             $tmp['##typology.itemurl##'] = urldecode($CFG_GLPI["url_base"] . "/index.php?redirect=" . Toolbox::strtolower($item['itemtype']) . "_" . $item["items_id"]);
             $tmp['##typology.itemuser##'] = getUserName($itemtype->fields["users_id"]);
             $tmp['##typology.itemlocation##'] = Dropdown::getDropdownName("glpi_locations", $itemtype->fields['locations_id']);
             $this->datas['typologyitems'][] = $tmp;
         }
     }
 }
Esempio n. 12
0
 public function getAnswer()
 {
     $value = $this->getValue();
     if ($this->fields['values'] == 'User') {
         return getUserName($value);
     } else {
         return Dropdown::getDropdownName(getTableForItemType($this->fields['values']), $value);
     }
 }
Esempio n. 13
0
 /**
  * @since version 0.84
  *
  * @param $row                HTMLTableRow object (default NULL)
  * @param $item               CommonDBTM object (default NULL)
  * @param $father             HTMLTableCell object (default NULL)
  * @param $options   array
  **/
 static function getHTMLTableCellsForItem(HTMLTableRow $row = NULL, CommonDBTM $item = NULL, HTMLTableCell $father = NULL, array $options = array())
 {
     $column_name = __CLASS__;
     if (isset($options['dont_display'][$column_name])) {
         return;
     }
     if ($item->fields["interfacetypes_id"]) {
         $row->addCell($row->getHeaderByName($column_name), Dropdown::getDropdownName("glpi_interfacetypes", $item->fields["interfacetypes_id"]));
     }
 }
Esempio n. 14
0
 /**
  * return the display data for a specific device
  *
  * @return array
  **/
 function getFormData()
 {
     global $LANG;
     $data['label'] = $data['value'] = array();
     if ($this->fields["devicecasetypes_id"]) {
         $data['label'][] = $LANG['device_case'][0];
         $data['value'][] = Dropdown::getDropdownName("glpi_devicecasetypes", $this->fields["devicecasetypes_id"]);
     }
     return $data;
 }
Esempio n. 15
0
 static function pdfForTicket(PluginPdfSimplePDF $pdf, Ticket $job, $private)
 {
     global $CFG_GLPI, $DB;
     $ID = $job->getField('id');
     //////////////Tasks///////////
     $RESTRICT = "";
     if (!$private) {
         // Don't show private'
         $RESTRICT = " AND `is_private` = '0' ";
     } else {
         if (!Session::haveRight("show_full_ticket", "1")) {
             // No right, only show connected user private one
             $RESTRICT = " AND (`is_private` = '0'\n                          OR `users_id` ='" . Session::getLoginUserID() . "' ) ";
         }
     }
     $query = "SELECT *\n                FROM `glpi_tickettasks`\n                WHERE `tickets_id` = '{$ID}'\n                      {$RESTRICT}\n                ORDER BY `date` DESC";
     $result = $DB->query($query);
     if (!$DB->numrows($result)) {
         $pdf->setColumnsSize(100);
         $pdf->displayLine(__('No task found.'));
     } else {
         $pdf->displayTitle("<b>" . TicketTask::getTypeName($DB->numrows($result) . "</b>"));
         $pdf->setColumnsSize(20, 20, 20, 20, 20);
         $pdf->displayTitle("<b><i>" . __('Type') . "</i></b>", "<b><i>" . __('Date') . "</i></b>", "<b><i>" . __('Duration') . "</i></b>", "<b><i>" . __('Writer') . "</i></b>", "<b><i>" . __('Planning') . "</i></b>");
         while ($data = $DB->fetch_array($result)) {
             $actiontime = Html::timestampToString($data['actiontime'], false);
             $planification = '';
             if (empty($data['begin'])) {
                 if (isset($data["state"])) {
                     $planification = Planning::getState($data["state"]) . "<br>";
                 }
                 $planification .= _e('None');
             } else {
                 if (isset($data["state"])) {
                     $planification = sprintf(__('%1$s: %2$s'), _x('item', 'State'), Planning::getState($data["state"]));
                 }
                 $planificiation = sprintf(__('%1$s - %2$s'), $planification, Html::convDateTime($data["begin"]) . " -> " . Html::convDateTime($data["end"]));
                 $planificiation = sprintf(__('%1$s - %2$s'), $planification, sprintf(__('%1$s  %2$s'), __('By'), getUserName($data["users_id_tech"])));
             }
             if ($data['taskcategories_id']) {
                 $lib = Dropdown::getDropdownName('glpi_taskcategories', $data['taskcategories_id']);
             } else {
                 $lib = '';
             }
             if ($data['is_private']) {
                 $lib = sprintf(__('%1$s (%2$s)'), $lib, __('Private'));
             }
             toolbox::logdebug("lib", $data);
             $pdf->displayLine(Html::clean($lib), Html::convDateTime($data["date"]), Html::timestampToString($data["actiontime"], 0), Html::clean(getUserName($data["users_id"])), Html::clean($planification), 1);
             $pdf->displayText("<b><i>" . sprintf(__('%1$s: %2$s'), __('Description') . "</i></b>", Html::clean($data["content"]), 1));
         }
     }
     $pdf->displaySpace();
 }
 /**
  * Get the attributes needed for processing the rules
  *
  * @see RuleCollection::prepareInputDataForProcess()
  *
  * @param $input     input data
  * @param $software  software data array
  *
  * @return an array of attributes
  **/
 function prepareInputDataForProcess($input, $software)
 {
     $params["name"] = $software["name"];
     if (isset($software["comment"])) {
         $params["comment"] = $software["comment"];
     }
     if (isset($software["manufacturers_id"])) {
         $params["manufacturer"] = Dropdown::getDropdownName("glpi_manufacturers", $software["manufacturers_id"]);
     }
     return $params;
 }
 /**
  * return the display data for a specific device
  *
  * @return array
  **/
 function getFormData()
 {
     global $LANG;
     $data['label'] = $data['value'] = array();
     if ($this->fields["interfacetypes_id"]) {
         $data['label'][] = $LANG['common'][65];
         $data['value'][] = Dropdown::getDropdownName("glpi_interfacetypes", $this->fields["interfacetypes_id"]);
     }
     // Specificity
     $data['label'][] = $LANG['devices'][6];
     $data['size'] = 10;
     return $data;
 }
Esempio n. 18
0
 static function pdfMain(PluginPdfSimplePDF $pdf, SoftwareVersion $version)
 {
     global $DB;
     $ID = $version->getField('id');
     $pdf->setColumnsSize(100);
     $pdf->displayTitle('<b><i>' . sprintf(__('%1$s: %2$s'), __('ID') . "</i>", $ID . "</b>"));
     $pdf->setColumnsSize(50, 50);
     $pdf->displayLine('<b><i>' . sprintf(__('%1$s: %2$s'), __('Name') . '</i></b>', $version->fields['name']), '<b><i>' . sprintf(__('%1$s: %2$s'), _n('Software', 'Software', 2) . '</i></b>', Html::clean(Dropdown::getDropdownName('glpi_softwares', $version->fields['softwares_id']))));
     $pdf->displayLine('<b><i>' . sprintf(__('%1$s: %2$s'), __('Status') . '</i></b>', Html::clean(Dropdown::getDropdownName('glpi_states', $version->fields['states_id']))), '<b><i>' . sprintf(__('%1$s: %2$s'), __('Operating system') . '</i></b>', Html::clean(Dropdown::getDropdownName('glpi_operatingsystems', $version->fields['operatingsystems_id']))));
     $pdf->setColumnsSize(100);
     PluginPdfCommon::mainLine($pdf, $version, 'comment');
     $pdf->displaySpace();
 }
 function getDatasForTemplate($event, $options = array())
 {
     $this->datas['##badge.entity##'] = Dropdown::getDropdownName('glpi_entities', $options['entities_id']);
     $this->datas['##lang.badge.entity##'] = __('Entity');
     switch ($event) {
         case self::ExpiredBadges:
             $this->datas['##badge.action##'] = __('Badges at the end of the validity', 'badges');
             break;
         case self::BadgesWhichExpire:
             $this->datas['##badge.action##'] = __('Badges which expires', 'badges');
             break;
         case self::AccessBadgeRequest:
             $this->datas['##badge.action##'] = __('Access badge request', 'badges');
             break;
         case self::BadgesReturn:
             $this->datas['##badge.action##'] = __('Badge return delay', 'badges');
             break;
     }
     $this->datas['##lang.badge.name##'] = __('Name');
     $this->datas['##lang.badge.dateexpiration##'] = __('Date of end of validity', 'badges');
     $this->datas['##lang.badge.serial##'] = __('Serial number');
     $this->datas['##lang.badge.users##'] = __('Allotted to', 'badges');
     if (isset($options['badges'])) {
         foreach ($options['badges'] as $id => $badge) {
             $tmp = array();
             $tmp['##badge.name##'] = $badge['name'];
             $tmp['##badge.serial##'] = $badge['serial'];
             $tmp['##badge.users##'] = Html::clean(getUserName($badge["users_id"]));
             $tmp['##badge.dateexpiration##'] = Html::convDate($badge['date_expiration']);
             $this->datas['badges'][] = $tmp;
         }
     }
     // Badge request
     $this->datas['##lang.badgerequest.visitorrealname##'] = __('Visitor realname', 'badges');
     $this->datas['##lang.badgerequest.visitorfirstname##'] = __('Visitor firstname', 'badges');
     $this->datas['##lang.badgerequest.visitorsociety##'] = __('Visitor society', 'badges');
     $this->datas['##lang.badgerequest.arrivaldate##'] = __('Arrival date', 'badges');
     $this->datas['##lang.badgerequest.requester##'] = __('Requester');
     if (isset($options['badgerequest'])) {
         foreach ($options['badgerequest'] as $id => $badge) {
             $tmp = array();
             $tmp['##badgerequest.visitorrealname##'] = $badge['visitor_realname'];
             $tmp['##badgerequest.visitorfirstname##'] = $badge['visitor_firstname'];
             $tmp['##badgerequest.visitorsociety##'] = $badge['visitor_society'];
             $tmp['##badgerequest.arrivaldate##'] = Html::convDate($badge['affectation_date']);
             $tmp['##badgerequest.requester##'] = Html::clean(getUserName(Session::getLoginUserID()));
             $this->datas['badgerequest'][] = $tmp;
         }
     }
 }
 function getDatasForTemplate($event, $options = array())
 {
     $this->datas['##certificate.entity##'] = Dropdown::getDropdownName('glpi_entities', $options['entities_id']);
     $this->datas['##lang.certificate.entity##'] = __('Entity');
     $this->datas['##certificate.action##'] = $event == "ExpiredCertificates" ? __('Expired certificates', 'certificates') : __('Expiring certificates', 'certificates');
     $this->datas['##lang.certificate.name##'] = __('Name');
     $this->datas['##lang.certificate.dateexpiration##'] = __('Expiration date');
     foreach ($options['certificates'] as $id => $certificate) {
         $tmp = array();
         $tmp['##certificate.name##'] = $certificate['name'];
         $tmp['##certificate.dateexpiration##'] = Html::convDate($certificate['date_expiration']);
         $this->datas['certificates'][] = $tmp;
     }
 }
 /**
  * return the display data for a specific device
  *
  * @return array
  **/
 function getFormData()
 {
     global $LANG;
     $data['label'] = $data['value'] = array();
     if ($this->fields["is_raid"]) {
         $data['label'][] = $LANG['device_control'][0];
         $data['value'][] = Dropdown::getYesNo($this->fields["is_raid"]);
     }
     if ($this->fields["interfacetypes_id"]) {
         $data['label'][] = $LANG['common'][65];
         $data['value'][] = Dropdown::getDropdownName("glpi_interfacetypes", $this->fields["interfacetypes_id"]);
     }
     return $data;
 }
 function getDatasForTemplate($event, $options = array())
 {
     global $CFG_GLPI;
     $this->datas['##domain.entity##'] = Dropdown::getDropdownName('glpi_entities', $options['entities_id']);
     $this->datas['##lang.domain.entity##'] = __('Entity');
     $this->datas['##domain.action##'] = $event == "ExpiredDomains" ? __('Expired domains', 'domains') : __('Expiring domains', 'domains');
     $this->datas['##lang.domain.name##'] = __('Name');
     $this->datas['##lang.domain.dateexpiration##'] = __('Expiration date');
     foreach ($options['domains'] as $id => $domain) {
         $tmp = array();
         $tmp['##domain.name##'] = $domain['name'];
         $tmp['##domain.dateexpiration##'] = Html::convDate($domain['date_expiration']);
         $this->datas['domains'][] = $tmp;
     }
 }
Esempio n. 23
0
 static function pdfMain(PluginPdfSimplePDF $pdf, Peripheral $item)
 {
     PluginPdfCommon::mainTitle($pdf, $item);
     PluginPdfCommon::mainLine($pdf, $item, 'name-status');
     PluginPdfCommon::mainLine($pdf, $item, 'location-type');
     PluginPdfCommon::mainLine($pdf, $item, 'tech-manufacturer');
     PluginPdfCommon::mainLine($pdf, $item, 'group-model');
     PluginPdfCommon::mainLine($pdf, $item, 'contactnum-serial');
     PluginPdfCommon::mainLine($pdf, $item, 'contact-otherserial');
     PluginPdfCommon::mainLine($pdf, $item, 'user_management');
     $pdf->displayLine('<b><i>' . sprintf(__('%1$s: %2$s'), __('Group') . '</i></b>', Html::clean(Dropdown::getDropdownName('glpi_groups', $item->fields['groups_id']))));
     $pdf->setColumnsSize(100);
     PluginPdfCommon::mainLine($pdf, $item, 'comment');
     $pdf->displaySpace();
 }
 function getDatasForTemplate($event, $options = array())
 {
     global $CFG_GLPI;
     $events = $this->getAllEvents();
     $this->datas['##lang.ideabox.title##'] = $events[$event];
     $this->datas['##lang.ideabox.entity##'] = __('Entity');
     $this->datas['##ideabox.entity##'] = Dropdown::getDropdownName('glpi_entities', $this->obj->getField('entities_id'));
     $this->datas['##ideabox.id##'] = sprintf("%07d", $this->obj->getField("id"));
     $this->datas['##lang.ideabox.name##'] = __('Title');
     $this->datas['##ideabox.name##'] = $this->obj->getField("name");
     $this->datas['##lang.ideabox.comment##'] = __('Description');
     $comment = stripslashes(str_replace(array('\\r\\n', '\\n', '\\r'), "<br/>", $this->obj->getField("comment")));
     $this->datas['##ideabox.comment##'] = nl2br($comment);
     $this->datas['##lang.ideabox.url##'] = "URL";
     $this->datas['##ideabox.url##'] = urldecode($CFG_GLPI["url_base"] . "/index.php?redirect=plugin_ideabox_" . $this->obj->getField("id"));
     //old values infos
     if (isset($this->target_object->oldvalues) && !empty($this->target_object->oldvalues) && $event == 'update') {
         $this->datas['##lang.update.title##'] = __('Modified fields', 'ideabox');
         $tmp = array();
         if (isset($this->target_object->oldvalues['name']) && !empty($this->target_object->oldvalues['name'])) {
             $tmp['##update.name##'] = $this->target_object->oldvalues['name'];
         }
         if (isset($this->target_object->oldvalues['comment']) && !empty($this->target_object->oldvalues['comment'])) {
             $tmp['##update.comment##'] = nl2br($this->target_object->oldvalues['comment']);
         }
         $this->datas['updates'][] = $tmp;
     }
     //comment infos
     $restrict = "`plugin_ideabox_ideaboxes_id`='" . $this->obj->getField('id') . "'";
     if (isset($options['comment_id']) && $options['comment_id']) {
         $restrict .= " AND `glpi_plugin_ideabox_comments`.`id` = '" . $options['comment_id'] . "'";
     }
     $restrict .= " ORDER BY `date_comment` DESC";
     $comments = getAllDatasFromTable('glpi_plugin_ideabox_comments', $restrict);
     $this->datas['##lang.comment.title##'] = _n('Associated comment', 'Associated comments', 2, 'ideabox');
     $this->datas['##lang.comment.name##'] = __('Name');
     $this->datas['##lang.comment.author##'] = __('Comment author', 'ideabox');
     $this->datas['##lang.comment.datecomment##'] = __('Date');
     $this->datas['##lang.comment.comment##'] = __('Content');
     foreach ($comments as $comment) {
         $tmp = array();
         $tmp['##comment.name##'] = $comment['name'];
         $tmp['##comment.author##'] = Html::clean(getUserName($comment['users_id']));
         $tmp['##comment.datecomment##'] = Html::convDateTime($comment['date_comment']);
         $tmp['##comment.comment##'] = nl2br($comment['comment']);
         $this->datas['comments'][] = $tmp;
     }
 }
 function getDatasForTemplate($event, $options = array())
 {
     global $LANG, $CFG_GLPI;
     //----------- Reservation infos -------------- //
     $events = $this->getAllEvents();
     $this->datas['##reservation.action##'] = $events[$event];
     if ($event != 'alert') {
         $this->datas['##reservation.user##'] = "";
         $user_tmp = new User();
         if ($user_tmp->getFromDB($this->obj->getField('users_id'))) {
             $this->datas['##reservation.user##'] = $user_tmp->getName();
         }
         $this->datas['##reservation.begin##'] = convDateTime($this->obj->getField('begin'));
         $this->datas['##reservation.end##'] = convDateTime($this->obj->getField('end'));
         $this->datas['##reservation.comment##'] = $this->obj->getField('comment');
         $reservationitem = new ReservationItem();
         $reservationitem->getFromDB($this->obj->getField('reservationitems_id'));
         $itemtype = $reservationitem->getField('itemtype');
         if (class_exists($itemtype)) {
             $item = new $itemtype();
             $item->getFromDB($reservationitem->getField('items_id'));
             $this->datas['##reservation.itemtype##'] = $item->getTypeName();
             $this->datas['##reservation.item.name##'] = $item->getField('name');
             $this->datas['##reservation.item.entity##'] = Dropdown::getDropdownName('glpi_entities', $item->getField('entities_id'));
             if ($item->isField('users_id_tech')) {
                 $this->datas['##reservation.item.tech##'] = Dropdown::getDropdownName('glpi_users', $item->getField('users_id_tech'));
             }
             $this->datas['##reservation.url##'] = urldecode($CFG_GLPI["url_base"] . "/index.php?redirect=" . strtolower($itemtype) . "_" . $reservationitem->getField('id'));
         }
     } else {
         $this->datas['##reservation.entity##'] = Dropdown::getDropdownName('glpi_entities', $options['entities_id']);
         foreach ($options['items'] as $id => $item) {
             $tmp = array();
             $obj = new $item['itemtype']();
             $tmp['##reservation.itemtype##'] = $obj->getTypeName();
             $tmp['##reservation.item##'] = $item['item_name'];
             $tmp['##reservation.expirationdate##'] = convDateTime($item['end']);
             $tmp['##reservation.url##'] = urldecode($CFG_GLPI["url_base"] . "/index.php?redirect=reservation_" . $id);
             $this->datas['reservations'][] = $tmp;
         }
     }
     $this->getTags();
     foreach ($this->tag_descriptions[NotificationTarget::TAG_LANGUAGE] as $tag => $values) {
         if (!isset($this->datas[$tag])) {
             $this->datas[$tag] = $values['label'];
         }
     }
 }
 function showCacheRuleDetail($fields)
 {
     global $LANG;
     echo "<td class='tab_bg_2'>" . $fields["old_value"] . "</td>";
     echo "<td class='tab_bg_2'>" . $fields["manufacturer"] . "</td>";
     echo "<td class='tab_bg_2'>" . ($fields["new_value"] != '' ? $fields["new_value"] : $LANG['rulesengine'][106]) . "</td>";
     echo "<td class='tab_bg_2'>" . ($fields["is_global"] != '' ? Dropdown::getGlobalSwitch($fields["is_global"]) : $LANG['rulesengine'][106]) . "</td>";
     echo "<td class='tab_bg_2'>" . (isset($fields["new_manufacturer"]) && $fields["new_manufacturer"] != '' ? Dropdown::getDropdownName("glpi_manufacturers", $fields["new_manufacturer"]) : $LANG['rulesengine'][106]) . "</td>";
     echo "<td class='tab_bg_2'>";
     if ($fields["ignore_ocs_import"] == '') {
         echo "&nbsp;";
     } else {
         echo Dropdown::getYesNo($fields["ignore_ocs_import"]);
     }
     echo "</td>";
 }
 static function pdfForComputer(PluginPdfSimplePDF $pdf, Computer $item)
 {
     global $DB;
     $ID = $item->getField('id');
     // From ComputerVirtualMachine::showForComputer()
     $virtualmachines = getAllDatasFromTable('glpi_computervirtualmachines', "`computers_id` = '{$ID}'");
     $pdf->setColumnsSize(100);
     if (count($virtualmachines)) {
         $pdf->displayTitle("<b>" . __('List of virtual machines') . "</b>");
         $pdf->setColumnsSize(20, 8, 8, 8, 25, 8, 8, 15);
         $pdf->setColumnsAlign('left', 'center', 'center', 'center', 'left', 'right', 'right', 'left');
         $typ = explode(' ', __('Virtualization system'));
         $sys = explode(' ', __('Virtualization model'));
         $sta = explode(' ', __('State of the virtual machine'));
         $pdf->displayTitle(__('Name'), $typ[0], $sys[0], $sta[0], __('UUID'), __('CPU'), __('Mio'), __('Machine'));
         foreach ($virtualmachines as $virtualmachine) {
             $name = '';
             if ($link_computer = ComputerVirtualMachine::findVirtualMachine($virtualmachine)) {
                 $computer = new Computer();
                 if ($computer->getFromDB($link_computer)) {
                     $name = $computer->getName();
                 }
             }
             $pdf->displayLine($virtualmachine['name'], Html::clean(Dropdown::getDropdownName('glpi_virtualmachinetypes', $virtualmachine['virtualmachinetypes_id'])), Html::clean(Dropdown::getDropdownName('glpi_virtualmachinesystems', $virtualmachine['virtualmachinesystems_id'])), Html::clean(Dropdown::getDropdownName('glpi_virtualmachinestates', $virtualmachine['virtualmachinestates_id'])), $virtualmachine['uuid'], $virtualmachine['vcpu'], Html::clean(Html::formatNumber($virtualmachine['ram'], false, 0)), $name);
         }
     } else {
         $pdf->displayTitle("<b>" . __('No virtual machine associated with the computer') . "</b>");
     }
     // From ComputerVirtualMachine::showForVirtualMachine()
     if ($item->fields['uuid']) {
         $where = "`uuid`" . ComputerVirtualMachine::getUUIDRestrictRequest($item->fields['uuid']);
         $hosts = getAllDatasFromTable('glpi_computervirtualmachines', $where);
         if (count($hosts)) {
             $pdf->setColumnsSize(100);
             $pdf->displayTitle("<b>" . __('List of host machines') . "</b>");
             $pdf->setColumnsSize(26, 37, 37);
             $pdf->displayTitle(__('Name'), __('Operating system'), __('Entity'));
             $computer = new Computer();
             foreach ($hosts as $host) {
                 if ($computer->getFromDB($host['computers_id'])) {
                     $pdf->displayLine($computer->getName(), Html::clean(Dropdown::getDropdownName('glpi_operatingsystems', $computer->getField('operatingsystems_id'))), Html::clean(Dropdown::getDropdownName('glpi_entities', $computer->getEntityID())));
                 }
             }
         }
     }
     $pdf->displaySpace();
 }
 static function pdfMain(PluginPdfSimplePDF $pdf, NetworkEquipment $item)
 {
     PluginPdfCommon::mainTitle($pdf, $item);
     PluginPdfCommon::mainLine($pdf, $item, 'name-status');
     PluginPdfCommon::mainLine($pdf, $item, 'location-type');
     PluginPdfCommon::mainLine($pdf, $item, 'tech-manufacturer');
     PluginPdfCommon::mainLine($pdf, $item, 'group-model');
     PluginPdfCommon::mainLine($pdf, $item, 'contactnum-serial');
     PluginPdfCommon::mainLine($pdf, $item, 'contact-otherserial');
     $pdf->displayLine('<b><i>' . sprintf(__('%1$s: %2$s'), __('User') . '</i></b>', getUserName($item->fields['users_id'])), '<b><i>' . sprintf(__('%1$s: %2$s'), __('Network') . '</i></b>', Html::clean(Dropdown::getDropdownName('glpi_networks', $item->fields['networks_id']))));
     $pdf->displayLine('<b><i>' . sprintf(__('%1$s: %2$s'), __('Group') . '</i></b>', Html::clean(Dropdown::getDropdownName('glpi_groups', $item->fields['groups_id']))), '<b><i>' . sprintf(__('%1$s: %2$s'), __('Domain') . '</i></b>', Html::clean(Dropdown::getDropdownName('glpi_domains', $item->fields['domains_id']))));
     $pdf->displayLine(__('The MAC address and the IP of the equipment are included in an aggregated network port'));
     $pdf->displayLine('<b><i>' . sprintf(__('%1$s: %2$s'), _n('Firmware', 'Firmwares', 1) . '</i></b>', Html::clean(Dropdown::getDropdownName('glpi_networkequipmentfirmwares', $item->fields['networkequipmentfirmwares_id']))), '<b><i>' . sprintf(__('%1$s: %2$s'), sprintf(__('%1$s (%2$s)'), __('Memory'), __('Mio')) . '</i></b>', $item->fields['ram']));
     $pdf->setColumnsSize(100);
     PluginPdfCommon::mainLine($pdf, $item, 'comment');
     $pdf->displaySpace();
 }
 /**
  * return the display data for a specific device
  *
  * @return array
  **/
 function getFormData()
 {
     global $LANG;
     $data['label'] = $data['value'] = array();
     if ($this->fields["devicememorytypes_id"]) {
         $data['label'][] = $LANG['common'][17];
         $data['value'][] = Dropdown::getDropdownName("glpi_devicememorytypes", $this->fields["devicememorytypes_id"]);
     }
     if (!empty($this->fields["frequence"])) {
         $data['label'][] = $LANG['device_ram'][1];
         $data['value'][] = $this->fields["frequence"];
     }
     // Specificity
     $data['label'][] = $LANG['device_ram'][2];
     $data['size'] = 10;
     return $data;
 }
 function getDatasForTemplate($event, $options = array())
 {
     $this->datas['##badge.entity##'] = Dropdown::getDropdownName('glpi_entities', $options['entities_id']);
     $this->datas['##lang.badge.entity##'] = __('Entity');
     $this->datas['##badge.action##'] = $event == "ExpiredBadges" ? __('Badges at the end of the validity', 'badges') : __('Badges which expires', 'badges');
     $this->datas['##lang.badge.name##'] = __('Name');
     $this->datas['##lang.badge.dateexpiration##'] = __('Date of end of validity', 'badges');
     $this->datas['##lang.badge.serial##'] = __('Serial number');
     $this->datas['##lang.badge.users##'] = __('Allotted to', 'badges');
     foreach ($options['badges'] as $id => $badge) {
         $tmp = array();
         $tmp['##badge.name##'] = $badge['name'];
         $tmp['##badge.serial##'] = $badge['serial'];
         $tmp['##badge.users##'] = Html::clean(getUserName($badge["users_id"]));
         $tmp['##badge.dateexpiration##'] = Html::convDate($badge['date_expiration']);
         $this->datas['badges'][] = $tmp;
     }
 }