phpScheduleIt
September 09, 2010, 01:13:00 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: phpScheduleIt 1.2.11 has been released
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Show ALL new reservations in control panel  (Read 2781 times)
reliablets
Newbie
*

Karma: 0
Posts: 20


View Profile
« on: May 02, 2007, 10:42:47 PM »

Here is the code to show all new reservation in the control panel as opposed to only showing reservations for the current user. Thanks to Nick for the help hacking this one out.

Taken from DBEngine.class.php

Code:
  function get_user_reservations($id, $order, $vert, $include_participating = false) {
        $return = array();
       
      // Clean out the duplicated order so that MSSQL is OK
      $orders = trim(preg_replace("/(res|rs).$order,?/", '', 'res.start_date, rs.name, res.starttime'));
      if (strrpos($orders, ',') == strlen($orders)-1) {
         $orders = substr($orders, 0, strlen($orders)-1);
      }
       
   $query = 'SELECT res.*, resusers.*, rs.name, rs.location, rs.rphone FROM '
                    . $this->get_table('reservations') . ' as res INNER JOIN '
                    . $this->get_table('resources') . ' as rs ON rs.machid=res.machid INNER JOIN '
                    . $this->get_table('reservation_users') . ' as resusers ON resusers.resid=res.resid'
                    . ' WHERE (res.start_date>=? OR (res.start_date<=? AND res.end_date>=?))'
                    . ' AND res.is_blackout <> 1'
                    . " ORDER BY $order $vert, res.start_date, rs.name, res.starttime";
                   
         $values = array(mktime(0,0,0), mktime(0,0,0), mktime(0,0,0));

        // Prepare query
        $q = $this->db->prepare($query);
        // Execute query
        $result = $this->db->execute($q, $values);
        // Check if error
        $this->check_for_error($result);
       
        if ($result->numRows() <= 0) {
            $this->err_msg = translate('You do not have any reservations scheduled.');
            return false;
        }
       
        while ($rs = $result->fetchRow()) {
            $return[] = $this->cleanRow($rs);
        }
       
        $result->free();
       
        return $return;
    }
Logged
Pages: [1]
  Print  
 
Jump to:  

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