Compare commits
	
		
			4 commits
		
	
	
		
			bcb1e1b2c8
			...
			f2dee0359f
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| f2dee0359f | |||
| 
							 | 
						5b18461bd9 | ||
| 
							 | 
						b0f25de000 | ||
| 
							 | 
						dd1b66bd06 | 
					 32 changed files with 26000 additions and 84 deletions
				
			
		
							
								
								
									
										9
									
								
								.directory
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								.directory
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,9 @@
 | 
			
		|||
[Dolphin]
 | 
			
		||||
HeaderColumnWidths=372,72,103
 | 
			
		||||
SortRole=modificationtime
 | 
			
		||||
Timestamp=2022,6,1,16,36,48
 | 
			
		||||
Version=4
 | 
			
		||||
ViewMode=1
 | 
			
		||||
 | 
			
		||||
[Settings]
 | 
			
		||||
HiddenFilesShown=true
 | 
			
		||||
| 
						 | 
				
			
			@ -1,6 +1,6 @@
 | 
			
		|||
# Pedi2
 | 
			
		||||
 | 
			
		||||
Aplicación de compras del Mercado Popular de Subsistencia.
 | 
			
		||||
Aplicación de pedidos del Mercado Popular de Subsistencia.
 | 
			
		||||
 | 
			
		||||
Pedi2 está hecha en Laravel 7 y utiliza laravel7-docker de dyarleniber.
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -120,4 +120,4 @@ DB_PASSWORD=password
 | 
			
		|||
- https://docs.docker.com/
 | 
			
		||||
- https://docs.docker.com/compose/
 | 
			
		||||
- https://github.com/dyarleniber/laravel7-docker
 | 
			
		||||
- https://laravel.com/docs/7.x/installation
 | 
			
		||||
- https://laravel.com/docs/7.x/installation
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -6,5 +6,12 @@ use Illuminate\Http\Request;
 | 
			
		|||
 | 
			
		||||
