diff --git a/app/Http/Controllers/Auth/RegisterController.php b/app/Http/Controllers/Auth/RegisterController.php index 3ff5644..5b8c4ce 100644 --- a/app/Http/Controllers/Auth/RegisterController.php +++ b/app/Http/Controllers/Auth/RegisterController.php @@ -52,6 +52,7 @@ protected function validator(array $data) return Validator::make($data, [ 'username' => ['required', 'string', 'max:50', 'unique:users'], 'name' => ['required', 'string', 'max:255'], + 'dni' => ['required', 'string', 'min:9', 'max:9', 'unique:users'], //'email' => ['required', 'string', 'email', 'max:255', 'unique:users'], 'magatzem' => ['required', 'integer', 'max:255'], //'password' => ['required', 'string', 'min:3', 'confirmed'], @@ -69,6 +70,7 @@ protected function create(array $data) return User::create([ 'username' => $data['username'], 'name' => $data['name'], + 'dni' => $data['dni'], //'email' => $data['email'], 'magatzem' => $data['magatzem'], //'password' => Hash::make($data['password']), diff --git a/app/Http/Controllers/ReportsController.php b/app/Http/Controllers/ReportsController.php index 3a172bb..dc3e1a5 100644 --- a/app/Http/Controllers/ReportsController.php +++ b/app/Http/Controllers/ReportsController.php @@ -71,7 +71,18 @@ public function completeQuery(Request $request){ $treballador= $request->worker; $data = $request->dia; $date = Carbon::parse($data)->format('Y-m-d'); - $query = Jornada::join('users','jornades.treballador','=','users.id')->where(['treballador' => $treballador,'dia'=>$date])->get(); + $query = Jornada::join('users','jornades.treballador','=','users.id') + ->where(['treballador' => $treballador,'dia'=>$date])->get(); + + return response()->json($query); + } + + public function shiftQuery(Request $request){ + $treballador = $request->worker; + $data = $request->dia; + $date = Carbon::parse($data)->format('Y-m-d'); + $query = Torn::join('users','torns.treballador','=','users.id') + ->where(['treballador' => $treballador,'jornada'=>$date])->get(); return response()->json($query); } diff --git a/app/Models/User.php b/app/Models/User.php index 83f9fad..3a61f2d 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -20,6 +20,7 @@ class User extends Authenticatable protected $fillable = [ 'username', 'name', + 'dni', 'email', 'password', 'magatzem', diff --git a/database/migrations/2014_10_12_000000_create_users_table.php b/database/migrations/2014_10_12_000000_create_users_table.php index 8092e6c..9bd2ffa 100644 --- a/database/migrations/2014_10_12_000000_create_users_table.php +++ b/database/migrations/2014_10_12_000000_create_users_table.php @@ -22,8 +22,8 @@ public function up() $table->string('password'); $table->boolean('magatzem');// 0 or 1 $table->boolean('administrador')->nullable(); - /* $table->string('DNI')->unique()->nullable(); - $table->string('NSS')->unique()->nullable(); */ + $table->string('DNI')->unique()->nullable(); + /* $table->string('NSS')->unique()->nullable(); */ $table->rememberToken(); $table->timestamps(); }); diff --git a/public/js/Reports.js b/public/js/Reports.js index 28754a3..ff781b6 100644 --- a/public/js/Reports.js +++ b/public/js/Reports.js @@ -100,6 +100,9 @@ $(document).ready(function() { { data: "treballador", }, + { + data: "geolocation", + }, ], } ); @@ -186,6 +189,14 @@ function modalForCompleteQuery(){ }); } +function modalShiftQuery(){ + $('#modalWorkShiftQuery').modal('show'); + + $("#closeModal3").on('click',function(){ + $('#modalWorkShiftQuery').modal('hide'); + }); +} + function completeQuery(){ translateAlertsQuery(); $.ajaxSetup({ @@ -261,19 +272,16 @@ function completeQuery(){ /* AUTOCOMPLETE 2*/ $(document).ready(function() { - src = '/employees-query';//"{{ route('admin.getEmployees') }}"; $("#worker0").autocomplete({ appendTo : ".autocompletediv", select: function (event, ui) {//trigger when you click on the autocomplete item //event.preventDefault();//you can prevent the default event - //console.log( ui.item.id);//employee id - //console.log( ui.item.value);//employee name $('#worker0').val(ui.item.value) $('#worker0id').val(ui.item.id) }, source: function(request, response) { $.ajax({ - url: src, + url: '/employees-query', dataType: "json", data: { term : request.term @@ -318,3 +326,105 @@ $(document).ready(function() { }); }); + +/* AUTOCOMPLETE 3*/ +$(document).ready(function() { + src = '/employees-query'; + $("#worker3").autocomplete({ + appendTo : "#autocomplete3", + select: function (event, ui) {//trigger when you click on the autocomplete item + //event.preventDefault();//you can prevent the default event + $('#worker3').val(ui.item.value) + $('#worker3id').val(ui.item.id) + }, + source: function(request, response) { + $.ajax({ + url: src, + dataType: "json", + data: { + term : request.term + }, + success: function(data) { + response(data); + + } + }); + }, + minLength: 1, + + }); +}); + + +function workShiftQuery(){ + translateAlertsQuery(); + $.ajaxSetup({ + headers: + { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') } + }); + var treballador = document.getElementById('worker3id').value; + var data = document.getElementById('reportDate3').value; + $.ajax( + { + type: "POST", + url: "/consulta-turno", + data: { + worker : treballador, + dia : data, + }, + success: function( response ) { + //console.log('1 '+response[0]); + if (response === undefined){ + + } else { + console.log(response); + console.log('___________'); + console.log(response[3].iniciTorn); + console.log(response[3].geolocation); + + + for(var i=0;i'+response[i].name+''+ + ''+response[i].jornada+''+ + ''+response[i].iniciTorn+''+ + ''+response[i].fiTorn+''+ + ''+response[i].total+''+ + ''+response[i].geolocation+'' + + ); + } + + /* JSON.stringify(response[0].jornada)+ + ''+ + ''+ + ''+ + '') */ + + + + + + }}, + error: function(xhr, textStatus, error){ + /* $("#alert-danger-message-final").text(msgNoResults); + $("#alert-warning") + .fadeTo(4000, 1000) + .slideUp(1000, function () { + $("#alert-warning").slideUp(1000); + }); */ + } + }); + + +} \ No newline at end of file diff --git a/resources/lang/ca/auth.php b/resources/lang/ca/auth.php index 61f0634..e96e072 100644 --- a/resources/lang/ca/auth.php +++ b/resources/lang/ca/auth.php @@ -17,4 +17,5 @@ 'password' => 'The provided password is incorrect.', 'throttle' => 'Ha superat el nombre màxim d\'intents d\'accés. Si us plau, torni a intentar-ho en :seconds segons.', 'username' => "Codi d'usuari incorrecte.", + 'dni' => "DNI ja existent als nostres registres.", ]; diff --git a/resources/lang/ca/messages.php b/resources/lang/ca/messages.php index 2150c4f..633aa83 100644 --- a/resources/lang/ca/messages.php +++ b/resources/lang/ca/messages.php @@ -50,6 +50,8 @@ 'Exact query' => "Consulta exacta entre dates", 'Reload table' => "Actualitzar taula", 'Complete query'=> "Consulta completa", + 'Shift query'=> "Consulta de torns", + 'Geolocation'=> "Geolocalització", /* alerts */ diff --git a/resources/lang/en/auth.php b/resources/lang/en/auth.php index 57cadb4..2804574 100644 --- a/resources/lang/en/auth.php +++ b/resources/lang/en/auth.php @@ -17,5 +17,5 @@ 'password' => 'The provided password is incorrect.', 'throttle' => 'Too many login attempts. Please try again in :seconds seconds.', 'username' => "Codi d'usuari incorrecte.", - + 'dni' => "This DNI is already registered.", ]; diff --git a/resources/lang/en/messages.php b/resources/lang/en/messages.php index c135fb2..34d2f2d 100644 --- a/resources/lang/en/messages.php +++ b/resources/lang/en/messages.php @@ -45,6 +45,8 @@ 'Exact query'=> "Exact query", 'Reload table' => "Reload table", 'Complete query'=> "Complete query", + 'Shift query'=> "Shift query", + 'Geolocation'=> "Geolocation", 'Preparació comanda' => 'Order preparation', 'Revisió comanda' => 'Order review', diff --git a/resources/lang/es/auth.php b/resources/lang/es/auth.php index 4960aaa..f234e77 100644 --- a/resources/lang/es/auth.php +++ b/resources/lang/es/auth.php @@ -17,4 +17,5 @@ 'password' => 'La contraseña ingresada no es correcta.', 'throttle' => 'Demasiados intentos de acceso. Por favor intente nuevamente en :seconds segundos.', 'username' => "Codigo de usuario incorrecto.", + 'dni' => "DNI ya existente en nuestros registros.", ]; diff --git a/resources/lang/es/messages.php b/resources/lang/es/messages.php index 56d5891..e84e38e 100644 --- a/resources/lang/es/messages.php +++ b/resources/lang/es/messages.php @@ -46,6 +46,8 @@ 'Exact query' => "Consulta exacta entre fechas", 'Reload table' => "Actualizar tabla", 'Complete query'=> "Consulta completa", + 'Shift query'=> "Consulta de turnos", + 'Geolocation'=> "Geolocalización", 'Preparació comanda' => 'Preparación pedido', 'Revisió comanda' => 'Revisión pedido', diff --git a/resources/views/admin/reports.blade.php b/resources/views/admin/reports.blade.php index e2bf01c..a1083f5 100644 --- a/resources/views/admin/reports.blade.php +++ b/resources/views/admin/reports.blade.php @@ -29,7 +29,8 @@
Total:
- + + {{-- --}}
{{-- MODAL 1 --}} @@ -103,14 +104,40 @@ -

+

+ {{-- MODAL 3 --}} + {{--
NombreJornadaInicio turnoFin turnoTotalGeolocalización
+ --}} - - -

{{ __('messages.Working days') }}

{{-- DATATABLE --}} @@ -121,7 +148,8 @@ {{ __('messages.Worker') }} {{ __('messages.Day') }} Total (min) - ID + ID {{ __('messages.Worker') }} + Geolocalización @@ -142,7 +170,8 @@ {{ __('messages.Worker') }} {{ __('messages.Day') }} Total (min) - ID + ID {{ __('messages.Worker') }} + {{ __('messages.Geolocation') }} @@ -163,38 +192,4 @@ } }); --}} - - - - - - - - - - - @endsection diff --git a/resources/views/auth/register.blade.php b/resources/views/auth/register.blade.php index 8431a0b..0bde5e6 100644 --- a/resources/views/auth/register.blade.php +++ b/resources/views/auth/register.blade.php @@ -39,6 +39,18 @@ +
+ + +
+ + @error('dni') + + {{ $message }} + + @enderror +
+
{{--
diff --git a/routes/web.php b/routes/web.php index d8ad94c..7d218eb 100644 --- a/routes/web.php +++ b/routes/web.php @@ -70,6 +70,8 @@ Route::post('/consulta',[ReportsController::class, 'twoDateQuery'])->name('admin.query'); Route::post('/consulta-completa',[ReportsController::class, 'completeQuery'])->name('admin.complete.query'); Route::get('/employees-query',[ReportsController::class, 'getEmployees'])->name('admin.getEmployees'); +Route::post('/consulta-turno',[ReportsController::class, 'shiftQuery'])->name('admin.shiftQuery'); + Route::get('/set_language/{lang}', [App\Http\Controllers\Controller::class, 'set_language'])->name('set_language'); App::setLocale("es");