Browse Source

ajoute le formulaire d'entrée

master
vince vince 3 years ago
parent
commit
bea6165760
1 changed files with 21 additions and 3 deletions
  1. +21
    -3
      index.php

+ 21
- 3
index.php View File

@ -7,7 +7,8 @@ define('SUPPLIER_REGEX', '/^[A-Za-z]\w{0,31}$/');
define('EVENT_REGEX', '/^\d{4}\-[01]\d\-[0123]\d$/'); define('EVENT_REGEX', '/^\d{4}\-[01]\d\-[0123]\d$/');
define('ACTION_REGEX', '/^[a-z]{1,16}$/i'); define('ACTION_REGEX', '/^[a-z]{1,16}$/i');
$requestUrl = trim(str_replace($_SERVER['QUERY_STRING'], '', $_SERVER['REQUEST_URI']), '?');
$baseUrl = trim((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'], '/');
$requestUrl = trim(str_replace($_SERVER['QUERY_STRING'], '', $baseUrl), '?');
if (preg_match(REQUEST_REGEX, $requestUrl, $match)) { if (preg_match(REQUEST_REGEX, $requestUrl, $match)) {
$requestSupplier = array_key_exists('supplier', $match) ? $match['supplier'] : null; $requestSupplier = array_key_exists('supplier', $match) ? $match['supplier'] : null;
@ -187,6 +188,9 @@ if ($action === 'config') {
$isConfig = true; $isConfig = true;
} }
$suppliers = array_keys($config);
sort($suppliers);
try { try {
$event = array_key_exists('event', $_REQUEST) ? $_REQUEST['event'] : $requestEvent; $event = array_key_exists('event', $_REQUEST) ? $_REQUEST['event'] : $requestEvent;
$hasEvent = ( $hasEvent = (
@ -333,12 +337,26 @@ if (!$isConfig and $hasSupplier) {
<main> <main>
<?php if (!$hasSupplier) : ?> <?php if (!$hasSupplier) : ?>
<section class="container-fluid"> <section class="container-fluid">
<div class="row my-3">
<div class="col">
<div class="row my-3 g-3">
<div class="col-12">
<div class="alert alert-danger" role="alert"> <div class="alert alert-danger" role="alert">
Pas de fournisseur ! Pas de fournisseur !
</div> </div>
</div> </div>
<div class="col-12">
<form action="<?php echo generateUrl(); ?>" method="post">
<datalist id="supplierList">
<?php foreach ($suppliers as $supplier) : ?>
<option value="<?php echo $supplier; ?>" />
<?php endforeach; ?>
</datalist>
<div class="input-group">
<span class="input-group-text"><?php echo generateUrl(); ?>/</span>
<input type="text" class="form-control" name="supplier" list="supplierList" required />
<button class="btn btn-primary" type="submit" name="action" value="goto">Aller</button>
</div>
</form>
</div>
</div> </div>
</section> </section>
<?php else : ?> <?php else : ?>


Loading…
Cancel
Save