Skip to content

Commit

Permalink
RATEPLUG-182: improve admin components
Browse files Browse the repository at this point in the history
  • Loading branch information
rommelfreddy authored Apr 22, 2021
1 parent 4c66590 commit 90b3370
Show file tree
Hide file tree
Showing 22 changed files with 175 additions and 202 deletions.
58 changes: 16 additions & 42 deletions Controllers/Backend/RatepayLogging.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,52 +6,31 @@
* file that was distributed with this source code.
*/

use Doctrine\ORM\Tools\Pagination\Paginator;
use RpayRatePay\Component\Model\ShopwareCustomerWrapper;
use RpayRatePay\Helper\XmlHelper;
use RpayRatePay\Models\Log;

class Shopware_Controllers_Backend_RatepayLogging extends Shopware_Controllers_Backend_ExtJs
class Shopware_Controllers_Backend_RatepayLogging extends Shopware_Controllers_Backend_Application
{

/**
* index action is called if no other action is triggered
*
* @return void
*/
public function indexAction()
{
$this->View()->assign('title', 'Ratepay-Logging');
}
protected $model = Log::class;
protected $alias = 'log';

/**
* This Action loads the loggingdata from the datebase into the backendview
*/
public function loadLogEntriesAction()
protected function getListQuery()
{
$start = (int)$this->Request()->getParam('start');
$limit = (int)$this->Request()->getParam('limit');
$orderId = (int)$this->Request()->getParam('orderId');

$logRepo = $this->getModelManager()->getRepository(Log::class);

$qb = $logRepo->createQueryBuilder('log');
$qb->addSelect('e_order')
$builder = parent::getListQuery();
$builder->addSelect('e_order')
->addSelect('billing_address')
->leftJoin('log.order', 'e_order')
->leftJoin('e_order.billing', 'billing_address')
->setMaxResults($limit)
->setFirstResult($start)
->orderBy('log.date', 'DESC');
return $builder;
}

if ($orderId) {
$qb->andWhere($qb->expr()->eq('e_order.id', ':order_id'))
->setParameter('order_id', $orderId);
}
protected function getList($offset, $limit, $sort = [], $filter = [], array $wholeParams = [])
{
$results = parent::getList($offset, $limit, $sort, $filter, $wholeParams);

$paginator = new Paginator($qb);
$results = $paginator->getQuery()->getArrayResult();
foreach ($results as &$result) {
foreach ($results['data'] as &$result) {
$matchesRequest = [];
preg_match("/(.*)(<\?.*)/s", $result['request'], $matchesRequest);
$result['request'] = $matchesRequest[1] . "\n" . $this->formatXml(trim($matchesRequest[2]));
Expand All @@ -66,16 +45,11 @@ public function loadLogEntriesAction()
$result['firstname'] = $result['order']['billing']['firstName'];
$result['lastname'] = $result['order']['billing']['lastName'];
}

unset($result['order']);
}
unset($result);

$this->View()->assign(
[
'data' => $results,
'total' => $paginator->count(),
'success' => true
]
);

return $results;
}

/**
Expand Down
20 changes: 0 additions & 20 deletions Controllers/Backend/RatepayOrderDetail.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,26 +83,6 @@ public function preDispatch()
}
}

/**
* Loads the History for the given Order
*/
public function loadHistoryStoreAction()
{
//TODO DQL & Models + update store in ExtJs to use own controller
$orderId = $this->Request()->getParam('orderId');
$sql = 'SELECT * FROM `rpay_ratepay_order_history`'
. ' WHERE `orderId`=? '
. 'ORDER BY `id` DESC';
$history = Shopware()->Db()->fetchAll($sql, [$orderId]);

$this->View()->assign(
[
'data' => $history,
'success' => true
]
);
}

/**
* This Action loads the data from the datebase into the backendview
*/
Expand Down
17 changes: 17 additions & 0 deletions Controllers/Backend/RatepayOrderHistory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

use RpayRatePay\Models\OrderHistory;

/**
* Copyright (c) 2020 Ratepay GmbH
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
class Shopware_Controllers_Backend_RatepayOrderHistory extends Shopware_Controllers_Backend_Application
{

protected $model = OrderHistory::class;
protected $alias = 'history';

}
16 changes: 10 additions & 6 deletions Resources/views/backend/ratepay_logging/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,20 @@
*/
Ext.define('Shopware.apps.RatepayLogging', {
extend: 'Enlight.app.SubApplication',

name: 'Shopware.apps.RatepayLogging',
bulkLoad: true,

loadPath: '{url action=load}',
bulkLoad: true,

controllers: ['Main'],
models: ['Main'],

views: ['main.Window'],
store: ['List'],

models: ['Log'],
stores: ['Log'],

launch: function () {
var me = this;
mainController = me.getController('Main');
return mainController.mainWindow;
return this.getController('Main').mainWindow;
}
});
8 changes: 2 additions & 6 deletions Resources/views/backend/ratepay_logging/controller/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,8 @@
*/
Ext.define('Shopware.apps.RatepayLogging.controller.Main', {
extend: 'Ext.app.Controller',
mainWindow: null,

init: function () {
var me = this;
me.mainWindow = me.getView('main.Window').create({
listStore: me.getStore('List').load()
});
me.callParent(arguments);
this.mainWindow = this.getView('main.Window').create({ }).show();
}
});
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,7 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
Ext.define('Shopware.apps.RatepayOrder.model.Log', {
Ext.define('Shopware.apps.RatepayLogging.model.Log', {
extend: 'Ext.data.Model',
fields: ['date', 'version', 'operation', 'subOperation', 'transactionId', 'firstname', 'lastname', 'request', 'response', 'status_code'],
proxy: {
type: 'ajax',
api: {
read: '{url controller="RatepayLogging" action="loadLogEntries"}'
},
reader: {
type: 'json',
root: 'data',
totalProperty: 'total'
}
}
});
21 changes: 0 additions & 21 deletions Resources/views/backend/ratepay_logging/model/main.js

This file was deleted.

13 changes: 0 additions & 13 deletions Resources/views/backend/ratepay_logging/store/list.js

This file was deleted.

17 changes: 17 additions & 0 deletions Resources/views/backend/ratepay_logging/store/log.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
* Copyright (c) 2020 Ratepay GmbH
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
Ext.define('Shopware.apps.RatepayLogging.store.Log', {
extend: 'Shopware.store.Listing',

configure: function () {
return {
controller: 'RatepayLogging'
};
},

model: 'Shopware.apps.RatepayLogging.model.Log'
});
6 changes: 4 additions & 2 deletions Resources/views/backend/ratepay_logging/view/main/window.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ Ext.define('Shopware.apps.RatepayLogging.view.main.Window', {

initComponent: function () {
var me = this;
me.store = me.listStore;
me.store = Ext.create('Shopware.apps.RatepayLogging.store.Log')
me.store.load();

me.items = [
me.createOverviewGrid(me),
me.createDetailGrid(me)
Expand All @@ -32,7 +34,7 @@ Ext.define('Shopware.apps.RatepayLogging.view.main.Window', {
return Ext.create('Ext.grid.Panel', {
store: me.store,
border: false,
flex: 0,
flex: 1,
width: '100%',
columns: [
{
Expand Down
8 changes: 0 additions & 8 deletions Resources/views/backend/ratepay_order/includes.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,10 @@

//{block name="backend/order/application" append}


// Model components
//{include file="backend/ratepay_order/model/history.js"}
//{include file="backend/ratepay_order/model/log.js"}
//{include file="backend/ratepay_order/model/position.js"}

// Store components
//{include file="backend/ratepay_order/store/history.js"}
//{include file="backend/ratepay_order/store/log.js"}
//{include file="backend/ratepay_order/store/position.js"}

// View components
Expand All @@ -27,7 +22,4 @@
//{include file="backend/ratepay_order/view/detail/tabs/positions.js"}
//{include file="backend/ratepay_order/view/detail/window.js"}




//{/block}
20 changes: 0 additions & 20 deletions Resources/views/backend/ratepay_order/model/history.js

This file was deleted.

13 changes: 0 additions & 13 deletions Resources/views/backend/ratepay_order/store/history.js

This file was deleted.

13 changes: 0 additions & 13 deletions Resources/views/backend/ratepay_order/store/log.js

This file was deleted.

Loading

0 comments on commit 90b3370

Please sign in to comment.