class AdminController extends Controller
 | 
			
		||||
{
 | 
			
		||||
    //
 | 
			
		||||
    public function show()
 | 
			
		||||
    {
 | 
			
		||||
        return view('auth/admin_login');
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function index() {
 | 
			
		||||
        return view('auth/admin_subpedidos');
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -27,6 +27,11 @@ class SubpedidoController extends Controller
 | 
			
		|||
        return Subpedido::filtrar($filtros)->get();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function indexResources(FiltroDeSubpedido $filtros, Request $request)
 | 
			
		||||
    {
 | 
			
		||||
        return SubpedidoResource::collection(Subpedido::filtrar($filtros)->get());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Store a newly created resource in storage.
 | 
			
		||||
     *
 | 
			
		||||
| 
						 | 
				
			
			@ -83,4 +88,12 @@ class SubpedidoController extends Controller
 | 
			
		|||
        return new SubpedidoResource($subpedido);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function toggleAprobacion(Subpedido $subpedido) {
 | 
			
		||||
        $valid = request()->validate([
 | 
			
		||||
            'aprobacion' => 'required | boolean'
 | 
			
		||||
        ]);
 | 
			
		||||
        $subpedido->toggleAprobacion($valid['aprobacion']);
 | 
			
		||||
        return new SubpedidoResource($subpedido);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -5,6 +5,7 @@ namespace App\Http\Controllers\Auth;
 | 
			
		|||
use App\Http\Controllers\Controller;
 | 
			
		||||
use App\Providers\RouteServiceProvider;
 | 
			
		||||
use Illuminate\Foundation\Auth\AuthenticatesUsers;
 | 
			
		||||
use Illuminate\Http\Request;
 | 
			
		||||
use Illuminate\Support\Facades\Auth;
 | 
			
		||||
 | 
			
		||||
class LoginController extends Controller
 | 
			
		||||
| 
						 | 
				
			
			@ -28,6 +29,16 @@ class LoginController extends Controller
 | 
			
		|||
     */
 | 
			
		||||
    protected $redirectTo = RouteServiceProvider::HOME;
 | 
			
		||||
 | 
			
		||||
    protected function authenticated(Request $request, $user)
 | 
			
		||||
    {
 | 
			
		||||
        if ($user->is_admin) {
 | 
			
		||||
            session(['admin_gdc' => $user->grupo_de_compra_id]);
 | 
			
		||||
            return redirect('admin/pedidos');
 | 
			
		||||
        } else {
 | 
			
		||||
            return redirect('/');
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Create a new controller instance.
 | 
			
		||||
     *
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,24 +0,0 @@
 | 
			
		|||
<?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');
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -23,7 +23,8 @@ class SubpedidoResource extends JsonResource
 | 
			
		|||
            'subtotal_bonos_de_transporte' => number_format($this->getSubtotalBDT(),0),
 | 
			
		||||
            'total' => number_format($this->getTotal(),0),
 | 
			
		||||
            'grupo_de_compra' => $this->grupoDeCompra,
 | 
			
		||||
            'productos' => $this->productos
 | 
			
		||||
            'productos' => $this->productos,
 | 
			
		||||
            'aprobado' => (bool) $this->aprobado
 | 
			
		||||
        ];
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -29,7 +29,6 @@ class Subpedido extends Model
 | 
			
		|||
    return $this->productos()->where('bono',false);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  public function grupoDeCompra()
 | 
			
		||||
  {
 | 
			
		||||
    return $this->belongsTo('App\GrupoDeCompra');
 | 
			
		||||
| 
						 | 
				
			
			@ -65,7 +64,6 @@ class Subpedido extends Model
 | 
			
		|||
    return $this->bonos()->sum('total');
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  public function getTotal()
 | 
			
		||||
  {
 | 
			
		||||
    return $this->getSubtotalProductos() + $this->getSubtotalBDT() + $this->getSubtotalBonos();
 | 
			
		||||
| 
						 | 
				
			
			@ -87,4 +85,9 @@ class Subpedido extends Model
 | 
			
		|||
        }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  public function toggleAprobacion(bool $aprobacion) {
 | 
			
		||||
      $this->aprobado = $aprobacion;
 | 
			
		||||
      $this->save();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -19,6 +19,8 @@ class CreateUsersTable extends Migration
 | 
			
		|||
            $table->string('email')->unique()->nullable();
 | 
			
		||||
            $table->timestamp('email_verified_at')->nullable();
 | 
			
		||||
            $table->foreignId('grupo_de_compra_id')->nullable();
 | 
			
		||||
            $table->boolean('is_admin');
 | 
			
		||||
            $table->unique(['name', 'is_admin']);
 | 
			
		||||
            $table->string('password');
 | 
			
		||||
            $table->rememberToken();
 | 
			
		||||
            $table->timestamps();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -17,7 +17,7 @@ class CreateSubpedidosTable extends Migration
 | 
			
		|||
            $table->id();
 | 
			
		||||
            $table->string('nombre');
 | 
			
		||||
            $table->foreignId('grupo_de_compra_id');
 | 
			
		||||
            $table->boolean('aprobado')->nullable();
 | 
			
		||||
            $table->boolean('aprobado')->default(false);
 | 
			
		||||
            $table->timestamps();
 | 
			
		||||
        });
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -32,16 +32,24 @@ class GrupoDeCompraSeeder extends Seeder
 | 
			
		|||
            $usersToInsert[] = [
 | 
			
		||||
                'name' => $registro['barrio'],
 | 
			
		||||
                'password' => Hash::make($registro['barrio']),
 | 
			
		||||
                "is_admin" => 0,
 | 
			
		||||
                'grupo_de_compra_id' => $key
 | 
			
		||||
            ];
 | 
			
		||||
 | 
			
		||||
            $usersToInsert[] = [
 | 
			
		||||
                'name' => $registro['barrio'] . "_admin",
 | 
			
		||||
                'password' => Hash::make($registro['barrio'] . "admin"),
 | 
			
		||||
                "is_admin" => 1,
 | 
			
		||||
                'grupo_de_compra_id' => $key
 | 
			
		||||
            ];
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        foreach (array_chunk($gdcToInsert,DatabaseSeeder::CHUNK_SIZE) as $chunk)  
 | 
			
		||||
        foreach (array_chunk($gdcToInsert,DatabaseSeeder::CHUNK_SIZE) as $chunk)
 | 
			
		||||
        {
 | 
			
		||||
            DB::table('grupos_de_compra')->insert($chunk); 
 | 
			
		||||
            DB::table('grupos_de_compra')->insert($chunk);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        foreach (array_chunk($usersToInsert,DatabaseSeeder::CHUNK_SIZE) as $chunk)  
 | 
			
		||||
        foreach (array_chunk($usersToInsert,DatabaseSeeder::CHUNK_SIZE) as $chunk)
 | 
			
		||||
        {
 | 
			
		||||
            DB::table('users')->insert($chunk);
 | 
			
		||||
        }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										24570
									
								
								package-lock.json
									
										
									
										generated
									
									
									
										Normal file
									
								
							
							
						
						
									
										24570
									
								
								package-lock.json
									
										
									
										generated
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load diff
											
										
									
								
							
							
								
								
									
										1039
									
								
								public/js/app.js
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										1039
									
								
								public/js/app.js
									
										
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load diff
											
										
									
								
							
							
								
								
									
										11
									
								
								public/js/app.js.LICENSE.txt
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								public/js/app.js.LICENSE.txt
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,11 @@
 | 
			
		|||
/*!
 | 
			
		||||
 * Vue.js v2.6.14
 | 
			
		||||
 * (c) 2014-2021 Evan You
 | 
			
		||||
 * Released under the MIT License.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
/*!
 | 
			
		||||
 * bulma-toast 2.4.1 
 | 
			
		||||
 * (c) 2018-present @rfoel <rafaelfr@outlook.com> 
 | 
			
		||||
 * Released under the MIT License.
 | 
			
		||||
 */
 | 
			
		||||
| 
						 | 
				
			
			@ -1,12 +1,14 @@
 | 
			
		|||
<template>
 | 
			
		||||
	<div v-show="visible" class="block">
 | 
			
		||||
		<div class="field">
 | 
			
		||||
			<label class="label">Seleccioná tu barrio o grupo de compra</label>
 | 
			
		||||
			<label class="label" :class="isAdmin ? 'has-text-white' : ''">Seleccioná tu barrio o grupo de compra</label>
 | 
			
		||||
			<div class="control">
 | 
			
		||||
				<div class="select">
 | 
			
		||||
		        	<select @change="onGDCSelected" v-model="gdc" name="name">
 | 
			
		||||
				    	<option :disabled="isDefaultDisabled==1" value=null>Seleccionar</option>
 | 
			
		||||
						<option v-for="gdc in gdcs" v-text="gdc.nombre" :name="gdc.nombre"></option>
 | 
			
		||||
						<option v-for="gdc in gdcs" v-text="gdc.nombre + (isAdmin ? '_admin' : '')"
 | 
			
		||||
                                :name="gdc.nombre + (isAdmin ? '_admin' : '')">
 | 
			
		||||
                        </option>
 | 
			
		||||
					</select>
 | 
			
		||||
				</div>
 | 
			
		||||
			</div>
 | 
			
		||||
| 
						 | 
				
			
			@ -22,7 +24,8 @@
 | 
			
		|||
				region: null,
 | 
			
		||||
				gdcs: [],
 | 
			
		||||
				isDefaultDisabled: 0,
 | 
			
		||||
				gdc: null
 | 
			
		||||
				gdc: null,
 | 
			
		||||
                isAdmin: this.admin == null ? false : this.admin
 | 
			
		||||
			}
 | 
			
		||||
		},
 | 
			
		||||
		mounted() {
 | 
			
		||||
| 
						 | 
				
			
			@ -42,6 +45,7 @@
 | 
			
		|||
				this.isDefaultDisabled = 1;
 | 
			
		||||
	  			Event.$emit("gdc-seleccionado",this.gdc);
 | 
			
		||||
	  		}
 | 
			
		||||
		}
 | 
			
		||||
		},
 | 
			
		||||
        props: {'admin': Boolean}
 | 
			
		||||
	}
 | 
			
		||||
</script>
 | 
			
		||||
</script>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										22
									
								
								resources/js/components/BotonAdminLogin.vue
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								resources/js/components/BotonAdminLogin.vue
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,22 @@
 | 
			
		|||
<template>
 | 
			
		||||
    <div class="buttons is-right">
 | 
			
		||||
        <a class="button is-danger is-light is-small" href="/admin">
 | 
			
		||||
            <span class="icon">
 | 
			
		||||
                <i class="fa fa-solid fa-user-check"></i>
 | 
			
		||||
            </span>
 | 
			
		||||
            <span>
 | 
			
		||||
                Admin
 | 
			
		||||
            </span>
 | 
			
		||||
        </a>
 | 
			
		||||
    </div>
 | 
			
		||||
</template>
 | 
			
		||||
 | 
			
		||||
<script>
 | 
			
		||||
export default {
 | 
			
		||||
    name: "BotonAdminLogin"
 | 
			
		||||
}
 | 
			
		||||
</script>
 | 
			
		||||
 | 
			
		||||
<style scoped>
 | 
			
		||||
 | 
			
		||||
</style>
 | 
			
		||||
							
								
								
									
										42
									
								
								resources/js/components/BotonAdminSubpedidoRow.vue
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										42
									
								
								resources/js/components/BotonAdminSubpedidoRow.vue
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,42 @@
 | 
			
		|||
<template>
 | 
			
		||||
    <button class="button" :class="pedido.aprobado ? 'is-danger' : 'is-success'" @click="toggleAprobacion">
 | 
			
		||||
                <span class="icon is-small">
 | 
			
		||||
                  <i class="fas" :class="pedido.aprobado ? 'fa-times' : 'fa-check'"></i>
 | 
			
		||||
                </span>
 | 
			
		||||
        <span>{{ mensaje }}</span>
 | 
			
		||||
    </button>
 | 
			
		||||
</template>
 | 
			
		||||
 | 
			
		||||
<script>
 | 
			
		||||
export default {
 | 
			
		||||
    name: "BotonAdminSubpedidoRow",
 | 
			
		||||
    props: {'subpedido': Object},
 | 
			
		||||
    data() {
 | 
			
		||||
        return {
 | 
			
		||||
            pedido: this.subpedido
 | 
			
		||||
        }
 | 
			
		||||
    },
 | 
			
		||||
    computed: {
 | 
			
		||||
        mensaje: function () {
 | 
			
		||||
            return this.pedido.aprobado ? "Desaprobar" : "Aprobar"
 | 
			
		||||
        }
 | 
			
		||||
    },
 | 
			
		||||
    methods: {
 | 
			
		||||
        toggleAprobacion() {
 | 
			
		||||
            this.aprobado = !this.aprobado;
 | 
			
		||||
            Event.$emit('aprobacion-subpedido', this.pedido.id, this.aprobado);
 | 
			
		||||
        }
 | 
			
		||||
    },
 | 
			
		||||
    mounted() {
 | 
			
		||||
        Event.$on('sync-aprobacion', (unSubpedido) => {
 | 
			
		||||
            if (this.pedido.id === unSubpedido.id) {
 | 
			
		||||
                this.pedido = unSubpedido
 | 
			
		||||
            }
 | 
			
		||||
        })
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
</script>
 | 
			
		||||
 | 
			
		||||
<style scoped>
 | 
			
		||||
 | 
			
		||||
</style>
 | 
			
		||||
| 
						 | 
				
			
			@ -9,8 +9,7 @@
 | 
			
		|||
		</div>
 | 
			
		||||
		<div class="field">
 | 
			
		||||
			<div class="control">
 | 
			
		||||
			    <input type="submit" class="button is-success" value="Ingresar">
 | 
			
		||||
			    </input>
 | 
			
		||||
			    <input type="submit" class="button is-success" value="Ingresar"/>
 | 
			
		||||
		    </div>
 | 
			
		||||
	    </div>
 | 
			
		||||
	</div>
 | 
			
		||||
| 
						 | 
				
			
			@ -37,4 +36,4 @@
 | 
			
		|||
	.help {
 | 
			
		||||
		font-size: 1rem;
 | 
			
		||||
	}
 | 
			
		||||
</style>
 | 
			
		||||
</style>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										41
									
								
								resources/js/components/LoginAdmin.vue
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										41
									
								
								resources/js/components/LoginAdmin.vue
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,41 @@
 | 
			
		|||
<template>
 | 
			
		||||
    <div v-show="visible" class="block">
 | 
			
		||||
        <div class="field">
 | 
			
		||||
            <label class="label has-text-white">Contraseña de administración del barrio</label>
 | 
			
		||||
            <p class="control">
 | 
			
		||||
                <input required class="input" type="password" name="password" placeholder="Contraseña de admin del barrio">
 | 
			
		||||
            </p>
 | 
			
		||||
            <p class="help has-text-white">Si no la sabés, consultá a la comisión informática.</p>
 | 
			
		||||
        </div>
 | 
			
		||||
        <div class="field">
 | 
			
		||||
            <div class="control">
 | 
			
		||||
                <input type="submit" class="button is-warning" value="Ingresar"/>
 | 
			
		||||
            </div>
 | 
			
		||||
        </div>
 | 
			
		||||
    </div>
 | 
			
		||||
</template>
 | 
			
		||||
 | 
			
		||||
<script>
 | 
			
		||||
    export default {
 | 
			
		||||
        name: "LoginAdmin.vue",
 | 
			
		||||
        data() {
 | 
			
		||||
            return {
 | 
			
		||||
                visible: false,
 | 
			
		||||
                gdc: null
 | 
			
		||||
            }
 | 
			
		||||
        },
 | 
			
		||||
        mounted() {
 | 
			
		||||
            Event.$on('gdc-seleccionado', (gdc) =>  {
 | 
			
		||||
                this.gdc = gdc;
 | 
			
		||||
                this.visible = true;
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
</script>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
<style>
 | 
			
		||||
    .help {
 | 
			
		||||
        font-size: 1rem;
 | 
			
		||||
    }
 | 
			
		||||
</style>
 | 
			
		||||
| 
						 | 
				
			
			@ -74,6 +74,20 @@
 | 
			
		|||
                });
 | 
			
		||||
            });
 | 
			
		||||
        });
 | 
			
		||||
        Event.$on('aprobacion-subpedido', (subpedidoId, aprb) => {
 | 
			
		||||
            axios.post("/api/admin/subpedidos/" + subpedidoId + "/aprobacion", {
 | 
			
		||||
                aprobacion: aprb
 | 
			
		||||
            }).then((response) => {
 | 
			
		||||
                Event.$emit('sync-aprobacion', response.data.data);
 | 
			
		||||
                window.bulmaToast.toast({
 | 
			
		||||
                    message: 'Pedido ' + (aprb ? 'aprobado' : 'desaprobado') + ' exitosamente',
 | 
			
		||||
                    duration: 1000,
 | 
			
		||||
                    type: 'is-danger',
 | 
			
		||||
                    position: 'bottom-center',
 | 
			
		||||
                    animate: { in: 'fadeIn', out: 'fadeOut' }
 | 
			
		||||
                })
 | 
			
		||||
            })
 | 
			
		||||
        })
 | 
			
		||||
      }
 | 
			
		||||
    };
 | 
			
		||||
