|
@@ -6,6 +6,7 @@ use Livewire\Component;
|
|
|
use Livewire\Attributes\Url;
|
|
use Livewire\Attributes\Url;
|
|
|
use Livewire\WithFileUploads;
|
|
use Livewire\WithFileUploads;
|
|
|
use Livewire\WithPagination;
|
|
use Livewire\WithPagination;
|
|
|
|
|
+use Illuminate\Support\Facades\Log;
|
|
|
|
|
|
|
|
use DateTime;
|
|
use DateTime;
|
|
|
|
|
|
|
@@ -126,12 +127,15 @@ class Member extends Component
|
|
|
public $member_categories = array(), $category_category_id;
|
|
public $member_categories = array(), $category_category_id;
|
|
|
|
|
|
|
|
// Courses data
|
|
// Courses data
|
|
|
- public $member_courses = array(), $course_course_id, $course_date_from, $course_date_to, $course_when = array(), $addCourse, $updateCourse, $courseDataId, $course_course_subscription_id, $course_status, $course_note, $course_price, $course_subscription_price, $course_subscribed, $course_months = array(), $course_exist;
|
|
|
|
|
|
|
+ public $member_courses = array(), $course_course_id, $course_course_type, $course_date_from, $course_date_to, $course_when = array(), $addCourse, $updateCourse, $courseDataId, $course_course_subscription_id, $course_status, $course_note, $course_price, $course_subscription_price, $course_subscribed, $course_months = array(), $course_exist;
|
|
|
|
|
+
|
|
|
|
|
+ public $course_months_list = [];
|
|
|
|
|
+ public $course_price_list = [];
|
|
|
|
|
|
|
|
public $course_name, $course_level_id, $course_type_id, $course_frequency_id;
|
|
public $course_name, $course_level_id, $course_type_id, $course_frequency_id;
|
|
|
|
|
|
|
|
// Certificates data
|
|
// Certificates data
|
|
|
- public $member_certificates = array(), $certificate_type, $certificate_filename_old, $certificate_filename, $certificate_expire_date, $certificate_status, $addCertificate, $updateCertificate, $certificateDataId;
|
|
|
|
|
|
|
+ public $member_certificates = array(), $certificate_type, $certificate_filename_old, $certificate_filename, $certificate_expire_date, $certificate_status, $addCertificate, $updateCertificate, $certificateDataId, $cardCertificateId;
|
|
|
|
|
|
|
|
public $filterCard = [];
|
|
public $filterCard = [];
|
|
|
public $filterCategory = [];
|
|
public $filterCategory = [];
|
|
@@ -139,7 +143,7 @@ class Member extends Component
|
|
|
public $filterCertAgonistic = 0;
|
|
public $filterCertAgonistic = 0;
|
|
|
public $filterCertScaduto = 0;
|
|
public $filterCertScaduto = 0;
|
|
|
public $filterCertInScadenza = 0;
|
|
public $filterCertInScadenza = 0;
|
|
|
-
|
|
|
|
|
|
|
+ public $already_existing = false;
|
|
|
protected $rules = [
|
|
protected $rules = [
|
|
|
'first_name' => 'required',
|
|
'first_name' => 'required',
|
|
|
'last_name' => 'required',
|
|
'last_name' => 'required',
|
|
@@ -208,6 +212,7 @@ class Member extends Component
|
|
|
$this->age = '';
|
|
$this->age = '';
|
|
|
|
|
|
|
|
$this->error_fc = false;
|
|
$this->error_fc = false;
|
|
|
|
|
+ $this->already_existing = false;
|
|
|
|
|
|
|
|
$this->isSaving = false;
|
|
$this->isSaving = false;
|
|
|
|
|
|
|
@@ -238,6 +243,9 @@ class Member extends Component
|
|
|
public function resetCourseFields()
|
|
public function resetCourseFields()
|
|
|
{
|
|
{
|
|
|
$this->course_course_id = null;
|
|
$this->course_course_id = null;
|
|
|
|
|
+ $this->course_course_type = 'standard';
|
|
|
|
|
+ $this->course_months_list = [];
|
|
|
|
|
+ $this->course_price_list = [];
|
|
|
$this->course_when = array();
|
|
$this->course_when = array();
|
|
|
$this->course_when[] = array('day' => array(), 'from' => '', 'to' => '');
|
|
$this->course_when[] = array('day' => array(), 'from' => '', 'to' => '');
|
|
|
$this->course_date_from = null;
|
|
$this->course_date_from = null;
|
|
@@ -275,7 +283,6 @@ class Member extends Component
|
|
|
{
|
|
{
|
|
|
$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 != '') {
|
|
@@ -287,28 +294,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;
|
|
@@ -323,7 +328,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()
|
|
|
{
|
|
{
|
|
@@ -331,7 +336,36 @@ 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);
|
|
@@ -343,7 +377,7 @@ 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;
|
|
@@ -351,6 +385,20 @@ class Member extends Component
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public function updatedCourseCourseType()
|
|
|
|
|
+ {
|
|
|
|
|
+ $this->course_level_id = '';
|
|
|
|
|
+ $this->course_frequency_id = '';
|
|
|
|
|
+ $this->course_course_id = null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public function updatedCourseCourseSubscriptionId()
|
|
|
|
|
+ {
|
|
|
|
|
+ $this->course_price = 0;
|
|
|
|
|
+ if (isset($this->course_price_list[$this->course_course_subscription_id]))
|
|
|
|
|
+ $this->course_price = $this->course_price_list[$this->course_course_subscription_id];
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
public $documents = [];
|
|
public $documents = [];
|
|
|
|
|
|
|
|
public $father_documents = [];
|
|
public $father_documents = [];
|
|
@@ -454,9 +502,7 @@ class Member extends Component
|
|
|
|
|
|
|
|
$this->getCategories(\App\Models\Category::select('id', 'name')->where('parent_id', null)->get(), 0);
|
|
$this->getCategories(\App\Models\Category::select('id', 'name')->where('parent_id', null)->get(), 0);
|
|
|
|
|
|
|
|
- $this->courses = \App\Models\Course::select('id', 'name')->where('enabled', null)->get();
|
|
|
|
|
|
|
|
|
|
- $this->course_subscriptions = \App\Models\CourseSubscription::select('*')->where('enabled', true)->get();
|
|
|
|
|
|
|
|
|
|
// $this->getCourses(\App\Models\Course::select('id', 'name')->where('parent_id', null)->get(), 0);
|
|
// $this->getCourses(\App\Models\Course::select('id', 'name')->where('parent_id', null)->get(), 0);
|
|
|
|
|
|
|
@@ -612,7 +658,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))
|
|
@@ -705,6 +751,9 @@ class Member extends Component
|
|
|
$this->loadMemberCategories();
|
|
$this->loadMemberCategories();
|
|
|
$this->loadMemberCertificates();
|
|
$this->loadMemberCertificates();
|
|
|
|
|
|
|
|
|
|
+ $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();
|
|
|
|
|
+
|
|
|
return view('livewire.member', ['datas' => $datas]);
|
|
return view('livewire.member', ['datas' => $datas]);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -714,8 +763,29 @@ 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;
|
|
|
|
|
+
|
|
|
|
|
+ // 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();
|
|
|
} else {
|
|
} else {
|
|
|
$this->course_price = 0;
|
|
$this->course_price = 0;
|
|
|
$this->course_subscription_price = 0;
|
|
$this->course_subscription_price = 0;
|
|
@@ -784,11 +854,9 @@ class Member extends Component
|
|
|
'email' => 'required',
|
|
'email' => 'required',
|
|
|
'phone' => 'required',
|
|
'phone' => 'required',
|
|
|
'birth_nation_id' => 'required',
|
|
'birth_nation_id' => 'required',
|
|
|
- //'birth_place' => 'required',
|
|
|
|
|
'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',
|
|
|
'gender' => 'required'
|
|
'gender' => 'required'
|
|
|
];
|
|
];
|
|
@@ -796,6 +864,7 @@ class Member extends Component
|
|
|
if ($this->isBirthItaly) {
|
|
if ($this->isBirthItaly) {
|
|
|
$rules['birth_province_id'] = 'required';
|
|
$rules['birth_province_id'] = 'required';
|
|
|
$rules['birth_city_id'] = 'required';
|
|
$rules['birth_city_id'] = 'required';
|
|
|
|
|
+ $rules['fiscal_code'] = 'required';
|
|
|
} else {
|
|
} else {
|
|
|
$rules['birth_place'] = 'required';
|
|
$rules['birth_place'] = 'required';
|
|
|
}
|
|
}
|
|
@@ -825,15 +894,36 @@ class Member extends Component
|
|
|
|
|
|
|
|
$this->emit('setErrorMsg', $zzz);
|
|
$this->emit('setErrorMsg', $zzz);
|
|
|
|
|
|
|
|
- $existingMember = \App\Models\Member::where('fiscal_code', $this->fiscal_code)->first();
|
|
|
|
|
- if ($existingMember) {
|
|
|
|
|
- $this->addError('fiscal_code', 'Codice fiscale già presente.');
|
|
|
|
|
- return;
|
|
|
|
|
|
|
+ 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;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- $this->validate($rules);
|
|
|
|
|
- //$this->emit('setErrors');
|
|
|
|
|
|
|
+ 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 = '';
|
|
@@ -848,6 +938,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),
|
|
@@ -893,6 +985,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();
|
|
@@ -1022,11 +1115,9 @@ class Member extends Component
|
|
|
'email' => 'required',
|
|
'email' => 'required',
|
|
|
'phone' => 'required',
|
|
'phone' => 'required',
|
|
|
'birth_nation_id' => 'required',
|
|
'birth_nation_id' => 'required',
|
|
|
- //'birth_place' => 'required',
|
|
|
|
|
'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'
|
|
|
];
|
|
];
|
|
|
|
|
|
|
@@ -1036,6 +1127,8 @@ class Member extends Component
|
|
|
} else {
|
|
} else {
|
|
|
$rules['birth_place'] = 'required';
|
|
$rules['birth_place'] = 'required';
|
|
|
}
|
|
}
|
|
|
|
|
+ Log::info('isItaly', ['isItaly' => $this->isItaly]);
|
|
|
|
|
+ $this->isItaly = $this->checkIsItaly();
|
|
|
|
|
|
|
|
if ($this->isItaly) {
|
|
if ($this->isItaly) {
|
|
|
$rules['province_id'] = 'required';
|
|
$rules['province_id'] = 'required';
|
|
@@ -1062,7 +1155,27 @@ class Member extends Component
|
|
|
|
|
|
|
|
$this->emit('setErrorMsg', $zzz);
|
|
$this->emit('setErrorMsg', $zzz);
|
|
|
|
|
|
|
|
- $this->validate($rules);
|
|
|
|
|
|
|
+ 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 = '';
|
|
@@ -1150,7 +1263,7 @@ class Member extends Component
|
|
|
session()->flash('success', "Tesserato eliminato");
|
|
session()->flash('success', "Tesserato eliminato");
|
|
|
$this->emit('reload');
|
|
$this->emit('reload');
|
|
|
} catch (\Exception $e) {
|
|
} catch (\Exception $e) {
|
|
|
- session()->flash('error', 'Errore (' . $ex->getMessage() . ')');
|
|
|
|
|
|
|
+ session()->flash('error', 'Errore (' . $e->getMessage() . ')');
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -1172,7 +1285,7 @@ class Member extends Component
|
|
|
\App\Models\Member::find($id)->delete();
|
|
\App\Models\Member::find($id)->delete();
|
|
|
}
|
|
}
|
|
|
} catch (\Exception $e) {
|
|
} catch (\Exception $e) {
|
|
|
- session()->flash('error', 'Errore (' . $ex->getMessage() . ')');
|
|
|
|
|
|
|
+ session()->flash('error', 'Errore (' . $e->getMessage() . ')');
|
|
|
}
|
|
}
|
|
|
$this->multipleAction = '';
|
|
$this->multipleAction = '';
|
|
|
}
|
|
}
|
|
@@ -1374,7 +1487,7 @@ class Member extends Component
|
|
|
\App\Models\MemberCard::find($id)->delete();
|
|
\App\Models\MemberCard::find($id)->delete();
|
|
|
session()->flash('success', "Tesserato eliminato");
|
|
session()->flash('success', "Tesserato eliminato");
|
|
|
} catch (\Exception $e) {
|
|
} catch (\Exception $e) {
|
|
|
- session()->flash('error', 'Errore (' . $ex->getMessage() . ')');
|
|
|
|
|
|
|
+ session()->flash('error', 'Errore (' . $e->getMessage() . ')');
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -1407,20 +1520,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) {
|
|
@@ -1432,6 +1546,53 @@ 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;
|
|
@@ -1455,6 +1616,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;
|
|
|
|
|
|
|
@@ -1546,7 +1708,7 @@ class Member extends Component
|
|
|
\App\Models\MemberCourse::find($id)->delete();
|
|
\App\Models\MemberCourse::find($id)->delete();
|
|
|
session()->flash('success', "Corso eliminato");
|
|
session()->flash('success', "Corso eliminato");
|
|
|
} catch (\Exception $e) {
|
|
} catch (\Exception $e) {
|
|
|
- session()->flash('error', 'Errore (' . $ex->getMessage() . ')');
|
|
|
|
|
|
|
+ session()->flash('error', 'Errore (' . $e->getMessage() . ')');
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -1680,7 +1842,7 @@ class Member extends Component
|
|
|
\App\Models\MemberCertificate::find($id)->delete();
|
|
\App\Models\MemberCertificate::find($id)->delete();
|
|
|
session()->flash('success', "Tesserato eliminato");
|
|
session()->flash('success', "Tesserato eliminato");
|
|
|
} catch (\Exception $e) {
|
|
} catch (\Exception $e) {
|
|
|
- session()->flash('error', 'Errore (' . $ex->getMessage() . ')');
|
|
|
|
|
|
|
+ session()->flash('error', 'Errore (' . $e->getMessage() . ')');
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -1736,7 +1898,7 @@ class Member extends Component
|
|
|
\App\Models\MemberCategory::find($id)->delete();
|
|
\App\Models\MemberCategory::find($id)->delete();
|
|
|
session()->flash('success', "Associazione eliminata");
|
|
session()->flash('success', "Associazione eliminata");
|
|
|
} catch (\Exception $e) {
|
|
} catch (\Exception $e) {
|
|
|
- session()->flash('error', 'Errore (' . $ex->getMessage() . ')');
|
|
|
|
|
|
|
+ session()->flash('error', 'Errore (' . $e->getMessage() . ')');
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -1828,25 +1990,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;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -1906,21 +2062,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;
|
|
|
}
|
|
}
|
|
@@ -1930,7 +2081,7 @@ class Member extends Component
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
if ($mm->status == "2")
|
|
if ($mm->status == "2")
|
|
|
$this->suspendedMonths[] = $m;
|
|
$this->suspendedMonths[] = $m;
|
|
|
}
|
|
}
|
|
@@ -1986,22 +2137,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;
|
|
|
}
|
|
}
|
|
@@ -2012,7 +2158,6 @@ class Member extends Component
|
|
|
$class = 'orange half';
|
|
$class = 'orange half';
|
|
|
//$class .= $extraC;
|
|
//$class .= $extraC;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|