-
Notifications
You must be signed in to change notification settings - Fork 5
/
pdf.php
134 lines (121 loc) · 3.6 KB
/
pdf.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
<?php
/*
pdf.php
2013/10/27- (c) [email protected]
*/
require('image.php');
require('yoyapdf.php');
function date2japanize($date) { // range: 0 - 99
$from = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9');
$to = array('〇', '一', '二', '三', '四', '五', '六', '七', '八', '九');
$dates = explode('-', $date);
$year = $dates[0];
$month = $dates[1];
if (($year < "2019") || (($year == "2019") && ($month < "5") )) {
$era = "平成";
$dates[0] -= 1988;
} else {
$era = "令和";
$dates[0] -= 2018;
}
$dates[0] .= "";
foreach (range(0, 2) as $idx) {
$d = $dates[$idx];
if ($d < 10) {
$d = mb_substr($d, -1);
} elseif ($d == 10) {
$d = '十';
} elseif ($d < 20) {
$d = '十'.mb_substr($d, 1);
} elseif (($d % 10) === 0) {
$d = mb_substr($d, 0, 1).'十';
} else {
$d = mb_substr($d, 0, 1).'十'.mb_substr($d, 1);
}
$dates[$idx] = str_replace($from, $to, $d);
}
if ($dates[0] == "一") {
$dates[0] = "元";
}
return $era.$dates[0].'年'.$dates[1].'月'.$dates[2].'日';
}
$type = $_REQUEST['type'];
$reason = $_REQUEST['reason'];
$resign_date = date2japanize($_REQUEST['resign_date']);
$commit_date = date2japanize($_REQUEST['commit_date']);
$mypart = $_REQUEST['mypart'];
$myname = $_REQUEST['myname'];
$campany = $_REQUEST['campany'];
$president = $_REQUEST['president'];
$note = $_REQUEST['note'];
$image_id = $_REQUEST['image_id'];
$qrcode = $_REQUEST['qrcode'];
$pdf=new YoyaPDF();
$pdf->AddSJISFont();
$pdf->AddPage();
if (($image_id !== '') && image_id_valid($image_id)) {
$path = image_id2path($image_id);
if (file_exists($path)) {
$pdf->Image($path, 30, 50, 140);
}
}
if ($qrcode === 'yes') {
require('phpqrcode.php');
$url = (empty($_SERVER["HTTPS"]) ? "http://" : "https://") . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"];
$url = substr($url, 0, strlen($url) - strlen('&ext=.pdf'));
$tmpfile = tempnam('tmp', 'qr');
QRcode::png($url, $tmpfile, 'L', 4, 0);
$pdf->Image($tmpfile, 25, 220, 40, 40, 'png');
unlink($tmpfile);
}
$pdf->SetFont('SJIS','',42);
$x = 170;
if ($type === 'wish') {
$pdf->TategakiText($x, 100, '退職願', 40);
} else {
$pdf->TategakiText($x, 100, '退職届', 40);
}
$pdf->SetFont('SJIS','',26);
$x -= 20;
$pdf->TategakiText($x, 250, '私儀', 14);
if ($type === 'wish') {
$message1 = $resign_date."をもって退職致したく、";
$message2 = "ここにお願い申し上げます。";
} else {
$message1 = $resign_date."をもって";
$message2 = "退職させて頂きます。";
}
$pdf->SetFont('SJIS','',20);
$x -= 20;
$pdf->TategakiText($x, 30, $reason, 9);
$x -= 12;
$pdf->TategakiText($x, 30, $message1, 9);
$x -= 12;
$pdf->TategakiText($x, 30, $message2, 9);
$x -= 20;
$pdf->TategakiText($x, 115, $commit_date, 8);
$x -= 12;
$pdf->TategakiText($x, 135, $mypart, 8);
$pdf->SetFont('SJIS','',24);
$x -= 10;
$y = 270 - mb_strlen($myname)*12;
$pdf->TategakiText($x, $y, $myname, 12);
$pdf->SetFont('SJIS','',18);
if ($note !== '') {
$pdf->TategakiText($x-15, 50, $note, 8);
$pdf->SetFont('SJIS','',24);
$x -= 35;
$pdf->TategakiText($x, 35, $campany, 10);
$x -= 15;
$pdf->TategakiText($x, 35, $president, 10);
} else {
$pdf->SetFont('SJIS','',24);
$x -= 30;
$pdf->TategakiText($x, 35, $campany, 10);
$x -= 15;
$pdf->TategakiText($x, 35, $president, 10);
}
header('Content-Type: application/pdf;');
header('Content-Disposition: attachment; filename=resign.pdf');
$pdf->Output();
exit(0);