Skip to content

Commit

Permalink
consulta de turnos de jornada a mig camí
Browse files Browse the repository at this point in the history
  • Loading branch information
stv-beep committed Mar 18, 2022
1 parent 85cc4f7 commit 0dd5557
Show file tree
Hide file tree
Showing 14 changed files with 190 additions and 49 deletions.
2 changes: 2 additions & 0 deletions app/Http/Controllers/Auth/RegisterController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand All @@ -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']),
Expand Down
13 changes: 12 additions & 1 deletion app/Http/Controllers/ReportsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
1 change: 1 addition & 0 deletions app/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class User extends Authenticatable
protected $fillable = [
'username',
'name',
'dni',
'email',
'password',
'magatzem',
Expand Down
4 changes: 2 additions & 2 deletions database/migrations/2014_10_12_000000_create_users_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
Expand Down
118 changes: 114 additions & 4 deletions public/js/Reports.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ $(document).ready(function() {
{
data: "treballador",
},
{
data: "geolocation",
},
],

} );
Expand Down Expand Up @@ -186,6 +189,14 @@ function modalForCompleteQuery(){
});
}

function modalShiftQuery(){
$('#modalWorkShiftQuery').modal('show');

$("#closeModal3").on('click',function(){
$('#modalWorkShiftQuery').modal('hide');
});
}

function completeQuery(){
translateAlertsQuery();
$.ajaxSetup({
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.length;i++){


console.log(response[i].iniciTorn);


}

for(var i=0;i<response.length;i++){
$('#shiftTable').html(


'<tr><th>'+response[i].name+'</th></tr>'+
'<tr><th>'+response[i].jornada+'</th></tr>'+
'<tr><th>'+response[i].iniciTorn+'</th></tr>'+
'<tr><th>'+response[i].fiTorn+'</th></tr>'+
'<tr><th>'+response[i].total+'</th></tr>'+
'<tr><th>'+response[i].geolocation+'</th></tr>'

);
}

/* JSON.stringify(response[0].jornada)+
'<table class="table table-striped table-hover"><thead class="thead-dark"><tr>'+
'<th scope="col">Nombre</th><th scope="col">Jornada</th><th scope="col">Inicio turno</th>'+
'<th scope="col">Fin turno</th><th scope="col">Total</th><th scope="col">Geolocalización</th>'+
'</tr></thead>') */





}},
error: function(xhr, textStatus, error){
/* $("#alert-danger-message-final").text(msgNoResults);
$("#alert-warning")
.fadeTo(4000, 1000)
.slideUp(1000, function () {
$("#alert-warning").slideUp(1000);
}); */
}
});


}
1 change: 1 addition & 0 deletions resources/lang/ca/auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
];
2 changes: 2 additions & 0 deletions resources/lang/ca/messages.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
2 changes: 1 addition & 1 deletion resources/lang/en/auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
];
2 changes: 2 additions & 0 deletions resources/lang/en/messages.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
1 change: 1 addition & 0 deletions resources/lang/es/auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
];
2 changes: 2 additions & 0 deletions resources/lang/es/messages.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
77 changes: 36 additions & 41 deletions resources/views/admin/reports.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
<div class="btn btn-dark noClicable">Total: <span id="total"></span></div>
<button id="btn-reload" type="button" class="btn btn-dark">{{ __('messages.Reload table') }} <abbr title="Reload table"><i id="icon-reload" class="fas fa-sync-alt"></i></abbr></button>
<button type="button" class="btn btn-info" onclick="modalForQuery();">{{ __('messages.Exact query') }}</button>
<button type="button" class="btn btn-info" onclick="modalForCompleteQuery();">Consulta completa{{-- {{ __('messages.Complete query') }} --}}</button>
<button type="button" class="btn btn-info" onclick="modalForCompleteQuery();">{{ __('messages.Complete query') }}</button>
{{-- <button type="button" class="btn btn-info" onclick="modalShiftQuery();">{{ __('messages.Shift query') }}</button> --}}

<br>
{{-- MODAL 1 --}}
Expand Down Expand Up @@ -103,14 +104,40 @@
<button type="button" class="btn btn-outline-dark" onclick="completeQuery()">Consultar</button>
</div>
</form>
<div id="completeResult"{{-- class="btn btn-dark noClicable" --}}><h4><span></span></h4></div>
<div id="completeResult"><h4><span></span></h4></div>
</div></div></div>

{{-- MODAL 3 --}}
{{-- <div class="modal" id="modalWorkShiftQuery">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
{{ __('messages.Shift query') }}
<button id="closeModal3" type="button" class="close" data-dismiss="modal" aria-hidden="true">
&times;
</button>
</div>
<div class="modal-body">
<form id="reportQuery1" action="{{route('admin.complete.query')}}" method="POST">
@csrf
<div class="row mb-3">
<label class="col-md-4 col-form-label text-md-end">{{ __('messages.Worker') }}</label>
<div id="autocomplete3" class="col-md-6"><input id="worker3" class="typeahead form-control" type="text" autocomplete="on" autofocus>
<input id="worker3id" class="typeahead form-control" type="hidden" autocomplete="on">
</div></div>
<div class="row mb-3">
<label class="col-md-4 col-form-label text-md-end">{{ __('messages.Day') }}</label>
<div class="col-md-6"><input id="reportDate3" class="form-control" type="date" autofocus>
</div></div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-outline-dark" onclick="workShiftQuery()">Consultar</button>
</div>
</form>
<table id="shiftTable"></table>
</div></div></div> --}}




<hr>
<p class="h4 text-center" id="titol">{{ __('messages.Working days') }}</p>
{{-- DATATABLE --}}
Expand All @@ -121,7 +148,8 @@
<th scope="col">{{ __('messages.Worker') }}</th>
<th scope="col">{{ __('messages.Day') }}</th>
<th scope="col">Total (min)</th>
<th scope="col">ID</th>
<th scope="col">ID {{ __('messages.Worker') }}</th>
<th scope="col">Geolocalización</th>
</tr>
</thead>
<tbody>
Expand All @@ -142,7 +170,8 @@
<th scope="col">{{ __('messages.Worker') }}</th>
<th scope="col">{{ __('messages.Day') }}</th>
<th scope="col">Total (min)</th>
<th scope="col">ID</th>
<th scope="col">ID {{ __('messages.Worker') }}</th>
<th scope="col">{{ __('messages.Geolocation') }}</th>
</tr>
</tfoot>
</table>
Expand All @@ -163,38 +192,4 @@
}
});
</script> --}}

<!-- Script -->
<script type="text/javascript">
// CSRF Token
/* var CSRF_TOKEN = $('meta[name="csrf-token"]').attr('content');
$(document).ready(function(){
$( "#worker0" ).typeahead({
source: function( request, response ) {
// Fetch data
$.ajax({
url:"{{route('admin.getEmployees')}}",
type: 'get',
dataType: "json",
success: function( data ) {
response( data );
}
});
},
});
}); */
</script>








@endsection
12 changes: 12 additions & 0 deletions resources/views/auth/register.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,18 @@
</div>
</div>

<div class="row mb-3">
<label for="dni" class="col-md-4 col-form-label text-md-end">{{ __('DNI') }}</label>

<div class="col-md-6">
<input id="dni" type="dni" class="form-control @error('dni') is-invalid @enderror" name="dni" value="{{ old('dni') }}" required>
@error('dni')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
</div>

{{-- <div class="row mb-3">
<label for="email" class="col-md-4 col-form-label text-md-end">{{ __('Email Address') }}</label>
Expand Down
2 changes: 2 additions & 0 deletions routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down

0 comments on commit 0dd5557

Please sign in to comment.