Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @model X.PagedList.IPagedList<Employee>
- @using X.PagedList.Mvc.Core
- @{
- ViewData["Title"] = "Dodaj pracownika";
- Layout = "~/Views/Shared/_Layout.cshtml";
- }
- <div id="page-wrapper">
- <div class="row">
- <a class="btn btn-default" asp-action="ProjectIndex" asp-route-id="@ViewBag.IdProjekct" style="margin-bottom:20px;margin-right:20px;">Powrót</a>
- <a class="btn btn-default" asp-action="AddEmployee" asp-route-filtr="all" style="margin-bottom:20px;">Pokaż wszystkich</a>
- </div>
- <div class="row">
- <div style="font-size: 16px; font-weight: bold; margin-bottom:10px;margin-top:20px;">
- @Html.ActionLink("A ", "AddEmployee", new { filtr = "A" })
- @Html.ActionLink("B ", "AddEmployee", new { filtr = "B" })
- @Html.ActionLink("C ", "AddEmployee", new { filtr = "C" })
- @Html.ActionLink("D ", "AddEmployee", new { filtr = "D" })
- @Html.ActionLink("E ", "AddEmployee", new { filtr = "E" })
- @Html.ActionLink("F ", "AddEmployee", new { filtr = "F" })
- @Html.ActionLink("G ", "AddEmployee", new { filtr = "G" })
- @Html.ActionLink("H ", "AddEmployee", new { filtr = "H" })
- @Html.ActionLink("I ", "AddEmployee", new { filtr = "I" })
- @Html.ActionLink("J ", "AddEmployee", new { filtr = "J" })
- @Html.ActionLink("K ", "AddEmployee", new { filtr = "K" })
- @Html.ActionLink("L ", "AddEmployee", new { filtr = "L" })
- @Html.ActionLink("M ", "AddEmployee", new { filtr = "M" })
- @Html.ActionLink("N ", "AddEmployee", new { filtr = "N" })
- @Html.ActionLink("O ", "AddEmployee", new { filtr = "O" })
- @Html.ActionLink("P ", "AddEmployee", new { filtr = "P" })
- @Html.ActionLink("Q ", "AddEmployee", new { filtr = "Q" })
- @Html.ActionLink("R ", "AddEmployee", new { filtr = "R" })
- @Html.ActionLink("S ", "AddEmployee", new { filtr = "S" })
- @Html.ActionLink("T ", "AddEmployee", new { filtr = "T" })
- @Html.ActionLink("U ", "AddEmployee", new { filtr = "U" })
- @Html.ActionLink("W ", "AddEmployee", new { filtr = "W" })
- @Html.ActionLink("X ", "AddEmployee", new { filtr = "X" })
- @Html.ActionLink("Y ", "AddEmployee", new { filtr = "Y" })
- @Html.ActionLink("Z ", "AddEmployee", new { filtr = "Z" })
- </div>
- </div>
- <div class="row">
- <div asp-validation-summary="All" class="text-danger"></div>
- <table class="table table-sm table-bordered table-striped">
- <tr>
- <th>@Html.ActionLink("ID", "AddEmployee", new { sortOrder = ViewBag.IdSortParm, filtr = ViewBag.FilterParm, currentFilter = ViewBag.CurrentFilter })</th>
- <th>@Html.ActionLink("Nazwisko", "AddEmployee", new { sortOrder = ViewBag.LastNameSortParm, filtr = ViewBag.FilterParm, currentFilter = ViewBag.CurrentFilter })</th>
- <th>@Html.ActionLink("Imię", "AddEmployee", new { sortOrder = ViewBag.FirstNameSortParm, filtr = ViewBag.FilterParm, currentFilter = ViewBag.CurrentFilter })</th>
- <th>@Html.ActionLink("Data urodzenia", "AddEmployee", new { sortOrder = ViewBag.DateSortParm, filtr = ViewBag.FilterParm, currentFilter = ViewBag.CurrentFilter })</th>
- <th>@Html.ActionLink("Paszporty", "AddEmployee", new { sortOrder = ViewBag.PasswordSortParm, filtr = ViewBag.FilterParm, currentFilter = ViewBag.CurrentFilter })</th>
- <th>@Html.ActionLink("Stanowisko", "AddEmployee", new { sortOrder = ViewBag.PositionSortParm, filtr = ViewBag.FilterParm, currentFilter = ViewBag.CurrentFilter })</th>
- <th>@Html.ActionLink("Aktualny klient", "AddEmployee", new { sortOrder = ViewBag.NameSortParm, filtr = ViewBag.FilterParm, currentFilter = ViewBag.CurrentFilter })</th>
- <th>@Html.ActionLink("Aktualny Projekt", "AddEmployee", new { sortOrder = ViewBag.NameSortParm, filtr = ViewBag.FilterParm, currentFilter = ViewBag.CurrentFilter })</th>
- <th>Dodaj</th>
- </tr>
- @if (Model.Count == 0)
- {
- <tr><td colspan="8" class="text-center">Brak Pracowników.</td></tr>
- }
- else
- {
- foreach (Employee employee in Model)
- {
- <tr id="@employee.Id" class="EmployeeRow">
- <td>@employee.Id</td>
- <td>@employee.LastName</td>
- <td>@employee.FirstName</td>
- <td>@employee.BirthDate.ToShortDateString()</td>
- @if (employee.PassportNumber2 == null || employee.PassportNumber2.Equals("Brak"))
- {
- <td>@employee.PassportNumber</td>
- }
- else
- {
- <td>@employee.PassportNumber<br />@employee.PassportNumber2</td>
- }
- @if (employee.Position == null)
- {
- <td>Brak stanowiska</td>
- }
- else
- {
- <td>@employee.Position.Name</td>
- }
- <td>
- @if (employee.Project == null)
- {
- <span>Brak</span>
- }
- else
- {
- @employee.Project.Customer.Name
- }
- </td>
- <td>
- @if (employee.Project == null)
- {
- <span>Brak</span>
- }
- else
- {
- @employee.Project.Name
- }
- </td>
- <td>
- @if (employee.Project == null)
- {
- <div id="dialog_@employee.Id" class="dialog" title="Create new user" style="display:none;" >
- <form asp-controller="Customer" asp-action="AddEmployee" method="post" class="dialogForm" >
- <input type="hidden" name="idProject" value="@ViewBag.IdProjekct" />
- <input type="hidden" name="idEmployee" value="@employee.Id" />
- <input name="payPerHour" value="@ViewBag.PayPerHour" />
- <input name="payToCustomer" value="@ViewBag.PayPerHour" />
- <br/>
- <input type="button" class="confirmButton" value="Dodaj" class="btn btn-default PayPerHour"/>
- </form>
- </div>
- <button onclick='abrete(@employee.Id)'>Dodaj</button>
- }
- else
- {
- <form asp-controller="Customer" asp-action="AddEmployee" method="post">
- <input type="hidden" name="idProject" value="@ViewBag.IdProjekct" />
- <input type="hidden" name="idEmployee" value="@employee.Id" />
- <input type="hidden" name="payPerHour" value="@ViewBag.PayPerHour" />
- <input type="submit" value="Dodaj" class="btn btn-default AddForce" />
- </form>
- }
- </td>
- </tr>
- }
- }
- </table>
- <div>
- Strona @(Model.PageCount < Model.PageNumber ? 0 : Model.PageNumber) z @Model.PageCount
- </div>
- <div>
- @Html.PagedListPager(Model, page => Url.Action("AddEmployee", new { page, sortOrder = ViewBag.CurrentSort, filtr = ViewBag.FilterParm, currentFilter = ViewBag.CurrentFilter }))
- </div>
- </div>
- </div>
- @section scripts
- {
- <script src="https://code.jquery.com/jquery-1.12.4.js"></script>
- <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
- @* <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.14/themes/smoothness/jquery-ui.css"></script> *@
- <style>
- .dialogStyle {
- background-color: beige;
- border: 1px solid #ccc;
- transition: 1.1s ease-out;
- box-shadow: -2rem 2rem 2rem;
- }
- .dialogStyle .dialog .dialogForm {
- display: flex;
- flex-direction: column;
- justify-content: center;
- }
- .ui-dialog-titlebar-close {
- visibility: hidden;
- }
- .confirmButton {
- background-color: royalblue;
- border-radius: 20px;
- padding: 15px;
- margin: 5px 5px 30px 30px;
- }
- </style>
- <link href="~/css/jquery.dialog.min.css" rel="stylesheet">
- <script>
- function abrete(id) {
- t = $("#dialog_" + id.toString()).dialog({
- dialogClass: "dialogStyle"
- });
- }
- </script>
- <script src="~/js/bootbox.all.min.js"></script>
- <script src="~/js/jquery.dialog.min.js"></script>
- <script>
- $(function() {
- $(".AddForce").click(function() {
- var t = $(this);
- dialog.confirm({
- title: "UWAGA!!!",
- message: "Ten pracownik jest już w projekcie. Dodanie go spowoduje usunięcie z innego projektu",
- cancel: "Anuluj",
- button: "OK",
- required: true,
- callback: function(value) {
- if (value == true) {
- diag(t);
- }
- }
- });
- return false;
- });
- $(".PayPerHour").click(function() {
- var t = $(this);
- console.log(t);
- var idProject = t.parents('form:first')[0][0].value;
- var idEmployee = t.parents('form:first')[0][1].value;
- var payPerHour = t.parents('form:first')[0][2].value;
- var payToCustomer = t.parents('form:first')[0][3].value;
- $.ajax({
- url: '/Customer/AddEmployee',
- type: 'POST',
- data: {
- 'idProject': idProject,
- 'idEmployee': idEmployee,
- 'payPerHour': payPerHour,
- 'payToCustomer': payToCustomer
- }
- })
- .done(function(response) {
- if (response.success === true) {
- t.closest('.ui-dialog-content').dialog('close');
- let id = '#' + t.parents('form:first')[0].children.idEmployee.value;
- $(id).remove();
- if ($('.EmployeeRow').length === 0) {
- location.reload();
- }
- }
- });
- });
- // var diag = function(t) {
- // dialog.prompt({
- // title: "Stawka pracownika",
- // message: "Możesz teraz zmienić stawkę pracownika",
- // button: "Wyślij",
- // required: true,
- // position: "absolute",
- // animation: "slide",
- // inputs: {
- // type: "text",
- // value: t.siblings("input[name='payPerHour']").val()
- // },
- // validate: function(value) {
- // if ($.trim(value) === "") {
- // return false;
- // }
- //
- // },
- // callback: function(value) {
- // t.siblings("input[name='payPerHour']").val(value);
- // $.ajax({
- // url: '/Customer/AddEmployee',
- // type: 'POST',
- // data: {
- // 'idProject': t.parents('form:first')[0].children.idProject.value,
- // 'idEmployee': t.parents('form:first')[0].children.idEmployee.value,
- // 'payPerHour': t.parents('form:first')[0].children.payPerHour.value
- // }
- // })
- // .done(function(response) {
- // if (response.success === true) {
- // let id = '#' + t.parents('form:first')[0].children.idEmployee.value;
- // $(id).remove();
- // console.log(response)
- // if ($('.EmployeeRow').length === 0) {
- // location.reload();
- // }
- //
- // }
- // });
- //
- //
- // }
- // });
- // }
- });
- </script>
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement