Browse Source

Stat tree edit (wip)

Vijayakrishnan 3 years ago
parent
commit
ba82db5e4c

+ 7 - 1
app/Http/Controllers/StatTreeLineController.php

@@ -190,7 +190,13 @@ class StatTreeLineController extends Controller
 
         $query = 'SELECT ' . implode(", ", $selectColumns) . ' FROM '.$model.' WHERE '. implode(" AND ", $clauses);
 
-        return DB::select($query);
+        try {
+            $result = DB::select($query);
+        }
+        catch (\Exception $ex) {
+            $result = 'error';
+        }
+        return $result;
     }
 
     protected function cleanupClause($clauseText)

+ 23 - 16
resources/views/app/stat-tree/stat-tree-lines/view-data.blade.php

@@ -1,27 +1,34 @@
 <div class="mcp-theme-1 p-3 border-top mt-3">
-    @if(!count($columns))
+    @if(@$rows === 'error')
         <div class="text-secondary">
             <i class="fa fa-exclamation-triangle"></i>
-            Report columns not configured for this report!
+            Query error / missing arg values!
         </div>
     @else
-        <table class="table table-sm table-striped table-bordered">
-            <thead>
-            <tr>
-                @foreach($columns as $column)
-                <th class="border-bottom-0 text-left">{{$column['label']}}</th>
-                @endforeach
-            </tr>
-            </thead>
-            <tbody>
-            @foreach($rows as $row)
+        @if(!count($columns))
+            <div class="text-secondary">
+                <i class="fa fa-exclamation-triangle"></i>
+                Report columns not configured for this report!
+            </div>
+        @else
+            <table class="table table-sm table-striped table-bordered">
+                <thead>
                 <tr>
                     @foreach($columns as $column)
-                        <td>{{ $row->{$column['as']} }}</td>
+                    <th class="border-bottom-0 text-left">{{$column['label']}}</th>
                     @endforeach
                 </tr>
-            @endforeach
-            </tbody>
-        </table>
+                </thead>
+                <tbody>
+                @foreach($rows as $row)
+                    <tr>
+                        @foreach($columns as $column)
+                            <td>{{ $row->{$column['as']} }}</td>
+                        @endforeach
+                    </tr>
+                @endforeach
+                </tbody>
+            </table>
+        @endif
     @endif
 </div>