phpScheduleIt
May 20, 2013, 08:49:11 PM *
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: Missing Reservations  (Read 2798 times)
cmgar
Newbie
*

Karma: 0
Posts: 5


« on: March 31, 2009, 12:59:22 PM »

Hi,
I've been having some serious issues. Yesterday it was reported that people could not enter reservations for the same day. Upon further investigation it appeared that either our time daemon had failed or that possibly since the machine was virtualized it hadn't been running so the date was quite a way off. Once I'd adjusted the date and time, I had no further problems reported with entering reservations. Then a bit later on I got a call saying that the phpScheduleIt instance was missing about a weeks worth of reservations. So after going through the system and looking directly at the database I found out that they are not missing, just not displaying for some reason on the calendar.

To fix a reservation, I had to go into the Manage Reservations area and find a "missing" reservation and then click Modify, once the window popped up, I clicked Modify again and closed the window, then it reappeared on the calendar view. I got through the reservations for yesterday and today, by hand, which wasn't pleasant. I didn't realize today until I'd done about 25 or so (trying to fix tomorrows reservations) that it changed the year to 2008 on the reservations I tried to fix today. When I changed my number of items shown on the Manage Reservations screen from 25 to 100, the Modify sequence I'd used yesterday to fix them worked as it did then.

I understand why a person, with the date/time screwed up, wouldn't be able to enter a res. That part was solved. However, I don't understand why all of a sudden a weeks worth (March 30 - April 6th, 2009) won't show up. They're still in the database, but they won't show until I go in and do the Modify sequence to them. My dream is to do this automatically to fix what is left,  since we are talking about a couple of hundred reservations a day. I tested just changing the modified column in the reservations table on a few and it didn't work. Apparently some other table is being touched.

We're running v1.1.1 on CentOS 4, using PHP4 and MySQL 4.1.

Any help you can give would be awesome, I'm kind of at a loss at this point.

Thanks,
Chris G
Logged
Nick
Administrator
Hero Member
*****

Karma: 15
Posts: 5419


WWW
« Reply #1 on: March 31, 2009, 02:40:11 PM »

Probably something with timezones.  For version 1.1.x, back up your database then run this script:


Code:
<?php
/**
* Daylight savings time (DST) patch for USA DST adjustment
* Target version phpScheduleIt 1.1.x
* @author Nick Korbel <lqqkout13@users.sourceforge.net>
* @version 03-11-07
* @package phpScheduleIt
*/

/**
* TO USE:
* 1) Back up your data
* 2) Place this file in the root of your phpScheduleIt installation
* 3) Browse to this file from your web browser
* 4) Delete this file
*/

/**
* Please refer to readme.html and LICENSE for any additional information
*
* Copyright (C) 2003 - 2006 phpScheduleIt
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the
* Free Software Foundation, Inc.
* 59 Temple Place
* Suite 330
* Boston, MA
* 02111-1307
* USA
*/

require_once('lib/db/ScheduleDB.class.php');

$dbEngine = new DBEngine();
$db $dbEngine->db;

$rs $db->query('SELECT resid, date FROM reservations');

$AdjustmentResults = new AdjustmentResults();

while (
$row $rs->fetchRow())
{
$result AdjustReservationDates($db$row['resid'], $row['date']);
$AdjustmentResults->Add($result);
}

if (
$AdjustmentResults->AnyAdjustments)
{
echo '<br/><br/>All date adjustments have been made.  Please use the provided rollback queries if any problems are found with the adjustments made.<br/>';
echo '<pre>' $AdjustmentResults->GetRollbackQueries() . '</pre>';
}
else
{
echo '<br/>No date adjustments were necessary.';
}

function 
AdjustReservationDates($db$resid$startDate)
{
$adjustedStartDate GetAdjustedDate($startDate);

if ($adjustedStartDate != $startDate)
{
echo sprintf('<br/>resid: %s will be adjusted.<br/>Start date is %s (%s).<br/>, $resid, date('m-d-Y H:i:s', $startDate), $startDate);
echo sprintf('
<br/>Start date should be %(%s).<br/>', $resid, date('m-d-Y H:i:s', $adjustedStartDate), $adjustedStartDate);

$query = $db->prepare('
UPDATE reservations SET date = ? WHERE resid = ?');
$result = $db->execute($query, array($adjustedStartDate, $resid));

$rollbackQuery = "UPDATE reservations SET date = $startDate WHERE resid = '
$resid'\n";

//$dbEngine->check_for_error($result);

return new AdjustmentResult(true, $rollbackQuery);
}

return new AdjustmentResult(false, '');
}

function GetAdjustedDate($timestamp)
{
$adjustedStartDate = $timestamp;

$parts = getdate($timestamp);

$hours = $parts['
hours'];

if ($hours != 0)
{
if ($hours > 16)
{
// Reservation was likely supposed to be for the next day
$adjustedDay = $parts['
mday'] + 1;
$adjustedStartDate = mktime(0, 0, 0, $parts['
mon'], $adjustedDay, $parts['year']);
}
else if ($hours < 8)
{
$adjustedStartDate = mktime(0, 0, 0, $parts['
mon'], $parts['mday'], $parts['year']);
}
}

return $adjustedStartDate;
}

class AdjustmentResult
{
var $DateAdjusted = false;
var $RollbackQuery = '';

function AdjusmtmentResult($dateAdjusted, $rollbackQuery)
{
$this->DateAdjusted = $dateAdjusted;
$this->RollbackQuery = $rollbackQuery;
}
}

class AdjustmentResults
{
var $AnyAdjustments = false;
var $Results = array();

function Add($adjustmentResult)
{
if ($adjustmentResult->DateAdjusted)
{
$this->AnyAdjustments = true;
}

$Results[] = $adjustmentResult;
}

function GetRollbackQueries()
{
$queries = '
;
foreach ($this->Results as $result)
{
$queries .= $result->RollbackQuery;
}

return $queries;
}
}
?>
Logged
cmgar
Newbie
*

Karma: 0
Posts: 5


« Reply #2 on: March 31, 2009, 03:37:51 PM »

Thank you very much for the quick reply.

I tried to run the script but it's giving me problems with the fetchRow() function on line 50.

Any suggestions?
Logged
cmgar
Newbie
*

Karma: 0
Posts: 5


« Reply #3 on: March 31, 2009, 03:49:41 PM »

Sorry, I forgot this, the actual error is:

Fatal error: Call to undefined function: fetchrow() in /var/www/html/Scheduler/dst_script.php

Thanks,
Chris G
Logged
Nick
Administrator
Hero Member
*****

Karma: 15
Posts: 5419


WWW
« Reply #4 on: April 01, 2009, 01:51:19 PM »

I guess I should have asked, are you using MySQL?  If so, what version?
Logged
cmgar
Newbie
*

Karma: 0
Posts: 5


« Reply #5 on: April 01, 2009, 04:56:08 PM »

MySQL 4.1

Thanks,
Chris
Logged
cmgar
Newbie
*

Karma: 0
Posts: 5


« Reply #6 on: April 01, 2009, 06:17:55 PM »

I think I have fixed the problem. I was able, after a few errors here and there, to make a copy of the DB and filesystem and upgrade it to the latest version. The dates seemed to appear as they should. I'm waiting for final confirmation from the content owners on the matter. Otherwise I believe it to be problem solved.

Thank you for your help, I really appreciate it.

Chris G
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!