Ordermanager/src/Application/Controller/Admin/d3_cfg_ordermanageritem_ove...

413 regels
13 KiB
PHP

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\Controller\Admin;
use D3\ModCfg\Application\Controller\Admin\d3_cfg_mod_main;
2021-03-16 10:11:13 +01:00
use D3\ModCfg\Application\Model\Exception\d3_cfg_mod_exception;
use D3\ModCfg\Application\Model\Exception\d3ParameterNotFoundException;
use D3\ModCfg\Application\Model\Exception\d3ShopCompatibilityAdapterException;
use D3\Ordermanager\Application\Model\Actions\d3ordermanager_actionlist as ActionListModel;
use D3\Ordermanager\Application\Model\d3ordermanager as Manager;
use D3\Ordermanager\Application\Model\d3ordermanager_configurationcheck;
use D3\Ordermanager\Application\Model\Exceptions\d3ActionRequirementAbstract;
use D3\Ordermanager\Application\Model\Requirements\d3ordermanager_requirementlist as RequirementListModel;
2018-02-20 09:37:52 +01:00
use Doctrine\DBAL\DBALException;
2019-05-15 11:31:56 +02:00
use Exception;
2017-12-20 13:44:53 +01:00
use OxidEsales\Eshop\Application\Model\Order;
2018-02-20 09:37:52 +01:00
use OxidEsales\Eshop\Core\Exception\DatabaseConnectionException;
use OxidEsales\Eshop\Core\Exception\DatabaseErrorException;
2021-03-16 10:11:13 +01:00
use OxidEsales\Eshop\Core\Exception\StandardException;
2019-05-15 11:31:56 +02:00
use OxidEsales\Eshop\Core\Language;
2017-12-20 13:44:53 +01:00
use OxidEsales\Eshop\Core\Request;
2021-03-16 10:11:13 +01:00
use OxidEsales\Eshop\Core\UtilsView;
2019-07-09 10:28:15 +02:00
use oxsystemcomponentexception;
2017-12-20 13:44:53 +01:00
class d3_cfg_ordermanageritem_overview extends d3_cfg_mod_main
{
protected $_sSetModId = 'd3_ordermanager';
protected $_sModId = 'd3_ordermanager';
protected $_sThisTemplate = "d3_cfg_ordermanageritem_overview.tpl";
protected $_sMenuItemTitle = 'd3mxordermanager';
protected $_sMenuSubItemTitle = 'd3mxordermanager_items';
protected $_blUseOwnOxid = true;
protected $_aNaviItems = array(
'new' => array(
'sScript' => 'top.oxid.admin.editThis( -1 );return false;',
'sTranslationId' => 'D3_TOOLTIPS_NEWORDERMANAGER',
),
);
2021-03-16 10:11:13 +01:00
protected $_sD3ObjectClass = Manager::class;
2017-12-20 13:44:53 +01:00
protected $_sRequestData;
2021-03-16 10:11:13 +01:00
/**
* @return string
* @throws DBALException
* @throws DatabaseConnectionException
* @throws DatabaseErrorException
* @throws d3ShopCompatibilityAdapterException
* @throws d3_cfg_mod_exception
* @throws StandardException
*/
public function render()
{
try {
d3GetModCfgDIC()->set(
d3ordermanager_configurationcheck::class.'.args.ordermanager',
$this->getManager()
);
d3GetModCfgDIC()->setParameter(
d3ordermanager_configurationcheck::class.'.args.checktypes',
d3ordermanager_configurationcheck::REQUIREMENTS_AND_ACTIONS
);
/** @var d3ordermanager_configurationcheck $confCheck */
$confCheck = d3GetModCfgDIC()->get(d3ordermanager_configurationcheck::class);
$confCheck->checkThrowingExceptions();
} catch (d3ActionRequirementAbstract $e) {
/** @var UtilsView $utilsView */
$utilsView = d3GetModCfgDIC()->get('d3ox.ordermanager.'.UtilsView::class);
$utilsView->addErrorToDisplay($e);
}
return parent::render();
}
2019-05-15 11:31:56 +02:00
/**
* @return d3_cfg_ordermanageritem_action
* @throws Exception
*/
public function getActionAdminController()
{
return d3GetModCfgDIC()->get(d3_cfg_ordermanageritem_action::class);
}
/**
* @return d3_cfg_ordermanageritem_requ
* @throws Exception
*/
public function getRequirementAdminController()
{
return d3GetModCfgDIC()->get(d3_cfg_ordermanageritem_requ::class);
}
2017-12-20 13:44:53 +01:00
/**
2021-03-16 10:11:13 +01:00
* @param $method
* @param $arguments
2017-12-20 13:44:53 +01:00
*
* @return mixed
2019-05-15 11:31:56 +02:00
* @throws oxSystemComponentException
* @throws Exception
2017-12-20 13:44:53 +01:00
*/
2021-03-16 10:11:13 +01:00
public function __call($method, $arguments)
2017-12-20 13:44:53 +01:00
{
2019-05-15 11:31:56 +02:00
$oActionView = $this->getActionAdminController();
2021-03-16 10:11:13 +01:00
if (method_exists($oActionView, $method)) {
return call_user_func_array(array($oActionView, $method), $arguments);
2017-12-20 13:44:53 +01:00
}
2019-05-15 11:31:56 +02:00
$oRequView = $this->getRequirementAdminController();
2021-03-16 10:11:13 +01:00
if (method_exists($oRequView, $method)) {
return call_user_func_array(array($oRequView, $method), $arguments);
2017-12-20 13:44:53 +01:00
}
2021-03-16 10:11:13 +01:00
return parent::__call($method, $arguments);
2017-12-20 13:44:53 +01:00
}
2019-05-15 11:31:56 +02:00
/**
2021-03-16 10:11:13 +01:00
* @param Manager $oManager
* @return RequirementListModel
2019-05-15 11:31:56 +02:00
* @throws Exception
*/
2021-03-16 10:11:13 +01:00
public function getRequirementListObject(Manager $oManager)
2019-05-15 11:31:56 +02:00
{
d3GetModCfgDIC()->set(
2021-03-16 10:11:13 +01:00
RequirementListModel::class.'.args.ordermanager',
2019-05-15 11:31:56 +02:00
$oManager
);
2021-03-16 10:11:13 +01:00
return d3GetModCfgDIC()->get(RequirementListModel::class);
2019-05-15 11:31:56 +02:00
}
2017-12-20 13:44:53 +01:00
/**
* @return array
2019-05-15 11:31:56 +02:00
* @throws Exception
2017-12-20 13:44:53 +01:00
*/
public function getRequirementList()
{
2021-03-16 10:11:13 +01:00
/** @var Manager $oManager */
2017-12-20 13:44:53 +01:00
$oManager = $this->getProfile();
2019-05-15 11:31:56 +02:00
$oRequList = $this->getRequirementListObject($oManager);
2017-12-20 13:44:53 +01:00
$oRequList->setRequirements($oManager->getConfiguration()->getRequirementIdList());
return $oRequList->getRequirementList();
}
2019-05-15 11:31:56 +02:00
/**
2021-03-16 10:11:13 +01:00
* @param Manager $oManager
* @return ActionListModel
2019-05-15 11:31:56 +02:00
* @throws Exception
*/
2021-03-16 10:11:13 +01:00
public function getActionListObject(Manager $oManager)
2019-05-15 11:31:56 +02:00
{
d3GetModCfgDIC()->set(
2021-03-16 10:11:13 +01:00
ActionListModel::class.'.args.ordermanager',
2019-05-15 11:31:56 +02:00
$oManager
);
d3GetModCfgDIC()->set(
2021-03-16 10:11:13 +01:00
ActionListModel::class.'.args.order',
2019-05-15 11:31:56 +02:00
d3GetModCfgDIC()->get('d3ox.ordermanager.'.Order::class)
);
2021-03-16 10:11:13 +01:00
return d3GetModCfgDIC()->get(ActionListModel::class);
2019-05-15 11:31:56 +02:00
}
2017-12-20 13:44:53 +01:00
/**
* @return array
2019-05-15 11:31:56 +02:00
* @throws Exception
2017-12-20 13:44:53 +01:00
*/
public function getActionList()
{
2021-03-16 10:11:13 +01:00
/** @var Manager $oManager */
2017-12-20 13:44:53 +01:00
$oManager = $this->getProfile();
2019-05-15 11:31:56 +02:00
$oActionList = $this->getActionListObject($oManager);
2017-12-20 13:44:53 +01:00
$oActionList->setActions($oManager->getConfiguration()->getActionIdList());
return $oActionList->getActionList();
}
/**
* @return bool
*/
public function isEditMode()
{
return false;
}
2019-05-15 11:31:56 +02:00
/**
* @throws Exception
*/
2017-12-20 13:44:53 +01:00
public function setRequestData()
{
2019-05-15 11:31:56 +02:00
/** @var Request $request */
$request = d3GetModCfgDIC()->get('d3ox.ordermanager.'.Request::class);
$this->_sRequestData = $request->getRequestEscapedParameter('sRequestData');
}
/**
* @return string
*/
protected function _getRequestData()
{
return $this->_sRequestData;
2017-12-20 13:44:53 +01:00
}
/**
* @return int
2018-02-20 09:37:52 +01:00
* @throws DBALException
* @throws DatabaseConnectionException
* @throws DatabaseErrorException
2019-05-15 11:31:56 +02:00
* @throws d3ParameterNotFoundException
* @throws Exception
2017-12-20 13:44:53 +01:00
*/
public function getToFinishedCount()
{
2019-05-15 11:31:56 +02:00
/** @var Request $request */
$request = d3GetModCfgDIC()->get('d3ox.ordermanager.'.Request::class);
$iRequestCount = $request->getRequestEscapedParameter('toFinishedCount');
2017-12-20 13:44:53 +01:00
if ($this->canRequestData(__FUNCTION__)) {
2021-03-16 10:11:13 +01:00
/** @var Manager $oProfile */
2017-12-20 13:44:53 +01:00
$oProfile = $this->getProfile();
return $oProfile->getListGenerator()->getConcernedItemCount();
} elseif ($this->canUseRequestData($iRequestCount)) {
return $iRequestCount;
}
return '';
}
/**
* @return int
2018-02-20 09:37:52 +01:00
* @throws DBALException
* @throws DatabaseConnectionException
* @throws DatabaseErrorException
2019-05-15 11:31:56 +02:00
* @throws d3ParameterNotFoundException
* @throws Exception
2017-12-20 13:44:53 +01:00
*/
public function getFinishedCount()
{
2019-05-15 11:31:56 +02:00
/** @var Request $request */
$request = d3GetModCfgDIC()->get('d3ox.ordermanager.'.Request::class);
$iRequestCount = $request->getRequestEscapedParameter('finishedCount');
2017-12-20 13:44:53 +01:00
if ($this->canRequestData(__FUNCTION__)) {
2021-03-16 10:11:13 +01:00
/** @var Manager $oProfile */
2017-12-20 13:44:53 +01:00
$oProfile = $this->getProfile();
return $oProfile->getListGenerator()->getFinishedItemCount();
} elseif ($this->canUseRequestData($iRequestCount)) {
return $iRequestCount;
}
return '';
}
/**
* @return int
2018-02-20 09:37:52 +01:00
* @throws DBALException
* @throws DatabaseConnectionException
* @throws DatabaseErrorException
2019-05-15 11:31:56 +02:00
* @throws d3ParameterNotFoundException
* @throws Exception
2017-12-20 13:44:53 +01:00
*/
public function getFinishedMonthCount()
{
2019-05-15 11:31:56 +02:00
/** @var Request $request */
$request = d3GetModCfgDIC()->get('d3ox.ordermanager.'.Request::class);
$iRequestCount = $request->getRequestEscapedParameter('finishedMonthCount');
2017-12-20 13:44:53 +01:00
if ($this->canRequestData(__FUNCTION__)) {
2021-03-16 10:11:13 +01:00
/** @var Manager $oProfile */
2017-12-20 13:44:53 +01:00
$oProfile = $this->getProfile();
return $oProfile->getListGenerator()->getFinishedMonthItemCount();
} elseif ($this->canUseRequestData($iRequestCount)) {
return $iRequestCount;
}
return '';
}
/**
* @return int
2018-02-20 09:37:52 +01:00
* @throws DBALException
* @throws DatabaseConnectionException
* @throws DatabaseErrorException
2019-05-15 11:31:56 +02:00
* @throws d3ParameterNotFoundException
* @throws Exception
2017-12-20 13:44:53 +01:00
*/
public function getNotFinishedCount()
{
2019-05-15 11:31:56 +02:00
/** @var Request $request */
$request = d3GetModCfgDIC()->get('d3ox.ordermanager.'.Request::class);
$iRequestCount = $request->getRequestEscapedParameter('notFinishedCount');
2017-12-20 13:44:53 +01:00
if ($this->canRequestData(__FUNCTION__)) {
2021-03-16 10:11:13 +01:00
/** @var Manager $oProfile */
2017-12-20 13:44:53 +01:00
$oProfile = $this->getProfile();
return $oProfile->getListGenerator()->getNotFinishedItemCount();
} elseif ($this->canUseRequestData($iRequestCount)) {
return $iRequestCount;
}
return '';
}
/**
* @param $sFunctionName
*
* @return bool
2018-02-20 09:37:52 +01:00
* @throws DBALException
* @throws DatabaseConnectionException
* @throws DatabaseErrorException
2017-12-20 13:44:53 +01:00
*/
public function canRequestData($sFunctionName)
{
return !$this->getDataOnDemand()
2019-05-15 11:31:56 +02:00
|| $this->_getRequestData() == $sFunctionName;
2017-12-20 13:44:53 +01:00
}
/**
* @param $iRequestCount
*
* @return bool
2018-02-20 09:37:52 +01:00
* @throws DBALException
* @throws DatabaseConnectionException
* @throws DatabaseErrorException
2017-12-20 13:44:53 +01:00
*/
public function canUseRequestData($iRequestCount)
{
return $this->getDataOnDemand()
&& strlen($iRequestCount);
}
/**
* @return bool
2018-02-20 09:37:52 +01:00
* @throws DatabaseConnectionException
* @throws DBALException
* @throws DatabaseErrorException
2017-12-20 13:44:53 +01:00
*/
public function getDataOnDemand()
{
return $this->d3GetSet()->getValue('blCalcStatOnDemand');
}
/**
* @param $sRequestName
* @param $sFunctionName
*
* @return bool
2019-05-15 11:31:56 +02:00
* @throws Exception
2017-12-20 13:44:53 +01:00
*/
public function hasRequestedData($sRequestName, $sFunctionName)
{
2019-05-15 11:31:56 +02:00
/** @var Request $request */
$request = d3GetModCfgDIC()->get('d3ox.ordermanager.'.Request::class);
$iRequestCount = $request->getRequestEscapedParameter($sRequestName);
2017-12-20 13:44:53 +01:00
2019-05-15 11:31:56 +02:00
if (strlen($iRequestCount) || $this->_getRequestData() == $sFunctionName) {
2017-12-20 13:44:53 +01:00
return true;
}
return false;
}
2019-05-15 11:31:56 +02:00
/**
2021-03-16 10:11:13 +01:00
* @return Manager
2019-05-15 11:31:56 +02:00
* @throws Exception
*/
public function getManager()
{
2021-03-16 10:11:13 +01:00
/** @var Manager $manager */
$manager = d3GetModCfgDIC()->get(Manager::class);
$manager->load($this->getEditObjectId());
return $manager;
2019-05-15 11:31:56 +02:00
}
/**
* @return Language
* @throws Exception
*/
public function getLang()
{
return d3GetModCfgDIC()->get('d3ox.ordermanager.'.Language::class);
}
2017-12-20 13:44:53 +01:00
/**
* @param $sManagerId
* @return string
2019-05-15 11:31:56 +02:00
* @throws Exception
2017-12-20 13:44:53 +01:00
*/
public function getManagerTitle($sManagerId)
{
2019-05-15 11:31:56 +02:00
$oManager = $this->getManager();
2017-12-20 13:44:53 +01:00
if ($oManager->load($sManagerId)) {
return $oManager->getFieldData('oxtitle');
2021-03-16 10:11:13 +01:00
}
2017-12-20 13:44:53 +01:00
2019-05-15 11:31:56 +02:00
return $this->getLang()->translateString('D3_ORDERMANAGER_REQU_OTHERJOB_UNKNOWNJOBID').' "'.$sManagerId.'"';
2017-12-20 13:44:53 +01:00
}
}