Menu="OtherSettings"
Type="xmenu"
Title="UPS Settings"
Icon="icon-ups"
Tag="battery-3"
---
<?PHP
/* Copyright 2005-2022, Lime Technology
 * Copyright 2012-2022, Bergware International.
 * Copyright 2015, Dan Landon.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License version 2,
 * as published by the Free Software Foundation.
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 */
?>

<?
$sName = "dynamix.apcupsd";
$cfg = parse_plugin_cfg($sName);
?>

<style>
table.ups thead tr th{width:16.6%;padding-left:10px}
table.ups tbody tr td{padding-left:10px;font-weight:bold}
tr.ups{height:3rem;line-height:3rem}
i.ups{margin-right:8px}
</style>
<script>
function toggleCustomCable(form) {
  var readonly = form.UPSCABLE.value != 'custom';
  form.CUSTOMUPSCABLE.readOnly = readonly;
  if (readonly) form.CUSTOMUPSCABLE.value = '';
}
function toggleDevice(form) {
  var readonly = form.UPSTYPE.value == 'usb';
  form.DEVICE.readOnly = readonly;
  if (readonly) form.DEVICE.value = '';
}
$(function() {
  showStatus('pid','apcupsd');
  toggleCustomCable(document.apcupsd_settings);
  toggleDevice(document.apcupsd_settings);
});
</script>
<table class="tablesorter shift ups" <?if (!file_exists("/var/run/apcupsd.pid")):?>style="display:none"<?endif;?>>
<thead><tr><th><i class='ups fa fa-shield'></i>_(UPS Model)_</th><th><i class='ups fa fa-plug'></i>_(UPS Status)_</th><th><i class='ups fa fa-battery'></i>_(Battery Charge)_</th><th><i class='ups fa fa-clock-o'></i>_(Runtime Left)_</th><th><i class='ups fa fa-bolt'></i>_(Nominal Power)_</th><th><i class='ups fa fa-bars'></i>_(UPS Load)_</th><th><i class='ups fa fa-ellipsis-h'></i>_(Output Voltage)_</th></tr></thead>
<tbody id="ups_summary"><tr class="ups"><td colspan="7">&nbsp;</td></tr></tbody>
</table>

<span style="float:right;margin-right:10px"><a href="http://apcupsd.org/manual/manual.html" target="_blank" title="_(APC UPS Daemon user manual)_"><i class="fa fa-file-text-o"></i> <u>_(Online Manual)_</u></a></span>
<form markdown="1" name="apcupsd_settings" method="POST" action="/update.php" target="progressFrame">
<input type="hidden" name="#file" value="<?=$sName?>/<?=$sName?>.cfg">
<input type="hidden" name="#include" value="/plugins/<?=$sName?>/include/update.apcupsd.php">

_(Start APC UPS daemon)_:
: <select name="SERVICE">
  <?=mk_option($cfg['SERVICE'], "disable", _("No"))?>
  <?=mk_option($cfg['SERVICE'], "enable", _("Yes"))?>
  </select>

:apc_ups_daemon_help:

_(UPS cable)_:
: <select name="UPSCABLE" onChange="toggleCustomCable(this.form)">
  <?=mk_option($cfg['UPSCABLE'], "usb", _("USB"))?>
  <?=mk_option($cfg['UPSCABLE'], "simple", _("Simple"))?>
  <?=mk_option($cfg['UPSCABLE'], "smart", _("Smart"))?>
  <?=mk_option($cfg['UPSCABLE'], "ether", _("Ether"))?>
  <?=mk_option($cfg['UPSCABLE'], "custom", _("Custom"))?>
  </select>

:apc_ups_cable_help:

_(Custom UPS cable)_:
: <input type="text" name="CUSTOMUPSCABLE" class="narrow" maxlength="40" value="<?=htmlspecialchars($cfg['CUSTOMUPSCABLE']);?>">

:apc_ups_custom_cable_help:

_(UPS type)_:
: <select name="UPSTYPE" onChange="toggleDevice(this.form)">
  <?=mk_option($cfg['UPSTYPE'], "usb", _("USB"))?>
  <?=mk_option($cfg['UPSTYPE'], "apcsmart", _("APCsmart"))?>
  <?=mk_option($cfg['UPSTYPE'], "net", _("Net"))?>
  <?=mk_option($cfg['UPSTYPE'], "snmp", _("SNMP"))?>
  <?=mk_option($cfg['UPSTYPE'], "dumb", _("Dumb"))?>
  <?=mk_option($cfg['UPSTYPE'], "pcnet", _("PCnet"))?>
  <?=mk_option($cfg['UPSTYPE'], "modbus", _("ModBus"))?>
  </select>

:apc_ups_type_help:

_(Device)_:
: <input type="text" name="DEVICE" maxlength="200" class="narrow" value="<?=htmlspecialchars($cfg['DEVICE']);?>">

:apc_ups_device_help:

_(Battery level to initiate shutdown)_ (%):
: <input type="text" name="BATTERYLEVEL" class="narrow" maxlength="3" value="<?=htmlspecialchars($cfg['BATTERYLEVEL']);?>">

:apc_battery_level_help:

_(Runtime left to initiate shutdown)_ (_(minutes)_):
: <input type="text" name="MINUTES" class="narrow" maxlength="3" value="<?=htmlspecialchars($cfg['MINUTES']);?>">

:apc_runtime_left_help:

_(Time on battery before shutdown)_ (_(seconds)_):
: <input type="text" name="TIMEOUT" class="narrow" maxlength="4" value="<?=htmlspecialchars($cfg['TIMEOUT']);?>">

:apc_battery_time_help:
<div></div>
:apc_note_help:

_(Turn off UPS after shutdown)_:
: <select name="KILLUPS">
  <?=mk_option($cfg['KILLUPS'], "no", _("No"))?>
  <?=mk_option($cfg['KILLUPS'], "yes", _("Yes"))?>
  </select>

:apc_killups_help:

<input type="submit" name="#default" value="_(Default)_">
: <input type="submit" name="#apply" value="_(Apply)_" disabled><input type="button" value="_(Done)_" onclick="done()">
</form>
