sale.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. <?php /** @noinspection PhpUnhandledExceptionInspection */
  2. namespace App;
  3. use App\Enums\Currencies;
  4. use App\Enums\SaleStatuses;
  5. use App\Helpers\HtmlHelper;
  6. /**
  7. * @var Sale $sale
  8. */
  9. $core = Core::getInstance();
  10. $user = $core->getUser();
  11. ?>
  12. <section class="mb-4">
  13. <h3><?=htmlspecialchars($sale->getTitle())?></h3>
  14. <form class="mb-4" action="<?=htmlspecialchars($sale->getUrl())?>/submit" method="post">
  15. <div class="row">
  16. <div class="col-xl-6">
  17. <h4><?=htmlspecialchars(__("Main Details"))?></h4>
  18. <div class="mb-3">
  19. <label class="form-label" for="currency"><?=htmlspecialchars(__("Currency"))?></label>
  20. <select class="form-control" name="currency" id="currency">
  21. <?php
  22. HtmlHelper::renderOptions(Currencies::options(), $sale->currency);
  23. ?>
  24. </select>
  25. </div>
  26. <div class="mb-3">
  27. <label class="form-label" for="status">
  28. <?=htmlspecialchars(__("Status"))?>
  29. </label>
  30. <select class="form-control" name="status" id="status">
  31. <?php
  32. HtmlHelper::renderOptions(SaleStatuses::options(), $sale->status);
  33. ?>
  34. </select>
  35. </div>
  36. <div class="mb-3">
  37. <label for="tax-rate" class="form-label">
  38. <?=htmlspecialchars(__("Tax Rate (%)"))?>
  39. </label>
  40. <input class="form-control" type="number" name="tax_rate" id="tax-rate" value="<?=$sale->tax_rate?>" min="0" max="100.00" step="0.01" placeholder="Type tax rate" required />
  41. </div>
  42. </div>
  43. <div class="col-xl-6">
  44. <h4><?=htmlspecialchars(__("Additional Details"))?></h4>
  45. <dl>
  46. <dt><?=htmlspecialchars(__("Company"))?></dt>
  47. <dd><?=htmlspecialchars($sale->getCompany()->name)?></dd>
  48. <dt><?=htmlspecialchars(__("Location"))?></dt>
  49. <dd><?=htmlspecialchars($sale->getLocation()->getDisplayName())?></dd>
  50. <dt><?=htmlspecialchars(__("Created By"))?></dt>
  51. <dd><?=htmlspecialchars($sale->getUser()->getDisplayName())?></dd>
  52. <dt><?=htmlspecialchars(__("Created Date/Time"))?></dt>
  53. <dd><?=htmlspecialchars($sale->getDateTimeCreated()->format("d/m/Y H:i"))?></dd>
  54. </dl>
  55. </div>
  56. </div>
  57. <button type="submit" class="btn btn-primary">
  58. <i class="fa fa-fw fa-save"></i>
  59. <?=htmlspecialchars(__("Save Sale"))?>
  60. </button>
  61. </form>
  62. </section>
  63. <?php
  64. View::include("sale_items_section", compact("sale"));
  65. View::include("sale_invoices_section", compact("sale"));
  66. View::include("sale_notes_section", compact("sale"));
  67. ?>
  68. <section class="mb-4">
  69. <div class="row mb-3">
  70. <div class="col">
  71. <h3><?=htmlspecialchars(__("Tickets"))?></h3>
  72. </div>
  73. <div class="col-auto">
  74. <button class="btn btn-success" type="button" data-bs-toggle="modal" data-bs-target="#ticket-modal" data-location-id="<?=$sale->location_id?>" data-sale-number="<?=$sale->getNumber()?>">
  75. <i class="fa fa-fw fa-plus"></i>
  76. <?=htmlspecialchars(__("Add Ticket"))?>
  77. </button>
  78. </div>
  79. </div>
  80. <?php
  81. $tickets = $sale->getTickets();
  82. if(empty($tickets)) {
  83. HtmlHelper::renderInfoAlert(__("No tickets to display."));
  84. }
  85. else {
  86. ?>
  87. <table class="table table-bordered table-hover">
  88. <colgroup>
  89. <col style="width: 10%"/>
  90. <col style="width: 10%"/>
  91. <col style="width: 35%"/>
  92. <col style="width: 10%"/>
  93. <col style="width: 20%"/>
  94. <col style="width: 15%"/>
  95. <col style="width: 1%"/>
  96. </colgroup>
  97. <thead>
  98. <tr>
  99. <th><?=htmlspecialchars(__("ID"))?></th>
  100. <th><?=htmlspecialchars(__("Date"))?></th>
  101. <th><?=htmlspecialchars(__("Subject"))?></th>
  102. <th><?=htmlspecialchars(__("Status"))?></th>
  103. <th><?=htmlspecialchars(__("Assigned To"))?></th>
  104. <th><?=htmlspecialchars(__("Last Updated"))?></th>
  105. <th><?=htmlspecialchars(__("Actions"))?></th>
  106. </tr>
  107. </thead>
  108. <tbody>
  109. <?php
  110. foreach($tickets as $ticket) {
  111. ?>
  112. <tr>
  113. <td class="text-end">
  114. <a href="<?=htmlspecialchars($ticket->getUrl())?>"><?=htmlspecialchars($ticket->id)?></a>
  115. </td>
  116. <td>
  117. <?=htmlspecialchars($user->formatDate($ticket->getDateTimeCreated()))?>
  118. </td>
  119. <td>
  120. <?=htmlspecialchars($ticket->subject)?>
  121. </td>
  122. <td>
  123. <?=htmlspecialchars($ticket->getDisplayStatus())?>
  124. </td>
  125. <td>
  126. <?=htmlspecialchars($ticket->getDisplayAssignedTo())?>
  127. </td>
  128. <td>
  129. <?=htmlspecialchars($user->formatDateTime($ticket->getDateTimeUpdated()))?>
  130. </td>
  131. <td class="p-1">
  132. <a class="btn btn-sm btn-primary" href="<?=htmlspecialchars($ticket->getUrl())?>"><?=htmlspecialchars(__("View"))?></a>
  133. </td>
  134. </tr>
  135. <?php
  136. }
  137. ?>
  138. </tbody>
  139. </table>
  140. <?php
  141. }
  142. ?>
  143. </section>