Обработка изменения статуса заказа через попап с указанием комментария к отклонению

parent 67ee96d3
......@@ -625,6 +625,7 @@ input[type="checkbox"]
.b-popup-content textarea.b-popup-comment
{
padding: 10px;
margin-bottom: 5px;
width: 100%;
background-color: #FFFFFF;
border: 1px solid #CCCCCC;
......@@ -634,6 +635,5 @@ input[type="checkbox"]
.b-popup-content button
{
display: block;
margin: 0 auto;
}
\ No newline at end of file
......@@ -345,14 +345,19 @@ $(document).ready(function(){
var
$popupBg = $('.l-popup'),
$popup = $('.b-popup__window.order-regected-comment', $popupBg),
$popupClose = $('.button-close', $popup),
$popupContent = $('.b-popup-content', $popup),
$popupClose = $('.button-close', $popup),
$popupApply = $('button.apply', $popup),
$popupCancel = $('button.cancel', $popup),
$popupComment = $('.b-popup-comment', $popup);
// Закрыввем попап по клику на Х:
$popupClose.on('click', function(){
ClosePopup();
});
$popupCancel.on('click', function(){
ClosePopup();
});
// Закрыввем попап по клику извне:
$popup.on('click', function(event){
event.stopPropagation();
......@@ -369,20 +374,22 @@ $(document).ready(function(){
$popupContent.attr("data-order-id", dataPopup.orderId);
}
function ClosePopup()
function ClosePopup(isApply = false)
{
$popupBg.removeClass('open-popup');
$popup.hide();
var
feedIdValue = $popupContent.attr("data-feed-id"),
orderIdValue = $popupContent.attr("data-order-id");
console.log('AAA feedIdValue = ', feedIdValue);
console.log('AAA orderIdValue = ', orderIdValue);
$popupContent.attr("data-feed-id", null);
$popupContent.attr("data-order-id", null);
$popupComment.val('');
if (!isApply) {
var $orderInput = $('tbody tr.transaction-item td.status span[data-feed-id="' + feedIdValue + '"][data-order-id="' + orderIdValue + '"] input', $tableStat);
$orderInput.prop("checked", true);
}
$popupApply.off('click');
}
// Клик на галочку подтверждения заказа:
......@@ -401,6 +408,7 @@ $(document).ready(function(){
},
$tableToExcel = $("#table2excel"),
$orderTrExcel = $('tbody tr.order-item[data-feed-id="' + $spanWrap.data('feed-id') + '"][data-order-id="' + $spanWrap.data('order-id') + '"]', $tableToExcel);
// Popup с комментарием к отклонению заказа:
if (!data.confirmed) {
......@@ -409,11 +417,45 @@ $(document).ready(function(){
'orderId': $spanWrap.data('order-id'),
}
ShowPopup(dataPopup);
$popupApply.on('click', function(){
data.comment = $popupComment.val();
RequestChangeConfirmed($this, action, data, $orderTr, $orderTrExcel);
ClosePopup(true);
});
} else {
/*
$this.prop("disabled", true);
$.ajax(action, {
type: 'POST',
data: data,
success: function(data) {
console.log('AAA success ', data);
if (data.result) {
$orderTr.removeClass('confirmed').removeClass('rejected');
$orderTr.addClass((data.confirmed) ? 'confirmed' : 'rejected');
$orderTrExcel.removeClass('confirmed').removeClass('rejected');
$orderTrExcel.addClass((data.confirmed) ? 'confirmed' : 'rejected');
} else {
$this.prop("checked", !$this.prop( "checked" ))
}
$this.prop("disabled", false);
OrdersStatusReCalc();
},
error: function(rew, status, err) {
console.log(status, err);
$this.prop("disabled", false);
}
});
*/
RequestChangeConfirmed($this, action, data, $orderTr, $orderTrExcel);
}
return false;
});
function RequestChangeConfirmed($this, action, data, $orderTr, $orderTrExcel) {
$this.prop("disabled", true);
$.ajax(action, {
type: 'POST',
data: data,
......@@ -422,23 +464,23 @@ $(document).ready(function(){
if (data.result) {
$orderTr.removeClass('confirmed').removeClass('rejected');
$orderTr.addClass((data.confirmed) ? 'confirmed' : 'rejected');
$orderTrExcel.removeClass('confirmed').removeClass('rejected');
$orderTrExcel.addClass((data.confirmed) ? 'confirmed' : 'rejected');
} else {
$this.prop("checked", !$this.prop( "checked" ))
$this.prop("checked", !$this.prop( "checked" ));
}
$this.prop("disabled", false);
OrdersStatusReCalc();
},
error: function(rew, status, err) {
console.log(status, err);
$this.prop("checked", !$this.prop( "checked" ));
$this.prop("disabled", false);
}
});
return false;
});
}
// Клик на Утвердить заказы:
/*
......
......@@ -409,7 +409,8 @@ class Cabinet extends Common
'feed_id' => $feed_id,
'order_id' => $order_id,
'confirmed' => $data_request['confirmed'],
'approved' => 0
'approved' => 0,
'comment' => ($data_request['comment']) ? $data_request['comment'] : null,
);
$orderStatus = $hydrator->hydrate($data, new OrderStatus());
$res = $ordersStatusModel->saveRetargOrderStatus($orderStatus, 'insert');
......
......@@ -107,5 +107,23 @@ class OrderStatus extends Common
$this->approved = $approved;
return $this;
}
/**
* @return int
*/
public function getComment()
{
return $this->comment;
}
/**
* @param string $comment
* @return OrderStatus
*/
public function setComment($comment)
{
$this->comment = $comment;
return $this;
}
}
\ No newline at end of file
......@@ -3,7 +3,8 @@
<div class="b-popup-content" data-feed-id="" data-order-id="">
<h2><?= _t("Комментарий к отклонению заказа") ?></h2>
<textarea class="b-popup-comment"></textarea>
<button class="btn btn-danger" type="button111" >Отклонить заказ</button>
<button class="btn btn-danger apply" type="button" >Отклонить заказ</button>
<button class="btn btn-default cancel" type="button" >Отмена</button>
</div>
</div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment