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));
38 $cnt = $this->dat[
"rows"];
39 $d = $this->dat[
"data"];
41 for ($i = 0; $i <
$cnt; $i++) {
42 if ($mm == $d[$i][
"mm"]) {
62 private function sum($mm)
70 $cnt = $this->dat[
"rows"];
71 $d = $this->dat[
"data"];
73 for ($i = 0; $i <
$cnt; $i++) {
74 if ($mm == $d[$i][
"mm"]) {
75 $s[0] += $d[$i][
"debit_remain"];
76 $s[1] += $d[$i][
"debit_sum"];
77 $s[3] += $d[$i][
"credit_sum"];
78 $s[4] += $d[$i][
"credit_remain"];
88 $csv = file($this->csvfile);
91 for ($i = 0; $i <
$cnt; $i++) {
92 $rec = explode(
"\t", $csv[$i]);
99 $this->dat[$rec[0]] = trim($rec[1]);
102 $this->dat[$rec[0]][
"n"] = trim($rec[1]);
103 $this->dat[$rec[0]][
"m"] = trim($rec[2]);
104 $this->dat[$rec[0]][
"mm"] = trim($rec[3]);
105 $this->dat[$rec[0]][
"ctg_div"] = trim($rec[4]);
106 $this->dat[$rec[0]][
"division"] = trim($rec[5]);
107 $this->dat[$rec[0]][
"ccd"] = trim($rec[6]);
108 $this->dat[$rec[0]][
"item"] = trim($rec[7]);
109 $this->dat[$rec[0]][
"debit_remain"] = trim($rec[8]);
110 $this->dat[$rec[0]][
"debit_sum"] = trim($rec[9]);
111 $this->dat[$rec[0]][
"name"] = trim($rec[10]);
112 $this->dat[$rec[0]][
"credit_sum"] = trim($rec[11]);
113 $this->dat[$rec[0]][
"credit_remain"] = trim($rec[12]);
116 $this->dat[$rec[0]][$data_n][
"n"] = trim($rec[1]);
117 $this->dat[$rec[0]][$data_n][
"m"] = trim($rec[2]);
118 $this->dat[$rec[0]][$data_n][
"mm"] = trim($rec[3]);
119 $this->dat[$rec[0]][$data_n][
"ctg_div"] = trim($rec[4]);
120 $this->dat[$rec[0]][$data_n][
"division"] = trim($rec[5]);
121 $this->dat[$rec[0]][$data_n][
"ccd"] = trim($rec[6]);
122 $this->dat[$rec[0]][$data_n][
"item"] = trim($rec[7]);
123 $this->dat[$rec[0]][$data_n][
"debit_remain"] = trim($rec[8]);
124 $this->dat[$rec[0]][$data_n][
"debit_sum"] = trim($rec[9]);
125 $this->dat[$rec[0]][$data_n][
"name"] = trim($rec[10]);
126 $this->dat[$rec[0]][$data_n][
"credit_sum"] = trim($rec[11]);
127 $this->dat[$rec[0]][$data_n][
"credit_remain"] = trim($rec[12]);
143 $d = $this->dat[
"data"];
144 $title = $this->dat[
"title"];
145 $name = $this->dat[
"name"];
146 $era = $this->dat[
"era"];
147 $bymd = $this->dat[
"bymd"];
150 $item = $d[$n][
"item"];
151 $inam = $d[$n][
"name"];
153 $yyyy = intval($m / 100);
154 $term = $this->
term($bymd, $yyyy, $mm);
158 $p = $this->
pages($n, $mm);
160 echo
"\\begin{center}\n";
161 echo
"\\begin{tabular}{ccc}\n";
162 echo
"\\multicolumn{2}{l}{\\makebox[12.5cm][l]{" . $name .
"}} & ";
163 echo
"\\makebox[2.5cm][r]{\\tt{" . $era .
"年度}} \\\\\n";
164 echo
"\\makebox[2.5cm][l]{} & ";
165 echo
"\\makebox[10cm][c]{\\bf\\LARGE{" . $title .
"}} & ";
166 echo
"\\makebox[2.5cm][r]{" . $mm .
"月度} \\\\\n";
167 echo
"\\makebox[2.5cm][l]{} & ";
168 echo
"\\makebox[10cm][c]{{\\tt{" . $term0 .
" 〜 " . $term1 .
"}}} & ";
169 echo
"\\makebox[2.5cm][r]{\\tt{" . $p[0] .
"/" . $p[1] .
"}} \\\\\n";
170 echo
"\\end{tabular}\n";
172 echo
"\\begin{center}\n";
173 echo
"\\begin{tabular}{@{\\Vline\\ }c|c|c|c|c@{\\ \\Vline}}\n";
175 echo
"\\multicolumn{2}{@{\\Vline\\ }c|}{\\makebox[4.4cm][c]{\\bf{借方}}} & ";
176 echo
"\\multirow{2}{*}{\\makebox[5cm][c]{\\bf{摘要}}} & ";
177 echo
"\\multicolumn{2}{c@{\\ \\Vline}}{\\makebox[4.4cm][c]{\\bf{貸方}}} \\\\\n";
178 echo
"\\cline{1-2}\\cline{4-5}\n";
179 echo
"\\makebox[2.2cm][c]{\\bf{当期残高}} & ";
180 echo
"\\makebox[2.2cm][c]{\\bf{当月合計}} & ";
181 echo
"\\makebox[5cm][c]{\\bf{}} & ";
182 echo
"\\makebox[2.2cm][c]{\\bf{当月合計}} & ";
183 echo
"\\makebox[2.2cm][c]{\\bf{当期残高}} \\\\\n ";
195 if (!isset($d[$n][
"mm"])) {
198 }
else if ($month != $d[$n][
"mm"]) {
203 $dr = $d[$n][
"debit_remain"];
204 $ds = $d[$n][
"debit_sum"];
205 $nam = $d[$n][
"name"];
206 $cs = $d[$n][
"credit_sum"];
207 $cr = $d[$n][
"credit_remain"];
209 $dr = ($dr == 0) ?
"" : $this->
amount($dr);
210 $ds = ($ds == 0) ?
"" : $this->
amount($ds);
211 $cs = ($cs == 0) ?
"" : $this->
amount($cs);
212 $cr = ($cr == 0) ?
"" : $this->
amount($cr);
214 echo
"\\makebox[2.2cm][r]{" . $dr .
"} & ";
215 echo
"\\makebox[2.2cm][r]{" . $ds .
"} & ";
216 echo
"\\makebox[5.0cm][c]{" . $nam .
"} & ";
217 echo
"\\makebox[2.2cm][r]{" . $cs .
"} & ";
218 echo
"\\makebox[2.2cm][r]{" . $cr .
"} \\\\\n";
224 $s = $this->
sum($mm);
232 $dr = ($dr == 0) ?
"" : $this->
amount($dr);
233 $ds = ($ds == 0) ?
"" : $this->
amount($ds);
234 $nam =
"{\\bf{" . $nam .
"}}";
235 $cs = ($cs == 0) ?
"" : $this->
amount($cs);
236 $cr = ($cr == 0) ?
"" : $this->
amount($cr);
239 echo
"\\makebox[2.2cm][r]{" . $dr .
"} & ";
240 echo
"\\makebox[2.2cm][r]{" . $ds .
"} & ";
241 echo
"\\makebox[5.0cm][c]{" . $nam .
"} & ";
242 echo
"\\makebox[2.2cm][r]{" . $cs .
"} & ";
243 echo
"\\makebox[2.2cm][r]{" . $cr .
"} \\\\\n";
247 echo
"\\end{tabular}\n";
248 echo
"\\end{center}\n";
257 echo
"title = " . $this->dat[
"title"] .
"\n\n";
258 echo
"name = " . $this->dat[
"name"] .
"\n\n";
259 echo
"era = " . $this->dat[
"era"] .
"\n\n";
260 echo
"bymd = " . $this->dat[
"bymd"] .
"\n\n";
261 echo
"rows = " . $this->dat[
"rows"] .
"\n\n";
263 echo $this->dat[
"field"][
"n"] .
", " .
264 $this->dat[
"field"][
"m"] .
", " .
265 $this->dat[
"field"][
"mm"] .
", " .
266 $this->dat[
"field"][
"ctg_div"] .
", " .
267 $this->dat[
"field"][
"division"] .
", " .
268 $this->dat[
"field"][
"ccd"] .
", " .
269 $this->dat[
"field"][
"item"] .
", " .
270 $this->dat[
"field"][
"debit_remain"] .
", " .
271 $this->dat[
"field"][
"debit_sum"] .
", " .
272 $this->dat[
"field"][
"name"] .
", " .
273 $this->dat[
"field"][
"credit_sum"] .
", " .
274 $this->dat[
"field"][
"credit_remain"] .
"\n\n";
276 $cnt = $this->dat[
"rows"];
277 for ($i = 0; $i <
$cnt; $i++) {
278 echo $this->dat[
"data"][$i][
"n"] .
", " .
279 $this->dat[
"data"][$i][
"m"] .
", " .
280 $this->dat[
"data"][$i][
"mm"] .
", " .
281 $this->dat[
"data"][$i][
"ctg_div"] .
", " .
282 $this->dat[
"data"][$i][
"division"] .
", " .
283 $this->dat[
"data"][$i][
"ccd"] .
", " .
284 $this->dat[
"data"][$i][
"item"] .
", " .
285 $this->dat[
"data"][$i][
"debit_remain"] .
", " .
286 $this->dat[
"data"][$i][
"debit_sum"] .
", " .
287 $this->dat[
"data"][$i][
"name"] .
", " .
288 $this->dat[
"data"][$i][
"credit_sum"] .
", " .
289 $this->dat[
"data"][$i][
"credit_remain"] .
"\n\n";
302 $this->csvfile = $filename;
303 $this->dat = array();
311 \documentclass[a4j]{jarticle}
313 \usepackage{supertabular}
314 \usepackage{multirow}
327 \def\Hline{\noalign{\hrule height .5mm}}
328 \def\Vline{\vrule width .5mm}
339 $n =
$my->make_a_page($n);