<?php if(!defined('PARENT')) { exit; }
$SQL = '';
if (isset($_GET['q']) && $_GET['q']) {
  $SQL = "WHERE `name` LIKE '%" . $DB->db_escape($_GET['q']) . "%' OR `info` LIKE '%" . $DB->db_escape($_GET['q']) . "%'";
}
$Q  = $DB->db_query("SELECT SQL_CALC_FOUND_ROWS * FROM `" . DB_PREFIX . "products` $SQL ORDER BY `name` LIMIT $limit," . PER_PAGE);
$NR = $DB->db_foundrows($Q);
?>

    <div class="row">
      <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 text-right">
        <div class="btn-group">
          <button type="button" class="btn btn-sm btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
            <i class="fa fa-chevron-down fa-fw"></i>
          </button>
          <ul class="dropdown-menu dropdown-menu-right">
            <li><a href="?p=product-add"><i class="fa fa-plus fa-fw"></i> <?php echo $msw_adm_manage2; ?></a></li>
            <?php
            if ($NR > 0) {
            ?>
            <li<?php echo (isset($_GET['q']) ? ' class="active"' : ''); ?>><a href="#" onclick="mswSB('.searchpanel','show');return false"><i class="fa fa-search fa-fw"></i> <?php echo $msw_adm_manage3; ?></a></li>
            <?php
            }
            ?>
          </ul>
        </div>
      </div>
    </div>

    <div class="managepanel searchpanel" style="margin-top:10px<?php echo (!isset($_GET['q']) ? ';display:none' : ''); ?>">
      <form method="get" action="index.php">
      <div class="panel panel-default managearea">
        <input type="hidden" name="p" value="<?php echo $cmd; ?>">
        <div class="panel-heading">
          <i class="fa fa-search fa-fw"></i> <?php echo $msw_adm_manage3; ?>
        </div>
        <div class="panel-body">
          <div class="form-group">
            <input type="text" class="form-control" name="q" value="<?php echo (isset($_GET['q']) ? mswSH($_GET['q']) : ''); ?>" placeholder="<?php echo mswSH($msw_adm_manage5); ?>">
          </div>
          <div class="text-center" style="padding-bottom:20px">
            <button class="btn btn-success" type="submit"><i class="fa fa-check fa-fw"></i><span class="hidden-xs"> <?php echo $msw_adm_manage6; ?></span></button>
            <button class="btn btn-default" type="button" onclick="mswWin('<?php echo $cmd; ?>')"><i class="fa fa-times fa-fw"></i><span class="hidden-xs">  <?php echo $msw_adm_manage4; ?></span></button>
          </div>
        </div>
      </div>
      </form>
    </div>

    <div class="managepanel" style="margin-top:10px">
      <form method="post" action="?p=<?php echo $cmd; ?>">
      <div class="panel panel-default managearea">
        <div class="panel-heading">
          <?php echo $msw_adm_manage; ?> (<?php echo mswNFM($NR); ?>)
        </div>
        <div class="panel-body">
          <div class="table-responsive">
           <table class="table table-striped table-hover" id="sortTable">
             <thead>
               <tr>
                 <th class="text-center"><input type="checkbox" name="c" value="yes" onclick="mswSC('.managearea .table td','delb')"></th>
                 <th data-sort="int"><?php echo $msw_adm_manage7; ?></th>
                 <th data-sort="string"><?php echo $msw_adm_manage8; ?></th>
                 <th data-sort="string"><?php echo $msw_adm_manage9; ?></th>
                 <th>&nbsp;</th>
               </tr>
             </thead>
             <tbody>
               <?php
               if ($NR > 0) {
                 while ($PR = $DB->db_object($Q)) {
                 ?>
                 <tr id="idr_<?php echo $PR->id; ?>">
                   <td><input type="checkbox" name="fm[id][]" value="<?php echo $PR->id; ?>" onclick="mswSCG('.managearea .table td','delb')"></td>
                   <td data-sort-value="<?php echo $PR->id; ?>"><?php echo mswSH($PR->id); ?></td>
                   <td><b><?php echo mswSH($PR->name); ?></b>
                   <span class="smalldata">
                     <?php echo mswSH($PR->url); ?>
                   </span>
                   </td>
                   <td data-sort-value="<?php echo $PR->en; ?>"><?php echo mswGST($PR->en, array($msw_common15, $msw_common16)); ?></td>
                   <td>
                     <a href="?p=product-manage&amp;html=<?php echo $PR->id; ?>" title="<?php echo mswSH($msw_adm_manage12); ?>"><i class="fa fa-html5 fa-2x fa-fw"></i></a>
                     <a href="?p=product-add&amp;id=<?php echo $PR->id; ?>" title="<?php echo mswSH($msw_common4); ?>"><i class="fa fa-pencil-square fa-2x fa-fw"></i></a>
                   </td>
                 </tr>
                 <?php
                 }
               } else {
                 $colspan = 5;
                 include(PATH . 'content/no-data.php');
               }
               ?>
             </tbody>
           </table>
         </div>
         <?php
         // Pagination..
         if ($NR > PER_PAGE) {
           $PGS = new pages(array(
             'count' => $NR,
             'text' => $msw_pages,
             'page' => $page,
             'admin' => 'yes',
             'flag' => '',
             'limit' => PER_PAGE,
             '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>