Browse Source

ajoute le qrcode

master
vince vince 3 years ago
parent
commit
393e3622e1
1 changed files with 96 additions and 38 deletions
  1. +96
    -38
      index.php

+ 96
- 38
index.php View File

@ -339,24 +339,27 @@ if ($supplierIsNew and !empty($suppliers)) {
</svg> </svg>
<?php echo $hasSupplier ? $supplier : DEFAULT_TITLE; ?> <?php echo $hasSupplier ? $supplier : DEFAULT_TITLE; ?>
</a> </a>
<?php if ($hasSupplier) : ?>
<span class="navbar-text text-muted">
<?php if ($isConfig) : ?>
<a class="text-reset" href="<?php echo generateUrl($supplier); ?>">Retour</a>
<?php else : ?>
<?php if ($hasPassword) : ?>
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-lock" viewBox="0 0 16 16">
<path d="M8 1a2 2 0 0 1 2 2v4H6V3a2 2 0 0 1 2-2zm3 6V3a3 3 0 0 0-6 0v4a2 2 0 0 0-2 2v5a2 2 0 0 0 2 2h6a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2zM5 8h6a1 1 0 0 1 1 1v5a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V9a1 1 0 0 1 1-1z"/>
</svg>
<span class="navbar-text text-muted">
<a class="text-reset me-3" data-bs-toggle="modal" href="#linkModal">Lien</a>
<?php if ($hasSupplier) : ?>
<?php if ($isConfig) : ?>
<a class="text-reset" href="<?php echo generateUrl($supplier); ?>">Retour</a>
<?php else : ?> <?php else : ?>
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-unlock" viewBox="0 0 16 16">
<path d="M11 1a2 2 0 0 0-2 2v4a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h5V3a3 3 0 0 1 6 0v4a.5.5 0 0 1-1 0V3a2 2 0 0 0-2-2zM3 8a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1h6a1 1 0 0 0 1-1V9a1 1 0 0 0-1-1H3z"/>
</svg>
<a tabindex="-1" class="text-reset" href="<?php printf('%s?action=config', generateUrl($supplier)); ?>">
<?php if ($hasPassword) : ?>
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-lock" viewBox="0 0 16 16">
<path d="M8 1a2 2 0 0 1 2 2v4H6V3a2 2 0 0 1 2-2zm3 6V3a3 3 0 0 0-6 0v4a2 2 0 0 0-2 2v5a2 2 0 0 0 2 2h6a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2zM5 8h6a1 1 0 0 1 1 1v5a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V9a1 1 0 0 1 1-1z"/>
</svg>
<?php else : ?>
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-unlock" viewBox="0 0 16 16">
<path d="M11 1a2 2 0 0 0-2 2v4a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h5V3a3 3 0 0 1 6 0v4a.5.5 0 0 1-1 0V3a2 2 0 0 0-2-2zM3 8a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1h6a1 1 0 0 0 1-1V9a1 1 0 0 0-1-1H3z"/>
</svg>
<?php endif; ?>
Configuration
</a>
<?php endif; ?> <?php endif; ?>
<a tabindex="-1" class="text-reset" href="<?php printf('%s?action=config', generateUrl($supplier)); ?>">Configuration</a>
<?php endif; ?> <?php endif; ?>
</span>
<?php endif; ?>
</span>
</div> </div>
</nav> </nav>
</header> </header>
@ -415,7 +418,7 @@ if ($supplierIsNew and !empty($suppliers)) {
<div class="row mb-3"> <div class="row mb-3">
<label for="description" class="col-sm-2 col-form-label">Description</label> <label for="description" class="col-sm-2 col-form-label">Description</label>
<div class="col-sm-10"> <div class="col-sm-10">
<textarea class="form-control js-ckeditor" name="description" rows="10"><?php echo $config[$supplier]['description']; ?></textarea>
<textarea class="form-control js-ckeditor" name="description" rows="20"><?php echo $config[$supplier]['description']; ?></textarea>
<div class="form-text">La description affichée sous le titre.</div> <div class="form-text">La description affichée sous le titre.</div>
</div> </div>
</div> </div>
@ -649,7 +652,51 @@ if ($supplierIsNew and !empty($suppliers)) {
<?php endif; /* $isConfig*/ ?> <?php endif; /* $isConfig*/ ?>
<?php endif; ?> <?php endif; ?>
</main> </main>
<div class="modal fade" id="linkModal" tabindex="-1" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Lien</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Fermer"></button>
</div>
<div class="modal-body">
<div class="container-fluid">
<div class="row g-3">
<div class="col-12">
Adresse web
</div>
<div class="col-12">
<tt id="linkURL">
<?php if (!$hasSupplier) : ?>
<?php echo generateUrl(); ?>
<?php else : ?>
<?php if (!$hasEvent) : ?>
<?php echo generateUrl($supplier); ?>
<?php else : ?>
<?php echo generateUrl($supplier, $event); ?>
<?php endif; ?>
<?php endif; ?>
</tt>
</div>
<div class="col-12">
QR Code
</div>
<div class="col-12">
<div id="linkQRCode"></div>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Fermer</button>
</div>
</div>
</div>
</div>
<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.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://cdnjs.cloudflare.com/ajax/libs/qrcodejs/1.0.0/qrcode.min.js"></script>
<?php if ($isConfig) : ?> <?php if ($isConfig) : ?>
<script src="https://cdn.ckeditor.com/ckeditor5/31.0.0/classic/ckeditor.js"></script> <script src="https://cdn.ckeditor.com/ckeditor5/31.0.0/classic/ckeditor.js"></script>
<script> <script>
@ -659,34 +706,45 @@ if ($supplierIsNew and !empty($suppliers)) {
</script> </script>
<?php endif; ?> <?php endif; ?>
<script> <script>
document.querySelectorAll('.js-localremember').forEach(function (form) {
const fields = [ 'name', 'choice' ];
document.addEventListener('DOMContentLoaded', function () {
document.querySelectorAll('.js-localremember').forEach(function (form) {
const fields = [ 'name', 'choice' ];
form.addEventListener('submit', function (event) {
fields.forEach(function (field) {
window.localStorage.setItem('mon_panier_bio_' + field, form.elements[field].value);
});
});
form.addEventListener('submit', function (event) {
fields.forEach(function (field) { fields.forEach(function (field) {
window.localStorage.setItem('mon_panier_bio_' + field, form.elements[field].value);
if (
(form.elements[field].value === '')
&& (window.localStorage.getItem('mon_panier_bio_' + field) !== null)
) {
form.elements[field].value = window.localStorage.getItem('mon_panier_bio_' + field);
}
}); });
}); });
fields.forEach(function (field) {
if (
(form.elements[field].value === '')
&& (window.localStorage.getItem('mon_panier_bio_' + field) !== null)
) {
form.elements[field].value = window.localStorage.getItem('mon_panier_bio_' + field);
}
document.querySelectorAll('.js-closealerts').forEach(function (element) {
element.addEventListener('input', function (event) {
if (event.target.value !== '') {
document.querySelectorAll('.alert').forEach(function (alertElement) {
var alert = bootstrap.Alert.getOrCreateInstance(alertElement)
alert.close();
});
}
});
}); });
});
document.querySelectorAll('.js-closealerts').forEach(function (element) {
element.addEventListener('input', function (event) {
if (event.target.value !== '') {
document.querySelectorAll('.alert').forEach(function (alertElement) {
var alert = bootstrap.Alert.getOrCreateInstance(alertElement)
alert.close();
});
}
var qrcode = new QRCode('linkQRCode', {
text: document.getElementById('linkURL').innerText,
width: 300,
height: 300,
colorDark : '#000000',
colorLight : '#ffffff',
correctLevel : QRCode.CorrectLevel.H,
}); });
});
document.querySelector('#linkQRCode img').classList.add('img-fluid', 'mx-auto', 'd-block');
}, false);
</script> </script>
</body> </body>
</html> </html>

Loading…
Cancel
Save