Skip to content

Instantly share code, notes, and snippets.

@marthatodi
Created October 11, 2017 16:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marthatodi/89cc8625508e5e39d7963fec419f6c2c to your computer and use it in GitHub Desktop.
Save marthatodi/89cc8625508e5e39d7963fec419f6c2c to your computer and use it in GitHub Desktop.
<html>
<head>
<?php
include_once "page_parts/head.php";
?>
</head>
<body class="container">
<?php
include_once "page_parts/header.php";
?>
<?php
include_once "page_parts/login_checker.php";
?>
<div class="page_content">
<form action="search_clients.php" method="post" enctype="multipart/form-data">
<div class="form-group">
<label for="keyword">Αναζήτηση Ασθενών:</label>
<input required="required" type="text" class="form-control" id="keyword" name="keyword"
placeholder="Αμκα ασθενή, λέξεις κλειδία χωρισμένα με κενό">
</div>
<center>
<button type="submit" name="search" class="btn btn-primary">Αναζήτηση</button>
</center>
</form>
<form action="search_clients.php" method="post" enctype="multipart/form-data">
<center>
<button type="submit" name="view_all" class="btn btn-primary">Εμφάνιση των Ασθενών</button>
</center>
</form>
<br>
<br>
<table class="table">
<?php
if ($_SERVER['REQUEST_METHOD'] == "POST" && isset($_POST['apply'])) {
echo"<br> id:".$_SESSION['user_id'];
$selected_thesis = mysqli_real_escape_string($link, $_POST['selected-thesis']);
//showAlertDialogMethod("selected thesis id" . $selected_thesis);
insert_thesis_apply_for_student($link, $selected_thesis, $_SESSION['user_id']);
change_thesis_state($link, $selected_thesis, 2);
}
if ($_SERVER['REQUEST_METHOD'] == "POST" && isset($_POST['new_examine'])) {
$id_doctor= $_SESSION['user_id'];
$amka= $_POST['amka'];
$id_c= $_POST['id_c'];
echo '<form action="search_clients.php" method="post" enctype="multipart/form-data">';
echo '<input type="hidden" id="id_c" name="id_c" value="'.$id_c.'">';
echo '<input type="hidden" id="amka" name="amka" value="'.$amka.'">';
?>
<div class="page_content">
<form action="search_clients.php" method="post" enctype="multipart/form-data">
<div class="form-group">
<label for="cname"> Τύπος Εξέτασης*:</label>
<input required="required" type="text" class="form-control" id="type" name="type" placeholder="Τύπος">
</div>
<div class="form-group">
<label for="csurname">Όνομα Εξέτασης*:</label>
<input required="required" type="text" class="form-control" id="name_exam" name="name_exam"
placeholder="Όνομα Εξέτασης">
</div>
<div class="form-group">
<label for="amka">Αποτέλεσμα*:</label>
<input required="required" type="text" class="form-control" id="result" name="result"
placeholder="Αποτέλεσμα">
</div>
<div class="form-group">
<label for="mail">Ημ/νία*:</label>
<input required="required" type="text" class="form-control" id="date" name="date"
placeholder="Ημ/νία">
</div>
<div class="form-group">
<label for="history">Σχόλια:</label>
<input required="required" type="text" class="form-control" id="comments" name="comments"
placeholder="Σχόλια">
</div>
<button type="submit" name="add_exam" id="add_exam" class="btn btn-primary">Προσθήκη Εξέτασης</button>
</form>
</div>
<?php
echo '</form>';
}
if ($_SERVER['REQUEST_METHOD'] == "POST" && isset($_POST['add_exam'])) {
$id_doctor= $_SESSION['user_id'];
$amka= $_POST['amka'];
$id_c= $_POST['id_c'];
$type = $_POST['type'];
$result =$_POST['result'];
$name_exam = $_POST['name_exam'];
$comments = $_POST['comments'];
$date = $_POST['date'];
if (empty($type) || empty($result) || empty($name_exam) || empty($comments) || empty($date) ) {
showAlertDialogMethod("Συμπληρωστε τα πεδία");
exit();
}
add_exams($link, $id_c, $id_doctor, $amka, $type, $name_exam, $result, $date , $comments);
}
if ($_SERVER['REQUEST_METHOD'] == "POST" && isset($_POST['upload'])) {
echo"<br> id:".$_SESSION['user_id'];
$selected_thesis = mysqli_real_escape_string($link, $_POST['selected-thesis']);
//showAlertDialogMethod("selected thesis id" . $selected_thesis);
insert_thesis_apply_for_student($link, $selected_thesis, $_SESSION['user_id']);
change_thesis_state($link, $selected_thesis, 2);
// TODO Teacher id
$selected_teacher_id = mysqli_real_escape_string($link, $_POST['selected-teacher-id']);
showAlertDialogMethod($selected_teacher_id);
// TODO send mail to teacher
$image = addslashes(file_get_contents($_FILES['image']['tmp_name'])); //SQL Injection defence!
$image_name = addslashes($_FILES['image']['name']);
$mime = mysqli_real_escape_string($link, $_FILES['image']['type']);
echo "<br> name:" . $image_name;
$target_dir = "C:/Users/User/Desktop/";
$target_file = $target_dir . basename($_FILES["image"]["name"]);
$uploadOk = 1;
$imageFileType = pathinfo($target_file, PATHINFO_EXTENSION);
// Check if file already exists
if (file_exists($target_file)) {
echo "Sorry, file already exists.";
$uploadOk = 0;
}
// Check if $uploadOk is set to 0 by an error
if ($uploadOk == 0) {
echo "Sorry, your file was not uploaded.";
// if everything is ok, try to upload file
} else {
if (move_uploaded_file($_FILES["image"]["tmp_name"], $target_file)) {
echo "The file " . basename($_FILES["image"]["name"]) . " has been uploaded.";
} else {
echo "Sorry, there was an error uploading your file.";
}
move_uploaded_file($_FILES['image']['tmp_name'], $target_dir. $_FILES['image']['name']);
$image_f = $target_dir. $_FILES['image']['name'];
echo"<br>path file : ".$image_f ;
$thesis= $_POST['selected-thesis'];
echo'<br>iddd'.$thesis;
$s="SELECT * FROM thesis WHERE id=$thesis" ;
$result1=$link->query($s);
if(mysqli_query($link,$s)) {
while ($row1 = $result1->fetch_assoc()) {
$id_t = $row1['teacher_id'];
}
}
echo"<br>nah".$id_t;
$s="SELECT * FROM user WHERE id=$id_t" ;
$result1=$link->query($s);
if(mysqli_query($link,$s)) {
while ($row1 = $result1->fetch_assoc()) {
$email = $row1['email'];
}
}
$address= $email;
$path=$image_f;
// $address= (get_user_by_id($link,$selected_teacher_id))->email;
// $path=$image_f;
$message="uparxei aithsh egdhlwshs endiaferontos gia diplwmatikh apo foithth mpeite sto susthma me tis diplwmatikes";
send_mail_to_user($address,$message,$path);
}
}
if ($_SERVER['REQUEST_METHOD'] == "POST" && isset($_POST['view_all'])) {
$all_clients = get_client($link);
if ($all_clients == null) {
echo '<h5>Δεν βρέθηκαν αποτελέσματα</h5>';
} else {
echo ' <tr>';
echo '<td><h4>Id Ασθενούς</h4></td>';
echo '<td><h4>Όνομα</h4></td>';
echo '<td><h4>Επώνυμο</h4></td>';
echo '<td><h4>ΑΜΚΑ</h4></td>';
echo '<td><h4>E-mail</h4></td>';
echo '<td><h4>Ιστορικό</h4></td>';
echo '</tr>';
while ($row = $all_clients->fetch_assoc()) {
echo '<tr>';
echo '<td>';
echo '<h5 id="align_start" style="">' . $row['id_c'] . '</h5>';
echo '</td>';
echo '<td>';
echo '<h5 id="align_start" style="">' . $row['cname'] . '</h5>';
echo '</td>';
echo '<td>';
echo '<h5 id="align_start" style="">' . $row['csurname'] . '</h5>';
echo '</td>';
echo '<td>';
echo '<h5 id="align_start" style="">' . $row['amka'] . '</h5>';
echo '</td>';
echo '<td>';
echo '<h5 id="align_start" style="">' . $row['mail'] . '</h5>';
echo '</td>';
echo '<td>';
echo '<h5 id="align_start" style="">' . $row['history'] . '</h5>';
echo '</td>';
echo '<td>';
echo '<form action="search_clients.php" method="post" enctype="multipart/form-data">';
// echo ' <input type="hidden" id="selected-thesis" name="selected-thesis" value="' . $row['id'] . '">';
// echo ' <input type="hidden" id="selected-teacher-id" name="selected-teacher-id" value="' . $row['teacher_id'] . '">';
echo '<input type="hidden" name="size" value="1000000" />';
echo ' <input type="file" name="image" />';
echo '<button type="submit" name="examine" class="btn btn-primary">Εξετάσεις Ασθενούς</button>';
echo '<form action="search_clients.php" method="post" enctype="multipart/form-data">';
echo '<input type="hidden" id="id_c" name="id_c" value="' . $row['id_c'] . '">';
echo '<input type="hidden" id="amka" name="amka" value="' . $row['amka'] . '">';
echo '<button type="submit" name="new_examine" class="btn btn-primary" >Νέα Εξέταση</button>';
echo '</form>';
echo '</td>';
echo '</tr>';
}
}
}
if ($_SERVER['REQUEST_METHOD'] == "POST" && isset($_POST['search'])) {
$keyword = mysqli_real_escape_string($link, $_POST['keyword']);
$all_clients = get_patient_with_keywords($link, $keyword);
if ($all_clients == null) {
echo '<h5>Δεν βρέθηκαν αποτελέσματα</h5>';
} else {
echo ' <tr>';
echo '<td><h4>Όνομα</h4></td>';
echo '<td><h4>Επώνυμο</h4></td>';
echo '<td><h4>ΑΜΚΑ</h4></td>';
echo '<td><h4>E-mail</h4></td>';
echo '<td><h4>Ιστορικό</h4></td>';
echo '</tr>';
while ($row = $all_clients->fetch_assoc()) {
echo '<tr>';
echo '<td>';
echo '<h5 id="align_start" style="">' . $row['cname'] . '</h5>';
echo '</td>';
echo '<td>';
echo '<h5 id="align_start" style="">' . $row['csurname'] . '</h5>';
echo '</td>';
echo '<td>';
echo '<h5 id="align_start" style="">' . $row['amka'] . '</h5>';
echo '</td>';
echo '<td>';
echo '<h5 id="align_start" style="">' . $row['mail'] . '</h5>';
echo '</td>';
echo '<td>';
echo '<h5 id="align_start" style="">' . $row['history'] . '</h5>';
echo '</td>';
echo '<td>';
echo '<form action="search_clients.php" method="post" enctype="multipart/form-data">';
// echo ' <input type="hidden" id="selected-thesis" name="selected-thesis" value="' . $row['id'] . '">';
// echo ' <input type="hidden" id="selected-teacher-id" name="selected-teacher-id" value="' . $row['teacher_id'] . '">';
echo '<input type="hidden" name="size" value="1000000" />';
echo ' <input type="file" name="image" />';
echo '<button type="submit" name="examine" class="btn btn-primary">Εξετάσεις Ασθενούς</button>';
echo '<button type="submit" value="' . $row['amka'] . '" name="new_examine" class="btn btn-primary">Νέα Εξέταση</button>';
echo '</form>';
echo '</td>';
echo '</tr>';
}
}
}
?>
</table>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment