예제 #1
0
 /**
  * Checks to see if a time is already reserved
  * @return whether the time is reserved or not
  */
 function check_res($resources_to_add)
 {
     $is_valid = $add_valid = true;
     $reserved = $this->db->checkAdditionalResources($this, $resources_to_add);
     $add_valid = count($reserved) <= 0;
     if (!$add_valid) {
         for ($i = 0; $i < count($reserved); $i++) {
             $this->add_error(translate('Additional resource is reserved', array($reserved[$i]['name'], $reserved[$i]['number_available'])));
         }
     } else {
         $is_valid = !$this->db->check_res($this);
     }
     if (!$is_valid) {
         $this->add_error(translate('reserved or unavailable', array(Time::formatDateTime($this->start_date + 60 * $this->start), Time::formatDateTime($this->end_date + 60 * $this->end))));
     }
     return $is_valid && $add_valid;
 }
예제 #2
0
/**
* Print table listing upcoming reservations
* This function prints a table of all upcoming
* reservations for the current user.  It also
* provides a way for them to modify and delete
* their reservations
* @param mixed $res array of reservation data
* @param string $err last error message from database
*/
function showReservationTable($res, $err)
{
    global $link;
    global $conf;
    $order = array('start_date', 'end_date', 'name', 'starttime', 'endtime', 'created', 'modified');
    $util = new Utility();
    $qs = isset($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : '';
    ?>
<table width="100%" border="0" cellspacing="0" cellpadding="1" align="center">
  <tr>
    <td class="tableBorder">
      <table width="100%" border="0" cellspacing="1" cellpadding="0">
        <tr>
          <td class="tableTitle" width="120">
		  	<a href="javascript: void(0);" onclick="showHideCpanelTable('reservation');">&#8250; <?php 
    echo translate('My Reservations');
    ?>
</a></div>
		  </td>
		  <td class="tableTitle2">
			<!-- <a href="export.php">Export Calendar to File</a> -->
		  	<!-- <?php 
    $link->doImageLink('export.php', 'img/export.gif', 'Export Reservations');
    ?>
 -->
		  </td>
          <td class="tableTitle">
            <div align="right">
              <!-- <a href="export.php">Export Calendar to File</a> -->
			  <!-- <?php 
    $link->doLink('javascript: help(\'my_reservations\');', '?', '', 'color: #FFFFFF;', translate('Help') . ' - ' . translate('My Reservations'));
    ?>
 -->
			</div>
          </td>
        </tr>
      </table>
      <div id="reservation" style="display: <?php 
    echo getShowHide('reservation');
    ?>
">
      <table width="100%" border="0" cellspacing="1" cellpadding="0">
        <tr class="rowHeaders">
          <td width="10%">
		  	<?php 
    $link->doLink($_SERVER['PHP_SELF'] . $util->getSortingUrl($qs, 'start_date'), translate('Start Date'));
    ?>
 
	
						
		  </td>
		  <td width="10%">
		 	 <?php 
    $link->doLink($_SERVER['PHP_SELF'] . $util->getSortingUrl($qs, 'end_date'), translate('End Date'));
    ?>
 

							 
		  </td>
          <td width="23%">
		  	<?php 
    $link->doLink($_SERVER['PHP_SELF'] . $util->getSortingUrl($qs, 'name'), translate('Room'));
    ?>
		  </td>
          <td width="10%">
		  	<?php 
    $link->doLink($_SERVER['PHP_SELF'] . $util->getSortingUrl($qs, 'starttime'), translate('Start Time'));
    ?>
		  </td>
          <td width="10%">
		  	<?php 
    $link->doLink($_SERVER['PHP_SELF'] . $util->getSortingUrl($qs, 'endtime'), translate('End Time'));
    ?>
		  </td>
          <!--<td width="20%">
		  	<?php 
    $link->doLink($_SERVER['PHP_SELF'] . $util->getSortingUrl($qs, 'created'), translate('Created'));
    ?>
		  </td>
          <td width="8%"><?php 
    echo '-';
    ?>
</td>
          <td width="8%"><?php 
    echo '-';
    ?>
</td>
	  -->
        </tr>

        <?php 
    // Write message if they have no reservations
    if (!$res) {
        echo '        <tr class="cellColor"><td colspan="8" align="center">' . $err . '</td></tr>';
    }
    // For each reservation, clean up the date/time and print it
    for ($i = 0; is_array($res) && $i < count($res); $i++) {
        $bgcolor = '';
        $rs = $res[$i];
        $class = 'cellColor' . $i % 2;
        if ($res[$i]['is_pending']) {
            $class = 'cpanelCell';
            $bgcolor = '#' . $conf['ui']['pending'][0]['color'];
        }
        $modified = isset($rs['modified']) && !empty($rs['modified']) ? Time::formatDateTime($rs['modified']) : 'N/A';
        echo "        <tr class=\"{$class}\" align=\"center\" style=\"background-color:{$bgcolor};\">" . "          <td>" . Time::formatReservationDate($rs['start_date'], $rs['starttime']) . '</td>' . '          <td>' . Time::formatReservationDate($rs['end_date'], $rs['endtime']) . '</td>' . '          <td style="text-align:left;">' . $rs['name'] . '</td>' . '          <td>' . Time::formatTime($rs['starttime']) . '</td>' . '          <td>' . Time::formatTime($rs['endtime']) . '</td>' . "        </tr>\n";
    }
    ?>
      </table>
	  </div>
    </td>
  </tr>
</table>
<?php 
}
예제 #3
0
파일: usage.php 프로젝트: razagilani/srrs
/**
* Perform search and print out results
* This function will perform the search for given
* criteria and print out formatted results.
* @param string $type output type
* @global $_POST['memberid'] array array of memberid's
* @global $_POST['piid'] array array of piID's
* @global $_POST['machid'] array array of machID's
* @global $_POST['startYear'] int starting year
* @global $_POST['startMonth'] int starting month
* @global $_POST['startDay'] int starting day
* @global $_POST['endYear'] int ending year
* @global $_POST['endMonth'] int ending month
* @global $_POST['endDay'] int ending day
* @global $_POST['starttime'] double starting time
* @global $_POST['endtime'] double ending time
*/
function search($type, $searchtype)
{
    global $db;
    global $link;
    $html = $type == 'html';
    // Store form vars for easy access
    $scheduleids = $_POST['scheduleid'];
    // Array of scheduleids
    $memberids = $_POST['memberid'];
    // Array of memberID's
    $machids = $_POST['machid'];
    // Array of machID's
    $startDateMin = mktime(0, 0, 0, intval($_POST['startMonthMin']), intval($_POST['startDayMin']), intval($_POST['startYearMin']));
    $startDateMax = mktime(0, 0, 0, intval($_POST['startMonthMax']), intval($_POST['startDayMax']), intval($_POST['startYearMax']));
    $endDateMin = mktime(0, 0, 0, intval($_POST['endMonthMin']), intval($_POST['endDayMin']), intval($_POST['endYearMin']));
    $endDateMax = mktime(0, 0, 0, intval($_POST['endMonthMax']), intval($_POST['endDayMax']), intval($_POST['endYearMax']));
    $starttimeMin = intval($_POST['starttimeMin']);
    $starttimeMax = intval($_POST['starttimeMax']);
    $endtimeMin = intval($_POST['endtimeMin']);
    $endtimeMax = intval($_POST['endtimeMax']);
    $percent = 0;
    $summarysearch = $_POST['summarysearch'];
    $summarytype = $_POST['summarytype'];
    //die($startDateMin . ' ' . $startDateMax . ' ' . $endDateMin . ' ' . $endDateMax);
    $res = $db->get_reservations($scheduleids, $memberids, $machids, $startDateMin, $startDateMax, $endDateMin, $endDateMax, $starttimeMin, $starttimeMax, $endtimeMin, $endtimeMax, $summarysearch, $summarytype);
    $rs_hours = $db->get_resource_times($machids);
    // Number of records returned
    $recs = count($res);
    // Print number of results found and a link to the text version
    echo '<h3 align="center">' . translate('Search Results found', array($recs)) . "</h3>\n" . '<h5 align="center">' . $link->getLink($_SERVER['PHP_SELF'], translate('Try a different search')) . "</h5>\n";
    print_change_output($_POST);
    echo "<hr noshade size=\"1\">\n";
    // If there were no results found, exit
    if ($recs <= 0) {
        return;
    }
    // Set up initial booleans
    $newUser = false;
    $newMach = false;
    $totalHours = 0;
    $resNo = 1;
    // Get first row
    $rs = $res[0];
    // Set up initial previous user/machine variables
    $prevUser = $rs['memberid'];
    $prevMach = $rs['machid'];
    /* Text file variables */
    // Create text output
    // Make global to share with other functions
    if ($type == 'text') {
        $GLOBALS['dblStr'] = str_repeat('=', 50) . "\n";
        $GLOBALS['sglStr'] = str_repeat('-', 50) . "\n";
    }
    if ($type != 'html') {
        // Plain-text view
        echo '<pre>';
        echo translate('Search Run On') . ' ' . date('M jS, Y - h:i:s a') . "\r\n\r\n";
    }
    // Print out first table with this information
    printUserInfo($rs['fname'], $rs['lname'], $rs['memberid'], $type);
    printTableHeader($rs['fname'], $rs['lname'], $rs['name'], $type, $rs['scheduletitle']);
    if ($type == 'csv') {
        // Print record id line for csv output
        print_csv_header();
    }
    // Repeat for each record
    for ($i = 0; $i < count($res); $i++) {
        $rs = $res[$i];
        // Current reservation
        // If we are at a new user, set them to prevUser
        if ($prevUser != $rs['memberid']) {
            $prevUser = $rs['memberid'];
            $newUser = true;
        }
        // If we are at a new resource, set it to prevMach
        if ($prevMach != $rs['machid']) {
            $prevMach = $rs['machid'];
            $newMach = true;
        }
        // If we are making a new table (by advancing to new user or resource)
        if ($newUser || $newMach) {
            // Write total hours row and close table
            // Write out total hours for this machine
            printTableFooter($totalHours, $type, $percent);
            $totalHours = 0;
            // Reset total hours
            $resNo = 1;
            // Reset total reservations
            // If it is a new user, write a comment, a extra break, and the user info
            if ($newUser) {
                // Write extra break to text output
                if ($type == 'text') {
                    echo "\r\n\r\n";
                }
                if ($html) {
                    echo '<p>&nbsp</p>';
                }
                printUserInfo($rs['fname'], $rs['lname'], $rs['memberid'], $type);
            }
            // Set both newUser and newResource to false
            $newUser = false;
            $newMach = false;
            // Write next table header
            printTableHeader($rs['fname'], $rs['lname'], $rs['name'], $type, $rs['scheduletitle']);
        }
        // Keep running total of hours on this machine
        $totalHours = $totalHours + ($rs['end_date'] / 60 + $rs['endtime'] - ($rs['start_date'] / 60 + $rs['starttime']));
        // Calculate what percentage that is of total machine time
        $percent = sprintf('%.02f', $totalHours / $rs_hours[$rs['machid']] * 100);
        // Store variables
        $start_date = Time::formatDate($rs['start_date'], null, false);
        $end_date = Time::formatDate($rs['end_date'], null, false);
        $created = Time::formatDateTime($rs['created'], null, false);
        $modified = !empty($rs['modified']) ? Time::formatDateTime($rs['modified'], null, false) : translate('N/A');
        $starttime = Time::formatTime($rs['starttime'], false);
        $endtime = Time::formatTime($rs['endtime'], false);
        $totTime = $rs['end_date'] / 60 + $rs['endtime'] - ($rs['start_date'] / 60 + $rs['starttime']);
        print_reservation_data($type, $link, $resNo++, $start_date, $end_date, $created, $modified, $starttime, $endtime, $totTime, $rs['resid'], $rs['fname'], $rs['lname'], $rs['name'], $rs['memberid'], $rs['scheduletitle']);
    }
    unset($rs);
    // On last record, print out total hours
    // Write out total hours for this machine
    printTableFooter($totalHours, $type, $percent);
    if (!$html) {
        echo '</pre>';
    }
}
예제 #4
0
/**
* Print out created and modifed times in a table, if they exist
* @param int $c created timestamp
* @param int $m modified stimestamp
*/
function print_create_modify($c, $m)
{
    ?>
    <table width="100%" border="0" cellspacing="0" cellpadding="1">
    <tr class="tableBorder">
     <td>
      <table width="100%" border="0" cellspacing="1" cellpadding="0">
       <tr>
       <td class="formNames" width="100"><?php 
    echo translate('Created');
    ?>
</td>
       <td class="cellColor"><?php 
    echo Time::formatDateTime($c);
    ?>
</td>
	   </tr>
       <tr>
       <td class="formNames"><?php 
    echo translate('Last Modified');
    ?>
</td>
       <td class="cellColor"><?php 
    echo !empty($m) ? Time::formatDateTime($m) : translate('N/A');
    ?>
</td>
       </tr>
      </table>
     </td>
    </tr>
   </table>
   <p>&nbsp;</p>
<?php 
}