Welcome to the nuBuilder forums!

Please register and login to view forums and other content only available to registered users.

Browse screen

johan
Posts: 392
Joined: Sun Feb 27, 2011 11:16 am
Location: Belgium

Browse screen

Unread post by johan »

Hi,

I have a little library where my collegues can reservate some books. I've created a form with subform. On that subform I have some lookups. The form used for the lookups show only the books available on the selected date.

Is there a way that I can show all the books in the library but where the user only can select the books available in lookup. P.ex those who are already reservated shown in red and not selectable for the user.
Anyone an idea?

Johan
massiws
Posts: 503
Joined: Thu May 24, 2012 2:08 am
Location: Milan, Italy
Contact:

Re: Browse screen

Unread post by massiws »

Johan, sorry but I'm not sure I understand the problem.

Do you need to filter out some records from the looked-up table?
Do you need to pass a filter to looked-up table?
Have you a field on that table to store the reserved/not-reserved information? If so, can't you show only not-reserved books?
johan
Posts: 392
Joined: Sun Feb 27, 2011 11:16 am
Location: Belgium

Re: Browse screen

Unread post by johan »

Max,


With sql I only show the books not reserved in the period. That part is alright.
Now my colleagues ask me if it is possible to show all the books, those who are reserved marked red and not selectable in lookup.

I could adjust my sql so I get a list with all the books and one extra column available yes/no.

But how to set colour red and item not selectable?

Johan
massiws
Posts: 503
Joined: Thu May 24, 2012 2:08 am
Location: Milan, Italy
Contact:

Re: Browse screen

Unread post by massiws »

Johan, I think you could not make this without hacking nuBuilder core (but perhaps someone could contradict me).

Have a look at this forum.
Following that approach, you can edit the standard browse.php file and add a class to column containing a specific value in your field; also, to make the row unselectable, remove the onlick attribute in each column.
So you could add a style to format these rows like you want (you can also apply the nuUnselectedRow style).

I've never tried this: let me know how you solve it.

Hope this helps,
Max
johan
Posts: 392
Joined: Sun Feb 27, 2011 11:16 am
Location: Belgium

Re: Browse screen

Unread post by johan »

Max,

Is it not possible with nuLoadThis() ? If i change browse.php it will affect all my forms / databases.

Johan
massiws
Posts: 503
Joined: Thu May 24, 2012 2:08 am
Location: Milan, Italy
Contact:

Re: Browse screen

Unread post by massiws »

mmm... nuLoadThis() is executed before nuBuilder load edit form, that is, after record in browse form is selected.
In nuLoadThis() you may insert a function to alert user with something like: "Please go back: this book is already reserved!".
johan
Posts: 392
Joined: Sun Feb 27, 2011 11:16 am
Location: Belgium

Re: Browse screen

Unread post by johan »

Max,

Thanks for your reply.

Perhaps a suggestion for the builders :D to add something simular as "nuloadThis()" that works before the browse screen opens a table.

Johan
massiws
Posts: 503
Joined: Thu May 24, 2012 2:08 am
Location: Milan, Italy
Contact:

Re: Browse screen

Unread post by massiws »

I have opened a post here: more suggestions are appreciated!

Max
johan
Posts: 392
Joined: Sun Feb 27, 2011 11:16 am
Location: Belgium

Re: Browse screen

Unread post by johan »

Max,

Great meanwhile I try the solution with the alert.

Thanks for your help.

Johan
massiws
Posts: 503
Joined: Thu May 24, 2012 2:08 am
Location: Milan, Italy
Contact:

Re: Browse screen

Unread post by massiws »

Johan, have a look at this solution from fester.

Inserting something like this in Custom Code > Before Open you can block editing of not-available book-records:

Code: Select all

// Get the 'available/not-available' field value
$sql = "SELECT available FROM myTable WHERE tableID = '#id#' ";
$field = db_fetch_object(nuRunQuery($sql));
$available = $field->available;

if ($available == true) {
    // add JavaScript function to stop Edit Screen
    $js  = "function notAvailable() {\n";
    $js .= "  alert('This book is not available: please go back!');\n";
    $js .= "  window.history.go(-1);\n";
    $js .= "}\n\n";
    
    $js .= "notAvailable();\n";

    addJSfunction($js);
}
So, when the user attempt to select a not-available book (open Edit Screen), he/her gets an alert message and is sent back to Browse Screen.

Max
Locked