forked from sarahdoi/Oun-project
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.php
167 lines (149 loc) · 7.05 KB
/
functions.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
<?php
//include("connection");
function check_loginParent($con){
if(isset($_SESSION['email']))
{
$em = $_SESSION['email'];
$query = "select * from parent where email = '$em' limit 1";
$result = mysqli_query( $con , $query);
if( $result && mysqli_num_rows($result) > 0)
{
$user_data = mysqli_fetch_assoc($result);
return $user_data;
}
}
//redirect to login
header("Location: login.php");
die;
}
function check_loginBabysitter($con){
if(isset($_SESSION['email']))
{
$nat_id = $_SESSION['email'];
$query = "select * from babysitter where email = '$nat_id' limit 1";
$result = mysqli_query( $con , $query);
if( $result && mysqli_num_rows($result) > 0)
{
$user_data = mysqli_fetch_assoc($result);
return $user_data;
}
}
//redirect to login
header("Location: login.php");
die;
}
function getRequests(){
global $con;
$query = "SELECT *
FROM request
INNER JOIN parent ON request.parent_id=parent.parent_id;";
return mysqli_query( $con , $query);
}
function getBookings(){
global $con;
$query = "SELECT bookings.booking_id, bookings.review , bookings.rating , request.* , offer.offer_id , offer.babysitter_id , offer.price , offer.status
FROM bookings
INNER JOIN request ON request.request_id = bookings.request_id
INNER JOIN offer ON request.request_id = offer.request_id";
return mysqli_query( $con , $query);
}
function getCurrentBookings(){
global $con;
$query = "SELECT bookings.booking_id, bookings.review , bookings.rating , request.* , offer.offer_id , offer.babysitter_id , offer.price , offer.status , parent.parent_id , babysitter.sitter_image , babysitter.name
FROM bookings
INNER JOIN request ON request.request_id = bookings.request_id && request.date >= (CAST(CURRENT_TIMESTAMP AS DATE))
INNER JOIN offer ON request.request_id = offer.request_id
INNER JOIN parent ON request.parent_id = parent.parent_id
INNER JOIN babysitter ON offer.babysitter_id = babysitter.national_ID ";
return mysqli_query( $con , $query);
}
/*function getcurrentBookings()
{
global $con;
$query = "SELECT bookings.booking_id, bookings.review , bookings.rating , request.* , offer.offer_id , offer.babysitter_id , offer.price , offer.status
FROM bookings
INNER JOIN request ON request.request_id = bookings.request_id && request.date >(CAST(CURRENT_TIMESTAMP AS DATE));
INNER JOIN offer ON request.request_id = offer.request_id";
return mysqli_query( $con , $query);
}
*/
function geprevtBookings(){ //use if there is prev in database
global $con;
$query = "SELECT bookings.booking_id, bookings.review , bookings.rating , request.* , offer.offer_id , offer.babysitter_id , offer.price , offer.status , babysitter.sitter_image , babysitter.name
FROM bookings
INNER JOIN request ON request.request_id = bookings.request_id && request.date < (CAST(CURRENT_TIMESTAMP AS DATE))
INNER JOIN offer ON request.request_id = offer.request_id
INNER JOIN babysitter ON offer.babysitter_id = babysitter.national_ID";
return mysqli_query( $con , $query);
}
function getCurrentoffers(){ //
global $con;
$query = "SELECT offer.*, babysitter.* , request.*
FROM offer
INNER JOIN babysitter ON babysitter.national_id = offer.babysitter_id
INNER JOIN request ON offer.request_id = request.request_id && request.date >= (CAST(CURRENT_TIMESTAMP AS DATE)) ";
return mysqli_query( $con , $query);
}
function getoffers(){
global $con;
$query = "SELECT offer.*, babysitter.* , request.*
FROM offer
INNER JOIN babysitter ON babysitter.national_id = offer.babysitter_id
INNER JOIN request ON offer.request_id = request.request_id;";
return mysqli_query( $con , $query);
}
function getPrevoffers(){ //
global $con;
$query = "SELECT offer.*, parent.* , request.*
FROM offer
INNER JOIN babysitter ON babysitter.national_id = offer.babysitter_id
INNER JOIN request ON offer.request_id = request.request_id && request.date < (CAST(CURRENT_TIMESTAMP AS DATE))
INNER JOIN parent ON offer.request_id = request.request_id && request.date < (CAST(CURRENT_TIMESTAMP AS DATE)) ;";
return mysqli_query( $con , $query);
}
function getPrevBookingsforID($id){
global $con;
$query = "SELECT bookings.booking_id, bookings.review , bookings.rating , request.* , offer.offer_id , offer.babysitter_id , offer.price , offer.status , parent.parent_id , parent.parent_image , babysitter.sitter_image , babysitter.name
FROM bookings
INNER JOIN request ON request.request_id = bookings.request_id && request.date < (CAST(CURRENT_TIMESTAMP AS DATE))
INNER JOIN offer ON request.request_id = offer.request_id
INNER JOIN parent ON request.parent_id = parent.parent_id
INNER JOIN babysitter ON offer.babysitter_id = babysitter.national_ID WHERE babysitter.national_ID=$id ";
return mysqli_query( $con , $query);
}
function getPrevBookingsforID2($id){
global $con;
$query = "SELECT bookings.booking_id, bookings.review , bookings.rating , request.* , offer.offer_id , offer.babysitter_id , offer.price , offer.status , parent.parent_id , parent.parent_image , babysitter.sitter_image , parent.name
FROM bookings
INNER JOIN request ON request.request_id = bookings.request_id && request.date < (CAST(CURRENT_TIMESTAMP AS DATE))
INNER JOIN offer ON request.request_id = offer.request_id
INNER JOIN parent ON request.parent_id = parent.parent_id
INNER JOIN babysitter ON offer.babysitter_id = babysitter.national_ID WHERE babysitter.national_ID=$id ";
return mysqli_query( $con , $query);
}
///////////////////// delete these 2 at the end if not used,, they didnt work well with me!
function createConfirmationmbox() {
echo '<script type="text/javascript"> ';
echo ' function openulr(newurl) {';
echo ' if (confirm("Are you sure you want to Delete?")) {';
echo ' document.location = newurl;';
echo ' }';
echo '}';
echo '</script>';
}
function myFunction() {
echo "<script>";
echo "return confirm('Are you sure?');";
echo "</script>";
}
/*function conflict( $s , $e , $id2 , $d){
global $con;
$query = "SELECT bookings.booking_id, bookings.review , bookings.rating , request.* , offer.offer_id , offer.babysitter_id , offer.price , offer.status , parent.parent_id , parent.parent_image , babysitter.sitter_image , babysitter.name
FROM bookings
INNER JOIN request ON request.request_id = bookings.request_id AND request.date < (CAST(CURRENT_TIMESTAMP AS DATE)) AND ($s < request.start_time or $s > request.end_time) AND ($e < request.start_time or $e> request.end_time) AND request.date=$d
INNER JOIN offer ON request.request_id = offer.request_id
INNER JOIN parent ON request.parent_id = parent.parent_id
INNER JOIN babysitter ON offer.babysitter_id = babysitter.national_ID WHERE babysitter.national_ID=$id2 ";
return mysqli_query( $con , $query);
}*/
?>