<?php
namespace PHPMaker2019\project_germanos;

// Session
if (session_status() !== PHP_SESSION_ACTIVE)
	session_start(); // Init session data

// Output buffering
ob_start(); 

// Autoload
include_once "autoload.php";
?>
<?php

// Write header
WriteHeader(FALSE);

// Create page object
$Cases_Report1_report = new Cases_Report1_report();

// Run the page
$Cases_Report1_report->run();

// Setup login status
SetupLoginStatus();
SetClientVar("login", LoginStatus());

// Global Page Rendering event (in userfn*.php)
Page_Rendering();

// Page Rendering event
$Cases_Report1_report->Page_Render();
?>
<?php include_once "header.php" ?>
<?php if (!$Cases_Report1->isExport()) { ?>
<script>

// Write your client script here, no need to add script tags.
</script>
<?php } ?>
<?php
$Cases_Report1_report->DefaultFilter = "";
$Cases_Report1_report->ReportFilter = $Cases_Report1_report->DefaultFilter;
if (!$Security->canReport()) {
	if ($Cases_Report1_report->ReportFilter <> "") $Cases_Report1_report->ReportFilter .= " AND ";
	$Cases_Report1_report->ReportFilter .= "(0=1)";
}
if ($Cases_Report1_report->DbDetailFilter <> "") {
	if ($Cases_Report1_report->ReportFilter <> "") $Cases_Report1_report->ReportFilter .= " AND ";
	$Cases_Report1_report->ReportFilter .= "(" . $Cases_Report1_report->DbDetailFilter . ")";
}
$ReportConn = &$Cases_Report1_report->getConnection();

// Set up filter and load group level SQL
$Cases_Report1->CurrentFilter = $Cases_Report1_report->ReportFilter;
$Cases_Report1_report->ReportSql = $Cases_Report1->getGroupSql();

// Load recordset
$Cases_Report1_report->Recordset = $ReportConn->Execute($Cases_Report1_report->ReportSql);
$Cases_Report1_report->RecordExists = !$Cases_Report1_report->Recordset->EOF;
?>
<?php if (!$Cases_Report1->isExport()) { ?>
<?php if ($Cases_Report1_report->RecordExists) { ?>
<div class="ew-view-export-options"><?php $Cases_Report1_report->ExportOptions->render("body") ?></div>
<?php } ?>
<?php } ?>
<?php $Cases_Report1_report->showPageHeader(); ?>
<table class="ew-report-table">
<?php

