Browse Source

NEW Ajout des infos d'identité

julien.legrand 8 years ago
parent
commit
9153bc13a6

+ 4 - 0
CD67.FicheCollege.MVC/CD67.FicheCollege.MVC.csproj

@@ -159,6 +159,7 @@
     <Compile Include="Controllers\AdminController.cs" />
     <Compile Include="Controllers\CollegesController.cs" />
     <Compile Include="Controllers\HomeController.cs" />
+    <Compile Include="Controllers\IdentitesController.cs" />
     <Compile Include="Controllers\TerritoireController.cs" />
     <Compile Include="Controllers\TypeCollegeController.cs" />
     <Compile Include="Global.asax.cs">
@@ -169,6 +170,7 @@
     <Compile Include="Internal\Navigation.cs" />
     <Compile Include="Internal\UtilisateurConnecteFactory.cs" />
     <Compile Include="Models\CollegeViewModel.cs" />
+    <Compile Include="Models\ContactViewModel.cs" />
     <Compile Include="Models\ModeAcces.cs" />
     <Compile Include="Models\UtilisateurConnecte.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
@@ -373,6 +375,8 @@
     <Content Include="Views\Colleges\Details.cshtml" />
     <Content Include="Views\Colleges\Edit.cshtml" />
     <Content Include="Views\Colleges\Index.cshtml" />
+    <Content Include="Views\Identites\Details.cshtml" />
+    <Content Include="Views\Identites\Edit.cshtml" />
   </ItemGroup>
   <ItemGroup>
     <Folder Include="App_Data\" />

+ 12 - 0
CD67.FicheCollege.MVC/Content/cd67-custom.less

@@ -68,3 +68,15 @@ input[aria-required='true'], textarea[aria-required='true'] {
     text-align:center;
     margin:0;
 }
+
+.flex-list {
+    display: flex;
+    flex-direction: row;
+    flex-wrap: wrap;
+    justify-content: space-around;
+}
+
+.flex-col {
+    display: flex;
+    flex-direction: column;
+}

+ 99 - 0
CD67.FicheCollege.MVC/Controllers/IdentitesController.cs

