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";
}
@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">
<span>
<span class="text-muted font-weight-light">@switch (@ViewData["Type"])
@@ -21,7 +28,7 @@
<i>Dobavnice</i>
break;
case 3:
<i>Naročila kupcev</i>
<i>Naročila ponudbe/kupcev</i>
break;
case 4:
<i>Kooperacije</i>
@@ -34,100 +41,101 @@
</span>
</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">
<table class="table card-table table-hover">
<div class="card-header">
<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>
<div class="card-body" style="max-height:65vh; overflow-y:auto;">
<table class="table card-table table-hover custom-table">
<thead>
<tr>
<th style="width: 200px;">#</th>
<th style="width: auto;">
@Html.DisplayNameFor(invoice => invoice.Invoice[0].IdPartnerFk)
</th>
<th style="width: 100px;">
@Html.DisplayNameFor(invoice => invoice.Invoice[0].Date)
</th>
<tr>
<th style="width: 200px;">#</th>
<th style="width: auto;">
@Html.DisplayNameFor(invoice => invoice.Invoice[0].IdPartnerFk)
</th>
<th style="width: 100px;">
@Html.DisplayNameFor(invoice => invoice.Invoice[0].Date)
</th>
<th style="width: 100px">
@Html.DisplayNameFor(invoice => invoice.Invoice[0].State)
</th>
@if (Model.ShowProjects)
{
<th style="width: 100px">
@Html.DisplayNameFor(invoice => invoice.Invoice[0].State)
Projekti
</th>
@if (Model.ShowProjects)
{
<th style="width: 100px">
Projekti
</th>
}
<th style="width: 140px;"></th>
</tr>
}
<th style="width: 140px;"></th>
</tr>
</thead>
<tbody>
@foreach (var item in Model.Invoice)
{
<tr data-idinvoice="@item.IdInvoice" data-number="@item.InvoiceNumberFormatted">
<td>@Html.DisplayFor(modelItem => item.InvoiceNumberFormatted)</td>
@foreach (var item in Model.Invoice)
{
<tr data-idinvoice="@item.IdInvoice" data-number="@item.InvoiceNumberFormatted">
<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>
@Html.DisplayFor(modelItem => item.Partner.Title)
</td>
<td>
@Html.DisplayFor(modelItem => item.Date)
</td>
<td>
@switch (item.State)
@if (item.InvoiceInvoiceItem.FirstOrDefault() != null)
{
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;
<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>
}
</td>
@if (Model.ShowProjects)
{
<td>
@if (item.InvoiceInvoiceItem.FirstOrDefault() != null)
{
<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>
}
</td>
}
<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>
}
}
<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>
</table>
</div>
<div class="card-footer py-3 text-right">
<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="card">
<h6 class="card-header">
Povezovanje excel z pozicijo
Povezovanje @Model.FileName z pozicijo
</h6>
<div class="card-body">
<input type="hidden" asp-for="IdProjectPart" />
@@ -31,10 +31,10 @@
@{
foreach (var item in Model.ExcelItems)
{
<div class="form-group">
<label class="control-label">@item.Name</label>
<select data-index="@item.CellIndex" class="form-control select-item" asp-items="ViewBag.ProjectPartItems"></select>
</div>
<div class="form-group">
<label class="control-label">@item.Name</label>
<select data-index="@item.CellIndex" class="form-control select-item" asp-items="ViewBag.ProjectPartItems"></select>
</div>
}
}
</div>

View File

@@ -47,6 +47,7 @@ namespace EveryThing.Pages.Projects
[BindProperty]
public string SelectedItems { get; set; }
public IActionResult OnGet(int idProject, int idProjectPart, string fileName)
{
var user = _userManager.GetUserAsync(User).Result;
@@ -67,9 +68,9 @@ namespace EveryThing.Pages.Projects
ViewData["ProjectPartItems"] = new SelectList(tmpList, "Name", "Display");
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
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
var worksheet = xlWorkbook.Worksheet(1);
@@ -157,8 +158,7 @@ namespace EveryThing.Pages.Projects
string value = row.Cell(excelItem.CellIndex).Value.ToString();
if (excelItem.Name == "IdItemFk"
|| excelItem.Name == "IdMaterialFk")
if (excelItem.Name is "IdItemFk" or "IdMaterialFk")
{
var completableItem = _context.CodeTableItems.FirstOrDefault(x => x.Title == value && x.Active == true);
if (completableItem == null)
@@ -179,6 +179,31 @@ namespace EveryThing.Pages.Projects
else
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
{
var propertyInfo = newPosition.GetType().GetProperties().First(x => x.Name == excelItem.Name);
@@ -191,6 +216,7 @@ namespace EveryThing.Pages.Projects
i++;
}
System.IO.File.Delete(path);
return RedirectToPage("./Edit", new {id = IdProject});
}

View File

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

View File

@@ -48,80 +48,81 @@
</div>
<div class="card">
<h6 class="card-header">
Seznam projektov
</h6>
<table class="table card-table table-hover">
<thead>
<tr>
<th style="width: 150px;">
@Html.DisplayNameFor(model => model.Project[0].ProjectNumberFormatted)
</th>
<th style="width: 200px;">
@Html.DisplayNameFor(model => model.Project[0].Title)
</th>
<th>
@Html.DisplayNameFor(model => model.Project[0].IdPartnerFk)
</th>
<th>
@Html.DisplayNameFor(model => model.Project[0].Description)
</th>
<th style="width: 140px">
@Html.DisplayNameFor(model => model.Project[0].FirstDeliveryDateString)
</th>
<th style="width: 100px">
@Html.DisplayNameFor(model => model.Project[0].Status)
</th>
<th style="width: 110px;"></th>
</tr>
</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>
<div class="card-body" style="max-height:65vh; overflow-y:auto;">
<table class="table card-table table-hover">
<thead>
<tr>
<th style="width: 150px;">
@Html.DisplayNameFor(model => model.Project[0].ProjectNumberFormatted)
</th>
<th style="width: 200px;">
@Html.DisplayNameFor(model => model.Project[0].Title)
</th>
<th>
@Html.DisplayNameFor(model => model.Project[0].IdPartnerFk)
</th>
<th>
@Html.DisplayNameFor(model => model.Project[0].Description)
</th>
<th style="width: 140px">
@Html.DisplayNameFor(model => model.Project[0].FirstDeliveryDateString)
</th>
<th style="width: 100px">
@Html.DisplayNameFor(model => model.Project[0].Status)
</th>
<th style="width: 110px;"></th>
</tr>
}
</tbody>
</table>
</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>
}
</tbody>
</table>
</div>
<div class="card-footer py-3 text-right">
<a asp-page="Create" class="btn btn-primary">Vnos projekta</a>