Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision e50a00d2

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

  • ID e50a00d20a90057f9b04dc524b6d13afffb0c750
  • Vorgänger 78637a08
  • Nachfolger 6f85ff8b

ir.pl: template footer, payments.

Unterschiede anzeigen:

bin/mozilla/ir.pl
265 265
  $form->{salesman_id} = $form->{old_salesman_id} if $form->{old_salesman_id};
266 266

  
267 267
  $form->{defaultcurrency} = $form->get_default_currency(\%myconfig);
268
  $form->{radier}          = ($form->current_date(\%myconfig) eq $form->{gldate}) ? 1 : 0;
269 268

  
270 269
  my $set_duedate_url = "$form->{script}?action=set_duedate";
271 270

  
......
354 353
  my $form     = $main::form;
355 354
  my %myconfig = %main::myconfig;
356 355
  my $locale   = $main::locale;
357
  my $cgi      = $main::cgi;
358

  
359
  $main::auth->assert('vendor_invoice_edit');
360 356

  
361
  $form->{invtotal} = $form->{invsubtotal};
362

  
363
  my ($rows, $introws);
364
  if (($rows = $form->numtextrows($form->{notes}, 25, 8)) < 2) {
365
    $rows = 2;
366
  }
367
  if (($introws = $form->numtextrows($form->{intnotes}, 35, 8)) < 2) {
368
    $introws = 2;
369
  }
370
  $rows = ($rows > $introws) ? $rows : $introws;
371
  my $notes =
372
    qq|<textarea name=notes rows=$rows cols=25 wrap=soft>$form->{notes}</textarea>|;
373
  my $intnotes =
374
    qq|<textarea name=intnotes rows=$rows cols=35 wrap=soft>$form->{intnotes}</textarea>|;
375

  
376
  $form->{taxincluded} = ($form->{taxincluded}) ? "checked" : "";
377

  
378
  my $taxincluded = "";
379
  if ($form->{taxaccounts}) {
380
    $taxincluded = qq|
381
		<input name=taxincluded class=checkbox type=checkbox value=1 $form->{taxincluded}> <b>|
382
      . $locale->text('Tax Included') . qq|</b>
383
|;
384
  }
385

  
386
  my ($tax, $subtotal);
387
  if (!$form->{taxincluded}) {
388

  
389
    foreach my $item (split / /, $form->{taxaccounts}) {
390
      if ($form->{"${item}_base"}) {
391
        $form->{invtotal} += $form->{"${item}_total"} =
392
          $form->round_amount(
393
                             $form->{"${item}_base"} * $form->{"${item}_rate"},
394
                             2);
395
        $form->{"${item}_total"} =
396
          $form->format_amount(\%myconfig, $form->{"${item}_total"}, 2);
397

  
398
        $tax .= qq|
399
		<tr>
400
		  <th align=right>$form->{"${item}_description"}&nbsp;|
401
                    . $form->{"${item}_rate"} * 100 .qq|%</th>
402
		  <td align=right>$form->{"${item}_total"}</td>
403
		</tr>
404
|;
405
      }
406
    }
357
  $main::auth->assert('invoice_edit');
407 358

  
408
    $form->{invsubtotal} =
409
      $form->format_amount(\%myconfig, $form->{invsubtotal}, 2, 0);
359
  $form->{invtotal}    = $form->{invsubtotal};
360
  $form->{oldinvtotal} = $form->{invtotal};
410 361

  
411
    $subtotal = qq|
412
	      <tr>
413
		<th align=right>| . $locale->text('Subtotal') . qq|</th>
414
		<td align=right>$form->{invsubtotal}</td>
415
	      </tr>
416
|;
362
  # note rows
363
  $form->{rows} = max 2,
364
    $form->numtextrows($form->{notes},    26, 8),
365
    $form->numtextrows($form->{intnotes}, 35, 8);
417 366

  
418
  }