</script>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -29,6 +29,6 @@
 | 
			
		|||
	            Event.$emit("sync-subpedido", 0, this.producto.id);
 | 
			
		||||
	            Event.$emit("sync-subpedido");
 | 
			
		||||
	        }
 | 
			
		||||
    }
 | 
			
		||||
        }
 | 
			
		||||
	}
 | 
			
		||||
</script>
 | 
			
		||||
</script>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,11 +1,11 @@
 | 
			
		|||
<template>
 | 
			
		||||
	<div class="block">
 | 
			
		||||
		<div class="field">
 | 
			
		||||
		    <label class="label">Seleccioná tu región</label>
 | 
			
		||||
		    <label class="label" :class="whiteText ? 'has-text-white' : ''">Seleccioná tu región</label>
 | 
			
		||||
	        <div class="control">
 | 
			
		||||
	        	<div class="select">
 | 
			
		||||
	        		<select @change="onRegionSelected" v-model="region">
 | 
			
		||||
			    		<option :disabled="isDefaultDisabled==1" value=null>Seleccionar</option>
 | 
			
		||||
			    		<option :disabled="isDefaultDisabled===1" value=null>Seleccionar</option>
 | 
			
		||||
						<option v-for="region in regiones" v-text="region" :name="region"></option>
 | 
			
		||||
					</select>
 | 
			
		||||
				</div>
 | 
			
		||||
