Add default categories and minor changes

This commit is contained in:
Abhishek Kumar
2022-12-13 15:38:11 +05:30
parent f0fe46a58c
commit 7da7bc5078
7 changed files with 52 additions and 21 deletions

View File

@@ -53,7 +53,7 @@ class QhrHotelReview extends ObjectModel
'id_order' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt', 'required' => true),
'rating' => array('type' => self::TYPE_FLOAT, 'validate' => 'isFloat'),
'subject' => array('type' => self::TYPE_STRING, 'validate' => 'isMessage', 'size' => 255, 'required' => true),
'description' => array('type' => self::TYPE_STRING, 'validate' => 'isMessage', 'size' => 65535, 'required' => true),
'description' => array('type' => self::TYPE_STRING, 'validate' => 'isMessage', 'size' => 65535),
'status_abusive' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'),
'status' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'),
'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate', 'copy_post' => false),

View File

@@ -96,6 +96,30 @@ class QhrHotelReviewDb
);
}
public static function saveDefaultCategories()
{
$categories = array('Food', 'Room Service');
$languages = Language::getLanguages();
foreach ($categories as $category) {
$objCategory = new QhrCategory();
$name = array();
foreach ($languages as $language) {
$name[$language['id_lang']] = $category;
}
$objCategory->name = $name;
$objCategory->active = 1;
if (!$objCategory->save()) {
return false;
}
}
return true;
}
public static function deleteTables()
{
return DB::getInstance()->execute(
@@ -115,7 +139,7 @@ class QhrHotelReviewDb
return array(
'QHR_ADMIN_APPROVAL_ENABLED' => 1,
'QHR_MAX_IMAGES_PER_REVIEW' => 5,
'QHR_REVIEWS_PER_PAGE' => 3,
'QHR_REVIEWS_PER_PAGE' => 5,
'QHR_REVIEW_APPROVAL_EMAIL_ENABLED' => 0,
'QHR_REVIEW_MGMT_REPLY_EMAIL_ENABLED' => 0,
);

View File

@@ -71,7 +71,7 @@ class AdminHotelReviewHotelReviewController extends ModuleAdminController
'hotel_name' => array(
'title' => $this->l('Hotel'),
'hint' => $this->l('Name of the hotel for which this review has been added.'),
'align' => 'center',
'align' => 'left',
'callback' => 'getHotelLink',
),
'rating' => array(
@@ -84,13 +84,13 @@ class AdminHotelReviewHotelReviewController extends ModuleAdminController
'subject' => array(
'title' => $this->l('Subject'),
'hint' => $this->l('Subject of the review.'),
'align' => 'center',
'align' => 'left',
'callback' => 'getSubject',
),
'customer_name' => array(
'title' => $this->l('Customer'),
'hint' => $this->l('Name of the customer who added this review.'),
'align' => 'center',
'align' => 'left',
'callback' => 'getCustomerLink',
'havingFilter' => true,
),

View File

@@ -66,9 +66,8 @@ class QloHotelReviewDefaultModuleFrontController extends ModuleFrontController
$errors['by_key']['subject'] = $objModule->l('This field is too long.', 'default');
}
if (!$description) {
$errors['by_key']['description'] = $objModule->l('Review description can not be empty.', 'default');
} elseif(!Validate::isMessage($description)) {
if(!Validate::isMessage($description)) {
$errors['by_key']['description'] = $objModule->l('Review description is invalid.', 'default');
} elseif(Tools::strlen($description) > 65535) {
$errors['by_key']['description'] = $objModule->l('This field is too long.', 'default');

View File

@@ -85,6 +85,11 @@ class QloHotelReview extends Module
return false;
}
}
if (!QhrHotelReviewDb::saveDefaultCategories()) {
return false;
}
return true;
}
@@ -280,7 +285,7 @@ class QloHotelReview extends Module
$tabs = array(
array('AdminParentHotelReview', 'Hotel Reviews', false, true),
array('AdminHotelReviewCategory', 'Configuration', 'AdminParentHotelReview', true),
array('AdminHotelReviewHotelReview', 'Manage Reviews', 'AdminHotelReservationSystemManagement', false),
array('AdminHotelReviewHotelReview', 'Reviews', 'AdminParentHotelReview', false),
);
foreach ($tabs as $tab) {

View File

@@ -17,4 +17,9 @@
* @license LICENSE.txt
*}
<span class="badge badge-danger">{$total_reports|escape:'html':'UTF-8'}</span>
{if $total_reports == 0}
--
{else}
<span class="badge badge-danger">{$total_reports|escape:'html':'UTF-8'}</span>
{/if}

View File

@@ -49,7 +49,7 @@
<div class="row">
<label class="control-label col-lg-3">{l s='Description' mod='qlohotelreview'}</label>
<div class="col-lg-9">
<p class="form-control-static rich-text">{$currentObject->description}</p>
<p class="form-control-static rich-text">{if !$currentObject->description|strlen}--{else}{$currentObject->description}{/if}</p>
</div>
</div>
@@ -60,18 +60,18 @@
{if $currentObject->rating|floatval < 2}
<span class="badge badge-danger">{$currentObject->rating|string_format:'%.1f'}</span>
{elseif $currentObject->rating|floatval < 3.5}
<span class="badge badge-danger">{$currentObject->rating|string_format:'%.1f'}</span>
<span class="badge badge-warning">{$currentObject->rating|string_format:'%.1f'}</span>
{else}
<span class="badge badge-danger">{$currentObject->rating|string_format:'%.1f'}</span>
<span class="badge badge-success">{$currentObject->rating|string_format:'%.1f'}</span>
{/if}
</p>
</div>
</div>
<div class="row">
<label class="control-label col-lg-3">{l s='Category Ratings' mod='qlohotelreview'}</label>
<div class="col-lg-9">
{if count($currentObject->category_ratings)}
{if count($currentObject->category_ratings)}
<div class="row">
<label class="control-label col-lg-3">{l s='Category Ratings' mod='qlohotelreview'}</label>
<div class="col-lg-9">
{foreach from=$currentObject->category_ratings item=category}
<div class="row">
<p class="form-control-static">
@@ -86,11 +86,9 @@
</p>
</div>
{/foreach}
{else}
<p class="form-control-static">{l s='No categories available.'}</p>
{/if}
</div>
</div>
</div>
{/if}
<div class="row">
<label class="control-label col-lg-3">{l s='Images' mod='qlohotelreview'}</label>