-
Notifications
You must be signed in to change notification settings - Fork 0
/
work_calendar.php
58 lines (38 loc) · 1.32 KB
/
work_calendar.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
<?php
//error_reporting(E_ALL ^ E_WARNING);
//Hae perustiedot
require 'db_connect.php';
require 'vendor/autoload.php';
$loader = new Twig_Loader_Filesystem('templates/');
$twig = new Twig_Environment($loader, array(
// Uncomment the line below to cache compiled templates
// 'cache' => __DIR__.'/../cache',
));
if(isset($_GET['id'])){
$id = $_GET['id']; }
else {
$id = null;}
if($id == null)
$disable = "disabled";
else
$disable = "";
$stmt2 = $db->query("SELECT key_id,make,type FROM machine_list"); //Get machine list to be used as headers of work table
while ($row2 = $stmt2->fetch()){
$machines[] = array('make' => $row2['make'], 'type' => $row2['type']);
}
$current_day = date("d.m",strtotime(date('m/d/y')));
for($i = 0; $i <= 60; $i++){ //build working table for next 60 days
$day = date("d.m",strtotime(date('m/d/y') . "+$i day"));
$day_number = date("N",strtotime(date('m/d/y') . "+$i day"));
$day_sql = date("Y-m-d",strtotime(date('m/d/y') . "+$i day"));
$date = new DateTime($day_sql);
$week_number = $date->format("W");
$days[$i] = array('day' => $day, 'day_sql' => $day_sql, 'machine' => array());
}
echo $twig->render('work_calendar.html', array(
'machines' => $machines,
'days' => $days,
'current_day' => $current_day,
'id' => $id,
'disable' => $disable
));