@@ -0,0 +1,99 @@
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.Data.Entity;
+using System.Linq;
+using System.Net;
+using System.Web;
+using System.Web.Mvc;
+using CD67.FicheCollege.Entity;
+using CD67.FicheCollege.Factory;
+
+namespace CD67.FicheCollege.MVC.Controllers
+{
+    public class IdentitesController : Controller
+    {
+        private Entities db = new Entities();
+
+        // GET: Identite/Details/5
+        public ActionResult Details(string id)
+        {
+            if (id == null)
+            {
+                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
+            }
+            IdentiteFactory identiteFactory = new IdentiteFactory(db);
+            Entity.Identite identite = identiteFactory.getById(id);
+            if (identite == null)
+            {
+                return HttpNotFound();
+            }
+            return View(GetViewModel(identite, Models.ModeAcces.Lecture));
+        }
+
+        // GET: Identite/Edit/5
+        public ActionResult Edit(string id)
+        {
+            if (id == null)
+            {
+                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
+            }
+            IdentiteFactory identiteFactory = new IdentiteFactory(db);
+            Entity.Identite identite = identiteFactory.getById(id);
+            if (identite == null)
+            {
+                return HttpNotFound();
+            }
+            return View(GetViewModel(identite, Models.ModeAcces.Modification));
+        }
+
+        // POST: Identite/Edit/5
+        // Afin de déjouer les attaques par sur-validation, activez les propriétés spécifiques que vous voulez lier. Pour 
+        // plus de détails, voir  http://go.microsoft.com/fwlink/?LinkId=317598.
+        [HttpPost]
+        [ValidateAntiForgeryToken]
+        public ActionResult Edit(Entity.Identite Contenu)
+        {
+            if (ModelState.IsValid)
+            {
+                IdentiteFactory identiteFactory = new IdentiteFactory(db);
+                identiteFactory.update(ref Contenu);
+                return RedirectToAction("Details", new { Id = Contenu.College_Id });
+            }
+            return View(GetViewModel(Contenu, Models.ModeAcces.Modification));
+        }
+
+        private Models.CollegeViewModel GetViewModel(Entity.Identite entity, Models.ModeAcces Acces)
+        {
+            object contenu;
+            if (Acces == Models.ModeAcces.Lecture)
+            {
+                List<Models.ContactViewModel> listeContacts = new List<Models.ContactViewModel>();
+                if (entity.Principal_SID != null) listeContacts.Add(new Models.ContactViewModel("Principal", entity.Principal_SID, entity.Principal_Login, entity.Principal_Nom, entity.Principal_Prenom, entity.Principal_Email, entity.Principal_Tel, entity.Principal_Structure));
+                if (entity.Adjoint_SID != null) listeContacts.Add(new Models.ContactViewModel("Principal adjoint", entity.Adjoint_SID, entity.Adjoint_Login, entity.Adjoint_Nom, entity.Adjoint_Prenom, entity.Adjoint_Email, entity.Adjoint_Tel, entity.Adjoint_Structure));
+                if (entity.Gestionnaire_SID != null) listeContacts.Add(new Models.ContactViewModel("Gestionnaire", entity.Gestionnaire_SID, entity.Gestionnaire_Login, entity.Gestionnaire_Nom, entity.Gestionnaire_Prenom, entity.Gestionnaire_Email, entity.Gestionnaire_Tel, entity.Gestionnaire_Structure));
+                if (entity.Gestionnaire2_SID != null) listeContacts.Add(new Models.ContactViewModel("Gestionnaire n°2", entity.Gestionnaire2_SID, entity.Gestionnaire2_Login, entity.Gestionnaire2_Nom, entity.Gestionnaire2_Prenom, entity.Gestionnaire2_Email, entity.Gestionnaire2_Tel, entity.Gestionnaire2_Structure));
+                contenu = listeContacts;
+            }
+            else contenu = entity;
+
+            return new Models.CollegeViewModel()
+            {
+                College_Id = entity.College.Id,
+                College_Libelle = entity.College.Libelle,
+                Contenu = contenu,
+                Acces = Acces,
+                Listes = null
+            };
+        }
+
+        protected override void Dispose(bool disposing)
+        {
+            if (disposing)
+            {
+                db.Dispose();
+            }
+            base.Dispose(disposing);
+        }
+    }
+}

+ 31 - 0
CD67.FicheCollege.MVC/Models/ContactViewModel.cs

@@ -0,0 +1,31 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+
+namespace CD67.FicheCollege.MVC.Models
+{
+    public class ContactViewModel
+    {
+        public string Role { get; set; }
+        public string SID { get; set; }
+        public string Login { get; set; }
+        public string Nom { get; set; }
+        public string Prenom { get; set; }
+        public string Email { get; set; }
+        public string Tel { get; set; }
+        public string Structure { get; set; }
+
+        public ContactViewModel(string Role, string SID, string Login, string Nom, string Prenom, string Email, string Tel, string Structure)
+        {
+            this.Role = Role;
+            this.SID = SID;
+            this.Login = Login;
+            this.Nom = Nom;
+            this.Prenom = Prenom;
+            this.Email = Email;
+            this.Tel = Tel;
+            this.Structure = Structure;
+        }
+    }
+}

+ 5 - 0
CD67.FicheCollege.MVC/Mvc.sitemap

@@ -10,6 +10,11 @@
       <mvcSiteMapNode title="Détail d'un collège" controller="Colleges" action="Details" preservedRouteParameters="id" >
         <mvcSiteMapNode title="Edition d'un collège" controller="Colleges" action="Edit" preservedRouteParameters="id" />
         <mvcSiteMapNode title="Suppression d'un collège" controller="Colleges" action="Delete" preservedRouteParameters="id" />