| 
						 | 
				
			
			@ -20,7 +20,8 @@
 | 
			
		|||
			return {
 | 
			
		||||
				regiones: [],
 | 
			
		||||
				isDefaultDisabled: 0,
 | 
			
		||||
				region: null
 | 
			
		||||
				region: null,
 | 
			
		||||
                whiteText: this.admin == null ? false : this.admin
 | 
			
		||||
			}
 | 
			
		||||
		},
 | 
			
		||||
		mounted() {
 | 
			
		||||
| 
						 | 
				
			
			@ -31,6 +32,7 @@
 | 
			
		|||
	  			this.isDefaultDisabled = 1;
 | 
			
		||||
	  			Event.$emit("region-seleccionada",this.region);
 | 
			
		||||
	  		}
 | 
			
		||||
	  	}
 | 
			
		||||
	  	},
 | 
			
		||||
        props: {'admin': Boolean}
 | 
			
		||||
	}
 | 
			
		||||
</script>
 | 
			
		||||
</script>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										35
									
								
								resources/js/components/SubpedidoRow.vue
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										35
									
								
								resources/js/components/SubpedidoRow.vue
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,35 @@
 | 
			
		|||
<template>
 | 
			
		||||
    <tr>
 | 
			
		||||
        <td>{{ subpedido.nombre }}</td>
 | 
			
		||||
        <td>{{ subpedido.total }}</td>
 | 
			
		||||
        <td><boton-admin-subpedido-row :subpedido="subpedido"></boton-admin-subpedido-row></td>
 | 
			
		||||
    </tr>
 | 
			
		||||
