diff --git a/app/Http/Controllers/DetailSaleController.php b/app/Http/Controllers/DetailSaleController.php new file mode 100644 index 0000000..3135500 --- /dev/null +++ b/app/Http/Controllers/DetailSaleController.php @@ -0,0 +1,109 @@ +with('i', (request()->input('page', 1) - 1) * $detailSales->perPage()); + } + + /** + * Show the form for creating a new resource. + * + * @return \Illuminate\Http\Response + */ + public function create() + { + $detailSale = new DetailSale(); + return view('detail-sale.create', compact('detailSale')); + } + + /** + * Store a newly created resource in storage. + * + * @param \Illuminate\Http\Request $request + * @return \Illuminate\Http\Response + */ + public function store(Request $request) + { + request()->validate(DetailSale::$rules); + + $detailSale = DetailSale::create($request->all()); + + return redirect()->route('detail-sales.index') + ->with('success', 'DetailSale created successfully.'); + } + + /** + * Display the specified resource. + * + * @param int $id + * @return \Illuminate\Http\Response + */ + public function show($id) + { + $detailSale = DetailSale::find($id); + + return view('detail-sale.show', compact('detailSale')); + } + + /** + * Show the form for editing the specified resource. + * + * @param int $id + * @return \Illuminate\Http\Response + */ + public function edit($id) + { + $detailSale = DetailSale::find($id); + + return view('detail-sale.edit', compact('detailSale')); + } + + /** + * Update the specified resource in storage. + * + * @param \Illuminate\Http\Request $request + * @param DetailSale $detailSale + * @return \Illuminate\Http\Response + */ + public function update(Request $request, DetailSale $detailSale) + { + request()->validate(DetailSale::$rules); + + $detailSale->update($request->all()); + + return redirect()->route('detail-sales.index') + ->with('success', 'DetailSale updated successfully'); + } + + /** + * @param int $id + * @return \Illuminate\Http\RedirectResponse + * @throws \Exception + */ + public function destroy($id) + { + $detailSale = DetailSale::find($id)->delete(); + + return redirect()->route('detail-sales.index') + ->with('success', 'DetailSale deleted successfully'); + } +} diff --git a/app/Http/Controllers/SaleController.php b/app/Http/Controllers/SaleController.php new file mode 100644 index 0000000..921fc63 --- /dev/null +++ b/app/Http/Controllers/SaleController.php @@ -0,0 +1,122 @@ +with('i', (request()->input('page', 1) - 1) * $sales->perPage()); + } + + public function create() + { + $products = Product::all(); + $sale = new Sale(); + + return view('Admin.Sale.create', compact('sale', 'products')); + } + + public function store(Request $request) + { + $request->validate([ + 'date' => 'required', + 'product_id.*' => 'required|distinct', + 'quantity.*' => 'required|numeric', + 'price.*' => 'required|numeric', + ]); + + $sale = Sale::create([ + 'date' => $request->input('date'), + ]); + + $productData = []; + $productIds = $request->input('product_id'); + $quantities = $request->input('quantity'); + $prices = $request->input('price'); + + $total = 0; + + foreach ($productIds as $key => $productId) { + $quantity = $quantities[$key]; + $price = $prices[$key]; + + $subtotal = $quantity * $price; + $total += $subtotal; + + $productData[$productId] = [ + 'quantity' => $quantity, + 'price' => $price, + ]; + } + + $sale->total = $total; + $sale->save(); + + $sale->products()->sync($productData); + + return redirect()->route('sales.index')->with('created', 'Venta creada con éxito'); + } + + public function show($id) + { + $sale = Sale::find($id); + $products = $sale->products; + + return view('Admin.sale.show', compact('sale', 'products')); + } + + public function edit($id) + { + $sale = Sale::find($id); + $products = $sale->products; + + return view('Admin.sale.edit', compact('sale', 'products')); + } + + public function update(Request $request, $id) + { + $request->validate([ + 'date' => 'required', + ]); + + $sale = Sale::find($id); + + $productData = []; + $productIds = $request->input('product_id'); + $quantities = $request->input('quantity'); + $prices = $request->input('price'); + + $total = 0; + + foreach ($productIds as $key => $productId) { + $productData[$productId] = [ + 'quantity' => $quantities[$key], + 'price' => $prices[$key], + ]; + + $subtotal = $quantities[$key] * $prices[$key]; + $total += $subtotal; + } + + $sale->products()->sync($productData); + $sale->total = $total; + $sale->save(); + + return redirect()->route('sales.index')->with('updated', 'Venta actualizada con éxito'); + } + + public function destroy($id) + { + $sale = Sale::find($id)->delete(); + + return redirect()->route('sales.index')->with('deleted', 'Venta eliminada con éxito'); + } +} diff --git a/app/Models/DetailSale.php b/app/Models/DetailSale.php new file mode 100644 index 0000000..cbee154 --- /dev/null +++ b/app/Models/DetailSale.php @@ -0,0 +1,58 @@ + 'required', + 'product_id' => 'required', + 'quantity' => 'required', + 'price' => 'required', + ]; + + protected $perPage = 20; + + /** + * Attributes that should be mass-assignable. + * + * @var array + */ + protected $fillable = ['sale_id','product_id','quantity','price']; + + + /** + * @return \Illuminate\Database\Eloquent\Relations\HasOne + */ + public function product() + { + return $this->belongsTo(Product::class); + } + + /** + * @return \Illuminate\Database\Eloquent\Relations\HasOne + */ + public function sale() + { + return $this->hasOne('App\Models\Sale', 'id', 'sale_id'); + } +} diff --git a/app/Models/Sale.php b/app/Models/Sale.php new file mode 100644 index 0000000..fd66344 --- /dev/null +++ b/app/Models/Sale.php @@ -0,0 +1,50 @@ + 'required', + 'total' => 'required', + ]; + + protected $perPage = 20; + + /** + * Attributes that should be mass-assignable. + * + * @var array + */ + protected $fillable = ['date','total']; + + + /** + * @return \Illuminate\Database\Eloquent\Relations\HasMany + */ + public function detailSales() + { + return $this->hasMany('App\Models\DetailSale', 'sale_id', 'id'); // Un detalle de venta tiene muchos productos y está ligado a una venta + } + + public function products() + { + return $this->belongsToMany(Product::class, 'detail_sale')->withPivot('quantity', 'price'); + } +} diff --git a/database/migrations/2023_12_05_155131_sales.php b/database/migrations/2023_12_05_155131_sales.php new file mode 100644 index 0000000..bf6a9ef --- /dev/null +++ b/database/migrations/2023_12_05_155131_sales.php @@ -0,0 +1,29 @@ +id(); + $table->date("date"); + $table->decimal("total")->default(0.0); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + // + } +}; diff --git a/database/migrations/2023_12_05_155143_detail_sale.php b/database/migrations/2023_12_05_155143_detail_sale.php new file mode 100644 index 0000000..202c8c4 --- /dev/null +++ b/database/migrations/2023_12_05_155143_detail_sale.php @@ -0,0 +1,34 @@ +id(); + $table->bigInteger('sale_id')->unsigned(); + $table->bigInteger('product_id')->unsigned(); + $table->integer('quantity'); + $table->decimal('price', 10, 2); + $table->timestamps(); + + $table->foreign('sale_id')->references('id')->on('sales')->onDelete('cascade'); + $table->foreign('product_id')->references('id')->on('products')->onDelete('cascade'); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + // + } +}; diff --git a/public/assets/css/Admin/modules/Sales/form-styles.css b/public/assets/css/Admin/modules/Sales/form-styles.css index 3261af2..5e56d47 100644 --- a/public/assets/css/Admin/modules/Sales/form-styles.css +++ b/public/assets/css/Admin/modules/Sales/form-styles.css @@ -1,3 +1,355 @@ -.tabla-registro-venta{ - margin: -0.8rem 0 0; +/* Contenedor de nueva factura */ +.cont-venta{ + height: auto; + margin-top: 2rem; } + +.cont-venta, .cont-info-venta, .cont-productos-venta{ + display: flex; + width: 100%; +} + +.cont-venta, .cont-info-venta{ + flex-direction: column; +} + + /* Contenedor información de factura */ + .cont-info-venta{ + height: 130px; + background-color: #D9D9D9; + border: 1px solid black; + justify-content: center; + align-items: center; + padding: 1rem 0 1rem; + } + + /* Label */ + .lbl-venta{ + display: flex; + width: 95%; + height: 35px; + font-size: 20px; + } + + /* Fecha, Cliente */ + #fechaVenta{ + display: flex; + width: 95%; + height: 30px; + padding: 0 5px 0; + font-size: 15px; + } + + #fechaVenta{ + margin-bottom: 8px; + } + + /* Tabla lista de productos de factura */ + .tab-productos-venta{ + height: auto; + margin: 1.5rem 0 2rem; + } + + /* Columnas caracteísticas de factura */ + .columnas-caract, .filas-datos{ + display: flex; + width: 100%; + justify-content: space-between; + } + + .columnas-caract{ + height: 35px; + } + + .item-columna, .item-fila{ + display: flex; + justify-content: center; + align-items: center; + border: 1px solid black; + } + + .item-columna{ + background-color: #212EC2; + font-size: 17px; + color: white; + } + + .filas-datos{ + height: 30px; + } + + .nombre-prod, .nombre-prod-dato{ + width: 50.7%; + } + + .cantidad-prod, .cantidad-prod-dato{ + width: 20%; + } + + .precio-prod, .precio-prod-dato{ + width: 25%; + } + + .elim-fila, .elim-fila-dato{ + width: 4%; + } + + .elim-fila-dato{ + background-color: #D9D9D9; + cursor: pointer; + } + + .elim-fila img, .elim-fila-dato img{ + width: 16.5px; + height: 20px; + } + + #seleccionarProducto, #cantidadProd, #precioProd{ + display: flex; + width: 100%; + height: 100%; + background-color: #D9D9D9; + font-size: 13.5px; + border: none; + } + + #seleccionarProducto{ + padding: 0 7px 0; + border: none; + } + + .item-fila input{ + display: flex; + justify-content: center; + align-items: center; + text-align: center; + border: none; + } + +/* Contenedor añadir fila */ +.cont-anadir-fila{ + display: flex; + width: 100%; + height: 35px; + margin: 2rem 0 1.5rem; +} + + /* Botón */ + .btn-anadir-fila{ + display: flex; + width: 200px; + height: auto; + border: 1px solid black; + border-radius: 7px; + background-color: #36BBFF; + font-size: 17px; + color: white; + align-items: center; + justify-content: center; + font-weight: bold; + cursor: pointer; + } + +/* Opciones factura */ +.opciones-venta{ + display: flex; + width: 100%; + height: 35px; + margin-top: 2rem; + justify-content: space-between; +} + + /* Botón: Cancelar */ + .bott-cancelar{ + display: flex; + width: 165px; + background-color: red; + border: 1px solid black; + border-radius: 7px; + justify-content: center; + align-items: center; + } + + .bott-cancelar h2{ + color: white; + font-size: 17px; + } + + /* Botón: Crear factura */ + .bott-guardar-cambios{ + display: flex; + width: 220px; + background-color: #2121E3; + border: 1px solid black; + border-radius: 7px; + justify-content: center; + align-items: center; + } + + .bott-guardar-cambios a h2{ + color: white; + font-size: 17px; + } + +/* @media */ + /* @media 1024px */ + @media(max-width: 1024px){ + .cont-venta{ + margin-top: 1.5rem; + } + + .cont-info-venta{ + height: 95px; + } + + .lbl-venta{ + font-size: 15px; + height: auto; + margin: 0 0 10px; + } + + #fechaVenta{ + height: 25px; + padding: 0 2.5px 0; + font-size: 12px; + } + + .tab-productos-venta{ + margin: 1rem 0 1.5rem; + } + + .columnas-caract{ + height: 30px; + } + + .item-columna{ + font-size: 14px; + } + + .nombre-prod, .nombre-prod-dato{ + width: 47.7%; + } + + .cantidad-prod, .cantidad-prod-dato{ + width: 20%; + } + + .precio-prod, .precio-prod-dato{ + width: 25%; + } + + .elim-fila, .elim-fila-dato{ + width: 7%; + } + + .elim-fila-dato{ + background-color: #D9D9D9; + cursor: pointer; + } + + .elim-fila img, .elim-fila-dato img{ + width: 16.5px; + height: 20px; + } + + .elim-fila img, .elim-fila-dato img{ + width: 14px; + height: 18px; + } + + #seleccionarProducto, #cantidadProd, #precioProd{ + font-size: 12px; + } + + .opciones-venta{ + margin-top: 0.5rem; + } + + .bott-guardar-cambios{ + width: 180px; + height: 30px; + } + + .btn-anadir-fila, .bott-cancelar{ + height: 30px; + width: 150px; + } + + .bott-guardar-cambios a h2, .btn-anadir-fila, .bott-cancelar a h2{ + font-size: 13.5px; + } + } + + /* @media 425px */ + @media(max-width: 425px){ + .cont-info-venta{ + height: 85px; + } + + .lbl-venta{ + width: 90%; + font-size: 13px; + } + + #fechaVenta{ + width: 90%; + height: 35px; + padding: 10px 5px 10px; + } + + .columnas-caract{ + height: 27.5px; + } + + .item-columna, #seleccionarProducto, #cantidadProd, #precioProd, + .btn-anadir-fila, .bott-cancelar a h2, .bott-guardar-cambios a h2, + #fechaVenta{ + font-size: 10px; + } + + .filas-datos{ + height: 25px; + } + + .nombre-prod, .nombre-prod-dato{ + width: 48%; + } + + .cantidad-prod, .cantidad-prod-dato{ + width: 20%; + } + + .precio-prod, .precio-prod-dato{ + width: 22%; + } + + .elim-fila, .elim-fila-dato{ + width: 9%; + } + + .elim-fila-dato{ + background-color: #D9D9D9; + cursor: pointer; + } + + .elim-fila img, .elim-fila-dato img{ + width: 11px; + height: 13px; + } + + .cont-anadir-fila, .opciones-venta{ + height: 27.5px; + } + + .btn-anadir-fila, .bott-cancelar, .bott-guardar-cambios{ + height: 100%; + } + + .bott-cancelar{ + width: 100px; + } + + .bott-guardar-cambios, .btn-anadir-fila{ + width: 120px; + } + } diff --git a/public/assets/css/Admin/modules/Sales/sales-styles.css b/public/assets/css/Admin/modules/Sales/sales-styles.css new file mode 100644 index 0000000..ee46845 --- /dev/null +++ b/public/assets/css/Admin/modules/Sales/sales-styles.css @@ -0,0 +1,486 @@ +/* Filtros de búsqueda */ +.filtros-busqueda{ + display: flex; + width: 100%; + height: 30px; + justify-content: space-between; + margin-top: 25px; +} + + /* Ordenar por */ + .ordenar_por{ + display: flex; + width: 45%; + height: 100%; + } + + #ordenar_por{ /* Input */ + border-radius: 0; + width: 60%; + font-size: 14px; + border: 1px solid black; + padding: 0 7px 0; + } + + /* Barra búsqueda */ + .barra_busqueda{ + display: flex; + width: 55%; + height: 100%; + justify-content: end; + border-radius: 5px; + } + + #barra_busqueda{ + border-radius: 5px; + width: 50%; + font-size: 14px; + border: 1px solid black; + padding: 10px; + } + +/* Contenedor ventas */ +.cont-ventas{ + display: flex; + width: 100%; + height: auto; + justify-content: space-between; + margin: 2.5rem 0 0; +} + + /* Contenedor lista de ventas */ + .cont-lista-ventas{ + width: 70%; + } + + /* Contenedor Opciones de ventas */ + .cont-opciones-venta{ + width: 30.5%; + } + + .cont-ventas, .cont-opciones-venta{ + display: flex; + height: 100%; + } + + .cont-opciones-venta, .opciones-venta{ + flex-direction: column; + align-items: end; + } + + /* Opciones venta */ + .opciones-venta{ + display: flex; + width: 90%; + } + + /* Contenedor opción venta */ + .cont-opcion-venta{ + display: flex; + width: 100%; + min-height: 150px; + max-height: 200px; + background-color: #D9D9D9; + border: 1px solid black; + justify-content: center; + align-items: center; + margin-bottom: 10px; + } + + .link-sect-venta, + .cont-opcion-venta a h2{ + font-size: 22px; + margin-left: 10px; + font-weight: lighter; + } + + .cont-opcion-venta img{ + width: 70px; + height: 70px; + } + + .no-records{ + display: flex; + width: 100%; + height: auto; + } + + /* Tabla ventas */ + .tabla-ventas{ + display: flex; + width: 100%; + height: auto; + flex-direction: column; + } + + .columnas-caract-venta{ + display: flex; + width: 100%; + color: white; + justify-content: space-between; + height: 35px; + } + + .item-columna{ + display: flex; + width: 100%; + height: 100%; + justify-content: center; + align-items: center; + font-size: 16.5px; + color: white; + background-color: #212EC2; + border: 1px solid black; + } + + .num-venta, .num-venta-dato{ + display: flex; + width: 20%; + } + + .fecha-venta, .fecha-venta-dato{ + display: flex; + width: 20%; + } + + .total-venta, .total-venta-dato{ + display: flex; + width: 19%; + } + + .opciones-venta-tabla, .opciones-venta-tabla-dato{ + display: flex; + width: 40.5%; + } + + .opciones-venta-tabla-dato{ + justify-content: space-between; + } + + /* Columnas datos de filas */ + .filas-datos{ + display: flex; + width: 100%; + height: 35px; + color: black; + margin-top: 3px; + } + + .item-fila{ + display: flex; + height: 100%; + justify-content: center; + align-items: center; + font-size: 15px; + background-color: #D9D9D9; + border: 1px solid black; + } + + /* Botones Opciones venta */ + .btn-venta{ + display: flex; + height: 100%; + border: 1px solid black; + justify-content: center; + align-items: center; + font-size: 15px; + cursor: pointer; + } + + .btn-venta img{ + width: 13.5px; + height: 13.5px; + margin-left: 7px; + } + + /* Ver */ + .btn-ver{ + width: 28.5%; + background-color: #36BBFF; + } + + .btn-venta a img{ + margin-top: 5px; + } + + /* Editar */ + .btn-editar{ + width: 35%; + background-color: #1988CF; + } + + /* Eliminar */ + .btn-eliminar{ + width: 35.5%; + background-color: red; + } + + .eliminar-venta{ + display: flex; + width: 100%; + height: 100%; + background-color: red; + } + +/* @media */ + /* @media 1024px */ + @media(max-width: 1024px){ + .cont-busqueda{ + margin: 2rem 0 1rem; + height: 32.5px; + } + + #buscarventa{ + width: 52.5%; + } + + .link-sect-venta{ + display: none; + } + + .cont-lista-ventas{ + width: 120%; + } + + .cont-opcion-venta{ + width: 120px; + height: 120px; + min-width: 100px; + min-height: 100px; + } + + .cont-opcion-venta img{ + margin: 0; + width: 55px; + height: 55px; + } + + .columnas-caract-venta{ + height: 32.5px; + } + + .item-columna{ + font-size: 15px; + } + + .filas-datos{ + height: 27.5px; + } + + .item-fila, .btn-venta{ + font-size: 13px; + } + + .btn-venta img{ + width: 10px; + height: 10px; + } + + + .btn-venta a img{ + margin-top: 5px; + } + } + + /* @media 768px */ + @media(max-width: 768px){ + .cont-busqueda{ + height: 27.5px; + margin: 2rem 0 1.5rem; + } + + #buscarventa{ + font-size: 11.7px; + } + + .btn-venta img{ + margin: 0; + } + + .link-op-venta{ + display: none; + } + + .columnas-caract-venta{ + height: 30px; + } + + .item-columna{ + font-size: 12px; + } + + .filas-datos{ + height: 25px; + } + + .item-fila, .btn-venta{ + font-size: 10px; + } + + .btn-venta img{ + width: 12px; + height: 12px; + } + + .num-venta, .num-venta-dato{ + width: 20%; + } + + .fecha-venta, .fecha-venta-dato{ + width: 20%; + } + + .total-venta, .total-venta-dato{ + width: 20.5%; + } + + .opciones-venta-tabla, .opciones-venta-tabla-dato{ + width: 38.5%; + } + + .opciones-venta-tabla-dato{ + justify-content: space-between; + } + + .btn-editar, .btn-eliminar, .btn-ver{ + width: 32.8%; + } + + .eliminar-venta{ + font-size: 0; + } + + .cont-opcion-venta{ + width: 70px; + height: 70px; + min-width: 60px; + min-height: 60px; + } + + .cont-opcion-venta img{ + width: 30px; + height: 30px; + } + + .btn-venta a img{ + margin-top: 3.5px; + } + } + + /* @media 425px */ + @media(max-width: 425px){ + .cont-busqueda{ + margin: 1.5rem 0 1rem; + height: 26px; + } + + /* Filtros de búsqueda */ + .filtros-busqueda{ + height: 15px; + margin-top: 25px; + align-items: center; + } + + #ordenar_por, #barra_busqueda{ + font-size: 9px; + } + + #ordenar_por{ + width: 70%; + } + + #barra_busqueda{ + width: 100%; + } + + .ordenar_por, .barra_busqueda{ + width: 50%; + height: 18px; + } + + .cont-ventas{ + flex-direction: column-reverse; + margin: 0; + height: auto; + } + + .cont-lista-ventas{ + width: 100%; + margin: 0; + } + + .cont-opciones-venta{ + width: 100%; + max-height: 50px; + height: 50px; + margin: 1.5rem 0 1rem; + } + + .opciones-venta{ + width: 100%; + height: 100%; + align-items: start; + justify-content: center; + } + + .cont-opcion-venta{ + width: auto; + height: 100%; + padding: 0 1rem 0; + margin: 0; + } + + .cont-opcion-venta img{ + margin: 0; + width: 20px; + height: 20px; + } + + .link-sect-venta, + .cont-opcion-venta a h2{ + display: flex; + margin-left: 5px; + font-size: 12px; + } + + .btn-venta img{ + width: 10px; + height: 10px; + } + + .columnas-caract-venta{ + height: 25px; + } + + .item-columna{ + font-size: 10px; + } + + .filas-datos{ + height: 22.5px; + } + + .num-venta, .num-venta-dato{ + width: 19%; + } + + .fecha-venta, .fecha-venta-dato{ + width: 21%; + } + + .total-venta, .total-venta-dato{ + width: 21.5%; + } + + .opciones-venta-tabla, .opciones-venta-tabla-dato{ + width: 37.5%; + } + + .item-fila, .btn-venta{ + font-size: 9.2px; + } + + .eliminar-venta{ + font-size: 0; + } + } diff --git a/public/assets/css/Admin/modules/Sales/sales.css b/public/assets/css/Admin/modules/Sales/sales.css deleted file mode 100644 index 8bf6b30..0000000 --- a/public/assets/css/Admin/modules/Sales/sales.css +++ /dev/null @@ -1,330 +0,0 @@ -/* Contenedor opciones de ventas */ -.cont-ops-ventas{ - display: flex; - width: 100%; - height: 65px; - margin: 2rem 0 1.5rem; -} - - /* Contenedor Registrar venta, Contenedor Filtrar venta */ - .cont-registrar-venta, .cont-filtrar-venta{ - display: flex; - width: 50%; - height: 100%; - } - - .cont-filtrar-venta{ - justify-content: end; - align-items: center; - } - - .btn-registrar-venta{ - display: flex; - width: 45%; - height: 100%; - align-items: center; - justify-content: center; - background-color: #D9D9D9; - border: 1px solid black; - cursor: pointer; - } - - .btn-registrar-venta:hover{ - background-color: white; - transition: 0.3s; - } - - .btn-registrar-venta img{ - display: flex; - width: 35px; - height: 35px; - margin-left: 15px; - } - - .btn-registrar-venta a h2{ - font-size: 20px; - } - - #filtrarVenta{ - display: flex; - width: 60%; - height: 30px; - font-size: 14px; - border: 1px solid black; - padding: 0 7px; - } - -/* Tabla Ventas */ -.tabla-ventas{ - display: flex; - width: 100%; - height: auto; - flex-direction: column; -} - - /* Columnas */ - .columnas-caract, .filas-dato{ - display: flex; - width: 100%; - justify-content: space-between; - color: white; - } - - .columnas-caract{ - height: 35px; - } - - .filas-dato{ - height: 32px; - margin: 4px 0 0; - } - - .item-columna, .item-fila{ - display: flex; - justify-content: center; - align-items: center; - border: 1px solid black; - } - - .item-columna{ - font-size: 16.5px; - color: white; - background-color: #212EC2; - } - - .item-fila{ - font-size: 15px; - color: black; - background-color: #D9D9D9; - } - - /* No */ - .no-venta, .no-venta-dato{ - width: 15.5%; - } - - /* Fecha */ - .fecha-venta, .fecha-venta-dato{ - width: 25%; - } - - /* Total */ - .total-venta, .total-venta-dato{ - width: 29%; - } - - /* Acciones */ - .acciones-venta, .acciones-venta-dato{ - width: 30%; - } - - .acciones-venta-dato{ - justify-content: space-between; - border: 0; - } - - /* Botones Acciones */ - .btn-editar-venta, .btn-eliminar-venta{ - display: flex; - width: 49.6%; - height: 100%; - align-items: center; - justify-content: center; - border: 1px solid black; - cursor: pointer; - } - - .btn-editar-venta{ - background-color: #1988CF; - } - - .btn-eliminar-venta{ - background-color: red; - } - - .btn-editar-venta a, .btn-eliminar-venta a{ - font-size: 15px; - } - - .btn-editar-venta a img, .btn-eliminar-venta a img{ - display: flex; - width: 14px; - height: 14px; - margin-left: 5px; - } - -/* @media */ - /* @media 1024px */ - @media(max-width: 1024px){ - .cont-ops-ventas{ - height: 50px; - margin: 1rem 0 1rem; - } - - .btn-registrar-venta{ - width: 50%; - } - - .btn-registrar-venta a h2{ - font-size: 0.9rem; - } - - .btn-registrar-venta img{ - width: 22.5px; - height: 22.5px; - } - - #filtrarVenta{ - width: 80%; - height: 28px; - font-size: 14px; - } - - .columnas-caract{ - height: 32.5px; - } - - .item-columna{ - font-size: 15px; - } - - .filas-dato{ - height: 27.5px; - } - - .item-fila, .btn-editar-venta a h2, .btn-eliminar-venta a h2{ - font-size: 13px; - } - - .btn-editar-venta a img, .btn-eliminar-venta a img{ - width: 12px; - height: 12px; - } - } - - /* @media 768px */ - @media(max-width: 768px){ - .cont-ops-ventas{ - height: 45px; - } - - .btn-registrar-venta{ - width: 65%; - } - - .btn-registrar-venta a h2{ - font-size: 12px; - font-weight: lighter; - } - - #filtrarVenta{ - width: 85%; - height: 25px; - font-size: 12px; - } - - .columnas-caract{ - height: 30px; - } - - .item-columna{ - font-size: 12px; - } - - .filas-dato{ - height: 25px; - } - - .item-fila, .btn-editar-venta a, .btn-eliminar-venta a{ - font-size: 10px; - } - - .btn-editar-venta a img, .btn-eliminar-venta a img{ - width: 9px; - height: 9px; - } - } - - /* @media 425px */ - @media(max-width: 425px){ - .cont-ops-ventas{ - flex-direction: column-reverse; - height: 100px; - margin: 1rem 0 0; - } - - .cont-registrar-venta, .cont-filtrar-venta{ - width: 100%; - height: 50%; - justify-content: end; - } - - .cont-registrar-venta{ - margin: -0.5rem 0 0; - } - - .cont-filtrar-venta{ - align-items: start; - } - - .btn-registrar-venta{ - width: 60%; - height: 90%; - } - - .btn-registrar-venta a h2{ - font-size: 12px; - font-weight: bold; - } - - .btn-registrar-venta img{ - margin-left: 8px; - } - - #filtrarVenta{ - width: 70%; - height: 25px; - padding: 0; - padding-left: 5px; - } - - .tabla-ventas{ - margin-top: 0.5rem; - } - - .link-btn-opcion{ - display: none; - } - - .columnas-caract{ - height: 25px; - } - - .item-columna{ - font-size: 10px; - } - - .filas-dato{ - height: 22.5px; - } - - .item-fila{ - font-size: 9.2px; - } - - .num-factura, .num-factura-dato{ - width: 22%; - } - - .fecha-factura, .fecha-factura-dato{ - width: 25%; - } - - .opciones-factura-tabla, .opciones-factura-tabla-dato{ - width: 49.5%; - } - - .btn-editar-venta a img, .btn-eliminar-venta a img{ - margin: 0; - } - } diff --git a/public/assets/css/Admin/modules/Sales/show-styles.css b/public/assets/css/Admin/modules/Sales/show-styles.css new file mode 100644 index 0000000..740057c --- /dev/null +++ b/public/assets/css/Admin/modules/Sales/show-styles.css @@ -0,0 +1,343 @@ +/* Contenedor de nueva venta */ +.cont-venta{ + height: auto; + margin-top: 2rem; +} + +.cont-venta, .cont-info-venta, .cont-productos-venta{ + display: flex; + width: 100%; +} + +.cont-venta, .cont-info-venta{ + flex-direction: column; +} + + /* Contenedor información de venta */ + .cont-info-venta{ + height: 130px; + background-color: #D9D9D9; + border: 1px solid black; + justify-content: center; + align-items: center; + } + + /* Número de venta */ + .num-venta{ + display: flex; + width: 100%; + height: 30%; + padding: 0 2rem 0; + } + + .num-venta h2, .num-venta h3{ + display: flex; + width: auto; + height: 100%; + font-size: 20px; + align-items: center; + justify-content: start; + } + + .num-venta h3{ + margin: 0 10px 0; + font-weight: lighter; + } + + /* Fecha, Cliente */ + .fecha-venta, .cliente-venta{ + display: flex; + width: 100%; + height: 20%; + padding: 0 2rem 0; + align-items: center; + justify-content: start; + font-size: 17px; + } + + .fecha-venta h2, .cliente-venta h2{ + display: flex; + font-size: 17.5px; + font-weight: bold; + } + + .fecha-venta h3, .cliente-venta h3{ + display: flex; + margin: 0 5px 0; + font-weight: lighter; + font-size: 16.5px; + } + + + /* Tabla lista de productos de venta */ + .tab-productos-venta{ + height: auto; + margin: 1.5rem 0 2rem; + } + + /* Columnas caracteísticas de venta */ + .columnas-caract, .filas-datos{ + display: flex; + width: 100%; + justify-content: space-between; + } + + .columnas-caract{ + height: 35px; + } + + .item-columna, .item-fila{ + display: flex; + justify-content: center; + align-items: center; + border: 1px solid black; + } + + .item-columna{ + background-color: #212EC2; + font-size: 17px; + color: white; + } + + .item-fila{ + background-color: #D9D9D9; + font-size: 14px; + } + + .filas-datos{ + height: 30px; + } + + .cols-total{ + display: flex; + margin: 3px 0 0; + justify-content: space-between; + } + + .nombre-prod, .nombre-prod-dato, .texto-total{ + width: 54.7%; + } + + .cantidad-prod, .cantidad-prod-dato, .cantidad-total{ + width: 20%; + } + + .precio-prod, .precio-prod-dato, .precio-total{ + width: 25%; + } + + #seleccionarProducto, #cantidadProd, #precioProd{ + display: flex; + width: 100%; + height: 100%; + background-color: #D9D9D9; + font-size: 13.5px; + border: none; + } + + #seleccionarProducto{ + padding: 0 7px 0; + border: none; + } + + /* Contenedor Volver */ + .cont-volver{ + display: flex; + width: 100%; + height: 35px; + } + + .link-btn-volver{ + display: flex; + width: auto; + height: 100%; + } + + .btn-volver{ + display: flex; + width: 160px; + height: 100%; + background-color: #808080; + border: 1px solid black; + border-radius: 7px; + justify-content: center; + align-items: center; + cursor: pointer; + } + + .btn-volver:hover{ + background-color: #D9D9D9; + transition: 0.3s; + } + + .btn-volver img{ + display: flex; + width: 14px; + height: 14px; + } + + .btn-volver h2{ + font-size: 17px; + margin-left: 8px; + font-weight: lighter; + } + +/* @media */ + /* @media 1024px */ + @media(max-width: 1024px){ + .cont-venta{ + margin-top: 1.5rem; + } + + .cont-info-venta{ + height: 100px; + } + + .num-venta h2, .num-venta h3{ + font-size: 14px; + } + + .fecha-venta h2, .fecha-venta h3, + .cliente-venta h2, .cliente-venta h3{ + font-size: 14px; + } + + .tab-productos-venta{ + margin: 1rem 0 1.5rem; + } + + .columnas-caract{ + height: 30px; + } + + .item-columna{ + font-size: 14px; + } + + .filas-datos{ + height: 27.5px; + } + + .item-fila{ + font-size: 12px; + } + + .nombre-prod, .nombre-prod-dato, .texto-total{ + width: 54.7%; + } + + .cantidad-prod, .cantidad-prod-dato, .cantidad-total{ + width: 20%; + } + + .precio-prod, .precio-prod-dato, .precio-total{ + width: 25%; + } + + #seleccionarProducto, #cantidadProd, #precioProd{ + font-size: 12px; + } + + .cont-volver{ + height: 30px; + } + + .btn-volver{ + width: 140px; + } + + .btn-volver h2{ + font-size: 14px; + } + + .btn-volver img{ + width: 12px; + height: 12px; + } + } + + /* @media 768px */ + @media(max-width: 768px){ + .cont-volver{ + height: 27.5px; + } + + .btn-volver{ + width: 125px; + } + + .btn-volver h2{ + font-size: 12.5px; + } + + .btn-volver img{ + width: 10px; + height: 10px; + } + + .num-venta, .fecha-venta, .cliente-venta{ + padding: 0 1.5rem 0; + } + } + + /* @media 425px */ + @media(max-width: 425px){ + .cont-info-venta{ + height: 65px; + } + + .columnas-caract{ + height: 27.5px; + } + + .num-venta, .cliente-venta, .fecha-venta{ + padding: 0 1rem 0; + } + + .item-columna, #seleccionarProducto, #cantidadProd, #precioProd, + .btn-anadir-fila, .bott-cancelar a h2, .bott-guardar-cambios a h2, + .num-venta h2, .num-venta h3, .fecha-venta h2, .fecha-venta h3, + .cliente-venta h2, .cliente-venta h3 + { + font-size: 10px; + } + + .filas-datos{ + height: auto; + } + + .item-fila{ + padding: 4px; + text-align: center; + font-size: 10px; + } + + .nombre-prod, .nombre-prod-dato, .texto-total{ + width: 55%; + } + + .cantidad-prod, .cantidad-prod-dato, .cantidad-total{ + width: 21%; + } + + .precio-prod, .precio-prod-dato, .precio-total{ + width: 23%; + } + + .cont-volver{ + height: 25px; + } + + .btn-volver{ + width: 100px; + } + + .btn-volver h2{ + font-size: 11px; + } + + .btn-volver img{ + width: 8px; + height: 8px; + } + } diff --git a/public/assets/img/Admin/modules/volver-flecha-icono-negro.png b/public/assets/img/Admin/modules/volver-flecha-icono-negro.png new file mode 100644 index 0000000..8d9c5c6 Binary files /dev/null and b/public/assets/img/Admin/modules/volver-flecha-icono-negro.png differ diff --git a/resources/views/Admin/sale/create.blade.php b/resources/views/Admin/sale/create.blade.php new file mode 100644 index 0000000..a25aeee --- /dev/null +++ b/resources/views/Admin/sale/create.blade.php @@ -0,0 +1,37 @@ +@include("layouts.headerAdmin") + + + + + + + + Ventas | Registrar + + + +
+ +
+

Registrar Venta

+
+ + @includeif('partials.errors') +
+ @csrf + @include('Admin.sale.form') + + {{-- Opciones Venta --}} +
+ + + +
+
+
+ + diff --git a/resources/views/Admin/sale/edit.blade.php b/resources/views/Admin/sale/edit.blade.php new file mode 100644 index 0000000..36a9b9c --- /dev/null +++ b/resources/views/Admin/sale/edit.blade.php @@ -0,0 +1,36 @@ + + + + + + + Editar Venta | No. {{ $sale->id }} + + + +
+ +
+

Editar Venta

+
+ + @includeif('partials.errors') +
+ {{ method_field('PATCH') }} + @csrf + @include('Admin.sale.form') + + {{-- Opciones Venta --}} +
+ + + +
+
+
+ + diff --git a/resources/views/Admin/sale/form.blade.php b/resources/views/Admin/sale/form.blade.php new file mode 100644 index 0000000..b27164b --- /dev/null +++ b/resources/views/Admin/sale/form.blade.php @@ -0,0 +1,119 @@ + + + + + + + + {{-- Estilos para este archivo --}} + + + + +
+ +
+ + + {{ Form::date('date', $sale->date ?? now()->toDateString(), ['class' => 'inp-venta' . ($errors->has('date') ? ' is-invalid' : ''), 'placeholder' => 'Seleccionar una fecha', "id" => "fechaVenta", "name" => "date"]) }} +
+ + + + + + + + + + +
Nombre productoCantidadPrecio /u + +
+ + +
+ +
+ Añadir Producto +
+
+
+ + + + diff --git a/resources/views/Admin/sale/index.blade.php b/resources/views/Admin/sale/index.blade.php new file mode 100644 index 0000000..581f798 --- /dev/null +++ b/resources/views/Admin/sale/index.blade.php @@ -0,0 +1,148 @@ +@include("layouts.headerAdmin") + + + + + + + + Admin | Ventas + + + + + +
+ +
+

Ventas

+
+ + +
+
+ +
+
+ +
+
+ + +
+ +
+ + + + + + + + + + + + @forelse ($sales as $sale) + + + + + + + + {{-- No hay registros de Ventas --}} + @empty + + + + @endforelse +
NoFechaTotalOpciones
{{ $sale->id }}{{ $sale->date }}{{ $sale->total }} $ + + +
+ @csrf + @method('DELETE') + +
+
No hay Registros de Ventas
+
+ + +
+ +
+ + +
+
+
+
+ + {{-- Alertas de acciones de venta --}} + {{-- Alerta de venta creada --}} + @if (session('created')) + + @endif + {{-- Alerta de venta actualizada --}} + @if (session('updated')) + + @endif + {{-- Alerta de venta eliminada --}} + @if (session('deleted')) + + @endif + + @section('content') + + + @endsection + + diff --git a/resources/views/Admin/sale/show.blade.php b/resources/views/Admin/sale/show.blade.php new file mode 100644 index 0000000..36255c5 --- /dev/null +++ b/resources/views/Admin/sale/show.blade.php @@ -0,0 +1,74 @@ +@include("layouts.headerAdmin") + + + + + + + + Ver Venta | No {{ $sale->id }} + + {{-- Estilos para este archivo --}} + + + + +
+ +
+

Ver Venta

+
+ + +
+ +
+ {{-- Número de la venta --}} +
+

Número de la venta:

{{ $sale->id }}

+
+ +
+

Fecha:

{{ $sale->date }}

+
+
+ + + + + + + + + + + + @foreach ($products as $product) + + + + + + @endforeach + + {{-- Total --}} + + + + + +
Nombre productoCantidadPrecio /u
{{ $product->name }}{{ $product->pivot->quantity }}{{ $product->pivot->price }} $
Total{{ $sale->total }} $
+
+ + +
+ + + +
+
+ + diff --git a/resources/views/Admin/sales/index.blade.php b/resources/views/Admin/sales/index.blade.php deleted file mode 100644 index 0aa2eb9..0000000 --- a/resources/views/Admin/sales/index.blade.php +++ /dev/null @@ -1,188 +0,0 @@ -@include("layouts.headerAdmin") - - - - - - - - Administrador | Ventas - - {{-- Hoja de estilos para este archivo --}} - - - - - -
- -
-

Ventas

-
- - -
- -
- - -
- - -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NúmeroFechaTotalAcciones
101/01/20237500 $ - - -
201/01/20237500 $ - - -
301/01/20237500 $ - - -
401/01/20237500 $ - - -
501/01/20237500 $ - - -
601/01/20237500 $ - - -
701/01/20237500 $ - - -
801/01/20237500 $ - - -
901/01/20237500 $ - - -
1001/01/20237500 $ - - -
-
- - diff --git a/resources/views/layouts/headerAdmin.blade.php b/resources/views/layouts/headerAdmin.blade.php index dbe0de8..fb36e6a 100644 --- a/resources/views/layouts/headerAdmin.blade.php +++ b/resources/views/layouts/headerAdmin.blade.php @@ -56,7 +56,7 @@