<?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"><a href="<?=self::getUrl("Network")?>">Netzgebiete</a></li>
              <li class="breadcrumb-item">POP</li>
              <li class="breadcrumb-item active"><?=($pop->id) ? "bearbeiten" : "Neu" ?></li>
            </ol>
          </div>
          <h4 class="page-title"><?=($pop->id) ? "POP bearbeiten" : "Neuer POP" ?></h4>
        </div>
      </div>
    </div>
    <!-- end page title -->
    
    <div class="row">
      <div class="col-lg-12">
        
        <div class="card">
          <div class="card-body">
            <h4 class="header-title mb-2"><?=($pop->id) ? "POP bearbeiten" : "Neuer POP"?></h4>
            
            <form class="form-horizontal" method="post" action="<?=self::getUrl("Pop", "save")?>">
              <div class="card">
                <div class="card-body">
                  
                  <input type="hidden" name="id" value="<?=$pop->id?>" />
                  
                  <div class="form-group row">
                    <label class="col-lg-2 col-form-label" for="network_id">Netzgebiet</label>
                    <div class="col-lg-10">
                      <select class="select2 form-control " name="network_id" id="owner_id">
                        <option></option>
                        <?php foreach($networks as $network): ?>
                          <option value="<?=$network->id?>" <?=($pop->network_id == $network->id) ? "selected='selected'" : ""?>><?=($network->name)?></option>
                        <?php endforeach; ?>
                      </select>
                    </div>
                  </div>
                  
                  <div class="form-group row">
                    <label class="col-lg-2 col-form-label" for="name">Name</label>
                    <div class="col-lg-10">
                      <input type="text" class="form-control" name="name" id="name" value="<?=$pop->name?>">
                    </div>
                  </div>
                  
                  <div class="form-group row">
                    <label class="col-lg-2 col-form-label" for="gps_lat">GPS Breite</label>
                    <div class="col-lg-10">
                      <input type="number" step="any" class="form-control" name="gps_lat" id="name" value="<?=$pop->gps_lat?>">
                    </div>
                  </div>
                  
                  <div class="form-group row">
                    <label class="col-lg-2 col-form-label" for="gps_long">GPS Länge</label>
                    <div class="col-lg-10">
                      <input type="number" step="any" class="form-control" name="gps_long" id="name" value="<?=$pop->gps_long?>">
                    </div>
                  </div>
                  
                  <div class="form-group row">
                    <label class="col-lg-2 col-form-label" for="location">Standortinfo</label>
                    <div class="col-lg-10">
                      <textarea id="note" class="form-control" name="location" rows="5"><?=$pop->location?></textarea>
                    </div>
                  </div>
                  
                </div>
              </div>
              
              <div class="card">
                <div class="card-body">
                  <h2 class="header-title mb-2">Access VLANs</h2>

                  <div class="form-group row">
                    <label class="col-lg-2 col-form-label" for="vlan_public">Public</label>
                    <div class="col-lg-10">
                      <input type="number" class="form-control" name="vlan_public" id="vlan_public" value="<?=$pop->vlan_public?>">
                    </div>
                  </div>
                  
                  <div class="form-group row">
                    <label class="col-lg-2 col-form-label" for="vlan_nat">NAT</label>
                    <div class="col-lg-10">
                      <input type="number" class="form-control" name="vlan_nat" id="vlan_nat" value="<?=$pop->vlan_nat?>">
                    </div>
                  </div>
                  
                  <div class="form-group row">
                    <label class="col-lg-2 col-form-label" for="vlan_ipv6">IPv6</label>
                    <div class="col-lg-10">
                      <input type="number" class="form-control" name="vlan_ipv6" id="vlan_ipv6" value="<?=$pop->vlan_ipv6?>">
                    </div>
                  </div>
                  
                </div>
              </div>
              
              <div class="card">
                <div class="card-body">
                  <div class="form-group row">
                    <label class="col-lg-2 col-form-label" for="note">Interne Notiz</label>
                    <div class="col-lg-10">
                      <textarea id="note" class="form-control" name="note" rows="5"><?=$pop->note?></textarea>
                    </div>
                  </div>
                </div>
              </div>
              
              <div class="form-group row">
                <label class="col-lg-2"></label>
                <div class="col-lg-10">
                  <button type="submit" class="btn btn-primary">Speichern</button>
                </div>
              </div>
              
              
              
            </form>
          </div>
        </div>
        
      </div>
    </div>

<script type="text/javascript">
  $("#parent_id").select2({
    allowClear: true,
    placeholder: ""
  });
  $("#addresstypes").select2();
  
  // disable mousewheel on a input number field when in focus
  $('form').on('focus', 'input[type=number]', function (e) {
    $(this).on('wheel.disableScroll', function (e) {
      e.preventDefault()
    })
  });
  $('form').on('blur', 'input[type=number]', function (e) {
    $(this).off('wheel.disableScroll')
  });
</script>

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