ok

Mini Shell

Direktori : /home2/selectio/www/frames-hub/data-tables/
Upload File :
Current File : //home2/selectio/www/frames-hub/data-tables/client-dt.php

<?php
include("../api/config/config.php");
$requestData= $_REQUEST;
$condition='';
if(isset($_POST['date'])){
    $condition.=" and date between '".$_POST['date']."' and '".$_POST['date']."' ";
}


/*Fetch Database column Details*/
        $columns = array( 
            0 =>'id',
            1 =>'id',
            2 =>'firstname',
            3 =>'mobile',
            4 =>'email',
            5 =>'password',
            6 =>'city',
            7 =>'address',
        );
        
/*Fetch All Data Start*/        
    	$statement = $pdo->prepare("SELECT * FROM client ORDER BY id DESC");
		$statement->execute();
		$query = $statement->fetchAll(PDO::FETCH_ASSOC);
		$totalData = $statement->rowCount();
/*Fetch All Data End*/       
        
/*Fetch Filter Data Start*/    
          $sql="SELECT * FROM client where 1=1 $condition";
         
        if( !empty($requestData['search']['value']) ) 
        {   
        	$sql.=" AND ( id LIKE '%".$requestData['search']['value']."%' ";    
        	$sql.=" OR firstname LIKE '%".$requestData['search']['value']."%' ";    
        	$sql.=" OR lastname LIKE '%".$requestData['search']['value']."%' ";
        	$sql.=" OR email LIKE '%".$requestData['search']['value']."%' ";
        	$sql.=" OR city LIKE '%".$requestData['search']['value']."%' ) ";
        	}
        	 
        $statement = $pdo->prepare($sql);
        $statement->execute();
		$query = $statement->fetchAll(PDO::FETCH_ASSOC);
        $totalFiltered = $statement->rowCount();
        
/*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=$requestData['start']+1;
foreach($query as $row ) {  // preparing an array
	$nestedData=array(); 
	$action='<div class="dropdown">
				<button class="small-btn btn-gray-bg dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false">Action</button>
				<ul class="dropdown-menu" style="">
					<li ><a class="dropdown-item " href="#">Update Client Info</a>
					</li>
					<li ><a class="dropdown-item" href="#">Update KYC</a>
					</li>
					<li><a class="dropdown-item" href="#">View Overall Data</a>
					</li>
				</ul>
			</div>';
	$client_details='<a >'.($row['firstname'].' '.$row['lastname']).'</a>';
	
	if(isset($row['mobile'])){ $client_details.="<br>Mobile :<b>".$row['mobile']."</b>";}
	if(isset($row['email'])){ $client_details.="<br>Email :<b>".$row['email']."</b>";}
	
	 
	$company_details='<a >'.($row['company_name'].' '.$row['company_name']).'</a>';
	 
	if(isset($row['gst_no'])){ $company_details.="<br>GST :<b>".$row['gst_no']."</b>";}
	if(isset($row['kyc_status'])){$kyc="<span class='span-success'> Verified </span>";	} else{$kyc="<span class='span-danger'> Not Verified </span>";}
    $nestedData[] = $action;
    $nestedData[] = $i;
    $nestedData[] = $client_details;
    $nestedData[] = '<img src="'.$row['logo'].'" style="width: 65px;height: 65px;border-radius: 10px;">';
    $nestedData[] = $company_details;
    $nestedData[] = $row['business_type'];
    $nestedData[] = $kyc;
    //$nestedData[] = $i;
    if(isset($row['status'])=="Active"){$status="<span class='span-success'> Active </span>";	} else{$status="<span class='span-danger'> In-Active </span>";}
    $nestedData[] = $status;
	$data[] = $nestedData;
	$i++;
}

$json_data = array(
			"draw"            => intval( $requestData['draw'] ),   // for every request/draw by clientside , they send a number as a parameter, when they recieve a response/data they first check the draw number, so we are sending same number in draw. 
			"recordsTotal"    => intval( $totalData ),  // total number of records
			"recordsFiltered" => intval( $totalFiltered ), // total number of records after searching, if there is no searching then totalFiltered = totalData
			"data"            => $data   // total data array
			);

echo json_encode($json_data);  // send data as json format

?>

Zerion Mini Shell 1.0