| 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/leo/application/plugins/module_imobles/assets/js/ |
Upload File : |
$(document).ready(function ()
{
var _url = $("#_url").val();
$(".add_objective").on('click', function (e) {
e.preventDefault();
var $modal = $('#ajax-modal');
$modal.load(_url + 'module_imobles/leadshistory/crm_control_item/' + $(this).data("module_imobles_crm_goals_category_id") + "/" + $(this).data('position') + "/" + $(this).data('crm_accounts_id'), function () {
$modal.modal();
$("#emsg-item").hide();
});
});
$("body").on('click', ".edit_objective", function (e) {
e.preventDefault();
var $modal = $('#ajax-modal');
$modal.load(_url + 'module_imobles/leadshistory/crm_control_item/' + $(this).data("module_imobles_crm_goals_category_id") + "/" + $(this).data('position') + "/" + $(this).data('crm_accounts_id') + '/' + $(this).data("id"), function () {
$modal.modal();
$("#emsg-item").hide();
});
});
$("body").on('click', '.submit_item_form', function (e) {
e.preventDefault();
var category = $(this).data("module_imobles_crm_goals_category_id");
var id = $(this).data("id");
$('<input>').attr({
type: 'hidden',
name: 'deal_id',
value: $('#deal_id').val()
}).appendTo('#form-post-item');
$.ajax(
{
type: 'POST',
url: _url + "module_imobles/leadshistory/post_crm_control_item",
data: new FormData($("#form-post-item")[0]),
processData: false,
contentType: false,
success: function (retorno) {
var data = JSON.parse(retorno);
if (data.status == "OK") {
if (id > 0) {
$(".tr_item_" + id).html(data.tds);
} else {
$(".table_objective_empty" + category).remove();
$(".table_objective_" + category).append(data.tr);
$(".table_objective_header" + category).removeClass('hide');
}
$(".row_objective_" + category).addClass("hide");
$(".cancel_item_form").click();
toastr.success(_L['module_imobles save']);
} else {
$("#emsgbody-item").html(data.msg);
$("#emsg-item").show("slow");
}
}
});
});
$("body").on('click', '.delete_comment', function (e) {
e.preventDefault();
var id = $(this).data('id');
var dialog = bootbox.confirm({
message: _L['module_imobles Delete comment?'],
buttons: {
confirm: {
label: _L['Yes'],
className: "btn-primary"
},
cancel: {
label: _L['No'],
className: "btn-danger"
}
},
callback: function (result) {
if (result == true) {
$.post(_url + "module_imobles/leadshistory/delete_crm_control_comment", {id: id})
.done(function (data) {
if (data == "OK") {
$(".tr_comment_" + id).remove();
toastr.success(_L['module_imobles comment delete success']);
} else {
var body = $("html, body");
body.animate({scrollTop: 0}, '1000', 'swing');
$("#emsgbody").html(data);
$("#emsg").show("slow");
}
});
} else {
dialog.modal('hide');
return false;
}
}
});
});
$(".add_comment").on('click', function (e) {
e.preventDefault();
var $modal = $('#ajax-modal');
$modal.load(_url + 'module_imobles/leadshistory/crm_control_comment/' + $(this).data("crm_accounts_id") + "/" + $(this).data('id'), function () {
$modal.modal();
$("#emsg-comment").hide();
});
});
$("body").on('click', '.edit_comment', function (e) {
e.preventDefault();
var $modal = $('#ajax-modal');
$modal.load(_url + 'module_imobles/leadshistory/crm_control_comment/' + $(this).data('crm_accounts_id') + '/' + $(this).data("id"), function () {
$modal.modal();
$("#emsg-comment").hide();
});
});
$("body").on('click', '.submit_comment_form', function (e) {
e.preventDefault();
var id = $(this).data("id");
$('<input>').attr({
type: 'hidden',
name: 'deal_id',
value: $('#deal_id').val()
}).appendTo('#form-post-comment');
$.ajax(
{
type: 'POST',
url: _url + "module_imobles/leadshistory/post_crm_control_comment",
data: new FormData($("#form-post-comment")[0]),
processData: false,
contentType: false,
success: function (retorno) {
var data = JSON.parse(retorno);
if (data.status == "OK") {
if (id > 0) {
$(".tr_comment_" + id).html(data.tds);
} else {
$(".table_commnet").append(data.tr);
}
$(".row_commnet").addClass("hide");
$(".cancel_comment_form").click();
toastr.success(_L['module_imobles save']);
} else {
$("#emsgbody-comment").html(data.msg);
$("#emsg-comment").show("slow");
}
}
});
});
$("body").on('click', '.delete_item_form', function (e) {
e.preventDefault();
var id = $(this).data('id');
var dialog = bootbox.confirm({
message: _L['module_imobles Delete item?'],
buttons: {
confirm: {
label: _L['Yes'],
className: "btn-primary"
},
cancel: {
label: _L['No'],
className: "btn-danger"
}
},
callback: function (result) {
if (result == true) {
$.post(_url + "module_imobles/leadshistory/delete_crm_control_item", {id: id})
.done(function (data) {
if (data == "OK") {
$(".tr_item_" + id).remove();
toastr.success(_L['module_imobles item delete success']);
} else {
var body = $("html, body");
body.animate({scrollTop: 0}, '1000', 'swing');
$("#emsgbody").html(data);
$("#emsg").show("slow");
}
});
} else {
dialog.modal('hide');
return false;
}
}
});
});
//crm_joueney
$('#module_imobles_crm_journey_stages_id').select2({theme: "bootstrap",
width: '100%'});
$("#module_imobles_crm_journey_stages_id").on('change', function (e) {
$('#crm_journey_data').block({ message: block_msg });
e.preventDefault();
var id = $(this).data("crm_accounts_id");
var val = $(this).val();
var deal_id = $('#deal_id').val();
if (val > 0) {
$.get(_url + 'module_imobles/leadshistory/crm_journey_data/' + id + "/" + val+"/"+deal_id, function (j) {
$("#crm_journey_data").html(j);
});
} else {
$("#crm_journey_data").html('');
}
var save_stage = $('#btn_save_journey_stage');
if(save_stage.data('journey_stage_id') != $("#module_imobles_crm_journey_stages_id").val()){
save_stage.removeClass('hide');
} else {
save_stage.addClass('hide');
}
});
$("body").on('click', '#btn_save_journey_stage', function (e) {
e.preventDefault();
var deal_id = $('#deal_id').val();
$.ajax(
{
type: 'POST',
url: _url + "module_imobles/leadshistory/saveNewJourneyStage",
dataType: 'json',
data: {"deal_id": deal_id, "journey_stage_id": $("#module_imobles_crm_journey_stages_id").val()},
success: function (data) {
if (data.status == "OK") {
console.log(data);
toastr.success(_L['module_imobles save']);
} else {
$("#emsgbody-journey").html(data.msg);
$("#emsg-journey").show("slow");
}
}
});
});
if($('#actual_journey_stage_id').val() > 0){
$('#module_imobles_crm_journey_stages_id').val($('#actual_journey_stage_id').val());
$('#module_imobles_crm_journey_stages_id').change();
};
$("body").on('click', '.add_next_stage', function (e) {
e.preventDefault();
var $modal = $('#ajax-modal');
$modal.load(_url + 'module_imobles/leadshistory/crm_journey_data_add/0/' + $("#module_imobles_crm_journey_stages_id").val() + "/" + $(this).data('crm_accounts_id'), function () {
$modal.modal();
$("#emsg-form-journey").hide();
$("#due_date").datepicker({
language: $("#_lan").val(),
autoclose: true,
dateFormat: $("#_formatDate").val()
});
$('#form-post-journey').find("[data-toggle='toggle']").bootstrapToggle();
});
});
$("body").on('click', '.submit_journey_form', function (e) {
e.preventDefault();
var id = $(this).data("id");
$('<input>').attr({
type: 'hidden',
name: 'deal_id',
value: $('#deal_id').val()
}).appendTo('#form-post-journey');
$.ajax(
{
type: 'POST',
url: _url + "module_imobles/leadshistory/post_crm_journey_task",
data: new FormData($("#form-post-journey")[0]),
processData: false,
contentType: false,
success: function (retorno) {
var data = JSON.parse(retorno);
if (data.status == "OK") {
if (id > 0) {
$(".tr_journey_task_" + id).remove();
}
if (data.closed == 1) {
$(".table-journeytasks_history").append(data.tr);
$(".crm_journey_stages_history").removeClass("hide");
if ($(".table-journeytasks tr").length == 1) {
$(".msg-journeytasks").removeClass("hide");
$(".table-journeytasks").addClass("hide");
}
} else {
$(".table-journeytasks").append(data.tr);
$(".msg-journeytasks").addClass("hide");
$(".table-journeytasks").removeClass("hide");
if ($(".table-journeytasks_history tr").length == 1) {
$(".crm_journey_stages_history").addClass("hide");
}
}
toastr.success(_L['module_imobles save']);
$(".cancel_journey_form").click();
} else {
$("#emsgbody-form-journey").html(data.msg);
$("#emsg-form-journey").show("slow");
}
}
});
});
$("body").on('click', ".edit_journey_task", function (e) {
e.preventDefault();
var $modal = $('#ajax-modal');
$modal.load(_url + 'module_imobles/leadshistory/crm_journey_data_add/' + $(this).data("id") + "/" + $("#module_imobles_crm_journey_stages_id").val(), function () {
$modal.modal();
$("#emsg-form-journey").hide();
$("#due_date").datepicker({
language: $("#_lan").val(),
autoclose: true,
dateFormat: $("#_formatDate").val()
});
$("[data-toggle='toggle']").bootstrapToggle();
});
});
$("body").on('click', '.delete_journey_task_form', function (e) {
e.preventDefault();
var id = $(this).data('id');
var dialog = bootbox.confirm({
message: _L['module_imobles Delete journey task?'],
buttons: {
confirm: {
label: _L['Yes'],
className: "btn-primary"
},
cancel: {
label: _L['No'],
className: "btn-danger"
}
},
callback: function (result) {
if (result == true) {
$.post(_url + "module_imobles/leadshistory/delete_crm_journey_task", {id: id})
.done(function (data) {
if (data == "OK") {
$(".tr_journey_task_" + id).remove();
toastr.success(_L['module imobles journey task delete success']);
if ($(".table-journeytasks tr").length == 1) {
$(".msg-journeytasks").removeClass("hide");
$(".table-journeytasks").addClass("hide");
}
if ($(".table-journeytasks_history tr").length == 1) {
$(".crm_journey_stages_history").addClass("hide");
}
} else {
toastr.error(data);
}
});
} else {
dialog.modal('hide');
return false;
}
}
});
});
scenariosLoaded = false;
dealsLoaded = false;
dealDocsLoaded = false;
tasksLoaded = false;
notesL1oaded = false;
$('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
var target = $(e.target).attr("href") // activated tab
if (target == '#crm_scenarios') {
var deal_id = $("#deal_id").val();
if (!scenariosLoaded) {
$('#ibox_form').block({ message: block_msg });
scenariosLoaded = true;
var id = $(this).data("crm_accounts_id");
$.get(_url + 'module_imobles/leadshistory/crm_scenarios_data/' + id+'/'+deal_id, function (j) {
$("#crm_scenarios_data").html(j);
$('#ibox_form').unblock();
});
}
} else if (target == '#crm_deals') {
var deal_id = $("#deal_id").val();
if (!dealsLoaded) {
$('#ibox_form').block({ message: block_msg });
dealsLoaded = true;
var id = $(this).data("crm_accounts_id");
$.get(_url + 'module_imobles/leadshistory/crm_control_deal_data/' + id+'/'+deal_id, function (j) {
$("#crm_deals_data").html(j);
dealForm();
$('#ibox_form').unblock();
});
}
} else if (target == '#crm_deals_docs') {
var deal_id = $("#deal_id").val();
if (!dealDocsLoaded) {
$('#ibox_form').block({ message: block_msg });
dealDocsLoaded = true;
$.get(_url + 'module_imobles/deals/docs_list/' + deal_id, function (j) {
$("#crm_deals_docs_data").html(j);
$("#emsg_deal_docs").hide();
$('#ibox_form').unblock();
});
}
} else if (target == '#crm_tasks') {
var deal_id = $("#deal_id").val();
var url_aux = 'module_imobles/deals/tasks';
console.log(deal_id);
if(deal_id != ''){
url_aux = 'module_imobles/deals/tasks/deal_id/'+deal_id;
}
if (!tasksLoaded) {
$("#crm_deals_data").html('');
dealsLoaded = false;
$('#ibox_form').block({ message: block_msg });
tasksLoaded = true;
var id = $(this).data("crm_accounts_id");
$.get(_url + url_aux, function (j) {
$("#crm_tasks_data").html(j);
// dealForm();
$('#ibox_form').unblock();
});
}
} else if (target == '#crm_notes') {
var deal_id = $("#deal_id").val();
var id = $(this).data("crm_accounts_id");
if (!notesL1oaded) {
$('#ibox_form').block({ message: block_msg });
notesLoaded = true;
var id = $(this).data("crm_accounts_id");
$.get(_url + 'module_imobles/deals/notes/'+ id+'/'+deal_id, function (j) {
$("#crm_notes_data").html(j);
// dealForm();
$( ".mmnt" ).each(function() {
var ut = $( this ).html();
$( this ).html(moment.unix(ut).fromNow());
});
$('#ibox_form').unblock();
$('#msg_note').redactor(
{
minHeight: 200,
imagePosition: true,
minHeight: 200,
// imageUpload: _url + "module_cms/image/create",
plugins: ['fontcolor']
}
);
$("#crm-notes-post").click(function(e){
e.preventDefault();
$('#ibox_form').block({ message: '' });
var _url = $("#_url").val();
$.post(_url + 'module_imobles/deals/add_notes_post/', {
cid: $('#cid').val(),
deal_id: deal_id,
msg: $('#msg_note').val()
})
.done(function (data) {
var _url = $("#_url").val();
if ($.isNumeric(data)) {
localStorage.setItem('guia_client_lead_control', 'tab_crm_notes');
window.location = _url + "contacts/view/" + id + "/module_imobles_leads_control";
}
else {
$('#ibox_form').unblock();
$("#emsgbody").html(data);
$("#emsg").show("slow");
}
});
});
});
}
}
});
$("body").on('click', ".edit_deal_note", function (e) {
e.preventDefault();
var $modal = $('#ajax-modal');
$modal.load(_url + 'module_imobles/deals/edit_notes/' + $(this).data("id"), function () {
$modal.modal();
$("#emsg-form-scenario-comment").hide();
$('#ib_modal_edit_note_form').redactor(
{
minHeight: 200,
imagePosition: true,
minHeight: 200,
// imageUpload: _url + "module_cms/image/create",
plugins: ['fontcolor']
}
);
});
});
$("body").on('click', '#modal_edit_note_submit', function(e){
e.preventDefault();
// $modal.modal('loading');
$.post( _url + "module_imobles/deals/edit_notes_post/", $("#ib_modal_edit_activity_form").serialize())
.done(function( data ) {
if ($.isNumeric(data)) {
localStorage.setItem('guia_client_lead_control', 'tab_crm_notes');
location.reload();
}
else {
// $modal.modal('loading');
toastr.error(data);
}
});
});
$("body").on('click', '.delete_deal_note', function (e) {
e.preventDefault();
var id = $(this).data('id');
var dialog = bootbox.confirm({
message: 'Tem certeza que deseja deletar essa anotação?',
buttons: {
confirm: {
label: _L['Yes'],
className: "btn-primary"
},
cancel: {
label: _L['No'],
className: "btn-danger"
}
},
callback: function (result) {
if (result == true) {
$.post(_url + "module_imobles/deals/deals_notes_delete", {id: id})
.done(function (data) {
if ($.isNumeric(data)) {
$(".tr_notes_deal_" + id).remove();
toastr.success('Anotação deletada com sucesso');
} else {
toastr.error(data);
}
});
} else {
dialog.modal('hide');
return false;
}
}
});
});
$("body").on('click', ".add_scenario_comments", function (e) {
e.preventDefault();
var $modal = $('#ajax-modal');
$modal.load(_url + 'module_imobles/leadshistory/scenario_comments_add/' + $(this).data("id"), function () {
$modal.modal();
$("#emsg-form-scenario-comment").hide();
});
});
$("body").on('click', '.submit_scenario_comment', function (e) {
e.preventDefault();
var id = $(this).data("id");
$.ajax(
{
type: 'POST',
url: _url + "module_imobles/leadshistory/scenario_comments_post",
data: new FormData($("#form-scenario_comments")[0]),
processData: false,
contentType: false,
success: function (retorno) {
var data = JSON.parse(retorno);
if (data.status == "OK") {
if (data.unit_type_id == null) {
$("#ul_" + data.scenario_id).append(data.comment)
}
toastr.success(_L['module_imobles save']);
$(".cancel_scenario_comment").click();
} else {
$("#emsgbody-form-scenario-comment").html(data.msg);
$("#emsg-form-scenario-comment").show("slow");
}
}
});
});
$("body").on('click', '.delete_scenario', function (e) {
e.preventDefault();
var id = $(this).data('id');
var dialog = bootbox.confirm({
message: _L['module_imobles_crm_scenario_delete'],
buttons: {
confirm: {
label: _L['Yes'],
className: "btn-primary"
},
cancel: {
label: _L['No'],
className: "btn-danger"
}
},
callback: function (result) {
if (result == true) {
$.post(_url + "module_imobles/leadshistory/delete_scenario", {id: id})
.done(function (data) {
if (data == "OK") {
$(".tr_scenario_" + id).remove();
toastr.success(_L['module_imobles_crm_scenario_delete_success']);
if ($(".table-scenarios tr").length == 1) {
$(".msg-scenarios").removeClass("hide");
$(".table-scenarios").addClass("hide");
}
} else {
toastr.error(data);
}
});
} else {
dialog.modal('hide');
return false;
}
}
});
});
///DEALS
$("body").on('click', '.delete_crm_service', function (e) {
e.preventDefault();
var id = $(this).data('id');
var dialog = bootbox.confirm({
message: _L['module_imobles Delete deals?'],
buttons: {
confirm: {
label: _L['Yes'],
className: "btn-primary"
},
cancel: {
label: _L['No'],
className: "btn-danger"
}
},
callback: function (result) {
if (result == true) {
$.post(_url + "module_imobles/leadshistory/delete_crm_control_deals", {id: id})
.done(function (data) {
if (data == "OK") {
$(".tr_deals_" + id).remove();
toastr.success(_L['module_imobles deals delete success']);
} else {
var body = $("html, body");
body.animate({scrollTop: 0}, '1000', 'swing');
$("#emsgbody").html(data);
$("#emsg").show("slow");
}
});
} else {
dialog.modal('hide');
return false;
}
}
});
});
//regra usada no js crm_control-deal-form.js para quando voltar vir com a guia selecionada
var guia = localStorage.getItem('guia_client_lead_control');
localStorage.setItem('guia_client_lead_control',null);
if (guia) {
$("#" + guia).click();
}
});
function send_to_client(scenario, event) {
event.preventDefault();
$("body").block({message: block_msg});
$("#form_send_scenario").html("");
$("#form_send_scenario").append('<input type="hidden" name="scenario_id" value="' + $(scenario).data('id') + '">');
$("#form_send_scenario").append('<input type="hidden" name="id" value="' + $(scenario).data('unit_type_ids') + '">');
$("#form_send_scenario").append('<input type="hidden" name="send_scenario" value="1">');
$.post($("#_url").val() + "module_imobles/typeunity/viewSendPdfClient", $("#form_send_scenario").serialize())
.done(function (data) {
$("body").unblock();
var $modal = $('#ajax-modal');
$modal.html(data);
$modal.modal();
$modal.find(".money").maskMoney({
thousands: ".",
decimal: ",",
precision: 2
});
$modal.find('#submit-group-typeunity').on("click", function (event) {
$("body").block({message: block_msg});
$.post($("#_url").val() + "module_imobles/typeunity/postSendTypeUnity", $("#send-pdf-type-unity-form").serialize())
.done(function (result) {
var data = JSON.parse(result);
if (data.status == 'OK') {
toastr.success(data.msg);
$modal.modal("hide");
} else if (data.status == 'REDIRECT') {
toastr.success(data.msg);
window.open(data.href, data.target);
$modal.modal("hide");
} else {
toastr.error(data.msg);
}
$("body").unblock();
}
);
});
$modal.find('#type_send').on("change", function (event) {
if ($(this).val() == 'jpg') {
$modal.find('#include_personal_shopper_img_row').show();
} else {
$modal.find('#include_personal_shopper_img_row').hide();
}
});
}
);
}
function dealForm(){
var _url = $("#_url").val();
$("#emsg_deal").hide();
findDataSelect("#sdr_id", 'module_imobles/ajax/sellers', '');
findDataSelect("#seller_id", 'module_imobles/ajax/sellers', '');
findDataSelect("#cliente_related", 'module_imobles/ajax/custommer', '');
$(".monetary").maskMoney({
thousands: ".",
decimal: ","
});
$(".porcentage").maskMoney({
thousands: ".",
decimal: ","
});
$(".date").datepicker();
//botão cancelar para voltar a mesma tela de onde saiu
$(".cancel_view_deal_form").click(function (e) {
localStorage.setItem('guia_client_lead_control', 'tab_crm_service');
window.location = _url + "contacts/view/" + $("#crm_account_id").val() + "/module_imobles_leads_control";
});
$("#submit_deal").click(function (e) {
$('#ibox_form').block({ message: block_msg });
$.ajax(
{
type: 'POST',
url: _url + "module_imobles/leadshistory/post_crm_control_deal",
data: new FormData($("#form-deal")[0]),
processData: false,
contentType: false,
success: function (retorno) {
$('#ibox_form').unblock();
var da = JSON.parse(retorno);
data = da.status;
if (data == "OK") {
localStorage.setItem('guia_client_lead_control', 'tab_crm_deals');
window.location = _url + "contacts/view/" + $("#crm_account_id").val() + "/module_imobles_leads_control";
} else {
var body = $("html, body");
body.animate({scrollTop: 0}, '1000', 'swing');
$("#emsgbody_deals").html(da.msg);
$("#emsg_deal").show("slow");
}
}
});
});
}