Просмотр исходного кода

Add support for specifying report month for projects

Alan Lam 8 лет назад
Родитель
Сommit
12cafebacd

+ 5 - 1
controllers/performance.php

@@ -169,7 +169,11 @@ if($submit) {
 		// Filter tests based on date range
 		$tests = array_filter($tests, function($test) use ($min_unix, $max_unix) {
 
-			$dt = new DateTime($test->dts_start . " UTC");
+			$project = $test->getProject();
+
+			$dts = $project->dts_report ?: $test->dts_start;
+
+			$dt = new DateTime($dts . " UTC");
 			$unix = $dt->format("U");
 
 			if($unix < $min_unix) {

+ 6 - 0
controllers/project_add.php

@@ -41,6 +41,7 @@ if($submit) {
 
 		$date_start = http::getDateFromFields("date_start");
 		$date_deadline = http::getDateFromFields("date_deadline");
+		$date_report = http::getDateFromFields("date_report");
 
 		$form_exception = new FormException;
 
@@ -60,10 +61,15 @@ if($submit) {
 
 		$unix_start = strtotime($date_start . " 00:00:00");
 		$unix_deadline = strtotime($date_deadline . " 23:59:59");
+		$unix_report = null;
+		if(!empty($date_report)) {
+			$unix_report = strtotime($date_report . " 12:00:00");
+		}
 
 		$project->dts_start = Util::getDateTime($unix_start);
 		$project->dts_deadline = Util::getDateTime($unix_deadline);
 		$project->dts_created = Util::getDateTime();
+		$project->dts_report = Util::getDateTime($unix_report);
 
 		if($unix_start > $unix_deadline) $form_exception->addError("Start Date cannot be after the Deadline.");
 

+ 6 - 0
controllers/project_edit.php

@@ -42,6 +42,7 @@ if($submit) {
 
 		$date_start = http::getDateFromFields("date_start");
 		$date_deadline = http::getDateFromFields("date_deadline");
+		$date_report = http::getDateFromFields("date_report");
 
 		$form_exception = new FormException;
 
@@ -61,10 +62,15 @@ if($submit) {
 
 		$unix_start = strtotime($date_start . " 00:00:00");
 		$unix_deadline = strtotime($date_deadline . " 23:59:59");
+		$unix_report = null;
+		if(!empty($date_report)) {
+			$unix_report = strtotime($date_report . " 12:00:00");
+		}
 
 		$project->dts_start = Util::getDateTime($unix_start);
 		$project->dts_deadline = Util::getDateTime($unix_deadline);
 		$project->dts_created = Util::getDateTime();
+		$project->dts_report = Util::getDateTime($unix_report);
 
 		if($unix_start > $unix_deadline) $form_exception->addError("Start Date cannot be after the Deadline.");
 

+ 1 - 1
engine/project.php

@@ -4,7 +4,7 @@ class Project extends Model {
 
 	protected static $table = "project";
 	protected static $id_field = "id";
-	protected static $fillable_fields = ["customer_id", "template_id", "name", "test_count", "min_age", "max_age", "default_tester_fee", "dts_start", "dts_deadline", "dts_created", "dts_updated"];
+	protected static $fillable_fields = ["customer_id", "template_id", "name", "test_count", "min_age", "max_age", "default_tester_fee", "dts_start", "dts_deadline", "dts_created", "dts_updated", "dts_report"];
 
 	protected static $field_map = [
 	];

+ 24 - 0
views/project_form.php

@@ -6,6 +6,12 @@ $date_start_parts = explode("-", $date_start);
 $date_deadline = explode(" ", date("Y-m-d H:i:s", strtotime($project->dts_deadline . " UTC")))[0];
 $date_deadline_parts = explode("-", $date_deadline);
 
+$date_report_parts = [0, 0, 0];
+if($project->dts_report) {
+	$date_report = explode(" ", date("Y-m-d H:i:s", strtotime($project->dts_report . " UTC")))[0];
+	$date_report_parts = explode("-", $date_report);
+}
+
 ?>
 <div class="container mt-3 py-4">
 	<h2>
@@ -121,6 +127,24 @@ $date_deadline_parts = explode("-", $date_deadline);
 						</select>
 					</div>
 				</div>
+				<div class="row mb-1">
+					<label class="col-sm-4 col-form-label" for="date-report">Report Month</label>
+					<div class="col-sm">
+						<input name="date_report_day" id="date-report-day" value="12" type="hidden" />
+						<select class="form-control w-auto d-inline-block" name="date_report_month" id="date-report-month">
+							<option value="">Month</option>
+							<?php
+							Form::renderMonthOptions($date_report_parts[1]);
+							?>
+						</select>
+						<select class="form-control w-auto d-inline-block" name="date_report_year" id="date-report-year">
+							<option value="">Year</option>
+							<?php
+							Form::renderYearOptions(2017, date("Y") + 1, $date_report_parts[0]);
+							?>
+						</select>
+					</div>
+				</div>
 			</div>
 		</div>
 		<hr />