ok
Direktori : /home2/selectio/www/vijay-gases/data-tables/ |
Current File : /home2/selectio/www/vijay-gases/data-tables/supplier-data-table.php |
<?php ob_start(); session_start(); include"../config/config.php"; $requestData= $_REQUEST; /*Fetch Database column Details*/ $columns = array( 0 =>'id', 1 =>'customer_name', 2 =>'mobile_number', 3 =>'address', 4 =>'status', 5 =>'location_id', 6 =>'cust_type' ); $conditions=""; /*Fetch All Data Start*/ $statement = $pdo->prepare("SELECT e.*,tbl_location.name FROM tbl_customer e LEFT JOIN tbl_location ON e.location_id=tbl_location.id where 1=1 and e.cust_type=2 ".$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.*,tbl_location.name FROM tbl_customer e LEFT JOIN tbl_location ON e.location_id=tbl_location.id where 1=1 and e.cust_type=2 ".$conditions; if( !empty($_REQUEST['search']) ) { $sql.=" AND ( e.customer_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'>"; $action.="<a style='padding: 6px;margin-right: 3px;' href='modal/supplier-edit.php?id=".$row["id"]."' data-toggle='ajax-modal' title='Edit Supplier' class='tip btn btn-warning btn-xs'> <i class='fa fa-edit'></i> </a> "; $action.=" <button style='padding: 6px;margin-right: 3px;' value='11' title='Delete Supplier' onClick='delete_supplier(".$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["customer_name"]; if($row["customer_name2"]!=''){$nestedData[] = "<span>".$row['customer_name2']."</span>";}else{$nestedData[] = "<span>Null</span>";} $nestedData[] = $row["mobile_number"]; $nestedData[] = $row["address"]; $nestedData[] = $row["name"]; if($row["gst_no"]!=''){$nestedData[] = "<span>".$row['gst_no']."</span>";}else{$nestedData[] = "<span>Null</span>";} 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>";} $data[] = $nestedData; $i++; } $json_data = array( "draw" => intval( $requestData['draw'] ), "recordsTotal" => intval( $totalData ), "recordsFiltered" => intval( $totalFiltered ), "data" => $data ); echo json_encode($json_data); ?>