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));
44 $csv = file($this->csvfile);
47 for ($i = 0; $i <
$cnt; $i++) {
48 $rec = explode(
"\t", $csv[$i]);
61 $this->dat[$rec[0]] = trim($rec[1]);
64 $this->dat[$rec[0]][
"n"] = trim($rec[1]);
65 $this->dat[$rec[0]][
"m"] = trim($rec[2]);
66 $this->dat[$rec[0]][
"mm"] = trim($rec[3]);
67 $this->dat[$rec[0]][
"account_cd"] = trim($rec[4]);
68 $this->dat[$rec[0]][
"name"] = trim($rec[5]);
69 $this->dat[$rec[0]][
"remain"] = trim($rec[6]);
70 $this->dat[$rec[0]][
"division"] = trim($rec[7]);
73 $this->dat[$rec[0]][$data_n][
"n"] = trim($rec[1]);
74 $this->dat[$rec[0]][$data_n][
"m"] = trim($rec[2]);
75 $this->dat[$rec[0]][$data_n][
"mm"] = trim($rec[3]);
76 $this->dat[$rec[0]][$data_n][
"account_cd"] = trim($rec[4]);
77 $this->dat[$rec[0]][$data_n][
"name"] = trim($rec[5]);
78 $this->dat[$rec[0]][$data_n][
"remain"] = trim($rec[6]);
79 $this->dat[$rec[0]][$data_n][
"division"] = trim($rec[7]);
95 $d = $this->dat[
"data"];
96 $title = $this->dat[
"title"];
97 $name = $this->dat[
"name"];
98 $era = $this->dat[
"era"];
99 $bymd = $this->dat[
"bymd"];
100 $ty = $this->dat[
"ty"];
102 $tax1 = $this->dat[
"tax1"];
103 $tax2 = $this->dat[
"tax2"];
104 $pprof = $this->dat[
"pprof"];
105 $ploss = $this->dat[
"ploss"];
106 $profit = $this->dat[
"profit"];
107 $xval = $profit - $tax1 - $tax2 + $pprof + $ploss;
108 $xnam = ($xval < 0) ?
"当期未処分損失" :
"当期未処分利益";
112 $inam = $d[$n][
"name"];
114 $yyyy = intval($m / 100);
115 $term = $this->
term($bymd, $yyyy, $mm);
119 echo
"\\begin{center}\n";
120 echo
"\\begin{tabular}{ccc}\n";
121 echo
"\\multicolumn{2}{l}{\\makebox[12.5cm][l]{" . $name .
"}} & ";
122 echo
"\\makebox[2.5cm][r]{\\tt{" . $era .
"年度}} \\\\\n";
123 echo
"\\makebox[2.5cm][l]{ } & ";
124 echo
"\\makebox[10cm][c]{\\bf\\LARGE{" . $title .
"}} & ";
125 echo
"\\makebox[2.5cm][r]{} \\\\\n";
126 echo
"\\makebox[2.5cm][l]{} & ";
127 echo
"\\makebox[10cm][c]{{\\tt{" . $term0 .
" 〜 " . $term1 .
"}}} & ";
128 echo
"\\makebox[2.5cm][r]{\\tt{}} \\\\\n";
129 echo
"\\end{tabular}\n";
130 echo
"\\end{center}\n";
132 echo
"\\begin{center}\n";
133 echo
"\\begin{tabular}{@{\\Vline\\ }c|c|c|c@{\\ \\Vline}}\n";
135 echo
"\\multicolumn{2}{@{\\Vline\\ }c|}{\\makebox[7.4cm][c]{\\bf{資 産}}} & ";
136 echo
"\\multicolumn{2}{c@{\\ \\Vline}}{\\makebox[7.4cm][c]{\\bf{負 債 ・ 資 本}}} \\\\\n";
150 if (!isset($d[$n][
"mm"])) {
153 }
else if ($month != $d[$n][
"mm"]) {
158 switch ($d[$n][
"name"]) {
166 if ($d[$n][
"division"]) {
167 $drec[$n1][1][
"name"] = $d[$n][
"name"];
168 $drec[$n1][1][
"remain"] = $d[$n][
"remain"];
171 $drec[$n0][0][
"name"] = $d[$n][
"name"];
172 $drec[$n0][0][
"remain"] = $d[$n][
"remain"];
181 $drec[$n1][1][
"name"] = $xnam;
182 $drec[$n1][1][
"remain"] = $xval;
187 $nmax = max($n0, $n1);
188 for ($i = 0; $i < $nmax; $i++) {
190 $dn = $drec[$i][0][
"name"];
191 $dr = $this->
amount($drec[$i][0][
"remain"]);
192 $dsum += $drec[$i][0][
"remain"];
199 $cn = $drec[$i][1][
"name"];
200 $cr = $this->
amount($drec[$i][1][
"remain"]);
201 $csum += $drec[$i][1][
"remain"];
207 echo
"\\makebox[3.7cm][l]{" . $dn .
"} & ";
208 echo
"\\makebox[3.7cm][r]{" . $dr .
"} & ";
209 echo
"\\makebox[3.7cm][l]{" . $cn .
"} & ";
210 echo
"\\makebox[3.7cm][r]{" . $cr .
"} \\\\\n";
218 echo
"\\makebox[3.7cm][c]{\bf{合 計}} & ";
219 echo
"\\makebox[3.7cm][r]{" . $dr .
"} & ";
220 echo
"\\makebox[3.7cm][c]{\bf{合 計}} & ";
221 echo
"\\makebox[3.7cm][r]{" . $cr .
"} \\\\\n";
225 echo
"\\end{tabular}\n";
226 echo
"\\end{center}\n";
235 $tax1 = $this->dat[
"tax1"];
236 $tax2 = $this->dat[
"tax2"];
237 $pprof = $this->dat[
"pprof"];
238 $ploss = $this->dat[
"ploss"];
239 $profit = $this->dat[
"profit"];
240 $prof2 = $profit - $tax1 - $tax2;
241 $x = $pprof + $ploss;
243 $nam1 = ($x < 0) ?
"期首繰越損失" :
"期首繰越利益";
244 $nam2 = ($y < 0) ?
"当期未処分損失" :
"当期未処分利益";
248 echo
"\\begin{center}\n";
249 echo
"\\begin{tabular}{ccc}\n";
250 echo
"\\multicolumn{3}{c}{\\makebox[8cm][l]{" . $nam2 .
"の内訳}} \\\\\n";
251 echo
"\\multicolumn{3}{c}{\\makebox[8cm][l]{}} \\\\\n";
252 echo
"\\multicolumn{1}{c}{\\makebox[1cm][l]{}} & ";
253 echo
"\\multicolumn{1}{c}{\\makebox[4cm][l]{当期利益}} & ";
254 echo
"\\multicolumn{1}{c}{\\makebox[3cm][r]{\\tt{" . $this->
amount0($profit) .
"}}} \\\\\n";
255 echo
"\\multicolumn{1}{c}{\\makebox[1cm][l]{}} & ";
256 echo
"\\multicolumn{1}{c}{\\makebox[4cm][l]{未払法人税等}} & ";
257 echo
"\\multicolumn{1}{c}{\\makebox[3cm][r]{\\tt{" . $this->
amount0($tax1) .
"}}} \\\\\n";
258 echo
"\\multicolumn{1}{c}{\\makebox[1cm][l]{}} & ";
259 echo
"\\multicolumn{1}{c}{\\makebox[4cm][l]{未払消費税}} & ";
260 echo
"\\multicolumn{1}{c}{\\makebox[3cm][r]{\\tt{" . $this->
amount0($tax2) .
"}}} \\\\\n";
261 echo
"\\multicolumn{1}{c}{\\makebox[1cm][l]{}} & ";
262 echo
"\\multicolumn{1}{c}{\\makebox[4cm][l]{税引後当期利益}} & ";
263 echo
"\\multicolumn{1}{c}{\\makebox[3cm][r]{\\tt{" . $this->
amount0($prof2) .
"}}} \\\\\n";
264 echo
"\\multicolumn{1}{c}{\\makebox[1cm][l]{}} & ";
265 echo
"\\multicolumn{1}{c}{\\makebox[4cm][l]{" . $nam1 .
"}} & ";
266 echo
"\\multicolumn{1}{c}{\\makebox[3cm][r]{\\tt{" . $this->
amount0($x) .
"}}} \\\\\n";
267 echo
"\\multicolumn{1}{c}{\\makebox[1cm][l]{}} & ";
268 echo
"\\multicolumn{1}{c}{\\makebox[4cm][l]{" . $nam2 .
"}} & ";
269 echo
"\\multicolumn{1}{c}{\\makebox[3cm][r]{\\tt{" . $this->
amount0($y) .
"}}} \\\\\n";
270 echo
"\\end{tabular}\n";
271 echo
"\\end{center}\n";
279 echo
"title = " . $this->dat[
"title"] .
"\n\n";
280 echo
"name = " . $this->dat[
"name"] .
"\n\n";
281 echo
"era = " . $this->dat[
"era"] .
"\n\n";
282 echo
"bymd = " . $this->dat[
"bymd"] .
"\n\n";
283 echo
"ty = " . $this->dat[
"ty"] .
"\n\n";
284 echo
"tax1 = " . $this->dat[
"tax1"] .
"\n\n";
285 echo
"tax2 = " . $this->dat[
"tax2"] .
"\n\n";
286 echo
"pprof = " . $this->dat[
"pprof"] .
"\n\n";
287 echo
"ploss = " . $this->dat[
"ploss"] .
"\n\n";
288 echo
"profit = " . $this->dat[
"profit"] .
"\n\n";
289 echo
"rows = " . $this->dat[
"rows"] .
"\n\n";
291 echo $this->dat[
"field"][
"n"] .
", " .
292 $this->dat[
"field"][
"m"] .
", " .
293 $this->dat[
"field"][
"mm"] .
", " .
294 $this->dat[
"field"][
"account_cd"] .
", " .
295 $this->dat[
"field"][
"name"] .
", " .
296 $this->dat[
"field"][
"remain"] .
", " .
297 $this->dat[
"field"][
"division"] .
"\n\n";
299 $cnt = $this->dat[
"rows"];
300 for ($i = 0; $i <
$cnt; $i++) {
301 echo $this->dat[
"data"][$i][
"n"] .
", " .
302 $this->dat[
"data"][$i][
"m"] .
", " .
303 $this->dat[
"data"][$i][
"mm"] .
", " .
304 $this->dat[
"data"][$i][
"account_cd"] .
", " .
305 $this->dat[
"data"][$i][
"name"] .
", " .
306 $this->dat[
"data"][$i][
"remain"] .
", " .
307 $this->dat[
"data"][$i][
"division"] .
"\n\n";
320 $this->csvfile = $filename;
321 $this->dat = array();
329 \documentclass[a4j]{jarticle}
331 \usepackage{supertabular}
332 \usepackage{multirow}
345 \def\Hline{\noalign{\hrule height .5mm}}
346 \def\Vline{\vrule width .5mm}
357 $n =
$my->make_a_page($n);
359 $my->make_a_result();