ildar-shaymukhametov_grandnode-refactorings/Grand.Web/Areas/Admin/Views/Customer/Edit.cshtml
@model CustomerModel
@inject Grand.Domain.Forums.ForumSettings forumsettings 
@{
    //page title
    ViewBag.Title = T("Admin.Customers.Customers.EditCustomerDetails").Text;
}
<form asp-area="@Constants.AreaAdmin" asp-controller="Customer" asp-action="Edit" method="post" id = "customer-form">
    
    <div class="row">
        <div class="col-md-12">
            <div class="x_panel light form-fit">
                <div class="x_title">
                    <div class="caption">
                        <i class="fa fa-user"></i>
                        @T("Admin.Customers.Customers.EditCustomerDetails") - @Model.LastName @Model.FirstName
                        <small><i class="fa fa-arrow-circle-left"></i>@Html.ActionLink(T("Admin.Customers.Customers.BackToList").Text, "List")</small>
                    </div>
                    <div class="actions">
                        <div class="btn-group btn-group-devided util-btn-margin-bottom-5">
                            <button class="btn btn-success" type="submit" name="save"><i class="fa fa-check"></i> @T("Admin.Common.Save") </button>
                            <button class="btn btn-success" type="submit" name="save-continue"><i class="fa fa-check-circle"></i> @T("Admin.Common.SaveContinue") </button>
                            <button class="btn btn-info" type="submit" id="sendemail"><i class="fa fa-paper-plane" aria-hidden="true"></i> &nbsp;@T("Admin.Customers.Customers.SendEmail") </button>
                            <button class="btn btn-info" type="submit" name="impersonate"><i class="fa fa-shopping-cart" aria-hidden="true"></i>&nbsp;@T("Admin.Customers.Customers.Impersonate.Button")</button>
                                @if (forumsettings.AllowPrivateMessages)
                                {
                                    <button class="btn btn-warning" type="submit" id="sendprivatemessage"><i class="fa fa-paper-plane" aria-hidden="true"></i> &nbsp;@T("Admin.Customers.Customers.SendPM") </button>
                                }
                                @if (Model.AllowSendingOfWelcomeMessage)
                                {
                                    <button class="btn btn-primary" type="submit" name="send-welcome-message" onclick="return confirm('@T("Admin.Common.AreYouSure")');"><span class="k-icon k-i-rotate"></span> &nbsp;@T("Admin.Customers.Customers.SendWelcomeMessage") </button>
                                }
                                @if (Model.AllowReSendingOfActivationMessage)
                                {
                                    <button class="btn btn-primary" type="submit" name="resend-activation-message" onclick="return confirm('@T("Admin.Common.AreYouSure")');"><span class="k-icon k-i-rotate"></span> &nbsp;@T("Admin.Customers.Customers.ReSendActivationMessage") </button>
                                }
                                <span id="customer-delete" class="btn red"><i class="fa fa-trash-o"></i><span class="d-none d-sm-inline"> @T("Admin.Common.Delete")</span></span>
                                <vc:admin-widget widget-zone="customer_details_buttons" additional-data="Model" />
                        </div>
                    </div>
                </div>
                <div class="x_content form">
                   <partial name="_CreateOrUpdate" model="Model" />
                </div>
            </div>
        </div>
    </div>
</form>
<admin-delete-confirmation button-id="customer-delete"/>

