1540 lines
85 KiB
Plaintext
1540 lines
85 KiB
Plaintext
@page
|
|
@using EveryThing.Models.Project
|
|
@using EveryThing.Models.Invoice
|
|
@model EveryThing.Pages.Projects.EditModel
|
|
|
|
@{
|
|
ViewData["Title"] = "Urejanje projekta";
|
|
Layout = "~/Pages/Layouts/_Layout.cshtml";
|
|
}
|
|
|
|
<style>
|
|
.table th {
|
|
border-top: none;
|
|
}
|
|
|
|
.tab-panel-invoices{
|
|
height: 490px;
|
|
overflow-y: auto;
|
|
}
|
|
.table-number-edit {
|
|
width: 50px;
|
|
}
|
|
.table-price-edit {
|
|
width: 70px;
|
|
}
|
|
.table-eddit {
|
|
padding-left: 2px !important;
|
|
padding-right: 2px !important;
|
|
}
|
|
|
|
.table-number {
|
|
width: 70px;
|
|
text-align: right;
|
|
}
|
|
|
|
.table-header-number {
|
|
text-align: right;
|
|
}
|
|
|
|
.card-body-tab {
|
|
padding: 5px 0 5px 0;
|
|
}
|
|
|
|
</style>
|
|
<link rel="stylesheet" href="~/vendor/libs/select2/select2.css" asp-append-version="true" />
|
|
|
|
<form method="post">
|
|
|
|
<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> Urejanje
|
|
</span>
|
|
</h4>
|
|
|
|
<div class="row mb-4">
|
|
<div class="col-4">
|
|
<div class="card">
|
|
<h6 class="card-header">
|
|
<div class="row">
|
|
<div class="col-6">
|
|
Podatki projekta
|
|
</div>
|
|
<div class="col-6" style="text-align: right;">
|
|
@Html.DisplayFor(x => x.Project.ProjectNumberFormatted)
|
|
</div>
|
|
</div>
|
|
</h6>
|
|
<div class="card-body card-body-tab" style="min-height: 474px;">
|
|
<input type="hidden" asp-for="Project.IdProject"/>
|
|
<input type="hidden" asp-for="Project.IdCompanyFk" />
|
|
<input type="hidden" asp-for="Project.ProjectYear" />
|
|
<input type="hidden" asp-for="Project.ProjectNumber" />
|
|
<div class="nav-tabs-top nav-responsive-sm">
|
|
<ul class="nav nav-tabs">
|
|
<li class="nav-item">
|
|
<a class="nav-link active" data-toggle="tab" href="#project-tab-basic-data">Osnovni podatki</a>
|
|
</li>
|
|
<li class="nav-item">
|
|
<a class="nav-link" data-toggle="tab" href="#project-tab-prices-overview">Pregled cen</a>
|
|
</li>
|
|
</ul>
|
|
<div class="tab-content">
|
|
<div class="tab-pane fade show active" id="project-tab-basic-data">
|
|
<div class="card-body" style="padding: 0.5rem">
|
|
<div class="form-group">
|
|
<label asp-for="Project.Title" class="form-label"></label>
|
|
<input asp-for="Project.Title" class="form-control" />
|
|
<span asp-validation-for="Project.Title" class="text-danger"></span>
|
|
</div>
|
|
<div class="form-group">
|
|
<label asp-for="Project.IdPartnerFk" class="control-label"></label>
|
|
<select asp-for="Project.IdPartnerFk" class="form-control" asp-items="ViewBag.IdPartnerFk"></select>
|
|
<span asp-validation-for="Project.IdPartnerFk" class="text-danger"></span>
|
|
</div>
|
|
<div class="form-group">
|
|
<label asp-for="Project.BuyersOrderNumber" class="form-label"></label>
|
|
<input asp-for="Project.BuyersOrderNumber" class="form-control" />
|
|
<span asp-validation-for="Project.BuyersOrderNumber" class="text-danger"></span>
|
|
</div>
|
|
<div class="form-group">
|
|
<label asp-for="Project.Description" class="form-label"></label>
|
|
<input asp-for="Project.Description" class="form-control" />
|
|
<span asp-validation-for="Project.Description" class="text-danger"></span>
|
|
</div>
|
|
<div class="row">
|
|
<div class="col-6">
|
|
<div class="form-group">
|
|
<label asp-for="Project.Status" class="form-label"></label>
|
|
<select asp-for="Project.Status" asp-items="Html.GetEnumSelectList<ProjectStatus>()" class="form-control project-status">
|
|
<option>Izberite status</option>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
<div class="col-6">
|
|
<div class="form-group">
|
|
<label asp-for="Project.FinishedDate" class="form-label"></label>
|
|
@Html.TextBoxFor(m => m.Project.FinishedDate, "{0:yyyy-MM-dd}", new { @class = "form-control project-finished-date", type = "date" })
|
|
<span asp-validation-for="Project.FinishedDate" class="text-danger"></span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="tab-pane fade show" id="project-tab-prices-overview">
|
|
<div class="card-body" style="padding: 0.5rem">
|
|
<label id="lblProjectPrices" class="form-label" style="font-weight: initial;"></label>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="card-footer py-3 text-right">
|
|
<a href="Javascript:;" onclick="createOfferFromProject();" class="btn btn-success">Kreiraj ponudbo</a>
|
|
<a asp-page="/Files/Upload" asp-route-idReferenceFk="@Model.Project.IdProject" asp-route-fileType="@Models.FileType.Project" class="btn btn-primary pull-right">Priloži datoteko</a>
|
|
<button type="submit" class="btn btn-primary">Shrani</button>
|
|
<a asp-page="Index" class="btn btn-default">Prekliči</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="col-8">
|
|
<div class="card">
|
|
<h6 class="card-header">
|
|
Povezani dokumenti
|
|
</h6>
|
|
<div class="card-body card-body-tab">
|
|
<div class="nav-tabs-top nav-responsive-sm">
|
|
<ul class="nav nav-tabs">
|
|
<li class="nav-item">
|
|
<a class="nav-link active" data-toggle="tab" href="#invoice-orders">Povpraševanje/Naročila dob.</a>
|
|
</li>
|
|
<li class="nav-item">
|
|
<a class="nav-link" data-toggle="tab" href="#invoice-delivery-notes">Dobavnice</a>
|
|
</li>
|
|
<li class="nav-item">
|
|
<a class="nav-link" data-toggle="tab" href="#invoice-invoces">Računi</a>
|
|
</li>
|
|
<li class="nav-item">
|
|
<a class="nav-link" data-toggle="tab" href="#invoice-buyers-order">Ponudbe/Naročila kup.</a>
|
|
</li>
|
|
<li class="nav-item">
|
|
<a class="nav-link" data-toggle="tab" href="#files-project">Datoteke projekt</a>
|
|
</li>
|
|
<li class="nav-item">
|
|
<a class="nav-link" data-toggle="tab" href="#files-project-part">Datoteke del projekta</a>
|
|
</li>
|
|
<li class="nav-item">
|
|
<a class="nav-link" data-toggle="tab" href="#invoice-cooperatioins">Koop.</a>
|
|
</li>
|
|
</ul>
|
|
<div class="tab-content">
|
|
<div class="tab-pane tab-panel-invoices fade show active" id="invoice-orders">
|
|
<table class="table">
|
|
<thead>
|
|
<tr>
|
|
<th>
|
|
#
|
|
</th>
|
|
<th>
|
|
Dobavitelj
|
|
</th>
|
|
<th>
|
|
Datum
|
|
</th>
|
|
<th>
|
|
Dobavni rok
|
|
</th>
|
|
<th>
|
|
Status
|
|
</th>
|
|
<th><a href="Javascript:;" class="btn btn-sm btn-primary" onclick="showAllInvoices();">Pokaži vse</a></th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
@foreach (var invoice in Model.Invoices.Where(x => x.Type == Models.Invoice.Invoice.InvoiceType.Order))
|
|
{
|
|
<tr class="invoice-row" data-idparts="@string.Join(",", invoice.InvoiceInvoiceItem.Select(x => x.ProjectPartItem.IdProjectPartFk))">
|
|
<td>
|
|
@Html.DisplayFor(modelItem => invoice.InvoiceYear) - @Html.DisplayFor(modelItem => invoice.InvoiceNumber)
|
|
</td>
|
|
<td>
|
|
@Html.DisplayFor(x => invoice.Partner.Title)
|
|
</td>
|
|
<td>
|
|
@Html.DisplayFor(x => invoice.Date)
|
|
</td>
|
|
<td>
|
|
@Html.DisplayFor(x => invoice.DateOfDispatch)
|
|
</td>
|
|
<td>
|
|
@switch (invoice.State)
|
|
{
|
|
case Models.Invoice.Invoice.InvoiceState.Closed:
|
|
<span class='badge badge-success'>@Html.DisplayFor(modelItem => invoice.State)</span>
|
|
break;
|
|
case Models.Invoice.Invoice.InvoiceState.Confirmed:
|
|
<span class='badge badge-warning'>@Html.DisplayFor(modelItem => invoice.State)</span>
|
|
break;
|
|
default:
|
|
<span class='badge badge-info'>@Html.DisplayFor(modelItem => invoice.State)</span>
|
|
break;
|
|
}
|
|
</td>
|
|
<td class="text-right">
|
|
<a class="btn btn-xs icon-btn btn-outline-primary borderless" asp-page="/Invoices/Print" asp-route-id="@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="@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 class="tab-pane tab-panel-invoices fade show" id="invoice-delivery-notes">
|
|
<div class="card-body" style="padding: 0.5rem">
|
|
<table class="table">
|
|
<thead>
|
|
<tr>
|
|
<th>
|
|
</th>
|
|
<th>
|
|
#
|
|
</th>
|
|
<th>
|
|
Partner
|
|
</th>
|
|
<th>
|
|
Datum
|
|
</th>
|
|
<th>
|
|
Datum odpreme
|
|
</th>
|
|
<th>
|
|
Status
|
|
</th>
|
|
<th><a href="Javascript:;" class="btn btn-sm btn-primary" onclick="showAllInvoices();">Pokaži vse</a></th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
@foreach (var invoice in Model.Invoices.Where(x => x.Type == Models.Invoice.Invoice.InvoiceType.DeliveryNote))
|
|
{
|
|
<tr class="invoice-row" data-idinvoice="@invoice.IdInvoice" data-idparts="@string.Join(",", invoice.InvoiceInvoiceItem.Select(x => x.ProjectPartItem.IdProjectPartFk))">
|
|
<td style="width: 20px;">
|
|
@if (invoice.State == Invoice.InvoiceState.Confirmed)
|
|
{
|
|
<input type="checkbox" class="form-control" name="projectDeliveryNote" style="width:15px; height:15px; margin: 0px;" />
|
|
}
|
|
</td>
|
|
<td>
|
|
@Html.DisplayFor(modelItem => invoice.InvoiceYear) - @Html.DisplayFor(modelItem => invoice.InvoiceNumber)
|
|
</td>
|
|
<td>
|
|
@Html.DisplayFor(x => invoice.Partner.Title)
|
|
</td>
|
|
<td>
|
|
@Html.DisplayFor(x => invoice.Date)
|
|
</td>
|
|
<td>
|
|
@Html.DisplayFor(x => invoice.DateOfDispatch)
|
|
</td>
|
|
<td>
|
|
@switch (invoice.State)
|
|
{
|
|
case Models.Invoice.Invoice.InvoiceState.Closed:
|
|
<span class='badge badge-success'>@Html.DisplayFor(modelItem => invoice.State)</span>
|
|
break;
|
|
case Models.Invoice.Invoice.InvoiceState.Confirmed:
|
|
<span class='badge badge-warning'>@Html.DisplayFor(modelItem => invoice.State)</span>
|
|
break;
|
|
default:
|
|
<span class='badge badge-info'>@Html.DisplayFor(modelItem => invoice.State)</span>
|
|
break;
|
|
}
|
|
</td>
|
|
<td class="text-right">
|
|
<a class="btn btn-xs icon-btn btn-outline-primary borderless" asp-page="/Invoices/Print" asp-route-id="@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="@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>
|
|
<a href="Javascript:;" class="btn btn-sm btn-success" onclick="deliveryNoteCreateInvoice();">Kreiraj račun</a>
|
|
</div>
|
|
</div>
|
|
<div class="tab-pane tab-panel-invoices fade show" id="invoice-invoces">
|
|
<div class="card-body" style="padding: 0.5rem">
|
|
<table class="table">
|
|
<thead>
|
|
<tr>
|
|
<th>
|
|
#
|
|
</th>
|
|
<th>
|
|
Partner
|
|
</th>
|
|
<th>
|
|
Datum
|
|
</th>
|
|
<th>
|
|
Datum odpreme
|
|
</th>
|
|
<th>
|
|
Status
|
|
</th>
|
|
<th><a href="Javascript:;" class="btn btn-sm btn-primary" onclick="showAllInvoices();">Pokaži vse</a></th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
@foreach (var invoice in Model.Invoices.Where(x => x.Type == Models.Invoice.Invoice.InvoiceType.Invoice))
|
|
{
|
|
<tr class="invoice-row" data-idinvoice="@invoice.IdInvoice" data-idparts="@string.Join(",", invoice.InvoiceInvoiceItem.Select(x => x.ProjectPartItem.IdProjectPartFk))">
|
|
<td>
|
|
@Html.DisplayFor(modelItem => invoice.InvoiceYear) - @Html.DisplayFor(modelItem => invoice.InvoiceNumber)
|
|
</td>
|
|
<td>
|
|
@Html.DisplayFor(x => invoice.Partner.Title)
|
|
</td>
|
|
<td>
|
|
@Html.DisplayFor(x => invoice.Date)
|
|
</td>
|
|
<td>
|
|
@Html.DisplayFor(x => invoice.DateOfDispatch)
|
|
</td>
|
|
<td>
|
|
@switch (invoice.State)
|
|
{
|
|
case Models.Invoice.Invoice.InvoiceState.Closed:
|
|
<span class='badge badge-success'>@Html.DisplayFor(modelItem => invoice.State)</span>
|
|
break;
|
|
case Models.Invoice.Invoice.InvoiceState.Confirmed:
|
|
<span class='badge badge-warning'>@Html.DisplayFor(modelItem => invoice.State)</span>
|
|
break;
|
|
default:
|
|
<span class='badge badge-info'>@Html.DisplayFor(modelItem => invoice.State)</span>
|
|
break;
|
|
}
|
|
</td>
|
|
<td class="text-right">
|
|
<a class="btn btn-xs icon-btn btn-outline-success borderless" href='javascript:;' onclick="generateInvoiceExcel(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="@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="@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 class="tab-pane tab-panel-invoices fade show" id="invoice-buyers-order">
|
|
<div class="card-body" style="padding: 0.5rem">
|
|
<table class="table">
|
|
<thead>
|
|
<tr>
|
|
<th>
|
|
#
|
|
</th>
|
|
<th>
|
|
Partner
|
|
</th>
|
|
<th>
|
|
Datum
|
|
</th>
|
|
<th>
|
|
Datum odpreme
|
|
</th>
|
|
<th>
|
|
Status
|
|
</th>
|
|
<th><a href="Javascript:;" class="btn btn-sm btn-primary" onclick="showAllInvoices();">Pokaži vse</a></th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
@foreach (var invoice in Model.Invoices.Where(x => x.Type == Invoice.InvoiceType.BuyersOrder))
|
|
{
|
|
<tr class="invoice-row" data-idparts="@string.Join(",", invoice.InvoiceInvoiceItem.Select(x => x.ProjectPartItem.IdProjectPartFk))">
|
|
<td>
|
|
@Html.DisplayFor(modelItem => invoice.InvoiceYear) - @Html.DisplayFor(modelItem => invoice.InvoiceNumber)
|
|
</td>
|
|
<td>
|
|
@Html.DisplayFor(x => invoice.Partner.Title)
|
|
</td>
|
|
<td>
|
|
@Html.DisplayFor(x => invoice.Date)
|
|
</td>
|
|
<td>
|
|
@Html.DisplayFor(x => invoice.DateOfDispatch)
|
|
</td>
|
|
<td>
|
|
@switch (invoice.State)
|
|
{
|
|
case Models.Invoice.Invoice.InvoiceState.Closed:
|
|
<span class='badge badge-success'>@Html.DisplayFor(modelItem => invoice.State)</span>
|
|
break;
|
|
case Models.Invoice.Invoice.InvoiceState.Confirmed:
|
|
<span class='badge badge-warning'>@Html.DisplayFor(modelItem => invoice.State)</span>
|
|
break;
|
|
default:
|
|
<span class='badge badge-info'>@Html.DisplayFor(modelItem => invoice.State)</span>
|
|
break;
|
|
}
|
|
</td>
|
|
<td class="text-right">
|
|
<a class="btn btn-xs icon-btn btn-outline-primary borderless" asp-page="/Invoices/Print" asp-route-id="@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="@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 class="tab-pane tab-panel-invoices fade show" id="files-project">
|
|
<div class="card-body" style="padding: 0.5rem">
|
|
<table class="table">
|
|
<thead>
|
|
<tr>
|
|
<th>
|
|
Naziv
|
|
</th>
|
|
<th>
|
|
Datum
|
|
</th>
|
|
<th></th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
@foreach (var file in Model.FilesProject)
|
|
{
|
|
<tr data-idfile="@file.IdFile">
|
|
<td>
|
|
@Html.DisplayFor(modelItem => file.Title)
|
|
</td>
|
|
<td style="width: 180px">
|
|
@Html.DisplayFor(x => file.DateOfUpload)
|
|
</td>
|
|
<td class="text-right" style="width: 80px">
|
|
<a download href="@Url.Page("/Files/Upload", "DownloadFile", new { idFile = file.IdFile, idReferenceFk = file.IdReferenceFk, fileTypeInt = (int)file.FileType})" class="btn btn-xs icon-btn btn-outline-secondary borderless" data-toggle="tooltip" data-placement="top" title="Prenos" data-state="secondary"><i class="fas fa-download"></i></a>
|
|
<a class="btn btn-xs icon-btn btn-outline-danger borderless" data-state="danger" href='javascript:;' onclick="deleteFile(this)"><i class="fas fa-times"></i></a>
|
|
</td>
|
|
</tr>
|
|
}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
<div class="tab-pane tab-panel-invoices fade show" id="files-project-part">
|
|
<div class="card-body" style="padding: 0.5rem">
|
|
<table class="table">
|
|
<thead>
|
|
<tr>
|
|
<th>
|
|
Naziv
|
|
</th>
|
|
<th>
|
|
Datum
|
|
</th>
|
|
<th></th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
@foreach (var file in Model.FilesProjectParts)
|
|
{
|
|
<tr class="invoice-row" data-idparts="@file.IdReferenceFk" data-idfile="@file.IdFile">
|
|
<td>
|
|
@Html.DisplayFor(modelItem => file.Title)
|
|
</td>
|
|
<td style="width: 180px">
|
|
@Html.DisplayFor(x => file.DateOfUpload)
|
|
</td>
|
|
<td class="text-right" style="width: 80px">
|
|
<a download href="@Url.Page("/Files/Upload", "DownloadFile", new { idFile = file.IdFile, idReferenceFk = file.IdReferenceFk, fileTypeInt = (int)file.FileType})" class="btn btn-xs icon-btn btn-outline-secondary borderless" data-toggle="tooltip" data-placement="top" title="Prenos" data-state="secondary"><i class="fas fa-download"></i></a>
|
|
<a class="btn btn-xs icon-btn btn-outline-danger borderless" data-state="danger" href='javascript:;' onclick="deleteFile(this)"><i class="fas fa-times"></i></a>
|
|
</td>
|
|
</tr>
|
|
}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
<div class="tab-pane tab-panel-invoices fade show" id="invoice-cooperatioins">
|
|
<div class="card-body" style="padding: 0.5rem">
|
|
<table class="table">
|
|
<thead>
|
|
<tr>
|
|
<th>
|
|
#
|
|
</th>
|
|
<th>
|
|
Partner
|
|
</th>
|
|
<th>
|
|
Datum
|
|
</th>
|
|
<th>
|
|
Datum odpreme
|
|
</th>
|
|
<th>
|
|
Status
|
|
</th>
|
|
<th><a href="Javascript:;" class="btn btn-sm btn-primary" onclick="showAllInvoices();">Pokaži vse</a></th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
@foreach (var invoice in Model.Invoices.Where(x => x.Type == Invoice.InvoiceType.Cooperation))
|
|
{
|
|
<tr class="invoice-row" data-idparts="@string.Join(",", invoice.InvoiceInvoiceItem.Select(x => x.ProjectPartItem.IdProjectPartFk))">
|
|
<td>
|
|
@Html.DisplayFor(modelItem => invoice.InvoiceYear) - @Html.DisplayFor(modelItem => invoice.InvoiceNumber)
|
|
</td>
|
|
<td>
|
|
@Html.DisplayFor(x => invoice.Partner.Title)
|
|
</td>
|
|
<td>
|
|
@Html.DisplayFor(x => invoice.Date)
|
|
</td>
|
|
<td>
|
|
@Html.DisplayFor(x => invoice.DateOfDispatch)
|
|
</td>
|
|
<td>
|
|
@switch (invoice.State)
|
|
{
|
|
case Models.Invoice.Invoice.InvoiceState.Closed:
|
|
<span class='badge badge-success'>@Html.DisplayFor(modelItem => invoice.State)</span>
|
|
break;
|
|
case Models.Invoice.Invoice.InvoiceState.Confirmed:
|
|
<span class='badge badge-warning'>@Html.DisplayFor(modelItem => invoice.State)</span>
|
|
break;
|
|
default:
|
|
<span class='badge badge-info'>@Html.DisplayFor(modelItem => invoice.State)</span>
|
|
break;
|
|
}
|
|
</td>
|
|
<td class="text-right">
|
|
<a class="btn btn-xs icon-btn btn-outline-primary borderless" asp-page="/Invoices/Print" asp-route-id="@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="@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>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="row">
|
|
<div class="col-12">
|
|
<div class="card">
|
|
<h6 class="card-header">
|
|
Deli projekta
|
|
</h6>
|
|
<div class="card-body" style="padding: 0.5rem">
|
|
<div class="accordion" id="accordionProjectParts">
|
|
@foreach (var part in Model.Parts)
|
|
{
|
|
<div id="accordion-item">
|
|
<div class="card mb-2">
|
|
<div class="card-header">
|
|
<a class="text-body" data-toggle="collapse" href="#accordion-@part.IdProjectPart">
|
|
@Html.DisplayFor(x => part.Title)
|
|
(@Html.DisplayFor(x => part.ProjectPartNumberFormatted))
|
|
</a>
|
|
|
|
@switch (part.Status)
|
|
{
|
|
case ProjectPartStatus.Finished:
|
|
<span class='badge badge-success'>@Html.DisplayFor(modelItem => part.Status)</span>
|
|
break;
|
|
case ProjectPartStatus.InProduction:
|
|
<span class='badge badge-warning'>@Html.DisplayFor(modelItem => part.Status)</span>
|
|
break;
|
|
case ProjectPartStatus.Shipped:
|
|
<span class='badge badge-warning'>@Html.DisplayFor(modelItem => part.Status)</span>
|
|
break;
|
|
default:
|
|
<span class='badge badge-info'>@Html.DisplayFor(modelItem => part.Status)</span>
|
|
break;
|
|
}
|
|
@{
|
|
string totalPrice = part.ProjectPartProjectPartItem.Sum(x => (x.WorkPrice + x.MaterialPrice) * x.NumberOfItems).ToString("0.00");
|
|
}
|
|
|
|
<div style="float: right">
|
|
<a class="btn btn-xs icon-btn btn-outline-primary borderless" asp-page="/Projects/PrintProjectPartPaths" asp-route-id="@part.IdProjectPart" data-toggle="tooltip" data-placement="top" title="Tiskanje" data-state="primary"><i class="ion ion-md-print"></i></a>
|
|
<a asp-page="/Files/Upload" asp-route-idReferenceFk="@part.IdProjectPart" asp-route-fileType="@Models.FileType.ProjectPart" class="btn btn-xs icon-btn btn-outline-secondary borderless" data-toggle="tooltip" data-placement="top" title="Priloži datoteko" data-state="secondary"><i class="fas fa-upload"></i></a>
|
|
<a data-idprojectpart="@part.IdProjectPart" class="btn btn-xs icon-btn btn-outline-secondary borderless" data-toggle="tooltip" data-placement="top" title="Kopiraj del projekta" data-state="secondary" href="javascript:;" onclick="copyProjectPart(this);"><i class="far fa-copy"></i></a>
|
|
<a asp-page="EditPart" asp-route-id="@part.IdProjectPart" class="btn btn-xs icon-btn btn-outline-secondary borderless" data-toggle="tooltip" data-placement="top" title="Urejanje" data-state="secondary"><i class="fas fa-pencil-alt"></i></a>
|
|
<a data-idprojectpart="@part.IdProjectPart" class="btn btn-xs icon-btn btn-outline-danger borderless" data-toggle="tooltip" data-placement="top" title="Odstrani" data-state="danger" href="javascript:;" onclick="deleteProjectPart(this);"><i class="fas fa-times"></i></a>
|
|
</div>
|
|
@if (!string.IsNullOrEmpty(part.PathOfPlans))
|
|
{
|
|
<br />
|
|
<small>@Html.DisplayFor(x => part.PathOfPlans)</small>
|
|
}
|
|
</div>
|
|
|
|
<div id="accordion-@part.IdProjectPart" data-idprojectpart="@part.IdProjectPart" class="accordion-panel collapse" data-parent="#accordionProjectParts">
|
|
<div class="card-body" style="padding: 0.5rem">
|
|
<table class="table table-hover">
|
|
<thead>
|
|
<tr>
|
|
<th>
|
|
<input type="checkbox" class="form-control" onclick="selectAllInTable(this)" style="width:15px; height:15px;"/>
|
|
</th>
|
|
<th>
|
|
Naziv<br/>Št. pozicije
|
|
</th>
|
|
<th>
|
|
Material - Dobavitelj
|
|
<br/>
|
|
Dimenzije surovca
|
|
</th>
|
|
<th class="table-header-number">
|
|
<div data-toggle="tooltip" data-placement="top" title="Število kosov<br/>Število kompletov" data-html="true">
|
|
Kos
|
|
<br/>
|
|
Kpl.
|
|
</div>
|
|
</th>
|
|
<th class="table-header-number">
|
|
<div data-toggle="tooltip" data-placement="top" title="Material cena<br/>Material vrednost" data-html="true">
|
|
Mat. cena
|
|
<br/>
|
|
Mat. vred.
|
|
</div>
|
|
</th>
|
|
<th class="table-header-number">
|
|
<div data-toggle="tooltip" data-placement="top" title="Delo cena<br/>Delo vrednost" data-html="true">
|
|
Delo cena
|
|
<br/>
|
|
Delo vred.
|
|
</div>
|
|
</th>
|
|
<th class="table-header-number">
|
|
<div data-toggle="tooltip" data-placement="top" title="Stroškovna cena<br/>Stroškovna vrednost" data-html="true">
|
|
Str. cena
|
|
<br/>
|
|
Str. vred.
|
|
</div>
|
|
</th>
|
|
<th class="table-header-number">
|
|
<div data-toggle="tooltip" data-placement="top" title="Razlika v ceni<br/>Razlika v ceni v procentih" data-html="true">
|
|
RVC
|
|
<br/>
|
|
RVC %
|
|
</div>
|
|
</th>
|
|
<th class="table-header-number">
|
|
<div data-toggle="tooltip" data-placement="top" title="Prodajna cena<br/>Prodaja vrednost" data-html="true">
|
|
Prod. cena
|
|
<br/>
|
|
Prod. vred.
|
|
</div>
|
|
</th>
|
|
<th>
|
|
<div data-toggle="tooltip" data-placement="top" title="Status<br/>Dobavni rok" data-html="true">
|
|
Status
|
|
<br/>
|
|
Dob. rok
|
|
</div>
|
|
</th>
|
|
<th></th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
@foreach (var partItem in part.ProjectPartProjectPartItem)
|
|
{
|
|
<partial name="DetailsPartItem" model="partItem"></partial>
|
|
}
|
|
</tbody>
|
|
</table>
|
|
<div class="row">
|
|
<div class="col-6">
|
|
<div class="form-inline">
|
|
<label class="form-label" style="font-weight: normal;">Marža na vse pozicije:</label>
|
|
|
|
<input class="form-control form-control-sm" type="text" id="inpMarginOnAllPositions_" style="width: 50px;"/>
|
|
|
|
<label class="form-label" style="font-weight: normal;">%</label>
|
|
|
|
<a data-idprojectpart="@part.IdProjectPart" href="javascript:;" class="btn btn-sm btn-primary" onclick="projectPartAddMarginOnAll(this);">Dodaj</a>
|
|
</div>
|
|
<div class="form-inline">
|
|
<label class="form-label" style="font-weight: normal;">Nova prodajan cena dela projekta:</label>
|
|
|
|
<input class="form-control form-control-sm" type="text" id="inpNewSaleValueForAllPositions_" style="width: 150px;"/>
|
|
|
|
<label class="form-label" style="font-weight: normal;">€</label>
|
|
|
|
<a data-idprojectpart="@part.IdProjectPart" href="javascript:;" class="btn btn-sm btn-primary" onclick="projectPartNewSaleValueForAll(this);">Dodaj</a>
|
|
</div>
|
|
<label id="lblProjectPartValues_@part.IdProjectPart" class="form-label" style="font-weight: initial;"></label>
|
|
</div>
|
|
<div class="col-6" style="text-align: right">
|
|
<a asp-page="CreateEditPartItem" asp-route-idProject="@Model.Project.IdProject" asp-route-idProjectPart="@part.IdProjectPart" asp-route-edit="@false" class="btn btn-sm btn-primary">Dodaj pozicijo</a>
|
|
<a asp-page="CreatePartItemUploadExcel" asp-route-idProject="@Model.Project.IdProject" asp-route-idProjectPart="@part.IdProjectPart" class="btn btn-sm btn-success">Uvozi kosovnico</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
}
|
|
</div>
|
|
</div>
|
|
<div class="card-footer py-3">
|
|
<div class="row">
|
|
<div class="col-6">
|
|
<button class="btn btn-success" onclick="createOrderSelectPartner(false); return false;">Kreiraj naročilo</button>
|
|
<button class="btn btn-success" onclick="createOrderSelectPartner(true); return false;">Kreiraj povpraševanje</button>
|
|
<button class="btn btn-info" onclick="createCooperationSelectPartner(); return false;">Kreiraj kooperacijo</button>
|
|
<button class="btn btn-primary" onclick="createInvoice(); return false;">Kreiraj dobavnico</button>
|
|
|
|
</div>
|
|
<div class="col-6 text-right">
|
|
<a asp-page="CreatePart" asp-route-idProject="@Model.Project.IdProject" class="btn btn-primary pull-right">Nov del projekta</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
@Html.AntiForgeryToken()
|
|
<div id="divModalCodetableItemAddEditPlaceholder"></div>
|
|
</form>
|
|
|
|
@section Scripts {
|
|
@{await Html.RenderPartialAsync("_ValidationScriptsPartial");}
|
|
|
|
<!-- HTMX -->
|
|
<script src="~/vendor/libs/htmx.org/dist/htmx.js" asp-append-version="true"></script>
|
|
<script src="~/vendor/libs/js-cookie/js.cookie.min.js" asp-append-version="true"></script>
|
|
<script src="~/vendor/libs/select2/select2.js" asp-append-version="true"></script>
|
|
<script src="~/vendor/libs/moment/moment.js" asp-append-version="true"></script>
|
|
<script src="~/js/codeTableItemHelper.js?v=3" asp-append-version="true"></script>
|
|
<script src="~/js/fileHelper.js?v=1" asp-append-version="true"></script>
|
|
|
|
<script>
|
|
const openProjectPartCookieName = 'openProjectPart' + @Html.Raw(Model.Project.IdProject);
|
|
$(document).ready(function() {
|
|
document.body.addEventListener('htmx:afterSettle',
|
|
function(evt) {
|
|
$('.select2').select2();
|
|
|
|
$('.inp-tbl-edit-calculate-price').on("input",
|
|
function() {
|
|
let id = $(this).parent().parent().attr('data-iditem');
|
|
let value = parseFloat($('#inpTblDifferenceInPrice_' + id).val().replace(',', '.'));
|
|
if (isNaN(value)) {
|
|
return;
|
|
}
|
|
let costs = parseFloat($('#inpTblMaterialPrice_' + id).val().replace(',', '.')) + parseFloat($('#inpTblWrokPrice_' + id).val().replace(',', '.'));
|
|
$('#inpTblCostPrice_' + id).val(costs);
|
|
|
|
let sellingPrice = costs * (value + 100.0) / 100.0;
|
|
$('#inpTblSellingPrice_' + id).val(sellingPrice);
|
|
console.log(12);
|
|
});
|
|
|
|
|
|
$('.inp-tbl-edit-calculate-difference-in-price').on("input",
|
|
function() {
|
|
let id = $(this).parent().parent().attr('data-iditem');
|
|
let value = parseFloat($('#inpTblSellingPrice_' + id).val().replace(',', '.'));
|
|
if (isNaN(value)) {
|
|
return;
|
|
}
|
|
let costs = parseFloat($('#inpTblMaterialPrice_' + id).val().replace(',', '.')) + parseFloat($('#inpTblWrokPrice_' + id).val().replace(',', '.'));
|
|
|
|
let differenceInPrice = costs == 0
|
|
? 0
|
|
: (value * 100 / costs) - 100;
|
|
$('#inpTblDifferenceInPrice_' + id).val(differenceInPrice);
|
|
console.log(13);
|
|
});
|
|
|
|
});
|
|
|
|
tooltips();
|
|
$('.accordion-panel').on('show.bs.collapse',
|
|
function() {
|
|
let idProjectPart = $(this).attr('data-idprojectpart');
|
|
//Nastavim cookie
|
|
Cookies.set(openProjectPartCookieName, $(this).attr('id'), { expires: 365 });
|
|
|
|
//Skrijem vrstice povezanih dokumentov
|
|
$(".invoice-row").each(function() {
|
|
let idParts = $(this).attr('data-idparts').split(',');
|
|
if (idParts.includes(idProjectPart)) {
|
|
$(this).show();
|
|
} else {
|
|
$(this).hide();
|
|
}
|
|
});
|
|
});
|
|
//$('.accordion-panel').on('hidden.bs.collapse', function () {
|
|
// console.log('colapse');
|
|
//});
|
|
|
|
$('.project-status').on('change', function (e) {
|
|
let value = $('.project-status').val();
|
|
console.log(value);
|
|
if (value === '2') {
|
|
$('.project-finished-date').val(moment().format('YYYY-MM-DD'));
|
|
} else {
|
|
$('.project-finished-date').val('');
|
|
}
|
|
});
|
|
let openProjectPartId = Cookies.get(openProjectPartCookieName);
|
|
if (openProjectPartId !== null) {
|
|
$('#' + openProjectPartId).collapse("show");
|
|
}
|
|
refreshPrices();
|
|
});
|
|
|
|
function showAllInvoices() {
|
|
$(".invoice-row").each(function() {
|
|
$(this).show();
|
|
});
|
|
}
|
|
|
|
function tooltips() {
|
|
$('[data-toggle="tooltip"]').tooltip();
|
|
}
|
|
function createOrderSelectPartner(inquiry) {
|
|
$.blockUI();
|
|
$.ajax({
|
|
type: "GET",
|
|
url: "/CodeTablePartners/Index/?handler=Partners",
|
|
data: {
|
|
suppliers: true
|
|
},
|
|
success: function (data) {
|
|
$.unblockUI();
|
|
if (data.successful) {
|
|
console.log(data.jsonPartners);
|
|
let confirmed = false;
|
|
Swal.fire({
|
|
title: 'Izberi partnerja',
|
|
input: 'select',
|
|
inputOptions: JSON.parse(data.jsonPartners),
|
|
inputPlaceholder: 'Samodejno',
|
|
showCancelButton: true,
|
|
confirmButtonText: 'Potrdi',
|
|
cancelButtonText: 'Prekliči',
|
|
inputValidator: (value) => {
|
|
return new Promise((resolve) => {
|
|
resolve();
|
|
});
|
|
}
|
|
}).then((result) => {
|
|
if (result.isConfirmed) {
|
|
createOrder(inquiry, result.value);
|
|
}
|
|
});
|
|
} else {
|
|
console.log(data);
|
|
Swal.fire('Napaka pri pridobivanju partnerjev',
|
|
data.error,
|
|
'error');
|
|
}
|
|
|
|
},
|
|
error: function (xhr, ajaxOptions, thrownError) {
|
|
console.log(xhr);
|
|
alert(xhr.responseText);
|
|
$.unblockUI();
|
|
}
|
|
});
|
|
}
|
|
|
|
function createOrder(inquiry, idPartner) {
|
|
if (idPartner == null || idPartner == undefined || isNaN(idPartner))
|
|
idPartner = 0;
|
|
|
|
let object = getSelectedPartItems();
|
|
|
|
if (object.length <= 0) {
|
|
alert("Izberi pozicije!");
|
|
return;
|
|
}
|
|
$.blockUI();
|
|
$.ajax({
|
|
type: "POST",
|
|
beforeSend: function(xhr) {
|
|
xhr.setRequestHeader("XSRF-TOKEN",
|
|
$('input:hidden[name="__RequestVerificationToken"]').val());
|
|
},
|
|
url: "Edit/?handler=CreateOrder",
|
|
data: { itemsJson: JSON.stringify(object), inquiry: inquiry, idPartner: idPartner },
|
|
success: function(data) {
|
|
if (data.successful) {
|
|
if (inquiry) {
|
|
window.location.href = '/Invoices/Edit?id=' + data.idInvoice;
|
|
} else {
|
|
location.reload();
|
|
}
|
|
|
|
} else {
|
|
}
|
|
|
|
},
|
|
error: function(xhr, ajaxOptions, thrownError) {
|
|
alert(xhr.responseText);
|
|
$.unblockUI();
|
|
}
|
|
});
|
|
}
|
|
|
|
function createCooperationSelectPartner() {
|
|
$.blockUI();
|
|
$.ajax({
|
|
type: "GET",
|
|
url: "/CodeTablePartners/Index/?handler=Partners",
|
|
data: {
|
|
suppliers: true
|
|
},
|
|
success: function (data) {
|
|
$.unblockUI();
|
|
if (data.successful) {
|
|
console.log(data.jsonPartners);
|
|
(async () => {
|
|
|
|
const { value: idPartner } = await Swal.fire({
|
|
title: 'Izberi partnerja',
|
|
input: 'select',
|
|
inputOptions: JSON.parse(data.jsonPartners),
|
|
inputPlaceholder: 'Izberi partnerja',
|
|
showCancelButton: true,
|
|
confirmButtonText: 'Potrdi',
|
|
cancelButtonText: 'Prekliči',
|
|
inputValidator: (value) => {
|
|
return new Promise((resolve) => {
|
|
if (value) {
|
|
resolve();
|
|
} else {
|
|
resolve("Partner ni izbran!");
|
|
}
|
|
});
|
|
}
|
|
});
|
|
if (idPartner) {
|
|
createCooperation(idPartner);
|
|
}
|
|
|
|
})();
|
|
} else {
|
|
console.log(data);
|
|
Swal.fire('Napaka pri pridobivanju partnerjev',
|
|
data.error,
|
|
'error');
|
|
}
|
|
|
|
},
|
|
error: function (xhr, ajaxOptions, thrownError) {
|
|
console.log(xhr);
|
|
alert(xhr.responseText);
|
|
$.unblockUI();
|
|
}
|
|
});
|
|
}
|
|
|
|
function createCooperation(idPartner) {
|
|
if (idPartner == null || idPartner == undefined || isNaN(idPartner))
|
|
idPartner = 0;
|
|
|
|
let object = getSelectedPartItems();
|
|
|
|
if (object.length <= 0) {
|
|
alert("Izberi pozicije!");
|
|
return;
|
|
}
|
|
$.blockUI();
|
|
$.ajax({
|
|
type: "POST",
|
|
beforeSend: function(xhr) {
|
|
xhr.setRequestHeader("XSRF-TOKEN",
|
|
$('input:hidden[name="__RequestVerificationToken"]').val());
|
|
},
|
|
url: "Edit/?handler=CreateCooperation",
|
|
data: { itemsJson: JSON.stringify(object), idPartner: idPartner },
|
|
success: function(data) {
|
|
if (data.successful) {
|
|
window.location.href = '/Invoices/Edit?id=' + data.idInvoice;
|
|
} else {
|
|
}
|
|
|
|
},
|
|
error: function(xhr, ajaxOptions, thrownError) {
|
|
alert(xhr.responseText);
|
|
$.unblockUI();
|
|
}
|
|
});
|
|
}
|
|
|
|
function createInvoice() {
|
|
let object = getSelectedPartItems();
|
|
|
|
if (object.length <= 0) {
|
|
alert("Izberi pozicije!");
|
|
return;
|
|
}
|
|
$.blockUI();
|
|
$.ajax({
|
|
type: "POST",
|
|
beforeSend: function(xhr) {
|
|
xhr.setRequestHeader("XSRF-TOKEN",
|
|
$('input:hidden[name="__RequestVerificationToken"]').val());
|
|
},
|
|
url: "Edit/?handler=CreateDeliveryNote",
|
|
data: { itemsJson: JSON.stringify(object) },
|
|
success: function(data) {
|
|
location.reload();
|
|
},
|
|
error: function(xhr, ajaxOptions, thrownError) {
|
|
alert(xhr.responseText);
|
|
$.unblockUI();
|
|
}
|
|
});
|
|
}
|
|
|
|
function getSelectedPartItems() {
|
|
let object = [];
|
|
$("input:checkbox[name=projectPartItem]:checked").each(function() {
|
|
object.push(parseInt($(this).parent().parent().attr('data-idpartitem')));
|
|
});
|
|
|
|
return object;
|
|
}
|
|
|
|
function updatePartItem(element) {
|
|
let id = $(element).attr('data-iditem');
|
|
let row = $(element).parent().parent();
|
|
|
|
let idItem = parseInt(row.find("select[id=selTblItem_" + id + "]").val());
|
|
let numberOfSets = parseInt(row.find("input[id=inpTblNumberOfSets_" + id + "]").val());
|
|
if (isNaN(numberOfSets)) {
|
|
alert('Nepravilna vrednost v polju število setov!');
|
|
return;
|
|
}
|
|
let numberOfItems = parseInt(row.find("input[id=inpTblNumberOfItems_" + id + "]").val());
|
|
if (isNaN(numberOfItems)) {
|
|
alert('Nepravilna vrednost v polju število kosov!');
|
|
return;
|
|
}
|
|
let idMaterial = parseInt(row.find("select[id=selTblMaterial_" + id + "]").val());
|
|
let materialDimension = row.find("input[id=inpTblMaterialDimensions_" + id + "]").val();
|
|
let idSupplier = parseInt(row.find("select[id=selTblMaterialSupplier_" + id + "]").val());
|
|
let materialPrice = parseFloat(row.find("input[id=inpTblMaterialPrice_" + id + "]").val().replace(',', '.'));
|
|
if (isNaN(materialPrice)) {
|
|
alert('Nepravilna vrednost v polju cena material!');
|
|
return;
|
|
}
|
|
let workPrice = parseFloat(row.find("input[id=inpTblWrokPrice_" + id + "]").val().replace(',', '.'));
|
|
if (isNaN(materialPrice)) {
|
|
alert('Nepravilna vrednost v polju cena delo!');
|
|
return;
|
|
}
|
|
let sellingPrice = parseFloat(row.find("input[id=inpTblSellingPrice_" + id + "]").val().replace(',', '.'));
|
|
if (isNaN(sellingPrice)) {
|
|
alert('Nepravilna vrednost v polju prodajna cena!');
|
|
return;
|
|
}
|
|
let status = parseInt(row.find("select[id=selTblStatus_" + id + "]").val());
|
|
let deliveryDate = row.find("input[id=inpTblDeliveryDate_" + id + "]").val();
|
|
|
|
var item = {
|
|
IdItemFk: idItem,
|
|
NumberOfSets: numberOfSets,
|
|
NumberOfItems: numberOfItems,
|
|
IdMaterialFk: idMaterial,
|
|
MaterialDimensions: materialDimension,
|
|
IdMaterialSupplierFk: idSupplier,
|
|
MaterialPrice: materialPrice,
|
|
WorkPrice: workPrice,
|
|
Status: status,
|
|
DeliveryDate: deliveryDate,
|
|
SellingPrice: sellingPrice
|
|
};
|
|
|
|
if (deliveryDate === '') {
|
|
delete item.DeliveryDate;
|
|
}
|
|
|
|
var jsonString = JSON.stringify(item);
|
|
$.blockUI();
|
|
$.ajax({
|
|
type: "POST",
|
|
beforeSend: function(xhr) {
|
|
xhr.setRequestHeader("XSRF-TOKEN",
|
|
$('input:hidden[name="__RequestVerificationToken"]').val());
|
|
},
|
|
url: "Edit/?handler=UpdatePartItem",
|
|
data: { idItem: id, json: jsonString },
|
|
success: function(data) {
|
|
if (data.successful) {
|
|
document.getElementById('btnTblCancel_' + id).click();
|
|
$.unblockUI();
|
|
refreshPrices();
|
|
} else {
|
|
$.unblockUI();
|
|
Swal.fire('Napaka pri posodabljanju pozicije',
|
|
data.error,
|
|
'error');
|
|
}
|
|
},
|
|
error: function(xhr, ajaxOptions, thrownError) {
|
|
alert(xhr.responseText);
|
|
$.unblockUI();
|
|
}
|
|
});
|
|
}
|
|
|
|
function deletePartItem(element) {
|
|
Swal.fire({
|
|
title: `Izbrišem pozicijo?`,
|
|
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) {
|
|
let idPartItem = parseInt($(element).parent().parent().attr('data-idpartitem'));
|
|
$.blockUI();
|
|
$.ajax({
|
|
type: "Delete",
|
|
beforeSend: function(xhr) {
|
|
xhr.setRequestHeader("XSRF-TOKEN",
|
|
$('input:hidden[name="__RequestVerificationToken"]').val());
|
|
},
|
|
url: "Edit/?handler=PartItem",
|
|
data: { idPartItem: idPartItem },
|
|
success: function(data) {
|
|
if (data.successful) {
|
|
$(element).parent().parent().remove();
|
|
$.unblockUI();
|
|
refreshPrices();
|
|
} else {
|
|
$.unblockUI();
|
|
Swal.fire('Napaka pri brisanju pozicije',
|
|
data.error,
|
|
'error');
|
|
}
|
|
},
|
|
error: function(xhr, ajaxOptions, thrownError) {
|
|
alert(xhr.responseText);
|
|
$.unblockUI();
|
|
}
|
|
});
|
|
}
|
|
});
|
|
}
|
|
|
|
function deleteProjectPart(element) {
|
|
let idProjectPart = $(element).attr('data-idprojectpart');
|
|
$.blockUI();
|
|
$.ajax({
|
|
type: "GET",
|
|
url: "Edit/?handler=ProjectPart",
|
|
data: {
|
|
idProjectPart
|
|
},
|
|
success: function(data) {
|
|
$.unblockUI();
|
|
if (data.successful) {
|
|
if (data.inUse) {
|
|
Swal.fire('Pozicije dela projekta imajo vezavo na dobavnice/naročila!',
|
|
'Brisanje ni možno!',
|
|
'warning');
|
|
return;
|
|
}
|
|
Swal.fire({
|
|
title: `Izbrišem del projekta ${data.projectPart.title} in vse pozicije tega dela?`,
|
|
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: "Edit/?handler=ProjectPart",
|
|
data: {
|
|
idProjectPart
|
|
},
|
|
success: function(data) {
|
|
$.unblockUI();
|
|
if (data.successful) {
|
|
location.reload();
|
|
} else {
|
|
Swal.fire('Napaka pri brisanju dela projekta',
|
|
data.error,
|
|
'error');
|
|
}
|
|
|
|
},
|
|
error: function(xhr, ajaxOptions, thrownError) {
|
|
console.log(xhr);
|
|
alert(xhr.responseText);
|
|
$.unblockUI();
|
|
}
|
|
});
|
|
} else {
|
|
if (onCancel != null) {
|
|
onCancel();
|
|
}
|
|
}
|
|
});
|
|
} else {
|
|
Swal.fire('Napaka pri branju dela projekta',
|
|
data.error,
|
|
'error');
|
|
}
|
|
},
|
|
error: function(xhr, ajaxOptions, thrownError) {
|
|
console.log(xhr);
|
|
alert(xhr.responseText);
|
|
$.unblockUI();
|
|
}
|
|
});
|
|
}
|
|
|
|
function selectAllInTable(element) {
|
|
let table = $(element).parent().parent().parent().parent();
|
|
let body = table.find('tbody');
|
|
|
|
let checked = $(element).is(':checked');
|
|
body.find("input[name=projectPartItem]").prop("checked", checked);
|
|
}
|
|
|
|
function copyProjectPart(element) {
|
|
let idProjectPart = $(element).attr('data-idprojectpart');
|
|
|
|
Swal.fire({
|
|
title: `Kopiram del projekta?`,
|
|
text: "Tega dejanja ni možno razveljaviti!",
|
|
icon: 'warning',
|
|
showCancelButton: true,
|
|
confirmButtonColor: '#3085d6',
|
|
cancelButtonColor: '#d33',
|
|
confirmButtonText: 'Da, kopiraj!',
|
|
cancelButtonText: 'Prekliči!'
|
|
}).then((result) => {
|
|
if (result.isConfirmed) {
|
|
$.blockUI();
|
|
$.ajax({
|
|
type: "POST",
|
|
beforeSend: function(xhr) {
|
|
xhr.setRequestHeader("XSRF-TOKEN",
|
|
$('input:hidden[name="__RequestVerificationToken"]').val());
|
|
},
|
|
url: "Edit/?handler=CopyProjectPart",
|
|
data: {
|
|
idProjectPart
|
|
},
|
|
success: function(data) {
|
|
$.unblockUI();
|
|
if (data.successful) {
|
|
location.reload();
|
|
} else {
|
|
Swal.fire('Napaka pri kopiranju dela projekta',
|
|
data.error,
|
|
'error');
|
|
}
|
|
|
|
},
|
|
error: function(xhr, ajaxOptions, thrownError) {
|
|
console.log(xhr);
|
|
alert(xhr.responseText);
|
|
$.unblockUI();
|
|
}
|
|
});
|
|
} else {
|
|
if (onCancel != null) {
|
|
onCancel();
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
function editCodetableItem(element) {
|
|
let idItem = $(element).attr("data-idcodetableitem");
|
|
let idPartItem = $(element).parent().parent().attr("data-idpartitem");
|
|
|
|
codeTableItemAddEdit('#divModalCodetableItemAddEditPlaceholder',
|
|
true,
|
|
idItem,
|
|
(idCodeTableItem) => {
|
|
document.getElementById('btnTblCancel_' + idPartItem).click();
|
|
},
|
|
null,
|
|
1);
|
|
|
|
}
|
|
|
|
function deleteFile(element) {
|
|
let row = $(element).parent().parent();
|
|
let idFile = parseInt(row.attr('data-idfile'));
|
|
|
|
fileDelete(idFile,
|
|
(idFile) => {
|
|
row.remove();
|
|
});
|
|
}
|
|
|
|
function refreshPrices() {
|
|
let idProject = @Model.Project.IdProject;
|
|
$.blockUI();
|
|
$.ajax({
|
|
type: "GET",
|
|
url: "Edit/?handler=ProjectPriceDetails",
|
|
data: { idProject: idProject },
|
|
success: function(data) {
|
|
$.unblockUI();
|
|
if (data.successful) {
|
|
data.totals.parts.forEach(x => {
|
|
$('#lblProjectPartValues_' + x.idProjectPart).html(x.text);
|
|
});
|
|
|
|
$('#lblProjectPrices').html(data.totals.project.text);
|
|
|
|
} else {
|
|
Swal.fire('Napaka pri osveževanju cen!',
|
|
'Brisanje ni možno!',
|
|
'warning');
|
|
}
|
|
|
|
},
|
|
error: function(xhr, ajaxOptions, thrownError) {
|
|
alert(xhr.responseText);
|
|
$.unblockUI();
|
|
}
|
|
});
|
|
}
|
|
|
|
function projectPartAddMarginOnAll(button) {
|
|
const idProjectPart = $(button).attr('data-idprojectPart');
|
|
const value = parseFloat($(button).closest("div").find('input').val());
|
|
|
|
$.blockUI();
|
|
$.ajax({
|
|
type: "POST",
|
|
beforeSend: function(xhr) {
|
|
xhr.setRequestHeader("XSRF-TOKEN",
|
|
$('input:hidden[name="__RequestVerificationToken"]').val());
|
|
},
|
|
url: "Edit/?handler=ProjectPartAddMarginOnAllPositions",
|
|
data: { idProjectPart: idProjectPart, value: value },
|
|
success: function(data) {
|
|
if (data.successful) {
|
|
location.reload();
|
|
} else {
|
|
Swal.fire('Napaka pri posodabljanju pozicij',
|
|
data.error,
|
|
'error');
|
|
}
|
|
|
|
},
|
|
error: function(xhr, ajaxOptions, thrownError) {
|
|
alert(xhr.responseText);
|
|
$.unblockUI();
|
|
}
|
|
});
|
|
}
|
|
|
|
function projectPartNewSaleValueForAll(button) {
|
|
const idProjectPart = $(button).attr('data-idprojectPart');
|
|
const value = parseFloat($(button).closest("div").find('input').val());
|
|
|
|
$.blockUI();
|
|
$.ajax({
|
|
type: "POST",
|
|
beforeSend: function(xhr) {
|
|
xhr.setRequestHeader("XSRF-TOKEN",
|
|
$('input:hidden[name="__RequestVerificationToken"]').val());
|
|
},
|
|
url: "Edit/?handler=ProjectPartNewSaleValueForAllPositions",
|
|
data: { idProjectPart: idProjectPart, value: value },
|
|
success: function(data) {
|
|
if (data.successful) {
|
|
location.reload();
|
|
} else {
|
|
Swal.fire('Napaka pri posodabljanju pozicij',
|
|
data.error,
|
|
'error');
|
|
}
|
|
|
|
},
|
|
error: function(xhr, ajaxOptions, thrownError) {
|
|
alert(xhr.responseText);
|
|
$.unblockUI();
|
|
}
|
|
});
|
|
}
|
|
|
|
function deliveryNoteCreateInvoice() {
|
|
let idInvoices = [];
|
|
$("input:checkbox[name=projectDeliveryNote]:checked").each(function() {
|
|
idInvoices.push(parseInt($(this).parent().parent().attr('data-idinvoice')));
|
|
});
|
|
|
|
if (idInvoices.length <= 0) {
|
|
alert("Izberi dobavnice!");
|
|
return;
|
|
}
|
|
$.blockUI();
|
|
$.ajax({
|
|
type: "POST",
|
|
beforeSend: function(xhr) {
|
|
xhr.setRequestHeader("XSRF-TOKEN",
|
|
$('input:hidden[name="__RequestVerificationToken"]').val());
|
|
},
|
|
url: "Edit/?handler=CreateInvoice",
|
|
data: { itemsJson: JSON.stringify(idInvoices) },
|
|
success: function(data) {
|
|
if (data.successful) {
|
|
window.location.href = `/Invoices/Edit?id=${data.idInvoice}`;
|
|
} else {
|
|
Swal.fire('Napaka pri kreiranju računa!',
|
|
data.error,
|
|
'warning');
|
|
}
|
|
},
|
|
error: function(xhr, ajaxOptions, thrownError) {
|
|
alert(xhr.responseText);
|
|
$.unblockUI();
|
|
}
|
|
});
|
|
|
|
}
|
|
|
|
function createOfferFromProject() {
|
|
let idProject = @Model.Project.IdProject;
|
|
|
|
let object = getSelectedPartItems();
|
|
|
|
if (object.length <= 0) {
|
|
alert("Izberi pozicije!");
|
|
return;
|
|
}
|
|
|
|
$.blockUI();
|
|
$.ajax({
|
|
type: "POST",
|
|
beforeSend: function(xhr) {
|
|
xhr.setRequestHeader("XSRF-TOKEN",
|
|
$('input:hidden[name="__RequestVerificationToken"]').val());
|
|
},
|
|
url: "Edit/?handler=CreateOfferFromProject",
|
|
data: { idProject, itemsJson: JSON.stringify(object) },
|
|
success: function(data) {
|
|
if (data.successful) {
|
|
window.location.href = `/Invoices/Edit?id=${data.idInvoice}`;
|
|
} else {
|
|
Swal.fire('Napaka pri kreiranju ponudbe!',
|
|
data.error,
|
|
'warning');
|
|
}
|
|
},
|
|
error: function(xhr, ajaxOptions, thrownError) {
|
|
alert(xhr.responseText);
|
|
$.unblockUI();
|
|
}
|
|
});
|
|
|
|
}
|
|
|
|
function generateInvoiceExcel(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>
|
|
}
|