@using GreenTree.Nachtragsmanagement.Web.Extensions

@model GreenTree.Nachtragsmanagement.Web.Models.Appendix.OrderInvoiceCreatedDataModel

<div class="editOrderInvoiceCreatedContainer">

	<script>

		function saveOrderInvoiceCreated() {
			var form = $("#orderInvoiceCreatedEditForm");
			$(form).submit(function (e) {
				$.ajax({
					type: "POST",
					url: '@Url.Action("EditOrderInvoiceCreated", "Appendix")',
					data: form.serialize(),
					success: function (response) {
						setTimeout(function () {
							$(".editOrderInvoiceCreatedContainer").remove();
							if (response == "success") {
								if (typeof editOrderInvoiceCreatedCallback === 'function') {
									editOrderInvoiceCreatedCallback();
								}
							} else {
								$("body").append(response);
							}
						}, 200);
					}
				});
				e.preventDefault();
			});
			form.submit();
		}

	</script>

	@Html.DevExpress().PopupControl(p =>
{
	p.Name = "devPopupControlEditOrderInvoiceCreated";
	p.HeaderText = "Abschlagsrechnung gestellt";
	p.ShowHeader = true;
	p.ShowFooter = false;
	p.Modal = true;
	p.Width = new Unit(350, UnitType.Pixel);
	p.MinHeight = new Unit(150, UnitType.Pixel);
	p.ShowOnPageLoad = true;
	p.SetContent(() =>
	{
		using (Html.BeginForm("EditOrderInvoiceCreated", "Appendix", FormMethod.Post, new { id = "orderInvoiceCreatedEditForm" }))
		{
			ViewContext.Writer.Write("<div class='editFormWrapper'>");

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

			ViewContext.Writer.Write(Html.CustomLabelFor(m => m.OrderInvoiceCreated, "AR gestellt:"));
			ViewContext.Writer.Write("<div style=\"overflow: hidden\">");
			{
				ViewContext.Writer.Write("<div style=\"float: left\">");
				{
					Html.DevExpress().RadioButtonFor(m => m.OrderInvoiceCreated, t =>
					{
						t.Text = "Ja";
						t.GroupName = "orderInvoiceCreated";
					}).Render();
				}
				ViewContext.Writer.Write("</div>");

				ViewContext.Writer.Write("<div style=\"float: left; margin-left: 8px\">");
				{
					Html.DevExpress().RadioButton(t =>
					{
						t.Name = "orderInvoiceCreatedFalse";
						t.Text = "Nein";
						t.GroupName = "orderInvoiceCreated";
						t.Checked = !Model.OrderInvoiceCreated;
					}).Render();
				}
				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 = "devPopupControlEditOrderInvoiceCreated",
					AcceptFunction = "function (s, e) { saveOrderInvoiceCreated(); }"
				}
			);
		}
	});
	p.CloseAction = CloseAction.CloseButton;
	p.PopupHorizontalAlign = PopupHorizontalAlign.WindowCenter;
	p.PopupVerticalAlign = PopupVerticalAlign.WindowCenter;
	p.Styles.Content.Paddings.Padding = new Unit(0, UnitType.Pixel);
	p.Styles.ModalBackground.Opacity = 0;
}).GetHtml()

</div>