1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
| <?php
/**
* Description of prices
* @package prices
* @author Axel Wargnier <axel@axessweb.fr>
* @copyright Copyright (c) 2016
*/
if (!empty($_POST)) {
$institution = $db->orderBy('id', 'ASC')->get('site_institution');
$comp = new \AxessWeb\Components();
foreach ($institution as $instit) {
$id = $instit['id'];
$value = 0;
// si la case est cochée
if (!empty($_POST['instit']) && !empty($_POST['instit'][$id])) {
$value = 1;
}
$data = [
'value' => $value
];
if ($db->where('id', $id)->update('site_institution', $data)) {
$success = true;
} else {
$success = false;
$err[] = 'Erreur lors de la mise à jour du header';
}
}
}
$institution = $db->orderBy('id', 'ASC')->get('site_institution');
?>
<main>
<section class="section">
<h1>
<i class="fa fa-stack-exchange"></i> Gestion des institutions
</h1>
<div class="row">
<div class="col s12">
<div class="card-panel z-depth-0 blue lighten-4">
<span class="font14 blue-grey-text text-darken-1">Gestion des institutions dans le header</span>
</div>
</div>
</div>
<div class="row">
<div class="col s12">
<?php if (!empty($_POST)): ?>
<?php if ($success): ?>
<div class="card-panel green">
<span class="white-text">Les images ont été mis à jour avec succès</span>
</div>
<?php else: ?>
<div class="card-panel red">
<span class="white-text">Une erreur est survenue lors de la mise à jour des liens</span>
</div>
<?php endif; ?>
<?php endif; ?>
<br>
<form id="" method="post">
<?php foreach($institution as $instit): ?>
<?php $check = ($instit['value'] == 1)?"checked":"";?>
<input type="checkbox" name="instit[<?= $instit['id'] ?>]" value="1" id="instit_<?= $instit['id'] ?>" <?php $check; ?> ><label for="instit_<?= $instit['id'] ?>"><?= htmlspecialchars_decode($instit['content']) ?></label>
<?php endforeach; ?>
<div class="row">
<div class="col s6 offset-s2">
<br>
<div class="center">
<button class="btn waves-effect indigo darken-4" type="submit" name="submit">
Envoyer
</button>
</div>
</div>
</div>
</form>
</div>
</div>
</section>
</main> |