<?php

use yii\grid\GridView;
use yii\helpers\Html;
use yii\widgets\ActiveForm;
use yii\widgets\DetailView;

/* @var $this yii\web\View */
/* @var $model common\models\Package */
/* @var $form yii\widgets\ActiveForm */
?>


<div class="nav-tabs-custom">
    <ul class="nav nav-tabs">
        <li class="active"><a href="#tab_3" data-toggle="tab" aria-expanded="true">发货物流信息</a></li>
    </ul>
    <div class="tab-content">
        <div class="tab-pane active" id="tab_3">
            <?php $form = ActiveForm::begin(); ?>


            <?= $form->field($model, 'no')->textInput(['maxlength' => true]) ?>

            <?= $form->field($model, 'com')->textInput(['maxlength' => true]) ?>

            <?= $form->field($model, 'status')->dropDownList(\common\models\Package::getStatusList()) ?>

            <div class="form-group form-submit">
                <?= Html::submitButton($model->isNewRecord ? Yii::t('common', 'Create') : Yii::t('common', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-success']) ?>
            </div>

            <?php ActiveForm::end(); ?>
        </div>
    </div>
</div>

<div class="nav-tabs-custom">
    <ul class="nav nav-tabs">
        <li class="active"><a href="#tab_2" data-toggle="tab" aria-expanded="true">发货商品</a></li>
    </ul>
    <div class="tab-content">
        <div class="tab-pane active" id="tab_2">
            <?= GridView::widget([
                'dataProvider' => $orderSku['data'],
                'columns' => [
                    'id',
                    [
                        'attribute' => 'goods_id',
                        'format' => 'raw',
                        'value' => function ($model) {
                            return $model->goods->name;
                        },
                    ],
                    [
                        'attribute' => 'sku_id',
                        'format' => 'raw',
                        'value' => function ($model) {

                            if ($model->sku) {

                                return $model->sku->name;
                            } else {
                                return '默认';
                            }
                        },
                    ],

                    'quantity',
                    'unit_price',

                    [
                        'label' => '商品总价',
                        'format' => 'raw',
                        'value' => function ($model) {
                            return $model->quantity * $model->unit_price . '元';
                        },
                    ],
                    [
                        'attribute' => 'status',
                        'value' => function ($model) {
                            return \common\models\OrderSku::getStatusList($model->status);
                        },
                    ],

                ],
            ]); ?>
        </div>
    </div>
</div>


<div class="nav-tabs-custom">
    <ul class="nav nav-tabs">
        <li class="active"><a href="#tab_1" data-toggle="tab" aria-expanded="true">订单信息</a></li>
    </ul>
    <div class="tab-content">
        <div class="tab-pane active" id="tab_1">
            <?= DetailView::widget([
                'model' => $order,
                'attributes' => [
                    'id',
//                    [
//                        'attribute' => 'user_id',
//                        'format' => 'raw',
//                        'value' => function ($model) {
//                            if (!empty($model->user)) {
//                                return Html::a($model->user->nickName, \yii\helpers\Url::to(['/wechat-user/view', 'id' => $model->user_id]), ['title' => '查看用户', 'data-toggle' => 'tooltip', 'target' => '_blank']);
//                            } else {
//                                return '无';
//                            }
//                        },
//                    ],
                    'out_trade_no',
                    'user_id:user',
                    'order_no',
                    'total_amount',
                    'pay_amount',
                    'pay_time:datetime',
                    'remark',
                    'receiver_name',
                    'receiver_tel',
                    'receiver_address',
                    'created_at:datetime',
                    'updated_at:datetime',
                    [
                        'attribute' => 'status',
                        'value' => function ($model) {
                            return \common\models\Order::getStatusList($model->status);
                        },
                    ],
                ],
            ]) ?>


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