Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand All @@ -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))) {
Expand All @@ -941,12 +940,12 @@ public function ajaxProcessDeleteHotelImage()
$objHtlImage->save();
}
}
die(true);
$response['status'] = true;
}
}
}
}
die(false);
$this->ajaxDie(json_encode($response));
}

public function ajaxProcessUpdateSlidesPosition()
Expand Down
26 changes: 0 additions & 26 deletions modules/hotelreservationsystem/views/js/HotelReservationAdmin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
6 changes: 4 additions & 2 deletions modules/hotelreservationsystem/views/js/hotelImage.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,15 @@ $(document).ready(function () {
$.ajax({
type:'POST',
url: adminHotelCtrlUrl,
dataType: 'json',
data: {
ajax: true,
action: 'changeCoverImage',
id_hotel: idHotel,
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");
Expand Down Expand Up @@ -149,14 +150,15 @@ $(document).ready(function () {
$.ajax({
type:'POST',
url: adminHotelCtrlUrl,
dataType: 'json',
data: {
ajax: true,
action: 'deleteHotelImage',
id_hotel: idHotel,
id_image: idImage,
},
success: function(result) {
if (result) {
if (result.status) {
if (parseInt(isCover)) {
location.reload();
} else {
Expand Down