Skip to content

Commit

Permalink
Added subdistrict recommendations to the create and edit form for plot
Browse files Browse the repository at this point in the history
Fixes #49
  • Loading branch information
MasterZydra committed Feb 28, 2024
1 parent 5841689 commit d5a0f24
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ Types of changes: `Added`, `Changed`, `Deprecate`, `Removed`, `Fixed`, `Secruity

## [Unreleased]

### Added
- Added subdistrict recommendations to the create and edit form for plot

## v2.2.1 - 27.02.2024 - Added developer setting

### Added
Expand Down
21 changes: 21 additions & 0 deletions resources/Views/Components/datalistSubdistricts.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

use Framework\Database\Database;
use Framework\Database\QueryBuilder;

$dataSet = Database::executeBuilder(QueryBuilder::new('plots')->select('DISTINCT subdistrict')->orderBy('subdistrict'));

$subdistricts = [];
if ($dataSet !== false) {
while ($row = $dataSet->fetch_assoc()) {
$subdistricts[] = $row['subdistrict'];
}
}

?>

<datalist id="subdistricts">
<?php foreach ($subdistricts as $subdistrict) { ?>
<option value="<?= $subdistrict ?>"><?= $subdistrict ?></option>
<?php } ?>
</datalist>
5 changes: 3 additions & 2 deletions resources/Views/entities/plot/create.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@
<input id="name" name="name" type="text" required><br>

<label for="subdistrict" class="required"><?= __('Subdistrict') ?>:</label><br>
<input id="subdistrict" name="subdistrict" type="text" required><br>

<input id="subdistrict" name="subdistrict" type="text" list="subdistricts" autocomplete="off" required><br>
<?= component('datalistSubdistricts') ?>

<?= component('supplierSelect') ?><br>

<button><?= __('Create') ?></button>
Expand Down
3 changes: 2 additions & 1 deletion resources/Views/entities/plot/edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
<input id="name" name="name" type="text" value="<?= $plot->getName() ?>" required><br>

<label for="subdistrict" class="required"><?= __('Subdistrict') ?>:</label><br>
<input id="subdistrict" name="subdistrict" type="text" value="<?= $plot->getSubdistrict() ?>" required><br>
<input id="subdistrict" name="subdistrict" type="text" value="<?= $plot->getSubdistrict() ?>" list="subdistricts" autocomplete="off" required><br>
<?= component('datalistSubdistricts') ?>

<?= component('supplierSelect', ['selected' => $plot->getSupplierId()]) ?><br>

Expand Down

0 comments on commit d5a0f24

Please sign in to comment.