Compare commits

..

10 Commits

14 changed files with 697 additions and 93 deletions
+1 -1
View File
@@ -128,7 +128,7 @@ class Base {
$host = 'localhost'; $host = 'localhost';
} else { } else {
$host = '192.168.1.190'; $host = '192.168.1.190';
$host = '100.67.215.67'; // $host = '100.67.215.67';
} }
try { try {
+1 -1
View File
@@ -102,7 +102,7 @@ class PermitsByBuilder extends Base {
// Ensure valid order by column // Ensure valid order by column
$allowed_order_columns = ["permit_permit_number", "permit_entry_date", "permit_permit_date", "permit_company", "permit_permit_count"]; $allowed_order_columns = ["permit_permit_number", "permit_entry_date", "permit_permit_date", "permit_company", "permit_permit_count"];
if (!in_array($permits_order_by, $allowed_order_columns)) { if (!in_array($permits_order_by, $allowed_order_columns)) {
$permits_order_by = "order by view_permits.permit_company"; $permits_order_by = " view_permits.permit_company";
} }
// Connect to DB // Connect to DB
+97 -26
View File
@@ -340,9 +340,6 @@ class PermitsBySubdivision extends Base {
$statement->bindValue(":limit", $this->pagination_size, PDO::PARAM_INT); $statement->bindValue(":limit", $this->pagination_size, PDO::PARAM_INT);
$statement->bindValue(":offset", $offset, PDO::PARAM_INT); $statement->bindValue(":offset", $offset, PDO::PARAM_INT);
// echo $projecttype;
// die();
$statement->execute(); $statement->execute();
$permits = $this->getTableXML("permits", $statement); $permits = $this->getTableXML("permits", $statement);
@@ -368,44 +365,118 @@ class PermitsBySubdivision extends Base {
// Fetch All Permits for Exports // Fetch All Permits for Exports
// ============================= // =============================
public function getAllPermitsBySubDivision($permit_area, $projecttype) { public function getAllPermitsBySubdivision($permit_area, $projecttype, $searchcriteria = array()) {
$connection = $this->connect(); $connection = $this->connect();
$searchcriteria = is_array($searchcriteria) ? $searchcriteria : [];
$conditions = ["r.permit_project_type = :permit_project_type"];
$parameters = [":permit_project_type" => [$projecttype, PDO::PARAM_STR]];
// County can be posted as [6, 7] or as a comma-separated string
$countyValues = $searchcriteria["permit_county"] ?? [];
if (!is_array($countyValues)) {
$countyValues = explode(",", (string) $countyValues);
}
$countyIds = [];
foreach ($countyValues as $countyValue) {
$countyValue = trim((string) $countyValue);
if ($countyValue !== "" && ctype_digit($countyValue)) {
$countyIds[] = (int) $countyValue;
}
}
$countyIds = array_values(array_unique($countyIds));
if ($permit_area != "All") {
$conditions[] = "r.permit_county in (
select county_serial
from view_counties
where county_area = :permit_area )";
$parameters[":permit_area"] = [$permit_area, PDO::PARAM_STR];
}
if ($countyIds) {
$countyPlaceholders = [];
foreach ($countyIds as $index => $countyId) {
$placeholder = ":permit_county_{$index}";
$countyPlaceholders[] = $placeholder;
$parameters[$placeholder] = [$countyId, PDO::PARAM_INT];
}
$conditions[] = "r.permit_county in (" . implode(", ", $countyPlaceholders) . ")";
}
$textFilters = [
"permit_company" => "permit_company",
"permit_sub_div_name" => "permit_sub_div_name",
"permit_project_city" => "permit_project_city",
"permit_project_addr" => "permit_project_addr"
];
foreach ($textFilters as $criteriaKey => $column) {
$value = trim((string) ($searchcriteria[$criteriaKey] ?? ""));
if ($value !== "") {
$placeholder = ":{$criteriaKey}";
$conditions[] = "r.{$column} like {$placeholder}";
$parameters[$placeholder] = ["%{$value}%", PDO::PARAM_STR];
}
}
$normalizeDate = static function ($value) {
$value = trim((string) $value);
if ($value === "") {
return null;
}
$timestamp = strtotime($value);
return $timestamp === false ? null : date("Y-m-d", $timestamp);
};
$dateRanges = [
["permit_entry_date", "permit_entry_start_date", "permit_entry_end_date"],
["permit_permit_date", "permit_permit_start_date", "permit_permit_end_date"]
];
foreach ($dateRanges as [$column, $startKey, $endKey]) {
$startDate = $normalizeDate($searchcriteria[$startKey] ?? "");
$endDate = $normalizeDate($searchcriteria[$endKey] ?? "");
if ($startDate !== null) {
$conditions[] = "r.{$column} >= :{$startKey}";
$parameters[":{$startKey}"] = [$startDate, PDO::PARAM_STR];
}
if ($endDate !== null) {
$conditions[] = "r.{$column} <= :{$endKey}";
$parameters[":{$endKey}"] = [$endDate, PDO::PARAM_STR];
}
}
$where = implode(" and ", $conditions);
$bindParameters = static function ($statement) use ($parameters) {
foreach ($parameters as $placeholder => [$value, $type]) {
$statement->bindValue($placeholder, $value, $type);
}
};
// Count Query
$SQL = "select count(*) as count $SQL = "select count(*) as count
from view_permits r from view_permits r
join counties c on r.permit_county = c.county_serial where {$where}";
where r.permit_project_type = :permit_project_type
and r.permit_county in
(select county_serial
from view_counties
where county_area = :permit_area)";
$statement = $connection->prepare($SQL); $statement = $connection->prepare($SQL);
$bindParameters($statement);
$statement->bindValue(":permit_project_type", $projecttype, PDO::PARAM_STR);
$statement->bindValue(":permit_area", $permit_area, PDO::PARAM_STR);
$statement->execute(); $statement->execute();
$recordset = $statement->fetch(PDO::FETCH_ASSOC); $recordset = $statement->fetch(PDO::FETCH_ASSOC);
$count = $recordset ? (int) $recordset["count"] : 0; $count = $recordset ? (int) $recordset["count"] : 0;
// === DATA QUERY === $SQL = "select r.*, c.county_name as county_name_verbose
$SQL = "select r.*, c.county_name as permit_county_name_verbose
from view_permits r from view_permits r
join counties c on r.permit_county = c.county_serial join counties c on r.permit_county = c.county_serial
where r.permit_project_type = :permit_project_type where {$where}
and r.permit_county in order by c.county_name, r.permit_sub_div_name";
(select county_serial
from view_counties
where county_area = :permit_area)";
$statement = $connection->prepare($SQL); $statement = $connection->prepare($SQL);
$bindParameters($statement);
$statement->bindValue(":permit_project_type", $projecttype, PDO::PARAM_STR);
$statement->bindValue(":permit_area", $permit_area, PDO::PARAM_STR);
$statement->execute(); $statement->execute();
$permits = $this->getTableXML("permits", $statement); $permits = $this->getTableXML("permits", $statement);
-3
View File
@@ -529,9 +529,6 @@ class Process_ImportRequest {
$settings = new SimpleXMLElement((file_exists("./xml/settings.xml") ? file_get_contents("./xml/settings.xml") : "<settings/>")); $settings = new SimpleXMLElement((file_exists("./xml/settings.xml") ? file_get_contents("./xml/settings.xml") : "<settings/>"));
print_r($settings);
die();
// Server Variables // Server Variables
$host = (string) $settings->SmtpServer; $host = (string) $settings->SmtpServer;
$username = (string) $settings->SmtpUserName; $username = (string) $settings->SmtpUserName;
+13
View File
@@ -757,6 +757,19 @@ class Users extends Base {
return $this->getTable("loginactivity", $SQL); return $this->getTable("loginactivity", $SQL);
} }
// ====================
// Return a User Object
// ====================
public function getActiveUsers() {
$SQL = "select view_users.*
from view_users
where view_users.user_active = true";
return $this->getTable("activeusers", $SQL);
}
} }
?> ?>
+62 -6
View File
@@ -204,8 +204,6 @@ $(document).ready(function () {
}); });
// ==================== // ====================
// Autocomplete Searches // Autocomplete Searches
// ==================== // ====================
@@ -529,6 +527,23 @@ $(document).ready(function () {
}); });
// // ------------------------
// // Export All Permits - PDF
// // ------------------------
//
// $(".btnExportAllPDF").on("click", function (e) {
//
// e.preventDefault();
//
// window.open("", "PrintTab");
//
// $("input[name = 'action']", "#PrintAllPermitsBySubdivisionPDFForm").val("print");
// $("input[name = 'subscription_serial']", "#PrintAllPermitsBySubdivisionPDFForm").val($sessionStorage.subscription_serial);
// $("input[name = 'subscription_serial']", "#PrintAllPermitsBySubdivisionPDFForm").val($sessionStorage.subscription_serial);
// $("#PrintAllPermitsBySubdivisionPDFForm").submit();
//
// });
// ------------------------ // ------------------------
// Export All Permits - PDF // Export All Permits - PDF
// ------------------------ // ------------------------
@@ -537,13 +552,54 @@ $(document).ready(function () {
e.preventDefault(); e.preventDefault();
window.open("", "PrintTab"); const $printForm = $("#PrintAllPermitsBySubdivisionPDFForm");
const $searchForm = $("#searchPermitsBySubdivision");
$("input[name = 'action']", "#PrintAllPermitsBySubdivisionPDFForm").val("print"); // Remove fields added by a previous PDF export.
$("input[name = 'subscription_serial']", "#PrintAllPermitsBySubdivisionPDFForm").val($sessionStorage.subscription_serial); $printForm.find(".print-search-field").remove();
$("#PrintAllPermitsBySubdivisionPDFForm").submit();
// Copy populated search criteria into the PDF form.
$searchForm.find(":input[name]").not(":button, :submit, :reset").not("[name='action']").not("[name='subscription_serial']").each(function () {
const $input = $(this);
const fieldName = $input.attr("name");
// Ignore unchecked checkboxes and radio buttons.
if (($input.is(":checkbox") || $input.is(":radio")) && !$input.is(":checked")) {
return;
}
let values = $input.val();
if (values === null || values === undefined) {
return;
}
// Supports multiple-select inputs.
if (!Array.isArray(values)) {
values = [values];
}
$.each(values, function (_, value) {
value = String(value).trim();
if (value === "") {
return;
}
$("<input>", {type: "hidden", name: fieldName, value: value, class: "print-search-field"}).appendTo($printForm);
}); });
});
$printForm.find("[name='action']").val("print");
$printForm.find("[name='subscription_serial']").val($sessionStorage.subscription_serial);
window.open("", "PrintTab");
$printForm.trigger("submit");
});
// -------------------------- // --------------------------
// Export All Permits - Excel // Export All Permits - Excel
+11 -11
View File
@@ -32,7 +32,7 @@ class Export_AllPermitsBySubdivision_CSV extends Base {
$permit_area = $subscription->record->subscription_area; $permit_area = $subscription->record->subscription_area;
$projecttype = $subscription->record->subscription_projecttype; $projecttype = $subscription->record->subscription_projecttype;
$permits = (new PermitsBySubdivision())->getAllPermitsBySubdivision($permit_area, $projecttype); $permits = (new PermitsBySubdivision())->getAllPermitsBySubdivision($permit_area, $projecttype, $_POST);
header('Content-Type: text/csv'); header('Content-Type: text/csv');
header('Content-Disposition: attachment; filename="All_PermitsBySubdivision.csv"'); header('Content-Disposition: attachment; filename="All_PermitsBySubdivision.csv"');
@@ -47,17 +47,17 @@ class Export_AllPermitsBySubdivision_CSV extends Base {
foreach ($permits as $permit) { foreach ($permits as $permit) {
$county_name = $permit->rdi_county_name_verbose; $county_name = $permit->county_name_verbose;
$subdivision = $permit->rdi_sub_div_name; $subdivision = $permit->permit_sub_div_name;
$address = "{$permit->rdi_address} {$permit->rdi_city} {$permit->rdi_state} {$permit->rdi_zip}"; $address = "{$permit->permit_address} {$permit->permit_city} {$permit->permit_state} {$permit->permit_zip}";
$city = $permit->rdi_city; $city = $permit->permit_city;
$builder = $permit->rdi_company; $builder = $permit->permit_company;
$permit_date = $permit->rdi_permit_date_verbose; $permit_date = $permit->permit_permit_date_verbose;
$square_footage = $permit->rdi_size_verbose; $square_footage = $permit->permit_size_verbose;
$value = $permit->rdi_value_verbose; $value = $permit->permit_value_verbose;
$permit_ytd_value = "$" . number_format((int) $permit->rdi_ytd_value, 2); $permit_ytd_value = "$" . number_format((int) $permit->permit_ytd_value, 2);
$permit_value = "$" . number_format((int) $permit->rdi_value, 2); $permit_value = "$" . number_format((int) $permit->permit_value, 2);
$permit_data = array($county_name, $subdivision, $address, $city, $builder, $permit_date, $square_footage, $value); $permit_data = array($county_name, $subdivision, $address, $city, $builder, $permit_date, $square_footage, $value);
@@ -35,7 +35,7 @@ class Export_AllPermitsBySubdivision_Excel extends Base {
$permit_area = $subscription->record->subscription_area; $permit_area = $subscription->record->subscription_area;
$projecttype = $subscription->record->subscription_projecttype; $projecttype = $subscription->record->subscription_projecttype;
$permits = (new PermitsBySubdivision())->getAllPermitsBySubdivision($permit_area, $projecttype); $permits = (new PermitsBySubdivision())->getAllPermitsBySubdivision($permit_area, $projecttype, $_POST);
// Create the Spreadsheet. // Create the Spreadsheet.
@@ -89,16 +89,16 @@ class Export_AllPermitsBySubdivision_Excel extends Base {
foreach ($permits as $permit) { foreach ($permits as $permit) {
$address = "{$permit->rdi_address} {$permit->rdi_city}, {$permit->rdi_state} {$permit->rdi_zip}"; $address = "{$permit->permit_address} {$permit->permit_city}, {$permit->permit_state} {$permit->permit_zip}";
$spreadsheet->getActiveSheet()->setCellValue("A" . $row, (string) $permit->rdi_county_name_verbose); $spreadsheet->getActiveSheet()->setCellValue("A" . $row, (string) $permit->county_name_verbose);
$spreadsheet->getActiveSheet()->setCellValue("B" . $row, (string) $permit->rdi_sub_div_name); $spreadsheet->getActiveSheet()->setCellValue("B" . $row, (string) $permit->permit_sub_div_name);
$spreadsheet->getActiveSheet()->setCellValue("C" . $row, (string) $address); $spreadsheet->getActiveSheet()->setCellValue("C" . $row, (string) $address);
$spreadsheet->getActiveSheet()->setCellValue("D" . $row, (string) $permit->rdi_city); $spreadsheet->getActiveSheet()->setCellValue("D" . $row, (string) $permit->permit_city);
$spreadsheet->getActiveSheet()->setCellValue("E" . $row, (string) $permit->rdi_company); $spreadsheet->getActiveSheet()->setCellValue("E" . $row, (string) $permit->permit_company);
$spreadsheet->getActiveSheet()->setCellValue("F" . $row, (string) $permit->rdi_permit_date_verbose); $spreadsheet->getActiveSheet()->setCellValue("F" . $row, (string) $permit->permit_permit_date_verbose);
$spreadsheet->getActiveSheet()->setCellValue("G" . $row, (string) $permit->rdi_size_verbose); $spreadsheet->getActiveSheet()->setCellValue("G" . $row, (string) $permit->permit_size_verbose);
$spreadsheet->getActiveSheet()->setCellValue("H" . $row, (string) $permit->rdi_value_verbose); $spreadsheet->getActiveSheet()->setCellValue("H" . $row, (string) $permit->permit_value_verbose);
$row++; $row++;
} }
+279
View File
@@ -0,0 +1,279 @@
<?php
require_once ("tcpdf/tcpdf.php");
// ================================
// Print Active Users Subscriptions
// ================================
class Print_ActiveUserSubscriptions extends Base {
// ==================
// Class Constructor.
// ==================
public function __construct($output_type = "normal") {
set_error_handler(array($this, "displayError"));
date_default_timezone_set(self::TIMEZONE);
}
// ================
// Print the Report
// ================
public function print($output_type = "normal") {
$report = new ActiveUserSubscriptions();
$report->output_type = $output_type;
ob_clean();
if ($output_type == "string") {
return $report->render();
} else {
$report->render();
}
}
}
// ==========================
// Class to Generate the .pdf
// ==========================
class ActiveUserSubscriptions extends TCPDF {
// Variables
public $user_serial = 0;
public $first_page = true;
public $output_type = "normal";
// ================
// Debug an Object.
// ================
public function debug($object = "") {
echo "<pre>";
print_r($object);
exit();
}
// =================
// Render the Report
// =================
public function render() {
set_time_limit(0);
// Get the data for the report
$users = (new Users())->getActiveUsers();
// Set report defaults
$this->title = "Active User Subscriptions";
$this->SetFont("Calibri");
$this->SetMargins(10, 25, 10);
$this->SetHeaderMargin(10);
$this->SetFooterMargin(10);
$this->setCellPaddings(0, 0, 0, 0);
$this->setCellMargins(2, 0, 0, 0);
$this->addPage("P", "LETTER");
// --------------------------
// Active Users Subscriptions
// --------------------------
$this->SetFont("Calibri", "B", 10);
foreach ($users as $user) {
$user_serial = (integer) $user->user_serial;
$user_name = (string) $user->user_name;
$users_login = (string) $user->user_login_verbose ?: 'Never Logged In';
$subscriptions = (new Subscriptions())->getUsersActiveSubscriptions($user_serial);
$this->SetFont("Calibri", "B", 10);
$this->Cell(25, 0, "Name:", 0, 0, "L", false, "", 3);
$this->SetFont("Calibri", "", 10);
$this->Cell(80, 0, $user->user_client_name, 0, 0, "L", false, "", 3);
$this->SetFont("Calibri", "B", 10);
$this->Cell(25, 0, "Created:", 0, 0, "L", false, "", 3);
$this->SetFont("Calibri", "", 10);
$this->Cell(80, 0, $user->user_created_verbose, 0, 1, "L", false, "", 3);
$this->SetFont("Calibri", "B", 10);
$this->Cell(25, 0, "Main Email:", 0, 0, "L", false, "", 3);
$this->SetFont("Calibri", "", 10);
$this->Cell(80, 0, $user->user_email, 0, 0, "L", false, "", 3);
$this->SetFont("Calibri", "B", 10);
$this->Cell(25, 0, "Created By:", 0, 0, "L", false, "", 3);
$this->SetFont("Calibri", "", 10);
$this->Cell(80, 0, $user->user_creator, 0, 1, "L", false, "", 3);
$this->SetFont("Calibri", "B", 10);
$this->Cell(25, 0, "User Name:", 0, 0, "L", false, "", 3);
$this->SetFont("Calibri", "", 10);
$this->Cell(80, 0, $user->user_name, 0, 0, "L", false, "", 3);
$this->SetFont("Calibri", "B", 10);
$this->Cell(25, 0, "Changed", 0, 0, "L", false, "", 3);
$this->SetFont("Calibri", "", 10);
$this->Cell(80, 0, $user->user_changed_verbose, 0, 1, "L", false, "", 3);
$this->SetFont("Calibri", "B", 10);
$this->Cell(25, 0, "Roll:", 0, 0, "L", false, "", 3);
$this->SetFont("Calibri", "", 10);
$this->Cell(80, 0, $user->user_role, 0, 0, "L", false, "", 3);
$this->SetFont("Calibri", "B", 10);
$this->Cell(25, 0, "Changed By:", 0, 0, "L", false, "", 3);
$this->SetFont("Calibri", "", 10);
$this->Cell(80, 0, $user->user_changer, 0, 1, "L", false, "", 3);
$this->SetFont("Calibri", "B", 10);
$this->Cell(25, 0, "Change Password:", 0, 0, "L", false, "", 3);
$this->SetFont("Calibri", "", 10);
$user_change_password = ($user->user_change_password == 1) ? "Yes" : "No";
$this->Cell(80, 0, $user_change_password, 0, 0, "L", false, "", 3);
$this->SetFont("Calibri", "B", 10);
$this->Cell(25, 0, "Last Login:", 0, 0, "L", false, "", 3);
$this->SetFont("Calibri", "", 10);
$this->Cell(80, 0, $user->user_login_verbose, 0, 1, "L", false, "", 3);
$this->SetFont("Calibri", "B", 10);
$this->Cell(25, 0, "", 0, 0, "L", false, "", 3);
$this->SetFont("Calibri", "", 10);
$this->Cell(80, 0, "", 0, 0, "L", false, "", 3);
$this->SetFont("Calibri", "B", 10);
$this->Cell(25, 0, "Active Status:", 0, 0, "L", false, "", 3);
$this->SetFont("Calibri", "", 10);
$user_active = ($user->user_active == 1) ? "Active" : "Inactive";
$this->Cell(80, 0, $user_active, 0, 1, "L", false, "", 3);
// ----------------------------------
// Rectangle around the Users Details
// ----------------------------------
$this->RoundedRect(10, 23, 190, $this->GetY() - 21, 1.50, "1111");
// -------------
// Subscriptions
// -------------
$this->Ln(7);
$this->SetFont("Calibri", "B", 12);
$this->Cell(0, 0, "Subscriptions", 0, 1, "L", false, "", 3);
$this->Ln(3);
$this->SetFont("Calibri", "B", 10);
$this->Cell(75, 0, "Description", "B", 0, "L", false, "", 3);
$this->Cell(20, 0, "End Date", "B", 0, "L", false, "", 3);
$this->Cell(10, 0, "Status", "B", 0, "L", false, "", 3);
$this->SetFont("Calibri", "", 10);
$this->Ln(6);
if ($subscriptions->count() == 0) {
$this->Cell(0, 0, "There are no Active Subscriptions...", 0, 1, "L", false, "", 3);
} else {
foreach ($subscriptions as $subscription) {
$this->Cell(75, 0, $subscription->subscription_title . " " . $subscription->subscription_description, 0, 0, "L", false, "", 3);
$this->Cell(20, 0, $subscription->usersubscription_stop_date_verbose, 0, 0, "L", false, "", 3);
$this->Cell(10, 0, $subscription->usersubscription_status, 0, 0, "L", false, "", 3);
$this->Ln(4);
if ($this->GetY() > 265) {
$this->AddPage("P", "LETTER");
$this->SetFont("Calibri", "B", 10);
$this->Cell(75, 0, "Description", "B", 0, "L", false, "", 3);
$this->Cell(20, 0, "End Date", "B", 0, "L", false, "", 3);
$this->Cell(10, 0, "Status", "B", 0, "L", false, "", 3);
$this->SetFont("Calibri", "", 10);
$this->Ln(6);
}
}
}
$this->addPage("P", "LETTER");
}
// --------------
// Return the pdf
// --------------
if ($this->output_type == "string") {
return $this->Output("ActiveUserSubscriptions.pdf", "S");
} else {
$this->Output("ActiveUserSubscriptions.pdf");
}
}
// ======
// Header
// ======
public function Header() {
$this->setCellPaddings(0, 0, 0, 0);
$this->setCellMargins(2, 0, 0, 0);
$this->Image('images/dec-international-logo.png', 10, 7, 25, 10);
$this->SetFont("Calibri", "B", 16);
$this->Cell(0, 6, "Active Users Subscriptions", 0, 1, "C");
$this->Ln(5);
}
// ======
// Footer
// ======
public function Footer() {
$this->SetFont("Calibri", "I", 8);
$X = $this->GetX();
$this->Cell(0, 10, "DEC-International, LLC", 0, false, "C");
$this->SetX($X);
$this->Cell(40, 10, "Page " . $this->getAliasNumPage() . "/" . $this->getAliasNbPages(), 0, false, "L");
$this->Cell(0, 10, date("Y-m-d g:i A"), 0, false, "R");
}
// =======================
// Stripe the printed line
// =======================
private function stripeLine($pRowCount = 0, $pRowWidth = 0) {
$this->SetFillColor(($pRowCount % 2) ? 220 : 255);
$X = $this->GetX();
$this->Cell($pRowWidth, 0, "", 0, 0, "L", true);
$this->SetX($X);
}
}
?>
+13 -8
View File
@@ -57,6 +57,7 @@ class AllPermitsBySubdivision_Print extends TCPDF {
public $subscription_serial = 0; public $subscription_serial = 0;
public $first_page = true; public $first_page = true;
public $output_type = "normal"; public $output_type = "normal";
public $record_count = 0;
// ================ // ================
// Debug an Object. // Debug an Object.
@@ -99,7 +100,9 @@ class AllPermitsBySubdivision_Print extends TCPDF {
// Get the data for the report // Get the data for the report
$permits = (new PermitsBySubdivision())->getAllPermitsBySubdivision($permit_area, $projecttype); $permits = (new PermitsBySubdivision())->getAllPermitsBySubdivision($permit_area, $projecttype, $_POST);
$this->record_count = count($permits);
// ------- // -------
// Permits // Permits
@@ -141,16 +144,16 @@ class AllPermitsBySubdivision_Print extends TCPDF {
$this->stripeLine($rowCount, 268); $this->stripeLine($rowCount, 268);
$rowCount++; $rowCount++;
$address = "{$permit->rdi_address} {$permit->rdi_city}, {$permit->rdi_state} {$permit->rdi_zip}"; $address = "{$permit->permit_address} {$permit->permit_city}, {$permit->permit_state} {$permit->permit_zip}";
$permit_value = "$" . number_format((int) $permit->rdi_value, 2); $permit_value = "$" . number_format((int) $permit->permit_value, 2);
$this->Cell(15, 0, $permit->rdi_county_name_verbose, 0, 0, "L", false, "", 3); $this->Cell(15, 0, $permit->county_name_verbose, 0, 0, "L", false, "", 3);
$this->Cell(40, 0, $permit->rdi_sub_div_name, 0, 0, "L", false, "", 3); $this->Cell(40, 0, $permit->permit_sub_div_name, 0, 0, "L", false, "", 3);
$this->Cell(85, 0, $address, 0, 0, "L", false, "", 3); $this->Cell(85, 0, $address, 0, 0, "L", false, "", 3);
$this->Cell(60, 0, $permit->rdi_company, 0, 0, "L", false, "", 3); $this->Cell(60, 0, $permit->permit_company, 0, 0, "L", false, "", 3);
$this->Cell(20, 0, $permit->rdi_permit_date_verbose, 0, 0, "L", false, "", 3); $this->Cell(20, 0, $permit->permit_permit_date_verbose, 0, 0, "L", false, "", 3);
$this->Cell(15, 0, $permit->rdi_size, 0, 0, "L", false, "", 3); $this->Cell(15, 0, $permit->permit_size_verbose, 0, 0, "L", false, "", 3);
$this->Cell(20, 0, $permit_value, 0, 0, "L", false, "", 3); $this->Cell(20, 0, $permit_value, 0, 0, "L", false, "", 3);
$this->Ln(4); $this->Ln(4);
@@ -186,6 +189,8 @@ class AllPermitsBySubdivision_Print extends TCPDF {
} }
} }
} }
$this->Ln(6);
$this->Cell(0, 0, "Records Returned: " . $this->record_count, "", 0, "R", false, "", 3);
// -------------- // --------------
// Return the pdf // Return the pdf
+179
View File
@@ -0,0 +1,179 @@
<?php
require_once ("tcpdf/tcpdf.php");
// ===========================
// Print a User Login Activity
// ===========================
class Print_UserLoginActivity extends Base {
// ==================
// Class Constructor.
// ==================
public function __construct($output_type = "normal") {
set_error_handler(array($this, "displayError"));
date_default_timezone_set(self::TIMEZONE);
}
// ================
// Print the Report
// ================
public function print($output_type = "normal") {
$report = new User_LoginActivity();
$report->output_type = $output_type;
ob_clean();
if ($output_type == "string") {
return $report->render();
} else {
$report->render();
}
}
}
// ==========================
// Class to Generate the .pdf
// ==========================
class User_LoginActivity extends TCPDF {
// Variables
public $user_serial = 0;
public $first_page = true;
public $output_type = "normal";
// ================
// Debug an Object.
// ================
public function debug($object = "") {
echo "<pre>";
print_r($object);
exit();
}
// =================
// Render the Report
// =================
public function render() {
set_time_limit(0);
// Get the data for the report
$users = (new Users())->getUsers();
// Set report defaults
$this->title = "All Users Login Activity";
$this->SetFont("Calibri");
$this->SetMargins(10, 30, 10);
$this->SetHeaderMargin(10);
$this->SetFooterMargin(10);
$this->setCellPaddings(0, 0, 0, 0);
$this->setCellMargins(2, 0, 0, 0);
$this->addPage("P", "LETTER");
// ------------------------
// Print the Users Activity
// ------------------------
$this->SetFont("Calibri", "B", 10);
$rowCount = 0;
foreach ($users as $user) {
$this->stripeLine($rowCount, 60);
$rowCount++;
$user_name = (string) $user->user_name;
$users_login = (string) $user->user_login_verbose ?: 'Never Logged In';
$this->Cell(20, 0, $user_name, 0, 0, "C", false, "", 0);
$this->Cell(20, 0, $users_login, 0, 0, "L", false, "", 0);
$this->Ln();
}
// --------------
// Return the pdf
// --------------
if ($this->output_type == "string") {
return $this->Output("UserLoginActivity.pdf", "S");
} else {
$this->Output("UserLoginActivity.pdf");
}
}
// ======
// Header
// ======
public function Header() {
$this->setCellPaddings(0, 0, 0, 0);
$this->setCellMargins(2, 0, 0, 0);
$this->Image('images/dec-international-logo.png', 10, 7, 25, 10);
$this->SetFont("Calibri", "B", 16);
$this->Cell(0, 6, "Users Login Activity", 0, 1, "C");
$this->Ln(5);
$this->SetFont("Calibri", "B", 12);
$this->Cell(20, 0, "User Name", "B", 0, "C", false, "", 3);
$this->Cell(50, 0, "Last Login", "B", 0, "L", false, "", 3);
$this->SetFont("Calibri", "B", 10);
}
// ======
// Footer
// ======
public function Footer() {
$this->SetFont("Calibri", "I", 8);
$X = $this->GetX();
$this->Cell(0, 10, "DEC-International, LLC", 0, false, "C");
$this->SetX($X);
$this->Cell(40, 10, "Page " . $this->getAliasNumPage() . "/" . $this->getAliasNbPages(), 0, false, "L");
$this->Cell(0, 10, date("Y-m-d g:i A"), 0, false, "R");
}
// =======================
// Stripe the printed line
// =======================
private function stripeLine($pRowCount = 0, $pRowWidth = 0) {
$this->SetFillColor(($pRowCount % 2) ? 220 : 255);
$X = $this->GetX();
$this->Cell($pRowWidth, 0, "", 0, 0, "L", true);
$this->SetX($X);
}
}
?>
+2 -2
View File
@@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
# -- Development -- # -- Development --
cd /var/www/html/clients/dec-international/ahrhousingreport #cd /var/www/html/clients/dec-international/atlhousingreport
# -- Production -- # -- Production --
#cd /var/www/html/webapps/dec-international/ahrhousingreport cd /var/www/html/webapps/dec-international/atlhousingreport
php ./scripts/ImportRequest_Worker.php php ./scripts/ImportRequest_Worker.php
+6 -2
View File
@@ -24,11 +24,15 @@ $SQL = "create view view_permits as
trends.permits_trend, trends.permits_trend,
trends.prev_ytd_value as previous_ytd_value, trends.prev_ytd_value as previous_ytd_value,
trends.ytd_value trends.ytd_value,
counties.county_name as county_name_verbose
from permits from permits
join view_company_permit_trends as trends join view_company_permit_trends as trends
on permits.permit_company = trends.permit_company"; on permits.permit_company = trends.permit_company
join counties
on permits.permit_county = counties.county_serial";
?> ?>
+3 -3
View File
@@ -47,7 +47,7 @@
<div class="col-lg-4 mb-3"> <div class="col-lg-4 mb-3">
<label class="form-label" for="permit_county">County</label> <label class="form-label" for="permit_county">County</label>
<select class="form-control form-control-sm multiple-dropdown" multiple="multiple" name="permit_county" id="permit_county" size="1"> <select class="form-control form-control-sm multiple-dropdown" multiple="multiple" name="permit_county[]" id="permit_county" size="1">
<xsl:apply-templates select="//counties"/> <xsl:apply-templates select="//counties"/>
</select> </select>
</div> </div>
@@ -364,7 +364,7 @@
<input type="hidden" name="action" value="print"/> <input type="hidden" name="action" value="print"/>
<input type="hidden" name="report" value="Print_All_PermitsBySubdivision"/> <input type="hidden" name="report" value="Print_All_PermitsBySubdivision"/>
<input type="hidden" name="subscription_serial" value="{{//subscriptions/record/subscription_serial}}"/> <input type="hidden" name="subscription_serial" value="{//subscriptions/record/subscription_serial}"/>
</form> </form>
@@ -375,7 +375,7 @@
<input type="hidden" name="action" value="print"/> <input type="hidden" name="action" value="print"/>
<input type="hidden" name="report" value="Print_Selected_PermitsBySubdivision"/> <input type="hidden" name="report" value="Print_Selected_PermitsBySubdivision"/>
<input type="hidden" name="selected_permits" value=""/> <input type="hidden" name="selected_permits" value=""/>
<input type="hidden" name="subscription_serial" value="{{//subscriptions/record/subscription_serial}}"/> <input type="hidden" name="subscription_serial" value="{//subscriptions/record/subscription_serial}"/>
</form> </form>