generate pdf with state and station ID
This commit is contained in:
parent
58434ccc1d
commit
7f4d39d2dd
@ -6,23 +6,21 @@ using PSTW_CentralSystem.Models;
|
|||||||
using PSTW_CentralSystem.Areas.MMS;
|
using PSTW_CentralSystem.Areas.MMS;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using QuestPDF.Fluent;
|
using QuestPDF.Fluent;
|
||||||
|
using PSTW_CentralSystem.Areas.MMS.Models.PDFGenerator;
|
||||||
|
|
||||||
namespace PSTW_CentralSystem.Areas.MMS.Controllers
|
namespace PSTW_CentralSystem.Areas.MMS.Controllers
|
||||||
{
|
{
|
||||||
[Area("MMS")]
|
[Area("MMS")]
|
||||||
|
|
||||||
//[Authorize(Policy = "RoleModulePolicy")]
|
//[Authorize(Policy = "RoleModulePolicy")]
|
||||||
public class MarineController : Controller
|
public class MarineController(MMSSystemContext context) : Controller
|
||||||
{
|
{
|
||||||
private readonly MMSSystemContext _context;
|
private readonly MMSSystemContext _context = context;
|
||||||
public MarineController(MMSSystemContext context)
|
|
||||||
{
|
|
||||||
_context = context;
|
|
||||||
}
|
|
||||||
public IActionResult Index()
|
public IActionResult Index()
|
||||||
{
|
{
|
||||||
return View(); // This will look for Index.cshtml in Areas/MMS/Views/Marine
|
return View(); // This will look for Index.cshtml in Areas/MMS/Views/Marine
|
||||||
}
|
}
|
||||||
|
|
||||||
public IActionResult TarBallForm()
|
public IActionResult TarBallForm()
|
||||||
{
|
{
|
||||||
var marineTarballs = _context.MarineTarballs
|
var marineTarballs = _context.MarineTarballs
|
||||||
@ -46,26 +44,34 @@ namespace PSTW_CentralSystem.Areas.MMS.Controllers
|
|||||||
|
|
||||||
public IActionResult GenerateReport(int id)
|
public IActionResult GenerateReport(int id)
|
||||||
{
|
{
|
||||||
|
Console.WriteLine($"Requested ID in GenerateReport: {id}"); // Log the ID
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Retrieve the specific record based on the id
|
// Retrieve the specific record based on the id, including the related StateID
|
||||||
var tarballData = _context.MarineTarballs
|
var tarballData = (from marine in _context.MarineTarballs
|
||||||
.Where(t => t.Id == id)
|
join station in _context.TarballStations
|
||||||
.Select(t => new
|
on marine.StationID equals station.StationID
|
||||||
|
join state in _context.States
|
||||||
|
on station.StateID equals state.StateID
|
||||||
|
where marine.Id == id
|
||||||
|
select new
|
||||||
{
|
{
|
||||||
t.StationID,
|
marine.StationID,
|
||||||
t.DateSample
|
marine.DateSample,
|
||||||
})
|
state.StateName // Get the full state name
|
||||||
.FirstOrDefault();
|
}).FirstOrDefault();
|
||||||
|
|
||||||
if (tarballData == null)
|
if (tarballData == null)
|
||||||
{
|
{
|
||||||
return NotFound("The specified record was not found.");
|
return NotFound("The specified record was not found.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Console.WriteLine($"Found Record: StationID = {tarballData.StationID}, StateName = {tarballData.StateName}");
|
||||||
|
|
||||||
// Generate the PDF
|
// Generate the PDF
|
||||||
var document = new TarBallPDF(); // Customize the report if needed
|
var pdfdocument = new TarBallPDF(tarballData.StationID, tarballData.StateName); // Pass StateID to the PDF generator
|
||||||
var pdf = document.GeneratePdf();
|
var pdf = pdfdocument.GeneratePdf();
|
||||||
|
|
||||||
// Construct the filename
|
// Construct the filename
|
||||||
var formattedDate = tarballData.DateSample.ToString("ddMMyyyy");
|
var formattedDate = tarballData.DateSample.ToString("ddMMyyyy");
|
||||||
@ -83,28 +89,39 @@ namespace PSTW_CentralSystem.Areas.MMS.Controllers
|
|||||||
|
|
||||||
public IActionResult ViewPDF(int id)
|
public IActionResult ViewPDF(int id)
|
||||||
{
|
{
|
||||||
|
Console.WriteLine("testing"); //TESTING DEBUGGING
|
||||||
|
Console.WriteLine($"Requested ID in ViewReport: {id}"); // Log the ID
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Retrieve the specific record based on the id
|
// Retrieve the specific record based on the id, including the related StateID
|
||||||
var tarballData = _context.MarineTarballs
|
var tarballData = (from marine in _context.MarineTarballs
|
||||||
.Where(t => t.Id == id)
|
join station in _context.TarballStations
|
||||||
.Select(t => new
|
on marine.StationID equals station.StationID into StationGroup
|
||||||
|
from station in StationGroup.DefaultIfEmpty() //Handle missing
|
||||||
|
join state in _context.States
|
||||||
|
on station.StateID equals state.StateID
|
||||||
|
where marine.Id == id
|
||||||
|
select new
|
||||||
{
|
{
|
||||||
t.StationID,
|
marine.StationID,
|
||||||
t.DateSample
|
marine.DateSample,
|
||||||
})
|
StationExists = station != null,
|
||||||
.FirstOrDefault();
|
state.StateName // Get the full state name
|
||||||
|
}).FirstOrDefault();
|
||||||
|
|
||||||
if (tarballData == null)
|
if (tarballData == null)
|
||||||
{
|
{
|
||||||
return NotFound("The specified record was not found.");
|
return NotFound("The specified record was not found.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Console.WriteLine($"Found Record: StationID = {tarballData.StationID}, StateName = {tarballData.StateName}");
|
||||||
|
|
||||||
// Generate the PDF
|
// Generate the PDF
|
||||||
var document = new TarBallPDF(); // Customize the PDF if needed
|
var document = new TarBallPDF(tarballData.StationID, tarballData.StateName); // Pass StateID to the PDF generator
|
||||||
var pdf = document.GeneratePdf();
|
var pdf = document.GeneratePdf();
|
||||||
|
|
||||||
//For filename
|
// Construct the filename
|
||||||
var formattedDate = tarballData.DateSample.ToString("ddMMyyyy");
|
var formattedDate = tarballData.DateSample.ToString("ddMMyyyy");
|
||||||
var fileName = $"TbReport_{tarballData.StationID}_{formattedDate}.pdf";
|
var fileName = $"TbReport_{tarballData.StationID}_{formattedDate}.pdf";
|
||||||
|
|
||||||
@ -117,6 +134,5 @@ namespace PSTW_CentralSystem.Areas.MMS.Controllers
|
|||||||
return StatusCode(StatusCodes.Status500InternalServerError, "An error occurred while viewing the PDF. " + ex.Message);
|
return StatusCode(StatusCodes.Status500InternalServerError, "An error occurred while viewing the PDF. " + ex.Message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,17 +1,30 @@
|
|||||||
using QuestPDF.Fluent;
|
using QuestPDF.Fluent;
|
||||||
using QuestPDF.Infrastructure;
|
using QuestPDF.Infrastructure;
|
||||||
using QuestPDF.Helpers;
|
using QuestPDF.Helpers;
|
||||||
using Microsoft.EntityFrameworkCore.Metadata.Internal;
|
|
||||||
|
|
||||||
|
namespace PSTW_CentralSystem.Areas.MMS.Models.PDFGenerator
|
||||||
|
{
|
||||||
public class TarBallPDF : IDocument
|
public class TarBallPDF : IDocument
|
||||||
{
|
{
|
||||||
public DocumentMetadata GetMetadata() => new DocumentMetadata
|
private readonly string _stationId;
|
||||||
|
private readonly string _stateName;
|
||||||
|
|
||||||
|
// Constructor
|
||||||
|
public TarBallPDF(string stationId, string stateName)
|
||||||
|
{
|
||||||
|
_stationId = stationId;
|
||||||
|
_stateName = stateName;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Metadata for the PDF document
|
||||||
|
public DocumentMetadata GetMetadata() => new()
|
||||||
{
|
{
|
||||||
Title = "TarBall Sampling Form",
|
Title = "TarBall Sampling Form",
|
||||||
Author = "PAKAR SCIENO TW Integrated Environmental Solutions",
|
Author = "PAKAR SCIENO TW Integrated Environmental Solutions",
|
||||||
Subject = "Environmental Survey and Observations"
|
Subject = "Environmental Survey and Observations"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Compose the PDF content
|
||||||
public void Compose(IDocumentContainer container)
|
public void Compose(IDocumentContainer container)
|
||||||
{
|
{
|
||||||
container.Page(page =>
|
container.Page(page =>
|
||||||
@ -27,23 +40,22 @@ public class TarBallPDF : IDocument
|
|||||||
row.RelativeItem(1).Element(CellStyle).Column(column =>
|
row.RelativeItem(1).Element(CellStyle).Column(column =>
|
||||||
{
|
{
|
||||||
column.Item()
|
column.Item()
|
||||||
.AlignMiddle() // Ensures vertical centering
|
.AlignMiddle()
|
||||||
.AlignCenter() // Ensures horizontal centering
|
.AlignCenter()
|
||||||
.Text("Logo Placeholder"); // Placeholder for the logo
|
.Text("Logo Placeholder");
|
||||||
});
|
});
|
||||||
|
|
||||||
row.RelativeItem(1).Element(CellStyle)
|
row.RelativeItem(1).Element(CellStyle)
|
||||||
.AlignMiddle() // Ensures vertical centering
|
.AlignMiddle()
|
||||||
.AlignCenter() // Ensures horizontal centering
|
.AlignCenter()
|
||||||
.Text("TARBALL SAMPLING FORM")
|
.Text("TARBALL SAMPLING FORM")
|
||||||
.FontSize(16)
|
.FontSize(16)
|
||||||
.FontColor("#4B0082");
|
.FontColor("#4B0082");
|
||||||
|
|
||||||
row.RelativeItem(1).Column(column =>
|
row.RelativeItem(1).Column(column =>
|
||||||
{
|
{
|
||||||
column.Spacing(0); // Adds consistent spacing between rows
|
column.Spacing(0);
|
||||||
|
|
||||||
// Document Row
|
|
||||||
column.Item().Row(innerRow =>
|
column.Item().Row(innerRow =>
|
||||||
{
|
{
|
||||||
innerRow.RelativeItem(1).Element(CellStyle).Text("Document:")
|
innerRow.RelativeItem(1).Element(CellStyle).Text("Document:")
|
||||||
@ -65,12 +77,10 @@ public class TarBallPDF : IDocument
|
|||||||
innerRow.RelativeItem(1).Element(CellStyle).Text("02")
|
innerRow.RelativeItem(1).Element(CellStyle).Text("02")
|
||||||
.AlignLeft();
|
.AlignLeft();
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Define styles
|
|
||||||
static IContainer CellStyle(IContainer container)
|
static IContainer CellStyle(IContainer container)
|
||||||
=> container.Border(0.5f).Padding(5); // Retains padding for text
|
=> container.Border(0.5f).Padding(5);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Content Section
|
// Content Section
|
||||||
@ -80,7 +90,7 @@ public class TarBallPDF : IDocument
|
|||||||
column.Item().Element(container =>
|
column.Item().Element(container =>
|
||||||
{
|
{
|
||||||
container
|
container
|
||||||
.PaddingTop(20) // Adds space above the text
|
.PaddingTop(20)
|
||||||
.PaddingBottom(10)
|
.PaddingBottom(10)
|
||||||
.Text("Please be informed that we have observed the following conditions:");
|
.Text("Please be informed that we have observed the following conditions:");
|
||||||
});
|
});
|
||||||
@ -90,42 +100,41 @@ public class TarBallPDF : IDocument
|
|||||||
|
|
||||||
table.ColumnsDefinition(columns =>
|
table.ColumnsDefinition(columns =>
|
||||||
{
|
{
|
||||||
columns.RelativeColumn(3); // Label/Header column
|
columns.RelativeColumn(3);
|
||||||
columns.RelativeColumn(3); // Data Entry column
|
columns.RelativeColumn(3);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Table Rows
|
|
||||||
table.Cell()
|
table.Cell()
|
||||||
.Background(Colors.Grey.Lighten2).Element(CellStyle).Text("STATE")
|
.Background(Colors.Grey.Lighten2).Element(CellStyle).Text("STATE")
|
||||||
.Bold();
|
.Bold();
|
||||||
table.Cell().Element(CellStyle).Text(""); // Empty cell for data entry
|
table.Cell().Element(CellStyle).Text(_stateName);
|
||||||
|
|
||||||
table.Cell()
|
table.Cell()
|
||||||
.Background(Colors.Grey.Lighten2).Element(CellStyle).Text("STATION ID")
|
.Background(Colors.Grey.Lighten2).Element(CellStyle).Text("STATION ID")
|
||||||
.Bold();
|
.Bold();
|
||||||
table.Cell().Element(CellStyle).Text(""); // Empty cell for data entry
|
table.Cell().Element(CellStyle).Text(_stationId);
|
||||||
|
|
||||||
table.Cell()
|
table.Cell()
|
||||||
.Background(Colors.Grey.Lighten2).Element(CellStyle).Text("LOCATION")
|
.Background(Colors.Grey.Lighten2).Element(CellStyle).Text("LOCATION")
|
||||||
.Bold();
|
.Bold();
|
||||||
table.Cell().Element(CellStyle).Text(""); // Empty cell for data entry
|
table.Cell().Element(CellStyle).Text("");
|
||||||
|
|
||||||
table.Cell()
|
table.Cell()
|
||||||
.Background(Colors.Grey.Lighten2).Element(CellStyle).Text("TARBALL SURVEY LOCATION LONGITUDE & LATITUDE")
|
.Background(Colors.Grey.Lighten2).Element(CellStyle).Text("TARBALL SURVEY LOCATION LONGITUDE & LATITUDE")
|
||||||
.Bold();
|
.Bold();
|
||||||
table.Cell().Element(CellStyle).Text(""); // Empty cell for data entry
|
table.Cell().Element(CellStyle).Text("");
|
||||||
|
|
||||||
table.Cell()
|
table.Cell()
|
||||||
.Background(Colors.Grey.Lighten2).Element(CellStyle).Text("DATE / TIME")
|
.Background(Colors.Grey.Lighten2).Element(CellStyle).Text("DATE / TIME")
|
||||||
.Bold();
|
.Bold();
|
||||||
table.Cell().Element(CellStyle).Text(""); // Empty cell for data entry
|
table.Cell().Element(CellStyle).Text("");
|
||||||
});
|
});
|
||||||
|
|
||||||
column.Spacing(3);
|
column.Spacing(3);
|
||||||
|
|
||||||
// Survey Findings
|
// Survey Findings
|
||||||
column.Item()
|
column.Item()
|
||||||
.PaddingTop(10) // Adds space above the text
|
.PaddingTop(10)
|
||||||
.PaddingBottom(10)
|
.PaddingBottom(10)
|
||||||
.Text("SURVEY FINDING:")
|
.Text("SURVEY FINDING:")
|
||||||
.Bold().FontSize(12);
|
.Bold().FontSize(12);
|
||||||
@ -146,22 +155,21 @@ public class TarBallPDF : IDocument
|
|||||||
column.Item()
|
column.Item()
|
||||||
.PaddingBottom(5)
|
.PaddingBottom(5)
|
||||||
.Text("PHOTOGRAPHS OF SAMPLING")
|
.Text("PHOTOGRAPHS OF SAMPLING")
|
||||||
.AlignCenter() // Ensures horizontal centering
|
.AlignCenter()
|
||||||
.Bold()
|
.Bold()
|
||||||
.FontSize(14);
|
.FontSize(14);
|
||||||
|
|
||||||
// Table for Photos with Existing Heights
|
// Table for Photos
|
||||||
column.Item().Table(table =>
|
column.Item().Table(table =>
|
||||||
{
|
{
|
||||||
column.Spacing(0); // No extra spacing between rows
|
column.Spacing(0);
|
||||||
|
|
||||||
table.ColumnsDefinition(columns =>
|
table.ColumnsDefinition(columns =>
|
||||||
{
|
{
|
||||||
columns.RelativeColumn(1); // First column
|
columns.RelativeColumn(1);
|
||||||
columns.RelativeColumn(1); // Second column
|
columns.RelativeColumn(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
// For pictures
|
|
||||||
table.Cell().Element(CellStyle).Height(150);
|
table.Cell().Element(CellStyle).Height(150);
|
||||||
table.Cell().Element(CellStyle).Height(150);
|
table.Cell().Element(CellStyle).Height(150);
|
||||||
|
|
||||||
@ -179,34 +187,25 @@ public class TarBallPDF : IDocument
|
|||||||
column.Item().PageBreak();
|
column.Item().PageBreak();
|
||||||
|
|
||||||
// Additional Photos Section
|
// Additional Photos Section
|
||||||
column.Item()
|
|
||||||
.PaddingBottom(5)
|
|
||||||
.AlignCenter(); // Ensures horizontal centering
|
|
||||||
|
|
||||||
// Table for Additional Photos
|
|
||||||
column.Item().Table(table =>
|
column.Item().Table(table =>
|
||||||
{
|
{
|
||||||
column.Spacing(0); // No extra spacing between rows
|
column.Spacing(0);
|
||||||
|
|
||||||
table.ColumnsDefinition(columns =>
|
table.ColumnsDefinition(columns =>
|
||||||
{
|
{
|
||||||
columns.RelativeColumn(1); // First column
|
columns.RelativeColumn(1);
|
||||||
columns.RelativeColumn(1); // Second column
|
columns.RelativeColumn(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Row 1: Empty spaces for pictures
|
|
||||||
table.Cell().Element(CellStyle).Height(150);
|
table.Cell().Element(CellStyle).Height(150);
|
||||||
table.Cell().Element(CellStyle).Height(150);
|
table.Cell().Element(CellStyle).Height(150);
|
||||||
|
|
||||||
// Row 2: Labels for the pictures
|
|
||||||
table.Cell().Element(CellStyle).Text("Figure 5:").FontSize(12).AlignLeft();
|
table.Cell().Element(CellStyle).Text("Figure 5:").FontSize(12).AlignLeft();
|
||||||
table.Cell().Element(CellStyle).Text("Figure 6:").FontSize(12).AlignLeft();
|
table.Cell().Element(CellStyle).Text("Figure 6:").FontSize(12).AlignLeft();
|
||||||
|
|
||||||
// Row 3: Empty spaces for pictures
|
|
||||||
table.Cell().Element(CellStyle).Height(150);
|
table.Cell().Element(CellStyle).Height(150);
|
||||||
table.Cell().Element(CellStyle).Height(150);
|
table.Cell().Element(CellStyle).Height(150);
|
||||||
|
|
||||||
// Row 4: Labels for the pictures
|
|
||||||
table.Cell().Element(CellStyle).Text("Figure 7:").FontSize(12).AlignLeft();
|
table.Cell().Element(CellStyle).Text("Figure 7:").FontSize(12).AlignLeft();
|
||||||
table.Cell().Element(CellStyle).Text("Figure 8:").FontSize(12).AlignLeft();
|
table.Cell().Element(CellStyle).Text("Figure 8:").FontSize(12).AlignLeft();
|
||||||
});
|
});
|
||||||
@ -222,43 +221,41 @@ public class TarBallPDF : IDocument
|
|||||||
// Signature Section
|
// Signature Section
|
||||||
column.Item().Table(table =>
|
column.Item().Table(table =>
|
||||||
{
|
{
|
||||||
//define how many columns the table has
|
|
||||||
table.ColumnsDefinition(columns =>
|
table.ColumnsDefinition(columns =>
|
||||||
{
|
{
|
||||||
columns.RelativeColumn(2); // Label column
|
columns.RelativeColumn(2);
|
||||||
columns.RelativeColumn(1); // Signature column
|
columns.RelativeColumn(1);
|
||||||
columns.RelativeColumn(2); //empty
|
columns.RelativeColumn(2);
|
||||||
columns.RelativeColumn(1); // Date column
|
columns.RelativeColumn(1);
|
||||||
columns.RelativeColumn(1); //empty
|
columns.RelativeColumn(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Signature Rows
|
|
||||||
table.Cell().RowSpan(2).Element(CellStyle).Text("REPORTED BY :").Bold().FontSize(12);
|
table.Cell().RowSpan(2).Element(CellStyle).Text("REPORTED BY :").Bold().FontSize(12);
|
||||||
table.Cell().Element(CellStyle).Text("Signature").FontSize(12);
|
table.Cell().Element(CellStyle).Text("Signature").FontSize(12);
|
||||||
table.Cell().Element(CellStyle).Text("").FontSize(12);
|
table.Cell().Element(CellStyle).Text("");
|
||||||
table.Cell().Element(CellStyle).Text("Date").FontSize(12);
|
table.Cell().Element(CellStyle).Text("Date").FontSize(12);
|
||||||
table.Cell().Element(CellStyle).Text("").FontSize(12);
|
table.Cell().Element(CellStyle).Text("");
|
||||||
|
|
||||||
table.Cell().Element(CellStyle).Text("Designation").FontSize(12);
|
table.Cell().Element(CellStyle).Text("Designation").FontSize(12);
|
||||||
table.Cell().ColumnSpan(3).Element(CellStyle).Text("").FontSize(12);
|
table.Cell().ColumnSpan(3).Element(CellStyle).Text("");
|
||||||
|
|
||||||
table.Cell().RowSpan(2).Element(CellStyle).Text("CHECKED BY :").Bold().FontSize(12);
|
table.Cell().RowSpan(2).Element(CellStyle).Text("CHECKED BY :").Bold().FontSize(12);
|
||||||
table.Cell().Element(CellStyle).Text("Signature").FontSize(12);
|
table.Cell().Element(CellStyle).Text("Signature").FontSize(12);
|
||||||
table.Cell().Element(CellStyle).Text("").FontSize(12);
|
table.Cell().Element(CellStyle).Text("");
|
||||||
table.Cell().Element(CellStyle).Text("Date").FontSize(12);
|
table.Cell().Element(CellStyle).Text("Date").FontSize(12);
|
||||||
table.Cell().Element(CellStyle).Text("").FontSize(12);
|
table.Cell().Element(CellStyle).Text("");
|
||||||
|
|
||||||
table.Cell().Element(CellStyle).Text("Designation").FontSize(12);
|
table.Cell().Element(CellStyle).Text("Designation").FontSize(12);
|
||||||
table.Cell().ColumnSpan(3).Element(CellStyle).Text("").FontSize(12);
|
table.Cell().ColumnSpan(3).Element(CellStyle).Text("");
|
||||||
|
|
||||||
table.Cell().RowSpan(2).Element(CellStyle).Text("VERIFIED BY :").Bold().FontSize(12);
|
table.Cell().RowSpan(2).Element(CellStyle).Text("VERIFIED BY :").Bold().FontSize(12);
|
||||||
table.Cell().Element(CellStyle).Text("Signature").FontSize(12);
|
table.Cell().Element(CellStyle).Text("Signature").FontSize(12);
|
||||||
table.Cell().Element(CellStyle).Text("").FontSize(12);
|
table.Cell().Element(CellStyle).Text("");
|
||||||
table.Cell().Element(CellStyle).Text("Date").FontSize(12);
|
table.Cell().Element(CellStyle).Text("Date").FontSize(12);
|
||||||
table.Cell().Element(CellStyle).Text("").FontSize(12);
|
table.Cell().Element(CellStyle).Text("");
|
||||||
|
|
||||||
table.Cell().Element(CellStyle).Text("Designation").FontSize(12);
|
table.Cell().Element(CellStyle).Text("Designation").FontSize(12);
|
||||||
table.Cell().ColumnSpan(3).Element(CellStyle).Text("").FontSize(12);
|
table.Cell().ColumnSpan(3).Element(CellStyle).Text("");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -270,8 +267,9 @@ public class TarBallPDF : IDocument
|
|||||||
text.Span(" of ");
|
text.Span(" of ");
|
||||||
text.TotalPages();
|
text.TotalPages();
|
||||||
});
|
});
|
||||||
static IContainer CellStyle(IContainer container) => container.Border(0.5f)
|
|
||||||
.Padding(5);
|
static IContainer CellStyle(IContainer container) => container.Border(0.5f).Padding(5);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -86,14 +86,15 @@
|
|||||||
<th>No.</th>
|
<th>No.</th>
|
||||||
<th v-on:click="sortBy('date')">
|
<th v-on:click="sortBy('date')">
|
||||||
Date
|
Date
|
||||||
<span class="sort-arrow" :class="{ active: sortKey === 'date' && sortOrder === 'asc' }">▲</span>
|
<span :class="['sort-arrow', { active: sortKey === 'date' && sortOrder === 'asc' }]">▲</span>
|
||||||
<span class="sort-arrow" :class="{ active: sortKey === 'date' && sortOrder === 'desc' }">▼</span>
|
<span :class="['sort-arrow', { active: sortKey === 'date' && sortOrder === 'desc' }]">▼</span>
|
||||||
</th>
|
</th>
|
||||||
<th v-on:click="sortBy('station')">
|
<th v-on:click="sortBy('station')">
|
||||||
Station
|
Station
|
||||||
<span class="sort-arrow" :class="{ active: sortKey === 'station' && sortOrder === 'asc' }">▲</span>
|
<span :class="['sort-arrow', { active: sortKey === 'station' && sortOrder === 'asc' }]">▲</span>
|
||||||
<span class="sort-arrow" :class="{ active: sortKey === 'station' && sortOrder === 'desc' }">▼</span>
|
<span :class="['sort-arrow', { active: sortKey === 'station' && sortOrder === 'desc' }]">▼</span>
|
||||||
</th>
|
</th>
|
||||||
|
|
||||||
<th>Status</th>
|
<th>Status</th>
|
||||||
<th>PDF</th>
|
<th>PDF</th>
|
||||||
</tr>
|
</tr>
|
||||||
@ -133,7 +134,7 @@
|
|||||||
'June', 'July', 'August', 'September',
|
'June', 'July', 'August', 'September',
|
||||||
'October', 'November', 'December'
|
'October', 'November', 'December'
|
||||||
],
|
],
|
||||||
dataFromServer: @Html.Raw(Json.Serialize(Model))
|
dataFromServer: @Html.Raw(Json.Serialize(Model ?? new List<object>()))
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
years() {
|
years() {
|
||||||
|
|||||||
@ -11,6 +11,9 @@ namespace PSTW_CentralSystem.DBContext
|
|||||||
|
|
||||||
// DbSet for tbl_marine_tarball
|
// DbSet for tbl_marine_tarball
|
||||||
public DbSet<MarineTarball> MarineTarballs { get; set; }
|
public DbSet<MarineTarball> MarineTarballs { get; set; }
|
||||||
|
public DbSet<TarballStation> TarballStations { get; set; }
|
||||||
|
public DbSet<State> States { get; set; }
|
||||||
|
|
||||||
|
|
||||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||||
{
|
{
|
||||||
@ -36,7 +39,46 @@ namespace PSTW_CentralSystem.DBContext
|
|||||||
entity.Property(e => e.GetLatitude).HasColumnName("getLatitude");
|
entity.Property(e => e.GetLatitude).HasColumnName("getLatitude");
|
||||||
entity.Property(e => e.GetLongitude).HasColumnName("getLongitude");
|
entity.Property(e => e.GetLongitude).HasColumnName("getLongitude");
|
||||||
entity.Property(e => e.Timestamp).HasColumnName("timestamp");
|
entity.Property(e => e.Timestamp).HasColumnName("timestamp");
|
||||||
|
|
||||||
|
//Configure relationship with TarballStation
|
||||||
|
entity.HasOne(m => m.TarballStation)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey(m => m.StationID)
|
||||||
|
.HasPrincipalKey(t => t.StationID);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Map TarballStation to tbl_tarball_station
|
||||||
|
modelBuilder.Entity<TarballStation>().ToTable("tbl_tarball_station");
|
||||||
|
|
||||||
|
modelBuilder.Entity<TarballStation>(entity =>
|
||||||
|
{
|
||||||
|
entity.HasKey(e => e.Id); // Primary key
|
||||||
|
entity.Property(e => e.Id).HasColumnName("id");
|
||||||
|
entity.Property(e => e.StationID).HasColumnName("stationID").HasMaxLength(20);
|
||||||
|
entity.Property(e => e.StateID).HasColumnName("stateID").HasMaxLength(10);
|
||||||
|
entity.Property(e => e.CategoryID).HasColumnName("categoryID").HasMaxLength(10);
|
||||||
|
entity.Property(e => e.LocationName).HasColumnName("locationName").HasMaxLength(50);
|
||||||
|
entity.Property(e => e.Longitude).HasColumnName("longitude").HasColumnType("decimal(10,5)");
|
||||||
|
entity.Property(e => e.Latitude).HasColumnName("latitude").HasColumnType("decimal(10,5)");
|
||||||
|
|
||||||
|
// Configure relationship with State
|
||||||
|
entity.HasOne(t => t.State)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey(t => t.StateID)
|
||||||
|
.HasPrincipalKey(s => s.StateID);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Map State to tbl_state
|
||||||
|
modelBuilder.Entity<State>().ToTable("tbl_state");
|
||||||
|
|
||||||
|
modelBuilder.Entity<State>(entity =>
|
||||||
|
{
|
||||||
|
entity.HasKey(e => e.Id); // Primary key
|
||||||
|
entity.Property(e => e.Id).HasColumnName("id");
|
||||||
|
entity.Property(e => e.StateID).HasColumnName("stateID").HasMaxLength(20);
|
||||||
|
entity.Property(e => e.StateName).HasColumnName("stateName").HasMaxLength(50);
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,21 +1,48 @@
|
|||||||
using System;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
|
||||||
namespace PSTW_CentralSystem.Models
|
namespace PSTW_CentralSystem.Models
|
||||||
{
|
{
|
||||||
public class MarineTarball
|
public class MarineTarball
|
||||||
{
|
{
|
||||||
public int Id { get; set; } // Maps to 'id'
|
public int Id { get; set; } // Maps to 'id'
|
||||||
public string ReportID { get; set; } // Maps to 'reportID'
|
public required string ReportID { get; set; } // Maps to 'reportID'
|
||||||
public string FirstSampler { get; set; } // Maps to 'firstSampler'
|
public required string FirstSampler { get; set; } // Maps to 'firstSampler'
|
||||||
public string SecondSampler { get; set; } // Maps to 'secondSampler'
|
public required string SecondSampler { get; set; } // Maps to 'secondSampler'
|
||||||
public DateTime DateSample { get; set; } // Maps to 'dateSample'
|
public DateTime DateSample { get; set; } // Maps to 'dateSample'
|
||||||
public TimeSpan TimeSample { get; set; } // Maps to 'timeSample'
|
public TimeSpan TimeSample { get; set; } // Maps to 'timeSample'
|
||||||
public string StationID { get; set; } // Maps to 'stationID'
|
public required string StationID { get; set; } // Maps to 'stationID'
|
||||||
public string ClassifyID { get; set; } // Maps to 'classifyID'
|
public required string ClassifyID { get; set; } // Maps to 'classifyID'
|
||||||
public double Latitude { get; set; } // Maps to 'latitude'
|
public double Latitude { get; set; } // Maps to 'latitude'
|
||||||
public double Longitude { get; set; } // Maps to 'longitude'
|
public double Longitude { get; set; } // Maps to 'longitude'
|
||||||
public double GetLatitude { get; set; } // Maps to 'getLatitude'
|
public double GetLatitude { get; set; } // Maps to 'getLatitude'
|
||||||
public double GetLongitude { get; set; } // Maps to 'getLongitude'
|
public double GetLongitude { get; set; } // Maps to 'getLongitude'
|
||||||
public DateTime Timestamp { get; set; } // Maps to 'timestamp'
|
public DateTime Timestamp { get; set; } // Maps to 'timestamp'
|
||||||
|
|
||||||
|
[ForeignKey("StationID")]
|
||||||
|
public required TarballStation TarballStation { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class TarballStation
|
||||||
|
{
|
||||||
|
public int Id { get; set; } // Maps to 'id'
|
||||||
|
public required string StationID { get; set; } // Maps to 'stationID'
|
||||||
|
public required string StateID { get; set; } // Maps to 'stateID'
|
||||||
|
public required string CategoryID { get; set; } // Maps to 'categoryID'
|
||||||
|
public required string LocationName { get; set; } // Maps to 'locationName'
|
||||||
|
public decimal Longitude { get; set; } // Maps to 'longitude'
|
||||||
|
public decimal Latitude { get; set; } // Maps to 'latitude'
|
||||||
|
|
||||||
|
[ForeignKey("StateID")]
|
||||||
|
public required State State { get; set; }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class State
|
||||||
|
{
|
||||||
|
public int Id { get; set; } // Maps to 'id'
|
||||||
|
public required string StateID { get; set; } // Maps to 'stateID'
|
||||||
|
public required string StateName { get; set; } // Maps to 'stateName'
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user