Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated Missing Person Details #63

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 67 additions & 1 deletion app/controllers/missing.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ function index() {

function report() {
$reported = null;
$updated = null;

if ( isset($_POST['report']) ) {
$reported = $this->missing_model->report(
Expand All @@ -23,7 +24,8 @@ function report() {
}

$this->load_view('missing/report', array(
'reported' => $reported
'reported' => $reported,
'updated' => $updated
));
}

Expand All @@ -46,4 +48,68 @@ function search() {
}
}

function update() {
$reported = null;
$updated = null;

$id = $_GET["id"];
$con=mysqli_connect(DB_HOST,DB_USER,DB_PASS,DB_NAME);
$q = "SELECT * FROM persons where id= '$id'";
$result = mysqli_query($con,$q);
$tmp_id = 2*$id - 1;
if($result){
$per = mysqli_fetch_array($result,MYSQLI_ASSOC);
}
$q = "SELECT * FROM missing_persons where id= '$id'";
$result = mysqli_query($con,$q);
if($result){
$per_det = mysqli_fetch_array($result,MYSQLI_ASSOC);
}
$q = "SELECT * FROM contact_details where id= '$id'";
$result = mysqli_query($con,$q);
if($result){
$per_cont = mysqli_fetch_array($result,MYSQLI_ASSOC);
}
$tmp_id = $tmp_id+1;
$q = "SELECT * FROM contact_details where id= '$tmp_id'";
$result = mysqli_query($con,$q);
if($result){
$per_cont_w = mysqli_fetch_array($result,MYSQLI_ASSOC);
}

if ( isset($_POST['report']) ) {
$updated = $this->missing_model->report(
$_POST['person'],
$_POST['person_contact'],
$_POST['person_detail'],
$_POST['contact_whom']
);
}

$this->load_view('missing/report', array(
'reported' => $reported,
'updated' => $updated,
'per' => $per,
'per_det' => $per_det,
'per_cont' => $per_cont,
'per_cont_w' => $per_cont_w
));
$sql = "DELETE FROM persons WHERE id=$id";
if ($con->query($sql) === TRUE) {}
$sql = "DELETE FROM missing_persons WHERE id=$id";
if ($con->query($sql) === TRUE) {}
$tmp_id = 2*$id-1;
if ($con->query($sql) === TRUE) {}
$sql = "DELETE FROM contact_details WHERE id=$tmp_id";
if ($con->query($sql) === TRUE) {}
$tmp_id = $tmp_id+1;
$sql = "DELETE FROM contact_details WHERE id=$tmp_id";
if ($con->query($sql) === TRUE) {}
/*if ($con->query($sql) === TRUE) {}
echo "Record deleted successfully";
} else {
echo "Error deleting record: " . $con->error;
}*/
mysqli_close($con);
}
}
2 changes: 1 addition & 1 deletion app/models/missing_model.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ function report($person, $person_contact, $person_detail, $contact_whom) {
}

$missing_person = $this->execute(
'INSERT INTO `missing_persons`(`person_id`, `body_marks`, `height`, `weight`, `hair`, `eye_color`, `last_seen`, `contact_id`) VALUES (?, ?, ?, ?, ?, ?, ?, ?)',
'INSERT INTO `missing_persons`(`person_id`, `body_marks`, `height`, `weight`, `hair`, `eye_color`, `last_seen`, `contact_id`, `status`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, "Missing")',
'issssssi',
array(
&$person_id,
Expand Down
Empty file modified app/views/missing/index.php
100644 → 100755
Empty file.
45 changes: 27 additions & 18 deletions app/views/missing/report.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,15 @@
}
echo "<br><br>";
}
else if ($updated !== null) {
if ($updated == true) {
echo "<div class='alert alert-success'> Updated Successfully </div>";
}
else {
echo "<div class='alert alert-danger'> Submission failed </div>";
}
echo "<br><br>";
}
?>

<form action="" method="POST">
Expand All @@ -135,11 +144,11 @@
</div>
<div class="panel-body">
<label for="fname">First name </label>
<input id="fname" type="text" class="form-control" name="person[fname]" placeholder="Enter First Name" required /><br>
<input id="fname" value="<?php if(isset($per)){echo $per['fname'];} ?>" type="text" class="form-control" name="person[fname]" placeholder="Enter First Name" required /><br>
<label for="lname">Last name </label>
<input type="text" class="form-control" placeholder="Enter Last Name" id="lname" name="person[lname]" required /><br>
<input type="text" value="<?php if(isset($per)){echo $per['lname'];} ?>" class="form-control" placeholder="Enter Last Name" id="lname" name="person[lname]" required /><br>
<label for="dob">Date of birth </label>
<input type="date" placeholder="Enter your DOB" class="form-control" id="dob" type="date" name="person[dob]" /><br>
<input type="date" value="<?php if(isset($per)){echo $per['dob'];} ?>" placeholder="Enter your DOB" class="form-control" id="dob" type="date" name="person[dob]" /><br>
<label class="sr-only" for="gender">Gender: </label>
<div class="dropdown">
<select class="dropdown-header" id="gender" name="person[gender]" required>
Expand All @@ -160,11 +169,11 @@
</div>
<div class="panel-body">
<label for="phone_no">Phone number </label>
<input placeholder="Enter Phone Number" class="form-control" id="phone_no" name="person_contact[phone_no]" /><br>
<input value="<?php if(isset($per_cont)){echo $per_cont['phone_no'];} ?>" placeholder="Enter Phone Number" class="form-control" id="phone_no" name="person_contact[phone_no]" /><br>
<label for="email">Email: </label>
<input class="form-control" type="email" placeholder="Enter your Email" id="email" type="email" name="person_contact[email]" /><br>
<input value="<?php if(isset($per_cont)){echo $per_cont['email'];} ?>" class="form-control" type="email" placeholder="Enter your Email" id="email" type="email" name="person_contact[email]" /><br>
<label for="mailing_list">Mailing list </label>
<input class="form-control" placeholder="Enter mailing-list" id="mailing_list" type="email" name="person_contact[mailing_list]" /><br>
<input value="<?php if(isset($per_cont)){echo $per_cont['mailing_list'];} ?>" class="form-control" placeholder="Enter mailing-list" id="mailing_list" type="email" name="person_contact[mailing_list]" /><br>
</div>
</div>
</fieldset>
Expand All @@ -176,17 +185,17 @@
</div>
<div class="panel-body">
<label for="body_marks">Body marks </label><br>
<textarea id="body_marks" class="form-control" placeholder="Enter Body Marks" name="person_detail[body_marks]"></textarea><br>
<textarea id="body_marks" class="form-control" placeholder="Enter Body Marks" name="person_detail[body_marks]"><?php if(isset($per_det)){echo $per_det['body_marks'];} ?></textarea><br>
<label for="height">Height </label>
<input id="height" placeholder="Enter Height" class="form-control" name="person_detail[height]" /><br>
<input value="<?php if(isset($per_det)){echo $per_det['height'];} ?>" id="height" placeholder="Enter Height" class="form-control" name="person_detail[height]" /><br>
<label for="weight">Weight </label>
<input class="form-control" placeholder="Enter Weight" id="weight" name="person_detail[weight]" /><br>
<input value="<?php if(isset($per_det)){echo $per_det['weight'];} ?>" class="form-control" placeholder="Enter Weight" id="weight" name="person_detail[weight]" /><br>
<label for="hair">Hair Style/Color </label>
<input id="hair" placeholder="Enter Hair Style/Color" class="form-control" name="person_detail[hair]" /><br>
<input value="<?php if(isset($per_det)){echo $per_det['hair'];} ?>" id="hair" placeholder="Enter Hair Style/Color" class="form-control" name="person_detail[hair]" /><br>
<label for="eye_color">Eye color </label>
<input id="eye_color" class="form-control" placeholder="Enter Eye color" name="person_detail[eye_color]" /><br>
<input value="<?php if(isset($per_det)){echo $per_det['eye_color'];} ?>" id="eye_color" class="form-control" placeholder="Enter Eye color" name="person_detail[eye_color]" /><br>
<label for="last_seen">Last seen (When, where, condition) </label><br>
<textarea id="last_seen" placeholder="Enter Last Seen Location" class="form-control" name="person_detail[last_seen]"></textarea><br>
<textarea id="last_seen" placeholder="Enter Last Seen Location" class="form-control" name="person_detail[last_seen]"><?php if(isset($per_det)){echo $per_det['last_seen'];} ?></textarea><br>
</div>
</div>
</fieldset>
Expand All @@ -198,11 +207,11 @@
</div>
<div class="panel-body">
<label for="w_phone_no">Phone number </label>
<input id="w_phone_no" class="form-control" placeholder="Enter Phone Number" name="contact_whom[phone_no]" required /><br>
<input value="<?php if(isset($per_cont_w)){echo $per_cont_w['phone_no'];} ?>" id="w_phone_no" class="form-control" placeholder="Enter Phone Number" name="contact_whom[phone_no]" required /><br>
<label for="w_email">Email </label>
<input id="w_email" placeholder="Enter Email" class="form-control" type="email" name="contact_whom[email]" required /><br>
<input value="<?php if(isset($per_cont_w)){echo $per_cont_w['email'];} ?>" id="w_email" placeholder="Enter Email" class="form-control" type="email" name="contact_whom[email]" required /><br>
<label for="w_mailing_list">Mailing list </label>
<input id="w_mailing_list" class="form-control" placeholder="Enter Mailing List" type="email" name="contact_whom[mailing_list]" /><br>
<input value="<?php if(isset($per_cont_w)){echo $per_cont_w['mailing_list'];} ?>" id="w_mailing_list" class="form-control" placeholder="Enter Mailing List" type="email" name="contact_whom[mailing_list]" /><br>
</div>
</div>
<!-- TODO Automatic adding of coordinates into DB after selection of location -->
Expand All @@ -213,13 +222,13 @@
</div>
<div class="panel-body">
<label for="my-address"><b>Landmark Nearest to Last Seen Location</b></label>
<input type="text" class="form-control" placeholder="Enter Nearest Landmark" id="my-address" name="person_contact[mailing_address]" />
<input value="<?php if(isset($per_cont)){echo $per_cont['mailing_address'];} ?>" type="text" class="form-control" placeholder="Enter Nearest Landmark" id="my-address" name="person_contact[mailing_address]" />
<br />
<center>
<div class="btn btn-success" id="getCords" onclick="codeAddress();">Show on Map</div>
<br />
<input name="person_contact[latitude]" id="lat" value="" style="visibility: hidden"/>
<input name="person_contact[longitude]" id="long" value="" style="visibility: hidden"/>
<input name="person_contact[latitude]" id="lat" value="" style="visibility: hidden"/>
<input name="person_contact[longitude]" id="long" value="" style="visibility: hidden"/>

<div id="map_canvas" style="width: 500px; height: 300px"></div>
</center>
Expand Down
Empty file modified app/views/missing/search.php
100644 → 100755
Empty file.
4 changes: 3 additions & 1 deletion app/views/missing/search_results.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,9 @@
echo "<li class='list-group-item'><b> Hair Color/Style: </b>" . $person['hair'] . '</li>';
echo "<li class='list-group-item'><b> Eye-Color: </b>" . $person['eye_color'] . '</li>';
echo "<li class='list-group-item'><b> Last Seen Location: </b>" . $person['last_seen'] . '</li>';
echo "<li class='list-group-item'><b> Status: </b>" . $person['status'] . '</li>';
echo "<li class='list-group-item'><b> Status: </b>" . $person['status'] . "<div class='btn btn-success'>Update Status As Found</div></li>";
$per_id = $person['id'];
echo "<a class='btn btn-info' href='update?id=$per_id' style=' color: #ffffff;'>Update Details</a>";
echo "</ul></div></div>";

if ($person['longitude'] != 0 || $person['latitude'] != 0) {
Expand Down