Skip to content

Commit

Permalink
IOMAD: /blocks/iomad_commerce/orderslist is throwing errors when tryi…
Browse files Browse the repository at this point in the history
…ng to filter by name #1827
  • Loading branch information
turf212 committed May 3, 2023
1 parent b9fc049 commit 8098c3b
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions blocks/iomad_commerce/classes/tables/orders_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,4 +143,36 @@ public function col_actions($row) {
}
return $editbutton;
}

/**
* @return string sql to add to where statement.
*/
function get_sql_where() {
global $DB, $SESSION;

$uniqueid = 'block_iomad_commerce_orders_table';

if (isset($SESSION->flextable[$uniqueid])) {
$prefs = $SESSION->flextable[$uniqueid];
} else if (!$prefs = json_decode(get_user_preferences("flextable_{$uniqueid}", ''), true)) {
return '';
}

$conditions = array();
$params = array();

static $i = 0;
$i++;

if (!empty($prefs['i_first'])) {
$conditions[] = $DB->sql_like('u.firstname', ':ifirstc'.$i, false, false);
$params['ifirstc'.$i] = $prefs['i_first'].'%';
}
if (!empty($prefs['i_last'])) {
$conditions[] = $DB->sql_like('u.lastname', ':ilastc'.$i, false, false);
$params['ilastc'.$i] = $prefs['i_last'].'%';
}

return array(implode(" AND ", $conditions), $params);
}
}

0 comments on commit 8098c3b

Please sign in to comment.