Show updated helpful count when marking a review helpful
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
})
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -124,7 +124,11 @@
|
||||
<label class="control-label col-lg-3">{l s='Total Reports' mod='qlohotelreview'}</label>
|
||||
<div class="col-lg-9">
|
||||
<p class="form-control-static">
|
||||
<span class="badge badge-danger">{$total_reports|escape:'html':'UTF-8'}</span>
|
||||
{if $total_reports|intval > 0}
|
||||
<span class="badge badge-danger">{$total_reports|escape:'html':'UTF-8'}</span>
|
||||
{else}
|
||||
--
|
||||
{/if}
|
||||
</p>
|
||||
{if $total_reports|intval > 0}
|
||||
<p>
|
||||
|
||||
@@ -51,7 +51,7 @@
|
||||
<i class="icon icon-thumbs-o-up text-primary"></i>
|
||||
</a>
|
||||
{/if}
|
||||
<p class="helpful-count">{l s='%1$d people found it helpful.' sprintf=[$review.total_useful] mod='qlohotelreview'}</p>
|
||||
<p class="helpful-count"><span>{$review.total_useful|escape:'html':'UTF-8'}</span>{l s=' people found it helpful.' mod='qlohotelreview'}</p>
|
||||
</div>
|
||||
{if $logged && !$review.response_report}
|
||||
<div class="col-sm-6 text-right">
|
||||
|
||||
Reference in New Issue
Block a user