Skip to content

Commit

Permalink
SW-8216 add pager to downloads
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcel Schmäing committed Apr 1, 2014
1 parent 5ebb790 commit 8fc8a28
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 11 deletions.
2 changes: 1 addition & 1 deletion UPGRADE.md
Expand Up @@ -9,7 +9,7 @@ In this document you will find a changelog of the important changes related to t
* Deprecation: The Database Column impressions in s_articles_details in now deprecated. Please use the s_statistics_article_impression table.
* `Shopware_Components_Plugin_Bootstrap` now has a `addFormTranslations()` method to facilitate translations creation for forms.
* Removed view variables `sOrders` and `sNotes` from `/engine/Shopware/Controllers/Frontend/Account.php` index action
* The method `sGetOpenOrderData` in `/engine/core/class/sAdmin.php` returns now a different array structure and will accept new optional parameters
* The methods `sGetOpenOrderData` and `sGetDownloads` in `/engine/core/class/sAdmin.php` will now return a different array structure and will accept new optional parameters to provide a pager functionality
* Added X-Sendfile support for ESD downloads. `redirectDownload` configuration variable is now deprecated, `esdDownloadStrategy` should be used instead
* Deprecation: `/engine/Shopware/Models/Payment/Repository.php:` `getPaymentsQuery` and `getPaymentsQueryBuilder` use `getActivePaymentsQuery` and `getActivePaymentsQueryBuilder` instead.

Expand Down
7 changes: 6 additions & 1 deletion engine/Shopware/Controllers/Frontend/Account.php
Expand Up @@ -175,7 +175,12 @@ public function ordersAction()
*/
public function downloadsAction()
{
$this->View()->sDownloads = $this->admin->sGetDownloads();
$destinationPage = (int)$this->Request()->sPage;
$orderData = $this->admin->sGetDownloads($destinationPage);
$this->View()->sDownloads = $orderData["orderData"];
$this->View()->sNumberPages = $orderData["numberOfPages"];
$this->View()->sPages = $orderData["pages"];

//this has to be assigned here because the config method in smarty can't handle array structures
$this->View()->sDownloadAvailablePaymentStatus = Shopware()->Config()->get('downloadAvailablePaymentStatus');
}
Expand Down
20 changes: 13 additions & 7 deletions engine/core/class/sAdmin.php
Expand Up @@ -2060,19 +2060,18 @@ public function sSaveRegister($paymentObject=null)

}




