Exemplo n.º 1
0
    if ($delete_permission) {
        $del_checkbox = '<input name="hrm_check[' . $post->ID . ']"$post="" type="checkbox">';
    } else {
        $del_checkbox = '';
    }
    $punch_out_time = get_post_meta($post->ID, '_puch_out_time', true);
    $puch_out_note = get_post_meta($post->ID, '_puch_out_note', true);
    if (!empty($punch_out_time)) {
        $total_duration = $total_duration + ($punch_out_time - strtotime($post->post_date));
        $punch_out = date("Y-m-d H:i:s", $punch_out_time);
        $punch_out = new DateTime($punch_out);
        $punch_in = new DateTime($post->post_date);
        $interval = date_diff($punch_out, $punch_in);
        $duration = $interval->format('%H:%I:%S');
    }
    $body[] = array($del_checkbox, $name_id, $post->post_content, !empty($punch_out_time) ? hrm_get_punch_in_time($punch_out_time, false) : '', $puch_out_note, isset($duration) ? $duration : '');
    $td_attr[] = array('class="check-column"');
}
$total = hrm_second_to_time($total_duration);
$total_time = $total['hour'] . ':' . $total['minute'] . ':' . $total['second'];
if ($delete_permission) {
    $body[] = array('', '', '', '', '<strong>' . __('Total', 'hrm') . '</strong>', $total_time);
} else {
    $body[] = array('', '', '', '<strong>' . __('Total', 'hrm') . '</strong>', $total_time);
}
$del_checkbox = $delete_permission ? '<input type="checkbox">' : '';
$table['head'] = array($del_checkbox, __('Punch In', 'hrm'), __('Punch In Note', 'hrm'), __('Punch Out', 'hrm'), __('Punch Out Note', 'hrm'), __('Duration (Hours)', 'hrm'));
$table['body'] = isset($body) ? $body : array();
$arg = array('post_type' => 'hrm_punch', 'post_status' => 'publish', 'author' => get_current_user_id(), 'meta_query' => array(array('key' => '_puch_in_status', 'value' => '1', 'compear' => '=')));
$query = new WP_Query($arg);
if (!isset($query->posts[0])) {
Exemplo n.º 2
0
 function punch_out_form()
 {
     $redirect = isset($_POST['hrm_dataAttr']['redirect']) && !empty($_POST['hrm_dataAttr']['redirect']) ? $_POST['hrm_dataAttr']['redirect'] : '';
     $user_id = isset($_POST['hrm_dataAttr']['user_id_js']) ? intval($_POST['hrm_dataAttr']['user_id_js']) : false;
     $form['user_id'] = array('type' => 'hidden', 'value' => $user_id);
     $arg = array('post_type' => 'hrm_punch', 'post_status' => 'publish', 'author' => $user_id ? $user_id : get_current_user_id(), 'meta_query' => array(array('key' => '_puch_in_status', 'value' => '1', 'compear' => '=')));
     $query = new WP_Query($arg);
     if (!isset($query->posts[0])) {
         return $this->punch_in_form();
     }
     $post = $query->posts[0];
     $form['post_id'] = array('type' => 'hidden', 'value' => $post->ID);
     $form['type'] = array('type' => 'hidden', 'value' => '_search');
     $form[] = array('type' => 'descriptive', 'label' => __('Punch in Time', 'hrm'), 'value' => isset($post->post_date) ? hrm_get_punch_in_time($post->post_date) : '');
     $form[] = array('type' => 'descriptive', 'label' => __('Punch in Note', 'hrm'), 'value' => isset($post->post_content) ? $post->post_content : '');
     $form[] = array('type' => 'descriptive', 'label' => __('Date', 'hrm'), 'value' => hrm_get_date2mysql(current_time('mysql')));
     $form[] = array('type' => 'descriptive', 'label' => __('Time', 'hrm'), 'value' => hrm_get_time(current_time('mysql'), true));
     $form['note'] = array('label' => __('Note', 'hrm'), 'type' => 'textarea', 'value' => isset($project->post_content) ? $project->post_content : '');
     $form['action'] = 'create_punch_out';
     $form['header'] = __('Punch Out', 'hrm');
     $form['url'] = $redirect;
     ob_start();
     echo hrm_Settings::getInstance()->hidden_form_generator($form);
     $return_value = array('append_data' => ob_get_clean());
     return $return_value;
 }