archires.class.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <?php
  2. /*
  3. * @version $Id: archires.class.php 234 2019-12-12 14:34:31Z yllen $
  4. -------------------------------------------------------------------------
  5. LICENSE
  6. This file is part of Archires plugin for GLPI.
  7. Archires is free software: you can redistribute it and/or modify
  8. it under the terms of the GNU Affero General Public License as published by
  9. the Free Software Foundation, either version 3 of the License, or
  10. (at your option) any later version.
  11. Archires is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. GNU Affero General Public License for more details.
  15. You should have received a copy of the GNU Affero General Public License
  16. along with Archires. If not, see <http://www.gnu.org/licenses/>.
  17. @package archires
  18. @author Nelly Mahu-Lasson, Xavier Caillaud
  19. @copyright Copyright (c) 2016-2021 Archires plugin team
  20. @license AGPL License 3.0 or (at your option) any later version
  21. http://www.gnu.org/licenses/agpl-3.0-standalone.html
  22. @link https://forge.glpi-project.org/projects/archires
  23. @since version 2.2
  24. --------------------------------------------------------------------------
  25. */
  26. if (!defined('GLPI_ROOT')) {
  27. die("Sorry. You can't access directly to this file");
  28. }
  29. class PluginArchiresArchires extends CommonDBTM {
  30. static $rightname = "plugin_archires";
  31. protected $usenotepad = true;
  32. static function getTypeName($nb=0) {
  33. return _n('Network Architecture', 'Network Architectures', $nb, 'archires');
  34. }
  35. static function showSummary() {
  36. $dbu = new DbUtils();
  37. echo "<div class='center'><table class='tab_cadre' cellpadding='5' width='50%'>";
  38. echo "<tr><th>".__('Summary')."</th></tr>";
  39. if ($dbu->countElementsInTable('glpi_plugin_archires_views',
  40. ['entities_id' => $_SESSION["glpiactive_entity"]]) > 0) {
  41. echo "<tr class='tab_bg_1'><td>";
  42. echo "<a href='view.php'>".PluginArchiresView::getTypeName(2)."</a>";
  43. echo "</td></tr>";
  44. echo "<tr class='tab_bg_1'><td>";
  45. echo "<a href='locationquery.php'>".
  46. sprintf(__('%1$s - %2$s'), self::getTypeName(1),
  47. PluginArchiresLocationQuery::getTypeName(1))."</a>";
  48. echo "</td></tr>";
  49. echo "<tr class='tab_bg_1'><td>";
  50. echo "<a href='networkequipmentquery.php'>".
  51. sprintf(__('%1$s - %2$s'), self::getTypeName(1),
  52. PluginArchiresNetworkEquipmentQuery::getTypeName(1))."</a>";
  53. echo "</td></tr>";
  54. $plugin = new Plugin();
  55. if ($plugin->isActivated("appliances")) {
  56. echo "<tr class='tab_bg_1'><td>";
  57. echo "<a href='appliancequery.php'>".
  58. sprintf(__('%1$s - %2$s'), self::getTypeName(1),
  59. PluginAppliancesAppliance::getTypeName(1))."</a>";
  60. echo "</td></tr>";
  61. }
  62. } else {
  63. echo "<tr class='tab_bg_1'><td>";
  64. echo "<a href='view.form.php?new=1'>".__('Add view', 'archires')."</a>";
  65. echo "</td></tr>";
  66. }
  67. echo "</table></div>";
  68. }
  69. function showAllItems($myname, $value_type=0, $value=0, $entity_restrict=-1) {
  70. global $DB,$CFG_GLPI;
  71. $types = ['Computer','NetworkEquipment','Peripheral','Phone','Printer'];
  72. $rand = mt_rand();
  73. foreach ($types as $label) {
  74. $item = new $label();
  75. $params[$label] = $item->getTypeName();
  76. }
  77. Dropdown::showFromArray('_itemtype', $params, ['width' => '80%',
  78. 'rand' => $rand,
  79. 'display_emptychoice' => true]);
  80. $field_id = Html::cleanId("dropdown__itemtype$rand");
  81. $params = ['itemtype' => '__VALUE__',
  82. 'value' => $value,
  83. 'myname' => $myname,
  84. 'entity' => $entity_restrict];
  85. echo "<span id='show_$myname$rand'>&nbsp;</span>\n";
  86. Ajax::updateItemOnSelectEvent($field_id, "show_$myname$rand",
  87. Plugin::getWebDir('archires')."/ajax/dropdownAllItems.php",
  88. $params);
  89. return $rand;
  90. }
  91. }