Hello all, I am looking for some assistance on building a custom filter for my page. When the user hits the page I want all the records for the current day moving forward to show. Example, 87 records in the table, but from today move forward there is only 14 records. So I need some automatic so show today's date and forward.
thank you in advance
Utony
Filter date
Re: Filter date
Hi,
you can use the $options->QueryWhere in the _init function to restrict your search for the result.
you can use the $options->QueryWhere in the _init function to restrict your search for the result.
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.
Re: Filter date
This is what I would like to do, but need your help.
Shows record in table from today to 14 days out on initial view TV.
Any code help, placement, ect would be greatly appreciated. I know this is probably so easy for a master coder like you. I just need assistance as I don't know the logical piece to make this happen.
Shows record in table from today to 14 days out on initial view TV.
Any code help, placement, ect would be greatly appreciated. I know this is probably so easy for a master coder like you. I just need assistance as I don't know the logical piece to make this happen.
Re: Filter date
As a starting point you can try with the following code:
file:
file:
hooks/TABLENAME.php
Code: Select all
function TABLENAME_init(&$options, $memberInfo, &$args)
{
$options->QueryWhere = $options->QueryWhere ? $options->QueryWhere . " AND " : "WHERE ";
$conditions = [
"datediff(now(), `TABLENAME`.`modified_on`) < 7"
];
$options->QueryWhere .= implode(" AND ", $conditions);
return TRUE;
}
- replace TABLENAME by your table name, there are two occurrences in the code
- replace
modified_on
by your column name - replace "
< 7
" by whatever condition you need - you can add more conditions to the
$conditions
array. They all will be joined withAND
Kind regards,
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
AppGini 24.10 Revision 1579 + all AppGini Helper tools
<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 readabilityAppGini 24.10 Revision 1579 + all AppGini Helper tools
Re: Filter date
jsetzer, you are an absolute master of your craft. Thank you so much for being so good to all of us and myself. I bought your plugin and will continue to support your site. Keep building this forward. We need you!
Thank you Sir.
Thank you Sir.
Re: Filter date
Work great, matter of fact it works to good. LOL... I got it to show the last 14 days by default, good there... But when I click the "show all" button it will not show all the records. The table holds true to the 14 days only. Anyway to keep the default 4 days from today's date, but all the show all button to work to see all records. Right now the 14 default shows 12 records, but I have 40 in the table.
Thanks in advance!!!
Tony
Thanks in advance!!!
Tony
Re: Filter date
So, the requirement has changed from "automatically filtering by date on load" to "optionally filtering by date".
In these cases I am usually using parameters in URL, for example
See the filter-parameter
In
Your next question could be:
"How can users open that page with the given
You can add custom links to your homepage or navbar (https://bigprof.com/appgini/help/advanc ... r-contents) or even custom links by modifying
In these cases I am usually using parameters in URL, for example
https://www.yourserver.com/yourApp/v1/TABLENAME_view.php?f=date
See the filter-parameter
f
? You can name it as you like.In
TABLENAME_init()
-hook I can get the filter name (and perhaps optional additional parameters) and build my conditions:Code: Select all
function TABLENAME_init(&$options, $memberInfo, &$args)
{
$filter = (string)Request::val("f", "");
$conditions = [];
switch ($filter) {
case 'date':
$conditions = [
"datediff(now(), `TABLENAME`.`modified_on`) < 7"
];
break;
default:
$conditions = ['1=1']; // always true
break;
}
$options->QueryWhere = $options->QueryWhere ? $options->QueryWhere . " AND " : "WHERE ";
$options->QueryWhere .= implode(" AND ", $conditions);
return TRUE;
}
"How can users open that page with the given
f
-parameter?", but that is a different forum request, I think.You can add custom links to your homepage or navbar (https://bigprof.com/appgini/help/advanc ... r-contents) or even custom links by modifying
hooks/TABLENAME-tv.js
(https://bigprof.com/appgini/help/advanc ... agic-files) or _header
-hook (https://bigprof.com/appgini/help/advanc ... ame_header) or _footer()
-hook (https://bigprof.com/appgini/help/advanc ... ame_footer) or even have a browser-bookmark or desktop-link. There are many places and options for placing additional links.Kind regards,
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
AppGini 24.10 Revision 1579 + all AppGini Helper tools
<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 readabilityAppGini 24.10 Revision 1579 + all AppGini Helper tools
Re: Filter date
Ok, as a starting point, here we have a very short snippet for
_footer
-hook in hooks/TABLENAME.php
which will render a filter- and a reset-filter-button:Code: Select all
function TABLENAME_footer($contentType, $memberInfo, &$args)
{
$footer = '';
switch ($contentType) {
case 'tableview':
$footer="<script>
jQuery(\"#top_buttons > .all_records\")
.append(jQuery('<a class=\"btn btn-default btn-lg\" href=\"?f=date\"><i class=\"glyphicon glyphicon-calendar\"></i></a>'))
.append(jQuery('<a class=\"btn btn-default btn-lg\" href=\"?f=\"><i class=\"glyphicon glyphicon-remove\"></i></a>'));
</script>";
break;
// ...
}
Kind regards,
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
AppGini 24.10 Revision 1579 + all AppGini Helper tools
<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 readabilityAppGini 24.10 Revision 1579 + all AppGini Helper tools
Re: Filter date
JS,
function Move_Log_footer($contentType, $memberInfo, &$args)
{
$footer = '';
switch ($contentType) {
case 'tableview':
$footer="<script>
jQuery(\"#top_buttons > .all_records\")
.append(jQuery('<a class=\"btn btn-default btn-lg\" href=\"?f=date\"><i class=\"glyphicon glyphicon-calendar\"></i></a>'))
.append(jQuery('<a class=\"btn btn-default btn-lg\" href=\"?f=\"><i class=\"glyphicon glyphicon-remove\"></i></a>'));
</script>";
break;
}
case 'tableview':
$footer='';
break;
case 'detailview':
$footer='';
break;
case 'tableview+detailview':
$footer='';
break;
case 'print-tableview':
$footer='';
break;
case 'print-detailview':
$footer='';
break;
case 'filters':
$footer='';
break;
}
return $footer;
}
gives me - Parse error: syntax error, unexpected token "case" in C:\xamppnew\htdocs\XXX\hooks\Move_Log.php on line 56
function Move_Log_footer($contentType, $memberInfo, &$args)
{
$footer = '';
switch ($contentType) {
case 'tableview':
$footer="<script>
jQuery(\"#top_buttons > .all_records\")
.append(jQuery('<a class=\"btn btn-default btn-lg\" href=\"?f=date\"><i class=\"glyphicon glyphicon-calendar\"></i></a>'))
.append(jQuery('<a class=\"btn btn-default btn-lg\" href=\"?f=\"><i class=\"glyphicon glyphicon-remove\"></i></a>'));
</script>";
break;
}
case 'tableview':
$footer='';
break;
case 'detailview':
$footer='';
break;
case 'tableview+detailview':
$footer='';
break;
case 'print-tableview':
$footer='';
break;
case 'print-detailview':
$footer='';
break;
case 'filters':
$footer='';
break;
}
return $footer;
}
gives me - Parse error: syntax error, unexpected token "case" in C:\xamppnew\htdocs\XXX\hooks\Move_Log.php on line 56
Re: Filter date
Personal wishes:
Now back to the topic: You have added an invalid extra bracket which has to be removed:
My Code Editor (VSCODE) immediately shows me the syntax problems
As soon as I remove that extra bracket, everything looks good:
I hope this was the only mistake.
- Please, when posting here in the forum, always paste code fragments inside
[code] ... [/code]
blocks for better readability.
see here app.php/help/bbcode?sid=63dcb1fb3510ea6 ... 552f4#f2r1
This makes it easier for all of us to read and understand your code and to help you. You can even use the code-tool of the toolbar. - I strongly recommend using a modern Code Editor like VSCODE (Visual Studio Code, free) offering Intellisense and Syntax Highlighting
Now back to the topic: You have added an invalid extra bracket which has to be removed:
My Code Editor (VSCODE) immediately shows me the syntax problems
As soon as I remove that extra bracket, everything looks good:
I hope this was the only mistake.
Kind regards,
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
AppGini 24.10 Revision 1579 + all AppGini Helper tools
<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 readabilityAppGini 24.10 Revision 1579 + all AppGini Helper tools
Re: Filter date
JS- you bet thanks for the info. You don't know what you don't know about the code pasting. That worked!
I like the idea of just building a button for 7 days out from todays date and 14 days out from today's date. Can you help me? here is my url. But, I would like URL to always be from today's date out 7 days and then 14 days. Is there a way to allow user to not have to click and manually add dates to filter?
Is there like [today's date] for something?
http://localhost/XXX/Move_Log_view.php? ... =510679940
I like the idea of just building a button for 7 days out from todays date and 14 days out from today's date. Can you help me? here is my url. But, I would like URL to always be from today's date out 7 days and then 14 days. Is there a way to allow user to not have to click and manually add dates to filter?
Is there like [today's date] for something?
http://localhost/XXX/Move_Log_view.php? ... =510679940
Re: Filter date
According to MySQL docs, you can replace
now()
by CURRENT_DATE()
Kind regards,
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
AppGini 24.10 Revision 1579 + all AppGini Helper tools
<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 readabilityAppGini 24.10 Revision 1579 + all AppGini Helper tools
Re: Filter date
Looking for some assistance.
I want to be able from the DV page, to click on the "Print Preview" button and a pop up message appears to display a message. The user will have to acknowledge before clicking the print button. Any assistance would much appreciated.
Looking for code help and location to put it .
Thank you!!!!!
-JS-?????
I want to be able from the DV page, to click on the "Print Preview" button and a pop up message appears to display a message. The user will have to acknowledge before clicking the print button. Any assistance would much appreciated.
Looking for code help and location to put it .
Thank you!!!!!
-JS-?????