creation and implementation of the table of selectable equipment to enter the indicated work according to its unit

This commit is contained in:
ygbanzato 2023-07-27 19:59:44 +01:00
parent fb4612fd15
commit 3d64ba9bc6
5 changed files with 143 additions and 49 deletions

View File

@ -530,13 +530,16 @@ public function showStep2($company_projects_id)
->with('listEquipmentsProjects', $listEquipmentsProjects) ->with('listEquipmentsProjects', $listEquipmentsProjects)
->with('typeEquipments', $typeEquipments) ->with('typeEquipments', $typeEquipments)
->with('checkEquipments', $checkEquipments) ->with('checkEquipments', $checkEquipments)
->with('checkUnits', $checkUnits); ->with('checkUnits', $checkUnits)
->with('receiveNumberProject',$project);
} }
return view('projectsClients/articulated_2', ['step' => 2, 'numberProject' => $numberProject]) return view('projectsClients/articulated_2', ['step' => 2, 'numberProject' => $numberProject])
->with('listEquipmentsProjects', $listEquipmentsProjects) ->with('listEquipmentsProjects', $listEquipmentsProjects)
->with('typeEquipments', $typeEquipments) ->with('typeEquipments', $typeEquipments)
->with('checkEquipments', $checkEquipments) ->with('checkEquipments', $checkEquipments)
->with('checkUnits', $checkUnits); ->with('checkUnits', $checkUnits)
->with('receiveNumberProject',$project);
} }
public function createEquipmentManual(Request $request) public function createEquipmentManual(Request $request)

View File

