Exemplo n.º 1
0
 /**
  * Default column values if no callback found
  *
  * @param  object  $item
  * @param  string  $column_name
  *
  * @return string
  */
 function column_default($campaign, $column_name)
 {
     switch ($column_name) {
         case 'name':
         case 'assigned_group':
             $groups = wp_list_pluck($campaign->groups, 'name', 'id');
             return implode(', ', $groups);
         case 'created_at':
             return erp_format_date($campaign->created_at);
         default:
             return isset($campaign->{$column_name}) ? $campaign->{$column_name} : '';
     }
 }
Exemplo n.º 2
0
 /**
  * Default column values if no callback found
  *
  * @param  object  $item
  * @param  string  $column_name
  *
  * @return string
  */
 function column_default($item, $column_name)
 {
     switch ($column_name) {
         case 'date':
             return erp_format_date($item->created_on);
         case 'policy':
             return stripslashes($item->policy_name);
         case 'status':
             return '<span class="status-' . $item->status . '">' . erp_hr_leave_request_get_statuses($item->status) . '</span>';
         default:
             return isset($item->{$column_name}) ? $item->{$column_name} : '';
     }
 }
 /**
  * Default column values if no callback found
  *
  * @param  object  $item
  * @param  string  $column_name
  *
  * @return string
  */
 function column_default($contact_group, $column_name)
 {
     switch ($column_name) {
         case 'name':
         case 'subscribed':
             return $contact_group->subscriber;
         case 'unsubscribed':
             return $contact_group->unsubscriber;
         case 'created_at':
             return erp_format_date($contact_group->created_at);
         default:
             return isset($contact_group->{$column_name}) ? $contact_group->{$column_name} : '';
     }
 }
Exemplo n.º 4
0
 /**
  * Gets the leave dates
  *
  * Returns the date list between the start and end date of the
  * two dates
  *
  * @since 0.1
  *
  * @return void
  */
 public function leave_request_dates()
 {
     $this->verify_nonce('wp-erp-hr-nonce');
     $id = isset($_POST['employee_id']) && $_POST['employee_id'] ? intval($_POST['employee_id']) : false;
     if (!$id) {
         $this->send_error('Please select employee', 'wp-erp');
     }
     $policy_id = isset($_POST['type']) && $_POST['type'] ? $_POST['type'] : false;
     if (!$policy_id) {
         $this->send_error('Please select leave type', 'wp-erp');
     }
     $start_date = isset($_POST['from']) ? sanitize_text_field($_POST['from']) : date_i18n('Y-m-d');
     $end_date = isset($_POST['to']) ? sanitize_text_field($_POST['to']) : date_i18n('Y-m-d');
     $valid_date_range = erp_hrm_is_valid_leave_date_range_within_financial_date_range($start_date, $end_date);
     $financial_start_date = date('Y-m-d', strtotime(erp_financial_start_date()));
     $financial_end_date = date('Y-m-d', strtotime(erp_financial_end_date()));
     if ($start_date > $end_date) {
         $this->send_error('Invalid date range', 'wp-erp');
     }
     if (!$valid_date_range) {
         $this->send_error(sprintf('Date range must be within %s to %s', erp_format_date($financial_start_date), erp_format_date($financial_end_date)));
     }
     $leave_record_exisst = erp_hrm_is_leave_recored_exist_between_date($start_date, $end_date, $id);
     if ($leave_record_exisst) {
         $this->send_error(__('Leave recored found withing this range!', 'wp-erp'));
     }
     $is_policy_valid = erp_hrm_is_valid_leave_duration($start_date, $end_date, $policy_id, $id);
     if (!$is_policy_valid) {
         $this->send_error(__('Your leave duration exceeded entitlement!', 'wp-erp'));
     }
     $days = erp_hr_get_work_days_between_dates($start_date, $end_date);
     if (is_wp_error($days)) {
         $this->send_error($days->get_error_message());
     }
     // just a bit more readable date format
     foreach ($days['days'] as &$date) {
         $date['date'] = erp_format_date($date['date'], 'D, M d');
     }
     $days['total'] = sprintf('%d %s', $days['total'], _n('day', 'days', $days['total'], 'wp-erp'));
     $this->send_success($days);
 }
