web.php 44 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186
  1. <?php
  2. use Illuminate\Support\Facades\Route;
  3. use Barryvdh\DomPDF\Facade\Pdf;
  4. /*
  5. |--------------------------------------------------------------------------
  6. | Web Routes
  7. |--------------------------------------------------------------------------
  8. |
  9. | Here is where you can register web routes for your application. These
  10. | routes are loaded by the RouteServiceProvider within a group which
  11. | contains the "web" middleware group. Now create something great!
  12. |
  13. */
  14. Route::get('/', function () {
  15. return view('login');
  16. // return Redirect::to('/dashboard');
  17. })->name('login');
  18. Route::post('/login', function () {
  19. if(\Auth::attempt(array('email' => $_POST["email"], 'password' => $_POST["password"])))
  20. {
  21. return Redirect::to('/dashboard');
  22. }
  23. else
  24. {
  25. return Redirect::to('/?error=1');
  26. }
  27. })->name('login');
  28. Route::get('/logout', function(){
  29. Auth::logout();
  30. return redirect('/');
  31. });
  32. Route::group(['middleware' => 'auth'],function(){
  33. //Route::get('/', \App\Http\Livewire\Login::class);
  34. Route::get('/dashboard', \App\Http\Livewire\Dashboard::class);
  35. Route::get('/settings', \App\Http\Livewire\Setting::class);
  36. Route::get('/courses', \App\Http\Livewire\Course::class);
  37. Route::get('/categories', \App\Http\Livewire\Category::class);
  38. Route::get('/nations_list', \App\Http\Livewire\Nation::class);
  39. Route::get('/provinces', \App\Http\Livewire\Province::class);
  40. Route::get('/cities', \App\Http\Livewire\City::class);
  41. Route::get('/banks', \App\Http\Livewire\Bank::class);
  42. Route::get('/vats', \App\Http\Livewire\Vat::class);
  43. Route::get('/disciplines', \App\Http\Livewire\Discipline::class);
  44. Route::get('/course_types', \App\Http\Livewire\CourseType::class);
  45. Route::get('/course_subscriptions', \App\Http\Livewire\CourseSubscription::class);
  46. Route::get('/course_durations', \App\Http\Livewire\CourseDuration::class);
  47. Route::get('/course_levels', \App\Http\Livewire\CourseLevel::class);
  48. Route::get('/course_frequencies', \App\Http\Livewire\CourseFrequency::class);
  49. Route::get('/course_list', \App\Http\Livewire\CourseList::class);
  50. Route::get('/course_member', \App\Http\Livewire\CourseMember::class);
  51. Route::get('/receipts', \App\Http\Livewire\Receipt::class);
  52. Route::get('/cards', \App\Http\Livewire\Card::class);
  53. Route::get('/causals', \App\Http\Livewire\Causal::class);
  54. Route::get('/payment_methods', \App\Http\Livewire\PaymentMethod::class);
  55. Route::get('/members', \App\Http\Livewire\Member::class);
  56. Route::get('/suppliers', \App\Http\Livewire\Supplier::class);
  57. Route::get('/sponsors', \App\Http\Livewire\Sponsor::class);
  58. Route::get('/records', \App\Http\Livewire\Record::class);
  59. Route::get('/reminders', \App\Http\Livewire\Reminder::class);
  60. Route::get('/in', \App\Http\Livewire\RecordIN::class);
  61. Route::get('/out', \App\Http\Livewire\RecordOUT::class);
  62. Route::get('/records_in_out', \App\Http\Livewire\RecordINOUT::class);
  63. Route::get('/users', \App\Http\Livewire\User::class);
  64. Route::get('/receipt/{id}', function($id){
  65. $receipt = \App\Models\Receipt::findOrFail($id);
  66. $pdf = PDF::loadView('receipt', array('receipt' => $receipt));
  67. $pdfName = "Ricevuta_" . $receipt->member->last_name . "_" . $receipt->number . "_" . $receipt->year . ".pdf";
  68. return $pdf->stream($pdfName);
  69. /*return response()->streamDownload(
  70. fn () => print($pdf),
  71. "ricevuta_" . $receipt->number . "_" . $receipt->year . ".pdf"
  72. );*/
  73. });
  74. Route::get('/receipt/mail/{id}', function($id){
  75. $receipt = \App\Models\Receipt::findOrFail($id);
  76. if ($receipt->status == 99)
  77. sendReceiptDeleteEmail($receipt);
  78. else
  79. sendReceiptEmail($receipt);
  80. /*
  81. $pdf = PDF::loadView('receipt', array('receipt' => $receipt));
  82. $pdfName = "ricevuta_" . $receipt->number . "_" . $receipt->year . ".pdf";
  83. Storage::put('public/pdf/' . $pdfName, $pdf->output());
  84. $email = \App\Models\Member::findOrFail($receipt->member_id)->email;
  85. if ($email != '')
  86. {
  87. Mail::to($email)->send(new \App\Mail\ReceipEmail([
  88. 'name' => 'Luca',
  89. 'pdf' => 'public/pdf/' . $pdfName,
  90. 'number' => $receipt->number . "/" . $receipt->year
  91. ]));
  92. }
  93. */
  94. return true;
  95. //return $pdf->stream();
  96. /*return response()->streamDownload(
  97. fn () => print($pdf),
  98. "ricevuta_" . $receipt->number . "_" . $receipt->year . ".pdf"
  99. );*/
  100. });
  101. Route::get('/nations', function(){
  102. if (isset($_GET["q"]))
  103. $datas = \App\Models\Nation::where('name', 'like', $_GET["q"] . '%')->orderBy('name')->get();
  104. else
  105. $datas = \App\Models\Nation::orderBy('name')->get();
  106. $data = array();
  107. foreach($datas as $d)
  108. {
  109. $data[] = array("id" => $d->id, "text" => $d->name);
  110. }
  111. return array("results" => $data);
  112. });
  113. Route::get('/provinces/{nation_id}', function($nation_id){
  114. if (isset($_GET["q"]))
  115. $datas = \App\Models\Province::where('nation_id', $nation_id)->where('name', 'like', $_GET["q"] . '%')->orderBy('name')->get();
  116. else
  117. $datas = \App\Models\Province::where('nation_id', $nation_id)->orderBy('name')->get();
  118. $data = array();
  119. foreach($datas as $d)
  120. {
  121. $data[] = array("id" => $d->id, "text" => $d->name);
  122. }
  123. return array("results" => $data);
  124. });
  125. Route::get('/cities/{province_id}', function($province_id){
  126. if (isset($_GET["q"]))
  127. $datas = \App\Models\City::where('province_id', $province_id)->where('name', 'like', $_GET["q"] . '%')->orderBy('name')->get();
  128. else
  129. $datas = \App\Models\City::where('province_id', $province_id)->orderBy('name')->get();
  130. $data = array();
  131. foreach($datas as $d)
  132. {
  133. $data[] = array("id" => $d->id, "text" => $d->name);
  134. }
  135. return array("results" => $data);
  136. });
  137. Route::get('/get_members', function(){
  138. $datas = [];
  139. // $datas = \App\Models\Member::select('members.*')->where('id', '>', 0);
  140. $x = \App\Models\Member::select('id', 'first_name', 'last_name', 'phone', 'birth_date', 'to_complete', 'current_status', 'certificate', 'certificate_date')->where('id', '>', 0);
  141. if (isset($_GET["search"]["value"]))
  142. {
  143. $v = str_replace("'", "''", stripcslashes($_GET["search"]["value"]));
  144. $x = $x->where(function ($query) use ($v) {
  145. $query->whereRaw("CONCAT(first_name, ' ', last_name) like '%" . $v . "%'")
  146. ->orWhereRaw("CONCAT(last_name, ' ', first_name) like '%" . $v . "%'");
  147. });
  148. //where('first_name', 'like', '%' . $_GET["search"]["value"] . '%');
  149. }
  150. if ($_GET["cards"] != "")
  151. {
  152. $card_ids = \App\Models\MemberCard::whereIn('card_id', explode(",", $_GET["cards"]))->pluck('member_id');
  153. $x = $x->whereIn('id', $card_ids);
  154. }
  155. if ($_GET["filterCategories"] != "null")
  156. {
  157. $cats_ids = \App\Models\MemberCategory::whereIn('category_id', explode(",", $_GET["filterCategories"]))->pluck('member_id');
  158. $x = $x->whereIn('id', $cats_ids);
  159. }
  160. if ($_GET["fromYear"] != "")
  161. {
  162. $x = $x->where('birth_date', '<', date("Y-m-d", strtotime("-" . $_GET["fromYear"] . " year", time())));
  163. }
  164. if ($_GET["toYear"] != "")
  165. {
  166. $x = $x->where('birth_date', '>', date("Y-m-d", strtotime("-" . $_GET["toYear"] . " year", time())));
  167. }
  168. if ($_GET["fromYearYear"] != "")
  169. {
  170. $x = $x->whereYear('birth_date', '>=', $_GET["fromYearYear"]);
  171. }
  172. if ($_GET["toYearYear"] != "")
  173. {
  174. $x = $x->whereYear('birth_date', '<=', $_GET["toYearYear"]);
  175. }
  176. $ids = [];
  177. if ($_GET["filterCertificateType"] != "null")
  178. {
  179. $types = \App\Models\MemberCertificate::where('type', $_GET["filterCertificateType"])->pluck('member_id');
  180. $x = $x->whereIn('id', $types->toArray());;
  181. //$ids = array_merge($ids, $types->toArray());
  182. }
  183. if ($_GET["filterScadenza"] != "null")
  184. {
  185. if ($_GET["filterScadenza"] == "1")
  186. $scad = \App\Models\MemberCertificate::where('expire_date', '<', date("Y-m-d"))->pluck('member_id');
  187. if ($_GET["filterScadenza"] == "2")
  188. $scad = \App\Models\MemberCertificate::whereBetween('expire_date', [date("Y-m-d"), date("Y-m-d", strtotime("+1 month"))])->pluck('member_id');
  189. //$ids = array_merge($ids, $scad->toArray());
  190. $x = $x->whereIn('id', $scad->toArray());;
  191. //$x = $x->whereIn('id', $scadenza);
  192. }
  193. if ($_GET["filterStatus"] != "null")
  194. {
  195. $status = explode(",", $_GET["filterStatus"]);
  196. $members = \App\Models\Member::all();
  197. foreach($status as $s)
  198. {
  199. foreach($members as $m)
  200. {
  201. $state = $m->isActive();
  202. if ($state["status"] == $s)
  203. $ids[] = $m->id;
  204. }
  205. }
  206. }
  207. if (sizeof($ids) > 0)
  208. {
  209. $x = $x->whereIn('id', $ids);
  210. }
  211. else
  212. {
  213. if ($_GET["filterStatus"] != "null")
  214. $x = $x->whereIn('id', [-1]);
  215. }
  216. $count = $x->count();
  217. $x = $x->orderBy('to_complete', 'DESC');
  218. if (isset($_GET["order"]))
  219. {
  220. $column = '';
  221. if ($_GET["order"][0]["column"] == 0)
  222. $column = 'last_name';
  223. if ($_GET["order"][0]["column"] == 1)
  224. $column = 'first_name';
  225. if ($_GET["order"][0]["column"] == 2)
  226. $column = 'phone';
  227. if ($_GET["order"][0]["column"] == 3)
  228. $column = 'birth_date';
  229. if ($_GET["order"][0]["column"] == 4)
  230. $column = 'birth_date';
  231. if ($_GET["order"][0]["column"] == 5)
  232. $column = 'current_status';
  233. if ($_GET["order"][0]["column"] == 6)
  234. $column = 'certificate';
  235. if ($column != '')
  236. $x = $x->orderBy($column, $_GET["order"][0]["dir"]);
  237. else
  238. $x = $x->orderBy('last_name', 'ASC')->orderBy('first_name', 'ASC');
  239. }
  240. else
  241. $x = $x->orderBy('last_name', 'ASC')->orderBy('first_name', 'ASC');
  242. if (isset($_GET["start"]))
  243. $x = $x->offset($_GET["start"])->limit($_GET["length"])->get();
  244. else
  245. $x = $x->get();
  246. foreach($x as $idx => $r)
  247. {
  248. // $status = $r->getStatus();
  249. // $status = $status["status"];
  250. $status = $r->current_status;
  251. $class = $status > 0 ? ($status == 2 ? 'active' : 'due') : 'suspended';
  252. $text = $status > 0 ? ($status == 2 ? 'Tesserato' : 'Sospeso') : 'Non tesserato';
  253. if ($r->to_complete)
  254. {
  255. $text = 'Da completare';
  256. $class = "complete";
  257. }
  258. // $has_certificate = $r->hasCertificate();
  259. $y = '';
  260. if ($r->certificate_date != '')
  261. {
  262. $y = $r->certificate . "|" . date("d/m/Y", strtotime($r->certificate_date));
  263. }
  264. /*
  265. if($has_certificate["date"] != '')
  266. {
  267. if($has_certificate["date"] < date("Y-m-d"))
  268. $y .= '0';
  269. if($has_certificate["date"] >= date("Y-m-d") && $has_certificate["date"] < date("Y-m-d", strtotime("+1 month")))
  270. $y .= '1';
  271. if($has_certificate["date"] >= date("Y-m-d", strtotime("+1 month")))
  272. $y .= '2';
  273. $y .= '|';
  274. $y .= $has_certificate["date"] != '' ? date("d/m/Y", strtotime($has_certificate["date"])) : '';
  275. }*/
  276. $datas[] = array(
  277. //'c' => $idx + 1,
  278. //'id' => "ID" . str_pad($r->id, 5, "0", STR_PAD_LEFT),
  279. 'last_name' => $r->last_name . "|" . $r->id,
  280. 'first_name' => $r->first_name . "|" . $r->id,
  281. 'phone' => $r->phone,
  282. 'age' => $r->getAge(),
  283. 'year' => date("Y", strtotime($r->birth_date)),
  284. 'status' => $class . "|" . $text,
  285. // 'state' => $x,
  286. 'certificate' => $y,
  287. 'action' => $r->id
  288. );
  289. }
  290. return json_encode(array("data" => $datas, "recordsTotal" => $count, "recordsFiltered" => $count));
  291. });
  292. Route::get('/get_record_in', function(){
  293. $datas = [];
  294. $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'))
  295. ->leftJoin('members', 'records.member_id', '=', 'members.id')
  296. ->leftJoin('payment_methods', 'records.payment_method_id', '=', 'payment_methods.id')
  297. ->where('records.type', 'IN');
  298. if (isset($_GET["search"]["value"]))
  299. {
  300. $v = str_replace("'", "''", stripcslashes($_GET["search"]["value"]));
  301. $x = $x->where(function ($query) use ($v) {
  302. $query->where('first_name', 'like', '%' . $v . '%')
  303. ->orWhere('last_name', 'like', '%' . $v . '%');
  304. });
  305. //where('first_name', 'like', '%' . $_GET["search"]["value"] . '%');
  306. }
  307. //$x = $x->where(function ($query) use ($v) {
  308. // $datas = \App\Models\Record::where('type', 'IN')->with('member', 'payment_method');
  309. if ($_GET["filterCommercial"] == 1)
  310. {
  311. $x = $x->where('commercial', true );
  312. }
  313. if ($_GET["filterCommercial"] == 2)
  314. {
  315. $x = $x->where('commercial', false);
  316. }
  317. if ($_GET["filterMember"] > 0)
  318. {
  319. $x = $x->where('member_id', $_GET["filterMember"]);
  320. }
  321. if ($_GET["filterPaymentMethod"] != "null")
  322. {
  323. $payments = explode(",", $_GET["filterPaymentMethod"]);
  324. $x = $x->whereIn('payment_method_id', $payments);
  325. }
  326. if ($_GET["filterCausals"] != "null")
  327. {
  328. $causals = explode(",", $_GET["filterCausals"]);
  329. //$causals = \App\Models\RecordRow::where('causal_id', $_GET["filterCausals"])->pluck('record_id');
  330. $causals = \App\Models\RecordRow::whereIn('causal_id', $causals)->pluck('record_id');
  331. $x = $x->whereIn('records.id', $causals);
  332. }
  333. if ($_GET["filterFrom"] != '')
  334. {
  335. $x = $x->where('date', '>=', $_GET["filterFrom"]);
  336. }
  337. if ($_GET["filterTo"] != '')
  338. {
  339. $x = $x->where('date', '<=', $_GET["filterTo"]);
  340. }
  341. //});
  342. $start = 0;
  343. $limit = 100000;
  344. if (isset($_GET["start"]))
  345. {
  346. $start = $_GET["start"];
  347. $limit = $_GET["length"];
  348. }
  349. $excludeCausals = [];
  350. /*$borsellino = \App\Models\Causal::where('money', true)->first();
  351. if ($borsellino)
  352. $excludeCausals[] = $borsellino->id;*/
  353. // Aggiungo
  354. $excludes = \App\Models\Causal::where('no_records', true)->get();
  355. foreach($excludes as $e)
  356. {
  357. $excludeCausals[] = $e->id;
  358. }
  359. $exclude_from_records = \App\Models\Member::where('exclude_from_records', true)->pluck('id')->toArray();
  360. // Pagamento money
  361. $moneys = \App\Models\PaymentMethod::where('money', true)->pluck('id')->toArray();
  362. // Causale money
  363. $moneysCausal = \App\Models\Causal::where('money', true)->pluck('id')->toArray();
  364. $total = 0;
  365. /*
  366. foreach($x->get() as $r)
  367. {
  368. if (!in_array($r->payment_method_id, $moneys))
  369. {
  370. foreach($r->rows as $rr)
  371. {
  372. if ((!in_array($rr->member_id, $exclude_from_records) || in_array($r->causal_id, $moneysCausal)) && (!$r->deleted || $r->deleted == null) && (!in_array($rr->causal_id, $excludeCausals) || in_array($r->causal_id, $moneysCausal)) && (!$r->financial_movement || $r->financial_movement == null) && (!$r->corrispettivo_fiscale || $r->corrispettivo_fiscale == null))
  373. {
  374. $total += $rr->amount;
  375. if ($rr->vat_id > 0)
  376. $total += getVatValue($rr->amount, $rr->vat_id);
  377. }
  378. }
  379. }
  380. }
  381. */
  382. $count = $x->count();
  383. if (isset($_GET["order"]))
  384. {
  385. $column = '';
  386. if ($_GET["order"][0]["column"] == 0)
  387. $column = 'date';
  388. if ($_GET["order"][0]["column"] == 1)
  389. $column = 'records.amount';
  390. if ($_GET["order"][0]["column"] == 2)
  391. $column = 'last_name';
  392. if ($_GET["order"][0]["column"] == 3)
  393. $column = 'first_name';
  394. if ($_GET["order"][0]["column"] == 4)
  395. $column = 'commercial';
  396. if ($column != '')
  397. $x = $x->orderBy($column, $_GET["order"][0]["dir"])->orderBy('records.id', 'DESC');
  398. else
  399. $x = $x->orderBy('records.id', 'DESC');
  400. }
  401. else
  402. $x = $x->orderBy('records.date', 'DESC')->orderBy('records.id', 'DESC');
  403. $x = $x->offset($start)->limit($limit)->get();
  404. foreach($x as $idx => $r)
  405. {
  406. $causals = '';
  407. foreach($r->rows as $row)
  408. {
  409. $causals .= $row->causal->getTree() . "<br>";
  410. }
  411. $datas[] = array(
  412. //'id' => $r->id,
  413. 'date' => $r->date,
  414. 'total' => formatPrice($r->getTotal()),
  415. 'first_name' => $r->first_name,
  416. 'last_name' => $r->last_name,
  417. 'commercial' => $r->financial_movement ? 'Movimento finanziario' : ($r->commercial ? 'SI' : 'NO'),
  418. 'causals' => $causals,
  419. 'payment' => $r->payment_method->name,
  420. 'status' => $r->deleted ? 'Annullato' : '',
  421. 'action' => $r->id . "|" . formatPrice($total) . "|" . ($r->deleted ? 'x' : '')
  422. );
  423. }
  424. /*$datas[] = array(
  425. //'id' => $r->id,
  426. 'date' => '',
  427. 'total' => formatPrice($total),
  428. 'first_name' => '',
  429. 'last_name' => '',
  430. 'commercial' => '',
  431. 'causals' => '',
  432. 'payment' => '',
  433. 'status' => '',
  434. 'action' => ''
  435. );*/
  436. return json_encode(array("data" => $datas, "recordsTotal" => $count, "recordsFiltered" => $count));
  437. });
  438. Route::get('/get_record_out', function(){
  439. $datas = [];
  440. $x = \App\Models\Record::where('type', 'OUT')->with('supplier', 'payment_method');
  441. if ($_GET["filterSupplier"] > 0)
  442. {
  443. $x = $x->where('supplier_id', $_GET["filterSupplier"]);
  444. }
  445. /*if ($_GET["filterPaymentMethod"] > 0)
  446. {
  447. $x = $x->where('payment_method_id', $_GET["filterPaymentMethod"]);
  448. }
  449. if ($_GET["filterCausals"] > 0)
  450. {
  451. $causals = \App\Models\RecordRow::where('causal_id', $_GET["filterCausals"])->pluck('record_id');
  452. $x = $x->whereIn('records.id', $causals);
  453. }*/
  454. if ($_GET["filterPaymentMethod"] != "null")
  455. {
  456. $payments = explode(",", $_GET["filterPaymentMethod"]);
  457. $x = $x->whereIn('payment_method_id', $payments);
  458. }
  459. if ($_GET["filterCausals"] != "null")
  460. {
  461. $causals = explode(",", $_GET["filterCausals"]);
  462. //$causals = \App\Models\RecordRow::where('causal_id', $_GET["filterCausals"])->pluck('record_id');
  463. $causals = \App\Models\RecordRow::whereIn('causal_id', $causals)->pluck('record_id');
  464. $x = $x->whereIn('records.id', $causals);
  465. }
  466. if ($_GET["filterFrom"] != '')
  467. {
  468. $x = $x->where('date', '>=', $_GET["filterFrom"]);
  469. }
  470. if ($_GET["filterTo"] != '')
  471. {
  472. $x = $x->where('date', '<=', $_GET["filterTo"]);
  473. }
  474. $total = 0;
  475. /*foreach($x->get() as $r)
  476. {
  477. foreach($r->rows as $rr)
  478. {
  479. $total += $rr->amount;
  480. if ($rr->vat_id > 0)
  481. $total += getVatValue($rr->amount, $rr->vat_id);
  482. }
  483. }*/
  484. $x = $x->get();
  485. foreach($x as $idx => $r)
  486. {
  487. $causals = '';
  488. foreach($r->rows as $row)
  489. {
  490. $causals .= $row->causal->getTree() . "<br>";
  491. }
  492. $datas[] = array(
  493. //'id' => $r->id,
  494. 'date' => $r->date,
  495. 'total' => formatPrice($r->getTotal()),
  496. 'supplier' => $r->supplier->name,
  497. 'causals' => $causals,
  498. 'payment' => $r->payment_method->name,
  499. 'action' => $r->id . "|" . formatPrice($total)
  500. );
  501. }
  502. /*
  503. $datas[] = array(
  504. //'id' => $r->id,
  505. 'date' => '',
  506. 'total' => formatPrice($total),
  507. 'supplier' => '',
  508. 'causals' => '',
  509. 'payment' => '',
  510. 'action' => ''
  511. );
  512. */
  513. return json_encode(array("data" => $datas));
  514. });
  515. Route::get('/get_course_list', function(){
  516. $member_course = \App\Models\MemberCourse::with('member');
  517. if (isset($_GET["search"]["value"]))
  518. {
  519. $v = str_replace("'", "''", stripcslashes($_GET["search"]["value"]));
  520. $member_ids = \App\Models\Member::where(function ($query) use ($v) {
  521. $query->where('first_name', 'like', '%' . $v . '%')
  522. ->orWhere('last_name', 'like', '%' . $v . '%');
  523. })->pluck('id');
  524. $member_course = $member_course->whereIn('member_id', $member_ids);
  525. }
  526. if ($_GET["filterCourse"] != "null")
  527. {
  528. $course_ids = [];
  529. $courses = explode(",", $_GET["filterCourse"]);
  530. foreach($courses as $c)
  531. {
  532. $all = \App\Models\Course::where('name', 'like', '%' . $c . "%")->get();
  533. foreach($all as $a)
  534. {
  535. $course_ids[] = $a->id;
  536. }
  537. }
  538. $member_course = $member_course->whereIn('course_id', $course_ids);
  539. }
  540. if ($_GET["filterLevel"] != "null")
  541. {
  542. $levels = explode(",", $_GET["filterLevel"]);
  543. $course_ids = \App\Models\Course::whereIn('course_level_id', $levels)->pluck('id');
  544. $member_course = $member_course->whereIn('course_id', $course_ids);
  545. }
  546. if ($_GET["filterFrequency"] != "null")
  547. {
  548. $frequencies = explode(",", $_GET["filterFrequency"]);
  549. $course_ids = \App\Models\Course::whereIn('course_type_id', $frequencies)->pluck('id');
  550. $member_course = $member_course->whereIn('course_id', $course_ids);
  551. }
  552. if ($_GET["filterType"] != "null")
  553. {
  554. $types = explode(",", $_GET["filterType"]);
  555. $course_ids = \App\Models\Course::whereIn('course_frequency_id', $types)->pluck('id');
  556. $member_course = $member_course->whereIn('course_id', $course_ids);
  557. }
  558. if ($_GET["filterDuration"] != "null")
  559. {
  560. $durations = explode(",", $_GET["filterDuration"]);
  561. $course_ids = \App\Models\Course::whereIn('course_duration_id', $durations)->pluck('id');
  562. $member_course = $member_course->whereIn('course_id', $course_ids);
  563. }
  564. $totals = [];
  565. $totalIsc = [];
  566. $member_course_totals = $member_course->get();
  567. foreach($member_course_totals as $x)
  568. {
  569. $price = 0;
  570. $price = $x->course->price;
  571. $subPrice = $x->course->subscription_price;
  572. $records = \App\Models\Record::where('member_course_id', $x->id)->where('deleted', 0)->get();
  573. $prices = [];
  574. foreach ($records as $record)
  575. {
  576. foreach ($record->rows as $row)
  577. {
  578. //if ($row->causal_id == $x->course->sub_causal_id || str_contains(strtolower($row->note), 'iscrizione'))
  579. if (str_contains(strtolower($row->note), 'iscrizione'))
  580. {
  581. $subPrice = $row->amount;
  582. }
  583. if ($row->causal_id == $x->course->causal_id && !str_contains(strtolower($row->note), 'iscrizione'))
  584. {
  585. $tot = sizeof(json_decode($row->when));
  586. foreach(json_decode($row->when) as $m)
  587. {
  588. $prices[$m->month] = $row->amount / $tot;
  589. }
  590. }
  591. }
  592. }
  593. for($i=1; $i<=12; $i++)
  594. {
  595. $cls = getColor($x->months, $i);
  596. if ($cls != 'grey')
  597. {
  598. if (!isset($totals[$i]))
  599. {
  600. $totals[$i]['green'] = 0;
  601. $totals[$i]['orange'] = 0;
  602. $totals[$i]['yellow'] = 0;
  603. }
  604. if ($cls == 'yellow')
  605. {
  606. $totals[$i][$cls] += 1;
  607. }
  608. else
  609. {
  610. $p = isset($prices[$i]) ? $prices[$i] : $price;
  611. $totals[$i][$cls] += $p;
  612. }
  613. }
  614. }
  615. $sub = $x->subscribed ? "Y" : "N";
  616. if (isset($totalIsc[$sub]))
  617. $totalIsc[$sub] += $subPrice;
  618. else
  619. $totalIsc[$sub] = $subPrice;
  620. }
  621. $count = $member_course->count();
  622. $js = '';
  623. $xx = 2;
  624. $str = '';
  625. if ($count > 0)
  626. {
  627. $str .= "<a style='width:100%;float:right; text-align:right; display:block;' class=green><small>" . (isset($totalIsc["Y"]) ? formatPrice($totalIsc["Y"]) : 0) . "</small></a><br>";
  628. $str .= "<a style='width:100%;float:right; text-align:right; display:block;' class=orange><small>" . (isset($totalIsc["N"]) ? formatPrice($totalIsc["N"]) : 0) . "</small></a><br>";
  629. $str .= "<a style='width:100%;float:right; text-align:right; display:block;' class=yellow><small>02220</small></a><br>";
  630. }
  631. $js .= "2§" . $str . "_";
  632. $str = "";
  633. foreach($totals as $z => $t)
  634. {
  635. if ($z == 1) $xx = 7;
  636. if ($z == 2) $xx = 8;
  637. if ($z == 3) $xx = 9;
  638. if ($z == 4) $xx = 10;
  639. if ($z == 5) $xx = 11;
  640. if ($z == 6) $xx = 12;
  641. if ($z == 7) $xx = 13;
  642. if ($z == 8) $xx = 14;
  643. if ($z == 9) $xx = 3;
  644. if ($z == 10) $xx = 4;
  645. if ($z == 11) $xx = 5;
  646. if ($z == 12) $xx = 6;
  647. $str = '';
  648. foreach($t as $x => $c)
  649. {
  650. $y = $x == 'yellow' ? $c : formatPrice($c);
  651. $str .= "<a style='width:100%;float:right; text-align:right; display:block;' class=" . $x . "><small>" . $y . "</small></a><br>";
  652. }
  653. $js .= $xx . "§" . $str . "_";
  654. $xx += 1;
  655. }
  656. //$member_course = $member_course->where('course_id', 999999);
  657. $start = 0;
  658. $limit = 100000;
  659. if (isset($_GET["start"]))
  660. {
  661. $start = $_GET["start"];
  662. $limit = $_GET["length"];
  663. }
  664. $member_course = $member_course->offset($start)->limit($limit)->get();
  665. $datas = [];
  666. foreach($member_course as $x)
  667. {
  668. $price = 0;
  669. $price = $x->course->price;
  670. $subPrice = $x->course->subscription_price;
  671. $records = \App\Models\Record::where('member_course_id', $x->id)->where('deleted', 0)->get();
  672. $prices = [];
  673. foreach ($records as $record)
  674. {
  675. foreach ($record->rows as $row)
  676. {
  677. //if ($row->causal_id == $x->course->sub_causal_id || str_contains(strtolower($row->note), 'iscrizione'))
  678. if (str_contains(strtolower($row->note), 'iscrizione'))
  679. {
  680. $subPrice = $row->amount;
  681. }
  682. if ($row->causal_id == $x->course->causal_id && !str_contains(strtolower($row->note), 'iscrizione'))
  683. {
  684. $tot = sizeof(json_decode($row->when));
  685. foreach(json_decode($row->when) as $m)
  686. {
  687. $prices[$m->month] = $row->amount / $tot;
  688. }
  689. }
  690. }
  691. }
  692. for($i=1; $i<=12; $i++)
  693. {
  694. $cls = getColor($x->months, $i);
  695. if ($cls != 'grey')
  696. {
  697. if (!isset($totals[$i]))
  698. {
  699. $totals[$i]['green'] = 0;
  700. $totals[$i]['orange'] = 0;
  701. $totals[$i]['yellow'] = 0;
  702. }
  703. if ($cls == 'yellow')
  704. {
  705. $prices[$i] = 0;
  706. $totals[$i][$cls] += 1;
  707. }
  708. else
  709. {
  710. $p = isset($prices[$i]) ? $prices[$i] : $price;
  711. $totals[$i][$cls] += $p;
  712. }
  713. }
  714. }
  715. $sub = $x->subscribed ? "Y" : "N";
  716. if (isset($totalIsc[$sub]))
  717. $totalIsc[$sub] += $subPrice;
  718. else
  719. $totalIsc[$sub] = $subPrice;
  720. $datas[] = array(
  721. "column_0" => $x->member->last_name,
  722. "column_1" => $x->member->first_name,
  723. "column_2" => $x->subscribed . "§" . formatPrice($subPrice),
  724. "column_3" => getColor($x->months, 9) . "§" . formatPrice(isset($prices[9]) ? $prices[9] : $price),
  725. "column_4" => getColor($x->months, 10) . "§" . formatPrice(isset($prices[10]) ? $prices[10] : $price),
  726. "column_5" => getColor($x->months, 11) . "§" . formatPrice(isset($prices[11]) ? $prices[11] : $price),
  727. "column_6" => getColor($x->months, 12) . "§" . formatPrice(isset($prices[12]) ? $prices[12] : $price),
  728. "column_7" => getColor($x->months, 1) . "§" . formatPrice(isset($prices[1]) ? $prices[1] : $price),
  729. "column_8" => getColor($x->months, 2) . "§" . formatPrice(isset($prices[2]) ? $prices[2] : $price),
  730. "column_9" => getColor($x->months, 3) . "§" . formatPrice(isset($prices[3]) ? $prices[3] : $price),
  731. "column_10" => getColor($x->months, 4) . "§" . formatPrice(isset($prices[4]) ? $prices[4] : $price),
  732. "column_11" => getColor($x->months, 5) . "§" . formatPrice(isset($prices[5]) ? $prices[5] : $price),
  733. "column_12" => getColor($x->months, 6) . "§" . formatPrice(isset($prices[6]) ? $prices[6] : $price),
  734. "column_13" => getColor($x->months, 7) . "§" . formatPrice(isset($prices[7]) ? $prices[7] : $price),
  735. "column_14" => getColor($x->months, 8) . "§" . formatPrice(isset($prices[8]) ? $prices[8] : $price),
  736. "column_15" => $x->course_id,
  737. "column_16" => $x->id,
  738. "column_17" => $x->member_id
  739. );
  740. }
  741. // Sort data
  742. /*
  743. if (isset($_GET["order"]))
  744. array_multisort(array_column($datas, 'column_' . $_GET["order"][0]["column"]), $_GET["order"][0]["dir"] == "asc" ? SORT_ASC : SORT_DESC, SORT_NATURAL|SORT_FLAG_CASE, $datas);
  745. else
  746. array_multisort(array_column($datas, 'column_0'), SORT_DESC, SORT_NATURAL|SORT_FLAG_CASE, $datas);
  747. //$x = $x->orderBy('records.date', 'DESC')->orderBy('records.id', 'DESC');
  748. */
  749. return json_encode(array("data" => $datas, "recordsTotal" => $count, "recordsFiltered" => $count, "totals" => $js));
  750. });
  751. Route::get('/get_course_members', function(){
  752. //$datas = \App\Models\MemberCourse::with('member');
  753. $datas = \App\Models\MemberCourse::select('member_courses.*', 'members.first_name', 'members.last_name', 'members.email', 'members.phone', 'members.birth_date')->leftJoin('members', 'member_courses.member_id', '=', 'members.id');
  754. if ($_GET["filterCourse"] != "null")
  755. {
  756. $course_ids = [];
  757. $courses = explode(",", $_GET["filterCourse"]);
  758. foreach($courses as $c)
  759. {
  760. $all = \App\Models\Course::where('name', 'like', '%' . $c . "%")->get();
  761. foreach($all as $a)
  762. {
  763. $course_ids[] = $a->id;
  764. }
  765. }
  766. $datas = $datas->whereIn('course_id', $course_ids);
  767. }
  768. if ($_GET["filterLevel"] != "null")
  769. {
  770. $levels = explode(",", $_GET["filterLevel"]);
  771. $course_ids = \App\Models\Course::whereIn('course_level_id', $levels)->pluck('id');
  772. $datas = $datas->whereIn('course_id', $course_ids);
  773. }
  774. if ($_GET["filterFrequency"] != "null")
  775. {
  776. $frequencies = explode(",", $_GET["filterFrequency"]);
  777. $course_ids = \App\Models\Course::whereIn('course_type_id', $frequencies)->pluck('id');
  778. $datas = $datas->whereIn('course_id', $course_ids);
  779. }
  780. if ($_GET["filterType"] != "null")
  781. {
  782. $types = explode(",", $_GET["filterType"]);
  783. $course_ids = \App\Models\Course::whereIn('course_frequency_id', $types)->pluck('id');
  784. $datas = $datas->whereIn('course_id', $course_ids);
  785. }
  786. if ($_GET["filterDuration"] != "null")
  787. {
  788. $durations = explode(",", $_GET["filterDuration"]);
  789. $course_ids = \App\Models\Course::whereIn('course_duration_id', $durations)->pluck('id');
  790. $datas = $datas->whereIn('course_id', $course_ids);
  791. }
  792. if ($_GET["filterDays"] != "null")
  793. {
  794. $ids = [];
  795. $days = explode(",", $_GET["filterDays"]);
  796. foreach($days as $d)
  797. {
  798. $all = \App\Models\MemberCourse::where('when', 'like', "%" . $d . "%")->get();
  799. foreach($all as $a)
  800. {
  801. $ids[] = $a->id;
  802. }
  803. }
  804. $datas = $datas->whereIn('member_courses.id', $ids);
  805. }
  806. if ($_GET["filterHours"] != "null")
  807. {
  808. $ids = [];
  809. $hours = explode(",", $_GET["filterHours"]);
  810. foreach($hours as $h)
  811. {
  812. $all = \App\Models\MemberCourse::where('when', 'like', '%"from":"' . $h . "%")->get();
  813. foreach($all as $a)
  814. {
  815. $ids[] = $a->id;
  816. }
  817. }
  818. $datas = $datas->whereIn('member_courses.id', $ids);
  819. }
  820. if ($_GET["filterSubscription"] != "")
  821. {
  822. $ids = \App\Models\MemberCourse::where('subscribed', $_GET["filterSubscription"] == 1 ? true : false)->pluck('id');
  823. $datas = $datas->whereIn('member_courses.id', $ids);
  824. //$this->filter .= $this->filter != '' ? ', ' : '';
  825. //$this->filter .= "Pagata sottoscrizione : " . ($this->filterSubscription == 1 ? "SI" : "NO") . " ";
  826. }
  827. if ($_GET["filterCertificateType"] != "null")
  828. {
  829. $ctypes = \App\Models\MemberCertificate::where('type', $_GET["filterCertificateType"])->pluck('member_id');
  830. $datas = $datas->whereIn('member_id', $ctypes);
  831. }
  832. if ($_GET["filterCertificateScadenza"] != "null")
  833. {
  834. if ($_GET["filterCertificateScadenza"] == "1")
  835. $scad = \App\Models\MemberCertificate::where('expire_date', '<', date("Y-m-d"))->pluck('member_id');
  836. if ($_GET["filterCertificateScadenza"] == "2")
  837. $scad = \App\Models\MemberCertificate::whereBetween('expire_date', [date("Y-m-d"), date("Y-m-d", strtotime("+1 month"))])->pluck('member_id');
  838. $datas = $datas->whereIn('member_id', $scad);
  839. }
  840. if ($_GET["fromYear"] != "")
  841. {
  842. $m_ids = \App\Models\Member::where('birth_date', '<', date("Y-m-d", strtotime("-" . $_GET["fromYear"] . " year", time())))->pluck('id');
  843. $datas = $datas->whereIn('member_id', $m_ids);
  844. }
  845. if ($_GET["toYear"] != "")
  846. {
  847. $m_ids = \App\Models\Member::where('birth_date', '>', date("Y-m-d", strtotime("-" . $_GET["toYear"] . " year", time())))->pluck('id');
  848. $datas = $datas->whereIn('member_id', $m_ids);
  849. }
  850. if ($_GET["fromFromYear"] != "")
  851. {
  852. $m_ids = \App\Models\Member::whereYear('birth_date', '>=', $_GET["fromFromYear"])->pluck('id');
  853. $datas = $datas->whereIn('member_id', $m_ids);
  854. }
  855. if ($_GET["toToYear"] != "")
  856. {
  857. $m_ids = \App\Models\Member::whereYear('birth_date', '<=', $_GET["toToYear"])->pluck('id');
  858. $datas = $datas->whereIn('member_id', $m_ids);
  859. }
  860. if ($_GET["filterCards"] != "null")
  861. {
  862. $cards = explode(",", $_GET["filterCards"]);
  863. $card_ids = \App\Models\MemberCard::whereIn('card_id', $cards)->pluck('member_id');
  864. $datas = $datas->whereIn('member_id', $card_ids);
  865. }
  866. if ($_GET["filterYear"] != "")
  867. {
  868. $course_ids = \App\Models\Course::where('year', $_GET["filterYear"])->pluck('id');
  869. $datas = $datas->whereIn('course_id', $course_ids);
  870. //$this->filter .= $this->filter != '' ? ', ' : '';
  871. //$this->filter .= "Anno : " . $this->filterYear . " ";
  872. }
  873. $aRet = [];
  874. if (isset($_GET["order"]))
  875. {
  876. $column = '';
  877. if ($_GET["order"][0]["column"] == 1)
  878. $column = 'last_name';
  879. if ($_GET["order"][0]["column"] == 2)
  880. $column = 'first_name';
  881. if ($_GET["order"][0]["column"] == 2)
  882. $column = 'birth_date';
  883. if ($_GET["order"][0]["column"] == 3)
  884. $column = 'birth_date';
  885. if ($_GET["order"][0]["column"] == 4)
  886. $column = 'birth_date';
  887. if ($_GET["order"][0]["column"] == 5)
  888. $column = 'phone';
  889. if ($_GET["order"][0]["column"] == 6)
  890. $column = 'email';
  891. if ($column != '')
  892. $datas = $datas->orderBy($column, $_GET["order"][0]["dir"]);
  893. else
  894. $datas = $datas->orderBy('last_name', 'ASC')->orderBy('first_name', 'ASC');
  895. }
  896. else
  897. $datas = $datas->orderBy('last_name', 'ASC')->orderBy('first_name', 'ASC');
  898. if ($_GET["filterStatus"] != "null")
  899. {
  900. $status = explode(",", $_GET["filterStatus"]);
  901. foreach($status as $s)
  902. {
  903. foreach($datas->get() as $aaa)
  904. {
  905. $state = \App\Models\Member::findOrFail($aaa->member_id)->isActive();
  906. if ($state["status"] == $s)
  907. $aRet[] = $aaa;
  908. }
  909. }
  910. }
  911. else
  912. $aRet = $datas->get();
  913. $ret = [];
  914. foreach($aRet as $idx => $r)
  915. {
  916. $date1 = new DateTime($r->birth_date);
  917. $date2 = new DateTime("now");
  918. $interval = $date1->diff($date2);
  919. $ret[] = array(
  920. "column_0" => $idx + 1,
  921. "column_1" => $r->last_name,
  922. "column_2" => $r->first_name,
  923. "column_3" => strval($interval->y),
  924. "column_4" => date("Y", strtotime($r->birth_date)),
  925. "column_5" => $r->phone,
  926. "column_6" => $r->email,
  927. "column_7" => $r->member_id
  928. );
  929. }
  930. if (isset($_GET["start"]))
  931. $ret = array_slice($ret, $_GET["start"], $_GET["length"]);
  932. return json_encode(array("data" => $ret, "recordsTotal" => sizeof($aRet), "recordsFiltered" => sizeof($aRet)));
  933. });
  934. Route::get('/get_receipts', function(){
  935. $x = \App\Models\Receipt::select('receipts.*', 'members.first_name', 'members.last_name')->leftJoin('members', 'receipts.member_id', '=', 'members.id');
  936. if (isset($_GET["search"]["value"]))
  937. {
  938. $v = str_replace("'", "''", stripcslashes($_GET["search"]["value"]));
  939. $member_ids = \App\Models\Member::where(function ($query) use ($v) {
  940. $query->where('first_name', 'like', '%' . $v . '%')
  941. ->orWhere('last_name', 'like', '%' . $v . '%');
  942. })->pluck('id');
  943. $x = $x->whereIn('member_id', $member_ids);
  944. }
  945. if ($_GET["filterStatus"] != '')
  946. $x = $x->where('receipts.status', $_GET["filterStatus"]);
  947. if ($_GET["filterFrom"] != "")
  948. $x = $x->where('date', '>=', $_GET["filterFrom"]);
  949. if ($_GET["filterTo"] != "")
  950. $x = $x->where('date', '<=', $_GET["filterTo"]);
  951. $count = $x->count();
  952. if (isset($_GET["order"]))
  953. {
  954. $column = '';
  955. if ($_GET["order"][0]["column"] == 0)
  956. $column = 'year';
  957. if ($_GET["order"][0]["column"] == 1)
  958. $column = 'number';
  959. if ($_GET["order"][0]["column"] == 2)
  960. $column = 'last_name';
  961. if ($_GET["order"][0]["column"] == 3)
  962. $column = 'first_name';
  963. if ($_GET["order"][0]["column"] == 4)
  964. $column = 'status';
  965. if ($_GET["order"][0]["column"] == 5)
  966. $column = 'date';
  967. if ($column != '')
  968. $x = $x->orderBy($column, $_GET["order"][0]["dir"])->orderBy('id', 'DESC');
  969. else
  970. $x = $x->orderBy('id', 'DESC');
  971. }
  972. else
  973. $x = $x->orderBy('id', 'DESC');
  974. if (isset($_GET["start"]))
  975. $x = $x->offset($_GET["start"])->limit($_GET["length"])->get();
  976. else
  977. $x = $x->get();
  978. $datas = [];
  979. foreach($x as $idx => $r)
  980. {
  981. $datas[] = array(
  982. 'year' => $r->year,
  983. 'number' => $r->number,
  984. 'last_name' => $r->member->last_name,
  985. 'first_name' => $r->member->first_name,
  986. 'status' => $r->status,
  987. 'date' => date("d/m/Y", strtotime($r->date)),
  988. 'totals' => formatPrice($r->rows->sum('amount')),
  989. 'action' => $r->id
  990. );
  991. }
  992. return json_encode(array("data" => $datas, "recordsTotal" => $count, "recordsFiltered" => $count));
  993. });
  994. });
  995. function getColor($months, $m)
  996. {
  997. $class = "grey";
  998. foreach(json_decode($months) as $mm)
  999. {
  1000. if ($mm->m == $m)
  1001. {
  1002. if ($mm->status == "")
  1003. {
  1004. $class = "orange";
  1005. }
  1006. if ($mm->status == "1")
  1007. {
  1008. $class = "green";
  1009. }
  1010. if ($mm->status == "2")
  1011. {
  1012. $class = "yellow";
  1013. }
  1014. }
  1015. }
  1016. return $class;
  1017. }
  1018. Route::get('/migrate', function(){
  1019. \Artisan::call('migrate');
  1020. dd('migrated!');
  1021. });
  1022. Route::get('/updateData', function()
  1023. {
  1024. // Call and Artisan command from within your application.
  1025. Artisan::call('update:data');
  1026. });