/**
* Account - get purchased instant downloads
* @access public
* @param int $destinationPage
* @param int $perPage
* @return array - Data from orders who contains instant downloads
*/
public function sGetDownloads()
public function sGetDownloads($destinationPage = 1, $perPage = 10)
{
$getOrders = $this->sSYSTEM->sDB_CONNECTION->GetAll("
SELECT id, ordernumber, invoice_amount, invoice_amount_net, invoice_shipping, invoice_shipping_net, DATE_FORMAT(ordertime,'%d.%m.%Y %H:%i') AS datum, status,cleared, comment
FROM s_order WHERE userID=? AND s_order.status>=0 ORDER BY ordertime DESC LIMIT 10
FROM s_order WHERE userID=? AND s_order.status>=0 ORDER BY ordertime DESC LIMIT 500
",array($this->sSYSTEM->_SESSION["sUserId"]));

foreach ($getOrders as $orderKey => $orderValue) {
Expand Down Expand Up @@ -2111,7 +2110,6 @@ public function sGetDownloads()
$getOrderDetails[$orderDetailsKey]["serial"] = implode(",",$numbers);
// Building download-link
$getOrderDetails[$orderDetailsKey]["esdLink"] = $this->sSYSTEM->sCONFIG["sBASEFILE"].'?sViewport=account&sAction=download&esdID='.$orderDetailsValue['id'];
//$getOrderDetails[$orderDetailsKey]["esdLink"] = "http://".$this->sSYSTEM->sCONFIG["sBASEPATH"]."/engine/core/php/loadesd.php?id=".$orderDetailsValue["id"];
} else {
unset($getOrderDetails[$orderDetailsKey]);
}
Expand All @@ -2127,7 +2125,14 @@ public function sGetDownloads()

$getOrders = Enlight()->Events()->filter('Shopware_Modules_Admin_GetDownloads_FilterResult', $getOrders, array('subject'=>$this,'id'=>$this->sSYSTEM->_SESSION["sUserId"]));

return $getOrders;
// Make Array with page-structure to render in template
$numberOfPages = ceil(count($getOrders) / $perPage);
$offset = ($destinationPage - 1) * $perPage;
$orderData["orderData"] = array_slice($getOrders, $offset, $perPage, true);
$orderData["numberOfPages"] = $numberOfPages;
$orderData["pages"] = $this->getPagerStructure($destinationPage, $numberOfPages);

return $orderData;

}

Expand Down Expand Up @@ -2275,6 +2280,7 @@ public function sGetOpenOrderData($destinationPage = 1, $perPage = 10)
*/
public function getPagerStructure($destinationPage, $numberOfPages, $additionalParams = array())
{
$destinationPage = !empty($destinationPage) ? $destinationPage : 1;
$pagesStructure = array();
$baseFile = $this->sSYSTEM->sCONFIG['sBASEFILE'];
if ($numberOfPages > 1) {
Expand Down
37 changes: 37 additions & 0 deletions templates/_default/frontend/account/downloads.tpl
Expand Up @@ -93,6 +93,43 @@
{/if}
{/foreach}
{/foreach}

<div class="space">&nbsp;</div>

{block name='frontend_account_downloads_actions_paging'}
{if $sPages.numbers|@count > 1}
<div class="listing_actions normal">
<div class="bottom">
<div class="paging">
<label>{se name='ListingPaging'}Blättern:{/se}</label>

{if $sPages.previous}
<a href="{$sPages.previous}" class="navi prev">
{s name="ListingTextPrevious"}&lt;{/s}
</a>
{/if}

{foreach from=$sPages.numbers item=page}
{if $page.markup}
<a title="" class="navi on">{$page.value}</a>
{else}
<a href="{$page.link}" title="" class="navi">
{$page.value}
</a>
{/if}
{/foreach}

{if $sPages.next}
<a href="{$sPages.next}" class="navi more">{s name="ListingTextNext"}&gt;{/s}</a>
{/if}
</div>
<div class="display_sites">
{se name="ListingTextSite"}Seite{/se} <strong>{if $sPage}{$sPage}{else}1{/if}</strong> {se name="ListingTextFrom"}von{/se} <strong>{$sNumberPages}</strong>
</div>
</div>
</div>
{/if}
{/block}
</div> <!-- TABLE END -->
{/if}
</div>
Expand Down
4 changes: 2 additions & 2 deletions templates/_emotion/frontend/_resources/styles/emotion.css
Expand Up @@ -364,8 +364,8 @@ div.orderdata_box div, #newsletterfrm, #frmRegister {background-color: #f7f7f7;}
#content div.inner .change_shipping div.alternative_shipping, #content div.inner .change_billing .shipping_address {border-color: #dfdfdf;}
#content .orders .orderoverview_active .lastrow {border-color: #dfdfdf;}
#content .orders .orderoverview_active .table_foot p.bold, #content .orders .orderoverview_active .table_foot div p {color:#333;}
#content .orders .listing_actions {width: 760px; padding-left: 10px; padding-right: 10px;}
#content .orders .listing_actions .bottom {border-top: none;}
#content .orders .listing_actions, #content .downloads .listing_actions {width: 760px; padding-left: 10px; padding-right: 10px;}
#content .orders .listing_actions .bottom, #content .downloads .listing_actions .bottom {border-top: none;}

.addresses .inner_container, .addresses .inner_container .select_billing, .addresses .inner_container .select_shipping, .account .password .inner_container {border-color: #dfdfdf;}
.password .outer {border-color: #dfdfdf;}
Expand Down

0 comments on commit 8fc8a28

Please sign in to comment.