| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553 |
- <?php
- namespace App\Http\Livewire;
- use Livewire\Component;
- use Livewire\Attributes\Url;
- use Livewire\WithFileUploads;
- use Livewire\WithPagination;
- use DateTime;
- class Member extends Component
- {
- use WithPagination;
- protected $paginationTheme = 'bootstrap';
- protected $listeners = ['storeCategoryWithID' => 'storeCategoryWithID', 'setCourse' => 'setCourse', 'hideMsg' => 'hideMsg'];
- use WithFileUploads;
- public $sortField ='id';
- public $sortAsc = false;
- public $groupMsg = '';
- public function sortBy($field)
- {
- if($this->sortField === $field)
- {
- $this->sortAsc = ! $this->sortAsc;
- } else {
- $this->sortAsc = true;
- }
- $this->sortField = $field;
- }
- public $records, $first_name, $last_name, $image, $image_old, $status, $birth_place, $birth_city_id, $birth_province_id, $birth_nation_id, $birth_date, $gender, $fiscal_code, $address, $zip_code, $nation_id, $province_id, $city_id, $phone, $phone2, $phone3, $email, $enabled, $dataId, $update = false, $add = false;
- public $father_name, $mother_name, $father_email, $mother_email, $father_phone, $mother_phone, $father_fiscal_code, $mother_fiscal_code;
- public $document_type, $document_number, $document_from, $document_expire_date, $document_files, $document_files_old;
- public $selectId = 0;
- public $causalId = 0;
- public $error_fc = false;
- public $under18 = false;
- public $refreshAfter = 0;
- public $checkedAll = false;
- public $multipleIds = [];
- public $multipleAction = '';
- public $isItaly = true;
- public $isBirthItaly = true;
- public $showDetail = false;
- public $currentMember;
- public $currentStatus;
- public $age = '';
- public $cards = array();
- public $categories = array();
- public $courses = array();
- public $searchTxt;
- public $search;
- public $showReset = false;
- public $advanced = false;
- public $birthNations = array();
- public $birthProvinces = array();
- public $birthCities = array();
- public $active;
- // Card data
- public $member_cards = array(), $card_card_id, $card_number, $card_date, $card_accept_date, $card_status, $addCard, $updateCard, $cardDataId;
- // Categories data
- public $member_categories = array(), $category_category_id;
- // Courses data
- public $member_courses = array(), $course_course_id, $course_date_from, $course_date_to, $course_when = array(), $addCourse, $updateCourse, $courseDataId;
- // Certificates data
- public $member_certificates = array(), $certificate_type, $certificate_filename_old, $certificate_filename, $certificate_expire_date, $certificate_status, $addCertificate, $updateCertificate, $certificateDataId;
- public $filterCard = [];
- public $filterCategory = [];
- public $filterCertNormal = 0;
- public $filterCertAgonistic = 0;
- public $filterCertScaduto = 0;
- public $filterCertInScadenza = 0;
- protected $rules = [
- 'first_name' => 'required',
- 'last_name' => 'required',
- ];
- public function resetFields(){
- $this->dataId = -1;
- $this->first_name = '';
- $this->last_name = '';
- $this->status = '';
- $this->birth_city_id = null;
- $this->birth_province_id = null;
- $this->birth_nation_id = null;
- $this->birth_date = null;
- $this->birth_place = '';
- $this->father_name = '';
- $this->mother_name = '';
- $this->father_email = '';
- $this->mother_email = '';
- $this->father_phone = '';
- $this->mother_phone = '';
- $this->father_fiscal_code = '';
- $this->mother_fiscal_code = '';
- $this->gender = '';
- $this->fiscal_code = '';
- $this->address = '';
- $this->zip_code = '';
- $this->document_type = '';
- $this->document_number = '';
- $this->document_from = '';
- $this->document_expire_date = null;
- $this->document_files = array();
- //$this->nation_id = null;
- //$this->province_id = null;
- $this->nation_id = null;
- $this->province_id = null;
- $this->city_id = null;
- $this->phone = '';
- $this->phone2 = '';
- $this->phone3 = '';
- $this->email = '';
- $this->enabled = true;
- $this->under18 = false;
- $this->image = null;
- $this->error_fc = false;
- $this->emit('load-data-table');
- }
- public function resetCardFields(){
- $this->card_card_id = null;
- $this->card_number = '';
- $this->card_date = null;
- $this->card_accept_date = null;
- $this->card_status = 0;
- }
- public function resetCertificateFields(){
- $this->certificate_type = 'N';
- $this->certificate_filename = '';
- $this->certificate_filename_old = '';
- $this->certificate_expire_date = null;
- $this->certificate_status = 0;
- }
- public function resetCourseFields(){
- $this->course_course_id = null;
- $this->course_when = array();
- $this->course_when[] = array('day' => '', 'from' => '', 'to' => '');
- $this->course_date_from = null;
- $this->course_date_to = null;
- }
- public function executeMultipleAction(){
- if ($this->multipleAction == 'delete')
- $this->multipleDelete();
- }
- public function updatedImage()
- {
- $this->validate([
- 'image' => 'image|max:1024',
- ]);
- $this->image_old = '';
- }
- public $documents = [];
- public function removeDocument($idx)
- {
- unset($this->document_files[$idx]);
- }
- public function updatedDocuments()
- {
- foreach ($this->documents as $document)
- {
- $name = $document->getClientOriginalName(); // . '.'.$allegato->extension();
- $document->storeAs('public', $name);
- $this->document_files[] = $name;
- }
- $this->documents = [];
- }
- public function resetCategoryFields(){
- $this->category_category_id = null;
- }
- public function getCategories($records, $indentation)
- {
- foreach($records as $record)
- {
- // $this->categories[] = array('id' => $record->id, 'name' => str_repeat(" / ", $indentation) . $record->name);
- $this->categories[] = array('id' => $record->id, 'name' => $record->getTree());
- if(count($record->childs))
- $this->getCategories($record->childs, $indentation + 1);
- }
- }
- public function getCourses($records, $indentation)
- {
- foreach($records as $record)
- {
- // $this->categories[] = array('id' => $record->id, 'name' => str_repeat(" / ", $indentation) . $record->name);
- $this->courses[] = array('id' => $record->id, 'name' => $record->getTree());
- if(count($record->childs))
- $this->getCourses($record->childs, $indentation + 1);
- }
- }
- public function updatedBirthDate()
- {
- $date1 = new DateTime($this->birth_date);
- $date2 = new DateTime("now");
- $interval = $date1->diff($date2);
- $this->age = $interval->y . " anni";
- $this->under18 = $interval->y < 18;
- }
- public function mount()
- {
- if (isset($_GET["new"]))
- {
- $this->refreshAfter = 1;
- $this->add();
- }
- $this->cards = \App\Models\Card::select('id', 'name')->get();
- $this->categories = array();
- $this->getCategories(\App\Models\Category::select('id', 'name')->where('parent_id', null)->get(), 0);
- $this->courses = array();
- $this->getCourses(\App\Models\Course::select('id', 'name')->where('parent_id', null)->get(), 0);
- /*$this->nations = \App\Models\Nation::select('id', 'name')->orderBy('name')->get();
- $this->provinces = \App\Models\Province::where('nation_id', 1)->orderBy('name')->get();
- $this->cities = \App\Models\City::where('province_id', 178)->orderBy('name')->orderBy('name')->get();*/
- $c = \App\Models\Causal::where('type', 'IN')->where('money', true)->first();
- if ($c)
- $this->causalId = $c->id;
- /*$this->birthNations = \App\Models\Nation::select('id', 'name')->orderBy('name')->get();
- $this->birthProvinces = \App\Models\Province::where('nation_id', 1)->orderBy('name')->get();
- $this->birthCities = \App\Models\City::where('province_id', 178)->orderBy('name')->orderBy('name')->get();*/
- }
- public function updated()
- {
- // $this->emit('load-select');
- }
- public function hydrate()
- {
- $this->emit('load-select');
- }
- public function checkIsItaly()
- {
- $n = \App\Models\Nation::findOrFail($this->nation_id);
- $this->isItaly = $n->is_italy;
- }
- public function checkIsBirthItaly()
- {
- $n = \App\Models\Nation::findOrFail($this->birth_nation_id);
- $this->isBirthItaly = $n->is_italy;
- }
- /*public function loadProvinces()
- {
- $n = \App\Models\Nation::findOrFail($this->nation_id);
- $this->isItaly = $n->is_italy;
- $this->provinces = \App\Models\Province::where('nation_id', $this->nation_id)->orderBy('name')->get();
- $this->cities = array();
- $this->selectId++;
- }
- public function loadCities()
- {
- $this->cities = \App\Models\City::where('province_id', $this->province_id)->orderBy('name')->orderBy('name')->get();
- $this->selectId++;
- }
- public function loadBirthProvinces()
- {
- $n = \App\Models\Nation::findOrFail($this->birth_nation_id);
- $this->isBirthItaly = $n->is_italy;
- $this->birthProvinces = \App\Models\Province::where('nation_id', $this->birth_nation_id)->orderBy('name')->get();
- $this->birthCities = array();
- $this->selectId++;
- }
- public function loadBirthCities()
- {
- $this->birthCities = \App\Models\City::where('province_id', $this->birth_province_id)->get();
- $this->selectId++;
- }
- */
- public function search()
- {
- if ($this->searchTxt != '')
- {
- $this->search = $this->searchTxt;
- $this->showReset = true;
- }
- }
- public function resetSearch()
- {
- $this->showReset = false;
- $this->searchTxt = '';
- $this->search = $this->searchTxt;
- }
- public function advancedSearch()
- {
- $this->advanced = true;
- }
- public function advancedSearchCancel()
- {
- $this->filterCard = [];
- $this->filterCategory = [];
- $this->filterCertNormal = 0;
- $this->filterCertAgonistic = 0;
- $this->filterCertScaduto = 0;
- $this->filterCertInScadenza = 0;
- $this->advanced = false;
- }
- public function render()
- {
- $datas = [];
- if (!$this->advanced)
- {
- /*if ($this->search != '')
- $datas = \App\Models\Member::select('members.*') // , \DB::raw('SUM(records.id) As total'))
- ->where('first_name', 'LIKE', '%' . $this->search . '%')
- ->orWhere('last_name', 'LIKE', '%' . $this->search . '%')
- ->orWhere('email', 'LIKE', '%' . $this->search . '%');
- $this->records = \App\Models\Member::where('first_name', 'LIKE', '%' . $this->search . '%')->orWhere('last_name', 'LIKE', '%' . $this->search . '%')->orWhere('email', 'LIKE', '%' . $this->search . '%')->get();
- else*/
- $this->records = \App\Models\Member::get();
- //$datas = \App\Models\Member::select('members.*');
- }
- else
- {
- //$this->records = \App\Models\Member::where('id', '>', 0);
- $datas = \App\Models\Member::select('members.*')->where('id', '>', 0);
- if (sizeof($this->filterCard) > 0)
- {
- $card_ids = \App\Models\MemberCard::whereIn('card_id', $this->filterCard)->pluck('member_id');
- $this->records->whereIn('id', $card_ids);
- //$datas = $datas->whereIn('id', $card_ids);
- }
- if (sizeof($this->filterCategory) > 0)
- {
- $cats_ids = \App\Models\MemberCategory::whereIn('category_id', $this->filterCategory)->pluck('member_id');
- $this->records->whereIn('id', $cats_ids);
- //$datas = $datas->whereIn('id', $cats_ids);
- }
- $certs = [];
- if ($this->filterCertNormal > 0)
- {
- $normal = \App\Models\MemberCertificate::where('type', 'N')->pluck('member_id');
- $this->records->whereIn('id', $normal);
- //$datas = $datas->whereIn('id', $normal);;
- }
- if ($this->filterCertAgonistic > 0)
- {
- $agonistic = \App\Models\MemberCertificate::where('type', 'A')->pluck('member_id');
- $this->records->whereIn('id', $agonistic);
- //$datas = $datas->whereIn('id', $agonistic);
- }
- if ($this->filterCertScaduto > 0)
- {
- $scaduto = \App\Models\MemberCertificate::where('expire_date', '<', date("Y-m-d"))->pluck('member_id');
- $this->records->whereIn('id', $scaduto);
- //$datas = $datas->whereIn('id', $scaduto);
- }
- if ($this->filterCertInScadenza > 0)
- {
- $scaduto = \App\Models\MemberCertificate::whereBetween('expire_date', [date("Y-m-d"), date("Y-m-d", strtotime("+1 month"))])->pluck('member_id');
- $this->records->whereIn('id', $scaduto);
- //$datas = $datas->whereIn('id', $scaduto);
- }
- if (sizeof($certs) > 0)
- {
- $this->records->whereIn('id', $certs);
- }
- $this->records = $this->records->get();
- }
- /*
- foreach($this->records as $r)
- {
- $r->age = $r->getAge();
- $r->status = $r->isActive()["status"];
- $r->certificate = $r->hasCertificate()["status"];
- $r->state = $r->getStatus()["status"];
- }
- if ($this->sortAsc)
- $this->records = $this->records->sortBy($this->sortField);
- else
- $this->records = $this->records->sortByDesc($this->sortField);
- */
- //$datas = $datas->get(); // ->orderBy($this->sortField, $this->sortAsc ? 'ASC' : 'DESC')->paginate(10);
- //$this->records = $this->records->get();
- $this->loadMemberCards();
- $this->loadMemberCourses();
- $this->loadMemberCategories();
- $this->loadMemberCertificates();
- return view('livewire.member', ['datas' => $datas]);
- }
- public function loadMemberCards()
- {
- $this->member_cards = \App\Models\MemberCard::where('member_id', $this->dataId)->get();
- // return view('livewire.member');
- }
- public function loadMemberCourses()
- {
- $this->member_courses = \App\Models\MemberCourse::where('member_id', $this->dataId)->get();
- // return view('livewire.member');
- }
- public function loadMemberCategories()
- {
- $this->member_categories = \App\Models\MemberCategory::where('member_id', $this->dataId)->get();
- // return view('livewire.member');
- }
- public function loadMemberCertificates()
- {
- $this->member_certificates = \App\Models\MemberCertificate::where('member_id', $this->dataId)->orderBy('expire_date', 'DESC')->get();
- // return view('livewire.member');
- }
- public function showDetail($id)
- {
- $this->currentMember = \App\Models\Member::findOrFail($id);
- $this->currentStatus = $this->currentMember->getStatus();
- $this->showDetail = true;
- }
- public function add()
- {
- $this->emit('load-select');
- $this->emit('hide-search');
- $this->showDetail = false;
- $this->resetFields();
- $this->add = true;
- $this->update = false;
- }
- public function store($close)
- {
- $this->emit('load-select');
- $this->validate();
- try {
- $name = '';
- if ($this->image)
- {
- $name = md5($this->image . microtime()).'.'.$this->image->extension();
- $this->image->storeAs('public', $name);
- }
- $docs = implode("|", $this->document_files);
- $member = \App\Models\Member::create([
- 'first_name' => strtoupper($this->first_name),
- 'last_name' => strtoupper($this->last_name),
- 'status' => $this->status,
- 'birth_city_id' => $this->birth_city_id > 0 ? $this->birth_city_id : null,
- 'birth_province_id' => $this->birth_province_id > 0 ? $this->birth_province_id : null,
- 'birth_nation_id' => $this->birth_nation_id > 0 ? $this->birth_nation_id : null,
- 'birth_date' => $this->birth_date,
- 'birth_place' => $this->birth_place,
- 'father_name' => $this->father_name,
- 'mother_name' => $this->mother_name,
- 'father_email' => strtolower($this->father_email),
- 'mother_email' => strtolower($this->mother_email),
- 'father_phone' => $this->father_phone,
- 'mother_phone' => $this->mother_phone,
- 'father_fiscal_code' => $this->father_fiscal_code,
- 'mother_fiscal_code' => $this->mother_fiscal_code,
- 'document_type' => $this->document_type,
- 'document_number' => $this->document_number,
- 'document_from' => $this->document_from,
- 'document_expire_date' => $this->document_expire_date,
- 'document_files' => $docs,
- 'gender' => $this->gender,
- 'fiscal_code' => $this->fiscal_code,
- 'address' => $this->address,
- 'zip_code' => $this->zip_code,
- 'nation_id' => $this->nation_id > 0 ? $this->nation_id : null,
- 'province_id' => $this->province_id > 0 ? $this->province_id : null,
- 'city_id' => $this->city_id > 0 ? $this->city_id : null,
- 'phone' => $this->phone,
- 'phone2' => $this->phone2,
- 'phone3' => $this->phone3,
- 'email' => strtolower($this->email),
- 'image' => $name,
- 'enabled' => $this->enabled
- ]);
- session()->flash('success, Tesserato creato');
- $this->resetFields();
- if ($close)
- {
- $this->add = false;
- }
- else
- {
- $this->edit($member->id);
- }
- } catch (\Exception $ex) {
- session()->flash('error','Errore (' . $ex->getMessage() . ')');
- }
- }
- public function duplicate($id){
- $member = \App\Models\Member::findOrFail($id);
- $newMember = $member->replicate();
- $newMember->save();
- $this->edit($newMember->id);
- }
- public function edit($id){
- $this->showDetail = false;
- $this->emit('hide-search');
- try {
- $member = \App\Models\Member::findOrFail($id);
- if( !$member) {
- session()->flash('error','Tesserato non trovato');
- } else {
- $this->first_name = $member->first_name;
- $this->last_name = $member->last_name;
- $this->status = $member->status;
- $this->birth_city_id = $member->birth_city_id;
- $this->birth_province_id = $member->birth_province_id;
- $this->birth_nation_id = $member->birth_nation_id;
- $this->birth_date = $member->birth_date;
- $this->birth_place = $member->birth_place;
- $this->father_name = $member->father_name;
- $this->mother_name = $member->mother_name;
- $this->father_email = strtolower($member->father_email);
- $this->mother_email = strtolower($member->mother_email);
- $this->father_phone = $member->father_phone;
- $this->mother_phone = $member->mother_phone;
- $this->father_fiscal_code = $member->father_fiscal_code;
- $this->mother_fiscal_code = $member->mother_fiscal_code;
- $this->document_type = $member->document_type;
- $this->document_number = $member->document_number;
- $this->document_from = $member->document_from;
- $this->document_expire_date = $member->document_expire_date;
- $this->document_files = explode("|", $member->document_files);
- $this->gender = $member->gender;
- $this->fiscal_code = $member->fiscal_code;
- $this->address = $member->address;
- $this->zip_code = $member->zip_code;
- $this->nation_id = $member->nation_id;
- $this->province_id = $member->province_id;
- $this->city_id = $member->city_id;
- $this->phone = $member->phone;
- $this->phone2 = $member->phone2;
- $this->phone3 = $member->phone3;
- $this->email = strtolower($member->email);
- $this->image_old = $member->image;
- $this->enabled = $member->enabled;
- $this->dataId = $member->id;
- $this->active = $member->getStatus();
- $date1 = new DateTime($this->birth_date);
- $date2 = new DateTime("now");
- $interval = $date1->diff($date2);
- $this->age = $interval->y . " anni";
- $this->under18 = $interval->y < 18;
- //$this->provinces = \App\Models\Province::where('nation_id', $this->nation_id)->get();
- //$this->cities = \App\Models\City::where('province_id', $this->province_id)->get();
- //$this->birthProvinces = \App\Models\Province::where('nation_id', $this->birth_nation_id)->get();
- //$this->birthCities = \App\Models\City::where('province_id', $this->birth_province_id)->get();
- $this->update = true;
- $this->add = false;
- $this->emit('load-select');
- $this->emit('load-provinces', $this->nation_id, 'provinceClass');
- $this->emit('load-provinces', $this->birth_nation_id, 'provinceBirthClass');
- $this->emit('load-cities', $this->province_id, 'cityClass');
- $this->emit('load-cities', $this->birth_province_id, 'cityBirthClass');
- }
- } catch (\Exception $ex) {
- session()->flash('error','Errore (' . $ex->getMessage() . ')');
- }
- }
- public function update($close)
- {
- $this->emit('load-select');
- $this->validate();
- try {
- $name = '';
- if ($this->image)
- {
- $name = md5($this->image . microtime()).'.'.$this->image->extension();
- $this->image->storeAs('public', $name);
- }
- $docs = implode("|", $this->document_files);
- \App\Models\Member::whereId($this->dataId)->update([
- 'first_name' => strtoupper($this->first_name),
- 'last_name' => strtoupper($this->last_name),
- 'status' => $this->status,
- 'birth_city_id' => $this->birth_city_id > 0 ? $this->birth_city_id : null,
- 'birth_province_id' => $this->birth_province_id > 0 ? $this->birth_province_id : null,
- 'birth_nation_id' => $this->birth_nation_id > 0 ? $this->birth_nation_id : null,
- 'birth_date' => $this->birth_date,
- 'birth_place' => $this->birth_place,
- 'father_name' => $this->father_name,
- 'mother_name' => $this->mother_name,
- 'father_email' => strtolower($this->father_email),
- 'mother_email' => strtolower($this->mother_email),
- 'father_phone' => $this->father_phone,
- 'mother_phone' => $this->mother_phone,
- 'father_fiscal_code' => $this->father_fiscal_code,
- 'mother_fiscal_code' => $this->mother_fiscal_code,
- 'document_type' => $this->document_type,
- 'document_number' => $this->document_number,
- 'document_from' => $this->document_from,
- 'document_expire_date' => $this->document_expire_date,
- 'document_files' => $docs,
- 'gender' => $this->gender,
- 'fiscal_code' => $this->fiscal_code,
- 'address' => $this->address,
- 'zip_code' => $this->zip_code,
- 'nation_id' => $this->nation_id > 0 ? $this->nation_id : null,
- 'province_id' => $this->province_id > 0 ? $this->province_id : null,
- 'city_id' => $this->city_id > 0 ? $this->city_id : null,
- 'image' => $name != '' ? $name : $this->image_old,
- 'phone' => $this->phone,
- 'phone2' => $this->phone2,
- 'phone3' => $this->phone3,
- 'email' => strtolower($this->email),
- 'enabled' => $this->enabled
- ]);
- session()->flash('success','Tesserato aggiornato');
- if ($close)
- {
- $this->resetFields();
- $this->update = false;
- }
- } catch (\Exception $ex) {
- session()->flash('error','Errore (' . $ex->getMessage() . ')');
- }
- }
- public function cancel()
- {
- $this->add = false;
- $this->update = false;
- $this->showDetail = false;
- $this->resetFields();
- }
- public function delete($id)
- {
- try{
- \App\Models\Member::find($id)->delete();
- session()->flash('success',"Tesserato eliminato");
- }catch(\Exception $e){
- session()->flash('error','Errore (' . $ex->getMessage() . ')');
- }
- }
- public function checkUncheckAll()
- {
- if (!$this->checkedAll)
- {
- $this->multipleIds = array();
- }
- else
- {
- foreach($this->records as $r)
- {
- $this->multipleIds[] = $r->id;
- }
- }
- }
- public function multipleDelete()
- {
- try{
- foreach($this->multipleIds as $id)
- {
- \App\Models\Member::find($id)->delete();
- }
- }catch(\Exception $e){
- session()->flash('error','Errore (' . $ex->getMessage() . ')');
- }
- $this->multipleAction = '';
- }
- // Card
- public function addCard()
- {
- $this->resetCardFields();
- $this->addCard = true;
- $this->updateCard = false;
- }
- public function storeCard()
- {
- $this->validate(['card_card_id' => 'required']);
- try {
- // in base alla card selezionata calcolo la scadenza
- $expire_date = null;
- if ($this->card_date != '')
- {
- $y = date("Y", strtotime($this->card_date));
- $card = \App\Models\Card::findOrFail($this->card_card_id);
- if ($card->next_day_expire > 0 && $card->next_month_expire > 0)
- {
- $m = strlen($card->next_month_expire) == 1 ? ('0' . $card->next_month_expire) : $card->next_month_expire;
- if (date("md", strtotime($this->card_date)) > ($m . $card->next_day_expire))
- $y += 1;
- $next_exp = date($y . "-" . $m . "-" . $card->next_day_expire);
- if ($next_exp > $this->card_date)
- {
- $expire_date = $next_exp;
- }
- else
- $expire_date = date($y . "-" . $card->next_month_expire . "-" . $card->next_day_expire, strtotime(' + 1 years'));
- }
- else
- {
- if ($card->one_year_expire)
- {
- $expire_date = date("Y-m-d", strtotime($this->card_date . ' + 1 years'));
- }
- }
- }
- \App\Models\MemberCard::create([
- 'member_id' => $this->dataId,
- 'card_id' => $this->card_card_id,
- 'number' => $this->card_number,
- 'date' => $this->card_date,
- 'accept_date' => $this->card_accept_date != '' ? $this->card_accept_date : $this->card_date,
- 'expire_date' => $expire_date,
- 'status' => $this->card_status
- ]);
- session()->flash('success, Tesserato creato');
- $this->resetCardFields();
- $this->addCard = false;
- } catch (\Exception $ex) {
- session()->flash('error','Errore (' . $ex->getMessage() . ')');
- }
- }
- public function editCard($id){
- try {
- $memberCard = \App\Models\MemberCard::findOrFail($id);
- if( !$memberCard) {
- session()->flash('error','Tesserato non trovato');
- } else {
- $this->card_card_id = $memberCard->card_id;
- $this->card_number = $memberCard->number;
- $this->card_date = $memberCard->date;
- $this->card_accept_date = $memberCard->accept_date;
- $this->card_status = $memberCard->status;
- $this->cardDataId = $memberCard->id;
- $this->updateCard = true;
- $this->addCard = false;
- }
- } catch (\Exception $ex) {
- session()->flash('error','Errore (' . $ex->getMessage() . ')');
- }
- }
- public function updateCard()
- {
- //$this->validate();
- $this->validate(['card_card_id' => 'required']);
- try {
- // in base alla card selezionata calcolo la scadenza
- $expire_date = null;
- if ($this->card_date != '')
- {
- $card = \App\Models\Card::findOrFail($this->card_card_id);
- if ($card->next_day_expire > 0 && $card->next_month_expire > 0)
- {
- $y = date("Y", strtotime($this->card_date));
- $m = strlen($card->next_month_expire) == 1 ? ('0' . $card->next_month_expire) : $card->next_month_expire;
- $next_exp = date($y . "-" . $m . "-" . $card->next_day_expire);
- if ($next_exp > $this->card_date)
- {
- $expire_date = $next_exp;
- }
- else
- $expire_date = date($y . "-" . $card->next_month_expire . "-" . $card->next_day_expire, strtotime(' + 1 years'));
- }
- else
- {
- if ($card->one_year_expire)
- {
- $expire_date = date("Y-m-d", strtotime($this->card_date . ' + 1 years'));
- }
- }
- }
- \App\Models\MemberCard::whereId($this->cardDataId)->update([
- 'member_id' => $this->dataId,
- 'card_id' => $this->card_card_id,
- 'number' => $this->card_number,
- 'date' => $this->card_date,
- 'accept_date' => $this->card_accept_date != '' ? $this->card_accept_date : $this->card_date,
- 'expire_date' => $expire_date,
- 'status' => $this->card_status
- ]);
- session()->flash('success','Tesserato aggiornato');
- $this->resetCardFields();
- $this->updateCard = false;
- } catch (\Exception $ex) {
- session()->flash('error','Errore (' . $ex->getMessage() . ')');
- }
- }
- public function cancelCard()
- {
- $this->addCard = false;
- $this->updateCard = false;
- $this->resetCardFields();
- }
- public function deleteCard($id)
- {
- try{
- \App\Models\MemberCard::find($id)->delete();
- session()->flash('success',"Tesserato eliminato");
- }catch(\Exception $e){
- session()->flash('error','Errore (' . $ex->getMessage() . ')');
- }
- }
- // Courses
- public function addCourse()
- {
- $this->resetCourseFields();
- $this->addCourse = true;
- $this->updateCourse = false;
- }
- public function storeCourse()
- {
- $this->validate(['course_course_id' => 'required']);
- 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,
- 'when' => json_encode($this->course_when)
- ]);
- session()->flash('success, Corso creato');
- $this->resetCourseFields();
- $this->addCourse = false;
- } catch (\Exception $ex) {
- session()->flash('error','Errore (' . $ex->getMessage() . ')');
- }
- }
- public function editCourse($id){
- try {
- $memberCourse = \App\Models\MemberCourse::findOrFail($id);
- if( !$memberCourse) {
- session()->flash('error','Corso non trovato');
- } else {
- $this->course_course_id = $memberCourse->course_id;
- $this->course_date_from = $memberCourse->date_from;
- $this->course_date_to = $memberCourse->date_to;
- $this->course_when = json_decode($memberCourse->when);
- $this->courseDataId = $memberCourse->id;
- $this->updateCourse = true;
- $this->addCourse = false;
- }
- } catch (\Exception $ex) {
- session()->flash('error','Errore (' . $ex->getMessage() . ')');
- }
- }
- public function updateCourse()
- {
- //$this->validate();
- $this->validate(['course_course_id' => 'required']);
- try {
- \App\Models\MemberCourse::whereId($this->courseDataId)->update([
- 'member_id' => $this->dataId,
- 'course_id' => $this->course_course_id,
- 'date_from' => $this->course_date_from,
- 'date_to' => $this->course_date_to,
- 'when' => json_encode($this->course_when)
- ]);
- session()->flash('success','Corso aggiornato');
- $this->resetCardFields();
- $this->updateCourse = false;
- } catch (\Exception $ex) {
- session()->flash('error','Errore (' . $ex->getMessage() . ')');
- }
- }
- public function cancelCourse()
- {
- $this->addCourse = false;
- $this->updateCourse = false;
- $this->resetCourseFields();
- }
- public function deleteCourse($id)
- {
- try{
- \App\Models\MemberCourse::find($id)->delete();
- session()->flash('success',"Corso eliminato");
- }catch(\Exception $e){
- session()->flash('error','Errore (' . $ex->getMessage() . ')');
- }
- }
- public function addRow()
- {
- $this->course_when[] = array('day' => '', 'from' => '', 'to' => '');
- }
- public function delRow($idx)
- {
- unset($this->course_when[$idx]);
- }
- // Certificates
- public function addCertificate()
- {
- $this->resetCertificateFields();
- $this->addCertificate = true;
- $this->updateCertificate = false;
- }
- public function storeCertificate()
- {
- $this->validate(['certificate_expire_date' => 'required']);
- // $this->validate();
- try {
- $name = '';
- try{
- if ($this->certificate_filename)
- {
- $name = md5($this->certificate_filename . microtime()).'.'.$this->certificate_filename->extension();
- $this->certificate_filename->storeAs('public', $name);
- }
- } catch (\Exception $ex) {
- //session()->flash('error','Errore (' . $ex->getMessage() . ')');
- }
- if ($this->dataId > -1)
- {
- \App\Models\MemberCertificate::create([
- 'member_id' => $this->dataId,
- 'type' => $this->certificate_type,
- 'filename' => $name,
- 'expire_date' => $this->certificate_expire_date,
- 'status' => $this->certificate_status
- ]);
- }
- /*else
- {
- $this->certificateTmp = new \App\Models\MemberCertificate();
- $this->certificateTmp->type = $this->certificate_type;
- $this->certificateTmp->filename = $name;
- $this->certificateTmp->expire_date = $this->certificate_expire_date;
- $this->certificateTmp->status = $this->certificate_status;
- $this->certificateTmp->status = $this->certificate_status;
- // s $this->member_certificates[] = $certificateTmp;
- }*/
- session()->flash('success, Tesserato creato');
- $this->resetCertificateFields();
- $this->addCertificate = false;
- } catch (\Exception $ex) {
- session()->flash('error','Errore (' . $ex->getMessage() . ')');
- }
- }
- public function editCertificate($id){
- try {
- $memberCertificate = \App\Models\MemberCertificate::findOrFail($id);
- if( !$memberCertificate) {
- session()->flash('error','Tesserato non trovato');
- } else {
- $this->certificate_type = $memberCertificate->type;
- $this->certificate_filename_old = $memberCertificate->filename;
- $this->certificate_expire_date = $memberCertificate->expire_date;
- $this->certificate_status = $memberCertificate->status;
- $this->cardCertificateId = $memberCertificate->id;
- $this->updateCertificate = true;
- $this->addCertificate = false;
- }
- } catch (\Exception $ex) {
- session()->flash('error','Errore (' . $ex->getMessage() . ')');
- }
- }
- public function updateCertificate()
- {
- $this->validate(['certificate_expire_date' => 'required']);
- try {
- $name = '';
- try{
- if ($this->certificate_filename)
- {
- $name = md5($this->certificate_filename . microtime()).'.'.$this->certificate_filename->extension();
- $this->certificate_filename->storeAs('public', $name);
- }
- } catch (\Exception $ex) {
- //session()->flash('error','Errore (' . $ex->getMessage() . ')');
- }
- \App\Models\MemberCertificate::whereId($this->cardCertificateId)->update([
- 'member_id' => $this->dataId,
- 'type' => $this->certificate_type,
- 'filename' => $name != '' ? $name : $this->certificate_filename_old,
- 'expire_date' => $this->certificate_expire_date,
- 'status' => $this->certificate_status
- ]);
- session()->flash('success','Tesserato aggiornato');
- $this->resetCertificateFields();
- $this->updateCertificate = false;
- } catch (\Exception $ex) {
- session()->flash('error','Errore (' . $ex->getMessage() . ')');
- }
- }
- public function cancelCertificate()
- {
- $this->addCertificate = false;
- $this->updateCertificate = false;
- $this->resetCertificateFields();
- }
- public function deleteCertificate($id)
- {
- try{
- \App\Models\MemberCertificate::find($id)->delete();
- session()->flash('success',"Tesserato eliminato");
- }catch(\Exception $e){
- session()->flash('error','Errore (' . $ex->getMessage() . ')');
- }
- }
- // Gruppi di appartenenza
- public function storeCategory()
- {
- $this->validate(['category_category_id' => 'required']);
- try {
- \App\Models\MemberCategory::create([
- 'member_id' => $this->dataId,
- 'category_id' => $this->category_category_id,
- 'date' => \Carbon\Carbon::now()
- ]);
- session()->flash('success, Associazione creato');
- $this->resetCategoryFields();
- $this->addCard = false;
- } catch (\Exception $ex) {
- session()->flash('error','Errore (' . $ex->getMessage() . ')');
- }
- }
- public function hideMsg()
- {
- $this->groupMsg = '';
- }
- public function storeCategoryWithID($id)
- {
- $this->groupMsg = '';
- try {
- if (\App\Models\MemberCategory::where('member_id', $this->dataId)->where('category_id', $id)->first())
- {
- $this->groupMsg = '<br>Attenzione, questo corso è stato già inserito';
- }
- else
- {
- \App\Models\MemberCategory::create([
- 'member_id' => $this->dataId,
- 'category_id' => $id,
- 'date' => \Carbon\Carbon::now()
- ]);
- session()->flash('success, Associazione creato');
- $this->resetCategoryFields();
- $this->addCard = false;
- }
- } catch (\Exception $ex) {
- session()->flash('error','Errore (' . $ex->getMessage() . ')');
- }
- }
- public function deleteCategory($id)
- {
- try{
- \App\Models\MemberCategory::find($id)->delete();
- session()->flash('success',"Associazione eliminata");
- }catch(\Exception $e){
- session()->flash('error','Errore (' . $ex->getMessage() . ')');
- }
- }
- public function setCourse($id)
- {
- $this->course_course_id = $id;
- }
- public function getNation($nation)
- {
- if ($nation > 0)
- {
- $ret = \App\Models\Nation::findOrFail($nation);
- return $ret->name;
- }
- return "";
- }
- public function getProvince($province)
- {
- if ($province > 0)
- {
- $ret = \App\Models\Province::findOrFail($province);
- return $ret->name;
- }
- return "";
- }
- public function getCity($city)
- {
- if ($city > 0)
- {
- $ret = \App\Models\City::findOrFail($city);
- return $ret->name;
- }
- return "";
- }
- public function getFiscalCode()
- {
- $this->error_fc = false;
- $cf = new codicefiscale();
- $cf->setDateSeparator('-');
- if ($this->first_name != '' && $this->last_name != '' && $this->birth_date != '' && $this->gender != '' && $this->birth_city_id > 0)
- {
- $code = '';
- if ($this->birth_city_id > 0)
- {
- $code = \App\Models\City::findOrFail($this->birth_city_id)->code;
- }
- $codice = $cf->calcola($this->first_name, $this->last_name, $this->birth_date, $this->gender, $code);
- $this->fiscal_code = $codice;
- }
- else
- $this->error_fc = true;
- }
- }
- class codicefiscale {
- /**
- * Array delle consonanti
- */
- protected $_consonanti = array(
- 'B', 'C', 'D', 'F', 'G', 'H', 'J', 'K',
- 'L', 'M', 'N', 'P', 'Q', 'R', 'S', 'T',
- 'V', 'W', 'X', 'Y', 'Z'
- );
- /**
- * Array delle vocali
- */
- protected $_vocali = array(
- 'A', 'E', 'I', 'O', 'U'
- );
- /**
- * Array per il calcolo della lettera del mese
- * Al numero del mese corrisponde una lettera
- */
- protected $_mesi = array(
- 1 => 'A', 2 => 'B', 3 => 'C', 4 => 'D', 5 => 'E',
- 6 => 'H', 7 => 'L', 8 => 'M', 9 => 'P', 10 => 'R',
- 11 => 'S', 12 => 'T'
- );
- protected $_pari = array(
- '0' => 0, '1' => 1, '2' => 2, '3' => 3, '4' => 4,
- '5' => 5, '6' => 6, '7' => 7, '8' => 8, '9' => 9,
- 'A' => 0, 'B' => 1, 'C' => 2, 'D' => 3, 'E' => 4,
- 'F' => 5, 'G' => 6, 'H' => 7, 'I' => 8, 'J' => 9,
- 'K' => 10, 'L' => 11, 'M' => 12, 'N' => 13, 'O' => 14,
- 'P' => 15, 'Q' => 16, 'R' => 17, 'S' => 18, 'T' => 19,
- 'U' => 20, 'V' => 21, 'W' => 22, 'X' => 23, 'Y' => 24,
- 'Z' => 25
- );
- protected $_dispari = array(
- '0' => 1, '1' => 0, '2' => 5, '3' => 7, '4' => 9,
- '5' => 13, '6' => 15, '7' => 17, '8' => 19, '9' => 21,
- 'A' => 1, 'B' => 0, 'C' => 5, 'D' => 7, 'E' => 9,
- 'F' => 13, 'G' => 15, 'H' => 17, 'I' => 19, 'J' => 21,
- 'K' => 2, 'L' => 4, 'M' => 18, 'N' => 20, 'O' => 11,
- 'P' => 3, 'Q' => 6, 'R' => 8, 'S' => 12, 'T' => 14,
- 'U' => 16, 'V' => 10, 'W' => 22, 'X' => 25, 'Y' => 24,
- 'Z' => 23
- );
- protected $_controllo = array(
- '0' => 'A', '1' => 'B', '2' => 'C', '3' => 'D',
- '4' => 'E', '5' => 'F', '6' => 'G', '7' => 'H',
- '8' => 'I', '9' => 'J', '10' => 'K', '11' => 'L',
- '12' => 'M', '13' => 'N', '14' => 'O', '15' => 'P',
- '16' => 'Q', '17' => 'R', '18' => 'S', '19' => 'T',
- '20' => 'U', '21' => 'V', '22' => 'W', '23' => 'X',
- '24' => 'Y', '25' => 'Z'
- );
- /**
- * Stringa di errore
- */
- protected $_error = null;
- /**
- * Separatore per la data di nascita
- */
- protected $_dateSeparator = '/';
- /**
- * Percorso del file del database SQLite
- * dei codici catastali
- */
- protected $_dbCatastali = null;
- /**
- * Trasforma la stringa passata in un array di lettere
- * e lo incrocia con un ulteriore array
- */
- protected function _getLettere($string, array $haystack) {
- $letters = array();
- foreach(str_split($string) as $needle) {
- if (in_array($needle, $haystack)) {
- $letters[] = $needle;
- }
- }
- return $letters;
- }
- /**
- * Ritorna un array con le vocali di una data stringa
- */
- protected function _getVocali($string) {
- return $this->_getLettere($string, $this->_vocali);
- }
- /**
- * Ritorna un array con le consonanti di una data stringa
- */
- protected function _getConsonanti($string) {
- return $this->_getLettere($string, $this->_consonanti);
- }
- /**
- * Pulisce la stringa filtrando tutti i caratteri che
- * non sono lettere. Lo switch $toupper se impostato a TRUE
- * converte la stringa risultante in MAIUSCOLO.
- */
- protected function _sanitize($string, $toupper = true) {
- $result = preg_replace('/[^A-Za-z]*/', '', $string);
- return ($toupper) ? strtoupper($result) : $result;
- }
- /**
- * Se la stringa passata a funzione e' costituita
- * da meno di 3 caratteri, rimpiazza le lettere
- * mancanti con la lettera X.
- */
- protected function _addMissingX($string) {
- $code = $string;
- while(strlen($code) < 3) {
- $code .= 'X';
- }
- return $code;
- }
- /**
- * Ottiene il codice identificativo del nome
- */
- protected function _calcolaNome($string) {
- $nome = $this->_sanitize($string);
- $code = '';
- // Se il nome inserito e' piu' corto di 3 lettere
- // si aggiungono tante X quanti sono i caratteri
- // mancanti.
- if (strlen($nome) < 3) {
- return $this->_addMissingX($nome);
- }
- $nome_cons = $this->_getConsonanti($nome);
- // Se le consonanti contenute nel nome sono minori
- // o uguali a 3 vengono considerate nell'ordine in cui
- // compaiono.
- if (count($nome_cons) <= 3) {
- $code = implode('', $nome_cons);
- } else {
- // Se invece abbiamo almeno 4 consonanti, prendiamo
- // la prima, la terza e la quarta.
- for($i=0; $i<4; $i++) {
- if ($i == 1) continue;
- if (!empty($nome_cons[$i])) {
- $code .= $nome_cons[$i];
- }
- }
- }
- // Se compaiono meno di 3 consonanti nel nome, si
- // utilizzano le vocali, nell'ordine in cui compaiono
- // nel nome.
- if (strlen($code) < 3) {
- $nome_voc = $this->_getVocali($nome);
- while (strlen($code) < 3) {
- $code .= array_shift($nome_voc);
- }
- }
- return $code;
- }
- protected function _calcolaCognome($string) {
- $cognome = $this->_sanitize($string);
- $code = '';
- // Se il cognome inserito e' piu' corto di 3 lettere
- // si aggiungono tante X quanti sono i caratteri
- // mancanti.
- if (strlen($cognome) < 3) {
- return $this->_addMissingX($cognome);
- }
- $cognome_cons = $this->_getConsonanti($cognome);
- // Per il calcolo del cognome si prendono le prime
- // 3 consonanti.
- for ($i=0; $i<3; $i++) {
- if (array_key_exists($i, $cognome_cons)) {
- $code .= $cognome_cons[$i];
- }
- }
- // Se le consonanti non bastano, vengono prese
- // le vocali nell'ordine in cui compaiono.
- if (strlen($code) < 3) {
- $cognome_voc = $this->_getVocali($cognome);
- while (strlen($code) < 3) {
- $code .= array_shift($cognome_voc);
- }
- }
- return $code;
- }
- /**
- * Imposta il separatore di data ( default: / )
- */
- public function setDateSeparator($char) {
- $this->_dateSeparator = $char;
- return $this;
- }
- /**
- * Ritorna la parte di codice fiscale corrispondente
- * alla data di nascita del soggetto (Forma: AAMGG)
- */
- protected function _calcolaDataNascita($data, $sesso) {
- $dn = explode($this->_dateSeparator, $data);
- $giorno = (int) @$dn[2];
- $mese = (int) @$dn[1];
- $anno = (int) @$dn[0];
- // Le ultime due cifre dell'anno di nascita
- $aa = substr($anno, -2);
- // La lettera corrispondente al mese di nascita
- $mm = $this->_mesi[$mese];
- // Il giorno viene calcolato a seconda del sesso
- // del soggetto di cui si calcola il codice:
- // se e' Maschio si mette il giorno reale, se e'
- // Femmina viene aggiungo 40 a questo numero.
- $gg = (strtoupper($sesso) == 'M') ? $giorno : ($giorno + 40);
- // Bug #1: Thanks to Luca
- if (strlen($gg) < 2) $gg = '0' . $gg;
- return $aa . $mm . $gg;
- }
- /**
- * Ritorna la cifra di controllo sulla base dei
- * 15 caratteri del codice fiscale calcolati.
- */
- protected function _calcolaCifraControllo($codice) {
- $code = str_split($codice);
- $sum = 0;
- for($i=1; $i <= count($code); $i++) {
- $cifra = $code[$i-1];
- $sum += ($i % 2) ? $this->_dispari[$cifra] : $this->_pari[$cifra];
- }
- $sum %= 26;
- return $this->_controllo[$sum];
- }
- /**
- * Imposta il messaggio di errore
- */
- protected function _setError($string) {
- $this->_error = $string;
- }
- /**
- * Verifica la presenza di un errore.
- * Ritorna TRUE se presente, FALSE altrimenti.
- */
- public function hasError() {
- return !is_null($this->_error);
- }
- /**
- * Ritorna la stringa di errore
- */
- public function getError() {
- return $this->_error;
- }
- /**
- * Ritorna il codice fiscale utilizzando i parametri
- * passati a funzione. Se si verifica
- */
- public function calcola($nome, $cognome, $data, $sesso, $comune) {
- $codice = $this->_calcolaCognome($cognome) .
- $this->_calcolaNome($nome) .
- $this->_calcolaDataNascita($data, $sesso) .
- $comune;
- if ($this->hasError()) {
- return false;
- }
- $codice .= $this->_calcolaCifraControllo($codice);
- if (strlen($codice) != 16) {
- //$this->_setError(self::ERR_GENERIC);
- return 'ERROR';
- }
- return $codice;
- }
- }
|