-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdateProject.php
More file actions
197 lines (156 loc) · 5.3 KB
/
updateProject.php
File metadata and controls
197 lines (156 loc) · 5.3 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
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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
<?php
date_default_timezone_set('America/Los_Angeles');
session_start();
include './Template.php';
include './DBConfig.php';
$mysql = new DBConfig();
$db = $mysql->getDBConfig();
if ((!empty($_POST) && !empty($_POST['radio'])) || !empty($_SESSION['pId']))
{
$head = '<link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
<script src="js/updateProject.js"></script>
';
$header = new Template("./header.php", array("current_page"=>2,"head" => $head, "title" => "Update Project"));
$header->out();
$id = $descErr = $edateErr ="";
//Get error messages if any
if( !empty($_SESSION['pId']))
{
$id = $_SESSION['pId'];
$_SESSION['pId'] ="";
}
if(!empty($_SESSION['uPDescErr']))
{
$descErr = $_SESSION['uPDescErr'];
$_SESSION['uPDescErr']="";
}
if (!empty($_SESSION['uPEDateError']))
{
$edateErr = $_SESSION['uPEDateError'];
$_SESSION['uPEDateError'] = "";
}
if (!empty($_SESSION['uPCostErr'])) {
$costErr = $_SESSION['uPCostErr'];
$_SESSION['uPCostErr'] = "";
}
?>
<div id="content-wrap">
<!-- content -->
<div id="content" class="clearfix">
<!-- main -->
<div id="main">
<div class="main-content">
<form action= "updateProjProc.php" method= "post">
<?php
if ($_POST['radio'])
$selectedProj = $_POST['radio'];
else
$selectedProj = $id;
$query="SELECT name, uid, status, priority, description, start_date, end_date, cost
FROM project WHERE uid like '$selectedProj'";
$result= $db->query($query);
$row= mysqli_fetch_row($result);
$name = $row[0];
$id = $row[1];
if (!empty($_SESSION['uPSts']))
{
$sts = $_SESSION['uPSts'];
$_SESSION['uPSts'] = "";
}
else
$sts = $row[2];
if (!empty($_SESSION['uPPrio']))
{
$prio = $_SESSION['uPPrio'];
$_SESSION['uPPrio'] = "";
}
else
$prio = $row[3];
if (!empty($_SESSION['uPDesc']))
{
$desc = $_SESSION['uPDesc'];
$_SESSION['uPDesc'] = "";
}
else
$desc = $row[4];
$sDate = $row[5];
if (!empty($_SESSION['uPEDate']))
{
$eDate = $_SESSION['uPEDate'];
$_SESSION['uPEDate'] = "";
}
else
$eDate = $row[6];
if (!empty($_SESSION['uPCost']))
{
$pCost = $_SESSION['uPCost'];
$_SESSION['uPCost'] = "";
}
else
$pCost = $row[7];
?>
<label>Project ID: <?php echo $id; ?></label>
<input type='hidden' value='<?php echo $id; ?>' name='projId'/>
<label>Project Name: <?php echo $name; ?></label>
<!-- Description -->
<label>Description</label>
<textarea rows='10' cols='50' name='descr' maxlength = "20000" required><?php echo $desc; ?></textarea>
<span class='err'><?php echo $descErr;$descErr =""; ?></span>
<!-- dates -->
<div>
<label for="exampleInputEmail1">Start Date</label>
<input class="form-control" name="startdate" value='<?php echo date("m/d/Y", strtotime($sDate)); ?>' readonly="true"></input>
</div>
<div>
<label for="exampleInputEmail1">End Date</label>
<input class="form-control" name="enddate" id="to" value='<?php echo date("m/d/Y", strtotime($eDate)); ?>' readonly="true"></input>
<span class="error"><?php echo $edateErr;?></span>
</div>
<!-- Status -->
<label for='exampleInputEmail1'>Status</label>
<select class='form-control' name='status' style='width: 165px'>
<option value='Open' <?php echo ($sts === "Open")?"selected":""; ?>>Open</option>
<option value='In Progress' <?php echo ($sts === "In Progress")?"selected":""; ?>>In Progress</option>
<option value='Completed' <?php echo ($sts === "Completed")?"selected":""; ?>>Completed</option>
<option value='Closed' <?php echo ($sts === "Closed")?"selected":""; ?>>Closed</option>
</select>
<!-- Priority -->
<label for='exampleInputEmail1'>Priority</label>
<select class='form-control' name='priority' style='width: 165px'>
<option value='High' <?php echo ($prio === "High")?"selected":""; ?>>High</option>
<option value='Mid' <?php echo ($prio === "Mid")?"selected":""; ?>>Mid</option>
<option value='Low' <?php echo ($prio === "Low")?"selected":""; ?>>Low</option>
</select>
<!-- Cost -->
<label >Project Budget</label>
<input type='text' class='form-control' name='cost' maxlength = "15"
value='<?php echo $pCost; ?>' placeholder='Enter project budget' required/>
<span class="error"><?php echo !empty($costErr) ? $costErr : ""; ?></span>
<br/>
<input type='submit' name='update' value= 'Update Project' class='btn btn-info1'>
<input type='submit' name='delete' value= 'Delete Project' class='btn btn-info2' onclick='return confirm("You are about to delete the project. Do you want to continue?");'>
<br/>
<a href="viewProjects.php"><input type="button" value="Cancel" class='btn btn-info'/></a>
</form>
<?php
}
else
{
header("Location:viewProjects.php");
exit;
}
?>
</div>
<!-- /main -->
</div>
<!-- sidebar -->
<? include './sidebar.php'; ?>
<!-- content -->
</div>
<!-- /content-out -->
</div>
<!-- extra -->
<?php
include './footer.php';
?>