Uvoz, ce je vec projektov da je scroll bar

This commit is contained in:
2026-02-03 19:07:52 +01:00
parent 980d3ff161
commit 7d64e423c3
14 changed files with 213 additions and 173 deletions

View File

@@ -7,6 +7,13 @@
Layout = "~/Pages/Layouts/_Layout.cshtml"; Layout = "~/Pages/Layouts/_Layout.cshtml";
} }
@section Styles
{
<style type="text/css">
</style>
}
<h4 class="d-flex justify-content-between align-items-center w-100 font-weight-bold py-1 mb-4"> <h4 class="d-flex justify-content-between align-items-center w-100 font-weight-bold py-1 mb-4">
<span> <span>
<span class="text-muted font-weight-light">@switch (@ViewData["Type"]) <span class="text-muted font-weight-light">@switch (@ViewData["Type"])
@@ -21,7 +28,7 @@
<i>Dobavnice</i> <i>Dobavnice</i>
break; break;
case 3: case 3:
<i>Naročila kupcev</i> <i>Naročila ponudbe/kupcev</i>
break; break;
case 4: case 4:
<i>Kooperacije</i> <i>Kooperacije</i>
@@ -34,100 +41,101 @@
</span> </span>
</h4> </h4>
<div class="row">
<div class="col-12 mb-2 text-right">
<form method="get">
<input type="hidden" asp-for="@ViewData["Type"]" name="type"/>
<div class="btn-group">
<input class="form-control" type="text" name="searchString" value="@ViewData["SearchString"]" placeholder="Iskanje..." autocomplete="off">
<button type="submit" class="btn btn-secondary" aria-label="Osveži" title="Osveži" asp-route-type="@ViewData["Type"]">
<i class="opacity-75 ion ion-md-refresh"></i>
</button>
<div class="btn-group" title="Columns">
<button class="btn btn-secondary dropdown-toggle" type="button" data-toggle="dropdown" aria-label="Nastavitve" title="Nastavitve">
<i class="opacity-75 ion ion-md-apps"></i>
<span class="caret"></span>
</button>
<div class="dropdown-menu dropdown-menu-right">
<label class="dropdown-item">
<input type="checkbox" name="finishedProjects" @ViewData["FinishedProjects"]> <span>Zaprte fakture</span>
</label>
</div>
</div>
</div>
</form>
</div>
</div>
<div class="card"> <div class="card">
<div class="card-header">
<div class="row">
<table class="table card-table table-hover"> <div class="col-12 mb-2 text-right">
<form method="get">
<input type="hidden" asp-for="@ViewData["Type"]" name="type"/>
<div class="btn-group">
<input class="form-control" type="text" name="searchString" value="@ViewData["SearchString"]" placeholder="Iskanje..." autocomplete="off">
<button type="submit" class="btn btn-secondary" aria-label="Osveži" title="Osveži" asp-route-type="@ViewData["Type"]">
<i class="opacity-75 ion ion-md-refresh"></i>
</button>
<div class="btn-group" title="Columns">
<button class="btn btn-secondary dropdown-toggle" type="button" data-toggle="dropdown" aria-label="Nastavitve" title="Nastavitve">
<i class="opacity-75 ion ion-md-apps"></i>
<span class="caret"></span>
</button>
<div class="dropdown-menu dropdown-menu-right">
<label class="dropdown-item">
<input type="checkbox" name="finishedProjects" @ViewData["FinishedProjects"]> <span>Zaprte fakture</span>
</label>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
<div class="card-body" style="max-height:65vh; overflow-y:auto;">
<table class="table card-table table-hover custom-table">
<thead> <thead>
<tr> <tr>
<th style="width: 200px;">#</th> <th style="width: 200px;">#</th>
<th style="width: auto;"> <th style="width: auto;">
@Html.DisplayNameFor(invoice => invoice.Invoice[0].IdPartnerFk) @Html.DisplayNameFor(invoice => invoice.Invoice[0].IdPartnerFk)
</th> </th>
<th style="width: 100px;"> <th style="width: 100px;">
@Html.DisplayNameFor(invoice => invoice.Invoice[0].Date) @Html.DisplayNameFor(invoice => invoice.Invoice[0].Date)
</th> </th>
<th style="width: 100px">
@Html.DisplayNameFor(invoice => invoice.Invoice[0].State)
</th>
@if (Model.ShowProjects)
{
<th style="width: 100px"> <th style="width: 100px">
@Html.DisplayNameFor(invoice => invoice.Invoice[0].State) Projekti
</th> </th>
@if (Model.ShowProjects) }
{ <th style="width: 140px;"></th>
<th style="width: 100px"> </tr>
Projekti
</th>
}
<th style="width: 140px;"></th>
</tr>
</thead> </thead>
<tbody> <tbody>
@foreach (var item in Model.Invoice) @foreach (var item in Model.Invoice)
{ {
<tr data-idinvoice="@item.IdInvoice" data-number="@item.InvoiceNumberFormatted"> <tr data-idinvoice="@item.IdInvoice" data-number="@item.InvoiceNumberFormatted">
<td>@Html.DisplayFor(modelItem => item.InvoiceNumberFormatted)</td> <td>@Html.DisplayFor(modelItem => item.InvoiceNumberFormatted)</td>
<td>
@Html.DisplayFor(modelItem => item.Partner.Title)
</td>
<td>
@Html.DisplayFor(modelItem => item.Date)
</td>
<td>
@switch (item.State)
{
case Invoice.InvoiceState.Closed:
<span class='badge badge-success'>@Html.DisplayFor(modelItem => item.State)</span>
break;
case Invoice.InvoiceState.Confirmed:
<span class='badge badge-warning'>@Html.DisplayFor(modelItem => item.State)</span>
break;
default:
<span class='badge badge-info'>@Html.DisplayFor(modelItem => item.State)</span>
break;
}
</td>
@if (Model.ShowProjects)
{
<td> <td>
@Html.DisplayFor(modelItem => item.Partner.Title) @if (item.InvoiceInvoiceItem.FirstOrDefault() != null)
</td>
<td>
@Html.DisplayFor(modelItem => item.Date)
</td>
<td>
@switch (item.State)
{ {
case Invoice.InvoiceState.Closed: <a asp-page="/Projects/Edit" asp-route-id="@item.InvoiceInvoiceItem.FirstOrDefault()?.ProjectPartItem?.ProjectPart?.Project?.IdProject">@string.Join(" ", item.InvoiceInvoiceItem.Select(x => x.ProjectPartItem?.ProjectPart?.Project?.ProjectNumberFormatted).Distinct())</a>
<span class='badge badge-success'>@Html.DisplayFor(modelItem => item.State)</span>
break;
case Invoice.InvoiceState.Confirmed:
<span class='badge badge-warning'>@Html.DisplayFor(modelItem => item.State)</span>
break;
default:
<span class='badge badge-info'>@Html.DisplayFor(modelItem => item.State)</span>
break;
} }
</td> </td>
@if (Model.ShowProjects) }
{ <td class="text-right">
<td> <a class="btn btn-xs icon-btn btn-outline-success borderless" href='javascript:;' onclick="generateExcel(this)" data-toggle="tooltip" data-placement="left" title="Izvozi pozicije v .xlsx format" data-state="success"><i class="far fa-file-excel"></i></a>
@if (item.InvoiceInvoiceItem.FirstOrDefault() != null) <a class="btn btn-xs icon-btn btn-outline-primary borderless" asp-page="/Invoices/Print" asp-route-id="@item.IdInvoice" data-toggle="tooltip" data-placement="top" title="Tiskanje" data-state="primary"><i class="ion ion-md-print"></i></a>
{ <a class="btn btn-xs icon-btn btn-outline-secondary borderless" asp-page="Edit" asp-route-id="@item.IdInvoice" data-toggle="tooltip" data-placement="top" title="Urejanje" data-state="secondary"><i class="fas fa-pencil-alt"></i></a>
<a asp-page="/Projects/Edit" asp-route-id="@item.InvoiceInvoiceItem.FirstOrDefault()?.ProjectPartItem?.ProjectPart?.Project?.IdProject">@string.Join(" ", item.InvoiceInvoiceItem.Select(x => x.ProjectPartItem?.ProjectPart?.Project?.ProjectNumberFormatted).Distinct())</a> <a class="btn btn-xs icon-btn btn-outline-danger borderless" data-state="danger" href='javascript:;' onclick="deleteInvoice(this)"><i class="fas fa-times"></i></a>
} </td>
</td> </tr>
} }
<td class="text-right">
<a class="btn btn-xs icon-btn btn-outline-success borderless" href='javascript:;' onclick="generateExcel(this)" data-toggle="tooltip" data-placement="left" title="Izvozi pozicije v .xlsx format" data-state="success"><i class="far fa-file-excel"></i></a>
<a class="btn btn-xs icon-btn btn-outline-primary borderless" asp-page="/Invoices/Print" asp-route-id="@item.IdInvoice" data-toggle="tooltip" data-placement="top" title="Tiskanje" data-state="primary"><i class="ion ion-md-print"></i></a>
<a class="btn btn-xs icon-btn btn-outline-secondary borderless" asp-page="Edit" asp-route-id="@item.IdInvoice" data-toggle="tooltip" data-placement="top" title="Urejanje" data-state="secondary"><i class="fas fa-pencil-alt"></i></a>
<a class="btn btn-xs icon-btn btn-outline-danger borderless" data-state="danger" href='javascript:;' onclick="deleteInvoice(this)"><i class="fas fa-times"></i></a>
</td>
</tr>
}
</tbody> </tbody>
</table> </table>
</div>
<div class="card-footer py-3 text-right"> <div class="card-footer py-3 text-right">
<a asp-page="Create" asp-route-type="@ViewData["Type"]" class="btn btn-primary">@switch (@ViewData["Type"]) <a asp-page="Create" asp-route-type="@ViewData["Type"]" class="btn btn-primary">@switch (@ViewData["Type"])

