<?php
//include('Views/HRM/ChangePassword.php');
//include('Views/HRM/changeprofile.php');
include('Views/Settings/change-password-modal.php');
include('Views/HRM/reportproblem.php');
if (!isset($_GET['url']))
    $menu_name = 'Dashboard';
else {
    $url = explode('/', $_GET['url']);
    if ($url[0] == null)
        $menu_name = 'Dashboard';
    else
        $menu_name = $url[0];
    if (empty($menu_name))
        $menu_name = 'Dashboard';
}


$menu_name = strtolower($menu_name);
$today = Date::getToday();

$purchase = new Purchase;

$logged_id = Session::getUserID();
$lang = Session::getUserPreferences();

$years = Session::getYearsInfo();
if ((!empty(smc_session()['notification_type']) && in_array(1, explode(",", smc_session()['notification_type']))) ||  (Session::is_smart_admin())) {
    $pending_assigned_ticketing = TicketingClass::get_pending_ticketing('assigned');
}
if ((!empty(smc_session()['notification_type']) && in_array(2, explode(",", smc_session()['notification_type']))) ||  (Session::is_smart_admin())) {
    $pending_late_ticketing = TicketingClass::get_pending_ticketing('late');
}
if ((!empty(smc_session()['notification_type']) && in_array(3, explode(",", smc_session()['notification_type']))) ||  (Session::is_smart_admin())) {
    $Count = Announcement::viewNotification();
}
if ((!empty(smc_session()['notification_type']) && in_array(4, explode(",", smc_session()['notification_type']))) ||  (Session::is_smart_admin())) {
    $count_sales_order = $purchase->get_pending_order_count();
}
if ((!empty(smc_session()['notification_type']) && in_array(5, explode(",", smc_session()['notification_type']))) ||  (Session::is_smart_admin())) {
    $product_reorder_total = Product::getTotalProductReorderPoint();
}
if ((!empty(smc_session()['notification_type']) && in_array(6, explode(",", smc_session()['notification_type']))) ||  (Session::is_smart_admin())) {
    $vehicle_data = Vehicle::getVehiclesInsuranceMecanique();
}
if ((!empty(smc_session()['notification_type']) && in_array(8, explode(",", smc_session()['notification_type']))) ||  (Session::is_smart_admin())) {
    $total_messages = Product::get_Un_Read_messages();
}
$jsonMer = json_encode([CommonLanguage::getMessage('am'), CommonLanguage::getMessage('pm')]);
echo "<script>var meridiemArr = {$jsonMer}</script>";
$modal = new authModel();
$companies=$modal->get_companies();




