Esempio n. 1
0
 /**
  * Update employee compensation
  *
  * @return void
  */
 public function employee_update_compensation()
 {
     $this->verify_nonce('employee_update_compensation');
     // @TODO: check permission
     $employee_id = isset($_REQUEST['employee_id']) ? intval($_REQUEST['employee_id']) : 0;
     $date = empty($_POST['date']) ? current_time('mysql') : $_POST['date'];
     $comment = strip_tags($_POST['comment']);
     $pay_rate = intval($_POST['pay_rate']);
     $pay_type = strip_tags($_POST['pay_type']);
     $reason = strip_tags($_POST['change-reason']);
     $types = erp_hr_get_pay_type();
     $reasons = erp_hr_get_pay_change_reasons();
     if (!$pay_rate) {
         $this->send_error(__('Enter a valid pay rate.', 'wp-erp'));
     }
     if (!array_key_exists($pay_type, $types)) {
         $this->send_error(__('Pay Type does not exists.', 'wp-erp'));
     }
     if (!array_key_exists($reason, $reasons)) {
         $this->send_error(__('Reason does not exists.', 'wp-erp'));
     }
     $employee = new Employee($employee_id);
     if ($employee->id) {
         $employee->update_compensation($pay_rate, $pay_type, $reason, $date, $comment);
         $this->send_success();
     }
     $this->send_error(__('Something went wrong!', 'wp-erp'));
 }
Esempio n. 2
0
    <div class="row">
        <?php 
erp_html_form_input(array('label' => __('Pay Rate', 'wp-erp'), 'name' => 'pay_rate', 'value' => '{{ data.work.pay_rate }}', 'required' => true));
?>
    </div>

    <div class="row">
        <?php 
erp_html_form_input(array('label' => __('Pay Type', 'wp-erp'), 'name' => 'pay_type', 'value' => '', 'type' => 'select', 'options' => array(0 => __('- Select -', 'wp-erp')) + erp_hr_get_pay_type()));
?>
    </div>

    <div class="row">
        <?php 
erp_html_form_input(array('label' => __('Change Reason', 'wp-erp'), 'name' => 'change-reason', 'value' => '', 'type' => 'select', 'options' => array(0 => __('- Select -', 'wp-erp')) + erp_hr_get_pay_change_reasons()));
?>
    </div>

    <div class="row">
        <?php 
erp_html_form_input(array('label' => __('Comment', 'wp-erp'), 'name' => 'comment', 'value' => '', 'placeholder' => __('Optional comment', 'wp-erp'), 'type' => 'textarea', 'custom_attr' => array('rows' => 4, 'cols' => 25)));
?>
    </div>

    <?php 
wp_nonce_field('employee_update_compensation');
?>
    <input type="hidden" name="action" id="status-action" value="erp-hr-emp-update-comp">
    <input type="hidden" name="employee_id" id="emp-id" value="{{ data.id }}">
</div>