View File

@@ -19,7 +19,7 @@
<div class="col-6"> <div class="col-6">
<div class="card"> <div class="card">
<h6 class="card-header"> <h6 class="card-header">
Povezovanje excel z pozicijo Povezovanje @Model.FileName z pozicijo
</h6> </h6>
<div class="card-body"> <div class="card-body">
<input type="hidden" asp-for="IdProjectPart" /> <input type="hidden" asp-for="IdProjectPart" />
@@ -31,10 +31,10 @@
@{ @{
foreach (var item in Model.ExcelItems) foreach (var item in Model.ExcelItems)
{ {
<div class="form-group"> <div class="form-group">
<label class="control-label">@item.Name</label> <label class="control-label">@item.Name</label>
<select data-index="@item.CellIndex" class="form-control select-item" asp-items="ViewBag.ProjectPartItems"></select> <select data-index="@item.CellIndex" class="form-control select-item" asp-items="ViewBag.ProjectPartItems"></select>
</div> </div>
} }
} }
</div> </div>

View File

@@ -47,6 +47,7 @@ namespace EveryThing.Pages.Projects
[BindProperty] [BindProperty]
public string SelectedItems { get; set; } public string SelectedItems { get; set; }
public IActionResult OnGet(int idProject, int idProjectPart, string fileName) public IActionResult OnGet(int idProject, int idProjectPart, string fileName)
{ {
var user = _userManager.GetUserAsync(User).Result; var user = _userManager.GetUserAsync(User).Result;
@@ -67,9 +68,9 @@ namespace EveryThing.Pages.Projects
ViewData["ProjectPartItems"] = new SelectList(tmpList, "Name", "Display"); ViewData["ProjectPartItems"] = new SelectList(tmpList, "Name", "Display");
ExcelItems = new List<ExcelItem>(); ExcelItems = new List<ExcelItem>();
string path = Path.Combine(_hostingEnvironment.WebRootPath, "Uploads"); var path = Path.Combine(_hostingEnvironment.WebRootPath, "Uploads", "TempExcelImport", fileName);
var xlWorkbook = new XLWorkbook(Path.Combine(path, fileName)); var xlWorkbook = new XLWorkbook(path);
//ONLY FIRST LIST //ONLY FIRST LIST
var worksheet = xlWorkbook.Worksheet(1); var worksheet = xlWorkbook.Worksheet(1);
@@ -120,9 +121,9 @@ namespace EveryThing.Pages.Projects
}); });
} }
string path = Path.Combine(_hostingEnvironment.WebRootPath, "Uploads"); var path = Path.Combine(_hostingEnvironment.WebRootPath, "Uploads", "TempExcelImport", FileName);
var xlWorkbook = new XLWorkbook(Path.Combine(path, FileName)); var xlWorkbook = new XLWorkbook(path);
//ONLY FIRST LIST //ONLY FIRST LIST
var worksheet = xlWorkbook.Worksheet(1); var worksheet = xlWorkbook.Worksheet(1);
@@ -157,8 +158,7 @@ namespace EveryThing.Pages.Projects
string value = row.Cell(excelItem.CellIndex).Value.ToString(); string value = row.Cell(excelItem.CellIndex).Value.ToString();
if (excelItem.Name == "IdItemFk" if (excelItem.Name is "IdItemFk" or "IdMaterialFk")
|| excelItem.Name == "IdMaterialFk")
{ {
var completableItem = _context.CodeTableItems.FirstOrDefault(x => x.Title == value && x.Active == true); var completableItem = _context.CodeTableItems.FirstOrDefault(x => x.Title == value && x.Active == true);
if (completableItem == null) if (completableItem == null)
@@ -178,7 +178,32 @@ namespace EveryThing.Pages.Projects
newPosition.IdItemFk = completableItem.IdItem; newPosition.IdItemFk = completableItem.IdItem;
else else
newPosition.IdMaterialFk = completableItem.IdItem; newPosition.IdMaterialFk = completableItem.IdItem;
} }
else if (excelItem.Name is "IdMaterialSupplierFk")
{
var tmpPartner = _context.CodeTablePartners.FirstOrDefault(x => x.Title == value && x.Active == true);
if (tmpPartner == null)
{
//Add new if not exists
tmpPartner = new CodeTablePartner()
{
Active = true,
IdCompanyFk = user.IdCompanyFk,
Title = value,
Supplier = true,
IdCountryFk = _context.CodeTableCountries.First(x => x.Code == "SI").IdCountry,
City = "",
Street = "",
HouseNumber = "",
PostNumber = 0,
Post = "",
};
_context.CodeTablePartners.Add(tmpPartner);
await _context.SaveChangesAsync();
}
newPosition.IdMaterialSupplierFk = tmpPartner.IdPartner;
}
else else
{ {
var propertyInfo = newPosition.GetType().GetProperties().First(x => x.Name == excelItem.Name); var propertyInfo = newPosition.GetType().GetProperties().First(x => x.Name == excelItem.Name);
@@ -190,7 +215,8 @@ namespace EveryThing.Pages.Projects
await _context.SaveChangesAsync(); await _context.SaveChangesAsync();
i++; i++;
} }
System.IO.File.Delete(path);
return RedirectToPage("./Edit", new {id = IdProject}); return RedirectToPage("./Edit", new {id = IdProject});
} }

