prasadnarwadkar_ASPNETCorePostgreSQL/ASPNETIdentityPostgres/Areas/ADT/Views/Patients/CamundaMyEmpEvals.cshtml
@model IEnumerable<ASPNETIdentityPostgres.Areas.ADT.Models.ProcessInstance>

@{
    ViewData["Title"] = "My Employee Evaluations";

    var username = User.Identity.Name;

    var bpmRole = "";

    var mapping = ASPNETIdentityPostgres.Areas.ADT.Models.WebAppAndBPMUserMap.mappings.FirstOrDefault(m => m.UserNameOnWebApp.ToLower() == username.ToLower());

    if (mapping != null)
    {
        bpmRole = mapping.UserRoleOnjBPMEngineOrApp;
    }
}

<div class="modal" tabindex="-1" role="dialog" id="exampleModal">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title">Camunda Engine must be running</h5>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
            <div class="modal-body">
                <p class="small">This example uses Camunda RESTful API and the Employee Evaluation process is executed from within this web app using that API.</p>
                <p class="small">Camunda Engine must be running for this to work. Please refer to <a href="https://camunda.com/blog/2021/10/start-and-step-through-a-process-with-rest-feat-swaggerui/">this page</a> and follow all the instructions from the pages linked on this page. There are links to download the Camunda BPM Platform and then work with it. </p>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
            </div>
        </div>
    </div>
</div>

<div class="row">
    <div class="col-md-10">
        <p class="alert-danger">@ViewData["notapprovermsg"]</p>
        @if (bpmRole == "pm" && Model != null)
        {
            <p>
                <a asp-action="CamundaStartEmpVal" class="btn btn-success"><span class="glyphicon glyphicon-play-circle"></span> New Employee Evaluation</a>
            </p>
        }
        else if (bpmRole != "pm" && Model != null)
        {
            <p class="alert-danger">Please login as a@b.com (PM) to start an employee's evaluation.</p>
        }
        <div>
            @if (Model == null)
            {
                <p class="alert-danger small">Camunda BPM Engine must be running for this to work. Please refer to <a href="https://jbpm.org/learn/gettingStarted.html">this page</a> and follow the simple instructions. There are links to download the Camunda BPM Platform and then work with it.</p>
            }
            <hr />
            <h5>My Employee Evaluations (Camunda engine)</h5>
            @if (Model != null && Model.Count() == 0)
            {
                <p>All tasks have been completed. Please login as a PM (a@b.com) to start an evaluation for an employee.</p>
            }
            @if (Model != null && Model.Count() > 0)
            {

                <table class="table">
                    <thead>
                        <tr>
                            <th>
                                Business Key
                            </th>
                            <th>
                                Employee
                            </th>
                            <th>
                                Self Comments
                            </th>

                            <th>
                                HR Comments
                            </th>

                            <th>
                                PM Comments
                            </th>

                            <th></th>
                        </tr>
                    </thead>
                    <tbody>
                        @foreach (var item in Model)
                        {
                            var vars = (await ASPNETIdentityPostgres.Areas.ADT.Models.CamundaBPMRestApiInvoker.getProcInstVars(item.id)).ToList();

                        <tr>
                            <td>
                                @Html.DisplayFor(modelItem => item.businessKey)
                            </td>
                            <td>
                                @vars.FirstOrDefault(v => v.name == "employee").value
                            </td>
                            <td>
                                @vars.FirstOrDefault(v => v.name == "self").value
                            </td>
                            <td>
                                @vars.FirstOrDefault(v => v.name == "hr").value
                            </td>
                            <td>
                                @vars.FirstOrDefault(v => v.name == "pm").value
                            </td>
                            <td>
                                <a asp-action="CamundaProcInstDetails" asp-route-id="@item.id">Go To Employee Evaluation</a>
                            </td>
                        </tr>
                        }
                    </tbody>
                </table>
            }
            else
            {
                <p class="alert-danger">No Evaluations are active.</p>
            }
        </div>
    </div>
    <div class="col-md-2">
        <!-- Button trigger modal -->

        <button type="button" class="glyphicon glyphicon-info-sign" data-toggle="modal" data-target="#exampleModal">
        </button>
    </div>
</div>

<p>
    @*<a asp-action="LoginToBonitaSoftEngine">Login to BonitaSoft Engine</a>*@
</p>

