This is my code for updating approved,pending and completed. How do i add time for pending,approved and completed? Approved on 19/05/2020, rejected on 19/05/2020 and so?
<?php
mysqli_report(MYSQLI_REPORT_ERROR|MYSQLI_REPORT_STRICT);
$conn = mysqli_connect("localhost","root", "","registration");
//
// PROCESS POSTED DATA
//
if ($_SERVER['REQUEST_METHOD']=='POST') {
$stmt = $conn->prepare("UPDATE proposals
SET
department = ?,
status = ?
WHERE id = ?
");
$stmt->bind_param('ssi', $_POST['department'], $_POST['status'], $_POST['id']);
($stmt->execute());
}
if (!isset($_GET['id']) || trim($_GET['id'])=='') {
header("Location: ");
exit;
}
$res = $conn->prepare("SELECT id
, details
, location
, date
, time
, checkbox
, injured
, agegender
, contact
, empid
, dept
, organization
, summary
, image
, outcome
, cause
, action
, reportedname
, position
, organisation
, reportedcontact
, reporteddept
, status
, department
FROM proposals
WHERE id = ?
");
$res->bind_param('i', $_GET['id']);
$res->execute();
$res->bind_result($id,$details,$location,$date,$time,$checkbox,$injured,$agegender,$contact,$empid,$dept,$organization,$summary,$image,$outcome,$cause,$action,$reportedname,$position,$organisation,$reportedcontact,$reporteddept,$status,$department);
$res->fetch();
$res->close();
//
// status-dependent processing
//
$buttons = "<div class='data'>
<button name='status' style='background-color:deepskyblue; border-radius:10px; cursor:pointer; font-size:20px;' value='$status'>Update</button>
</div>";
switch ($status) {
case 'approved':
$cls1 = '"';
$buttons = "<div class='data'>
<button name='status' style='background-color:deepskyblue; border-radius:10px; cursor:pointer; font-size:20px;' value='completed'>Complete</button>
</div>";
break;
case 'completed':
$buttons = "<div class='data'>
<button name='status' style='background-color:deepskyblue; border-radius:10px; cursor:pointer; font-size:20px; display:none;' value='completed'>Completed</button>
</div>";
case 'rejected':
$cls1 = 'class="w3-pale-green data"';
$buttons = "<div class='data'>
<button name='status' style='background-color:deepskyblue; border-radius:10px; cursor:pointer; font-size:20px;' value='$status' disabled>Update</button>
</div>";
case 'pending':
$cls1 = 'class="w3-dark-gray data"';
}
?>
<html lang = "en">
<head>
<title>Proposals</title>
<meta charset = "UTF-8" />
</head>
<body><button onclick="myFunction()">Print</button>
<script>
function myFunction() {
window.print();
}
</script>
<h1>Proposal Form No : <?php echo $id ?></h1>
<form method='POST' id='formId'>
<input type='hidden' name='id' value='<?=$id?>'>
<fieldset>
<legend>NearMiss Proposal</legend>
<p>
<b style="font-size:17px; color:black; position: absolute; top:130px;">Details of incident :</b>
<textarea style="position:relative;" disabled id = "myTextArea"
rows = "5"
cols = "110"><?php echo $details ?></textarea></p><br>
<fieldset style="height:55px; width:848px; border:1px solid #888;">
<p>
<b style="font-size:17px; color:black; position: relative; bottom:-5px;">Location :</b>
<textarea style="position:absolute; left:115px;" disabled id = "myTextArea"
rows="2" cols="56"><?php echo $location ?></textarea>
</p>
<br>
<p>
<b style="font-size:17px; color:black; position:relative; left:545px; bottom:80px;" >Date :</b><textarea style="position:relative; left:555px; bottom:70px;" disabled id = "myTextArea"
rows="2" cols="10"><?php echo $date ?></textarea>
</p>
<p>
<b style="font-size:17px; color:black; position:relative; left:708px; bottom:135px;" >Time :</b><textarea style="position:relative; left:715px; bottom:125px;" disabled id = "myTextArea"
rows="2" cols="10"><?php echo $time ?></textarea>
</p>
</fieldset>
<p><b>Classification(Tick the appropriate one, Leave blank if you find it difficulty) :</b><br>
<label style="font-size:16px;color:black;">Selected Classification :</label>
<textarea style="position:relative; bottom:-3px;" disabled id = "myTextArea"
rows="1" cols="47"><?php echo $checkbox ?></textarea>
</p>
<p>
<b style="font-size:17px;color:black;">Details of Injured(IP)(if any) :NA</b><br>
<b>Name:</b>
<textarea style="position:relative; bottom:-5px;" disabled name="name" cols="25" rows="1" class="form-control"> <?php echo $injured ?></textarea>
</p>
<p style="position:relative; left:280px; bottom:35px;">
<b style="position:relative; bottom:4px;">Age/Gender :</b>
<textarea disabled name="agegender" cols="3" rows="1"><?php echo $agegender ?></textarea>
</p>
<p style="position:relative; left:435px; bottom:75px;">
<b style="position:relative; bottom:4px;">Contact :</b>
<textarea disabled name="agegender" cols="9" rows="1"><?php echo $contact ?></textarea>
</p>
<p style="position:relative; left:600px; bottom:115px;">
<b style="position:relative; bottom:4px;">Organization :</b>
<textarea disabled name="agegender" cols="9" rows="1"><?php echo $organization ?></textarea>
</p>
<p style="position:relative; left:0px; bottom:125px;">
<b style="position:relative; bottom:4px;">Department :</b>
<textarea disabled name="agegender" cols="9" rows="1"><?php echo $dept ?></textarea>
</p>
<p style="position:relative; left:226px; bottom:165px;">
<b style="position:relative; bottom:4px;">Employee ID :</b>
<textarea disabled name="agegender" cols="9" rows="1"><?php echo $empid ?></textarea>
</p><br>
<p>
<b style="color:black; position: relative; bottom:204px;">Summary of Incident(Attach Photographs, if any, as Annexure1) :</b>
<textarea style="position:absolute; left:25px; top:525px;" disabled id = "myTextArea"
rows="8" cols="110"><?php echo $summary ?></textarea>
</p>
<div class="form-group">
<label style="position:absolute; left:82%; top:505px;">Uploaded Images Here :</label><b style="position:relative; left:88%; bottom:198px;"><?php echo "<a href='uploads/" . $image . "'><img src='uploads/" . $image . "'height='105' width='120'></a>" ?> </b>
</div>
<p>
<b style="color:black; position: relative; bottom:186px;">Potential outcome(Incase of Near Miss Case or Potential incident only) :</b>
<textarea style="position:absolute; left:27px; top:700px;" disabled id = "myTextArea"
rows="8" cols="110"><?php echo $outcome ?></textarea>
</p>
<p>
<b style="color:black; position: relative; bottom:146px;">Likely cause(s) :</b>
<textarea style="position:relative; right:112px; top:-10px;" disabled id = "myTextArea"
rows="8" cols="110"><?php echo $cause ?></textarea>
</p><br>
<p>
<b style="position: absolute; top:1032px;">Immediate action(s) taken :</b>
<textarea style=" float:left; position:relative; bottom:14px;" disabled id = "myTextArea"
rows="8" cols="110"><?php echo $action ?></textarea></p>
<br><br><br><br><br><br><br>
<p style="float:left;">
<b style="font-size:17px;color:black;">Incident reported by :</b><br><br>
<b>Name:</b>
<input type="text" disabled value="<?php echo $reportedname ?>">
<b>Position:</b>
<input type="text" disabled value="<?php echo $position ?>">
<b>Organisation:</b>
<input type="text" disabled value="<?php echo $organisation ?>"><br><br>
<b>Reporter contact no:</b>
<input type="text" disabled value="<?php echo $reportedcontact ?>">
<b>Reporter department:</b>
<input type="text" disabled name="name" value= "<?php echo $reporteddept ?>">
</p>
<fieldset style="position:relative; top:30px; width:848px; ">
<p>
<b style="font-size:18px; color:darkblue;">Status of the Proposal : <?=$status?></b>
</p>
<p>
<b style="font-size:18px;">Select Department :</b>
<input type='hidden' name='department'>
<tr>
<td><select name='department'>
<option value='' selected>------SELECT DEPARTMENT------</option>
<option value='Civil'>Civil</option>
<option value='O&M'>O&M</option>
<option value='C&M'>C&M</option>
<option value='MMD'>MMD</option>
<option value='Logistics'>Logistics</option>
<option value='HR&ADMIN'>HR&ADMIN</option>
<option value='Fire & Safety'>Fire & Safety</option>
<option value='IT & MIS'>IT & MIS</option>
<option value='F&M'>F&M</option>
<option value='EMD'>EMD</option>
<option value='C&I'>C&I</option>
<option value='Store'>Store</option>
<option value='EHS'>EHS</option>
<option value='Tech Cell'>Tech Cell</option>
<option value='Operation'>Operation</option>
</select></td>
</tr>
</p>
<div>
<b style="font-size:18px;">Selected Department : <input type="text" disabled value="<?=$department?>"></b>
</div>
</fieldset>
<br><br><br>
</fieldset><br>
<div style="display: flex; justify-content: center;">
<?=$buttons?>
</div>
</form> </body></html>
<br>
<label style="background-color:deepskyblue; border-radius: 5px; font-size:32px;">Uploaded Files after Completion</label>
<fieldset style="background-color:aliceblue;">
<br>
<!--<div>
<form action="upload.php" method="post" enctype="multipart/form-data">
<input type="hidden" name="id" value="<?php echo $row->id?>">
<div>
<label><b>Upload Image Here :</b></label><br><br>
<div>
<input type="file" name="name" enctype="multipart/form-data" id="incident_reference" onchange="document.getElementById('inc_ref').src = window.URL.createObjectURL(this.files[0]); document.getElementById('inc_ref').className +='_active'; document.getElementById('inc_ref_span').className += '_hidden'">
</div><iframe id="inc_ref" width="220px" height="130px"></iframe><br><br>
<b>Details :</b><br>
<div>
<textarea rows="6" cols="110" style="border-radius:12px;" name="details" placeholder="Details"></textarea>
</div>
</div>
<input type="submit" name="submit" style="background-color:deepskyblue; cursor:pointer; border-radius: 8px; font-size:19px;" value="Submit"></form>
</div>-->
<?php
mysqli_report(MYSQLI_REPORT_ERROR|MYSQLI_REPORT_STRICT);
$conn = mysqli_connect("localhost","root", "","registration");
$res = $conn->prepare("SELECT id
,image, details
FROM upload
WHERE id = ?
");
$res->bind_param('i', $_GET['id']);
$res->execute();
$res->bind_result($id,$image,$details);
while ($res->fetch()) {
echo"<a href='completedupload/" . $image . "'><img src='completedupload/" . $image . "'height='105' width='120'></a><br><br>";
echo '<b style="font-size:18px;">Details :'.$details.'</b><br>';
}
?>
</fieldset><br>
<fieldset style="background-color:aliceblue;">
<label style="background-color:deepskyblue; border-radius: 5px; font-size:22px;">Comment Section</label><br><br>
<div>
<form action="ehscomment.php" method="post">
<input type="hidden" name="id" value="<?php echo $id ?>">
<div>
<b>Name :</b>
<input type="text" name="cname" style="border-radius:5px;"><br><br>
<b>Leave a Comment :</b>
<div>
<textarea rows="6" cols="110" style="border-radius:12px;" name="comment" placeholder="comment"></textarea>
</div>
</div>
<input type="submit" name="postcomment" style="background-color:deepskyblue; cursor:pointer; border-radius: 8px; font-size:19px;" value="comment"></form>
</div>
<?php
mysqli_report(MYSQLI_REPORT_ERROR|MYSQLI_REPORT_STRICT);
$conn = mysqli_connect("localhost","root", "","registration");
if (!isset($_GET['id']) || trim($_GET['id'])=='') {
header("Location: ");
exit;
}
$res = $conn->prepare("SELECT id
,cname, comment,date
FROM comments
WHERE id = ?
");
$res->bind_param('i', $_GET['id']);
$res->execute();
$res->bind_result($id,$cname,$comment,$date);
while ($res->fetch()) {
echo'<b style="color:darkmagenta">'.$cname.' : </b>';
echo ''.$comment.'<br>';
echo'<b style="color:gray">'.$date.'</b><br><br>';
}
?>
</fieldset>