View File

@@ -104,21 +104,26 @@ namespace EveryThing.Pages.Projects
{ {
return Page();//TODO return error return Page();//TODO return error
} }
string path = Path.Combine(_hostingEnvironment.WebRootPath, "Uploads"); var path = Path.Combine(_hostingEnvironment.WebRootPath, "Uploads", "TempExcelImport");
if (!Directory.Exists(path)) if (!Directory.Exists(path))
{ {
Directory.CreateDirectory(path); Directory.CreateDirectory(path);
} }
else
List<string> uploadedFiles = new List<string>(); {
//Pocistimo mapo
foreach (var fileInfo in new DirectoryInfo(path).GetFiles("*.*"))
{
fileInfo.Delete();
}
}
var postedFile = postedFiles[0]; var postedFile = postedFiles[0];
string fileName = Guid.NewGuid().ToString().Replace("-", "_") + Path.GetExtension(postedFile.FileName); var fileName = postedFile.FileName;//Guid.NewGuid().ToString().Replace("-", "_") + Path.GetExtension(postedFile.FileName);
using (FileStream stream = new FileStream(Path.Combine(path, fileName), FileMode.Create)) await using (var stream = new FileStream(Path.Combine(path, fileName), FileMode.Create))
{ {
postedFile.CopyTo(stream); await postedFile.CopyToAsync(stream);
uploadedFiles.Add(fileName);
} }
return RedirectToPage("./CreatePartItemImportExcel", new { idProject = idProject, idProjectPart = idProjectPart, fileName = fileName}); return RedirectToPage("./CreatePartItemImportExcel", new { idProject = idProject, idProjectPart = idProjectPart, fileName = fileName});
} }

