Filter table with closed date > 21 days ago

Discussions related to customizing hooks. Hooks are documented at http://bigprof.com/appgini/help/advanced-topics/hooks/
Post Reply
bescott53

Filter table with closed date > 21 days ago

Post by bescott53 » 2018-10-29 13:54

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.

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1635
Joined: 2018-04-01 10:12

Re: Filter table with closed date > 21 days ago

Post by pbottcher » 2018-10-29 16:13

Hi,
what kind of filter are you looking for? Can you show an example.
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 1807
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

Re: Filter table with closed date > 21 days ago

Post by jsetzer » 2018-10-30 08:36

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
Kind regards,
<js />

My AppGini Blog:
https://appgini.bizzworxx.de/blog

You can help us helping you:
Please always put code fragments inside [code]...[/code] blocks for better readability

AppGini 24.10 Revision 1579 + all AppGini Helper tools

bescott53

Re: Filter table with closed date > 21 days ago

Post by bescott53 » 2018-11-05 13:51

thanks jsetzer, I was hoping to create a link in the nave menu for this, is there a way to do that?

bescott53

Re: Filter table with closed date > 21 days ago

Post by bescott53 » 2018-11-05 15:33

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
                                );

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1635
Joined: 2018-04-01 10:12

Re: Filter table with closed date > 21 days ago

Post by pbottcher » 2018-11-06 14:08

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.
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

bescott53

Re: Filter table with closed date > 21 days ago

Post by bescott53 » 2018-11-06 14:51

Thanks pböttcher, tried this now but the filter on the date is not working it just shows all records.

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1635
Joined: 2018-04-01 10:12

Re: Filter table with closed date > 21 days ago

Post by pbottcher » 2018-11-06 17:18

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
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

bescott53

Re: Filter table with closed date > 21 days ago

Post by bescott53 » 2018-11-07 14:49

perfect, it works!

Post Reply