﻿@using System.Drawing
@using System.Web.UI.WebControls
@using RevZone.Core.Common
@using RevZone.Web.MVC.ViewModels.PropertyCard
@model PropertyCardSettingsViewModel
@if (Model.ObjectId != 0)
{
    <div class="row">
        <div class="col-md-12">
            @{
                Html.RenderAction("GetFieldTypeGroupsNew", "Properties", new { objectId = Model.ObjectId, recordId = Model.IdRecord, actionToPerform = RevZone.Web.MVC.Common.Properties.ActionToPerform.NewFrom, subObjectGuid = Model.SubObjectGuid });
            }
        </div>
    </div>
    
    <div class="row">
        <div class="col-lg-9 col-md-8" style="padding-right: 0 !important;">
            @using (Html.BeginForm("NewFromSave", "Properties", new { objectId = Model.ObjectId, recordId = Model.IdRecord, recordGuid = Model.RecordGuid, parentRecordId = Model.parentRecordId }, FormMethod.Post, new
            {
                @class = "form-horizontal",
                role = "form",
                id = "FormSubmitGroupFieldsNewFrom",
                onsubmit = "AjaxStatus.OnFormSubmit(event)",
                name = "NewFromSubmitForm"

            }))
            {
                Html.RenderAction("Edit", "Properties", new { objectId = Model.ObjectId, recordId = Model.IdRecord, isPreviewMode = Model.IsPreviewMode, hasEditRights = Model.HasEditRights, getFields = false, ActionToPerform = RevZone.Web.MVC.Common.Properties.ActionToPerform.NewFrom, keepNbs = Model.KeepNbs, parentRecordId = Model.parentRecordId });
                ViewContext.Writer.Write("<div id='_pcModalCascadingValues'></div>");
            }
        </div>
        <div class="col-lg-3  col-md-4" style="height: 100%;">
            <div style="margin-bottom: 20px;"></div>
            @Html.DevExpress().Label(labelCopySettings =>
              {
                  labelCopySettings.Name = "whatToCopyLabel";
                  labelCopySettings.Text = T("WhatDoYouWantToCopy").ToString();
                  labelCopySettings.ControlStyle.Font.Bold = true;
              }).GetHtml()
            <div style="margin-bottom: 20px;"></div>
            @{
                Html.DevExpress().Panel(panelSettings =>
                {
                    panelSettings.Name = "treeListPanel";
                    panelSettings.Width = Unit.Percentage(100);
                    panelSettings.Height = Unit.Pixel(450);
                    panelSettings.ScrollBars = ScrollBars.Both;
                    panelSettings.Styles.Panel.BorderWidth = Unit.Pixel(1);

                    panelSettings.SetContent(() =>
                    {
                        Html.RenderPartial("../NewFrom/_NewFromTreeList", Model);

                    });
                }).GetHtml();
            }
            <div style="margin-bottom: 20px;"></div>
            @Html.DevExpress().CheckBox(checkBoxCopySettings =>
               {
                   checkBoxCopySettings.Name = "checkBoxAutonumber";
                   checkBoxCopySettings.Text = T("DoNotIncrementAutonumber").ToString();
                   checkBoxCopySettings.Properties.ClientSideEvents.CheckedChanged = "newFrom.Events.keepNbsChanged";
                   checkBoxCopySettings.Checked = Model.KeepNbs;
                   checkBoxCopySettings.Enabled = (int)Model.ObjectType != (int)ObjectTypes.SWPDM;
               }).GetHtml()

        <div style="margin-left: 23px;margin-top:10px">
            @Html.DevExpress().Label(settings =>
            {
                settings.Name = "LblAutoNumber";
                settings.Text = "No previous Autonumber has been saved for this record.";
                settings.ClientVisible = false;
                settings.ControlStyle.ForeColor = Color.Chocolate;
                settings.Width = Unit.Percentage(100);
            }).GetHtml()
            @Html.DevExpress().TextBox(txtSettings =>
            {
                txtSettings.Name = "useThisAutoNumberTextBox";
                txtSettings.Text = T("UseThisAutonumber").ToString();
                txtSettings.Properties.CaptionSettings.Position = EditorCaptionPosition.Top;
                txtSettings.Properties.Caption = T("UseThisAutonumber").ToString();
                txtSettings.ClientVisible = false;
            }).Bind(Model.Nbs).GetHtml()
        </div>
            
            @*<div style="margin-bottom: 20px;"></div>*@
        </div>
    </div>
    <div class="spacer"></div>

    <hr style="margin-top: 0px;  margin-bottom: 0px;" />
    <div class="row">
        <div class="col-md-8 form-group" style="margin-bottom: 0px;">
            @Html.DevExpress().CheckBox(checkBoxCopySettings =>
            {
                checkBoxCopySettings.Name = "checkBoxCopy";
                checkBoxCopySettings.Text = T("CopyOriginalPrimaryFile").ToString();
                checkBoxCopySettings.Enabled = (int)Model.ObjectType != (int)ObjectTypes.SWPDM;

                //will be changed when "copy original promary file" will be implemented
                //checkBoxCopySettings.ClientEnabled = false;
                //checkBoxCopySettings.Checked = true;

                if (Model.ObjectType == ObjectTypes.Records)
                {
                    checkBoxCopySettings.ClientEnabled = false;
                }
                else
                {
                    checkBoxCopySettings.Checked = true;
                }
                if (!string.IsNullOrEmpty(Model.ConfigGuid))
                {
                    checkBoxCopySettings.ClientEnabled = false;
                }
                else
                {
                    if (Model.ObjectType != ObjectTypes.Documents)
                    {
                        checkBoxCopySettings.ClientEnabled = false;
                    }
                    else
                    {
                        checkBoxCopySettings.ClientEnabled = true;
                    }
                }
            }).GetHtml()
            <div class="spacer"></div>
            @Html.DevExpress().Label(labelCopySettings =>
            {
                labelCopySettings.Name = "labelCopy";
                labelCopySettings.Text = T("UncheckToSelectADifferentFile").ToString();

                if (Model.ObjectType == ObjectTypes.Records)
                {
                    labelCopySettings.ClientEnabled = false;
                }

            }).GetHtml()
        </div>
        <div class="col-md-4 form-group" style="margin-bottom: 0px;">
            @Html.DevExpress().CheckBox(checkBoxCopySettings =>
            {
                checkBoxCopySettings.Name = "cmbKeepCheckOut";
                checkBoxCopySettings.Text = T("KeepCheckedOut").ToString();
                checkBoxCopySettings.Checked=(int)Model.ObjectType == (int)ObjectTypes.SWPDM;

                if(!string.IsNullOrEmpty(Model.ConfigGuid))
                {
                    checkBoxCopySettings.ClientEnabled = false;
                    checkBoxCopySettings.Checked = true;
                }
                //else
                //{
                //    if (Model.ObjectType != ObjectTypes.Documents)
                //    {
                //        checkBoxCopySettings.ClientEnabled = false;
                //    }
                //    else
                //    {
                //        checkBoxCopySettings.ClientEnabled = true;
                //    }
                //}
            }).GetHtml()
            <div class="spacer"></div>
            @Html.DevExpress().CheckBox(checkBoxCopySettings =>
            {
                     checkBoxCopySettings.Name = "cmbOpenAfterSave";
                     checkBoxCopySettings.Text = T("OpenAfterSave").ToString();
                     checkBoxCopySettings.Checked=(int)Model.ObjectType == (int)ObjectTypes.SWPDM;
            }).GetHtml()
        </div>
    </div>
    @*  Render the Popup ObjectTypeField*@
    <div id="@("_pcModalObjectType" + (int)RevZone.Web.MVC.Common.Properties.ActionToPerform.NewFrom)"></div>
}