Compare commits

..

9 Commits

Author SHA1 Message Date
da7b320032 tiskanje bulk + vrsni red opreacij na tiskanju 2026-03-19 19:31:24 +01:00
43efa11d9c ce je project part item na invocu null vrze error 2026-03-12 15:52:05 +01:00
5d492de137 Opomba 2026-03-12 15:46:27 +01:00
8349ce5b41 styling 2026-03-04 20:28:19 +01:00
aa85143ff3 brisanje pobrise se operacije 2026-03-04 20:27:54 +01:00
99d61af1a1 tiskanje opombe, poti nacrtov
stolpec naslednja operacija,
popravljeno brisanje
popravljeno da nafila samo privzete operacije in ne vec doda v kooepracije
posiljanje dodano skp
2026-03-04 20:19:23 +01:00
73e41cc3a3 Only warn 2026-03-03 20:46:26 +01:00
5ed4ca19fc double click edit + tooltips 2026-03-03 14:45:53 +01:00
4cdfbace03 tiskanje in posiljanje po mailo 2026-03-03 09:16:17 +01:00
14 changed files with 504 additions and 165 deletions

View File

@@ -34,6 +34,7 @@
<PackageReference Include="Htmx" Version="0.0.15" />
<PackageReference Include="Htmx.TagHelpers" Version="0.0.15" />
<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.Negotiate" Version="6.0.2" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="6.0.1" />

View File

@@ -112,7 +112,7 @@ namespace EveryThing.Pages.CodeTableItems
sellingPrice = projectPartItem.SellingPrice;
differenceInPricePercentage = projectPartItem.DifferenceInPricePercentage;
materialDimensions = projectPartItem.MaterialDimensions;
material = projectPartItem.Material.Title;
material = projectPartItem?.Material?.Title;
}
}

View File

