8 define(
'MAX_LINES_PAR_PAGE', 40);
18 return ($x == 0) ?
"" :
"{\\tt{" . str_replace(
"-",
"▲", number_format($x)) .
"}}";
22 private function term($bymd, $y, $m)
24 $yyyymm = intval($bymd / 100);
25 $by = intval($yyyymm / 100);
29 $a[0] = date(
"Y/m/d", mktime(0, 0, 0, $bm, 1, $by));
30 $a[1] = date(
"Y/m/d", mktime(0, 0, 0, $m + 1, 0, $y));
37 $cnt = $this->dat[
"rows"];
38 $d = $this->dat[
"data"];
40 for ($i = 0; $i <
$cnt; $i++) {
41 if ($mm == $d[$i][
"mm"]) {
60 private function sum($mm)
65 $cnt = $this->dat[
"rows"];
66 $d = $this->dat[
"data"];
68 for ($i = 0; $i <
$cnt; $i++) {
69 if ($mm == $d[$i][
"mm"]) {
70 $r = $d[$i][
"remain"];
71 if ($d[$i][
"division"]) {
85 $csv = file($this->csvfile);
88 for ($i = 0; $i <
$cnt; $i++) {
89 $rec = explode(
"\t", $csv[$i]);
96 $this->dat[$rec[0]] = trim($rec[1]);
99 $this->dat[$rec[0]][
"n"] = trim($rec[1]);
100 $this->dat[$rec[0]][
"m"] = trim($rec[2]);
101 $this->dat[$rec[0]][
"mm"] = trim($rec[3]);
102 $this->dat[$rec[0]][
"account_cd"] = trim($rec[4]);
103 $this->dat[$rec[0]][
"name"] = trim($rec[5]);
104 $this->dat[$rec[0]][
"remain"] = trim($rec[6]);
105 $this->dat[$rec[0]][
"division"] = trim($rec[7]);
108 $this->dat[$rec[0]][$data_n][
"n"] = trim($rec[1]);
109 $this->dat[$rec[0]][$data_n][
"m"] = trim($rec[2]);
110 $this->dat[$rec[0]][$data_n][
"mm"] = trim($rec[3]);
111 $this->dat[$rec[0]][$data_n][
"account_cd"] = trim($rec[4]);
112 $this->dat[$rec[0]][$data_n][
"name"] = trim($rec[5]);
113 $this->dat[$rec[0]][$data_n][
"remain"] = trim($rec[6]);
114 $this->dat[$rec[0]][$data_n][
"division"] = trim($rec[7]);
130 $d = $this->dat[
"data"];
131 $title = $this->dat[
"title"];
132 $name = $this->dat[
"name"];
133 $era = $this->dat[
"era"];
134 $bymd = $this->dat[
"bymd"];
137 $inam = $d[$n][
"name"];
139 $yyyy = intval($m / 100);
140 $term = $this->
term($bymd, $yyyy, $mm);
144 $p = $this->
pages($n, $mm);
146 echo
"\\begin{center}\n";
147 echo
"\\begin{tabular}{ccc}\n";
148 echo
"\\multicolumn{2}{l}{\\makebox[12.5cm][l]{" . $name .
"}} & ";
149 echo
"\\makebox[2.5cm][r]{\\tt{" . $era .
"年度}} \\\\\n";
150 echo
"\\makebox[2.5cm][l]{} & ";
151 echo
"\\makebox[10cm][c]{\\bf\\LARGE{" . $title .
"}} & ";
152 echo
"\\makebox[2.5cm][r]{" . $mm .
"月度} \\\\\n";
153 echo
"\\makebox[2.5cm][l]{} & ";
154 echo
"\\makebox[10cm][c]{{\\tt{" . $term0 .
" 〜 " . $term1 .
"}}} & ";
155 echo
"\\makebox[2.5cm][r]{\\tt{" . $p[0] .
"/" . $p[1] .
"}} \\\\\n";
156 echo
"\\end{tabular}\n";
158 echo
"\\begin{center}\n";
159 echo
"\\begin{tabular}{@{\\Vline\\ }c|c|c|c@{\\ \\Vline}}\n";
161 echo
"\\multicolumn{2}{@{\\Vline\\ }c|}{\\makebox[7.4cm][c]{\\bf{資 産}}} & ";
162 echo
"\\multicolumn{2}{c@{\\ \\Vline}}{\\makebox[7.4cm][c]{\\bf{負 債 ・ 資 本}}} \\\\\n";
176 if (!isset($d[$n][
"mm"])) {
179 }
else if ($month != $d[$n][
"mm"]) {
184 if ($d[$n][
"division"]) {
185 $drec[$n1][1][
"name"] = $d[$n][
"name"];
186 $drec[$n1][1][
"remain"] = $d[$n][
"remain"];
189 $drec[$n0][0][
"name"] = $d[$n][
"name"];
190 $drec[$n0][0][
"remain"] = $d[$n][
"remain"];
197 $nmax = max($n0, $n1);
198 for ($i = 0; $i < $nmax; $i++) {
200 $dn = $drec[$i][0][
"name"];
201 $dr = $this->
amount($drec[$i][0][
"remain"]);
208 $cn = $drec[$i][1][
"name"];
209 $cr = $this->
amount($drec[$i][1][
"remain"]);
215 echo
"\\makebox[3.7cm][l]{" . $dn .
"} & ";
216 echo
"\\makebox[3.7cm][r]{" . $dr .
"} & ";
217 echo
"\\makebox[3.7cm][l]{" . $cn .
"} & ";
218 echo
"\\makebox[3.7cm][r]{" . $cr .
"} \\\\\n";
223 $s = $this->
sum($mm);
228 $dr = ($dr == 0) ?
"" : $this->
amount($dr);
229 $cr = ($cr == 0) ?
"" : $this->
amount($cr);
232 echo
"\\makebox[3.7cm][c]{\bf{合 計}} & ";
233 echo
"\\makebox[3.7cm][r]{" . $dr .
"} & ";
234 echo
"\\makebox[3.7cm][c]{\bf{合 計}} & ";
235 echo
"\\makebox[3.7cm][r]{" . $cr .
"} \\\\\n";
239 echo
"\\end{tabular}\n";
240 echo
"\\end{center}\n";
249 echo
"title = " . $this->dat[
"title"] .
"\n\n";
250 echo
"name = " . $this->dat[
"name"] .
"\n\n";
251 echo
"era = " . $this->dat[
"era"] .
"\n\n";
252 echo
"bymd = " . $this->dat[
"bymd"] .
"\n\n";
253 echo
"rows = " . $this->dat[
"rows"] .
"\n\n";
255 echo $this->dat[
"field"][
"n"] .
", " .
256 $this->dat[
"field"][
"m"] .
", " .
257 $this->dat[
"field"][
"mm"] .
", " .
258 $this->dat[
"field"][
"account_cd"] .
", " .
259 $this->dat[
"field"][
"name"] .
", " .
260 $this->dat[
"field"][
"remain"] .
", " .
261 $this->dat[
"field"][
"division"] .
"\n\n";
263 $cnt = $this->dat[
"rows"];
264 for ($i = 0; $i <
$cnt; $i++) {
265 echo $this->dat[
"data"][$i][
"n"] .
", " .
266 $this->dat[
"data"][$i][
"m"] .
", " .
267 $this->dat[
"data"][$i][
"mm"] .
", " .
268 $this->dat[
"data"][$i][
"account_cd"] .
", " .
269 $this->dat[
"data"][$i][
"name"] .
", " .
270 $this->dat[
"data"][$i][
"remain"] .
", " .
271 $this->dat[
"data"][$i][
"division"] .
"\n\n";
284 $this->csvfile = $filename;
285 $this->dat = array();
293 \documentclass[a4j]{jarticle}
295 \usepackage{supertabular}
296 \usepackage{multirow}
309 \def\Hline{\noalign{\hrule height .5mm}}
310 \def\Vline{\vrule width .5mm}
321 $n =
$my->make_a_page($n);