Skip to content

Commit 89c7ab3

Browse files
authored
Merge pull request #69 from chechojgb/buttonsLovers
add: agregar historico de marcacion
2 parents fc01479 + 3aa152a commit 89c7ab3

File tree

6 files changed

+179
-14
lines changed

6 files changed

+179
-14
lines changed

app/Http/Controllers/BlProductoController.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public function indexHistorico()
6262
}),
6363
];
6464
});
65-
$historico = BlMovimiento::with(['empaque.producto', 'usuario'])
65+
$entrada = BlMovimiento::with(['empaque.producto', 'usuario'])
6666
->where('tipo', 'entrada')
6767
->whereHas('empaque.producto')
6868
->get()
@@ -81,12 +81,21 @@ public function indexHistorico()
8181
'cantidad_por_empaque' => $movimiento->empaque->cantidad_por_empaque,
8282
];
8383
});
84+
$marcacion = BlMovimiento::with(['empaque.producto', 'usuario'])
85+
->where('tipo', 'pedido')
86+
->whereIn('motivo', [
87+
'Cambio de estado a en proceso',
88+
'Cambio de estado a completado'
89+
])
90+
->get();
91+
// dd($marcacion);
8492

8593
return Inertia::render('BLHistorico', [
8694
'productos' => $productos,
8795
'colores' => BlColor::all(),
8896
'user' => $user,
89-
'historico' => $historico,
97+
'marcacion' => $marcacion,
98+
'entrada' => $entrada
9099
]);
91100
}
92101

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\Schema;
6+
7+
return new class extends Migration
8+
{
9+
/**
10+
* Run the migrations.
11+
*/
12+
public function up(): void
13+
{
14+
Schema::table('bl_movimientos', function (Blueprint $table) {
15+
// 1. Eliminar la foreign key y la columna empaque_id
16+
if (Schema::hasColumn('bl_movimientos', 'empaque_id')) {
17+
$table->dropForeign(['empaque_id']);
18+
$table->dropColumn('empaque_id');
19+
}
20+
21+
// 2. Cambiar enum tipo a string
22+
if (Schema::hasColumn('bl_movimientos', 'tipo')) {
23+
$table->dropColumn('tipo');
24+
}
25+
26+
// ✅ Nueva columna tipo como string con valor por defecto
27+
$table->string('tipo', 50)->default('entrada')->after('id');
28+
});
29+
}
30+
31+
/**
32+
* Reverse the migrations.
33+
*/
34+
public function down(): void
35+
{
36+
Schema::table('bl_movimientos', function (Blueprint $table) {
37+
// Restaurar la columna empaque_id
38+
$table->foreignId('empaque_id')->constrained('bl_empaques')->after('id');
39+
40+
// Eliminar tipo como string y volverlo enum original
41+
$table->dropColumn('tipo');
42+
$table->enum('tipo', ['entrada', 'salida', 'ajuste'])->after('empaque_id');
43+
});
44+
}
45+
};

package-lock.json

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
"class-variance-authority": "^0.7.1",
5757
"clsx": "^2.1.1",
5858
"concurrently": "^9.0.1",
59+
"date-fns": "^4.1.0",
5960
"express": "^5.1.0",
6061
"flowbite": "^3.1.2",
6162
"flowbite-react": "^0.11.7",

resources/js/components/BL/historicoBL.jsx

Lines changed: 105 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import { Card, CardContent } from "@/components/ui/card";
22
import { Badge } from "@/components/ui/badge";
3-
import { ArrowDown } from "lucide-react";
3+
import { ArrowDown, ArrowUp } from "lucide-react";
4+
import { format } from "date-fns";
45

