Merge branch 'develop' into gli-2908

This commit is contained in:
Amit sharma
2026-03-30 17:13:20 +05:30
42 changed files with 517 additions and 235 deletions

225
AGENTS.md Normal file
View File

@@ -0,0 +1,225 @@
# AGENTS.md
## Project Overview
QloApps is an open-source hotel reservation and property management platform. It enables hotels to manage rooms, bookings, guests, and payments through a web-based system.
## Purpose of this File
This document provides guidance for AI coding agents contributing to the QloApps project. It defines conventions, safety rules, and workflows to ensure consistent and secure code generation.
## Technology Stack
- **Language:** PHP 8.1–8.4 (backend), Smarty 3.x (templates), JavaScript/jQuery (frontend)
- **Database:** MySQL 5.7, 8.0+; MariaDB 10.5, 10.6, 10.11, 11.0, 11.2, 11.4
- **Architecture:** MVC with hook-based module system
- **License:** OSL-3.0 (core), AFL-3.0 (modules)
- **Required PHP Extensions:** PDO_MySQL, cURL, OpenSSL, SOAP, GD, SimpleXML, DOM, Zip, Phar
## Environment Setup
Install dependencies:
```bash
composer install
```
Clear caches:
```bash
rm -rf cache/smarty/compile/* cache/smarty/cache/*
rm -f cache/class_index.php
```
Clear class cache after adding or modifying overrides.
## Project Structure
```
.
├── classes/ # Core models extending ObjectModel
├── controllers/ # Front and admin controllers
│ ├── admin/
│ └── front/
├── modules/ # Feature modules with isolated functionality
├── override/ # Core class and controller overrides
├── themes/ # Smarty templates (.tpl files)
├── config/ # Configuration files (settings.inc.php contains secrets)
├── cache/ # Generated cache files
├── tests/ # PHPUnit test suite
```
**QloApps Agent Skills:** Install reusable development skills using:
```bash
npx skills add Qloapps/agent-skills
```
Available skills: module-development, payment-module-development, stats-module-development. Check installed skills before implementing new functionality.
## Architecture Overview
**MVC Pattern**
- Models: classes/ extending ObjectModel
- Controllers: FrontController or AdminController
- Views: Smarty templates (.tpl)
**Modules**
- Located in modules/<modulename>/
- Provide isolated functionality
- Integrate using hooks
**Overrides**
- Located in override/
- Extend core classes using the Core suffix
- Clear class cache after creating overrides
**Context**
- Access runtime objects using Context::getContext()
## Core vs Module Development Rules
**When working on a module:**
1. Never modify core files directly
2. Use **hooks** to integrate module functionality into core features
3. If no suitable hook exists, create a **custom hook** — but only if the hook placement is generic and useful for other modules too
4. Use **overrides** only as a last resort — overrides can conflict with other module override files and require manual resolution
**When working on a core feature:**
- Make changes directly in core files
- Do not use hooks or overrides for core-to-core changes
## Coding Conventions
**Classes:** PascalCase — `HotelBookingData`
**Methods:** camelCase — `getBookingDetails()`
**Variables:** camelCase — `$hotelId`
**Constants:** UPPER_SNAKE_CASE — `BOOKING_STATUS_CONFIRMED`
**Database Tables:** _DB_PREFIX_ + lowercase_snake — `qlo_hotel_booking`
**Config Keys:** MODULENAME_SETTING — `HOTELRESERVATION_ENABLED`
**Files:** One class per file, filename matches class name
**Templates:** lowercase-hyphens.tpl — `booking-form.tpl`
Add PHPDoc blocks to all classes and methods.
## Translation
Never hardcode user-facing English strings — always wrap them in the appropriate translation method.
| Context | Method |
|---------|--------|
| Module main file | `$this->l('string')` |
| Module admin controller | `$this->l('string')` |
| Module front controller | `$this->module->l('string', 'controllerName')` |
| Module classes | `$objModule->l('string', 'ClassName')` |
| Core admin controller | `$this->l('string')` |
| Core front controller | `Tools::displayError('string')` |
| Smarty template (core) | `{l s='string'}` |
| Smarty template (module) | `{l s='string' mod='modulename'}` |
## Multi-language
- Always include `id_lang` in queries that return translatable content
- Use `Context::getContext()->language->id` for the current language
## Module Development Guidelines
**Module Location:** modules/<modulename>/
**Required Files:**
- <modulename>.php — Main class extending Module
- config.xml — Module metadata
**Optional Directories:**
- classes/ — Module-specific models
- controllers/ — Module controllers
- views/templates/ — Smarty templates
- upgrade/ — Version migration scripts
**Hook Integration:**
- Register hooks in install() method
- Unregister hooks in uninstall() method
- Keep hook handlers lightweight
**Configuration:**
- Store settings using Configuration::updateValue()
- Retrieve settings using Configuration::get()
- Prefix config keys with module name
## Database Rules
**Table Prefix:** Always use _DB_PREFIX_ constant instead of hardcoding the table prefix
**Escaping:**
- Strings: pSQL($value)
- Integers: (int)$value
- Table/column names: bqSQL($name)
**Preferred Access:** Use ObjectModel for CRUD operations instead of raw SQL queries
**Prohibited:** Never concatenate raw user input into SQL queries.
## Security Guidelines
**Input Handling**
- Use Tools::getValue() for request parameters
- Cast numeric values to (int)
- Escape strings using pSQL()
- Validate input using Validate class methods
**Output Escaping**
- Use Tools::safeOutput() in PHP
- Use Smarty escape modifiers in templates
**Sensitive Data**
- Never expose config/settings.inc.php
- Never commit API keys, passwords, or tokens
**Authorization**
- Verify permissions before performing admin operations
## Testing
Testing infrastructure is being configured. Check tests/ directory for available tests before running.
## AI Agent Workflow
1. Check installed agent skills before implementing new functionality
2. Search codebase for similar implementations before creating new code
3. Extend existing classes rather than duplicating functionality
4. Follow patterns established in surrounding code
5. Reuse existing utilities: Tools, Validate, Db, Configuration classes
6. Prioritize consistency with existing codebase over new approaches
After making changes:
- Clear caches if modifying templates or overrides
- Add PHPDoc to new methods
## Safety Rules
**Agents must not:**
- Delete files unless explicitly instructed
- Run git commands automatically
- Modify composer.json without approval
- Modify config/settings.inc.php
- Execute DROP, TRUNCATE, or destructive SQL
- Modify core files directly when working on a module (use hooks or override system)
**Agents must:**
- Use pSQL() for strings and (int) for IDs in SQL
- Use Tools::getValue() for request parameters
- Escape all output
- Check installed agent skills before implementing new functionality
- Follow project naming conventions
- Validate inputs before processing
**Agents should ask before:**
- Deleting any files
- Running git commands
- Changing dependencies
- Modifying database schema
- Altering payment or booking logic
---
**Resources:**
- Documentation: https://docs.qloapps.com
- Forum: https://forums.qloapps.com
- GitHub: https://github.com/Qloapps/QloApps
- Security Issues: support@qloapps.com

View File

@@ -60,7 +60,7 @@
<li>
<a id="desc-module-back" class="toolbar_btn" href="javascript: window.history.back();" title="{l s='Back'}">
<i class="process-icon-back"></i>
<div>{l s='Back'}</div>
<span>{l s='Back'}</span>
</a>
</li>
<!-- <li>
@@ -85,7 +85,7 @@
<li>
<a id="desc-module-translate" data-toggle="modal" data-target="#moduleTradLangSelect" class="toolbar_btn" href="#" title="{l s='Translate'}">
<i class="process-icon-flag"></i>
<div>{l s='Translate'}</div>
<span>{l s='Translate'}</span>
</a>
</li>
{/if}
@@ -100,7 +100,7 @@
<li>
<a id="desc-module-hook" class="toolbar_btn" href="{$module_hook_link}" title="{l s='Manage hooks'}">
<i class="process-icon-anchor"></i>
<div>{l s='Manage hooks'}</div>
<span>{l s='Manage hooks'}</span>
</a>
</li>
</ul>

