Skip to content

Commit

Permalink
Filter working
Browse files Browse the repository at this point in the history
  • Loading branch information
abhis091 committed Jul 12, 2021
1 parent c53904f commit 47158ef
Show file tree
Hide file tree
Showing 2 changed files with 183 additions and 169 deletions.
338 changes: 178 additions & 160 deletions Receivables.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@
crossorigin="anonymous"></script>
<!-- JavaScript Bundle with Popper -->


<script src="https://cdn.jsdelivr.net/npm/js-cookie@rc/dist/js.cookie.min.js"></script>

<!-- FOR jQuery cookie -->

<script>
$(document).ready(function(){
$("#filterSelect").click(function(){
Expand Down Expand Up @@ -72,174 +77,16 @@
data: { "firm1": firm1,"firm2": firm2, "firm3": firm3, "clientId": clientId},
success: function(result) {
if(result){
obj = JSON.parse(result);
$("#firmName").val(obj[0]['shortname']);
$(document).cookie="objCookie="+JSON.stringify(obj);
document.cookie = "queryString="+result;
refreshDivs();
}

}
});
});
});
</script>
<title>Receivables</title>
</head>

<body>
<div class="container-fluid mt-3">
<h1 class="text-center">Receivables</h1>
<a class="text-center pl-5 ml-5" id="filterSelect">Filter</a>
<div id="filter" class="border border-2 p-5 m-5">
<div class="row col-12 form-group">
<h5 class="col-2">Select Firm:</h5>
<div class="form-check col-2 form-check-inline">
<input class="form-check-input" type="checkbox" id="firm3" name="firm3" value="3">
<label class="form-check-label" for="firm1">H Mistry & Associates</label>
</div>
<div class="form-check col-2 form-check-inline">
<input class="form-check-input" type="checkbox" id="firm1" name="firm1" value="1">
<label class="form-check-label" for="firm2">Jinal Waghela & Associates</label>
</div>
<div class="form-check col-2 form-check-inline">
<input class="form-check-input" type="checkbox" id="firm2" name="firm2" value="2">
<label class="form-check-label" for="firm3">MoneySphere Solutions</label>
</div>
</div>
<br>
<div class="row col-12">
<h5 class="col-2">Select client:</h5>
<div class="col-4">
<input type="text" id="clientName" name="clientName" class="form-control" aria-label="Default select example"
list="cityname" value="All Clients">

<datalist id="cityname">
<option data-id="0" selected >All Clients</option>
<?php
$sql="select * from clientlist order by clientName";
$result=mysqli_query($con,$sql) or die($con->error);
if($result->num_rows>0){
while($row=$result->fetch_assoc()){

?>
<option data-id="<?php echo $row['clientId']; ?>">
<?php echo $row['clientName']; ?>
</option>
<?php
}
}
?>
</datalist>
</div>
</div>
<button id="filterBtn" class="btn btn-success col-auto mt-3">Filter</button>
</div>
<table id="tbl" class="table table-responsive-md table-responsive-sm table-striped table-bordered mt-5" width="100%">
<thead style="background-color: rgb(79,129,189);">
<tr style="color:white;">
<th>Sr. No.</th>
<th>Firm Name</th>
<th>Bill No.</th>
<th>Date</th>
<th>Party</th>
<th>Amount</th>
<th>Amount Received</th>
<th>Receipt Date</th>
<th>Mode</th>
<th>Chq. No.</th>
<th>Amount Pending</th>
<th>TDS</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php
$query = "select * from bill_master bm inner join clientlist cl inner join firmname fn on bm.firm_id = fn.firmNameId and bm.client_id = cl.clientId";
$resultTable = mysqli_query($con, $query);
if ($resultTable->num_rows > 0) {
$row_count = 0;
while ($row = mysqli_fetch_assoc($result)) {
$row_count += 1;
?>
<tr>
<td class="text-center">
<?php echo $row_count; ?>
</td>
<td class="text-left">
<?php echo $row['shortForm']; ?>
</td>
<td class="text-left">
<?php echo $row['invoice_no']; ?>
</td>
<td class="text-right">
<?php echo $row['invoice_date']; ?>
</td>
<td class="text-left">
<?php echo $row['clientName']; ?>
</td>
<td class="text-right">
<?php echo $row['total_amount']; ?>
</td>
<td>
<div style="width:60%;">
<?php
if ($row['amount_received'] == 0) {
?>
<select id="<?php echo $row_count. 'amount_received'; ?>" class="custom-select" disabled>
<option value="0" class="text-danger" selected >No</option>
<option value="1" class="text-success">Yes</option>
</select>
<?php
} else {
?>
<span class="text-success">Yes</span>
<?php
}
?>
</div>
</td>
<td class="text-right"><input type="date" class="form-control" id="<?php echo $row_count . 'rDate'; ?>"
value="<?php echo $row['receipt_date']; ?>" disabled></td>
<td class="text-left">
<select class="form-control" id="<?php echo $row_count.'mode' ?>" disabled>
<option value="online" selected>Online</option>
<option value="cheque">Cheque</option>
<option value="cash">Cash</option>
</select>
</td>
<td class="text-left col-1" ><input type="text" class="form-control" id="<?php echo $row_count . 'chq'; ?>"
value="<?php echo $row['cheque_no']; ?>" disabled></td>
<td class="text-right col-1"><input type="text" class="form-control" id="<?php echo $row_count . 'pending'; ?>"
value="<?php echo $row['amount_pending']; ?>" disabled></td>
<td class="text-left col-1"><input type="text" class="form-control" id="<?php echo $row_count . 'tds'; ?>"
value="<?php echo $row['tds']; ?>" disabled></td>
<td width="10%">
<div class="row col-12" width="100%" style="display:inline-block;">
<button class="btn btn-primary col-5 mr-1" style="float:left;" id="<?php echo $row_count . 'edit' ?>"
onClick="handleEdit('<?php echo $row_count; ?>','Edit', '<?php echo $row['firm_id']; ?>', '<?php echo $row['invoice_no']; ?>')" class="btn btn-primary mb-2">
&#10000;
</button>
<button class="btn btn-primary text-center col-5 mr-1" style="float:left; display:none;" id="<?php echo $row_count . 'save' ?>"
onClick="handleEdit('<?php echo $row_count; ?>','Save', '<?php echo $row['firm_id']; ?>', '<?php echo $row['invoice_no']; ?>')" class="btn btn-success m-2">
&#10004;
</button>
<button class="btn btn-danger text-center col-5" style="float:right;" id="<?php echo $row_count; ?>"
onClick="handleCancel('<?php echo $row_count; ?>')" class="btn btn-danger mt-2">
&#10008;
</button>
</div>
</td>
</tr>

<?php
}
}
?>
</tbody>
</table>
</div>


