Skip to content

Commit ce8800e

Browse files
authored
Merge pull request #1626 from vishal-singh-webkul/gli-2871
Fixed: Getting error in growl while deleting the hotel image or while changing the hotel cover image in the admin office.
2 parents 1474ec2 + 33a521a commit ce8800e

File tree

3 files changed

+10
-35
lines changed

3 files changed

+10
-35
lines changed

modules/hotelreservationsystem/controllers/admin/AdminAddHotelController.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -907,6 +907,7 @@ public function ajaxProcessUploadHotelImages()
907907
public function ajaxProcessChangeCoverImage()
908908
{
909909
$idImage = Tools::getValue('id_image');
910+
$response = array('status' => false);
910911
if ($idImage) {
911912
$idHotel = Tools::getValue('id_hotel');
912913
if ($coverImg = HotelImage::getCover($idHotel)) {
@@ -918,17 +919,15 @@ public function ajaxProcessChangeCoverImage()
918919
$objHtlImage = new HotelImage((int) $idImage);
919920
$objHtlImage->cover = 1;
920921
if ($objHtlImage->update()) {
921-
die(true);
922-
} else {
923-
die(false);
922+
$response['status'] = true;
924923
}
925-
} else {
926-
die(false);
927924
}
925+
$this->ajaxDie(json_encode($response));
928926
}
929927

930928
public function ajaxProcessDeleteHotelImage()
931929
{
930+
$response = array('status' => false);
932931
if ($idImage = Tools::getValue('id_image')) {
933932
if ($idHotel = Tools::getValue('id_hotel')) {
934933
if (Validate::isLoadedObject($objHtlImage = new HotelImage((int) $idImage))) {
@@ -941,12 +940,12 @@ public function ajaxProcessDeleteHotelImage()
941940
$objHtlImage->save();
942941
}
943942
}
944-
die(true);
943+
$response['status'] = true;
945944
}
946945
}
947946
}
948947
}
949-
die(false);
948+
$this->ajaxDie(json_encode($response));
950949
}
951950

952951
public function ajaxProcessUpdateSlidesPosition()

modules/hotelreservationsystem/views/js/HotelReservationAdmin.js

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -293,32 +293,6 @@ $(document).ready(function() {
293293
}
294294
});
295295

296-
// delete hotel image
297-
$('.deleteHtlImage').on('click', function(){
298-
var imgId = $(this).attr('id_htl_img');
299-
var $this = $(this);
300-
$.ajax({
301-
url: statebycountryurl,
302-
data: {
303-
id_htl_img: imgId,
304-
ajax: true,
305-
action: 'deleteHotelImage',
306-
},
307-
method: 'POST',
308-
success: function(data) {
309-
if (data == 1) {
310-
$this.closest('.img-container-div').remove();
311-
showSuccessMessage(htlImgDeleteSuccessMsg);
312-
} else {
313-
showErrorMessage(htlImgDeleteErrMsg);
314-
}
315-
},
316-
error: function(XMLHttpRequest, textStatus, errorThrown) {
317-
alert(textStatus);
318-
}
319-
});
320-
});
321-
322296
$('#hotel_country').on('change', function() {
323297
$('#hotel_state').empty();
324298
$.ajax({

modules/hotelreservationsystem/views/js/hotelImage.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,14 +109,15 @@ $(document).ready(function () {
109109
$.ajax({
110110
type:'POST',
111111
url: adminHotelCtrlUrl,
112+
dataType: 'json',
112113
data: {
113114
ajax: true,
114115
action: 'changeCoverImage',
115116
id_hotel: idHotel,
116117
id_image: idImage,
117118
},
118119
success: function(result) {
119-
if (result) {
120+
if (result.status) {
120121
// remover cover image identifier from old cover image
121122
var oldCoverImageTr = $("#hotel-image-table tbody tr.cover-image-tr");
122123
oldCoverImageTr.removeClass("cover-image-tr").find("td.cover-image-td").removeClass("cover-image-td").find("a.changer-cover-image").removeClass("text-success").addClass("text-danger").attr("data-is-cover", "0").find("i.icon-check").removeClass("icon-check").addClass("icon-times");
@@ -149,14 +150,15 @@ $(document).ready(function () {
149150
$.ajax({
150151
type:'POST',
151152
url: adminHotelCtrlUrl,
153+
dataType: 'json',
152154
data: {
153155
ajax: true,
154156
action: 'deleteHotelImage',
155157
id_hotel: idHotel,
156158
id_image: idImage,
157159
},
158160
success: function(result) {
159-
if (result) {
161+
if (result.status) {
160162
if (parseInt(isCover)) {
161163
location.reload();
162164
} else {

0 commit comments

Comments
 (0)