<?php

use yii\helpers\Html;
use yii\widgets\DetailView;
use backend\models\SysCountry;
use common\widgets\TraceabilityDetailWidget;

/**
 * @var yii\web\View $this
 * @var PortalPeople\shippingcosts\models\SysShippingSetting $model
 */

$this->title = $model->title;
$this->params['breadcrumbs'][] = ['label' => 'Sys Shipping Settings', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
\yii\web\YiiAsset::register($this);
?>
<div class="sys-shipping-setting-view">
    <div class="row">
        
        <div class="sidebar col-200 col-12 pr-lg-0">
            <ul class="nav nav-pills nav-stacked">
                <li class="nav-item">
                <?= Html::a('Update', ['update', 'id' => $model->id, 'language' => $model->language], ['class' => 'btn btn-primary nav-link update']) ?>
                </li>
                <li class="nav-item">
                <?= Html::a('Delete', ['delete', 'id' => $model->id, 'language' => $model->language], [
                    'class' => 'btn bg-danger text-white nav-link delete',
                    'data' => [
                        'confirm' => 'Are you sure you want to delete this item?',
                        'method' => 'post',
                    ],
                ]) ?>
                </li>
            </ul>
        </div>

        <div class="col main">
            <div class="card">
                <div class="card-header"><?= Html::encode($this->title) ?></div>
                    <div class="card-body">

                        <div class="row margin-10">
                            <div class="col-4 col-md-2 font-weight-bold">
                                <span class="font-500 font-weight-bold"><?= $model->getAttributeLabel('title') ?>: </span>
                            </div>
                            <div class="col-8 col-md-4">
                                 <?= $model->title ?></div>
                            <div class="col-4 col-md-2 font-weight-bold">
                                <span class="font-500 font-weight-bold"><?= $model->getAttributeLabel('enabled') ?>: </span>
                            </div>
                            <div class="col-8 col-md-4">
                                <?= $model->enabled == "1" ? "Yes" : ($model->enabled == "0" ? "No" : "");  ?>
                            </div>
                        </div>

                        <div class="row margin-10"> 

                            <div class="col-4 col-md-2 font-weight-bold">
                                <span class="font-500 font-weight-bold"><?= $model->getAttributeLabel('centerid') ?>: </span>
                            </div>
                            <div class="col-8 col-md-4">
                                 <?= $model->storename ?></div>
                            <div class="col-4 col-md-2 font-weight-bold">
                                <span class="font-500 font-weight-bold"><?= $model->getAttributeLabel('package_id') ?>: </span>
                            </div>
                            <div class="col-8 col-md-4">
                                <?= $model->package_id == "1" ? "Yes" : ($model->package_id == "0" ? "No" : "");  ?></div>
                        </div>

                        <div class="row margin-10">                            
                            <div class="col-4 col-md-2 font-weight-bold">
                                <span class="font-500 font-weight-bold"><?= $model->getAttributeLabel('max_shipping_cost') ?>: </span>
                            </div>
                            <div class="col-8 col-md-4">
                                 <?= $model->max_shipping_cost ?></div>
                            <div class="col-4 col-md-2 font-weight-bold">
                                <span class="font-500 font-weight-bold"><?= $model->getAttributeLabel('totaling_algo') ?>: </span>
                            </div>
                            <div class="col-8 col-md-4">
                                 <?= $model->algoname ?></div>
                        </div>

                        <div class="row margin-10">
                            <div class="col-4 col-md-2 font-weight-bold">
                                <span class="font-500 font-weight-bold"><?= $model->getAttributeLabel('shipping_group') ?>: </span>
                            </div>
                            <div class="col-8 col-md-4">
                                <?= $model->shipping_group == '1' ? "Yes" : ($model->shipping_group == '0' ? "No" : "");  ?></div>
                            <div class="col-4 col-md-2 font-weight-bold">
                                <span class="font-500 font-weight-bold"><?= $model->getAttributeLabel('exclude_fornt_price') ?>: </span>
                            </div>
                            <div class="col-8 col-md-4">
                                <?= $model->exclude_fornt_price == "1" ? "Yes" : ($model->exclude_fornt_price == "0" ? "No" : "");  ?>
                            </div>
                            
                        </div>

                        <div class="row margin-10">
                            
                            <div class="col-4 col-md-2 font-weight-bold">
                                <span class="font-500 font-weight-bold"><?= $model->getAttributeLabel('error_message') ?>: </span>
                            </div>
                            <div class="col-8 col-md-4">
                                 <?= $model->error_message ?></div>
                        </div>

                        <hr>

                        <div class="row margin-10">
                            <div class="col-sm-3">
                                <span class="font-500 font-weight-bold"><?= $model->getAttributeLabel('show_ship_status') ?>: </span>
                            </div>
                            <div class="col-sm-3">
                                <?= $model->show_ship_status == "1" ? "Yes" : "No";  ?></div>
                            <div class="col-4 col-md-2 font-weight-bold">
                                <span class="font-500 font-weight-bold"><?= $model->getAttributeLabel('default_ship_status') ?>: </span>
                            </div>
                            <div class="col-8 col-md-4">
                                <?= $model->default_ship_status;  ?></div>
                        </div>

                        <hr>

                        <div class="row margin-10">
                            <div class="col-sm-3">
                                <span class="font-500 font-weight-bold"><?= $model->getAttributeLabel('post_code_range') ?>: </span>
                            </div>
                            <div class="col-sm-3">
                                <?= $model->post_code_range == "1" ? "Yes" : ($model->post_code_range == "0" ? "No" : "");  ?></div>
                            <div class="col-4 col-md-2 font-weight-bold">
                                <span class="font-500 font-weight-bold"><?= $model->getAttributeLabel('uk_post_code') ?>: </span>
                            </div>
                            <div class="col-8 col-md-4">
                                <?= $model->uk_post_code == "1" ? "Yes" : ($model->uk_post_code == "0" ? "No" : "");  ?></div>
                        </div>

                        <hr>

                        <div class="row margin-10">
                            
                            <div class="col-4 col-md-2 font-weight-bold">
                                <span class="font-500 font-weight-bold"><?= $model->getAttributeLabel('applicable_countries') ?>: </span>
                            </div>
                            <div class="col-8 col-md-4">
                                <?php
                                if ($model->applicable_countries == "1") {
                                    echo "All Countries";
                                }
                                if ($model->applicable_countries == "2") {
                                    echo "Selected Countries";
                                }
                                ?></div>
                            <?php if ($model->applicable_countries == "2") : ?>
                            <div class="col-4 col-md-2 font-weight-bold">
                                <span class="font-500 font-weight-bold"><?= $model->getAttributeLabel('countries') ?>: </span>
                            </div>
                            <div class="col-8 col-md-4">
                                <ul>
                                    <?php
                                    $countries =  explode(",", $model->countries);
                                    foreach ($countries as $value) {
                                        $country = SysCountry::find()->where(['alpha_3' => $value])->one();
                                        echo $country ?  '<li>' . $country->name . " </li>" : '';
                                    }
                                    ?>
                                </ul>
                            </div>
                            <?php endif;?>
                        </div>

                        <hr>

                        <div class="row margin-10">

                            <div class="col-sm-3">
                                <span class="font-500 font-weight-bold"><?= $model->getAttributeLabel('apply_handling_fee') ?>: </span>
                            </div>
                            <div class="col-sm-3">
                                <?= $model->apply_handling_fee == "1" ? "Yes" : ($model->apply_handling_fee == "0" ? "No" : "");  ?>
                             </div>
                            <?php if ($model->apply_handling_fee == "1") : ?>
                                <div class="col-4 col-md-2 font-weight-bold">
                                    <span class="font-500 font-weight-bold"><?= $model->getAttributeLabel('cal_handling_fee') ?>: </span>
                                </div>
                                <div class="col-8 col-md-4">
                                    <?= $model->cal_handling_fee == "1" ? "Fixed Pric" : ($model->cal_handling_fee == "0" ? "%" : "");  ?>
                                </div>
                            <?php endif; ?>
                        </div>
                        <div class="row margin-10">
                            <?php if ($model->apply_handling_fee == "1") : ?>
                                <div class="col-4 col-md-2 font-weight-bold">
                                    <span class="font-500 font-weight-bold"><?= $model->getAttributeLabel('handling_fee') ?>: </span>
                                </div>
                                <div class="col-8 col-md-4">
                                     <?= $model->handling_fee ?></div>
                            <?php endif; ?>
                        </div>

                        <hr>
                        
                        <div class="row margin-10">

                            <div class="col-4 col-md-2 font-weight-bold">
                                <span class="font-500 font-weight-bold"><?= $model->getAttributeLabel('zero_cost_shipping') ?>: </span>
                            </div>
                            <div class="col-8 col-md-4">
                                 <?= $model->zero_cost_shipping ?></div>
                            <div class="col-4 col-md-2 font-weight-bold">
                                <span class="font-500 font-weight-bold"><?= $model->getAttributeLabel('shipping_promotion') ?>: </span>
                            </div>
                            <div class="col-8 col-md-4">
                                 <?= $model->shipping_promotion ?></div>
                            
                        </div>

                        <div class="row margin-10">
                            
                            <div class="col-4 col-md-2 font-weight-bold">
                                <span class="font-500 font-weight-bold"><?= $model->getAttributeLabel('discount_price') ?>: </span>
                            </div>
                            <div class="col-8 col-md-4">
                                <?= $model->discount_price == "1" ? "Yes" : ($model->discount_price == "0" ? "No" : "");  ?>
                            </div>
                            
                        </div>


                        
                    </div>
                </div>
                <div class="card">
                    <?= TraceabilityDetailWidget::widget([
                        'model' => $model,
                        'title' => 'Traceability Information',
                        'options' => [
                        'class' => 'custom-traceability-card',
                            ],
                    ]) ?>
                </div>                              
            </div>
        </div>
    </div>
</div>