';
}
if (data.secure) {
stageWork += '
';
}
$("#stagesWork").html(stageWork);
} else {
$("#completeWork").hide();
}
if (!data.has_user_review) {
if ((stagesCompleted.length == stagesResults.length) && stagesCompleted.length > 0) {
$("#leaveReview").show();
} else {
$("#leaveReview").hide();
}
} else {
$("#leaveReview").hide();
}
});
});
// Закрыть этап (complete)
$('#tab2').on('click', '.closeStage', function (e) {
e.preventDefault();
var stageId = $(this).attr('data-stage-id');
var _this = $(this);
$.ajax({
url: '/api/stages/' + stageId + '/',
type: 'PATCH',
beforeSend: function (xhr) {
xhr.setRequestHeader("X-CSRFToken", getCookie('csrftoken'))
},
data: "close_contractor=True",
dataType: 'json',
success: function (json) {
socket.send_stages_approve({
"format_type": "approve_stages",
"data": {
"sender_id": _this.attr('data-sender-id'),
"recipent_id": _this.attr('data-recipent-id'),
"order_id": _this.attr('data-order-id'),
"msg": "Исполнитель завершил этап " + json.name,
}
});
console.log(json);
},
error: function (e) {
console.log('error');
console.log(e);
}
});
});
//Добавить сообщение для исполнителей в группе(copy)
$("#add-team-chat-message").on('click', function (e) {
e.preventDefault();
var chatMessage = $("#team-chat-form #chatText").val();
var recipentId = $("#team-chat-form #recipentTeamId").val();
var senderId = $("#team-chat-form #senderTeamId").val();
var teamId = $("#team-chat-form #teamId").val();
var orderId = $("#team-chat-form #orderTeamId").val();
var documentSendIds = $("#documentSendIds").val();
var teamIds = $("#team-chat-form #teamIds").val();
var sendLinks = $("#document-send a");
if (chatMessage || sendLinks.length > 0) {
var sendLinkIds = "";
var documentLinks = "";
var documentAttachFiles = "";
$.each(sendLinks, function (i, v) {
sendLinkIds += $(this).attr('data-id') + ';';
documentLinks += 'Приложенный файл. скачать:
' + $(this).text() + '';
documentAttachFiles += '
' +
'' + $(this).text() + '' +
'';
});
socket.send_message({
"format_type": "add_message_team",
"data": {
"sender_id": senderId,
"recipent_id": recipentId,
"chat_message": chatMessage,
"team_id": teamId,
"team_ids": teamIds,
"order_id": orderId,
"document_send_links": sendLinkIds,
"document_data": {
"document_links": documentLinks,
"document_attach_files": documentAttachFiles,
}
}
});
$("#team-chat-form #chatText").val("");
$("#document-send").html("");
$("#documentSendIds").val("");
} else {
$("#team-chat-form .errorEmptyMessage").show();
}
});
});