<?php

/**
 *
 * bareos-webui - Bareos Web-Frontend
 *
 * @link      https://github.com/bareos/bareos for the canonical source repository
 * @copyright Copyright (C) 2022-2026 Bareos GmbH & Co. KG (http://www.bareos.org/)
 * @license   GNU Affero General Public License (http://www.gnu.org/licenses/)
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program 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 Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

$title = _('Director');
$this->headTitle($title);
?>

<ul class="nav nav-tabs">
   <li><a href="<?php echo $this->url('director', array('action'=>'index')); ?>"><?php echo $this->translate('Status'); ?></a></li>
   <li><a href="<?php echo $this->url('director', array('action'=>'messages')); ?>"><?php echo $this->translate('Messages'); ?></a></li>
   <li class="active"><a href="<?php echo $this->url('director', array('action'=>'subscription')); ?>"><?php echo $this->translate('Subscription'); ?></a></li>
</ul>

<br />

<?php if($this->acl_alert) : echo $this->ACLAlert($this->invalid_commands); else : ?>

<div class="row">
<div class="col-md-8">

<p>
<a href="https://www.bareos.com/product/subscription/" target="_blank">Bareos subscription</a>
is required to access maintained
<a href="https://download.bareos.com/bareos/release/" target="_blank">Bareos subscription release packages</a>
offering hot fixes, new product functionalities and persistent security analysis.
It offers our most current enterprise grade code selected and quality assured for production use and fully maintained for default multi year Bareos lifecycle.
As well it is a prerequisite to get official
<a href="https://www.bareos.com/support/" target="_blank">Bareos support</a>.
</p>
<p>
The backup unit report below will show the estimated number of subscriptions.
Please request a quote by sending the downloadable backup unit report via e-mail to <a href="mailto:sales@bareos.com?subject=Request%20for%20Quote">sales@bareos.com</a>.
</p>

<div class="panel panel-default">

<div class="panel-heading">
   <h3 class="panel-title"><?php echo $this->translate("Backup Unit Report"); ?></h3>
</div>

<div>
</div>

<div class="panel-body">

<?php

   $panelcontent = "";

   if (!empty($this->error)) {
      $panelcontent .= '<div class="container-fluid">';
      $panelcontent .= '<div class="row">';
      $panelcontent .= '<div class="col-md-6">';
      $panelcontent .= '<div class="alert alert-danger">';
      $panelcontent .= $this->escapeHtml($this->error);
      $panelcontent .= '</div>';
      $panelcontent .= '</div>';
      $panelcontent .= '<div class="col-md-6"></div>';
      $panelcontent .= '</div>';
      $panelcontent .= '</div>';
   } elseif (!$this->directorOutput) {
      $panelcontent .= '<div class="container-fluid">';
      $panelcontent .= '<div class="row">';
      $panelcontent .= '<div class="col-md-6">';
      $panelcontent .= '<div class="alert alert-danger">';
      $panelcontent .= '<strong>'.$this->translate("Insufficient permission!").'</strong>';
      $panelcontent .= '<br><br>';
      $panelcontent .= $this->translate("For a Backup Unit Report, access to all job, client and fileset resources is required.");
      $panelcontent .= '</div>';
      $panelcontent .= '</div>';
      $panelcontent .= '<div class="col-md-6"></div>';
      $panelcontent .= '</div>';
      $panelcontent .= '</div>';
   } else  {
      $panelcontent .= '<pre>';
      $panelcontent .= '<code>';
      $panelcontent .= $this->escapeHtml($this->directorOutput);
      $panelcontent .= '</code>';
      $panelcontent .= '</pre>';
   }

   echo $panelcontent;

?>

</div>

</div>
</div>
</div>
<div class="row row-no-gutters">
<?php
    if ($this->directorOutput) {
        echo '<a class="btn btn-primary" href="' . $this->url('director', array('action' => 'backupunitreport')) . '">' . $this->translate('Download Backup Unit Report (JSON)') . '</a> ';
        echo '<a class="btn btn-default" href="' . $this->url('director', array('action' => 'backupunitreport'), array('query' => ['anonymize' => true ])) . '">' . $this->translate('Download Anonymized Backup Unit Report (JSON)') . '</a> ';
    }
?>
</div>
<?php endif; ?>
