This commit is contained in:
2026-03-10 21:37:24 +01:00
parent 5bce68c56b
commit 9d70ea0547
37 changed files with 1534 additions and 282 deletions

View File

@@ -92,6 +92,7 @@ class ProductArchiveController
. $skuEanHtml;
$rows[] = [
'_checkbox' => '<input type="checkbox" class="js-bulk-check" value="' . $id . '" aria-label="Zaznacz produkt">',
'lp' => $lp++ . '.',
'product' => $productCell,
'price_brutto' => $priceBrutto !== '' ? $priceBrutto : '-',
@@ -123,6 +124,7 @@ class ProductArchiveController
$viewModel = new \admin\ViewModels\Common\PaginatedTableViewModel(
[
['key' => '_checkbox', 'label' => '', 'class' => 'text-center table-col-bulk-check', 'sortable' => false, 'raw' => true],
['key' => 'lp', 'label' => 'Lp.', 'class' => 'text-center', 'sortable' => false],
['key' => 'product', 'sort_key' => 'name', 'label' => 'Nazwa', 'sortable' => true, 'raw' => true],
['key' => 'price_brutto', 'sort_key' => 'price_brutto', 'label' => 'Cena', 'class' => 'text-center', 'sortable' => true],
@@ -190,4 +192,40 @@ class ProductArchiveController
header( 'Location: /admin/product_archive/list/' );
exit;
}
public function bulk_delete_permanent(): void
{
header( 'Content-Type: application/json; charset=utf-8' );
$rawIds = isset( $_POST['ids'] ) && is_array( $_POST['ids'] ) ? $_POST['ids'] : [];
$ids = [];
foreach ( $rawIds as $raw ) {
$id = (int) $raw;
if ( $id > 0 ) {
$ids[] = $id;
}
}
if ( empty( $ids ) ) {
echo json_encode( ['success' => false, 'message' => 'Nie wybrano żadnych produktów.'] );
exit;
}
$deleted = 0;
$errors = [];
foreach ( $ids as $id ) {
if ( $this->productRepository->delete( $id ) ) {
$deleted++;
} else {
$errors[] = $id;
}
}
echo json_encode( [
'success' => empty( $errors ),
'deleted' => $deleted,
'errors' => $errors,
] );
exit;
}
}