-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathproses_spk.php
executable file
·213 lines (207 loc) · 10.5 KB
/
proses_spk.php
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
<?php
session_start();
error_reporting(0);
if(empty($_SESSION['id'])){
header('location:login.php?error_login=1');
}
?>
<?php include 'header.php';?>
<?php include 'menu.php';?>
<div class="content-wrapper">
<div class="container">
<div class="row">
<div class="col-md-12">
<h4 class="page-head-line">Proses SPK</h4>
</div>
</div>
<div class="row">
<h3>Tabel Hasil TPA</h3>
<div class="table-responsive">
<table id="example1" class="table table-striped table-bordered table-hover">
<thead>
<tr>
<th>### </th>
<?php foreach ($db->select('kriteria','kriteria')->get() as $k): ?>
<th>
<?php
$tmp = explode('_',$k['kriteria']);
echo ucwords(implode(' ',$tmp));
?>
</th>
<?php endforeach ?>
</tr>
</thead>
<tbody>
<?php
foreach ($db->select('karyawan.nama,hasil_tpa.*','karyawan,hasil_tpa')->where('karyawan.id_calon_kr=hasil_tpa.id_calon_kr')->get() as $data):
?>
<tr>
<td><?= $data['nama']?></td>
<?php foreach ($db->select('kriteria','kriteria')->get() as $td): ?>
<td><?= $db->getnilaisubkriteria($data[$td['kriteria']])?></td>
<?php endforeach ?>
</tr>
<?php
endforeach;
?>
</tbody>
</table>
</div>
</div>
<div class="row">
<div class="col-md-12 text-center">
<button class="btn btn-lg" onclick="tpl()">PROSES</button>
</div>
</div>
<br>
<div id="proses_spk" style="display: none;">
<div class="row">
<h3>Normalisasi</h3>
<div class="table-responsive">
<table id="example2" class="table table-striped table-bordered table-hover">
<thead>
<tr>
<th>### </th>
<?php foreach ($db->select('kriteria','kriteria')->get() as $k): ?>
<th>
<?php
$tmp = explode('_',$k['kriteria']);
echo ucwords(implode(' ',$tmp));
?>
</th>
<?php endforeach ?>
</tr>
</thead>
<tbody>
<?php
foreach ($db->select('karyawan.nama,hasil_tpa.*','karyawan,hasil_tpa')->where('karyawan.id_calon_kr=hasil_tpa.id_calon_kr')->get() as $data):
?>
<tr>
<td><?= $data['nama']?></td>
<?php foreach ($db->select('kriteria','kriteria')->get() as $td): ?>
<td><?= number_format($db->rumus($db->getnilaisubkriteria($data[$td['kriteria']]),$td['kriteria']),2);?></td>
<?php endforeach ?>
</tr>
<?php
endforeach;
?>
</tbody>
</table>
</div>
</div>
<div class="row">
<h3>Proses Penentuan</h3>
<div class="table-responsive">
<table id="example3" class="table table-striped table-bordered table-hover">
<thead>
<tr>
<th>Nama </th>
<th>Hasil</th>
</tr>
</thead>
<tbody>
<?php
foreach ($db->select('karyawan.id_calon_kr,karyawan.nama,hasil_tpa.*','karyawan,hasil_tpa')->where('karyawan.id_calon_kr=hasil_tpa.id_calon_kr')->get() as $data):
?>
<tr>
<td><?= $data['nama']?></td>
<td>
<?php
$hasil = [];
$bulan = date('m');
$tahun = date('Y');
$tanggal = date('Y-m-d');
$minggu = $db->weekOfMonth($tanggal);
foreach($db->select('kriteria','kriteria')->get() as $dt){
array_push($hasil,$db->rumus($db->getnilaisubkriteria($data[$dt['kriteria']]),$dt['kriteria'])*$db->bobot($dt['kriteria']));
}
echo $h = number_format(array_sum($hasil),2);
if($db->select('id_calon_kr','hasil_spk')->where("id_calon_kr='$data[id_calon_kr]' and minggu='$minggu' and bulan='$bulan' and tahun='$tahun'")->count() == 0){
$db->insert('hasil_spk',"'','$data[id_calon_kr]','$h','$minggu','$bulan','$tahun'")->count();
} else {
$db->update('hasil_spk',"hasil_spk='$h',minggu='$minggu',bulan='$bulan',tahun='$tahun'")->where("id_calon_kr='$data[id_calon_kr]' and minggu='$minggu' and bulan='$bulan' and tahun='$tahun'")->count();
}
?>
</td>
</tr>
<?php
endforeach;
?>
</tbody>
</table>
</div>
</div>
<div class="row">
<h3>Perankingan</h3>
<div class="table-responsive">
<table id="example4" class="table table-striped table-bordered table-hover">
<thead>
<tr>
<th>Hasil </th>
<?php $no = 1; foreach ($db->select('kriteria','kriteria')->get() as $th): ?>
<th>K<?= $no?></th>
<?php $no++; endforeach ?>
<th rowspan="2" style="padding-bottom:25px">Hasil</th>
<th rowspan="2" style="padding-bottom:25px">Ranking</th>
</tr>
<tr>
<th>Bobot </th>
<?php foreach ($db->select('bobot','kriteria')->get() as $th): ?>
<th><?= $th['bobot']?></th>
<?php endforeach ?>
</tr>
</thead>
<tbody>
<?php
$no = 1;
$bulan = date('m');
$tahun = date('Y');
$tanggal = date('Y-m-d');
$minggu = $db->weekOfMonth($tanggal);
foreach ($db->select('distinct(karyawan.nama),hasil_tpa.*,hasil_spk.*','karyawan,hasil_tpa,hasil_spk')->where('karyawan.id_calon_kr=hasil_tpa.id_calon_kr and karyawan.id_calon_kr=hasil_spk.id_calon_kr and hasil_spk.minggu='.$minggu.' and hasil_spk.bulan='.$bulan.' and hasil_spk.tahun='.$tahun.'')->order_by('hasil_spk.hasil_spk','desc')->get() as $data):
?>
<tr>
<td><?= $data['nama']?></td>
<?php foreach ($db->select('kriteria','kriteria')->get() as $td): ?>
<td><?= number_format($db->rumus($db->getnilaisubkriteria($data[$td['kriteria']]),$td['kriteria']),2);?></td>
<?php endforeach ?>
<td>
<?php
$hasil = [];
foreach($db->select('kriteria','kriteria')->get() as $dt){
array_push($hasil,$db->rumus($db->getnilaisubkriteria($data[$dt['kriteria']]),$dt['kriteria'])*$db->bobot($dt['kriteria']));
}
echo $r = number_format(array_sum($hasil),2);
?>
</td>
<td>
<?= $no?>
</td>
</tr>
<?php
$no++;
endforeach;
?>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<!-- CONTENT-WRAPPER SECTION END-->
<?php include 'footer.php'; ?>
<script type="text/javascript">
$(function(){
$("#proses").addClass('menu-top-active');
// $.ajax({
// url:'truncate_tpa.php',
// success:function(data){
// //alert(data);
// }
// });
});
function tpl(){
$("#proses_spk").show();
}
</script>