Exemplo n.º 5
0
</td>
                <td>
                    <?php 
        if ($available < 0) {
            printf('<span class="red">%d %s</span>', number_format_i18n($available), __('days', 'wp-erp'));
        } elseif ($available > 0) {
            printf('<span class="green">%d %s</span>', number_format_i18n($available), __('days', 'wp-erp'));
        } else {
            echo '-';
        }
        ?>
                </td>
                <td>
                    <?php 
        if ($en) {
            printf('%s - %s', erp_format_date($en->from_date), erp_format_date($en->to_date));
        } else {
            _e('No Policy', 'wp-erp');
        }
        ?>
                </td>
            </tr>

            <?php 
    }
    ?>
        </tbody>

    </table>

<?php 
Exemplo n.º 6
0
 /**
  * Default column values if no callback found
  *
  * @param  object  $item
  * @param  string  $column_name
  *
  * @return string
  */
 function column_default($audit_log, $column_name)
 {
     switch ($column_name) {
         case 'name':
             return ucfirst($audit_log->component);
         case 'sections':
             return ucfirst($audit_log->sub_component);
         case 'message':
             if ($audit_log->changetype == 'edit') {
                 if (!empty($audit_log->old_value) && !empty($audit_log->new_value)) {
                     return sprintf('%s. <a href="#" class="erp-audit-log-view-changes erp-tips" data-id="%d" title="%s">(view changes)</a>', htmlspecialchars_decode($audit_log->message), $audit_log->id, __('View what elements are changes', 'wp-erp'));
                 } else {
                     return htmlspecialchars_decode($audit_log->message);
                 }
             }
             return htmlspecialchars_decode($audit_log->message);
         case 'created_by':
             return $audit_log->display_name;
         case 'created_at':
             return erp_format_date($audit_log->created_at);
         default:
             return isset($audit_log->{$column_name}) ? $audit_log->{$column_name} : '';
     }
 }
Exemplo n.º 7
0
 /**
  * Default column values if no callback found
  *
  * @since 1.0
  *
  * @param  object  $item
  * @param  string  $column_name
  *
  * @return string
  */
 function column_default($customer, $column_name)
 {
     $life_stages = erp_crm_get_life_statges_dropdown_raw();
     $life_stage = erp_people_get_meta($customer->id, 'life_stage', true);
     switch ($column_name) {
         case 'email':
             return $customer->email;
         case 'phone_number':
             return $customer->phone;
         case 'life_stages':
             return isset($life_stages[$life_stage]) ? $life_stages[$life_stage] : '-';
         case 'created':
             return erp_format_date($customer->created);
         default:
             return isset($customer->{$column_name}) ? $customer->{$column_name} : '';
     }
 }
Exemplo n.º 8
0
"><br></div>
        <h3 class="hndle"><span><?php 
    _e('Termination', 'wp-erp');
    ?>
</span></h3>
        <div class="inside">

            <?php 
    $termination_data = get_user_meta($employee->id, '_erp_hr_termination', true);
    ?>

            <p><?php 
    _e('Termination Date', 'wp-erp');
    ?>
 : <?php 
    echo isset($termination_data['terminate_date']) ? erp_format_date($termination_data['terminate_date']) : '';
    ?>
</p>
            <p><?php 
    _e('Termination Type', 'wp-erp');
    ?>
 : <?php 
    echo isset($termination_data['termination_type']) ? erp_hr_get_terminate_type($termination_data['termination_type']) : '';
    ?>
</p>
            <p><?php 
    _e('Termination Reason', 'wp-erp');
    ?>
 : <?php 
    echo isset($termination_data['termination_reason']) ? erp_hr_get_terminate_reason($termination_data['termination_reason']) : '';
    ?>
Exemplo n.º 9
0
"><?php 
            echo esc_html($entitlement->employee_name);
            ?>
</a></strong>

                            </td>
                            <td class="col-"><?php 
            echo esc_html($entitlement->policy_name);
            ?>
