|
@@ -31,6 +31,7 @@ class Member extends Component
|
|
|
|
|
|
|
|
public $selectedCourseMember = 0;
|
|
public $selectedCourseMember = 0;
|
|
|
|
|
|
|
|
|
|
+ public $hasCertificate = false;
|
|
|
protected $messages = [
|
|
protected $messages = [
|
|
|
'birth_nation_id.required' => 'birth_nation_id',
|
|
'birth_nation_id.required' => 'birth_nation_id',
|
|
|
'birth_province_id.required' => 'birth_province_id',
|
|
'birth_province_id.required' => 'birth_province_id',
|
|
@@ -44,6 +45,13 @@ class Member extends Component
|
|
|
public function change($type)
|
|
public function change($type)
|
|
|
{
|
|
{
|
|
|
$this->type = $type;
|
|
$this->type = $type;
|
|
|
|
|
+ if ($type === 'corsi' && $this->dataId > 0) {
|
|
|
|
|
+ $this->loadMemberCards();
|
|
|
|
|
+ $this->loadMemberCertificates();
|
|
|
|
|
+ $this->checkCourseAvailability();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $this->dispatchBrowserEvent('scroll-to-top');
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public function sortBy($field)
|
|
public function sortBy($field)
|
|
@@ -1509,6 +1517,8 @@ class Member extends Component
|
|
|
session()->flash('success, Tesserato creato');
|
|
session()->flash('success, Tesserato creato');
|
|
|
$this->resetCardFields();
|
|
$this->resetCardFields();
|
|
|
$this->addCard = false;
|
|
$this->addCard = false;
|
|
|
|
|
+ $this->loadMemberCards();
|
|
|
|
|
+ $this->checkCourseAvailability();
|
|
|
} catch (\Exception $ex) {
|
|
} catch (\Exception $ex) {
|
|
|
session()->flash('error', 'Errore (' . $ex->getMessage() . ')');
|
|
session()->flash('error', 'Errore (' . $ex->getMessage() . ')');
|
|
|
}
|
|
}
|
|
@@ -1543,7 +1553,7 @@ class Member extends Component
|
|
|
$this->validate(['card_card_id' => 'required']);
|
|
$this->validate(['card_card_id' => 'required']);
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
|
- \Illuminate\Support\Facades\Log::info('Starting card update', [
|
|
|
|
|
|
|
+ Log::info('Starting card update', [
|
|
|
'member_id' => $this->dataId,
|
|
'member_id' => $this->dataId,
|
|
|
'card_id' => $this->card_card_id,
|
|
'card_id' => $this->card_card_id,
|
|
|
'card_number' => $this->card_number
|
|
'card_number' => $this->card_number
|
|
@@ -1553,7 +1563,7 @@ class Member extends Component
|
|
|
if ($this->card_date != '') {
|
|
if ($this->card_date != '') {
|
|
|
$card = \App\Models\Card::findOrFail($this->card_card_id);
|
|
$card = \App\Models\Card::findOrFail($this->card_card_id);
|
|
|
|
|
|
|
|
- \Illuminate\Support\Facades\Log::info('Card details', [
|
|
|
|
|
|
|
+ Log::info('Card details', [
|
|
|
'card_id' => $card->id,
|
|
'card_id' => $card->id,
|
|
|
'next_day_expire' => $card->next_day_expire,
|
|
'next_day_expire' => $card->next_day_expire,
|
|
|
'next_month_expire' => $card->next_month_expire,
|
|
'next_month_expire' => $card->next_month_expire,
|
|
@@ -1578,7 +1588,7 @@ class Member extends Component
|
|
|
$expire_date = $next_exp_obj->format('Y-m-d');
|
|
$expire_date = $next_exp_obj->format('Y-m-d');
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- \Illuminate\Support\Facades\Log::info('Calculated expiration date (next_day_expire/next_month_expire rule)', [
|
|
|
|
|
|
|
+ Log::info('Calculated expiration date (next_day_expire/next_month_expire rule)', [
|
|
|
'input_date' => $this->card_date,
|
|
'input_date' => $this->card_date,
|
|
|
'next_exp' => $next_exp,
|
|
'next_exp' => $next_exp,
|
|
|
'expire_date' => $expire_date,
|
|
'expire_date' => $expire_date,
|
|
@@ -1588,7 +1598,7 @@ class Member extends Component
|
|
|
if ($card->one_year_expire) {
|
|
if ($card->one_year_expire) {
|
|
|
$expire_date = date("Y-m-d", strtotime($this->card_date . ' + 1 years'));
|
|
$expire_date = date("Y-m-d", strtotime($this->card_date . ' + 1 years'));
|
|
|
|
|
|
|
|
- \Illuminate\Support\Facades\Log::info('Calculated expiration date (one_year_expire rule)', [
|
|
|
|
|
|
|
+ Log::info('Calculated expiration date (one_year_expire rule)', [
|
|
|
'input_date' => $this->card_date,
|
|
'input_date' => $this->card_date,
|
|
|
'expire_date' => $expire_date
|
|
'expire_date' => $expire_date
|
|
|
]);
|
|
]);
|
|
@@ -1596,7 +1606,7 @@ class Member extends Component
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- \Illuminate\Support\Facades\Log::info('Updating member card', [
|
|
|
|
|
|
|
+ Log::info('Updating member card', [
|
|
|
'card_id' => $this->cardDataId,
|
|
'card_id' => $this->cardDataId,
|
|
|
'member_id' => $this->dataId,
|
|
'member_id' => $this->dataId,
|
|
|
'card_number' => $this->card_number,
|
|
'card_number' => $this->card_number,
|
|
@@ -1620,7 +1630,7 @@ class Member extends Component
|
|
|
|
|
|
|
|
updateMemberData($this->dataId);
|
|
updateMemberData($this->dataId);
|
|
|
|
|
|
|
|
- \Illuminate\Support\Facades\Log::info('Card updated successfully', [
|
|
|
|
|
|
|
+ Log::info('Card updated successfully', [
|
|
|
'card_id' => $this->cardDataId,
|
|
'card_id' => $this->cardDataId,
|
|
|
'member_id' => $this->dataId
|
|
'member_id' => $this->dataId
|
|
|
]);
|
|
]);
|
|
@@ -1628,8 +1638,10 @@ class Member extends Component
|
|
|
session()->flash('success', 'Tesserato aggiornato');
|
|
session()->flash('success', 'Tesserato aggiornato');
|
|
|
$this->resetCardFields();
|
|
$this->resetCardFields();
|
|
|
$this->updateCard = false;
|
|
$this->updateCard = false;
|
|
|
|
|
+ $this->loadMemberCards();
|
|
|
|
|
+ $this->checkCourseAvailability();
|
|
|
} catch (\Exception $ex) {
|
|
} catch (\Exception $ex) {
|
|
|
- \Illuminate\Support\Facades\Log::error('Error updating card', [
|
|
|
|
|
|
|
+ Log::error('Error updating card', [
|
|
|
'card_id' => $this->cardDataId,
|
|
'card_id' => $this->cardDataId,
|
|
|
'member_id' => $this->dataId,
|
|
'member_id' => $this->dataId,
|
|
|
'error_message' => $ex->getMessage(),
|
|
'error_message' => $ex->getMessage(),
|
|
@@ -1656,24 +1668,9 @@ class Member extends Component
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // Courses
|
|
|
|
|
-
|
|
|
|
|
public function addCourse()
|
|
public function addCourse()
|
|
|
{
|
|
{
|
|
|
$this->resetCourseFields();
|
|
$this->resetCourseFields();
|
|
|
- /*if ($this->under18)
|
|
|
|
|
- {
|
|
|
|
|
- $this->course_months[] = array("m" => 9, "status" => "");
|
|
|
|
|
- $this->course_months[] = array("m" => 10, "status" => "");
|
|
|
|
|
- $this->course_months[] = array("m" => 11, "status" => "");
|
|
|
|
|
- $this->course_months[] = array("m" => 12, "status" => "");
|
|
|
|
|
- $this->course_months[] = array("m" => 1, "status" => "");
|
|
|
|
|
- $this->course_months[] = array("m" => 2, "status" => "");
|
|
|
|
|
- $this->course_months[] = array("m" => 3, "status" => "");
|
|
|
|
|
- $this->course_months[] = array("m" => 4, "status" => "");
|
|
|
|
|
- $this->course_months[] = array("m" => 5, "status" => "");
|
|
|
|
|
- $this->course_months[] = array("m" => 6, "status" => "");
|
|
|
|
|
- }*/
|
|
|
|
|
$this->addCourse = true;
|
|
$this->addCourse = true;
|
|
|
$this->updateCourse = false;
|
|
$this->updateCourse = false;
|
|
|
$this->emit('setEditCorso', true);
|
|
$this->emit('setEditCorso', true);
|
|
@@ -1729,24 +1726,6 @@ class Member extends Component
|
|
|
$rate->status = 0;
|
|
$rate->status = 0;
|
|
|
$rate->is_subscription = true;
|
|
$rate->is_subscription = true;
|
|
|
$rate->save();
|
|
$rate->save();
|
|
|
-
|
|
|
|
|
- // Se la data inizio pagamenti è "inizio corso" allora prendo quella come start date
|
|
|
|
|
- /*if ($r->when_start == 'COURSE')
|
|
|
|
|
- $start = $c->date_from;
|
|
|
|
|
-
|
|
|
|
|
- //
|
|
|
|
|
- $month_day = $r->month_day;
|
|
|
|
|
- if ($month_day > 0)
|
|
|
|
|
- {
|
|
|
|
|
- if ($month_day >= 29)
|
|
|
|
|
- $start = date("Y-m-t", strtotime($start));
|
|
|
|
|
- else
|
|
|
|
|
- $start = date('Y-m-d', strtotime('+' . ($month_day - 1) . ' days', strtotime('first day of ' . ((int)date('j', strtotime($start)) < $month_day ? 'this' : 'next' ) . ' month', strtotime($start))));
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- if ($r->months > 1)
|
|
|
|
|
- $start = date('Y-m-' . ($month_day >= 29 ? 't' : 'd'), strtotime("+" . ($r->months - 1) . " months", strtotime($start)));
|
|
|
|
|
- */
|
|
|
|
|
$go = true;
|
|
$go = true;
|
|
|
while ($go) {
|
|
while ($go) {
|
|
|
|
|
|
|
@@ -1944,6 +1923,8 @@ class Member extends Component
|
|
|
session()->flash('success', 'Certificato creato');
|
|
session()->flash('success', 'Certificato creato');
|
|
|
$this->resetCertificateFields();
|
|
$this->resetCertificateFields();
|
|
|
$this->addCertificate = false;
|
|
$this->addCertificate = false;
|
|
|
|
|
+ $this->loadMemberCertificates();
|
|
|
|
|
+ $this->checkCourseAvailability();
|
|
|
} catch (\Exception $ex) {
|
|
} catch (\Exception $ex) {
|
|
|
session()->flash('error', 'Errore (' . $ex->getMessage() . ')');
|
|
session()->flash('error', 'Errore (' . $ex->getMessage() . ')');
|
|
|
}
|
|
}
|
|
@@ -1991,6 +1972,8 @@ class Member extends Component
|
|
|
session()->flash('success', 'Certificato aggiornato');
|
|
session()->flash('success', 'Certificato aggiornato');
|
|
|
$this->resetCertificateFields();
|
|
$this->resetCertificateFields();
|
|
|
$this->updateCertificate = false;
|
|
$this->updateCertificate = false;
|
|
|
|
|
+ $this->loadMemberCertificates();
|
|
|
|
|
+ $this->checkCourseAvailability();
|
|
|
} catch (\Exception $ex) {
|
|
} catch (\Exception $ex) {
|
|
|
session()->flash('error', 'Errore (' . $ex->getMessage() . ')');
|
|
session()->flash('error', 'Errore (' . $ex->getMessage() . ')');
|
|
|
}
|
|
}
|
|
@@ -2441,6 +2424,32 @@ class Member extends Component
|
|
|
}
|
|
}
|
|
|
return $ret;
|
|
return $ret;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ private function checkCourseAvailability()
|
|
|
|
|
+ {
|
|
|
|
|
+ $this->active = $this->getActiveStatus();
|
|
|
|
|
+ $this->hasCertificate = $this->checkHasCertificate();
|
|
|
|
|
+
|
|
|
|
|
+ $this->emit('course-availability-updated');
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private function getActiveStatus()
|
|
|
|
|
+ {
|
|
|
|
|
+ if ($this->dataId > 0) {
|
|
|
|
|
+ $member = \App\Models\Member::find($this->dataId);
|
|
|
|
|
+ if ($member) {
|
|
|
|
|
+ return $member->isActive();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return ["status" => 0, "date" => null];
|
|
|
|
|
+ }
|
|
|
|
|
+ private function checkHasCertificate()
|
|
|
|
|
+ {
|
|
|
|
|
+ if ($this->dataId > 0) {
|
|
|
|
|
+ return $this->member_certificates->where('expire_date', '>=', date('Y-m-d'))->count() > 0;
|
|
|
|
|
+ }
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
class codicefiscale
|
|
class codicefiscale
|