Edit.cshtml 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. @using CD67.FicheCollege.MVC.Models
  2. @model CollegeViewModel
  3. @{
  4. ViewBag.Title = "Ajout";
  5. Layout = "~/Views/Shared/_Layout.cshtml";
  6. College college = Model.Contenu as College;
  7. }
  8. <h2>@Model.Acces.ToString()</h2>
  9. @using (Html.BeginForm())
  10. {
  11. @Html.AntiForgeryToken()
  12. <div class="form-horizontal">
  13. <h4>Collège</h4>
  14. <hr />
  15. @Html.ValidationSummary(true, "", new { @class = "text-danger" })
  16. @if (Model.Acces == ModeAcces.Modification)
  17. {
  18. @Html.HiddenFor(model => college.Id)
  19. }
  20. <div class="form-group">
  21. @Html.LabelFor(model => college.Id, htmlAttributes: new { @class = "control-label col-md-2" })
  22. <div class="col-md-10">
  23. @if (Model.Acces == ModeAcces.Modification)
  24. {
  25. @Html.EditorFor(model => college.Id, new { htmlAttributes = new { @class = "form-control", @disabled = true } })
  26. }
  27. else
  28. {
  29. @Html.EditorFor(model => college.Id, new { htmlAttributes = new { @class = "form-control" } })
  30. }
  31. @Html.ValidationMessageFor(model => college.Id, "", new { @class = "text-danger" })
  32. </div>
  33. </div>
  34. <div class="form-group">
  35. @Html.LabelFor(model => college.Libelle, htmlAttributes: new { @class = "control-label col-md-2" })
  36. <div class="col-md-10">
  37. @Html.EditorFor(model => college.Libelle, new { htmlAttributes = new { @class = "form-control" } })
  38. @Html.ValidationMessageFor(model => college.Libelle, "", new { @class = "text-danger" })
  39. </div>
  40. </div>
  41. <div class="form-group">
  42. @Html.LabelFor(model => college.TypeCollege_Id, htmlAttributes: new { @class = "control-label col-md-2" })
  43. <div class="col-md-10">
  44. @Html.DropDownListFor(model => college.TypeCollege_Id, Model.Listes["TypeCollege_Id"], htmlAttributes: new { @class = "form-control" })
  45. @Html.ValidationMessageFor(model => college.TypeCollege_Id, "", new { @class = "text-danger" })
  46. </div>
  47. </div>
  48. <div class="form-group">
  49. @Html.LabelFor(model => college.Adresse, htmlAttributes: new { @class = "control-label col-md-2" })
  50. <div class="col-md-10">
  51. @Html.EditorFor(model => college.Adresse, new { htmlAttributes = new { @class = "form-control" } })
  52. @Html.ValidationMessageFor(model => college.Adresse, "", new { @class = "text-danger" })
  53. </div>
  54. </div>
  55. @Html.HiddenFor(model => college.Code_Postal, new { data_picker = "commune.code_postal" })
  56. @Html.HiddenFor(model => college.Commune_Insee, new { data_picker = "commune.insee" })
  57. @Html.HiddenFor(model => college.Commune, new { data_picker = "commune.nom" })
  58. @Html.HiddenFor(model => college.Canton, new { data_picker = "commune.canton" })
  59. @Html.HiddenFor(model => college.Territoire_Id, new { data_picker = "commune.code_tad" })
  60. @Html.HiddenFor(model => college.TAD, new { data_picker = "commune.tad" })
  61. @Html.HiddenFor(model => college.CDC, new { data_picker = "commune.cdc" })
  62. <div class="form-group">
  63. @Html.LabelFor(model => college.Commune, htmlAttributes: new { @class = "control-label col-md-2 required" })
  64. <div class="col-md-4">
  65. <a class='modal-window' href="http://referentiel.bas-rhin.fr/picker/cd67/com67/" title="Selection commune (nouvelle fenetre)">Sélectionner une commune</a>
  66. <br />
  67. <div class="panel panel-default" id="Commune_Panel" name="Commune_Panel" style="@if (college.Commune_Insee == null) { <text>display: none;</text> }">
  68. <div class="panel-heading clearfix">
  69. <h4 class="panel-title pull-left" style="padding-top: 7.5px;">
  70. <i class="fa fa-map-marker color1" aria-hidden="true"></i>
  71. Localisation (commune)
  72. </h4>
  73. <div class="pull-right">
  74. <span class="glyphicon glyphicon-trash removeItem btn btn-danger btn-sm" aria-hidden="true" data-type="commune"></span>
  75. </div>
  76. </div>
  77. <div class="panel-body" style="text-align: center;">
  78. <span>
  79. <b><span data-picker="commune.nom">@college.Commune</span ></b >
  80. <br />Canton : <span data-picker="commune.canton">@college.Canton</span >
  81. <br />TAD : <span data-picker="commune.tad">@college.TAD</span >
  82. <br />CDC : <span data-picker="commune.cdc">@college.CDC</span >
  83. </span>
  84. </div>
  85. </div>
  86. @Html.ValidationMessageFor(model => college.Commune, "", new { @class = "text-danger" })
  87. </div>
  88. </div>
  89. <div class="form-group">
  90. @Html.LabelFor(model => college.Tel, htmlAttributes: new { @class = "control-label col-md-2" })
  91. <div class="col-md-10">
  92. @Html.EditorFor(model => college.Tel, new { htmlAttributes = new { @class = "form-control" } })
  93. @Html.ValidationMessageFor(model => college.Tel, "", new { @class = "text-danger" })
  94. </div>
  95. </div>
  96. <div class="form-group">
  97. @Html.LabelFor(model => college.Fax, htmlAttributes: new { @class = "control-label col-md-2" })
  98. <div class="col-md-10">
  99. @Html.EditorFor(model => college.Fax, new { htmlAttributes = new { @class = "form-control" } })
  100. @Html.ValidationMessageFor(model => college.Fax, "", new { @class = "text-danger" })
  101. </div>
  102. </div>
  103. <div class="form-group">
  104. @Html.LabelFor(model => college.Email, htmlAttributes: new { @class = "control-label col-md-2" })
  105. <div class="col-md-10">
  106. @Html.EditorFor(model => college.Email, new { htmlAttributes = new { @class = "form-control" } })
  107. @Html.ValidationMessageFor(model => college.Email, "", new { @class = "text-danger" })
  108. </div>
  109. </div>
  110. <div class="form-group">
  111. <div class="col-md-offset-2 col-md-10">
  112. <input type="submit" value="@Model.Acces.EnumDisplayNameFor(MvcHtmlHelpers.DisplayValue.Prompt)" class="btn btn-default" /> |
  113. @if (Model.Acces == ModeAcces.Creation)
  114. { @Html.ActionLink("Annuler", "Index") }
  115. else
  116. { @Html.ActionLink("Annuler", "Details", new { Id = Model.College_Id }) }
  117. </div>
  118. </div>
  119. </div>
  120. }
  121. @section Scripts {
  122. <script type="text/javascript">
  123. $(".removeItem").click(function () {
  124. switch ($(this).data("type")) {
  125. case 'commune':
  126. $('#Code_Postal').val(null);
  127. $('#Commune_Insee').val(null);
  128. $('#Commune').val(null);
  129. $('#Canton').val(null);
  130. $('#Territoire_Id').val(null);
  131. $('#TAD').val(null);
  132. $('#CDC').val(null);
  133. $('#Commune_Panel').hide();
  134. break;
  135. default:
  136. return false;
  137. }
  138. });
  139. </script>
  140. @Scripts.Render("~/bundles/jqueryval")
  141. }