ok
Direktori : /proc/self/root/home2/selectio/www/vijay-gases/data-tables/ |
Current File : //proc/self/root/home2/selectio/www/vijay-gases/data-tables/purchase-data-table.php |
<?php ob_start(); session_start(); include"../config/config.php"; $requestData= $_REQUEST; /*Fetch Database column Details*/ $columns = array( 0 =>'id', 1 =>'purchase_date', 2 =>'location_id', 3 =>'total_refill_item', 4 =>'total_new_item', 5 =>'total_amount', 6 =>'total_amount', 7 =>'paid_amount', 8 =>'status', 9 =>'created_at', 10 =>'supplier' ); $conditions=""; /*Fetch All Data Start*/ $statement = $pdo->prepare("SELECT h.*,tbl_customer.id as supplier_id,tbl_customer.customer_name as tbl_cus_name,tbl_customer.mobile_number as tbl_cus_mobile,tbl_location.id as tbl_location_id,tbl_location.name as tb_loca_name FROM `tbl_purchase` h LEFT JOIN tbl_customer ON h.supplier=tbl_customer.id LEFT JOIN tbl_location ON h.location_id=tbl_location.id where 1=1 ".$conditions." ORDER BY h.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 h.*,tbl_customer.customer_name as tbl_cus_name,tbl_customer.mobile_number as tbl_cus_mobile,tbl_location.name as tb_loca_name FROM `tbl_purchase` h LEFT JOIN tbl_customer ON h.supplier=tbl_customer.id LEFT JOIN tbl_location ON h.location_id=tbl_location.id where 1=1".$conditions; if( !empty($_REQUEST['search']) ) { $sql.=" AND ( tbl_customer.customer_name LIKE '%".$_REQUEST['search']."%' "; $sql.=" OR tbl_location.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='purchase-print-invoice.php?id=".$row["id"]."' target='_blank' title='Edit Customer' class='tip btn btn-success btn-xs'> <i class='fa fa-print'></i> </a> "; $action.="<a style='padding: 6px;margin-right: 3px;' href='purchase-invoice-share.php?id=".$row["id"]."' target='_blank' title='Edit Customer' class='tip btn btn-info btn-xs'> <i class='fa fa-share'></i> </a> "; $action.="<a style='padding: 6px;margin-right: 3px;' href='tax-invoice.php?id=".$row["id"]."' target='_blank' title='print tax invoice' class='tip btn btn-primary btn-xs'> <i class='fa fa-print'></i> </a> "; $action.="<a style='padding: 6px;margin-right: 3px;' href='modal/purchase-payment.php?id=".$row["id"]."' 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/purchase-view.php?id=".$row["id"]."' data-toggle='ajax-modal' title='Edit Customer' class='tip btn btn-danger 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["tb_loca_name"]; $nestedData[] = $row["tbl_cus_name"]; $nestedData[] = $row["total_refill_item"]; $nestedData[] = $row["total_amount"]; $nestedData[] = $row["paid_amount"]; $nestedData[] = $row["total_amount"]-$row["paid_amount"]; if($row["paid_amount"]==0){ $nestedData[] ="<a href='modal/purchase-payment.php?id=".$row["id"]."' data-toggle='ajax-modal'><span class='btn btn-danger btn-xs' style='background-color:#0078a6;'><i class='fa fa-inr'></i> All Payment Pending</span></a>";}elseif($row["total_amount"]==$row["paid_amount"]){ $nestedData[] ="<a href='modal/purchase-payment.php?id=".$row["id"]."' data-toggle='ajax-modal'><span class='btn btn-warning btn-xs' style='background-color:#a600a3;'><i class='fa fa-inr'></i> Fully Paid</span></a>";}elseif($row["total_amount"]>$row["paid_amount"]){ $nestedData[] ="<a href='modal/purchase-payment.php?id=".$row["id"]."' data-toggle='ajax-modal'><span class='btn btn-success btn-xs' style='background-color:#bca43c;'><i class='fa fa-eye'></i> Partialy Paid</span></a>";}elseif($row["total_amount"]<$row["paid_amount"]){ $nestedData[] ="<a href='modal/purchase-payment.php?id=".$row["id"]."' data-toggle='ajax-modal'><span class='btn btn-danger btn-xs'><i class='fa fa-eye'></i> Advanced Amount</span></a>";} $nestedData[] = date('d-m-Y', strtotime($row["purchase_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); ?>