</template>
 | 
			
		||||
 | 
			
		||||
<script>
 | 
			
		||||
import BotonAdminSubpedidoRow from "./BotonAdminSubpedidoRow";
 | 
			
		||||
export default {
 | 
			
		||||
    name: "SubpedidoRow",
 | 
			
		||||
    components: {BotonAdminSubpedidoRow},
 | 
			
		||||
    props: {
 | 
			
		||||
        subpedido: Object
 | 
			
		||||
    },
 | 
			
		||||
    data() {
 | 
			
		||||
        return {
 | 
			
		||||
            pedido: this.subpedido
 | 
			
		||||
        }
 | 
			
		||||
    },
 | 
			
		||||
    mounted() {
 | 
			
		||||
        Event.$on('sync-aprobacion', (unSubpedido) => {
 | 
			
		||||
            console.log(unSubpedido);
 | 
			
		||||
            if (this.pedido.id === unSubpedido.id) {
 | 
			
		||||
                this.pedido = unSubpedido
 | 
			
		||||
            }
 | 
			
		||||
        })
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
</script>
 | 
			
		||||
 | 
			
		||||
<style scoped>
 | 
			
		||||
 | 
			
		||||
</style>
 | 
			
		||||
| 
						 | 
				
			
			@ -5,7 +5,7 @@
 | 
			
		|||
	  		<div class="column is-two-thirds">
 | 
			
		||||
				<div class="field">
 | 
			
		||||
			        <div class="control">
 | 
			
		||||
		        		<input class="input" @input="onType" v-model="subpedido"></input>
 | 
			
		||||
		        		<input class="input" @input="onType" v-model="subpedido"/>
 | 
			
		||||
					</div>
 | 
			
		||||
					<p class="help">Debe ser claro para que tus compas del barrio te identifiquen.</p>
 | 
			
		||||
				</div>
 | 
			
		||||
| 
						 | 
				
			
			@ -14,18 +14,19 @@
 | 
			
		|||
			  	<button class="button is-danger" v-show="!botonCrearDesabilitado" @click="submit">Crear nuevo pedido</button>
 | 
			
		||||
			</div>
 | 
			
		||||
		</div>
 | 
			
		||||
		<div v-if="subpedidosExistentes.length" class="block">
 | 
			
		||||
			<label class="label">Si ya comenzaste a hacer tu pedido este mes, elegilo en esta lista:</label>
 | 
			
		||||
			<p class="help">Podés seguir escribiendo en el campo de arriba para refinar la búsqueda.</p>
 | 
			
		||||
  				<div class="columns is-mobile" v-for="(subpedidoExistente, index) in subpedidosExistentes" :class="{'has-background-grey-lighter': index % 2}">
 | 
			
		||||
  					<div class="column is-half-mobile is-two-thirds-desktop is-two-thirds-tablet"><p style="padding-top: calc(.5em - 1px); margin-bottom: .5rem" v-text="subpedidoExistente.nombre"></p></div>
 | 
			
		||||
					<div class="buttons column is-half-mobile is-one-third-desktop is-one-third-tablet">
 | 
			
		||||
						<button class="button is-danger" @click="elegirSubpedido(subpedidoExistente)">Continuar pedido</button>
 | 
			
		||||
  					</div>
 | 
			
		||||
  				</div>
 | 
			
		||||
			</div>		
 | 
			
		||||
		</div>
 | 
			
		||||
	</div>
 | 
			
		||||
        <div v-if="subpedidosExistentes.length" class="block">
 | 
			
		||||
            <label class="label">Si ya comenzaste a hacer tu pedido este mes, elegilo en esta lista:</label>
 | 
			
		||||
            <p class="help">Podés seguir escribiendo en el campo de arriba para refinar la búsqueda.</p>
 | 
			
		||||
            <div class="columns is-mobile" v-for="(subpedidoExistente, index) in subpedidosExistentes" :class="{'has-background-grey-lighter': index % 2}">
 | 
			
		||||
                <div class="column is-half-mobile is-two-thirds-desktop is-two-thirds-tablet">
 | 
			
		||||
                    <p style="padding-top: calc(.5em - 1px); margin-bottom: .5rem" v-text="subpedidoExistente.nombre"></p>
 | 
			
		||||
                </div>
 | 
			
		||||
                <div class="buttons column is-half-mobile is-one-third-desktop is-one-third-tablet">
 | 
			
		||||
                    <button class="button is-danger" @click="elegirSubpedido(subpedidoExistente)">Continuar pedido</button>
 | 
			
		||||
                </div>
 | 
			
		||||
            </div>
 | 
			
		||||
        </div>
 | 
			
		||||
    </div>
 | 
			
		||||
</template>
 | 
			
		||||
 | 
			
		||||
<script>
 | 
			
		||||
| 
						 | 
				
			
			@ -85,4 +86,4 @@
 | 
			
		|||
	      }
 | 
			
		||||
	  	}
 | 
			
		||||
	}
 | 
			
		||||
