Skip to content

Commit

Permalink
Allow to filter investments by contract number (#572)
Browse files Browse the repository at this point in the history
Co-authored-by: Daniel Subiabre <daniel.subiabre@platoniq.net>
  • Loading branch information
subiabre and subiabre authored Nov 6, 2023
1 parent 08ef465 commit 4d7e460
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Resources/templates/default/admin/accounts/list.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@
<input type="text" id ="id-filter" name="id" value ="<?= $filters['id']?>" />
</div>

<div style="float:left;margin:5px;">
<label for="contract-filter">N. de contrato:</label><br />
<input type="text" id ="contract-filter" name="contract" value ="<?= $filters['contract']?>" />
</div>

<br clear="both" />

<div style="float:left;margin:5px;">
Expand Down
1 change: 1 addition & 0 deletions src/Goteo/Controller/Admin/AccountsSubController.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ class AccountsSubController extends AbstractSubController {
'procStatus' => 'all',
'amount' => '',
'maxamount' => '',
'contract' => ''
);

/**
Expand Down
8 changes: 8 additions & 0 deletions src/Goteo/Model/Invest.php
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,10 @@ public static function getSQLFilter($filters = []) {
}
}

if (!empty($filters['contract'])) {
$sqlFilter[] = "contract.number = :contract";
$values[':contract'] = $filters['contract'];
}
if (!empty($filters['date_from'])) {
$sqlFilter[] = "invest.invested >= :date_from";
$values[':date_from'] = $filters['date_from'];
Expand Down Expand Up @@ -603,6 +607,8 @@ public static function getList ($filters = array(), $node = null, $offset = 0, $
ON invest.admin = user.id
LEFT JOIN invest_reward
ON invest_reward.invest = invest.id
LEFT JOIN `contract`
ON contract.project = invest.project
$sqlFilter";

// echo sqldbg($sql, $values)."\n";
Expand Down Expand Up @@ -633,6 +639,8 @@ public static function getList ($filters = array(), $node = null, $offset = 0, $
ON invest.admin = user.id
LEFT JOIN invest_reward
ON invest_reward.invest = invest.id
LEFT JOIN `contract`
ON contract.project = invest.project
$sqlFilter
" . ($order ? "ORDER BY $order" : '') ."
LIMIT $offset, $limit
Expand Down

0 comments on commit 4d7e460

Please sign in to comment.