if (!isset($vars['no_left_bar'])) {
?>
    <style>
        .ins_mecq_div .notification-panel .notification-body {
            overflow: auto !important;
        }

        .dropdown .tooltip {
            width: 160px;
        }
    </style>
    <div class="header">
        <div class="pull-left full-height ">
            <div class="sm-action-bar">
                <a href="#" class="btn-link toggle-sidebar MainLeftSidebarCloser pg pg-menu hidden-lg-up" data-toggle="sidebar">
                    <!--<span class="icon-set menu-hambuger"></span>-->
                </a>
            </div>
        </div>
        <div class="pull-right  m-t-10" >
            <a href="javascript:;" data-toggle="dropdown" aria-expanded="true" style="font-size:16px;">
                <span class="text-master"><?php echo Session::getFullName(); ?></span>
                <span class="fa fa-angle-down "></span>
            </a>
            <ul  class="dropdown-menu profile-dropdown" role="menu">
                <?php if ($permissions->hasPermission('change_password')) { ?>
                    <li>
                        <a href="#" class="mainPageLinks change-login-password" data-toggle="modal" data-target="#change-password-modal"><i class="pg-settings_small"></i> <?php print CommonLanguage::getMessage('change_password'); ?></a>
                    </li>
                <?php } ?>
 

                <li class="bg-master-lighter">
                    <a href="smc/doLogout" class="clearfix">
                        <span class="pull-left"><?php print CommonLanguage::getMessage('logout'); ?></span>
                        <span class="pull-right"><i class="pg-power"></i></span>
                    </a>
                </li>
            </ul>
        </div>
        <!-- <?php if ($permissions->hasPermission('show_company')) { ?>
        <div  style=" margin-right: 20px;" class="pull-right  m-t-10 <?php echo empty($companies) ? 'hidden':''; ?>">
            <a href="javascript:;" data-toggle="dropdown" aria-expanded="true" style="font-size:16px;">
                <span class="text-master"><?php echo CommonLanguage::getMessage('change_company'); ?></span>
                <span class="fa fa-angle-down "></span>
            </a>
            <ul style="margin-right: 160px;" class="dropdown-menu profile-dropdown" role="menu">
                <?php if (isset($companies)) { ?>
                    <?php foreach ($companies as $com) { ?>
                        <li>
                            <a href="<?php echo $com['company_url'] ?>" class="mainPageLinks change-login-password" ><i class="pg-settings_small"></i> <?php echo $com['company_name']; ?></a>
                         </li>
                    <?php } ?>
                <?php } ?>
            </ul>
        </div>
        <?php } ?> -->
        <?php if (strlen(smc_session()['default_setting']['website_panel'])) { ?>
        <div style=" margin-right: 20px;" class="pull-right  m-t-10">
            <a href="<?php echo  smc_session()['default_setting']['website_panel']; ?>"     style="font-size:16px;">
                <span class="text-master"><?php echo CommonLanguage::getMessage('website'); ?></span>
                 
            </a>
        </div>
        <?php } ?>
        <div class=" pull-left">
            <div class="header-inner">
                <!--            < ?php echo $lang[0]['Language_Code'] == 'ar' ? "top:7px" : "" ?>-->
                <div class="brand inline" style="font-size:1.3em;padding:5px;margin-left:10px;text-align:center;">
                    <img src="img/logo.png" alt="logo" title="trusto <?= defined('trusto_VERSION') ? ('v' . trusto_VERSION) : ''; ?> | <?= htmlspecialchars(smc_session()['org_detail']['Organization_Name'], ENT_QUOTES); ?>" class="brand hidden-sm hidden-xs" data-src="img/logo.png" data-src-retina="img/logo.png" style="width:80px; margin-left: 40px;" />
                </div>
                <?php if (((!empty(smc_session()['notification_type']) && in_array(8, explode(",", smc_session()['notification_type']))) || (Session::is_smart_admin())) && isset($total_messages) && $total_messages >= 0) { ?>
                    <li class="p-r-15 inline">
                        <div class="dropdown" id="messages_notification">
                            <a href="messages" class="fa fa-comments" tool-tip-toggle="tooltip-demo" data-original-title="<?php echo CommonLanguage::getMessage('un_read_messages'); ?>">
                                <span class="badge" style="position:fixed;top:10px;background-color: #652d90 !important;color: #ed9421 !important;"><?php echo $total_messages ?></span>
                            </a>
                        </div>
                    </li>
                <?php }
                 if (((!empty(smc_session()['notification_type']) && in_array(5, explode(",", smc_session()['notification_type']))) || (Session::is_smart_admin())) && isset($product_reorder_total) && $product_reorder_total >= 0) { ?>
                    <li class="p-r-15 inline">
                        <div class="dropdown" id="reorder_product_notification">
                            <a href="Inventory/reorderStock" class="fa fa-text-height" tool-tip-toggle="tooltip-demo" data-original-title="<?php echo CommonLanguage::getMessage('product_reorder_total'); ?>">
                                <span class="badge" style="position:fixed;top:10px;background-color: #652d90 !important;color: #ed9421 !important;"><?php echo $product_reorder_total ?></span>
                            </a>
                        </div>
                    </li>
                <?php }
                if (((!empty(smc_session()['notification_type']) && in_array(4, explode(",", smc_session()['notification_type']))) || (Session::is_smart_admin())) && !empty($count_sales_order['official'])) { ?>
                    <li class="p-r-15 inline">
                        <div class="dropdown">
                            <a href="Inventory/quotationOrderList/order/sales" id="notification-center" class="fa fa-shopping-basket" tool-tip-toggle="tooltip-demo" data-original-title="<?php echo CommonLanguage::getMessage('sales_order_official'); ?>">
                                <span class="badge" style="position:fixed;top:10px;background-color: #652d90 !important;color: #ed9421 !important;"><?php echo $count_sales_order['official'] ?></span>
                            </a>

                        </div>
                    </li>
                <?php }
                if (((!empty(smc_session()['notification_type']) && in_array(6, explode(",", smc_session()['notification_type']))) || (Session::is_smart_admin())) && !empty($vehicle_data['total'])) { ?>
                    <li class="p-r-15 inline " style="margin-top:20px">
                        <div class="dropdown" id="vehicle_notification">
                            <a href="javascript:;" class="fa fa-truck" data-toggle="dropdown" aria-expanded="true" tool-tip-toggle="tooltip-demo" data-original-title="<?php echo CommonLanguage::getMessage('late_vehicle_insur_mecaq'); ?>"></a>
                            <span class="badge" style="position:fixed;top:10px;background-color: #652d90 !important;color: #ed9421 !important;"><?php echo $vehicle_data['total'] ?></span>
                            <div class="dropdown-menu notification-toggle ins_mecq_div" role="menu" aria-labelledby="notification-center" x-placement="bottom-start" style="position: absolute; transform: translate3d(0px, 16px, 0px); top: 0px; left: 0px; will-change: transform;width:340px!important;">
                                <div class="notification-panel">
                                    <div class="scroll-wrapper notification-body scrollable" style="position: relative;">
                                        <div class="notification-body scrollable scroll-content scroll-scrolly_visible">
                                            <?php foreach ($vehicle_data['data'] as $current_vehicle) { ?>
                                                <div class="notification-item  clearfix">
                                                    <div class="heading">
                                                        <span class="bold"><?php echo $current_vehicle['Vehicle_Name']; ?></span>
                                                        <?php if ($current_vehicle['insurance'] == 1) {
                                                            if (($permissions->hasPermission('add_vehicle_syndicate'))) {  ?>
                                                                <a class="fs-12 m-l-10 text-danger openFrame" data-src="garage/vehicle_mecanique_syndicate/syndicate?is_pop=1&modal=1&vehicle_id=<?php echo $current_vehicle['Vehicle_ID'] . '&vehicle_name=' . $current_vehicle['vehicle_name_code'] . '' ?>"><?php echo CommonLanguage::getMessage('syndicate'); ?></a>
                                                            <?php }
                                                        }
                                                        if ($current_vehicle['mecanique'] == 1) {  ?>
                                                            <span class="fs-12 m-l-10 text-danger"><?php echo CommonLanguage::getMessage('mecanique'); ?></span>
                                                        <?php } ?>
                                                    </div>
                                                </div>
                                            <?php } ?>
                                        </div>
                                    </div>
                                    <div class="scroll-element scroll-x" style="">
                                        <div class="scroll-element_outer">
                                            <div class="scroll-element_size"></div>
                                            <div class="scroll-element_track"></div>
                                            <div class="scroll-bar" style="width: 96px;"></div>
                                        </div>
                                    </div>
                                    <div class="scroll-element scroll-y" style="">
                                        <div class="scroll-element_outer">
                                            <div class="scroll-element_size"></div>
                                            <div class="scroll-element_track"></div>
                                            <div class="scroll-bar" style="height: 94px;"></div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </li>
                <?php }
                if (((!empty(smc_session()['notification_type']) && in_array(3, explode(",", smc_session()['notification_type']))) || (Session::is_smart_admin())) && !empty($Count)) { ?>
                    <li class="p-r-15 inline">
                        <div class="dropdown">
                            <a href="HRM/view_ntf" id="notification-center" class="fa fa-bell-o" tool-tip-toggle="tooltip-demo" data-original-title="<?php echo CommonLanguage::getMessage('hrm_notification'); ?>">
                                <span class="badge" style="position:fixed;top:10px;background-color: #652d90 !important;color: #ed9421 !important;"><?php echo $Count ?></span>
                            </a>
                        </div>
                    </li>
                    
                <?php }                
                
                if (((!empty(smc_session()['notification_type']) && in_array(1, explode(",", smc_session()['notification_type']))) || (Session::is_smart_admin())) && !empty($pending_assigned_ticketing['count'])) { ?>
                    <li class="p-r-15 inline">
                        <div class="dropdown" id="pending_assigned_ticketing_not">
                            <a href="javascript:;" class="fa fa-check" data-toggle="dropdown" aria-expanded="true" tool-tip-toggle="tooltip-demo" data-original-title="<?php echo CommonLanguage::getMessage('pending_assigned_ticketing'); ?>"></a>
                            <span class="badge pulsate" style="position:fixed;top:10px;background-color: #652d90 !important;color: #ed9421 !important;"><?php echo $pending_assigned_ticketing['count'] ?></span>
                            <div class="dropdown-menu notification-toggle" role="menu" aria-labelledby="notification-center" style="position: absolute; transform: translate3d(0px, 16px, 0px); top: 0px; left: 0px; will-change: transform;width:455px!important;">
                                <div class="notification-panel">
                                    <div class="notification-body scrollable" style="position: relative;">
                                        <div class="notification-body scrollable scroll-content scroll-scrolly_visible" style="height: auto; margin-bottom: 0px; margin-right: 0px; ">
                                            <?php foreach ($pending_assigned_ticketing['data'] as $row) { ?>
                                                <div class="notification-item  clearfix">
                                                    <div class="heading">
                                                        <span class="bold"><?php echo $row['Customer_Name']; ?></span>
                                                        <a class="fs-12 m-l-10" href="Ticketing/ticketing/<?php echo $row['ticketing_id'] ?>"><?php echo $row['ticketing_type_name'] . ' ( ' . $row['ticketing_schedule_date'] . ' )'; ?></a>
                                                    </div>
                                                </div>
                                            <?php } ?>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </li>
                <?php }
                if (((!empty(smc_session()['notification_type']) && in_array(2, explode(",", smc_session()['notification_type']))) || (Session::is_smart_admin())) && !empty($pending_late_ticketing['count'])) { ?>
                    <li class="p-r-15 inline">
                        <div class="dropdown" id="pending_late_ticketing_not">
                            <a href="javascript:;" class="fa fa-clock-o" data-toggle="dropdown" aria-expanded="true" tool-tip-toggle="tooltip-demo" data-original-title="<?php echo CommonLanguage::getMessage('pending_late_ticketing'); ?>"></a>
                            <span class="badge pulsate" style="position:fixed;top:10px;background-color: #652d90 !important;color: #ed9421 !important;"><?php echo $pending_late_ticketing['count'] ?></span>
                            <div class="dropdown-menu notification-toggle" role="menu" aria-labelledby="notification-center" style="position: absolute; transform: translate3d(0px, 16px, 0px); top: 0px; left: 0px; will-change: transform;width:455px!important;">
                                <div class="notification-panel">
                                    <div class="notification-body scrollable" style="position: relative;">
                                        <div class="notification-body scrollable scroll-content scroll-scrolly_visible" style="height: auto; margin-bottom: 0px; margin-right: 0px; ">
                                            <?php foreach ($pending_late_ticketing['data'] as $row) { ?>
                                                <div class="notification-item  clearfix">
                                                    <div class="heading">
                                                        <span class="bold"><?php echo $row['Customer_Name']; ?></span>
                                                        <a class="fs-12 m-l-10 " href="Ticketing/ticketing/<?php echo $row['ticketing_id'] ?>"><?php echo $row['ticketing_type_name'] . ' - ' . $row['User_Name'] . ' <span class="text-danger"> (' . $row['hours'] . ' hours) </span>'; ?></a>
                                                    </div>
                                                </div>
                                            <?php } ?>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </li>
                <?php } ?>
                <li class="p-r-15 inline " style="margin-top:20px">
                    <div class="dropdown">
                        <a href="javascript:;" class="fa fa-cog" data-toggle="dropdown" aria-expanded="true"></a>
                        <div class="dropdown-menu notification-toggle" role="menu" aria-labelledby="notification-center">
                            <!--                         style="< ?php echo $lang[0]["Language_Code"] === 'en' ? "" : "height:108px" ?>"-->
                            <div class="notification-panel">
                                <div class="notification-body scrollable" style="position: relative;">
                                    <div class="notification-body scrollable scroll-content scroll-scrolly_visible" style="height: auto; margin-bottom: 0px; margin-right: 0px; ">
                                        <div class="notification-item  clearfix">
                                            <div class="heading ">
                                                <span class="text-center"><?php echo CommonLanguage::getMessage('choose_lang'); ?> </span>
                                                <div class="col-md-12" style="text-align:center">
                                                    <div class="radio radio-success " id="Language">
                                                        <input type="radio" value="en" <?php echo $lang === 'en' ? 'checked="checked"' : ''; ?> name="User_language" id="en">
                                                        <label for="en"><?php print CommonLanguage::getMessage('english'); ?> </label>
                                                        <input type="radio" value="ar" <?php echo $lang === 'ar' ? 'checked="checked"' : ''; ?> name="User_language" id="ar">
                                                        <label for="ar"><?php print CommonLanguage::getMessage('arabic'); ?></label>
                                                        <input type="radio" value="fr" <?php echo $lang === 'fr' ? 'checked="checked"' : ''; ?> name="User_language" id="fr">
                                                        <label for="fr"><?php print CommonLanguage::getMessage('french'); ?></label>
                                                        <input type="radio" value="tr" <?php echo $lang === 'tr' ? 'checked="checked"' : ''; ?> name="User_language" id="tr">
                                                        <label for="tr"><?php print CommonLanguage::getMessage('turki'); ?></label>
                                                        <input type="radio" value="hy" <?php echo $lang === 'hy' ? 'checked="checked"' : ''; ?> name="User_language" id="hy">
                                                        <label for="hy"><?php print CommonLanguage::getMessage('armani'); ?></label>


                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </li>
                

                <ul class="notification-list no-margin hidden-sm hidden-xs b-grey b-l b-r no-style p-l-30 p-r-20">
                    <!--                style="< ?php echo $lang[0]['Language_Code'] == 'ar' ? "margin-top:15px" : "" ?>"-->
                    <li class="p-r-15 inline">
                        <span class="pg-calender" style="margin-right:5px"></span>
                        <?php echo CommonLanguage::getMessage(date("l")) . " " . date("d-m-Y"); ?>
                    </li>
                    <li class="p-r-15 inline" id="HeaderTime">
                        <span class="pg-clock" style="margin-right:5px"></span>
                        <span class="hour"></span>
                        <span>:</span>
                        <span class="min"></span>
                        <span>:</span>
                        <span class="sec"></span>
                        <span class="meridiem"></span>
                    </li>
                </ul>
                <span class="bold no-style p-l-30 p-r-20 hidden-sm hidden-xs" style="font-size:13px;"><?php echo CommonLanguage::getMessage('current_year') . ' ' . SESSION::getCurrentYear(); ?>
                </span>
                <li class="p-r-15 inline" style="margin-top:20px">
                    <div class="dropdown ">
                        <a href="javascript:;" class="fa fa-pencil hidden-sm hidden-xs" data-toggle="dropdown" aria-expanded="true"></a>
                        <div class="dropdown-menu notification-toggle" role="menu" aria-labelledby="notification-center">
                            <div class="notification-panel" style="">
                                <div class="scroll-wrapper notification-body " style="position: relative;">
                                    <div class="notification-body  scroll-content" style="position: relative; margin-bottom: 0px; margin-right: 0px;">
                                        <div class="scroll-wrapper notification-body  scroll-content scroll-scrolly_visible" style="position: relative;">
                                            <div class="notification-body  scroll-content" style="margin-bottom: 0px; margin-right: 0px;">
                                                <div class="notification-item  clearfix">
                                                    <div class="heading ">
                                                        <span class="text-center">Choose Year </span>
                                                        <div class="col-md-12" style="text-align:center">
                                                            <div class="radio radio-success " id="edit_current">
                                                                <?php for ($i = 0; $i < count($years); $i++) { ?>
                                                                    <input type="radio" <?php echo $years[$i]['current_year_id'] == Session::getCurrentYearID() ? 'checked="checked" ' : '' ?> value="<?php echo $years[$i]['current_year_id']; ?>" data-start="<?php echo $years[$i]['start_date']; ?>" data-end="<?php echo $years[$i]['end_date']; ?>" data-closed="<?php echo $years[$i]['is_closed']; ?>" data-year="<?php echo $years[$i]['current_year']; ?>" name="choose_year" id="year<?php echo $years[$i]['current_year_id'] ?>">
                                                                    <label for="year<?php echo $years[$i]['current_year_id'] ?>"><?php echo $years[$i]['current_year']; ?> </label>
                                                                <?php } ?>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="scroll-element scroll-x">
                                                <div class="scroll-element_outer">
                                                    <div class="scroll-element_size"></div>
                                                    <div class="scroll-element_track"></div>
                                                    <div class="scroll-bar" style="width: 96px;"></div>
                                                </div>
                                            </div>
                                            <div class="scroll-element scroll-y">
                                                <div class="scroll-element_outer">
                                                    <div class="scroll-element_size"></div>
                                                    <div class="scroll-element_track"></div>
                                                    <div class="scroll-bar" style="height: 95px;"></div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="scroll-element scroll-x">
                                        <div class="scroll-element_outer">
                                            <div class="scroll-element_size"></div>
                                            <div class="scroll-element_track"></div>
                                            <div class="scroll-bar" style="width: 96px;"></div>
                                        </div>
                                    </div>
                                    <div class="scroll-element scroll-y">
                                        <div class="scroll-element_outer">
                                            <div class="scroll-element_size"></div>
                                            <div class="scroll-element_track"></div>
                                            <div class="scroll-bar" style="height: 96px;"></div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </li>
            </div>
        </div>
    </div>
<?php } ?>
<div class="modal fade bs-example-modal-md " id="cash-drawer-amount-modal" data-backdrop="static">
    <div class="modal-dialog modal-sm">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true"><i class="pg-close fs-20"></i>
                </button>
                <h5 class="text-left semi-bold "><?php echo CommonLanguage::getMessage('cash_drawer_amount'); ?></h5>
            </div>
            <div class="modal-body">
                <form id="cash_drawer_amount_form" method="POST" onsubmit="return false">
                    <?php echo Forms::AlertDiv('cash_drawer_amount_alert'); ?>
                    <div class="row">
                        <div class="col-md-12 form-group m-t-10">
                            <label><?php print CommonLanguage::getMessage('real_cash_amount'); ?></label><span class="red-star">*</span>
                            <input type="number" placeholder="<?php print CommonLanguage::getMessage('amount'); ?>" id="real_amount" name="real_amount" step="any" min="0" class="form-control " required>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-md-12 form-group">
                            <label class="labelText"><?php print CommonLanguage::getMessage('cash_drawer'); ?></label>
                            <span class="red-star">*</span>
                            <span class="fa fa-plus-circle m-l-5 openFrame" data-src="ACC/cash_drawer_accounts/1?is_pop=1" style="color:#4c0870;cursor:pointer"></span>
                            <input class=" full-width" id="cash_drawer_id_ref" name="cash_drawer_id_ref" type="hidden" required />
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button class="btn btn-default" data-dismiss="modal"><?php print CommonLanguage::getMessage('Close'); ?></button>
                <button class="btn bg-complete white" id="submit_cash_drawer_amount"><?php print CommonLanguage::getMessage('Save'); ?></button>
            </div>
            <?php echo Forms::ModalLoader('cashDrawerAmountLoader'); ?>
        </div>
    </div>
