diff --git a/app/Exports/NfcVoucherExportsCollection.php b/app/Exports/NfcVoucherExportsCollection.php new file mode 100644 index 00000000..48b5ab5a --- /dev/null +++ b/app/Exports/NfcVoucherExportsCollection.php @@ -0,0 +1,17 @@ +nfc_vouchers = $nfc_vouchers; + } + + public function view(): View + { + return view('seller.pos.exports.nfc_chourches', [ + 'nfc_vouchers' => $this->nfc_vouchers + ]); + } + + //estilos de exel + public function styles(Worksheet $sheet) + { + $nfc_vouchersCount = count($this->nfc_vouchers); + + // Aplica los estilos a la tabla en Excel + $sheet->getStyle('A1:H1')->getFont()->setBold(true); + $sheet->getStyle('A1:H1')->getFill()->setFillType(Fill::FILL_SOLID)->getStartColor()->setRGB('DDDDDD'); + $sheet->getStyle('A2:H' . ($nfc_vouchersCount + 1))->getAlignment()->setWrapText(true); + + // Ajusta automáticamente el ancho de las columnas + foreach(range('A', 'H') as $column) { + $sheet->getColumnDimension($column)->setAutoSize(true); + } + + // Agrega líneas alternas de color a las filas + for ($row = 2; $row <= $nfc_vouchersCount + 1; $row += 2) { + $sheet->getStyle('A' . $row . ':H' . $row)->applyFromArray([ + 'fill' => [ + 'fillType' => Fill::FILL_SOLID, + 'startColor' => [ + 'rgb' => 'F2F2F2' // Color gris claro + ] + ], + 'borders' => [ + 'allBorders' => [ + 'borderStyle' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN, + 'color' => ['rgb' => '000000'] // Color negro + ] + ] + ]); + } + + // Agrega bordes a todas las celdas + $sheet->getStyle('A1:H' . ($nfc_vouchersCount + 1))->applyFromArray([ + 'borders' => [ + 'allBorders' => [ + 'borderStyle' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN, + 'color' => ['rgb' => '000000'] // Color negro + ] + ] + ]); + } + + +} diff --git a/app/Http/Controllers/NfcVouchersController.php b/app/Http/Controllers/NfcVouchersController.php new file mode 100644 index 00000000..05be8bb1 --- /dev/null +++ b/app/Http/Controllers/NfcVouchersController.php @@ -0,0 +1,135 @@ +validate([ + 'nfc_type' => 'required', + 'nfc_following' => 'required', + 'nfc_expiration' => 'required|date', + 'nfc_amount' => 'required|numeric', + 'nfc_next' => 'required', + 'nfc_select' => 'required|in:active,deactivated', + ]); + + // Guardar los datos en la base de datos + DB::beginTransaction(); + + try { + $nfc_voucher->nfc_type = $validatedData['nfc_type']; + $nfc_voucher->nfc_following = $validatedData['nfc_following']; + $nfc_voucher->nfc_expiration = $validatedData['nfc_expiration']; + $nfc_voucher->nfc_amount = $validatedData['nfc_amount']; + $nfc_voucher->nfc_next = $validatedData['nfc_next']; + $nfc_voucher->nfc_select = $validatedData['nfc_select']; + + $nfc_voucher->save(); + + DB::commit(); + + // Redireccionar o mostrar un mensaje de éxito + // Redireccionar a la ruta '/pos-activation' + + return redirect()->route('pos.configuration')->with('toast_success', '¡Política de empresa creada con éxito!'); + } catch (\Exception $e) { + DB::rollback(); + + // Manejar el error y mostrar un mensaje de error + // + } + + + + + } + + /** + * Display the specified resource. + * + * @param \App\Models\NfcVoucher $nfcVoucher + * @return \Illuminate\Http\Response + */ + public function show(NfcVoucher $nfcVoucher) + { + // + } + + /** + * Show the form for editing the specified resource. + * + * @param \App\Models\NfcVoucher $nfcVoucher + * @return \Illuminate\Http\Response + */ + public function edit(NfcVoucher $nfcVoucher) + { + // + } + + /** + * Update the specified resource in storage. + * + * @param \Illuminate\Http\Request $request + * @param \App\Models\NfcVoucher $nfcVoucher + * @return \Illuminate\Http\Response + */ + public function update(Request $request, NfcVoucher $nfcVoucher) + { + // + } + + /** + * Remove the specified resource from storage. + * + * @param \App\Models\NfcVoucher $nfcVoucher + * @return \Illuminate\Http\Response + */ + public function collection() + { + return Excel::download(new NfcVoucherExportsCollection, 'Nfc_Voucher.xlsx'); + } + + public function view() + { + // return Excel::download(new NfcVoucherExportsView, 'Nfc_Voucher.xlsx'); + + $nfc_vouchers = NfcVoucher::latest()->get();// Obtén los datos de la tabla desde tu controlador o modelo + + return Excel::download(new NfcVoucherExportsView($nfc_vouchers), 'nfc_vouchers.xlsx'); + } +} diff --git a/app/Http/Controllers/Seller/PosController.php b/app/Http/Controllers/Seller/PosController.php index d3124aa1..f50f6237 100644 --- a/app/Http/Controllers/Seller/PosController.php +++ b/app/Http/Controllers/Seller/PosController.php @@ -17,6 +17,7 @@ use Mail; use App\Mail\InvoiceEmailManager; use App\Http\Resources\PosProductCollection; use App\Models\Country; +use App\Models\NfcVoucher; use App\Models\State; use App\Utility\CategoryUtility; use App\Utility\FontUtility; @@ -365,7 +366,12 @@ class PosController extends Controller public function configuration() { - return view('seller.pos.pos_activation'); + + //AQUI AGREGO LA CONSULTA donde traigo los comprobantes desde el ultimo que agrego que se muestre primero + $nfc_vouchers = $nfc_vouchers = NfcVoucher::latest()->get(); + + + return view('seller.pos.pos_activation', compact('nfc_vouchers')); } public function invoice($id) diff --git a/app/Models/NfcVoucher.php b/app/Models/NfcVoucher.php new file mode 100644 index 00000000..c1107a50 --- /dev/null +++ b/app/Models/NfcVoucher.php @@ -0,0 +1,22 @@ + + + + ID + NFC Tipo + NFC Siguiente + NFC Vencimiento + NFC Cantidad + NFC Próximo + NFC Estado + NFC Usado + + + + @foreach($nfc_vouchers as $nfc_voucher) + + {{ $nfc_voucher->id }} + {{ $nfc_voucher->nfc_type }} + {{ $nfc_voucher->nfc_following }} + {{ $nfc_voucher->nfc_expiration }} + {{ $nfc_voucher->nfc_amount }} + {{ $nfc_voucher->nfc_next }} + + @if($nfc_voucher->nfc_select == 'active') + Activo + @elseif($nfc_voucher->nfc_select == 'deactivated') + Desactivado + @endif + + + @if($nfc_voucher->nfc_used == 'not_use') + No usado + @elseif($nfc_voucher->nfc_used == 'in_use') + En uso + @endif + + + @endforeach + + + diff --git a/resources/views/seller/pos/pos_activation.blade.php b/resources/views/seller/pos/pos_activation.blade.php index 158386e1..39fed097 100644 --- a/resources/views/seller/pos/pos_activation.blade.php +++ b/resources/views/seller/pos/pos_activation.blade.php @@ -29,7 +29,192 @@ +
+
+
+
{{ translate('Lista de comprobantes fiscales') }}
+ +
+ {{-- Exportar (Collection) --}} + Exportar en excel + + + +
+ +
+ + + + +
+ + + + + + + + + + + + + + + @foreach($nfc_vouchers as $nfc_voucher) + + + + + + + + + + + @endforeach + +
IDNFC TipoNFC SiguienteNFC VencimientoNFC CantidadNFC PróximoNFC EstadoNFC Usado
{{ $nfc_voucher->id }}{{ $nfc_voucher->nfc_type }}{{ $nfc_voucher->nfc_following }}{{ $nfc_voucher->nfc_expiration }}{{ $nfc_voucher->nfc_amount }}{{ $nfc_voucher->nfc_next }} + @if($nfc_voucher->nfc_select == 'active') + Activo + @elseif($nfc_voucher->nfc_select == 'deactivated') + Desactivado + @endif + + @if($nfc_voucher->nfc_used == 'not_use') + No usado + @elseif($nfc_voucher->nfc_used == 'in_use') + En uso + @endif +
+
+
+
+ + + + + + + {{-- @dd($nfc_vouchers) --}} + {{-- --}} @endsection + +@push('styles') + +@endpush + +@push('scripts') + + + + + + +@endpush diff --git a/routes/pos.php b/routes/pos.php index 467a37a4..aa07ff9f 100644 --- a/routes/pos.php +++ b/routes/pos.php @@ -13,6 +13,7 @@ use App\Http\Controllers\PosController; use App\Http\Controllers\BusinessSettingsController; +use App\Http\Controllers\NfcVouchersController; use App\Http\Controllers\Seller\PosController as SellerPosController; Route::controller(PosController::class)->group(function () { @@ -37,6 +38,9 @@ Route::group(['prefix' => 'admin', 'middleware' => ['auth', 'admin']], function Route::get('/pos-activation', 'configuration')->name('poin-of-sales.activation'); Route::get('/pos/thermal-printer/{order_id}', 'invoice')->name('admin.invoice.thermal_printer'); }); + + // + }); //Seller @@ -44,8 +48,18 @@ Route::group(['prefix' => 'seller', 'middleware' => ['seller', 'verified']], fun Route::controller(SellerPosController::class)->group(function () { Route::get('/pos', 'index')->name('poin-of-sales.seller_index'); Route::get('/pos/thermal-printer/{order_id}', 'invoice')->name('seller.invoice.thermal_printer'); + //aqui esta el index o lista de NFC Route::get('/pos-activation', 'configuration')->name('pos.configuration'); Route::get('/pos/products', 'search')->name('pos.search_seller_product'); }); - Route::post('/pos-configuration', [BusinessSettingsController::class, 'update'])->name('seller_business_settings.update'); + Route::post('/pos-configuration', [BusinessSettingsController::class, 'update'])->name('seller_business_settings.update'); + + + //configuracion de los comprobantes NFC + //CREAR NFC + Route::post('/nfc_store', [NfcVouchersController::class, 'store'])->name('pos.configuration.store'); + //EXPORTAR por exel + Route::get('/nfc_configuration/collection', [NfcVouchersController::class, 'collection'])->name('pos.configuration.collection'); + Route::get('/nfc_configuration/view', [NfcVouchersController::class, 'view'])->name('pos.configuration.view'); + });