Updates to the creation of projects, visual improvements to the list of pending tasks and structure updates to the selection of tasks in workstations
This commit is contained in:
parent
d26bdacd70
commit
20d9ef2266
2
.env
2
.env
|
|
@ -18,7 +18,7 @@ DB_PORT=3306
|
|||
|
||||
# Alteracoes para funcionar com o servidor, porem não funciona na firma
|
||||
DB_HOST=ispt-innovation.com
|
||||
DB_DATABASE=ispt40_version01
|
||||
DB_DATABASE=ispt40_version01_BK
|
||||
DB_USERNAME=ispt40
|
||||
DB_PASSWORD=qu3ro3ntr@r
|
||||
|
||||
|
|
|
|||
|
|
@ -12,10 +12,10 @@ class Kernel extends ConsoleKernel
|
|||
*/
|
||||
protected function schedule(Schedule $schedule): void
|
||||
{
|
||||
//Para atualizar a fObra para execussao quando chegar na hora estipulada.
|
||||
//Para atualizar a Obra para execussao quando chegar na hora estipulada.
|
||||
$schedule->call(function () {
|
||||
\App\Models\CompanyProject::where('order_project', 2)
|
||||
->where('date_started', '<=', now())
|
||||
->where('date_started', '>=', now())
|
||||
->update(['order_project' => 3]);
|
||||
})->everyMinute(); // Ou ajuste para a frequência desejada
|
||||
|
||||
|
|
|
|||
|
|
@ -327,7 +327,7 @@ public function getDataProjectsClient(Request $request)
|
|||
$query = CompanyProject::with('plant') // Assegure-se de que a relação está correta.
|
||||
->whereIn('plant_id', $allPlantsClient)
|
||||
->whereNotNull('end_date')
|
||||
->select(['company_projects_id', 'plant_id', 'project_company_number', 'company_project_description', 'project_company_responsible', 'date_started', 'end_date']);
|
||||
->select(['company_projects_id', 'plant_id', 'project_company_name', 'company_project_description', 'project_company_responsible', 'date_started', 'end_date']);
|
||||
|
||||
$dataProjectsClient = $query->get();
|
||||
|
||||
|
|
|
|||
|
|
@ -108,7 +108,6 @@ public function changeAmbitEquipment(Request $request)
|
|||
$JoinsEquipmentsWithTasks->equipmentWorkHistorys_id = $receiveEquipmentWorkHistorys->equipmentWorkHistorys_id;
|
||||
$JoinsEquipmentsWithTasks->execution_order = $execution_order++;
|
||||
$JoinsEquipmentsWithTasks->elemental_tasks_id = $TasksAssociationAmbit->elemental_tasks_id;
|
||||
$JoinsEquipmentsWithTasks->further_tasks_id = null;
|
||||
$JoinsEquipmentsWithTasks->inspection = 2; // ou outro valor conforme necessário
|
||||
$JoinsEquipmentsWithTasks->save();
|
||||
}
|
||||
|
|
@ -194,7 +193,7 @@ public function deleteFurtherTasks(Request $request)
|
|||
|
||||
$receiveDataEquipment = Equipment::where('equipment_id', $request->equipmentID)->first();
|
||||
// Buscar os registros que correspondem ao equipmentID e que têm further_tasks_id nos selectedTasks
|
||||
|
||||
//Nao deve ter mais further_tasks_id, pois agora as further tasks devem ficar nas tarefas elementares
|
||||
$detailsEquipmentWorkHistory = EquipmentWorkHistory::where('equipment_id', $request->equipmentID)->first();
|
||||
|
||||
$tasksToDelete = OrderEquipmentTasks::where('equipmentWorkHistorys_id', $detailsEquipmentWorkHistory->equipmentWorkHistorys_id)
|
||||
|
|
@ -308,70 +307,6 @@ public function addFurtherTasks(Request $request)
|
|||
return redirect()->back()->with('success', 'Ordem de execução do equipamento: ' . $receiveDataEquipment->equipment_tag . ' Atulizada!');
|
||||
}
|
||||
|
||||
|
||||
// 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;
|
||||
|
|
@ -430,7 +365,7 @@ public function receiveEquipmentToAssociateTasks(Request $request)
|
|||
$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;
|
||||
// $JoinsEquipmentsWithTasks->further_tasks_id = null;
|
||||
$JoinsEquipmentsWithTasks->inspection = 2;
|
||||
$JoinsEquipmentsWithTasks->save();
|
||||
}
|
||||
|
|
@ -754,10 +689,10 @@ public function createWorkStations(Request $request)
|
|||
//Apos criar a Workstation vamos criar um login para pode aceder os postos de trabalho na obra
|
||||
$loginWorkStation = new User;
|
||||
$loginWorkStation->user_name = $workstation->name_workstations;
|
||||
$loginWorkStation->email = $receveProjectCompanyNumber->project_company_number . '-' . $receiveNumberWorkstation . '@isptgroup.com';
|
||||
$loginWorkStation->password = bcrypt($receveProjectCompanyNumber->project_company_number . '-' . $receiveNumberWorkstation);
|
||||
$loginWorkStation->email = $receveProjectCompanyNumber->project_company_name . '-' . $receiveNumberWorkstation . '@isptgroup.com';
|
||||
$loginWorkStation->password = bcrypt($receveProjectCompanyNumber->project_company_name . '-' . $receiveNumberWorkstation);
|
||||
$loginWorkStation->type_users = 5;
|
||||
$loginWorkStation->user_nif = $receveProjectCompanyNumber->project_company_number . '-' . $receiveNumberWorkstation;
|
||||
$loginWorkStation->user_nif = $receveProjectCompanyNumber->project_company_name . '-' . $receiveNumberWorkstation;
|
||||
$loginWorkStation->save();
|
||||
}
|
||||
|
||||
|
|
@ -793,25 +728,56 @@ public function showStep1($company_projects_id)
|
|||
$projects->plantName = $receiveDetailsPlant->plant_name;
|
||||
$projects->userName = $receiveDetailsCompany->company_name;
|
||||
|
||||
$receiveCompanyManager = '';
|
||||
$receiveCompanyManagerID = null; // Inicialize com null ou um valor padrão apropriado
|
||||
|
||||
// Se o project_company_responsible for igual a null, significa que ainda não foi definido após a criação da Obra.
|
||||
// Se foi definido, deve buscar o nome do User atribuído.
|
||||
if ($projects->project_company_responsible === null) {
|
||||
$receiveCompanyManager = 'Gestor da empresa ainda não atribuído...';
|
||||
} else {
|
||||
$NameCompanyManager = User::where('user_id', $projects->project_company_responsible)->first();
|
||||
// Verifica se um usuário foi encontrado antes de tentar acessar a propriedade user_name.
|
||||
if ($NameCompanyManager) {
|
||||
$receiveCompanyManager = $NameCompanyManager->user_name;
|
||||
$receiveCompanyManagerID = $NameCompanyManager->user_id;
|
||||
} else {
|
||||
$receiveCompanyManager = 'Usuário não encontrado'; // Mensagem caso o ID não corresponda a nenhum usuário.
|
||||
$receiveCompanyManagerID = null; // Assegure-se que há um valor definido mesmo em caso de falha
|
||||
}
|
||||
}
|
||||
$projects->NameCompanyManager = $receiveCompanyManager;
|
||||
$projects->NameCompanyManagerID = $receiveCompanyManagerID;
|
||||
|
||||
|
||||
//deve receber os User disponiveis da Empresa atual da Obra.
|
||||
$receiveAllCompanyManager = AssociationCompanyUser::where('company_id', $projects->plant->company_id)->get();
|
||||
|
||||
return view('projectsClients/projectDetails_1', ['step' => 1], ['companies' => $companies])
|
||||
->with('projects', $projects);
|
||||
->with('projects', $projects)
|
||||
->with('receiveAllCompanyManager', $receiveAllCompanyManager);
|
||||
}
|
||||
|
||||
// Se forem alterados dados dos Detalhes da Obra, vai ser alterado
|
||||
public function EditprocessStep1(Request $request)
|
||||
{
|
||||
// Validação...
|
||||
|
||||
$project = CompanyProject::where('company_projects_id', $request->projectId)->first();
|
||||
|
||||
$project->company_project_description = $request->input('description_project');
|
||||
$project->project_company_number = $request->input('project_company_number');
|
||||
$project->project_company_responsible = $request->input('responsible_project_company');
|
||||
$project->project_company_name = $request->input('project_company_name');
|
||||
$project->project_ispt_number = $request->input('n_project_ispt');
|
||||
$project->project_ispt_responsible = $request->input('responsible_project_ispt');
|
||||
|
||||
//Verifica se exsite uma nova data, se existe atualiza o projecto com a nova, se nao existir usa a antiga
|
||||
if ($request->date_started <> null) {
|
||||
// Correção aqui: A verificação de 'undefined' deve ser feita corretamente
|
||||
if ($request->input('responsible_project_company') === 'undefined') {
|
||||
$project->project_company_responsible = null;
|
||||
} else {
|
||||
$project->project_company_responsible = $request->input('responsible_project_company');
|
||||
}
|
||||
|
||||
// Verifica se existe uma nova data, se existe atualiza o projeto com a nova, se não existir usa a antiga
|
||||
if ($request->input('date_started') !== null) {
|
||||
$project->date_started = $request->input('date_started');
|
||||
} else {
|
||||
$project->date_started = $request->input('date_started_present');
|
||||
|
|
@ -840,75 +806,6 @@ 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);
|
||||
|
|
@ -981,7 +878,6 @@ public function processStep1(Request $request)
|
|||
|
||||
$installationId = $request->input('installation_id');
|
||||
|
||||
|
||||
//Para criar uma nova instalacao
|
||||
if ($installationId <> null && $installationId == 'new_install') {
|
||||
|
||||
|
|
@ -1009,15 +905,22 @@ public function processStep1(Request $request)
|
|||
|
||||
}
|
||||
}
|
||||
|
||||
$receiveDetailsPlant = Plant::where('plant_id', $installationId)->first();
|
||||
|
||||
//Code apenas para criacao de Obra sem criar instlacao ou empresa
|
||||
$project = new CompanyProject;
|
||||
$project->company_project_description = $request->input('description_project');
|
||||
$project->project_ispt_number = $request->input('n_project_ispt');
|
||||
$project->project_company_number = $request->input('project_company_number');
|
||||
$project->project_company_name = $request->input('project_company_name');
|
||||
$project->project_ispt_responsible = $request->input('responsible_project_ispt');
|
||||
$project->project_company_responsible = $request->input('responsible_project_company');
|
||||
|
||||
if ($request->input('user_id') == 'ispt') {
|
||||
$project->project_company_responsible = null;
|
||||
} else {
|
||||
$project->project_company_responsible = $request->input('user_id');
|
||||
}
|
||||
|
||||
$project->plant_id = $receiveDetailsPlant->plant_id;
|
||||
$project->order_project = 1;
|
||||
$project->date_started = $request->input('date_started');
|
||||
|
|
@ -1189,7 +1092,7 @@ public function createEquipmentManual(Request $request)
|
|||
$isptNumber = 1;
|
||||
}
|
||||
|
||||
|
||||
$newEquipmentWorkHistorys->equipment_status_project = 0;
|
||||
$newEquipmentWorkHistorys->equipment_id = $equipmentID;
|
||||
$newEquipmentWorkHistorys->ispt_number = $isptNumber;
|
||||
$newEquipmentWorkHistorys->company_projects_id = $request->numberProject;
|
||||
|
|
@ -1243,7 +1146,7 @@ public function createEquipmentManual(Request $request)
|
|||
$JoinsEquipmentsWithTasks->equipmentWorkHistorys_id = $equipmentWorkHistorysID;
|
||||
$JoinsEquipmentsWithTasks->execution_order = $execution_order++;
|
||||
$JoinsEquipmentsWithTasks->elemental_tasks_id = $TasksAssociationAmbit->elemental_tasks_id;
|
||||
$JoinsEquipmentsWithTasks->further_tasks_id = null;
|
||||
// $JoinsEquipmentsWithTasks->further_tasks_id = null;
|
||||
$JoinsEquipmentsWithTasks->inspection = 2;
|
||||
$JoinsEquipmentsWithTasks->save();
|
||||
}
|
||||
|
|
@ -1305,6 +1208,7 @@ public function processStep2(Request $request)
|
|||
$documentType = $parts[2]; // 98
|
||||
$timestamp = $parts[3]; // 2024-01-14_14-33
|
||||
|
||||
|
||||
function normalize($value)
|
||||
{
|
||||
// Remove espaços em branco no início e no fim da string
|
||||
|
|
@ -1410,11 +1314,20 @@ function normalize($value)
|
|||
$uniqueRowsHashmap[$key] = $i;
|
||||
} else {
|
||||
$duplicateLines[] = $i; // Linha duplicada no Excel
|
||||
|
||||
//Guardar os informacoes para o logs geral da pagina de articulado
|
||||
$equipmentPendingLogs[] = [
|
||||
'excel_Name' => $originalFileName,
|
||||
'typePendingLog' => 1,
|
||||
'duplicate_line' => $i + 1,
|
||||
'original_line' => $uniqueRowsHashmap[$key] + 1,
|
||||
'reason' => 'Duplicata no Excel referente aos campos: ' . $columnRealNames[0] . ' e ' . $columnRealNames[1] . '.'
|
||||
'reason' => 'Duplicata no Excel - (Original Line '. $uniqueRowsHashmap[$key] + 1 .') referente aos campos: ' . $columnRealNames[0] . ' e ' . $columnRealNames[1] . '.'
|
||||
];
|
||||
|
||||
//este e criado apenas para o PendingEquipment a indicar a reason de sua criacao.
|
||||
$pending_equipment_creation_log = [
|
||||
'excel_Name' => $originalFileName,
|
||||
'reason' => 'Duplicata no Excel - (Original Line '. $uniqueRowsHashmap[$key] + 1 .') referente aos campos: ' . $columnRealNames[0] . ' e ' . $columnRealNames[1] . '.(Duplicate Line ' .$i + 1 .')'
|
||||
];
|
||||
|
||||
$pendingEquipament = new PendingEquipment;
|
||||
|
|
@ -1424,6 +1337,10 @@ function normalize($value)
|
|||
$pendingEquipament->pending_equipment_type_id = $equipmentType->equipment_type_id;
|
||||
$pendingEquipament->pending_equipment_tag = $datas['equipment_tag'];
|
||||
$pendingEquipament->pending_equipment_description = $datas['equipment_description'];
|
||||
|
||||
//recebe os valores de $equipmentPendingLogs para guardar o logs de criacao deste pendente.
|
||||
$pendingEquipament->pending_equipment_creation_log = json_encode($pending_equipment_creation_log);
|
||||
|
||||
$pendingEquipament->pending_equipment_serial_number = $datas['serial_number'];
|
||||
$pendingEquipament->pending_equipment_brand = $datas['model'];
|
||||
$pendingEquipament->pending_company_projects_id = $company_projects_id;
|
||||
|
|
@ -1475,7 +1392,7 @@ function normalize($value)
|
|||
// Criar um equipment_work_historys
|
||||
$newEquipmentWorkHistory = new EquipmentWorkHistory;
|
||||
$newEquipmentWorkHistory->equipment_id = $findEquipment->equipment_id;
|
||||
|
||||
$newEquipmentWorkHistory->equipment_status_project = 0;
|
||||
$newEquipmentWorkHistory->ispt_number = $isptNumber++;
|
||||
$newEquipmentWorkHistory->company_projects_id = $company_projects_id;
|
||||
$newEquipmentWorkHistory->save();
|
||||
|
|
@ -1505,7 +1422,6 @@ function normalize($value)
|
|||
$newEquipmentWorkHistory->ispt_number = $isptNumber++;
|
||||
$JoinsEquipmentsWithTasks->equipmentWorkHistorys_id = $newEquipmentWorkHistory->equipmentWorkHistorys_id;
|
||||
$JoinsEquipmentsWithTasks->elemental_tasks_id = $TasksAssociationAmbit->elemental_tasks_id;
|
||||
$JoinsEquipmentsWithTasks->further_tasks_id = null;
|
||||
$JoinsEquipmentsWithTasks->save();
|
||||
}
|
||||
|
||||
|
|
@ -1532,6 +1448,7 @@ function normalize($value)
|
|||
|
||||
//Deve adicionar tambem os outros atributos espesificos para o equipameto.
|
||||
|
||||
|
||||
//Criar o equipment Work History
|
||||
$newEquipmentWorkHistory = new EquipmentWorkHistory;
|
||||
$newEquipmentWorkHistory->equipment_id = $newEquipament->equipment_id;
|
||||
|
|
@ -1563,7 +1480,6 @@ function normalize($value)
|
|||
$JoinsEquipmentsWithTasks->execution_order = $execution_order++;
|
||||
$JoinsEquipmentsWithTasks->equipmentWorkHistorys_id = $newEquipmentWorkHistory->equipmentWorkHistorys_id;
|
||||
$JoinsEquipmentsWithTasks->elemental_tasks_id = $TasksAssociationAmbit->elemental_tasks_id;
|
||||
$JoinsEquipmentsWithTasks->further_tasks_id = null;
|
||||
$JoinsEquipmentsWithTasks->save();
|
||||
}
|
||||
|
||||
|
|
@ -1878,7 +1794,6 @@ public function storeProject(Request $request)
|
|||
|
||||
public function getByUserNif(Request $request)
|
||||
{
|
||||
// dd($request);
|
||||
|
||||
$companyId = $request->input('company_id'); // Considerando que este ID é na verdade o ID da empresa
|
||||
|
||||
|
|
|
|||
|
|
@ -486,7 +486,7 @@ public function enterWorkstation()
|
|||
// // Busca na model User
|
||||
// $filteredUsers = User::where('type_users', 5)
|
||||
// ->whereRaw("SUBSTRING_INDEX(user_name, '-', -1) = ?", [$DatasProject->company_projects_id])
|
||||
// ->whereRaw("SUBSTRING_INDEX(SUBSTRING_INDEX(email, '@', 1), '-', 1) = ?", [$DatasProject->project_company_number])
|
||||
// ->whereRaw("SUBSTRING_INDEX(SUBSTRING_INDEX(email, '@', 1), '-', 1) = ?", [$DatasProject->project_company_name])
|
||||
// ->get();
|
||||
|
||||
// // Adicionando a nova coluna realPassword
|
||||
|
|
@ -518,7 +518,7 @@ public function receiveExecutionProject($ProjectId)
|
|||
// Busca na model User
|
||||
$filteredUsers = User::where('type_users', 5)
|
||||
->whereRaw("SUBSTRING_INDEX(user_name, '-', -1) = ?", [$DatasProject->company_projects_id])
|
||||
->whereRaw("SUBSTRING_INDEX(SUBSTRING_INDEX(email, '@', 1), '-', 1) = ?", [$DatasProject->project_company_number])
|
||||
->whereRaw("SUBSTRING_INDEX(SUBSTRING_INDEX(email, '@', 1), '-', 1) = ?", [$DatasProject->project_company_name])
|
||||
->get();
|
||||
|
||||
// Adicionando a nova coluna realPassword
|
||||
|
|
|
|||
|
|
@ -108,7 +108,6 @@ public function editEquipmentTasks(Request $request, $equipmentID)
|
|||
foreach ($orderTasks as $task) {
|
||||
$taskExecutionOrders[$task->elemental_tasks_id] = $task->execution_order;
|
||||
}
|
||||
// dd($orderTasks);
|
||||
|
||||
return redirect()->back()->with('success', 'As tarefas do equipamento foram atualizado com sucesso');
|
||||
|
||||
|
|
@ -120,7 +119,7 @@ public function checkProjectIsptNumber(Request $request, $projectId = null)
|
|||
$number = $request->get('number');
|
||||
$type = $request->get('type'); // 'ispt' ou 'company'
|
||||
|
||||
$column = $type == 'ispt' ? 'project_ispt_number' : 'project_company_number';
|
||||
$column = $type == 'ispt' ? 'project_ispt_number' : 'project_company_name';
|
||||
|
||||
// Inicialmente verifica se o número já existe
|
||||
$query = CompanyProject::where($column, $number);
|
||||
|
|
@ -393,12 +392,11 @@ public function projectDetails_11($projectID, $equipmentID)
|
|||
|
||||
$dataEquipment = Equipment::find($equipmentID);
|
||||
|
||||
$detailsEquipmentWorkHistory = EquipmentWorkHistory::where('equipment_id', $dataEquipment->equipment_id)->first();
|
||||
|
||||
$receiveEquipmentWorkHistorys = EquipmentWorkHistory::where('equipment_id', $equipmentID)
|
||||
->where('company_projects_id', $projectID)
|
||||
->first();
|
||||
|
||||
|
||||
$attributes = SpecificAttributesEquipmentType::where('equipment_id', $equipmentID)->get(); // recebe todos os atributos espesificos do equipamento
|
||||
|
||||
// $DetailsTasks = OrderEquipmentTasks::where('equipmentWorkHistorys_id', $receiveEquipmentWorkHistorys->equipmentWorkHistorys_id)->get(); // Todas as tarefas que o equipamento vai realizar :
|
||||
|
|
@ -414,6 +412,7 @@ public function projectDetails_11($projectID, $equipmentID)
|
|||
->get();
|
||||
|
||||
// Filtra para manter apenas os registros que realmente têm uma tarefa elemental associada com company_projects_id não nulo
|
||||
//O resultado sera as tarefas complementares, pois apenas estas tarefas tem company_projects_id associados.
|
||||
$filteredTasks = $DetailsTasks->filter(function ($task) {
|
||||
return !is_null($task->elementalTask) && !is_null($task->elementalTask->company_projects_id);
|
||||
});
|
||||
|
|
@ -424,6 +423,8 @@ public function projectDetails_11($projectID, $equipmentID)
|
|||
->get()
|
||||
->keyBy('elemental_tasks_id'); // Keying by elemental_tasks_id para fácil acesso
|
||||
|
||||
|
||||
|
||||
$filteredTasks = $filteredTasks->map(function ($task) use ($elementalTasksDetails, $DetailsTasks) {
|
||||
// Primeiro bloco: Adiciona detalhes da tarefa elemental
|
||||
if (isset ($elementalTasksDetails[$task->elemental_tasks_id])) {
|
||||
|
|
@ -450,6 +451,7 @@ public function projectDetails_11($projectID, $equipmentID)
|
|||
});
|
||||
|
||||
|
||||
|
||||
// Para buscar a tarefa com execution_order = 3
|
||||
$taskBeforeExecutionOrder = OrderEquipmentTasks::where('equipmentWorkHistorys_id', $receiveEquipmentWorkHistorys->equipmentWorkHistorys_id)
|
||||
->where('execution_order', 3)
|
||||
|
|
@ -462,6 +464,9 @@ public function projectDetails_11($projectID, $equipmentID)
|
|||
->first();
|
||||
}
|
||||
|
||||
// dd($taskBeforeExecutionOrder);
|
||||
|
||||
|
||||
|
||||
// $OrdemTasks = $DetailsTasks->pluck('elemental_tasks_id')->all(); // Array de IDs
|
||||
$OrdemTasks = $DetailsTasks->pluck('execution_order', 'elemental_tasks_id')->all();
|
||||
|
|
@ -478,10 +483,9 @@ public function projectDetails_11($projectID, $equipmentID)
|
|||
foreach ($specificAttributes as $attribute) {
|
||||
$specificAttributesArray[$attribute->general_attributes_equipment_id] = $attribute->specific_attributes_value;
|
||||
}
|
||||
// vou te achar cabrao.
|
||||
|
||||
|
||||
|
||||
return view('projectsClients.articulated_2_ShowEquipment', compact('receiveComments', 'detailsProject', 'dataEquipment', 'filteredTasks', 'OrdemTasks', 'DetailsTasks', 'detailsEquipmentWorkHistory', 'specificAttributesArray'));
|
||||
return view('projectsClients.articulated_2_ShowEquipment', compact( 'detailsProject', 'dataEquipment', 'filteredTasks', 'OrdemTasks', 'DetailsTasks','specificAttributesArray','receiveEquipmentWorkHistorys'));
|
||||
}
|
||||
|
||||
//Funcao que recebe a Acoes do dataTables do portifolio.
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@
|
|||
namespace App\Livewire\Articulado;
|
||||
|
||||
use App\Models\ElementalTasks;
|
||||
use App\Models\EquipmentWorkHistory;
|
||||
use App\Models\OrderEquipmentTasks;
|
||||
use Livewire\Component;
|
||||
|
||||
use App\Models\Equipment;
|
||||
|
|
@ -40,18 +42,20 @@ public function mount($workstation)
|
|||
{
|
||||
$this->workstation = $workstation;
|
||||
|
||||
//verificar se nao o motivo de receber os valores antigos do ws ao entrar em outro.
|
||||
$workstation = $this->workstation; // Atribuindo a uma variável local para uso na closure
|
||||
|
||||
//recebe todos os equipamentos do projecto atual
|
||||
$this->receiveAllEquipments = Equipment::join('equipment_work_historys', function ($join) use ($workstation) {
|
||||
$join->on('equipments.equipment_id', '=', 'equipment_work_historys.equipment_id')
|
||||
->where('equipment_work_historys.company_projects_id', '=', $workstation->company_projects_id);
|
||||
})
|
||||
->join('equipment_association_ambits', 'equipment_work_historys.equipmentWorkHistorys_id', '=', 'equipment_association_ambits.equipmentWorkHistorys_id')
|
||||
->select('equipments.equipment_id', 'equipments.equipment_type_id', 'equipment_association_ambits.ambits_id')
|
||||
->select('equipments.equipment_id','equipment_work_historys.equipmentWorkHistorys_id','equipment_work_historys.company_projects_id', 'equipments.equipment_type_id', 'equipment_association_ambits.ambits_id',)
|
||||
->get()
|
||||
->toArray();
|
||||
|
||||
$this->receiveAllFurtherTasks = ElementalTasks::where('company_projects_id', $this->workstation->company_projects_id)->get();
|
||||
// $this->receiveAllFurtherTasks = ElementalTasks::where('company_projects_id', $this->workstation->company_projects_id)->get();
|
||||
|
||||
// Inicializar a matriz
|
||||
$this->receiveElementalTasks = [
|
||||
|
|
@ -63,7 +67,14 @@ public function mount($workstation)
|
|||
|
||||
// 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'])
|
||||
|
||||
//Esta parte esta errada, nao esta indo pela tarefas do equipamento e sim pelos padrao ao selecionar um ambito.
|
||||
// $elementalTasksIds = TasksAssociationAmbits::where('ambits_equipment_id', $equipment['ambits_id'])
|
||||
// ->pluck('elemental_tasks_id')
|
||||
// ->toArray();
|
||||
|
||||
$elementalTasksIds = OrderEquipmentTasks::where('equipmentWorkHistorys_id',$equipment['equipmentWorkHistorys_id'])
|
||||
->orderBy('elemental_tasks_id', 'asc')
|
||||
->pluck('elemental_tasks_id')
|
||||
->toArray();
|
||||
|
||||
|
|
@ -115,7 +126,7 @@ public function mount($workstation)
|
|||
$receiveTasksRepository = app(ReceiveTasksRepository::class);
|
||||
// Chama a variavel do Repositorio para amazenar a variavel e depois conseguir chamar facilmente.
|
||||
$receiveTasksRepository->setElementalTasks($this->receiveElementalTasks);
|
||||
$receiveTasksRepository->setFurtherTasks($this->receiveAllFurtherTasks);
|
||||
// $receiveTasksRepository->setFurtherTasks($this->receiveAllFurtherTasks);
|
||||
}
|
||||
|
||||
public function render()
|
||||
|
|
|
|||
|
|
@ -15,6 +15,9 @@ class AssociationCompanyUser extends Model
|
|||
|
||||
protected $fillable = ['association_company_user_id', 'company_id', 'user_id'];
|
||||
|
||||
public function user(){
|
||||
return $this->belongsTo(User::class, 'user_id', 'user_id');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ 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'];
|
||||
protected $fillable = ['company_projects_id', 'plant_id', 'project_company_name','project_ispt_number','company_project_description','project_ispt_responsible','project_company_responsible','date_started','end_date','order_project'];
|
||||
|
||||
public $timestamps = false;
|
||||
|
||||
|
|
|
|||
|
|
@ -24,8 +24,8 @@ public function elementalTask()
|
|||
return $this->belongsTo(ElementalTasks::class,'elemental_tasks_id','elemental_tasks_id');
|
||||
}
|
||||
|
||||
public function furtherTasks()
|
||||
{
|
||||
return $this->belongsTo(FurtherTasks::class,'further_tasks_id','further_tasks_id');
|
||||
}
|
||||
// public function furtherTasks()
|
||||
// {
|
||||
// return $this->belongsTo(FurtherTasks::class,'further_tasks_id','further_tasks_id');
|
||||
// }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,9 +15,9 @@ class Plant extends Model
|
|||
|
||||
public $timestamps = false;
|
||||
|
||||
// public function user(){
|
||||
// return $this->belongsTo(User::class, 'user_id', 'user_id');
|
||||
// }
|
||||
public function user(){
|
||||
return $this->belongsTo(User::class, 'user_id', 'user_id');
|
||||
}
|
||||
|
||||
public function company(){
|
||||
return $this->belongsTo(Company::class, 'company_id', 'company_id');
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ public function equipment()
|
|||
|
||||
public function generalAttributesEquipment()
|
||||
{
|
||||
return $this->belongsTo(GeneralAttributesEquipament::class, 'general_attributes_equipment_id', 'general_attributes_equipment_id');
|
||||
return $this->belongsTo(GeneralAttributesEquipment::class, 'general_attributes_equipment_id', 'general_attributes_equipment_id');
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -73,4 +73,10 @@ public function comments()
|
|||
return $this->hasMany(EquipmentComment::class, 'user_id');
|
||||
}
|
||||
|
||||
public function associationCompanyUser()
|
||||
{
|
||||
return $this->hasMany(AssociationCompanyUser::class, 'user_id', 'user_id');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,8 +23,8 @@ public function elementalTask()
|
|||
return $this->belongsTo(ElementalTasks::class,'elemental_tasks_id','elemental_tasks_id');
|
||||
}
|
||||
|
||||
public function furtherTask()
|
||||
{
|
||||
return $this->belongsTo(FurtherTasks::class,'further_tasks_id','further_tasks_id');
|
||||
}
|
||||
// public function furtherTask()
|
||||
// {
|
||||
// return $this->belongsTo(FurtherTasks::class,'further_tasks_id','further_tasks_id');
|
||||
// }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
{{-- 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 }}">
|
||||
{{-- <input type="hidden" name="receiveAllFurtherTasks" value="{{ $receiveAllFurtherTasks }}"> --}}
|
||||
<div class="row">
|
||||
<p class="mt-1 mr-1">Nome Posto de Trabalho : </p>
|
||||
<input class="form-control col-sm-6" type="text" name="nameWorkstation"
|
||||
|
|
@ -228,30 +228,28 @@ class="fas fa-plus"></i></button>
|
|||
$('.open-modal').click(function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
// Limpa todos os checkboxes antes de abrir o modal
|
||||
$('input[type="checkbox"]').prop('checked', false);
|
||||
|
||||
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);
|
||||
|
||||
// Seleciona o checkbox 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>
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -107,8 +107,6 @@ class="fas fa-plus"></i></button>
|
|||
@case(3)
|
||||
Equipamentos Novos (Criado novos equipamentos)
|
||||
@break
|
||||
|
||||
|
||||
@endswitch
|
||||
</h3>
|
||||
<div class="card-tools">
|
||||
|
|
@ -1357,10 +1355,10 @@ class="btn btn-primary float-right">Postos de Trabalho</a>
|
|||
<!--Codigo Novo -->
|
||||
<fieldset class="content">
|
||||
<div class="container-fluid">
|
||||
<h2 class="text-center">Equipamentos Pendentes de Criacao:</h2>
|
||||
<h2 class="text-center">Equipamentos Pendentes de Criação:</h2>
|
||||
@isset($pendingEquipments)
|
||||
<ul class="list-group scrollable-list-xl">
|
||||
@foreach ($pendingEquipments as $pendingEquipment)
|
||||
{{-- @foreach ($pendingEquipments as $pendingEquipment)
|
||||
<li class="list-group-item align-items-center" aria-current="true">
|
||||
<div class="card card-primary collapsed-card" style="padding: 0;margin:0;">
|
||||
<div class="card-header clickable">
|
||||
|
|
@ -1375,31 +1373,6 @@ class="btn btn-primary float-right">Postos de Trabalho</a>
|
|||
<div class="card-body">
|
||||
<div class="row">
|
||||
<div class="col-sm-8">
|
||||
{{-- <ul>
|
||||
<li><b>Equipamento pendente (Tag): </b>
|
||||
{{ $pendingEquipment->pending_equipment_tag }}</li>
|
||||
<li><b>Equipamento pendente (Descrição):
|
||||
</b>{{ $pendingEquipment->pending_equipment_description }}</li>
|
||||
@if (isset($groupedArrayForPendingEquipments) && !empty($groupedArrayForPendingEquipments))
|
||||
@foreach ($groupedArrayForPendingEquipments[1][1] as $equipmentLog)
|
||||
@if ($equipmentLog['pendingEquipmentId'] == $pendingEquipment->pending_equipment_id)
|
||||
<li> <b>Equipamento copiado de Execel:</b>
|
||||
{{ $groupedArrayForPendingEquipments[0] }} -
|
||||
{{ $groupedArrayForPendingEquipments[1][0] }}</li>
|
||||
<li><b>Linha de
|
||||
criação:{{ $equipmentLog['rowExecel'] }}</b>
|
||||
</li>
|
||||
@if ($equipmentLog['foundInExcel'])
|
||||
<li> <b>Linha de cópia:
|
||||
{{ $equipmentLog['rowExcelDuplicated'] ?? 'Não duplicado' }}
|
||||
</b> </li>
|
||||
@endif
|
||||
@endif
|
||||
@endforeach
|
||||
@else
|
||||
<li>Sem dados Disponiveis sobre sua criacao!!!</li>
|
||||
@endif
|
||||
</ul> --}}
|
||||
|
||||
</div>
|
||||
<div class="col-sm-4">
|
||||
|
|
@ -1418,7 +1391,88 @@ class="btn btn-primary float-right">Postos de Trabalho</a>
|
|||
</div>
|
||||
</div>
|
||||
</li>
|
||||
@endforeach --}}
|
||||
|
||||
@foreach ($pendingEquipments as $pendingEquipment)
|
||||
<li class="list-group-item align-items-center" aria-current="true">
|
||||
<div class="card card-primary collapsed-card" style="padding: 0;margin:0;">
|
||||
<div class="card-header clickable">
|
||||
<h3 class="card-title">Equipamento :
|
||||
{{ $pendingEquipment->pending_equipment_tag }}</h3>
|
||||
<div class="card-tools">
|
||||
<button type="button" class="btn btn-tool collapse-button"
|
||||
data-card-widget="collapse"><i class="fas fa-plus"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card-body">
|
||||
<div class="row">
|
||||
|
||||
<div class="col-sm-8">
|
||||
@php
|
||||
$logData = json_decode(
|
||||
$pendingEquipment->pending_equipment_creation_log,
|
||||
true,
|
||||
);
|
||||
@endphp
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">Detalhes do Equipamento</h5>
|
||||
<p class="card-text"><strong>Nome do Arquivo:</strong>
|
||||
{{ $logData['excel_Name'] ?? 'Não disponível' }}</p>
|
||||
<p class="card-text"><strong>Motivo:</strong>
|
||||
{{ $logData['reason'] ?? 'Não disponível' }}</p>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-4">
|
||||
<div class="text-center d-flex justify-content-around">
|
||||
<!-- Botão Azul para visualizar detalhes -->
|
||||
<button type="button" class="btn btn-primary"
|
||||
data-toggle="modal"
|
||||
data-target="#modal-PendingEquipmentCreate-{{ $pendingEquipment->pending_equipment_id }}">
|
||||
<i class="fa-solid fa-eye"></i> Visualizar
|
||||
</button>
|
||||
|
||||
<!-- Botão Vermelho para remover -->
|
||||
<button type="button" class="btn btn-danger"
|
||||
data-toggle="modal"
|
||||
data-target="#modal-PendingEquipmentRemove-{{ $pendingEquipment->pending_equipment_id }}">
|
||||
<i class="fa-solid fa-trash-alt"></i> Remover
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
|
||||
<div class="col-sm">
|
||||
<div class="card">
|
||||
|
||||
<ul class="list-group list-group-flush">
|
||||
<li class="list-group-item"><strong>Tag do
|
||||
Equipamento:</strong>
|
||||
{{ $pendingEquipment->pending_equipment_tag }}</li>
|
||||
<li class="list-group-item"><strong>Descrição:</strong>
|
||||
{{ $pendingEquipment->pending_equipment_description }}
|
||||
</li>
|
||||
<li class="list-group-item"><strong>Tipo de
|
||||
Equipamento:</strong>
|
||||
{{ $pendingEquipment->equipmentType->equipment_type_name }}
|
||||
</li>
|
||||
<li class="list-group-item"><strong>Unidade:</strong>
|
||||
{{ $pendingEquipment->unit->unit_name }}</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
@endforeach
|
||||
|
||||
</ul>
|
||||
@else
|
||||
<p colspan="9" class="text-center">Sem dados existentes !!!</p>
|
||||
|
|
@ -1485,29 +1539,31 @@ class="btn btn-primary float-right">Postos de Trabalho</a>
|
|||
@csrf
|
||||
|
||||
<div class="modal-body">
|
||||
<p>Ao optar por criar o equipamento, este assumirá o nome já existente acrescido de (+1)
|
||||
<p>Ao optar por criar o equipamento, este assumirá o nome já existente
|
||||
acrescido de <span class="badge badge-secondary">+1</span>
|
||||
para indicar o número da cópia e para diferenciá-lo como um equipamento individual em
|
||||
relação ao equipamento original de mesma TAG.</p>
|
||||
<h4><b>Tag:</b> {{ $pendingEquipment->pending_equipment_tag }} <strong>(Número da
|
||||
copia)</strong>
|
||||
</h4>
|
||||
<h4><b>Descrição:</b> {{ $pendingEquipment->pending_equipment_description }}
|
||||
<strong>(Número da copia)</strong>
|
||||
<h4><b>Tag:</b> {{ $pendingEquipment->pending_equipment_tag }} <span
|
||||
class="badge badge-info">(Número da copia)</span></h4>
|
||||
<h4><b>Descrição:</b> {{ $pendingEquipment->pending_equipment_description }} <span
|
||||
class="badge badge-info">(Número da copia)</span></h4>
|
||||
<h4><b>Tipo de Equipamento:</b> {{ $pendingEquipment->equipmentType->equipment_type_name }}
|
||||
</h4>
|
||||
|
||||
<h4>{{ $pendingEquipment->pending_equipment_type_id }}({{ $pendingEquipment->equipmentType->equipment_type_name }})
|
||||
</h4>
|
||||
<select class="form-control" name="EquipmentAmbit"
|
||||
<select class="form-control mt-3 mb-4" name="EquipmentAmbit"
|
||||
id="AmbitsEquipments_list-{{ $pendingEquipment->pending_equipment_id }}" required>
|
||||
<option value='' hidden>Selecionar Âmbitos...</option>
|
||||
<!-- adicionar opções dinamicamente -->
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="modal-footer justify-content-between">
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal">Fechar</button>
|
||||
<button type="submit" class="btn btn-success">Criar</button>
|
||||
<button type="button" class="btn btn-outline-secondary"
|
||||
data-dismiss="modal">Fechar</button>
|
||||
<button type="submit" class="btn btn-primary">Criar</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
<!-- /.modal-content -->
|
||||
</div>
|
||||
|
|
@ -1515,37 +1571,40 @@ class="btn btn-primary float-right">Postos de Trabalho</a>
|
|||
<!-- ./modal-PendingEquipmentCreate -->
|
||||
|
||||
<!-- modal-PendingEquipmentRemove -->
|
||||
<div class="modal fade" id="modal-PendingEquipmentRemove-{{ $pendingEquipment->pending_equipment_id }}">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal fade" id="modal-PendingEquipmentRemove-{{ $pendingEquipment->pending_equipment_id }}"
|
||||
tabindex="-1" role="dialog" aria-labelledby="modalLabelRemove" aria-hidden="true">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header bg-primary">
|
||||
<h4 class="modal-title">Remover</h4>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">x</span>
|
||||
<div class="modal-header bg-primary text-white">
|
||||
<h5 class="modal-title" id="modalLabelRemove">Remover Equipamento</h5>
|
||||
<button type="button" class="close text-white" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p>Deseja realmente remover o equipamento ?</p>
|
||||
<h4>{{ $pendingEquipment->pending_equipment_tag }}</h4>
|
||||
<h4>{{ $pendingEquipment->pending_equipment_description }}</h4>
|
||||
<p class="lead">Deseja realmente remover o equipamento?</p>
|
||||
<ul class="list-group list-group-flush">
|
||||
<li class="list-group-item"><strong>Tag:</strong>
|
||||
{{ $pendingEquipment->pending_equipment_tag }}</li>
|
||||
<li class="list-group-item"><strong>Descrição:</strong>
|
||||
{{ $pendingEquipment->pending_equipment_description }}</li>
|
||||
<li class="list-group-item"><strong>Tipo de Equipamento:</strong>
|
||||
{{ $pendingEquipment->equipmentType->equipment_type_name }}</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="modal-footer justify-content-between">
|
||||
<form action="{{ route('removeEquipment', $pendingEquipment->pending_equipment_id) }}"
|
||||
method="POST">
|
||||
method="POST" style="width:100%;">
|
||||
@csrf
|
||||
@method('DELETE')
|
||||
<div class="modal-footer justify-content-between">
|
||||
<button type="button" class="btn btn-default"
|
||||
data-dismiss="modal">Fechar</button>
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">Fechar</button>
|
||||
<button type="submit" class="btn btn-danger">Remover</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<!-- /.modal-content -->
|
||||
</div>
|
||||
<!-- /.modal-dialog -->
|
||||
</div>
|
||||
|
||||
<!-- ./modal-PendingEquipmentRemove -->
|
||||
@endforeach
|
||||
@endif
|
||||
|
|
@ -2456,5 +2515,4 @@ function(task) {
|
|||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
@endsection
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@
|
|||
|
||||
<div class="card card-primary">
|
||||
<div class="card-header "> <!-- Flex container with spaced between items -->
|
||||
<h3 class="float-left"><b>Número ISPT -</b> {{ $detailsEquipmentWorkHistory->ispt_number }}</h3>
|
||||
<h3 class="float-left"><b>Número ISPT -</b> {{ $receiveEquipmentWorkHistorys->ispt_number }}</h3>
|
||||
<!-- This item will be on the left -->
|
||||
<h3 class="float-right"> <b>Tag -</b> {{ $dataEquipment->equipment_tag }}</h3>
|
||||
<!-- This item will be on the right -->
|
||||
|
|
@ -443,7 +443,7 @@ class="form-control card_inputs" id="crane"
|
|||
|
||||
<div class="card-header clickable">
|
||||
<h3 class="card-title">Âmbito :
|
||||
{{ $detailsEquipmentWorkHistory->equipmentAssociationAmbit->ambitsEquipment->ambits_description }}
|
||||
{{ $receiveEquipmentWorkHistorys->equipmentAssociationAmbit->ambitsEquipment->ambits_description }}
|
||||
- Visualizar
|
||||
</h3>
|
||||
<div class="card-tools">
|
||||
|
|
@ -456,7 +456,7 @@ class="form-control card_inputs" id="crane"
|
|||
<div class="card ordemTasks-div">
|
||||
<div class="card-header">
|
||||
<h3 class="card-title">Lista de Tarefas Elementares :
|
||||
{{ $detailsEquipmentWorkHistory->equipmentAssociationAmbit->ambitsEquipment->ambits_description }}
|
||||
{{ $receiveEquipmentWorkHistorys->equipmentAssociationAmbit->ambitsEquipment->ambits_description }}
|
||||
</h3>
|
||||
</div>
|
||||
<!-- /.card-header -->
|
||||
|
|
@ -1035,7 +1035,7 @@ class="form-control card_inputs"
|
|||
|
||||
<div class="card-header clickable">
|
||||
<h3 class="card-title">Âmbito :
|
||||
{{ $detailsEquipmentWorkHistory->equipmentAssociationAmbit->ambitsEquipment->ambits_description }}
|
||||
{{ $receiveEquipmentWorkHistorys->equipmentAssociationAmbit->ambitsEquipment->ambits_description }}
|
||||
- Editar
|
||||
</h3>
|
||||
<div class="card-tools">
|
||||
|
|
@ -1049,7 +1049,7 @@ class="form-control card_inputs"
|
|||
<div class="card ordemTasks-div">
|
||||
<div class="card-header">
|
||||
<h3 class="card-title">Lista de Tarefas Elementares :
|
||||
{{ $detailsEquipmentWorkHistory->equipmentAssociationAmbit->ambitsEquipment->ambits_description }}
|
||||
{{ $receiveEquipmentWorkHistorys->equipmentAssociationAmbit->ambitsEquipment->ambits_description }}
|
||||
</h3>
|
||||
</div>
|
||||
<!-- /.card-header -->
|
||||
|
|
@ -1850,7 +1850,7 @@ class="form-control card_inputs"
|
|||
|
||||
<div class="card-header clickable">
|
||||
<h3 class="card-title">Âmbito :
|
||||
{{ $detailsEquipmentWorkHistory->equipmentAssociationAmbit->ambitsEquipment->ambits_description }}
|
||||
{{ $receiveEquipmentWorkHistorys->equipmentAssociationAmbit->ambitsEquipment->ambits_description }}
|
||||
- Editar
|
||||
</h3>
|
||||
<div class="card-tools">
|
||||
|
|
@ -1863,7 +1863,7 @@ class="form-control card_inputs"
|
|||
<div class="card ordemTasks-div">
|
||||
<div class="card-header">
|
||||
<h3 class="card-title">Lista de Tarefas Elementares :
|
||||
{{ $detailsEquipmentWorkHistory->equipmentAssociationAmbit->ambitsEquipment->ambits_description }}
|
||||
{{ $receiveEquipmentWorkHistorys->equipmentAssociationAmbit->ambitsEquipment->ambits_description }}
|
||||
</h3>
|
||||
</div>
|
||||
<!-- /.card-header -->
|
||||
|
|
@ -2362,7 +2362,7 @@ class="form-control card_inputs" id="Crane"
|
|||
|
||||
<div class="card-header clickable">
|
||||
<h3 class="card-title">Âmbito :
|
||||
{{ $detailsEquipmentWorkHistory->equipmentAssociationAmbit->ambitsEquipment->ambits_description }}
|
||||
{{ $receiveEquipmentWorkHistorys->equipmentAssociationAmbit->ambitsEquipment->ambits_description }}
|
||||
- Visualizar
|
||||
</h3>
|
||||
<div class="card-tools">
|
||||
|
|
@ -2375,7 +2375,7 @@ class="form-control card_inputs" id="Crane"
|
|||
<div class="card ordemTasks-div">
|
||||
<div class="card-header">
|
||||
<h3 class="card-title">Lista de Tarefas Elementares :
|
||||
{{ $detailsEquipmentWorkHistory->equipmentAssociationAmbit->ambitsEquipment->ambits_description }}
|
||||
{{ $receiveEquipmentWorkHistorys->equipmentAssociationAmbit->ambitsEquipment->ambits_description }}
|
||||
</h3>
|
||||
</div>
|
||||
<!-- /.card-header -->
|
||||
|
|
@ -2520,7 +2520,7 @@ class="form-control card_inputs" id="Crane"
|
|||
<td class="text-center">
|
||||
<input type="checkbox" name="ordemTasks[15]"
|
||||
value="on"
|
||||
@if (isset($OrdemTasks[15]) && $OrdemTasks[15] == 'on') checked @endif
|
||||
@if (isset($OrdemTasks[24]) && $OrdemTasks[24] == 'on') checked @endif
|
||||
onclick="return false;"
|
||||
onkeydown="return false;"
|
||||
style="pointer-events: none;">
|
||||
|
|
@ -2911,7 +2911,7 @@ class="form-control card_inputs" id="isolation"
|
|||
|
||||
<div class="card-header clickable">
|
||||
<h3 class="card-title">Âmbito :
|
||||
{{ $detailsEquipmentWorkHistory->equipmentAssociationAmbit->ambitsEquipment->ambits_description }}
|
||||
{{ $receiveEquipmentWorkHistorys->equipmentAssociationAmbit->ambitsEquipment->ambits_description }}
|
||||
- Editar
|
||||
</h3>
|
||||
<div class="card-tools">
|
||||
|
|
@ -2924,7 +2924,7 @@ class="form-control card_inputs" id="isolation"
|
|||
<div class="card ordemTasks-div">
|
||||
<div class="card-header">
|
||||
<h3 class="card-title">Lista de Tarefas Elementares :
|
||||
{{ $detailsEquipmentWorkHistory->equipmentAssociationAmbit->ambitsEquipment->ambits_description }}
|
||||
{{ $receiveEquipmentWorkHistorys->equipmentAssociationAmbit->ambitsEquipment->ambits_description }}
|
||||
</h3>
|
||||
</div>
|
||||
<!-- /.card-header -->
|
||||
|
|
@ -3071,14 +3071,14 @@ class="form-control card_inputs" id="isolation"
|
|||
<tr id="24">
|
||||
<td>TE10.1</td>
|
||||
<td>Confirmação de ligação</td>
|
||||
{{-- Apenas para ver se recebe um on ou off, o hidden serve para devolver valor se o checkbox não estiver a 'checked' --}}
|
||||
<!-- Apenas para ver se recebe um on ou off, o hidden serve para devolver valor se o checkbox não estiver a 'checked' -->
|
||||
<td class="text-center">
|
||||
<input type="hidden" name="ordemTasks[15]"
|
||||
<input type="hidden" name="ordemTasks[24]"
|
||||
value="off">
|
||||
<!-- se não marcado, o valor será 'off' -->
|
||||
<input type="checkbox" name="ordemTasks[15]"
|
||||
<input type="checkbox" name="ordemTasks[24]"
|
||||
value="on"
|
||||
{{ old('ordemTasks[15]', isset($OrdemTasks[15]) && $OrdemTasks[15] == 'on' ? 'on' : '') == 'on' ? 'checked' : '' }}>
|
||||
{{ old('ordemTasks[24]', isset($OrdemTasks[24]) && $OrdemTasks[24] == 'on' ? 'on' : '') == 'on' ? 'checked' : '' }}>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="17">
|
||||
|
|
|
|||
|
|
@ -66,9 +66,10 @@
|
|||
<div class="form-group col-sm-6">
|
||||
<label>{{ __('messages.createProject.ispt_project_number') }}<b
|
||||
style="color:red">*</b></label>
|
||||
<input type="number" name="n_project_ispt" class="form-control" data-type="ispt"
|
||||
<input type="text" name="n_project_ispt" class="form-control" data-type="ispt"
|
||||
placeholder="{{ __('messages.createProject.ispt_project_number') }}…"
|
||||
required>
|
||||
|
||||
<div id="project-number-exists-ispt"></div>
|
||||
</div>
|
||||
|
||||
|
|
@ -165,7 +166,12 @@
|
|||
<label>{{ __('messages.createProject.company_project_number') }}<b
|
||||
style="color:red">*</b></label>
|
||||
|
||||
<input type="number" name="project_company_number" class="form-control"
|
||||
{{-- <input type="number" name="project_company_name" class="form-control"
|
||||
data-type="company"
|
||||
placeholder="{{ __('messages.createProject.company_project_number') }}…"
|
||||
required> --}}
|
||||
|
||||
<input type="text" name="project_company_name" class="form-control"
|
||||
data-type="company"
|
||||
placeholder="{{ __('messages.createProject.company_project_number') }}…"
|
||||
required>
|
||||
|
|
@ -231,71 +237,8 @@ class="btn btn-primary">{{ __('messages.buttons.save') }}</button>
|
|||
});
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
{{-- Funciona Bem --}}
|
||||
{{-- <script>
|
||||
|
||||
// Função para atualizar o estado do botão de envio com base na validade dos inputs
|
||||
function updateSubmitButtonState() {
|
||||
// Verifica se ambos os inputs possuem a classe 'valid-input', o que indica que são válidos
|
||||
var allValid = $('.valid-input').length === 2;
|
||||
// Habilita ou desabilita o botão de envio ('#submitButton') com base na validade dos inputs
|
||||
$('#submitButton').prop('disabled', !allValid);
|
||||
}
|
||||
|
||||
|
||||
// Aguarda o documento HTML estar completamente carregado para executar o script
|
||||
$(document).ready(function() {
|
||||
// Adiciona um ouvinte de evento 'input' para cada input especificado
|
||||
$('input[name="n_project_ispt"], input[name="project_company_number"]').on('input', function() {
|
||||
// Armazena o valor atual do input
|
||||
var number = $(this).val();
|
||||
// Armazena o tipo do input, determinado pelo atributo 'data-type'
|
||||
var type = $(this).data('type');
|
||||
|
||||
// Verifica se o input não está vazio
|
||||
if (number.length > 0) {
|
||||
// Realiza uma requisição AJAX para verificar se o número já existe no banco de dados
|
||||
$.ajax({
|
||||
url: '{{ route('checkProjectIsptNumber') }}',
|
||||
type: 'GET',
|
||||
data: {
|
||||
number: number,
|
||||
type: type
|
||||
},
|
||||
success: function(response) {
|
||||
// Se o número já existir, marca o input como inválido
|
||||
if (response.exists) {
|
||||
$(this).css('border', '2px solid red').removeClass(
|
||||
'valid-input').addClass('invalid-input');
|
||||
$('#project-number-exists-' + type).text('Número já existe')
|
||||
.css('color', 'red');
|
||||
} else {
|
||||
// Se o número não existir, marca o input como válido
|
||||
$(this).css('border', '2px solid green').removeClass(
|
||||
'invalid-input').addClass('valid-input');
|
||||
$('#project-number-exists-' + type).text('');
|
||||
}
|
||||
// Chama a função para atualizar o estado do botão de envio
|
||||
updateSubmitButtonState();
|
||||
}.bind(
|
||||
this
|
||||
) // Garante que 'this' se refere ao input dentro da função de sucesso
|
||||
});
|
||||
} else {
|
||||
// Se o input estiver vazio, remove qualquer marcação de validade/invalidade
|
||||
$(this).css('border', '1px solid #ced4da').removeClass('valid-input').removeClass(
|
||||
'invalid-input');
|
||||
$('#project-number-exists-' + type).text('');
|
||||
// Atualiza o estado do botão de envio
|
||||
updateSubmitButtonState();
|
||||
}
|
||||
});
|
||||
});
|
||||
</script> --}}
|
||||
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
function updateSubmitButtonState() {
|
||||
// Verifica se os inputs e os selects são válidos
|
||||
|
|
@ -309,7 +252,7 @@ function updateSubmitButtonState() {
|
|||
}
|
||||
|
||||
// Verifica mudanças nos inputs especificados
|
||||
$('input[name="n_project_ispt"], input[name="project_company_number"]').on('input', function() {
|
||||
$('input[name="n_project_ispt"], input[name="project_company_name"]').on('input', function() {
|
||||
var number = $(this).val();
|
||||
var type = $(this).data('type');
|
||||
|
||||
|
|
@ -343,12 +286,103 @@ function updateSubmitButtonState() {
|
|||
});
|
||||
|
||||
// Verifica mudanças nos selects
|
||||
$('#company_select, #user_id, #installationSelect').on('change', function() {
|
||||
updateSubmitButtonState();
|
||||
});
|
||||
});
|
||||
</script> --}}
|
||||
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
function updateSubmitButtonState() {
|
||||
var inputsValid = $('.valid-input').length === 2;
|
||||
var selectsValid = $('#company_select').val() !== '#' &&
|
||||
$('#user_id').val() !== '#' &&
|
||||
$('#installationSelect').val() !== '#';
|
||||
|
||||
$('#submitButton').prop('disabled', !(inputsValid && selectsValid));
|
||||
}
|
||||
|
||||
$('input[name="n_project_ispt"]').on('input', function(e) {
|
||||
var inputValue = $(this).val();
|
||||
// Permite apenas números e hífens, remove outros caracteres
|
||||
var validValue = inputValue.replace(/[^0-9-]/g, '');
|
||||
$(this).val(validValue); // Atualiza o campo com o valor válido
|
||||
|
||||
var type = $(this).data('type');
|
||||
|
||||
if (validValue.length > 0) {
|
||||
$.ajax({
|
||||
url: '{{ route('checkProjectIsptNumber') }}',
|
||||
type: 'GET',
|
||||
data: {
|
||||
number: validValue, // Envia o valor como o usuário digitou, incluindo hífens
|
||||
type: type
|
||||
},
|
||||
success: function(response) {
|
||||
if (response.exists) {
|
||||
$(this).css('border', '2px solid red').removeClass(
|
||||
'valid-input').addClass('invalid-input');
|
||||
$('#project-number-exists-' + type).text(
|
||||
'Identificação já existente')
|
||||
.css('color', 'red');
|
||||
} else {
|
||||
$(this).css('border', '2px solid green').removeClass(
|
||||
'invalid-input').addClass('valid-input');
|
||||
$('#project-number-exists-' + type).text('');
|
||||
}
|
||||
updateSubmitButtonState();
|
||||
}.bind(this)
|
||||
});
|
||||
} else {
|
||||
$(this).css('border', '1px solid #ced4da').removeClass('valid-input invalid-input');
|
||||
$('#project-number-exists-' + type).text('');
|
||||
updateSubmitButtonState();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// Para input[name="project_company_name"]
|
||||
$('input[name="project_company_name"]').on('input', function() {
|
||||
var inputValue = $(this).val();
|
||||
var type = $(this).data('type');
|
||||
|
||||
if (inputValue.length > 0) {
|
||||
$.ajax({
|
||||
url: '{{ route('checkProjectIsptNumber') }}', // Assume uma URL de verificação específica
|
||||
type: 'GET',
|
||||
data: {
|
||||
number: inputValue,
|
||||
type: type
|
||||
},
|
||||
success: function(response) {
|
||||
if (response.exists) {
|
||||
$(this).css('border', '2px solid red').removeClass(
|
||||
'valid-input').addClass('invalid-input');
|
||||
$('#project-number-exists-' + type).text('Número já existe')
|
||||
.css('color', 'red');
|
||||
} else {
|
||||
$(this).css('border', '2px solid green').removeClass(
|
||||
'invalid-input').addClass('valid-input');
|
||||
$('#project-number-exists-' + type).text('');
|
||||
}
|
||||
updateSubmitButtonState();
|
||||
}.bind(this)
|
||||
});
|
||||
} else {
|
||||
$(this).css('border', '1px solid #ced4da').removeClass('valid-input invalid-input');
|
||||
$('#project-number-exists-' + type).text('');
|
||||
updateSubmitButtonState();
|
||||
}
|
||||
});
|
||||
|
||||
$('#company_select, #user_id, #installationSelect').on('change', function() {
|
||||
updateSubmitButtonState();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
{{-- <script>
|
||||
$(document).ready(function() {
|
||||
var installationSelect = $('#installationSelect');
|
||||
|
|
@ -424,6 +458,39 @@ function updateSubmitButtonState() {
|
|||
installationSelect.append('<option value="new_install">Criar instalação</option>');
|
||||
newCompanyDiv.hide();
|
||||
|
||||
// $('#company_select').change(function() {
|
||||
// var companyId = $(this).val();
|
||||
|
||||
// if (companyId === '#' || companyId === '') {
|
||||
// $('#companyProjectManager').hide();
|
||||
// $('#installationField').hide();
|
||||
// newCompanyDiv.hide();
|
||||
// return;
|
||||
// }
|
||||
|
||||
// $('#companyProjectManager').show();
|
||||
// $('#installationField').show();
|
||||
|
||||
// userManagerSelect.empty();
|
||||
// userManagerSelect.append('<option value="#">Selecione um usuário...</option>');
|
||||
|
||||
// installationSelect.empty();
|
||||
// installationSelect.append('<option value="#">Selecione uma instalação...</option>');
|
||||
// installationSelect.append('<option value="new_install">Criar instalação</option>');
|
||||
|
||||
// $.get('/api/installations?company_id=' + companyId, function(response) {
|
||||
// response.users.forEach(function(user) {
|
||||
// userManagerSelect.append('<option value="' + user.user_id + '">' +
|
||||
// user.user_name + '</option>');
|
||||
// });
|
||||
|
||||
// response.installations.forEach(function(plant) {
|
||||
// installationSelect.append('<option value="' + plant.plant_id +
|
||||
// '">' + plant.plant_name + '</option>');
|
||||
// });
|
||||
// });
|
||||
// });
|
||||
|
||||
$('#company_select').change(function() {
|
||||
var companyId = $(this).val();
|
||||
|
||||
|
|
@ -439,6 +506,8 @@ function updateSubmitButtonState() {
|
|||
|
||||
userManagerSelect.empty();
|
||||
userManagerSelect.append('<option value="#">Selecione um usuário...</option>');
|
||||
userManagerSelect.append(
|
||||
'<option value="ispt">Definir mais tarde...</option>'); // Adiciona nova opção
|
||||
|
||||
installationSelect.empty();
|
||||
installationSelect.append('<option value="#">Selecione uma instalação...</option>');
|
||||
|
|
@ -451,21 +520,25 @@ function updateSubmitButtonState() {
|
|||
});
|
||||
|
||||
response.installations.forEach(function(plant) {
|
||||
installationSelect.append('<option value="' + plant.plant_id + '">' + plant.plant_name + '</option>');
|
||||
installationSelect.append('<option value="' + plant.plant_id +
|
||||
'">' + plant.plant_name + '</option>');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
$('#installationSelect').change(function() {
|
||||
var selectedValue = $(this).val();
|
||||
if (selectedValue === 'new_install') {
|
||||
newCompanyDiv.show();
|
||||
// Adiciona o atributo 'required' para os inputs dentro de #new_company_div
|
||||
$('#new_company_div input[type="text"], #new_company_div select').attr('required', true);
|
||||
$('#new_company_div input[type="text"], #new_company_div select').attr('required',
|
||||
true);
|
||||
} else {
|
||||
newCompanyDiv.hide();
|
||||
// Remove o atributo 'required' quando não é a opção de nova instalação
|
||||
$('#new_company_div input[type="text"], #new_company_div select').removeAttr('required');
|
||||
$('#new_company_div input[type="text"], #new_company_div select').removeAttr(
|
||||
'required');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ class="btn btn-block bg-gradient-primary btn-lg">Articulado</a>
|
|||
</tr>
|
||||
<tr>
|
||||
<td>N.ºobra Cliente :</td>
|
||||
<td>{{ $DatasProject->project_company_number }}</td>
|
||||
<td>{{ $DatasProject->project_company_name }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Resp.Cliente:</td>
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@
|
|||
</tr>
|
||||
<tr>
|
||||
<td>N.º obra Cliente :</td>
|
||||
<td>{{ $DatasProject->project_company_number }}</td>
|
||||
<td>{{ $DatasProject->project_company_name }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@
|
|||
</tr>
|
||||
<tr>
|
||||
<td>N.º obra Cliente :</td>
|
||||
<td>{{ $numberProject->project_company_number }}</td>
|
||||
<td>{{ $numberProject->project_company_name }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Resp.Cliente:</td>
|
||||
|
|
|
|||
|
|
@ -42,11 +42,13 @@
|
|||
</div>
|
||||
<div class="form-group col-sm-6">
|
||||
<label>Nº. obra ISPT</label>
|
||||
{{-- <input type="number" name="n_project_ispt" class="form-control"
|
||||
placeholder="Nº. obra ISPT…"
|
||||
value="{{ $projects->project_ispt_number }}"> --}}
|
||||
<input type="number" name="n_project_ispt" class="form-control" data-type="ispt"
|
||||
placeholder="Nº. obra ISPT…" value="{{ $projects->project_ispt_number }}">
|
||||
|
||||
{{-- <input type="text" name="n_project_ispt" class="form-control" data-type="ispt"
|
||||
placeholder="Nº. obra ISPT…" value="{{ $projects->project_ispt_number }}"> --}}
|
||||
|
||||
<input type="text" name="n_project_ispt" class="form-control" data-type="ispt"
|
||||
placeholder="{{ __('messages.createProject.ispt_project_number') }}…"
|
||||
value="{{ $projects->project_ispt_number }}" required>
|
||||
|
||||
<div id="project-number-exists-ispt"></div>
|
||||
|
||||
|
|
@ -57,13 +59,35 @@
|
|||
<label>Responsável obra ISPT</label>
|
||||
<input type="text" name="responsible_project_ispt" class="form-control"
|
||||
placeholder="Responsável obra ISPT…"
|
||||
value="{{ $projects->project_ispt_number }}">
|
||||
value="{{ $projects->project_ispt_responsible }}">
|
||||
</div>
|
||||
<div class="form-group col-sm-6">
|
||||
<label>Responsável obra Empresa</label>
|
||||
<input type="text" name="responsible_project_company" class="form-control"
|
||||
placeholder="Responsável obra cliente…"
|
||||
value="{{ $projects->project_company_responsible }}">
|
||||
|
||||
<select class="form-control" name="responsible_project_company"
|
||||
id="responsible_project_company">
|
||||
<!-- Opção para mostrar o gestor atual, sempre como a primeira opção se existir -->
|
||||
@if ($projects->NameCompanyManager)
|
||||
<option value="{{ $projects->NameCompanyManagerID }}">
|
||||
{{ $projects->NameCompanyManager }}</option>
|
||||
@endif
|
||||
|
||||
<!-- Opção para não ter gestor atribuído, apenas se NameCompanyManagerID não for null -->
|
||||
@if ($projects->NameCompanyManagerID !== null)
|
||||
<option value="undefined">Gestor da empresa ainda não atribuído...</option>
|
||||
@endif
|
||||
|
||||
<!-- Lista todos os gestores disponíveis, exceto o atual -->
|
||||
@foreach ($receiveAllCompanyManager as $companyManager)
|
||||
@if ($companyManager->user_id != $projects->NameCompanyManagerID)
|
||||
<option value="{{ $companyManager->user_id }}">
|
||||
{{ $companyManager->user->user_name }}</option>
|
||||
@endif
|
||||
@endforeach
|
||||
</select>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
@ -84,29 +108,6 @@
|
|||
|
||||
</div>
|
||||
|
||||
|
||||
{{-- <div class="row">
|
||||
|
||||
<div class="form-group col-sm-6" id="companyField">
|
||||
<label>Empresa Nova </label>
|
||||
<select class="form-control" name="user_id" id="company_select">
|
||||
<option value="#">Selecione uma Empresa...</option>
|
||||
@foreach ($companies as $company)
|
||||
<option value="{{ $company->user_id }}">{{ $company->user_name }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-sm-6" id="installationField" hidden>
|
||||
<label>Instalação Nova</label>
|
||||
<select class="form-control" name="installation_id" id="installationSelect">
|
||||
|
||||
<!-- As opções de instalação serão preenchidas dinamicamente -->
|
||||
</select>
|
||||
</div>
|
||||
|
||||
</div> --}}
|
||||
|
||||
<div class="row" id="new_company_div">
|
||||
|
||||
<div class="form-group col-sm-6">
|
||||
|
|
@ -131,19 +132,16 @@
|
|||
|
||||
<div class="row">
|
||||
<div class="form-group col-sm-6">
|
||||
<label>Nº. de obra Empresa</label>
|
||||
{{-- <input type="number" name="project_company_number" class="form-control"
|
||||
placeholder="Nº. de obra cliente…"
|
||||
value="{{ $projects->project_company_number }}"> --}}
|
||||
<input type="number" name="project_company_number" class="form-control"
|
||||
<label>Nome da obra. Empresa</label>
|
||||
<input type="text" name="project_company_name" class="form-control"
|
||||
data-type="company" placeholder="Nº. de obra cliente…"
|
||||
value="{{ $projects->project_company_number }}">
|
||||
value="{{ $projects->project_company_name }}">
|
||||
<div id="project-number-exists-company"></div>
|
||||
</div>
|
||||
|
||||
<!-- Date -->
|
||||
<div class="form-group col-sm-6">
|
||||
<label>Data inicio obra:</label>
|
||||
<label>Data inicio prevista da obra:</label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text">
|
||||
|
|
@ -151,7 +149,7 @@
|
|||
</span>
|
||||
</div>
|
||||
<input type="text" class="form-control "
|
||||
value="{{ \Carbon\Carbon::parse($projects->date_started)->format('d/m/Y') }}"
|
||||
value="{{ \Carbon\Carbon::parse($projects->date_started)->format('d/m/Y H:i:s') }}"
|
||||
readonly>
|
||||
<input type="hidden" name="date_started_present"
|
||||
value="{{ $projects->date_started }}">
|
||||
|
|
@ -231,7 +229,7 @@ class="btn btn-primary next float-right mt-3">Articulado</a>
|
|||
</div>
|
||||
|
||||
<!-- SCript para verificar se Numeros ->obra ISPT e obra Empresa, nao podem ser repetidos -->
|
||||
<script>
|
||||
{{-- <script>
|
||||
function updateSubmitButtonState() {
|
||||
// Verifica se existe algum input inválido
|
||||
var anyInvalid = $('.invalid-input').length > 0;
|
||||
|
|
@ -241,7 +239,7 @@ function updateSubmitButtonState() {
|
|||
|
||||
$(document).ready(function() {
|
||||
// Define um ouvinte de evento para quando o valor dos inputs muda
|
||||
$('input[name="n_project_ispt"], input[name="project_company_number"]').on('input', function() {
|
||||
$('input[name="n_project_ispt"], input[name="project_company_name"]').on('input', function() {
|
||||
var number = $(this).val();
|
||||
var type = $(this).data('type');
|
||||
var projectId = $('input[name="projectId"]').val();
|
||||
|
|
@ -281,9 +279,104 @@ function updateSubmitButtonState() {
|
|||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</script> --}}
|
||||
|
||||
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
function updateSubmitButtonState() {
|
||||
var inputsValid = $('.valid-input').length === 2;
|
||||
var selectsValid = $('#company_select').val() !== '#' &&
|
||||
$('#user_id').val() !== '#' &&
|
||||
$('#installationSelect').val() !== '#';
|
||||
|
||||
$('#submitButton').prop('disabled', !(inputsValid && selectsValid));
|
||||
}
|
||||
|
||||
var projectId = $('input[name="projectId"]').val();
|
||||
|
||||
$('input[name="n_project_ispt"]').on('input', function(e) {
|
||||
var inputValue = $(this).val();
|
||||
// Permite apenas números e hífens, remove outros caracteres
|
||||
var validValue = inputValue.replace(/[^0-9-]/g, '');
|
||||
$(this).val(validValue); // Atualiza o campo com o valor válido
|
||||
|
||||
var type = $(this).data('type');
|
||||
|
||||
if (validValue.length > 0) {
|
||||
$.ajax({
|
||||
url: '{{ route('checkProjectIsptNumber') }}' + (projectId ? '/' +
|
||||
projectId : ''),
|
||||
type: 'GET',
|
||||
data: {
|
||||
number: validValue, // Envia o valor como o usuário digitou, incluindo hífens
|
||||
type: type
|
||||
},
|
||||
success: function(response) {
|
||||
// Se o número já existir e não for do projeto atual, marca como inválido
|
||||
if (response.exists && !response.isCurrentProjectNumber) {
|
||||
$(this).css('border', '2px solid red').addClass('invalid-input')
|
||||
.removeClass('valid-input');
|
||||
$('#project-number-exists-' + type).text('Número já existe')
|
||||
.css('color', 'red');
|
||||
} else {
|
||||
// Se o número não existir ou for do projeto atual, marca como válido
|
||||
$(this).css('border', '2px solid green').addClass('valid-input')
|
||||
.removeClass('invalid-input');
|
||||
$('#project-number-exists-' + type).text('');
|
||||
}
|
||||
updateSubmitButtonState(); // Atualiza o estado do botão
|
||||
}.bind(this)
|
||||
});
|
||||
} else {
|
||||
$(this).css('border', '1px solid #ced4da').removeClass('valid-input invalid-input');
|
||||
$('#project-number-exists-' + type).text('');
|
||||
updateSubmitButtonState();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// Para input[name="project_company_name"]
|
||||
$('input[name="project_company_name"]').on('input', function() {
|
||||
var inputValue = $(this).val();
|
||||
var type = $(this).data('type');
|
||||
|
||||
if (inputValue.length > 0) {
|
||||
$.ajax({
|
||||
url: '{{ route('checkProjectIsptNumber') }}' + (projectId ? '/' +
|
||||
projectId : ''),
|
||||
type: 'GET',
|
||||
data: {
|
||||
number: inputValue,
|
||||
type: type
|
||||
},
|
||||
success: function(response) {
|
||||
if (response.exists) {
|
||||
$(this).css('border', '2px solid red').removeClass(
|
||||
'valid-input').addClass('invalid-input');
|
||||
$('#project-number-exists-' + type).text('Número já existe')
|
||||
.css('color', 'red');
|
||||
} else {
|
||||
$(this).css('border', '2px solid green').removeClass(
|
||||
'invalid-input').addClass('valid-input');
|
||||
$('#project-number-exists-' + type).text('');
|
||||
}
|
||||
updateSubmitButtonState();
|
||||
}.bind(this)
|
||||
});
|
||||
} else {
|
||||
$(this).css('border', '1px solid #ced4da').removeClass('valid-input invalid-input');
|
||||
$('#project-number-exists-' + type).text('');
|
||||
updateSubmitButtonState();
|
||||
}
|
||||
});
|
||||
|
||||
$('#company_select, #user_id, #installationSelect').on('change', function() {
|
||||
updateSubmitButtonState();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -174,8 +174,8 @@ class="form-control">
|
|||
name: 'company_project_description'
|
||||
},
|
||||
{
|
||||
data: 'project_company_number',
|
||||
name: 'project_company_number'
|
||||
data: 'project_company_name',
|
||||
name: 'project_company_name'
|
||||
},
|
||||
{
|
||||
data: 'project_ispt_responsible',
|
||||
|
|
|
|||
|
|
@ -129,8 +129,8 @@
|
|||
name: 'plant_name'
|
||||
},
|
||||
{
|
||||
data: 'project_company_number',
|
||||
name: 'project_company_number'
|
||||
data: 'project_company_name',
|
||||
name: 'project_company_name'
|
||||
},
|
||||
{
|
||||
data: 'company_project_description',
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user