| |
| <?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| add_action( 'show_user_profile', 'kic_add_hr_staff_profile_fields', 12 );
|
| add_action( 'edit_user_profile', 'kic_add_hr_staff_profile_fields', 12 );
|
|
|
| function kic_add_hr_staff_profile_fields( $user ) {
|
|
|
| wp_nonce_field( 'kic_hr_profile_update', 'kic_hr_profile_nonce' );
|
| ?>
|
|
|
| <!-- HR STAFF FIELDS - COLLAPSIBLE SECTION -->
|
| <div id="kic-hr-fields-wrapper" class="postbox" style="margin-top: 40px;">
|
| <div class="postbox-header" style="cursor: pointer;">
|
| <h2 class="hndle" style="margin: 0; padding: 12px; border-bottom: 2px solid #00a32a;">
|
| <span class="dashicons dashicons-arrow-down-alt2" style="margin-right: 8px;"></span>
|
| HR Staff Information
|
| </h2>
|
| </div>
|
| <div class="inside" id="kic-hr-fields-content">
|
| <p style="background: #dff7e8; border-left: 4px solid #00a32a; padding: 10px; margin: 10px 0 20px;">
|
| <strong>Note:</strong> These are comprehensive HR compliance fields for staff members. All fields are optional.
|
| </p>
|
|
|
| <h3>Employment Classification & Status</h3>
|
| <table class="form-table" role="presentation">
|
| <tr>
|
| <th><label for="kic_employment_status">Employment Status</label></th>
|
| <td>
|
| <select name="kic_employment_status" id="kic_employment_status" class="regular-text">
|
| <?php
|
| $emp_status = get_user_meta( $user->ID, 'kic_employment_status', true );
|
| $status_options = array(
|
| '' => '-- Select Status --',
|
| 'full_time_employee' => 'Full-time Employee',
|
| 'part_time_employee' => 'Part-time Employee',
|
| 'contractor' => 'Contractor',
|
| 'volunteer_contractor' => 'Volunteer Contractor',
|
| 'intern_contractor' => 'Intern Contractor',
|
| 'intern_employee' => 'Intern Employee',
|
| 'temporary' => 'Temporary'
|
| );
|
| foreach ( $status_options as $value => $label ) {
|
| echo '<option value="' . esc_attr( $value ) . '" ' . selected( $emp_status, $value, false ) . '>' . esc_html( $label ) . '</option>';
|
| }
|
| ?>
|
| </select>
|
| <p class="description">Required: Employment classification</p>
|
| </td>
|
| </tr>
|
| <tr>
|
| <th><label for="kic_flsa_classification">FLSA Classification</label></th>
|
| <td>
|
| <select name="kic_flsa_classification" id="kic_flsa_classification" class="regular-text">
|
| <?php
|
| $flsa = get_user_meta( $user->ID, 'kic_flsa_classification', true );
|
| $flsa_options = array(
|
| '' => '-- Select Classification --',
|
| 'exempt' => 'Exempt',
|
| 'non_exempt' => 'Non-Exempt',
|
| 'na' => 'N/A (Contractor)'
|
| );
|
| foreach ( $flsa_options as $value => $label ) {
|
| echo '<option value="' . esc_attr( $value ) . '" ' . selected( $flsa, $value, false ) . '>' . esc_html( $label ) . '</option>';
|
| }
|
| ?>
|
| </select>
|
| <p class="description">Critical for overtime compliance (select N/A for contractors)</p>
|
| </td>
|
| </tr>
|
| <tr>
|
| <th><label for="kic_job_title">Job Title/Position</label></th>
|
| <td>
|
| <input type="text"
|
| name="kic_job_title"
|
| id="kic_job_title"
|
| value="<?php echo esc_attr( get_user_meta( $user->ID, 'kic_job_title', true ) ); ?>"
|
| class="regular-text" />
|
| <p class="description">Current role/position title</p>
|
| </td>
|
| </tr>
|
| <tr>
|
| <th><label for="kic_department">Department/Division</label></th>
|
| <td>
|
| <input type="text"
|
| name="kic_department"
|
| id="kic_department"
|
| value="<?php echo esc_attr( get_user_meta( $user->ID, 'kic_department', true ) ); ?>"
|
| class="regular-text" />
|
| <p class="description">Department or division assignment</p>
|
| </td>
|
| </tr>
|
| <tr>
|
| <th><label for="kic_supervisor">Supervisor/Manager</label></th>
|
| <td>
|
| <input type="text"
|
| name="kic_supervisor"
|
| id="kic_supervisor"
|
| value="<?php echo esc_attr( get_user_meta( $user->ID, 'kic_supervisor', true ) ); ?>"
|
| class="regular-text" />
|
| <p class="description">Direct manager or supervisor name</p>
|
| </td>
|
| </tr>
|
| </table>
|
|
|
| <h3>Contact Information</h3>
|
| <table class="form-table" role="presentation">
|
| <tr>
|
| <th><label for="kic_full_name">Full Name</label></th>
|
| <td>
|
| <input type="text"
|
| name="kic_full_name"
|
| id="kic_full_name"
|
| value="<?php echo esc_attr( get_user_meta( $user->ID, 'kic_full_name', true ) ); ?>"
|
| class="regular-text" />
|
| <p class="description">Full legal name</p>
|
| </td>
|
| </tr>
|
| <tr>
|
| <th><label for="kic_work_email">Work Email</label></th>
|
| <td>
|
| <input type="email"
|
| name="kic_work_email"
|
| id="kic_work_email"
|
| value="<?php echo esc_attr( get_user_meta( $user->ID, 'kic_work_email', true ) ); ?>"
|
| class="regular-text" />
|
| <p class="description">Official work email address</p>
|
| </td>
|
| </tr>
|
| <tr>
|
| <th><label for="kic_phone">Phone Number</label></th>
|
| <td>
|
| <input type="tel"
|
| name="kic_phone"
|
| id="kic_phone"
|
| value="<?php echo esc_attr( get_user_meta( $user->ID, 'kic_phone', true ) ); ?>"
|
| class="regular-text" />
|
| <p class="description">Primary contact number</p>
|
| </td>
|
| </tr>
|
| <tr>
|
| <th><label for="kic_phone_secondary">Secondary Phone</label></th>
|
| <td>
|
| <input type="tel"
|
| name="kic_phone_secondary"
|
| id="kic_phone_secondary"
|
| value="<?php echo esc_attr( get_user_meta( $user->ID, 'kic_phone_secondary', true ) ); ?>"
|
| class="regular-text" />
|
| <p class="description">Alternative or work phone</p>
|
| </td>
|
| </tr>
|
| </table>
|
|
|
| <h3>Address Information</h3>
|
| <table class="form-table" role="presentation">
|
| <tr>
|
| <th><label for="kic_address_street">Street Address</label></th>
|
| <td>
|
| <input type="text"
|
| name="kic_address_street"
|
| id="kic_address_street"
|
| value="<?php echo esc_attr( get_user_meta( $user->ID, 'kic_address_street', true ) ); ?>"
|
| class="regular-text" />
|
| </td>
|
| </tr>
|
| <tr>
|
| <th><label for="kic_address_street_2">Address Line 2</label></th>
|
| <td>
|
| <input type="text"
|
| name="kic_address_street_2"
|
| id="kic_address_street_2"
|
| value="<?php echo esc_attr( get_user_meta( $user->ID, 'kic_address_street_2', true ) ); ?>"
|
| class="regular-text" />
|
| <p class="description">Apartment, suite, unit, etc.</p>
|
| </td>
|
| </tr>
|
| <tr>
|
| <th><label for="kic_address_city">City</label></th>
|
| <td>
|
| <input type="text"
|
| name="kic_address_city"
|
| id="kic_address_city"
|
| value="<?php echo esc_attr( get_user_meta( $user->ID, 'kic_address_city', true ) ); ?>"
|
| class="regular-text" />
|
| </td>
|
| </tr>
|
| <tr>
|
| <th><label for="kic_address_state">State</label></th>
|
| <td>
|
| <input type="text"
|
| name="kic_address_state"
|
| id="kic_address_state"
|
| value="<?php echo esc_attr( get_user_meta( $user->ID, 'kic_address_state', true ) ); ?>"
|
| class="regular-text"
|
| placeholder="e.g., MD"
|
| maxlength="2"
|
| style="width: 100px;" />
|
| </td>
|
| </tr>
|
| <tr>
|
| <th><label for="kic_address_zip">ZIP Code</label></th>
|
| <td>
|
| <input type="text"
|
| name="kic_address_zip"
|
| id="kic_address_zip"
|
| value="<?php echo esc_attr( get_user_meta( $user->ID, 'kic_address_zip', true ) ); ?>"
|
| class="regular-text"
|
| pattern="[0-9]{5}(-[0-9]{4})?"
|
| placeholder="12345 or 12345-6789"
|
| style="width: 150px;" />
|
| </td>
|
| </tr>
|
| <tr>
|
| <th><label for="kic_address_country">Country</label></th>
|
| <td>
|
| <select name="kic_address_country" id="kic_address_country" class="regular-text">
|
| <?php
|
| $saved_country = get_user_meta( $user->ID, 'kic_address_country', true );
|
| $selected_country = $saved_country ?: 'US';
|
| ?>
|
| <option value="US" <?php selected( $selected_country, 'US' ); ?>>United States</option>
|
| <option value="CA" <?php selected( $selected_country, 'CA' ); ?>>Canada</option>
|
| <option value="MX" <?php selected( $selected_country, 'MX' ); ?>>Mexico</option>
|
| <option value="GB" <?php selected( $selected_country, 'GB' ); ?>>United Kingdom</option>
|
| <option value="AU" <?php selected( $selected_country, 'AU' ); ?>>Australia</option>
|
| <option value="OTHER" <?php selected( $selected_country, 'OTHER' ); ?>>Other</option>
|
| </select>
|
| </td>
|
| </tr>
|
| </table>
|
|
|
| <h3>Work Location</h3>
|
| <table class="form-table" role="presentation">
|
| <tr>
|
| <th><label for="kic_work_location_street">Work Location Street</label></th>
|
| <td>
|
| <input type="text"
|
| name="kic_work_location_street"
|
| id="kic_work_location_street"
|
| value="<?php echo esc_attr( get_user_meta( $user->ID, 'kic_work_location_street', true ) ); ?>"
|
| class="regular-text" />
|
| <p class="description">Primary work site address</p>
|
| </td>
|
| </tr>
|
| <tr>
|
| <th><label for="kic_work_location_city">Work Location City</label></th>
|
| <td>
|
| <input type="text"
|
| name="kic_work_location_city"
|
| id="kic_work_location_city"
|
| value="<?php echo esc_attr( get_user_meta( $user->ID, 'kic_work_location_city', true ) ); ?>"
|
| class="regular-text" />
|
| </td>
|
| </tr>
|
| <tr>
|
| <th><label for="kic_work_location_state">Work Location State</label></th>
|
| <td>
|
| <input type="text"
|
| name="kic_work_location_state"
|
| id="kic_work_location_state"
|
| value="<?php echo esc_attr( get_user_meta( $user->ID, 'kic_work_location_state', true ) ); ?>"
|
| class="regular-text"
|
| placeholder="e.g., MD"
|
| maxlength="2"
|
| style="width: 100px;" />
|
| </td>
|
| </tr>
|
| <tr>
|
| <th><label for="kic_work_location_zip">Work Location ZIP</label></th>
|
| <td>
|
| <input type="text"
|
| name="kic_work_location_zip"
|
| id="kic_work_location_zip"
|
| value="<?php echo esc_attr( get_user_meta( $user->ID, 'kic_work_location_zip', true ) ); ?>"
|
| class="regular-text"
|
| style="width: 150px;" />
|
| </td>
|
| </tr>
|
| </table>
|
|
|
| <h3>Work Authorization & I-9 Compliance</h3>
|
| <table class="form-table" role="presentation">
|
| <tr>
|
| <th><label for="kic_i9_completion_date">I-9 Form Completion Date</label></th>
|
| <td>
|
| <input type="date"
|
| name="kic_i9_completion_date"
|
| id="kic_i9_completion_date"
|
| value="<?php echo esc_attr( get_user_meta( $user->ID, 'kic_i9_completion_date', true ) ); ?>" />
|
| <p class="description">Federal I-9 form completion date (must be within 3 days of hire)</p>
|
| </td>
|
| </tr>
|
| <tr>
|
| <th><label for="kic_work_auth_status">Work Authorization Status</label></th>
|
| <td>
|
| <select name="kic_work_auth_status" id="kic_work_auth_status" class="regular-text">
|
| <?php
|
| $work_auth = get_user_meta( $user->ID, 'kic_work_auth_status', true );
|
| $auth_options = array(
|
| '' => '-- Select Status --',
|
| 'us_citizen' => 'U.S. Citizen',
|
| 'permanent_resident' => 'Permanent Resident',
|
| 'work_visa' => 'Work Visa',
|
| 'ead' => 'Employment Authorization Document (EAD)',
|
| 'other' => 'Other'
|
| );
|
| foreach ( $auth_options as $value => $label ) {
|
| echo '<option value="' . esc_attr( $value ) . '" ' . selected( $work_auth, $value, false ) . '>' . esc_html( $label ) . '</option>';
|
| }
|
| ?>
|
| </select>
|
| </td>
|
| </tr>
|
| <tr>
|
| <th><label for="kic_work_auth_expiration">Work Authorization Expiration</label></th>
|
| <td>
|
| <input type="date"
|
| name="kic_work_auth_expiration"
|
| id="kic_work_auth_expiration"
|
| value="<?php echo esc_attr( get_user_meta( $user->ID, 'kic_work_auth_expiration', true ) ); ?>" />
|
| <p class="description">For visa holders or temporary work authorization</p>
|
| </td>
|
| </tr>
|
| </table>
|
|
|
| <h3>Tax & Payroll Information</h3>
|
| <table class="form-table" role="presentation">
|
| <tr>
|
| <th><label for="kic_w4_file_url">W-4 Form Upload</label></th>
|
| <td>
|
| <input type="url"
|
| name="kic_w4_file_url"
|
| id="kic_w4_file_url"
|
| value="<?php echo esc_attr( get_user_meta( $user->ID, 'kic_w4_file_url', true ) ); ?>"
|
| class="regular-text"
|
| placeholder="https:
|
| <p class="description">Link to uploaded W-4 form (populated by Gravity Forms)</p>
|
| </td>
|
| </tr>
|
| <tr>
|
| <th><label for="kic_w4_date">W-4 on File Date</label></th>
|
| <td>
|
| <input type="date"
|
| name="kic_w4_date"
|
| id="kic_w4_date"
|
| value="<?php echo esc_attr( get_user_meta( $user->ID, 'kic_w4_date', true ) ); ?>" />
|
| <p class="description">When W-4 was completed/updated</p>
|
| </td>
|
| </tr>
|
| <tr>
|
| <th><label for="kic_payment_method">Payment Method</label></th>
|
| <td>
|
| <select name="kic_payment_method" id="kic_payment_method" class="regular-text">
|
| <?php
|
| $payment = get_user_meta( $user->ID, 'kic_payment_method', true );
|
| ?>
|
| <option value="" <?php selected( $payment, '' ); ?>>-- Select Method --</option>
|
| <option value="direct_deposit" <?php selected( $payment, 'direct_deposit' ); ?>>Direct Deposit</option>
|
| <option value="check" <?php selected( $payment, 'check' ); ?>>Check</option>
|
| </select>
|
| <p class="description">Payment delivery method (does not show account details)</p>
|
| </td>
|
| </tr>
|
| <tr>
|
| <th><label for="kic_pay_rate">Pay Rate/Salary</label></th>
|
| <td>
|
| <input type="text"
|
| name="kic_pay_rate"
|
| id="kic_pay_rate"
|
| value="<?php echo esc_attr( get_user_meta( $user->ID, 'kic_pay_rate', true ) ); ?>"
|
| class="regular-text"
|
| placeholder="50000 or 25.00/hr" />
|
| <p class="description">Annual salary or hourly rate</p>
|
| </td>
|
| </tr>
|
| </table>
|
|
|
| <h3>Benefits Information</h3>
|
| <table class="form-table" role="presentation">
|
| <tr>
|
| <th><label for="kic_benefits_eligible">Benefits Eligible</label></th>
|
| <td>
|
| <select name="kic_benefits_eligible" id="kic_benefits_eligible">
|
| <?php
|
| $benefits = get_user_meta( $user->ID, 'kic_benefits_eligible', true );
|
| ?>
|
| <option value="" <?php selected( $benefits, '' ); ?>>-- Select --</option>
|
| <option value="yes" <?php selected( $benefits, 'yes' ); ?>>Yes</option>
|
| <option value="no" <?php selected( $benefits, 'no' ); ?>>No</option>
|
| </select>
|
| </td>
|
| </tr>
|
| <tr>
|
| <th><label for="kic_benefits_enrollment_date">Benefits Enrollment Date</label></th>
|
| <td>
|
| <input type="date"
|
| name="kic_benefits_enrollment_date"
|
| id="kic_benefits_enrollment_date"
|
| value="<?php echo esc_attr( get_user_meta( $user->ID, 'kic_benefits_enrollment_date', true ) ); ?>" />
|
| </td>
|
| </tr>
|
| <tr>
|
| <th><label for="kic_health_insurance_status">Health Insurance Status</label></th>
|
| <td>
|
| <select name="kic_health_insurance_status" id="kic_health_insurance_status" class="regular-text">
|
| <?php
|
| $health = get_user_meta( $user->ID, 'kic_health_insurance_status', true );
|
| ?>
|
| <option value="" <?php selected( $health, '' ); ?>>-- Select Status --</option>
|
| <option value="enrolled" <?php selected( $health, 'enrolled' ); ?>>Enrolled</option>
|
| <option value="declined" <?php selected( $health, 'declined' ); ?>>Declined</option>
|
| <option value="waived" <?php selected( $health, 'waived' ); ?>>Waived</option>
|
| </select>
|
| </td>
|
| </tr>
|
| <tr>
|
| <th><label for="kic_retirement_plan">Retirement Plan Participation</label></th>
|
| <td>
|
| <select name="kic_retirement_plan" id="kic_retirement_plan" class="regular-text">
|
| <?php
|
| $retirement = get_user_meta( $user->ID, 'kic_retirement_plan', true );
|
| ?>
|
| <option value="" <?php selected( $retirement, '' ); ?>>-- Select Status --</option>
|
| <option value="enrolled_401k" <?php selected( $retirement, 'enrolled_401k' ); ?>>Enrolled - 401(k)</option>
|
| <option value="not_enrolled" <?php selected( $retirement, 'not_enrolled' ); ?>>Not Enrolled</option>
|
| <option value="not_eligible" <?php selected( $retirement, 'not_eligible' ); ?>>Not Eligible</option>
|
| </select>
|
| <p class="description">401(k) or retirement plan enrollment status</p>
|
| </td>
|
| </tr>
|
| </table>
|
|
|
| <h3>Training & Certifications</h3>
|
| <table class="form-table" role="presentation">
|
| <tr>
|
| <th><label for="kic_training_certifications">Training & Certifications Log</label></th>
|
| <td>
|
| <textarea name="kic_training_certifications"
|
| id="kic_training_certifications"
|
| rows="6"
|
| class="large-text"><?php echo esc_textarea( get_user_meta( $user->ID, 'kic_training_certifications', true ) ); ?></textarea>
|
| <p class="description">Gravity Forms can append new training records here. Format: Date | Training Name | Expiration</p>
|
| </td>
|
| </tr>
|
| </table>
|
|
|
| <h3>Background Checks</h3>
|
| <table class="form-table" role="presentation">
|
| <tr>
|
| <th><label for="kic_background_checks">Background Check Log</label></th>
|
| <td>
|
| <textarea name="kic_background_checks"
|
| id="kic_background_checks"
|
| rows="6"
|
| class="large-text"><?php echo esc_textarea( get_user_meta( $user->ID, 'kic_background_checks', true ) ); ?></textarea>
|
| <p class="description">Multiple background checks can be logged here. Format: Date | Check Type | Status | Cleared By</p>
|
| </td>
|
| </tr>
|
| </table>
|
|
|
| <h3>Performance Management</h3>
|
| <table class="form-table" role="presentation">
|
| <tr>
|
| <th><label for="kic_last_review_date">Last Performance Review Date</label></th>
|
| <td>
|
| <input type="date"
|
| name="kic_last_review_date"
|
| id="kic_last_review_date"
|
| value="<?php echo esc_attr( get_user_meta( $user->ID, 'kic_last_review_date', true ) ); ?>" />
|
| </td>
|
| </tr>
|
| <tr>
|
| <th><label for="kic_next_review_date">Next Review Due Date</label></th>
|
| <td>
|
| <input type="date"
|
| name="kic_next_review_date"
|
| id="kic_next_review_date"
|
| value="<?php echo esc_attr( get_user_meta( $user->ID, 'kic_next_review_date', true ) ); ?>" />
|
| </td>
|
| </tr>
|
| </table>
|
|
|
| <h3>Identification Numbers</h3>
|
| <table class="form-table" role="presentation">
|
| <tr>
|
| <th><label for="kic_staff_id">Staff ID</label></th>
|
| <td>
|
| <input type="text"
|
| name="kic_staff_id"
|
| id="kic_staff_id"
|
| value="<?php echo esc_attr( get_user_meta( $user->ID, 'kic_staff_id', true ) ); ?>"
|
| class="regular-text" />
|
| <p class="description">Staff identification number</p>
|
| </td>
|
| </tr>
|
| <tr>
|
| <th><label for="kic_employee_id">Employee ID</label></th>
|
| <td>
|
| <input type="text"
|
| name="kic_employee_id"
|
| id="kic_employee_id"
|
| value="<?php echo esc_attr( get_user_meta( $user->ID, 'kic_employee_id', true ) ); ?>"
|
| class="regular-text" />
|
| <p class="description">Employee/HR identification number</p>
|
| </td>
|
| </tr>
|
| <tr>
|
| <th><label for="kic_member_id">Member ID</label></th>
|
| <td>
|
| <input type="text"
|
| name="kic_member_id"
|
| id="kic_member_id"
|
| value="<?php echo esc_attr( get_user_meta( $user->ID, 'kic_member_id', true ) ); ?>"
|
| class="regular-text" />
|
| </td>
|
| </tr>
|
| <tr>
|
| <th><label for="kic_vendor_id">Vendor ID</label></th>
|
| <td>
|
| <input type="text"
|
| name="kic_vendor_id"
|
| id="kic_vendor_id"
|
| value="<?php echo esc_attr( get_user_meta( $user->ID, 'kic_vendor_id', true ) ); ?>"
|
| class="regular-text" />
|
| <p class="description">For contractor/vendor assignments</p>
|
| </td>
|
| </tr>
|
| <tr>
|
| <th><label for="kic_intern_id">Intern ID</label></th>
|
| <td>
|
| <input type="text"
|
| name="kic_intern_id"
|
| id="kic_intern_id"
|
| value="<?php echo esc_attr( get_user_meta( $user->ID, 'kic_intern_id', true ) ); ?>"
|
| class="regular-text" />
|
| </td>
|
| </tr>
|
| <tr>
|
| <th><label for="kic_time_tracking_id">Time Tracking ID</label></th>
|
| <td>
|
| <input type="text"
|
| name="kic_time_tracking_id"
|
| id="kic_time_tracking_id"
|
| value="<?php echo esc_attr( get_user_meta( $user->ID, 'kic_time_tracking_id', true ) ); ?>"
|
| class="regular-text" />
|
| <p class="description">Timeclock/timesheet system ID</p>
|
| </td>
|
| </tr>
|
| </table>
|
|
|
| <h3>External System IDs</h3>
|
| <table class="form-table" role="presentation">
|
| <tr>
|
| <th><label for="kic_ghl_id">GoHighLevel ID</label></th>
|
| <td>
|
| <input type="text"
|
| name="kic_ghl_id"
|
| id="kic_ghl_id"
|
| value="<?php echo esc_attr( get_user_meta( $user->ID, 'kic_ghl_id', true ) ); ?>"
|
| class="regular-text" />
|
| <p class="description">GoHighLevel contact ID</p>
|
| </td>
|
| </tr>
|
| <tr>
|
| <th><label for="kic_org_name">Organization Name</label></th>
|
| <td>
|
| <input type="text"
|
| name="kic_org_name"
|
| id="kic_org_name"
|
| value="<?php echo esc_attr( get_user_meta( $user->ID, 'kic_org_name', true ) ); ?>"
|
| class="regular-text" />
|
| <p class="description">Organization/company name</p>
|
| </td>
|
| </tr>
|
| <tr>
|
| <th><label for="kic_org_id">Organization ID</label></th>
|
| <td>
|
| <input type="text"
|
| name="kic_org_id"
|
| id="kic_org_id"
|
| value="<?php echo esc_attr( get_user_meta( $user->ID, 'kic_org_id', true ) ); ?>"
|
| class="regular-text" />
|
| </td>
|
| </tr>
|
| <tr>
|
| <th><label for="kic_group_id">Group ID</label></th>
|
| <td>
|
| <input type="text"
|
| name="kic_group_id"
|
| id="kic_group_id"
|
| value="<?php echo esc_attr( get_user_meta( $user->ID, 'kic_group_id', true ) ); ?>"
|
| class="regular-text" />
|
| <p class="description">Group/cohort identification</p>
|
| </td>
|
| </tr>
|
| </table>
|
|
|
| <h3>Additional Information</h3>
|
| <table class="form-table" role="presentation">
|
| <tr>
|
| <th><label for="kic_date_of_birth">Date of Birth</label></th>
|
| <td>
|
| <input type="date"
|
| name="kic_date_of_birth"
|
| id="kic_date_of_birth"
|
| value="<?php echo esc_attr( get_user_meta( $user->ID, 'kic_date_of_birth', true ) ); ?>" />
|
| </td>
|
| </tr>
|
| <tr>
|
| <th><label for="kic_hire_date">Hire Date</label></th>
|
| <td>
|
| <input type="date"
|
| name="kic_hire_date"
|
| id="kic_hire_date"
|
| value="<?php echo esc_attr( get_user_meta( $user->ID, 'kic_hire_date', true ) ); ?>" />
|
| <p class="description">Employment start date</p>
|
| </td>
|
| </tr>
|
| <tr>
|
| <th><label for="kic_shirt_size">Uniform/Shirt Size</label></th>
|
| <td>
|
| <select name="kic_shirt_size" id="kic_shirt_size" class="regular-text">
|
| <?php
|
| $size = get_user_meta( $user->ID, 'kic_shirt_size', true );
|
| $sizes = array( '' => '-- Select Size --', 'XS' => 'XS', 'S' => 'S', 'M' => 'M', 'L' => 'L', 'XL' => 'XL', '2XL' => '2XL', '3XL' => '3XL' );
|
| foreach ( $sizes as $value => $label ) {
|
| echo '<option value="' . esc_attr( $value ) . '" ' . selected( $size, $value, false ) . '>' . esc_html( $label ) . '</option>';
|
| }
|
| ?>
|
| </select>
|
| </td>
|
| </tr>
|
| <tr>
|
| <th><label for="kic_parking_access">Parking/Building Access Info</label></th>
|
| <td>
|
| <input type="text"
|
| name="kic_parking_access"
|
| id="kic_parking_access"
|
| value="<?php echo esc_attr( get_user_meta( $user->ID, 'kic_parking_access', true ) ); ?>"
|
| class="regular-text" />
|
| <p class="description">Access card numbers, parking permits, etc.</p>
|
| </td>
|
| </tr>
|
| <tr>
|
| <th><label for="kic_emergency_contact_name">Emergency Contact Name</label></th>
|
| <td>
|
| <input type="text"
|
| name="kic_emergency_contact_name"
|
| id="kic_emergency_contact_name"
|
| value="<?php echo esc_attr( get_user_meta( $user->ID, 'kic_emergency_contact_name', true ) ); ?>"
|
| class="regular-text" />
|
| </td>
|
| </tr>
|
| <tr>
|
| <th><label for="kic_emergency_contact_phone">Emergency Contact Phone</label></th>
|
| <td>
|
| <input type="tel"
|
| name="kic_emergency_contact_phone"
|
| id="kic_emergency_contact_phone"
|
| value="<?php echo esc_attr( get_user_meta( $user->ID, 'kic_emergency_contact_phone', true ) ); ?>"
|
| class="regular-text" />
|
| </td>
|
| </tr>
|
| <tr>
|
| <th><label for="kic_emergency_contact_2_name">Secondary Emergency Contact</label></th>
|
| <td>
|
| <input type="text"
|
| name="kic_emergency_contact_2_name"
|
| id="kic_emergency_contact_2_name"
|
| value="<?php echo esc_attr( get_user_meta( $user->ID, 'kic_emergency_contact_2_name', true ) ); ?>"
|
| class="regular-text" />
|
| </td>
|
| </tr>
|
| <tr>
|
| <th><label for="kic_emergency_contact_2_phone">Secondary Emergency Phone</label></th>
|
| <td>
|
| <input type="tel"
|
| name="kic_emergency_contact_2_phone"
|
| id="kic_emergency_contact_2_phone"
|
| value="<?php echo esc_attr( get_user_meta( $user->ID, 'kic_emergency_contact_2_phone', true ) ); ?>"
|
| class="regular-text" />
|
| </td>
|
| </tr>
|
| </table>
|
|
|
| <h3>Termination Information</h3>
|
| <table class="form-table" role="presentation">
|
| <tr>
|
| <th><label for="kic_termination_date">Termination Date</label></th>
|
| <td>
|
| <input type="date"
|
| name="kic_termination_date"
|
| id="kic_termination_date"
|
| value="<?php echo esc_attr( get_user_meta( $user->ID, 'kic_termination_date', true ) ); ?>" />
|
| </td>
|
| </tr>
|
| <tr>
|
| <th><label for="kic_termination_type">Termination Type</label></th>
|
| <td>
|
| <select name="kic_termination_type" id="kic_termination_type" class="regular-text">
|
| <?php
|
| $term_type = get_user_meta( $user->ID, 'kic_termination_type', true );
|
| $term_options = array(
|
| '' => '-- Select Type --',
|
| 'voluntary' => 'Voluntary',
|
| 'involuntary' => 'Involuntary',
|
| 'retirement' => 'Retirement',
|
| 'layoff' => 'Layoff',
|
| 'contract_end' => 'Contract End'
|
| );
|
| foreach ( $term_options as $value => $label ) {
|
| echo '<option value="' . esc_attr( $value ) . '" ' . selected( $term_type, $value, false ) . '>' . esc_html( $label ) . '</option>';
|
| }
|
| ?>
|
| </select>
|
| </td>
|
| </tr>
|
| <tr>
|
| <th><label for="kic_eligible_rehire">Eligible for Rehire</label></th>
|
| <td>
|
| <select name="kic_eligible_rehire" id="kic_eligible_rehire">
|
| <?php
|
| $rehire = get_user_meta( $user->ID, 'kic_eligible_rehire', true );
|
| ?>
|
| <option value="" <?php selected( $rehire, '' ); ?>>-- Select --</option>
|
| <option value="yes" <?php selected( $rehire, 'yes' ); ?>>Yes</option>
|
| <option value="no" <?php selected( $rehire, 'no' ); ?>>No</option>
|
| </select>
|
| </td>
|
| </tr>
|
| </table>
|
|
|
| </div><!--
|
| </div><!--
|
|
|
| <script type="text/javascript">
|
| jQuery(document).ready(function($) {
|
|
|
| $('#kic-hr-fields-wrapper .postbox-header').on('click', function() {
|
| var $wrapper = $('#kic-hr-fields-wrapper');
|
| var $content = $('#kic-hr-fields-content');
|
| var $icon = $wrapper.find('.dashicons');
|
|
|
| if ($content.is(':visible')) {
|
| $content.slideUp(300);
|
| $icon.removeClass('dashicons-arrow-down-alt2').addClass('dashicons-arrow-right-alt2');
|
| $wrapper.addClass('closed');
|
| } else {
|
| $content.slideDown(300);
|
| $icon.removeClass('dashicons-arrow-right-alt2').addClass('dashicons-arrow-down-alt2');
|
| $wrapper.removeClass('closed');
|
| }
|
| });
|
|
|
|
|
| $('#kic-hr-fields-content').hide();
|
| $('#kic-hr-fields-wrapper .dashicons').removeClass('dashicons-arrow-down-alt2').addClass('dashicons-arrow-right-alt2');
|
| });
|
| </script>
|
|
|
| <style>
|
|
|
| border: 1px solid
|
| background:
|
| }
|
|
|
| background:
|
| border-bottom: 1px solid
|
| }
|
|
|
| background:
|
| }
|
|
|
| padding: 0 12px 12px;
|
| }
|
|
|
| border-bottom: none;
|
| }
|
| </style>
|
|
|
| <?php
|
| }
|
|
|
|
|
| add_action( 'personal_options_update', 'kic_save_hr_staff_profile_fields', 12 );
|
| add_action( 'edit_user_profile_update', 'kic_save_hr_staff_profile_fields', 12 );
|
|
|
| function kic_save_hr_staff_profile_fields( $user_id ) {
|
|
|
| if ( ! isset( $_POST['kic_hr_profile_nonce'] ) ||
|
| ! wp_verify_nonce( $_POST['kic_hr_profile_nonce'], 'kic_hr_profile_update' ) ) {
|
| return;
|
| }
|
|
|
| if ( ! current_user_can( 'edit_user', $user_id ) ) {
|
| return;
|
| }
|
|
|
|
|
| $update_or_delete_meta = function( $user_id, $meta_key, $value ) {
|
| if ( empty( $value ) ) {
|
| delete_user_meta( $user_id, $meta_key );
|
| } else {
|
| update_user_meta( $user_id, $meta_key, $value );
|
| }
|
| };
|
|
|
|
|
| $update_or_delete_meta( $user_id, 'kic_employment_status',
|
| sanitize_text_field( $_POST['kic_employment_status'] ?? '' ) );
|
|
|
| $update_or_delete_meta( $user_id, 'kic_flsa_classification',
|
| sanitize_text_field( $_POST['kic_flsa_classification'] ?? '' ) );
|
|
|
| $update_or_delete_meta( $user_id, 'kic_job_title',
|
| sanitize_text_field( $_POST['kic_job_title'] ?? '' ) );
|
|
|
| $update_or_delete_meta( $user_id, 'kic_department',
|
| sanitize_text_field( $_POST['kic_department'] ?? '' ) );
|
|
|
| $update_or_delete_meta( $user_id, 'kic_supervisor',
|
| sanitize_text_field( $_POST['kic_supervisor'] ?? '' ) );
|
|
|
|
|
| $update_or_delete_meta( $user_id, 'kic_full_name',
|
| sanitize_text_field( $_POST['kic_full_name'] ?? '' ) );
|
|
|
| $update_or_delete_meta( $user_id, 'kic_work_email',
|
| sanitize_email( $_POST['kic_work_email'] ?? '' ) );
|
|
|
|
|
| $phone = preg_replace( '/[^0-9+\-\(\)\s]/', '', $_POST['kic_phone'] ?? '' );
|
| $update_or_delete_meta( $user_id, 'kic_phone', $phone );
|
|
|
| $phone_secondary = preg_replace( '/[^0-9+\-\(\)\s]/', '', $_POST['kic_phone_secondary'] ?? '' );
|
| $update_or_delete_meta( $user_id, 'kic_phone_secondary', $phone_secondary );
|
|
|
|
|
| $update_or_delete_meta( $user_id, 'kic_address_street',
|
| sanitize_text_field( $_POST['kic_address_street'] ?? '' ) );
|
|
|
| $update_or_delete_meta( $user_id, 'kic_address_street_2',
|
| sanitize_text_field( $_POST['kic_address_street_2'] ?? '' ) );
|
|
|
| $update_or_delete_meta( $user_id, 'kic_address_city',
|
| sanitize_text_field( $_POST['kic_address_city'] ?? '' ) );
|
|
|
| $state = strtoupper( substr( sanitize_text_field( $_POST['kic_address_state'] ?? '' ), 0, 2 ) );
|
| $update_or_delete_meta( $user_id, 'kic_address_state', $state );
|
|
|
| $zip = preg_replace( '/[^0-9\-]/', '', $_POST['kic_address_zip'] ?? '' );
|
| $update_or_delete_meta( $user_id, 'kic_address_zip', $zip );
|
|
|
| $update_or_delete_meta( $user_id, 'kic_address_country',
|
| sanitize_text_field( $_POST['kic_address_country'] ?? 'US' ) );
|
|
|
|
|
| $update_or_delete_meta( $user_id, 'kic_work_location_street',
|
| sanitize_text_field( $_POST['kic_work_location_street'] ?? '' ) );
|
|
|
| $update_or_delete_meta( $user_id, 'kic_work_location_city',
|
| sanitize_text_field( $_POST['kic_work_location_city'] ?? '' ) );
|
|
|
| $work_state = strtoupper( substr( sanitize_text_field( $_POST['kic_work_location_state'] ?? '' ), 0, 2 ) );
|
| $update_or_delete_meta( $user_id, 'kic_work_location_state', $work_state );
|
|
|
| $update_or_delete_meta( $user_id, 'kic_work_location_zip',
|
| sanitize_text_field( $_POST['kic_work_location_zip'] ?? '' ) );
|
|
|
|
|
| $i9_date = sanitize_text_field( $_POST['kic_i9_completion_date'] ?? '' );
|
| if ( $i9_date && ! preg_match( '/^\d{4}-\d{2}-\d{2}$/', $i9_date ) ) {
|
| $i9_date = '';
|
| }
|
| $update_or_delete_meta( $user_id, 'kic_i9_completion_date', $i9_date );
|
|
|
| $update_or_delete_meta( $user_id, 'kic_work_auth_status',
|
| sanitize_text_field( $_POST['kic_work_auth_status'] ?? '' ) );
|
|
|
| $auth_exp = sanitize_text_field( $_POST['kic_work_auth_expiration'] ?? '' );
|
| if ( $auth_exp && ! preg_match( '/^\d{4}-\d{2}-\d{2}$/', $auth_exp ) ) {
|
| $auth_exp = '';
|
| }
|
| $update_or_delete_meta( $user_id, 'kic_work_auth_expiration', $auth_exp );
|
|
|
|
|
| $update_or_delete_meta( $user_id, 'kic_w4_file_url',
|
| esc_url_raw( $_POST['kic_w4_file_url'] ?? '' ) );
|
|
|
| $w4_date = sanitize_text_field( $_POST['kic_w4_date'] ?? '' );
|
| if ( $w4_date && ! preg_match( '/^\d{4}-\d{2}-\d{2}$/', $w4_date ) ) {
|
| $w4_date = '';
|
| }
|
| $update_or_delete_meta( $user_id, 'kic_w4_date', $w4_date );
|
|
|
| $update_or_delete_meta( $user_id, 'kic_payment_method',
|
| sanitize_text_field( $_POST['kic_payment_method'] ?? '' ) );
|
|
|
| $update_or_delete_meta( $user_id, 'kic_pay_rate',
|
| sanitize_text_field( $_POST['kic_pay_rate'] ?? '' ) );
|
|
|
|
|
| $update_or_delete_meta( $user_id, 'kic_benefits_eligible',
|
| sanitize_text_field( $_POST['kic_benefits_eligible'] ?? '' ) );
|
|
|
| $ben_date = sanitize_text_field( $_POST['kic_benefits_enrollment_date'] ?? '' );
|
| if ( $ben_date && ! preg_match( '/^\d{4}-\d{2}-\d{2}$/', $ben_date ) ) {
|
| $ben_date = '';
|
| }
|
| $update_or_delete_meta( $user_id, 'kic_benefits_enrollment_date', $ben_date );
|
|
|
| $update_or_delete_meta( $user_id, 'kic_health_insurance_status',
|
| sanitize_text_field( $_POST['kic_health_insurance_status'] ?? '' ) );
|
|
|
| $update_or_delete_meta( $user_id, 'kic_retirement_plan',
|
| sanitize_text_field( $_POST['kic_retirement_plan'] ?? '' ) );
|
|
|
|
|
| $update_or_delete_meta( $user_id, 'kic_training_certifications',
|
| sanitize_textarea_field( $_POST['kic_training_certifications'] ?? '' ) );
|
|
|
| $update_or_delete_meta( $user_id, 'kic_background_checks',
|
| sanitize_textarea_field( $_POST['kic_background_checks'] ?? '' ) );
|
|
|
|
|
| $last_review = sanitize_text_field( $_POST['kic_last_review_date'] ?? '' );
|
| if ( $last_review && ! preg_match( '/^\d{4}-\d{2}-\d{2}$/', $last_review ) ) {
|
| $last_review = '';
|
| }
|
| $update_or_delete_meta( $user_id, 'kic_last_review_date', $last_review );
|
|
|
| $next_review = sanitize_text_field( $_POST['kic_next_review_date'] ?? '' );
|
| if ( $next_review && ! preg_match( '/^\d{4}-\d{2}-\d{2}$/', $next_review ) ) {
|
| $next_review = '';
|
| }
|
| $update_or_delete_meta( $user_id, 'kic_next_review_date', $next_review );
|
|
|
|
|
| $id_fields = [
|
| 'kic_staff_id',
|
| 'kic_employee_id',
|
| 'kic_member_id',
|
| 'kic_vendor_id',
|
| 'kic_intern_id',
|
| 'kic_time_tracking_id',
|
| 'kic_ghl_id',
|
| 'kic_org_name',
|
| 'kic_org_id',
|
| 'kic_group_id'
|
| ];
|
|
|
| foreach ( $id_fields as $field ) {
|
| $update_or_delete_meta( $user_id, $field,
|
| sanitize_text_field( $_POST[$field] ?? '' ) );
|
| }
|
|
|
|
|
| $dob = sanitize_text_field( $_POST['kic_date_of_birth'] ?? '' );
|
| if ( $dob && ! preg_match( '/^\d{4}-\d{2}-\d{2}$/', $dob ) ) {
|
| $dob = '';
|
| }
|
| $update_or_delete_meta( $user_id, 'kic_date_of_birth', $dob );
|
|
|
| $hire_date = sanitize_text_field( $_POST['kic_hire_date'] ?? '' );
|
| if ( $hire_date && ! preg_match( '/^\d{4}-\d{2}-\d{2}$/', $hire_date ) ) {
|
| $hire_date = '';
|
| }
|
| $update_or_delete_meta( $user_id, 'kic_hire_date', $hire_date );
|
|
|
| $update_or_delete_meta( $user_id, 'kic_shirt_size',
|
| sanitize_text_field( $_POST['kic_shirt_size'] ?? '' ) );
|
|
|
| $update_or_delete_meta( $user_id, 'kic_parking_access',
|
| sanitize_text_field( $_POST['kic_parking_access'] ?? '' ) );
|
|
|
|
|
| $update_or_delete_meta( $user_id, 'kic_emergency_contact_name',
|
| sanitize_text_field( $_POST['kic_emergency_contact_name'] ?? '' ) );
|
|
|
| $emergency_phone = preg_replace( '/[^0-9+\-\(\)\s]/', '', $_POST['kic_emergency_contact_phone'] ?? '' );
|
| $update_or_delete_meta( $user_id, 'kic_emergency_contact_phone', $emergency_phone );
|
|
|
| $update_or_delete_meta( $user_id, 'kic_emergency_contact_2_name',
|
| sanitize_text_field( $_POST['kic_emergency_contact_2_name'] ?? '' ) );
|
|
|
| $emergency_phone_2 = preg_replace( '/[^0-9+\-\(\)\s]/', '', $_POST['kic_emergency_contact_2_phone'] ?? '' );
|
| $update_or_delete_meta( $user_id, 'kic_emergency_contact_2_phone', $emergency_phone_2 );
|
|
|
|
|
| $term_date = sanitize_text_field( $_POST['kic_termination_date'] ?? '' );
|
| if ( $term_date && ! preg_match( '/^\d{4}-\d{2}-\d{2}$/', $term_date ) ) {
|
| $term_date = '';
|
| }
|
| $update_or_delete_meta( $user_id, 'kic_termination_date', $term_date );
|
|
|
| $update_or_delete_meta( $user_id, 'kic_termination_type',
|
| sanitize_text_field( $_POST['kic_termination_type'] ?? '' ) );
|
|
|
| $update_or_delete_meta( $user_id, 'kic_eligible_rehire',
|
| sanitize_text_field( $_POST['kic_eligible_rehire'] ?? '' ) );
|
| }
|
|
|
|
|
|
|
|
|
| add_filter( 'manage_users_columns', 'kic_add_hr_user_list_columns' );
|
| function kic_add_hr_user_list_columns( $columns ) {
|
| $new_columns = [];
|
| foreach ( $columns as $key => $value ) {
|
| $new_columns[$key] = $value;
|
| if ( 'email' === $key ) {
|
| $new_columns['kic_employment_status'] = 'Employment Status';
|
| $new_columns['kic_department'] = 'Department';
|
| $new_columns['kic_job_title'] = 'Job Title';
|
| }
|
| }
|
| return $new_columns;
|
| }
|
|
|
| add_action( 'manage_users_custom_column', 'kic_show_hr_user_list_column_content', 10, 3 );
|
| function kic_show_hr_user_list_column_content( $value, $column_name, $user_id ) {
|
| switch ( $column_name ) {
|
| case 'kic_employment_status':
|
| $status = get_user_meta( $user_id, 'kic_employment_status', true );
|
| $status_labels = array(
|
| 'full_time_employee' => 'Full-time',
|
| 'part_time_employee' => 'Part-time',
|
| 'contractor' => 'Contractor',
|
| 'volunteer_contractor' => 'Volunteer',
|
| 'intern_contractor' => 'Intern (C)',
|
| 'intern_employee' => 'Intern (E)',
|
| 'temporary' => 'Temporary'
|
| );
|
| return $status && isset( $status_labels[$status] ) ? esc_html( $status_labels[$status] ) : '—';
|
| case 'kic_department':
|
| $dept = get_user_meta( $user_id, 'kic_department', true );
|
| return $dept ? esc_html( $dept ) : '—';
|
| case 'kic_job_title':
|
| $title = get_user_meta( $user_id, 'kic_job_title', true );
|
| return $title ? esc_html( $title ) : '—';
|
| default:
|
| return $value;
|
| }
|
| }
|
|
|
|
|
| add_filter( 'manage_users_sortable_columns', 'kic_make_hr_user_columns_sortable' );
|
| function kic_make_hr_user_columns_sortable( $columns ) {
|
| $columns['kic_employment_status'] = 'kic_employment_status';
|
| $columns['kic_department'] = 'kic_department';
|
| $columns['kic_job_title'] = 'kic_job_title';
|
| return $columns;
|
| }
|
|
|
|
|
| add_action( 'pre_user_query', 'kic_sort_hr_users_by_custom_columns' );
|
| function kic_sort_hr_users_by_custom_columns( $user_query ) {
|
| global $wpdb;
|
|
|
| $orderby = $user_query->get( 'orderby' );
|
|
|
| if ( ! $orderby || ! is_string( $orderby ) ) {
|
| return;
|
| }
|
|
|
| $meta_key_map = [
|
| 'kic_employment_status' => 'kic_employment_status',
|
| 'kic_department' => 'kic_department',
|
| 'kic_job_title' => 'kic_job_title',
|
| ];
|
|
|
| if ( isset( $meta_key_map[ $orderby ] ) ) {
|
| $meta_key = $meta_key_map[ $orderby ];
|
| $user_query->query_vars['meta_key'] = $meta_key;
|
| $user_query->query_vars['orderby'] = 'meta_value';
|
| }
|
| }
|
| |
| |
Comments