View File

@@ -638,7 +638,7 @@
html += '</select>';
html += '</td>';
html += '<td class="col-sm-3 center">';
html += '<input class="form-control" type="text" name="'+prefix+'[floor]">';
html += '<input class="form-control" type="text" name="'+prefix+'[comment]">';
html += '</td>';
html += '<td class="center col-sm-2">';
html += '<a class="btn btn-default deactiveDatesModal disabled" data-toggle="modal" data-target="#deactiveDatesModal">';

View File

@@ -104,7 +104,7 @@
<div class="col-lg-1"><span class="pull-right">{include file="controllers/products/multishop/checkbox.tpl" field="name" type="default" multilang="true"}</span></div>
<label class="control-label col-lg-2 required" id="name" for="name_{$id_lang}">
<span class="label-tooltip" data-toggle="tooltip" title="{l s='Write the name of the Room Type for ex. Delux, Executive etc.'} {l s='Invalid characters:'} &lt;&gt;;=#{}">
{l s='Room Type'}
{l s='Name'}
</span>
</label>
<div class="col-lg-5">
@@ -137,12 +137,16 @@
{l s='Select Hotel'}
</label>
<div class="col-sm-5">
{if isset($htl_info) && $htl_info}
<select name="id_hotel" id="hotel_place" class="form-control chosen">
{foreach from=$htl_info item=htl_dtl}
<option value="{$htl_dtl['id']}" >{$htl_dtl['hotel_name']}</option>
<option value="{$htl_dtl['id_hotel']}" >{$htl_dtl['hotel_name']}</option>
{/foreach}
</select>
<p class="help-block">{l s='Hotel once assigned cannot be reassigned'}</p>
{else}
<div class="control-label col-sm-3 text-danger">{l s='No hotel are available'}</div>
{/if}
</div>
{/if}
</div>

View File

@@ -123,7 +123,7 @@
function startTree(idElem) {
if (typeof $.fn.tree === 'undefined') {
setTimeout(startTree, 100);
setTimeout(function() { startTree(idElem); }, 100);
return;
}

View File

@@ -41,7 +41,7 @@
{if $action.type == 'link'}
<a href="{$action.href}" class="btn {$action.class}">{$action.label}</a>
{elseif $action.type == 'button'}
<button type="button" value="{$action.value}" class="btn {$action.class}">
<button type="button" value="{$action.value|default:''}" class="btn {$action.class}">
{$action.label}
</button>
{/if}

View File

@@ -332,6 +332,14 @@ class CookieCore
$this->logout();
}
if (isset($this->_content['id_customer']) && isset($this->_content['passwd']) && (int)$this->_content['id_customer']) {
if (Validate::isLoadedObject($objCustomer = new Customer((int)$this->_content['id_customer']))) {
if ($objCustomer->passwd != $this->_content['passwd']) {
$this->logout();
}
}
}
if (!isset($this->_content['date_add'])) {
$this->_content['date_add'] = date('Y-m-d H:i:s');
}

View File

@@ -67,5 +67,6 @@ class SearchEngineCore extends ObjectModel
return $str;
}
}
return '';
}
}

View File

@@ -875,9 +875,13 @@ class AdminControllerCore extends Controller
$prefix = $this->getCookieFilterPrefix();
$filters = array();
if (isset($this->list_id)) {
$postPrefixPattern = '#^('.
$this->list_id.'Filter_|'.
'submitFilter'.
')#i';
foreach ($_POST as $key => $value) {
// only process the filter fields.
if (stripos($key, $this->list_id.'Filter_') !== 0) {
if (!preg_match($postPrefixPattern, $key)) {
continue;
}
@@ -898,9 +902,15 @@ class AdminControllerCore extends Controller
}
}
$getPrefixPattern = '#^(' .
'submitFilter|'.
$this->list_id.'Filter_|'.
$this->list_id.'Orderby|'.
$this->list_id.'Orderway'.
')#i';
foreach ($_GET as $key => $value) {
// only process the filter fields.
if (stripos($key, $this->list_id.'Filter_') !== 0) {
// only process the filter and order by, order way fields.
if (!preg_match($getPrefixPattern, $key)) {
continue;
}
@@ -2387,7 +2397,7 @@ class AdminControllerCore extends Controller
$must_have_module_list = file_get_contents(_PS_ROOT_DIR_.Module::CACHE_FILE_MUST_HAVE_MODULES_LIST);
if (!empty($must_have_module_list) && $must_have_module_list_xml = @simplexml_load_string($must_have_module_list)) {
$must_have_module_list_array = array();
if (is_object($country_module_list_xml->module)) {
if (is_object($must_have_module_list_xml->module)) {
foreach ($must_have_module_list_xml->module as $l => $mo) {
$all_module_list[] = (string)$mo->name;
}

View File

@@ -3019,7 +3019,7 @@ abstract class ModuleCore
),
array(
' ',
'class '.$overrideClassName.'OverrideOriginal'.$uniq
'class '.$overrideClassName.'OverrideOriginal'.$uniq.' extends \stdClass'
),
implode('', $overrideClassFileArray)
)
@@ -3037,7 +3037,7 @@ abstract class ModuleCore
),
array(
' ',
'class '.$overrideClassName.'Override'.$uniq
'class '.$overrideClassName.'Override'.$uniq.' extends \stdClass'
),
implode('', $moduleClassFileArray)
)
@@ -3084,7 +3084,7 @@ abstract class ModuleCore
),
array(
' ',
'class '.$overrideClassName.'Override'.$uniq
'class '.$overrideClassName.'Override'.$uniq.' extends \stdClass'
),
implode('', $moduleClassFileArray)
)
@@ -3213,7 +3213,7 @@ abstract class ModuleCore
),
array(
' ',
'class '.$overrideClassName.'Original_remove'.$uniq
'class '.$overrideClassName.'Original_remove'.$uniq.' extends \stdClass'
),
implode('', $overrideClassFileArray)
)
@@ -3230,7 +3230,7 @@ abstract class ModuleCore
),
array(
' ',
'class '.$overrideClassName.'Override_remove'.$uniq
'class '.$overrideClassName.'Override_remove'.$uniq.' extends \stdClass'
),
implode('', $moduleClassFileArray)
)

View File

