customer.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. <?php
  2. namespace App;
  3. /**
  4. * @var Customer $customer
  5. * @var Sale[] $sales
  6. * @var Ticket[] $tickets
  7. * @var Document[] $sales_orders
  8. */
  9. $locations = $customer->getLocations();
  10. $entities = $customer->getEntities();
  11. ?>
  12. <div class="row mb-3 align-items-center">
  13. <div class="col">
  14. <h3 class="mb-0"><?=htmlspecialchars($customer->name)?></h3>
  15. </div>
  16. <div class="col-auto">
  17. <a class="btn btn-primary" href="<?=htmlspecialchars($customer->getUrl())?>/update">
  18. <i class="fa fa-fw fa-pencil"></i>
  19. <?=htmlspecialchars(__("Update"))?>
  20. </a>
  21. </div>
  22. </div>
  23. <section class="mb-4">
  24. <div class="row mb-3 align-items-center">
  25. <div class="col">
  26. <h4 class="mb-0"><?=htmlspecialchars(__("Locations"))?></h4>
  27. </div>
  28. <div class="col-auto">
  29. <a class="btn btn-success" href="/locations/add?customer_id=<?=$customer->id?>">
  30. <i class="fa fa-fw fa-plus"></i>
  31. <?=htmlspecialchars(__("Add Location"))?>
  32. </a>
  33. </div>
  34. </div>
  35. <?php
  36. if(empty($locations)) {
  37. ?>
  38. <div class="alert alert-info mb-3">
  39. <i class="fa fa-fw fa-info-circle"></i>
  40. <?=htmlspecialchars(__("No locations to display."))?>
  41. </div>
  42. <?php
  43. }
  44. else {
  45. ?>
  46. <div class="mb-3 rounded" id="map" style="height: 480px;" data-customer-id="<?=$customer->id?>">
  47. </div>
  48. <?php
  49. View::include("locations_table", compact("locations"));
  50. }
  51. ?>
  52. </section>
  53. <?php
  54. View::include("sale_invoices_section", ["sales_orders" => $customer->getActiveSalesOrders()]);
  55. ?>
  56. <section class="mb-4">
  57. <div class="row mb-3 align-items-center">
  58. <div class="col">
  59. <h4 class="mb-0"><?=htmlspecialchars(__("Leads"))?></h4>
  60. </div>
  61. <div class="col-auto">
  62. <button class="btn btn-success" type="button" data-bs-toggle="modal" data-bs-target="#new-sale-modal">
  63. <i class="fa fa-fw fa-plus"></i>
  64. <?=htmlspecialchars(__("Add Lead"))?>
  65. </button>
  66. </div>
  67. </div>
  68. <?php
  69. if(empty($sales)) {
  70. ?>
  71. <div class="alert alert-info mb-3">
  72. <i class="fa fa-fw fa-info-circle"></i>
  73. <?=htmlspecialchars(__("No leads to display."))?>
  74. </div>
  75. <?php
  76. }
  77. else {
  78. View::include("sales_table", compact("sales"));
  79. }
  80. ?>
  81. </section>
  82. <section class="mb-4">
  83. <div class="row mb-3 align-items-center">
  84. <div class="col">
  85. <h4 class="mb-0"><?=htmlspecialchars(__("Tickets"))?></h4>
  86. </div>
  87. <div class="col-auto">
  88. <button class="btn btn-success" type="button" data-bs-toggle="modal" data-bs-target="#ticket-modal">
  89. <i class="fa fa-fw fa-plus"></i>
  90. <?=htmlspecialchars(__("Add Ticket"))?>
  91. </button>
  92. </div>
  93. </div>
  94. <?php
  95. if(empty($tickets)) {
  96. ?>
  97. <div class="alert alert-info mb-3">
  98. <i class="fa fa-fw fa-info-circle"></i>
  99. <?=htmlspecialchars(__("No tickets to display."))?>
  100. </div>
  101. <?php
  102. }
  103. else {
  104. View::include("tickets_table", compact("tickets"));
  105. }
  106. ?>
  107. </section>
  108. <section class="mb-4">
  109. <div class="row mb-3 align-items-center">
  110. <div class="col">
  111. <h4 class="mb-0"><?=htmlspecialchars(__("Entities"))?></h4>
  112. </div>
  113. <div class="col-auto">
  114. <a class="btn btn-success" href="/customers/<?=htmlspecialchars($customer->getSlug())?>/entities/add">
  115. <i class="fa fa-fw fa-plus"></i>
  116. <?=htmlspecialchars(__("Add Entity"))?>
  117. </a>
  118. </div>
  119. </div>
  120. <?php
  121. if(empty($entities)) {
  122. ?>
  123. <div class="alert alert-info mb-3">
  124. <i class="fa fa-fw fa-info-circle"></i>
  125. <?=htmlspecialchars(__("No entities to display."))?>
  126. </div>
  127. <?php
  128. }
  129. else {
  130. ?>
  131. <table class="table table-bordered table-hover mb-3">
  132. <thead>
  133. <tr>
  134. <th><?=htmlspecialchars(__("Name"))?></th>
  135. <th><?=htmlspecialchars(__("Actions"))?></th>
  136. </tr>
  137. </thead>
  138. <tbody>
  139. <?php
  140. foreach($entities as $entity) {
  141. ?>
  142. <tr>
  143. <td><?=htmlspecialchars($entity->name)?></td>
  144. <td class="p-1">
  145. <a class="btn btn-sm btn-primary" href="<?=htmlspecialchars($entity->getUrl())?>">
  146. <?=htmlspecialchars(__("Update"))?>
  147. </a>
  148. </td>
  149. </tr>
  150. <?php
  151. }
  152. ?>
  153. </tbody>
  154. </table>
  155. <?php
  156. }
  157. ?>
  158. </section>