184 lines
6.3 KiB
PHP
184 lines
6.3 KiB
PHP
<?php
|
|
|
|
class Upgrade36 extends UpgradeNew
|
|
{
|
|
public function check_RemoveInPersonColumn()
|
|
{
|
|
if (!findModule('eshop_delivery') || $this->checkColumnExists('delivery_type_delivery', 'in_person')) {
|
|
return false;
|
|
}
|
|
|
|
$hasInPerson = returnSQLResult("SELECT COUNT(*) FROM delivery_type_delivery WHERE in_person='Y'");
|
|
|
|
if ($hasInPerson && !findModule('deliveries')) {
|
|
exit("<h2>Nekde je aktivovany osobni odber a neni modul 'deliveries'!: \$cfg['Modules']['deliveries'] = true;</h2>");
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
/** remove delivery_type_delivery in_person column */
|
|
public function upgrade_RemoveInPersonColumn()
|
|
{
|
|
if (findModule('deliveries')) {
|
|
sqlQuery('UPDATE delivery_type_delivery SET class="OsobniOdber" WHERE in_person="Y" AND class IS NULL');
|
|
}
|
|
|
|
sqlQuery('ALTER TABLE delivery_type_delivery DROP COLUMN in_person');
|
|
|
|
$this->upgradeOK();
|
|
}
|
|
|
|
public function check_AddDiscountTypeProduct()
|
|
{
|
|
return findModule('purchase_discounts') && $this->checkEnumExists('discounts', 'condition_type', 'product');
|
|
}
|
|
|
|
/** add condition_type product to enum */
|
|
public function upgrade_AddDiscountTypeProduct()
|
|
{
|
|
sqlQuery("ALTER TABLE discounts MODIFY COLUMN condition_type ENUM('price','pieces','date','coupon','order','product');");
|
|
|
|
$this->upgradeOK();
|
|
}
|
|
|
|
public function check_MoreSpaceForSliderSize()
|
|
{
|
|
return findModule('sliders') && $this->checkColumnType('sliders', 'size', 'VARCHAR(100)');
|
|
}
|
|
|
|
/** Make slider.size larger */
|
|
public function upgrade_MoreSpaceForSliderSize()
|
|
{
|
|
sqlQuery('ALTER TABLE sliders CHANGE size size VARCHAR(100)');
|
|
|
|
$this->upgradeOK();
|
|
}
|
|
|
|
public function check_IncreaseFirmField()
|
|
{
|
|
return findModule('eshop_users') && $this->checkColumnType('users', 'firm', 'VARCHAR(100)');
|
|
}
|
|
|
|
/** Change users firm from varchar(50) to varchar(100) */
|
|
public function upgrade_IncreaseFirmField()
|
|
{
|
|
sqlQuery("ALTER TABLE users CHANGE COLUMN `firm` `firm` VARCHAR(100) NOT NULL DEFAULT ''");
|
|
sqlQuery("ALTER TABLE users CHANGE COLUMN `delivery_firm` `delivery_firm` VARCHAR(100) NOT NULL DEFAULT ''");
|
|
|
|
$this->upgradeOK();
|
|
}
|
|
|
|
public function check_IncreaseOrdersFirmField()
|
|
{
|
|
return findModule('orders') && $this->checkColumnType('orders', 'invoice_firm', 'VARCHAR(100)');
|
|
}
|
|
|
|
/** Change users orders firm from varchar(50) to varchar(100) */
|
|
public function upgrade_IncreaseOrdersFirmField()
|
|
{
|
|
sqlQuery("ALTER TABLE orders CHANGE COLUMN `invoice_firm` `invoice_firm` VARCHAR(100) NOT NULL DEFAULT ''");
|
|
sqlQuery("ALTER TABLE orders CHANGE COLUMN `delivery_firm` `delivery_firm` VARCHAR(100) NOT NULL DEFAULT ''");
|
|
|
|
$this->upgradeOK();
|
|
}
|
|
|
|
public function check_MorePrecisionForProductDiscount()
|
|
{
|
|
return $this->checkColumnType('products', 'discount', 'decimal(12,8) unsigned');
|
|
}
|
|
|
|
/** Make product discount more precise */
|
|
public function upgrade_MorePrecisionForProductDiscount()
|
|
{
|
|
sqlQuery('ALTER TABLE `products` CHANGE `discount` `discount` DECIMAL(12,8) UNSIGNED NOT NULL DEFAULT \'0\'');
|
|
|
|
$this->upgradeOK();
|
|
}
|
|
|
|
public function check_PriceLvlsProductsUnit()
|
|
{
|
|
return findModule('price_levels') && $this->checkColumnType('price_levels_products', 'unit', "enum('perc','price','final_price')");
|
|
}
|
|
|
|
/** Add final_price to price_levels_products unit enum */
|
|
public function upgrade_PriceLvlsProductsUnit()
|
|
{
|
|
sqlQuery("ALTER TABLE price_levels_products CHANGE unit unit ENUM('perc','price','final_price') NOT NULL DEFAULT 'perc'");
|
|
|
|
$this->upgradeOK();
|
|
}
|
|
|
|
public function check_ReviewOrderId()
|
|
{
|
|
return findModule('reviews') && $this->checkColumnExists('reviews', 'id_order');
|
|
}
|
|
|
|
/** Add order_id to review */
|
|
public function upgrade_ReviewOrderId()
|
|
{
|
|
sqlQuery('ALTER TABLE reviews ADD id_order INT(10) UNSIGNED NULL DEFAULT NULL');
|
|
sqlQuery('ALTER TABLE reviews ADD CONSTRAINT `reviews_order_fk` FOREIGN KEY (id_order) REFERENCES orders(id) ON DELETE SET NULL ON UPDATE CASCADE');
|
|
|
|
$this->upgradeOK();
|
|
}
|
|
|
|
public function check_ReviewNullableVariation()
|
|
{
|
|
return findModule('reviews') && $this->checkColumnIsNull('reviews', 'id_product_variation', true);
|
|
}
|
|
|
|
/** Allow review variation to be null*/
|
|
public function upgrade_ReviewNullableVariation()
|
|
{
|
|
sqlQuery('ALTER TABLE reviews CHANGE id_product_variation id_product_variation INT(11) NULL DEFAULT NULL');
|
|
|
|
$this->upgradeOK();
|
|
}
|
|
|
|
public function check_AddUserToReviews()
|
|
{
|
|
return findModule('reviews') && $this->checkColumnExists('reviews', 'id_user');
|
|
}
|
|
|
|
/** Add ref to id_user, figure into reviews*/
|
|
public function upgrade_AddUserToReviews()
|
|
{
|
|
sqlQuery('ALTER TABLE reviews ADD COLUMN id_user INT(11) UNSIGNED DEFAULT NULL');
|
|
sqlQuery('ALTER TABLE reviews ADD COLUMN figure TINYINT(1) NOT NULL DEFAULT 1');
|
|
|
|
sqlQuery('ALTER TABLE `reviews` ADD CONSTRAINT `reviews_user_ibfk1` FOREIGN KEY (`id_user`) REFERENCES `users` (`id`) ON DELETE SET NULL ON UPDATE CASCADE');
|
|
|
|
$this->upgradeOK();
|
|
}
|
|
|
|
public function check_AddProductsWeight()
|
|
{
|
|
return findModule(\Modules::PRODUCTS, \Modules::SUB_WEIGHT) && $this->checkColumnExists('products', 'weight');
|
|
}
|
|
|
|
/** Add weight to products and variations*/
|
|
public function upgrade_AddProductsWeight()
|
|
{
|
|
sqlQuery('ALTER TABLE products ADD COLUMN weight DECIMAL(15,4) DEFAULT NULL');
|
|
sqlQuery('ALTER TABLE products_variations ADD COLUMN weight DECIMAL(15,4) DEFAULT NULL');
|
|
|
|
$this->upgradeOK();
|
|
}
|
|
|
|
public function check_DeliveryDescription()
|
|
{
|
|
return findModule('eshop_delivery') && $this->checkColumnExists('delivery_type', 'description');
|
|
}
|
|
|
|
/** Add description to delivery_types/deliveries/payments */
|
|
public function upgrade_DeliveryDescription()
|
|
{
|
|
sqlQuery('ALTER TABLE delivery_type ADD COLUMN description TEXT DEFAULT NULL');
|
|
sqlQuery('ALTER TABLE delivery_type_delivery ADD COLUMN description TEXT DEFAULT NULL');
|
|
sqlQuery('ALTER TABLE delivery_type_payment ADD COLUMN description TEXT DEFAULT NULL');
|
|
|
|
$this->upgradeOK();
|
|
}
|
|
}
|