Plugin Directory

Changeset 3287366


Ignore:
Timestamp:
05/05/2025 04:57:07 AM (11 months ago)
Author:
codebangers
Message:

fixing security and improving ui

Location:
aio-time-clock-lite
Files:
114 added
7 edited

Legend:

Unmodified
Added
Removed
  • aio-time-clock-lite/trunk/aio-settings.php

    r3286600 r3287366  
    11<div class="wrap aio_admin_wrapper">
    2     <?php session_start(); ?>
    3     <?php
    4     $token = isset($_SESSION['timeclock_manage_token']) ? $_SESSION['timeclock_manage_token'] : null;
    5     if (!isset($token)) {
    6         //echo "setting session";
    7         // generate token and persist for later verification
    8         // - in practice use openssl_random_pseudo_bytes() or similar instead of uniqid()
    9         $token = md5(uniqid());
    10         $_SESSION['timeclock_manage_token']= $token;
    11         session_write_close();
    12     }
    13     else{
    14         //echo $token;
    15     }
    16     ?>
    172    <?php $logo = plugins_url('/images/logo.png', __FILE__); ?>
    183    <a href="https://codebangers.com" target="_blank"><img src="<?php echo esc_url($logo); ?>" style="width:15%;"></a>
     
    249        <?php settings_errors(); ?>
    2510        <?php
    26             $new_eprofile_id = null;
    2711            $job = isset($_GET["job"]) ? sanitize_text_field($_GET["job"]) : null;
    2812            $current_user = wp_get_current_user();       
     
    6751            <?php
    6852        }
    69        
    70         if (isset($job)){
    71             if ($token && $_SESSION['timeclock_manage_token'] === $token) {
    72                 if ($job == "create_timeclock_page") {
    73                     $tc_page = $this->aio_check_tc_shortcode_lite();
    74                     if ($tc_page == null) {
    75                         $my_post = array(
    76                             'post_type' => 'page',
    77                             'post_title' => 'Time Clock',
    78                             'post_status' => 'publish',
    79                             'post_content' => '[show_aio_time_clock_lite]',
    80                             'comment_status' => 'closed',
    81                             'post_author' => $current_user->ID
    82                         );
    83                         // Insert the post into the database
    84                         $new_post_id = wp_insert_post($my_post);
    85                     }
    86                     ?>
    87                     <div id="setting-error-settings_updated" class="updated settings-error aio-tc-alert">
    88                         <?php
    89                         if ($new_post_id != null) {
    90                             echo esc_attr_x('TimeClock Page Created Sucessfully', 'aio-time-clock-lite'); ?>
    91                             <a href="<?php echo esc_url(get_permalink($new_post_id)); ?>" class="button small_button" target="_blank"><i class="dashicons dashicons-search vmiddle"></i><?php echo esc_attr_x('View Page', 'aio-time-clock-lite'); ?></a>
    92                         <?php } else {
    93                             echo esc_attr_x('Something went wrong.  Timeclock was not created successfully', 'aio-time-clock-lite');
    94                             if ($tc_page != null) {
    95                                 echo esc_attr_x('You already have a TimeClock page created', 'aio-time-clock-lite'); ?>
    96                                 &nbsp;<a href="<?php echo esc_url(get_permalink($tc_page)); ?>" class="button small_button" target="_blank"><i class="dashicons dashicons-search vmiddle"></i><?php echo esc_attr_x('View Page', 'aio-time-clock-lite'); ?></a>
    97                                 <?php
    98                             }
    99                         }
    100                         ?>
    101                     </div>
    102                     <?php
    103                 }
    104                 if ($job == "create_eprofile_page") {
    105                     $eprofile_page = $this->check_eprofile_shortcode_lite();
    106                     if ($eprofile_page == null) {
    107                         $my_post = array(
    108                             'post_type' => 'page',
    109                             'post_title' => 'Employee Profile',
    110                             'post_status' => 'publish',
    111                             'post_content' => '[show_aio_employee_profile_lite]',
    112                             'comment_status' => 'closed',
    113                             'post_author' => 1
    114                         );
    115                         // Insert the post into the database
    116                         $new_eprofile_id = wp_insert_post($my_post);
    117                     }
    118                     ?>
    119                     <div id="setting-error-settings_updated" class="updated settings-error aio-tc-alert">
    120                         <?php
    121                         if ($new_eprofile_id != null) {
    122                             echo esc_attr_x('Employee Profile Page Created Sucessfully', 'aio-time-clock-lite'); ?>
    123                             <a href="<?php echo esc_url(get_permalink($new_eprofile_id)); ?>" class="button small_button" target="_blank"><i class="dashicons dashicons-search vmiddle"></i> <?php echo esc_attr_x('View Profile', 'aio-time-clock-lite'); ?></a>
    124                             <?php
    125                         } else {
    126                             echo esc_attr_x('Something went wrong.  Employee Profile Page was not created successfully', 'aio-time-clock-lite');
    127                             if ($eprofile_page != null) {
    128                                 echo esc_attr_x('You already have a Employee Profile page created', 'aio-time-clock-lite'); ?>
    129                                 <a href="<?php echo esc_url(get_permalink($eprofile_page)); ?>" class="button small_button" target="_blank"><i class="dashicons dashicons-search vmiddle"></i> <?php echo esc_attr_x('View Profile', 'aio-time-clock-lite'); ?></a>
    130                                 <?php
    131                             }
    132                         }
    133                         ?>
    134                     </div>
    135                     <?php
    136                 }
    137                 session_write_close();
    138             }   
    139             else{
    140                 session_write_close();
    141                 die(__("You are not authorized to perform this action", "aio-time-clock"));
    142             }
    143         }
    14453        ?>
    14554        <h3><?php echo esc_attr_x('General Settings', 'aio-time-clock-lite'); ?></h3>
     
    14958            $options = get_option('nertworks-timeclock-settings-group');
    15059            ?>
    151             <table class="widefat fixed" cellspacing="0">
     60            <table class="widefat fixed time-clock-table" cellspacing="0">
    15261                <tr class="alternate">
    15362                    <th scope="col" class="manage-column column-columnname"><strong><?php echo esc_attr_x('Company Name', 'aio-time-clock-lite'); ?>: </strong></th>
     
    17180                <tr class="alternate">
    17281                    <th scope="col" class="manage-column column-columnname"><strong><?php echo esc_attr_x('Time Clock', 'aio-time-clock-lite'); ?>: </strong></th>
    173                     <td>
     82                    <td id="create_timeclock_page_td">
    17483                        <?php
    17584                        $tc_page = $this->aio_check_tc_shortcode_lite();
    17685                        if ($tc_page != null) { ?>
    177                             <a href="<?php echo esc_url(get_permalink($tc_page)); ?>" class="button small_button" target="_blank"><i class="dashicons dashicons-search vmiddle"></i> <?php echo esc_attr_x('View Page', 'aio-time-clock-lite'); ?></a>
    178                             <a href="/wp-admin/post.php?post=<?php echo esc_attr($tc_page); ?>&action=edit" class="button small_button" target="_blank"><i class="dashicons dashicons-edit vmiddle"></i><?php echo esc_attr_x('Edit Page', 'aio-time-clock-lite'); ?></a>
     86                            <a href="<?php echo esc_url(get_permalink($tc_page)); ?>" class="button small_button" target="_blank"><i class="dashicons dashicons-search vmiddle"></i>&nbsp;<?php echo esc_attr_x('View Page', 'aio-time-clock-lite'); ?></a>
     87                            <a href="/wp-admin/post.php?post=<?php echo esc_attr($tc_page); ?>&action=edit" class="button small_button" target="_blank"><i class="dashicons dashicons-edit vmiddle"></i>&nbsp; <?php echo esc_attr_x('Edit Page', 'aio-time-clock-lite'); ?></a>
    17988                        <?php } else { ?>
    180                             <?php echo esc_attr_x('Time Clock page not found. Would you like to create one', 'aio-time-clock-lite'); ?>?&nbsp;<a href="<?php echo esc_url(admin_url('?page=aio-tc-lite&tab=general_settings&job=create_timeclock_page&t=' . $token)); ?>" class="button small_button"><span class="dashicons dashicons-plus vmiddle"></span></a>
     89                            <?php echo esc_attr_x('Time Clock page not found. Would you like to create one', 'aio-time-clock-lite'); ?>? &nbsp; <a onclick="createTimeClockPage(this);" data-admin-action="<?php echo esc_attr("create_timeclock_page"); ?>" class="button small_button time-clock-admin-button"><span class="dashicons dashicons-plus vmiddle"></span></a>
    18190                            <?php
    18291                        }
     
    18998                <tr>
    19099                    <th scope="col" class="manage-column column-columnname"><strong><?php echo esc_attr_x('Employee Profile', 'aio-time-clock-lite');?>: </strong></th>
    191                     <td>
     100                    <td id="create_eprofile_page_td">
    192101                        <?php
    193102                        $eprofile_page = $this->check_eprofile_shortcode_lite();
    194103                        if ($eprofile_page != null) { ?>
    195                             <a href="<?php echo esc_url(get_permalink(intval($eprofile_page))); ?>" class="button small_button" target="_blank"><i class="dashicons dashicons-search vmiddle"></i> <?php echo esc_attr_x('View Page', 'aio-time-clock-lite'); ?></a>
    196                             <a href="/wp-admin/post.php?post=<?php echo intval($eprofile_page); ?>&action=edit" class="button small_button" target="_blank"><i class="dashicons dashicons-edit vmiddle"></i> <?php echo esc_attr_x('Edit Page', 'aio-time-clock-lite'); ?></a>
     104                            <a href="<?php echo esc_url(get_permalink(intval($eprofile_page))); ?>" class="button small_button" target="_blank"><i class="dashicons dashicons-search vmiddle"></i>&nbsp;<?php echo esc_attr_x('View Page', 'aio-time-clock-lite'); ?></a>
     105                            <a href="/wp-admin/post.php?post=<?php echo intval($eprofile_page); ?>&action=edit" class="button small_button" target="_blank"><i class="dashicons dashicons-edit vmiddle"></i>&nbsp;<?php echo esc_attr_x('Edit Page', 'aio-time-clock-lite'); ?></a>
    197106                        <?php
    198107                        } else {
    199108                            ?>
    200                             <?php echo esc_attr_x('Employee Profile page not found. Would you like to create one', 'aio-time-clock-lite'); ?>? ?&nbsp;<a href="<?php echo esc_url(admin_url('?page=aio-tc-lite&tab=general_settings&job=create_eprofile_page&t=' . $token)); ?>" class="button small_button"><span class="dashicons dashicons-plus vmiddle"></span></a>                   
     109                            <?php echo esc_attr_x('Employee Profile page not found. Would you like to create one', 'aio-time-clock-lite'); ?>? &nbsp; <a onclick="createTimeClockPage(this);" data-admin-action="<?php echo esc_attr("create_eprofile_page"); ?>" class="button small_button time-clock-admin-button"><span class="dashicons dashicons-plus vmiddle"></span></a>                   
    201110                            <?php
    202111                        }
     
    210119                    <th scope="col" class="manage-column column-columnname"><strong><?php echo esc_attr_x('Quick Pick Time Clock', 'aio-time-clock-lite');?>: </strong></th>
    211120                    <td>
    212                         <?php echo esc_attr_x('Available in', 'aio-time-clock-lite').' <a href="https://codebangers.com/product/all-in-one-time-clock/" target="_blank" class="button">' . esc_attr_x('Pro', 'aio-time-clock-lite') . '</a>'; ?>
     121                        <?php echo esc_attr_x('Available in', 'aio-time-clock-lite').' &nbsp; <a href="https://codebangers.com/product/all-in-one-time-clock/" target="_blank" class="button time-clock-admin-button"><i class="dashicons dashicons-clock vmiddle"></i>&nbsp; ' . esc_attr_x('Pro', 'aio-time-clock-lite') . '</a>'; ?>
    213122                    </td>
    214123                    <td>
     
    231140                    <th scope="col" class="manage-column column-columnname"><strong><?php echo esc_attr_x('Show Employee Avatar', 'aio-time-clock-lite'); ?>: </strong></th>
    232141                    <td>
    233                         <?php echo esc_attr_x('Available in', 'aio-time-clock-lite').' <a href="https://codebangers.com/product/all-in-one-time-clock/" target="_blank" class="button">' . esc_attr_x('Pro', 'aio-time-clock-lite') . '</a>'; ?>
     142                        <?php echo esc_attr_x('Available in', 'aio-time-clock-lite').' &nbsp; <a href="https://codebangers.com/product/all-in-one-time-clock/" target="_blank" class="button time-clock-admin-button"><span class="dashicons dashicons-clock vmiddle"></span>&nbsp; ' . esc_attr_x('Pro', 'aio-time-clock-lite') . '</a>'; ?>
    234143                    </td>
    235144                    <td>
     
    266175                    <th scope="col" class="manage-column column-columnname"><strong><?php echo esc_attr_x('Enable Location', 'aio-time-clock-lite'); ?>: </strong></th>
    267176                    <td>
    268                         <?php echo esc_attr_x('Available in', 'aio-time-clock-lite').' <a href="https://codebangers.com/product/all-in-one-time-clock/" target="_blank" class="button">' . esc_attr_x('Pro', 'aio-time-clock-lite') . '</a>'; ?>
     177                        <?php echo esc_attr_x('Available in', 'aio-time-clock-lite').' &nbsp; <a href="https://codebangers.com/product/all-in-one-time-clock/" target="_blank" class="button time-clock-admin-button"><span class="dashicons dashicons-clock vmiddle"></span>&nbsp; ' . esc_attr_x('Pro', 'aio-time-clock-lite') . '</a>'; ?>
    269178                    </td>
    270179                    <td>
     
    277186                    <th scope="col" class="manage-column column-columnname"><strong><?php echo esc_attr_x('Custom Roles', 'aio-time-clock-lite'); ?>: </strong></th>
    278187                    <td>
    279                         <?php echo esc_attr_x('Available in', 'aio-time-clock-lite').' <a href="https://codebangers.com/product/all-in-one-time-clock/" target="_blank" class="button">' . esc_attr_x('Pro', 'aio-time-clock-lite') . '</a>'; ?>
     188                        <?php echo esc_attr_x('Available in', 'aio-time-clock-lite').' &nbsp; <a href="https://codebangers.com/product/all-in-one-time-clock/" target="_blank" class="button time-clock-admin-button"><span class="dashicons dashicons-clock vmiddle"></span>&nbsp; ' . esc_attr_x('Pro', 'aio-time-clock-lite') . '</a>'; ?>
    280189                    </td>
    281190                    <td>
     
    286195                </tr>
    287196            </table>
     197            <input type="hidden" name="time-clock-nonce" id="time-clock-nonce" value="<?php echo wp_create_nonce("time-clock-nonce"); ?>">
    288198            <?php submit_button(); ?>
    289199        </form>
  • aio-time-clock-lite/trunk/aio-time-clock-lite-actions.php

    r3286600 r3287366  
    22class AIO_Time_Clock_Lite_Actions
    33{
    4     public $dateFormat = 'Y-m-d H:i:s';
    5     public $safeDateFormat = 'm/d/Y g:i A';
     4    public $dateFormat        = 'Y-m-d H:i:s';
     5    public $safeDateFormat    = 'm/d/Y g:i A';
    66    public $defaultDateFormat = 'Y-m-d g:i A';
    7     public $mysqlDateFormat = 'Y-m-d H:i:s';
    8     public $prettyDateTime = 'Y-m-d h:i A';
     7    public $mysqlDateFormat   = 'Y-m-d H:i:s';
     8    public $prettyDateTime    = 'Y-m-d h:i A';
    99    public $widgets;
    1010
    1111    public function setup()
    1212    {
    13         register_activation_hook(__FILE__, array($this, 'aio_time_clock_lite_plugin_update'));
    14         add_action("admin_menu", array($this, 'addMenuItem'));
    15         add_action('init', array($this, 'pluginInit'));
    16         add_action('wp_enqueue_scripts', array($this, 'frontEndScripts'));
    17         add_action('admin_enqueue_scripts', array($this, 'adminScripts'));
    18         add_action('admin_init', array($this, 'aio_timeclock_lite_plugin_redirect'));
     13        register_activation_hook(__FILE__, [$this, 'aio_time_clock_lite_plugin_update']);
     14        add_action("admin_menu", [$this, 'addMenuItem']);
     15        add_action('init', [$this, 'pluginInit']);
     16        add_action('wp_enqueue_scripts', [$this, 'frontEndScripts']);
     17        add_action('admin_enqueue_scripts', [$this, 'adminScripts']);
     18        add_action('admin_init', [$this, 'aio_timeclock_lite_plugin_redirect']);
    1919        //Shortcode
    20         add_shortcode('show_aio_time_clock_lite', array($this, 'show_aio_time_clock_lite'));
    21         add_shortcode('show_aio_employee_profile_lite', array($this, 'show_aio_employee_profile_lite'));
     20        add_shortcode('show_aio_time_clock_lite', [$this, 'show_aio_time_clock_lite']);
     21        add_shortcode('show_aio_employee_profile_lite', [$this, 'show_aio_employee_profile_lite']);
    2222        //Ajax
    23         add_action('wp_ajax_aio_time_clock_lite_js', array($this, 'aio_time_clock_lite_js'));
    24         add_action('wp_ajax_nopriv_aio_time_clock_lite_js', array($this, 'aio_time_clock_lite_js'));
    25         add_action('wp_ajax_aio_time_clock_lite_admin_js', array($this, 'aio_time_clock_lite_admin_js'));
    26         add_action('wp_ajax_nopriv_aio_time_clock_lite_admin_js', array($this, 'aio_time_clock_lite_admin_js'));
     23        add_action('wp_ajax_aio_time_clock_lite_js', [$this, 'aio_time_clock_lite_js']);
     24        add_action('wp_ajax_nopriv_aio_time_clock_lite_js', [$this, 'aio_time_clock_lite_js']);
     25        add_action('wp_ajax_aio_time_clock_lite_admin_js', [$this, 'aio_time_clock_lite_admin_js']);
     26        add_action('wp_ajax_nopriv_aio_time_clock_lite_admin_js', [$this, 'aio_time_clock_lite_admin_js']);
    2727        //Shift Meta
    28         add_action('admin_init', array($this, 'aio_tc_custom_post_shift_lite'));
    29         add_action("admin_init", array($this, "aio_timeclock_admin_init_lite"));
    30         add_action('add_meta_boxes', array($this, 'aio_shift_info_box_meta_lite'));
    31         add_action('admin_menu', array($this, 'removeMetaBoxes'));
    32         add_action('admin_init', array($this, 'register_aio_timeclock_lite_settings'));
    33         add_filter('user_contactmethods', array($this, 'modifyWageLite'));
    34         add_action('admin_menu', array($this, 'remove_my_post_metaboxes_aio_lite'));
    35         add_action('admin_notices', array($this, 'adminNoticesLite'));
    36         add_action('plugins_loaded', array($this, 'pluginInitLite'));
     28        add_action('admin_init', [$this, 'aio_tc_custom_post_shift_lite']);
     29        add_action("admin_init", [$this, "aio_timeclock_admin_init_lite"]);
     30        add_action('add_meta_boxes', [$this, 'aio_shift_info_box_meta_lite']);
     31        add_action('admin_menu', [$this, 'removeMetaBoxes']);
     32        add_action('admin_init', [$this, 'register_aio_timeclock_lite_settings']);
     33        add_filter('user_contactmethods', [$this, 'modifyWageLite']);
     34        add_action('admin_menu', [$this, 'remove_my_post_metaboxes_aio_lite']);
     35        add_action('admin_notices', [$this, 'adminNoticesLite']);
     36        add_action('plugins_loaded', [$this, 'pluginInitLite']);
    3737
    3838        if (is_admin()) {
    39             add_action('save_post', array($this, 'aio_save_shift_meta_lite'));
     39            add_action('save_post', [$this, 'aio_save_shift_meta_lite']);
    4040        }
    4141
    4242        if (get_option('aio_timeclock_redirect_employees') == "enabled") {
    43             add_action('login_redirect', array($this, 'memberLoginRedirect'), 10, 3);
    44         }
    45 
    46         add_filter('post_row_actions', array($this, 'aio_remove_row_actions'), 10, 1);
     43            add_action('login_redirect', [$this, 'memberLoginRedirect'], 10, 3);
     44        }
     45
     46        add_filter('post_row_actions', [$this, 'aio_remove_row_actions'], 10, 1);
    4747
    4848        //Taxonomy
    49         add_action('init', array($this, 'aio_lite_register_user_taxonomy'));
    50         add_action('personal_options_update', array($this, 'aio_tc_lite_save_user_department_terms'));
    51         add_action('edit_user_profile_update', array($this, 'aio_tc_lite_save_user_department_terms'));
    52         add_action('admin_menu', array($this, 'aio_lite_add_department_admin_page'));
    53         add_action('show_user_profile', array($this, 'aio_lite_edit_user_department_section'));
    54         add_action('edit_user_profile', array($this, 'aio_lite_edit_user_department_section'));
    55         add_action('personal_options_update', array($this, 'aio_lite_save_user_department_terms'));
    56         add_action('edit_user_profile_update', array($this, 'aio_lite_save_user_department_terms'));
    57         add_action('manage_department_custom_column', array($this, 'aio_lite_manage_department_column', 10, 3));
    58 
    59         add_filter('manage_edit-departments_columns', array($this, 'aio_lite_manage_department_user_column'));
    60         add_filter('sanitize_user', array($this, 'aio_lite_disable_username'));
     49        add_action('init', [$this, 'aio_lite_register_user_taxonomy']);
     50        add_action('personal_options_update', [$this, 'aio_tc_lite_save_user_department_terms']);
     51        add_action('edit_user_profile_update', [$this, 'aio_tc_lite_save_user_department_terms']);
     52        add_action('admin_menu', [$this, 'aio_lite_add_department_admin_page']);
     53        add_action('show_user_profile', [$this, 'aio_lite_edit_user_department_section']);
     54        add_action('edit_user_profile', [$this, 'aio_lite_edit_user_department_section']);
     55        add_action('personal_options_update', [$this, 'aio_lite_save_user_department_terms']);
     56        add_action('edit_user_profile_update', [$this, 'aio_lite_save_user_department_terms']);
     57        add_action('manage_department_custom_column', [$this, 'aio_lite_manage_department_column', 10, 3]);
     58
     59        add_filter('manage_edit-departments_columns', [$this, 'aio_lite_manage_department_user_column']);
     60        add_filter('sanitize_user', [$this, 'aio_lite_disable_username']);
    6161
    6262        //Get the widgets
    63         if (!class_exists('AIO_Time_Clock_Lite_Widgets')) {
     63        if (! class_exists('AIO_Time_Clock_Lite_Widgets')) {
    6464            require_once plugin_dir_path(__FILE__) . 'aio-time-clock-lite-widgets.php';
    6565            $this->widgets = new AIO_Time_Clock_Lite_Widgets();
    66             add_action('widgets_init', array($this, 'loadWidgets'));
     66            add_action('widgets_init', [$this, 'loadWidgets']);
    6767        }
    6868
     
    7272    public function getVersion()
    7373    {
    74         return "1.3.325";
     74        return "1.3.326";
    7575    }
    7676
     
    8181            'manager',
    8282            esc_attr_x('Manager', 'aio-time-clock-lite'),
    83             array(
    84                 'read' => true,
    85                 'create_posts' => true,
    86                 'edit_posts' => true,
     83            [
     84                'read'              => true,
     85                'create_posts'      => true,
     86                'edit_posts'        => true,
    8787                'edit_others_posts' => true,
    88                 'publish_posts' => true,
     88                'publish_posts'     => true,
    8989                'manage_categories' => true,
    90             )
     90            ]
    9191        );
    9292
     
    9595            'volunteer',
    9696            esc_attr_x('Volunteer', 'aio-time-clock-lite'),
    97             array(
     97            [
    9898                'read' => true,
    99             )
     99            ]
    100100        );
    101101
     
    104104            'employee',
    105105            esc_attr_x('Employee', 'aio-time-clock-lite'),
    106             array(
     106            [
    107107                'read' => true,
    108             )
     108            ]
    109109        );
    110110
     
    113113            'time_clock_admin',
    114114            esc_attr_x('Time Clock Admin', 'aio-time-clock-lite'),
    115             array(
    116                 'read' => true, // Allows a user to read
    117                 'create_shifts' => true, // Allows user to create new posts
    118                 'edit_posts' => true, // Allows user to edit their own posts
    119                 'edit_shifts' => true, // Allows user to edit their own posts
    120                 'edit_others_posts' => true, // Allows user to edit others posts too
    121                 'edit_others_shifts' => true, // Allows user to edit others posts too
    122                 'publish_posts' => true, // Allows the user to publish posts
    123                 'publish_shifts' => true, // Allows the user to publish posts
    124                 'manage_categories' => true, // Allows user to manage post categories
    125                 'edit_private_posts' => true, // Allows user to manage post categories
    126                 'edit_private_shifts' => true, // Allows user to manage post categories
    127                 'read_private_posts' => true, // Allows user to manage post categories
    128                 'read_private_shifts' => true, // Allows user to manage post categories
    129                 'edit_published_posts' => true, // Allows user to manage post categories
     115            [
     116                'read'                  => true, // Allows a user to read
     117                'create_shifts'         => true, // Allows user to create new posts
     118                'edit_posts'            => true, // Allows user to edit their own posts
     119                'edit_shifts'           => true, // Allows user to edit their own posts
     120                'edit_others_posts'     => true, // Allows user to edit others posts too
     121                'edit_others_shifts'    => true, // Allows user to edit others posts too
     122                'publish_posts'         => true, // Allows the user to publish posts
     123                'publish_shifts'        => true, // Allows the user to publish posts
     124                'manage_categories'     => true, // Allows user to manage post categories
     125                'edit_private_posts'    => true, // Allows user to manage post categories
     126                'edit_private_shifts'   => true, // Allows user to manage post categories
     127                'read_private_posts'    => true, // Allows user to manage post categories
     128                'read_private_shifts'   => true, // Allows user to manage post categories
     129                'edit_published_posts'  => true, // Allows user to manage post categories
    130130                'edit_published_shifts' => true, // Allows user to manage post categories
    131             )
     131            ]
    132132        );
    133133    }
     
    140140    public function addMenuItem()
    141141    {
    142         $page_hook_suffix = add_menu_page('Time Clock Lite', 'Time Clock Lite', 'edit_posts', 'aio-tc-lite', array($this, 'settingsPageLite'), 'dashicons-clock');
    143         add_submenu_page('aio-tc-lite', esc_attr_x('Settings', 'aio-time-clock-lite'), esc_attr_x('Settings', 'aio-time-clock-lite'), 'edit_posts', 'aio-tc-lite', array($this, 'settingsPageLite'));
    144         add_submenu_page('aio-tc-lite', esc_attr_x('Real Time Monitoring', 'aio-time-clock-lite'), esc_attr_x('Real Time Monitoring', 'aio-time-clock-lite'), 'edit_posts', 'aio-monitoring-sub', array($this, 'montioringPage'));
    145         add_submenu_page('aio-tc-lite', esc_attr_x('Employees', 'aio-time-clock-lite'), esc_attr_x('Employees', 'aio-time-clock-lite'), 'edit_posts', 'aio-employees-sub', array($this, 'employeePage'));
    146         add_submenu_page('aio-tc-lite', esc_attr_x('Departments', 'aio-time-clock-lite'), esc_attr_x('Departments', 'aio-time-clock-lite'), 'edit_posts', 'aio-department-sub', array($this, 'departmentPage'));
    147         add_submenu_page('aio-tc-lite', esc_attr_x('Shifts', 'aio-time-clock-lite'), esc_attr_x('Shifts', 'aio-time-clock-lite'), 'edit_posts', 'aio-shifts-sub', array($this, 'shiftsPage'));
    148         add_submenu_page('aio-tc-lite', esc_attr_x('Reports', 'aio-time-clock-lite'), esc_attr_x('Reports', 'aio-time-clock-lite'), 'edit_posts', 'aio-reports-sub', array($this, 'reportsPageLite'));
     142        $page_hook_suffix = add_menu_page('Time Clock Lite', 'Time Clock Lite', 'edit_posts', 'aio-tc-lite', [$this, 'settingsPageLite'], 'dashicons-clock');
     143        add_submenu_page('aio-tc-lite', esc_attr_x('Settings', 'aio-time-clock-lite'), esc_attr_x('Settings', 'aio-time-clock-lite'), 'edit_posts', 'aio-tc-lite', [$this, 'settingsPageLite']);
     144        add_submenu_page('aio-tc-lite', esc_attr_x('Real Time Monitoring', 'aio-time-clock-lite'), esc_attr_x('Real Time Monitoring', 'aio-time-clock-lite'), 'edit_posts', 'aio-monitoring-sub', [$this, 'montioringPage']);
     145        add_submenu_page('aio-tc-lite', esc_attr_x('Employees', 'aio-time-clock-lite'), esc_attr_x('Employees', 'aio-time-clock-lite'), 'edit_posts', 'aio-employees-sub', [$this, 'employeePage']);
     146        add_submenu_page('aio-tc-lite', esc_attr_x('Departments', 'aio-time-clock-lite'), esc_attr_x('Departments', 'aio-time-clock-lite'), 'edit_posts', 'aio-department-sub', [$this, 'departmentPage']);
     147        add_submenu_page('aio-tc-lite', esc_attr_x('Shifts', 'aio-time-clock-lite'), esc_attr_x('Shifts', 'aio-time-clock-lite'), 'edit_posts', 'aio-shifts-sub', [$this, 'shiftsPage']);
     148        add_submenu_page('aio-tc-lite', esc_attr_x('Reports', 'aio-time-clock-lite'), esc_attr_x('Reports', 'aio-time-clock-lite'), 'edit_posts', 'aio-reports-sub', [$this, 'reportsPageLite']);
    149149    }
    150150
     
    158158
    159159        //Scripts
    160         wp_enqueue_script('aio_time_clock_lite_js', plugins_url('/js/time-clock-lite.js', __FILE__), array('jquery'), $this->getVersion());
     160        wp_enqueue_script('aio_time_clock_lite_js', plugins_url('/js/time-clock-lite.js', __FILE__), ['jquery'], $this->getVersion());
    161161        wp_enqueue_script('jquery');
    162         wp_enqueue_script('nert-aio-timepicker', plugins_url('js/jquery.datetimepicker.js', __FILE__), array('jquery'));
     162        wp_enqueue_script('nert-aio-timepicker', plugins_url('js/jquery.datetimepicker.js', __FILE__), ['jquery']);
    163163        wp_enqueue_script('aio_time_clock_lite_js');
    164         wp_localize_script('aio_time_clock_lite_js',
     164        wp_localize_script(
     165            'aio_time_clock_lite_js',
    165166            'timeClockAjax',
    166167            $this->getTranslationStrings()
     
    177178        wp_enqueue_style('aio-tc-admin-style');
    178179        wp_enqueue_style('aio-tc-lite-steps-style');
     180        wp_register_style('aio_time_clock_jquery_ui', plugins_url('css/jquery-ui-1.8.23.css', __FILE__));
     181        wp_enqueue_style('aio_time_clock_jquery_ui');
     182        wp_register_style('aio_time_clock_toastr_style', plugins_url('css/toastr.min.css', __FILE__));
     183        wp_enqueue_style('aio_time_clock_toastr_style');
     184        wp_register_style('aio_time_clock_swal_style', plugins_url('css/sweetalert2.min.css', __FILE__));
     185        wp_enqueue_style('aio_time_clock_swal_style');
    179186
    180187        //Scripts
    181188        wp_enqueue_script('jquery');
    182         wp_register_script("aio_time_clock_lite_steps", plugins_url('/js/jquery.steps.min.js', __FILE__), array('jquery'));
    183         wp_enqueue_script('aio_time_clock_lite_admin_js', plugins_url('/js/time-clock-lite-admin.js', __FILE__), array('jquery'), $this->getVersion());
    184         wp_enqueue_script('nert-aio-timepicker', plugins_url('js/jquery.datetimepicker.js', __FILE__), array('jquery'));
     189        wp_enqueue_script('jquery-effects-core');
     190        wp_enqueue_script('jquery-ui-core');
     191        wp_enqueue_script('aio_time_clock_toastr_js', plugins_url('js/toastr.min.js', __FILE__), ['jquery', 'jquery-effects-core', 'jquery-ui-core'], $this->getVersion());
     192        wp_enqueue_script('aio_time_clock_swal_js', plugins_url('js/sweetalert2.min.js', __FILE__), ['jquery', 'jquery-effects-core', 'jquery-ui-core'], $this->getVersion());
     193        wp_register_script("aio_time_clock_lite_steps", plugins_url('/js/jquery.steps.min.js', __FILE__), ['jquery']);
     194        wp_enqueue_script('aio_time_clock_lite_admin_js', plugins_url('/js/time-clock-lite-admin.js', __FILE__), ['jquery'], $this->getVersion());
     195        wp_enqueue_script('nert-aio-timepicker', plugins_url('js/jquery.datetimepicker.js', __FILE__), ['jquery']);
    185196        wp_enqueue_script('aio_time_clock_lite_admin_js');
    186197        wp_enqueue_script('aio_time_clock_lite_steps');
    187198
    188         wp_localize_script('aio_time_clock_lite_admin_js',
     199        wp_localize_script(
     200            'aio_time_clock_lite_admin_js',
    189201            'timeClockAdminAjax',
    190202            $this->getTranslationStrings()
     
    229241    {
    230242        $tc_page = $this->aio_check_tc_shortcode_lite();
    231         $nonce = wp_create_nonce("clock_in_nonce");
    232         $link = admin_url('admin-ajax.php?action=clock_in_nonce&post_id=' . get_the_ID() . '&nonce=' . esc_attr($nonce));
     243        $nonce   = wp_create_nonce("time-clock-nonce");
     244        $link    = admin_url('admin-ajax.php?action=time-clock-nonce&post_id=' . get_the_ID() . '&nonce=' . esc_attr($nonce));
    233245        require_once "templates/time-clock-style1.php";
    234246    }
     
    237249    {
    238250        $ep_page = $this->check_eprofile_shortcode_lite();
    239         $nonce = wp_create_nonce("clock_in_nonce");
    240         $link = admin_url('admin-ajax.php?action=clock_in_nonce&post_id=' . get_the_ID() . '&nonce=' . esc_attr($nonce));
     251        $nonce   = wp_create_nonce("time-clock-nonce");
     252        $link    = admin_url('admin-ajax.php?action=time-clock-nonce&post_id=' . get_the_ID() . '&nonce=' . esc_attr($nonce));
    241253        require_once "aio-employee-profile.php";
    242254    }
     
    245257    {
    246258        global $current_user;
    247         $clock_action = (isset($_POST["clock_action"])) ? sanitize_text_field($_POST["clock_action"]) : null;
    248         $employee_clock_in_time = null;
     259        $clock_action            = (isset($_POST["clock_action"])) ? sanitize_text_field($_POST["clock_action"]) : null;
     260        $employee_clock_in_time  = null;
    249261        $employee_clock_out_time = null;
    250         $is_clocked_in = false;
    251         $open_shift_id = (isset($_POST["open_shift_id"])) ? intval($_POST["open_shift_id"]) : null;
    252         $new_shift_created = false;       
    253         $employee =(isset($_POST["employee"])) ? intval($_POST["employee"]) : intval($current_user->ID);
    254         $message = null;
    255         $time_total = strtotime(0);
    256 
    257         if ($clock_action == "check_shifts") {
    258             $found_shift_id = null;
    259             $args = array(
    260                 'post_type' => 'shift',
    261                 'orderby' => 'ID'
    262             );
    263 
    264             $query = new WP_Query($args);
    265 
    266             if ($query->have_posts()) {
    267                 while ($query->have_posts()) {
    268                     $query->the_post();
    269                     $custom = get_post_custom($query->post->ID);
    270                     $author_id = get_post_field('post_author', $query->post->ID);
    271                     $employee_clock_in_time = (isset($custom["employee_clock_in_time"][0])) ? sanitize_text_field($custom["employee_clock_in_time"][0]) : null;
    272                     $employee_clock_out_time = (isset($custom["employee_clock_out_time"][0])) ? sanitize_text_field($custom["employee_clock_out_time"][0]) :  null;
    273                     if ($employee_clock_in_time != null && $employee_clock_out_time == null && $employee == $author_id) {
    274                         $found_shift_id = $query->post->ID;
    275                         $is_clocked_in = true;
    276                         break;
     262        $is_clocked_in           = false;
     263        $open_shift_id           = (isset($_POST["open_shift_id"])) ? intval($_POST["open_shift_id"]) : null;
     264        $new_shift_created       = false;
     265        $employee                = (isset($_POST["employee"])) ? intval($_POST["employee"]) : intval($current_user->ID);
     266        $nonce                   = (isset($_POST["nonce"])) ? $_POST["nonce"] : null;
     267        $message                 = "";
     268        $response_html           = "";
     269        $time_total              = strtotime(0);
     270
     271        if (wp_verify_nonce($nonce, 'time-clock-nonce')) {
     272
     273            if ($clock_action == "check_shifts") {
     274                $found_shift_id = null;
     275                $args           = [
     276                    'post_type' => 'shift',
     277                    'orderby'   => 'ID',
     278                ];
     279
     280                $query = new WP_Query($args);
     281
     282                if ($query->have_posts()) {
     283                    while ($query->have_posts()) {
     284                        $query->the_post();
     285                        $custom                  = get_post_custom($query->post->ID);
     286                        $author_id               = get_post_field('post_author', $query->post->ID);
     287                        $employee_clock_in_time  = (isset($custom["employee_clock_in_time"][0])) ? sanitize_text_field($custom["employee_clock_in_time"][0]) : null;
     288                        $employee_clock_out_time = (isset($custom["employee_clock_out_time"][0])) ? sanitize_text_field($custom["employee_clock_out_time"][0]) : null;
     289                        if ($employee_clock_in_time != null && $employee_clock_out_time == null && $employee == $author_id) {
     290                            $found_shift_id = $query->post->ID;
     291                            $is_clocked_in  = true;
     292                            break;
     293                        }
    277294                    }
    278295                }
     296
     297                echo json_encode(
     298                    [
     299                        "response"                => "success",
     300                        "message"                 => $message,
     301                        "employee"                => $employee,
     302                        "clock_action"            => $clock_action,
     303                        "is_clocked_in"           => $is_clocked_in,
     304                        "open_shift_id"           => $found_shift_id,
     305                        "employee_clock_in_time"  => (($employee_clock_in_time != null) ? $this->cleanDate($employee_clock_in_time) : null),
     306                        "employee_clock_out_time" => (($employee_clock_in_time != null) ? $this->cleanDate($employee_clock_out_time) : null),
     307                    ]
     308                );
     309            } elseif ($clock_action == "clock_in") {
     310                $device_time  = (isset($_POST["device_time"])) ? sanitize_text_field($_POST["device_time"]) : null;
     311                $current_time = $this->getCurrentTime();
     312
     313                $aio_new_shift = [
     314                    'post_type'   => 'shift',
     315                    'post_title'  => 'Employee Shift',
     316                    'post_status' => 'publish',
     317                    'post_author' => $employee,
     318                ];
     319                $new_post_id = wp_insert_post($aio_new_shift);
     320                $department  = "";
     321                $terms       = get_the_terms($current_user->ID, 'department');
     322                if (! empty($terms)) {
     323                    foreach ($terms as $term) {
     324                        $department = $term->name;
     325                    }
     326                }
     327                update_post_meta($new_post_id, 'employee_clock_in_time', sanitize_text_field($current_time["current_time"]));
     328                update_post_meta($new_post_id, 'employee_clock_out_time', null);
     329                if ($department != null) {
     330                    add_post_meta($new_post_id, 'department', $department, true);
     331                }
     332                add_post_meta($new_post_id, 'ip_address_in', sanitize_text_field($_SERVER['REMOTE_ADDR']), true);
     333                $open_shift_id = $new_post_id;
     334                $is_clocked_in = true;
     335
     336                echo json_encode(
     337                    [
     338                        "response"                => "success",
     339                        "message"                 => $message,
     340                        "employee"                => $employee,
     341                        "open_shift_id"           => $open_shift_id,
     342                        "clock_action"            => $clock_action,
     343                        "is_clocked_in"           => $is_clocked_in,
     344                        "employee_clock_in_time"  => $this->cleanDate(sanitize_text_field($current_time["current_time"])),
     345                        "employee_clock_out_time" => null,
     346                    ]
     347                );
     348            } elseif ($clock_action == "clock_out") {
     349                $device_time            = isset($_POST["device_time"]) ? sanitize_text_field($_POST["device_time"]) : null;
     350                $current_time           = $this->getCurrentTime();
     351                $is_clocked_in          = false;
     352                $employee_clock_in_time = get_post_meta($open_shift_id, 'employee_clock_in_time', true);
     353                update_post_meta($open_shift_id, 'employee_clock_out_time', sanitize_text_field($current_time["current_time"]));
     354                add_post_meta($open_shift_id, 'ip_address_out', sanitize_text_field($_SERVER['REMOTE_ADDR']), true);
     355                $shift_sum  = $this->dateDifference($employee_clock_in_time, sanitize_text_field($current_time["current_time"]));
     356                $time_total = $shift_sum;
     357
     358                echo json_encode(
     359                    [
     360                        "response"                => "success",
     361                        "message"                 => $message,
     362                        "employee"                => $employee,
     363                        "clock_action"            => $clock_action,
     364                        "employee_clock_in_time"  => $this->cleanDate($employee_clock_in_time),
     365                        "employee_clock_out_time" => $this->cleanDate(sanitize_text_field($current_time["current_time"])),
     366                        "time_total"              => $this->secondsToTime($time_total),
     367                        "is_clocked_in"           => $is_clocked_in,
     368                    ]
     369                );
     370            } else {
     371                echo json_encode(
     372                    [
     373                        "response"     => "failed",
     374                        "message"      => esc_attr_x("action does not exist", 'aio-time-clock-lite'),
     375                        "employee"     => $employee,
     376                        "clock_action" => $clock_action,
     377                    ]
     378                );
    279379            }
    280 
    281             echo json_encode(
    282                 array(
    283                     "response" => "success",
    284                     "message" => $message,
    285                     "employee" => $employee,
    286                     "clock_action" => $clock_action,
    287                     "is_clocked_in" => $is_clocked_in,
    288                     "open_shift_id" => $found_shift_id,
    289                     "employee_clock_in_time" => (($employee_clock_in_time != null) ? $this->cleanDate($employee_clock_in_time) : null),
    290                     "employee_clock_out_time" => (($employee_clock_in_time != null) ? $this->cleanDate($employee_clock_out_time) : null),
    291                 )
    292             );
    293         } elseif ($clock_action == "clock_in") {
    294             $device_time = (isset($_POST["device_time"])) ? sanitize_text_field($_POST["device_time"]) : null;           
    295             $current_time = $this->getCurrentTime();
    296 
    297             $aio_new_shift = array(
    298                 'post_type' => 'shift',
    299                 'post_title' => 'Employee Shift',
    300                 'post_status' => 'publish',
    301                 'post_author' => $employee,
    302             );
    303             $new_post_id = wp_insert_post($aio_new_shift);
    304             $department = "";
    305             $terms = get_the_terms($current_user->ID, 'department');
    306             if (!empty($terms)) {
    307                 foreach ($terms as $term) {
    308                     $department = $term->name;
    309                 }
    310             }
    311             update_post_meta($new_post_id, 'employee_clock_in_time', sanitize_text_field($current_time["current_time"]));
    312             update_post_meta($new_post_id, 'employee_clock_out_time', null);
    313             if ($department != null) {
    314                 add_post_meta($new_post_id, 'department', $department, true);
    315             }
    316             add_post_meta($new_post_id, 'ip_address_in', sanitize_text_field($_SERVER['REMOTE_ADDR']), true);
    317             $open_shift_id = $new_post_id;
    318             $is_clocked_in = true;
    319 
    320             echo json_encode(
    321                 array(
    322                     "response" => "success",
    323                     "message" => $message,
    324                     "employee" => $employee,
    325                     "open_shift_id" => $open_shift_id,
    326                     "clock_action" => $clock_action,
    327                     "is_clocked_in" => $is_clocked_in,
    328                     "employee_clock_in_time" => $this->cleanDate(sanitize_text_field($current_time["current_time"])),
    329                     "employee_clock_out_time" => null,
    330                 )
    331             );
    332         } elseif ($clock_action == "clock_out") {
    333             $device_time = isset($_POST["device_time"]) ? sanitize_text_field($_POST["device_time"]) : null;
    334             $current_time = $this->getCurrentTime();
    335             $is_clocked_in = false;
    336             $employee_clock_in_time = get_post_meta($open_shift_id, 'employee_clock_in_time', true);
    337             update_post_meta($open_shift_id, 'employee_clock_out_time', sanitize_text_field($current_time["current_time"]));
    338             add_post_meta($open_shift_id, 'ip_address_out', sanitize_text_field($_SERVER['REMOTE_ADDR']), true);
    339             $shift_sum = $this->dateDifference($employee_clock_in_time, sanitize_text_field($current_time["current_time"]));
    340             $time_total = $shift_sum;
    341 
    342             echo json_encode(
    343                 array(
    344                     "response" => "success",
    345                     "message" => $message,
    346                     "employee" => $employee,
    347                     "clock_action" => $clock_action,
    348                     "employee_clock_in_time" => $this->cleanDate($employee_clock_in_time),
    349                     "employee_clock_out_time" => $this->cleanDate(sanitize_text_field($current_time["current_time"])),
    350                     "time_total" => $this->secondsToTime($time_total),
    351                     "is_clocked_in" => $is_clocked_in,
    352                 )
    353             );
    354380        } else {
    355381            echo json_encode(
    356                 array(
    357                     "response" => "failed",
    358                     "message" => esc_attr_x("action does not exist", 'aio-time-clock-lite'),
    359                     "employee" => $employee,
     382                [
     383                    "response"     => "failed",
     384                    "message"      => esc_attr_x("Not authorized to perform this action", 'aio-time-clock-lite'),
     385                    "nonce"        => $nonce,
    360386                    "clock_action" => $clock_action,
    361                 )
     387                ]
    362388            );
    363389        }
     
    370396    {
    371397        if ($seconds != null) {
    372             $dtF = new DateTime('@0');
    373             $dtT = new DateTime("@$seconds");
    374             $days = $dtF->diff($dtT)->format('%D');
    375             $hours = $dtF->diff($dtT)->format('%H');
     398            $dtF     = new DateTime('@0');
     399            $dtT     = new DateTime("@$seconds");
     400            $days    = $dtF->diff($dtT)->format('%D');
     401            $hours   = $dtF->diff($dtT)->format('%H');
    376402            $minutes = $dtF->diff($dtT)->format('%I');
    377             $hours = $hours + ($days * 24);
     403            $hours   = $hours + ($days * 24);
    378404            return $hours . ":" . $minutes;
    379405        } else {
     
    385411    {
    386412        global $current_user;
    387         $report_action = isset($_POST["report_action"]) ? sanitize_text_field($_POST["report_action"]) : null;
    388         $employee = isset($_POST["employee"]) ? intval($_POST["employee"]) : intval($current_user->ID);
     413        $admin_action     = isset($_POST["admin_action"]) ? sanitize_text_field($_POST["admin_action"]) : null;
     414        $report_action    = isset($_POST["report_action"]) ? sanitize_text_field($_POST["report_action"]) : null;
     415        $nonce            = isset($_POST["nonce"]) ? $_POST["nonce"] : null;
     416        $message          = "";
     417        $response_html    = "";
     418        $employee         = isset($_POST["employee"]) ? intval($_POST["employee"]) : intval($current_user->ID);
    389419        $date_range_start = date($this->mysqlDateFormat, strtotime(sanitize_text_field($_POST["aio_pp_start_date"])));
    390         $date_range_end = date($this->mysqlDateFormat, strtotime(sanitize_text_field($_POST["aio_pp_end_date"])));
    391         $errors = null;
    392 
    393         if ($report_action != null) {
    394             echo json_encode(
    395                 array(
    396                     "response" => "success",
    397                     "employee" => $employee,
    398                     "date_range_start" => $date_range_start,
    399                     "date_range_end" => $date_range_end,
    400                     "report_action" => $report_action,
    401                     "shifts" =>
    402                     $this->getShiftTotalFromRange(
    403                         $employee,
    404                         $date_range_start,
    405                         $date_range_end
    406                     ),
    407                 )
    408             );
     420        $date_range_end   = date($this->mysqlDateFormat, strtotime(sanitize_text_field($_POST["aio_pp_end_date"])));
     421        $errors           = null;
     422
     423        if (wp_verify_nonce($nonce, 'time-clock-nonce')) {
     424            if ($admin_action == "create_timeclock_page") {
     425                $tc_page = $this->aio_check_tc_shortcode_lite();
     426                if ($tc_page == null) {
     427                    $my_post = [
     428                        'post_type'      => 'page',
     429                        'post_title'     => 'Time Clock',
     430                        'post_status'    => 'publish',
     431                        'post_content'   => '[show_aio_time_clock_lite]',
     432                        'comment_status' => 'closed',
     433                        'post_author'    => $employee,
     434                    ];
     435                    // Insert the post into the database
     436                    $new_page_id = wp_insert_post($my_post);
     437                }
     438
     439                if ($new_page_id != null) {
     440                    $message = esc_attr_x('TimeClock Page Created Sucessfully', 'aio-time-clock-lite');
     441                    $response_html .= '<a href="' . esc_url(get_permalink($new_page_id)) . '" class="button small_button" target="_blank"><i class="dashicons dashicons-search vmiddle"></i>' . esc_attr_x('View Page', 'aio-time-clock-lite') . '</a>';
     442                } else {
     443                    if ($tc_page != null) {
     444                        $message = esc_attr_x('You already have a TimeClock page created', 'aio-time-clock-lite');
     445                        $response_html .= '<a href="' . esc_url(get_permalink($tc_page)) . '" class="button small_button" target="_blank"><i class="dashicons dashicons-search vmiddle"></i>' . esc_attr_x('View Page', 'aio-time-clock-lite') . '</a>';
     446                    }
     447                }
     448
     449                if ($new_page_id != null) {
     450                    echo json_encode(
     451                        [
     452                            "response"      => "success",
     453                            "message"       => $message,
     454                            "response_html" => $response_html,
     455                            "nonce"         => $nonce,
     456                            "admin_action"  => $admin_action,
     457                            "page_id"       => $new_page_id,
     458                            'link'          => esc_url(get_permalink($new_page_id)),
     459                        ]
     460                    );
     461                } else if ($tc_page != null) {
     462                    echo json_encode(
     463                        [
     464                            "response"      => "failed",
     465                            "message"       => $message,
     466                            "response_html" => $response_html,
     467                            "nonce"         => $nonce,
     468                            "admin_action"  => $admin_action,
     469                            'link'          => esc_url(get_permalink($tc_page)),
     470                        ]
     471                    );
     472                } else {
     473                    echo json_encode(
     474                        [
     475                            "response"      => "failed",
     476                            "message"       => $message,
     477                            "response_html" => $response_html,
     478                            "nonce"         => $nonce,
     479                            "admin_action"  => $admin_action,
     480                        ]
     481                    );
     482                }
     483            } elseif ($admin_action == "create_eprofile_page") {
     484                $eprofile_page = $this->check_eprofile_shortcode_lite();
     485                if ($eprofile_page == null) {
     486                    $my_post = [
     487                        'post_type'      => 'page',
     488                        'post_title'     => 'Employee Profile',
     489                        'post_status'    => 'publish',
     490                        'post_content'   => '[show_aio_employee_profile_lite]',
     491                        'comment_status' => 'closed',
     492                        'post_author'    => $employee,
     493                    ];
     494                    $new_eprofile_id = wp_insert_post($my_post);
     495                }
     496
     497                if ($new_eprofile_id != null) {
     498                    $message .= esc_attr_x('Employee profile created successfully', 'aio-time-clock-lite');
     499                    $response_html .= '<a href="' . esc_url(get_permalink($new_eprofile_id)) . '" class="button small_button" target="_blank"><i class="dashicons dashicons-search vmiddle"></i>' . esc_attr_x('View Profile', 'aio-time-clock-lite') . '</a>';
     500                } else {
     501                    if ($eprofile_page != null) {
     502                        $message .= esc_attr_x('You already have a Employee Profile page created', 'aio-time-clock-lite');
     503                        $response_html .= '<a href="' . esc_url(get_permalink($eprofile_page)) . '" class="button small_button" target="_blank"><i class="dashicons dashicons-search vmiddle"></i>' . esc_attr_x('View Profile', 'aio-time-clock-lite') . '</a>';
     504                    }
     505                }
     506
     507                if ($new_eprofile_id != null) {
     508                    echo json_encode(
     509                        [
     510                            "response"      => "success",
     511                            "message"       => $message,
     512                            "response_html" => $response_html,
     513                            "nonce"         => $nonce,
     514                            "admin_action"  => $admin_action,
     515                            "page_id"       => $new_eprofile_id,
     516                            'link'          => esc_url(get_permalink($new_eprofile_id)),
     517                        ]
     518                    );
     519                } else if ($eprofile_page != null) {
     520                    echo json_encode(
     521                        [
     522                            "response"      => "failed",
     523                            "message"       => $message,
     524                            "response_html" => $response_html,
     525                            "nonce"         => $nonce,
     526                            "admin_action"  => $admin_action,
     527                            "page_id"       => $eprofile_page,
     528                            "link"          => esc_url(get_permalink($eprofile_page)),
     529                        ]
     530                    );
     531                } else {
     532                    echo json_encode(
     533                        [
     534                            "response"      => "failed",
     535                            "message"       => $message,
     536                            "response_html" => $response_html,
     537                            "nonce"         => $nonce,
     538                        ]
     539                    );
     540                }
     541            } else if ($admin_action == "report") {
     542                if ($report_action != null) {
     543                    echo json_encode(
     544                        [
     545                            "response"         => "success",
     546                            "employee"         => $employee,
     547                            "date_range_start" => $date_range_start,
     548                            "date_range_end"   => $date_range_end,
     549                            "report_action"    => $report_action,
     550                            "shifts"           =>
     551                            $this->getShiftTotalFromRange(
     552                                $employee,
     553                                $date_range_start,
     554                                $date_range_end
     555                            ),
     556                        ]
     557                    );
     558                } else {
     559                    echo json_encode(
     560                        [
     561                            "response"         => "failed",
     562                            "employee"         => $employee,
     563                            "date_range_start" => $date_range_start,
     564                            "date_range_end"   => $date_range_end,
     565                            "message"          => esc_attr_x("report action cannot be null", "aio-time-clock"),
     566                            "errors"           => $errors,
     567                        ]
     568                    );
     569                }
     570            } else {
     571                echo json_encode(
     572                    [
     573                        "response"     => "failed",
     574                        "message"      => esc_attr_x("action does not exist", 'aio-time-clock-lite'),
     575                        "employee"     => $employee,
     576                        "admin_action" => $admin_action,
     577                    ]
     578                );
     579            }
    409580        } else {
    410581            echo json_encode(
    411                 array(
    412                     "response" => "failed",
    413                     "employee" => $employee,
    414                     "date_range_start" => $date_range_start,
    415                     "date_range_end" => $date_range_end,
    416                     "message" => esc_attr_x("report action cannot be null", "aio-time-clock"),
    417                     "errors" => $errors,
    418                 )
     582                [
     583                    "response"     => "failed",
     584                    "message"      => esc_attr_x("Not authorized to perform this action", 'aio-time-clock-lite'),
     585                    "nonce"        => $nonce,
     586                    "admin_action" => $admin_action,
     587                ]
    419588            );
    420589        }
     
    425594    public function aio_tc_custom_post_shift_lite()
    426595    {
    427         $labels = array(
    428             'name' => esc_attr_x('Shifts', 'aio-time-clock-lite'),
    429             'singular_name' => esc_attr_x('Shift', 'aio-time-clock-lite'),
    430             'add_new' => esc_attr_x('Add New', 'shift', 'aio-time-clock-lite'),
    431             'add_new_item' => esc_attr_x('Clock Out', 'aio-time-clock-lite'),
    432             'edit_item' => esc_attr_x('Edit Shift', 'aio-time-clock-lite'),
    433             'new_item' => esc_attr_x('Clock In', 'aio-time-clock-lite'),
    434             'all_items' => esc_attr_x('All Shifts', 'aio-time-clock-lite'),
    435             'view_item' => esc_attr_x('View Shift', 'aio-time-clock-lite'),
    436             'search_items' => esc_attr_x('Search Shifts', 'aio-time-clock-lite'),
    437             'not_found' => esc_attr_x('No shifts found', 'aio-time-clock-lite'),
     596        $labels = [
     597            'name'               => esc_attr_x('Shifts', 'aio-time-clock-lite'),
     598            'singular_name'      => esc_attr_x('Shift', 'aio-time-clock-lite'),
     599            'add_new'            => esc_attr_x('Add New', 'shift', 'aio-time-clock-lite'),
     600            'add_new_item'       => esc_attr_x('Clock Out', 'aio-time-clock-lite'),
     601            'edit_item'          => esc_attr_x('Edit Shift', 'aio-time-clock-lite'),
     602            'new_item'           => esc_attr_x('Clock In', 'aio-time-clock-lite'),
     603            'all_items'          => esc_attr_x('All Shifts', 'aio-time-clock-lite'),
     604            'view_item'          => esc_attr_x('View Shift', 'aio-time-clock-lite'),
     605            'search_items'       => esc_attr_x('Search Shifts', 'aio-time-clock-lite'),
     606            'not_found'          => esc_attr_x('No shifts found', 'aio-time-clock-lite'),
    438607            'not_found_in_trash' => esc_attr_x('No shifts found in the Trash', 'aio-time-clock-lite'),
    439             'parent_item_colon' => '',
    440             'menu_name' => esc_attr_x('Employee Shifts', 'aio-time-clock-lite'),
    441         );
    442         $args = array(
    443             'labels' => $labels,
    444             'description' => esc_attr_x('Employee shifts dates and times', 'aio-time-clock-lite'),
    445             'query_var' => true,
    446             'public' => false,
    447             'show_ui' => true,
    448             'supports' => array('title', 'author'),
    449             'has_archive' => true,
    450             'show_tagcloud' => false,
    451             'rewrite' => array('slug' => 'shifts'),
     608            'parent_item_colon'  => '',
     609            'menu_name'          => esc_attr_x('Employee Shifts', 'aio-time-clock-lite'),
     610        ];
     611        $args = [
     612            'labels'            => $labels,
     613            'description'       => esc_attr_x('Employee shifts dates and times', 'aio-time-clock-lite'),
     614            'query_var'         => true,
     615            'public'            => false,
     616            'show_ui'           => true,
     617            'supports'          => ['title', 'author'],
     618            'has_archive'       => true,
     619            'show_tagcloud'     => false,
     620            'rewrite'           => ['slug' => 'shifts'],
    452621            'show_in_nav_menus' => false,
    453             'supports' => false,
    454         );
     622            'supports'          => false,
     623        ];
    455624        register_post_type('shift', $args);
    456625    }
     
    458627    public function aio_timeclock_admin_init_lite()
    459628    {
    460         add_filter('manage_edit-shift_columns', array($this, 'shiftColumnsFilter'), 10, 1);
    461         add_action('manage_shift_posts_custom_column', array($this, 'shiftColumn'), 10, 2);
     629        add_filter('manage_edit-shift_columns', [$this, 'shiftColumnsFilter'], 10, 1);
     630        add_action('manage_shift_posts_custom_column', [$this, 'shiftColumn'], 10, 2);
    462631    }
    463632
     
    466635        unset($columns['date']);
    467636        unset($columns['author']);
    468         $columns['employee'] = esc_attr_x('Employee', 'aio-time-clock-lite');
    469         $columns['department'] = esc_attr_x('Department', 'aio-time-clock-lite');
    470         $columns['employee_clock_in_time'] = esc_attr_x('Clock In Time', 'aio-time-clock-lite');
     637        $columns['employee']                = esc_attr_x('Employee', 'aio-time-clock-lite');
     638        $columns['department']              = esc_attr_x('Department', 'aio-time-clock-lite');
     639        $columns['employee_clock_in_time']  = esc_attr_x('Clock In Time', 'aio-time-clock-lite');
    471640        $columns['employee_clock_out_time'] = esc_attr_x('Clock Out Time', 'aio-time-clock-lite');
    472         $columns['total_shift_time'] = esc_attr_x('Total Time', 'aio-time-clock-lite');
     641        $columns['total_shift_time']        = esc_attr_x('Total Time', 'aio-time-clock-lite');
    473642        return $columns;
    474643    }
     
    477646    {
    478647        global $post;
    479         $custom = get_post_custom($post_id);
    480         $employee_clock_in_time = isset($custom['employee_clock_in_time'][0]) ? $this->cleanDate(sanitize_text_field($custom['employee_clock_in_time'][0])) : null;
     648        $custom                  = get_post_custom($post_id);
     649        $employee_clock_in_time  = isset($custom['employee_clock_in_time'][0]) ? $this->cleanDate(sanitize_text_field($custom['employee_clock_in_time'][0])) : null;
    481650        $employee_clock_out_time = isset($custom['employee_clock_out_time'][0]) ? $this->cleanDate(sanitize_text_field($custom['employee_clock_out_time'][0])) : null;
    482         $shift_sum = "00:00";
     651        $shift_sum               = "00:00";
    483652        if ($employee_clock_in_time != null && $employee_clock_out_time != null) {
    484653            $shift_sum = $this->secondsToTime($this->dateDifference($employee_clock_in_time, $employee_clock_out_time));
     
    512681        global $wordpress;
    513682
    514         $terms = get_terms('department', array('hide_empty' => false));
    515 
    516         if (!empty($terms)) {
     683        $terms = get_terms('department', ['hide_empty' => false]);
     684
     685        if (! empty($terms)) {
    517686            foreach ($terms as $term) {
    518687                if (is_object_in_term(intval($author_id), 'department', $term)) {
     
    527696    public function getShiftTotal($post_id)
    528697    {
    529         $employee_clock_in_time = get_post_meta($post_id, 'employee_clock_in_time', true);
     698        $employee_clock_in_time  = get_post_meta($post_id, 'employee_clock_in_time', true);
    530699        $employee_clock_out_time = get_post_meta($post_id, 'employee_clock_out_time', true);
    531         $total_shift_time = strtotime(0);
     700        $total_shift_time        = strtotime(0);
    532701        if ($employee_clock_in_time != null && $employee_clock_out_time != null) {
    533702            if (strtotime($employee_clock_in_time) > strtotime(0) && strtotime($employee_clock_out_time) > strtotime(0)) {
     
    544713            'shift_info_box',
    545714            esc_attr_x('Shift Info', 'aio-time-clock-lite'),
    546             array($this, 'aio_shift_info_box_content'),
     715            [$this, 'aio_shift_info_box_content'],
    547716            'shift',
    548717            'normal',
     
    553722    public function aio_shift_info_box_content()
    554723    {
    555         require_once("aio-time-clock-box-content.php");
     724        require_once "aio-time-clock-box-content.php";
    556725    }
    557726
     
    559728    {
    560729        $selected = json_decode($selected);
    561         $count = 0;
    562         $users = $this->getUsers();
     730        $count    = 0;
     731        $users    = $this->getUsers();
    563732        foreach ($users as $user) {
    564733            $active = "";
     
    566735                $active = "selected";
    567736            }
    568             $user_id = isset($user["employee_id"]) ? intval($user["employee_id"]) : 0;
     737            $user_id    = isset($user["employee_id"]) ? intval($user["employee_id"]) : 0;
    569738            $user_first = isset($user["first_name"]) ? sanitize_text_field($user["first_name"]) : "";
    570             $user_last = isset($user["last_name"]) ? sanitize_text_field($user["last_name"]) : "";
     739            $user_last  = isset($user["last_name"]) ? sanitize_text_field($user["last_name"]) : "";
    571740            echo '<option value="' . esc_attr($user_id) . '" ' . esc_attr($active) . '>' . esc_attr($user_first) . ", " . esc_attr($user_last) . '</option>';
    572741            $count++;
     
    576745    public function getBuiltInRoles()
    577746    {
    578         return array('aio_tc_employee', 'aio_tc_manager', 'time_clock_admin', 'aio_tc_volunteer', 'aio_tc_contractor', 'employee', 'manager', 'volunteer', 'contractor', 'administrator');
     747        return ['aio_tc_employee', 'aio_tc_manager', 'time_clock_admin', 'aio_tc_volunteer', 'aio_tc_contractor', 'employee', 'manager', 'volunteer', 'contractor', 'administrator'];
    579748    }
    580749
     
    587756    public function aio_save_shift_meta_lite($post_id)
    588757    {
    589         $clock_in = (isset($_REQUEST['clock_in'])) ? sanitize_text_field($_REQUEST['clock_in']) : null;
     758        $clock_in  = (isset($_REQUEST['clock_in'])) ? sanitize_text_field($_REQUEST['clock_in']) : null;
    590759        $clock_out = (isset($_REQUEST['clock_out'])) ? sanitize_text_field($_REQUEST['clock_out']) : null;
    591760
    592         if ($clock_in != null){
     761        if ($clock_in != null) {
    593762            $clock_in = str_replace("/", "-", $clock_in);
    594763            update_post_meta($post_id, 'employee_clock_in_time', date($this->dateFormat, strtotime($clock_in)));
    595         }
    596         else{
     764        } else {
    597765            update_post_meta($post_id, 'employee_clock_in_time', null);
    598766        }
    599767
    600         if ($clock_out != null){
     768        if ($clock_out != null) {
    601769            $clock_out = str_replace("/", "-", $clock_out);
    602770            update_post_meta($post_id, 'employee_clock_out_time', date($this->dateFormat, strtotime($clock_out)));
    603         }
    604         else{
     771        } else {
    605772            update_post_meta($post_id, 'employee_clock_out_time', null);
    606773        }
    607774
    608775        if (isset($_REQUEST['employee_id'])) {
    609             remove_action('save_post', array($this, 'aio_save_shift_meta_lite'));
    610             $arg = array(
    611                 'ID' => $post_id,
     776            remove_action('save_post', [$this, 'aio_save_shift_meta_lite']);
     777            $arg = [
     778                'ID'          => $post_id,
    612779                'post_author' => intval($_REQUEST['employee_id']),
    613             );
     780            ];
    614781            wp_update_post($arg);
    615             add_action('save_post', array($this, 'aio_save_shift_meta_lite'));
     782            add_action('save_post', [$this, 'aio_save_shift_meta_lite']);
    616783        }
    617784    }
     
    637804    }
    638805
    639     function register_aio_timeclock_lite_settings()
    640     {
    641         register_setting('nertworks-timeclock-settings-group', 'aio_company_name', array( 'sanitize_callback' => array($this, 'clean_text')));
    642         register_setting('nertworks-timeclock-settings-group', 'aio_pay_schedule', array( 'sanitize_callback' => array($this, 'clean_text')));
    643         register_setting('nertworks-timeclock-settings-group', 'aio_wage_manage', array( 'sanitize_callback' => array($this, 'clean_text')));
    644         register_setting('nertworks-timeclock-settings-group', 'aio_timeclock_time_zone', array( 'sanitize_callback' => array($this, 'clean_text')));
    645         register_setting('nertworks-timeclock-settings-group', 'aio_timeclock_text_align', array( 'sanitize_callback' => array($this, 'clean_text')));
    646         register_setting('nertworks-timeclock-settings-group', 'aio_timeclock_redirect_employees', array( 'sanitize_callback' => array($this, 'clean_text')));
    647         register_setting('nertworks-timeclock-settings-group', 'aio_timeclock_show_avatar', array( 'sanitize_callback' => array($this, 'clean_text')));
    648     }
    649 
    650     function clean_text($value){
     806    public function register_aio_timeclock_lite_settings()
     807    {
     808        register_setting('nertworks-timeclock-settings-group', 'aio_company_name', ['sanitize_callback' => [$this, 'clean_text']]);
     809        register_setting('nertworks-timeclock-settings-group', 'aio_pay_schedule', ['sanitize_callback' => [$this, 'clean_text']]);
     810        register_setting('nertworks-timeclock-settings-group', 'aio_wage_manage', ['sanitize_callback' => [$this, 'clean_text']]);
     811        register_setting('nertworks-timeclock-settings-group', 'aio_timeclock_time_zone', ['sanitize_callback' => [$this, 'clean_text']]);
     812        register_setting('nertworks-timeclock-settings-group', 'aio_timeclock_text_align', ['sanitize_callback' => [$this, 'clean_text']]);
     813        register_setting('nertworks-timeclock-settings-group', 'aio_timeclock_redirect_employees', ['sanitize_callback' => [$this, 'clean_text']]);
     814        register_setting('nertworks-timeclock-settings-group', 'aio_timeclock_show_avatar', ['sanitize_callback' => [$this, 'clean_text']]);
     815    }
     816
     817    public function clean_text($value)
     818    {
    651819        $value = str_replace('"', "", $value);
    652820        return sanitize_text_field($value);
     
    655823    public function aio_check_tc_shortcode_lite()
    656824    {
    657         $loop = new WP_Query(array('post_type' => 'page', 'posts_per_page' => -1));
    658         while ($loop->have_posts()): $loop->the_post();
     825        $loop = new WP_Query(['post_type' => 'page', 'posts_per_page' => -1]);
     826        while ($loop->have_posts()):
     827            $loop->the_post();
    659828            $content = get_the_content();
    660829            if (has_shortcode($content, 'show_aio_time_clock_lite')) {
     
    670839    public function check_eprofile_shortcode_lite()
    671840    {
    672         $loop = new WP_Query(array('post_type' => 'page', 'posts_per_page' => -1));
    673         while ($loop->have_posts()): $loop->the_post();
     841        $loop = new WP_Query(['post_type' => 'page', 'posts_per_page' => -1]);
     842        while ($loop->have_posts()):
     843            $loop->the_post();
    674844            $content = get_the_content();
    675845            if (has_shortcode($content, 'show_aio_employee_profile_lite')) {
     
    685855    {
    686856        $tc_page = $this->aio_check_tc_shortcode_lite();
    687         $roles = $this->getBuiltInRoles();
    688         $roles = $this->arrayDelete(array('administrator'), $roles);
    689 
    690         if (isset($user->roles)){
     857        $roles   = $this->getBuiltInRoles();
     858        $roles   = $this->arrayDelete(['administrator'], $roles);
     859
     860        if (isset($user->roles)) {
    691861            if (is_array($user->roles) && $tc_page != null) {
    692862                if (array_intersect($roles, $user->roles)) {
    693863                    return esc_url(get_permalink($tc_page));
    694                 }               
     864                }
    695865            }
    696866        }
     
    701871    public function arrayDelete($del_val, $array)
    702872    {
    703         if(is_array($del_val)) {
    704              foreach ($del_val as $del_key => $del_value) {
    705                 foreach ($array as $key => $value){
     873        if (is_array($del_val)) {
     874            foreach ($del_val as $del_key => $del_value) {
     875                foreach ($array as $key => $value) {
    706876                    if ($value == $del_value) {
    707877                        unset($array[$key]);
     
    710880            }
    711881        } else {
    712             foreach ($array as $key => $value){
     882            foreach ($array as $key => $value) {
    713883                if ($value == $del_val) {
    714884                    unset($array[$key]);
     
    754924            if ($start != null && $end != null) {
    755925                $start = sanitize_text_field($start);
    756                 $end = sanitize_text_field($end);
     926                $end   = sanitize_text_field($end);
    757927                if ($this->isValidDate($start) && $this->isValidDate($end)) {
    758                     $start = str_replace('/', '-', $start);
    759                     $end = str_replace('/', '-', $end);
    760                     $s = new DateTime();
     928                    $start      = str_replace('/', '-', $start);
     929                    $end        = str_replace('/', '-', $end);
     930                    $s          = new DateTime();
    761931                    $start_date = $s->setTimestamp(intval(strtotime($start)));
    762                     $e = new DateTime();
    763                     $end_date = $e->setTimestamp(intval(strtotime($end)));
    764                     $diff = $end_date->diff($start_date);
    765                     $diff_sec = $diff->format('%r') . ( // prepend the sign - if negative, change it to R if you want the +, too
    766                         ($diff->s) + // seconds (no errors)
    767                         (60 * ($diff->i)) + // minutes (no errors)
    768                         (60 * 60 * ($diff->h)) + // hours (no errors)
    769                         (24 * 60 * 60 * ($diff->d)) + // days (no errors)
    770                         (30 * 24 * 60 * 60 * ($diff->m)) + // months (???)
    771                         (365 * 24 * 60 * 60 * ($diff->y)) // years (???)
     932                    $e          = new DateTime();
     933                    $end_date   = $e->setTimestamp(intval(strtotime($end)));
     934                    $diff       = $end_date->diff($start_date);
     935                    $diff_sec   = $diff->format('%r') . ( // prepend the sign - if negative, change it to R if you want the +, too
     936                        ($diff->s) +                          // seconds (no errors)
     937                        (60 * ($diff->i)) +                   // minutes (no errors)
     938                        (60 * 60 * ($diff->h)) +              // hours (no errors)
     939                        (24 * 60 * 60 * ($diff->d)) +         // days (no errors)
     940                        (30 * 24 * 60 * 60 * ($diff->m)) +    // months (???)
     941                        (365 * 24 * 60 * 60 * ($diff->y))     // years (???)
    772942                    );
    773943                    return $diff_sec;
     
    779949    public function addTwoTimes($time1 = "00:00", $time2 = "00:00")
    780950    {
    781         $times = array($time1, $time2);
    782         $hours = 0;
    783         $minutes = 0;       
     951        $times   = [$time1, $time2];
     952        $hours   = 0;
     953        $minutes = 0;
    784954        $seconds = 0;
    785         foreach ($times as $time)
    786         {
    787             if ($this->Contains($time, ":")){
    788                 list($hour,$minute) = explode(':', $time);
    789                 $seconds += $hour*3600;
    790                 $seconds += $minute*60;               
    791             }           
    792         }
    793         $hours = floor($seconds/3600);
    794         $seconds -= $hours*3600;
    795         $minutes  = floor($seconds/60);
    796         $seconds -= $minutes*60;
    797         if($seconds < 9)
    798         {
    799         $seconds = "0".$seconds;
    800         }
    801         if($minutes < 9)
    802         {
    803         $minutes = "0".$minutes;
    804         }
    805           if($hours < 9)
    806         {
    807         $hours = "0".$hours;
     955        foreach ($times as $time) {
     956            if ($this->Contains($time, ":")) {
     957                list($hour, $minute) = explode(':', $time);
     958                $seconds += $hour * 3600;
     959                $seconds += $minute * 60;
     960            }
     961        }
     962        $hours = floor($seconds / 3600);
     963        $seconds -= $hours * 3600;
     964        $minutes = floor($seconds / 60);
     965        $seconds -= $minutes * 60;
     966        if ($seconds < 9) {
     967            $seconds = "0" . $seconds;
     968        }
     969        if ($minutes < 9) {
     970            $minutes = "0" . $minutes;
     971        }
     972        if ($hours < 9) {
     973            $hours = "0" . $hours;
    808974        }
    809975        return "{$hours}:{$minutes}";
     
    822988    {
    823989        $shift_total_time = "00:00";
    824         $shift_array = array();
    825         $wage_total = floatval(0);
    826         $count = 0;
    827         $loop = new WP_Query(array('post_type' => 'shift', 'author' => $employee, 'posts_per_page' => -1));
    828 
    829         while ($loop->have_posts()): $loop->the_post();
    830             $shift_sum = "00:00";
    831             $shift_id = $loop->post->ID;
    832             $custom = get_post_custom($shift_id);
    833             $employee_clock_in_time = isset($custom["employee_clock_in_time"][0]) ? sanitize_text_field($custom["employee_clock_in_time"][0]) : null;
     990        $shift_array      = [];
     991        $wage_total       = floatval(0);
     992        $count            = 0;
     993        $loop             = new WP_Query(['post_type' => 'shift', 'author' => $employee, 'posts_per_page' => -1]);
     994
     995        while ($loop->have_posts()):
     996            $loop->the_post();
     997            $shift_sum               = "00:00";
     998            $shift_id                = $loop->post->ID;
     999            $custom                  = get_post_custom($shift_id);
     1000            $employee_clock_in_time  = isset($custom["employee_clock_in_time"][0]) ? sanitize_text_field($custom["employee_clock_in_time"][0]) : null;
    8341001            $employee_clock_out_time = isset($custom["employee_clock_out_time"][0]) ? sanitize_text_field($custom["employee_clock_out_time"][0]) : null;
    835             $searchDateBegin = sanitize_text_field($date_range_start);
    836             $searchDateEnd = sanitize_text_field($date_range_end);
     1002            $searchDateBegin         = sanitize_text_field($date_range_start);
     1003            $searchDateEnd           = sanitize_text_field($date_range_end);
    8371004            if ((strtotime($employee_clock_in_time) >= strtotime($searchDateBegin)) && (strtotime($employee_clock_in_time) <= strtotime($searchDateEnd))) {
    838                 $author_id = $loop->post->post_author;
    839                 $last_name = sanitize_text_field(get_the_author_meta('last_name', $author_id));
     1005                $author_id  = $loop->post->post_author;
     1006                $last_name  = sanitize_text_field(get_the_author_meta('last_name', $author_id));
    8401007                $first_name = sanitize_text_field(get_the_author_meta('first_name', $author_id));
    841                 $wage = sanitize_text_field(get_the_author_meta('employee_wage', $author_id));
    842                
     1008                $wage       = sanitize_text_field(get_the_author_meta('employee_wage', $author_id));
     1009
    8431010                if ($employee_clock_in_time != null && $employee_clock_out_time != null) {
    8441011                    $shift_sum = $this->secondsToTime($this->dateDifference($employee_clock_in_time, $employee_clock_out_time));
    845                     if (!$this->isNull($wage)){
     1012                    if (! $this->isNull($wage)) {
    8461013                        $decimal_total = $this->TimeToDecimal($shift_sum);
    8471014                        $wage_total += (floatval($wage) * floatval($decimal_total));
    848                     }                   
     1015                    }
    8491016                    $shift_total_time = $this->addTwoTimes($shift_total_time, $shift_sum);
    8501017                }
    851                 array_push($shift_array,
    852                     array(
    853                         "shift_id" => $shift_id,
    854                         "employee_clock_in_time" => $this->cleanDate($employee_clock_in_time),
     1018                array_push(
     1019                    $shift_array,
     1020                    [
     1021                        "shift_id"                => $shift_id,
     1022                        "employee_clock_in_time"  => $this->cleanDate($employee_clock_in_time),
    8551023                        "employee_clock_out_time" => $this->cleanDate($employee_clock_out_time),
    856                         "first_name" => $first_name,
    857                         "last_name" => $last_name,
    858                         "shift_sum" => $shift_sum,
    859                     )
     1024                        "first_name"              => $first_name,
     1025                        "last_name"               => $last_name,
     1026                        "shift_sum"               => $shift_sum,
     1027                    ]
    8601028                );
    8611029                $count++;
    8621030            }
    8631031        endwhile;
    864         wp_reset_query();       
    865 
    866         return array(
    867             "response" => "success",
    868             "shift_count" => $count,
     1032        wp_reset_query();
     1033
     1034        return [
     1035            "response"         => "success",
     1036            "shift_count"      => $count,
    8691037            "shift_total_time" => $shift_total_time,
    870             "wage_total" => $this->Money($wage_total),
    871             "shift_array" => $shift_array,
    872         );
    873     }
    874 
    875     function TimeToDecimal($time)
     1038            "wage_total"       => $this->Money($wage_total),
     1039            "shift_array"      => $shift_array,
     1040        ];
     1041    }
     1042
     1043    public function TimeToDecimal($time)
    8761044    {
    8771045        $timeArr = explode(':', $time);
    878         $decTime = ($timeArr[0]*60) + ($timeArr[1]);       
    879      
     1046        $decTime = ($timeArr[0] * 60) + ($timeArr[1]);
     1047
    8801048        return ($decTime / 60);
    8811049    }
     
    8881056    public function isNull($string)
    8891057    {
    890         if ($string == null || $string == ''){
     1058        if ($string == null || $string == '') {
    8911059            return true;
    892         }
    893         else{
     1060        } else {
    8941061            return false;
    8951062        }
     
    9171084    public function getCurrentTime()
    9181085    {
    919         $timezone = null;
    920         $current_time = null;
     1086        $timezone        = null;
     1087        $current_time    = null;
    9211088        $timezone_option = get_option('aio_timeclock_time_zone');
    9221089        if ($timezone_option != null) {
    9231090            date_default_timezone_set($timezone_option);
    9241091            $current_time = date($this->mysqlDateFormat);
    925             $time_type = "timezone option";
     1092            $time_type    = "timezone option";
    9261093        } else {
    9271094            $timezone = 'UTC';
    9281095            date_default_timezone_set($timezone);
    9291096            $current_time = date($this->mysqlDateFormat);
    930             $time_type = "default utc";
    931         }
    932 
    933         return array(
    934             "response" => "success",
     1097            $time_type    = "default utc";
     1098        }
     1099
     1100        return [
     1101            "response"        => "success",
    9351102            "timezone_option" => $timezone_option,
    936             "current_time" => $current_time,
    937             "time_type" => $time_type,
    938             "timezone" => $timezone
    939         );
     1103            "current_time"    => $current_time,
     1104            "time_type"       => $time_type,
     1105            "timezone"        => $timezone,
     1106        ];
    9401107    }
    9411108
     
    9761143    public function isTimeMachine($date)
    9771144    {
    978         $now = date("Y-m-d h:i:s A");
     1145        $now      = date("Y-m-d h:i:s A");
    9791146        $end_date = date("Y-m-d", strtotime(date("Y-m-d", strtotime($now)) . " - 10 years"));
    9801147        return (strtotime($date) <= strtotime($end_date));
    981     }   
     1148    }
    9821149
    9831150    public function aio_lite_update_department_count($terms, $taxonomy)
     
    9901157
    9911158            do_action('edit_term_taxonomy', $term, $taxonomy);
    992             $wpdb->update($wpdb->term_taxonomy, compact('count'), array('term_taxonomy_id' => $term));
     1159            $wpdb->update($wpdb->term_taxonomy, compact('count'), ['term_taxonomy_id' => $term]);
    9931160            do_action('edited_term_taxonomy', $term, $taxonomy);
    9941161        }
     
    9971164    public function aio_lite_register_user_taxonomy()
    9981165    {
    999 
    10001166        register_taxonomy(
    10011167            'department',
    10021168            'user',
    1003             array(
    1004                 'public' => true,
    1005                 'labels' => array(
    1006                     'name' => esc_attr_x('Department', 'aio-time-clock-lite'),
    1007                     'singular_name' => esc_attr_x('Department', 'aio-time-clock-lite'),
    1008                     'menu_name' => esc_attr_x('Departments', 'aio-time-clock-lite'),
    1009                     'search_items' => esc_attr_x('Search Departments', 'aio-time-clock-lite'),
    1010                     'popular_items' => esc_attr_x('Popular Departments', 'aio-time-clock-lite'),
    1011                     'all_items' => esc_attr_x('All Departments', 'aio-time-clock-lite'),
    1012                     'edit_item' => esc_attr_x('Edit Department', 'aio-time-clock-lite'),
    1013                     'update_item' => esc_attr_x('Update Department', 'aio-time-clock-lite'),
    1014                     'add_new_item' => esc_attr_x('Add New Department', 'aio-time-clock-lite'),
    1015                     'new_item_name' => esc_attr_x('New Department Name', 'aio-time-clock-lite'),
     1169            [
     1170                'public'                => true,
     1171                'labels'                => [
     1172                    'name'                       => esc_attr_x('Department', 'aio-time-clock-lite'),
     1173                    'singular_name'              => esc_attr_x('Department', 'aio-time-clock-lite'),
     1174                    'menu_name'                  => esc_attr_x('Departments', 'aio-time-clock-lite'),
     1175                    'search_items'               => esc_attr_x('Search Departments', 'aio-time-clock-lite'),
     1176                    'popular_items'              => esc_attr_x('Popular Departments', 'aio-time-clock-lite'),
     1177                    'all_items'                  => esc_attr_x('All Departments', 'aio-time-clock-lite'),
     1178                    'edit_item'                  => esc_attr_x('Edit Department', 'aio-time-clock-lite'),
     1179                    'update_item'                => esc_attr_x('Update Department', 'aio-time-clock-lite'),
     1180                    'add_new_item'               => esc_attr_x('Add New Department', 'aio-time-clock-lite'),
     1181                    'new_item_name'              => esc_attr_x('New Department Name', 'aio-time-clock-lite'),
    10161182                    'separate_items_with_commas' => esc_attr_x('Separate departments with commas', 'aio-time-clock-lite'),
    1017                     'add_or_remove_items' => esc_attr_x('Add or remove departments', 'aio-time-clock-lite'),
    1018                     'choose_from_most_used' => esc_attr_x('Choose from the most popular departments', 'aio-time-clock-lite'),
    1019                 ),
    1020                 'rewrite' => array(
     1183                    'add_or_remove_items'        => esc_attr_x('Add or remove departments', 'aio-time-clock-lite'),
     1184                    'choose_from_most_used'      => esc_attr_x('Choose from the most popular departments', 'aio-time-clock-lite'),
     1185                ],
     1186                'rewrite'               => [
    10211187                    'with_front' => true,
    1022                     'slug' => 'author/department', // Use 'author' (default WP user slug).
    1023                 ),
    1024                 'capabilities' => array(
     1188                    'slug'       => 'author/department', // Use 'author' (default WP user slug).
     1189                ],
     1190                'capabilities'          => [
    10251191                    'manage_terms' => 'edit_users', // Using 'edit_users' cap to keep this simple.
    1026                     'edit_terms' => 'edit_users',
     1192                    'edit_terms'   => 'edit_users',
    10271193                    'delete_terms' => 'edit_users',
    10281194                    'assign_terms' => 'read',
    1029                 ),
     1195                ],
    10301196                'update_count_callback' => 'aio_lite_update_department_count', // Use a custom function to update the count.
    1031             )
     1197            ]
    10321198        );
    10331199    }
     
    10381204        $tax = get_taxonomy('department');
    10391205
    1040         if (!current_user_can('edit_user', $user_id) && current_user_can($tax->cap->assign_terms)) {
     1206        if (! current_user_can('edit_user', $user_id) && current_user_can($tax->cap->assign_terms)) {
    10411207            return false;
    10421208        }
    10431209
    1044         if (isset($_POST['department'])){
     1210        if (isset($_POST['department'])) {
    10451211            $term = sanitize_text_field($_POST['department']);
    1046             wp_set_object_terms($user_id, array($term), 'department', false);
     1212            wp_set_object_terms($user_id, [$term], 'department', false);
    10471213        }
    10481214
     
    10871253        $tax = get_taxonomy('department');
    10881254
    1089         if (!current_user_can('edit_user', $user_id) && current_user_can($tax->cap->assign_terms)) {
     1255        if (! current_user_can('edit_user', $user_id) && current_user_can($tax->cap->assign_terms)) {
    10901256            return false;
    10911257        }
    10921258
    1093         if (isset($_POST['department'])){
     1259        if (isset($_POST['department'])) {
    10941260            $term = sanitize_text_field($_POST['department']);
    1095             wp_set_object_terms(intval($user_id), array($term), 'department', false);
     1261            wp_set_object_terms(intval($user_id), [$term], 'department', false);
    10961262        }
    10971263
     
    11601326    public function getUsers()
    11611327    {
    1162         $users = array();
    1163         $blog_id = get_current_blog_id();
     1328        $users          = [];
     1329        $blog_id        = get_current_blog_id();
    11641330        $built_in_roles = $this->getBuiltInRoles();
    11651331
    1166         $args = array(
    1167             'blog_id' => $blog_id,
    1168             'role' => '',
    1169             'role__in' => $built_in_roles,
    1170             'role__not_in' => array(),
    1171             'meta_key' => 'last_name',
    1172             'meta_value' => '',
     1332        $args = [
     1333            'blog_id'      => $blog_id,
     1334            'role'         => '',
     1335            'role__in'     => $built_in_roles,
     1336            'role__not_in' => [],
     1337            'meta_key'     => 'last_name',
     1338            'meta_value'   => '',
    11731339            'meta_compare' => '',
    1174             'meta_query' => array(),
    1175             'date_query' => array(),
    1176             'include' => array(),
    1177             'exclude' => array(),
    1178             'orderby' => 'meta_value',
    1179             'order' => 'ASC',
    1180             'offset' => '',
    1181             'search' => '',
    1182             'number' => '',
    1183             'count_total' => false,
    1184             'fields' => 'all',
    1185             'who' => '',
    1186         );
     1340            'meta_query'   => [],
     1341            'date_query'   => [],
     1342            'include'      => [],
     1343            'exclude'      => [],
     1344            'orderby'      => 'meta_value',
     1345            'order'        => 'ASC',
     1346            'offset'       => '',
     1347            'search'       => '',
     1348            'number'       => '',
     1349            'count_total'  => false,
     1350            'fields'       => 'all',
     1351            'who'          => '',
     1352        ];
    11871353        $your_users = get_users($args);
    11881354        foreach ($your_users as $user) {
    11891355            array_push(
    11901356                $users,
    1191                 array(
     1357                [
    11921358                    "employee_id" => $user->ID,
    1193                     "first_name" => $user->first_name,
    1194                     "last_name" => $user->last_name,
    1195                     "department" => $this->getDepartment($user->ID),
    1196                     "roles" => $user->roles,
    1197                 )
     1359                    "first_name"  => $user->first_name,
     1360                    "last_name"   => $user->last_name,
     1361                    "department"  => $this->getDepartment($user->ID),
     1362                    "roles"       => $user->roles,
     1363                ]
    11981364            );
    11991365        }
     
    12031369    public function getEmployeeName($employee_id)
    12041370    {
    1205         $full_name = null;
     1371        $full_name   = null;
    12061372        $employee_id = intval($employee_id);
    1207         $first_name = sanitize_text_field(get_the_author_meta('first_name', $employee_id));
    1208         $last_name = sanitize_text_field(get_the_author_meta('last_name', $employee_id));
     1373        $first_name  = sanitize_text_field(get_the_author_meta('first_name', $employee_id));
     1374        $last_name   = sanitize_text_field(get_the_author_meta('last_name', $employee_id));
    12091375
    12101376        if (($first_name == null || $last_name == null)) {
     
    12241390    public function getDepartment($user_id)
    12251391    {
    1226         $department = "";
    1227         $user_groups = wp_get_object_terms($user_id, 'department', array('fields' => 'all_with_object_id')); // Get user group detail
     1392        $department  = "";
     1393        $user_groups = wp_get_object_terms($user_id, 'department', ['fields' => 'all_with_object_id']); // Get user group detail
    12281394        foreach ($user_groups as $user_gro) {
    12291395            $department = $user_gro->name; // Get current user group name
     
    12351401    public function aio_lite_edit_user_department_section($user)
    12361402    {
    1237         require_once("templates/department-section.php");
    1238     }
    1239 
    1240     public function getMonitoringShiftColumn($employee_id){
    1241         return '<div class="shiftStatus">     
     1403        require_once "templates/department-section.php";
     1404    }
     1405
     1406    public function getMonitoringShiftColumn($employee_id)
     1407    {
     1408        return '<div class="shiftStatus">
    12421409            <span>' . esc_attr_x('Working', 'aio-time-clock') . '</span>
    12431410        </div>';
     
    12461413    public function getTranslationStrings()
    12471414    {
    1248         return array(
    1249             'Nonce' => wp_create_nonce("clock_in_nonce"),
    1250             'ajaxurl' => admin_url('admin-ajax.php'),
    1251             'isClockedIn' => esc_attr_x('You are currently clocked in', 'aio-time-clock-lite'),
    1252             'clockInTime' => esc_attr_x('Clock In Time', 'aio-time-clock-lite'),
    1253             'updateNote' => esc_attr_x('Update Note', 'aio-time-clock-lite'),
    1254             'addNote' => esc_attr_x('Add Note', 'aio-time-clock-lite'),
    1255             'clockInMessage' => esc_attr_x('Click CLOCK IN to START your shift', 'aio-time-clock-lite'),
    1256             'locationError' => esc_attr_x('Location Required', 'aio-time-clock-lite'),
     1415        return [
     1416            'Nonce'             => wp_create_nonce("time-clock-nonce"),
     1417            'ajaxurl'           => admin_url('admin-ajax.php'),
     1418            'isClockedIn'       => esc_attr_x('You are currently clocked in', 'aio-time-clock-lite'),
     1419            'clockInTime'       => esc_attr_x('Clock In Time', 'aio-time-clock-lite'),
     1420            'updateNote'        => esc_attr_x('Update Note', 'aio-time-clock-lite'),
     1421            'addNote'           => esc_attr_x('Add Note', 'aio-time-clock-lite'),
     1422            'clockInMessage'    => esc_attr_x('Click CLOCK IN to START your shift', 'aio-time-clock-lite'),
     1423            'locationError'     => esc_attr_x('Location Required', 'aio-time-clock-lite'),
    12571424            'clockedOutMessage' => esc_attr_x('You have been clocked out', 'aio-time-clock-lite'),
    1258             'clockOutFail' => esc_attr_x('Clock out failed', 'aio-time-clock-lite'),
    1259             'clockInFail' => esc_attr_x('Clock In failed', 'aio-time-clock-lite'),
    1260             'currentTime' => esc_attr_x('Current Time', 'aio-time-clock-lite'),
    1261             'clockIn' => esc_attr_x('Clock In', 'aio-time-clock-lite'),
    1262             'clockOut' => esc_attr_x('Clock Out', 'aio-time-clock-lite'),
    1263             'Name' => esc_attr_x('Name', 'aio-time-clock-lite'),
    1264             'Options' => esc_attr_x('Options', 'aio-time-clock-lite'),
    1265             'ShiftTotal' => esc_attr_x('Shift Total', 'aio-time-clock-lite'),
    1266             'TotalShifts' => esc_attr_x('Total Shifts', 'aio-time-clock-lite'),
    1267             'TotalShiftTime' => esc_attr_x('Total Shift Time', 'aio-time-clock-lite'),
    1268             'WageTotal' => esc_attr_x('Wage Total', 'aio-time-clock-lite'),
    1269             'TimeClockDetected' => esc_attr_x('Widget time clock disabled while on time clock page', 'aio-time-clock-lite')
    1270         );
     1425            'clockOutFail'      => esc_attr_x('Clock out failed', 'aio-time-clock-lite'),
     1426            'clockInFail'       => esc_attr_x('Clock In failed', 'aio-time-clock-lite'),
     1427            'currentTime'       => esc_attr_x('Current Time', 'aio-time-clock-lite'),
     1428            'clockIn'           => esc_attr_x('Clock In', 'aio-time-clock-lite'),
     1429            'clockOut'          => esc_attr_x('Clock Out', 'aio-time-clock-lite'),
     1430            'Name'              => esc_attr_x('Name', 'aio-time-clock-lite'),
     1431            'Options'           => esc_attr_x('Options', 'aio-time-clock-lite'),
     1432            'ShiftTotal'        => esc_attr_x('Shift Total', 'aio-time-clock-lite'),
     1433            'TotalShifts'       => esc_attr_x('Total Shifts', 'aio-time-clock-lite'),
     1434            'TotalShiftTime'    => esc_attr_x('Total Shift Time', 'aio-time-clock-lite'),
     1435            'WageTotal'         => esc_attr_x('Wage Total', 'aio-time-clock-lite'),
     1436            'TimeClockDetected' => esc_attr_x('Widget time clock disabled while on time clock page', 'aio-time-clock-lite'),
     1437            'PageLinkEmpty'     => esc_attr_x('Page link not available so cannot redirect', 'aio-time-clock-lite'),
     1438            'ViewPage'          => esc_attr_x('View Page', 'aio-time-clock-lite'),
     1439            'EditPage'          => esc_attr_x('Edit Page', 'aio-time-clock-lite'),
     1440            'Close'             => esc_attr_x('Close', 'aio-time-clock-lite'),
     1441            'Cancel'            => esc_attr_x('Cancel', 'aio-time-clock-lite'),
     1442        ];
    12711443    }
    12721444
    12731445    public function getProFeatures()
    12741446    {
    1275         $features = array(
    1276             array(
    1277                 "title" => esc_attr_x('More Settings', 'aio-time-clock-lite'),
     1447        $features = [
     1448            [
     1449                "title"       => esc_attr_x('More Settings', 'aio-time-clock-lite'),
    12781450                "description" => esc_attr_x('Easily customize the time clock for your company', 'aio-time-clock-lite'),
    1279                 "image" => "/images/pro/1-settings.png"
    1280             ),
    1281             array(
    1282                 "title" => esc_attr_x('Custom Roles', 'aio-time-clock-lite'),
     1451                "image"       => "/images/pro/1-settings.png",
     1452            ],
     1453            [
     1454                "title"       => esc_attr_x('Custom Roles', 'aio-time-clock-lite'),
    12831455                "description" => esc_attr_x('Add your own custom roles for time clock access', 'aio-time-clock-lite'),
    1284                 "image" => "/images/pro/2-custom-roles.png"
    1285             ),
    1286             array(
    1287                 "title" => esc_attr_x('Manager Profiles', 'aio-time-clock-lite'),
     1456                "image"       => "/images/pro/2-custom-roles.png",
     1457            ],
     1458            [
     1459                "title"       => esc_attr_x('Manager Profiles', 'aio-time-clock-lite'),
    12881460                "description" => esc_attr_x('Manager profiles that can export, import and edit shifts', 'aio-time-clock-lite'),
    1289                 "image" => "/images/pro/3-manager-profile.png"
    1290             ),
    1291             array(
    1292                 "title" => esc_attr_x('Improved Reports', 'aio-time-clock-lite'),
     1461                "image"       => "/images/pro/3-manager-profile.png",
     1462            ],
     1463            [
     1464                "title"       => esc_attr_x('Improved Reports', 'aio-time-clock-lite'),
    12931465                "description" => esc_attr_x('Custom Simple and Advanced Shift Reports', 'aio-time-clock-lite'),
    1294                 "image" => "/images/pro/4-reports.png"
    1295             ),
    1296             array(
    1297                 "title" => esc_attr_x('Charts and Graphs', 'aio-time-clock-lite'),
     1466                "image"       => "/images/pro/4-reports.png",
     1467            ],
     1468            [
     1469                "title"       => esc_attr_x('Charts and Graphs', 'aio-time-clock-lite'),
    12981470                "description" => esc_attr_x('View activity in the form of a chart', 'aio-time-clock-lite'),
    1299                 "image" => "/images/pro/5-charts.png"           
    1300             ),
    1301             array(
    1302                 "title" => esc_attr_x('Multiple Shift Views', 'aio-time-clock-lite'),
     1471                "image"       => "/images/pro/5-charts.png",
     1472            ],
     1473            [
     1474                "title"       => esc_attr_x('Multiple Shift Views', 'aio-time-clock-lite'),
    13031475                "description" => esc_attr_x('View, edit or create bulk shifts', 'aio-time-clock-lite'),
    1304                 "image" => "/images/pro/6-shift-views.png"
    1305             ),
    1306             array(
    1307                 "title" => esc_attr_x('Predefined Locations', 'aio-time-clock-lite'),
     1476                "image"       => "/images/pro/6-shift-views.png",
     1477            ],
     1478            [
     1479                "title"       => esc_attr_x('Predefined Locations', 'aio-time-clock-lite'),
    13081480                "description" => esc_attr_x('Unlimited Clock in Locations', 'aio-time-clock-lite'),
    1309                 "image" => "/images/pro/7-locations.png"
    1310             ),
    1311             array(
    1312                 "title" => esc_attr_x('IP And GPS Tracking', 'aio-time-clock-lite'),
     1481                "image"       => "/images/pro/7-locations.png",
     1482            ],
     1483            [
     1484                "title"       => esc_attr_x('IP And GPS Tracking', 'aio-time-clock-lite'),
    13131485                "description" => esc_attr_x('Shifts can show the location of an IP address and a GPS coordinate', 'aio-time-clock-lite'),
    1314                 "image" => "/images/pro/8-shift-info.png"
    1315             ),
    1316             array(
    1317                 "title" => esc_attr_x('Quick Pick Time Clock', 'aio-time-clock-lite'),
     1486                "image"       => "/images/pro/8-shift-info.png",
     1487            ],
     1488            [
     1489                "title"       => esc_attr_x('Quick Pick Time Clock', 'aio-time-clock-lite'),
    13181490                "description" => esc_attr_x('List style time clock page with pin pad entry instead of a login', 'aio-time-clock-lite'),
    1319                 "image" => "/images/pro/9-quick-pick.png"
    1320             ),
    1321             array(
    1322                 "title" => esc_attr_x('Predefined Shifts', 'aio-time-clock-lite'),
     1491                "image"       => "/images/pro/9-quick-pick.png",
     1492            ],
     1493            [
     1494                "title"       => esc_attr_x('Predefined Shifts', 'aio-time-clock-lite'),
    13231495                "description" => esc_attr_x('Create prefined shifts that employees can choose from instead of a dynamic clock', 'aio-time-clock-lite'),
    1324                 "image" => "/images/pro/10-predefined-shifts.png"
    1325             ),
    1326             array(
    1327                 "title" => esc_attr_x('Extendable', 'aio-time-clock-lite'),
     1496                "image"       => "/images/pro/10-predefined-shifts.png",
     1497            ],
     1498            [
     1499                "title"       => esc_attr_x('Extendable', 'aio-time-clock-lite'),
    13281500                "description" => esc_attr_x('Extensions/Addons Supported to allow anything to be possible', 'aio-time-clock-lite'),
    1329                 "image" => "/images/pro/11-extendable.png"               
    1330             )   
    1331         );       
     1501                "image"       => "/images/pro/11-extendable.png",
     1502            ],
     1503        ];
    13321504        return $features;
    13331505    }
  • aio-time-clock-lite/trunk/aio-time-clock-lite.php

    r3286600 r3287366  
    66 * Author:      Codebangers
    77 * Author URI:  https://codebangers.com
    8  * Version:     1.3.325
     8 * Version:     1.3.326
    99 */
    1010class AIO_Time_Clock_Plugin_Lite
  • aio-time-clock-lite/trunk/css/aio-admin.css

    r2845181 r3287366  
    6464  font-family: "Roboto", sans-serif;
    6565  font-weight: 900;
     66}
     67
     68.time-clock-admin-button{
     69  margin-top: -5px !important;
    6670}
    6771
     
    327331table.dataTable thead .sorting, table.dataTable thead .sorting_asc, table.dataTable thead .sorting_desc, table.dataTable thead .sorting_asc_disabled, table.dataTable thead .sorting_desc_disabled {
    328332  cursor: pointer;
    329   *cursor: hand;
    330333  background-repeat: no-repeat;
    331334  background-position: center right;
     
    572575  position: relative;
    573576  clear: both;
    574   *zoom: 1;
    575577  zoom: 1;
    576578}
     
    610612  text-decoration: none !important;
    611613  cursor: pointer;
    612   *cursor: hand;
    613614  color: #6b6363 !important;
    614615  border: 1px solid transparent;
     
    711712
    712713.dataTables_wrapper .dataTables_scroll div.dataTables_scrollBody {
    713   *margin-top: -1px;
    714714  -webkit-overflow-scrolling: touch;
    715715}
     
    732732.dataTables_wrapper.no-footer div.dataTables_scrollHead table.dataTable, .dataTables_wrapper.no-footer div.dataTables_scrollBody>table {
    733733  border-bottom: none;
     734}
     735
     736.hidden-item{
     737  display: none;
    734738}
    735739
     
    742746}
    743747
     748.time-clock-swal-header{
     749  font-size: 22px;
     750  line-height: .2;
     751  padding-bottom: 20px;
     752
     753}
     754
    744755@media screen and (max-width: 767px) {
    745756  .dataTables_wrapper .dataTables_info, .dataTables_wrapper .dataTables_paginate {
  • aio-time-clock-lite/trunk/js/time-clock-lite-admin.js

    r2856326 r3287366  
     1var Toast = Swal.mixin({
     2  toast: true,
     3  position: 'top-end',
     4  showConfirmButton: false,
     5  timer: 3000
     6});
     7
    18jQuery(function () {
    2 
    3     jQuery('.adminInputDate').datetimepicker({
    4       format:'Y-m-d h:i A',
    5       formatTime: 'h:i A'
     9  jQuery('.adminInputDate').datetimepicker({
     10    format: 'Y-m-d h:i A',
     11    formatTime: 'h:i A'
     12  });
     13
     14  if (jQuery("#aio_tc_news").length > 0) {
     15    jQuery("#aio_tc_news").steps({
     16      headerTag: "h3",
     17      bodyTag: "section",
     18      transitionEffect: "slideLeft",
     19      stepsOrientation: "vertical",
     20      autoFocus: true,
     21      onFinished: function () {
     22        window.location = "?page=aio-tc-lite";
     23      }
    624    });
    7  
    8     if (jQuery("#aio_tc_news").length > 0) {
    9       jQuery("#aio_tc_news").steps({
    10         headerTag: "h3",
    11         bodyTag: "section",
    12         transitionEffect: "slideLeft",
    13         stepsOrientation: "vertical",
    14         autoFocus: true,
    15         onFinished: function () {
    16           window.location = "?page=aio-tc-lite";
     25  }
     26
     27
     28  jQuery("#aio_generate_report").click(function (e) {
     29    e.preventDefault();
     30    var wage_enabled = jQuery("#wage_enabled").val()
     31    var report_action = "generate_report";
     32    var admin_action = 'report';
     33    jQuery("#aio-reports-results").html('<center><img src="/wp-admin/images/spinner-2x.gif"></center>').show();
     34    jQuery.ajax({
     35      type: "post",
     36      dataType: "json",
     37      url: timeClockAdminAjax.ajaxurl,
     38      data: {
     39        action: "aio_time_clock_lite_admin_js",
     40        admin_action: admin_action,
     41        report_action: report_action,
     42        aio_pp_start_date: jQuery("#aio_pp_start_date").val(),
     43        aio_pp_end_date: jQuery("#aio_pp_end_date").val(),
     44        employee: jQuery("#employee").val(),
     45        nonce: timeClockAdminAjax.Nonce
     46      },
     47      success: function (data) {
     48        if (data["response"] == "success") {
     49          var shiftRows = data["shifts"]["shift_array"];
     50          jQuery("#aio-reports-results").html("");
     51          var reportHtml =
     52            '<table class="widefat fixed" cellspacing="0">' +
     53            '<thead>' +
     54            '<tr>' +
     55            '<th id="columnname" class="manage-column column-columnname" scope="col"><strong>' + timeClockAdminAjax.Name + '</strong></th>' +
     56            '<th id="columnname" class="manage-column column-columnname" scope="col"><strong>' + timeClockAdminAjax.clockIn + '</strong></th>' +
     57            '<th id="columnname" class="manage-column column-columnname" scope="col"><strong>' + timeClockAdminAjax.clockOut + '</strong></th>' +
     58            '<th id="columnname" class="manage-column column-columnname" scope="col"><strong>' + timeClockAdminAjax.ShiftTotal + '</strong></th>' +
     59            '</tr>' +
     60            '</thead>' +
     61            '<tbody>';
     62          var count = 0;
     63          shiftRows.forEach(function (item) {
     64            count++;
     65            var alternate_class = "";
     66            if (isEven(count)) {
     67              alternate_class = 'alternate';
     68            }
     69            var employee_clock_in_time = "";
     70            if (item["employee_clock_in_time"] != null) {
     71              employee_clock_in_time = item["employee_clock_in_time"];
     72            }
     73            var employee_clock_out_time = "";
     74            if (item["employee_clock_out_time"] != null) {
     75              employee_clock_out_time = item["employee_clock_out_time"];
     76            }
     77            var shift_sum = "";
     78            if (item["shift_sum"]) {
     79              shift_sum = item["shift_sum"];
     80            }
     81
     82            reportHtml +=
     83              '<tr class="' + alternate_class + '">' +
     84              '<td>' + item["last_name"] + ', ' + item["first_name"] + '</td>' +
     85              '<td>' + employee_clock_in_time + '</td>' +
     86              '<td>' + employee_clock_out_time + '</td>' +
     87              '<td>' + shift_sum + '</td>' +
     88              '</tr>';
     89          });
     90          reportHtml += '</tbody>' +
     91            '</table>';
     92
     93          var shift_total_time = "0";
     94          if (data["shifts"]["shift_total_time"]) {
     95            shift_total_time = data["shifts"]["shift_total_time"];
     96          }
     97
     98          var wage_total = "0";
     99          var wage_total_row = "";
     100          if (data["shifts"]["wage_total"]) {
     101            wage_total = data["shifts"]["wage_total"];
     102          }
     103
     104          if (wage_enabled == "enabled") {
     105            wage_total_row = '<strong>' + timeClockAdminAjax.WageTotal + ': </strong>' + wage_total + '<br />'
     106          }
     107
     108          reportHtml += '<div class="controlDiv">' +
     109            '<strong>' + timeClockAdminAjax.TotalShifts + ': </strong>' + data["shifts"]["shift_count"] + '<br />' +
     110            '<strong>' + timeClockAdminAjax.TotalShiftTime + ': </strong>' + shift_total_time + '<br />' +
     111            wage_total_row +
     112            '<hr>' +
     113            '</div>';
     114          jQuery("#aio-reports-results").html(reportHtml);
     115          jQuery("#aio-reports-results").show();
    17116        }
    18       });
    19     }
    20  
    21  
    22     jQuery("#aio_generate_report").click(function (e) {
    23       e.preventDefault();
    24       var wage_enabled = jQuery("#wage_enabled").val()
    25       var report_action = "generate_report";
    26       jQuery("#aio-reports-results").html('<center><img src="/wp-admin/images/spinner-2x.gif"></center>').show();
    27       jQuery.ajax({
    28         type: "post",
    29         dataType: "json",
    30         url: timeClockAdminAjax.ajaxurl,
    31         data: {
    32           action: "aio_time_clock_lite_admin_js",
    33           report_action: report_action,
    34           aio_pp_start_date: jQuery("#aio_pp_start_date").val(),
    35           aio_pp_end_date: jQuery("#aio_pp_end_date").val(),
    36           employee: jQuery("#employee").val(),
    37           nonce: timeClockAdminAjax.Nonce
    38         },
    39         success: function (data) {
    40           if (data["response"] == "success") {
    41             var shiftRows = data["shifts"]["shift_array"];
    42             jQuery("#aio-reports-results").html("");
    43             var reportHtml =
    44               '<table class="widefat fixed" cellspacing="0">' +
    45               '<thead>' +
    46               '<tr>' +
    47               '<th id="columnname" class="manage-column column-columnname" scope="col"><strong>' + timeClockAdminAjax.Name + '</strong></th>' +
    48               '<th id="columnname" class="manage-column column-columnname" scope="col"><strong>' + timeClockAdminAjax.clockIn + '</strong></th>' +
    49               '<th id="columnname" class="manage-column column-columnname" scope="col"><strong>' + timeClockAdminAjax.clockOut + '</strong></th>' +
    50               '<th id="columnname" class="manage-column column-columnname" scope="col"><strong>' + timeClockAdminAjax.ShiftTotal + '</strong></th>' +
    51               '</tr>' +
    52               '</thead>' +
    53               '<tbody>';
    54             var count = 0;
    55             shiftRows.forEach(function (item) {
    56               count++;
    57               var alternate_class = "";
    58               if (isEven(count)) {
    59                 alternate_class = 'alternate';
    60               }
    61               var employee_clock_in_time = "";
    62               if (item["employee_clock_in_time"] != null) {
    63                 employee_clock_in_time = item["employee_clock_in_time"];
    64               }
    65               var employee_clock_out_time = "";
    66               if (item["employee_clock_out_time"] != null) {
    67                 employee_clock_out_time = item["employee_clock_out_time"];
    68               }
    69               var shift_sum = "";
    70               if (item["shift_sum"]) {
    71                 shift_sum = item["shift_sum"];
    72               }
    73  
    74               reportHtml +=
    75                 '<tr class="' + alternate_class + '">' +
    76                 '<td>' + item["last_name"] + ', ' + item["first_name"] + '</td>' +
    77                 '<td>' + employee_clock_in_time + '</td>' +
    78                 '<td>' + employee_clock_out_time + '</td>' +
    79                 '<td>' + shift_sum + '</td>' +
    80                 '</tr>';
    81             });
    82             reportHtml += '</tbody>' +
    83               '</table>';
    84  
    85             var shift_total_time = "0";
    86             if (data["shifts"]["shift_total_time"]) {
    87               shift_total_time = data["shifts"]["shift_total_time"];
    88             }
    89  
    90             var wage_total = "0";
    91             var wage_total_row = "";
    92             if (data["shifts"]["wage_total"]){
    93               wage_total = data["shifts"]["wage_total"];
    94             }
    95  
    96             if (wage_enabled == "enabled"){
    97               wage_total_row = '<strong>' + timeClockAdminAjax.WageTotal + ': </strong>' + wage_total + '<br />'
    98             }
    99  
    100             reportHtml += '<div class="controlDiv">' +
    101               '<strong>' + timeClockAdminAjax.TotalShifts + ': </strong>' + data["shifts"]["shift_count"] + '<br />' +
    102               '<strong>' + timeClockAdminAjax.TotalShiftTime + ': </strong>' + shift_total_time + '<br />' +
    103               wage_total_row +
    104               '<hr>' +
    105               '</div>';
    106             jQuery("#aio-reports-results").html(reportHtml);
    107             jQuery("#aio-reports-results").show();
    108           }
    109         }
    110       });
     117      }
    111118    });
    112  
    113119  });
    114  
    115   function editClockTime(type) {
    116     if (type == "in") {
    117       jQuery("#clock_in").show("fast");
    118     }
    119     if (type == "out") {
    120       jQuery("#clock_out").show("fast");
    121     }
     120
     121});
     122
     123function editClockTime(type) {
     124  if (type == "in") {
     125    jQuery("#clock_in").show("fast");
    122126  }
    123  
    124   function editEmployee() {
    125     jQuery("#employee_id").show("fast");
     127  if (type == "out") {
     128    jQuery("#clock_out").show("fast");
    126129  }
    127  
    128   function isEven(number) {
    129     if (number % 2 == 0) {
    130       return true;
    131     }  // even
    132     else {
    133       return false;
    134     } // odd
    135   }
    136  
    137   function getProPopup(element) {
    138     jQuery(".getProButton").hide("fast")
    139     var count = jQuery(element).attr("data-count")
    140     var title = jQuery(" #featureTitle-" + count).html()
    141     var img = jQuery(" #featureImage-" + count).attr("src")
    142     var description = jQuery(" #featureDesc-" + count).html()
    143  
    144     jQuery("#aio_modal_image").html('<img class="aioModalImage" src="' + img + '">')
    145     jQuery("#aio_modal_title").html('<h2>' + title + '</h2>')
    146     jQuery("#aio_modal_description").html('<p>' + description + '</p>')
    147     tb_show("", "#TB_inline?width=1000&height=650&inlineId=aio-modal-window-id");
    148     jQuery(".getProButton").show("fade")
    149   }
     130}
     131
     132function editEmployee() {
     133  jQuery("#employee_id").show("fast");
     134}
     135
     136function isEven(number) {
     137  if (number % 2 == 0) {
     138    return true;
     139  }  // even
     140  else {
     141    return false;
     142  } // odd
     143}
     144
     145function getProPopup(element) {
     146  jQuery(".getProButton").hide("fast")
     147  var count = jQuery(element).attr("data-count")
     148  var title = jQuery(" #featureTitle-" + count).html()
     149  var img = jQuery(" #featureImage-" + count).attr("src")
     150  var description = jQuery(" #featureDesc-" + count).html()
     151
     152  jQuery("#aio_modal_image").html('<img class="aioModalImage" src="' + img + '">')
     153  jQuery("#aio_modal_title").html('<h2>' + title + '</h2>')
     154  jQuery("#aio_modal_description").html('<p>' + description + '</p>')
     155  tb_show("", "#TB_inline?width=1000&height=650&inlineId=aio-modal-window-id");
     156  jQuery(".getProButton").show("fade")
     157}
     158
     159function createTimeClockPage(element) {
     160  var admin_action = jQuery(element).attr("data-admin-action");
     161  var nonce = jQuery('input[name="time-clock-nonce"]').val()
     162  jQuery.ajax({
     163    type: "post",
     164    dataType: "json",
     165    url: timeClockAdminAjax.ajaxurl,
     166    data: {
     167      action: "aio_time_clock_lite_admin_js",
     168      admin_action: admin_action,
     169      nonce: nonce
     170    },
     171    success: function (data) {
     172      console.log(data)
     173      if (data['response'] == "success") {
     174        Swal.fire({
     175          icon: 'success',
     176          title: 'Success',
     177          html: data['message'],
     178          showCancelButton: true,
     179          confirmButtonText: timeClockAdminAjax.ViewPage,
     180          cancelButtonText: timeClockAdminAjax.Close,
     181          customClass: {
     182              actions: 'my-actions',
     183              confirmButton: 'order-1 right-gap' + (!data['page'] ? ' hidden-item' : ''),
     184              cancelButton: 'order-2'
     185          },
     186        }).then((result) => {
     187          var page_id = data['page_id'] ? data['page_id'] : null;
     188          var page_link = data['link'] ? data['link'] : null;
     189          if (page_link && page_id){
     190            var page_html = '<a href="' + page_link + '" class="button small_button" target="_blank"><i class="dashicons dashicons-search vmiddle"></i>&nbsp;' + timeClockAdminAjax.ViewPage + '</a>&nbsp;' +
     191            '<a href="/wp-admin/post.php?post=' + page_id + '&action=edit" class="button small_button" target="_blank"><i class="dashicons dashicons-edit vmiddle"></i>&nbsp; ' + timeClockAdminAjax.EditPage + '</a>';
     192            if (jQuery('#' + admin_action + '_td')){
     193              jQuery('#' + admin_action + '_td').html(page_html)
     194            }
     195          }
     196         
     197          if (result.isConfirmed) {
     198            if (page_link){
     199              window.location.href = page_link;
     200            }
     201            else{
     202              Toast.fire({
     203                icon: 'error',
     204                title: timeClockAdminAjax.PageLinkEmpty
     205              })
     206            }
     207          } else if (result.isDenied) {
     208           
     209          }
     210        })
     211      } else {
     212        Swal.fire({
     213          title: '<span class="time-clock-swal-header">' + data['message'] + '</span>',
     214          html: (data['response_html'] ? data['response_html'] : ''),
     215          icon: "error"
     216        })
     217      }
     218    },
     219    error: function (data) {
     220      Swal.fire({
     221        title: '<span class="time-clock-swal-header">' + data['message'] + '</span>',
     222        html: (data['response_html'] ? data['response_html'] : ''),
     223        icon: "error"
     224      })
     225    },
     226  });
     227}
  • aio-time-clock-lite/trunk/js/time-clock-lite.js

    r2856326 r3287366  
    2525            '<i>' + timeClockAjax.isClockedIn + '</i><br /><strong>' + timeClockAjax.clockInTime + ':</strong> ' +  response['employee_clock_in_time']
    2626          );
    27 
    2827        }
    2928        else{
  • aio-time-clock-lite/trunk/readme.txt

    r3286600 r3287366  
    342342
    3433431. Fixed security issues
     344
     3452025-5-4 - Version 1.3.326
     346
     3471. Fixed security issues
     3482. Improved UI
Note: See TracChangeset for help on using the changeset viewer.