
PK 
<?php
ob_start();
//error_reporting(E_ALL ^ E_NOTICE);
@session_start();
ini_set('allow_url_include',1);
date_default_timezone_set("Asia/Kolkata");
set_time_limit(600);
ini_set('max_execution_time',600);
include '../includes/settings/constant.php';
//include '../includes/settings/db.php';
require_once '../includes/settings/PDODB.php';
include '../includes/modules/functions.php';
$function = new FUNCTIONS();
if (!empty($_SESSION['adminId']) && !empty($_SESSION['admin_role_id'])) {
if($_SESSION['admin_role_id']==1){
//header("Location: index.php");
}elseif($_SESSION['admin_role_id']==2){
header("Location: ../dashboard/index.php");
}
}else{
header("Location: ../index.php");
exit();
}
if(!empty($_GET['id'])){
$id = $_GET['id'];
}else{ ?>
<script type="text/javascript">location.replace("index.php");</script>
<?php }
$member_id = $_GET['id'];
$members = $function->getMemberDetails($member_id,1);
/*for($i=0;$i<count($members);$i++){
echo $members[$i]['name']; exit;
}*/
$pdodb = PDODB::getInstance();
$sql = "SELECT e.house_no, e.occupation_self, u.owner_name, u.mobile,u.tel_no,u.id FROM `user_details` AS e INNER JOIN `users` AS u ON e.id = u.id WHERE u.isactive=1 AND e.isactive=1 AND u.id=$member_id AND e.id=$member_id"; //exit;
$result = $pdodb->query($sql);
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>INSPINIA | Basic Form</title>
<?php include_once '../layout/style.php'; ?>
</head>
<body>
<div id="wrapper">
<?php $currentPage = 'familymember-index'; include_once '../layout/side-bar.php'; ?>
<div id="page-wrapper" class="gray-bg">
<?php include_once '../layout/header.php'; ?>
<div class="row wrapper border-bottom white-bg page-heading">
<div class="col-lg-10">
<h2>Family Member List for</h2>
<h2><?=$result[0]['owner_name']." - ".$result[0]['house_no'];?></h2>
</div>
<div class="col-lg-2">
</div>
</div>
<div class="row">
<div class="col-lg-12">
<div class="ibox float-e-margins">
<div class="wrapper wrapper-content animated fadeInRight">
<div class="row">
<div class="col-lg-12">
<div class="ibox float-e-margins">
<div class="ibox-title">
</div>
<div class="ibox-content">
<div class="table-responsive">
<form method="POST" action="">
<table class="table table-striped table-bordered table-hover dataTables-example" id="myTable">
<thead>
<tr>
<th>S.no</th>
<th>Name</th>
<th>Age</th>
<th>Relation</th>
<th>Blood</th>
<th>Member Id</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php
for($i=0;$i<count($members);$i++){
?>
<tr>
<td><?=$i+1;?></td>
<td><?=$members[$i]['name'];?></td>
<td><?=$members[$i]['age'];?></td>
<td><?=$members[$i]['relation'];?></td>
<td><?=$members[$i]['blood_gp'];?></td>
<td><?=$members[$i]['member_id'];?></td>
<td>
<a class="btn btn-warning btn-xs fmemberedit"
data-id="<?=$members[$i]['id'];?>"
data-member_id="<?=$members[$i]['member_id'];?>"
data-name="<?=$members[$i]['name'];?>"
data-age="<?=$members[$i]['age'];?>"
data-relation="<?=$members[$i]['relation'];?>"
data-blood_gp="<?=$members[$i]['blood_gp'];?>"
data-toggle="modal" data-target="#fmemberedit">
<i class="fa fa-pencil"></i> Edit</a>
<a class="btn btn-danger btn-xs" href="list-family.php?fmid=<?=$members[$i]['id'];?>&id=<?=$_GET['id'];?>&action=Del" onclick=" return confirm('Do you really want to delete!')"><i class="fa fa-trash"></i> Delete</a>
</td>
</tr>
<?php } ?>
</tbody>
</table>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- add modal -->
<div class="modal inmodal fade" id="fmemberedit" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
<h4 class="modal-title">Family Member Edit Form</h4>
</div>
<form action="" enctype="multipart/form-data" method="post">
<div class="modal-body">
<div class="ibox-content">
<div class="table-responsive">
<table class="table table-striped table-bordered table-hover dataTables-example" id="myTable">
<thead>
<tr>
<th>Name</th>
<th>Age</th>
<th>Relation</th>
<th>Blood </th>
</tr>
</thead>
<tbody>
<tr>
<input type="hidden" value="<?=$member_id;?>" name="member_id" id="emember_id">
<input type="hidden" value="<?=$id;?>" name="id" id="eid">
<td><input type="text" value="" id="ename" name="name"></td>
<td><input type="text" value="" id="eage" name="age"></td>
<td><input value="" type="text" id="erelation" name="relation"></td>
<td><input value="" type="text" id="eblood_gp" name="blood_gp"></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-white" data-dismiss="modal">Close</button>
<button type="submit" name="update" value="EDIT" class="btn btn-primary">Save changes</button>
</div>
</form>
</div>
</div>
</div>
<!-- End modal -->
<?php include_once '../layout/script.php'; ?>
<script>
$(document).on("click", ".fmemberedit", function () {
$("#eid").val($(this).data('id'));
$("#ename").val($(this).data('name'));
$("#eage").val($(this).data('age'));
$("#erelation").val($(this).data('relation'));
$("#emember_id").val($(this).data('member_id'));
$('#eblood_gp').val($(this).data('blood_gp'));
});
</script>
<script>
function tossterMsgAlert(msg='Welcome',title='') {
toastr.options = {
closeButton: true,
//debug: false,
newestOnTop: false,
//progressBar: false,
positionClass: 'toast-top-center',
preventDuplicates: true,
//onclick: null,
//showDuration: 300,
//hideDuration: 1000,
timeOut: 2000,
//extendedTimeOut: 1000,
//showEasing: 'swing',
//hideEasing: 'linear',
//showMethod: 'fadeIn',
hideMethod: 'fadeOut'
};
toastr.warning(title,msg);
}
</script>
</body>
</html>
<?php
//start Delete Family-member
if(!empty($_GET['fmid']) && ($_GET['action']=='Del')) {
//print_r($_GET); exit;
$fmid=$_GET['fmid'];
$id=$_GET['id'];
//print_r($id); exit;
$pdodb = PDODB::getInstance();
echo $sql = "UPDATE family_member SET isactive=0 WHERE id = '".$fmid."'";
$result = $pdodb->query($sql);
PDODB::closeInstance();
if(!empty($result)){
header("Location: list-family.php?id=$id");
//echo '<script type="text/javascript">location.href("member-details.php?id=$id");</script>';
}
}
//End Delete Family-member
//Start edit family-member
if (!empty($_POST["update"]) && $_POST["update"]=='EDIT')
{
//print_r($_POST['id']); exit;
$fmid =$_POST['id'];
//print_r($fmid); exit;
$ipaddress = $function->getRealIpAddr();
$member_id = !empty($_POST['member_id'])?trim($_POST['member_id']):"";
$name = !empty($_POST['name'])?trim($_POST['name']):"";
$age = !empty($_POST['age'])?trim($_POST['age']):"";
$relation = !empty($_POST['relation'])?trim($_POST['relation']):"";
$blood_gp = !empty($_POST['blood_gp'])?trim($_POST['blood_gp']):"";
$pdodb = PDODB::getInstance();
echo $sql = "UPDATE family_member SET name='$name',age='$age',relation='$relation',blood_gp='$blood_gp',ipaddress='$ipaddress' WHERE id = '$fmid'";
//exit;
$result = $pdodb->query($sql);
PDODB::closeInstance();
if(!empty($result)){
header("Location: list-family.php?id=$member_id");
//echo '<script type="text/javascript">location.href("member-details.php?id=$id");</script>';
}
}
?>


PK 99