sale.php 5.5 KB

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