@@ -61,6 +61,29 @@
</span>
</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>&nbsp; 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>&nbsp; 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>&nbsp; Pošlji</button>
</div>
</div>
</div>
</div>
<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">
@@ -150,6 +173,9 @@
<th class="py-1 text-right">
@Model.Translation.Price
</th>
<th class="py-1 text-right">
@Model.Translation.Discount
</th>
<th class="py-1 text-right">
@Model.Translation.Amount
</th>
@@ -199,6 +225,7 @@
|| 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.Discount)%</td>
<td class="text-right">@Html.DisplayFor(x => item.TotalValue)</td>
}
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>
<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>&nbsp; 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>&nbsp; Natisni</button>
</div>
</div>
</div>
</div>
@Html.AntiForgeryToken()
@@ -281,6 +291,7 @@
<script>
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 element = document.getElementById('print-content');
@@ -300,43 +311,40 @@
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) {
laddaPrint.start();
if (laddaPrintAndConfirm != null) {
laddaPrintAndConfirm.start();
}
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);
}
buildPdf(function (pdf) {
laddaPrint.stop();
if (laddaPrintAndConfirm != null) {
laddaPrintAndConfirm.stop();
}
//window.open(pdf.output('bloburl'), '_blank');
let link = document.createElement('a');
link.target = '_blank';
link.href = pdf.output('bloburl');
@@ -346,7 +354,6 @@
if (confirm) {
confirmInvoice();
}
});
}
@@ -358,6 +365,85 @@
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() {
$.blockUI();
$.ajax({

View File

@@ -3,10 +3,16 @@ using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using MailKit.Net.Smtp;
using MailKit.Security;
using MimeKit;
using EveryThing.Data;
using EveryThing.Models;
using EveryThing.Models.Invoice;
@@ -36,6 +42,7 @@ namespace EveryThing.Pages.Invoices
public string Article { get; set; } = "Artikel";
public string Quantity { get; set; } = "Količina";
public string Price { get; set; } = "Cena";
public string Discount { get; set; } = "Rabat";
public string Amount { get; set; } = "Znesek";
public string Dimensions { get; set; } = "Dimenzije";
public string Total { get; set; } = "Skupaj";
@@ -55,16 +62,20 @@ namespace EveryThing.Pages.Invoices
private readonly ApplicationDbContext _context;
private readonly UserManager<IdentityApplicationUser> _userManager;
private readonly IConfiguration _configuration;
private readonly IWebHostEnvironment _environment;
public Models.Invoice.Invoice Invoice { get; set; }
public PrintTranslation Translation { get; set; }
public IList<Models.Invoice.InvoiceItem> InvoiceItems { 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;
_userManager = userManager;
_configuration = configuration;
_environment = environment;
}
public async Task<IActionResult> OnGetAsync(int id, int? printTranslationLanguage)
@@ -112,6 +123,97 @@ namespace EveryThing.Pages.Invoices
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)
{
var user = _userManager.GetUserAsync(User).Result;
@@ -200,6 +302,7 @@ namespace EveryThing.Pages.Invoices
OrderNumber = invoiceState == Invoice.InvoiceState.Offer ? "Anfrage No." : "Bestellnummer",
Price = "Preis(€)",
Quantity = "Menge(Stk)",
Discount = "Rabatt",
SwiftBic = "SWIFT/BIC",
Total = "Gesamtsumme",
Project = "Projekt",

View File

@@ -204,7 +204,7 @@
</div>
}
<table class="table">
<table id="tblOperations" class="table">
<thead>
<tr>
<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>
</td>
</tr>`;
$('table.table tbody').append(row);
$('#tblOperations tbody').append(row);
$('#selProjectPartItemOperation option[value="' + op.idCodeTableOperation + '"]').remove();
});
$('#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>
</td>
</tr>`;
$('table.table tbody').append(row);
$('#tblOperations tbody').append(row);
$('#selProjectPartItemOperation option[value="' + idCodeTableOperation + '"]').remove();
$('#selProjectPartItemOperation').trigger('change');
} else {

View File

@@ -1,7 +1,11 @@
@using System.Globalization
@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;">
@if(Model.Status != Models.Project.ProjectPartItemStatus.Shipped)
{
@@ -18,6 +22,10 @@
@Html.DisplayFor(modelItem => Model.IdItemFk)
}
<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)
</td>
<td>
@@ -35,6 +43,20 @@
<br/>
@Html.DisplayFor(modelItem => Model.MaterialDimensions)
</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>&nbsp;Vse zaključeno</span>
}
else
{
@(nextOp?.Operation?.Title ?? "")
}
</td>
<td class="table-number">
@(Model.NumberOfItems.ToString("0.00", new CultureInfo("sl-SI")))
<br/>
@@ -71,9 +93,9 @@
@Html.DisplayFor(modelItem => Model.DeliveryDate)
</td>
<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 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-danger borderless" data-state="danger" href='javascript:;' onclick="deletePartItem(this)"><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 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:;' 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)" 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" 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>
</tr>

View File