@@ -28,6 +28,9 @@ abstract class ModuleGraphCore extends Module
{
protected $_employee;
/** @var string CSV data */
protected $_csv;
/** @var array of integers graph data */
protected $_values = array();

View File

@@ -159,12 +159,13 @@ abstract class ModuleGridCore extends Module
$this->setLang($context->language->id);
$this->setEmployee($context->employee->id);
$layers = isset($datas['layers']) ? $datas['layers'] : 1;
if (isset($datas['option'])) {
$this->setOption($datas['option'], $layers);
}
$this->getData();
$layers = isset($datas['layers']) ? $datas['layers'] : 1;
if (count($datas['columns'])) {
foreach ($datas['columns'] as $column) {

View File

@@ -277,7 +277,7 @@ class OrderSlipCore extends ObjectModel
FROM `'._DB_PREFIX_.'order_slip` os
LEFT JOIN `'._DB_PREFIX_.'orders` o ON (o.`id_order` = os.`id_order`)
WHERE os.`date_add` BETWEEN \''.pSQL($dateFrom).' 00:00:00\' AND \''.pSQL($dateTo).' 23:59:59\'
'.Shop::addSqlRestriction(Shop::SHARE_ORDER, 'o').'
'.Shop::addSqlRestriction(Shop::SHARE_ORDER, 'o'). ' ' .HotelBranchInformation::addHotelRestriction(false).'
ORDER BY os.`date_add` ASC');
$slips = array();

View File

@@ -1262,6 +1262,13 @@ class AdminModulesControllerCore extends AdminController
if (Configuration::get('PS_SHOW_CAT_MODULES_'.(int)$this->id_employee)) {
$filter_categories = explode('|', Configuration::get('PS_SHOW_CAT_MODULES_'.(int)$this->id_employee));
}
if (count($filter_categories) > 0) {
foreach ($filter_categories as $fc) {
if (!empty($fc)) {
$category_filtered[$fc] = 1;
}
}
}
if (count($category_filtered) > 0 && !isset($category_filtered[$module->tab])) {
return true;
}

View File

@@ -2605,6 +2605,7 @@ class AdminNormalProductsControllerCore extends AdminController
->setSelectedCategories(array((int)$id_category));
$this->tpl_list_vars['category_tree'] = $tree->render();
$this->context->smarty->assign('token', $this->token);// as tree updates the token from the smarty context
// used to build the new url when changing category
$this->tpl_list_vars['base_url'] = preg_replace('#&id_category=[0-9]*#', '', self::$currentIndex).'&token='.$this->token;
}
@@ -4513,7 +4514,7 @@ class AdminNormalProductsControllerCore extends AdminController
if ($this->tabAccess['edit'] === 1) {
$way = (int)(Tools::getValue('way'));
$id_product = (int)Tools::getValue('id_product');
$id_category = (int)Tools::getValue('id_category');
$id_category = (int)Tools::getValue('id_category_hotel');
$positions = Tools::getValue('product');
$page = (int)Tools::getValue('page');
$selected_pagination = (int)Tools::getValue('selected_pagination');
@@ -4521,14 +4522,13 @@ class AdminNormalProductsControllerCore extends AdminController
if (is_array($positions)) {
foreach ($positions as $position => $value) {
$pos = explode('_', $value);
if ((isset($pos[1]) && isset($pos[2])) && ($pos[1] == $id_category && (int)$pos[2] === $id_product)) {
if ($page > 1) {
$position = $position + (($page - 1) * $selected_pagination);
}
if ($product = new Product((int)$pos[2])) {
if (isset($position) && $product->updatePosition($way, $position)) {
if (isset($position) && $product->updatePosition($way, $position, $id_category)) {
$category = new Category((int)$id_category);
if (Validate::isLoadedObject($category)) {
hook::Exec('categoryUpdate', array('category' => $category));

View File

@@ -368,6 +368,54 @@ class AdminOrdersControllerCore extends AdminController
'icon' => 'process-icon-new'
);
}
if ($this->display == 'view') {
/** @var Order $order */
if (Validate::isLoadedObject($order = $this->loadObject())) {
// hotel link in header
if ($idHotel = HotelBookingDetail::getIdHotelByIdOrder($order->id)) {
$this->page_header_toolbar_btn['hotel'] = array(
'href' => $this->context->link->getAdminLink('AdminAddHotel').'&id='.$idHotel.'&updatehtl_branch_info',
'desc' => $this->l('View Hotel'),
'class' => 'icon-building',
'target' => true,
);
}
if (Configuration::get('PS_INVOICE') && $order->hasInvoice() && !$this->lite_display) {
$this->page_header_toolbar_btn['file'] = array(
'short' => $this->l('Invoice'),
'href' => $this->context->link->getAdminLink('AdminPdf').'&submitAction=generateInvoicePDF&id_order='.$order->id,
'desc' => $this->l('View invoice'),
'class' => 'icon-file-text',
'target' => true,
);
}
$this->page_header_toolbar_btn['print'] = array(
'short' => $this->l('Print'),
'href' => 'javascript:window.print()',
'desc' => $this->l('Print order'),
'class' => 'icon-print',
);
if ($this->tabAccess['edit'] === 1) {
if (((int) $order->isReturnable())
&& !$order->hasCompletelyRefunded(Order::ORDER_COMPLETE_CANCELLATION_OR_REFUND_REQUEST_FLAG, 0, 0)
) {
$orderTotalPaid = $order->getTotalPaid();
$orderDiscounts = $order->getCartRules();
$hasOrderDiscountOrPayment = ((float)$orderTotalPaid > 0 || $orderDiscounts) ? true : false;
$this->page_header_toolbar_btn['cancel'] = array(
'short' => ($hasOrderDiscountOrPayment) ? $this->l('Refund') : $this->l('Cancel'),
'id' => 'desc-order-standard_refund',
'desc' => ($hasOrderDiscountOrPayment) ? $this->l('Initiate refund') : $this->l('Cancel bookings'),
'class' => 'icon-exchange',
'target' => true,
);
}
}
}
}
parent::initPageHeaderToolbar();
}
@@ -476,55 +524,6 @@ class AdminOrdersControllerCore extends AdminController
public function initToolbar()
{
if ($this->display == 'view') {
/** @var Order $order */
if (Validate::isLoadedObject($order = $this->loadObject())) {
// hotel link in header
if ($idHotel = HotelBookingDetail::getIdHotelByIdOrder($order->id)) {
$this->toolbar_btn['hotel'] = array(
'href' => $this->context->link->getAdminLink('AdminAddHotel').'&id='.$idHotel.'&updatehtl_branch_info',
'desc' => $this->l('View Hotel'),
'class' => 'icon-building',
'target' => true,
);
}
if (Configuration::get('PS_INVOICE') && $order->hasInvoice() && !$this->lite_display) {
$this->toolbar_btn['file'] = array(
'short' => $this->l('Invoice'),
'href' => $this->context->link->getAdminLink('AdminPdf').'&submitAction=generateInvoicePDF&id_order='.$order->id,
'desc' => $this->l('View invoice'),
'class' => 'icon-file-text',
'target' => true,
);
}
$this->toolbar_btn['print'] = array(
'short' => $this->l('Print'),
'href' => 'javascript:window.print()',
'desc' => $this->l('Print order'),
'class' => 'icon-print',
);
if ($this->tabAccess['edit'] === 1) {
if (((int) $order->isReturnable())
&& !$order->hasCompletelyRefunded(Order::ORDER_COMPLETE_CANCELLATION_OR_REFUND_REQUEST_FLAG, 0, 0)
) {
$orderTotalPaid = $order->getTotalPaid();
$orderDiscounts = $order->getCartRules();
$hasOrderDiscountOrPayment = ((float)$orderTotalPaid > 0 || $orderDiscounts) ? true : false;
$this->toolbar_btn['cancel'] = array(
'short' => ($hasOrderDiscountOrPayment) ? $this->l('Refund') : $this->l('Cancel'),
'id' => 'desc-order-standard_refund',
'desc' => ($hasOrderDiscountOrPayment) ? $this->l('Initiate refund') : $this->l('Cancel bookings'),
'class' => 'icon-exchange',
'target' => true,
);
}
}
}
}
$res = parent::initToolbar();
if (Context::getContext()->shop->getContext() != Shop::CONTEXT_SHOP && isset($this->toolbar_btn['new']) && Shop::isFeatureActive()) {
unset($this->toolbar_btn['new']);
@@ -3710,6 +3709,7 @@ class AdminOrdersControllerCore extends AdminController
'ROOM_STATUS_CHECKED_OUT' => HotelBookingDetail::STATUS_CHECKED_OUT,
'ALLOTMENT_MANUAL' => HotelBookingDetail::ALLOTMENT_MANUAL,
'order_convenience_fee_services' => $orderConvenienceFeeServices,
'page_header_toolbar_btn' => $this->page_header_toolbar_btn,
);
return parent::renderView();

View File

@@ -3064,7 +3064,7 @@ class AdminProductsControllerCore extends AdminController
if ($obj->id) {
if ($this->product_exists_in_shop) {
$objHotelInfo = new HotelBranchInformation();
$hotelInfo = $objHotelInfo->hotelsNameAndId();
$hotelInfo = HotelBranchInformation::getProfileAccessedHotels($this->context->employee->id_profile, 1);
if ($hotelInfo) {
$objRoomInfo = new HotelRoomInformation();
$roomStatus = $objRoomInfo->getAllRoomStatus();
@@ -3111,7 +3111,7 @@ class AdminProductsControllerCore extends AdminController
$this->displayWarning($this->l('You must save the room type in this shop before managing hotel configuration.'));
}
} else {
$this->displayWarning($this->l('You must save this room type before managing hotel configuration.'));
$this->displayWarning($this->l('You must save this room type before managing rooms.'));
}
$this->tpl_form_vars['custom_form'] = $data->fetch();
@@ -4527,7 +4527,7 @@ class AdminProductsControllerCore extends AdminController
$objRoomType = new HotelRoomType();
$objHotelInfo = new HotelBranchInformation();
$data->assign('htl_info', $objHotelInfo->hotelsNameAndId());
$data->assign('htl_info', HotelBranchInformation::getProfileAccessedHotels($this->context->employee->id_profile, 1));
if ($hotelRoomType = $objRoomType->getRoomTypeInfoByIdProduct($product->id)) {
$data->assign('htl_room_type', $hotelRoomType);
$hotelFullInfo = $objHotelInfo->hotelBranchInfoById($hotelRoomType['id_hotel']);

View File

@@ -38,6 +38,8 @@ class AdminSlipControllerCore extends AdminController
$this->_select = ' o.`id_shop`';
$this->_join .= ' LEFT JOIN '._DB_PREFIX_.'orders o ON (o.`id_order` = a.`id_order`)';
$this->_join .= ' INNER JOIN '._DB_PREFIX_.'htl_booking_detail hbd
ON (a.`id_order` = hbd.`id_order`) ' . HotelBranchInformation::addHotelRestriction(false, 'hbd');
$this->_group = ' GROUP BY a.`id_order_slip`';
$this->addRowAction('statusChange');

View File

@@ -714,8 +714,11 @@ class AdminThemesControllerCore extends AdminController
}
$ids_themes = Tools::unSerialize(Configuration::get('PS_ADDONS_THEMES_IDS'));
if (array_key_exists($obj->directory, $ids_themes)) {
unset($ids_themes[$obj->directory]);
if(is_array($ids_themes)) {
if (array_key_exists($obj->directory, $ids_themes)) {
unset($ids_themes[$obj->directory]);
}
}
$obj->removeMetas();
@@ -1358,8 +1361,8 @@ class AdminThemesControllerCore extends AdminController
$fields_value['theme_name'] = $theme->name;
$fields_value['theme_directory'] = $theme->directory;
$fields_value['theme_version'] = '1.0';
$fields_value['compa_from'] = _PS_VERSION_;
$fields_value['compa_to'] = _PS_VERSION_;
$fields_value['compa_from'] = _QLOAPPS_VERSION_;
$fields_value['compa_to'] = _QLOAPPS_VERSION_;
$fields_value['id_theme_export'] = Tools::getValue('id_theme_export');
$fields_value['documentationName'] = $this->l('documentation');

View File

@@ -7,7 +7,6 @@
<tr>
<th>{l s="Room Image"}</th>
<th>{l s="Room Description"}</th>
<th>{l s="Hotel"}</th>
<th>{l s="Room Capcity"}</th>
<th>{l s="Unit Price"}</th>
<th>{l s="Rooms Qty"}</th>
@@ -25,9 +24,6 @@
<td >
{$data_v['name']}
</td>
<td >
{$data_v['hotel_name']}
</td>
<td >
{$rm_v['adults']} {l s='Adults'}, {$rm_v['children']} {l s='Children'}
</td>

View File

@@ -730,50 +730,56 @@ class HotelBranchInformation extends ObjectModel
$catName,
$parent_category
)) {
if (is_array($link_rewrite)) {
$objCategory = new Category($categoryExists['id_category']);
foreach (Language::getLanguages() as $lang) {
$objCategory->link_rewrite[$lang['id_lang']] = $link_rewrite[$lang['id_lang']];
}
$objCategory->save();
}
return $categoryExists['id_category'];
} else {
$category = new Category();
foreach (Language::getLanguages(true) as $lang) {
if (is_array($name) && isset($name[$lang['id_lang']])) {
$catName = $name[$lang['id_lang']];
} else {
$catName = $name;
}
$category->name[$lang['id_lang']] = $catName;
$category->description[$lang['id_lang']] = $this->moduleInstance->l('Hotel Branch Category', 'HotelBranchInformation');
$idHotel = isset($params['id_hotel']) ? $params['id_hotel'] : false;
$isHotel = isset($params['is_hotel']) ? $params['is_hotel'] : false;
$existsCatId = $categoryExists['id_category'];
$belongsToSameHotel = ($idHotel == HotelBranchInformation::getHotelIdByIdCategory($existsCatId));
if (!$isHotel || $belongsToSameHotel) {
if (is_array($link_rewrite)) {
$category->link_rewrite[$lang['id_lang']] = $link_rewrite[$lang['id_lang']];
} else {
$category->link_rewrite[$lang['id_lang']] = Tools::link_rewrite($catName);
$objCategory = new Category($existsCatId);
foreach (Language::getLanguages() as $lang) {
$objCategory->link_rewrite[$lang['id_lang']] = $link_rewrite[$lang['id_lang']];
}
$objCategory->save();
}
return $existsCatId;
}
if ($meta_title) {
$category->meta_title = $meta_title;
}
if ($meta_description) {
$category->meta_description = $meta_description;
}
if ($meta_keywords) {
$category->meta_keywords = $meta_keywords;
}
$category->id_parent = $parent_category;
$category->groupBox = $group_ids;
$category->add();
return $category->id;
}
$category = new Category();
foreach (Language::getLanguages(true) as $lang) {
if (is_array($name) && isset($name[$lang['id_lang']])) {
$catName = $name[$lang['id_lang']];
} else {
$catName = $name;
}
$category->name[$lang['id_lang']] = $catName;
$category->description[$lang['id_lang']] = $this->moduleInstance->l('Hotel Branch Category', 'HotelBranchInformation');
if (is_array($link_rewrite)) {
$category->link_rewrite[$lang['id_lang']] = $link_rewrite[$lang['id_lang']];
} else {
$category->link_rewrite[$lang['id_lang']] = Tools::link_rewrite($catName);
}
}
if ($meta_title) {
$category->meta_title = $meta_title;
}
if ($meta_description) {
$category->meta_description = $meta_description;
}
if ($meta_keywords) {
$category->meta_keywords = $meta_keywords;
}
$category->id_parent = $parent_category;
$category->groupBox = $group_ids;
$category->add();
return $category->id;
}
//Overrided ObjectModet::delete() to delete all the dependencies of the hotel

View File

@@ -907,6 +907,7 @@ class AdminAddHotelController extends ModuleAdminController
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 @@ class AdminAddHotelController extends ModuleAdminController
$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 @@ class AdminAddHotelController extends ModuleAdminController
$objHtlImage->save();
}
}
die(true);
$response['status'] = true;
}
}
}
}
die(false);
$this->ajaxDie(json_encode($response));
}
public function ajaxProcessUpdateSlidesPosition()

View File

@@ -1024,6 +1024,8 @@ class AdminHotelRoomsBookingController extends ModuleAdminController
'no_realloc_rm_type_avail_txt' => $this->l('No room type available for reallocation.', null, true),
'no_swap_rm_avail_txt' => $this->l('No room available for swap.', null, true),
'select_room_txt' => $this->l('Select room', null, true),
'added_room_success_txt' => $this->l('Room added to cart successfully', null, true),
'removed_room_success_txt' => $this->l('Room removed from cart successfully', null, true),
);
if (Configuration::get('PS_BACKOFFICE_SEARCH_TYPE') == HotelBookingDetail::SEARCH_TYPE_OWS ) {
$jsVars['is_occupancy_wise_search'] = true;

View File

@@ -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({

View File

@@ -386,6 +386,7 @@ $(document).ready(function() {
if (result.success) {
$(".cart_booking_btn").removeAttr('disabled');
$current_btn.removeAttr('disabled');
showSuccessMessage(added_room_success_txt);
}
btn.removeClass('btn-primary').removeClass('avai_add_cart').addClass('btn-danger').addClass('avai_delete_cart_data').html(remove);
@@ -512,6 +513,7 @@ $(document).ready(function() {
if (!result.success) {
$(".cart_booking_btn").attr('disabled', 'true');
} else {
showSuccessMessage(removed_room_success_txt);
$("#htl_rooms_list").empty().append(result.data.room_tpl);
refreshCartData();
refreshStatsData();
@@ -571,7 +573,7 @@ $(document).ready(function() {
if (!(result.success)) {
$(".cart_booking_btn").attr('disabled', 'true');
}
showSuccessMessage(removed_room_success_txt);
$(".cart_tbody tr td button[data-id-cart-book-data='" + id_cart_book_data + "']").parent().parent().remove();
refreshCartData();
refreshStatsData();

View File

@@ -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 {

View File

@@ -261,7 +261,7 @@
{/if}
<td>{HotelRoomInformation::getRoomStatusTitle($unavail_dtl_v['id_status'])|escape:'htmlall':'UTF-8'}</td>
<td>
{if $unavail_dtl_v['date_from'] && $unavail_dtl_v['date_to']}
{if isset($unavail_dtl_v['date_from']) && isset($unavail_dtl_v['date_to'])}
{dateFormat date=$unavail_dtl_v['date_from']} - {dateFormat date=$unavail_dtl_v['date_to']}
{else}
--

View File

@@ -65,7 +65,7 @@ class WkPaypalCommerceHelper
if ($err) {
throw new PrestaShopException(sprintf('cURL Error #: %s', $err));
} else {
$accessToken = Tools::jsonDecode($response, true);
$accessToken = json_decode($response, true);
if (isset($accessToken['error']) && !empty($accessToken['error'])) {
$apiResp['success'] = false;
$apiResp['message'] = $accessToken['error_description'];
@@ -83,12 +83,12 @@ class WkPaypalCommerceHelper
$temp = array(
"alg" => "none"
);
$returnData = base64_encode(Tools::jsonEncode($temp)) . '.';
$returnData = base64_encode(json_encode($temp)) . '.';
$temp = array(
"iss" => trim(Configuration::get('WK_PAYPAL_COMMERCE_CLIENT_ID')),
"payer_id" => Configuration::get('WK_PAYPAL_COMMERCE_MERCHANT_ID')
);
$returnData .= base64_encode(Tools::jsonEncode($temp)) . '.';
$returnData .= base64_encode(json_encode($temp)) . '.';
return $returnData;
}
@@ -145,7 +145,7 @@ class WkPaypalCommerceHelper
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => Tools::jsonEncode($postData),
CURLOPT_POSTFIELDS => json_encode($postData),
CURLOPT_HTTPHEADER => array(
"PayPal-Partner-Attribution-Id: " . PayPalHelper::WK_PAYPAL_COMMERCE_ATTRIBUTION_ID,
"authorization: Bearer " . $token,
@@ -161,7 +161,7 @@ class WkPaypalCommerceHelper
if ($err) {
throw new PrestaShopException(sprintf('cURL Error #: %s', $err));
} else {
$webhookResponse = Tools::jsonDecode($response, true);
$webhookResponse = json_decode($response, true);
if (isset($webhookResponse['id']) && !empty($webhookResponse['id'])) {
$apiResp['success'] = true;
$apiResp['webhook_id'] = $webhookResponse['id'];
@@ -243,7 +243,7 @@ class WkPaypalCommerceHelper
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => Tools::jsonEncode($postData),
CURLOPT_POSTFIELDS => json_encode($postData),
CURLOPT_HTTPHEADER => array(
"PayPal-Partner-Attribution-Id: " . PayPalHelper::WK_PAYPAL_COMMERCE_ATTRIBUTION_ID,
"authorization: Bearer " . $accessToken['access_token'],
@@ -260,7 +260,7 @@ class WkPaypalCommerceHelper
if ($err) {
throw new PrestaShopException(sprintf('cURL Error #: %s', $err));
} else {
$apiResp = Tools::jsonDecode($response, true);
$apiResp = json_decode($response, true);
}
}
return $apiResp;

View File

@@ -52,7 +52,7 @@ class WkPaypalCommerceWebhook
if (isset($eventData['resource']['note_to_payer'])) {
$refundObj->refund_reason = $eventData['resource']['note_to_payer'];
}
$refundObj->response = Tools::jsonEncode($eventData);
$refundObj->response = json_encode($eventData);
$refundObj->refund_status = $eventData['resource']['status'];
$refundObj->save();
}
@@ -188,7 +188,7 @@ class WkPaypalCommerceWebhook
return Db::getInstance()->execute(
'UPDATE `'._DB_PREFIX_.'wk_paypal_commerce_order`
SET `pp_payment_status` = "'.pSQL($payment_status).'",
`response` = "'.pSQL(Tools::jsonEncode($orderData)).'"
`response` = "'.pSQL(json_encode($orderData)).'"
WHERE `pp_transaction_id` = "'.pSQL($transaction_id).'"
'
);

View File

@@ -137,39 +137,46 @@ class AdminPaypalCommerceTransactionController extends ModuleAdminController
$smartyVars = array();
$refundData = array();
$totalRefunded = 0;
$transactionData = WKPayPalCommerceOrder::getTransactionDetails((int)$idTrans);
$orderCurrency = new Currency((int)$transactionData['id_currency']);
$refundData = WkPaypalCommerceRefund::getRefundListByTransID((int)$idTrans);
$totalRefundedFormatted = WkPaypalCommerceRefund::getTotalRefundedAmount((int)$idTrans, true);
if ($transactionData = WKPayPalCommerceOrder::getTransactionDetails((int)$idTrans)) {
$orderCurrency = new Currency((int)$transactionData['id_currency']);
$refundData = WkPaypalCommerceRefund::getRefundListByTransID((int)$idTrans);
$totalRefundedFormatted = WkPaypalCommerceRefund::getTotalRefundedAmount((int)$idTrans, true);
$totalRefunded = WkPaypalCommerceRefund::getTotalRefundedAmount((int)$idTrans, false);
$remainingRefund = (float)($transactionData['pp_paid_total'] - $totalRefunded);
$response = Tools::jsonDecode($transactionData['response'], true);
$totalRefunded = WkPaypalCommerceRefund::getTotalRefundedAmount((int)$idTrans, false);
$remainingRefund = (float)($transactionData['pp_paid_total'] - $totalRefunded);
$response = Tools::jsonDecode($transactionData['response'], true);
// Buyer making a payment in a different currency (ex: EUR) which is different from the default currency of merchant (Ex: USD), In all those cross currency cases, After Capture, transaction will fall into Pending state and will require merchant to manually go to his PayPal account and accept the payment.
$objPPOrder = new WKPayPalCommerceOrder();
if (isset($response['data']['purchase_units'][0]['payments']['captures'][0]['status_details']['reason'])
&& ($transactionData['pp_payment_status'] == 'PENDING' || $transactionData['pp_payment_status'] == 'DENIED')
&& isset($response['data']['purchase_units'][0]['payments']['captures'][0]['status_details']['reason'])
) {
if (isset($objPPOrder->ppStatusDetail[$response['data']['purchase_units'][0]['payments']['captures'][0]['status_details']['reason']])) {
$smartyVars['ppstatusDetailMsg'] = $objPPOrder->ppStatusDetail[$response['data']['purchase_units'][0]['payments']['captures'][0]['status_details']['reason']];
// Buyer making a payment in a different currency (ex: EUR) which is different from the default currency of merchant (Ex: USD), In all those cross currency cases, After Capture, transaction will fall into Pending state and will require merchant to manually go to his PayPal account and accept the payment.
$objPPOrder = new WKPayPalCommerceOrder();
if (
isset($response['data']['purchase_units'][0]['payments']['captures'][0]['status_details']['reason'])
&& ($transactionData['pp_payment_status'] == 'PENDING' || $transactionData['pp_payment_status'] == 'DENIED')
&& isset($response['data']['purchase_units'][0]['payments']['captures'][0]['status_details']['reason'])
) {
if (isset($objPPOrder->ppStatusDetail[$response['data']['purchase_units'][0]['payments']['captures'][0]['status_details']['reason']])) {
$smartyVars['ppstatusDetailMsg'] = $objPPOrder->ppStatusDetail[$response['data']['purchase_units'][0]['payments']['captures'][0]['status_details']['reason']];
}
}
$smartyVars['transaction_url'] = $this->context->link->getAdminLink('AdminPaypalCommerceTransaction',Tools::getAdminTokenLite('AdminPaypalCommerceTransaction')).'&viewwk_paypal_commerce_order&id_paypal_commerce_order=' . (int)$idTrans;
$smartyVars['transaction_data'] = $transactionData;
$smartyVars['refund_data'] = $refundData;
$smartyVars['refunded_amount'] = $totalRefundedFormatted;
$smartyVars['remaining_refund'] = $remainingRefund;
$smartyVars['remaining_refund_format'] = Tools::displayPrice($remainingRefund, $orderCurrency);
$smartyVars['currency'] = $orderCurrency;
$smartyVars['WK_PAYPAL_COMMERCE_REFUND_TYPE_FULL'] = WkPaypalCommerceRefund::WK_PAYPAL_COMMERCE_REFUND_TYPE_FULL;
$smartyVars['WK_PAYPAL_COMMERCE_REFUND_TYPE_PARTIAL'] = WkPaypalCommerceRefund::WK_PAYPAL_COMMERCE_REFUND_TYPE_PARTIAL;
$this->context->smarty->assign($smartyVars);
$this->base_tpl_view = 'view.tpl';
return parent::renderView();
} else {
Tools::redirectAdmin(self::$currentIndex . '&token=' . $this->token);
}
$smartyVars['transaction_data'] = $transactionData;
$smartyVars['refund_data'] = $refundData;
$smartyVars['refunded_amount'] = $totalRefundedFormatted;
$smartyVars['remaining_refund'] = $remainingRefund;
$smartyVars['remaining_refund_format'] = Tools::displayPrice($remainingRefund, $orderCurrency);
$smartyVars['currency'] = $orderCurrency;
$smartyVars['WK_PAYPAL_COMMERCE_REFUND_TYPE_FULL'] = WkPaypalCommerceRefund::WK_PAYPAL_COMMERCE_REFUND_TYPE_FULL;
$smartyVars['WK_PAYPAL_COMMERCE_REFUND_TYPE_PARTIAL'] = WkPaypalCommerceRefund::WK_PAYPAL_COMMERCE_REFUND_TYPE_PARTIAL;
$this->context->smarty->assign($smartyVars);
} else {
Tools::redirectAdmin(self::$currentIndex . '&token=' . $this->token);
}
$this->base_tpl_view = 'view.tpl';
return parent::renderView();
}
public function postProcess()
@@ -231,7 +238,7 @@ class AdminPaypalCommerceTransactionController extends ModuleAdminController
WkPaypalCommerceHelper::logMsg('refund', 'PayPal Transaction ID: '. $transactionData['pp_transaction_id']);
WkPaypalCommerceHelper::logMsg('refund', 'PayPal Order ID: '. $transactionData['pp_order_id']);
WkPaypalCommerceHelper::logMsg('refund', 'Refund request data: ');
WkPaypalCommerceHelper::logMsg('refund', Tools::jsonEncode($postData));
WkPaypalCommerceHelper::logMsg('refund', json_encode($postData));
$objPPCommerce = new PayPalCommerce();
$refundData = $objPPCommerce->orders->refund($postData);
@@ -243,7 +250,7 @@ class AdminPaypalCommerceTransactionController extends ModuleAdminController
WkPaypalCommerceHelper::logMsg('refund', 'Refund success: ', true);
WkPaypalCommerceHelper::logMsg('refund', 'PayPal Refund Id: '. $refundID);
WkPaypalCommerceHelper::logMsg('refund', 'Refund reponse data: ');
WkPaypalCommerceHelper::logMsg('refund', Tools::jsonEncode($refundData));
WkPaypalCommerceHelper::logMsg('refund', json_encode($refundData));
WkPaypalCommerceHelper::logMsg('refund', '----------------------- ', true);
$refundObj = new WkPaypalCommerceRefund();
@@ -253,7 +260,7 @@ class AdminPaypalCommerceTransactionController extends ModuleAdminController
$refundObj->refund_type = (int)$refundType;
$refundObj->currency_code = $transactionData['pp_paid_currency'];
$refundObj->refund_reason = $refundReason;
$refundObj->response = Tools::jsonEncode($refundData);
$refundObj->response = json_encode($refundData);
$refundObj->refund_status = $refundData['data']['status'];
if ($refundObj->save()) {
$urlString = '&viewwk_paypal_commerce_order=&id_paypal_commerce_order=' . (int)Tools::getValue('id_paypal_commerce_order');
@@ -263,7 +270,7 @@ class AdminPaypalCommerceTransactionController extends ModuleAdminController
} else {
WkPaypalCommerceHelper::logMsg('refund', 'Refund failed: ', true);
WkPaypalCommerceHelper::logMsg('refund', 'Refund reponse data: ');
WkPaypalCommerceHelper::logMsg('refund', Tools::jsonEncode($refundData));
WkPaypalCommerceHelper::logMsg('refund', json_encode($refundData));
WkPaypalCommerceHelper::logMsg('refund', '----------------------- ', true);
$this->errors[] = $refundData['data']['message'];
}

View File

@@ -44,25 +44,25 @@ class QloPaypalCommerceCallbackModuleFrontController extends ModuleFrontControll
}
if ($json) {
$payload['webhook_event'] = Tools::jsonDecode($json, true);
$payload['webhook_event'] = json_decode($json, true);
}
if ($payload) {
WkPaypalCommerceHelper::logMsg('webhook', 'Webhook initiated...', true);
WkPaypalCommerceHelper::logMsg('webhook', 'Environment: '. Configuration::get('WK_PAYPAL_COMMERCE_PAYMENT_MODE'));
WkPaypalCommerceHelper::logMsg('webhook', 'Webhook payload data: ');
WkPaypalCommerceHelper::logMsg('webhook', Tools::jsonEncode($payload));
WkPaypalCommerceHelper::logMsg('webhook', json_encode($payload));
WkPaypalCommerceHelper::logMsg('webhook', 'Validating webhook signature...');
$validateSig = WkPaypalCommerceHelper::validateWebhookSig($payload);
WkPaypalCommerceHelper::logMsg('webhook', 'Webhook respose data: ');
WkPaypalCommerceHelper::logMsg('webhook', Tools::jsonEncode($validateSig));
WkPaypalCommerceHelper::logMsg('webhook', json_encode($validateSig));
if (isset($validateSig['verification_status'])
&& $validateSig['verification_status'] == 'SUCCESS'
) {
$eventData = Tools::jsonDecode($json, true);
$eventData = json_decode($json, true);
$objWebhook = new WkPaypalCommerceWebhook();
switch ($eventData['event_type']) {
case 'CHECKOUT.ORDER.APPROVED':

View File

@@ -69,7 +69,7 @@ class QloPaypalCommercePaymentModuleFrontController extends ModuleFrontControlle
switch ($action) {
case 1:
$json = Tools::file_get_contents('php://input');
$orderDetails = Tools::jsonDecode($json, true);
$orderDetails = json_decode($json, true);
$cart = $this->context->cart;
@@ -86,23 +86,23 @@ class QloPaypalCommercePaymentModuleFrontController extends ModuleFrontControlle
// create order
$orderDetails['original'] = $this->getOrderDetails();
WkPaypalCommerceHelper::logMsg('payment', Tools::jsonEncode($orderDetails));
WkPaypalCommerceHelper::logMsg('payment', json_encode($orderDetails));
$ppOrderData = $ppCommerce->orders->create($orderDetails);
WkPaypalCommerceHelper::logMsg('payment', 'Payment response data: ', true);
WkPaypalCommerceHelper::logMsg('payment', Tools::jsonEncode($ppOrderData));
WkPaypalCommerceHelper::logMsg('payment', json_encode($ppOrderData));
die(Tools::jsonEncode($ppOrderData));
die(json_encode($ppOrderData));
case 2:
$json = Tools::file_get_contents('php://input');
$orderData = Tools::jsonDecode($json, true);
$orderData = json_decode($json, true);
if ($orderData['orderID'] && $orderData['getOrderData']) {
$ppCommerce = new PayPalCommerce();
$returnData = $ppCommerce->orders->capture($orderData['orderID']);
header('Content-Type: application/json');
echo Tools::jsonEncode($returnData['data']);
echo json_encode($returnData['data']);
die;
} elseif (Tools::getIsset('order_id')) {
$orderID = Tools::getValue('order_id');
@@ -116,14 +116,14 @@ class QloPaypalCommercePaymentModuleFrontController extends ModuleFrontControlle
WkPaypalCommerceHelper::logMsg('payment', 'Customer ID: '. $cart->id_customer);
WkPaypalCommerceHelper::logMsg('payment', 'Currency ID: '. $cart->id_currency);
WkPaypalCommerceHelper::logMsg('payment', 'Cart Total: '. $cart->getOrderTotal(true, Cart::BOTH));
WkPaypalCommerceHelper::logMsg('payment', Tools::jsonEncode($returnData));
WkPaypalCommerceHelper::logMsg('payment', json_encode($returnData));
if (isset($returnData['data']['id']) && !empty($returnData['data']['id'])) {
// Payment success
$paypalOrderID = $returnData['data']['id'];
// Save order data
$this->saveOrderData($returnData);
$transaction_id = $this->saveOrderData($returnData);
if ($paypalOrderID) {
$currency = $this->context->currency;
$total = (float)$cart->getOrderTotal(true, Cart::BOTH);
@@ -144,6 +144,7 @@ class QloPaypalCommercePaymentModuleFrontController extends ModuleFrontControlle
$orderStatus = Configuration::get('PS_OS_AWAITING_PAYMENT');
}
$extraVars['transaction_id'] = $transaction_id;
// create order for the payment
$this->module->validateOrder(
$cart->id,
@@ -151,7 +152,7 @@ class QloPaypalCommercePaymentModuleFrontController extends ModuleFrontControlle
$total,
$this->module->l('PayPal Checkout', 'payment'),
null,
null,
$extraVars,
(int)$currency->id,
false,
$customer->secure_key
@@ -210,7 +211,7 @@ class QloPaypalCommercePaymentModuleFrontController extends ModuleFrontControlle
break;
case 3:
WkPaypalCommerceHelper::logMsg('payment', 'Payment cancelled by customer...', true);
WkPaypalCommerceHelper::logMsg('payment', Tools::jsonEncode(Tools::getAllValues()));
WkPaypalCommerceHelper::logMsg('payment', json_encode(Tools::getAllValues()));
WkPaypalCommerceHelper::logMsg('payment', '--------------', true);
Tools::redirect($this->context->link->getPageLink('order-opc', true, null).'?pp_cancel=1');
@@ -226,6 +227,7 @@ class QloPaypalCommercePaymentModuleFrontController extends ModuleFrontControlle
// Save order data
private function saveOrderData($orderData)
{
$transaction_id = '';
if ($orderData) {
$purchaseUnits = $orderData['data']['purchase_units'];
foreach ($purchaseUnits as $purchase) {
@@ -260,15 +262,13 @@ class QloPaypalCommercePaymentModuleFrontController extends ModuleFrontControlle
$orderObj->pp_order_id = $orderData['data']['id'];
$orderObj->pp_transaction_id = $transaction_id;
$orderObj->pp_payment_status = $payment_status;
$orderObj->response = Tools::jsonEncode($orderData);
$orderObj->response = json_encode($orderData);
$orderObj->order_date = date('Y-m-d H:i:s');
$orderObj->save();
}
return true;
}
return false;
return $transaction_id;
}
// Create order data to send to PayPal

View File

@@ -44,25 +44,25 @@ class QloPaypalCommerceWebhookModuleFrontController extends ModuleFrontControlle
}
if ($json) {
$payload['webhook_event'] = Tools::jsonDecode($json, true);
$payload['webhook_event'] = json_decode($json, true);
}
if ($payload) {
WkPaypalCommerceHelper::logMsg('webhook', 'Webhook initiated...', true);
WkPaypalCommerceHelper::logMsg('webhook', 'Environment: '. Configuration::get('WK_PAYPAL_COMMERCE_PAYMENT_MODE'));
WkPaypalCommerceHelper::logMsg('webhook', 'Webhook payload data: ');
WkPaypalCommerceHelper::logMsg('webhook', Tools::jsonEncode($payload));
WkPaypalCommerceHelper::logMsg('webhook', json_encode($payload));
WkPaypalCommerceHelper::logMsg('webhook', 'Validating webhook signature...');
$validateSig = WkPaypalCommerceHelper::validateWebhookSig($payload);
WkPaypalCommerceHelper::logMsg('webhook', 'Webhook respose data: ');
WkPaypalCommerceHelper::logMsg('webhook', Tools::jsonEncode($validateSig));
WkPaypalCommerceHelper::logMsg('webhook', json_encode($validateSig));
if (isset($validateSig['verification_status'])
&& $validateSig['verification_status'] == 'SUCCESS'
) {
$eventData = Tools::jsonDecode($json, true);
$eventData = json_decode($json, true);
$objWebhook = new WkPaypalCommerceWebhook();
switch ($eventData['event_type']) {
case 'CHECKOUT.ORDER.APPROVED':

View File

@@ -70,7 +70,7 @@ class HttpHelper {
$headerSize = curl_getinfo($this->_curl, CURLINFO_HEADER_SIZE);
$body = substr($result, $headerSize);
return Tools::jsonDecode($body, true);
return json_decode($body, true);
}
public function resetHelper() {
@@ -85,7 +85,7 @@ class HttpHelper {
public function setBody($postData) {
if(is_array($postData)) {
$postData = Tools::jsonEncode($postData);
$postData = json_encode($postData);
}
curl_setopt($this->_curl, CURLOPT_POSTFIELDS, $postData);
curl_setopt($this->_curl, CURLOPT_POST, true);

View File

@@ -107,7 +107,7 @@
{if $transaction_data and $transaction_data.pp_payment_status == 'COMPLETED'}
{* show refund form only if there is any remaing amount for refund *}
{if $remaining_refund > 0}
<form action="" method="post" class="form-horizontal" id="refund_form">
<form action="{$transaction_url|escape:'html':'UTF-8'}" method="post" class="form-horizontal" id="refund_form">
<div class="panel col-lg-12">
<div class="panel-heading">
<i class="icon-reply"></i>
@@ -176,6 +176,7 @@
<th style="text-align: center">{l s='Amount' mod='qlopaypalcommerce'}</th>
<th style="text-align: center">{l s='Type' mod='qlopaypalcommerce'}</th>
<th style="text-align: center">{l s='Status' mod='qlopaypalcommerce'}</th>
<th style="text-align: center">{l s='Remark' mod='qlopaypalcommerce'}</th>
<th style="text-align: center">{l s='Date' mod='qlopaypalcommerce'}</th>
</tr>
{if $refund_data}
@@ -197,6 +198,7 @@
<label class="label label-danger">{$refund.refund_status|escape:'html':'UTF-8'}</label>
{/if}
</td>
<td style="text-align: center">{$refund.refund_reason|escape:'html':'UTF-8'}</td>
<td style="text-align: center">{$refund.date_add|escape:'html':'UTF-8'}</td>
</tr>
{/foreach}

View File

@@ -184,7 +184,11 @@ class StatsRegistrations extends ModuleGraph
{
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($this->query.$this->getDate());
foreach ($result as $row) {
$this->_values[(int)Tools::substr($row['date_add'], 0, 4)]++;
$year = (int)Tools::substr($row['date_add'], 0, 4);
if (!isset($this->_values[$year])) {
$this->_values[$year] = 0;
}
$this->_values[$year]++;
}
}
@@ -204,7 +208,11 @@ class StatsRegistrations extends ModuleGraph
{
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($this->query.$this->getDate());
foreach ($result as $row) {
$this->_values[(int)Tools::substr($row['date_add'], 8, 2)]++;
$days = (int)Tools::substr($row['date_add'], 8, 2);
if (!isset($this->_values[$days])) {
$this->_values[$days] = 0;
}
$this->_values[$days]++;
}
}
@@ -212,7 +220,11 @@ class StatsRegistrations extends ModuleGraph
{
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($this->query.$this->getDate());
foreach ($result as $row) {
$this->_values[(int)Tools::substr($row['date_add'], 11, 2)]++;
$hour = (int)Tools::substr($row['date_add'], 11, 2);
if (!isset($this->_values[$hour])) {
$this->_values[$hour] = 0;
}
$this->_values[$hour]++;
}
}
}

View File

@@ -310,10 +310,14 @@ class StatsSales extends ModuleGraph
{
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($this->query.$this->getDate().$this->query_group_by.$this->query_having_filter);
foreach ($result as $row) {
$days = (int)substr($row['invoice_date'], 8, 2);
if (!isset($this->_values[$days])) {
$this->_values[$days] = 0;
}
if ($this->option == 1) {
$this->_values[(int)substr($row['invoice_date'], 8, 2)] += 1;
$this->_values[$days] += 1;
} else {
$this->_values[(int)substr($row['invoice_date'], 8, 2)] += $row['total_revenue'];
$this->_values[$days] += $row['total_revenue'];
}
}
}

View File

@@ -28,11 +28,19 @@
<th class="header small" valign="middle">{l s='Invoice Date' pdf='true'}</th>
<th class="header small" valign="middle">{l s='Order Reference' pdf='true'}</th>
<th class="header small" valign="middle">{l s='Order date' pdf='true'}</th>
{if $addresses.invoice->vat_number}
<th class="header small" valign="middle">{l s='VAT Number' pdf='true'}</th>
{/if}
</tr>
<tr>
<td class="center small white">{$title|escape:'html':'UTF-8'}</td>
<td class="center small white">{dateFormat date=$order->invoice_date full=0}</td>
<td class="center small white">{$order->getUniqReference()}</td>
<td class="center small white">{dateFormat date=$order->date_add full=0}</td>
{if $addresses.invoice->vat_number}
<td class="center small white">
{$addresses.invoice->vat_number|escape:'html':'UTF-8'}
</td>
{/if}
</tr>
</table>

View File

@@ -42,7 +42,7 @@
<div class="col-sm-8 room_info_cont">
{block name='room_type_list_room_quantity'}
<div class="row">
<p class="rm_heading col-sm-12 col-md-7">{$room_v['name']|escape:'htmlall':'UTF-8'}</p>
<a href="{$room_v['product_link']|escape:'htmlall':'UTF-8'}"><p class="rm_heading col-sm-12 col-md-7">{$room_v['name']|escape:'htmlall':'UTF-8'}</p></a>
{if !isset($restricted_country_mode) && !$PS_CATALOG_MODE && !$order_date_restrict}
<p class="rm_left col-sm-12 col-md-5" {if !empty($display_all_room_types) || $room_v['room_left'] > $warning_num} style="display:none"{/if}>
{l s='Hurry!'} <span class="remain_rm_qty">{$room_v['room_left']|escape:'htmlall':'UTF-8'}</span> {l s='rooms left'}

View File

@@ -5776,10 +5776,13 @@ textarea {
background: #fff; }
#columns {
padding: 0;
}
#columns:has(#center_column > *) {
position: relative;
padding-bottom: 50px;
padding-top: 15px; }
padding-top: 15px;
}
#index .tab-content {
margin-top: 35px;
margin-bottom: 34px; }

View File

@@ -74,7 +74,7 @@
<span class="htl-address-icon htl-email-icon"></span>{$hotel['email']}
</p>
<div class="hotel-branch-info-actions">
<a href="{$hotel['view_rooms_link']}" target="_blank" class="btn btn-primary view_rooms_btn col-sm-6 col-xs-12">{l s='View Rooms'}</a>
<a href="{$hotel['view_rooms_link']}" target="_blank" class="btn btn-primary view_rooms_btn col-sm-6 col-xs-12">{l s='View Property'}</a>
{if ($hotel['latitude'] != 0 || $hotel['longitude'] != 0) && $viewOnMap}
<a class="btn htl-map-direction-btn col-sm-6 col-xs-12" href="http://maps.google.com/maps?daddr=({$hotel['latitude']},{$hotel['longitude']})" target="_blank">{l s='View on map'}</a>
{/if}

View File

@@ -30,7 +30,8 @@ function classAutoLoader($class)
return;
}
$className = end(explode('\\', $class));
$parts = explode('\\', $class);
$className = end($parts);
if(class_exists($className)) {
return;
}