File size: 7,627 Bytes
2512215
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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

<!DOCTYPE html>

<html lang="en">
<head>
<meta charset="utf-8"/>
<meta content="width=device-width, initial-scale=1.0" name="viewport"/>
<title>
   Work Hours Calculator
  </title>
<meta content="noindex, nofollow" name="robots"/>
<meta content="noindex, nofollow" name="robots"/></head>
<body>
<!-- Navigation Bar -->
<nav class="navbar navbar-expand-lg navbar-dark bg-primary">
<a class="navbar-brand" href="#" rel="nofollow noindex">
    WorkCalc
   </a>
<button aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation" class="navbar-toggler" data-target="#navbarNav" data-toggle="collapse" type="button">
<span class="navbar-toggler-icon">
</span>
</button>
<div class="collapse navbar-collapse justify-content-end" id="navbarNav">
<ul class="navbar-nav">
<li class="nav-item active">
<a class="nav-link" href="#" rel="nofollow noindex">
       Home
      </a>
</li>
<li class="nav-item">
<a class="nav-link" href="#" rel="nofollow noindex">
       Reports
      </a>
</li>
<li class="nav-item">
<a class="nav-link" href="#" rel="nofollow noindex">
       Settings
      </a>
</li>
</ul>
</div>
</nav>
<!-- Main Container -->
<div class="container my-5">
<h2 class="text-center mb-4">
    Mesai Hesaplama
   </h2>
<!-- Data Input Section -->
<div class="card mb-4">
<div class="card-header bg-secondary text-white">
     Veri Girişi
    </div>
<div class="card-body">
<form id="dataForm">
<div class="form-group">
<label for="timeInput">
        Kopyala ve Yapıştır:
       </label>
<textarea class="form-control" id="timeInput" placeholder="Örnek:
10:01 18:00
10:06 18:00
..." rows="6"></textarea>
</div>
<button class="btn btn-primary" type="submit">
       Hesapla
      </button>
</form>
</div>
</div>
<!-- Report Section -->
<div class="card">
<div class="card-header bg-success text-white">
     Haftalık Rapor
    </div>
<div class="card-body">
<div id="reportContent">
<!-- Dynamic Report will be inserted here -->
</div>
</div>
</div>
</div>
<!-- Footer -->
<footer class="bg-dark text-white text-center py-3">
   © 2023 WorkCalc. Tüm hakları saklıdır.
  </footer>
</body>
</html>


<style>
    body {
    background-color: #f0f4f7;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.navbar-brand {
    font-weight: bold;
    font-size: 1.5rem;
}

.card-header {
    font-size: 1.2rem;
    font-weight: bold;
}

#reportContent {
    white-space: pre-wrap;
    font-family: Consolas, monospace;
}

footer {
    position: fixed;
    width: 100%;
    bottom: 0;
}

@media (max-width: 576px) {
    .navbar-brand {
        font-size: 1.2rem;
    }
}
</style>

<script  src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.4/jquery.min.js"></script>
<script  src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.3.1/js/bootstrap.min.js"></script>
<script>
    (function() {
        window.onload = function() {
            parent.iframeLoaded();
        }
    })();
    try {
    $(document).ready(function() {
    $('#dataForm').submit(function(e) {
        e.preventDefault();
        const input = $('#timeInput').val().trim();
        if (input === "") {
            alert("Lütfen zaman girişlerini giriniz.");
            return;
        }

        const lines = input.split('\n').filter(line => line.trim() !== "");
        const sessions = [];

        // Parse input lines
        lines.forEach(line => {
            const times = line.trim().split(/\s+/);
            if (times.length === 2) {
                const start = parseTime(times[0]);
                const end = parseTime(times[1]);
                if (start && end) {
                    sessions.push({ start, end });
                }
            }
        });

        if (sessions.length === 0) {
            alert("Geçerli zaman girişleri bulunamadı.");
            return;
        }

        // Calculate reports
        const report = calculateWeeklyReport(sessions);

        // Display report
        displayReport(report);
    });

    function parseTime(timeStr) {
        const parts = timeStr.split(':');
        if (parts.length !== 2) return null;
        const hours = parseInt(parts[0], 10);
        const minutes = parseInt(parts[1], 10);
        if (isNaN(hours) || isNaN(minutes)) return null;
        // Assuming all entries are on the same arbitrary day
        return new Date(2023, 0, 1, hours, minutes);
    }

    function calculateWeeklyReport(sessions) {
        let totalWorkMinutes = 0;
        let overtimeMinutes = 0;
        let nightOvertimeMinutes = 0;
        let restOvertimeMinutes = 0;

        sessions.forEach(session => {
            let duration = (session.end - session.start) / (1000 * 60); // minutes
            totalWorkMinutes += duration;

            if (duration > 11 * 60) { // More than 11 hours
                overtimeMinutes += duration - 11 * 60;
            }

            // Check for night shift
            if (session.start.getHours() >= 20 || session.end.getHours() <= 6) {
                if (duration > 7.5 * 60) {
                    nightOvertimeMinutes += duration - 7.5 * 60;
                }
            }

            // Assuming rest day overtime is calculated separately
            // Placeholder for actual logic
        });

        return {
            totalWorkHours: (totalWorkMinutes / 60).toFixed(2),
            overtimeHours: (overtimeMinutes / 60).toFixed(2),
            nightOvertimeHours: (nightOvertimeMinutes / 60).toFixed(2),
            restOvertimeHours: (restOvertimeMinutes / 60).toFixed(2),
            dailyDetails: sessions.map((s, index) => ({
                day: `Gün ${index + 1}`,
                start: formatTime(s.start),
                end: formatTime(s.end),
                duration: ( (s.end - s.start) / (1000 * 60) / 60 ).toFixed(2) + ' saat'
            }))
        };
    }

    function formatTime(date) {
        const hours = date.getHours().toString().padStart(2, '0');
        const minutes = date.getMinutes().toString().padStart(2, '0');
        return `${hours}:${minutes}`;
    }

    function displayReport(report) {
        let html = `<h4>Toplam Çalışma: ${report.totalWorkHours} saat</h4>`;
        html += `<h4>Fazla Mesai: ${report.overtimeHours} saat</h4>`;
        html += `<h4>Gece Çalışması Fazla Mesai: ${report.nightOvertimeHours} saat</h4>`;
        html += `<h4>Hafta Tatili Fazla Mesai: ${report.restOvertimeHours} saat</h4>`;
        html += `<hr>`;
        html += `<h5>Günlük Detaylar:</h5>`;
        html += `<table class="table table-striped">
                    <thead>
                        <tr>
                            <th>Gün</th>
                            <th>Başlangıç</th>
                            <th>Bitiş</th>
                            <th>Toplam Süre</th>
                        </tr>
                    </thead>
                    <tbody>`;
        report.dailyDetails.forEach(detail => {
            html += `<tr>
                        <td>${detail.day}</td>
                        <td>${detail.start}</td>
                        <td>${detail.end}</td>
                        <td>${detail.duration}</td>
                     </tr>`;
        });
        html += `</tbody></table>`;

        $('#reportContent').html(html);
    }
});
    } catch (e) {
        console.log("Error in JS code", e);
    }
</script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/all.min.css" integrity="sha512-z3gLpd7yknf1YoNbCzqRKc4qyor8gaKU1qmn+CShxbuBusANI9QpRohGBreCFkKxLhei6S9CQXFEbbKuqLg0DA==" crossorigin="anonymous" referrerpolicy="no-referrer" />
</html>