ok

Mini Shell

Direktori : /home2/selectio/www/lilyexpresslive/software/admin/data-tables/
Upload File :
Current File : /home2/selectio/www/lilyexpresslive/software/admin/data-tables/add_cash_dt.php

<?php
include("../inc/config.php");

$requestData= $_REQUEST;
    $from = $_REQUEST['from'];
    $to = $_REQUEST['to'];
    $type_of = $_REQUEST['type'];
    $sort_location = $_REQUEST['sort_location'];
/*Fetch Database column Details*/
        $columns = array( 
            0 =>'id', 
            1 =>'type', 
            2 =>'amount', 
            3 =>'note',
            4 =>'cash_date',
            5 =>'location'
        );
                          $condition="";
/*Fetch All Data Start*/    
                            
                             if($type_of!='none')
                            {
                                  $condition.=" WHERE tc.type =$type_of";
                            }
                            
                             if($type_of!='none')
                            {
                                $condition.=" AND tc.cash_date BETWEEN '$from' AND '$to' ";
                            }
                            elseif($from!='' && $to!='')
                            {
                                $condition.=" WHERE tc.cash_date BETWEEN '$from' AND '$to' ";
                            }
                            
                             if($sort_location!='none')
                            {
                                $condition.=" AND tc.location='$sort_location'  ";
                            }
                            
                           
                            
        
							$statement = $pdo->prepare("SELECT tc.*,tel.location as office FROM tbl_cash tc inner join tbl_exp_location tel ON tc.location=tel.id $condition");
                    		$statement->execute();
                    		$query = $statement->fetchAll(PDO::FETCH_ASSOC);
                    		$totalData = $statement->rowCount();
                            $totalFiltered = $totalData;
/*Fetch All Data End*/       
        
/*Fetch Filter Data Start*/    
         	                
							$sql = "SELECT tc.*,tel.location as office FROM tbl_cash tc inner join tbl_exp_location tel ON tc.location=tel.id $condition";
         
                        if( !empty($requestData['search']['value']) ) 
                        {   
                        	$sql.=" AND ( tc.type LIKE '%".$requestData['search']['value']."%' ";    
                        	$sql.=" OR tc.amount LIKE '%".$requestData['search']['value']."%' ";    
                        	$sql.=" OR tc.note LIKE '%".$requestData['search']['value']."%' ";
                        	$sql.=" OR tc.amount LIKE '%".$requestData['search']['value']."%' ";
                        	$sql.=" OR tel.location LIKE '%".$requestData['search']['value']."%' ";
                        	$sql.=" OR tc.cash_date 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']."   ";
        //  $requestData['order'][0]['column'] contains colmun index, $requestData['order'][0]['dir'] contains order such as asc/desc  */	
        $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(); 
 	$nestedData[] = $i;
 	if($row["type"]==1){ $type="<button class='btn btn-info btn-xs'>Credit&ensp;<i class='fa fa-plus-square'></i></button>";}
	elseif($row["type"]==2){ $type="<button class='btn btn-success btn-xs'>Debit&ensp;<i class='fa fa-minus-square'></i></button>";}
	$nestedData[] = $type;
	$nestedData[] = '&#8377;'.$row["amount"];
	$nestedData[] = $row["office"];
	$nestedData[] = $row["note"];
	$day=date_create($row['cash_date']);
    $date=date_format($day,'d-m-Y');
	$nestedData[] = $date;
	$nestedData[] = "<a href='cash-edit.php?id=".$row['id']."' class='btn btn-primary btn-xs'>Edit</a><a href='#' class='btn btn-danger btn-xs' data-href='cash-delete.php?id=".$row['id']."' data-toggle='modal' data-target='#confirm-delete'>Delete</a>";
	$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