37 lines
1.0 KiB
PHP
37 lines
1.0 KiB
PHP
<?php
|
|
include('include/headscript.php');
|
|
|
|
header('Content-Type: application/json; charset=utf-8');
|
|
|
|
try {
|
|
$idmatrice = (int)($_GET['id'] ?? 0);
|
|
if ($idmatrice <= 0) {
|
|
echo json_encode(['success' => false, 'message' => 'Invalid id']);
|
|
exit;
|
|
}
|
|
|
|
$db = DBHandlerSelect::getInstance();
|
|
$pdo = $db->getConnection();
|
|
|
|
// tutte le linee (attive + inattive se vuoi: qui prendo tutte)
|
|
$stmt = $pdo->query("
|
|
SELECT id, line_number, name
|
|
FROM production_lines
|
|
ORDER BY line_number ASC
|
|
");
|
|
$lines = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
|
|
|
// linee già associate
|
|
$stmt = $pdo->prepare("SELECT idlinea FROM matrici_lines WHERE idmatrice = ?");
|
|
$stmt->execute([$idmatrice]);
|
|
$selected_ids = $stmt->fetchAll(PDO::FETCH_COLUMN);
|
|
|
|
echo json_encode([
|
|
'success' => true,
|
|
'lines' => $lines,
|
|
'selected_ids' => $selected_ids
|
|
]);
|
|
} catch (Throwable $e) {
|
|
echo json_encode(['success' => false, 'message' => 'Server error']);
|
|
}
|