|
|
|
@ -99,12 +99,12 @@ $(function () { |
|
|
|
if (stageCount == 0) { |
|
|
|
if (stageCount == 0) { |
|
|
|
htmlInboxStage += '<div class="numberStepp box-sizing" id="stage1">' + |
|
|
|
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">' + |
|
|
|
'<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>Название</label><input class="form-control" name="name" type="text"><p class="error error-name"></p>' + |
|
|
|
'<label for="">Цена</label><input class="form-control" name="cost" type="text">' + |
|
|
|
'<label>Цена</label><input class="form-control" name="cost" type="text"><p class="error error-cost"></p>' + |
|
|
|
'<input class="form-control orderStagesInput" name="order" type="hidden" value="' + orderId + '">' + |
|
|
|
'<input class="form-control orderStagesInput" name="order" type="hidden" value="' + orderId + '">' + |
|
|
|
'<input class="form-control" type="hidden" name="status" value="send_approve">' + |
|
|
|
'<input class="form-control" type="hidden" name="status" value="send_approve">' + |
|
|
|
'<label for="">Срок</label><input class="term-picker form-control datepicker" name="term" type="text">' + |
|
|
|
'<label>Срок</label><input class="term-picker form-control datepicker" name="term" type="text"><p class="error error-term"></p>' + |
|
|
|
'<label for="">Результат</label><input class="form-control" name="result" type="text">' + |
|
|
|
'<label>Результат</label><input class="form-control" name="result" type="text"><p class="error error-result"></p>' + |
|
|
|
'<input class="form-control" name="pos" value="1" type="hidden">' + |
|
|
|
'<input class="form-control" name="pos" value="1" type="hidden">' + |
|
|
|
'</form></div>'; |
|
|
|
'</form></div>'; |
|
|
|
} |
|
|
|
} |
|
|
|
@ -135,12 +135,13 @@ $(function () { |
|
|
|
if (v.status == "not_agreed" || v.status == 'cancel_approve' || v.status == 'send_approve') { |
|
|
|
if (v.status == "not_agreed" || v.status == 'cancel_approve' || v.status == 'send_approve') { |
|
|
|
htmlInbox += '<div class="numberStepp box-sizing">' + |
|
|
|
htmlInbox += '<div class="numberStepp box-sizing">' + |
|
|
|
'<p>Этап</p><form class="update-stages-form" data-stage-id="' + v.id + '" id="stage-form-' + v.pos + '">' + |
|
|
|
'<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>Название</label><input class="form-control" type="text" name="name" value="' + v.name + '"><p class="error error-name"></p>' + |
|
|
|
'<label for="">Цена</label><input class="form-control" type="text" name="cost" value="' + v.cost + '" >' + |
|
|
|
'<label>Цена</label><input class="form-control" type="text" name="cost" value="' + v.cost + '" ><p class="error error-cost"></p>' + |
|
|
|
|
|
|
|
'<label>Позиция</label><input class="form-control" name="pos" type="text" value="' + v.pos + '" ><p class="error error-pos"></p>' + |
|
|
|
'<input class="form-control orderStagesInput" type="hidden" name="order" value="' + v.order + '">' + |
|
|
|
'<input class="form-control orderStagesInput" type="hidden" name="order" value="' + v.order + '">' + |
|
|
|
'<input class="form-control" type="hidden" name="status" value="send_approve">' + |
|
|
|
'<input class="form-control" type="hidden" name="status" value="send_approve">' + |
|
|
|
'<label for="">Срок</label><input class="term-picker form-control datepicker" type="text" name="term" value="' + v.term + '" />' + |
|
|
|
'<label>Срок</label><input class="term-picker form-control datepicker" type="text" name="term" value="' + v.term + '" ><p class="error error-term"></p>' + |
|
|
|
'<label for="">Результат</label><input class="form-control" type="text" name="result" value="' + v.result + '" >' + |
|
|
|
'<label>Результат</label><input class="form-control" type="text" name="result" value="' + v.result + '" ><p class="error error-result"></p>' + |
|
|
|
'</form></div>'; |
|
|
|
'</form></div>'; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
statusNotAgreed = false; |
|
|
|
statusNotAgreed = false; |
|
|
|
@ -226,12 +227,15 @@ $(function () { |
|
|
|
$("#reserveSpace").hide(); |
|
|
|
$("#reserveSpace").hide(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if ((stagesCompleted.length == stagesResults.length) && (stagesCompleted.length > 0) && (!isReviewLeave)) { |
|
|
|
if (!data.has_user_review) { |
|
|
|
$("#leaveReview").show(); |
|
|
|
if ((stagesCompleted.length == stagesResults.length) && (stagesCompleted.length > 0) && (!isReviewLeave)) { |
|
|
|
|
|
|
|
$("#leaveReview").show(); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
$("#leaveReview").hide(); |
|
|
|
|
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
$("#leaveReview").hide(); |
|
|
|
$("#leaveReview").hide(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$(".stages-paid").html(stagesReservedHtml); |
|
|
|
$(".stages-paid").html(stagesReservedHtml); |
|
|
|
|
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
@ -297,80 +301,75 @@ $(function () { |
|
|
|
|
|
|
|
|
|
|
|
var callbacks = []; |
|
|
|
var callbacks = []; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$(".new-stages-form").each(function (i, v) { |
|
|
|
$(".new-stages-form").each(function (i, v) { |
|
|
|
var _this = $(this); |
|
|
|
var _this = $(this); |
|
|
|
callbacks.push($.ajax({ |
|
|
|
$.ajax({ |
|
|
|
url: '/api/stages/', |
|
|
|
url: '/api/stages/', |
|
|
|
type: 'POST', |
|
|
|
type: 'POST', |
|
|
|
beforeSend: function (xhr) { |
|
|
|
beforeSend: function (xhr) { |
|
|
|
xhr.setRequestHeader("X-CSRFToken", getCookie('csrftoken')) |
|
|
|
xhr.setRequestHeader("X-CSRFToken", getCookie('csrftoken')) |
|
|
|
}, |
|
|
|
}, |
|
|
|
data: $(this).serialize(), |
|
|
|
data: $(this).serialize(), |
|
|
|
dataType: 'json', |
|
|
|
dataType: 'json' |
|
|
|
done: function (json) { |
|
|
|
}) |
|
|
|
|
|
|
|
.done(function (json) { |
|
|
|
_this.removeClass('new-stages-form').addClass('update-stages-form'); |
|
|
|
_this.removeClass('new-stages-form').addClass('update-stages-form'); |
|
|
|
|
|
|
|
_this.find('.error').html(""); |
|
|
|
console.log(json); |
|
|
|
console.log(json); |
|
|
|
}, |
|
|
|
}) |
|
|
|
fail: function (xhr, errorMsg,error) { |
|
|
|
.fail(function (xhr, errorMsg, error) { |
|
|
|
$.each(xhr.responseJSON, function(i,v){ |
|
|
|
console.log(xhr); |
|
|
|
|
|
|
|
$.each(xhr.responseJSON, function (i, v) { |
|
|
|
|
|
|
|
_this.find('.error-' + i).html(v).css('color', 'red'); |
|
|
|
console.log(v); |
|
|
|
console.log(v); |
|
|
|
console.log(i); |
|
|
|
console.log(i); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}, |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
})); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
//$.when(callbacks).then(function(x){
|
|
|
|
|
|
|
|
// console.log(x);
|
|
|
|
|
|
|
|
// $.each(x,function(i,v){
|
|
|
|
|
|
|
|
// console.log(v);
|
|
|
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
// alert("Запросы успешно выполнились");
|
|
|
|
|
|
|
|
//}, function(){
|
|
|
|
|
|
|
|
// alert("Произошла ошибка в запросах");
|
|
|
|
|
|
|
|
//});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$(".update-stages-form").each(function (i, v) { |
|
|
|
$(".update-stages-form").each(function (i, v) { |
|
|
|
|
|
|
|
var _this = $(this); |
|
|
|
var currentStageId = parseInt($(this).attr('data-stage-id')); |
|
|
|
var currentStageId = parseInt($(this).attr('data-stage-id')); |
|
|
|
|
|
|
|
|
|
|
|
$.ajax({ |
|
|
|
$.ajax({ |
|
|
|
url: '/api/stages/' + currentStageId + '/', |
|
|
|
url: '/api/stages/' + currentStageId + '/', |
|
|
|
type: 'PUT', |
|
|
|
type: 'PUT', |
|
|
|
beforeSend: function (xhr) { |
|
|
|
beforeSend: function (xhr) { |
|
|
|
xhr.setRequestHeader("X-CSRFToken", getCookie('csrftoken')) |
|
|
|
xhr.setRequestHeader("X-CSRFToken", getCookie('csrftoken')) |
|
|
|
}, |
|
|
|
}, |
|
|
|
data: $(this).serialize(), |
|
|
|
data: $(this).serialize(), |
|
|
|
dataType: 'json', |
|
|
|
dataType: 'json' |
|
|
|
success: function (json) { |
|
|
|
}) |
|
|
|
console.log(json); |
|
|
|
.done(function (json) { |
|
|
|
}, |
|
|
|
_this.find('.error').html(""); |
|
|
|
error: function (e) { |
|
|
|
}) |
|
|
|
console.log('error'); |
|
|
|
.fail(function (xhr, errorMsg, error) { |
|
|
|
console.log(e); |
|
|
|
$.each(xhr.responseJSON, function (i, v) { |
|
|
|
} |
|
|
|
_this.find('.error-' + i).html(v).css('color', 'red'); |
|
|
|
}); |
|
|
|
console.log(v); |
|
|
|
|
|
|
|
console.log(i); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var currentRecipentId = $(this).attr('data-recipent-id'); |
|
|
|
var currentRecipentId = $(this).attr('data-recipent-id'); |
|
|
|
var secureOrder = true |
|
|
|
var secureOrder = true |
|
|
|
|
|
|
|
|
|
|
|
//socket.send_stages_approve({
|
|
|
|
socket.send_stages_approve({ |
|
|
|
// "format_type": "approve_stages",
|
|
|
|
"format_type": "approve_stages", |
|
|
|
// "data": {
|
|
|
|
"data": { |
|
|
|
// "sender_id": userId,
|
|
|
|
"sender_id": userId, |
|
|
|
// "recipent_id": currentRecipentId,
|
|
|
|
"recipent_id": currentRecipentId, |
|
|
|
// "order_id": currentOrderId,
|
|
|
|
"order_id": currentOrderId, |
|
|
|
// "msg": "Этапы для заказа " + currentOrderId + " изменены",
|
|
|
|
"msg": "Этапы для заказа " + currentOrderId + " изменены", |
|
|
|
// }
|
|
|
|
} |
|
|
|
//});
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
//Изменение счетчика
|
|
|
|
//Изменение счетчика
|
|
|
|
$('#order-stages-tab').on('change', '#countStage', function () { |
|
|
|
$('#order-stages-tab').on('change', '#countStage', function () { |
|
|
|
var countStage = parseInt($(this).val()); |
|
|
|
var countStage = parseInt($(this).val()); |
|
|
|
var currentCountStage = $("#order-stages .numberStepp").length; |
|
|
|
var currentCountStage = $("#order-stages .numberStepp").length; |
|
|
|
@ -385,13 +384,13 @@ $(function () { |
|
|
|
var orderId = lastFormStage.find('.orderStagesInput').val(); |
|
|
|
var orderId = lastFormStage.find('.orderStagesInput').val(); |
|
|
|
var addFormTemplate = '<div class="numberStepp box-sizing" id="stage1">' + |
|
|
|
var addFormTemplate = '<div class="numberStepp box-sizing" id="stage1">' + |
|
|
|
'<p>Этап <span class="stage-span-id">' + pos + '</span></p><form class="new-stages-form" id="stage-form">' + |
|
|
|
'<p>Этап <span class="stage-span-id">' + pos + '</span></p><form class="new-stages-form" id="stage-form">' + |
|
|
|
'<label for="">Название</label><input class="form-control" name="name" type="text">' + |
|
|
|
'<label>Название</label><input class="form-control" name="name" type="text"><p class="error error-name"></p>' + |
|
|
|
'<label for="">Цена</label><input class="form-control" name="cost" type="text">' + |
|
|
|
'<label>Цена</label><input class="form-control" name="cost" type="text"><p class="error error-cost"></p>' + |
|
|
|
'<input class="form-control orderStagesInput" name="order" type="hidden" value="' + orderId + '">' + |
|
|
|
'<input class="form-control orderStagesInput" name="order" type="hidden" value="' + orderId + '">' + |
|
|
|
'<input class="form-control" type="hidden" name="status" value="send_approve">' + |
|
|
|
'<input class="form-control" type="hidden" name="status" value="send_approve">' + |
|
|
|
'<label for="">Срок</label><input class="term-picker form-control datepicker" name="term" type="text">' + |
|
|
|
'<label>Срок</label><input class="term-picker form-control datepicker" name="term" type="text"><p class="error error-term"></p>' + |
|
|
|
'<label for="">Результат</label><input class="form-control" name="result" type="text">' + |
|
|
|
'<label>Результат</label><input class="form-control" name="result" type="text"><p class="error error-result"></p>' + |
|
|
|
'<input class="form-control" name="pos" value="' + pos + '" type="hidden"></form></div>'; |
|
|
|
'<input class="form-control" name="pos" value="' + pos + '" type="text"></form></div>'; |
|
|
|
lastFormStage.after(addFormTemplate); |
|
|
|
lastFormStage.after(addFormTemplate); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -409,7 +408,7 @@ $(function () { |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
// Для заказов все вытащить
|
|
|
|
// Для заказов все вытащить
|
|
|
|
$('.order-block').on('click', function () { |
|
|
|
$('.order-block').on('click', function () { |
|
|
|
$("#chat-order-add").css("display", "block"); |
|
|
|
$("#chat-order-add").css("display", "block"); |
|
|
|
$("#formsetStage").css("display", "block"); |
|
|
|
$("#formsetStage").css("display", "block"); |
|
|
|
@ -465,7 +464,7 @@ $(function () { |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
$.ajax({ |
|
|
|
$.ajax({ |
|
|
|
url: '/api/users/{{ request.user.pk }}/', |
|
|
|
url: '/api/users/' + userId + '/', |
|
|
|
type: 'GET', |
|
|
|
type: 'GET', |
|
|
|
data: { |
|
|
|
data: { |
|
|
|
csrfmiddlewaretoken: csrftoken, |
|
|
|
csrfmiddlewaretoken: csrftoken, |
|
|
|
@ -520,4 +519,5 @@ $(function () { |
|
|
|
getStages(orderId, userId, recipentId, secureOrder); |
|
|
|
getStages(orderId, userId, recipentId, secureOrder); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
}); |
|
|
|
}) |
|
|
|
|
|
|
|
; |
|
|
|
|