Skip to content
Open
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
35 changes: 35 additions & 0 deletions app/controllers/missing.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,4 +181,39 @@ function img($id) {
echo $img;
}

function pdf() {
// TODO: Add Image in PDF
$missing_person_list = false;
$missing_person_list = $this->missing_model->get_missing();
if(($missing_person_list === false)) {
echo "HELLO";
exit;
}
$this->load_library('html2pdf_lib', 'html2pdf_lib');
$this->content = "<page>";
$this->content = $this->content . "<h1 style='text-align:center;'>Saathi</h1>";
$this->content = $this->content . "<h2 style='text-align:center;'>List of Missing Persons</h2>";
$this->content = $this->content . "<br><div>";
$this->content = $this->content . "<table style='width:100%;border: 1px solid #000000;'><tr>";
$this->content = $this->content . "<th style='width:40%;text-align:center; text-decoration:underline;'>Person Name</th>";
$this->content = $this->content . "<th style='width:25%;text-align:center; text-decoration:underline;'>Gender</th>";
$this->content = $this->content . "<th style='width:35%;text-align:center; text-decoration:underline;'>Date of Birth</th></tr>";
foreach($missing_person_list as $list) {
if ($list['gender'] === "M")
$gender = "Male";
else if ($list['gender'] === "F")
$gender = "Female";
else if ($list['gender'] === "O")
$gender = "Other";
$this->content = $this->content . "<tr><td style='width:40%;text-align:center;'>" . $list['fname'] . " " . $list['lname'] . "</td>";
$this->content = $this->content . "<td style='width:25%;text-align:center;'> " . $gender . " </td>";
$this->content = $this->content . "<td style='width:35%;text-align:center;'>" . $list['dob'] . "</td></tr>";
}
$this->content = $this->content . "</table></div>";
$this->content = $this->content . "</page>";
$this->html2pdf = $this->html2pdf_lib->getobject();
$this->html2pdf->WriteHTML($this->content);
$this->html2pdf->Output("missing_person.pdf");
}

}
1 change: 1 addition & 0 deletions app/libraries/html2pdf
Submodule html2pdf added at 68d0b8
12 changes: 12 additions & 0 deletions app/libraries/html2pdf_lib.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php
class html2pdf_lib extends Library {

function __construct() {
require("html2pdf". DIRECTORY_SEPARATOR ."html2pdf.class.php");
$this->html2pdf = new HTML2PDF('P', 'A4', 'en');
}

function getobject() {
return $this->html2pdf;
}
}
49 changes: 27 additions & 22 deletions app/views/missing/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,30 +119,35 @@
</h1>
</div>
<?php
echo "<div class='table-responsive'>";
echo "<table style='text-align:center;' class='table table-striped missing-list'>";
echo "<tr class='active h3'>";
echo "<th>Photo</th>";
echo "<th>Person Name</th>";
echo "<th>Gender</th>";
echo "<th>Date of Birth</th>";
echo "</tr>";
foreach ($missing_person_list as $list) {
if ($list['gender'] === "M")
$gender = "Male";
else if ($list['gender'] === "F")
$gender = "Female";
else if ($list['gender'] === "O")
$gender = "Other";
echo "<tr class='h4'>";
echo "<td>".($list['img'] ? "<img class='person-img' src='" . base_url() . "missing/img/" . $list['id'] . "' />" : '')."</td>";
echo "<td>".$list['fname']." ".$list['lname']."</td>";
echo "<td>".$gender."</td>";
echo "<td>".$list['dob']."</td>";
if($missing_person_list === false) {
echo "<h2><center><u>No Missing Persons Reported</u></center></h2>";
} else {
echo "<h5 style='text-align:right;'>Download as PDF <a href='". base_url() ."missing/pdf'><img src='". base_url() ."static/img/pdf_image.png' height='25px' width='25px'></a></h5>";
echo "<div class='table-responsive'>";
echo "<table style='text-align:center;' class='table table-striped missing-list'>";
echo "<tr class='active h3'>";
echo "<th style='text-align:center;'>Photo</th>";
echo "<th style='text-align:center;'>Person Name</th>";
echo "<th style='text-align:center;'>Gender</th>";
echo "<th style='text-align:center;'>Date of Birth</th>";
echo "</tr>";
foreach ($missing_person_list as $list) {
if ($list['gender'] === "M")
$gender = "Male";
else if ($list['gender'] === "F")
$gender = "Female";
else if ($list['gender'] === "O")
$gender = "Other";
echo "<tr class='h4'>";
echo "<td>".($list['img'] ? "<img class='person-img' src='" . base_url() . "missing/img/" . $list['id'] . "' />" : '')."</td>";
echo "<td>".$list['fname']." ".$list['lname']."</td>";
echo "<td>".$gender."</td>";
echo "<td>".$list['dob']."</td>";
echo "</tr>";
}
echo "</table>";
echo "</div>";
}
echo "</table>";
echo "</div>";
?>
</div>
</div>
Expand Down
Binary file added static/img/pdf_image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.