<?php if(!defined('PARENT')) { exit; } ?>

    <div class="row">
      <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
        <ul class="nav nav-tabs">
          <li class="active"><a href="#one" data-toggle="tab"><i class="fa fa-pencil fa-fw"></i> <span class="hidden-xs"><?php echo $msw_adm_apages; ?></span></a></li>
          <li><a href="#two" data-toggle="tab"><i class="fa fa-cog fa-fw"></i> <span class="hidden-xs"><?php echo $msw_adm_apages3; ?></span></a></li>
        </ul>
      </div>
    </div>

    <form method="post" action="?p=<?php echo $cmd; ?>">
    <div class="row formarea">
      <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
        <div class="tab-content">
          <div class="tab-pane active in" id="one">
            <div class="panel panel-default">
              <div class="panel-body">
                <div class="form-group">
                  <label><?php echo $msw_adm_apages4; ?></label>
                  <input type="text" class="form-control" name="fm[name]" value="<?php echo (isset($ED->name) ? mswSH($ED->name) : ''); ?>">
                </div>
                <div class="form-group">
                  <label><?php echo $msw_adm_apages5; ?></label>
                  <textarea class="form-control" name="fm[info]" rows="5" cols="20"><?php echo (isset($ED->info) ? tags::filter($ED->info) : ''); ?></textarea>
                </div>
              </div>
            </div>
          </div>
          <div class="tab-pane fade" id="two">
            <div class="panel panel-default">
              <div class="panel-body">
                <div class="form-group">
                  <label><?php echo $msw_adm_apages12; ?></label>
                  <select name="fm[tmp]" class="form-control">
                    <option value="">- - - - - - - - -</option>
                    <?php
                    if (is_dir(PATH . 'content/admin-pages')) {
                      $files = Nette\Utils\Finder::findFiles(['*.php'])
                        ->in(PATH . 'content/admin-pages');
                      if (!empty($files)) {
                        foreach($files AS $file) {
                          ?>
                          <option value="<?php echo $file->getBasename(); ?>"<?php echo (isset($ED->tmp) && $ED->tmp == $file->getBasename() ? ' selected="selected"' : ''); ?>><?php echo $file->getBasename(); ?></option>
                          <?php
                        }
                      }
                    }
                    ?>
                  </select>
                </div>
                <div class="form-group">
                  <label><?php echo $msw_adm_apages8; ?></label>
                  <div class="radio">
                    <label><input type="radio" name="fm[en]" value="yes"<?php echo (isset($ED->en) && $ED->en == 'yes' ? ' checked="checked"' : (!isset($ED->en) ? ' checked="checked"' : '')); ?>> <?php echo $msw_common; ?></label>
                  </div>
                  <div class="radio">
                   <label><input type="radio" name="fm[en]" value="no"<?php echo (isset($ED->en) && $ED->en == 'no' ? ' checked="checked"' : ''); ?>> <?php echo $msw_common2; ?></label>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
    <div class="act-button">
      <button type="button" class="btn btn-success" onclick="mswAction('<?php echo  $cmd . (isset($ED->id) ? '-edit' : ''); ?>')"><i class="fa fa-<?php echo (isset($ED->id) ? 'check' : 'plus'); ?> fa-fw"></i> <span class="hidden-xs"><?php echo (isset($ED->id) ? $msw_common5 : $msw_adm_apages9); ?></span></button>
      <?php
      if (isset($ED->id)) {
      ?>
      <input type="hidden" name="fm[id]" value="<?php echo $ED->id; ?>">
      <button type="button" class="btn btn-default left_20" onclick="mswWin('<?php echo $cmd; ?>')"><i class="fa fa-arrow-left fa-fw"></i> <span class="hidden-xs"><?php echo $msw_common6; ?></span></button>
      <?php
      }
      ?>
    </div>
    </form>

    <?php
    $Q  = $DB->db_query("SELECT SQL_CALC_FOUND_ROWS `id`,`name`,`en` FROM `" . DB_PREFIX . "admin_pages` ORDER BY `ordr` LIMIT $limit," . DEF_PER_PAGE);
    $NR = $DB->db_foundrows($Q);
    ?>
    <div class="managepanel">
      <form method="post" action="?p=<?php echo $cmd; ?>">
      <div class="panel panel-default managearea">
        <div class="panel-heading">
          <i class="fa fa-list fa-fw cursorp" onclick="mswSC('.managearea .table td','delb')"></i> <?php echo $msw_adm_apages10; ?> (<?php echo mswNFM($NR); ?>)
        </div>
        <div class="panel-body">
          <div class="table-responsive">
           <table class="table table-striped table-hover">
             <tbody id="mswsort">
               <?php
               if ($NR > 0) {
                 while ($PG = $DB->db_object($Q)) {
                 ?>
                 <tr id="idr_<?php echo $PG->id; ?>">
                   <td><input type="hidden" name="fm[sort][]" value="<?php echo $PG->id; ?>"><input type="checkbox" name="fm[id][]" value="<?php echo $PG->id; ?>" onclick="mswSCG('.managearea .table td','delb')"></td>
                   <td class="cursorm"><b><?php echo mswSH($PG->name); ?></b></td>
                   <td><?php echo mswGST($PG->en); ?></td>
                   <td><a href="?p=<?php echo $cmd; ?>&amp;id=<?php echo $PG->id; ?>" title="<?php echo mswSH($msw_common4); ?>"><span class="fa-stack"><i class="fa fa-square fa-stack-2x mswicon"></i><i class="fa fa-pencil fa-stack-1x fa-inverse"></i></span></a></td>
                 </tr>
                 <?php
                 }
               } else {
                 include(PATH . 'content/no-data.php');
               }
               ?>
             </tbody>
           </table>
         </div>
         <?php
         // Pagination..
         if ($NR > DEF_PER_PAGE) {
           $PGS = new pages(array(
             'count' => $NR,
             'text' => $msw_pages,
             'page' => $page,
             'admin' => 'yes',
             'flag' => '',
             'limit' => 0,
             's' => $SETTINGS
           ));
           echo $PGS->display();
         }
         ?>
        </div>
      </div>
      <?php
      if ($NR > 0) {
      ?>
      <div class="act-button">
        <div class="text-center delselected" id="delb_span" style="display:none"><span>0</span> <?php echo $msw_public_11_global[0]; ?></div>
        <button type="button" class="btn btn-danger disabled" id="delb" onclick="if(jQuery(this).attr('class')!='btn btn-danger disabled'){mswAction('<?php echo $cmd; ?>-del','.managepanel','no','yes')}"><i class="fa fa-times fa-fw"></i> <span class="hidden-xs"><?php echo $msw_common3; ?></span></button>
      </div>
      <?php
      }
      ?>
      </form>
    </div>