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