ogled ponudb
This commit is contained in:
@@ -110,6 +110,9 @@ namespace EveryThing.Models.Invoice
|
|||||||
[NotMapped]
|
[NotMapped]
|
||||||
public string InvoiceNumberFormatted => $"{InvoiceYear}-{InvoiceNumber}";
|
public string InvoiceNumberFormatted => $"{InvoiceYear}-{InvoiceNumber}";
|
||||||
|
|
||||||
|
[NotMapped]
|
||||||
|
public string InvoiceNumberFormattedLong => $"{InvoiceNumberFormatted}-{Partner?.Title ?? ""}";
|
||||||
|
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
public string InvoiceTypeString
|
public string InvoiceTypeString
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -170,6 +170,7 @@
|
|||||||
</ul>
|
</ul>
|
||||||
<div class="tab-content">
|
<div class="tab-content">
|
||||||
<div class="tab-pane tab-panel-invoices fade show active" id="invoice-orders">
|
<div class="tab-pane tab-panel-invoices fade show active" id="invoice-orders">
|
||||||
|
<div class="card-body" style="padding: 0.5rem">
|
||||||
<table class="table">
|
<table class="table">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -194,7 +195,7 @@
|
|||||||
<tbody>
|
<tbody>
|
||||||
@foreach (var invoice in Model.Invoices.Where(x => x.Type == Models.Invoice.Invoice.InvoiceType.Order))
|
@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))">
|
<tr class="invoice-row" data-idparts="@string.Join(",", invoice.InvoiceInvoiceItem?.Select(x => x.ProjectPartItem.IdProjectPartFk) ?? Array.Empty<int>())">
|
||||||
<td>
|
<td>
|
||||||
@Html.DisplayFor(modelItem => invoice.InvoiceYear) - @Html.DisplayFor(modelItem => invoice.InvoiceNumber)
|
@Html.DisplayFor(modelItem => invoice.InvoiceYear) - @Html.DisplayFor(modelItem => invoice.InvoiceNumber)
|
||||||
</td>
|
</td>
|
||||||
@@ -229,6 +230,8 @@
|
|||||||
}
|
}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="tab-pane tab-panel-invoices fade show" id="invoice-delivery-notes">
|
<div class="tab-pane tab-panel-invoices fade show" id="invoice-delivery-notes">
|
||||||
<div class="card-body" style="padding: 0.5rem">
|
<div class="card-body" style="padding: 0.5rem">
|
||||||
@@ -258,7 +261,7 @@
|
|||||||
<tbody>
|
<tbody>
|
||||||
@foreach (var invoice in Model.Invoices.Where(x => x.Type == Models.Invoice.Invoice.InvoiceType.DeliveryNote))
|
@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))">
|
<tr class="invoice-row" data-idinvoice="@invoice.IdInvoice" data-idparts="@string.Join(",", invoice.InvoiceInvoiceItem?.Select(x => x.ProjectPartItem.IdProjectPartFk) ?? Array.Empty<int>())">
|
||||||
<td style="width: 20px;">
|
<td style="width: 20px;">
|
||||||
@if (invoice.State == Invoice.InvoiceState.Confirmed)
|
@if (invoice.State == Invoice.InvoiceState.Confirmed)
|
||||||
{
|
{
|
||||||
@@ -328,7 +331,7 @@
|
|||||||
<tbody>
|
<tbody>
|
||||||
@foreach (var invoice in Model.Invoices.Where(x => x.Type == Models.Invoice.Invoice.InvoiceType.Invoice))
|
@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))">
|
<tr class="invoice-row" data-idinvoice="@invoice.IdInvoice" data-idparts="@string.Join(",", invoice.InvoiceInvoiceItem?.Select(x => x.ProjectPartItem.IdProjectPartFk) ?? Array.Empty<int>())">
|
||||||
<td>
|
<td>
|
||||||
@Html.DisplayFor(modelItem => invoice.InvoiceYear) - @Html.DisplayFor(modelItem => invoice.InvoiceNumber)
|
@Html.DisplayFor(modelItem => invoice.InvoiceYear) - @Html.DisplayFor(modelItem => invoice.InvoiceNumber)
|
||||||
</td>
|
</td>
|
||||||
@@ -386,13 +389,16 @@
|
|||||||
<th>
|
<th>
|
||||||
Status
|
Status
|
||||||
</th>
|
</th>
|
||||||
<th><a href="Javascript:;" class="btn btn-sm btn-primary" onclick="showAllInvoices();">Pokaži vse</a></th>
|
<th style="text-align: right">
|
||||||
|
Znesek
|
||||||
|
</th>
|
||||||
|
<th style="text-align: right"><a href="Javascript:;" class="btn btn-sm btn-primary" onclick="showAllInvoices();">Pokaži vse</a></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@foreach (var invoice in Model.Invoices.Where(x => x.Type == Invoice.InvoiceType.BuyersOrder))
|
@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))">
|
<tr class="invoice-row" data-idparts="@string.Join(",", invoice.InvoiceInvoiceItem?.Select(x => x.ProjectPartItem?.IdProjectPartFk ?? 0) ?? Array.Empty<int>())">
|
||||||
<td>
|
<td>
|
||||||
@Html.DisplayFor(modelItem => invoice.InvoiceYear) - @Html.DisplayFor(modelItem => invoice.InvoiceNumber)
|
@Html.DisplayFor(modelItem => invoice.InvoiceYear) - @Html.DisplayFor(modelItem => invoice.InvoiceNumber)
|
||||||
</td>
|
</td>
|
||||||
@@ -418,6 +424,9 @@
|
|||||||
<span class='badge badge-info'>@Html.DisplayFor(modelItem => invoice.State)</span>
|
<span class='badge badge-info'>@Html.DisplayFor(modelItem => invoice.State)</span>
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
</td>
|
||||||
|
<td style="text-align: right">
|
||||||
|
@invoice.InvoiceInvoiceItem.Sum(y => y.TotalValue).ToString("#,###,##0.00") €
|
||||||
</td>
|
</td>
|
||||||
<td class="text-right">
|
<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-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>
|
||||||
@@ -427,6 +436,7 @@
|
|||||||
}
|
}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
<a href="Javascript:;" class="btn btn-sm btn-success" onclick="openModalCreateLinkToBuyersOrders();">Poveži ponudbo</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="tab-pane tab-panel-invoices fade show" id="files-project">
|
<div class="tab-pane tab-panel-invoices fade show" id="files-project">
|
||||||
@@ -523,7 +533,7 @@
|
|||||||
<tbody>
|
<tbody>
|
||||||
@foreach (var invoice in Model.Invoices.Where(x => x.Type == Invoice.InvoiceType.Cooperation))
|
@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))">
|
<tr class="invoice-row" data-idparts="@string.Join(",", invoice.InvoiceInvoiceItem?.Select(x => x.ProjectPartItem.IdProjectPartFk) ?? Array.Empty<int>())">
|
||||||
<td>
|
<td>
|
||||||
@Html.DisplayFor(modelItem => invoice.InvoiceYear) - @Html.DisplayFor(modelItem => invoice.InvoiceNumber)
|
@Html.DisplayFor(modelItem => invoice.InvoiceYear) - @Html.DisplayFor(modelItem => invoice.InvoiceNumber)
|
||||||
</td>
|
</td>
|
||||||
@@ -745,6 +755,8 @@
|
|||||||
</div>
|
</div>
|
||||||
@Html.AntiForgeryToken()
|
@Html.AntiForgeryToken()
|
||||||
<div id="divModalCodetableItemAddEditPlaceholder"></div>
|
<div id="divModalCodetableItemAddEditPlaceholder"></div>
|
||||||
|
<div id="divModalLinkToBuyersOrderPlaceholder"></div>
|
||||||
|
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
@section Scripts {
|
@section Scripts {
|
||||||
@@ -1535,5 +1547,98 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function openModalCreateLinkToOrders(){
|
||||||
|
$.blockUI();
|
||||||
|
$.ajax({
|
||||||
|
type: "GET",
|
||||||
|
url: "/Invoices/Index/?handler=Excel",
|
||||||
|
data: {
|
||||||
|
idInvoice
|
||||||
|
},
|
||||||
|
success: function (data) {
|
||||||
|
$.unblockUI();
|
||||||
|
if (data.successful) {
|
||||||
|
|
||||||
|
} else {
|
||||||
|
console.log(data);
|
||||||
|
Swal.fire('Napaka pri pridobivanju ponudb',
|
||||||
|
data.error,
|
||||||
|
'error');
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
error: function (xhr, ajaxOptions, thrownError) {
|
||||||
|
console.log(xhr);
|
||||||
|
alert(xhr.responseText);
|
||||||
|
$.unblockUI();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
function openModalCreateLinkToBuyersOrders(){
|
||||||
|
idProject = @Model.Project.IdProject;
|
||||||
|
|
||||||
|
$.blockUI();
|
||||||
|
$.ajax({
|
||||||
|
type: "GET",
|
||||||
|
// beforeSend: function(xhr) {
|
||||||
|
// xhr.setRequestHeader("XSRF-TOKEN",
|
||||||
|
// $('input:hidden[name="__RequestVerificationToken"]').val());
|
||||||
|
// },
|
||||||
|
url: "Edit/?handler=LinkToProjectData",
|
||||||
|
data: { idProject: idProject},
|
||||||
|
success: function(data) {
|
||||||
|
$.unblockUI();
|
||||||
|
$('#divModalLinkToBuyersOrderPlaceholder').html(data);
|
||||||
|
|
||||||
|
|
||||||
|
$("#divModalLinkToBuyersOrder").modal('show');
|
||||||
|
$('#selModalLinkToOrderIdProjectOrder').select2({
|
||||||
|
dropdownParent: $('#divModalLinkToBuyersOrder')
|
||||||
|
});
|
||||||
|
$('#btnModalLinkToOrderConfirm').off();
|
||||||
|
$('#btnModalLinkToOrderCancel').off();
|
||||||
|
|
||||||
|
$('#btnModalLinkToOrderCancel').on('click', function (){
|
||||||
|
$("#divModalLinkToBuyersOrder").modal('hide');
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#btnModalLinkToOrderConfirm').on('click', function (){
|
||||||
|
let idOrder = parseInt($('#selModalLinkToOrderIdProjectOrder').val());
|
||||||
|
$.blockUI();
|
||||||
|
$.ajax({
|
||||||
|
type: "POST",
|
||||||
|
beforeSend: function(xhr) {
|
||||||
|
xhr.setRequestHeader("XSRF-TOKEN",
|
||||||
|
$('input:hidden[name="__RequestVerificationToken"]').val());
|
||||||
|
},
|
||||||
|
url: "Edit/?handler=LinkProjectToBuyerOrder",
|
||||||
|
data: { idProject: idProject, idOrder: idOrder },
|
||||||
|
success: function(data) {
|
||||||
|
if (data.successful) {
|
||||||
|
location.reload();
|
||||||
|
|
||||||
|
} else {
|
||||||
|
Swal.fire(data.error,'error', 'error');
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
error: function(xhr, ajaxOptions, thrownError) {
|
||||||
|
alert(xhr.responseText);
|
||||||
|
$.unblockUI();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$("#divModalLinkToBuyersOrder").modal('hide');
|
||||||
|
});
|
||||||
|
},
|
||||||
|
error: function (xhr, ajaxOptions, thrownError) {
|
||||||
|
alert(xhr.responseText);
|
||||||
|
$.unblockUI();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,31 +1,39 @@
|
|||||||
using System;
|
using DocumentFormat.OpenXml.InkML;
|
||||||
using System.Collections.Generic;
|
using DocumentFormat.OpenXml.Spreadsheet;
|
||||||
using System.Globalization;
|
using EveryThing.Data;
|
||||||
using System.Linq;
|
using EveryThing.Models;
|
||||||
using System.Threading.Tasks;
|
using EveryThing.Models.CodeTable;
|
||||||
|
using EveryThing.Models.Invoice;
|
||||||
|
using EveryThing.Models.Project;
|
||||||
|
using EveryThing.Models.Vehicle;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Identity;
|
using Microsoft.AspNetCore.Identity;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using EveryThing.Data;
|
|
||||||
using EveryThing.Models;
|
|
||||||
using EveryThing.Models.Project;
|
|
||||||
using System.Text.Json;
|
|
||||||
using EveryThing.Models.CodeTable;
|
|
||||||
using DocumentFormat.OpenXml.InkML;
|
|
||||||
using EveryThing.Models.Invoice;
|
|
||||||
using EveryThing.Models.Vehicle;
|
|
||||||
using static EveryThing.Pages.CodeTableVehicleFuelTypes.IndexModel;
|
|
||||||
using DocumentFormat.OpenXml.Spreadsheet;
|
|
||||||
using NuGet.Packaging;
|
using NuGet.Packaging;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Globalization;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text.Json;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using static EveryThing.Pages.CodeTableItems.IndexModel;
|
||||||
|
using static EveryThing.Pages.CodeTableVehicleFuelTypes.IndexModel;
|
||||||
|
|
||||||
namespace EveryThing.Pages.Projects
|
namespace EveryThing.Pages.Projects
|
||||||
{
|
{
|
||||||
[Authorize(Roles = "Administrator,ProjecThingUser")]
|
[Authorize(Roles = "Administrator,ProjecThingUser")]
|
||||||
public class EditModel : PageModel
|
public class EditModel : PageModel
|
||||||
{
|
{
|
||||||
|
public class LinkToBuyersOrderData
|
||||||
|
{
|
||||||
|
public int IdProject { get; set; }
|
||||||
|
public SelectList SelectListOrders { get; set; }
|
||||||
|
public int IdOrder { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
public class EditProjectPartData
|
public class EditProjectPartData
|
||||||
{
|
{
|
||||||
public ProjectPartItem Item { get; set; }
|
public ProjectPartItem Item { get; set; }
|
||||||
@@ -96,6 +104,12 @@ namespace EveryThing.Pages.Projects
|
|||||||
.OrderBy(x => x.InvoiceYear).ThenBy(x => x.InvoiceNumber)
|
.OrderBy(x => x.InvoiceYear).ThenBy(x => x.InvoiceNumber)
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
|
Invoices.AddRange(await _context.Invoices
|
||||||
|
.Include(x => x.Project)
|
||||||
|
.Include(x => x.InvoiceInvoiceItem)
|
||||||
|
.Where(x => x.IdProjectFk == id).ToArrayAsync());
|
||||||
|
|
||||||
|
|
||||||
FilesProject = await _context.Files
|
FilesProject = await _context.Files
|
||||||
.Where(x => x.IdCompanyFk == user.IdCompanyFk
|
.Where(x => x.IdCompanyFk == user.IdCompanyFk
|
||||||
&& x.IdReferenceFk == Project.IdProject
|
&& x.IdReferenceFk == Project.IdProject
|
||||||
@@ -820,5 +834,39 @@ namespace EveryThing.Pages.Projects
|
|||||||
|
|
||||||
return new JsonResult(new { successful = true, error = "", idInvoice });
|
return new JsonResult(new { successful = true, error = "", idInvoice });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IActionResult OnGetLinkToProjectData(int idProject)
|
||||||
|
{
|
||||||
|
var user = _userManager.GetUserAsync(User).Result;
|
||||||
|
|
||||||
|
var selListOrders = new SelectList(_context.Invoices.Include(x => x.Partner)
|
||||||
|
.Where(x => x.Type == Invoice.InvoiceType.BuyersOrder && x.State == Invoice.InvoiceState.Offer)
|
||||||
|
.OrderByDescending(x => x.InvoiceYear).ThenBy(x => x.InvoiceNumber).ToList(), "IdInvoice", "InvoiceNumberFormattedLong");
|
||||||
|
|
||||||
|
return Partial("ModalCreateLinkToBuyersOrders", new LinkToBuyersOrderData
|
||||||
|
{
|
||||||
|
SelectListOrders = selListOrders,
|
||||||
|
IdProject = idProject
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public IActionResult OnPostLinkProjectToBuyerOrder(int idProject, int idOrder)
|
||||||
|
{
|
||||||
|
var user = _userManager.GetUserAsync(User).Result;
|
||||||
|
|
||||||
|
var project = _context.Projects.FirstOrDefault(x => x.IdProject == idProject);
|
||||||
|
if (project == null)
|
||||||
|
return new JsonResult(new { successful = false, error = $"Project with ID {idProject} not exists!" });
|
||||||
|
|
||||||
|
var invoice = _context.Invoices.FirstOrDefault(x => x.IdInvoice == idOrder);
|
||||||
|
|
||||||
|
if (invoice == null)
|
||||||
|
return new JsonResult(new { successful = false, error = $"Invoice with ID {idOrder} not exists!" });
|
||||||
|
|
||||||
|
invoice.IdProjectFk = project.IdProject;
|
||||||
|
_context.SaveChanges();
|
||||||
|
|
||||||
|
return new JsonResult(new { successful = true, error = ""});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
@model EveryThing.Pages.Projects.EditModel.LinkToBuyersOrderData
|
||||||
|
|
||||||
|
<div class="modal" tabindex="-1" role="dialog" id="divModalLinkToBuyersOrder">
|
||||||
|
<div class="modal-dialog" role="document">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h5 class="modal-title" id="modalAddEditCodeTableItemTitle">Povezovanje ponudb</h5>
|
||||||
|
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||||
|
<span aria-hidden="true">×</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<input id="inpModalLinkToOrderIdProject" type="hidden" asp-for="@Model.IdProject" />
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="control-label">Ponudba</label>
|
||||||
|
<select id="selModalLinkToOrderIdProjectOrder" asp-for="IdOrder" asp-items="@Model.SelectListOrders" class="form-control" style="width: 100%">
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button id="btnModalLinkToOrderConfirm" type="button" class="btn btn-primary">Shrani</button>
|
||||||
|
<button id="btnModalLinkToOrderCancel" type="button" class="btn btn-secondary">Prekliči</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
Reference in New Issue
Block a user