8 define(
'MAX_LINES_PAR_PAGE', 40);
18 return ($x == 0) ?
"" :
"{\\tt{" . str_replace(
"-",
"▲", number_format($x)) .
"}}";
24 $y = explode(
" ", $x);
25 $z = explode(
"-", $y[0]);
27 return $z[0].
"/" . $z[1] .
"/" . $z[2];
31 private function sum($id, $n)
37 $d = $this->dat[
"data"];
41 if (!isset($d[$i][
"id"])) {
45 if ($id != $d[$i][
"id"]) {
49 $s[0] += $d[$i][
"debit_amount"];
50 $s[2] += $d[$i][
"credit_amount"];
60 $csv = file($this->csvfile);
63 for ($i = 0; $i <
$cnt; $i++) {
64 $rec = explode(
"\t", $csv[$i]);
70 $this->dat[$rec[0]] = trim($rec[1]);
73 $this->dat[$rec[0]][
"n"] = trim($rec[1]);
74 $this->dat[$rec[0]][
"id"] = trim($rec[2]);
75 $this->dat[$rec[0]][
"scd"] = trim($rec[3]);
76 $this->dat[$rec[0]][
"name"] = trim($rec[4]);
77 $this->dat[$rec[0]][
"ymd"] = trim($rec[5]);
78 $this->dat[$rec[0]][
"line"] = trim($rec[6]);
79 $this->dat[$rec[0]][
"debit"] = trim($rec[7]);
80 $this->dat[$rec[0]][
"credit"] = trim($rec[8]);
81 $this->dat[$rec[0]][
"debit_name"] = trim($rec[9]);
82 $this->dat[$rec[0]][
"credit_name"] = trim($rec[10]);
83 $this->dat[$rec[0]][
"debit_account"] = trim($rec[11]);
84 $this->dat[$rec[0]][
"credit_account"] = trim($rec[12]);
85 $this->dat[$rec[0]][
"debit_amount"] = trim($rec[13]);
86 $this->dat[$rec[0]][
"credit_amount"] = trim($rec[14]);
87 $this->dat[$rec[0]][
"amount"] = trim($rec[15]);
88 $this->dat[$rec[0]][
"remarks"] = trim($rec[16]);
89 $this->dat[$rec[0]][
"settled_flg"] = trim($rec[17]);
92 $this->dat[$rec[0]][$data_n][
"n"] = trim($rec[1]);
93 $this->dat[$rec[0]][$data_n][
"id"] = trim($rec[2]);
94 $this->dat[$rec[0]][$data_n][
"scd"] = trim($rec[3]);
95 $this->dat[$rec[0]][$data_n][
"name"] = trim($rec[4]);
96 $this->dat[$rec[0]][$data_n][
"ymd"] = trim($rec[5]);
97 $this->dat[$rec[0]][$data_n][
"line"] = trim($rec[6]);
98 $this->dat[$rec[0]][$data_n][
"debit"] = trim($rec[7]);
99 $this->dat[$rec[0]][$data_n][
"credit"] = trim($rec[8]);
100 $this->dat[$rec[0]][$data_n][
"debit_name"] = trim($rec[9]);
101 $this->dat[$rec[0]][$data_n][
"credit_name"] = trim($rec[10]);
102 $this->dat[$rec[0]][$data_n][
"debit_account"] = trim($rec[11]);
103 $this->dat[$rec[0]][$data_n][
"credit_account"] = trim($rec[12]);
104 $this->dat[$rec[0]][$data_n][
"debit_amount"] = trim($rec[13]);
105 $this->dat[$rec[0]][$data_n][
"credit_amount"] = trim($rec[14]);
106 $this->dat[$rec[0]][$data_n][
"amount"] = trim($rec[15]);
107 $this->dat[$rec[0]][$data_n][
"remark"] = trim($rec[16]);
108 $this->dat[$rec[0]][$data_n][
"settled_flg"] = trim($rec[17]);
119 echo
"\\multicolumn{5}{c}{\\makebox[7.2cm][c]{}} \\\\\n";
122 echo
"\\makebox[2.2cm][l]{\\tt{" . sprintf(
"%06d", $this->dat[
"seq"]) .
"}} & ";
123 echo
"\\makebox[2.2cm][l]{" . $this->
yyyymmdd($this->dat[
"data"][$n][
"ymd"]) .
"} & ";
124 echo
"\\multicolumn{2}{l}{\\makebox[7.2cm][l]{}} & ";
125 echo
"\\makebox[2.2cm][r]{} \\\\\n";
128 echo
"\\makebox[2.2cm][c]{\\bf{金額}} & ";
129 echo
"\\makebox[2.2cm][c]{\\bf{借方科目}} & ";
130 echo
"\\makebox[5.0cm][c]{\\bf{摘 要}} & ";
131 echo
"\\makebox[2.2cm][c]{\\bf{貸方科目}} & ";
132 echo
"\\makebox[2.2cm][c]{\\bf{金額}} \\\\\n";
142 $s = $this->
sum($id, $n);
143 $s[0] = ($s[0] == 0) ?
"" : $this->
amount($s[0]);
144 $s[2] = ($s[2] == 0) ?
"" : $this->
amount($s[2]);
146 echo
"\\makebox[2.2cm][r]{" . $s[0] .
"} & ";
147 echo
"\\multicolumn{3}{c}{\\makebox[9.4cm][c]{\\bf{" . $s[1] .
"}}} & ";
148 echo
"\\makebox[2.2cm][r]{" . $s[2] .
"} \\\\\n";
159 $this->dat[
"seq"] = 0;
160 $this->dat[
"pre_id"] = -1;
168 $d = $this->dat[
"data"];
169 $title = $this->dat[
"title"];
170 $name = $this->dat[
"name"];
171 $era = $this->dat[
"era"];
173 echo
"\\begin{center}\n";
175 echo
"\\begin{tabular}{ccccc}\n";
176 echo
"\\multicolumn{4}{l}{\\makebox[12.5cm][l]{" . $name .
"}} & ";
177 echo
"\\makebox[2.5cm][r]{\\tt{" . $era .
"年度}} \\\\\n";
179 echo
"\\multicolumn{5}{c}{\\makebox[15.0cm][c]{\\Large\\bf{" . $title .
"}}} \\\\\n";
181 echo
"\\multicolumn{5}{l}{\\makebox[15.0cm][c]{}} \\\\\n";
185 $id = $this->dat[
"pre_id"];
186 while ($n <
$cnt && $x < $max) {
187 if ($id != $d[$n][
"id"]) {
189 $x = $this->
footer($x, $id, $n - 1);
191 $x = $this->
header($x, $n);
196 $dn = $d[$n][
"debit_name"];
197 $cn = $d[$n][
"credit_name"];
198 $da = $d[$n][
"debit_amount"];
199 $ca = $d[$n][
"credit_amount"];
200 $itm = $d[$n][
"remark"];
202 $da = ($da == 0) ?
"" : $this->
amount($da);
203 $ca = ($ca == 0) ?
"" : $this->
amount($ca);
205 echo
"\\makebox[2.2cm][r]{" . $da .
"} & ";
206 echo
"\\makebox[2.2cm][c]{" . $dn .
"} & ";
207 echo
"\\makebox[5.0cm][c]{" . $itm .
"} & ";
208 echo
"\\makebox[2.2cm][c]{" . $cn .
"} & ";
209 echo
"\\makebox[2.2cm][r]{" . $ca .
"} \\\\\n";
217 $x = $this->
footer($x, $id, $n - 1);
218 echo
"\\end{tabular}\n";
219 echo
"\\end{center}\n";
221 if ($id != $d[$n][
"id"]) {
222 $x = $this->
footer($x, $id, $n - 1);
224 echo
"\\end{tabular}\n";
225 echo
"\\end{center}\n";
229 $this->dat[
"pre_id"] = $id;
237 echo
"title = " . $this->dat[
"title"] .
"\n\n";
238 echo
"name = " . $this->dat[
"name"] .
"\n\n";
239 echo
"era = " . $this->dat[
"era"] .
"\n\n";
240 echo
"rows = " . $this->dat[
"rows"] .
"\n\n";
242 echo $this->dat[
"field"][
"n"] .
", ".
243 $this->dat[
"field"][
"id"] .
", ".
244 $this->dat[
"field"][
"scd"] .
", ".
245 $this->dat[
"field"][
"name"] .
", ".
246 $this->dat[
"field"][
"ymd"] .
", ".
247 $this->dat[
"field"][
"line"] .
", ".
248 $this->dat[
"field"][
"debit"] .
", ".
249 $this->dat[
"field"][
"credit"] .
", ".
250 $this->dat[
"field"][
"debit_name"] .
", ".
251 $this->dat[
"field"][
"credit_name"] .
", ".
252 $this->dat[
"field"][
"debit_account"] .
", ".
253 $this->dat[
"field"][
"credit_account"] .
", ".
254 $this->dat[
"field"][
"debit_amount"] .
", ".
255 $this->dat[
"field"][
"credit_amount"] .
", ".
256 $this->dat[
"field"][
"amount"] .
", ".
257 $this->dat[
"field"][
"remark"] .
", ".
258 $this->dat[
"field"][
"settled_flg"] .
"\n\n";
260 $cnt = $this->dat[
"rows"];
261 for ($i = 0; $i <
$cnt; $i++) {
262 echo $this->dat[
"data"][$i][
"n"] .
", ".
263 $this->dat[
"data"][$i][
"id"] .
", ".
264 $this->dat[
"data"][$i][
"scd"] .
", ".
265 $this->dat[
"data"][$i][
"name"] .
", ".
266 $this->dat[
"data"][$i][
"ymd"] .
", ".
267 $this->dat[
"data"][$i][
"line"] .
", ".
268 $this->dat[
"data"][$i][
"debit"] .
", ".
269 $this->dat[
"data"][$i][
"credit"] .
", ".
270 $this->dat[
"data"][$i][
"debit_name"] .
", ".
271 $this->dat[
"data"][$i][
"credit_name"] .
", ".
272 $this->dat[
"data"][$i][
"debit_account"] .
", ".
273 $this->dat[
"data"][$i][
"credit_account"] .
", ".
274 $this->dat[
"data"][$i][
"debit_amount"] .
", ".
275 $this->dat[
"data"][$i][
"credit_amount"] .
", ".
276 $this->dat[
"data"][$i][
"amount"] .
", ".
277 $this->dat[
"data"][$i][
"remark"] .
", ".
278 $this->dat[
"data"][$i][
"settled_flg"] .
"\n\n";
291 $this->csvfile = $filename;
292 $this->dat = array();
300 \documentclass[a4j]{jarticle}
302 \usepackage{supertabular}
303 \usepackage{multirow}
316 \def\Hline{\noalign{\hrule height .5mm}}
317 \def\Vline{\vrule width .5mm}
328 $n =
$my->make_a_page($n,
$cnt);