|
@@ -278,12 +278,10 @@ class Member extends Component
|
|
|
$this->image_old = '';
|
|
$this->image_old = '';
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- /*
|
|
|
|
|
public function updatedCourseName()
|
|
public function updatedCourseName()
|
|
|
{
|
|
{
|
|
|
$this->course_course_id = null;
|
|
$this->course_course_id = null;
|
|
|
$this->course_level_id = '';
|
|
$this->course_level_id = '';
|
|
|
- $this->course_type_id = '';
|
|
|
|
|
$this->course_frequency_id = '';
|
|
$this->course_frequency_id = '';
|
|
|
$levels_ids = [];
|
|
$levels_ids = [];
|
|
|
if ($this->course_name != '') {
|
|
if ($this->course_name != '') {
|
|
@@ -295,28 +293,26 @@ class Member extends Component
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
$this->course_levels = \App\Models\CourseLevel::select('*')->where('enabled', true)->whereIn('id', $levels_ids)->get();
|
|
$this->course_levels = \App\Models\CourseLevel::select('*')->where('enabled', true)->whereIn('id', $levels_ids)->get();
|
|
|
- $this->course_types = [];
|
|
|
|
|
$this->course_frequencies = [];
|
|
$this->course_frequencies = [];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public function updatedCourseLevelId()
|
|
public function updatedCourseLevelId()
|
|
|
{
|
|
{
|
|
|
$this->course_course_id = null;
|
|
$this->course_course_id = null;
|
|
|
- $this->course_type_id = '';
|
|
|
|
|
$this->course_frequency_id = '';
|
|
$this->course_frequency_id = '';
|
|
|
- $types_ids = [];
|
|
|
|
|
|
|
+ $frequencies_ids = [];
|
|
|
if ($this->course_level_id != '') {
|
|
if ($this->course_level_id != '') {
|
|
|
list($n, $y) = explode("(", $this->course_name);
|
|
list($n, $y) = explode("(", $this->course_name);
|
|
|
$y = trim(str_replace(")", "", $y));
|
|
$y = trim(str_replace(")", "", $y));
|
|
|
$all = \App\Models\Course::where('name', 'like', '%' . trim($n) . "%")->where('year', $y)->where('enabled', true)->where('course_level_id', $this->course_level_id)->get();
|
|
$all = \App\Models\Course::where('name', 'like', '%' . trim($n) . "%")->where('year', $y)->where('enabled', true)->where('course_level_id', $this->course_level_id)->get();
|
|
|
foreach ($all as $a) {
|
|
foreach ($all as $a) {
|
|
|
- $types_ids[] = $a->course_type_id;
|
|
|
|
|
|
|
+ $frequencies_ids[] = $a->course_frequency_id;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- $this->course_types = \App\Models\CourseType::select('*')->where('enabled', true)->whereIn('id', $types_ids)->get();
|
|
|
|
|
- $this->course_frequencies = [];
|
|
|
|
|
|
|
+ $this->course_frequencies = \App\Models\CourseFrequency::select('*')->where('enabled', true)->whereIn('id', $frequencies_ids)->get();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /*
|
|
|
public function updatedCourseTypeId()
|
|
public function updatedCourseTypeId()
|
|
|
{
|
|
{
|
|
|
$this->course_course_id = null;
|
|
$this->course_course_id = null;
|
|
@@ -331,7 +327,7 @@ class Member extends Component
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
$this->course_frequencies = \App\Models\CourseFrequency::select('*')->where('enabled', true)->whereIn('id', $frequencies_ids)->get();
|
|
$this->course_frequencies = \App\Models\CourseFrequency::select('*')->where('enabled', true)->whereIn('id', $frequencies_ids)->get();
|
|
|
- }
|
|
|
|
|
|
|
+ }*/
|
|
|
|
|
|
|
|
public function updatedCourseFrequencyId()
|
|
public function updatedCourseFrequencyId()
|
|
|
{
|
|
{
|
|
@@ -339,7 +335,39 @@ class Member extends Component
|
|
|
if ($this->course_frequency_id != '') {
|
|
if ($this->course_frequency_id != '') {
|
|
|
list($n, $y) = explode("(", $this->course_name);
|
|
list($n, $y) = explode("(", $this->course_name);
|
|
|
$y = trim(str_replace(")", "", $y));
|
|
$y = trim(str_replace(")", "", $y));
|
|
|
- $this->course_course_id = \App\Models\Course::where('name', 'like', '%' . trim($n) . "%")->where('year', $y)->where('course_level_id', $this->course_level_id)->where('course_type_id', $this->course_type_id)->where('course_frequency_id', $this->course_frequency_id)->first()->id;
|
|
|
|
|
|
|
+ $this->course_course_id = \App\Models\Course::where('name', 'like', '%' . trim($n) . "%")->where('year', $y)->where('course_level_id', $this->course_level_id)->where('course_frequency_id', $this->course_frequency_id)->first()->id;
|
|
|
|
|
+
|
|
|
|
|
+ $c = \App\Models\Course::findOrFail($this->course_course_id);
|
|
|
|
|
+ $this->course_price = formatPrice($c->price);
|
|
|
|
|
+ $this->course_subscription_price = formatPrice($c->subscription_price);
|
|
|
|
|
+ $this->course_date_from = $c->date_from;
|
|
|
|
|
+ $this->course_date_to = $c->date_to;
|
|
|
|
|
+ // Controllo se sono già iscritto la corso
|
|
|
|
|
+ $this->course_exist = \App\Models\MemberCourse::where('course_id', $this->course_course_id)->where('member_id', $this->dataId)->count() > 0;
|
|
|
|
|
+
|
|
|
|
|
+ // Carico gli abbonamenti e i mesi
|
|
|
|
|
+ $period = \Carbon\CarbonPeriod::create($c->date_from, '1 month', $c->date_to);
|
|
|
|
|
+ $this->course_months_list = [];
|
|
|
|
|
+ foreach ($period as $dt)
|
|
|
|
|
+ {
|
|
|
|
|
+ $this->course_months_list[] = $dt->format("m");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $course_subscription_ids = [];
|
|
|
|
|
+ $this->course_price_list = [];
|
|
|
|
|
+ if ($c->prices != null)
|
|
|
|
|
+ {
|
|
|
|
|
+ foreach(json_decode($c->prices) as $z)
|
|
|
|
|
+ {
|
|
|
|
|
+ $this->course_price_list[$z->course_subscription_id] = $z->price;
|
|
|
|
|
+ if ($z->price > 0)
|
|
|
|
|
+ $course_subscription_ids[] = $z->course_subscription_id;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $this->course_subscriptions = \App\Models\CourseSubscription::select('*')->whereIn('id', $course_subscription_ids)->where('enabled', true)->get();
|
|
|
|
|
+
|
|
|
|
|
+ /*
|
|
|
|
|
|
|
|
if ($this->course_course_id > 0) {
|
|
if ($this->course_course_id > 0) {
|
|
|
$c = \App\Models\Course::findOrFail($this->course_course_id);
|
|
$c = \App\Models\Course::findOrFail($this->course_course_id);
|
|
@@ -351,16 +379,18 @@ class Member extends Component
|
|
|
$this->course_price = 0;
|
|
$this->course_price = 0;
|
|
|
$this->course_subscription_price = 0;
|
|
$this->course_subscription_price = 0;
|
|
|
$this->course_exist = false;
|
|
$this->course_exist = false;
|
|
|
- }
|
|
|
|
|
|
|
+ }*/
|
|
|
} else {
|
|
} else {
|
|
|
$this->course_price = 0;
|
|
$this->course_price = 0;
|
|
|
$this->course_subscription_price = 0;
|
|
$this->course_subscription_price = 0;
|
|
|
$this->course_exist = false;
|
|
$this->course_exist = false;
|
|
|
}
|
|
}
|
|
|
- }*/
|
|
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
public function updatedCourseCourseType()
|
|
public function updatedCourseCourseType()
|
|
|
{
|
|
{
|
|
|
|
|
+ $this->course_level_id = '';
|
|
|
|
|
+ $this->course_frequency_id = '';
|
|
|
$this->course_course_id = null;
|
|
$this->course_course_id = null;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -630,7 +660,7 @@ class Member extends Component
|
|
|
{
|
|
{
|
|
|
|
|
|
|
|
$this->course_names = [];
|
|
$this->course_names = [];
|
|
|
- $allC = \App\Models\Course::orderBy('name')->get();
|
|
|
|
|
|
|
+ $allC = \App\Models\Course::where('type', $this->course_course_type)->orderBy('name')->get();
|
|
|
foreach ($allC as $c) {
|
|
foreach ($allC as $c) {
|
|
|
$cN = $c->name . " (" . $c->year . ")";
|
|
$cN = $c->name . " (" . $c->year . ")";
|
|
|
if (!in_array($cN, $this->course_names))
|
|
if (!in_array($cN, $this->course_names))
|
|
@@ -724,7 +754,7 @@ class Member extends Component
|
|
|
$this->loadMemberCertificates();
|
|
$this->loadMemberCertificates();
|
|
|
|
|
|
|
|
$this->courses = \App\Models\Course::select('id', 'name')->where('type', $this->course_course_type)->get();
|
|
$this->courses = \App\Models\Course::select('id', 'name')->where('type', $this->course_course_type)->get();
|
|
|
- $this->course_subscriptions = \App\Models\CourseSubscription::select('*')->where('enabled', true)->get();
|
|
|
|
|
|
|
+ // $this->course_subscriptions = \App\Models\CourseSubscription::select('*')->where('enabled', true)->get();
|
|
|
|
|
|
|
|
return view('livewire.member', ['datas' => $datas]);
|
|
return view('livewire.member', ['datas' => $datas]);
|
|
|
}
|
|
}
|
|
@@ -735,6 +765,8 @@ class Member extends Component
|
|
|
$c = \App\Models\Course::findOrFail($this->course_course_id);
|
|
$c = \App\Models\Course::findOrFail($this->course_course_id);
|
|
|
$this->course_price = formatPrice($c->price);
|
|
$this->course_price = formatPrice($c->price);
|
|
|
$this->course_subscription_price = formatPrice($c->subscription_price);
|
|
$this->course_subscription_price = formatPrice($c->subscription_price);
|
|
|
|
|
+ $this->course_date_from = $c->date_from;
|
|
|
|
|
+ $this->course_date_to = $c->date_to;
|
|
|
// Controllo se sono già iscritto la corso
|
|
// Controllo se sono già iscritto la corso
|
|
|
$this->course_exist = \App\Models\MemberCourse::where('course_id', $this->course_course_id)->where('member_id', $this->dataId)->count() > 0;
|
|
$this->course_exist = \App\Models\MemberCourse::where('course_id', $this->course_course_id)->where('member_id', $this->dataId)->count() > 0;
|
|
|
|
|
|
|
@@ -746,15 +778,20 @@ class Member extends Component
|
|
|
$this->course_months_list[] = $dt->format("m");
|
|
$this->course_months_list[] = $dt->format("m");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ $course_subscription_ids = [];
|
|
|
$this->course_price_list = [];
|
|
$this->course_price_list = [];
|
|
|
if ($c->prices != null)
|
|
if ($c->prices != null)
|
|
|
{
|
|
{
|
|
|
foreach(json_decode($c->prices) as $z)
|
|
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)
|
|
|
|
|
+ $course_subscription_ids[] = $z->course_subscription_id;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ $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;
|
|
@@ -871,10 +908,9 @@ class Member extends Component
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
$this->validate($rules);
|
|
$this->validate($rules);
|
|
|
- //$this->emit('setErrors');
|
|
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
try {
|
|
try {
|
|
|
|
|
|
|
|
$name = '';
|
|
$name = '';
|
|
@@ -889,6 +925,8 @@ class Member extends Component
|
|
|
|
|
|
|
|
$mother_docs = implode("|", $this->mother_document_files);
|
|
$mother_docs = implode("|", $this->mother_document_files);
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
$member = \App\Models\Member::create([
|
|
$member = \App\Models\Member::create([
|
|
|
'first_name' => strtoupper($this->first_name),
|
|
'first_name' => strtoupper($this->first_name),
|
|
|
'last_name' => strtoupper($this->last_name),
|
|
'last_name' => strtoupper($this->last_name),
|
|
@@ -934,6 +972,7 @@ class Member extends Component
|
|
|
'to_complete' => false,
|
|
'to_complete' => false,
|
|
|
'enabled' => $this->enabled
|
|
'enabled' => $this->enabled
|
|
|
]);
|
|
]);
|
|
|
|
|
+
|
|
|
session()->flash('success, Tesserato creato');
|
|
session()->flash('success, Tesserato creato');
|
|
|
updateMemberData($member->id);
|
|
updateMemberData($member->id);
|
|
|
$this->resetFields();
|
|
$this->resetFields();
|
|
@@ -1448,20 +1487,21 @@ class Member extends Component
|
|
|
$this->validate(['course_course_id' => 'required']);
|
|
$this->validate(['course_course_id' => 'required']);
|
|
|
try {
|
|
try {
|
|
|
|
|
|
|
|
- \App\Models\MemberCourse::create([
|
|
|
|
|
- 'member_id' => $this->dataId,
|
|
|
|
|
- 'course_id' => $this->course_course_id,
|
|
|
|
|
- 'date_from' => $this->course_date_from,
|
|
|
|
|
- 'date_to' => $this->course_date_to,
|
|
|
|
|
- 'course_subscription_id' => $this->course_course_subscription_id,
|
|
|
|
|
- 'status' => $this->course_status,
|
|
|
|
|
- 'subscribed' => false, // default non iscritto
|
|
|
|
|
- 'price' => currencyToDouble($this->course_price),
|
|
|
|
|
- 'subscription_price' => currencyToDouble($this->course_subscription_price),
|
|
|
|
|
- 'notes' => $this->course_note,
|
|
|
|
|
- 'months' => json_encode($this->course_months),
|
|
|
|
|
- 'when' => json_encode($this->course_when)
|
|
|
|
|
- ]);
|
|
|
|
|
|
|
+ $mc = new \App\Models\MemberCourse();
|
|
|
|
|
+ $mc->member_id = $this->dataId;
|
|
|
|
|
+ $mc->course_id = $this->course_course_id;
|
|
|
|
|
+ $mc->date_from = $this->course_date_from;
|
|
|
|
|
+ $mc->date_to = $this->course_date_to;
|
|
|
|
|
+ $mc->course_subscription_id = $this->course_course_subscription_id;
|
|
|
|
|
+ $mc->status = $this->course_status;
|
|
|
|
|
+ $mc->subscribed = false;
|
|
|
|
|
+ $mc->price = currencyToDouble($this->course_price);
|
|
|
|
|
+ $mc->subscription_price = currencyToDouble($this->course_subscription_price);
|
|
|
|
|
+ $mc->notes = $this->course_note;
|
|
|
|
|
+ $mc->months = json_encode($this->course_months);
|
|
|
|
|
+ $mc->when = json_encode($this->course_when);
|
|
|
|
|
+ $mc->save();
|
|
|
|
|
+
|
|
|
// Se il corso ha associato una categoria iscrivo anche al gruppo
|
|
// Se il corso ha associato una categoria iscrivo anche al gruppo
|
|
|
$c = \App\Models\Course::findOrFail($this->course_course_id);
|
|
$c = \App\Models\Course::findOrFail($this->course_course_id);
|
|
|
if ($c) {
|
|
if ($c) {
|
|
@@ -1473,6 +1513,56 @@ class Member extends Component
|
|
|
]);
|
|
]);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ // Creo i pagamenti in base alla tipologia
|
|
|
|
|
+ $r = \App\Models\CourseSubscription::findOrFail($this->course_course_subscription_id);
|
|
|
|
|
+
|
|
|
|
|
+ $start = $this->course_date_from;
|
|
|
|
|
+
|
|
|
|
|
+ // Creo il pagamento per l'iscrizione
|
|
|
|
|
+ $rate = new \App\Models\Rate();
|
|
|
|
|
+ $rate->member_id = $this->dataId;
|
|
|
|
|
+ $rate->member_course_id = $mc->id;
|
|
|
|
|
+ $rate->course_subscription_id = null;
|
|
|
|
|
+ $rate->price = currencyToDouble($this->course_subscription_price);
|
|
|
|
|
+ $rate->date = $start;
|
|
|
|
|
+ $rate->months = json_encode([]);
|
|
|
|
|
+ $rate->note = '';
|
|
|
|
|
+ $rate->status = 0;
|
|
|
|
|
+ $rate->is_subscription = true;
|
|
|
|
|
+ $rate->save();
|
|
|
|
|
+
|
|
|
|
|
+ $go = true;
|
|
|
|
|
+ while($go)
|
|
|
|
|
+ {
|
|
|
|
|
+
|
|
|
|
|
+ $mms = [];
|
|
|
|
|
+ $mms[] = date("n", strtotime($start));
|
|
|
|
|
+ for($jj=1; $jj<$r->months;$jj++)
|
|
|
|
|
+ {
|
|
|
|
|
+ $mms[] = date('n', strtotime("+" . $jj . " months", strtotime($start)));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $rate = new \App\Models\Rate();
|
|
|
|
|
+ $rate->member_id = $this->dataId;
|
|
|
|
|
+ $rate->member_course_id = $mc->id;
|
|
|
|
|
+ $rate->course_subscription_id = $this->course_course_subscription_id;
|
|
|
|
|
+ $rate->price = currencyToDouble($this->course_price);
|
|
|
|
|
+ $rate->date = $start;
|
|
|
|
|
+ $rate->months = json_encode($mms);
|
|
|
|
|
+ $rate->note = '';
|
|
|
|
|
+ $rate->status = 0;
|
|
|
|
|
+ $rate->save();
|
|
|
|
|
+
|
|
|
|
|
+ $start = date('Y-m-d', strtotime("+" . $r->months . " months", strtotime($start)));
|
|
|
|
|
+
|
|
|
|
|
+ if ($start > $this->course_date_to)
|
|
|
|
|
+ {
|
|
|
|
|
+ $go = false;
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
session()->flash('success, Corso creato');
|
|
session()->flash('success, Corso creato');
|
|
|
$this->resetCourseFields();
|
|
$this->resetCourseFields();
|
|
|
$this->addCourse = false;
|
|
$this->addCourse = false;
|
|
@@ -1496,6 +1586,7 @@ class Member extends Component
|
|
|
$c = \App\Models\Course::findOrFail($this->course_course_id);
|
|
$c = \App\Models\Course::findOrFail($this->course_course_id);
|
|
|
$this->course_name = $c->name . " (" . $c->year . ")";
|
|
$this->course_name = $c->name . " (" . $c->year . ")";
|
|
|
$this->course_level_id = $c->course_level_id;
|
|
$this->course_level_id = $c->course_level_id;
|
|
|
|
|
+ $this->course_course_type = $c->type;
|
|
|
$this->course_type_id = $c->course_type_id;
|
|
$this->course_type_id = $c->course_type_id;
|
|
|
$this->course_frequency_id = $c->course_frequency_id;
|
|
$this->course_frequency_id = $c->course_frequency_id;
|
|
|
|
|
|