@ -21,6 +21,26 @@
class ProjectoDatacontroller extends Controller class ProjectoDatacontroller extends Controller
{ {
public function receiveAllInstallationEquipment($receiveNumberProject)
{
$receveProject = CompanyProject::find($receiveNumberProject);
$receveEquipments = Equipment::whereHas('unit.plant', function ($query) use ($receveProject) {
$query->where('plants.plant_id', '=', $receveProject->plant_id);
})
->with(['equipmentType', 'unit', 'equipmentAssociationAmbit.ambitsEquipment'])
->get();
return DataTables::of($receveEquipments)
->addColumn('equipment_type', function ($row) {
return $row->equipmentType->equipment_type_name;
})
->addColumn('unit', function ($row) {
return $row->unit->unit_name;
})
->toJson();
}
public function HomePage() public function HomePage()
{ {

View File

@ -21,4 +21,11 @@ public function equipments(){
public function pendingEquipments(){ public function pendingEquipments(){
return $this->hasMany(PendingEquipment::class, 'pending_equipment_unit_id', 'unit_id'); return $this->hasMany(PendingEquipment::class, 'pending_equipment_unit_id', 'unit_id');
} }
public function plant()
{
return $this->belongsTo(Plant::class, 'plant_id');
}
} }

View File

@ -28,6 +28,9 @@
</script> </script>
@endif @endif
<input type="hidden" value="{{ $receiveNumberProject->company_projects_id }}" id="receiveNumberProject">
<section class="content-header"> <section class="content-header">
<div class="container-fluid"> <div class="container-fluid">
<!-- Progressbar --> <!-- Progressbar -->
@ -1103,56 +1106,17 @@ class="fas fa-plus"></i>
</div> </div>
</div> </div>
<input type="checkbox" id="select-all"> Selecionar todos
{{-- <table class="table table-bordered table-striped"> --}}
<table id="tableSelectEquipements" class="table table-bordered table-striped"> <table id="tableSelectEquipements" class="table table-bordered table-striped">
<thead> <thead>
<tr> <tr>
<th>ID</th>
<th>Fabrica</th>
<th>Tipo de Equipamento</th>
<th>Tag</th> <th>Tag</th>
<th>Descricao Equipamento</th> <th>Descricao Equipamento</th>
<th>Numero de Serie</th> <th>Tipo de Equipamento</th>
<th>Marca</th> <th>Fabrica</th>
<th>Selecionar Equipamentos</th> <th>Selecionar Equipamentos</th>
<th>Editar</th>
</tr> </tr>
</thead> </thead>
<tbody>
{{-- @if (Session::has('listValves'))
@foreach (Session::get('listValves') as $valve) --}}
@foreach ($listEquipmentsProjects as $listEquipmentsProject)
<tr>
<td>{{ $listEquipmentsProject->equipment_id }}</td>
<td>{{ $listEquipmentsProject->unit->unit_name ?? 'Sem Fabrica Associada!!!' }}
</td>
<td>{{ $listEquipmentsProject->equipmentType->equipment_type_name ?? 'Sem tipo de Equipamento Associado!!!' }}
</td>
<td>{{ $listEquipmentsProject->equipment_tag }}</td>
<td>{{ $listEquipmentsProject->equipment_description }}</td>
<td>{{ $listEquipmentsProject->equipment_serial_number }}</td>
<td>{{ $listEquipmentsProject->equipment_brand }}</td>
{{-- <td>{{ $vallistEquipmentsProjectve->equipment_model }}</td> --}}
<td class="text-center d-flex justify-content-around">
<div class="form-check">
<input class="form-check-input" type="checkbox"
value="uniqueValue" id="uniqueId">
<label class="form-check-label" for="uniqueId">
Recebe algo
</label>
</div>
</td>
</tr>
@endforeach
</tbody>
<tfoot>
<tr>
<th>Selecionar tudo :</th>
</tr>
</tfoot>
</table> </table>
</div> </div>
{{-- ./table-responsive --}} {{-- ./table-responsive --}}
@ -1165,9 +1129,10 @@ class="fas fa-plus"></i>
<input type="hidden" name="numberProject" value="{{ $numberProject }}"> <input type="hidden" name="numberProject" value="{{ $numberProject }}">
<div class="row"> <div class="row">
<div class="col-sm-4 d-flex justify-content-center"> <div class="col-sm-4 d-flex justify-content-center">
<a href="{{ route('download',['numberProject'=>$numberProject]) }}" class="btn btn-info">Baixar Template</a> <a href="{{ route('download', ['numberProject' => $numberProject]) }}"
class="btn btn-info">Baixar Template</a>
{{-- <a id="btn-download-template" href="{{ route('download1',['numberProject'=>$numberProject]) }}" class="btn btn-info">Baixar Template</a> --}} {{-- <a id="btn-download-template" href="{{ route('download1',['numberProject'=>$numberProject]) }}" class="btn btn-info">Baixar Template</a> --}}
</div> </div>
<div class="form-group col-sm-4"> <div class="form-group col-sm-4">
<div class="input-group"> <div class="input-group">
<span class="input-group-text border rounded-left" id="" <span class="input-group-text border rounded-left" id=""
@ -2355,7 +2320,7 @@ class="form-control card_inputs"
<input type="checkbox" name=""> <input type="checkbox" name="">
</td> </td>
</tr> </tr>
<tr> <tr>
<td>TE15</td> <td>TE15</td>
<td>Empancar (ISV)</td> <td>Empancar (ISV)</td>
<td class="text-center"> <td class="text-center">
@ -2940,7 +2905,7 @@ class="form-control card_inputs"
<input type="checkbox" name=""> <input type="checkbox" name="">
</td> </td>
</tr> </tr>
<tr> <tr>
<td>TE13</td> <td>TE13</td>
<td>Teste final</td> <td>Teste final</td>
<td class="text-center"> <td class="text-center">
@ -3688,7 +3653,104 @@ function(task) {
<script> <script>
$(document).ready(function() { $(document).ready(function() {
$('#tableSelectEquipements').DataTable(); $('#tableSelectEquipements').DataTable({
autoWidth: false,
processing: true,
serverSide: true,
ajax: {
url: '/api/receiveAllInstallationEquipment/' + $('#receiveNumberProject').val()
},
columns: [{
data: 'equipment_tag',
name: 'equipment_tag'
},
{
data: 'equipment_description',
name: 'equipment_description'
},
{
data: 'equipment_type',
name: 'equipment_type'
},
{
data: 'unit',
name: 'unit'
},
{
data: 'equipment_id',
name: 'equipment_id',
render: function(data, type, row) {
return '<input type="checkbox" class="equipment-checkbox" value="' +
data + '">';
},
orderable: false,
searchable: false
},
]
});
var selectedEquipments = [];
$(document).on('click', '.equipment-checkbox', function() {
var equipmentId = $(this).val();
if ($(this).is(':checked')) {
// Adiciona o equipmentId ao array se a checkbox está marcada
selectedEquipments.push(equipmentId);
} else {
// Remove o equipmentId do array se a checkbox está desmarcada
var index = selectedEquipments.indexOf(equipmentId);
if (index > -1) {
selectedEquipments.splice(index, 1);
}
}
// console.log(selectedEquipments);
});
$(document).on('click', '#select-all', function() {
var isChecked = $(this).is(':checked');
// Seleciona ou desseleciona todas as checkboxes
$('.equipment-checkbox').prop('checked', isChecked);
// Adiciona ou remove todos os IDs de equipamento do array selectedEquipments
if (isChecked) {
$('.equipment-checkbox').each(function() {
var equipmentId = $(this).val();
if ($.inArray(equipmentId, selectedEquipments) === -1) {
selectedEquipments.push(equipmentId);
}
});
} else {
selectedEquipments = [];
}
console.log(selectedEquipments);
});
$(document).on('click', '.equipment-checkbox', function() {
var equipmentId = $(this).val();
if ($(this).is(':checked')) {
// Adiciona o equipmentId ao array se a checkbox está marcada
if ($.inArray(equipmentId, selectedEquipments) === -1) {
selectedEquipments.push(equipmentId);
}
} else {
// Remove o equipmentId do array se a checkbox está desmarcada
var index = selectedEquipments.indexOf(equipmentId);
if (index > -1) {
selectedEquipments.splice(index, 1);
}
// Desmarca a checkbox "selecionar todos"
$('#select-all').prop('checked', false);
}
console.log(selectedEquipments);
});
}); });
</script> </script>

View File

@ -38,6 +38,8 @@
Route::get('/api/receiveEquipmentsProject/{receiveNumberProject}',[ProjectoDatacontroller::class,'receiveEquipmentsProject']); Route::get('/api/receiveEquipmentsProject/{receiveNumberProject}',[ProjectoDatacontroller::class,'receiveEquipmentsProject']);
Route::get('/api/receiveWorkstationProject/{receiveNumberProject}',[ProjectoDatacontroller::class,'receiveWorkstationProject' ]); Route::get('/api/receiveWorkstationProject/{receiveNumberProject}',[ProjectoDatacontroller::class,'receiveWorkstationProject' ]);
Route::get('/api/receiveAllInstallationEquipment/{receiveNumberProject}',[ProjectoDatacontroller::class,'receiveAllInstallationEquipment']);
Route::get('api/receveTasksWorkstationPlanning/{WorkstationId}',[CreateProjectController::class,'receveTasksWorkstationPlanning']); Route::get('api/receveTasksWorkstationPlanning/{WorkstationId}',[CreateProjectController::class,'receveTasksWorkstationPlanning']);