324 lines
14 KiB
PHP
324 lines
14 KiB
PHP
<?php
|
|
|
|
$menu = "menus/men_list";
|
|
$header = "headers/hea_default";
|
|
|
|
$this->setVar('menu', $menu);
|
|
$this->setVar('header', $header);
|
|
|
|
?>
|
|
|
|
<?= $this->extend('layouts/default') ?>
|
|
<?= $this->section('content') ?>
|
|
<div class="content relative lg:px-4 flex-grow">
|
|
|
|
<!--:Prelaoder:-->
|
|
<div id="preloader" class="absolute inset-0 w-full h-[75vh] flex items-center justify-center z-50">
|
|
<div class="size-12 bg-white shadow-xl rounded-full flex items-center justify-center">
|
|
<div class="animate-spin rounded-full size-10 border-b-2 border-primary"></div>
|
|
</div>
|
|
</div>
|
|
|
|
<div id="readers-container" class="px-4 grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-5 gap-4 mb-4">
|
|
</div>
|
|
|
|
<div id="readerstp-container" class="px-4 grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-5 gap-4 mb-4">
|
|
</div>
|
|
|
|
<div class="px-4">
|
|
|
|
<!-- Contenu collapsable -->
|
|
<div class="mt-2">
|
|
|
|
<div class="lg:col-span-8">
|
|
<!--:Card:-->
|
|
<div class="rounded-xl bg-green-300 dark:bg-zinc-900 shadow-card overflow-hidden">
|
|
<div class="flex items-center justify-between p-4 pb-2">
|
|
<h1>Liste</h1>
|
|
</div>
|
|
|
|
<div class="overflow-x-auto px-2">
|
|
<div class="overflow-x-auto px-2">
|
|
|
|
<h2 class="text-lg font-semibold mb-3"><?= esc($form['title']) ?></h2>
|
|
|
|
<form method="post"
|
|
action="<?= site_url('v4/labels/print/' . ($form['label_format'] ?? 'avery5160') . '/' . ($form['label_render'] ?? 'product')) ?>"
|
|
target="_blank">
|
|
<input type="hidden" name="form_code" value="<?= esc($form['code']) ?>">
|
|
<input type="hidden" name="start_label" id="start_label" value="1">
|
|
<?= csrf_field() ?>
|
|
|
|
<table class="min-w-full text-sm text-left border border-zinc-200 dark:border-zinc-700 bg-white">
|
|
|
|
<thead class="bg-zinc-50 dark:bg-zinc-800 border-b border-zinc-200 dark:border-zinc-700">
|
|
<tr>
|
|
<?php
|
|
|
|
if (!empty($form['label_format'])): ?>
|
|
<th class="px-3 py-2">
|
|
<input type="checkbox" id="selectAll">
|
|
</th>
|
|
<?php endif; ?>
|
|
<?php foreach ($fields as $field): ?>
|
|
<th class="px-3 py-2 border-r border-zinc-200 dark:border-zinc-700 font-semibold">
|
|
<?= esc($field['label']) ?>
|
|
</th>
|
|
<?php endforeach; ?>
|
|
|
|
<th class="px-3 py-2 font-semibold">
|
|
Actions
|
|
</th>
|
|
</tr>
|
|
</thead>
|
|
|
|
<tbody>
|
|
|
|
<?php foreach ($data as $row): ?>
|
|
<tr class="border-b border-zinc-200 dark:border-zinc-700 hover:bg-zinc-50 dark:hover:bg-zinc-800">
|
|
|
|
<?php if (!empty($form['label_format'])): ?>
|
|
<td class="px-3 py-2">
|
|
<input type="checkbox"
|
|
class="rowCheck"
|
|
name="ids[]"
|
|
value="<?= esc($row[$form['target_primary_key']]) ?>">
|
|
</td>
|
|
<?php endif; ?>
|
|
|
|
<?php foreach ($fields as $field): ?>
|
|
<td class="px-3 py-2 border-r border-zinc-200 dark:border-zinc-700">
|
|
|
|
<?php
|
|
|
|
switch (true) {
|
|
|
|
// =========================
|
|
// SELECT INV_GENRES (EXISTANT)
|
|
// =========================
|
|
case ($field['type'] === 'select' && $field['source_table'] === 'inv_genres'):
|
|
|
|
$option = $genresModel->getOptionById((int)$row[$field['db_column']]);
|
|
|
|
if ($option) {
|
|
echo '<span style="
|
|
background:' . esc($option['inv_color']) . ';
|
|
color:' . esc($option['inv_text_color']) . ';
|
|
padding:4px 8px;
|
|
border-radius:6px;
|
|
">';
|
|
echo esc($option['inv_nom_fr']);
|
|
echo '</span>';
|
|
}
|
|
|
|
break;
|
|
|
|
// =========================
|
|
// COLOR SIMPLE (NOUVEAU)
|
|
// =========================
|
|
case (($field['list_display_type'] ?? '') === 'color'):
|
|
|
|
$color = $row[$field['db_column']] ?? '#000000';
|
|
|
|
echo '<div style="
|
|
width:24px;
|
|
height:24px;
|
|
background:' . esc($color) . ';
|
|
border-radius:4px;
|
|
border:1px solid #ccc;
|
|
"></div>';
|
|
|
|
break;
|
|
|
|
// =========================
|
|
// DEFAULT
|
|
// =========================
|
|
default:
|
|
echo esc($row[$field['db_column']]);
|
|
}
|
|
?>
|
|
|
|
|
|
</td>
|
|
<?php endforeach; ?>
|
|
|
|
<td class="px-3 py-2 whitespace-nowrap">
|
|
|
|
<?php if (isset($parentFormCode, $parentId) && $parentFormCode && $parentId): ?>
|
|
<a class="text-primary hover:underline mr-2"
|
|
href="<?= site_url(
|
|
'v4/dynamic/edit/'
|
|
. $form['code'] . '/'
|
|
. $row[$form['target_primary_key']]
|
|
. '/parent/'
|
|
. $parentFormCode . '/'
|
|
. $parentId
|
|
) ?>">
|
|
Modifier
|
|
</a>
|
|
<?php else: ?>
|
|
<a class="text-primary hover:underline mr-2"
|
|
href="<?= site_url(
|
|
'v4/dynamic/edit/'
|
|
. $form['code'] . '/'
|
|
. $row[$form['target_primary_key']]
|
|
) ?>">
|
|
Modifier
|
|
</a>
|
|
<?php endif; ?>
|
|
<?php if (!empty($row['can_delete'])): ?>
|
|
<a class="text-red-500 hover:underline"
|
|
href="<?= site_url('v4/dynamic/delete/' . $form['code'] . '/' . $row[$form['target_primary_key']]) ?>"
|
|
onclick="return confirm('Supprimer cet enregistrement ?')">
|
|
Delete
|
|
</a>
|
|
<?php endif; ?>
|
|
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
|
|
</tbody>
|
|
</table>
|
|
|
|
|
|
<div class="mt-4 flex gap-2 items-center">
|
|
|
|
<?php if (isset($parentFormCode, $parentId)): ?>
|
|
<a href="<?= site_url(
|
|
'v4/dynamic/edit/' . $form['code'] . '/0/parent/' . $parentFormCode . '/' . $parentId
|
|
) ?>"
|
|
class="inline-block px-3 py-2 bg-primary text-white rounded-lg">
|
|
Ajouter
|
|
</a>
|
|
<?php else: ?>
|
|
<a href="<?= site_url('v4/dynamic/edit/' . $form['code'] . '/0') ?>"
|
|
class="inline-block px-3 py-2 bg-primary text-white rounded-lg">
|
|
Ajouter
|
|
</a>
|
|
<?php endif; ?>
|
|
<?php if (!empty($form['label_format'])): ?>
|
|
<button type="button"
|
|
id="printLabels"
|
|
class="inline-block px-3 py-2 bg-primary text-white rounded-lg">
|
|
Imprimer étiquettes
|
|
</button>
|
|
<?php endif; ?>
|
|
</div>
|
|
<div id="labelModal" class="fixed inset-0 hidden items-center justify-center bg-black/40 z-50">
|
|
<div class="bg-white rounded-xl p-6 shadow-xl">
|
|
|
|
<h2 class="text-lg font-semibold mb-4">
|
|
Choisir la première étiquette
|
|
</h2>
|
|
|
|
<div id="labelGrid" class="grid grid-cols-3 gap-2"></div>
|
|
|
|
<div class="mt-4 text-right">
|
|
<button id="closeModal" class="px-3 py-2 bg-gray-400 text-white rounded-lg">
|
|
Annuler
|
|
</button>
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="flex gap-[0px] items-start">
|
|
|
|
<!-- COLONNE GAUCHE : TIMING POINTS (~75%) -->
|
|
<div class="w-4/5">
|
|
</div>
|
|
|
|
<!-- COLONNES DROITES : INTERVALLES (~25%) -->
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
|
|
|
|
const modal = document.getElementById('labelModal');
|
|
const grid = document.getElementById('labelGrid');
|
|
const startInput = document.getElementById('start_label');
|
|
|
|
const printBtn = document.getElementById('printLabels');
|
|
|
|
if (printBtn) {
|
|
|
|
printBtn.addEventListener('click', function () {
|
|
|
|
modal.classList.remove('hidden');
|
|
modal.classList.add('flex');
|
|
|
|
grid.innerHTML = '';
|
|
|
|
const rows = 10;
|
|
const cols = 3;
|
|
|
|
let index = 1;
|
|
|
|
for (let r = 0; r < rows; r++) {
|
|
for (let c = 0; c < cols; c++) {
|
|
|
|
const cell = document.createElement('button');
|
|
|
|
cell.type = "button";
|
|
cell.textContent = index;
|
|
|
|
cell.className =
|
|
"w-12 h-12 border rounded hover:bg-blue-500 hover:text-white";
|
|
|
|
cell.dataset.index = index;
|
|
|
|
cell.onclick = function () {
|
|
|
|
startInput.value = this.dataset.index;
|
|
|
|
modal.classList.add('hidden');
|
|
|
|
printBtn.closest('form').submit();
|
|
};
|
|
|
|
grid.appendChild(cell);
|
|
|
|
index++;
|
|
}
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
const closeBtn = document.getElementById('closeModal');
|
|
|
|
if (closeBtn) {
|
|
closeBtn.onclick = function () {
|
|
modal.classList.add('hidden');
|
|
};
|
|
}
|
|
const selectAll = document.getElementById('selectAll');
|
|
|
|
if (selectAll) {
|
|
|
|
selectAll.addEventListener('change', function () {
|
|
|
|
const checkboxes = document.querySelectorAll('.rowCheck');
|
|
|
|
checkboxes.forEach(cb => {
|
|
cb.checked = this.checked;
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
</script>
|
|
|
|
<?= $this->endSection() ?>
|