sales_table.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php /** @noinspection PhpUnhandledExceptionInspection */
  2. namespace App;
  3. /**
  4. * @var Sale[] $sales
  5. */
  6. $core = Core::getInstance();
  7. $user = $core->getUser();
  8. ?>
  9. <table class="table table-bordered table-hover mb-3">
  10. <thead>
  11. <tr>
  12. <th><?=htmlspecialchars(__("Ref."))?></th>
  13. <th><?=htmlspecialchars(__("Date"))?></th>
  14. <th><?=htmlspecialchars(__("Location"))?></th>
  15. <th><?=htmlspecialchars(__("Status"))?></th>
  16. <th><?=htmlspecialchars(__("Items"))?></th>
  17. <th><?=htmlspecialchars(__("Value"))?></th>
  18. <th><?=htmlspecialchars(__("Predicted Sold Date"))?></th>
  19. <th><?=htmlspecialchars(__("Last Updated"))?></th>
  20. <th><?=htmlspecialchars(__("Actions"))?></th>
  21. </tr>
  22. </thead>
  23. <tbody>
  24. <?php
  25. foreach($sales as $sale) {
  26. $location = $sale->getLocation();
  27. ?>
  28. <tr>
  29. <td class="text-end">
  30. <a href="<?=htmlspecialchars($sale->getUrl())?>"><?=htmlspecialchars($sale->getReference())?></a>
  31. </td>
  32. <td>
  33. <?=htmlspecialchars($user->formatDate($sale->getDateTimeCreated()))?>
  34. </td>
  35. <td>
  36. <a href="<?=htmlspecialchars($location->getUrl())?>">
  37. <?=htmlspecialchars($location->getDisplayName())?>
  38. </a>
  39. </td>
  40. <td>
  41. <?=htmlspecialchars($sale->getDisplayStatus())?>
  42. </td>
  43. <td>
  44. <?php
  45. foreach($sale->getItems() as $item) {
  46. ?>
  47. <?=htmlspecialchars($item->getProduct()->name)?> &times; <?=$item->quantity?><br />
  48. <?php
  49. }
  50. ?>
  51. </td>
  52. <td class="text-end">
  53. <?=htmlspecialchars($sale->getDisplayAmount())?>
  54. </td>
  55. <td>
  56. <?=htmlspecialchars($sale->getDisplayPredictedSoldDate())?>
  57. </td>
  58. <td>
  59. <?php
  60. $dt_updated = $sale->getDateTimeUpdated();
  61. if($dt_updated) {
  62. echo $dt_updated->diffForHumans();
  63. }
  64. ?>
  65. </td>
  66. <td class="p-1">
  67. <a class="btn btn-sm btn-primary" href="<?=htmlspecialchars($sale->getUrl())?>">
  68. <?=htmlspecialchars(__("View"))?>
  69. </a>
  70. </td>
  71. </tr>
  72. <?php
  73. }
  74. ?>
  75. </tbody>
  76. </table>