meeting-room-booking-system / mrbs-code

MRBS application code
Other
129 stars 64 forks source link

SQL string for integration external program #1838

Open jberanek opened 7 years ago

jberanek commented 7 years ago

Let us assume that you have created an area "First floor", and that it contains the rooms: Room 1, Room 2 and Room 3

If I wanted to book the room 1 from 8:00 to 10:00 of mm/dd/yyyy making an external program is or what I should do on Queri db?

If you were to do the same reservation but with weekly repetition up to a certain date?

thanks in advance

Reported by: *anonymous

Original Ticket: mrbs/support-requests/1117

jberanek commented 7 years ago

The best thing to do is to follow the code from mrbsMakeBookings() in mrbs_sql.inc and seeing for yourself what SQL is produced. However, I'd be wary of using SQL to insert bookings directly into the database. The database structure often changes between versions of MRBS and it will be easy for your code to make the MRBS tables inconsistent.

Did you know that there is an import.php page which can import events that have been exported in .ics format by another program? I don't know if this would help?

If not, then if at all possible I would recommend using a higher level of interface into MRBS to insert bookings. For example if your script is a PHP script then maybe you could use mrbsMakeBookings() yourself, a little bit like import.php does.

Maybe you could give a little more detail on why you need to insert events from an external program and then the solution might be clearer. It may even lead to an MRBS feature request.

Original comment by: campbell-m

jberanek commented 7 years ago

I would use MRBS in a school, the teachers and the subjects they teach are almost always the same. Reserve the room would be much faster if the brief and full description description fields could be preset and selected via a dropdown box. Sorry for my english

Original comment by: *anonymous

jberanek commented 7 years ago

You can do this by settings in the config file. For example

$select_options['entry.name'] = array('Maths', 'Physics', 'Chemistry');
$select_options['entry.description'] = array('Mr. Jones', 'Miss Jean Brodie');

or else, by using associative arrays:

$select_options['entry.name'] = array('m' => 'Maths', 'p' => 'Physics', 'c' => 'Chemistry');
$select_options['entry.description'] = array('a' => 'Mr. Jones', 'b' => 'Miss Jean Brodie');

Using associative arrays has the advantage that you can change the description without having to change the database: the key (eg 'm') is stored in the database, while the value (eg 'Maths') is the text that it is displayed in the browser.

You can also use datalists ($datalist_options) if you want to retain the ability to enter a new value while still having a list of standard values presented.

For more details see the comments in systemdefaults.inc.php.

Original comment by: campbell-m