View File

@@ -48,80 +48,81 @@
</div> </div>
<div class="card"> <div class="card">
<h6 class="card-header"> <h6 class="card-header">
Seznam projektov Seznam projektov
</h6> </h6>
<table class="table card-table table-hover"> <div class="card-body" style="max-height:65vh; overflow-y:auto;">
<thead> <table class="table card-table table-hover">
<tr> <thead>
<th style="width: 150px;"> <tr>
@Html.DisplayNameFor(model => model.Project[0].ProjectNumberFormatted) <th style="width: 150px;">
</th> @Html.DisplayNameFor(model => model.Project[0].ProjectNumberFormatted)
<th style="width: 200px;"> </th>
@Html.DisplayNameFor(model => model.Project[0].Title) <th style="width: 200px;">
</th> @Html.DisplayNameFor(model => model.Project[0].Title)
<th> </th>
@Html.DisplayNameFor(model => model.Project[0].IdPartnerFk) <th>
</th> @Html.DisplayNameFor(model => model.Project[0].IdPartnerFk)
<th> </th>
@Html.DisplayNameFor(model => model.Project[0].Description) <th>
</th> @Html.DisplayNameFor(model => model.Project[0].Description)
<th style="width: 140px"> </th>
@Html.DisplayNameFor(model => model.Project[0].FirstDeliveryDateString) <th style="width: 140px">
</th> @Html.DisplayNameFor(model => model.Project[0].FirstDeliveryDateString)
<th style="width: 100px"> </th>
@Html.DisplayNameFor(model => model.Project[0].Status) <th style="width: 100px">
</th> @Html.DisplayNameFor(model => model.Project[0].Status)
<th style="width: 110px;"></th> </th>
</tr> <th style="width: 110px;"></th>
</thead>
<tbody>
@foreach (var item in Model.Project)
{
<tr data-idproject="@item.IdProject" data-title="@item.Title">
<td>
@Html.DisplayFor(modelItem => item.ProjectNumberFormatted)
</td>
<td>
<a asp-page="Edit" asp-route-id="@item.IdProject">@Html.DisplayFor(modelItem => item.Title)</a>
</td>
<td>
@Html.DisplayFor(modelItem => item.Partner.Title)
</td>
<td>
@Html.DisplayFor(modelItem => item.Description)
</td>
<td>
@Html.DisplayFor(modelItem => item.FirstDeliveryDateString)
</td>
<td>
@switch (item.Status)
{
case ProjectStatus.Finished:
<span class='badge badge-success'>@Html.DisplayFor(modelItem => item.Status)</span>
break;
case ProjectStatus.InProduction:
<span class='badge badge-warning'>@Html.DisplayFor(modelItem => item.Status)</span>
break;
case ProjectStatus.Offer:
<span class='badge badge-default'>@Html.DisplayFor(modelItem => item.Status)</span>
break;
default:
<span class='badge badge-info'>@Html.DisplayFor(modelItem => item.Status)</span>
break;
}
</td>
<td class="text-right">
<a class="btn btn-xs icon-btn btn-outline-secondary borderless" asp-page="Edit" asp-route-id="@item.IdProject" data-toggle="tooltip" data-placement="top" title="Urejanje" data-state="secondary"><i class="fas fa-pencil-alt"></i></a>
<a data-idproject="@item.IdProject" class="btn btn-xs icon-btn btn-outline-secondary borderless" data-toggle="tooltip" data-placement="top" title="Kopiraj projekt" data-state="secondary" href="javascript:;" onclick="copyProject(this);"><i class="far fa-copy"></i></a>
<a class="btn btn-xs icon-btn btn-outline-danger borderless" data-state="danger" href='javascript:;' onclick="deleteProject(this)" data-toggle="tooltip" data-placement="top" title="Izbriši"><i class="fas fa-times"></i></a>
</td>
</tr> </tr>
} </thead>
</tbody> <tbody>
</table> @foreach (var item in Model.Project)
{
<tr data-idproject="@item.IdProject" data-title="@item.Title">
<td>
@Html.DisplayFor(modelItem => item.ProjectNumberFormatted)
</td>
<td>
<a asp-page="Edit" asp-route-id="@item.IdProject">@Html.DisplayFor(modelItem => item.Title)</a>
</td>
<td>
@Html.DisplayFor(modelItem => item.Partner.Title)
</td>
<td>
@Html.DisplayFor(modelItem => item.Description)
</td>
<td>
@Html.DisplayFor(modelItem => item.FirstDeliveryDateString)
</td>
<td>
@switch (item.Status)
{
case ProjectStatus.Finished:
<span class='badge badge-success'>@Html.DisplayFor(modelItem => item.Status)</span>
break;
case ProjectStatus.InProduction:
<span class='badge badge-warning'>@Html.DisplayFor(modelItem => item.Status)</span>
break;
case ProjectStatus.Offer:
<span class='badge badge-default'>@Html.DisplayFor(modelItem => item.Status)</span>
break;
default:
<span class='badge badge-info'>@Html.DisplayFor(modelItem => item.Status)</span>
break;
}
</td>
<td class="text-right">
<a class="btn btn-xs icon-btn btn-outline-secondary borderless" asp-page="Edit" asp-route-id="@item.IdProject" data-toggle="tooltip" data-placement="top" title="Urejanje" data-state="secondary"><i class="fas fa-pencil-alt"></i></a>
<a data-idproject="@item.IdProject" class="btn btn-xs icon-btn btn-outline-secondary borderless" data-toggle="tooltip" data-placement="top" title="Kopiraj projekt" data-state="secondary" href="javascript:;" onclick="copyProject(this);"><i class="far fa-copy"></i></a>
<a class="btn btn-xs icon-btn btn-outline-danger borderless" data-state="danger" href='javascript:;' onclick="deleteProject(this)" data-toggle="tooltip" data-placement="top" title="Izbriši"><i class="fas fa-times"></i></a>
</td>
</tr>
}
</tbody>
</table>
</div>
<div class="card-footer py-3 text-right"> <div class="card-footer py-3 text-right">
<a asp-page="Create" class="btn btn-primary">Vnos projekta</a> <a asp-page="Create" class="btn btn-primary">Vnos projekta</a>