JezK
Edit File: dashboard-ajax.php
<?php include_once("adminObj.php"); // include('../../app/checkSession.php'); // print_r($_SESSION); if($_SESSION['user_id']!=''){ $company_id=$_SESSION['company_id']; $subQuery=" and umw.company_id =$company_id"; } if( $_GET['id']==1){ // echo $_GET['id']; $data =array(); $limit = ""; $tableColumns=array('umw.warehouse_number','umw.warehouse_name','uc.country_name','uws.warehouse_status'); if (isset($_GET['iDisplayStart'] ) && $_GET['iDisplayLength'] != '-1' ) { $limit = "OFFSET ".$wareHouseAdminObj->db->escape($_GET['iDisplayStart'] )." LIMIT ". $wareHouseAdminObj->db->escape($_GET['iDisplayLength'] ); } $order="Order by warehouse_id desc"; $whereCondition = ""; if ( $_GET['sSearch'] != "" ) { $whereCondition = "and ("; for ( $i=0 ; $i<count($tableColumns) ; $i++ ) { $whereCondition .= $tableColumns[$i]." ILIKE '%".$wareHouseAdminObj->db->escape($_GET['sSearch'] )."%' OR "; } $whereCondition = substr_replace( $whereCondition, "", -3 ); $whereCondition .= ') '; } $sql= "select uws.warehouse_status,uc.country_name ,uc.display_name, umw.* from uflexit_countries as uc JOIN uflexit_master_wareHouse as umw ON umw.warehouse_country_id=uc.country_id join uflexit_warehouse_status as uws on uws.status_type=umw.warehouse_status where umw.warehouse_status=1 $subQuery $whereCondition $order $limit "; $rows = $wareHouseAdminObj->db->get_results($sql); $totalRecord = count($rows); $query="select count(*) from uflexit_countries as uc JOIN uflexit_master_wareHouse as umw ON umw.warehouse_country_id=uc.country_id join uflexit_warehouse_status as uws on uws.status_type=umw.warehouse_status where umw.warehouse_status=1 $subQuery $whereCondition "; $count_result = $wareHouseAdminObj->db->get_results($query); // $res_rec=$customerObj->db->get_results($count_result); $totalRecords = 0; if($count_result !="" && $count_result[0] !="") { $totalRecords = $count_result[0]['count']; } if($totalRecord>0) { $j=1; foreach($rows as $fetch) { $active = "In active"; $statusCls='style="color:green"'; if($fetch['warehouse_status']==1) { $active= "active"; } $fetch['country_name'] = $fetch["display_name"]; $fetch['status'] = '<span '.$statusCls.'>'.$active.'<span>'; // $fetch['id'] = $j++; $fetch['id'] = (1*$_GET['iDisplayStart'])+$j; $j++; $fetch['action']='<small class="d-inline-flex tableData smallFont"> <a href="warehouse_details.php?wid='.$fetch["warehouse_id"].'" class="pr-2" title="More"><img src="images/more.png" /></a> <a href="edit-warehouse.php?wid='.$fetch["warehouse_id"].'" title="Edit"><img src="images/edit.png" /></a> </small>'; $data[]=$fetch; } } $data = ["sEcho" => intval($_GET['sEcho']), "iTotalRecords" => $totalRecord, "iTotalDisplayRecords" => $totalRecords, "aaData" => $data ]; echo json_encode($data); exit; } if( $_GET['id']==0){ // echo $_GET['id']; $data =array(); $limit = ""; $tableColumns=array('umw.warehouse_number','umw.warehouse_name','uc.country_name','uws.warehouse_status'); if (isset($_GET['iDisplayStart'] ) && $_GET['iDisplayLength'] != '-1' ) { $limit = "OFFSET ".$wareHouseAdminObj->db->escape($_GET['iDisplayStart'] )." LIMIT ". $wareHouseAdminObj->db->escape($_GET['iDisplayLength'] ); } $order="Order by warehouse_id desc"; $whereCondition = ""; if ( $_GET['sSearch'] != "" ) { $whereCondition = "and ("; for ( $i=0 ; $i<count($tableColumns) ; $i++ ) { $whereCondition .= $tableColumns[$i]." ILIKE '%".$wareHouseAdminObj->db->escape(strtolower($_GET['sSearch']) )."%' OR "; } $whereCondition = substr_replace( $whereCondition, "", -3 ); $whereCondition .= ') '; } $sql= "select uws.warehouse_status,uc.country_name ,uc.display_name, umw.* from uflexit_countries as uc JOIN uflexit_master_wareHouse as umw ON umw.warehouse_country_id=uc.country_id join uflexit_warehouse_status as uws on uws.status_type=umw.warehouse_status where umw.warehouse_status=0 $subQuery $whereCondition $order $limit "; $rows = $wareHouseAdminObj->db->get_results($sql); $totalRecord = count($rows); $query="select count(*) from uflexit_countries as uc JOIN uflexit_master_wareHouse as umw ON umw.warehouse_country_id=uc.country_id join uflexit_warehouse_status as uws on uws.status_type=umw.warehouse_status where umw.warehouse_status=0 $subQuery $whereCondition "; $count_result = $wareHouseAdminObj->db->get_results($query); // $res_rec=$customerObj->db->get_results($count_result); $totalRecords = 0; if($count_result !="" && $count_result && $count_result[0] !="") { $totalRecords = $count_result[0]['count']; } if($totalRecord>0) { $j=1; foreach($rows as $fetch) { $active = "In active"; $statusCls='style="color:orange"'; if($fetch['warehouse_status']==0) { $active= "pending"; } $fetch['status'] = '<span '.$statusCls.'>'.$active.'<span>'; $fetch['id'] = (1*$_GET['iDisplayStart'])+$j; $j++; $fetch['action']='<small class="d-inline-flex tableData smallFont"> <a href="warehouse_details.php?wid='.$fetch["warehouse_id"].'" class="pr-2" title="More"><img src="images/more.png" /></a> <a href="edit-warehouse.php?wid='.$fetch["warehouse_id"].'" title="Edit"><img src="images/edit.png" /></a> </small>'; $data[]=$fetch; } } $data = ["sEcho" => intval($_GET['sEcho']), "iTotalRecords" => $totalRecord, "iTotalDisplayRecords" => $totalRecords, "aaData" => $data ]; echo json_encode($data); exit; } if( $_GET['id']==2){ // echo $_GET['id']; $data =array(); $limit = ""; $tableColumns=array('umw.warehouse_number','umw.warehouse_name','uc.country_name','uws.warehouse_status'); if (isset($_GET['iDisplayStart'] ) && $_GET['iDisplayLength'] != '-1' ) { $limit = "OFFSET ".$wareHouseAdminObj->db->escape($_GET['iDisplayStart'] )." LIMIT ". $wareHouseAdminObj->db->escape($_GET['iDisplayLength'] ); } $order="Order by warehouse_id desc"; $whereCondition = ""; if ( $_GET['sSearch'] != "" ) { $whereCondition = "and ("; for ( $i=0 ; $i<count($tableColumns) ; $i++ ) { $whereCondition .= $tableColumns[$i]." LIKE '%".$wareHouseAdminObj->db->escape(strtolower($_GET['sSearch']) )."%' OR "; } $whereCondition = substr_replace( $whereCondition, "", -3 ); $whereCondition .= ') '; } $sql= "select uws.warehouse_status,uc.country_name ,uc.display_name, umw.* from uflexit_countries as uc JOIN uflexit_master_wareHouse as umw ON umw.warehouse_country_id=uc.country_id join uflexit_warehouse_status as uws on uws.status_type=umw.warehouse_status where (umw.warehouse_status=2 or umw.warehouse_status=3) $subQuery $whereCondition $order $limit "; $rows = $wareHouseAdminObj->db->get_results($sql); $totalRecord = count($rows); $query="select count(*) from uflexit_countries as uc JOIN uflexit_master_wareHouse as umw ON umw.warehouse_country_id=uc.country_id join uflexit_warehouse_status as uws on uws.status_type=umw.warehouse_status where (umw.warehouse_status=2 or umw.warehouse_status=3) $subQuery $whereCondition "; $count_result = $wareHouseAdminObj->db->get_results($query); // $res_rec=$customerObj->db->get_results($count_result); $totalRecords = 0; if($count_result !="" && $count_result[0] !="") { $totalRecords = $count_result[0]['count']; } if($totalRecord>0) { $j=1; foreach($rows as $fetch) { $active = "In active"; $statusCls='style="color:red"'; if($fetch['warehouse_status']==2) { $active= "Rejected"; }else if($fetch['warehouse_status']==3) { $active= "Blocked"; } $fetch['status'] = '<span '.$statusCls.'>'.$active.'<span>'; $fetch['id'] = (1*$_GET['iDisplayStart'])+$j; $j++; $fetch['action']='<small class="d-inline-flex tableData smallFont"> <a href="warehouse_details.php?wid='.$fetch["warehouse_id"].'" class="pr-2" title="More"><img src="images/more.png" /></a> <a href="edit-warehouse.php?wid='.$fetch["warehouse_id"].'" title="Edit"><img src="images/edit.png" /></a> </small>'; $data[]=$fetch; } } $data = ["sEcho" => intval($_GET['sEcho']), "iTotalRecords" => $totalRecord, "iTotalDisplayRecords" => $totalRecords, "aaData" => $data ]; echo json_encode($data); exit; } ?>