<?php $__env->startSection('content'); ?>
<div>
    <div class="input-prepend input-append">
    </div>
        <h4 class="nametag"><?php echo e(trans($_CONST["LANG_DEST"].".title")); ?></h4>
        <a href="<?php echo route($_CONST["CONTROLLER_ROUTE"].'.create'); ?>" class="btn btn-primary">
            <span class="glyphicon glyphicon-file"></span>
            <?php echo e(trans($_CONST["LANG_DEST"].".create_action")); ?>

        </a>
        <a href="<?php echo action($_CONST["CLASS_CONTROLLER"].'@index'); ?>" class="btn btn-success">
            <span class="glyphicon glyphicon-th-list"></span>
            <?php echo e(trans($_CONST["LANG_DEST"].".browse_class")); ?>

        </a>
    <hr>
    <?php echo Form::open(array(  'class'=>'form-horizontal well')); ?>

    <div class="input-group">
        <span class="input-group-addon"><?php echo e(trans($_CONST["LANG_DEST"].".select_class")); ?>：</span>
        <?php echo Form::select('id', $categories, 0, array('class' => 'form-control') ); ?>

    </div>
    <?php echo Form::close(); ?>

    <table class="table table-bordered">
        <tr><th>精油名稱</th><th>產品分類</th><th>副標題</th><th>價格</th><th>最後修改時間</th><th>操作</th></tr>
        <?php foreach($products as $product): ?> 
        <tr>
            <td style="width:129px"><?php echo e($product->title); ?></td>
            <td style="width:129px">
                    <a href="<?php echo route($_CONST["CONTROLLER_ROUTE"].'.show', $product->category->id); ?>">
                        <?php echo e($product->category->title); ?>

                    </a>
            </td>
            <td style="width:100px"><?php echo e($product->sub_title); ?></td>
            <td style="width:80px"><?php echo e($product->price); ?></td>
            <td style="width:100px"><?php echo e($product->updated_at); ?></td>
            <td style="width:200px">
                <?php echo Form::open(array(
                    'route'=>array('admin.product.destroy', $product->id),
                    'method' => 'delete')
                ); ?>

                <a href="<?php echo route('admin.product.edit', $product->id); ?>" class="btn btn-primary">
                    <span class="glyphicon glyphicon-pencil"></span>
                    修改
                </a>
                <a target="_blank" href="<?php echo e($fronturl); ?>/<?php echo $product->id; ?>" class="btn btn-primary">
                    <span class="glyphicon glyphicon-eye-open"></span>
                    瀏覽網頁
                </a>
                <a href="#" onclick="if (confirm('<?php echo trans('Myadmin::layout.whether_to_delete'); ?>'))$(this).closest('form').submit()" class="btn btn-danger">
                    <span class="glyphicon glyphicon-trash"></span>
                    刪除
                </a>
                <?php echo Form::close(); ?>

            </td>
        </tr>
        <?php endforeach; ?>
    </table>
    <div class="pagination">
        <?php echo $products->links(); ?>

    </div>
    <script type="text/javascript" charset="utf-8">
        $(document).ready(function(){
            var base_url = "<?php echo route('admin.product.index'); ?>";
            $("#search").click(function(){
                var redirect = base_url+'/'+$("input[name=search]").val();
                window.location.href = redirect;
            });
            $("#reset").click(function(){
                $("input[name=search]").val('');
            });

            $("select[name=id]").change(function(){
                var t = $("select[name=id]").val();
                var base_url = "<?php echo route($_CONST["CONTROLLER_ROUTE"].".index"); ?>";
                if (t==0) {
                    var target = base_url;
                }else {
                    var target = base_url + '/' + t;
                }
                window.location = target;
            });
        });
    </script>
</div>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('Myadmin::layout.basic', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>