419 367

  
420
  if ($form->{taxincluded}) {
421
    foreach my $item (split / /, $form->{taxaccounts}) {
422
      if ($form->{"${item}_base"}) {
423
        $form->{"${item}_total"} =
424
          $form->round_amount(
425
                           ($form->{"${item}_base"} * $form->{"${item}_rate"} /
426
                              (1 + $form->{"${item}_rate"})
427
                           ),
428
                           2);
429
        $form->{"${item}_base"} =
430
          $form->round_amount($form->{"${item}_base"}, 2);
431
        $form->{"${item}_netto"} =
432
          $form->round_amount(
433
                          ($form->{"${item}_base"} - $form->{"${item}_total"}),
434
                          2);
435
        $form->{"${item}_netto"} =
436
          $form->format_amount(\%myconfig, $form->{"${item}_netto"}, 2);
437
        $form->{"${item}_total"} =
438
          $form->format_amount(\%myconfig, $form->{"${item}_total"}, 2);
439

  
440
        $tax .= qq|
441
	      <tr>
442
		<th align=right>Enthaltene $form->{"${item}_description"}&nbsp;|
443
		                    . $form->{"${item}_rate"} * 100 .qq|%</th>
444
		<td align=right>$form->{"${item}_total"}</td>
445
	      </tr>
446
	      <tr>
447
	        <th align=right>Nettobetrag</th>
448
		<td align=right>$form->{"${item}_netto"}</td>
449
	      </tr>
450
|;
368
  # tax, total and subtotal calculations
369
  my ($tax, $subtotal);
370
  $form->{taxaccounts_array} = [ split / /, $form->{taxaccounts} ];
371

  
372
  foreach my $item (@{ $form->{taxaccounts_array} }) {
373
    if ($form->{"${item}_base"}) {
374
      if ($form->{taxincluded}) {
375
        $form->{"${item}_total"} = $form->round_amount( ($form->{"${item}_base"} * $form->{"${item}_rate"}
376
                                                                                 / (1 + $form->{"${item}_rate"})), 2);
377
        $form->{"${item}_netto"} = $form->round_amount( ($form->{"${item}_base"} - $form->{"${item}_total"}), 2);
378
      } else {
379
        $form->{"${item}_total"} = $form->round_amount( $form->{"${item}_base"} * $form->{"${item}_rate"}, 2);
380
        $form->{invtotal} += $form->{"${item}_total"};
451 381
      }
452 382
    }
453

  
454 383
  }
455 384

  
456
  $form->{oldinvtotal} = $form->{invtotal};
457
  $form->{invtotal}    =
458
    $form->format_amount(\%myconfig, $form->{invtotal}, 2, 0);
459

  
460
  my $follow_ups_block;
385
  # follow ups
461 386
  if ($form->{id}) {
462
    my $follow_ups = FU->follow_ups('trans_id' => $form->{id});
463

  
464
    if (@{ $follow_ups} ) {
465
      my $num_due       = sum map { $_->{due} * 1 } @{ $follow_ups };
466
      $follow_ups_block = qq|
467
      <tr>
468
        <td colspan="2">| . $locale->text("There are #1 unfinished follow-ups of which #2 are due.", scalar @{ $follow_ups }, $num_due) . qq|</td>
469
      </tr>
470
|;
471
    }
472
  }
473

  
474
  our $colspan;
475
  print qq|
476
  <tr>
477
    <td colspan=$colspan>
478
      <table cellspacing="0">
479
	<tr valign=bottom>
480
	  <td>
481
	    <table>
482
	      <tr>
483
		<th align=left>| . $locale->text('Notes') . qq|</th>
484
		<th align=left>| . $locale->text('Internal Notes') . qq|</th>
485
	      </tr>
486
	      <tr valign=top>
487
		<td>$notes</td>
488
		<td>$intnotes</td>
489
	      </tr>
490
        $follow_ups_block
491
	    </table>
492
	  </td>
493
	  <td colspan=2 align=right width=100%>
494
	    $taxincluded
495
	    <br>
496
	    <table width=100%>
497
	      $subtotal
498
	      $tax
499
	      <tr>
500
		<th align=right>| . $locale->text('Total') . qq|</th>
501
		<td align=right>$form->{invtotal}</td>
502
	      </tr>
503
	    </table>
504
	  </td>
505
	</tr>
506
      </table>
507
    </td>
508
  </tr>
509
|;
510
  my $webdav_list;
511
  if ($main::webdav) {
512
    $webdav_list = qq|
513
  <tr>
514
    <td><hr size=3 noshade></td>
515
  </tr>
516
  <tr>
517
    <th class=listtop align=left>Dokumente im Webdav-Repository</th>
518
  </tr>
519
    <table width=100%>
520
      <td align=left width=30%><b>Dateiname</b></td>
521
      <td align=left width=70%><b>Webdavlink</b></td>
522
|;
523
    foreach my $file (@{ $form->{WEBDAV} }) {
524
      $webdav_list .= qq|
525
      <tr>
526
        <td align="left">$file->{name}</td>
527
        <td align="left"><a href="$file->{link}">$file->{type}</a></td>
528
      </tr>
529
|;
530
    }
531
    $webdav_list .= qq|
532
    </table>
533
  </tr>
534
|;
535

  
536
    print $webdav_list;
537
  }
538
  print qq|
539
  <tr>
540
    <td colspan=$colspan>
541
      <table width=100%>
542
        <tr>
543
	  <th colspan=6 class=listheading>| . $locale->text('Payments') . qq|</th>
544
	</tr>
545
|;
546

  
547
  my @column_index;
548
  if ($form->{currency} eq $form->{defaultcurrency}) {
549
    @column_index = qw(datepaid source memo paid AP_paid);
550
  } else {
551
    @column_index = qw(datepaid source memo paid exchangerate AP_paid);
387
    $form->{follow_ups}            = FU->follow_ups('trans_id' => $form->{id}) || [];
388
    $form->{follow_ups_unfinished} = ( sum map { $_->{due} * 1 } @{ $form->{follow_ups} } ) || 0;
552 389
  }
553 390

  
554
  my %column_data;
555
  $column_data{datepaid}     = "<th>" . $locale->text('Date') . "</th>";
556
  $column_data{paid}         = "<th>" . $locale->text('Amount') . "</th>";
557
  $column_data{exchangerate} = "<th>" . $locale->text('Exch') . "</th>";
558
  $column_data{AP_paid}      = "<th>" . $locale->text('Account') . "</th>";
559
  $column_data{source}       = "<th>" . $locale->text('Source') . "</th>";
560
  $column_data{memo}         = "<th>" . $locale->text('Memo') . "</th>";
561

  
562
  print qq|
563
	<tr>
564
|;
565
  map { print "$column_data{$_}\n" } @column_index;
566
  print qq|
567
	</tr>
568
|;
569

  
570
  my @triggers  = ();
391
  # payments
571 392
  my $totalpaid = 0;
572

  
573 393
  $form->{paidaccounts}++ if ($form->{"paid_$form->{paidaccounts}"});
574
  for my $i (1 .. $form->{paidaccounts}) {
575

  
576
    print qq|
577
	<tr>
578
|;
394
  $form->{paid_indices} = [ 1 .. $form->{paidaccounts} ];
579 395

  
396
  for my $i (1 .. $form->{paidaccounts}) {
580 397
    $form->{"selectAP_paid_$i"} = $form->{selectAP_paid};
581
    $form->{"selectAP_paid_$i"} =~
582
      s/option>\Q$form->{"AP_paid_$i"}\E/option selected>$form->{"AP_paid_$i"}/;
583

  
398
    $form->{"selectAP_paid_$i"} =~ s/option>\Q$form->{"AP_paid_$i"}\E/option selected>$form->{"AP_paid_$i"}/;
584 399
    $totalpaid += $form->{"paid_$i"};
585

  
586
    # format amounts
587
    if ($form->{"paid_$i"}) {
588
      $form->{"paid_$i"} =
589
        $form->format_amount(\%myconfig, $form->{"paid_$i"}, 2);
590
    }
591
    $form->{"exchangerate_$i"} =
592
      $form->format_amount(\%myconfig, $form->{"exchangerate_$i"});
593

  
594
    my $exchangerate = qq|&nbsp;|;
595
    if ($form->{currency} ne $form->{defaultcurrency}) {
596
      if ($form->{"forex_$i"}) {
597
        $exchangerate =
598
          qq|<input type=hidden name="exchangerate_$i" value=$form->{"exchangerate_$i"}>$form->{"exchangerate_$i"}|;
599
      } else {
600
        $exchangerate =
601
          qq|<input name="exchangerate_$i" size=10 value=$form->{"exchangerate_$i"}>|;
602
      }
603
    }
604
    $exchangerate .= qq|
605
<input type=hidden name="forex_$i" value=$form->{"forex_$i"}>
606
|;
607

  
608
    $column_data{"paid_$i"} =
609
      qq|<td align=center><input name="paid_$i" size=11 value="$form->{"paid_$i"}" onBlur=\"check_right_number_format(this)\"></td>|;
610
    $column_data{"exchangerate_$i"} = qq|<td align=center>$exchangerate</td>|;
611
    $column_data{"AP_paid_$i"}      =
612
      qq|<td align=center><select name="AP_paid_$i">$form->{"selectAP_paid_$i"}</select></td>|;
613
    $column_data{"datepaid_$i"} =
614
      qq|<td align=center><input name="datepaid_$i" id="datepaid_$i" size=11 title="$myconfig{dateformat}" value="$form->{"datepaid_$i"}" onBlur=\"check_right_date_format(this)\">
615
         <input type="button" name="datepaid_$i" id="trigger_datepaid_$i" value="?"></td>|;
616
    $column_data{"source_$i"} =
617
      qq|<td align=center><input name="source_$i" size=11 value="$form->{"source_$i"}"></td>|;
618
    $column_data{"memo_$i"} =
619
      qq|<td align=center><input name="memo_$i" size=11 value="$form->{"memo_$i"}"></td>|;
620

  
621
    map { print qq|$column_data{"${_}_$i"}\n| } @column_index;
622

  
623
    print qq|
624
	</tr>
625
|;
626
    push(@triggers, "datepaid_$i", "BL", "trigger_datepaid_$i");
627
  }
628

  
629
  my $paid_missing = $form->{oldinvtotal} - $totalpaid;
630

  
631
  print qq|
632
        <tr>
633
          <td></td>
634
          <td></td>
635
          <td align="center">| . $locale->text('Total') . qq|</td>
636
          <td align="center">| . H($form->format_amount(\%myconfig, $totalpaid, 2)) . qq|</td>
637
        </tr>
638
        <tr>
639
          <td></td>
640
          <td></td>
641
          <td align="center">| . $locale->text('Missing amount') . qq|</td>
642
          <td align="center">| . H($form->format_amount(\%myconfig, $paid_missing, 2)) . qq|</td>
643
        </tr>
644

  
645
	    <input type=hidden name=oldinvtotal value=$form->{oldinvtotal}>
646
	    <input type=hidden name=paidaccounts value=$form->{paidaccounts}>
647
      	    <input type=hidden name=selectAP_paid value="$form->{selectAP_paid}">
648
      </table>
649
    </td>
650
  </tr>
651
  <tr>
652
    <td><hr size=3 noshade></td>
653
  </tr>
654
</table>
655
<br>
656
|;
657

  
658
  my $invdate  = $form->datetonum($form->{invdate},  \%myconfig);
659
  my $closedto = $form->datetonum($form->{closedto}, \%myconfig);
660

  
661
  print qq|<input class=submit type=submit name=action id=update_button value="|
662
    . $locale->text('Update') . qq|">
663
|;
664

  
665
  if ($form->{id}) {
666
    my $show_storno = !$form->{storno} && !IS->has_storno(\%myconfig, $form, "ap") && (($totalpaid == 0) || ($totalpaid eq ""));
667

  
668
    print qq|<input class=submit type=submit name=action value="|
669
      . $locale->text('Post Payment') . qq|">
670
|;
671
    print qq|<input class=submit type=submit name=action value="|
672
      . $locale->text('Storno') . qq|">
673
| if ($show_storno);
674
    if ($form->{radier}) {
675
    print qq|
676
    <input class=submit type=submit name=action value="|
677
      . $locale->text('Delete') . qq|">
678
|;
679
  }
680
    print qq|<input class=submit type=submit name=action value="|
681
      . $locale->text('Use As Template') . qq|">
682
        <input type="button" class="submit" onclick="follow_up_window()" value="|
683
      . $locale->text('Follow-Up')
684
      . qq|">
685
|;
686

  
687 400
  }
688 401

  
689
  if (!$form->{id} && ($invdate > $closedto)) {
690
    print qq| <input class=submit type=submit name=action value="|
691
      . $locale->text('Post') . qq|"> | .
692
      NTI($cgi->submit('-name' => 'action', '-value' => $locale->text('Save draft'),
693
                       '-class' => 'submit'));
694
  }
695

  
696
  print $form->write_trigger(\%myconfig, scalar(@triggers) / 3, @triggers);
697
  $form->hide_form(qw(rowcount callback draft_id draft_description vendor_discount));
698

  
699
  # button for saving history
700
  if($form->{id} ne "") {
701
    print qq|
702
  	  <input type="button" class="submit" onclick="set_history_window(|
703
  	  . Q($form->{id})
704
  	  . qq|);" name="history" id="history" value="|
705
  	  . $locale->text('history')
706
  	  . qq|">|;
707
  }
708
  # /button for saving history
709
  # mark_as_paid button
710
  if($form->{id} ne "") {
711
    print qq| <input type="submit" class="submit" name="action" value="|
712
          . $locale->text('mark as paid') . qq|">|;
713
  }
714
  # /mark_as_paid button
715
print qq|</form>
716
</body>
717
</html>
718
|;
402
  print $form->parse_html_template('ir/form_footer', {
403
    is_type_credit_note => ($form->{type} eq "credit_note"),
404
    totalpaid           => $totalpaid,
405
    paid_missing        => $form->{invtotal} - $totalpaid,
406
    show_storno         => $form->{id} && !$form->{storno} && !IS->has_storno(\%myconfig, $form, "ap") && !$totalpaid,
407
    show_delete         => ($form->current_date(\%myconfig) eq $form->{gldate}),
408
  });
409
##print $form->parse_html_template('ir/_payments'); # parser
410
##print $form->parse_html_template('webdav/_list'); # parser
719 411

  
720 412
  $main::lxdebug->leave_sub();
721 413
}

Auch abrufbar als: Unified diff