Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
105 changes: 105 additions & 0 deletions install/upgrade/php/add_order_detail_meta_page_161.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
<?php
/**
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License version 3.0
* that is bundled with this package in the file LICENSE.md
* It is also available through the world-wide-web at this URL:
* https://opensource.org/license/osl-3-0-php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this module to a newer
* versions in the future. If you wish to customize this module for your needs
* please refer to https://store.webkul.com/customisation-guidelines for more information.
*
* @author Webkul IN
* @copyright Since 2010 Webkul
* @license https://opensource.org/license/osl-3-0-php Open Software License version 3.0
*/

function add_order_detail_meta_page_161()
{

if (!Db::getInstance()->getValue('
SELECT id_meta
FROM `'._DB_PREFIX_.'meta` m
WHERE m.`page` = "order-detail"')
) {
// meta
Db::getInstance()->insert(
'meta',
array(
'page' => 'order-detail',
'configurable' => 1,
)
);
if ($last_id = Db::getInstance()->Insert_ID()) {
// meta lang
$pageDetail = array(
'en' => array(
'title' => 'Booking details',
'url_rewrite' => 'order-detail'
),
'fr' => array(
'title' => 'Détails de réservation',
'url_rewrite' => 'details-de-reservation'
)
);
if ($languages = Db::getInstance()->executeS('SELECT id_lang, iso_code FROM `'._DB_PREFIX_.'lang`')) {
$row = array();
foreach ($languages as $lang) {
if (in_array(strtolower($lang['iso_code']), array_keys($pageDetail))) {
$row[] = array(
'id_meta' => (int)$last_id,
'id_shop' => 1,
'id_lang' => (int)$lang['id_lang'],
'title' => $pageDetail[strtolower($lang['iso_code'])]['title'],
'description' => '',
'keywords' => '',
'url_rewrite' => $pageDetail[strtolower($lang['iso_code'])]['url_rewrite']
);
} else {
$row[] = array(
'id_meta' => (int)$last_id,
'id_shop' => 1,
'id_lang' => (int)$lang['id_lang'],
'title' => $pageDetail['en']['title'],
'description' => '',
'keywords' => '',
'url_rewrite' => $pageDetail['en']['url_rewrite']
);
}
}
Db::getInstance()->insert(
'meta_lang',
$row
);
}

// meta themes
$row = array();
if ($themes = Db::getInstance()->executeS('SELECT id_theme FROM `'._DB_PREFIX_.'theme`')) {
foreach ($themes as $theme) {
$row[] = array(
'id_theme' => (int)$theme,
'id_meta' => (int)$last_id,
'left_column' => 0,
'right_column' => 0
);
}
Db::getInstance()->insert(
'theme_meta',
$row
);
}

return true;
} else {
return false;
}
}
}
39 changes: 39 additions & 0 deletions install/upgrade/php/clean_product_description_161.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php
/**
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License version 3.0
* that is bundled with this package in the file LICENSE.md
* It is also available through the world-wide-web at this URL:
* https://opensource.org/license/osl-3-0-php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this module to a newer
* versions in the future. If you wish to customize this module for your needs
* please refer to https://store.webkul.com/customisation-guidelines for more information.
*
* @author Webkul IN
* @copyright Since 2010 Webkul
* @license https://opensource.org/license/osl-3-0-php Open Software License version 3.0
*/

function clean_product_description_161()
{
if ($descriptions = Db::getInstance()->executeS(
'SELECT `id_product`, `id_lang`, `description_short` FROM `'._DB_PREFIX_.'product_lang`'
)) {
$sql = 'UPDATE `'._DB_PREFIX_.'product_lang`
SET description_short = CASE';
foreach ($descriptions as $description) {
$sql .= ' WHEN id_product = '.(int)$description['id_product'].' AND id_lang = '.(int)$description['id_lang'].'
THEN "'.pSQL(Tools::getDescriptionClean($description['description_short'])).'"';
}
$sql .= ' END';
Db::getInstance()->execute($sql);
}

}
51 changes: 51 additions & 0 deletions install/upgrade/php/update_order_payment_type_160.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php
/**
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License version 3.0
* that is bundled with this package in the file LICENSE.md
* It is also available through the world-wide-web at this URL:
* https://opensource.org/license/osl-3-0-php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this module to a newer
* versions in the future. If you wish to customize this module for your needs
* please refer to https://store.webkul.com/customisation-guidelines for more information.
*
* @author Webkul IN
* @copyright Since 2010 Webkul
* @license https://opensource.org/license/osl-3-0-php Open Software License version 3.0
*/

function update_order_payment_type_160()
{
if ($orders = Db::getInstance()->executeS(
'SELECT `id_order`, `module` FROM `'._DB_PREFIX_.'orders`'
)) {
$sql = 'UPDATE `'._DB_PREFIX_.'orders`
SET payment_type = CASE';
$modulePaymentType = array();
foreach ($orders as &$order) {
if (!isset($modulePaymentType[$order['module']])) {
$module = Module::getInstanceByName($order['module']);
if ($module instanceof Module && $module->payment_type) {
$modulePaymentType[$order['module']] = $module->payment_type;
} else {
$modulePaymentType[$order['module']] = 1;
}
}
$sql .= ' WHEN id_order = '.(int)$order['id_order'].' THEN '.(int)$modulePaymentType[$order['module']];
}
$sql .= ' END WHERE id_order IN ('.pSQL(implode(', ', array_column($orders, 'id_order'))).')';
Db::getInstance()->execute($sql);
}
Db::getInstance()->execute(
'UPDATE `'._DB_PREFIX_.'order_payment` op
INNER JOIN `'._DB_PREFIX_.'orders` o ON (op.`order_reference` = o.`reference`)
SET op.`payment_type` = o.`payment_type`'
);
}
67 changes: 67 additions & 0 deletions install/upgrade/php/update_order_states_161.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?php
/**
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License version 3.0
* that is bundled with this package in the file LICENSE.md
* It is also available through the world-wide-web at this URL:
* https://opensource.org/license/osl-3-0-php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this module to a newer
* versions in the future. If you wish to customize this module for your needs
* please refer to https://store.webkul.com/customisation-guidelines for more information.
*
* @author Webkul IN
* @copyright Since 2010 Webkul
* @license https://opensource.org/license/osl-3-0-php Open Software License version 3.0
*/

function update_order_states_161()
{
$data = array(
'invoice' => 0,
'send_email' => 0,
'color' => '#FF69B4',
'unremovable' => 1,
'hidden' => 0,
'logable' => 0,
'delivery' => 0,
'shipped' => 0,
'paid' => 0,
'pdf_delivery' => 0,
'pdf_invoice' => 0,
'deleted' => 0
);
Db::getInstance()->insert('order_state', $data);
if ($last_id = Db::getInstance()->Insert_ID()) {
if ($languages = Db::getInstance()->executeS('SELECT id_lang, iso_code FROM `'._DB_PREFIX_.'lang`')) {
$row = array();
foreach ($languages as $lang) {
$row[] = array(
'id_order_state' => (int)$last_id,
'id_lang' => (int)$lang['id_lang'],
'name' => 'Overbooking (Partial payment)',
'template' => '',
);
}
Db::getInstance()->insert(
'order_state_lang',
$row
);
}
if (file_exists(dirname(__FILE__).'/../../data/img/os/Overbooking_partial_paid.gif')) {
copy(dirname(__FILE__).'/../../data/img/os/Overbooking_partial_paid.gif', _PS_ROOT_DIR_.'/img/os/'.$last_id.'.gif');
}
Db::getInstance()->insert('configuration',[
'name' => 'PS_OS_OVERBOOKING_PARTIAL_PAID',
'value' => $last_id,
'date_add' => date('Y-m-d H:i:s'),
'date_upd' => date('Y-m-d H:i:s')
]);
}
}
58 changes: 58 additions & 0 deletions install/upgrade/php/update_tabs_161.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php
/**
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License version 3.0
* that is bundled with this package in the file LICENSE.md
* It is also available through the world-wide-web at this URL:
* https://opensource.org/license/osl-3-0-php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this module to a newer
* versions in the future. If you wish to customize this module for your needs
* please refer to https://store.webkul.com/customisation-guidelines for more information.
*
* @author Webkul IN
* @copyright Since 2010 Webkul
* @license https://opensource.org/license/osl-3-0-php Open Software License version 3.0
*/

function update_tabs_161()
{
$remove_tabs = array(
'AdminParentStats',
'AdminSearchEngines',
'AdminReferrers',
);

$ids = array();
foreach ($remove_tabs as $tab) {
if ($id = get_tab_id($tab)) {
$ids[] = $id;
}
}

if ($ids) {
Db::getInstance()->delete('tab', 'id_tab IN ('.implode(', ', $ids).')');
Db::getInstance()->delete('tab_lang', 'id_tab IN ('.implode(', ', $ids).')');
}

// remove id parent of stats tab
$idAdminStats = get_tab_id('AdminStats');
$position = Db::getInstance()->getValue('SELECT MAX(`position`) FROM `'._DB_PREFIX_.'tab` WHERE `id_parent` = 0');
Db::getInstance()->update('tab', array('id_parent' => 0, 'position' => ($position + 1)), '`id_tab` = '.$idAdminStats);
}

function get_tab_id($class_name)
{
static $cache = array();

if (!isset($cache[$class_name])) {
$cache[$class_name] = Db::getInstance()->getValue('SELECT id_tab FROM '._DB_PREFIX_.'tab WHERE class_name = \''.pSQL($class_name).'\'');
}
return $cache[$class_name];
}
65 changes: 65 additions & 0 deletions install/upgrade/sql/1.6.1.0.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
SET NAMES 'utf8';

INSERT INTO `PREFIX_configuration` (`name`, `value`, `date_add`, `date_upd`) VALUES
('PS_ALLOW_EMP', '0', NOW(), NOW()),
('PS_ALLOW_EMP_MAX_ATTEMPTS', '0', NOW(), NOW()),
('PS_KPI_BEST_SELLING_ROOM_TYPE_NB_DAYS', '30', NOW(), NOW()),
('PS_ORDER_LIST_PRICE_DISPLAY_CURRENCY', '1', NOW(), NOW()),
('PS_OVERBOOKING_ORDER_ACTION', '1', NOW(), NOW()),
('PS_MAX_OVERBOOKING_PER_HOTEL_PER_DAY', '2', NOW(), NOW()),

('PS_CUSTOMER_BIRTHDATE', '1', NOW(), NOW()),

('PS_KPI_FREQUENT_CUSTOMER_NB_ORDERS', '5', NOW(), NOW()),
('PS_KPI_REVPAC_NB_DAYS', '30', NOW(), NOW()),
('PS_KPI_CONVERSION_RATE_NB_DAYS', '30', NOW(), NOW()),
('PS_ORDER_KPI_AVG_ORDER_VALUE_NB_DAYS', '30', NOW(), NOW()),
('PS_ORDER_KPI_PER_VISITOR_PROFIT_NB_DAYS', '30', NOW(), NOW()),
('PS_KPI_NEW_CUSTOMERS_NB_DAYS', '30', NOW(), NOW()),

('PS_BACKDATE_ORDER_SUPERADMIN', '1', NOW(), NOW()),
('PS_BACKDATE_ORDER_EMPLOYEES', '0', NOW(), NOW());

UPDATE `PREFIX_configuration`
set `value` = 1
WHERE `name` = 'PS_TAX_DISPLAY';

UPDATE `PREFIX_configuration`
set `value` = 'id_address_invoice'
WHERE `name` = 'PS_TAX_ADDRESS_TYPE';


UPDATE `PREFIX_configuration`
set `value` = STR_TO_DATE(`value`, '%d-%m-%Y')
WHERE `name` = 'MAX_GLOBAL_BOOKING_DATE';

UPDATE `PREFIX_product`
set `show_at_front` = 1
WHERE `booking_product` = 1;
UPDATE `PREFIX_product_shop` ps
INNER JOIN `PREFIX_product` p on(ps.`id_product` = p.`id_product`)
set ps.`show_at_front` = 1
WHERE p.`booking_product` = 1;

INSERT INTO `PREFIX_cart_customer_guest_detail`
(`phone`, `id_gender`, `firstname`, `lastname`, `email`, `id_cart`, `date_add`, `date_upd`)
SELECT
IF(a.phone_mobile IS NOT NULL AND a.phone_mobile != '', a.phone_mobile, a.phone) AS phone,
c.id_gender, c.firstname, c.lastname, c.email, 0 AS id_cart,
NOW() AS date_add, NOW() AS date_upd
FROM
`PREFIX_address` a
INNER JOIN
`PREFIX_customer` c ON a.`id_customer` = c.`id_customer`
WHERE
a.`auto_generated` = 0
GROUP BY
c.`id_customer`;



/* PHP:add_order_detail_meta_page_161(); */;
/* PHP:clean_product_description_161(); */;
/* PHP:update_tabs_161(); */;
/* PHP:update_order_states_161(); */;

Loading