updating the system of completed projects and finished work based on the admin approving all the Work equipment
This commit is contained in:
parent
e712ff2a27
commit
ba3ce035a8
|
|
@ -44,8 +44,8 @@ public function getEquipmentsOfAmbit(Request $request)
|
|||
//Recebe os dados do Ambito
|
||||
$dataAmbit = AmbitsEquipment::where('ambits_id', $ambitId)->first();
|
||||
|
||||
$receiveDataEquipments = Equipment::where('equipments.company_projects_id', $projectId)
|
||||
->join('equipment_work_historys', 'equipments.equipment_id', '=', 'equipment_work_historys.equipment_id')
|
||||
$receiveDataEquipments = Equipment::
|
||||
join('equipment_work_historys', 'equipments.equipment_id', '=', 'equipment_work_historys.equipment_id')
|
||||
->select('equipment_work_historys.equipmentWorkHistorys_id', 'equipment_work_historys.ispt_number') // Adicionei 'equipment_work_historys.ispt_number' aqui
|
||||
->pluck('equipmentWorkHistorys_id');
|
||||
|
||||
|
|
@ -56,6 +56,8 @@ public function getEquipmentsOfAmbit(Request $request)
|
|||
$equipmentWorkHistoryIds = $filteredAssociations->pluck('equipmentWorkHistorys_id');
|
||||
|
||||
$query = EquipmentWorkHistory::whereIn('equipmentWorkHistorys_id', $equipmentWorkHistoryIds)
|
||||
->where('equipment_status_project', 2)
|
||||
->where('equipment_work_historys.company_projects_id', $projectId)
|
||||
->join('equipments', 'equipment_work_historys.equipment_id', '=', 'equipments.equipment_id')
|
||||
->select([
|
||||
'equipments.*',
|
||||
|
|
@ -103,6 +105,7 @@ public function showReportingForAmbitsProjectPdf($ambitId, $projectId)
|
|||
|
||||
// Agora, em vez de buscar diretamente em Equipment, vamos pegar os detalhes via EquipmentWorkHistory
|
||||
$equipmentDetails = EquipmentWorkHistory::whereIn('equipmentWorkHistorys_id', $equipmentWorkHistoryIds)
|
||||
->where('equipment_status_project', 2)
|
||||
->join('equipments', 'equipment_work_historys.equipment_id', '=', 'equipments.equipment_id')
|
||||
->select([
|
||||
'equipments.*',
|
||||
|
|
@ -175,31 +178,37 @@ public function getDataAmbitsOfProject(Request $request)
|
|||
// Recebe o id do Projecto atual
|
||||
$projectId = $request->get('projectId');
|
||||
|
||||
|
||||
// Recebe os IDS passados de todos os âmbitos do projeto atual
|
||||
$AmbitsIdString = $request->get('AmbitsIdString');
|
||||
$AmbitsIdArray = explode(",", $AmbitsIdString); // Converter de string para Array
|
||||
// Converter de string para Array
|
||||
$AmbitsIdArray = explode(",", $AmbitsIdString);
|
||||
|
||||
//Busca todos os Ambitos relativos aos ids enviados por request
|
||||
$query = AmbitsEquipment::whereIn('ambits_id', $AmbitsIdArray)
|
||||
->select(['ambits_id', 'ambits_description']);
|
||||
|
||||
return Datatables::of($query)
|
||||
|
||||
//MESMO que supostamente sao equipamentos ja libedos, faz sentido indica equipamentos que ja foram libedos pelo Admin
|
||||
->addColumn('amountEquipment', function ($ambitsEquipment) use ($projectId) {
|
||||
// Contar quantos equipamentos estão associados a este âmbito para o projeto específico
|
||||
return EquipmentAssociationAmbit::where('ambits_id', $ambitsEquipment->ambits_id)
|
||||
// Primeiro, juntar-se com equipment_work_historys
|
||||
->join('equipment_work_historys', 'equipment_association_ambits.equipmentWorkHistorys_id', '=', 'equipment_work_historys.equipmentWorkHistorys_id')
|
||||
// Filtra apenas os registros onde equipment_status_project é igual a 2
|
||||
->where('equipment_work_historys.equipment_status_project', 2)
|
||||
->where('equipment_work_historys.company_projects_id', $projectId)
|
||||
// Depois, juntar-se com equipments
|
||||
->join('equipments', 'equipment_work_historys.equipment_id', '=', 'equipments.equipment_id')
|
||||
// Agora, podemos filtrar pela company_projects_id
|
||||
->where('equipments.company_projects_id', $projectId)
|
||||
->count();
|
||||
->join('equipments','equipment_work_historys.equipment_id', '=', 'equipments.equipment_id')
|
||||
//filtrar pela company_projects_id
|
||||
->count(); // Retorna a contagem de equipamentos que atendem às condições
|
||||
})
|
||||
->addColumn('action', function ($dataAmbitProject) use ($projectId) {
|
||||
$actionBtn = '<a title="Detalhes do equipamento" href="' . route('showReportingForAmbitsProject', ['ambitId' => $dataAmbitProject->ambits_id, 'projectId' => $projectId]) . '"><i class="fa-solid fa-eye text-primary"></i></a>';
|
||||
return $actionBtn;
|
||||
})
|
||||
->make(true);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -214,23 +223,39 @@ public function getDataEquipmentsOfProject(Request $request)
|
|||
{
|
||||
$projectId = $request->get('projectId');
|
||||
|
||||
$query = Equipment::join('equipment_work_historys', 'equipments.equipment_id', '=', 'equipment_work_historys.equipment_id')
|
||||
// Juntar-se com equipment_association_ambits usando equipment_work_historys
|
||||
->join('equipment_association_ambits', 'equipment_work_historys.equipmentWorkHistorys_id', '=', 'equipment_association_ambits.equipmentWorkHistorys_id')
|
||||
// Juntar-se com ambits_equipments
|
||||
->join('ambits_equipments', 'equipment_association_ambits.ambits_id', '=', 'ambits_equipments.ambits_id')
|
||||
// Filtrar por company_projects_id
|
||||
->where('equipments.company_projects_id', $projectId)
|
||||
// Selecionar os campos desejados
|
||||
->select([
|
||||
'equipments.equipment_id',
|
||||
'equipments.unit_id',
|
||||
'equipments.equipment_tag',
|
||||
'equipments.equipment_type_id',
|
||||
'ambits_equipments.ambits_description as ambits_description'
|
||||
]);
|
||||
$initialQuery = Equipment::
|
||||
whereHas('equipmentWorkHistory', function ($query) use ($projectId) {
|
||||
//Para a tabela com status = pending' deve ir equipamentos com status = 1 pois estao pendentes para Aprovar
|
||||
// Para os restantes equipamentos vao para a tabela que lista os equipamentos da Obra,porem apenas os equipmentos com status = 0
|
||||
//Equipamentos concluidos e aprovados, nao vao entrar em nenhuma das 2 listas ate agora.
|
||||
$query
|
||||
->where('equipment_status_project', 2)
|
||||
->where('company_projects_id',$projectId);
|
||||
});
|
||||
|
||||
$dataEquipentProject = $query->get();
|
||||
$dataEquipentProject = $initialQuery->get();
|
||||
|
||||
return Datatables::of($dataEquipentProject)
|
||||
|
||||
->addColumn('unit_name', function ($equipment) {
|
||||
// Retorna 'unit_name' do relacionamento 'unit'
|
||||
return $equipment->unit ? $equipment->unit->unit_name : 'N/A';
|
||||
})
|
||||
->addColumn('equipment_type_name', function ($equipment) {
|
||||
// Retorna 'equipment_type_name' do relacionamento 'equipmentType'
|
||||
return $equipment->equipmentType ? $equipment->equipmentType->equipment_type_name : 'N/A';
|
||||
})
|
||||
|
||||
->addColumn('ambit_name', function ($equipment) {
|
||||
$firstEquipmentWorkHistory = $equipment->equipmentWorkHistory->first();
|
||||
return $firstEquipmentWorkHistory ? $firstEquipmentWorkHistory->equipmentAssociationAmbit->ambitsEquipment->ambits_description : 'N/A';
|
||||
})
|
||||
|
||||
->addColumn('action', function ($dataEquipment) use ($projectId) { // Use a palavra-chave 'use' para passar $projectId
|
||||
$actionBtn = '<a title="Detalhes do equipamento" href="' . route('showAmbitDetailsProjectHistory', ['equipmentStatus' => 2, 'projectID' => $projectId, 'equipmentID' => $dataEquipment->equipment_id]) . '"><i class="fa-solid fa-eye text-primary"></i></a>';
|
||||
return $actionBtn;
|
||||
})
|
||||
->make(true);
|
||||
|
||||
|
||||
// // Retornar a resposta para o DataTables
|
||||
|
|
@ -247,14 +272,6 @@ public function getDataEquipmentsOfProject(Request $request)
|
|||
|
||||
// ->make(true);
|
||||
|
||||
return Datatables::of($dataEquipentProject)
|
||||
->addColumn('action', function ($dataEquipment) use ($projectId) { // Use a palavra-chave 'use' para passar $projectId
|
||||
$actionBtn = '<a title="Detalhes do equipamento" href="' . route('showAmbitDetailsProjectHistory', ['projectID' => $projectId, 'equipmentID' => $dataEquipment->equipment_id]) . '"><i class="fa-solid fa-eye text-primary"></i></a>';
|
||||
return $actionBtn;
|
||||
})
|
||||
->make(true);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -264,6 +281,10 @@ public function showDataDetailsProjectClient($projectID)
|
|||
|
||||
// Recebe os detalhes do Projecto.
|
||||
$receiveDataProject = CompanyProject::where('company_projects_id', $projectID)->first();
|
||||
|
||||
$receivePlant = Plant::where('plant_id', $receiveDataProject->plant_id)->first();
|
||||
$receiveDetailsCompany = Company::where('company_id', $receivePlant->company_id)->first();
|
||||
|
||||
// Recebe todas as Fabricas relacionadas a intalacao do Projecto recebido.
|
||||
$receiveUnitsOfProject = Unit::where('plant_id', $receiveDataProject->plant_id)->get();
|
||||
//Recebe todos os tipos de equipamentos
|
||||
|
|
@ -284,7 +305,7 @@ public function showDataDetailsProjectClient($projectID)
|
|||
// Recebe os dados de cada Ambito
|
||||
$receiveDataAmbitsProject = AmbitsEquipment::whereIn('ambits_id', $AmbitsId)->get();
|
||||
|
||||
return view('userClient.showDataDetailsProjectClient', compact('receiveDataProject', 'receiveUnitsOfProject', 'receiveAllTypeEquipments', 'receiveDataAmbitsProject', 'AmbitsIdString'));
|
||||
return view('userClient.showDataDetailsProjectClient', compact('receiveDetailsCompany', 'receiveDataProject', 'receiveUnitsOfProject', 'receiveAllTypeEquipments', 'receiveDataAmbitsProject', 'AmbitsIdString'));
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -378,7 +399,7 @@ public function getDataProjects(Request $request)
|
|||
->addColumn('client', function ($item) {
|
||||
return $item->plant && $item->plant->company ? $item->plant->company->company_name : 'N/A';
|
||||
})
|
||||
->addColumn('action', function ($projectClient) use ($projectOrder) {
|
||||
->addColumn('action', function ($projectClient) use ($projectOrder) {
|
||||
$routeName = 'articulated_2';
|
||||
if ($projectOrder == 2) {
|
||||
$routeName = 'preparedProject';
|
||||
|
|
@ -399,7 +420,7 @@ public function receiveProjectsClient()
|
|||
{
|
||||
$client = Auth::user()->user_id;
|
||||
// DD($client);
|
||||
$recebeCompanyID = AssociationCompanyUser::where('user_id',$client)->first();
|
||||
$recebeCompanyID = AssociationCompanyUser::where('user_id', $client)->first();
|
||||
|
||||
|
||||
|
||||
|
|
@ -445,7 +466,7 @@ public function reportingDataClient($clientID = null)
|
|||
$clientID = Auth::user()->user_id;
|
||||
}
|
||||
|
||||
$companyDetails = Company::where('company_id',$clientID)->first();
|
||||
$companyDetails = Company::where('company_id', $clientID)->first();
|
||||
|
||||
// Busca todas as Instalacoes com base no id do CLIENTE
|
||||
$allPlantsClient = Plant::where('company_id', $companyDetails->company_id)->get();
|
||||
|
|
|
|||
|
|
@ -309,6 +309,69 @@ public function addFurtherTasks(Request $request)
|
|||
}
|
||||
|
||||
|
||||
// public function receiveEquipmentToAssociateTasks(Request $request)
|
||||
// {
|
||||
// $receiveIsptNumber = 0;
|
||||
|
||||
// // Obter o maior ispt_number da tabela EquipmentWorkHistory que corresponde aos valores em Equipment
|
||||
// $highestIsptNumber = EquipmentWorkHistory::select('equipment_work_historys.ispt_number')
|
||||
// ->join('equipments', function ($join) {
|
||||
// $join->on('equipments.equipment_id', '=', 'equipment_work_historys.equipment_id')
|
||||
// ->on('equipments.company_projects_id', '=', 'equipment_work_historys.company_projects_id');
|
||||
// })
|
||||
// ->orderBy('equipment_work_historys.ispt_number', 'desc')
|
||||
// ->first();
|
||||
|
||||
// // Se existir, ele busca o maior número e acrescenta mais um para adicionar um novo equipamento.
|
||||
// if ($highestIsptNumber) {
|
||||
|
||||
// $receiveIsptNumber = $highestIsptNumber->ispt_number + 1;
|
||||
// } else {
|
||||
// // Se não houver registros, comece com 1
|
||||
// $receiveIsptNumber = 1;
|
||||
// }
|
||||
|
||||
// $execution_order = 1;
|
||||
|
||||
// foreach ($request->equipment as $equipment) {
|
||||
// $equipmentModel = Equipment::where('equipment_id', $equipment['equipment_id'])->first();
|
||||
|
||||
// //Atualiza a tabela equipment para associar o equipamento a uma Obra.
|
||||
// if ($equipmentModel) {
|
||||
// $equipmentModel->company_projects_id = $request->receiveNumberProject;
|
||||
// $equipmentModel->save();
|
||||
|
||||
// // Ja associado, criar dados nos Historico para depois ser possivel de acessar.
|
||||
// $createEquipmentWorkHistory = new EquipmentWorkHistory;
|
||||
// $createEquipmentWorkHistory->equipment_id = $equipment['equipment_id'];
|
||||
// $createEquipmentWorkHistory->ispt_number = $receiveIsptNumber++;
|
||||
// $createEquipmentWorkHistory->company_projects_id = $request->receiveNumberProject;
|
||||
// $createEquipmentWorkHistory->save();
|
||||
|
||||
// //Criar associacao do equipamento ao Âmbito
|
||||
// $AssociationEquipmentAmbit = new EquipmentAssociationAmbit;
|
||||
// $AssociationEquipmentAmbit->equipment_type_id = $equipment['equipment_type_id'];
|
||||
// $AssociationEquipmentAmbit->ambits_id = $equipment['ambit_id'];
|
||||
// $AssociationEquipmentAmbit->equipmentWorkHistorys_id = $createEquipmentWorkHistory->equipmentWorkHistorys_id;
|
||||
// $AssociationEquipmentAmbit->save();
|
||||
|
||||
// //Recebe a tabela com as associoacoes entre Âmbitos e tarefas Elementares
|
||||
// $TasksAssociationAmbits = TasksAssociationAmbits::all()->where('ambits_equipment_id', $AssociationEquipmentAmbit->ambits_id);
|
||||
|
||||
// foreach ($TasksAssociationAmbits as $TasksAssociationAmbit) {
|
||||
// $JoinsEquipmentsWithTasks = new OrderEquipmentTasks;
|
||||
// $JoinsEquipmentsWithTasks->equipmentWorkHistorys_id = $createEquipmentWorkHistory->equipmentWorkHistorys_id;
|
||||
// $JoinsEquipmentsWithTasks->execution_order = $execution_order++;
|
||||
// $JoinsEquipmentsWithTasks->elemental_tasks_id = $TasksAssociationAmbit->elemental_tasks_id;
|
||||
// $JoinsEquipmentsWithTasks->further_tasks_id = null;
|
||||
// $JoinsEquipmentsWithTasks->inspection = 2;
|
||||
// $JoinsEquipmentsWithTasks->save();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// return redirect()->back()->with('success', 'Equipametos associados a Obra com Sucesso !');
|
||||
// }
|
||||
public function receiveEquipmentToAssociateTasks(Request $request)
|
||||
{
|
||||
$receiveIsptNumber = 0;
|
||||
|
|
@ -324,7 +387,6 @@ public function receiveEquipmentToAssociateTasks(Request $request)
|
|||
|
||||
// Se existir, ele busca o maior número e acrescenta mais um para adicionar um novo equipamento.
|
||||
if ($highestIsptNumber) {
|
||||
|
||||
$receiveIsptNumber = $highestIsptNumber->ispt_number + 1;
|
||||
} else {
|
||||
// Se não houver registros, comece com 1
|
||||
|
|
@ -341,26 +403,31 @@ public function receiveEquipmentToAssociateTasks(Request $request)
|
|||
$equipmentModel->company_projects_id = $request->receiveNumberProject;
|
||||
$equipmentModel->save();
|
||||
|
||||
// Ja associado, criar dados nos Historico para depois ser possivel de acessar.
|
||||
$createEquipmentWorkHistory = new EquipmentWorkHistory;
|
||||
$createEquipmentWorkHistory->equipment_id = $equipment['equipment_id'];
|
||||
$createEquipmentWorkHistory->ispt_number = $receiveIsptNumber++;
|
||||
$createEquipmentWorkHistory->company_projects_id = $request->receiveNumberProject;
|
||||
$createEquipmentWorkHistory->save();
|
||||
// Utiliza firstOrCreate para evitar duplicidades
|
||||
$attributes = [
|
||||
'equipment_id' => $equipment['equipment_id'],
|
||||
'company_projects_id' => $request->receiveNumberProject
|
||||
];
|
||||
|
||||
//Criar associacao do equipamento ao Âmbito
|
||||
$values = [
|
||||
'ispt_number' => $receiveIsptNumber++ // Incrementa o número ISPT se criar um novo registro
|
||||
];
|
||||
|
||||
$createEquipmentWorkHistory = EquipmentWorkHistory::firstOrCreate($attributes, $values);
|
||||
|
||||
//Criar associacao do equipamento ao Âmbito
|
||||
$AssociationEquipmentAmbit = new EquipmentAssociationAmbit;
|
||||
$AssociationEquipmentAmbit->equipment_type_id = $equipment['equipment_type_id'];
|
||||
$AssociationEquipmentAmbit->ambits_id = $equipment['ambit_id'];
|
||||
$AssociationEquipmentAmbit->equipmentWorkHistorys_id = $createEquipmentWorkHistory->equipmentWorkHistorys_id;
|
||||
$AssociationEquipmentAmbit->equipmentWorkHistorys_id = $createEquipmentWorkHistory->id; // Note que mudamos para id
|
||||
$AssociationEquipmentAmbit->save();
|
||||
|
||||
//Recebe a tabela com as associoacoes entre Âmbitos e tarefas Elementares
|
||||
$TasksAssociationAmbits = TasksAssociationAmbits::all()->where('ambits_equipment_id', $AssociationEquipmentAmbit->ambits_id);
|
||||
//Recebe a tabela com as associações entre Âmbitos e tarefas Elementares
|
||||
$TasksAssociationAmbits = TasksAssociationAmbits::where('ambits_equipment_id', $AssociationEquipmentAmbit->ambits_id)->get();
|
||||
|
||||
foreach ($TasksAssociationAmbits as $TasksAssociationAmbit) {
|
||||
$JoinsEquipmentsWithTasks = new OrderEquipmentTasks;
|
||||
$JoinsEquipmentsWithTasks->equipmentWorkHistorys_id = $createEquipmentWorkHistory->equipmentWorkHistorys_id;
|
||||
$JoinsEquipmentsWithTasks->equipmentWorkHistorys_id = $createEquipmentWorkHistory->id; // Note que mudamos para id
|
||||
$JoinsEquipmentsWithTasks->execution_order = $execution_order++;
|
||||
$JoinsEquipmentsWithTasks->elemental_tasks_id = $TasksAssociationAmbit->elemental_tasks_id;
|
||||
$JoinsEquipmentsWithTasks->further_tasks_id = null;
|
||||
|
|
@ -373,6 +440,7 @@ public function receiveEquipmentToAssociateTasks(Request $request)
|
|||
return redirect()->back()->with('success', 'Equipametos associados a Obra com Sucesso !');
|
||||
}
|
||||
|
||||
|
||||
public function receiveUnitsForExcelTemplate($numberProject)
|
||||
{
|
||||
// Dados do Projecto
|
||||
|
|
@ -713,12 +781,12 @@ public function createProjectForStep1()
|
|||
public function showStep1($company_projects_id)
|
||||
{
|
||||
$projects = CompanyProject::find($company_projects_id);
|
||||
|
||||
|
||||
$companies = Company::all();
|
||||
|
||||
$receiveDetailsPlant = Plant::where('plant_id', $projects->plant_id)->first();
|
||||
|
||||
$receiveDetailsCompany = Company::where('company_id',$receiveDetailsPlant->company_id)->first();
|
||||
$receiveDetailsCompany = Company::where('company_id', $receiveDetailsPlant->company_id)->first();
|
||||
// $receiveDetailsUser = User::where('user_id', $receiveDetailsPlant->user_id)->first();
|
||||
// $receiveDetailsUser->plantName = $receiveDetailsPlant->plant_name;
|
||||
|
||||
|
|
@ -754,14 +822,14 @@ public function EditprocessStep1(Request $request)
|
|||
session(['form_data.step1' => $request->all()]);
|
||||
|
||||
$receiveAllLogsProject = ProjectExcelLog::where('company_projects_id', $project->company_projects_id)
|
||||
->get()
|
||||
->groupBy('excel_name')
|
||||
->map(function ($group) {
|
||||
return $group->sortByDesc('project_excel_logs_id')->first();
|
||||
});
|
||||
->get()
|
||||
->groupBy('excel_name')
|
||||
->map(function ($group) {
|
||||
return $group->sortByDesc('project_excel_logs_id')->first();
|
||||
});
|
||||
|
||||
return redirect()->route('articulated_2', ['projectID' => $project->company_projects_id])
|
||||
->with('receiveAllLogsProject',$receiveAllLogsProject)
|
||||
->with('receiveAllLogsProject', $receiveAllLogsProject)
|
||||
->with('success', 'Detalhes do Project atualizados!');
|
||||
}
|
||||
|
||||
|
|
@ -772,76 +840,136 @@ public function removePendingEquipment($id)
|
|||
return back()->with('success', 'Equipamento pendente removido com sucesso!');
|
||||
}
|
||||
|
||||
// public function CreateNewEquipmentFromPendingEquipment(Request $request, $id)
|
||||
// {
|
||||
// $checkPendingEquipment = PendingEquipment::findOrFail($id);
|
||||
|
||||
// // dd($checkPendingEquipment);
|
||||
|
||||
// //Para que serve ??
|
||||
// $counter = 2;
|
||||
// $baseTag = $checkPendingEquipment->pending_equipment_tag;
|
||||
// $baseDescription = $checkPendingEquipment->pending_equipment_description;
|
||||
|
||||
// // Ciclo para verificar se ja existe um equipamento com o mesmo nome se existir vai criando com o contador iniciado a partir de (2)
|
||||
// while (Equipment::where('equipment_tag', $baseTag . "({$counter})")->orWhere('equipment_description', $baseDescription . "({$counter})")->exists()) {
|
||||
// $counter++;
|
||||
// }
|
||||
|
||||
// $newEquipment = new Equipment;
|
||||
// $newEquipment->unit_id = $checkPendingEquipment->pending_equipment_unit_id;
|
||||
// $newEquipment->equipment_type_id = $checkPendingEquipment->pending_equipment_type_id;
|
||||
// $newEquipment->equipment_tag = $baseTag . "({$counter})";
|
||||
// $newEquipment->equipment_description = $baseDescription . "({$counter})";
|
||||
// $newEquipment->equipment_serial_number = $checkPendingEquipment->pending_equipment_serial_number;
|
||||
// $newEquipment->equipment_brand = $checkPendingEquipment->pending_equipment_brand;
|
||||
// $newEquipment->equipment_model = $checkPendingEquipment->pending_equipment_model;
|
||||
// $newEquipment->company_projects_id = $checkPendingEquipment->pending_company_projects_id;
|
||||
// $newEquipment->save();
|
||||
|
||||
// $newEquipmentWorkHistory = new EquipmentWorkHistory;
|
||||
// $newEquipmentWorkHistory->equipment_id = $newEquipment->equipment_id;
|
||||
// $newEquipmentWorkHistory->company_projects_id = $newEquipment->company_projects_id;
|
||||
|
||||
// // Busca o maior ispt_number para o company_projects_id específico
|
||||
// $lastIsptNumber = EquipmentWorkHistory::where('company_projects_id', $newEquipment->company_projects_id)
|
||||
// ->max('ispt_number');
|
||||
|
||||
// // Se não houver registros, definimos o primeiro número para 1, caso contrário, incrementamos o último número encontrado
|
||||
// $newIsptNumber = $lastIsptNumber ? $lastIsptNumber + 1 : 1;
|
||||
|
||||
// // Agora, atribuímos o novo número ISPT ao registro de histórico de equipamento
|
||||
// $newEquipmentWorkHistory->ispt_number = $newIsptNumber;
|
||||
|
||||
// $newEquipmentWorkHistory->save();
|
||||
|
||||
|
||||
// $newEquipmentAssociationAmbits = new EquipmentAssociationAmbit;
|
||||
// $newEquipmentAssociationAmbits->equipmentWorkHistorys_id = $newEquipmentWorkHistory->equipmentWorkHistorys_id;
|
||||
// $newEquipmentAssociationAmbits->ambits_id = $request->EquipmentAmbit;
|
||||
// $newEquipmentAssociationAmbits->equipment_type_id = $checkPendingEquipment->pending_equipment_type_id;
|
||||
// $newEquipmentAssociationAmbits->save();
|
||||
|
||||
// //Recebe a tabela com as associoacoes entre Âmbitos e tarefas Elementares
|
||||
// $TasksAssociationAmbits = TasksAssociationAmbits::all()->where('ambits_equipment_id', $newEquipmentAssociationAmbits->ambits_id);
|
||||
|
||||
// foreach ($TasksAssociationAmbits as $TasksAssociationAmbit) {
|
||||
// $JoinsEquipmentsWithTasks = new OrderEquipmentTasks;
|
||||
// $JoinsEquipmentsWithTasks->equipmentWorkHistorys_id = $newEquipmentWorkHistory->equipmentWorkHistorys_id;
|
||||
// $JoinsEquipmentsWithTasks->execution_order = null;
|
||||
// $JoinsEquipmentsWithTasks->elemental_tasks_id = $TasksAssociationAmbit->elemental_tasks_id;
|
||||
// $JoinsEquipmentsWithTasks->further_tasks_id = null;
|
||||
// $JoinsEquipmentsWithTasks->inspection = 2;
|
||||
// $JoinsEquipmentsWithTasks->save();
|
||||
// }
|
||||
|
||||
|
||||
// $checkPendingEquipment->delete();
|
||||
|
||||
// return back()->with('success', 'Equipamento ' . $newEquipment->equipment_tag . ' criado com sucesso');
|
||||
// }
|
||||
|
||||
public function CreateNewEquipmentFromPendingEquipment(Request $request, $id)
|
||||
{
|
||||
$checkPendingEquipment = PendingEquipment::findOrFail($id);
|
||||
|
||||
// dd($checkPendingEquipment);
|
||||
|
||||
//Para que serve ??
|
||||
$counter = 2;
|
||||
$baseTag = $checkPendingEquipment->pending_equipment_tag;
|
||||
$baseDescription = $checkPendingEquipment->pending_equipment_description;
|
||||
|
||||
// Ciclo para verificar se ja existe um equipamento com o mesmo nome se existir vai criando com o contador iniciado a partir de (2)
|
||||
// Ciclo para verificar se já existe um equipamento com o mesmo nome se existir vai criando com o contador iniciado a partir de (2)
|
||||
while (Equipment::where('equipment_tag', $baseTag . "({$counter})")->orWhere('equipment_description', $baseDescription . "({$counter})")->exists()) {
|
||||
$counter++;
|
||||
}
|
||||
|
||||
$newEquipment = new Equipment;
|
||||
$newEquipment->unit_id = $checkPendingEquipment->pending_equipment_unit_id;
|
||||
$newEquipment->equipment_type_id = $checkPendingEquipment->pending_equipment_type_id;
|
||||
$newEquipment->equipment_tag = $baseTag . "({$counter})";
|
||||
$newEquipment->equipment_description = $baseDescription . "({$counter})";
|
||||
$newEquipment->equipment_serial_number = $checkPendingEquipment->pending_equipment_serial_number;
|
||||
$newEquipment->equipment_brand = $checkPendingEquipment->pending_equipment_brand;
|
||||
$newEquipment->equipment_model = $checkPendingEquipment->pending_equipment_model;
|
||||
$newEquipment->company_projects_id = $checkPendingEquipment->pending_company_projects_id;
|
||||
$newEquipment->save();
|
||||
$attributes = [
|
||||
'unit_id' => $checkPendingEquipment->pending_equipment_unit_id,
|
||||
'equipment_type_id' => $checkPendingEquipment->pending_equipment_type_id,
|
||||
'equipment_tag' => $baseTag . "({$counter})",
|
||||
'equipment_description' => $baseDescription . "({$counter})",
|
||||
'company_projects_id' => $checkPendingEquipment->pending_company_projects_id
|
||||
];
|
||||
|
||||
$newEquipmentWorkHistory = new EquipmentWorkHistory;
|
||||
$newEquipmentWorkHistory->equipment_id = $newEquipment->equipment_id;
|
||||
$newEquipmentWorkHistory->company_projects_id = $newEquipment->company_projects_id;
|
||||
$newEquipment = Equipment::firstOrCreate($attributes);
|
||||
|
||||
// Busca o maior ispt_number para o company_projects_id específico
|
||||
$lastIsptNumber = EquipmentWorkHistory::where('company_projects_id', $newEquipment->company_projects_id)
|
||||
->max('ispt_number');
|
||||
$newEquipmentWorkHistoryAttributes = [
|
||||
'equipment_id' => $newEquipment->equipment_id,
|
||||
'company_projects_id' => $newEquipment->company_projects_id
|
||||
];
|
||||
|
||||
// Se não houver registros, definimos o primeiro número para 1, caso contrário, incrementamos o último número encontrado
|
||||
$lastIsptNumber = EquipmentWorkHistory::where('company_projects_id', $newEquipment->company_projects_id)->max('ispt_number');
|
||||
$newIsptNumber = $lastIsptNumber ? $lastIsptNumber + 1 : 1;
|
||||
|
||||
// Agora, atribuímos o novo número ISPT ao registro de histórico de equipamento
|
||||
$newEquipmentWorkHistory->ispt_number = $newIsptNumber;
|
||||
|
||||
$newEquipmentWorkHistory->save();
|
||||
$valuesWorkHistory = [
|
||||
'ispt_number' => $newIsptNumber,
|
||||
'equipment_status_project' => 0
|
||||
];
|
||||
|
||||
$newEquipmentWorkHistory = EquipmentWorkHistory::firstOrCreate($newEquipmentWorkHistoryAttributes, $valuesWorkHistory);
|
||||
|
||||
$newEquipmentAssociationAmbits = new EquipmentAssociationAmbit;
|
||||
$newEquipmentAssociationAmbits->equipmentWorkHistorys_id = $newEquipmentWorkHistory->equipmentWorkHistorys_id;
|
||||
$newEquipmentAssociationAmbits->ambits_id = $request->EquipmentAmbit;
|
||||
$newEquipmentAssociationAmbits->equipment_type_id = $checkPendingEquipment->pending_equipment_type_id;
|
||||
$newEquipmentAssociationAmbits->equipment_type_id = $newEquipment->equipment_type_id;
|
||||
$newEquipmentAssociationAmbits->save();
|
||||
|
||||
//Recebe a tabela com as associoacoes entre Âmbitos e tarefas Elementares
|
||||
$TasksAssociationAmbits = TasksAssociationAmbits::all()->where('ambits_equipment_id', $newEquipmentAssociationAmbits->ambits_id);
|
||||
|
||||
$TasksAssociationAmbits = TasksAssociationAmbits::where('ambits_equipment_id', $newEquipmentAssociationAmbits->ambits_id)->get();
|
||||
|
||||
foreach ($TasksAssociationAmbits as $TasksAssociationAmbit) {
|
||||
$JoinsEquipmentsWithTasks = new OrderEquipmentTasks;
|
||||
$JoinsEquipmentsWithTasks->equipmentWorkHistorys_id = $newEquipmentWorkHistory->equipmentWorkHistorys_id;
|
||||
$JoinsEquipmentsWithTasks->execution_order = null;
|
||||
$JoinsEquipmentsWithTasks->elemental_tasks_id = $TasksAssociationAmbit->elemental_tasks_id;
|
||||
$JoinsEquipmentsWithTasks->further_tasks_id = null;
|
||||
$JoinsEquipmentsWithTasks->inspection = 2;
|
||||
$JoinsEquipmentsWithTasks->save();
|
||||
}
|
||||
|
||||
|
||||
$checkPendingEquipment->delete();
|
||||
|
||||
return back()->with('success', 'Equipamento ' . $newEquipment->equipment_tag . ' criado com sucesso');
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function processStep1(Request $request)
|
||||
{
|
||||
//NAO DEVE SER CRIAR UMA NOVA EMPRESA NA CRIACAO DA OBRA (era uma boa ideia para facilitar ao Admin ter que criar a empresa para Depois a Obra, mas e necessario pelo facto da autentificao de 2 factores e envio e email , entao devido essa adicoes, nao preciso atualmente fazer sentido criar isto)
|
||||
|
|
@ -1264,7 +1392,7 @@ function normalize($value)
|
|||
// Registra a linha como ignorada se menos de 2 campos estiverem preenchidos ou se houver campos não preenchidos
|
||||
if ($nonEmptyFieldsCount > 2 && $nonEmptyFieldsCount < 5) {
|
||||
$equipmentPendingLogs[] = [
|
||||
'typePendingLog' => 0 ,
|
||||
'typePendingLog' => 0,
|
||||
'line' => $i + 1,
|
||||
'reason' => implode(', ', $missingFields), // Converte o array de campos faltantes para uma string
|
||||
];
|
||||
|
|
@ -1409,6 +1537,7 @@ function normalize($value)
|
|||
$newEquipmentWorkHistory->equipment_id = $newEquipament->equipment_id;
|
||||
$newEquipmentWorkHistory->ispt_number = $isptNumber++;
|
||||
$newEquipmentWorkHistory->company_projects_id = $company_projects_id;
|
||||
$newEquipmentWorkHistory->equipment_status_project = 0;
|
||||
$newEquipmentWorkHistory->save();
|
||||
|
||||
$ambit = AmbitsEquipment::where('ambits_description', $datas['ambit'])->first();
|
||||
|
|
|
|||
|
|
@ -71,7 +71,6 @@ public function getDataEquipmentClient(Request $request)
|
|||
|
||||
public function getDataEquipment(Request $request)
|
||||
{
|
||||
|
||||
//Variaveis recebidos da Obra em Planeamento (Filtros)
|
||||
$numberProject = $request->get('numberProject');
|
||||
$receiveRespostUnitsSelect = $request->get('checkUnits');
|
||||
|
|
@ -527,13 +526,42 @@ public function receiveExecutionProject($ProjectId)
|
|||
}
|
||||
return $user;
|
||||
});
|
||||
// Retornando a view com os dados necessários
|
||||
return view('projectsClients/executionProjectNew', [
|
||||
'DatasProject' => $DatasProject,
|
||||
'equipmentsTypes' => $equipmentsTypes,
|
||||
'receiveCompany' => $receiveCompany,
|
||||
'filteredUsers' => $filteredUsers
|
||||
]);
|
||||
|
||||
//Recebe todos os equipamentos apenas para verificar quantos ainda faltam para terminar a Obra.
|
||||
$receiveAllEquipments = Equipment::where('company_projects_id', $DatasProject->company_projects_id)->get();
|
||||
|
||||
$allEquipmentsFullyCompleted = $receiveAllEquipments->every(function ($equipment) {
|
||||
// Verifica se todos os registros dos Equipamntos têm equipment_status_project igual a 2 (TRUE /FALSE)
|
||||
return $equipment->equipmentWorkHistory->every(function ($workHistory) {
|
||||
return $workHistory->equipment_status_project == 2;
|
||||
});
|
||||
});
|
||||
|
||||
// $allEquipmentsFullyCompleted será true se todos os equipamentos tiverem todos seus históricos com status 2
|
||||
//Deve verificar se todos os equipamentos ja foram concluidos e se for o caso, deve alterar para Obra concluido, autorizar os relatorios e dessasociar todos os equipamento da Obra atual.
|
||||
if ($allEquipmentsFullyCompleted) {
|
||||
|
||||
$DatasProject->order_project = 4;
|
||||
$DatasProject->save();
|
||||
|
||||
// Desassocia todos os equipamentos do projeto
|
||||
Equipment::where('company_projects_id', $DatasProject->company_projects_id)
|
||||
->update(['company_projects_id' => null]);
|
||||
|
||||
return redirect()->route('home');
|
||||
|
||||
} else {
|
||||
//Caso nem todos os equipamento tenham-se concluidos, deve voltar a pagina de Execussao normalmente
|
||||
// Retornando a view com os dados necessários
|
||||
return view('projectsClients/executionProjectNew', [
|
||||
'DatasProject' => $DatasProject,
|
||||
'equipmentsTypes' => $equipmentsTypes,
|
||||
'receiveCompany' => $receiveCompany,
|
||||
'filteredUsers' => $filteredUsers
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function changeFromExecutionToPlanning($projectID)
|
||||
|
|
@ -604,6 +632,85 @@ public function showQrcodesInProject($projectNumber)
|
|||
->with('equipmentsProjects', $equipmentsProjects);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// public function receiveDetailsEquipmentsProject(Request $request)
|
||||
// {
|
||||
// $numberProject = $request->input('receiveNumberProject');
|
||||
// $tableType = $request->input('tableType'); // Captura o tipo de tabela
|
||||
|
||||
// // Para
|
||||
// if ($tableType == 'pending') {
|
||||
|
||||
// $initialQuery = Equipment::where('company_projects_id', $numberProject);
|
||||
|
||||
// } else {
|
||||
// // Lógica para a tabela 'normal'
|
||||
// $initialQuery = Equipment::where('company_projects_id', $numberProject);
|
||||
// }
|
||||
|
||||
// $query = $initialQuery->get(); // Certifique-se de usar get() para retornar uma coleção
|
||||
|
||||
// return DataTables::of($query)
|
||||
// ->addColumn('equipment_type_name', function ($query) {
|
||||
// // Retorna 'equipment_type_name' do relacionamento 'equipmentType'
|
||||
// return $query->equipmentType ? $query->equipmentType->equipment_type_name : 'N/A';
|
||||
// })
|
||||
// ->addColumn('unit_name', function ($query) {
|
||||
// // Retorna 'unit_name' do relacionamento 'unit'
|
||||
// return $query->unit ? $query->unit->unit_name : 'N/A';
|
||||
// })
|
||||
// ->addColumn('ambit_name', function ($query) {
|
||||
// $firstEquipmentWorkHistory = $query->equipmentWorkHistory->first();
|
||||
// return $firstEquipmentWorkHistory->equipmentAssociationAmbit->ambitsEquipment->ambits_description;
|
||||
// })
|
||||
// ->make(true);
|
||||
// }
|
||||
|
||||
public function receiveDetailsEquipmentsProject(Request $request)
|
||||
{
|
||||
$numberProject = $request->input('receiveNumberProject');
|
||||
$tableType = $request->input('tableType'); // Captura o tipo de tabela
|
||||
|
||||
// Ajusta a query inicial dependendo se estamos buscando equipamentos pendentes ou normais.
|
||||
$initialQuery = Equipment::where('company_projects_id', $numberProject)
|
||||
->whereHas('equipmentWorkHistory', function ($query) use ($tableType) {
|
||||
//Para a tabela com status = pending' deve ir equipamentos com status = 1 pois estao pendentes para Aprovar
|
||||
// Para os restantes equipamentos vao para a tabela que lista os equipamentos da Obra,porem apenas os equipmentos com status = 0
|
||||
//Equipamentos concluidos e aprovados, nao vao entrar em nenhuma das 2 listas ate agora.
|
||||
$status = $tableType === 'pending' ? 1 : 0;
|
||||
$query->where('equipment_status_project', $status);
|
||||
});
|
||||
|
||||
$query = $initialQuery->get(); // Obtém a coleção de equipamentos com base nos critérios
|
||||
|
||||
return DataTables::of($query)
|
||||
->addColumn('equipment_type_name', function ($equipment) {
|
||||
// Retorna 'equipment_type_name' do relacionamento 'equipmentType'
|
||||
return $equipment->equipmentType ? $equipment->equipmentType->equipment_type_name : 'N/A';
|
||||
})
|
||||
->addColumn('unit_name', function ($equipment) {
|
||||
// Retorna 'unit_name' do relacionamento 'unit'
|
||||
return $equipment->unit ? $equipment->unit->unit_name : 'N/A';
|
||||
})
|
||||
->addColumn('ambit_name', function ($equipment) {
|
||||
$firstEquipmentWorkHistory = $equipment->equipmentWorkHistory->first();
|
||||
return $firstEquipmentWorkHistory ? $firstEquipmentWorkHistory->equipmentAssociationAmbit->ambitsEquipment->ambits_description : 'N/A';
|
||||
})
|
||||
|
||||
//Vai ser 2 tipos de action, para as tabelas.
|
||||
->addColumn('action', function ($dataEquipment) use ($numberProject, $tableType) {
|
||||
$equipmentStatus = $tableType === 'pending' ? 1 : 0;
|
||||
$actionBtn = '<a title="Detalhes do equipamento" href="' . route('showAmbitDetailsProjectHistory', ['equipmentStatus' => $equipmentStatus, 'projectID' => $numberProject, 'equipmentID' => $dataEquipment->equipment_id]) . '"><i class="fa-solid fa-eye text-primary"></i></a>';
|
||||
return $actionBtn;
|
||||
})
|
||||
|
||||
->make(true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// public function receiveEquipmentsExecutionProject($receiveNumberProject)
|
||||
// {
|
||||
// // Recebe os dados vindos da funcao 'data' criada na view
|
||||
|
|
|
|||
|
|
@ -126,49 +126,53 @@ class PreparedProjectController extends Controller
|
|||
public function showAllEquipmentsInProjectForQrCode($projectId)
|
||||
{
|
||||
$equipments = Equipment::where('company_projects_id', $projectId)->get();
|
||||
|
||||
|
||||
$equipmentData = [];
|
||||
foreach ($equipments as $equipment) {
|
||||
$associatedEquipments = QrcodesAssociatedEquipment::where('equipment_id', $equipment->equipment_id)->get();
|
||||
$associatedArray = [];
|
||||
|
||||
|
||||
foreach ($associatedEquipments as $associatedEquipment) {
|
||||
$qrCode = new QrCode($associatedEquipment->component_tag);
|
||||
$writer = new PngWriter();
|
||||
$qrCodeImage = 'data:image/png;base64,' . base64_encode($writer->write($qrCode)->getString());
|
||||
|
||||
|
||||
$associatedArray[] = [
|
||||
'id' => $associatedEquipment->id,
|
||||
'component_tag' => $associatedEquipment->component_tag,
|
||||
'qrCodeImage' => $qrCodeImage
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
$equipmentData[] = [
|
||||
'equipment' => $equipment,
|
||||
'associatedArray' => $associatedArray
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
$detailsCompanyProject = CompanyProject::find($projectId);
|
||||
$detailsPlant = Plant::where('plant_id', $detailsCompanyProject->plant_id)->first();
|
||||
$detailsCompany = Company::where('company_id', $detailsPlant->company_id)->first();
|
||||
$logoPath = public_path('companies_logo/' . ($detailsCompany->company_logo ?: 'logoISPT4.0.jpg'));
|
||||
|
||||
|
||||
if (!file_exists($logoPath)) {
|
||||
$logoPath = public_path('companies_logo/logoISPT4.0.jpg');
|
||||
}
|
||||
|
||||
|
||||
$html = view('projectsClients.showAllEquipmentsInProjectQrCodePdf', [
|
||||
'equipmentData' => $equipmentData,
|
||||
'logoPath' => $logoPath
|
||||
])->render();
|
||||
|
||||
$mpdf = new \Mpdf\Mpdf(['mode' => 'utf-8', 'format' => 'A4']);
|
||||
|
||||
$mpdf = new Mpdf(['mode' => 'utf-8', 'format' => 'A4']);
|
||||
|
||||
$mpdf->useSubstitutions = false; // Reduce processing
|
||||
$mpdf->simpleTables = true; // Simplifies tables into basic HTML
|
||||
|
||||
$mpdf->WriteHTML($html);
|
||||
$mpdf->Output('equipamentos_projeto_' . $projectId . '.pdf', 'I');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// public function showDetailsEquipmentForQrCode($equipmentId, $projectId)
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
use App\Models\ControlEquipmentWorkstation;
|
||||
use App\Models\ElementalTasks;
|
||||
use App\Models\EquipmentAssociationAmbit;
|
||||
use App\Models\EquipmentComment;
|
||||
use App\Models\EquipmentWorkHistory;
|
||||
use App\Models\TasksAssociationAmbits;
|
||||
use App\Models\Unit;
|
||||
|
|
@ -146,9 +147,8 @@ public function checkProjectIsptNumber(Request $request, $projectId = null)
|
|||
}
|
||||
|
||||
|
||||
public function showAmbitDetailsProjectHistory($projectID, $equipmentID)
|
||||
public function showAmbitDetailsProjectHistory($equipmentStatus, $projectID, $equipmentID)
|
||||
{
|
||||
|
||||
$detailsProject = CompanyProject::where('company_projects_id', $projectID)->first();
|
||||
$detailsCliente = Plant::where('plant_id', $detailsProject->plant_id)->first();
|
||||
$detailsProject->user_id = $detailsCliente->user_id;
|
||||
|
|
@ -255,7 +255,7 @@ public function showAmbitDetailsProjectHistory($projectID, $equipmentID)
|
|||
// dd($receiveAmbit);
|
||||
|
||||
|
||||
return view('projectsClients.showAmbitDetailProjectHistory', compact('detailsProject', 'receiveAmbit', 'receiveAllTasksHistiory', 'detalsEquipment'));
|
||||
return view('projectsClients.showAmbitDetailProjectHistory', compact('equipmentStatus', 'detailsProject', 'receiveAmbit', 'receiveAllTasksHistiory', 'detalsEquipment'));
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -349,7 +349,7 @@ public function testRelatorio()
|
|||
|
||||
public function receiveUnitsManageAssets($receivePlantClientRelated)
|
||||
{
|
||||
|
||||
|
||||
|
||||
$UnitsData = Unit::where('plant_id', $receivePlantClientRelated)->get();
|
||||
|
||||
|
|
@ -739,4 +739,35 @@ public function receiveWorkstationProject($receiveNumberProject)
|
|||
})
|
||||
->toJson();
|
||||
}
|
||||
|
||||
public function changeEquipmentStatusOnProject(Request $request)
|
||||
{
|
||||
|
||||
$receivedetailsUser = auth()->user();
|
||||
|
||||
$detailsEquipmentWorkHistory = EquipmentWorkHistory::
|
||||
where('equipment_id', $request->equipmentID)
|
||||
->where('company_projects_id', $request->projectID)
|
||||
->where('equipment_status_project', 1)
|
||||
->first();
|
||||
|
||||
if ($request->choiseAdminForEquipment == 'approve') {
|
||||
//Se for aprovado, libera o equipamento para relatorio.
|
||||
$detailsEquipmentWorkHistory->equipment_status_project = 2 ;
|
||||
$detailsEquipmentWorkHistory->save();
|
||||
}
|
||||
|
||||
//Sempre vai criar o comentario, a diferenca a se o equipamento tem status : 2 o comanterio vai para o relatorio,se nao vai para os comentarios da Ws.
|
||||
$createCommet= new EquipmentComment;
|
||||
$createCommet->equipmentWorkHistorys_id = $detailsEquipmentWorkHistory->equipmentWorkHistorys_id;
|
||||
$createCommet->user_id = $receivedetailsUser->user_id;
|
||||
$createCommet->company_projects_id = $detailsEquipmentWorkHistory->company_projects_id;
|
||||
$createCommet->creation_date = now();
|
||||
$createCommet->comment =$request->comment;
|
||||
$createCommet->save();
|
||||
|
||||
return redirect()->route('ExecutionProject', ['projectID' => $request->projectID])
|
||||
->with('success', 'Equipamento aprovado, liberado para relatório.');
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -78,8 +78,8 @@ protected function getAllowedRoutesForUserType($userType)
|
|||
'deletePendingEquipments','CreateNewEquipmentFromPendingEquipment','removeEquipment','receiveEquipmentToAssociateTasks',
|
||||
'createCompany','ShowPendingUser','register','download','projectDetails_11','editEquipment','EditprocessStep1','createWorkStations','workstationsAssociationTasks','finishCreatingProject',
|
||||
'preparedProject','EditProjectForArticulated','companyEdit','reportingDataClient','ExecutionProject',
|
||||
'changeFromExecutionToPlanning','deleteWorkstation','deleteProject','showQrcodesInProject',
|
||||
|
||||
'changeFromExecutionToPlanning','deleteWorkstation','deleteProject','showQrcodesInProject','showDataDetailsProjectClient',
|
||||
'getDataAmbitsOfProject', 'showReportingForAmbitsProject','getEquipmentsOfAmbit','getDataEquipmentsOfProject',
|
||||
];
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -18,12 +18,11 @@ class WorkstationComposer
|
|||
{
|
||||
public function compose(View $view)
|
||||
{
|
||||
//Recebe o User pela sessao atual e recebe seus dados.
|
||||
//Recebe os dados do Ws pela sessao atual.
|
||||
$userEmail = Auth::user()->email;
|
||||
$receiveDataEmail = User::where('email', $userEmail)->first();
|
||||
$receiveDataWs = ConstructionWorkstation::where('name_workstations', $receiveDataEmail->user_name)->first();
|
||||
|
||||
|
||||
// Verifica equipamentos que tenho 2 dados com o departure_date = NULL e especificamente um dado tem o elemental_tasks_id = 9 e o outro igual a NULL.
|
||||
//Isto para ser possivel identificar equipamentos (psv-Provavelmente) que esta sendo feitas em simultanio suas pecas e nao deve ser diponivel ate uma de suas pecas tiverem deponivel.
|
||||
$excludedEquipmentsQuery = ControlEquipmentWorkstation::select('equipmentWorkHistorys_id')
|
||||
|
|
@ -34,77 +33,23 @@ public function compose(View $view)
|
|||
->havingRaw('SUM(CASE WHEN elemental_tasks_id IS NULL THEN 1 ELSE 0 END) = 1') // Assegura um registro com elemental_tasks_id NULL
|
||||
->pluck('equipmentWorkHistorys_id'); // Obtém os IDs para exclusão
|
||||
|
||||
|
||||
// // Busca todos os equipamentos associados a um determinado projeto.
|
||||
// $receiveAllEquipmentOfProject = Equipment::where('company_projects_id', $receiveDataWs->company_projects_id)
|
||||
|
||||
// ->WhereHas('equipmentWorkHistory.controlEquipmentWorkstation', function ($subQuery) use ($excludedEquipmentsQuery) {
|
||||
// $subQuery->whereNot('equipmentWorkHistorys_id', $excludedEquipmentsQuery);
|
||||
// })
|
||||
// // Primeiro filtro: Equipamentos sem ocorrência em ControlEquipmentWorkstation
|
||||
// ->whereDoesntHave('equipmentWorkHistory.controlEquipmentWorkstation')
|
||||
|
||||
// // Segundo filtro: Equipamentos que ja tiverem um controlEquipmentWorkstation_ID criado uma dos Ws o fechou sem concluir por um metodo nao convencional e o script do servidor limpou o controlEquipmentWorkstation_ID
|
||||
// ->orWhereHas('equipmentWorkHistory.controlEquipmentWorkstation', function ($subQuery) {
|
||||
// $subQuery->whereNull('id_workstations')
|
||||
// ->whereNull('elemental_tasks_id')
|
||||
// ->whereNull('departure_date')
|
||||
// ->where('status', 0);
|
||||
// })
|
||||
// // Terceiro filtro: Equipamentos com todas as colunas sao prenchidas como deve ser, signifca que e uma tarefa concluida(finalizada) e agora vai criar um novo dado na controlEquipmentWorkstation para a proxima tarefa.
|
||||
// ->orWhereHas('equipmentWorkHistory.controlEquipmentWorkstation', function ($subQuery) {
|
||||
// $subQuery->whereNotNull('id_workstations')
|
||||
// ->where(function ($innerQuery) {
|
||||
// $innerQuery->whereNotNull('elemental_tasks_id')
|
||||
// ->whereNotNull('departure_date')
|
||||
// ->where('status', 1);
|
||||
// });
|
||||
// })
|
||||
|
||||
// // No geral esta condicao verifica que e uma psv, e que tem a possiblidade de ficar diponivel para selecionar o equipamento , mesmo com ele ja dentro de uma Ws.
|
||||
// // Adiciona condição para PSV (equipment_type_id = 3)
|
||||
// ->orWhere(function ($query) {
|
||||
// // Verifica no sistema se for uma 'PSV' , mesmo apos entrar como @Corpo, ou pelo @Obutador deve deixar o outro disponivel.
|
||||
// $query->whereHas('equipmentType', function ($typeQuery) {
|
||||
// $typeQuery->where('equipment_type_id', 3);
|
||||
// })
|
||||
// ->whereHas('equipmentWorkHistory.controlEquipmentWorkstation', function ($subQuery) {
|
||||
// $subQuery->where('status', 1)
|
||||
// ->whereNull('departure_date')
|
||||
// ->where(function ($taskQuery) {
|
||||
// $taskQuery->where('elemental_tasks_id', 9)
|
||||
// ->orWhereNull('elemental_tasks_id');
|
||||
// });
|
||||
// });
|
||||
// })
|
||||
// // Último filtro: Equipamentos cujo equipmentWorkHistorys_id NÃO estão na lista excluída.
|
||||
// ->whereDoesntHave('equipmentWorkHistory.controlEquipmentWorkstation', function ($subQuery) use ($excludedEquipmentsQuery) {
|
||||
// // Aqui é onde verificamos se o equipmentWorkHistorys_id NÃO está contido na lista excluída.
|
||||
// $subQuery->whereIn('equipmentWorkHistorys_id', $excludedEquipmentsQuery);
|
||||
// })
|
||||
// ->get()
|
||||
// ->map(function ($equipment) {
|
||||
// if (!$equipment->equipmentWorkHistory->isEmpty()) {
|
||||
// $equipmentWorkHistory = $equipment->equipmentWorkHistory->first();
|
||||
// $equipment->equipmentWorkHistoryId = $equipmentWorkHistory->equipmentWorkHistorys_id;
|
||||
// } else {
|
||||
// $equipment->equipmentWorkHistoryId = null;
|
||||
// }
|
||||
// return $equipment;
|
||||
// });
|
||||
|
||||
//Onde estava o antigo Code
|
||||
|
||||
// Busca todos os equipamentos associados a um determinado projeto.
|
||||
$receiveAllEquipmentOfProject = Equipment::where('company_projects_id', $receiveDataWs->company_projects_id)
|
||||
// Use whereDoesntHave para excluir os equipamentos cujos IDs de histórico estão no array excluído
|
||||
->where(function ($query) use ($excludedEquipmentsQuery) {
|
||||
|
||||
// Agrupa as condições para aplicar corretamente a lógica de exclusão e inclusão
|
||||
$query->whereDoesntHave('equipmentWorkHistory.controlEquipmentWorkstation', function ($subQuery) use ($excludedEquipmentsQuery) {
|
||||
|
||||
// Exclui os equipamentos cujos IDs de histórico estão no array excluído
|
||||
$subQuery->whereIn('equipmentWorkHistorys_id', $excludedEquipmentsQuery);
|
||||
})
|
||||
->orWhere(function ($query) {
|
||||
|
||||
// Aplica o segundo filtro somente aos equipamentos que não foram excluídos pelo primeiro
|
||||
//Libera novamente o equipamento ao concluir uma tarefa.
|
||||
$query->whereHas('equipmentWorkHistory.controlEquipmentWorkstation', function ($subQuery) {
|
||||
$subQuery->whereNotNull('id_workstations')
|
||||
->whereNotNull('elemental_tasks_id')
|
||||
|
|
@ -154,12 +99,13 @@ public function compose(View $view)
|
|||
// Inicializa um array para armazenar o status de cada equipamento
|
||||
$equipmentStatus = [];
|
||||
|
||||
|
||||
foreach ($receiveAllEquipmentOfProject as $equipment) {
|
||||
|
||||
// Agora 'equipmentWorkHistoryId' contém um único ID, então não usamos 'pluck'
|
||||
$workHistoryId = $equipment->equipmentWorkHistoryId; // Obter ID do histórico de trabalho diretamente
|
||||
|
||||
// Verifica se existe um workHistoryId antes de prosseguir
|
||||
//POREM POR NORMA, TODOS DEVEM TER
|
||||
if (is_null($workHistoryId)) {
|
||||
continue; // Se não houver histórico de trabalho, continua para o próximo equipamento
|
||||
}
|
||||
|
|
@ -210,16 +156,30 @@ public function compose(View $view)
|
|||
->groupBy('elemental_tasks_id')
|
||||
->pluck('total', 'elemental_tasks_id'); // Contagem de tarefas nas estações de trabalho
|
||||
|
||||
// Verificar se todas as tarefas foram concluídas pelo menos uma vez
|
||||
$allTasksCompleted = $taskIds->every(function ($taskId) use ($workstationTaskCounts) {
|
||||
return isset ($workstationTaskCounts[$taskId]) && $workstationTaskCounts[$taskId] >= 1;
|
||||
// Vai verificar diretamente na base de dados , busca todos os dados do equipmentWorkHistorys_id, nesta obra e verificar com base na colecao recebida, se entre todos os seus valores, tem pelo menos um elemental_tasks_id, presente na variavel $taskIds
|
||||
$taskCountsInControlRecords = ControlEquipmentWorkstation::where('equipmentWorkHistorys_id', $workHistoryId)
|
||||
->whereNotNull('departure_date')
|
||||
->whereIn('elemental_tasks_id', $taskIds)
|
||||
->groupBy('elemental_tasks_id')
|
||||
->select('elemental_tasks_id', DB::raw('COUNT(*) as count'))
|
||||
->pluck('count', 'elemental_tasks_id');
|
||||
|
||||
// Verifica se todas as tarefas foram concluídas pelo menos uma vez
|
||||
$allTasksCompleted = $taskIds->every(function ($taskId) use ($taskCountsInControlRecords) {
|
||||
return isset ($taskCountsInControlRecords[$taskId]) && $taskCountsInControlRecords[$taskId] > 0;
|
||||
});
|
||||
|
||||
if ($allTasksCompleted && $workstationTaskCounts->count() >= $taskIds->count()) {
|
||||
$completedEquipments->push($equipment); // Adicionar equipamento à lista de concluídos
|
||||
//$allTasksCompleted vai ter TRUE, apenas quando se verificar todos as tarefas foram feitas no equipamento.
|
||||
if ($allTasksCompleted) {
|
||||
$completedEquipments->push($equipment);
|
||||
|
||||
//Se o equipamento for verificado como concluido, altera o seu status na Obra, para o mesmo ser indicado como um equipamento pendente a aplovacao de Admin.
|
||||
$changeEquipmentStatus = EquipmentWorkHistory::where('equipmentWorkHistorys_id',$equipment->equipmentWorkHistoryId)->first();
|
||||
$changeEquipmentStatus->equipment_status_project = 1;
|
||||
$changeEquipmentStatus->save();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Remover equipamentos concluídos da coleção original
|
||||
$receiveAllEquipmentOfProject = $receiveAllEquipmentOfProject->reject(function ($equipment) use ($completedEquipments) {
|
||||
return $completedEquipments->contains($equipment);
|
||||
|
|
@ -227,12 +187,20 @@ public function compose(View $view)
|
|||
|
||||
$equipmentIds = array_keys($equipmentStatus);
|
||||
|
||||
// dd($equipmentIds);
|
||||
|
||||
// Obtendo os registros QrcodesAssociatedEquipment para esses equipamentos
|
||||
$receiveQrcodeEquipmentsProject = QrcodesAssociatedEquipment::whereIn('equipment_id', $equipmentIds)
|
||||
->get();
|
||||
$receiveQrcodeEquipmentsProject = QrcodesAssociatedEquipment::whereIn('equipment_id', $equipmentIds)->get();
|
||||
|
||||
// Extrai os IDs de equipamentos dos equipamentos completados
|
||||
$completedEquipmentIds = $completedEquipments->pluck('equipment_id')->toArray();
|
||||
|
||||
// Filtra a coleção $receiveQrcodeEquipmentsProject para excluir registros com equipment_id em $completedEquipmentIds
|
||||
$filteredQrcodeEquipments = $receiveQrcodeEquipmentsProject->reject(function ($qrcodeEquipment) use ($completedEquipmentIds) {
|
||||
return in_array($qrcodeEquipment->equipment_id, $completedEquipmentIds);
|
||||
});
|
||||
|
||||
// Se você desejar, pode reatribuir a coleção filtrada de volta à variável original
|
||||
$receiveQrcodeEquipmentsProject = $filteredQrcodeEquipments;
|
||||
|
||||
$filteredQrcodeEquipments = $receiveQrcodeEquipmentsProject->filter(function ($qrcodeEquipment) use ($equipmentStatus) {
|
||||
// Exclui 'Flange'
|
||||
|
|
@ -241,7 +209,6 @@ public function compose(View $view)
|
|||
}
|
||||
|
||||
|
||||
|
||||
// Obtém o status do equipamento atual
|
||||
$equipmentId = $qrcodeEquipment->equipment_id;
|
||||
$status = $equipmentStatus[$equipmentId] ?? null;
|
||||
|
|
|
|||
|
|
@ -34,7 +34,6 @@ public function mount($datasProject)
|
|||
|
||||
$this->lastUpdated = now()->format('Y-m-d H:i');
|
||||
|
||||
|
||||
// chama a funcao e envia a variavel datasProject recebido da view principal
|
||||
$this->refreshDataEquipments($datasProject);
|
||||
}
|
||||
|
|
@ -109,6 +108,7 @@ public function refreshDataEquipments($datasProject)
|
|||
// Conta quantas vezes o equipamento aparece em OrderEquipmentTasks
|
||||
$tasksCount = OrderEquipmentTasks::where('equipmentWorkHistorys_id', $equipment->equipmentWorkHistorys_id)->count();
|
||||
|
||||
|
||||
// ira receber varios dados para o array sendo array[key:equipment_id,valor:quantidade de vezes que o equipment_id se repete na tabela 'OrderEquipmentTasks']
|
||||
$equipmentCounts[$equipment->equipment_id] = $tasksCount;
|
||||
|
||||
|
|
|
|||
|
|
@ -13,6 +13,8 @@ class AmbitsEquipment extends Model
|
|||
// protected $primaryKey = 'ambits_equipment_id';
|
||||
protected $primaryKey = 'ambits_id';
|
||||
|
||||
protected $fillable = ['ambits_id', 'ambits_description', 'equipment_type_id'];
|
||||
|
||||
|
||||
public $timestamps = false;
|
||||
|
||||
|
|
|
|||
|
|
@ -13,4 +13,6 @@ class AssociationCompanyUser extends Model
|
|||
|
||||
public $timestamps = false;
|
||||
|
||||
protected $fillable = ['association_company_user_id', 'company_id', 'user_id'];
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,9 @@ class Company extends Model
|
|||
|
||||
protected $primaryKey = 'company_id';
|
||||
|
||||
protected $fillable = ['company_id', 'company_name', 'company_logo'];
|
||||
|
||||
|
||||
public function plants(){
|
||||
return $this->hasMany(Plant::class,'company_id', 'company_id');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,8 @@ class CompanyProject extends Model
|
|||
|
||||
protected $primaryKey = 'company_projects_id';
|
||||
|
||||
protected $fillable = ['company_projects_id', 'plant_id', 'project_company_number','project_ispt_number','company_project_description','project_ispt_responsible','project_company_responsible','date_started','end_date','order_project'];
|
||||
|
||||
public $timestamps = false;
|
||||
|
||||
public function plant(){
|
||||
|
|
|
|||
|
|
@ -20,6 +20,10 @@ class Equipment extends Model
|
|||
|
||||
protected $primaryKey = 'equipment_id';
|
||||
|
||||
protected $fillable = ['unit_id', 'equipment_type_id', 'equipment_tag', 'equipment_description', 'company_projects_id'];
|
||||
|
||||
|
||||
|
||||
|
||||
public function unit()
|
||||
{
|
||||
|
|
|
|||
33
app/Models/EquipmentComment.php
Normal file
33
app/Models/EquipmentComment.php
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class EquipmentComment extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = 'equipment_comments';
|
||||
protected $primaryKey = 'equipment_comment_id';
|
||||
protected $fillable = ['equipmentWorkHistorys_id', 'user_id', 'company_projects_id', 'creation_date', 'comment'];
|
||||
|
||||
public $timestamps = false;
|
||||
|
||||
// Relacoes *(Muitos) para 1
|
||||
public function equipmentWorkHistory()
|
||||
{
|
||||
return $this->belongsTo(EquipmentWorkHistory::class, 'equipmentWorkHistorys_id');
|
||||
}
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'user_id');
|
||||
}
|
||||
|
||||
public function companyProject()
|
||||
{
|
||||
return $this->belongsTo(CompanyProject::class, 'company_projects_id');
|
||||
}
|
||||
}
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class EquipmentComments extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
public $timestamps = false;
|
||||
|
||||
protected $table = 'equipment_comments';
|
||||
|
||||
protected $primaryKey = 'equipment_comment_id';
|
||||
|
||||
|
||||
public function equipment()
|
||||
{
|
||||
return $this->belongsTo(Equipment::class, 'equipment_id', 'equipment_id');
|
||||
}
|
||||
}
|
||||
|
|
@ -15,6 +15,9 @@ class EquipmentWorkHistory extends Model
|
|||
|
||||
protected $primaryKey = 'equipmentWorkHistorys_id';
|
||||
|
||||
protected $fillable = ['equipmentWorkHistorys_id', 'equipment_id', 'ispt_number','company_projects_id','equipment_status_project'];
|
||||
|
||||
|
||||
public function equipment()
|
||||
{
|
||||
return $this->belongsTo(Equipment::class, 'equipment_id', 'equipment_id');
|
||||
|
|
|
|||
|
|
@ -24,19 +24,6 @@
|
|||
<div class="container-fluid">
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-md-12">
|
||||
{{-- <form>
|
||||
<div class="row">
|
||||
<div class="col-sm-6" id="buttonCreateAssets">
|
||||
<a href="#" type="button"
|
||||
class="btn btn-block bg-primary btn-lg">{{ __('messages.portfolio.change_buttons.create_assets') }}</a>
|
||||
</div>
|
||||
<div class="col-sm-6" id="buttonAssetsTable">
|
||||
<a href="#" type="button"
|
||||
class="btn btn-block bg-primary btn-lg">{{ __('messages.portfolio.change_buttons.asset_table') }}</a>
|
||||
</div>
|
||||
</div>
|
||||
</form> --}}
|
||||
|
||||
|
||||
<div class="card card-primary" id="cardAssetsTable">
|
||||
|
||||
|
|
@ -115,6 +102,7 @@ class="form-control">
|
|||
@endsection
|
||||
|
||||
@section('scriptsTemplateAdmin')
|
||||
|
||||
<script type="text/javascript">
|
||||
var dataTables;
|
||||
$(document).ready(function() {
|
||||
|
|
|
|||
|
|
@ -192,7 +192,7 @@ class="info-box-number">{{ $CompanyProject->where('order_project', 4)->count() }
|
|||
<h5 class="progress-description">{{ $project->company_project_description }}
|
||||
</h5>
|
||||
<div class="card-tools">
|
||||
<a href="{{ route('ExecutionProject', ['ProjectId' => $project->company_projects_id]) }}"
|
||||
<a href="{{ route('showDataDetailsProjectClient', ['projectID' => $project->company_projects_id]) }}"
|
||||
class="btn btn-tool">
|
||||
<i class="fa-solid fa-eye" style="color:rgb(62, 62, 62)"></i>
|
||||
</a>
|
||||
|
|
@ -203,7 +203,7 @@ class="btn btn-tool">
|
|||
@endforeach
|
||||
</div>
|
||||
<div class="card-footer">
|
||||
<a href="{{ route('viewProjectsList', ['orderProjectID' => '4']) }}"
|
||||
<a href="{{ route('showAllClientsForProjectReports') }}"
|
||||
class="btn btn-outline-secondary float-right">Ver Lista</a>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -70,12 +70,14 @@
|
|||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<!-- Right navbar links -->
|
||||
<ul class="navbar-nav ml-auto">
|
||||
<li class="nav-item d-none d-sm-inline-block">
|
||||
<!--<div class="nav-link">{{ Auth::user()->user_name }}</div>-->
|
||||
<div class="nav-link" style="color:#1f2d3d">{{ $receiveDataWs->nomenclature_workstation }}</div>
|
||||
</li>
|
||||
|
||||
<!-- User Dropdown Menu -->
|
||||
<li class="nav-item dropdown">
|
||||
<a class="nav-link" data-toggle="dropdown" href="#">
|
||||
|
|
@ -85,15 +87,18 @@
|
|||
<div class="dropdown-menu dropdown-menu-right">
|
||||
<form id="logout-form" action="{{ route('logout') }}" method="POST">
|
||||
@csrf
|
||||
|
||||
@method('POST')
|
||||
<a class="dropdown-item" href="{{ route('logout') }}"
|
||||
onclick="event.preventDefault(); document.getElementById('logout-form').submit();">
|
||||
<i class="fas fa-sign-out-alt text-danger"></i>
|
||||
<span>Terminar sessão</span>
|
||||
</a>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
<!-- Control sidebar -->
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" data-widget="control-sidebar" data-controlsidebar-slide="true" href="#"
|
||||
|
|
@ -101,7 +106,9 @@
|
|||
<i class="fas fa-bars"></i>
|
||||
</a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
</nav>
|
||||
<!-- /.navbar -->
|
||||
|
||||
|
|
|
|||
|
|
@ -1150,20 +1150,7 @@ class="input-group-text border rounded-left"
|
|||
<i class="fa-solid fa-download" style="color: #09255C;"></i>
|
||||
</a>
|
||||
</div>
|
||||
{{-- <div class="col-10 col-md col-lg">
|
||||
<div class="input-group">
|
||||
<span class="input-group-text border rounded-left"
|
||||
style="background-color: #ffffff;" data-toggle="tooltip"
|
||||
title="Seleciona a Funcao do Template">
|
||||
<i class="fa-solid fa-list-check" style="color: #09255C;"></i>
|
||||
</span>
|
||||
<select class="form-control" style="border: 1px solid #09255C;"
|
||||
name="chooseIfSelectOrCreateEquipments">
|
||||
<option value="selectEquipments">Selecionar</option>
|
||||
<option value="createEquipments" selected>Criar Novos</option>
|
||||
</select>
|
||||
</div>
|
||||
</div> --}}
|
||||
|
||||
<div class="col-9 col-md col-lg">
|
||||
<div class="input-group">
|
||||
<span class="input-group-text border rounded-left"
|
||||
|
|
@ -2469,4 +2456,5 @@ function(task) {
|
|||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
@endsection
|
||||
|
|
|
|||
|
|
@ -23,6 +23,22 @@
|
|||
</section>
|
||||
<!-- /.content-header -->
|
||||
|
||||
@if (session('success'))
|
||||
<div class="content">
|
||||
|
||||
<div class="alert alert-success" role="alert" id="alert-message-success" style="transition: opacity 1s;">
|
||||
{{ session('success') }}
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
setTimeout(function() {
|
||||
$('#alert-message-success').fadeOut('slow', function() {
|
||||
$(this).remove();
|
||||
});
|
||||
}, 5000); // A mensagem desaparecerá após 5 segundos
|
||||
</script>
|
||||
@endif
|
||||
|
||||
<!-- Main content -->
|
||||
<section class="content">
|
||||
<div class="container-fluid">
|
||||
|
|
@ -90,13 +106,15 @@
|
|||
|
||||
<div class="row m-3 justify-content-between">
|
||||
<div>
|
||||
<button class="btn btn-info" data-toggle="modal" data-target="#exampleModal">Adicionar equipamentos a Obra</button>
|
||||
<button class="btn btn-info" data-toggle="modal" data-target="#exampleModal">Adicionar
|
||||
equipamentos a Obra</button>
|
||||
</div>
|
||||
<div>
|
||||
<a href="{{ route('showQrcodesInProject',['projectNumber' => $DatasProject->company_projects_id])}}" class="btn btn-danger" >Imprimir Qrcodes</a>
|
||||
<a href="{{ route('showQrcodesInProject', ['projectNumber' => $DatasProject->company_projects_id]) }}"
|
||||
class="btn btn-danger">Imprimir Qrcodes</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<!-- Modal -->
|
||||
<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog"
|
||||
|
|
@ -121,14 +139,15 @@
|
|||
action="{{ route('changeFromExecutionToPlanning', ['projectID' => $DatasProject->company_projects_id]) }}"
|
||||
method="post">
|
||||
@csrf
|
||||
<button type="submit" class="btn btn-primary">Alterar para
|
||||
Planeamento</button>
|
||||
<button type="submit" class="btn btn-primary">
|
||||
Alterar para Planeamento
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- ./Modal -->
|
||||
|
||||
|
||||
</div>
|
||||
|
|
@ -145,6 +164,61 @@
|
|||
|
||||
<div class="card-body">
|
||||
@livewire('execução.equipments-dashboard', ['datasProject' => $DatasProject], key($DatasProject->company_projects_id))
|
||||
|
||||
<div class="card card-info mt-4">
|
||||
|
||||
<div class="card-header">
|
||||
<h3 class="card-title">Lista de equipamentos da Obra</h3>
|
||||
</div>
|
||||
<!-- /.card-header -->
|
||||
|
||||
<div class="card-body">
|
||||
|
||||
<table id="TableListEquipmentInProject" class="table table-bordered table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Tag</th>
|
||||
<th>Descrição</th>
|
||||
<th>Tipo Equipamento</th>
|
||||
<th>Fabrica</th>
|
||||
<th>Âmbito</th>
|
||||
<th>Ação</th>
|
||||
</tr>
|
||||
</thead>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<!-- ./card card-info -->
|
||||
|
||||
|
||||
<div class="card card-info mt-4">
|
||||
|
||||
<div class="card-header ">
|
||||
<h3 class="card-title">Concluidos, por Aprovar</h3>
|
||||
</div>
|
||||
<!-- /.card-header -->
|
||||
|
||||
<div class="card-body">
|
||||
|
||||
<table id="TableListEquipmentInProjectPendingsForApprove"
|
||||
class="table table-bordered table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Tag</th>
|
||||
<th>Descrição</th>
|
||||
<th>Tipo Equipamento</th>
|
||||
<th>Fabrica</th>
|
||||
<th>Âmbito</th>
|
||||
<th>Ação</th>
|
||||
</tr>
|
||||
</thead>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<!-- ./card card-info -->
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
@ -169,7 +243,7 @@
|
|||
|
||||
@foreach ($filteredUsers as $user)
|
||||
<tr>
|
||||
<td>{{ $user->nomenclature_workstation}}</td>
|
||||
<td>{{ $user->nomenclature_workstation }}</td>
|
||||
<td>{{ $user->email }}</td>
|
||||
<td>{{ $user->realPassword }}</td>
|
||||
</tr>
|
||||
|
|
@ -230,6 +304,169 @@
|
|||
@endsection
|
||||
|
||||
@section('scriptsTemplateAdmin')
|
||||
{{-- Antigocode para funcioanr o yajra, porem apenas para uma tabela, quando concluir osyajrada pagina,pode apagar. --}}
|
||||
{{-- <script type="text/javascript">
|
||||
var dataTables;
|
||||
$(document).ready(function() {
|
||||
|
||||
dataTables = $('#TableListEquipmentInProject', '#TableListEquipmentInProjectPendingsForApprove')
|
||||
.DataTable({
|
||||
responsive: true,
|
||||
processing: true,
|
||||
serverSide: true,
|
||||
ajax: {
|
||||
url: '{{ route('receiveDetailsEquipmentsProject') }}',
|
||||
type: 'GET',
|
||||
data: function(d) {
|
||||
d.receiveNumberProject = $('#receiveNumberProject').val();
|
||||
// Envia as variaveis de acordo com as opcoes selecionadas para o DataTables
|
||||
d.equipmentTypeSelected = $('#tipo_valvulasList').val();
|
||||
d.unitSelected = $('#unitsList').val();
|
||||
d.receiveAllUnits = $('#receiveUnitsClientRelated').val();
|
||||
}
|
||||
},
|
||||
columns: [{
|
||||
data: 'equipment_tag',
|
||||
name: 'equipment_tag'
|
||||
},
|
||||
{
|
||||
data: 'equipment_description',
|
||||
name: 'equipment_description'
|
||||
},
|
||||
// {
|
||||
// data: 'equipment_type_name',
|
||||
// name: 'equipment_type_name'
|
||||
// },
|
||||
// {
|
||||
// data: 'unit_name',
|
||||
// name: 'unit_name'
|
||||
// },
|
||||
// {
|
||||
// data: 'ambit_name',
|
||||
// name: 'ambit_name'
|
||||
// },
|
||||
|
||||
// {
|
||||
// data: 'action',
|
||||
// name: 'action',
|
||||
// orderable: false,
|
||||
// searchable: false
|
||||
// },
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
//De acordo com os valores deste campos, como anteriormente ja sao enviados para a DataTables para fazer as filtragens, agora atualizamos a Tabela com base no filtros feitos
|
||||
// $('#tipo_valvulasList,#unitsList,#receiveUnitsClientRelated').on('change',
|
||||
// function() {
|
||||
// dataTables.ajax.reload();
|
||||
// });
|
||||
</script> --}}
|
||||
|
||||
{{-- <script type="text/javascript">
|
||||
// Inicialize as tabelas deequipamentos
|
||||
$(document).ready(function() {
|
||||
setupDataTable('#TableListEquipmentInProject', 'normal');
|
||||
setupDataTable('#TableListEquipmentInProjectPendingsForApprove', 'pending');
|
||||
});
|
||||
|
||||
function setupDataTable(tableSelector) {
|
||||
$(tableSelector).DataTable({
|
||||
responsive: true,
|
||||
processing: true,
|
||||
serverSide: true,
|
||||
ajax: {
|
||||
url: '{{ route('receiveDetailsEquipmentsProject') }}',
|
||||
type: 'GET',
|
||||
data: function(d) {
|
||||
d.receiveNumberProject = $('#receiveNumberProject').val();
|
||||
}
|
||||
},
|
||||
columns: [{
|
||||
data: 'equipment_tag',
|
||||
name: 'equipment_tag'
|
||||
},
|
||||
{
|
||||
data: 'equipment_description',
|
||||
name: 'equipment_description'
|
||||
},
|
||||
{
|
||||
data: 'equipment_type_name',
|
||||
name: 'equipment_type_name'
|
||||
},
|
||||
{
|
||||
data: 'unit_name',
|
||||
name: 'unit_name'
|
||||
},
|
||||
{
|
||||
data: 'ambit_name',
|
||||
name: 'ambit_name'
|
||||
},
|
||||
]
|
||||
});
|
||||
}
|
||||
</script> --}}
|
||||
|
||||
<script type="text/javascript">
|
||||
// Inicialize as tabelas deequipamentos
|
||||
function setupDataTable(tableSelector, tableType) { // Adiciona tableType como um parâmetro
|
||||
$(tableSelector).DataTable({
|
||||
responsive: true,
|
||||
processing: true,
|
||||
serverSide: true,
|
||||
ajax: {
|
||||
url: '{{ route('receiveDetailsEquipmentsProject') }}',
|
||||
type: 'GET',
|
||||
data: function(d) {
|
||||
d.receiveNumberProject = $('#receiveNumberProject').val();
|
||||
d.tableType = tableType; // Agora está definido corretamente
|
||||
}
|
||||
},
|
||||
columns: [{
|
||||
data: 'equipment_tag',
|
||||
name: 'equipment_tag'
|
||||
},
|
||||
{
|
||||
data: 'equipment_description',
|
||||
name: 'equipment_description'
|
||||
},
|
||||
{
|
||||
data: 'equipment_type_name',
|
||||
name: 'equipment_type_name'
|
||||
},
|
||||
{
|
||||
data: 'unit_name',
|
||||
name: 'unit_name'
|
||||
},
|
||||
{
|
||||
data: 'ambit_name',
|
||||
name: 'ambit_name'
|
||||
},
|
||||
{
|
||||
data: 'action',
|
||||
name: 'action'
|
||||
},
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
// Inicialização das DataTables para cada tabela especificada
|
||||
$(document).ready(function() {
|
||||
setupDataTable('#TableListEquipmentInProject', 'normal');
|
||||
setupDataTable('#TableListEquipmentInProjectPendingsForApprove', 'pending');
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
// Ja vai ser inicializado no card Equipamentos.
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -9,8 +9,10 @@
|
|||
</div>
|
||||
<div class="col-sm-6">
|
||||
<ol class="breadcrumb float-sm-right">
|
||||
<li class="breadcrumb-item active"><a href="{{ route('reportingDataClient') }}">Obras Concluidas</a></li>
|
||||
<li class="breadcrumb-item active"> Relatorios Gerais</li>
|
||||
<li class="breadcrumb-item active"><a
|
||||
href="{{ route('reportingDataClient', ['clientID' => $receiveDetailsCompany->company_id]) }}">Obras
|
||||
Concluidas</a></li>
|
||||
<li class="breadcrumb-item active"> Relatorios Gerais</li>
|
||||
</ol>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -100,7 +102,7 @@
|
|||
</select>
|
||||
</div>
|
||||
</div>
|
||||
{{-- @dd($receiveAllTypeEquipments) --}}
|
||||
|
||||
<div class="col-sm">
|
||||
<div class="form-group">
|
||||
<label>Tipo de equipamento</label>
|
||||
|
|
@ -121,8 +123,8 @@
|
|||
<table id="showEquipmentsOfProject" class="table table-bordered table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Tag</th>
|
||||
<th>Fabrica</th>
|
||||
<th>Tag Number</th>
|
||||
<th>Tipo de Equipamento</th>
|
||||
<th>Ambito</th>
|
||||
<th>Visualizar</th>
|
||||
|
|
@ -153,7 +155,7 @@
|
|||
$(document).ready(function() {
|
||||
|
||||
|
||||
|
||||
|
||||
$('.clickable').on('click', function(e) {
|
||||
// Verifica se o clique não foi no botão
|
||||
if (!$(e.target).is('.collapse-button') && !$(e.target).is('.collapse-button *')) {
|
||||
|
|
@ -162,12 +164,11 @@
|
|||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
var dataTables;
|
||||
$(document).ready(function() {
|
||||
|
||||
|
||||
dataTables = $('#showReportingForAmbits').DataTable({
|
||||
responsive: true,
|
||||
processing: true,
|
||||
|
|
@ -182,11 +183,11 @@
|
|||
d.projectId = $('#projectId').val();
|
||||
}
|
||||
},
|
||||
columns: [{
|
||||
columns: [
|
||||
{
|
||||
data: 'ambits_description',
|
||||
name: 'ambits_description'
|
||||
},
|
||||
|
||||
{
|
||||
data: 'amountEquipment',
|
||||
name: 'amountEquipment'
|
||||
|
|
@ -202,8 +203,6 @@
|
|||
});
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
var dataTables;
|
||||
$(document).ready(function() {
|
||||
|
|
@ -227,20 +226,20 @@
|
|||
}
|
||||
},
|
||||
columns: [{
|
||||
data: 'unit_id',
|
||||
name: 'unit_id'
|
||||
},
|
||||
{
|
||||
data: 'equipment_tag',
|
||||
name: 'equipment_tag'
|
||||
},
|
||||
{
|
||||
data: 'equipment_type_id',
|
||||
name: 'equipment_type_id'
|
||||
data: 'unit_name',
|
||||
name: 'unit_name'
|
||||
},
|
||||
{
|
||||
data: 'ambits_description',
|
||||
name: 'ambits_description'
|
||||
data: 'equipment_type_name',
|
||||
name: 'equipment_type_name'
|
||||
},
|
||||
{
|
||||
data: 'ambit_name',
|
||||
name: 'ambit_name'
|
||||
},
|
||||
{
|
||||
data: 'action',
|
||||
|
|
|
|||
|
|
@ -34,7 +34,6 @@
|
|||
<h3 class="card-title ">{{ $dataAmbit->ambits_description }}</h3>
|
||||
</div>
|
||||
<div class="col-sm text-right">
|
||||
{{-- <a href="{{route('showReportingForAmbitsProjectPdf')}}><i class="fa-solid fa-file-pdf fa-2x"></i></a> --}}
|
||||
<a
|
||||
href="{{ route('showReportingForAmbitsProjectPdf', ['ambitId' => $ambitId, 'projectId' => $projectId]) }}"><i
|
||||
class="fa-solid fa-file-pdf fa-2x"></i></a>
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@
|
|||
Route::get('showAllClientsForProjectReports', [ProjectoDatacontroller::class, 'showAllClientsForProjectReports'])->name('showAllClientsForProjectReports');
|
||||
|
||||
Route::get('showAllClientsForProjectReportsTable', [ProjectoDatacontroller::class, 'showAllClientsForProjectReportsTable'])->name('showAllClientsForProjectReportsTable');
|
||||
|
||||
Route::post('changeEquipmentStatusOnProject',[ProjectoDatacontroller::class,'changeEquipmentStatusOnProject'])->name('changeEquipmentStatusOnProject');
|
||||
|
||||
|
||||
Route::get('cancelElementalTaskForEquipment/{controlEquipmentID}', [WorkstationsJobsController::class, 'cancelElementalTaskForEquipment'])->name('cancelElementalTaskForEquipment');
|
||||
|
|
@ -75,7 +75,7 @@
|
|||
Route::get('articulated_2/{projectID}/{equipmentID}', [ProjectoDatacontroller::class, 'projectDetails_11'])->name('projectDetails_11');
|
||||
Route::get('manageAssets/{equipmentID}', [ProjectoDatacontroller::class, 'articulated_22'])->name('articulated_22');
|
||||
|
||||
Route::get('showAmbitDetailsProjectHistory/{projectID}/{equipmentID}', [ProjectoDatacontroller::class, 'showAmbitDetailsProjectHistory'])->name('showAmbitDetailsProjectHistory');
|
||||
Route::get('showAmbitDetailsProjectHistory/{equipmentStatus}/{projectID}/{equipmentID}', [ProjectoDatacontroller::class, 'showAmbitDetailsProjectHistory'])->name('showAmbitDetailsProjectHistory');
|
||||
|
||||
|
||||
Route::get('getDataEquipment', [ExecutionProjectController::class, 'getDataEquipment'])->name('getDataEquipment');
|
||||
|
|
@ -333,6 +333,7 @@
|
|||
Route::post('/api/updateSessionStatus/{controlEquipmentId}', [WorkstationsJobsController::class, 'updateSessionStatus']);
|
||||
Route::post('/api/closeSession/{controlEquipmentId}', [WorkstationsJobsController::class, 'closeSession']);
|
||||
|
||||
Route::get('/api/receiveDetailsEquipmentsProject/', [ExecutionProjectController::class,'receiveDetailsEquipmentsProject'])->name('receiveDetailsEquipmentsProject');
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user