<?php
$ref_id = new Common_Model();
$gtn_notf_details=array();//$ref_id->getGTNNotification($this->session->userdata('ss_user_id'));
$gtn_notf_details=$ref_id->getGTNNotification($this->session->userdata('ss_user_id'));

$not_count_gtn=0;
$ss_warehouse_id=$this->session->userdata('ss_warehouse_id');
?>

	<ul class="nav navbar-right">
   
                                

						<!-- start: NOTIFICATION DROPDOWN -->
						<li class="dropdown">
							<a data-toggle="dropdown" data-hover="dropdown" class="dropdown-toggle" data-close-others="true" href="#">
								<i class="clip-notification-2"></i>
								<span class="badge"> <!--0--> <span id="not_count_dis_2_gtn">0 </span></span>
							</a>
							<ul class="dropdown-menu notifications">
                             <!--<li>
									<span class="dropdown-menu-title"> You have <span id="not_count_dis_2_gtn">0 </span> Transfer notifications</span>
								</li>-->
								
								<li>
									<div class="drop-down-wrapper">
									  
<!-- Scroll bar present and enabled -->        
    <div style="width: 100%; height: 240px; overflow-y: scroll;">
         <?php
										 
										 //print_r($gtn_notf_details);
										 $to_whe_name='';
										 foreach ($gtn_notf_details as $row){
										  $display_list=0;
																
															 if($this->session->userdata('ss_group_id')==1){
																  $display_list=1;
															 }else if($ss_warehouse_id==$row->trnsfr_to_warehouse_id){
																  $display_list=1;
															 }
															 
															 
															
														 if($display_list)
														{
																
																  $msg1='';
																  $msg2='';
																  
																  $whe_details=$ref_id->get_warehouse_info($row->trnsfr_to_warehouse_id);
																  $to_whe_name=$whe_details['name'];
																  
																  if (!$row->reviewed_status) {
																      $not_count_gtn++;
                                                              ?>

	<a href="<?php echo base_url("transfer/view/$row->trnsfr_id".'/u'.rand(000,999)); ?>" target="_blank">
													<!--<span class="label label-primary"><i class="fa fa-user"></i></span>-->
													<span class="message"> 
                                                    <?php echo "$not_count_gtn. ";?>
                                                    New Transfer 
                                                  <?php echo $row->name.'  '; ?>
                                                   to  <?php echo $to_whe_name.'  '; 
                                                   echo " ($row->trnsfr_reference_no)";
                                                   
                                                   echo " / Items: ";
                                                   ?>
                                                     <span style="font-weight:bold">
                                                         <?php

if($row->trnsfr_id){
	
	$tra_des=$ref_id->get_trnsfr_item_list_by_trnsfr_id($row->trnsfr_id);
	
foreach ($tra_des as $row_t)
                                                            
{
												        	
echo $row_t['product_name'].' X '.number_format($row_t['trnsfr_itm_quantity'], 0, '', ',') . ' , ';
                 
 }

}
                                                   ?>
                                                   
                                                   </span>
                                                   </a>




<?php

} } } ?>
    </div>
    
    <!-- End Scroll bar present and enabled -->
										<ul>
                                        
											
											<!-- 
											<li>
												<a href="javascript:void(0)">
													<span class="label label-success"><i class="fa fa-comment"></i></span>
													<span class="message"> New comment</span>
													<span class="time"> 7 min</span>
											</a></li>-->
										</ul>
									</div>
								</li>
								<!--<li class="view-all">
									<a href="javascript:void(0)">
										See all notifications <i class="fa fa-arrow-circle-o-right"></i>
									</a>
								</li>-->
							</ul>
						</li>
						<!-- end: NOTIFICATION DROPDOWN -->

						<!-- start: USER DROPDOWN -->
                        <?php 
						//$ss_warehouse_id=1;
						
						$mod_warehouse=new Common_Model();
						
						$warehouse_des=$mod_warehouse->get_warehouse_info($ss_warehouse_id);
						
						
						//print_r($gtn_notf_details);
						?>
						<li class="dropdown current-user">
							<a data-toggle="dropdown" data-hover="dropdown" class="dropdown-toggle" data-close-others="true" href="#">
								
								<span class="username">Welcome 
								<?php echo $this->session->userdata('ss_user_first_name'); ?> (<?php echo $this->session->userdata('ss_user_group_name'); ?>) <span class="label label-primary"><?php echo $warehouse_des['name'] ?></span>
                                </span>
								<i class="clip-chevron-down"></i>
							</a>
							<ul class="dropdown-menu">
								<li>
									<a href="<?php echo base_url('users/create_user'); ?>">
										<i class="clip-user-2"></i>
										&nbsp;My Profile
									</a>
								</li>
								<li>
									<a href="<?php echo base_url('logout'); ?>">
										<i class="clip-exit"></i>
										&nbsp;Log Out
									</a>
                                    
								</li>
                                <li>
									<a href=""><?php echo date("Y-m-d H:i:s"); ?></a>
                                    
								</li>
							</ul>
						</li>
						<!-- end: USER DROPDOWN -->
					</ul>
                    
                    
<script src="<?php echo asset_url(); ?>plugins/jQuery-lib/2.0.3/jquery.min.js"></script>
<script type="text/javascript">
$(function() {
	var val='';


	
	$('#not_count_dis_gtn').html('Transfer:'+'<?php echo $not_count_gtn;?>');
	$('#not_count_dis_2_gtn').html( <?php echo $not_count_gtn;?>);

});



var waitTime = 30 * 60 * 1000; // = 30min.


/*setTimeout(function(){
  window.location = "<?php echo base_url('logout/');?>";
}, waitTime);*/
</script>