Пример #1
0
 public static function getInstance()
 {
     if (!self::$_instance) {
         self::$_instance = new Hrm_Admin();
     }
     return self::$_instance;
 }
 function get_user_by_project_id($project_id)
 {
     $users = Hrm_Admin::getInstance()->get_project_assigned_user($project_id);
     $option_value = array();
     $option_value['-1'] = __('-Select-', 'hrm');
     foreach ($users as $user_id => $user) {
         $option_value[$user_id] = $user['name'];
     }
     $co_worker = array('label' => __('Co Worker', 'hrm'), 'class' => 'hrm-chosen', 'id' => 'hrm-rank-task-user', 'type' => 'select', 'option' => $option_value, 'selected' => '', 'desc' => __('Type project name', 'hrm'), 'extra' => array('data-placeholder' => __("Choose project", 'hrm'), 'data-project_id' => $project_id));
     echo '<div class="hrm-text-wrap hrm-task-rating-user">';
     echo Hrm_Settings::getInstance()->select_field('co_worker', $co_worker);
     echo '</div>';
 }
$delete_permission = hrm_user_can_access($tab, $subtab, 'delete') ? true : false;
foreach ($results['posts'] as $key => $project_obj) {
    if ($project_obj->post_type != 'hrm_project') {
        continue;
    }
    $task_id = array();
    foreach ($results['posts'] as $key => $obj) {
        if ($obj->post_type == 'hrm_task' && $obj->post_parent == $project_obj->ID) {
            $task_id[] = $obj->ID;
        }
    }
    $currency_symbol = get_post_meta($project_obj->ID, '_currency_symbol', true);
    $total_budget = get_post_meta($project_obj->ID, '_budget', true);
    $budget_utilize = get_post_meta($project_obj->ID, '_project_budget_utilize', true);
    $budget_remain = $total_budget - $budget_utilize;
    $body[] = array('<input name="hrm_check[' . $project_obj->ID . ']" value="' . $project_obj->ID . '" type="checkbox">', '<a href="#" class="hrm-editable"  data-action="project_edit"  data-id=' . $project_obj->ID . '><strong>' . $project_obj->post_title . '</strong></a>' . '<div style="color: #000;">' . __('<strong>Total budget:</strong> ' . $currency_symbol . $total_budget, 'hrm') . '</div><div style="color: #000;">' . __('<strong>Budget utilize:</strong> ' . $currency_symbol . $budget_utilize, 'hrm') . '</div><div style="color: #000;">' . __('<strong>Budget remain:</strong> ' . $currency_symbol . $budget_remain, 'hrm') . '</div>', $project_obj->post_content, Hrm_Admin::getInstance()->get_task_title($results['posts'], $task_id, $project_obj->ID, $add_permission, $currency_symbol));
    $td_attr[] = array('class="check-column"');
    $task_id = '';
}
$table['head'] = array('<input type="checkbox">', __('Project Title', 'hrm'), __('Description', 'hrm'), __('Task Title', 'hrm'));
$table['body'] = isset($body) ? $body : array();
$table['td_attr'] = isset($td_attr) ? $td_attr : array();
$table['th_attr'] = array('class="check-column"');
$table['table_attr'] = array('class' => 'widefat');
$table['table'] = 'hrm_project_customer';
$table['action'] = 'delete_project';
$table['table_attr'] = array('class' => 'widefat');
$table['tab'] = $tab;
$table['subtab'] = $subtab;
echo Hrm_Settings::getInstance()->table($table);
//table
<?php

$general_info = Hrm_Admin::getInstance()->get_general_info();
$general_info = isset($general_info['data']) ? $general_info['data'] : '';
?>

<div id="hrm-visible-form-warp">
	<div class="hrm-search-head">
		<h2 id="hrm-searchLocationHeading"><?php 
_e('General Information', 'hrm');
?>
</h2>
	</div>
	<?php 
if (isset($general_info['organization_name']) && !empty($general_info['organization_name'])) {
    ?>
		<div class="hrm-text-wrap"><strong class="hrm-text-label"><?php 
    _e('Organization Name', 'hrm');
    ?>
</strong><div class="hrm-text-info"><?php 
    echo $general_info['organization_name'];
    ?>
</div><div class="hrm-clear"></div></div>
		<?php 
}
?>

	<?php 
