diff --git a/modules/qlohotelreview/classes/QhrHotelReview.php b/modules/qlohotelreview/classes/QhrHotelReview.php index 92602bdac..39bc9a262 100644 --- a/modules/qlohotelreview/classes/QhrHotelReview.php +++ b/modules/qlohotelreview/classes/QhrHotelReview.php @@ -244,6 +244,15 @@ class QhrHotelReview extends ObjectModel ); } + public function getTotalUseful() + { + return (int) Db::getInstance()->getValue( + 'SELECT COUNT(*) + FROM `'._DB_PREFIX_.'qhr_review_usefulness` ru + WHERE ru.`id_hotel_review` = '.(int) $this->id_hotel_review + ); + } + public function getTotalReports() { $sql = new DbQuery(); diff --git a/modules/qlohotelreview/controllers/front/default.php b/modules/qlohotelreview/controllers/front/default.php index e1cfecb53..fe6e6f2eb 100644 --- a/modules/qlohotelreview/controllers/front/default.php +++ b/modules/qlohotelreview/controllers/front/default.php @@ -139,6 +139,8 @@ class QloHotelReviewDefaultModuleFrontController extends ModuleFrontController if (QhrHotelReview::markHelpful($idHotelReview, $this->context->cookie->id_customer)) { $response['status'] = true; + $objHotelReview = new QhrHotelReview($idHotelReview); + $response['count_useful'] = $objHotelReview->getTotalUseful(); $this->ajaxDie(json_encode($response)); } } diff --git a/modules/qlohotelreview/views/js/front/review-list.js b/modules/qlohotelreview/views/js/front/review-list.js index 5b26ab468..8e67eea04 100644 --- a/modules/qlohotelreview/views/js/front/review-list.js +++ b/modules/qlohotelreview/views/js/front/review-list.js @@ -36,9 +36,10 @@ var QhrReview = { headers: { 'cache-control': 'no-cache' }, success: function(response) { if (response.status == true) { + $(btnHelpful).closest('.review').find('.helpful-count span').html(response.count_useful); $(btnHelpful).fadeOut('slow', function() { $(btnHelpful).remove(); - }) + }); } } }); diff --git a/modules/qlohotelreview/views/templates/admin/hotel_review_hotel_review/helpers/view/_partials/review.tpl b/modules/qlohotelreview/views/templates/admin/hotel_review_hotel_review/helpers/view/_partials/review.tpl index 57e88a071..114f895d3 100644 --- a/modules/qlohotelreview/views/templates/admin/hotel_review_hotel_review/helpers/view/_partials/review.tpl +++ b/modules/qlohotelreview/views/templates/admin/hotel_review_hotel_review/helpers/view/_partials/review.tpl @@ -124,7 +124,11 @@
- {$total_reports|escape:'html':'UTF-8'} + {if $total_reports|intval > 0} + {$total_reports|escape:'html':'UTF-8'} + {else} + -- + {/if}
{if $total_reports|intval > 0}diff --git a/modules/qlohotelreview/views/templates/hook/_partials/review.tpl b/modules/qlohotelreview/views/templates/hook/_partials/review.tpl index 5362b70b5..5444ec30f 100644 --- a/modules/qlohotelreview/views/templates/hook/_partials/review.tpl +++ b/modules/qlohotelreview/views/templates/hook/_partials/review.tpl @@ -51,7 +51,7 @@ {/if} -
{l s='%1$d people found it helpful.' sprintf=[$review.total_useful] mod='qlohotelreview'}
+{$review.total_useful|escape:'html':'UTF-8'}{l s=' people found it helpful.' mod='qlohotelreview'}