1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
|
<?php defined('BASEPATH') or exit('No direct script access allowed');
class Bk_judge extends MY_Controller { public function __construct() { // set $this->table and $this->model parent::__construct(substr(__CLASS__, 3));
$this->block_methods = array('sort');
$this->updated_single_language_fields = array( 'name' => 'Name', 'login_id' => 'ID', 'login_pw' => 'Password', ); $tmp = array( 'confirm_login_pw' => __('Confirm Password'), 'groups_id[]' => __('Groups'), ); $this->single_language_fields = array_merge($this->updated_single_language_fields, $tmp);
$this->single_language_validate_fields = array( 'name' => 'required', 'login_id' => 'required', 'login_pw' => 'required', 'confirm_login_pw' => 'required|matches[login_pw]', 'groups_id[]' => 'callback_validate_group', );
$this->single_language_encpytion_fields = array( 'login_pw', );
$this->validate_massages['validate_group'] = __('Please enter validated ') . ' %s';
$this->load->vars('groups', Group_model::get_data('webadmin')); }
public function modify($id) { $groups_judges = Group_judge_model::get_data_by_field_with_value(['judge_id' => $id]); $groups_id = array(); foreach ($groups_judges as $row) { $groups_id[] = $row['group_id']; }
$this->load->vars('groups_id', $groups_id);
$this->single_language_validate_fields['login_pw'] = ''; $this->single_language_validate_fields['confirm_login_pw'] = 'matches[login_pw]';
parent::modify($id); }
public function submit_form($id = null) { $latest_no = Judge_no_model::create()->id; $this->additional_submit_data['judge_no'] = 'JG' . date('ym') . str_pad($latest_no, 4, "0", STR_PAD_LEFT);
if (!empty($id)) { $this->single_language_validate_fields['login_pw'] = ''; $this->single_language_validate_fields['confirm_login_pw'] = 'matches[login_pw]'; }
if (empty(trim($_POST['login_pw']))) { unset($this->updated_single_language_fields['login_pw']); }
parent::submit_form($id); } protected function update_other_tables($id, $current_update_data, $action) { $groups_id = $_POST['groups_id']; $delete_data = array( "deleted" => 1, "deleted_by" => $_SESSION['sys_user_id'], "deleted_at" => date('Y-m-d H:i:s'), ); $current_group_judge = Group_judge_model::where('judge_id', $id)->where('deleted', 0)->get(); foreach ($current_group_judge as $row) { if (!in_array($row['group_id'], $groups_id)) { Group_judge_model::where('id', $row['id'])->where('deleted', 0)->update($delete_data);
$current_score = Score_model::where('judge_id', $id)->where('deleted', 0)->get(); foreach ($current_score as $row2) { $application = Application_model::get_certain($row2['application_id']); if ($application['group_id'] == $row['group_id']) { Score_model::where('id', $row2['id'])->update($delete_data); Score_status_model::where('judge_id', $id)->where('deleted', 0)->update($delete_data); } } } else { $groups_id = array_diff($groups_id, [$row['group_id']]); } } foreach ($groups_id as $group_id) { Group_judge_model::create()->update(['judge_id' => $id, 'group_id' => $group_id]); } }
public function validate_group($str) { return count(Group_model::get_certain($str)) || empty($str) ? true : false; } }
|