sale.php 5.8 KB

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