@ -24,7 +24,7 @@
< / div >
< / div >
< div class = "tab-content" >
<!-- Tab1 (contacts block) -->
<!-- Tab1 (contacts block) -->
< div class = "chatBlock disTab tab-pane fade in active" id = "tab1" >
< div class = "col-lg-3 wrMessages" >
< div class = "messageBlock box-sizing disTab" >
@ -32,14 +32,21 @@
{% for contact in contacts_users %}
< div class = "message messd user-block" data-id = "{{ contact.pk }}" >
< div class = "imgMess" >
{% thumbnail contact.avatar "60x60" crop="center" as im %}
< img src = "{{ im.url }}" alt = "mess-image" >
{% endthumbnail %}
{% if contact.avatar %}
{% thumbnail contact.avatar "60x60" crop="center" as im %}
< img src = "{{ im.url }}" alt = "mess-image" >
{% endthumbnail %}
{% else %}
< img src = "{% static 'img/profile.jpg' %}" alt = "mess-image" >
{% endif %}
< / div >
< p class = "nameMess" >
< a href = "#" > {{ contact.username }} {{ contact.username }}< / a >
< div > < a href = "#" > {{ contact.username }}< / a > < / div >
< / p >
< a href = "javascript:void(0)" class = "conMess" > Контакты< / a >
< a href = "#" data-target = "#userModal" data-toggle = "modal"
class="conMess">Контакты< / a >
< span > 0< / span >
< a href = "javascript:void(0)" class = "deleteMess" >
Удалить контакт
@ -49,6 +56,20 @@
< / div >
< / div >
< div class = "modal fade" id = "userModal" tabindex = "-1" role = "dialog" >
< div class = "modal-dialog" >
< div class = "modal-content" >
< div class = "modal-header" >
< button class = "close" type = "button" data-dismiss = "modal" > x< / button >
< h4 class = "modal-title" id = "myModalLabel" > Название модального
окна< / h4 >
< / div >
< div class = "modal-body" >
< h3 > Содержимое модального окна< / h3 >
< / div >
< / div >
< / div >
< / div >
< div class = "col-lg-6 commChat" id = "contact-chat" >
< div id = "message-chat-space" >
< / div >
@ -60,9 +81,9 @@
< div class = "bunChat" >
< div class = "setChat box-sizing" >
< p > Прикрепить файл< / p >
< span >
Не более 10 файлов с общим объемом 500мб
< / span >
< span >
Не более 10 файлов с общим объемом 500мб
< / span >
< / div >
< a id = "contact-chat-add-message" href = "javascript:void(0)" > отправить< / a >
@ -79,9 +100,9 @@
< / div >
< / div >
< / div >
<!-- End block Tab1(contacts block) -->
<!-- End block Tab1(contacts block) -->
<!-- Tab2 (chat order block) -->
<!-- Tab2 (chat order block) -->
< div class = "chatBlock disTab tab-pane fade" id = "tab2" >
< div class = "col-lg-3 wrMessages" >
< div class = "messageBlock box-sizing disTab" >
@ -117,9 +138,9 @@
< div class = "bunChat" >
< div class = "setChat box-sizing" >
< p > Прикрепить файл< / p >
< span >
Не более 10 файлов с общим объемом 500мб
< / span >
< span >
Не более 10 файлов с общим объемом 500мб
< / span >
< / div >
< a href = "javascript:void(0)" id = "order-chat-add-message" > отправить< / a >
< / div >
@ -136,79 +157,51 @@
< / p >
< / div >
{# < div class = "stepssBlock box-sizing disTab" > #}
{# < p class = "textStepss" > #}
{# Какое кол-во этапов подразумевает работа? < input type = "text" id = "countStage" size = "3" / > #}
{# < / p > #}
{# < div id = "formsetStage" class = "numberStepp box-sizing" style = "display: none;" > #}
{# < div class = "insetNumStepp" id = "stage1" > #}
{# < p class = "titleNumStepp" > #}
{# < span > Этап < / span > #}
{# < / p > #}
{# < div class = "textAreaBlock2 box-sizing disTab" > #}
{# < form class = "new-stages-form" > #}
{# < label > Название< / label > #}
{# < input type = "text" name = "name" / > #}
{# < label > Результат< / label > #}
{# < input type = "text" name = "result" / > #}
{# < label > Стоимость< / label > #}
{# < input type = "text" name = "cost" / > #}
{# < input type = "hidden" name = "order" class = "orderStagesInput" / > #}
{# < / form > #}
{# < / div > #}
{# < / div > #}
{##}
{# < / div > #}
{##}
{# < / div > #}
{# < div class = "textAreaBlock2 FFD box-sizing disTab" > #}
{# < a href = "javascript:void()" > согласовать< / a > #}
{# < / div > #}
< div id = "order-stages" > < / div >
< div id = "order-stages" class = "stepssBlock" > < / div >
< div class = "stepssBlock box-sizing disTab" >
< p class = "titleStepss" > 2 / Резервирование< / p >
< p class = "textStepss" >
Резервирование заказчиком суммы оплаты по заказ. Деньги перечисляются и хранятся на сайте.
< / p >
< p class = "titleStepss" > 2 / Резервирование< / p >
< p class = "textStepss" >
Резервирование заказчиком суммы оплаты по заказ. Деньги перечисляются и хранятся на
сайте.
< / p >
< div class = "textAreaBlock2 FFD box-sizing disTab" >
< a href = "#" data-toggle = "modal" data-target = "#reserve-stage-modal" > Зарезирвировать< / a >
< / div >
< a href = "#" data-toggle = "modal" data-target = "#reserve-stage-modal" > Зарезирвировать< / a >
< / div >
< / div >
< / div >
<!-- Зарезервировать средства (модальное окно) -->
< div id = "reserve-stage-modal" class = "modal fade" >
< div class = "modal-dialog" style = "width:900px;" >
< div class = "modal-content" >
< div class = "modal-header" >
< button type = "button" class = "close" data-dismiss = "modal" aria-hidden = "true" > ×< / button >
< h4 class = "modal-title" > Зарезервировать средства< / h4 >
< / div >
< div id = "reserve-stage-modal" class = "modal fade" >
< div class = "modal-dialog" style = "width:900px;" >
< div class = "modal-content" >
< div class = "modal-header" >
< button type = "button" class = "close" data-dismiss = "modal" aria-hidden = "true" > ×
< / button >
< h4 class = "modal-title" > Зарезервировать средства< / h4 >
< / div >
< div class = "modal-body" >
< div class = "textAreaBlock2 text-nn box-sizing disTab" >
< / div >
< div class = "modal-body" >
< div class = "textAreaBlock2 text-nn box-sizing disTab" >
< / div >
< div class = "searchF1 polsF1 polsFF links-filter" >
< input class = "btn-submit-link" type = "submit" value = "Сохранить" >
< / div >
< / div >
< div class = "modal-footer" > < / div >
< div class = "searchF1 polsF1 polsFF links-filter" >
< input class = "btn-submit-link" type = "submit" value = "Сохранить" >
< / div >
< / div >
< div class = "modal-footer" > < / div >
< / div >
<!-- Конец блока -->
< / div >
< / div >
<!-- Конец блока -->
< div class = "stepssBlock box-sizing disTab" >
< p class = "titleStepss" > 3 / Выполнение работы< / p >
< p class = "textStepss" >
Процесс выполнения задания в заказе до получения заказчиком итогового результата работы.
< / p >
< / div >
< div class = "stepssBlock box-sizing disTab" >
< p class = "titleStepss" > 3 / Выполнение работы< / p >
< p class = "textStepss" >
Процесс выполнения задания в заказе до получения заказчиком итогового результата работы.
< / p >
< / div >
< div class = "textAreaBlock2 box-sizing disTab" >
@ -216,13 +209,75 @@
< textarea id = "chat2" > < / textarea >
< a href = "javascript:void()" > сохранить< / a >
< / div >
< div class = "linkChatB box-sizing disTab" >
< a href = "javascript:void(0)" > предложить проект< / a >
< div class = "closeChat closeChat1" >
< a href = "#" data-toggle = "modal" data-target = "#review-add" >
Закрыть проект< br > и оставить отзыв
< / a >
< / div >
<!-- Review add -->
< div id = "review-add" class = "modal fade" role = "dialog" >
< div class = "modal-dialog" role = "document" style = "width:900px;" >
< div class = "modal-content" >
< div class = "modal-header" >
< button type = "button" class = "close" data-dismiss = "modal" aria-hidden = "true" > ×
< / button >
< h4 class = "modal-title" > Оставить отзыв< / h4 >
< / div >
< form id = "review-adds-form" method = "POST" > {% csrf_token %}
< div class = "modal-body" >
< div style = "height: 250px;" >
< div class = "text-nn box-sizing disTab" >
< input type = "radio" value = "positive"
name="type">Положительный
< input type = "radio" value = "negative"
name="type">Отрицательный
< input type = "radio" value = "neutral"
name="type">Нейтральный
< / div >
< div class = "textAreaBlock2 text-nn box-sizing disTab" >
< textarea cols = "40" name = "text" rows = "10" > < / textarea >
< input type = "hidden" name = "from_customer"
value="{{ request.user.pk }}"/>
< input type = "hidden" name = "target_contractor"
id="targetContractorId"/>
< input type = "hidden" name = "project" id = "projectReviewId" / >
< / div >
< / div >
< / div >
< div class = "modal-footer" >
< button type = "button" class = "btn btn-default" data-dismiss = "modal" > Закрыть
< / button >
< button type = "submit" id = "order-review-add" class = "btn btn-primary" > Оставить
отзыв
< / button >
< / div >
< / form >
< / div >
< / div >
< / div >
<!-- -->
< / div >
< / div >
<!-- End block (chat order block) -->
<!-- End block (chat order block) -->
< / div >
{% include 'partials/footer.html' %}
< / div >
< / div >
@ -238,38 +293,133 @@
var form = document.getElementById('message_form');
var csrftoken = getCookie('csrftoken');
function getStages(orderId) {
$.ajax({
url: '/api/stages/',
type: 'GET',
data: {csrfmiddlewaretoken: csrftoken, 'order': orderId},
dataType: 'json',
success: function (json) {
var stageCount = json.results.length;
if (stageCount == 0) {
stageCountVal = 1;
} else {
stageCountVal = stageCount;
}
var htmlInbox = "";
var htmlInboxStage = '< p class = "textStepss" > Какое кол-во этапов подразумевает работа? ' +
'< input type = "text" id = "countStage" value = "' + stageCountVal + '" size = "3" / > < / p > ';
if (stageCount == 0) {
htmlInboxStage += '< div class = "box-sizing" id = "stage1" > ' +
'< p > Этап < span class = "stage-span-id" > 1< / span > < / p > < form class = "new-stages-form" id = "stage-form" > ' +
'< label for = "" > Название< / label > < input class = "form-control" name = "name" type = "text" / > ' +
'< label for = "" > Цена< / label > < input class = "form-control" name = "cost" type = "text" / > ' +
// '< input class = "form-control" name = "order" type = "text" value = "' + orderId + '" class = "orderStagesInput" / > />' +
'< label for = "" > Срок< / label > < input class = "form-control" name = "term" type = "text" / > ' +
'< label for = "" > Результат< / label > < input class = "form-control" name = "result" type = "text" / > ' +
'< / form > < / div > ';
}
var statusNotAgreed = true;
$.each(json.results, function (i, v) {
if (v.status == "not_agreed") {
htmlInbox += '< div class = "box-sizing" > ' +
'< p > Этап< / p > < form class = "update-stages-form" data-stage-id = "' + v.id + '" id = "stage-form-' + v.pos + '" > ' +
'< label for = "" > Название< / label > < input class = "form-control" type = "text" name = "name" value = "' + v.name + '" / > ' +
'< label for = "" > Цена< / label > < input class = "form-control" type = "text" name = "cost" value = "' + v.cost + '" / > ' +
'< input class = "form-control" type = "hidden" name = "order" value = "' + v.order + '" / > ' +
'< label for = "" > Срок< / label > < input class = "form-control" type = "text" name = "term" value = "' + v.term + '" / > ' +
'< label for = "" > Результат< / label > < input class = "form-control" type = "text" name = "result" value = "' + v.result + '" / > ' +
'< / form > < / div > ';
} else {
statusNotAgreed = false;
htmlInboxStage = "";
htmlInbox += '< div class = "box-sizing" > < div class = "insetNumStepp" > ' +
'< p class = "titleNumStepp" > < span > Этап ' + v.pos + '< / span > ' + v.name + '< / p > ' +
'< p class = "textNumStepp" > Результаты этапа:' + v.result + '< / p > < div > ' +
'< p > до 16.03.2015< / p > < span > ' + v.cost + '< i class = "fa fa-rub" > < / i > < / span > < / div > < / div > < / div > ';
}
});
if (statusNotAgreed) {
htmlInbox += '< div class = "box-sizing disTab" style = "text-align:center;" > < div class = "checkbox" > < label > < input type = "checkbox" style = "opacity:1" > < span > < / span > < / label > Перейти в режим безопасной сделки' +
'< / div > < / div > < div class = "textAreaBlock2 box-sizing disTab" > ' +
'< a href = "#" data-order-id = "' + orderId + '" id = "addStagesForm" > отправить на согласование< / a > < / div > ';
}
htmlInbox = htmlInboxStage + htmlInbox;
$("#order-stages").html(htmlInbox);
}
});
}
setTimeout(function () {
$(".user-block").first().trigger('click');
}, 10);
setTimeout(function () {
$(".order-block").first().trigger('click');
}, 100);
$("#order-stages").on('click', "#addStagesForm", function(){
$(".new-stages-form").each(function(i,v){
console.log($(this).serialize());
alert($(this).serialize());
$("#order-stages").on('click', "#addStagesForm", function (e ) {
e.preventDefault();
$(".new-stages-form").each(function (i, v) {
console.log ($(this).serialize());
$.ajax({
$.ajax({
url: '/api/stages/',
type: 'POST',
beforeSend: function (xhr) {
xhr.setRequestHeader("X-CSRFToken", getCookie('csrftoken'))
},
data:$(this).serialize(),
data: $(this).serialize(),
dataType: 'json',
success: function (json) {
console.log(json);
},
error: function (e) {
console.log('error');
console.log(e);
}
});
});
$(".update-stages-form").each(function (i, v) {
var currentStageId = parseInt($(this).attr('data-stage-id'));
$.ajax({
url: '/api/stages/' + currentStageId + '/',
type: 'PUT',
beforeSend: function (xhr) {
xhr.setRequestHeader("X-CSRFToken", getCookie('csrftoken'))
},
data: $(this).serialize(),
dataType: 'json',
success: function (json) {
console.log(json);
},
error: function(e){
error: function (e) {
console.log('error');
console.log(e);
}
});
});
var currentOrderId = $(this).attr('data-order-id');
currentOrderId = parseInt(currentOrderId);
getStages(currentOrderId);
});
});
$('#order-stages-tab').on('change', '#countStage', function(){
$('#order-stages-tab').on('change', '#countStage', function () {
var countStage = parseInt($(this).val());
var updateFormStages = $(".update-stages-form");
alert(updateFormStages.length);
alert(typeof updateFormStages.length);
var limitCount = countStage + 1;
for (var i = 2; i < limitCount ; i + + ) {
var stageCopy = $("#stage1").clone().attr("id", "stage" + i).addClass("stages_form");
@ -277,10 +427,9 @@
}
});
$('.order-block').on('click', function () {
$("#chat-order-add").css("display", "block");
$("#formsetStage").css("display","block");
$("#formsetStage").css("display", "block");
$('.order-block').each(function () {
$(this).removeClass('orAct');
@ -290,6 +439,8 @@
var orderId = $(this).attr('data-id');
var recipentId = $(this).attr('data-recipent-id');
$("#chat-order-add #orderId").val(orderId);
$("#projectReviewId").val(orderId);
$("#targetContractorId").val(recipentId);
$("#chat-order-add #recipentId").val(recipentId);
$(".orderStagesInput").val(orderId);
var inbox = document.getElementById('message-chat-order-space');
@ -315,71 +466,9 @@
});
}
});
$.ajax({
url: '/api/stages/',
type: 'GET',
data: {csrfmiddlewaretoken: csrftoken, 'order': orderId},
dataType: 'json',
success: function (json) {
var stageCount = json.results.length;
if (stageCount == 0){
stageCountVal = 1;
}else{
stageCountVal = stageCount;
}
var htmlInbox = "";
var htmlInboxStage = '< p class = "textStepss" > Какое кол-во этапов подразумевает работа? ' +
'< input type = "text" id = "countStage" value = "'+ stageCountVal +'" size = "3" / > < / p > ';
if (stageCount == 0){
htmlInboxStage += '< div class = "numberStepp box-sizing" id = "stage1" > ' +
'< p > Этап < span class = "stage-span-id" > 1< / span > < / p > < form class = "new-stages-form" id = "stage-form" > ' +
'< label for = "" > Название< / label > < input class = "form-control" name = "name" type = "text" / > ' +
'< label for = "" > Цена< / label > < input class = "form-control" name = "cost" type = "text" / > ' +
'< input class = "form-control" name = "order" type = "text" value = "'+ orderId +'" class = "orderStagesInput" / > />' +
'< label for = "" > Срок< / label > < input class = "form-control" name = "term" type = "text" / > ' +
'< label for = "" > Результат< / label > < input class = "form-control" name = "result" type = "text" / > ' +
'< / form > < / div > ';
}
var statusNotAgreed = true;
$.each(json.results, function (i, v) {
if (v.status == "not_agreed") {
htmlInbox += '< div class = "numberStepp box-sizing" > ' +
'< p > Этап< / p > < form class = "update-stages-form" id = "stage-form-'+ v.pos +'" > ' +
'< label for = "" > Название< / label > < input class = "form-control" type = "text" value = "'+ v.name +'" / > ' +
'< label for = "" > Цена< / label > < input class = "form-control" type = "text" value = "'+ v.cost +'" / > ' +
'< input class = "form-control" type = "hidden" value = "'+ v.order +'" / > ' +
'< label for = "" > Срок< / label > < input class = "form-control" type = "text" value = "'+ v.term +'" / > ' +
'< label for = "" > Результат< / label > < input class = "form-control" type = "text" value = "'+ v.result +'" / > ' +
'< / form > < / div > ';
} else {
statusNotAgreed = false;
htmlInboxStage = "";
htmlInbox += '< div class = "numberStepp box-sizing" > < div class = "insetNumStepp" > ' +
'< p class = "titleNumStepp" > < span > Этап ' + v.pos + '< / span > ' + v.name + '< / p > ' +
'< p class = "textNumStepp" > Результаты этапа:' + v.result + '< / p > < div > ' +
'< p > до 16.03.2015< / p > < span > ' + v.cost + '< i class = "fa fa-rub" > < / i > < / span > < / div > < / div > < / div > ';
}
});
if (statusNotAgreed) {
htmlInbox += '< div class = "box-sizing disTab" style = "text-align:center;" > < div class = "checkbox" > < input type = "checkbox" style = "opacity:1" > Перейти в режим безопасной сделки' +
'< / div > < / div > < div class = "textAreaBlock2 box-sizing disTab" > ' +
'< a href = "javascript:void()" id = "addStagesForm" > отправить на согласование< / a > < / div > ';
}
htmlInbox = htmlInboxStage + htmlInbox;
$("#order-stages").html(htmlInbox);
}
});
getStages(orderId);
});
// Вытащить сообщения для конактов
$('.user-block').on('click', function () {
var userId = $(this).attr('data-id');
@ -430,6 +519,10 @@
$("#chat").val("");
});
$('#order-review-add').on('click', function () {
alert('add review');
});
$('#order-chat-add-message').on('click', function () {
var chatMessage = $("#chat-order-add #chat").val();
var recipentId = $("#chat-order-add #recipentId").val();
@ -452,10 +545,13 @@
});
var userId = '{{ request.user.pk }}';
var userId = '{{ request.user.pk }}';
var SocketHandler = function () {
var url = 'ws://127.0.0.1:8888/chat/' + userId + '/';
var domain = '{{ request.META.HTTP_HOST }}';
var port = '{{ request.META.SERVER_PORT }}';
domain = domain.replace(':' + port, '');
var url = 'ws://' + domain + ':8888/chat/' + userId + '/';
var sock = new WebSocket(url);
var intervalId;
sock.onopen = function () {