File: /var/www/nclive/technc/institutions_list.php
<?php include 'header.php'; ?>
<!-- Main Container -->
<main id="main-container">
<div class="content content-narrow">
<?php
if(isset($_REQUEST['update'])){
$id=$_REQUEST['id'];
$type=$_REQUEST['category'];
$name=$_REQUEST['unames'];
$stateid=$_REQUEST['states'];
$cityid=$_REQUEST['citys'];
$pin=$_REQUEST['pincodes'];
$address=$_REQUEST['adds'];
$longitude=$_REQUEST['longitudes'];
$latitude=$_REQUEST['latitudes'];
$emails=$_REQUEST['emailss'];
$phones=$_REQUEST['phoness'];
$weblink=$_REQUEST['links'];
$applylink=$_REQUEST['applys'];
$onlinefee=$_REQUEST['fees'];
$result=$_REQUEST['results'];
$other=$_REQUEST['others'];
$display=$_REQUEST['orders'];
$status=$_REQUEST['statuss'];
$query2="UPDATE `sp_institutions` SET `category_id` = '$type',`institutions_name` = '$name',`state_id` = '$stateid', `city_id` = '$cityid',`pincode` = '$pin',`longitude` = '$longitude',`latitude` = '$latitude', `important_emails` = '$emails',`important_phones` = '$phones',`official_website_link` = '$weblink', `online_apply_link` = '$applylink',`online_fee_link` = '$onlinefee',`result_link` = '$result',`other_info` = '$other',`display_order` = '$display',`status` = '$status' WHERE `id` = '$id';";
$sql2=$db->prepare($query2);
if($sql2->execute()){
$cou_name=$_REQUEST['cour'];
foreach($cou_name as $c){
$n=$db->prepare("insert into sp_institute_courses set institute_id='$id',course_id='$c'");
$n->execute();
}
echo '<h3 style="color:green;">Data submit successfully</h3>';
echo "<meta http-equiv='refresh' content='0'>";
}
else{echo "Something Wrong!";}
}
$count="select count(*) as total from sp_institutions as t1
LEFT JOIN sp_institutions_category as ic on ic.id=t1.category_id
LEFT JOIN sp_states as t2 on t2.state_id=t1.state_id
LEFT JOIN sp_city as t3 on t3.city_id=t1.city_id";
$sql4=$db->prepare($count);
$sql4->execute();
$plus=$sql4->fetch();
$query="SELECT t1.id,ic.category_name, t1.institutions_name,sc.course_name, t1.state_id, t1.city_id,t1.pincode,t1.longitude, t1.latitude,t1.important_emails, t1.important_phones, t1.official_website_link, t1.online_apply_link, t1.online_fee_link, t1.result_link, t1.other_info,t1.display_order, t1.status,t2.state_name ,t1.added_date,t3.city as city FROM sp_institutions as t1
LEFT JOIN sp_institutions_category as ic on ic.id=t1.category_id
LEFT JOIN sp_states as t2 on t2.state_id=t1.state_id
LEFT JOIN sp_city as t3 on t3.city_id=t1.city_id
LEFT JOIN sp_institute_courses as c on c.institute_id=t1.id
LEFT JOIN sp_courses as sc on sc.id=c.course_id";
$sql=$db->prepare($query);
$sql->execute();
?>
<!-- Forms Row -->
<div class="row">
<div class="col-lg-12">
<!-- Bootstrap Forms Validation -->
<h2 class="content-heading">KVS/NVS Navodya List</h2>
<div style="overflow-x:auto;">
<table class="table table-striped table-hover text-capitalize">
<thead>
<tr class="danger">
<th class="text-center">S.No.</th>
<th class="text-center"> Category Name</th>
<th class="text-center">Institutions Name</th>
<th class="text-center">State</th>
<th class="text-center">City</th>
<th class="text-center">Pincode</th>
<th class="text-center">Address</th>
<th class="text-center">longitude</th>
<th class="text-center"> latitude</th>
<th class="text-center">Important Email</th>
<th class="text-center">important phones</th>
<th class="text-center">official website link</th>
<th class="text-center">online apply link</th>
<th class="text-center">online fee link</th>
<th class="text-center">result link</th>
<th class="text-center">other info</th>
<th class="text-center">display order</th>
<th class="text-center">status</th>
<th class="text-center">Edit</th>
<th class="text-center">Delete</th>
</tr>
</thead>
<?php $i='1';
while($row=$sql->fetch()){
?>
<tr>
<td class="text-center"> <?php echo $i; ?></td>
<td class="text-center"><?php echo $row['category_name']; ?></td>
<td class="text-center"><?php echo $row['institutions_name']; ?></td>
<td class="text-center"><?php echo $row['state_name']; ?></td>
<td class="text-center"><?php echo $row['city']; ?></td>
<td class="text-center"><?php echo $row['pincode']; ?></td>
<td class="text-center"><?php echo $row['address']; ?></td>
<td class="text-center"><?php echo $row['longitude']; ?></td>
<td class="text-center"><?php echo $row['latitude']; ?></td>
<td class="text-center"><?php echo $row['important_emails']; ?></td>
<td class="text-center"><?php echo $row['important_phones']; ?></td>
<td class="text-center"><?php echo $row['official_website_link']; ?></td>
<td class="text-center"><?php echo $row['online_apply_link']; ?></td>
<td class="text-center"><?php echo $row['online_fee_link']; ?></td>
<td class="text-center"><?php echo $row['result_link']; ?></td>
<td class="text-center"><?php echo $row['other_info']; ?></td>
<td class="text-center"><?php echo $row['display_order']; ?></td>
<td class="text-center"><?php echo $row['status']; ?></td>
<td class="text-center"><button name="edit" class="btn btn-info" onclick="selectData(<?php echo $row['id']; ?>)" data-toggle="tooltip" title="Edit this exam">Edit</button></td>
<td class="text-center"><a style="color:#fff;" href="institutions_list_delete.php?id=<?php echo $row['id'];?>" onclick="return confirm('Are you sure you want to delete')"><button class="btn btn-danger" data-toggle="tooltip" title="Delete this exam!">Delete</button></a></td>
</tr>
<?php $i++; } ?>
<tr class="danger">
<th colspan='10'>Total </th>
<td colspan='10 '><?php echo $plus['total']; ?></td>
.
</tr>
</table>
</div>
<!-- Bootstrap Forms Validation -->
</div>
</div>
</div>
<!-- END Forms Row -->
</div>
<!-------STATUS MODEL-------------------------------->
<div class=" modal fade" id="statusModel" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Edit</h4>
</div>
<div class="modal-body">
<form class="js-validation-bootstrap form-horizontal" action="" method="post" id="form">
<div class="form-group">
<label class="col-md-2 control-label" for="val-select2"> Category </label>
<input type="hidden" id="id" name="id">
<div class="col-md-10">
<select class="js-select2 form-control" name="category" style="width: 100%;">
<?php
$cat=$db->prepare("select category_name,id from sp_institutions_category");
$cat->execute();
?>
<option id="category" value="" selected="selected">--Select Category--</option>
<?php while($all=$cat->fetch()){
?>
<option value="<?php echo $all['id']; ?>"><?php echo $all['category_name']; ?></option>
<?php } ?>
</select>
</div>
</div>
<div class="form-group">
<label class="col-md-2 control-label" for="val-username">Institutions Name<span class="text-danger">*</span></label>
<div class="col-md-10">
<input class="form-control" type="text" name="unames" id="name" placeholder="">
</div>
</div>
<div class="form-group" >
<label class="col-md-2 control-label" for="val-select2">Select State<span class="text-danger">*</span></label>
<div class="col-md-10">
<select class="js-select2 form-control" id="type2" name="states" style="width: 100%;">
<?php
$sql = $db->prepare("SELECT state_id,state_name FROM sp_states");
$sql->execute();
?><option value="" id="st" selected="selected">--Select State--</option><?php
while($row1=$sql->fetch(PDO::FETCH_ASSOC))
{
?>
<option value="<?php echo $row1['state_id']; ?>"><?php echo $row1['state_name']; ?></option>
<?php
} ?>
</select>
</div>
</div>
<div class="form-group" >
<label class="col-md-2 control-label" for="val-select2">Select City<span class="text-danger">*</span></label>
<div class="col-md-10">
<select name="citys" class="form-control">
<option id="city" selected="selected">Select City</option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-md-2 control-label" for="val-password">Pin Code<span class="text-danger">*</span></label>
<div class="col-md-10">
<input class="form-control" id="Pin" value="" type="number" name="pincodes">
</div>
</div>
<div class="form-group">
<label class="col-md-2 control-label" for="val-password"> longitude<span class="text-danger">*</span></label>
<div class="col-md-10">
<input class="form-control" type="number" name="longitudes" id="longitude" value="">
</div>
</div>
<div class="form-group">
<label class="col-md-2 control-label" for="val-password">latitude<span class="text-danger">*</span></label>
<div class="col-md-10">
<input class="form-control" type="number" name="latitudes" id="latitude" value="">
</div>
</div>
<div class="form-group">
<label class="col-md-2 control-label" for="val-password">Important Emails<span class="text-danger">*</span></label>
<div class="col-md-10">
<input class="form-control" type="text" name="emailss" id="Emails" value="">
</div>
</div>
<div class="form-group">
<label class="col-md-2 control-label" for="val-password">Important Phones<span class="text-danger">*</span></label>
<div class="col-md-10">
<input class="form-control" type="text" name="phoness" id="Phones" value="" />
</div>
</div>
<div class="form-group">
<label class="col-md-2 control-label" for="val-password">official Website Link<span class="text-danger">*</span></label>
<div class="col-md-10">
<input class="form-control" type="text" name="links" id="Link" value="" />
</div>
</div>
<div class="form-group">
<label class="col-md-2 control-label" for="val-password">Online Apply Link<span class="text-danger">*</span></label>
<div class="col-md-10">
<input class="form-control" type="url" name="applys" id="apply" value="" />
</div>
</div>
<div class="form-group">
<label class="col-md-2 control-label" for="val-password">Online Fee Link<span class="text-danger">*</span></label>
<div class="col-md-10">
<input class="form-control" type="text" name="fees" id="feelink" value="" />
</div>
</div>
<div class="form-group">
<label class="col-md-2 control-label" for="val-password">Result link<span class="text-danger">*</span></label>
<div class="col-md-10">
<input class="form-control" type="text" name="results" id="Resultlink" value="" />
</div>
</div>
<div class="form-group">
<label class="col-md-2 control-label" for="val-password">Selected course<span class="text-danger">*</span></label>
<div class="col-md-10">
<input class="form-control" type="text" name="sel" id="sel_cou" readonly="readonly">
</div>
</div>
<div class="form-group">
<label class="col-md-2 control-label" for="val-password">Select courses<span class="text-danger">*</span></label>
<div class="col-md-10">
<?php
$cou=$db->prepare("select id,course_name from sp_courses order by id asc");
$cou->execute();
while($row3=$cou->fetch(PDO::FETCH_ASSOC)){
?>
<div class="col-md-4"><input id="chk" class="form-control" type="checkbox" name="cour[]" value="<?php echo $row3['id'];?>"><?php echo $row3['course_name']; ?>
<!-- <input type="hidden" name="course_id" id="ins_cou" value=""> -->
</div>
<?php } ?>
</div>
</div>
<div class="form-group">
<label class="col-md-2 control-label" for="val-password">Other Info<span class="text-danger">*</span></label>
<div class="col-md-10">
<input class="form-control" type="text" name="others" id="Info" value="" />
</div>
</div>
<div class="form-group">
<label class="col-md-2 control-label" for="val-password">Display Order<span class="text-danger">*</span></label>
<div class="col-md-10">
<input class="form-control" type="number" name="orders" id="Order" value="" />
</div>
</div>
<div class="form-group">
<label class="col-md-2 control-label" for="val-password">Status<span class="text-danger">*</span></label>
<div class="col-md-10">
<select name="statuss" class="form-control">
<option value="" id="status"></option>
<option value="1">Active</option>
<option value="0">Deactive</option>
</select>
</div>
</div>
<div class="form-group">
<div class="col-md-10 col-md-offset-2">
<button class="btn btn-lg btn-primary" type="submit" name="update">Submit</button>
</div>
</div>
</form>
</div>
</div>
</div> </div>
<!---------END STATUS MODEL----->
<!-- END Page Content -->
</main>
<script type="text/javascript">
function selectData(id) {
var base_url = window.location.origin;
$.ajax('institutions_list_select.php', {
type: 'POST',
data: { id:id },
success: function (data) {
document.getElementById("id").value=id;
document.getElementById("category").value=data.category_id;
document.getElementById("category").innerHTML=data.category_name;
document.getElementById("name").value=data.institutions_name;
document.getElementById("Pin").value=data.pincode;
document.getElementById("longitude").value=data.longitude;
document.getElementById("latitude").value=data.latitude;
document.getElementById("Emails").value=data.important_emails;
document.getElementById("Phones").value=data.important_phones;
document.getElementById("Link").value=data.official_website_link;
document.getElementById("apply").value=data.online_apply_link;
document.getElementById("feelink").value=data.online_fee_link;
document.getElementById("Resultlink").value=data.result_link;
document.getElementById("sel_cou").value=data.courses;
// document.getElementById("ins_cou").value=data.ins_cou;
// document.getElementById("chk").value=data.courseid;
// document.getElementById("chk").innerHTML=data.course_name;
document.getElementById("Info").value=data.other_info;
document.getElementById("Order").value=data.display_order;
document.getElementById("status").value=data.status;
document.getElementById("st").value=data.state_id;
document.getElementById("st").innerHTML=data.state_name;
document.getElementById("city").innerHTML=data.city;
document.getElementById("city").value=data.city_id;
if(document.getElementById("status").value==1){
document.getElementById("status").innerHTML="Active";
}
else if(document.getElementById("status").value==2){
document.getElementById("status").innerHTML="De-Active";
}
},
error: function (jqXhr, textStatus, errorMessage) {
}
});
jQuery("#statusModel").modal();
}
</script>
<script type="text/javascript">
$(document).ready(function()
{
$("#type2").change(function()
{
var id=$(this).val();
var dataString = 'id='+ id;
$.ajax
({
type: "POST",
url: "get_city.php",
data: dataString,
cache: false,
success: function(html)
{
$("#city").html(html);
}
});
});
});
</script>
<?php include 'footer.php'; ?>
<!-- END Main Container -->