git commit all base code

This commit is contained in:
2026-06-30 21:34:42 -04:00
parent 11fdf7b164
commit 1a643d7935
1452 changed files with 433360 additions and 0 deletions
+86
View File
@@ -0,0 +1,86 @@
<?php
// ====================
// Export Permits - CSV
// ====================
class Export_AllPermitsByBuilderCSV extends Base {
// ==================
// Class Constructor.
// ==================
public function __construct() {
set_error_handler(array($this, "displayError"));
date_default_timezone_set(self::TIMEZONE);
}
// ===============
// Export the Data
// ===============
public function export() {
set_time_limit(0);
$subscription_serial = filter_input(INPUT_POST, "subscription_serial", FILTER_SANITIZE_NUMBER_INT) ?: 0;
$subscription = (new Subscriptions())->getSubscription($subscription_serial);
$permit_area = $subscription->record->subscription_area;
$projecttype = $subscription->record->subscription_projecttype;
$permits = (new PermitsByBuilder())->getAllPermits($permit_area, $projecttype);
header('Content-Type: text/csv');
header('Content-Disposition: attachment; filename="AllPermitsByBuilder.csv"');
$output = fopen('php://output', 'w');
$header = array('Builder/Company', 'Permits', 'Value', 'Current Year YTD', 'Current YTD Value', 'Last 12 Months', 'Address', 'Phone');
// Add CSV headers
fputcsv($output, $header, ',', '"', '\\');
$permit_ytd_value = 0.00;
$permit_value = 0.00;
foreach ($permits as $permit) {
$builder = $permit->permit_company;
$permitcount = $permit->permit_permit_count;
$permit_value = $permit->permit_value_verbose;
$currentyearytd = $permit->ytd_permits;
$permit_ytd_value = $permit->ytd_value;
$permit12monthprevpermits = $permit->previous_ytd_permits;
$address = "{$permit->permit_address} {$permit->permit_city} {$permit->permit_state} {$permit->permit_zip}";
$phone = $permit->permit_phone_verbose;
$permit_ytd_value = "$" . number_format((int) $permit_ytd_value, 2);
$permit_value = "$" . number_format((int) $permit_value, 2);
$permit_data = array($builder, $permitcount, $permit_value, $currentyearytd, $permit_ytd_value, $permit12monthprevpermits, $address, $phone);
fputcsv($output, $permit_data, ',', '"', '\\');
}
fclose($output);
exit();
}
// ===============
// Debug an Object
// ===============
public function debug($object = "") {
echo "<pre>";
print_r($object);
exit();
}
}
?>
+144
View File
@@ -0,0 +1,144 @@
<?php
// ==================
// Export Permits
// ==================
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
class Export_AllPermitsByBuilderExcel extends Base {
// ==================
// Class Constructor.
// ==================
public function __construct() {
set_error_handler(array($this, "displayError"));
date_default_timezone_set(self::TIMEZONE);
}
// ===============
// Export the Data
// ===============
public function export() {
set_time_limit(0);
$subscription_serial = filter_input(INPUT_POST, "subscription_serial", FILTER_SANITIZE_NUMBER_INT) ?: 0;
$subscription = (new Subscriptions())->getSubscription($subscription_serial);
$permit_area = $subscription->record->subscription_area;
$projecttype = $subscription->record->subscription_projecttype;
$permits = (new PermitsByBuilder())->getAllPermits($permit_area, $projecttype);
// Create the Spreadsheet.
$spreadsheet = new Spreadsheet();
$spreadsheet->getProperties()->setCreator("DEC International")
->setTitle("Permits")
->setSubject("Permits")
->setDescription("Permits")
->setKeywords("Permits")
->setCategory("Permits");
// Create the Base Sheet.
$spreadsheet->setActiveSheetIndex(0);
$spreadsheet->getActiveSheet()->setTitle("Permits");
// Format the Cells and Create the Headings.
$spreadsheet->getActiveSheet()->getColumnDimension("A")->setAutoSize(true);
$spreadsheet->getActiveSheet()->getColumnDimension("B")->setAutoSize(true);
$spreadsheet->getActiveSheet()->getColumnDimension("C")->setAutoSize(true);
$spreadsheet->getActiveSheet()->getColumnDimension("D")->setAutoSize(true);
$spreadsheet->getActiveSheet()->getColumnDimension("E")->setAutoSize(true);
$spreadsheet->getActiveSheet()->getColumnDimension("F")->setAutoSize(true);
$spreadsheet->getActiveSheet()->getColumnDimension("G")->setAutoSize(true);
$spreadsheet->getActiveSheet()->getColumnDimension("H")->setAutoSize(true);
$spreadsheet->getActiveSheet()->getStyle("A1:H1")->getFont()->setBold(true);
$spreadsheet->getActiveSheet()->getStyle("A1:H1")->getFill()->setFillType(\PhpOffice\PhpSpreadsheet\Style\Fill::FILL_SOLID)->getStartColor()->setARGB("D3D3D3");
$spreadsheet->setActiveSheetIndex(0)->setCellValue("A1", "Builder/Company")
->setCellValue("B1", "Permits")
->setCellValue("C1", "Value")
->setCellValue("D1", "Current Year YTD")
->setCellValue("E1", "Current Year YTD Value")
->setCellValue("F1", "Last 12 Months")
->setCellValue("G1", "Address")
->setCellValue("H1", "Phone");
$spreadsheet->getActiveSheet()->getStyle("A:A")->getNumberFormat()->setFormatCode(\PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_NUMBER);
$spreadsheet->getActiveSheet()->getStyle("C:C")->getNumberFormat()->setFormatCode(\PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_TEXT);
$spreadsheet->getActiveSheet()->getStyle("D:D")->getNumberFormat()->setFormatCode(\PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_TEXT);
$spreadsheet->getActiveSheet()->getStyle("E:E")->getNumberFormat()->setFormatCode(\PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_TEXT);
$spreadsheet->getActiveSheet()->getStyle("F:F")->getNumberFormat()->setFormatCode(\PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_TEXT);
$spreadsheet->getActiveSheet()->getStyle("G:G")->getNumberFormat()->setFormatCode(\PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_TEXT);
$spreadsheet->getActiveSheet()->getStyle("H:H")->getNumberFormat()->setFormatCode(\PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_TEXT);
$spreadsheet->getActiveSheet()->freezePane("A2");
// Create the Detail Rows.
$row = 2;
$permit_ytd_value = 0.00;
$permit_value = 0.00;
foreach ($permits as $permit) {
$address = "{$permit->permit_address} {$permit->permit_city}, {$permit->permit_state} {$permit->permit_zip}";
$permit_ytd_value = "$" . number_format((int) $permit->ytd_value, 2);
$permit_value = "$" . number_format((int) $permit->permit_value_verbose, 2);
$spreadsheet->getActiveSheet()->setCellValue("A" . $row, (string) $permit->permit_company);
$spreadsheet->getActiveSheet()->setCellValue("B" . $row, (string) $permit->permit_permit_count);
$spreadsheet->getActiveSheet()->setCellValue("C" . $row, (string) $permit_value);
$spreadsheet->getActiveSheet()->setCellValue("D" . $row, (string) $permit->ytd_permits);
$spreadsheet->getActiveSheet()->setCellValue("E" . $row, (string) $permit_ytd_value);
$spreadsheet->getActiveSheet()->setCellValue("F" . $row, (string) $permit->previous_ytd_permits);
$spreadsheet->getActiveSheet()->setCellValue("G" . $row, (string) $address);
$spreadsheet->getActiveSheet()->setCellValue("H" . $row, (string) $permit->permit_phone_verbose);
$row++;
}
$spreadsheet->setActiveSheetIndex(0);
// Download the spreadsheet.
header("Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
header("Content-disposition: attachment; filename=AllPermitsByBuilder.xlsx");
header("Cache-Control: max-age=0");
$excelWriter = new Xlsx($spreadsheet);
@ob_clean();
$excelWriter->save('php://output');
exit();
}
// ===============
// Debug an Object
// ===============
public function debug($object = "") {
echo "<pre>";
print_r($object);
exit();
}
}
?>
+256
View File
@@ -0,0 +1,256 @@
<?php
require_once ("tcpdf/tcpdf.php");
// ==========================
// Print Selected Work Orders
// ==========================
class Print_All_PermitsByBuilder extends Base {
// Variables.
private $output_type = "normal";
// ==================
// Class Constructor.
// ==================
public function __construct($output_type = "normal") {
set_error_handler(array($this, "displayError"));
date_default_timezone_set(self::TIMEZONE);
$this->output_type = $output_type;
}
// ================
// Print the Report
// ================
public function print() {
$report = new AllPermitsByBuilder_Print();
$report->subscription_serial = $_SESSION[self::REPORTS_POST]["subscription_serial"] ?? 0;
$report->output_type = $this->output_type;
ob_clean();
if ($this->output_type == "string") {
return $report->render();
} else {
$report->render();
}
}
}
// ==========================
// Class to Generate the .pdf
// ==========================
class AllPermitsByBuilder_Print extends TCPDF {
// Variables
public $subscription_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);
$subscription = (new Subscriptions())->getSubscription($this->subscription_serial);
$permit_area = $subscription->record->subscription_area;
$projecttype = $subscription->record->subscription_projecttype;
// Set report defaults
$this->title = "All Permit Records";
$this->SetFont("Calibri");
$this->SetMargins(10, 26, 10);
$this->SetHeaderMargin(10);
$this->SetFooterMargin(10);
$this->setCellPaddings(0, 0, 0, 0);
$this->setCellMargins(2, 0, 0, 0);
$this->addPage("L", "LETTER");
$rowCount = 0;
// Get the data for the report
$permits = (new PermitsByBuilder())->getAllPermits($permit_area, $projecttype);
// -------
// Permits
// -------
$permit_ytd_value = 0.00;
$permit_value = 0.00;
if ($permits->count() > 0) {
$this->Ln(7);
$this->SetFont("Calibri", "B", 10);
$this->Cell(52, 0, "", "", 0, "L", false, "", 3);
$this->Cell(10, 0, "", "", 0, "L", false, "", 3);
$this->Cell(20, 0, "", "", 0, "L", false, "", 3);
$this->Cell(15, 0, "Current", "", 0, "L", false, "", 3);
$this->Cell(20, 0, "Current Year", "", 0, "L", false, "", 3);
$this->Cell(15, 0, "Last", "", 0, "L", false, "", 3);
$this->Cell(85, 0, "", "", 0, "L", false, "", 3);
$this->Cell(25, 0, "", "", 0, "L", false, "", 3);
$this->Ln();
$this->Cell(52, 0, "Company/Builder", "B", 0, "L", false, "", 3);
$this->Cell(10, 0, "Permits", "B", 0, "L", false, "", 3);
$this->Cell(20, 0, "Value", "B", 0, "L", false, "", 3);
$this->Cell(15, 0, "Year YTD", "B", 0, "L", false, "", 3);
$this->Cell(20, 0, "YTD Value", "B", 0, "L", false, "", 3);
$this->Cell(15, 0, "12 Months", "B", 0, "L", false, "", 3);
$this->Cell(85, 0, "Address", "B", 0, "L", false, "", 3);
$this->Cell(25, 0, "Phone", "B", 0, "L", false, "", 3);
$this->SetFont("Calibri", "", 10);
$this->Ln(6);
foreach ($permits as $permit) {
$this->stripeLine($rowCount, 257);
$rowCount++;
$address = "{$permit->permit_address} {$permit->permit_city}, {$permit->permit_state} {$permit->permit_zip}";
$permit_ytd_value = "$" . number_format((int) $permit->ytd_value, 2);
$permit_value = "$" . number_format((int) $permit->permit_value_verbose, 2);
$this->Cell(52, 0, $permit->permit_company, 0, 0, "L", false, "", 3);
$this->Cell(10, 0, $permit->permit_permit_count, 0, 0, "C", false, "", 3);
$this->Cell(20, 0, $permit_value, 0, 0, "L", false, "", 3);
$this->Cell(15, 0, $permit->ytd_permits, 0, 0, "C", false, "", 3);
$this->Cell(20, 0, $permit_ytd_value, 0, 0, "L", false, "", 3);
$this->Cell(15, 0, $permit->previous_ytd_permits, 0, 0, "C", false, "", 3);
$this->Cell(85, 0, $address, 0, 0, "L", false, "", 3);
$this->Cell(25, 0, $permit->permit_phone_verbose, 0, 0, "L", false, "", 3);
$this->Ln(4);
if ($rowCount == 38) {
$this->AddPage("L", "LETTER");
$this->SetFont("Calibri", "B", 10);
$this->Cell(52, 0, "", "", 0, "L", false, "", 3);
$this->Cell(10, 0, "", "", 0, "L", false, "", 3);
$this->Cell(20, 0, "", "", 0, "L", false, "", 3);
$this->Cell(15, 0, "Current", "", 0, "L", false, "", 3);
$this->Cell(20, 0, "Current Year", "", 0, "L", false, "", 3);
$this->Cell(15, 0, "Last", "", 0, "L", false, "", 3);
$this->Cell(85, 0, "", "", 0, "L", false, "", 3);
$this->Cell(25, 0, "", "", 0, "L", false, "", 3);
$this->Ln();
$this->Cell(52, 0, "Company/Builder", "B", 0, "L", false, "", 3);
$this->Cell(10, 0, "Permits", "B", 0, "L", false, "", 3);
$this->Cell(20, 0, "Value", "B", 0, "L", false, "", 3);
$this->Cell(15, 0, "Year YTD", "B", 0, "L", false, "", 3);
$this->Cell(20, 0, "YTD Value", "B", 0, "L", false, "", 3);
$this->Cell(15, 0, "12 Months", "B", 0, "L", false, "", 3);
$this->Cell(85, 0, "Address", "B", 0, "L", false, "", 3);
$this->Cell(25, 0, "Phone", "B", 0, "L", false, "", 3);
$this->SetFont("Calibri", "", 10);
$this->Ln(6);
$rowCount = 0;
}
}
}
// --------------
// Return the pdf
// --------------
if ($this->output_type == "string") {
return $this->Output("AllPermitByBuilderRecords.pdf", "S");
} else {
$this->Output("AllPermitByBuilderRecords.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, 10, 25, 12);
$this->SetFont("Calibri", "B", 16);
$this->Cell(0, 6, "DEC International", 0, 0, "C");
$this->Ln(6);
$this->Cell(0, 6, "All Permit By Builder Records", 0, 1, "C");
}
// ======
// Footer
// ======
public function Footer() {
$this->SetFont("Calibri", "I", 8);
$X = $this->GetX();
$this->Cell(0, 10, "DEC International", 0, false, "C");
$this->SetX($X);
$this->Cell(40, 10, "Page " . $this->getAliasNumPage() . "/" . $this->getAliasNbPages(), 0, false, "L");
$this->Cell(0, 10, date("n/j/Y 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);
}
}
?>