-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstop_work.php
More file actions
48 lines (36 loc) · 1.34 KB
/
stop_work.php
File metadata and controls
48 lines (36 loc) · 1.34 KB
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
<?php
session_start();
include "functions.php";
$connection = mysqli_connect("localhost", "root", "", "workmanagement");
$current_user = $_SESSION['user'];
$current_timestamp = time();
$current_date = date('Y-m-d');
$ticket_id = $_GET['id'];
$job_id = $_GET['job_id'];
$active_ticket = GetActiveTicket($current_user);
$check_ticket = CheckUserTicket($current_user, $ticket_id);
if (empty($check_ticket)) {
die("Radni nalog nije na vama!");
header( "Refresh:1; url=tickets.php");
}
if ($active_ticket != NULL) {
$time_spent = 0;
$ticket_timestamp = GetTicketStartTime($ticket_id, $current_user);
if (!empty($ticket_timestamp) AND $ticket_timestamp != NULL) {
$time_spent = $current_timestamp - $ticket_timestamp;
}
if (!empty($time_spent)) {
$sql = "INSERT INTO task_hours(task_id,user_id,time_spent,date_created) VALUES (?,?,?,'$current_date')";
$statement = $connection->prepare($sql);
$statement->bind_param('iii', $ticket_id, $current_user, $time_spent);
$statement->execute();
$sql = "UPDATE users SET active_ticket_id = NULL,time_started = NULL WHERE id = '$current_user'";
$statement = $connection->prepare($sql);
$statement->execute();
}
header( "Refresh:1; url=tickets.php" );
} else {
echo "Greška!";
header( "Refresh:1; url=tickets.php" );
}
?>