<?php 
/**
 * The browse view file of product module of ZDOO.
 *
 * @copyright   Copyright 2009-2018 青岛易软天创网络科技有限公司(QingDao Nature Easy Soft Network Technology Co,LTD, www.cnezsoft.com)
 * @license     ZPL (http://zpl.pub/page/zplv12.html)
 * @author      Tingting Dai <daitingting@xirangit.com>
 * @package     product 
 * @version     $Id$
 * @link        http://www.zdoo.com
 */
?>
<?php include $app->getModuleRoot() . 'common/view/header.html.php';?>
<?php include '../../common/view/sortable.html.php';?>
<?php include '../../common/view/treeview.html.php';?>
<?php js::set('mode', $mode);?>
<?php js::set('status', $status);?>
<?php js::set('category', $category);?>
<?php js::set('recPerPage', $pager->recPerPage);?>
<?php js::set('pageID', $pager->pageID);?>
<?php $canSort = commonModel::hasPriv('product', 'sort');?>
<li id='bysearchTab'><?php echo html::a('#', "<i class='icon-search icon'></i>" . $lang->search->common)?></li>
<div id='menuActions'>
  <?php commonModel::printLink('product', 'create', '', '<i class="icon-plus"></i> ' . $lang->product->create, "class='btn btn-primary' data-toggle='modal' data-width='500'");?>
</div>
<div class='main-row'>
  <div class='side-col'>
    <div class='panel panel-block'>
      <div class='panel-heading'>
        <strong><?php echo $lang->product->category;?></strong>
      </div>
      <div class='panel-body'>
        <div id='treeMenuBox'><?php echo $treeMenu;?></div>
        <?php commonModel::printLink('tree', 'browse', 'type=product&startModule=&root=&from=product', $lang->product->setCategory, "class='btn btn-primary'");?>
      </div>
    </div>
  </div>
  <div class='main-col'>
    <div class='panel main-table' data-ride='table'>
      <table class='table has-sort-head'>
        <thead>
          <tr class='text-center'>
            <?php $vars = "mode={$mode}&status={$status}&category={$category}&orderBy=%s&recTotal={$pager->recTotal}&recPerPage={$pager->recPerPage}&pageID={$pager->pageID}";?>
            <th class='w-60px'><?php commonModel::printOrderLink('id', $orderBy, $vars, $lang->product->id);?></th>
            <th><?php commonModel::printOrderLink('name', $orderBy, $vars, $lang->product->name);?></th>
            <th class='w-160px'><?php commonModel::printOrderLink('code', $orderBy, $vars, $lang->product->code);?></th>
            <th class='w-140px'><?php commonModel::printOrderLink('subject', $orderBy, $vars, $lang->product->subject);?></th>
            <th class='w-150px'> <?php commonModel::printOrderLink('category', $orderBy, $vars, $lang->product->category);?></th>
            <th class='w-160px'><?php commonModel::printOrderLink('createdDate', $orderBy, $vars, $lang->product->createdDate);?></th>
            <th class='w-60px'><?php commonModel::printOrderLink('type', $orderBy, $vars, $lang->product->type);?></th>
            <th class='w-80px'><?php commonModel::printOrderLink('status', $orderBy, $vars, $lang->product->status);?></th>
            <th class='w-<?php echo $lang->product->actionWidth;?>px'><?php echo $lang->actions;?></th>
          </tr>
        </thead>
        <tbody class="<?php if($canSort) echo 'sortable';?>" id='productList'>
          <?php foreach($products as $product):?>
          <tr class='text-center' data-id='<?php echo $product->id;?>' data-url="<?php echo $this->createLink('product', 'view', "productID={$product->id}");?>">
            <td class="text-center <?php if($canSort) echo 'sort-handler';?>">
              <?php if($canSort) echo "<i class='icon icon-move text-muted'></i>";?>
              <?php printf('%03d', $product->id);?>
            </td>
            <td class='text-left c-name'><?php echo $product->name;?></td>
            <td><?php echo $product->code;?></td>
            <td><?php echo zget($subjects, $product->subject, '');?></td>
            <td><?php echo zget($categories, $product->category, '');?></td>
            <td><?php echo formatTime($product->createdDate, DT_DATETIME1);?></td>
            <td><?php echo zget($lang->product->typeList, $product->type);?></td>
            <td><?php echo $lang->product->statusList[$product->status];?></td>
            <td class='actions'>
              <?php
              commonModel::printLink('product', 'edit', "productID=$product->id", $lang->edit, "data-toggle='modal' data-width='500'");
              commonModel::printLink('product', 'delete', "productID=$product->id", $lang->delete, "class='reloadDeleter'");
              ?>
            </td>
          </tr>
          <?php endforeach;?>
        </tbody>
      </table>
      <div class='table-footer'><?php $pager->show();?></div>
    </div>
  </div>
</div>
<?php include '../../common/view/footer.html.php';?>
