<div class="content-wrapper">
    <?php
    $form = $this->form;
    $form->prepare();

    $form->get('warehouseSn')->setAttributes([
        'placeholder' => $this->translate('仓库编号')
    ]);

    $form->get('warehouseName')->setAttributes([
        'placeholder' => $this->translate('仓库名称')
    ]);

    $form->get('warehouseContacts')->setAttributes([
        'placeholder' => $this->translate('联系人')
    ]);

    $form->get('warehousePhone')->setAttributes([
        'placeholder' => $this->translate('联系电话')
    ]);

    $form->get('warehouseSort')->setAttributes([
        'placeholder' => $this->translate('仓库排序')
    ]);

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

        <h1 class="pull-right">
            <a href="<?=$this->url('warehouse');?>" class="btn btn-default btn-sm"><i class="fa fa-arrow-left"></i> <?=$this->translate('返回仓库列表')?></a>
            <button type="submit" class="btn btn-primary btn-sm"><i class="fa fa-check"></i> <?=$this->translate('保存仓库')?></button>
            <?=(isset($warehouse) ? $this->HelpUrl('warehouseEdit') : $this->HelpUrl('warehouseAdd'))?>
        </h1>
    </section>

    <section class="content">

        <div class="row">
            <div class="col-md-12">
                <div class="box box-primary">
                    <div class="box-header with-border">
                        <h3 class="box-title"><?=((isset($warehouse) && $warehouse->getWarehouseId()) ? $this->translate('编辑仓库') : $this->translate('添加仓库'))?></h3>
                    </div>

                    <div class="box-body">
                        <?=$this->formElementErrors($form->get('dberp_csrf'), ['class'=>'error-message']); ?>
                        <div class="form-group">
                            <label  class="col-sm-2 control-label"><?=$this->translate('仓库编号')?><span class="must_add_value">*</span></label>
                            <div class="col-sm-6">
                                <?= $this->formElement($form->get('warehouseSn')); ?>
                                <?= $this->formElementErrors($form->get('warehouseSn'), ['class'=>'error-message']); ?>
                            </div>
                        </div>

                        <div class="form-group">
                            <label  class="col-sm-2 control-label"><?=$this->translate('仓库名称')?><span class="must_add_value">*</span></label>
                            <div class="col-sm-6">
                                <?= $this->formElement($form->get('warehouseName')); ?>
                                <?= $this->formElementErrors($form->get('warehouseName'), ['class'=>'error-message']); ?>
                            </div>
                        </div>

                        <div class="form-group">
                            <label  class="col-sm-2 control-label"><?=$this->translate('仓库管理员')?></label>
                            <div class="col-sm-6">
                                <?= $this->formElement($form->get('warehouseContacts')); ?>
                                <?= $this->formElementErrors($form->get('warehouseContacts'), ['class'=>'error-message']); ?>
                            </div>
                        </div>

                        <div class="form-group">
                            <label  class="col-sm-2 control-label"><?=$this->translate('联系电话')?></label>
                            <div class="col-sm-6">
                                <?= $this->formElement($form->get('warehousePhone')); ?>
                                <?= $this->formElementErrors($form->get('warehousePhone'), ['class'=>'error-message']); ?>
                            </div>
                        </div>

                        <div class="form-group">
                            <label  class="col-sm-2 control-label"><?=$this->translate('排序')?><span class="must_add_value">*</span></label>
                            <div class="col-sm-3">
                                <?= $this->formElement($form->get('warehouseSort')); ?>
                                <?= $this->formElementErrors($form->get('warehouseSort'), ['class'=>'error-message']); ?>
                            </div>
                        </div>

                    </div>

                    <div>
                        <div class="box-footer">
                            <?=$this->formElement($form->get('dberp_csrf')); ?>
                            <button type="submit" class="btn btn-primary col-md-offset-2"><i class="fa fa-check"></i> <?=$this->translate('保存仓库')?></button>
                        </div>
                    </div>

                </div>
            </div>
        </div>

    </section>
    <?= $this->form()->closeTag(); ?>

</div>
<script>
    $(document).ready(function() {
        $("#<?=$form->getName()?>").validate({
            rules: {
                warehouseSn: {
                    required: true
                },
                warehouseName: {
                    required: true
                },
                warehouseSort: {
                    required: true,
                    number: true,
                    min: 1
                }
            },
            messages: {
                warehouseSn: {
                    required: "<?=$this->translate('仓库编号不能为空！')?>"
                },
                warehouseName: {
                    required: "<?=$this->translate('仓库名称不能为空！')?>"
                },
                warehouseSort: {
                    required: "<?=$this->translate('排序不能为空！')?>",
                    number: "<?=$this->translate('排序必须为数字！')?>",
                    min: "<?=$this->translate('排序最小为1！')?>"
                }
            }
        });
    });
</script>