+
+        <mvcSiteMapNode title="Identité" controller="Identites" action="Details" preservedRouteParameters="id" >
+          <mvcSiteMapNode title="Edition de l'identité" controller="Identites" action="Edit" preservedRouteParameters="id" />
+        </mvcSiteMapNode>
+          
       </mvcSiteMapNode>
     </mvcSiteMapNode>
 

+ 60 - 0
CD67.FicheCollege.MVC/Views/Identites/Details.cshtml

@@ -0,0 +1,60 @@
+@using CD67.FicheCollege.MVC.Models
+@model CollegeViewModel
+
+@{
+    ViewBag.Title = "Details";
+    Layout = "~/Views/Shared/_Layout.cshtml";
+    List<ContactViewModel> contenu = Model.Contenu as List<ContactViewModel>;
+}
+
+<!-- Menu de niveau 2 -->
+<div>
+    <ul id="menu-l2">
+        <li id="li-menu-l2"><a id="a-li-menu-l2" class="btn-sm" href="@Url.Action("Details", "Colleges", new { Id = Model.College_Id })">Général</a></li>
+        <li id="li-menu-l2"><a id="a-li-menu-l2-active" class="btn-sm" href="@Url.Action("Details", "Identites", new { Id = Model.College_Id })/">Identité</a></li>
+    </ul>
+</div>
+
+
+<h1>@Model.College_Libelle</h1>
+
+<fieldset>
+    <legend>
+        Identité du collège
+        @if (Model.Acces == ModeAcces.Lecture)
+        {
+            <div class="pull-right">
+                @Html.ActionLink("Modifier", "Edit", "Identites", new { Id = Model.College_Id }, new { @class = "btn btn-default" })
+            </div>
+        }
+    </legend>
+
+    @if (contenu.Count == 0)
+    {
+        <text>Aucun contact défini</text>
+    }
+    else
+    {
+        <div class="flex-list">
+            @foreach (var item in contenu)
+            {
+                <div style="width:400px !important">
+                    <div class="panel panel-default" style="overflow: hidden;">
+                        <div class="panel-heading clearfix">
+                            <h4 class="panel-title pull-left" style="padding-top: 7.5px;">
+                                <i class="fa fa-user color1" aria-hidden="true"></i>
+                                @Html.DisplayFor(model => item.Role)
+                            </h4>
+                        </div>
+                        <div class="panel-body" style="text-align: center;">
+                            <b>@Html.DisplayFor(model => item.Prenom) @Html.DisplayFor(model => item.Nom)</b><br />
+                            @Html.DisplayFor(model => item.Structure)<br />
+                            @Html.DisplayFor(model => item.Email)<br />
+                            Tel : @Html.DisplayFor(model => item.Tel)<br />
+                        </div>
+                    </div>
+                </div>
+            }
+        </div>
+    }
+</fieldset>

+ 207 - 0
CD67.FicheCollege.MVC/Views/Identites/Edit.cshtml

