2024-04-19 16:15:46 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
2024-09-02 08:48:43 +02:00
|
|
|
* Copyright (c) D3 Data Development (Inh. Thomas Dartsch)
|
|
|
|
*
|
|
|
|
* For the full copyright and license information, please view
|
|
|
|
* the LICENSE file that was distributed with this source code.
|
|
|
|
*
|
|
|
|
* https://www.d3data.de
|
2024-04-19 16:15:46 +02:00
|
|
|
*
|
|
|
|
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
|
2024-09-02 08:48:43 +02:00
|
|
|
* @author D3 Data Development - Daniel Seifert <info@shopmodule.com>
|
|
|
|
* @link https://www.oxidmodule.com
|
2024-04-19 16:15:46 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
namespace D3\ModCfg\Application\Model\Maintenance\Actions;
|
|
|
|
|
|
|
|
use Doctrine\DBAL\Driver\Exception as DoctrineDriverException;
|
|
|
|
use Doctrine\DBAL\Exception as DoctrineException;
|
|
|
|
use Doctrine\DBAL\Query\QueryBuilder;
|
|
|
|
use Psr\Container\ContainerExceptionInterface;
|
|
|
|
use Psr\Container\NotFoundExceptionInterface;
|
|
|
|
|
|
|
|
class Object2DeliveryOrphans extends AbstractAction
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @return int
|
|
|
|
* @throws ContainerExceptionInterface
|
|
|
|
* @throws DoctrineDriverException
|
|
|
|
* @throws DoctrineException
|
|
|
|
* @throws NotFoundExceptionInterface
|
|
|
|
*/
|
|
|
|
public function getAffectedRows(): int
|
|
|
|
{
|
|
|
|
$oQB = $this->getBaseQuery('o2d');
|
|
|
|
$oQB->select('count(*)')
|
|
|
|
->setMaxResults(1);
|
|
|
|
|
|
|
|
return (int) $oQB->execute()->fetchOne();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @throws ContainerExceptionInterface
|
|
|
|
* @throws DoctrineDriverException
|
|
|
|
* @throws DoctrineException
|
|
|
|
* @throws NotFoundExceptionInterface
|
|
|
|
*/
|
|
|
|
public function fixIt(): void
|
|
|
|
{
|
|
|
|
$this->fixAction(
|
|
|
|
$this->getBaseQuery('o2d'),
|
|
|
|
'o2d.oxid',
|
|
|
|
'oxobject2delivery',
|
|
|
|
'D3_CFG_CLRTMP_ASSIGNOBJ2DEL_SUCC'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param string $tableAlias
|
|
|
|
*
|
|
|
|
* @return QueryBuilder
|
|
|
|
* @throws ContainerExceptionInterface
|
|
|
|
* @throws NotFoundExceptionInterface
|
|
|
|
*/
|
|
|
|
protected function getBaseQuery(string $tableAlias): QueryBuilder
|
|
|
|
{
|
|
|
|
$oQB = $this->getQueryBuilder();
|
|
|
|
$oQB->from('oxobject2delivery', $tableAlias)
|
|
|
|
->leftJoin($tableAlias, 'oxarticles', 'art', $oQB->expr()->eq($tableAlias.'.oxobjectid', 'art.oxid'))
|
|
|
|
->leftJoin($tableAlias, 'oxdelivery', 'del', $oQB->expr()->eq($tableAlias.'.oxdeliveryid', 'del.oxid'))
|
|
|
|
->leftJoin($tableAlias, 'oxcountry', 'cou', $oQB->expr()->eq($tableAlias.'.oxobjectid', 'cou.oxid'))
|
|
|
|
->leftJoin($tableAlias, 'oxdeliveryset', 'des', $oQB->expr()->eq($tableAlias.'.oxdeliveryid', 'des.oxid'))
|
|
|
|
->where(
|
|
|
|
$oQB->expr()->or(
|
|
|
|
$oQB->expr()->and(
|
|
|
|
$oQB->expr()->eq($tableAlias.'.oxtype', $oQB->createNamedParameter('oxarticles')),
|
|
|
|
$oQB->expr()->or(
|
|
|
|
$oQB->expr()->isNull('art.oxid'),
|
|
|
|
$oQB->expr()->isNull('del.oxid')
|
|
|
|
)
|
|
|
|
),
|
|
|
|
$oQB->expr()->or(
|
|
|
|
$oQB->expr()->isNull('cou.oxid'),
|
|
|
|
$oQB->expr()->or(
|
|
|
|
$oQB->expr()->and(
|
|
|
|
$oQB->expr()->eq($tableAlias.'.oxtype', $oQB->createNamedParameter('oxcountry')),
|
|
|
|
$oQB->expr()->isNull('del.oxid')
|
|
|
|
),
|
|
|
|
$oQB->expr()->and(
|
|
|
|
$oQB->expr()->eq($tableAlias.'.oxtype', $oQB->createNamedParameter('oxdelset')),
|
|
|
|
$oQB->expr()->isNull('des.oxid')
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
return $oQB;
|
|
|
|
}
|
|
|
|
}
|