if (isset($general_info['tax_id']) && !empty($general_info['tax_id'])) {
    ?>
		<div class="hrm-text-wrap"><strong class="hrm-text-label"><?php 
$search['table_option'] = 'hrm_user_search';
echo Hrm_settings::getInstance()->get_serarch_form($search, 'Admin');
?>
<div id="hrm-admin-list"></div>
<?php 
//hidden form
$pagenum = hrm_pagenum();
$limit = hrm_result_limit();
if (isset($_POST['type']) && $_POST['type'] == '_search') {
    $search = $_POST['employer'];
    $search_satus = true;
} else {
    $search = '';
    $search_satus = false;
}
$search_query = Hrm_Admin::getInstance()->get_employer($limit, $search, $pagenum);
$results = $search_query->get_results();
$total = $search_query->get_total();
$add_permission = hrm_user_can_access($tab, $subtab, 'add') ? true : false;
$delete_permission = hrm_user_can_access($tab, $subtab, 'delete') ? true : false;
$user = wp_get_current_user();
foreach ($results as $id => $user_obj) {
    if ($user->user_login == $user_obj->user_login) {
        continue;
    }
    $flag = get_user_meta($user_obj->ID, '_status', true);
    $status = $flag == 'yes' ? 'Enable' : 'Disable';
    $role = isset($user_obj->roles[0]) ? $user_obj->roles[0] : '';
    if ($add_permission) {
        $name_id = '<a href="#" class="hrm-editable" data-action="user-role-edit-form-appear" data-id=' . $user_obj->ID . '>' . $user_obj->user_login . '<a>';
    } else {
Пример #6
0
 function instantiate()
 {
     Hrm_Ajax::getInstance();
     Hrm_Admin::getInstance();
     Hrm_Leave::getInstance();
     Hrm_Employee::getInstance();
 }
Пример #7
0
 function create_user()
 {
     parse_str($_POST['data'], $postdata);
     $validate = $this->new_admin_form_validate($postdata);
     if (is_wp_error($validate)) {
         wp_send_json_error($validate->errors['error'][0]);
     }
     $random_password = wp_generate_password($length = 12, $include_standard_special_chars = false);
     $first_name = sanitize_text_field($postdata['first_name']);
     $last_name = sanitize_text_field($postdata['last_name']);
     $display_name = $first_name . ' ' . $last_name;
     $userdata = array('user_login' => $postdata['admin_name'], 'user_pass' => $random_password, 'user_email' => $postdata['admin_email'], 'first_name' => $first_name, 'last_name' => $last_name, 'display_name' => $display_name);
     $user_id = wp_insert_user($userdata);
     if ($user_id) {
         update_user_meta($user_id, '_user_flag', 1);
         update_user_meta($user_id, 'first_name', $first_name);
         update_user_meta($user_id, 'last_name', $last_name);
         update_user_meta($user_id, 'hrm_admin_level', 'admin');
         wp_new_user_notification($user_id, $random_password);
         $user_meta = Hrm_Admin::getInstance()->create_user_meta($display_name, $user_id);
         wp_send_json_success(array('success_msg' => __('Create admin successfull', 'hrm'), '_user_meta' => $user_meta));
     } else {
         wp_send_json_error(array('error_msg' => __('Unknown Error!', 'hrm')));
     }
 }
<div class="hrm-update-notification"></div>
<?php 
if (!hrm_user_can_access($tab, $subtab, 'view')) {
    printf('<h1>%s</h1>', __('You do no have permission to access this page', 'cpm'));
    return;
}
?>

<?php 
$country = hrm_Settings::getInstance()->country_list();
//default $this for class hrm_Admin, $tab, $subtab;
$field_value = Hrm_Admin::getInstance()->get_general_info();
$field['organization_name'] = array('label' => __('Organization Name', 'hrm'), 'class' => 'required', 'type' => 'text', 'value' => isset($field_value['data']['organization_name']) ? $field_value['data']['organization_name'] : '', 'extra' => array('data-hrm_validation' => true, 'data-hrm_required' => true, 'data-hrm_required_error_msg' => __('This field is required', 'hrm')));
$field['tax_id'] = array('label' => __('Tax ID', 'hrm'), 'type' => 'text', 'value' => isset($field_value['data']['tax_id']) ? $field_value['data']['tax_id'] : '');
$field['registration_number'] = array('label' => __('Registration Number', 'hrm'), 'type' => 'text', 'value' => isset($field_value['data']['registration_number']) ? $field_value['data']['registration_number'] : '');
$field['phone'] = array('label' => __('Phone', 'hrm'), 'type' => 'text', 'value' => isset($field_value['data']['phone']) ? $field_value['data']['phone'] : '');
$field['fax'] = array('label' => __('Fax', 'hrm'), 'type' => 'text', 'value' => isset($field_value['data']['fax']) ? $field_value['data']['fax'] : '');
$field['email'] = array('label' => __('email', 'hrm'), 'type' => 'email', 'value' => isset($field_value['data']['email']) ? $field_value['data']['email'] : '');
$field['addres_street_1'] = array('label' => __('Address Street 1', 'hrm'), 'type' => 'text', 'value' => isset($field_value['data']['addres_street_1']) ? $field_value['data']['addres_street_1'] : '');
$field['address_street_2'] = array('label' => __('Address Street 2', 'hrm'), 'type' => 'text', 'value' => isset($field_value['data']['address_street_2']) ? $field_value['data']['address_street_2'] : '');
$field['city'] = array('label' => __('City', 'hrm'), 'type' => 'text', 'value' => isset($field_value['data']['city']) ? $field_value['data']['city'] : '');
$field['state_province'] = array('label' => __('State/Province', 'hrm'), 'type' => 'text', 'value' => isset($field_value['data']['state_province']) ? $field_value['data']['state_province'] : '');
$field['zip'] = array('label' => __('Zip/Postal Code', 'hrm'), 'type' => 'text', 'value' => isset($field_value['data']['zip']) ? $field_value['data']['zip'] : '');
$field['country'] = array('label' => __('Country', 'hrm'), 'type' => 'select', 'option' => $country, 'selected' => isset($field_value['data']['country']) ? $field_value['data']['country'] : '', 'desc' => 'Chose your country');
$field['note'] = array('label' => __('Note', 'hrm'), 'type' => 'textarea', 'value' => isset($field_value['data']['note']) ? $field_value['data']['note'] : '');
$field['header'] = 'General Information';
$field['action'] = 'single_form';
$field['table_option'] = 'hrm_general_info';
$field['tab'] = $tab;
$field['subtab'] = $subtab;
echo Hrm_Settings::getInstance()->visible_form_generator($field);