<?php if($reminders_count>0){ ?>
  <li class="m-nav__item m-topbar__notifications m-topbar__notifications--img m-dropdown m-dropdown--large m-dropdown--header-bg-fill m-dropdown--arrow m-dropdown--align-center 	m-dropdown--mobile-full-width" m-dropdown-toggle="click" m-dropdown-persistent="1">
  <a href="#" class="m-nav__link m-dropdown__toggle" id="m_topbar_notification_icon">
    <span class="m-nav__link-badge m-badge m-badge--dot m-badge--dot-small m-badge--danger"></span>
    <span class="m-nav__link-icon"><i class="fa fa-bell"></i></span>
  </a>
  <div class="m-dropdown__wrapper">
    <span class="m-dropdown__arrow m-dropdown__arrow--center"></span>
    <div class="m-dropdown__inner">
      <div class="m-dropdown__header m--align-center" style="background: url(<?php echo $this->config->item('Template_template_file_url'); ?>template/assets/app/media/img/misc/notification_bg.jpg); background-size: cover;">
        <span class="m-dropdown__header-title"><?php echo $reminders_count?> New</span>
        <span class="m-dropdown__header-subtitle">Reminders Notifications</span>
      </div>
      <div class="m-dropdown__body">
        <div class="m-dropdown__content">
          <div class="m-scrollable" data-scrollable="true" style="height:250px;overflow-y: auto;" data-height="250" data-mobile-height="200">
            <div class="m-list-timeline m-list-timeline--skin-light">
              <div class="m-list-timeline__items">
                <?php foreach ($reminders->result() as $key => $value) { ?>
                  <a href="<?php echo base_url().'reminders' ?>">
                    <div class="m-list-timeline__item">
                      <span class="m-list-timeline__badge -m-list-timeline__badge--state-success"></span>
                      <span class="m-list-timeline__text"><strong><?php echo $value->reminder_type ?> Reminder</strong> </span>
                      <span class="m-list-timeline__time" style="font-size: 1rem;font-weight: 800;"><?php echo date('d-m-Y',strtotime($value->reminder_date))?></span>
                    </div>
                  </a>
                <?php } ?>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
  </li>
<?php } ?>
<?php if($this->config->item('app_module_sales_quotation')==1 && sizeof($sales_quotations_approved)>0  && $this->session->userdata('user_role') != 'qs_manager' && $this->session->userdata('user_role') != 'qs' && $this->session->userdata('user_role') != 'procurement_engineer' && $this->session->userdata('user_role') != 'project_manager'){ ?>
  <li class="m-nav__item m-topbar__notifications m-topbar__notifications--img m-dropdown m-dropdown--large m-dropdown--header-bg-fill m-dropdown--arrow m-dropdown--align-center 	m-dropdown--mobile-full-width" m-dropdown-toggle="click" m-dropdown-persistent="1">
  <a href="#" class="m-nav__link m-dropdown__toggle" id="m_topbar_notification_icon">
    <span class="m-nav__link-badge m-badge m-badge--dot m-badge--dot-small m-badge--danger"></span>
    <span class="m-nav__link-icon"><i class="fa fa-file-alt"></i></span>
  </a>
  <div class="m-dropdown__wrapper">
    <span class="m-dropdown__arrow m-dropdown__arrow--center"></span>
    <div class="m-dropdown__inner">
      <div class="m-dropdown__header m--align-center" style="background: url(<?php echo $this->config->item('Template_template_file_url'); ?>template/assets/app/media/img/misc/notification_bg.jpg); background-size: cover;">
        <span class="m-dropdown__header-title"><?php echo sizeof($sales_quotations_approved)?> New</span>
        <span class="m-dropdown__header-subtitle">Quotation Notifications</span>
      </div>
      <div class="m-dropdown__body">
        <div class="m-dropdown__content">
          <div class="m-scrollable" data-scrollable="true" style="height:250px;overflow-y: auto;" data-height="250" data-mobile-height="200">
            <div class="m-list-timeline m-list-timeline--skin-light">
              <div class="m-list-timeline__items">
                <?php foreach ($sales_quotations_approved as $key => $value) { ?>
                  <a href="<?php echo base_url().'sales_quotation/profile/view/'.$value['quotation_id'] ?>">
                    <div class="m-list-timeline__item">
                      <span class="m-list-timeline__badge -m-list-timeline__badge--state-success"></span>
                      <span class="m-list-timeline__text"><strong>Sales Quotation #BIS-<?php echo $value['quotation_id'] ?> is Approved By : <?php echo $value['user'] ?> [Customer: <?php echo $value['customer_name'] ?>]</strong> </span>
                      <span class="m-list-timeline__time" style="font-size: 1rem;font-weight: 800;"><?php echo date('d-m-Y',strtotime($value['quotation_date']))?></span>
                    </div>
                  </a>
                <?php } ?>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
  </li>
<?php } ?>

