質問編集履歴
1
コード全文追記しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -21,3 +21,168 @@
|
|
21
21
|

|
22
22
|
|
23
23
|

|
24
|
+
|
25
|
+
以下、コード全文です。
|
26
|
+
```PHP
|
27
|
+
<?php
|
28
|
+
|
29
|
+
//---自作関数集
|
30
|
+
require_once __DIR__ .'/lib/function.php';
|
31
|
+
|
32
|
+
//---基礎設定ファイル
|
33
|
+
require_once __DIR__ .'/lib/config.php';
|
34
|
+
|
35
|
+
if($_SESSION['login']['veryfy'] == true):
|
36
|
+
if($_POST):
|
37
|
+
if($_POST['数量']<=0):
|
38
|
+
echo "<script>window.close();</script>";//新規タブで開いているので、有効な値がない場合はタブを閉じる
|
39
|
+
exit;
|
40
|
+
endif;
|
41
|
+
$i=1;
|
42
|
+
$row = 1;
|
43
|
+
$col = 1;
|
44
|
+
$p = 1;
|
45
|
+
$i = 1;
|
46
|
+
$pages = 0;
|
47
|
+
$remain = $_POST['数量'];
|
48
|
+
while($remain>0):
|
49
|
+
if($remain>=$_POST['入数']):
|
50
|
+
$data[$p][$row][$col]['page'] = $i;
|
51
|
+
$data[$p][$row][$col]['入数'] = $_POST['入数'];
|
52
|
+
else://最終ページ
|
53
|
+
$data[$p][$row][$col]['page'] = $i;
|
54
|
+
$data[$p][$row][$col]['入数'] = $remain;
|
55
|
+
endif;
|
56
|
+
$remain -=$data[$p][$row][$col]['入数'];
|
57
|
+
++$i;
|
58
|
+
++$pages;
|
59
|
+
++$col;
|
60
|
+
if($col==3):
|
61
|
+
$col = 1;
|
62
|
+
++$row;
|
63
|
+
endif;
|
64
|
+
if($row==5 AND $remain>=1):
|
65
|
+
$row = 1;
|
66
|
+
++$p;
|
67
|
+
endif;
|
68
|
+
endwhile;
|
69
|
+
|
70
|
+
if($col==2):
|
71
|
+
$data[$p][$row][$col]['page'] = 'End';
|
72
|
+
endif;
|
73
|
+
require_once __DIR__ .'/libs/tcpdf/tcpdf.php';
|
74
|
+
$tcpdf = new TCPDF();
|
75
|
+
$tcpdf->setPrintHeader(false);
|
76
|
+
$tcpdf->setPrintFooter(false);
|
77
|
+
$tcpdf->SetTitle($config['sys_name'].' 現品票');
|
78
|
+
$tcpdf->SetAuthor($config['sys_name']);
|
79
|
+
|
80
|
+
$line_style = array();
|
81
|
+
$line_style['width'] = 0.2;
|
82
|
+
foreach($data as $page_num=>$pagedata):
|
83
|
+
$x = 5;
|
84
|
+
$y = 5;
|
85
|
+
$tcpdf->AddPage();
|
86
|
+
$tcpdf->SetAutoPageBreak(true, 5);
|
87
|
+
$tcpdf->SetFont("kozgopromedium", "", 8);
|
88
|
+
foreach($pagedata as $row_num=>$row):
|
89
|
+
foreach($row as $col_num=>$tag):
|
90
|
+
if($tag['page']!='End'):
|
91
|
+
if($col_num==2):
|
92
|
+
$x = $x+95+10;
|
93
|
+
endif;
|
94
|
+
//外枠
|
95
|
+
$tcpdf->SetXY($x,$y,true);
|
96
|
+
$tcpdf->cell(95,64.25,'',1);
|
97
|
+
//現品票
|
98
|
+
$tcpdf->SetXY($x,$y,true);
|
99
|
+
$tcpdf->cell(23.75,22.5,'',1,0,'C',false,'',1,false,'T','T');
|
100
|
+
$tcpdf->SetXY($x,$y+1,true);
|
101
|
+
$tcpdf->cell(23.75,20.5,'現品票',0,0,'C',false,'',1,false,'T','T');
|
102
|
+
//品名
|
103
|
+
$tcpdf->SetXY($x+23.75,$y,true);
|
104
|
+
$tcpdf->cell(11.875,12.5,'品 名',1,0,'C',false,'',1,false,'T','M');
|
105
|
+
$tcpdf->SetXY($x+23.75+11.875,$y,true);
|
106
|
+
$tcpdf->SetFont("kozgopromedium", "", 25);
|
107
|
+
$tcpdf->cell(59.375,12.5,$_POST['機種名'],1,0,'C',false,'',1,false,'T','M');
|
108
|
+
$tcpdf->SetFont("kozgopromedium", "", 8);
|
109
|
+
//品番
|
110
|
+
$tcpdf->SetXY($x+23.75,$y+12.5,true);
|
111
|
+
$tcpdf->cell(11.875,10,'品 番',1,0,'C',false,'',1,false,'T','M');
|
112
|
+
$tcpdf->SetXY($x+23.75+11.875,$y+12.5,true);
|
113
|
+
$tcpdf->SetFont("kozgopromedium", "", 22);
|
114
|
+
$tcpdf->cell(59.375,10,$_POST['品目コード'],1,0,'C',false,'',1,false,'T','M');
|
115
|
+
$tcpdf->SetFont("kozgopromedium", "", 8);
|
116
|
+
//製造日
|
117
|
+
$tcpdf->SetXY($x,$y+22.5,true);
|
118
|
+
$tcpdf->cell(11.875,10,'製造日',1,0,'C',false,'',1,false,'T','M');
|
119
|
+
$tcpdf->SetXY($x+11.875,$y+22.5,true);
|
120
|
+
$tcpdf->cell(35.625,10,'',1,0,'C',false,'',1,false,'T','M');
|
121
|
+
//No
|
122
|
+
$tcpdf->SetXY($x+47.5,$y+22.5,true);
|
123
|
+
$tcpdf->cell(11.875,10,'',1,0,'C',false,'',1,false,'T','M');
|
124
|
+
$tcpdf->SetXY($x+49,$y+22.5,true);
|
125
|
+
$tcpdf->cell(10.375,10,'No.',0,0,'C',false,'',1,false,'T','M');
|
126
|
+
$tcpdf->SetXY($x+47.5+11.875,$y+22.5,true);
|
127
|
+
$tcpdf->SetFont("kozgopromedium", "", 22.5);
|
128
|
+
$tcpdf->cell(20,10,$tag['page'],'B',0,'R',false,'',1,false,'T','M');
|
129
|
+
$tcpdf->SetFont("kozgopromedium", "", 10);
|
130
|
+
$tcpdf->SetXY($x+47.5+11.875+20,$y+22.5,true);
|
131
|
+
$tcpdf->cell(15.625,10,'','B',0,'L',false,'',1,false,'T','M');
|
132
|
+
$tcpdf->SetXY($x+47.5+11.875+20,$y+22.5+4,true);
|
133
|
+
$tcpdf->cell(15.625,4,'/'.$pages,0,0,'L',false,'',1,false,'T','M');
|
134
|
+
$tcpdf->SetFont("kozgopromedium", "", 8);
|
135
|
+
//ハコガエ
|
136
|
+
$tcpdf->SetXY($x,$y+32.5,true);
|
137
|
+
$tcpdf->cell(23.75,5,'ハコガエ',1,0,'C',false,'',1,false,'T','M');
|
138
|
+
//検査
|
139
|
+
$tcpdf->SetXY($x+23.75,$y+32.5,true);
|
140
|
+
$tcpdf->cell(23.75,5,'検 査',1,0,'C',false,'',1,false,'T','M');
|
141
|
+
$tcpdf->SetXY($x+23.75,$y+37.5,true);
|
142
|
+
$tcpdf->cell(23.75,19.75,'',1,0,'C',false,'',1,false,'T','M');
|
143
|
+
//入数
|
144
|
+
$tcpdf->SetXY($x+23.75+23.75,$y+32.5,true);
|
145
|
+
$tcpdf->cell(23.75,5,'入 数',1,0,'C',false,'',1,false,'T','M');
|
146
|
+
$tcpdf->SetXY($x+23.75+23.75,$y+37.5,true);
|
147
|
+
$tcpdf->SetFont("kozgopromedium", "", 32);
|
148
|
+
$tcpdf->cell(23.75,19.75,$tag['入数'],1,0,'C',false,'',1,false,'T','M');
|
149
|
+
$tcpdf->SetFont("kozgopromedium", "", 8);
|
150
|
+
$tcpdf->SetXY($x+23.75+23.75,$y+37.5,true);
|
151
|
+
$tcpdf->cell(23.75,19,'/'.$_POST['入数'],0,0,'R',false,'',1,false,'T','B');
|
152
|
+
//備考
|
153
|
+
$tcpdf->SetXY($x+23.75+23.75+23.75,$y+32.5,true);
|
154
|
+
$tcpdf->cell(23.75,5,'備 考',1,0,'C',false,'',1,false,'T','M');
|
155
|
+
$tcpdf->SetXY($x+23.75+23.75+23.75,$y+37.5,true);
|
156
|
+
$tcpdf->cell(23.75,19.75,'',1,0,'C',false,'',1,false,'T','M');
|
157
|
+
//材料名
|
158
|
+
$tcpdf->SetXY($x+23.75,$y+57.25,true);
|
159
|
+
$tcpdf->cell(71.25,7,'材料名:',1,0,'L',false,'',1,false,'T','M');
|
160
|
+
|
161
|
+
$x = 5;
|
162
|
+
endif;
|
163
|
+
endforeach;
|
164
|
+
$y = $y + 64.25 + 10;
|
165
|
+
endforeach;
|
166
|
+
endforeach;
|
167
|
+
$tcpdf->Output('tag.pdf', 'I');//生成したPDFをブラウザ上で表示させる
|
168
|
+
exit;
|
169
|
+
endif;
|
170
|
+
|
171
|
+
$line_list = get_line_list($config);
|
172
|
+
foreach($line_list as $sort=>$val):
|
173
|
+
$line_code = $val['code'];
|
174
|
+
$data[$sort] = get_product_list($line_code);
|
175
|
+
endforeach;
|
176
|
+
|
177
|
+
$smarty->assign('msg',$msg);
|
178
|
+
$smarty->assign('line_list',$line_list);
|
179
|
+
$smarty->assign('auth',$_SESSION['login']['auth']);
|
180
|
+
$smarty->assign('data',$data);
|
181
|
+
$smarty->display('tag.html');
|
182
|
+
else:
|
183
|
+
$smarty->display('index.html');
|
184
|
+
endif;
|
185
|
+
exit;
|
186
|
+
?>
|
187
|
+
|
188
|
+
```
|