1588 lines
53 KiB
JavaScript
1588 lines
53 KiB
JavaScript
|
|
setTimeout(() => {
|
|||
|
|
if (document.location.pathname != '/requisitions.php') {
|
|||
|
|
localStorage.removeItem('req_filter');
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$("body").on("click", ".add_req_new", function() {
|
|||
|
|
$('#req_form .klient').show();
|
|||
|
|
var client_id = 0;
|
|||
|
|
if ($(this).attr("data-client"))
|
|||
|
|
client_id = parseInt($(this).attr("data-client"));
|
|||
|
|
req_form.noEmptyClientId = 1;
|
|||
|
|
req_form.clientId = client_id;
|
|||
|
|
|
|||
|
|
req_form.openReqForm();
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
$("body").on("click", ".double_client_req", function() {
|
|||
|
|
var client_id = 0;
|
|||
|
|
if ($(this).attr("data-id")) {
|
|||
|
|
client_id = $(this).attr("data-id");
|
|||
|
|
}
|
|||
|
|
req_form.clientId = parseInt(client_id);
|
|||
|
|
req_form.noEmptyClientId = 1;
|
|||
|
|
req_form.openReqForm();
|
|||
|
|
$('#send_bg_new').fadeOut(500);
|
|||
|
|
$("#send_bg_new .edit-modal").toggle(10);
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
$("#req-new-funnel").fastselect({ placeholder: 'Воронка' });
|
|||
|
|
|
|||
|
|
|
|||
|
|
$('#req-new-client-work').fastselect({
|
|||
|
|
placeholder: 'Ответственный',
|
|||
|
|
onItemCreate: function() { $(this).find('.fstQueryInput').hide() },
|
|||
|
|
});
|
|||
|
|
$('#ms-req-partner').fastselect({
|
|||
|
|
placeholder: 'Партнёр',
|
|||
|
|
onItemCreate: function($item, itemModel) {
|
|||
|
|
let partner_name = $("#ms-req-partner-input select option[value=" + itemModel.value + "]").data('partner');
|
|||
|
|
itemModel.text = itemModel.text + ' <!-- ' + partner_name + ' -->';
|
|||
|
|
|
|||
|
|
$(this).find(".fstControls input.hidenClass").attr('type', "text");
|
|||
|
|
$(this).find(".fstControls input.hidenClass").removeClass('hidenClass');
|
|||
|
|
},
|
|||
|
|
onItemSelect: function($item, itemModel) {
|
|||
|
|
|
|||
|
|
let partner_label = $("#ms-req-partner-input select option:selected").data("label");
|
|||
|
|
if (partner_label)
|
|||
|
|
$("#ms-req-partner-input select").closest(".inputs").find(".fstToggleBtn").text(partner_label);
|
|||
|
|
|
|||
|
|
$(this).find(".fstControls input.hidenClass").attr('type', "text");
|
|||
|
|
$(this).find(".fstControls input.hidenClass").removeClass('hidenClass');
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
$('#ms-req-source').fastselect({
|
|||
|
|
placeholder: 'Источник',
|
|||
|
|
onItemCreate: function() { $(this).find('.fstQueryInput').hide() },
|
|||
|
|
|
|||
|
|
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
$('#req_filter_etap').fastselect({
|
|||
|
|
placeholder: 'Этап',
|
|||
|
|
onItemSelect: function(item, val) {
|
|||
|
|
filtr.checkFiltr();
|
|||
|
|
},
|
|||
|
|
onItemDelete: function() {
|
|||
|
|
filtr.checkFiltr();
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
$('#req_filter_period').fastselect({
|
|||
|
|
placeholder: 'Период',
|
|||
|
|
onItemSelect: function(item, val) {
|
|||
|
|
filtr.checkFiltr();
|
|||
|
|
},
|
|||
|
|
onItemDelete: function() {
|
|||
|
|
filtr.checkFiltr();
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
|
|||
|
|
$('#req_denial_work').fastselect({
|
|||
|
|
placeholder: 'Причина закрытия',
|
|||
|
|
onItemSelect: function(item, val) {
|
|||
|
|
filtr.checkFiltr();
|
|||
|
|
},
|
|||
|
|
onItemDelete: function() {
|
|||
|
|
filtr.checkFiltr();
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
$('#req_filter_activities').fastselect({
|
|||
|
|
placeholder: 'Теги',
|
|||
|
|
onItemSelect: function(item, val) {
|
|||
|
|
filtr.checkFiltr();
|
|||
|
|
},
|
|||
|
|
onItemDelete: function() {
|
|||
|
|
filtr.checkFiltr();
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
$('#req_filter-source').fastselect({
|
|||
|
|
placeholder: 'Источники',
|
|||
|
|
onItemCreate: function(item, model) {
|
|||
|
|
|
|||
|
|
if ($('#req_filter-source').find('option[value=' + model.value + ']').hasClass('bolt')) {
|
|||
|
|
$(item).addClass('bolt');
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
onItemSelect: function(item, val) {
|
|||
|
|
|
|||
|
|
filtr.checkFiltr();
|
|||
|
|
},
|
|||
|
|
onItemDelete: function() {
|
|||
|
|
filtr.checkFiltr();
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
$('#req_filter_partner').fastselect({
|
|||
|
|
placeholder: 'Партнеры',
|
|||
|
|
onItemSelect: function(item, val) {
|
|||
|
|
filtr.checkFiltr();
|
|||
|
|
},
|
|||
|
|
onItemDelete: function() {
|
|||
|
|
filtr.checkFiltr();
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
$('#confirm__who_work_req').fastselect({
|
|||
|
|
placeholder: 'Новый ответственный',
|
|||
|
|
onItemCreate: function(item, model) {
|
|||
|
|
if ($('#confirm__who_work_req').find('option[value=' + model.value + ']').hasClass('bolt')) {
|
|||
|
|
$(item).addClass('bolt');
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
$('#reqDates .datepicker-filter').datepicker({
|
|||
|
|
autoClose: 'true',
|
|||
|
|
onSelect: function() {
|
|||
|
|
filtr.checkFiltr();
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
$('#dates_contract_req .datepicker-filter').datepicker({
|
|||
|
|
autoClose: 'true',
|
|||
|
|
onSelect: function() {
|
|||
|
|
filtr.checkFiltr();
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
$('#dates_date_step .datepicker-filter').datepicker({
|
|||
|
|
autoClose: 'true',
|
|||
|
|
onSelect: function() {
|
|||
|
|
filtr.checkFiltr();
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
$("body").on("click", ".req-events-new", function() {
|
|||
|
|
$('.object-content__preloader').show();
|
|||
|
|
var req_id = $(this).attr("data-id");
|
|||
|
|
var client_id = 0;
|
|||
|
|
var adjacent_id = false;
|
|||
|
|
if($(this).attr("data-adjacent")){
|
|||
|
|
adjacent_id = $(this).attr("data-adjacent");
|
|||
|
|
}
|
|||
|
|
if (req_id > 0) {
|
|||
|
|
openClientEventsWindowNew(client_id, $('#session_to_send').val(), 0, req_id, adjacent_id);
|
|||
|
|
$('#client-history__bg').css('zIndex', '99998');
|
|||
|
|
} else {
|
|||
|
|
$('.object-content__preloader').hide();
|
|||
|
|
}
|
|||
|
|
//$('#send_bg_new .closer').click();
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
$("body").on("change", "#sort_order_req", function() {
|
|||
|
|
filtr.filtr.order = $('#sort_order_req').val();
|
|||
|
|
filtr.search();
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
$("body").on("click", "#modalDetailsObj .closer", function() {
|
|||
|
|
$("#modalDetailsObj_bg").hide(10);
|
|||
|
|
$("#modalDetailsObj").hide(10);
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
$('body').click(function(e) {
|
|||
|
|
|
|||
|
|
if ($(e.target).closest('.jw__popup').length == 0 &&
|
|||
|
|
$(e.target).closest('.fstChoiceItem').length == 0 &&
|
|||
|
|
$(e.target).closest('.vs__deselect').length == 0
|
|||
|
|
) {
|
|||
|
|
if (typeof requisitions != "undefined") {
|
|||
|
|
for (var i in requisitions.req) {
|
|||
|
|
if(i !== 'count')
|
|||
|
|
requisitions.req[i].add_tag = false;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if ($(e.target).closest('.actions-menu').length != 1) {
|
|||
|
|
$('#popup__reqs').removeClass('show');
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
});
|
|||
|
|
$("body").on("mouseover", ".contracts", function(e) {
|
|||
|
|
var left = $(this).position().left;
|
|||
|
|
var left1 = $(this).offset().left;
|
|||
|
|
if ($(this).closest('.client-inner').find(".actions").length > 0) {
|
|||
|
|
var left2 = $(this).closest('.client-inner').find(".actions").offset().left;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (left2) {
|
|||
|
|
var width = left2 - left - 150;
|
|||
|
|
var top = $(this).position().top;
|
|||
|
|
$(this).css("maxWidth", width + "px").css("position", "absolute").css("left", left + "px").css("top", top + "px").css("whiteSpace", "normal");
|
|||
|
|
}
|
|||
|
|
//$(this).offset().left = left;
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
|
|||
|
|
$("body").on("mouseout", ".contracts", function(e) {
|
|||
|
|
//$(this).css("maxWidth","15%");
|
|||
|
|
$(this).attr("style", "");
|
|||
|
|
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
$('body').on('click', '.confirm__reqs', function() {
|
|||
|
|
var userId = $(this).attr("data-id");
|
|||
|
|
var reqsId = [];
|
|||
|
|
var all = 0;
|
|||
|
|
if ($('#changeReqAllFilter').prop('checked')) {
|
|||
|
|
all = 1;
|
|||
|
|
}
|
|||
|
|
if (all == 0) {
|
|||
|
|
$('.changeReqInput').each(function() {
|
|||
|
|
if ($(this).prop('checked')) {
|
|||
|
|
var id = $(this).attr('id').replace("changeReq", "");
|
|||
|
|
if (id != 'All') {
|
|||
|
|
reqsId.push(id);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
if (reqsId.length == 0) {
|
|||
|
|
alert("Нет выбранных заявок");
|
|||
|
|
} else {
|
|||
|
|
|
|||
|
|
changeUserReqs_confirm(userId, reqsId);
|
|||
|
|
}
|
|||
|
|
} else {
|
|||
|
|
changeUserReqs_confirm(userId, reqsId);
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
$('body').on('click', '.transfer_reqs_closed', function() {
|
|||
|
|
var userId = $(this).attr("data-id");
|
|||
|
|
var reqsId = [];
|
|||
|
|
var all = 0;
|
|||
|
|
|
|||
|
|
if ($('#changeReqAllFilter').prop('checked')) {
|
|||
|
|
all = 1;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (all == 0) {
|
|||
|
|
$('.changeReqInput').each(function() {
|
|||
|
|
if ($(this).prop('checked')) {
|
|||
|
|
var id = $(this).attr('id').replace("changeReq", "");
|
|||
|
|
if (id != 'All') {
|
|||
|
|
reqsId.push(id);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
if (reqsId.length == 0) {
|
|||
|
|
alert("Нет выбранных заявок");
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$("#transfer_reqs_closed_pick_owner_user_id").val(userId);
|
|||
|
|
$("#transfer_reqs_closed_pick_owner_req_id").val(JSON.stringify(reqsId));
|
|||
|
|
|
|||
|
|
$("#transfer_reqs_closed_pick_owner_bg").fadeIn(500);
|
|||
|
|
$("#transfer_reqs_closed_pick_owner").fadeIn(10);
|
|||
|
|
$("body").addClass("lock");
|
|||
|
|
|
|||
|
|
return false;
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
$('body').on('click', '.confirm_on_reqs', function() {
|
|||
|
|
var reqsId = [];
|
|||
|
|
var all = 0;
|
|||
|
|
if ($('#changeReqAllFilter').prop('checked')) {
|
|||
|
|
all = 1;
|
|||
|
|
}
|
|||
|
|
if (all == 0) {
|
|||
|
|
$('.changeReqInput').each(function() {
|
|||
|
|
if ($(this).prop('checked')) {
|
|||
|
|
var id = $(this).attr('id').replace("changeReq", "");
|
|||
|
|
if (id != 'All') {
|
|||
|
|
reqsId.push(id);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
if (reqsId.length == 0) {
|
|||
|
|
alert("Нет выбранных заявок");
|
|||
|
|
} else {
|
|||
|
|
console.log(reqsId);
|
|||
|
|
|
|||
|
|
|
|||
|
|
open_confirmation__req_client('req', 'confirm_on', '');
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
} else {
|
|||
|
|
|
|||
|
|
open_confirmation__req_client('req', 'confirm_on', '');
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
})
|
|||
|
|
|
|||
|
|
$('body').on('click', '#confirm__user_req_bg .ti-close', function() {
|
|||
|
|
closeConfirmReq();
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
$('body').on('click', '#transfer_reqs_closed_pick_owner_bg .ti-close', function() {
|
|||
|
|
$("#transfer_reqs_closed_pick_owner_bg").fadeOut(500);
|
|||
|
|
$("#transfer_reqs_closed_pick_owner").fadeOut(10);
|
|||
|
|
$("body").removeClass("lock");
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
$('body').on('click', '#funnel__user_bg_req .ti-close', function() {
|
|||
|
|
closeFunnelReqs();
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
$('body').on('click', '.funnel__reqs', function() {
|
|||
|
|
|
|||
|
|
var reqsId = [];
|
|||
|
|
var all = 0;
|
|||
|
|
if ($('#changeReqAllFilter').prop('checked')) {
|
|||
|
|
all = 1;
|
|||
|
|
}
|
|||
|
|
if (all == 0) {
|
|||
|
|
$('.changeReqInput').each(function() {
|
|||
|
|
if ($(this).prop('checked')) {
|
|||
|
|
var id = $(this).attr('id').replace("changeReq", "");
|
|||
|
|
reqsId.push(id);
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
|
|||
|
|
//console.log(reqsId);
|
|||
|
|
|
|||
|
|
if (reqsId.length == 0) {
|
|||
|
|
alert("Нет выбранных заявок");
|
|||
|
|
} else {
|
|||
|
|
|
|||
|
|
funnelReqs(reqsId);
|
|||
|
|
}
|
|||
|
|
} else {
|
|||
|
|
funnelReqs(reqsId);
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
//Открытие нескольких заявок
|
|||
|
|
$("body").on('click', '.renew_all_reqs', function() {
|
|||
|
|
|
|||
|
|
var reqsId = [];
|
|||
|
|
var all = 0;
|
|||
|
|
if ($('#changeReqAllFilter').prop('checked')) {
|
|||
|
|
all = 1;
|
|||
|
|
}
|
|||
|
|
if (all == 0) {
|
|||
|
|
$('.changeReqInput').each(function() {
|
|||
|
|
if ($(this).prop('checked')) {
|
|||
|
|
var id = $(this).attr('id').replace("changeReq", "");
|
|||
|
|
if (id != 'All') {
|
|||
|
|
reqsId.push(id);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
if (reqsId.length == 0) {
|
|||
|
|
alert("Нет выбранных заявок");
|
|||
|
|
} else {
|
|||
|
|
console.log(reqsId);
|
|||
|
|
|
|||
|
|
open_confirmation__req_client('req', 'renew_all', '');
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
} else {
|
|||
|
|
|
|||
|
|
open_confirmation__req_client('req', 'renew_all', '');
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return false;
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
//Принять нескольких закрытых заявок
|
|||
|
|
$("body").on('click', '.mass_take_from_closed', function() {
|
|||
|
|
let reqsId = [];
|
|||
|
|
let all = 0;
|
|||
|
|
if ($('#changeReqAllFilter').prop('checked')) {
|
|||
|
|
all = 1;
|
|||
|
|
}
|
|||
|
|
if (all === 0) {
|
|||
|
|
$('.changeReqInput').each(function() {
|
|||
|
|
if ($(this).prop('checked')) {
|
|||
|
|
let id = $(this).attr('id').replace("changeReq", "");
|
|||
|
|
if (id != 'All') {
|
|||
|
|
reqsId.push(id);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
if (reqsId.length > 0) {
|
|||
|
|
console.log(reqsId);
|
|||
|
|
open_confirmation__req_client('req', 'take_from_closed_all', '');
|
|||
|
|
} else {
|
|||
|
|
alert("Нет выбранных заявок");
|
|||
|
|
}
|
|||
|
|
} else {
|
|||
|
|
//open_confirmation__req_client('req', 'renew_all', '');
|
|||
|
|
}
|
|||
|
|
return false;
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
//Закрыть поиск объектов
|
|||
|
|
$('body').on('click', '#modalFindObj_bg .closer', function(e) {
|
|||
|
|
//console.log(e.target);
|
|||
|
|
if ($(e.target).closest(".crm__filter-popup").length == 0 && $(e.target).closest(".map_object").length == 0) {
|
|||
|
|
closeFindObject();
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
//Закрыть модал параметров автопоиска
|
|||
|
|
$('body').on('click', '#modalAutoSearchFiltr_bg .closer', function(e) {
|
|||
|
|
//console.log(e.target);
|
|||
|
|
if ($(e.target).closest(".crm__filter-popup").length == 0 && $(e.target).closest(".map_object").length == 0) {
|
|||
|
|
closeAutoSearchFiltr();
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
//Закрыть модал карты в автопоиске
|
|||
|
|
$('body').on('click', '#modalAutoSearchMap_bg .closer', function(e) {
|
|||
|
|
closeAutoSearchMap();
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
//Выбор объекта
|
|||
|
|
$('body').on('click', '#objectsFind .item', function(e) {
|
|||
|
|
if ($(e.target).hasClass("edit_opis") ||
|
|||
|
|
$(e.target).hasClass("edit-link") ||
|
|||
|
|
$(e.target).closest(".fotorama").length > 0 ||
|
|||
|
|
$(e.target).hasClass("save_opis") ||
|
|||
|
|
$(e.target).hasClass("open_can_map") ||
|
|||
|
|
$(e.target).closest(".map_object").length > 0 ||
|
|||
|
|
$(e.target).closest(".phone").length > 0
|
|||
|
|
) {
|
|||
|
|
|
|||
|
|
} else {
|
|||
|
|
var idObj = $(this).attr('id').replace("item", "");
|
|||
|
|
var who_work = parseInt($(this).attr('data-user'));
|
|||
|
|
req_form.objectId = parseInt(idObj);
|
|||
|
|
//req_form.isObject = true;
|
|||
|
|
req_form.getObjectFind(who_work, req_form.objectId);
|
|||
|
|
closeFindObject();
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
$("body").on("click", ".view-adv-find-list", function() {
|
|||
|
|
localStorage['view-adv-find'] = "list";
|
|||
|
|
$(this).addClass('active');
|
|||
|
|
$('#modalFindObj .view-adv-find-table').removeClass('active');
|
|||
|
|
findObject();
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
$("body").on("click", "#modalFindObj .view-adv-find-table", function() {
|
|||
|
|
localStorage['view-adv-find'] = "table";
|
|||
|
|
$(this).addClass('active');
|
|||
|
|
$('.view-adv-find-list').removeClass('active');
|
|||
|
|
findObject();
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
$("body").on("click", "#modalFindObj .crm__filters .crm__filter-popup .filter-popup__left .filter-popup-type", function() {
|
|||
|
|
|
|||
|
|
if ($(this).hasClass('active')) {
|
|||
|
|
$(this).removeClass('active');
|
|||
|
|
} else {
|
|||
|
|
$('#modalFindObj .crm__filters .crm__filter-popup .filter-popup__left .filter-popup-type').removeClass('active');
|
|||
|
|
$(this).addClass('active');
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
findObject();
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
$("body").on('click', '#modalFindObj .ti-search2', function() {
|
|||
|
|
findObject();
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
|
|||
|
|
$('#find_obj___a').click(function() {
|
|||
|
|
if ($('#find_obj___a').attr('data-active') == 0) {
|
|||
|
|
$('#find_obj___a').attr('data-active', 1);
|
|||
|
|
findObject();
|
|||
|
|
} else {
|
|||
|
|
$('#find_obj___a').attr('data-active', 0);
|
|||
|
|
findObject();
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
$('#find_obj___b').click(function() {
|
|||
|
|
if ($('#find_obj___b').attr('data-active') == 0) {
|
|||
|
|
$('#find_obj___b').attr('data-active', 1);
|
|||
|
|
findObject();
|
|||
|
|
} else {
|
|||
|
|
$('#find_obj___b').attr('data-active', 0);
|
|||
|
|
findObject();
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
$('#find_obj___c').click(function() {
|
|||
|
|
if ($('#find_obj___c').attr('data-active') == 0) {
|
|||
|
|
$('#find_obj___c').attr('data-active', 1);
|
|||
|
|
findObject();
|
|||
|
|
} else {
|
|||
|
|
$('#find_obj___c').attr('data-active', 0);
|
|||
|
|
findObject();
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
$('#find_obj___d').click(function() {
|
|||
|
|
if ($('#find_obj___d').attr('data-active') == 0) {
|
|||
|
|
$('#find_obj___d').attr('data-active', 1);
|
|||
|
|
findObject();
|
|||
|
|
} else {
|
|||
|
|
$('#find_obj___d').attr('data-active', 0);
|
|||
|
|
findObject();
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
// === Фильтр доп.полей в модалке Найти объект (Спрос) ===
|
|||
|
|
|
|||
|
|
function showReqObjectFieldsSearchModal() {
|
|||
|
|
$.ajax({
|
|||
|
|
url: '/ajax/modals/objectFieldsSearchWinContentReq.php',
|
|||
|
|
success: function(data) {
|
|||
|
|
$("#objectFieldsSearchReqBg").html(data);
|
|||
|
|
$("#objectFieldsSearchReqBg").show();
|
|||
|
|
$("#objectFieldsSearchReq").show();
|
|||
|
|
$("body").addClass("lock");
|
|||
|
|
|
|||
|
|
var form = $('#objectFieldsSearchFormReq');
|
|||
|
|
form.find('[type="submit"]').unbind('click');
|
|||
|
|
form.find('[type="submit"]').on('click', function(event) {
|
|||
|
|
event.preventDefault();
|
|||
|
|
event.stopPropagation();
|
|||
|
|
|
|||
|
|
$.ajax({
|
|||
|
|
url: '/ajax/setReqObjectFieldsFilter.php',
|
|||
|
|
method: "post",
|
|||
|
|
data: form.serialize(),
|
|||
|
|
success: function(data) {
|
|||
|
|
var results = JSON.parse(data);
|
|||
|
|
if (results.success) {
|
|||
|
|
$('#filter-object-fields-req').attr('data-active', 1);
|
|||
|
|
$('#filter-object-fields-req-count').text(results.count > 0 ? ' (' + results.count + ')' : '');
|
|||
|
|
$('#filter-object-fields-req-reset').css('display', 'inline-block');
|
|||
|
|
$("#objectFieldsSearchReqBg").hide();
|
|||
|
|
$("#objectFieldsSearchReqBg").empty();
|
|||
|
|
$("#objectFieldsSearchReq").hide();
|
|||
|
|
$("body").removeClass("lock");
|
|||
|
|
findObject();
|
|||
|
|
} else {
|
|||
|
|
console.log(results);
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
error: function(XMLHttpRequest, textStatus, errorThrown) {
|
|||
|
|
console.log("eRROR: " + errorThrown + "; status:" + textStatus);
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
});
|
|||
|
|
},
|
|||
|
|
error: function(XMLHttpRequest, textStatus, errorThrown) {
|
|||
|
|
console.log("eRROR: " + errorThrown + "; status:" + textStatus);
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$('body').on('click', '#filter-object-fields-req', function() {
|
|||
|
|
showReqObjectFieldsSearchModal();
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
$('body').on('click', '#filter-object-fields-req-reset', function() {
|
|||
|
|
$.ajax({
|
|||
|
|
url: '/ajax/unsetReqObjectFieldsFilter.php',
|
|||
|
|
method: "get",
|
|||
|
|
success: function() {
|
|||
|
|
$('#filter-object-fields-req').attr('data-active', 0);
|
|||
|
|
$('#filter-object-fields-req-count').text('');
|
|||
|
|
$('#filter-object-fields-req-reset').css('display', 'none');
|
|||
|
|
findObject();
|
|||
|
|
},
|
|||
|
|
error: function(XMLHttpRequest, textStatus, errorThrown) {
|
|||
|
|
console.log("eRROR: " + errorThrown + "; status:" + textStatus);
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
// Закрытие модалки доп.полей по клику на × или подложку
|
|||
|
|
$('body').on('click', '#objectFieldsSearchReqBg .closer, #objectFieldsSearchReq .closer', function(e) {
|
|||
|
|
e.stopPropagation();
|
|||
|
|
$("#objectFieldsSearchReqBg").hide();
|
|||
|
|
$("#objectFieldsSearchReqBg").empty();
|
|||
|
|
$("#objectFieldsSearchReq").hide();
|
|||
|
|
$("body").removeClass("lock");
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
$("body").on("click", "#modalFindObj .actionJW", function() {
|
|||
|
|
if ($(this).hasClass('active')) {
|
|||
|
|
$(this).removeClass('active');
|
|||
|
|
} else {
|
|||
|
|
$(this).addClass('active');
|
|||
|
|
}
|
|||
|
|
// findObject();
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
|
|||
|
|
$("body").on("click", ".openListReq", function() {
|
|||
|
|
var obj_id = 0;
|
|||
|
|
if ($(this).attr('data-id')) {
|
|||
|
|
obj_id = parseInt($(this).attr('data-id'));
|
|||
|
|
//console.log(obj_id);
|
|||
|
|
requisitions_object.openForm(obj_id);
|
|||
|
|
}
|
|||
|
|
})
|
|||
|
|
|
|||
|
|
//Поиск заявок по enter
|
|||
|
|
$('#req_filtr .search-filter__filter').keydown(function(e) {
|
|||
|
|
if (e.keyCode == 13) {
|
|||
|
|
if (typeof filtr == 'object') {
|
|||
|
|
filtr.search(1);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
//Поиск по дате по enter
|
|||
|
|
$('#reqOnDate').keydown(function(e) {
|
|||
|
|
if (e.keyCode == 13) {
|
|||
|
|
if (typeof filtr == 'object') {
|
|||
|
|
filtr.checkFiltr();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
$('#reqOffDate').keydown(function(e) {
|
|||
|
|
if (e.keyCode == 13) {
|
|||
|
|
if (typeof filtr == 'object') {
|
|||
|
|
filtr.checkFiltr();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
var time_out;
|
|||
|
|
$('body').on('keydown', '#search_filter_input_find_obj', function(e) {
|
|||
|
|
if (e.keyCode == 13) {
|
|||
|
|
clearTimeout(time_out);
|
|||
|
|
findObject();
|
|||
|
|
}
|
|||
|
|
//Не нужно else, так не упевают отслеживать поиск при наборе...
|
|||
|
|
/*else {
|
|||
|
|
clearTimeout(time_out);
|
|||
|
|
time_out = setTimeout(findObject, 500);
|
|||
|
|
}*/
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
var agency_id = $('#session_agency_id').val();
|
|||
|
|
updateFilterEmpSelect('work');
|
|||
|
|
|
|||
|
|
|
|||
|
|
if (agency_id > 0) {
|
|||
|
|
axios.post('/ajax/modals/selects/filter_req_type.php', { agency_id: agency_id }).then((response) => {
|
|||
|
|
//console.log(response.data);
|
|||
|
|
$('#filter-req-type-input').html(response.data);
|
|||
|
|
$("#filter-req-type").fastselect({
|
|||
|
|
placeholder: 'Тип',
|
|||
|
|
onItemSelect: function(item, val) {
|
|||
|
|
filtr.checkFiltr();
|
|||
|
|
},
|
|||
|
|
onItemDelete: function() {
|
|||
|
|
filtr.checkFiltr();
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$('body').on('click', '.req_info', function() {
|
|||
|
|
var id = $(this).attr("data-id");
|
|||
|
|
req_info.open(id);
|
|||
|
|
})
|
|||
|
|
|
|||
|
|
$('body').on('click', '.status_button', function() {
|
|||
|
|
var id = $(this).attr("data-req-id");
|
|||
|
|
if (id) {
|
|||
|
|
req_info.openFromOtherPage(id);
|
|||
|
|
}
|
|||
|
|
})
|
|||
|
|
|
|||
|
|
}, 1000)
|
|||
|
|
|
|||
|
|
//
|
|||
|
|
function add_object_new_client_input_vue(client_id) {
|
|||
|
|
console.log(client_id);
|
|||
|
|
console.log(typeof object_new_client_input_vue);
|
|||
|
|
if (typeof object_new_client_input_vue == 'object') {
|
|||
|
|
object_new_client_input_vue.search_client(client_id);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if(typeof client_req_bind == 'object' && client_req_bind.is_show){
|
|||
|
|
client_req_bind.search_client(client_id);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//Подключение select после ajax
|
|||
|
|
function installationComponentFindObj() {
|
|||
|
|
|
|||
|
|
// if (!$('#filter_emp_find_obj').length > 0) {
|
|||
|
|
axios.get('/ajax/modals/selects/filter_emp_find_obj.php').then((response) => {
|
|||
|
|
$('#filter_emp_find_obj_input').html(response.data);
|
|||
|
|
$('#filter_emp_find_obj').fastselect({
|
|||
|
|
placeholder: 'Ответственный',
|
|||
|
|
onItemCreate: function(item, model) {
|
|||
|
|
if ($('#filter_emp_find_obj').find('option[value=' + model.value + ']').hasClass('bolt')) {
|
|||
|
|
$(item).addClass('bolt');
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
// onItemSelect: function() {
|
|||
|
|
|
|||
|
|
// // findObject();
|
|||
|
|
// },
|
|||
|
|
// onItemDelete: function() {
|
|||
|
|
|
|||
|
|
// findObject();
|
|||
|
|
// }
|
|||
|
|
|
|||
|
|
});
|
|||
|
|
})
|
|||
|
|
.catch(function(error) {
|
|||
|
|
console.log(error);
|
|||
|
|
});
|
|||
|
|
// }
|
|||
|
|
/* $('#filter_emp_find_obj').fastselect({
|
|||
|
|
placeholder: 'Ответственный',
|
|||
|
|
onItemCreate: function(item, model) {
|
|||
|
|
if ($('#filter_emp_find_obj').find('option[value=' + model.value + ']').hasClass('bolt')) {
|
|||
|
|
$(item).addClass('bolt');
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
onItemSelect: function() {
|
|||
|
|
|
|||
|
|
findObject();
|
|||
|
|
},
|
|||
|
|
onItemDelete: function() {
|
|||
|
|
|
|||
|
|
findObject();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
});*/
|
|||
|
|
|
|||
|
|
$('body').on('click', "#requisitions-objects_filter_apply", function(e){
|
|||
|
|
findObject();
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
$('#filter-object-type-find-obj').fastselect({
|
|||
|
|
placeholder: 'Тип объекта',
|
|||
|
|
onItemSelect: function() {
|
|||
|
|
$val = $('#filter-object-type-find-obj').val();
|
|||
|
|
if ($val.indexOf('Квартиры') >= 0) {
|
|||
|
|
$('.requisitions-filter-obj-komnat').show();
|
|||
|
|
} else {
|
|||
|
|
$('.requisitions-filter-obj-komnat').hide();
|
|||
|
|
}
|
|||
|
|
//show_objects_options_search();
|
|||
|
|
// findObject();
|
|||
|
|
},
|
|||
|
|
onItemDelete: function() {
|
|||
|
|
if (
|
|||
|
|
!$('#filter-object-type-find-obj').val() ||
|
|||
|
|
!$('#filter-object-type-find-obj').val().includes("Квартиры")) {
|
|||
|
|
$('.requisitions-filter-obj-komnat').hide();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//show_objects_options_search();
|
|||
|
|
// findObject();
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
$('#filter-object-activities-find-obj').fastselect({
|
|||
|
|
placeholder: 'Теги',
|
|||
|
|
// onItemSelect: function() {
|
|||
|
|
// //show_objects_options_search();
|
|||
|
|
// findObject();
|
|||
|
|
// },
|
|||
|
|
// onItemDelete: function() {
|
|||
|
|
// //show_objects_options_search();
|
|||
|
|
// findObject();
|
|||
|
|
// }
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
///Подробно про объект
|
|||
|
|
function seeDetails(id) {
|
|||
|
|
|
|||
|
|
if (parseInt(id) > 0) {
|
|||
|
|
console.log(id);
|
|||
|
|
$('#oobjectsDetails').html('');
|
|||
|
|
|
|||
|
|
$("#modalDetailsObj_bg").fadeIn(500);
|
|||
|
|
|
|||
|
|
$("#modalDetailsObj").toggle(10);
|
|||
|
|
|
|||
|
|
$("body").addClass("lock");
|
|||
|
|
|
|||
|
|
$('#objectsDetails').css({ "background": "url(/images/ajax_preloader.gif) no-repeat center center", "min-height": "300px" });
|
|||
|
|
|
|||
|
|
$.post("/ajax/objectsDetails.php", { id: id }, function(data) {
|
|||
|
|
|
|||
|
|
$('#objectsDetails').html(data);
|
|||
|
|
|
|||
|
|
$('#objectsDetails').css({ "background": "none" });
|
|||
|
|
|
|||
|
|
setTimeout(function() {
|
|||
|
|
$('#modalDetailsObj .fotorama').fotorama();
|
|||
|
|
}, 100);
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
function changeUserReqs_confirm(userId, reqId) {
|
|||
|
|
|
|||
|
|
$("#confirm__user_id_req").val(userId);
|
|||
|
|
$("#confirm_reqs_id").val(JSON.stringify(reqId));
|
|||
|
|
$("#confirm__who_work_req option").show();
|
|||
|
|
//$("#confirm__who_work option[value='" + userId + "']").hide();
|
|||
|
|
|
|||
|
|
$("#confirm__user_req_bg").fadeIn(500);
|
|||
|
|
|
|||
|
|
$("#confirm__user_req").fadeIn(10);
|
|||
|
|
|
|||
|
|
$("body").addClass("lock");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
function confirmOnReqs(reqs) {
|
|||
|
|
var user_id = $('#session_user_id').val();
|
|||
|
|
var all = 0;
|
|||
|
|
var ids = [];
|
|||
|
|
if ($('#changeReqAllFilter').prop('checked')) {
|
|||
|
|
all = 1;
|
|||
|
|
if (localStorage['ids_exception_req']) {
|
|||
|
|
var ids_exception_req = localStorage.getItem('ids_exception_req');
|
|||
|
|
|
|||
|
|
ids = JSON.parse(ids_exception_req);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
var reqs_id = reqs;
|
|||
|
|
axios.post('/ajax/ajax_vue_requisitions.php', {
|
|||
|
|
request: 'confirm_on_reqs',
|
|||
|
|
reqs_id: reqs_id,
|
|||
|
|
user_id: user_id,
|
|||
|
|
all: all,
|
|||
|
|
ids_exception: ids,
|
|||
|
|
|
|||
|
|
}, )
|
|||
|
|
.then((response) => {
|
|||
|
|
//console.log(response.data);
|
|||
|
|
let funnel_id = $('#funnelIdClients').val();
|
|||
|
|
let use_custom_funnel = $('#useCustomFunnel').val();
|
|||
|
|
let section = 'clients';
|
|||
|
|
// if (req_id != 0) {
|
|||
|
|
section = 'requisitions';
|
|||
|
|
if (document.location.pathname == '/requisitions.php') {
|
|||
|
|
requisitions.getList();
|
|||
|
|
}
|
|||
|
|
// }
|
|||
|
|
//console.log('conf' + section);
|
|||
|
|
get_funnels(funnel_id, section, use_custom_funnel);
|
|||
|
|
/*closeConfirmReq();
|
|||
|
|
this.getList();*/
|
|||
|
|
})
|
|||
|
|
.catch(function(error) {
|
|||
|
|
console.log(error);
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//Закрыть форму передачи заявок
|
|||
|
|
function closeConfirmReq() {
|
|||
|
|
$("#confirm__user_req_bg").fadeOut(500);
|
|||
|
|
$("#confirm__user_req").fadeOut(10);
|
|||
|
|
$("body").removeClass("lock");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//Перемещение в воронку
|
|||
|
|
function funnelReqs(reqsId) {
|
|||
|
|
$("#funnel_reqs_id").val(JSON.stringify(reqsId));
|
|||
|
|
$("#funnel__check_req option").show();
|
|||
|
|
//$("#confirm__who_work option[value='" + userId + "']").hide();
|
|||
|
|
|
|||
|
|
$("#funnel__user_bg_req").fadeIn(500);
|
|||
|
|
|
|||
|
|
$("#funnel__user_req").fadeIn(10);
|
|||
|
|
|
|||
|
|
$("body").addClass("lock");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//Закрыть форму передачи заявок
|
|||
|
|
function closeFunnelReqs() {
|
|||
|
|
$("#funnel__user_bg_req").fadeOut(500);
|
|||
|
|
$("#funnel__user_req").fadeOut(10);
|
|||
|
|
$("body").removeClass("lock");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
function to_check_req_all() {
|
|||
|
|
$('#changeReqAllFilter').prop('checked', false);
|
|||
|
|
$('#changeReqAllFilterDiv').removeClass('active');
|
|||
|
|
if ($('#changeReqAll').prop('checked')) {
|
|||
|
|
$('#changeReqAll').prop('checked', false);
|
|||
|
|
$('#changeReqAllDiv').removeClass('active');
|
|||
|
|
var check = false;
|
|||
|
|
$('.changeReqInput').prop('checked', check);
|
|||
|
|
$('.changeReqInput').each(function() {
|
|||
|
|
var id = $(this).data("id");
|
|||
|
|
$('#checked-clt' + id).removeClass('active');
|
|||
|
|
});
|
|||
|
|
$('#client_toltip_text').text("Выделить все заявки на странице");
|
|||
|
|
} else {
|
|||
|
|
$('#changeReqAll').prop('checked', true);
|
|||
|
|
$('#changeReqAllDiv').addClass('active');
|
|||
|
|
var check = true;
|
|||
|
|
$('.changeReqInput').prop('checked', check);
|
|||
|
|
$('.changeReqInput').each(function() {
|
|||
|
|
var id = $(this).data("id");
|
|||
|
|
$('#checked-clt' + id).addClass('active');
|
|||
|
|
});
|
|||
|
|
$('#client_toltip_text').text("Снять выделение у всех заявок на странице");
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
function to_check_req_all_filter() {
|
|||
|
|
localStorage.removeItem('ids_exception_req');
|
|||
|
|
// if ($('#changeReqAll').prop('checked')) {
|
|||
|
|
$('#changeReqAll').prop('checked', false);
|
|||
|
|
$('#changeReqAllDiv').removeClass('active');
|
|||
|
|
var check = false;
|
|||
|
|
$('.changeReqInput').prop('checked', check);
|
|||
|
|
$('.changeReqInput').each(function() {
|
|||
|
|
var id = $(this).data("id");
|
|||
|
|
$('#checked-clt' + id).removeClass('active');
|
|||
|
|
});
|
|||
|
|
$('#client_toltip_text').text("Выделить все заявки на странице");
|
|||
|
|
// }
|
|||
|
|
if ($('#changeReqAllFilter').prop('checked')) {
|
|||
|
|
$('#changeReqAllFilter').prop('checked', false);
|
|||
|
|
$('#changeReqAllFilterDiv').removeClass('active');
|
|||
|
|
} else {
|
|||
|
|
$('#changeReqAllFilter').prop('checked', true);
|
|||
|
|
$('#changeReqAllFilterDiv').addClass('active');
|
|||
|
|
check_req_all_filter();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
function check_req_all_filter() {
|
|||
|
|
//console.log($('#changeReqAllFilter').prop('checked'));
|
|||
|
|
if ($('#changeReqAllFilter').prop('checked')) {
|
|||
|
|
var check = true;
|
|||
|
|
$('.changeReqInput').prop('checked', check);
|
|||
|
|
$('.changeReqInput').each(function() {
|
|||
|
|
|
|||
|
|
var id = $(this).attr("data-id");
|
|||
|
|
//console.log(id);
|
|||
|
|
$('#checked-clt' + id).addClass('active');
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
function to_check_req_new(id) {
|
|||
|
|
if ($('#changeClient' + id).prop('checked')) {
|
|||
|
|
$('#changeClient' + id).prop('checked', false);
|
|||
|
|
$('#checked-clt' + id).removeClass('active');
|
|||
|
|
} else {
|
|||
|
|
$('#changeClient' + id).prop('checked', true);
|
|||
|
|
$('#checked-clt' + id).addClass('active');
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
function closeFindObject() {
|
|||
|
|
|
|||
|
|
$("#modalFindObj_bg").fadeOut(500);
|
|||
|
|
$("#modalFindObj").toggle(10);
|
|||
|
|
$("body").addClass("lock");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
function kanbanOverscroll() {
|
|||
|
|
|
|||
|
|
$("#requisitions_list .kanban__sortable").sortable({
|
|||
|
|
|
|||
|
|
connectWith: ".connectedSortable",
|
|||
|
|
helper: "clone",
|
|||
|
|
placeholder: "is__highlight",
|
|||
|
|
cancel: '.no-drag',
|
|||
|
|
start: function(event, ui) {
|
|||
|
|
if ($(ui.item).hasClass('no-drag')) {
|
|||
|
|
return false; // блокируем начало drag
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
var prev = $(ui.item).prev('li');
|
|||
|
|
var parent = $(ui.item).closest('ul');
|
|||
|
|
if (requisitions.prev_selectors) {
|
|||
|
|
//console.log(parent.attr("id"));
|
|||
|
|
requisitions.prev_selectors.ul = parent.attr("id");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (prev.length > 0) {
|
|||
|
|
if (requisitions.prev_selectors) {
|
|||
|
|
requisitions.prev_selectors.li = prev.attr("id");
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
update: function(event, ui) {
|
|||
|
|
|
|||
|
|
var id = $('.funnels_client li.active').data("id");
|
|||
|
|
var stage = $(ui.item).closest('.kanban__sortable').data("stage");
|
|||
|
|
var idReq = $(ui.item).attr("id").replace("kanban_item_li_", "");
|
|||
|
|
|
|||
|
|
|
|||
|
|
if (id === undefined || id === 0) {
|
|||
|
|
|
|||
|
|
var turn = 0;
|
|||
|
|
var turns = {};
|
|||
|
|
$(ui.item).closest('.kanban__sortable').find('li').each(function(index) {
|
|||
|
|
if ($(this).attr("id") == "kanban_item_li_" + idReq) {
|
|||
|
|
turn = (index + 1);
|
|||
|
|
}
|
|||
|
|
turns[$(this).attr("id").replace("kanban_item_li_", "")] = (index + 1);
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
|
|||
|
|
if (stage === 8) {
|
|||
|
|
if (!$("#del_client_bg").is(":visible")) {
|
|||
|
|
$("#del_client_bg").fadeIn(500);
|
|||
|
|
|
|||
|
|
$("#del_client").toggle(10);
|
|||
|
|
|
|||
|
|
$("#del_client").find('input[name="id_funnel_client"]').val('0');
|
|||
|
|
$("#del_client").find('input[name="id_del_client"]').val(idReq);
|
|||
|
|
|
|||
|
|
$("#del_client #id_del_req").val(idReq);
|
|||
|
|
set_select_denial_work(0);
|
|||
|
|
|
|||
|
|
$("body").addClass("lock");
|
|||
|
|
}
|
|||
|
|
} else {
|
|||
|
|
axios.post('/ajax/ajax_vue_requisitions.php', {
|
|||
|
|
request: 'add_edit_stage',
|
|||
|
|
stage: stage,
|
|||
|
|
req_id: idReq,
|
|||
|
|
turn: turn,
|
|||
|
|
},
|
|||
|
|
|
|||
|
|
)
|
|||
|
|
.then((response) => {
|
|||
|
|
//console.log(requisitions.view);
|
|||
|
|
if (typeof requisitions !== 'undefined') {
|
|||
|
|
|
|||
|
|
if(requisitions.view == 'kanban'){
|
|||
|
|
requisitions.page = requisitions.page+1;
|
|||
|
|
requisitions.getList();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
})
|
|||
|
|
|
|||
|
|
.catch(function(error) {
|
|||
|
|
console.log(error);
|
|||
|
|
});
|
|||
|
|
/* $.post('/ajax/addEditClient.php', {
|
|||
|
|
stage_edit: stage,
|
|||
|
|
id: idclient,
|
|||
|
|
turn: JSON.stringify(turns)
|
|||
|
|
},
|
|||
|
|
function(data) {
|
|||
|
|
|
|||
|
|
});*/
|
|||
|
|
}
|
|||
|
|
} else {
|
|||
|
|
/* console.log(idReq);
|
|||
|
|
console.log(stage);
|
|||
|
|
console.log(requisitions.req['req' + idReq].steps);*/
|
|||
|
|
if (requisitions.req['req' + idReq].steps.stageId != stage) {
|
|||
|
|
|
|||
|
|
var next = false;
|
|||
|
|
var stageNext = 0;
|
|||
|
|
var adjacent_id = 0;
|
|||
|
|
if(requisitions.req['req' + idReq].funnel_type == 'adjacent'){
|
|||
|
|
adjacent_id = requisitions.req['req' + idReq].steps.adjacent_id;
|
|||
|
|
}
|
|||
|
|
for (var i in requisitions.req['req' + idReq].steps.bar) {
|
|||
|
|
if (requisitions.req['req' + idReq].steps.bar[i].isNext) {
|
|||
|
|
stageNext = requisitions.req['req' + idReq].steps.bar[i].id;
|
|||
|
|
next = true;
|
|||
|
|
}
|
|||
|
|
if (stage == requisitions.req['req' + idReq].steps.bar[i].id) {
|
|||
|
|
if (next) {
|
|||
|
|
//console.log('закрыть');
|
|||
|
|
$.post('/ajax/funnel_step_close.php', { 'step': stageNext, 'client': 0 }, function(res) {
|
|||
|
|
ac.kanbanReq = true;
|
|||
|
|
ac.closesStep = true;
|
|||
|
|
ac.step = JSON.parse(res);
|
|||
|
|
ac.clientId = 0;
|
|||
|
|
ac.reqId = idReq;
|
|||
|
|
ac.stepId = stageNext;
|
|||
|
|
ac.adjacentId = adjacent_id;
|
|||
|
|
ac.openStep();
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
} else {
|
|||
|
|
|
|||
|
|
ac.kanbanReq = true;
|
|||
|
|
ac.reqId = idReq;
|
|||
|
|
ac.adjacentId = adjacent_id;
|
|||
|
|
ac.openPrevStep();
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
/* $.post('/ajax/funnel_step_check_close.php', {'step': stage, 'client': 0, 'req_id':idclient}, function(checkRes){
|
|||
|
|
//console.log(checkRes);
|
|||
|
|
var resParsed = JSON.parse(checkRes);
|
|||
|
|
if (resParsed.result === '0') {
|
|||
|
|
//showAfterStageFail();
|
|||
|
|
ac.clientId = 0;
|
|||
|
|
ac.req_id = idclient;
|
|||
|
|
ac.openPrevStep();
|
|||
|
|
//return;
|
|||
|
|
//$(".kanban__sortable").sortable("cancel");
|
|||
|
|
} else {
|
|||
|
|
if (app_clients_li != '' && app_clients_li == 0) {
|
|||
|
|
|
|||
|
|
} else {
|
|||
|
|
$.post('/ajax/funnel_step_close.php', {
|
|||
|
|
'step': resParsed.etap,
|
|||
|
|
'client': idclient
|
|||
|
|
}, function (res) {
|
|||
|
|
ac.closesStep = true;
|
|||
|
|
ac.kanban = true;
|
|||
|
|
ac.step = JSON.parse(res);
|
|||
|
|
ac.clientId = idclient;
|
|||
|
|
ac.stepId = resParsed.etap;
|
|||
|
|
ac.openStep();
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
});*/
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
$("#requisitions_list .kanban__sortable").disableSelection();
|
|||
|
|
|
|||
|
|
//console.log('safsfds');
|
|||
|
|
$("#requisitions_list .kanban").overscroll({
|
|||
|
|
direction: 'horizontal',
|
|||
|
|
cancelOn: '.kanban__item',
|
|||
|
|
// dragHold: true,
|
|||
|
|
captureWheel: true,
|
|||
|
|
showThumbs: false
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//Для таблицы
|
|||
|
|
function reqBootgrid() {
|
|||
|
|
//добавление вспомогательной таблицы
|
|||
|
|
$("#req_table2").remove();
|
|||
|
|
var node = document.getElementById("req_table").cloneNode(true);
|
|||
|
|
node.id = "req_table2";
|
|||
|
|
$("#req_table").hide();
|
|||
|
|
document.getElementById("req_table").parentNode.append(node);
|
|||
|
|
$("#req_table2").show();
|
|||
|
|
|
|||
|
|
var bg = $("#req_table2").bootgrid({
|
|||
|
|
rowCount: 20,
|
|||
|
|
sorting: false,
|
|||
|
|
ajax: false,
|
|||
|
|
templates: {
|
|||
|
|
search: ""
|
|||
|
|
},
|
|||
|
|
formatters: {
|
|||
|
|
"edit": function(column, row) {
|
|||
|
|
if (row.who_work !== "Все агентство") {
|
|||
|
|
if (row.deleted === "0" || (row.deleted === "1" && row.can_see_contact_closed === "1")) {
|
|||
|
|
return '<a href="javascript:{}" onclick="requisitions.getReq(\'req' + row.edit + '\')" class="no-border" title="Редактировать"><span class="simple-button settings"><i class="jw-action-icon-settings"></i></span></a>';
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else if (row.who_work === "Все агентство") {
|
|||
|
|
if (row.deleted === "0" && row.can_see_contact_common === "1") {
|
|||
|
|
return '<a href="javascript:{}" onclick="requisitions.getReq(\'req' + row.edit + '\')" class="no-border" title="Редактировать"><span class="simple-button settings"><i class="jw-action-icon-settings"></i></span></a>';
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
return '';
|
|||
|
|
},
|
|||
|
|
"priority": function(column, row) {
|
|||
|
|
if (row.priority > 0) {
|
|||
|
|
return '<div title="Категория заявки">' +
|
|||
|
|
'<svg xmlns="http://www.w3.org/2000/svg" x="0px" y="0px" viewBox="0 0 512 512" style="enable-background:new 0 0 512 512;" xml:space="preserve" width="24px" height="24px" class="">' +
|
|||
|
|
'<ellipse cx="256" cy="256" rx="136" ry="136" class="priority' + row.priority + '"/></svg></div>';
|
|||
|
|
}
|
|||
|
|
return '';
|
|||
|
|
},
|
|||
|
|
"name": function(column, row) {
|
|||
|
|
if (row.who_work !== "Все агентство") {
|
|||
|
|
if (row.deleted === "0" || (row.deleted === "1" && row.can_see_contact_closed === "1")) {
|
|||
|
|
return '<a style="text-decoration: underline;" href="javascript:{}" data-id="' + row.edit + '" class="req-events-new no-border">' + row.name + '</a>';
|
|||
|
|
} else {
|
|||
|
|
return row.name;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else if (row.who_work === "Все агентство") {
|
|||
|
|
if (row.deleted === "0" && row.can_see_contact_common === "1") {
|
|||
|
|
return '<a style="text-decoration: underline;" href="javascript:{}" data-id="' + row.edit + '" class="req-events-new no-border">' + row.name + '</a>';
|
|||
|
|
} else {
|
|||
|
|
return row.name;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
return row.name;
|
|||
|
|
},
|
|||
|
|
"type": function(column, row) {
|
|||
|
|
if (row.type == 1) {
|
|||
|
|
return 'Подбор объекта';
|
|||
|
|
} else if (row.type == 2) {
|
|||
|
|
return 'Реализация объекта';
|
|||
|
|
} else if (row.type == 3) {
|
|||
|
|
return 'Другие услуги';
|
|||
|
|
} else if (row.type == 4) {
|
|||
|
|
return 'Спрос по нашему объекту';
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
"hot": function(column, row) {
|
|||
|
|
if (row.hot === '1') {
|
|||
|
|
return '<div class="client-hot" title="Горячий"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" id="Capa_1" x="0px" y="0px" viewBox="0 0 512 512"' +
|
|||
|
|
' style="enable-background:new 0 0 512 512;" xml:space="preserve" width="23px" height="18px" class=""><g><g transform="matrix(1.25 0 0 -1.25 0 45)">' +
|
|||
|
|
' <path style="fill:#F4511E" d="M398.448-179.952c0,23.5-4.18,46.008-11.847,66.843c-5.24-61.375-37.967-92.917-72.162-78.234 c-32.043,13.761-10.445,67.401-8.851,92.996C308.277-54.958,305.451-5.293,226.637,36c32.749-62.651,3.793-101.563-26.586-103.943 c-33.683-2.62-64.542,28.956-53.151,80.216c-36.884-27.179-37.967-72.925-26.586-102.52c11.869-30.847-0.467-56.477-29.423-59.325 c-32.339-3.189-50.314,34.641-33.74,94.922c-28.683-33.775-45.997-77.516-45.997-125.302C11.152-286.902,97.85-373.6,204.8-373.6 S398.448-286.902,398.448-179.952z"' +
|
|||
|
|
' data-original="#F4900C" class="active-path" data-old_color="#FF7043"/><path style="fill:#FFB74D" d="M277.418-279.146c-23.978,9.603-17.554,26.097-23.728,60.27 c-6.174,34.173-29.902,57.912-65.031,68.346c25.63-72.14-14.204-98.726-35.084-103.476c-21.324-4.853-42.751,0.012-45.2,45.644 c-24.867-24.764-40.267-59.028-40.267-96.893c0-4.186,0.199-8.325,0.567-12.415C103.652-352.245,151.729-373.6,204.8-373.6 s101.148,21.355,136.126,55.932c0.369,4.09,0.567,8.229,0.567,12.415c0,24.901-6.652,48.253-18.283,68.358 C324.885-272.026,294.026-285.798,277.418-279.146z"' +
|
|||
|
|
' data-original="#FFCC4D" class="" data-old_color="#FFCC4D"/></g></g></svg></div>'
|
|||
|
|
}
|
|||
|
|
return '';
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
bg.on("loaded.rs.jquery.bootgrid", function(e, c, rows) {
|
|||
|
|
$(".req-events-new").click(function(e) {
|
|||
|
|
|
|||
|
|
e.preventDefault();
|
|||
|
|
e.stopPropagation();
|
|||
|
|
|
|||
|
|
var req_id = $(this).attr("data-id");
|
|||
|
|
var client_id = 0;
|
|||
|
|
var adjacent_id = false;
|
|||
|
|
if($(this).attr("data-adjacent")){
|
|||
|
|
adjacent_id = $(this).attr("data-adjacent");
|
|||
|
|
}
|
|||
|
|
//console.log( $('#session_to_send').val());
|
|||
|
|
openClientEventsWindowNew(client_id, $('#session_to_send').val(), 0, req_id, adjacent_id);
|
|||
|
|
//$('#send_bg_new .closer').click();
|
|||
|
|
return false;
|
|||
|
|
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
|
|||
|
|
let columns = bg.bootgrid("getColumnSettings");
|
|||
|
|
saveClientsTableFields(columns);
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
bg.bootgrid('reload');
|
|||
|
|
$('[data-toggle="dropdown"]').dropdown();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
function findObject(page) {
|
|||
|
|
var param8 = 1;
|
|||
|
|
var param9 = 0;
|
|||
|
|
|
|||
|
|
var filter_requisition_komnat_from = '';
|
|||
|
|
var filter_requisition_komnat_to = '';
|
|||
|
|
var filter_requisition_price_from = '';
|
|||
|
|
var filter_requisition_price_to = '';
|
|||
|
|
var filter_employee = '';
|
|||
|
|
var filter_type = '';
|
|||
|
|
var param5 = 0;
|
|||
|
|
|
|||
|
|
var param3 = 0;
|
|||
|
|
var param4 = 0;
|
|||
|
|
var param7 = 0;
|
|||
|
|
var param6 = 0;
|
|||
|
|
var param10 = '';
|
|||
|
|
var filter_activities = '';
|
|||
|
|
|
|||
|
|
var view = 'list';
|
|||
|
|
//console.log(localStorage['view-adv-find']);
|
|||
|
|
if (localStorage['view-adv-find']) {
|
|||
|
|
if (localStorage['view-adv-find'] == 'table') {
|
|||
|
|
view = 'table';
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
if (view == 'list') {
|
|||
|
|
$('#modalFindObj .view-adv-find-list').addClass('active');
|
|||
|
|
$('#modalFindObj .view-adv-find-table').removeClass('active');
|
|||
|
|
//console.log('1112');
|
|||
|
|
} else if (view == 'table') {
|
|||
|
|
//console.log('111');
|
|||
|
|
$('#modalFindObj .view-adv-find-list').removeClass('active');
|
|||
|
|
$('#modalFindObj .view-adv-find-table').addClass('active');
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$('#modalFindObj .crm__filters .crm__filter-popup .filter-popup__left .filter-popup-type').each(function() {
|
|||
|
|
if ($(this).hasClass('active')) {
|
|||
|
|
param10 = $(this).attr('data-id');
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
if (!!$('#requisitions-objects_filter_price_from').val()) {
|
|||
|
|
filter_requisition_price_from = $('#requisitions-objects_filter_price_from').val()
|
|||
|
|
}
|
|||
|
|
if (!!$('#requisitions-objects_filter_price_to').val()) {
|
|||
|
|
filter_requisition_price_to = $('#requisitions-objects_filter_price_to').val()
|
|||
|
|
}
|
|||
|
|
if (!!$('#requisitions-objects_filter_komnat_from').val()) {
|
|||
|
|
filter_requisition_komnat_from = $('#requisitions-objects_filter_komnat_from').val()
|
|||
|
|
}
|
|||
|
|
if (!!$('#requisitions-objects_filter_komnat_to').val()) {
|
|||
|
|
filter_requisition_komnat_to = $('#requisitions-objects_filter_komnat_to').val()
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//
|
|||
|
|
if ($('#filter_emp_find_obj').val() !== null && $('#filter_emp_find_obj').val() != '')
|
|||
|
|
filter_employee = JSON.stringify($('#filter_emp_find_obj').val());
|
|||
|
|
|
|||
|
|
if ($('#filter-object-type-find-obj').val() !== null && $('#filter-object-type-find-obj').val() != '')
|
|||
|
|
filter_type = JSON.stringify($('#filter-object-type-find-obj').val());
|
|||
|
|
|
|||
|
|
if ($('#filter-object-activities-find-obj').val() !== null && $('#filter-object-activities-find-obj').val() != '')
|
|||
|
|
filter_activities = JSON.stringify($('#filter-object-activities-find-obj').val());
|
|||
|
|
|
|||
|
|
param3 = $('#find_obj___b').attr('data-active');
|
|||
|
|
param4 = $('#find_obj___c').attr('data-active');
|
|||
|
|
param7 = $('#find_obj___d').attr('data-active');
|
|||
|
|
param6 = $('#find_obj___a').attr('data-active');
|
|||
|
|
|
|||
|
|
if ($('#modalFindObj .crm__filter-popup .object-content__sub-actions td > div > div')) {
|
|||
|
|
var __e = $('#modalFindObj .crm__filter-popup .object-content__sub-actions td > div > div');
|
|||
|
|
for (var i = 0; i < __e.length; i++) {
|
|||
|
|
for (var j = 0; j < __e[i].classList.length; j++) {
|
|||
|
|
if (__e[i].classList[j] === 'active') {
|
|||
|
|
param5 += Math.pow(2, i);
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
$('#objectsFind').html('<div style="text-align:center; margin-top: 25px;">' +
|
|||
|
|
'<img src="../images/rocket-spinner.svg" width="96px">' +
|
|||
|
|
'</div>');
|
|||
|
|
//console.log(page);
|
|||
|
|
$.post("/ajax/getFindObjects.php", {
|
|||
|
|
filter_employee: filter_employee, // ответственный
|
|||
|
|
filter_type: filter_type, // тип
|
|||
|
|
price_from: filter_requisition_price_from,
|
|||
|
|
price_to: filter_requisition_price_to,
|
|||
|
|
komnat_from: filter_requisition_komnat_from,
|
|||
|
|
komnat_to: filter_requisition_komnat_to,
|
|||
|
|
param3: param3, // с отчётами
|
|||
|
|
param4: param4, // Бесплатные
|
|||
|
|
param5: param5, // кнопки
|
|||
|
|
param6: param6, // не рекламируется
|
|||
|
|
param7: param7, // пакеты
|
|||
|
|
|
|||
|
|
param10: param10, // 'sale' - продажа, 'rent' - аренда
|
|||
|
|
filter_activities: filter_activities, // теги объекта
|
|||
|
|
search: $('#search_filter_input_find_obj').val(),
|
|||
|
|
view: view,
|
|||
|
|
page: page ? Number(page) : 1,
|
|||
|
|
find_object: 1,
|
|||
|
|
},
|
|||
|
|
function(a) {
|
|||
|
|
//console.log(a);
|
|||
|
|
$('#objectsFind').html(a);
|
|||
|
|
|
|||
|
|
$('.fotorama').fotorama();
|
|||
|
|
$('.find_obj___a1').click(function(e) {
|
|||
|
|
var n = Number(e.target.innerHTML);
|
|||
|
|
//console.log(n);
|
|||
|
|
if (n) {
|
|||
|
|
findObject(n);
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
function set_select_denial_work(req_id, all = false) {
|
|||
|
|
if (!all) {
|
|||
|
|
$('#denial_work-input').html('<img src="../images/rocket-spinner.svg" width="45px">');
|
|||
|
|
} else {
|
|||
|
|
$('#denial_work_all-input').html('<img src="../images/rocket-spinner.svg" width="45px">');
|
|||
|
|
}
|
|||
|
|
var agency_id = $("#session_agency_id").val();
|
|||
|
|
|
|||
|
|
// if ($(this).attr("data-req")) req_id = $(this).attr("data-req");
|
|||
|
|
axios.post('/ajax/modals/selects/getSelectDenialWork.php', { agency_id: agency_id, req_id: req_id, all: all }).then((response) => {
|
|||
|
|
//console.log(response.data);
|
|||
|
|
var selector = 'denial_work';
|
|||
|
|
if (all) {
|
|||
|
|
selector = 'denial_work_all';
|
|||
|
|
}
|
|||
|
|
$('#' + selector + '-input').html(response.data);
|
|||
|
|
$("#" + selector).fastselect({
|
|||
|
|
placeholder: 'Причина закрытия',
|
|||
|
|
|
|||
|
|
});
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
function confirm__User_req(){
|
|||
|
|
|
|||
|
|
open_confirmation__req_client('req', 'confirm_user', 'confirm__user_req');
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
function funnel_Confirm_req(){
|
|||
|
|
|
|||
|
|
open_confirmation__req_client('req', 'confirm_funnel', 'funnel__user_req');
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
function allOnCheckId(id, section){
|
|||
|
|
var ids = [];
|
|||
|
|
if (localStorage['ids_exception_req']) {
|
|||
|
|
var ids_exception_req = localStorage.getItem('ids_exception_req');
|
|||
|
|
|
|||
|
|
ids = JSON.parse(ids_exception_req);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
ids.push(id);
|
|||
|
|
var temp_ids = JSON.stringify(ids);
|
|||
|
|
localStorage['ids_exception_req'] = temp_ids;
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
function allOffCheckId(id, section){
|
|||
|
|
var ids = [];
|
|||
|
|
if (localStorage['ids_exception_req']) {
|
|||
|
|
var ids_exception_req = localStorage.getItem('ids_exception_req');
|
|||
|
|
|
|||
|
|
ids = JSON.parse(ids_exception_req);
|
|||
|
|
}
|
|||
|
|
var tempIds = [];
|
|||
|
|
for(var i=0; i<ids.length; i++){
|
|||
|
|
// console.log(parseInt(ids[i]) != parseInt(id))
|
|||
|
|
if(parseInt(ids[i]) != parseInt(id)){
|
|||
|
|
tempIds.push(ids[i]);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
if(!isEmpty(tempIds)){
|
|||
|
|
ids = tempIds;
|
|||
|
|
var temp_ids = JSON.stringify(ids);
|
|||
|
|
localStorage['ids_exception_req'] = temp_ids;
|
|||
|
|
} else {
|
|||
|
|
localStorage.removeItem('ids_exception_req');
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
function updateFilterEmpSelect(filterType = 'work') {
|
|||
|
|
const formData = new FormData();
|
|||
|
|
formData.append('filter_context', filterType);
|
|||
|
|
axios.post('/ajax/modals/selects/filter_emp_requisitions.php', formData).then((response) => {
|
|||
|
|
$('#req_filter_emp_input').html(response.data);
|
|||
|
|
$("#req_filter_emp").fastselect({
|
|||
|
|
placeholder: 'Ответственный',
|
|||
|
|
onItemCreate: function(item, model) {
|
|||
|
|
if ($('#req_filter_emp').find('option[value=' + model.value + ']').hasClass('bolt')) {
|
|||
|
|
$(item).addClass('bolt');
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
onItemSelect: function(item, val) {
|
|||
|
|
filtr.checkFiltr();
|
|||
|
|
},
|
|||
|
|
onItemDelete: function() {
|
|||
|
|
filtr.checkFiltr();
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$(document).on('click', '.filter-popup-type[id^="filter_stage_"] a', function () {
|
|||
|
|
const $container = $(this).parent('.filter-popup-type');
|
|||
|
|
const filterId = $container.attr('id');
|
|||
|
|
const filterType = filterId.replace('filter_stage_', '');
|
|||
|
|
setTimeout(() => {
|
|||
|
|
const isActive = $container.hasClass('active');
|
|||
|
|
if (filterType === 'close') {
|
|||
|
|
updateFilterEmpSelect(isActive ? 'close' : 'work');
|
|||
|
|
} else {
|
|||
|
|
updateFilterEmpSelect('work');
|
|||
|
|
}
|
|||
|
|
}, 50);
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
|
|||
|
|
function transferClosedReqs() {
|
|||
|
|
var userId = $('#transfer_reqs_closed_pick_owner_user_id').val();
|
|||
|
|
var newOwnerId = $('#transfer_reqs_closed_pick_owner_select').val();
|
|||
|
|
var reqsId = JSON.parse($('#transfer_reqs_closed_pick_owner_req_id').val());
|
|||
|
|
|
|||
|
|
if (!newOwnerId || newOwnerId == 0) {
|
|||
|
|
alert('Пожалуйста, выберите нового ответственного');
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
var all = 0;
|
|||
|
|
if ($('#changeReqAllFilter').prop('checked')) {
|
|||
|
|
all = 1;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
var ids_exception = [];
|
|||
|
|
if (localStorage['ids_exception_req']) {
|
|||
|
|
ids_exception = JSON.parse(localStorage.getItem('ids_exception_req'));
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
axios.post('/ajax/ajax_vue_requisitions.php', {
|
|||
|
|
request: 'transfer_closed_reqs',
|
|||
|
|
from_user_id: userId,
|
|||
|
|
to_user_id: newOwnerId,
|
|||
|
|
reqs_id: reqsId,
|
|||
|
|
all: all,
|
|||
|
|
ids_exception: ids_exception
|
|||
|
|
})
|
|||
|
|
.then(response => {
|
|||
|
|
var result = response.data;
|
|||
|
|
if (result.success) {
|
|||
|
|
alert(result.message);
|
|||
|
|
$("#transfer_reqs_closed_pick_owner_bg").fadeOut(500);
|
|||
|
|
$("#transfer_reqs_closed_pick_owner").fadeOut(10);
|
|||
|
|
$("body").removeClass("lock");
|
|||
|
|
requisitions.getList();
|
|||
|
|
if (result.notification_data) {
|
|||
|
|
axios.post('/ajax/ajax_vue_requisitions.php', {
|
|||
|
|
request: 'send_transfer_closed_notifications',
|
|||
|
|
...result.notification_data
|
|||
|
|
})
|
|||
|
|
.then(notifyResponse => {
|
|||
|
|
console.log('Уведомления в Telegram отправлены:', notifyResponse.data);
|
|||
|
|
})
|
|||
|
|
.catch(notifyError => {
|
|||
|
|
console.error('Ошибка при отправке уведомлений в Telegram:', notifyError);
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
} else {
|
|||
|
|
alert('Ошибка: ' + (result.error || 'Неизвестная ошибка'));
|
|||
|
|
}
|
|||
|
|
})
|
|||
|
|
.catch(error => {
|
|||
|
|
console.error('Ошибка:', error);
|
|||
|
|
alert('Произошла ошибка при передаче заявок');
|
|||
|
|
});
|
|||
|
|
}
|