</script>
 | 
			
		||||
</script>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										57
									
								
								resources/js/components/SubpedidosGdc.vue
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										57
									
								
								resources/js/components/SubpedidosGdc.vue
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,57 @@
 | 
			
		|||
<template>
 | 
			
		||||
    <div class="container table-container chismosa-container is-max-widescreen is-max-desktop animate__animated" :class="animation" v-show="!init">
 | 
			
		||||
        <table v-show="this.subpedidos.length !== 0" class="table is-fullwidth is-striped is-bordered">
 | 
			
		||||
            <thead>
 | 
			
		||||
                <tr>
 | 
			
		||||
                    <th>Núcleo</th>
 | 
			
		||||
                    <th><abbr title="Total a Pagar">Total $</abbr></th>
 | 
			
		||||
                    <th><abbr title="Aprobacion">Aprobación</abbr></th>
 | 
			
		||||
                </tr>
 | 
			
		||||
            </thead>
 | 
			
		||||
                <tbody>
 | 
			
		||||
                    <subpedido-row v-for="subpedido in this.subpedidos"
 | 
			
		||||
                                   :subpedido="subpedido" :key="subpedido.id">
 | 
			
		||||
                    </subpedido-row>
 | 
			
		||||
                </tbody>
 | 
			
		||||
        </table>
 | 
			
		||||
        <p class="has-text-centered" v-show="this.subpedidos.length === 0">
 | 
			
		||||
            Todavía no hay ningún pedido para administrar.
 | 
			
		||||
        </p>
 | 
			
		||||
    </div>
 | 
			
		||||
</template>
 | 
			
		||||
 | 
			
		||||
<script>
 | 
			
		||||
import SubpedidoRow from "./SubpedidoRow";
 | 
			
		||||
