Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 52983c08

Von Sven Schöling vor etwa 17 Jahren hinzugefügt

  • ID 52983c089cf1b4f1a4451e57ffa76f846c4791ba
  • Vorgänger 67b5f446
  • Nachfolger 31f79e34

Kosmetikmerge aus Revisionen 5187, 5191, 5193, 5194, 5218, 5219, 5222, 5228, 5229

Unterschiede anzeigen:

bin/mozilla/oe.pl
38 38
use SL::IS;
39 39
use SL::PE;
40 40
use SL::ReportGenerator;
41
use List::Util qw(max);
41 42

  
42 43
require "bin/mozilla/io.pl";
43 44
require "bin/mozilla/arap.pl";
......
324 325
sub form_header {
325 326
  $lxdebug->enter_sub();
326 327

  
327
  my $checkedclosed = $form->{"closed"} ? "checked" : "";
328
  my $checkedclosed    = $form->{"closed"}    ? "checked" : "";
328 329
  my $checkeddelivered = $form->{"delivered"} ? "checked" : "";
329 330

  
330
  if ($form->{old_employee_id}) {
331
    $form->{employee_id} = $form->{old_employee_id};
332
  }
333
  if ($form->{old_salesman_id}) {
334
    $form->{salesman_id} = $form->{old_salesman_id};
335
  }
331
  $form->{employee_id} = $form->{old_employee_id} if $form->{old_employee_id};
332
  $form->{salesman_id} = $form->{old_salesman_id} if $form->{old_salesman_id};
336 333

  
337 334
  $form->{defaultcurrency} = $form->get_default_currency(\%myconfig);
338 335

  
339

  
340
  if ($form->{old_employee_id}) {
341
    $form->{employee_id} = $form->{old_employee_id};
342
  }
343
  if ($form->{old_salesman_id}) {
344
    $form->{salesman_id} = $form->{old_salesman_id};
345
  }
336
  $form->{employee_id} = $form->{old_employee_id} if $form->{old_employee_id};
337
  $form->{salesman_id} = $form->{old_salesman_id} if $form->{old_salesman_id};
346 338

  
347 339
  map { $form->{$_} =~ s/\"/"/g }
348 340
    qw(ordnumber quonumber shippingpoint shipvia notes intnotes shiptoname
......
365 357
   |;
366 358

  
367 359
  #write Trigger
368
  $jsscript =
369
    Form->write_trigger(\%myconfig, "2", "transdate", "BL", "trigger1",
370
                        "reqdate", "BL", "trigger2");
360
  $jsscript = Form->write_trigger(\%myconfig, "2", "transdate", "BL", "trigger1", "reqdate", "BL", "trigger2");
371 361

  
372 362
  my @tmp;
373 363

  
374 364
  if (($form->{"type"} eq "sales_order") ||
375 365
      ($form->{"type"} eq "purchase_order")) {
376
    push(@tmp, qq|
377
          <input name="delivered" id="delivered" type="checkbox" class="checkbox" value="1" $checkeddelivered>
378
          <label for="delivered">| . $locale->text('Delivered') . qq|</label>|);
366
    push(@tmp, qq|<input name="delivered" id="delivered" type="checkbox" class="checkbox" value="1" $checkeddelivered>
367
                  <label for="delivered">| . $locale->text('Delivered') . qq|</label>|);
379 368
  }
380 369

  
381 370
  if ($form->{id}) {
382
    push(@tmp, qq|
383
          <input name="closed" id="closed" type="checkbox" class="checkbox" value="1" $checkedclosed>
384
          <label for="closed">| . $locale->text('Closed') . qq|</label>|);
371
    push(@tmp, qq|<input name="closed" id="closed" type="checkbox" class="checkbox" value="1" $checkedclosed>
372
                  <label for="closed">| . $locale->text('Closed') . qq|</label>|);
385 373
  }
386 374

  
387 375
  if (@tmp) {
388
    $openclosed .= qq|
389
      <tr>
390
        <td colspan=| . (2 * scalar(@tmp)) . qq| align=center>| . join("\n", @tmp) . qq|
391
        </td>
392
      </tr>
393
|;
376
    $openclosed .= qq|<tr>
377
                        <td colspan=| . (2 * scalar(@tmp)) . qq| align=center>| . join("\n", @tmp) . qq|
378
                        </td>
379
                      </tr>\n|;
394 380
  }
395 381

  
396 382
  # set option selected
397 383
  foreach $item ($form->{vc}, currency, department, ($form->{vc} eq "customer" ? customer : vendor)) {
398 384
    $form->{"select$item"} =~ s/ selected//;
399
    $form->{"select$item"} =~
400
      s/option>\Q$form->{$item}\E/option selected>$form->{$item}/;
385
    $form->{"select$item"} =~ s/option>\Q$form->{$item}\E/option selected>$form->{$item}/;
401 386
  }
402 387

  
403 388
  #quote select[customer|vendor] Bug 133
......
429 414
  my @values = (undef);
430 415
  foreach my $item (@{ $form->{"ALL_CONTACTS"} }) {
431 416
    push(@values, $item->{"cp_id"});
432
    $labels{$item->{"cp_id"}} = $item->{"cp_name"} .
433
      ($item->{"cp_abteilung"} ? " ($item->{cp_abteilung})" : "");
417
    $labels{$item->{"cp_id"}} = $item->{"cp_name"} . ($item->{"cp_abteilung"} ? " ($item->{cp_abteilung})" : "");
434 418
  }
435 419

  
436 420
  my $contact;
......
506 490
    push(@values, $item->{"id"});
507 491
    $labels{$item->{"id"}} = $item->{"projectnumber"};
508 492
  }
509
  my $globalprojectnumber =
510
    NTI($cgi->popup_menu('-name' => 'globalproject_id', '-values' => \@values,
511
                         '-labels' => \%labels,
512
                         '-default' => $form->{"globalproject_id"}));
493
  my $globalprojectnumber = NTI($cgi->popup_menu('-name' => 'globalproject_id', '-values' => \@values,
494
                                                 '-labels' => \%labels,
495
                                                 '-default' => $form->{"globalproject_id"}));
513 496
  
514 497
  my $salesmen = "";
515 498
  %labels = ();
......
582 565
    </tr>|;
583 566
  }
584 567

  
585
  $form->{exchangerate} =
586
    $form->format_amount(\%myconfig, $form->{exchangerate});
587

  
588
  if (!$form->{exchangerate}) {
589
    $form->{exchangerate} = "";
590
  }
568
  $form->{exchangerate} = $form->format_amount(\%myconfig, $form->{exchangerate});
569
  $form->{exchangerate} = "" unless $form->{exchangerate};
591 570

  
592
  if (($form->{creditlimit} != 0) && ($form->{creditremaining} < 0) && !$form->{update}) {
593
    $creditwarning = 1;
594
  } else {
595
    $creditwarning = 0;
596
  }
571
  $creditwarning = (($form->{creditlimit} != 0) && ($form->{creditremaining} < 0) && !$form->{update}) ? 1 : 0;
597 572

  
598
  $form->{creditlimit} =
599
    $form->format_amount(\%myconfig, $form->{creditlimit}, 0, "0");
600
  $form->{creditremaining} =
601
    $form->format_amount(\%myconfig, $form->{creditremaining}, 0, "0");
573
  $form->{creditlimit}     = $form->format_amount(\%myconfig, $form->{creditlimit}, 0, "0");
574
  $form->{creditremaining} = $form->format_amount(\%myconfig, $form->{creditremaining}, 0, "0");
602 575

  
603
  $exchangerate = qq|
604
<input type=hidden name=forex value=$form->{forex}>
605
|;
576
  $exchangerate = qq|\n<input type=hidden name=forex value=$form->{forex}>\n|;
606 577

  
607 578
  if ($form->{currency} ne $form->{defaultcurrency}) {
608 579
    if ($form->{forex}) {
609 580
      $exchangerate .=
610
          qq|<th align=right>|
611
        . $locale->text('Exchangerate')
581
          qq|<th align=right>| . $locale->text('Exchangerate')
612 582
        . qq|</th><td>$form->{exchangerate}</td>
613 583
      <input type=hidden name=exchangerate value=$form->{exchangerate}>
614 584
|;
615 585
    } else {
616 586
      $exchangerate .=
617
          qq|<th align=right>|
618
        . $locale->text('Exchangerate')
587
          qq|<th align=right>| . $locale->text('Exchangerate')
619 588
        . qq|</th><td><input name=exchangerate size=10 value=$form->{exchangerate}></td>|;
620 589
    }
621 590
  }
......
683 652
	      </tr>
