PageRenderTime 90ms CodeModel.GetById 13ms RepoModel.GetById 1ms app.codeStats 0ms

/www/include/monitoring/external_cmd/popup/massive_downtime.php

https://gitlab.com/florianocomercial/centreon
PHP | 167 lines | 87 code | 28 blank | 52 comment | 13 complexity | f8617e7d75ef75623c4717a5e345e2e4 MD5 | raw file
  1. <?php
  2. /*
  3. * Copyright 2005-2015 Centreon
  4. * Centreon is developped by : Julien Mathis and Romain Le Merlus under
  5. * GPL Licence 2.0.
  6. *
  7. * This program is free software; you can redistribute it and/or modify it under
  8. * the terms of the GNU General Public License as published by the Free Software
  9. * Foundation ; either version 2 of the License.
  10. *
  11. * This program is distributed in the hope that it will be useful, but WITHOUT ANY
  12. * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
  13. * PARTICULAR PURPOSE. See the GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License along with
  16. * this program; if not, see <http://www.gnu.org/licenses>.
  17. *
  18. * Linking this program statically or dynamically with other modules is making a
  19. * combined work based on this program. Thus, the terms and conditions of the GNU
  20. * General Public License cover the whole combination.
  21. *
  22. * As a special exception, the copyright holders of this program give Centreon
  23. * permission to link this program with independent modules to produce an executable,
  24. * regardless of the license terms of these independent modules, and to copy and
  25. * distribute the resulting executable under terms of Centreon choice, provided that
  26. * Centreon also meet, for each linked independent module, the terms and conditions
  27. * of the license of that module. An independent module is a module which is not
  28. * derived from this program. If you modify this program, you may extend this
  29. * exception to your version of the program, but you are not obliged to do so. If you
  30. * do not wish to do so, delete this exception statement from your version.
  31. *
  32. * For more information : contact@centreon.com
  33. *
  34. * SVN : $URL
  35. * SVN : $Id$
  36. *
  37. */
  38. if (!isset ($oreon))
  39. exit ();
  40. $select = array();
  41. if (isset($_GET['select'])) {
  42. foreach ($_GET['select'] as $key => $value) {
  43. if ($cmd == '75') {
  44. $tmp = preg_split("/\;/", $key);
  45. $select[] = $tmp[0];
  46. }
  47. else {
  48. $select[] = $key;
  49. }
  50. }
  51. }
  52. $path = _CENTREON_PATH_."/www/include/monitoring/external_cmd/popup/";
  53. /*
  54. * Init GMT
  55. */
  56. $centreonGMT = new CentreonGMT($pearDB);
  57. $centreonGMT->getMyGMTFromSession(session_id(), $pearDB);
  58. /*
  59. * Smarty template Init
  60. */
  61. $tpl = new Smarty();
  62. $tpl = initSmartyTplForPopup($path, $tpl, './templates/', _CENTREON_PATH_);
  63. /*
  64. * Pear library
  65. */
  66. require_once "HTML/QuickForm.php";
  67. require_once 'HTML/QuickForm/Renderer/ArraySmarty.php';
  68. $form = new HTML_QuickForm('select_form', 'GET', 'main.php');
  69. $form->addElement('header', 'title', _("Set downtimes"));
  70. $tpl->assign('authorlabel', _("Alias"));
  71. $tpl->assign('authoralias', $oreon->user->get_alias());
  72. $form->addElement('textarea', 'comment', _("Comment"), array("rows"=>"5", "cols"=>"70", "id"=>"popupComment"));
  73. $form->setDefaults(array("comment" => sprintf(_("Downtime set by %s"), $oreon->user->alias)));
  74. $form->addElement('text', 'start', _('Start Time'), array('id'=>'start', 'size'=>10, 'class'=>'datepicker'));
  75. $form->addElement('text', 'end', _('End Time'), array('id'=>'end', 'size'=>10, 'class'=>'datepicker'));
  76. $form->addElement('text', 'start_time', '', array('id'=>'start_time', 'size' => 5, 'class' => 'timepicker'));
  77. $form->addElement('text', 'end_time', '', array('id'=>'end_time', 'size' => 5, 'class' => 'timepicker'));
  78. $form->setDefaults(
  79. array(
  80. "start" => $centreonGMT->getDate("m/d/Y" , time() + 120),
  81. "end" => $centreonGMT->getDate("m/d/Y", time() + 7320),
  82. "start_time" => $centreonGMT->getDate("G:i" , time() + 120),
  83. "end_time" => $centreonGMT->getDate("G:i" , time() + 7320)
  84. )
  85. );
  86. // uncomment this section : the user can choose to set a downtime based on the host time or the centreon user time.
  87. /*
  88. $host_or_centreon_time[] = HTML_QuickForm::createElement('radio', 'host_or_centreon_time', null, _("Centreon Time"), '0');
  89. $host_or_centreon_time[] = HTML_QuickForm::createElement('radio', 'host_or_centreon_time', null, _("Host Time"), '1');
  90. $form->addGroup($host_or_centreon_time, 'host_or_centreon_time', _("Select Host or Centreon Time"), '&nbsp;');
  91. $form->setDefaults(array('host_or_centreon_time' => '0'));
  92. */
  93. $form->addElement('text', 'duration', _('Duration'), array('id'=>'duration', 'width'=>'30', 'disabled'=>'true'));
  94. $defaultDuration = 3600;
  95. if (isset($oreon->optGen['monitoring_dwt_duration']) && $oreon->optGen['monitoring_dwt_duration']) {
  96. $defaultDuration = $oreon->optGen['monitoring_dwt_duration'];
  97. }
  98. $form->setDefaults(array('duration' => $defaultDuration));
  99. $scaleChoices = array("s" => _("Seconds"),
  100. "m" => _("Minutes"),
  101. "h" => _("Hours"),
  102. "d" => _("Days")
  103. );
  104. $form->addElement('select', 'duration_scale', _("Scale of time"), $scaleChoices, array('id'=>'duration_scale'));
  105. $defaultScale = 's';
  106. if (isset($oreon->optGen['monitoring_dwt_duration_scale']) && $oreon->optGen['monitoring_dwt_duration_scale']) {
  107. $defaultScale = $oreon->optGen['monitoring_dwt_duration_scale'];
  108. }
  109. $form->setDefaults(array('duration_scale' => $defaultScale));
  110. $chckbox[] = $form->addElement('checkbox', 'fixed', _("Fixed"), "", array("id"=>"fixed"));
  111. $chckbox[0]->setChecked(true);
  112. $chckbox2[] = $form->addElement('checkbox', 'downtimehostservice', _("Set downtimes on services attached to hosts"), "", array("id"=>"downtimehostservice"));
  113. $chckbox2[0]->setChecked(true);
  114. $form->addElement('hidden', 'author', $oreon->user->get_alias(), array("id"=>"author"));
  115. $form->addRule('comment', _("Comment is required"), 'required', '', 'client');
  116. $form->setJsWarnings(_("Invalid information entered"), _("Please correct these fields"));
  117. $form->addElement('button', 'submit', _("Set downtime"), array("onClick" => "send_the_command();", "class" => "btc bt_info"));
  118. $form->addElement('reset', 'reset', _("Reset"), array("class" => "btc bt_default"));
  119. $renderer = new HTML_QuickForm_Renderer_ArraySmarty($tpl);
  120. $renderer->setRequiredTemplate('{$label}&nbsp;<font color="red" size="1">*</font>');
  121. $renderer->setErrorTemplate('<font color="red">{$error}</font><br />{$html}');
  122. $form->accept($renderer);
  123. $tpl->assign('form', $renderer->toArray());
  124. $defaultFixed = "";
  125. if (isset($oreon->optGen['monitoring_dwt_fixed']) && $oreon->optGen['monitoring_dwt_fixed']) {
  126. $defaultFixed = "checked";
  127. }
  128. $tpl->assign('defaultFixed', $defaultFixed);
  129. $defaultSetDwtOnSvc = "";
  130. if (isset($oreon->optGen['monitoring_dwt_svc']) && $oreon->optGen['monitoring_dwt_svc']) {
  131. $defaultSetDwtOnSvc = "checked";
  132. }
  133. $tpl->assign('defaultSetDwtOnSvc', $defaultSetDwtOnSvc);
  134. $tpl->assign('o', $o);
  135. $tpl->assign('p', $p);
  136. $tpl->assign('cmd', $cmd);
  137. $tpl->assign('select', $select);
  138. $tpl->display("massive_downtime.ihtml");
  139. ?>