@@ -13,6 +13,10 @@
border-top: none;
}
.project-part-item-has-note {
background-color: #fff8e1;
}
.tab-panel-invoices{
height: 490px;
overflow-y: auto;
@@ -195,7 +199,7 @@
<tbody>
@foreach (var invoice in Model.Invoices.Where(x => x.Type == Models.Invoice.Invoice.InvoiceType.Order))
{
<tr class="invoice-row" data-idparts="@string.Join(",", invoice.InvoiceInvoiceItem?.Select(x => x.ProjectPartItem.IdProjectPartFk) ?? Array.Empty<int>())">
<tr class="invoice-row" data-idparts="@string.Join(",", invoice.InvoiceInvoiceItem?.Select(x => x.ProjectPartItem?.IdProjectPartFk ?? 0) ?? Array.Empty<int>())">
<td>
@Html.DisplayFor(modelItem => invoice.InvoiceYear) - @Html.DisplayFor(modelItem => invoice.InvoiceNumber)
</td>
@@ -261,7 +265,7 @@
<tbody>
@foreach (var invoice in Model.Invoices.Where(x => x.Type == Models.Invoice.Invoice.InvoiceType.DeliveryNote))
{
<tr class="invoice-row" data-idinvoice="@invoice.IdInvoice" data-idparts="@string.Join(",", invoice.InvoiceInvoiceItem?.Select(x => x.ProjectPartItem.IdProjectPartFk) ?? 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;">
@if (invoice.State == Invoice.InvoiceState.Confirmed)
{
@@ -331,7 +335,7 @@
<tbody>
@foreach (var invoice in Model.Invoices.Where(x => x.Type == Models.Invoice.Invoice.InvoiceType.Invoice))
{
<tr class="invoice-row" data-idinvoice="@invoice.IdInvoice" data-idparts="@string.Join(",", invoice.InvoiceInvoiceItem?.Select(x => x.ProjectPartItem.IdProjectPartFk) ?? 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>
@Html.DisplayFor(modelItem => invoice.InvoiceYear) - @Html.DisplayFor(modelItem => invoice.InvoiceNumber)
</td>
@@ -533,7 +537,7 @@
<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) ?? Array.Empty<int>())">
<tr class="invoice-row" data-idparts="@string.Join(",", invoice.InvoiceInvoiceItem?.Select(x => x.ProjectPartItem?.IdProjectPartFk ?? 0) ?? Array.Empty<int>())">
<td>
@Html.DisplayFor(modelItem => invoice.InvoiceYear) - @Html.DisplayFor(modelItem => invoice.InvoiceNumber)
</td>
@@ -644,6 +648,9 @@
<br/>
Dimenzije surovca
</th>
<th>
Naslednja operacija
</th>
<th class="table-header-number">
<div data-toggle="tooltip" data-placement="top" title="Število kosov<br/>Število kompletov" data-html="true">
Kos
@@ -739,14 +746,16 @@
</div>
<div class="card-footer py-3">
<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(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-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 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>
</div>
</div>
@@ -774,9 +783,15 @@
<script>
const openProjectPartCookieName = 'openProjectPart' + @Html.Raw(Model.Project.IdProject);
$(document).ready(function() {
document.body.addEventListener('htmx:beforeRequest',
function(evt) {
$('[data-toggle=tooltip]').tooltip('hide');
});
document.body.addEventListener('htmx:afterSettle',
function(evt) {
$('.select2').select2();
tooltips();
$('.inp-tbl-edit-calculate-price').on("input",
function() {
@@ -867,7 +882,17 @@
function tooltips() {
$('[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();
$.ajax({
type: "GET",
@@ -895,7 +920,7 @@
}
}).then((result) => {
if (result.isConfirmed) {
createOrder(inquiry, result.value);
createOrder(inquiry, result.value, positionsType);
}
});
} else {
@@ -914,10 +939,14 @@
});
}
function createOrder(inquiry, idPartner) {
function createOrder(inquiry, idPartner, positionsType) {
if (idPartner == null || idPartner == undefined || isNaN(idPartner))
idPartner = 0;
if (isNaN(positionsType) || positionsType == null || positionsType == undefined){
positionsType = 1;
}
let object = getSelectedPartItems();
if (object.length <= 0) {
@@ -932,7 +961,7 @@
$('input:hidden[name="__RequestVerificationToken"]').val());
},
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) {
if (data.successful) {
if (inquiry) {

View File

@@ -91,6 +91,9 @@ namespace EveryThing.Pages.Projects
.ThenInclude(x => x.Material)
.Include(c => c.ProjectPartProjectPartItem)
.ThenInclude(x => x.Item)
.Include(c => c.ProjectPartProjectPartItem)
.ThenInclude(x => x.ProjectPartItemOperation)
.ThenInclude(x => x.Operation)
.Where(x => x.IdProjectFk == id)
.OrderBy(x => x.ProjectPartNumber).ThenBy(x => x.IdProjectPart)
.ToListAsync();
@@ -192,6 +195,8 @@ namespace EveryThing.Pages.Projects
.Include(x => x.Material)
.Include(x => x.ProjectPart)
.ThenInclude(x => x.Project)
.Include(x => x.ProjectPartItemOperation)
.ThenInclude(x => x.Operation)
.First(x => x.IdProjectPartItem == id);
return Partial("DetailsPartItem", item);
@@ -272,7 +277,7 @@ namespace EveryThing.Pages.Projects
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;
@@ -333,13 +338,21 @@ namespace EveryThing.Pages.Projects
Discount = 0,
IdInvoiceFk = idInvoice,
IdProjectPartItem = projectPartItem.IdProjectPartItem,
IdItemFk = projectPartItem.IdMaterialFk,
ItemDescription = projectPartItem.MaterialDimensions,
Note = "",
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.SaveChanges();
@@ -633,12 +646,17 @@ namespace EveryThing.Pages.Projects
{
foreach (var projectPartItem in _context.ProjectPartItems.Where(x => x.IdProjectPartFk == projectPart.IdProjectPart).ToList())
{
var operations = _context.ProjectPartItemOperations
.Where(x => x.IdProjectPartItemFk == projectPartItem.IdProjectPartItem)
.ToList();
_context.ProjectPartItemOperations.RemoveRange(operations);
_context.ProjectPartItems.Remove(projectPartItem);
}
_context.ProjectParts.Remove(projectPart);
_context.SaveChanges();
projectPart.Project = null;
projectPart.ProjectPartProjectPartItem = null;
}
else
{

View File

@@ -21,6 +21,7 @@
</div>
<input id="inpTblMaterialDimensions_@(Model.Item.IdProjectPartItem.ToString())" asp-for="Item.MaterialDimensions" class="form-control" style="width: 100%"/>
</td>
<td class="table-eddit"></td>
<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="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() })
</td>
<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 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 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" 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>
}
</tr>

View File

@@ -80,7 +80,7 @@
<tbody>
@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>
@Html.DisplayFor(modelItem => item.ProjectNumberFormatted)
</td>
@@ -133,6 +133,10 @@
<script>
$('[data-toggle="tooltip"]').tooltip({container: 'table'});
$('table tbody tr').on('dblclick', function () {
window.location.href = $(this).data('href');
});
function deleteProject(element) {
let row = $(element).parent().parent();
let idProject = $(row).attr('data-idproject');

View File

@@ -39,13 +39,28 @@
</span>
</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>&nbsp; Natisni</button>
</div>
</div>
</div>
</div>
<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">
@for (int i = 0; i < Model.Items.Count; i++)
{
var item = Model.Items[i];
<div style="@(i > 0 ? "page-break-before: always;" : "")">
<div class="row">
<div class="col-12">
<address class="mb-0">
<strong>@Html.DisplayFor(modelItem => Model.PartItem.ProjectPart.Project.Company.Title)</strong> <br/>
<strong>@Html.DisplayFor(modelItem => item.PartItem.ProjectPart.Project.Company.Title)</strong> <br/>
</address>
</div>
</div>
@@ -53,35 +68,51 @@
<hr/>
<h4 class="font-weight-bold mb-3">
Projekt št.: @Html.DisplayFor(modelItem => Model.PartItem.ProjectPart.Project.ProjectNumberFormatted)
Projekt št.: @Html.DisplayFor(modelItem => item.PartItem.ProjectPart.Project.ProjectNumberFormatted)
</h4>
<div class="text-big mb-3" style="margin-top: 0 !important; margin-bottom: 0 !important;">
@Html.DisplayFor(modelItem => Model.PartItem.ProjectPart.Project.Title)
@Html.DisplayFor(modelItem => item.PartItem.ProjectPart.Project.Title)
</div>
<div class="mb-3" style="margin-top: 0 !important; margin-bottom: 0 !important;">
<label style="margin-top: 0 !important; margin-bottom: 0 !important;">Del projekta</label>:&nbsp;
<strong class="font-weight-semibold">@Html.DisplayFor(modelItem => Model.PartItem.ProjectPartNumberFormatted)</strong>
<strong class="font-weight-semibold">@Html.DisplayFor(modelItem => item.PartItem.ProjectPartNumberFormatted)</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;">Artikel</label>:&nbsp;
<strong class="font-weight-semibold">@Html.DisplayFor(modelItem => Model.PartItem.Item.Title)</strong>
<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>:&nbsp;
<strong class="font-weight-semibold">@Html.DisplayFor(modelItem => Model.PartItem.Material.Title)</strong>
<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>:&nbsp;
<strong class="font-weight-semibold">@Html.DisplayFor(modelItem => Model.PartItem.MaterialDimensions)</strong>
<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>:&nbsp;
<strong class="font-weight-semibold">@Html.DisplayFor(modelItem => Model.PartItem.NumberOfItems)</strong>
<strong class="font-weight-semibold">@Html.DisplayFor(modelItem => item.PartItem.NumberOfItems)</strong>
</div>
@if (!string.IsNullOrEmpty(item.PartItem.ProjectPart.PathOfPlans))
{
<div class="mb-3" style="margin-top: 0 !important; margin-bottom: 0 !important;">
<label style="margin-top: 0 !important; margin-bottom: 0 !important;">Pot načrtov</label>:&nbsp;
<strong class="font-weight-semibold">@Html.DisplayFor(modelItem => item.PartItem.ProjectPart.PathOfPlans)</strong>
</div>
}
@if (!string.IsNullOrEmpty(item.PartItem.Note))
{
<div class="mb-3" style="margin-top: 0 !important; margin-bottom: 0 !important;">
<br />
<i class="">@Html.DisplayFor(modelItem => item.PartItem.Note)</i>
</div>
}
<br/>
<h6>Operacije</h6>
@@ -99,13 +130,13 @@
</tr>
</thead>
<tbody style="font-size: 0.75rem">
@foreach (var item in Model.Operations)
@{ var opIndex = 0; }
@foreach (var op in item.Operations)
{
opIndex++;
<tr>
<td>
@(Model.Operations.IndexOf(item) + 1)
</td>
<td>@Html.DisplayFor(x => item.Operation.Title)</td>
<td>@opIndex</td>
<td>@Html.DisplayFor(x => op.Operation.Title)</td>
<td></td>
</tr>
}
@@ -114,8 +145,8 @@
</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>&nbsp; Natisni</button>
}
</div>
</div>
@Html.AntiForgeryToken()

View File

@@ -19,14 +19,18 @@ namespace EveryThing.Pages.Projects
[Authorize(Roles = "Administrator,InvoicingUser,ProjecThingUser")]
public class PrintPartItem : PageModel
{
public class PrintPartItemData
{
public ProjectPartItem PartItem { get; set; }
public IList<ProjectPartItemOperation> Operations { get; set; }
}
private readonly ApplicationDbContext _context;
private readonly UserManager<IdentityApplicationUser> _userManager;
public ProjectPartItem PartItem { get; set; }
public IList<ProjectPartItemOperation> Operations { get; set; }
public IList<PrintPartItemData> Items { get; set; } = new List<PrintPartItemData>();
public PrintPartItem(ApplicationDbContext context, UserManager<IdentityApplicationUser> userManager)
{
@@ -34,27 +38,57 @@ namespace EveryThing.Pages.Projects
_userManager = userManager;
}
public async Task<IActionResult> OnGetAsync(int id)
public async Task<IActionResult> OnGetAsync(int? id, string ids)
{
var user = _userManager.GetUserAsync(User).Result;
PartItem = await _context.ProjectPartItems
var itemIds = new List<int>();
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();
var partItems = await _context.ProjectPartItems
.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)
return NotFound();
Operations = await _context.ProjectPartItemOperations
.Include(x => x.Operation)
.Where(x => x.IdProjectPartItemFk == PartItem.IdProjectPartItem)
.Where(x => itemIds.Contains(x.IdProjectPartItem) && x.ProjectPart.Project.Company.IdCompany == user.IdCompanyFk)
.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();
}

View File

@@ -2,6 +2,16 @@
"ConnectionStrings": {
"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": {
"LogLevel": {
"Default": "Information",

View File

@@ -13,8 +13,8 @@
</targets>
<rules>
<logger name="*" minlevel="Trace" writeTo="logFile" />
<logger name="*" minlevel="Trace" writeTo="console" />
<logger name="*" minlevel="Warn" writeTo="logFile" />
<logger name="*" minlevel="Warn" writeTo="console" />
<logger name="Microsoft.*" maxlevel="Info" final="true" />
<logger name="System.Net.Http.*" maxlevel="Info" final="true" />