Hi all,
in a custom module I have successfully created a custom export query with the create_export_query function.
This works perfectly for csv and pdf export if in listview I use “Select all” method.
However it has no effect on pdf if I select only some records or only the current page. I am particularly interested in adding a condition in the WHERE clause.
I also tried injecting directly into the array $mass-> where_clauses in formLetterPdf, but to no avail.
When doing it from formLetterPdf, you probably need to add the field also to the previous parameter, $searchFields, in the format it expects.
Adding just to where_clauses doesn’t seem enough, based on what I see inside the function called (create_export_query_relate_link_patch, in include/utils.php)
Ultimately in pdf printing, the key point is this
$recordIds = explode (’,’, $ _REQUEST [‘uid’]);
This line is executed in case I select only a few records.
So the trick is to add an exception and unset records, if they don’t match the criterion.
Example:
if ($_REQUEST['module'] == 'myModule') {
foreach ($recordIds as $recordId) {
// here I do something and set my conditions
$key = array_search($recordId, $recordIds);
unset($recordIds[$key]);
}
}