Merge pull request #2005 from shazar-webkul/gli-3350

Updated: Tools correction and admin css
This commit is contained in:
Rohit Jain
2026-11-05 16:26:16 +05:30
committed by GitHub
10 changed files with 74 additions and 87 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -101,6 +101,11 @@ function scroll_if_anchor(href, fromTop = 120) {
}
$(document).ready(function() {
// refresh the upgrade info cache in background, result is shown on next page load
if (typeof upgrade_check_needed !== 'undefined' && upgrade_check_needed) {
$.ajax({url: upgrade_check_url, type: 'GET'});
}
//set main navigation aside
/* global employee_token */
function navSidebar(){

View File

@@ -1,8 +1,5 @@
// Make sure the charset is set appropriately
@charset "UTF-8"
//Compass is required to pre-compile this stylesheets to .css
@import "compass"
@import "modules/colors"
@import "modules/variables"
@import "modules/mixins"

View File

@@ -3384,7 +3384,7 @@ exit;
'iso_code' => Tools::strtolower(isset($params['iso_country']) ? $params['iso_country'] : Country::getIsoById(Configuration::get('PS_COUNTRY_DEFAULT'))),
'shop_url' => isset($params['shop_url']) ? $params['shop_url'] : Tools::getShopDomain(),
'shop_url_ssl' => isset($params['shop_url_ssl']) ? $params['shop_url_ssl'] : Tools::getShopDomainSsl(),
'physical_uri' => Context::getContext()->shop->physical_uri,
'physical_uri' => isset($params['physical_uri']) ? $params['physical_uri'] : Context::getContext()->shop->physical_uri,
'mail' => isset($params['email']) ? $params['email'] : Configuration::get('PS_SHOP_EMAIL')
));
@@ -3449,6 +3449,9 @@ exit;
$post_data .= (isset($params['controller']) ? $params['controller'] : Context::getContext()->controller->controller_name);
$post_data .= defined('_PS_HOST_MODE_') ? '-od' : '';
break;
case 'installation':
$post_data .= '&method=installation&data='.urlencode(json_encode($params['install_data']));
break;
case 'check-version':
$post_data .= '&method=check-version&autoupgrade='.(int)(Module::isInstalled('qloautoupgrade') && Module::isEnabled('qloautoupgrade'));
break;

View File

@@ -1117,6 +1117,26 @@ class AdminControllerCore extends Controller
$this->context->cookie->$cookieKey = (int) Tools::getValue('is_visible');
}
/**
* Refreshes the upgrade available cache from api.qloapps.com in the background.
* A failed or invalid response never replaces the existing cache.
*/
protected function ajaxProcessCheckUpgrade()
{
if (Tools::isFresh(Upgrader::CACHE_FILE_UPGRADE_AVAILABE, _TIME_1_DAY_)) {
return;
}
$cacheFile = _PS_ROOT_DIR_.Upgrader::CACHE_FILE_UPGRADE_AVAILABE;
$content = Tools::addonsRequest('check-version');
if ($content && @simplexml_load_string($content)) {
file_put_contents($cacheFile, $content);
} elseif (file_exists($cacheFile) && filesize($cacheFile) > 0) {
// API unreachable: keep the last known info and retry after the cache lifetime
@touch($cacheFile);
}
}
protected function ajaxProcessSaveKpiView()
{
$cookieKey = 'kpi_wrapping_'.$this->context->controller->className;
@@ -2983,6 +3003,12 @@ class AdminControllerCore extends Controller
Media::addJsDef(array('host_cluster' => defined('_PS_HOST_CLUSTER_') ? _PS_HOST_CLUSTER_ : 'fr1'));
}
// upgrade info is read from cache only, the cache is refreshed in background by ajaxProcessCheckUpgrade()
Media::addJsDef(array(
'upgrade_check_needed' => !Tools::isFresh(Upgrader::CACHE_FILE_UPGRADE_AVAILABE, _TIME_1_DAY_),
'upgrade_check_url' => 'index.php?controller='.$this->controller_name.'&ajax=1&action=checkUpgrade&token='.$this->token,
));
// Execute Hook AdminController SetMedia
Hook::exec('actionAdminControllerSetMedia');
}
@@ -3091,10 +3117,6 @@ class AdminControllerCore extends Controller
'submit_form_ajax' => (int)Tools::getValue('submitFormAjax')
));
// get upgrade available info
if (!Tools::isFresh(Upgrader::CACHE_FILE_UPGRADE_AVAILABE, _TIME_1_DAY_)) {
file_put_contents(_PS_ROOT_DIR_.Upgrader::CACHE_FILE_UPGRADE_AVAILABE, Tools::addonsRequest('check-version'));
}
if (file_exists(_PS_ROOT_DIR_.Upgrader::CACHE_FILE_UPGRADE_AVAILABE)) {
$content = Tools::file_get_contents( _PS_ROOT_DIR_.Upgrader::CACHE_FILE_UPGRADE_AVAILABE);
$upgradeInfo = simplexml_load_string($content);

View File

@@ -628,30 +628,22 @@ class InstallModelInstall extends InstallAbstractModel
return true;
}
public function setNotification($notificationData)
/**
* @param array $installData
* @return bool
*/
public function setNotification($installData)
{
if (function_exists('curl_version')) {
$url = _QLO_API_URL_.'/getNotification.php';
$params = [
'method' => 'POST',
'headers' => array('Content-Type: application/json'),
'postdata' => json_encode($notificationData),
];
$curlInit = curl_init();
curl_setopt($curlInit, CURLOPT_URL, $url);
curl_setopt($curlInit, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($curlInit, CURLOPT_HTTPHEADER, $params['headers']);
curl_setopt($curlInit, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curlInit, CURLOPT_CUSTOMREQUEST, $params['method']);
curl_setopt($curlInit, CURLOPT_RETURNTRANSFER, 1);
if (isset($params['postdata'])) {
curl_setopt($curlInit, CURLOPT_POSTFIELDS, $params['postdata']);
}
$response = curl_exec($curlInit);
} else {
// Mail Code
}
Tools::addonsRequest('installation', array(
'install_data' => $installData,
'version' => _QLO_INSTALL_VERSION_,
'iso_lang' => $this->language->getLanguageIso(),
'iso_country' => $installData['countryCode'],
'shop_url' => $installData['shopDomain'],
'shop_url_ssl' => $installData['shopDomainSsl'],
'physical_uri' => $installData['physicalUri'],
'email' => $installData['email'],
));
return true;
}
@@ -721,7 +713,7 @@ class InstallModelInstall extends InstallAbstractModel
'qlostatsserviceproducts',
'blockcart',
'blockuserinfo',
'qlochannelmanagerconnector',
'qlocmconnector',
'qlogooglehotelconnector'
);
}

