<?php
use home\assets\MainAsset;
use yii\helpers\Url;
use home\modules\sale\models\Status;
use yii\widgets\ActiveForm;
use yii\helpers\StringHelper;

/* @var $this \yii\web\View */
/* @var $form yii\bootstrap\ActiveForm */
/* @var $model \home\modules\sale\models\Status */

$this->title = '状态列表';
?>

<!--container-->
<div class="container manage-project fix">
    <?= $this->render('@home/views/site/_left-menu') ?>

  <!--manage-left -->
  <div class="manage-right">
    <div class="tab-column tab-manage">
        <div class="tab-right">

            <button type="button" title="添加状态" data-width="400" data-height="240" data-url='<?= Url::to([$this->context->id . '/create']) ?>' data-title="添加状态" class="btn btn-default btn-task open-dialog">
                <i class="icon-plus"></i>
            </button>

        </div>
        <p class="caption">状态列表</p>
    </div>
    <?= \home\widgets\Alert::widget(); ?>
    <?php $mainForm = ActiveForm::begin([ 'id' => 'main-form', 'action' => '']); ?>
    <table class="table task-table">
        <tr>
            <!-- <th width="60"><label style="font-weight:lighter" ><input type="checkbox" name="select_all" class="box-select-all" style="position:relative;top:2px;" /> 全选</label></th> -->
            <th width="25%">状态名称</th>
            <th width="45%">备注</th>
            <th width="60">状态</th>
            <th width="150" align="center">操作</th>
        </tr>
        <?php if (empty($models)) : ?>
        <tr><td colspan="6" class="tac red">还没有任何数据...</td></tr>
        <?php else : ?>
            <?php foreach ($models as $model) : ?>
            <tr>
                <!-- <td><input type="checkbox" name="delete[]" class="box-delete" value="<?= $model->status_id ?>" /></td> -->
                <td class="theleft-min" title="<?= $model->name ?>"><?= $model->name ?></td>
                <td class='theleft-min' title="<?= $model->remark ?>"><?= empty($model->remark) ? '' : StringHelper::truncate($model->remark, 32) ?></td>
                <td><?= ($model->status == Status::STATUS_ENABLE) ? '<font color="green">启用</font>' : '<font color="red">禁用</font>' ?></td>
                <td align="center" >
                    <a href="javascript:;" class="open-dialog"  data-url="<?= Url::to([$this->context->id . '/view', 'id' => $model->status_id]) ?>" data-width='400' data-height='240' data-title='编辑状态' >编辑</a>  
                    <a href="<?= Url::to([$this->context->id . '/delete', 'id' => $model->status_id]) ?>" class="link-delete" >删除</a>
                </td>
            </tr>
            <?php endforeach; ?>
        <?php endif; ?>
    </table>
    <!-- <div class="tab-column tab-manage">
        <button type="button" class="btn btn-default btn-task batch-delete" data-url="<?= Url::to([$this->context->id.'/delete']) ?>" >
            <a href="javascript:;">删除</a>
        </button>
    </div> -->
    <?php ActiveForm::end(); ?>
    <div class="pages">
        <span class="pagetotal">共<em><?= $pages->totalCount ?></em>条记录<em><?= $pages->page + 1 ?>/<?= $pages->pageCount ?></em>页 </span>
        <?= \yii\widgets\LinkPager::widget(['pagination' => $pages, 'prevPageLabel' => '上一页','nextPageLabel' => '下一页', 'firstPageLabel' => '首页', 'lastPageLabel' => '末页']); ?>
    </div>
  </div>
  <!--manage-right--> 
</div>
<!--container-->