static function showFormAlerts($target)
 {
     $self = new self();
     $self->getFromDB(1);
     echo "<form action='{$target}' method='post'>";
     echo "<input type='hidden' name='id' value='1'>";
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr class='tab_bg_2'>";
     echo "<td>" . __('Reminders frequency', 'additionalalerts') . " " . PluginAdditionalalertsInfocomAlert::getTypeName(2) . "</td><td>";
     Alert::dropdownYesNo(array('name' => "use_infocom_alert", 'value' => $self->fields["use_infocom_alert"]));
     echo "</td></tr>";
     echo "<tr class='tab_bg_2'>";
     echo "<td >" . __('Reminders frequency', 'additionalalerts') . " " . __('New imported computers from OCS-NG', 'additionalalerts') . "</td><td>";
     Alert::dropdownYesNo(array('name' => "use_newocs_alert", 'value' => $self->fields["use_newocs_alert"]));
     echo "</td></tr>";
     echo "<tr class='tab_bg_2'><td >" . __('OCS-NG Synchronization alerts', 'additionalalerts') . "</td><td>";
     Alert::dropdownIntegerNever('delay_ocs', $self->fields["delay_ocs"], array('max' => 99));
     echo "&nbsp;" . _n('Day', 'Days', 2) . "</td></tr>";
     echo "</td></tr>";
     echo "<tr class='tab_bg_2'><td class='center' colspan='2'>";
     echo "<input type='hidden' name='id' value='1'>";
     echo "<input class='submit' type='submit' name='update' value='" . _sx('button', 'Save') . "'>";
     echo "</td></tr>";
     echo "</table>";
     Html::closeForm();
 }
 function getTags()
 {
     $tags = array('notinfocom.name' => __('Name'), 'notinfocom.urlname' => __('URL') . " " . __('Name'), 'notinfocom.computertype' => __('Type'), 'notinfocom.operatingsystem' => __('Operating system'), 'notinfocom.state' => __('Status'), 'notinfocom.location' => __('Location'), 'notinfocom.user' => __('User'), 'notinfocom.urluser' => __('URL') . " " . __('User'), 'notinfocom.group' => __('Group'), 'notinfocom.urlgroup' => __('URL') . " " . __('Group'), 'notinfocom.contact' => __('Alternate username'));
     foreach ($tags as $tag => $label) {
         $this->addTagToList(array('tag' => $tag, 'label' => $label, 'value' => true));
     }
     $this->addTagToList(array('tag' => 'additionalalerts', 'label' => PluginAdditionalalertsInfocomAlert::getTypeName(2), 'value' => false, 'foreach' => true, 'events' => array('notinfocom')));
     asort($this->tag_descriptions);
 }
示例#3
0
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.

Additionalalerts 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 additionalalerts. If not, see <http://www.gnu.org/licenses/>.
--------------------------------------------------------------------------
*/
include '../../../inc/includes.php';
$type = new PluginAdditionalalertsNotificationType();
$infocom = new PluginAdditionalalertsInfocomAlert();
if (isset($_POST["add"])) {
    if ($infocom->canCreate()) {
        $newID = $infocom->add($_POST);
    }
    Html::back();
} else {
    if (isset($_POST["update"])) {
        if ($infocom->canCreate()) {
            $infocom->update($_POST);
        }
        Html::back();
    } else {
        if (isset($_POST["add_type"])) {
            if ($infocom->canCreate()) {
                $newID = $type->add($_POST);
示例#4
0
 static function showNotificationOptions(Entity $entity)
 {
     $con_spotted = false;
     $ID = $entity->getField('id');
     if (!$entity->can($ID, 'r')) {
         return false;
     }
     // Notification right applied
     $canedit = Session::haveRight('notification', 'w') && Session::haveAccessToEntity($ID);
     // Get data
     $entitynotification = new PluginAdditionalalertsInfocomAlert();
     if (!$entitynotification->getFromDBbyEntity($ID)) {
         $entitynotification->getEmpty();
     }
     if ($canedit) {
         echo "<form method='post' name=form action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "'>";
     }
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr><th colspan='2'>" . __('Alarms options') . "</th></tr>";
     echo "<tr class='tab_bg_1'><td>" . PluginAdditionalalertsInfocomAlert::getTypeName(2) . "</td><td>";
     $default_value = $entitynotification->fields['use_infocom_alert'];
     Alert::dropdownYesNo(array('name' => "use_infocom_alert", 'value' => $default_value, 'inherit_global' => 1));
     echo "</td></tr>";
     if ($canedit) {
         echo "<tr>";
         echo "<td class='tab_bg_2 center' colspan='4'>";
         echo "<input type='hidden' name='entities_id' value='{$ID}'>";
         if ($entitynotification->fields["id"]) {
             echo "<input type='hidden' name='id' value=\"" . $entitynotification->fields["id"] . "\">";
             echo "<input type='submit' name='update' value=\"" . _sx('button', 'Save') . "\" class='submit' >";
         } else {
             echo "<input type='submit' name='add' value=\"" . _sx('button', 'Save') . "\" class='submit' >";
         }
         echo "</td></tr>";
         echo "</table>";
         Html::closeForm();
     } else {
         echo "</table>";
     }
 }
 static function displayAlerts()
 {
     global $DB;
     $CronTask = new CronTask();
     $config = new PluginAdditionalalertsConfig();
     $config->getFromDB('1');
     $infocom = new PluginAdditionalalertsInfocomAlert();
     $infocom->getFromDBbyEntity($_SESSION["glpiactive_entity"]);
     if (isset($infocom->fields["use_infocom_alert"]) && $infocom->fields["use_infocom_alert"] > 0) {
         $use_infocom_alert = $infocom->fields["use_infocom_alert"];
     } else {
         $use_infocom_alert = $config->fields["use_infocom_alert"];
     }
     $ocsalert = new PluginAdditionalalertsOcsAlert();
     $ocsalert->getFromDBbyEntity($_SESSION["glpiactive_entity"]);
     if (isset($ocsalert->fields["use_newocs_alert"]) && $ocsalert->fields["use_newocs_alert"] > 0) {
         $use_newocs_alert = $ocsalert->fields["use_newocs_alert"];
     } else {
         $use_newocs_alert = $config->fields["use_newocs_alert"];
     }
     if (isset($ocsalert->fields["delay_ocs"]) && $ocsalert->fields["delay_ocs"] > 0) {
         $delay_ocs = $ocsalert->fields["delay_ocs"];
     } else {
         $delay_ocs = $config->fields["delay_ocs"];
     }
     $additionalalerts_ocs = 0;
     if ($CronTask->getFromDBbyName("PluginAdditionalalertsOcsAlert", "AdditionalalertsOcs")) {
         if ($CronTask->fields["state"] != CronTask::STATE_DISABLE && $delay_ocs > 0) {
             $additionalalerts_ocs = 1;
         }
     }
     $additionalalerts_new_ocs = 0;
     if ($CronTask->getFromDBbyName("PluginAdditionalalertsOcsAlert", "AdditionalalertsNewOcs")) {
         if ($CronTask->fields["state"] != CronTask::STATE_DISABLE && $use_newocs_alert > 0) {
             $additionalalerts_new_ocs = 1;
         }
     }
     $additionalalerts_not_infocom = 0;
     if ($CronTask->getFromDBbyName("PluginAdditionalalertsInfocomAlert", "AdditionalalertsNotInfocom")) {
         if ($CronTask->fields["state"] != CronTask::STATE_DISABLE && $use_infocom_alert > 0) {
             $additionalalerts_not_infocom = 1;
         }
     }
     if ($additionalalerts_ocs == 0 && $additionalalerts_new_ocs == 0 && $additionalalerts_not_infocom == 0) {
         echo "<div align='center'><b>" . __('No used alerts', 'additionalalerts') . "</b></div>";
     }
     if ($additionalalerts_not_infocom != 0) {
         if (Session::haveRight("infocom", "w")) {
             $query = PluginAdditionalalertsInfocomAlert::query($_SESSION["glpiactive_entity"]);
             $result = $DB->query($query);
             if ($DB->numrows($result) > 0) {
                 if (Session::isMultiEntitiesMode()) {
                     $nbcol = 7;
                 } else {
                     $nbcol = 6;
                 }
                 echo "<div align='center'><table class='tab_cadre' cellspacing='2' cellpadding='3'><tr><th colspan='{$nbcol}'>";
                 echo PluginAdditionalalertsInfocomAlert::getTypeName(2) . "</th></tr>";
                 echo "<tr><th>" . __('Name') . "</th>";
                 if (Session::isMultiEntitiesMode()) {
                     echo "<th>" . __('Entity') . "</th>";
                 }
                 echo "<th>" . __('Type') . "</th>";
                 echo "<th>" . __('Operating system') . "</th>";
                 echo "<th>" . __('Status') . "</th>";
                 echo "<th>" . __('Location') . "</th>";
                 echo "<th>" . __('User') . " / " . __('Group') . " / " . __('Alternate username') . "</th></tr>";
                 while ($data = $DB->fetch_array($result)) {
                     echo PluginAdditionalalertsInfocomAlert::displayBody($data);
                 }
                 echo "</table></div>";
             } else {
                 echo "<br><div align='center'><b>" . __('No computers with no buy date', 'additionalalerts') . "</b></div>";
             }
             echo "<br>";
         }
     }
     if ($additionalalerts_new_ocs != 0) {
         $plugin = new Plugin();
         if ($plugin->isActivated("ocsinventoryng") && plugin_ocsinventoryng_haveRight("ocsng", "w")) {
             foreach ($DB->request("glpi_plugin_ocsinventoryng_ocsservers", "`is_active` = 1") as $config) {
                 $query = PluginAdditionalalertsOcsAlert::queryNew($config, $_SESSION["glpiactive_entity"]);
                 $result = $DB->query($query);
                 if ($DB->numrows($result) > 0) {
                     if (Session::isMultiEntitiesMode()) {
                         $nbcol = 9;
                     } else {
                         $nbcol = 8;
                     }
                     echo "<div align='center'><table class='tab_cadre' cellspacing='2' cellpadding='3'><tr><th colspan='{$nbcol}'>";
                     echo __('New imported computers from OCS-NG', 'additionalalerts') . "</th></tr>";
                     echo "<tr><th>" . __('Name') . "</th>";
                     if (Session::isMultiEntitiesMode()) {
                         echo "<th>" . __('Entity') . "</th>";
                     }
                     echo "<th>" . __('Operating system') . "</th>";
                     echo "<th>" . __('Status') . "</th>";
                     echo "<th>" . __('Location') . "</th>";
                     echo "<th>" . __('User') . " / " . __('Group') . " / " . __('Alternate username') . "</th>";
                     echo "<th>" . __('Last OCSNG inventory date', 'additionalalerts') . "</th>";
                     echo "<th>" . __('Import date in GLPI', 'additionalalerts') . "</th>";
                     echo "<th>" . __('OCSNG server', 'additionalalerts') . "</th></tr>";
                     while ($data = $DB->fetch_array($result)) {
                         echo PluginAdditionalalertsOcsAlert::displayBody($data);
                     }
                     echo "</table></div>";
                 } else {
                     echo "<br><div align='center'><b>" . __('No new imported computer from OCS-NG', 'additionalalerts') . "</b></div>";
                 }
             }
             echo "<br>";
         }
     }
     if ($additionalalerts_ocs != 0) {
         $plugin = new Plugin();
         if ($plugin->isActivated("ocsinventoryng") && plugin_ocsinventoryng_haveRight("ocsng", "w")) {
             foreach ($DB->request("glpi_plugin_ocsinventoryng_ocsservers", "`is_active` = 1") as $config) {
                 $query = PluginAdditionalalertsOcsAlert::query($delay_ocs, $config, $_SESSION["glpiactive_entity"]);
                 $result = $DB->query($query);
                 if ($DB->numrows($result) > 0) {
                     if (Session::isMultiEntitiesMode()) {
                         $nbcol = 9;
                     } else {
                         $nbcol = 8;
                     }
                     echo "<div align='center'><table class='tab_cadre' cellspacing='2' cellpadding='3'><tr><th colspan='{$nbcol}'>";
                     echo __('Computers not synchronized with OCS-NG since more', 'additionalalerts') . " " . $delay_ocs . " " . _n('Day', 'Days', 2) . "</th></tr>";
                     echo "<tr><th>" . __('Name') . "</th>";
                     if (Session::isMultiEntitiesMode()) {
                         echo "<th>" . __('Entity') . "</th>";
                     }
                     echo "<th>" . __('Operating system') . "</th>";
                     echo "<th>" . __('Status') . "</th>";
                     echo "<th>" . __('Location') . "</th>";
                     echo "<th>" . __('User') . " / " . __('Group') . " / " . __('Alternate username') . "</th>";
                     echo "<th>" . __('Last OCSNG inventory date', 'additionalalerts') . "</th>";
                     echo "<th>" . __('Import date in GLPI', 'additionalalerts') . "</th>";
                     echo "<th>" . __('OCSNG server', 'additionalalerts') . "</th></tr>";
                     while ($data = $DB->fetch_array($result)) {
                         echo PluginAdditionalalertsOcsAlert::displayBody($data);
                     }
                     echo "</table></div>";
                 } else {
                     echo "<br><div align='center'><b>" . __('No computer not synchronized since more', 'additionalalerts') . " " . $delay_ocs . " " . _n('Day', 'Days', 2) . "</b></div>";
                 }
             }
             echo "<br>";
         }
     }
 }