Copyright (C) 2003-2011 by the Racks Development Team. https://forge.indepnet.net/projects/racks ------------------------------------------------------------------------- LICENSE This file is part of Racks. Racks is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. Racks is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Racks. If not, see <http://www.gnu.org/licenses/>. -------------------------------------------------------------------------- */ include '../../../inc/includes.php'; $PluginRacksRack_Item = new PluginRacksRack_Item(); if (isset($_POST["update"])) { if ($PluginRacksRack_Item->canCreate()) { $PluginRacksRack_Item->update($_POST); } Html::back(); }
function UpdateItemSpecification($input) { global $DB; $modelfield = getForeignKeyFieldForTable(getTableForItemType($input['itemtype'])); $itemtype = substr($input['itemtype'], 0, -5); $table = getTableForItemType($itemtype); //selection de tous les materiels lies au modele $query_spec = "SELECT *\n FROM `" . $this->getTable() . "`\n WHERE `id` = '" . $input["id"] . "' "; $result_spec = $DB->query($query_spec); while ($device = $DB->fetch_array($result_spec)) { $query_device = "SELECT `" . $table . "`.`id` FROM `" . $table . "`, `" . $this->getTable() . "` " . "WHERE `" . $this->getTable() . "`.`model_id` = `" . $table . "`.`" . $modelfield . "`\n AND `" . $this->getTable() . "`.`id` = '" . $input["id"] . "'"; $result_device = $DB->query($query_device); while ($model = $DB->fetch_array($result_device)) { //detail de chaque materiel dans la baie $query_content = "SELECT * FROM `glpi_plugin_racks_racks_items` " . "WHERE `itemtype` = '" . $input['itemtype'] . "'\n AND `items_id` = '" . $model['id'] . "' "; $result_content = $DB->query($query_content); while ($content = $DB->fetch_array($result_content)) { if ($device["amps"] == $content["amps"] && $device["flow_rate"] == $content["flow_rate"] && $device["dissipation"] == $content["dissipation"] && $device["weight"] == $content["weight"]) { //si les params du materiel sont les memes que le modele alors update $PluginRacksRack_Item = new PluginRacksRack_Item(); $values["id"] = $content['id']; $values["amps"] = $input["amps"]; $values["flow_rate"] = $input["flow_rate"]; $values["dissipation"] = $input["dissipation"]; $values["weight"] = $input["weight"]; $PluginRacksRack_Item->update($values); } } } } $this->update($input); }