2021-04-28 13:40:04 +02: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\DataWizard\Application\Model\Exports;
|
|
|
|
|
|
|
|
use D3\DataWizard\Application\Model\ExportBase;
|
2021-06-25 15:33:57 +02:00
|
|
|
use FormManager\Inputs\Date;
|
2021-04-28 13:40:04 +02:00
|
|
|
use OxidEsales\Eshop\Application\Model\Order;
|
|
|
|
use OxidEsales\Eshop\Core\Registry;
|
2021-06-25 15:33:57 +02:00
|
|
|
use FormManager\Factory as FormFactory;
|
2021-04-28 13:40:04 +02:00
|
|
|
|
|
|
|
class KeyFigures extends ExportBase
|
|
|
|
{
|
2021-06-25 15:33:57 +02:00
|
|
|
const STARTDATE_NAME = 'startdate';
|
|
|
|
const ENDDATE_NAME = 'enddate';
|
|
|
|
|
2021-04-28 13:40:04 +02:00
|
|
|
/**
|
|
|
|
* Shopkennzahlen
|
|
|
|
*/
|
|
|
|
|
2021-06-25 15:33:57 +02:00
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
/** @var Date $startDate */
|
|
|
|
$startDateValue = Registry::getRequest()->getRequestEscapedParameter(self::STARTDATE_NAME);
|
|
|
|
$startDate = FormFactory::date(
|
|
|
|
Registry::getLang()->translateString('D3_DATAWIZARD_EXPORTS_KEYFIGURES_FIELD_STARTDATE'),
|
|
|
|
[
|
|
|
|
'name' => self::STARTDATE_NAME,
|
|
|
|
'value' => $startDateValue
|
|
|
|
]
|
|
|
|
);
|
|
|
|
$this->registerFormElement($startDate);
|
|
|
|
|
|
|
|
/** @var Date $endDate */
|
|
|
|
$endDateValue = Registry::getRequest()->getRequestEscapedParameter(self::ENDDATE_NAME);
|
|
|
|
$endDate = FormFactory::date(
|
|
|
|
Registry::getLang()->translateString('D3_DATAWIZARD_EXPORTS_KEYFIGURES_FIELD_ENDDATE'),
|
|
|
|
[
|
|
|
|
'name' => self::ENDDATE_NAME,
|
|
|
|
'value' => $endDateValue
|
|
|
|
]
|
|
|
|
);
|
|
|
|
$this->registerFormElement($endDate);
|
|
|
|
}
|
|
|
|
|
2021-04-28 13:40:04 +02:00
|
|
|
/**
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getTitle() : string
|
|
|
|
{
|
|
|
|
return Registry::getLang()->translateString('D3_DATAWIZARD_EXPORTS_KEYFIGURES');
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function getQuery() : array
|
|
|
|
{
|
|
|
|
$orderTable = oxNew(Order::class)->getCoreTableName();
|
|
|
|
$ordersTitle = Registry::getLang()->translateString('D3_DATAWIZARD_EXPORTS_KEYFIGURES_ORDERSPERMONTH');
|
|
|
|
$basketsTitle = Registry::getLang()->translateString('D3_DATAWIZARD_EXPORTS_KEYFIGURES_BASKETSIZE');
|
|
|
|
$monthTitle = Registry::getLang()->translateString('D3_DATAWIZARD_EXPORTS_KEYFIGURES_MONTH');
|
|
|
|
|
2021-06-25 15:33:57 +02:00
|
|
|
$startDateValue = Registry::getRequest()->getRequestEscapedParameter(self::STARTDATE_NAME) ?: '1970-01-01';
|
|
|
|
$endDateValue = Registry::getRequest()->getRequestEscapedParameter(self::ENDDATE_NAME) ?: date('Y-m-d');
|
|
|
|
|
2021-04-28 13:40:04 +02:00
|
|
|
return [
|
|
|
|
'SELECT
|
|
|
|
DATE_FORMAT(oo.oxorderdate, "%Y-%m") as :monthTitle,
|
|
|
|
FORMAT(COUNT(oo.oxid), 0) AS :ordersTitle,
|
|
|
|
FORMAT(SUM(oo.OXTOTALBRUTSUM / oo.oxcurrate) / COUNT(oo.oxid), 2) as :basketsTitle
|
|
|
|
FROM '.$orderTable.' AS oo
|
2021-06-25 15:33:57 +02:00
|
|
|
WHERE oo.oxorderdate >= :startDate AND oo.oxorderdate <= :endDate
|
|
|
|
GROUP BY DATE_FORMAT(oo.oxorderdate, "%Y-%m")
|
|
|
|
ORDER BY DATE_FORMAT(oo.oxorderdate, "%Y-%m") DESC
|
2021-04-28 13:40:04 +02:00
|
|
|
LIMIT 30',
|
|
|
|
[
|
2021-06-25 15:33:57 +02:00
|
|
|
'startDate' => $startDateValue,
|
|
|
|
'endDate' => $endDateValue,
|
|
|
|
'monthTitle' => $monthTitle,
|
|
|
|
'ordersTitle' => $ordersTitle,
|
|
|
|
'basketsTitle' => $basketsTitle
|
2021-04-28 13:40:04 +02:00
|
|
|
]
|
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|