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

parent 67ee96d3
...@@ -625,6 +625,7 @@ input[type="checkbox"] ...@@ -625,6 +625,7 @@ input[type="checkbox"]
.b-popup-content textarea.b-popup-comment .b-popup-content textarea.b-popup-comment
{ {
padding: 10px; padding: 10px;
margin-bottom: 5px;
width: 100%; width: 100%;
background-color: #FFFFFF; background-color: #FFFFFF;
border: 1px solid #CCCCCC; border: 1px solid #CCCCCC;
...@@ -634,6 +635,5 @@ input[type="checkbox"] ...@@ -634,6 +635,5 @@ input[type="checkbox"]
.b-popup-content button .b-popup-content button
{ {
display: block;
margin: 0 auto;
} }
\ No newline at end of file
...@@ -345,14 +345,19 @@ $(document).ready(function(){ ...@@ -345,14 +345,19 @@ $(document).ready(function(){
var var
$popupBg = $('.l-popup'), $popupBg = $('.l-popup'),
$popup = $('.b-popup__window.order-regected-comment', $popupBg), $popup = $('.b-popup__window.order-regected-comment', $popupBg),
$popupClose = $('.button-close', $popup),
$popupContent = $('.b-popup-content', $popup), $popupContent = $('.b-popup-content', $popup),
$popupClose = $('.button-close', $popup),
$popupApply = $('button.apply', $popup),
$popupCancel = $('button.cancel', $popup),
$popupComment = $('.b-popup-comment', $popup); $popupComment = $('.b-popup-comment', $popup);
// Закрыввем попап по клику на Х: // Закрыввем попап по клику на Х:
$popupClose.on('click', function(){ $popupClose.on('click', function(){
ClosePopup(); ClosePopup();
}); });
$popupCancel.on('click', function(){
ClosePopup();
});
// Закрыввем попап по клику извне: // Закрыввем попап по клику извне:
$popup.on('click', function(event){ $popup.on('click', function(event){
event.stopPropagation(); event.stopPropagation();
...@@ -369,7 +374,7 @@ $(document).ready(function(){ ...@@ -369,7 +374,7 @@ $(document).ready(function(){
$popupContent.attr("data-order-id", dataPopup.orderId); $popupContent.attr("data-order-id", dataPopup.orderId);
} }
function ClosePopup() function ClosePopup(isApply = false)
{ {
$popupBg.removeClass('open-popup'); $popupBg.removeClass('open-popup');
$popup.hide(); $popup.hide();
...@@ -377,12 +382,14 @@ $(document).ready(function(){ ...@@ -377,12 +382,14 @@ $(document).ready(function(){
feedIdValue = $popupContent.attr("data-feed-id"), feedIdValue = $popupContent.attr("data-feed-id"),
orderIdValue = $popupContent.attr("data-order-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-feed-id", null);
$popupContent.attr("data-order-id", null); $popupContent.attr("data-order-id", null);
$popupComment.val(''); $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');
} }
// Клик на галочку подтверждения заказа: // Клик на галочку подтверждения заказа:
...@@ -402,6 +409,7 @@ $(document).ready(function(){ ...@@ -402,6 +409,7 @@ $(document).ready(function(){
$tableToExcel = $("#table2excel"), $tableToExcel = $("#table2excel"),
$orderTrExcel = $('tbody tr.order-item[data-feed-id="' + $spanWrap.data('feed-id') + '"][data-order-id="' + $spanWrap.data('order-id') + '"]', $tableToExcel); $orderTrExcel = $('tbody tr.order-item[data-feed-id="' + $spanWrap.data('feed-id') + '"][data-order-id="' + $spanWrap.data('order-id') + '"]', $tableToExcel);
// Popup с комментарием к отклонению заказа: // Popup с комментарием к отклонению заказа:
if (!data.confirmed) { if (!data.confirmed) {
var dataPopup = { var dataPopup = {
...@@ -409,11 +417,14 @@ $(document).ready(function(){ ...@@ -409,11 +417,14 @@ $(document).ready(function(){
'orderId': $spanWrap.data('order-id'), 'orderId': $spanWrap.data('order-id'),
} }
ShowPopup(dataPopup); ShowPopup(dataPopup);
} $popupApply.on('click', function(){
return false; data.comment = $popupComment.val();
RequestChangeConfirmed($this, action, data, $orderTr, $orderTrExcel);
ClosePopup(true);
});
} else {
/*
$this.prop("disabled", true); $this.prop("disabled", true);
$.ajax(action, { $.ajax(action, {
type: 'POST', type: 'POST',
data: data, data: data,
...@@ -437,9 +448,40 @@ $(document).ready(function(){ ...@@ -437,9 +448,40 @@ $(document).ready(function(){
$this.prop("disabled", false); $this.prop("disabled", false);
} }
}); });
*/
RequestChangeConfirmed($this, action, data, $orderTr, $orderTrExcel);
}
return false; return false;
}); });
function RequestChangeConfirmed($this, action, data, $orderTr, $orderTrExcel) {
$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("checked", !$this.prop( "checked" ));
$this.prop("disabled", false);
}
});
}
// Клик на Утвердить заказы: // Клик на Утвердить заказы:
/* /*
$('a.btn.approve').on('click', function(){ $('a.btn.approve').on('click', function(){
......
...@@ -409,7 +409,8 @@ class Cabinet extends Common ...@@ -409,7 +409,8 @@ class Cabinet extends Common
'feed_id' => $feed_id, 'feed_id' => $feed_id,
'order_id' => $order_id, 'order_id' => $order_id,
'confirmed' => $data_request['confirmed'], 'confirmed' => $data_request['confirmed'],
'approved' => 0 'approved' => 0,
'comment' => ($data_request['comment']) ? $data_request['comment'] : null,
); );
$orderStatus = $hydrator->hydrate($data, new OrderStatus()); $orderStatus = $hydrator->hydrate($data, new OrderStatus());
$res = $ordersStatusModel->saveRetargOrderStatus($orderStatus, 'insert'); $res = $ordersStatusModel->saveRetargOrderStatus($orderStatus, 'insert');
......
...@@ -108,4 +108,22 @@ class OrderStatus extends Common ...@@ -108,4 +108,22 @@ class OrderStatus extends Common
return $this; 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 @@ ...@@ -3,7 +3,8 @@
<div class="b-popup-content" data-feed-id="" data-order-id=""> <div class="b-popup-content" data-feed-id="" data-order-id="">
<h2><?= _t("Комментарий к отклонению заказа") ?></h2> <h2><?= _t("Комментарий к отклонению заказа") ?></h2>
<textarea class="b-popup-comment"></textarea> <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>
</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