phpScheduleIt
May 26, 2013, 03:03:59 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: phpScheduleIt 2.4.2 has been released!
 
   Home   Help Login Register  
Pages: [1]
  Print  
Author Topic: auto black out at end of each booking  (Read 3096 times)
panda007
Newbie
*

Karma: 0
Posts: 26


« on: August 20, 2007, 07:48:00 AM »

HI all

I am using the scheduler to allow technical users and testers to book several IT systems.  At the end of each booking I would like a period of two days blackout to be entered automatically in the calendar.  This is to all my group (environemnt management) to return the system to its original state before the next group of testers are unleashed.

Has anyone out there got an implementation suggestion?

Thanks
Logged
Nick
Administrator
Hero Member
*****

Karma: 15
Posts: 5419


WWW
« Reply #1 on: August 24, 2007, 09:52:27 AM »

Are all reservations the same length?
Logged
panda007
Newbie
*

Karma: 0
Posts: 26


« Reply #2 on: August 24, 2007, 09:54:56 AM »

no - the lengths of the bookings vary greatly the user can choose it
Logged
Nick
Administrator
Hero Member
*****

Karma: 15
Posts: 5419


WWW
« Reply #3 on: August 24, 2007, 09:56:50 AM »

Ok.  So then is the 2 day buffer afterward a true 2 days, or is it up to 2 days.

For example, if a reservation ends at 7 on Monday, do you want until 7:00 on Wednesday blacked out, or until midnight Tuesday blacked out.
Logged
panda007
Newbie
*

Karma: 0
Posts: 26


« Reply #4 on: August 24, 2007, 10:00:14 AM »

it wold be 7 on the wednesday (or maybe even 5 days later, this isn't definitive yet
Logged
Nick
Administrator
Hero Member
*****

Karma: 15
Posts: 5419


WWW
« Reply #5 on: August 24, 2007, 10:30:57 AM »

In the lib/ResDB.class.php file, change the add_res() to just insert another reservation with all the same data as what is passed in with the dates changed.
Logged
panda007
Newbie
*

Karma: 0
Posts: 26


« Reply #6 on: August 27, 2007, 02:27:37 AM »

HI nick

Thanks for the hint, but I don't have lib/ResDB.class.php I searched for the string add_res() in the lib dir but I couldn't find anything

I am using version 1.2.7
Logged
jperl
Newbie
*

Karma: 0
Posts: 4


« Reply #7 on: August 27, 2007, 02:39:22 AM »

Search for the string add_res( if you want to find the function.

Since the function gets parameters the brackets aren't closed immediately.

jperl
Logged
panda007
Newbie
*

Karma: 0
Posts: 26


« Reply #8 on: August 27, 2007, 04:33:10 AM »

Ok, I found the file and the function - sorry for the Monday morning slowness

I guess that I would have to add a sub routine that finds $res -> get_end_date and then adds a blackout period starting from the next day?  


(users can only book days and not parts there of so the next day should begin the blackout period)

However I read the following lines that make me wonder if this can work

from blackouts.php

if (!Auth::isAdmin()) {
    CmnFns::do_error_box(translate('This is only accessable to the administrator') . '<br />'
        . '<a href="ctrlpnl.php">' . translate('Back to My Control Panel') . '</a>');
}


As I want this blackout to be added when the users place a reservation and a normal user isn't an admin - can this be done in this way at all?  

I am no php expert so any pointers are welcome
Logged
Nick
Administrator
Hero Member
*****

Karma: 15
Posts: 5419


WWW
« Reply #9 on: August 27, 2007, 01:56:41 PM »

Yes, it can be done.  Right after line 221 in lib/db/resdb.class.php, try adding something like:

Code:
$d = getdate($res->get_end_date());
$end = mktime(0, 0, 0, $d["mon"], $d["mday"] + 2, $d["year"]);
$values[3] = $res->get_end_date();
$values[4] = $end;
$values[5] = $res->get_end();

$query = 'INSERT INTO ' . $this->get_table(TBL_RESERVATIONS) . ' VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)';
$q = $this->db->prepare($query);
$result = $this->db->execute($q, $values);
$this->check_for_error($result);



I'm not sure if this will work and it's absolutely not supported.  Back up your files before making any changes.
Logged
berndvf
Newbie
*

Karma: 0
Posts: 1


« Reply #10 on: October 15, 2007, 03:26:36 AM »

I managed to get this working by doing the following:

After Line 221:
Code:
$temp_values = $values;


After line 248, just before the unset:

Code:


// Now add auto blackout
if ( !$res->is_blackout )
{
$end = $res->get_end() + 15;
$newid = $this->get_new_id();

$temp_values[0] = $newid;
$temp_values[5] = $res->get_end();
$temp_values[6] = $end;
$temp_values[10] = 1;

$query = 'INSERT INTO ' . $this->get_table(TBL_RESERVATIONS) . ' VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)';

$q = $this->db->prepare($query);
$result = $this->db->execute($q, $temp_values);
$this->check_for_error($result);

         // Insert the user participation data
$values = null;
$values[] = array($newid, $res->get_memberid(), 1, 0, 1, 1, null);

$query = 'INSERT INTO ' . $this->get_table(TBL_RESERVATION_USERS) . ' VALUES(?,?,?,?,?,?,?)';
$q = $this->db->prepare($query);
$result = $this->db->executeMultiple($q, $values);

$this->check_for_error($result);
}
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2006-2007, Simple Machines Valid XHTML 1.0! Valid CSS!