Browse screen

Browse screen

Postby johan » Thu Jul 25, 2013 3:20 am

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
johan
 
Posts: 270
Joined: Sun Feb 27, 2011 7:46 pm
Location: Belgium

Re: Browse screen

Postby massiws » Fri Jul 26, 2013 10:04 am

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?
massiws
 
Posts: 503
Joined: Thu May 24, 2012 9:38 am
Location: Milan, Italy

Re: Browse screen

Postby johan » Fri Jul 26, 2013 6:03 pm

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
johan
 
Posts: 270
Joined: Sun Feb 27, 2011 7:46 pm
Location: Belgium

Re: Browse screen

Postby massiws » Fri Jul 26, 2013 7:21 pm

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
massiws
 
Posts: 503
Joined: Thu May 24, 2012 9:38 am
Location: Milan, Italy

Re: Browse screen

Postby johan » Fri Jul 26, 2013 11:40 pm

Max,

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

Johan
johan
 
Posts: 270
Joined: Sun Feb 27, 2011 7:46 pm
Location: Belgium

Re: Browse screen

Postby massiws » Sun Jul 28, 2013 9:01 am

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!".
massiws
 
Posts: 503
Joined: Thu May 24, 2012 9:38 am
Location: Milan, Italy

Re: Browse screen

Postby johan » Mon Jul 29, 2013 5:26 am

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
johan
 
Posts: 270
Joined: Sun Feb 27, 2011 7:46 pm
Location: Belgium

Re: Browse screen

Postby massiws » Mon Jul 29, 2013 7:56 am

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

Max
massiws
 
Posts: 503
Joined: Thu May 24, 2012 9:38 am
Location: Milan, Italy

Re: Browse screen

Postby johan » Mon Jul 29, 2013 4:50 pm

Max,

Great meanwhile I try the solution with the alert.

Thanks for your help.

Johan
johan
 
Posts: 270
Joined: Sun Feb 27, 2011 7:46 pm
Location: Belgium

Re: Browse screen

Postby massiws » Fri Aug 02, 2013 6:33 am

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
massiws
 
Posts: 503
Joined: Thu May 24, 2012 9:38 am
Location: Milan, Italy

Next

Return to Custom Code



cron