Sort on equipments
This commit is contained in:
@@ -51,7 +51,7 @@ if(isset($get_content) && $get_content!=''){
|
|||||||
$v = explode("=", $y);
|
$v = explode("=", $y);
|
||||||
//INCLUDE VARIABLES IN ARRAY
|
//INCLUDE VARIABLES IN ARRAY
|
||||||
$criterias[$v[0]] = $v[1];
|
$criterias[$v[0]] = $v[1];
|
||||||
if ($v[0] == 'page' || $v[0] =='p' || $v[0] =='totals' || $v[0] =='history' || $v[0] =='success_msg' || $v[0] =='download'){
|
if ($v[0] == 'page' || $v[0] =='p' || $v[0] =='totals' || $v[0] =='history' || $v[0] =='success_msg' || $v[0] =='download' || $v[0] =='sort'){
|
||||||
//do nothing
|
//do nothing
|
||||||
}
|
}
|
||||||
elseif ($v[0] == 'equipmentid') {
|
elseif ($v[0] == 'equipmentid') {
|
||||||
@@ -124,8 +124,52 @@ elseif (isset($criterias['history']) && $criterias['history'] ==''){
|
|||||||
$sql ='SELECT h.rowID as historyID, e.rowID as equipmentID, h.equipmentid as h_equipmentid, e.serialnumber, h.type, h.description, h.created, h.createdby from history h LEFT JOIN equipment e ON h.equipmentid = e.rowID '.$whereclause.'';
|
$sql ='SELECT h.rowID as historyID, e.rowID as equipmentID, h.equipmentid as h_equipmentid, e.serialnumber, h.type, h.description, h.created, h.createdby from history h LEFT JOIN equipment e ON h.equipmentid = e.rowID '.$whereclause.'';
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
// GET SORT INDICATOR
|
||||||
|
$sort_indicator = $criterias['sort'] ?? '';
|
||||||
|
|
||||||
|
/*
|
||||||
|
1 Serialnumber ASC
|
||||||
|
2 Serialnumber DESC
|
||||||
|
3 Status ASC
|
||||||
|
4 Status DESC
|
||||||
|
5 Warranty ASC
|
||||||
|
6 Warranty DESC
|
||||||
|
7 Service ASC
|
||||||
|
8 Service DESC
|
||||||
|
*/
|
||||||
|
|
||||||
|
switch ($sort_indicator){
|
||||||
|
case 1:
|
||||||
|
$sort = ' e.serialnumber ASC ';
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
$sort = ' e.serialnumber DESC ';
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
$sort = ' e.status ASC ';
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
$sort = ' e.status DESC ';
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
$sort = ' e.warranty_date ASC ';
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
$sort = ' e.warranty_date DESC ';
|
||||||
|
break;
|
||||||
|
case 7:
|
||||||
|
$sort = ' e.service_date ASC ';
|
||||||
|
break;
|
||||||
|
case 8:
|
||||||
|
$sort = ' e.service_date DESC ';
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$sort = ' equipmentID ';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
//SQL for Paging
|
//SQL for Paging
|
||||||
$sql = 'SELECT e.rowID as equipmentID, e.productrowid, e.serialnumber, e.status, e.created, e.createdby, e.hw_version, e.sw_version, e.accounthierarchy, e.service_date, e.warranty_date, p.productcode, p.productname from equipment e LEFT JOIN products p ON e.productrowid = p.rowID '.$whereclause.' ORDER BY equipmentID LIMIT :page,:num_products';
|
$sql = 'SELECT e.rowID as equipmentID, e.productrowid, e.serialnumber, e.status, e.created, e.createdby, e.hw_version, e.sw_version, e.accounthierarchy, e.service_date, e.warranty_date, p.productcode, p.productname from equipment e LEFT JOIN products p ON e.productrowid = p.rowID '.$whereclause.' ORDER BY '.$sort.' LIMIT :page,:num_products';
|
||||||
}
|
}
|
||||||
|
|
||||||
$stmt = $pdo->prepare($sql);
|
$stmt = $pdo->prepare($sql);
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ $create_allowed = isAllowed($page_manage ,$_SESSION['profile'],$_SESSION['permis
|
|||||||
//GET PARAMETERS
|
//GET PARAMETERS
|
||||||
$pagination_page = isset($_GET['p']) ? $_GET['p'] : 1;
|
$pagination_page = isset($_GET['p']) ? $_GET['p'] : 1;
|
||||||
$status = isset($_GET['status']) ? '&status='.$_GET['status'] : '';
|
$status = isset($_GET['status']) ? '&status='.$_GET['status'] : '';
|
||||||
|
$sort = isset($_GET['sort']) ? '&sort='.$_GET['sort'] : '';
|
||||||
$search = isset($_GET['search']) ? '&search='.$_GET['search'] : '';
|
$search = isset($_GET['search']) ? '&search='.$_GET['search'] : '';
|
||||||
$software = isset($_GET['firmware']) ? '&firmware='.$_GET['firmware'] : '';
|
$software = isset($_GET['firmware']) ? '&firmware='.$_GET['firmware'] : '';
|
||||||
$servicedate = isset($_GET['servicedate']) ? '&servicedate='.$_GET['servicedate'] : '';
|
$servicedate = isset($_GET['servicedate']) ? '&servicedate='.$_GET['servicedate'] : '';
|
||||||
@@ -31,7 +32,7 @@ $warrantydate = isset($_GET['warrantydate']) ? '&warrantydate='.$_GET['warrantyd
|
|||||||
$partnerid = isset($_GET['partnerid']) ? '&partnerid='.$_GET['partnerid'] : '';
|
$partnerid = isset($_GET['partnerid']) ? '&partnerid='.$_GET['partnerid'] : '';
|
||||||
|
|
||||||
// Determine the URL
|
// Determine the URL
|
||||||
$url = 'index.php?page=equipments'.$status.$search.$software.$servicedate.$warrantydate.$partnerid;
|
$url = 'index.php?page=equipments'.$status.$search.$software.$servicedate.$warrantydate.$partnerid.$sort;
|
||||||
//GET Details from URL
|
//GET Details from URL
|
||||||
$GET_VALUES = urlGETdetails($_GET) ?? '';
|
$GET_VALUES = urlGETdetails($_GET) ?? '';
|
||||||
//CALL TO API
|
//CALL TO API
|
||||||
@@ -103,6 +104,24 @@ $view .= '
|
|||||||
<option value="3"'.($status==3?' selected':'').'>'.$status3_text.'</option>
|
<option value="3"'.($status==3?' selected':'').'>'.$status3_text.'</option>
|
||||||
<option value="4"'.($status==4?' selected':'').'>'.$status4_text.'</option>
|
<option value="4"'.($status==4?' selected':'').'>'.$status4_text.'</option>
|
||||||
<option value="5"'.($status==5?' selected':'').'>'.$status5_text.'</option>
|
<option value="5"'.($status==5?' selected':'').'>'.$status5_text.'</option>
|
||||||
|
</select>
|
||||||
|
<button type="submit">'.$button_apply.'</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="filters">
|
||||||
|
<a href="#">'.$general_sort.'</a>
|
||||||
|
<div class="list">
|
||||||
|
<select name="sort">
|
||||||
|
<option value="" disabled selected>'.$general_sort.'</option>
|
||||||
|
<option value="1"'.($sort==1?' selected':'').'>'.$equipment_label2.' '.$general_sort_type_1.'</option>
|
||||||
|
<option value="2"'.($sort==2?' selected':'').'>'.$equipment_label2.' '.$general_sort_type_2.'</option>
|
||||||
|
<option value="3"'.($sort==3?' selected':'').'>'.$equipment_label3.' '.$general_sort_type_1.'</option>
|
||||||
|
<option value="4"'.($sort==4?' selected':'').'>'.$equipment_label3.' '.$general_sort_type_2.'</option>
|
||||||
|
<option value="5"'.($sort==5?' selected':'').'>'.$warranty_status.' '.$general_sort_type_1.'</option>
|
||||||
|
<option value="6"'.($sort==6?' selected':'').'>'.$warranty_status.' '.$general_sort_type_2.'</option>
|
||||||
|
<option value="7"'.($sort==7?' selected':'').'>'.$service_status.' '.$general_sort_type_1.'</option>
|
||||||
|
<option value="8"'.($sort==8?' selected':'').'>'.$service_status.' '.$general_sort_type_2.'</option>
|
||||||
|
|
||||||
</select>
|
</select>
|
||||||
<button type="submit">'.$button_apply.'</button>
|
<button type="submit">'.$button_apply.'</button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -39,9 +39,13 @@ $general_updated = 'Update';
|
|||||||
$general_updatedby = 'Update door';
|
$general_updatedby = 'Update door';
|
||||||
|
|
||||||
$general_filters = 'Filters';
|
$general_filters = 'Filters';
|
||||||
|
$general_sort = 'Sorteren';
|
||||||
$general_page = 'Pagina ';
|
$general_page = 'Pagina ';
|
||||||
$general_page_of = ' van ';
|
$general_page_of = ' van ';
|
||||||
|
|
||||||
|
$general_sort_type_1 = 'Laag - Hoog';
|
||||||
|
$general_sort_type_2 = 'Hoog - Laag';
|
||||||
|
|
||||||
$general_prev = '«';
|
$general_prev = '«';
|
||||||
$general_next = '»';
|
$general_next = '»';
|
||||||
$general_last = '↦'; // Last->
|
$general_last = '↦'; // Last->
|
||||||
|
|||||||
@@ -39,9 +39,13 @@ $general_updated = 'Updated';
|
|||||||
$general_updatedby = 'Updatedby';
|
$general_updatedby = 'Updatedby';
|
||||||
|
|
||||||
$general_filters = 'Filters';
|
$general_filters = 'Filters';
|
||||||
|
$general_sort = 'Sort';
|
||||||
$general_page = 'Page ';
|
$general_page = 'Page ';
|
||||||
$general_page_of = ' of ';
|
$general_page_of = ' of ';
|
||||||
|
|
||||||
|
$general_sort_type_1 = 'Low - High';
|
||||||
|
$general_sort_type_1 = 'High - Low';
|
||||||
|
|
||||||
$general_prev = '«';
|
$general_prev = '«';
|
||||||
$general_next = '»';
|
$general_next = '»';
|
||||||
$general_last = '↦'; // Last->
|
$general_last = '↦'; // Last->
|
||||||
|
|||||||
Reference in New Issue
Block a user