<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta http-equiv="Cache-control" content="no-cache">
    <meta http-equiv="Expires" content="-1">
    <!-- Tell the browser to be responsive to screen width -->

    <?php
  //dd($_SESSION);
  $user_type_name = $this->Common->getCurrentUserType();
  if(isset($setting['meta_tag']))
  echo $setting['meta_tag'];
  ?>
    <?php
    if (!empty($setting['favicon_path'])) {
        $favicon_path = $setting['favicon_path'];
    } else {
        $favicon_path = 'images/favicon/favicon.ico';
    }
    
    if((APP_SERVER_HOST_URL == CLIENT_PORTAL_DOMAIN) || (strpos(CLIENT_PORTAL_DOMAIN, $_SERVER['REDIRECT_REDIRECT_SSL_TLS_SNI']) !== false)){
        $favicon_path = CLIENT_PORTAL_FAVICON;
        $setting['title'] = CLIENT_PORTAL_DEFAULT_HEADER;
    }
    
    if (isset($employee_notification['client_note'][$note_client_id]) && $note_client_id > 0) {
        unset($employee_notification['client_note'][$note_client_id]);
    }
    $total_client_message = count($employee_notification['client_message']);
    $total_client_note = count($employee_notification['client_note']);

    $total_employee_messages = $employee_messages;
    $total_unread_employee_messages = count($employee_messages);

    if(isset($is_employee_message_zero) && $is_employee_message_zero){
        $total_unread_employee_messages = 0;
    }

    // pr($total_unread_employee_messages);exit;

    $controller = $this->request->params['controller'];
    $method = $this->request->params['action'];
  ?>
    <title><?php echo $setting['title'];?></title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
    <link rel="icon" href="<?php echo $this->request->webroot.'webroot/'.$favicon_path;?>" type="image/icon">
    <!-- Bootstrap 3.3.6 -->
    <link rel="stylesheet" href="<?php echo $this->request->webroot; ?>admin_lte/bootstrap/css/bootstrap.min.css">
    <!-- Font Awesome -->
    <link rel="stylesheet" href="<?php echo $this->request->webroot; ?>admin_lte/bootstrap/css/font-awesome.min.css">
    <!-- Ionicons -->
    <link rel="stylesheet" href="<?php echo $this->request->webroot; ?>admin_lte/bootstrap/css/ionicons.min.css">
    <!-- Theme style -->
    <link rel="stylesheet" href="<?php echo $this->request->webroot; ?>admin_lte/dist/css/AdminLTE.min.css">
    <!-- AdminLTE Skins. Choose a skin from the css/skins
       folder instead of downloading all of them to reduce the load. -->
    <link rel="stylesheet" href="<?php echo $this->request->webroot; ?>admin_lte/dist/css/skins/_all-skins.min.css">
    <!-- iCheck -->
    <link rel="stylesheet" href="<?php echo $this->request->webroot; ?>admin_lte/plugins/iCheck/flat/blue.css">
    <!-- Morris chart -->
    <link rel="stylesheet" href="<?php echo $this->request->webroot; ?>admin_lte/plugins/morris/morris.css">
    <!-- jvectormap -->
    <link rel="stylesheet"
        href="<?php echo $this->request->webroot; ?>admin_lte/plugins/jvectormap/jquery-jvectormap-1.2.2.css">
    <!-- Date Picker -->
    <link rel="stylesheet" href="<?php echo $this->request->webroot; ?>admin_lte/plugins/datepicker/datepicker3.css">
    <!-- Daterange picker -->
    <link rel="stylesheet"
        href="<?php echo $this->request->webroot; ?>admin_lte/plugins/daterangepicker/daterangepicker-bs3.css">
    <!-- bootstrap wysihtml5 - text editor -->
    <!--<link rel="stylesheet" href="<?php //echo $this->request->webroot; ?>admin_lte/plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.min.css">-->
    <!--  cms_style.css   custom style -->
    <link rel="stylesheet" href="<?php echo $this->request->webroot; ?>css/cms_style.css">
    <!--  custom.css   custom style -->
    <link rel="stylesheet" href="<?php echo $this->request->webroot; ?>css/custom.css">
    <link rel="stylesheet" href="<?php echo $this->request->webroot; ?>css/reminder-task.css?1.0.0">

    <?php //echo $this->CKEditor->loadJs(); ?>
    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
  <script src="<?php echo $this->request->webroot; ?>admin_lte/bootstrap/js/html5shiv.min.js"></script>
  <script src="<?php echo $this->request->webroot; ?>admin_lte/bootstrap/js/respond.min.js"></script>
  <![endif]-->


    <!-- Layout ::  new_dashboard  -->
    <!-- Font Awesome -->
    <!-- <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.5.0/css/font-awesome.min.css"> -->
    <!-- Ionicons -->
    <!-- <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/ionicons/2.0.1/css/ionicons.min.css"> -->
    <link rel="stylesheet" href="<?php echo $this->request->webroot; ?>new_layout/css/_all-skins.min.css">
    <link rel="stylesheet" href="<?php echo $this->request->webroot;?>datepicker/bootstrap-datetimepicker.min.css">

    <link rel="stylesheet" href="<?php echo $this->request->webroot; ?>rtgv3/css/conv_core.css">
    <?php if(($controller != "Invoice" && $method != "add") && $controller != "Calendar"){ ?>
    <link rel="stylesheet" href="<?php echo $this->request->webroot; ?>rtgv3/css/conv_components.min.css">
    <?php } ?>
    <link rel="stylesheet" href="<?php echo $this->request->webroot; ?>new_layout/css/style.css">
    <link rel="stylesheet" href="<?php echo $this->request->webroot; ?>rtgv3/css/sertg.css?1.0.1">
    <!-- Layout ::  new_dashboard  -->



    <link rel="stylesheet" href="<?php echo $this->request->webroot; ?>rtgv3/css/full_page_loader.css?1.0.0">
    <link rel="stylesheet" href="<?php echo $this->request->webroot; ?>magnify/magnific-popup.css">
