@model Nop.Web.Models.ShoppingCart.ShoppingCartModel
@using Nop.Core.Domain.Orders
@using Nop.Web.Framework;
<div class="order-summary-content">
    @if (Model.Items.Count > 0)
    {
        if (Model.Warnings.Count > 0)
        {
        <div class="warning-box">
            <div class="warning-text">
                @for (int i = 0; i < Model.Warnings.Count; i++)
                {
                    @Model.Warnings[i]
               if (i != Model.Warnings.Count - 1)
               {
                    <br />
               }
                }
            </div>
        </div>
        }
        using (Html.BeginRouteForm("ShoppingCart", FormMethod.Post))
        {
        <table class="cart">
            @if (Model.IsEditable)
            {
                <col width="1" />
            }
            @if (Model.ShowSku)
            {
                <col width="1" />
            }
            @if (Model.ShowProductImages)
            {
                <col width="1" />
            }
            <col />
            <col width="1" />
            <col width="1" />
            <col width="1" />
            <thead>
                <tr class="cart-header-row">
                    @if (Model.IsEditable)
                    {
                        <th>
                            @T("ShoppingCart.Remove")
                        </th>
                    }
                    @if (Model.ShowSku)
                    {
                        <th>
                            @T("ShoppingCart.SKU")
                        </th>
                    }
                    @if (Model.ShowProductImages)
                    {
                        <th class="picture">
                        </th>
                    }
                    <th>
                        @T("ShoppingCart.Product(s)")
                    </th>
                    <th>
                        @T("ShoppingCart.UnitPrice")
                    </th>
                    <th>
                        @T("ShoppingCart.Quantity")
                    </th>
                    <th class="end">
                        @T("ShoppingCart.ItemTotal")
                    </th>
                </tr>
            </thead>
            <tbody>
                @foreach (var item in Model.Items)
                {
                    <tr class="cart-item-row">
                        @if (Model.IsEditable)
                        {
                            <td>
                                <input id="removefromcart" type="checkbox" name="removefromcart" value="@(item.Id)" />
                            </td>
                        }
                        @if (Model.ShowSku)
                        {
                            <td style="white-space: nowrap;">
                                @item.Sku
                            </td>
                        }
                        @if (Model.ShowProductImages)
                        {
                            <td class="productpicture">
                                <img style="border-width: 0px;" alt="@item.Picture.AlternateText" src="@item.Picture.ImageUrl" title="@item.Picture.Title" />
                            </td>
                        }
                        <td class="product">
                            <a href="@Url.RouteUrl("Product", new { productId = item.ProductId, SeName = item.ProductSeName })" title="View details">@item.ProductName</a>
                            @if (!String.IsNullOrEmpty(item.AttributeInfo))
                            {
                                <br />
                                @Html.Raw(item.AttributeInfo)
                            }
                            @if (!String.IsNullOrEmpty(item.RecurringInfo))
                            {
                                <br />
                                @Html.Raw(item.RecurringInfo)
                            }
                            @if (item.Warnings.Count > 0)
                            {
                                <div class="warning-box">
                                    <div class="warning-text">
                                        @for (int i = 0; i < item.Warnings.Count; i++)
                                        {
                                            @item.Warnings[i]
                                       if (i != item.Warnings.Count - 1)
                                       {
                                            <br />
                                       }
                                        }
                                    </div>
                                </div>
                            }
                        </td>
                        <td style="white-space: nowrap;">
                            <span class="productPrice">@item.UnitPrice</span>
                        </td>
                        <td style="white-space: nowrap;">
                            @if (Model.IsEditable)
                            {
                                <input name="itemquantity@(item.Id)" type="text" value="@(item.Quantity)" id="itemquantity@(item.Id)" class="shoppingcartquantitytext" size="4" />
                            }
                            else
                            {
                                <span>@item.Quantity</span>
                            }
                        </td>
                        <td style="white-space: nowrap;" class="end">
                            <span class="productPrice">@item.SubTotal</span>
                            @if (!String.IsNullOrEmpty(item.Discount))
                            {
                                <br />
                                @T("ShoppingCart.ItemYouSave")<text>:</text>
                                <text>&nbsp; &nbsp;</text>@item.Discount
                            }
                        </td>
                    </tr>
                }
            </tbody>
        </table>                
        <div class="clear">
        </div>
                if (!String.IsNullOrEmpty(Model.CheckoutAttributeInfo))
                {
        <div class="selected-checkout-attributes">
            @Html.Raw(Model.CheckoutAttributeInfo)
        </div>
        <div class="clear">
        </div>
                }
        <div>
            @if (Model.IsEditable)
            {
                <div class="common-buttons">
                    <input type="submit" name="updatecart" value="@T("ShoppingCart.UpdateCart")" id="updatecart" class="updatecartbutton" />
                    <input type="submit" name="continueshopping" value="@T("ShoppingCart.ContinueShopping")" id="continueshopping" class="continueshoppingbutton" />
                    <input type="submit" name="startcheckout" value="startcheckout" id="startcheckout"
                        style="display: none;" />
                </div>                    
                <div class="clear">
                </div>
                @Html.Partial("_CheckoutAttributes", Model.CheckoutAttributes, new ViewDataDictionary())
                <div class="clear">
                </div>
            }
        </div>
        <div class="clear">
        </div>                
        }
        <div class="cart-footer">
            @if (Model.IsEditable)
            {
                if (!String.IsNullOrEmpty(Model.MinOrderSubtotalWarning))
                {
                <div>
                    <div class="min-amount-warning">
                        @Model.MinOrderSubtotalWarning
                    </div>
                </div>
                }
            }
            <div class="clear">
            </div>
            <div class="totals">
                @Html.Action("OrderTotals", "ShoppingCart", new { isEditable = Model.IsEditable })
                @if (Model.IsEditable)
                {
                    <div class="clear">
                    </div>
                    if (Model.TermsOfServiceEnabled)
                    {
                    <script language="javascript" type="text/javascript">
                        function accepttermsofservice() {
                            if (!document.getElementById('termsofservice').checked) {
                                alert('@T("Checkout.TermsOfService.PleaseAccept")');
                                return false;
                            }
                            else
                                return true;
                        }
                    </script>
                    <div class="terms-of-service">
                        <input id="termsofservice" type="checkbox" name="termsofservice" />
                        @T("Checkout.TermsOfService.IAccept")
                        <span class="read" onclick="javascript:OpenWindow('@Url.RouteUrl("TopicPopup", new { SystemName = "conditionsofUse" })', 450, 500, true)">@T("Checkout.TermsOfService.Read")</span>
                    </div>
                    }
                            
                    <div class="clear">
                    </div>
                    <div class="checkout-buttons">
                        @if (String.IsNullOrEmpty(Model.MinOrderSubtotalWarning))
                        {
                            <script language="javascript" type="text/javascript">
                                        function startcheckout() {
                                            //terms of services
                                            var termOfServiceOk = true;
                                            @if (Model.TermsOfServiceEnabled)
                                            {
                                                <text>
                                                termOfServiceOk = accepttermsofservice();
                                                </text>
                                            }
                                            if (termOfServiceOk)
                                            {
                                                $('#startcheckout').trigger("click");
                                            }
                                        }
                            </script>
                            <input type="submit" name="checkout" value="@T("Checkout")" id="checkout" class="checkoutbutton" onclick="startcheckout()" />
                        }
                    </div>
                    <div class="addon-buttons">
                        @*Payment method buttons (e.g. GoogleCheckoutButton, Paypal Express)*@
                        @if (Model.ButtonPaymentMethodActionNames != null && Model.ButtonPaymentMethodActionNames.Count > 0)
                        {
                            for (int i = 0; i < Model.ButtonPaymentMethodActionNames.Count; i++)
                            {
                                @Html.Action(Model.ButtonPaymentMethodActionNames[i], Model.ButtonPaymentMethodControllerNames[i], Model.ButtonPaymentMethodRouteValues[i])
                            }
                        }
                    </div>
                }
            </div>
            <div class="cart-collaterals">
                @if (Model.IsEditable)
                {
                    <div class="deals">
                        @if (Model.ShowDiscountBox)
                        {
                            using (Html.BeginRouteForm("ShoppingCart", FormMethod.Post))
                            {
                            <div class="coupon-box">
                                <b>@T("ShoppingCart.DiscountCouponCode")</b>
                                <br />@T("ShoppingCart.DiscountCouponCode.Tooltip")<br />
                                <input name="discountcouponcode" type="text" id="discountcouponcode" style="width: 125px;" />&nbsp;
                                <input type="submit" name="applydiscountcouponcode" value="@T("ShoppingCart.DiscountCouponCode.Button")" id="applydiscountcouponcode" class="applycouponcodebutton" />
                                @if (!String.IsNullOrEmpty(Model.DiscountWarning))
                                {
                                    <div class="warning-box">
                                        <div class="warning-text">
                                            <br />
                                            @Model.DiscountWarning
                                        </div>
                                    </div>
                                }
                            </div>
                            }
                        }
                        @if (Model.ShowGiftCardBox)
                        {
                            using (Html.BeginRouteForm("ShoppingCart", FormMethod.Post))
                            {
                            <div class="giftcard-box">
                                <b>@T("ShoppingCart.GiftCardCouponCode")</b>
                                <br />@T("ShoppingCart.GiftCardCouponCode.Tooltip")<br />
                                <input name="giftcardcouponcode" type="text" id="giftcardcouponcode" style="width: 125px;" />&nbsp;
                                <input type="submit" name="applygiftcardcouponcode" value="@T("ShoppingCart.GiftCardCouponCode.Button")" id="applygiftcardcouponcode" class="applycouponcodebutton" />
                                @if (!String.IsNullOrEmpty(Model.GiftCardWarning))
                                {
                                    <div class="warning-box">
                                        <div class="warning-text">
                                            <br />
                                            @Model.GiftCardWarning
                                        </div>
                                    </div>
                                }
                            </div>
                            }
                        }
                    </div>
                    @Html.Partial("EstimateShipping", Model.EstimateShipping)
                }
            </div>
            <div class="clear">
            </div>
            @Html.Action("CrossSellProducts", "Catalog")
        </div>
    }
    else
    {
        @T("ShoppingCart.CartIsEmpty")
    }
</div>
