-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
380 lines (323 loc) · 10.2 KB
/
Copy pathindex.php
File metadata and controls
380 lines (323 loc) · 10.2 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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
<?php
session_set_cookie_params(3600 *24); // 24 hour
session_start(); // 세션 시작
include "./head.php";
include "./sidebar.php";
$visit_date = date('Y-m-d');
if (count($_SESSION)==0){
$_SESSION['first_visit']=0;
}
?>
<!-----------======================
<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
<div class="modal fade" id="modal-primary">
<div class="modal-dialog">
<div class="modal-content bg-primary">
<div class="modal-header">
<!-- <h4 class="modal-title">공지사항</h4> !-->
<h4 class="modal-title text-center">공지사항</h4>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<p> cloudtype의 프리티어 등급으로 관리 중 <font color='red'> (매일1회 중지됨)</font></p>
<p> 고정URL : <font color='red'> https://sites.google.com/view/etftrader </font> </p>
<p> 운영목적 : 국내 상장된 ETF 분석을 통해 누구나 안정적인 투자를</p>
<p> 이어가길 바라는 마음에서 싸이트을 운영합니다.</p>
<p> 문의사항 : 상단 <font color='red'>질문</font>를 누르고 문의하세요 </p>
</div>
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal-dialog -->
</div>
<!-- Main content -->
<section class="content">
<div class="container-fluid">
<!-- Small boxes (Stat box) -->
<!-- Main row -->
<div class="row">
<!-- Left col -->
<section class="col-lg-7 connectedSortable">
<div class="card">
<div class="card-header">
<h3 class="card-title">분배금(배당금) 지급현황</h3>
</div>
<div class="card-body">
<table id="divtable" class="table table-bordered table-striped">
<thead>
<tr>
<th>종목명</th>
<th>년도</th>
<th>분배금</th>
<th>시가대비</th>
<th>건수</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
<!-- /.card-body -->
</div>
<!-- /.card -->
</section>
<!-------------------------!>
<section class="col-lg-5 connectedSortable">
<div class="card card-primary card-outline">
<div class="card-header">
<h3 class="card-title">
<i class="far fa-chart-bar"></i>
년도별 분배금 지급현황
</h3>
<div class="card-tools">
<button type="button" class="btn btn-tool" data-card-widget="collapse">
<i class="fas fa-minus"></i>
</button>
<button type="button" class="btn btn-tool" data-card-widget="remove">
<i class="fas fa-times"></i>
</button>
</div>
</div>
<div class="card-body">
<div id="chartContainer">
<canvas id="myChart" style="height: 300px;"></canvas>
</div>
<!-- <div id="bar-chart" style="height: 300px;"></div> !-->
<!-- <canvas id="myChart" style="height: 300px;"></canvas> !-->
</div>
<!-- /.card-body-->
</div>
<!-- /.card -->
<div class="row">
<div class="card">
<div class="card-body">
<table id="divtabledetail" class="table table-bordered table-striped">
<thead>
<tr>
<th>지급일</th>
<th>분배금</th>
<th>시가대비</th>
<th>구분</th>
<th>기준가</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
</div>
</section>
</div>
</div>
</section>
</div>
<?php
include "./footer.php";
?>
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<script>
$(document).ready(function(e){
var is_first_visit = <?php echo json_encode($_SESSION); ?>;
if (is_first_visit['first_visit']==0){
$('#modal-primary').modal('show');
<?php $_SESSION['first_visit']=1; ?>
}
let myChart; // 전역 변수로 차트 객체를 저장
$('[data-widget="pushmenu"]').PushMenu('collapse');
var result=DivinfoReq();
appendDataToTable(result['line']);
var divtable=$('#divtable').DataTable({
"responsive": true,
"lengthChange": false,
"autoWidth": false,
"info": true,
"buttons": ["excel"],
});
$('#divtable tbody').on('click', 'tr', function () {
var data = divtable.row(this).data();
var title=data[0];
var Htitle=JSHTMLescape(data[0]);
if ('graph' in result){
labels=Object.keys(result['graph'][Htitle]);
}
const barData=[];
const lineData=[];
const barTitle="분배금";
const lineTitle="분배율";
if ('graph' in result){
for (const key in result['graph'][Htitle]) {
barData.push(result['graph'][Htitle][key]['div']);
lineData.push(result['graph'][Htitle][key]['rate']);
}
// 차트그리기
bar_line_draw(barData, lineData, labels, barTitle, lineTitle);
}
var divdetail=DivinfoDetail(Htitle);
appendDataToTableDetail(divdetail);
if ($.fn.DataTable.isDataTable('#divtabledetail')) {
divtabledetail.clear();
var divtabledetail=$('#divtabledetail').DataTable({
"responsive": true,
"lengthChange": false,
"autoWidth": false,
"info": true,
"searching": false,
//"buttons": ["excel"],
});
} else {
$('#divtabledetail').DataTable({
});
}
});
});
//});
function JSHTMLescape(str) {
if (!str) return '';
return str
.replace('&',"&")
.replace( '<',"<")
.replace('>',">")
.replace('"','"')
.replace(''',"'");
}
function bar_line_draw(barData, lineData, labels, barTitle, lineTitle) {
const chartContainer = document.getElementById('chartContainer');
const oldCanvas = document.getElementById('myChart');
// 기존 canvas 요소를 삭제
if (oldCanvas) {
chartContainer.removeChild(oldCanvas);
}
// 새로운 canvas 요소를 생성하고 추가
const newCanvas = document.createElement('canvas');
newCanvas.id = 'myChart';
newCanvas.style.height = '300px';
chartContainer.appendChild(newCanvas);
const ctx = newCanvas.getContext('2d');
// 새로운 혼합 차트를 생성
myChart = new Chart(ctx, {
type: 'bar',
data: {
labels: labels,
datasets: [
{
type: 'bar',
label: barTitle,
data: barData,
yAxisID: 'y',
backgroundColor: 'rgba(75, 192, 192, 0.2)',
borderColor: 'rgba(75, 192, 192, 1)',
borderWidth: 1
},
{
type: 'line',
label: lineTitle,
data: lineData,
yAxisID: 'y1',
backgroundColor: 'rgba(153, 102, 255, 0.2)',
borderColor: 'rgba(153, 102, 255, 1)',
borderWidth: 1,
fill: false
}
]
},
options: {
scales: {
y: {
type: 'linear',
display: true,
position: 'left',
beginAtZero: true
},
y1: {
type: 'linear',
display: true,
position: 'right',
beginAtZero: true,
grid: {
drawOnChartArea: false // 오른쪽 y축의 그리드 라인을 그리지 않음
}
}
}
}
});
}
function DivinfoReq(){
var result;
$.ajax({
url: "AjaxHtml/Receiver.php",
type: "POST",
data: JSON.stringify({ "request": "divinfo"}),
contentType: "application/json; charset=utf-8",
async: false, // 동기식 호출
success: function(redata){
result=redata;
console.log(result);
},
error: function(xhr, status, error){
console.log(status,error);
$("#result").html("An error occurred: " + error);
},
complete : function(xhr, status) {
},
});
return result;
}
function DivinfoDetail(title){
var result;
$.ajax({
url: "AjaxHtml/Receiver.php",
type: "POST",
data: JSON.stringify({ "request": "divinfodetail", "name": title}),
contentType: "application/json; charset=utf-8",
async: false, // 동기식 호출
success: function(redata){
result=redata;
console.log(result);
},
error: function(xhr, status, error){
console.log(status,error);
$("#result").html("An error occurred: " + error);
},
complete : function(xhr, status) {
},
});
return result;
}
function appendDataToTable(data) {
console.log("Received data:", data);
var divtable = $('#divtable tbody');
data.forEach(function(row) {
var newRow = '<tr>' +
'<td>' + row[0] + '</td>' +
'<td>' + row[1] + '</td>' +
'<td>' + row[2].toLocaleString() + '</td>' +
'<td>' + row[3] + '</td>' +
'<td>' + row[4] + '</td>' +
'</tr>';
divtable.append(newRow);
});
}
function appendDataToTableDetail(data) {
console.log("Received data:", data);
var divtable = $('#divtabledetail tbody');
divtable.empty();
data.forEach(function(row) {
var newRow = '<tr>' +
'<td>' + row[0].toLocaleString() + '</td>' +
'<td>' + row[1] + '</td>' +
'<td>' + row[2] +'</td>' +
'<td>' + row[3] + '</td>' +
'<td>' + row[4].toLocaleString() + '</td>' +
'</tr>';
divtable.append(newRow);
});
}
</script>
<?
?>
</body>
</html>