|
|
@@ -179,7 +179,7 @@ Route::get('/get_members', function () {
|
|
|
// $datas = \App\Models\Member::select('members.*')->where('id', '>', 0);
|
|
|
$x = \App\Models\Member::select('id', 'first_name', 'last_name', 'phone', 'birth_date', 'to_complete', 'current_status', 'certificate', 'certificate_date')->where('id', '>', 0);
|
|
|
|
|
|
- if (isset($_GET["search"]["value"])) {
|
|
|
+ if (isset($_GET["search"]["value"]) && $_GET["search"]["value"] != "") {
|
|
|
$v = str_replace("'", "\'", stripcslashes($_GET["search"]["value"]));
|
|
|
$x = $x->where(function ($query) use ($v) {
|
|
|
$query->whereRaw("CONCAT(TRIM(first_name), ' ', TRIM(last_name)) like ?", ["%{$v}%"])
|
|
|
@@ -332,7 +332,6 @@ Route::get('/get_members', function () {
|
|
|
|
|
|
$count = $x->count();
|
|
|
|
|
|
- $x = $x->orderBy('to_complete', 'DESC');
|
|
|
|
|
|
if (isset($_GET["order"])) {
|
|
|
$column = '';
|
|
|
@@ -350,14 +349,27 @@ Route::get('/get_members', function () {
|
|
|
$column = 'current_status';
|
|
|
if ($_GET["order"][0]["column"] == 6)
|
|
|
$column = 'certificate';
|
|
|
+
|
|
|
if ($column != '') {
|
|
|
- $x = $x->orderBy($column, $_GET["order"][0]["dir"]);
|
|
|
+ if ($column == 'last_name') {
|
|
|
+ $x = $x->orderBy('to_complete', 'DESC');
|
|
|
+ }
|
|
|
if ($column == 'certificate')
|
|
|
$x = $x->orderBy('certificate_date', $_GET["order"][0]["dir"]);
|
|
|
- } else
|
|
|
+ elseif ($column == 'current_status') {
|
|
|
+ $x = $x->orderBy('to_complete', 'DESC');
|
|
|
+ $x = $x->orderBy($column, $_GET["order"][0]["dir"]);
|
|
|
+ } else {
|
|
|
+ $x = $x->orderBy($column, $_GET["order"][0]["dir"]);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ $x = $x->orderBy('to_complete', 'DESC');
|
|
|
$x = $x->orderBy('last_name', 'ASC')->orderBy('first_name', 'ASC');
|
|
|
- } else
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ $x = $x->orderBy('to_complete', 'DESC');
|
|
|
$x = $x->orderBy('last_name', 'ASC')->orderBy('first_name', 'ASC');
|
|
|
+ }
|
|
|
|
|
|
if (isset($_GET["start"]))
|
|
|
$x = $x->offset($_GET["start"])->limit($_GET["length"])->get();
|