|
@@ -349,17 +349,14 @@ class Member extends Component
|
|
|
// Carico gli abbonamenti e i mesi
|
|
// Carico gli abbonamenti e i mesi
|
|
|
$period = \Carbon\CarbonPeriod::create($c->date_from, '1 month', $c->date_to);
|
|
$period = \Carbon\CarbonPeriod::create($c->date_from, '1 month', $c->date_to);
|
|
|
$this->course_months_list = [];
|
|
$this->course_months_list = [];
|
|
|
- foreach ($period as $dt)
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ foreach ($period as $dt) {
|
|
|
$this->course_months_list[] = $dt->format("m");
|
|
$this->course_months_list[] = $dt->format("m");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
$course_subscription_ids = [];
|
|
$course_subscription_ids = [];
|
|
|
$this->course_price_list = [];
|
|
$this->course_price_list = [];
|
|
|
- if ($c->prices != null)
|
|
|
|
|
- {
|
|
|
|
|
- foreach(json_decode($c->prices) as $z)
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ if ($c->prices != null) {
|
|
|
|
|
+ foreach (json_decode($c->prices) as $z) {
|
|
|
$this->course_price_list[$z->course_subscription_id] = $z->price;
|
|
$this->course_price_list[$z->course_subscription_id] = $z->price;
|
|
|
if ($z->price > 0)
|
|
if ($z->price > 0)
|
|
|
$course_subscription_ids[] = $z->course_subscription_id;
|
|
$course_subscription_ids[] = $z->course_subscription_id;
|
|
@@ -774,17 +771,14 @@ class Member extends Component
|
|
|
// Carico gli abbonamenti e i mesi
|
|
// Carico gli abbonamenti e i mesi
|
|
|
$period = \Carbon\CarbonPeriod::create($c->date_from, '1 month', $c->date_to);
|
|
$period = \Carbon\CarbonPeriod::create($c->date_from, '1 month', $c->date_to);
|
|
|
$this->course_months_list = [];
|
|
$this->course_months_list = [];
|
|
|
- foreach ($period as $dt)
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ foreach ($period as $dt) {
|
|
|
$this->course_months_list[] = $dt->format("m");
|
|
$this->course_months_list[] = $dt->format("m");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
$course_subscription_ids = [];
|
|
$course_subscription_ids = [];
|
|
|
$this->course_price_list = [];
|
|
$this->course_price_list = [];
|
|
|
- if ($c->prices != null)
|
|
|
|
|
- {
|
|
|
|
|
- foreach(json_decode($c->prices) as $z)
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ if ($c->prices != null) {
|
|
|
|
|
+ foreach (json_decode($c->prices) as $z) {
|
|
|
$this->course_price_list[$z->course_subscription_id] = $z->price;
|
|
$this->course_price_list[$z->course_subscription_id] = $z->price;
|
|
|
if ($z->price > 0)
|
|
if ($z->price > 0)
|
|
|
$course_subscription_ids[] = $z->course_subscription_id;
|
|
$course_subscription_ids[] = $z->course_subscription_id;
|
|
@@ -792,7 +786,6 @@ class Member extends Component
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
$this->course_subscriptions = \App\Models\CourseSubscription::select('*')->whereIn('id', $course_subscription_ids)->where('enabled', true)->get();
|
|
$this->course_subscriptions = \App\Models\CourseSubscription::select('*')->whereIn('id', $course_subscription_ids)->where('enabled', true)->get();
|
|
|
-
|
|
|
|
|
} else {
|
|
} else {
|
|
|
$this->course_price = 0;
|
|
$this->course_price = 0;
|
|
|
$this->course_subscription_price = 0;
|
|
$this->course_subscription_price = 0;
|
|
@@ -1126,7 +1119,6 @@ class Member extends Component
|
|
|
'address' => 'required',
|
|
'address' => 'required',
|
|
|
'zip_code' => 'required',
|
|
'zip_code' => 'required',
|
|
|
'nation_id' => 'required',
|
|
'nation_id' => 'required',
|
|
|
- 'fiscal_code' => 'required',
|
|
|
|
|
'birth_date' => 'before_or_equal:today'
|
|
'birth_date' => 'before_or_equal:today'
|
|
|
];
|
|
];
|
|
|
|
|
|
|
@@ -1162,7 +1154,38 @@ class Member extends Component
|
|
|
|
|
|
|
|
$this->emit('setErrorMsg', $zzz);
|
|
$this->emit('setErrorMsg', $zzz);
|
|
|
|
|
|
|
|
- $this->validate($rules);
|
|
|
|
|
|
|
+
|
|
|
|
|
+ if (!empty($this->fiscal_code)) {
|
|
|
|
|
+ $existingMember = \App\Models\Member::where('fiscal_code', $this->fiscal_code)->first();
|
|
|
|
|
+ if ($existingMember) {
|
|
|
|
|
+ $this->already_existing = true;
|
|
|
|
|
+ $this->emit('focus-error-field', 'fiscal_code');
|
|
|
|
|
+
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if ($this->under18) {
|
|
|
|
|
+ $rules['father_name'] = 'required_without:mother_name';
|
|
|
|
|
+ $rules['father_email'] = 'required_without:mother_email|email';
|
|
|
|
|
+ $rules['father_fiscal_code'] = 'required_without:mother_fiscal_code';
|
|
|
|
|
+ $rules['mother_name'] = 'required_without:father_name';
|
|
|
|
|
+ $rules['mother_email'] = 'required_without:father_email|email';
|
|
|
|
|
+ $rules['mother_fiscal_code'] = 'required_without:father_fiscal_code';
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ try {
|
|
|
|
|
+ $this->validate($rules);
|
|
|
|
|
+ } catch (\Illuminate\Validation\ValidationException $e) {
|
|
|
|
|
+ $this->isSaving = false;
|
|
|
|
|
+ $errorFields = array_keys($e->errors());
|
|
|
|
|
+ if (!empty($errorFields)) {
|
|
|
|
|
+ $this->emit('focus-error-field', $errorFields[0]);
|
|
|
|
|
+ }
|
|
|
|
|
+ Log::error('Validation failed', ['errors' => $e->errors()]);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
try {
|
|
try {
|
|
|
|
|
|
|
|
$name = '';
|
|
$name = '';
|
|
@@ -1553,13 +1576,11 @@ class Member extends Component
|
|
|
$rate->save();
|
|
$rate->save();
|
|
|
|
|
|
|
|
$go = true;
|
|
$go = true;
|
|
|
- while($go)
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ while ($go) {
|
|
|
|
|
|
|
|
$mms = [];
|
|
$mms = [];
|
|
|
$mms[] = date("n", strtotime($start));
|
|
$mms[] = date("n", strtotime($start));
|
|
|
- for($jj=1; $jj<$r->months;$jj++)
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ for ($jj = 1; $jj < $r->months; $jj++) {
|
|
|
$mms[] = date('n', strtotime("+" . $jj . " months", strtotime($start)));
|
|
$mms[] = date('n', strtotime("+" . $jj . " months", strtotime($start)));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -1576,8 +1597,7 @@ class Member extends Component
|
|
|
|
|
|
|
|
$start = date('Y-m-d', strtotime("+" . $r->months . " months", strtotime($start)));
|
|
$start = date('Y-m-d', strtotime("+" . $r->months . " months", strtotime($start)));
|
|
|
|
|
|
|
|
- if ($start > $this->course_date_to)
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ if ($start > $this->course_date_to) {
|
|
|
$go = false;
|
|
$go = false;
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
@@ -1980,25 +2000,19 @@ class Member extends Component
|
|
|
|
|
|
|
|
$price = $course["price"];
|
|
$price = $course["price"];
|
|
|
|
|
|
|
|
- if (sizeof($this->payMonths) == 1)
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ if (sizeof($this->payMonths) == 1) {
|
|
|
$month = $this->payMonths[0];
|
|
$month = $this->payMonths[0];
|
|
|
$records = \App\Models\Record::where('member_course_id', $this->selectedCourseMember)->where('deleted', 0)->get();
|
|
$records = \App\Models\Record::where('member_course_id', $this->selectedCourseMember)->where('deleted', 0)->get();
|
|
|
- foreach ($records as $record)
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ foreach ($records as $record) {
|
|
|
|
|
|
|
|
- if (in_array($month, json_decode($record->months)))
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ if (in_array($month, json_decode($record->months))) {
|
|
|
|
|
|
|
|
- foreach ($record->rows as $row)
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ foreach ($record->rows as $row) {
|
|
|
|
|
|
|
|
|
|
|
|
|
- if ($row->causal_id == $c->causal_id && !str_contains(strtolower($row->note), 'iscrizione'))
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ if ($row->causal_id == $c->causal_id && !str_contains(strtolower($row->note), 'iscrizione')) {
|
|
|
$tot = sizeof(json_decode($row->when));
|
|
$tot = sizeof(json_decode($row->when));
|
|
|
- foreach(json_decode($row->when) as $m)
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ foreach (json_decode($row->when) as $m) {
|
|
|
$price -= $row->amount / $tot;
|
|
$price -= $row->amount / $tot;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -2058,21 +2072,16 @@ class Member extends Component
|
|
|
if ($mm->m == $m) {
|
|
if ($mm->m == $m) {
|
|
|
if ($mm->status == "")
|
|
if ($mm->status == "")
|
|
|
$this->payMonths[] = $m;
|
|
$this->payMonths[] = $m;
|
|
|
- if ($mm->status == "1")
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ if ($mm->status == "1") {
|
|
|
$mc = \App\Models\MemberCourse::findOrFail($selectedCourseMember);
|
|
$mc = \App\Models\MemberCourse::findOrFail($selectedCourseMember);
|
|
|
$price = $mc->price;
|
|
$price = $mc->price;
|
|
|
$payed = 0;
|
|
$payed = 0;
|
|
|
$extraC = '';
|
|
$extraC = '';
|
|
|
$recordsPayed = \App\Models\Record::where('member_course_id', $selectedCourseMember)->where('deleted', 0)->get();
|
|
$recordsPayed = \App\Models\Record::where('member_course_id', $selectedCourseMember)->where('deleted', 0)->get();
|
|
|
- foreach ($recordsPayed as $record)
|
|
|
|
|
- {
|
|
|
|
|
- if (in_array($m, json_decode($record->months)))
|
|
|
|
|
- {
|
|
|
|
|
- foreach ($record->rows as $row)
|
|
|
|
|
- {
|
|
|
|
|
- if ($row->causal_id == $mc->course->causal_id && !str_contains(strtolower($row->note), 'iscrizione'))
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ foreach ($recordsPayed as $record) {
|
|
|
|
|
+ if (in_array($m, json_decode($record->months))) {
|
|
|
|
|
+ foreach ($record->rows as $row) {
|
|
|
|
|
+ if ($row->causal_id == $mc->course->causal_id && !str_contains(strtolower($row->note), 'iscrizione')) {
|
|
|
$tot = sizeof(json_decode($row->when));
|
|
$tot = sizeof(json_decode($row->when));
|
|
|
$payed += $row->amount / $tot;
|
|
$payed += $row->amount / $tot;
|
|
|
}
|
|
}
|
|
@@ -2138,22 +2147,17 @@ class Member extends Component
|
|
|
$class = "yellow";
|
|
$class = "yellow";
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if ($class == 'green')
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ if ($class == 'green') {
|
|
|
|
|
|
|
|
$mc = \App\Models\MemberCourse::findOrFail($selectedCourseMember);
|
|
$mc = \App\Models\MemberCourse::findOrFail($selectedCourseMember);
|
|
|
$price = $mc->price;
|
|
$price = $mc->price;
|
|
|
$payed = 0;
|
|
$payed = 0;
|
|
|
$extraC = '';
|
|
$extraC = '';
|
|
|
$recordsPayed = \App\Models\Record::where('member_course_id', $selectedCourseMember)->where('deleted', 0)->get();
|
|
$recordsPayed = \App\Models\Record::where('member_course_id', $selectedCourseMember)->where('deleted', 0)->get();
|
|
|
- foreach ($recordsPayed as $record)
|
|
|
|
|
- {
|
|
|
|
|
- if (in_array($m, json_decode($record->months)))
|
|
|
|
|
- {
|
|
|
|
|
- foreach ($record->rows as $row)
|
|
|
|
|
- {
|
|
|
|
|
- if ($row->causal_id == $mc->course->causal_id && !str_contains(strtolower($row->note), 'iscrizione'))
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ foreach ($recordsPayed as $record) {
|
|
|
|
|
+ if (in_array($m, json_decode($record->months))) {
|
|
|
|
|
+ foreach ($record->rows as $row) {
|
|
|
|
|
+ if ($row->causal_id == $mc->course->causal_id && !str_contains(strtolower($row->note), 'iscrizione')) {
|
|
|
$tot = sizeof(json_decode($row->when));
|
|
$tot = sizeof(json_decode($row->when));
|
|
|
$payed += $row->amount / $tot;
|
|
$payed += $row->amount / $tot;
|
|
|
}
|
|
}
|
|
@@ -2164,7 +2168,6 @@ class Member extends Component
|
|
|
$class = 'orange half';
|
|
$class = 'orange half';
|
|
|
//$class .= $extraC;
|
|
//$class .= $extraC;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|