sale.php 5.7 KB

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