<?php if($purchase_notifications_count>0){
  ?>
  <li class="m-nav__item m-topbar__notifications m-topbar__notifications--img m-dropdown m-dropdown--large m-dropdown--header-bg-fill m-dropdown--arrow m-dropdown--align-center 	m-dropdown--mobile-full-width" m-dropdown-toggle="click"
  m-dropdown-persistent="1" >
  <a href="#" class="m-nav__link m-dropdown__toggle" id="m_topbar_notification_icon">
    <span class="m-nav__link-badge m-badge m-badge--dot m-badge--dot-small m-badge--danger"></span>
    <span class="m-nav__link-icon"><i class="fa fa-shopping-cart faa-tada animated"></i></span>
  </a>
  <div class="m-dropdown__wrapper">
    <span class="m-dropdown__arrow m-dropdown__arrow--center"></span>
    <div class="m-dropdown__inner">
      <div class="m-dropdown__header m--align-center" style="background: url(<?php echo $this->config->item('Template_template_file_url'); ?>template/assets/app/media/img/misc/notification_bg.jpg); background-size: cover;">
        <span class="m-dropdown__header-title"><?php echo $purchase_notifications_count?> New</span>
        <span class="m-dropdown__header-subtitle">Purchase Notifications</span>
      </div>
      <div class="m-dropdown__body">
        <div class="m-dropdown__content">
          <div class="m-scrollable" data-scrollable="true" style="height:250px;overflow-y: auto;" data-height="250" data-mobile-height="200">
            <div class="m-list-timeline m-list-timeline--skin-light">
              <div class="m-list-timeline__items">
                <?php
                if(isset($purchase_request_pending)){
                foreach ($purchase_request_pending->result() as $key => $value) { ?>
                  <a href="<?php echo base_url().'purchase_request/profile/'.$value->request_id ?>">
                    <div class="m-list-timeline__item">
                      <span class="m-list-timeline__badge -m-list-timeline__badge--state-success"></span>
                      <span class="m-list-timeline__text"><strong>Purchase Request Pending  <br> User : <?php echo $value->user_alias?><br> Date : <?php echo date('d-m-Y',strtotime($value->request_date))?></strong><br> Project : <?php echo $value->location_name?> </span>
                      <span class="m-list-timeline__time"><?php echo date('d-m-Y',strtotime($value->created_date))?></span>
                    </div>
                  </a>
                <?php }
              }
              if(isset($purchase_order_pending)){
              foreach ($purchase_order_pending->result() as $key => $value) { ?>
                <a href="<?php echo base_url().'purchase_order/profile/'.$value->order_id ?>">
                  <div class="m-list-timeline__item">
                    <span class="m-list-timeline__badge -m-list-timeline__badge--state-success"></span>
                    <span class="m-list-timeline__text"><strong>PO Approval Pending  <br> User : <?php echo $value->user_alias?><br> Date : <?php echo date('d-m-Y',strtotime($value->order_date))?></strong><br> Project : <?php echo $value->location_name?> </span>
                    <span class="m-list-timeline__time"><?php echo date('d-m-Y',strtotime($value->created_date))?></span>
                  </div>
                </a>
              <?php }
            } ?>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
<?php } ?>

