ok
Direktori : /home2/selectio/public_html/saew.in/admin/data-tables/ |
Current File : /home2/selectio/public_html/saew.in/admin/data-tables/holidays-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 =>'id', 2 =>'holiday_date', 3 =>'reason', 4 =>'created_at', 5 =>'updated_at' /* 8 =>'created_by', 9 =>'updated_by'*/ ); $conditions=""; // $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.*,(select emp_name from tbl_user where id=h.created_by) as created_by_name,(select emp_name from tbl_user where id=h.updated_by) as updated_by_name FROM `tbl_holidays` h where 1=1 ".$conditions." ORDER BY h.id DESC");*/ $statement = $pdo->prepare("SELECT h.* FROM tbl_holidays 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 emp_name from tbl_user where id=h.created_by) as created_by_name,(select emp_name from tbl_user where id=h.updated_by) as updated_by_name FROM `tbl_holidays` h where 1=1 ".$conditions; $sql="SELECT h.* FROM tbl_holidays h where h.id!=0".$conditions; if( !empty($_REQUEST['search']) ) { $sql.=" AND ( h.reason LIKE '%".$_REQUEST['search']."%' ) "; } /*Fetch Filter Data End*/ if($requestData['length']==-1){ $requestData['length']=100000; } $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['holidays']['update']=="1"){ $action.=" <a style='padding: 6px;margin-right: 3px;' href='holiday-edit.php?id=".$row["id"]."' title='Edit Holiday' class='tip btn btn-warning btn-xs'> <i class='fa fa-edit'></i> </a>"; } if($_SESSION['hrm']['id']==1 || $allPermissions['holidays']['delete']=="1"){ $action.=" <button style='padding: 6px;margin-right: 3px;' title='Delete Holiday' onClick='delete_holiday(".$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["holiday_date"]; // $nestedData[] = str_pad($row["month"], 2, "0", STR_PAD_LEFT); // $nestedData[] = $row["year"]; $nestedData[] = $row["reason"]; // if($row["type"]==1){ $nestedData[] ="Executive Holidays";}else if($row["status"]==2){$nestedData[] ="National Holidays";}else if($row["status"]==3){$nestedData[] ="Restricted Holidays";} if($row["created_at"]!=""){ $nestedData[] =date('d-m-Y', strtotime($row["created_at"]));}else{$nestedData[] ="";} if($row["updated_at"]!=""){ $nestedData[] =date('d-m-Y', strtotime($row["updated_at"]));}else{$nestedData[] ="";} /*$nestedData[] = $row["created_by_name"]; $nestedData[] = $row["updated_by_name"];*/ $data[] = $nestedData; $i++; } $json_data = array( "draw" => intval( $requestData['draw'] ), "recordsTotal" => intval( $totalData ), "recordsFiltered" => intval( $totalFiltered ), "data" => $data ); echo json_encode($json_data); ?>