<?php
namespace PHPMaker2020\hostelmgr20;

// 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
$hostel_list = new hostel_list();

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

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

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

// Page Rendering event
$hostel_list->Page_Render();
?>
<?php include_once "header.php"; ?>
<?php if (!$hostel_list->isExport()) { ?>
<script>
var fhostellist, currentPageID;
loadjs.ready("head", function() {

	// Form object
	currentPageID = ew.PAGE_ID = "list";
	fhostellist = currentForm = new ew.Form("fhostellist", "list");
	fhostellist.formKeyCountName = '<?php echo $hostel_list->FormKeyCountName ?>';
	loadjs.done("fhostellist");
});
var fhostellistsrch;
loadjs.ready("head", function() {

	// Form object for search
	fhostellistsrch = currentSearchForm = new ew.Form("fhostellistsrch");

	// Dynamic selection lists
	// Filters

	fhostellistsrch.filterList = <?php echo $hostel_list->getFilterList() ?>;
	loadjs.done("fhostellistsrch");
});
</script>
<script>
loadjs.ready("head", function() {

	// Client script
	// Write your client script here, no need to add script tags.

});
</script>
<?php } ?>
<?php if (!$hostel_list->isExport()) { ?>
<div class="btn-toolbar ew-toolbar">
<?php if ($hostel_list->TotalRecords > 0 && $hostel_list->ExportOptions->visible()) { ?>
<?php $hostel_list->ExportOptions->render("body") ?>
<?php } ?>
<?php if ($hostel_list->ImportOptions->visible()) { ?>
<?php $hostel_list->ImportOptions->render("body") ?>
<?php } ?>
<?php if ($hostel_list->SearchOptions->visible()) { ?>
<?php $hostel_list->SearchOptions->render("body") ?>
<?php } ?>
<?php if ($hostel_list->FilterOptions->visible()) { ?>
<?php $hostel_list->FilterOptions->render("body") ?>
<?php } ?>
<div class="clearfix"></div>
</div>
<?php } ?>
<?php
$hostel_list->renderOtherOptions();
?>
<?php if ($Security->CanSearch()) { ?>
<?php if (!$hostel_list->isExport() && !$hostel->CurrentAction) { ?>
<form name="fhostellistsrch" id="fhostellistsrch" class="form-inline ew-form ew-ext-search-form" action="<?php echo CurrentPageName() ?>">
<div id="fhostellistsrch-search-panel" class="<?php echo $hostel_list->SearchPanelClass ?>">
<input type="hidden" name="cmd" value="search">
<input type="hidden" name="t" value="hostel">
	<div class="ew-extended-search">
<div id="xsr_<?php echo $hostel_list->SearchRowCount + 1 ?>" class="ew-row d-sm-flex">
	<div class="ew-quick-search input-group">
		<input type="text" name="<?php echo Config("TABLE_BASIC_SEARCH") ?>" id="<?php echo Config("TABLE_BASIC_SEARCH") ?>" class="form-control" value="<?php echo HtmlEncode($hostel_list->BasicSearch->getKeyword()) ?>" placeholder="<?php echo HtmlEncode($Language->phrase("Search")) ?>">
		<input type="hidden" name="<?php echo Config("TABLE_BASIC_SEARCH_TYPE") ?>" id="<?php echo Config("TABLE_BASIC_SEARCH_TYPE") ?>" value="<?php echo HtmlEncode($hostel_list->BasicSearch->getType()) ?>">
		<div class="input-group-append">
			<button class="btn btn-primary" name="btn-submit" id="btn-submit" type="submit"><?php echo $Language->phrase("SearchBtn") ?></button>
			<button type="button" data-toggle="dropdown" class="btn btn-primary dropdown-toggle dropdown-toggle-split" aria-haspopup="true" aria-expanded="false"><span id="searchtype"><?php echo $hostel_list->BasicSearch->getTypeNameShort() ?></span></button>
			<div class="dropdown-menu dropdown-menu-right">
				<a class="dropdown-item<?php if ($hostel_list->BasicSearch->getType() == "") { ?> active<?php } ?>" href="#" onclick="return ew.setSearchType(this);"><?php echo $Language->phrase("QuickSearchAuto") ?></a>
				<a class="dropdown-item<?php if ($hostel_list->BasicSearch->getType() == "=") { ?> active<?php } ?>" href="#" onclick="return ew.setSearchType(this, '=');"><?php echo $Language->phrase("QuickSearchExact") ?></a>
				<a class="dropdown-item<?php if ($hostel_list->BasicSearch->getType() == "AND") { ?> active<?php } ?>" href="#" onclick="return ew.setSearchType(this, 'AND');"><?php echo $Language->phrase("QuickSearchAll") ?></a>
				<a class="dropdown-item<?php if ($hostel_list->BasicSearch->getType() == "OR") { ?> active<?php } ?>" href="#" onclick="return ew.setSearchType(this, 'OR');"><?php echo $Language->phrase("QuickSearchAny") ?></a>
			</div>
		</div>
	</div>
</div>
	</div><!-- /.ew-extended-search -->
</div><!-- /.ew-search-panel -->
</form>
<?php } ?>
<?php } ?>
<?php $hostel_list->showPageHeader(); ?>
<?php
$hostel_list->showMessage();
?>
<?php if ($hostel_list->TotalRecords > 0 || $hostel->CurrentAction) { ?>
<div class="card ew-card ew-grid<?php if ($hostel_list->isAddOrEdit()) { ?> ew-grid-add-edit<?php } ?> hostel">
<?php if (!$hostel_list->isExport()) { ?>
<div class="card-header ew-grid-upper-panel">
<?php if (!$hostel_list->isGridAdd()) { ?>
<form name="ew-pager-form" class="form-inline ew-form ew-pager-form" action="<?php echo CurrentPageName() ?>">
<?php echo $hostel_list->Pager->render() ?>
</form>
<?php } ?>
<div class="ew-list-other-options">
<?php $hostel_list->OtherOptions->render("body") ?>
</div>
<div class="clearfix"></div>
</div>
<?php } ?>
<form name="fhostellist" id="fhostellist" class="form-inline ew-form ew-list-form" action="<?php echo CurrentPageName() ?>" method="post">
<?php if ($Page->CheckToken) { ?>
<input type="hidden" name="<?php echo Config("TOKEN_NAME") ?>" value="<?php echo $Page->Token ?>">
<?php } ?>
<input type="hidden" name="t" value="hostel">
<div id="gmp_hostel" class="<?php echo ResponsiveTableClass() ?>card-body ew-grid-middle-panel">
<?php if ($hostel_list->TotalRecords > 0 || $hostel_list->isGridEdit()) { ?>
<table id="tbl_hostellist" class="table ew-table"><!-- .ew-table -->
<thead>
	<tr class="ew-table-header">
<?php

// Header row
$hostel->RowType = ROWTYPE_HEADER;

// Render list options
$hostel_list->renderListOptions();

// Render list options (header, left)
$hostel_list->ListOptions->render("header", "left");
?>
<?php if ($hostel_list->id->Visible) { // id ?>
	<?php if ($hostel_list->SortUrl($hostel_list->id) == "") { ?>
		<th data-name="id" class="<?php echo $hostel_list->id->headerCellClass() ?>"><div id="elh_hostel_id" class="hostel_id"><div class="ew-table-header-caption"><?php echo $hostel_list->id->caption() ?></div></div></th>
	<?php } else { ?>
		<th data-name="id" class="<?php echo $hostel_list->id->headerCellClass() ?>"><div class="ew-pointer" onclick="ew.sort(event, '<?php echo $hostel_list->SortUrl($hostel_list->id) ?>', 1);"><div id="elh_hostel_id" class="hostel_id">
			<div class="ew-table-header-btn"><span class="ew-table-header-caption"><?php echo $hostel_list->id->caption() ?></span><span class="ew-table-header-sort"><?php if ($hostel_list->id->getSort() == "ASC") { ?><i class="fas fa-sort-up"></i><?php } elseif ($hostel_list->id->getSort() == "DESC") { ?><i class="fas fa-sort-down"></i><?php } ?></span></div>
		</div></div></th>
	<?php } ?>
<?php } ?>
<?php if ($hostel_list->Hostel_Name->Visible) { // Hostel_Name ?>
	<?php if ($hostel_list->SortUrl($hostel_list->Hostel_Name) == "") { ?>
		<th data-name="Hostel_Name" class="<?php echo $hostel_list->Hostel_Name->headerCellClass() ?>"><div id="elh_hostel_Hostel_Name" class="hostel_Hostel_Name"><div class="ew-table-header-caption"><?php echo $hostel_list->Hostel_Name->caption() ?></div></div></th>
	<?php } else { ?>
		<th data-name="Hostel_Name" class="<?php echo $hostel_list->Hostel_Name->headerCellClass() ?>"><div class="ew-pointer" onclick="ew.sort(event, '<?php echo $hostel_list->SortUrl($hostel_list->Hostel_Name) ?>', 1);"><div id="elh_hostel_Hostel_Name" class="hostel_Hostel_Name">
			<div class="ew-table-header-btn"><span class="ew-table-header-caption"><?php echo $hostel_list->Hostel_Name->caption() ?><?php echo $Language->phrase("SrchLegend") ?></span><span class="ew-table-header-sort"><?php if ($hostel_list->Hostel_Name->getSort() == "ASC") { ?><i class="fas fa-sort-up"></i><?php } elseif ($hostel_list->Hostel_Name->getSort() == "DESC") { ?><i class="fas fa-sort-down"></i><?php } ?></span></div>
		</div></div></th>
	<?php } ?>
<?php } ?>
<?php if ($hostel_list->Fee->Visible) { // Fee ?>
	<?php if ($hostel_list->SortUrl($hostel_list->Fee) == "") { ?>
		<th data-name="Fee" class="<?php echo $hostel_list->Fee->headerCellClass() ?>"><div id="elh_hostel_Fee" class="hostel_Fee"><div class="ew-table-header-caption"><?php echo $hostel_list->Fee->caption() ?></div></div></th>
	<?php } else { ?>
		<th data-name="Fee" class="<?php echo $hostel_list->Fee->headerCellClass() ?>"><div class="ew-pointer" onclick="ew.sort(event, '<?php echo $hostel_list->SortUrl($hostel_list->Fee) ?>', 1);"><div id="elh_hostel_Fee" class="hostel_Fee">
			<div class="ew-table-header-btn"><span class="ew-table-header-caption"><?php echo $hostel_list->Fee->caption() ?></span><span class="ew-table-header-sort"><?php if ($hostel_list->Fee->getSort() == "ASC") { ?><i class="fas fa-sort-up"></i><?php } elseif ($hostel_list->Fee->getSort() == "DESC") { ?><i class="fas fa-sort-down"></i><?php } ?></span></div>
		</div></div></th>
	<?php } ?>
<?php } ?>
<?php if ($hostel_list->Remarks->Visible) { // Remarks ?>
	<?php if ($hostel_list->SortUrl($hostel_list->Remarks) == "") { ?>
		<th data-name="Remarks" class="<?php echo $hostel_list->Remarks->headerCellClass() ?>"><div id="elh_hostel_Remarks" class="hostel_Remarks"><div class="ew-table-header-caption"><?php echo $hostel_list->Remarks->caption() ?></div></div></th>
	<?php } else { ?>
		<th data-name="Remarks" class="<?php echo $hostel_list->Remarks->headerCellClass() ?>"><div class="ew-pointer" onclick="ew.sort(event, '<?php echo $hostel_list->SortUrl($hostel_list->Remarks) ?>', 1);"><div id="elh_hostel_Remarks" class="hostel_Remarks">
			<div class="ew-table-header-btn"><span class="ew-table-header-caption"><?php echo $hostel_list->Remarks->caption() ?><?php echo $Language->phrase("SrchLegend") ?></span><span class="ew-table-header-sort"><?php if ($hostel_list->Remarks->getSort() == "ASC") { ?><i class="fas fa-sort-up"></i><?php } elseif ($hostel_list->Remarks->getSort() == "DESC") { ?><i class="fas fa-sort-down"></i><?php } ?></span></div>
		</div></div></th>
	<?php } ?>
<?php } ?>
<?php

// Render list options (header, right)
$hostel_list->ListOptions->render("header", "right");
?>
	</tr>
</thead>
<tbody>
<?php
if ($hostel_list->ExportAll && $hostel_list->isExport()) {
	$hostel_list->StopRecord = $hostel_list->TotalRecords;
} else {

	// Set the last record to display
	if ($hostel_list->TotalRecords > $hostel_list->StartRecord + $hostel_list->DisplayRecords - 1)
		$hostel_list->StopRecord = $hostel_list->StartRecord + $hostel_list->DisplayRecords - 1;
	else
		$hostel_list->StopRecord = $hostel_list->TotalRecords;
}
$hostel_list->RecordCount = $hostel_list->StartRecord - 1;
if ($hostel_list->Recordset && !$hostel_list->Recordset->EOF) {
	$hostel_list->Recordset->moveFirst();
	$selectLimit = $hostel_list->UseSelectLimit;
	if (!$selectLimit && $hostel_list->StartRecord > 1)
		$hostel_list->Recordset->move($hostel_list->StartRecord - 1);
} elseif (!$hostel->AllowAddDeleteRow && $hostel_list->StopRecord == 0) {
	$hostel_list->StopRecord = $hostel->GridAddRowCount;
}

// Initialize aggregate
$hostel->RowType = ROWTYPE_AGGREGATEINIT;
$hostel->resetAttributes();
$hostel_list->renderRow();
while ($hostel_list->RecordCount < $hostel_list->StopRecord) {
	$hostel_list->RecordCount++;
	if ($hostel_list->RecordCount >= $hostel_list->StartRecord) {
		$hostel_list->RowCount++;

		// Set up key count
		$hostel_list->KeyCount = $hostel_list->RowIndex;

		// Init row class and style
		$hostel->resetAttributes();
		$hostel->CssClass = "";
		if ($hostel_list->isGridAdd()) {
		} else {
			$hostel_list->loadRowValues($hostel_list->Recordset); // Load row values
		}
		$hostel->RowType = ROWTYPE_VIEW; // Render view

		// Set up row id / data-rowindex
		$hostel->RowAttrs->merge(["data-rowindex" => $hostel_list->RowCount, "id" => "r" . $hostel_list->RowCount . "_hostel", "data-rowtype" => $hostel->RowType]);

		// Render row
		$hostel_list->renderRow();

		// Render list options
		$hostel_list->renderListOptions();
?>
	<tr <?php echo $hostel->rowAttributes() ?>>
<?php

// Render list options (body, left)
$hostel_list->ListOptions->render("body", "left", $hostel_list->RowCount);
?>
	<?php if ($hostel_list->id->Visible) { // id ?>
		<td data-name="id" <?php echo $hostel_list->id->cellAttributes() ?>>
<span id="el<?php echo $hostel_list->RowCount ?>_hostel_id">
<span<?php echo $hostel_list->id->viewAttributes() ?>><?php echo $hostel_list->id->getViewValue() ?></span>
</span>
</td>
	<?php } ?>
	<?php if ($hostel_list->Hostel_Name->Visible) { // Hostel_Name ?>
		<td data-name="Hostel_Name" <?php echo $hostel_list->Hostel_Name->cellAttributes() ?>>
<span id="el<?php echo $hostel_list->RowCount ?>_hostel_Hostel_Name">
<span<?php echo $hostel_list->Hostel_Name->viewAttributes() ?>><?php echo $hostel_list->Hostel_Name->getViewValue() ?></span>
</span>
</td>
	<?php } ?>
	<?php if ($hostel_list->Fee->Visible) { // Fee ?>
		<td data-name="Fee" <?php echo $hostel_list->Fee->cellAttributes() ?>>
<span id="el<?php echo $hostel_list->RowCount ?>_hostel_Fee">
<span<?php echo $hostel_list->Fee->viewAttributes() ?>><?php echo $hostel_list->Fee->getViewValue() ?></span>
</span>
</td>
	<?php } ?>
	<?php if ($hostel_list->Remarks->Visible) { // Remarks ?>
		<td data-name="Remarks" <?php echo $hostel_list->Remarks->cellAttributes() ?>>
<span id="el<?php echo $hostel_list->RowCount ?>_hostel_Remarks">
<span<?php echo $hostel_list->Remarks->viewAttributes() ?>><?php echo $hostel_list->Remarks->getViewValue() ?></span>
</span>
</td>
	<?php } ?>
<?php

// Render list options (body, right)
$hostel_list->ListOptions->render("body", "right", $hostel_list->RowCount);
?>
	</tr>
<?php
	}
	if (!$hostel_list->isGridAdd())
		$hostel_list->Recordset->moveNext();
}
?>
</tbody>
</table><!-- /.ew-table -->
<?php } ?>
</div><!-- /.ew-grid-middle-panel -->
<?php if (!$hostel->CurrentAction) { ?>
<input type="hidden" name="action" id="action" value="">
<?php } ?>
</form><!-- /.ew-list-form -->
<?php

// Close recordset
if ($hostel_list->Recordset)
	$hostel_list->Recordset->Close();
?>
<?php if (!$hostel_list->isExport()) { ?>
<div class="card-footer ew-grid-lower-panel">
<?php if (!$hostel_list->isGridAdd()) { ?>
<form name="ew-pager-form" class="form-inline ew-form ew-pager-form" action="<?php echo CurrentPageName() ?>">
<?php echo $hostel_list->Pager->render() ?>
</form>
<?php } ?>
<div class="ew-list-other-options">
<?php $hostel_list->OtherOptions->render("body", "bottom") ?>
</div>
<div class="clearfix"></div>
</div>
<?php } ?>
</div><!-- /.ew-grid -->
<?php } ?>
<?php if ($hostel_list->TotalRecords == 0 && !$hostel->CurrentAction) { // Show other options ?>
<div class="ew-list-other-options">
<?php $hostel_list->OtherOptions->render("body") ?>
</div>
<div class="clearfix"></div>
<?php } ?>
<?php
$hostel_list->showPageFooter();
if (Config("DEBUG"))
	echo GetDebugMessage();
?>
<?php if (!$hostel_list->isExport()) { ?>
<script>
loadjs.ready("load", function() {

	// Startup script
	// Write your table-specific startup script here
	// console.log("page loaded");

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