<!--Notice: (c)2013 This page is part of the management program for Manase, Gaborone, 
and developed by Customized Software (Pty) Ltd, Gaborone, Botswana. 
Customized Software holds the copyright on the source code on this and all other pages in the 
management program. For more info contact Customized Software on email: info@bwcustomized.com-->


<title>Manase</title>
<link rel="shortcut icon" type="image/x-icon" href="../images/favicon.ico">


<!--style sheets-->
<link rel="stylesheet" type="text/css" href="../css/main.css" />
<link href="../css/navigation.css" rel="stylesheet" type="text/css" />
<link type="text/css" rel="stylesheet" media="all" 	href="../css/chat.css" />

<!--jscript-->
<script type="text/javascript" src="../jscript/jquery.1.4.2.js"></script>
<script type="text/javascript" src="../jscript/chat.js"></script>
<script language="JavaScript" src="../jscript/go_to_url.js"  type="text/javascript"></script> 


<?php 


$today = date('Y-m-d');
date_default_timezone_set('Africa/Gaborone');
$entry_date = date("Y-m-d H:i:s", time()); 

$table_name = "man_active_users";
$active_users_query = "SELECT username FROM $table_name";
$active_users_result = execsql($active_users_query);
$active_users_num = mysql_num_rows($active_users_result);

//$table_name = "man_active_users";
//$update_query = "UPDATE $table_name SET last_active = '".$entry_date."' WHERE username = '".$_SESSION['username']."' ";
//execsql($update_query);

function curPageName() {
 return substr($_SERVER["SCRIPT_NAME"],strrpos($_SERVER["SCRIPT_NAME"],"/")+1);
}

$path_current = getcwd();
if ( strpos("$path_current","hr_module")>0) {$current_page = "hr";}
if ( strpos("$path_current","sales")>0) {$current_page = "sales";}
if ( strpos("$path_current","production")>0) {$current_page = "production";}
if ( strpos("$path_current","orders")>0) {$current_page = "orders";}
if ( strpos("$path_current","maintenance")>0) {$current_page = "maintenance";}
if ( strpos("$path_current","store")>0) {$current_page = "stores";}
if ( strpos("$path_current","transport")>0) {$current_page = "transport";}
if ( strpos("$path_current","admin")>0) {$current_page = "admin";};


$table_name = $_SESSION['db_prefix']."_alert_message";
$hr_alert_query = "SELECT message_id FROM $table_name WHERE department = 'hr' AND user_name = '".$_SESSION['username']."' AND read_done IS NULL AND no_view IS NULL";
$hr_alert_result = mySQL_query($hr_alert_query);
$hr_alert_num = mysql_num_rows($hr_alert_result);
if ($hr_alert_num>5) { $hr_alert_num=6; }

$table_name = $_SESSION['db_prefix']."_alert_message";
$sales_alert_query = "SELECT message_id FROM $table_name WHERE department = 'sales' AND user_name = '".$_SESSION['username']."' AND read_done IS NULL AND no_view IS NULL";
$sales_alert_result = mySQL_query($sales_alert_query);
$sales_alert_num = mysql_num_rows($sales_alert_result);
if ($sales_alert_num>5) { $sales_alert_num=6; }

$table_name = $_SESSION['db_prefix']."_alert_message";
$orders_alert_query = "SELECT message_id FROM $table_name WHERE department = 'orders' AND user_name = '".$_SESSION['username']."' AND read_done IS NULL AND no_view IS NULL ";
$orders_alert_result = mySQL_query($orders_alert_query);
$orders_alert_num = mysql_num_rows($orders_alert_result);
if ($orders_alert_num>5) { $orders_alert_num=6; }

$table_name = $_SESSION['db_prefix']."_alert_message";
$maintenance_alert_query = "SELECT message_id FROM $table_name WHERE department = 'maintenance' AND user_name = '".$_SESSION['username']."' AND read_done IS NULL AND no_view IS NULL";
$maintenance_alert_result = mySQL_query($maintenance_alert_query);
$maintenance_alert_num = mysql_num_rows($maintenance_alert_result);
if ($maintenance_alert_num>5) { $maintenance_alert_num=6; }


$table_name = $_SESSION['db_prefix']."_alert_message";
$stores_alert_query = "SELECT message_id FROM $table_name WHERE department = 'stores' AND user_name = '".$_SESSION['username']."' AND read_done IS NULL AND no_view IS NULL";
$stores_alert_result = mySQL_query($stores_alert_query);
$stores_alert_num = mysql_num_rows($stores_alert_result);
if ($stores_alert_num>5) { $stores_alert_num=6; }

$table_name = $_SESSION['db_prefix']."_alert_message";
$production_alert_query = "SELECT message_id FROM $table_name WHERE department = 'production' AND user_name = '".$_SESSION['username']."' AND read_done IS NULL AND no_view IS NULL";
$production_alert_result = mySQL_query($production_alert_query);
$production_alert_num = mysql_num_rows($production_alert_result);
if ($production_alert_num>5) { $production_alert_num=6; }

$table_name = $_SESSION['db_prefix']."_alert_message";
$transport_alert_query = "SELECT message_id FROM $table_name WHERE department = 'transport' AND user_name = '".$_SESSION['username']."' AND read_done IS NULL AND no_view IS NULL";
$transport_alert_result = mySQL_query($transport_alert_query);
$transport_alert_num = mysql_num_rows($transport_alert_result);

