public
Created

Computer Availability Map UI for Drupal

  • Download Gist
computer-drupal.php
PHP
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
<?php
drupal_add_css("sites/all/themes/osulibraries/comp_map.css");
drupal_add_js('setTimeout("window.location.reload()",300000);', 'inline');
db_set_active('comp_map');
 
$total_pc_results = db_query("SELECT * FROM compstatus WHERE computer_type='PC'");
$avail_pc_results = db_query("SELECT * FROM compstatus WHERE status='0' AND computer_type='PC'");
$pcs = mysql_num_rows($avail_pc_results) . '/' . mysql_num_rows($total_pc_results);
$total_mac_results = db_query("SELECT * FROM compstatus WHERE computer_type='MAC'");
$avail_mac_results = db_query("SELECT * FROM compstatus WHERE status='0' AND computer_type='MAC'");
$macs = mysql_num_rows($avail_mac_results) . '/' . mysql_num_rows($total_mac_results);
$result = db_query("SELECT * FROM compstatus");
 
db_set_active('default');
?>
 
<div id="computer_map">
#Text Equivalant
<p>PC's available: <?php echo $pcs; ?> Mac's available: <?php echo $macs; ?></p>
 
<div id="computer_map_600">
<dl>
<?php while($row = mysql_fetch_assoc($result)){?>
<dt class="<?=($row['status']==0 ? 'avail' : 'busy');?>_<?=(strcmp($row['computer_type'],'PC')==0 ? 'pc' : 'mac');?>_600 icon" style="left: <?=($row['left_pos']*2);?>px; top:<?=($row['top_pos']*2)+30;?>px" ><?=$row['computer_name']?></dt>
<?php }?>
</dl>
<dl>
<dt class="avail_pc_600 legend_icon" style="left: 376px; top: -2795px;">PC Available</dt>
<dt class="busy_pc_600 legend_icon" style="left: 376px; top: -2790px;">PC Busy</dt>
<dt class="avail_mac_600 legend_icon" style="left: 376px; top: -2785px;">Mac Available</dt>
<dt class="busy_mac_600 legend_icon" style="left: 376px; top: -2780px;">Mac Busy</dt>
</dl>
</div>
#Last Update
<p>Map is updated every 5 minutes. Last updated: <?php echo date("M j, Y \&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;\m\d\a\s\h\; H:i:s"); ?></p>
#end map
</div>
</div>

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.