Open LordBat opened 6 years ago
solution:
////delete line 243 and add:
echo ""; echo "
if($item->getTypeName()=="Ordinateur")
$type::dropdown(array('value' => $item->fields["computertypes_id"]));
else if ($item->getTypeName()=="Moniteur")
$type::dropdown(array('value' => $item->fields["monitortypes_id"]));
else if ($item->getTypeName()=="Imprimante")
$type::dropdown(array('value' => $item->fields["printertypes_id"]));
else if ($item->getTypeName()=="Périphérique")
$type::dropdown(array('value' => $item->fields["peripheraltypes_id"]));
else if ($item->getTypeName()=="Téléphone")
$type::dropdown(array('value' => $item->fields["phonetypes_id"]));
else if ($item->getTypeName()=="Matériel réseau")
$type::dropdown(array('value' => $item->fields["networkequipmenttypes_id"]));
else if ($item->getTypeName()=="Scannersdocument")
$type::dropdown(array('value' => $item->fields["plugin_genericobject_scannersdocumenttypes_id"]));
else if ($item->getTypeName()=="Scannerscheque")
$type::dropdown(array('value' => $item->fields["plugin_genericobject_scannerschequetypes_id"]));
}
else { echo "
////delete line 271 and add:
echo ""; $model = $itemtype.'Model'; if (TableExists(getTableForItemType($model))) {
echo "<td>";
echo __('Model');
echo "</td>";
echo "<td>";
if($item->getTypeName()=="Ordinateur")
$model::dropdown(array('value' => $item->fields["computermodels_id"]));
else if ($item->getTypeName()=="Moniteur")
$model::dropdown(array('value' => $item->fields["monitormodels_id"]));
else if ($item->getTypeName()=="Imprimante")
$model::dropdown(array('value' => $item->fields["printermodels_id"]));
else if ($item->getTypeName()=="Périphérique")
$model::dropdown(array('value' => $item->fields["peripheralmodels_id"]));
else if ($item->getTypeName()=="Téléphone")
$model::dropdown(array('value' => $item->fields["phonemodels_id"]));
else if ($item->getTypeName()=="Matériel réseau")
$model::dropdown(array('value' => $item->fields["networkequipmentmodels_id"]));
else if ($item->getTypeName()=="Scannersdocument")
$model::dropdown(array('value' => $item->fields["plugin_genericobject_scannersdocumentmodels_id"]));
else if ($item->getTypeName()=="Scannerscheque")
$model::dropdown(array('value' => $item->fields["plugin_genericobject_scannerschequemodels_id"]));
echo "</td>";
} else {
echo "<td colspan='2'></td>";
}
echo "</tr>";
I suggest another solution:
if ($DB->tableExists(getTableForItemType($model))) {
$fk = getForeignKeyFieldForTable(getTableForItemType($model));
...
$model::dropdown(array('value' => $item->fields["computermodels_id"]));
It is more flexible, it works with General Object plugins and doesn't need any names which depend from system language.
You can check my pull proposal for whole code.
Hi, is posible to get the model and type field based on the type of inventory?
For example i search a peripheral item and i get
on Type:
PHP Notice: Undefined index: computertypes_id in /var/www/html/glpi/plugins/physicalinv/inc/inventory.class.php at line 243
on Model:
PHP Notice: Undefined index: computermodels_id in /var/www/html/glpi/plugins/physicalinv/inc/inventory.class.php at line 271
Regards!