ok
Direktori : /home2/selectio/www/lilyexpresslive/expense-invoice/api/ |
Current File : /home2/selectio/www/lilyexpresslive/expense-invoice/api/users-data-table.php |
<?php ob_start(); session_start(); include"../config/config.php"; $allPermissions=$_SESSION['permission']; $requestData= $_REQUEST; /*Fetch Database column Details*/ $columns = array( 0 =>'id', 1 =>'name', 2 =>'email', 3 =>'password', 4 =>'phone', 5 =>'address', 6 =>'role', 7 =>'role_id', 8 =>'location', 9 =>'profile_photo_path' ); $conditions=""; /*Fetch All Data Start*/ $statement = $pdo->prepare("SELECT * FROM users e where e.id!=1 and e.status=1 ".$conditions." ORDER BY e.id DESC"); $statement->execute(); $query = $statement->fetchAll(PDO::FETCH_ASSOC); $totalData = $statement->rowCount(); $totalFiltered = $totalData; /*Fetch All Data End*/ /*Fetch Filter Data Start*/ $sql="SELECT *,(select role_name from tbl_role where id=e.role) as role_name FROM users e where e.id!=1 and e.status=1 ".$conditions; if( !empty($_REQUEST['search']) ) { $sql.=" AND ( e.name LIKE '%".$_REQUEST['search']."%' "; $sql.=" OR e.email '%".$_REQUEST['search']."%' ) "; } /*Fetch Filter Data End*/ $sql.=" ORDER BY ". $columns[$requestData['order'][0]['column']]." ".$requestData['order'][0]['dir']." LIMIT ".$requestData['start']." ,".$requestData['length']." "; $statement = $pdo->prepare($sql); $statement->execute(); $query = $statement->fetchAll(PDO::FETCH_ASSOC); $data = array(); $i=1; foreach( $query as $row ) { // preparing an array $nestedData=array(); $action= "<div class='text-center'><div class='btn-group'>"; if($allPermissions['user']['update']=="1"){ $action.="<a style='padding: 6px;margin-right: 3px;' href='users-edit.php?id=".$row["id"]."' title='Edit Users' class='tip btn btn-warning btn-xs'> <i class='fa fa-edit'></i> </a> "; } if($allPermissions['user']['delete']=="1"){ $action.=" <button style='padding: 6px;margin-right: 3px;' value='11' title='Delete Users' onClick='delete_users(".$row["id"].")' class='tip btn btn-danger btn-xs'> <i class='fa fa-trash-o'></i> </button>"; } $action.="</div></div>"; $nestedData[] = $action; $nestedData[] = $i; $nestedData[] = $row["name"]; $nestedData[] = $row["password"]; $nestedData[] = $row["phone"]; $nestedData[] = $row["role_name"]; $nestedData[] = $row["email"]; $nestedData[] = $row["location"]; /*$nestedData[] = $row["created_at"]; $nestedData[] = $row["updated_at"];*/ /*$nestedData[] = $row["email_verified_at"]; $nestedData[] = $row["password"]; $nestedData[] = $row["two_factor_secret"]; $nestedData[] = $row["two_factor_recovery_codes"]; $nestedData[] = $row["phone"]; $nestedData[] = $row["address"]; $nestedData[] = $row["role"]; $nestedData[] = $row["role_id"]; $nestedData[] = $row["location"]; $nestedData[] = $row["remember_token"]; $nestedData[] = $row["current_team_id"]; $nestedData[] = $row["profile_photo_path"]; $nestedData[] = $row["created_at"]; $nestedData[] = $row["updated_at"];*/ $data[] = $nestedData; $i++; } $json_data = array( "draw" => intval( $requestData['draw'] ), "recordsTotal" => intval( $totalData ), "recordsFiltered" => intval( $totalFiltered ), "data" => $data ); echo json_encode($json_data); ?>