<?php include(realpath(dirname(__FILE__)."/../")."/header.php"); ?>

    <!-- start page title -->
    <div class="row">
      <div class="col-12">
        <div class="page-title-box">
          <div class="page-title-right">
            <ol class="breadcrumb m-0">
              <li class="breadcrumb-item"><a href="<?=self::getUrl("Dashboard")?>">the-tool</a></li>
              <li class="breadcrumb-item active">Produkte</li>
            </ol>
          </div>
          <h4 class="page-title">Produkte</h4>
        </div>
      </div>
    </div>
    <!-- end page title -->

    <div class="row">
      <div class="col-lg-12">
        
        <div class="card">
          <div class="card-body mb-3">
            <div class="float-left">
              <h4 class="header-title">Liste aller Produkte</h4>
            </div>
            <div class="float-right">
              <a class="btn btn-primary mb-2" href="<?=self::getUrl("Product", "add")?>"><i class="fas fa-plus"></i> Neues Produkt anlegen</a>
            </div>
            
            <table class="table table-striped table-hover">
              <tr>
                <th>Netzgebiete</th>
                <th>Gruppe</th>
                <th>Name</th>
                <th>Technologie</th>
                <th>Kundentyp</th>
                <th>Verkaufspreis</th>
                <th>Verr. Periode</th>
                <th>SLA</th>
                <th>IVT ID</th>
                <th></th>
              </tr>
              <?php foreach($products as $product): ?>
              <tr>
                <td><?=(count($product->networks)) ? array_shift($product->networks)->name . ((count($product->networks) > 1) ? ", ..." : "") : ""?></td>
                <td><?=$product->productgroup->name?></td>
                <td><?=$product->name?></td>
                <td><?=$product->producttech->name?> (<?=$product->attributes[TT_ATTRIB_RTRTECHCODE_NAME]->value?>)</td>
                <td><?=__($product->producttech->customer_type)?></td>
                <td><?=$product->price?></td>
                <td><?=(12 / $product->billing_period)?>x Jährlich</td>
                <td><?=$product->sla->name?></td>
                <td><?=$product->ivt_id?></td>
                <td style="text-align: left; letter-spacing: 4px; font-size: 1.1em;">
                  <a href="<?=self::getUrl("Product", "edit", ["id" => $product->id])?>"><i class="far fa-edit"  title="Produkt Bearbeiten"></i></a>
                  <a href="<?=self::getUrl("Product", "delete", ["id" => $product->id])?>" class="text-danger" onclick="if(!confirm('Berechtigungen wirklich löschen?')) return false;" title="Produkt Löschen"><i class="fas fa-trash"></i></a>
                </td>
              </tr>
              <?php endforeach; ?>
            </table>
          </div>
        </div>
        
      </div>
    </div>

<?php include(realpath(dirname(__FILE__)."/../")."/footer.php"); ?>
