<?php


////////////////////// CORE FUNCTION | MODULE FUNCTION (c) i2d Technologies //////////////////////////////////
if (!function_exists('fetch_notifications')) {
function fetch_notifications($table,$ref,$ref_col,$fields,$limit) { 


$tdsettings_count=array(
	'table'=>$table,
	'id_col'=>id_col,
	'ref_value'=>$ref,
	'ref_col'=>$ref_col,
	'where_col'=>status,
	'where_value'=>'Active',
	'fields_array'=>$fields,
	'status_vaue'=>'Active',
	'order'=>'DESC',
	'echo'=>'0',
	'limit'=>$limit,
	'counter'=>'1',
	'order_col'=>id_col,
	'type'=>'wherecol_ref_status');

	$tdload=db_fetch($tdsettings_count);

$tdsettings=array(
	'table'=>$table,
	'id_col'=>id_col,
	'ref_value'=>$ref,
	'ref_col'=>$ref_col,
	'where_col'=>status,
	'where_value'=>'Active',
	'fields_array'=>$fields,
	'status_vaue'=>'Active',
	'order'=>'DESC',
	'echo'=>'0',
	'limit'=>$limit,
	'order_col'=>id_col,
	'type'=>'wherecol_ref_status');

	$tdload2=db_fetch($tdsettings);

$param=array(
'count'=>$tdload,
'notifications'=>$tdload2
);

return $param;


} 
}
/////////////////////////// function ends /////////////////////////////////

/////////////////////////// function ends /////////////////////////////////
////////////////////// FUNCTION | MODULE FUNCTION (c) i2d Technologies //////////////////////////////////

if (!function_exists('notifications')) {
	function notifications($settings){

if (array_key_exists('table', $settings)) {
   $table=$settings['table'];
   }
   
if (array_key_exists('limit', $settings)) {
   $limit=$settings['limit'];
   }	
if (array_key_exists('path', $settings)) {
   $path=$settings['path'];
   }	

$fields=array(sub_table_title,dated,table_id);   

$count=fetch_notifications($table,routine_notification_alias,"alias",$fields,$limit);   



   ?>
   
   <!-- PAGE FUNCTION NOTIFICATIONS STARTS (c) i2d Technologies Website Engine -->
   <li class="dropdown top-menu-item-xs">
                                    <a href="#" data-target="#" class="dropdown-toggle menu-right-item" data-toggle="dropdown" aria-expanded="true">
                                        <i class="mdi mdi-bell-outline"></i> 
										<?php if($count!=0){ ?>
										<span class="label label-danger"><?php echo $count['count']; ?>
										<?php } else { ?>
										<span class="label label-primary">0
										<?php } ?>
										</span>
                                    </a>
<?php
if(!empty($count['notifications'])){
	?>								
                                    <ul class="dropdown-menu p-0 dropdown-menu-lg">
                                        <!--<li class="notifi-title"><span class="label label-default pull-right">New 3</span>Notification</li>-->
                                        <li class="list-group notification-list" style="height: 267px;">
                                           <div class="slimscroll">
                                            


<?php 

if(!empty($count['notifications'])){

foreach($count['notifications'] as $item){ 


?>                                              

											   <!-- list item-->
                                               <a href="<?php echo $path."/view/notification/".$item[id_col]; ?>" class="list-group-item">
                                                  <div class="media">
                                                     <div class="media-left p-r-10">
                                                        <em class="fa fa-clock-o bg-success"></em>
                                                     </div>
                                                     <div class="media-body">
                                                        <h5 class="media-heading">New Notification!</h5>
                                                        <p class="m-0">
                                                            <small><?php echo $item[sub_table_title]." on ".$item[dated]; ?></small>
                                                        </p>
                                                     </div>
                                                  </div>
                                               </a>

                                               <!-- list item-->
<?php } 
}

?>              

                                          
											   
											   
                                           </div>
                                        </li>
                                        <!--<li>-->
                                            <!--<a href="javascript:void(0);" class="list-group-item text-right">-->
                                                <!--<small class="font-600">See all notifications</small>-->
                                            <!--</a>-->
                                        <!--</li>-->
                                    </ul>
<?php } ?>
                                </li>
 <!-- PAGE FUNCTION NOTIFICATIONS ENDS (c) i2d Technologies Website Engine -->   
<?php   
}
}
//////////////////////////// HTML FUNCTION ENDS (c) i2d Technologies ///////////////////////////////////////























?>