ok
Direktori : /home2/selectio/public_html/thedentalpark.com/admin/data-tables/ |
Current File : /home2/selectio/public_html/thedentalpark.com/admin/data-tables/course-data-table.php |
<?php ob_start(); session_start(); include"../config/config.php"; $requestData = $_REQUEST; /*Fetch Database column Details*/ $columns = array( 0 =>'id', 1 =>'id', 2 =>'id', 3 =>'id', 4 =>'id', 5 =>'id', 6 =>'id', 7 =>'id', 8 =>'id', 9 =>'id' ); $conditions=""; $college_id = $_POST['college_id']; $status = $_POST['status']; if($status!=""){ $conditions.=" and co.status=".$status; } if($college_id!=""){ $conditions.=" and co.college_id=".$college_id; } $sql_query = "SELECT co.*,c.college_name FROM tbl_course as co LEFT JOIN tbl_college as c ON c.id = co.college_id AND c.status=1 "; /*Fetch All Data Start*/ $statement = $pdo->prepare("$sql_query WHERE 1=1 ".$conditions." ORDER BY id DESC"); $statement->execute(); $query = $statement->fetchAll(PDO::FETCH_ASSOC); $totalData = $statement->rowCount(); $totalFiltered = $totalData; /*Fetch All Data End*/ /*Fetch Filter Data Start*/ $sql = "$sql_query WHERE 1=1 ".$conditions; if( !empty($_REQUEST['search'])){ $sql.=" AND ( c.college_name LIKE '%".$_REQUEST['search']."%' OR co.course_name 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(); // error_log($sql); $i=1; foreach($query as $row){ $nestedData = array(); $create_at = date('d M Y h:ia',strtotime($row["created_at"])); $action= "<div class='text-center'><div class='btn-group'>"; $action.="<a style='padding: 6px;margin-right: 3px;' href='course-add.php?id=".$row["id"]."' title='Edit Course' class='tip btn btn-warning btn-xs'> <i class='fa fa-edit'></i> </a> "; $action.=" <a style='padding: 6px;margin-right: 3px;' href='course-list.php?del_id=".$row["id"]."' title='Delete Course' class='tip btn btn-danger btn-xs course_delete'> <i class='fa fa-trash-o'></i> </a>"; $action.="</div></div>"; $nestedData[] = $action; $nestedData[] = "<div class='text-center'>".$i."</div>"; $nestedData[] = "<div class='text-center'>".$row["college_name"]."</div>"; $nestedData[] = "<div class='text-center'>".$row['course_name']."</div>"; if($row["status"]==1){ $nestedData[] ="<div class='text-center'><span class='btn btn-success btn-xs'onClick='DynamicInActive(".$row["id"].")'><i class='fa fa-eye'></i> Active</span></div>"; }else if($row["status"]==0){ $nestedData[] ="<div class='text-center'><span class='btn btn-danger btn-xs' onClick='DynamicActive(".$row["id"].")'><i class='fa fa-eye-slash'></i> In-Active</span></div>"; } $nestedData[] = "<div class='text-center'>".$create_at."</div>"; $data[] = $nestedData; $i++; } $json_data = array( "draw" => intval($requestData['draw']), "recordsTotal" => intval($totalData), "recordsFiltered" => intval($totalFiltered), "data" => $data ); echo json_encode($json_data); ?>