ok
Direktori : /home2/selectio/public_html/subamangala/admin/data-tables/ |
Current File : /home2/selectio/public_html/subamangala/admin/data-tables/sub-caste-datatable.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 =>'name', 3 =>'name' ); $conditions=""; $filter_caste_id=$_POST['caste_id']; if($filter_caste_id!='' && $filter_caste_id!='0'){ $conditions.=" and h.casteid='".$filter_caste_id."'"; } /*Fetch All Data Start*/ $statement = $pdo->prepare("SELECT h.*,caste.name as cas_name FROM `subcaste` h LEFT JOIN caste ON caste.id=h.casteid where h.id!=0 ".$conditions." GROUP BY h.name ORDER BY h.id DESC"); $result = $statement->execute(); $query = $statement->fetchAll(PDO::FETCH_ASSOC); $totalData = $statement->rowCount(); $totalFiltered = $totalData; /*Fetch All Data End*/ /*Fetch Filter Data Start*/ $sql="SELECT h.*,caste.name as cas_name FROM `subcaste` h LEFT JOIN caste ON caste.id=h.casteid where h.id!=0".$conditions." GROUP BY h.name " ; if( !empty($_REQUEST['search']) ) { $sql.=" AND ( h.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(); $i=1; foreach( $query as $row ) { // preparing an array $nestedData=array(); $action= "<div class='text-center'><div class='btn-group'>"; //if($allPermissions['category']['update']=="1"){ $action.=" <a style='padding: 6px;margin-right: 3px;' href='modal/cities-details-update.php?id=".$row["id"]."' data-toggle='ajax-modal' title='Edit Departement' class='tip btn btn-warning btn-xs'> <i class='fa fa-edit'></i> </a>"; //} //if($allPermissions['category']['delete']=="1"){ $action.=" <button style='padding: 6px;margin-right: 3px;' title='Delete City Details' onClick='delete_cities(".$row["id"].")' class='tip btn btn-danger btn-xs'> <i class='fa fa-trash-o'></i> </button>"; // } $action.="</div></div>"; // $nestedData[] = $action; if($row["status"]==1){ $status = "<div class='text-center'><span class='btn btn-success btn-xs'><i class='fa fa-eye'></i> Active</span></div>"; }else if($row["status"]==0){ $status = "<div class='text-center'><span class='btn btn-danger btn-xs'><i class='fa fa-eye-slash'></i> In-Active</span></div>"; } $nestedData[] = $i; $nestedData[] = $row["cas_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); ?>