diff --git a/EveryThing/Keys/key-e803459e-6187-453a-92e2-246643ca1beb.xml b/EveryThing/Keys/key-e803459e-6187-453a-92e2-246643ca1beb.xml new file mode 100644 index 0000000..5535049 --- /dev/null +++ b/EveryThing/Keys/key-e803459e-6187-453a-92e2-246643ca1beb.xml @@ -0,0 +1,16 @@ + + + 2025-07-18T03:36:53.332167Z + 2025-07-18T03:36:53.2539748Z + 2025-10-16T03:36:53.2539748Z + + + + + + + dvPmRFK1RknKgQ74zgbcJgxSjN+LpaD4ch2GfGpz1CiTymQOdtOjD+wIv/dtG62IaBfeB5+By3/i3EpBCKtLHg== + + + + \ No newline at end of file diff --git a/EveryThing/Models/CodeTable/CodeTableItem.cs b/EveryThing/Models/CodeTable/CodeTableItem.cs index fbc80a9..833113e 100644 --- a/EveryThing/Models/CodeTable/CodeTableItem.cs +++ b/EveryThing/Models/CodeTable/CodeTableItem.cs @@ -27,7 +27,7 @@ namespace EveryThing.Models.CodeTable [Display(Name = "Naziv")] public string Title { get; set; } - [Display(Name = "Opis")] + [Display(Name = "Pot dokumentov")] public string Description { get; set; } [Required] diff --git a/EveryThing/Models/Invoice/Invoice.cs b/EveryThing/Models/Invoice/Invoice.cs index 95fe936..6a8f53f 100644 --- a/EveryThing/Models/Invoice/Invoice.cs +++ b/EveryThing/Models/Invoice/Invoice.cs @@ -12,7 +12,7 @@ namespace EveryThing.Models.Invoice { public class InvoiceStateAttribute : Attribute { - public string AllowedTypes { get; set; } = "0,1,2,3"; + public string AllowedTypes { get; set; } = "0,1,2,3,4"; } public enum InvoiceType @@ -25,6 +25,8 @@ namespace EveryThing.Models.Invoice DeliveryNote = 2, [Display(Name = "Naročilo kupca", ShortName = "Narocilo")] BuyersOrder = 3, + [Display(Name = "Kooperacija", ShortName = "Kooperacija")] + Cooperation = 4, } public enum InvoiceState diff --git a/EveryThing/Pages/CodeTableItems/AddEditItemModal.cshtml b/EveryThing/Pages/CodeTableItems/AddEditItemModal.cshtml index 18df8ef..013ebc2 100644 --- a/EveryThing/Pages/CodeTableItems/AddEditItemModal.cshtml +++ b/EveryThing/Pages/CodeTableItems/AddEditItemModal.cshtml @@ -37,6 +37,8 @@
Cena skupaj: @Model.TotalPrice  €
Prodajna cena: @Model.SellingPrice  €
Razlika: @Model.DifferenceInPricePercentage  % +
Material: @Model.Material   +
Dimenzije surovca: @Model.MaterialDimensions   @if (Model.Files != null && Model.Files.Count > 0) { diff --git a/EveryThing/Pages/CodeTableItems/Index.cshtml.cs b/EveryThing/Pages/CodeTableItems/Index.cshtml.cs index 67aab76..5633958 100644 --- a/EveryThing/Pages/CodeTableItems/Index.cshtml.cs +++ b/EveryThing/Pages/CodeTableItems/Index.cshtml.cs @@ -29,7 +29,8 @@ namespace EveryThing.Pages.CodeTableItems public string TotalPrice { get; set; } public string SellingPrice { get; set; } public string DifferenceInPricePercentage { get; set; } - + public string MaterialDimensions { get; set; } + public string Material { get; set; } } private readonly ApplicationDbContext _context; @@ -51,17 +52,29 @@ namespace EveryThing.Pages.CodeTableItems { var user = _userManager.GetUserAsync(User).Result; - ViewData["SearchString"] = searchString; + ViewData["SearchString"] = searchString ?? ""; + + var search = !string.IsNullOrEmpty(searchString); Item = await _context.CodeTableItems - .Where(x => x.IdCompanyFk == user.IdCompanyFk) - .Include(j => j.Company).ToListAsync(); + .Where(x => x.IdCompanyFk == user.IdCompanyFk + && EF.Functions.Like(x.Title, $"%{searchString}%") + || EF.Functions.Like(x.Description, $"%{searchString}%")) + .Include(j => j.Company).Take(100).ToListAsync(); - if (!string.IsNullOrEmpty(searchString)) - { - Item = Item.Where(s => s.Title.Contains(searchString, StringComparison.InvariantCultureIgnoreCase) - || (s.Description != null && s.Description.Contains(searchString, StringComparison.InvariantCultureIgnoreCase))).ToList(); - } + //Item = await _context.CodeTableItems + // .Where(x => x.IdCompanyFk == user.IdCompanyFk + // && (!search + // || EF.Functions.Like(x.Title, $"%{searchString}%") + // || (x.Description != null + // && EF.Functions.Like(x.Description, $"%{searchString}%")))) + // .Include(j => j.Company).Take(100).ToListAsync(); + + //if () + //{ + // Item = Item.Where(s => s.Title.Contains(searchString, StringComparison.InvariantCultureIgnoreCase) + // || (s.Description != null && s.Description.Contains(searchString, StringComparison.InvariantCultureIgnoreCase))).ToList(); + //} } @@ -75,6 +88,8 @@ namespace EveryThing.Pages.CodeTableItems var workPrice = 0d; var sellingPrice = 0d; var differenceInPricePercentage = 0d; + var materialDimensions = ""; + var material = ""; if (edit) { @@ -98,6 +113,7 @@ namespace EveryThing.Pages.CodeTableItems else { var projectPartItem = _context.ProjectPartItems + .Include(x => x.Material) .OrderByDescending(x => x.DateModified) .ThenByDescending(x => x.IdProjectPartItem) .FirstOrDefault(x => x.IdItemFk == item.IdItem); @@ -108,6 +124,8 @@ namespace EveryThing.Pages.CodeTableItems workPrice = projectPartItem.WorkPrice; sellingPrice = projectPartItem.SellingPrice; differenceInPricePercentage = projectPartItem.DifferenceInPricePercentage; + materialDimensions = projectPartItem.MaterialDimensions; + material = projectPartItem.Material.Title; } } @@ -122,7 +140,9 @@ namespace EveryThing.Pages.CodeTableItems SellingPrice = sellingPrice.ToString("#,###,##0.00", new CultureInfo("sl-SI")), TotalPrice = (materialPrice + workPrice).ToString("#,###,##0.00", new CultureInfo("sl-SI")), WorkPrice = workPrice.ToString("#,###,##0.00", new CultureInfo("sl-SI")), - DifferenceInPricePercentage = differenceInPricePercentage.ToString("#,###,##0.00", new CultureInfo("sl-SI")) + DifferenceInPricePercentage = differenceInPricePercentage.ToString("#,###,##0.00", new CultureInfo("sl-SI")), + MaterialDimensions = materialDimensions, + Material = material }); } diff --git a/EveryThing/Pages/CodeTablePartners/Index.cshtml.cs b/EveryThing/Pages/CodeTablePartners/Index.cshtml.cs index 404cccc..9abb880 100644 --- a/EveryThing/Pages/CodeTablePartners/Index.cshtml.cs +++ b/EveryThing/Pages/CodeTablePartners/Index.cshtml.cs @@ -1,16 +1,18 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Security.Cryptography.X509Certificates; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Identity; -using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.Mvc.RazorPages; -using Microsoft.EntityFrameworkCore; -using EveryThing.Data; +using EveryThing.Data; using EveryThing.Models; using EveryThing.Models.CodeTable; using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Identity; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.RazorPages; +using Microsoft.Data.SqlClient; +using Microsoft.EntityFrameworkCore; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Security.Cryptography.X509Certificates; +using System.Text; +using System.Threading.Tasks; namespace EveryThing.Pages.CodeTablePartners { @@ -49,5 +51,30 @@ namespace EveryThing.Pages.CodeTablePartners .ToList(); } } + + public IActionResult OnGetPartners(bool? suppliers) + { + var user = _userManager.GetUserAsync(User).Result; + + var successful = true; + var error = ""; + + var partners = _context.CodeTablePartners + .Where(x => x.IdCompanyFk == user.IdCompanyFk); + + if (suppliers != null) + partners = partners.Where(x => x.Supplier == suppliers); + + var sbJson = new StringBuilder(); + + foreach (var codeTablePartner in partners) + { + if (sbJson.Length > 0) + sbJson.Append(","); + sbJson.Append($"\"{codeTablePartner.IdPartner}\": \"{codeTablePartner.Title}\""); + } + + return new JsonResult(new { jsonPartners = $"{{{sbJson}}}", error = error, successful = successful }); + } } } diff --git a/EveryThing/Pages/Invoices/Create.cshtml b/EveryThing/Pages/Invoices/Create.cshtml index fd36652..c60a426 100644 --- a/EveryThing/Pages/Invoices/Create.cshtml +++ b/EveryThing/Pages/Invoices/Create.cshtml @@ -27,6 +27,9 @@ case 3: Naročila kupcev break; + case 4: + Kooperacije + break; default: Fakture break; diff --git a/EveryThing/Pages/Invoices/Edit.cshtml b/EveryThing/Pages/Invoices/Edit.cshtml index 83c73b0..4d52f9b 100644 --- a/EveryThing/Pages/Invoices/Edit.cshtml +++ b/EveryThing/Pages/Invoices/Edit.cshtml @@ -56,6 +56,9 @@ case 3: Naročila kupcev break; + case 4: + Kooperacije + break; default: Fakture break; @@ -145,6 +148,9 @@ case 3: Naročilo kupca break; + case 4: + Kooperacija + break; default: Faktura break; diff --git a/EveryThing/Pages/Invoices/Edit.cshtml.cs b/EveryThing/Pages/Invoices/Edit.cshtml.cs index 9c750cd..6e1b167 100644 --- a/EveryThing/Pages/Invoices/Edit.cshtml.cs +++ b/EveryThing/Pages/Invoices/Edit.cshtml.cs @@ -13,6 +13,7 @@ using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Authorization; using EveryThing.Models.Project; using System.Text.Json; +using EveryThing.Models.Invoice; using static EveryThing.Pages.Projects.EditModel; namespace EveryThing.Pages.Invoices @@ -106,10 +107,26 @@ namespace EveryThing.Pages.Invoices return Page(); } + //var oldInvoice = _context.Invoices.FirstOrDefault(x => x.IdInvoice == Invoice.IdInvoice); + + var statusChanged = true;//oldInvoice == null || oldInvoice.State != Invoice.State; + Invoice.PostText = Invoice.PostText.Replace("

", ""); Invoice.PreText = Invoice.PreText.Replace("

", ""); _context.Attach(Invoice).State = EntityState.Modified; + + if (Invoice.Type == Invoice.InvoiceType.Cooperation + && statusChanged + && Invoice.State == Invoice.InvoiceState.Closed) + { + await _context.InvoiceItems + .Where(x => x.IdInvoiceFk == Invoice.IdInvoice) + .Include(invoiceItem => invoiceItem.ProjectPartItem).ForEachAsync(x => + { + x.ProjectPartItem.Status = ProjectPartItemStatus.Finished; + }); + } try { diff --git a/EveryThing/Pages/Invoices/Index.cshtml b/EveryThing/Pages/Invoices/Index.cshtml index e5f8f3f..855dc2e 100644 --- a/EveryThing/Pages/Invoices/Index.cshtml +++ b/EveryThing/Pages/Invoices/Index.cshtml @@ -23,6 +23,9 @@ case 3: Naročila kupcev break; + case 4: + Kooperacije + break; default: Fakture break; @@ -127,7 +130,27 @@ @Html.AntiForgeryToken() diff --git a/EveryThing/Pages/Invoices/Print.cshtml b/EveryThing/Pages/Invoices/Print.cshtml index ad65f48..9ff57fe 100644 --- a/EveryThing/Pages/Invoices/Print.cshtml +++ b/EveryThing/Pages/Invoices/Print.cshtml @@ -50,6 +50,9 @@ case 3: Naročila kupcev break; + case 4: + Kooperacija + break; default: Fakture break; diff --git a/EveryThing/Pages/Invoices/Print.cshtml.cs b/EveryThing/Pages/Invoices/Print.cshtml.cs index 0466f85..3964352 100644 --- a/EveryThing/Pages/Invoices/Print.cshtml.cs +++ b/EveryThing/Pages/Invoices/Print.cshtml.cs @@ -172,6 +172,9 @@ namespace EveryThing.Pages.Invoices case Invoice.InvoiceType.DeliveryNote: Translation.InvoiceType = "Dobavnica"; break; + case Invoice.InvoiceType.Cooperation: + Translation.InvoiceType = "Kooperacija"; + break; default: Translation.InvoiceType = "Faktura"; break; @@ -231,6 +234,9 @@ namespace EveryThing.Pages.Invoices case Invoice.InvoiceType.DeliveryNote: Translation.InvoiceType = "Lieferschein"; break; + case Invoice.InvoiceType.Cooperation: + Translation.InvoiceType = "Zusammenarbeit"; + break; default: Translation.InvoiceType = "Faktura"; break; diff --git a/EveryThing/Pages/Layouts/Partials/_LayoutSidenav.cshtml b/EveryThing/Pages/Layouts/Partials/_LayoutSidenav.cshtml index a3d718a..6af2429 100644 --- a/EveryThing/Pages/Layouts/Partials/_LayoutSidenav.cshtml +++ b/EveryThing/Pages/Layouts/Partials/_LayoutSidenav.cshtml @@ -70,6 +70,9 @@
  • Dobavnice
  • +
  • +
    Kooperacije
    +
  • } @*
  • Planiranje
    diff --git a/EveryThing/Pages/Projects/Edit.cshtml b/EveryThing/Pages/Projects/Edit.cshtml index 3602752..923e5e9 100644 --- a/EveryThing/Pages/Projects/Edit.cshtml +++ b/EveryThing/Pages/Projects/Edit.cshtml @@ -164,6 +164,9 @@
  • +
    @@ -464,36 +467,99 @@
    - - - - - + + + + + - @foreach (var file in Model.FilesProjectParts) - { - - - - - - } + @foreach (var file in Model.FilesProjectParts) + { + + + + + + }
    - Naziv - - Datum -
    + Naziv + + Datum +
    - @Html.DisplayFor(modelItem => file.Title) - - @Html.DisplayFor(x => file.DateOfUpload) - - - -
    + @Html.DisplayFor(modelItem => file.Title) + + @Html.DisplayFor(x => file.DateOfUpload) + + + +
    +
    +
    + + + + + + + + + + + + + @foreach (var invoice in Model.Invoices.Where(x => x.Type == Invoice.InvoiceType.Cooperation)) + { + x.ProjectPartItem.IdProjectPartFk))"> + + + + + + + + } + +
    + # + + Partner + + Datum + + Datum odpreme + + Status + Pokaži vse
    + @Html.DisplayFor(modelItem => invoice.InvoiceYear) - @Html.DisplayFor(modelItem => invoice.InvoiceNumber) + + @Html.DisplayFor(x => invoice.Partner.Title) + + @Html.DisplayFor(x => invoice.Date) + + @Html.DisplayFor(x => invoice.DateOfDispatch) + + @switch (invoice.State) + { + case Models.Invoice.Invoice.InvoiceState.Closed: + @Html.DisplayFor(modelItem => invoice.State) + break; + case Models.Invoice.Invoice.InvoiceState.Confirmed: + @Html.DisplayFor(modelItem => invoice.State) + break; + default: + @Html.DisplayFor(modelItem => invoice.State) + break; + } + + + +
    +
    +
    @@ -663,8 +729,9 @@