export default {
 | 
			
		||||
    name: "SubpedidosGdc",
 | 
			
		||||
    components: {SubpedidoRow},
 | 
			
		||||
    data() {
 | 
			
		||||
        return {
 | 
			
		||||
            gdc: null,
 | 
			
		||||
            subpedidos: []
 | 
			
		||||
        }
 | 
			
		||||
    },
 | 
			
		||||
    beforeCreate() {
 | 
			
		||||
        axios.get("/admin/obtener_sesion").then(response => {
 | 
			
		||||
            this.gdc = response.data.gdc;
 | 
			
		||||
            this.fetchSubpedidos();
 | 
			
		||||
        });
 | 
			
		||||
    },
 | 
			
		||||
    methods: {
 | 
			
		||||
        fetchSubpedidos() {
 | 
			
		||||
            axios.get("/api/subpedidos/resources").then(response => {
 | 
			
		||||
                this.subpedidos = response.data.data
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
    },
 | 
			
		||||
    mounted() {
 | 
			
		||||
        Event.$on('sync-aprobacion', (_) => {
 | 
			
		||||
            this.fetchSubpedidos();
 | 
			
		||||
        })
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
</script>
 | 
			
		||||
 | 
			
		||||
<style scoped>
 | 
			
		||||
 | 
			
		||||
</style>
 | 
			
		||||
							
								
								
									
										34
									
								
								resources/views/auth/admin_login.blade.php
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										34
									
								
								resources/views/auth/admin_login.blade.php
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,34 @@
 | 
			
		|||
<!DOCTYPE html>
 | 
			
		||||
<html class="has-background-danger" lang="{{ str_replace('_', '-', app()->getLocale()) }}">
 | 
			
		||||
<head>
 | 
			
		||||
    <meta charset="utf-8">
 | 
			
		||||
    <meta name="viewport" content="width=device-width, initial-scale=1">
 | 
			
		||||
    <title>{{ config('app.name', 'Pedidos 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">
 | 
			
		||||
    <div id="root" class="container">
 | 
			
		||||
        <h1 class="title has-text-white">
 | 
			
		||||
            Administración de Pedidos MPS
 | 
			
		||||
        </h1>
 | 
			
		||||
        <p class="subtitle has-text-white">
 | 
			
		||||
            Bienvenidx a la administración de pedidos del <strong class="has-text-white">Mercado Popular de Subsistencia</strong>
 | 
			
		||||
        </p>
 | 
			
		||||
        @error('name')
 | 
			
		||||
        <div class="notification is-warning">
 | 
			
		||||
            Contraseña incorrecta, intentalo nuevamente.
 | 
			
		||||
        </div>
 | 
			
		||||
        @enderror
 | 
			
		||||
        <region-select admin="true"></region-select>
 | 
			
		||||
        <form method="post" action="login">
 | 
			
		||||
            @csrf
 | 
			
		||||
            <barrio-select admin="true"></barrio-select>
 | 
			
		||||
            <login-admin></login-admin>
 | 
			
		||||
        </form>
 | 
			
		||||
    </div>
 | 
			
		||||
</section>
 | 
			
		||||
<script src="{{ asset('js/app.js') }}" defer></script>
 | 
			
		||||
</body>
 | 
			
		||||
</html>
 | 
			
		||||
							
								
								
									
										11
									
								
								resources/views/auth/admin_subpedidos.blade.php
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								resources/views/auth/admin_subpedidos.blade.php
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,11 @@
 | 
			
		|||
@extends('layouts.app')
 | 
			
		||||
 | 
			
		||||
@section('content')
 | 
			
		||||
    <subpedidos-gdc></subpedidos-gdc>
 | 
			
		||||
@endsection
 | 
			
		||||
<script>
 | 
			
		||||
    import SubpedidosGdc from "../../js/components/SubpedidosGdc";
 | 
			
		||||
    export default {
 | 
			
		||||
        components: {SubpedidosGdc}
 | 
			
		||||
    }
 | 
			
		||||
</script>
 | 
			
		||||
| 
						 | 
				
			
			@ -3,18 +3,20 @@
 | 
			
		|||
    <head>
 | 
			
		||||
        <meta charset="utf-8">
 | 
			
		||||
        <meta name="viewport" content="width=device-width, initial-scale=1">
 | 
			
		||||
        <title>{{ config('app.name', 'Compras del MPS') }}</title>
 | 
			
		||||
        <title>{{ config('app.name', 'Pedidos 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') }}">
 | 
			
		||||
        <script src="https://kit.fontawesome.com/9235d1c676.js" crossorigin="anonymous"></script>
 | 
			
		||||
    </head>
 | 
			
		||||
    <body>
 | 
			
		||||
        <section class="section">
 | 
			
		||||
        <div id="root" class="container">
 | 
			
		||||
          <boton-admin-login></boton-admin-login>
 | 
			
		||||
          <h1 class="title">
 | 
			
		||||
            Compras MPS
 | 
			
		||||
            Pedidos MPS
 | 
			
		||||
          </h1>
 | 
			
		||||
          <p class="subtitle">
 | 
			
		||||
            Bienvenidx a la aplicación de compras del <strong>Mercado Popular de Subsistencia</strong>
 | 
			
		||||
            Bienvenidx a la aplicación de pedidos del <strong>Mercado Popular de Subsistencia</strong>
 | 
			
		||||
          </p>
 | 
			
		||||
          @error('name')
 | 
			
		||||
            <div class="notification is-danger">
 | 
			
		||||
| 
						 | 
				
			
			@ -32,3 +34,9 @@
 | 
			
		|||
      <script src="{{ asset('js/app.js') }}" defer></script>
 | 
			
		||||
    </body>
 | 
			
		||||
</html>
 | 
			
		||||
<script>
 | 
			
		||||
    import BotonAdminLogin from "../../js/components/BotonAdminLogin";
 | 
			
		||||
    export default {
 | 
			
		||||
        components: {BotonAdminLogin}
 | 
			
		||||
    }
 | 
			
		||||
</script>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -7,7 +7,7 @@
 | 
			
		|||
    <!-- CSRF Token -->
 | 
			
		||||
    <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>
 | 
			
		||||
    <title>{{ session("subpedido_nombre") ? "Pedido de " . session("subpedido_nombre") . " - " . config('app.name', 'Pedidos del MPS') : config('app.name', 'Pedidos del MPS')}}</title>
 | 
			
		||||
    <link rel="icon" type="image/x-icon" href="/assets/favicon.png">
 | 
			
		||||
 | 
			
		||||
    <!-- Fonts -->
 | 
			
		||||
| 
						 | 
				
			
			@ -45,4 +45,4 @@
 | 
			
		|||
    <script src="{{ asset('js/app.js') }}" defer></script>
 | 
			
		||||
    @yield('scripts')
 | 
			
		||||
</body>
 | 
			
		||||
</html>
 | 
			
		||||
</html>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,10 +4,10 @@
 | 
			
		|||
<section class="section">
 | 
			
		||||
<div id="root" class="container">
 | 
			
		||||
  <h1 class="title">
 | 
			
		||||
    Compras MPS
 | 
			
		||||
    Pedidos MPS
 | 
			
		||||
  </h1>
 | 
			
		||||
  <p class="subtitle">
 | 
			
		||||
    Bienvenidx a la aplicación de compras del <strong>Mercado Popular de Subsistencia</strong>
 | 
			
		||||
    Bienvenidx a la aplicación de pedidos del <strong>Mercado Popular de Subsistencia</strong>
 | 
			
		||||
  </p>
 | 
			
		||||
  <subpedido-select gdcid="{{Auth::user()->grupoDeCompra->id}}"></subpedido-select>
 | 
			
		||||
</div>
 | 
			
		||||
| 
						 | 
				
			
			@ -15,4 +15,4 @@
 | 
			
		|||
@endsection
 | 
			
		||||
 | 
			
		||||
@section('scripts')
 | 
			
		||||
@endsection
 | 
			
		||||
@endsection
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -34,11 +34,18 @@ Route::middleware('api')->group(function () {
 | 
			
		|||
 | 
			
		||||
    Route::prefix('subpedidos')->group(function () {
 | 
			
		||||
        Route::get('/','Api\SubpedidoController@index');
 | 
			
		||||
        Route::get('/resources', 'Api\SubpedidoController@indexResources');
 | 
			
		||||
        Route::get('{subpedido}','Api\SubpedidoController@show');
 | 
			
		||||
        Route::post('/','Api\SubpedidoController@store');
 | 
			
		||||
        Route::post('/{subpedido}/sync', 'Api\SubpedidoController@syncProductos');
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
    Route::prefix('admin')->group(function () {
 | 
			
		||||
        Route::prefix('subpedidos')->group(function() {
 | 
			
		||||
            Route::post('/{subpedido}/aprobacion', 'Api\SubpedidoController@toggleAprobacion');
 | 
			
		||||
        });
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
    //@TO DO -> esta ruta debe estar en middleware de auth y/o subpedido
 | 
			
		||||
    Route::get('/categorias', function() {
 | 
			
		||||
		return Producto::all()->pluck('categoria')->unique()->flatten();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -23,7 +23,20 @@ Auth::routes(['register' => false]);
 | 
			
		|||
 | 
			
		||||
Route::get('/productos', 'ProductoController@index')->name('productos.index');
 | 
			
		||||
 | 
			
		||||
Route::get('/chismosa', 'ChismosaController@show')->name('chismosa.show');
 | 
			
		||||
Route::get('/admin', 'AdminController@show')->name('admin_login.show');
 | 
			
		||||
 | 
			
		||||
Route::get('/admin/pedidos', 'AdminController@index')->name('admin_login.index');
 | 
			
		||||
 | 
			
		||||
Route::get('/admin/obtener_sesion', function() {
 | 
			
		||||
    $sesion = [
 | 
			
		||||
        'gdc' => session("admin_gdc")
 | 
			
		||||
    ];
 | 
			
		||||
    return $sesion;
 | 
			
		||||
})->name('admin_obtener_sesion');
 | 
			
		||||
 | 
			
		||||
Route::middleware(['auth', 'admin'])->group( function () {
 | 
			
		||||
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
Route::middleware('auth')->group( function() {
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue