<div class="content-wrapper">

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

        <h1 class="pull-right">
            <a href="<?php echo $this->url('cms', ['action'=> 'add']);?>" class="btn btn-primary btn-sm"><i class="fa fa-plus"></i> <?php echo $this->translate('添加文章'); ?></a>
            <?php echo $this->HelpUrl('cmsList'); ?>
        </h1>

    </section>

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

        <div class="row">
            <div class="col-xs-12">
                <div class="box shop-box">

                    <div class="box-body table-responsive no-padding">
                        <table class="table shop-table table-hover">
                            <thead>
                            <tr class="shop-bg-thead">
                                <th width="6%">ID</th>
                                <th width="25%"><?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>
                                <th width="15%"><?php echo $this->translate('操作'); ?></th>
                            </tr>
                            <?php
                            $sForm = $this->searchForm;
                            $sForm->prepare();
                            $sForm->get('cms_state')->setEmptyOption('选择状态');
                            ?>
                            <?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('cms_title')); ?>
                                    <?php echo $this->formElementErrors($sForm->get('cms_title'), ['class'=>'error-message']);?>
                                </td>
                                <td>
                                    <?php echo $this->formElement($sForm->get('cms_class_id')); ?>
                                    <?php echo $this->formElementErrors($sForm->get('cms_class_id'), ['class'=>'error-message']);?>
                                </td>
                                <td>
                                    <?php echo $this->formElement($sForm->get('cms_state')); ?>
                                    <?php echo $this->formElementErrors($sForm->get('cms_state'), ['class'=>'error-message']);?>
                                </td>
                                <td></td>
                                <td>
                                    <p>
                                        <?php echo $this->formElement($sForm->get('start_time')); ?>
                                    </p>
                                    <div>
                                        <?php echo $this->formElement($sForm->get('end_time')); ?>
                                    </div>
                                    <?php echo $this->formElementErrors($sForm->get('start_time'), ['class'=>'error-message']);?>
                                    <?php echo $this->formElementErrors($sForm->get('end_time'), ['class'=>'error-message']);?>
                                </td>
                                <td>
                                    <button type="submit" class="btn btn-info btn-sm"><i class="fa fa-search"></i></button>
                                    <?php
                                    $formData = $sForm->getData();
                                    if(!empty(array_filter($formData)) || $formData['cms_state'] != '') { ?>
                                        &nbsp;&nbsp;<a href="<?php echo $this->url('cms');?>" class="btn btn-default btn-sm"><i class="fa fa-reply"></i></a>
                                    <?php }  $formData['page'] = $this->cmsList->getCurrentPageNumber(); ?>
                                </td>
                            </tr>
                            <?php echo $this->form()->closeTag(); ?>
                            </thead>
                            <tbody>
                            <?php if($this->cmsList) foreach ($this->cmsList as $cmsValue) { ?>
                                <tr>
                                    <td><?php echo $cmsValue[0]->getCmsId(); ?></td>
                                    <td><?php echo $this->escapeHtml($cmsValue[0]->getCmsTitle()); ?></td>
                                    <td><?php echo $this->escapeHtml($cmsValue['cmsClassName']); ?></td>
                                    <td><?php echo $this->cmsHelper()->cmsState($cmsValue[0]->getCmsState()); ?></td>
                                    <td><?php echo $cmsValue[0]->getCmsSort(); ?></td>
                                    <td><?php echo empty($cmsValue[0]->getCmsAddTime()) ? '' : $this->shopDateFormat()->cmsAddTime($cmsValue[0]->getCmsAddTime()); ?></td>
                                    <td>
                                        <a href="<?php echo $this->url('cms',
                                            ['action'=>'edit', 'id'=>$cmsValue[0]->getCmsId()], ['query' => $formData]); ?>"
                                           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('cms', ['action'=>'delete', 'id'=>$cmsValue[0]->getCmsId()], ['query' => ['qToken' => $this->adminHelper()->getCsrfValue()]]); ?>');" class="btn btn-xs btn-danger"><i class="fa fa-trash"></i> <?php echo $this->translate('删除'); ?></a>
                                        <a href="<?php echo $this->url('shop-cms', ['action' => 'content', 'id' => $cmsValue[0]->getCmsId()]); ?>" target="_blank" class="btn btn-xs btn-info"><i class="fa fa-share"></i> <?php echo $this->translate('预览'); ?></a>
                                    </td>
                                </tr>
                            <?php } ?>
                            </tbody>
                        </table>
                    </div>
                    <div class="box-footer clearfix">
                        <?php echo $this->paginationControl($this->cmsList, 'Sliding', 'layout/page', ['route' => 'cms']); ?>
                    </div>
                </div>

            </div>
        </div>

    </section>
</div>
<script type="text/javascript">
    laydate.render({elem: '#start_time'});
    laydate.render({elem: '#end_time'});
</script>