Filter by year with buton in TV
Posted: 2022-07-14 07:58
Hi All,
Hope somebody can help ?
I am trying to add buttons to the Table Veiw to allow users to only see "This Year" or "Last Year" and then only "Confirmed Orders" for that filtered year, I have managed to add new buttons however the code attached to them does not work. ??
The code I have used in "invoices.tv.js" is as follows:
/* end of mass_update code */
jQuery(function(){
jQuery('.clearfix').after('<button class="btn btn-success btn-lg"" type="button" id="filter-button"><i class="glyphicon glyphicon glyphicon-print"></i> This Year</button>');
jQuery('button[id=filter-button]').click(function(){
window.location = 'invoices_view.php?SortField=&SortDirection=&FilterAnd%5B1%5D=and&FilterField%5B1%5D=11&FilterOperator%5B1%5D=greater-than-or-equal-to&FilterValue%5B1%5D=01%2F01%2F2022&FilterAnd%5B2%5D=and&FilterField%5B2%5D=11&FilterOperator%5B2%5D=less-than-or-equal-to&FilterValue%5B2%5D=31%2F12%2F2022';
});
});
jQuery(function(){
jQuery('.clearfix').after('<button class="btn btn-success btn-lg"" type="button" id="filter-button"><i class="glyphicon glyphicon glyphicon-print"></i> Last Year</button>');
jQuery('button[id=filter-button]').click(function(){
window.location = 'invoices_view.php?SortField=&SortDirection=&FilterAnd%5B1%5D=and&FilterField%5B1%5D=11&FilterOperator%5B1%5D=greater-than-or-equal-to&FilterValue%5B1%5D=01%2F01%2F2021&FilterAnd%5B2%5D=and&FilterField%5B2%5D=11&FilterOperator%5B2%5D=less-than-or-equal-to&FilterValue%5B2%5D=31%2F12%2F2021';
});
});
jQuery(function(){
jQuery('.clearfix').after('<button class="btn btn-success btn-lg"" type="button" id="filter-button"><i class="glyphicon glyphicon glyphicon-print"></i> Confirmed</button>');
jQuery('button[id=filter-button]').click(function(){
window.location = 'invoices_view.php?SortField=&SortDirection=&FilterAnd%5B1%5D=and&FilterField%5B1%5D=11&FilterOperator%5B1%5D=greater-than-or-equal-to&FilterValue%5B1%5D=01%2F01%2F2021&FilterAnd%5B2%5D=and&FilterField%5B2%5D=11&FilterOperator%5B2%5D=less-than-or-equal-to&FilterValue%5B2%5D=31%2F12%2F2021';
});
});
I have a code written in links-navmenu.php that works OK for current year but have to go to main menu to use which is not ideal ? this is the menu code:
/* This Year Invoices links */
$navLinks[] = array(
'url' => 'invoices_view.php?SortField=2+asc%2C3&SortDirection=asc&FilterAnd%5B1%5D=and&FilterField%5B1%5D=11&FilterOperator%5B1%5D=greater-than-or-equal-to&FilterValue%5B1%5D=01%2F04%2F' . date('Y') . '&FilterAnd%5B2%5D=and&FilterField%5B2%5D=11&FilterOperator%5B2%5D=less-than-or-equal-to&&FilterValue%5B2%5D=31%2F12%2F' . date('Y'),
'icon' => 'resources/table_icons/table_go.png', // optional icon to use with the link
'title' => 'This Years Orders',
'groups' => array('*'), // groups allowed to see this link, use '*' if you want to show the link to all groups
'table_group' => '1' // optional name of the table group you wish to add the link to. If the table group name contains non-Latin characters, you should convert them to html entities.
);
Is there any way I can use this code in the button on the TV currently, if I paste the "filter" part of the code into the invoice_veiw line the buttons disapear ???
hoping someone can point me in right direction ?
Hope somebody can help ?
I am trying to add buttons to the Table Veiw to allow users to only see "This Year" or "Last Year" and then only "Confirmed Orders" for that filtered year, I have managed to add new buttons however the code attached to them does not work. ??
The code I have used in "invoices.tv.js" is as follows:
/* end of mass_update code */
jQuery(function(){
jQuery('.clearfix').after('<button class="btn btn-success btn-lg"" type="button" id="filter-button"><i class="glyphicon glyphicon glyphicon-print"></i> This Year</button>');
jQuery('button[id=filter-button]').click(function(){
window.location = 'invoices_view.php?SortField=&SortDirection=&FilterAnd%5B1%5D=and&FilterField%5B1%5D=11&FilterOperator%5B1%5D=greater-than-or-equal-to&FilterValue%5B1%5D=01%2F01%2F2022&FilterAnd%5B2%5D=and&FilterField%5B2%5D=11&FilterOperator%5B2%5D=less-than-or-equal-to&FilterValue%5B2%5D=31%2F12%2F2022';
});
});
jQuery(function(){
jQuery('.clearfix').after('<button class="btn btn-success btn-lg"" type="button" id="filter-button"><i class="glyphicon glyphicon glyphicon-print"></i> Last Year</button>');
jQuery('button[id=filter-button]').click(function(){
window.location = 'invoices_view.php?SortField=&SortDirection=&FilterAnd%5B1%5D=and&FilterField%5B1%5D=11&FilterOperator%5B1%5D=greater-than-or-equal-to&FilterValue%5B1%5D=01%2F01%2F2021&FilterAnd%5B2%5D=and&FilterField%5B2%5D=11&FilterOperator%5B2%5D=less-than-or-equal-to&FilterValue%5B2%5D=31%2F12%2F2021';
});
});
jQuery(function(){
jQuery('.clearfix').after('<button class="btn btn-success btn-lg"" type="button" id="filter-button"><i class="glyphicon glyphicon glyphicon-print"></i> Confirmed</button>');
jQuery('button[id=filter-button]').click(function(){
window.location = 'invoices_view.php?SortField=&SortDirection=&FilterAnd%5B1%5D=and&FilterField%5B1%5D=11&FilterOperator%5B1%5D=greater-than-or-equal-to&FilterValue%5B1%5D=01%2F01%2F2021&FilterAnd%5B2%5D=and&FilterField%5B2%5D=11&FilterOperator%5B2%5D=less-than-or-equal-to&FilterValue%5B2%5D=31%2F12%2F2021';
});
});
I have a code written in links-navmenu.php that works OK for current year but have to go to main menu to use which is not ideal ? this is the menu code:
/* This Year Invoices links */
$navLinks[] = array(
'url' => 'invoices_view.php?SortField=2+asc%2C3&SortDirection=asc&FilterAnd%5B1%5D=and&FilterField%5B1%5D=11&FilterOperator%5B1%5D=greater-than-or-equal-to&FilterValue%5B1%5D=01%2F04%2F' . date('Y') . '&FilterAnd%5B2%5D=and&FilterField%5B2%5D=11&FilterOperator%5B2%5D=less-than-or-equal-to&&FilterValue%5B2%5D=31%2F12%2F' . date('Y'),
'icon' => 'resources/table_icons/table_go.png', // optional icon to use with the link
'title' => 'This Years Orders',
'groups' => array('*'), // groups allowed to see this link, use '*' if you want to show the link to all groups
'table_group' => '1' // optional name of the table group you wish to add the link to. If the table group name contains non-Latin characters, you should convert them to html entities.
);
Is there any way I can use this code in the button on the TV currently, if I paste the "filter" part of the code into the invoice_veiw line the buttons disapear ???
hoping someone can point me in right direction ?