@using CD67.FicheCollege.MVC.Models
@model RestaurationFormulaireViewModel

@{
    ViewBag.Title = "Restauration " + Model.Annee_Lib;
    Layout = "~/Views/Shared/_Layout.cshtml";
    RestaurationFormulaire form = Model.Obj;
    int anneePlus = ViewBag.AnneeEnCours + 1;
    int anneeMoins = ViewBag.AnneeEnCours - 1;
    RestaurationParametre param = ViewBag.Param;
    List<RestaurationFormulairesRepa> repas = Model.Obj.RestaurationFormulairesRepas.ToList();
}

<h2>
    La Restauration - @form.College.Libelle
    @if (form.College.RestaurationType_Id != null)
    {
        <text>(</text>@form.College.RestaurationType.Libelle<text>)</text>
    }
</h2>

<hr />

@using (Html.BeginForm())
{
    @Html.AntiForgeryToken()

    <div class="form-horizontal">
        <h4><b>PROPOSITIONS DE TARIFS DE RESTAURATION ET D'HEBERGEMENT POUR L'ANNEE @anneePlus</b></h4>
        <hr />
        @Html.ValidationSummary(true, "", new { @class = "text-danger" })
        @Html.HiddenFor(model => form.Id)
        @Html.HiddenFor(model => form.College_Id)
        @Html.HiddenFor(model => form.Statut)

        <b>I. Nombre de demi-pensionnaires</b><br /><br />
        <div class="form-group">
            @Html.LabelFor(model => form.NbDP_College, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => form.NbDP_College, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => form.NbDP_College, "", new { @class = "text-danger" })
            </div>
        </div>

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

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

        <div class="form-group">
            @Html.LabelFor(model => form.NbDP_Commensaux, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => form.NbDP_Commensaux, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => form.NbDP_Commensaux, "", new { @class = "text-danger" })
            </div>
        </div>
        <div class="form-group">
            @Html.LabelFor(model => form.NbDP_ATC, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => form.NbDP_ATC, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => form.NbDP_ATC, "", new { @class = "text-danger" })
            </div>
        </div>
        <div class="form-group">
            @Html.LabelFor(model => form.NbDP_AgentC, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => form.NbDP_AgentC, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => form.NbDP_AgentC, "", new { @class = "text-danger" })
            </div>
        </div>

        <hr />

        <b>II. Tarifs élèves @anneePlus</b><br /><br />
        <div class="form-group">
            <div class="col-md-12">
                <text>Prix des forfaits (prix unitaire <b>minimum</b> fixé à <b>@param.Prix_Mini €</b>)</text>
            </div>
        </div>

        <div class="form-group">
            <table id="table-actions" class="table">
                <thead>
                    <tr>
                        <th>
                            Forfait
                        </th>
                        <th>
                            Prix du forfait
                        </th>
                        <th>
                            Nombre de jours d'ouverture prévu de la demi-pension
                        </th>
                    </tr>
                </thead>
                <tbody>
                    <tr>
                        <td>
                            5 j
                        </td>
                        <td>
                            @Html.EditorFor(model => form.Prix_Forfait5j, new { htmlAttributes = new { @class = "form-control" } })
                            @Html.ValidationMessageFor(model => form.Prix_Forfait5j, "", new { @class = "text-danger" })
                        </td>
                        <td>
                            @Html.EditorFor(model => form.NbJours_Forfait5j, new { htmlAttributes = new { @class = "form-control" } })
                            @Html.ValidationMessageFor(model => form.NbJours_Forfait5j, "", new { @class = "text-danger" })
                        </td>
                    </tr>
                    <tr>
                        <td>
                            4 j
                        </td>
                        <td>
                            @Html.EditorFor(model => form.Prix_Forfait4j, new { htmlAttributes = new { @class = "form-control" } })
                            @Html.ValidationMessageFor(model => form.Prix_Forfait4j, "", new { @class = "text-danger" })
                        </td>
                        <td>
                            @Html.EditorFor(model => form.NbJours_Forfait4j, new { htmlAttributes = new { @class = "form-control" } })
                            @Html.ValidationMessageFor(model => form.NbJours_Forfait4j, "", new { @class = "text-danger" })
                        </td>
                    </tr>
                    <tr>
                        <td>
                            3 j
                        </td>
                        <td>
                            @Html.EditorFor(model => form.Prix_Forfait3j, new { htmlAttributes = new { @class = "form-control" } })
                            @Html.ValidationMessageFor(model => form.Prix_Forfait3j, "", new { @class = "text-danger" })
                        </td>
                        <td>
                            @Html.EditorFor(model => form.NbJours_Forfait3j, new { htmlAttributes = new { @class = "form-control" } })
                            @Html.ValidationMessageFor(model => form.NbJours_Forfait3j, "", new { @class = "text-danger" })
                        </td>
                    </tr>
                    <tr>
                        <td>
                            2 j
                        </td>
                        <td>
                            @Html.EditorFor(model => form.Prix_Forfait2j, new { htmlAttributes = new { @class = "form-control" } })
                            @Html.ValidationMessageFor(model => form.Prix_Forfait2j, "", new { @class = "text-danger" })
                        </td>
                        <td>
                            @Html.EditorFor(model => form.NbJours_Forfait2j, new { htmlAttributes = new { @class = "form-control" } })
                            @Html.ValidationMessageFor(model => form.NbJours_Forfait2j, "", new { @class = "text-danger" })
                        </td>
                    </tr>
                    <tr>
                        <td>
                            1 j
                        </td>
                        <td>
                            @Html.EditorFor(model => form.Prix_Forfait1j, new { htmlAttributes = new { @class = "form-control" } })
                            @Html.ValidationMessageFor(model => form.Prix_Forfait1j, "", new { @class = "text-danger" })
                        </td>
                        <td>
                            @Html.EditorFor(model => form.NbJours_Forfait1j, new { htmlAttributes = new { @class = "form-control" } })
                            @Html.ValidationMessageFor(model => form.NbJours_Forfait1j, "", new { @class = "text-danger" })
                        </td>
                    </tr>
                </tbody>
            </table>
        </div>

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

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

        <hr />

        <b>III. Tarifs « commensaux » @anneePlus</b><br /><br />
        <div class="form-group">
            @Html.LabelFor(model => form.Prix_ATC, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => form.Prix_ATC, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => form.Prix_ATC, "", new { @class = "text-danger" })
                <text><b>(défaut @param.Prix_ATC €)</b></text>
            </div>
        </div>
        <div class="form-group">
            @Html.LabelFor(model => form.Prix_AgentC, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => form.Prix_AgentC, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => form.Prix_AgentC, "", new { @class = "text-danger" })
                <text><b>(défaut @param.Prix_AgentC €)</b></text>
            </div>
        </div>
        <div class="form-group">
            @Html.LabelFor(model => form.Prix_Commensaux, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => form.Prix_Commensaux, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => form.Prix_Commensaux, "", new { @class = "text-danger" })
                <text><b>(minimum @param.Prix_MiniAutres €)</b></text>
            </div>
        </div>
        <div class="form-group">
            @Html.LabelFor(model => form.Prix_EcolePeri, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => form.Prix_EcolePeri, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => form.Prix_EcolePeri, "", new { @class = "text-danger" })
            </div>
        </div>

        <hr />

        <b>IV. Nombre de repas encaissés en @anneeMoins</b> (données STAR, PRESTO, ALISE)<br /><br />

        <div class="form-group">
            <table id="table-actions" class="table">
                <thead>
                    <tr>
                        <th>
                            Type de repas
                        </th>
                        <th>
                            Nombre de repas
                        </th>
                        <th>
                            Nombre de jours en @anneeMoins
                        </th>
                        <th>
                            Nom de l'établissement
                        </th>
                    </tr>
                </thead>
                <tbody>
                    @for (int i = 0; i < repas.Count(); i++)
                    {
                        <tr>
                            <td>
                                @repas[i].RestaurationTypesRepa.Libelle
                                @Html.HiddenFor(model => repas[i].Id)
                                @Html.HiddenFor(model => repas[i].RestaurationFormulaires_Id)
                                @Html.HiddenFor(model => repas[i].RestaurationTypesRepas_Id)
                            </td>
                            <td>
                                @Html.EditorFor(model => repas[i].NbRepas, new { htmlAttributes = new { @class = "form-control" } })
                                @Html.ValidationMessageFor(model => repas[i].NbRepas, "", new { @class = "text-danger" })
                            </td>
                            <td>
                                @Html.EditorFor(model => repas[i].NbJours, new { htmlAttributes = new { @class = "form-control" } })
                                @Html.ValidationMessageFor(model => repas[i].NbJours, "", new { @class = "text-danger" })
                            </td>
                            <td>
                                @Html.EditorFor(model => repas[i].NomEtablissement, new { htmlAttributes = new { @class = "form-control" } })
                                @Html.ValidationMessageFor(model => repas[i].NomEtablissement, "", new { @class = "text-danger" })
                            </td>
                        </tr>
                    }
                </tbody>
            </table>
        </div>

        <hr />

        <b>V. Participation au fond social ou impayés @anneeMoins</b><br /><br />

        <div class="form-group">
            <table id="table-actions" class="table">
                <thead>
                    <tr>
                        <th>
                        </th>
                        <th>
                            Fond social
                        </th>
                        <th>
                            Impayés
                        </th>
                    </tr>
                </thead>
                <tbody>
                    <tr>
                        <td>
                            Nombre d'élèves concernés
                        </td>
                        <td>
                            @Html.EditorFor(model => form.NbEleves_FondSocial, new { htmlAttributes = new { @class = "form-control" } })
                            @Html.ValidationMessageFor(model => form.NbEleves_FondSocial, "", new { @class = "text-danger" })
                        </td>
                        <td>
                            @Html.EditorFor(model => form.NbEleves_Impayes, new { htmlAttributes = new { @class = "form-control" } })
                            @Html.ValidationMessageFor(model => form.NbEleves_Impayes, "", new { @class = "text-danger" })
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Montant
                        </td>
                        <td>
                            @Html.EditorFor(model => form.Montant_FondSocial, new { htmlAttributes = new { @class = "form-control" } })
                            @Html.ValidationMessageFor(model => form.Montant_FondSocial, "", new { @class = "text-danger" })
                        </td>
                        <td>
                            @Html.EditorFor(model => form.Montant_Impayes, new { htmlAttributes = new { @class = "form-control" } })
                            @Html.ValidationMessageFor(model => form.Montant_Impayes, "", new { @class = "text-danger" })
                        </td>
                    </tr>
                </tbody>
            </table>
        </div>

        <hr />

        <div class="form-group">
            @Html.Label("Avis du conseil d'administration du collège recueilli en date du", htmlAttributes: new { @class = "control-label col-md-5" })

            <div class="col-md-7">
                @Html.EditorFor(model => form.Date_AvisCA, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => form.Date_AvisCA, "", new { @class = "text-danger" })
            </div>
        </div>

        <b>Signature du chef d'établissement : </b> <br /><br />
        <div class="form-group">
            <div class="col-md-1">
                @Html.EditorFor(model => form.Ind_Signature, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => form.Ind_Signature, "", new { @class = "text-danger" })
            </div>
            @Html.LabelFor(model => form.Ind_Signature, htmlAttributes: new { @class = "control-label" })
        </div>

        <div class="form-group btn-bar">
            <a href=@Url.Action("Index", "Restauration", new { annee_id = form.College.Annee_Id }) class="btn btn-default">Annuler</a>
            <input type="submit" value="Enregistrer" class="btn btn-primary" />
        </div>

    </div>
}