Show only a certain group some information

The recommended method of customizing your AppGini-generated application is through hooks. But sometimes you might need to add functionality not accessible through hooks. You can discuss this here.
Post Reply
User avatar
shasta59
AppGini Super Hero
AppGini Super Hero
Posts: 231
Joined: 2013-01-08 19:40
Location: Calgary, Alberta, Canada

Show only a certain group some information

Post by shasta59 » 2013-01-30 02:28

I needed the directors responsible for different districts to be able to see, at a glance, the results and status of registrations for an event. They needed to know how many from their area, (even though the system sent them an email when someone from their area registered), how many from other areas, level of experience etc.

So, rather than having someone do this manually (read me), I set up a page that displays only to those in certain groups based upon the group id. It then displayed the results when they signed in underneath the table choices area. There are three parts needed. Some javascript, some php and, if you wish some css to make it look pretty.

Here is the code. It was placed at the bottom of the index.php page in versions prior to the metro style versions but now would be placed at the bottom of the home.php page. This code is inserted just above/before the last </html>

<div id = "stats" style="display:none">Clinic Registration Stats</div>
</div>

if (getLoggedGroupID() == 6 || getLoggedGroupID() == 2){
echo "<script language=javascript>hideshow(document.getElementById('stats'))</script>";
include("$d/stats.php");
}
?>
<?php
if (getLoggedGroupID() == 7){
echo "<script language=javascript>hideshow(document.getElementById('stats'))</script>";
include("$d/stats.php");
}
?>


What it does: (I have placed two sets in this example to show how to do two groups or only one. )

if (getLoggedGroupID() == 6 || getLoggedGroupID() == 2){
this line checks to see what the group id is of the person who logged in. Group 6 or 2

echo "<script language=javascript>hideshow(document.getElementById('stats'))</script>";
this line runs the javascript if the above was true and shows the div stats

include("$d/stats.php");
this line includes the file stats.php. This can be whatever you wish it to be. Stats is the name I used for my file of clinic stats.

The stats file is a php file which made up pretty graphs, pulled info from the database based upon where from, experience etc then displays it all on one page. Since it presented a comparison of one area to another it also helped foster some competition between areas to get more people signed up. The stats file also had html and php in it to display the page properly.

For this same event the registration maxed out at a certain number. I had another routine which, on the main sign in page, where you enter your user/pass, would show you how many slots were left or if it was filled. This was done by pulling info from the database and then hiding/showing the signup button. If someone wants this how to let me know. I would have to revise it to work with AppGini 5.

If any of the above is clear as mud let me know and I can try to explain it better.

Alan
Calgary, Alberta, Canada - Using Appgini 5.50 -

wplim
Veteran Member
Posts: 36
Joined: 2013-01-17 22:42

Re: Show only a certain group some information

Post by wplim » 2013-02-26 00:33

Hi Alan,

That's a great idea to hide/show additional information.

I am trying to hide/show some of the table column in table view (and also in detail view) based on group id. Do I create separate XXX_id#_view.php file? or modifying the related XXX hook file will do?

I am at the beginning stage of learning PHP. Some code example will be helpful. Thanks!

Weoi

Post Reply