</div>
<div class="modal fade bs-example-modal-md " id="logout-amount-modal" data-backdrop="static">
    <div class="modal-dialog modal-sm">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true"><i class="pg-close fs-20"></i>
                </button>
                <h5 class="text-left semi-bold "><?php echo CommonLanguage::getMessage('cash_drawer_amount'); ?></h5>
            </div>
            <div class="modal-body">
                <form id="logout_amount_form" method="POST" onsubmit="return false">
                    <?php echo Forms::AlertDiv('logout_amount_alert'); ?>
                    <input name="cash_drawer_id_ref" type="hidden" value="1" />
                    <div class="row">
                        <div class="col-md-12 form-group m-t-10">
                            <label><?php print CommonLanguage::getMessage('withdrawal_amount'); ?></label><span class="red-star">*</span>
                            <input type="number" placeholder="<?php print CommonLanguage::getMessage('withdrawal_amount'); ?>" id="withdrawal_amount" name="withdrawal_amount" step="any" min="0" class="form-control " required>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-md-12 form-group m-t-10">
                            <label><?php print CommonLanguage::getMessage('remaining_amount'); ?></label><span class="red-star">*</span>
                            <input type="number" placeholder="<?php print CommonLanguage::getMessage('remaining_amount'); ?>" id="remaining_amount" name="remaining_amount" step="any" min="0" class="form-control " required>
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button class="btn btn-default" data-dismiss="modal"><?php print CommonLanguage::getMessage('Close'); ?></button>
                <button class="btn bg-complete white" id="submit_logout_amount"><?php print CommonLanguage::getMessage('Save'); ?></button>
            </div>
            <?php echo Forms::ModalLoader('logoutAmountLoader'); ?>
        </div>
    </div>
