isAdmin() && $customer_id == "ALL") { $page_title = "All Projects"; Core::addBreadcrumb("/account/projects?customer_id=ALL", $page_title); $nvp = []; $customer = new Customer; $customer->id = "ALL"; $customer->name = "All"; } else { $customer = Customer::getForAdmin(); $page_title = "$customer->name Projects"; Core::addBreadcrumb("/account/projects?customer_id=$customer->id", $page_title); $nvp = ["customer_id" => $customer->id]; } $id = http::value("id", "int"); $name = http::value("name", "trim"); $year = http::value("year", "int"); $report_month = http::value("report_month", "db"); if($year === false) { $year = date("Y"); } if($id) $nvp["id"] = $id; if($name) $nvp["name"] = (new Constraint("CONTAINS"))->setValues($name); 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); } if($report_month) { $nvp["dts_report"] = (new Constraint("BEGINS_WITH"))->setValues($report_month); } $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::includeOnce("footer");