JSlip  1.0
user_journal_list.tmplt
Go to the documentation of this file.
1 <?php
2 /**
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
6  */
7 
8 $view = $ctrl->view;
9 $bid = $ctrl->bid;
10 $basic = $ctrl->basic;
11 $kcd = $ctrl->kcd;
12 $section = $ctrl->section;
13 $settled = $ctrl->settled;
14 $begin = $ctrl->begin;
15 $end = $ctrl->end;
16 $cnd = $ctrl->dat['cnd'];
17 $list = $ctrl->dat['list'];
18 $limit = $ctrl->dat['limit'];
19 ?>
20 <script type="text/javascript">
21 
22  var my = {
23 
24  next: null,
25  func: null,
26  act: null,
27  id: null,
28  cnd_scd: null,
29  cnd_begin: null,
30  cnd_end: null,
31  cnd_denpyo: null,
32  cnd_kcd: null,
33  cnd_remark: null,
34  cnd_stflg: null,
35  cnd_nuflg: null,
36  page_curr: null,
37  v_cnd_scd: null,
38  v_cnd_begin: null,
39  v_cnd_end: null,
40  v_cnd_denpyo: null,
41  v_cnd_kcd: null,
42  v_cnd_remark: null,
43  v_cnd_stflg: null,
44  v_cnd_nuflg: null,
45  v_page_curr: null,
46  v_page_last: null,
47 
48  gotoNext: function(func) {
49  this.func.val(func);
50  this.act.val('');
51  this.next.submit();
52  return false;
53  },
54 
55  create: function() {
56  if (this.chk_slip == 'NG') {
57  alert("入力伝票の最大明細数: " + this.max_slip);
58  return false;
59  }
60  this.func.val('UserJournal');
61  this.act.val('create');
62  this.next.submit();
63  return false;
64  },
65 
66  drop: function(dno) {
67 
68  var msg = '';
69 
70  if (!confirm("伝票番号[" + dno + "] を削除しますか?")) {
71  return false;
72  }
73 
74  $.ajax({
75  url: '<?= $base ?>',
76  type: 'post',
77  async: false,
78  data: {
79  'func': 'UserJournal',
80  'act': 'drop',
81  'dno': dno,
82  'eod': ''
83  }
84  })
85  .done((data) => {
86  eval("this.ans = " + data);
87  })
88  .fail((data) => {
89  this.ans = {"sts": "NG", "err": "ajax error"};
90  });
91 
92  if (this.ans.sts == 'NG') {
93  alert(this.ans.err);
94  return false;
95  }
96 
97  this.gotoNext('UserJournal', 'remember');
98 
99  return false;
100  },
101 
102  edit: function(id) {
103  this.func.val('UserJournal');
104  this.act.val('edit');
105  this.id.val(id);
106  this.next.submit();
107  return false;
108  },
109 
110  duplicate: function(id) {
111  if (this.chk_slip == 'NG') {
112  alert("入力伝票の最大明細数: " + this.max_slip);
113  return false;
114  }
115  this.func.val('UserJournal');
116  this.act.val('duplicate');
117  this.id.val(id);
118  this.next.submit();
119  return false;
120  },
121 
122  move: function(dlt) {
123 
124  var curr = this.v_page_curr.val() * 1;
125  var last = this.v_page_last.val() * 1;
126  var next;
127 
128  switch (dlt) {
129  case -9: next = 1; break;
130  case 9: next = last; break;
131  default: next = curr + dlt; break;
132  }
133 
134  if (next > last) {
135  next = last;
136  }
137 
138  if (next < 1) {
139  next = 1;
140  }
141 
142  this.v_page_curr.val(next);
143  this.search();
144 
145  return false;
146  },
147 
148  search: function() {
149 
150  if (this.v_page_curr.val() < 1) {
151  this.v_page_curr.val(1);
152  }
153 
154  this.func.val('UserJournal');
155  this.act.val('search');
156  this.cnd_scd.val(this.v_cnd_scd.val());
157  this.cnd_begin.val(this.v_cnd_begin.val());
158  this.cnd_end.val(this.v_cnd_end.val());
159  this.cnd_denpyo.val(this.v_cnd_denpyo.val());
160  this.cnd_kcd.val(this.v_cnd_kcd.val());
161  this.cnd_remark.val(this.v_cnd_remark.val());
162  this.cnd_stflg.val(this.v_cnd_stflg.val());
163  this.cnd_nuflg.val(this.v_cnd_nuflg.val());
164 
165  this.page_curr.val(this.v_page_curr.val());
166  this.next.submit();
167  return false;
168  },
169 
170  reset: function() {
171  this.v_cnd_scd.val('-1');
172  this.v_cnd_begin.val('<?= $begin ?>');
173  this.v_cnd_end.val('<?= $end ?>');
174  this.v_cnd_denpyo.val('');
175  this.v_cnd_kcd.val('-1');
176  this.v_cnd_remark.val('');
177  this.v_cnd_stflg.val('-2');
178  this.v_cnd_nuflg.val('-1');
179  this.v_page_curr.val(1);
180  return false;
181  },
182 
183  init: function() {
184  this.chk_slip = '<?= $limit['chk_slip'] ?>';
185  this.max_slip = '<?= $limit['max_slip'] ?>';
186  this.next = $('#next');
187  this.func = $('#func');
188  this.act = $('#act');
189  this.id = $('#id');
190  this.cnd_scd = $('#cnd_scd');
191  this.cnd_begin = $('#cnd_begin');
192  this.cnd_end = $('#cnd_end');
193  this.cnd_denpyo = $('#cnd_denpyo');
194  this.cnd_kcd = $('#cnd_kcd');
195  this.cnd_remark = $('#cnd_remark');
196  this.cnd_stflg = $('#cnd_stflg');
197  this.cnd_nuflg = $('#cnd_nuflg');
198  this.page_curr = $('#page_curr');
199  this.v_cnd_scd = $('#v_cnd_scd');
200  this.v_cnd_begin = $('#v_cnd_begin');
201  this.v_cnd_end = $('#v_cnd_end');
202  this.v_cnd_denpyo = $('#v_cnd_denpyo');
203  this.v_cnd_kcd = $('#v_cnd_kcd');
204  this.v_cnd_remark = $('#v_cnd_remark');
205  this.v_cnd_stflg = $('#v_cnd_stflg');
206  this.v_cnd_nuflg = $('#v_cnd_nuflg');
207  this.v_page_curr = $('#v_page_curr');
208  this.v_page_last = $('#v_page_last');
209 
210  this.v_cnd_begin.datepicker();
211  this.v_cnd_end.datepicker();
212  this.v_cnd_begin.val('<?= $cnd['cnd_begin'] ?>');
213  this.v_cnd_end.val('<?= $cnd['cnd_end'] ?>');
214  }
215  }
216 
217  $(function(){
218  my.init();
219  });
220 
221 </script>
222 
223 <form method="post" name="next" id="next" action="<?= $base ?>">
224  <input type="hidden" name="func" id="func">
225  <input type="hidden" name="act" id="act">
226  <input type="hidden" name="cnd_scd" id="cnd_scd">
227  <input type="hidden" name="cnd_begin" id="cnd_begin">
228  <input type="hidden" name="cnd_end" id="cnd_end">
229  <input type="hidden" name="cnd_denpyo" id="cnd_denpyo">
230  <input type="hidden" name="cnd_kcd" id="cnd_kcd">
231  <input type="hidden" name="cnd_remark" id="cnd_remark">
232  <input type="hidden" name="cnd_stflg" id="cnd_stflg">
233  <input type="hidden" name="cnd_nuflg" id="cnd_nuflg">
234  <input type="hidden" name="page_curr" id="page_curr">
235  <input type="hidden" name="id" id="id">
236  <input type="hidden" name="bid" id="bid" value="<?= $bid ?>">
237 </form>
238 
239 <table id="my_header" width="100%">
240  <tr>
241  <td>
242  &nbsp;<a onclick="return my.gotoNext('UserMenu');">メニュー</a>
243  &nbsp;&gt;&nbsp;仕訳帳
244  </td>
245  <td style="text-align: right;">
246  <button type="button" class="my_magenta" style="width: 120px;" onclick="return my.gotoNext('Login');">ログアウト</button>
247  </td>
248  </tr>
249  <tr>
250  <td colspan="2" style="text-align: center;">
251  <?= $view->strBasic($basic) ?>
252  </td>
253  </tr>
254 </table>
255 
256 <div style="height: 5px;">&nbsp;</div>
257 
258 <table width="100%">
259  <tr>
260  <td align="center">
261  <table class="my_table" width="100%">
262  <tr>
263  <th class="my_border">仕訳帳</th>
264  </tr>
265  </table>
266 
267  <div style="height: 1px;">&nbsp;</div><hr>
268 
269  <table class="my_table" width="100%">
270  <tr>
271  <th colspan="11" class="my_border">絞込み検索</th>
272  </tr>
273  <tr>
274  <td class="my_border" style="text-align: center; width: 110px;" rowspan="2">
275  <table class="my_table" cellpadding="0" cellspacing="2">
276  <tr>
277  <td>
278  <button type="button" class="my_cyan" style="width: 100px;" onclick="return my.search();">検索</button>
279  </td>
280  </tr>
281  <tr>
282  <td>
283  <button type="button" class="my_magenta" style="width: 100px;" onclick="return my.reset();">検索リセット</button>
284  </td>
285  </tr>
286  </table>
287  </td>
288  <th class="my_border">部門</th>
289  <td class="my_border">
290  <select id="v_cnd_scd">
291 <?php
292 $s = ($cnd['cnd_scd'] < 0) ? ' selected' : '';
293 ?>
294  <option value="-1"<?= $s ?>>&nbsp;</option>
295 <?php
296 foreach ($section as $key => $dat) {
297  $k = $view->str($key);
298  $d = $view->str($dat);
299  $s = ($cnd['cnd_scd'] == $k) ? ' selected' : '';
300 ?>
301  <option value="<?= $k ?>"<?= $s ?>><?= $d ?></option>
302 <?php
303 }
304 ?>
305  </select>
306  </td>
307  <th class="my_border" style="width: 100px;">期間</th>
308  <td class="my_border" colspan="3">
309  <input id="v_cnd_begin" type="text">
310  〜
311  <input id="v_cnd_end" type="text">
312  </td>
313  <th class="my_border" style="width: 100px;">伝票番号</th>
314  <td class="my_border">
315  <input id="v_cnd_denpyo" type="text" value="<?= $view->str($cnd['cnd_denpyo']) ?>">
316  </td>
317  </tr>
318  <tr>
319  <th class="my_border">科目</th>
320  <td class="my_border">
321  <select id="v_cnd_kcd">
322 <?php
323 $s = ($cnd['cnd_kcd'] < 0) ? ' selected' : '';
324 ?>
325  <option value="-1"<?= $s ?>>&nbsp;</option>
326 <?php
327 $c = '';
328 foreach ($kcd as $key => $dat) {
329  $k = $view->str($key);
330  $d = $view->str($dat['name']);
331  $s = ($cnd['cnd_kcd'] == $k) ? ' selected' : '';
332  $p = mb_substr($dat['kana'], 0, 1);
333  if ($c != $p) {
334  if ($c != '') {
335  echo '</optgroup>';
336  }
337  echo '<optgroup label="' . $p . '">';
338  $c = $p;
339  }
340 ?>
341  <option value="<?= $k ?>"<?= $s ?>><?= $d ?></option>
342 <?php
343 }
344 if ($c != '') {
345  echo '</optgroup>';
346 }
347 ?>
348  </select>
349  </td>
350  <th class="my_border">摘要</th>
351  <td class="my_border">
352  <input id="v_cnd_remark" type="text" value="<?= $view->str($cnd['cnd_remark']) ?>">
353  </td>
354  <th class="my_border">通常/決算</th>
355  <td class="my_border">
356  <select id="v_cnd_stflg">
357 <?php
358 $s = ($cnd['cnd_stflg'] < 0) ? ' selected' : '';
359 ?>
360  <option value="-2"<?= $s ?>>&nbsp;</option>
361 <?php
362 foreach ($settled as $k => $d) {
363  $s = ($k == $cnd['cnd_stflg']) ? ' selected' : '';
364  echo '<option value="' . $view->str($k) . '"' . $s . '>' . $view->str($d) . '</option>';
365 }
366 ?>
367  </select>
368  </td>
369  <th class="my_border">使用/不使用</th>
370  <td class="my_border">
371  <select id="v_cnd_nuflg">
372 <?php
373 $nu = ['-1' => '', '0' => '使用伝票', '1' => '不使用伝票'];
374 foreach ($nu as $k => $d) {
375  $s = ($k == $cnd['cnd_nuflg']) ? ' selected' : '';
376  echo '<option value="' . $view->str($k) . '"' . $s . '>' . $view->str($d) . '</option>';
377 }
378 ?>
379  </select>
380  </td>
381  </tr>
382  </table>
383 
384  <div style="height: 1px;">&nbsp;</div><hr>
385 
386  <table class="my_table" width="100%">
387  <tr>
388  <td class="my_border" id="my_create">
389  <button type="button" class="my_cyan" style="width: 150px;" onclick="return my.create();">新規伝票作成</button>
390  </td>
391  </tr>
392  </table>
393 
394  <div style="height: 2px;">&nbsp;</div>
395 
396  <table width="100%">
397  <tr>
398  <td style="text-align: left; width: 20%;">全件数:<?= $list['cnt'] ?>[件]</td>
399 <?php
400 if ($list['cnt'] < 1) {
401 ?>
402  <td style="visibility: hidden;">
403 <?php
404 } else {
405 ?>
406  <td style="text-align: center;">
407 <?php
408 }
409 ?>
410  <button type="button" class="my_blue" style="width: 40px;" onclick="return my.move(-9);">|&lt;</button>
411  <button type="button" class="my_blue" style="width: 40px;" onclick="return my.move(-1);">&lt;</button>
412  <input id="v_page_last" type="hidden" value="<?= $list['last'] ?>">
413  <input id="v_page_curr" style="text-align: right;" type="text" size="4" value="<?= $list['page'] ?>">/<?= $list['last'] ?>[ページ]
414  <button type="button" class="my_blue" style="width: 40px;" onclick="return my.move(1);">&gt;</button>
415  <button type="button" class="my_blue" style="width: 40px;" onclick="return my.move(9);">&gt;|</button>
416  </td>
417  <td style="text-align: right; width: 20%;">
418  表示数:<?= $list['rpp'] ?>[件/ページ]
419  </td>
420  </tr>
421  </table>
422 
423  <div style="height: 2px;">&nbsp;</div>
424 
425  <table class="my_list">
426  <thead>
427  <tr>
428  <th>&nbsp;</th>
429  <th>連番</th>
430  <th>伝票番号</th>
431  <th>日付</th>
432  <th>決算伝票</th>
433  <th>不使用伝票</th>
434  <th>部門</th>
435  </tr>
436  </thead>
437  <tbody>
438 <?php
439 if ($list['cnt'] < 1) {
440 ?>
441  <tr>
442  <td colspan="7">データなし</td>
443  </tr>
444 <?php
445 } else {
446  $i = ($list['page'] - 1) * $list['rpp'];
447  foreach ($list['rec']['journal'] as $jod) {
448 
449  $i++;
450 
451  $jid = $jod['id'];
452  $dno = $view->str($jid);
453  $ymd = $view->strDate($jod['ymd']);
454  $week = $view->week($jod['ymd']);
455  $sflg = $view->settledFlag($jod['settled_flg'], $settled);
456  $nflg = $view->checkFlag($jod['not_use_flg']);
457  $scd = $view->str($section[$jod['scd']]);
458 ?>
459  <tr>
460  <td style="text-align: center;" rowspan="2">
461  <button type="button" class="my_cyan" onclick="return my.duplicate(<?= $dno ?>);">複製</button>
462  <br>
463  <button type="button" class="my_green" onclick="return my.edit(<?= $dno ?>);">編集</button>
464  <br>
465  <button type="button" class="my_magenta" onclick="return my.drop(<?= $dno ?>);">削除</button>
466  </td>
467  <td style="text-align: right;" rowspan="2"><?= $i ?></td>
468  <td style="text-align: center;"><?= $dno ?></td>
469  <td style="text-align: center;"><?= $ymd ?>(<?= $week ?>)</td>
470  <td style="text-align: center;"><?= $sflg ?></td>
471  <td style="text-align: center;"><?= $nflg ?></td>
472  <td style="text-align: center;"><?= $scd ?></td>
473  </tr>
474  <tr>
475  <td colspan="5" style="background-color: #77c;">
476  <table>
477  <tr>
478  <th>借方金額</th>
479  <th>借方科目</th>
480  <th>摘要</th>
481  <th>貸方科目</th>
482  <th>貸方金額</th>
483  </tr>
484 <?php
485  $dsum = 0;
486  $csum = 0;
487  foreach ($list['rec']['slip'][$jid] as $jsd) {
488  $damount = ($jsd['debit'] == 0) ? '' : number_format((int)$jsd['amount']);
489  $camount = ($jsd['credit'] == 0) ? '' : number_format((int)$jsd['amount']);
490 
491  if (empty($kcd[$jsd['debit']]['name'])) {
492  $dname = $view->str($jsd['debit']);
493  } else {
494  $dname = $view->str($kcd[$jsd['debit']]['name']);
495  }
496 
497  if (empty($kcd[$jsd['credit']]['name'])) {
498  $cname = $view->str($jsd['credit']);
499  } else {
500  $cname = $view->str($kcd[$jsd['credit']]['name']);
501  }
502 
503  $remark = $view->str($jsd['remark']);
504 
505  $dsum += ($jsd['debit'] == 0) ? 0 : (int)$jsd['amount'];
506  $csum += ($jsd['credit'] == 0) ? 0 : (int)$jsd['amount'];
507 ?>
508  <tr>
509  <td style="text-align: right;"><?= $damount ?></td>
510  <td style="text-align: center;"><?= $dname ?></td>
511  <td style="text-align: center;"><?= $remark ?></td>
512  <td style="text-align: center;"><?= $cname ?></td>
513  <td style="text-align: right;"><?= $camount ?></td>
514  </tr>
515 <?php
516  }
517  $dtotal = number_format($dsum);
518  $ctotal = number_format($csum);
519 ?>
520  <tr>
521  <th><?= $dtotal ?></th>
522  <th colspan="3">合計</th>
523  <th><?= $ctotal ?></th>
524  </tr>
525  </table>
526  </td>
527  </tr>
528 <?php
529  }
530 }
531 ?>
532  </tbody>
533  </table>
534 
535  </td>
536  </tr>
537 </table>