</div>
<div class="modal fade" id="product_alert_expiry" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" style="max-width: 500px;margin:auto;    max-height: 241px;">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true"><i class="pg-close fs-20"></i>
                </button>
                <h5 class="text-left semi-bold "><?php echo CommonLanguage::getMessage('product_alert_expire'); ?></h5>
            </div>
            <div class="modal-body">
            <div class="row">
                        <div class="Conf col-md-12 m-t-10">
                            <p><?php echo CommonLanguage::getMessage('you_have'); ?> <?php echo Product::count_expire_product() > 0 ? Product::count_expire_product() :'';  echo " ";  echo Product::count_expire_product() == 1 ? CommonLanguage::getMessage('product') : CommonLanguage::getMessage('products') ; ?>  <?php echo CommonLanguage::getMessage('will_expire_soon'); ?></p>
                        </div>
                    </div>
            </div>
            <div class="modal-footer">
                <button class="btn btn-default" data-dismiss="modal"><?php print CommonLanguage::getMessage('Close'); ?></button>
                <a class="btn bg-complete white" href="Inventory/ExpiryDate/ex"><?php print CommonLanguage::getMessage('expire_report'); ?></a>
            </div>
            <?php echo Forms::ModalLoader('logoutAmountLoader'); ?>
        </div>
    </div>
</div>

<script>
    var cash_drawer_id = <?php echo json_encode(smc_session()['user_accounts']['cash_drawer_id']); ?>,
        cash_drawer_title = <?php echo json_encode(smc_session()['user_accounts']['cash_drawer_title']); ?>,
        activate_cash_drawer = <?php echo json_encode(smc_session()['default_setting']['activate_cash_drawer']); ?>,
        set_cash_drawer = <?php echo json_encode(isset(smc_session()['is_cash_drawer_active']) ? 1 : 0); ?>;
    var current_page = "<?php echo $menu_name; ?>";
    var PageStyles = {
        "dashboard": "bg-danger",
        "acc": "bg-complete",
        "inventory": "bg-primary",
        "pos": "bg-info",
        "hrm": "bg-success",
        "production": "bg-danger",
        "stock": "bg-complete-darker",
        "garage": "bg-success-darker",
        "useractivity": "bg-logging",
        "crm": "bg-complete-dark",
        "ticketing": "bg-complete",
        "general": "bg-primary-darker",
        "settings": "bg-info-light",
        "website_panel": "bg-info-light",
        "maintenance": "bg-success-dark"
    }
    var myCurrentLocation = "<?php echo (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"; ?>";
    //
    $(function() {
        <?php if(Product::count_expire_product() > 0 && smc_session()['default_setting']['enable_expiry_alert'] == 1 &&  smc_session()['default_setting']['count_expiry_product_alert'] > 0 && $permissions->hasPermission('active_expiry_qty_products')){ 
        ?>
        $('.modal-content').resizable({
      //alsoResize: ".modal-dialog",
      minHeight: 300,
      minWidth: 300
    });
    $('.modal-dialog').draggable();

    $('#product_alert_expiry').on('show.bs.modal', function() {
      $(this).find('.modal-body').css({
        'max-height': '100%'
      });
    });
            $('#product_alert_expiry').modal('show');
        <?php 
            smc_session()['default_setting']['count_expiry_product_alert'] -=1;
        } ?>


        $('[tool-tip-toggle="tooltip-demo"]').tooltip({
            placement: 'bottom'
        });
        if (cash_drawer_id && cash_drawer_id != 0) {
            $("#cash_drawer_id_ref").val(cash_drawer_id).attr('data-select-name', cash_drawer_title);
        }
        build_select2($("#cash_drawer_id_ref"), "xhr/cashDrawerSearch");
        $("#submit_cash_drawer_amount").on('click', function() {
            if (!$("#cash_drawer_amount_form").valid())
                return;
            var Data = new FormData(document.getElementById("cash_drawer_amount_form"));
            $("#cashDrawerAmountLoader").removeClass('hidden');
            $.ajax({
                url: "ACCAjax/submitCashDrawerAmount",
                method: "POST",
                data: Data,
                processData: false,
                contentType: false,
                dataType: "JSON",
                complete: function(jqXHR, status) {
                    if (status == 'success') {
                        if (jqXHR.responseJSON[1] == "success") {
                            hideModalAlert('cash-drawer-amount-modal', 'cash_drawer_amount_alert');
                            if (current_page == 'main_pos') {
                                $("#OrderTable > tbody ").empty();
                                UpdateTable($("#OrderTable > tbody:last"));
                            }
                            setTimeout(function() {
                                window.location = myCurrentLocation;
                            }, 1000)

                        }
                        AddAlert("#cash_drawer_amount_alert", jqXHR.responseJSON[0], jqXHR.responseJSON[1]);
                    }
                    $("#cashDrawerAmountLoader").addClass('hidden');
                }
            });
        });
        $("#submit_logout_amount").on('click', function() {
            if (!$("#logout_amount_form").valid())
                return;
            var Data = new FormData(document.getElementById("logout_amount_form"));
            $("#logoutAmountLoader").removeClass('hidden');
            $.ajax({
                url: "ACCAjax/submitCashDrawerAmountLogout",
                method: "POST",
                data: Data,
                processData: false,
                contentType: false,
                dataType: "JSON",
                complete: function(jqXHR, status) {
                    if (status == 'success') {
                        if (jqXHR.responseJSON[1] == "success") {
                            hideModalAlert('logout-amount-modal', 'logout_amount_alert');
                            if (current_page == 'main_pos') {
                                $("#OrderTable > tbody ").empty();
                                UpdateTable($("#OrderTable > tbody:last"));
                            }
                            setTimeout(function() {
                                window.location = site_link + 'smc/doLogout<?php echo smc_session()['default_setting']['activate_smart_diner'] == 1 ? '/1' : ''; ?>';
                            }, 1000)

                        }
                        AddAlert("#logout_amount_alert", jqXHR.responseJSON[0], jqXHR.responseJSON[1]);
                    }
                    $("#logoutAmountLoader").addClass('hidden');
                }
            });
        });
        $("#Language input").on("click", function() {
            $.ajax({
                url: "xhr/ajaxLanguage",
                method: "POST",
                data: {
                    Lang: $("#Language input[name=User_language]:checked").val()
                },
                complete: function(v1, v2) {
                    if (v2 == 'success') {
                        if (v1.responseText === "ok") {
                            window.location = myCurrentLocation;
                        } else {
                            return false;
                        }
                    }
                }
            })
        })
    });

    function doLogoutSystem() {
        if (activate_cash_drawer == 1 && set_cash_drawer == 1) {
            $('#logout-amount-modal input[name=cash_drawer_id_ref]').val('<?php echo !empty(smc_session()['current_cash_drawer_id']) ? smc_session()['current_cash_drawer_id'] : ''; ?>')
            $('#logout-amount-modal').modal('show');
        } else {
            window.location = site_link + 'smc/doLogout';
        }
    }

    $("#notification-center > span.badge,#vehicle_notification > span.badge,#reorder_product_notification span.badge,#pending_assigned_ticketing_not span.badge,#pending_late_ticketing_not span.badge").addClass(PageStyles[current_page])

    $("#edit_current input").on("click", function() {
        var Data = {
            year: $(this).attr('data-year'),
            year_id: $(this).val(),
            start_date: $(this).attr('data-start'),
            end_date: $(this).attr('data-end'),
            is_closed: $(this).attr('data-closed')
        }
        $.ajax({
            url: "xhr/ajaxCurrentYear",
            method: "POST",
            data: Data,
            //                data:{year:$("#edit_current input[name=choose_year]:checked").val()},
            complete: function(v1, v2) {
                if (v2 == 'success') {
                    if (v1.responseText === "ok") {
                        window.location = myCurrentLocation;
                    } else {
                        return false;
                    }
                }
            }
        })
    })
</script>