sale.php 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  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-select" 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-select" 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)?>" required />
  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-select" 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. <div class="row">
  77. <div class="col-sm-6 col-xl-12">
  78. <?php
  79. View::include("related_items_section", [
  80. "sale" => $sale,
  81. "current" => $sale
  82. ]);
  83. ?>
  84. </div>
  85. <div class="col-sm-6 col-xl-12">
  86. <section class="mb-4">
  87. <h4><?=htmlspecialchars(__("Additional Details"))?></h4>
  88. <dl>
  89. <dt><?=htmlspecialchars(__("Location"))?></dt>
  90. <dd>
  91. <a href="<?=htmlspecialchars($location->getUrl())?>">
  92. <?=htmlspecialchars($location->getDisplayName())?>
  93. </a>
  94. </dd>
  95. <dt><?=htmlspecialchars(__("Created By"))?></dt>
  96. <dd><?=htmlspecialchars($sale->getUser()->getDisplayName())?></dd>
  97. <dt><?=htmlspecialchars(__("Created Date/Time"))?></dt>
  98. <dd><?=htmlspecialchars($sale->getDateTimeCreated()->format("d/m/Y H:i"))?></dd>
  99. </dl>
  100. </section>
  101. </div>
  102. </div>
  103. </div>
  104. </div>
  105. <button type="submit" class="btn btn-primary">
  106. <i class="fa fa-fw fa-save"></i>
  107. <?=htmlspecialchars(__("Save Lead"))?>
  108. </button>
  109. </form>
  110. </section>
  111. <?php
  112. View::include("sale_items_section", compact("sale"));
  113. View::include("sale_invoices_section", compact("sale"));
  114. View::include("sale_notes_section", compact("sale"));
  115. ?>
  116. <section class="mb-4">
  117. <div class="row mb-3">
  118. <div class="col">
  119. <h3><?=htmlspecialchars(__("Tickets"))?></h3>
  120. </div>
  121. <div class="col-auto">
  122. <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()?>">
  123. <i class="fa fa-fw fa-plus"></i>
  124. <?=htmlspecialchars(__("Add Ticket"))?>
  125. </button>
  126. </div>
  127. </div>
  128. <?php
  129. $tickets = $sale->getTickets();
  130. if(empty($tickets)) {
  131. HtmlHelper::renderInfoAlert(__("No tickets to display."));
  132. }
  133. else {
  134. ?>
  135. <table class="table table-bordered table-hover">
  136. <colgroup>
  137. <col style="width: 1%"/>
  138. <col style="width: 10%"/>
  139. <col style="width: 45%"/>
  140. <col style="width: 10%"/>
  141. <col style="width: 20%"/>
  142. <col style="width: 15%"/>
  143. <col style="width: 1%"/>
  144. </colgroup>
  145. <thead>
  146. <tr>
  147. <th><?=htmlspecialchars(__("ID"))?></th>
  148. <th><?=htmlspecialchars(__("Date"))?></th>
  149. <th><?=htmlspecialchars(__("Subject"))?></th>
  150. <th><?=htmlspecialchars(__("Status"))?></th>
  151. <th><?=htmlspecialchars(__("Assigned To"))?></th>
  152. <th><?=htmlspecialchars(__("Last Updated"))?></th>
  153. <th><?=htmlspecialchars(__("Actions"))?></th>
  154. </tr>
  155. </thead>
  156. <tbody>
  157. <?php
  158. foreach($tickets as $ticket) {
  159. ?>
  160. <tr>
  161. <td class="text-end">
  162. <a href="<?=htmlspecialchars($ticket->getUrl())?>"><?=htmlspecialchars($ticket->id)?></a>
  163. </td>
  164. <td>
  165. <?=htmlspecialchars($user->formatDate($ticket->getDateTimeCreated()))?>
  166. </td>
  167. <td>
  168. <?=htmlspecialchars($ticket->subject)?>
  169. </td>
  170. <td>
  171. <?=htmlspecialchars($ticket->getDisplayStatus())?>
  172. </td>
  173. <td>
  174. <?=htmlspecialchars($ticket->getDisplayAssignedTo())?>
  175. </td>
  176. <td>
  177. <?=htmlspecialchars($user->formatDateTime($ticket->getDateTimeUpdated()))?>
  178. </td>
  179. <td class="p-1">
  180. <a class="btn btn-sm btn-primary" href="<?=htmlspecialchars($ticket->getUrl())?>"><?=htmlspecialchars(__("View"))?></a>
  181. </td>
  182. </tr>
  183. <?php
  184. }
  185. ?>
  186. </tbody>
  187. </table>
  188. <?php
  189. }
  190. ?>
  191. </section>