<?php
require_once("common/config.php");
require_once("common/database.php");
require_once("common/functions.php");
require_once("common/messages.php");
require_once("common/initialize.php");
if (isset($_POST["email"]) && $_POST["email"] != "") {
$email = trim($_POST['email']);
$pwd = md5(trim($_POST['pwd']));
if (!$email == "" && !$pwd == "") {
$query = "SELECT * FROM users WHERE email='$email' AND password='$pwd'";
$result = db::getRecord($query);
if (!empty($result)) {
$user = true;
} else {
$user = false;
}
//$pwd = md5($pwd);
//$query = "select u.*, ut.refcode as userrole from users u left join usertypes as ut on ut.typeid=u.usertype where email='" . $email . "' and password='". $pwd ."'" ;
//$user = db::getRecord($query);
if ($user) {
//saveLastActiveTime($user['id']);
$_SESSION["loggedInUserRole"] = $result['role'];
$_SESSION['firstname'] = $result['first_name'];
$_SESSION['lastname'] = $result['last_name'];
$_SESSION['email'] = $result['email'];
$_SESSION["isAdminloggedin"] = true;
$_SESSION['adminid'] = $result['id'];
if ($result['role'] == 'Admin') {
header('Location: ' . $site_root . 'admin/index.php');
}
/* if (trim($user["usertype"])=="1"){ //Administrator
$_SESSION["isAdminloggedin"]=true;
$_SESSION['adminid'] = $user['id'];
header('Location: '.$site_root.'admin/index.php');
} */
} else {
$_SESSION['error'] = "incorrect_login";
$_SESSION["msgType"] = "danger";
}
} else {
$_SESSION['error'] = "incorrect_login";
$_SESSION["msgType"] = "danger";
}
}
$disease_list = db::getRecords("select id,title as name from diseas");
//print_r($disease_list);
//exit;
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<!-- Title and other stuffs -->
<title>FSO ODA PATIENT <?php @showTitle($title); ?></title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="style/bootstrap.css" rel="stylesheet">
<link rel="stylesheet" href="style/font-awesome.css">
<link rel="stylesheet" href="style/jquery-ui-1.9.2.custom.min.css">
<link rel="stylesheet" href="style/fullcalendar.css">
<link rel="stylesheet" href="style/prettyPhoto.css">
<link rel="stylesheet" href="style/rateit.css">
<link rel="stylesheet" href="style/bootstrap-datetimepicker.min.css">
<link rel="stylesheet" href="style/jquery.cleditor.css">
<link rel="stylesheet" href="style/uniform.default.html">
<link rel="stylesheet" href="style/daterangepicker-bs3.css" />
<link rel="stylesheet" href="style/bootstrap-switch.css">
<link href="style/style.css" rel="stylesheet">
<link href="style/widgets.css" rel="stylesheet">
<link href="style/jquery.gritter.css" rel="stylesheet">
<link href="style/validationEngine.jquery.css" rel="stylesheet">
<link href="https://cdnjs.cloudflare.com/ajax/libs/chosen/1.8.7/chosen.css" rel="stylesheet">
<link href="https://cdnjs.cloudflare.com/ajax/libs/chosen/1.8.7/chosen.min.css" rel="stylesheet">
<!-- HTML5 Support for IE -->
<!--[if lt IE 9]>
<script src="js/html5shim.js"></script>
<![endif]-->
<!-- Favicon -->
<link rel="shortcut icon" href="../img/favicon.png">
</head>
<style>
.container{max-width: 100%!important}
</style>
<body>
<!-- Form area -->
<div class="container">
<div class="row">
<div class="col-sm-12">
<!-- Widget starts -->
<div class="widget">
<!-- Widget head -->
<div class="widget-head">
<i class="icon-lock"></i> Sign up
</div>
<div class="widget-content">
<!-- Login form -->
<?php if ($_GET["id"] != 1) { ?>
<form class="validate form-horizontal" role="form" id="formLogin" action='actions.php' method="post" enctype="multipart/form-data">
<!-- Email -->
<div class="form-group padd">
<label class="control-label col-sm-2" >First Name</label>
<div class="col-sm-4">
<input type="text" name="first_name" class="validate[required] form-control" placeholder="first name" onChange="checkemail(this.value);"/>
</div>
<label class="control-label col-sm-2" for="inputEmail">Last Name</label>
<div class="col-sm-4">
<input type="text" name="last_name" class="validate[required] form-control" placeholder="last Name" onChange="checkemail(this.value);"/>
</div>
</div>
<div class="form-group padd">
<label class="control-label col-sm-2">Email</label>
<div class="col-sm-4">
<input type="text" name="email" class="validate[required, custom[email]] form-control" placeholder="email" onChange="checkemail(this.value);"/>
</div>
<label class="control-label col-sm-2">Contact</label>
<div class="col-sm-4">
<input type="text" name="contact" class="validate[required,custom[integer]] form-control" placeholder="contact" onChange="checkemail(this.value);"/>
</div>
</div>
<div class="form-group padd">
<label class="control-label col-sm-2">Adress</label>
<div class="col-sm-4">
<input type="text" name="adress" class="validate[required] form-control" placeholder="adress" onChange="checkemail(this.value);"/>
</div>
<label class="control-label col-sm-2">City</label>
<div class="col-sm-4">
<input type="text" name="city" class="validate[required] form-control" placeholder="city" onChange="checkemail(this.value);"/>
</div>
</div>
<div class="form-group padd">
<label class="control-label col-sm-2">Disease</label>
<div class="col-sm-4">
<select name="diseas[]" id="diseas" class="form-control" multiple>
<?php echo displayDropDown($disease_list, '') ?>
</select>
</div>
<label class="control-label col-sm-2">Doctor</label>
<div class="col-sm-4">
<select name="doctor" id="doctor" class="form-control" >
</select>
</div>
</div>
<div class="col-sm-9 col-sm-offset-3">
<button type="submit" class="btn btn-danger">Register</button>
<!--<button type="reset" class="btn btn-default">Reset</button>-->
</div>
<br />
<input type="hidden" name="j" value="1">
</form>
<?php } else { ?>
<div class="well">YOU ARE SUCCESSFULLY REGISTERED</div>
<?php } ?>
</div>
</div>
</div>
</div>
</div>
<?php require_once("common/scripts.php"); ?>
<script src="https://cdnjs.cloudflare.com/ajax/libs/chosen/1.8.7/chosen.jquery.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/chosen/1.8.7/chosen.jquery.min.js"></script>
<script type="text/javascript">
function checkemail(emailval) {
$.post('admin/checkemail.php', {'emailid': emailval}, function (data) {
$('#logcheck').html(data);
});
}
$("#diseas").chosen();
$("body").on("change", "#diseas", function (e) {
// alert($(this).val());
$.ajax({
type: "POST",
url: '../common/service.php?j=4',
data: {diseas: $(this).val()}, // serializes the form's elements.
dataType: 'json',
success: function (data) {
$("#doctor").html("");
$('#doctor').append('<option value="0">Select Doctor</option>');
if (data.doctors) {
$.each(data.doctors, function (index, value) {
$('#doctor').append('<option value="' + value['id'] + '">' + value['name'] + '</option>');
});
} else {
$('#doctor').append('<option value="">No Doctor Found</option>');
}
}
});
});
</script>
</body>
</html>