ok

Mini Shell

Direktori : /proc/self/root/home2/selectio/www/vijay-gases/data-tables/
Upload File :
Current File : //proc/self/root/home2/selectio/www/vijay-gases/data-tables/sales-data-table.php

<?php 
ob_start();
session_start();
include"../config/config.php";
$requestData= $_REQUEST;

/*Fetch Database column Details*/
        $columns = array( 
            0 =>'h.id', 
            1 =>'sell_date', 
            2 =>'location_id',
            3 =>'total_refill_item',
            4 =>'total_new_item',
            5 =>'total_amount',
            6 =>'paid_amount',
            7 =>'status',
            8 =>'status',
            9 =>'inv_no',
            10 =>'customer_id',
            11 =>'customer_id'
        );
        
$conditions="";

$installed_from_date=$_POST['installed_from_date'];
$installed_to_date=$_POST['installed_to_date'];
$cy_status = $_POST['cy_status'];
$location_id = $_POST['location_id'];


if (!empty($installed_from_date) && !empty($installed_to_date)) {
    $conditions .= " AND h.sell_date BETWEEN '" . $installed_from_date . "' AND '" . $installed_to_date . "'";
}

if (!empty($cy_status)) {
    if ($cy_status == 1 || $cy_status == 2 || $cy_status == 3) {
        $conditions .= " AND tbl_product.product_type = '" . $cy_status . "'";
    }
}

// Make sure to handle empty or invalid $cy_status if needed
if (empty($cy_status) || ($cy_status != 1 && $cy_status != 2 && $cy_status != 3)) {
$conditions.="";
    
}

if(isset($location_id) && $location_id!=0 && $location_id!=''){
    $conditions.=" and h.location_id=".$location_id;
}



/*Fetch Filter Data Start*/    
         $sql="SELECT h.*,h.id as ids,tbl_location.id,tbl_location.name,tbl_customer.id,tbl_customer.customer_name,tbl_product.id,tbl_product.product_name,tbl_product.cylinder_no  FROM `tbl_sell` h LEFT JOIN tbl_sell_items ON tbl_sell_items.sell_id=h.id LEFT JOIN tbl_customer ON tbl_customer.id=h.customer_id LEFT JOIN tbl_location ON h.location_id=tbl_location.id LEFT JOIN tbl_product ON tbl_product.id=tbl_sell_items.product_id where 1=1".$conditions." ";
         
        if( !empty($_REQUEST['search']) ) 
        {   
            $sql.=" AND ( tbl_product.product_name LIKE '%".$_REQUEST['search']."%') ";
        }
        
/*Fetch Filter Data End*/       
        


         $sql.=" GROUP BY h.id ORDER BY ". $columns[$requestData['order'][0]['column']]."   ".$requestData['order'][0]['dir']."  LIMIT ".$requestData['start']." ,".$requestData['length']."   ";
        error_log($sql);
        $statement = $pdo->prepare($sql);
        $statement->execute();
        $query = $statement->fetchAll(PDO::FETCH_ASSOC);
        $totalData = $statement->rowCount();
        $totalFiltered = $totalData;
    //  print_r($query);
        

$data = array();
$i=1;
foreach( $query as $row ) {  // preparing an array
    $nestedData=array(); 
    $action= "<div class='text-center'><div class='btn-group'>";
     
     
     if($row['location_id']!=5){
         $action.="<a style='padding: 6px;margin-right: 3px;' href='sales-invoice-type-1.php?id=".$row["ids"]."' target='_BLANK' title='View Invoice' class='tip btn btn-info btn-xs'>
                            <i class='fa fa-print'></i>
                        </a> ";
     }
                       $action.="<a style='padding: 6px;margin-right: 3px;' href='modal/sales-payment.php?id=".$row["ids"]."' data-toggle='ajax-modal' title='Edit Customer' class='tip btn btn-warning btn-xs'>
                            <i class='fa fa-inr'></i>
                        </a> ";
                         $action.="<a style='padding: 6px;margin-right: 3px;' href='modal/sales-view.php?id=".$row["ids"]."' data-toggle='ajax-modal' title='Edit Customer' class='tip btn btn-success btn-xs'>
                            <i class='fa fa-eye'></i>
                        </a> ";
                        
                        /*$action.=" <button style='padding: 6px;margin-right: 3px;' value='11' title='Delete Users' onClick='delete_users(".$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"];
    $nestedData[] = $row["inv_no"];
    $nestedData[] = $row["cylinder_no"];
    $nestedData[] = $row["name"];
    $nestedData[] = $row["total_refill_item"];
    $nestedData[] = $row["total_new_item"];
    $nestedData[] = $row["total_amount"];
    $nestedData[] = $row["paid_amount"];
    $nestedData[] = abs($row["total_amount"]-$row["paid_amount"]);
    
    
    
    if($row["total_amount"]==0){ 
        $nestedData[] ="<a href='modal/sales-payment.php?id=".$row["ids"]."' data-toggle='ajax-modal'><span class='btn btn-success btn-xs'><i class='fa fa-inr'></i>&nbsp;&nbsp; Only Collected</span></a>";
    }else if($row["paid_amount"]==0){ 
        $nestedData[] ="<a href='modal/sales-payment.php?id=".$row["ids"]."' data-toggle='ajax-modal'><span class='btn btn-danger btn-xs' style='background-color:#0078a6; border-color: #0078a6;'><i class='fa fa-inr'></i>&nbsp;&nbsp; Payment Pending</span></a>";
    }else if($row["total_amount"]==$row["paid_amount"]){ 
        $nestedData[] ="<a href='modal/sales-payment.php?id=".$row["ids"]."' data-toggle='ajax-modal'><span class='btn btn-warning btn-xs' style='background-color:#a600a3;'><i class='fa fa-inr'></i>&nbsp;&nbsp; Fully Paid</span></a>";
    }elseif($row["total_amount"]>$row["paid_amount"]){ 
        $nestedData[] ="<a href='modal/sales-payment.php?id=".$row["ids"]."' data-toggle='ajax-modal'><span class='btn btn-success btn-xs' style='background-color:#bca43c;'><i class='fa fa-eye'></i>&nbsp;&nbsp; Partialy Paid</span></a>";
    }else if($row["total_amount"]<$row["paid_amount"]){ 
        $nestedData[] ="<a href='modal/sales-payment.php?id=".$row["ids"]."' data-toggle='ajax-modal'><span class='btn btn-danger btn-xs'><i class='fa fa-eye'></i>&nbsp;&nbsp; Advanced Amount</span></a>";
    }
    
    
    $nestedData[] = date('d-m-Y', strtotime($row["sell_date"]));
    
    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); 




?>

Zerion Mini Shell 1.0