</head>

<body class="hold-transition skin-blue sidebar-mini">
    <?php $username = $this->request->session()->read('Auth.User.username'); 
$img_path = $this->request->session()->read('Auth.User.img_path');


$profile_picture = (empty($img_path)) ? $this->request->webroot."media/companies/default.jpg" : $this->request->webroot.$img_path;
 ?>


    <div class="loading" id="full-page-loader">
        <div class='uil-ring-css' style='transform:scale(0.79);'>
            <div></div>
        </div>
    </div>

    <style type="text/css">
    .reminder-part {
        max-height: 170px;
        overflow-y: scroll;
    }

    .name-part {
        color: green;
        position: relative;
        top: 0;
        z-index: 1000;
        background: white;
        padding-top: 0 !important;
    }

    .pkgForm {
        border-bottom: 1px solid #008de1;

    }

    .pkgFormBtn {
        color: #fff;
        border: none;
        background: none;
        width: 100%;
        text-align: left;
        padding: 3px 20px;
        line-height: 24px;

    }

    .pkgFormBtn:hover {
        background: #008de1 none repeat scroll 0 0;
    }

    #media-heading-new {
        padding-left: 0;
        color: #009cf9;
        font-weight: bold;
    }

    .width-350.dropdown-menu {
        min-width: 324px;
    }

    .yellow-alert .alert {
        padding-right: 35px !important;
        margin-top: 10px;
        margin-bottom: 0;
        background: #ffb347 !important;
        border-color: #faebcc !important;
        color: white !important;
    }

    .yellow-alert .close {
        font-size: 21px !important;
        font-weight: 700 !important;
        line-height: 1 !important;
        color: #000 !important;
        text-shadow: 0 1px 0 #fff !important;
    }

    .yellow-alert .clear {
        line-height: 1 !important;
        color: #000 !important;
        text-shadow: 0 1px 0 #fff !important;
    }

    .bootstrap-datetimepicker-widget table {
        table-layout: fixed;
        width: 100%;
    }

    #member-note-modal-edit .modal-dialog {
        width: 600px !important;
        margin: 30px auto !important;
    }

    #before-saving-modal .multiselect .caret {
        position: absolute;
        top: 50%;
        right: 12px;
        margin-top: -3px;
        width: 9px;
        text-align: right;
    }

    #before-saving-modal .multiselect-container {
        width: 100%;
        max-height: 250px;
        overflow-y: auto;
    }
    </style>
    <style>
    .swal2-content,
    .swal2-actions {
        font-size: 15px !important;
    }

    .ka-main-content .view-html {
        text-align: left;
    }

    .view-html #personalInfo {
        width: 100%;
    }

    .swal2-icon .swal2-icon-content {
        font-size: 3em !important;
    }

    .swal2-popup .swal2-styled {
        margin-top: 0 !important;
    }
    </style>
    <link rel="stylesheet" href="<?php echo $this->request->webroot; ?>css/letter_steps.css?1.0.6">
    <?php
    $is_from_setting = false;
    if(file_exists($setting['logo_path'])){
        $logo_path = $setting['logo_path'];
        $is_from_setting = true;
    } else{
        $logo_path = '/images/logo/favicon.ico';
    }
    $affiliate_user_type = $this->request->session()->read('Auth.User.type');
    if($affiliate_user_type == AFFILIATE_USER_TYPE || $affiliate_user_type == 1 || $user_type_name == "EMPLOYEE"){
        $current_member_logo = $this->request->session()->read('Auth.User.member_logo'); 
        $logo_path_member = "/cmsuser_logo/".$current_member_logo;
        if(file_exists( WWW_ROOT.$logo_path_member)){
            $logo_path = $logo_path_member;
        }else{
            if($is_from_setting){
                $logo_path ='/'.$logo_path; 
            }
        }
        //dd($logo_path_member);exit;
        if(empty($current_member_logo) && APP_SERVER_HOST_URL == CLIENT_PORTAL_DOMAIN){
             $logo_path = CLIENT_PORTAL_LOGO;
        }
    }
