Compare commits
	
		
			11 commits
		
	
	
		
			667d7dbddb
			...
			67aadf157f
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
							 | 
						67aadf157f | ||
| 
							 | 
						54e515cb7a | ||
| 
							 | 
						c82fdeee96 | ||
| 
							 | 
						34e4fd6bb5 | ||
| 
							 | 
						9fb5275007 | ||
| 
							 | 
						f7f06cfa3a | ||
| 
							 | 
						1779f573ec | ||
| 
							 | 
						fba73636de | ||
| 
							 | 
						3814022411 | ||
| 
							 | 
						53b998f1e5 | ||
| 86d2c0e9f6 | 
					 14 changed files with 215 additions and 20 deletions
				
			
		
							
								
								
									
										24
									
								
								app/Http/Controllers/ChismosaController.php
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										24
									
								
								app/Http/Controllers/ChismosaController.php
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,24 @@
 | 
			
		|||
<?php
 | 
			
		||||
 | 
			
		||||
namespace App\Http\Controllers;
 | 
			
		||||
 | 
			
		||||
use Illuminate\Http\Request;
 | 
			
		||||
 | 
			
		||||
class ChismosaController extends Controller
 | 
			
		||||
{
 | 
			
		||||
    /**
 | 
			
		||||
     * Create a new controller instance.
 | 
			
		||||
     *
 | 
			
		||||
     * @return void
 | 
			
		||||
     */
 | 
			
		||||
    public function __construct()
 | 
			
		||||
    {
 | 
			
		||||
        $this->middleware(['auth','subpedido']);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    public function show()
 | 
			
		||||
    {
 | 
			
		||||
        return view('chismosa');
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -17,11 +17,11 @@ class SubpedidoResource extends JsonResource
 | 
			
		|||
        return [
 | 
			
		||||
            'id' => $this->id,
 | 
			
		||||
            'nombre' => $this->nombre,
 | 
			
		||||
            'subtotal_productos' => number_format($this->getSubtotalProductos(),2),
 | 
			
		||||
            'subtotal_bonos' => number_format($this->getSubtotalBonos(),2),
 | 
			
		||||
            'subtotal_productos' => number_format($this->getSubtotalProductos(),0),
 | 
			
		||||
            'subtotal_bonos' => number_format($this->getSubtotalBonos(),0),
 | 
			
		||||
            'bonos_de_transporte' => $this->cantidadBDT(),
 | 
			
		||||
            'subtotal_bonos_de_transporte' => number_format($this->getSubtotalBDT(),2),
 | 
			
		||||
            'total' => number_format($this->getTotal(),2),
 | 
			
		||||
            'subtotal_bonos_de_transporte' => number_format($this->getSubtotalBDT(),0),
 | 
			
		||||
            'total' => number_format($this->getTotal(),0),
 | 
			
		||||
            'grupo_de_compra' => $this->grupoDeCompra,
 | 
			
		||||
            'productos' => $this->productos
 | 
			
		||||
        ];
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										
											BIN
										
									
								
								public/assets/favicon.png
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								public/assets/favicon.png
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| 
		 After Width: | Height: | Size: 3.1 KiB  | 
							
								
								
									
										7
									
								
								public/css/animate.min.css
									
										
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								public/css/animate.min.css
									
										
									
									
										vendored
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
							
								
								
									
										25
									
								
								public/css/app.css
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										25
									
								
								public/css/app.css
									
										
									
									
										vendored
									
									
								
							| 
						 | 
				
			
			@ -6,3 +6,28 @@ p.navbar-item:empty {
 | 
			
		|||
	color: #cc0f35;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
.help {
 | 
			
		||||
	font-size: 1rem;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
table.table td {
 | 
			
		||||
	vertical-align: middle;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
nav.breadcrumb.is-fixed-top {
 | 
			
		||||
	left: 0;
 | 
			
		||||
	position: fixed;
 | 
			
		||||
	right: 0;
 | 
			
		||||
	z-index: 30;
 | 
			
		||||
	top: 3.25rem;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
main.has-top-padding {
 | 
			
		||||
	padding-top: 3rem !important;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.has-text-centered {
 | 
			
		||||
    text-align: center;
 | 
			
		||||
    margin: 0 1em;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										14
									
								
								public/js/app.js
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										14
									
								
								public/js/app.js
									
										
									
									
										vendored
									
									
								
							| 
						 | 
				
			
			@ -2,13 +2,13 @@ window.Event = new Vue();
 | 
			
		|||
 | 
			
		||||
Vue.component('nav-bar', {
 | 
			
		||||
	template: `
 | 
			
		||||
		<nav class="navbar is-danger" role="navigation" aria-label="main navigation">
 | 
			
		||||
		<nav class="navbar is-danger is-fixed-top" role="navigation" aria-label="main navigation">
 | 
			
		||||
          <div class="navbar-brand">
 | 
			
		||||
            <a class="navbar-item" href="https://mps.org.uy">
 | 
			
		||||
              <img src="/assets/logoMPS.png" height="28">
 | 
			
		||||
            </a>
 | 
			
		||||
            <p style="margin:0 auto" class="navbar-item"><slot name="subpedido"></slot></p>
 | 
			
		||||
            <a class="navbar-item" href="#">
 | 
			
		||||
            <a class="navbar-item" href="/chismosa">
 | 
			
		||||
              <img style="padding:0 0.3em;" src="/assets/chismosa.png" height="28">
 | 
			
		||||
              <p style="margin:0 auto; color:white">$ <span v-text="subpedido == null ? 0 : subpedido.total"></span></p>
 | 
			
		||||
            </a>
 | 
			
		||||
| 
						 | 
				
			
			@ -35,7 +35,7 @@ Vue.component('nav-bar', {
 | 
			
		|||
	data() {
 | 
			
		||||
		return {
 | 
			
		||||
			isActive: false,
 | 
			
		||||
      subpedido: null
 | 
			
		||||
            subpedido: null
 | 
			
		||||
		}
 | 
			
		||||
	},
 | 
			
		||||
	methods: {
 | 
			
		||||
| 
						 | 
				
			
			@ -59,7 +59,13 @@ Vue.component('nav-bar', {
 | 
			
		|||
            cantidad: cantidad,
 | 
			
		||||
            producto_id: id
 | 
			
		||||
        }).then(() => {
 | 
			
		||||
            alert('subpedido actualizado');
 | 
			
		||||
            bulmaToast.toast({
 | 
			
		||||
              message: 'Pedido actualizado exitosamente',
 | 
			
		||||
              duration: 1000,
 | 
			
		||||
              type: 'is-danger',
 | 
			
		||||
              position: 'bottom-center',
 | 
			
		||||
              animate: { in: 'fadeIn', out: 'fadeOut' }
 | 
			
		||||
            });
 | 
			
		||||
            this.actualizarSubpedido();
 | 
			
		||||
        });
 | 
			
		||||
    });
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										6
									
								
								public/js/bulma-toast.min.js
									
										
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								public/js/bulma-toast.min.js
									
										
									
									
										vendored
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
							
								
								
									
										105
									
								
								public/js/chismosa.js
									
										
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										105
									
								
								public/js/chismosa.js
									
										
									
									
										vendored
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,105 @@
 | 
			
		|||
Vue.component('chismosa', {
 | 
			
		||||
    template: `
 | 
			
		||||
        <div class="container">
 | 
			
		||||
            <table v-show="this.subpedido.productos.length != 0" class="table is-fullwidth is-striped is-bordered">
 | 
			
		||||
                <thead>
 | 
			
		||||
                <tr>
 | 
			
		||||
                    <th>Producto</th>
 | 
			
		||||
                    <th><abbr title="Cantidad">C</abbr></th>
 | 
			
		||||
                    <th><abbr title="Precio Total">$</abbr></th>
 | 
			
		||||
                    <th></th>
 | 
			
		||||
                    <th><abbr title="Eliminar"></abbr></th>
 | 
			
		||||
                </tr>
 | 
			
		||||
                </thead>
 | 
			
		||||
                <tfoot>
 | 
			
		||||
                <tr>
 | 
			
		||||
                    <th><abbr title="Bonos de Transporte">B. Transporte</abbr></th>
 | 
			
		||||
                    <th>{{ this.subpedido.bonos_de_transporte }}</th>
 | 
			
		||||
                    <th>{{ this.subpedido.subtotal_bonos_de_transporte }}</th>
 | 
			
		||||
                    <th></th>
 | 
			
		||||
                    <th></th>
 | 
			
		||||
                </tr>
 | 
			
		||||
                <tr>
 | 
			
		||||
                    <th>Total total</th>
 | 
			
		||||
                    <th></th>
 | 
			
		||||
                    <th>{{ this.subpedido.total }}</th>
 | 
			
		||||
                    <th></th>
 | 
			
		||||
                    <th></th>
 | 
			
		||||
                </tr>
 | 
			
		||||
                </tfoot>
 | 
			
		||||
                <tbody>
 | 
			
		||||
                <producto-row v-for="producto in this.subpedido.productos" :producto="producto" :key="producto.id"></producto-row>
 | 
			
		||||
                </tbody>
 | 
			
		||||
            </table>
 | 
			
		||||
            <p class="has-text-centered" v-show="this.subpedido.productos.length == 0">Compa, todavía no agregaste nada a la chismosa.</p>
 | 
			
		||||
        </div>
 | 
			
		||||
    `,
 | 
			
		||||
    data() {
 | 
			
		||||
        return {
 | 
			
		||||
            subpedido: {
 | 
			
		||||
                productos:[]
 | 
			
		||||
            },
 | 
			
		||||
        }
 | 
			
		||||
    },
 | 
			
		||||
    computed: {
 | 
			
		||||
        /* TODO: tener el camino que se había hecho antes de abrir la chismosa para volver atrás */
 | 
			
		||||
        miga: function() {
 | 
			
		||||
            return {
 | 
			
		||||
                nombre: "Chismosa de " + this.subpedido.nombre,
 | 
			
		||||
                href: "/chismosa"
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    },
 | 
			
		||||
    beforeCreate() {
 | 
			
		||||
        axios.get("/subpedidos/obtener_sesion").then(response => {
 | 
			
		||||
            this.subpedido = response.data.subpedido;
 | 
			
		||||
            this.fetchSubpedido();
 | 
			
		||||
            Event.$emit("migas-agregar",this.miga);
 | 
			
		||||
        });
 | 
			
		||||
    },
 | 
			
		||||
    methods: {
 | 
			
		||||
        fetchSubpedido() {
 | 
			
		||||
            axios.get("/api/subpedidos/" + this.subpedido.id)
 | 
			
		||||
                .then(response => {
 | 
			
		||||
                    this.subpedido = response.data.data;
 | 
			
		||||
                });
 | 
			
		||||
        }
 | 
			
		||||
    },
 | 
			
		||||
    mounted() {
 | 
			
		||||
        Event.$on('sync-subpedido', () =>  {
 | 
			
		||||
            this.fetchSubpedido();
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
Vue.component('producto-row', {
 | 
			
		||||
    template: `
 | 
			
		||||
    <tr>
 | 
			
		||||
            <td>{{ this.producto.nombre }}</td>
 | 
			
		||||
            <td>{{ this.producto.pivot.cantidad }}</td>
 | 
			
		||||
            <td>{{ this.producto.pivot.total }}</td>
 | 
			
		||||
            <td><button @click.capture="seleccionarProducto(producto)" class="button is-warning">
 | 
			
		||||
                <span class="icon">
 | 
			
		||||
                    <i class="fas fa-edit"></i>
 | 
			
		||||
                </span>
 | 
			
		||||
            </button></td>
 | 
			
		||||
            <td><button @click.capture="eliminarProducto(producto)" class="button is-danger">
 | 
			
		||||
                <span class="icon">
 | 
			
		||||
                    <i class="fas fa-trash-alt"></i>
 | 
			
		||||
                </span>
 | 
			
		||||
            </button></td>
 | 
			
		||||
    </tr>
 | 
			
		||||
    `,
 | 
			
		||||
    props: {
 | 
			
		||||
        producto: Object
 | 
			
		||||
    },
 | 
			
		||||
    methods: {
 | 
			
		||||
        seleccionarProducto(producto) {
 | 
			
		||||
            Event.$emit("producto-seleccionado",producto);
 | 
			
		||||
        },
 | 
			
		||||
        eliminarProducto(producto) {
 | 
			
		||||
            Event.$emit("sync-subpedido", 0, this.producto.id);
 | 
			
		||||
            Event.$emit("sync-subpedido");
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
})
 | 
			
		||||
							
								
								
									
										13
									
								
								public/js/productos.js
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										13
									
								
								public/js/productos.js
									
										
									
									
										vendored
									
									
								
							| 
						 | 
				
			
			@ -119,20 +119,21 @@ Vue.component('producto-container', {
 | 
			
		|||
          </header>
 | 
			
		||||
          <section class="modal-card-body">
 | 
			
		||||
              <div class="card-image">
 | 
			
		||||
                  <figure v-show="producto.nacional" class="image icono is-32x32" style="z-index:10">
 | 
			
		||||
                      <img src="/assets/uruguay.png">
 | 
			
		||||
                  </figure>
 | 
			
		||||
                  <figure v-show="producto.economia_solidaria" class="image icono is-32x32" style="z-index:10">
 | 
			
		||||
                      <img src="/assets/solidaria.png">
 | 
			
		||||
                  </figure>
 | 
			
		||||
                  <figure class="image is-4by3">
 | 
			
		||||
                      <img
 | 
			
		||||
                          v-bind:src="producto.imagen ? producto.imagen : 'https://bulma.io/images/placeholders/1280x960.png'">
 | 
			
		||||
                  </figure>
 | 
			
		||||
                  <figure v-show="producto.nacional" class="image icono is-32x32">
 | 
			
		||||
                      <img src="/assets/uruguay.png">
 | 
			
		||||
                  </figure>
 | 
			
		||||
                  <figure v-show="producto.economia_solidaria" class="image icono is-32x32">
 | 
			
		||||
                      <img src="/assets/solidaria.png">
 | 
			
		||||
                  </figure>
 | 
			
		||||
              </div>
 | 
			
		||||
              <div class="media-content">
 | 
			
		||||
                  <p class="title is-4" v-text="producto.proveedor"></p>
 | 
			
		||||
                  <p class="subtitle is-4">$<span v-text="producto.precio"></span></p>
 | 
			
		||||
                  <p class="subtitle is-6"><span v-show="producto.apto_veganxs">Apto para veganxs. </span><span v-show="producto.apto_celiacxs">Apto para celíacxs.</span></p>
 | 
			
		||||
                  <p class="subtitle is-5"><span v-text="producto.descripcion"></span></p>
 | 
			
		||||
                  <div class="field has-addons is-centered is-thin-centered">
 | 
			
		||||
                      <p class="control">
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -5,6 +5,7 @@
 | 
			
		|||
        <meta name="viewport" content="width=device-width, initial-scale=1">
 | 
			
		||||
        <title>{{ config('app.name', 'Compras del MPS') }}</title>
 | 
			
		||||
        <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bulma@0.9.3/css/bulma.min.css">
 | 
			
		||||
        <link rel="stylesheet" href="{{ asset('css/app.css') }}">
 | 
			
		||||
    </head>
 | 
			
		||||
    <body>
 | 
			
		||||
        <section class="section">
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										15
									
								
								resources/views/chismosa.blade.php
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								resources/views/chismosa.blade.php
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,15 @@
 | 
			
		|||
@extends('layouts.app')
 | 
			
		||||
 | 
			
		||||
@section('stylesheets')
 | 
			
		||||
 | 
			
		||||
@endsection
 | 
			
		||||
 | 
			
		||||
@section('content')
 | 
			
		||||
    <chismosa></chismosa>
 | 
			
		||||
	<producto-container></producto-container>
 | 
			
		||||
@endsection
 | 
			
		||||
 | 
			
		||||
@section('scripts')
 | 
			
		||||
    <script src="{{ asset('js/chismosa.js') }}"></script>
 | 
			
		||||
	<script src="{{ asset('js/productos.js') }}"></script>
 | 
			
		||||
@endsection
 | 
			
		||||
| 
						 | 
				
			
			@ -8,17 +8,20 @@
 | 
			
		|||
    <meta name="csrf-token" content="{{ csrf_token() }}">
 | 
			
		||||
 | 
			
		||||
    <title>{{ session("subpedido_nombre") ? "Pedido de " . session("subpedido_nombre") . " - " . config('app.name', 'Compras del MPS') : config('app.name', 'Compras del MPS')}}</title>
 | 
			
		||||
    <link rel="icon" type="image/x-icon" href="/assets/favicon.png">
 | 
			
		||||
 | 
			
		||||
    <!-- Fonts -->
 | 
			
		||||
 | 
			
		||||
    <script src="https://kit.fontawesome.com/9235d1c676.js" crossorigin="anonymous"></script>
 | 
			
		||||
    <script src="{{ asset('js/bulma-toast.min.js') }}"></script>
 | 
			
		||||
    <!-- Styles -->
 | 
			
		||||
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bulma@0.9.3/css/bulma.min.css">
 | 
			
		||||
    <link rel="stylesheet" href="{{ asset('css/app.css') }}">
 | 
			
		||||
    <link rel="stylesheet" href="{{ asset('css/animate.min.css') }}">
 | 
			
		||||
    @yield('stylesheets')
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
</head>
 | 
			
		||||
<body>
 | 
			
		||||
<body class="has-navbar-fixed-top">
 | 
			
		||||
    <div id="app">
 | 
			
		||||
        <nav-bar>
 | 
			
		||||
            <template slot="subpedido">{{ session('subpedido_nombre') ? 'Pedido de '. session('subpedido_nombre') : Auth::user()->name }}</template>
 | 
			
		||||
| 
						 | 
				
			
			@ -30,14 +33,14 @@
 | 
			
		|||
            </template>
 | 
			
		||||
        </nav-bar>
 | 
			
		||||
        <nav-migas inline-template>
 | 
			
		||||
            <nav class="breadcrumb is-centered has-background-danger-light" aria-label="breadcrumbs" v-show="visible">
 | 
			
		||||
            <nav class="breadcrumb is-centered has-background-danger-light is-fixed-top" aria-label="breadcrumbs" v-show="visible">
 | 
			
		||||
              <ul>
 | 
			
		||||
                <li v-for="(miga, i) in migas" v-bind:class="i==migas.length-1 ? 'is-active' : ''"><a :href="miga.href" v-text="miga.nombre"></a></li>
 | 
			
		||||
              </ul>
 | 
			
		||||
            </nav>
 | 
			
		||||
        </nav-migas>
 | 
			
		||||
 | 
			
		||||
        <main class="py-4">
 | 
			
		||||
        <main class="py-4 has-top-padding">
 | 
			
		||||
            @yield('content')
 | 
			
		||||
        </main>
 | 
			
		||||
    </div>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -22,7 +22,7 @@
 | 
			
		|||
				</div>
 | 
			
		||||
			</div>
 | 
			
		||||
	  		<div class="column is-one-third buttons">
 | 
			
		||||
			  	<button class="button is-danger" :disabled="botonCrearDesabilitado" @click="submit">Crear nuevo pedido</button>
 | 
			
		||||
			  	<button class="button is-danger" v-show="!botonCrearDesabilitado" @click="submit">Crear nuevo pedido</button>
 | 
			
		||||
			</div>
 | 
			
		||||
		</div>
 | 
			
		||||
		<div v-if="subpedidosExistentes.length" class="block">
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -19,13 +19,15 @@ Auth::routes(['register' => false]);
 | 
			
		|||
 | 
			
		||||
Route::get('/productos', 'ProductoController@index')->name('productos.index');
 | 
			
		||||
 | 
			
		||||
Route::get('/chismosa', 'ChismosaController@show')->name('chismosa.show');
 | 
			
		||||
 | 
			
		||||
Route::middleware('auth')->group( function() {
 | 
			
		||||
 | 
			
		||||
	Route::name('subpedidos.')->prefix("subpedidos")->group( function() {
 | 
			
		||||
		Route::get('/', function() {
 | 
			
		||||
			return view('subpedidos_create');
 | 
			
		||||
		})->name('create');
 | 
			
		||||
	
 | 
			
		||||
 | 
			
		||||
		Route::post('guardar_sesion', function() {
 | 
			
		||||
			$r = request();
 | 
			
		||||
			if (!isset($r["subpedido"])) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue