From 19e06420f16857ffb0ba6c047b59285951c71743 Mon Sep 17 00:00:00 2001 From: Marcos Tzuc Date: Thu, 2 May 2024 16:36:18 -0600 Subject: [PATCH] Permite agregar mano de obra con conceptos individuales --- app/Http/Controllers/ControllerAjax.php | 22 +++++++++++- .../views/dashboard/expenseslist.blade.php | 2 +- .../views/dashboard/payrollslist.blade.php | 34 +++++++++++++++++-- routes/api.php | 4 +++ routes/web.php | 2 ++ 5 files changed, 59 insertions(+), 5 deletions(-) diff --git a/app/Http/Controllers/ControllerAjax.php b/app/Http/Controllers/ControllerAjax.php index 27fd3e0..d816036 100644 --- a/app/Http/Controllers/ControllerAjax.php +++ b/app/Http/Controllers/ControllerAjax.php @@ -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, @@ -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; + } + } diff --git a/resources/views/dashboard/expenseslist.blade.php b/resources/views/dashboard/expenseslist.blade.php index 027a7e3..c2d1a9e 100644 --- a/resources/views/dashboard/expenseslist.blade.php +++ b/resources/views/dashboard/expenseslist.blade.php @@ -135,7 +135,7 @@ var checkboxResult = []; checkboxGroup.each(function() { - if ($(this).prop('checked')) { + if ($(this).prop('checked')) { checkboxResult.push( $(this).attr('id') ); } }); diff --git a/resources/views/dashboard/payrollslist.blade.php b/resources/views/dashboard/payrollslist.blade.php index 60d0ab1..41f4391 100644 --- a/resources/views/dashboard/payrollslist.blade.php +++ b/resources/views/dashboard/payrollslist.blade.php @@ -95,10 +95,10 @@ - + @endforeach @@ -118,4 +118,32 @@ + @endsection \ No newline at end of file diff --git a/routes/api.php b/routes/api.php index 7e9c5bc..4bd1609 100644 --- a/routes/api.php +++ b/routes/api.php @@ -83,3 +83,7 @@ Route::post('removeItemExpense', [ ControllerAjax::class, 'removeItemExpense' ])->name('removeItemExpense'); + +Route::post('manageSalaries', [ + ControllerAjax::class, 'manageSalaries' +])->name('manageSalaries'); \ No newline at end of file diff --git a/routes/web.php b/routes/web.php index 47d6260..37cff7a 100644 --- a/routes/web.php +++ b/routes/web.php @@ -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')