parent
bf0157d738
commit
ffac41da05
21 changed files with 869 additions and 16 deletions
@ -0,0 +1,16 @@ |
|||||||
|
# -*- coding: utf-8 -*- |
||||||
|
# Generated by Django 1.9.7 on 2016-09-02 07:45 |
||||||
|
from __future__ import unicode_literals |
||||||
|
|
||||||
|
from django.db import migrations |
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration): |
||||||
|
|
||||||
|
dependencies = [ |
||||||
|
('projects', '0024_auto_20160901_1247'), |
||||||
|
('projects', '0024_auto_20160901_1548'), |
||||||
|
] |
||||||
|
|
||||||
|
operations = [ |
||||||
|
] |
||||||
@ -0,0 +1,632 @@ |
|||||||
|
{% extends 'partials/base.html' %} |
||||||
|
|
||||||
|
{% load project_tags %} |
||||||
|
{% load specializtions_tags %} |
||||||
|
{% load thumbnail %} |
||||||
|
|
||||||
|
|
||||||
|
{% block content %} |
||||||
|
{% include 'partials/header.html' %} |
||||||
|
|
||||||
|
<div class="container mainScore"> |
||||||
|
<div class="row"> |
||||||
|
<div class="col-lg-12"> |
||||||
|
<p class="titleScore">Личный кабинет</p> |
||||||
|
</div> |
||||||
|
|
||||||
|
{% include 'partials/contractor_profile_tabs.html' %} |
||||||
|
|
||||||
|
|
||||||
|
<div class="projectsBlock disTab"> |
||||||
|
|
||||||
|
|
||||||
|
<!-- Tab2 (chat order block)--> |
||||||
|
<div class="chatBlock disTab tab-pane"> |
||||||
|
<div class="col-lg-3 wrMessages"> |
||||||
|
<div class="messageBlock box-sizing disTab"> |
||||||
|
<p>Заказы</p> |
||||||
|
{% for order in orders %} |
||||||
|
<div class="orderBlock box-sizing order-block" data-project-id="{{ order.id }}" |
||||||
|
id="orderBlock{{ order.order.id }}" |
||||||
|
data-secure-deal="{% if order.order.secure %}true{% else %}false{% endif %}" |
||||||
|
{% if order.order.contractor %} |
||||||
|
data-recipent-id="{{ order.order.contractor.pk }}" |
||||||
|
{% else %} |
||||||
|
data-recipent-id="{{ order.order.team.owner.pk }}" |
||||||
|
{% endif %} data-id="{{ order.order.id }}"> |
||||||
|
<span class="dimovChat"></span> |
||||||
|
<p class="titleOB">{{ order }}</p> |
||||||
|
<div class="hideOBB"> |
||||||
|
<p class="pOB"> |
||||||
|
<span>Исполнитель:</span> |
||||||
|
{% if order.order.contractor %} |
||||||
|
{{ order.order.contractor.get_full_name }} |
||||||
|
{% else %} |
||||||
|
{{ order.order.team.name }} |
||||||
|
{% endif %} |
||||||
|
</p> |
||||||
|
<a href="#" class="linkChat11 full-order-info"> |
||||||
|
<span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span> |
||||||
|
Полное описание заказа |
||||||
|
</a> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
{% endfor %} |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
<div class="col-lg-6 commChat"> |
||||||
|
<div id="message-chat-order-space"></div> |
||||||
|
<form id="chat-order-add"> |
||||||
|
<input type="hidden" name="senderId" id="senderId" value="{{ request.user.pk }}"/> |
||||||
|
<input type="hidden" name="recipentId" id="recipentId"> |
||||||
|
<input type="hidden" name="orderId" id="orderId"> |
||||||
|
<textarea id="chat" class="box-sizing"></textarea> |
||||||
|
<p class="errorEmptyMessage" style="color: red;display:none;">Пустое сообщение нельзя |
||||||
|
отправить</p> |
||||||
|
<div class="bunChat"> |
||||||
|
<div class="setChat box-sizing upload"> |
||||||
|
<input type="file" name="file" id="upload-document-order"> |
||||||
|
<p>Прикрепить файл</p> |
||||||
|
</div> |
||||||
|
<div id="document-send-order"></div> |
||||||
|
<a href="#" id="order-chat-add-message">отправить</a> |
||||||
|
</div> |
||||||
|
</form> |
||||||
|
</div> |
||||||
|
<div class="col-lg-3 wrstepschat" id="order-stages-tab"> |
||||||
|
<p>Этапы работы</p> |
||||||
|
<div class="stepssBlock box-sizing disTab"> |
||||||
|
<p class="titleStepss">1 / Согласование условий</p> |
||||||
|
<p class="textStepss"> |
||||||
|
Обсуджение задания и условий выполнения работы. Подтверждение заказа исполнителем. |
||||||
|
</p> |
||||||
|
</div> |
||||||
|
|
||||||
|
<div id="order-stages" class="stepssBlock"></div> |
||||||
|
|
||||||
|
<div class="stepssBlock box-sizing disTab" id="reserveSpace" style="display:none;"> |
||||||
|
<p class="titleStepss">2 / Резервирование</p> |
||||||
|
<p class="textStepss"> |
||||||
|
Резервирование заказчиком суммы оплаты по заказ. |
||||||
|
Деньги перечисляются и хранятся насайте. |
||||||
|
</p> |
||||||
|
<ul class="stages-paid"></ul> |
||||||
|
|
||||||
|
<div class="textAreaBlock2 FFD box-sizing disTab"> |
||||||
|
<a href="#" id="reserve-button" data-order-id="">Зарезервировать</a> |
||||||
|
</div> |
||||||
|
|
||||||
|
</div> |
||||||
|
|
||||||
|
<!-- Зарезервировать средства (модальное окно)--> |
||||||
|
{% include 'reverse_stage_modal.html' %} |
||||||
|
<!-- Конец блока --> |
||||||
|
|
||||||
|
<div class="stepssBlock box-sizing disTab" id="completeWork"> |
||||||
|
<p class="titleStepss">3 / Выполнение работы</p> |
||||||
|
<p class="textStepss"> |
||||||
|
Процесс выполнения задания в заказе до получения |
||||||
|
заказчиком итогового результата работы. |
||||||
|
</p> |
||||||
|
<div id="stagesWork" class="stages-work"></div> |
||||||
|
</div> |
||||||
|
|
||||||
|
<div class="closeChat closeChat1" id="leaveReview" style="display: none;"> |
||||||
|
<a href="#" data-toggle="modal" data-target="#review-add"> |
||||||
|
Закрыть проект<br>и оставить отзыв |
||||||
|
</a> |
||||||
|
</div> |
||||||
|
|
||||||
|
<div class="col-lg-12 documentsChat"> |
||||||
|
<p>Входящие документы</p> |
||||||
|
<ul id="documentOrderSpace"></ul> |
||||||
|
{# <a href="javascript:void(0)">#} |
||||||
|
{# Распечатать с помощью ресурса#} |
||||||
|
{# </a>#} |
||||||
|
</div> |
||||||
|
|
||||||
|
<div class="textAreaBlock2 box-sizing disTab"> |
||||||
|
<p>Для заметок</p> |
||||||
|
<textarea id="chat2"></textarea> |
||||||
|
<a href="#">сохранить</a> |
||||||
|
</div> |
||||||
|
|
||||||
|
<!-- Review add --> |
||||||
|
{% include 'review_add_modal.html' %} |
||||||
|
<!-- --> |
||||||
|
|
||||||
|
<!-- Arbitration add --> |
||||||
|
{% include 'arbitration_modal.html' %} |
||||||
|
<!-- --> |
||||||
|
|
||||||
|
<!-- order-info --> |
||||||
|
{% include 'order_info.html' %} |
||||||
|
<!-- --> |
||||||
|
|
||||||
|
|
||||||
|
</div> |
||||||
|
</div> |
||||||
|
<!-- End block (chat order block) --> |
||||||
|
|
||||||
|
</div> |
||||||
|
|
||||||
|
{% include 'partials/footer.html' %} |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
{% endblock %} |
||||||
|
|
||||||
|
|
||||||
|
{% block js_block %} |
||||||
|
<script type="text/javascript"> |
||||||
|
var userId = {{ request.user.pk }}; |
||||||
|
var domain = '{{ request.META.HTTP_HOST }}'; |
||||||
|
var port = '{{ request.META.SERVER_PORT }}'; |
||||||
|
|
||||||
|
</script> |
||||||
|
<script type="text/javascript" src='{% static "js/chat.js" %}'></script> |
||||||
|
<script type="text/javascript"> |
||||||
|
$(function () { |
||||||
|
var currentChatUser = {{ request.user.pk }}; |
||||||
|
var form = document.getElementById('message_form'); |
||||||
|
|
||||||
|
$('body').on('focus',".term-picker", function(){ |
||||||
|
$(this).datepicker({ |
||||||
|
{# minDate: 0,#} |
||||||
|
|
||||||
|
}); |
||||||
|
}) |
||||||
|
|
||||||
|
$("#reserve-button").on("click",function(e) { |
||||||
|
e.preventDefault(); |
||||||
|
$("#reserve-stage-modal").modal('show'); |
||||||
|
var orderId = $(this).attr('data-order-id'); |
||||||
|
$.ajax({ |
||||||
|
url: '/api/stages/', |
||||||
|
type: 'GET', |
||||||
|
data: {csrfmiddlewaretoken: csrftoken, 'order': orderId}, |
||||||
|
dataType: 'json', |
||||||
|
success: function (json) { |
||||||
|
var outputValues = ''; |
||||||
|
var totalSum = 0; |
||||||
|
var stagesIds = ''; |
||||||
|
var notPaidCount = 0; |
||||||
|
$.each(json.results, function (i, v) { |
||||||
|
if((v.status == 'in_process') && (!v.is_paid)) { |
||||||
|
totalSum += parseInt(v.cost); |
||||||
|
notPaidCount +=1; |
||||||
|
outputValues += '<option data-stage-sum="' + v.cost + '" value="' + v.id + '">' + v.name + '</option>'; |
||||||
|
stagesIds += v.id + ';' |
||||||
|
} |
||||||
|
}); |
||||||
|
|
||||||
|
$("#stagesSelect").html(outputValues); |
||||||
|
$(".totalSum").text(totalSum); |
||||||
|
|
||||||
|
if(json.results.length>notPaidCount && notPaidCount>0){ |
||||||
|
$("#choiceWayOrder").hide(); |
||||||
|
} |
||||||
|
|
||||||
|
$("#choiceWayOrder").val(totalSum); |
||||||
|
$("#ordermodalId").val(orderId); |
||||||
|
|
||||||
|
$("#stages-pay-form #stageSumPay").val(totalSum); |
||||||
|
$("#stages-pay-form #stagesIds").val(stagesIds); |
||||||
|
|
||||||
|
$("#choiceWayOrder").attr('data-stages-ids',stagesIds); |
||||||
|
|
||||||
|
} |
||||||
|
}); |
||||||
|
|
||||||
|
}); |
||||||
|
|
||||||
|
$("#tab2").on("change","input[name=choice_way]:radio", function(e){ |
||||||
|
var sumStage = $("#stagesSelect").find('option:selected').attr('data-stage-sum'); |
||||||
|
var currIdStage = $("#stagesSelect").find('option:selected').val(); |
||||||
|
$("#choiceWayStage").val(sumStage); |
||||||
|
var currValue = $(this).val(); |
||||||
|
$("#stages-pay-form #stageSumPay").val(currValue); |
||||||
|
var selectId = ($(this).attr('id')); |
||||||
|
if (selectId == 'choiceWayOrder'){ |
||||||
|
$("#stages-pay-form #stagesIds").val($(this).attr('data-stages-ids')); |
||||||
|
$("#stagesSelect").prop('disabled', 'disabled'); |
||||||
|
}else { |
||||||
|
$("#stages-pay-form #stagesIds").val(currIdStage); |
||||||
|
$("#stagesSelect").prop('disabled', false); |
||||||
|
} |
||||||
|
|
||||||
|
}); |
||||||
|
|
||||||
|
$("#tab2").on("change","#stagesSelect", function(e){ |
||||||
|
var sumStage = $(this).find('option:selected').attr("data-stage-sum"); |
||||||
|
$("#choiceWayStage").val(sumStage); |
||||||
|
$("#stages-pay-form #stageSumPay").val(sumStage); |
||||||
|
$(".stageSum").text(sumStage); |
||||||
|
$("#stages-pay-form #stagesIds").val($(this).val()); |
||||||
|
}); |
||||||
|
|
||||||
|
//Получить заказы |
||||||
|
function getStages(orderId, senderId, recipentId, secureOrder) { |
||||||
|
$.ajax({ |
||||||
|
url:'/api/orders/' + orderId + '/', |
||||||
|
type: 'GET', |
||||||
|
data:{csrfmiddlewaretoken: csrftoken}, |
||||||
|
dataType: 'json', |
||||||
|
}).then(function(data){ |
||||||
|
var stagesResults = data.stages; |
||||||
|
var stageCount = stagesResults.length; |
||||||
|
if (stageCount == 0) { |
||||||
|
$("#reserveSpace").hide(); |
||||||
|
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 orderStagesInput" name="order" type="hidden" value="' + orderId + '"/>' + |
||||||
|
'<label for="">Срок</label><input class="term-picker form-control datepicker" name="term" type="text" />' + |
||||||
|
'<label for="">Результат</label><input class="form-control" name="result" type="text" />' + |
||||||
|
'<input class="form-control" name="pos" value="1" type="hidden" />' + |
||||||
|
'</form></div>'; |
||||||
|
} |
||||||
|
var statusNotAgreed = true; |
||||||
|
var stagesInWork = []; |
||||||
|
var stagesPaidProcess = []; |
||||||
|
var stagesCompleted = []; |
||||||
|
var stagePaidCount = 0; |
||||||
|
var stagesReservedHtml = ""; |
||||||
|
|
||||||
|
$.each(stagesResults, function (i, v) { |
||||||
|
if (v.status == "completed"){ |
||||||
|
stagesCompleted.push(v); |
||||||
|
} |
||||||
|
if(!data.secure){ |
||||||
|
if(v.status == "in_process") { |
||||||
|
stagesInWork.push(v); |
||||||
|
} |
||||||
|
}else if ((v.status == "in_process") && (v.is_paid)){ |
||||||
|
stagesInWork.push(v); |
||||||
|
stagesPaidProcess.push(v); |
||||||
|
} |
||||||
|
|
||||||
|
if(v.is_paid){ |
||||||
|
stagePaidCount +=1; |
||||||
|
} |
||||||
|
|
||||||
|
if (v.status == "not_agreed") { |
||||||
|
htmlInbox += '<div class="numberStepp 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 orderStagesInput" type="hidden" name="order" value="' + v.order + '"/>' + |
||||||
|
'<label for="">Срок</label><input class="term-picker form-control datepicker" 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 = ""; |
||||||
|
var statusName = ''; |
||||||
|
if (v.status == 'completed'){ |
||||||
|
statusName = 'Завершен'; |
||||||
|
} |
||||||
|
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>до '+ v.term +'</p><span>' + v.cost + '<i class="fa fa-rub"></i></span>' + |
||||||
|
'</div><div><p>'+ statusName +'</p></div></div></div>'; |
||||||
|
|
||||||
|
} |
||||||
|
if(data.secure) { |
||||||
|
if (v.is_paid) { |
||||||
|
stagesReservedHtml += '<li class="reserved">Сумма за этап ' + v.pos + '.Зарезервирована.</li>'; |
||||||
|
} else { |
||||||
|
stagesReservedHtml += '<li class="unreserved">Сумма за этап ' + v.pos + '.Не зарезервирована.</li>'; |
||||||
|
} |
||||||
|
} |
||||||
|
}); |
||||||
|
|
||||||
|
if (stagesResults.length == stagePaidCount && data.secure){ |
||||||
|
$("#reserve-button").parent().hide(); |
||||||
|
}else { |
||||||
|
$("#reserve-button").parent().show(); |
||||||
|
} |
||||||
|
|
||||||
|
if (statusNotAgreed) { |
||||||
|
if(!data.secure) { |
||||||
|
htmlInbox += '<div class="box-sizing disTab">' + |
||||||
|
'<div class="checkbox"><input name="secure" id="secureOrder" type="checkbox" style="opacity:1">' + |
||||||
|
'Перейти в режим безопасной сделки</div></div>'; |
||||||
|
} |
||||||
|
|
||||||
|
htmlInbox +='<div class="textAreaBlock2 box-sizing disTab">' + |
||||||
|
'<a href="#" data-sender-id="' + senderId +'" ' + |
||||||
|
'data-recipent-id="' + recipentId +'" data-order-id="' + orderId + '" ' + |
||||||
|
'id="addStagesForm">отправить на согласование</a> </div>'; |
||||||
|
}else if((stagesResults.length>0) && (data.secure)){ |
||||||
|
$("#reserveSpace").show(); |
||||||
|
} |
||||||
|
htmlInbox = htmlInboxStage + htmlInbox; |
||||||
|
$("#order-stages").html(htmlInbox); |
||||||
|
$("#completeWork").hide(); |
||||||
|
|
||||||
|
if(stagesInWork.length > 0){ |
||||||
|
$("#completeWork").show(); |
||||||
|
var stage = stagesInWork[0]; |
||||||
|
var stageWork = '<div class="numberStepp box-sizing">' + |
||||||
|
'<div class="insetNumStepp"><div><p>В работе '+ stage.name +'</p></div> ' + |
||||||
|
'<div><p>Результат этапа : '+ stage.result +'</p></div>' + |
||||||
|
'<div><p>Срок сдачи '+ stage.term +'</p><span>' + stage.cost + '<i class="fa fa-rub"></i></span></div>' + |
||||||
|
'</div></div>'; |
||||||
|
|
||||||
|
if (stage.close_contractor){ |
||||||
|
stageWork += '<div class="textAreaBlock2 FFD box-sizing disTab"><a href="#" class="closeStage" data-order-id="'+ orderId + '" data-sender-id="{{ request.user.pk }}"' + |
||||||
|
' data-recipent-id="'+ recipentId + '" data-stage-id="'+ stage.id+'">Закрыть этап '+ stage.pos +'</a></div>'; |
||||||
|
} |
||||||
|
|
||||||
|
if (data.secure){ |
||||||
|
stageWork += '<div class="textAreaBlock2 FFD box-sizing disTab"><a href="#" data-toggle="modal" data-target="#arbitration-add">Обратитьсяв арбитраж</a></div>'; |
||||||
|
} |
||||||
|
$("#stagesWork").html(stageWork); |
||||||
|
} |
||||||
|
|
||||||
|
if (!data.secure){ |
||||||
|
$("#reserveSpace").hide(); |
||||||
|
} |
||||||
|
|
||||||
|
if((stagesCompleted.length == stagesResults.length) && (stagesCompleted.length > 0)){ |
||||||
|
$("#leaveReview").show(); |
||||||
|
console.log("Все этапы завершены"); |
||||||
|
}else { |
||||||
|
$("#leaveReview").hide(); |
||||||
|
} |
||||||
|
|
||||||
|
if (data.status == 'completed'){ |
||||||
|
$("#leaveReview").hide(); |
||||||
|
} |
||||||
|
|
||||||
|
$(".stages-paid").html(stagesReservedHtml); |
||||||
|
|
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
//Закрыть этап |
||||||
|
$('#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_customer: true, status: 'completed'}, |
||||||
|
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); |
||||||
|
} |
||||||
|
}); |
||||||
|
}); |
||||||
|
|
||||||
|
// Добавление этапов |
||||||
|
$("#order-stages").on('click', "#addStagesForm", function (e) { |
||||||
|
e.preventDefault(); |
||||||
|
var currentOrderId = $(this).attr('data-order-id'); |
||||||
|
var secureOrderEl = $("#secureOrder"); |
||||||
|
if(secureOrderEl.length > 0) { |
||||||
|
var secOrderVal = false; |
||||||
|
if (secureOrderEl.prop('checked')) { |
||||||
|
secOrderVal = true; |
||||||
|
} |
||||||
|
$.ajax({ |
||||||
|
url: '/api/orders/' + currentOrderId + '/', |
||||||
|
type: 'PATCH', |
||||||
|
beforeSend: function (xhr) { |
||||||
|
xhr.setRequestHeader("X-CSRFToken", getCookie('csrftoken')) |
||||||
|
}, |
||||||
|
data: {secure: secOrderVal}, |
||||||
|
dataType: 'json', |
||||||
|
success: function (json){ |
||||||
|
}, |
||||||
|
error: function(e){ |
||||||
|
console.log(e); |
||||||
|
} |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
$(".new-stages-form").each(function (i, v) { |
||||||
|
$.ajax({ |
||||||
|
url: '/api/stages/', |
||||||
|
type: 'POST', |
||||||
|
beforeSend: function (xhr) { |
||||||
|
xhr.setRequestHeader("X-CSRFToken", getCookie('csrftoken')) |
||||||
|
}, |
||||||
|
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) { |
||||||
|
console.log('error'); |
||||||
|
console.log(e); |
||||||
|
} |
||||||
|
}); |
||||||
|
}); |
||||||
|
|
||||||
|
|
||||||
|
var currentRecipentId = $(this).attr('data-recipent-id'); |
||||||
|
var secureOrder = true |
||||||
|
|
||||||
|
socket.send_stages_approve({ |
||||||
|
"format_type": "approve_stages", |
||||||
|
"data": { |
||||||
|
"sender_id": userId, |
||||||
|
"recipent_id": currentRecipentId, |
||||||
|
"order_id": currentOrderId, |
||||||
|
"msg": "Этапы для заказа "+ currentOrderId +"изменены", |
||||||
|
} |
||||||
|
}); |
||||||
|
|
||||||
|
{# setTimeout(function () {#} |
||||||
|
{# getStages(currentOrderId,userId,currentRecipentId,secureOrder);#} |
||||||
|
{##} |
||||||
|
{# }, 1000);#} |
||||||
|
|
||||||
|
}); |
||||||
|
|
||||||
|
//Изменение счетчика |
||||||
|
$('#order-stages-tab').on('change', '#countStage', function () { |
||||||
|
var countStage = parseInt($(this).val()); |
||||||
|
var currentCountStage = $(".numberStepp").length; |
||||||
|
if ((countStage<1) || isNaN(countStage)) { |
||||||
|
countStage = 1; |
||||||
|
$('#order-stages-tab #countStage').val(currentCountStage); |
||||||
|
}else { |
||||||
|
if (countStage > currentCountStage) { |
||||||
|
for (var jj = currentCountStage; jj < countStage; jj++) { |
||||||
|
var pos = jj + 1; |
||||||
|
var lastFormStage = $(".numberStepp").last(); |
||||||
|
var orderId = lastFormStage.find('.orderStagesInput').val(); |
||||||
|
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">' + |
||||||
|
'<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 orderStagesInput" name="order" type="hidden" value="' + orderId + '" />' + |
||||||
|
'<label for="">Срок</label><input class="term-picker form-control datepicker" name="term" type="text" />' + |
||||||
|
'<label for="">Результат</label><input class="form-control" name="result" type="text" />' + |
||||||
|
'<input class="form-control" name="pos" value="' + pos + '" type="hidden" />' |
||||||
|
'</form></div>'; |
||||||
|
lastFormStage.after(addFormTemplate); |
||||||
|
} |
||||||
|
|
||||||
|
} else if (countStage < currentCountStage) { |
||||||
|
var ii = currentCountStage; |
||||||
|
$($(".numberStepp").get().reverse()).each(function () { |
||||||
|
var currenFormName = ($(this).find('form').attr('class')); |
||||||
|
if (ii > countStage) { |
||||||
|
$(this).remove(); |
||||||
|
} |
||||||
|
ii--; |
||||||
|
}); |
||||||
|
|
||||||
|
} |
||||||
|
} |
||||||
|
}); |
||||||
|
|
||||||
|
// Для заказов все вытащить |
||||||
|
$('.order-block').on('click', function () { |
||||||
|
$("#chat-order-add").css("display", "block"); |
||||||
|
$("#formsetStage").css("display", "block"); |
||||||
|
|
||||||
|
$('.order-block').each(function () { |
||||||
|
$(this).removeClass('orAct'); |
||||||
|
}); |
||||||
|
|
||||||
|
$(this).addClass('orAct'); |
||||||
|
var orderId = $(this).attr('data-id'); |
||||||
|
var projectId = $(this).attr('data-project-id'); |
||||||
|
var recipentId = $(this).attr('data-recipent-id'); |
||||||
|
var secureOrder = $(this).attr('data-secure-deal'); |
||||||
|
secureOrder = Boolean(secureOrder); |
||||||
|
$("#chat-order-add #orderId").val(orderId); |
||||||
|
$("#orderArbitrationId").val(orderId); |
||||||
|
$("#projectReviewId").val(projectId); |
||||||
|
$("#reserve-button").attr('data-order-id', orderId); |
||||||
|
$("#targetContractorId").val(recipentId); |
||||||
|
$("#chat-order-add #recipentId").val(recipentId); |
||||||
|
$(".orderStagesInput").val(orderId); |
||||||
|
var inbox = document.getElementById('message-chat-order-space'); |
||||||
|
var docList = document.getElementById('documentOrderSpace'); |
||||||
|
inbox.innerHTML = ''; |
||||||
|
docList.innerHTML = ''; |
||||||
|
|
||||||
|
$.ajax({ |
||||||
|
url:'/api/documents', |
||||||
|
type: 'GET', |
||||||
|
data:{ |
||||||
|
csrfmiddlewaretoken: csrftoken, |
||||||
|
'order': orderId |
||||||
|
}, |
||||||
|
dataType: 'json', |
||||||
|
success: function (json){ |
||||||
|
console.log(json); |
||||||
|
|
||||||
|
$.each(json.results, function (i, v) { |
||||||
|
docList.innerHTML += '<li style="word-break: break-all;"><a class="file-link" href="'+ v.file_url +'">'+ v.file+'</a></li>'; |
||||||
|
}); |
||||||
|
}, |
||||||
|
error: function(e){ |
||||||
|
console.log(e); |
||||||
|
} |
||||||
|
}); |
||||||
|
$.ajax({ |
||||||
|
url: '/api/message', |
||||||
|
type: 'GET', |
||||||
|
data: {csrfmiddlewaretoken: csrftoken, 'order': orderId,'team__isnull': 'true'}, |
||||||
|
dataType: 'json', |
||||||
|
success: function (json) { |
||||||
|
$.each(json.results, function (i, v) { |
||||||
|
var senderName = 'Вы'; |
||||||
|
var className = 'youChat'; |
||||||
|
|
||||||
|
if (v.sender.id !== currentChatUser) { |
||||||
|
senderName = v.sender.username; |
||||||
|
className = ''; |
||||||
|
} |
||||||
|
|
||||||
|
inbox.innerHTML += '<div class="col-lg-12 insetCommChat ' + className + '"><div class="topCommChat">' + |
||||||
|
'<p class="nameCommChat">' + senderName + '</p><span>' + v.created + '</span></div>' + |
||||||
|
'<p class="textCommChat">' + v.text + '</p></div>'; |
||||||
|
}); |
||||||
|
} |
||||||
|
}); |
||||||
|
getStages(orderId,userId,recipentId, secureOrder); |
||||||
|
}); |
||||||
|
|
||||||
|
}); |
||||||
|
var userId = '{{ request.user.pk }}'; |
||||||
|
|
||||||
|
</script> |
||||||
|
{% endblock %} |
||||||
|
|
||||||
@ -0,0 +1,16 @@ |
|||||||
|
# -*- coding: utf-8 -*- |
||||||
|
# Generated by Django 1.9.7 on 2016-09-02 07:45 |
||||||
|
from __future__ import unicode_literals |
||||||
|
|
||||||
|
from django.db import migrations |
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration): |
||||||
|
|
||||||
|
dependencies = [ |
||||||
|
('wallets', '0012_auto_20160901_1247'), |
||||||
|
('wallets', '0012_auto_20160901_1548'), |
||||||
|
] |
||||||
|
|
||||||
|
operations = [ |
||||||
|
] |
||||||
@ -0,0 +1,29 @@ |
|||||||
|
# -*- coding: utf-8 -*- |
||||||
|
# Generated by Django 1.9.7 on 2016-09-02 09:25 |
||||||
|
from __future__ import unicode_literals |
||||||
|
|
||||||
|
from django.conf import settings |
||||||
|
from django.db import migrations, models |
||||||
|
import django.db.models.deletion |
||||||
|
import django.utils.timezone |
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration): |
||||||
|
|
||||||
|
dependencies = [ |
||||||
|
migrations.swappable_dependency(settings.AUTH_USER_MODEL), |
||||||
|
('wallets', '0013_merge'), |
||||||
|
] |
||||||
|
|
||||||
|
operations = [ |
||||||
|
migrations.CreateModel( |
||||||
|
name='PayFromScore', |
||||||
|
fields=[ |
||||||
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), |
||||||
|
('sum', models.DecimalField(decimal_places=0, default=0, max_digits=20)), |
||||||
|
('stages_id', models.CharField(blank=True, max_length=100, null=True)), |
||||||
|
('created_at', models.DateTimeField(default=django.utils.timezone.now, editable=False)), |
||||||
|
('customer', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='customer_payfromscore', to=settings.AUTH_USER_MODEL)), |
||||||
|
], |
||||||
|
), |
||||||
|
] |
||||||
@ -0,0 +1 @@ |
|||||||
|
<h1> Ваш счет: {{ score }}</h1> |
||||||
@ -0,0 +1,16 @@ |
|||||||
|
# -*- coding: utf-8 -*- |
||||||
|
# Generated by Django 1.9.7 on 2016-09-02 07:45 |
||||||
|
from __future__ import unicode_literals |
||||||
|
|
||||||
|
from django.db import migrations |
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration): |
||||||
|
|
||||||
|
dependencies = [ |
||||||
|
('work_sell', '0009_auto_20160901_1548'), |
||||||
|
('work_sell', '0009_auto_20160901_1247'), |
||||||
|
] |
||||||
|
|
||||||
|
operations = [ |
||||||
|
] |
||||||
Loading…
Reference in new issue