| 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/public_html/lrsys_apps/leo/application/plugins/module_helpdesk/assets/js/ |
Upload File : |
/* global ind_mil, curr_code, ind_decimal */
$(document).ready(function ()
{
var _url = $("#_url").val();
$('textarea').redactor({minHeight: 250});
$("#emsg").hide();
findDataSelect("#module_helpdesk_tickets_priority_id", 'module_helpdesk/ajax/priority', '');
findDataSelect("#module_helpdesk_tickets_cat_id", 'module_helpdesk/ajax/category', '');
findDataSelect("#module_helpdesk_tickets_treatment_type_id", 'module_helpdesk/ajax/type', '');
findDataSelect("#client_id", 'module_helpdesk/ajax/crm_accounts/customer', '');
findDataSelect("#responsible_id", 'module_helpdesk/ajax/crm_accounts/Employee/select', '');
loadProductCategory($('#category_id').val());
$("#product_cat_id").on('change', function () {
$("#product_id").val("").trigger("change");
});
$("#product_id").select2({
theme: "bootstrap",
placeholder: "",
ajax: {
url: $("#_url").val() + 'module_helpdesk/ajax/product',
dataType: "json",
delay: 250,
method: "POST",
data: function (params) {
var queryParameters = {
term: params.term,
category: $("#product_cat_id").val()
};
return queryParameters;
},
processResults: function (data) {
return {
results: $.map(data, function (item) {
return {
text: item.text,
id: item.id
}
})
};
},
cache: true,
}
});
$("#submit").click(function (e) {
$.ajax(
{
type: 'POST',
url: _url + "module_helpdesk/ticket/post",
data: new FormData($("#form-ticket")[0]),
processData: false,
contentType: false,
success: function (result) {
var data = JSON.parse(result);
if (data.status == "OK") {
location.reload();
} else {
$("#ibox-form").unblock();
var body = $("html, body");
body.animate({scrollTop: 0}, '1000', 'swing');
$("#emsgbody").html(data.msg);
$("#emsg").show("slow");
}
}
});
});
//dropzone
//
Dropzone.autoDiscover = false;
var $ib_form_submit = $("#submit");
var ib_file = new Dropzone("#upload_container_attachment",
{
url: $("#_url").val() + "module_helpdesk/ticket/add_attach/" + $("#id").val(),
//maxFiles: 1000,
// acceptedFiles: "image/*",
// autoProcessQueue: false,
maxFilesize: 5,
acceptedFiles: 'image/*,application/pdf',
addRemoveLinks: true,
dictRemoveFile: _L["Remove"],
dictCancelUpload: _L["Cancel"],
// maxfilesexceeded: function (file) {
// toastr.error(_L["Limit 10 Files"]);
// var _ref;
// return (_ref = file.previewElement) != null ? _ref.parentNode.removeChild(file.previewElement) : void 0;
// },
removedfile: function (file) {
var id = file.id;
bootbox.confirm(_L['module_helpdesk Delete Attach?'], function (result) {
if (result)
{
$.ajax({
type: 'POST',
url: $("#_url").val() + "module_helpdesk/ticket/delete_attach/",
data: "id=" + file.id,
dataType: 'html'
}).done(function (data) {
//se ok remove
//remove com uma vírgula caso encontre o id
var obj = JSON.parse(data);
toastr.success(obj.msg);
if (obj.status == 'Yes') {
$('#attachment').val($('#attachment').val().replace(id + ",", ""));
$('#attachment').val($('#attachment').val().replace("," + id, ""));
$('#attachment').val($('#attachment').val().replace(id, ""));
var _ref;
return (_ref = file.previewElement) != null ? _ref.parentNode.removeChild(file.previewElement) : void 0;
}
});
}
});
}
}
);
ib_file.on("sending", function () {
$ib_form_submit.prop('disabled', true);
});
ib_file.on("success", function (file, response) {
$ib_form_submit.prop('disabled', false);
upload_resp = response;
if (upload_resp.success == 'Yes') {
$('#attachment').val(function (i, val) {
return val + (!val ? '' : ',') + upload_resp.id;
});
file.id = upload_resp.id;
file.url = upload_resp.url;
file._downloadLink = Dropzone.createElement("<a class=\"dz-remove\" target=\"_blank\" href='" + file.url + "');\" title=\"Baixar\" ><i class=\"fa fa-eye\"></i> " + _L['View'] + "</a>");
file.previewElement.appendChild(file._downloadLink);
file.previewElement.classList.add("dz-success");
toastr.success(upload_resp.msg);
} else {
toastr.error(upload_resp.msg);
var _ref;
return (_ref = file.previewElement) != null ? _ref.parentNode.removeChild(file.previewElement) : void 0;
}
});
ib_file.on("addedfile", function (file) {
//aqui para quando já tem arquivo no dropzone, para colocar o baixar
if (file.url !== undefined) {
file._downloadLink = Dropzone.createElement("<a class=\"dz-remove\" target=\"_blank\" href='" + file.url + "');\" title=\"Baixar\" ><i class=\"fa fa-eye\"></i> " + _L['View'] + "</a>");
file.previewElement.appendChild(file._downloadLink);
file.previewElement.classList.add("dz-success");
}
});
//Add existing files into dropzone arquivos existentes
for (i = 0; i < existingFiles.length; i++) {
ib_file.emit("addedfile", existingFiles[i]);
ib_file.createThumbnailFromUrl(existingFiles[i], existingFiles[i].url);
ib_file.emit("complete", existingFiles[i]);
}
///fim dropzone
//dropzone tipo de atendimento fiscal
var ib_fileNote = new Dropzone("#upload_container_attachment_type_atendence",
{
url: $("#_url").val() + "module_helpdesk/ticket/add_attach_type_atendence/" + $("#id").val(),
//maxFiles: 1000,
// acceptedFiles: "image/*",
// autoProcessQueue: false,
maxFilesize: 5,
acceptedFiles: 'image/*,application/pdf',
addRemoveLinks: true,
dictRemoveFile: _L["Remove"],
dictCancelUpload: _L["Cancel"],
// maxfilesexceeded: function (file) {
// toastr.error(_L["Limit 10 Files"]);
// var _ref;
// return (_ref = file.previewElement) != null ? _ref.parentNode.removeChild(file.previewElement) : void 0;
// },
removedfile: function (file) {
var id = file.id;
bootbox.confirm(_L['module_helpdesk Delete Attach?'], function (result) {
if (result)
{
$.ajax({
type: 'POST',
url: $("#_url").val() + "module_helpdesk/ticket/delete_attach_type_atendence/",
data: "id=" + file.id,
dataType: 'html'
}).done(function (data) {
//se ok remove
//remove com uma vírgula caso encontre o id
var obj = JSON.parse(data);
toastr.success(obj.msg);
if (obj.status == 'Yes') {
$('#attachment_type_atendence').val($('#attachment_type_atendence').val().replace(id + ",", ""));
$('#attachment_type_atendence').val($('#attachment_type_atendence').val().replace("," + id, ""));
$('#attachment_type_atendence').val($('#attachment_type_atendence').val().replace(id, ""));
var _ref;
return (_ref = file.previewElement) != null ? _ref.parentNode.removeChild(file.previewElement) : void 0;
}
});
}
});
}
}
);
ib_fileNote.on("sending", function () {
$ib_form_submit.prop('disabled', true);
});
ib_fileNote.on("success", function (file, response) {
$ib_form_submit.prop('disabled', false);
upload_resp = response;
if (upload_resp.success == 'Yes') {
$('#attachment_type_atendence').val(function (i, val) {
return val + (!val ? '' : ',') + upload_resp.id;
});
file.id = upload_resp.id;
file.url = upload_resp.url;
file._downloadLink = Dropzone.createElement("<a class=\"dz-remove\" target=\"_blank\" href='" + file.url + "');\" title=\"Baixar\" ><i class=\"fa fa-eye\"></i> " + _L['View'] + "</a>");
file.previewElement.appendChild(file._downloadLink);
file.previewElement.classList.add("dz-success");
toastr.success(upload_resp.msg);
} else {
toastr.error(upload_resp.msg);
var _ref;
return (_ref = file.previewElement) != null ? _ref.parentNode.removeChild(file.previewElement) : void 0;
}
});
ib_fileNote.on("addedfile", function (file) {
//aqui para quando já tem arquivo no dropzone, para colocar o baixar
if (file.url !== undefined) {
file._downloadLink = Dropzone.createElement("<a class=\"dz-remove\" target=\"_blank\" href='" + file.url + "');\" title=\"Baixar\" ><i class=\"fa fa-eye\"></i> " + _L['View'] + "</a>");
file.previewElement.appendChild(file._downloadLink);
file.previewElement.classList.add("dz-success");
}
});
//Add existing files into dropzone arquivos existentes
for (i = 0; i < existingFilesNote.length; i++) {
ib_fileNote.emit("addedfile", existingFilesNote[i]);
ib_fileNote.createThumbnailFromUrl(existingFilesNote[i], existingFilesNote[i].url);
ib_fileNote.emit("complete", existingFilesNote[i]);
}
//
//
//fim do dropzone
//ADICIONAR TIPO MODAL
//add
var _msg_add_new_type = $("#_msg_add_new_type").val();
var _msg_type_name = $("#_msg_type_name").val();
var _msg_edit = $("#_msg_edit").val();
var _msg_ok = $("#_msg_ok").val();
var _msg_cancel = $("#_msg_cancel").val();
var ib_form_bootbox_type = "<form class=\"form-horizontal push-10\" method=\"post\" onsubmit=\"return false;\">\n <div class=\"form-type row\">\n <div class=\"col-xs-12\">\n <div class=\"form-material floating\">\n <input class=\"form-control\" type=\"text\" id=\"type_name\" name=\"type_name\">\n <label for=\"type_name\">" + _msg_type_name + "</label>\n </div>\n </div>\n </div>\n\n</form>";
$("#add_new_type").click(function (e) {
e.preventDefault();
var boxtType = bootbox.dialog({
title: _msg_add_new_type,
message: ib_form_bootbox_type,
buttons: {
success: {
label: $("#_msg_save").val(),
className: "btn-primary",
callback: function () {
var type_name_val = $('#type_name').val();
$.post(_url + "module_helpdesk/type/post/", {name: type_name_val})
.done(function (data) {
if (data == 'OK') {
toastr.success($("#_msg_add_new_type_success").val());
} else {
bootbox.alert(data);
}
});
}
}
},
show: false
}
);
boxtType.modal('show');
});
//fim tipo
//prioridade em modal
var _msg_add_new_priority = $("#_msg_add_new_priority").val();
var _msg_priority_name = $("#_msg_priority_name").val();
var ib_form_bootboxPriority = "<form class=\"form-horizontal push-10\" method=\"post\" onsubmit=\"return false;\">\n <div class=\"form-priority row\">\n <div class=\"col-xs-12\">\n <div class=\"form-material floating\">\n <input class=\"form-control\" type=\"text\" id=\"priority_name\" name=\"priority_name\">\n <label for=\"priority_name\">" + _msg_priority_name + "</label>\n </div>\n </div>\n </div>\n\n</form>";
$("#add_new_priority").click(function (e) {
e.preventDefault();
var boxPriority = bootbox.dialog({
title: _msg_add_new_priority,
message: ib_form_bootboxPriority,
buttons: {
success: {
label: $("#_msg_save").val(),
className: "btn-primary",
callback: function () {
var priority_name_val = $('#priority_name').val();
$.post(_url + "module_helpdesk/priority/post/", {name: priority_name_val})
.done(function (data) {
if (data == 'OK') {
toastr.success($("#_msg_add_new_priority_success").val());
} else {
bootbox.alert(data);
}
});
}
}
},
show: false
}
);
boxPriority.modal('show');
});
//fim prioridade
$('#module_helpdesk_tickets_treatment_type_id').on('change', function () {
$(".inputbytype").addClass("hide");
$(".type" + $(this).val()).removeClass("hide");
});
});
function loadProductCategory(val) {
//carrega os grupos;
$.getJSON($("#_url").val() + 'module_helpdesk/ajax/categoryProductAjax', function (j) {
var options = '';
options += '<option value="">' + _L['Select'] + '</option>';
for (var i = 0; i < j.length; i++) {
if (j[i].name_parent === null) {
options += '<option ' + (val == j[i].id ? 'selected' : '') + ' value="' + j[i].id + '">' + j[i].name + '</option>';
} else {
options += '<option ' + (val == j[i].id ? 'selected' : '') + ' value="' + j[i].id + '">' + j[i].name_parent + " > " + j[i].name + '</option>';
}
}
$('#product_cat_id').html(options);
});
}