Page 1 of 1

Filter table with closed date > 21 days ago

Posted: 2018-10-29 13:54
by bescott53
i thought this would be easy but i am struggling to filter a table. I am looking for a way to filter based on a number of days.

Re: Filter table with closed date > 21 days ago

Posted: 2018-10-29 16:13
by pbottcher
Hi,
what kind of filter are you looking for? Can you show an example.

Re: Filter table with closed date > 21 days ago

Posted: 2018-10-30 08:36
by jsetzer
This works for me:

Code: Select all

function YOURTABLENAME_init(&$options, $memberInfo, &$args) {
	
    $field_number = 6; // CHANGE THIS!
    $options->AllowFilters = true;
    addFilter(1, 'and', $field_number, '<', date('d/m/Y', strtotime('-21 days')));
    return TRUE;
}
Replace YOURTABLENAME and set field-number.

You may have a look here:
https://bigprof.com/appgini/tips-and-tu ... ult-filter
https://bigprof.com/appgini/tips-and-tu ... ers/part-1

Hope this helps,
Regards,
Jan

Re: Filter table with closed date > 21 days ago

Posted: 2018-11-05 13:51
by bescott53
thanks jsetzer, I was hoping to create a link in the nave menu for this, is there a way to do that?

Re: Filter table with closed date > 21 days ago

Posted: 2018-11-05 15:33
by bescott53
here is an example pbottcher

Code: Select all

$navLinks[] = array(
                                                'url' => 'http:xxxxxxxxxxxxxxxxxxxxxx/WDCD_view.php?SortField=8&SortDirection=asc&FilterAnd%5B1%5D=&FilterField%5B1%5D=8&FilterOperator%5B1%5D=like&FilterValue%5B1%5D=CD&FilterAnd%5B2%5D=and&FilterField%5B2%5D=21&FilterOperator%5B2%5D=not-equal-to&FilterValue%5B2%5D=Closed+Cancelled&FilterAnd%5B3%5D=and&FilterField%5B3%5D=21&FilterOperator%5B3%5D=not-equal-to&FilterValue%5B3%5D=Closed+Lost&FilterAnd%5B4%5D=and&FilterField%5B4%5D=21&FilterOperator%5B4%5D=not-equal-to&FilterValue%5B4%5D=Closed+Won&FilterAnd%5B5%5D=and&FilterField%5B5%5D=21&FilterOperator%5B5%5D=not-equal-to&FilterValue%5B5%5D=Won&FilterAnd%5B6%5D=and&FilterField%5B6%5D=21&FilterOperator%5B6%5D=not-equal-to&FilterValue%5B6%5D=Cancelled&FilterAnd%5B7%5D=and&FilterField%5B7%5D=21&FilterOperator%5B7%5D=not-equal-to&FilterValue%5B7%5D=Lost', 
                                                'title' => 'CD Exc Lost/Closed Opps', 
                                                'groups' => array('*'), // groups allowed to see this link, use '*' if you want to show the link to all groups
                                                'icon' => '',
                                                'table_group' => '3' // optional index of table group, default is 0
                                );

Re: Filter table with closed date > 21 days ago

Posted: 2018-11-06 14:08
by pbottcher
Hi you can try this:

Code: Select all

	$filterdate= date('Y-m-d',strtotime('-21 days'));
$navLinks[] = array(
                                                'url' => 'http:xxxxxxxxxxxxxxxxxxxxxx/WDCD_view.php?SortField=8&SortDirection=asc&FilterAnd%5B1%5D=&FilterField%5B1%5D=8&FilterOperator%5B1%5D=like&FilterValue%5B1%5D=CD&FilterAnd%5B2%5D=and&FilterField%5B2%5D=21&FilterOperator%5B2%5D=not-equal-to&FilterValue%5B2%5D=Closed+Cancelled&FilterAnd%5B3%5D=and&FilterField%5B3%5D=21&FilterOperator%5B3%5D=not-equal-to&FilterValue%5B3%5D=Closed+Lost&FilterAnd%5B4%5D=and&FilterField%5B4%5D=21&FilterOperator%5B4%5D=not-equal-to&FilterValue%5B4%5D=Closed+Won&FilterAnd%5B5%5D=and&FilterField%5B5%5D=21&FilterOperator%5B5%5D=not-equal-to&FilterValue%5B5%5D=Won&FilterAnd%5B6%5D=and&FilterField%5B6%5D=21&FilterOperator%5B6%5D=not-equal-to&FilterValue%5B6%5D=Cancelled&FilterAnd%5B7%5D=and&FilterField%5B7%5D=21&FilterOperator%5B7%5D=not-equal-to&FilterValue%5B7%5D=Lost&FilterField%5B8%5D=21&FilterOperator%5B8%5D=less-than&FilterValue%5B8%5D='.$filterdate, 
                                                'title' => 'CD Exc Lost/Closed Opps', 
                                                'groups' => array('*'), // groups allowed to see this link, use '*' if you want to show the link to all groups
                                                'icon' => '',
                                                'table_group' => '3' // optional index of table group, default is 0
                                );
I added

&FilterOperator%5B8%5D=less-than&FilterValue%5B8%5D='.$filterdate at the end of your filter.

Re: Filter table with closed date > 21 days ago

Posted: 2018-11-06 14:51
by bescott53
Thanks pböttcher, tried this now but the filter on the date is not working it just shows all records.

Re: Filter table with closed date > 21 days ago

Posted: 2018-11-06 17:18
by pbottcher
Hi,
sorry I forgot to state that you need to adjust the filter to match your date field. In my sample I used field nr. 21, but yours is for sure different.

FilterField%5B8%5D=21

Re: Filter table with closed date > 21 days ago

Posted: 2018-11-07 14:49
by bescott53
perfect, it works!