sale.php 5.1 KB

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