<?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'));

$cash_traf_notf_details=array();//$ref_id->getGTNNotification($this->session->userdata('ss_user_id'));
$cash_traf_notf_details=$ref_id->getcash_trafNotification();

//print_r($cash_traf_notf_details);

$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;">
    
    
<!--Transection Notifiation start-->
  <?php
										 
										 //print_r($gtn_notf_details);
										 $to_whe_name='';
										 foreach ($cash_traf_notf_details as $row){
										  $display_list=0;
																
															 if($this->session->userdata('ss_group_id')==1){
																  $display_list=1;
															 }else if($this->session->userdata('ss_group_id')==9){
																  $display_list=1;
															 }else if($ss_warehouse_id==$row->to_warehouse_id){
																  $display_list=1;
															 }
															 
															 
															
														 if($display_list)
														{
																
																  $msg1='';
																  $msg2='';
																  
																  $whe_details=$ref_id->get_warehouse_info($row->to_warehouse_id);
																  $to_whe_name=$whe_details['name'];
																  
																  if ($row->at_status==0) {
																      $not_count_gtn++;
                                                              ?>
<a id="modal_ajax_cash_transfer_btn"  href="javascript:;" onclick="cash_transfer_active('<?php echo $row->acctrnss_id;?>')">
<!--<span class="label label-primary"><i class="fa fa-user"></i></span>-->
<span class="message"> 
<?php
$date_t=site_date($row->acctrnss_date);
echo "$not_count_gtn. ";	
 echo "Cash Transfer <b>$row->acctrnss_amount</b> / $date_t (From: <b>$row->name</b>  To: <b>$to_whe_name</b>)";?>
</span>
</a>

<?php } } }  ?>
<!--End Transection Notification-->

  
         <?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($this->session->userdata('ss_group_id')==9){
																  $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)); ?>" >
													<!--<span class="label label-primary"><i class="fa fa-user"></i></span>-->
													<span class="message"> 
                                                    <?php echo "$not_count_gtn. ";?>
                                                   
                                                     <span style="font-weight:bold">
                                                  <?php echo $row->name.'  '; ?>
                                                   to  <?php echo $to_whe_name.'  '; 
												   ?>
                                                    </span> 
                                                   <?php
                                                   echo " ($row->trnsfr_datetime)";
                                                   
												   ?>
                                                  
                                                   <?php
                                                   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 -->
						
						<?php
						//get active shift id by user
						$ss_user_id=$this->session->userdata('ss_user_id');
						$shift_date=date("Y-m-d");
						$active_shift_des=$ref_id->get_active_shift_by_user_id_date($ss_user_id,$shift_date);
					//	print_r($active_shift_des);
						
						
						if(!count($active_shift_des)){
						?>
						
						<li class="dropdown current-user">
							    <a target="_blank" data-toggle="" data-hover="dropdown" class="dropdown-toggle" data-close-others="true" id="modal_ajax_transactions_btn_2"><span class="username btn btn-success">SHIFT START</span></a>
							    </li>
							    <?php } else { 
							    
							    if($active_shift_des['user_id']==$ss_user_id){
							    ?>
							    
							<li class="dropdown current-user">
							    <a target="" href="<?php echo base_url('/cash_balance'); ?>" data-toggle="" data-hover="dropdown" class="dropdown-toggle" data-close-others="true" >
								
								<span class="username btn btn-danger">
							 SHIFT END  </span></a>
							    </li>
							    <?php 
							    if($this->session->userdata('ss_group_id')==1){
							    ?>
							    <li class="dropdown current-user">
							    <a onClick="print_transactions('<?php echo $active_shift_des['acctrnss_id'];?>')" data-toggle="" data-hover="dropdown" class="dropdown-toggle" data-close-others="true" >
								
								<span class="username btn btn-success">
							 DETAILS  </span></a>
							    </li>
							    <?php } ?>
							    <?php } 
							    } ?>
						
						<!-- 
							<li class="dropdown current-user">
							    <a target="_blank" href="<?php echo base_url('app_android/sales_print'); ?>" data-toggle="" data-hover="dropdown" class="dropdown-toggle" data-close-others="true" >
								
								<span class="username">
							    Phone Bill Print </span></a>
							    </li>
							    -->

						<!-- 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/user_change_pw/');?>/<?php echo $this->session->userdata('ss_user_id');?>">
										<i class="clip-user-2"></i>
										&nbsp;Change Password
									</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>
                        <li>
                        	<div id="ajax-loading-top-corner" class="collapse" style="position: absolute; right: 31px; top: 80px; float: right; border-radius:40px; height: 75px; width: 75px; text-align: center; background-color:rgba(17,80,174,0.3)">
                      			<i class="fa fa-cog fa-spin fa-3x" style="padding:18px;"></i>
                    		</div>
      </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>