Entity::showNotificationOptions PHP Method

showNotificationOptions() static public method

static public showNotificationOptions ( Entity $entity )
$entity Entity Entity object
    static function showNotificationOptions(Entity $entity)
    {
        $ID = $entity->getField('id');
        if (!$entity->can($ID, READ) || !Notification::canView()) {
            return false;
        }
        // Notification right applied
        $canedit = Notification::canUpdate() && Session::haveAccessToEntity($ID);
        echo "<div class='spaced'>";
        if ($canedit) {
            echo "<form method='post' name=form action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "'>";
        }
        echo "<table class='tab_cadre_fixe'>";
        echo "<tr><th colspan='4'>" . __('Notification options') . "</th></tr>";
        echo "<tr class='tab_bg_1'>";
        echo "<td>" . __('Administrator email') . "</td>";
        echo "<td>";
        Html::autocompletionTextField($entity, "admin_email");
        echo "</td>";
        echo "<td>" . __('Administrator name') . "</td><td>";
        Html::autocompletionTextField($entity, "admin_email_name");
        echo "</td></tr>";
        echo "<tr class='tab_bg_1'>";
        echo "<td>" . __('Administrator reply-to email (if needed)') . "</td>";
        echo "<td>";
        Html::autocompletionTextField($entity, "admin_reply");
        echo "</td>";
        echo "<td>" . __('Response address (if needed)') . "</td><td>";
        Html::autocompletionTextField($entity, "admin_reply_name");
        echo "</td></tr>";
        echo "<tr class='tab_bg_1'>";
        echo "<td>" . __('Prefix for notifications') . "</td>";
        echo "<td>";
        Html::autocompletionTextField($entity, "notification_subject_tag");
        echo "</td>";
        echo "<td>" . __('Delay to send email notifications') . "</td>";
        echo "<td>";
        $toadd = array();
        if ($ID > 0) {
            $toadd = array(self::CONFIG_PARENT => __('Inheritance of the parent entity'));
        }
        Dropdown::showNumber('delay_send_emails', array('value' => $entity->fields["delay_send_emails"], 'min' => 0, 'max' => 100, 'unit' => 'minute', 'toadd' => $toadd));
        if ($entity->fields['delay_send_emails'] == self::CONFIG_PARENT) {
            $tid = self::getUsedConfig('delay_send_emails', $entity->getField('entities_id'));
            echo "<font class='green'><br>";
            echo $entity->getValueToDisplay('delay_send_emails', $tid, array('html' => true));
            echo "</font>";
        }
        echo "</td></tr>";
        echo "<tr class='tab_bg_1'>";
        echo "<td>" . __('Enable notifications by default') . "</td>";
        echo "<td>";
        Alert::dropdownYesNo(array('name' => "is_notif_enable_default", 'value' => $entity->getField('is_notif_enable_default'), 'inherit_parent' => $ID > 0 ? 1 : 0));
        if ($entity->fields['is_notif_enable_default'] == self::CONFIG_PARENT) {
            $tid = self::getUsedConfig('is_notif_enable_default', $entity->getField('entities_id'));
            echo "<font class='green'><br>";
            echo self::getSpecificValueToDisplay('is_notif_enable_default', $tid);
            echo "</font>";
        }
        echo "</td>";
        echo "<td colspan='2'>&nbsp;</td>";
        echo "</tr>";
        echo "<tr class='tab_bg_1'>";
        echo "<td class='middle right'>" . __('Email signature') . "</td>";
        echo "<td colspan='3'>";
        echo "<textarea cols='60' rows='5' name='mailing_signature'>" . $entity->fields["mailing_signature"] . "</textarea>";
        echo "</td></tr>";
        echo "</table>";
        echo "<table class='tab_cadre_fixe tab_spaced'>";
        echo "<tr><th colspan='4'>" . __('Alarms options') . "</th></tr>";
        echo "<tr class='tab_bg_1'>";
        echo "<th colspan='2' rowspan='2'>";
        echo _n('Cartridge', 'Cartridges', Session::getPluralNumber());
        echo "</th>";
        echo "<td>" . __('Reminders frequency for alarms on cartridges') . "</td><td>";
        $default_value = $entity->fields['cartridges_alert_repeat'];
        Alert::dropdown(array('name' => 'cartridges_alert_repeat', 'value' => $default_value, 'inherit_parent' => $ID > 0 ? 1 : 0));
        if ($entity->fields['cartridges_alert_repeat'] == self::CONFIG_PARENT) {
            $tid = self::getUsedConfig('cartridges_alert_repeat', $entity->getField('entities_id'));
            echo "<font class='green'><br>";
            echo self::getSpecificValueToDisplay('cartridges_alert_repeat', $tid);
            echo "</font>";
        }
        echo "</td></tr>";
        echo "<tr class='tab_bg_1'><td>" . __('Default threshold for cartridges count') . "</td><td>";
        if ($ID > 0) {
            $toadd = array(self::CONFIG_PARENT => __('Inheritance of the parent entity'), self::CONFIG_NEVER => __('Never'));
        } else {
            $toadd = array(self::CONFIG_NEVER => __('Never'));
        }
        Dropdown::showNumber('default_cartridges_alarm_threshold', array('value' => $entity->fields["default_cartridges_alarm_threshold"], 'min' => 0, 'max' => 100, 'step' => 1, 'toadd' => $toadd));
        if ($entity->fields['default_cartridges_alarm_threshold'] == self::CONFIG_PARENT) {
            $tid = self::getUsedConfig('default_cartridges_alarm_threshold', $entity->getField('entities_id'));
            echo "<font class='green'><br>";
            echo self::getSpecificValueToDisplay('default_cartridges_alarm_threshold', $tid);
            echo "</font>";
        }
        echo "</td></tr>";
        echo "<tr class='tab_bg_1'>";
        echo "<th colspan='2' rowspan='2'>";
        echo _n('Consumable', 'Consumables', Session::getPluralNumber());
        echo "</th>";
        echo "<td>" . __('Reminders frequency for alarms on consumables') . "</td><td>";
        $default_value = $entity->fields['consumables_alert_repeat'];
        Alert::dropdown(array('name' => 'consumables_alert_repeat', 'value' => $default_value, 'inherit_parent' => $ID > 0 ? 1 : 0));
        if ($entity->fields['consumables_alert_repeat'] == self::CONFIG_PARENT) {
            $tid = self::getUsedConfig('consumables_alert_repeat', $entity->getField('entities_id'));
            echo "<font class='green'><br>";
            echo self::getSpecificValueToDisplay('consumables_alert_repeat', $tid);
            echo "</font>";
        }
        echo "</td></tr>";
        echo "<tr class='tab_bg_1'><td>" . __('Default threshold for consumables count') . "</td><td>";
        if ($ID > 0) {
            $toadd = array(self::CONFIG_PARENT => __('Inheritance of the parent entity'), self::CONFIG_NEVER => __('Never'));
        } else {
            $toadd = array(self::CONFIG_NEVER => __('Never'));
        }
        Dropdown::showNumber('default_consumables_alarm_threshold', array('value' => $entity->fields["default_consumables_alarm_threshold"], 'min' => 0, 'max' => 100, 'step' => 1, 'toadd' => $toadd));
        if ($entity->fields['default_consumables_alarm_threshold'] == self::CONFIG_PARENT) {
            $tid = self::getUsedConfig('default_consumables_alarm_threshold', $entity->getField('entities_id'));
            echo "<font class='green'><br>";
            echo self::getSpecificValueToDisplay('default_consumables_alarm_threshold', $tid);
            echo "</font>";
        }
        echo "</td></tr>";
        echo "<tr class='tab_bg_1'>";
        echo "<th colspan='2' rowspan='3'>";
        echo _n('Contract', 'Contracts', Session::getPluralNumber());
        echo "</th>";
        echo "<td>" . __('Alarms on contracts') . "</td><td>";
        $default_value = $entity->fields['use_contracts_alert'];
        Alert::dropdownYesNo(array('name' => "use_contracts_alert", 'value' => $default_value, 'inherit_parent' => $ID > 0 ? 1 : 0));
        if ($entity->fields['use_contracts_alert'] == self::CONFIG_PARENT) {
            $tid = self::getUsedConfig('use_contracts_alert', $entity->getField('entities_id'));
            echo "<font class='green'><br>";
            echo self::getSpecificValueToDisplay('use_contracts_alert', $tid);
            echo "</font>";
        }
        echo "</td></tr>";
        echo "<tr class='tab_bg_1'><td>" . __('Default value') . "</td><td>";
        Contract::dropdownAlert(array('name' => "default_contract_alert", 'value' => $entity->fields["default_contract_alert"], 'inherit_parent' => $ID > 0 ? 1 : 0));
        if ($entity->fields['default_contract_alert'] == self::CONFIG_PARENT) {
            $tid = self::getUsedConfig('default_contract_alert', $entity->getField('entities_id'));
            echo "<font class='green'><br>";
            echo self::getSpecificValueToDisplay('default_contract_alert', $tid);
            echo "</font>";
        }
        echo "</td></tr>";
        echo "<tr class='tab_bg_1'><td>" . __('Send contract alarms before') . "</td><td>";
        Alert::dropdownIntegerNever('send_contracts_alert_before_delay', $entity->fields['send_contracts_alert_before_delay'], array('max' => 99, 'inherit_parent' => $ID > 0 ? 1 : 0, 'unit' => 'day', 'never_string' => __('No')));
        if ($entity->fields['send_contracts_alert_before_delay'] == self::CONFIG_PARENT) {
            $tid = self::getUsedConfig('send_contracts_alert_before_delay', $entity->getField('entities_id'));
            echo "<font class='green'><br>";
            echo self::getSpecificValueToDisplay('send_contracts_alert_before_delay', $tid);
            echo "</font>";
        }
        echo "</td></tr>";
        echo "<tr class='tab_bg_1'>";
        echo "<th colspan='2' rowspan='3'>";
        _e('Financial and administrative information');
        echo "</th>";
        echo "<td>" . __('Alarms on financial and administrative information') . "</td><td>";
        $default_value = $entity->fields['use_infocoms_alert'];
        Alert::dropdownYesNo(array('name' => "use_infocoms_alert", 'value' => $default_value, 'inherit_parent' => $ID > 0 ? 1 : 0));
        if ($entity->fields['use_infocoms_alert'] == self::CONFIG_PARENT) {
            $tid = self::getUsedConfig('use_infocoms_alert', $entity->getField('entities_id'));
            echo "<font class='green'><br>";
            echo self::getSpecificValueToDisplay('use_infocoms_alert', $tid);
            echo "</font>";
        }
        echo "</td></tr>";
        echo "<tr class='tab_bg_1'><td>" . __('Default value') . "</td><td>";
        Infocom::dropdownAlert(array('name' => 'default_infocom_alert', 'value' => $entity->fields["default_infocom_alert"], 'inherit_parent' => $ID > 0 ? 1 : 0));
        if ($entity->fields['default_infocom_alert'] == self::CONFIG_PARENT) {
            $tid = self::getUsedConfig('default_infocom_alert', $entity->getField('entities_id'));
            echo "<font class='green'><br>";
            echo self::getSpecificValueToDisplay('default_infocom_alert', $tid);
            echo "</font>";
        }
        echo "</td></tr>";
        echo "<tr class='tab_bg_1'>";
        echo "<td>" . __('Send financial and administrative information alarms before') . "</td><td>";
        Alert::dropdownIntegerNever('send_infocoms_alert_before_delay', $entity->fields['send_infocoms_alert_before_delay'], array('max' => 99, 'inherit_parent' => $ID > 0 ? 1 : 0, 'unit' => 'day', 'never_string' => __('No')));
        if ($entity->fields['send_infocoms_alert_before_delay'] == self::CONFIG_PARENT) {
            $tid = self::getUsedConfig('send_infocoms_alert_before_delay', $entity->getField('entities_id'));
            echo "<font class='green'><br>";
            echo self::getSpecificValueToDisplay('send_infocoms_alert_before_delay', $tid);
            echo "</font>";
        }
        echo "</td></tr>";
        echo "<tr class='tab_bg_1'>";
        echo "<th colspan='2' rowspan='2'>";
        echo _n('License', 'Licenses', Session::getPluralNumber());
        echo "</th>";
        echo "<td>" . __('Alarms on expired licenses') . "</td><td>";
        $default_value = $entity->fields['use_licenses_alert'];
        Alert::dropdownYesNo(array('name' => "use_licenses_alert", 'value' => $default_value, 'inherit_parent' => $ID > 0 ? 1 : 0));
        if ($entity->fields['use_licenses_alert'] == self::CONFIG_PARENT) {
            $tid = self::getUsedConfig('use_licenses_alert', $entity->getField('entities_id'));
            echo "<font class='green'><br>";
            echo self::getSpecificValueToDisplay('use_licenses_alert', $tid);
            echo "</font>";
        }
        echo "</td></tr>";
        echo "<tr class='tab_bg_1'><td>" . __('Send license alarms before') . "</td><td>";
        Alert::dropdownIntegerNever('send_licenses_alert_before_delay', $entity->fields['send_licenses_alert_before_delay'], array('max' => 99, 'inherit_parent' => $ID > 0 ? 1 : 0, 'unit' => 'day', 'never_string' => __('No')));
        if ($entity->fields['send_licenses_alert_before_delay'] == self::CONFIG_PARENT) {
            $tid = self::getUsedConfig('send_licenses_alert_before_delay', $entity->getField('entities_id'));
            echo "<font class='green'><br>";
            echo self::getSpecificValueToDisplay('send_licenses_alert_before_delay', $tid);
            echo "</font>";
        }
        echo "</td></tr>";
        echo "<tr class='tab_bg_1'>";
        echo "<th colspan='2' rowspan='1'>";
        echo _n('Reservation', 'Reservations', Session::getPluralNumber());
        echo "</th>";
        echo "<td>" . __('Alerts on reservations') . "</td><td>";
        Alert::dropdownIntegerNever('use_reservations_alert', $entity->fields['use_reservations_alert'], array('max' => 99, 'inherit_parent' => $ID > 0 ? 1 : 0, 'unit' => 'hour'));
        if ($entity->fields['use_reservations_alert'] == self::CONFIG_PARENT) {
            $tid = self::getUsedConfig('use_reservations_alert', $entity->getField('entities_id'));
            echo "<font class='green'><br>";
            echo self::getSpecificValueToDisplay('use_reservations_alert', $tid);
            echo "</font>";
        }
        echo "</td></tr>";
        echo "<tr class='tab_bg_1'>";
        echo "<th colspan='2' rowspan='1'>";
        echo _n('Ticket', 'Tickets', Session::getPluralNumber());
        echo "</th>";
        echo "<td >" . __('Alerts on tickets which are not solved since') . "</td><td>";
        Alert::dropdownIntegerNever('notclosed_delay', $entity->fields["notclosed_delay"], array('max' => 99, 'inherit_parent' => $ID > 0 ? 1 : 0, 'unit' => 'day'));
        if ($entity->fields['notclosed_delay'] == self::CONFIG_PARENT) {
            $tid = self::getUsedConfig('notclosed_delay', $entity->getField('entities_id'));
            echo "<font class='green'><br>";
            echo self::getSpecificValueToDisplay('notclosed_delay', $tid);
            echo "</font>";
        }
        echo "</td></tr>";
        if ($canedit) {
            echo "<tr>";
            echo "<td class='tab_bg_2 center' colspan='4'>";
            echo "<input type='hidden' name='id' value='" . $entity->fields["id"] . "'>";
            echo "<input type='submit' name='update' value=\"" . _sx('button', 'Save') . "\" class='submit'>";
            echo "</td></tr>";
            echo "</table>";
            Html::closeForm();
        } else {
            echo "</table>";
        }
        echo "</div>";
    }