Skip to content

Commit

Permalink
Agregando vista de nominas
Browse files Browse the repository at this point in the history
  • Loading branch information
mtcnxd committed Apr 12, 2024
1 parent 82262bc commit 749ef6b
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 26 deletions.
7 changes: 7 additions & 0 deletions app/Http/Controllers/ControllerAjax.php
Original file line number Diff line number Diff line change
Expand Up @@ -225,4 +225,11 @@ public function getImageAttached(Request $request)
->first();
}

public function loadEmployee(Request $request)
{
return json_encode(
DB::table('employees')->where('id', $request->employee)->first()
);
}

}
1 change: 1 addition & 0 deletions database/migrations/2024_03_27_185756_create_employees.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public function up(): void
$table->id();
$table->string('name');
$table->double('salary');
$table->double('extra');
$table->string('periodicity');
$table->string('status')->default('Pendiente');
$table->timestamps();
Expand Down
94 changes: 68 additions & 26 deletions resources/views/dashboard/payroll.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<label class="window-body-form">Registrar Nomina</label>
<form action="{{ route('expenses.store') }}" method="POST" class="border pt-5 pb-4">
@csrf
<div class="col-md-6">
<div class="col-md-6">
<div class="row">
<div class="col-md-3 pt-2 text-end">
Empleado
Expand All @@ -26,25 +26,16 @@
</div>
</div>

<div class="row mt-3">
<div class="col-md-3 pt-2 text-end">
Concepto
</div>
<div class="col-md-4">
<div class="input-group">
<input type="text" class="form-control" name="name" value="Nomina #{{ date('Ymd') }}">
</div>
</div>
</div>

<div class="row mt-3">
<div class="col-md-3 pt-2 text-end">
Sueldo
</div>
<div class="col-md-4">
</div>
<div class="col-md-5">
<div class="input-group">
<span class="input-group-text">$</span>
<input type="number" class="form-control" name="name" required>
<input type="text" class="form-control" name="name" id="salary" style="text-align: right" disabled>
</div>
</div>
</div>
Expand All @@ -53,34 +44,55 @@
<div class="col-md-3 pt-2 text-end">
Horas extra
</div>
<div class="col-md-4">
<div class="col-md-2">
<input type="number" class="form-control" name="amount_hours" id="amount_hours" value="0">
</div>
<div class="col-md-2">
</div>
<div class="col-md-5">
<div class="input-group">
<span class="input-group-text">$</span>
<input type="number" class="form-control" name="name" required>
<input type="text" class="form-control" name="price_hour" id="price_hour" value="0" style="text-align: right" disabled>
</div>
</div>
</div>
</div>

<div class="row mt-3">
<div class="col-md-3 pt-2 text-end">
Bonos
</div>
<div class="col-md-4">
<div class="col-md-9">
<textarea name="" class="form-control" id="" cols="30" rows="2"></textarea>
</div>
</div>

<div class="row mt-3">
<div class="col-md-7">
</div>
<div class="col-md-5">
<div class="input-group">
<span class="input-group-text">$</span>
<input type="number" class="form-control" name="name" required>
<input type="text" class="form-control" name="bonos" id="bonos" value="0" style="text-align: right">
</div>
</div>
</div>
</div>

<div class="row mt-3">
<div class="col-md-3 pt-2 text-end">
Descuentos
</div>
<div class="col-md-4">
<div class="col-md-9">
<textarea name="" class="form-control" id="" cols="30" rows="2"></textarea>
</div>
</div>

<div class="row mt-3">
<div class="col-md-7">
</div>
<div class="col-md-5">
<div class="input-group">
<span class="input-group-text">$</span>
<input type="number" class="form-control" name="name" required>
<input type="text" class="form-control" name="discount" id="discount" value="0" style="text-align: right">
</div>
</div>
</div>
Expand All @@ -89,10 +101,10 @@
<div class="col-md-3 pt-2 text-end">
Total
</div>
<div class="col-md-4">
<div class="col-md-9">
<div class="input-group">
<span class="input-group-text">$</span>
<input type="number" class="form-control" name="name" required>
<input type="text" class="form-control" name="name" id="total" value="0" style="text-align: right" disabled>
</div>
</div>
</div>
Expand All @@ -101,17 +113,21 @@
<div class="col-md-3 pt-2 text-end">
Estatus
</div>
<div class="col-md-3">
<div class="col-md-4">
<select class="form-select" name="status" required>
<option>Pendiente</option>
<option>Pagado</option>
</select>
</div>
</div>
</div>

<div class="col-md-6 mt-3 text-end">
<a href="{{ route('expenses.index') }}" class="btn btn-secondary">Cancelar</a>
<a href="#" onclick="calculate()" class="btn btn-success">
<x-feathericon-refresh-cw class="table-icon" style="margin: -2px 5px 2px"/>
Calcular
</a>
<button type="submit" class="btn btn-success">
<x-feathericon-save class="table-icon" style="margin: -2px 5px 2px"/>
Guardar
Expand All @@ -123,9 +139,35 @@
@endsection

@section('js')
<script src="https://cdnjs.cloudflare.com/ajax/libs/numeral.js/2.0.6/numeral.min.js"></script>
<script>
function calculate(){
var amount_hours = parseFloat( $("#amount_hours").val() );
var salary = parseFloat( $("#salary").val() );
var bonos = parseFloat( $("#bonos").val() );
var discount = parseFloat( $("#discount").val() );
$("#price_hour").val( (amount_hours * 50) );
total = salary + (amount_hours * 50) + bonos - discount;
$("#total").val( numeral(parseFloat(total)).format('0,0.00') );
}
$("#employee").on('change', function(){
console.log($(this).val());
var employee = $(this).val();
$.ajax({
url: "{{ route('loadEmployee') }}",
method: 'POST',
data: {
employee: employee
},
success: function(response){
const json = JSON.parse(response);
$("#salary").val(json.salary);
json.salary }
})
});
</script>
@endsection
4 changes: 4 additions & 0 deletions routes/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@
ControllerAjax::class, 'loadEvent'
])->name('loadEvent');

Route::post('loadEmployee', [
ControllerAjax::class, 'loadEmployee'
])->name('loadEmployee');

Route::get('getDataTableServices', [
ControllerAjax::class, 'getDataTableServices'
])->name('getDataTableServices');
Expand Down

0 comments on commit 749ef6b

Please sign in to comment.