Range Date Search on DataTables (CodeIgniter)












0















I need help.
I want to show the data's within the range of the date i choose.
Here's my code so far



Here's the code where I display the datatables



View



<div class="box-body">
<div class="table-responsive">

<div class="row">
<div class="col-md-4">
<div class="form-group start-date">
<label>From</label>
<div class="input-group date">
<div class="input-group-addon">
<i class="fa fa-calendar"></i>
</div>
<input type="text" class="form-control pull-right" id="start_date" name="start_date">
</div>
<!-- /.input group -->
</div>
</div>
<div class="col-md-4">
<div class="form-group end-date">
<label>To</label>
<div class="input-group date">
<div class="input-group-addon">
<i class="fa fa-calendar"></i>
</div>
<input type="text" class="form-control pull-right" id="end_date" name="end_date">
</div>
<!-- /.input group -->
</div>
</div>
<div class="col-md-2">
<div class="form-group met-cheq">
<label>Go </label>
<div class="input-group date">
<button class="btn btn-warning btn-md" name = "search" id="search">Search!</button>
</div>
<!-- /.input group -->
</div>
</div>
</div>


<table id="table-sales" class="table table-bordered table-striped">
<thead>
<tr>
<th>DR</th>
<th>Date</th>
<th>Customer</th>
<th>Price</th>
<th>Paid Amnt</th>
<th>Balance</th>
<th>Receipt</th>
<th>Remarks</th>
<th>Items</th>
<th style="width:55px;">Action</th>
</tr>
</thead>
<tbody>
<?php foreach ($sales_inv as $inv) {
$balance = $inv->inv_price-$inv->payment;
$status = "";
$payment = $inv->payment;

if ($inv->inv_type==1) {
$status = "Department Store";
}elseif($inv->inv_type==2){
$status = "Local";
}elseif($inv->inv_type==3){
$status = "Provincial";
}elseif($inv->inv_type==4){
$status = "UNITOP";
}elseif($inv->inv_type==5){
$status = "GAISANO";
}
?>
<tr class="row-<?php echo $inv->id; ?>">
<td><a href="#" class="btn-inv-show" data-value="<?php echo $inv->inv_cno; ?>@<?php echo $inv->id; ?>"><?php echo $inv->inv_cno; ?></a></td>
<td><?php echo date("M d, Y", strtotime($inv->timestamp)); ?></td>
<td><?php echo $inv->cust_name; ?></td>
<td class="price-<?php echo $inv->inv_cno; ?>">Php <?php echo number_format($inv->inv_price,2); ?></td>
<td class="payment-<?php echo $inv->inv_cno; ?>">Php <?php echo number_format($payment,2); ?></td>
<td class="bal-<?php echo $inv->inv_cno; ?>">Php <?php echo number_format($balance,2); ?></td>
<td><?php echo $status; ?></td>
<td>
<button class="btn btn-info btn-sm btn-rem" data-value="<?php echo $inv->id; ?>">View Remarks
</button>
</td>
<td>
<button class="btn btn-success btn-sm btn-item" data-value="<?php echo $inv->inv_cno; ?>">View Item
</button>
</td>
<td>
<button class="btn btn-primary btn-xs btn-print" data-value="<?php echo $inv->inv_cno; ?>"><i class="fa fa-print"></i></button>
<button class="btn btn-warning btn-xs btn-add-pay" data-value="<?php echo $inv->inv_cno; ?>@<?php echo $inv->custid; ?>@<?php echo $inv->id; ?>"><i class="fa fa-credit-card"></i></button>
<button class="btn btn-danger btn-xs btn-edit-pay" data-value="<?php echo $inv->inv_cno; ?>@<?php echo $inv->custid; ?>@<?php echo $inv->id; ?>"><i class="fa fa-edit"></i></button>
</td>
</tr>
<?php } ?>
</tbody>
<tfooter>
<tr>
<th>DR</th>
<th>Date</th>
<th>Customer</th>
<th>Price</th>
<th>Paid Amnt</th>
<th>Balance</th>
<th>Receipt</th>
<th>Remarks</th>
<th style="width:55px;">Action</th>
</tr>
</tfooter>
</table>
</div>
<!-- /.table-responsive -->
</div>
</div>
<!-- /.box -->
</section>
<!-- right col -->
</div>


Model



public function rangeDate($start_date,$end_date){

$query = $this->db->select($this->tables['invent_inv'].'.id,'
.$this->tables['invent_inv'].'.inv_type,'.$this->tables['invent_inv'].'.inv_cno,'
.$this->tables['invent_cust'].'.id as custid,'.$this->tables['invent_cust'].'.cust_name,'
.$this->tables['invent_inv'].'.inv_price, '.$this->tables['invent_inv'].'.inv_tax,'
.$this->tables['invent_inv'].'.pay_due, SUM('.$this->tables['invent_sales'].'.paid_amnt) as payment,'
.$this->tables['invent_inv'].'.timestamp')
->join($this->tables['invent_cust'], $this->tables['invent_inv'].'.cust_id='
.$this->tables['invent_cust'].'.id','LEFT')
->join($this->tables['invent_sales'], $this->tables['invent_inv'].'.inv_cno='
.$this->tables['invent_sales'].'.inv_cno','LEFT')
->where($this->tables['invent_inv'].'.status !=', 1)
->where($this->tables['invent_inv'].'.status !=', 0)
->where($this->tables['invent_inv'].'.timestamp >=',$start_date)
->where($this->tables['invent_inv'].'.timestamp <=',$end_date)
->group_by($this->tables['invent_sales'].".inv_cno")
->group_by($this->tables['invent_inv'].".inv_cno")
->group_by($this->tables['invent_inv'].".timestamp")
->get($this->tables['invent_inv']);

return $query;
}


JS



$('#start_date').datepicker({
dateFormat: 'yy-mm-dd',
autoclose: true
})

$('#end_date').datepicker({
dateFormat: 'yy-mm-dd',
autoclose: true
})

$('#table-sales').DataTable();


enter image description here



Now my problem is that I don't know what to put on the controller and I don't know how to show it on my table-sales . I don't know if the code I am putting is correct or if I am on the right path . I'm using codeigniter3x . Could someone help me please.



Thank you in advance for someone who will help me .










share|improve this question

























  • Could you please display you code where you are showing data in datatales. Please explain in detail (Post all code)

    – amba patel
    Nov 16 '18 at 9:06











  • @ambapatel edited my question and posted the code to show datatable

    – BoonMingProg
    Nov 16 '18 at 9:08
















0















I need help.
I want to show the data's within the range of the date i choose.
Here's my code so far



Here's the code where I display the datatables



View



<div class="box-body">
<div class="table-responsive">

<div class="row">
<div class="col-md-4">
<div class="form-group start-date">
<label>From</label>
<div class="input-group date">
<div class="input-group-addon">
<i class="fa fa-calendar"></i>
</div>
<input type="text" class="form-control pull-right" id="start_date" name="start_date">
</div>
<!-- /.input group -->
</div>
</div>
<div class="col-md-4">
<div class="form-group end-date">
<label>To</label>
<div class="input-group date">
<div class="input-group-addon">
<i class="fa fa-calendar"></i>
</div>
<input type="text" class="form-control pull-right" id="end_date" name="end_date">
</div>
<!-- /.input group -->
</div>
</div>
<div class="col-md-2">
<div class="form-group met-cheq">
<label>Go </label>
<div class="input-group date">
<button class="btn btn-warning btn-md" name = "search" id="search">Search!</button>
</div>
<!-- /.input group -->
</div>
</div>
</div>


<table id="table-sales" class="table table-bordered table-striped">
<thead>
<tr>
<th>DR</th>
<th>Date</th>
<th>Customer</th>
<th>Price</th>
<th>Paid Amnt</th>
<th>Balance</th>
<th>Receipt</th>
<th>Remarks</th>
<th>Items</th>
<th style="width:55px;">Action</th>
</tr>
</thead>
<tbody>
<?php foreach ($sales_inv as $inv) {
$balance = $inv->inv_price-$inv->payment;
$status = "";
$payment = $inv->payment;

if ($inv->inv_type==1) {
$status = "Department Store";
}elseif($inv->inv_type==2){
$status = "Local";
}elseif($inv->inv_type==3){
$status = "Provincial";
}elseif($inv->inv_type==4){
$status = "UNITOP";
}elseif($inv->inv_type==5){
$status = "GAISANO";
}
?>
<tr class="row-<?php echo $inv->id; ?>">
<td><a href="#" class="btn-inv-show" data-value="<?php echo $inv->inv_cno; ?>@<?php echo $inv->id; ?>"><?php echo $inv->inv_cno; ?></a></td>
<td><?php echo date("M d, Y", strtotime($inv->timestamp)); ?></td>
<td><?php echo $inv->cust_name; ?></td>
<td class="price-<?php echo $inv->inv_cno; ?>">Php <?php echo number_format($inv->inv_price,2); ?></td>
<td class="payment-<?php echo $inv->inv_cno; ?>">Php <?php echo number_format($payment,2); ?></td>
<td class="bal-<?php echo $inv->inv_cno; ?>">Php <?php echo number_format($balance,2); ?></td>
<td><?php echo $status; ?></td>
<td>
<button class="btn btn-info btn-sm btn-rem" data-value="<?php echo $inv->id; ?>">View Remarks
</button>
</td>
<td>
<button class="btn btn-success btn-sm btn-item" data-value="<?php echo $inv->inv_cno; ?>">View Item
</button>
</td>
<td>
<button class="btn btn-primary btn-xs btn-print" data-value="<?php echo $inv->inv_cno; ?>"><i class="fa fa-print"></i></button>
<button class="btn btn-warning btn-xs btn-add-pay" data-value="<?php echo $inv->inv_cno; ?>@<?php echo $inv->custid; ?>@<?php echo $inv->id; ?>"><i class="fa fa-credit-card"></i></button>
<button class="btn btn-danger btn-xs btn-edit-pay" data-value="<?php echo $inv->inv_cno; ?>@<?php echo $inv->custid; ?>@<?php echo $inv->id; ?>"><i class="fa fa-edit"></i></button>
</td>
</tr>
<?php } ?>
</tbody>
<tfooter>
<tr>
<th>DR</th>
<th>Date</th>
<th>Customer</th>
<th>Price</th>
<th>Paid Amnt</th>
<th>Balance</th>
<th>Receipt</th>
<th>Remarks</th>
<th style="width:55px;">Action</th>
</tr>
</tfooter>
</table>
</div>
<!-- /.table-responsive -->
</div>
</div>
<!-- /.box -->
</section>
<!-- right col -->
</div>


Model



public function rangeDate($start_date,$end_date){

$query = $this->db->select($this->tables['invent_inv'].'.id,'
.$this->tables['invent_inv'].'.inv_type,'.$this->tables['invent_inv'].'.inv_cno,'
.$this->tables['invent_cust'].'.id as custid,'.$this->tables['invent_cust'].'.cust_name,'
.$this->tables['invent_inv'].'.inv_price, '.$this->tables['invent_inv'].'.inv_tax,'
.$this->tables['invent_inv'].'.pay_due, SUM('.$this->tables['invent_sales'].'.paid_amnt) as payment,'
.$this->tables['invent_inv'].'.timestamp')
->join($this->tables['invent_cust'], $this->tables['invent_inv'].'.cust_id='
.$this->tables['invent_cust'].'.id','LEFT')
->join($this->tables['invent_sales'], $this->tables['invent_inv'].'.inv_cno='
.$this->tables['invent_sales'].'.inv_cno','LEFT')
->where($this->tables['invent_inv'].'.status !=', 1)
->where($this->tables['invent_inv'].'.status !=', 0)
->where($this->tables['invent_inv'].'.timestamp >=',$start_date)
->where($this->tables['invent_inv'].'.timestamp <=',$end_date)
->group_by($this->tables['invent_sales'].".inv_cno")
->group_by($this->tables['invent_inv'].".inv_cno")
->group_by($this->tables['invent_inv'].".timestamp")
->get($this->tables['invent_inv']);

return $query;
}


JS



$('#start_date').datepicker({
dateFormat: 'yy-mm-dd',
autoclose: true
})

$('#end_date').datepicker({
dateFormat: 'yy-mm-dd',
autoclose: true
})

$('#table-sales').DataTable();


enter image description here



Now my problem is that I don't know what to put on the controller and I don't know how to show it on my table-sales . I don't know if the code I am putting is correct or if I am on the right path . I'm using codeigniter3x . Could someone help me please.



Thank you in advance for someone who will help me .










share|improve this question

























  • Could you please display you code where you are showing data in datatales. Please explain in detail (Post all code)

    – amba patel
    Nov 16 '18 at 9:06











  • @ambapatel edited my question and posted the code to show datatable

    – BoonMingProg
    Nov 16 '18 at 9:08














0












0








0








I need help.
I want to show the data's within the range of the date i choose.
Here's my code so far



Here's the code where I display the datatables



View



<div class="box-body">
<div class="table-responsive">

<div class="row">
<div class="col-md-4">
<div class="form-group start-date">
<label>From</label>
<div class="input-group date">
<div class="input-group-addon">
<i class="fa fa-calendar"></i>
</div>
<input type="text" class="form-control pull-right" id="start_date" name="start_date">
</div>
<!-- /.input group -->
</div>
</div>
<div class="col-md-4">
<div class="form-group end-date">
<label>To</label>
<div class="input-group date">
<div class="input-group-addon">
<i class="fa fa-calendar"></i>
</div>
<input type="text" class="form-control pull-right" id="end_date" name="end_date">
</div>
<!-- /.input group -->
</div>
</div>
<div class="col-md-2">
<div class="form-group met-cheq">
<label>Go </label>
<div class="input-group date">
<button class="btn btn-warning btn-md" name = "search" id="search">Search!</button>
</div>
<!-- /.input group -->
</div>
</div>
</div>


<table id="table-sales" class="table table-bordered table-striped">
<thead>
<tr>
<th>DR</th>
<th>Date</th>
<th>Customer</th>
<th>Price</th>
<th>Paid Amnt</th>
<th>Balance</th>
<th>Receipt</th>
<th>Remarks</th>
<th>Items</th>
<th style="width:55px;">Action</th>
</tr>
</thead>
<tbody>
<?php foreach ($sales_inv as $inv) {
$balance = $inv->inv_price-$inv->payment;
$status = "";
$payment = $inv->payment;

if ($inv->inv_type==1) {
$status = "Department Store";
}elseif($inv->inv_type==2){
$status = "Local";
}elseif($inv->inv_type==3){
$status = "Provincial";
}elseif($inv->inv_type==4){
$status = "UNITOP";
}elseif($inv->inv_type==5){
$status = "GAISANO";
}
?>
<tr class="row-<?php echo $inv->id; ?>">
<td><a href="#" class="btn-inv-show" data-value="<?php echo $inv->inv_cno; ?>@<?php echo $inv->id; ?>"><?php echo $inv->inv_cno; ?></a></td>
<td><?php echo date("M d, Y", strtotime($inv->timestamp)); ?></td>
<td><?php echo $inv->cust_name; ?></td>
<td class="price-<?php echo $inv->inv_cno; ?>">Php <?php echo number_format($inv->inv_price,2); ?></td>
<td class="payment-<?php echo $inv->inv_cno; ?>">Php <?php echo number_format($payment,2); ?></td>
<td class="bal-<?php echo $inv->inv_cno; ?>">Php <?php echo number_format($balance,2); ?></td>
<td><?php echo $status; ?></td>
<td>
<button class="btn btn-info btn-sm btn-rem" data-value="<?php echo $inv->id; ?>">View Remarks
</button>
</td>
<td>
<button class="btn btn-success btn-sm btn-item" data-value="<?php echo $inv->inv_cno; ?>">View Item
</button>
</td>
<td>
<button class="btn btn-primary btn-xs btn-print" data-value="<?php echo $inv->inv_cno; ?>"><i class="fa fa-print"></i></button>
<button class="btn btn-warning btn-xs btn-add-pay" data-value="<?php echo $inv->inv_cno; ?>@<?php echo $inv->custid; ?>@<?php echo $inv->id; ?>"><i class="fa fa-credit-card"></i></button>
<button class="btn btn-danger btn-xs btn-edit-pay" data-value="<?php echo $inv->inv_cno; ?>@<?php echo $inv->custid; ?>@<?php echo $inv->id; ?>"><i class="fa fa-edit"></i></button>
</td>
</tr>
<?php } ?>
</tbody>
<tfooter>
<tr>
<th>DR</th>
<th>Date</th>
<th>Customer</th>
<th>Price</th>
<th>Paid Amnt</th>
<th>Balance</th>
<th>Receipt</th>
<th>Remarks</th>
<th style="width:55px;">Action</th>
</tr>
</tfooter>
</table>
</div>
<!-- /.table-responsive -->
</div>
</div>
<!-- /.box -->
</section>
<!-- right col -->
</div>


Model



public function rangeDate($start_date,$end_date){

$query = $this->db->select($this->tables['invent_inv'].'.id,'
.$this->tables['invent_inv'].'.inv_type,'.$this->tables['invent_inv'].'.inv_cno,'
.$this->tables['invent_cust'].'.id as custid,'.$this->tables['invent_cust'].'.cust_name,'
.$this->tables['invent_inv'].'.inv_price, '.$this->tables['invent_inv'].'.inv_tax,'
.$this->tables['invent_inv'].'.pay_due, SUM('.$this->tables['invent_sales'].'.paid_amnt) as payment,'
.$this->tables['invent_inv'].'.timestamp')
->join($this->tables['invent_cust'], $this->tables['invent_inv'].'.cust_id='
.$this->tables['invent_cust'].'.id','LEFT')
->join($this->tables['invent_sales'], $this->tables['invent_inv'].'.inv_cno='
.$this->tables['invent_sales'].'.inv_cno','LEFT')
->where($this->tables['invent_inv'].'.status !=', 1)
->where($this->tables['invent_inv'].'.status !=', 0)
->where($this->tables['invent_inv'].'.timestamp >=',$start_date)
->where($this->tables['invent_inv'].'.timestamp <=',$end_date)
->group_by($this->tables['invent_sales'].".inv_cno")
->group_by($this->tables['invent_inv'].".inv_cno")
->group_by($this->tables['invent_inv'].".timestamp")
->get($this->tables['invent_inv']);

return $query;
}


JS



$('#start_date').datepicker({
dateFormat: 'yy-mm-dd',
autoclose: true
})

$('#end_date').datepicker({
dateFormat: 'yy-mm-dd',
autoclose: true
})

$('#table-sales').DataTable();


enter image description here



Now my problem is that I don't know what to put on the controller and I don't know how to show it on my table-sales . I don't know if the code I am putting is correct or if I am on the right path . I'm using codeigniter3x . Could someone help me please.



Thank you in advance for someone who will help me .










share|improve this question
















I need help.
I want to show the data's within the range of the date i choose.
Here's my code so far



Here's the code where I display the datatables



View



<div class="box-body">
<div class="table-responsive">

<div class="row">
<div class="col-md-4">
<div class="form-group start-date">
<label>From</label>
<div class="input-group date">
<div class="input-group-addon">
<i class="fa fa-calendar"></i>
</div>
<input type="text" class="form-control pull-right" id="start_date" name="start_date">
</div>
<!-- /.input group -->
</div>
</div>
<div class="col-md-4">
<div class="form-group end-date">
<label>To</label>
<div class="input-group date">
<div class="input-group-addon">
<i class="fa fa-calendar"></i>
</div>
<input type="text" class="form-control pull-right" id="end_date" name="end_date">
</div>
<!-- /.input group -->
</div>
</div>
<div class="col-md-2">
<div class="form-group met-cheq">
<label>Go </label>
<div class="input-group date">
<button class="btn btn-warning btn-md" name = "search" id="search">Search!</button>
</div>
<!-- /.input group -->
</div>
</div>
</div>


<table id="table-sales" class="table table-bordered table-striped">
<thead>
<tr>
<th>DR</th>
<th>Date</th>
<th>Customer</th>
<th>Price</th>
<th>Paid Amnt</th>
<th>Balance</th>
<th>Receipt</th>
<th>Remarks</th>
<th>Items</th>
<th style="width:55px;">Action</th>
</tr>
</thead>
<tbody>
<?php foreach ($sales_inv as $inv) {
$balance = $inv->inv_price-$inv->payment;
$status = "";
$payment = $inv->payment;

if ($inv->inv_type==1) {
$status = "Department Store";
}elseif($inv->inv_type==2){
$status = "Local";
}elseif($inv->inv_type==3){
$status = "Provincial";
}elseif($inv->inv_type==4){
$status = "UNITOP";
}elseif($inv->inv_type==5){
$status = "GAISANO";
}
?>
<tr class="row-<?php echo $inv->id; ?>">
<td><a href="#" class="btn-inv-show" data-value="<?php echo $inv->inv_cno; ?>@<?php echo $inv->id; ?>"><?php echo $inv->inv_cno; ?></a></td>
<td><?php echo date("M d, Y", strtotime($inv->timestamp)); ?></td>
<td><?php echo $inv->cust_name; ?></td>
<td class="price-<?php echo $inv->inv_cno; ?>">Php <?php echo number_format($inv->inv_price,2); ?></td>
<td class="payment-<?php echo $inv->inv_cno; ?>">Php <?php echo number_format($payment,2); ?></td>
<td class="bal-<?php echo $inv->inv_cno; ?>">Php <?php echo number_format($balance,2); ?></td>
<td><?php echo $status; ?></td>
<td>
<button class="btn btn-info btn-sm btn-rem" data-value="<?php echo $inv->id; ?>">View Remarks
</button>
</td>
<td>
<button class="btn btn-success btn-sm btn-item" data-value="<?php echo $inv->inv_cno; ?>">View Item
</button>
</td>
<td>
<button class="btn btn-primary btn-xs btn-print" data-value="<?php echo $inv->inv_cno; ?>"><i class="fa fa-print"></i></button>
<button class="btn btn-warning btn-xs btn-add-pay" data-value="<?php echo $inv->inv_cno; ?>@<?php echo $inv->custid; ?>@<?php echo $inv->id; ?>"><i class="fa fa-credit-card"></i></button>
<button class="btn btn-danger btn-xs btn-edit-pay" data-value="<?php echo $inv->inv_cno; ?>@<?php echo $inv->custid; ?>@<?php echo $inv->id; ?>"><i class="fa fa-edit"></i></button>
</td>
</tr>
<?php } ?>
</tbody>
<tfooter>
<tr>
<th>DR</th>
<th>Date</th>
<th>Customer</th>
<th>Price</th>
<th>Paid Amnt</th>
<th>Balance</th>
<th>Receipt</th>
<th>Remarks</th>
<th style="width:55px;">Action</th>
</tr>
</tfooter>
</table>
</div>
<!-- /.table-responsive -->
</div>
</div>
<!-- /.box -->
</section>
<!-- right col -->
</div>


Model



public function rangeDate($start_date,$end_date){

$query = $this->db->select($this->tables['invent_inv'].'.id,'
.$this->tables['invent_inv'].'.inv_type,'.$this->tables['invent_inv'].'.inv_cno,'
.$this->tables['invent_cust'].'.id as custid,'.$this->tables['invent_cust'].'.cust_name,'
.$this->tables['invent_inv'].'.inv_price, '.$this->tables['invent_inv'].'.inv_tax,'
.$this->tables['invent_inv'].'.pay_due, SUM('.$this->tables['invent_sales'].'.paid_amnt) as payment,'
.$this->tables['invent_inv'].'.timestamp')
->join($this->tables['invent_cust'], $this->tables['invent_inv'].'.cust_id='
.$this->tables['invent_cust'].'.id','LEFT')
->join($this->tables['invent_sales'], $this->tables['invent_inv'].'.inv_cno='
.$this->tables['invent_sales'].'.inv_cno','LEFT')
->where($this->tables['invent_inv'].'.status !=', 1)
->where($this->tables['invent_inv'].'.status !=', 0)
->where($this->tables['invent_inv'].'.timestamp >=',$start_date)
->where($this->tables['invent_inv'].'.timestamp <=',$end_date)
->group_by($this->tables['invent_sales'].".inv_cno")
->group_by($this->tables['invent_inv'].".inv_cno")
->group_by($this->tables['invent_inv'].".timestamp")
->get($this->tables['invent_inv']);

return $query;
}


JS



$('#start_date').datepicker({
dateFormat: 'yy-mm-dd',
autoclose: true
})

$('#end_date').datepicker({
dateFormat: 'yy-mm-dd',
autoclose: true
})

$('#table-sales').DataTable();


enter image description here



Now my problem is that I don't know what to put on the controller and I don't know how to show it on my table-sales . I don't know if the code I am putting is correct or if I am on the right path . I'm using codeigniter3x . Could someone help me please.



Thank you in advance for someone who will help me .







javascript php mysql ajax codeigniter






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 16 '18 at 9:06







BoonMingProg

















asked Nov 16 '18 at 8:56









BoonMingProgBoonMingProg

9210




9210













  • Could you please display you code where you are showing data in datatales. Please explain in detail (Post all code)

    – amba patel
    Nov 16 '18 at 9:06











  • @ambapatel edited my question and posted the code to show datatable

    – BoonMingProg
    Nov 16 '18 at 9:08



















  • Could you please display you code where you are showing data in datatales. Please explain in detail (Post all code)

    – amba patel
    Nov 16 '18 at 9:06











  • @ambapatel edited my question and posted the code to show datatable

    – BoonMingProg
    Nov 16 '18 at 9:08

















Could you please display you code where you are showing data in datatales. Please explain in detail (Post all code)

– amba patel
Nov 16 '18 at 9:06





Could you please display you code where you are showing data in datatales. Please explain in detail (Post all code)

– amba patel
Nov 16 '18 at 9:06













@ambapatel edited my question and posted the code to show datatable

– BoonMingProg
Nov 16 '18 at 9:08





@ambapatel edited my question and posted the code to show datatable

– BoonMingProg
Nov 16 '18 at 9:08