@@ -0,0 +1,207 @@
+@using CD67.FicheCollege.MVC.Models
+@model CollegeViewModel
+
+@{
+    ViewBag.Title = "Edit";
+    Layout = "~/Views/Shared/_Layout.cshtml";
+    Identite contenu = Model.Contenu as Identite;
+}
+
+<h1>@Model.College_Libelle</h1>
+
+@using (Html.BeginForm())
+{
+    @Html.AntiForgeryToken()
+    
+    <fieldset>
+        <legend>
+            Identité du collège - @Model.Acces.ToString()
+        </legend>
+        <div class="form-horizontal">
+            @Html.ValidationSummary(true, "", new { @class = "text-danger" })
+            @Html.HiddenFor(model => contenu.College_Id)
+
+            <div class="form-group">
+                @Html.Label("Principal et ajoint", htmlAttributes: new { @class = "control-label col-md-2" })
+
+                <div class="col-md-4" data-picker-type="principal">
+                    @Html.HiddenFor(model => contenu.Principal_SID, new { data_picker = "agent.id" })
+                    @Html.HiddenFor(model => contenu.Principal_Login, new { data_picker = "agent.login" })
+                    @Html.HiddenFor(model => contenu.Principal_Nom, new { data_picker = "agent.nom" })
+                    @Html.HiddenFor(model => contenu.Principal_Prenom, new { data_picker = "agent.prenom" })
+                    @Html.HiddenFor(model => contenu.Principal_Email, new { data_picker = "agent.mail" })
+                    @Html.HiddenFor(model => contenu.Principal_Structure, new { data_picker = "agent.chemin" })
+                    @Html.HiddenFor(model => contenu.Principal_Tel, new { data_picker = "agent.telephone" })
+                    <a class='modal-window' href="http://referentiel.bas-rhin.fr/picker/cd67/ad67/?type=principal" title="Selection du principal (nouvelle fenetre)">Sélectionner un principal</a>
+                    <br />
+                    <div class="panel panel-default" id="Principal_Panel" name="Principal_Panel" style="@if (contenu.Principal_SID == null) { <text>display: none;</text> }">
+                        <div class="panel-heading clearfix">
+                            <h4 class="panel-title pull-left" style="padding-top: 7.5px;">
+                                <i class="fa fa-user color1" aria-hidden="true"></i>
+                                Principal
+                            </h4>
+                            <div class="pull-right">
+                                <span class="glyphicon glyphicon-trash removeItem btn btn-danger btn-sm" aria-hidden="true" data-type="principal"></span>
+                            </div>
+                        </div>
+                        <div class="panel-body" style="text-align: center;">
+                            <b><span data-picker="agent.prenom">@contenu.Principal_Prenom</span> <span data-picker="agent.nom">@contenu.Principal_Nom</span></b>
+                            <br /><span data-picker="agent.chemin">@contenu.Principal_Structure</span>
+                            <br /><span data-picker="agent.mail">@contenu.Principal_Email</span>
+                            <br />Tel : <span data-picker="agent.telephone">@contenu.Principal_Tel</span>
+                        </div>
+                    </div>
+                </div>
+
+                <div class="col-md-4" data-picker-type="adjoint">
+                    @Html.HiddenFor(model => contenu.Adjoint_SID, new { data_picker = "agent.id" })
+                    @Html.HiddenFor(model => contenu.Adjoint_Login, new { data_picker = "agent.login" })
+                    @Html.HiddenFor(model => contenu.Adjoint_Nom, new { data_picker = "agent.nom" })
+                    @Html.HiddenFor(model => contenu.Adjoint_Prenom, new { data_picker = "agent.prenom" })
+                    @Html.HiddenFor(model => contenu.Adjoint_Email, new { data_picker = "agent.mail" })
+                    @Html.HiddenFor(model => contenu.Adjoint_Structure, new { data_picker = "agent.chemin" })
+                    @Html.HiddenFor(model => contenu.Adjoint_Tel, new { data_picker = "agent.telephone" })
+                    <a class='modal-window' href="http://referentiel.bas-rhin.fr/picker/cd67/ad67/?type=adjoint" title="Selection du principal adjoint (nouvelle fenetre)">Sélectionner un principal adjoint</a>
+                    <br />
+                    <div class="panel panel-default" id="Adjoint_Panel" name="Adjoint_Panel" style="@if (contenu.Adjoint_SID == null) { <text>display: none;</text> }">
+                        <div class="panel-heading clearfix">
+                            <h4 class="panel-title pull-left" style="padding-top: 7.5px;">
+                                <i class="fa fa-user color1" aria-hidden="true"></i>
+                                Principal adjoint
+                            </h4>
+                            <div class="pull-right">
+                                <span class="glyphicon glyphicon-trash removeItem btn btn-danger btn-sm" aria-hidden="true" data-type="adjoint"></span>
+                            </div>
+                        </div>
+                        <div class="panel-body" style="text-align: center;">
+                            <b><span data-picker="agent.prenom">@contenu.Adjoint_Prenom</span> <span data-picker="agent.nom">@contenu.Adjoint_Nom</span></b>
+                            <br /><span data-picker="agent.chemin">@contenu.Adjoint_Structure</span>
+                            <br /><span data-picker="agent.mail">@contenu.Adjoint_Email</span>
+                            <br />Tel : <span data-picker="agent.telephone">@contenu.Adjoint_Tel</span>
+                        </div>
+                    </div>
+                </div>
+            </div>
+
+            <div class="form-group">
+                @Html.Label("Gestionnaire et ajoint", htmlAttributes: new { @class = "control-label col-md-2" })
+
+                <div class="col-md-4" data-picker-type="gestionnaire">
+                    @Html.HiddenFor(model => contenu.Gestionnaire_SID, new { data_picker = "agent.id" })
+                    @Html.HiddenFor(model => contenu.Gestionnaire_Login, new { data_picker = "agent.login" })
+                    @Html.HiddenFor(model => contenu.Gestionnaire_Nom, new { data_picker = "agent.nom" })
+                    @Html.HiddenFor(model => contenu.Gestionnaire_Prenom, new { data_picker = "agent.prenom" })
+                    @Html.HiddenFor(model => contenu.Gestionnaire_Email, new { data_picker = "agent.mail" })
+                    @Html.HiddenFor(model => contenu.Gestionnaire_Structure, new { data_picker = "agent.chemin" })
+                    @Html.HiddenFor(model => contenu.Gestionnaire_Tel, new { data_picker = "agent.telephone" })
+                    <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>
+                    <br />
+                    <div class="panel panel-default" id="Gestionnaire_Panel" name="Gestionnaire_Panel" style="@if (contenu.Gestionnaire_SID == null) { <text>display: none;</text> }">
+                        <div class="panel-heading clearfix">
+                            <h4 class="panel-title pull-left" style="padding-top: 7.5px;">
+                                <i class="fa fa-user color1" aria-hidden="true"></i>
+                                Gestionnaire
+                            </h4>
+                            <div class="pull-right">
+                                <span class="glyphicon glyphicon-trash removeItem btn btn-danger btn-sm" aria-hidden="true" data-type="gestionnaire"></span>
+                            </div>
+                        </div>
+                        <div class="panel-body" style="text-align: center;">
+                            <b><span data-picker="agent.prenom">@contenu.Gestionnaire_Prenom</span> <span data-picker="agent.nom">@contenu.Gestionnaire_Nom</span></b>
+                            <br /><span data-picker="agent.chemin">@contenu.Gestionnaire_Structure</span>
+                            <br /><span data-picker="agent.mail">@contenu.Gestionnaire_Email</span>
+                            <br />Tel : <span data-picker="agent.telephone">@contenu.Gestionnaire_Tel</span>
+                        </div>
+                    </div>
+                </div>
+
+                <div class="col-md-4" data-picker-type="gestionnaire2">
+                    @Html.HiddenFor(model => contenu.Gestionnaire2_SID, new { data_picker = "agent.id" })
+                    @Html.HiddenFor(model => contenu.Gestionnaire2_Login, new { data_picker = "agent.login" })
+                    @Html.HiddenFor(model => contenu.Gestionnaire2_Nom, new { data_picker = "agent.nom" })
+                    @Html.HiddenFor(model => contenu.Gestionnaire2_Prenom, new { data_picker = "agent.prenom" })
+                    @Html.HiddenFor(model => contenu.Gestionnaire2_Email, new { data_picker = "agent.mail" })
+                    @Html.HiddenFor(model => contenu.Gestionnaire2_Structure, new { data_picker = "agent.chemin" })
+                    @Html.HiddenFor(model => contenu.Gestionnaire2_Tel, new { data_picker = "agent.telephone" })
+                    <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 n°2</a>
+                    <br />
+                    <div class="panel panel-default" id="Gestionnaire2_Panel" name="Gestionnaire2_Panel" style="@if (contenu.Gestionnaire2_SID == null) { <text>display: none;</text> }">
+                        <div class="panel-heading clearfix">
+                            <h4 class="panel-title pull-left" style="padding-top: 7.5px;">
+                                <i class="fa fa-user color1" aria-hidden="true"></i>
+                                Gestionnaire n°2
+                            </h4>
+                            <div class="pull-right">
+                                <span class="glyphicon glyphicon-trash removeItem btn btn-danger btn-sm" aria-hidden="true" data-type="gestionnaire2"></span>
+                            </div>
+                        </div>
+                        <div class="panel-body" style="text-align: center;">
+                            <b><span data-picker="agent.prenom">@contenu.Gestionnaire2_Prenom</span> <span data-picker="agent.nom">@contenu.Gestionnaire2_Nom</span></b>
+                            <br /><span data-picker="agent.chemin">@contenu.Gestionnaire2_Structure</span>
+                            <br /><span data-picker="agent.mail">@contenu.Gestionnaire2_Email</span>
+                            <br />Tel : <span data-picker="agent.telephone">@contenu.Gestionnaire2_Tel</span>
+                        </div>
+                    </div>
+                </div>
+            </div>
+
+            <div class="form-group">
+                <div class="col-md-offset-2 col-md-10">
+                    <input type="submit" value="@Model.Acces.EnumDisplayNameFor(MvcHtmlHelpers.DisplayValue.Prompt)" class="btn btn-default" /> |
+                    @Html.ActionLink("Annuler", "Details", new { Id = Model.College_Id })
+                </div>
+            </div>
+        </div>
+    </fieldset>
+}
+
+@section Scripts {
+    <script type="text/javascript">
+        $(".removeItem").click(function () {
+            switch ($(this).data("type")) {
+                case 'principal':
+                    $('#contenu_Principal_SID').val(null);
+                    $('#contenu_Principal_Login').val(null);
+                    $('#contenu_Principal_Nom').val(null);
+                    $('#contenu_Principal_Prenom').val(null);
+                    $('#contenu_Principal_Email').val(null);
+                    $('#contenu_Principal_Structure').val(null);
+                    $('#contenu_Principal_Tel').val(null);
+                    $('#Principal_Panel').hide();
+                    break;
+                case 'adjoint':
+                    $('#contenu_Adjoint_SID').val(null);
+                    $('#contenu_Adjoint_Login').val(null);
+                    $('#contenu_Adjoint_Nom').val(null);
+                    $('#contenu_Adjoint_Prenom').val(null);
+                    $('#contenu_Adjoint_Email').val(null);
+                    $('#contenu_Adjoint_Structure').val(null);
+                    $('#contenu_Adjoint_Tel').val(null);
+                    $('#Adjoint_Panel').hide();
+                    break;
+                case 'gestionnaire':
+                    $('#contenu_Gestionnaire_SID').val(null);
+                    $('#contenu_Gestionnaire_Login').val(null);
+                    $('#contenu_Gestionnaire_Nom').val(null);
+                    $('#contenu_Gestionnaire_Prenom').val(null);
+                    $('#contenu_Gestionnaire_Email').val(null);
+                    $('#contenu_Gestionnaire_Structure').val(null);
+                    $('#contenu_Gestionnaire_Tel').val(null);
+                    $('#Gestionnaire_Panel').hide();
+                    break;
+                case 'gestionnaire2':
+                    $('#contenu_Gestionnaire2_SID').val(null);
+                    $('#contenu_Gestionnaire2_Login').val(null);
+                    $('#contenu_Gestionnaire2_Nom').val(null);
+                    $('#contenu_Gestionnaire2_Prenom').val(null);
+                    $('#contenu_Gestionnaire2_Email').val(null);
+                    $('#contenu_Gestionnaire2_Structure').val(null);
+                    $('#contenu_Gestionnaire2_Tel').val(null);
+                    $('#Gestionnaire2_Panel').hide();
+                    break;
+                default:
+                    return false;
+            }
+        });
+    </script>
+}