<style type="text/css">
  .layout-tree-toggle {
    width: 18px;
    height: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    background: transparent;
    padding: 0;
    margin-right: 4px;
    color: #666;
    cursor: pointer;
  }

  .layout-tree-toggle:focus,
  .layout-tree-toggle:active,
  .layout-tree-toggle:focus-visible {
    outline: none;
    box-shadow: none;
  }

  li.sort-expanded > div .layout-tree-toggle i {
    transform: rotate(90deg);
  }

  #mass-edit-panel .product-item {
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
  }

  #mass-edit-panel .product-item label {
    cursor: pointer;
    font-weight: normal;
    margin-bottom: 0;
  }

  #mass-edit-panel .content_menu .icheckbox_minimal-blue {
    margin-top: 0;
  }

  #mass-edit-panel .icheckbox_minimal-blue {
    position: relative;
    overflow: hidden;
  }
</style>

<link rel="stylesheet" type="text/css" href="/libraries/grid/plugins/icheck/skins/minimal/minimal.css">
<link rel="stylesheet" type="text/css" href="/libraries/grid/plugins/icheck/skins/minimal/blue.css">

<div class="panel mb50 panel-primary" id="mass-edit-panel">
  <div class="panel-heading">
    <span class="panel-title">Masowa edycja produktów</span>
  </div>
  <div class="panel-body">
    <button class="btn btn-dark select-all">Zaznacz wszystkie</button>
    <button class="btn btn-default btn-outline-dark deselect-all">Odznacz wszystkie</button>
  </div>
  <div class="panel-body">
    <div class="form-group mb10">
      <label class="col-lg-3 control-label" for="discount_percent">Ustaw cenę promocyjną (minus X procent)</label>
      <div class="col-lg-9">
        <div class="bs-component">
          <div class="input-group">
            <input class="form-control" type="text" id="discount_percent" name="discount_percent">
            <span class="input-group-addon cursor" field-id="discount_percent">
              <i class="fa fa-save"></i>
            </span>
          </div>
        </div>
      </div>
    </div>
  </div>
  <div class="panel-body">
    <div class="row">
      <div class="col-lg-6">
        <?php if ( is_array( $this->products ) ): foreach ( $this->products as $key => $product ): ?>
          <div class="product-item">
            <input type="checkbox" class="g-checkbox" name="products[]" id="product<?= $key; ?>" value="<?= $key; ?>">
            <label for="product<?= $key; ?>"><?= htmlspecialchars( $product ); ?></label>
          </div>
        <?php endforeach; endif; ?>
      </div>
      <div class="col-lg-6">
        <div class="menu_sortable">
          <ol class="sortable" id="sortable">
            <?php if ( is_array( $this->categories ) ): foreach ( $this->categories as $category ): ?>
              <li id="list_<?= $category['id']; ?>" class="category_<?= $category['id']; ?>" category="<?= $category['id']; ?>">
                <div class="context_0 content content_menu">
                  <button type="button" class="disclose layout-tree-toggle" aria-expanded="false" title="Rozwin / zwin">
                    <i class="fa fa-caret-right"></i>
                  </button>
                  <?php if ( !$category['status'] ) echo '<i class="fa fa-ban fa-lg text-danger" title="Kategoria nieaktywna"></i>'; ?>
                  <input type="checkbox" class="g-checkbox" name="mass_categories[]" value="<?= $category['id']; ?>" />
                  <b><?= $category['languages'][$this->dlang]['title']; ?></b>
                </div>
                <?= \Shared\Tpl\Tpl::view( 'shop-product/subcategories-list', [
                  'categories' => ( new \Domain\Category\CategoryRepository( $GLOBALS['mdb'] ) )->subcategories( $category['id'] ),
                        'level' => ($this->level ?? 0) + 1,
                        'dlang' => $this->dlang,
                        'name' => 'mass_categories[]'
                      ] ); ?>
              </li>
            <?php endforeach; endif; ?>
          </ol>
        </div>
      </div>
    </div>
  </div>
</div>

<?= \Shared\Tpl\Tpl::view( 'shop-product/mass-edit-custom-script' ); ?>
