Skip to content

Commit

Permalink
0051829 added min date for order export
Browse files Browse the repository at this point in the history
implemented save routine into custom config form

implemented reading routine to custom form
  • Loading branch information
FCStephanAltmann committed Aug 6, 2019
1 parent 811b802 commit 05a6807
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 4 deletions.
3 changes: 3 additions & 0 deletions Controllers/Backend/viaebConfigForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ public function saveConnectionConfigAction() {
$this->configWriter->save('userPassword', $_REQUEST['userPassword'], $this->pluginName);
$this->configWriter->save('mainSystem', intval($_REQUEST['mainSystem']), $this->pluginName);
$this->configWriter->save('ordernumberMapping', intval($_REQUEST['ordernumberMapping']), $this->pluginName);

$this->configWriter->save('minOrderDate', str_replace(" ", "T", $_REQUEST['minOrderDate'], $this->pluginName));

$this->configWriter->save('baseCategory', intval($_REQUEST['baseCategory']), $this->pluginName);
$this->configWriter->save('ExportAllArticles', intval($_REQUEST['ExportAllArticles']), $this->pluginName);
$this->configWriter->save('targetShop', intval($_REQUEST['targetShop']), $this->pluginName);
Expand Down
14 changes: 14 additions & 0 deletions Resources/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,23 @@

<element type="button">
<name>Spacer3</name>
<label>Bestellexporteinstellungen</label>
<value>1</value>
</element>

<element type="date">
<name>minOrderDate</name>
<label lang="de">Bestellungen neuer als</label>
<label lang="en">Orders from</label>
<description>Nur Bestellungen neuer als das festgelegte Datum exportieren</description>
</element>

<element type="button">
<name>Spacer4</name>
<label>Bestellimporteinstellungen</label>
<value>1</value>
</element>

<element type="combo" required="true">
<name>targetShop</name>
<label lang="de">Zielshop für Bestellungen</label>
Expand Down
15 changes: 15 additions & 0 deletions Resources/views/backend/viaeb_config_form/view/config_window.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ Ext.define('Shopware.apps.viaebConfigForm.view.ConfigWindow', {
ordernumberMapping: '{s namespace="backend/viaebConfigForm" name=ordernumberMapping}Bestellnummer Mapping{/s}',
baseCategory: '{s namespace="backend/viaebConfigForm" name=baseCategory}Stammkategorie{/s}',
ExportAllArticles: '{s namespace="backend/viaebConfigForm" name=ExportAllArticles}Alle Artikel exportieren{/s}',
MinOrderDate: '{s namespace="backend/viaebConfigForm" name=MinOrderdate}Bestellungen exportieren ab{/s}',
targetShop: '{s namespace="backend/viaebConfigForm" name=targetShop}Zielshop für Bestellungen{/s}',
shipping: '{s namespace="backend/viaebConfigForm" name=shipping}Versandart{/s}',
customerGroup: '{s namespace="backend/viaebConfigForm" name=customerGroup}Kundengruppe{/s}',
Expand Down Expand Up @@ -129,6 +130,11 @@ Ext.define('Shopware.apps.viaebConfigForm.view.ConfigWindow', {
resetFieldValues: function (item) {
const me = this;

if(me.configValues['minOrderDate'] && me.configValues['minOrderDate'].includes('T')) {
var myDate = Ext.Date.parse(me.configValues['minOrderDate'].substring(0,10), 'Y-m-d');
me.configValues['minOrderDate'] = Ext.Date.format(myDate, 'd.m.Y');
}

if (item.name in me.configValues) {
item.setValue(me.configValues[item.name]);
}
Expand Down Expand Up @@ -369,6 +375,15 @@ Ext.define('Shopware.apps.viaebConfigForm.view.ConfigWindow', {
forceSelection: false,
allowBlank: true,
},
{
xtype: 'datefield',
fieldLabel: me.snippets.MinOrderDate,
//dateFormat:'Y-m-dTH:i:s',
submitFormat:'Y-m-d 00:00:00',
format: 'd.m.Y',
name: 'minOrderDate',
allowBlank: true,
},
{
fieldLabel: me.snippets.ExportAllArticles,
store: me.createYesNoStore(),
Expand Down
20 changes: 17 additions & 3 deletions Services/Helper/ShopwareOrderHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace viaebShopwareAfterbuy\Services\Helper;

use Doctrine\ORM\OptimisticLockException;
use Shopware\Models\Attribute\Order as OrderAttributes;
use viaebShopwareAfterbuy\ValueObjects\Address as ValueAddress;
use viaebShopwareAfterbuy\ValueObjects\Order as ValueOrder;
use viaebShopwareAfterbuy\ValueObjects\OrderPosition;
Expand Down Expand Up @@ -336,14 +337,26 @@ public function setAfterBuyIds(array $values)
/**
* @return array
*/
public function getUnexportedOrders()
public function getUnexportedOrders(array $config)
{
$orders = $this->entityManager->createQueryBuilder()
$query = $this->entityManager->createQueryBuilder();

$query
->select(['orders'])
->from(ShopwareOrder::class, 'orders', 'orders.id')
->leftJoin('orders.attribute', 'attributes')
->where('attributes.afterbuyOrderId IS NULL')
->orWhere("attributes.afterbuyOrderId = ''")
->andWhere('orders.number != 0');

if(!empty($config["minOrderDate"])) {
$minOrderDate = new \DateTime($config["minOrderDate"]);

$query->andWhere('orders.orderTime > :minOrderDate')
->setParameters(array('minOrderDate' => $minOrderDate));
}

$orders = $query
->getQuery()
->setMaxResults(200)
->getResult();
Expand Down Expand Up @@ -394,7 +407,8 @@ public function getUnfullfilledOrders() {

$orders = $this->entityManager->createQueryBuilder()
->select(['attributes.afterbuyOrderId'])
->from(\Shopware\Models\Attribute\Order::class, 'attributes')
->from(OrderAttributes::class,
'attributes')
->leftJoin('attributes.order', 'orders')
->where('attributes.afterbuyOrderId IS NOT NULL')
->andWhere("attributes.afterbuyOrderId != ''")
Expand Down
2 changes: 1 addition & 1 deletion Services/ReadData/Internal/ReadOrdersService.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ public function read(array $filter) {
/**
* @var Repository $repo
*/
$data = $this->helper->getUnexportedOrders();
$data = $this->helper->getUnexportedOrders($this->config);

if(!$data) {
$this->logger->error('No data received', array('Orders', 'Read', 'Internal'));
Expand Down
18 changes: 18 additions & 0 deletions plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,24 @@
<link>https://www.via-connect.de/</link>
<author>ViA-Online GmbH</author>
<compatibility minVersion="5.3.0" />
<changelog version="0.9.12">
<changes lang="de">
<![CDATA[
<ul>
<li>New: added min order date for export</li>
<li>fixed: submission of unfinished orders</li>
</ul>
]]>
</changes>
<changes>
<![CDATA[
<ul>
<li>New: added min order date for export</li>
<li>fixed: submission of unfinished orders</li>
</ul>
]]></changes>
</changelog>

<changelog version="0.9.11">
<changes lang="de">
<![CDATA[
Expand Down

0 comments on commit 05a6807

Please sign in to comment.