Changeset 3287366
- Timestamp:
- 05/05/2025 04:57:07 AM (11 months ago)
- Location:
- aio-time-clock-lite
- Files:
-
- 114 added
- 7 edited
-
tags/1.3.326 (added)
-
tags/1.3.326/aio-employee-profile.php (added)
-
tags/1.3.326/aio-employees.php (added)
-
tags/1.3.326/aio-get-pro.php (added)
-
tags/1.3.326/aio-monitoring.php (added)
-
tags/1.3.326/aio-news.php (added)
-
tags/1.3.326/aio-report-wizard.php (added)
-
tags/1.3.326/aio-reports.php (added)
-
tags/1.3.326/aio-settings.php (added)
-
tags/1.3.326/aio-simple-report.php (added)
-
tags/1.3.326/aio-time-clock-box-content.php (added)
-
tags/1.3.326/aio-time-clock-lite-actions.php (added)
-
tags/1.3.326/aio-time-clock-lite-widgets.php (added)
-
tags/1.3.326/aio-time-clock-lite.php (added)
-
tags/1.3.326/css (added)
-
tags/1.3.326/css/aio-admin.css (added)
-
tags/1.3.326/css/aio-site.css (added)
-
tags/1.3.326/css/jquery-ui-1.8.23.css (added)
-
tags/1.3.326/css/jquery.datetimepicker.css (added)
-
tags/1.3.326/css/jquery.steps.css (added)
-
tags/1.3.326/css/layouts (added)
-
tags/1.3.326/css/layouts/widget (added)
-
tags/1.3.326/css/layouts/widget/default.css (added)
-
tags/1.3.326/css/sweetalert2.min.css (added)
-
tags/1.3.326/css/toastr.min.css (added)
-
tags/1.3.326/icon-256x256.png (added)
-
tags/1.3.326/images (added)
-
tags/1.3.326/images/AjaxLoader.gif (added)
-
tags/1.3.326/images/Bar Graph.png (added)
-
tags/1.3.326/images/Graph.png (added)
-
tags/1.3.326/images/add.png (added)
-
tags/1.3.326/images/ajax-loader2.gif (added)
-
tags/1.3.326/images/clock.png (added)
-
tags/1.3.326/images/clock_play.png (added)
-
tags/1.3.326/images/clock_stop.png (added)
-
tags/1.3.326/images/csvicon.jpg (added)
-
tags/1.3.326/images/double_dragon.jpg (added)
-
tags/1.3.326/images/download.png (added)
-
tags/1.3.326/images/employee.png (added)
-
tags/1.3.326/images/gear_3.gif (added)
-
tags/1.3.326/images/graph-sample.png (added)
-
tags/1.3.326/images/graph_pic.jpg (added)
-
tags/1.3.326/images/icon.png (added)
-
tags/1.3.326/images/icon16.png (added)
-
tags/1.3.326/images/logo.png (added)
-
tags/1.3.326/images/nertworks_logo.png (added)
-
tags/1.3.326/images/pro (added)
-
tags/1.3.326/images/pro/1-settings.png (added)
-
tags/1.3.326/images/pro/10-predefined-shifts.png (added)
-
tags/1.3.326/images/pro/11-extendable.png (added)
-
tags/1.3.326/images/pro/2-custom-roles.png (added)
-
tags/1.3.326/images/pro/3-manager-profile.png (added)
-
tags/1.3.326/images/pro/4-reports.png (added)
-
tags/1.3.326/images/pro/5-charts.png (added)
-
tags/1.3.326/images/pro/6-shift-views.png (added)
-
tags/1.3.326/images/pro/7-locations.png (added)
-
tags/1.3.326/images/pro/8-shift-info.png (added)
-
tags/1.3.326/images/pro/9-quick-pick.png (added)
-
tags/1.3.326/images/report_magnify.png (added)
-
tags/1.3.326/images/sadpuppy.jpg (added)
-
tags/1.3.326/images/search.png (added)
-
tags/1.3.326/images/sort_asc.png (added)
-
tags/1.3.326/images/sort_asc_disabled.png (added)
-
tags/1.3.326/images/sort_both.png (added)
-
tags/1.3.326/images/sort_desc.png (added)
-
tags/1.3.326/images/sort_desc_disabled.png (added)
-
tags/1.3.326/images/support.jpg (added)
-
tags/1.3.326/images/tablet.jpg (added)
-
tags/1.3.326/images/walking.gif (added)
-
tags/1.3.326/images/working.gif (added)
-
tags/1.3.326/images/wrench.png (added)
-
tags/1.3.326/images/xlsicon.jpg (added)
-
tags/1.3.326/js (added)
-
tags/1.3.326/js/jquery.datetimepicker.js (added)
-
tags/1.3.326/js/jquery.steps.min.js (added)
-
tags/1.3.326/js/sweetalert2.min.js (added)
-
tags/1.3.326/js/time-clock-lite-admin.js (added)
-
tags/1.3.326/js/time-clock-lite.js (added)
-
tags/1.3.326/js/toastr.min.js (added)
-
tags/1.3.326/languages (added)
-
tags/1.3.326/languages/aio-time-clock-lite-ar.mo (added)
-
tags/1.3.326/languages/aio-time-clock-lite-ar.po (added)
-
tags/1.3.326/languages/aio-time-clock-lite-es_MX.mo (added)
-
tags/1.3.326/languages/aio-time-clock-lite-es_MX.po (added)
-
tags/1.3.326/languages/aio-time-clock-lite-fr.mo (added)
-
tags/1.3.326/languages/aio-time-clock-lite-fr.po (added)
-
tags/1.3.326/languages/aio-time-clock-lite-fr_FR.mo (added)
-
tags/1.3.326/languages/aio-time-clock-lite-fr_FR.po (added)
-
tags/1.3.326/languages/aio-time-clock-lite-it.mo (added)
-
tags/1.3.326/languages/aio-time-clock-lite-it.po (added)
-
tags/1.3.326/languages/aio-time-clock-lite-ru.mo (added)
-
tags/1.3.326/languages/aio-time-clock-lite-ru.po (added)
-
tags/1.3.326/languages/aio-time-clock-lite-zh.mo (added)
-
tags/1.3.326/languages/aio-time-clock-lite-zh.po (added)
-
tags/1.3.326/languages/aio-time-clock-lite.pot (added)
-
tags/1.3.326/readme.txt (added)
-
tags/1.3.326/screenshot-1.png (added)
-
tags/1.3.326/screenshot-10.png (added)
-
tags/1.3.326/screenshot-11.png (added)
-
tags/1.3.326/screenshot-12.png (added)
-
tags/1.3.326/screenshot-13.png (added)
-
tags/1.3.326/screenshot-2.png (added)
-
tags/1.3.326/screenshot-3.png (added)
-
tags/1.3.326/screenshot-4.png (added)
-
tags/1.3.326/screenshot-5.png (added)
-
tags/1.3.326/screenshot-6.png (added)
-
tags/1.3.326/screenshot-7.png (added)
-
tags/1.3.326/screenshot-8.png (added)
-
tags/1.3.326/screenshot-9.png (added)
-
tags/1.3.326/templates (added)
-
tags/1.3.326/templates/department-section.php (added)
-
tags/1.3.326/templates/error.php (added)
-
tags/1.3.326/templates/time-clock-style1.php (added)
-
tags/1.3.326/templates/widget-content.php (added)
-
trunk/aio-settings.php (modified) (11 diffs)
-
trunk/aio-time-clock-lite-actions.php (modified) (47 diffs)
-
trunk/aio-time-clock-lite.php (modified) (1 diff)
-
trunk/css/aio-admin.css (modified) (7 diffs)
-
trunk/js/time-clock-lite-admin.js (modified) (1 diff)
-
trunk/js/time-clock-lite.js (modified) (1 diff)
-
trunk/readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
aio-time-clock-lite/trunk/aio-settings.php
r3286600 r3287366 1 1 <div class="wrap aio_admin_wrapper"> 2 <?php session_start(); ?>3 <?php4 $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 verification8 // - 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 ?>17 2 <?php $logo = plugins_url('/images/logo.png', __FILE__); ?> 18 3 <a href="https://codebangers.com" target="_blank"><img src="<?php echo esc_url($logo); ?>" style="width:15%;"></a> … … 24 9 <?php settings_errors(); ?> 25 10 <?php 26 $new_eprofile_id = null;27 11 $job = isset($_GET["job"]) ? sanitize_text_field($_GET["job"]) : null; 28 12 $current_user = wp_get_current_user(); … … 67 51 <?php 68 52 } 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->ID82 );83 // Insert the post into the database84 $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 <?php89 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 <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 <?php98 }99 }100 ?>101 </div>102 <?php103 }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' => 1114 );115 // Insert the post into the database116 $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 <?php121 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 <?php125 } 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 <?php131 }132 }133 ?>134 </div>135 <?php136 }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 }144 53 ?> 145 54 <h3><?php echo esc_attr_x('General Settings', 'aio-time-clock-lite'); ?></h3> … … 149 58 $options = get_option('nertworks-timeclock-settings-group'); 150 59 ?> 151 <table class="widefat fixed " cellspacing="0">60 <table class="widefat fixed time-clock-table" cellspacing="0"> 152 61 <tr class="alternate"> 153 62 <th scope="col" class="manage-column column-columnname"><strong><?php echo esc_attr_x('Company Name', 'aio-time-clock-lite'); ?>: </strong></th> … … 171 80 <tr class="alternate"> 172 81 <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"> 174 83 <?php 175 84 $tc_page = $this->aio_check_tc_shortcode_lite(); 176 85 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> <?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> <?php echo esc_attr_x('Edit Page', 'aio-time-clock-lite'); ?></a> 179 88 <?php } else { ?> 180 <?php echo esc_attr_x('Time Clock page not found. Would you like to create one', 'aio-time-clock-lite'); ?>? <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'); ?>? <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> 181 90 <?php 182 91 } … … 189 98 <tr> 190 99 <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"> 192 101 <?php 193 102 $eprofile_page = $this->check_eprofile_shortcode_lite(); 194 103 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> <?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> <?php echo esc_attr_x('Edit Page', 'aio-time-clock-lite'); ?></a> 197 106 <?php 198 107 } else { 199 108 ?> 200 <?php echo esc_attr_x('Employee Profile page not found. Would you like to create one', 'aio-time-clock-lite'); ?>? ? <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'); ?>? <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> 201 110 <?php 202 111 } … … 210 119 <th scope="col" class="manage-column column-columnname"><strong><?php echo esc_attr_x('Quick Pick Time Clock', 'aio-time-clock-lite');?>: </strong></th> 211 120 <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').' <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> ' . esc_attr_x('Pro', 'aio-time-clock-lite') . '</a>'; ?> 213 122 </td> 214 123 <td> … … 231 140 <th scope="col" class="manage-column column-columnname"><strong><?php echo esc_attr_x('Show Employee Avatar', 'aio-time-clock-lite'); ?>: </strong></th> 232 141 <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').' <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> ' . esc_attr_x('Pro', 'aio-time-clock-lite') . '</a>'; ?> 234 143 </td> 235 144 <td> … … 266 175 <th scope="col" class="manage-column column-columnname"><strong><?php echo esc_attr_x('Enable Location', 'aio-time-clock-lite'); ?>: </strong></th> 267 176 <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').' <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> ' . esc_attr_x('Pro', 'aio-time-clock-lite') . '</a>'; ?> 269 178 </td> 270 179 <td> … … 277 186 <th scope="col" class="manage-column column-columnname"><strong><?php echo esc_attr_x('Custom Roles', 'aio-time-clock-lite'); ?>: </strong></th> 278 187 <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').' <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> ' . esc_attr_x('Pro', 'aio-time-clock-lite') . '</a>'; ?> 280 189 </td> 281 190 <td> … … 286 195 </tr> 287 196 </table> 197 <input type="hidden" name="time-clock-nonce" id="time-clock-nonce" value="<?php echo wp_create_nonce("time-clock-nonce"); ?>"> 288 198 <?php submit_button(); ?> 289 199 </form> -
aio-time-clock-lite/trunk/aio-time-clock-lite-actions.php
r3286600 r3287366 2 2 class AIO_Time_Clock_Lite_Actions 3 3 { 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'; 6 6 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'; 9 9 public $widgets; 10 10 11 11 public function setup() 12 12 { 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']); 19 19 //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']); 22 22 //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']); 27 27 //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']); 37 37 38 38 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']); 40 40 } 41 41 42 42 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); 47 47 48 48 //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']); 61 61 62 62 //Get the widgets 63 if (! class_exists('AIO_Time_Clock_Lite_Widgets')) {63 if (! class_exists('AIO_Time_Clock_Lite_Widgets')) { 64 64 require_once plugin_dir_path(__FILE__) . 'aio-time-clock-lite-widgets.php'; 65 65 $this->widgets = new AIO_Time_Clock_Lite_Widgets(); 66 add_action('widgets_init', array($this, 'loadWidgets'));66 add_action('widgets_init', [$this, 'loadWidgets']); 67 67 } 68 68 … … 72 72 public function getVersion() 73 73 { 74 return "1.3.32 5";74 return "1.3.326"; 75 75 } 76 76 … … 81 81 'manager', 82 82 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, 87 87 'edit_others_posts' => true, 88 'publish_posts' => true,88 'publish_posts' => true, 89 89 'manage_categories' => true, 90 )90 ] 91 91 ); 92 92 … … 95 95 'volunteer', 96 96 esc_attr_x('Volunteer', 'aio-time-clock-lite'), 97 array(97 [ 98 98 'read' => true, 99 )99 ] 100 100 ); 101 101 … … 104 104 'employee', 105 105 esc_attr_x('Employee', 'aio-time-clock-lite'), 106 array(106 [ 107 107 'read' => true, 108 )108 ] 109 109 ); 110 110 … … 113 113 'time_clock_admin', 114 114 esc_attr_x('Time Clock Admin', 'aio-time-clock-lite'), 115 array(116 'read' => true, // Allows a user to read117 'create_shifts' => true, // Allows user to create new posts118 'edit_posts' => true, // Allows user to edit their own posts119 'edit_shifts' => true, // Allows user to edit their own posts120 'edit_others_posts' => true, // Allows user to edit others posts too121 'edit_others_shifts' => true, // Allows user to edit others posts too122 'publish_posts' => true, // Allows the user to publish posts123 'publish_shifts' => true, // Allows the user to publish posts124 'manage_categories' => true, // Allows user to manage post categories125 'edit_private_posts' => true, // Allows user to manage post categories126 'edit_private_shifts' => true, // Allows user to manage post categories127 'read_private_posts' => true, // Allows user to manage post categories128 'read_private_shifts' => true, // Allows user to manage post categories129 'edit_published_posts' => true, // Allows user to manage post categories115 [ 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 130 130 'edit_published_shifts' => true, // Allows user to manage post categories 131 )131 ] 132 132 ); 133 133 } … … 140 140 public function addMenuItem() 141 141 { 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']); 149 149 } 150 150 … … 158 158 159 159 //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()); 161 161 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']); 163 163 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', 165 166 'timeClockAjax', 166 167 $this->getTranslationStrings() … … 177 178 wp_enqueue_style('aio-tc-admin-style'); 178 179 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'); 179 186 180 187 //Scripts 181 188 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']); 185 196 wp_enqueue_script('aio_time_clock_lite_admin_js'); 186 197 wp_enqueue_script('aio_time_clock_lite_steps'); 187 198 188 wp_localize_script('aio_time_clock_lite_admin_js', 199 wp_localize_script( 200 'aio_time_clock_lite_admin_js', 189 201 'timeClockAdminAjax', 190 202 $this->getTranslationStrings() … … 229 241 { 230 242 $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)); 233 245 require_once "templates/time-clock-style1.php"; 234 246 } … … 237 249 { 238 250 $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)); 241 253 require_once "aio-employee-profile.php"; 242 254 } … … 245 257 { 246 258 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; 249 261 $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 } 277 294 } 278 295 } 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 ); 279 379 } 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 );354 380 } else { 355 381 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, 360 386 "clock_action" => $clock_action, 361 )387 ] 362 388 ); 363 389 } … … 370 396 { 371 397 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'); 376 402 $minutes = $dtF->diff($dtT)->format('%I'); 377 $hours = $hours + ($days * 24);403 $hours = $hours + ($days * 24); 378 404 return $hours . ":" . $minutes; 379 405 } else { … … 385 411 { 386 412 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); 389 419 $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 } 409 580 } else { 410 581 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 ] 419 588 ); 420 589 } … … 425 594 public function aio_tc_custom_post_shift_lite() 426 595 { 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'), 438 607 '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'], 452 621 'show_in_nav_menus' => false, 453 'supports' => false,454 );622 'supports' => false, 623 ]; 455 624 register_post_type('shift', $args); 456 625 } … … 458 627 public function aio_timeclock_admin_init_lite() 459 628 { 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); 462 631 } 463 632 … … 466 635 unset($columns['date']); 467 636 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'); 471 640 $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'); 473 642 return $columns; 474 643 } … … 477 646 { 478 647 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; 481 650 $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"; 483 652 if ($employee_clock_in_time != null && $employee_clock_out_time != null) { 484 653 $shift_sum = $this->secondsToTime($this->dateDifference($employee_clock_in_time, $employee_clock_out_time)); … … 512 681 global $wordpress; 513 682 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)) { 517 686 foreach ($terms as $term) { 518 687 if (is_object_in_term(intval($author_id), 'department', $term)) { … … 527 696 public function getShiftTotal($post_id) 528 697 { 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); 530 699 $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); 532 701 if ($employee_clock_in_time != null && $employee_clock_out_time != null) { 533 702 if (strtotime($employee_clock_in_time) > strtotime(0) && strtotime($employee_clock_out_time) > strtotime(0)) { … … 544 713 'shift_info_box', 545 714 esc_attr_x('Shift Info', 'aio-time-clock-lite'), 546 array($this, 'aio_shift_info_box_content'),715 [$this, 'aio_shift_info_box_content'], 547 716 'shift', 548 717 'normal', … … 553 722 public function aio_shift_info_box_content() 554 723 { 555 require_once ("aio-time-clock-box-content.php");724 require_once "aio-time-clock-box-content.php"; 556 725 } 557 726 … … 559 728 { 560 729 $selected = json_decode($selected); 561 $count = 0;562 $users = $this->getUsers();730 $count = 0; 731 $users = $this->getUsers(); 563 732 foreach ($users as $user) { 564 733 $active = ""; … … 566 735 $active = "selected"; 567 736 } 568 $user_id = isset($user["employee_id"]) ? intval($user["employee_id"]) : 0;737 $user_id = isset($user["employee_id"]) ? intval($user["employee_id"]) : 0; 569 738 $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"]) : ""; 571 740 echo '<option value="' . esc_attr($user_id) . '" ' . esc_attr($active) . '>' . esc_attr($user_first) . ", " . esc_attr($user_last) . '</option>'; 572 741 $count++; … … 576 745 public function getBuiltInRoles() 577 746 { 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']; 579 748 } 580 749 … … 587 756 public function aio_save_shift_meta_lite($post_id) 588 757 { 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; 590 759 $clock_out = (isset($_REQUEST['clock_out'])) ? sanitize_text_field($_REQUEST['clock_out']) : null; 591 760 592 if ($clock_in != null) {761 if ($clock_in != null) { 593 762 $clock_in = str_replace("/", "-", $clock_in); 594 763 update_post_meta($post_id, 'employee_clock_in_time', date($this->dateFormat, strtotime($clock_in))); 595 } 596 else{ 764 } else { 597 765 update_post_meta($post_id, 'employee_clock_in_time', null); 598 766 } 599 767 600 if ($clock_out != null) {768 if ($clock_out != null) { 601 769 $clock_out = str_replace("/", "-", $clock_out); 602 770 update_post_meta($post_id, 'employee_clock_out_time', date($this->dateFormat, strtotime($clock_out))); 603 } 604 else{ 771 } else { 605 772 update_post_meta($post_id, 'employee_clock_out_time', null); 606 773 } 607 774 608 775 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, 612 779 'post_author' => intval($_REQUEST['employee_id']), 613 );780 ]; 614 781 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']); 616 783 } 617 784 } … … 637 804 } 638 805 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 { 651 819 $value = str_replace('"', "", $value); 652 820 return sanitize_text_field($value); … … 655 823 public function aio_check_tc_shortcode_lite() 656 824 { 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(); 659 828 $content = get_the_content(); 660 829 if (has_shortcode($content, 'show_aio_time_clock_lite')) { … … 670 839 public function check_eprofile_shortcode_lite() 671 840 { 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(); 674 844 $content = get_the_content(); 675 845 if (has_shortcode($content, 'show_aio_employee_profile_lite')) { … … 685 855 { 686 856 $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)) { 691 861 if (is_array($user->roles) && $tc_page != null) { 692 862 if (array_intersect($roles, $user->roles)) { 693 863 return esc_url(get_permalink($tc_page)); 694 } 864 } 695 865 } 696 866 } … … 701 871 public function arrayDelete($del_val, $array) 702 872 { 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) { 706 876 if ($value == $del_value) { 707 877 unset($array[$key]); … … 710 880 } 711 881 } else { 712 foreach ($array as $key => $value) {882 foreach ($array as $key => $value) { 713 883 if ($value == $del_val) { 714 884 unset($array[$key]); … … 754 924 if ($start != null && $end != null) { 755 925 $start = sanitize_text_field($start); 756 $end = sanitize_text_field($end);926 $end = sanitize_text_field($end); 757 927 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(); 761 931 $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 +, too766 ($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 (???) 772 942 ); 773 943 return $diff_sec; … … 779 949 public function addTwoTimes($time1 = "00:00", $time2 = "00:00") 780 950 { 781 $times = array($time1, $time2);782 $hours = 0;783 $minutes = 0; 951 $times = [$time1, $time2]; 952 $hours = 0; 953 $minutes = 0; 784 954 $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; 808 974 } 809 975 return "{$hours}:{$minutes}"; … … 822 988 { 823 989 $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; 834 1001 $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); 837 1004 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)); 840 1007 $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 843 1010 if ($employee_clock_in_time != null && $employee_clock_out_time != null) { 844 1011 $shift_sum = $this->secondsToTime($this->dateDifference($employee_clock_in_time, $employee_clock_out_time)); 845 if (! $this->isNull($wage)){1012 if (! $this->isNull($wage)) { 846 1013 $decimal_total = $this->TimeToDecimal($shift_sum); 847 1014 $wage_total += (floatval($wage) * floatval($decimal_total)); 848 } 1015 } 849 1016 $shift_total_time = $this->addTwoTimes($shift_total_time, $shift_sum); 850 1017 } 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), 855 1023 "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 ] 860 1028 ); 861 1029 $count++; 862 1030 } 863 1031 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, 869 1037 "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) 876 1044 { 877 1045 $timeArr = explode(':', $time); 878 $decTime = ($timeArr[0] *60) + ($timeArr[1]);879 1046 $decTime = ($timeArr[0] * 60) + ($timeArr[1]); 1047 880 1048 return ($decTime / 60); 881 1049 } … … 888 1056 public function isNull($string) 889 1057 { 890 if ($string == null || $string == '') {1058 if ($string == null || $string == '') { 891 1059 return true; 892 } 893 else{ 1060 } else { 894 1061 return false; 895 1062 } … … 917 1084 public function getCurrentTime() 918 1085 { 919 $timezone = null;920 $current_time = null;1086 $timezone = null; 1087 $current_time = null; 921 1088 $timezone_option = get_option('aio_timeclock_time_zone'); 922 1089 if ($timezone_option != null) { 923 1090 date_default_timezone_set($timezone_option); 924 1091 $current_time = date($this->mysqlDateFormat); 925 $time_type = "timezone option";1092 $time_type = "timezone option"; 926 1093 } else { 927 1094 $timezone = 'UTC'; 928 1095 date_default_timezone_set($timezone); 929 1096 $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", 935 1102 "timezone_option" => $timezone_option, 936 "current_time" => $current_time,937 "time_type" => $time_type,938 "timezone" => $timezone939 );1103 "current_time" => $current_time, 1104 "time_type" => $time_type, 1105 "timezone" => $timezone, 1106 ]; 940 1107 } 941 1108 … … 976 1143 public function isTimeMachine($date) 977 1144 { 978 $now = date("Y-m-d h:i:s A");1145 $now = date("Y-m-d h:i:s A"); 979 1146 $end_date = date("Y-m-d", strtotime(date("Y-m-d", strtotime($now)) . " - 10 years")); 980 1147 return (strtotime($date) <= strtotime($end_date)); 981 } 1148 } 982 1149 983 1150 public function aio_lite_update_department_count($terms, $taxonomy) … … 990 1157 991 1158 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]); 993 1160 do_action('edited_term_taxonomy', $term, $taxonomy); 994 1161 } … … 997 1164 public function aio_lite_register_user_taxonomy() 998 1165 { 999 1000 1166 register_taxonomy( 1001 1167 'department', 1002 1168 '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'), 1016 1182 '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' => [ 1021 1187 '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' => [ 1025 1191 'manage_terms' => 'edit_users', // Using 'edit_users' cap to keep this simple. 1026 'edit_terms' => 'edit_users',1192 'edit_terms' => 'edit_users', 1027 1193 'delete_terms' => 'edit_users', 1028 1194 'assign_terms' => 'read', 1029 ),1195 ], 1030 1196 'update_count_callback' => 'aio_lite_update_department_count', // Use a custom function to update the count. 1031 )1197 ] 1032 1198 ); 1033 1199 } … … 1038 1204 $tax = get_taxonomy('department'); 1039 1205 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)) { 1041 1207 return false; 1042 1208 } 1043 1209 1044 if (isset($_POST['department'])) {1210 if (isset($_POST['department'])) { 1045 1211 $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); 1047 1213 } 1048 1214 … … 1087 1253 $tax = get_taxonomy('department'); 1088 1254 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)) { 1090 1256 return false; 1091 1257 } 1092 1258 1093 if (isset($_POST['department'])) {1259 if (isset($_POST['department'])) { 1094 1260 $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); 1096 1262 } 1097 1263 … … 1160 1326 public function getUsers() 1161 1327 { 1162 $users = array();1163 $blog_id = get_current_blog_id();1328 $users = []; 1329 $blog_id = get_current_blog_id(); 1164 1330 $built_in_roles = $this->getBuiltInRoles(); 1165 1331 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' => '', 1173 1339 '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 ]; 1187 1353 $your_users = get_users($args); 1188 1354 foreach ($your_users as $user) { 1189 1355 array_push( 1190 1356 $users, 1191 array(1357 [ 1192 1358 "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 ] 1198 1364 ); 1199 1365 } … … 1203 1369 public function getEmployeeName($employee_id) 1204 1370 { 1205 $full_name = null;1371 $full_name = null; 1206 1372 $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)); 1209 1375 1210 1376 if (($first_name == null || $last_name == null)) { … … 1224 1390 public function getDepartment($user_id) 1225 1391 { 1226 $department = "";1227 $user_groups = wp_get_object_terms($user_id, 'department', array('fields' => 'all_with_object_id')); // Get user group detail1392 $department = ""; 1393 $user_groups = wp_get_object_terms($user_id, 'department', ['fields' => 'all_with_object_id']); // Get user group detail 1228 1394 foreach ($user_groups as $user_gro) { 1229 1395 $department = $user_gro->name; // Get current user group name … … 1235 1401 public function aio_lite_edit_user_department_section($user) 1236 1402 { 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"> 1242 1409 <span>' . esc_attr_x('Working', 'aio-time-clock') . '</span> 1243 1410 </div>'; … … 1246 1413 public function getTranslationStrings() 1247 1414 { 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'), 1257 1424 '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 ]; 1271 1443 } 1272 1444 1273 1445 public function getProFeatures() 1274 1446 { 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'), 1278 1450 "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'), 1283 1455 "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'), 1288 1460 "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'), 1293 1465 "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'), 1298 1470 "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'), 1303 1475 "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'), 1308 1480 "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'), 1313 1485 "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'), 1318 1490 "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'), 1323 1495 "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'), 1328 1500 "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 ]; 1332 1504 return $features; 1333 1505 } -
aio-time-clock-lite/trunk/aio-time-clock-lite.php
r3286600 r3287366 6 6 * Author: Codebangers 7 7 * Author URI: https://codebangers.com 8 * Version: 1.3.32 58 * Version: 1.3.326 9 9 */ 10 10 class AIO_Time_Clock_Plugin_Lite -
aio-time-clock-lite/trunk/css/aio-admin.css
r2845181 r3287366 64 64 font-family: "Roboto", sans-serif; 65 65 font-weight: 900; 66 } 67 68 .time-clock-admin-button{ 69 margin-top: -5px !important; 66 70 } 67 71 … … 327 331 table.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 { 328 332 cursor: pointer; 329 *cursor: hand;330 333 background-repeat: no-repeat; 331 334 background-position: center right; … … 572 575 position: relative; 573 576 clear: both; 574 *zoom: 1;575 577 zoom: 1; 576 578 } … … 610 612 text-decoration: none !important; 611 613 cursor: pointer; 612 *cursor: hand;613 614 color: #6b6363 !important; 614 615 border: 1px solid transparent; … … 711 712 712 713 .dataTables_wrapper .dataTables_scroll div.dataTables_scrollBody { 713 *margin-top: -1px;714 714 -webkit-overflow-scrolling: touch; 715 715 } … … 732 732 .dataTables_wrapper.no-footer div.dataTables_scrollHead table.dataTable, .dataTables_wrapper.no-footer div.dataTables_scrollBody>table { 733 733 border-bottom: none; 734 } 735 736 .hidden-item{ 737 display: none; 734 738 } 735 739 … … 742 746 } 743 747 748 .time-clock-swal-header{ 749 font-size: 22px; 750 line-height: .2; 751 padding-bottom: 20px; 752 753 } 754 744 755 @media screen and (max-width: 767px) { 745 756 .dataTables_wrapper .dataTables_info, .dataTables_wrapper .dataTables_paginate { -
aio-time-clock-lite/trunk/js/time-clock-lite-admin.js
r2856326 r3287366 1 var Toast = Swal.mixin({ 2 toast: true, 3 position: 'top-end', 4 showConfirmButton: false, 5 timer: 3000 6 }); 7 1 8 jQuery(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 } 6 24 }); 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(); 17 116 } 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 } 111 118 }); 112 113 119 }); 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 123 function editClockTime(type) { 124 if (type == "in") { 125 jQuery("#clock_in").show("fast"); 122 126 } 123 124 function editEmployee() { 125 jQuery("#employee_id").show("fast"); 127 if (type == "out") { 128 jQuery("#clock_out").show("fast"); 126 129 } 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 132 function editEmployee() { 133 jQuery("#employee_id").show("fast"); 134 } 135 136 function isEven(number) { 137 if (number % 2 == 0) { 138 return true; 139 } // even 140 else { 141 return false; 142 } // odd 143 } 144 145 function 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 159 function 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> ' + timeClockAdminAjax.ViewPage + '</a> ' + 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> ' + 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 25 25 '<i>' + timeClockAjax.isClockedIn + '</i><br /><strong>' + timeClockAjax.clockInTime + ':</strong> ' + response['employee_clock_in_time'] 26 26 ); 27 28 27 } 29 28 else{ -
aio-time-clock-lite/trunk/readme.txt
r3286600 r3287366 342 342 343 343 1. Fixed security issues 344 345 2025-5-4 - Version 1.3.326 346 347 1. Fixed security issues 348 2. Improved UI
Note: See TracChangeset
for help on using the changeset viewer.