Skip to content

Commit

Permalink
Merge pull request djroxx2000#20 from djroxx2000/hritik
Browse files Browse the repository at this point in the history
added : update case functionality to admin panel
  • Loading branch information
hrithikkothari1234 authored Jan 14, 2020
2 parents de035cc + 73453f6 commit 782a4e7
Show file tree
Hide file tree
Showing 4 changed files with 128 additions and 4 deletions.
6 changes: 3 additions & 3 deletions admin/currentcases.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@
if ($con) {
$x=1;
$stmt = $con->prepare("
SELECT case_type, case_details, next_hearing_date, prev_hearing_date, court_name
SELECT case_id, case_type, case_details, next_hearing_date, prev_hearing_date, court_name
FROM cases WHERE case_status = ?");
$status = "pending";
$stmt->bind_param('s', $status);
$stmt->execute();
$stmt->store_result();
$stmt->bind_result($case_type,
$stmt->bind_result($case_id, $case_type,
$case_details, $next_hearing_date,
$prev_hearing_date, $court_name);

Expand All @@ -73,7 +73,7 @@
<td> {$next_hearing_date} </td>
<td> Pending </td>
<td> {$court_name} </td>
<td><button class='btn btn-info'> Update </button> </td>
<td><a class='btn btn-info' href='admin_dashboard.php?q=updatecase&id={$case_id}'> Update </button> </td>
</tr>
";
$x++;
Expand Down
122 changes: 122 additions & 0 deletions admin/updatecase.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
<div class="container-fluid">
<div class="row">
<div class="col-sm-2">
<h1>
<?php echo $_SESSION["admin_name"]; ?>
</h1>
<br>
<ul id="side_menu" class="nav nav-pills nav-stacked">
<li class="">
<a href="admin_dashboard.php">
<span class="glyphicon glyphicon-list-alt"></span>
&nbsp; Current Cases
</a>
</li>
<li class="">
<a href="admin_dashboard.php?q=finishedcases">
<span class="glyphicon glyphicon-ok"></span>
&nbsp; Finished Cases
</a>
</li>
<li class="">
<a href="admin_dashboard.php?q=managelawyers">
<span class="glyphicon glyphicon-user"></span>
&nbsp; Manage Lawyers
</a>
</li>
<li class="">
<a href="admin_dashboard.php?q=feedbacks">
<span class="glyphicon glyphicon-comment"></span>
&nbsp; Feedbacks
</a>
</li>
</ul>
</div> <!--div ending of vertical nav -->

<?php if(isset($_GET['id'])){ ?>
<?php
require_once("includes/db.php");
$con;
if ($con) {
$stmt = $con->prepare("
SELECT case_type, case_details, next_hearing_date, prev_hearing_date,
case_status, court_name
FROM cases WHERE case_id=?");
$stmt->bind_param('i', $_GET['id']);
$stmt->execute();
$stmt->store_result();
$stmt->bind_result($case_type, $case_details, $next_hearing_date,
$prev_hearing_date, $case_status, $court_name);
while ($stmt->fetch()) {
$c_type = $case_type;
$c_details = $case_details;
$next_hearing = $next_hearing_date;
$prev_hearing = $prev_hearing_date;
$c_status = $case_status;
$c_name = $court_name;
}
}
?>
<div class="col-sm-10">
<h1>Update Case</h1>
<form action="admin_dashboard.php?q=updatecase&id=<?php echo $_GET['id']; ?>" method="post">
<fieldset>
<div class="form-group">

<label for="case-type"> Case Type: </label>
<input class="form-control" type="text" name="case-type"
value="<?php echo $c_type; ?>" placeholder="case-type" required><br>

<label for="case-details"> Case details: </label>
<input class="form-control" type="text" name="case-details"
value="<?php echo $c_details; ?>" placeholder="case-details" required><br>

<label for="next-hearing-date"> Next hearing date(Format: dd-mm-yyyy): </label>
<input class="form-control" type="text" name="next-hearing-date"
value="<?php echo $next_hearing; ?>" placeholder="next-hearing-date"><br>

<label for="prev-hearing-date"> Prev hearing date(Format: dd-mm-yyyy): </label>
<input class="form-control" type="text" name="prev-hearing-date"
value="<?php echo $prev_hearing; ?>" placeholder="prev-hearing-date" required><br>

<label for="case-status"> Case Status(pending/finished): </label>
<input class="form-control" type="text" name="case-status"
value="<?php echo $c_status; ?>" placeholder="case-status" required><br>

<label for="court-name"> Court Name: </label>
<input class="form-control" type="text" name="court-name"
value="<?php echo $c_name; ?>" placeholder="court-name" required><br>

<input class="btn btn-info btn-block" type="submit" name="update-case" value="Update Case">
</div>
</form>
</div>
<?php } ?>
</div>
</div>


<?php
if(isset($_POST['update-case'])){
$case_type = $_POST['case-type'];
$case_details = $_POST['case-details'];
$next_hearing_date = $_POST['next-hearing-date'];
$prev_hearing_date = $_POST['prev-hearing-date'];
$case_status = $_POST['case-status'];
$court_name = $_POST['court-name'];
require_once("includes/db.php");
$con;
if ($con) {
$case_id = $_GET['id'];
$stmt = $con->prepare("UPDATE cases SET
case_type = ?, case_details = ?, next_hearing_date = ?,
prev_hearing_date = ?, case_status = ?, court_name = ?
WHERE case_id = ? ");

$stmt->bind_param('ssssssi', $case_type, $case_details, $next_hearing_date,
$prev_hearing_date, $case_status, $court_name, $case_id);
$stmt->execute();
echo "updated case";
}
}
?>
2 changes: 2 additions & 0 deletions admin_dashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@
require_once("admin/managelawyers.php");
elseif($_GET['q'] == "feedbacks")
require_once("admin/feedbacks.php");
elseif($_GET['q'] == "updatecase")
require_once("admin/updatecase.php");

?>

Expand Down
2 changes: 1 addition & 1 deletion includes/db.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

$host = 'localhost';
$user = 'root';
$pwd = 'pw';
$pwd = 'db';
$db = 'court_case_management';

$con = new mysqli($host, $user, $pwd, $db);
Expand Down

0 comments on commit 782a4e7

Please sign in to comment.