8 define(
'MAX_LINES_PAR_PAGE', 40);
18 return ($x == 0) ?
"" :
"{\\tt{" . str_replace(
"-",
"▲", number_format($x)) .
"}}";
24 return ($x == 0) ? 0 :
"{\\tt{" . str_replace(
"-",
"▲", number_format($x)) .
"}}";
28 private function term($bymd, $y, $m)
30 $yyyymm = intval($bymd / 100);
31 $by = intval($yyyymm / 100);
35 $a[0] = date(
"Y/m/d", mktime(0, 0, 0, $bm, 1, $by));
36 $a[1] = date(
"Y/m/d", mktime(0, 0, 0, $m + 1, 0, $y));
42 private function sum($mm)
47 $cnt = $this->dat[
"rows"];
48 $d = $this->dat[
"data"];
50 for ($i = 0; $i <
$cnt; $i++) {
51 if ($mm == $d[$i][
"mm"]) {
52 $r = $d[$i][
"remain"];
53 if ($d[$i][
"division"]) {
67 $csv = file($this->csvfile);
70 for ($i = 0; $i <
$cnt; $i++) {
71 $rec = explode(
"\t", $csv[$i]);
84 $this->dat[$rec[0]] = trim($rec[1]);
87 $this->dat[$rec[0]][
"n"] = trim($rec[1]);
88 $this->dat[$rec[0]][
"m"] = trim($rec[2]);
89 $this->dat[$rec[0]][
"mm"] = trim($rec[3]);
90 $this->dat[$rec[0]][
"account_cd"] = trim($rec[4]);
91 $this->dat[$rec[0]][
"name"] = trim($rec[5]);
92 $this->dat[$rec[0]][
"remain"] = trim($rec[6]);
93 $this->dat[$rec[0]][
"division"] = trim($rec[7]);
96 $this->dat[$rec[0]][$data_n][
"n"] = trim($rec[1]);
97 $this->dat[$rec[0]][$data_n][
"m"] = trim($rec[2]);
98 $this->dat[$rec[0]][$data_n][
"mm"] = trim($rec[3]);
99 $this->dat[$rec[0]][$data_n][
"account_cd"] = trim($rec[4]);
100 $this->dat[$rec[0]][$data_n][
"name"] = trim($rec[5]);
101 $this->dat[$rec[0]][$data_n][
"remain"] = trim($rec[6]);
102 $this->dat[$rec[0]][$data_n][
"division"] = trim($rec[7]);
118 $d = $this->dat[
"data"];
119 $title = $this->dat[
"title"];
120 $name = $this->dat[
"name"];
121 $era = $this->dat[
"era"];
122 $bymd = $this->dat[
"bymd"];
123 $ty = $this->dat[
"ty"];
124 $bps = $this->dat[
"bps"];
125 $eps = $this->dat[
"eps"];
126 $bgs = $this->dat[
"bgs"];
127 $egs = $this->dat[
"egs"];
128 $pcost = $this->dat[
"pcost"];
131 $inam = $d[$n][
"name"];
133 $yyyy = intval($m / 100);
134 $term = $this->
term($bymd, $yyyy, $mm);
138 echo
"\\begin{center}\n";
139 echo
"\\begin{tabular}{ccc}\n";
140 echo
"\\multicolumn{2}{l}{\\makebox[12.5cm][l]{" . $name .
"}} & ";
141 echo
"\\makebox[2.5cm][r]{\\tt{" . $era .
"年度}} \\\\\n";
142 echo
"\\makebox[2.5cm][l]{ } & ";
143 echo
"\\makebox[10cm][c]{\\bf\\LARGE{" . $title .
"}} & ";
144 echo
"\\makebox[2.5cm][r]{} \\\\\n";
145 echo
"\\makebox[2.5cm][l]{} & ";
146 echo
"\\makebox[10cm][c]{{\\tt{" . $term0 .
" 〜 " . $term1 .
"}}} & ";
147 echo
"\\makebox[2.5cm][r]{\\tt{}} \\\\\n";
148 echo
"\\end{tabular}\n";
149 echo
"\\end{center}\n";
151 echo
"\\begin{center}\n";
152 echo
"\\begin{tabular}{@{\\Vline\\ }c|c|c|c@{\\ \\Vline}}\n";
154 echo
"\\multicolumn{2}{@{\\Vline\\ }c|}{\\makebox[7.4cm][c]{\\bf{費 用}}} & ";
155 echo
"\\multicolumn{2}{c@{\\ \\Vline}}{\\makebox[7.4cm][c]{\\bf{収 益}}} \\\\\n";
169 if (!isset($d[$n][
"mm"])) {
172 }
else if ($month != $d[$n][
"mm"]) {
177 if ($d[$n][
"division"]) {
178 $drec[$n1][1][
"name"] = $d[$n][
"name"];
179 $drec[$n1][1][
"remain"] = $d[$n][
"remain"];
182 $drec[$n0][0][
"name"] = $d[$n][
"name"];
183 $drec[$n0][0][
"remain"] = $d[$n][
"remain"];
190 $nmax = max($n0, $n1);
191 for ($i = 0; $i < $nmax; $i++) {
193 $dn = $drec[$i][0][
"name"];
194 $dr = $this->
amount($drec[$i][0][
"remain"]);
201 $cn = $drec[$i][1][
"name"];
202 $cr = $this->
amount($drec[$i][1][
"remain"]);
208 echo
"\\makebox[3.7cm][l]{" . $dn .
"} & ";
209 echo
"\\makebox[3.7cm][r]{" . $dr .
"} & ";
210 echo
"\\makebox[3.7cm][l]{" . $cn .
"} & ";
211 echo
"\\makebox[3.7cm][r]{" . $cr .
"} \\\\\n";
215 $s = $this->
sum($mm);
220 $dr = ($dr == 0) ?
"" : $this->
amount($dr);
221 $cr = ($cr == 0) ?
"" : $this->
amount($cr);
224 echo
"\\makebox[3.7cm][c]{\bf{合 計}} & ";
225 echo
"\\makebox[3.7cm][r]{" . $dr .
"} & ";
226 echo
"\\makebox[3.7cm][c]{\bf{合 計}} & ";
227 echo
"\\makebox[3.7cm][r]{" .$cr .
"} \\\\\n";
231 echo
"\\end{tabular}\n";
232 echo
"\\end{center}\n";
241 $bps = $this->dat[
"bps"];
242 $eps = $this->dat[
"eps"];
243 $bgs = $this->dat[
"bgs"];
244 $egs = $this->dat[
"egs"];
245 $pcost = $this->dat[
"pcost"];
246 $psum = $bps + $pcost;
247 $pcs = $eps - $bps + $pcost;
253 echo
"\\begin{center}\n";
254 echo
"\\begin{tabular}{ccccc}\n";
255 echo
"\\multicolumn{5}{l}{\\makebox[9cm][l]{売上原価の内訳}} \\\\\n";
256 echo
"\\multicolumn{1}{l}{\\makebox[1cm][l]{}} & ";
257 echo
"\\multicolumn{4}{l}{\\makebox[8cm][l]{製品売上原価}} \\\\\n";
258 echo
"\\multicolumn{2}{l}{\\makebox[2cm][l]{}} & ";
259 echo
"\\multicolumn{1}{l}{\\makebox[3cm][l]{期首製品棚卸高}} & ";
260 echo
"\\multicolumn{1}{l}{\\makebox[1cm][c]{}} & ";
261 echo
"\\multicolumn{1}{l}{\\makebox[3cm][r]{\\tt{" . $this->
amount0($bps) .
"}}} \\\\\n";
262 echo
"\\multicolumn{2}{l}{\\makebox[2cm][l]{}} & ";
263 echo
"\\multicolumn{1}{l}{\\makebox[3cm][l]{当期製造原価}} & ";
264 echo
"\\multicolumn{1}{l}{\\makebox[1cm][c]{}} & ";
265 echo
"\\multicolumn{1}{l}{\\makebox[3cm][r]{\\tt{" . $this->
amount0($pcost) .
"}}} \\\\\n";
266 echo
"\\multicolumn{3}{l}{\\makebox[5cm][l]{}} & ";
267 echo
"\\multicolumn{1}{l}{\\makebox[1cm][c]{合計}} & ";
268 echo
"\\multicolumn{1}{l}{\\makebox[3cm][r]{\\tt{" . $this->
amount0($psum) .
"}}} \\\\\n";
269 echo
"\\multicolumn{2}{l}{\\makebox[2cm][l]{}} & ";
270 echo
"\\multicolumn{1}{l}{\\makebox[3cm][l]{期末製品棚卸高}} & ";
271 echo
"\\multicolumn{1}{l}{\\makebox[1cm][c]{}} & ";
272 echo
"\\multicolumn{1}{l}{\\makebox[3cm][r]{\\tt{" . $this->
amount0($eps) .
"}}} \\\\\n";
273 echo
"\\multicolumn{2}{l}{\\makebox[2cm][l]{}} & ";
274 echo
"\\multicolumn{1}{l}{\\makebox[3cm][l]{製品売上原価}} & ";
275 echo
"\\multicolumn{1}{l}{\\makebox[1cm][c]{}} & ";
276 echo
"\\multicolumn{1}{l}{\\makebox[3cm][r]{\\tt{" . $this->
amount0($pcs) .
"}}} \\\\\n";
277 echo
"\\multicolumn{1}{l}{\\makebox[1cm][l]{}} & ";
278 echo
"\\multicolumn{4}{l}{\\makebox[8cm][l]{商品売上原価}} \\\\\n";
279 echo
"\\multicolumn{2}{l}{\\makebox[2cm][l]{}} & ";
280 echo
"\\multicolumn{1}{l}{\\makebox[3cm][l]{期首商品棚卸高}} & ";
281 echo
"\\multicolumn{1}{l}{\\makebox[1cm][c]{}} & ";
282 echo
"\\multicolumn{1}{l}{\\makebox[3cm][r]{\\tt{" . $this->
amount0($bgs) .
"}}} \\\\\n";
283 echo
"\\multicolumn{3}{l}{\\makebox[5cm][l]{}} & ";
284 echo
"\\multicolumn{1}{l}{\\makebox[1cm][c]{合計}} & ";
285 echo
"\\multicolumn{1}{l}{\\makebox[3cm][r]{\\tt{" . $this->
amount0($gsum) .
"}}} \\\\\n";
286 echo
"\\multicolumn{2}{l}{\\makebox[2cm][l]{}} & ";
287 echo
"\\multicolumn{1}{l}{\\makebox[3cm][l]{期末商品棚卸高}} & ";
288 echo
"\\multicolumn{1}{l}{\\makebox[1cm][c]{}} & ";
289 echo
"\\multicolumn{1}{l}{\\makebox[3cm][r]{\\tt{" . $this->
amount0($egs) .
"}}} \\\\\n";
290 echo
"\\multicolumn{2}{l}{\\makebox[2cm][l]{}} & ";
291 echo
"\\multicolumn{1}{l}{\\makebox[3cm][l]{商品売上原価}} & ";
292 echo
"\\multicolumn{1}{l}{\\makebox[1cm][c]{}} & ";
293 echo
"\\multicolumn{1}{l}{\\makebox[3cm][r]{\\tt{" . $this->
amount0($gcs) .
"}}} \\\\\n";
294 echo
"\\end{tabular}\n";
295 echo
"\\end{center}\n";
303 echo
"title = " . $this->dat[
"title"] .
"\n\n";
304 echo
"name = " . $this->dat[
"name"] .
"\n\n";
305 echo
"era = " . $this->dat[
"era"] .
"\n\n";
306 echo
"bymd = " . $this->dat[
"bymd"] .
"\n\n";
307 echo
"ty = " . $this->dat[
"ty"] .
"\n\n";
308 echo
"bps = " . $this->dat[
"bps"] .
"\n\n";
309 echo
"eps = " . $this->dat[
"eps"] .
"\n\n";
310 echo
"bgs = " . $this->dat[
"bgs"] .
"\n\n";
311 echo
"egs = " . $this->dat[
"egs"] .
"\n\n";
312 echo
"pcost = " . $this->dat[
"pcost"] .
"\n\n";
313 echo
"rows = " . $this->dat[
"rows"] .
"\n\n";
315 echo $this->dat[
"field"][
"n"] .
", " .
316 $this->dat[
"field"][
"m"] .
", " .
317 $this->dat[
"field"][
"mm"] .
", " .
318 $this->dat[
"field"][
"account_cd"] .
", " .
319 $this->dat[
"field"][
"name"] .
", " .
320 $this->dat[
"field"][
"remain"] .
", " .
321 $this->dat[
"field"][
"division"] .
"\n\n";
323 $cnt = $this->dat[
"rows"];
324 for ($i = 0; $i <
$cnt; $i++) {
325 echo $this->dat[
"data"][$i][
"n"] .
", " .
326 $this->dat[
"data"][$i][
"m"] .
", " .
327 $this->dat[
"data"][$i][
"mm"] .
", " .
328 $this->dat[
"data"][$i][
"account_cd"] .
", " .
329 $this->dat[
"data"][$i][
"name"] .
", " .
330 $this->dat[
"data"][$i][
"remain"] .
", " .
331 $this->dat[
"data"][$i][
"division"] .
"\n\n";
344 $this->csvfile = $filename;
345 $this->dat = array();
353 \documentclass[a4j]{jarticle}
355 \usepackage{supertabular}
356 \usepackage{multirow}
369 \def\Hline{\noalign{\hrule height .5mm}}
370 \def\Vline{\vrule width .5mm}
381 $n =
$my->make_a_page($n);
383 $my->make_a_result();