ok

Mini Shell

Direktori : /home2/selectio/public_html/lilyexpresslive/expense-invoice/api/
Upload File :
Current File : /home2/selectio/public_html/lilyexpresslive/expense-invoice/api/cash-data-table.php

<?php 
ob_start();
session_start();
include"../config/config.php";


$requestData= $_REQUEST;
$allPermissions=$_SESSION['permission'];

/*Fetch Database column Details*/
        $columns = array( 
            0 =>'id', 
            1 =>'user_id', 
            2 =>'type',
            3 =>'location',
            4 =>'otherLocation',
            5 =>'amount',
            6 =>'cash_date',
            7 =>'note'
        );
        
$location_id=$_REQUEST['location'];
$status=$_REQUEST['status'];
$start_date=$_REQUEST['start_date'];
$end_date=$_REQUEST['end_date'];
$conditions="";
if($location_id!=0){
	$conditions.=" and e.location=".$location_id;
}
if($start_date!="" && $end_date!=""){
	$conditions.=" and (e.cash_date BETWEEN '$start_date' AND '$end_date') ";
}
if($status!="0" ){
	$conditions.=" and e.type='$status'";
}

        
/*Fetch All Data Start*/        
        
    	$statement = $pdo->prepare("SELECT * FROM tbl_cash e where e.id!=0 ".$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.*,users.name,(select location from tbl_exp_location where id=e.location) as location_name,(select location from tbl_exp_location where id=e.otherLocation) as trnsfer_location_name FROM `tbl_cash` e inner join users on e.user_id=users.id where e.id!=0 ".$conditions;
         
        if( !empty($_REQUEST['search']) ) 
        {   
        	$sql.=" AND ( e.note LIKE '%".$_REQUEST['search']."%' ";    
        	$sql.=" OR users.name LIKE '%".$_REQUEST['search']."%'  ) ";
        }
       
        	 
      /* $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=1;
foreach( $query as $row ) {  // preparing an array
	$nestedData=array(); 

    $action= "<div class='text-center'><div class='btn-group'>";
	 
	 if($allPermissions['cash']['update']=="1"){                   
		               $action.="<a style='padding: 6px;margin-right: 3px;' href='cash-edit.php?id=".$row["id"]."' title='Edit Cash' class='tip btn btn-warning btn-xs'><i class='fa fa-edit'></i></a> ";
	 }	                
	if($allPermissions['cash']['delete']=="1"){	                
		                $action.=" <button style='padding: 6px;margin-right: 3px;' value='11' title='Delete Cash' onClick='delete_cash(".$row["id"].")' class='tip btn btn-danger btn-xs'><i class='fa fa-trash-o'></i></button>";
	}
		 	$action.="</div></div>";
		 	$nestedData[] = $action;
		 
		 
		 
		 
		 
	$nestedData[] = $i;
	
	if($row["type"]==1){
		$type="<button class='tip btn btn-success btn-xs'>Cash</button>";
	}else if($row["type"]==2){
		$type="<button class='tip btn btn-danger btn-xs'>Depit Cash</button>";
	}
	else if($row["type"]==3){
		$type="<button class='tip btn btn-warning btn-xs'>Transfer Cash</button>";
	}
	else if($row["type"]==4){
		$type="<button class='tip btn btn-warning btn-xs'>Card</button>";
	}
	else if($row["type"]==5){
		$type="<button class='tip btn btn-warning btn-xs'>UPI Transfer</button>";
	}
	else if($row["type"]==6){
		$type="<button class='tip btn btn-warning btn-xs'>Acc Transfer</button>";
	}
	else {
		$type="<button class='tip btn btn-default btn-xs'>---</button>";
	}
	$nestedData[] = $type;
	
	$nestedData[] = $row["amount"];
	$nestedData[] = $row["transaction_id"];
	$nestedData[] = $row["note"];
	$nestedData[] = $row["name"];
	$nestedData[] = $row["location_name"];
$nestedData[] = $row["cash_date"];
$nestedData[] = $row["updated_at"];

	
	$data[] = $nestedData;
	$i++;
}

$json_data = array(
			"draw"            => intval( $requestData['draw'] ),  
			"recordsTotal"    => intval( $totalData ),  
			"recordsFiltered" => intval( $totalFiltered ), 
			"data"            => $data   
			);

echo json_encode($json_data); 




?>

Zerion Mini Shell 1.0