Luca Parisio 1 рік тому
батько
коміт
78b2543d54
1 змінених файлів з 30 додано та 7 видалено
  1. 30 7
      routes/web.php

+ 30 - 7
routes/web.php

@@ -660,6 +660,8 @@ Route::group(['middleware' => 'auth'],function(){
         $totals = [];
         $totalIsc = [];
 
+        $datas = [];
+
         $member_course_totals = $member_course->get();
         foreach($member_course_totals as $x)
         {
@@ -723,6 +725,27 @@ Route::group(['middleware' => 'auth'],function(){
             else
                 $totalIsc[$sub] = $subPrice;
 
+            $datas[] = array(
+                "column_0" => $x->member->last_name,
+                "column_1" => $x->member->first_name,
+                "column_2" => $x->subscribed . "§" . formatPrice($subPrice),
+                "column_3" => getColor($x->months, 9) . "§" . formatPrice(isset($prices[9]) ? $prices[9] : $price),
+                "column_4" => getColor($x->months, 10) . "§" . formatPrice(isset($prices[10]) ? $prices[10] : $price),
+                "column_5" => getColor($x->months, 11) . "§" . formatPrice(isset($prices[11]) ? $prices[11] : $price),
+                "column_6" => getColor($x->months, 12) . "§" . formatPrice(isset($prices[12]) ? $prices[12] : $price),
+                "column_7" => getColor($x->months, 1) . "§" . formatPrice(isset($prices[1]) ? $prices[1] : $price),
+                "column_8" => getColor($x->months, 2) . "§" . formatPrice(isset($prices[2]) ? $prices[2] : $price),
+                "column_9" => getColor($x->months, 3) . "§" . formatPrice(isset($prices[3]) ? $prices[3] : $price),
+                "column_10" => getColor($x->months, 4) . "§" . formatPrice(isset($prices[4]) ? $prices[4] : $price),
+                "column_11" => getColor($x->months, 5) . "§" . formatPrice(isset($prices[5]) ? $prices[5] : $price),
+                "column_12" => getColor($x->months, 6) . "§" . formatPrice(isset($prices[6]) ? $prices[6] : $price),
+                "column_13" => getColor($x->months, 7) . "§" . formatPrice(isset($prices[7]) ? $prices[7] : $price),
+                "column_14" => getColor($x->months, 8) . "§" . formatPrice(isset($prices[8]) ? $prices[8] : $price),
+                "column_15" => $x->course_id,
+                "column_16" => $x->id,
+                "column_17" => $x->member_id
+            );
+
         }
 
         $count = $member_course->count();
@@ -765,6 +788,8 @@ Route::group(['middleware' => 'auth'],function(){
 
         //$member_course = $member_course->where('course_id', 999999);
 
+        /*
+
         $start = 0;
         $limit = 100000;
 
@@ -774,7 +799,8 @@ Route::group(['middleware' => 'auth'],function(){
             $limit = $_GET["length"];
         }
 
-        $member_course = $member_course->offset($start)->limit($limit)->get();
+        //$member_course = $member_course->offset($start)->limit($limit)->get();
+        $member_course = $member_course->get();
 
         $datas = [];
 
@@ -862,16 +888,13 @@ Route::group(['middleware' => 'auth'],function(){
                 "column_17" => $x->member_id
             );
         }
+        */
 
-        // Sort data
-        /*
         if (isset($_GET["order"]))
             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);
-        else
-            array_multisort(array_column($datas, 'column_0'), SORT_DESC, SORT_NATURAL|SORT_FLAG_CASE, $datas);
-            //$x = $x->orderBy('records.date', 'DESC')->orderBy('records.id', 'DESC');
-        */
 
+        if (isset($_GET["start"]))
+            $datas = array_slice($datas, $_GET["start"], $_GET["length"]);
 
         return json_encode(array("data" => $datas, "recordsTotal" => $count, "recordsFiltered" => $count, "totals" => $js));