Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision aae6de35

Von Sven Schöling vor fast 9 Jahren hinzugefügt

  • ID aae6de35362b09814f64be668537fe6d164f6e5a
  • Vorgänger d3975bc1
  • Nachfolger 8c1d5d75

rp/report: Vorbelegung des freien Zeitraums - javascript Fixes

Unterschiede anzeigen:

templates/webpages/rp/report.html
371 371
</form>
372 372

  
373 373
<script type="text/javascript">
374
function format_date(yy, mm, dd) {
375
  var format = "[% dateformat %]";
376
  format = format.replace("yyyy", "yy");
377
  format = format.replace("yy", yy);
378
  format = format.replace("mm", mm);
379
  format = format.replace("dd", dd);
380
  return format;
381
}
382 374
function set_from_to(duetyp, year) {
383
  switch(duetyp) {
384
    case '1':
385
      document.getElementById('fromdate').value=format_date(year, '01', '01');
386
      document.getElementById('todate').value=format_date(year, '01', '31');
387
    break;
388
    case '2':
389
      document.getElementById('fromdate').value=format_date(year, '02', '01');
390
      if(year % 4) document.getElementById('todate').value=format_date(year, '02', '28');
391
      else document.getElementById('todate').value=format_date(year, '2', '29');
392
    break;
393
    case '3':
394
      document.getElementById('fromdate').value=format_date(year, '03', '01');
395
      document.getElementById('todate').value=format_date(year, '03', '31');
396
    break;
397
    case '4':
398
      document.getElementById('fromdate').value=format_date(year, '04', '01');
399
      document.getElementById('todate').value=format_date(year, '04', '30');
400
    break;
401
    case '5':
402
      document.getElementById('fromdate').value=format_date(year, '05', '01');
403
      document.getElementById('todate').value=format_date(year, '05', '31');
404
    break;
405
    case '6':
406
      document.getElementById('fromdate').value=format_date(year, '06', '01');
407
      document.getElementById('todate').value=format_date(year, '06', '30');
408
    break;
409
    case '7':
410
      document.getElementById('fromdate').value=format_date(year, '07', '01');
411
      document.getElementById('todate').value=format_date(year, '07', '31');
412
    break;
413
    case '8':
414
      document.getElementById('fromdate').value=format_date(year, '08', '01');
415
      document.getElementById('todate').value=format_date(year, '08', '31');
416
    break;
417
    case '9':
418
      document.getElementById('fromdate').value=format_date(year, '09', '01');
419
      document.getElementById('todate').value=format_date(year, '09', '30');
420
    break;
421
    case '10':
422
      document.getElementById('fromdate').value=format_date(year, '10', '01');
423
      document.getElementById('todate').value=format_date(year, '10', '31');
424
    break;
425
    case '11':
426
      document.getElementById('fromdate').value=format_date(year, '11', '01');
427
      document.getElementById('todate').value=format_date(year, '11', '30');
428
    break;
429
    case '12':
430
      document.getElementById('fromdate').value=format_date(year, '12', '01');
431
      document.getElementById('todate').value=format_date(year, '12', '31');
432
    break;
433
    case '13':
434
      document.getElementById('fromdate').value=format_date(year, '01', '01');
435
      document.getElementById('todate').value=format_date(year, '12', '31');
436
    break;
437
    case 'A':
438
      document.getElementById('fromdate').value=format_date(year, '01', '01');
439
      document.getElementById('todate').value=format_date(year, '03', '31');
440
    break;
441
    case 'B':
442
      document.getElementById('fromdate').value=format_date(year, '04', '01');
443
      document.getElementById('todate').value=format_date(year, '06', '30');
444
    break;
445
    case 'C':
446
      document.getElementById('fromdate').value=format_date(year, '07', '01');
447
      document.getElementById('todate').value=format_date(year, '09', '31');
448
    break;
449
    case 'D':
450
      document.getElementById('fromdate').value=format_date(year, '10', '01');
451
      document.getElementById('todate').value=format_date(year, '12', '31');
452
    break;
453
    default:
454
      document.getElementById('fromdate').value=format_date(year, '01', '01');
455
      document.getElementById('todate').value=format_date(year, '12', '31');
456
  }
375
  var date = {
376
    1:  [ 1,  1, 1,  31 ],
377
    2:  [ 2,  1, 2,  new Date(year, 1, 29).getMonth() == 1 ? 29 : 28 ],
378
    3:  [ 3,  1, 3,  31 ],
379
    4:  [ 4,  1, 4,  30 ],
380
    5:  [ 5,  1, 5,  31 ],
381
    6:  [ 6,  1, 6,  30 ],
382
    7:  [ 7,  1, 7,  31 ],
383
    8:  [ 8,  1, 8,  31 ],
384
    9:  [ 9,  1, 9,  30 ],
385
    10: [ 10, 1, 10, 31 ],
386
    11: [ 11, 1, 11, 30 ],
387
    12: [ 12, 1, 12, 31 ],
388
    13: [  1, 1, 12, 31 ],
389
    'A': [ 1,  1, 3,  31 ],
390
    'B': [ 4,  1, 6,  30 ],
391
    'C': [ 7,  1, 9,  30 ],
392
    'D': [ 10, 1, 12, 31 ]
393
  }[duetyp];
394

  
395
  $('#fromdate').val(kivi.format_date(new Date(year, date[0]-1, date[1])));
396
  $('#todate').val(kivi.format_date(new Date(year, date[2]-1, date[3])));
397

  
457 398
  return true;
458 399
}
459 400
</script>

Auch abrufbar als: Unified diff