+ Timeout logout
+ Pred kreiranjem povpraševanja vprašaj za partnerja + Prikaz TOP 100 (predolgo nalaga) + Dodaj Sorovec na Urejanje Artikla (zadnji surovec) + V Urejanju artikla popravi opis v pot dokumentov + Kooperant
This commit is contained in:
@@ -164,6 +164,9 @@
|
||||
<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">
|
||||
@@ -464,36 +467,99 @@
|
||||
<div class="card-body" style="padding: 0.5rem">
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
Naziv
|
||||
</th>
|
||||
<th>
|
||||
Datum
|
||||
</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
<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>
|
||||
}
|
||||
@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>
|
||||
@@ -663,8 +729,9 @@
|
||||
<div class="card-footer py-3">
|
||||
<div class="row">
|
||||
<div class="col-6">
|
||||
<button class="btn btn-success" onclick="createOrder(false); return false;">Kreiraj naročilo</button>
|
||||
<button class="btn btn-success" onclick="createOrder(true); return false;">Kreiraj povpraševanje</button>
|
||||
<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>
|
||||
@@ -778,8 +845,57 @@
|
||||
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);
|
||||
(async () => {
|
||||
|
||||
const { value: idPartner } = await 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();
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
createOrder(inquiry, 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 createOrder(inquiry, idPartner) {
|
||||
if (idPartner == null || idPartner == undefined || isNaN(idPartner))
|
||||
idPartner = 0;
|
||||
|
||||
function createOrder(inquiry) {
|
||||
let object = getSelectedPartItems();
|
||||
|
||||
if (object.length <= 0) {
|
||||
@@ -794,7 +910,7 @@
|
||||
$('input:hidden[name="__RequestVerificationToken"]').val());
|
||||
},
|
||||
url: "Edit/?handler=CreateOrder",
|
||||
data: { itemsJson: JSON.stringify(object), inquiry: inquiry },
|
||||
data: { itemsJson: JSON.stringify(object), inquiry: inquiry, idPartner: idPartner },
|
||||
success: function(data) {
|
||||
if (data.successful) {
|
||||
if (inquiry) {
|
||||
@@ -814,6 +930,92 @@
|
||||
});
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
|
||||
@@ -183,7 +183,7 @@ namespace EveryThing.Pages.Projects
|
||||
return Partial("DetailsPartItem", item);
|
||||
}
|
||||
|
||||
public IActionResult OnPostCreateOrder(string itemsJson, bool inquiry)
|
||||
public IActionResult OnPostCreateCooperation(string itemsJson, int idPartner)
|
||||
{
|
||||
var user = _userManager.GetUserAsync(User).Result;
|
||||
|
||||
@@ -197,6 +197,83 @@ namespace EveryThing.Pages.Projects
|
||||
var suppliers = _context.ProjectPartItems
|
||||
.Where(x => itemsId.Contains(x.IdProjectPartItem))
|
||||
.Select(x => x.IdMaterialSupplierFk).Distinct().ToList();
|
||||
|
||||
if (idPartner > 0) //vse na izbranega partnerja
|
||||
suppliers = new List<int?> { idPartner };
|
||||
|
||||
var idInvoice = -1;
|
||||
|
||||
foreach (var idSupplier in suppliers)
|
||||
{
|
||||
var invoice = _context.Invoices
|
||||
.Include(x => x.InvoiceInvoiceItem)
|
||||
.ThenInclude(x => x.ProjectPartItem)
|
||||
.ThenInclude(x => x.ProjectPart)
|
||||
.Where(x => x.State == Models.Invoice.Invoice.InvoiceState.New
|
||||
&& x.Type == Models.Invoice.Invoice.InvoiceType.Cooperation
|
||||
//Ce ze kateri item obstaja na dobavnici
|
||||
&& x.InvoiceInvoiceItem.Any(invoiceItem => items.Select(item => item.ProjectPart.IdProjectFk).Contains(invoiceItem.ProjectPartItem.ProjectPart.IdProjectFk)))
|
||||
.FirstOrDefault(x => x.IdPartnerFk == idSupplier);
|
||||
|
||||
|
||||
if (invoice == null)
|
||||
{
|
||||
//Create new invoice
|
||||
var newInvoice = new Models.Invoice.Invoice();
|
||||
Pages.Invoices.CreateModel.SetNewInvoice(user.IdCompanyFk, Models.Invoice.Invoice.InvoiceType.Cooperation, ref newInvoice, _context);
|
||||
newInvoice.IdPartnerFk = idSupplier;
|
||||
newInvoice.Date = DateTime.Now.Date;
|
||||
|
||||
_context.Invoices.Add(newInvoice);
|
||||
_context.SaveChanges();
|
||||
idInvoice = newInvoice.IdInvoice;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Add to existing invoice
|
||||
idInvoice = invoice.IdInvoice;
|
||||
}
|
||||
|
||||
foreach (var projectPartItem in items.Where(x => idPartner > 0 || //ce damo vse na izbranega partnerja
|
||||
x.IdMaterialSupplierFk == idSupplier))
|
||||
{
|
||||
var newInvoiceItem = new Models.Invoice.InvoiceItem
|
||||
{
|
||||
Discount = 0,
|
||||
IdInvoiceFk = idInvoice,
|
||||
IdProjectPartItem = projectPartItem.IdProjectPartItem,
|
||||
IdItemFk = projectPartItem.IdMaterialFk,
|
||||
ItemDescription = projectPartItem.MaterialDimensions,
|
||||
Note = "",
|
||||
Price = projectPartItem.MaterialPrice,
|
||||
Quantity = projectPartItem.NumberOfItems
|
||||
};
|
||||
_context.InvoiceItems.Add(newInvoiceItem);
|
||||
}
|
||||
_context.SaveChanges();
|
||||
}
|
||||
|
||||
return new JsonResult(new { error = "", successful = true, idInvoice });
|
||||
}
|
||||
|
||||
public IActionResult OnPostCreateOrder(string itemsJson, bool inquiry, int idPartner)
|
||||
{
|
||||
var user = _userManager.GetUserAsync(User).Result;
|
||||
|
||||
var itemsId = JsonSerializer.Deserialize<List<int>>(itemsJson);
|
||||
|
||||
var items = _context.ProjectPartItems
|
||||
.Include(x => x.ProjectPart)
|
||||
.ThenInclude(x => x.Project)
|
||||
.Where(x => itemsId.Contains(x.IdProjectPartItem)).ToList();
|
||||
|
||||
var suppliers = _context.ProjectPartItems
|
||||
.Where(x => itemsId.Contains(x.IdProjectPartItem))
|
||||
.Select(x => x.IdMaterialSupplierFk).Distinct().ToList();
|
||||
|
||||
if (idPartner > 0) //vse na izbranega partnerja
|
||||
suppliers = new List<int?> { idPartner };
|
||||
|
||||
var idInvoice = -1;
|
||||
|
||||
foreach (var idSupplier in suppliers)
|
||||
@@ -232,7 +309,8 @@ namespace EveryThing.Pages.Projects
|
||||
idInvoice = invoice.IdInvoice;
|
||||
}
|
||||
|
||||
foreach (var projectPartItem in items.Where(x => x.IdMaterialSupplierFk == idSupplier))
|
||||
foreach (var projectPartItem in items.Where(x => idPartner > 0 || //ce damo vse na izbranega partnerja
|
||||
x.IdMaterialSupplierFk == idSupplier))
|
||||
{
|
||||
var newInvoiceItem = new Models.Invoice.InvoiceItem
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user