@using System.Collections.Generic
@using MrCMS.Web.Apps.Ecommerce.Settings
@model MrCMS.Web.Apps.Ecommerce.Entities.Products.ProductVariant
@{
    var productVariantTypeOptions = ViewData["product-variant-type-options"] as List<SelectListItem> ?? new List<SelectListItem>();
    var eTagOptions = ViewData["e-tag-options"] as List<SelectListItem> ?? new List<SelectListItem>();
}
<div id="details" class="tab-pane active" style="padding-left: 5px; padding-right: 5px;">
    @Html.HiddenFor(variant => variant.Product.Id)
    <div class="row">
        <div class="col-xs-6">
            <div class="form-group">
                @Html.LabelFor(variant => variant.Name)
                @Html.TextBoxFor(variant => variant.Name, new { @class = "form-control" })
            </div>
        </div>
        <div class="col-xs-6">
            <div class="form-group">
                @Html.LabelFor(variant => variant.VariantType)
                @Html.DropDownListFor(variant => variant.VariantType, productVariantTypeOptions, new { @class = "form-control" })
            </div>
        </div>
    </div>

    @for (var index = 0; index < Model.Product.Options.Count; index++)
    {

        var option = Model.Product.Options[index];
        <div class="form-group">
            @Html.LabelFor(variant => variant.OptionValues[index].Value, option.Name)
            @Html.TextBoxFor(variant => variant.OptionValues[index].Value, new { @class = "form-control required" })
            @Html.Hidden("OptionValues[" + index + "].Id", Model.OptionValues[index].Id)
            @Html.Hidden("OptionValues[" + index + "].ProductOption.Id", option.Id.ToString())
        </div>
    }
    <div class="row">
        <div class="col-xs-6">
            <div class="form-group">
                @Html.LabelFor(variant => variant.Barcode)
                @Html.TextBoxFor(variant => variant.Barcode, new { @class = "form-control" })
            </div>
        </div>
        <div class="col-xs-6">
            <div class="form-group">
                @Html.LabelFor(variant => variant.ManufacturerPartNumber)
                @Html.TextBoxFor(variant => variant.ManufacturerPartNumber, new { @class = "form-control" })
            </div>
        </div>
    </div>

    <div class="row">
        <div class="col-xs-6">
            <div class="form-group">
                @Html.LabelFor(variant => variant.SKU)
                @Html.TextBoxFor(variant => variant.SKU, new { @class = "form-control" })
                @Html.ValidationMessageFor(variant => variant.SKU)
            </div>
        </div>
        <div class="col-xs-6">
            <div class="row">
                <div class="col-xs-6">
                    <div class="form-group">
                        @Html.LabelFor(variant => variant.BasePrice)
                        @Html.TextBoxFor(variant => variant.BasePrice, new { @class = "form-control" })
                        @Html.ValidationMessageFor(variant => variant.BasePrice)
                    </div>
                </div>
                <div class="col-xs-6">
                    <div class="form-group">
                        @Html.LabelFor(variant => variant.PreviousPrice)
                        @Html.TextBoxFor(variant => variant.PreviousPrice, new { @class = "form-control" })
                        @Html.ValidationMessageFor(variant => variant.PreviousPrice)
                    </div>
                </div>
            </div>

        </div>
    </div>
    
    <div class="row">
        <div class="col-xs-6">
            <div class="form-group">
                @Html.LabelFor(variant => variant.Weight)
                @Html.TextBoxFor(variant => variant.Weight, new { @class = "form-control" })
                @Html.ValidationMessageFor(variant => variant.Weight)
            </div>
        </div>
        <div class="col-xs-6">
            <div class="form-group">
                @Html.LabelFor(variant => variant.ETag)
                @Html.DropDownListFor(variant => variant.ETag.Id, eTagOptions, new { @class = "form-control" })
            </div>
        </div>
    </div>
    
    <div class="row">
        <div class="col-xs-6">
            <div class="form-group">
                @if (MrCMS.Website.MrCMSApplication.Get<MrCMS.Web.Apps.Ecommerce.Settings.TaxSettings>().TaxesEnabled)
                {
                    @Html.LabelFor(product => product.TaxRate.Id, "Tax Rate")
                    @Html.DropDownListFor(product => product.TaxRate.Id, ViewData["tax-rate-options"] as IEnumerable<SelectListItem>, new { @class = "form-control" })
                }
            </div>
        </div>
    </div>
</div>