684 653
|;
685 654
  } else {
686
    $reqlabel =
687
      ($form->{type} eq 'sales_quotation')
688
      ? $locale->text('Valid until')
689
      : $locale->text('Required by');
655
    $reqlabel = ($form->{type} eq 'sales_quotation') ? $locale->text('Valid until') : $locale->text('Required by');
690 656
    if ($form->{type} eq 'sales_quotation') {
691 657
      $ordnumber = qq|
692 658
	      <tr>
......
707 673

  
708 674
    }
709 675

  
710
    $ordnumber .= qq|
711
	      <tr>
712
		<th align=right nowrap>| . $locale->text('Quotation Date') . qq|</th>
713
                $button1
714
              </tr>
715
	      <tr>
716
		<th align=right nowrap=true>$reqlabel</th>
717
                $button2
718
	      </tr>
719
|;
720
    $creditremaining = qq| <tr>
721
                            <td colspan=4></td>
722
                            $shipto
723
                          </tr>|;
676
    $ordnumber      .= qq| <tr> <th align=right nowrap>| . $locale->text('Quotation Date') . qq|</th> $button1 </tr>
677
                           <tr> <th align=right nowrap=true>$reqlabel</th> $button2 </tr>\n|;
678
    $creditremaining = qq| <tr> <td colspan=4></td> $shipto </tr>|;
724 679
  }
725 680

  
726 681
  $department = qq|
......
732 687
	      </tr> | if $form->{selectdepartment};
733 688

  
734 689
  if ($form->{type} eq 'sales_order') {
735
    if ($form->{selectemployee}) {
736
      $employee .= qq|
737
        <input type="hidden" name="customer_klass" value="$form->{customer_klass}">|;
738
    }
739
  } else {
740
    $employee .= qq|
741
      <input type="hidden" name="customer_klass" value="$form->{customer_klass}">|;
742
  }
743
  if ($form->{resubmit} && ($form->{format} eq "html")) {
744
    $onload =
745
      qq|window.open('about:blank','Beleg'); document.oe.target = 'Beleg';document.oe.submit()|;
746
  } elsif ($form->{resubmit}) {
747
    $onload = qq|document.oe.submit()|;
690
    $employee .= qq|\n<input type="hidden" name="customer_klass" value="$form->{customer_klass}">| if $form->{selectemployee};
748 691
  } else {
749
    $onload = "focus()";
692
    $employee .= qq|\n<input type="hidden" name="customer_klass" value="$form->{customer_klass}">|;
750 693
  }
751 694

  
752 695
  $credittext = $locale->text('Credit Limit exceeded!!!');
753
  if ($creditwarning) {
754
    $onload = qq|alert('$credittext')|;
755
  }
756
  
696

  
697
  $onload = ($form->{resubmit} && ($form->{format} eq "html")) ? "window.open('about:blank','Beleg'); document.oe.target = 'Beleg';document.oe.submit()"
698
          : ($form->{resubmit})                                ? "document.oe.submit()"
699
          : ($creditwarning)                                   ? "alert('$credittext')"
700
          :                                                      "focus()";
701

  
757 702
  $onload .= qq|;setupDateFormat('|. $myconfig{dateformat} .qq|', '|. $locale->text("Falsches Datumsformat!") .qq|')|;
758
  $onload .= qq|;setupPoints('|. $myconfig{numberformat} .qq|', '|. $locale->text("wrongformat") .qq|')|;
703
  $onload .= qq|;setupPoints('|.   $myconfig{numberformat} .qq|', '|. $locale->text("wrongformat") .qq|')|;
759 704
  
760
  $form->{"javascript"} .= qq|<script type="text/javascript" src="js/show_form_details.js"></script>|;
761
  # show history button js
705
  $form->{javascript} .= qq|<script type="text/javascript" src="js/show_form_details.js"></script>|;
762 706
  $form->{javascript} .= qq|<script type="text/javascript" src="js/show_history.js"></script>|;
763
  #/show history button js
764 707
  $form->{javascript} .= qq|<script type="text/javascript" src="js/show_vc_details.js"></script>|;
765 708

  
766 709
  $form->header;
......
778 721

  
779 722
  $form->hide_form(qw(id action type vc formname media format proforma queued printed emailed
780 723
                      title discount creditlimit creditremaining tradediscount business
781
                      max_dunning_level dunning_amount));
782

  
724
                      max_dunning_level dunning_amount shiptoname shiptostreet shiptozipcode
725
                      shiptocity shiptocountry shiptocontact shiptophone shiptofax 
726
                      shiptodepartment_1 shiptodepartment_2 shiptoemail 
727
                      message email subject cc bcc taxpart taxservice taxaccounts), 
728
                      map { $_.'_rate', $_.'_description' } split / /, $form->{taxaccounts} );
783 729
  print qq|
