ok
Direktori : /home2/selectio/www/lilyexpresslive/expense-invoice/api/ |
Current File : /home2/selectio/www/lilyexpresslive/expense-invoice/api/employee-data-table.php |
<?php ob_start(); session_start(); include"../config/config.php"; $allPermissions=$_SESSION['permission']; $requestData= $_REQUEST; if($requestData['length']=='-1'){ $requestData['length']=100000; } /*Fetch Database column Details*/ $columns = array( 0 =>'id', 1 =>'employee_name', 2 =>'employee_mobile', 3 =>'employee_role', 4 =>'office', 5 =>'location', 6 =>'status', 7 =>'salary', 8 =>'name' ); $location_id=$_REQUEST['location']; $start_date=$_REQUEST['start_date']; $end_date=$_REQUEST['end_date']; $conditions=""; if($location_id!=0){ $conditions.=" and e.location=".$location_id; } /*Fetch All Data Start*/ $statement = $pdo->prepare("SELECT * FROM tbl_employee e where 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 e.*,u.name,l.office,l.location as location_name FROM `tbl_employee` e inner join users u on e.user_id=u.id inner join tbl_exp_location l on e.location=l.id where e.status=1 ".$conditions." "; if( !empty($_REQUEST['search']) ) { /* $sql.=" AND ( e.employee_name LIKE '%".$_REQUEST['search']."%' "; $sql.=" OR e.location LIKE '%".$_REQUEST['search']."%' "; $sql.=" OR e.employee_mobile LIKE '%".$_REQUEST['search']."%' "; $sql.=" OR e.employee_role LIKE '%".$_REQUEST['search']."%' ) ";*/ } /* $statement = $pdo->prepare($sql); $statement->execute(); $query = $statement->fetchAll(PDO::FETCH_ASSOC); $totalFiltered = $statement->rowCount();*/ /*Fetch Filter Data End*/ $sql.=" ORDER BY ". $columns[$requestData['order'][0]['column']]." ".$requestData['order'][0]['dir']." LIMIT ".$requestData['start']." ,".$requestData['length']." "; error_log($sql); $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['employee']['update']=="1"){ $action.=" <a style='padding: 6px;margin-right: 3px;' href='employee-edit.php?id=".$row["id"]."' title='Edit Employee' class='tip btn btn-warning btn-xs'><i class='fa fa-edit'></i></a> "; } if($allPermissions['employee']['delete']=="1"){ $action.=" <button style='padding: 6px;margin-right: 3px;' value='11' title='Delete Employee' onClick='delete_employee(".$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["employee_name"]; $nestedData[] = $row["employee_mobile"]; $nestedData[] = $row["employee_role"]; $nestedData[] = $row["location_name"]; $nestedData[] = $row["name"]; $data[] = $nestedData; $i++; } $json_data = array( "draw" => intval( $requestData['draw'] ), "recordsTotal" => intval( $totalData ), "recordsFiltered" => intval( $totalFiltered ), "data" => $data ); echo json_encode($json_data); ?>