<div class="content-wrapper">

    <section class="content-header">
        <?php echo $this->partial('layout/breadcrumb'); ?>

        <h1 class="pull-right">
            <a href="<?php echo $this->url('goods', ['action'=> 'importGoods']);?>" class="btn btn-primary btn-sm"><i class="fa fa-bars" aria-hidden="true"></i> <?php echo $this->translate('批量导入商品'); ?></a>
            <a href="<?php echo $this->url('goods', ['action'=> 'add']);?>" class="btn btn-primary btn-sm"><i class="fa fa-plus"></i> <?php echo $this->translate('添加商品'); ?></a>
            <?php echo $this->HelpUrl('goodsList'); ?>
        </h1>

    </section>

    <section class="content">
        <?php echo $this->partial('layout/messages'); ?>

        <div class="row">
            <div class="col-xs-12">
                <div class="box erp-box">
                    <div class="box-body table-responsive no-padding">
                            <table class="table table-hover">
                                <thead>
                                <tr class="erp-bg-thead">
                                    <th width="6%">ID</th>
                                    <th width="20%"><?php echo $this->translate('商品名称'); ?></th>
                                    <th width="10%"><?php echo $this->translate('商品编号'); ?></th>
                                    <th width="12%"><?php echo $this->translate('商品规格'); ?></th>
                                    <th width="10%"><?php echo $this->translate('采购价格'); ?></th>
                                    <th width="7%"><?php echo $this->translate('建议售价'); ?></th>
                                    <th width="10%"><?php echo $this->translate('商品分类'); ?></th>
                                    <th width="8%"><?php echo $this->translate('商品品牌'); ?></th>
                                    <th width="6%"><?php echo $this->translate('库存'); ?></th>
                                    <th width="12%"><?php echo $this->translate('操作'); ?></th>
                                </tr>
                                <?php
                                $sForm = $this->searchForm;
                                $sForm->prepare();
                                ?>
                                <?php echo $this->form()->openTag($sForm); ?>
                                <tr>
                                    <td>
                                        <p>
                                            <?php echo $this->formElement($sForm->get('start_id')); ?>
                                        </p>
                                        <div>
                                            <?php echo $this->formElement($sForm->get('end_id')); ?>
                                        </div>
                                        <?php echo $this->formElementErrors($sForm->get('start_id'), ['class'=>'error-message']);?>
                                        <?php echo $this->formElementErrors($sForm->get('end_id'), ['class'=>'error-message']);?>
                                    </td>
                                    <td>
                                        <?php echo $this->formElement($sForm->get('goods_name')); ?>
                                        <?php echo $this->formElementErrors($sForm->get('goods_name'), ['class'=>'error-message']);?>
                                    </td>
                                    <td>
                                        <?php echo $this->formElement($sForm->get('goods_number')); ?>
                                        <?php echo $this->formElementErrors($sForm->get('goods_number'), ['class'=>'error-message']);?>
                                    </td>
                                    <td>
                                        <?php echo $this->formElement($sForm->get('goods_spec')); ?>
                                        <?php echo $this->formElementErrors($sForm->get('goods_spec'), ['class'=>'error-message']);?>
                                    </td>
                                    <td>
                                        <p>
                                            <?php echo $this->formElement($sForm->get('start_price')); ?>
                                        </p>
                                        <div>
                                            <?php echo $this->formElement($sForm->get('end_price')); ?>
                                        </div>
                                        <?php echo $this->formElementErrors($sForm->get('start_price'), ['class'=>'error-message']);?>
                                        <?php echo $this->formElementErrors($sForm->get('end_price'), ['class'=>'error-message']);?>
                                    </td>
                                    <td>
                                        <p>
                                            <?php echo $this->formElement($sForm->get('start_sales_price')); ?>
                                        </p>
                                        <div>
                                            <?php echo $this->formElement($sForm->get('end_sales_price')); ?>
                                        </div>
                                        <?php echo $this->formElementErrors($sForm->get('start_sales_price'), ['class'=>'error-message']);?>
                                        <?php echo $this->formElementErrors($sForm->get('end_sales_price'), ['class'=>'error-message']);?>
                                    </td>
                                    <td>
                                        <?php echo $this->formElement($sForm->get('goods_category_id')); ?>
                                        <?php echo $this->formElementErrors($sForm->get('goods_category_id'), ['class'=>'error-message']);?>
                                    </td>
                                    <td>
                                        <?php echo $this->formElement($sForm->get('brand_id')); ?>
                                        <?php echo $this->formElementErrors($sForm->get('brand_id'), ['class'=>'error-message']);?>
                                    </td>
                                    <td>
                                        <p>
                                            <?php echo $this->formElement($sForm->get('start_stock')); ?>
                                        </p>
                                        <div>
                                            <?php echo $this->formElement($sForm->get('end_stock')); ?>
                                        </div>
                                        <?php echo $this->formElementErrors($sForm->get('start_stock'), ['class'=>'error-message']);?>
                                        <?php echo $this->formElementErrors($sForm->get('end_stock'), ['class'=>'error-message']);?>
                                    </td>
                                    <td>
                                        <button type="submit" class="btn btn-info btn-sm"><i class="fa fa-search"></i></button>
                                        <?php if(!empty(array_filter($sForm->getData()))) { ?>
                                            <a href="<?php echo $this->url('goods');?>" class="btn btn-default btn-sm"><i class="fa fa-reply"></i></a>
                                        <?php } ?>
                                    </td>
                                </tr>
                                <?php echo $this->form()->closeTag(); ?>
                                </thead>

                                <?php if($this->goodsList) foreach ($this->goodsList as $goods) { ?>
                                    <tr>
                                        <td><?php echo $goods->getGoodsId(); ?></td>
                                        <td>
                                            <?php if (!empty($goods->getGoodsImage())) { ?><img src="<?php echo $this->storeHelper()->goodsImage($goods->getGoodsImage()); ?>" class="img-thumbnail" style="<?php echo $this->adminHelper()->defaultGoodsImageWidth(); ?>float:left;margin-right: 3px;"><?php } ?>
                                            <?php echo $this->escapeHtml($goods->getGoodsName()); ?>
                                        </td>
                                        <td><?php echo $this->escapeHtml($goods->getGoodsNumber()); ?></td>
                                        <td><?php echo empty($goods->getGoodsSpec()) ? $this->translate('无') : $this->escapeHtml($goods->getGoodsSpec()); ?></td>
                                        <td>
                                            <?php if ($goods->getGoodsPrice() > 0) { ?>
                                            <?php echo $this->erpCurrencyFormat($goods->getGoodsPrice()); ?> <a href="<?php echo $this->url('goods', ['action' => 'priceTrend', 'id' => $goods->getGoodsId()]);?>" title="<?php echo $this->translate('价格走势'); ?>"><i class="fa fa-bar-chart text-green"></i></a></td>
                                            <?php } else echo $this->translate('无'); ?>
                                        <td><?php echo $this->erpCurrencyFormat($goods->getGoodsRecommendPrice()); ?></td>
                                        <td><?php echo $this->escapeHtml($goods->getGoodsCategory()->getGoodsCategoryName()); ?></td>
                                        <td><?php echo empty($goods->getBrand()) ? $this->translate('无') : $this->escapeHtml($goods->getBrand()->getBrandName()); ?></td>
                                        <td>
                                            <?php if($goods->getGoodsStock() > 0) { ?>
                                                <?php echo $goods->getGoodsStock(); ?> <a href="<?php echo $this->url('goods', ['action' => 'goodsWarehouse', 'id' => $goods->getGoodsId()]);?>" title="<?php echo $this->translate('仓库分布'); ?>"><i class="fa fa-cubes text-green"></i></a>
                                            <?php } else { ?>
                                                <?php echo $this->translate('无'); ?>
                                            <?php } ?>
                                        </td>
                                        <td>
                                            <a href="<?php echo $this->url('goods',
                                                ['action'=>'edit', 'id'=>$goods->getGoodsId()]); ?>"
                                               class="btn btn-xs btn-success"><i class="fa fa-pencil"></i> <?php echo $this->translate('编辑'); ?>
                                            </a>

                                            <a href="javascript:;" onclick="deleteConfirm('<?php echo $this->translate('您确实要删除该商品吗？'); ?>', '<?php echo $this->url('goods', ['action'=>'delete', 'id'=>$goods->getGoodsId()], ['query' => ['qToken' => $this->common()->getCsrfValue()]]); ?>');" class="btn btn-xs btn-danger">
                                                <i class="fa fa-trash"></i> <?php echo $this->translate('删除'); ?>
                                            </a>

                                            <a href="<?php echo $this->url('goods',
                                                ['action'=>'', 'id'=>$goods->getGoodsId()]); ?>"
                                               class="btn btn-xs btn-success"><i class="fa fa-pencil"></i> <?php echo $this->translate('查看出入库'); ?>
                                            </a>
                                        </td>
                                    </tr>
                                <?php } ?>
                            </table>
                    </div>
                    <div class="box-footer clearfix">
                        <?php echo $this->paginationControl($this->goodsList,
                            'Sliding',
                            'layout/page',
                            ['route' => 'goods']); ?>
                    </div>
                </div>

            </div>
        </div>

    </section>
</div>