<?php if(sizeof($client_payment_notifications)>0){
  ?>
  <li class="m-nav__item m-topbar__notifications m-topbar__notifications--img m-dropdown m-dropdown--large m-dropdown--header-bg-fill m-dropdown--arrow m-dropdown--align-center 	m-dropdown--mobile-full-width" m-dropdown-toggle="click"
  m-dropdown-persistent="1" >
  <a href="#" class="m-nav__link m-dropdown__toggle" id="m_topbar_notification_icon">
    <span class="m-nav__link-badge m-badge m-badge--dot m-badge--dot-small m-badge--danger"></span>
    <span class="m-nav__link-icon"><i class="fa fa-shopping-cart faa-tada animated"></i></span>
  </a>
  <div class="m-dropdown__wrapper">
    <span class="m-dropdown__arrow m-dropdown__arrow--center"></span>
    <div class="m-dropdown__inner">
      <div class="m-dropdown__header m--align-center" style="background: url(<?php echo $this->config->item('Template_template_file_url'); ?>template/assets/app/media/img/misc/notification_bg.jpg); background-size: cover;">
        <span class="m-dropdown__header-title"><?php echo sizeof($client_payment_notifications)?> New</span>
        <span class="m-dropdown__header-subtitle">Client Payment Notifications</span>
      </div>
      <div class="m-dropdown__body">
        <div class="m-dropdown__content">
          <div class="m-scrollable" data-scrollable="true" style="height:250px;overflow-y: auto;" data-height="250" data-mobile-height="200">
            <div class="m-list-timeline m-list-timeline--skin-light">
              <div class="m-list-timeline__items">
                <?php foreach ($client_payment_notifications as $key => $value) { ?>
                  <a href="<?php echo base_url().'work/profile/'.$value['work_id'] ?>">
                    <div class="m-list-timeline__item">
                      <span class="m-list-timeline__badge -m-list-timeline__badge--state-success"></span>
                      <span class="m-list-timeline__text"><strong><?php if($value['type']=='completed_project_payment_pending'){ echo "<span class='m-badge m-badge--danger m-badge--wide'>Client Payment Pending For Completed Project</span>";}elseif($value['type']=='project_cost_exceeded_payment_pending'){ echo "<span class='m-badge m-badge--warning m-badge--wide'>Client Payment Need to Request - Project Cost Exceeded</span>";}  ?><br> Project : <?php echo $value['work_name']?><br> Client : <?php echo $value['client_name'] ?></strong></span>
                      <span class="m-list-timeline__time"><?php echo date('d-m-Y')?></span>
                    </div>
                  </a>
                <?php } ?>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
<?php } ?>
</li>
<?php if($notifications_count>0  && $this->session->userdata('user_role') != 'qs_manager' && $this->session->userdata('user_role') != 'qs' && $this->session->userdata('user_role') != 'procurement_engineer' && $this->session->userdata('user_role') != 'project_manager'){
  ?>
  <li class="m-nav__item m-topbar__notifications m-topbar__notifications--img m-dropdown m-dropdown--large m-dropdown--header-bg-fill m-dropdown--arrow m-dropdown--align-center 	m-dropdown--mobile-full-width" m-dropdown-toggle="click"
  m-dropdown-persistent="1" >
  <a href="#" class="m-nav__link m-dropdown__toggle" id="m_topbar_notification_icon">
    <span class="m-nav__link-badge m-badge m-badge--dot m-badge--dot-small m-badge--danger"></span>
    <span class="m-nav__link-icon"><i class="fa fa-bell faa-tada animated"></i></span>
  </a>
  <div class="m-dropdown__wrapper">
    <span class="m-dropdown__arrow m-dropdown__arrow--center"></span>
    <div class="m-dropdown__inner">
      <div class="m-dropdown__header m--align-center" style="background: url(<?php echo $this->config->item('Template_template_file_url'); ?>template/assets/app/media/img/misc/notification_bg.jpg); background-size: cover;">
        <span class="m-dropdown__header-title"><?php echo $notifications_count?> New</span>
        <span class="m-dropdown__header-subtitle">Notifications</span>
      </div>
      <div class="m-dropdown__body">
        <div class="m-dropdown__content">
          <div class="m-scrollable" data-scrollable="true" style="height:250px;overflow-y: auto;" data-height="250" data-mobile-height="200">
            <div class="m-list-timeline m-list-timeline--skin-light">
              <div class="m-list-timeline__items">
                <?php
                foreach ($payment_schedules_subcontract->result() as $key => $value) { ?>
                  <a href="<?php echo base_url().'subcontracts/payment_schedule' ?>">
                    <div class="m-list-timeline__item">
                      <span class="m-list-timeline__badge -m-list-timeline__badge--state-success"></span>
                      <span class="m-list-timeline__text"><strong><?php echo $value->work_name?> : Subcontract Payment sheduleded pending  <br> Sheduled Amount : <?php echo $this->config->item('Currency_currency_format').' '.$value->scheduled_amount; ?></strong> </span>
                      <span class="m-list-timeline__time"><?php echo date('d-m-Y')?></span>
                    </div>
                  </a>
                  <?php
                } ?>
                  <?php
                  foreach ($payment_schedules_client->result() as $key => $value) { ?>
                  <a href="<?php echo base_url().'client_payments/schedule' ?>">
                    <div class="m-list-timeline__item">
                      <span class="m-list-timeline__badge -m-list-timeline__badge--state-success"></span>
                      <span class="m-list-timeline__text"><strong><?php echo $value->work_name?> : Client Payment sheduleded pending  <br> Sheduled Amount : <?php echo $this->config->item('Currency_currency_format').' '.$value->scheduled_amount; ?></strong> </span>
                      <span class="m-list-timeline__time"><?php echo date('d-m-Y')?></span>
                    </div>
                  </a>
                <?php
              } ?>
                <?php
                foreach ($enquiry_followups->result() as $key => $value) { ?>
                  <a href="<?php echo base_url().'enquiries/profile/'.$value->enquiry_id ?>">
                    <div class="m-list-timeline__item">
                      <span class="m-list-timeline__badge -m-list-timeline__badge--state-success"></span>
                      <span class="m-list-timeline__text"><strong>Sales Enquiry Followup pending  <br> Service : <?php echo $value->service_name?><br> Customer : <?php echo $value->customer_name?></strong> </span>
                      <span class="m-list-timeline__time"><?php echo date('d-m-Y')?></span>
                    </div>
                  </a>
                <?php
              } ?>
                <?php
                  if(isset($leave_applications)){
                foreach ($leave_applications->result() as $key => $value) { ?>
                  <a href="<?php echo base_url().'employees/leave_applications/' ?>">
                    <div class="m-list-timeline__item">
                      <span class="m-list-timeline__badge -m-list-timeline__badge--state-success"></span>
                      <span class="m-list-timeline__text"><strong>Leave Application Approval Pending  <br> Employee : <?php echo $value->employee_name?><br> Date : <?php echo date('d-m-Y',strtotime($value->leave_date_from))?></strong><br> Reason : <?php echo $value->leave_reason?> </span>
                      <span class="m-list-timeline__time"><?php echo date('d-m-Y',strtotime($value->created_date))?></span>
                    </div>
                  </a>
                <?php }
              } ?>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
  </li>
<?php } ?>

