@ -127,7 +127,7 @@
< / div >
< div class = "col-lg-3 wrstepschat" >
< div class = "col-lg-3 wrstepschat" id = "order-stages-tab" >
< p > Этапы работы< / p >
< div class = "stepssBlock box-sizing disTab" >
< p class = "titleStepss" > 1 / Согласование условий< / p >
@ -136,37 +136,35 @@
< / 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 class = "textAreaBlock2 box-sizing disTab" >
< a href = "javascript:void()" id = "addStagesForm" > отправить на согласование< / a >
< / div >
< / div >
< / div >
< div class = "textAreaBlock2 FFD box-sizing disTab" >
< a href = "javascript:void()" > согласовать< / a >
< / 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 >
@ -241,8 +239,11 @@
var csrftoken = getCookie('csrftoken');
$("#addStagesForm").on('click',function(){
$(".new-stages-form").each(function(i,v){
$("#order-stages").on('click', "#addStagesForm", function(){
$(".new-stages-form").each(function(i,v){
console.log($(this).serialize());
alert($(this).serialize());
$.ajax({
url: '/api/stages/',
type: 'POST',
@ -255,6 +256,7 @@
console.log(json);
},
error: function(e){
console.log('error');
console.log(e);
}
});
@ -262,19 +264,20 @@
});
});
$('#countStage').on('change', function (e) {
$(".stages_form").each(function () {
$(this).remove();
});
$('#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");
$("#stage1").after(stageCopy);
}
});
$('.order-block').on('click', function () {
$("#chat-order-add").css("display", "block");
$("#formsetStage").css("display","block");
@ -319,8 +322,29 @@
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 = "";
console.log(json.results.length);
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" > ' +
@ -332,6 +356,8 @@
'< 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 > ' +
@ -339,6 +365,13 @@
}
});
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);
}
});
@ -483,7 +516,6 @@
textareaMessage.value = "";
}
}
< / script >