diff --git a/modules/hotelreservationsystem/controllers/admin/AdminAddHotelController.php b/modules/hotelreservationsystem/controllers/admin/AdminAddHotelController.php index 57dcea009c..a2b5136766 100644 --- a/modules/hotelreservationsystem/controllers/admin/AdminAddHotelController.php +++ b/modules/hotelreservationsystem/controllers/admin/AdminAddHotelController.php @@ -907,6 +907,7 @@ public function ajaxProcessUploadHotelImages() public function ajaxProcessChangeCoverImage() { $idImage = Tools::getValue('id_image'); + $response = array('status' => false); if ($idImage) { $idHotel = Tools::getValue('id_hotel'); if ($coverImg = HotelImage::getCover($idHotel)) { @@ -918,17 +919,15 @@ public function ajaxProcessChangeCoverImage() $objHtlImage = new HotelImage((int) $idImage); $objHtlImage->cover = 1; if ($objHtlImage->update()) { - die(true); - } else { - die(false); + $response['status'] = true; } - } else { - die(false); } + $this->ajaxDie(json_encode($response)); } public function ajaxProcessDeleteHotelImage() { + $response = array('status' => false); if ($idImage = Tools::getValue('id_image')) { if ($idHotel = Tools::getValue('id_hotel')) { if (Validate::isLoadedObject($objHtlImage = new HotelImage((int) $idImage))) { @@ -941,12 +940,12 @@ public function ajaxProcessDeleteHotelImage() $objHtlImage->save(); } } - die(true); + $response['status'] = true; } } } } - die(false); + $this->ajaxDie(json_encode($response)); } public function ajaxProcessUpdateSlidesPosition() diff --git a/modules/hotelreservationsystem/views/js/HotelReservationAdmin.js b/modules/hotelreservationsystem/views/js/HotelReservationAdmin.js index 33fdb3ab66..b3232b15f9 100644 --- a/modules/hotelreservationsystem/views/js/HotelReservationAdmin.js +++ b/modules/hotelreservationsystem/views/js/HotelReservationAdmin.js @@ -293,32 +293,6 @@ $(document).ready(function() { } }); - // delete hotel image - $('.deleteHtlImage').on('click', function(){ - var imgId = $(this).attr('id_htl_img'); - var $this = $(this); - $.ajax({ - url: statebycountryurl, - data: { - id_htl_img: imgId, - ajax: true, - action: 'deleteHotelImage', - }, - method: 'POST', - success: function(data) { - if (data == 1) { - $this.closest('.img-container-div').remove(); - showSuccessMessage(htlImgDeleteSuccessMsg); - } else { - showErrorMessage(htlImgDeleteErrMsg); - } - }, - error: function(XMLHttpRequest, textStatus, errorThrown) { - alert(textStatus); - } - }); - }); - $('#hotel_country').on('change', function() { $('#hotel_state').empty(); $.ajax({ diff --git a/modules/hotelreservationsystem/views/js/hotelImage.js b/modules/hotelreservationsystem/views/js/hotelImage.js index ad3152c066..c1fd5f6666 100644 --- a/modules/hotelreservationsystem/views/js/hotelImage.js +++ b/modules/hotelreservationsystem/views/js/hotelImage.js @@ -109,6 +109,7 @@ $(document).ready(function () { $.ajax({ type:'POST', url: adminHotelCtrlUrl, + dataType: 'json', data: { ajax: true, action: 'changeCoverImage', @@ -116,7 +117,7 @@ $(document).ready(function () { id_image: idImage, }, success: function(result) { - if (result) { + if (result.status) { // remover cover image identifier from old cover image var oldCoverImageTr = $("#hotel-image-table tbody tr.cover-image-tr"); 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,6 +150,7 @@ $(document).ready(function () { $.ajax({ type:'POST', url: adminHotelCtrlUrl, + dataType: 'json', data: { ajax: true, action: 'deleteHotelImage', @@ -156,7 +158,7 @@ $(document).ready(function () { id_image: idImage, }, success: function(result) { - if (result) { + if (result.status) { if (parseInt(isCover)) { location.reload(); } else {