3 * @link https://datagram.co.jp/source/bksj for the canonical source repository
4 * @copyright Copyright (c) 2006-2019 Datagram Ltd. (https://datagram.co.jp)
5 * @license https://datagram.co.jp/source/bksj/license.txt
12 $basic = $ctrl->basic;
17 $jid = $view->str($dat['journal']['id']);
18 $scd = $view->str($dat['journal']['scd']);
19 $ymd = $view->str(str_replace('-', '/', $dat['journal']['ymd']));
20 $settled_flg = $view->str($dat['journal']['settled_flg']);
21 $not_use_flg = $view->str($dat['journal']['not_use_flg']);
25 $lines = count($slip);
28 $insert = ($mode == 'edit') ? 0 : 1;
29 $title = ($mode == 'edit') ? '編集' : '複製';
31 <script type="text/javascript">
51 sname: ['50音順', '使用順'],
52 sundry: '<?= $sundry ?>',
58 gotoNext: function(func, act) {
69 val['jid'] = $('#jid').val();
70 val['ymd'] = $('#ymd').val();
72 $('select').each(function(){
73 s = $(this).attr('id');
75 val[s] = $('#' + s).val();
79 $('input[type="hidden"]').each(function(){
80 s = $(this).attr('id');
83 v = '#v_' + a[1] + '_valid';
84 if ($(v).val() == 1) {
85 val[s] = $('#' + s).val();
90 $('input[type="text"]').each(function(){
91 s = $(this).attr('id');
94 v = '#v_' + a[1] + '_valid';
95 if ($(v).val() == 1) {
96 val[s] = $('#' + s).val();
106 for (var i in this.val) {
107 alert(i + ' = ' + this.val[i]);
113 var itm = (this.sid == 0) ? '#item_name' : '#item_time';
115 var debs = 's_' + id + '_deb_name';
116 var debo = 'o_' + id + '_deb_name';
117 var debv = 'v_' + id + '_deb_name';
118 $('#' + debs).html($(itm).html());
119 $('#' + debs + ' select').attr('id', debo);
120 $('#' + debo).attr('onchange', "return my.selChg(" + id + ", 'deb');");
121 $('#' + debo).val($('#' + debv).val());
123 var cres = 's_' + id + '_cre_name';
124 var creo = 'o_' + id + '_cre_name';
125 var crev = 'v_' + id + '_cre_name';
126 $('#' + cres).html($(itm).html());
127 $('#' + cres + ' select').attr('id', creo);
128 $('#' + creo).attr('onchange', "return my.selChg(" + id + ", 'cre');");
129 $('#' + creo).val($('#' + crev).val());
132 selChg: function(id, w) {
133 var o = '#o_' + id + '_' + w + '_name';
134 var v = '#v_' + id + '_' + w + '_name';
139 if (k == this.sundry) {
140 $('#v_' + id + '_' + w + '_amount').val(0);
151 for (var i = 1; i <= this.max; i++) {
152 if ($('#v_' + i + '_valid').val() > 0) {
153 d = $('#v_' + i + '_deb_amount').val();
154 c = $('#v_' + i + '_cre_amount').val();
155 deb += d.replace(/,/g, '') * 1;
156 cre += c.replace(/,/g, '') * 1;
160 $('#v_deb_sum').val(deb);
161 $('#v_cre_sum').val(cre);
164 chgAmount: function(id, w) {
167 var debv = '#v_' + id + '_deb_amount';
168 var crev = '#v_' + id + '_cre_amount';
178 for (var i = 1; i <= this.max; i++) {
180 if ($('#v_' + i + '_valid').val() > 0) {
181 if ($('#v_' + i + '_deb_name').val() == this.sundry) {
182 $('#v_' + i + '_deb_amount').val(0);
184 if ($('#v_' + i + '_cre_name').val() == this.sundry) {
185 $('#v_' + i + '_cre_amount').val(0);
193 chkTax: function(id) {
195 var v = $('#' + id).val();
206 'func': 'UserJournal',
208 'bid': '<?= $bid ?>',
214 $('#modalTaxBody').html(data);
217 $('#modalTaxBody').html('error');
220 $('#modalTax').modal();
225 $('#v_' + i + '_valid').val(1);
226 $('#r_' + i).css('visibility', 'visible');
231 if (this.last >= this.max) {
232 alert('これ以上追加できません。');
238 this.using(this.last);
241 drop: function(seq) {
243 if (this.lines < 2) {
244 alert('これ以上削除できません。');
248 if (!confirm('行番号' + seq + 'を削除しますか?')) {
254 $('#v_' + seq + '_valid').val(0);
255 $('#r_' + seq).css('visibility', 'collapse');
260 this.sid = ++this.sid % 2;
261 this.sort1.html(this.sname[this.sid]);
262 this.sort2.html(this.sname[this.sid]);
264 for (var i = 1; i <= this.max; i++) {
265 if ($('#v_' + i + '_valid').val() > 0) {
271 check: function(arg) {
278 'func': 'UserJournal',
280 'insert': <?= $insert ?>,
281 'bid': '<?= $bid ?>',
287 this.ans = {"sts": "OK", "err": ""};
290 this.ans = {"sts": "NG", "err": "ajax error"};
305 for (var i = 1; i <= this.max; i++) {
306 if ($('#v_' + i + '_valid').val() > 0) {
309 v[i]['deb_amount'] = this.val[n + 'deb_amount'];
310 v[i]['deb_name'] = this.val[n + 'deb_name'];
311 v[i]['remark'] = this.val[n + 'remark'];
312 v[i]['cre_name'] = this.val[n + 'cre_name'];
313 v[i]['cre_amount'] = this.val[n + 'cre_amount'];
318 'jid': this.val['jid'],
319 'scd': this.val['scd'],
320 'ymd': this.val['ymd'],
321 'settled_flg': this.val['settled_flg'],
322 'not_use_flg': this.val['not_use_flg'],
326 if (!confirm("登録しますか?")) {
330 if (this.check(arg) == 'NG') {
332 for (var i in this.ans.err) {
333 msg += this.ans.err[i] + '<br>';
336 this.errmsg.html(msg);
345 'func': 'UserJournal',
347 'insert': <?= $insert ?>,
348 'bid': '<?= $bid ?>',
354 eval("this.ans = " + data);
357 this.ans = {"sts": "NG", "err": "ajax error"};
360 if (this.ans.sts == 'NG') {
361 this.errmsg.html(this.ans.err);
365 this.gotoNext('UserJournal', 'remember');
371 this.errmsg = $('#errmsg');
372 this.next = $('#next');
373 this.func = $('#func');
374 this.act = $('#act');
375 this.jid = $('#jid');
376 this.scd = $('#scd');
377 this.ymd = $('#ymd');
378 this.settled_flg = $('#settled_flg');
379 this.not_use_flg = $('#not_use_flg');
380 this.sort1 = $('#sort1');
381 this.sort2 = $('#sort2');
383 this.ymd.datepicker();
385 this.sort1.html(this.sname[this.sid]);
386 this.sort2.html(this.sname[this.sid]);
388 for (var i = 1; i <= this.lines; i++) {
400 <form method="post" name="next" id="next" action="<?= $base ?>">
401 <input type="hidden" name="func" id="func">
402 <input type="hidden" name="act" id="act">
405 <div id="item_name" style="visibility: hidden;">
407 <option value="-1"> </option>
410 foreach ($item['name'] as $k => $d) {
411 $p = mb_substr($d['kana'], 0, 1);
416 echo '<optgroup label="' . $p . '">';
419 echo '<option value="' . $view->str($k) . '">' . $view->str($d['name']) , '</option>';
428 <div id="item_time" style="visibility: hidden;">
430 <option value="-1"> </option>
432 foreach ($item['time'] as $k => $d) {
433 echo '<option value="' . $view->str($k) . '">' . $view->str($d) . '</option>';
439 <table id="my_header" width="100%">
442 <a onclick="return my.gotoNext('UserMenu', '');">メニュー</a>
443 > <a onclick="return my.gotoNext('UserJournal', 'remember');">仕訳帳</a>
444 > <?= $title ?>
446 <td style="text-align: right;">
447 <button type="button" class="my_magenta" style="width: 120px;" onclick="return my.gotoNext('Login', '');">ログアウト</button>
451 <td colspan="2" style="text-align: center;">
452 <?= $view->strBasic($basic) ?>
457 <div style="height: 5px;"> </div>
462 <table class="my_table" width="100%">
464 <th class="my_border">仕訳帳・<?= $title ?></th>
468 <div style="height: 1px;"> </div><hr>
475 <td style="padding: 8px;">
476 <button type="button" class="my_cyan" style="width: 100px;" onclick="return my.regist();">登録</button>
478 <td style="width: 80px;"> </td>
480 <button type="button" class="my_magenta" style="width: 100px;" onclick="return my.gotoNext('UserJournal', 'remember');">戻る</button>
488 <div style="height: 1px;"> </div><hr>
492 <td><div id="errmsg" class="my_red"></div></td>
496 <table class="my_list" width="100%">
508 <td style="text-align: center;">
510 $mnam = ($mode == 'edit') ? $jid : '新番号';
511 $mjid = ($mode == 'edit') ? $jid : '-1';
513 <?= $mnam ?><input id="jid" type="hidden" value="<?= $mjid ?>">
515 <td style="text-align: center;">
518 foreach ($sect as $k => $d) {
519 $slct = ($k == $scd) ? ' selected' : '';
520 echo '<option value="' . $view->str($k) . '"' . $slct . '>' . $view->str($d) . '</option>';
525 <td style="text-align: center;">
526 <input id="ymd" size="10" style="text-align: center;" type="text" value="<?= $ymd ?>">
528 <td style="text-align: center;">
529 <select id="settled_flg">
531 foreach ($stld as $k => $d) {
532 $slct = ($k == $settled_flg) ? ' selected' : '';
533 echo '<option value="' . $view->str($k) . '"' . $slct . '>' . $view->str($d) . '</option>';
538 <td style="text-align: center;">
539 <select id="not_use_flg">
541 $nuflg = (empty($not_use_flg)) ? ['', ' selected'] : [' selected', ''];
543 <option value="1"<?= $nuflg[0] ?>>不使用伝票</option>
544 <option value="0"<?= $nuflg[1] ?>>使用伝票</option>
551 <div style="height: 4px;"> </div>
552 <!-- <button type="button" class="my_magenta" onclick="return my.debug();">debug</button> -->
557 <table class="my_list">
564 <button type="button" class="my_th" onclick="return my.sort();">
565 <div id="sort1"></div>
571 <button type="button" class="my_th" onclick="return my.sort();">
572 <div id="sort2"></div>
583 for ($i = 0; $i < $max; $i++) {
587 if (empty($slip[$i])) {
594 $amount = (int)$slip[$i]['amount'];
595 $debit = $view->str($slip[$i]['debit']);
596 $credit = $view->str($slip[$i]['credit']);
597 $remark = $view->str($slip[$i]['remark']);
598 $damnt = ($debit == $sundry) ? 0 : $amount;
599 $camnt = ($credit == $sundry) ? 0 : $amount;
605 <tr id="r_<?= $seq ?>" style="visibility: collapse;">
606 <td style="text-align: right;">
609 <td style="text-align: center;">
610 <input id="v_<?= $seq ?>_deb_amount" size="10" style="text-align: right;" type="text" value="<?= $damnt ?>" onchange="return my.chgAmount('<?= $seq ?>', 'deb')" ondblclick="my.chkTax('v_<?= $seq ?>_deb_amount')">
612 <td style="text-align: center;">
613 <input id="v_<?= $seq ?>_deb_name" type="hidden" value="<?= $debit ?>">
614 <div id="s_<?= $seq ?>_deb_name"> </div>
616 <td style="text-align: center;">
617 <input id="v_<?= $seq ?>_remark" size="40" type="text" value="<?= $remark ?>">
619 <td style="text-align: center;">
620 <input id="v_<?= $seq ?>_cre_name" type="hidden" value="<?= $credit ?>">
621 <div id="s_<?= $seq ?>_cre_name"> </div>
623 <td style="text-align: center;">
624 <input id="v_<?= $seq ?>_cre_amount" size="10" style="text-align: right;" type="text" value="<?= $camnt ?>" onchange="return my.chgAmount('<?= $seq ?>', 'cre')" ondblclick="my.chkTax('v_<?= $seq ?>_cre_amount')">
626 <td style="text-align: center;">
627 <input id="v_<?= $seq ?>_valid" type="hidden" value="0">
628 <button type="button" class="my_magenta" onclick="return my.drop(<?= $seq ?>);">削除</button>
636 <button type="button" class="my_th" onclick="return my.plus();">+</button>
638 <td style="text-align: center;">
639 <input id="v_deb_sum" size="10" style="text-align: right;" type="text" value="<?= $sdamnt ?>">
641 <th colspan="3" style="text-align: center;">合計</th>
642 <td style="text-align: center;">
643 <input id="v_cre_sum" size="10" style="text-align: right;" type="text" value="<?= $scamnt ?>">
657 <!-- モーダルダイアログ Tax -->
658 <div class="modal" id="modalTax" tabindex="-1" role="dialog" aria-labelledby="staticModalLabel" aria-hidden="true" data-show="true" data-keyboard="false" data-backdrop="static">
659 <div class="modal-dialog">
660 <div class="modal-content">
661 <div class="modal-header">
662 <button type="button" class="close" data-dismiss="modal">
663 <span aria-hidden="true">×</span>
665 <h4 class="modal-tax-title">消費税</h4>
667 <div class="modal-body">
668 <div id="modalTaxBody"></div>
670 <div class="modal-footer">
671 <button type="button" class="my_magenta" data-dismiss="modal">閉じる</button>