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"]) {
65 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 $r = $d[$i][
"remain"];
76 if ($d[$i][
"division"]) {
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]][
"account_cd"] = trim($rec[4]);
108 $this->dat[$rec[0]][
"name"] = trim($rec[5]);
109 $this->dat[$rec[0]][
"remain"] = trim($rec[6]);
110 $this->dat[$rec[0]][
"division"] = trim($rec[7]);
113 $this->dat[$rec[0]][$data_n][
"n"] = trim($rec[1]);
114 $this->dat[$rec[0]][$data_n][
"m"] = trim($rec[2]);
115 $this->dat[$rec[0]][$data_n][
"mm"] = trim($rec[3]);
116 $this->dat[$rec[0]][$data_n][
"account_cd"] = trim($rec[4]);
117 $this->dat[$rec[0]][$data_n][
"name"] = trim($rec[5]);
118 $this->dat[$rec[0]][$data_n][
"remain"] = trim($rec[6]);
119 $this->dat[$rec[0]][$data_n][
"division"] = trim($rec[7]);
135 $d = $this->dat[
"data"];
136 $title = $this->dat[
"title"];
137 $name = $this->dat[
"name"];
138 $era = $this->dat[
"era"];
139 $bymd = $this->dat[
"bymd"];
142 $inam = $d[$n][
"name"];
144 $yyyy = intval($m / 100);
145 $term = $this->
term($bymd, $yyyy, $mm);
149 $p = $this->
pages($n, $mm);
150 echo
"\\begin{center}\n";
151 echo
"\\begin{tabular}{ccc}\n";
152 echo
"\\multicolumn{2}{l}{\\makebox[12.5cm][l]{" . $name .
"}} & ";
153 echo
"\\makebox[2.5cm][r]{\\tt{" . $era .
"年度}} \\\\\n";
154 echo
"\\makebox[2.5cm][l]{} & ";
155 echo
"\\makebox[10cm][c]{\\bf\\LARGE{" . $title .
"}} & ";
156 echo
"\\makebox[2.5cm][r]{" . $mm .
"月度} \\\\\n";
157 echo
"\\makebox[2.5cm][l]{} & ";
158 echo
"\\makebox[10cm][c]{{\\tt{" . $term0 .
" 〜 " . $term1 .
"}}} & ";
159 echo
"\\makebox[2.5cm][r]{\\tt{" . $p[0] .
"/" . $p[1] .
"}} \\\\\n";
160 echo
"\\end{tabular}\n";
162 echo
"\\begin{center}\n";
163 echo
"\\begin{tabular}{@{\\Vline\\ }c|c|c|c@{\\ \\Vline}}\n";
165 echo
"\\multicolumn{2}{@{\\Vline\\ }c|}{\\makebox[7.4cm][c]{\\bf{費 用}}} & ";
166 echo
"\\multicolumn{2}{c@{\\ \\Vline}}{\\makebox[7.4cm][c]{\\bf{収 益}}} \\\\\n";
180 if (!isset($d[$n][
"mm"])) {
183 }
else if ($month != $d[$n][
"mm"]) {
188 if ($d[$n][
"division"]) {
189 $drec[$n1][1][
"name"] = $d[$n][
"name"];
190 $drec[$n1][1][
"remain"] = $d[$n][
"remain"];
193 $drec[$n0][0][
"name"] = $d[$n][
"name"];
194 $drec[$n0][0][
"remain"] = $d[$n][
"remain"];
201 $nmax = max($n0, $n1);
202 for ($i = 0; $i < $nmax; $i++) {
204 $dn = $drec[$i][0][
"name"];
205 $dr = $this->
amount($drec[$i][0][
"remain"]);
212 $cn = $drec[$i][1][
"name"];
213 $cr = $this->
amount($drec[$i][1][
"remain"]);
219 echo
"\\makebox[3.7cm][l]{" . $dn .
"} & ";
220 echo
"\\makebox[3.7cm][r]{" . $dr .
"} & ";
221 echo
"\\makebox[3.7cm][l]{" . $cn .
"} & ";
222 echo
"\\makebox[3.7cm][r]{" . $cr .
"} \\\\\n";
226 $s = $this->
sum($mm);
231 $dr = ($dr == 0) ?
"" : $this->
amount($dr);
232 $cr = ($cr == 0) ?
"" : $this->
amount($cr);
235 echo
"\\makebox[3.7cm][c]{\bf{合 計}} & ";
236 echo
"\\makebox[3.7cm][r]{" . $dr .
"} & ";
237 echo
"\\makebox[3.7cm][c]{\bf{合 計}} & ";
238 echo
"\\makebox[3.7cm][r]{" . $cr .
"} \\\\\n";
242 echo
"\\end{tabular}\n";
243 echo
"\\end{center}\n";
252 echo
"title = " . $this->dat[
"title"] .
"\n\n";
253 echo
"name = " . $this->dat[
"name"] .
"\n\n";
254 echo
"era = " . $this->dat[
"era"] .
"\n\n";
255 echo
"bymd = " . $this->dat[
"bymd"] .
"\n\n";
256 echo
"rows = " . $this->dat[
"rows"] .
"\n\n";
258 echo $this->dat[
"field"][
"n"] .
", " .
259 $this->dat[
"field"][
"m"] .
", " .
260 $this->dat[
"field"][
"mm"] .
", " .
261 $this->dat[
"field"][
"account_cd"] .
", " .
262 $this->dat[
"field"][
"name"] .
", " .
263 $this->dat[
"field"][
"remain"] .
", " .
264 $this->dat[
"field"][
"division"] .
"\n\n";
266 $cnt = $this->dat[
"rows"];
267 for ($i = 0; $i <
$cnt; $i++) {
268 echo $this->dat[
"data"][$i][
"n"] .
", " .
269 $this->dat[
"data"][$i][
"m"] .
", " .
270 $this->dat[
"data"][$i][
"mm"] .
", " .
271 $this->dat[
"data"][$i][
"account_cd"] .
", " .
272 $this->dat[
"data"][$i][
"name"] .
", " .
273 $this->dat[
"data"][$i][
"remain"] .
", " .
274 $this->dat[
"data"][$i][
"division"] .
"\n\n";
287 $this->csvfile = $filename;
288 $this->dat = array();
296 \documentclass[a4j]{jarticle}
298 \usepackage{supertabular}
299 \usepackage{multirow}
312 \def\Hline{\noalign{\hrule height .5mm}}
313 \def\Vline{\vrule width .5mm}
324 $n =
$my->make_a_page($n);