function showForNotification(Notification $notification)
{
global $DB;
if (!Notification::canView()) {
return false;
}
if ($notification->getField('itemtype') != '') {
$notifications_id = $notification->fields['id'];
$canedit = $notification->can($notifications_id, UPDATE);
if ($canedit) {
echo "<form name='notificationtargets_form' id='notificationtargets_form'\n method='post' action=' ";
echo Toolbox::getItemTypeFormURL(__CLASS__) . "'>";
echo "<input type='hidden' name='notifications_id' value='" . $notification->getField('id') . "'>";
echo "<input type='hidden' name='itemtype' value='" . $notification->getField('itemtype') . "'>";
}
echo "<table class='tab_cadre_fixe'>";
echo "<tr><th colspan='4'>" . _n('Recipient', 'Recipients', Session::getPluralNumber()) . "</th></tr>";
echo "<tr class='tab_bg_2'>";
$values = array();
foreach ($this->notification_targets as $key => $val) {
list($type, $id) = explode('_', $key);
$values[$key] = $this->notification_targets_labels[$type][$id];
}
$targets = getAllDatasFromTable('glpi_notificationtargets', 'notifications_id = ' . $notifications_id);
$actives = array();
if (count($targets)) {
foreach ($targets as $data) {
$actives[$data['type'] . '_' . $data['items_id']] = $data['type'] . '_' . $data['items_id'];
}
}
echo "<td>";
Dropdown::showFromArray('_targets', $values, array('values' => $actives, 'multiple' => true, 'readonly' => !$canedit));
echo "</td>";
if ($canedit) {
echo "<td width='20%'>";
echo "<input type='submit' class='submit' name='update' value=\"" . _x('button', 'Update') . "\">";
echo "</td>";
}
echo "</tr>";
echo "</table>";
}
if ($canedit) {
Html::closeForm();
}
}