Skip to content

Commit

Permalink
Permite agregar mano de obra con conceptos individuales
Browse files Browse the repository at this point in the history
  • Loading branch information
mtcnxd committed May 2, 2024
1 parent 35c5a10 commit 19e0642
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 5 deletions.
22 changes: 21 additions & 1 deletion app/Http/Controllers/ControllerAjax.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public function createItemInvoice(Request $request)
$result = DB::table('services_items')->insert([
'service_id' => $request->service,
'amount' => ($labour) ? 1 : $request->amount,
'item' => ($labour) ? 'Mano de obra' : $request->item,
'item' => $request->item,
'supplier' => $request->supplier,
'price' => $request->price,
'labour' => $labour,
Expand Down Expand Up @@ -233,4 +233,24 @@ public function loadEmployee(Request $request)
);
}

public function manageSalaries(Request $request)
{
switch ($request->action){
case 'pay':
DB::table('salaries')->where('id', $request->id)->update([
'status' => 'Pagado'
]);
$response = "El pago se registro correctamente";
break;
case 'cancell':
DB::table('salaries')->where('id', $request->id)->update([
'status' => 'Cancelado'
]);
$response = "El pago se cancelo correctamente";
break;
}

return $response;
}

}
2 changes: 1 addition & 1 deletion resources/views/dashboard/expenseslist.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@
var checkboxResult = [];
checkboxGroup.each(function() {
if ($(this).prop('checked')) {
if ($(this).prop('checked')) {
checkboxResult.push( $(this).attr('id') );
}
});
Expand Down
34 changes: 31 additions & 3 deletions resources/views/dashboard/payrollslist.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,10 @@
<x-feathericon-more-vertical style="height:20px;"/>
</button>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="#">Cancelar</a></li>
<li><a class="dropdown-item" href="#">Pagar</a></li>
<li><a class="dropdown-item" href="#" data-action="pay" data-id="{{ $salary->id }}">Pagar</a></li>
<li><a class="dropdown-item" href="#" data-action="cancell" data-id="{{ $salary->id }}">Cancelar</a></li>
</ul>
</div>
</div>
</td>
</tr>
@endforeach
Expand All @@ -118,4 +118,32 @@
<script src="https://cdn.datatables.net/1.13.7/js/jquery.dataTables.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/numeral.js/2.0.6/numeral.min.js"></script>
<script>
$(".dropdown-item").on('click', function(){
const buttonGroup = $(this);
$.ajax({
url: "{{ route('manageSalaries') }}",
method: 'POST',
data: {
id:buttonGroup.data('id'),
action:buttonGroup.data('action')
},
success: function(response){
showMessageAlert(response);
}
});
});
function showMessageAlert(message){
Swal.fire({
text: message,
icon: 'success',
confirmButtonText: 'Aceptar'
}).then( () => {
history.go();
})
}
</script>
@endsection
4 changes: 4 additions & 0 deletions routes/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,7 @@
Route::post('removeItemExpense', [
ControllerAjax::class, 'removeItemExpense'
])->name('removeItemExpense');

Route::post('manageSalaries', [
ControllerAjax::class, 'manageSalaries'
])->name('manageSalaries');
2 changes: 2 additions & 0 deletions routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,12 @@
Route::get('dashboard', function()
{
$services = DB::table('services_view')
->select(DB::raw('sum(price) as price, car'))
->join('services_items','services_view.id','services_items.service_id')
->where('services_items.labour', true)
->where('services_view.status', 'Entregado')
->whereBetween('created_at', [Carbon::now()->format('Y-m-01'), Carbon::now()])
->groupBy('services_view.car')
->get();

$expenses = DB::table('expenses')
Expand Down

0 comments on commit 19e0642

Please sign in to comment.