Supervisor: 残=新規・保存・印刷・時計表示
This commit is contained in:
@ -53,7 +53,9 @@ services:
|
|||||||
- type: volume
|
- type: volume
|
||||||
source: nginx_logs
|
source: nginx_logs
|
||||||
target: /var/log/nginx
|
target: /var/log/nginx
|
||||||
- media_data:/app/media:ro
|
- type: bind
|
||||||
|
source: ./media
|
||||||
|
target: /usr/share/nginx/html/media
|
||||||
ports:
|
ports:
|
||||||
- "80:80"
|
- "80:80"
|
||||||
depends_on:
|
depends_on:
|
||||||
@ -73,4 +75,3 @@ volumes:
|
|||||||
geoserver-data:
|
geoserver-data:
|
||||||
static_volume:
|
static_volume:
|
||||||
nginx_logs:
|
nginx_logs:
|
||||||
media_data:
|
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
BIN
rog/.urls.py.swp
BIN
rog/.urls.py.swp
Binary file not shown.
@ -323,6 +323,8 @@ class NewEvent2(models.Model):
|
|||||||
class_solo_male = models.BooleanField(default=True)
|
class_solo_male = models.BooleanField(default=True)
|
||||||
class_solo_female = models.BooleanField(default=True)
|
class_solo_female = models.BooleanField(default=True)
|
||||||
|
|
||||||
|
self_rogaining = models.BooleanField(default=False)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return f"{self.event_name} - From:{self.start_datetime} To:{self.end_datetime}"
|
return f"{self.event_name} - From:{self.start_datetime} To:{self.end_datetime}"
|
||||||
|
|
||||||
|
|||||||
@ -2362,6 +2362,12 @@ def get_team_info(request, zekken_number):
|
|||||||
entry = Entry.objects.select_related('team','event').get(zekken_number=zekken_number)
|
entry = Entry.objects.select_related('team','event').get(zekken_number=zekken_number)
|
||||||
members = Member.objects.filter(team=entry.team)
|
members = Member.objects.filter(team=entry.team)
|
||||||
|
|
||||||
|
start_datetime = entry.event.start_datetime #イベントの規定スタート時刻
|
||||||
|
if entry.event.self_rogaining:
|
||||||
|
#get_checkinsの中で、
|
||||||
|
# start_datetime = -1(ロゲ開始)のcreate_at
|
||||||
|
logger.debug(f"self.rogaining={entry.event.self_rogaining} => start_datetime = -1(ロゲ開始)のcreate_at")
|
||||||
|
|
||||||
# チームのゴール時間を取得
|
# チームのゴール時間を取得
|
||||||
goal_record = GoalImages.objects.filter(
|
goal_record = GoalImages.objects.filter(
|
||||||
team_name=entry.team.team_name,
|
team_name=entry.team.team_name,
|
||||||
@ -2373,7 +2379,8 @@ def get_team_info(request, zekken_number):
|
|||||||
'members': ', '.join([f"{m.lastname} {m.firstname}" for m in members]),
|
'members': ', '.join([f"{m.lastname} {m.firstname}" for m in members]),
|
||||||
'event_code': entry.event.event_name,
|
'event_code': entry.event.event_name,
|
||||||
'start_datetime': entry.event.start_datetime,
|
'start_datetime': entry.event.start_datetime,
|
||||||
'end_datetime': goal_record.goaltime if goal_record else None
|
'end_datetime': goal_record.goaltime if goal_record else None,
|
||||||
|
'duration': entry.category.duration.total_seconds()
|
||||||
})
|
})
|
||||||
|
|
||||||
def create(self, request, *args, **kwargs):
|
def create(self, request, *args, **kwargs):
|
||||||
|
|||||||
Binary file not shown.
@ -6,24 +6,25 @@
|
|||||||
<title>スーパーバイザーパネル</title>
|
<title>スーパーバイザーパネル</title>
|
||||||
<link href="https://cdnjs.cloudflare.com/ajax/libs/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
|
<link href="https://cdnjs.cloudflare.com/ajax/libs/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
|
||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/Sortable/1.15.0/Sortable.min.js"></script>
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/Sortable/1.15.0/Sortable.min.js"></script>
|
||||||
|
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css" rel="stylesheet">
|
||||||
</head>
|
</head>
|
||||||
<body class="bg-gray-50">
|
<body class="bg-gray-50">
|
||||||
<div class="container mx-auto p-4">
|
<div class="container mx-auto p-4">
|
||||||
<div class="bg-white rounded-lg shadow-lg p-6 mb-6">
|
<div class="bg-white rounded-lg shadow-lg p-6 mb-6">
|
||||||
<h1 class="text-2xl font-bold mb-6">スーパーバイザーパネル</h1>
|
<h1 class="text-2xl font-bold mb-6">通過審査管理画面</h1>
|
||||||
|
|
||||||
<!-- 選択フォーム -->
|
<!-- 選択フォーム -->
|
||||||
<div class="grid grid-cols-1 md:grid-cols-4 gap-4 mb-6">
|
<div class="grid grid-cols-1 md:grid-cols-4 gap-4 mb-6">
|
||||||
<div>
|
<div>
|
||||||
<label class="block text-sm font-medium text-gray-700 mb-2">イベントコード</label>
|
<label class="block text-sm font-medium text-gray-700 mb-2">イベントコード</label>
|
||||||
<select id="eventCode" class="w-full border border-gray-300 rounded-md px-3 py-2">
|
<select id="eventCode" class="w-full border border-gray-300 rounded-md px-3 py-2">
|
||||||
<option value="">イベントを選択してください</option>
|
<option value="">イベントを選択</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<label class="block text-sm font-medium text-gray-700 mb-2">ゼッケン番号</label>
|
<label class="block text-sm font-medium text-gray-700 mb-2">ゼッケン番号</label>
|
||||||
<select id="zekkenNumber" class="w-full border border-gray-300 rounded-md px-3 py-2">
|
<select id="zekkenNumber" class="w-full border border-gray-300 rounded-md px-3 py-2">
|
||||||
<option value="">ゼッケン番号を選択してください</option>
|
<option value="">ゼッケン番号を選択</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div class="bg-gray-50 p-4 rounded-lg">
|
<div class="bg-gray-50 p-4 rounded-lg">
|
||||||
@ -44,7 +45,11 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="bg-gray-50 p-4 rounded-lg">
|
<div class="bg-gray-50 p-4 rounded-lg">
|
||||||
<div class="text-sm text-gray-500">ゴール時刻</div>
|
<div class="text-sm text-gray-500">ゴール時刻</div>
|
||||||
<div id="goalTime" class="font-semibold"></div>
|
<div class="goal-time-container">
|
||||||
|
<span id="goalTimeDisplay" class="goal-time-display cursor-pointer"></span>
|
||||||
|
<input type="datetime-local" id="goalTimeInput" class="goal-time-input hidden border rounded px-2 py-1"
|
||||||
|
onchange="updateGoalTime(this)">
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="bg-gray-50 p-4 rounded-lg">
|
<div class="bg-gray-50 p-4 rounded-lg">
|
||||||
<div class="text-sm text-gray-500">ゴール時計</div>
|
<div class="text-sm text-gray-500">ゴール時計</div>
|
||||||
@ -80,14 +85,15 @@
|
|||||||
<table class="min-w-full divide-y divide-gray-200">
|
<table class="min-w-full divide-y divide-gray-200">
|
||||||
<thead class="bg-gray-50">
|
<thead class="bg-gray-50">
|
||||||
<tr>
|
<tr>
|
||||||
<th class="px-2 py-3 text-left text-xs font-medium text-gray-500 uppercase">走行順</th>
|
<th class="w-8"></th> <!-- ハンバーガーアイコン用 -->
|
||||||
<th class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase">規定写真</th>
|
<th class="px-1 py-3 text-left text-xs font-medium text-gray-500 uppercase">走行順</th>
|
||||||
<th class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase">撮影写真</th>
|
<th class="px-2 py-3 text-left text-xs font-medium text-gray-500 uppercase">規定写真</th>
|
||||||
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase">CP名称</th>
|
<th class="px-2 py-3 text-left text-xs font-medium text-gray-500 uppercase">撮影写真</th>
|
||||||
<th class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase">通過時刻</th>
|
<th class="px-2 py-3 text-left text-xs font-medium text-gray-500 uppercase">CP名称</th>
|
||||||
<th class="px-2 py-3 text-left text-xs font-medium text-gray-500 uppercase">通過審査</th>
|
<th class="px-2 py-3 text-left text-xs font-medium text-gray-500 uppercase">通過時刻</th>
|
||||||
<th class="px-2 py-3 text-left text-xs font-medium text-gray-500 uppercase">買物審査</th>
|
<th class="px-1 py-3 text-left text-xs font-medium text-gray-500 uppercase">買物申請</th>
|
||||||
<th class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase">獲得点数</th>
|
<th class="px-1 py-3 text-left text-xs font-medium text-gray-500 uppercase">通過審査</th>
|
||||||
|
<th class="px-2 py-3 text-left text-xs font-medium text-gray-500 uppercase">獲得点数</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody id="checkinList" class="bg-white divide-y divide-gray-200">
|
<tbody id="checkinList" class="bg-white divide-y divide-gray-200">
|
||||||
@ -115,9 +121,9 @@
|
|||||||
// APIのベースURLを環境に応じて設定
|
// APIのベースURLを環境に応じて設定
|
||||||
const API_BASE_URL = '/api';
|
const API_BASE_URL = '/api';
|
||||||
|
|
||||||
|
// イベントリスナーの設定
|
||||||
document.addEventListener('DOMContentLoaded', function() {
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
// Sortable初期化
|
// Sortable初期化これで、通過順序を変更できる
|
||||||
const checkinList = document.getElementById('checkinList');
|
const checkinList = document.getElementById('checkinList');
|
||||||
new Sortable(checkinList, {
|
new Sortable(checkinList, {
|
||||||
animation: 150,
|
animation: 150,
|
||||||
@ -126,7 +132,7 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// イベントコードのドロップダウン要素を取得
|
// 選択されたイベントコード・ゼッケン番号を取得
|
||||||
const eventCodeSelect = document.getElementById('eventCode');
|
const eventCodeSelect = document.getElementById('eventCode');
|
||||||
const zekkenNumberSelect = document.getElementById('zekkenNumber');
|
const zekkenNumberSelect = document.getElementById('zekkenNumber');
|
||||||
|
|
||||||
@ -146,11 +152,11 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
// チェックボックス変更時の処理
|
// チェックボックス変更時の処理
|
||||||
checkinList.addEventListener('change', function(e) {
|
//checkinList.addEventListener('change', function(e) {
|
||||||
if (e.target.type === 'checkbox') {
|
// if (e.target.type === 'checkbox') {
|
||||||
updateValidation(e.target);
|
// updateValidation(e.target);
|
||||||
}
|
// }
|
||||||
});
|
//});
|
||||||
|
|
||||||
// 保存ボタンの処理
|
// 保存ボタンの処理
|
||||||
document.getElementById('saveButton').addEventListener('click', saveChanges);
|
document.getElementById('saveButton').addEventListener('click', saveChanges);
|
||||||
@ -163,6 +169,195 @@
|
|||||||
loadEventCodes();
|
loadEventCodes();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// editGoalTime関数の修正
|
||||||
|
function editGoalTime(element) {
|
||||||
|
const container = element.closest('.goal-time-container');
|
||||||
|
if (!container) {
|
||||||
|
console.error('Goal time container not found');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const display = container.querySelector('.goal-time-display');
|
||||||
|
const input = container.querySelector('.goal-time-input');
|
||||||
|
|
||||||
|
if (!display || !input) {
|
||||||
|
console.error('Goal time elements not found');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (display.textContent && display.textContent !== '-') {
|
||||||
|
try {
|
||||||
|
const date = new Date(display.textContent);
|
||||||
|
input.value = date.toISOString().slice(0, 19);
|
||||||
|
} catch (e) {
|
||||||
|
console.error('Error parsing date:', e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// input要素のstep属性を1秒に設定
|
||||||
|
input.setAttribute('step', '1'); // 1秒単位で入力可能に設定
|
||||||
|
|
||||||
|
display.classList.add('hidden');
|
||||||
|
input.classList.remove('hidden');
|
||||||
|
input.focus();
|
||||||
|
}
|
||||||
|
|
||||||
|
// ゴール時刻編集機能
|
||||||
|
function old_editGoalTime(element) {
|
||||||
|
const display = element.getElementById('goalTimeDisplay');
|
||||||
|
const input = element.getElementById('goalTimeInput');
|
||||||
|
|
||||||
|
|
||||||
|
if (!display || !input) {
|
||||||
|
console.error('Goal time elements not found');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 現在の表示時刻をinputの初期値として設定
|
||||||
|
const currentTime = display.textContent;
|
||||||
|
if (currentTime && currentTime !== '-') {
|
||||||
|
try {
|
||||||
|
const date = new Date(currentTime);
|
||||||
|
input.value = date.toISOString().slice(0, 19); // YYYY-MM-DDThh:mm:ss 形式に変換
|
||||||
|
} catch (e) {
|
||||||
|
console.error('Error parsing date:', e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// input要素のstep属性を1秒に設定
|
||||||
|
input.setAttribute('step', '1'); // 1秒単位で入力可能に設定
|
||||||
|
|
||||||
|
display.classList.add('hidden');
|
||||||
|
input.classList.remove('hidden');
|
||||||
|
input.focus();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateGoalTime(input) {
|
||||||
|
|
||||||
|
const display = document.getElementById('goalTimeDisplay');
|
||||||
|
const validateElement = document.getElementById('validate');
|
||||||
|
|
||||||
|
if (!display) {
|
||||||
|
console.error('Goal time display element not found');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const newTime = new Date(input.value);
|
||||||
|
display.textContent = newTime.toLocaleString();
|
||||||
|
|
||||||
|
const eventCodeSelect = document.getElementById('eventCode');
|
||||||
|
const event_code = eventCodeSelect.value;
|
||||||
|
const zekkenNumberSelect = document.getElementById('zekkenNumber');
|
||||||
|
const zekkenNumber = zekkenNumberSelect.value
|
||||||
|
|
||||||
|
// イベントとチェックインデータを取得
|
||||||
|
fetch(`${API_BASE_URL}/team_info/${zekkenNumber}`,{
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(team => {
|
||||||
|
if (team.self_rogaining) {
|
||||||
|
// セルフロゲイニングの場合
|
||||||
|
fetch(`${API_BASE_URL}/checkins/${zekkenNumber}/${eventCode}/`,{
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(checkins => {
|
||||||
|
const startCheckin = checkins.find(c => c.cp_number === -1);
|
||||||
|
if (startCheckin) {
|
||||||
|
const startTime = new Date(startCheckin.create_at);
|
||||||
|
const timeDiff = (newTime - startTime) / 1000; // 秒単位の差
|
||||||
|
const maxTime = team.duration + 15*60; // 制限時間+15分
|
||||||
|
updateValidation(timeDiff, maxTime );
|
||||||
|
const overtime = ((newTime - startTime) / 1000 - team.duration/1000 + 60 ) // 60;
|
||||||
|
if( overtime>0 ){
|
||||||
|
late_point = overtime*(-50);
|
||||||
|
lateElement = document.getElementById('latePoints');
|
||||||
|
lateElement.textContent = late_point;
|
||||||
|
lateElement.classList.add('text-red-600');
|
||||||
|
}else{
|
||||||
|
lateElement = document.getElementById('latePoints');
|
||||||
|
lateElement.textContent = 0;
|
||||||
|
lateElement.classList.remove('text-red-600');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(error => handleApiError(error));
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// 通常のロゲイニングの場合
|
||||||
|
const startTime = new Date(team.start_datetime);
|
||||||
|
const timeDiff = (newTime - startTime) / 1000; // 分単位の差
|
||||||
|
const maxTime = team.duration + 15*60; // 制限時間+15分
|
||||||
|
|
||||||
|
console.info('startTime=',startTime,',goalTime=',newTime,',timeDiff=',timeDiff,'duration=',team.duration,',maxTime=',maxTime);
|
||||||
|
updateValidation(timeDiff, maxTime );
|
||||||
|
|
||||||
|
// 1秒でも遅刻すると、1分につき-50点
|
||||||
|
const overtime = ((newTime - startTime) / 1000 - team.duration );
|
||||||
|
if( overtime>0 ){
|
||||||
|
console.info('overtime=',overtime);
|
||||||
|
late_point = Math.ceil(overtime/60)*(-50);
|
||||||
|
lateElement = document.getElementById('latePoints');
|
||||||
|
lateElement.textContent = late_point;
|
||||||
|
lateElement.classList.add('text-red-600');
|
||||||
|
}else{
|
||||||
|
lateElement = document.getElementById('latePoints');
|
||||||
|
lateElement.textContent = 0;
|
||||||
|
lateElement.classList.remove('text-red-600');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
} catch (e) {
|
||||||
|
console.error('Error updating goal time:', e);
|
||||||
|
alert('無効な日時形式です。');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
display.classList.remove('hidden');
|
||||||
|
input.classList.add('hidden');
|
||||||
|
}
|
||||||
|
|
||||||
|
// 判定の更新を行う補助関数
|
||||||
|
function updateValidation(timeDiff, maxTime) {
|
||||||
|
console.log('updateValidation',timeDiff,' > ',maxTime)
|
||||||
|
const validateElement = document.getElementById('validate');
|
||||||
|
if (validateElement) {
|
||||||
|
if (timeDiff > maxTime) {
|
||||||
|
validateElement.textContent = '失格';
|
||||||
|
validateElement.classList.add('text-red-600');
|
||||||
|
validateElement.classList.remove('text-green-600');
|
||||||
|
} else {
|
||||||
|
validateElement.textContent = '合格';
|
||||||
|
validateElement.classList.add('text-green-600');
|
||||||
|
validateElement.classList.remove('text-red-600');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function validateGoalTime(goalTime) {
|
||||||
|
const eventEndTime = new Date(document.getElementById('eventEndTime').value);
|
||||||
|
const goalDateTime = new Date(goalTime);
|
||||||
|
const timeDiff = (goalDateTime - eventEndTime) / (1000 * 60); // 分単位の差
|
||||||
|
|
||||||
|
const validateElement = document.getElementById('validate');
|
||||||
|
if (timeDiff > 15) {
|
||||||
|
validateElement.textContent = '失格';
|
||||||
|
validateElement.classList.add('text-red-600');
|
||||||
|
} else {
|
||||||
|
validateElement.textContent = '正常';
|
||||||
|
validateElement.classList.remove('text-red-600');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function loadEventCodes() {
|
async function loadEventCodes() {
|
||||||
try {
|
try {
|
||||||
const response = await fetch(`${API_BASE_URL}/events/`);
|
const response = await fetch(`${API_BASE_URL}/events/`);
|
||||||
@ -177,7 +372,7 @@
|
|||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
const select = document.getElementById('eventCode');
|
const select = document.getElementById('eventCode');
|
||||||
// 既存のオプションをクリア
|
// 既存のオプションをクリア
|
||||||
select.innerHTML = '<option value="">イベントを選択してください</option>';
|
select.innerHTML = '<option value="">イベントを選択</option>';
|
||||||
|
|
||||||
data.forEach(event => {
|
data.forEach(event => {
|
||||||
const option = document.createElement('option');
|
const option = document.createElement('option');
|
||||||
@ -201,7 +396,7 @@
|
|||||||
.then(response => response.json())
|
.then(response => response.json())
|
||||||
.then(data => {
|
.then(data => {
|
||||||
const select = document.getElementById('zekkenNumber');
|
const select = document.getElementById('zekkenNumber');
|
||||||
select.innerHTML = '<option value="">ゼッケン番号を選択してください</option>';
|
select.innerHTML = '<option value="">ゼッケン番号を選択</option>';
|
||||||
data.forEach(number => {
|
data.forEach(number => {
|
||||||
const option = document.createElement('option');
|
const option = document.createElement('option');
|
||||||
option.value = number;
|
option.value = number;
|
||||||
@ -229,6 +424,9 @@
|
|||||||
const teamData = await teamResponse.json();
|
const teamData = await teamResponse.json();
|
||||||
const checkinsData = await checkinsResponse.json();
|
const checkinsData = await checkinsResponse.json();
|
||||||
|
|
||||||
|
// ゴール時刻の表示を更新
|
||||||
|
updateGoalTimeDisplay(teamData.end_datetime);
|
||||||
|
|
||||||
// イベントコードに対応するイベントを検索
|
// イベントコードに対応するイベントを検索
|
||||||
//const event = eventData.find(e => e.code === document.getElementById('eventCode').value);
|
//const event = eventData.find(e => e.code === document.getElementById('eventCode').value);
|
||||||
|
|
||||||
@ -236,10 +434,22 @@
|
|||||||
document.getElementById('members').textContent = teamData.members || '-';
|
document.getElementById('members').textContent = teamData.members || '-';
|
||||||
document.getElementById('startTime').textContent =
|
document.getElementById('startTime').textContent =
|
||||||
teamData.start_datetime ? new Date(teamData.start_datetime).toLocaleString() : '-';
|
teamData.start_datetime ? new Date(teamData.start_datetime).toLocaleString() : '-';
|
||||||
document.getElementById('goalTime').textContent =
|
//document.getElementById('goalTime').textContent =
|
||||||
teamData.end_datetime ? new Date(teamData.end_datetime).toLocaleString() : '-';
|
// teamData.end_datetime ? new Date(teamData.end_datetime).toLocaleString() : '-';
|
||||||
//'(未ゴール)';
|
//'(未ゴール)';
|
||||||
|
|
||||||
|
const goalTimeDisplay = document.getElementById('goalTimeDisplay');
|
||||||
|
const goalTime = teamData.end_datetime ?
|
||||||
|
new Date(teamData.end_datetime).toLocaleString() :
|
||||||
|
'未ゴール';
|
||||||
|
goalTimeDisplay.textContent = goalTime;
|
||||||
|
|
||||||
|
if (goalTime === '-') {
|
||||||
|
goalTimeDisplay.classList.add('cursor-pointer');
|
||||||
|
goalTimeDisplay.onclick = () => editGoalTime(goalTimeDisplay);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// チェックインリストの更新
|
// チェックインリストの更新
|
||||||
const tbody = document.getElementById('checkinList');
|
const tbody = document.getElementById('checkinList');
|
||||||
tbody.innerHTML = ''; // 既存のデータをクリア
|
tbody.innerHTML = ''; // 既存のデータをクリア
|
||||||
@ -251,63 +461,65 @@
|
|||||||
const tr = document.createElement('tr');
|
const tr = document.createElement('tr');
|
||||||
tr.dataset.id = checkin.id;
|
tr.dataset.id = checkin.id;
|
||||||
tr.dataset.cpNumber = checkin.cp_number;
|
tr.dataset.cpNumber = checkin.cp_number;
|
||||||
|
tr.dataset.buyPoint = checkin.buy_point;
|
||||||
const bgColor = checkin.buy_point > 0 ? 'bg-blue-100' : 'bg-red-100';
|
tr.dataset.checkinPoint = checkin.checkin_point;
|
||||||
|
const bgColor = checkin.buy_point > 0 ? 'bg-blue-100' : '';
|
||||||
|
|
||||||
tr.innerHTML = `
|
tr.innerHTML = `
|
||||||
<td class="px-6 py-4">${checkin.path_order}</td>
|
<td class="px-1 py-3 cursor-move">
|
||||||
<td class="px-6 py-4">
|
<i class="fas fa-bars text-gray-400"></i>
|
||||||
|
</td>
|
||||||
|
<td class="px-2 py-3">${checkin.path_order}</td>
|
||||||
|
<td class="px-2 py-3">
|
||||||
${checkin.photos ?
|
${checkin.photos ?
|
||||||
`<img src="/media/compressed/${checkin.photos}" class="h-20 w-20 object-cover rounded" onclick="showLargeImage(this.src)">` : ''}
|
`<img src="/media/compressed/${checkin.photos}" class="h-20 w-20 object-cover rounded" onclick="showLargeImage(this.src)">` : ''}
|
||||||
<div class="text-sm">${checkin.photos}</div>
|
|
||||||
</td>
|
</td>
|
||||||
<td class="px-6 py-4">
|
<td class="px-2 py-3">
|
||||||
${checkin.image_address ?
|
${checkin.image_address ?
|
||||||
`<img src="${checkin.image_address}" class="h-20 w-20 object-cover rounded">` : ''}
|
`<img src="${checkin.image_address}" class="h-20 w-20 object-cover rounded" onclick="showLargeImage(this.src)">` : ''}
|
||||||
${checkin.receipt_address && checkin.buy_flag ?
|
|
||||||
`<img src="${checkin.receipt_address}" class="h-20 w-20 object-cover rounded ml-2">` : ''}
|
|
||||||
<div class="text-sm">${checkin.image_address}</div>
|
|
||||||
<div class="text-sm">${checkin.receipt_address}</div>
|
|
||||||
</td>
|
</td>
|
||||||
<td class="px-6 py-4 ${bgColor}">
|
<td class="px-2 py-3 ${bgColor}">
|
||||||
<div class="font-bold">${checkin.sub_loc_id}</div>
|
<div class="font-bold">${checkin.sub_loc_id}</div>
|
||||||
<div class="text-sm">${checkin.location_name}</div>
|
<div class="text-sm">${checkin.location_name}</div>
|
||||||
</td>
|
</td>
|
||||||
<td class="px-6 py-4">${checkin.create_at || '不明'}</td>
|
<td class="px-2 py-3">${checkin.create_at || '不明'}</td>
|
||||||
<td class="px-6 py-4">
|
<td class="px-1 py-3">
|
||||||
|
${checkin.buy_point > 0 ? `
|
||||||
|
<input type="checkbox"
|
||||||
|
${checkin.buy_flag ? 'checked' : ''}
|
||||||
|
class="h-4 w-4 text-green-600 rounded buy-checkbox"
|
||||||
|
onchange="updatePoints(this)">
|
||||||
|
` : ''}
|
||||||
|
</td>
|
||||||
|
<td class="px-1 py-3">
|
||||||
<input type="checkbox"
|
<input type="checkbox"
|
||||||
${checkin.validate_location ? 'checked' : ''}
|
${checkin.validate_location ? 'checked' : ''}
|
||||||
class="h-4 w-4 text-blue-600 rounded validate-checkbox"
|
class="h-4 w-4 text-blue-600 rounded validate-checkbox"
|
||||||
onchange="updatePoints(this)">
|
onchange="updatePoints(this)">
|
||||||
</td>
|
</td>
|
||||||
<td class="px-6 py-4">
|
<td class="px-2 py-3 point-value">${calculatePointsForCheckin(checkin)}</td>
|
||||||
${checkin.buy_point > 0 ? `
|
|
||||||
<input type="checkbox"
|
|
||||||
${checkin.buy_flag ? 'checked' : ''}
|
|
||||||
class="h-4 w-4 text-green-600 rounded buy-checkbox"
|
|
||||||
onchange="updateBuyPoints(this)">
|
|
||||||
` : ''}
|
|
||||||
</td>
|
|
||||||
<td class="px-6 py-4 point-value">${checkin.points}</td>
|
|
||||||
`;
|
`;
|
||||||
tbody.appendChild(tr);
|
tbody.appendChild(tr);
|
||||||
|
|
||||||
if (checkin.points) {
|
// 合計計算
|
||||||
if (checkin.buy_flag) {
|
//if (checkin.points) {
|
||||||
buyPoints += checkin.points;
|
// if (checkin.buy_flag) {
|
||||||
} else {
|
// buyPoints += checkin.points;
|
||||||
totalPoints += checkin.points;
|
// } else {
|
||||||
}
|
// totalPoints += checkin.points;
|
||||||
}
|
// }
|
||||||
|
//}
|
||||||
});
|
});
|
||||||
|
updatePathOrders();
|
||||||
|
|
||||||
// 合計ポイントの更新
|
// 合計ポイントの更新
|
||||||
document.getElementById('totalPoints').textContent = totalPoints;
|
//document.getElementById('totalPoints').textContent = totalPoints;
|
||||||
document.getElementById('buyPoints').textContent = buyPoints;
|
//document.getElementById('buyPoints').textContent = buyPoints;
|
||||||
document.getElementById('latePoints').textContent = teamData.late_points || 0;
|
//document.getElementById('latePoints').textContent = teamData.late_points || 0;
|
||||||
document.getElementById('finalPoints').textContent =
|
//document.getElementById('finalPoints').textContent =
|
||||||
totalPoints + buyPoints - (teamData.late_points || 0);
|
// totalPoints + buyPoints + (teamData.late_points || 0);
|
||||||
|
|
||||||
|
calculatePoints(); // 総合ポイントの計算
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error loading team info:', error);
|
console.error('Error loading team info:', error);
|
||||||
@ -329,20 +541,61 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadTeamData_old(zekkenNumber) {
|
// ゴール時刻表示を更新する関数
|
||||||
// チーム情報とチェックインデータを取得
|
function updateGoalTimeDisplay(endDateTime) {
|
||||||
Promise.all([
|
const goalTimeDisplay = document.getElementById('goalTimeDisplay');
|
||||||
fetch(`${API_BASE_URL}/team_info/${zekkenNumber}`),
|
const goalTimeInput = document.getElementById('goalTimeInput');
|
||||||
fetch(`${API_BASE_URL}/checkins/${zekkenNumber}`)
|
|
||||||
]).then(responses => Promise.all(responses.map(r => r.json())))
|
if (!goalTimeDisplay || !goalTimeInput) {
|
||||||
.then(([teamInfo, checkins]) => {
|
console.error('Goal time elements not found');
|
||||||
updateTeamInfo(teamInfo);
|
return;
|
||||||
updateCheckinList(checkins);
|
}
|
||||||
calculatePoints();
|
|
||||||
});
|
let displayText = '-';
|
||||||
|
if (endDateTime) {
|
||||||
|
try {
|
||||||
|
const date = new Date(endDateTime);
|
||||||
|
displayText = date.toLocaleString();
|
||||||
|
// input要素の値も更新
|
||||||
|
goalTimeInput.value = date.toISOString().slice(0, 16);
|
||||||
|
} catch (e) {
|
||||||
|
console.error('Error formatting date:', e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
goalTimeDisplay.textContent = displayText;
|
||||||
|
goalTimeDisplay.onclick = () => editGoalTime(goalTimeDisplay);
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateTeamInfo(teamInfo) {
|
// UI要素をリセットする関数
|
||||||
|
function resetUIElements() {
|
||||||
|
const elements = {
|
||||||
|
'goalTimeDisplay': '-',
|
||||||
|
'teamName': '-',
|
||||||
|
'members': '-',
|
||||||
|
'startTime': '-',
|
||||||
|
'totalPoints': '0',
|
||||||
|
'buyPoints': '0',
|
||||||
|
'latePoints': '0',
|
||||||
|
'finalPoints': '0'
|
||||||
|
};
|
||||||
|
|
||||||
|
for (const [id, defaultValue] of Object.entries(elements)) {
|
||||||
|
const element = document.getElementById(id);
|
||||||
|
if (element) {
|
||||||
|
element.textContent = defaultValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// チェックインリストをクリア
|
||||||
|
const checkinList = document.getElementById('checkinList');
|
||||||
|
if (checkinList) {
|
||||||
|
checkinList.innerHTML = '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// チーム情報の表示...使われていない
|
||||||
|
function nouse_updateTeamInfo(teamInfo) {
|
||||||
document.getElementById('teamName').textContent = teamInfo.team_name;
|
document.getElementById('teamName').textContent = teamInfo.team_name;
|
||||||
document.getElementById('members').textContent = teamInfo.members;
|
document.getElementById('members').textContent = teamInfo.members;
|
||||||
document.getElementById('startTime').textContent = teamInfo.start_time;
|
document.getElementById('startTime').textContent = teamInfo.start_time;
|
||||||
@ -350,7 +603,8 @@
|
|||||||
document.getElementById('latePoints').textContent = teamInfo.late_points;
|
document.getElementById('latePoints').textContent = teamInfo.late_points;
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateCheckinList(checkins) {
|
// 通過リストの表示...呼ばれていない
|
||||||
|
function nouse_updateCheckinList(checkins) {
|
||||||
const tbody = document.getElementById('checkinList');
|
const tbody = document.getElementById('checkinList');
|
||||||
tbody.innerHTML = '';
|
tbody.innerHTML = '';
|
||||||
|
|
||||||
@ -395,8 +649,46 @@
|
|||||||
calculateTotalPoints();
|
calculateTotalPoints();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 削除機能
|
||||||
|
async function deleteCheckin(id) {
|
||||||
|
if (!confirm('このチェックインを削除してもよろしいですか?')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const response = await fetch(`${API_BASE_URL}/checkins/${id}`, {
|
||||||
|
method: 'DELETE',
|
||||||
|
})
|
||||||
|
|
||||||
|
if (response.ok) {
|
||||||
|
const row = document.querySelector(`tr[data-id="${id}"]`);
|
||||||
|
row.remove();
|
||||||
|
calculatePoints(); // 総合ポイントを再計算
|
||||||
|
} else {
|
||||||
|
throw new Error('Delete failed');
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error deleting checkin:', error);
|
||||||
|
alert('削除に失敗しました');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ポイント計算関数
|
||||||
|
function calculatePointsForCheckin(checkin) {
|
||||||
|
let points = 0;
|
||||||
|
if (checkin.validate_location) {
|
||||||
|
if(checkin.buy_flag){
|
||||||
|
points += Number(checkin.buy_point) || 0;
|
||||||
|
}else{
|
||||||
|
points += Number(checkin.checkin_point) || 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return points;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// ポイント更新関数
|
// ポイント更新関数
|
||||||
function updatePoints(checkbox) {
|
function old_updatePoints(checkbox) {
|
||||||
const tr = checkbox.closest('tr');
|
const tr = checkbox.closest('tr');
|
||||||
const pointCell = tr.querySelector('.point-value');
|
const pointCell = tr.querySelector('.point-value');
|
||||||
const cpNumber = tr.dataset.cpNumber;
|
const cpNumber = tr.dataset.cpNumber;
|
||||||
@ -410,8 +702,41 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 審査チェックボックス更新関数
|
||||||
|
function updatePoints(checkbox) {
|
||||||
|
const tr = checkbox.closest('tr');
|
||||||
|
const pointCell = tr.querySelector('.point-value');
|
||||||
|
const cpNumber = tr.dataset.cpNumber;
|
||||||
|
const buyPoint = tr.dataset.buyPoint;
|
||||||
|
const checkinPoint = tr.dataset.checkinPoint;
|
||||||
|
const validateCheckbox = tr.querySelector('.validate-checkbox');
|
||||||
|
const buyCheckbox = tr.querySelector('.buy-checkbox');
|
||||||
|
let checkin = {
|
||||||
|
validate_location: validateCheckbox ? validateCheckbox.checked : false,
|
||||||
|
buy_flag: buyCheckbox ? buyCheckbox.checked : false,
|
||||||
|
points: 0
|
||||||
|
};
|
||||||
|
|
||||||
|
if (checkin.validate_location) {
|
||||||
|
// チェックボックスがONの場合
|
||||||
|
if (checkin.buy_flag) {
|
||||||
|
checkin.points = buyPoint || 0;
|
||||||
|
} else {
|
||||||
|
checkin.points = checkinPoint || 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// チェックボックスがOFFの場合
|
||||||
|
checkin.points = 0;
|
||||||
|
}
|
||||||
|
// ポイントを表示
|
||||||
|
pointCell.textContent = checkin.points;
|
||||||
|
calculatePoints(); // 総合ポイントの計算
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// 買い物ポイント更新関数
|
// 買い物ポイント更新関数
|
||||||
function updateBuyPoints(checkbox) {
|
function old_updateBuyPoints(checkbox) {
|
||||||
const tr = checkbox.closest('tr');
|
const tr = checkbox.closest('tr');
|
||||||
const pointCell = tr.querySelector('.point-value');
|
const pointCell = tr.querySelector('.point-value');
|
||||||
const cpNumber = tr.dataset.cpNumber;
|
const cpNumber = tr.dataset.cpNumber;
|
||||||
@ -425,6 +750,36 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 買い物チェックボックス更新関数
|
||||||
|
function updateBuyPoints(checkbox) {
|
||||||
|
const tr = checkbox.closest('tr');
|
||||||
|
const pointCell = tr.querySelector('.point-value');
|
||||||
|
const cpNumber = tr.dataset.cpNumber;
|
||||||
|
const validateCheckbox = tr.querySelector('.validate-checkbox');
|
||||||
|
let checkin = {
|
||||||
|
validate_location: validateCheckbox.checked,
|
||||||
|
buy_flag: checkbox.checked,
|
||||||
|
points: 0
|
||||||
|
};
|
||||||
|
|
||||||
|
fetch(`${API_BASE_URL}/location/${cpNumber}/`)
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(location => {
|
||||||
|
if (checkin.validate_location) {
|
||||||
|
// 通過審査がONの場合
|
||||||
|
checkin.points = checkbox.checked ? location.buy_point : location.checkin_point;
|
||||||
|
} else {
|
||||||
|
// 通過審査がOFFの場合
|
||||||
|
checkin.points = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ポイントを表示
|
||||||
|
pointCell.textContent = checkin.points;
|
||||||
|
calculatePoints(); // 総合ポイントの計算
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// 画像拡大表示用のモーダル関数
|
// 画像拡大表示用のモーダル関数
|
||||||
function showLargeImage(src) {
|
function showLargeImage(src) {
|
||||||
const modal = document.createElement('div');
|
const modal = document.createElement('div');
|
||||||
@ -505,29 +860,42 @@
|
|||||||
function updatePathOrders() {
|
function updatePathOrders() {
|
||||||
const rows = Array.from(document.getElementById('checkinList').children);
|
const rows = Array.from(document.getElementById('checkinList').children);
|
||||||
rows.forEach((row, index) => {
|
rows.forEach((row, index) => {
|
||||||
row.children[0].textContent = index + 1;
|
row.children[1].textContent = index + 1;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 総合ポイントの計算
|
||||||
function calculatePoints() {
|
function calculatePoints() {
|
||||||
|
console.info('calculatePoints');
|
||||||
const rows = Array.from(document.getElementById('checkinList').children);
|
const rows = Array.from(document.getElementById('checkinList').children);
|
||||||
let totalPoints = 0;
|
let totalPoints = 0; // チェックインポイントの合計をクリア
|
||||||
let buyPoints = 0;
|
let cpPoints = 0; // チェックインポイントの合計をクリア
|
||||||
|
let buyPoints = 0; // 買い物ポイントの合計をクリア
|
||||||
|
|
||||||
|
// 各行のチェックインポイント及び買い物ポイントを合算
|
||||||
rows.forEach(row => {
|
rows.forEach(row => {
|
||||||
const points = parseInt(row.children[4].textContent);
|
const buybox = row.children[6].querySelector('input[type="checkbox"]');
|
||||||
if (!isNaN(points)) {
|
const checkbox = row.children[7].querySelector('input[type="checkbox"]');
|
||||||
totalPoints += points;
|
const point = parseInt(row.children[8].textContent);
|
||||||
if (row.dataset.buyFlag === 'true') {
|
if (checkbox) {
|
||||||
buyPoints += points;
|
totalPoints += point;
|
||||||
}
|
if (buybox && buybox.checked) {
|
||||||
|
buyPoints += point;
|
||||||
|
}else{
|
||||||
|
cpPoints += point;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 遅刻ポイントの計算=ゴール時刻がEventのゴール時刻を超えていたら1分につき-50点を加算する。
|
||||||
const latePoints = parseInt(document.getElementById('latePoints').textContent) || 0;
|
const latePoints = parseInt(document.getElementById('latePoints').textContent) || 0;
|
||||||
const finalPoints = totalPoints + buyPoints - latePoints;
|
// 総合得点を計算
|
||||||
|
const finalPoints = totalPoints + latePoints;
|
||||||
|
|
||||||
document.getElementById('totalPoints').textContent = totalPoints;
|
// 判定を更新。順位を表示、ゴール時刻を15分経過したら失格
|
||||||
|
console.info('calculatePoints:totalPoints=',cpPoints,',buyPoints=',buyPoints,',finalPoints=',finalPoints);
|
||||||
|
|
||||||
|
document.getElementById('totalPoints').textContent = cpPoints;
|
||||||
document.getElementById('buyPoints').textContent = buyPoints;
|
document.getElementById('buyPoints').textContent = buyPoints;
|
||||||
document.getElementById('finalPoints').textContent = finalPoints;
|
document.getElementById('finalPoints').textContent = finalPoints;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user