ok
Direktori : /home2/selectio/www/saew.in/admin/data-tables/ |
Current File : /home2/selectio/www/saew.in/admin/data-tables/desgination-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 =>'desgination', 2 =>'departement_id', 3 =>'status', 4 =>'created_at', 5 =>'updated_at', 6 =>'id', 7 =>'id', 8 =>'id' ); $conditions=""; $department=$_REQUEST['department']; $designation=$_REQUEST['designation']; if(!empty($department)){ $conditions.=" and h.departement_id ='$department'"; } if(!empty($designation)){ $conditions.=" and h.desgination ='$designation'"; } //$filter_month=$_REQUEST['filter_month']; // $filter_year=$_REQUEST['filter_year']; // $filter_created_by=$_REQUEST['filter_created_by']; // $filter_updated_by=$_REQUEST['filter_updated_by']; // $conditions=""; // if($filter_month!=''){ // $conditions.=" and h.month=".$filter_month; // } // if($filter_year!="" ){ // $conditions.=" and h.year=".$filter_year; // } // if($filter_created_by!=''){ // $conditions.=" and h.created_at=".$filter_created_by; // } // if($filter_updated_by!=''){ // $conditions.=" and h.updated_at=".$filter_updated_by; // } /*Fetch All Data Start*/ $statement = $pdo->prepare("SELECT h.* FROM tbl_desgination h where h.id!=0 ".$conditions." ORDER BY h.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 h.*,(select departement from tbl_departement WHERE tbl_departement.id=h.departement_id) as departement_id FROM tbl_desgination h where h.id!=0".$conditions; if( !empty($_REQUEST['search']) ) { $sql.=" AND ( h.desgination LIKE '%".$_REQUEST['search']."%' "; $sql.=" OR h.created_at LIKE '%".$_REQUEST['search']."%'"; $sql.=" OR h.updated_at LIKE '%".$_REQUEST['search']."%' ) "; $sql.=" OR h.departement_id LIKE '%".$_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($_SESSION['hrm']['id']==1 || $allPermissions['designation']['update']=="1"){ $action.=" <a style='padding: 6px;margin-right: 3px;' href='desgination-edit.php?id=".$row["id"]."' title='Edit Designation' class='tip btn btn-warning btn-xs'> <i class='fa fa-edit'></i> </a>"; } if($_SESSION['hrm']['id']==1 || $allPermissions['designation']['delete']=="1"){ $action.=" <button style='padding: 6px;margin-right: 3px;' title='Delete Designation Details' onClick='delete_designation(".$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["desgination"]; $nestedData[] = $row["departement_id"]; if($row["status"]==1){ $nestedData[] ="<span class='btn btn-success btn-xs'><i class='fa fa-eye'></i> Active</span>";}else{$nestedData[] ="<span onClick='dynamic_active(".$row["id"].")' class='btn btn-danger btn-xs'><i class='fa fa-eye-slash'> In-active</span>";} if($row["created_at"]!=""){ $nestedData[] =date('d-m-Y h:i:s A', strtotime($row["created_at"]));}else{$nestedData[] ="";} if($row["updated_at"]!=""){ $nestedData[] =date('d-m-Y h:i:s A', strtotime($row["updated_at"]));}else{$nestedData[] ="";} $data[] = $nestedData; $i++; } $json_data = array( "draw" => intval( $requestData['draw'] ), "recordsTotal" => intval( $totalData ), "recordsFiltered" => intval( $totalFiltered ), "data" => $data ); echo json_encode($json_data); ?>