Compare commits
9 Commits
1da4b1e751
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| da7b320032 | |||
| 43efa11d9c | |||
| 5d492de137 | |||
| 8349ce5b41 | |||
| aa85143ff3 | |||
| 99d61af1a1 | |||
| 73e41cc3a3 | |||
| 5ed4ca19fc | |||
| 4cdfbace03 |
@@ -34,6 +34,7 @@
|
|||||||
<PackageReference Include="Htmx" Version="0.0.15" />
|
<PackageReference Include="Htmx" Version="0.0.15" />
|
||||||
<PackageReference Include="Htmx.TagHelpers" Version="0.0.15" />
|
<PackageReference Include="Htmx.TagHelpers" Version="0.0.15" />
|
||||||
<PackageReference Include="LettuceEncrypt" Version="1.1.2" />
|
<PackageReference Include="LettuceEncrypt" Version="1.1.2" />
|
||||||
|
<PackageReference Include="MailKit" Version="3.6.0" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="6.0.1" />
|
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="6.0.1" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.Negotiate" Version="6.0.2" />
|
<PackageReference Include="Microsoft.AspNetCore.Authentication.Negotiate" Version="6.0.2" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="6.0.1" />
|
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="6.0.1" />
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ namespace EveryThing.Pages.CodeTableItems
|
|||||||
sellingPrice = projectPartItem.SellingPrice;
|
sellingPrice = projectPartItem.SellingPrice;
|
||||||
differenceInPricePercentage = projectPartItem.DifferenceInPricePercentage;
|
differenceInPricePercentage = projectPartItem.DifferenceInPricePercentage;
|
||||||
materialDimensions = projectPartItem.MaterialDimensions;
|
materialDimensions = projectPartItem.MaterialDimensions;
|
||||||
material = projectPartItem.Material.Title;
|
material = projectPartItem?.Material?.Title;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -61,6 +61,29 @@
|
|||||||
</span>
|
</span>
|
||||||
</h4>
|
</h4>
|
||||||
|
|
||||||
|
<div class="card pt-2" style="width: 595pt; margin-bottom:10px;">
|
||||||
|
<div class="card-body">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-6">
|
||||||
|
<div class="d-flex align-items-center">
|
||||||
|
<select id="selTranslationLangue" asp-items="Html.GetEnumSelectList<PrintModel.PrintTranslationLanguage>()" class="form-control form-control-sm" style="width: 200px;">
|
||||||
|
</select>
|
||||||
|
<button id="btnTranslate" type="button" class="btn btn-sm btn-success ml-2" data-style="zoom-out" onclick="setLanguage();return false;">Prevedi</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-6 text-right">
|
||||||
|
@if (Model.Invoice.State == Models.Invoice.Invoice.InvoiceState.New)
|
||||||
|
{
|
||||||
|
<button id="btnPrintAndConfirm" type="button" class="btn btn-sm btn-success btn-print ladda-button pull-right" data-style="zoom-out" data-confirm="true"><i class="ion ion-md-print"></i> Natisni in potrdi</button>
|
||||||
|
}
|
||||||
|
<button id="btnPrint" type="button" class="btn btn-sm btn-primary btn-print ladda-button pull-right" data-style="zoom-out"><i class="ion ion-md-print"></i> Natisni</button>
|
||||||
|
|
||||||
|
<button id="btnSend" type="button" class="btn btn-sm btn-secondary ladda-button pull-right" data-style="zoom-out"><i class="far fa-envelope"></i> Pošlji</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="card pt-2" style="width: 595pt">
|
<div class="card pt-2" style="width: 595pt">
|
||||||
<div id="print-content" class="card-body pb-4 pl-4 pt-0" style="padding-right: 2rem !important">
|
<div id="print-content" class="card-body pb-4 pl-4 pt-0" style="padding-right: 2rem !important">
|
||||||
|
|
||||||
@@ -150,6 +173,9 @@
|
|||||||
<th class="py-1 text-right">
|
<th class="py-1 text-right">
|
||||||
@Model.Translation.Price
|
@Model.Translation.Price
|
||||||
</th>
|
</th>
|
||||||
|
<th class="py-1 text-right">
|
||||||
|
@Model.Translation.Discount
|
||||||
|
</th>
|
||||||
<th class="py-1 text-right">
|
<th class="py-1 text-right">
|
||||||
@Model.Translation.Amount
|
@Model.Translation.Amount
|
||||||
</th>
|
</th>
|
||||||
@@ -199,6 +225,7 @@
|
|||||||
|| Model.Invoice.Type == Models.Invoice.Invoice.InvoiceType.BuyersOrder)
|
|| Model.Invoice.Type == Models.Invoice.Invoice.InvoiceType.BuyersOrder)
|
||||||
{
|
{
|
||||||
<td class="text-right">@Html.DisplayFor(x => item.Price)</td>
|
<td class="text-right">@Html.DisplayFor(x => item.Price)</td>
|
||||||
|
<td class="text-right">@Html.DisplayFor(x => item.Discount)%</td>
|
||||||
<td class="text-right">@Html.DisplayFor(x => item.TotalValue)</td>
|
<td class="text-right">@Html.DisplayFor(x => item.TotalValue)</td>
|
||||||
}
|
}
|
||||||
else if (Model.Invoice.Type == Models.Invoice.Invoice.InvoiceType.Order)
|
else if (Model.Invoice.Type == Models.Invoice.Invoice.InvoiceType.Order)
|
||||||
@@ -253,23 +280,6 @@
|
|||||||
<div style="display: none" id="footer2">Tel.: @Html.DisplayFor(modelItem => Model.Invoice.Company.Phone), @Html.DisplayFor(modelItem => Model.Invoice.Company.Bank); IBAN: @Html.DisplayFor(modelItem => Model.Invoice.Company.Iban); SWIFT/BIC: @Html.DisplayFor(modelItem => Model.Invoice.Company.SwiftBic)</div>
|
<div style="display: none" id="footer2">Tel.: @Html.DisplayFor(modelItem => Model.Invoice.Company.Phone), @Html.DisplayFor(modelItem => Model.Invoice.Company.Bank); IBAN: @Html.DisplayFor(modelItem => Model.Invoice.Company.Iban); SWIFT/BIC: @Html.DisplayFor(modelItem => Model.Invoice.Company.SwiftBic)</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="card-footer">
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-6">
|
|
||||||
<select id="selTranslationLangue" asp-items="Html.GetEnumSelectList<PrintModel.PrintTranslationLanguage>()" class="form-control" style="width: 200px;">
|
|
||||||
</select>
|
|
||||||
<button id="btnTranslate" type="button" class="btn btn-success pull-right" data-style="zoom-out" onclick="setLanguage();return false;">Prevedi</button>
|
|
||||||
</div>
|
|
||||||
<div class="col-6 text-right">
|
|
||||||
@if (Model.Invoice.State == Models.Invoice.Invoice.InvoiceState.New)
|
|
||||||
{
|
|
||||||
<button id="btnPrintAndConfirm" type="button" class="btn btn-success btn-print ladda-button pull-right" data-style="zoom-out" data-confirm="true"><i class="ion ion-md-print"></i> Natisni in potrdi</button>
|
|
||||||
}
|
|
||||||
<button id="btnPrint" type="button" class="btn btn-primary btn-print ladda-button pull-right" data-style="zoom-out"><i class="ion ion-md-print"></i> Natisni</button>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
@Html.AntiForgeryToken()
|
@Html.AntiForgeryToken()
|
||||||
|
|
||||||
@@ -281,6 +291,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
var laddaPrint = Ladda.create(document.querySelector('#btnPrint'));
|
var laddaPrint = Ladda.create(document.querySelector('#btnPrint'));
|
||||||
|
var laddaSend = Ladda.create(document.querySelector('#btnSend'));
|
||||||
var laddaPrintAndConfirm = document.querySelector('#btnPrintAndConfirm') == null ? null : Ladda.create(document.querySelector('#btnPrintAndConfirm'));
|
var laddaPrintAndConfirm = document.querySelector('#btnPrintAndConfirm') == null ? null : Ladda.create(document.querySelector('#btnPrintAndConfirm'));
|
||||||
|
|
||||||
var element = document.getElementById('print-content');
|
var element = document.getElementById('print-content');
|
||||||
@@ -300,43 +311,40 @@
|
|||||||
jsPDF: { unit: 'mm', format: 'a4', orientation: 'portrait' }
|
jsPDF: { unit: 'mm', format: 'a4', orientation: 'portrait' }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function buildPdf(callback) {
|
||||||
|
html2pdf().set(opt).from(element).toPdf().get('pdf').then(function (pdf) {
|
||||||
|
var totalPages = pdf.internal.getNumberOfPages();
|
||||||
|
for (var i = 1; i <= totalPages; i++) {
|
||||||
|
pdf.setPage(i);
|
||||||
|
pdf.setFontSize(8);
|
||||||
|
pdf.setTextColor(0);
|
||||||
|
var fontSize = pdf.internal.getFontSize();
|
||||||
|
var pageWidth = pdf.internal.pageSize.width;
|
||||||
|
var txt = $('#footer1').text();
|
||||||
|
var txtWidth = pdf.getStringUnitWidth(txt) * fontSize / pdf.internal.scaleFactor;
|
||||||
|
var x = (pageWidth - txtWidth) / 2;
|
||||||
|
pdf.text(x, pdf.internal.pageSize.getHeight() - 8, txt);
|
||||||
|
txt = $('#footer2').text();
|
||||||
|
txtWidth = pdf.getStringUnitWidth(txt) * fontSize / pdf.internal.scaleFactor;
|
||||||
|
x = (pageWidth - txtWidth) / 2;
|
||||||
|
pdf.text(x, pdf.internal.pageSize.getHeight() - 5, txt);
|
||||||
|
}
|
||||||
|
callback(pdf);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function print(confirm) {
|
function print(confirm) {
|
||||||
laddaPrint.start();
|
laddaPrint.start();
|
||||||
if (laddaPrintAndConfirm != null) {
|
if (laddaPrintAndConfirm != null) {
|
||||||
laddaPrintAndConfirm.start();
|
laddaPrintAndConfirm.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
buildPdf(function (pdf) {
|
||||||
html2pdf().set(opt).from(element).toPdf().get('pdf').then(function (pdf) {
|
|
||||||
|
|
||||||
var totalPages = pdf.internal.getNumberOfPages();
|
|
||||||
for (i = 1; i <= totalPages; i++) {
|
|
||||||
pdf.setPage(i);
|
|
||||||
pdf.setFontSize(8);
|
|
||||||
pdf.setTextColor(0);
|
|
||||||
var fontSize = pdf.internal.getFontSize();
|
|
||||||
var pageWidth = pdf.internal.pageSize.width;
|
|
||||||
|
|
||||||
var txt = $('#footer1').text();
|
|
||||||
var txtWidth = pdf.getStringUnitWidth(txt) * fontSize / pdf.internal.scaleFactor;
|
|
||||||
var x = (pageWidth - txtWidth) / 2;
|
|
||||||
|
|
||||||
pdf.text(x, pdf.internal.pageSize.getHeight() - 8, txt);
|
|
||||||
|
|
||||||
txt = $('#footer2').text();
|
|
||||||
txtWidth = pdf.getStringUnitWidth(txt) * fontSize / pdf.internal.scaleFactor;
|
|
||||||
x = (pageWidth - txtWidth) / 2;
|
|
||||||
|
|
||||||
pdf.text(x, pdf.internal.pageSize.getHeight() - 5, txt);
|
|
||||||
|
|
||||||
//pdf.addImage("YOUR_IMAGE", 'JPEG', pdf.internal.pageSize.getWidth() - 1.1, pdf.internal.pageSize.getHeight() - 0.25, 1, 0.2);
|
|
||||||
}
|
|
||||||
laddaPrint.stop();
|
laddaPrint.stop();
|
||||||
if (laddaPrintAndConfirm != null) {
|
if (laddaPrintAndConfirm != null) {
|
||||||
laddaPrintAndConfirm.stop();
|
laddaPrintAndConfirm.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
//window.open(pdf.output('bloburl'), '_blank');
|
|
||||||
let link = document.createElement('a');
|
let link = document.createElement('a');
|
||||||
link.target = '_blank';
|
link.target = '_blank';
|
||||||
link.href = pdf.output('bloburl');
|
link.href = pdf.output('bloburl');
|
||||||
@@ -346,7 +354,6 @@
|
|||||||
if (confirm) {
|
if (confirm) {
|
||||||
confirmInvoice();
|
confirmInvoice();
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -358,6 +365,85 @@
|
|||||||
print($(this).attr("data-confirm") === 'true');
|
print($(this).attr("data-confirm") === 'true');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('#btnSend').click(function () {
|
||||||
|
send();
|
||||||
|
});
|
||||||
|
|
||||||
|
function send() {
|
||||||
|
var partnerEmail = '@Html.Raw(Model.Invoice.Partner?.Email ?? "")';
|
||||||
|
var partnerTitle = '@Html.Raw(Model.Invoice.Partner?.Title ?? "")';
|
||||||
|
var emailInput = document.createElement('input');
|
||||||
|
emailInput.type = 'email';
|
||||||
|
emailInput.value = partnerEmail;
|
||||||
|
|
||||||
|
if (!partnerEmail || !emailInput.checkValidity()) {
|
||||||
|
Swal.fire('Napaka', `Partner nima veljavnega e-poštnega naslova (${partnerEmail}).`, 'error');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Swal.fire({
|
||||||
|
title: 'Pošlji dokument',
|
||||||
|
html: 'Dokument bo poslan na:<br>' + partnerTitle + ' (' + partnerEmail + ')',
|
||||||
|
icon: 'question',
|
||||||
|
showCancelButton: true,
|
||||||
|
showDenyButton: true,
|
||||||
|
confirmButtonText: 'Pošlji s prilogo',
|
||||||
|
denyButtonText: 'Pošlji',
|
||||||
|
cancelButtonText: 'Prekliči',
|
||||||
|
denyButtonColor: '#007bff'
|
||||||
|
}).then(function (result) {
|
||||||
|
if (result.isConfirmed) {
|
||||||
|
laddaSend.start();
|
||||||
|
buildPdf(function (pdf) {
|
||||||
|
var formData = new FormData();
|
||||||
|
formData.append('pdfFile', pdf.output('blob'), '@(Model.Invoice.InvoiceNumberFull.Replace("-", "_"))' + '.pdf');
|
||||||
|
formData.append('idInvoice', @Model.Invoice.IdInvoice);
|
||||||
|
formData.append('withAttachment', 'true');
|
||||||
|
sendDocument(formData);
|
||||||
|
});
|
||||||
|
} else if (result.isDenied) {
|
||||||
|
laddaSend.start();
|
||||||
|
buildPdf(function (pdf) {
|
||||||
|
var formData = new FormData();
|
||||||
|
formData.append('pdfFile', pdf.output('blob'), '@(Model.Invoice.InvoiceNumberFull.Replace("-", "_"))' + '.pdf');
|
||||||
|
formData.append('idInvoice', @Model.Invoice.IdInvoice);
|
||||||
|
formData.append('withAttachment', 'false');
|
||||||
|
sendDocument(formData);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function sendDocument(formData) {
|
||||||
|
$.blockUI();
|
||||||
|
$.ajax({
|
||||||
|
type: 'POST',
|
||||||
|
beforeSend: function (xhr) {
|
||||||
|
xhr.setRequestHeader('XSRF-TOKEN',
|
||||||
|
$('input:hidden[name="__RequestVerificationToken"]').val());
|
||||||
|
},
|
||||||
|
url: 'Print/?handler=SendDocument',
|
||||||
|
data: formData,
|
||||||
|
processData: false,
|
||||||
|
contentType: false,
|
||||||
|
success: function (data) {
|
||||||
|
laddaSend.stop();
|
||||||
|
if (data.successful) {
|
||||||
|
Swal.fire('Dokument poslan', '', 'success');
|
||||||
|
} else {
|
||||||
|
Swal.fire('Napaka pri pošiljanju dokumenta', data.error, 'error');
|
||||||
|
}
|
||||||
|
$.unblockUI();
|
||||||
|
},
|
||||||
|
error: function (xhr, ajaxOptions, thrownError) {
|
||||||
|
laddaSend.stop();
|
||||||
|
console.log(xhr);
|
||||||
|
alert(xhr.responseText);
|
||||||
|
$.unblockUI();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function confirmInvoice() {
|
function confirmInvoice() {
|
||||||
$.blockUI();
|
$.blockUI();
|
||||||
$.ajax({
|
$.ajax({
|
||||||
|
|||||||
@@ -3,10 +3,16 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Microsoft.AspNetCore.Hosting;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
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.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.Extensions.Configuration;
|
||||||
|
using MailKit.Net.Smtp;
|
||||||
|
using MailKit.Security;
|
||||||
|
using MimeKit;
|
||||||
using EveryThing.Data;
|
using EveryThing.Data;
|
||||||
using EveryThing.Models;
|
using EveryThing.Models;
|
||||||
using EveryThing.Models.Invoice;
|
using EveryThing.Models.Invoice;
|
||||||
@@ -36,6 +42,7 @@ namespace EveryThing.Pages.Invoices
|
|||||||
public string Article { get; set; } = "Artikel";
|
public string Article { get; set; } = "Artikel";
|
||||||
public string Quantity { get; set; } = "Količina";
|
public string Quantity { get; set; } = "Količina";
|
||||||
public string Price { get; set; } = "Cena";
|
public string Price { get; set; } = "Cena";
|
||||||
|
public string Discount { get; set; } = "Rabat";
|
||||||
public string Amount { get; set; } = "Znesek";
|
public string Amount { get; set; } = "Znesek";
|
||||||
public string Dimensions { get; set; } = "Dimenzije";
|
public string Dimensions { get; set; } = "Dimenzije";
|
||||||
public string Total { get; set; } = "Skupaj";
|
public string Total { get; set; } = "Skupaj";
|
||||||
@@ -55,16 +62,20 @@ namespace EveryThing.Pages.Invoices
|
|||||||
|
|
||||||
private readonly ApplicationDbContext _context;
|
private readonly ApplicationDbContext _context;
|
||||||
private readonly UserManager<IdentityApplicationUser> _userManager;
|
private readonly UserManager<IdentityApplicationUser> _userManager;
|
||||||
|
private readonly IConfiguration _configuration;
|
||||||
|
private readonly IWebHostEnvironment _environment;
|
||||||
|
|
||||||
public Models.Invoice.Invoice Invoice { get; set; }
|
public Models.Invoice.Invoice Invoice { get; set; }
|
||||||
public PrintTranslation Translation { get; set; }
|
public PrintTranslation Translation { get; set; }
|
||||||
public IList<Models.Invoice.InvoiceItem> InvoiceItems { get; set; }
|
public IList<Models.Invoice.InvoiceItem> InvoiceItems { get; set; }
|
||||||
public string ProjectNumber { get; set; }
|
public string ProjectNumber { get; set; }
|
||||||
|
|
||||||
public PrintModel(ApplicationDbContext context, UserManager<IdentityApplicationUser> userManager)
|
public PrintModel(ApplicationDbContext context, UserManager<IdentityApplicationUser> userManager, IConfiguration configuration, IWebHostEnvironment environment)
|
||||||
{
|
{
|
||||||
_context = context;
|
_context = context;
|
||||||
_userManager = userManager;
|
_userManager = userManager;
|
||||||
|
_configuration = configuration;
|
||||||
|
_environment = environment;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<IActionResult> OnGetAsync(int id, int? printTranslationLanguage)
|
public async Task<IActionResult> OnGetAsync(int id, int? printTranslationLanguage)
|
||||||
@@ -112,6 +123,97 @@ namespace EveryThing.Pages.Invoices
|
|||||||
return NotFound();
|
return NotFound();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<IActionResult> OnPostSendDocumentAsync(IFormFile pdfFile, int idInvoice, bool withAttachment)
|
||||||
|
{
|
||||||
|
if (pdfFile == null || pdfFile.Length == 0)
|
||||||
|
return new JsonResult(new { successful = false, error = "PDF datoteka je obvezna." });
|
||||||
|
|
||||||
|
var user = await _userManager.GetUserAsync(User);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var invoice = await _context.Invoices
|
||||||
|
.Include(x => x.Partner)
|
||||||
|
.Include(x => x.Company)
|
||||||
|
.FirstOrDefaultAsync(x => x.IdInvoice == idInvoice && x.IdCompanyFk == user.IdCompanyFk);
|
||||||
|
|
||||||
|
if (invoice == null)
|
||||||
|
return new JsonResult(new { successful = false, error = "Invoice not found." });
|
||||||
|
|
||||||
|
using var stream = pdfFile.OpenReadStream();
|
||||||
|
var pdfBytes = new byte[pdfFile.Length];
|
||||||
|
await stream.ReadAsync(pdfBytes, 0, (int)pdfFile.Length);
|
||||||
|
|
||||||
|
var attachments = new List<Models.File>();
|
||||||
|
if (withAttachment)
|
||||||
|
{
|
||||||
|
var itemIds = await _context.InvoiceItems
|
||||||
|
.Where(x => x.IdInvoiceFk == idInvoice && x.IdItemFk != null)
|
||||||
|
.Select(x => x.IdItemFk.Value)
|
||||||
|
.Distinct()
|
||||||
|
.ToListAsync();
|
||||||
|
|
||||||
|
if (itemIds.Any())
|
||||||
|
{
|
||||||
|
attachments = await _context.Files
|
||||||
|
.Where(x => x.IdCompanyFk == user.IdCompanyFk
|
||||||
|
&& itemIds.Contains(x.IdReferenceFk)
|
||||||
|
&& x.FileType == FileType.CodeTableItem)
|
||||||
|
.ToListAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var emailSettings = _configuration.GetSection("EmailSettings");
|
||||||
|
var host = emailSettings["Host"];
|
||||||
|
var port = int.Parse(emailSettings["Port"] ?? "587");
|
||||||
|
var secureSocketOptions = Enum.Parse<SecureSocketOptions>(emailSettings["SecureSocketOptions"] ?? "StartTls");
|
||||||
|
var username = emailSettings["Username"];
|
||||||
|
var password = emailSettings["Password"];
|
||||||
|
var fromEmail = emailSettings["FromEmail"];
|
||||||
|
var fromName = emailSettings["FromName"];
|
||||||
|
var bcc = emailSettings["Bcc"];
|
||||||
|
|
||||||
|
var mimeMessage = new MimeMessage();
|
||||||
|
mimeMessage.From.Add(new MailboxAddress(fromName, fromEmail));
|
||||||
|
mimeMessage.To.Add(new MailboxAddress(invoice.Partner.Title, invoice.Partner.Email));
|
||||||
|
if (!string.IsNullOrWhiteSpace(bcc))
|
||||||
|
mimeMessage.Bcc.Add(MailboxAddress.Parse(bcc));
|
||||||
|
mimeMessage.Subject = invoice.InvoiceNumberFull;
|
||||||
|
|
||||||
|
var bodyBuilder = new BodyBuilder
|
||||||
|
{
|
||||||
|
TextBody = $"Spoštovani,\n\nv prilogi vam pošiljamo dokument {invoice.InvoiceNumberFull}.\n\nLep pozdrav,\n{invoice.Company.Title}"
|
||||||
|
};
|
||||||
|
|
||||||
|
bodyBuilder.Attachments.Add(invoice.InvoiceNumberFull + ".pdf", pdfBytes, new ContentType("application", "pdf"));
|
||||||
|
|
||||||
|
var filesFolder = System.IO.Path.Combine(_environment.WebRootPath, "Uploads", "Files", ((int)FileType.CodeTableItem).ToString());
|
||||||
|
foreach (var file in attachments)
|
||||||
|
{
|
||||||
|
var filePath = System.IO.Path.Combine(filesFolder, file.Guid + file.Extension);
|
||||||
|
if (System.IO.File.Exists(filePath))
|
||||||
|
{
|
||||||
|
var fileBytes = await System.IO.File.ReadAllBytesAsync(filePath);
|
||||||
|
bodyBuilder.Attachments.Add(file.Title + file.Extension, fileBytes);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mimeMessage.Body = bodyBuilder.ToMessageBody();
|
||||||
|
|
||||||
|
using var smtpClient = new SmtpClient();
|
||||||
|
await smtpClient.ConnectAsync(host, port, secureSocketOptions);
|
||||||
|
await smtpClient.AuthenticateAsync(username, password);
|
||||||
|
await smtpClient.SendAsync(mimeMessage);
|
||||||
|
await smtpClient.DisconnectAsync(true);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
return new JsonResult(new { successful = false, error = ex.Message });
|
||||||
|
}
|
||||||
|
|
||||||
|
return new JsonResult(new { successful = true });
|
||||||
|
}
|
||||||
|
|
||||||
public IActionResult OnPostConfirmInvoice(int idInvoice)
|
public IActionResult OnPostConfirmInvoice(int idInvoice)
|
||||||
{
|
{
|
||||||
var user = _userManager.GetUserAsync(User).Result;
|
var user = _userManager.GetUserAsync(User).Result;
|
||||||
@@ -200,6 +302,7 @@ namespace EveryThing.Pages.Invoices
|
|||||||
OrderNumber = invoiceState == Invoice.InvoiceState.Offer ? "Anfrage No." : "Bestellnummer",
|
OrderNumber = invoiceState == Invoice.InvoiceState.Offer ? "Anfrage No." : "Bestellnummer",
|
||||||
Price = "Preis(€)",
|
Price = "Preis(€)",
|
||||||
Quantity = "Menge(Stk)",
|
Quantity = "Menge(Stk)",
|
||||||
|
Discount = "Rabatt",
|
||||||
SwiftBic = "SWIFT/BIC",
|
SwiftBic = "SWIFT/BIC",
|
||||||
Total = "Gesamtsumme",
|
Total = "Gesamtsumme",
|
||||||
Project = "Projekt",
|
Project = "Projekt",
|
||||||
|
|||||||
@@ -204,7 +204,7 @@
|
|||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
|
||||||
<table class="table">
|
<table id="tblOperations" class="table">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th class="w-100">Naziv</th>
|
<th class="w-100">Naziv</th>
|
||||||
@@ -477,7 +477,7 @@
|
|||||||
<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>
|
<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>
|
</td>
|
||||||
</tr>`;
|
</tr>`;
|
||||||
$('table.table tbody').append(row);
|
$('#tblOperations tbody').append(row);
|
||||||
$('#selProjectPartItemOperation option[value="' + op.idCodeTableOperation + '"]').remove();
|
$('#selProjectPartItemOperation option[value="' + op.idCodeTableOperation + '"]').remove();
|
||||||
});
|
});
|
||||||
$('#selProjectPartItemOperation').trigger('change');
|
$('#selProjectPartItemOperation').trigger('change');
|
||||||
@@ -529,7 +529,7 @@
|
|||||||
<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>
|
<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>
|
</td>
|
||||||
</tr>`;
|
</tr>`;
|
||||||
$('table.table tbody').append(row);
|
$('#tblOperations tbody').append(row);
|
||||||
$('#selProjectPartItemOperation option[value="' + idCodeTableOperation + '"]').remove();
|
$('#selProjectPartItemOperation option[value="' + idCodeTableOperation + '"]').remove();
|
||||||
$('#selProjectPartItemOperation').trigger('change');
|
$('#selProjectPartItemOperation').trigger('change');
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -1,7 +1,11 @@
|
|||||||
@using System.Globalization
|
@using System.Globalization
|
||||||
@model EveryThing.Models.Project.ProjectPartItem
|
@model EveryThing.Models.Project.ProjectPartItem
|
||||||
|
|
||||||
<tr data-idpartitem="@Model.IdProjectPartItem">
|
@{
|
||||||
|
var hasNote = !string.IsNullOrWhiteSpace(Model.Note);
|
||||||
|
}
|
||||||
|
|
||||||
|
<tr data-idpartitem="@Model.IdProjectPartItem" class="@(hasNote ? "project-part-item-has-note" : "")" style="cursor: pointer;" ondblclick="if(!$(event.target).closest('a,button,input').length) { $('[data-toggle=tooltip]').tooltip('hide'); $(this).find('.btn-tbl-inline-edit').click(); }">
|
||||||
<td style="width: 20px;">
|
<td style="width: 20px;">
|
||||||
@if(Model.Status != Models.Project.ProjectPartItemStatus.Shipped)
|
@if(Model.Status != Models.Project.ProjectPartItemStatus.Shipped)
|
||||||
{
|
{
|
||||||
@@ -18,6 +22,10 @@
|
|||||||
@Html.DisplayFor(modelItem => Model.IdItemFk)
|
@Html.DisplayFor(modelItem => Model.IdItemFk)
|
||||||
}
|
}
|
||||||
<br/>
|
<br/>
|
||||||
|
@if (hasNote)
|
||||||
|
{
|
||||||
|
<i class="fas fa-sticky-note text-warning mr-1" data-toggle="tooltip" data-placement="top" title="@Model.Note"></i>
|
||||||
|
}
|
||||||
@(Model.ProjectPartNumberFormatted)
|
@(Model.ProjectPartNumberFormatted)
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
@@ -35,6 +43,20 @@
|
|||||||
<br/>
|
<br/>
|
||||||
@Html.DisplayFor(modelItem => Model.MaterialDimensions)
|
@Html.DisplayFor(modelItem => Model.MaterialDimensions)
|
||||||
</td>
|
</td>
|
||||||
|
<td>
|
||||||
|
@{
|
||||||
|
var ops = Model.ProjectPartItemOperation;
|
||||||
|
var nextOp = ops?.Where(x => !x.Finished).OrderBy(x => x.Order).FirstOrDefault();
|
||||||
|
}
|
||||||
|
@if (ops != null && ops.Any() && nextOp == null)
|
||||||
|
{
|
||||||
|
<span class="badge badge-success"><i class="fas fa-check"></i> Vse zaključeno</span>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
@(nextOp?.Operation?.Title ?? "")
|
||||||
|
}
|
||||||
|
</td>
|
||||||
<td class="table-number">
|
<td class="table-number">
|
||||||
@(Model.NumberOfItems.ToString("0.00", new CultureInfo("sl-SI")))
|
@(Model.NumberOfItems.ToString("0.00", new CultureInfo("sl-SI")))
|
||||||
<br/>
|
<br/>
|
||||||
@@ -71,9 +93,9 @@
|
|||||||
@Html.DisplayFor(modelItem => Model.DeliveryDate)
|
@Html.DisplayFor(modelItem => Model.DeliveryDate)
|
||||||
</td>
|
</td>
|
||||||
<td class="text-right" style="width: 90px;">
|
<td class="text-right" style="width: 90px;">
|
||||||
<a asp-page="CreateEditPartItem" asp-route-idProjectPartItem="@Model.IdProjectPartItem" asp-route-idProject="@Model.ProjectPart.IdProjectFk" asp-route-idProjectPart="@Model.IdProjectPartFk" asp-route-edit="@true" class="btn btn-xs icon-btn btn-outline-secondary borderless" data-state="secondary"><i class="far fa-edit"></i></a>
|
<a asp-page="CreateEditPartItem" asp-route-idProjectPartItem="@Model.IdProjectPartItem" asp-route-idProject="@Model.ProjectPart.IdProjectFk" asp-route-idProjectPart="@Model.IdProjectPartFk" asp-route-edit="@true" class="btn btn-xs icon-btn btn-outline-secondary borderless" data-state="secondary" data-toggle="tooltip" data-placement="top" title="Urejanje"><i class="far fa-edit"></i></a>
|
||||||
<a class="btn btn-xs icon-btn btn-outline-secondary borderless" data-state="secondary" href='javascript:;'><i class="fas fa-pencil-alt" hx-get="@Url.Page("Edit", "EditPartItem", new {id = Model.IdProjectPartItem})" hx-swap="outerHTML" hx-target="closest tr"></i></a>
|
<a class="btn btn-xs icon-btn btn-outline-secondary borderless" data-state="secondary" href='javascript:;' data-toggle="tooltip" data-placement="top" title="Hitro urejanje"><i class="fas fa-pencil-alt btn-tbl-inline-edit" hx-get="@Url.Page("Edit", "EditPartItem", new {id = Model.IdProjectPartItem})" hx-swap="outerHTML" hx-target="closest tr"></i></a>
|
||||||
<a class="btn btn-xs icon-btn btn-outline-danger borderless" data-state="danger" href='javascript:;' onclick="deletePartItem(this)"><i class="fas fa-times"></i></a>
|
<a class="btn btn-xs icon-btn btn-outline-danger borderless" data-state="danger" href='javascript:;' onclick="deletePartItem(this)" data-toggle="tooltip" data-placement="top" title="Izbriši"><i class="fas fa-times"></i></a>
|
||||||
<a style="display: none;" id="btnTblCancel_@(Model.IdProjectPartItem.ToString())" href='javascript:;' class="btn btn-xs icon-btn btn-outline-danger borderless" data-state="danger" hx-get="@Url.Page("Edit", "DetailPartItem", new { id = Model.IdProjectPartItem })" hx-swap="outerHTML" hx-target="closest tr"><i class="fas fa-ban"></i></a>
|
<a style="display: none;" id="btnTblCancel_@(Model.IdProjectPartItem.ToString())" href='javascript:;' class="btn btn-xs icon-btn btn-outline-danger borderless" data-state="danger" data-toggle="tooltip" data-placement="top" title="Prekliči" hx-get="@Url.Page("Edit", "DetailPartItem", new { id = Model.IdProjectPartItem })" hx-swap="outerHTML" hx-target="closest tr"><i class="fas fa-ban"></i></a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
@@ -13,6 +13,10 @@
|
|||||||
border-top: none;
|
border-top: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.project-part-item-has-note {
|
||||||
|
background-color: #fff8e1;
|
||||||
|
}
|
||||||
|
|
||||||
.tab-panel-invoices{
|
.tab-panel-invoices{
|
||||||
height: 490px;
|
height: 490px;
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
@@ -195,7 +199,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) ?? Array.Empty<int>())">
|
<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>
|
||||||
@@ -261,7 +265,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) ?? Array.Empty<int>())">
|
<tr class="invoice-row" data-idinvoice="@invoice.IdInvoice" data-idparts="@string.Join(",", invoice.InvoiceInvoiceItem?.Select(x => x.ProjectPartItem?.IdProjectPartFk ?? 0) ?? Array.Empty<int>())">
|
||||||
<td style="width: 20px;">
|
<td style="width: 20px;">
|
||||||
@if (invoice.State == Invoice.InvoiceState.Confirmed)
|
@if (invoice.State == Invoice.InvoiceState.Confirmed)
|
||||||
{
|
{
|
||||||
@@ -331,7 +335,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) ?? Array.Empty<int>())">
|
<tr class="invoice-row" data-idinvoice="@invoice.IdInvoice" 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>
|
||||||
@@ -533,7 +537,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) ?? Array.Empty<int>())">
|
<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>
|
||||||
@@ -644,6 +648,9 @@
|
|||||||
<br/>
|
<br/>
|
||||||
Dimenzije surovca
|
Dimenzije surovca
|
||||||
</th>
|
</th>
|
||||||
|
<th>
|
||||||
|
Naslednja operacija
|
||||||
|
</th>
|
||||||
<th class="table-header-number">
|
<th class="table-header-number">
|
||||||
<div data-toggle="tooltip" data-placement="top" title="Število kosov<br/>Število kompletov" data-html="true">
|
<div data-toggle="tooltip" data-placement="top" title="Število kosov<br/>Število kompletov" data-html="true">
|
||||||
Kos
|
Kos
|
||||||
@@ -739,14 +746,16 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="card-footer py-3">
|
<div class="card-footer py-3">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-6">
|
<div class="col-9">
|
||||||
<button class="btn btn-success" onclick="createOrderSelectPartner(false); return false;">Kreiraj naročilo</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-success" onclick="createOrderSelectPartner(true); return false;">Kreiraj povpraševanje materiala</button>
|
||||||
|
<button class="btn btn-secondary" onclick="createOrderSelectPartner(true, 2); return false;">Kreiraj povpraševanje izdelka</button>
|
||||||
<button class="btn btn-info" onclick="createCooperationSelectPartner(); return false;">Kreiraj kooperacijo</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>
|
<button class="btn btn-primary" onclick="createInvoice(); return false;">Kreiraj dobavnico</button>
|
||||||
|
<button class="btn btn-secondary" onclick="bulkPrintPartItems(); return false;"><i class="ion ion-md-print"></i> Natisni naloge</button>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="col-6 text-right">
|
<div class="col-3 text-right">
|
||||||
<a asp-page="CreatePart" asp-route-idProject="@Model.Project.IdProject" class="btn btn-primary pull-right">Nov del projekta</a>
|
<a asp-page="CreatePart" asp-route-idProject="@Model.Project.IdProject" class="btn btn-primary pull-right">Nov del projekta</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -774,9 +783,15 @@
|
|||||||
<script>
|
<script>
|
||||||
const openProjectPartCookieName = 'openProjectPart' + @Html.Raw(Model.Project.IdProject);
|
const openProjectPartCookieName = 'openProjectPart' + @Html.Raw(Model.Project.IdProject);
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
|
document.body.addEventListener('htmx:beforeRequest',
|
||||||
|
function(evt) {
|
||||||
|
$('[data-toggle=tooltip]').tooltip('hide');
|
||||||
|
});
|
||||||
|
|
||||||
document.body.addEventListener('htmx:afterSettle',
|
document.body.addEventListener('htmx:afterSettle',
|
||||||
function(evt) {
|
function(evt) {
|
||||||
$('.select2').select2();
|
$('.select2').select2();
|
||||||
|
tooltips();
|
||||||
|
|
||||||
$('.inp-tbl-edit-calculate-price').on("input",
|
$('.inp-tbl-edit-calculate-price').on("input",
|
||||||
function() {
|
function() {
|
||||||
@@ -867,7 +882,17 @@
|
|||||||
function tooltips() {
|
function tooltips() {
|
||||||
$('[data-toggle="tooltip"]').tooltip();
|
$('[data-toggle="tooltip"]').tooltip();
|
||||||
}
|
}
|
||||||
function createOrderSelectPartner(inquiry) {
|
|
||||||
|
function bulkPrintPartItems() {
|
||||||
|
let ids = getSelectedPartItems();
|
||||||
|
if (ids.length <= 0) {
|
||||||
|
alert("Izberi pozicije!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
window.open('/Projects/PrintPartItem?ids=' + ids.join(','), '_blank');
|
||||||
|
}
|
||||||
|
|
||||||
|
function createOrderSelectPartner(inquiry, positionsType) {
|
||||||
$.blockUI();
|
$.blockUI();
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: "GET",
|
type: "GET",
|
||||||
@@ -895,7 +920,7 @@
|
|||||||
}
|
}
|
||||||
}).then((result) => {
|
}).then((result) => {
|
||||||
if (result.isConfirmed) {
|
if (result.isConfirmed) {
|
||||||
createOrder(inquiry, result.value);
|
createOrder(inquiry, result.value, positionsType);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
@@ -914,10 +939,14 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function createOrder(inquiry, idPartner) {
|
function createOrder(inquiry, idPartner, positionsType) {
|
||||||
if (idPartner == null || idPartner == undefined || isNaN(idPartner))
|
if (idPartner == null || idPartner == undefined || isNaN(idPartner))
|
||||||
idPartner = 0;
|
idPartner = 0;
|
||||||
|
|
||||||
|
if (isNaN(positionsType) || positionsType == null || positionsType == undefined){
|
||||||
|
positionsType = 1;
|
||||||
|
}
|
||||||
|
|
||||||
let object = getSelectedPartItems();
|
let object = getSelectedPartItems();
|
||||||
|
|
||||||
if (object.length <= 0) {
|
if (object.length <= 0) {
|
||||||
@@ -932,7 +961,7 @@
|
|||||||
$('input:hidden[name="__RequestVerificationToken"]').val());
|
$('input:hidden[name="__RequestVerificationToken"]').val());
|
||||||
},
|
},
|
||||||
url: "Edit/?handler=CreateOrder",
|
url: "Edit/?handler=CreateOrder",
|
||||||
data: { itemsJson: JSON.stringify(object), inquiry: inquiry, idPartner: idPartner },
|
data: { itemsJson: JSON.stringify(object), inquiry: inquiry, idPartner: idPartner, positionsType: positionsType },
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
if (data.successful) {
|
if (data.successful) {
|
||||||
if (inquiry) {
|
if (inquiry) {
|
||||||
|
|||||||
@@ -91,6 +91,9 @@ namespace EveryThing.Pages.Projects
|
|||||||
.ThenInclude(x => x.Material)
|
.ThenInclude(x => x.Material)
|
||||||
.Include(c => c.ProjectPartProjectPartItem)
|
.Include(c => c.ProjectPartProjectPartItem)
|
||||||
.ThenInclude(x => x.Item)
|
.ThenInclude(x => x.Item)
|
||||||
|
.Include(c => c.ProjectPartProjectPartItem)
|
||||||
|
.ThenInclude(x => x.ProjectPartItemOperation)
|
||||||
|
.ThenInclude(x => x.Operation)
|
||||||
.Where(x => x.IdProjectFk == id)
|
.Where(x => x.IdProjectFk == id)
|
||||||
.OrderBy(x => x.ProjectPartNumber).ThenBy(x => x.IdProjectPart)
|
.OrderBy(x => x.ProjectPartNumber).ThenBy(x => x.IdProjectPart)
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
@@ -192,6 +195,8 @@ namespace EveryThing.Pages.Projects
|
|||||||
.Include(x => x.Material)
|
.Include(x => x.Material)
|
||||||
.Include(x => x.ProjectPart)
|
.Include(x => x.ProjectPart)
|
||||||
.ThenInclude(x => x.Project)
|
.ThenInclude(x => x.Project)
|
||||||
|
.Include(x => x.ProjectPartItemOperation)
|
||||||
|
.ThenInclude(x => x.Operation)
|
||||||
.First(x => x.IdProjectPartItem == id);
|
.First(x => x.IdProjectPartItem == id);
|
||||||
|
|
||||||
return Partial("DetailsPartItem", item);
|
return Partial("DetailsPartItem", item);
|
||||||
@@ -272,7 +277,7 @@ namespace EveryThing.Pages.Projects
|
|||||||
return new JsonResult(new { error = "", successful = true, idInvoice });
|
return new JsonResult(new { error = "", successful = true, idInvoice });
|
||||||
}
|
}
|
||||||
|
|
||||||
public IActionResult OnPostCreateOrder(string itemsJson, bool inquiry, int idPartner)
|
public IActionResult OnPostCreateOrder(string itemsJson, bool inquiry, int idPartner, int positionsType)
|
||||||
{
|
{
|
||||||
var user = _userManager.GetUserAsync(User).Result;
|
var user = _userManager.GetUserAsync(User).Result;
|
||||||
|
|
||||||
@@ -330,16 +335,24 @@ namespace EveryThing.Pages.Projects
|
|||||||
{
|
{
|
||||||
var newInvoiceItem = new Models.Invoice.InvoiceItem
|
var newInvoiceItem = new Models.Invoice.InvoiceItem
|
||||||
{
|
{
|
||||||
Discount = 0,
|
Discount = 0,
|
||||||
IdInvoiceFk = idInvoice,
|
IdInvoiceFk = idInvoice,
|
||||||
IdProjectPartItem = projectPartItem.IdProjectPartItem,
|
IdProjectPartItem = projectPartItem.IdProjectPartItem,
|
||||||
IdItemFk = projectPartItem.IdMaterialFk,
|
Note = "",
|
||||||
ItemDescription = projectPartItem.MaterialDimensions,
|
Price = projectPartItem.MaterialPrice,
|
||||||
Note = "",
|
Quantity = projectPartItem.NumberOfItems
|
||||||
Price = projectPartItem.MaterialPrice,
|
|
||||||
//Quantity = projectPartItem.NumberOfItems * projectPartItem.NumberOfSets
|
|
||||||
Quantity = projectPartItem.NumberOfItems
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (positionsType == 2)
|
||||||
|
{
|
||||||
|
newInvoiceItem.IdItemFk = projectPartItem.IdItemFk;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
newInvoiceItem.IdItemFk = projectPartItem.IdMaterialFk;
|
||||||
|
newInvoiceItem.ItemDescription = projectPartItem.MaterialDimensions;
|
||||||
|
}
|
||||||
|
|
||||||
_context.InvoiceItems.Add(newInvoiceItem);
|
_context.InvoiceItems.Add(newInvoiceItem);
|
||||||
}
|
}
|
||||||
_context.SaveChanges();
|
_context.SaveChanges();
|
||||||
@@ -631,14 +644,19 @@ namespace EveryThing.Pages.Projects
|
|||||||
|
|
||||||
if (projectPart != null)
|
if (projectPart != null)
|
||||||
{
|
{
|
||||||
foreach (var projectPartItem in _context.ProjectPartItems.Where(x => x.IdProjectPartFk == projectPart.IdProjectPart).ToList())
|
foreach (var projectPartItem in _context.ProjectPartItems.Where(x => x.IdProjectPartFk == projectPart.IdProjectPart).ToList())
|
||||||
{
|
{
|
||||||
_context.ProjectPartItems.Remove(projectPartItem);
|
var operations = _context.ProjectPartItemOperations
|
||||||
}
|
.Where(x => x.IdProjectPartItemFk == projectPartItem.IdProjectPartItem)
|
||||||
_context.ProjectParts.Remove(projectPart);
|
.ToList();
|
||||||
|
_context.ProjectPartItemOperations.RemoveRange(operations);
|
||||||
|
_context.ProjectPartItems.Remove(projectPartItem);
|
||||||
|
}
|
||||||
|
_context.ProjectParts.Remove(projectPart);
|
||||||
_context.SaveChanges();
|
_context.SaveChanges();
|
||||||
|
|
||||||
projectPart.Project = null;
|
projectPart.Project = null;
|
||||||
|
projectPart.ProjectPartProjectPartItem = null;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<input id="inpTblMaterialDimensions_@(Model.Item.IdProjectPartItem.ToString())" asp-for="Item.MaterialDimensions" class="form-control" style="width: 100%"/>
|
<input id="inpTblMaterialDimensions_@(Model.Item.IdProjectPartItem.ToString())" asp-for="Item.MaterialDimensions" class="form-control" style="width: 100%"/>
|
||||||
</td>
|
</td>
|
||||||
|
<td class="table-eddit"></td>
|
||||||
<td class="table-eddit table-number-edit">
|
<td class="table-eddit table-number-edit">
|
||||||
<input id="inpTblNumberOfItems_@(Model.Item.IdProjectPartItem.ToString())" asp-for="Item.NumberOfItems" class="form-control" style="width: 100%" />
|
<input id="inpTblNumberOfItems_@(Model.Item.IdProjectPartItem.ToString())" asp-for="Item.NumberOfItems" class="form-control" style="width: 100%" />
|
||||||
<input id="inpTblNumberOfSets_@(Model.Item.IdProjectPartItem.ToString())" asp-for="Item.NumberOfSets" class="form-control" style="width: 100%" />
|
<input id="inpTblNumberOfSets_@(Model.Item.IdProjectPartItem.ToString())" asp-for="Item.NumberOfSets" class="form-control" style="width: 100%" />
|
||||||
@@ -46,8 +47,8 @@
|
|||||||
@Html.TextBoxFor(m => m.Item.DeliveryDate, "{0:yyyy-MM-dd}", new { @class = "form-control", type = "date", id = "inpTblDeliveryDate_" + Model.Item.IdProjectPartItem.ToString() })
|
@Html.TextBoxFor(m => m.Item.DeliveryDate, "{0:yyyy-MM-dd}", new { @class = "form-control", type = "date", id = "inpTblDeliveryDate_" + Model.Item.IdProjectPartItem.ToString() })
|
||||||
</td>
|
</td>
|
||||||
<td class="text-right table-eddit" style="width: 70px;">
|
<td class="text-right table-eddit" style="width: 70px;">
|
||||||
<a class="btn btn-xs icon-btn btn-outline-success borderless" href='javascript:;' data-state="success" data-iditem="@(Model.Item.IdProjectPartItem)" onclick="updatePartItem(this)"><i class="fas fa-check"></i></a>
|
<a class="btn btn-xs icon-btn btn-outline-success borderless" href='javascript:;' data-state="success" data-iditem="@(Model.Item.IdProjectPartItem)" onclick="updatePartItem(this)" data-toggle="tooltip" data-placement="top" title="Shrani"><i class="fas fa-check"></i></a>
|
||||||
<a id="btnTblCancel_@(Model.Item.IdProjectPartItem.ToString())" href='javascript:;' class="btn btn-xs icon-btn btn-outline-danger borderless" data-state="danger" hx-get="@Url.Page("Edit", "DetailPartItem", new { id = Model.Item.IdProjectPartItem })" hx-swap="outerHTML" hx-target="closest tr"><i class="fas fa-ban"></i></a>
|
<a id="btnTblCancel_@(Model.Item.IdProjectPartItem.ToString())" href='javascript:;' class="btn btn-xs icon-btn btn-outline-danger borderless" data-state="danger" data-toggle="tooltip" data-placement="top" title="Prekliči" hx-get="@Url.Page("Edit", "DetailPartItem", new { id = Model.Item.IdProjectPartItem })" hx-swap="outerHTML" hx-target="closest tr"><i class="fas fa-ban"></i></a>
|
||||||
</td>
|
</td>
|
||||||
}
|
}
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
@@ -80,7 +80,7 @@
|
|||||||
<tbody>
|
<tbody>
|
||||||
@foreach (var item in Model.Project)
|
@foreach (var item in Model.Project)
|
||||||
{
|
{
|
||||||
<tr data-idproject="@item.IdProject" data-title="@item.Title">
|
<tr data-idproject="@item.IdProject" data-title="@item.Title" data-href="@Url.Page("Edit", new { id = item.IdProject })" style="cursor:pointer;">
|
||||||
<td>
|
<td>
|
||||||
@Html.DisplayFor(modelItem => item.ProjectNumberFormatted)
|
@Html.DisplayFor(modelItem => item.ProjectNumberFormatted)
|
||||||
</td>
|
</td>
|
||||||
@@ -133,6 +133,10 @@
|
|||||||
<script>
|
<script>
|
||||||
$('[data-toggle="tooltip"]').tooltip({container: 'table'});
|
$('[data-toggle="tooltip"]').tooltip({container: 'table'});
|
||||||
|
|
||||||
|
$('table tbody tr').on('dblclick', function () {
|
||||||
|
window.location.href = $(this).data('href');
|
||||||
|
});
|
||||||
|
|
||||||
function deleteProject(element) {
|
function deleteProject(element) {
|
||||||
let row = $(element).parent().parent();
|
let row = $(element).parent().parent();
|
||||||
let idProject = $(row).attr('data-idproject');
|
let idProject = $(row).attr('data-idproject');
|
||||||
|
|||||||
@@ -39,83 +39,114 @@
|
|||||||
</span>
|
</span>
|
||||||
</h4>
|
</h4>
|
||||||
|
|
||||||
|
<div class="card pt-2" style="width: 595pt; margin-bottom:10px;">
|
||||||
|
<div class="card-body">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-12 text-right">
|
||||||
|
<button id="btnPrint" type="button" class="btn btn-sm btn-primary btn-print ladda-button pull-right" data-style="zoom-out"><i class="ion ion-md-print"></i> Natisni</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="card pt-2" style="width: 595pt">
|
<div class="card pt-2" style="width: 595pt">
|
||||||
<div id="print-content" class="card-body pb-4 pl-4 pt-0" style="padding-right: 2rem !important">
|
<div id="print-content" class="card-body pb-4 pl-4 pt-0" style="padding-right: 2rem !important">
|
||||||
|
|
||||||
<div class="row">
|
@for (int i = 0; i < Model.Items.Count; i++)
|
||||||
<div class="col-12">
|
{
|
||||||
<address class="mb-0">
|
var item = Model.Items[i];
|
||||||
<strong>@Html.DisplayFor(modelItem => Model.PartItem.ProjectPart.Project.Company.Title)</strong> <br/>
|
<div style="@(i > 0 ? "page-break-before: always;" : "")">
|
||||||
</address>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<hr/>
|
<div class="row">
|
||||||
|
<div class="col-12">
|
||||||
|
<address class="mb-0">
|
||||||
|
<strong>@Html.DisplayFor(modelItem => item.PartItem.ProjectPart.Project.Company.Title)</strong> <br/>
|
||||||
|
</address>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<h4 class="font-weight-bold mb-3">
|
<hr/>
|
||||||
Projekt št.: @Html.DisplayFor(modelItem => Model.PartItem.ProjectPart.Project.ProjectNumberFormatted)
|
|
||||||
</h4>
|
|
||||||
|
|
||||||
<div class="text-big mb-3" style="margin-top: 0 !important; margin-bottom: 0 !important;">
|
<h4 class="font-weight-bold mb-3">
|
||||||
@Html.DisplayFor(modelItem => Model.PartItem.ProjectPart.Project.Title)
|
Projekt št.: @Html.DisplayFor(modelItem => item.PartItem.ProjectPart.Project.ProjectNumberFormatted)
|
||||||
</div>
|
</h4>
|
||||||
|
|
||||||
<div class="mb-3" style="margin-top: 0 !important; margin-bottom: 0 !important;">
|
<div class="text-big mb-3" style="margin-top: 0 !important; margin-bottom: 0 !important;">
|
||||||
<label style="margin-top: 0 !important; margin-bottom: 0 !important;">Del projekta</label>:
|
@Html.DisplayFor(modelItem => item.PartItem.ProjectPart.Project.Title)
|
||||||
<strong class="font-weight-semibold">@Html.DisplayFor(modelItem => Model.PartItem.ProjectPartNumberFormatted)</strong>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="mb-3" style="margin-top: 0 !important; margin-bottom: 0 !important;">
|
<div class="mb-3" style="margin-top: 0 !important; margin-bottom: 0 !important;">
|
||||||
<label style="margin-top: 0 !important; margin-bottom: 0 !important;">Artikel</label>:
|
<label style="margin-top: 0 !important; margin-bottom: 0 !important;">Del projekta</label>:
|
||||||
<strong class="font-weight-semibold">@Html.DisplayFor(modelItem => Model.PartItem.Item.Title)</strong>
|
<strong class="font-weight-semibold">@Html.DisplayFor(modelItem => item.PartItem.ProjectPartNumberFormatted)</strong>
|
||||||
</div>
|
</div>
|
||||||
<div class="mb-3" style="margin-top: 0 !important; margin-bottom: 0 !important;">
|
|
||||||
<label style="margin-top: 0 !important; margin-bottom: 0 !important;">Material</label>:
|
|
||||||
<strong class="font-weight-semibold">@Html.DisplayFor(modelItem => Model.PartItem.Material.Title)</strong>
|
|
||||||
</div>
|
|
||||||
<div class="mb-3" style="margin-top: 0 !important; margin-bottom: 0 !important;">
|
|
||||||
<label style="margin-top: 0 !important; margin-bottom: 0 !important;">Dimenzije surovca</label>:
|
|
||||||
<strong class="font-weight-semibold">@Html.DisplayFor(modelItem => Model.PartItem.MaterialDimensions)</strong>
|
|
||||||
</div>
|
|
||||||
<div class="mb-3" style="margin-top: 0 !important; margin-bottom: 0 !important;">
|
|
||||||
<label style="margin-top: 0 !important; margin-bottom: 0 !important;">Število kosov</label>:
|
|
||||||
<strong class="font-weight-semibold">@Html.DisplayFor(modelItem => Model.PartItem.NumberOfItems)</strong>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<br/>
|
<div class="mb-3" style="margin-top: 0 !important; margin-bottom: 0 !important;">
|
||||||
|
<label style="margin-top: 0 !important; margin-bottom: 0 !important;">Artikel</label>:
|
||||||
|
<strong class="font-weight-semibold">@Html.DisplayFor(modelItem => item.PartItem.Item.Title)</strong>
|
||||||
|
</div>
|
||||||
|
<div class="mb-3" style="margin-top: 0 !important; margin-bottom: 0 !important;">
|
||||||
|
<label style="margin-top: 0 !important; margin-bottom: 0 !important;">Material</label>:
|
||||||
|
<strong class="font-weight-semibold">@Html.DisplayFor(modelItem => item.PartItem.Material.Title)</strong>
|
||||||
|
</div>
|
||||||
|
<div class="mb-3" style="margin-top: 0 !important; margin-bottom: 0 !important;">
|
||||||
|
<label style="margin-top: 0 !important; margin-bottom: 0 !important;">Dimenzije surovca</label>:
|
||||||
|
<strong class="font-weight-semibold">@Html.DisplayFor(modelItem => item.PartItem.MaterialDimensions)</strong>
|
||||||
|
</div>
|
||||||
|
<div class="mb-3" style="margin-top: 0 !important; margin-bottom: 0 !important;">
|
||||||
|
<label style="margin-top: 0 !important; margin-bottom: 0 !important;">Število kosov</label>:
|
||||||
|
<strong class="font-weight-semibold">@Html.DisplayFor(modelItem => item.PartItem.NumberOfItems)</strong>
|
||||||
|
</div>
|
||||||
|
|
||||||
<h6>Operacije</h6>
|
@if (!string.IsNullOrEmpty(item.PartItem.ProjectPart.PathOfPlans))
|
||||||
<div class="table-responsive mb-4">
|
{
|
||||||
<table class="table m-0 table-bordered">
|
<div class="mb-3" style="margin-top: 0 !important; margin-bottom: 0 !important;">
|
||||||
<thead style="font-size: 0.75rem">
|
<label style="margin-top: 0 !important; margin-bottom: 0 !important;">Pot načrtov</label>:
|
||||||
<tr>
|
<strong class="font-weight-semibold">@Html.DisplayFor(modelItem => item.PartItem.ProjectPart.PathOfPlans)</strong>
|
||||||
<th style="width: 30px">#</th>
|
</div>
|
||||||
<th class="py-1">
|
}
|
||||||
Operacija
|
|
||||||
</th>
|
@if (!string.IsNullOrEmpty(item.PartItem.Note))
|
||||||
<th class="py-1" style="width: 150px">
|
{
|
||||||
Čas
|
<div class="mb-3" style="margin-top: 0 !important; margin-bottom: 0 !important;">
|
||||||
</th>
|
<br />
|
||||||
</tr>
|
<i class="">@Html.DisplayFor(modelItem => item.PartItem.Note)</i>
|
||||||
</thead>
|
</div>
|
||||||
<tbody style="font-size: 0.75rem">
|
}
|
||||||
@foreach (var item in Model.Operations)
|
|
||||||
{
|
<br/>
|
||||||
|
|
||||||
|
<h6>Operacije</h6>
|
||||||
|
<div class="table-responsive mb-4">
|
||||||
|
<table class="table m-0 table-bordered">
|
||||||
|
<thead style="font-size: 0.75rem">
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<th style="width: 30px">#</th>
|
||||||
@(Model.Operations.IndexOf(item) + 1)
|
<th class="py-1">
|
||||||
</td>
|
Operacija
|
||||||
<td>@Html.DisplayFor(x => item.Operation.Title)</td>
|
</th>
|
||||||
<td></td>
|
<th class="py-1" style="width: 150px">
|
||||||
|
Čas
|
||||||
|
</th>
|
||||||
</tr>
|
</tr>
|
||||||
}
|
</thead>
|
||||||
</tbody>
|
<tbody style="font-size: 0.75rem">
|
||||||
</table>
|
@{ var opIndex = 0; }
|
||||||
</div>
|
@foreach (var op in item.Operations)
|
||||||
|
{
|
||||||
|
opIndex++;
|
||||||
|
<tr>
|
||||||
|
<td>@opIndex</td>
|
||||||
|
<td>@Html.DisplayFor(x => op.Operation.Title)</td>
|
||||||
|
<td></td>
|
||||||
|
</tr>
|
||||||
|
}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
|
||||||
</div>
|
|
||||||
<div class="card-footer">
|
|
||||||
<button id="btnPrint" type="button" class="btn btn-primary btn-print ladda-button pull-right" data-style="zoom-out"><i class="ion ion-md-print"></i> Natisni</button>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@Html.AntiForgeryToken()
|
@Html.AntiForgeryToken()
|
||||||
|
|||||||
@@ -19,14 +19,18 @@ namespace EveryThing.Pages.Projects
|
|||||||
[Authorize(Roles = "Administrator,InvoicingUser,ProjecThingUser")]
|
[Authorize(Roles = "Administrator,InvoicingUser,ProjecThingUser")]
|
||||||
public class PrintPartItem : PageModel
|
public class PrintPartItem : PageModel
|
||||||
{
|
{
|
||||||
|
public class PrintPartItemData
|
||||||
|
{
|
||||||
|
public ProjectPartItem PartItem { get; set; }
|
||||||
|
public IList<ProjectPartItemOperation> Operations { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
private readonly ApplicationDbContext _context;
|
private readonly ApplicationDbContext _context;
|
||||||
private readonly UserManager<IdentityApplicationUser> _userManager;
|
private readonly UserManager<IdentityApplicationUser> _userManager;
|
||||||
|
|
||||||
public ProjectPartItem PartItem { get; set; }
|
public ProjectPartItem PartItem { get; set; }
|
||||||
|
|
||||||
public IList<ProjectPartItemOperation> Operations { get; set; }
|
public IList<ProjectPartItemOperation> Operations { get; set; }
|
||||||
|
public IList<PrintPartItemData> Items { get; set; } = new List<PrintPartItemData>();
|
||||||
|
|
||||||
public PrintPartItem(ApplicationDbContext context, UserManager<IdentityApplicationUser> userManager)
|
public PrintPartItem(ApplicationDbContext context, UserManager<IdentityApplicationUser> userManager)
|
||||||
{
|
{
|
||||||
@@ -34,27 +38,57 @@ namespace EveryThing.Pages.Projects
|
|||||||
_userManager = userManager;
|
_userManager = userManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<IActionResult> OnGetAsync(int id)
|
public async Task<IActionResult> OnGetAsync(int? id, string ids)
|
||||||
{
|
{
|
||||||
var user = _userManager.GetUserAsync(User).Result;
|
var user = _userManager.GetUserAsync(User).Result;
|
||||||
|
|
||||||
PartItem = await _context.ProjectPartItems
|
var itemIds = new List<int>();
|
||||||
.Include(x => x.ProjectPart)
|
|
||||||
.ThenInclude(x => x.Project)
|
|
||||||
.ThenInclude(x => x.Company)
|
|
||||||
.Include(x => x.Material)
|
|
||||||
.Include(x => x.Item)
|
|
||||||
.FirstOrDefaultAsync(x => x.IdProjectPartItem == id && x.ProjectPart.Project.Company.IdCompany == user.IdCompanyFk);
|
|
||||||
|
|
||||||
if (PartItem == null)
|
if (!string.IsNullOrEmpty(ids))
|
||||||
|
{
|
||||||
|
itemIds = ids.Split(',', StringSplitOptions.RemoveEmptyEntries)
|
||||||
|
.Select(x => int.TryParse(x.Trim(), out var v) ? v : 0)
|
||||||
|
.Where(x => x > 0)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
else if (id.HasValue)
|
||||||
|
{
|
||||||
|
itemIds.Add(id.Value);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!itemIds.Any())
|
||||||
return NotFound();
|
return NotFound();
|
||||||
|
|
||||||
|
var partItems = await _context.ProjectPartItems
|
||||||
Operations = await _context.ProjectPartItemOperations
|
.Include(x => x.ProjectPart)
|
||||||
.Include(x => x.Operation)
|
.ThenInclude(x => x.Project)
|
||||||
.Where(x => x.IdProjectPartItemFk == PartItem.IdProjectPartItem)
|
.ThenInclude(x => x.Company)
|
||||||
|
.Include(x => x.Material)
|
||||||
|
.Include(x => x.Item)
|
||||||
|
.Where(x => itemIds.Contains(x.IdProjectPartItem) && x.ProjectPart.Project.Company.IdCompany == user.IdCompanyFk)
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
|
if (!partItems.Any())
|
||||||
|
return NotFound();
|
||||||
|
|
||||||
|
var allOperations = await _context.ProjectPartItemOperations
|
||||||
|
.Include(x => x.Operation)
|
||||||
|
.Where(x => itemIds.Contains(x.IdProjectPartItemFk))
|
||||||
|
.OrderBy(x => x.Order)
|
||||||
|
.ToListAsync();
|
||||||
|
|
||||||
|
foreach (var partItem in partItems.OrderBy(x => itemIds.IndexOf(x.IdProjectPartItem)))
|
||||||
|
{
|
||||||
|
Items.Add(new PrintPartItemData
|
||||||
|
{
|
||||||
|
PartItem = partItem,
|
||||||
|
Operations = allOperations.Where(x => x.IdProjectPartItemFk == partItem.IdProjectPartItem).ToList()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Keep backward compatibility for single-item references
|
||||||
|
PartItem = Items.First().PartItem;
|
||||||
|
Operations = Items.First().Operations;
|
||||||
|
|
||||||
return Page();
|
return Page();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,16 @@
|
|||||||
"ConnectionStrings": {
|
"ConnectionStrings": {
|
||||||
"DataConnection": "server=192.168.1.12;user=everything;password=EveryThing2022!;database=EveryThingDev"
|
"DataConnection": "server=192.168.1.12;user=everything;password=EveryThing2022!;database=EveryThingDev"
|
||||||
},
|
},
|
||||||
|
"EmailSettings": {
|
||||||
|
"Host": "mail.no-reply.si",
|
||||||
|
"Port": 465,
|
||||||
|
"SecureSocketOptions": "SslOnConnect",
|
||||||
|
"Username": "cnc-paradiz@no-reply.si",
|
||||||
|
"Password": "52svchwokzce#ss",
|
||||||
|
"FromEmail": "cnc-paradiz@no-reply.si",
|
||||||
|
"FromName": "CNC - Paradiž",
|
||||||
|
"Bcc": "david.staleker@gmail.com"
|
||||||
|
},
|
||||||
"Logging": {
|
"Logging": {
|
||||||
"LogLevel": {
|
"LogLevel": {
|
||||||
"Default": "Information",
|
"Default": "Information",
|
||||||
|
|||||||
@@ -13,8 +13,8 @@
|
|||||||
</targets>
|
</targets>
|
||||||
|
|
||||||
<rules>
|
<rules>
|
||||||
<logger name="*" minlevel="Trace" writeTo="logFile" />
|
<logger name="*" minlevel="Warn" writeTo="logFile" />
|
||||||
<logger name="*" minlevel="Trace" writeTo="console" />
|
<logger name="*" minlevel="Warn" writeTo="console" />
|
||||||
|
|
||||||
<logger name="Microsoft.*" maxlevel="Info" final="true" />
|
<logger name="Microsoft.*" maxlevel="Info" final="true" />
|
||||||
<logger name="System.Net.Http.*" maxlevel="Info" final="true" />
|
<logger name="System.Net.Http.*" maxlevel="Info" final="true" />
|
||||||
|
|||||||
Reference in New Issue
Block a user