<li class="m-nav__item m-topbar__notifications m-topbar__notifications--img m-dropdown m-dropdown--large m-dropdown--header-bg-fill m-dropdown--arrow m-dropdown--align-center 	m-dropdown--mobile-full-width" m-dropdown-toggle="click" m-dropdown-persistent="1">
<?php if($notification_2_count>0  && $this->session->userdata('user_role') != 'qs_manager' && $this->session->userdata('user_role') != 'qs' && $this->session->userdata('user_role') != 'procurement_engineer' && $this->session->userdata('user_role') != 'project_manager'){ ?>
  <a href="#" class="m-nav__link m-dropdown__toggle" id="m_topbar_notification_icon">
    <span class="m-nav__link-badge m-badge m-badge--dot m-badge--dot-small m-badge--danger"></span>
    <span class="m-nav__link-icon"><i class="fa fa-envelope"></i></span>
  </a>
  <div class="m-dropdown__wrapper">
    <span class="m-dropdown__arrow m-dropdown__arrow--center"></span>
    <div class="m-dropdown__inner">
      <div class="m-dropdown__header m--align-center" style="background: url(<?php echo $this->config->item('Template_template_file_url'); ?>template/assets/app/media/img/misc/notification_bg.jpg); background-size: cover;">
        <span class="m-dropdown__header-title"><?php echo $notification_2_count?> New</span>
        <span class="m-dropdown__header-subtitle">Messages</span>
      </div>
      <div class="m-dropdown__body">
        <div class="m-dropdown__content">
          <div class="m-scrollable" data-scrollable="true" style="height:250px;overflow-y: auto;" data-height="250" data-mobile-height="200">
            <div class="m-list-timeline m-list-timeline--skin-light">
              <div class="m-list-timeline__items">
                <?php foreach ($daily_notes->result() as $key => $value) { ?>
                  <a href="<?php echo base_url().'daily_notes' ?>">
                    <div class="m-list-timeline__item">
                      <span class="m-list-timeline__badge -m-list-timeline__badge--state-success"></span>
                      <span class="m-list-timeline__text"><strong>Daily Notes Added by : <?php echo $value->user_alias ?></strong> </span>
                      <span class="m-list-timeline__time"><?php echo date('d-m-Y',strtotime($value->created_date))?></span>
                    </div>
                  </a>
                <?php } ?>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
<?php } ?>
</li>
<li class="m-nav__item m-topbar__notifications m-topbar__notifications--img m-dropdown m-dropdown--large m-dropdown--header-bg-fill m-dropdown--arrow m-dropdown--align-center 	m-dropdown--mobile-full-width" m-dropdown-toggle="click" m-dropdown-persistent="1">
<?php if($this->config->item('app_module_vehicle_management')==1 && $vehicle_notifications>0  && $this->session->userdata('user_role') != 'qs_manager' && $this->session->userdata('user_role') != 'project_manager' && $this->session->userdata('user_role') != 'procurement_engineer' && $this->session->userdata('user_role') != 'project_manager'){ ?>
  <a href="#" class="m-nav__link m-dropdown__toggle" id="m_topbar_notification_icon">
    <span class="m-nav__link-badge m-badge m-badge--dot m-badge--dot-small m-badge--danger"></span>
    <span class="m-nav__link-icon"><i class="fa fa-truck"></i></span>
  </a>
  <div class="m-dropdown__wrapper">
    <span class="m-dropdown__arrow m-dropdown__arrow--center"></span>
    <div class="m-dropdown__inner">
      <div class="m-dropdown__header m--align-center" style="background: url(<?php echo $this->config->item('Template_template_file_url'); ?>template/assets/app/media/img/misc/notification_bg.jpg); background-size: cover;">
        <span class="m-dropdown__header-title"><?php echo $vehicle_notifications?> New</span>
        <span class="m-dropdown__header-subtitle">Reminder</span>
      </div>
      <div class="m-dropdown__body">
        <div class="m-dropdown__content">
          <div class="m-scrollable" data-scrollable="true" style="height:250px;overflow-y: auto;" data-height="250" data-mobile-height="200">
            <div class="m-list-timeline m-list-timeline--skin-light">
              <div class="m-list-timeline__items">
                <?php foreach ($vehicle_renewals as $key => $value) { ?>
                  <a href="<?php echo base_url().'vehicles/profile/'.$value['vehicle_id'] ?>">
                    <div class="m-list-timeline__item">
                      <span class="m-list-timeline__badge -m-list-timeline__badge--state-success"></span>
                      <span class="m-list-timeline__text"><strong><?php echo $value['type'] ?> Renewal For : <?php echo $value['vehicle_name'] ?> [<?php echo $value['vehicle_no'] ?>]</strong> </span>
                      <span class="m-list-timeline__time" style="font-size: 1rem;font-weight: 800;"><?php echo date('d-m-Y',strtotime($value['renewal_date']))?></span>
                    </div>
                  </a>
                <?php } ?>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
<?php } ?>
</li>
<li class="m-nav__item m-topbar__user-profile m-topbar__user-profile--img m-dropdown m-dropdown--medium m-dropdown--arrow m-dropdown--header-bg-fill m-dropdown--align-right m-dropdown--mobile-full-width m-dropdown--skin-light" m-dropdown-toggle="click" aria-expanded="true">
  <a href="#" class="m-nav__link m-dropdown__toggle">
    <span class="m-topbar__userpic">
      <img src="<?php echo $this->session->userdata('user_photo');?>" class="m--img-rounded m--marginless m--img-centered" alt="">
    </span>
    <span class="m-topbar__username" style="color: black">
      &nbsp;&nbsp;Hello , <?php echo $this->session->userdata('user_alias');?>
    </span>
  </a>
  <div class="m-dropdown__wrapper" style="z-index: 101;">
    <span class="m-dropdown__arrow m-dropdown__arrow--right m-dropdown__arrow--adjust" style="left: auto; right: 12.5px;"></span>
    <div class="m-dropdown__inner">
      <div class="m-dropdown__header m--align-center" style="background: url(<?php echo $this->config->item('Template_template_file_url'); ?>template/assets/app/media/img/misc/user_profile_bg.jpg); background-size: cover;">
        <div class="m-card-user m-card-user--skin-dark">
          <div class="m-card-user__pic">
            <img src="<?php echo $this->session->userdata('user_photo');?>" class="m--img-rounded m--marginless" alt="">
          </div>
          <div class="m-card-user__details">
            <span class="m-card-user__name m--font-weight-500">
              <?php echo $this->session->userdata('user_alias');?>
            </span>
            <a href="" class="m-card-user__email m--font-weight-300 m-link">
              <?php echo $this->session->userdata('user_role_title');?>
            </a>
          </div>
        </div>
      </div>
      <div class="m-dropdown__body">
        <div class="m-dropdown__content">
          <ul class="m-nav m-nav--skin-light">
            <li class="m-nav__section m--hide">
              <span class="m-nav__section-text">
                Section
              </span>
            </li>
            <li class="m-nav__item">
              <a href="<?php echo base_url();?>user/change_password" class="m-nav__link">
                <i class="m-nav__link-icon fa fa-cogs"></i>
                <span class="m-nav__link-title">
                  <span class="m-nav__link-wrap">
                    <span class="m-nav__link-text">
                      Settings
                    </span>
                  </span>
                </span>
              </a>
            </li>
            <li class="m-nav__separator m-nav__separator--fit"></li>
            <li class="m-nav__item">
              <a href="<?php echo base_url();?>login/logout" class="btn m-btn--pill    btn-danger m-btn m-btn--custom m-btn--label-brand m-btn--bolder"><i class="fa fa-sign-out"></i>
                Logout
              </a>
            </li>
          </ul>
        </div>
      </div>
    </div>
  </div>
</li>
