sale.php 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  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 id="sale-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. <div class="mb-3">
  46. <label class="form-label" for="company-id">
  47. <?=htmlspecialchars(__("Company"))?>
  48. </label>
  49. <select class="form-control" name="company_id" id="company-id" required>
  50. <option value=""><?=htmlspecialchars(__("Select Company"))?></option>
  51. <?php
  52. HtmlHelper::renderOptions(Company::getOptions(), $sale->company_id);
  53. ?>
  54. </select>
  55. </div>
  56. <dl>
  57. <dt><?=htmlspecialchars(__("Location"))?></dt>
  58. <dd><?=htmlspecialchars($sale->getLocation()->getDisplayName())?></dd>
  59. <dt><?=htmlspecialchars(__("Created By"))?></dt>
  60. <dd><?=htmlspecialchars($sale->getUser()->getDisplayName())?></dd>
  61. <dt><?=htmlspecialchars(__("Created Date/Time"))?></dt>
  62. <dd><?=htmlspecialchars($sale->getDateTimeCreated()->format("d/m/Y H:i"))?></dd>
  63. </dl>
  64. </div>
  65. </div>
  66. <button type="submit" class="btn btn-primary">
  67. <i class="fa fa-fw fa-save"></i>
  68. <?=htmlspecialchars(__("Save Sale"))?>
  69. </button>
  70. </form>
  71. </section>
  72. <?php
  73. View::include("sale_items_section", compact("sale"));
  74. View::include("sale_invoices_section", compact("sale"));
  75. View::include("sale_notes_section", compact("sale"));
  76. ?>
  77. <section class="mb-4">
  78. <div class="row mb-3">
  79. <div class="col">
  80. <h3><?=htmlspecialchars(__("Tickets"))?></h3>
  81. </div>
  82. <div class="col-auto">
  83. <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()?>">
  84. <i class="fa fa-fw fa-plus"></i>
  85. <?=htmlspecialchars(__("Add Ticket"))?>
  86. </button>
  87. </div>
  88. </div>
  89. <?php
  90. $tickets = $sale->getTickets();
  91. if(empty($tickets)) {
  92. HtmlHelper::renderInfoAlert(__("No tickets to display."));
  93. }
  94. else {
  95. ?>
  96. <table class="table table-bordered table-hover">
  97. <colgroup>
  98. <col style="width: 1%"/>
  99. <col style="width: 10%"/>
  100. <col style="width: 45%"/>
  101. <col style="width: 10%"/>
  102. <col style="width: 20%"/>
  103. <col style="width: 15%"/>
  104. <col style="width: 1%"/>
  105. </colgroup>
  106. <thead>
  107. <tr>
  108. <th><?=htmlspecialchars(__("ID"))?></th>
  109. <th><?=htmlspecialchars(__("Date"))?></th>
  110. <th><?=htmlspecialchars(__("Subject"))?></th>
  111. <th><?=htmlspecialchars(__("Status"))?></th>
  112. <th><?=htmlspecialchars(__("Assigned To"))?></th>
  113. <th><?=htmlspecialchars(__("Last Updated"))?></th>
  114. <th><?=htmlspecialchars(__("Actions"))?></th>
  115. </tr>
  116. </thead>
  117. <tbody>
  118. <?php
  119. foreach($tickets as $ticket) {
  120. ?>
  121. <tr>
  122. <td class="text-end">
  123. <a href="<?=htmlspecialchars($ticket->getUrl())?>"><?=htmlspecialchars($ticket->id)?></a>
  124. </td>
  125. <td>
  126. <?=htmlspecialchars($user->formatDate($ticket->getDateTimeCreated()))?>
  127. </td>
  128. <td>
  129. <?=htmlspecialchars($ticket->subject)?>
  130. </td>
  131. <td>
  132. <?=htmlspecialchars($ticket->getDisplayStatus())?>
  133. </td>
  134. <td>
  135. <?=htmlspecialchars($ticket->getDisplayAssignedTo())?>
  136. </td>
  137. <td>
  138. <?=htmlspecialchars($user->formatDateTime($ticket->getDateTimeUpdated()))?>
  139. </td>
  140. <td class="p-1">
  141. <a class="btn btn-sm btn-primary" href="<?=htmlspecialchars($ticket->getUrl())?>"><?=htmlspecialchars(__("View"))?></a>
  142. </td>
  143. </tr>
  144. <?php
  145. }
  146. ?>
  147. </tbody>
  148. </table>
  149. <?php
  150. }
  151. ?>
  152. </section>