225 lines
9.7 KiB
Plaintext
225 lines
9.7 KiB
Plaintext
@page
|
|
@using EveryThing.Models.Invoice
|
|
@model EveryThing.Pages.Invoices.IndexModel
|
|
|
|
@{
|
|
ViewData["Title"] = "Projekti";
|
|
Layout = "~/Pages/Layouts/_Layout.cshtml";
|
|
}
|
|
|
|
<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">@switch (@ViewData["Type"])
|
|
{
|
|
case 1:
|
|
<i>Naročila dobaviteljem</i>
|
|
break;
|
|
case 0:
|
|
<i>Računi</i>
|
|
break;
|
|
case 2:
|
|
<i>Dobavnice</i>
|
|
break;
|
|
case 3:
|
|
<i>Naročila kupcev</i>
|
|
break;
|
|
default:
|
|
<i>Fakture</i>
|
|
break;
|
|
}
|
|
/</span> Pregled
|
|
</span>
|
|
</h4>
|
|
|
|
<div class="row">
|
|
<div class="col-12 mb-2 text-right">
|
|
<form method="get">
|
|
<input type="hidden" asp-for="@ViewData["Type"]" name="type"/>
|
|
<div class="btn-group">
|
|
<input class="form-control" type="text" name="searchString" value="@ViewData["SearchString"]" placeholder="Iskanje..." autocomplete="off">
|
|
<button type="submit" class="btn btn-secondary" aria-label="Osveži" title="Osveži" asp-route-type="@ViewData["Type"]">
|
|
<i class="opacity-75 ion ion-md-refresh"></i>
|
|
</button>
|
|
<div class="btn-group" title="Columns">
|
|
<button class="btn btn-secondary dropdown-toggle" type="button" data-toggle="dropdown" aria-label="Nastavitve" title="Nastavitve">
|
|
<i class="opacity-75 ion ion-md-apps"></i>
|
|
<span class="caret"></span>
|
|
</button>
|
|
<div class="dropdown-menu dropdown-menu-right">
|
|
<label class="dropdown-item">
|
|
<input type="checkbox" name="finishedProjects" @ViewData["FinishedProjects"]> <span>Zaprte fakture</span>
|
|
</label>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="card">
|
|
|
|
|
|
<table class="table card-table table-hover">
|
|
<thead>
|
|
<tr>
|
|
<th style="width: 200px;">#</th>
|
|
<th style="width: auto;">
|
|
@Html.DisplayNameFor(invoice => invoice.Invoice[0].IdPartnerFk)
|
|
</th>
|
|
<th style="width: 100px;">
|
|
@Html.DisplayNameFor(invoice => invoice.Invoice[0].Date)
|
|
</th>
|
|
<th style="width: 100px">
|
|
@Html.DisplayNameFor(invoice => invoice.Invoice[0].State)
|
|
</th>
|
|
@if (Model.ShowProjects)
|
|
{
|
|
<th style="width: 100px">
|
|
Projekti
|
|
</th>
|
|
}
|
|
<th style="width: 140px;"></th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
@foreach (var item in Model.Invoice)
|
|
{
|
|
<tr data-idinvoice="@item.IdInvoice" data-number="@item.InvoiceNumberFormatted">
|
|
<td>@Html.DisplayFor(modelItem => item.InvoiceNumberFormatted)</td>
|
|
<td>
|
|
@Html.DisplayFor(modelItem => item.Partner.Title)
|
|
</td>
|
|
<td>
|
|
@Html.DisplayFor(modelItem => item.Date)
|
|
</td>
|
|
<td>
|
|
@switch (item.State)
|
|
{
|
|
case Invoice.InvoiceState.Closed:
|
|
<span class='badge badge-success'>@Html.DisplayFor(modelItem => item.State)</span>
|
|
break;
|
|
case Invoice.InvoiceState.Confirmed:
|
|
<span class='badge badge-warning'>@Html.DisplayFor(modelItem => item.State)</span>
|
|
break;
|
|
default:
|
|
<span class='badge badge-info'>@Html.DisplayFor(modelItem => item.State)</span>
|
|
break;
|
|
}
|
|
</td>
|
|
@if (Model.ShowProjects)
|
|
{
|
|
<td>
|
|
@if (item.InvoiceInvoiceItem.FirstOrDefault() != null)
|
|
{
|
|
<a asp-page="/Projects/Edit" asp-route-id="@item.InvoiceInvoiceItem.FirstOrDefault()?.ProjectPartItem?.ProjectPart?.Project?.IdProject">@string.Join(" ", item.InvoiceInvoiceItem.Select(x => x.ProjectPartItem?.ProjectPart?.Project?.ProjectNumberFormatted).Distinct())</a>
|
|
}
|
|
</td>
|
|
}
|
|
<td class="text-right">
|
|
<a class="btn btn-xs icon-btn btn-outline-success borderless" href='javascript:;' onclick="generateExcel(this)" data-toggle="tooltip" data-placement="left" title="Izvozi pozicije v .xlsx format" data-state="success"><i class="far fa-file-excel"></i></a>
|
|
<a class="btn btn-xs icon-btn btn-outline-primary borderless" asp-page="/Invoices/Print" asp-route-id="@item.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="Edit" asp-route-id="@item.IdInvoice" data-toggle="tooltip" data-placement="top" title="Urejanje" data-state="secondary"><i class="fas fa-pencil-alt"></i></a>
|
|
<a class="btn btn-xs icon-btn btn-outline-danger borderless" data-state="danger" href='javascript:;' onclick="deleteInvoice(this)"><i class="fas fa-times"></i></a>
|
|
</td>
|
|
</tr>
|
|
}
|
|
</tbody>
|
|
</table>
|
|
|
|
<div class="card-footer py-3 text-right">
|
|
<a asp-page="Create" asp-route-type="@ViewData["Type"]" class="btn btn-primary">Vnos fakture</a>
|
|
</div>
|
|
</div>
|
|
@Html.AntiForgeryToken()
|
|
|
|
@section Scripts {
|
|
<script>
|
|
$('[data-toggle="tooltip"]').tooltip({container: 'table'});
|
|
|
|
function deleteInvoice(element){
|
|
let row = $(element).parent().parent();
|
|
let idInvoice = $(row).attr('data-idinvoice');
|
|
let invoiceNumber = $(row).attr('data-number');
|
|
|
|
Swal.fire({
|
|
title: `Izbrišem dokument ${invoiceNumber}?`,
|
|
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) {
|
|
$.blockUI();
|
|
$.ajax({
|
|
type: "DELETE",
|
|
beforeSend: function (xhr) {
|
|
xhr.setRequestHeader("XSRF-TOKEN",
|
|
$('input:hidden[name="__RequestVerificationToken"]').val());
|
|
},
|
|
url: "/Invoices/Index/?handler=Invoice",
|
|
data: {
|
|
idInvoice
|
|
},
|
|
success: function (data) {
|
|
$.unblockUI();
|
|
if (data.successful) {
|
|
$(row).remove();
|
|
} else {
|
|
console.log(data);
|
|
Swal.fire('Napaka pri brisanju dokumenta',
|
|
data.error,
|
|
'error');
|
|
}
|
|
|
|
},
|
|
error: function (xhr, ajaxOptions, thrownError) {
|
|
console.log(xhr);
|
|
alert(xhr.responseText);
|
|
$.unblockUI();
|
|
}
|
|
});
|
|
}
|
|
});
|
|
}
|
|
|
|
function generateExcel(element) {
|
|
const row = $(element).parent().parent();
|
|
const idInvoice = $(row).attr('data-idinvoice');
|
|
|
|
$.blockUI();
|
|
$.ajax({
|
|
type: "GET",
|
|
url: "/Invoices/Index/?handler=Excel",
|
|
data: {
|
|
idInvoice
|
|
},
|
|
success: function (data) {
|
|
$.unblockUI();
|
|
if (data.successful) {
|
|
var tmpElement = document.createElement('A');
|
|
tmpElement.href = 'data:application/octet-stream;base64,' + data.base64;
|
|
tmpElement.download = data.name;
|
|
document.body.appendChild(tmpElement);
|
|
tmpElement.click();
|
|
document.body.removeChild(tmpElement);
|
|
} else {
|
|
console.log(data);
|
|
Swal.fire('Napaka pri kreiranju excela',
|
|
data.error,
|
|
'error');
|
|
}
|
|
|
|
},
|
|
error: function (xhr, ajaxOptions, thrownError) {
|
|
console.log(xhr);
|
|
alert(xhr.responseText);
|
|
$.unblockUI();
|
|
}
|
|
});
|
|
}
|
|
</script>
|
|
}
|