Commit 7396f154 authored by Johan Cwiklinski's avatar Johan Cwiklinski

Limit to PDU only when adding a rackable power unit

parent fb82cbdd
......@@ -71,6 +71,9 @@ if (isset($_GET['id'])) {
'orientation' => $_GET['orientation'],
'position' => $_GET['position']
];
if (isset($_GET['_onlypdu'])) {
$params['_onlypdu'] = $_GET['_onlypdu'];
}
}
$ajax = isset($_REQUEST['ajax']) ? true : false;
......
......@@ -555,18 +555,30 @@ JAVASCRIPT;
echo "<td><label for='dropdown_itemtype$rand'>".__('Item type')."</label></td>";
echo "<td>";
$types = array_combine($CFG_GLPI['rackable_types'], $CFG_GLPI['rackable_types']);
foreach ($types as $type => &$text) {
$text = $type::getTypeName(1);
if (isset($options['_onlypdu']) && $options['_onlypdu']) {
$this->fields['itemtype'] = 'PDU';
echo Html::hidden(
'itemtype',
[
'id' => "itemtype_$rand",
'value' => 'PDU'
]
);
echo PDU::getTypeName(1);
} else {
$types = array_combine($CFG_GLPI['rackable_types'], $CFG_GLPI['rackable_types']);
foreach ($types as $type => &$text) {
$text = $type::getTypeName(1);
}
Dropdown::showFromArray(
'itemtype',
$types, [
'display_emptychoice' => true,
'value' => $this->fields["itemtype"],
'rand' => $rand
]
);
}
Dropdown::showFromArray(
'itemtype',
$types, [
'display_emptychoice' => true,
'value' => $this->fields["itemtype"],
'rand' => $rand
]
);
//get all used items
$used = $used_reserved = [];
......
......@@ -505,7 +505,7 @@ JAVASCRIPT;
]);
$pra_url = PDU_Rack::getFormURL()."?racks_id=$racks_id&ajax=true";
$ira_url = Item_Rack::getFormURL()."?orientation=0&position=1&racks_id=$racks_id&ajax=true";
$ira_url = Item_Rack::getFormURL()."?_onlypdu=true&orientation=0&position=1&racks_id=$racks_id&ajax=true";
$js = <<<JAVASCRIPT
var showAddPduSubForm = function() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment