| Server IP : 162.214.74.102 / Your IP : 216.73.217.46 Web Server : Apache System : Linux dedi-4363141.lrsys.com.br 3.10.0-1160.119.1.el7.tuxcare.els25.x86_64 #1 SMP Wed Oct 1 17:37:27 UTC 2025 x86_64 User : lrsys ( 1015) PHP Version : 5.6.40 Disable Function : exec,passthru,shell_exec,system MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /home/lrsys/www/lrsys_apps/mundotennis/application/plugins/module_events/assets/js/ |
Upload File : |
var device;
function setup(device) {
return device.open()
.then(() => device.selectConfiguration(1))
.then(() => device.claimInterface(0))
}
function printUsb(copies) {
console.log(device);
// var text_pacient = $( "#patient_id option:selected" ).text().split(' | ');
// var name = text_pacient[0].toUpperCase().substring(0, 25);
//
// var idade = 'NÃO INFORMADO';
// if (text_pacient[1] != '')
// {
// idade = text_pacient[1];
// }
//
// var data = $('#date').val();
//
// var convenio = $( "#agreement_id option:selected" ).text().toUpperCase().substring(0, 20);
//
// var valor = '';
// if(convenio == 'PARTICULAR')
// {
// valor = ' VALOR: '+$( "#value_total_patient" ).text();
// }
//
// // Pego o solicitante
// var solicitante_aux = 'PROCURA DIRETA';
// if($( "#requester_id option:selected" ).text() != '')
// {
// solicitante_aux = $( "#requester_id option:selected" ).text();
// }
//
// var solicitante = solicitante_aux.toUpperCase().substring(0, 30);
// var exame = $( "#select_procedure_0 option:selected" ).text().toUpperCase().substring(0, 30);
// var prontuario = $('#patient_id').val();
var STX = '\x02';
var CR = '\x0D';
var ESC = '\X1B';
// var string = STX+'Q'+CR;
var string = STX+'KI<7';
string += STX+'KI70x01'+CR;
string += STX+'e'+CR;
string += STX+'j'+CR;
string += STX+'m'+CR;
string += STX+'M0600'+CR;
// string += STX+'V1'+CR;
string += STX+'L'+CR;
string += 'D11'+CR;
string += '190000202000060NOME: GGGGG'+CR;
string += '190000202000060NOME: '+name+' ('+idade+')'+CR;
string += '190000201500850N.: '+prontuario+CR;
string += '190000201500060EXAME:'+exame+CR;
string += '190000201000060SOLICITANTE: ' +solicitante+CR;
string += '190000200500060'+convenio+' DATA: '+data+valor+CR;
string += 'Q000'+copies+CR;
string += 'E'+CR;
// string += STX+'f999'+CR;
string += STX+'Q'+CR;
// string = STX+'T';
var encoder = new TextEncoder();
var data = encoder.encode(string);
device.open()
.then(() => device.selectConfiguration(1))
.then(() => device.claimInterface(1))
device.transferOut(1, data)
.then(teste => console.log(teste))
.catch(error => { console.log(error); })
console.log(string);
}
function connectAndPrint(copies) {
if (device == null)
{
navigator.usb.requestDevice({ filters: [{ vendorId: 0x1664 }] })
.then(selectedDevice => {
device = selectedDevice;
console.log(device);
return setup(device);
})
.then(() => printUsb(copies))
.catch(error => { console.log(error); })
}
else
{
printUsb(copies);
}
}
//function verifyPrinter() {
//
//
// if (device == null)
// {
// navigator.usb.requestDevice({ filters: [{ vendorId: 0x1664 }] })
// .then(selectedDevice => {
// device = selectedDevice;
// console.log(device);
// return setup(device);
// })
// .catch(error => { console.log(error); })
// }
// else
// {
// console.log('SELECIONADO');
// }
//}
navigator.usb.getDevices()
.then(devices => {
if (devices.length > 0) {
device = devices[0];
return setup(device);
}
console.log(devices);
})
.catch(error => { console.log(error); });