web.php 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. <?php
  2. use Illuminate\Support\Facades\Route;
  3. /*
  4. |--------------------------------------------------------------------------
  5. | Web Routes
  6. |--------------------------------------------------------------------------
  7. |
  8. | Here is where you can register web routes for your application. These
  9. | routes are loaded by the RouteServiceProvider within a group which
  10. | contains the "web" middleware group. Now create something great!
  11. |
  12. */
  13. Route::get('/', function () {
  14. return view('login');
  15. // return Redirect::to('/dashboard');
  16. });
  17. //Route::get('/', \App\Http\Livewire\Login::class);
  18. Route::get('/dashboard', \App\Http\Livewire\Dashboard::class);
  19. Route::get('/settings', \App\Http\Livewire\Setting::class);
  20. Route::get('/courses', \App\Http\Livewire\Course::class);
  21. Route::get('/categories', \App\Http\Livewire\Category::class);
  22. Route::get('/nations_list', \App\Http\Livewire\Nation::class);
  23. Route::get('/provinces', \App\Http\Livewire\Province::class);
  24. Route::get('/cities', \App\Http\Livewire\City::class);
  25. Route::get('/banks', \App\Http\Livewire\Bank::class);
  26. Route::get('/vats', \App\Http\Livewire\Vat::class);
  27. Route::get('/cards', \App\Http\Livewire\Card::class);
  28. Route::get('/causals', \App\Http\Livewire\Causal::class);
  29. Route::get('/payment_methods', \App\Http\Livewire\PaymentMethod::class);
  30. Route::get('/members', \App\Http\Livewire\Member::class);
  31. Route::get('/suppliers', \App\Http\Livewire\Supplier::class);
  32. Route::get('/sponsors', \App\Http\Livewire\Sponsor::class);
  33. Route::get('/records', \App\Http\Livewire\Record::class);
  34. Route::get('/reminders', \App\Http\Livewire\Reminder::class);
  35. Route::get('/in', \App\Http\Livewire\RecordIN::class);
  36. Route::get('/out', \App\Http\Livewire\RecordOUT::class);
  37. Route::get('/records_in_out', \App\Http\Livewire\RecordINOUT::class);
  38. Route::get('/nations', function(){
  39. if (isset($_GET["q"]))
  40. $datas = \App\Models\Nation::where('name', 'like', $_GET["q"] . '%')->orderBy('name')->get();
  41. else
  42. $datas = \App\Models\Nation::orderBy('name')->get();
  43. $data = array();
  44. foreach($datas as $d)
  45. {
  46. $data[] = array("id" => $d->id, "text" => $d->name);
  47. }
  48. return array("results" => $data);
  49. });
  50. Route::get('/provinces/{nation_id}', function($nation_id){
  51. if (isset($_GET["q"]))
  52. $datas = \App\Models\Province::where('nation_id', $nation_id)->where('name', 'like', $_GET["q"] . '%')->orderBy('name')->get();
  53. else
  54. $datas = \App\Models\Province::where('nation_id', $nation_id)->orderBy('name')->get();
  55. $data = array();
  56. foreach($datas as $d)
  57. {
  58. $data[] = array("id" => $d->id, "text" => $d->name);
  59. }
  60. return array("results" => $data);
  61. });
  62. Route::get('/cities/{province_id}', function($province_id){
  63. if (isset($_GET["q"]))
  64. $datas = \App\Models\City::where('province_id', $province_id)->where('name', 'like', $_GET["q"] . '%')->orderBy('name')->get();
  65. else
  66. $datas = \App\Models\City::where('province_id', $province_id)->orderBy('name')->get();
  67. $data = array();
  68. foreach($datas as $d)
  69. {
  70. $data[] = array("id" => $d->id, "text" => $d->name);
  71. }
  72. return array("results" => $data);
  73. });
  74. Route::get('/get_members', function(){
  75. $datas = [];
  76. // $datas = \App\Models\Member::select('members.*')->where('id', '>', 0);
  77. $x = \App\Models\Member::select('id', 'first_name', 'last_name', 'phone')->where('id', '>', 0);
  78. if ($_GET["cards"] != "")
  79. {
  80. $card_ids = \App\Models\MemberCard::whereIn('card_id', explode(",", $_GET["cards"]))->pluck('member_id');
  81. $x = $x->whereIn('id', $card_ids);
  82. }
  83. if ($_GET["categories"] != "")
  84. {
  85. $cats_ids = \App\Models\MemberCategory::whereIn('category_id', explode(",", $_GET["categories"]))->pluck('member_id');
  86. $x = $x->whereIn('id', $cats_ids);
  87. }
  88. $certs = [];
  89. if ($_GET["chkCertificateNormal"] != "")
  90. {
  91. $normal = \App\Models\MemberCertificate::where('type', 'N')->pluck('member_id');
  92. $x = $x->whereIn('id', $normal);;
  93. }
  94. if ($_GET["chkCertificateAgonistico"] != "")
  95. {
  96. $agonistic = \App\Models\MemberCertificate::where('type', 'A')->pluck('member_id');
  97. $x = $x->whereIn('id', $agonistic);
  98. }
  99. if ($_GET["chkCertificateScaduti"] != "")
  100. {
  101. $scaduto = \App\Models\MemberCertificate::where('expire_date', '<', date("Y-m-d"))->pluck('member_id');
  102. $x = $x->whereIn('id', $scaduto);
  103. }
  104. if ($_GET["chkCertificateScadenza"] != "")
  105. {
  106. $scadenza = \App\Models\MemberCertificate::whereBetween('expire_date', [date("Y-m-d"), date("Y-m-d", strtotime("+1 month"))])->pluck('member_id');
  107. $x = $x->whereIn('id', $scadenza);
  108. }
  109. if (sizeof($certs) > 0)
  110. {
  111. $x = $x->whereIn('id', $certs);
  112. }
  113. $x = $x->get();
  114. foreach($x as $idx => $r)
  115. {
  116. $status = $r->getStatus();
  117. $status = $status["status"];
  118. $class = $status > 0 ? ($status == 2 ? 'active' : 'suspended') : 'due';
  119. $text = $status > 0 ? ($status == 2 ? 'Tesserato' : 'Sospeso') : 'Non tesserato';
  120. $state = $r->isActive();
  121. $x = $state["status"] > 0 ? ($state["status"] == 2 ? 'active' : 'suspended') : '';
  122. $x .= "|";
  123. $x .= $state["status"] > 0 ? ($state["status"] == 2 ? 'Attivo' : 'Sospesa') : '';
  124. $x .= "|";
  125. $x .= $state["status"] ? 'Scadenza : ' : ($state["date"] != '' ? 'Scaduto : ' : '');
  126. $x .= "|";
  127. $x .= $state["date"] != '' ? date("d/m/Y", strtotime($state["date"])) : '';
  128. $has_certificate = $r->hasCertificate();
  129. $y = '';
  130. if($has_certificate["date"] != '')
  131. {
  132. if($has_certificate["date"] < date("Y-m-d"))
  133. $y .= '0';
  134. if($has_certificate["date"] >= date("Y-m-d") && $has_certificate["date"] < date("Y-m-d", strtotime("+1 month")))
  135. $y .= '1';
  136. if($has_certificate["date"] >= date("Y-m-d", strtotime("+1 month")))
  137. $y .= '2';
  138. $y .= '|';
  139. $y .= $has_certificate["date"] != '' ? date("d/m/Y", strtotime($has_certificate["date"])) : '';
  140. }
  141. $datas[] = array(
  142. 'id' => $r->id,
  143. 'first_name' => $r->first_name,
  144. 'last_name' => $r->last_name,
  145. 'phone' => $r->phone,
  146. 'age' => $r->getAge(),
  147. 'status' => $class . "|" . $text,
  148. 'state' => $x,
  149. 'certificate' => $y,
  150. 'action' => $r->id
  151. );
  152. /*
  153. $r->age = $r->getAge();
  154. $active = $r->isActive();
  155. $r->status = $active["status"];
  156. $r->date = $active["date"] . "|" . $r->hasCertificate()["date"];
  157. $r->state = $r->getStatus()["status"];
  158. $r->action = '';*/
  159. }
  160. /*
  161. if ($this->sortAsc)
  162. $this->records = $this->records->sortBy($this->sortField);
  163. else
  164. $this->records = $this->records->sortByDesc($this->sortField);
  165. */
  166. // $datas = $x; // ->orderBy($this->sortField, $this->sortAsc ? 'ASC' : 'DESC')->paginate(10);
  167. return json_encode(array("data" => $datas));
  168. });