$ajax = false;
$get = $request->getQueryParams();
- if (
- ($request->getHeaderLine('X-Requested-With') === 'XMLHttpRequest')
- || isset($get['ajax'])
- && $get['ajax'] == 'true'
- ) {
- $ajax = true;
- }
-
switch ($type) {
case 'transactions':
$raw_type = 'transactions';
}
$filter_name = 'filter_' . $raw_type;
+ if (
+ ($request->getHeaderLine('X-Requested-With') === 'XMLHttpRequest')
+ || isset($get['ajax'])
+ && $get['ajax'] == 'true'
+ ) {
+ $ajax = true;
+ $filter_name .= '_ajax';
+ }
if (isset($this->session->$filter_name)) {
$filters = $this->session->$filter_name;
}
if ($type === 'contributions') {
- $filters->filtre_transactions = false;
if (isset($request->getQueryParams()['max_amount'])) {
$filters->filtre_transactions = true;
$filters->max_amount = (int)$request->getQueryParams()['max_amount'];
*/
public function filter(Request $request, Response $response, string $type = null): Response
{
+ $ajax = false;
$filter_name = 'filter_' . $type;
+ if ($request->getHeaderLine('X-Requested-With') === 'XMLHttpRequest') {
+ $ajax = true;
+ $filter_name .= '_ajax';
+ }
+
$post = $request->getParsedBody();
$error_detected = [];
}
if (isset($post['clear_filter'])) {
- $filters->reinit();
+ $filters->reinit($ajax);
} else {
- if (isset($post['max_amount'])) {
+ if (!isset($post['max_amount'])) {
$filters->max_amount = null;
}
/**
* Reinit default parameters
*
+ * @param boolean $ajax Called form an ajax query
+ *
* @return void
*/
- public function reinit()
+ public function reinit($ajax = false)
{
parent::reinit();
$this->date_field = self::DATE_BEGIN;
$this->start_date_filter = null;
$this->end_date_filter = null;
$this->payment_type_filter = null;
- $this->filtre_transactions = false;
$this->filtre_cotis_adh = null;
$this->filtre_cotis_children = false;
$this->from_transaction = false;
- $this->max_amount = null;
$this->selected = [];
+
+ if ($ajax === false) {
+ $this->max_amount = null;
+ $this->filtre_transactions = false;
+ }
}
/**
$('.contributions-selection .contribution_row input[type=checkbox]').hide();
//Initialize Fomantic components
- $('.contributions-selection .dropdown').dropdown()
- $('[id$="rangestart"], [id$="rangeend"]').calendar();
+ $('.contributions-selection .dropdown').dropdown();
+ {% include "elements/js/calendar.js.twig" %}
//Deactivate contributions list links
$('.contributions-selection tbody a').click(function(){