Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

created hm tea tally and hm overtime

  • Loading branch information...
commit 006ba7ffd57cf1cf70baa2e34a2bc32d5bcd736e 1 parent b0e0ce6
@tcrsavage tcrsavage authored
View
269 wp-content/plugins/hm-holidays/hm-holidays.php
@@ -10,8 +10,6 @@
define( 'HMH_PATH', dirname( __FILE__ ) . '/' );
define( 'HMH_URL', str_replace( ABSPATH, site_url( '/' ), HMH_PATH ) );
-
-
/**
* hmh_prepare_plugin function.
*
@@ -46,12 +44,27 @@ function hmh_prepare_plugin() {
add_action( 'admin_menu', function() {
- add_menu_page( 'Holidays', 'Holidays', 'read', 'holidays', 'hmh_my_holidays_page' );
- add_submenu_page( 'holidays', 'Users', 'Users', 'administrator', 'users', 'hmh_all_holidays_page' );
+ if ( current_user_can( 'administrator' ) && get_user_meta( get_current_user_id(), 'hmh_active', true ) ) {
+
+ add_menu_page( 'Holidays', 'Holidays', 'read', 'holidays', 'hmh_holidays_page' );
+ add_submenu_page( 'holidays', 'Users', 'Users', 'administrator', 'holidays_users', 'hmh_all_holidays_page' );
+
+ add_action ( 'load-holidays_page_holidays_users', 'hmh_enqueue_styles' );
+ }
+
+ elseif ( current_user_can( 'administrator' ) ) {
+
+ add_menu_page( 'Holidays', 'Holidays', 'read', 'holidays', 'hmh_all_holidays_page' );
+ }
+
+ elseif( get_user_meta( get_current_user_id(), 'hmh_active', true ) ) {
+
+ add_menu_page( 'Holidays', 'Holidays', 'read', 'holidays', 'hmh_holidays_page' );
+ }
+
} );
add_action( 'load-toplevel_page_holidays', 'hmh_enqueue_styles');
- add_action ( 'load-holidays_page_users', 'hmh_enqueue_styles' );
}
add_action( 'init', 'hmh_prepare_plugin' );
@@ -124,11 +137,17 @@ function hmh_show_single_user_holidays( $user_id = 0 ) {
* @access public
* @return void
*/
-function hmh_my_holidays_page () {
+function hmh_holidays_page () {
?>
<div class="wrap">
+ <?php if ( isset( $_GET['booking-done'] ) ): ?>
+
+ <div class="updated message"><p>Your Holiday has been successfully booked!</p></div>
+
+ <?php endif; ?>
+
<div id="icon-users" class="icon32"><br></div><h2>My Holidays</h2>
<div class="clearfix"></div>
@@ -137,79 +156,18 @@ function hmh_my_holidays_page () {
</div>
<div class="widefat hmh">
-
- <form method="post">
-
- <table class="form-table">
- <tr>
- <td colspan="3"><h2 class="block">Book a Holiday</h2></td>
- </tr>
-
- <tr>
- <th>
- <label for="hmh_start_date">The Date
- </label></th>
- <td>
- <input type="text" placeholder="yyyy-mm-dd" name="hmh_holiday_start_date" id="hmh_holiday_start_date" value="" class="regular-text" /><br />
- <span class="description">The date that you wish to start your holiday, don't include weekends</span>
- </td>
- <td></td>
- </tr>
-
- <tr>
- <th>
- <label for="hmh_offset">How Long
- </label></th>
- <td>
- <input type="text" placeholder="days" name="hmh_holiday_duration" id="hmh_holiday_duration" value="" class="regular-text" /><br />
- <span class="description">The amount of time you wish to take off (in days), don't include weekends</span>
- </td>
- <td></td>
- </tr>
-
- <tr>
- <th>
- <label for="hmh_offset">Description
- </label></th>
- <td>
- <textarea class="widefat" placeholder="Description" name="hmh_holiday_description" id="hmh_holiday_description" value="" class="regular-text"></textarea><br />
- <span class="description">(Optional) Make a note of where you are going/what you are doing</span>
- </td>
- <td class="hmh-button">
- <input class="button-primary hmh" type="submit" value="Book it" />
- </td>
- </tr>
-
- </table>
- </form>
- </div>
+ <?php hmh_booking_form(); ?>
+ </div>
+
+ <div class="widefat hmh">
+ <?php hmh_history( get_current_user_id() ); ?>
+ </div>
+
</div>
<?php
}
/**
- * hmh_add_holiday function.
- *
- * @access public
- * @return void
- */
-function hmh_add_holiday() {
-
- if ( ! isset( $_POST ) || ! isset( $_POST['hmh_holiday_start_date'] ) || ! isset( $_POST['hmh_holiday_duration'] ) || ! $_POST['hmh_holiday_start_date'] || ! $_POST['hmh_holiday_duration'] )
- return;
-
- $user_id = ( isset( $_POST['hmh_user_id'] ) ) ? (int) $_POST['hmh_user_id'] : get_current_user_id();
-
- $user = new HMH_User ( $user_id );
-
- $description = ( $_POST['hmh_holiday_description'] ) ? $_POST['hmh_holiday_description'] : 'No Description Provided';
-
- $user->book_holiday( $_POST['hmh_holiday_start_date'], $_POST['hmh_holiday_duration'] . ' days', $description );
-
-}
-add_action( 'admin_init', 'hmh_add_holiday' );
-
-/**
* hmh_all_holidays_page function.
*
* @access public
@@ -219,7 +177,7 @@ function hmh_all_holidays_page() {
$users = get_users( array(
- 'meta_key' => 'hmh_employment_start',
+ 'meta_key' => 'hmh_active',
'meta_compare' => '>',
'meta_value' => 0,
@@ -245,6 +203,148 @@ function hmh_all_holidays_page() {
}
+function hmh_booking_form() {
+
+ ?>
+ <form method="post">
+
+ <table class="form-table">
+ <tr>
+ <td colspan="3"><h2 class="block">Book a Holiday</h2></td>
+ </tr>
+
+ <tr>
+ <th>
+ <label for="hmh_start_date">The Date
+ </label></th>
+ <td>
+ <input type="text" placeholder="yyyy-mm-dd" name="hmh_holiday_start_date" id="hmh_holiday_start_date" value="" class="regular-text" /><br />
+ <span class="description">The date that you wish to start your holiday, don't include weekends</span>
+ </td>
+ <td></td>
+ </tr>
+
+ <tr>
+ <th>
+ <label for="hmh_offset">How Long
+ </label></th>
+ <td>
+ <input type="text" placeholder="days" name="hmh_holiday_duration" id="hmh_holiday_duration" value="" class="regular-text" /><br />
+ <span class="description">The amount of time you wish to take off (in days), don't include weekends</span>
+ </td>
+ <td></td>
+ </tr>
+
+ <tr>
+ <th>
+ <label for="hmh_offset">Description
+ </label></th>
+ <td>
+ <textarea class="widefat" placeholder="Description" name="hmh_holiday_description" id="hmh_holiday_description" value="" class="regular-text"></textarea><br />
+ <span class="description">(Optional) Make a note of where you are going/what you are doing</span>
+ </td>
+ <td class="hmh-button">
+ <input class="button-primary hmh" type="submit" value="Book it" />
+ </td>
+ </tr>
+
+ </table>
+ </form>
+ <?php
+}
+
+/**
+ * hmh_history function.
+ *
+ * @access public
+ * @param mixed $user_id
+ * @return void
+ */
+function hmh_history( $user_id ) {
+
+ $posts = get_posts( array(
+
+ 'post_type' => 'holiday',
+ 'author' => $user_id,
+
+ ) ); ?>
+
+ <table class="hmh_history">
+ <tbody>
+ <tr>
+ <td clospan="3"><h2 class="block">My Holiday History</h2></td>
+ <td></td>
+ </tr>
+
+ <?php if ( ! $posts ): ?>
+
+ <tr>
+ <td colspan="2">No History</td>
+ </tr>
+
+ <?php endif; ?>
+
+ <?php foreach ( (array) $posts as $post ):
+
+ $date = date( 'l \t\h\e j \o\f F Y', (int) get_post_meta( $post->ID, 'hmh_holiday_start', true ) );
+ $duration = ( (int) get_post_meta( $post->ID, 'hmh_holiday_duration', true ) / strtotime( '1 day', 0 ) );
+ ?>
+
+ <tr>
+ <td class="hmh-date"><?php echo $date; ?></td>
+
+ <td>
+ <span><?php echo $duration; ?> days</span><br />
+ <span>&quot;<?php echo $post->post_content;?>&quot;</span> <br />
+ </td>
+ </tr>
+
+ <?php endforeach; ?>
+ </tbody>
+ </table>
+ <?php
+}
+
+/**
+ * hmh_add_holiday function.
+ *
+ * @access public
+ * @return void
+ */
+function hmh_add_holiday() {
+
+ if ( ! isset( $_POST ) || ! isset( $_POST['hmh_holiday_start_date'] ) || ! isset( $_POST['hmh_holiday_duration'] ) || ! $_POST['hmh_holiday_start_date'] || ! $_POST['hmh_holiday_duration'] )
+ return;
+
+ $user_id = ( isset( $_POST['hmh_user_id'] ) ) ? (int) $_POST['hmh_user_id'] : get_current_user_id();
+
+ try{
+
+ $user = new HMH_User ( $user_id );
+
+ $description = ( $_POST['hmh_holiday_description'] ) ? $_POST['hmh_holiday_description'] : 'No Description Provided';
+
+ $user->book_holiday( $_POST['hmh_holiday_start_date'], $_POST['hmh_holiday_duration'] . ' days', $description );
+
+ }catch ( Exception $e ) {
+
+ add_action( 'toplevel_page_holidays', function () use ( $e ) {
+ ?>
+
+ <div class="updated message"><p>Error: <?php var_export( $e ); ?></p></div>
+
+ <?php
+ } );
+
+ return;
+ }
+
+ wp_redirect( add_query_arg( 'booking-done', 'true', wp_get_referer( ) ) );
+
+ exit;
+}
+add_action( 'admin_init', 'hmh_add_holiday' );
+
/**
* hmh_add_admin_user_edit_fields function.
*
@@ -260,6 +360,17 @@ function hmh_add_admin_user_edit_fields( $user ) {
?>
<h3>HM Holidays Settings</h3>
<table class="form-table">
+
+ <tr>
+ <th>
+ <label for="hmh_start_date">Enable HM Holidays for this user
+ </label></th>
+ <td>
+ <input type="checkbox" value="1" name="hmh_active" id="hmh_active" <?php checked( get_the_author_meta( 'hmh_active', $user->ID, true ) ); ?> class="regular-text" /><br />
+ <span class="description">Allow this user to view their available holidays and book holidays in</span>
+ </td>
+ </tr>
+
<tr>
<th>
<label for="hmh_start_date">Employment Started
@@ -305,7 +416,7 @@ function hmh_add_admin_user_edit_fields( $user ) {
*/
function hmh_save_admin_user_edit_fields( $user_id ) {
- if ( ! current_user_can( 'administrator', $user_id ) )
+ if ( ! current_user_can( 'administrator' ) )
return false;
if ( isset( $_POST['hmh_start_date'] ) )
@@ -315,7 +426,11 @@ function hmh_save_admin_user_edit_fields( $user_id ) {
update_user_meta( $user_id, 'hmh_holidays_offset', strtotime( $_POST['hmh_offset'] . ' days', 0 ) );
if ( isset( $_POST['hmh_per_year'] ) )
- update_user_meta( $user_id, 'hmh_holidays_per_year', strtotime( $_POST['hmh_per_year'] . ' days', 0 ) );
+ update_user_meta( $user_id, 'hmh_holidays_per_year', strtotime( $_POST['hmh_per_year'] . ' days', 0 ) );
+
+ if ( isset( $_POST['hmh_active'] ) )
+ update_user_meta( $user_id, 'hmh_active', (int) $_POST['hmh_active'] );
+
}
add_action( 'edit_user_profile_update', 'hmh_save_admin_user_edit_fields' );
add_action( 'personal_options_update', 'hmh_save_admin_user_edit_fields' );
View
38 wp-content/plugins/hm-holidays/hmh-styles.css
@@ -1,42 +1,36 @@
+.hmh-user-details { float: left; }
+
+.hmh.widefat tr td { padding-right: 10px; border-top-color: #F9F9F9; }
-.hmh-body { background-color: #E0E0E0; position: relative; margin: 8px 0; font-family: Tahoma; }
-
-.hmh-h2 { font-size: 30px; font-weight: bold; margin: 20px 0 0 0; }
-
-.hmh-main-wrap { width: 90%; max-width: 1500px; margin-left: auto; margin-right: auto; background-color: white; }
-
-.hmh-header-wrap { width: 100%; position: absolute; height: 100px; top: 100px; left: 0; background-color: #666; border-top: 1px solid #555; border-bottom: 1px solid #444; }
-
-.hmh-header { width: 80%; max-width: 1500px; margin-left: auto; margin-right: auto; text-align: right; line-height: 80px; padding-right: 10px; }
+.hmh td.hmh-button { vertical-align: bottom;}
-.hmh-content { width: 90%; padding: 230px 5% 20px 5%; -webkit-box-shadow: 0px 0px 2px 2px #ccc; -moz-box-shadow: 0px 0px 2px 2px #ccc; box-shadow: 0px 0px 2px 2px #ccc; -webkit-border-radius: 3px; -moz-border-radius: 3px; border-radius: 3px; }
+.hmh-chart-wrap { float: right; }
-.hmh-user-details { float: left; }
-
-.hmh.widefat tr td { padding-right: 10px; border-top-color: #F9F9F9; }
+.hmh.widefat { margin-top: 10px; }
-.hmh td.hmh-button { vertical-align: bottom;}
+.hmh.widefat>h1 { margin: 20px 0 5px 0; padding-left: 10px; }
-.hmh-chart-wrap { float: right; }
+.form-table { margin-bottom: 0px; }
-.hmh.widefat { margin-top: 10px; }
+.hmh.button-primary { margin: 5px 5px 5px 0; float: right; }
-.hmh.widefat>h1 { margin: 20px 0 5px 0; padding-left: 10px; }
+.clearfix { clear: both; }
-.form-table { margin-bottom: 0px; }
+.hmh-date {width: 30%}
-.hmh.button-primary { margin: 5px 5px 5px 0; float: right; }
+.hmh_history { width: 100%; }
-.clearfix { clear: both; }
+.hmh table tr:last-child td,
+.hmh table tr:last-child th { border-bottom: none; }
@media ( max-width: 900px ) {
- .hmh-main-wrap { width: 98%; }
+ .hmh-main-wrap { width: 98%; }
}
@media ( max-width: 640px ) {
- .hmh-chart-wrap { width: 68%; margin-left: 32%; }
+ .hmh-chart-wrap { width: 68%; margin-left: 32%; }
}
View
3  wp-content/plugins/hm-holidays/hmh-user-class.php
@@ -210,6 +210,9 @@ function book_holiday ( $start_date, $duration, $description ) {
$post_id = wp_insert_post( $post );
+ if ( is_wp_error( $post_id ) || ! $post_id )
+ throw new Exception ( 'Error creating new post: ' . var_export( $post_id ) );
+
update_post_meta( $post_id, 'hmh_holiday_start', $start_date_int );
update_post_meta( $post_id, 'hmh_holiday_end', ( $start_date_int + $duration_int ) );
update_post_meta( $post_id, 'hmh_holiday_duration', $duration_int );
View
481 wp-content/plugins/hm-overtime/hm-overtime.php
@@ -0,0 +1,481 @@
+<?php
+/*
+Plugin Name: HM OverTime
+Description: A simple Overtime Tracker - Clone of HM Holidays
+Version: 0.1
+Author: Human Made Limited
+Author URI: http://hmn.md/
+*/
+
+define( 'HMOT_PATH', dirname( __FILE__ ) . '/' );
+define( 'HMOT_URL', str_replace( ABSPATH, site_url( '/' ), HMOT_PATH ) );
+
+
+
+/**
+ * hmot_prepare_plugin function.
+ *
+ * @access public
+ * @return void
+ */
+function hmot_prepare_plugin() {
+
+ register_post_type( 'overtime',
+ array(
+ 'labels' => array(
+ 'name' => __( 'Overtime' ),
+ 'singular_name' => __( 'Overtime' ),
+ 'add_new' => __( 'Add New' ),
+ 'add_new_item' => __( 'Add New Overtime' ),
+ 'edit' => __( 'Overtime' ),
+ 'edit_item' => __( 'Edit Overtime' ),
+ 'new_item' => __( 'New Overtime' ),
+ 'view' => __( 'View Overtime' ),
+ 'view_item' => __( 'View Overtime' ),
+ 'search_items' => __( 'Search Overtime' ),
+ 'not_found' => __( 'No Overtime Found' ),
+ 'not_found_in_trash' => __( 'No Overtime found in Trash' ),
+ 'parent' => __( 'Overtime' ),
+ ),
+ 'show_ui' => true,
+ 'has_archive' => false
+ )
+ );
+
+ require_once( HMOT_PATH . 'hmot-user-class.php' );
+
+ add_action( 'admin_menu', function() {
+
+ if ( current_user_can( 'administrator' ) && get_user_meta( get_current_user_id(), 'hmot_active', true ) ) {
+
+ add_menu_page( 'Overtime', 'Overtime', 'read', 'overtime', 'hmot_overtime_page' );
+ add_submenu_page( 'overtime', 'Users', 'Users', 'administrator', 'overtime_users', 'hmot_all_overtime_page' );
+
+ add_action ( 'load-overtime_page_overtime_users', 'hmot_enqueue_styles' );
+ }
+
+ elseif ( current_user_can( 'administrator' ) ) {
+
+ add_menu_page( 'Overtime', 'Overtime', 'read', 'overtime', 'hmot_all_overtime_page' );
+ }
+
+ elseif( get_user_meta( get_current_user_id(), 'hmot_active', true ) ) {
+
+ add_menu_page( 'Overtime', 'Overtime', 'read', 'overtime', 'hmot_overtime_page' );
+ }
+
+ } );
+
+ add_action( 'load-toplevel_page_overtime', 'hmot_enqueue_styles');
+
+}
+add_action( 'init', 'hmot_prepare_plugin' );
+
+/**
+ * hmot_enqueue_styles function.
+ *
+ * @access public
+ * @return void
+ */
+function hmot_enqueue_styles() {
+
+ wp_enqueue_style( 'hmot-styles', HMOT_URL . 'hmot-styles.css' );
+}
+
+/**
+ * hmot_show_single_user_overtime function.
+ * lets test some outputting!
+ * @access public
+ * @return object
+ */
+function hmot_show_single_user_overtime( $user_id = 0 ) {
+
+ if ( ! $user_id )
+ $user_id = get_current_user_id();
+
+ if ( ! $user_id )
+ return;
+
+ $user = new HMOT_User( $user_id );
+
+ ?>
+ <table class="hmot-user-details">
+
+ <tbody>
+
+ <tr>
+ <td><h2>Pending Overtime Hours</h2></td>
+ <td><h2><?php echo hmot_in_hours( $user->get_pending_overtime() ); ?> Hours</h2></td>
+ </tr>
+
+ <tr>
+ <td><h3>Pending Overtime Payment</h3></td>
+ <td><h3><?php echo $user->get_pending_payment(); ?></h3></td>
+ </tr>
+
+ <tr>
+ <td><h3>Net Overtime Recorded<h3></td>
+ <td><h3><?php echo hmot_in_hours( $user->get_total_overtime() ); ?></h3></td>
+ </tr>
+
+ <tr>
+ <td><h3>Net Overtime Payments<h3></td>
+ <td><h3><?php echo $user->get_total_payment(); ?></h3></td>
+ </tr>
+
+ </tbody>
+
+ </table>
+
+ <div class="hmot-chart-wrap"><?php //hmot_show_pie_chart( $user->get_holiday_time_avaliable(), $user->get_total_time_taken(), $user_id ); ?></div>
+
+ <div class="clearfix"></div>
+
+ <?php
+
+ return $user;
+}
+
+/**
+ * hmot_my_overtime_page function.
+ *
+ * @access public
+ * @return void
+ */
+function hmot_overtime_page () {
+
+ ?>
+ <div class="wrap">
+
+ <div id="icon-users" class="icon32"><br></div><h2>My Overtime</h2>
+ <div class="clearfix"></div>
+
+ <?php if ( isset( $_GET['logging-done'] ) ): ?>
+
+ <div class="updated message"><p>Your Overtime has been successfully Logged!</p></div>
+
+ <?php endif; ?>
+
+ <div class="widefat hmot">
+ <?php hmot_show_single_user_overtime(); ?>
+ </div>
+
+ <div class="widefat hmot">
+ <?php hmot_booking_form(); ?>
+ </div>
+
+ <div class="widefat hmot">
+ <?php hmot_history( get_current_user_id() ); ?>
+ </div>
+
+ </div>
+ <?php
+}
+
+/**
+ * hmot_all_overtime_page function.
+ *
+ * @access public
+ * @return void
+ */
+function hmot_all_overtime_page() {
+
+ $users = get_users( array(
+
+ 'meta_key' => 'hmot_active',
+ 'meta_compare' => '>',
+ 'meta_value' => 0,
+
+ ) );
+
+ ?>
+ <div class="wrap">
+
+ <div id="icon-users" class="icon32"><br></div><h2>All Users' Overtime</h2>
+ <div class="clearfix"></div>
+
+ <?php foreach ( $users as $user ): ?>
+
+ <div class="widefat hmot">
+ <h1><?php echo $user->display_name; ?></h1>
+ <?php hmot_show_single_user_overtime( $user->ID ); ?>
+ </div>
+
+ <?php endforeach; ?>
+
+ </div>
+ <?php
+
+}
+
+function hmot_booking_form() {
+
+ ?>
+
+ <form method="post">
+
+ <table class="form-table">
+
+ <tr>
+ <td colspan="3"><h2 class="block">Log some overtime</h2></td>
+ </tr>
+
+ <tr>
+ <th>
+ <label for="hmot_offset">How Long
+ </label></th>
+ <td>
+ <input type="text" placeholder="1 hour 30 minutes" name="hmot_overtime_duration" id="hmot_overtime_duration" value="" class="regular-text" /><br />
+ <span class="description">The amount of overtime you have done ( e.g. 1 hour 40 minutes )</span>
+ </td>
+ <td></td>
+ </tr>
+
+ <tr>
+ <th>
+ <label for="hmot_offset">The Date
+ </label></th>
+ <td>
+ <input type="text" placeholder="yyyy-dd-mm" name="hmot_overtime_date" id="hmot_overtime_date" value="<?php echo date( 'Y-m-d', time() ); ?>" class="regular-text" /><br />
+ <span class="description">The date which you did the overtime work. </span>
+ </td>
+ <td></td>
+ </tr>
+
+ <tr>
+ <th>
+ <label for="hmot_offset">Description
+ </label></th>
+ <td>
+ <textarea class="widefat" placeholder="Description" name="hmot_overtime_description" id="hmot_overtime_description" value="" class="regular-text"></textarea><br />
+ <span class="description">(Optional) Make a note of what you did</span>
+ </td>
+ <td class="hmot-button">
+ <input class="button-primary hmot" type="submit" value="Log it" />
+ </td>
+ </tr>
+
+ </table>
+ </form>
+
+ <?php
+}
+
+/**
+ * hmot_history function.
+ *
+ * @access public
+ * @param mixed $user_id
+ * @return void
+ */
+function hmot_history( $user_id ) {
+
+ $posts = get_posts( array(
+
+ 'post_type' => 'overtime',
+ 'author' => $user_id,
+
+ ) ); ?>
+
+ <table class="hmot_history">
+ <tbody>
+ <tr>
+ <td clospan="3"><h2 class="block">My Overtime History</h2></td>
+ <td></td>
+ </tr>
+
+ <?php if ( ! $posts ): ?>
+
+ <tr>
+ <td colspan="2">No History</td>
+ </tr>
+
+ <?php endif; ?>
+
+ <?php foreach ( (array) $posts as $post ):
+
+ $date = date( 'l \t\h\e j\t\h \o\f F Y', (int) get_post_meta( $post->ID, 'hmot_date', true ) );
+ $duration = date( 'G \h\o\u\r\s i \m\i\n\s', (int) get_post_meta( $post->ID, 'hmot_duration', true ) )
+ ?>
+
+ <tr>
+ <td class="hmot-date"><?php echo $date; ?></td>
+
+ <td>
+ <span><?php echo $duration; ?></span><br />
+ <span>&quot;<?php echo $post->post_content;?>&quot;</span> <br />
+ </td>
+ </tr>
+
+ <?php endforeach; ?>
+ </tbody>
+ </table>
+ <?php
+}
+
+/**
+ * hmot_add_overtime function.
+ *
+ * @access public
+ * @return void
+ */
+function hmot_add_overtime() {
+
+ if ( ! isset( $_POST ) || ! isset( $_POST['hmot_overtime_date'] ) || ! isset( $_POST['hmot_overtime_duration'] ) || ! $_POST['hmot_overtime_date'] || ! $_POST['hmot_overtime_duration'] )
+ return;
+
+ $user_id = ( isset( $_POST['hmot_user_id'] ) ) ? (int) $_POST['hmot_user_id'] : get_current_user_id();
+
+
+ try{
+
+ $user = new HMOT_User ( $user_id );
+
+ $description = ( $_POST['hmot_overtime_description'] ) ? $_POST['hmot_overtime_description'] : 'No Description Provided';
+
+ $user->log_overtime( $_POST['hmot_overtime_date'], $_POST['hmot_overtime_duration'], $description );
+
+ }catch ( Exception $e ) {
+
+ add_action( 'toplevel_page_overtime', function () use ( $e ) {
+ ?>
+
+ <div class="updated message"><p>Error: <?php var_export( $e ); ?></p></div>
+
+ <?php
+ } );
+
+ return;
+ }
+
+ wp_redirect( add_query_arg( 'logging-done', 'true', wp_get_referer( ) ) );
+
+ exit;
+
+}
+add_action( 'admin_init', 'hmot_add_overtime' );
+
+/**
+ * hmot_add_admin_user_edit_fields function.
+ *
+ * @access public
+ * @param mixed $user
+ * @return void
+ */
+function hmot_add_admin_user_edit_fields( $user ) {
+
+ if ( ! current_user_can( 'administrator' ) )
+ return false;
+
+ ?>
+ <h3>HM Overtime Settings</h3>
+ <table class="form-table">
+ <tr>
+ <th>
+ <label for="hmot_start_date">Activate HMOT for this user
+ </label></th>
+ <td>
+ <input type="checkbox" name="hmot_active" id="hmot_active" value="1" class="regular-text" <?php checked( (bool) get_the_author_meta( 'hmot_active', $user->ID ) ); ?> /><br />
+ <span class="description">Allow this user to see and log their overtime and display them in the overtime list</span>
+ </td>
+ </tr>
+
+ <tr>
+ <th>
+ <label for="hmot_offset">User's annual salary
+ </label></th>
+ <td>
+ <input type="text" placeholder="20000" name="hmot_wage" id="hmot_wage" value="<?php echo get_the_author_meta( 'hmot_wage', $user->ID ); ?>" class="regular-text" /><br />
+ <span class="description">Their annual salary</span>
+ </td>
+ </tr>
+
+ </table>
+ <?php
+}
+add_action( 'edit_user_profile', 'hmot_add_admin_user_edit_fields' );
+add_action( 'show_user_profile', 'hmot_add_admin_user_edit_fields' );
+
+/**
+ * hmot_save_admin_user_edit_fields function.
+ *
+ * @access public
+ * @param mixed $user_id
+ * @return void
+ */
+function hmot_save_admin_user_edit_fields( $user_id ) {
+
+ if ( ! current_user_can( 'administrator' ) )
+ return false;
+
+ if ( isset( $_POST['hmot_active'] ) )
+ update_user_meta( $user_id, 'hmot_active', (int) $_POST['hmot_active'] );
+
+ if ( isset( $_POST['hmot_wage'] ) )
+ update_user_meta( $user_id, 'hmot_wage', str_replace( array( '.', '-', ',', ' ' ), '', $_POST['hmot_wage'] ) );
+}
+add_action( 'edit_user_profile_update', 'hmot_save_admin_user_edit_fields' );
+add_action( 'personal_options_update', 'hmot_save_admin_user_edit_fields' );
+
+/**
+ * hmot_show_pie_chart function.
+ *
+ * @access public
+ * @param mixed $value1
+ * @param mixed $value2
+ * @param int $user_id (default: 0)
+ * @return void
+ */
+function hmot_show_pie_chart( $value1, $value2, $user_id = 0 ) {
+
+ $value1 = ( hmot_in_days( $value1 ) > 0 ) ? hmot_in_days( $value1 ): 0;
+ $value2 = ( hmot_in_days( $value2 ) > 0 ) ? hmot_in_days( $value2 ) : 0;
+
+ ?>
+
+ <script type="text/javascript" src="https://www.google.com/jsapi"></script>
+ <script type="text/javascript">
+ google.load("visualization", "1", {packages:["corechart"]});
+ google.setOnLoadCallback(drawChart);
+ function drawChart() {
+ var data = new google.visualization.DataTable();
+ data.addColumn('string', 'Task');
+ data.addColumn('number', 'Hours per Day');
+ data.addRows([
+ ['Avaliable', <?php echo $value1; ?>],
+ ['Used', <?php echo $value2; ?>]
+ ]);
+
+ var options = {
+
+ legend: { position: 'none' },
+
+ chartArea: { width: '90%', height: '90%' },
+
+ pieSliceText: 'label',
+
+ backgroundColor: { fill: '#F9F9F9' }
+
+ };
+
+ var chart = new google.visualization.PieChart(document.getElementById('chart_div_<?php echo $user_id; ?>'));
+ chart.draw(data, options);
+ }
+ </script>
+
+ <div id="chart_div_<?php echo $user_id; ?>" style="width: 200px; height: 200px;"></div>
+ <?php
+}
+
+/**
+ * hmot_hours function.
+ *
+ * @access public
+ * @param mixed $timestamp
+ * @return float
+ */
+function hmot_in_hours( $timestamp ) {
+
+ return round ( ( $timestamp / strtotime( '1 hour', 0 ) ), 1 );
+
+}
View
39 wp-content/plugins/hm-overtime/hmot-styles.css
@@ -0,0 +1,39 @@
+
+.hmot-user-details { float: left; }
+
+.hmot.widefat tr td { padding-right: 10px; border-top-color: #F9F9F9; }
+
+.hmot td.hmot-button { vertical-align: bottom;}
+
+.hmot-chart-wrap { float: right; }
+
+.hmot.widefat { margin-top: 10px; }
+
+.hmot .padded { margin: 0 20px; }
+
+.hmot.widefat>h1 { margin: 20px 0 5px 0; padding-left: 10px; }
+
+.form-table { margin-bottom: 0px; }
+
+.hmot.button-primary { margin: 5px 5px 5px 0; float: right; }
+
+.clearfix { clear: both; }
+
+.hmot-date {width: 30%}
+
+.hmot_history { width: 100%; }
+
+.hmot table tr:last-child td,
+.hmot table tr:last-child th { border-bottom: none; }
+
+@media ( max-width: 900px ) {
+
+ .hmot-main-wrap { width: 98%; }
+
+}
+
+@media ( max-width: 640px ) {
+
+ .hmot-chart-wrap { width: 68%; margin-left: 32%; }
+
+}
View
151 wp-content/plugins/hm-overtime/hmot-user-class.php
@@ -0,0 +1,151 @@
+<?php
+
+/**
+ * HMOT_User class.
+ */
+class HMOT_User {
+
+ /**
+ * __construct function.
+ *
+ * @access public
+ * @param mixed $id
+ * @param bool $employment_start (default: false)
+ * @param bool $holidays_offset (default: false)
+ * @param bool $holidays_per_year (default: false)
+ * @return void
+ */
+ function __construct( $id, $employment_start = false, $holidays_offset = false, $holidays_per_year = false ){
+
+ $this->ID = $id;
+
+ try{
+
+ $this->grab_userdata();
+
+ }catch ( Exception $e ){
+
+ echo ( $e );
+ exit;
+ }
+ }
+
+ /**
+ * grab_userdata function.
+ *
+ * @access public
+ * @return array
+ */
+ function grab_userdata() {
+
+ $data = get_userdata( $this->ID );
+
+ if ( is_wp_error( $data ) || ! $data )
+ throw new Exception ( 'Error finding user' );
+
+ $this->data = $data->data;
+
+ return $data->data;
+ }
+
+ /**
+ * set_wage function.
+ *
+ * @access public
+ * @param int $date (default: 0)
+ * @return void
+ */
+ function set_wage( $wage = 0 ) {
+
+ if ( ! $wage )
+ return;
+
+ $wage_sanitized = str_replace( array( '.', '-', ',', ' ' ), '', $_POST['hmot_wage'] );
+
+ update_user_meta( $this->ID, 'hmot_wage', $date_sanitized );
+ }
+
+ /**
+ * get_wage function.
+ *
+ * @access public
+ * @return int
+ */
+ function get_wage() {
+
+ return $this->wage = (int) get_user_meta( $this->ID, 'hmot_wage', true );
+ }
+
+ /**
+ * get_total_overtime_hours function.
+ *
+ * @access public
+ * @return int
+ */
+ function get_total_overtime() {
+
+ return $this->total_taken = ( get_user_meta( $this->ID, 'hmot_running_total', true ) );
+ }
+
+ function get_total_payment() {
+
+ return $this->total_taken = ( get_user_meta( $this->ID, 'hmot_running_total_payment', true ) );
+ }
+
+ function get_pending_payment() {
+
+ return $this->total_taken = ( get_user_meta( $this->ID, 'hmot_pending_payment', true ) );
+ }
+
+ function get_pending_overtime() {
+
+ return $this->total_taken = ( get_user_meta( $this->ID, 'hmot_pending_overtime', true ) );
+ }
+
+ function get_overtime_wage_timestamp() {
+
+ return $this->hourly_overtime_wage = ( ( get_user_meta( $this->ID, 'hmot_wage', true ) * 2 ) / ( 52 * 40 * 3600 ) );
+ }
+
+ function add_to_user_meta( $user_id, $meta_key, $addition ) {
+
+ update_user_meta( $user_id, $meta_key, ( (int) get_user_meta( $user_id, $meta_key, true ) + (int) $addition ) );
+ }
+
+ /**
+ * log_overtime function.
+ *
+ * @access public
+ * @param mixed $start_date
+ * @param mixed $duration
+ * @return int
+ */
+ function log_overtime ( $date, $duration, $description ) {
+
+ $date_int = strtotime( $date );
+ $duration_int = strtotime( $duration, 0 );
+
+ $post = array(
+ 'post_author' => $this->ID,
+ 'post_content' => stripslashes( $description ),
+ 'post_name' => sanitize_title( $this->data->display_name . '-' . $date . '-' . $duration ),
+ 'post_title' => $this->data->display_name . ' - ' . $date . ' - ' . $duration ,
+ 'post_type' => 'overtime',
+ 'post_status' => 'publish'
+ );
+
+ $post_id = wp_insert_post( $post );
+
+ update_post_meta( $post_id, 'hmot_date', $date_int );
+ update_post_meta( $post_id, 'hmot_duration', $duration_int );
+
+ $this->add_to_user_meta( $this->ID, 'hmot_running_total', $duration_int );
+ $this->add_to_user_meta( $this->ID, 'hmot_running_total_payment', ( $duration_int * $this->get_overtime_wage_timestamp() ) );
+
+ $this->add_to_user_meta( $this->ID, 'hmot_pending_payment', ( $duration_int * $this->get_overtime_wage_timestamp() ) );
+ $this->add_to_user_meta( $this->ID, 'hmot_pending_overtime', $duration_int );
+
+ return $post_id;
+ }
+
+}
View
151 wp-content/plugins/hm-tea-tally/hm-tea-tally-class.php
@@ -0,0 +1,151 @@
+<?php
+
+/**
+ * HMOT_User class.
+ */
+class HM_Tea_Tally {
+
+ /**
+ * __construct function.
+ *
+ * @access public
+ * @param mixed $id
+ * @param bool $employment_start (default: false)
+ * @param bool $holidays_offset (default: false)
+ * @param bool $holidays_per_year (default: false)
+ * @return void
+ */
+ function __construct( ){
+
+ $this->grab_users();
+
+ }
+
+ /**
+ * grab_userdata function.
+ *
+ * @access public
+ * @return array
+ */
+ function grab_users() {
+
+ $users = get_users( array(
+
+ 'meta_key' => 'hmtt_active',
+ 'meta_compare' => '>',
+ 'meta_value' => 0,
+
+ ) );
+
+ foreach ( $users as $key => $user ){
+
+ $this->users[$user->ID] = $user;
+
+ $this->users[$user->ID]->name = ( $name = get_the_author_meta( 'first_name', $user->ID ) ) ? $name : $this->users[$user->ID]->display_name;
+ $this->users[$user->ID]->hmtt_offset = (int) get_user_meta( $user->ID, 'hmtt_offset', true );
+ $this->users[$user->ID]->hmtt_rolling_total = (int) get_user_meta( $user->ID, 'hmtt_rolling_total', true );
+ $this->users[$user->ID]->hmtt_total = $this->users[$user->ID]->hmtt_rolling_total + (int) get_user_meta( $user->ID, 'hmtt_offset', true );
+ }
+
+ if ( isset( $this->users ) )
+ return $this->users;
+
+ return false;
+ }
+
+ /**
+ * set_wage function.
+ *
+ * @access public
+ * @param int $date (default: 0)
+ * @return void
+ */
+ function set_offset( $offset = 0 ) {
+
+ if ( ! $offset )
+ return;
+
+ update_user_meta( $this->ID, 'hmtt_offset', $offset );
+ }
+
+ /**
+ * add_tea function.
+ *
+ * @access public
+ * @return int
+ */
+ function add_tea( $user_id ) {
+
+ update_user_meta( $user_id, 'hmtt_rolling_total', (int) get_user_meta( $user_id, 'hmtt_rolling_total', true ) + 1 );
+
+ $this->users[$user_id]->hmtt_rolling_total++;
+ $this->users[$user_id]->hmtt_total++;
+
+ return;
+ }
+
+ /**
+ * remove_tea function.
+ *
+ * @access public
+ * @return int
+ */
+ function remove_tea( $user_id ) {
+
+ update_user_meta( $user_id, 'hmtt_rolling_total', ( (int) get_user_meta( $user_id, 'hmtt_rolling_total', true ) - 1 ) );
+
+ $this->users[$user_id]->hmtt_rolling_total--;
+ $this->users[$user_id]->hmtt_total--;
+ return;
+ }
+
+ /**
+ * do_a_round function.
+ *
+ * @access public
+ * @param mixed $start_date
+ * @param mixed $duration
+ * @return int
+ */
+ function do_a_round ( $who_made = 0, $who_received = array() ) {
+
+ $data = $this->users[$who_made]->name . ' made tea for: <br />';
+
+ foreach ( $who_received as $key => $person ){
+
+ if ( $who_made == $person ) {
+
+ unset( $who_received[$key] );
+
+ continue;
+ }
+
+ $data .= $this->users[$person]->name . ' (' . $this->users[$person]->hmtt_total . ') <br />';
+
+ $this->add_tea( $person );
+
+ $this->remove_tea( $who_made );
+ }
+
+ $people = ( count( $who_received ) > 1 ) ? count ( $who_received ) . ' people' : count ( $who_received ) . ' person';
+
+ $post = array(
+ 'post_author' => $who_made,
+ 'post_content' => $data,
+ 'post_name' => sanitize_title( $this->users[$who_made]->name . ' made a round for ' . $people ),
+ 'post_title' => $this->users[$who_made]->name . ' made a round for ' . $people,
+ 'post_type' => 'tea-round',
+ 'post_status' => 'publish'
+ );
+
+ $post_id = wp_insert_post( $post );
+
+ update_post_meta( $post_id, 'hmtt_who_received', $who_received );
+ update_post_meta( $post_id, 'hmtt_who_made', $who_made );
+ update_post_meta( $post_id, 'hmtt_who_received_count', count ( $who_received ) );
+ update_post_meta( $post_id, 'hmtt_date', time() );
+
+ return $post_id;
+ }
+
+}
View
347 wp-content/plugins/hm-tea-tally/hm-tea-tally.php
@@ -0,0 +1,347 @@
+<?php
+/*
+Plugin Name: HM Tea Tally
+Description: A simple Overtime Tracker - Clone of HM Holidays
+Version: 0.1
+Author: Human Made Limited
+Author URI: http://hmn.md/
+*/
+
+define( 'HMTT_PATH', dirname( __FILE__ ) . '/' );
+define( 'HMTT_URL', str_replace( ABSPATH, site_url( '/' ), HMTT_PATH ) );
+
+
+
+/**
+ * hmtt_prepare_plugin function.
+ *
+ * @access public
+ * @return void
+ */
+function hmtt_prepare_plugin() {
+
+ register_post_type( 'tea-round',
+ array(
+ 'labels' => array(
+ 'name' => __( 'Tea Round' ),
+ 'singular_name' => __( 'Tea Round' ),
+ 'add_new' => __( 'Add New' ),
+ 'add_new_item' => __( 'Add New Tea Round' ),
+ 'edit' => __( 'Overtime' ),
+ 'edit_item' => __( 'Edit Tea Round' ),
+ 'new_item' => __( 'New Tea Round' ),
+ 'view' => __( 'View Tea Round' ),
+ 'view_item' => __( 'View Tea Round' ),
+ 'search_items' => __( 'Search Tea Round' ),
+ 'not_found' => __( 'No Tea Round Found' ),
+ 'not_found_in_trash' => __( 'No Tea Round found in Trash' ),
+ 'parent' => __( 'Tea Round' ),
+ ),
+ 'show_ui' => true,
+ 'has_archive' => false
+ )
+ );
+
+ require_once( HMTT_PATH . 'hm-tea-tally-class.php' );
+
+ add_action( 'admin_menu', function() {
+
+ add_menu_page( 'Tea Tally', 'Tea Tally', 'read', 'tea-tally', 'hmtt_tally_page' );
+
+ } );
+
+ add_action( 'load-toplevel_page_tea-tally', 'hmtt_enqueue_styles' );
+}
+add_action( 'init', 'hmtt_prepare_plugin' );
+
+/**
+ * hmtt_enqueue_styles function.
+ *
+ * @access public
+ * @return void
+ */
+function hmtt_enqueue_styles() {
+
+ wp_enqueue_style( 'hmtt-styles', HMTT_URL . 'hmtt-styles.css' );
+}
+
+/**
+ * hmtt_all_overtime_page function.
+ *
+ * @access public
+ * @return void
+ */
+function hmtt_tally_page() {
+
+ $tally = new HM_Tea_Tally();
+
+ ?>
+ <div class="wrap">
+
+ <div id="icon-users" class="icon32"><br></div><h2>HM Tea Tally</h2>
+ <div class="clearfix"></div>
+
+ <?php if ( isset( $_GET['round-done'] ) ): ?>
+
+ <div class="updated message"><p>Your tea round has been successfully logged!</p></div>
+
+ <?php endif; ?>
+
+ <div class="widefat hmtt">
+ <?php hmtt_show_tally( $tally ); ?>
+ </div>
+
+ <div class="widefat hmtt">
+ <?php hmtt_logging_form( $tally ); ?>
+ </div>
+
+ <div class="widefat hmtt">
+ <?php hmtt_history(); ?>
+ </div>
+
+ </div>
+ <?php
+
+}
+
+function hmtt_show_tally( $tally ) {
+?>
+ <table class="hmtt-tally">
+
+ <tbody>
+
+ <tr>
+ <td clospan="3"><h2 class="block">The Tally</h2></td>
+ <td></td>
+ </tr>
+
+ <?php foreach ( $tally->users as $user ): ?>
+
+ <?php $count = ( $user->hmtt_total < 0 ) ? ( $user->hmtt_total * -1 ) : $user->hmtt_total; ?>
+ <?php $class = ( $user->hmtt_total < 0 ) ? 'hmtt-in-credit' : 'hmtt-in-debt'; ?>
+
+ <tr>
+ <td class="hmtt-name"><h3 class="block"><?php echo $user->name; ?></h3></td>
+ <td>
+ <ul>
+ <?php for ( $i = 0; $i < $count; $i++ ): ?>
+ <li class="<?php echo $class; ?>"></li>
+ <?php endfor; ?>
+ </ul>
+ </td>
+ </tr>
+
+ <?php endforeach; ?>
+
+ </tbody>
+ </table>
+
+<?php
+}
+
+function hmtt_logging_form( $tally ) {
+
+ ?>
+
+ <form method="post">
+
+ <table class="form-table">
+
+ <tr>
+ <td colspan="3"><h2 class="block">Make a round of tea</h2></td>
+ </tr>
+
+ <tr>
+ <th>
+ <label for="hmtt_offset">Who made it?
+ </label></th>
+ <td>
+
+ <select name="hmtt_who_made_it">
+
+ <?php foreach ( $tally->users as $user ): ?>
+
+ <option value="<?php echo $user->ID; ?>" <?php selected( get_current_user_id(), $user->ID ); ?>><?php echo $user->name; ?></option>
+
+ <?php endforeach; ?>
+
+ </select><br />
+
+ <span class="description"></span>
+
+ </td>
+ <td></td>
+ </tr>
+
+ <tr>
+ <th>
+ <label>Tea receivers</label>
+ </th>
+ <td class="hmtt_receivers">
+
+ <?php foreach ( $tally->users as $user ): ?>
+
+ <input name="hmtt_tea_receivers[]" id="tea_receiver_<?php echo $user->ID; ?>" type="checkbox" value="<?php echo $user->ID; ?>" />
+ <label for="tea_receiver_<?php echo $user->ID; ?>"><?php echo $user->name; ?></label><br />
+
+ <?php endforeach; ?>
+
+ </td>
+ <td class="hmtt-button">
+ <input class="button-primary hmtt" type="submit" value="Do it!" />
+ </td>
+ </tr>
+
+ </table>
+ </form>
+
+ <?php
+}
+
+/**
+ * hmtt_history function.
+ *
+ * @access public
+ * @param mixed $user_id
+ * @return void
+ */
+function hmtt_history( ) {
+
+ $posts = get_posts( array(
+
+ 'post_type' => 'tea-round',
+ 'posts_per_page' => 20,
+ ) ); ?>
+
+ <table class="hmtt_history">
+ <tbody>
+ <tr>
+ <td clospan="3"><h2 class="block">Tea Round History</h2></td>
+ <td></td>
+ </tr>
+
+ <?php if ( ! $posts ): ?>
+
+ <tr>
+ <td colspan="2">No History</td>
+ </tr>
+
+ <?php endif; ?>
+
+ <?php foreach ( (array) $posts as $post ):
+
+ $date = date( 'l \t\h\e j\t\h \o\f F Y', (int) get_post_meta( $post->ID, 'hmtt_date', true ) );
+ ?>
+
+ <tr>
+ <td class="hmtt-date"><?php echo $date; ?></td>
+
+ <td>
+ <span><?php echo $post->post_title; ?></span><br />
+ </td>
+ </tr>
+
+ <?php endforeach; ?>
+ </tbody>
+ </table>
+ <?php
+}
+
+/**
+ * hmtt_add_overtime function.
+ *
+ * @access public
+ * @return void
+ */
+function hmtt_add_round() {
+
+ if ( ! isset( $_POST ) || ! isset( $_POST['hmtt_who_made_it'] ) || ! isset( $_POST['hmtt_tea_receivers'] ) || ! $_POST['hmtt_who_made_it'] || ! $_POST['hmtt_tea_receivers'] )
+ return;
+
+ try{
+
+ $user = new HM_Tea_Tally();
+
+ $user->do_a_round( (int) $_POST['hmtt_who_made_it'], (array) $_POST['hmtt_tea_receivers'] );
+
+ }catch ( Exception $e ) {
+
+ add_action( 'toplevel_page_tea-tally', function () use ( $e ) {
+ ?>
+
+ <div class="updated message"><p>Error: <?php var_export( $e ); ?></p></div>
+
+ <?php
+ } );
+
+ return;
+ }
+
+ wp_redirect( add_query_arg( 'round-done', 'true', wp_get_referer( ) ) );
+
+ exit;
+
+}
+add_action( 'admin_init', 'hmtt_add_round' );
+
+/**
+ * hmtt_add_admin_user_edit_fields function.
+ *
+ * @access public
+ * @param mixed $user
+ * @return void
+ */
+function hmtt_add_admin_user_edit_fields( $user ) {
+
+ if ( ! current_user_can( 'administrator' ) )
+ return false;
+
+ ?>
+ <h3>HM Overtime Settings</h3>
+ <table class="form-table">
+ <tr>
+ <th>
+ <label for="hmtt_start_date">Activate HMTT for this user
+ </label></th>
+ <td>
+ <input type="checkbox" name="hmtt_active" id="hmtt_active" value="1" class="regular-text" <?php checked( (bool) get_the_author_meta( 'hmtt_active', $user->ID ) ); ?> /><br />
+ <span class="description">Add this user to the tally and allow them to see and log tea rounds</span>
+ </td>
+ </tr>
+
+ <tr>
+ <th>
+ <label for="hmtt_offset">Tea Tally Offset
+ </label></th>
+ <td>
+ <input type="text" placeholder="5" name="hmtt_offset" id="hmtt_offset" value="<?php echo get_the_author_meta( 'hmtt_offset', $user->ID ); ?>" class="regular-text" /><br />
+ <span class="description">Give this user an offset (cups of tea made for them before tracking)</span>
+ </td>
+ </tr>
+
+ </table>
+ <?php
+}
+add_action( 'edit_user_profile', 'hmtt_add_admin_user_edit_fields' );
+add_action( 'show_user_profile', 'hmtt_add_admin_user_edit_fields' );
+
+/**
+ * hmtt_save_admin_user_edit_fields function.
+ *
+ * @access public
+ * @param mixed $user_id
+ * @return void
+ */
+function hmtt_save_admin_user_edit_fields( $user_id ) {
+
+ if ( ! current_user_can( 'administrator' ) )
+ return false;
+
+ if ( isset( $_POST['hmtt_active'] ) )
+ update_user_meta( $user_id, 'hmtt_active', (int) $_POST['hmtt_active'] );
+
+ if ( isset( $_POST['hmtt_offset'] ) )
+ update_user_meta( $user_id, 'hmtt_offset', (int) $_POST['hmtt_offset'] );
+}
+add_action( 'edit_user_profile_update', 'hmtt_save_admin_user_edit_fields' );
+add_action( 'personal_options_update', 'hmtt_save_admin_user_edit_fields' );
View
49 wp-content/plugins/hm-tea-tally/hmtt-styles.css
@@ -0,0 +1,49 @@
+
+.hmtt.widefat tr td { padding-right: 10px; border-top-color: #F9F9F9; vertical-align: middle; }
+
+.hmtt td.hmtt-button { vertical-align: bottom; }
+
+.hmtt-chart-wrap { float: right; }
+
+.hmtt.widefat { margin-top: 10px; }
+
+.hmtt-tally { width: 100%; }
+
+.hmtt-tally .hmtt-name { width: 200px; }
+
+.hmtt .padded { margin: 0 20px; }
+
+.hmtt.widefat>h1 { margin: 20px 0 5px 0; padding-left: 10px; }
+
+.hmtt.button-primary { margin: 5px 5px 5px 0; float: right; }
+
+.clearfix { clear: both; }
+
+.hmtt-date {width: 30%}
+
+.hmtt_history { width: 100%; }
+
+.hmtt table tr:last-child td,
+.hmtt table tr:last-child th { border-bottom: none; }
+
+.hmtt .hmtt_receivers { line-height: 2; }
+
+.hmtt ul { list-style: none; padding-top: 15px; }
+
+.hmtt ul li { display: inline-block; width: 20px; height: 20px; background: url( 'hmtt-tea-cup.png' ) no-repeat 0px 0px; }
+
+.hmtt table tr .hmtt-button { vertical-align: bottom; padding-bottom: 10px; padding-top: 0px; }
+
+.hmtt li.hmtt-in-credit { background-position: 0 -25px; }
+
+@media ( max-width: 900px ) {
+
+ .hmtt-main-wrap { width: 98%; }
+
+}
+
+@media ( max-width: 640px ) {
+
+ .hmtt-chart-wrap { width: 68%; margin-left: 32%; }
+
+}
View
BIN  wp-content/plugins/hm-tea-tally/hmtt-tea-cup.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 006ba7f

Please sign in to comment.
Something went wrong with that request. Please try again.