Advertisement
Guest User

Untitled

a guest
Mar 31st, 2019
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 13.81 KB | None | 0 0
  1. @model X.PagedList.IPagedList<Employee>
  2. @using X.PagedList.Mvc.Core
  3. @{
  4.     ViewData["Title"] = "Dodaj pracownika";
  5.     Layout = "~/Views/Shared/_Layout.cshtml";
  6. }
  7.  
  8. <div id="page-wrapper">
  9.     <div class="row">
  10.         <a class="btn btn-default" asp-action="ProjectIndex" asp-route-id="@ViewBag.IdProjekct" style="margin-bottom:20px;margin-right:20px;">Powrót</a>
  11.         <a class="btn btn-default" asp-action="AddEmployee" asp-route-filtr="all" style="margin-bottom:20px;">Pokaż wszystkich</a>
  12.     </div>
  13.     <div class="row">
  14.         <div style="font-size: 16px; font-weight: bold; margin-bottom:10px;margin-top:20px;">
  15.             @Html.ActionLink("A ", "AddEmployee", new { filtr = "A" })
  16.             @Html.ActionLink("B ", "AddEmployee", new { filtr = "B" })
  17.             @Html.ActionLink("C ", "AddEmployee", new { filtr = "C" })
  18.             @Html.ActionLink("D ", "AddEmployee", new { filtr = "D" })
  19.             @Html.ActionLink("E ", "AddEmployee", new { filtr = "E" })
  20.             @Html.ActionLink("F ", "AddEmployee", new { filtr = "F" })
  21.             @Html.ActionLink("G ", "AddEmployee", new { filtr = "G" })
  22.             @Html.ActionLink("H ", "AddEmployee", new { filtr = "H" })
  23.             @Html.ActionLink("I ", "AddEmployee", new { filtr = "I" })
  24.             @Html.ActionLink("J ", "AddEmployee", new { filtr = "J" })
  25.             @Html.ActionLink("K ", "AddEmployee", new { filtr = "K" })
  26.             @Html.ActionLink("L ", "AddEmployee", new { filtr = "L" })
  27.             @Html.ActionLink("M ", "AddEmployee", new { filtr = "M" })
  28.             @Html.ActionLink("N ", "AddEmployee", new { filtr = "N" })
  29.             @Html.ActionLink("O ", "AddEmployee", new { filtr = "O" })
  30.             @Html.ActionLink("P ", "AddEmployee", new { filtr = "P" })
  31.             @Html.ActionLink("Q ", "AddEmployee", new { filtr = "Q" })
  32.             @Html.ActionLink("R ", "AddEmployee", new { filtr = "R" })
  33.             @Html.ActionLink("S ", "AddEmployee", new { filtr = "S" })
  34.             @Html.ActionLink("T ", "AddEmployee", new { filtr = "T" })
  35.             @Html.ActionLink("U ", "AddEmployee", new { filtr = "U" })
  36.             @Html.ActionLink("W ", "AddEmployee", new { filtr = "W" })
  37.             @Html.ActionLink("X ", "AddEmployee", new { filtr = "X" })
  38.             @Html.ActionLink("Y ", "AddEmployee", new { filtr = "Y" })
  39.             @Html.ActionLink("Z ", "AddEmployee", new { filtr = "Z" })
  40.         </div>
  41.     </div>
  42.     <div class="row">
  43.         <div asp-validation-summary="All" class="text-danger"></div>
  44.         <table class="table table-sm table-bordered table-striped">
  45.             <tr>
  46.                 <th>@Html.ActionLink("ID", "AddEmployee", new { sortOrder = ViewBag.IdSortParm, filtr = ViewBag.FilterParm, currentFilter = ViewBag.CurrentFilter })</th>
  47.                 <th>@Html.ActionLink("Nazwisko", "AddEmployee", new { sortOrder = ViewBag.LastNameSortParm, filtr = ViewBag.FilterParm, currentFilter = ViewBag.CurrentFilter })</th>
  48.                 <th>@Html.ActionLink("Imię", "AddEmployee", new { sortOrder = ViewBag.FirstNameSortParm, filtr = ViewBag.FilterParm, currentFilter = ViewBag.CurrentFilter })</th>
  49.                 <th>@Html.ActionLink("Data urodzenia", "AddEmployee", new { sortOrder = ViewBag.DateSortParm, filtr = ViewBag.FilterParm, currentFilter = ViewBag.CurrentFilter })</th>
  50.                 <th>@Html.ActionLink("Paszporty", "AddEmployee", new { sortOrder = ViewBag.PasswordSortParm, filtr = ViewBag.FilterParm, currentFilter = ViewBag.CurrentFilter })</th>
  51.                 <th>@Html.ActionLink("Stanowisko", "AddEmployee", new { sortOrder = ViewBag.PositionSortParm, filtr = ViewBag.FilterParm, currentFilter = ViewBag.CurrentFilter })</th>
  52.                 <th>@Html.ActionLink("Aktualny klient", "AddEmployee", new { sortOrder = ViewBag.NameSortParm, filtr = ViewBag.FilterParm, currentFilter = ViewBag.CurrentFilter })</th>
  53.                 <th>@Html.ActionLink("Aktualny Projekt", "AddEmployee", new { sortOrder = ViewBag.NameSortParm, filtr = ViewBag.FilterParm, currentFilter = ViewBag.CurrentFilter })</th>
  54.                 <th>Dodaj</th>
  55.             </tr>
  56.             @if (Model.Count == 0)
  57.             {
  58.                 <tr><td colspan="8" class="text-center">Brak Pracowników.</td></tr>
  59.             }
  60.             else
  61.             {
  62.                 foreach (Employee employee in Model)
  63.                 {
  64.                     <tr id="@employee.Id" class="EmployeeRow">
  65.                         <td>@employee.Id</td>
  66.                         <td>@employee.LastName</td>
  67.                         <td>@employee.FirstName</td>
  68.                         <td>@employee.BirthDate.ToShortDateString()</td>
  69.                         @if (employee.PassportNumber2 == null || employee.PassportNumber2.Equals("Brak"))
  70.                         {
  71.                             <td>@employee.PassportNumber</td>
  72.                         }
  73.                         else
  74.                         {
  75.                             <td>@employee.PassportNumber<br />@employee.PassportNumber2</td>
  76.                         }
  77.  
  78.                         @if (employee.Position == null)
  79.                         {
  80.                             <td>Brak stanowiska</td>
  81.                         }
  82.                         else
  83.                         {
  84.                             <td>@employee.Position.Name</td>
  85.                         }
  86.  
  87.                         <td>
  88.                             @if (employee.Project == null)
  89.                             {
  90.                                 <span>Brak</span>
  91.                             }
  92.                             else
  93.                             {
  94.                                 @employee.Project.Customer.Name
  95.                             }
  96.                         </td>
  97.                         <td>
  98.                             @if (employee.Project == null)
  99.                             {
  100.                                 <span>Brak</span>
  101.                             }
  102.                             else
  103.                             {
  104.                                 @employee.Project.Name
  105.                             }
  106.                         </td>
  107.                         <td>
  108.                             @if (employee.Project == null)
  109.                             {
  110.  
  111.                                 <div id="dialog_@employee.Id" class="dialog" title="Create new user" style="display:none;" >
  112.                                  
  113.  
  114.                                     <form asp-controller="Customer" asp-action="AddEmployee" method="post" class="dialogForm" >
  115.                                         <input type="hidden" name="idProject" value="@ViewBag.IdProjekct" />
  116.                                         <input type="hidden" name="idEmployee" value="@employee.Id" />
  117.                                         <input name="payPerHour" value="@ViewBag.PayPerHour" />
  118.                                         <input name="payToCustomer" value="@ViewBag.PayPerHour" />
  119.                                         <br/>
  120.                                         <input type="button" class="confirmButton" value="Dodaj" class="btn btn-default PayPerHour"/>
  121.                                     </form>
  122.                                 </div>
  123.                                 <button onclick='abrete(@employee.Id)'>Dodaj</button>
  124.                             }
  125.                             else
  126.                             {
  127.                                 <form asp-controller="Customer" asp-action="AddEmployee" method="post">
  128.                                     <input type="hidden" name="idProject" value="@ViewBag.IdProjekct" />
  129.                                     <input type="hidden" name="idEmployee" value="@employee.Id" />
  130.                                     <input type="hidden" name="payPerHour" value="@ViewBag.PayPerHour" />
  131.                                     <input type="submit" value="Dodaj" class="btn btn-default AddForce" />
  132.                                 </form>
  133.                             }
  134.                         </td>
  135.                     </tr>
  136.                 }
  137.             }
  138.         </table>
  139.         <div>
  140.             Strona @(Model.PageCount < Model.PageNumber ? 0 : Model.PageNumber) z @Model.PageCount
  141.         </div>
  142.         <div>
  143.  
  144.             @Html.PagedListPager(Model, page => Url.Action("AddEmployee", new { page, sortOrder = ViewBag.CurrentSort, filtr = ViewBag.FilterParm, currentFilter = ViewBag.CurrentFilter }))
  145.  
  146.         </div>
  147.     </div>
  148. </div>
  149. @section scripts
  150. {
  151.     <script src="https://code.jquery.com/jquery-1.12.4.js"></script>
  152.     <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
  153.     @* <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.14/themes/smoothness/jquery-ui.css"></script> *@
  154.     <style>
  155.         .dialogStyle {
  156.             background-color: beige;
  157.             border: 1px solid #ccc;
  158.             transition: 1.1s ease-out;
  159.             box-shadow: -2rem 2rem 2rem;
  160.         }
  161.         .dialogStyle .dialog .dialogForm {
  162.             display: flex;
  163.             flex-direction: column;
  164.             justify-content: center;
  165.         }
  166.         .ui-dialog-titlebar-close {
  167.             visibility: hidden;
  168.         }
  169.         .confirmButton {
  170.             background-color: royalblue;
  171.             border-radius: 20px;
  172.             padding: 15px;
  173.             margin: 5px 5px 30px 30px;
  174.  
  175.         }
  176.     </style>
  177.      <link href="~/css/jquery.dialog.min.css" rel="stylesheet">
  178.     <script>
  179.         function abrete(id) {
  180.             t = $("#dialog_" + id.toString()).dialog({
  181.                 dialogClass: "dialogStyle"
  182.             });
  183.            
  184.         }
  185.     </script>
  186.  
  187.     <script src="~/js/bootbox.all.min.js"></script>
  188.     <script src="~/js/jquery.dialog.min.js"></script>
  189.     <script>
  190.         $(function() {
  191.             $(".AddForce").click(function() {
  192.                 var t = $(this);
  193.                 dialog.confirm({
  194.                     title: "UWAGA!!!",
  195.                     message: "Ten pracownik jest już w projekcie. Dodanie go spowoduje usunięcie z innego projektu",
  196.                     cancel: "Anuluj",
  197.                     button: "OK",
  198.                     required: true,
  199.                     callback: function(value) {
  200.                         if (value == true) {
  201.                             diag(t);
  202.                         }
  203.                     }
  204.                 });
  205.                 return false;
  206.             });
  207.  
  208.             $(".PayPerHour").click(function() {
  209.                 var t = $(this);
  210.                 console.log(t);
  211.                 var idProject = t.parents('form:first')[0][0].value;
  212.                 var idEmployee = t.parents('form:first')[0][1].value;
  213.                 var payPerHour = t.parents('form:first')[0][2].value;
  214.                 var payToCustomer = t.parents('form:first')[0][3].value;
  215.                 $.ajax({
  216.                         url: '/Customer/AddEmployee',
  217.                         type: 'POST',
  218.                         data: {
  219.                             'idProject': idProject,
  220.                             'idEmployee': idEmployee,
  221.                             'payPerHour': payPerHour,
  222.                             'payToCustomer': payToCustomer
  223.                         }
  224.                     })
  225.                     .done(function(response) {
  226.                         if (response.success === true) {
  227.                            
  228.                             t.closest('.ui-dialog-content').dialog('close');
  229.                             let id = '#' + t.parents('form:first')[0].children.idEmployee.value;
  230.                             $(id).remove();
  231.                             if ($('.EmployeeRow').length === 0) {
  232.                                 location.reload();
  233.                             }
  234.  
  235.                         }
  236.                     });
  237.             });
  238.  
  239. //            var diag = function(t) {
  240. //                dialog.prompt({
  241. //                    title: "Stawka pracownika",
  242. //                    message: "Możesz teraz zmienić stawkę pracownika",
  243. //                    button: "Wyślij",
  244. //                    required: true,
  245. //                    position: "absolute",
  246. //                    animation: "slide",
  247. //                    inputs: {
  248. //                        type: "text",
  249. //                        value: t.siblings("input[name='payPerHour']").val()
  250. //                    },
  251. //                    validate: function(value) {
  252. //                        if ($.trim(value) === "") {
  253. //                            return false;
  254. //                        }
  255. //
  256. //                    },
  257. //                    callback: function(value) {
  258. //                        t.siblings("input[name='payPerHour']").val(value);
  259. //                        $.ajax({
  260. //                                url: '/Customer/AddEmployee',
  261. //                                type: 'POST',
  262. //                                data: {
  263. //                                    'idProject': t.parents('form:first')[0].children.idProject.value,
  264. //                                    'idEmployee': t.parents('form:first')[0].children.idEmployee.value,
  265. //                                    'payPerHour': t.parents('form:first')[0].children.payPerHour.value
  266. //                                }
  267. //                            })
  268. //                            .done(function(response) {
  269. //                                if (response.success === true) {
  270. //                                    let id = '#' + t.parents('form:first')[0].children.idEmployee.value;
  271. //                                    $(id).remove();
  272. //                                    console.log(response)
  273. //                                    if ($('.EmployeeRow').length === 0) {
  274. //                                        location.reload();
  275. //                                    }
  276. //
  277. //                                }
  278. //                            });
  279. //
  280. //
  281. //                    }
  282. //                });
  283. //            }
  284.  
  285.         });
  286.     </script>
  287. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement