• logo
  • PHP
  • PHP OOPs
  • script
    • JavaScript
    • JQuery
    • Ajax
    • AngularJs
    • VueJs
    • NodeJs
    • ReactJs
  • wordpress
  • Codeigniter
  • Codeigniter 4
  • Laravel
  • Python
  • MySql
  • Json
  • C
  • C++
  • More ...
    • Cakephp Framework
    • MongoDb
    • MySqli PDO
    • .htaccess
    • HTML 5
    • CSS
    • SEO
    • DCA

Codeigniter Tutorials

  • What is codeigniter?
  • Application_Architecture
  • MVC Architecture
  • HMVC Architecture
  • Codeigniter Configuration
  • Remove index.php from url in codeigniter
  • MVC Concept
  • View
  • Alternate PHP Syntax for View Files
  • Routing
  • Codeigniter URL
  • Get Current URL
  • Previous page URL get
  • Seo Friendly URL
  • Slug Create in codeigniter
  • What is _remap() function
  • Remove controller name from url in codeigniter
  • Codeigniter Controller Class
  • Class Constructor
  • GET $ POST method in Codeigniter
  • Models
  • Basepath, Apppath, FCPATH
  • URI Segment
  • Page Redirect
  • Helper class
  • Custom Helper class
  • Form Helper
  • Common Helper Functions
  • Common Function
  • Array Problems
  • Call controller in Helper
  • Add active class to menu using Helper class
  • Custom Library
  • Custom Library Example
  • when to use get_instance()
  • Codeigniter Hook
  • how to work inline css in codeigniter
  • Custom 404 page
  • 404 custom error page
  • Create custom config file in codeigniter
  • How to set and get config item value
  • How to Speed Up CodeIgniter App?
  • Codeigniter Functions
  • Session
  • cookies
  • How to Set & Get Tempdata in Codeigniter
  • flash messages in Codeigniter
  • Flashdata
  • Encryption and Decryption In CodeIgniter
  • Codeigniter security
  • csrf token form security
  • Password Hashing
  • Form Validation
  • Custom Validation
  • Registration Form with validation
  • Server Side Form Validation
  • Validate Select Option Field
  • Date Format Validation
  • Date Format change in codeigniter
  • Date Functions
  • DOB Validation
  • CI CRUD
  • User SignUp
  • User Login
  • User Logout
  • Login Account
  • Login form with RememberMe
  • Login Form with session
  • User change password
  • Change Password with Callback Validation to Check Old Password
  • Forgot password
  • Reset password
  • Insert data in database
  • Fetch data from database
  • Update data in database
  • Delete data in database
  • File Upload
  • Image Upload with resize Image
  • Upload Multiple file and images
  • Upload Multiple images with CRUD
  • File and image update
  • Upload Image Using Ajax.
  • Email Send
  • Email Send Using Email library
  • Email Send Using SMTP Gmail
  • Notification send
  • store data in json format in DB
  • Json parse
  • Fetch data Using Ajax with Json data
  • How to Show data Using Ajax with Json parse
  • Get JSON Data from PHP Script using jQuery Ajax
  • Insert data Using Ajax
  • Submit data Using Ajax with form validation
  • How to show data Using Ajax in codeigniter
  • Insert & Update Using Ajax
  • Registration Form With Validation Using Ajax in codeigniter
  • Delete data Using Ajax Confirmation
  • Delete All data Using checkbox selection
  • Ajax CSRF Token
  • Ajax Post
  • Ajax serverside form validation
  • Contact form using AJAX with form validation
  • DataTable Using Ajax dynamically
  • DataTables pagination using AJAX with Custom filter
  • DataTables AJAX Pagination with Search and Sort in codeigniter
  • DataTables in Codeigniter using Ajax
  • Ajax Custom Serarch
  • Ajax Live Data Search using Jquery PHP MySql
  • Ajax Custom Serarch and sorting in datatable
  • Dynamic Search Using Ajax
  • Autocomplete using jquery ajax
  • Jquery Ajax Autocomplete Search using Typeahead
  • Dynamic Dependent Dropdown Using Ajax
  • Dynamic Dependent Dropdown list Using Ajax
  • Dynamic Dependent Dropdown in codeigniter using Ajax
  • ajax username/email availability check using JQuery
  • Check Email Availability Using Ajax
  • Data Load on mouse scroll
  • Ajax CI Pagination
  • Pagination in codeigniter
  • Ajax Codeigniter Pagination
  • email exists or not using ajax with json
  • CRUD using AJAX With Modal popup in CI
  • Add / Show Data on modal popup using Ajax
  • Modal popup Validation using Ajax
  • Data show on Modal popup Using Ajax
  • Add / Remove text field dynamically using jquery ajax
  • How to Add/Delete Multiple HTML Rows using JavaScript
  • Delete Multiple Rows using Checkbox
  • Multiple Checkbox value
  • Form submit using jquery Example
  • REST & SOAP API
  • Multi-Language implementation in CodeIgniter
  • How to pass multiple array in view
  • Captcha
  • create zip file and download
  • PhpOffice PhpSpreadsheet Library (Export data in excel sheet)
  • data export in excel sheet
  • Excel File generate in Codeigniter using PHPExcel
  • Dompdf library
  • tcpdf library
  • Html table to Excel & docs download
  • CI Database Query
  • Database Query
  • SQL Injection Prevention
  • Auth Model
  • Join Mysql
  • Tree View in dropdown option list
  • OTP Integration in codeigniter
  • curl post
  • download file using curl
  • Sweet Alert
  • Sweet alert Delete & Success
  • Log Message in Codeigniter
  • Menu & Submenu show dynamically
  • Set Default value in input box
  • Cron Jobs
  • Stored Procedure
  • Display Loading Image when AJAX call is in Progress
  • Send SMS
  • IP Address
  • Codeigniter Tutorialspoint
  • Website Link
  • How To Create Dynamic Xml Sitemap In Codeigniter
  • Paypal Payment Integration
  • Get Latitude and Longitude From Address in Codeigniter Using google map API
  • How To Create Simple Bar Chart In Codeigniter Using AmCharts?
  • dynamic Highcharts in Codeigniter
  • Barcode in Codeigniter
  • Codeigniter Interview Questions
  • Project
Home » Codeigniter » 

Dynamic Search Using Ajax


View

File Name :

<?php $this->load->view('dashboard_includes/header.php');?>
<?php $this->load->view('dashboard_includes/nav.php');?>
<?php $this->load->view('dashboard_includes/left.php');?>
<style>

#msg_loader{
position: fixed;
bottom: 25%;
left: 37%;
display: none;
}
</style>


<div class="content-wrapper">

<div class="content-header">
<div class="container-fluid">
<div class="row mb-2">
<div class="col-sm-6">
<h1 class="m-0 text-dark">Court Cases Reports</h1>
</div>
<div class="col-sm-6">
<ol class="breadcrumb float-sm-right">
<li class="breadcrumb-item"><a href="<?php echo base_url();?>rtiList">Court</a></li>
<li class="breadcrumb-item active">Cases reports</li>
</ol>
</div>
</div>
</div>
</div>



<section class="content">
<div class="col-md-12" data-aos="fade-left">





<div class="card">
<div class="card-body">
<div class="tab-content">
<div class="portlet-body">


<form id="frm" name="form" method="get" enctype="multipart/form-data" action="" onSubmit="return validateForm()" >
<dl class="row" style="background:#43A078; color:#fff;">
<div class="col-md-10">
<h4 class="ml-1 p-2">Please Select Keywords for Search </h4>
</div>
</dl>
<div class="form-row">
<div class="col-md-4 mb-3">

<label for="validationCustom01">Regional Office</label>

<select class="form-control" name="regional_office" id="regional_office" >

<option value="" selected="selected" disabled="disabled">--- Select Regional Office ---</option>
<?php foreach($region_info as $row){?>
<option value="<?php echo $row->pki_region_id; ?>"><?php echo $row->uvc_region_title;?></option>
<?php } ?>
</select>


</div>

<div class="col-md-4 mb-3">

<label for="">Branch Office</label>
<select class="form-control" name="branch_office" id="branch_office">
<option value="" selected="selected" disabled="disabled">--- Select Branch Office ---</option>

<?php foreach($branch_info as $row){?>
<option value="<?php echo $row->pki_id; ?>"><?php echo $row->uvc_branch_code;?></option>
<?php } ?>
</select>
<span class="help-block" id="error"></span>

</div>

<div class="col-md-4 mb-3">
<label for="">Type Of Cases</label>
<select class="form-control" name="type_of_cases" id="type_of_cases">
<option value="" selected="selected" disabled="disabled">--- Select Type Of Cases ---</option>
<?php foreach($typeofcases as $row){?>
<option value="<?php echo $row->id; ?>"><?php echo $row->type_of_cases;?></option>
<?php } ?> </select>
<span class="help-block" id="error"></span>
</div>
</div>

<div class="form-row">
<div class="col-md-4 mb-3">
<label for="">State</label>
<select class="form-control" name="state" id="state">
<option value="" selected="selected" disabled="disabled">--- Select state ---</option>

<?php foreach($state_list as $row){?>
<option value="<?php echo $row->id; ?>"><?php echo $row->state_name;?></option>
<?php } ?>

</select>

</div>


<!--
<div class="col-md-4 mb-3">
<label for="fromdate">From Date</label>
<?php if($this->input->get('fromdate')){$fromdate = $this->input->get('fromdate',true); } else { $fromdate = false;} ?>
<input type="text" class="form-control" name="fromdate" id="fromdatepicker" placeholder="Please select Form Date" value="<?php echo $fromdate; ?>" readonly />

</div>
<div class="col-md-4 mb-3">
<?php if($this->input->get('todate')){ $todate = $this->input->get('todate',true); } else { $todate = false;} ?>
<label for="todate">To Date </label>
<input type="text" class="form-control" name="todate" id="todatepicker" placeholder="Please select To Date" value="<?php echo $todate; ?>" readonly />
<span class="help-block" id="error"></span>
<span class="help-block" id="input_error"><?php echo form_error('isno')?></span>
</div>

</div>

-->


<!-- <input type="submit" name="submit" value="Submit" class="btn btn-primary"> -->
<div class="col-md-12 text-center mt-2">
<input class="btn btn-lg text-uppercase text-white" id="btn_search" type="submit" name="Submit" value="Search" style="width:300px; background-color:#20b2aa;">
</div>

</form>
</div>
</div>
</div>
</div>
<!-- start search table listing date 28-07-2021 dinesh kumar-->


<!-- end search table listing date 28-07-2021 dinesh kumar-->

</div>
</section>



<section class="content">
<div id="search_data">

</div>

</section>









</div>

<?php $this->load->view('includes/footer.php');?>



<script>
$(function () {
$("#fromdatepicker").datepicker({
numberOfMonths: 1,
changeMonth: true,
changeYear: true,
dateFormat: 'dd-mm-yy',
maxDate: "+0d"

});
$("#todatepicker").datepicker({
numberOfMonths: 1,
changeMonth: true,
changeYear: true,
dateFormat: 'dd-mm-yy',
maxDate: "+0d"

});
});

</script>

<script>
$(document).ready(function(){
$("#search").click(function(){



});
});

</script>
<script>
$("#btn_search").click(function(){

$("#search_loader").css('display', 'block');
event.preventDefault();
var searchqry = $("#frm").serialize();
//alert("search data");

$.ajax({
type: "POST",
url: "<?php echo base_url();?>itechxpert/search_data",
data: $("#frm").serialize(),
cache: false,
success:function(data){
//alert(data);
$("#search_loader").fadeOut("slow");
$("#search_data").html(data);
// location.reload();
},
complete:function(){
$('#frm').each(function(){
this.reset(); //Here form fields will be cleared.

});
}
});

});

</script>




</body>
</html>

Controller

File Name : Itechxpert.php

public function search_data()
{
$data = array();
$regional_office = $this->input->post('regional_office');
$branch_office = $this->input->post('branch_office');
$type_of_cases = $this->input->post('type_of_cases');
$state = $this->input->post('state');

$data['search_parameters']= [
'reg' => $regional_office,
'bra' => $branch_office,
'type' => $type_of_cases,
'state' => $state
];



//$data['regional_office'] = $this->Common->get_regional_office($regional_office);
//$data['branch_office'] = $this->Common->get_branch_office($branch_office);
//$data['type_of_cases'] = $this->Common->get_type_of_cases($type_of_cases);
//$data['state'] = $this->Common->get_state($state);
//print_r($data['regional_office']);exit;

$data['search_result'] = $this->Common->get_search_data($regional_office,$branch_office,$type_of_cases,$state);


$search_result = $this->load->view("search-result",$data,true);
echo $search_result;
exit;
}

public function export_excel()
{
$filename = 'case_'.date('Ymd').'.csv';
header("Content-Description: File Transfer");
header("Content-Disposition: attachment; filename=$filename");
header("Content-Type: application/csv; ");

$regional_office = $this->input->get('reg');
$branch_office = $this->input->get('bra');
$type_of_cases = $this->input->get('type');
$state = $this->input->get('state');

$reportdata = $this->Common->get_search_data_excel($regional_office,$branch_office,$type_of_cases,$state);

//print_r($reportdata);exit;

$file = fopen('php://output','w');

$header = array("Id","file_no","case_no","regional_office","branch_office","search_seizure","complaint_date","type_of_cases","state","name_of_court","complaint_officer","name_of_accused","name_of_counsel","mobile_no","advocate_fee","misc_expenses","product_name","mandatory_voluntary","certified_body","complaint_detail","bis_act","stay_granted","case_status","order_of_court","date_of_hearing","date_of_order","decision_in_brief","financial_penalty","review_appeal","remarks","created_at","created_by","status");
fputcsv($file, $header);
foreach ($reportdata as $key=>$line){
fputcsv($file,$line);
}
fclose($file);
exit;


}

Model

File Name : Common_model.php

public function get_search_data($regional_office,$branch_office,$type_of_cases,$state)
{
/*
$where = '';
if(!empty($regional_office)){
$where .= "regional_office = ".$regional_office;
}

if(!empty($branch_office)){
$where .= " AND branch_office = ".$branch_office;
}

if(!empty($type_of_cases)){
$where .= " AND type_of_cases = ".$type_of_cases;
}

if(!empty($state)){
$where .= " AND state =".$state;
}
$this->db->select('*');
$this->db->from('itechxpert');
$this->db->where($where);
$query = $this->db->get();
echo $this->db->last_query();
return $query->result();


*/

$sqlquery = "select * from itechxpert where id=0 ";

if(!empty($regional_office))
{
$sqlquery .= "Union
(select * from itechxpert where regional_office =".$regional_office.")";
}
if(!empty($branch_office))
{
$sqlquery .= "Union
(select * from itechxpert where branch_office =".$branch_office.")";
}
if(!empty($type_of_cases))
{
$sqlquery .= "Union
(select * from itechxpert where type_of_cases =".$type_of_cases.")";
}
if(!empty($state))
{
$sqlquery .= "Union
(select * from itechxpert where state =".$state.")";
}

$sqlquery .= " order by id asc";
$query = $this->db->query($sqlquery);
$result = $query->result();
//print_r($result);die();
return $result;



}