// Get First Row
if ($Cases_Report1_report->RecordExists) {
	$Cases_Report1->FileNumber->setDbValue($Cases_Report1_report->Recordset->fields('FileNumber'));
	$Cases_Report1_report->ReportGroups[0] = $Cases_Report1->FileNumber->DbValue;
	$Cases_Report1->FirstName->setDbValue($Cases_Report1_report->Recordset->fields('FirstName'));
	$Cases_Report1_report->ReportGroups[1] = $Cases_Report1->FirstName->DbValue;
}
$Cases_Report1_report->RecCnt = 0;
$Cases_Report1_report->ReportCounts[0] = 0;
$Cases_Report1_report->checkLevelBreak();
while (!$Cases_Report1_report->Recordset->EOF) {

	// Render for view
	$Cases_Report1->RowType = ROWTYPE_VIEW;
	$Cases_Report1->resetAttributes();
	$Cases_Report1_report->renderRow();

	// Show group headers
	if ($Cases_Report1_report->LevelBreak[1]) { // Reset counter and aggregation
?>
	<tr><td colspan=2 class="ew-group-field"><?php echo $Cases_Report1->FileNumber->caption() ?></td>
	<td colspan="7" class="ew-group-name">
<span<?php echo $Cases_Report1->FileNumber->viewAttributes() ?>>
<?php echo $Cases_Report1->FileNumber->getViewValue() ?></span>
</td></tr>
<?php
	}
	if ($Cases_Report1_report->LevelBreak[2]) { // Reset counter and aggregation
?>
	<tr><td><div class="ew-group-indent"></div></td><td class="ew-group-field"><?php echo $Cases_Report1->FirstName->caption() ?></td>
	<td colspan="7" class="ew-group-name">
<span<?php echo $Cases_Report1->FirstName->viewAttributes() ?>>
<?php echo $Cases_Report1->FirstName->getViewValue() ?></span>
</td></tr>
<?php
	}

	// Get detail records
	$Cases_Report1_report->ReportFilter = $Cases_Report1_report->DefaultFilter;
	if ($Cases_Report1_report->ReportFilter <> "") $Cases_Report1_report->ReportFilter .= " AND ";
	if ($Cases_Report1->FileNumber->CurrentValue == NULL) {
		$Cases_Report1_report->ReportFilter .= "(`FileNumber` IS NULL)";
	} else {
		$Cases_Report1_report->ReportFilter .= "(`FileNumber` = " . QuotedValue($Cases_Report1->FileNumber->CurrentValue, DATATYPE_STRING, $Cases_Report1_report->Dbid) . ")";
	}
	if ($Cases_Report1_report->ReportFilter <> "") $Cases_Report1_report->ReportFilter .= " AND ";
	if ($Cases_Report1->FirstName->CurrentValue == NULL) {
		$Cases_Report1_report->ReportFilter .= "(`FirstName` IS NULL)";
	} else {
		$Cases_Report1_report->ReportFilter .= "(`FirstName` = " . QuotedValue($Cases_Report1->FirstName->CurrentValue, DATATYPE_STRING, $Cases_Report1_report->Dbid) . ")";
	}
	if ($Cases_Report1_report->DbDetailFilter <> "") {
		if ($Cases_Report1_report->ReportFilter <> "")
			$Cases_Report1_report->ReportFilter .= " AND ";
		$Cases_Report1_report->ReportFilter .= "(" . $Cases_Report1_report->DbDetailFilter . ")";
	}
	if (!$Security->canReport()) {
		if ($Cases_Report1_report->ReportFilter <> "")
			$Cases_Report1_report->ReportFilter .= " AND ";
		$Cases_Report1_report->ReportFilter .= "(0=1)";
	}

	// Set up detail SQL
	$Cases_Report1->CurrentFilter = $Cases_Report1_report->ReportFilter;
	$Cases_Report1_report->ReportSql = $Cases_Report1->getDetailSql();

	// Load detail records
	$Cases_Report1_report->DetailRecordset = $ReportConn->execute($Cases_Report1_report->ReportSql);
	$Cases_Report1_report->DtlRecordCount = $Cases_Report1_report->DetailRecordset->RecordCount();

	// Initialize aggregates
	if (!$Cases_Report1_report->DetailRecordset->EOF) {
		$Cases_Report1_report->RecCnt++;
	}
	if ($Cases_Report1_report->RecCnt == 1) {
		$Cases_Report1_report->ReportCounts[0] = 0;
	}
	for ($i = 1; $i <= 2; $i++) {
		if ($Cases_Report1_report->LevelBreak[$i]) { // Reset counter and aggregation
			$Cases_Report1_report->ReportCounts[$i] = 0;
		}
	}
	$Cases_Report1_report->ReportCounts[0] += $Cases_Report1_report->DtlRecordCount;
	$Cases_Report1_report->ReportCounts[1] += $Cases_Report1_report->DtlRecordCount;
	$Cases_Report1_report->ReportCounts[2] += $Cases_Report1_report->DtlRecordCount;
	if ($Cases_Report1_report->RecordExists) {
?>
	<tr>
		<td><div class="ew-group-indent"></div></td>
		<td><div class="ew-group-indent"></div></td>
		<td class="ew-group-header"><?php echo $Cases_Report1->EnvelopeNumber->caption() ?></td>
		<td class="ew-group-header"><?php echo $Cases_Report1->CaseNumber->caption() ?></td>
		<td class="ew-group-header"><?php echo $Cases_Report1->MiddleName->caption() ?></td>
		<td class="ew-group-header"><?php echo $Cases_Report1->LastName->caption() ?></td>
		<td class="ew-group-header"><?php echo $Cases_Report1->FirstName1->caption() ?></td>
		<td class="ew-group-header"><?php echo $Cases_Report1->MiddleName1->caption() ?></td>
		<td class="ew-group-header"><?php echo $Cases_Report1->LastName1->caption() ?></td>
	</tr>
<?php
	}
	while (!$Cases_Report1_report->DetailRecordset->EOF) {
		$Cases_Report1_report->RowCnt++;
		$Cases_Report1->EnvelopeNumber->setDbValue($Cases_Report1_report->DetailRecordset->fields('EnvelopeNumber'));
		$Cases_Report1->CaseNumber->setDbValue($Cases_Report1_report->DetailRecordset->fields('CaseNumber'));
		$Cases_Report1->MiddleName->setDbValue($Cases_Report1_report->DetailRecordset->fields('MiddleName'));
		$Cases_Report1->LastName->setDbValue($Cases_Report1_report->DetailRecordset->fields('LastName'));
		$Cases_Report1->FirstName1->setDbValue($Cases_Report1_report->DetailRecordset->fields('FirstName1'));
		$Cases_Report1->MiddleName1->setDbValue($Cases_Report1_report->DetailRecordset->fields('MiddleName1'));
		$Cases_Report1->LastName1->setDbValue($Cases_Report1_report->DetailRecordset->fields('LastName1'));

		// Render for view
		$Cases_Report1->RowType = ROWTYPE_VIEW;
		$Cases_Report1->resetAttributes();
		$Cases_Report1_report->renderRow();
?>
	<tr>
		<td><div class="ew-group-indent"></div></td>
		<td><div class="ew-group-indent"></div></td>
		<td<?php echo $Cases_Report1->EnvelopeNumber->cellAttributes() ?>>
<span<?php echo $Cases_Report1->EnvelopeNumber->viewAttributes() ?>>
<?php echo $Cases_Report1->EnvelopeNumber->getViewValue() ?></span>
</td>
		<td<?php echo $Cases_Report1->CaseNumber->cellAttributes() ?>>
<span<?php echo $Cases_Report1->CaseNumber->viewAttributes() ?>>
<?php echo $Cases_Report1->CaseNumber->getViewValue() ?></span>
</td>
		<td<?php echo $Cases_Report1->MiddleName->cellAttributes() ?>>
<span<?php echo $Cases_Report1->MiddleName->viewAttributes() ?>>
<?php echo $Cases_Report1->MiddleName->getViewValue() ?></span>
</td>
		<td<?php echo $Cases_Report1->LastName->cellAttributes() ?>>
<span<?php echo $Cases_Report1->LastName->viewAttributes() ?>>
<?php echo $Cases_Report1->LastName->getViewValue() ?></span>
</td>
		<td<?php echo $Cases_Report1->FirstName1->cellAttributes() ?>>
<span<?php echo $Cases_Report1->FirstName1->viewAttributes() ?>>
<?php echo $Cases_Report1->FirstName1->getViewValue() ?></span>
</td>
		<td<?php echo $Cases_Report1->MiddleName1->cellAttributes() ?>>
<span<?php echo $Cases_Report1->MiddleName1->viewAttributes() ?>>
<?php echo $Cases_Report1->MiddleName1->getViewValue() ?></span>
</td>
		<td<?php echo $Cases_Report1->LastName1->cellAttributes() ?>>
<span<?php echo $Cases_Report1->LastName1->viewAttributes() ?>>
<?php echo $Cases_Report1->LastName1->getViewValue() ?></span>
</td>
	</tr>
<?php
		$Cases_Report1_report->DetailRecordset->moveNext();
	}
	$Cases_Report1_report->DetailRecordset->close();

	// Save old group data
	$Cases_Report1_report->ReportGroups[0] = $Cases_Report1->FileNumber->CurrentValue;
	$Cases_Report1_report->ReportGroups[1] = $Cases_Report1->FirstName->CurrentValue;

	// Get next record
	$Cases_Report1_report->Recordset->moveNext();
	if ($Cases_Report1_report->Recordset->EOF) {
		$Cases_Report1_report->RecCnt = 0; // EOF, force all level breaks
	} else {
		$Cases_Report1->FileNumber->setDbValue($Cases_Report1_report->Recordset->fields('FileNumber'));
		$Cases_Report1->FirstName->setDbValue($Cases_Report1_report->Recordset->fields('FirstName'));
	}
	$Cases_Report1_report->checkLevelBreak();

	// Show footers
	if ($Cases_Report1_report->LevelBreak[2]) {
		$Cases_Report1->FirstName->CurrentValue = $Cases_Report1_report->ReportGroups[1];

		// Render row for view
		$Cases_Report1->RowType = ROWTYPE_VIEW;
		$Cases_Report1->resetAttributes();
		$Cases_Report1_report->renderRow();
		$Cases_Report1->FirstName->CurrentValue = $Cases_Report1->FirstName->DbValue;
?>
<?php
}
	if ($Cases_Report1_report->LevelBreak[1]) {
		$Cases_Report1->FileNumber->CurrentValue = $Cases_Report1_report->ReportGroups[0];

		// Render row for view
		$Cases_Report1->RowType = ROWTYPE_VIEW;
		$Cases_Report1->resetAttributes();
		$Cases_Report1_report->renderRow();
		$Cases_Report1->FileNumber->CurrentValue = $Cases_Report1->FileNumber->DbValue;
?>
<?php
}
}

// Close recordset
$Cases_Report1_report->Recordset->close();
?>
<?php if ($Cases_Report1_report->RecordExists) { ?>
	<tr><td colspan="9">&nbsp;<br></td></tr>
	<tr><td colspan="9" class="ew-grand-summary"><?php echo $Language->Phrase("RptGrandTotal") ?>&nbsp;(<?php echo FormatNumber($Cases_Report1_report->ReportCounts[0], 0) ?>&nbsp;<?php echo $Language->Phrase("RptDtlRec") ?>)</td></tr>
<?php } ?>
<?php if ($Cases_Report1_report->RecordExists) { ?>
	<tr><td colspan=9>&nbsp;<br></td></tr>
<?php } else { ?>
	<tr><td><?php echo $Language->phrase("NoRecord") ?></td></tr>
<?php } ?>
</table>
<?php
$Cases_Report1_report->showPageFooter();
if (DEBUG_ENABLED)
	echo GetDebugMessage();
?>
<?php if (!$Cases_Report1->isExport()) { ?>
<script>

// Write your table-specific startup script here
// document.write("page loaded");

</script>
<?php } ?>
<?php include_once "footer.php" ?>
<?php
$Cases_Report1_report->terminate();
?>
