diff --git a/Areas/IT/Printing/ItRequestPdfService.cs b/Areas/IT/Printing/ItRequestPdfService.cs index 646f6fc..1611edc 100644 --- a/Areas/IT/Printing/ItRequestPdfService.cs +++ b/Areas/IT/Printing/ItRequestPdfService.cs @@ -26,13 +26,13 @@ namespace PSTW_CentralSystem.Areas.IT.Printing page.Content().Column(col => { col.Item().Element(e => HeaderStrip(e, m)); - col.Item().PaddingTop(4).LineHorizontal(0.8f); + col.Item().PaddingTop(4).Text( - "Submit this form into http://support.transwater.com.my"); + "This form is digitally generated. Submit to http://support.transwater.com.my"); // ===== SECTION A ===== - #region SECTION A + col.Item().PaddingTop(4).Text("Section A").Bold().FontSize(7); col.Item().Element(e => SectionA_IdentityEmployment(e, m)); @@ -61,61 +61,8 @@ namespace PSTW_CentralSystem.Areas.IT.Printing .Element(x => x.MinHeight(380)) // same floor as left .Element(e => SectionA_RightPane_EmailInternetShared(e, m)); }); - - - // -- Hardware + Email - #region SECTION A • Hardware Requirements - // Rendered together inside SectionA_HardwareEmail (Hardware block) - #endregion - #region SECTION A • Email - // Rendered together inside SectionA_HardwareEmail (Email block) - #endregion - - // -- Internet Permissions - #region SECTION A • Internet Permissions - #endregion - - // -- OS Requirements - #region SECTION A • OS Requirements - #endregion - - // -- Software & Shared Permissions - #region SECTION A • Software (General, Utility, Custom) - #endregion - #region SECTION A • Shared Permissions - #endregion - - // -- Copier (kept as-is) - - // -- Form Arrangement - #region SECTION A • Form Arrangement col.Item().Element(e => FormArrangementBlock(e, m)); - - #endregion - - // -- Approvals table - #endregion // SECTION A - - // ===== SECTION B ===== - #region SECTION B col.Item().Element(e => SectionB_TwoBlocks(e, m)); - - - // -- Asset Information - #region SECTION B • Asset Information - #endregion - - // -- Remarks - #region SECTION B • Remarks - - #endregion - - // -- Signatures - #region SECTION B • Requestor Acknowledgement / Completed By - #endregion - - - #endregion // SECTION B }); }); }).GeneratePdf(); @@ -130,28 +77,55 @@ namespace PSTW_CentralSystem.Areas.IT.Printing static IContainer CellMandatory(IContainer x) => x.Background(Colors.Grey.Lighten2).Border(1).BorderColor(Colors.Grey.Lighten2).Padding(4); #endregion - // ================= HEADER ================= - #region HEADER + // ================= HEADER (boxed like your screenshot) ================= void HeaderStrip(IContainer c, ItRequestReportModel m) { - c.Row(row => + c.Border(1).Padding(0).Table(t => { - row.RelativeItem().Column(left => + t.ColumnsDefinition(cols => { - left.Item().Text("I.T. REQUEST FORM").SemiBold().FontSize(14); - left.Item().Text("(Group IT)").Italic().FontSize(10); + cols.RelativeColumn(2); // LEFT: big title + cols.RelativeColumn(1); // RIGHT: meta table }); - row.ConstantItem(230).Column(right => + // LEFT pane: centered title + t.Cell().BorderRight(1).Padding(8).MinHeight(10).AlignCenter().AlignMiddle().Column(left => { - right.Item().Text($"Document No. {m.DocumentNo}").AlignRight(); - right.Item().Text($"Effective Date {(m.EffectiveDate == default ? "" : m.EffectiveDate.ToString("dd/MM/yyyy"))}").AlignRight(); - right.Item().Text($"Rev. No {m.RevNo}").AlignRight(); - right.Item().Text($"Doc. Page No {m.DocPageNo}").AlignRight(); + left.Item().Text("I.T. REQUEST FORM").SemiBold().FontSize(14).AlignCenter(); + left.Item().Text("(Group IT)").SemiBold().FontSize(14).AlignCenter(); }); + + // RIGHT pane: 2-column grid with borders + t.Cell().Padding(0).Element(x => RightMetaBox(x, m)); }); } - #endregion + + // draws the right-side 2-column table with boxed rows + void RightMetaBox(IContainer c, ItRequestReportModel m) + { + c.Table(t => + { + t.ColumnsDefinition(cols => + { + cols.RelativeColumn(1); // label + cols.RelativeColumn(1); // value + }); + + void Row(string label, string value, bool isLast = false) + { + // label cell (left) + t.Cell().BorderBottom(1).Padding(2).Text(label); + // value cell (right) — add vertical divider between label/value + t.Cell().BorderLeft(1).BorderBottom(1).Padding(0).AlignMiddle().Text(value ?? ""); + } + + Row("Document No.", m.DocumentNo); + Row("Effective Date", (m.EffectiveDate == default) ? "" : m.EffectiveDate.ToString("dd/MM/yyyy")); + Row("Rev. No", m.RevNo); // <- shows dynamic StatusId value + Row("Doc. Page No", m.DocPageNo); // last row still gets bottom border for boxed look + }); + } + // ================= SECTION A ================= #region SECTION A • Identity & Employment @@ -230,7 +204,7 @@ namespace PSTW_CentralSystem.Areas.IT.Printing #endregion - #region SECTION A • Hardware Requirements + Email + #region SECTION A • HardwareOsSoftware // ===================== SECTION A – HARDWARE + OS + SOFTWARE ===================== void SectionA_HardwareOsSoftware(IContainer c, ItRequestReportModel m) @@ -349,7 +323,7 @@ namespace PSTW_CentralSystem.Areas.IT.Printing #endregion - #region SECTION A • Internet Permissions + #region SECTION A • EmailInternetSharedperm // ===================== SECTION A – RIGHT PANE ===================== void SectionA_RightPane_EmailInternetShared(IContainer c, ItRequestReportModel m) { @@ -390,13 +364,13 @@ namespace PSTW_CentralSystem.Areas.IT.Printing }); // ===== Shared Permissions ===== - col.Item().PaddingTop(6).Element(x => x.Background(Colors.Black).Padding(3)) + col.Item().PaddingTop(0).Element(x => x.Background(Colors.Black).Padding(3)) .Text("Shared Permissions").FontColor(Colors.White).Bold(); col.Item().Border(1).Padding(0).Element(x => SharedPermissionsTable(x, m)); // ===== Copier ===== - col.Item().PaddingTop(6).Element(x => x.Border(1).Padding(8)).Column(cc => + col.Item().PaddingTop(0).Element(x => x.Border(1).Padding(8)).Column(cc => { cc.Item().Row(rr => { @@ -481,7 +455,7 @@ namespace PSTW_CentralSystem.Areas.IT.Printing #region SECTION A • OS Requirements // ===================== SECTION A – Form Arrangement ===================== - // ===================== SECTION A – Form Arrangement (BOXED) ===================== + void FormArrangementBlock(IContainer c, ItRequestReportModel m) { // tiny helper: draws the vertical borders for each cell so it looks like 5 boxed panels @@ -550,15 +524,6 @@ namespace PSTW_CentralSystem.Areas.IT.Printing }); } - - #endregion - - #region SECTION A • Software (General, Utility, Custom) & Shared Permissions - - #endregion - - #region SECTION A • Copier - #endregion #region SECTION A • Approvals @@ -637,8 +602,8 @@ namespace PSTW_CentralSystem.Areas.IT.Printing #endregion // ================= SECTION B ================= - #region SECTION B • Asset Information - // ===================== SECTION B – EXACT TWO-BLOCK, TWO-PANE LAYOUT ===================== + #region SECTION B • Asset Information/ Acknowledgment + void SectionB_TwoBlocks(IContainer c, ItRequestReportModel m) { c.Column(col => @@ -761,12 +726,5 @@ namespace PSTW_CentralSystem.Areas.IT.Printing } #endregion - - #region SECTION B • Requestor Acknowledgement / Completed By - #endregion - - // Naive text wrap for justification box - #region HELPER • JointLines - #endregion } } diff --git a/Areas/IT/Printing/ItRequestReportModel.cs b/Areas/IT/Printing/ItRequestReportModel.cs index c0b42a7..73f4477 100644 --- a/Areas/IT/Printing/ItRequestReportModel.cs +++ b/Areas/IT/Printing/ItRequestReportModel.cs @@ -4,7 +4,7 @@ { // Header/meta public string DocumentNo { get; set; } = "GITRF_01"; - public string RevNo { get; set; } = "05"; + public string RevNo { get; set; } = ""; public string DocPageNo { get; set; } = "1 of 1"; public DateTime EffectiveDate { get; set; } = DateTime.Today; diff --git a/Controllers/API/ITRequestAPI.cs b/Controllers/API/ITRequestAPI.cs index 4378529..43add09 100644 --- a/Controllers/API/ITRequestAPI.cs +++ b/Controllers/API/ITRequestAPI.cs @@ -204,6 +204,7 @@ namespace PSTW_CentralSystem.Controllers.API { ItRequestId = status.ItRequestId, StatusId = status.StatusId, + RevNo = status.StatusId.ToString(), OverallStatus = status.OverallStatus ?? "Pending", SubmitDate = req.SubmitDate, // if nullable: req.SubmitDate ?? DateTime.MinValue @@ -329,8 +330,8 @@ namespace PSTW_CentralSystem.Controllers.API return BadRequest(new { message = "PDF available after both acceptances." }); var pdf = new ItRequestPdfService().Generate(m); - var fileName = $"IT_Request_{m.ItRequestId}_SectionB.pdf"; - return File(pdf, "application/pdf", fileName); + //var fileName = $"IT_Request_{m.ItRequestId}_SectionB.pdf"; + return File(pdf, "application/pdf"); }