<script>
function handleEdit(id, action,firmId,invoice_no) {
if (action == 'Edit') {
if ($('#' + id + 'amount_received').val() == 0) {
Expand Down Expand Up @@ -293,6 +140,177 @@ <h5 class="col-2">Select client:</h5>
document.cookie = "tds=" + $("#" + id + 'tds').val();

}

function refreshDivs(){
$('#tblDiv').load('#tblDiv .tbl');
}

</script>
<title>Receivables</title>
</head>

<body>
<div class="container-fluid mt-3" id="container">
<h1 class="text-center">Receivables</h1>
<div id="filter" class="border border-2 p-5 m-5">
<div class="row col-12 form-group">
<h5 class="col-2">Select Firm:</h5>
<div class="form-check col-2 form-check-inline">
<input class="form-check-input" type="checkbox" id="firm1" name="firm1" value="1">
<label class="form-check-label" for="firm2">Jinal Waghela & Associates</label>
</div>
<div class="form-check col-2 form-check-inline">
<input class="form-check-input" type="checkbox" id="firm2" name="firm2" value="2">
<label class="form-check-label" for="firm3">MoneySphere Solutions</label>
</div>
<div class="form-check col-2 form-check-inline">
<input class="form-check-input" type="checkbox" id="firm3" name="firm3" value="3">
<label class="form-check-label" for="firm1">H Mistry & Associates</label>
</div>
</div>
<br>
<div class="row col-12">
<h5 class="col-2">Select client:</h5>
<div class="col-4">
<input type="text" id="clientName" name="clientName" class="form-control" aria-label="Default select example"
list="cityname" value="All Clients">

<datalist id="cityname">
<option data-id="0" selected >All Clients</option>
<?php
$sql="select * from clientlist order by clientName";
$result=mysqli_query($con,$sql) or die($con->error);
if($result->num_rows>0){
while($row=$result->fetch_assoc()){

?>
<option data-id="<?php echo $row['clientId']; ?>">
<?php echo $row['clientName']; ?>
</option>
<?php
}
}
?>
</datalist>
</div>
</div>
<button id="filterBtn" name="filter" class="btn btn-success col-auto mt-3">Filter</button>
</div>
<div id="tblDiv">
<table class="tbl table table-responsive-md table-responsive-sm table-striped table-bordered mt-5" width="100%">
<thead style="background-color: rgb(79,129,189);">
<tr style="color:white;">
<th>Sr. No.</th>
<th>Firm Name</th>
<th>Bill No.</th>
<th>Date</th>
<th>Party</th>
<th>Amount</th>
<th>Amount Received</th>
<th>Receipt Date</th>
<th>Mode</th>
<th>Chq. No.</th>
<th>Amount Pending</th>
<th>TDS</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php
$query = "select * from bill_master bm inner join clientlist cl inner join firmname fn on bm.firm_id = fn.firmNameId and bm.client_id = cl.clientId";
if($_COOKIE['queryString']!=null){
$query = $_COOKIE['queryString'];
}
$resultTable = mysqli_query($con, $query);

if ($resultTable->num_rows > 0) {
$row_count = 0;
while ($row = mysqli_fetch_assoc($resultTable)) {
$row_count += 1;
?>

<tr>
<td class="text-center">
<?php echo $row_count; ?>
</td>
<td class="text-left">
<?php echo $row['shortForm']; ?>
</td>
<td class="text-left">
<?php echo $row['invoice_no']; ?>
</td>
<td class="text-right">
<?php echo $row['invoice_date']; ?>
</td>
<td class="text-left">
<?php echo $row['clientName']; ?>
</td>
<td class="text-right">
<?php echo $row['total_amount']; ?>
</td>
<td>
<div style="width:60%;">
<?php
if ($row['amount_received'] == 0) {
?>
<select id="<?php echo $row_count. 'amount_received'; ?>" class="custom-select" disabled>
<option value="0" class="text-danger" selected >No</option>
<option value="1" class="text-success">Yes</option>
</select>
<?php
} else {
?>
<span class="text-success">Yes</span>
<?php
}
?>
</div>
</td>
<td class="text-right"><input type="date" class="form-control" id="<?php echo $row_count . 'rDate'; ?>"
value="<?php echo $row['receipt_date']; ?>" disabled></td>
<td class="text-left">
<select class="form-control" id="<?php echo $row_count.'mode' ?>" disabled>
<option value="online" selected>Online</option>
<option value="cheque">Cheque</option>
<option value="cash">Cash</option>
</select>
</td>
<td class="text-left col-1" ><input type="text" class="form-control" id="<?php echo $row_count . 'chq'; ?>"
value="<?php echo $row['cheque_no']; ?>" disabled></td>
<td class="text-right col-1"><input type="text" class="form-control" id="<?php echo $row_count . 'pending'; ?>"
value="<?php echo $row['amount_pending']; ?>" disabled></td>
<td class="text-left col-1"><input type="text" class="form-control" id="<?php echo $row_count . 'tds'; ?>"
value="<?php echo $row['tds']; ?>" disabled></td>
<td width="10%">
<div class="row col-12" width="100%" style="display:inline-block;">
<button class="btn btn-primary col-5 mr-1" style="float:left;" id="<?php echo $row_count . 'edit' ?>"
onClick="handleEdit('<?php echo $row_count; ?>','Edit', '<?php echo $row['firm_id']; ?>', '<?php echo $row['invoice_no']; ?>')" class="btn btn-primary mb-2">
&#10000;
</button>
<button class="btn btn-primary text-center col-5 mr-1" style="float:left; display:none;" id="<?php echo $row_count . 'save' ?>"
onClick="handleEdit('<?php echo $row_count; ?>','Save', '<?php echo $row['firm_id']; ?>', '<?php echo $row['invoice_no']; ?>')" class="btn btn-success m-2">
&#10004;
</button>
<button class="btn btn-danger text-center col-5" style="float:right;" id="<?php echo $row_count; ?>"
onClick="handleCancel('<?php echo $row_count; ?>')" class="btn btn-danger mt-2">
&#10008;
</button>
</div>
</td>
</tr>

<?php
}
}
?>
</tbody>
</table>
</div>
</div>


<script>

</script>

</body>
Expand Down
14 changes: 5 additions & 9 deletions filterReceivables.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,17 @@
require_once "connect.php";

if(isset($_POST)){
$data = array();

if($_POST['clientId'] == 0){
$query = "select * from bill_master bm inner join clientlist cl inner join firmname fn on bm.firm_id = fn.firmNameId and bm.client_id = cl.clientId where (fn.firmNameId=".$_POST['firm3']." or fn.firmNameId=".$_POST['firm2']." or fn.firmNameId=".$_POST['firm1'].") and cl.clientId>0";
}
else{
$query = "select * from bill_master bm inner join clientlist cl inner join firmname fn on bm.firm_id = fn.firmNameId and bm.client_id = cl.clientId where (fn.firmNameId=".$_POST['firm3']." or fn.firmNameId=".$_POST['firm2']." or fn.firmNameId=".$_POST['firm1'].") and cl.clientId=".$_POST['clientId'];
}
$result = mysqli_query($con, $query);
if($result->num_rows > 0) {
while ($row = mysqli_fetch_assoc($result)) {
array_push($data,$row);
}
}
echo json_encode($data);

echo $query;
}




?>

0 comments on commit 47158ef

Please sign in to comment.