-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathform_fields.php
More file actions
executable file
·146 lines (135 loc) · 7.33 KB
/
form_fields.php
File metadata and controls
executable file
·146 lines (135 loc) · 7.33 KB
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
<?php
// views/user/form_fields.php
// 変数のデフォルト値を設定
if (!isset($user)) $user = [];
if (!isset($isEdit)) $isEdit = false;
// デバッグ用(実際の運用では削除してください)
// echo "<pre>";
// var_dump($user);
// echo "</pre>";
?>
<div class="row mb-3">
<div class="col-md-6">
<label for="username" class="form-label">ユーザー名 <span class="text-danger">*</span></label>
<input type="text" class="form-control" id="username" name="username"
value="<?php echo isset($user['username']) ? htmlspecialchars($user['username']) : ''; ?>"
required <?php echo $isEdit ? 'readonly' : ''; ?>>
<div class="invalid-feedback"></div>
</div>
<div class="col-md-6">
<label for="email" class="form-label">メールアドレス <span class="text-danger">*</span></label>
<input type="email" class="form-control" id="email" name="email"
value="<?php echo isset($user['email']) ? htmlspecialchars($user['email']) : ''; ?>"
required>
<div class="invalid-feedback"></div>
</div>
</div>
<div class="row mb-3">
<div class="col-md-6">
<label for="last_name" class="form-label">姓 <span class="text-danger">*</span></label>
<input type="text" class="form-control" id="last_name" name="last_name"
value="<?php echo isset($user['last_name']) ? htmlspecialchars($user['last_name']) : ''; ?>"
required>
<div class="invalid-feedback"></div>
</div>
<div class="col-md-6">
<label for="first_name" class="form-label">名 <span class="text-danger">*</span></label>
<input type="text" class="form-control" id="first_name" name="first_name"
value="<?php echo isset($user['first_name']) ? htmlspecialchars($user['first_name']) : ''; ?>"
required>
<div class="invalid-feedback"></div>
</div>
</div>
<div class="mb-3">
<label for="display_name" class="form-label">表示名 <span class="text-danger">*</span></label>
<input type="text" class="form-control" id="display_name" name="display_name"
value="<?php echo isset($user['display_name']) ? htmlspecialchars($user['display_name']) : ''; ?>"
required>
<div class="invalid-feedback"></div>
<small class="form-text text-muted">氏名から自動生成されます。必要に応じて変更できます。</small>
</div>
<?php if (!$isEdit): ?>
<div class="row mb-3">
<div class="col-md-6">
<label for="password" class="form-label">パスワード <span class="text-danger">*</span></label>
<input type="password" class="form-control" id="password" name="password" required>
<div class="invalid-feedback"></div>
<div class="mt-1">
<div class="progress" style="height: 5px;">
<div id="password-strength" class="progress-bar" role="progressbar" style="width: 0%;" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100"></div>
</div>
<small id="password-feedback" class="form-text text-muted"></small>
</div>
</div>
<div class="col-md-6">
<label for="password_confirm" class="form-label">パスワード(確認) <span class="text-danger">*</span></label>
<input type="password" class="form-control" id="password_confirm" name="password_confirm" required>
<div class="invalid-feedback"></div>
</div>
</div>
<?php endif; ?>
<div class="mb-3">
<label for="organization_id" class="form-label">主所属組織</label>
<?php $selectedOrganizationId = isset($primaryOrgId) ? (string)$primaryOrgId : (isset($user['organization_id']) ? (string)$user['organization_id'] : ''); ?>
<select class="form-select" id="organization_id" name="organization_id"
data-selected="<?php echo htmlspecialchars($selectedOrganizationId); ?>">
<option value="">選択してください</option>
<?php if (isset($organizations) && is_array($organizations)): ?>
<?php foreach ($organizations as $organization): ?>
<option value="<?php echo $organization['id']; ?>" <?php echo $selectedOrganizationId === (string)$organization['id'] ? 'selected' : ''; ?>>
<?php echo htmlspecialchars($organization['name']); ?>
</option>
<?php endforeach; ?>
<?php endif; ?>
</select>
</div>
<div class="mb-3">
<label class="form-label">追加所属組織</label>
<div id="organizations-container">
<!-- 追加組織の行はJSで動的に生成 -->
</div>
<button type="button" id="add-organization" class="btn btn-outline-secondary btn-sm mt-2">
<i class="fas fa-plus"></i> 組織を追加
</button>
<input type="hidden" id="additional_organizations" name="additional_organizations"
value="<?php echo isset($additionalOrganizations) ? $additionalOrganizations : ''; ?>">
</div>
<div class="row mb-3">
<div class="col-md-6">
<label for="position" class="form-label">役職</label>
<input type="text" class="form-control" id="position" name="position"
value="<?php echo isset($user['position']) ? htmlspecialchars($user['position']) : ''; ?>">
</div>
<div class="col-md-6">
<label for="phone" class="form-label">電話番号</label>
<input type="text" class="form-control" id="phone" name="phone"
value="<?php echo isset($user['phone']) ? htmlspecialchars($user['phone']) : ''; ?>">
</div>
</div>
<div class="row mb-3">
<div class="col-md-6">
<label for="mobile_phone" class="form-label">携帯電話</label>
<input type="text" class="form-control" id="mobile_phone" name="mobile_phone"
value="<?php echo isset($user['mobile_phone']) ? htmlspecialchars($user['mobile_phone']) : ''; ?>">
</div>
<div class="col-md-6">
<label for="status" class="form-label">ステータス <span class="text-danger">*</span></label>
<select class="form-select" id="status" name="status" required>
<option value="active" <?php echo isset($user['status']) && $user['status'] === 'active' ? 'selected' : ''; ?>>有効</option>
<option value="inactive" <?php echo isset($user['status']) && $user['status'] === 'inactive' ? 'selected' : ''; ?>>無効</option>
<option value="suspended" <?php echo isset($user['status']) && $user['status'] === 'suspended' ? 'selected' : ''; ?>>停止</option>
</select>
</div>
</div>
<?php if ($isEdit && \Core\Auth::getInstance()->isAdmin()): ?>
<div class="mb-3">
<label for="role" class="form-label">役割 <span class="text-danger">*</span></label>
<select class="form-select" id="role" name="role" required>
<option value="user" <?php echo isset($user['role']) && $user['role'] === 'user' ? 'selected' : ''; ?>>一般ユーザー</option>
<option value="manager" <?php echo isset($user['role']) && $user['role'] === 'manager' ? 'selected' : ''; ?>>管理者</option>
<option value="admin" <?php echo isset($user['role']) && $user['role'] === 'admin' ? 'selected' : ''; ?>>システム管理者</option>
</select>
</div>
<?php else: ?>
<input type="hidden" name="role" value="<?php echo $isEdit && isset($user['role']) ? htmlspecialchars($user['role']) : 'user'; ?>">
<?php endif; ?>