actual prod
This commit is contained in:
parent
9299bad7e2
commit
00254be53c
394
js/main.js
394
js/main.js
@ -617,19 +617,21 @@ $(document).ready(function() {
|
||||
$("body").on('click', '.to_send', function() {
|
||||
let kol_send = $('#kol_send').val();
|
||||
const id = $(this).attr('data-id');
|
||||
// ключ корзины: листинг — data-token (EXT-{el.id}); свой объект — числовой data-id. DOM-селекторы остаются по data-id.
|
||||
const sendKey = $(this).attr('data-token') || id;
|
||||
const asfilter_id = $(this).attr('data-asfilter-id');
|
||||
if ($('#to_send_button' + id).hasClass('active')) {
|
||||
kol_send--;
|
||||
if (typeof asfilter_id !== "undefined")
|
||||
$.ajax('/ajax/to_send.php?remove=' + id + '&asfilter_id=' + asfilter_id);
|
||||
$.ajax('/ajax/to_send.php?remove=' + encodeURIComponent(sendKey) + '&asfilter_id=' + asfilter_id);
|
||||
else
|
||||
$.ajax('/ajax/to_send.php?remove=' + id);
|
||||
$.ajax('/ajax/to_send.php?remove=' + encodeURIComponent(sendKey));
|
||||
} else {
|
||||
kol_send++;
|
||||
if (typeof asfilter_id !== "undefined")
|
||||
$.ajax('/ajax/to_send.php?add=' + id + '&asfilter_id=' + asfilter_id);
|
||||
$.ajax('/ajax/to_send.php?add=' + encodeURIComponent(sendKey) + '&asfilter_id=' + asfilter_id);
|
||||
else
|
||||
$.ajax('/ajax/to_send.php?add=' + id);
|
||||
$.ajax('/ajax/to_send.php?add=' + encodeURIComponent(sendKey));
|
||||
}
|
||||
$('#num_send').text(kol_send);
|
||||
$('#kol_send').val(kol_send);
|
||||
@ -683,8 +685,10 @@ $(document).ready(function() {
|
||||
$("body").on('click', '.download-photo', function() {
|
||||
|
||||
var id = $(this).attr('data-id');
|
||||
// листинг: бэкенд берёт фото из external_listings (CDN) при src=ext
|
||||
var srcParam = ($(this).attr('data-is-external') == 1) ? '&src=ext' : '';
|
||||
|
||||
window.open('/ajax/getPhotoArchive.php?id=' + id, '_blank');
|
||||
window.open('/ajax/getPhotoArchive.php?id=' + id + srcParam, '_blank');
|
||||
|
||||
});
|
||||
|
||||
@ -969,6 +973,7 @@ $(document).ready(function() {
|
||||
});
|
||||
|
||||
function hide_modal_events() {
|
||||
console.log('[CloseStage] hide_modal_events вызван. closesStep:', typeof ac !== 'undefined' ? ac.closesStep : 'ac undefined');
|
||||
$("#chat-modal__bg__call").hide(10);
|
||||
|
||||
$("#chat-modal__call").hide(10);
|
||||
@ -985,8 +990,6 @@ $(document).ready(function() {
|
||||
|
||||
$("#chat-modal__deal").hide(10);
|
||||
|
||||
$("body").removeClass("lock");
|
||||
|
||||
$("#chat-modal__bg__file").hide(10);
|
||||
|
||||
$("#chat-modal__file").hide(10);
|
||||
@ -1319,6 +1322,8 @@ $(document).ready(function() {
|
||||
$("body").on('click', '.add_from_archive', function() {
|
||||
|
||||
var id = $(this).attr('data-id');
|
||||
// Offset-free: листинг помечен data-src="ext" → копируем с is_external (иначе copyObjectFromArchive уйдёт в own-ветку по el.id и ничего не скопирует)
|
||||
var is_external = $(this).attr('data-src') === 'ext' ? 1 : 0;
|
||||
|
||||
$.ajax({
|
||||
url: '/ajax/checkObjectsCount.php',
|
||||
@ -1326,7 +1331,7 @@ $(document).ready(function() {
|
||||
success: function(data) {
|
||||
var resParsed = JSON.parse(data);
|
||||
if (resParsed.canAdd === '1') {
|
||||
copyToMyObjects(id);
|
||||
copyToMyObjects(id, is_external);
|
||||
} else {
|
||||
showMaxCountWin();
|
||||
}
|
||||
@ -1451,7 +1456,7 @@ $(document).ready(function() {
|
||||
|
||||
$('#kol_obj_send').text(kol_send);
|
||||
|
||||
$('.to_send[data-id="' + id + '"]').removeAttr("checked").removeClass('active');
|
||||
$('.to_send[data-id="' + id + '"], .to_send[data-token="' + id + '"]').removeAttr("checked").removeClass('active');
|
||||
|
||||
$('.object_' + id).toggleClass('active');
|
||||
|
||||
@ -1649,6 +1654,13 @@ $(document).ready(function() {
|
||||
|
||||
var obj = $('#blk_opis' + id);
|
||||
|
||||
// Переносим модалку в <body>, чтобы выйти из stacking context родительской
|
||||
// плашки .fr-send-presentation (z-index: 888) — иначе наш z-index ограничен ею
|
||||
// и шапка/sidebar (z-index: 998) пробивают над модалом.
|
||||
if (obj.length && !obj.parent().is('body')) {
|
||||
obj.appendTo('body');
|
||||
}
|
||||
|
||||
obj.toggle();
|
||||
|
||||
return false;
|
||||
@ -1692,9 +1704,11 @@ $(document).ready(function() {
|
||||
|
||||
var id = $(this).attr('data-id');
|
||||
var obj = $('#blk_opis' + id);
|
||||
var opis = $('#descr' + id).prop('value');
|
||||
// Для contenteditable-div читаем innerHTML, для textarea — value.
|
||||
var descrElem = $('#descr' + id);
|
||||
var opis = descrElem.is('textarea') ? descrElem.prop('value') : descrElem.html();
|
||||
$.ajax({
|
||||
url: '/ajax/edit_opis.php?id_personal=' + id,
|
||||
url: '/ajax/save_draft_description.php?id=' + id,
|
||||
method: 'post',
|
||||
dataType: 'html',
|
||||
data: {
|
||||
@ -1707,6 +1721,90 @@ $(document).ready(function() {
|
||||
|
||||
});
|
||||
|
||||
// Объединённое сохранение цены и описания одной кнопкой.
|
||||
// Цена: локально обновляем href ссылки на PDF (та же логика, что в .save_personal_cena).
|
||||
// Описание: пишем draft в $_SESSION через save_draft_description.php.
|
||||
$("body").on('click', '.save_personal_data', function() {
|
||||
|
||||
for (var instanceName in CKEDITOR.instances) {
|
||||
CKEDITOR.instances[instanceName].updateElement();
|
||||
}
|
||||
|
||||
var id = $(this).attr('data-id');
|
||||
var obj = $('#blk_opis' + id);
|
||||
|
||||
// 1) Сохраняем цену — обновляем href у ссылки генерации PDF (preview).
|
||||
var $linkGenerate = $('#linkGeneratePdf_' + id);
|
||||
var price = $('#edit_personal_cena' + id).val();
|
||||
if ($linkGenerate.length) {
|
||||
var cleanLinkGenerate = removeURLParameter($linkGenerate.attr("href"), 'cena');
|
||||
$linkGenerate.attr("href", cleanLinkGenerate + '&cena=' + price);
|
||||
}
|
||||
|
||||
// 2) Сохраняем описание — отправляем в endpoint, который положит draft в $_SESSION.
|
||||
var descrElem = $('#descr' + id);
|
||||
var opis = descrElem.is('textarea') ? descrElem.prop('value') : descrElem.html();
|
||||
$.ajax({
|
||||
url: '/ajax/save_draft_description.php?id=' + id,
|
||||
method: 'post',
|
||||
dataType: 'html',
|
||||
data: {
|
||||
opis: opis
|
||||
},
|
||||
success: function() {
|
||||
obj.hide();
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
// Закрытие модалки редактирования при клике на затемнённый фон (не на сам контент).
|
||||
$("body").on('click', '.blk_opis_modal', function(e) {
|
||||
if (e.target === this) {
|
||||
$(this).hide();
|
||||
}
|
||||
});
|
||||
|
||||
// Закрытие модалки по кнопке-крестику в правом верхнем углу.
|
||||
$("body").on('click', '.blk_opis_modal_close', function() {
|
||||
var id = $(this).attr('data-id');
|
||||
$('#blk_opis' + id).hide();
|
||||
});
|
||||
|
||||
// Закрытие модалки по клавише Escape.
|
||||
$(document).on('keydown.blk_opis_modal', function(e) {
|
||||
if (e.key === 'Escape' || e.keyCode === 27) {
|
||||
if ($('.blk_opis_modal:visible').length) {
|
||||
$('.blk_opis_modal:visible').hide();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Сброс per-send черновика описания: удаляет запись в $_SESSION и возвращает поле к общему описанию объекта.
|
||||
$("body").on('click', '.reset_personal_opis', function() {
|
||||
var id = $(this).attr('data-id');
|
||||
var obj = $('#blk_opis' + id);
|
||||
$.ajax({
|
||||
url: '/ajax/clear_draft_description.php?id=' + id,
|
||||
method: 'post',
|
||||
dataType: 'html',
|
||||
success: function() {
|
||||
// Возвращаем поле к исходному objects.opis (сохранено в data-default-opis).
|
||||
// Для contenteditable-div пишем innerHTML, для textarea — value.
|
||||
var descrElem = $('#descr' + id);
|
||||
var defaultOpis = descrElem.attr('data-default-opis') || '';
|
||||
if (descrElem.is('textarea')) {
|
||||
descrElem.val(defaultOpis);
|
||||
} else {
|
||||
descrElem.html(defaultOpis);
|
||||
}
|
||||
obj.hide();
|
||||
// Сама кнопка «Сбросить» должна исчезнуть — черновика больше нет.
|
||||
$(document).find('.reset_personal_opis[data-id="' + id + '"]').hide();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('body').on('click', '#calc-button', function () {
|
||||
var ready = parseInt($("#all_ready").val());
|
||||
|
||||
@ -1916,14 +2014,12 @@ $(document).ready(function() {
|
||||
|
||||
$('body').on('click', '.calc-close-modal', function () {
|
||||
$(this).closest('.calc-modal-all').remove();
|
||||
$('body').css('overflow', '');
|
||||
});
|
||||
|
||||
|
||||
$('body').on('click', '.calc-close-modal', function () {
|
||||
const $modal = $(this).closest('.calc-modal-all');
|
||||
$modal.remove();
|
||||
$('body').css('overflow', '');
|
||||
});
|
||||
|
||||
$('body').on('change', '#frequency_payment', function () {
|
||||
@ -2122,24 +2218,24 @@ $(document).ready(function() {
|
||||
.replace(/\u00A0/g, '')
|
||||
.replace(',', '.');
|
||||
return parseFloat(rawVal) || 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$('body').on('keypress', '#custom_frequency, #installment_period', function (e) {
|
||||
$('body').on('keypress', '#custom_frequency, #installment_period', function (e) {
|
||||
if (!/^[0-9]$/.test(e.key)) {
|
||||
e.preventDefault();
|
||||
}
|
||||
if ($(this).val().length === 0 && e.key === '0') {
|
||||
e.preventDefault();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('body').on('paste', '#custom_frequency, #installment_period', function (e) {
|
||||
$('body').on('paste', '#custom_frequency, #installment_period', function (e) {
|
||||
const paste = (e.originalEvent || e).clipboardData.getData('text');
|
||||
if (!/^[1-9][0-9]*$/.test(paste)) {
|
||||
e.preventDefault();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
@ -4063,7 +4159,7 @@ $('body').on('paste', '#custom_frequency, #installment_period', function (e) {
|
||||
})
|
||||
|
||||
$("body").on('click', '.delClientAgent', function() {
|
||||
|
||||
console.log('kotsss');
|
||||
$("#del_client_bg").fadeIn(500);
|
||||
|
||||
$("#del_client").toggle(10);
|
||||
@ -5361,6 +5457,9 @@ $('body').on('paste', '#custom_frequency, #installment_period', function (e) {
|
||||
|
||||
var id_object = $(this).attr('data-id');
|
||||
var id_event = $(this).attr('data-event-id');
|
||||
// offset-free: маркер листинга прокинут в data-src окна задач (openEventsWindow); src=ext роутит в external_listing_*
|
||||
var isExternal = $(this).attr('data-src') === 'ext';
|
||||
var srcParam = isExternal ? '&src=ext' : '';
|
||||
|
||||
$('#event-chat').html('<div class="preloader"></div>');
|
||||
$('#event-chat .preloader').css({
|
||||
@ -5374,13 +5473,14 @@ $('body').on('paste', '#custom_frequency, #installment_period', function (e) {
|
||||
data: {
|
||||
"object_id": id_object,
|
||||
"event_id": id_event || null,
|
||||
"comment": text
|
||||
"comment": text,
|
||||
"src": isExternal ? 'ext' : ''
|
||||
},
|
||||
success: function() {
|
||||
$('#chatTextArea').val('');
|
||||
$('.jw__object.item[id="' + id_object + '"] .object-content__main-actions .addEditNote').addClass('active');
|
||||
$.ajax({
|
||||
url: '/ajax/getLogForEvents.php?object_id=' + id_object,
|
||||
url: '/ajax/getLogForEvents.php?object_id=' + id_object + srcParam,
|
||||
success: function(data) {
|
||||
$('#event-chat').html(data);
|
||||
$('.history__chat').scrollTop($('#event-chat').prop("scrollHeight"));
|
||||
@ -5444,6 +5544,8 @@ $('body').on('paste', '#custom_frequency, #installment_period', function (e) {
|
||||
if (text && $.trim(text)) {
|
||||
var id_object = $(this).attr('data-id');
|
||||
var id_note = $(this).attr('data-note-id');
|
||||
// offset-free: маркер листинга на кнопке заметок (openNotesWindow); src=ext роутит сводку/заметки в external_listing_*
|
||||
var srcParam = ($(this).attr('data-src') === 'ext') ? '&src=ext' : '';
|
||||
|
||||
$('#notes-chat').html('<div class="preloader"></div>');
|
||||
$('#notes-chat .preloader').css({
|
||||
@ -5457,21 +5559,24 @@ $('body').on('paste', '#custom_frequency, #installment_period', function (e) {
|
||||
data: {
|
||||
"object_id": id_object,
|
||||
"note_id": id_note,
|
||||
"message": text
|
||||
"message": text,
|
||||
"src": (srcParam ? 'ext' : '')
|
||||
},
|
||||
success: function() {
|
||||
$('#chatTextArea2').val('');
|
||||
$.ajax({
|
||||
url: '/ajax/getLogForNotes.php?object_id=' + id_object,
|
||||
url: '/ajax/getLogForNotes.php?object_id=' + id_object + srcParam,
|
||||
success: function(data) {
|
||||
//console.log(data);
|
||||
$('#notes-chat').html(data);
|
||||
$('#object-notes .chat-form #cancelTextButton2').click();
|
||||
|
||||
// карточка адресуется по реальному id (data-id листинга = el.id); снимаем витринный префикс EXT-
|
||||
var note_card_id = String(id_object).replace(/^EXT-?/i, '');
|
||||
if ($('#notes-chat .chat-block').length > 0)
|
||||
$('.addEditNote[data-id="' + id_object + '"]').addClass('haveNotes');
|
||||
$('.addEditNote[data-id="' + note_card_id + '"]').addClass('haveNotes');
|
||||
else
|
||||
$('.addEditNote[data-id="' + id_object + '"]').removeClass('haveNotes');
|
||||
$('.addEditNote[data-id="' + note_card_id + '"]').removeClass('haveNotes');
|
||||
|
||||
|
||||
$('.history__chat').scrollTop($('#notes-chat').prop("scrollHeight"));
|
||||
@ -5539,6 +5644,8 @@ $('body').on('paste', '#custom_frequency, #installment_period', function (e) {
|
||||
if (type == 'object') {
|
||||
|
||||
var id_object = $('#submitTextButton').attr('data-id');
|
||||
// offset-free: маркер листинга на кнопке окна задач (openEventsWindow); src=ext роутит лог в external_listing_*
|
||||
var srcParam = ($('#submitTextButton').attr('data-src') === 'ext') ? '&src=ext' : '';
|
||||
|
||||
$('#event-chat').html('<div class="preloader"></div>');
|
||||
$('#event-chat .preloader').css({
|
||||
@ -5554,6 +5661,7 @@ $('body').on('paste', '#custom_frequency, #installment_period', function (e) {
|
||||
"comment": text,
|
||||
"schedule_date": date,
|
||||
"who_work": who_work,
|
||||
"src": (srcParam ? 'ext' : '')
|
||||
},
|
||||
success: function() {
|
||||
$("#chat-modal__bg__call").hide(10);
|
||||
@ -5561,7 +5669,7 @@ $('body').on('paste', '#custom_frequency, #installment_period', function (e) {
|
||||
$('#callComment').val('');
|
||||
$('#callDatetime').datepicker().data('datepicker').selectDate(new Date());
|
||||
$.ajax({
|
||||
url: '/ajax/getLogForEvents.php?object_id=' + id_object,
|
||||
url: '/ajax/getLogForEvents.php?object_id=' + id_object + srcParam,
|
||||
success: function(data) {
|
||||
$('#event-chat').html(data);
|
||||
$('.history__chat').scrollTop($('#event-chat').prop("scrollHeight"));
|
||||
@ -5649,6 +5757,7 @@ $('body').on('paste', '#custom_frequency, #installment_period', function (e) {
|
||||
"schedule_date": date,
|
||||
"req_id": req_id,
|
||||
"who_work": who_work,
|
||||
"src": ($('#submitTextButton').attr('data-src') === 'ext' ? 'ext' : '')
|
||||
},
|
||||
success: function() {
|
||||
//console.log(data);
|
||||
@ -5658,7 +5767,7 @@ $('body').on('paste', '#custom_frequency, #installment_period', function (e) {
|
||||
$('#showAddress').val('');
|
||||
$('#showDatetime').datepicker().data('datepicker').selectDate(new Date());
|
||||
$.ajax({
|
||||
url: '/ajax/getLogForEvents.php?object_id=' + id_object,
|
||||
url: '/ajax/getLogForEvents.php?object_id=' + id_object + ($('#submitTextButton').attr('data-src') === 'ext' ? '&src=ext' : ''),
|
||||
success: function(data) {
|
||||
$('#event-chat').html(data);
|
||||
$('.history__chat').scrollTop($('#event-chat').prop("scrollHeight"));
|
||||
@ -5746,6 +5855,7 @@ $('body').on('paste', '#custom_frequency, #installment_period', function (e) {
|
||||
"address": address,
|
||||
"schedule_date": date,
|
||||
"who_work": who_work,
|
||||
"src": ($('#submitTextButton').attr('data-src') === 'ext' ? 'ext' : '')
|
||||
},
|
||||
success: function() {
|
||||
$("#chat-modal__bg__meeting").hide(10);
|
||||
@ -5754,7 +5864,7 @@ $('body').on('paste', '#custom_frequency, #installment_period', function (e) {
|
||||
$('#meetAddress').val('');
|
||||
$('#meetDatetime').datepicker().data('datepicker').selectDate(new Date());
|
||||
$.ajax({
|
||||
url: '/ajax/getLogForEvents.php?object_id=' + id_object,
|
||||
url: '/ajax/getLogForEvents.php?object_id=' + id_object + ($('#submitTextButton').attr('data-src') === 'ext' ? '&src=ext' : ''),
|
||||
success: function(data) {
|
||||
$('#event-chat').html(data);
|
||||
$('.history__chat').scrollTop($('#event-chat').prop("scrollHeight"));
|
||||
@ -5859,13 +5969,14 @@ $('body').on('paste', '#custom_frequency, #installment_period', function (e) {
|
||||
"client_ids": client_ids,
|
||||
},
|
||||
success: function() {
|
||||
console.log('[Deal] Сделка сохранена (addDealButton/object). closesStep:', ac.closesStep);
|
||||
$("#chat-modal__bg__deal").hide(10);
|
||||
$("#chat-modal__deal").hide(10);
|
||||
$('#dealComment').val('');
|
||||
$('#dealSum').val('');
|
||||
$('#dealDatetime').datepicker().data('datepicker').selectDate(new Date());
|
||||
$.ajax({
|
||||
url: '/ajax/getLogForEvents.php?object_id=' + id_object,
|
||||
url: '/ajax/getLogForEvents.php?object_id=' + id_object + ($('#submitTextButton').attr('data-src') === 'ext' ? '&src=ext' : ''),
|
||||
success: function(data) {
|
||||
$('#event-chat').html(data);
|
||||
$('.history__chat').scrollTop($('#event-chat').prop("scrollHeight"));
|
||||
@ -5900,9 +6011,9 @@ $('body').on('paste', '#custom_frequency, #installment_period', function (e) {
|
||||
"schedule_date": date
|
||||
},
|
||||
success: function() {
|
||||
console.log('[Deal] Сделка сохранена (addDealButton/client). closesStep:', ac.closesStep);
|
||||
$("#chat-modal__bg__deal").hide(10);
|
||||
$("#chat-modal__deal").hide(10);
|
||||
$("body").removeClass("lock");
|
||||
$('#dealComment').val('');
|
||||
$('#dealSum').val('');
|
||||
$('#dealDatetime').datepicker().data('datepicker').selectDate(new Date());
|
||||
@ -5928,14 +6039,17 @@ $('body').on('paste', '#custom_frequency, #installment_period', function (e) {
|
||||
$("body").on('click', '.add-event,.add-event-full', function(e) {
|
||||
e.stopPropagation();
|
||||
var id_object = $(this).attr('data-id');
|
||||
openEventsWindow(id_object);
|
||||
// offset-free: листинг помечен маркером data-src="ext" на кнопке/карточке (id == реальный el.id, диапазон не различает)
|
||||
var isExternal = isExternalListingTrigger(this);
|
||||
openEventsWindow(id_object, isExternal);
|
||||
return false;
|
||||
});
|
||||
|
||||
$("body").on('click', '.addEditNote, .add-note', function(e) {
|
||||
e.stopPropagation();
|
||||
let id = $(this).attr('data-id');
|
||||
openNotesWindow(id);
|
||||
var isExternal = isExternalListingTrigger(this);
|
||||
openNotesWindow(id, isExternal);
|
||||
return false;
|
||||
});
|
||||
|
||||
@ -6314,8 +6428,10 @@ $('body').on('paste', '#custom_frequency, #installment_period', function (e) {
|
||||
$('.modal__content').html('<div class="object-content__preloader" style="display: block;"><img src="/images/rocket-spinner.svg" width="96px"></div>');
|
||||
$('.analytics-modal').addClass('is-opened');
|
||||
$('#filter-sort-order option[value=date]').prop('selected', true);
|
||||
// Листинг парсера как исходный объект аналитики: пробрасываем маркер src=ext (offset-free, el.id коллизит с objects.id)
|
||||
var analyticsSrc = ($(this).attr('data-src') === 'ext') ? '&src=ext' : '';
|
||||
$.ajax({
|
||||
url: '/ajax/modals/analyticsWinContent.php?page=1&objectId=' + $(this).attr('data-id'),
|
||||
url: '/ajax/modals/analyticsWinContent.php?page=1&objectId=' + $(this).attr('data-id') + analyticsSrc,
|
||||
success: function(data) {
|
||||
$(".modal__content").html(data);
|
||||
let modalContainer = document.querySelector('.analytics-modal').querySelector('.modal__container');
|
||||
@ -6364,7 +6480,13 @@ $('body').on('paste', '#custom_frequency, #installment_period', function (e) {
|
||||
$("#modalObjectsAnalysis").get(0).scrollIntoView();
|
||||
|
||||
setTimeout(function() {
|
||||
$('#objectsAnalysisContainer .fotorama').fotorama();
|
||||
// карточки используют swiper (не fotorama) — инициализируем галереи фото с рабочими стрелками
|
||||
if (typeof Swiper !== 'undefined') {
|
||||
document.querySelectorAll('#objectsAnalysisContainer .js-object-swiper').forEach(function (sw) {
|
||||
if (sw.swiper) return;
|
||||
new Swiper(sw, { slidesPerView: 1, spaceBetween: 10, navigation: { nextEl: sw.querySelector('.swiper-button-next'), prevEl: sw.querySelector('.swiper-button-prev') } });
|
||||
});
|
||||
}
|
||||
}, 100);
|
||||
}
|
||||
});
|
||||
@ -6509,7 +6631,10 @@ $('body').on('paste', '#custom_frequency, #installment_period', function (e) {
|
||||
object_id = parseInt($(this).attr("data-object-id"));
|
||||
}
|
||||
|
||||
$('#addTaskBgObj .action_obj_call').attr("data-objectid", object_id);
|
||||
// offset-free: для найденного листинга (data-src="ext") сохранение нового события адресуем витринным
|
||||
// EXT-{el.id} — changeEventsObj по нему уйдёт в external_listing_events (диапазон id больше не различает)
|
||||
var objectIdForSave = ($(this).attr('data-src') === 'ext') ? ('EXT-' + object_id) : object_id;
|
||||
$('#addTaskBgObj .action_obj_call').attr("data-objectid", objectIdForSave);
|
||||
editEventObj(0, 'even');
|
||||
});
|
||||
|
||||
@ -6518,18 +6643,24 @@ $('body').on('paste', '#custom_frequency, #installment_period', function (e) {
|
||||
var selector = '#chat-modal__showing';
|
||||
var id = 0;
|
||||
var object_id = 0;
|
||||
$('#showRequisitionsInput').closest('.form-block').show();
|
||||
if ($(this).attr("data-object-id")) {
|
||||
object_id = parseInt($(this).attr("data-object-id"));
|
||||
id = object_id;
|
||||
}
|
||||
$('#showRequisitionsInput').html('');
|
||||
// offset-free: найденный листинг помечен маркером data-src="ext" (openEventsWindow); показ не привязан к
|
||||
// заявке покупателя — поле «Заявка» скрываем. Диапазон id больше не различает (el.id коллизит с objects.id).
|
||||
if ($(this).attr('data-src') === 'ext') {
|
||||
$('#showRequisitionsInput').closest('.form-block').hide();
|
||||
} else {
|
||||
$('#showRequisitionsInput').closest('.form-block').show();
|
||||
$("#showRequisitionsInput").html('<input type="text" id="showRequisitions" data-url="/ajax/lists/list_reqs_object.php?id=' + object_id + '" data-load-once="true">');
|
||||
|
||||
$('#showRequisitions').fastselect({
|
||||
placeholder: 'Заявка',
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
$('#showDatetime').datepicker().data('datepicker').selectDate(new Date());
|
||||
$('#addShowButton').show();
|
||||
@ -6700,6 +6831,7 @@ $('body').on('paste', '#custom_frequency, #installment_period', function (e) {
|
||||
$('#chat-modal__deal form #dealBlank').closest(".inputs").find(".fstControls input.hidenClass").attr('type', "text");
|
||||
$('#chat-modal__deal form #dealBlank').closest(".inputs").find(".fstControls input.hidenClass").removeClass('hidenClass');
|
||||
|
||||
console.log('[Deal] Открытие модала сделки из étape. closesStep:', ac.closesStep);
|
||||
$("#chat-modal__bg__deal").fadeIn(500);
|
||||
$("#chat-modal__deal").toggle(10);
|
||||
$("body").addClass("lock");
|
||||
@ -7782,7 +7914,8 @@ $('body').on('paste', '#custom_frequency, #installment_period', function (e) {
|
||||
"object_id": id_object,
|
||||
"comment": text,
|
||||
"address": address,
|
||||
"schedule_date": date
|
||||
"schedule_date": date,
|
||||
"src": ($('#submitTextButton').attr('data-src') === 'ext' ? 'ext' : '')
|
||||
},
|
||||
success: function() {
|
||||
$("#chat-modal__bg__showing").hide(10);
|
||||
@ -7791,7 +7924,7 @@ $('body').on('paste', '#custom_frequency, #installment_period', function (e) {
|
||||
$('#showAddress').val('');
|
||||
$('#showDatetime').datepicker().data('datepicker').selectDate(new Date());
|
||||
$.ajax({
|
||||
url: '/ajax/getLogForEvents.php?object_id=' + id_object,
|
||||
url: '/ajax/getLogForEvents.php?object_id=' + id_object + ($('#submitTextButton').attr('data-src') === 'ext' ? '&src=ext' : ''),
|
||||
success: function(data) {
|
||||
$('#event-chat').html(data);
|
||||
$('.history__chat').scrollTop($('#event-chat').prop("scrollHeight"));
|
||||
@ -7902,7 +8035,8 @@ $('body').on('paste', '#custom_frequency, #installment_period', function (e) {
|
||||
"object_id": id_object,
|
||||
"comment": text,
|
||||
"address": address,
|
||||
"schedule_date": date
|
||||
"schedule_date": date,
|
||||
"src": ($('#submitTextButton').attr('data-src') === 'ext' ? 'ext' : '')
|
||||
},
|
||||
success: function() {
|
||||
$("#chat-modal__bg__meeting").hide(10);
|
||||
@ -7911,7 +8045,7 @@ $('body').on('paste', '#custom_frequency, #installment_period', function (e) {
|
||||
$('#meetAddress').val('');
|
||||
$('#meetDatetime').datepicker().data('datepicker').selectDate(new Date());
|
||||
$.ajax({
|
||||
url: '/ajax/getLogForEvents.php?object_id=' + id_object,
|
||||
url: '/ajax/getLogForEvents.php?object_id=' + id_object + ($('#submitTextButton').attr('data-src') === 'ext' ? '&src=ext' : ''),
|
||||
success: function(data) {
|
||||
$('#event-chat').html(data);
|
||||
$('.history__chat').scrollTop($('#event-chat').prop("scrollHeight"));
|
||||
@ -8028,7 +8162,7 @@ $('body').on('paste', '#custom_frequency, #installment_period', function (e) {
|
||||
$('#dealSum').val('');
|
||||
$('#dealDatetime').datepicker().data('datepicker').selectDate(new Date());
|
||||
$.ajax({
|
||||
url: '/ajax/getLogForEvents.php?object_id=' + id_object,
|
||||
url: '/ajax/getLogForEvents.php?object_id=' + id_object + ($('#submitTextButton').attr('data-src') === 'ext' ? '&src=ext' : ''),
|
||||
success: function(data) {
|
||||
$('#event-chat').html(data);
|
||||
$('.history__chat').scrollTop($('#event-chat').prop("scrollHeight"));
|
||||
@ -8080,9 +8214,10 @@ $('body').on('paste', '#custom_frequency, #installment_period', function (e) {
|
||||
"clients_ids": clients_ids,
|
||||
},
|
||||
success: function(data) {
|
||||
console.log('[Deal] Сделка сохранена (addDealButtonNew). closesStep:', ac.closesStep, 'data:', data);
|
||||
console.log(data);
|
||||
$("#chat-modal__bg__deal").hide(10);
|
||||
$("#chat-modal__deal").hide(10);
|
||||
$("body").removeClass("lock");
|
||||
$('#dealComment').val('');
|
||||
$('#dealSum').val('');
|
||||
$('#dealDatetime').datepicker().data('datepicker').selectDate(new Date());
|
||||
@ -8156,7 +8291,7 @@ $('body').on('paste', '#custom_frequency, #installment_period', function (e) {
|
||||
$("#chat-modal__file").hide(10);
|
||||
$('#fileComment').val('');
|
||||
$.ajax({
|
||||
url: '/ajax/getLogForEvents.php?object_id=' + id_object,
|
||||
url: '/ajax/getLogForEvents.php?object_id=' + id_object + ($('#submitTextButton').attr('data-src') === 'ext' ? '&src=ext' : ''),
|
||||
success: function(data) {
|
||||
$('#event-chat').html(data);
|
||||
$('.history__chat').scrollTop($('#event-chat').prop("scrollHeight"));
|
||||
@ -8295,7 +8430,9 @@ $('body').on('paste', '#custom_frequency, #installment_period', function (e) {
|
||||
//
|
||||
$('body').on('click', '.fltr-req-list', function() {
|
||||
let object_id = $(this).data('id');
|
||||
openAutoSearchObjectReq(object_id);
|
||||
// Offset-free: листинг помечен data-src="ext" → шлём is_external, иначе el.id коллизит с objects.id.
|
||||
let is_external = $(this).data('src') === 'ext' ? 1 : 0;
|
||||
openAutoSearchObjectReq(object_id, is_external);
|
||||
});
|
||||
|
||||
// Закрыть модал результатов автопоиска
|
||||
@ -8326,7 +8463,8 @@ $('body').on('paste', '#custom_frequency, #installment_period', function (e) {
|
||||
})
|
||||
$('body').on('click', '.antiznakRequest', function() {
|
||||
let object_id = $(this).attr("data-id");
|
||||
antiznak_modals.open_modal_photos(object_id);
|
||||
let is_external = $(this).attr("data-is-external") == 1;
|
||||
antiznak_modals.open_modal_photos(object_id, is_external);
|
||||
})
|
||||
});
|
||||
|
||||
@ -8826,7 +8964,7 @@ function saveNewBuildingsCatalog(
|
||||
checkboxAddresses,
|
||||
availableCatalogs,
|
||||
request
|
||||
) {
|
||||
) {
|
||||
$.ajax({
|
||||
url: "/ajax/send_catalog.php",
|
||||
|
||||
@ -8888,9 +9026,9 @@ function saveNewBuildingsCatalog(
|
||||
console.log("error", link);
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function saveComplexesCatalog(
|
||||
function saveComplexesCatalog(
|
||||
clients,
|
||||
theme,
|
||||
txt,
|
||||
@ -8902,7 +9040,7 @@ function saveNewBuildingsCatalog(
|
||||
checkboxAddresses,
|
||||
availableCatalogs,
|
||||
request
|
||||
) {
|
||||
) {
|
||||
$.ajax({
|
||||
url: "/ajax/send_catalog.php",
|
||||
|
||||
@ -8966,7 +9104,7 @@ function saveNewBuildingsCatalog(
|
||||
console.log("error", link);
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function generateMailWithLinksAndSend(clients, theme, txt, send_type, closes_contact, priсes, checkboxAddresses, request, id) {
|
||||
|
||||
@ -9755,10 +9893,16 @@ function testIfResendAllCanBeActive(oneElement) {
|
||||
});
|
||||
}
|
||||
|
||||
function updateEventState(id) {
|
||||
function updateEventState(id, from) {
|
||||
if (id) {
|
||||
// from='listing' (из calendarEvents) → setEventViewed завершает в external_listing_events по id события,
|
||||
// а не в user_object_events (id-коллизия). Старые вызовы с одним аргументом работают как прежде.
|
||||
var url = '/ajax/setEventViewed.php?id=' + id;
|
||||
if (from) {
|
||||
url += '&from=' + from;
|
||||
}
|
||||
$.ajax({
|
||||
url: '/ajax/setEventViewed.php?id=' + id,
|
||||
url: url,
|
||||
success: function(data) {
|
||||
$('#calendarCounter').html(data);
|
||||
$('#calendar').fullCalendar('refetchEvents');
|
||||
@ -9785,8 +9929,22 @@ function updateClientEventState() {
|
||||
}*/
|
||||
}
|
||||
|
||||
function openEventsWindow(id_object) {
|
||||
// Определяет, открыта ли карточка задач/заметок для найденного листинга парсера. Offset-free: диапазон id больше
|
||||
// не различает (el.id коллизит с objects.id), поэтому смотрим явный маркер data-src="ext" — на самой кнопке либо
|
||||
// на корне карточки .jw__object.item (его проставляет рендер списка/«Поиска» для source=1 строк).
|
||||
function isExternalListingTrigger(el) {
|
||||
var $el = $(el);
|
||||
if ($el.attr('data-src') === 'ext') return true;
|
||||
return $el.closest('.jw__object.item').attr('data-src') === 'ext';
|
||||
}
|
||||
|
||||
// isExternal — найденный листинг парсера. Offset-free: id_object == реальный el.id, листинг помечаем явным
|
||||
// маркером src=ext (диапазон id больше не различает: el.id коллизит с objects.id). Маркер прокидываем во все
|
||||
// downstream-URL окна задач и в data-src кнопок «+», чтобы обработчики роутили в external_listing_*.
|
||||
function openEventsWindow(id_object, isExternal) {
|
||||
var srcParam = isExternal ? '&src=ext' : '';
|
||||
$('#submitTextButton').attr('data-id', id_object);
|
||||
$('#submitTextButton').attr('data-src', isExternal ? 'ext' : '');
|
||||
|
||||
$('#object-info-block').html('<div class="preloader"></div>');
|
||||
$('#event-chat').html('<div class="preloader"></div>');
|
||||
@ -9794,10 +9952,18 @@ function openEventsWindow(id_object) {
|
||||
$('#object-info-block .preloader').css({ "background": "url(/images/ajax_preloader.gif) no-repeat center center", "background-size": "26px 26px" });
|
||||
$('#event-chat .preloader').css({ "background": "url(/images/ajax_preloader.gif) no-repeat center center", "background-size": "26px 26px" });
|
||||
|
||||
$('#chat__new-deal').attr('data-object-id', id_object);
|
||||
$('#chat__new-file').attr('data-object-id', id_object);
|
||||
$('#chat__new-showing').attr('data-object-id', id_object);
|
||||
$('#chat__new-event').attr('data-object-id', id_object);
|
||||
$('#chat__new-deal').attr('data-object-id', id_object).attr('data-src', isExternal ? 'ext' : '');
|
||||
$('#chat__new-file').attr('data-object-id', id_object).attr('data-src', isExternal ? 'ext' : '');
|
||||
$('#chat__new-showing').attr('data-object-id', id_object).attr('data-src', isExternal ? 'ext' : '');
|
||||
$('#chat__new-event').attr('data-object-id', id_object).attr('data-src', isExternal ? 'ext' : '');
|
||||
|
||||
// Листинг парсера read-only: «Сделка» (доступна только после копии в CRM) и «Файл» (файлы листингу запрещены) — скрыть;
|
||||
// для своего объекта — показать (меню глобальное, переиспользуется). Звонок/Встреча/Показ/Задача листингу разрешены.
|
||||
if (isExternal) {
|
||||
$('#chat__new-deal, #chat__new-file').hide();
|
||||
} else {
|
||||
$('#chat__new-deal, #chat__new-file').show();
|
||||
}
|
||||
|
||||
$("#object-history__bg").fadeIn(500);
|
||||
|
||||
@ -9805,29 +9971,34 @@ function openEventsWindow(id_object) {
|
||||
|
||||
$("body").addClass("lock");
|
||||
|
||||
// Панели независимы — грузим параллельно (раньше лог висел внутри success инфо-панели → времена суммировались)
|
||||
$.ajax({
|
||||
url: '/ajax/getObjectInfoForEvents.php?id=' + id_object,
|
||||
url: '/ajax/getObjectInfoForEvents.php?id=' + id_object + srcParam,
|
||||
success: function(data) {
|
||||
$('#object-info-block').html(data);
|
||||
|
||||
$.ajax({
|
||||
url: '/ajax/getLogForEvents.php?object_id=' + id_object,
|
||||
success: function(data) {
|
||||
$('#event-chat').html(data);
|
||||
$('.history__chat').scrollTop($('#event-chat').prop("scrollHeight"));
|
||||
}
|
||||
});
|
||||
|
||||
setTimeout(function() {
|
||||
$('#object-info-block .fotorama').fotorama();
|
||||
initializeMapOnEventWindow();
|
||||
}, 100);
|
||||
}
|
||||
});
|
||||
|
||||
$.ajax({
|
||||
url: '/ajax/getLogForEvents.php?object_id=' + id_object + srcParam,
|
||||
success: function(data) {
|
||||
$('#event-chat').html(data);
|
||||
$('.history__chat').scrollTop($('#event-chat').prop("scrollHeight"));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function openNotesWindow(id_object) {
|
||||
// isExternal — найденный листинг парсера (offset-free, см. openEventsWindow): id_object == реальный el.id,
|
||||
// маркер src=ext прокидываем в URL сводки и заметок, чтобы читать external_listing_notes, а не object_notes.
|
||||
function openNotesWindow(id_object, isExternal) {
|
||||
var srcParam = isExternal ? '&src=ext' : '';
|
||||
$('#submitTextButton2').attr('data-id', id_object);
|
||||
$('#submitTextButton2').attr('data-src', isExternal ? 'ext' : '');
|
||||
|
||||
$('#object-info-block2').html('<div class="preloader"></div>');
|
||||
$('#notes-chat').html('<div class="preloader"></div>');
|
||||
@ -9841,12 +10012,12 @@ function openNotesWindow(id_object) {
|
||||
$("body").addClass("lock");
|
||||
|
||||
$.ajax({
|
||||
url: '/ajax/getObjectInfoForEvents.php?id=' + id_object,
|
||||
url: '/ajax/getObjectInfoForEvents.php?id=' + id_object + srcParam,
|
||||
success: function(data) {
|
||||
$('#object-info-block2').html(data);
|
||||
|
||||
$.ajax({
|
||||
url: '/ajax/getLogForNotes.php?object_id=' + id_object,
|
||||
url: '/ajax/getLogForNotes.php?object_id=' + id_object + srcParam,
|
||||
success: function(data) {
|
||||
//console.log(data);
|
||||
$('#notes-chat').html(data);
|
||||
@ -10235,6 +10406,7 @@ function openClientEventsWindow(id_client) {
|
||||
function switchPotential() {
|
||||
var id_object = $('#potentialObj').attr('data-id');
|
||||
var state = $('#potentialObj').prop('checked');
|
||||
var is_external = $('#potentialObj').attr('data-is-external') == 1 ? 1 : 0;
|
||||
|
||||
if (id_object) {
|
||||
$.ajax({
|
||||
@ -10242,7 +10414,8 @@ function switchPotential() {
|
||||
method: "post",
|
||||
data: {
|
||||
"id_object": id_object,
|
||||
"state": state ? 1 : 0
|
||||
"state": state ? 1 : 0,
|
||||
"is_external": is_external
|
||||
},
|
||||
success: function() {
|
||||
//nothing
|
||||
@ -13203,7 +13376,8 @@ function copyMyObjects(objId) {
|
||||
data: {
|
||||
"objId": objId
|
||||
},
|
||||
success: function() {
|
||||
success: function(d) {
|
||||
console.log(d);
|
||||
$.ajax({
|
||||
url: '/ajax/modals/afterCopyMyObjectWinContent.php',
|
||||
success: function(data) {
|
||||
@ -13227,7 +13401,7 @@ function closeAfterAddCopyMyObject() {
|
||||
window.location.reload(true);
|
||||
}
|
||||
|
||||
function copyToMyObjects(objId) {
|
||||
function copyToMyObjects(objId, is_external) {
|
||||
if (objId) {
|
||||
$.ajax({
|
||||
url: '/ajax/modals/afterAddFromArchiveWinContent.php',
|
||||
@ -13236,10 +13410,13 @@ function copyToMyObjects(objId) {
|
||||
url: '/ajax/copyObjectFromArchive.php',
|
||||
method: "post",
|
||||
data: {
|
||||
"objId": objId
|
||||
"objId": objId,
|
||||
"is_external": is_external ? 1 : 0
|
||||
},
|
||||
success: function() {
|
||||
if (window.authUser) {
|
||||
// листингу заметку «скопирован из Поиска» добавляет сам copyObjectFromArchive по новому own-id;
|
||||
// objId здесь = реальный el.id, поэтому свою заметку шлём только для своих объектов
|
||||
if (window.authUser && !is_external) {
|
||||
$.ajax({
|
||||
url: '/ajax/addObjectNote.php',
|
||||
method: "post",
|
||||
@ -14265,3 +14442,72 @@ function refreshCalendar(){
|
||||
$('#calendar').fullCalendar('addEventSource', events);
|
||||
}
|
||||
}
|
||||
|
||||
// ===== Переиспользуемая модалка подтверждения действия (замена нативного confirm()) =====
|
||||
// Разметка — #jw_confirm_bg в templates/footer.php (z-index 100000, поверх вложенных модалок).
|
||||
// Использование: jwConfirm({ title, text, btnText, onConfirm, onCancel }).
|
||||
// onConfirm — по кнопке подтверждения; onCancel (опц.) — по крестику/«Отмена»/клику по фону/Esc.
|
||||
// Если разметки нет (страница без общего футера) — деградирует к нативному confirm(), чтобы не сломать действие.
|
||||
(function () {
|
||||
var pending = null; // колбэки текущего открытого диалога
|
||||
|
||||
function hideConfirm() {
|
||||
$('#jw_confirm_bg').hide();
|
||||
$('#jw_confirm').hide();
|
||||
// блокировку прокрутки снимаем, только если под нами не осталось другой открытой модалки
|
||||
if ($('.full_modal-bg:visible, .f__modal-bg:visible').length === 0) {
|
||||
$('body').removeClass('lock');
|
||||
}
|
||||
}
|
||||
|
||||
function resolve(confirmed) {
|
||||
var cb = pending;
|
||||
pending = null;
|
||||
hideConfirm();
|
||||
if (!cb) return;
|
||||
if (confirmed) {
|
||||
if (typeof cb.onConfirm === 'function') cb.onConfirm();
|
||||
} else if (typeof cb.onCancel === 'function') {
|
||||
cb.onCancel();
|
||||
}
|
||||
}
|
||||
|
||||
window.jwConfirm = function (opts) {
|
||||
opts = opts || {};
|
||||
// деградация, если общий футер с разметкой модалки не подключён на странице
|
||||
if (!$('#jw_confirm_bg').length) {
|
||||
if (window.confirm(opts.text || 'Подтвердите действие')) {
|
||||
if (typeof opts.onConfirm === 'function') opts.onConfirm();
|
||||
} else if (typeof opts.onCancel === 'function') {
|
||||
opts.onCancel();
|
||||
}
|
||||
return;
|
||||
}
|
||||
pending = { onConfirm: opts.onConfirm, onCancel: opts.onCancel };
|
||||
$('#jw_confirm_title').text(opts.title || 'Подтверждение действия');
|
||||
$('#jw_confirm_text').html(String(opts.text || '').replace(/\n/g, '<br>'));
|
||||
$('#jw_confirm_ok').text(opts.btnText || 'Подтвердить');
|
||||
$('#jw_confirm_bg').css('display', 'block');
|
||||
$('#jw_confirm').show();
|
||||
$('body').addClass('lock');
|
||||
};
|
||||
|
||||
$(function () {
|
||||
// делегирование на body — разметка статична в футере, но так надёжнее при перерисовках
|
||||
$('body').on('click', '#jw_confirm_ok', function () { resolve(true); });
|
||||
$('body').on('click', '.jw_confirm_cancel, .jw_confirm_closer', function (e) {
|
||||
e.stopPropagation();
|
||||
resolve(false);
|
||||
});
|
||||
// клик по затемнённому фону вне окна = отмена
|
||||
$('body').on('click', '#jw_confirm_bg', function (e) {
|
||||
if (e.target === this) resolve(false);
|
||||
});
|
||||
// Esc = отмена
|
||||
$(document).on('keydown', function (e) {
|
||||
if ((e.key === 'Escape' || e.keyCode === 27) && pending && $('#jw_confirm_bg').is(':visible')) {
|
||||
resolve(false);
|
||||
}
|
||||
});
|
||||
});
|
||||
})();
|
||||
Loading…
Reference in New Issue
Block a user