- Dodati operacije na pozicijo dela projekta
- Dodatna tabela z operacijami in stanjem (končano/nekončano) - šifrant operacij - možnost določevanje privzetih operacij - Opombe na pozicij dela projekta - Pogled kooperacij na poziciji dela projekta - Izpisano številka kooperacije in kooperant
This commit is contained in:
@@ -13,7 +13,7 @@
|
||||
|
||||
<h4 class="d-flex justify-content-between align-items-center w-100 font-weight-bold py-1 mb-4">
|
||||
<span>
|
||||
<span class="text-muted font-weight-light">Projekt /</span>
|
||||
<span class="text-muted font-weight-light">Projekt /</span>
|
||||
@if ((bool)ViewData["Edit"])
|
||||
{
|
||||
<span> Urejanje pozicije dela projekta</span>
|
||||
@@ -22,7 +22,7 @@
|
||||
{
|
||||
<span> Nova pozicija dela projekta</span>
|
||||
}
|
||||
|
||||
|
||||
</span>
|
||||
</h4>
|
||||
|
||||
@@ -46,9 +46,11 @@
|
||||
<div class="col-12">
|
||||
<div class="form-group">
|
||||
<label asp-for="ProjectPartItem.IdItemFk" class="form-label"></label>
|
||||
<div class="form-row">
|
||||
<div class="col-12">
|
||||
<div class="form-row align-items-end">
|
||||
<div class="col">
|
||||
<select id="selCodeTableItem" asp-for="ProjectPartItem.IdItemFk" class="form-control select2" asp-items="ViewBag.IdItemFk"></select>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<button class="btn btn-success" type="button" onclick="copyDataFromLastPartItem();">Napolni prejšnje</button>
|
||||
<button class="btn btn-primary" type="button" onclick="addNewCodeTableItem();">Novi artikel</button>
|
||||
</div>
|
||||
@@ -76,11 +78,11 @@
|
||||
<div class="col-12">
|
||||
<div class="form-group">
|
||||
<label asp-for="ProjectPartItem.IdMaterialFk" class="form-label"></label>
|
||||
<div class="form-row">
|
||||
<div class="col-9">
|
||||
<div class="form-row align-items-end">
|
||||
<div class="col">
|
||||
<select id="selCodeTableItemMaterial" asp-for="ProjectPartItem.IdMaterialFk" class="form-control select2" asp-items="ViewBag.IdMaterialFk"></select>
|
||||
</div>
|
||||
<div class="col-3">
|
||||
<div class="col-auto">
|
||||
<button class="btn btn-primary" type="button" onclick="addNewCodeTableItemMaterial();">Novi material</button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -153,6 +155,15 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="form-group">
|
||||
<label asp-for="ProjectPartItem.Note" class="form-label"></label>
|
||||
<textarea asp-for="ProjectPartItem.Note" class="form-control" rows="3"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-footer py-3 text-right">
|
||||
@if (ViewData["Edit"] != null && (bool)ViewData["Edit"])
|
||||
@@ -161,13 +172,93 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
<button type="submit" class="btn btn-primary">Dodaj del projekta</button>
|
||||
<button type="submit" class="btn btn-primary">Dodaj pozicijo dela projekta</button>
|
||||
}
|
||||
|
||||
|
||||
<a asp-page="Edit" asp-route-id="@ViewBag.IdProject" class="btn btn-default">Prekliči</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<div class="card">
|
||||
<h6 class="card-header">
|
||||
Operacije
|
||||
</h6>
|
||||
<div class="card-body">
|
||||
@if (ViewData["Edit"] != null && (bool)ViewData["Edit"])
|
||||
{
|
||||
<div class="form-row align-items-end mb-3">
|
||||
<div class="col">
|
||||
<label class="form-label" for="selProjectPartItemOperation">Naziv</label>
|
||||
<select id="selProjectPartItemOperation" class="form-control select2" asp-items="ViewBag.IdCodeTableOperationFk"></select>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<button type="button" class="btn btn-primary" onclick="addProjectPartItemOperation();">Dodaj</button>
|
||||
<button type="button" class="btn btn-success" onclick="addDefaultOperations();">Dodaj privzete</button>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="w-100">Naziv</th>
|
||||
<th class="text-right" style="white-space: nowrap; width: 1%;">Končano</th>
|
||||
<th class="text-right" style="white-space: nowrap; width: 1%;"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var operation in Model.ProjectPartItemOperations)
|
||||
{
|
||||
<tr data-id="@operation.Id" data-id-code-table-operation="@operation.IdCodeTableOperationFk">
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => operation.Operation.Title)
|
||||
</td>
|
||||
<td class="text-right" style="white-space: nowrap; width: 1%;">
|
||||
<input type="checkbox" @(operation.Finished ? "checked" : "") onchange="toggleOperationFinished(@operation.Id, this);" />
|
||||
</td>
|
||||
<td class="text-right" style="white-space: nowrap; width: 1%;">
|
||||
<a class="btn btn-xs icon-btn btn-outline-secondary borderless" href="javascript:;" onclick="moveOperation(@operation.Id, 'up', this);" title="Gor"><i class="fas fa-arrow-up"></i></a>
|
||||
<a class="btn btn-xs icon-btn btn-outline-secondary borderless" href="javascript:;" onclick="moveOperation(@operation.Id, 'down', this);" title="Dol"><i class="fas fa-arrow-down"></i></a>
|
||||
<a class="btn btn-xs icon-btn btn-outline-danger borderless" data-state="danger" href="javascript:;" onclick="deleteProjectPartItemOperation(@operation.Id, this);" title="Izbriši"><i class="fas fa-times"></i></a>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<h6 class="card-header">
|
||||
Kooperacije
|
||||
</h6>
|
||||
<div class="card-body">
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="white-space: nowrap; width: 1%;">Številka</th>
|
||||
<th>Partner</th>
|
||||
<th style="white-space: nowrap; width: 1%;"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var item in Model.CooperationInvoiceItems)
|
||||
{
|
||||
<tr>
|
||||
<td style="white-space: nowrap;">@item.Invoice.InvoiceNumberFormatted</td>
|
||||
<td>@item.Invoice.Partner?.Title</td>
|
||||
<td class="text-right" style="white-space: nowrap; width: 1%;">
|
||||
<a class="btn btn-xs icon-btn btn-outline-primary borderless" asp-page="/Invoices/Print" asp-route-id="@item.Invoice.IdInvoice" data-toggle="tooltip" data-placement="top" title="Tiskanje" data-state="primary"><i class="ion ion-md-print"></i></a>
|
||||
<a class="btn btn-xs icon-btn btn-outline-secondary borderless" asp-page="/Invoices/Edit" asp-route-id="@item.Invoice.IdInvoice" data-toggle="tooltip" data-placement="top" title="Urejanje" data-state="secondary"><i class="fas fa-pencil-alt"></i></a>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
|
||||
@@ -246,5 +337,209 @@
|
||||
location.replace(`CreateEditPartItem?idProjectPartItem=${idProjectPartItem}&idProject=${idProject}&idProjectPart=${idProjectPart}&edit=${edit}&idArticleCopyFrom=${idArticle}`);
|
||||
}
|
||||
|
||||
function moveOperation(idProjectPartItemOperation, direction, element) {
|
||||
let row = $(element).closest('tr');
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
beforeSend: function(xhr) {
|
||||
xhr.setRequestHeader("XSRF-TOKEN",
|
||||
$('input:hidden[name="__RequestVerificationToken"]').val());
|
||||
},
|
||||
url: "CreateEditPartItem/?handler=MoveOperation",
|
||||
data: {
|
||||
idProjectPartItemOperation,
|
||||
direction
|
||||
},
|
||||
success: function(data) {
|
||||
if (data.successful) {
|
||||
if (direction === 'up') {
|
||||
let prev = row.prev('tr');
|
||||
if (prev.length) {
|
||||
row.insertBefore(prev);
|
||||
}
|
||||
} else {
|
||||
let next = row.next('tr');
|
||||
if (next.length) {
|
||||
row.insertAfter(next);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
error: function(xhr, ajaxOptions, thrownError) {
|
||||
console.log(xhr);
|
||||
alert(xhr.responseText);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function toggleOperationFinished(idProjectPartItemOperation, checkbox) {
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
beforeSend: function(xhr) {
|
||||
xhr.setRequestHeader("XSRF-TOKEN",
|
||||
$('input:hidden[name="__RequestVerificationToken"]').val());
|
||||
},
|
||||
url: "CreateEditPartItem/?handler=ToggleProjectPartItemOperationFinished",
|
||||
data: {
|
||||
idProjectPartItemOperation
|
||||
},
|
||||
success: function(data) {
|
||||
if (!data.successful) {
|
||||
Swal.fire('Napaka pri posodabljanju operacije', data.error, 'error');
|
||||
checkbox.checked = !checkbox.checked;
|
||||
}
|
||||
},
|
||||
error: function(xhr, ajaxOptions, thrownError) {
|
||||
console.log(xhr);
|
||||
alert(xhr.responseText);
|
||||
checkbox.checked = !checkbox.checked;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function deleteProjectPartItemOperation(idProjectPartItemOperation, element) {
|
||||
let row = $(element).closest('tr');
|
||||
Swal.fire({
|
||||
title: 'Izbrišem operacijo?',
|
||||
text: "Tega dejanja ni možno razveljaviti!",
|
||||
icon: 'warning',
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: '#3085d6',
|
||||
cancelButtonColor: '#d33',
|
||||
confirmButtonText: 'Da, izbriši!',
|
||||
cancelButtonText: 'Prekliči!'
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
$.ajax({
|
||||
type: "DELETE",
|
||||
beforeSend: function(xhr) {
|
||||
xhr.setRequestHeader("XSRF-TOKEN",
|
||||
$('input:hidden[name="__RequestVerificationToken"]').val());
|
||||
},
|
||||
url: "CreateEditPartItem/?handler=ProjectPartItemOperation",
|
||||
data: {
|
||||
idProjectPartItemOperation
|
||||
},
|
||||
success: function(data) {
|
||||
if (data.successful) {
|
||||
let operationName = row.find('td:first').text().trim();
|
||||
let operationId = row.data('idCodeTableOperation');
|
||||
$('#selProjectPartItemOperation').append($('<option></option>').val(operationId).html(operationName));
|
||||
row.remove();
|
||||
$('#selProjectPartItemOperation').trigger('change');
|
||||
} else {
|
||||
Swal.fire('Napaka pri brisanju operacije', data.error, 'error');
|
||||
}
|
||||
},
|
||||
error: function(xhr, ajaxOptions, thrownError) {
|
||||
console.log(xhr);
|
||||
alert(xhr.responseText);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function addDefaultOperations() {
|
||||
let idProjectPartItem = parseInt($('#ProjectPartItem_IdProjectPartItem').val());
|
||||
if (isNaN(idProjectPartItem)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$.blockUI();
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
beforeSend: function(xhr) {
|
||||
xhr.setRequestHeader("XSRF-TOKEN",
|
||||
$('input:hidden[name="__RequestVerificationToken"]').val());
|
||||
},
|
||||
url: "CreateEditPartItem/?handler=AddDefaultOperations",
|
||||
data: {
|
||||
idProjectPartItem
|
||||
},
|
||||
success: function(data) {
|
||||
$.unblockUI();
|
||||
if (data.successful) {
|
||||
$.each(data.operations, function(i, op) {
|
||||
let row = `<tr data-id="${op.idProjectPartItemOperation}" data-id-code-table-operation="${op.idCodeTableOperation}">
|
||||
<td>${op.title}</td>
|
||||
<td class="text-right" style="white-space: nowrap; width: 1%;">
|
||||
<input type="checkbox" onchange="toggleOperationFinished(${op.idProjectPartItemOperation}, this);" />
|
||||
</td>
|
||||
<td class="text-right" style="white-space: nowrap; width: 1%;">
|
||||
<a class="btn btn-xs icon-btn btn-outline-secondary borderless" href="javascript:;" onclick="moveOperation(${op.idProjectPartItemOperation}, 'up', this);" title="Gor"><i class="fas fa-arrow-up"></i></a>
|
||||
<a class="btn btn-xs icon-btn btn-outline-secondary borderless" href="javascript:;" onclick="moveOperation(${op.idProjectPartItemOperation}, 'down', this);" title="Dol"><i class="fas fa-arrow-down"></i></a>
|
||||
<a class="btn btn-xs icon-btn btn-outline-danger borderless" data-state="danger" href="javascript:;" onclick="deleteProjectPartItemOperation(${op.idProjectPartItemOperation}, this);" title="Izbriši"><i class="fas fa-times"></i></a>
|
||||
</td>
|
||||
</tr>`;
|
||||
$('table.table tbody').append(row);
|
||||
$('#selProjectPartItemOperation option[value="' + op.idCodeTableOperation + '"]').remove();
|
||||
});
|
||||
$('#selProjectPartItemOperation').trigger('change');
|
||||
} else {
|
||||
Swal.fire('Napaka pri dodajanju privzetih operacij', data.error, 'error');
|
||||
}
|
||||
},
|
||||
error: function(xhr, ajaxOptions, thrownError) {
|
||||
console.log(xhr);
|
||||
alert(xhr.responseText);
|
||||
$.unblockUI();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function addProjectPartItemOperation() {
|
||||
let idProjectPartItem = parseInt($('#ProjectPartItem_IdProjectPartItem').val());
|
||||
let idCodeTableOperation = parseInt($('#selProjectPartItemOperation').val());
|
||||
|
||||
if (isNaN(idProjectPartItem) || isNaN(idCodeTableOperation)) {
|
||||
Swal.fire('Izberite operacijo.');
|
||||
return;
|
||||
}
|
||||
|
||||
$.blockUI();
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
beforeSend: function(xhr) {
|
||||
xhr.setRequestHeader("XSRF-TOKEN",
|
||||
$('input:hidden[name="__RequestVerificationToken"]').val());
|
||||
},
|
||||
url: "CreateEditPartItem/?handler=ProjectPartItemOperation",
|
||||
data: {
|
||||
idProjectPartItem,
|
||||
idCodeTableOperation
|
||||
},
|
||||
success: function(data) {
|
||||
$.unblockUI();
|
||||
if (data.successful){
|
||||
let id = data.idProjectPartItemOperation;
|
||||
let row = `<tr data-id="${id}" data-id-code-table-operation="${idCodeTableOperation}">
|
||||
<td>${data.title}</td>
|
||||
<td class="text-right" style="white-space: nowrap; width: 1%;">
|
||||
<input type="checkbox" onchange="toggleOperationFinished(${id}, this);" />
|
||||
</td>
|
||||
<td class="text-right" style="white-space: nowrap; width: 1%;">
|
||||
<a class="btn btn-xs icon-btn btn-outline-secondary borderless" href="javascript:;" onclick="moveOperation(${id}, 'up', this);" title="Gor"><i class="fas fa-arrow-up"></i></a>
|
||||
<a class="btn btn-xs icon-btn btn-outline-secondary borderless" href="javascript:;" onclick="moveOperation(${id}, 'down', this);" title="Dol"><i class="fas fa-arrow-down"></i></a>
|
||||
<a class="btn btn-xs icon-btn btn-outline-danger borderless" data-state="danger" href="javascript:;" onclick="deleteProjectPartItemOperation(${id}, this);" title="Izbriši"><i class="fas fa-times"></i></a>
|
||||
</td>
|
||||
</tr>`;
|
||||
$('table.table tbody').append(row);
|
||||
$('#selProjectPartItemOperation option[value="' + idCodeTableOperation + '"]').remove();
|
||||
$('#selProjectPartItemOperation').trigger('change');
|
||||
} else {
|
||||
Swal.fire('Napaka pri dodajanju operacije',
|
||||
data.error,
|
||||
'error');
|
||||
}
|
||||
},
|
||||
error: function(xhr, ajaxOptions, thrownError) {
|
||||
console.log(xhr);
|
||||
alert(xhr.responseText);
|
||||
$.unblockUI();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
</script>
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user