784 730

  
785 731
<table width=100%>
......
858 804

  
859 805
$jsscript
860 806

  
861
<!-- shipto are in hidden variables -->
862

  
863
<input type=hidden name=shiptoname value="$form->{shiptoname}">
864
<input type=hidden name=shiptostreet value="$form->{shiptostreet}">
865
<input type=hidden name=shiptozipcode value="$form->{shiptozipcode}">
866
<input type=hidden name=shiptocity value="$form->{shiptocity}">
867
<input type=hidden name=shiptocountry value="$form->{shiptocountry}">
868
<input type=hidden name=shiptocontact value="$form->{shiptocontact}">
869
<input type=hidden name=shiptophone value="$form->{shiptophone}">
870
<input type=hidden name=shiptofax value="$form->{shiptofax}">
871
<input type=hidden name=shiptodepartment_1 value="$form->{shiptodepartment_1}">
872
<input type=hidden name=shiptodepartment_2 value="$form->{shiptodepartment_2}">
873
<input type=hidden name=shiptoemail value="$form->{shiptoemail}">
874

  
875
<!-- email variables -->
876
<input type=hidden name=message value="$form->{message}">
877
<input type=hidden name=email value="$form->{email}">
878
<input type=hidden name=subject value="$form->{subject}">
879
<input type=hidden name=cc value="$form->{cc}">
880
<input type=hidden name=bcc value="$form->{bcc}">
881

  
882
<input type=hidden name=taxpart value="$form->{taxpart}">
883
<input type=hidden name=taxservice value="$form->{taxservice}">
884

  
885
<input type=hidden name=taxaccounts value="$form->{taxaccounts}">
886 807
|;
887 808

  
888
  foreach $item (split / /, $form->{taxaccounts}) {
889
    print qq|
890
<input type=hidden name="${item}_rate" value=$form->{"${item}_rate"}>
891
<input type=hidden name="${item}_description" value="$form->{"${item}_description"}">
892
|;
893
  }
894 809
  $lxdebug->leave_sub();
895 810
}
896 811

  
......
1190 1105

  
1191 1106
  set_headings($form->{"id"} ? "edit" : "add");
1192 1107

  
1193
  map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
1194
    qw(exchangerate creditlimit creditremaining);
1108
  map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) } qw(exchangerate creditlimit creditremaining);
1195 1109
  $form->{update} = 1;
1196 1110
      
1197
  if($form->{payment_id}) { 
1198
    $payment_id = $form->{payment_id};
1199
  }
1111
  $payment_id = $form->{payment_id} if $form->{payment_id};
1200 1112
  
1201 1113
  &check_name($form->{vc});
1202 1114
  
1203
  if($form->{payment_id} eq "") { 
1204
    $form->{payment_id} = $payment_id;
1205
  }
1115
  $form->{payment_id} = $payment_id if $form->{payment_id} eq "";
1206 1116
  
1207 1117
  $buysell              = 'buy';
1208 1118
  $buysell              = 'sell' if ($form->{vc} eq 'vendor');
1209
  $form->{exchangerate} = $exchangerate
1210
    if (
1211
        $form->{forex} = (
1212
                  $exchangerate =
1213
                    $form->check_exchangerate(
1214
                    \%myconfig, $form->{currency}, $form->{transdate}, $buysell
1215
                    )));
1119
  $form->{exchangerate} = $exchangerate if 
1120
    $form->{forex} = $exchangerate = $form->check_exchangerate(\%myconfig, $form->{currency}, $form->{transdate}, $buysell);
1216 1121

  
1217 1122
  # for pricegroups
1218 1123
  $i = $form->{rowcount};
1219 1124

  
1220
  $exchangerate = ($form->{exchangerate}) ? $form->{exchangerate} : 1;
1125
  $exchangerate = $form->{exchangerate} || 1;
1221 1126

  
1222 1127
  if (   ($form->{"partnumber_$i"} eq "")
1223 1128
      && ($form->{"description_$i"} eq "")
......
1232 1137
        || $form->{type} eq 'request_quotation') {
1233 1138
      IR->retrieve_item(\%myconfig, \%$form);
1234 1139
    }
1235
    if ($form->{type} eq 'sales_order' || $form->{type} eq 'sales_quotation') {
1140
    if (   $form->{type} eq 'sales_order' 
1141
        || $form->{type} eq 'sales_quotation') {
1236 1142
      IS->retrieve_item(\%myconfig, \%$form);
1237 1143
    }
1238 1144

  
1239 1145
    my $rows = scalar @{ $form->{item_list} };
1240 1146

  
1241
    $form->{"discount_$i"} =
1242
      $form->format_amount(\%myconfig, $form->{discount} * 100);
1147
    $form->{"discount_$i"} = $form->format_amount(\%myconfig, $form->{discount} * 100);
1243 1148

  
1244 1149
    if ($rows) {
1245 1150
      $form->{"qty_$i"} = 1 unless ($form->{"qty_$i"});
......
1251 1156

  
1252 1157
      } else {
1253 1158

  
1254
        $sellprice = $form->parse_amount(\%myconfig, $form->{"sellprice_$i"});
1255
        if ($form->{"not_discountable_$i"}) {
1256
          $form->{"discount_$i"} = 0;
1257
        }
1258
        map { $form->{item_list}[$i]{$_} =~ s/\"/&quot;/g }
1259
          qw(partnumber description unit);
1260
        map { $form->{"${_}_$i"} = $form->{item_list}[0]{$_} }
1261
          keys %{ $form->{item_list}[0] };
1262
        if ($form->{"part_payment_id_$i"} ne "") {
1263
          $form->{payment_id} = $form->{"part_payment_id_$i"};
1264
        }
1265

  
1266
        $s = ($sellprice) ? $sellprice : $form->{"sellprice_$i"};
1159
        $sellprice             = $form->parse_amount(\%myconfig, $form->{"sellprice_$i"});
1160
        $form->{"discount_$i"} = 0 if $form->{"not_discountable_$i"};
1161
        map { $form->{item_list}[$i]{$_} =~ s/\"/&quot;/g }    qw(partnumber description unit);
1162
        map { $form->{"${_}_$i"} = $form->{item_list}[0]{$_} } keys %{ $form->{item_list}[0] };
1163
        $form->{payment_id} = $form->{"part_payment_id_$i"} if $form->{"part_payment_id_$i"} ne "";
1267 1164

  
1268
        ($dec) = ($s =~ /\.(\d+)/);
1269
        $dec           = length $dec;
1270
        $decimalplaces = ($dec > 2) ? $dec : 2;
1165
        ($sellprice || $form->{"sellprice_$i"}) =~ /\.(\d+)/;
1166
        $decimalplaces = max 2, length $1;
1271 1167

  
1272 1168
        if ($sellprice) {
1273 1169
          $form->{"sellprice_$i"} = $sellprice;
1274 1170
        } else {
1275

  
1276 1171
          $form->{"sellprice_$i"} *= (1 - $form->{tradediscount});
1277

  
1278
          # if there is an exchange rate adjust sellprice
1279
          $form->{"sellprice_$i"} /= $exchangerate;
1172
          $form->{"sellprice_$i"} /= $exchangerate;   # if there is an exchange rate adjust sellprice
1280 1173
        }
1281 1174

  
1282
        $amount =
1283
          $form->{"sellprice_$i"} * $form->{"qty_$i"} *
1284
          (1 - $form->{"discount_$i"} / 100);
1285
        map { $form->{"${_}_base"} = 0 } (split / /, $form->{taxaccounts});
1286
        map { $form->{"${_}_base"} += $amount }
1287
          (split / /, $form->{"taxaccounts_$i"});
1288
        map { $amount += ($form->{"${_}_base"} * $form->{"${_}_rate"}) }
1289
          split / /, $form->{taxaccounts}
1290
          if !$form->{taxincluded};
1175
        $amount = $form->{"sellprice_$i"} * $form->{"qty_$i"} * (1 - $form->{"discount_$i"} / 100);
1176
        map { $form->{"${_}_base"} = 0 }                                 split / /, $form->{taxaccounts};
1177
        map { $form->{"${_}_base"} += $amount }                          split / /, $form->{"taxaccounts_$i"};
1178
        map { $amount += ($form->{"${_}_base"} * $form->{"${_}_rate"}) } split / /, $form->{taxaccounts} if !$form->{taxincluded};
1291 1179

  
1292 1180
        $form->{creditremaining} -= $amount;
1293 1181

  
1294
        $form->{"sellprice_$i"} =
1295
          $form->format_amount(\%myconfig, $form->{"sellprice_$i"},
1296
                               $decimalplaces);
1297
        $form->{"qty_$i"} =
1298
          $form->format_amount(\%myconfig, $form->{"qty_$i"}, $dec_qty);
1182
        $form->{"sellprice_$i"} = $form->format_amount(\%myconfig, $form->{"sellprice_$i"}, $decimalplaces);
1183
        $form->{"qty_$i"}       = $form->format_amount(\%myconfig, $form->{"qty_$i"}, $dec_qty);
1299 1184

  
1300 1185
        # get pricegroups for parts
1301 1186
        IS->get_pricegroups_for_parts(\%myconfig, \%$form);

Auch abrufbar als: Unified diff