updating the structure of the workstations to receive only the necessary tasks, and to associate elemental tasks and further tasks
This commit is contained in:
parent
b896b64328
commit
9d42d71a54
|
|
@ -122,7 +122,7 @@ public function addFurtherTasks(Request $request)
|
|||
$newOrderEquipmentTask->further_tasks_id = $request->selectedFurtherTaskExisting;
|
||||
}
|
||||
|
||||
$newOrderEquipmentTask->inspection = 'Nao';
|
||||
$newOrderEquipmentTask->inspection = 2;
|
||||
$newOrderEquipmentTask->save();
|
||||
|
||||
|
||||
|
|
@ -192,187 +192,78 @@ function () use ($writer) {
|
|||
|
||||
public function finishCreatingProject($numberProject)
|
||||
{
|
||||
// recebe atraves de sessao toda a vez quem entra no componente 'SelectElementalTasksInWonkstation' para selecionar as tarefas de cada Workstation
|
||||
$receiveAllFurtherTasks = session('receiveAllFurtherTasks');
|
||||
$receiveElementalTasks = session('receiveElementalTasks');
|
||||
|
||||
// Inicializar a matriz de IDs faltantes
|
||||
$missingElementalTasks = [];
|
||||
$missingFurtherTasksDetails = [];
|
||||
$missingWorkstations = [];
|
||||
|
||||
// Recebe todos os dados dos postos de Trabalho
|
||||
$receiveWorkstaions = ConstructionWorkstation::where('company_projects_id', $numberProject)->get();
|
||||
|
||||
foreach ($receiveWorkstaions as $workstation) {
|
||||
// Verifica se o ID da workstation está presente na tabela WorkstationsAssociationTasks
|
||||
$exists = WorkstationsAssociationTasks::where('id_workstations', $workstation->id_workstations)->exists();
|
||||
|
||||
// Se não existe na tabela, adiciona à lista das workstations onde nao tem tarefas atribuidas ainda.
|
||||
if (!$exists) {
|
||||
$missingWorkstations[$workstation->id_workstations] = [
|
||||
'name_workstations' => $workstation->name_workstations,
|
||||
'nomenclature_workstation' => $workstation->nomenclature_workstation
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
// Extrai apena o id_workstations de cada um
|
||||
$workstationIds = $receiveWorkstaions->pluck('id_workstations')->toArray();
|
||||
|
||||
$workstationOccurrences = WorkstationsAssociationTasks::whereIn('id_workstations', $workstationIds)
|
||||
->get()
|
||||
->countBy('id_workstations')
|
||||
->toArray();
|
||||
|
||||
// Guarda as WorkStations que não tem nenhuma tarefa associada
|
||||
$missingWorkstations = array_filter($workstationIds, function ($workstationId) use ($workstationOccurrences) {
|
||||
return !isset($workstationOccurrences[$workstationId]) || $workstationOccurrences[$workstationId] == 0;
|
||||
});
|
||||
|
||||
foreach ($missingWorkstations as $dataWs => $idWs) {
|
||||
$checkDataWsMissing = ConstructionWorkstation::where('id_workstations', $idWs)->get();
|
||||
$receiveDataWsMissing[$idWs] = $checkDataWsMissing;
|
||||
}
|
||||
|
||||
// Recebe todos os equipamentos relacionados na Obra indicada
|
||||
$receiveEquipments = Equipment::where('company_projects_id', $numberProject)->get();
|
||||
|
||||
// Recebe a quantidade de equipamentos de acordo com seu tipo de Equipamento
|
||||
$equipmentCounts = $receiveEquipments->countBy('equipment_type_id');
|
||||
|
||||
|
||||
// CV
|
||||
$countType1 = $equipmentCounts[1] ?? 0;
|
||||
// ISV
|
||||
$countType2 = $equipmentCounts[2] ?? 0;
|
||||
// PSV
|
||||
$countType3 = $equipmentCounts[3] ?? 0;
|
||||
|
||||
$valuesTypeCV = [];
|
||||
$valuesTypeISV = [];
|
||||
$valuesTypePSV = [];
|
||||
$GeneralValues = [1, 2, 8, 14, 17];
|
||||
|
||||
if ($countType1 > 0) {
|
||||
$valuesTypeCV = [18, 4, 6, 11, 19, 16];
|
||||
}
|
||||
if ($countType2 > 0) {
|
||||
$valuesTypeISV = [7, 12, 20, 15, 21];
|
||||
}
|
||||
if ($countType3 > 0) {
|
||||
$valuesTypePSV = [3, 9, 10, 13, 15];
|
||||
}
|
||||
$missingTasks = [];
|
||||
|
||||
// Recebe cada id de workstations
|
||||
foreach ($workstationIds as $id) {
|
||||
|
||||
// Verificar se há pelo menos uma entrada para cada valor em $GeneralValues
|
||||
foreach ($GeneralValues as $value) {
|
||||
$exists = WorkstationsAssociationTasks::where('id_workstations', $id)
|
||||
->where('elemental_tasks_id', $value)
|
||||
// Iterar sobre cada tarefa em $receiveElementalTasks
|
||||
foreach ($receiveElementalTasks as $taskGroup) {
|
||||
foreach ($taskGroup as $taskId => $taskDetails) {
|
||||
// Verificar se a tarefa está associada a algum id_workstations
|
||||
$exists = WorkstationsAssociationTasks::whereIn('id_workstations', $workstationIds)
|
||||
->where('elemental_tasks_id', $taskId)
|
||||
->exists();
|
||||
|
||||
// Se não existe, adicionar à lista de tarefas faltantes
|
||||
if (!$exists) {
|
||||
$missingTasks[$id][] = $value;
|
||||
}
|
||||
}
|
||||
// Verificar se há pelo menos uma entrada para cada valor em $valuesTypeCV
|
||||
if ($countType1 > 0) {
|
||||
foreach ($valuesTypeCV as $value) {
|
||||
$exists = WorkstationsAssociationTasks::where('id_workstations', $id)
|
||||
->where('elemental_tasks_id', $value)
|
||||
->exists();
|
||||
|
||||
if (!$exists) {
|
||||
$missingTasks[$id][] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Verificar se há pelo menos uma entrada para cada valor em $valuesTypeISV
|
||||
if ($countType2 > 0) {
|
||||
foreach ($valuesTypeISV as $value) {
|
||||
$exists = WorkstationsAssociationTasks::where('id_workstations', $id)
|
||||
->where('elemental_tasks_id', $value)
|
||||
->exists();
|
||||
|
||||
if (!$exists) {
|
||||
$missingTasks[$id][] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Verificar se há pelo menos uma entrada para cada valor em $valuesTypePSV
|
||||
if ($countType3 > 0) {
|
||||
foreach ($valuesTypePSV as $value) {
|
||||
$exists = WorkstationsAssociationTasks::where('id_workstations', $id)
|
||||
->where('elemental_tasks_id', $value)
|
||||
->exists();
|
||||
|
||||
if (!$exists) {
|
||||
$missingTasks[$id][] = $value;
|
||||
}
|
||||
$missingElementalTasks[$taskId] = $taskDetails;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Todas as tarefas que não estao em cada posto
|
||||
$allMissingTasks = [];
|
||||
// Iterar sobre cada tarefa em $receiveAllFurtherTasks
|
||||
foreach ($receiveAllFurtherTasks as $furtherTask) {
|
||||
// Obter o ID da tarefa
|
||||
$taskId = $furtherTask->further_tasks_id;
|
||||
|
||||
// Aqui nós contamos quantas workstations existem
|
||||
$numberOfWorkstations = count($workstationIds);
|
||||
// Verificar se a tarefa está associada a algum id_workstations
|
||||
$exists = WorkstationsAssociationTasks::whereIn('id_workstations', $workstationIds)
|
||||
->where('further_tasks_id', $taskId)
|
||||
->exists();
|
||||
|
||||
// Junta todas as tarefas ausentes em um único array
|
||||
foreach ($missingTasks as $tasks) {
|
||||
$allMissingTasks = array_merge($allMissingTasks, $tasks);
|
||||
// Se não existe, adicionar à lista de tarefas faltantes
|
||||
if (!$exists) {
|
||||
$missingFurtherTasksDetails[$taskId] = [
|
||||
'name' => $furtherTask->further_tasks_name,
|
||||
'description' => $furtherTask->further_tasks_description
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
// Conta o número de ocorrências de cada tarefa no array
|
||||
$counts = array_count_values($allMissingTasks);
|
||||
// A Partir daqui ja temos as 2 variaveis a receberem array com as tarefas que faltam ser associadas.
|
||||
$allMissingTasks = [
|
||||
'elemental' => $missingElementalTasks,
|
||||
'further' => $missingFurtherTasksDetails,
|
||||
'workstation' => $missingWorkstations
|
||||
];
|
||||
|
||||
// Mantém apenas as tarefas que aparecem no array o mesmo número de vezes que o número de workstations
|
||||
$allMissingTasks = array_filter($counts, function ($count) use ($numberOfWorkstations) {
|
||||
return $count === $numberOfWorkstations;
|
||||
});
|
||||
|
||||
// Recebe as tarefas, não existentes em nenhum do postos
|
||||
$receveDataTasksMissing = [];
|
||||
|
||||
foreach ($allMissingTasks as $IdElementalTask => $ElementalTask) {
|
||||
// dd($IdElementalTask);
|
||||
$checkDataTask = ElementalTasks::where('elemental_tasks_id', $IdElementalTask)->first();
|
||||
|
||||
$receiveDataTasksMissing[$IdElementalTask] = $checkDataTask;
|
||||
}
|
||||
|
||||
// // Se receber zero(0) quer dizer que todas as tarefas foram atribuidas pelo menos uma vez em cada posto de Trabalho.
|
||||
// if (sizeof($allMissingTasks) != 0) {
|
||||
// $missingTasksList = collect($receiveDataTasksMissing)
|
||||
// ->map(function ($task) {
|
||||
// return $task->elemental_tasks_code . ' => ' . $task->elemental_tasks_description;
|
||||
// })
|
||||
// ->implode('<br>');
|
||||
|
||||
// return redirect()->back()->with('error', 'As seguintes tarefas não foram atribuídas a nenhum posto de trabalho: <br>' . $missingTasksList);
|
||||
// } elseif (sizeof($missingWorkstations) != 0) {
|
||||
// $receveMissingWorkstations = collect($receiveDataWsMissing)
|
||||
// ->map(function ($DataWorkstation) {
|
||||
// // Aqui iteramos sobre a Collection de ConstructionWorkstation
|
||||
// return $DataWorkstation->map(function ($constructionWorkstation) {
|
||||
// return $constructionWorkstation->name_workstations ;
|
||||
// });
|
||||
// })
|
||||
// ->flatten() // Achata a coleção multi-dimensional para um único nível
|
||||
// ->implode('<br>');
|
||||
|
||||
// return redirect()->back()->with('error', 'O seguintes postos não tem nenhuma tarefa atribuida!! <br>' . $receveMissingWorkstations.);
|
||||
|
||||
$errors = [];
|
||||
|
||||
// Se receber zero(0) quer dizer que todas as tarefas foram atribuídas pelo menos uma vez em cada posto de Trabalho.
|
||||
if (sizeof($allMissingTasks) != 0) {
|
||||
$missingTasksList = collect($receiveDataTasksMissing)
|
||||
->map(function ($task) {
|
||||
return $task->elemental_tasks_code . ' => ' . $task->elemental_tasks_description;
|
||||
})
|
||||
->implode('<br>');
|
||||
|
||||
$errors[] = 'As seguintes tarefas não foram atribuídas a nenhum posto de trabalho: <br>' . $missingTasksList;
|
||||
}
|
||||
|
||||
if (sizeof($missingWorkstations) != 0) {
|
||||
$receveMissingWorkstations = collect($receiveDataWsMissing)
|
||||
->map(function ($DataWorkstation) {
|
||||
// Aqui iteramos sobre a Collection de ConstructionWorkstation
|
||||
return $DataWorkstation->map(function ($constructionWorkstation) {
|
||||
return $constructionWorkstation->name_workstations;
|
||||
});
|
||||
})
|
||||
->flatten() // Achata a coleção multi-dimensional para um único nível
|
||||
->implode('<br>');
|
||||
|
||||
$errors[] = 'O seguintes postos não tem nenhuma tarefa atribuida!! <br>' . $receveMissingWorkstations;
|
||||
} // Verificar se existem erros e retornar, se houver
|
||||
if (!empty($errors)) {
|
||||
return redirect()->back()->with('errors', $errors);
|
||||
if (!empty($allMissingTasks)) {
|
||||
return redirect()->back()->with('errors', $allMissingTasks);
|
||||
} else {
|
||||
$project = CompanyProject::find($numberProject);
|
||||
$project->order_project = 2;
|
||||
|
|
@ -427,24 +318,6 @@ public function deleteWorkstation($name)
|
|||
return back()->with('danger', 'Posto de Trabalho não encontrado!');
|
||||
}
|
||||
|
||||
public function AddNomenclatureWorkstation(Request $request)
|
||||
{
|
||||
foreach ($request->nameWorkstations as $key => $value) {
|
||||
// Procurar a Workstation pelo ID
|
||||
$workstation = ConstructionWorkstation::where('name_workstations', $key)
|
||||
->first();
|
||||
if ($workstation) {
|
||||
// Atualizar o valor do campo nomenclature_workstation
|
||||
$workstation->nomenclature_workstation = $value;
|
||||
$workstation->save();
|
||||
}
|
||||
}
|
||||
|
||||
// Redirecionar de volta com uma mensagem de sucesso
|
||||
return back()->with('success', 'Nome da estação de trabalho atualizado com sucesso!');
|
||||
}
|
||||
|
||||
|
||||
public function removeProjectEquipment(Request $request)
|
||||
{
|
||||
|
||||
|
|
@ -936,7 +809,7 @@ public function createEquipmentManual(Request $request)
|
|||
$JoinsEquipmentsWithTasks->execution_order = $execution_order++;
|
||||
$JoinsEquipmentsWithTasks->elemental_tasks_id = $TasksAssociationAmbit->elemental_tasks_id;
|
||||
$JoinsEquipmentsWithTasks->further_tasks_id = null;
|
||||
$JoinsEquipmentsWithTasks->inspection = 'Nao';
|
||||
$JoinsEquipmentsWithTasks->inspection = 2;
|
||||
$JoinsEquipmentsWithTasks->save();
|
||||
}
|
||||
|
||||
|
|
@ -1151,24 +1024,36 @@ public function workstationsAssociationTasks(Request $request)
|
|||
$workStation->save();
|
||||
}
|
||||
|
||||
// então, iteramos sobre as três listas de tarefas e as associamos à estação de trabalho
|
||||
$taskTypes = ['generalTasks', 'PsvTasks', 'CvTasks', 'IsvTasks'];
|
||||
// Atualizar a lista de tipos de tarefas para incluir os novos grupos
|
||||
$taskTypes = ['generalTasks', '1', '2', '3', 'FurtherTasks'];
|
||||
|
||||
foreach ($taskTypes as $groupTasks) {
|
||||
if (isset($request[$groupTasks])) { // Checar se esse grupo de tarefas existe no request
|
||||
foreach ($request[$groupTasks] as $taskID => $check) {
|
||||
|
||||
// Encontra a tarefa existente, se houver
|
||||
$taskAssociation = WorkstationsAssociationTasks::where('id_workstations', $workStation->id_workstations)
|
||||
->where('elemental_tasks_id', $taskID)
|
||||
->where('company_projects_id', $workStation->company_projects_id)
|
||||
->first();
|
||||
if ($groupTasks == 'FurtherTasks') {
|
||||
// Encontra a tarefa existente, se houver, para FurtherTasks
|
||||
$taskAssociation = WorkstationsAssociationTasks::where('id_workstations', $workStation->id_workstations)
|
||||
->where('further_tasks_id', $taskID)
|
||||
->where('company_projects_id', $workStation->company_projects_id)
|
||||
->first();
|
||||
} else {
|
||||
// Encontra a tarefa existente, se houver, para os outros grupos
|
||||
$taskAssociation = WorkstationsAssociationTasks::where('id_workstations', $workStation->id_workstations)
|
||||
->where('elemental_tasks_id', $taskID)
|
||||
->where('company_projects_id', $workStation->company_projects_id)
|
||||
->first();
|
||||
}
|
||||
|
||||
if ($check == 'on') {
|
||||
if (!$taskAssociation) {
|
||||
$taskAssociation = new WorkstationsAssociationTasks;
|
||||
$taskAssociation->id_workstations = $workStation->id_workstations;
|
||||
$taskAssociation->elemental_tasks_id = $taskID; // Usando $taskID, que é a key
|
||||
if ($groupTasks == 'FurtherTasks') {
|
||||
$taskAssociation->further_tasks_id = $taskID; // Usando $taskID, que é a key
|
||||
} else {
|
||||
$taskAssociation->elemental_tasks_id = $taskID; // Usando $taskID, que é a key
|
||||
}
|
||||
$taskAssociation->company_projects_id = $workStation->company_projects_id;
|
||||
}
|
||||
$taskAssociation->save();
|
||||
|
|
@ -1179,6 +1064,7 @@ public function workstationsAssociationTasks(Request $request)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
// Redirecionar de volta com uma mensagem de sucesso
|
||||
return back()->with('success', 'Posto de trabalho : ' . $workStation->name_workstations . ' atualizado com sucesso!');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ class AdditonalTask extends Component
|
|||
public $selectedFurtherTask = 'null';
|
||||
public $showAdditionalTask = false;
|
||||
|
||||
|
||||
|
||||
public function mount($equipment)
|
||||
{
|
||||
$this->equipment = $equipment;
|
||||
|
|
|
|||
113
app/Livewire/Articulado/SelectElementalTasksInWonkstation.php
Normal file
113
app/Livewire/Articulado/SelectElementalTasksInWonkstation.php
Normal file
|
|
@ -0,0 +1,113 @@
|
|||
<?php
|
||||
|
||||
namespace App\Livewire\Articulado;
|
||||
|
||||
use App\Models\ElementalTasks;
|
||||
use Livewire\Component;
|
||||
|
||||
use App\Models\Equipment;
|
||||
|
||||
use App\Models\EquipmentAssociationAmbit;
|
||||
use App\Models\TasksAssociationAmbits;
|
||||
use App\Models\FurtherTasks;
|
||||
|
||||
class SelectElementalTasksInWonkstation extends Component
|
||||
{
|
||||
public $workstation;
|
||||
|
||||
// recebe todos os equipamentos e pode filtros por tipos de equipamentos.
|
||||
public $receiveAllEquipments = [];
|
||||
|
||||
// Recebe todos os Ambitos nao repetidos, apos filtrar por todos os equipamentos.
|
||||
public $uniqueAmbitsIds = [];
|
||||
|
||||
public $receiveAllFurtherTasks = [];
|
||||
|
||||
public $receiveElementalTasks = [];
|
||||
|
||||
public $dataElementalTasks;
|
||||
|
||||
public $receiveAllAmbits = [];
|
||||
|
||||
public $elementalTasksDetails = [];
|
||||
|
||||
public $test;
|
||||
|
||||
public function mount($workstation)
|
||||
{
|
||||
$this->workstation = $workstation;
|
||||
|
||||
$this->receiveAllEquipments = Equipment::where('company_projects_id', $this->workstation->company_projects_id)
|
||||
->join('equipment_association_ambits', 'equipments.equipment_id', '=', 'equipment_association_ambits.equipment_id')
|
||||
->select('equipments.equipment_id', 'equipments.equipment_type_id', 'equipment_association_ambits.ambits_id')
|
||||
->get()
|
||||
->toArray();
|
||||
|
||||
$this->receiveAllFurtherTasks = FurtherTasks::where('company_projects_id', $this->workstation->company_projects_id)
|
||||
->get();
|
||||
|
||||
// Inicializar a matriz
|
||||
$this->receiveElementalTasks = [
|
||||
'geral' => [],
|
||||
'1' => [],
|
||||
'2' => [],
|
||||
'3' => []
|
||||
];
|
||||
|
||||
// Coletar todos os elemental_tasks_id para cada equipment_type_id
|
||||
foreach ($this->receiveAllEquipments as $equipment) {
|
||||
$elementalTasksIds = TasksAssociationAmbits::where('ambits_equipment_id', $equipment['ambits_id'])
|
||||
->pluck('elemental_tasks_id')
|
||||
->toArray();
|
||||
|
||||
// Inicializar cada ID como uma chave com um array vazio como valor
|
||||
foreach ($elementalTasksIds as $id) {
|
||||
$this->receiveElementalTasks[$equipment['equipment_type_id']][$id] = [];
|
||||
}
|
||||
}
|
||||
|
||||
// Mover elemental_tasks_id que aparecem em mais de um equipment_type_id para 'geral'
|
||||
foreach ($this->receiveElementalTasks as $key1 => $values1) {
|
||||
foreach ($this->receiveElementalTasks as $key2 => $values2) {
|
||||
if ($key1 !== $key2 && $key1 !== 'geral' && $key2 !== 'geral') {
|
||||
$commonValues = array_intersect_key($values1, $values2);
|
||||
if (!empty($commonValues)) {
|
||||
foreach ($commonValues as $value => $emptyArray) {
|
||||
$this->receiveElementalTasks['geral'][$value] = [];
|
||||
unset($this->receiveElementalTasks[$key1][$value]);
|
||||
unset($this->receiveElementalTasks[$key2][$value]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Iterar sobre $receiveElementalTasks
|
||||
foreach ($this->receiveElementalTasks as $key => $ids) {
|
||||
// Para cada ID em uma chave específica, buscar os detalhes na tabela ElementalTasks
|
||||
$details = ElementalTasks::whereIn('elemental_tasks_id', array_keys($ids))
|
||||
->select(['elemental_tasks_id', 'elemental_tasks_code', 'elemental_tasks_description'])
|
||||
->get()
|
||||
->toArray();
|
||||
|
||||
// Atualizar o array $receiveElementalTasks com os detalhes
|
||||
foreach ($details as $detail) {
|
||||
$this->receiveElementalTasks[$key][$detail['elemental_tasks_id']] = [
|
||||
'code' => $detail['elemental_tasks_code'],
|
||||
'description' => $detail['elemental_tasks_description']
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
// Armazenar os dados na sessão
|
||||
session([
|
||||
'receiveAllFurtherTasks' => $this->receiveAllFurtherTasks,
|
||||
'receiveElementalTasks' => $this->receiveElementalTasks,
|
||||
]);
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.articulado.select-elemental-tasks-in-wonkstation');
|
||||
}
|
||||
}
|
||||
|
|
@ -46,7 +46,7 @@
|
|||
<input type="text" name="email" class="form-control card_inputs"
|
||||
id="email" placeholder="Digite o email..." aria-label="Tag Equipment"
|
||||
aria-describedby="form-tagEquipment">
|
||||
<label>Email </label>
|
||||
{{-- <label>Email </label> --}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,219 @@
|
|||
<div class="modal fade" id="modal-ViewOfices-{{ $workstation->id_workstations }}">
|
||||
<div class="modal-dialog modal-xl">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header bg-primary">
|
||||
<h4 class="modal-title">{{ $workstation->name_workstations }}</h4>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
|
||||
|
||||
|
||||
<form action="{{ route('workstationsAssociationTasks') }}" method="get">
|
||||
{{-- Necessario passar essas 2 variaveis, para poder verificar quais as tarefas que foram ou nao selecionadas --}}
|
||||
<input type="hidden" name="receiveElementalTasks"
|
||||
value="{{ json_encode($receiveElementalTasks) }}">
|
||||
<input type="hidden" name="receiveAllFurtherTasks" value="{{ $receiveAllFurtherTasks }}">
|
||||
<div class="row">
|
||||
<p>Nome Posto de Trabalho : </p>
|
||||
<input class="form-control col-sm-6" type="text" name="nameWorkstation"
|
||||
value="{{ $workstation->nomenclature_workstation }}">
|
||||
<input type="hidden" name="idWorkStation" value="{{ $workstation->id_workstations }}">
|
||||
</div>
|
||||
<br>
|
||||
<section class="content">
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
@if (count($receiveElementalTasks['geral']) > 0)
|
||||
<div class="col-sm-6">
|
||||
<div class="card card-success">
|
||||
<div class="card-header">
|
||||
<h3 class="card-title">Tarefas Gerais</h3>
|
||||
<div class="card-tools">
|
||||
<button type="button" class="btn btn-tool"
|
||||
data-card-widget="collapse"><i class="fas fa-minus"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
@foreach ($receiveElementalTasks['geral'] as $taskId => $generalTasks)
|
||||
<p>{{ $generalTasks['code'] }} - {{ $generalTasks['description'] }}
|
||||
<input type="hidden" name="generalTasks[{{ $taskId }}]"
|
||||
value="off">
|
||||
<input type="checkbox" value="on"
|
||||
name="generalTasks[{{ $taskId }}]">
|
||||
</p>
|
||||
@endforeach
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<div class="col-sm-6">
|
||||
<div class="row">
|
||||
@if (count($receiveElementalTasks['3']) > 0)
|
||||
<div class="col-sm-12">
|
||||
<div class="card card-primary collapsed-card">
|
||||
<div class="card-header">
|
||||
<h3 class="card-title">
|
||||
Tarefas PSV</h3>
|
||||
<div class="card-tools">
|
||||
<button type="button" class="btn btn-tool"
|
||||
data-card-widget="collapse">
|
||||
<i class="fas fa-plus"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
@foreach ($receiveElementalTasks['3'] as $taskId => $generalTasks)
|
||||
<p>{{ $generalTasks['code'] }} -
|
||||
{{ $generalTasks['description'] }}
|
||||
<input type="hidden" name="3[{{ $taskId }}]"
|
||||
value="off">
|
||||
<input type="checkbox" value="on"
|
||||
name="3[{{ $taskId }}]">
|
||||
</p>
|
||||
@endforeach
|
||||
</div> {{-- ./card-body --}}
|
||||
</div>
|
||||
</div> {{-- ./col-sm-12 --}}
|
||||
@endif
|
||||
|
||||
@if (count($receiveElementalTasks['2']) > 0)
|
||||
<div class="col-sm-12">
|
||||
<div class="card card-primary collapsed-card">
|
||||
<div class="card-header">
|
||||
<h3 class="card-title">
|
||||
Tarefas ISV</h3>
|
||||
<div class="card-tools">
|
||||
<button type="button" class="btn btn-tool"
|
||||
data-card-widget="collapse">
|
||||
<i class="fas fa-plus"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
@foreach ($receiveElementalTasks['2'] as $taskId => $generalTasks)
|
||||
<p>{{ $generalTasks['code'] }} -
|
||||
{{ $generalTasks['description'] }}
|
||||
<input type="hidden" name="2[{{ $taskId }}]"
|
||||
value="off">
|
||||
<input type="checkbox" value="on"
|
||||
name="2[{{ $taskId }}]">
|
||||
</p>
|
||||
@endforeach
|
||||
</div> {{-- ./card-body --}}
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
@if (count($receiveElementalTasks['1']) > 0)
|
||||
<div class="col-sm-12">
|
||||
<div class="card card-primary collapsed-card">
|
||||
<div class="card-header">
|
||||
<h3 class="card-title">
|
||||
Tarefas CV</h3>
|
||||
<div class="card-tools">
|
||||
<button type="button" class="btn btn-tool"
|
||||
data-card-widget="collapse">
|
||||
<i class="fas fa-plus"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
@foreach ($receiveElementalTasks['1'] as $taskId => $generalTasks)
|
||||
<p>{{ $generalTasks['code'] }} -
|
||||
{{ $generalTasks['description'] }}
|
||||
<input type="hidden" name="1[{{ $taskId }}]"
|
||||
value="off">
|
||||
<input type="checkbox" value="on"
|
||||
name="1[{{ $taskId }}]">
|
||||
</p>
|
||||
@endforeach
|
||||
</div> {{-- ./card-body --}}
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
@if (count($receiveAllFurtherTasks) > 0)
|
||||
<div class="col-sm-12">
|
||||
<div class="card card-info collapsed-card">
|
||||
<div class="card-header">
|
||||
<h3 class="card-title">
|
||||
Tarefas Complementares</h3>
|
||||
<div class="card-tools">
|
||||
<button type="button" class="btn btn-tool"
|
||||
data-card-widget="collapse">
|
||||
<i class="fas fa-plus"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
@foreach ($receiveAllFurtherTasks as $furtherTasks)
|
||||
<p>{{ $furtherTasks->further_tasks_name }} -
|
||||
{{ $furtherTasks->further_tasks_description }}
|
||||
<input type="hidden"
|
||||
name="FurtherTasks[{{ $furtherTasks->further_tasks_id }}]"
|
||||
value="off">
|
||||
<input type="checkbox" value="on"
|
||||
name="FurtherTasks[{{ $furtherTasks->further_tasks_id }}]">
|
||||
</p>
|
||||
@endforeach
|
||||
</div> {{-- ./card-body --}}
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
{{-- @dump($receiveAllFurtherTasks) --}}
|
||||
|
||||
|
||||
</div>{{-- ./row --}}
|
||||
|
||||
</div> {{-- ./col-sm-6 --}}
|
||||
</div> {{-- ./row --}}
|
||||
|
||||
</div>
|
||||
</section>
|
||||
|
||||
</div>
|
||||
{{-- Modal-body --}}
|
||||
<div class="modal-footer justify-content-between">
|
||||
<input type="submit" class="btn btn-success" value="Guardar">
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{-- Scrip para assim que entrar na modal, ele verifica quais as tarefas ja associadas a essa Ws e mostra nas checkbox como checked --}}
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$('.open-modal').click(function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
var WorkstationId = $(this).data('workstation-id');
|
||||
|
||||
$.ajax({
|
||||
url: '/api/receveTasksWorkstationPlanning/' + WorkstationId,
|
||||
method: 'GET',
|
||||
success: function(data) {
|
||||
console.log(data.workstationsAssociationTasks);
|
||||
|
||||
data.workstationsAssociationTasks.forEach(function(item) {
|
||||
// Seleciona o checkbox com nome "3[taskId]" e marca como selecionado
|
||||
$('input[name="1[' + item.elemental_tasks_id + ']"]').prop('checked', true);
|
||||
$('input[name="2[' + item.elemental_tasks_id + ']"]').prop('checked', true);
|
||||
$('input[name="3[' + item.elemental_tasks_id + ']"]').prop('checked', true);
|
||||
$('input[name="generalTasks[' + item.elemental_tasks_id + ']"]').prop('checked', true);
|
||||
$('input[name="FurtherTasks[' + item.further_tasks_id + ']"]').prop('checked', true);
|
||||
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
|
|
@ -14,18 +14,106 @@
|
|||
</script>
|
||||
@endif
|
||||
|
||||
{{-- @if (session('error'))
|
||||
<div class="alert alert-danger" role="alert" id="alert-message-danger" style="transition: opacity 1s;">
|
||||
{!! session('error') !!}
|
||||
</div>
|
||||
@endif --}}
|
||||
@if (session('errors'))
|
||||
<div class="alert alert-danger" role="alert" id="alert-message-danger" style="transition: opacity 1s;">
|
||||
@php
|
||||
$allMissingTasks = session('errors');
|
||||
@endphp
|
||||
<div class="card card-danger">
|
||||
<div class="card-header">
|
||||
<h3 class="card-title">Elementos não associados:</h3>
|
||||
<div class="card-tools">
|
||||
<button type="button" class="btn btn-tool" data-card-widget="collapse"><i class="fas fa-minus"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="row">
|
||||
|
||||
<div class="col-sm-4">
|
||||
@if (count($allMissingTasks['workstation']) > 0)
|
||||
<div class="card card-danger">
|
||||
<div class="card-header">
|
||||
<h3 class="card-title">Postos de Trabalho sem tarefas</h3>
|
||||
<div class="card-tools">
|
||||
<button type="button" class="btn btn-tool" data-card-widget="collapse"><i
|
||||
class="fas fa-minus"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body" style="padding: 0;">
|
||||
<ul class="list-group scrollable-list">
|
||||
@foreach ($allMissingTasks['workstation'] as $workstationId => $workstationDetails)
|
||||
<li class="list-group-item d-flex align-items-center" aria-current="true">
|
||||
{{ $workstationDetails['name_workstations'] }}
|
||||
- {{ $workstationDetails['nomenclature_workstation'] }}
|
||||
</li>
|
||||
@endforeach
|
||||
</ul>
|
||||
</div>
|
||||
</div>{{-- ./card card-danger --}}
|
||||
@endif
|
||||
</div>
|
||||
|
||||
<div class="col-sm-4">
|
||||
@if (count($allMissingTasks['elemental']) > 0)
|
||||
<div class="card card-danger">
|
||||
<div class="card-header">
|
||||
<h3 class="card-title">Tarefas elementares não atribuidas</h3>
|
||||
<div class="card-tools">
|
||||
<button type="button" class="btn btn-tool" data-card-widget="collapse"><i
|
||||
class="fas fa-minus"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body" style="padding: 0;">
|
||||
<ul class="list-group scrollable-list">
|
||||
@foreach ($allMissingTasks['elemental'] as $taskId => $taskDetails)
|
||||
<li class="list-group-item d-flex align-items-center" aria-current="true">
|
||||
{{ $taskDetails['code'] }}
|
||||
- {{ $taskDetails['description'] }}
|
||||
</li>
|
||||
@endforeach
|
||||
</ul>
|
||||
</div>
|
||||
</div>{{-- ./card card-danger --}}
|
||||
@endif
|
||||
</div>
|
||||
|
||||
<div class="col-sm-4">
|
||||
@if (count($allMissingTasks['further']) > 0)
|
||||
<div class="card card-danger">
|
||||
<div class="card-header">
|
||||
<h3 class="card-title">Tarefas complementares não atribuidas</h3>
|
||||
<div class="card-tools">
|
||||
<button type="button" class="btn btn-tool" data-card-widget="collapse"><i
|
||||
class="fas fa-minus"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body" style="padding: 0;">
|
||||
<ul class="list-group scrollable-list">
|
||||
@foreach ($allMissingTasks['further'] as $taskId => $taskDetails)
|
||||
<li class="list-group-item d-flex align-items-center" aria-current="true">
|
||||
{{ $taskDetails['name'] }}
|
||||
- {{ $taskDetails['description'] }}
|
||||
</li>
|
||||
@endforeach
|
||||
</ul>
|
||||
</div>
|
||||
</div>{{-- ./card card-danger --}}
|
||||
@endif
|
||||
</div>
|
||||
|
||||
</div>{{-- ./row --}}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
{{-- <div class="alert alert-danger" role="alert" id="alert-message-danger" style="transition: opacity 1s;">
|
||||
@foreach (session('errors') as $error)
|
||||
{!! $error !!}
|
||||
<br>
|
||||
@endforeach
|
||||
</div>
|
||||
</div> --}}
|
||||
@endif
|
||||
|
||||
|
||||
|
|
@ -72,25 +160,17 @@ class="fas fa-plus"></i>
|
|||
<div class="form-group col-md-12">
|
||||
<form action="{{ route('createWorkStations') }}" method="post">
|
||||
@csrf
|
||||
{{-- <input type="hidden" name="numberProject" value="{{ $numberProject }}">
|
||||
<div class="row">
|
||||
<div class="form-group">
|
||||
<label>Selecione o Número de Postos Pretendidos :
|
||||
</label>
|
||||
<input class="form-control" name="numberWorkstations" type="number"
|
||||
id="numberPosts">
|
||||
</div>
|
||||
<input class="btn btn-success" type="submit" value="Guardar">
|
||||
</div> --}}
|
||||
<input type="hidden" name="numberProject" value="{{ $numberProject }}">
|
||||
<input type="hidden" name="numberProject" value="{{ $numberProject }}">
|
||||
<div style="display: flex; justify-content: space-between;">
|
||||
<div style="display: flex; align-items: center;">
|
||||
<label for="inputName" style="margin-right: 10px;"> Quantidade de Postos Pretendidos :</label>
|
||||
<label for="inputName" style="margin-right: 10px;"> Quantidade de Postos
|
||||
Pretendidos :</label>
|
||||
<input class="form-control" name="numberWorkstations" type="number"
|
||||
id="numberPosts">
|
||||
id="numberPosts">
|
||||
</div>
|
||||
<div>
|
||||
<button class="btn btn-success" type="submit" value="Guardar" type="button" style="align-self: flex-end;">Button</button>
|
||||
<button class="btn btn-success" type="submit" value="Guardar"
|
||||
type="button" style="align-self: flex-end;">Button</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
|
@ -109,48 +189,36 @@ class="fas fa-plus"></i>
|
|||
</div>
|
||||
<div class="card-body">
|
||||
<div class="table-responsive">
|
||||
<form action="{{ route('AddNomenclatureWorkstation') }}" method="GET">
|
||||
<table id="workstationTable" class="table table-bordered table-striped">
|
||||
<thead>
|
||||
<table id="workstationTable" class="table table-bordered table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Posto de Trabalho</th>
|
||||
<th>Nome Posto de Trabalho</th>
|
||||
<th>Detalhes</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach ($listWorkstations as $listWorkstation)
|
||||
<tr>
|
||||
<th>Posto de Trabalho</th>
|
||||
<th>Nome Posto de Trabalho</th>
|
||||
<th>Detalhes</th>
|
||||
<td>{{ $listWorkstation->name_workstations }}</td>
|
||||
<td class="text-center">
|
||||
<span>{{ $listWorkstation->nomenclature_workstation ?? '' }}</span>
|
||||
</td>
|
||||
<td class="text-center d-flex justify-content-around ">
|
||||
<a href='#' data-toggle='modal' class="open-modal"
|
||||
data-workstation-id="{{ $listWorkstation->id_workstations }}"
|
||||
data-target='#modal-ViewOfices-{{ $listWorkstation->id_workstations }}'>
|
||||
<i class='fa-solid fa-edit text-primary'></i>
|
||||
</a>
|
||||
<a href="#" data-toggle="modal"
|
||||
data-target="#modal-remover-{{ $listWorkstation->id_workstations }}">
|
||||
<i class="fa-solid fa-trash-alt text-danger"></i>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach ($listWorkstations as $listWorkstation)
|
||||
<tr>
|
||||
<td>{{ $listWorkstation->name_workstations }}</td>
|
||||
<td class="text-center">
|
||||
@if ($listWorkstation->nomenclature_workstation == null)
|
||||
<input type="text" class="form-control"
|
||||
name="nameWorkstations[{{ $listWorkstation->name_workstations }}]"
|
||||
value="">
|
||||
@else
|
||||
<input type="text" class="form-control"
|
||||
name="nameWorkstations[{{ $listWorkstation->name_workstations }}]"
|
||||
value="{{ $listWorkstation->nomenclature_workstation }}"
|
||||
readonly>
|
||||
@endif
|
||||
</td>
|
||||
<td class="text-center d-flex justify-content-around ">
|
||||
<a href='#' data-toggle='modal' class="open-modal"
|
||||
data-workstation-id="{{ $listWorkstation->id_workstations }}"
|
||||
data-target='#modal-ViewOfices-{{ $listWorkstation->id_workstations }}'>
|
||||
<i class='fa-solid fa-edit text-primary'></i>
|
||||
</a>
|
||||
<a href="#" data-toggle="modal"
|
||||
data-target="#modal-remover-{{ $listWorkstation->id_workstations }}">
|
||||
<i class="fa-solid fa-trash-alt text-danger"></i>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
<input class="btn btn-primary" type="submit" value="Guardar">
|
||||
</form>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<!--/articulado de obra-->
|
||||
</div>
|
||||
|
|
@ -174,7 +242,7 @@ class="btn btn-primary previous float-left">Anterior</a>
|
|||
</fieldset>
|
||||
{{-- ./content --}}
|
||||
@foreach ($listWorkstations as $listWorkstation)
|
||||
<div class="modal fade" id="modal-ViewOfices-{{ $listWorkstation->id_workstations }}">
|
||||
<div class="modal fade" id="modal-ViewOfices1-{{ $listWorkstation->id_workstations }}">
|
||||
<div class="modal-dialog modal-xl">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header bg-primary">
|
||||
|
|
@ -474,6 +542,10 @@ class="checkboxChoseTasksOficesPSV" value="16"
|
|||
</div>
|
||||
<!-- /.Modal, Postos de Trabalho -->
|
||||
|
||||
@livewire('articulado.select-elemental-tasks-in-wonkstation', ['workstation' => $listWorkstation], key($listWorkstation->id_workstations))
|
||||
|
||||
|
||||
|
||||
{{-- modal-remover --}}
|
||||
<div class="modal fade" id="modal-remover-{{ $listWorkstation->id_workstations }}">
|
||||
<div class="modal-dialog">
|
||||
|
|
@ -503,44 +575,6 @@ class="checkboxChoseTasksOficesPSV" value="16"
|
|||
@endsection
|
||||
|
||||
@section('scriptsTemplateAdmin')
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$('.open-modal').click(function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
var WorkstationId = $(this).data('workstation-id');
|
||||
|
||||
// Limpa todos os checkboxes ao abrir a modal
|
||||
$('input[name^="generalTasks"]').prop('checked', false);
|
||||
$('input[name^="PsvTasks"]').prop('checked', false);
|
||||
$('input[name^="CvTasks"]').prop('checked', false);
|
||||
|
||||
$.ajax({
|
||||
url: '/api/receveTasksWorkstationPlanning/' + WorkstationId,
|
||||
method: 'GET',
|
||||
success: function(data) {
|
||||
console.log(data.workstationsAssociationTasks);
|
||||
|
||||
data.workstationsAssociationTasks.forEach(function(item) {
|
||||
// Aqui estamos assumindo que os checkboxes estão nomeados exatamente como "generalTasks[elemental_tasks_id]",
|
||||
// "PsvTasks[elemental_tasks_id]", e "CvTasks[elemental_tasks_id]". Se eles não estiverem, você precisará ajustar isto.
|
||||
$('input[name="generalTasks[' + item.elemental_tasks_id +
|
||||
']"]').prop('checked', true);
|
||||
$('input[name="PsvTasks[' + item.elemental_tasks_id + ']"]')
|
||||
.prop('checked', true);
|
||||
$('input[name="CvTasks[' + item.elemental_tasks_id + ']"]')
|
||||
.prop('checked', true);
|
||||
$('input[name="IsvTasks[' + item.elemental_tasks_id + ']"]')
|
||||
.prop('checked', true);
|
||||
|
||||
});
|
||||
}
|
||||
})
|
||||
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<script>
|
||||
$(function() {
|
||||
$("#workstationTable").DataTable({
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user