8 require_once(dirname(__FILE__) .
'/../../lib/Model.php');
25 $sql =
"SELECT `last` FROM `w_calc` WHERE `bid` = '" . $this->
esc($this->bid) .
"'";
30 return (empty($rec[0][
'last'])) ?
'' : $rec[0][
'last'];
53 }
catch(Exception $e) {
54 $err = $e->getMessage();
73 $qry =
"DELETE FROM `" . $tableName .
"`"
74 .
" WHERE `bid` = '" . $this->
esc($this->bid) .
"'"
76 $ans = $this->
query($qry);
77 }
catch(Exception $e) {
110 }
catch(Exception $e) {
119 $qry =
"INSERT INTO `w_slip`"
121 .
" `j`.`bid`" .
" AS `bid`,"
122 .
" `j`.`id`" .
" AS `id`,"
123 .
" `j`.`scd`" .
" AS `scd`,"
124 .
" `j`.`ymd`" .
" AS `ymd`,"
125 .
" `s`.`line`" .
" AS `line`,"
126 .
" `s`.`debit`" .
" AS `debit`,"
127 .
" `s`.`credit`" .
" AS `credit`,"
128 .
" `i1`.`name`" .
" AS `debit_name`,"
129 .
" `i2`.`name`" .
" AS `credit_name`,"
130 .
" CAST(TRUNCATE(`s`.`debit` / 100, 0) AS SIGNED)" .
" AS `debit_account`,"
131 .
" CAST(TRUNCATE(`s`.`credit` / 100, 0) AS SIGNED)" .
" AS `credit_account`,"
133 .
" WHEN `s`.`debit` = 0 THEN 0 ELSE `s`.`amount`"
134 .
" END " .
" AS `debit_amount`,"
136 .
" WHEN `s`.`credit` = 0 THEN 0 ELSE `s`.`amount`"
137 .
" END " .
" AS `credit_amount`,"
138 .
" `s`.`amount`" .
" AS `amount`,"
139 .
" `s`.`remark`" .
" AS `remark`,"
140 .
" `j`.`settled_flg`" .
" AS `settled_flg`"
143 .
" INNER JOIN `t_jslip` `s`"
144 .
" ON `j`.`id` = `s`.`jid`"
146 .
" (SELECT `kcd`, `name` FROM `t_item` WHERE `bid` = '" . $this->
esc($this->bid) .
"') `i1`"
147 .
" ON `i1`.`kcd` = `s`.`debit`"
149 .
" (SELECT `kcd`, `name` FROM `t_item` WHERE `bid` = '" . $this->
esc($this->bid) .
"') `i2`"
150 .
" ON `i2`.`kcd` = `s`.`credit`"
152 .
" (`j`.`bid` = '" . $this->
esc($this->bid) .
"')"
153 .
" AND (`j`.`not_use_flg` IS FALSE)"
155 .
" `j`.`id`, `s`.`line`"
158 $ans = $this->
query($qry);
160 }
catch(Exception $e) {
169 $qry =
"INSERT INTO `w_account`"
171 .
" `i`.`bid`" .
" AS `bid`,"
172 .
" `i`.`ccd`" .
" AS `ccd`,"
173 .
" `i`.`account`" .
" AS `account`,"
174 .
" `i`.`item`" .
" AS `item`,"
175 .
" CAST(TRUNCATE(`i`.`kcd` / 100, 0) AS SIGNED)" .
" AS `account_cd`,"
176 .
" `i`.`kcd`" .
" AS `item_cd`,"
177 .
" `a`.`item_ccd`" .
" AS `account_ccd`,"
178 .
" `a`.`division`" .
" AS `division`"
181 .
" INNER JOIN `t_account` `a`"
182 .
" ON `i`.`account` = `a`.`item` AND `i`.`ccd` = `a`.`ccd`"
184 .
" `i`.`bid` = '" . $this->
esc($this->bid) .
"' AND"
185 .
" `a`.`bid` = '" . $this->
esc($this->bid) .
"'"
188 $ans = $this->
query($qry);
190 }
catch(Exception $e) {
199 $qry =
"INSERT INTO `w_item`"
205 .
" `s`.`bid`" .
" AS `bid`,"
206 .
" `s`.`debit`" .
" AS `item`,"
207 .
" `s`.`debit_account`" .
" AS `account`,"
208 .
" `a`.`account_ccd`" .
" AS `ccd`,"
209 .
" `a`.`division`" .
" AS `division`"
212 .
" INNER JOIN `w_account` `a`"
213 .
" ON `s`.`debit` = `a`.`item_cd`"
215 .
" (`s`.`bid` = '" . $this->
esc($this->bid) .
"') AND"
216 .
" (`a`.`bid` = '" . $this->
esc($this->bid) .
"') AND"
217 .
" (`s`.`debit` != 0) AND"
218 .
" (`a`.`account_ccd` NOT BETWEEN 11 AND 14)"
220 .
" `s`.`bid`, `s`.`debit`, `s`.`debit_account`, `a`.`account_ccd`, `a`.`division`"
227 .
" `s`.`bid`" .
" AS `bid`,"
228 .
" `s`.`credit`" .
" AS `item`,"
229 .
" `s`.`credit_account`" .
" AS `account`,"
230 .
" `a`.`account_ccd`" .
" AS `ccd`,"
231 .
" `a`.`division`" .
" AS `division`"
234 .
" INNER JOIN `w_account` `a`"
235 .
" ON `s`.`credit` = `a`.`item_cd`"
237 .
" (`s`.`bid` = '" . $this->
esc($this->bid) .
"') AND"
238 .
" (`a`.`bid` = '" . $this->
esc($this->bid) .
"') AND"
239 .
" (`s`.`credit` != 0) AND"
240 .
" (`a`.`account_ccd` NOT BETWEEN 11 AND 14)"
242 .
" `s`.`bid`, `s`.`credit`, `s`.`credit_account`, `a`.`account_ccd`, `a`.`division`"
248 $ans = $this->
query($qry);
250 }
catch(Exception $e) {
259 $qry =
"INSERT INTO `w_ledger` ("
278 .
"'" . $this->
esc(
$dat[
'bid']) .
"'"
279 .
", '" . $this->
esc(
$dat[
'account']) .
"'"
280 .
", '" . $this->
esc(
$dat[
'typ']) .
"'"
281 .
", '" . $this->
esc(
$dat[
'item']) .
"'"
282 .
", '" . $this->
esc(
$dat[
'ymd']) .
"'"
283 .
", '" . $this->
esc(
$dat[
'id']) .
"'"
284 .
", '" . $this->
esc(
$dat[
'line']) .
"'"
285 .
", '" . $this->
esc(
$dat[
'm']) .
"'"
286 .
", '" . $this->
esc(
$dat[
'other']) .
"'"
287 .
", '" . $this->
esc(
$dat[
'memo']) .
"'"
288 .
", '" . $this->
esc(
$dat[
'settled_flg']) .
"'"
289 .
", '" . $this->
esc(
$dat[
'amount']) .
"'"
290 .
", '" . $this->
esc(
$dat[
'amount0']) .
"'"
291 .
", '" . $this->
esc(
$dat[
'amount1']) .
"'"
292 .
", '" . $this->
esc(
$dat[
'remain']) .
"'"
293 .
", '" . $this->
esc(
$dat[
'division']) .
"'"
294 .
", '" . $this->
esc(
$dat[
'mmdd']) .
"'"
297 $ans = $this->
query($qry);
299 }
catch(Exception $e) {
309 $qry =
"INSERT INTO `w_ledger`"
315 .
" `s1`.`bid`" .
" AS `bid`,"
316 .
" `i1`.`account`" .
" AS `account`,"
317 .
" 1" .
" AS `typ`,"
318 .
" `s1`.`debit`" .
" AS `item`,"
319 .
" `s1`.`ymd`" .
" AS `ymd`,"
320 .
" `s1`.`id`" .
" AS `id`,"
321 .
" `s1`.`line`" .
" AS `line`,"
323 .
" `s1`.`credit`" .
" AS `other`,"
324 .
" `s1`.`remark`" .
" AS `memo`,"
325 .
" `s1`.`settled_flg`" .
" AS `settled_flg`,"
326 .
" `s1`.`amount`" .
" AS `amount`,"
327 .
" 0" .
" AS `amount0`,"
328 .
" 0" .
" AS `amount1`,"
329 .
" 0" .
" AS `remain`,"
330 .
" `i1`.`division`" .
" AS `division`,"
331 .
" ''" .
" AS `mmdd`"
334 .
" LEFT JOIN `w_item` `i1`"
335 .
" ON `s1`.`debit` = `i1`.`item`"
337 .
" `s1`.`bid` = '" . $this->
esc($this->bid) .
"' AND"
338 .
" `i1`.`bid` = '" . $this->
esc($this->bid) .
"' AND"
339 .
" `s1`.`settled_flg` > -1"
346 .
" `s2`.`bid`" .
" AS `bid`,"
347 .
" `i2`.`account`" .
" AS `account`,"
348 .
" 2" .
" AS `typ`,"
349 .
" `s2`.`credit`" .
" AS `item`,"
350 .
" `s2`.`ymd`" .
" AS `ymd`,"
351 .
" `s2`.`id`" .
" AS `id`,"
352 .
" `s2`.`line`" .
" AS `line`,"
354 .
" `s2`.`debit`" .
" AS `other`,"
355 .
" `s2`.`remark`" .
" AS `memo`,"
356 .
" `s2`.`settled_flg`" .
" AS `settled_flg`,"
357 .
" `s2`.`amount`" .
" AS `amount`,"
358 .
" 0" .
" AS `amount0`,"
359 .
" 0" .
" AS `amount1`,"
360 .
" 0" .
" AS `remain`,"
361 .
" `i2`.`division`" .
" AS `division`,"
362 .
" ''" .
" AS `mmdd`"
365 .
" LEFT JOIN `w_item` `i2`"
366 .
" ON `s2`.`credit` = `i2`.`item`"
368 .
" `s2`.`bid` = '" . $this->
esc($this->bid) .
"' AND"
369 .
" `i2`.`bid` = '" . $this->
esc($this->bid) .
"' AND"
370 .
" `s2`.`settled_flg` > -1"
373 .
" `account`, `item`, `ymd`, `id`, `line`, `typ`"
376 $ans = $this->
query($qry);
382 .
" `bid` = '" . $this->
esc($this->bid) .
"' AND"
383 .
" `settled_flg` < 0"
387 $qry =
"SELECT `bid`, `item`, `account`, `ccd`, `division`"
389 .
" WHERE `bid` = '" . $this->
esc($this->bid) .
"'"
390 .
" ORDER BY `account`"
393 $cnt = (empty($rec)) ? 0 : count($rec);
397 $ymd = explode(
'-', $this->basic[
'term_begin']);
401 for ($i = 0; $i <
$cnt; $i++) {
402 for ($j = 0; $j < 12; $j++) {
404 ? date(
'Y/m/d', mktime(0, 0, 0, $m + $j - 12, $d, $y + 1))
405 : date(
'Y/m/d', mktime(0, 0, 0, $m + $j, $d, $y))
407 $memo = ($j == 0) ?
'前期繰越' :
'前月繰越';
410 foreach ($znk as $z) {
412 if ($z[
'credit'] == 0) {
426 if ($itm == $rec[$i][
'item']) {
432 if ($memo ==
'前期繰越' && $zflg ==
true) {
433 $r[$n][
'typ'] = $typ;
434 $r[$n][
'item'] = $itm;
435 $r[$n][
'settled_flg'] = -1;
436 $r[$n][
'amount'] = $amt;
437 $r[$n][
'amount0'] = $am0;
438 $r[$n][
'amount1'] = $am1;
441 $r[$n][
'item'] = $rec[$i][
'item'];
442 $r[$n][
'settled_flg'] = 0;
443 $r[$n][
'amount'] = 0;
444 $r[$n][
'amount0'] = 0;
445 $r[$n][
'amount1'] = 0;
449 $r[$n][
'account'] = $rec[$i][
'account'];
457 $r[$n][
'memo'] = $memo;
462 $r[$n][
'remain'] = 0;
463 $r[$n][
'division'] = $rec[$i][
'division'];
469 for ($i = 0; $i < $n; $i++) {
473 }
catch(Exception $e) {
504 .
" `bid` = '" . $this->
esc($this->bid) .
"' AND"
505 .
" (`item` != 0 OR `item` IS NULL) AND"
506 .
" `ymd` BETWEEN '" . $this->
esc($this->basic[
'term_begin']) .
"' AND '" . $this->
esc($this->basic[
'term_end']) .
"'"
508 .
" `account`, `item`, `ymd`, `id`, `line`"
511 $cnt = (empty($rec)) ? 0 : count($rec);
515 for ($i = 0; $i <
$cnt; $i++) {
516 switch ($rec[$i][
'typ'] ) {
517 case 1: $rec[$i][
'amount0'] = $rec[$i][
'amount'];
break;
518 case 2: $rec[$i][
'amount1'] = $rec[$i][
'amount'];
break;
521 if ($rec[$i][
'item'] != $k) {
522 $k = $rec[$i][
'item'];
526 switch ($rec[$i][
'division']) {
527 case 0: $z += $rec[$i][
'amount0'] - $rec[$i][
'amount1'];
break;
528 case 1: $z += $rec[$i][
'amount1'] - $rec[$i][
'amount0'];
break;
531 $rec[$i][
'remain'] = $z;
533 $a = explode(
'-', $rec[$i][
'ymd']);
535 $rec[$i][
'm'] = intval($a[0] . $a[1]);
536 $rec[$i][
'mmdd'] = $a[1] .
'/' . $a[2];
540 for ($i =
$cnt - 1; $i >= 0; $i--) {
541 switch ($rec[$i][
'memo']) {
546 if ($t != $rec[$i][
'mmdd'])
547 $t = $rec[$i][
'mmdd'];
549 $rec[$i][
'remain'] = 0;
555 for ($i = 0; $i <
$cnt; $i++) {
556 $ymd = $rec[$i][
'ymd'];
557 $a = explode(
'-', $ymd);
561 $rec[$i][
'mmdd'] = $a[1] .
'/' . $a[2];
563 $rec[$i][
'mmdd'] =
'〃';
567 $qry =
"DELETE FROM `w_ledger` WHERE `bid` = '" . $this->
esc($this->bid) .
"'";
568 $ans = $this->
query($qry);
570 for ($i = 0; $i <
$cnt; $i++) {
571 if ($rec[$i][
'ymd'] >= $this->basic[
'term_begin']) {
576 }
catch(Exception $e) {
586 $qry =
"INSERT INTO `w_aicd`"
588 .
" '" . $this->
esc($this->bid) .
"' AS `bid`"
589 .
", `c1`, 0 AS `c2`, 0 AS `c3`, 0 AS `c4`, `c1` * 1000 AS `ctg`, 0 AS `div`, `name`"
592 .
" '" . $this->
esc($this->bid) .
"' AS `bid`"
593 .
", `c1`, `c2`, 0 AS `c3`, 0 AS `c4`, `c1` * 1000 + `c2` * 100 AS `ctg`, 0 AS `div`, `name`"
596 .
" '" . $this->
esc($this->bid) .
"' AS `bid`"
597 .
", `c1`, `c2`, `c3`, 0 AS `c4`, `c1` * 1000 + `c2` * 100 + `c3` * 10 AS `ctg`, `div`, `name`"
600 .
" '" . $this->
esc($this->bid) .
"' AS `bid`"
601 .
", `c1`, `c2`, `c3`, `c4`, `c1` * 1000 + `c2` * 100 + `c3` * 10 + `c4` AS `ctg`, 0 AS `div`, `name`"
604 $ans = $this->
query($qry);
607 $qry =
"INSERT INTO `w_tb_a`"
609 .
" `l`.`bid` AS `bid`"
610 .
", `l`.`item` AS `item`"
612 .
", `i`.`name` AS `name`"
613 .
", `l`.`remain` AS `remain`"
615 .
" WHEN `l`.`division` = 0 THEN `l`.`remain` ELSE 0"
616 .
" END AS `debit_amount`"
618 .
" WHEN `l`.`division` = 1 THEN `l`.`remain` ELSE 0"
619 .
" END AS `credit_amount`"
620 .
", `l`.`division` AS `division`"
622 .
" `w_ledger` `l` INNER JOIN `t_item` `i` ON `l`.`item` = `i`.`kcd`"
624 .
" `l`.`bid` = '" . $this->
esc($this->bid) .
"' AND"
625 .
" `i`.`bid` = '" . $this->
esc($this->bid) .
"' AND"
626 .
" ((`l`.`memo` = '前期繰越') OR (`l`.`memo` = '前月繰越'))"
628 .
" `l`.`item`, `l`.`m`"
630 $ans = $this->
query($qry);
633 $qry =
"INSERT INTO `w_tb_b`"
635 .
" `a`.`bid` AS `bid`"
636 .
", `a`.`item` AS `item`"
638 .
", SUM(`a`.`debit_sum`) AS `debit_sum`"
639 .
", SUM(`a`.`credit_sum`) AS `credit_sum`"
646 .
" WHEN SUM(`amount0`) IS NULL"
648 .
" ELSE SUM(`amount0`)"
649 .
" END AS `debit_sum`"
651 .
" WHEN SUM(`amount1`) IS NULL"
653 .
" ELSE SUM(`amount1`)"
654 .
" END AS `credit_sum`"
658 .
" `bid` = '" . $this->
esc($this->bid) .
"' AND"
659 .
" `settled_flg` > -1"
661 .
" `bid`, `item`, `m`"
662 .
" UNION SELECT DISTINCT"
666 .
", 0 AS `debit_sum`"
667 .
", 0 AS `credit_sum`"
671 .
" `bid` = '" . $this->
esc($this->bid) .
"' AND"
672 .
" `settled_flg` < 0"
674 .
" `bid`, `item`, `m`"
677 .
" `a`.`bid`, `a`.`item`, `a`.`m`"
679 .
" `a`.`item`, `a`.`m`"
681 $ans = $this->
query($qry);
684 $qry =
"INSERT INTO `w_tb_c`"
686 .
" `a`.`bid` AS `bid`"
687 .
", `a`.`item` AS `item`"
689 .
", `a`.`name` AS `name`"
690 .
", `a`.`debit_amount` AS `debit_amount`"
691 .
", `a`.`credit_amount` AS `credit_amount`"
692 .
", `a`.`division` AS `division`"
694 .
" WHEN `b`.`debit_sum` IS NULL"
696 .
" ELSE `b`.`debit_sum`"
697 .
" END AS `debit_sum`"
699 .
" WHEN `b`.`credit_sum` IS NULL"
701 .
" ELSE `b`.`credit_sum`"
702 .
" END AS `credit_sum`"
704 .
" WHEN `a`.`division` = 0"
705 .
" THEN (`a`.`debit_amount` - `a`.`credit_amount`) + (`b`.`debit_sum` - `b`.`credit_sum`)"
706 .
" ELSE (`a`.`credit_amount` - `a`.`debit_amount` ) + (`b`.`credit_sum` - `b`.`debit_sum` )"
708 .
", CAST(TRUNCATE(`a`.`item` / 100000, 0) AS SIGNED) * 10 AS `ctg3`"
709 .
", CAST(TRUNCATE(`a`.`item` / 10000, 0) AS SIGNED) AS `ctg4`"
711 .
" `w_tb_a` `a` LEFT JOIN `w_tb_b` `b` ON (`a`.`item` = `b`.`item` AND `a`.`m` = `b`.`m`)"
713 .
" `a`.`bid` = '" . $this->
esc($this->bid) .
"' AND"
714 .
" `b`.`bid` = '" . $this->
esc($this->bid) .
"'"
716 .
" `a`.`item`, `a`.`m`"
718 $ans = $this->
query($qry);
721 $qry =
"INSERT INTO `w_tb_rslt1`"
723 .
" `c`.`bid` AS `bid`"
725 .
", `c`.`item` AS `item`"
727 .
" WHEN `c`.`division` = 0 THEN `c`.`remain` ELSE 0"
728 .
" END AS `debit_remain`"
729 .
", `c`.`debit_sum` AS `debit_sum`"
730 .
", `c`.`name` AS `name`"
731 .
", `c`.`credit_sum` AS `credit_sum`"
733 .
" WHEN `c`.`division` = 0 THEN 0 ELSE `c`.`remain`"
734 .
" END AS `credit_remain`"
735 .
", `c`.`m` % 100 AS `mm`"
736 .
", `c`.`division` AS `division`"
737 .
", `i`.`div` AS `ctg_div`"
738 .
", CAST(TRUNCATE(`c`.`ctg3` / 1000, 0) AS SIGNED) * 1000 AS `ctg1`"
739 .
", CAST(TRUNCATE(`c`.`ctg3` / 100, 0) AS SIGNED) * 100 AS `ctg2`"
740 .
", `c`.`ctg3` AS `ctg3`"
741 .
", `c`.`ctg4` AS `ctg4`"
742 .
", CAST(TRUNCATE(`c`.`item` / 100, 0) AS SIGNED) % 100 AS `ctg5`"
744 .
" `w_tb_c` `c` INNER JOIN `w_aicd` `i` ON `c`.`ctg3` = `i`.`ctg`"
746 .
" `c`.`bid` = '" . $this->
esc($this->bid) .
"' AND"
747 .
" `i`.`bid` = '" . $this->
esc($this->bid) .
"'"
749 .
" `c`.`m`, `c`.`item`"
751 $ans = $this->
query($qry);
754 $qry =
"INSERT INTO `w_tb_rslt2`"
759 .
", `ctg4` AS `ccd`"
760 .
", `ctg5` AS `item`"
761 .
", `division` AS `division`"
762 .
", `ctg_div` AS `ctg_div`"
763 .
", SUM(`debit_remain`) AS `debit_remain`"
764 .
", SUM(`debit_sum`) AS `debit_sum`"
765 .
", SUM(`credit_sum`) AS `credit_sum`"
766 .
", SUM(`credit_remain`) AS `credit_remain`"
770 .
" `bid` = '" . $this->
esc($this->bid) .
"'"
772 .
" `bid`, `m`, `mm`, `ctg4`, `ctg5`, `division`, `ctg_div`"
774 .
" `bid`, `m`, `ctg4`, `ctg5`"
776 $ans = $this->
query($qry);
778 }
catch(Exception $e) {
788 $qry =
"INSERT INTO `w_sa_a`"
794 .
", `item` AS `item`"
795 .
", `debit_remain` AS `debit_remain`"
796 .
", `credit_remain` AS `credit_remain`"
797 .
", CASE WHEN `ctg_div` = 1 THEN `debit_remain` ELSE 0 END AS `bsd`"
798 .
", CASE WHEN `ctg_div` = 1 THEN `credit_remain` ELSE 0 END AS `bsc`"
799 .
", CASE WHEN `ctg_div` = 2 THEN `debit_remain` ELSE 0 END AS `pld`"
800 .
", CASE WHEN `ctg_div` = 2 THEN `credit_remain` ELSE 0 END AS `plc`"
801 .
", CASE WHEN `ccd` = 9910 THEN `debit_remain` ELSE 0 END AS `cod`"
802 .
", CASE WHEN `ccd` = 9910 THEN `credit_remain` ELSE 0 END AS `coc`"
806 .
" bid = '" . $this->
esc($this->bid) .
"'"
808 $ans = $this->
query($qry);
811 $qry =
"INSERT INTO `w_sa_b`"
816 .
", SUM(`debit_remain`) AS `debit_remain`"
817 .
", SUM(`credit_remain`) AS `credit_remain`"
818 .
", SUM(`bsd`) AS `bsd`"
819 .
", SUM(`bsc`) AS `bsc`"
820 .
", SUM(`pld`) AS `pld`"
821 .
", SUM(`plc`) AS `plc`"
822 .
", SUM(`cod`) AS `cod`"
823 .
", SUM(`coc`) AS `coc`"
827 .
" `bid` = '" . $this->
esc($this->bid) .
"'"
829 .
" `bid`, `m`, `mm`"
833 $ans = $this->
query($qry);
836 $qry =
"INSERT INTO `w_sa_c`"
841 .
", '当期利益' AS `name`"
842 .
", `plc` - `pld` AS `remain`"
843 .
", 999999 AS `account_cd`"
847 .
" `bid` = '" . $this->
esc($this->bid) .
"'"
851 $ans = $this->
query($qry);
854 $qry =
"INSERT INTO `w_sa_d`"
856 .
" `t`.`bid` AS `bid`"
858 .
", `t`.`mm` AS `mm`"
859 .
", `a`.`name` AS `name`"
860 .
", `t`.`debit_remain` AS `remain`"
861 .
", `t`.`ccd` * 100 + `t`.`item` AS `account_cd`"
863 .
" `w_tb_rslt2` `t`"
864 .
" INNER JOIN `t_account` `a`"
865 .
" ON `t`.`ccd` = `a`.`ccd` AND `t`.`item` = `a`.`item`"
867 .
" `t`.`bid` = '" . $this->
esc($this->bid) .
"' AND"
868 .
" `a`.`bid` = '" . $this->
esc($this->bid) .
"' AND"
869 .
" `t`.`ctg_div` = 1 AND"
870 .
" `t`.`division` = 0"
872 .
"`m`, `t`.`ccd`, `t`.`item`"
874 $ans = $this->
query($qry);
877 $qry =
"INSERT INTO `w_sa_e`"
879 .
" `t`.`bid` AS `bid`"
881 .
", `t`.`mm` AS `mm`"
882 .
", `a`.`name` AS `name`"
883 .
", `t`.`credit_remain` AS `remain`"
884 .
", `t`.`ccd` * 100 + `t`.`item` AS `account_cd`"
886 .
" `w_tb_rslt2` `t`"
887 .
" INNER JOIN `t_account` `a`"
888 .
" ON `t`.`ccd` = `a`.`ccd` AND `t`.`item` = `a`.`item`"
890 .
" `t`.`bid` = '" . $this->
esc($this->bid) .
"' AND"
891 .
" `a`.`bid` = '" . $this->
esc($this->bid) .
"' AND"
892 .
" `t`.`ctg_div` = 1 AND"
893 .
" `t`.`division` = 1"
895 .
" `t`.`m`, `t`.`ccd`, `t`.`item`"
897 $ans = $this->
query($qry);
900 $qry =
"INSERT INTO `w_sa_f`"
902 .
" `t`.`bid` AS `bid`"
904 .
", `t`.`mm` AS `mm`"
905 .
", `a`.`name` AS `name`"
906 .
", `t`.`debit_remain` AS `remain`"
907 .
", `t`.`ccd` * 100 + `t`.`item` AS `account_cd`"
909 .
" `w_tb_rslt2` `t`"
910 .
" INNER JOIN `t_account` `a`"
911 .
" ON `t`.`ccd` = `a`.`ccd` AND `t`.`item` = `a`.`item`"
913 .
" `t`.`bid` = '" . $this->
esc($this->bid) .
"' AND"
914 .
" `a`.`bid` = '" . $this->
esc($this->bid) .
"' AND"
915 .
" `t`.`ctg_div` = 2 AND"
916 .
" `t`.`division` = 0"
918 .
" `t`.`m`, `t`.`ccd`, `t`.`item`"
920 $ans = $this->
query($qry);
923 $qry =
"INSERT INTO `w_sa_g`"
925 .
" `t`.`bid` AS `bid`"
927 .
", `t`.`mm` AS `mm`"
928 .
", `a`.`name` AS `name`"
929 .
", `t`.`credit_remain` AS `remain`"
930 .
", `t`.`ccd` * 100 + `t`.`item` AS `account_cd`"
932 .
" `w_tb_rslt2` `t`"
933 .
" INNER JOIN `t_account` `a`"
934 .
" ON `t`.`ccd` = `a`.`ccd` AND `t`.`item` = `a`.`item`"
936 .
" `t`.`bid` = '" . $this->
esc($this->bid) .
"' AND"
937 .
" `a`.`bid` = '" . $this->
esc($this->bid) .
"' AND"
938 .
" `t`.`ctg_div` = 2 AND"
939 .
" `t`.`division` = 1"
941 .
"`t`.`m`, `t`.`ccd`, `t`.`item`"
943 $ans = $this->
query($qry);
946 $qry =
"INSERT INTO `w_sa_h`"
948 .
" `t`.`bid` AS `bid`"
950 .
", `t`.`mm` AS `mm`"
951 .
", `a`.`name` AS `name`"
952 .
", `t`.`debit_remain` AS `remain`"
953 .
", `t`.`ccd` * 100 + `t`.`item` AS `account_cd`"
955 .
" `w_tb_rslt2` `t`"
956 .
" INNER JOIN `t_account` `a`"
957 .
" ON `t`.`ccd` = `a`.`ccd` AND `t`.`item` = `a`.`item`"
959 .
" `t`.`bid` = '" . $this->
esc($this->bid) .
"' AND"
960 .
" `a`.`bid` = '" . $this->
esc($this->bid) .
"' AND"
961 .
" `t`.`ctg_div` = 2 AND"
962 .
" `t`.`division` = 0"
964 .
"`t`.`m`, `t`.`ccd`, `t`.`item`"
966 $ans = $this->
query($qry);
969 $qry =
"INSERT INTO `w_sa_rslt`"
970 .
" SELECT *, 1 AS `ctg_div`, 0 AS `division` FROM `w_sa_d`"
971 .
" WHERE `bid` = '" . $this->
esc($this->bid) .
"'"
972 .
" UNION SELECT *, 1 AS `ctg_div`, 1 AS `division` FROM `w_sa_e`"
973 .
" WHERE `bid` = '" . $this->
esc($this->bid) .
"'"
974 .
" UNION SELECT *, 1 AS `ctg_div`, 1 AS `division` FROM `w_sa_c`"
975 .
" WHERE `bid` = '" . $this->
esc($this->bid) .
"'"
976 .
" UNION SELECT *, 2 AS `ctg_div`, 0 AS `division` FROM `w_sa_c`"
977 .
" WHERE `bid` = '" . $this->
esc($this->bid) .
"'"
978 .
" UNION SELECT *, 2 AS `ctg_div`, 0 AS `division` FROM `w_sa_f`"
979 .
" WHERE `bid` = '" . $this->
esc($this->bid) .
"'"
980 .
" UNION SELECT *, 2 AS `ctg_div`, 1 AS `division` FROM `w_sa_g`"
981 .
" WHERE `bid` = '" . $this->
esc($this->bid) .
"'"
982 .
" UNION SELECT *, 2 AS `ctg_div`, 0 AS `division` FROM `w_sa_h`"
983 .
" WHERE `bid` = '" . $this->
esc($this->bid) .
"'"
985 $ans = $this->
query($qry);
988 $qry =
"INSERT INTO `w_sa_bsd`"
990 .
" FROM `w_sa_rslt`"
992 .
" `bid` = '" . $this->
esc($this->bid) .
"' AND"
993 .
" `ctg_div` = 1 AND"
996 .
" `bid`, `m`, `account_cd`"
998 $ans = $this->
query($qry);
1001 $qry =
"INSERT INTO `w_sa_bsc`"
1003 .
" FROM `w_sa_rslt`"
1005 .
" `bid` = '" . $this->
esc($this->bid) .
"' AND"
1006 .
" `ctg_div` = 1 AND"
1009 .
" `bid`, `m`, `account_cd`"
1011 $ans = $this->
query($qry);
1014 $qry =
"INSERT INTO `w_sa_pld`"
1016 .
" FROM `w_sa_rslt`"
1018 .
" `bid` = '" . $this->
esc($this->bid) .
"' AND"
1019 .
" `ctg_div` = 2 AND"
1022 .
" bid, m, account_cd"
1024 $ans = $this->
query($qry);
1027 $qry =
"INSERT INTO `w_sa_plc`"
1031 .
" bid = '" . $this->
esc($this->bid) .
"' AND"
1032 .
" ctg_div = 2 AND"
1035 .
" bid, m, account_cd"
1037 $ans = $this->
query($qry);
1040 $qry =
"INSERT INTO `w_efy`"
1041 .
" SELECT `bid`, MAX(m) AS `m`"
1042 .
" FROM `w_sa_rslt`"
1043 .
" WHERE `bid` = '" . $this->
esc($this->bid) .
"'"
1046 $ans = $this->
query($qry);
1049 $qry =
"INSERT INTO `w_calc` ("
1053 .
"'" . $this->
esc($this->bid) .
"'"
1054 .
", '" . date(
'Y-m-d H:i:s') .
"'"
1057 $ans = $this->
query($qry);
1059 }
catch(Exception $e) {
1067 $name =
$basic[
'disp_name'];
1068 $era =
$basic[
'era'][
'abbr'];
1069 $tsv =
"title\t仕訳帳\n"
1070 .
"name\t" . $name .
"\n"
1071 .
"era\t" . $era .
"\n"
1072 .
"field\t連番\t伝票番号\t部門ID\t部門名\t参考\t伝票日付\t行番号\t借方科目\t貸方科目\t借方科目名\t貸方科目名\t借方勘定科目\t貸方勘定科目\t借方金額\t貸方金額\t金額\t摘要\t備考\t決算フラグ\n"
1073 .
"rows\t" .
$cnt .
"\n"
1076 for ($i = 0; $i <
$cnt; $i++)
1080 . $this->
texStr($rec[$i][
'id']) .
"\t"
1081 . $this->
texStr($rec[$i][
'scd']) .
"\t"
1082 . $this->
texStr($rec[$i][
'name']) .
"\t"
1083 . $this->
texStr($rec[$i][
'ymd']) .
"\t"
1084 . $this->
texStr($rec[$i][
'line']) .
"\t"
1085 . $this->
texStr($rec[$i][
'debit']) .
"\t"
1086 . $this->
texStr($rec[$i][
'credit']) .
"\t"
1087 . $this->
texStr($rec[$i][
'debit_name']) .
"\t"
1088 . $this->
texStr($rec[$i][
'credit_name']) .
"\t"
1089 . $this->
texStr($rec[$i][
'debit_account']) .
"\t"
1090 . $this->
texStr($rec[$i][
'credit_account']) .
"\t"
1091 . $this->
texStr($rec[$i][
'debit_amount']) .
"\t"
1092 . $this->
texStr($rec[$i][
'credit_amount']) .
"\t"
1093 . $this->
texStr($rec[$i][
'amount']) .
"\t"
1094 . $this->
texStr($rec[$i][
'remark']) .
"\t"
1095 . $this->
texStr($rec[$i][
'settled_flg']) .
"\n"
1099 file_put_contents($tsvfn, $tsv);
1107 `sl`.`id` AS `id`, -- 伝票番号
1108 `sl`.`scd` AS `scd`, -- 部門ID
1109 `se`.`name` AS `name`, -- 部門名
1110 `sl`.`ymd` AS `ymd`, -- 伝票日付
1111 `sl`.`line` AS `line`, -- 行番号
1112 `sl`.`debit` AS `debit`, -- 借方科目
1113 `sl`.`credit` AS `credit`, -- 貸方科目
1114 `sl`.`debit_name` AS `debit_name`, -- 借方科目名
1115 `sl`.`credit_name` AS `credit_name`, -- 貸方科目名
1116 `sl`.`debit_account` AS `debit_account`, -- 借方勘定科目
1117 `sl`.`credit_account` AS `credit_account`, -- 貸方勘定科目
1118 `sl`.`debit_amount` AS `debit_amount`, -- 借方金額
1119 `sl`.`credit_amount` AS `credit_amount`, -- 貸方金額
1120 `sl`.`amount` AS `amount`, -- 金額
1121 `sl`.`remark` AS `remark`, -- 摘要
1122 `sl`.`settled_flg` AS `settled_flg` -- 決算フラグ
1125 INNER JOIN `t_section` `se` ON `sl`.`scd` = `se`.`id`
1127 `sl`.`bid` = '%s' AND `se`.`bid` = '%s'
1129 `sl`.`ymd`, `sl`.`scd`, `sl`.`id`, `sl`.`line`
1131 $sql = sprintf($fmt, $this->
esc($this->bid), $this->
esc($this->bid), $this->
esc($this->bid));
1141 $name =
$basic[
'disp_name'];
1142 $era =
$basic[
'era'][
'abbr'];
1143 $tsv =
"title\t総勘定元帳\n"
1144 .
"name\t" . $name .
"\n"
1145 .
"era\t" . $era .
"\n"
1146 .
"field\t連番\t年月度\t日付\t摘要\t科目\t相手方科目\t借方\t貸方\t差引残高\t科目名\n"
1147 .
"rows\t" .
$cnt .
"\n"
1150 for ($i = 0; $i <
$cnt; $i++)
1154 . $this->
texStr($rec[$i][
'm']) .
"\t"
1155 . $this->
texStr($rec[$i][
'mmdd']) .
"\t"
1156 . $this->
texStr($rec[$i][
'memo']) .
"\t"
1157 . $this->
texStr($rec[$i][
'item']) .
"\t"
1158 . $this->
texStr($rec[$i][
'other']) .
"\t"
1159 . $this->
texStr($rec[$i][
'amount0']) .
"\t"
1160 . $this->
texStr($rec[$i][
'amount1']) .
"\t"
1161 . $this->
texStr($rec[$i][
'remain']) .
"\t"
1162 . $this->
texStr($rec[$i][
'name']) .
"\n"
1166 file_put_contents($tsvfn, $tsv);
1174 `l`.`m` AS `m`, -- 年月度
1175 `l`.`mmdd` AS `mmdd`, -- 日付
1176 `l`.`memo` AS `memo`, -- 摘要
1177 `l`.`item` AS `item`, -- 科目
1178 `l`.`other` AS `other`, -- 相手方科目
1179 `l`.`amount0` AS `amount0`, -- 借方
1180 `l`.`amount1` AS `amount1`, -- 貸方
1181 `l`.`remain` AS `remain`, -- 差引残高
1182 `i`.`name` AS `name` -- 科目名
1184 `w_ledger` `l` INNER JOIN `t_item` `i` ON `l`.`item` = `i`.`kcd`
1186 `l`.`bid` = '%s' AND `i`.`bid` = '%s'
1188 `l`.`item`, `l`.`ymd`, `l`.`other`
1190 $sql = sprintf($fmt, $this->
esc($this->bid), $this->
esc($this->bid));
1200 $name =
$basic[
'disp_name'];
1201 $era =
$basic[
'era'][
'abbr'];
1202 $bymd = str_replace(
'-',
'',
$basic[
'term_begin']);
1203 $tsv =
"title\t試算表(詳細)\n"
1204 .
"name\t" . $name .
"\n"
1205 .
"era\t" . $era .
"\n"
1206 .
"bymd\t" . $bymd .
"\n"
1207 .
"field\t連番\t年月度\t月度\t勘定分類コード\t貸借区分\t勘定科目コード\t借方残高\t借方月度合計\t個別科目名\t貸方月度合計\t貸方残高\n"
1208 .
"rows\t" .
$cnt .
"\n"
1211 for ($i = 0; $i <
$cnt; $i++)
1215 . $this->
texStr($rec[$i][
'm']) .
"\t"
1216 . $this->
texStr($rec[$i][
'mm']) .
"\t"
1217 . $this->
texStr($rec[$i][
'ctg_div']) .
"\t"
1218 . $this->
texStr($rec[$i][
'division']) .
"\t"
1219 . $this->
texStr($rec[$i][
'item']) .
"\t"
1220 . $this->
texStr($rec[$i][
'debit_remain']) .
"\t"
1221 . $this->
texStr($rec[$i][
'debit_sum']) .
"\t"
1222 . $this->
texStr($rec[$i][
'name']) .
"\t"
1223 . $this->
texStr($rec[$i][
'credit_sum']) .
"\t"
1224 . $this->
texStr($rec[$i][
'credit_remain']) .
"\n"
1228 file_put_contents($tsvfn, $tsv);
1238 `ctg_div`, -- 勘定分類コード
1241 `debit_remain`, -- 借方残高
1242 `debit_sum`, -- 借方月度合計
1244 `credit_sum`, -- 貸方月度合計
1245 `credit_remain` -- 貸方残高
1251 `m`, `ctg_div`, `item`
1253 $sql = sprintf($fmt, $this->
esc($this->bid));
1263 $name =
$basic[
'disp_name'];
1264 $era =
$basic[
'era'][
'abbr'];
1265 $bymd = str_replace(
'-',
'',
$basic[
'term_begin']);
1267 $tsv =
"title\t試算表\n"
1268 .
"name\t" . $name .
"\n"
1269 .
"era\t" . $era .
"\n"
1270 .
"bymd\t" . $bymd .
"\n"
1271 .
"field\t連番\t年月度\t月度\t勘定分類コード\t貸借区分\t分類コード\t勘定科目\t借方残高\t借方月度合計\t個別科目名\t貸方月度合計\t貸方残高\n"
1272 .
"rows\t" .
$cnt .
"\n"
1275 for ($i = 0; $i <
$cnt; $i++)
1279 . $this->
texStr($rec[$i][
'm']) .
"\t"
1280 . $this->
texStr($rec[$i][
'mm']) .
"\t"
1281 . $this->
texStr($rec[$i][
'ctg_div']) .
"\t"
1282 . $this->
texStr($rec[$i][
'division']) .
"\t"
1283 . $this->
texStr($rec[$i][
'ccd']) .
"\t"
1284 . $this->
texStr($rec[$i][
'item']) .
"\t"
1285 . $this->
texStr($rec[$i][
'debit_remain']) .
"\t"
1286 . $this->
texStr($rec[$i][
'debit_sum']) .
"\t"
1287 . $this->
texStr($rec[$i][
'name']) .
"\t"
1288 . $this->
texStr($rec[$i][
'credit_sum']) .
"\t"
1289 . $this->
texStr($rec[$i][
'credit_remain']) .
"\n"
1293 file_put_contents($tsvfn, $tsv);
1303 `t`.`ctg_div`, -- 勘定分類コード
1304 `t`.`division`, -- 貸借区分
1307 `t`.`debit_remain`, -- 借方残高
1308 `t`.`debit_sum`, -- 借方月度合計
1309 `a`.`name`, -- 個別科目名
1310 `t`.`credit_sum`, -- 貸方月度合計
1311 `t`.`credit_remain` -- 貸方残高
1314 INNER JOIN `t_account` `a`
1315 ON `t`.`ccd` = `a`.`ccd` AND `t`.`item` = `a`.`item`
1317 `t`.`bid` = '%s' AND `a`.`bid` = '%s'
1319 `t`.`m`, `t`.`ctg_div`, `t`.`ccd`
1322 $sql = sprintf($fmt, $this->
esc($this->bid), $this->
esc($this->bid));
1332 $name =
$basic[
'disp_name'];
1333 $era =
$basic[
'era'][
'abbr'];
1334 $bymd = str_replace(
'-',
'',
$basic[
'term_begin']);
1336 $tsv =
"title\t損益計算書\n"
1337 .
"name\t" . $name .
"\n"
1338 .
"era\t" . $era .
"\n"
1339 .
"bymd\t" . $bymd .
"\n"
1340 .
"field\t連番\t年月度\t月度\t勘定科目コード\t勘定科目名\t残高\t範疇\n"
1341 .
"rows\t" .
$cnt .
"\n"
1344 for ($i = 0; $i <
$cnt; $i++)
1348 . $this->
texStr($rec[$i][
'm']) .
"\t"
1349 . $this->
texStr($rec[$i][
'mm']) .
"\t"
1350 . $this->
texStr($rec[$i][
'account_cd']) .
"\t"
1351 . $this->
texStr($rec[$i][
'name']) .
"\t"
1352 . $this->
texStr($rec[$i][
'remain']) .
"\t"
1353 . $this->
texStr($rec[$i][
'division']) .
"\n"
1357 file_put_contents($tsvfn, $tsv);
1367 `account_cd`, -- 勘定科目コード
1374 `bid` = '%s' AND `ctg_div` = 2
1379 $sql = sprintf($fmt, $this->
esc($this->bid));
1389 $name =
$basic[
'disp_name'];
1390 $era =
$basic[
'era'][
'abbr'];
1391 $bymd = str_replace(
'-',
'',
$basic[
'term_begin']);
1393 $tsv =
"title\t貸借対照表\n"
1394 .
"name\t" . $name .
"\n"
1395 .
"era\t" . $era .
"\n"
1396 .
"bymd\t" . $bymd .
"\n"
1397 .
"field\t連番\t年月度\t月度\t勘定科目コード\t勘定科目名\t残高\t範疇\n"
1398 .
"rows\t" .
$cnt .
"\n"
1401 for ($i = 0; $i <
$cnt; $i++)
1405 . $this->
texStr($rec[$i][
'm']) .
"\t"
1406 . $this->
texStr($rec[$i][
'mm']) .
"\t"
1407 . $this->
texStr($rec[$i][
'account_cd']) .
"\t"
1408 . $this->
texStr($rec[$i][
'name']) .
"\t"
1409 . $this->
texStr($rec[$i][
'remain']) .
"\t"
1410 . $this->
texStr($rec[$i][
'division']) .
"\n"
1414 file_put_contents($tsvfn, $tsv);
1424 `account_cd`, -- 勘定科目コード
1431 `bid` = '%s' AND `ctg_div` = 1
1436 $sql = sprintf($fmt, $this->
esc($this->bid));
1447 $name =
$basic[
'disp_name'];
1448 $era =
$basic[
'era'][
'abbr'];
1449 $bymd = str_replace(
'-',
'',
$basic[
'term_begin']);
1450 $ty =
$basic[
'term_year'];
1458 $tsv =
"title\t損益計算書(決算)\n"
1459 .
"name\t" . $name .
"\n"
1460 .
"era\t" . $era .
"\n"
1461 .
"bymd\t" . $bymd .
"\n"
1462 .
"ty\t" . $ty .
"\n"
1463 .
"bps\t" . $bps .
"\n"
1464 .
"eps\t" . $eps .
"\n"
1465 .
"bgs\t" . $bgs .
"\n"
1466 .
"egs\t" . $egs .
"\n"
1467 .
"pcost\t" . $pcost .
"\n"
1468 .
"field\t連番\t年月度\t月度\t勘定科目コード\t勘定科目名\t残高\t範疇\n"
1469 .
"rows\t" .
$cnt .
"\n"
1472 for ($i = 0; $i <
$cnt; $i++)
1476 . $this->
texStr($rec[$i][
'm']) .
"\t"
1477 . $this->
texStr($rec[$i][
'mm']) .
"\t"
1478 . $this->
texStr($rec[$i][
'account_cd']) .
"\t"
1479 . $this->
texStr($rec[$i][
'name']) .
"\t"
1480 . $this->
texStr($rec[$i][
'remain']) .
"\t"
1481 . $this->
texStr($rec[$i][
'division']) .
"\n"
1485 file_put_contents($tsvfn, $tsv);
1496 `account_cd`, -- 勘定科目コード
1505 `m` = (SELECT MAX(`m`) FROM `w_sa_rslt` WHERE `bid` = '%s')
1510 $sql = sprintf($fmt, $this->
esc($this->bid), $this->
esc($this->bid));
1526 INNER JOIN `t_jslip` `s` ON `j`.`id` = `s`.`jid`
1528 `j`.`bid` = '%s' AND
1529 `j`.`not_use_flg` IS FALSE AND
1530 `s`.`debit` = (SELECT `kcd` FROM `t_item` WHERE `bid` = '%s' AND `name` = '期首製品棚卸高')
1533 $sql = sprintf($fmt, $this->
esc($this->bid), $this->
esc($this->bid));
1541 $ans = $rec[0][
'amount'];
1556 INNER JOIN `t_jslip` `s` ON `j`.`id` = `s`.`jid`
1558 `j`.`bid` = '%s' AND
1559 `j`.`not_use_flg` IS FALSE AND
1560 `s`.`credit` = (SELECT `kcd` FROM `t_item` WHERE `bid` = '%s' AND `name` = '期末製品棚卸高')
1563 $sql = sprintf($fmt, $this->
esc($this->bid), $this->
esc($this->bid));
1571 $ans = $rec[0][
'amount'];
1586 INNER JOIN `t_jslip` `s` ON `j`.`id` = `s`.`jid`
1588 `j`.`bid` = '%s' AND
1589 `j`.`not_use_flg` IS FALSE AND
1590 `s`.`debit` = (SELECT `kcd` FROM `t_item` WHERE `bid` = '%s' AND `name` = '期首商品棚卸高')
1593 $sql = sprintf($fmt, $this->
esc($this->bid), $this->
esc($this->bid));
1601 $ans = $rec[0][
'amount'];
1616 INNER JOIN `t_jslip` `s` ON `j`.`id` = `s`.`jid`
1618 `j`.`bid` = '%s' AND
1619 `j`.`not_use_flg` IS FALSE AND
1620 `s`.`credit` = (SELECT `kcd` FROM `t_item` WHERE `bid` = %s AND `name` = '期末商品棚卸高')
1623 $sql = sprintf($fmt, $this->
esc($this->bid), $this->
esc($this->bid));
1631 $ans = $rec[0][
'amount'];
1642 for ($i = 0; $i <
$cnt; $i++)
1643 if (substr($rec[$i][
"account_cd"], 0, 4) ==
"8230")
1644 $ans = $rec[$i][
"remain"];
1653 $name =
$basic[
'disp_name'];
1654 $era =
$basic[
'era'][
'abbr'];
1655 $bymd = str_replace(
'-',
'',
$basic[
'term_begin']);
1656 $ty =
$basic[
'term_year'];
1664 $tsv =
"title\t貸借対照表(決算)\n"
1665 .
"name\t" . $name .
"\n"
1666 .
"era\t" . $era .
"\n"
1667 .
"bymd\t" . $bymd .
"\n"
1668 .
"ty\t" . $ty .
"\n"
1669 .
"tax1\t" . $tax1 .
"\n"
1670 .
"tax2\t" . $tax2 .
"\n"
1671 .
"pprof\t" . $pprof .
"\n"
1672 .
"ploss\t" . $ploss .
"\n"
1673 .
"profit\t" . $profit .
"\n"
1674 .
"field\t連番\t年月度\t月度\t勘定科目コード\t勘定科目名\t残高\t範疇\n"
1675 .
"rows\t" .
$cnt .
"\n"
1678 for ($i = 0; $i <
$cnt; $i++)
1682 . $this->
texStr($rec[$i][
'm']) .
"\t"
1683 . $this->
texStr($rec[$i][
'mm']) .
"\t"
1684 . $this->
texStr($rec[$i][
'account_cd']) .
"\t"
1685 . $this->
texStr($rec[$i][
'name']) .
"\t"
1686 . $this->
texStr($rec[$i][
'remain']) .
"\t"
1687 . $this->
texStr($rec[$i][
'division']) .
"\n"
1691 file_put_contents($tsvfn, $tsv);
1702 `account_cd`, -- 勘定科目コード
1711 `m` = (SELECT MAX(`m`) FROM `w_sa_rslt` WHERE `bid` = '%s')
1716 $sql = sprintf($fmt, $this->
esc($this->bid), $this->
esc($this->bid));
1732 INNER JOIN `t_jslip` `s` ON `j`.`id` = `s`.`jid`
1734 `j`.`bid` = '%s' AND
1735 `j`.`not_use_flg` IS FALSE AND
1736 `s`.`debit` = (SELECT `kcd` FROM `t_item` WHERE `bid` = '%s' AND `name` = '未払法人税等')
1739 $sql = sprintf($fmt, $this->
esc($this->bid), $this->
esc($this->bid));
1747 $ans = $rec[0][
'amount'];
1762 INNER JOIN `t_jslip` `s` ON `j`.`id` = `s`.`jid`
1764 `j`.`bid` = '%s' AND
1765 `j`.`not_use_flg` IS FALSE AND
1766 `s`.`debit` = (SELECT `kcd` FROM `t_item` WHERE `bid` = '%s' AND `name` = '未払消費税')
1769 $sql = sprintf($fmt, $this->
esc($this->bid), $this->
esc($this->bid));
1777 $ans = $rec[0][
'amount'];
1792 INNER JOIN `t_jslip` `s` ON `j`.`id` = `s`.`jid`
1794 `j`.`bid` = '%s' AND
1795 `j`.`not_use_flg` IS FALSE AND
1796 `s`.`credit` = (SELECT `kcd` FROM `t_item` WHERE `bid` = '%s' AND `name` = '前期繰越利益')
1799 $sql = sprintf($fmt, $this->
esc($this->bid), $this->
esc($this->bid));
1807 $ans = $rec[0][
'amount'];
1822 INNER JOIN `t_jslip` `s` ON `j`.`id` = `s`.`jid`
1824 `j`.`bid` = '%s' AND
1825 `j`.`not_use_flg` IS FALSE AND
1826 `s`.`credit` = (SELECT `kcd` FROM `t_item` WHERE `bid` = '%s' AND `name` = '前期繰越損失')
1829 $sql = sprintf($fmt, $this->
esc($this->bid), $this->
esc($this->bid));
1837 $ans = $rec[0][
'amount'];
1847 for ($i = 0; $i <
$cnt; $i++)
1848 if ($rec[$i][
'name'] ==
'当期利益')
1849 $ans = $rec[$i][
'remain'];