-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathnew_project.php
More file actions
123 lines (115 loc) · 6.64 KB
/
new_project.php
File metadata and controls
123 lines (115 loc) · 6.64 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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
<?php if(!isset($conn)) { include 'db_connect.php'; } ?>
<div class="col-lg-12">
<div class="card card-outline card-primary">
<div class="card-body">
<form action="" id="manage-project">
<input type="hidden" name="id" value="<?php echo isset($id) ? htmlspecialchars($id) : '' ?>">
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label for="name" class="control-label">Name</label>
<input type="text" class="form-control form-control-sm" name="name" value="<?php echo isset($name) ? htmlspecialchars($name) : '' ?>">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="status">Status</label>
<select name="status" id="status" class="custom-select custom-select-sm">
<option value="0" <?php echo isset($status) && $status == 0 ? 'selected' : '' ?>>Pending</option>
<option value="3" <?php echo isset($status) && $status == 3 ? 'selected' : '' ?>>On-Hold</option>
<option value="5" <?php echo isset($status) && $status == 5 ? 'selected' : '' ?>>Done</option>
</select>
</div>
</div>
</div>
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label for="start_date" class="control-label">Start Date</label>
<input type="date" class="form-control form-control-sm" autocomplete="off" name="start_date" value="<?php echo isset($start_date) ? date("Y-m-d", strtotime($start_date)) : '' ?>">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="end_date" class="control-label">End Date</label>
<input type="date" class="form-control form-control-sm" autocomplete="off" name="end_date" value="<?php echo isset($end_date) ? date("Y-m-d", strtotime($end_date)) : '' ?>">
</div>
</div>
</div>
<div class="row">
<?php if($_SESSION['login_type'] == 1): ?>
<div class="col-md-6">
<div class="form-group">
<label for="manager_id" class="control-label">Project Manager</label>
<select class="form-control form-control-sm select2" name="manager_id">
<option></option>
<?php
$managers = $conn->query("SELECT *, CONCAT(firstname, ' ', lastname) as name FROM users WHERE type = 2 ORDER BY CONCAT(firstname, ' ', lastname) ASC");
while ($row = $managers->fetch_assoc()):
?>
<option value="<?php echo $row['id'] ?>" <?php echo isset($manager_id) && $manager_id == $row['id'] ? "selected" : '' ?>><?php echo ucwords(htmlspecialchars($row['name'])) ?></option>
<?php endwhile; ?>
</select>
</div>
</div>
<?php else: ?>
<input type="hidden" name="manager_id" value="<?php echo htmlspecialchars($_SESSION['login_id']) ?>">
<?php endif; ?>
<div class="col-md-6">
<div class="form-group">
<label for="user_ids" class="control-label">Project Team Members</label>
<select class="form-control form-control-sm select2" multiple="multiple" name="user_ids[]">
<option></option>
<?php
$employees = $conn->query("SELECT *, CONCAT(firstname, ' ', lastname) as name FROM users WHERE type = 3 ORDER BY CONCAT(firstname, ' ', lastname) ASC");
while ($row = $employees->fetch_assoc()):
?>
<option value="<?php echo $row['id'] ?>" <?php echo isset($user_ids) && in_array($row['id'], explode(',', $user_ids)) ? "selected" : '' ?>><?php echo ucwords(htmlspecialchars($row['name'])) ?></option>
<?php endwhile; ?>
</select>
</div>
</div>
</div>
<div class="row">
<div class="col-md-10">
<div class="form-group">
<label for="description" class="control-label">Description</label>
<textarea name="description" id="" cols="30" rows="10" class="summernote form-control">
<?php echo isset($description) ? htmlspecialchars($description) : '' ?>
</textarea>
</div>
</div>
</div>
</form>
</div>
<div class="card-footer border-top border-info">
<div class="d-flex w-100 justify-content-center align-items-center">
<button class="btn btn-flat bg-gradient-primary mx-2" form="manage-project">Save</button>
<button class="btn btn-flat bg-gradient-secondary mx-2" type="button" onclick="location.href='index.php?page=project_list'">Cancel</button>
</div>
</div>
</div>
</div>
<script>
$('#manage-project').submit(function(e) {
e.preventDefault();
start_load();
$.ajax({
url: 'ajax.php?action=save_project',
data: new FormData($(this)[0]),
cache: false,
contentType: false,
processData: false,
method: 'POST',
type: 'POST',
success: function(resp) {
if (resp == 1) {
alert_toast('Data successfully saved', 'success');
setTimeout(function() {
location.href = 'index.php?page=project_list';
}, 2000);
}
}
});
});
</script>