@using AutomatizovanySklad.Core.Entity
@model Web.Models.Subjekt.SubjektModel

@{
  Layout = "~/Views/Shared/_Layout.cshtml";
}

@using (Html.BeginForm()) {
  @Html.AntiForgeryToken()
  <hr />
  <div class="form-horizontal col-md-8">
    @Html.ValidationSummary(true, "", new { @class = "text-danger" })
    @Html.HiddenFor(model => model.Id)
    @Html.HiddenFor(model => model.Adresa.Id)
    @Html.HiddenFor(model => model.Kontakt.Id)
    @Html.HiddenFor(model => model.DatumUpravy)
    @Html.HiddenFor(model => model.DatumVytvoreni)
    @Html.HiddenFor(model => model.UpravilId)
    @Html.HiddenFor(model => model.VytvorilId)

    <div class="form-group">
      @Html.LabelFor(model => model.Jmeno, htmlAttributes: new { @class = "control-label col-md-3" })
      <div class="col-md-9">
        @Html.EditorFor(model => model.Jmeno, new { htmlAttributes = new { @class = "form-control" } })
        @Html.ValidationMessageFor(model => model.Jmeno, "", new { @class = "text-danger" })
      </div>
    </div>

    <div class="form-group">
      @Html.LabelFor(model => model.TypSubjektu, htmlAttributes: new { @class = "control-label col-md-3" })
      <div class="col-md-9">
        @Html.EnumDropDownListFor(model => model.TypSubjektu, "-- Vyber typ subjektu --", htmlAttributes: new { @id = "typSubjektuDropdown", @class = "form-control" })
        @Html.ValidationMessageFor(model => model.TypSubjektu, "", new { @class = "text-danger" })
      </div>
    </div>

    <div class="form-group">
      @Html.LabelFor(model => model.Adresa.Ulice, htmlAttributes: new { @class = "control-label col-md-3" })
      <div class="col-md-9">
        @Html.EditorFor(model => model.Adresa.Ulice, new { htmlAttributes = new { @class = "form-control" } })
        @Html.ValidationMessageFor(model => model.Adresa.Ulice, "", new { @class = "text-danger" })
      </div>
    </div>

    <div class="form-group">
      @Html.LabelFor(model => model.Adresa.Cislo, htmlAttributes: new { @class = "control-label col-md-3" })
      <div class="col-md-9">
        @Html.EditorFor(model => model.Adresa.Cislo, new { htmlAttributes = new { @class = "form-control" } })
        @Html.ValidationMessageFor(model => model.Adresa.Cislo, "", new { @class = "text-danger" })
      </div>
    </div>

    <div class="form-group">
      @Html.LabelFor(model => model.Adresa.Mesto, htmlAttributes: new { @class = "control-label col-md-3" })
      <div class="col-md-9">
        @Html.EditorFor(model => model.Adresa.Mesto, new { htmlAttributes = new { @class = "form-control" } })
        @Html.ValidationMessageFor(model => model.Adresa.Mesto, "", new { @class = "text-danger" })
      </div>
    </div>

    <div class="form-group">
      @Html.LabelFor(model => model.Adresa.PSC, htmlAttributes: new { @class = "control-label col-md-3" })
      <div class="col-md-9">
        @Html.EditorFor(model => model.Adresa.PSC, new { htmlAttributes = new { @class = "form-control" } })
        @Html.ValidationMessageFor(model => model.Adresa.PSC, "", new { @class = "text-danger" })
      </div>
    </div>

    @*@if (Model.TypSubjektu == TypSubjektu.Pravnicka) {*@
      <div id="Pravnicka">
        <div class="form-group">
          @Html.LabelFor(model => model.DIC, htmlAttributes: new { @class = "control-label col-md-3" })
          <div class="col-md-9">
            @Html.EditorFor(model => model.DIC, new { htmlAttributes = new { @class = "form-control" } })
            @Html.ValidationMessageFor(model => model.DIC, "", new { @class = "text-danger" })
          </div>
        </div>
        <div class="form-group">
          @Html.LabelFor(model => model.ICO, htmlAttributes: new { @class = "control-label col-md-3" })
          <div class="col-md-9">
            @Html.EditorFor(model => model.ICO, new { htmlAttributes = new { @class = "form-control" } })
            @Html.ValidationMessageFor(model => model.ICO, "", new { @class = "text-danger" })
          </div>
        </div>
      </div>
    @*}*@


    <div class="form-group">
      @Html.LabelFor(model => model.Poznamka, htmlAttributes: new { @class = "control-label col-md-3" })
      <div class="col-md-9">
        @Html.TextAreaFor(model => model.Poznamka, htmlAttributes: new { @class = "form-control", rows = 5 })
        @Html.ValidationMessageFor(model => model.Poznamka, "", new { @class = "text-danger" })
      </div>
    </div>

    <div class="form-group">
      @Html.LabelFor(model => model.Kontakt.Email, htmlAttributes: new { @class = "control-label col-md-3" })
      <div class="col-md-9">
        @Html.EditorFor(model => model.Kontakt.Email, new { htmlAttributes = new { @class = "form-control" } })
        @Html.ValidationMessageFor(model => model.Kontakt.Email, "", new { @class = "text-danger" })
      </div>
    </div>

    <div class="form-group">
      @Html.LabelFor(model => model.Kontakt.Telefon, htmlAttributes: new { @class = "control-label col-md-3" })
      <div class="col-md-9">
        @Html.EditorFor(model => model.Kontakt.Telefon, new { htmlAttributes = new { @class = "form-control" } })
        @Html.ValidationMessageFor(model => model.Kontakt.Telefon, "", new { @class = "text-danger" })
      </div>
    </div>

    <div class="form-group">
      @Html.LabelFor(model => model.Kontakt.Webovky, htmlAttributes: new { @class = "control-label col-md-3" })
      <div class="col-md-9">
        @Html.EditorFor(model => model.Kontakt.Webovky, new { htmlAttributes = new { @class = "form-control" } })
        @Html.ValidationMessageFor(model => model.Kontakt.Webovky, "", new { @class = "text-danger" })
      </div>
    </div>


    <div class="form-group">
      <div class="col-md-offset-2 col-md-10">
        @*@Html.ActionLink("Zrušit", "", new { id = Model.VybranyZamestnanecModel.Id }, htmlAttributes: new { @class = "btn btn-danger" })*@
        <input type="submit" value="Uložit" data-bind="enable: !!email()" class="btn btn-primary" />
      </div>
    </div>
    @Html.ActionLink("Zpět na Seznam subjektů ", "Index")
  </div>

  <div class="col-md-4"></div>
}

<script>
  $(document).ready(function () {
    var value = $('#typSubjektuDropdown').val();
      if (value === '0') {
        $('#Pravnicka').show();
      } else if (value === '1') {
        $('#Pravnicka').hide();
      } else {
        $('#Pravnicka').hide();
      };

    $('#typSubjektuDropdown').change(function (){
      var value = $(this).val();
      if (value === '0') {
        $('#Pravnicka').show();
      } else if (value === '1') {
        $('#Pravnicka').hide();
      } else {
        $('#Pravnicka').hide();
      }
    });
  });
</script>



