@ -169,6 +169,12 @@ if (!$isConfig and $hasSupplier) {
$ { $match [ 1 ]},
$ { $match [ 1 ]},
$config [ $supplier ][ 'title' ]
$config [ $supplier ][ 'title' ]
);
);
$stats = [];
foreach ( $items as $item )
if ( ! empty ( $item [ 'choice' ]))
$stats [ $item [ 'choice' ]] += 1 ;
}
}
?> <!DOCTYPE html>
?> <!DOCTYPE html>
@ -177,84 +183,215 @@ if (!$isConfig and $hasSupplier) {
< meta charset = " UTF-8 " />
< meta charset = " UTF-8 " />
< meta name = " viewport " content = " width=device-width, initial-scale=1 " />
< meta name = " viewport " content = " width=device-width, initial-scale=1 " />
< title >< ? php echo strip_tags ( $config [ $supplier ][ 'title' ]); ?> </title>
< title >< ? php echo strip_tags ( $config [ $supplier ][ 'title' ]); ?> </title>
< link href = " https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css " rel = " stylesheet " integrity = " sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3 " crossorigin = " anonymous " >
</ head >
</ head >
< body >
< body >
< header >
< nav class = " navbar navbar-dark bg-dark " >
< div class = " container-fluid " >
< a class = " navbar-brand " href = " <?php echo $requestUrl ; ?> " >
< svg xmlns = " http://www.w3.org/2000/svg " width = " 24 " height = " 24 " fill = " currentColor " class = " bi bi-basket d-inline-block align-text-top " viewBox = " 0 0 16 16 " >
< path d = " M5.757 1.071a.5.5 0 0 1 .172.686L3.383 6h9.234L10.07 1.757a.5.5 0 1 1 .858-.514L13.783 6H15a1 1 0 0 1 1 1v1a1 1 0 0 1-1 1v4.5a2.5 2.5 0 0 1-2.5 2.5h-9A2.5 2.5 0 0 1 1 13.5V9a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1h1.217L5.07 1.243a.5.5 0 0 1 .686-.172zM2 9v4.5A1.5 1.5 0 0 0 3.5 15h9a1.5 1.5 0 0 0 1.5-1.5V9H2zM1 7v1h14V7H1zm3 3a.5.5 0 0 1 .5.5v3a.5.5 0 0 1-1 0v-3A.5.5 0 0 1 4 10zm2 0a.5.5 0 0 1 .5.5v3a.5.5 0 0 1-1 0v-3A.5.5 0 0 1 6 10zm2 0a.5.5 0 0 1 .5.5v3a.5.5 0 0 1-1 0v-3A.5.5 0 0 1 8 10zm2 0a.5.5 0 0 1 .5.5v3a.5.5 0 0 1-1 0v-3a.5.5 0 0 1 .5-.5zm2 0a.5.5 0 0 1 .5.5v3a.5.5 0 0 1-1 0v-3a.5.5 0 0 1 .5-.5z " />
</ svg >
< ? php echo $hasSupplier ? $supplier : 'Mon panier bio' ; ?>
</ a >
< ? php if ( $hasSupplier ) : ?>
< span class = " navbar-text text-muted " >
< ? php if ( $isConfig ) : ?>
< a class = " text-reset " href = " <?php printf('%s?supplier=%s', $requestUrl , $supplier ); ?> " > Retour </ a >
< ? php else : ?>
< a tabindex = " -1 " class = " text-reset " href = " <?php printf('%s?supplier=%s&action=config', $requestUrl , $supplier ); ?> " > Configuration </ a >
< ? php endif ; ?>
</ span >
< ? php endif ; ?>
</ div >
</ nav >
</ header >
< main >
< ? php if ( ! $hasSupplier ) : ?>
< ? php if ( ! $hasSupplier ) : ?>
< p > pas de fournisseur </ p >
< section class = " container-fluid " >
< div class = " row my-3 " >
< div class = " col " >
< div class = " alert alert-danger " role = " alert " >
Pas de fournisseur !
</ div >
</ div >
</ div >
</ section >
< ? php else : ?>
< ? php else : ?>
< ? php if ( $isConfig ) : ?>
< ? php if ( $isConfig ) : ?>
< a href = " <?php printf('%s?supplier=%s', $requestUrl , $supplier ); ?> " > retour </ a >
< h1 > config < ? php echo $supplier ; ?> </h1>
< form action = " <?php printf('%s?supplier=%s', $requestUrl , $supplier ); ?> " method = " post " >
< p >
< label for = " title " > titre </ label >
< input type = " text " name = " title " value = " <?php echo $config[$supplier] ['title']; ?> " />
</ p >
< p >
< label for = " description " > description </ label >
< textarea name = " description " rows = " 10 " >< ? php echo $config [ $supplier ][ 'description' ]; ?> </textarea>
</ p >
< p >
< label for = " choices " > choix </ label >
< textarea name = " choices " rows = " 10 " >< ? php echo implode ( PHP_EOL , $config [ $supplier ][ 'choices' ]); ?> </textarea>
</ p >
< p >
< label for = " start " > début </ label >
< input type = " date " name = " start " value = " <?php echo $config[$supplier] ['start']; ?> " />
</ p >
< p >
< label for = " frequency " > fréquence </ label >
< input type = " text " name = " frequency " value = " <?php echo $config[$supplier] ['frequency']; ?> " />
</ p >
< p >
< label for = " password " > password </ label >
< input type = " text " name = " password " value = " <?php echo $config[$supplier] ['password']; ?> " />
</ p >
< button type = " submit " name = " action " value = " config " > config </ button >
</ p >
</ form >
< section class = " container-fluid " >
< div class = " row g-3 " >
< div class = " col " >
< h1 > Configuration </ h1 >
</ div >
</ div >
</ section >
< section class = " container-fluid " >
< div class = " row g-3 " >
< form action = " <?php printf('%s?supplier=%s', $requestUrl , $supplier ); ?> " method = " post " >
< div class = " row mb-3 " >
< label for = " title " class = " col-sm-2 col-form-label " > Titre </ label >
< div class = " col-sm-10 " >
< input class = " form-control " type = " text " name = " title " value = " <?php echo $config[$supplier] ['title']; ?> " />
< div class = " form-text " > Le titre de la page . Où < kbd >% supplier %</ kbd > est le fournisseur et < kbd >% event %</ kbd > l ' événement .</ div >
</ div >
</ div >
< div class = " row mb-3 " >
< label for = " description " class = " col-sm-2 col-form-label " > Description </ label >
< div class = " col-sm-10 " >
< textarea class = " form-control js-ckeditor " name = " description " rows = " 10 " >< ? php echo $config [ $supplier ][ 'description' ]; ?> </textarea>
< div class = " form-text " > La description affichée sous le titre .</ div >
</ div >
</ div >
< div class = " row mb-3 " >
< label for = " choices " class = " col-sm-2 col-form-label " > Choix </ label >
< div class = " col-sm-10 " >
< textarea class = " form-control " name = " choices " rows = " 5 " >< ? php echo implode ( PHP_EOL , $config [ $supplier ][ 'choices' ]); ?> </textarea>
< div class = " form-text " > Les différents choix possibles . Un par ligne . Ou pas .</ div >
</ div >
</ div >
< div class = " row mb-3 " >
< label for = " start " class = " col-sm-2 col-form-label " > Début </ label >
< div class = " col-sm-10 " >
< input class = " form-control " type = " date " name = " start " value = " <?php echo $config[$supplier] ['start']; ?> " />
< div class = " form-text " > La date du premier événement , si nécessaire de le préciser .</ div >
</ div >
</ div >
< div class = " row mb-3 " >
< label for = " frequency " class = " col-sm-2 col-form-label " > Fréquence </ label >
< div class = " col-sm-10 " >
< input class = " form-control " type = " text " name = " frequency " value = " <?php echo $config[$supplier] ['frequency']; ?> " />
< div class = " form-text " > La fréquence des événements dans le format < a class = " text-reset " href = " https://www.php.net/manual/fr/datetime.formats.relative.php " target = " _blank " > décrit sur cette page </ a >.</ div >
</ div >
</ div >
< div class = " row mb-3 " >
< label for = " password " class = " col-sm-2 col-form-label " > Mot de passe </ label >
< div class = " col-sm-10 " >
< input class = " form-control " type = " text " name = " password " value = " <?php echo $config[$supplier] ['password']; ?> " />
< div class = " form-text " > Ce mot de passe sera demandé pour accéder à la configuration la prochaine fois . Le nom d 'utilisateur est le fournisseur courant (en l' occurrence < kbd >< ? php echo $supplier ; ?> </kbd>).</div>
</ div >
</ div >
< div class = " row " >
< div class = " col mb-3 " >
< button class = " btn btn-primary " type = " submit " name = " action " value = " config " > Enregistrer </ button >
</ div >
</ div >
</ form >
</ div >
</ section >
< ? php else : ?>
< ? php else : ?>
< a href = " <?php printf('%s?supplier=%s&action=config', $requestUrl , $supplier ); ?> " > config </ a >
< h1 >< ? php echo $config [ $supplier ][ 'title' ]; ?> </h1>
< ? php if ( ! empty ( $config [ $supplier ][ 'description' ])) : ?>
< p >< ? php echo $config [ $supplier ][ 'description' ]; ?> </p>
< ? php endif ; ?>
< ul >
< li >
< form >
< input type = " hidden " name = " supplier " value = " <?php echo $supplier ; ?> " />
< input type = " hidden " name = " event " value = " <?php echo $event ; ?> " />
< input type = " text " name = " name " required placeholder = " nom " />
< ? php if ( empty ( $config [ $supplier ][ 'choices' ])) : ?>
< input type = " hidden " name = " choice " value = " <?php echo $item['choice'] ; ?> " />
< ? php else : ?>
< select name = " choice " required placeholder = " choix " >
< option />
< ? php foreach ( $config [ $supplier ][ 'choices' ] as $choice ) : ?>
< option >< ? php echo $choice ; ?> </option>
< ? php endforeach ; ?>
</ select >
< section class = " container-fluid " >
< div class = " row my-3 " >
< div class = " col " >
< h1 >< ? php echo $config [ $supplier ][ 'title' ]; ?> </h1>
< ? php if ( ! empty ( $config [ $supplier ][ 'description' ])) : ?>
< p class = " lead " >< ? php echo $config [ $supplier ][ 'description' ]; ?> </p>
< ? php endif ; ?>
< ? php endif ; ?>
< button type = " submit " name = " action " value = " insert " > ajouter </ button >
</ form >
</ li >
< ? php foreach ( $items as $item ) : ?>
< li >
< form >
< input type = " hidden " name = " supplier " value = " <?php echo $supplier ; ?> " />
< input type = " hidden " name = " event " value = " <?php echo $event ; ?> " />
< input type = " hidden " name = " name " value = " <?php echo $item['name'] ; ?> " />
< input type = " hidden " name = " choice " value = " <?php echo $item['choice'] ; ?> " />
< ? php echo $item [ 'name' ]; ?>
< ? php if ( ! empty ( $item [ 'choice' ])) : ?>
— < ? php echo $item [ 'choice' ]; ?>
</ div >
</ div >
</ section >
< section class = " container-fluid " >
< div class = " row g-3 " >
< form action = " <?php printf('%s?supplier=%s', $requestUrl , $supplier ); ?> " method = " post " >
< div class = " row mb-3 " >
< label for = " title " class = " col-sm-2 col-form-label " > Nom </ label >
< div class = " col-sm-10 " >
< input class = " form-control " type = " text " name = " name " required placeholder = " Camille Martin " />
</ div >
</ div >
< ? php if ( ! empty ( $config [ $supplier ][ 'choices' ])) : ?>
< div class = " row mb-3 " >
< label for = " title " class = " col-sm-2 col-form-label " > Choix </ label >
< div class = " col-sm-10 " >
< select class = " form-select " name = " choice " required placeholder = " choix " >
< option />
< ? php foreach ( $config [ $supplier ][ 'choices' ] as $choice ) : ?>
< option >< ? php echo $choice ; ?> </option>
< ? php endforeach ; ?>
</ select >
</ div >
</ div >
< ? php endif ; ?>
< ? php endif ; ?>
< button type = " submit " name = " action " value = " delete " > supprimer </ button >
< div class = " row " >
< div class = " col mb-3 " >
< input type = " hidden " name = " supplier " value = " <?php echo $supplier ; ?> " />
< input type = " hidden " name = " event " value = " <?php echo $event ; ?> " />
< ? php if ( empty ( $config [ $supplier ][ 'choices' ])) : ?>
< input type = " hidden " name = " choice " value = " " />
< ? php endif ; ?>
< button class = " btn btn-primary " type = " submit " name = " action " value = " insert " > Commander </ button >
</ div >
</ div >
</ form >
</ form >
</ li >
< ? php endforeach ; ?>
</ ul >
</ div >
</ section >
< section class = " container-fluid " >
< div class = " row my-3 " >
< div class = " col " >
< div class = " table-responsive " >
< table class = " table table-striped table-hover align-middle " >
< thead >
< tr >
< th scope = " col " >
Nom
</ th >
< ? php if ( ! empty ( $config [ $supplier ][ 'choices' ])) : ?>
< th scope = " col " >
Choix
</ th >
< ? php endif ; ?>
< th scope = " col " >
& nbsp ;
</ th >
</ tr >
</ thead >
< tbody >
< ? php foreach ( $items as $item ) : ?>
< tr >
< td >
< ? php echo $item [ 'name' ]; ?>
</ td >
< ? php if ( ! empty ( $config [ $supplier ][ 'choices' ])) : ?>
< td >
< ? php if ( ! empty ( $item [ 'choice' ])) : ?>
< ? php echo $item [ 'choice' ]; ?>
< ? php endif ; ?>
</ td >
< ? php endif ; ?>
< td >
< form onsubmit = " return confirm('Souhaitez-vous vraiment annuler cette commande ?'); " >
< input type = " hidden " name = " supplier " value = " <?php echo $supplier ; ?> " />
< input type = " hidden " name = " event " value = " <?php echo $event ; ?> " />
< input type = " hidden " name = " name " value = " <?php echo $item['name'] ; ?> " />
< input type = " hidden " name = " choice " value = " <?php echo $item['choice'] ; ?> " />
< button class = " btn btn-secondary float-end " type = " submit " name = " action " value = " delete " > Annuler </ button >
</ form >
</ td >
</ tr >
< ? php endforeach ; ?>
</ tbody >
< caption >
Commandes & nbsp ; < span class = " badge bg-primary rounded-pill " >< ? php echo count ( $items ); ?> </span>
< ? php foreach ( $stats as $choice => $count ) : ?>
/
< ? php echo $choice ; ?> <span class="badge bg-secondary rounded-pill"><?php echo $count; ?></span>
< ? php endforeach ; ?>
</ caption >
</ table >
</ div >
</ div >
</ div >
</ section >
< ? php endif ; ?>
< ? php endif ; ?>
< ? php endif ; ?>
< ? php endif ; ?>
</ main >
< script src = " https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js " integrity = " sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p " crossorigin = " anonymous " ></ script >
< script src = " https://cdn.ckeditor.com/ckeditor5/31.0.0/classic/ckeditor.js " ></ script >
< script >
document . querySelectorAll ( '.js-ckeditor' ) . forEach ( function ( element ) {
ClassicEditor . create ( element ) . catch ( error => { console . error ( error ); });
});
</ script >
</ body >
</ body >
</ html >
</ html >