View File

@@ -168,7 +168,7 @@ class QghcApiService
public function createConnection($pmsUrl, $apiKey)
{
$this->setApiType(QghcApiLog::TYPE_CONNECTION);
$this->setEndpoint('/api/google-hotel-connection');
$this->setEndpoint('/api/google-hotel/v1/connection');
$this->setMethod('POST');
$this->addHeaders(array(
'Content-Type: application/json',
@@ -190,7 +190,7 @@ class QghcApiService
public function deleteConnection($pmsUrl, $apiKey)
{
$this->setApiType(QghcApiLog::TYPE_DELETE_CONNECTION);
$this->setEndpoint('/api/google-hotel-connection');
$this->setEndpoint('/api/google-hotel/v1/connection');
$this->setMethod('DELETE');
$this->addHeaders(array(
'Content-Type: application/json',
@@ -203,4 +203,4 @@ class QghcApiService
return $this->getResult();
}
}
}

View File

@@ -28,5 +28,5 @@ header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Location: ../../');
header('Location: ../../../');
exit;

View File

@@ -94,13 +94,6 @@ class QloGoogleHotelConnector extends Module
) {
return false;
}
// Best-effort: a failed CM connection or hotel enrollment must never fail install() —
// any issue is surfaced via hookDashboardZoneThree instead.
if ($this->connectToChannelManager()) {
$this->autoEnrollHotels((int) Configuration::get('PS_LANG_DEFAULT'));
}
return true;
}
@@ -119,31 +112,6 @@ class QloGoogleHotelConnector extends Module
return $isConnected;
}
/** Enables every hotel that passes required-field validation, selecting all its room
* types regardless of active status. Hotels that fail are left unenrolled — surfaced by
* QghcPropertyService::getHotelsWithIssues() on the dashboard. */
private function autoEnrollHotels($idLang)
{
$hotels = QghcProperty::getAllHotels($idLang);
if (!$hotels) {
return;
}
$objHotelRoomType = new HotelRoomType();
foreach ($hotels as $hotel) {
$idHotel = (int) $hotel['id'];
if (QghcPropertyService::validateRequiredFields($idHotel, $idLang)) {
continue;
}
$roomTypeIds = array();
foreach ((array) $objHotelRoomType->getRoomTypeByHotelId($idHotel, $idLang) as $roomType) {
$roomTypeIds[] = (int) $roomType['id_product'];
}
QghcPropertyService::enable($idHotel, $roomTypeIds);
}
}
/** Registers all PrestaShop / QloApps hooks the module needs. */
public function registerModuleHooks()
@@ -1250,4 +1218,4 @@ class QloGoogleHotelConnector extends Module
return '';
}
}
}