Ordermanager/src/Application/Model/d3ordermanagerlist.php

229 lines
7.4 KiB
PHP
Raw Normal View History

2017-12-20 13:44:53 +01:00
<?php
/**
* This Software is the property of Data Development and is protected
* by copyright law - it is NOT Freeware.
*
* Any unauthorized use of this software without a valid license
* is a violation of the license agreement and will be prosecuted by
* civil and criminal law.
*
* http://www.shopmodule.com
*
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
* @author D3 Data Development - Daniel Seifert <support@shopmodule.com>
* @link http://www.oxidmodule.com
*/
namespace D3\Ordermanager\Application\Model;
use D3\ModCfg\Application\Model\Configuration\d3modprofilelist;
use D3\ModCfg\Application\Model\d3utils;
2018-02-20 09:37:52 +01:00
use D3\ModCfg\Application\Model\Exception\d3_cfg_mod_exception;
use D3\ModCfg\Application\Model\Exception\d3ShopCompatibilityAdapterException;
use Doctrine\DBAL\DBALException;
2019-05-15 11:31:56 +02:00
use Exception;
use OxidEsales\Eshop\Core\Database\Adapter\DatabaseInterface;
2018-02-20 09:37:52 +01:00
use OxidEsales\Eshop\Core\Exception\DatabaseConnectionException;
use OxidEsales\Eshop\Core\Exception\DatabaseErrorException;
use OxidEsales\Eshop\Core\Exception\StandardException;
2017-12-20 13:44:53 +01:00
class d3ordermanagerlist extends d3modprofilelist
{
/**
* List Object class name
*
* @var string
*/
protected $_sObjectsInListName = d3ordermanager::class;
/**
* @param $sFolderId
* @return d3ordermanagerlist
2018-02-20 09:37:52 +01:00
* @throws DBALException
* @throws DatabaseConnectionException
* @throws DatabaseErrorException
* @throws StandardException
* @throws d3ShopCompatibilityAdapterException
* @throws d3_cfg_mod_exception
2019-05-15 11:31:56 +02:00
* @throws Exception
2017-12-20 13:44:53 +01:00
*/
public function d3GetManuallyManagerJobsByFolder($sFolderId)
{
/** @var d3ordermanager $oListObject */
$oListObject = $this->getBaseObject();
$sFieldList = $oListObject->getSelectFields();
$sQ = "select $sFieldList from " . $oListObject->getViewName();
$sQ .= " where ";
2019-05-15 11:31:56 +02:00
$sQ = $this->d3AddActiveSnippet($oListObject, $sQ, true, false);
2017-12-20 13:44:53 +01:00
$sQ = $this->d3AddFolderSelection($sFolderId, $oListObject, $sQ);
$sQ .= " ORDER BY ".$oListObject->getViewName().".oxsort ASC, ".$oListObject->getViewName().".oxfolder ASC";
$this->selectString($sQ);
/** @var $oManager d3ordermanager */
foreach ($this->getArray() as $sKey => $oManager) {
if (false == $this->canExecutedManually($oManager)) {
$this->offsetUnset($sKey);
}
}
return $this;
}
2019-07-09 10:28:15 +02:00
/**
* @return d3ordermanagerlist
* @throws DBALException
* @throws DatabaseConnectionException
* @throws DatabaseErrorException
* @throws StandardException
* @throws d3ShopCompatibilityAdapterException
* @throws d3_cfg_mod_exception
* @throws Exception
*/
public function d3GetOrderSaveTriggeredManagerTasks()
{
/** @var d3ordermanager $oListObject */
$oListObject = $this->getBaseObject();
$sFieldList = $oListObject->getSelectFields();
$sQ = "select $sFieldList from " . $oListObject->getViewName();
$sQ .= " where ";
$sQ = $this->d3AddActiveSnippet($oListObject, $sQ, true, false);
$sQ .= ' AND '.$oListObject->getViewName().'.D3_OM_ORDERSAVETRIGGERED = 1';
$sQ .= " ORDER BY ".$oListObject->getViewName().".oxsort ASC, ".$oListObject->getViewName().".oxfolder ASC";
$this->selectString($sQ);
/** @var $oManager d3ordermanager */
foreach ($this->getArray() as $sKey => $oManager) {
if (false == $oManager->getLicenseActive()) {
$this->offsetUnset($sKey);
}
}
return $this;
}
/**
* @return $this
* @throws DBALException
* @throws DatabaseConnectionException
* @throws DatabaseErrorException
* @throws StandardException
* @throws d3ShopCompatibilityAdapterException
* @throws d3_cfg_mod_exception
*/
public function d3GetOrderFinishTriggeredManagerTasks()
{
/** @var d3ordermanager $oListObject */
$oListObject = $this->getBaseObject();
$sFieldList = $oListObject->getSelectFields();
$sQ = "select $sFieldList from " . $oListObject->getViewName();
$sQ .= " where ";
$sQ = $this->d3AddActiveSnippet($oListObject, $sQ, true, false);
$sQ .= ' AND '.$oListObject->getViewName().'.D3_OM_ORDERFINISHTRIGGERED = 1';
$sQ .= " ORDER BY ".$oListObject->getViewName().".oxsort ASC, ".$oListObject->getViewName().".oxfolder ASC";
$this->selectString($sQ);
/** @var $oManager d3ordermanager */
foreach ($this->getArray() as $sKey => $oManager) {
if (false == $oManager->getLicenseActive()) {
$this->offsetUnset($sKey);
}
}
return $this;
}
2017-12-20 13:44:53 +01:00
/**
* @param d3ordermanager $oManager
*
* @return bool
2018-02-20 09:37:52 +01:00
* @throws DatabaseConnectionException
* @throws d3ShopCompatibilityAdapterException
* @throws d3_cfg_mod_exception
* @throws DBALException
* @throws DatabaseErrorException
* @throws StandardException
2017-12-20 13:44:53 +01:00
*/
public function canExecutedManually(d3ordermanager $oManager)
{
return $oManager->getFieldData('D3_OM_EXECMANUALLY') &&
$oManager->getLicenseActive();
}
/**
* @param d3ordermanager $oListObject
* @param $sQ
2018-02-20 09:37:52 +01:00
* @param bool $blManually
2019-05-15 11:31:56 +02:00
* @param bool $blUseCommonActiveCheck (oxactive field)
2017-12-20 13:44:53 +01:00
*
* @return string
2018-02-20 09:37:52 +01:00
* @throws DatabaseConnectionException
2019-05-15 11:31:56 +02:00
* @throws Exception
2017-12-20 13:44:53 +01:00
*/
2019-05-15 11:31:56 +02:00
public function d3AddActiveSnippet(d3ordermanager $oListObject, $sQ, $blManually = false, $blUseCommonActiveCheck = true)
2017-12-20 13:44:53 +01:00
{
$sActiveSnippet = $oListObject->getSqlActiveSnippet();
2019-05-15 11:31:56 +02:00
/** @var d3utils $d3Utils */
$d3Utils = d3GetModCfgDIC()->get(d3utils::class);
if ($blUseCommonActiveCheck && $sActiveSnippet) {
2017-12-20 13:44:53 +01:00
$sQ .= " $sActiveSnippet ";
} else {
$sQ .= " 1 ";
}
if ($blManually) {
2019-05-15 11:31:56 +02:00
$sFieldName = $d3Utils->getMultiLangFieldName(
2017-12-20 13:44:53 +01:00
'D3_OM_EXECMANUALLY',
'',
$oListObject
);
} else {
2019-05-15 11:31:56 +02:00
$sFieldName = $d3Utils->getMultiLangFieldName(
2017-12-20 13:44:53 +01:00
'oxactive',
'',
$oListObject
);
}
$sQ .= " AND " . $oListObject->getViewName() . "." . $sFieldName . " = 1 ";
return $sQ;
}
/**
* @param $sFolderId
* @param d3ordermanager $oListObject
* @param $sQ
*
* @return string
2019-05-15 11:31:56 +02:00
* @throws Exception
2017-12-20 13:44:53 +01:00
*/
public function d3AddFolderSelection($sFolderId, d3ordermanager $oListObject, $sQ)
{
2019-05-15 11:31:56 +02:00
/** @var DatabaseInterface $oDb */
$oDb = d3GetModCfgDIC()->get('d3ox.ordermanager.'.DatabaseInterface::class.'.num');
2017-12-20 13:44:53 +01:00
if ($sFolderId && $sFolderId != '-1') {
2019-05-15 11:31:56 +02:00
$sQ .= " AND " . $oListObject->getViewName() . ".oxfolder = " . $oDb->quote($sFolderId);
2017-12-20 13:44:53 +01:00
}
return $sQ;
}
/**
* @param bool|string $iCronJobId
*/
public function setCronJobId($iCronJobId)
{
/** @var d3ordermanager $oBaseObject */
$oBaseObject = $this->getBaseObject();
$oBaseObject->setCronJobIdFilter($iCronJobId);
}
}