|
|
@@ -1,5 +1,7 @@
|
|
|
<?php /** @noinspection PhpUnhandledExceptionInspection */
|
|
|
|
|
|
+use Carbon\CarbonImmutable;
|
|
|
+
|
|
|
Core::addBreadcrumb("/account", "Account");
|
|
|
Core::addBreadcrumb("/account/projects", "Projects");
|
|
|
|
|
|
@@ -8,8 +10,7 @@ Core::addScript("public/js/app-projects.js");
|
|
|
Core::$allow_all_customers = true;
|
|
|
|
|
|
$customer_id = http::value("customer_id");
|
|
|
-if(Core::$user->isAdmin() && $customer_id == "ALL") {
|
|
|
-
|
|
|
+if(Core::$user->isAdmin() && $customer_id === "ALL") {
|
|
|
$page_title = "All Projects";
|
|
|
Core::addBreadcrumb("/account/projects?customer_id=ALL", $page_title);
|
|
|
|
|
|
@@ -18,7 +19,6 @@ if(Core::$user->isAdmin() && $customer_id == "ALL") {
|
|
|
$customer = new Customer;
|
|
|
$customer->id = "ALL";
|
|
|
$customer->name = "All";
|
|
|
-
|
|
|
}
|
|
|
else {
|
|
|
$customer = Customer::getForAdmin();
|
|
|
@@ -29,31 +29,48 @@ else {
|
|
|
}
|
|
|
|
|
|
$id = http::value("id", "int");
|
|
|
+if($id) {
|
|
|
+ $nvp["id"] = $id;
|
|
|
+}
|
|
|
+
|
|
|
$name = http::value("name", "trim");
|
|
|
+if($name) {
|
|
|
+ $nvp["name"] = (new Constraint("CONTAINS"))->setValues($name);
|
|
|
+}
|
|
|
+
|
|
|
$year = http::value("year", "int");
|
|
|
-$report_month = http::value("report_month", "db");
|
|
|
+$month = http::value("month", "int");
|
|
|
|
|
|
if($year === false) {
|
|
|
$year = date("Y");
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-if($id) $nvp["id"] = $id;
|
|
|
-if($name) $nvp["name"] = (new Constraint("CONTAINS"))->setValues($name);
|
|
|
-if($year) {
|
|
|
+if($year && $month) {
|
|
|
+ $dt_min = CarbonImmutable::now()->setYear($year)->setMonth($month)->startOfMonth();
|
|
|
+ $dt_max = $dt_min->endOfMonth();
|
|
|
+ $nvp["dts_start"] = (new Constraint("BETWEEN"))->setValues((string) $dt_min, (string) $dt_max);
|
|
|
+}
|
|
|
+else if($year) {
|
|
|
$min_dts = "{$year}-01-01 00:00:00";
|
|
|
$max_dts = "{$year}-12-31 23:59:59";
|
|
|
$nvp["dts_start"] = (new Constraint("BETWEEN"))->setValues($min_dts, $max_dts);
|
|
|
}
|
|
|
+
|
|
|
+$report_month = http::value("report_month", "db");
|
|
|
if($report_month) {
|
|
|
$nvp["dts_report"] = (new Constraint("BEGINS_WITH"))->setValues($report_month);
|
|
|
}
|
|
|
|
|
|
+$finished = http::value("finished", "int");
|
|
|
+if($finished !== null) {
|
|
|
+ $nvp["dts_finished"] = $finished ? Constraint::isNotNull() : null;
|
|
|
+}
|
|
|
+
|
|
|
$projects = Project::query($nvp, ["sort" => "dts_start", "order" => "desc"]);
|
|
|
$templates = Template::load(array_column($projects, "template_id"));
|
|
|
|
|
|
$filter_count = count($nvp);
|
|
|
|
|
|
View::includeOnce("header", compact("page_title"));
|
|
|
-View::include("projects", compact("customer", "filter_count", "projects", "year", "report_month"));
|
|
|
+View::include("projects", compact("customer", "filter_count", "projects", "year", "month", "report_month", "finished"));
|
|
|
View::includeOnce("footer");
|