first commit

This commit is contained in:
2025-08-02 16:30:27 +02:00
commit 23646bfcee
14851 changed files with 1750626 additions and 0 deletions

View File

@@ -0,0 +1,227 @@
<?php
class Upgrade19 extends Upgrade
{
public function upgrade()
{
$changed = false;
// jestlize je opravnene udelat upgrade, tak provest
if ($this->checkRightfulness_1()) {
$this->makeChanges_1();
$changed = true;
}
// jestlize je opravnene udelat upgrade, tak provest
if ($this->checkRightfulness_2()) {
$this->makeChanges_2();
$changed = true;
}
// jestlize je opravnene udelat upgrade, tak provest
if ($this->checkRightfulness_3()) {
$this->makeChanges_3();
$changed = true;
}
// jestlize je opravnene udelat upgrade, tak provest
if (findModule('payments')) {
if ($this->checkRightfulness_4()) {
$this->makeChanges_4();
$changed = true;
}
}
if (findModule('order_payment')) {
if ($this->checkRightfulness_5()) {
$this->makeChanges_5();
$changed = true;
}
if ($this->checkRightfulness_6()) {
$this->makeChanges_6();
$changed = true;
}
}
if ($this->checkRightfulness_7()) {
$this->makeChanges_7();
$changed = true;
}
if ($changed == false) {
$this->noChanges();
}
$this->printResult();
}
// overi, jestli je opravnene provest upgrade
public function checkRightfulness_1()
{
$change = true;
$SQL = sqlQuery('SHOW FIELDS FROM '.getTableName('products'));
while ($row = sqlFetchArray($SQL)) {
if ($row['Field'] == 'position') {
$change = false;
break;
}
}
return $change;
}
// provest samotny upgrade
public function makeChanges_1()
{
$SQL = sqlQuery('ALTER TABLE '.getTableName('products').' ADD `position` INT NULL DEFAULT NULL');
$this->upgradeOK();
}
// overi, jestli je opravnene provest upgrade
public function checkRightfulness_2()
{
$change = false;
$SQL = sqlQuery('SHOW FIELDS FROM '.getTableName('discounts'));
while ($row = sqlFetchArray($SQL)) {
if ($row['Field'] == 'unit') {
$change = strpos($row['Type'], 'product') === false;
break;
}
}
return $change;
}
// provest samotny upgrade
public function makeChanges_2()
{
sqlQuery('ALTER TABLE '.getTableName('discounts')." CHANGE `unit` `unit` ENUM( 'perc', 'price', 'product' ) NOT NULL DEFAULT 'perc'");
$this->upgradeOK();
}
// overi, jestli je opravnene provest upgrade
public function checkRightfulness_3()
{
return false; // Overriden by later update
$change = false;
$SQL = sqlQuery('SHOW FIELDS FROM '.getTableName('order_items'));
while ($row = sqlFetchArray($SQL)) {
if ($row['Field'] == 'note' && $row['Null'] == 'NO') {
$change = true;
break;
}
}
return $change;
}
// provest samotny upgrade
public function makeChanges_3()
{
sqlQuery('ALTER TABLE '.getTableName('order_items').'
CHANGE `note` `note` TINYTEXT NULL DEFAULT NULL ');
$this->upgradeOK();
}
// overi, jestli je opravnene provest upgrade
public function checkRightfulness_4()
{
$change = true;
$SQL = sqlQuery('SHOW FIELDS FROM '.getTableName('delivery_type'));
while ($row = sqlFetchArray($SQL)) {
if ($row['Field'] == 'payment_class') {
$change = false;
break;
}
}
return $change;
}
// provest samotny upgrade
public function makeChanges_4()
{
sqlQuery('ALTER TABLE '.getTableName('delivery_type').'
ADD `payment_class` VARCHAR(20) NULL DEFAULT NULL ');
$this->upgradeOK();
}
// overi, jestli je opravnene provest upgrade
public function checkRightfulness_5()
{
$change = true;
$SQL = sqlQuery("SHOW TABLES LIKE '".getTableName('order_payments', false)."'");
if (sqlNumRows($SQL) > 0) {
$change = false;
}
return $change;
}
// provest samotny upgrade
public function makeChanges_5()
{
sqlQuery('CREATE TABLE IF NOT EXISTS '.getTableName('order_payments').' (
`id` INT(11) NOT NULL AUTO_INCREMENT,
`id_order` INT(11) UNSIGNED NOT NULL,
`price` DOUBLE NOT NULL,
`date` DATE NOT NULL,
`note` VARCHAR(100) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `id_order` (`id_order`)
) ENGINE=InnoDB ');
$this->upgradeOK();
}
// overi, jestli je opravnene provest upgrade
public function checkRightfulness_6()
{
$change = true;
$SQL = sqlQuery('SHOW FIELDS FROM '.getTableName('order_payments'));
while ($row = sqlFetchArray($SQL)) {
if ($row['Field'] == 'status') {
$change = false;
break;
}
}
return $change;
}
// provest samotny upgrade
public function makeChanges_6()
{
sqlQuery('ALTER TABLE '.getTableName('order_payments').'
ADD `status` INT(11) NOT NULL DEFAULT 0,
ADD `payment_data` TEXT NULL DEFAULT NULL');
$this->upgradeOK();
}
// overi, jestli je opravnene provest upgrade
public function checkRightfulness_7()
{
return sqlNumRows(sqlQuery('SELECT * FROM '.getTableName('admins')." WHERE `privilege` LIKE '%PROD_STOCK%'")) == 0
&& Settings::getDefault()->user_rights_version == 0;
}
// provest samotny upgrade
public function makeChanges_7()
{
sqlQuery('UPDATE '.getTableName('admins')." SET privilege=REPLACE(privilege, 'PROD_EDIT', 'PROD_EDIT|PROD_STOCK')");
$this->upgradeOK();
}
}