function edit($staff_id) { $app = get_app(); $staff = Staff::find_by_id($staff_id); //GET if ($app->request()->isGet()) { render_with_layout('misc.php', 'Staffs/edit.php', compact('staff')); } //POST if ($app->request()->isPost()) { $post = $app->request()->post(); // $staff->identifier = $post['identifier']; $staff->name = $post['name']; $staff->short = $post['short']; $staff->group_id = $post['group_id']; if (!$staff->is_valid()) { $app->flashNow('errors', $staff->errors); render_with_layout('misc.php', 'Staffs/add.php', compact('staff')); } else { $staff->save(); $app->flash('success', '员工信息更新成功!'); redirect('/staffs'); } } }
function staff($short) { // 按照员工拼音缩写查找员工 // 如果执行查询操作的是 操作者 权限的用户 // 只允许查询与其同一班组的员工 : team_id if (has_perm(8, 4)) { $team_id = $_SESSION['team_id']; $staffs = Staff::find('all', array('conditions' => " short LIKE '{$short}%' AND group_id = {$team_id} ", 'order' => 'id desc')); } else { $staffs = Staff::find('all', array('conditions' => "short like '{$short}%'", 'order' => 'id desc')); } $results = array(); if (!empty($staffs)) { foreach ($staffs as $staff) { $results[] = array('id' => $staff->id, 'name' => $staff->name); } } echo json_encode($results); }
function stat_staff_unsubmitted_work($staff_id) { $staff = Staff::find_by_id($staff_id); $results = Work::get_staff_unsubmitted_works($staff); $table_title = '操作者未交验工时明细'; render_with_layout('misc.php', 'Statistics/work/stat_staff_unsubmitted_work.php', compact('results', 'table_title')); }
function staff_rest_work_hours() { $staffs = Staff::find('all'); $resutls = array(); foreach ($staffs as $staff) { $results[] = array('staff' => $staff->name, 'work_hours' => get_staff_rest_work_hours($staff)); } //debug( $results ); render_with_layout('misc.php', 'Misc/staff_rest_work_hours.php', compact('results')); }
function quick_list_get_html($part) { $app = get_app(); $cur_proc_id = ''; // 查找当前工序 foreach ($part->processes as $proc) { if (!empty($proc->production_date) && !$proc->is_done) { $cur_proc_id = $proc->id; } } if (empty($cur_proc_id)) { $processes = $part->processes; $cur_proc_id = $processes[0]->id; } // 渲染现场工时列表View $staffs = Staff::find('all', array('order' => 'id asc')); $works = Work::find_all_by_process_id($cur_proc_id, array('order' => 'id asc')); if (count($works)) { $slider_step = get_slider_step($works); $loongest_float_work = get_loongest_float_num_work($works); $fixed_num = get_float_num($loongest_float_work->count); } else { $slider_step = 1; $fixed_num = 2; } $available_count = Process::get_available_count($cur_proc_id, $fixed_num); $proc_id = $cur_proc_id; return array('html' => $app->view->fetch('Works/list.php', compact('proc_id', 'works', 'staffs', 'available_count', 'slider_step')), 'cur_proc_id' => $cur_proc_id); }