| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405 |
- <?php
- use Illuminate\Support\Facades\Route;
- use Barryvdh\DomPDF\Facade\Pdf;
- /*
- |--------------------------------------------------------------------------
- | Web Routes
- |--------------------------------------------------------------------------
- |
- | Here is where you can register web routes for your application. These
- | routes are loaded by the RouteServiceProvider within a group which
- | contains the "web" middleware group. Now create something great!
- |
- */
- Route::get('/', function () {
- return view('login');
- // return Redirect::to('/dashboard');
- });
- //Route::get('/', \App\Http\Livewire\Login::class);
- Route::get('/dashboard', \App\Http\Livewire\Dashboard::class);
- Route::get('/settings', \App\Http\Livewire\Setting::class);
- Route::get('/courses', \App\Http\Livewire\Course::class);
- Route::get('/categories', \App\Http\Livewire\Category::class);
- Route::get('/nations_list', \App\Http\Livewire\Nation::class);
- Route::get('/provinces', \App\Http\Livewire\Province::class);
- Route::get('/cities', \App\Http\Livewire\City::class);
- Route::get('/banks', \App\Http\Livewire\Bank::class);
- Route::get('/vats', \App\Http\Livewire\Vat::class);
- Route::get('/disciplines', \App\Http\Livewire\Discipline::class);
- Route::get('/course_types', \App\Http\Livewire\CourseType::class);
- Route::get('/course_subscriptions', \App\Http\Livewire\CourseSubscription::class);
- Route::get('/course_durations', \App\Http\Livewire\CourseDuration::class);
- Route::get('/course_levels', \App\Http\Livewire\CourseLevel::class);
- Route::get('/course_frequencies', \App\Http\Livewire\CourseFrequency::class);
- Route::get('/course_list', \App\Http\Livewire\CourseList::class);
- Route::get('/course_member', \App\Http\Livewire\CourseMember::class);
- Route::get('/receipts', \App\Http\Livewire\Receipt::class);
- Route::get('/cards', \App\Http\Livewire\Card::class);
- Route::get('/causals', \App\Http\Livewire\Causal::class);
- Route::get('/payment_methods', \App\Http\Livewire\PaymentMethod::class);
- Route::get('/members', \App\Http\Livewire\Member::class);
- Route::get('/suppliers', \App\Http\Livewire\Supplier::class);
- Route::get('/sponsors', \App\Http\Livewire\Sponsor::class);
- Route::get('/records', \App\Http\Livewire\Record::class);
- Route::get('/reminders', \App\Http\Livewire\Reminder::class);
- Route::get('/in', \App\Http\Livewire\RecordIN::class);
- Route::get('/out', \App\Http\Livewire\RecordOUT::class);
- Route::get('/records_in_out', \App\Http\Livewire\RecordINOUT::class);
- Route::get('/receipt/{id}', function($id){
- $receipt = \App\Models\Receipt::findOrFail($id);
- $pdf = PDF::loadView('receipt', array('receipt' => $receipt));
- return $pdf->stream();
- /*return response()->streamDownload(
- fn () => print($pdf),
- "ricevuta_" . $receipt->number . "_" . $receipt->year . ".pdf"
- );*/
- });
- Route::get('/nations', function(){
- if (isset($_GET["q"]))
- $datas = \App\Models\Nation::where('name', 'like', $_GET["q"] . '%')->orderBy('name')->get();
- else
- $datas = \App\Models\Nation::orderBy('name')->get();
- $data = array();
- foreach($datas as $d)
- {
- $data[] = array("id" => $d->id, "text" => $d->name);
- }
- return array("results" => $data);
- });
- Route::get('/provinces/{nation_id}', function($nation_id){
- if (isset($_GET["q"]))
- $datas = \App\Models\Province::where('nation_id', $nation_id)->where('name', 'like', $_GET["q"] . '%')->orderBy('name')->get();
- else
- $datas = \App\Models\Province::where('nation_id', $nation_id)->orderBy('name')->get();
- $data = array();
- foreach($datas as $d)
- {
- $data[] = array("id" => $d->id, "text" => $d->name);
- }
- return array("results" => $data);
- });
- Route::get('/cities/{province_id}', function($province_id){
- if (isset($_GET["q"]))
- $datas = \App\Models\City::where('province_id', $province_id)->where('name', 'like', $_GET["q"] . '%')->orderBy('name')->get();
- else
- $datas = \App\Models\City::where('province_id', $province_id)->orderBy('name')->get();
- $data = array();
- foreach($datas as $d)
- {
- $data[] = array("id" => $d->id, "text" => $d->name);
- }
- return array("results" => $data);
- });
- Route::get('/get_members', function(){
- $datas = [];
- // $datas = \App\Models\Member::select('members.*')->where('id', '>', 0);
- $x = \App\Models\Member::select('id', 'first_name', 'last_name', 'phone', 'birth_date')->where('id', '>', 0);
- if ($_GET["cards"] != "")
- {
- $card_ids = \App\Models\MemberCard::whereIn('card_id', explode(",", $_GET["cards"]))->pluck('member_id');
- $x = $x->whereIn('id', $card_ids);
- }
- if ($_GET["categories"] != "")
- {
- $cats_ids = \App\Models\MemberCategory::whereIn('category_id', explode(",", $_GET["categories"]))->pluck('member_id');
- $x = $x->whereIn('id', $cats_ids);
- }
- if ($_GET["fromYear"] != "")
- {
- $x = $x->where('birth_date', '<', date("Y-m-d", strtotime("-" . $_GET["fromYear"] . " year", time())));
- }
- if ($_GET["toYear"] != "")
- {
- $x = $x->where('birth_date', '>', date("Y-m-d", strtotime("-" . $_GET["toYear"] . " year", time())));
- }
- $certs = [];
- if ($_GET["chkCertificateNormal"] != "")
- {
- $normal = \App\Models\MemberCertificate::where('type', 'N')->pluck('member_id');
- $x = $x->whereIn('id', $normal);;
- }
- if ($_GET["chkCertificateAgonistico"] != "")
- {
- $agonistic = \App\Models\MemberCertificate::where('type', 'A')->pluck('member_id');
- $x = $x->whereIn('id', $agonistic);
- }
- if ($_GET["chkCertificateScaduti"] != "")
- {
- $scaduto = \App\Models\MemberCertificate::where('expire_date', '<', date("Y-m-d"))->pluck('member_id');
- $x = $x->whereIn('id', $scaduto);
- }
- if ($_GET["chkCertificateScadenza"] != "")
- {
- $scadenza = \App\Models\MemberCertificate::whereBetween('expire_date', [date("Y-m-d"), date("Y-m-d", strtotime("+1 month"))])->pluck('member_id');
- $x = $x->whereIn('id', $scadenza);
- }
- if (sizeof($certs) > 0)
- {
- $x = $x->whereIn('id', $certs);
- }
- $x = $x->get();
- $filterStatus = isset($_GET["status"]) ? $_GET["status"] : -1;
- foreach($x as $idx => $r)
- {
- $status = $r->getStatus();
- $status = $status["status"];
- $state = $r->isActive();
- $procede = true;
- if ($filterStatus >= 0)
- {
- if ($state["status"] != $filterStatus)
- $procede = false;
- }
- if ($procede)
- {
- $class = $status > 0 ? ($status == 2 ? 'active' : 'suspended') : 'due';
- $text = $status > 0 ? ($status == 2 ? 'Tesserato' : 'Sospeso') : 'Non tesserato';
- $x = $state["status"] > 0 ? ($state["status"] == 2 ? 'active' : 'suspended') : '';
- $x .= "|";
- $x .= $state["status"] > 0 ? ($state["status"] == 2 ? 'Attivo' : 'Sospesa') : '';
- $x .= "|";
- $x .= $state["status"] ? 'Scadenza : ' : ($state["date"] != '' ? 'Scaduto : ' : '');
- $x .= "|";
- $x .= $state["date"] != '' ? date("d/m/Y", strtotime($state["date"])) : '';
- $has_certificate = $r->hasCertificate();
- $y = '';
- if($has_certificate["date"] != '')
- {
- if($has_certificate["date"] < date("Y-m-d"))
- $y .= '0';
- if($has_certificate["date"] >= date("Y-m-d") && $has_certificate["date"] < date("Y-m-d", strtotime("+1 month")))
- $y .= '1';
- if($has_certificate["date"] >= date("Y-m-d", strtotime("+1 month")))
- $y .= '2';
- $y .= '|';
- $y .= $has_certificate["date"] != '' ? date("d/m/Y", strtotime($has_certificate["date"])) : '';
- }
- $datas[] = array(
- //'c' => $idx + 1,
- 'id' => "ID" . str_pad($r->id, 5, "0", STR_PAD_LEFT),
- 'first_name' => $r->first_name . "|" . $r->id,
- 'last_name' => $r->last_name . "|" . $r->id,
- 'phone' => $r->phone,
- 'age' => $r->getAge(),
- 'status' => $class . "|" . $text,
- 'state' => $x,
- 'certificate' => $y,
- 'action' => $r->id
- );
- }
- /*
- $r->age = $r->getAge();
- $active = $r->isActive();
- $r->status = $active["status"];
- $r->date = $active["date"] . "|" . $r->hasCertificate()["date"];
- $r->state = $r->getStatus()["status"];
- $r->action = '';*/
- }
- /*
- if ($this->sortAsc)
- $this->records = $this->records->sortBy($this->sortField);
- else
- $this->records = $this->records->sortByDesc($this->sortField);
- */
- // $datas = $x; // ->orderBy($this->sortField, $this->sortAsc ? 'ASC' : 'DESC')->paginate(10);
- return json_encode(array("data" => $datas));
- });
- Route::get('/get_record_in', function(){
- $datas = [];
- $x = \App\Models\Record::select('records.*', \DB::raw('members.first_name as first_name'), \DB::raw('members.last_name as last_name'), \DB::raw('payment_methods.name as payment')) // , \DB::raw('SUM(records.id) As total'))
- ->leftJoin('members', 'records.member_id', '=', 'members.id')
- ->leftJoin('payment_methods', 'records.payment_method_id', '=', 'payment_methods.id')
- ->where('records.type', 'IN');
- // $datas = \App\Models\Record::where('type', 'IN')->with('member', 'payment_method');
- if ($_GET["filterCommercial"] > 0)
- {
- $x = $x->where('commercial', $_GET["filterCommercial"] == 1 ? true : false);
- }
- if ($_GET["filterMember"] > 0)
- {
- $x = $x->where('member_id', $_GET["filterMember"]);
- }
- if ($_GET["filterPaymentMethod"] > 0)
- {
- $x = $x->where('payment_method_id', $_GET["filterPaymentMethod"]);
- }
- if ($_GET["filterCausals"] > 0)
- {
- $causals = \App\Models\RecordRow::where('causal_id', $_GET["filterCausals"])->pluck('record_id');
- $x = $x->whereIn('records.id', $causals);
- }
- if ($_GET["filterFrom"] != '')
- {
- $x = $x->where('date', '>=', $_GET["filterFrom"]);
- }
- if ($_GET["filterTo"] != '')
- {
- $x = $x->where('date', '<=', $_GET["filterTo"]);
- }
- $total = 0;
- foreach($x->get() as $r)
- {
- foreach($r->rows as $rr)
- {
- $total += $rr->amount;
- if ($rr->vat_id > 0)
- $total += getVatValue($rr->amount, $rr->vat_id);
- }
- }
- $x = $x->get();
- foreach($x as $idx => $r)
- {
- $causals = '';
- foreach($r->rows as $row)
- {
- $causals .= $row->causal->getTree() . "<br>";
- }
- $datas[] = array(
- //'id' => $r->id,
- 'date' => $r->date,
- 'total' => formatPrice($r->getTotal()),
- 'first_name' => $r->first_name,
- 'last_name' => $r->last_name,
- 'commercial' => $r->commercial ? 'SI' : 'NO',
- 'causals' => $causals,
- 'payment' => $r->payment_method->name,
- 'status' => $r->deleted ? 'Annullato' : '',
- 'action' => $r->id . "|" . formatPrice($total) . "|" . ($r->deleted ? 'x' : '')
- );
- }
- $datas[] = array(
- //'id' => $r->id,
- 'date' => '',
- 'total' => formatPrice($total),
- 'first_name' => '',
- 'last_name' => '',
- 'commercial' => '',
- 'causals' => '',
- 'payment' => '',
- 'status' => '',
- 'action' => ''
- );
- return json_encode(array("data" => $datas));
- });
- Route::get('/get_record_out', function(){
- $datas = [];
- $x = \App\Models\Record::where('type', 'OUT')->with('supplier', 'payment_method');
- if ($_GET["filterSupplier"] > 0)
- {
- $x = $x->where('supplier_id', $_GET["filterSupplier"]);
- }
- if ($_GET["filterPaymentMethod"] > 0)
- {
- $x = $x->where('payment_method_id', $_GET["filterPaymentMethod"]);
- }
- if ($_GET["filterCausals"] > 0)
- {
- $causals = \App\Models\RecordRow::where('causal_id', $_GET["filterCausals"])->pluck('record_id');
- $x = $x->whereIn('records.id', $causals);
- }
- if ($_GET["filterFrom"] != '')
- {
- $x = $x->where('date', '>=', $_GET["filterFrom"]);
- }
- if ($_GET["filterTo"] != '')
- {
- $x = $x->where('date', '<=', $_GET["filterTo"]);
- }
- $total = 0;
- foreach($x->get() as $r)
- {
- foreach($r->rows as $rr)
- {
- $total += $rr->amount;
- if ($rr->vat_id > 0)
- $total += getVatValue($rr->amount, $rr->vat_id);
- }
- }
- $x = $x->get();
- foreach($x as $idx => $r)
- {
- $causals = '';
- foreach($r->rows as $row)
- {
- $causals .= $row->causal->getTree() . "<br>";
- }
- $datas[] = array(
- //'id' => $r->id,
- 'date' => $r->date,
- 'total' => formatPrice($r->getTotal()),
- 'supplier' => $r->supplier->name,
- 'causals' => $causals,
- 'payment' => $r->payment_method->name,
- 'action' => $r->id . "|" . formatPrice($total)
- );
- }
- $datas[] = array(
- //'id' => $r->id,
- 'date' => '',
- 'total' => formatPrice($total),
- 'supplier' => '',
- 'causals' => '',
- 'payment' => '',
- 'action' => ''
- );
- return json_encode(array("data" => $datas));
- });
- Route::get('/migrate', function(){
- \Artisan::call('migrate');
- dd('migrated!');
- });
|