sale.php 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  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. <div class="row">
  20. <div class="col">
  21. <label class="form-label" for="status">
  22. <b><?=htmlspecialchars(__("Status"))?></b>
  23. </label>
  24. </div>
  25. <div class="col-auto">
  26. <span class="badge rounded-pill text-bg-danger">
  27. <?=htmlspecialchars(__("Important"))?>
  28. </span>
  29. </div>
  30. </div>
  31. <select class="form-control" name="status" id="status">
  32. <?php
  33. HtmlHelper::renderOptions(SaleStatuses::options(), $sale->status);
  34. ?>
  35. </select>
  36. </div>
  37. <div class="row">
  38. <div class="col-md">
  39. <div class="mb-3">
  40. <label class="form-label" for="currency"><?=htmlspecialchars(__("Currency"))?></label>
  41. <select class="form-control" name="currency" id="currency">
  42. <?php
  43. HtmlHelper::renderOptions(Currencies::options(), $sale->currency);
  44. ?>
  45. </select>
  46. </div>
  47. </div>
  48. <div class="col-md">
  49. <div class="mb-3">
  50. <label for="tax-rate" class="form-label">
  51. <?=htmlspecialchars(__("Tax Rate (%)"))?>
  52. </label>
  53. <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 />
  54. </div>
  55. </div>
  56. </div>
  57. </div>
  58. <div class="col-xl-6">
  59. <h4><?=htmlspecialchars(__("Additional Details"))?></h4>
  60. <div class="mb-3">
  61. <label class="form-label" for="company-id">
  62. <?=htmlspecialchars(__("Company"))?>
  63. </label>
  64. <select class="form-control" name="company_id" id="company-id" required>
  65. <option value=""><?=htmlspecialchars(__("Select Company"))?></option>
  66. <?php
  67. HtmlHelper::renderOptions(Company::getOptions(), $sale->company_id);
  68. ?>
  69. </select>
  70. </div>
  71. <div class="mb-3">
  72. <label class="form-label" for="date-predicted-sold"><?=htmlspecialchars(__("Predicted Sold Date"))?></label>
  73. <input class="form-control" type="date" name="date_predicted_sold" id="date-predicted-sold" value="<?=htmlspecialchars($sale->date_predicted_sold)?>" />
  74. </div>
  75. <dl>
  76. <dt><?=htmlspecialchars(__("Location"))?></dt>
  77. <dd><?=htmlspecialchars($sale->getLocation()->getDisplayName())?></dd>
  78. <dt><?=htmlspecialchars(__("Created By"))?></dt>
  79. <dd><?=htmlspecialchars($sale->getUser()->getDisplayName())?></dd>
  80. <dt><?=htmlspecialchars(__("Created Date/Time"))?></dt>
  81. <dd><?=htmlspecialchars($sale->getDateTimeCreated()->format("d/m/Y H:i"))?></dd>
  82. </dl>
  83. </div>
  84. </div>
  85. <button type="submit" class="btn btn-primary">
  86. <i class="fa fa-fw fa-save"></i>
  87. <?=htmlspecialchars(__("Save Lead"))?>
  88. </button>
  89. </form>
  90. </section>
  91. <?php
  92. View::include("sale_items_section", compact("sale"));
  93. View::include("sale_invoices_section", compact("sale"));
  94. View::include("sale_notes_section", compact("sale"));
  95. ?>
  96. <section class="mb-4">
  97. <div class="row mb-3">
  98. <div class="col">
  99. <h3><?=htmlspecialchars(__("Tickets"))?></h3>
  100. </div>
  101. <div class="col-auto">
  102. <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()?>">
  103. <i class="fa fa-fw fa-plus"></i>
  104. <?=htmlspecialchars(__("Add Ticket"))?>
  105. </button>
  106. </div>
  107. </div>
  108. <?php
  109. $tickets = $sale->getTickets();
  110. if(empty($tickets)) {
  111. HtmlHelper::renderInfoAlert(__("No tickets to display."));
  112. }
  113. else {
  114. ?>
  115. <table class="table table-bordered table-hover">
  116. <colgroup>
  117. <col style="width: 1%"/>
  118. <col style="width: 10%"/>
  119. <col style="width: 45%"/>
  120. <col style="width: 10%"/>
  121. <col style="width: 20%"/>
  122. <col style="width: 15%"/>
  123. <col style="width: 1%"/>
  124. </colgroup>
  125. <thead>
  126. <tr>
  127. <th><?=htmlspecialchars(__("ID"))?></th>
  128. <th><?=htmlspecialchars(__("Date"))?></th>
  129. <th><?=htmlspecialchars(__("Subject"))?></th>
  130. <th><?=htmlspecialchars(__("Status"))?></th>
  131. <th><?=htmlspecialchars(__("Assigned To"))?></th>
  132. <th><?=htmlspecialchars(__("Last Updated"))?></th>
  133. <th><?=htmlspecialchars(__("Actions"))?></th>
  134. </tr>
  135. </thead>
  136. <tbody>
  137. <?php
  138. foreach($tickets as $ticket) {
  139. ?>
  140. <tr>
  141. <td class="text-end">
  142. <a href="<?=htmlspecialchars($ticket->getUrl())?>"><?=htmlspecialchars($ticket->id)?></a>
  143. </td>
  144. <td>
  145. <?=htmlspecialchars($user->formatDate($ticket->getDateTimeCreated()))?>
  146. </td>
  147. <td>
  148. <?=htmlspecialchars($ticket->subject)?>
  149. </td>
  150. <td>
  151. <?=htmlspecialchars($ticket->getDisplayStatus())?>
  152. </td>
  153. <td>
  154. <?=htmlspecialchars($ticket->getDisplayAssignedTo())?>
  155. </td>
  156. <td>
  157. <?=htmlspecialchars($user->formatDateTime($ticket->getDateTimeUpdated()))?>
  158. </td>
  159. <td class="p-1">
  160. <a class="btn btn-sm btn-primary" href="<?=htmlspecialchars($ticket->getUrl())?>"><?=htmlspecialchars(__("View"))?></a>
  161. </td>
  162. </tr>
  163. <?php
  164. }
  165. ?>
  166. </tbody>
  167. </table>
  168. <?php
  169. }
  170. ?>
  171. </section>