Compare commits

...

6 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
10 changed files with 228 additions and 102 deletions

View File

@@ -173,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>
@@ -222,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)

View File

@@ -42,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";
@@ -170,10 +171,13 @@ namespace EveryThing.Pages.Invoices
var password = emailSettings["Password"]; var password = emailSettings["Password"];
var fromEmail = emailSettings["FromEmail"]; var fromEmail = emailSettings["FromEmail"];
var fromName = emailSettings["FromName"]; var fromName = emailSettings["FromName"];
var bcc = emailSettings["Bcc"];
var mimeMessage = new MimeMessage(); var mimeMessage = new MimeMessage();
mimeMessage.From.Add(new MailboxAddress(fromName, fromEmail)); mimeMessage.From.Add(new MailboxAddress(fromName, fromEmail));
mimeMessage.To.Add(new MailboxAddress(invoice.Partner.Title, invoice.Partner.Email)); 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; mimeMessage.Subject = invoice.InvoiceNumberFull;
var bodyBuilder = new BodyBuilder var bodyBuilder = new BodyBuilder
@@ -298,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",

View File

@@ -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 {

View File

@@ -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" style="cursor: pointer;" ondblclick="if(!$(event.target).closest('a,button,input').length) { $('[data-toggle=tooltip]').tooltip('hide'); $(this).find('.btn-tbl-inline-edit').click(); }"> @{
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>&nbsp;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/>

View File

@@ -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
@@ -745,6 +752,7 @@
<button class="btn btn-secondary" onclick="createOrderSelectPartner(true, 2); return false;">Kreiraj povpraševanje izdelka</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-3 text-right"> <div class="col-3 text-right">
@@ -874,6 +882,16 @@
function tooltips() { function tooltips() {
$('[data-toggle="tooltip"]').tooltip(); $('[data-toggle="tooltip"]').tooltip();
} }
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) { function createOrderSelectPartner(inquiry, positionsType) {
$.blockUI(); $.blockUI();
$.ajax({ $.ajax({

View File

@@ -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);
@@ -641,12 +646,17 @@ namespace EveryThing.Pages.Projects
{ {
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())
{ {
var operations = _context.ProjectPartItemOperations
.Where(x => x.IdProjectPartItemFk == projectPartItem.IdProjectPartItem)
.ToList();
_context.ProjectPartItemOperations.RemoveRange(operations);
_context.ProjectPartItems.Remove(projectPartItem); _context.ProjectPartItems.Remove(projectPartItem);
} }
_context.ProjectParts.Remove(projectPart); _context.ProjectParts.Remove(projectPart);
_context.SaveChanges(); _context.SaveChanges();
projectPart.Project = null; projectPart.Project = null;
projectPart.ProjectPartProjectPartItem = null;
} }
else else
{ {

View File

@@ -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%" />

View File

@@ -39,13 +39,28 @@
</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>&nbsp; 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">
@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="row">
<div class="col-12"> <div class="col-12">
<address class="mb-0"> <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> </address>
</div> </div>
</div> </div>
@@ -53,35 +68,51 @@
<hr/> <hr/>
<h4 class="font-weight-bold mb-3"> <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> </h4>
<div class="text-big 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;">
@Html.DisplayFor(modelItem => Model.PartItem.ProjectPart.Project.Title) @Html.DisplayFor(modelItem => item.PartItem.ProjectPart.Project.Title)
</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;">Del projekta</label>:&nbsp; <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>
<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>:&nbsp; <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>
<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;">Material</label>:&nbsp; <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>
<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;">Dimenzije surovca</label>:&nbsp; <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>
<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;">Število kosov</label>:&nbsp; <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> </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/> <br/>
<h6>Operacije</h6> <h6>Operacije</h6>
@@ -99,13 +130,13 @@
</tr> </tr>
</thead> </thead>
<tbody style="font-size: 0.75rem"> <tbody style="font-size: 0.75rem">
@foreach (var item in Model.Operations) @{ var opIndex = 0; }
@foreach (var op in item.Operations)
{ {
opIndex++;
<tr> <tr>
<td> <td>@opIndex</td>
@(Model.Operations.IndexOf(item) + 1) <td>@Html.DisplayFor(x => op.Operation.Title)</td>
</td>
<td>@Html.DisplayFor(x => item.Operation.Title)</td>
<td></td> <td></td>
</tr> </tr>
} }
@@ -114,8 +145,8 @@
</div> </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>&nbsp; Natisni</button>
</div> </div>
</div> </div>
@Html.AntiForgeryToken() @Html.AntiForgeryToken()

View File

@@ -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>();
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) .Include(x => x.ProjectPart)
.ThenInclude(x => x.Project) .ThenInclude(x => x.Project)
.ThenInclude(x => x.Company) .ThenInclude(x => x.Company)
.Include(x => x.Material) .Include(x => x.Material)
.Include(x => x.Item) .Include(x => x.Item)
.FirstOrDefaultAsync(x => x.IdProjectPartItem == id && x.ProjectPart.Project.Company.IdCompany == user.IdCompanyFk); .Where(x => itemIds.Contains(x.IdProjectPartItem) && 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)
.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();
} }

View File

@@ -9,7 +9,8 @@
"Username": "cnc-paradiz@no-reply.si", "Username": "cnc-paradiz@no-reply.si",
"Password": "52svchwokzce#ss", "Password": "52svchwokzce#ss",
"FromEmail": "cnc-paradiz@no-reply.si", "FromEmail": "cnc-paradiz@no-reply.si",
"FromName": "CNC - Paradiž" "FromName": "CNC - Paradiž",
"Bcc": "david.staleker@gmail.com"
}, },
"Logging": { "Logging": {
"LogLevel": { "LogLevel": {