裕隆城折扣合作@中興低碳 折扣報表
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

140 line
5.3KB

  1. @using CouponReport.Models.CouponMiddleware
  2. @model CouponReportViewModel
  3. @{
  4. ViewData["Title"] = "折扣報表";
  5. }
  6. <h2>折扣報表</h2>
  7. <div class="card mb-4">
  8. <div class="card-body">
  9. <form method="post" asp-action="Index">
  10. <div class="row">
  11. <div class="col-md-4">
  12. <div class="form-group">
  13. <label for="startDate">開始日期</label>
  14. <input type="date" class="form-control" id="startDate" name="startDate"
  15. value="@Model.StartDate?.ToString("yyyy-MM-dd")" />
  16. </div>
  17. </div>
  18. <div class="col-md-4">
  19. <div class="form-group">
  20. <label for="endDate">結束日期</label>
  21. <input type="date" class="form-control" id="endDate" name="endDate"
  22. value="@Model.EndDate?.ToString("yyyy-MM-dd")" />
  23. </div>
  24. </div>
  25. <div class="col-md-4">
  26. <label>&nbsp;</label>
  27. <div>
  28. <button type="submit" class="btn btn-primary">查詢</button>
  29. </div>
  30. </div>
  31. </div>
  32. </form>
  33. </div>
  34. </div>
  35. @if (Model.ReportItems != null && Model.ReportItems.Any())
  36. {
  37. <div class="mb-3">
  38. <a href="@Url.Action("ExportToExcel", new { startDate = Model.StartDate, endDate = Model.EndDate })"
  39. class="btn btn-success">
  40. <i class="bi bi-file-excel"></i> 匯出 Excel
  41. </a>
  42. <a href="@Url.Action("ExportToPdf", new { startDate = Model.StartDate, endDate = Model.EndDate })"
  43. class="btn btn-danger">
  44. <i class="bi bi-file-pdf"></i> 匯出 PDF
  45. </a>
  46. </div>
  47. <style>
  48. .group-row-even {
  49. background-color: #f8f9fa;
  50. }
  51. .group-row-odd {
  52. background-color: #ffffff;
  53. }
  54. .table th, .table td {
  55. text-align: center;
  56. vertical-align: middle;
  57. }
  58. .text-right {
  59. text-align: right !important;
  60. }
  61. </style>
  62. <div class="table-responsive">
  63. <table class="table table-bordered">
  64. <thead>
  65. <tr>
  66. <th></th>
  67. <th>店別(統編)</th>
  68. <th>車號</th>
  69. <th>發票日期</th>
  70. <th>發票號碼</th>
  71. <th>發票金額</th>
  72. <th>折扣單位</th>
  73. <th>折扣金額</th>
  74. <th>折扣時間</th>
  75. <th>入場時間</th>
  76. <th>出場時間</th>
  77. <th>停車金額</th>
  78. <th>請款金額</th>
  79. </tr>
  80. </thead>
  81. <tbody>
  82. @{
  83. int currentRowNumber = -1;
  84. int rowSpanCount = 0;
  85. int groupIndex = 0;
  86. }
  87. @foreach (var item in Model.ReportItems)
  88. {
  89. bool isNewGroup = item.RowNumber != currentRowNumber;
  90. if (isNewGroup)
  91. {
  92. // 計算這個編號有多少筆資料
  93. rowSpanCount = Model.ReportItems.Count(x => x.RowNumber == item.RowNumber);
  94. currentRowNumber = item.RowNumber;
  95. groupIndex++;
  96. }
  97. var rowClass = (groupIndex % 2 == 0) ? "group-row-even" : "group-row-odd";
  98. <tr class="@rowClass">
  99. @if (isNewGroup)
  100. {
  101. <td rowspan="@rowSpanCount">@item.RowNumber</td>
  102. }
  103. <td>@item.TenantCode</td>
  104. @if (isNewGroup)
  105. {
  106. <td rowspan="@rowSpanCount">@item.CarNumber</td>
  107. }
  108. <td>@item.InvoiceDate?.ToString("yyyy-MM-dd")</td>
  109. <td>@item.InvoiceNumber</td>
  110. <td class="text-right">NT$ @item.InvoiceAmount?.ToString("N0")</td>
  111. @if (isNewGroup)
  112. {
  113. <td rowspan="@rowSpanCount">@item.DiscountUnit</td>
  114. <td rowspan="@rowSpanCount" class="text-right">NT$ @item.DiscountAmount?.ToString("N0")</td>
  115. <td rowspan="@rowSpanCount">@item.DiscountTime?.ToString("yyyy-MM-dd HH:mm:ss")</td>
  116. <td rowspan="@rowSpanCount">@item.EnterTime?.ToString("yyyy-MM-dd HH:mm:ss")</td>
  117. <td rowspan="@rowSpanCount">@item.ExitTime?.ToString("yyyy-MM-dd HH:mm:ss")</td>
  118. <td rowspan="@rowSpanCount" class="text-right">NT$ @item.ParkingAmount?.ToString("N0")</td>
  119. <td rowspan="@rowSpanCount" class="text-right">NT$ @item.ClaimAmount?.ToString("N0")</td>
  120. }
  121. </tr>
  122. }
  123. </tbody>
  124. </table>
  125. </div>
  126. <div class="mt-3">
  127. <p>總筆數: <strong>@Model.ReportItems.Count</strong></p>
  128. </div>
  129. }