|
|
|
|
@ -15,6 +15,8 @@ var SocketHandler = function () { |
|
|
|
|
var message = JSON.parse(event.data); |
|
|
|
|
var inbox; |
|
|
|
|
if (message.answer_type == 'contact' || message.answer_type == 'add_message_contact') { |
|
|
|
|
var docSpace = document.getElementById('documentSpace'); |
|
|
|
|
docSpace.innerHTML += message.docs_attach; |
|
|
|
|
var sumSenderRecipent = parseInt(message.recipent_id) + parseInt(message.sender_id); |
|
|
|
|
var inboxClass = document.getElementsByClassName('contact-space' + sumSenderRecipent); |
|
|
|
|
if (inboxClass.length > 0) { |
|
|
|
|
@ -24,8 +26,12 @@ var SocketHandler = function () { |
|
|
|
|
} |
|
|
|
|
} else if (message.answer_type == 'order' || message.answer_type == 'add_message_order') { |
|
|
|
|
inbox = document.getElementById('message-chat-order-space'); |
|
|
|
|
var docOrderSpace = document.getElementById('documentOrderSpace'); |
|
|
|
|
docOrderSpace.innerHTML += message.docs_attach; |
|
|
|
|
} else if (message.answer_type == 'add_message_team') { |
|
|
|
|
inbox = document.getElementById('message-chat-team-space'); |
|
|
|
|
var docSpace = document.getElementById('documentTeamSpace'); |
|
|
|
|
docSpace.innerHTML += message.docs_attach; |
|
|
|
|
} else if (message.answer_type == 'approve_stages') { |
|
|
|
|
var resOrderId = message.order_id; |
|
|
|
|
$.jGrowl(message.msg, { |
|
|
|
|
@ -73,6 +79,21 @@ var socket = new SocketHandler(); |
|
|
|
|
var csrftoken = getCookie('csrftoken'); |
|
|
|
|
|
|
|
|
|
$(function () { |
|
|
|
|
|
|
|
|
|
function dialog(message, yesCallback, notCallback) { |
|
|
|
|
$("#dialog_delete .modal-title").html(message); |
|
|
|
|
var dialog = $("#dialog_delete").modal('show'); |
|
|
|
|
$("#btnYes").click(function () { |
|
|
|
|
yesCallback(); |
|
|
|
|
$("#dialog_delete").modal('hide'); |
|
|
|
|
}); |
|
|
|
|
$("#btnNot").click(function () { |
|
|
|
|
notCallback(); |
|
|
|
|
$("#dialog_delete").modal('hide'); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var currentHash = URI(location.href).hash(); |
|
|
|
|
if (currentHash.indexOf("#order") == 0) { |
|
|
|
|
var ordHashId = currentHash.replace("#order", ""); |
|
|
|
|
@ -90,7 +111,7 @@ $(function () { |
|
|
|
|
$(".order-block").first().trigger('click'); |
|
|
|
|
}, 500); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Информация о заказе
|
|
|
|
|
$(".full-order-info").click('on', function (e) { |
|
|
|
|
e.preventDefault(); |
|
|
|
|
e.stopPropagation(); |
|
|
|
|
@ -131,23 +152,23 @@ $(function () { |
|
|
|
|
dataType: 'json', |
|
|
|
|
success: function (data) { |
|
|
|
|
var outTable = ''; |
|
|
|
|
if(data.username) { |
|
|
|
|
if (data.username) { |
|
|
|
|
outTable += '<tr><td>Ник</td><td>' + data.username + '</td>'; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if(data.fio) { |
|
|
|
|
if (data.fio) { |
|
|
|
|
outTable += '<tr><td>Ф.И.О</td><td>' + data.fio + '</td>'; |
|
|
|
|
} |
|
|
|
|
if(data.skype) { |
|
|
|
|
outTable += '<tr><td>Skype</td><td>'+ data.skype +'</td>'; |
|
|
|
|
if (data.skype) { |
|
|
|
|
outTable += '<tr><td>Skype</td><td>' + data.skype + '</td>'; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if(data.website) { |
|
|
|
|
outTable += '<tr><td>Сайт</td><td>'+ data.website +'</td>'; |
|
|
|
|
if (data.website) { |
|
|
|
|
outTable += '<tr><td>Сайт</td><td>' + data.website + '</td>'; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if(data.phone) { |
|
|
|
|
outTable += '<tr><td>Телефон</td><td>'+ data.phone +'</td>'; |
|
|
|
|
if (data.phone) { |
|
|
|
|
outTable += '<tr><td>Телефон</td><td>' + data.phone + '</td>'; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$("#contact-info table").html(outTable); |
|
|
|
|
@ -303,33 +324,42 @@ $(function () { |
|
|
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$('.deleteMess').on('click', function (e) { |
|
|
|
|
e.preventDefault(); |
|
|
|
|
e.stopPropagation(); |
|
|
|
|
|
|
|
|
|
var senderId = userId; |
|
|
|
|
var recipentId = $(this).attr('data-recipent-id'); |
|
|
|
|
var _this = $(this); |
|
|
|
|
$.ajax({ |
|
|
|
|
url: '/chat/messages_delete/', |
|
|
|
|
type: 'POST', |
|
|
|
|
beforeSend: function (xhr) { |
|
|
|
|
xhr.setRequestHeader("X-CSRFToken", getCookie('csrftoken')) |
|
|
|
|
}, |
|
|
|
|
data: {'sender_id': senderId, 'recipent_id': recipentId}, |
|
|
|
|
dataType: 'json', |
|
|
|
|
success: function (json) { |
|
|
|
|
if (json.status == 'ok') { |
|
|
|
|
_this.parent().remove(); |
|
|
|
|
$("#message-chat-space").html(""); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
}, |
|
|
|
|
error: function (e) { |
|
|
|
|
console.log('error'); |
|
|
|
|
console.log(e); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
dialog("Вы действительно хотите удалить сообщения этого пользователя?", |
|
|
|
|
function(){ |
|
|
|
|
$.ajax({ |
|
|
|
|
url: '/chat/messages_delete/', |
|
|
|
|
type: 'POST', |
|
|
|
|
beforeSend: function (xhr) { |
|
|
|
|
xhr.setRequestHeader("X-CSRFToken", getCookie('csrftoken')) |
|
|
|
|
}, |
|
|
|
|
data: {'sender_id': senderId, 'recipent_id': recipentId}, |
|
|
|
|
dataType: 'json', |
|
|
|
|
success: function (json) { |
|
|
|
|
|
|
|
|
|
if (json.status == 'ok') { |
|
|
|
|
_this.parent().remove(); |
|
|
|
|
$("#message-chat-space").html(""); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
}, |
|
|
|
|
error: function (e) { |
|
|
|
|
console.log('error'); |
|
|
|
|
console.log(e); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
}.bind(null, senderId, recipentId, _this), |
|
|
|
|
function () { |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
$('#add-note-contractor').on('click', function (e) { |
|
|
|
|
@ -366,7 +396,7 @@ $(function () { |
|
|
|
|
data: $("#add-form-order-note").serialize(), |
|
|
|
|
dataType: 'json', |
|
|
|
|
success: function (json) { |
|
|
|
|
$("<li>"+ json.text +"</li>").appendTo(".order-notes-block"); |
|
|
|
|
$("<li>" + json.text + "</li>").appendTo(".order-notes-block"); |
|
|
|
|
$("#add-form-order-note #chat2").val(""); |
|
|
|
|
}, |
|
|
|
|
error: function (e) { |
|
|
|
|
@ -388,7 +418,7 @@ $(function () { |
|
|
|
|
data: $("#add-form-team-note").serialize(), |
|
|
|
|
dataType: 'json', |
|
|
|
|
success: function (json) { |
|
|
|
|
$("<li>"+ json.text +"</li>").appendTo(".team-notes-block"); |
|
|
|
|
$("<li>" + json.text + "</li>").appendTo(".team-notes-block"); |
|
|
|
|
$("#add-form-team-note #chat2").val(""); |
|
|
|
|
}, |
|
|
|
|
error: function (e) { |
|
|
|
|
@ -409,8 +439,14 @@ $(function () { |
|
|
|
|
if (chatMessage) { |
|
|
|
|
var sendLinks = $("#document-send-order a"); |
|
|
|
|
var sendLinkIds = ""; |
|
|
|
|
var documentLinks = ""; |
|
|
|
|
var documentAttachFiles = ""; |
|
|
|
|
$.each(sendLinks, function (i, v) { |
|
|
|
|
sendLinkIds += $(this).attr('data-id') + ';'; |
|
|
|
|
documentLinks += 'Входящий файл: <br> <a href="'+ $(this).attr('href') + '">'+ $(this).text() +'</a><br>'; |
|
|
|
|
documentAttachFiles += '<li style="word-break: break-all;">' + |
|
|
|
|
'<a class="file-link" href="' + $(this).attr('href') + '">' + $(this).text() + '</a>' + |
|
|
|
|
'<div class="remove-document" data-id="' + $(this).attr('data-id') + '" style="right:-10px;"></div></li>'; |
|
|
|
|
}); |
|
|
|
|
socket.send_message({ |
|
|
|
|
"format_type": "add_message_order", |
|
|
|
|
@ -420,6 +456,10 @@ $(function () { |
|
|
|
|
"chat_message": chatMessage, |
|
|
|
|
"order_id": orderId, |
|
|
|
|
"document_send_links": sendLinkIds, |
|
|
|
|
"document_data": { |
|
|
|
|
"document_links": documentLinks, |
|
|
|
|
"document_attach_files": documentAttachFiles, |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
}); |
|
|
|
|
@ -441,8 +481,15 @@ $(function () { |
|
|
|
|
$("#contact-chat-form .errorEmptyMessage").hide(); |
|
|
|
|
var sendLinks = $("#document-send-contact a"); |
|
|
|
|
var sendLinkIds = ""; |
|
|
|
|
var documentLinks = ""; |
|
|
|
|
var documentAttachFiles = ""; |
|
|
|
|
|
|
|
|
|
$.each(sendLinks, function (i, v) { |
|
|
|
|
sendLinkIds += $(this).attr('data-id') + ';'; |
|
|
|
|
documentLinks += 'Входящий файл: <br> <a href="'+ $(this).attr('href') + '">'+ $(this).text() +'</a><br>'; |
|
|
|
|
documentAttachFiles += '<li style="word-break: break-all;">' + |
|
|
|
|
'<a class="file-link" href="' + $(this).attr('href') + '">' + $(this).text() + '</a>' + |
|
|
|
|
'<div class="remove-document" data-id="' + $(this).attr('data-id') + '" style="right:-10px;"></div></li>'; |
|
|
|
|
}); |
|
|
|
|
console.log(sendLinkIds); |
|
|
|
|
socket.send_message({ |
|
|
|
|
@ -452,6 +499,10 @@ $(function () { |
|
|
|
|
"recipent_id": recipentId, |
|
|
|
|
"chat_message": chatMessage, |
|
|
|
|
"document_send_links": sendLinkIds, |
|
|
|
|
"document_data": { |
|
|
|
|
"document_links": documentLinks, |
|
|
|
|
"document_attach_files": documentAttachFiles, |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
$("#chat").val(""); |
|
|
|
|
@ -541,10 +592,7 @@ $(function () { |
|
|
|
|
dataType: 'json', |
|
|
|
|
done: function (e, data) { |
|
|
|
|
$.each(data.result.files, function (index, file) { |
|
|
|
|
// var currentValue = '';
|
|
|
|
|
// currentValue += file.id + ';';
|
|
|
|
|
//$("#documentSendIds").val(currentValue);
|
|
|
|
|
var htmlImg = '<a href="' + file.url + '" class="send-doc" data-id="' + file.id + '">' + file.name + '</a><br />'; |
|
|
|
|
var htmlImg = '<a href="/chat/download/' + file.name + '" class="send-doc" data-id="' + file.id + '">' + file.name + '</a><br />'; |
|
|
|
|
var document_send = $(htmlImg).appendTo("#document-send-order"); |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
@ -587,7 +635,7 @@ $(function () { |
|
|
|
|
dataType: 'json', |
|
|
|
|
done: function (e, data) { |
|
|
|
|
$.each(data.result.files, function (index, file) { |
|
|
|
|
var htmlImg = '<a href="' + file.url + '" class="send-doc" data-id="' + file.id + '">' + file.name + '</a>'; |
|
|
|
|
var htmlImg = '<a href="/chat/download/' + file.name + '" class="send-doc" data-id="' + file.id + '">' + file.name + '</a>'; |
|
|
|
|
var document_send = $(htmlImg).appendTo("#document-send-contact"); |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
|