@*send email form*@
<div id="sendemail-window" style="display:none;">
    <form asp-area="@Constants.AreaAdmin" asp-controller="Customer" asp-action="SendEmail" method="post" asp-route-id="Id">

        <input type="hidden" asp-for="Id" id="sendemail_customerId" />
        <div class="form-horizontal">
            <div class="form-body">
                <div class="form-group">
                    <admin-label asp-for="SendEmail.Subject" />
                    <div class="col-md-9 col-sm-9">
                        <admin-input asp-for="SendEmail.Subject" />
                        <span asp-validation-for="SendEmail.Subject"></span>
                    </div>
                </div>
                <div class="form-group">
                    <admin-label asp-for="SendEmail.Body" />
                    <div class="col-md-9 col-sm-9">
                        <admin-textarea asp-for="SendEmail.Body"></admin-textarea>
                        <span asp-validation-for="SendEmail.Body"></span>
                    </div>
                </div>
                <div class="form-group">
                    <admin-label asp-for="SendEmail.SendImmediately" />
                    <div class="col-md-9 col-sm-9">
                        <admin-input asp-for="SendEmail.SendImmediately" />
                        <span asp-validation-for="SendEmail.SendImmediately"></span>
                    </div>
                </div>
                <div class="form-group" id="pnl-send-date">
                    <admin-label asp-for="SendEmail.DontSendBeforeDate" />
                    <div class="col-md-9 col-sm-9">
                        <admin-input asp-for="SendEmail.DontSendBeforeDate" />
                        <span asp-validation-for="SendEmail.DontSendBeforeDate"></span>
                    </div>
                </div>
            </div>
            <div class="form-actions">
                <div class="offset-md-3 offset-sm-3 col-md-6 col-sm-6">
                    <button type="submit" class="k-button"><span class="k-icon k-i-email"></span>&nbsp;@T("Admin.Customers.Customers.SendEmail")</button>
                </div>
            </div>
        </div>
    </form>
</div>
<script>
    $(document).ready(function () {
        $("#sendemail").click(function (e) {
            e.preventDefault();
            var window = $("#sendemail-window");
            if (!window.data("kendoWindow")) {
                window.kendoWindow({
                    modal: true,
                    width: "650px",
                    title: "@T("Admin.Customers.Customers.SendEmail")",
                    actions: ["Close"]
                });
            }
            window.data('kendoWindow').center().open();
        });
    });
</script>


@*send PM form*@
<div id="sendprivatemessage-window" style="display:none;">
                            <form asp-area="@Constants.AreaAdmin" asp-controller="Customer" asp-action="SendPm" method="post" asp-route-id="Id">

                                <input type="hidden" asp-for="Id" id="sendprivatemessage_customerId" />
                                <div class="form-horizontal">
                                    <div class="form-body">
                                        <div class="form-group">
                                            <admin-label asp-for="SendPm.Subject" class="control-label col-8 col-md-4 col-sm-4" />
                                            <div class="col-4 col-md-8 col-sm-8">
                                                <admin-input asp-for="SendPm.Subject" />
                                                <span asp-validation-for="SendPm.Subject"></span>
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <admin-label asp-for="SendPm.Message" class="control-label col-8 col-md-4 col-sm-4" />
                                            <div class="col-4 col-md-8 col-sm-8">
                                                <admin-textarea asp-for="SendPm.Message"></admin-textarea>
                                                <span asp-validation-for="SendPm.Message"></span>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="form-actions">
                                        <div class="offset-md-3 offset-sm-3 col-md-6 col-sm-6">
                                            <button type="submit" class="k-button"><span class="k-icon k-i-email-box"></span>&nbsp;@T("Admin.Customers.Customers.SendPM")</button>
                                        </div>
                                    </div>
                                </div>
                            </form>
</div>
<script>
    $(document).ready(function () {
        $("#sendprivatemessage").click(function (e) {
            e.preventDefault();
            var window = $("#sendprivatemessage-window");
            if (!window.data("kendoWindow")) {
                window.kendoWindow({
                    modal: true,
                    width: "500px",
                    title: "@T("Admin.Customers.Customers.SendPM")",
                    actions: ["Close"]
                });
            }
            window.data('kendoWindow').center().open();
        });
        $("#@Html.FieldIdFor(model => model.SendEmail.SendImmediately)").click(sendImmediately);
        sendImmediately();
    });

    function sendImmediately() {
        if ($('#@Html.FieldIdFor(model => model.SendEmail.SendImmediately)').is(':checked'))
            $('#pnl-send-date').hide();
        else
            $('#pnl-send-date').show();
    }
</script>