@using GreenTree.Nachtragsmanagement.Web.Extensions

@model GreenTree.Nachtragsmanagement.Web.Models.Deviation.StatusDataModel

<div class="claimEditContainer">
	
	<script>
		function saveStatus() {
			var form = $("#statusEditForm");
			$(form).submit(function (e) {
				$.ajax({
					type: "POST",
					url: '@Url.Action("EditStatus", "Deviation")',
					data: form.serialize(),
					success: function (response) {
						setTimeout(function () {
							$(".claimEditContainer").remove();
							if (response == "success") {
								parent.callCustomEventListener('StatusDataCallbackEventReceiver');
							} else {
								$("body").append(response);
							}
						}, 200);
					}
				});
				e.preventDefault();
			});
			form.submit();
		}
	</script>

	@Html.DevExpress().PopupControl(s =>
{
	s.Name = "devPopupControlEditStatus";

	if (Model.Id == -1)
		s.HeaderText = "Neuen Status erstellen";
	else
		s.HeaderText = "\"" + Model.Description + "\" bearbeiten";

	s.Modal = true;
	s.Width = new Unit(250, UnitType.Pixel);
	s.CloseAction = CloseAction.CloseButton;
	s.PopupHorizontalAlign = PopupHorizontalAlign.WindowCenter;
	s.PopupVerticalAlign = PopupVerticalAlign.WindowCenter;
	s.AllowDragging = false;
	s.AllowResize = false;
	s.ShowFooter = false;
	s.ShowOnPageLoad = true;
	s.SetContent(() =>
	{
		using (Html.BeginForm("EditStatus", "Deviation", FormMethod.Post, new { id = "statusEditForm" }))
		{
			ViewContext.Writer.Write("<div class='editFormWrapper'>");

			ViewContext.Writer.Write("<input type=\"hidden\" value=\"" + Model.Id + "\" id=\"Id\" name=\"Id\" />");

			ViewContext.Writer.Write(Html.CustomLabelFor(m => m.Description, "Beschreibung:"));
			ViewContext.Writer.Write(Html.ValidationMessageFor(m => m.Description).ToHtmlString());
			Html.DevExpress().TextBoxFor(m => m.Description, t =>
			{
				t.Width = new Unit(100, UnitType.Percentage);
			}).Render();

			ViewContext.Writer.Write("<div class='inlineModelPropertyContainer'>");
			{
				ViewContext.Writer.Write("<div class='inlineModelProperty' style='width: 100%'>");
				{
					ViewContext.Writer.Write(Html.CustomLabelFor(m => m.IsDefault, "Ist Standard:"));
					ViewContext.Writer.Write("<div style=\"overflow: hidden\">");
					{
						ViewContext.Writer.Write("<div style=\"float: left\">");
						{
							Html.DevExpress().RadioButtonFor(m => m.IsDefault, t =>
							{
								t.Text = "Ja";
								t.GroupName = "isDefault";
							}).Render();
						}
						ViewContext.Writer.Write("</div>");

						ViewContext.Writer.Write("<div style=\"float: left; margin-left: 8px\">");
						{
							Html.DevExpress().RadioButton(t =>
							{
								t.Name = "isDefaultFalse";
								t.Text = "Nein";
								t.GroupName = "isDefault";
								t.Checked = !Model.IsDefault;
							}).Render();
						}
						ViewContext.Writer.Write("</div>");
					}
					ViewContext.Writer.Write("</div>");
				}
				ViewContext.Writer.Write("</div>");
			}
			ViewContext.Writer.Write("</div>");

			ViewContext.Writer.Write("<div class='inlineModelPropertyContainer'>");
			{
				ViewContext.Writer.Write("<div class='inlineModelProperty' style='width: 100%'>");
				{
					ViewContext.Writer.Write(Html.CustomLabelFor(m => m.IsZeroValue, "Ist ein \"0 Wert\"-Status:"));
					ViewContext.Writer.Write("<div style=\"overflow: hidden\">");
					{
						ViewContext.Writer.Write("<div style=\"float: left\">");
						{
							Html.DevExpress().RadioButtonFor(m => m.IsZeroValue, t =>
							{
								t.Text = "Ja";
								t.GroupName = "isZeroValue";
							}).Render();
						}
						ViewContext.Writer.Write("</div>");

						ViewContext.Writer.Write("<div style=\"float: left; margin-left: 8px\">");
						{
							Html.DevExpress().RadioButton(t =>
							{
								t.Name = "IsZeroValueFalse";
								t.Text = "Nein";
								t.GroupName = "isZeroValue";
								t.Checked = !Model.IsZeroValue;
							}).Render();
						}
						ViewContext.Writer.Write("</div>");
					}
					ViewContext.Writer.Write("</div>");
				}
				ViewContext.Writer.Write("</div>");
			}
			ViewContext.Writer.Write("</div>");

			ViewContext.Writer.Write("<div class='inlineModelPropertyContainer'>");
			{
				ViewContext.Writer.Write("<div class='inlineModelProperty' style='width: 100%'>");
				{
					ViewContext.Writer.Write(Html.CustomLabelFor(m => m.IsZeroSummarize, "Ist ein \"0 Summierung\"-Status:"));
					ViewContext.Writer.Write("<div style=\"overflow: hidden\">");
					{
						ViewContext.Writer.Write("<div style=\"float: left\">");
						{
							Html.DevExpress().RadioButtonFor(m => m.IsZeroSummarize, t =>
							{
								t.Text = "Ja";
								t.GroupName = "isZeroSummarize";
							}).Render();
						}
						ViewContext.Writer.Write("</div>");

						ViewContext.Writer.Write("<div style=\"float: left; margin-left: 8px\">");
						{
							Html.DevExpress().RadioButton(t =>
							{
								t.Name = "IsZeroSummarizeFalse";
								t.Text = "Nein";
								t.GroupName = "isZeroSummarize";
								t.Checked = !Model.IsZeroSummarize;
							}).Render();
						}
						ViewContext.Writer.Write("</div>");
					}
					ViewContext.Writer.Write("</div>");
				}
				ViewContext.Writer.Write("</div>");
			}
			ViewContext.Writer.Write("</div>");

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

			Html.RenderPartial(
				"~/Views/Shared/_PopupButtonPanel.cshtml",
				new GreenTree.Nachtragsmanagement.Web.Models.Global.PopupModel
				{
					PopupName = "devPopupControlEditStatus",
					AcceptFunction = "function (s, e) { saveStatus(); }"
				}
			);
		}
	});
	s.Styles.Content.Paddings.Padding = new Unit(0);
	s.Styles.ModalBackground.Opacity = 0;
}).GetHtml()
</div>