</td>
                            <td class="col-"><?php 
            echo erp_format_date($entitlement->from_date);
            ?>
</td>
                            <td class="col-"><?php 
            echo erp_format_date($entitlement->to_date);
            ?>
</td>
                            <td class="col-"><?php 
            echo number_format_i18n($entitlement->days);
            ?>
</td>
                            <td class="col-"></td>
                            <td class="col-"></td>
                        </tr>
                    <?php 
        }
        ?>
                <?php 
    } else {
        ?>
Exemplo n.º 10
0
        <tbody>
            <?php 
if ($performance['goals']) {
    foreach ($performance['goals'] as $num => $row) {
        ?>
                    <tr class="<?php 
        echo $num % 2 == 0 ? 'alternate' : 'odd';
        ?>
">
                        <td><?php 
        echo erp_format_date($row->performance_date);
        ?>
</td>
                        <td><?php 
        echo erp_format_date($row->completion_date);
        ?>
</td>
                        <td><?php 
        echo esc_textarea($row->goal_description);
        ?>
</td>
                        <td><?php 
        echo esc_textarea($row->employee_assessment);
        ?>
</td>
                        <td>
                            <?php 
        $reporting_user = new \WeDevs\ERP\HRM\Employee(intval($row->supervisor));
        echo $reporting_user->get_full_name();
        ?>
Exemplo n.º 11
0
/**
 * Erp dashboard who is out widget
 *
 * @since 0.1
 *
 * @return void
 */
function erp_hr_dashboard_widget_whoisout()
{
    $leave_requests = erp_hr_get_current_month_leave_list();
    $leave_requests_nextmonth = erp_hr_get_next_month_leave_list();
    ?>
    <h4><?php 
    _e('This Month', 'wp-erp');
    ?>
</h4>
    <?php 
    if ($leave_requests) {
        ?>
        <ul class="erp-list list-two-side list-sep">
            <?php 
        foreach ($leave_requests as $key => $leave) {
            ?>
                <?php 
            $employee = new \WeDevs\ERP\HRM\Employee(intval($leave->user_id));
            ?>
                <li>
                    <a href="<?php 
            echo $employee->get_details_url();
            ?>
"><?php 
            echo $employee->get_full_name();
            ?>
</a>
                    <span><i class="fa fa-calendar"></i> <?php 
            echo erp_format_date($leave->start_date, 'M d,y') . ' - ' . erp_format_date($leave->end_date, 'M d,y');
            ?>
</span>
                </li>
            <?php 
        }
        ?>
        </ul>
    <?php 
    } else {
        ?>
        <?php 
        _e('No one is in vacation', 'wp-erp');
        ?>
    <?php 
    }
    ?>
    <hr>
    <h4><?php 
    _e('Next Month', 'wp-erp');
    ?>
</h4>
    <?php 
    if ($leave_requests_nextmonth) {
        ?>
        <ul class="erp-list list-two-side list-sep">
            <?php 
        foreach ($leave_requests_nextmonth as $key => $leave) {
            ?>
                <?php 
            $employee = new \WeDevs\ERP\HRM\Employee(intval($leave->user_id));
            ?>
                <li>
                    <a href="<?php 
            echo $employee->get_details_url();
            ?>
"><?php 
            echo $employee->get_full_name();
            ?>
</a>
                    <span><i class="fa fa-calendar"></i> <?php 
            echo erp_format_date($leave->start_date, 'M d,y') . ' - ' . erp_format_date($leave->end_date, 'M d,y');
            ?>
</span>
                </li>
            <?php 
        }
        ?>
        </ul>
    <?php 
    } else {
        ?>
        <?php 
        _e('No one is vacation on next month', 'wp-erp');
        ?>
    <?php 
    }
    ?>

    <?php 
}
Exemplo n.º 12
0
 /**
  * Edit assignable contact
  *
  * @since 1.0
  *
  * @return json
  */
 public function edit_assign_contact()
 {
     $this->verify_nonce('wp-erp-crm-nonce');
     $data = [];
     $user_id = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : 0;
     if (!$user_id) {
         $this->send_error(__('Contact not found. Try again', 'wp-erp'));
     }
     $result = erp_crm_get_editable_assign_contact($user_id);
     foreach ($result as $key => $value) {
         $data[$value['group_id']] = ['status' => $value['status'], 'subscribe_at' => erp_format_date($value['subscribe_at']), 'unsubscribe_at' => erp_format_date($value['unsubscribe_at']), 'subscribe_message' => sprintf(' ( %s %s )', __('Subscribed on'), erp_format_date($value['subscribe_at'])), 'unsubscribe_message' => sprintf(' ( %s %s )', __('Unsubscribed on'), erp_format_date($value['unsubscribe_at']))];
     }
     $this->send_success(['groups' => wp_list_pluck($result, 'group_id'), 'results' => $data]);
 }
 /**
  * Prepare data for subscriber group
  *
  * @since 1.0
  *
  * @param  array $item
  *
  * @return string
  */
 public function prepare_subscriber_group_data($item)
 {
     $status = wp_list_pluck($item, 'status');
     $res = wp_list_pluck($item, 'name');
     $str = '';
     foreach ($res as $key => $data) {
         $subscribe_date = sprintf('%s %s', $status[$key] == 'subscribe' ? __('Subscribed on ', 'wp-erp') : __('Unsubscribed on ', 'wp-erp'), $status[$key] == 'subscribe' ? erp_format_date($item[$key]['subscribe_at']) : erp_format_date($item[$key]['unsubscribe_at']));
         $str .= sprintf('%s<span class="%s-group erp-crm-tips" title="%s">%s</span>', $key != 0 ? ' , ' : '', $status[$key], $subscribe_date, $data);
     }
     return $str;
 }
Exemplo n.º 14
0
        ?>

                        <tr class="<?php 
        echo $key % 2 == 0 ? 'alternate' : 'odd';
        ?>
">
                            <td><?php 
        echo esc_html($dependent->name);
        ?>
</td>
                            <td><?php 
        echo esc_html($dependent->relation);
        ?>
</td>
                            <td><?php 
        echo erp_format_date($dependent->dob);
        ?>
</td>
                            <td width="10%">
                                <div class="row-actions">
                                    <a href="#" class="dependent-edit" data-template="erp-employment-dependent" data-title="<?php 
        esc_attr_e('Dependents', 'wp-erp');
        ?>
" data-data='<?php 
        echo json_encode($dependent);
        ?>
' data-button="<?php 
        esc_attr_e('Update Dependent', 'wp-erp');
        ?>
"><span class="dashicons dashicons-edit"></span></a>
                                    <a href="#" class="dependent-delete" data-id="<?php 
Exemplo n.º 15
0
 /**
  * Add log when edit holiday
  *
  * @since 0.1
  *
  * @param  integer $holiday_id
  * @param  array $fields
  *
  * @return void
  */
 public function update_holiday($holiday_id, $fields)
 {
     if (!$holiday_id) {
         return;
     }
     $old_holiday = \WeDevs\ERP\HRM\Models\Leave_Holiday::find($holiday_id)->toArray();
     unset($old_holiday['created_at'], $old_holiday['updated_at']);
     $old_holiday['start'] = erp_format_date($old_holiday['start'], 'Y-m-d');
     $old_holiday['end'] = erp_format_date($old_holiday['end'], 'Y-m-d');
     $fields['start'] = erp_format_date($fields['start'], 'Y-m-d');
     $fields['end'] = erp_format_date($fields['end'], 'Y-m-d');
     $changes = $this->get_array_diff($fields, $old_holiday, true);
     if (empty($changes['old_val']) && empty($changes['new_val'])) {
         $message = false;
     } else {
         array_walk($changes, function (&$key) {
             if (isset($key['start'])) {
                 $key['start_date'] = erp_format_date($key['start']);
                 unset($key['start']);
             }
             if (isset($key['end'])) {
                 $key['end_date'] = erp_format_date($key['end']);
                 unset($key['end']);
             }
         });
         $message = sprintf('<strong>%s</strong> holiday has been edited', $old_holiday['title']);
     }
     if ($message) {
         erp_log()->add(['sub_component' => 'leave', 'message' => $message, 'created_by' => get_current_user_id(), 'changetype' => 'edit', 'old_value' => $changes['old_val'] ? base64_encode(maybe_serialize($changes['old_val'])) : '', 'new_value' => $changes['new_val'] ? base64_encode(maybe_serialize($changes['new_val'])) : '']);
     }
 }
Exemplo n.º 16
0
                <th class="action">&nbsp;</th>
            </tr>
        </thead>
        <tbody>

            <?php 
if ($history['job']) {
    $types = erp_hr_get_pay_type();
    foreach ($history['job'] as $num => $row) {
        ?>
                    <tr class="<?php 
        echo $num % 2 == 0 ? 'alternate' : 'odd';
        ?>
">
                        <td><?php 
        echo erp_format_date($row->date);
        ?>
</td>
                        <td>
                            <?php 
        echo !empty($row->type) ? $row->type : '--';
        ?>
                        </td>
                        <td>
                            <?php 
        echo !empty($row->category) ? $row->category : '--';
        ?>
                        </td>
                        <td>
                            <?php 
        echo !empty($row->comment) ? $row->comment : '--';
Exemplo n.º 17
0
/**
 * Leave period dropdown at entitlement create time
 *
 * @since 0.1
 *
 * @return void
 */
function erp_hr_leave_period()
{
    $next_sart_date = date('Y-m-01 H:i:s', strtotime('+1 year', strtotime(erp_financial_start_date())));
    $next_end_date = date('Y-m-t H:i:s', strtotime('+1 year', strtotime(erp_financial_end_date())));
    $date = [erp_financial_start_date() => erp_format_date(erp_financial_start_date()) . ' - ' . erp_format_date(erp_financial_end_date()), $next_sart_date => erp_format_date($next_sart_date) . ' - ' . erp_format_date($next_end_date)];
    return $date;
}
Exemplo n.º 18
0
</span></h3>
                        <div class="inside contact-group-content">
                            <div class="contact-group-list">
                                <?php 
$subscribe_groups = erp_crm_get_user_assignable_groups($customer->id);
?>
                                <?php 
if ($subscribe_groups) {
    ?>
                                    <?php 
    foreach ($subscribe_groups as $key => $groups) {
        ?>
                                        <p>
                                            <?php 
        echo $groups['groups']['name'];
        $info_messg = $groups['status'] == 'subscribe' ? sprintf('%s %s', __('Subscribed on'), erp_format_date($groups['subscribe_at'])) : sprintf('%s %s', __('Unsubscribed on'), erp_format_date($groups['unsubscribe_at']));
        ?>
                                            <span class="erp-crm-tips" title="<?php 
        echo $info_messg;
        ?>
">
                                                <i class="fa fa-info-circle"></i>
                                            </span>
                                        </p>
                                    <?php 
    }
    ?>
                                <?php 
}
?>
Exemplo n.º 19
0
 /**
  * Get birth date
  *
  * @return string
  */
 public function get_birthday()
 {
     if ($this->date_of_birth) {
         return erp_format_date($this->date_of_birth);
     }
 }
Exemplo n.º 20
0
 /**
  * Gets the leave dates
  *
  * Returns the date list between the start and end date of the
  * two dates
  *
  * @return void
  */
 public function leave_request_dates()
 {
     $this->verify_nonce('wp-erp-hr-nonce');
     $id = isset($_POST['employee_id']) ? intval($_POST['employee_id']) : get_current_user_id();
     $start_date = isset($_POST['from']) ? sanitize_text_field($_POST['from']) : date_i18n('Y-m-d');
     $end_date = isset($_POST['to']) ? sanitize_text_field($_POST['to']) : date_i18n('Y-m-d');
     $days = erp_hr_get_work_days_between_dates($start_date, $end_date);
     if (is_wp_error($days)) {
         $this->send_error($days->get_error_message());
     }
     // just a bit more readable date format
     foreach ($days['days'] as &$date) {
         $date['date'] = erp_format_date($date['date'], 'D, M d');
     }
     $days['total'] = sprintf('%d %s', $days['total'], _n('day', 'days', $days['total'], 'wp-erp'));
     $this->send_success($days);
 }
 /**
  * Default column values if no callback found
  *
  * @param  object  $item
  * @param  string  $column_name
  *
  * @return string
  */
 function column_default($entitlement, $column_name)
 {
     $balance = erp_hr_leave_get_balance($entitlement->user_id);
     if (isset($balance[$entitlement->policy_id])) {
         $scheduled = $balance[$entitlement->policy_id]['scheduled'];
         $available = $balance[$entitlement->policy_id]['entitlement'] - $balance[$entitlement->policy_id]['total'];
     } else {
         $scheduled = '';
         $available = '';
     }
     switch ($column_name) {
         case 'name':
             return sprintf('<strong><a href="%s">%s</a></strong>', erp_hr_url_single_employee($entitlement->user_id), esc_html($entitlement->employee_name));
         case 'leave_policy':
             return esc_html($entitlement->policy_name);
         case 'valid_from':
             return erp_format_date($entitlement->from_date);
         case 'valid_to':
             return erp_format_date($entitlement->to_date);
         case 'days':
             return number_format_i18n($entitlement->days);
         case 'scheduled':
             return $scheduled ? sprintf(__('%d days', 'wp-erp'), number_format_i18n($scheduled)) : '-';
         case 'available':
             if ($available < 0) {
                 return sprintf('<span class="red">%d %s</span>', number_format_i18n($available), __('days', 'wp-erp'));
             } elseif ($available > 0) {
                 return sprintf('<span class="green">%d %s</span>', number_format_i18n($available), __('days', 'wp-erp'));
             } else {
                 return '-';
             }
         default:
             return isset($entitlement->{$column_name}) ? $entitlement->{$column_name} : '';
     }
 }
Exemplo n.º 22
0
 /**
  * Default column values if no callback found
  *
  * @param  object  $item
  * @param  string  $column_name
  *
  * @return string
  */
 function column_default($holiday, $column_name)
 {
     switch ($column_name) {
         case 'name':
             return $holiday->title;
         case 'start':
             return erp_format_date($holiday->start);
         case 'end':
             return erp_format_date($holiday->end);
         case 'duration':
             $days = erp_date_duration($holiday->start, $holiday->end) + 1;
             return $days . ' ' . _n(__('day', 'wp-erp'), __('days', 'wp-erp'), $days);
         case 'description':
             return !empty($holiday->description) ? $holiday->description : '--';
         default:
             return '';
     }
 }
Exemplo n.º 23
0
        ?>
            <li>
                <div class="avatar-wrap">
                    <?php 
        echo get_avatar($note->by_email, 64);
        ?>
                </div>

                <div class="note-wrap">
                    <div class="by">
                        <a href="#" class="author"><?php 
        echo $note->by_name;
        ?>
</a>
                        <span class="date"><?php 
        echo erp_format_date($note->created_on, __('M j, Y \\a\\t g:i a', 'wp-erp'));
        ?>
</span>
                    </div>

                    <div class="note-body">
                        <?php 
        echo wpautop($note->comment);
        ?>
                    </div>
                </div>
            </li>
            <?php 
    }
    ?>
        </ul>
Exemplo n.º 24
0
<?php

if ($requests) {
    foreach ($requests as $num => $request) {
        ?>
        <tr class="<?php 
        echo $num % 2 == 0 ? 'alternate' : 'odd';
        ?>
">
            <td>
                <?php 
        printf('%s - %s', erp_format_date($request->start_date, 'd M'), erp_format_date($request->end_date, 'd M'));
        ?>
            </td>
            <td><?php 
        echo esc_html($request->policy_name);
        ?>
</td>
            <td><?php 
        echo !empty($request->reason) ? esc_html($request->reason) : '-';
        ?>
</td>
            <td><?php 
        echo number_format_i18n($request->days);
        ?>
</td>
        </tr>

    <?php 
    }
    ?>