updating qrcode structure and qrcode verification system in job tasks
This commit is contained in:
parent
aaa479ef32
commit
2ce2e0d455
|
|
@ -6,6 +6,7 @@
|
|||
use App\Models\EquipmentWorkHistory;
|
||||
use App\Models\Plant;
|
||||
use App\Models\Unit;
|
||||
use App\Models\User;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\CompanyProject;
|
||||
use App\Models\ConstructionWorkstation;
|
||||
|
|
@ -415,6 +416,38 @@ public function enterWorkstation()
|
|||
return view('workstations/index');
|
||||
}
|
||||
|
||||
// public function receiveExecutionProject($ProjectId)
|
||||
// {
|
||||
// $DatasProject = CompanyProject::find($ProjectId);
|
||||
// $equipmentsTypes = EquipmentType::all();
|
||||
|
||||
// $receivePlant = Plant::where('plant_id', $DatasProject->plant_id)->first();
|
||||
// $receiveCompany = Company::where('company_id', $receivePlant->company_id)->first();
|
||||
|
||||
// // 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])
|
||||
// ->get();
|
||||
|
||||
// // Adicionando a nova coluna realPassword
|
||||
// $filteredUsers->map(function ($user) {
|
||||
// $user->realPassword = explode('@', $user->email)[0];
|
||||
// return $user;
|
||||
// });
|
||||
|
||||
// $receiveDetailsWs = ConstructionWorkstation::where('name_workstations',$filteredUsers->user_name)->get();
|
||||
|
||||
// //Deve buscar o nome do posto de trabalho tambem.
|
||||
// // Retornando a view com os dados necessários
|
||||
// return view('projectsClients/executionProjectNew', [
|
||||
// 'DatasProject' => $DatasProject,
|
||||
// 'equipmentsTypes' => $equipmentsTypes,
|
||||
// 'receiveCompany' => $receiveCompany,
|
||||
// 'filteredUsers' => $filteredUsers
|
||||
// ]);
|
||||
// }
|
||||
|
||||
public function receiveExecutionProject($ProjectId)
|
||||
{
|
||||
$DatasProject = CompanyProject::find($ProjectId);
|
||||
|
|
@ -423,12 +456,35 @@ public function receiveExecutionProject($ProjectId)
|
|||
$receivePlant = Plant::where('plant_id', $DatasProject->plant_id)->first();
|
||||
$receiveCompany = Company::where('company_id', $receivePlant->company_id)->first();
|
||||
|
||||
// return view('projectsClients/executionProject')
|
||||
return view('projectsClients/executionProjectNew')
|
||||
->with('DatasProject', $DatasProject)
|
||||
->with('equipmentsTypes', $equipmentsTypes)
|
||||
->with('receiveCompany', $receiveCompany);
|
||||
// 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])
|
||||
->get();
|
||||
|
||||
// Adicionando a nova coluna realPassword
|
||||
$filteredUsers->map(function ($user) {
|
||||
$user->realPassword = explode('@', $user->email)[0];
|
||||
return $user;
|
||||
});
|
||||
|
||||
// Busca todos os workstations relevantes
|
||||
$allWorkstations = ConstructionWorkstation::whereIn('name_workstations', $filteredUsers->pluck('user_name'))->get()->keyBy('name_workstations');
|
||||
|
||||
// Adicionando a nomenclatura de workstation aos usuários filtrados
|
||||
$filteredUsers->map(function ($user) use ($allWorkstations) {
|
||||
if (isset ($allWorkstations[$user->user_name])) {
|
||||
$user->nomenclature_workstation = $allWorkstations[$user->user_name]->nomenclature_workstation;
|
||||
}
|
||||
return $user;
|
||||
});
|
||||
// Retornando a view com os dados necessários
|
||||
return view('projectsClients/executionProjectNew', [
|
||||
'DatasProject' => $DatasProject,
|
||||
'equipmentsTypes' => $equipmentsTypes,
|
||||
'receiveCompany' => $receiveCompany,
|
||||
'filteredUsers' => $filteredUsers
|
||||
]);
|
||||
}
|
||||
|
||||
public function changeFromExecutionToPlanning($projectID)
|
||||
|
|
|
|||
|
|
@ -73,98 +73,180 @@ class PreparedProjectController extends Controller
|
|||
// $mpdf->Output('equipamentos_projeto_' . $projectId . '.pdf', 'I');
|
||||
// }
|
||||
|
||||
|
||||
// public function showAllEquipmentsInProjectForQrCode($projectId)
|
||||
// {
|
||||
// $equipments = Equipment::where('company_projects_id', $projectId)->get();
|
||||
|
||||
// $equipmentData = [];
|
||||
// foreach ($equipments as $equipment) {
|
||||
// $qrCode = new QrCode($equipment->equipment_tag);
|
||||
// $writer = new PngWriter();
|
||||
// $qrCodeImage = 'data:image/png;base64,' . base64_encode($writer->write($qrCode)->getString());
|
||||
|
||||
// $associatedEquipments = QrcodesAssociatedEquipment::where('equipment_id', $equipment->equipment_id)->get();
|
||||
// $associatedArray = [];
|
||||
// foreach ($associatedEquipments as $associatedEquipment) {
|
||||
// $associatedArray[$associatedEquipment->id] = $associatedEquipment->component_tag;
|
||||
// }
|
||||
|
||||
// $equipmentData[] = [
|
||||
// 'equipment' => $equipment,
|
||||
// 'qrCodeImage' => $qrCodeImage,
|
||||
// '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');
|
||||
// }
|
||||
|
||||
// // dd($equipmentData);
|
||||
|
||||
// $html = view('projectsClients.showAllEquipmentsInProjectQrCodePdf', [
|
||||
// 'equipmentData' => $equipmentData,
|
||||
// 'logoPath' => $logoPath
|
||||
// ])->render();
|
||||
|
||||
// $mpdf = new \Mpdf\Mpdf([
|
||||
// 'mode' => 'utf-8',
|
||||
// 'format' => 'A4'
|
||||
// ]);
|
||||
// $mpdf->WriteHTML($html);
|
||||
// $mpdf->Output('equipamentos_projeto_' . $projectId . '.pdf', 'I');
|
||||
// }
|
||||
|
||||
public function showAllEquipmentsInProjectForQrCode($projectId)
|
||||
{
|
||||
$equipments = Equipment::where('company_projects_id', $projectId)->get();
|
||||
|
||||
$equipmentData = [];
|
||||
foreach ($equipments as $equipment) {
|
||||
$qrCode = new QrCode($equipment->equipment_tag);
|
||||
$writer = new PngWriter();
|
||||
$qrCodeImage = 'data:image/png;base64,' . base64_encode($writer->write($qrCode)->getString());
|
||||
|
||||
$associatedEquipments = QrcodesAssociatedEquipment::where('equipment_id', $equipment->equipment_id)->get();
|
||||
$associatedArray = [];
|
||||
|
||||
foreach ($associatedEquipments as $associatedEquipment) {
|
||||
$associatedArray[$associatedEquipment->id] = $associatedEquipment->component_tag;
|
||||
$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,
|
||||
'qrCodeImage' => $qrCodeImage,
|
||||
'associatedArray' => $associatedArray
|
||||
];
|
||||
}
|
||||
|
||||
$detailsCompanyProject = CompanyProject::find($projectId);
|
||||
$detailsPlant = Plant::where('plant_id', $detailsCompanyProject->plant_id)->first();
|
||||
|
||||
$detailsCompany= Company::where('company_id', $detailsPlant->company_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');
|
||||
}
|
||||
|
||||
// dd($equipmentData);
|
||||
|
||||
$html = view('projectsClients.showAllEquipmentsInProjectQrCodePdf', [
|
||||
'equipmentData' => $equipmentData,
|
||||
'logoPath' => $logoPath
|
||||
])->render();
|
||||
|
||||
$mpdf = new \Mpdf\Mpdf([
|
||||
'mode' => 'utf-8',
|
||||
'format' => 'A4'
|
||||
]);
|
||||
$mpdf = new \Mpdf\Mpdf(['mode' => 'utf-8', 'format' => 'A4']);
|
||||
$mpdf->WriteHTML($html);
|
||||
$mpdf->Output('equipamentos_projeto_' . $projectId . '.pdf', 'I');
|
||||
}
|
||||
|
||||
|
||||
|
||||
// public function showDetailsEquipmentForQrCode($equipmentId, $projectId)
|
||||
// {
|
||||
// $detailsEquipment = Equipment::find($equipmentId);
|
||||
|
||||
// // Gera o QR Code
|
||||
// $qrCode = new QrCode($detailsEquipment->equipment_tag);
|
||||
// $writer = new PngWriter();
|
||||
|
||||
// // Converte o QR Code para base64 para incorporar na página
|
||||
// $qrCodeImage = 'data:image/png;base64,' . base64_encode($writer->write($qrCode)->getString());
|
||||
|
||||
// $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');
|
||||
// }
|
||||
|
||||
// $associatedEquipments = QrcodesAssociatedEquipment::where('equipment_id', $detailsEquipment->equipment_id)->get();
|
||||
|
||||
// $associatedArray = [];
|
||||
// foreach ($associatedEquipments as $associatedEquipment) {
|
||||
// $associatedArray[$associatedEquipment->id] = $associatedEquipment->component_tag;
|
||||
// }
|
||||
|
||||
// $html = view('projectsClients.showDetailsEquipmentForQrCodePdf', [
|
||||
// 'detailsEquipment' => $detailsEquipment,
|
||||
// 'logoPath' => $logoPath,
|
||||
// 'qrCodeImage' => $qrCodeImage,
|
||||
// 'associatedArray' => $associatedArray
|
||||
// ])->render();
|
||||
|
||||
// // Define a orientação da folha como horizontal (Landscape)
|
||||
// $mpdf = new \Mpdf\Mpdf([
|
||||
// 'mode' => 'utf-8',
|
||||
// 'format' => 'A4' // Define o formato como A4 e orientação como Landscape (horizontal)
|
||||
// ]);
|
||||
// $mpdf->WriteHTML($html);
|
||||
// $mpdf->Output('nome_do_arquivo.pdf', 'I');
|
||||
// }
|
||||
|
||||
public function showDetailsEquipmentForQrCode($equipmentId, $projectId)
|
||||
{
|
||||
$detailsEquipment = Equipment::find($equipmentId);
|
||||
|
||||
// Gera o QR Code
|
||||
$qrCode = new QrCode($detailsEquipment->equipment_tag);
|
||||
$writer = new PngWriter();
|
||||
|
||||
// Converte o QR Code para base64 para incorporar na página
|
||||
$qrCodeImage = 'data:image/png;base64,' . base64_encode($writer->write($qrCode)->getString());
|
||||
|
||||
$detailsCompanyProject = CompanyProject::find($projectId);
|
||||
$detailsPlant = Plant::where('plant_id', $detailsCompanyProject->plant_id)->first();
|
||||
|
||||
$detailsCompany= Company::where('company_id', $detailsPlant->company_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');
|
||||
}
|
||||
|
||||
|
||||
$associatedEquipments = QrcodesAssociatedEquipment::where('equipment_id', $detailsEquipment->equipment_id)->get();
|
||||
|
||||
$associatedArray = [];
|
||||
$qrCodeImages = [];
|
||||
|
||||
foreach ($associatedEquipments as $associatedEquipment) {
|
||||
$associatedArray[$associatedEquipment->id] = $associatedEquipment->component_tag;
|
||||
$qrCode = new QrCode($associatedEquipment->component_tag);
|
||||
$writer = new PngWriter();
|
||||
$qrCodeImages[$associatedEquipment->id] = 'data:image/png;base64,' . base64_encode($writer->write($qrCode)->getString());
|
||||
}
|
||||
|
||||
$html = view('projectsClients.showDetailsEquipmentForQrCodePdf', [
|
||||
'detailsEquipment' => $detailsEquipment,
|
||||
'logoPath' => $logoPath,
|
||||
'qrCodeImage' => $qrCodeImage,
|
||||
'qrCodeImages' => $qrCodeImages,
|
||||
'associatedArray' => $associatedArray
|
||||
])->render();
|
||||
|
||||
// Define a orientação da folha como horizontal (Landscape)
|
||||
$mpdf = new \Mpdf\Mpdf([
|
||||
'mode' => 'utf-8',
|
||||
'format' => 'A4' // Define o formato como A4 e orientação como Landscape (horizontal)
|
||||
]);
|
||||
$mpdf = new \Mpdf\Mpdf(['mode' => 'utf-8', 'format' => 'A4']);
|
||||
$mpdf->WriteHTML($html);
|
||||
$mpdf->Output('nome_do_arquivo.pdf', 'I');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -94,7 +94,6 @@ public function receiveQuestionsEquipment($equipmentID)
|
|||
|
||||
public function receiveAnswersEquipment(Request $request, $control_equipment_workstation_id)
|
||||
{
|
||||
|
||||
//No request recebemos ID(NUmero da tarela elementar) , esta variavel vai receber este ID apos selerar o id da string
|
||||
$elementalTaskID = 0;
|
||||
|
||||
|
|
|
|||
|
|
@ -520,7 +520,6 @@ function(qrCodeMessage) {
|
|||
});
|
||||
});
|
||||
</script> --}}
|
||||
|
||||
{{-- <script>
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
|
||||
|
|
@ -565,7 +564,6 @@ function checkInputAndToggleSubmit() {
|
|||
checkInputAndToggleSubmit();
|
||||
});
|
||||
</script> --}}
|
||||
|
||||
{{-- <script>
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
|
||||
|
|
@ -753,9 +751,6 @@ function processQRCode(qrCodeMessage) {
|
|||
|
||||
});
|
||||
</script> --}}
|
||||
|
||||
|
||||
|
||||
{{-- <script>
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
|
||||
|
|
@ -834,7 +829,6 @@ function updateUIBasedOnQRCodeResult(formId, isValid) {
|
|||
});
|
||||
});
|
||||
</script> --}}
|
||||
|
||||
{{-- <script>
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
|
||||
|
|
@ -1040,18 +1034,18 @@ function processQRCode(qrCodeMessage, qrCodeError, qrCodeErrorText, verification
|
|||
</script> --}}
|
||||
|
||||
|
||||
{{-- Novo teste --}}
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
|
||||
// let scannerCheck;
|
||||
// let isScanning = false; // Estado global de escaneamento
|
||||
{{-- Novo teste --}}
|
||||
{{-- <script>
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
|
||||
//Para leitura do Qrcode
|
||||
let scannerCheck = new Html5Qrcode("readerUnique");
|
||||
let startScanCheck = document.getElementById("startScanUnique");
|
||||
let readerCheck = document.getElementById("readerUnique");
|
||||
|
||||
// Modal de confirmacao para equipamentos manualmente
|
||||
let ModalForConfirmManual = document/getElementById('exampleModalSmall');
|
||||
const btnConfirmManual = document.getElementById('btnConfirmManual');
|
||||
|
||||
let currentFormId = ''; // Variável para armazenar o ID do formulário ativo
|
||||
|
|
@ -1061,7 +1055,8 @@ function processQRCode(qrCodeMessage, qrCodeError, qrCodeErrorText, verification
|
|||
button.addEventListener('click', function() {
|
||||
currentFormId = this.getAttribute('data-form-id');
|
||||
console.log(` ${currentFormId}`); // Exibe o ID do formulário atual
|
||||
// const submitButton = document.querySelector(`${formSelector} #checkValidateQrCode`);
|
||||
// Tirei do comentario , ver se faz diferenca no code
|
||||
const submitButton = document.querySelector(`${formSelector} #checkValidateQrCode`);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
@ -1078,12 +1073,20 @@ function processQRCode(qrCodeMessage, qrCodeError, qrCodeErrorText, verification
|
|||
qrbox: 250
|
||||
}, function(qrCodeMessage) {
|
||||
// Chamada quando um QR Code é detectado
|
||||
processQRCode(qrCodeMessage,currentFormId);
|
||||
processQRCode(qrCodeMessage, currentFormId);
|
||||
// startScan(currentFormId); // Inicia a leitura com base no formulário ativo
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
ModalForConfirmManual.addEventListener('',function(){
|
||||
btnConfirmManual(currentFormId)
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function processQRCode(qrCodeMessage, currentFormId) {
|
||||
scannerCheck.stop().then(() => {
|
||||
// Separa o valor do QR code.
|
||||
|
|
@ -1097,7 +1100,7 @@ function processQRCode(qrCodeMessage, currentFormId) {
|
|||
@endif
|
||||
|
||||
//Verifica se o form atual espera receber o valor : Obturador ou Flange
|
||||
const expectedComponente = (currentFormId == "form10") ? "Obturador" : "Flange";
|
||||
const expectedComponente = (currentFormId == "form10") ? "Obturador" : "Flange";
|
||||
|
||||
const expectedValor = expectedTag[0];
|
||||
let receiveValueValidateQRcode; //
|
||||
|
|
@ -1106,7 +1109,8 @@ function processQRCode(qrCodeMessage, currentFormId) {
|
|||
|
||||
const qrCodeError = document.querySelector(`${formSelector} #qrCodeError`);
|
||||
const qrCodeErrorText = document.querySelector(`${formSelector} #qrCodeErrorText`);
|
||||
const verificationStatusP = document.querySelector(`${formSelector} #verificationStatus`);
|
||||
const verificationStatusP = document.querySelector(
|
||||
`${formSelector} #verificationStatus`);
|
||||
|
||||
const confirmCheckbox = document.querySelector(
|
||||
`${formSelector} input[name^='ID'][name$='[confirm_label_compliance-checkbox]']`
|
||||
|
|
@ -1139,7 +1143,7 @@ function processQRCode(qrCodeMessage, currentFormId) {
|
|||
|
||||
// Ajusta o estado do botão de submit com base no resultado da verificação.
|
||||
const submitButton = document.querySelector(
|
||||
`${formSelector} #checkValidateQrCode`); // Ajuste o seletor conforme necessário.
|
||||
`${formSelector} #checkValidateQrCode`); // Ajuste o seletor conforme necessário.
|
||||
|
||||
console.log(submitButton);
|
||||
|
||||
|
|
@ -1169,33 +1173,224 @@ function stopScan(currentFormId) {
|
|||
const confirmCheckbox = document.querySelector(
|
||||
`${formSelector} input[name^='ID'][name$='[confirm_label_compliance-checkbox]']`
|
||||
);
|
||||
console.log(confirmCheckbox);
|
||||
});
|
||||
}
|
||||
|
||||
btnConfirmManual.addEventListener('click', function() {
|
||||
|
||||
const formSelector = `#${currentFormId}`;
|
||||
btnConfirmManual.addEventListener('click', function(currentFormId) {
|
||||
|
||||
// const qrCodeError = document.querySelector(`${formSelector} #qrCodeError`);
|
||||
// const verificationStatusP = document.querySelector(`${formSelector} #verificationStatus`);
|
||||
// // Constrói o nome do input dinamicamente com base no ID do formulário atual
|
||||
// const inputNameSelector =
|
||||
// `input[name='ID${currentFormId.replace('form', '')}[confirm_label_compliance-checkbox]']`;
|
||||
// const confirmCheckbox = document.querySelector(`${formSelector} ${inputNameSelector}`);
|
||||
// if (!confirmCheckbox) {
|
||||
// console.error("Elemento confirmCheckbox não encontrado.");
|
||||
// return;
|
||||
// }
|
||||
const formSelector = `#${currentFormId}`; // Seletor do formulário atual
|
||||
const confirmCheckbox = document.querySelector(
|
||||
`${formSelector} input[name^='ID'][name$='[confirm_label_compliance-checkbox]']`);
|
||||
|
||||
// Define 'receiveValueValidateQRcode' para 0.
|
||||
let receiveValueValidateQRcode = 0;
|
||||
confirmCheckbox.value =
|
||||
receiveValueValidateQRcode; // Atualiza o valor do checkbox para refletir a confirmação manual.
|
||||
|
||||
const verificationStatusP = document.querySelector(`${formSelector} #verificationStatus`);
|
||||
verificationStatusP.textContent = 'Etiquetas confirmadas manualmente';
|
||||
verificationStatusP.style.color = 'orange'; // Altera a cor do texto conforme necessário.
|
||||
|
||||
// Ajusta o estado do botão de submit com base no resultado da verificação.
|
||||
const submitButton = document.querySelector(`${formSelector} #checkValidateQrCode`);
|
||||
submitButton.disabled = receiveValueValidateQRcode !== 1;
|
||||
|
||||
// Para o scanner de QR Code (se necessário)
|
||||
scannerCheck.stop().then(() => {
|
||||
// Esconde o leitor de QR Code e mostra o botão para iniciar a leitura
|
||||
readerCheck.style.display = "none";
|
||||
startScanCheck.style.display = "block";
|
||||
|
||||
// Fecha modais após confirmação
|
||||
$('#exampleModalSmall').modal('hide'); // Fecha a segunda modal.
|
||||
$('#exampleModal').modal('hide'); // Fecha a primeira modal.
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
});
|
||||
</script> --}}
|
||||
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
let scannerCheck = new Html5Qrcode("readerUnique");
|
||||
let startScanCheck = document.getElementById("startScanUnique");
|
||||
let readerCheck = document.getElementById("readerUnique");
|
||||
let ModalForConfirmManual = document.getElementById('exampleModalSmall');
|
||||
const btnConfirmManual = document.getElementById('btnConfirmManual');
|
||||
|
||||
let currentFormId = ''; // Variável global para armazenar o ID do formulário ativo
|
||||
|
||||
// Captura cliques em botões que abrem a primeira modal e extrai o ID do formulário
|
||||
document.querySelectorAll('[data-toggle="modal"]').forEach(button => {
|
||||
button.addEventListener('click', function() {
|
||||
if (this.dataset.target ===
|
||||
"#exampleModal") { // Verifica se o botão abre a primeira modal
|
||||
currentFormId = this.getAttribute('data-form-id');
|
||||
console.log(`Current Form ID: ${currentFormId}`);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Evento de clique para iniciar a leitura do QR Code
|
||||
startScanCheck.addEventListener('click', function() {
|
||||
startScanCheck.style.display = "none";
|
||||
readerCheck.style.display = "block";
|
||||
|
||||
// Inicia o scanner de QR Code com configurações específicas
|
||||
scannerCheck.start({
|
||||
facingMode: "environment" // Usa a câmera traseira
|
||||
}, {
|
||||
fps: 10,
|
||||
qrbox: 250
|
||||
}, function(qrCodeMessage) {
|
||||
// Chamada quando um QR Code é detectado
|
||||
processQRCode(qrCodeMessage, currentFormId);
|
||||
// startScan(currentFormId); // Inicia a leitura com base no formulário ativo
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
function processQRCode(qrCodeMessage, currentFormId) {
|
||||
scannerCheck.stop().then(() => {
|
||||
// Separa o valor do QR code.
|
||||
const parts = qrCodeMessage.split('@');
|
||||
const valor = parts[0];
|
||||
const componente = parts[1];
|
||||
|
||||
//verica se existe $receiveComponentTag e se nao e vazio, se nao for separa a varaivel e guarda o valor antes do @
|
||||
@if (isset($receiveComponentTag) && !empty($receiveComponentTag))
|
||||
var expectedTag = "{{ $receiveComponentTag }}".split('@');
|
||||
@endif
|
||||
|
||||
//Verifica se o form atual espera receber o valor : Obturador ou Flange
|
||||
const expectedComponente = (currentFormId == "form10") ? "Obturador" : "Flange";
|
||||
|
||||
const expectedValor = expectedTag[0];
|
||||
let receiveValueValidateQRcode; //
|
||||
// Seleciona os elementos específicos do formulário ativo.
|
||||
const formSelector = `#${currentFormId}`;
|
||||
|
||||
const qrCodeError = document.querySelector(`${formSelector} #qrCodeError`);
|
||||
const qrCodeErrorText = document.querySelector(`${formSelector} #qrCodeErrorText`);
|
||||
const verificationStatusP = document.querySelector(
|
||||
`${formSelector} #verificationStatus`);
|
||||
|
||||
const confirmCheckbox = document.querySelector(
|
||||
`${formSelector} input[name^='ID'][name$='[confirm_label_compliance-checkbox]']`
|
||||
);
|
||||
|
||||
|
||||
// const btnConfirmManual = document.getElementById('btnConfirmManual');
|
||||
// Processa a leitura do QR Code.
|
||||
if (valor == expectedValor && componente == expectedComponente) {
|
||||
receiveValueValidateQRcode = 1; // Atualiza para 1 (confirmado).
|
||||
verificationStatusP.textContent = 'Verificado com sucesso !!!';
|
||||
verificationStatusP.style.color = 'green';
|
||||
$('#exampleModal').modal('hide'); // Fecha a modal após confirmação.
|
||||
qrCodeError.style.display = 'none';
|
||||
} else {
|
||||
$('#exampleModal').modal('hide'); // Fecha a modal após confirmação.
|
||||
verificationStatusP.textContent =
|
||||
'Tags não correspondem ao mesmo equipamento, tente novamente com a Tag correta !!!';
|
||||
verificationStatusP.style.color = 'red';
|
||||
qrCodeErrorText.textContent =
|
||||
`QR Lido: ${valor}@${componente} ||| Esperado: ${expectedValor}@${expectedComponente}`;
|
||||
qrCodeErrorText.style.color = 'red';
|
||||
qrCodeError.style.display = 'block';
|
||||
}
|
||||
// Apos finalizar a leitura, deve voltar a poder utilizar a leitura do QrCode se necessario.
|
||||
readerCheck.style.display = "none";
|
||||
startScanCheck.style.display = "block";
|
||||
// Atualiza o valor do input no formulário com o resultado da verificação.
|
||||
confirmCheckbox.value = receiveValueValidateQRcode;
|
||||
|
||||
// Ajusta o estado do botão de submit com base no resultado da verificação.
|
||||
const submitButton = document.querySelector(
|
||||
`${formSelector} #checkValidateQrCode`); // Ajuste o seletor conforme necessário.
|
||||
|
||||
console.log(submitButton);
|
||||
|
||||
submitButton.disabled = receiveValueValidateQRcode !== 1;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Configura o evento de clique para o botão que para a leitura do QR Code
|
||||
document.getElementById('stopQrcodeRead').addEventListener('click', function() {
|
||||
// Para o scanner de QR Code e executa ações de limpeza da interface
|
||||
stopScan(currentFormId);
|
||||
});
|
||||
|
||||
//Função para parar a leitura do QR Code e limpar a interface
|
||||
function stopScan(currentFormId) {
|
||||
scannerCheck.stop().then(() => {
|
||||
readerCheck.style.display = "none";
|
||||
startScanCheck.style.display = "block";
|
||||
//Recebe o form atual
|
||||
const formSelector = `#${currentFormId}`;
|
||||
|
||||
const qrCodeError = document.querySelector(`${formSelector} #qrCodeError`);
|
||||
const verificationStatusP = document.querySelector(
|
||||
`${formSelector} #verificationStatus`);
|
||||
|
||||
//De acordo com o form atual, devolve o nome do input referente ao numero do form atual
|
||||
const confirmCheckbox = document.querySelector(
|
||||
`${formSelector} input[name^='ID'][name$='[confirm_label_compliance-checkbox]']`
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// Tratar equipamentos feitos Manualmente.
|
||||
// Adiciona listener para quando o botão da segunda modal for clicado
|
||||
document.querySelector('[data-toggle="modal"][data-target="#exampleModalSmall"]').addEventListener(
|
||||
'click',
|
||||
function() {
|
||||
// Aqui você garante que o currentFormId ainda esteja correto e pode fazer o que precisar antes de abrir a segunda modal
|
||||
console.log(`Passing Current Form ID to second modal: ${currentFormId}`);
|
||||
});
|
||||
btnConfirmManual.addEventListener('click', function() {
|
||||
// Agora, currentFormId deve estar correto e acessível aqui
|
||||
confirmManually(currentFormId);
|
||||
});
|
||||
|
||||
function confirmManually(formId) {
|
||||
const formSelector = `#${formId}`;
|
||||
// Operações baseadas no formId...
|
||||
console.log(`Manual Confirmation for Form ID: ${formId}`);
|
||||
|
||||
const confirmCheckbox = document.querySelector(
|
||||
`${formSelector} input[name^='ID'][name$='[confirm_label_compliance-checkbox]']`);
|
||||
|
||||
// Define 'receiveValueValidateQRcode' para 0.
|
||||
let receiveValueValidateQRcode = 0;
|
||||
confirmCheckbox.value =
|
||||
receiveValueValidateQRcode; // Atualiza o valor do checkbox para refletir a confirmação manual.
|
||||
|
||||
const verificationStatusP = document.querySelector(`${formSelector} #verificationStatus`);
|
||||
verificationStatusP.textContent = 'Etiquetas confirmadas manualmente';
|
||||
verificationStatusP.style.color = 'orange'; // Altera a cor do texto conforme necessário.
|
||||
|
||||
// Ajusta o estado do botão de submit com base no resultado da verificação.
|
||||
const submitButton = document.querySelector(`${formSelector} #checkValidateQrCode`);
|
||||
submitButton.disabled = receiveValueValidateQRcode !== 0;
|
||||
|
||||
$('#exampleModalSmall').modal('hide'); // Fecha a segunda modal.
|
||||
$('#exampleModal').modal('hide'); // Fecha a primeira modal.
|
||||
// Para o scanner de QR Code (se necessário)
|
||||
scannerCheck.stop().then(() => {
|
||||
// Esconde o leitor de QR Code e mostra o botão para iniciar a leitura
|
||||
readerCheck.style.display = "none";
|
||||
startScanCheck.style.display = "block";
|
||||
// Fecha modais após confirmação
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -39,22 +39,25 @@
|
|||
<a href="#" type="button" class="btn btn-block bg-primary btn-lg"
|
||||
style="margin-bottom: 2%;"> Equipamentos</a>
|
||||
</div>
|
||||
|
||||
<div class="col-sm" id="ViewWorkstationButton">
|
||||
<a href="#" type="button" class="btn btn-block bg-primary btn-lg"
|
||||
style="margin-bottom: 2%;">Postos de Trabalho</a>
|
||||
</div>
|
||||
|
||||
<div class="col-sm" id="ViewTasksButton">
|
||||
<a href="#" type="button" class="btn btn-block bg-primary btn-lg"
|
||||
style="margin-bottom: 2%;">Tarefas</a>
|
||||
</div>
|
||||
|
||||
{{-- <div class="col-sm" id="ViewWorkstationButton">
|
||||
<a href="#" type="button" class="btn btn-block bg-primary btn-lg"
|
||||
style="margin-bottom: 2%;">Postos de Trabalho</a>
|
||||
</div> --}}
|
||||
</div>
|
||||
|
||||
<div class="card card-primary" id="CardViewDetails">
|
||||
<div class="card-header">
|
||||
<h3 class="text-center">Detalhes da Obra</h3>
|
||||
<h3 class="card-title">Detalhes da Obra</h3>
|
||||
</div>
|
||||
<div class="card-body p-0">
|
||||
|
||||
<table class="table table-striped text-center">
|
||||
<tbody>
|
||||
<tr>
|
||||
|
|
@ -111,10 +114,13 @@
|
|||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary"
|
||||
data-dismiss="modal">Fechar</button>
|
||||
<form action="{{ route('changeFromExecutionToPlanning', ['projectID' => $DatasProject->company_projects_id]) }}" method="post">
|
||||
@csrf
|
||||
<button type="submit" class="btn btn-primary">Alterar para Planeamento</button>
|
||||
</form>
|
||||
<form
|
||||
action="{{ route('changeFromExecutionToPlanning', ['projectID' => $DatasProject->company_projects_id]) }}"
|
||||
method="post">
|
||||
@csrf
|
||||
<button type="submit" class="btn btn-primary">Alterar para
|
||||
Planeamento</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -139,6 +145,40 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card card-primary" id="CardViewWorkstations">
|
||||
<div class="card-header">
|
||||
<h3 class="card-title">Postos de Trabalho</h3>
|
||||
<div class="card-tools">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card-body">
|
||||
|
||||
<table class="table table-striped text-center">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Nome do Posto</th>
|
||||
<th>Login</th>
|
||||
<th>Senha</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
@foreach ($filteredUsers as $user)
|
||||
<tr>
|
||||
<td>{{ $user->nomenclature_workstation}}</td>
|
||||
<td>{{ $user->email }}</td>
|
||||
<td>{{ $user->realPassword }}</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
<!-- Adicione mais linhas conforme necessário -->
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="card card-primary" id="CardViewTasks">
|
||||
<div class="card-header">
|
||||
<h3 class="card-title">Tarefas</h3>
|
||||
|
|
@ -151,6 +191,8 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
{{-- <div class="card card-primary" id="CardViewWorkstations">
|
||||
<div class="card-header">
|
||||
<h3 class="card-title">Postos de Trabalho</h3>
|
||||
|
|
@ -178,6 +220,7 @@
|
|||
</div> --}}
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
|
@ -187,70 +230,71 @@
|
|||
<script>
|
||||
$(document).ready(function() {
|
||||
// Ja vai ser inicializado no card Equipamentos.
|
||||
$("#ViewEquipmentsButton").hide();
|
||||
$("#CardViewTasks").hide();
|
||||
$("#CardViewWorkstations").hide();
|
||||
$("#CardViewDetails").hide();
|
||||
// $("#ViewEquipmentsButton").hide();
|
||||
// $("#CardViewTasks").hide();
|
||||
// $("#CardViewWorkstations").hide();
|
||||
// $("#CardViewDetails").hide();
|
||||
|
||||
//Visualizacao das Tarefas
|
||||
$("#ViewTasksButton").on('click', function() {
|
||||
// $("#ViewTasksButton").on('click', function() {
|
||||
|
||||
$("#CardViewTasks").show();
|
||||
$("#ViewEquipmentsButton").show();
|
||||
$("#ViewWorkstationButton").show();
|
||||
$("#ViewDetailsButton").show();
|
||||
// $("#CardViewTasks").show();
|
||||
// $("#ViewEquipmentsButton").show();
|
||||
// $("#ViewWorkstationButton").show();
|
||||
// $("#ViewDetailsButton").show();
|
||||
|
||||
$("#CardViewDetails").hide();
|
||||
$("#CardViewEquipments").hide();
|
||||
$("#CardViewWorkstations").hide();
|
||||
$("#ViewTasksButton").hide();
|
||||
})
|
||||
// $("#CardViewDetails").hide();
|
||||
// $("#CardViewEquipments").hide();
|
||||
// $("#CardViewWorkstations").hide();
|
||||
// $("#ViewTasksButton").hide();
|
||||
// })
|
||||
|
||||
//Visualizacao dos Equipamentos
|
||||
$("#ViewEquipmentsButton").on('click', function() {
|
||||
// $("#ViewEquipmentsButton").on('click', function() {
|
||||
|
||||
$("#CardViewEquipments").show();
|
||||
// $("#CardViewEquipments").show();
|
||||
|
||||
$("#ViewTasksButton").show();
|
||||
$("#ViewWorkstationButton").show();
|
||||
$("#ViewDetailsButton").show();
|
||||
// $("#ViewTasksButton").show();
|
||||
// $("#ViewWorkstationButton").show();
|
||||
// $("#ViewDetailsButton").show();
|
||||
|
||||
$("#CardViewDetails").hide();
|
||||
$("#CardViewTasks").hide();
|
||||
$("#CardViewWorkstations").hide();
|
||||
$("#ViewEquipmentsButton").hide();
|
||||
})
|
||||
// $("#CardViewDetails").hide();
|
||||
// $("#CardViewTasks").hide();
|
||||
// $("#CardViewWorkstations").hide();
|
||||
// $("#ViewEquipmentsButton").hide();
|
||||
// })
|
||||
|
||||
//Visualizacao das Workstatios
|
||||
$("#ViewWorkstationButton").on('click', function() {
|
||||
// $("#ViewWorkstationButton").on('click', function() {
|
||||
|
||||
$("#CardViewWorkstations").show();
|
||||
$("#ViewEquipmentsButton").show();
|
||||
$("#ViewTasksButton").show();
|
||||
$("#ViewDetailsButton").show();
|
||||
// $("#CardViewWorkstations").show();
|
||||
|
||||
// $("#ViewEquipmentsButton").show();
|
||||
// $("#ViewTasksButton").show();
|
||||
// $("#ViewDetailsButton").show();
|
||||
|
||||
|
||||
$("#CardViewDetails").hide();
|
||||
$("#CardViewEquipments").hide();
|
||||
$("#CardViewTasks").hide();
|
||||
$("#ViewWorkstationButton").hide();
|
||||
})
|
||||
// $("#CardViewDetails").hide();
|
||||
// $("#CardViewEquipments").hide();
|
||||
// $("#CardViewTasks").hide();
|
||||
// $("#ViewWorkstationButton").hide();
|
||||
// })
|
||||
|
||||
$("#ViewDetailsButton").on('click', function() {
|
||||
// $("#ViewDetailsButton").on('click', function() {
|
||||
|
||||
$("#CardViewDetails").show();
|
||||
// $("#CardViewDetails").show();
|
||||
|
||||
$("#ViewDetailsButton").hide();
|
||||
$("#ViewEquipmentsButton").show();
|
||||
$("#ViewTasksButton").show();
|
||||
$("#ViewWorkstationButton").show();
|
||||
// $("#ViewDetailsButton").hide();
|
||||
// $("#ViewEquipmentsButton").show();
|
||||
// $("#ViewTasksButton").show();
|
||||
// $("#ViewWorkstationButton").show();
|
||||
|
||||
|
||||
$("#CardViewWorkstations").hide();
|
||||
$("#CardViewEquipments").hide();
|
||||
$("#CardViewTasks").hide();
|
||||
// $("#CardViewWorkstations").hide();
|
||||
// $("#CardViewEquipments").hide();
|
||||
// $("#CardViewTasks").hide();
|
||||
|
||||
})
|
||||
// })
|
||||
});
|
||||
</script>
|
||||
@endsection
|
||||
|
|
|
|||
|
|
@ -127,11 +127,11 @@
|
|||
@php $globalCounter = 0; @endphp
|
||||
|
||||
@foreach ($equipmentData as $data)
|
||||
@foreach ($data['associatedArray'] as $id => $componentTag)
|
||||
@foreach ($data['associatedArray'] as $component)
|
||||
@php
|
||||
$parts = explode('@', $componentTag);
|
||||
$parts = explode('@', $component['component_tag']);
|
||||
$tagName = $parts[0];
|
||||
$tagType = $parts[1] ?? ''; // Use '??' para evitar erros se '@' não estiver presente
|
||||
$tagType = $parts[1] ?? 'Tipo não especificado'; // Garante que o tipo não seja nulo
|
||||
@endphp
|
||||
|
||||
<div class="box-pai">
|
||||
|
|
@ -149,23 +149,19 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="box-principal">
|
||||
{{-- <img class="qr-code" src="{{ $qrCodeImage }}" alt="QR Code"> --}}
|
||||
<img class="qr-code" src="{{ $data['qrCodeImage'] }}" alt="QR Code">
|
||||
|
||||
<img class="qr-code" src="{{ $component['qrCodeImage'] }}" alt="QR Code de {{ $tagName }}">
|
||||
<div class="title-tag"><b>Tag :</b> {{ $tagName }}</div>
|
||||
<div class="type-tag">{{ $tagType }}</div>
|
||||
|
||||
<div class="col2 col-1">{{ $data['equipment']->equipmentType->equipment_type_name }}</div>
|
||||
<div class="col2 col-2">{{ $data['equipment']->unit->unit_name }}</div>
|
||||
|
||||
<div class="col2-img col-1-img">
|
||||
<img class="img-company" src="{{ public_path('/img/ispt/4.0/galpLogo1.png') }}"
|
||||
alt="Logo Esquerdo">
|
||||
<img class="img-company" src="{{ public_path('/img/ispt/ispt.jpg') }}"
|
||||
alt="Logo Esquerdo">
|
||||
</div>
|
||||
<div class="col2-img col-2-img">
|
||||
<img class="img-istp" src="{{ $logoPath }}"
|
||||
alt="Logo Esquerdo">
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
@ -177,6 +173,7 @@
|
|||
@endforeach
|
||||
@endforeach
|
||||
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
|
|
|||
|
|
@ -152,7 +152,7 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="box-principal">
|
||||
<img class="qr-code" src="{{ $qrCodeImage }}" alt="QR Code">
|
||||
<img class="qr-code" src="{{ $qrCodeImages[$id] }}" alt="QR Code">
|
||||
<div class="title-tag"><b>Tag :</b> {{ $tagName }}</div>
|
||||
<div class="type-tag">{{$tagType}}</div>
|
||||
|
||||
|
|
@ -160,12 +160,12 @@
|
|||
<div class="col2 col-2">{{ $detailsEquipment->unit->unit_name }}</div>
|
||||
|
||||
<div class="col2-img col-1-img">
|
||||
<img class="img-company" src="{{ public_path('/img/ispt/4.0/galpLogo1.png') }}" alt="Logo Esquerdo">
|
||||
<img class="img-company" src="{{ public_path('/img/ispt/ispt.jpg') }}"
|
||||
alt="Logo Esquerdo">
|
||||
</div>
|
||||
|
||||
<div class="col2-img col-2-img">
|
||||
{{-- <img class="img-istp" src="{{ public_path('/img/ispt/4.0/isptLogoVertical.png') }}"
|
||||
alt="Logo Esquerdo"> --}}
|
||||
<img class="img-istp" src="{{ $logoPath }}" alt="Logo da Empresa">
|
||||
<img class="img-istp" src="{{ $logoPath }}" alt="Logo da Empresa">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user