Files
pos_heidiver/app/Exports/PlantillaCompraExport.php
T
2026-01-06 15:35:59 -05:00

107 lines
3.1 KiB
PHP

<?php
namespace App\Exports;
use Maatwebsite\Excel\Concerns\FromArray;
use Maatwebsite\Excel\Concerns\WithHeadings;
use Maatwebsite\Excel\Concerns\WithStyles;
use Maatwebsite\Excel\Concerns\WithColumnWidths;
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
use Maatwebsite\Excel\Concerns\WithTitle;
class PlantillaCompraExport implements FromArray, WithHeadings, WithStyles, WithColumnWidths, WithTitle
{
/**
* Datos de ejemplo para la plantilla
*/
public function array(): array
{
return [
['7501234567890', 'Balde 15 L', 10, 50000, 'Principal', 'Si codigo existe, usa ese producto'],
['', 'Producto Nuevo Sin Codigo', 5, 75000, 'Principal', 'Si no hay codigo, busca por nombre'],
['9999999999999', 'Escoba Verde', 20, 25000, 'Principal', 'Codigo nuevo - crea producto con ese nombre'],
['', '', '', '', '', ''],
['', 'INSTRUCCIONES:', '', '', '', ''],
['', '1. Si tiene codigo: busca por codigo primero', '', '', '', ''],
['', '2. Si no hay codigo: busca por nombre', '', '', '', ''],
['', '3. Si no existe: crea nuevo producto', '', '', '', ''],
];
}
/**
* Encabezados de las columnas
*/
public function headings(): array
{
return [
'Codigo de Barras',
'Producto',
'Cantidad',
'Precio Unitario',
'Bodega',
'Observaciones',
];
}
/**
* Estilos de la hoja
*/
public function styles(Worksheet $sheet)
{
return [
// Estilo para la fila de encabezados
1 => [
'font' => [
'bold' => true,
'size' => 12,
'color' => ['rgb' => 'FFFFFF'],
],
'fill' => [
'fillType' => \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_SOLID,
'startColor' => ['rgb' => '4472C4'],
],
'alignment' => [
'horizontal' => \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER,
'vertical' => \PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_CENTER,
],
],
// Filas de datos
'2:8' => [
'alignment' => [
'vertical' => \PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_CENTER,
],
],
// Filas de instrucciones
'5:8' => [
'font' => [
'italic' => true,
'color' => ['rgb' => '666666'],
],
],
];
}
/**
* Ancho de las columnas
*/
public function columnWidths(): array
{
return [
'A' => 20, // Codigo de Barras
'B' => 25, // Producto
'C' => 12, // Cantidad
'D' => 18, // Precio Unitario
'E' => 15, // Bodega
'F' => 35, // Observaciones
];
}
/**
* Título de la hoja
*/
public function title(): string
{
return 'Plantilla Compras';
}
}