modificati i valori dei campi e corretto il Drag & Drop
This commit is contained in:
parent
17592d1f35
commit
70d33380b5
2 changed files with 36 additions and 6 deletions
|
|
@ -79,6 +79,18 @@ export default function ArticleCard({
|
||||||
${isDragging ? "opacity-50 ring-2 ring-blue-500" : ""}
|
${isDragging ? "opacity-50 ring-2 ring-blue-500" : ""}
|
||||||
`}
|
`}
|
||||||
>
|
>
|
||||||
|
{/* Indicatore draggable */}
|
||||||
|
{canDrag && (
|
||||||
|
<div
|
||||||
|
className="w-4 h-8 flex flex-col items-center justify-center gap-0.5 text-zinc-600 hover:text-zinc-400 flex-shrink-0"
|
||||||
|
title="Trascina per assegnare a macchina"
|
||||||
|
>
|
||||||
|
<div className="w-1 h-1 rounded-full bg-current"></div>
|
||||||
|
<div className="w-1 h-1 rounded-full bg-current"></div>
|
||||||
|
<div className="w-1 h-1 rounded-full bg-current"></div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
{/* Indicatore sotto scorta */}
|
{/* Indicatore sotto scorta */}
|
||||||
{isSottoScorta && (
|
{isSottoScorta && (
|
||||||
<div className="w-2 h-2 rounded-full bg-red-500 flex-shrink-0" title="Sotto scorta" />
|
<div className="w-2 h-2 rounded-full bg-red-500 flex-shrink-0" title="Sotto scorta" />
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,13 @@ export async function assegnaArticoloMacchina(
|
||||||
|
|
||||||
const articolo = articoloRows[0];
|
const articolo = articoloRows[0];
|
||||||
|
|
||||||
|
const [macchinaRows] = await db.execute<(RowDataPacket & { nome: string })[]>(
|
||||||
|
"SELECT nome FROM macchine_parti WHERE id = :idmacchina LIMIT 1",
|
||||||
|
{ idmacchina }
|
||||||
|
);
|
||||||
|
|
||||||
|
const macchinaNome = macchinaRows[0]?.nome || "Macchina";
|
||||||
|
|
||||||
const [existingRows] = await db.execute<(RowDataPacket & { id: number })[]>(
|
const [existingRows] = await db.execute<(RowDataPacket & { id: number })[]>(
|
||||||
"SELECT id FROM art_macchine_parti WHERE idart = :idart AND idmacchina = :idmacchina LIMIT 1",
|
"SELECT id FROM art_macchine_parti WHERE idart = :idart AND idmacchina = :idmacchina LIMIT 1",
|
||||||
{ idart, idmacchina }
|
{ idart, idmacchina }
|
||||||
|
|
@ -77,14 +84,17 @@ export async function assegnaArticoloMacchina(
|
||||||
}
|
}
|
||||||
|
|
||||||
await db.execute(
|
await db.execute(
|
||||||
`INSERT INTO movimenti (id_articolo, quantita, tipo, causale, user, id_macchina_parte, data_movimento)
|
`INSERT INTO movimenti (id_articolo, articolo_codice, articolo_descrizione, quantita, tipo_movimento, causale, utente, id_macchina_parte, nome_macchina_parte)
|
||||||
VALUES (:id_articolo, :quantita, 'scarico', :causale, :user, :id_macchina_parte, NOW())`,
|
VALUES (:id_articolo, :articolo_codice, :articolo_descrizione, :quantita, 2, :causale, :utente, :id_macchina_parte, :nome_macchina_parte)`,
|
||||||
{
|
{
|
||||||
id_articolo: idart,
|
id_articolo: idart,
|
||||||
|
articolo_codice: articolo.codice,
|
||||||
|
articolo_descrizione: articolo.descrizione,
|
||||||
quantita,
|
quantita,
|
||||||
causale,
|
causale,
|
||||||
user,
|
utente: user,
|
||||||
id_macchina_parte: idmacchina,
|
id_macchina_parte: idmacchina,
|
||||||
|
nome_macchina_parte: macchinaNome,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -122,14 +132,22 @@ export async function rimuoviArticoloDaMacchina(
|
||||||
);
|
);
|
||||||
|
|
||||||
if (opzione === "carico") {
|
if (opzione === "carico") {
|
||||||
|
const [articoloRows] = await db.execute<(RowDataPacket & { descrizione: string; codice: string })[]>(
|
||||||
|
"SELECT descrizione, codice FROM articoli WHERE id = :idart LIMIT 1",
|
||||||
|
{ idart }
|
||||||
|
);
|
||||||
|
const articolo = articoloRows[0];
|
||||||
|
|
||||||
await db.execute(
|
await db.execute(
|
||||||
`INSERT INTO movimenti (id_articolo, quantita, tipo, causale, user, data_movimento)
|
`INSERT INTO movimenti (id_articolo, articolo_codice, articolo_descrizione, quantita, tipo_movimento, causale, utente)
|
||||||
VALUES (:id_articolo, :quantita, 'carico', :causale, :user, NOW())`,
|
VALUES (:id_articolo, :articolo_codice, :articolo_descrizione, :quantita, 1, :causale, :utente)`,
|
||||||
{
|
{
|
||||||
id_articolo: idart,
|
id_articolo: idart,
|
||||||
|
articolo_codice: articolo?.codice || "",
|
||||||
|
articolo_descrizione: articolo?.descrizione || "",
|
||||||
quantita,
|
quantita,
|
||||||
causale: "Rientro da macchina",
|
causale: "Rientro da macchina",
|
||||||
user,
|
utente: user,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue