﻿@using RevZone.Web.MVC.ViewModels.NotificationsTab
@using System.Web.UI.WebControls
@using DevExpress.Web
@using DevExpress.Web.Mvc
@using DevExpress.Web.Mvc.UI
@using RevZone.Core.Common
@model NotificationsViewModel

@{ 
    var firstName = "";
    var lastName = "";
    if (Model.UserData != null)
    {
        firstName = Model.UserData.FirstName;
        lastName = Model.UserData.LastName;
    }
}

@Html.DevExpress().PopupControl(settings =>
{
    settings.Name = "pcModalAddManuallyNotification";
    settings.HeaderText = T("AddManually").ToString();
    settings.AllowDragging = true;
    settings.CloseOnEscape = true;
    settings.Modal = true;
    settings.ShowFooter = true;
    settings.AutoUpdatePosition = true;
    settings.CloseAction = CloseAction.CloseButton;
    settings.PopupHorizontalAlign = PopupHorizontalAlign.WindowCenter;
    settings.PopupVerticalAlign = PopupVerticalAlign.WindowCenter;
    settings.Images.Header.SpriteProperties.CssClass = SystemConfig.GetSystemIcon();
    settings.Images.Header.Width = 16;

    settings.SetFooterTemplateContent(c =>
    {
        Html.DevExpress().FormLayout(formLayoutsettings =>
        {
            formLayoutsettings.Name = "pcModalAddManuallyNotificationFooter";
            formLayoutsettings.Width = Unit.Percentage(100);
            formLayoutsettings.ControlStyle.CssClass = "clearPaddings";
            formLayoutsettings.Styles.LayoutItem.CssClass = "clearPaddings";
            formLayoutsettings.Styles.LayoutGroup.CssClass = "clearPaddings";

            formLayoutsettings.Items.AddGroupItem(g =>
            {
                g.GroupBoxDecoration = GroupBoxDecoration.None;
                g.Paddings.Padding = Unit.Pixel(0);
                g.Items.Add(i =>
                {
                    i.ShowCaption = DefaultBoolean.False;
                }).SetNestedContent(() =>
                {
                    ViewContext.Writer.Write("<div class='buttonsContainer' style='padding-top: 0px'>");
                    Html.DevExpress().Button(s =>
                    {
                        s.Name = "btnAddManuallyOk";
                        s.Width = Unit.Pixel(90);
                        s.ControlStyle.CssClass = "cancelButton";
                        s.Text = T("OK").ToString();
                        s.ClientSideEvents.Click = "function(s, e){  Notifications.CloseAddManuallyNotification(s,e) }";
                    }).Render();
                    Html.DevExpress().Button(s =>
                    {
                        s.Name = "btnAddManuallyClose";
                        s.Width = Unit.Pixel(90);
                        s.ControlStyle.CssClass = "cancelButton";
                        s.Text = T("Cancel").ToString();
                        s.ClientSideEvents.Click = "function(s, e){ pcModalAddManuallyNotification.Hide() }";
                    }).Render();
                    ViewContext.Writer.Write("</div>");
                });
            });
        }).Render();
    });

    settings.Width = 360;
    settings.Height = 204;

    settings.MaxWidth = 360;
    settings.MaxHeight = 204;

    settings.SetContent(() =>
    {
        ViewContext.Writer.Write("<br/>");
        Html.DevExpress().TextBox(t =>
        {
            t.Name = "notificationAddManuallyFirstName";
            t.Properties.Caption = T("FirstName").ToString();
            t.Properties.CaptionSettings.Position = EditorCaptionPosition.Left;
            t.Width = Unit.Percentage(85);
            t.ClientVisible = true;
            t.Properties.ClientSideEvents.TextChanged = "function(s, e) { Notifications.FieldLengthValidation(notificationAddManuallyFirstName); }";
        }).Bind(firstName).GetHtml();

        ViewContext.Writer.Write("<br/>");

        Html.DevExpress().TextBox(t =>
        {
            t.Name = "notificationAddManuallyLastName";
            t.Properties.Caption = T("LastName").ToString();
            t.Properties.CaptionSettings.Position = EditorCaptionPosition.Left;
            t.Width = Unit.Percentage(85);
            t.ClientVisible = true;
            t.Properties.ClientSideEvents.TextChanged = "function(s, e) { Notifications.FieldLengthValidation(notificationAddManuallyLastName); }";
        }).Bind(lastName).GetHtml();
        ViewContext.Writer.Write("<br/>");

        if (Model.SmsChecked == false)
        {
            Html.DevExpress().TextBox(t =>
            {
                t.Name = "notificationAddManuallyEmail";
                t.Properties.Caption = T("Email").ToString();
                t.Properties.CaptionSettings.Position = EditorCaptionPosition.Left;
                t.Width = Unit.Percentage(85);
                t.ClientVisible = true;
                t.Properties.ClientSideEvents.TextChanged = "function(s, e) { Notifications.FieldLengthValidation(notificationAddManuallyEmail); }";
            }).GetHtml();
        }
        else
        {
            Html.DevExpress().TextBox(t =>
            {
                t.Name = "notificationAddManuallyTelephone";
                t.Properties.Caption = T("Telephone").ToString();
                t.Properties.CaptionSettings.Position = EditorCaptionPosition.Left;
                t.Width = Unit.Percentage(85);
                t.ClientVisible = true;
                t.Properties.ClientSideEvents.TextChanged = "function(s, e) { Notifications.FieldLengthValidation(notificationAddManuallyTelephone); }";
            }).GetHtml();
        }
    });
}).GetHtml();
