-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoperation.php
More file actions
102 lines (80 loc) · 3.77 KB
/
operation.php
File metadata and controls
102 lines (80 loc) · 3.77 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
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
<?php
include_once 'core/core.inc.php';
if (isset($_POST['draft_id'])) {
if (isset($_POST['forword_to'])) {
// $_POST['draft_id'] = 'OERG60476';
// $_POST['forword_to'] = 2;
// $_POST['forword_msg'] = 'pass';
include_once 'core/application.db.php';
include_once 'core/user.db.php';
$a = new Application($host, $db_name, $db_user, $db_pass);
$u = new User($host, $db_name, $db_user, $db_pass);
$fwd_to = $_POST['forword_to'];
$fwd_msg = $_POST['forword_msg'];
$application_details = $a->fetch_by_id('draft_id', $_POST['draft_id'])[0];
$fwd_details = $u->getName($fwd_to)[0];
if ($application_details['forwarded'] != 0) {
$cu_name = $u->getName($application_details['forwarded'])[0];
}else{
$cu_name = $u->getName($application_details['receiver'])[0];
}
$log = $application_details['log'].'<br>'.$cu_name['name']." (".$cu_name['department'].") : Forwarded to ".$fwd_details['name']." with message - ".$fwd_msg;
$a->update("forwarded", $fwd_to, $_POST['draft_id']);
$a->update("log", $log, $_POST['draft_id']);
$a->update("status", "Processing Under ".$fwd_details['name']."(".$fwd_details['department'].")", $_POST['draft_id']);
echo "true";
}elseif (isset($_POST['vichel_no'])) {
// $_POST['draft_id'] = 'OERG60476';
// $_POST['vichel_no'] = 'JH05AC1234';
if (empty($_POST['vichel_no'])) {
die("empty");
}
include_once 'core/application.db.php';
include_once 'core/user.db.php';
include_once 'core/vehicle.db.php';
$a = new Application($host, $db_name, $db_user, $db_pass);
$u = new User($host, $db_name, $db_user, $db_pass);
$v = new Vehicle($host, $db_name, $db_user, $db_pass);
$application_details = $a->fetch_by_id('draft_id', $_POST['draft_id'])[0];
$name = $u->getName($_SESSION['user_id'])[0];
$log = $application_details['log'].'<br>'.$name['name']." (".$name['department'].") : Approved your request.";
$a->update("status", "Approved by ".$name['name']." (".$name['department'].")", $_POST['draft_id']);
$a->update("log", $log, $_POST['draft_id']);
$a->update("issued_by", $_SESSION['user_id'], $_POST['draft_id']);
$a->update("vehicle_issue", $_POST['vichel_no'], $_POST['draft_id']);
$v->update("app_id", $_POST['draft_id'], $_POST['vichel_no']);
$v->update("status", "Last issue to ".$name['name'], $_POST['vichel_no']);
echo "true";
}elseif (isset($_POST['reject_msg'])) {
// $_POST['draft_id'] = 'OERG60476';
// $_POST['reject_msg'] = 'JH05AC1234';
include_once 'core/application.db.php';
include_once 'core/user.db.php';
$a = new Application($host, $db_name, $db_user, $db_pass);
$u = new User($host, $db_name, $db_user, $db_pass);
$application_details = $a->fetch_by_id('draft_id', $_POST['draft_id'])[0];
$rejector = $u->getName($_SESSION['user_id'])[0];
$log = $application_details['log'].'<br>'.$rejector['name']." (".$rejector['department'].") : Rejected with message - ".$_POST['reject_msg'];
$a->update("log", $log, $_POST['draft_id']);
$a->update("status", "Rejected by ".$rejector['name']."(".$rejector['department'].")", $_POST['draft_id']);
echo "true";
}elseif (isset($_POST['delete'])) {
// $_POST['draft_id'] = 'OERG60476';
// $_POST['delete'] = '-';
include_once 'core/application.db.php';
$a = new Application($host, $db_name, $db_user, $db_pass);
$a->delete($_POST['draft_id']);
echo "true";
}
}elseif (isset($_POST['user_id'])) {
if (!empty($_POST['user_id']) && $_POST['user_id'] != $_SESSION['user_id']) {
if (isset($_POST['auth_level'])) {
if ($_POST['auth_level'] < $_SESSION['auth_level']) {
include_once 'core/user.db.php';
$u = new User($host, $db_name, $db_user, $db_pass);
$u->update('auth_level', $_POST['auth_level'], $_POST['user_id']);
echo "true";
}
}
}
}