This commit is contained in:
@@ -165,17 +165,22 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-footer py-3 text-right">
|
||||
@if (ViewData["Edit"] != null && (bool)ViewData["Edit"])
|
||||
{
|
||||
<button type="submit" class="btn btn-primary">Shrani</button>
|
||||
}
|
||||
else
|
||||
{
|
||||
<button type="submit" class="btn btn-primary">Dodaj pozicijo dela projekta</button>
|
||||
}
|
||||
<div class="card-footer py-3 d-flex justify-content-between">
|
||||
<div>
|
||||
<a class="btn btn-outline-primary" asp-page="PrintPartItem" asp-route-id="@Model.ProjectPartItem.IdProjectPartItem" data-toggle="tooltip" data-placement="top" title="Tiskanje" data-state="primary"><i class="ion ion-md-print"></i> Natisni</a>
|
||||
</div>
|
||||
<div>
|
||||
@if (ViewData["Edit"] != null && (bool)ViewData["Edit"])
|
||||
{
|
||||
<button type="submit" class="btn btn-primary">Shrani</button>
|
||||
}
|
||||
else
|
||||
{
|
||||
<button type="submit" class="btn btn-primary">Dodaj pozicijo dela projekta</button>
|
||||
}
|
||||
|
||||
<a asp-page="Edit" asp-route-id="@ViewBag.IdProject" class="btn btn-default">Prekliči</a>
|
||||
<a asp-page="Edit" asp-route-id="@ViewBag.IdProject" class="btn btn-default">Prekliči</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
209
EveryThing/Pages/Projects/PrintPartItem.cshtml
Normal file
209
EveryThing/Pages/Projects/PrintPartItem.cshtml
Normal file
@@ -0,0 +1,209 @@
|
||||
@page
|
||||
@using System.Web
|
||||
@using EveryThing.Models.Invoice
|
||||
@using Org.BouncyCastle.Asn1
|
||||
@model EveryThing.Pages.Projects.PrintPartItem
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Izpis";
|
||||
Layout = "~/Pages/Layouts/_Layout.cshtml";
|
||||
}
|
||||
|
||||
<style type="text/css">
|
||||
table {
|
||||
page-break-inside: auto;
|
||||
color: black !important;
|
||||
}
|
||||
|
||||
tr {
|
||||
page-break-inside: avoid;
|
||||
page-break-after: auto
|
||||
}
|
||||
|
||||
thead {
|
||||
display: table-header-group
|
||||
}
|
||||
|
||||
tfoot {
|
||||
display: table-footer-group
|
||||
}
|
||||
|
||||
body {
|
||||
color: black !important;
|
||||
}
|
||||
</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">Projekti / </span> Izpis
|
||||
</span>
|
||||
</h4>
|
||||
|
||||
<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 class="row">
|
||||
<div class="col-12">
|
||||
<address class="mb-0">
|
||||
<strong>@Html.DisplayFor(modelItem => Model.PartItem.ProjectPart.Project.Company.Title)</strong> <br/>
|
||||
</address>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<hr/>
|
||||
|
||||
<h4 class="font-weight-bold mb-3">
|
||||
Projekt št.: @Html.DisplayFor(modelItem => Model.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)
|
||||
</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>:
|
||||
<strong class="font-weight-semibold">@Html.DisplayFor(modelItem => Model.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>:
|
||||
<strong class="font-weight-semibold">@Html.DisplayFor(modelItem => Model.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>:
|
||||
<strong class="font-weight-semibold">@Html.DisplayFor(modelItem => Model.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>:
|
||||
<strong class="font-weight-semibold">@Html.DisplayFor(modelItem => Model.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>:
|
||||
<strong class="font-weight-semibold">@Html.DisplayFor(modelItem => Model.PartItem.NumberOfItems)</strong>
|
||||
</div>
|
||||
|
||||
<br/>
|
||||
|
||||
<h6>Operacije</h6>
|
||||
<div class="table-responsive mb-4">
|
||||
<table class="table m-0 table-bordered">
|
||||
<thead style="font-size: 0.75rem">
|
||||
<tr>
|
||||
<th style="width: 30px">#</th>
|
||||
<th class="py-1">
|
||||
Operacija
|
||||
</th>
|
||||
<th class="py-1" style="width: 150px">
|
||||
Čas
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody style="font-size: 0.75rem">
|
||||
@foreach (var item in Model.Operations)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
@(Model.Operations.IndexOf(item) + 1)
|
||||
</td>
|
||||
<td>@Html.DisplayFor(x => item.Operation.Title)</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</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> Natisni</button>
|
||||
</div>
|
||||
</div>
|
||||
@Html.AntiForgeryToken()
|
||||
|
||||
@section Scripts {
|
||||
@{await Html.RenderPartialAsync("_ValidationScriptsPartial");}
|
||||
|
||||
<!-- PDF -->
|
||||
<script src="~/vendor/libs/html2pdf.js/dist/html2pdf.bundle.min.js" asp-append-version="true"></script>
|
||||
|
||||
<script>
|
||||
var laddaPrint = Ladda.create(document.querySelector('#btnPrint'));
|
||||
var laddaPrintAndConfirm = document.querySelector('#btnPrintAndConfirm') == null ? null : Ladda.create(document.querySelector('#btnPrintAndConfirm'));
|
||||
|
||||
var element = document.getElementById('print-content');
|
||||
var opt = {
|
||||
//pagebreak: { mode: 'avoid-all' },
|
||||
filename: 'nalog.pdf',
|
||||
image: { type: 'png' },
|
||||
enableLinks: false,
|
||||
margin: [5, 0, 13, 0],
|
||||
html2canvas: {
|
||||
scale: 1.2,
|
||||
scrollX: 0,
|
||||
scrollY: 0,
|
||||
dpi: 300,
|
||||
letterRendering: true
|
||||
},
|
||||
jsPDF: { unit: 'mm', format: 'a4', orientation: 'portrait' }
|
||||
};
|
||||
|
||||
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);
|
||||
}
|
||||
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');
|
||||
link.download = '@Model.PartItem.ProjectPartNumberFormatted.Replace("-", "_")';
|
||||
link.click();
|
||||
link.remove();
|
||||
if (confirm) {
|
||||
confirmInvoice();
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
$(document).ready(function () {
|
||||
//print();
|
||||
});
|
||||
|
||||
$(".btn-print").click(function () {
|
||||
print($(this).attr("data-confirm") === 'true');
|
||||
});
|
||||
|
||||
</script>
|
||||
}
|
||||
62
EveryThing/Pages/Projects/PrintPartItem.cshtml.cs
Normal file
62
EveryThing/Pages/Projects/PrintPartItem.cshtml.cs
Normal file
@@ -0,0 +1,62 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using EveryThing.Data;
|
||||
using EveryThing.Models;
|
||||
using EveryThing.Models.Project;
|
||||
using EveryThing.Models.Transport;
|
||||
using DocumentFormat.OpenXml.Wordprocessing;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace EveryThing.Pages.Projects
|
||||
{
|
||||
[Authorize(Roles = "Administrator,InvoicingUser,ProjecThingUser")]
|
||||
public class PrintPartItem : PageModel
|
||||
{
|
||||
|
||||
|
||||
private readonly ApplicationDbContext _context;
|
||||
private readonly UserManager<IdentityApplicationUser> _userManager;
|
||||
|
||||
public ProjectPartItem PartItem { get; set; }
|
||||
|
||||
public IList<ProjectPartItemOperation> Operations { get; set; }
|
||||
|
||||
public PrintPartItem(ApplicationDbContext context, UserManager<IdentityApplicationUser> userManager)
|
||||
{
|
||||
_context = context;
|
||||
_userManager = userManager;
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnGetAsync(int id)
|
||||
{
|
||||
var user = _userManager.GetUserAsync(User).Result;
|
||||
|
||||
PartItem = 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)
|
||||
.ToListAsync();
|
||||
|
||||
|
||||
return Page();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user