| 1 | @model List<StockMaster.Models.ProductPriceLog>
|
|---|
| 2 | @{
|
|---|
| 3 | ViewData["Title"] = "Product Price Change Logs";
|
|---|
| 4 | }
|
|---|
| 5 |
|
|---|
| 6 | <div class="d-flex justify-content-between align-items-center mb-3">
|
|---|
| 7 | <h2>Product Price Change Logs</h2>
|
|---|
| 8 | <div>
|
|---|
| 9 | <a href="/Report/Index" class="btn btn-secondary"><i class="fas fa-arrow-left"></i> Back</a>
|
|---|
| 10 | <a href="/Report/ExportPriceLogs" class="btn btn-success"><i class="fas fa-file-csv"></i> CSV</a>
|
|---|
| 11 | <button onclick="exportToPDF()" class="btn btn-danger"><i class="fas fa-file-pdf"></i> PDF</button>
|
|---|
| 12 | </div>
|
|---|
| 13 | </div>
|
|---|
| 14 |
|
|---|
| 15 | <div id="reportContent">
|
|---|
| 16 | <table class="table table-bordered table-striped">
|
|---|
| 17 | <thead class="table-dark">
|
|---|
| 18 | <tr>
|
|---|
| 19 | <th>Date</th>
|
|---|
| 20 | <th>Who</th>
|
|---|
| 21 | <th>Product</th>
|
|---|
| 22 | <th>Old Price</th>
|
|---|
| 23 | <th>New Price</th>
|
|---|
| 24 | </tr>
|
|---|
| 25 | </thead>
|
|---|
| 26 | <tbody>
|
|---|
| 27 | @foreach (var item in Model)
|
|---|
| 28 | {
|
|---|
| 29 | <tr>
|
|---|
| 30 | <td>@item.ChangedAt.ToString("g")</td>
|
|---|
| 31 | <td>@(item.ChangedBy ?? "System")</td>
|
|---|
| 32 | <td>@item.ProductName</td>
|
|---|
| 33 | <td>@item.OldPrice.ToString("N2") MKD</td>
|
|---|
| 34 | <td>@item.NewPrice.ToString("N2") MKD</td>
|
|---|
| 35 | </tr>
|
|---|
| 36 | }
|
|---|
| 37 | </tbody>
|
|---|
| 38 | </table>
|
|---|
| 39 | </div>
|
|---|
| 40 |
|
|---|
| 41 | @section Scripts {
|
|---|
| 42 | <script src="https://cdnjs.cloudflare.com/ajax/libs/html2pdf.js/0.10.1/html2pdf.bundle.min.js"></script>
|
|---|
| 43 | <script>
|
|---|
| 44 | function exportToPDF() {
|
|---|
| 45 | var element = document.getElementById('reportContent');
|
|---|
| 46 | var opt = {
|
|---|
| 47 | margin: 0.5,
|
|---|
| 48 | filename: 'PriceChangeLogs.pdf',
|
|---|
| 49 | image: { type: 'jpeg', quality: 0.98 },
|
|---|
| 50 | html2canvas: { scale: 2 },
|
|---|
| 51 | jsPDF: { unit: 'in', format: 'letter', orientation: 'portrait' }
|
|---|
| 52 | };
|
|---|
| 53 | html2pdf().set(opt).from(element).save();
|
|---|
| 54 | }
|
|---|
| 55 | </script>
|
|---|
| 56 | } |
|---|