5-
function EntradaBL({ historico }) {
6+
export default function EntradaBL({ historico }) {
67
// Filtrar solo las entradas
78
const entradas = historico?.filter((item) => item.tipo === "entrada") || [];
89

@@ -48,4 +49,105 @@ function EntradaBL({ historico }) {
4849
);
4950
}
5051

51-
export default EntradaBL;
52+
53+
export function MarcacionBL({ marcacion }) {
54+
// Filtrar solo los pedidos
55+
const marcaciones = marcacion?.filter((item) => item.tipo === "pedido") || [];
56+
57+
// Agrupar según motivo
58+
const enProceso = marcaciones.filter(
59+
(item) => item.motivo === "Cambio de estado a en proceso"
60+
);
61+
const completados = marcaciones.filter(
62+
(item) => item.motivo === "Cambio de estado a completado"
63+
);
64+
65+
return (
66+
<Card className="h-[350px] overflow-hidden shadow-md border">
67+
<CardContent className="p-4 flex flex-col gap-4 h-full">
68+
<div className="flex items-center gap-3">
69+
<div className="bg-yellow-50 p-2 rounded-full dark:bg-yellow-200">
70+
<ArrowUp className="w-5 h-5 text-yellow-400 dark:text-yellow-700" />
71+
</div>
72+
<h2 className="text-lg font-bold text-yellow-700 tracking-tight">
73+
Items en marcación
74+
</h2>
75+
</div>
76+
77+
<div className="overflow-y-auto pr-2 h-full space-y-6 scrollbar-thin scrollbar-thumb-gray-300 scrollbar-track-transparent">
78+
{/* En proceso */}
79+
<div>
80+
<h3 className="text-sm font-semibold text-blue-600 mb-2">
81+
En proceso
82+
</h3>
83+
{enProceso.length === 0 ? (
84+
<p className="text-xs text-gray-500">
85+
No hay items en proceso.
86+
</p>
87+
) : (
88+
enProceso.map((item) => (
89+
<div
90+
key={item.id}
91+
className="flex justify-between items-start border p-3 rounded-lg transition hover:shadow-md"
92+
>
93+
<div className="space-y-1">
94+
<p className="font-semibold">{item?.motivo}</p>
95+
<p className="text-xs">
96+
{format(new Date(item.updated_at), "dd-MM-yyyy HH:mm")}{" "}
97+
{item.tipo || "sin tipo"}{" "}
98+
<span className="font-medium">
99+
{item?.usuario?.name || "Sin usuario"}
100+
</span>
101+
</p>
102+
</div>
103+
<Badge
104+
variant="outline"
105+
className="text-sm border-blue-300 text-blue-600"
106+
>
107+
{item.cantidad} und
108+
</Badge>
109+
</div>
110+
))
111+
)}
112+
</div>
113+
114+
{/* Completados */}
115+
<div>
116+
<h3 className="text-sm font-semibold text-green-600 mb-2">
117+
Completados
118+
</h3>
119+
{completados.length === 0 ? (
120+
<p className="text-xs text-gray-500">
121+
No hay items completados.
122+
</p>
123+
) : (
124+
completados.map((item) => (
125+
<div
126+
key={item.id}
127+
className="flex justify-between items-start border p-3 rounded-lg transition hover:shadow-md"
128+
>
129+
<div className="space-y-1">
130+
<p className="font-semibold">{item?.motivo}</p>
131+
<p className="text-xs">
132+
{format(new Date(item.updated_at), "dd-MM-yyyy HH:mm")}{" "}
133+
{item.tipo || "sin tipo"}{" "}
134+
<span className="font-medium">
135+
{item?.usuario?.name || "Sin usuario"}
136+
</span>
137+
</p>
138+
</div>
139+
<Badge
140+
variant="outline"
141+
className="text-sm border-green-300 text-green-600"
142+
>
143+
{item.cantidad} und
144+
</Badge>
145+
</div>
146+
))
147+
)}
148+
</div>
149+
</div>
150+
</CardContent>
151+
</Card>
152+
);
153+
}

resources/js/pages/BLHistorico.jsx

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { Card, CardContent } from "@/components/ui/card";
66
import { Badge } from "@/components/ui/badge";
77
import { ShoppingCart, PackageCheck, ArrowDown, ArrowUp } from "lucide-react";
88
import EntradaBL from "@/components/BL/historicoBL";
9+
import { MarcacionBL } from "@/components/BL/historicoBL";
910

1011
const breadcrumbs = [{ title: "Histórico", href: "/BLproductosInventario/historico" }];
1112

@@ -73,8 +74,9 @@ function Seccion({ title, icon: Icon, color, data }) {
7374
);
7475
}
7576

76-
export default function BLHistorico({historico}) {
77-
console.log("Datos del histórico:", historico);
77+
export default function BLHistorico({entrada, marcacion}) {
78+
console.log("Datos del histórico:", entrada);
79+
console.log("Datos de marcacion:", marcacion);
7880

7981
return (
8082
<AppLayout breadcrumbs={breadcrumbs}>
@@ -83,13 +85,8 @@ export default function BLHistorico({historico}) {
8385
<h1 className="text-2xl font-bold">Histórico de movimientos</h1>
8486

8587
<div className="grid md:grid-cols-2 lg:grid-cols-3 gap-6">
86-
<EntradaBL historico={historico} />
87-
<Seccion
88-
title="Salidas de Productos"
89-
icon={ArrowUp}
90-
color="text-red-500"
91-
data={salidas}
92-
/>
88+
<EntradaBL historico={entrada} />
89+
<MarcacionBL marcacion={marcacion}/>
9390
<Seccion
9491
title="Pedidos Entregados"
9592
icon={PackageCheck}

0 commit comments

Comments
 (0)