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"];
42 for ($i = 0; $i <
$cnt; $i++) {
43 if ($mm == $d[$i][
"mm"]) {
64 private function sum($mm)
72 $cnt = $this->dat[
"rows"];
73 $d = $this->dat[
"data"];
75 for ($i = 0; $i <
$cnt; $i++) {
76 if ($mm == $d[$i][
"mm"]) {
77 $s[0] += $d[$i][
"debit_remain"];
78 $s[1] += $d[$i][
"debit_sum"];
79 $s[3] += $d[$i][
"credit_sum"];
80 $s[4] += $d[$i][
"credit_remain"];
90 $csv = file($this->csvfile);
93 for ($i = 0; $i <
$cnt; $i++) {
94 $rec = explode(
"\t", $csv[$i]);
101 $this->dat[$rec[0]] = trim($rec[1]);
104 $this->dat[$rec[0]][
"n"] = trim($rec[1]);
105 $this->dat[$rec[0]][
"m"] = trim($rec[2]);
106 $this->dat[$rec[0]][
"mm"] = trim($rec[3]);
107 $this->dat[$rec[0]][
"ctg_div"] = trim($rec[4]);
108 $this->dat[$rec[0]][
"division"] = trim($rec[5]);
109 $this->dat[$rec[0]][
"item"] = trim($rec[6]);
110 $this->dat[$rec[0]][
"debit_remain"] = trim($rec[7]);
111 $this->dat[$rec[0]][
"debit_sum"] = trim($rec[8]);
112 $this->dat[$rec[0]][
"name"] = trim($rec[9]);
113 $this->dat[$rec[0]][
"credit_sum"] = trim($rec[10]);
114 $this->dat[$rec[0]][
"credit_remain"] = trim($rec[11]);
117 $this->dat[$rec[0]][$data_n][
"n"] = trim($rec[1]);
118 $this->dat[$rec[0]][$data_n][
"m"] = trim($rec[2]);
119 $this->dat[$rec[0]][$data_n][
"mm"] = trim($rec[3]);
120 $this->dat[$rec[0]][$data_n][
"ctg_div"] = trim($rec[4]);
121 $this->dat[$rec[0]][$data_n][
"division"] = trim($rec[5]);
122 $this->dat[$rec[0]][$data_n][
"item"] = trim($rec[6]);
123 $this->dat[$rec[0]][$data_n][
"debit_remain"] = trim($rec[7]);
124 $this->dat[$rec[0]][$data_n][
"debit_sum"] = trim($rec[8]);
125 $this->dat[$rec[0]][$data_n][
"name"] = trim($rec[9]);
126 $this->dat[$rec[0]][$data_n][
"credit_sum"] = trim($rec[10]);
127 $this->dat[$rec[0]][$data_n][
"credit_remain"] = trim($rec[11]);
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 ";
194 if (!isset($d[$n][
"mm"])) {
197 }
else if ($month != $d[$n][
"mm"]) {
202 $dr = $d[$n][
"debit_remain"];
203 $ds = $d[$n][
"debit_sum"];
204 $nam = $d[$n][
"name"];
205 $cs = $d[$n][
"credit_sum"];
206 $cr = $d[$n][
"credit_remain"];
208 $dr = ($dr == 0) ?
"" : $this->
amount($dr);
209 $ds = ($ds == 0) ?
"" : $this->
amount($ds);
210 $cs = ($cs == 0) ?
"" : $this->
amount($cs);
211 $cr = ($cr == 0) ?
"" : $this->
amount($cr);
213 echo
"\\makebox[2.2cm][r]{" . $dr .
"} & ";
214 echo
"\\makebox[2.2cm][r]{" . $ds .
"} & ";
215 echo
"\\makebox[5.0cm][c]{" . $nam .
"} & ";
216 echo
"\\makebox[2.2cm][r]{" . $cs .
"} & ";
217 echo
"\\makebox[2.2cm][r]{" . $cr .
"} \\\\\n";
223 $s = $this->
sum($mm);
231 $dr = ($dr == 0) ?
"" : $this->
amount($dr);
232 $ds = ($ds == 0) ?
"" : $this->
amount($ds);
233 $nam =
"{\\bf{" . $nam .
"}}";
234 $cs = ($cs == 0) ?
"" : $this->
amount($cs);
235 $cr = ($cr == 0) ?
"" : $this->
amount($cr);
238 echo
"\\makebox[2.2cm][r]{" . $dr .
"} & ";
239 echo
"\\makebox[2.2cm][r]{" . $ds .
"} & ";
240 echo
"\\makebox[5.0cm][c]{" . $nam .
"} & ";
241 echo
"\\makebox[2.2cm][r]{" . $cs .
"} & ";
242 echo
"\\makebox[2.2cm][r]{" . $cr .
"} \\\\\n";
246 echo
"\\end{tabular}\n";
247 echo
"\\end{center}\n";
256 echo
"title = " .$this->dat[
"title"] .
"\n\n";
257 echo
"name = " .$this->dat[
"name"] .
"\n\n";
258 echo
"era = " .$this->dat[
"era"] .
"\n\n";
259 echo
"bymd = " .$this->dat[
"bymd"] .
"\n\n";
260 echo
"rows = " .$this->dat[
"rows"] .
"\n\n";
262 echo $this->dat[
"field"][
"n"] .
", " .
263 $this->dat[
"field"][
"m"] .
", " .
264 $this->dat[
"field"][
"mm"] .
", " .
265 $this->dat[
"field"][
"ctg_div"] .
", " .
266 $this->dat[
"field"][
"division"] .
", " .
267 $this->dat[
"field"][
"item"] .
", " .
268 $this->dat[
"field"][
"debit_remain"] .
", " .
269 $this->dat[
"field"][
"debit_sum"] .
", " .
270 $this->dat[
"field"][
"name"] .
", " .
271 $this->dat[
"field"][
"credit_sum"] .
", " .
272 $this->dat[
"field"][
"credit_remain"] .
"\n\n";
274 $cnt = $this->dat[
"rows"];
275 for ($i = 0; $i <
$cnt; $i++) {
276 echo $this->dat[
"data"][$i][
"n"] .
", " .
277 $this->dat[
"data"][$i][
"m"] .
", " .
278 $this->dat[
"data"][$i][
"mm"] .
", " .
279 $this->dat[
"data"][$i][
"ctg_div"] .
", " .
280 $this->dat[
"data"][$i][
"division"] .
", " .
281 $this->dat[
"data"][$i][
"item"] .
", " .
282 $this->dat[
"data"][$i][
"debit_remain"] .
", " .
283 $this->dat[
"data"][$i][
"debit_sum"] .
", " .
284 $this->dat[
"data"][$i][
"name"] .
", " .
285 $this->dat[
"data"][$i][
"credit_sum"] .
", " .
286 $this->dat[
"data"][$i][
"credit_remain"] .
"\n\n";
299 $this->csvfile = $filename;
300 $this->dat = array();
308 \documentclass[a4j]{jarticle}
310 \usepackage{supertabular}
311 \usepackage{multirow}
324 \def\Hline{\noalign{\hrule height .5mm}}
325 \def\Vline{\vrule width .5mm}
336 $n =
$my->make_a_page($n);