|
|
@@ -2269,6 +2269,7 @@ class Member extends Component
|
|
|
|
|
|
public function setMonth($m)
|
|
|
{
|
|
|
+ if ($m < 1 || $m > 12) return;
|
|
|
|
|
|
$exist = -1;
|
|
|
foreach ($this->course_months as $idx => $x) {
|
|
|
@@ -2283,16 +2284,29 @@ class Member extends Component
|
|
|
$this->course_months[] = array("m" => $m, "status" => "");
|
|
|
}
|
|
|
|
|
|
- /*
|
|
|
- if (in_array($m, $this->course_months))
|
|
|
- {
|
|
|
- $i = array_search($m, $this->course_months);
|
|
|
- array_splice($this->course_months, $i, 1);
|
|
|
+ $rank = function (int $mm) { return ($mm - 9 + 12) % 12; };
|
|
|
+ usort($this->course_months, function ($a, $b) use ($rank) {
|
|
|
+ return $rank((int)$a['m']) <=> $rank((int)$b['m']);
|
|
|
+ });
|
|
|
+ $this->course_months = array_values($this->course_months);
|
|
|
+
|
|
|
+ if ($this->course_course_id && !empty($this->course_months)) {
|
|
|
+ try {
|
|
|
+ $course = \App\Models\Course::findOrFail($this->course_course_id);
|
|
|
+ $year = (int)$course->year;
|
|
|
+
|
|
|
+ $first_month = (int)$this->course_months[0]['m'];
|
|
|
+ $last_month = (int)$this->course_months[count($this->course_months) - 1]['m'];
|
|
|
+ $start_year = ($first_month >= 9) ? $year : $year + 1;
|
|
|
+ $end_year = ($last_month >= 9) ? $year : $year + 1;
|
|
|
+
|
|
|
+ $start = \Illuminate\Support\Carbon::create($start_year, $first_month, 1, 0, 0, 0, 'Europe/Rome')->startOfDay();
|
|
|
+ $end = \Illuminate\Support\Carbon::create($end_year, $last_month, 1, 0, 0, 0, 'Europe/Rome')->endOfMonth()->endOfDay();
|
|
|
+
|
|
|
+ $this->course_date_from = $start->format('Y-m-d');
|
|
|
+ $this->course_date_to = $end->format('Y-m-d');
|
|
|
+ } catch (\Throwable $e) {}
|
|
|
}
|
|
|
- else
|
|
|
- {
|
|
|
- $this->course_months[] = $m;
|
|
|
- }*/
|
|
|
}
|
|
|
|
|
|
public function newPayment($course)
|