1 Answer
1






active

oldest

votes


















0















  1. You can call ajax when click on Search button and pass start and end date as parameters in ajax request and filter data.


  2. After get ajax response from controller you can update tbody of table-sales table using jquery with updated data.
    Example
    Assume you get array of updated data
    var tab_body = '';



        $.each(sub_subject, function (key, value)
    {
    tab_body = tab_body + '<tr><td>' + value.sub_subject_name + '</td>' +
    '<td>' + value.sub_subject_code + '</td>' +
    '<td><div class="text-center"><button class="btn btn-primary open_edit_sub_subject_model" sub_subject_id="' + value.sub_subject_id + '" type="button" title="Edit" request_type="open_edit" subject_name="' + d.subject_name + '"><i class="fas fa-edit"></i></button>n
    <button type="button" class="btn btn-primary subject-data-delete" title="Remove" delete_type="sub_subject" subject_group_id="' + d.subject_group_id + '" subject_id="' + d.subject_id + '" sub_subject_id="' + value.sub_subject_id + '"><i class="fa fa-trash"></i></button>n
    </div></td>' +
    '</tr>';
    });
    // example is just for reference
    put above data in table using
    $("#table-sales tbody").html(tab_body);


    Hopfully it will help.








share|improve this answer


























  • I don't quite understand this sir. Could you explain a bit more. If you don't mind

    – BoonMingProg
    Nov 16 '18 at 9:40











  • Are you familiar with ajax call ?

    – amba patel
    Nov 16 '18 at 9:43











  • not really sir. I'm very sorry

    – BoonMingProg
    Nov 16 '18 at 9:44












Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53334410%2frange-date-search-on-datatables-codeigniter%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0















  1. You can call ajax when click on Search button and pass start and end date as parameters in ajax request and filter data.


  2. After get ajax response from controller you can update tbody of table-sales table using jquery with updated data.
    Example
    Assume you get array of updated data
    var tab_body = '';



        $.each(sub_subject, function (key, value)
    {
    tab_body = tab_body + '<tr><td>' + value.sub_subject_name + '</td>' +
    '<td>' + value.sub_subject_code + '</td>' +
    '<td><div class="text-center"><button class="btn btn-primary open_edit_sub_subject_model" sub_subject_id="' + value.sub_subject_id + '" type="button" title="Edit" request_type="open_edit" subject_name="' + d.subject_name + '"><i class="fas fa-edit"></i></button>n
    <button type="button" class="btn btn-primary subject-data-delete" title="Remove" delete_type="sub_subject" subject_group_id="' + d.subject_group_id + '" subject_id="' + d.subject_id + '" sub_subject_id="' + value.sub_subject_id + '"><i class="fa fa-trash"></i></button>n
    </div></td>' +
    '</tr>';
    });
    // example is just for reference
    put above data in table using
    $("#table-sales tbody").html(tab_body);


    Hopfully it will help.








share|improve this answer


























  • I don't quite understand this sir. Could you explain a bit more. If you don't mind

    – BoonMingProg
    Nov 16 '18 at 9:40











  • Are you familiar with ajax call ?

    – amba patel
    Nov 16 '18 at 9:43











  • not really sir. I'm very sorry

    – BoonMingProg
    Nov 16 '18 at 9:44
















0















  1. You can call ajax when click on Search button and pass start and end date as parameters in ajax request and filter data.


  2. After get ajax response from controller you can update tbody of table-sales table using jquery with updated data.
    Example
    Assume you get array of updated data
    var tab_body = '';



        $.each(sub_subject, function (key, value)
    {
    tab_body = tab_body + '<tr><td>' + value.sub_subject_name + '</td>' +
    '<td>' + value.sub_subject_code + '</td>' +
    '<td><div class="text-center"><button class="btn btn-primary open_edit_sub_subject_model" sub_subject_id="' + value.sub_subject_id + '" type="button" title="Edit" request_type="open_edit" subject_name="' + d.subject_name + '"><i class="fas fa-edit"></i></button>n
    <button type="button" class="btn btn-primary subject-data-delete" title="Remove" delete_type="sub_subject" subject_group_id="' + d.subject_group_id + '" subject_id="' + d.subject_id + '" sub_subject_id="' + value.sub_subject_id + '"><i class="fa fa-trash"></i></button>n
    </div></td>' +
    '</tr>';
    });
    // example is just for reference
    put above data in table using
    $("#table-sales tbody").html(tab_body);


    Hopfully it will help.