public function get_search_data_excel($regional_office,$branch_office,$type_of_cases,$state)
{
$sqlquery = "select * from court_cases where id=0 ";
if(!empty($regional_office))
{
$sqlquery .= "Union
(select * from court_cases where regional_office =".$regional_office.")";
}
if(!empty($branch_office))
{
$sqlquery .= "Union
(select * from court_cases where branch_office =".$branch_office.")";
}
if(!empty($type_of_cases))
{
$sqlquery .= "Union
(select * from court_cases where type_of_cases =".$type_of_cases.")";
}
if(!empty($state))
{
$sqlquery .= "Union
(select * from court_cases where state =".$state.")";
}
$sqlquery .= " order by id asc";
$query = $this->db->query($sqlquery);
$result = $query->result_array();
return $result;

}

View

File Name : search-result.php


<div class="col-md-12">
<div class="card">
<div class="card-body">
<div class="tab-content">
<div class="portlet-body" data-aos="fade-right">
<div class="row mb-3">
<div class="col-md-12">
<dl class="row" style="background:#43A078; color:#fff">
<div class="col-md-10">
<h4 class="p-2" style="margin-top:7px;">Total Records ( <?php echo $total = count($search_result); ?> ) </h4>
</div>

<div class="col-md-2 float-md-end p-2">
<a href="<?php echo base_url()?>itechxpert/export_excel?reg=
<?php echo $search_parameters['reg'];?>&bra=<?php echo $search_parameters['bra'];?>&type=<?php echo $search_parameters['type'];?>&state=<?php echo $search_parameters['state'];?>"

class="btn btn-info active float-right navbar-brand"> <i class="fa fa-file-excel-o" aria-hidden="true"></i> Excel Download</a>
</div>


</dl>

<table id="example" class="table table-striped table-bordered" style="width:100%">
<thead style="background-color:#f4f4f4; color:#000;">
<tr>
<th style="width:1%"><center><strong>S.No</strong></center></th>
<th style="width:10%"><center> File No. </center></th>
<th style="width:10%"><center>Case No.</center></th>
<th style="width:10%"><center>Region </center></th>
<th style="width:10%"><center>Branch</center></th>
<th style="width:20%"><center>Case Type</center></th>
<th style="width:15%"><center>State </center></th>
<th style="width:10%"><center>status </center></th>
<th style="width:10%"><center>Action </center></th>
</tr>
</thead>
<tbody>

<?php $i = 1;
foreach($search_result as $row){
?>

<tr>
<td align="center"> <?php echo $i++;?></td>
<td align="center"><?php echo $row->file_no; ?> </td>
<td align="center"><?php echo $row->case_no; ?> </td>
<td align="center"><?php echo $row->regional_office; ?> </td>
<td align="center"><?php echo $row->branch_office; ?> </td>
<td align="center"><?php echo $row->type_of_cases; ?> </td>
<td align="center"><?php echo $row->state; ?> </td>
<td align="center"><?php echo $row->status; ?> </td>
<td align="center"> <a href="<?php echo base_url()?>court/courtcases/caseview/<?php echo base64_encode($row->id); ?>" target="_blank" class="btn btn-info active float-right navbar-brand"> View </a> </td>
</tr>
<?php } ?>




</tbody>
</table>
</div>
</div>

</div>
</div>
</div>
</div>
</div>
</div>



File Name :


File Name :





Itechtuto

Connect Us Socially:

Quick Links

  • itech
  • About Us
  • Feedback
  • Trademarks
  • Privacy Policy
  • Terms of Use
  • Sitemap
  • Trademarks
  • Privacy Policy
  • Terms of Use
  • Sitemap

Copyright © 2016 itechxpert (P) Ltd. All rights reserved.

Copyright © 2016 itechxpert (P) Ltd. All rights reserved.