$table_name = $_SESSION['db_prefix']."_alert_message";
$admin_alert_query = "SELECT message_id FROM $table_name WHERE department = 'admin' AND user_name = '".$_SESSION['username']."' AND read_done IS NULL AND no_view IS NULL";
$admin_alert_result = mySQL_query($admin_alert_query);
$admin_alert_num = mysql_num_rows($admin_alert_result);


?>

<div class="header_frame">
  <table width="967" height="81" cellpadding="0" cellspacing="0" id="navigation_main_table" >
    <tr>
      <td width="110" rowspan="2" align="left" valign="middle"><img src="../images/manase_logo.png" width="110" height="118" /></td>
      <td height="37" valign="top"><div align="center" class="label_header_title"><img src="../images/manase.png" width="233" height="32" /></div></td>
      <td width="133" rowspan="2" align="center" valign="middle"><img src="../images/m_works_logo_2.png" width="110" height="118" /></td>
    </tr>
    <tr valign="top">
      <td width="722" height="38" align="left" valign="top">
      <div class="header_button_holder_frame">
      
      <a href="../hr_module/hr_main.php?date=0"><div class="<?php if ($current_page =='hr') {echo 'header_button_active'; } else { echo 'header_button'; }?>">
      <div align="center">
      <table width="85" border="0" >
        <tr>
        <td height="20" align="center" valign="bottom" <?php if ($hr_alert_num>0) {?> style="background-image:url(../images/alert_circle_<?php echo $hr_alert_num ?>.png); background-repeat:no-repeat;" <?php } ?>>HR</td>
        </tr>
        </table>
        </div>
        </div>
       </a>
       
      <a href="../sales/sales_main.php?date=0"><div class="<?php if ($current_page =='sales') {echo 'header_button_active'; } else { echo 'header_button'; }?>">
      <div align="center">
      <table width="85" border="0" >
        <tr>
        <td height="20" align="center" valign="bottom" <?php if ($sales_alert_num>0) {?> style="background-image:url(../images/alert_circle_<?php echo $sales_alert_num ?>.png); background-repeat:no-repeat;" <?php } ?>>Sales</td>
        </tr>
        </table>
        </div>
        </div>
       </a>
      
      <a href="../orders/orders_main.php"><div class="<?php if ($current_page =='orders') {echo 'header_button_active'; } else { echo 'header_button'; }?>">
        <div align="center">
      <table width="85" border="0" >
        <tr>
        <td height="20" align="center" valign="bottom" <?php if ($orders_alert_num>0) {?> style="background-image:url(../images/alert_circle_<?php echo $orders_alert_num ?>.png); background-repeat:no-repeat;" <?php } ?>>Orders</td>
        </tr>
        </table>
        </div>
        </div>
       </a>
        
        
      <a href="../maintenance/maintenance_main.php"><div class="<?php if ($current_page =='maintenance') {echo 'header_button_active'; } else { echo 'header_button'; }?>">
      <div align="center">
      <table width="85" border="0" >
        <tr>
        <td height="20" align="center" valign="bottom" <?php if ($maintenance_alert_num>0) {?> style="background-image:url(../images/alert_circle_<?php echo $maintenance_alert_num ?>.png); background-repeat:no-repeat;" <?php } ?>>Maintenance</td>
        </tr>
        </table>
        </div>
        </div>
       </a>
      

      
      <a href="../store/store_main.php"><div class="<?php if ($current_page =='stores') {echo 'header_button_active'; } else { echo 'header_button'; }?>">
       <div align="center">
      <table width="85" border="0" >
        <tr>
        <td height="20" align="center" valign="bottom" <?php if ($stores_alert_num>0) {?> style="background-image:url(../images/alert_circle_<?php echo $stores_alert_num ?>.png); background-repeat:no-repeat;" <?php } ?>>Stores</td>
        </tr>
        </table>
        </div>
        </div>
       </a>
      
      <a href="../production/production_main.php"><div class="<?php if ($current_page =='production') {echo 'header_button_active'; } else { echo 'header_button'; }?>">
      <div align="center">
      <table width="85" border="0" >
        <tr>
        <td height="20" align="center" valign="bottom" <?php if ($production_alert_num>0) {?> style="background-image:url(../images/alert_circle_<?php echo $production_alert_num ?>.png); background-repeat:no-repeat;" <?php } ?>>Production</td>
        </tr>
        </table>
        </div>
        </div>
       </a> 
      
      <a href="../transport/transport_main.php"><div class="<?php if ($current_page =='transport') {echo 'header_button_active'; } else { echo 'header_button'; }?>">
       <div align="center">
      <table width="85" border="0" >
        <tr>
        <td height="20" align="center" valign="bottom" <?php if ($transport_alert_num>0) {?> style="background-image:url(../images/alert_circle_<?php echo $transport_alert_num ?>.png); background-repeat:no-repeat;" <?php } ?>>Transport</td>
        </tr>
        </table>
        </div>
        </div>
       </a>
      
      
      <a href="../admin_module/user_list.php?date="><div class="<?php if ($current_page =='admin') {echo 'header_button_active'; } else { echo 'header_button'; }?>">
      <div align="center">
      <table width="85" border="0" >
        <tr>
        <td height="20" align="center" valign="bottom" <?php if ($admin_alert_num>0) {?> style="background-image:url(../images/alert_circle_<?php echo $admin_alert_num ?>.png); background-repeat:no-repeat;" <?php } ?>>admin</td>
        </tr>
        </table>
        </div>
        </div>
       </a>
       
      </div>
      </td>
    </tr>
  </table>
</div>