?>
    <div class="container-fluid ka-header">
        <div class="col-sm-2">
            <!-- <img src="<?php echo $this->request->webroot; ?>new_layout/img/logo.png"  alt="" class="img-responsive ka-logo center-block"/> -->
            <img style="max-height: 71px;" class="img-responsive ka-logo center-block" alt="Login Logo"
                src="<?php echo $this->Url->build($logo_path); ?>">
        </div>
        <div class="col-sm-10 text-right">
            <ul class="ka-nav">
                <?php 
         if($_SESSION['Auth']['User']['type'] == 1){ 
            // pr($member_remainder_others);exit;
            $remainders = $member_remainder["remainders"];
            $remainders = $member_remainder_others["due"];
            $total_unread_remainders = $member_remainder["total_unread"]+$member_remainder_others['total_unread'];
            $total_remainders = $member_remainder["total_remainder"]+$member_remainder_others['total_remainder'];
            $today_reminders = $member_remainder["today"]+$member_remainder["over"];

            $notes = $member_note["remainders"];
            $notes = $member_note_others["due"];
            $total_unread_notes = $member_note["total_unread"]+$member_note_others['total_unread'];
            $total_notes = $member_note["total_remainder"]+$member_note_others['total_remainder'];
            $today_notes = $member_note["today"]+$member_note["over"];
            
            // pr($total_unread_employee_messages);exit;

         }
        if($_SESSION['Auth']['User']['type'] == 2){ 
                $remainders = $member_remainder["remainders"];
                $total_unread_remainders = $member_remainder["total_unread"];
                $total_remainders = $member_remainder["total_remainder"];
                $total_client_note = count($affliliate_note_notification);
                $total_affiliate_note_against_client = count($affiliate_notes_against);
                $affiliate_note_against_client = $affiliate_notes_against;
                $total_affiliate_message = (int)$affliliate_message;
                // $total_unread_employee_messages = $employee_messages;
                // pr($total_unread_employee_messages);exit;
    
            ?>
                <style>
                .reminder.dropdown-menu {
                    left: unset;
                    right: 0;
                }
                </style>
                <li class="dropdown">
                    <a title="Message"
                        href="<?php echo $this->Url->build(["controller" => 'Clientmessage', "action" => "affiliatemessage"]); ?>"
                        style="text-decoration:none;">
                        <i class="fa fa-send-o" aria-hidden="true"></i>
                        <span class="badge badge-light" id="reminder-notification-count"
                            style="background-color:#e94b35;position: absolute;"><?php if($total_affiliate_message > 0){echo $total_affiliate_message;} ?></span>
                        <i style="position: absolute;display:none;" id="reminder-msg-noti"
                            class="fa fa-spinner fa-spin"></i>
                    </a>

                </li>
                <li class="dropdown">
                    <a title="Affiliate Note" href="#" class="dropdown-toggle" data-toggle="dropdown"
                        style="text-decoration:none;">
                        <i class="fa fa-folder-o" aria-hidden="true"></i>
                        <span class="badge badge-light" id="reminder-notification-count"
                            style="background-color:#e94b35;position: absolute;"><?php if($total_affiliate_note_against_client > 0){echo $total_affiliate_note_against_client;} ?></span>
                        <i style="position: absolute;display:none;" id="reminder-msg-noti"
                            class="fa fa-spinner fa-spin"></i>
                    </a>
                    <?php if($total_affiliate_note_against_client > 0){ ?>
                    <div class="reminder dropdown-menu dropdown-content width-350">
                        <div class="dropdown-content-heading">Affliliate Note</div>
                        <ul class="media-list dropdown-content-body">
                            <?php if(!empty($affiliate_note_against_client)){
                        foreach ($affiliate_note_against_client as $affiliate_note_id =>  $affiliate_note){
                           
                            if($affiliate_note['client_id'] == $client_id_from_dashboard){
                                continue;
                            }
                        ?>
                            <li class="media" id="reminder-list-<?php echo $affiliate_note_id; ?>">
                                <div class="media-left">
                                    <img src="<?php echo $this->request->webroot; ?>rtgv3/images/placeholder.jpg"
                                        class="img-circle img-sm" alt="">
                                    <span class="badge bg-danger-400 media-badge">4</span>
                                </div>

                                <div class="media-body">
                                    <a href="<?php echo $this->Url->build('/Client/clientdashboard/'.$affiliate_note['client_id']); ?>#affiliate-note"
                                        class="media-heading" id="media-heading-new">
                                        <span class="text-semibold"><?php echo $affiliate_note['title']; ?> </span>
                                    </a>
                                    <span
                                        class="text-muted"><?php echo substr(strip_tags($affiliate_note['message']), 0, 15)." ..."; ?></span>
                                </div>
                            </li>
                            <?php
                        }
                        } ?>
                        </ul>


                    </div>
                    <?php } ?>
                </li>
                <li class="dropdown">
                    <a title="Notes" href="#" class="dropdown-toggle" data-toggle="dropdown"
                        style="text-decoration:none;">
                        <i class="fa fa-sticky-note-o"></i>
                        <span id="affiliate-note-count" class="badge badge-light"
                            style="background-color:#e94b35;position: absolute;"><?php if($total_client_note > 0){echo $total_client_note;} ?></span>
                        <i style="position: absolute;display:none;" id="affiliate-note-loader"
                            class="fa fa-spinner fa-spin"></i>
                    </a>
                    <?php if($total_client_note > 0){ ?>
                    <div class="reminder dropdown-menu dropdown-content width-350 affiliate-noti">

                        <div class="dropdown-content-heading">Notes</div>
                        <ul class="media-list dropdown-content-body">

                            <?php if(!empty($affliliate_note_notification)){ 
                                        foreach ($affliliate_note_notification as  $affiliate_n){
                             ?>
                            <li class="media" id="affliliate_row_<?php echo $affiliate_n->id; ?>">
                                <div class="media-left">
                                    <img src="<?php echo $this->request->webroot; ?>rtgv3/images/placeholder.jpg"
                                        class="img-circle img-sm" alt="">
                                    <span class="badge bg-danger-400 media-badge">4</span>
                                </div>

                                <div class="media-body">
                                    <a onclick="getAffliateMessage(<?php echo $affiliate_n->id; ?>,'<?php echo $affiliate_n->title; ?>')"
                                        href="#" class="media-heading" id="media-heading-new">

                                        <span class="text-semibold"><?php echo $affiliate_n->title; ?> </span>
                                    </a>


                                </div>
                            </li>
                            <?php 
                                        }
                                        } ?>
                        </ul>


                    </div>
                    <?php } ?>
                </li>
                <?php } ?>
                <?php if( $_SESSION['Auth']['User']['type'] == 1){ ?>
                <?php if($this->Common->isPermitted(SAVE_DOWNLOAD_PRINT_LETTER_CONTROLLER_ID)){  ?>
                    <li class="dropdown svpdf save-pdf-notification-li">
                        <?php echo $this->element('common/save_pdf_letter', compact('pdf_letters', 'total_save_letter')); ?>
                    </li>
                <?php } ?>
                <li class="dropdown" id="emp-to-emp-notification">
                    <?php echo $this->element('/teammessage/employee_to_employee_notification') ?>
                </li>
                <li class="dropdown">
                    <a title="Employee Message"
                        href="<?php echo $this->Url->build(["controller" => 'EmployeeMessage', "action" => "index"]); ?>"
                        class="dropdown-toggle" style="text-decoration:none;">
                        <i class="fa fa-users"></i>
                        <span id="bage-noti-count" class="badge badge-light total_unread_employee_messages"
                            style="background-color:#e94b35;position: absolute;"><?php if($total_unread_employee_messages > 0){echo $total_unread_employee_messages;} ?></span>
                        <i style="position: absolute;display:none;" id="member-client-msg-noti"
                            class="fa fa-spinner fa-spin"></i>
                    </a>

                </li>
                <li class="dropdown rem reminder-notification-li">
                    <?php echo $this->element('reminder/reminder_notification_list',compact('remainders','total_unread_remainders','total_remainders','today_reminders')); ?>
                </li>
                <li class="dropdown rem reminder-notification-li">
                    <?php echo $this->element('note/note_notification_list',compact('notes','total_unread_notes','total_notes','today_notes')); ?>
                </li>
                <li class="dropdown">
                    <a title="Notes" href="#" class="dropdown-toggle" data-toggle="dropdown"
                        style="text-decoration:none;">
                        <i class="fa fa-sticky-note-o"></i>
                        <span class="badge badge-light"
                            style="background-color:#e94b35;position: absolute;"><?php if($total_client_note > 0){echo $total_client_note;} ?></span>
                    </a>
                    <?php if($total_client_note > 0){ ?>
                    <div class="dropdown-menu dropdown-content width-350">

                        <div class="dropdown-content-heading">Notes</div>
                        <ul class="media-list dropdown-content-body">
                            <?php if(!empty($employee_notification['client_note'])){ 
                                        foreach ($employee_notification['client_note'] as $client_id => $client_message){
                             ?>
                            <li class="media">
                                <div class="media-left">
                                    <img src="<?php echo $this->request->webroot; ?>rtgv3/images/placeholder.jpg"
                                        class="img-circle img-sm" alt="">
                                    <span class="badge bg-danger-400 media-badge">4</span>
                                </div>

                                <div class="media-body">
                                    <a href="<?php echo $this->Url->build('/client/clientChat/'. $client_id); ?>"
                                        class="media-heading" id="media-heading-new">

                                        <span class="text-semibold"><?php echo $client_message['name']; ?> </span>
                                    </a>

                                    <span class="text-muted"><?php echo $client_message['email']; ?> </span>
                                </div>
                            </li>
                            <?php 
                                        }
                                        } ?>
                        </ul>


                    </div>
                    <?php } ?>
                </li>

                <li class="dropdown">
                    <a title="Message" href="#" class="dropdown-toggle" data-toggle="dropdown"
                        style="text-decoration:none;">
                        <i class="fa fa-envelope-o"></i>
                        <span id="bage-noti-count" class="badge badge-light"
                            style="background-color:#e94b35;position: absolute;"><?php if($total_client_message > 0){echo $total_client_message;} ?></span>
                    </a>
                    <i style="position: absolute;display:none;" id="member-client-msg-noti"
                        class="fa fa-spinner fa-spin"></i>
                    <?php if($total_client_message > 0){ ?>
                    <div class="dropdown-menu dropdown-content width-350" id="total_client_message">

                        <div class="dropdown-content-heading">Messages</div>
                        <ul class="media-list dropdown-content-body">
                            <?php if(!empty($employee_notification['client_message'])){ 
                                        foreach ($employee_notification['client_message'] as $client_id => $client_message){
                             ?>
                            <li class="media" id="noti-message-<?php echo $client_id;?>">
                                <div class="media-left">
                                    <img src="<?php echo $this->request->webroot; ?>rtgv3/images/placeholder.jpg"
                                        class="img-circle img-sm" alt="">
                                    <span class="badge bg-danger-400 media-badge">4</span>
                                </div>

                                <div class="media-body">
                                    <a onclick="sendClientMemberMessage(<?php echo $client_id;?>,<?php echo $_SESSION['Auth']['User']['id'];?>,'modalloading','member-client-msg-noti')"
                                        href="#" class="media-heading" id="media-heading-new">

                                        <span class="text-semibold"><?php echo $client_message['name']; ?> </span>
                                        <!--                                    <span class="media-annotation pull-right">06:55 AM</span>-->
                                    </a>

                                    <span class="text-muted"><?php echo $client_message['email']; ?> </span>
                                </div>
                            </li>
                            <?php 
                                        }
                                        } ?>
                        </ul>


                    </div>
                    <?php } ?>
                </li>
                <?php
            $checkSupport = 0;

            foreach ($supports as $support):
            $checkSupport = $checkSupport+1;
            endforeach;
            if(isset($_SESSION['no_of_yellow']) && $_SESSION['no_of_yellow'] > 0){
            $supportMsg = $supportMsg + $_SESSION['no_of_yellow'];
            }

           ?>
                <style>
                .bell-icon.dropdown-menu {
                    left: unset;
                    right: 0;
                }
                </style>
                <li class="dropdown">
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown" style="text-decoration:none;">
                        <i class="fa fa-bell-o"></i>

                        <span class="badge badge-light"
                            style="background-color:#e94b35;position: absolute;"><?php if($supportMsg > 0){echo $supportMsg;} ?></span>

                    </a>

                    <div class="bell-icon dropdown-menu dropdown-content width-350">

                        <div class="dropdown-content-heading">
                            <div class="row">
                                <div class="col-md-12">
                                    <span>You have
                                        <?php
                                    if($_SESSION['no_of_yellow'] > 0){
                                    echo $_SESSION['no_of_yellow'];
                                    }
                                    ?>
                                        files to send. Click</span>
                                    <span><a href="<?php echo $this->Url->build('/Client/showclientfiles?yellow=1'); ?>"
                                            style="text-decoration:underline;padding:0">here</a></span> to review
                                </div>
                            </div>
                            <br />
                            Tickets
                            <ul class="icons-list">
                                <li><a href="<?php echo $this->Url->build('/Supports/add/'); ?>" data-popup="tooltip"
                                        title="Add ticket"><i class="fa fa-plus-circle" aria-hidden="true"></i></a></li>
                            </ul>
                        </div>

                        <ul class="media-list dropdown-content-body">
                            <?php
                        $checkDate ='';
                        foreach ($supports as $support):
                        if(!empty($support->created_on)){
                        $created = $support->created_on;
                        }else{
                        $created = $support->reply_date;
                        }
                        if(!empty($support->title)) {
                        $time = '';
                        $start_date = new DateTime(date("Y-M-d",strtotime($created)));
                        $since_start = $start_date->diff(new DateTime(date(strtotime("Y-m-d"))));
                        if($since_start->d == 0) {
                        $currentDay = 'Today';
                        $to_time = strtotime($created);
                        $from_time = strtotime(date("Y-m-d H:i:s"));
                        $getTime = round(abs($to_time - $from_time) / 60);
                        if($getTime > 60){
                        $time = round(abs($getTime) / 60)." hour ago";
                        }else{
                        $time = round(abs($to_time - $from_time) / 60)." minutes ago";
                        }
                        }
                        else if($since_start->d == 1) {
                        $currentDay = 'Yesterday';
                        $time = date("H:i A",strtotime($created));
                        }else{
                        $currentDay = date("D", strtotime($created)).", ". date("Y-M-d",strtotime($created));
                        $time = date("H:i A",strtotime($created));
                        }

                        if(($checkDate != $currentDay))
                        {
                        ?>

                            <li class="media date-step content-divider">
                                <span><?php echo $currentDay ?></span>
                            </li>
                            <?php $checkDate = $currentDay;
                        }
                        ?>
                            <li class="media">
                                <div class="media-left">
                                    <img src="<?php echo $this->request->webroot; ?>rtgv3/images/placeholder.jpg"
                                        class="img-circle img-sm" alt="">
                                    <span class="badge bg-danger-400 media-badge">4</span>
                                </div>

                                <div class="media-body">
                                    <a href="<?php echo $this->Url->build("/Supports/view/".$support->id ); ?>"
                                        class="media-heading" id="media-heading-new">
                                        <span class="text-semibold"><?= h($support->title)?>
                                            <?php  if(isset($parentIDs[$support->id])){echo "(".$parentIDs[$support->id].")";} ?></span>
                                        <span class="media-annotation pull-right"><?php echo $time ?></span>
                                    </a>

                                    <span class="text-muted">
                                        <?php
                                    $support->description = strip_tags($support->description);
                                    if(isset($parentIDs[$support->id])){

                                    if(strlen($support->description) > 75)
                                    {

                                    ?>
                                        <strong><?php echo substr($support->description, 0, 75)." ..."; ?></strong>

                                        <?php }else{ ?>
                                        <strong><?php echo $support->description; ?></strong>
                                        <?php
                                    }
                                    }else{

                                    if(strlen($support->description) > 75)
                                    {
                                    echo substr($support->description, 0, 75)." ...";
                                    }else{
                                    echo $support->description;
                                    }
                                    }
                                    ?>
                                    </span>
                                </div>
                            </li>
                            <?php }
                        endforeach; ?>

                        </ul>

                        <div class="dropdown-content-footer">
                            <a href="<?php echo $this->Url->build('/Supports/index/'); ?>" data-popup="tooltip"
                                title="All ticket">Show More</a>
                        </div>
                    </div>
                </li>
                <?php } ?>
                <?php if(isset($settingData['facebook_url']) && !empty(isset($settingData['facebook_url'])) ): ?>
                <!--            <li>
                <a target=_blank href="<?php echo $settingData['facebook_url']; ?>">Facebook Group</a>
            </li>-->
                <?php endif; ?>
                <!--        <li><a href="<?php echo $this->Url->build(["controller" => "dashboard","action" => "contact"]);?>">Contact</a></li>-->
                <?php if(isset($_SESSION['crm_has_velocity']) && $_SESSION['crm_has_velocity'] == 1){  ?>
                <li><a href="<?php echo $this->Url->build(["controller" => "Supports","action" => "index"]);?>">Contact
                        Support</a></li>
                <?php } ?>
                <li><a
                        href="<?php echo $this->Url->build(["controller" => "dashboard","action" => "edit-profile"]); ?>">Profile</a>
                </li>
                <li><a href="<?php echo $this->Url->build(["controller" => "users","action" => "logout"]);?>">Logout</a>
                </li>
            </ul>
        </div>
        <?php if(isset($_SESSION['is_warning']) && $_SESSION['is_warning'] == 1){?>
        <div class="col-md-12 col-xs-12 yellow-alert">
            <div class="alert alert-warning alert-dismissible text-center" role="alert">
                <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                    <span class="close-btn" aria-hidden="true">&times;</span>
                </button>
                <strong>Warning! </strong> You have Client Files that Need Updated or Sent out Again. Please check your
                Clients Files
            </div>
        </div>
        <br>
        <?php } ?>

        <?php if(isset($_SESSION['total_num_of_clients']) && $_SESSION['total_num_of_clients'] > 0){?>
        <div class="col-md-12 col-xs-12 yellow-alert">
            <div class="alert alert-success alert-dismissible text-center">
                <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                    <span class="close-client-btn" aria-hidden="true">&times;</span>
                </button>
                <strong>Great news! </strong> <?php echo $_SESSION['total_num_of_clients']; ?> new client<?php echo $_SESSION['total_num_of_clients'] > 1 ? 's':''; ?> has been registered.
                <a href="#" id="clear-client_notification">(Clear all notifications)</a>
                <i id="spinner" style="display:none" class="fa fa-spinner fa-spin"></i>
            </div>
        </div>
        <br>
    <?php } ?>
    </div>
    <div class="container-fluid ka-body">

        <!--Start of Main Navigation-->
        <?= $this->element('new_user_dashboard_nav') ?>
        <!--End of Main Navigation-->

        <div class="<?php echo $this->Common->isEmployeeSidebarMaxWidth() ? "col-sm-9":"col-sm-10"; ?>"
            style="padding-left:0">
            <?= $this->element('top_link') ?>
            <div class="ka-main-content">
                <?= $this->Flash->render() ?>
                <?= $this->fetch('content') ?>
            </div>
        </div>

    </div>
    <footer class="">
        <div class="ka-footer">
            <?= $this->element('footer') ?>
        </div>
    </footer>




    <div id="reply-modal" class="modal fade" role="dialog">
        <div class="modal-dialog">

            <!-- Modal content-->
            <div class="modal-content" style="width:50%;margin: 0 auto;">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal">&times;</button>
                    <h4 class="modal-title">Reply</h4>
                </div>
                <div class="modal-body">

                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                </div>
            </div>

        </div>
    </div>

    <div id="client-member-message" class="modal fade" role="dialog">
        <div class="modal-dialog">

            <!-- Modal content-->
            <div class="modal-content" style="width:100%;margin: 0 auto;">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal">&times;</button>
                    <h4 class="modal-title">Send Message</h4>
                </div>
                <div class="modal-body">

                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                </div>
            </div>

        </div>
    </div>
     <div class="modal fade fa fa-users" id="stt-info" style="display: none;">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">×</span></button>
                    <h4 class="modal-title">Letter Sets</h4>
                </div>
                <div class="modal-body">

                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-outline pull-left" data-dismiss="modal">Close</button>
                    <button type="button" class="btn btn-outline">Save changes</button>
                </div>
            </div>
            <!-- /.modal-content -->
        </div>
        <!-- /.modal-dialog -->
    </div>
    <link rel="stylesheet" href="<?php echo $this->request->webroot; ?>css/modal_custom.css?1.0.19" />
    <!-- ./wrapper -->
    <script src="<?php echo $this->request->webroot; ?>js/jquery-1.11.2.js"></script>
    <!-- jQuery 2.2.0 -->
    <script src="<?php echo $this->request->webroot; ?>admin_lte/plugins/jQuery/jQuery-2.2.0.min.js"></script>
    <!-- jQuery UI 1.11.4 -->
    <script src="<?php echo $this->request->webroot; ?>admin_lte/bootstrap/js/jquery-ui.min.js"></script>
    <!-- Resolve conflict in jQuery UI tooltip with Bootstrap tooltip -->
    <script>
    $.widget.bridge('uibutton', $.ui.button);
    </script>
    <!-- Bootstrap 3.3.6 -->
    <script src="<?php echo $this->request->webroot; ?>admin_lte/bootstrap/js/bootstrap.min.js"></script>
    <script src="<?php echo $this->request->webroot; ?>rtgv3/js/select2.full.min.js"></script>
    <!-- Morris.js charts -->
    <script src="https://cdnjs.cloudflare.com/ajax/libs/raphael/2.1.0/raphael-min.js"></script>
    <!-- <script src="http://code.jquery.com/jquery-1.8.2.min.js"></script> -->
    <!-- <script src="https://cdn.oesmith.co.uk/morris-0.4.1.min.js"></script> -->
    <!-- Sparkline -->
    <script src="<?php echo $this->request->webroot; ?>admin_lte/plugins/sparkline/jquery.sparkline.min.js"></script>
    <!-- jvectormap -->
    <script src="<?php echo $this->request->webroot; ?>admin_lte/plugins/jvectormap/jquery-jvectormap-1.2.2.min.js">
    </script>
    <script src="<?php echo $this->request->webroot; ?>admin_lte/plugins/jvectormap/jquery-jvectormap-world-mill-en.js">
    </script>
    <!-- jQuery Knob Chart -->
    <script src="<?php echo $this->request->webroot; ?>admin_lte/plugins/knob/jquery.knob.js"></script>
    <!-- daterangepicker -->
    <script src="<?php echo $this->request->webroot; ?>admin_lte/bootstrap/js/moment.min.js"></script>
    <script src="<?php echo $this->request->webroot; ?>admin_lte/plugins/daterangepicker/daterangepicker.js"></script>
    <!-- datepicker -->
    <script src="<?php echo $this->request->webroot; ?>admin_lte/plugins/datepicker/bootstrap-datepicker.js"></script>
    <!-- Bootstrap WYSIHTML5 -->
    <!--<script src="<?php //echo $this->request->webroot; ?>admin_lte/plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.all.min.js"></script>-->
    <!-- Slimscroll -->
    <script src="<?php echo $this->request->webroot; ?>admin_lte/plugins/slimScroll/jquery.slimscroll.min.js"></script>
    <!-- FastClick -->
    <script src="<?php echo $this->request->webroot; ?>admin_lte/plugins/fastclick/fastclick.js"></script>
    <!-- AdminLTE App -->
    <script src="<?php echo $this->request->webroot; ?>admin_lte/dist/js/app.min.js"></script>
    <!-- AdminLTE dashboard demo (This is only for demo purposes) -->

    <script src="<?php echo $this->request->webroot; ?>admin_lte/dist/js/pages/dashboard.js"></script>
    <!-- AdminLTE for demo purposes -->
    <script src="<?php echo $this->request->webroot; ?>admin_lte/dist/js/demo.js"></script>

    <!-- InnerTablist1 Select Option Value -->
    <?php echo $this->Html->script('selectbox1/jcf.js'); ?>
    <?php echo $this->Html->script('selectbox1/jcf.select.js'); ?>
    <?php echo $this->Html->script('selectbox1/jcf.scrollable.js'); ?>

    <?php echo $this->Html->script('bootstrap-datetimepicker.min.js'); ?>

    <!-- SmartMenus jQuery plugin -->
    <?php echo $this->Html->script('smartmenus.js'); ?>

    <!-- SmartMenus jQuery Bootstrap Addon -->
    <?php echo $this->Html->script('jquery.smartmenus.bootstrap.js'); ?>

    <script src="<?php echo $this->request->webroot;?>js/sweetalert2/sweetalert2.min.js"></script>

    <!-- bootstrap date picker -->

    <?php echo $this->Html->script('timepick.js') ?>
    <?php echo $this->Html->script('jquery.countdown.js') ?>

    <!-- Datatable -->
    <script src="<?php echo $this->request->webroot; ?>rtgv3/js/dataTables.js"></script>

    <!-- important custom js -->
    <?php echo $this->Html->script('custom.js'); ?>
    <?php echo $this->Html->script('globalsettings.js'); ?>
    <?php echo $this->element('tinymce_js'); ?>
    <script>
    function getMessageForDashboard(note_id, title) {
        event.preventDefault();
        if (note_id && title) {
            var loader = $('#reply-loder-' + note_id);
            loader.show();
            var formData = {
                action: 'GET_REPLY_DATA',
                note_id: note_id,
                title: title

            }
            $.ajax({
                type: "POST",
                data: formData,
                url: '<?php echo $this->Url->build($ajax_url); ?>',
                success: function(response) {
                    loader.hide();
                    response = JSON.parse(response);
                    $('#reply-modal .modal-body').html(response)
                    $('#reply-modal').modal('show');

                },
                error: function() {
                    loader.hide();
                }
            })
        }
    }


    function sendClientMemberMessage(client_id, member_id, html_id, additional_id = "") {
        event.preventDefault();
        var total_client_message = '<?php echo $total_client_message; ?>';
        //        alert(total_client_message)
        if (client_id > 0 && member_id > 0) {
            var loader = $('#' + html_id + '-' + client_id);
            if (additional_id) {
                loader = $('#' + additional_id);
            }
            loader.show();
            var formData = {
                action: 'GET_REPLY_DATA',
                client_id: client_id,
                member_id: member_id
            }
            console.log(formData)
            $.ajax({
                type: "POST",
                data: formData,
                url: '<?php echo $this->Url->build('/Client/sendmessage'); ?>',
                success: function(response) {
                    loader.hide();
                    response = JSON.parse(response);
                    console.log('emp response',response);
                    // total_client_message = $('span#bage-noti-count').text()
                    // total_client_message = parseInt(total_client_message);
                    // total_client_message--;
                    // $('span#bage-noti-count').text('');
                    // if(total_client_message > 0){
                    //  $('span#bage-noti-count').text(total_client_message);
                    // }
                    
                    $('#client-member-message .modal-body').html(response.html)
                    $('#client-member-message .modal-body').html(response.html)
                    var client_dashboard_url = '<?php echo $this->Url->build('/Client/clientdashboard/'); ?>'
                    $('#client-message a').attr('href', client_dashboard_url+client_id)

                    // if(total_client_message == 0){
                    //     $('#total_client_message').remove()
                    // }else{
                    //     $('#noti-message-'+client_id).remove();
                    // }

                    var current_client_name = "";
                    if (response.client_name) {
                        current_client_name = ' (' + response.client_name + ')'
                    }
                    $('#client-member-message h4.modal-title').text('Send Message' + current_client_name);

                    $('#client-member-message').modal('show');

                },
                error: function() {
                    loader.hide();
                }
            })
        }
    }

    function editAffiliateReminderDashboard(note_id, tag_id, type = "EDIT") {
        event.preventDefault();
        var loader = $('#' + tag_id);
        if (note_id > 0) {
            loader.show();
            var formData = {
                action: "EDIT_MEMBER_REMINDER",
                reminder_id: note_id,
                user_type: 2
            }

            <?php if($_SESSION['userType']== CRM_USER_INDICATOR && $_SESSION['Auth']['User']['type'] == 1){ ?>
            formData['user_type'] = 3;
            <?php } ?>

            $.ajax({
                type: "POST",
                data: formData,
                url: '<?php echo $this->Url->build('/AffiliateDashboard/'); ?>',
                success: function(response) {
                    loader.hide();
                    response = JSON.parse(response);
                    $('#member-reminder-dashboard textarea').val(response.description);
                    $('#member-reminder-dashboard input').val(response.title);
                    $('#member-reminder-dashboard input[name=member_reminder_id]').val(response.id);
                    $('#member-reminder-dashboard input[name=remainder_date]').val(response.remainder_date);
                    $('#member-reminder-dashboard textarea').attr('disabled', false);
                    $('#member-reminder-dashboard input').attr('disabled', false);
                    $('#member-reminder-dashboard button[type=submit]').show();
                    $('#member-reminder-dashboard h4.modal-title').text('Reminder');
                    if (type == "VIEW" || type == "NOTIFICATION_VIEW") {
                        $('#member-reminder-dashboard h4.modal-title').text('Reminder');
                        $('#member-reminder-dashboard textarea').attr('disabled', true);
                        $('#member-reminder-dashboard input').attr('disabled', true);
                        $('#member-reminder-dashboard button[type=submit]').hide();
                    }
                    if (type == "NOTIFICATION_VIEW") {
                        $('#client-dashboard-url').show();
                        if (response.client_id > 0) {
                            var final_url = response.client_dashboard_url
                            if (response.client_dashboard_url) {
                                final_url += "#member-reminder-note"
                            }
                            $('#client-dashboard-url a').attr('href', final_url);
                        } else {
                            $('#client-dashboard-url').hide()
                        }


                        var prev_title = $('#member-reminder-dashboard h4.modal-title').text()
                        $('#member-reminder-dashboard h4.modal-title').text('')
                        $('#member-reminder-dashboard h4.modal-title').text(prev_title)
                    }
                    //
                    $('#member-reminder-dashboard').modal('show');
                }
            })

        }
    }
    </script>
    <script src="<?php echo $this->request->webroot; ?>magnify/jquery.magnific-popup.js"></script>
    <script>
    $('#popup-youtube, #popup-youtube2').magnificPopup({
        type: 'iframe',
        iframe: {
            patterns: {
                youtube: {
                    index: 'youtube.com',
                    id: 'v=',
                    src: 'https://www.youtube.com/embed/%id%?rel=0&autoplay=1'
                }
            }
        },
    });

    $('.limited-time').magnificPopup({
        type: 'iframe',
        midClick: true,
        closeOnBgClick: false,
        iframe: {
            patterns: {
                youtube: {
                    index: 'youtube.com',
                    id: 'v=',
                    src: 'https://www.youtube.com/embed/%id%?rel=0&autoplay=1'
                }
            },
            markup: '<div class="mfp-iframe-scaler">' +
                '<iframe allow="autoplay;" class="mfp-iframe" frameborder="0" allowfullscreen></iframe>' +
                '</div><div class="confirm-btn-area">' +
                '<a class="btn btn-primary btn-orange-color" href="#">YES! I want to Upgrade Now</a>' +
                '<a class="btn btn-primary btn-orange-color" href="<?php echo $this->Url->build('/users/logout/'); ?>">No! I will Do It Later</a></div>',
        },
        callbacks: {
            open: function() {
                console.log('popup open');
                target.trigger('click');
            },
        }
    });
    </script>
    <?php echo $this->element('datepicker_js') ?>
    <script>
    var ENVIROMENT = '<?php echo ENVIROMENT; ?>'
    $('[data-toggle="tooltip"]').tooltip({
        html: true
    })
    
    
    
    </script>
    <script src="<?php echo $this->request->webroot; ?>js/reminder_event.js?1.0.1"></script>
    <script src="<?php echo $this->request->webroot; ?>js/unwanted_char_remove.js?1.0.4"></script>
    <script src="<?php echo $this->request->webroot;?>js/js.input.validation.js?1.0.1"></script>
    <script src="<?php echo $this->request->webroot; ?>js/note_event.js?1.0.0"></script>
    <?php echo $this->element('sidebar_js'); ?>
    <?php echo $this->element('letter_count_textarea'); ?>
    <?php echo $this->element('reminder_checkbox'); ?>
    <?php echo $this->Html->script('letter_steps.js?1.0.2'); ?>
    <?php echo $this->element('js_clipboardcopy'); ?>
    <?php echo $this->element('employee_to_employee_popup_js'); ?>
    <?php echo $this->element('common/prepare_form_serialize'); ?>

</body>

</html>