location_notes_tab.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. /**
  3. * @var Location $location
  4. */
  5. $user = Core::$user;
  6. $action = sprintf("/account/locations/%d/add-note", $location->id);
  7. $notes = $location->getNotes();
  8. ?>
  9. <div class="tab-pane fade" id="notes" role="tabpanel" aria-labelledby="notes-tab">
  10. <form class="card mb-3" action="<?=htmlspecialchars($action)?>" method="post">
  11. <div class="card-header">
  12. <?=htmlspecialchars(__("Add Note"))?>
  13. </div>
  14. <div class="card-body">
  15. <label class="sr-only" for="note-content">
  16. <?=htmlspecialchars(__("Note"))?>
  17. </label>
  18. <textarea name="content" id="note-content" rows="4" class="form-control" placeholder="<?=htmlspecialchars(__("Type note"))?>"></textarea>
  19. </div>
  20. <div class="card-footer">
  21. <button class="btn btn-success" type="submit" name="submit" value="<?=htmlspecialchars($_SESSION["csrf_token"])?>">
  22. <?=htmlspecialchars(__("Add Note"))?>
  23. </button>
  24. </div>
  25. </form>
  26. <?php
  27. if(empty($notes)) {
  28. ?>
  29. <div class="alert alert-info">
  30. <i class="fa fa-fw fa-info-circle"></i>
  31. <?=htmlspecialchars(__("No notes have been added to this location."))?>
  32. </div>
  33. <?php
  34. }
  35. else {
  36. ?>
  37. <div class="list-group">
  38. <?php
  39. foreach($notes as $note) {
  40. $user = $note->getUser();
  41. $dt = $note->getDateTimeCreated();
  42. $dt->setTimezone(new DateTimeZone(TIMEZONE));
  43. $delete_url = sprintf("/account/locations/%d/delete-note/%d", $location->id, $note->id);
  44. ?>
  45. <div class="list-group-item">
  46. <div class="form-row">
  47. <div class="col">
  48. <div>
  49. <strong><?=htmlspecialchars($user->getDisplayName())?></strong>
  50. <span class="float-right text-muted"><?=htmlspecialchars($dt->format("d/m/Y H:i"))?></span>
  51. </div>
  52. <div>
  53. <?=$note->getContentHTML()?>
  54. </div>
  55. </div>
  56. <div class="col-auto">
  57. <button class="btn btn-sm btn-primary dropdown-toggle" type="button" data-toggle="dropdown">
  58. <?=htmlspecialchars(__("Actions"))?>
  59. </button>
  60. <div class="dropdown-menu">
  61. <a class="dropdown-item text-danger" href="<?=htmlspecialchars($delete_url)?>">
  62. <?=htmlspecialchars(__("Delete"))?>
  63. </a>
  64. </div>
  65. </div>
  66. </div>
  67. </div>
  68. <?php
  69. }
  70. ?>
  71. </div>
  72. <?php
  73. }
  74. ?>
  75. </div>