1
0

projects.php 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. <?php /** @noinspection PhpUnhandledExceptionInspection */
  2. /**
  3. * @var Customer $customer
  4. * @var Project[] $projects
  5. * @var int $filter_count
  6. * @var int $year
  7. * @var int $month
  8. * @var string $report_month
  9. * @var int $finished
  10. */
  11. $report_months = array_reverse(Project::getReportMonths());
  12. $user = Core::$user;
  13. $year_options = [];
  14. foreach(range(2018, date("Y")) as $i) {
  15. $year_options[$i] = $i;
  16. }
  17. $month_options = [
  18. 1 => __("January"),
  19. 2 => __("February"),
  20. 3 => __("March"),
  21. 4 => __("April"),
  22. 5 => __("May"),
  23. 6 => __("June"),
  24. 7 => __("July"),
  25. 8 => __("August"),
  26. 9 => __("September"),
  27. 10 => __("October"),
  28. 11 => __("November"),
  29. 12 => __("December"),
  30. ];
  31. $finished_options = [
  32. 0 => __("Unfinished Only"),
  33. 1 => __("Finished Only"),
  34. ];
  35. ?>
  36. <div class="container mt-3 py-4">
  37. <div class="row">
  38. <div class="col-auto">
  39. <h2>
  40. <?=htmlspecialchars($customer->name)?> Projects
  41. <span class="badge badge-pill badge-primary"><?=number_format(count($projects))?></span>
  42. </h2>
  43. </div>
  44. <div class="col text-right">
  45. <button type="button" class="btn btn-primary" data-toggle="collapse" data-target="#project-filters">
  46. <i class="fa fa-fw fa-filter"></i>
  47. Filters
  48. <?php
  49. if($filter_count > 0) {
  50. ?>
  51. <span class="badge badge-pill badge-danger"><?=$filter_count?></span>
  52. <?php
  53. }
  54. ?>
  55. </button>
  56. <a class="btn btn-success" href="/account/projects/add?customer_id=<?=$customer->id?>">
  57. <i class="fa fa-fw fa-plus"></i>
  58. Add
  59. </a>
  60. </div>
  61. </div>
  62. <?php
  63. $filters_show = $filter_count > 0 ? "show" : "";
  64. ?>
  65. <div class="collapse <?=$filters_show?>" id="project-filters">
  66. <div class="card card-body bg-light text-dark mb-3">
  67. <h3>Filters</h3>
  68. <form method="get">
  69. <div class="row">
  70. <div class="col-lg">
  71. <input type="hidden" name="customer_id" value="<?=htmlspecialchars($customer->id)?>" />
  72. <div class="row mb-1">
  73. <label class="col-sm-4 col-form-label" for="id">ID</label>
  74. <div class="col-sm">
  75. <input class="form-control" type="number" name="id" id="id" placeholder="Enter ID" value="<?=htmlspecialchars(http::value("id", "int"))?>" />
  76. </div>
  77. </div>
  78. <div class="row mb-1">
  79. <label class="col-sm-4 col-form-label" for="name">Name</label>
  80. <div class="col-sm">
  81. <input class="form-control" type="text" name="name" id="name" placeholder="Enter name" value="<?=htmlspecialchars(http::value("name"))?>" />
  82. </div>
  83. </div>
  84. <div class="row mb-1">
  85. <label class="col-sm-4 col-form-label" for="year">Year</label>
  86. <div class="col-sm">
  87. <select class="form-control" type="text" name="year" id="year">
  88. <option value="0">Select Year</option>
  89. <?php
  90. HtmlHelper::renderOptions($year_options, $year);
  91. ?>
  92. </select>
  93. </div>
  94. </div>
  95. <div class="row mb-1">
  96. <label for="month" class="col-sm-4 col-form-label">
  97. <?=htmlspecialchars(__("Month"))?>
  98. </label>
  99. <div class="col-sm">
  100. <select class="form-control" id="month" name="month">
  101. <option value=""><?=htmlspecialchars(__("Select Month"))?></option>
  102. <?php
  103. HtmlHelper::renderOptions($month_options, $month);
  104. ?>
  105. </select>
  106. </div>
  107. </div>
  108. <div class="row mb-1">
  109. <label for="report-month" class="col-sm-4 col-form-label"><?=htmlspecialchars(__("Report Month"))?></label>
  110. <div class="col-sm">
  111. <select class="form-control" name="report_month" id="report-month">
  112. <option value=""><?=htmlspecialchars(__("Select Report Month"))?></option>
  113. <?php
  114. HtmlHelper::renderOptions($report_months, $report_month);
  115. ?>
  116. </select>
  117. </div>
  118. </div>
  119. <div class="row mb-1">
  120. <label class="col-sm-4 col-form-label" for="finished"><?=htmlspecialchars(__("Finished"))?></label>
  121. <div class="col-sm">
  122. <select class="form-control" type="text" name="finished" id="finished">
  123. <option value="">Show all</option>
  124. <?php
  125. HtmlHelper::renderOptions($finished_options, $finished);
  126. ?>
  127. </select>
  128. </div>
  129. </div>
  130. <div class="row">
  131. <div class="col-sm offset-sm-4">
  132. <button class="btn btn-primary" type="submit">Submit</button>
  133. <a class="btn btn-secondary" href="/account/projects?customer_id=<?=htmlspecialchars($customer->id)?>">Clear Filters</a>
  134. </div>
  135. </div>
  136. </div>
  137. </div>
  138. </form>
  139. </div>
  140. </div>
  141. <form id="projects-form" method="post">
  142. <input type="hidden" id="type" name="type" value="" />
  143. <?php
  144. View::include("project_list", compact("customer", "projects"));
  145. ?>
  146. <div class="row">
  147. <div class="col-md-6 offset-md-6">
  148. <div class="input-group">
  149. <div class="input-group-prepend">
  150. <label class="input-group-text" for="batch-action">
  151. Batch Action
  152. </label>
  153. </div>
  154. <select class="form-control" id="batch-action" required>
  155. <option value="">Select Action</option>
  156. <?php
  157. if($user->canExportProjectCsv()) {
  158. ?>
  159. <option value="export-admin-csv">Export CSV</option>
  160. <?php
  161. }
  162. ?>
  163. <option value="export-customer-csv">Export Customer CSV</option>
  164. <option value="export-quickbooks-customer-csv">Export Quickbooks Customer CSV</option>
  165. <option value="export-quickbooks-tester-csv">Export Quickbooks Tester CSV</option>
  166. </select>
  167. <div class="input-group-append">
  168. <button type="submit" class="btn btn-primary" name="submit" value="<?=htmlspecialchars($_SESSION["csrf_token"])?>">
  169. Submit
  170. </button>
  171. </div>
  172. </div>
  173. </div>
  174. </div>
  175. </form>
  176. </div>