Edit.cshtml 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341
  1. @using CD67.FicheCollege.MVC.Models
  2. @model CollegeViewModel
  3. @{
  4. ViewBag.Title = "Les Collèges " + Model.Annee_Lib;
  5. Layout = "~/Views/Shared/_Layout.cshtml";
  6. College college = Model.Obj;
  7. }
  8. <header>
  9. @if (Model.Acces == ModeAcces.Modification)
  10. {
  11. <h2>@college.Libelle</h2>
  12. }
  13. else
  14. {
  15. <h2>Nouveau collège</h2>
  16. }
  17. </header>
  18. @using (Html.BeginForm())
  19. {
  20. @Html.AntiForgeryToken()
  21. <fieldset>
  22. <legend>
  23. Informations générales
  24. </legend>
  25. <div class="form-horizontal">
  26. @Html.ValidationSummary(true, "", new { @class = "text-danger" })
  27. @if (Model.Acces == ModeAcces.Modification)
  28. {
  29. @Html.HiddenFor(model => college.Id)
  30. }
  31. @Html.HiddenFor(model => college.Annee_Id)
  32. @Html.HiddenFor(model => college.TokenId)
  33. @Html.HiddenFor(model => college.RestaurationType_Id)
  34. <div class="form-group">
  35. @Html.LabelFor(model => college.CodeRne, htmlAttributes: new { @class = "control-label col-md-2" })
  36. <div class="col-md-10">
  37. @Html.EditorFor(model => college.CodeRne, new { htmlAttributes = new { @class = "form-control" } })
  38. @Html.ValidationMessageFor(model => college.CodeRne, "", new { @class = "text-danger" })
  39. </div>
  40. </div>
  41. <div class="form-group">
  42. @Html.LabelFor(model => college.Libelle, htmlAttributes: new { @class = "control-label col-md-2" })
  43. <div class="col-md-10">
  44. @Html.EditorFor(model => college.Libelle, new { htmlAttributes = new { @class = "form-control" } })
  45. @Html.ValidationMessageFor(model => college.Libelle, "", new { @class = "text-danger" })
  46. </div>
  47. </div>
  48. <div class="form-group">
  49. @Html.LabelFor(model => college.TypeCollege_Id, htmlAttributes: new { @class = "control-label col-md-2" })
  50. <div class="col-md-10">
  51. @Html.DropDownListFor(model => college.TypeCollege_Id, Model.Sel_TypesCollege, htmlAttributes: new { @class = "form-control" })
  52. @Html.ValidationMessageFor(model => college.TypeCollege_Id, "", new { @class = "text-danger" })
  53. </div>
  54. </div>
  55. <div class="form-group">
  56. @Html.LabelFor(model => college.Adresse, htmlAttributes: new { @class = "control-label col-md-2" })
  57. <div class="col-md-10">
  58. @Html.EditorFor(model => college.Adresse, new { htmlAttributes = new { @class = "form-control" } })
  59. @Html.ValidationMessageFor(model => college.Adresse, "", new { @class = "text-danger" })
  60. </div>
  61. </div>
  62. <div class="form-group">
  63. @Html.LabelFor(model => college.Territoire_Id, htmlAttributes: new { @class = "control-label col-md-2" })
  64. <div class="col-md-10">
  65. @Html.DropDownListFor(model => college.Territoire_Id, Model.Sel_Territoires, htmlAttributes: new { @class = "form-control" })
  66. @Html.ValidationMessageFor(model => college.Territoire_Id, "", new { @class = "text-danger" })
  67. </div>
  68. </div>
  69. @Html.HiddenFor(model => college.Commune_Insee, new { data_picker = "commune.insee" })
  70. @Html.TextBoxFor(model => college.Commune, new { data_picker = "commune.nom", @class = "special_hidden" }) @*On est obligé d'utiliser cette méthode bizzare pour cacher le champ, sinon pas de validation coté user (pas de validation des données sur les champs cachés)*@
  71. @Html.HiddenFor(model => college.Canton, new { data_picker = "commune.canton" })
  72. @Html.HiddenFor(model => college.Territoire_Id, new { data_picker = "commune.code_tad" })
  73. @Html.HiddenFor(model => college.TAD, new { data_picker = "commune.tad" })
  74. @Html.HiddenFor(model => college.CDC, new { data_picker = "commune.cdc" })
  75. <div class="form-group">
  76. @Html.LabelFor(model => college.Commune, htmlAttributes: new { @class = "control-label col-md-2 required" })
  77. <div class="col-md-4">
  78. <a class='modal-window-events' href="http://referentiel.bas-rhin.fr/picker/cd67/com67/" title="Selection commune (nouvelle fenetre)">Sélectionner une commune</a>
  79. <br />
  80. <div class="panel panel-default" id="Commune_Panel" name="Commune_Panel" style="@if (college.Commune_Insee == null) { <text>display: none;</text> }">
  81. <div class="panel-heading clearfix">
  82. <h4 class="panel-title pull-left" style="padding-top: 7.5px;">
  83. <i class="fa fa-map-marker color1" aria-hidden="true"></i>
  84. Localisation (commune)
  85. </h4>
  86. <div class="pull-right">
  87. <span class="glyphicon glyphicon-trash removeItem btn btn-danger btn-sm" aria-hidden="true" data-type="commune"></span>
  88. </div>
  89. </div>
  90. <div class="panel-body" style="text-align: center;">
  91. <span>
  92. <b><span data-picker="commune.nom">@college.Commune</span></b>
  93. <br />Canton : <span data-picker="commune.canton">@college.Canton</span>
  94. <br />TAD : <span data-picker="commune.tad">@college.TAD</span>
  95. <br />CDC : <span data-picker="commune.cdc">@college.CDC</span>
  96. </span>
  97. </div>
  98. </div>
  99. @Html.ValidationMessageFor(model => college.Commune, "", new { @class = "text-danger" })
  100. </div>
  101. </div>
  102. <div class="form-group">
  103. @Html.LabelFor(model => college.Code_Postal, htmlAttributes: new { @class = "control-label col-md-2" })
  104. <div class="col-md-10">
  105. Code(s) postal(aux) associé(s) à la commune
  106. @if (Model.Sel_CodesPostaux.Count() > 1)
  107. {
  108. <span id="CP-warning" class="text-danger">(attention, plusieurs choix possibles)</span>
  109. }
  110. : <input id="code_postaux" data-picker="commune.code_postal" value="@String.Join(" ,", Model.Sel_CodesPostaux.Select(i=> i.Text))" class="disabled-input-as-label" />
  111. <br />
  112. @Html.DropDownListFor(model => college.Code_Postal, Model.Sel_CodesPostaux, htmlAttributes: new { @class = "form-control" })
  113. @Html.ValidationMessageFor(model => college.Code_Postal, "", new { @class = "text-danger" })
  114. </div>
  115. </div>
  116. <div class="form-group">
  117. @Html.LabelFor(model => college.Tel, htmlAttributes: new { @class = "control-label col-md-2" })
  118. <div class="col-md-10">
  119. @Html.EditorFor(model => college.Tel, new { htmlAttributes = new { @class = "form-control" } })
  120. @Html.ValidationMessageFor(model => college.Tel, "", new { @class = "text-danger" })
  121. </div>
  122. </div>
  123. <div class="form-group">
  124. @Html.LabelFor(model => college.Fax, htmlAttributes: new { @class = "control-label col-md-2" })
  125. <div class="col-md-10">
  126. @Html.EditorFor(model => college.Fax, new { htmlAttributes = new { @class = "form-control" } })
  127. @Html.ValidationMessageFor(model => college.Fax, "", new { @class = "text-danger" })
  128. </div>
  129. </div>
  130. <div class="form-group">
  131. @Html.LabelFor(model => college.Email, htmlAttributes: new { @class = "control-label col-md-2" })
  132. <div class="col-md-10">
  133. @Html.EditorFor(model => college.Email, new { htmlAttributes = new { @class = "form-control" } })
  134. @Html.ValidationMessageFor(model => college.Email, "", new { @class = "text-danger" })
  135. </div>
  136. </div>
  137. <div class="form-group">
  138. <label class="control-label col-md-2" for="college_Email">Personnel</label>
  139. <div class="col-md-4" data-picker-type="principal">
  140. @Html.HiddenFor(model => college.PrincipalSid, new { data_picker = "agent.id" })
  141. <a class='modal-window' href="http://referentiel.bas-rhin.fr/picker/cd67/externes/?type=principal&query=organisation:%22Principaux%20de%20coll%C3%A8ges%22" title="Selection du principal (nouvelle fenetre)">Sélectionner un principal</a>
  142. <br />
  143. <div class="panel panel-default" id="Principal_Panel" name="Principal_Panel" style="@if (college.PrincipalSid == null) { <text>display: none;</text> }">
  144. <div class="panel-heading clearfix">
  145. <h4 class="panel-title pull-left" style="padding-top: 7.5px;">
  146. <i class="fa fa-user color1" aria-hidden="true"></i>
  147. @Html.LabelFor(model => college.PrincipalSid)
  148. </h4>
  149. <div class="pull-right">
  150. <span class="glyphicon glyphicon-trash removeItem btn btn-danger btn-sm" aria-hidden="true" data-type="principal"></span>
  151. </div>
  152. </div>
  153. <div class="panel-body" style="text-align: center;">
  154. <b><span data-picker="agent.prenom">@Html.DisplayFor(model => college.principal.Prenom)</span> <span data-picker="agent.nom">@Html.DisplayFor(model => college.principal.Nom)</span></b><br />
  155. <span data-picker="agent.chemin">@Html.DisplayFor(model => college.principal.Organisation)</span><br />
  156. <span data-picker="agent.mail">@Html.DisplayFor(model => college.principal.Mail)</span><br />
  157. <span data-picker="agent.telephone">@Html.DisplayFor(model => college.principal.Telephone)</span>
  158. </div>
  159. </div>
  160. </div>
  161. <div class="col-md-4" data-picker-type="adjoint">
  162. @Html.HiddenFor(model => college.AdjointSid, new { data_picker = "agent.id" })
  163. <a class='modal-window' href="http://referentiel.bas-rhin.fr/picker/cd67/externes/?type=adjoint&query=organisation:%22Principaux%20de%20coll%C3%A8ges%22" title="Selection du principal adjoint (nouvelle fenetre)">Sélectionner un principal adjoint</a>
  164. <br />
  165. <div class="panel panel-default" id="Adjoint_Panel" name="Adjoint_Panel" style="@if (college.AdjointSid == null) { <text>display: none;</text> }">
  166. <div class="panel-heading clearfix">
  167. <h4 class="panel-title pull-left" style="padding-top: 7.5px;">
  168. <i class="fa fa-user color1" aria-hidden="true"></i>
  169. @Html.LabelFor(model => college.AdjointSid)
  170. </h4>
  171. <div class="pull-right">
  172. <span class="glyphicon glyphicon-trash removeItem btn btn-danger btn-sm" aria-hidden="true" data-type="adjoint"></span>
  173. </div>
  174. </div>
  175. <div class="panel-body" style="text-align: center;">
  176. <b><span data-picker="agent.prenom">@Html.DisplayFor(model => college.adjoint.Prenom)</span> <span data-picker="agent.nom">@Html.DisplayFor(model => college.adjoint.Nom)</span></b><br />
  177. <span data-picker="agent.chemin">@Html.DisplayFor(model => college.adjoint.Organisation)</span><br />
  178. <span data-picker="agent.mail">@Html.DisplayFor(model => college.adjoint.Mail)</span><br />
  179. <span data-picker="agent.telephone">@Html.DisplayFor(model => college.adjoint.Telephone)</span>
  180. </div>
  181. </div>
  182. </div>
  183. </div>
  184. <div class="form-group">
  185. <div class="col-md-offset-2 col-md-4" data-picker-type="gestionnaire">
  186. @Html.HiddenFor(model => college.Gestionnaire1Sid, new { data_picker = "agent.id" })
  187. <a class='modal-window' href="http://referentiel.bas-rhin.fr/picker/cd67/ad67/?type=gestionnaire" title="Selection du gestionnaire (nouvelle fenetre)">Sélectionner un gestionnaire</a>
  188. <br />
  189. <div class="panel panel-default" id="Gestionnaire_Panel" name="Gestionnaire_Panel" style="@if (college.Gestionnaire1Sid == null) { <text>display: none;</text> }">
  190. <div class="panel-heading clearfix">
  191. <h4 class="panel-title pull-left" style="padding-top: 7.5px;">
  192. <i class="fa fa-user color1" aria-hidden="true"></i>
  193. @Html.LabelFor(model => college.Gestionnaire1Sid)
  194. </h4>
  195. <div class="pull-right">
  196. <span class="glyphicon glyphicon-trash removeItem btn btn-danger btn-sm" aria-hidden="true" data-type="gestionnaire"></span>
  197. </div>
  198. </div>
  199. <div class="panel-body" style="text-align: center;">
  200. <b><span data-picker="agent.prenom">@Html.DisplayFor(model => college.gestionnaire1.Prenom)</span> <span data-picker="agent.nom">@Html.DisplayFor(model => college.gestionnaire1.Nom)</span></b><br />
  201. <span data-picker="agent.chemin">@Html.DisplayFor(model => college.gestionnaire1.Organisation)</span><br />
  202. <span data-picker="agent.mail">@Html.DisplayFor(model => college.gestionnaire1.Mail)</span><br />
  203. <span data-picker="agent.telephone">@Html.DisplayFor(model => college.gestionnaire1.Telephone)</span>
  204. </div>
  205. </div>
  206. </div>
  207. <div class="col-md-4" data-picker-type="gestionnaire2">
  208. @Html.HiddenFor(model => college.Gestionnaire2Sid, new { data_picker = "agent.id" })
  209. <a class='modal-window' href="http://referentiel.bas-rhin.fr/picker/cd67/ad67/?type=gestionnaire2" title="Selection du gestionnaire n°2 (nouvelle fenetre)">Sélectionner un gestionnaire</a>
  210. <br />
  211. <div class="panel panel-default" id="Gestionnaire2_Panel" name="Gestionnaire2_Panel" style="@if (college.Gestionnaire2Sid == null) { <text>display: none;</text> }">
  212. <div class="panel-heading clearfix">
  213. <h4 class="panel-title pull-left" style="padding-top: 7.5px;">
  214. <i class="fa fa-user color1" aria-hidden="true"></i>
  215. @Html.LabelFor(model => college.Gestionnaire2Sid)
  216. </h4>
  217. <div class="pull-right">
  218. <span class="glyphicon glyphicon-trash removeItem btn btn-danger btn-sm" aria-hidden="true" data-type="gestionnaire2"></span>
  219. </div>
  220. </div>
  221. <div class="panel-body" style="text-align: center;">
  222. <b><span data-picker="agent.prenom">@Html.DisplayFor(model => college.gestionnaire2.Prenom)</span> <span data-picker="agent.nom">@Html.DisplayFor(model => college.gestionnaire2.Nom)</span></b><br />
  223. <span data-picker="agent.chemin">@Html.DisplayFor(model => college.gestionnaire2.Organisation)</span><br />
  224. <span data-picker="agent.mail">@Html.DisplayFor(model => college.gestionnaire2.Mail)</span><br />
  225. <span data-picker="agent.telephone">@Html.DisplayFor(model => college.gestionnaire2.Telephone)</span>
  226. </div>
  227. </div>
  228. </div>
  229. </div>
  230. </div>
  231. <br />
  232. <div class="form-group btn-bar">
  233. @if (Model.Acces == ModeAcces.Creation)
  234. {
  235. <a href=@Url.Action("Index", new { annee_id = college.Annee_Id }) class="btn btn-default">Annuler</a>
  236. }
  237. else
  238. {
  239. <a href=@Url.Action("Details", new { Id = college.Id }) class="btn btn-default">Annuler</a>
  240. }
  241. <input type="submit" value="Enregistrer" class="btn btn-primary" />
  242. </div>
  243. </fieldset>
  244. }
  245. @section Scripts {
  246. <script type="text/javascript">
  247. $(".removeItem").click(function () {
  248. switch ($(this).data("type")) {
  249. case 'commune':
  250. $('#contenu_Code_Postal').val(null);
  251. $('#contenu_Commune_Insee').val(null);
  252. $('#contenu_Commune').val(null);
  253. $('#contenu_Canton').val(null);
  254. $('#contenu_Territoire_Id').val(null);
  255. $('#contenu_TAD').val(null);
  256. $('#contenu_CDC').val(null);
  257. $('#Commune_Panel').hide();
  258. //suppression du champ en dessous
  259. $('#code_postaux').val(null);
  260. $('#contenu_Code_Postal').empty();
  261. $('#CP-warning').hide();
  262. break;
  263. case 'principal':
  264. $('#college_PrincipalSid').val(null);
  265. $('#Principal_Panel').hide();
  266. break;
  267. case 'adjoint':
  268. $('#college_AdjointSid').val(null);
  269. $('#Adjoint_Panel').hide();
  270. break;
  271. case 'gestionnaire':
  272. $('#college_Gestionnaire1Sid').val(null);
  273. $('#Gestionnaire_Panel').hide();
  274. break;
  275. case 'gestionnaire2':
  276. $('#college_Gestionnaire2Sid').val(null);
  277. $('#Gestionnaire2_Panel').hide();
  278. break;
  279. default:
  280. return false;
  281. }
  282. });
  283. // Function à implémenter pour éviter une erreur
  284. function onModalOpen() {
  285. $('#CP-warning').hide();
  286. }
  287. function onModalClose() {
  288. var code_postaux = $('#code_postaux').val();
  289. if (code_postaux != '') {
  290. //On vide la liste actuelle
  291. $('#college_Code_Postal').empty();
  292. var liste = code_postaux.split(',');
  293. liste.forEach(function (element) {
  294. //On ajoute les choix
  295. $('#college_Code_Postal').append($('<option>', {
  296. value: element,
  297. text: element
  298. }));
  299. });
  300. if (liste.length > 1) $('#CP-warning').show();
  301. }
  302. }
  303. </script>
  304. @Scripts.Render("~/bundles/jqueryval")
  305. }