Skip to content

Commit

Permalink
Add a purshase history
Browse files Browse the repository at this point in the history
  • Loading branch information
nivcoo authored and Eywek committed May 13, 2018
1 parent dfa665a commit 304ab3c
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 4 deletions.
10 changes: 8 additions & 2 deletions app/Controller/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -394,15 +394,21 @@ function profile()
if ($this->isConnected) {

$this->loadModel('User');

$this->set('title_for_layout', $this->User->getKey('pseudo'));
$this->layout = $this->Configuration->getKey('layout');
if ($this->EyPlugin->isInstalled('eywek.shop')) {
$this->loadModel('Shop.ItemsBuyHistory');
$this->loadModel('Shop.Item');
$histories = $this->ItemsBuyHistory->find('all', array(
'recursive' => 1,
'order' => 'ItemsBuyHistory.created DESC',
'conditions' => ['user_id' => $this->User->getKey('id')]
));
$this->set(compact('histories'));
$this->set('shop_active', true);
} else {
$this->set('shop_active', false);
}

$available_ranks = array(0 => $this->Lang->get('USER__RANK_MEMBER'), 2 => $this->Lang->get('USER__RANK_MODERATOR'), 3 => $this->Lang->get('USER__RANK_ADMINISTRATOR'), 4 => $this->Lang->get('USER__RANK_ADMINISTRATOR'), 5 => $this->Lang->get('USER__RANK_BANNED'));
$this->loadModel('Rank');
$custom_ranks = $this->Rank->find('all');
Expand Down
27 changes: 25 additions & 2 deletions app/View/User/profile.ctp
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,32 @@
</div>
</form>
<?php } ?>

<?php if($EyPlugin->isInstalled('eywek.shop')) { ?>
<hr>
<h3 class="text-center"><?= $Lang->get('SHOP__HISTORY_PURCHASES') ?></h3>
<table class="table table-bordered" id="users">
<thead>
<tr>
<th><?= $Lang->get('DASHBOARD__PURCHASES') ?> ID</th>
<th><?= $Lang->get('GLOBAL__CREATED') ?></th>
<th><?= $Lang->get('SHOP__ITEM_PRICE') ?></th>
<th class="right"><?= $Lang->get('SHOP__ITEMS') ?></th>
</tr>
</thead>
<tbody>
<?php
foreach ($histories as $value) { ?>
<tr>
<td><?= $value["ItemsBuyHistory"]["id"] ?></td>
<td><?= $value["ItemsBuyHistory"]["created"] ?></td>
<td><?= $value["Item"]["price"] ?></td>
<td><?= $value["Item"]["name"] ?></td>
</tr>
<?php } ?>
</tbody>
</table>
<?php } ?>
<?= $Module->loadModules('user_profile') ?>

</div>
</div>
</div>

0 comments on commit 304ab3c

Please sign in to comment.