share|improve this answer


























  • I don't quite understand this sir. Could you explain a bit more. If you don't mind

    – BoonMingProg
    Nov 16 '18 at 9:40











  • Are you familiar with ajax call ?

    – amba patel
    Nov 16 '18 at 9:43











  • not really sir. I'm very sorry

    – BoonMingProg
    Nov 16 '18 at 9:44














0












0








0








  1. You can call ajax when click on Search button and pass start and end date as parameters in ajax request and filter data.


  2. After get ajax response from controller you can update tbody of table-sales table using jquery with updated data.
    Example
    Assume you get array of updated data
    var tab_body = '';



        $.each(sub_subject, function (key, value)
    {
    tab_body = tab_body + '<tr><td>' + value.sub_subject_name + '</td>' +
    '<td>' + value.sub_subject_code + '</td>' +
    '<td><div class="text-center"><button class="btn btn-primary open_edit_sub_subject_model" sub_subject_id="' + value.sub_subject_id + '" type="button" title="Edit" request_type="open_edit" subject_name="' + d.subject_name + '"><i class="fas fa-edit"></i></button>n
    <button type="button" class="btn btn-primary subject-data-delete" title="Remove" delete_type="sub_subject" subject_group_id="' + d.subject_group_id + '" subject_id="' + d.subject_id + '" sub_subject_id="' + value.sub_subject_id + '"><i class="fa fa-trash"></i></button>n
    </div></td>' +
    '</tr>';
    });
    // example is just for reference
    put above data in table using
    $("#table-sales tbody").html(tab_body);


    Hopfully it will help.








share|improve this answer
















  1. You can call ajax when click on Search button and pass start and end date as parameters in ajax request and filter data.


  2. After get ajax response from controller you can update tbody of table-sales table using jquery with updated data.
    Example
    Assume you get array of updated data
    var tab_body = '';



        $.each(sub_subject, function (key, value)
    {
    tab_body = tab_body + '<tr><td>' + value.sub_subject_name + '</td>' +
    '<td>' + value.sub_subject_code + '</td>' +
    '<td><div class="text-center"><button class="btn btn-primary open_edit_sub_subject_model" sub_subject_id="' + value.sub_subject_id + '" type="button" title="Edit" request_type="open_edit" subject_name="' + d.subject_name + '"><i class="fas fa-edit"></i></button>n
    <button type="button" class="btn btn-primary subject-data-delete" title="Remove" delete_type="sub_subject" subject_group_id="' + d.subject_group_id + '" subject_id="' + d.subject_id + '" sub_subject_id="' + value.sub_subject_id + '"><i class="fa fa-trash"></i></button>n
    </div></td>' +
    '</tr>';
    });
    // example is just for reference
    put above data in table using
    $("#table-sales tbody").html(tab_body);


    Hopfully it will help.









share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 21 '18 at 5:05

























answered Nov 16 '18 at 9:36









amba patelamba patel

278315




278315













  • I don't quite understand this sir. Could you explain a bit more. If you don't mind

    – BoonMingProg
    Nov 16 '18 at 9:40











  • Are you familiar with ajax call ?

    – amba patel
    Nov 16 '18 at 9:43











  • not really sir. I'm very sorry

    – BoonMingProg
    Nov 16 '18 at 9:44



















  • I don't quite understand this sir. Could you explain a bit more. If you don't mind

    – BoonMingProg
    Nov 16 '18 at 9:40











  • Are you familiar with ajax call ?

    – amba patel
    Nov 16 '18 at 9:43











  • not really sir. I'm very sorry

    – BoonMingProg
    Nov 16 '18 at 9:44

















I don't quite understand this sir. Could you explain a bit more. If you don't mind

– BoonMingProg
Nov 16 '18 at 9:40





I don't quite understand this sir. Could you explain a bit more. If you don't mind

– BoonMingProg
Nov 16 '18 at 9:40













Are you familiar with ajax call ?

– amba patel
Nov 16 '18 at 9:43





Are you familiar with ajax call ?

– amba patel
Nov 16 '18 at 9:43













not really sir. I'm very sorry

– BoonMingProg
Nov 16 '18 at 9:44





not really sir. I'm very sorry

– BoonMingProg
Nov 16 '18 at 9:44




















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53334410%2frange-date-search-on-datatables-codeigniter%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Florida Star v. B. J. F.

Danny Elfman

Retrieve a Users Dashboard in Tumblr with R and TumblR. Oauth Issues