|
@@ -1435,8 +1435,10 @@ Route::get('/get_course_members', function () {
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
Route::get('/get_receipts', function () {
|
|
Route::get('/get_receipts', function () {
|
|
|
- $x = \App\Models\Receipt::select('receipts.*', 'members.first_name', 'members.last_name')
|
|
|
|
|
- ->leftJoin('members', 'receipts.member_id', '=', 'members.id');
|
|
|
|
|
|
|
+ $x = \App\Models\Receipt::select('receipts.*', 'members.first_name', 'members.last_name', DB::raw('SUM(receipts_rows.amount) AS totals'))
|
|
|
|
|
+ ->leftJoin('members', 'receipts.member_id', '=', 'members.id')
|
|
|
|
|
+ ->leftJoin('receipts_rows', 'receipts.id', '=', 'receipts_rows.receip_id')
|
|
|
|
|
+ ->groupBy('receipts.id', 'members.first_name', 'members.last_name');
|
|
|
|
|
|
|
|
if (isset($_GET["search"]["value"])) {
|
|
if (isset($_GET["search"]["value"])) {
|
|
|
$v = str_replace("'", "\'", stripcslashes($_GET["search"]["value"]));
|
|
$v = str_replace("'", "\'", stripcslashes($_GET["search"]["value"]));
|
|
@@ -1475,12 +1477,14 @@ Route::get('/get_receipts', function () {
|
|
|
$column = 'status';
|
|
$column = 'status';
|
|
|
if ($_GET["order"][0]["column"] == 5)
|
|
if ($_GET["order"][0]["column"] == 5)
|
|
|
$column = 'date';
|
|
$column = 'date';
|
|
|
|
|
+ if ($_GET["order"][0]["column"] == 6)
|
|
|
|
|
+ $column = 'totals';
|
|
|
if ($column != '')
|
|
if ($column != '')
|
|
|
- $x = $x->orderBy($column, $_GET["order"][0]["dir"])->orderBy('id', 'DESC');
|
|
|
|
|
|
|
+ $x = $x->orderBy($column, $_GET["order"][0]["dir"])->orderBy('receipts.id', 'DESC');
|
|
|
else
|
|
else
|
|
|
- $x = $x->orderBy('id', 'DESC');
|
|
|
|
|
|
|
+ $x = $x->orderBy('receipts.id', 'DESC');
|
|
|
} else
|
|
} else
|
|
|
- $x = $x->orderBy('id', 'DESC');
|
|
|
|
|
|
|
+ $x = $x->orderBy('receipts.id', 'DESC');
|
|
|
|
|
|
|
|
if (isset($_GET["start"]))
|
|
if (isset($_GET["start"]))
|
|
|
$x = $x->offset($_GET["start"])->limit($_GET["length"])->get();
|
|
$x = $x->offset($_GET["start"])->limit($_GET["length"])->get();
|
|
@@ -1497,7 +1501,7 @@ Route::get('/get_receipts', function () {
|
|
|
'first_name' => $r->member->first_name,
|
|
'first_name' => $r->member->first_name,
|
|
|
'status' => $r->status,
|
|
'status' => $r->status,
|
|
|
'date' => date("d/m/Y", strtotime($r->created_at)),
|
|
'date' => date("d/m/Y", strtotime($r->created_at)),
|
|
|
- 'totals' => formatPrice($r->rows->sum('amount')),
|
|
|
|
|
|
|
+ 'totals' => formatPrice($r->totals),
|
|
|
'action' => $ids
|
|
'action' => $ids
|
|
|
);
|
|
);
|
|
|
}
|
|
}
|