| Server IP : 162.214.74.102 / Your IP : 216.73.216.192 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/erp/application/plugins/module_med_scheduling/assets/js/ |
Upload File : |
/* global parseFloat, _L, $rowNumTab */
$(function () {
// TODO: IMPLEMENTAR NOTIFICAÇÕES
// Notification.requestPermission().then(function(result) {
// var notification = new Notification("New Email Received", {body:'dsaf fdsa fsa fsda<br><a href="https://leo.erp.lrsys.com.br/?ng=dashboard&module=rh">CLIQUE AQUI</a>', icon: "application/storage/system/logo.png" })
// notification.onshow = function() { setTimeout(notification.close, 15000) };
// notification.onclick = function() { console.log('clique') };
// });
var _url = $("#_url").val();
var $calendar_wrap = $("#calendar_wrap");
var renderDataTableFinalizar = false;
$('#queue_number').mask('999');
var carregou=true;
//$('#calendar').fullCalendar( 'gotoDate', date )
var render = 0;
// Verifico se é pra mostrar o header com filtro de data
var headerCalendar = null;
var erp_list_view = getCookie("erp_list_view");
if (erp_list_view == "")
{
headerCalendar = 'agendaDay agendaWeek month listYear';
}
var ib_calendar_options = {
customButtons: {
custom1: {
text: _L['Structured List'],
click: function (e) {
// $('#structured_list').toggleClass('hidden');
// $('#calendar').find('.fc-view-container').toggleClass('hidden');
// console.log(e);
if ($(this).hasClass('btn-checked-calendar')) {
document.cookie = "erp_list_view=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
} else {
setCookie("erp_list_view", "Y", 365);
}
verifyCookie();
location.reload();
}
},
datePickerButton: {
// icon: 'down-triangle',
text: _L['Date'],
click: function () {
var $btnCustom = $('.fc-datePickerButton-button');
$btnCustom.datepicker({
language: $("#_lan").val(),
autoclose: true
});
$btnCustom.datepicker('show')
.on("changeDate", function (e, v) {
$('#calendar').fullCalendar('gotoDate', moment(e.date).format());
$btnCustom.datepicker('hide');
});
}
}
},
eventAfterAllRender: function ( ) {
renderDataTableFinalizar = true;
// $('#structured_list').footable();
// $("#structured_list").DataTable({
// retrieve: true,
// paging: false,
// searching: false,
//// columnDefs : [
//// {type : 'date', targets : [3]}
//// ],
// });
// $('.footable').data('footable-sort').doSort(1, true);
},
header: {
left: 'prev,next today datePickerButton',
center: 'title',
right: headerCalendar
},
eventResize: function (event, delta, revertFunc, jsEvent, ui, view) {
bootbox.confirm(_L['Scheduling Do you want to change the appointment schedule?'] + "<br/>" + event.title + "<br/>" + _L['Scheduling Hour Start'] + " : <b>" + event.start.format($("#_formatDate").val().toUpperCase() + ' HH:mm') + '</b><br/>' + _L['Scheduling Hour Finish'] + " : <b>" + event.end.format($("#_formatDate").val().toUpperCase() + ' HH:mm') + "</b>", function (result) {
if (result) {
$.post(_url + 'module_med_scheduling/scheduling/postEditShedulling/', {id: event.id, hour_start: event.start.format('HH:mm'), hour_finish: event.end.format('HH:mm'), date: event.end.format($("#_formatDate").val().toUpperCase())})
.done(function (data) {
if (data == 'OK') {
toastr.success(_L['edit_successful']);
} else {
toastr.error(data);
revertFunc();
}
});
} else {
revertFunc();
}
});
},
eventDrop: function (event, delta, revertFunc, jsEvent, ui, view) {
$(".popover ").addClass('hide');
bootbox.confirm(_L['Scheduling Do you want to change the appointment schedule?'] + "<br/>" + event.title + "<br/>" + _L['Scheduling Hour Start'] + " : <b>" + event.start.format($("#_formatDate").val().toUpperCase() + ' HH:mm') + '</b><br/>' + _L['Scheduling Hour Finish'] + " : <b>" + event.end.format($("#_formatDate").val().toUpperCase() + ' HH:mm') + "</b>",
function (result) {
if (result) {
$.post(_url + 'module_med_scheduling/scheduling/postEditShedulling/', {id: event.id, hour_start: event.start.format('HH:mm'), hour_finish: event.end.format('HH:mm'), date: event.end.format($("#_formatDate").val().toUpperCase())})
.done(function (data) {
if (data == 'OK') {
toastr.success(_L['edit_successful']);
} else {
toastr.error(data);
revertFunc();
}
});
} else {
revertFunc();
}
}
);
},
loading: function (isLoading, view) {
if (isLoading) {
$calendar_wrap.block({message: block_msg});
} else {
$calendar_wrap.unblock();
$('[data-toggle="tooltip"]').tooltip();
}
$('#structured_list > tbody').empty();
},
defaultView: ib_list_calendar,
navLinks: true,
editable: true,
droppable: true,
minTime: minTime,//'07:00:00',
maxTime: maxTime,// '19:00:00',
slotDuration: interval,//"00:20:00",
eventLimit: false,
lang: ib_lang,
isRTL: ib_rtl,
eventSources: [{
url: _url + 'module_med_scheduling/scheduling/dataCalendar/',
type: 'GET',
error: function () {
bootbox.alert("Unable to load data.");
},
complete: function (data) {
// console.log(data.responseJSON);
var compactlist = $("#scheduling_compactlist").val();
console.log($("#scheduling_compactlist").val());
// Trato os procedimentos
var zero_queue = new Array();
$.each(data.responseJSON, function (index, event) {
// Pego os procedimentos
var procedures = '';
var procedures_med = '';
$.each(event.procedures, function (index, value) {
procedures = procedures+value.description +'<br/>';
procedures_med = procedures_med+value.description +' | ';
});
procedures = ' <b>Procedimentos:</b><br/> '+procedures.substring(0, procedures.length - 5);
procedures_med = '<span style="font-size: 10px;"> | '+procedures_med.substring(0, procedures_med.length - 3)+'</span>';
var role_hidden = '';
var procedures_aux = '';
if(compactlist == 'Y')
{
role_hidden = 'hide';
procedures_aux = procedures_med;
}
var style = 'style="color:#FFF; background-color:' + event.color + '"';
var date_view = "<td " + style + " class='date_list_info' data-sort-value ='"+event.date_view_order+"'>" + event.date_view + "</td>";
var queue_number = event.queue_number;
if(queue_number == null)
{
zero_queue.push(event);
queue_number = 0;
return;
}
console.log(event.saldoPatient);
// Adiciono o agendamento na tabela do dia
$("#structured_list").find('tbody')
.append('<tr ' + style + ' class="' + render + '">\n\
<td ' + style + '>' + event.option + '</td>\n\
<td ' + style + '>' + queue_number + '</td>' + date_view + '\
<td ' + style + ' class="date_list_info">' + event.hour_start.substr(0,5) + '</td>\n\
<td ' + style + ' class="table-hide-tablet '+(role_hidden)+'">' + event.diary + '</td>\n\
<td data-toggle="tooltip" id="shed_'+event.id+'" ' + style + '>\n\
<a class="edit_shedulling" style="color:#FFF;" data-id="'+event.id+'" href="#">' + event.account +procedures_aux+ '</a>\n\
</td>\n\
<td ' + style + '>' + event.desc_status + '</td>\n\
<td ' + style + '>' + event.professional_name + '</td></td>\n\
<td ' + style + ' class="table-hide-tablet">' + event.agreement_company_name + '</td>\n\
<td class="table-hide-tablet '+(role_hidden)+'" '+(event.saldoPatient==0?style:'style="color:#FFF; background-color:#ec8e00"')+'>'+$("#_curr_code").val() + " " + formatMonetary(parseFloat(event.saldoPatient).toFixed(2) + "")+'</td></tr>');
// Pego os contatos do paciente
var contatos = '';
if (event.contacts)
{
contatos = event.contacts;
};
contatos = contatos.substring(0, contatos.length - 5);
// Pego as observações do agendamento
var observation = '';
if (event.observation)
{
observation = '<br/>Obs: ' + event.observation;
};
var ocurrence = '';
$.ajax({url: $("#_url").val() + "module_med_scheduling/scheduling/listOcurrence/" +event.id, success: function(result){
// ocurrence = result;
var element_hover = $("#shed_"+event.id);
element_hover.attr('title', event.account+' | ID: '+event.patient_id + ' | '+ contatos );
element_hover.attr('onclick', event.onclick);
element_hover.attr('data-toggle', 'tooltip');
element_hover.popover({
content: '<b>'+_L["Diary_Diary"] + ':</b> ' + event.diary + ' | <b>' + _L["Scheduling Created by"] + '</b> ' + event.useradmin_name + '<br/>'
+ procedures + observation+'<br/>'+ocurrence,
trigger: 'hover',
placement: 'auto',
container: 'body',
html: true
});
}});
});
// insiro os agendamentos sem senha
$.each(zero_queue, function (index, event) {
// Pego os procedimentos
var procedures = '';
var procedures_med = '';
$.each(event.procedures, function (index, value) {
procedures = procedures+value.description +'<br/>';
procedures_med = procedures_med+value.description +' | ';
});
procedures = ' <b>Procedimentos:</b><br/> '+procedures.substring(0, procedures.length - 5);
procedures_med = '<span style="font-size: 10px;"> | '+procedures_med.substring(0, procedures_med.length - 3)+'</span>';
var role_hidden = '';
var procedures_aux = '';
if(compactlist == 'Y')
{
role_hidden = 'hide';
procedures_aux = procedures_med;
}
var style = 'style="color:#FFF; background-color:' + event.color + '"';
var date_view = "<td " + style + " class='date_list_info' data-sort-value ='"+event.date_view_order+"'>" + event.date_view + "</td>";
var queue_number = event.queue_number;
if(queue_number == null)
{
queue_number ='-';
}
// Adiciono o agendamento na tabela do dia
$("#structured_list").find('tbody')
.append('<tr ' + style + ' class="' + render + '">\n\
<td ' + style + '>' + event.option + '</td>\n\
<td ' + style + '>' + queue_number + '</td>' + date_view + '\
<td ' + style + ' class="date_list_info">' + event.hour_start.substr(0,5) + '</td>\n\
<td class="table-hide-tablet '+(role_hidden)+'" ' + style + '>' + event.diary + '</td>\n\
<td data-toggle="tooltip" id="shed_'+event.id+'" ' + style + '>\n\
<a class="edit_shedulling" style="color:#FFF;" data-id="'+event.id+'" href="#">' + event.account + procedures_aux +'</a>\n\
</td>\n\
<td ' + style + '>' + event.desc_status + '</td>\n\
<td ' + style + '>' + event.professional_name + '</td></td>\n\
<td class="table-hide-tablet" ' + style + '>' + event.agreement_company_name + '</td>\n\
<td class="table-hide-tablet '+(role_hidden)+'" '+(event.saldoPatient==0?style:'style="color:#FFF; background-color:#ec8e00"')+'>'+$("#_curr_code").val() + " " + formatMonetary(parseFloat(event.saldoPatient).toFixed(2) + "")+'</td></tr>');
// Pego os contatos do paciente
var contatos = '';
if (event.contacts)
{
contatos = event.contacts;
};
contatos = ''+contatos.substring(0, contatos.length - 5);
// Pego as observações do agendamento
var observation = '';
if (event.observation)
{
observation = '<br/>Obs: ' + event.observation;
};
var ocurrence = '';
$.ajax({
url: $("#_url").val() + "module_med_scheduling/scheduling/listOcurrence/" +event.id,
success: function(result){
// ocurrence = result;
var element_hover = $("#shed_"+event.id);
element_hover.attr('title', event.account+' | ID: '+event.patient_id + ' | '+ contatos );
element_hover.attr('onclick', event.onclick);
element_hover.attr('data-toggle', 'tooltip');
element_hover.popover({
content: '<b>'+_L["Diary_Diary"] + ':</b> ' + event.diary + ' | <b>' + _L["Scheduling Created by"] + '</b> ' + event.useradmin_name + '<br/>'
+ procedures + observation+'<br/>'+ocurrence,
trigger: 'hover',
placement: 'auto',
container: 'body',
html: true
});
}});
});
var view = $('#calendar').fullCalendar('getView');
if (view.name == 'agendaDay')
{
$(".date_list_info").addClass("hide");
} else {
$(".date_list_info").removeClass("hide");
}
}
}],
eventRender: function (event, element) {
// element.attr('title', event.account+' | ID: '+event.patient_id);
// element.attr('onclick', event.onclick);
// element.attr('data-toggle', 'tooltip');
var observation = '';
if (event.observation)
{
observation = '<br/>Obs: ' + event.observation;
};
var contatos = '';
if (event.contacts)
{
contatos = event.contacts;
};
contatos = ''+contatos.substring(0, contatos.length - 5);
// Trato os procedimentos
var procedures = '';
$.each(event.procedures, function (index, value) {
procedures = procedures+value.description +'<br/>';
});
procedures = ' <b>Procedimentos:<br/></b> '+procedures.substring(0, procedures.length - 5);
var ocurrence = '';
$.ajax({url: $("#_url").val() + "module_med_scheduling/scheduling/listOcurrence/" +event.id, success: function(result){
// ocurrence = result;
element.attr('title', event.account+' | ID: '+event.patient_id + ' | '+ contatos );
element.attr('onclick', event.onclick);
element.attr('data-toggle', 'tooltip');
element.popover({
content: '<b>'+_L["Diary_Diary"] + ':</b> ' + event.diary + ' | <b>' + _L["Scheduling Created by"] + '</b> ' + event.useradmin_name + '<br/>'
+ procedures + observation+'<br/>'+ocurrence,
trigger: 'hover',
placement: 'auto',
container: 'body',
html: true
});
}});
if (!event.url) {
element.click(function () {
view_event(event.id);
});
}
},
dayClick: function (date) {
// $modal.modal('show');
date = date.format();
var $modal = $('#ajax-modal');
$modal.load(_url + 'module_med_scheduling/scheduling/add/modal', {date: date}, function () {
$modal.modal({
backdrop: 'static',
keyboard: false
});
$("#diary_id").html($("#diary_option_selected").html());
initScheduling();
$("[data-toggle='toggle']").bootstrapToggle();
$("#hour_start").trigger("blur");
});
return false;
},
firstDay: parseInt(ib_calendar_first_day),
defaultDate: moment(ib_date_calendar),
timeFormat: 'HH:mm',
slotLabelFormat: ['HH:mm'],
height: 'auto',
allDaySlot: false,
// agendaEventMinHeight: 200,
// eventDrop: function(event, delta, revertFunc) {
//
// alert(event.title + " was dropped on " + event.start.format());
//
// if (!confirm("Are you sure about this change?")) {
// revertFunc();
// }
//
// }
};
$('#calendar').fullCalendar(ib_calendar_options);
function view_event(id) {
var $modal = $('#ajax-modal');
$modal.load(_url + 'module_med_scheduling/scheduling/edit/' + id + "/modal", "", function () {
$modal.modal({
backdrop: 'static',
keyboard: false
});
initScheduling();
$("[data-toggle='toggle']").bootstrapToggle();
$(".emsgbody-occurrence-edit").addClass("hide");
$(".table-occurrence").html("");
$(".table-occurrence").load($("#_url").val() + "module_med_scheduling/scheduling/listOcurrence/" + id);
});
}
$('#ajax-modal').on('click', '#register_occurrence', function (e) {
e.preventDefault();
console.log($("#id").val());
$.post($("#_url").val() + "module_med_scheduling/scheduling/postOcurrence/", {obs: $("#modal_occurrence_obs").val(), status: $("#occurrence_status").val(), module_med_scheduling_id: $("#scheduling_id").val()})
.done(function (data) {
if (data == "OK") {
$("#occurrence_obs").val("");
$("#ajax-modal .emsgbody-occurrence").addClass("hide");
$(".table-occurrence").html();
$(".table-occurrence").load($("#_url").val() + "module_med_scheduling/scheduling/listOcurrence/" + $('#scheduling_id').val());
} else {
bootbox.alert(data);
}
});
});
//verifica o cookie para setar a visualização
verifyCookie();
function verifyCookie() {
var erp_list_view = getCookie("erp_list_view");
if (erp_list_view != "") {
$(".fc-custom1-button").addClass("btn-checked-calendar");
$('#structured_list').removeClass('hidden');
$('#calendar').find('.fc-view-container').addClass('hidden');
$('#btn_add_scheduling').removeClass('hide');
$('#btn_structured_list').addClass('hide');
} else {
$(".fc-custom1-button").removeClass("btn-checked-calendar");
$('#structured_list').addClass('hidden');
$('#calendar').find('.fc-view-container').removeClass('hidden');
$('#btn_add_scheduling').addClass('hide');
$('#btn_structured_list').removeClass('hide');
}
}
$("#structured_list").on("click", ".edit_shedulling", function (e) {
view_event($(this).data("id"));
});
$("#structured_list").on("click", ".delete_payment", function (e)
{
var id = $(this).data("id");
bootbox.confirm('Estornar Pagamento', function (result) {
if (result)
{
$.ajax({
type: 'POST',
url: $("#_url").val() + "module_med_scheduling/scheduling/delete_payment/",
data: {id: id},
dataType: 'html'
}).done(function (data) {
//se ok remove
//remove com uma vírgula caso encontre o id
console.log(data);
var obj = JSON.parse(data);
// toastr.success(obj.msg);
if (obj.status == 'OK') {
location.reload();
}
else
{
bootbox.alert(obj.msg);
}
});
}
});
});
// Impressão de etiquetas
$("#structured_list").on("click", ".print_label", function (e) {
var scheduling_id = $(this).attr("data-id");
bootbox.prompt({
title: "Deseja imprimir a etiqueta?",
inputType: 'number',
value: 1,
callback: function (result) {
if (result) {
connectAndPrint(result,scheduling_id);
}
}
});
});
var $modal = $('#ajax-modal');
// UPDATE STATUS
$("#structured_list").on("click", ".update_status", function (e) {
$('#modal_status #modal_status_desc').html( $(this).attr("data-text"));
$('#modal_status #modal_status_status').val($(this).attr("data-value"));
$('#modal_status #modal_status_obs').val("");
$('#modal_status #modal_status_module_med_scheduling_id').val($(this).attr("data-id"));
$("#emsgModalAlterStatus").addClass("hide");
// $('#modal_status').modal('show');
$.post($("#_url").val() + "module_med_scheduling/scheduling/postOcurrence/", $("#formUpdateStatus").serialize())
.done(function (data) {
if (data=="OK") {
if($('#modal_status_status').val() == 'On Hold')
{
var scheduling_id = $('#modal_status_module_med_scheduling_id').val();
$('.register_payment[data-url="'+$("#_url").val()+'module_med_scheduling/payment/register/'+scheduling_id+'"]').click();
}
$('#modal_status').modal('hide');
$('#ajax-modal-2').modal("hide");
$('#calendar').fullCalendar('removeEvents');
$('#calendar').fullCalendar('refetchEvents');
} else {
var body = $("html, body");
body.animate({scrollTop:0}, '1000', 'swing');
$("#emsgbodyModalAlterStatus").html(data);
$("#emsgModalAlterStatus").removeClass("hide");
$("#emsgModalAlterStatus").show("slow");
}
});
});
// MODAL DE STATUS
$("#modal_status").on('click','#update_status', function (e){
$.post($("#_url").val() + "module_med_scheduling/scheduling/postOcurrence/", $("#formUpdateStatus").serialize())
.done(function (data) {
if (data=="OK") {
if($('#modal_status_status').val() == 'On Hold')
{
var scheduling_id = $('#modal_status_module_med_scheduling_id').val();
$('.register_payment[data-url="'+$("#_url").val()+'module_med_scheduling/payment/register/'+scheduling_id+'"]').click();
}
$('#modal_status').modal('hide');
$('#ajax-modal-2').modal("hide");
$('#calendar').fullCalendar('removeEvents');
$('#calendar').fullCalendar('refetchEvents');
} else {
var body = $("html, body");
body.animate({scrollTop:0}, '1000', 'swing');
$("#emsgbodyModalAlterStatus").html(data);
$("#emsgModalAlterStatus").removeClass("hide");
$("#emsgModalAlterStatus").show("slow");
}
});
});
// OCORRÊNCIAS
$("#structured_list").on("click", ".occurrence", function (e) {
$('#modal_occurrence .status_on_hold').remove();
// verifico se o status é ON HOLD
if($(this).attr("data-status") == 'On Hold')
{
$('#modal_occurrence #modal_occurrence_status').append('<option value ="On Hold" class="status_on_hold">Em Espera</option>');
}
$('#modal_occurrence #modal_occurrence_status').val($(this).attr("data-status"));
$('#modal_occurrence #modal_occurrence_status').select2({
theme: "bootstrap",
width: '100%',
});
if($(this).attr("data-status") == 'Finished')
{
// $('#modal_occurrence #modal_occurrence_status option').remove();
$('#modal_occurrence #modal_occurrence_status').select2('enable',false);
}
else
{
$('#modal_occurrence #modal_occurrence_status').select2('enable',true);
}
$('#modal_occurrence #modal_occurrence_obs').val("");
$('#modal_occurrence #modal_occurrence_module_med_scheduling_id').val($(this).attr("data-id"));
$("#modal_occurrence #emsg-occurrence").addClass("hide");
$('#modal_occurrence').modal('show');
$("#modal_occurrence_table-occurrence").load($("#_url").val() + "module_med_scheduling/scheduling/listOcurrence/" + $(this).attr("data-id"));
});
// AUTORIZAÇÃO
$("#structured_list").on("click", ".tab_autorization", function (e) {
var $modal = $('#ajax-modal');
idShedulling= $(this).data("id");
$modal.load(_url + 'module_med_scheduling/scheduling/modal_add_autorization/' +idShedulling, '', function () {
$modal.modal();
if ($('.date')[0]) {
$(document).ready(function () {
$(".date").datepicker();
$(".contratante_select").on('click', function(e)
{
var row = $(this).data('row');
var agreement_id = $('.agreement_select[data-row='+row+']').val();
findDataSelect(".contratante_select[data-row="+row+"]",'module_med_scheduling/ajax/agreementProfessional/'+agreement_id, "Nenhum selecionado");
});
// Mascaras para os campos
// $('.authorization_code').mask('AAAAAAA');
// $('.tab_number').mask('9999999');
});
}
findDataSelect(".agreement_select",'module_med_scheduling/ajax/agreement/', "");
findDataSelectNotIn(".procedure_select",'module_med_scheduling/ajax/procedureByScheduling/'+idShedulling,"", ".procedure_select");
$rowNumTab=$("#rowNumTab").val();
$("#autorization_items").on("click", ".delete_tab", function (e) {
$(this).closest('tr').remove();
});
$(".agreement_select").on('change', function(e)
{
var row = $(this).data('row');
findDataSelect(".contratante_select[data-row="+row+"]",'module_med_scheduling/ajax/agreementProfessional/'+$(this).val(), "Nenhum selecionado");
});
});
});
// MODAL DE AUTORIZAÇÃO
$('#ajax-modal').on('click','.add_tab', function () {
$("#autorization_items").find('tbody')
.append(
'<tr >\n\
<td ><input type="hidden" name="row[]" value="'+$rowNumTab+'">\n\
<div class="row">\n\
<div class="col-md-3 col-xs-12">\n\
<label>'+_L['Scheduling tab number']+" "+_L['*']+'</label>\n\
<input type="text" class="form-control tab_number" name="tab_number_'+$rowNumTab+'" value="">'
+'</div>'
+'<div class="col-md-3 col-xs-12">'
+'<label>'+_L['Scheduling authorization code']+" "+_L['*']+'</label>'
+'<input type="text" class="form-control authorization_code" name="authorization_code_'+$rowNumTab+'" value="">'
+'</div>'
+'<div class="col-md-3 col-xs-12">'
+'<label>'+_L['Scheduling date authorization']+" "+_L['*']+'</label>'
+'<input type="text" class="form-control date_authorization" name="date_authorization_'+$rowNumTab+'" id="date_authorization_'+$rowNumTab+'"'
+'value="">'
+'</div>'
+'<div class="col-md-3 col-xs-12">'
+'<label>'+_L['Scheduling validaty']+" "+_L['*']+'</label>'
+'<input type="text" class="form-control " name="date_validate_'+$rowNumTab+'" id="date_validate_'+$rowNumTab+'"'
+'value="">'
+'</div>'
+'</div>'
+'<div class="row">'
+'<div class="col-md-3 col-xs-12">'
+'<label>'+_L['Scheduling_Agreement_Module']+" "+_L['*']+'</label>'
+'<select data-row="'+$rowNumTab+'" name="agreement_'+$rowNumTab+'" class="form-control agreement_select agreement_select_'+$rowNumTab+'">'
+'</select>'
+'</div>'
+'<div class="col-md-3 col-xs-12">'
+'<label>'+_L['Scheduling Autorization Profissional']+" "+_L['*']+'</label>'
+'<select data-row="'+$rowNumTab+'" name="contratante_id_'+$rowNumTab+'" class="form-control contratante_select contratante_select_'+$rowNumTab+'">'
+'</select>'
+'</div>'
+'<div class="col-md-6 col-xs-12">'
+'<label>'+_L['Scheduling_Procedure_Module']+" "+_L['*']+'</label>'
+'<select data-row="'+$rowNumTab+'" multiple name="procedures_'+$rowNumTab+'[]" id="procedures_'+$rowNumTab+'" class="form-control procedure_select">'
+'</select>'
+'</div>'
+'</div>'
+'</td>'
+'<td class="middle col-xs-1"> <span class="btn btn-danger btn-xs delete_tab" ><i class="fa fa-trash"></i> </span></td></tr>'
);
$("#date_authorization_" + $rowNumTab).datepicker({
language: $("#_lan").val(),
autoclose: true,
dateFormat: $("#_formatDate").val()
});
$("#date_validate_" + $rowNumTab).datepicker({
language: $("#_lan").val(),
autoclose: true,
dateFormat: $("#_formatDate").val()
});
findDataSelect(".agreement_select_"+$rowNumTab,'module_med_scheduling/ajax/agreement/', "");
findDataSelectNotIn("#procedures_"+$rowNumTab,'module_med_scheduling/ajax/procedureByScheduling/'+idShedulling,"", ".procedure_select");
$(".agreement_select_"+$rowNumTab).on('change', function(e)
{
var row = $(this).data('row');
findDataSelect(".contratante_select[data-row="+row+"]",'module_med_scheduling/ajax/agreementProfessional/'+$(this).val(), "Nenhum selecionado");
});
// Mascaras para os campos
// $('.authorization_code').mask('9999999999');
// $('.tab_number').mask('9999999');
$rowNumTab++;
});
// SUBMIT AUTORIZAÇÃO
$('#ajax-modal').on('click', '.submit_autorization', function (e) {
e.preventDefault();
$.post($("#_url").val() + "module_med_scheduling/scheduling/post_autorization/",$("#form_autorization").serialize())
.done(function (retorno) {
var data =JSON.parse(retorno);
if (data.status == "success") {
$modal.modal("hide");
$('#calendar').fullCalendar('removeEvents');
$('#calendar').fullCalendar('refetchEvents');
bootbox.alert(_L['Scheduling autorized procedures']);
} else {
$("#ajax-modal #emsgbodyModalAutorization").html(data.msg);
$("#ajax-modal #emsgModalAutorization").removeClass("hide");
$("#ajax-modal #emsgModalAutorization").show("slow");
}
});
});
// SUBMIT OCORRÊNCIA
$('#modal_occurrence').on('click', '#modal_register_occurrence', function (e) {
e.preventDefault();
if($("#modal_occurrence_status").val() == "Finished")
{
bootbox.confirm('Tem certeza que deseja FINALIZAR este atendimento?<br/>Depois de FINALIZADO \n\
somente o Administrador do sistema poderá realizar qualquer tipo de alteração.<br>\n\
Caso precise adicionar algum procedimento a este atendimento, mude o status para AGUARDANDO ALTERAÇÃO.', function (result) {
if (result)
{
$.post($("#_url").val() + "module_med_scheduling/scheduling/postOcurrence/", {alter_status:"Y",obs: $("#modal_occurrence_obs").val(), status: $("#modal_occurrence_status").val(), module_med_scheduling_id: $("#modal_occurrence_module_med_scheduling_id").val()})
.done(function (data) {
if (data == "OK") {
$("#modal_occurrence_obs").val("");
$("#emsgModalAlterStatus").addClass("hide");
$("#modal_occurrence_table-occurrence").load($("#_url").val() + "module_med_scheduling/scheduling/listOcurrence/" + $('#modal_occurrence_module_med_scheduling_id').val());
$('#calendar').fullCalendar('removeEvents');
$('#calendar').fullCalendar('refetchEvents');
$('#modal_occurrence').modal('hide');
} else {
$("#modal_occurrence #emsgbody-occurrence").html(data);
$("#modal_occurrence #emsg-occurrence").removeClass("hide");
$("#modal_occurrence #emsg-occurrence").show("slow");
}
});
}
});
}
else
{
$.post($("#_url").val() + "module_med_scheduling/scheduling/postOcurrence/", {alter_status:"Y",obs: $("#modal_occurrence_obs").val(), status: $("#modal_occurrence_status").val(), module_med_scheduling_id: $("#modal_occurrence_module_med_scheduling_id").val()})
.done(function (data) {
if (data == "OK") {
$("#modal_occurrence_obs").val("");
$("#emsgModalAlterStatus").addClass("hide");
$("#modal_occurrence_table-occurrence").load($("#_url").val() + "module_med_scheduling/scheduling/listOcurrence/" + $('#modal_occurrence_module_med_scheduling_id').val());
$('#calendar').fullCalendar('removeEvents');
$('#calendar').fullCalendar('refetchEvents');
$('#modal_occurrence').modal('hide');
} else {
$("#modal_occurrence #emsgbody-occurrence").html(data);
$("#modal_occurrence #emsg-occurrence").removeClass("hide");
$("#modal_occurrence #emsg-occurrence").show("slow");
}
});
}
});
// VISUALIZAR AGENDAMENTO
$("#structured_list").on("click", ".view", function (e) {
var $modal = $('#ajax-modal-2');
var id=$(this).attr("data-id");
$modal.load(_url + 'module_med_scheduling/scheduling/modal_view_shedulling/' + id, '', function () {
$modal.modal();
$(".table-occurrence").load($("#_url").val() + "module_med_scheduling/scheduling/listOcurrence/" + id+"/1");
});
$('#ajax-modal-2').on("click", ".update_status", function (e) {
$('#modal_status #modal_status_desc').html( $(this).attr("data-text"));
$('#modal_status #modal_status_status').val($(this).attr("data-value"));
$('#modal_status #modal_status_obs').val("");
$('#modal_status #modal_status_module_med_scheduling_id').val($(this).attr("data-id"));
$('#modal_status').modal('show');
});
});
// Altera a visualização para Agendamento
$("#btn_add_scheduling").on("click", function (e) {
// $modal.modal('show');
// var data = new Date();
// var ano = data.getFullYear();
// var dia = data.getDate(); // 1-31
// var mes = data.getMonth(); // 0-11 (zero=janeiro)
// var date = ano+'-'+(mes+1)+'-'+dia;
// var $modal = $('#ajax-modal');
// $modal.load(_url + 'module_med_scheduling/scheduling/add/modal', {date: date}, function () {
// $modal.modal();
// $("#diary_id").html($("#diary_option_selected").html());
// initScheduling();
// $("[data-toggle='toggle']").bootstrapToggle();
//
// });
// $('#hour_start').val('');
// return false;
document.cookie = "erp_list_view=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
// $('#btn_structured_list').removeClass('hide');
// $('#btn_add_scheduling').addClass('hide');
location.reload();
});
// Altero a visuação para o modo de Lista de Agendados
$("#btn_structured_list").on("click", function (e)
{
setCookie("erp_list_view", "Y", 365);
location.reload();
});
});