Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 0270c3d5

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

  • ID 0270c3d56c5caccb535b328e56e0888329430888
  • Vorgänger 5b9f9bd6
  • Nachfolger a6476377

Feature Sammelauftraege fuer Antivir
- Kann jetzt mehrere Auftraege in der Suchmaske anwaehlen und zusammenfassen zu einem Sammelauftrag.
- Kann diesen Sammelauftrag als neu speichern und eine Rechnung dafuer ausstellen.
- Kann die folgende Rechnung wiederum speichern und buchen.
- Wird Sammelauftraege mit nur einem Auftrag abfangen und wie gehabt als einzelnen behandeln.
- Wird soviele Daten wie moeglich im Header des Sammelauftrags beibehalten, wobei customer, ordnumber und transdate eindeutig sein muessen.
- transdate und ordnumber werden bei Bedarf ueberschrieben, nicht eindeutiger customer wird mit Fehlermeldung quittiert

Zusaetzlich:
- Bugfix in Form::get_exchangerate, genauso gefixt wie in Form::check_exchangerate
- neue Routine OE:close_orders, die genau das tut.
- Der Versuch oe::edit ohne eine id aufzurufen wird nun auf oe::add umgeleitet

Unterschiede anzeigen:

SL/Form.pm
1
#=====================================================================
1
#====================================================================
2 2
# LX-Office ERP
3 3
# Copyright (C) 2004
4 4
# Based on SQL-Ledger Version 2.1.9
......
1277 1277
  $main::lxdebug->enter_sub();
1278 1278

  
1279 1279
  my ($self, $dbh, $curr, $transdate, $fld) = @_;
1280
  
1281
  unless ($transdate) {
1282
    $main::lxdebug->leave_sub();
1283
    return "";
1284
  }
1280 1285

  
1281 1286
  my $query = qq|SELECT e.$fld FROM exchangerate e
1282 1287
                 WHERE e.curr = '$curr'
SL/OE.pm
1
#=====================================================================
1
#====================================================================
2 2
# LX-Office ERP
3 3
# Copyright (C) 2004
4 4
# Based on SQL-Ledger Version 2.1.9
......
464 464
  return $rc;
465 465
}
466 466

  
467
# this function closes multiple orders given in $form->{ordnumber_#}. 
468
# use this for multiple orders that don't have to be saved back
469
# single orders should use OE::save instead.
470
sub close_orders {
471
  $main::lxdebug->enter_sub();
472

  
473
  my ($self, $myconfig ,$form) = @_;
474

  
475
  # get ids from $form
476
  map { push @ids, $form->{"ordnumber_$_"} if $form->{"ordnumber_$_"} } (1 .. $form->{rowcount});
477
  
478
  my $dbh = $form->dbconnect($myconfig);
479
  $query = qq|UPDATE oe SET
480
              closed = TRUE
481
              WHERE ordnumber IN (|.join(', ', map{ $dbh->quote($_) }@ids).qq|)|;
482
  $dbh->do($query) || $form->dberror($query);
483
  $dbh->disconnect;
484

  
485
  $main::lxdebug->leave_sub();
486
}
487

  
467 488
sub delete {
468 489
  $main::lxdebug->enter_sub();
469 490

  
......
544 565

  
545 566
  my $query;
546 567

  
568
  # translate the ids (given by id_# and trans_id_#) into one array of ids, so we can join them later
569
  map { push @ids, $form->{"trans_id_$_"} if ($form->{"id_$_"}) } (1 .. $form->{"rowcount"});
570

  
571
  # if called in multi id mode, and still only got one id, switch back to single id 
572
  if ($form->{"rowcount"} and $#ids == 0) {
573
    $form->{"id"} = $ids[0];
574
    undef @ids;
575
  }
576

  
547 577
  if ($form->{id}) {
548 578

  
549 579
    # get default accounts and last order number
......
583 613

  
584 614
  ($form->{currency}) = split /:/, $form->{currencies};
585 615

  
586
  if ($form->{id}) {
616
  if ($form->{id} or @ids) {
587 617

  
588
    # retrieve order
589
    $query = qq|SELECT o.cp_id,o.ordnumber, o.transdate, o.reqdate,
618
    # retrieve order for single id
619
    # NOTE: this query is intended to fetch all information only ONCE.
620
    # so if any of these infos is important (or even different) for any item, 
621
    # it will be killed out and then has to be fetched from the item scope query further down
622
    $query = qq|SELECT o.cp_id, o.ordnumber, o.transdate, o.reqdate,
590 623
                o.taxincluded, o.shippingpoint, o.shipvia, o.notes, o.intnotes,
591 624
		o.curr AS currency, e.name AS employee, o.employee_id,
592 625
		o.$form->{vc}_id, cv.name AS $form->{vc}, o.amount AS invtotal,
......
596 629
	        JOIN $form->{vc} cv ON (o.$form->{vc}_id = cv.id)
597 630
	        LEFT JOIN employee e ON (o.employee_id = e.id)
598 631
	        LEFT JOIN department d ON (o.department_id = d.id)
599
		WHERE o.id = $form->{id}|;
600
    $sth = $dbh->prepare($query);
601
    $sth->execute || $form->dberror($query);
632
		|. ($form->{id} 
633
		   ? qq|WHERE o.id = $form->{id}| 
634
                   : qq|WHERE o.id IN (|.join(', ', @ids).qq|)|
635
		   );
602 636

  
603
    $ref = $sth->fetchrow_hashref(NAME_lc);
604
    map { $form->{$_} = $ref->{$_} } keys %$ref;
605
    $sth->finish;
637
#$main::lxdebug->message(0, $query);
606 638

  
607
    $query = qq|SELECT s.* FROM shipto s
608
                WHERE s.trans_id = $form->{id}|;
609 639
    $sth = $dbh->prepare($query);
610 640
    $sth->execute || $form->dberror($query);
611 641

  
612 642
    $ref = $sth->fetchrow_hashref(NAME_lc);
613 643
    map { $form->{$_} = $ref->{$_} } keys %$ref;
614
    $sth->finish;
615

  
616
    # get printed, emailed and queued
617
    $query = qq|SELECT s.printed, s.emailed, s.spoolfile, s.formname
618
                FROM status s
619
		WHERE s.trans_id = $form->{id}|;
620
    $sth = $dbh->prepare($query);
621
    $sth->execute || $form->dberror($query);
622 644

  
645
    # destroy all entries for multiple ids that yield different information
623 646
    while ($ref = $sth->fetchrow_hashref(NAME_lc)) {
624
      $form->{printed} .= "$ref->{formname} " if $ref->{printed};
625
      $form->{emailed} .= "$ref->{formname} " if $ref->{emailed};
626
      $form->{queued} .= "$ref->{formname} $ref->{spoolfile} "
627
        if $ref->{spoolfile};
647
      map { undef $form->{$_} if ($ref->{$_} ne $form->{$_}) } keys %$ref;
628 648
    }
649

  
650
    # if not given, fill transdate with current_date
651
    $form->{transdate} = $form->current_date($myconfig) unless $form->{transdate};
652

  
629 653
    $sth->finish;
630
    map { $form->{$_} =~ s/ +$//g } qw(printed emailed queued);
654

  
655
    # shipto and pinted/mailed/queued status makes only sense for single id retrieve 
656
    if (!@ids) {
657
      $query = qq|SELECT s.* FROM shipto s
658
                  WHERE s.trans_id = $form->{id}|;
659
      $sth = $dbh->prepare($query);
660
      $sth->execute || $form->dberror($query);
661

  
662
      $ref = $sth->fetchrow_hashref(NAME_lc);
663
      map { $form->{$_} = $ref->{$_} } keys %$ref;
664
      $sth->finish;
665

  
666
      # get printed, emailed and queued
667
      $query = qq|SELECT s.printed, s.emailed, s.spoolfile, s.formname
668
                  FROM status s
669
                  WHERE s.trans_id = $form->{id}|;
670
      $sth = $dbh->prepare($query);
671
      $sth->execute || $form->dberror($query);
672

  
673
      while ($ref = $sth->fetchrow_hashref(NAME_lc)) {
674
        $form->{printed} .= "$ref->{formname} " if $ref->{printed};
675
        $form->{emailed} .= "$ref->{formname} " if $ref->{emailed};
676
        $form->{queued} .= "$ref->{formname} $ref->{spoolfile} " if $ref->{spoolfile};
677
      }
678
      $sth->finish;
679
      map { $form->{$_} =~ s/ +$//g } qw(printed emailed queued);
680
    } # if !@ids
631 681

  
632 682
    my %oid = ('Pg'     => 'oid',
633 683
               'Oracle' => 'rowid');
634 684

  
635 685
    # retrieve individual items
686
    # this query looks up all information about the items
687
    # stuff different from the whole will not be overwritten, but saved with a suffix.
636 688
    $query = qq|SELECT o.id AS orderitems_id,
637 689
                c1.accno AS inventory_accno,
638 690
                c2.accno AS income_accno,
639 691
		c3.accno AS expense_accno,
692
		oe.ordnumber, oe.transdate, oe.cusordnumber, 
640 693
                p.partnumber, p.assembly, o.description, o.qty,
641 694
		o.sellprice, o.parts_id AS id, o.unit, o.discount, p.bin, p.notes AS partnotes,
642 695
                o.reqdate, o.project_id, o.serialnumber, o.ship,
......
644 697
		pg.partsgroup, o.pricegroup_id, (SELECT pricegroup FROM pricegroup WHERE id=o.pricegroup_id) as pricegroup
645 698
		FROM orderitems o
646 699
		JOIN parts p ON (o.parts_id = p.id)
700
		JOIN oe ON (o.trans_id = oe.id)
647 701
		LEFT JOIN chart c1 ON (p.inventory_accno_id = c1.id)
648 702
		LEFT JOIN chart c2 ON (p.income_accno_id = c2.id)
649 703
		LEFT JOIN chart c3 ON (p.expense_accno_id = c3.id)
650 704
		LEFT JOIN project pr ON (o.project_id = pr.id)
651 705
		LEFT JOIN partsgroup pg ON (p.partsgroup_id = pg.id)
652
		WHERE o.trans_id = $form->{id}
706
		|. ($form->{id} 
707
		   ? qq|WHERE o.trans_id = $form->{id}| 
708
		   : qq|WHERE o.trans_id IN (|.join(", ", @ids).qq|)| 
709
		   ).qq|
653 710
                ORDER BY o.$oid{$myconfig->{dbdriver}}|;
711
    
654 712
    $sth = $dbh->prepare($query);
655 713
    $sth->execute || $form->dberror($query);
656 714

  
bin/mozilla/io.pl
357 357
<input type=hidden name="listprice_$i" value="$form->{"listprice_$i"}">
358 358
<input type=hidden name="assembly_$i" value="$form->{"assembly_$i"}">
359 359
<input type=hidden name="taxaccounts_$i" value="$form->{"taxaccounts_$i"}">
360
<input type=hidden name="ordnumber_$i" value="$form->{"ordnumber_$i"}">
361
<input type=hidden name="transdate_$i" value="$form->{"transdate_$i"}">
362
<input type=hidden name="cusordnumber_$i" value="$form->{"cusordnumber_$i"}">
360 363

  
361 364
|;
362 365

  
bin/mozilla/oe.pl
1
#=====================================================================
1
# #=====================================================================
2 2
# LX-Office ERP
3 3
# Copyright (C) 2004
4 4
# Based on SQL-Ledger Version 2.1.9
......
77 77
sub edit {
78 78
  $lxdebug->enter_sub();
79 79

  
80
  # editing without stuff to edit? try adding it first
81
  if ($form->{rowcount}) {
82
    map {$id++ if $form->{"id_$_"}} (1 .. $form->{rowcount});
83
    if (!$id) {
84
      # reset rowcount
85
      undef $form->{rowcount};
86
      &add;
87
      return;
88
    }
89
  } else {
90
    if (!$form->{id}) {
91
      &add;
92
      return;
93
    }
94
  }
95

  
80 96
  if ($form->{type} eq 'purchase_order') {
81 97
    $form->{title}   = $locale->text('Edit Purchase Order');
82 98
    $form->{heading} = $locale->text('Purchase Order');
......
121 137

  
122 138
  OE->retrieve(\%myconfig, \%$form);
123 139

  
140
  # if multiple rowcounts (== collective order) then check if the
141
  # there were more than one customer (in that case OE::retrieve removes 
142
  # the content from the field)
143
  if ($form->{rowcount} && $form->{type} eq 'sales_order' && $form->{customer} eq '') {
144
#    $main::lxdebug->message(0, "Detected Edit order with concurrent customers");
145
    $form->error($locale->text('Collective Orders only work for orders from one customer!'));
146
  }
147

  
124 148
  $taxincluded = $form->{taxincluded};
125 149
  $form->{shipto} = 1 if $form->{id};
126 150

  
......
197 221
  $form->{media}    = "screen";
198 222
  $form->{formname} = $form->{type};
199 223

  
200
  if ($form->{id}) {
201

  
202 224
    map { $form->{$_} =~ s/\"/&quot;/g }
203 225
      qw(ordnumber quonumber shippingpoint shipvia notes intnotes shiptoname shiptostreet shiptozipcode shiptocity shiptocountry shiptocontact);
204 226

  
205 227
    foreach $ref (@{ $form->{form_details} }) {
206
      $i++;
207
      map { $form->{"${_}_$i"} = $ref->{$_} } keys %{$ref};
208
      $form->{"discount_$i"} =
209
        $form->format_amount(\%myconfig, $form->{"discount_$i"} * 100);
228
      $form->{rowcount} = ++$i;
210 229

  
211
      ($dec) = ($form->{"sellprice_$i"} =~ /\.(\d+)/);
212
      $dec           = length $dec;
213
      $decimalplaces = ($dec > 2) ? $dec : 2;
214

  
215
      $form->{"sellprice_$i"} =
216
        $form->format_amount(\%myconfig, $form->{"sellprice_$i"},
217
                             $decimalplaces);
218

  
219
      (my $dec_qty) = ($form->{"qty_$i"} =~ /\.(\d+)/);
220
      $dec_qty      = length $dec_qty;
221

  
222
      $form->{"qty_$i"} = $form->format_amount(\%myconfig, $form->{"qty_$i"}, $dec_qty);
223

  
224
      map { $form->{"${_}_$i"} =~ s/\"/&quot;/g }
225
        qw(partnumber description unit);
226
      $form->{rowcount} = $i;
230
      map { $form->{"${_}_$i"} = $ref->{$_} } keys %{$ref};
227 231
    }
228
  } elsif ($form->{rowcount}) {
232
    
229 233
    for my $i (1 .. $form->{rowcount}) {
230 234
       $form->{"discount_$i"} =
231 235
        $form->format_amount(\%myconfig, $form->{"discount_$i"} * 100);
232 236

  
233
      ($dec) = ($form->{"sellprice_$i"} =~ /\.(\d+)/);
237
      ($dec) = ($form->{"sellprice_$i"} =~ /\.(\d+)/);    
234 238
      $dec           = length $dec;
235 239
      $decimalplaces = ($dec > 2) ? $dec : 2;
236 240

  
......
245 249
      map { $form->{"${_}_$i"} =~ s/\"/&quot;/g }
246 250
        qw(partnumber description unit);
247 251
    }
248
  }
249 252

  
250 253
  $lxdebug->leave_sub();
251 254
}
......
860 863
        . $locale->text('Order') . qq|">
861 864
|;
862 865
    }
866
  } elsif ($form->{type} =~ /sales_order$/ && $form->{rowcount}) {
867
    print qq|
868
<br>Workflow  $form->{heading}<br>
869
<input class=submit type=submit name=action value="|
870
      . $locale->text('Save as new') . qq|">
871
<input class=submit type=submit name=action value="|
872
      . $locale->text('Invoice') . qq|">
873
|;
863 874
  }
875
  
864 876

  
865 877
  if ($form->{menubar}) {
866 878
    require "$form->{path}/menu.pl";
......
1312 1324
    }
1313 1325
  }
1314 1326

  
1327
  # only show checkboxes if gotten here via sales_order form.
1328
  if ($form->{type} =~ /sales_order/) {
1329
    unshift @column_index, "ids";
1330
  }
1331

  
1315 1332
  if ($form->{l_subtotal} eq 'Y') {
1316 1333
    $callback .= "&l_subtotal=Y";
1317 1334
    $href     .= "&l_subtotal=Y";
......
1384 1401
  $column_header{employee} =
1385 1402
    qq|<th><a class=listheading href=$href&sort=employee>$employee</a></th>|;
1386 1403

  
1404
  $column_header{ids} = qq|<th></th>|;
1405

  
1387 1406
  if ($form->{ $form->{vc} }) {
1388 1407
    $option = $locale->text(ucfirst $form->{vc});
1389 1408
    $option .= " : $form->{$form->{vc}}";
......
1423 1442
  print qq|
1424 1443
<body>
1425 1444

  
1445
<form method="post" action="oe.pl">
1426 1446
<table width=100%>
1427 1447
  <tr>
1428 1448
    <th class=listtop>$form->{title}</th>
......
1443 1463
|;
1444 1464

  
1445 1465
  # add sort and escape callback
1446
  $callback = $form->escape($callback . "&sort=$form->{sort}");
1466
  $callback_escaped = $form->escape($callback . "&sort=$form->{sort}");
1447 1467

  
1448 1468
  if (@{ $form->{OE} }) {
1449 1469
    $sameitem = $form->{OE}->[0]->{ $form->{sort} };
......
1455 1475
  $warehouse = $form->escape($form->{warehouse});
1456 1476

  
1457 1477
  foreach $oe (@{ $form->{OE} }) {
1478
    $form->{rowcount} = ++$j;
1458 1479

  
1459 1480
    if ($form->{l_subtotal} eq 'Y') {
1460 1481
      if ($sameitem ne $oe->{ $form->{sort} }) {
......
1483 1504
    $subtotalnetamount += $oe->{netamount};
1484 1505
    $subtotalamount    += $oe->{amount};
1485 1506

  
1507
    $column_data{ids}    = qq|<td><input name="id_$j" class=checkbox type=checkbox><input type="hidden" name="trans_id_$j" value="$oe->{id}"></td>|;
1486 1508
    $column_data{id}        = "<td>$oe->{id}</td>";
1487 1509
    $column_data{transdate} = "<td>$oe->{transdate}&nbsp;</td>";
1488 1510
    $column_data{reqdate}   = "<td>$oe->{reqdate}&nbsp;</td>";
1489 1511

  
1490 1512
    $column_data{$ordnumber} =
1491
      "<td><a href=oe.pl?path=$form->{path}&action=$action&type=$form->{type}&id=$oe->{id}&warehouse=$warehouse&vc=$form->{vc}&login=$form->{login}&password=$form->{password}&callback=$callback>$oe->{$ordnumber}</a></td>";
1513
      "<td><a href=oe.pl?path=$form->{path}&action=$action&type=$form->{type}&id=$oe->{id}&warehouse=$warehouse&vc=$form->{vc}&login=$form->{login}&password=$form->{password}&callback=$callback_escaped>$oe->{$ordnumber}</a></td>";
1492 1514
    $column_data{name} = "<td>$oe->{name}</td>";
1493 1515

  
1494 1516
    $column_data{employee} = "<td>$oe->{employee}&nbsp;</td>";
......
1546 1568
  <tr>
1547 1569
    <td><hr size=3 noshade></td>
1548 1570
  </tr>
1549
</table>
1571
</table>|;
1572

  
1573
# multiple invoice edit button only if gotten there via sales_order form.
1574

  
1575
if ($form->{type} =~ /sales_order/) {
1576
print qq|
1577
  <input type="hidden" name="path" value="$form->{path}">
1578
  <input class"submit" type="submit" name="action" value="|
1579
. $locale->text('Continue') .qq|">
1580
  <input type="hidden" name="nextsub" value="edit">
1581
  <input type="hidden" name="type" value="$form->{type}">
1582
  <input type="hidden" name="warehouse" value="$warehouse">
1583
  <input type="hidden" name="vc" value="$form->{vc}">
1584
  <input type="hidden" name="login" value="$form->{login}">
1585
  <input type="hidden" name="password" value="$form->{password}">
1586
  <input type="hidden" name="callback" value="$callback">
1587
  <input type="hidden" name="rowcount" value="$form->{rowcount}">|;
1588
}
1589

  
1590
print qq|
1591
</form>
1550 1592

  
1551 1593
<br>
1552 1594
<form method=post action=$form->{script}>
......
1751 1793
  $lxdebug->enter_sub();
1752 1794

  
1753 1795
  if ($form->{type} =~ /_order$/) {
1754
    $form->isblank("ordnumber", $locale->text('Order Number missing!'));
1755
    $form->isblank("transdate", $locale->text('Order Date missing!'));
1796
    # these checks only apply if the items don't bring their own ordnumbers/transdates.
1797
    # The if clause ensures that by searching for empty ordnumber_#/transdate_# fields.
1798
    $form->isblank("ordnumber", $locale->text('Order Number missing!')) if ( +{ map { $form->{"ordnumber_$_"}, 1 } ( 1 .. $form->{rowcount}-1 ) }->{''} );
1799
    $form->isblank("transdate", $locale->text('Order Date missing!'))   if ( +{ map { $form->{"transdate_$_"}, 1 } ( 1 .. $form->{rowcount}-1 ) }->{''} );
1756 1800

  
1757 1801
  } else {
1758 1802
    $form->isblank("quonumber", $locale->text('Quotation Number missing!'));
......
1788 1832

  
1789 1833
  # close orders/quotations
1790 1834
  $form->{closed} = 1;
1791
  OE->save(\%myconfig, \%$form);
1835

  
1836
  # save order iff one ordnumber has been given 
1837
  # if not it's most likely a collective order, which can't be saved back
1838
  # so they just have to be closed
1839
  if ($form->{ordnumber} ne '') {
1840
    OE->save(\%myconfig, \%$form);
1841
  } else {
1842
    OE->close_orders(\%myconfig, \%$form);
1843
  }
1792 1844

  
1793 1845
  $form->{transdate} = $form->{invdate} = $form->current_date(\%myconfig);
1794 1846
  $form->{duedate} =
locale/de/all
174 174
  'Closed'                      => 'Geschlossen',
175 175
  'Code'                        => 'kode',
176 176
  'Code missing!'               => 'kode fehlt!',
177
  'Collective Orders only work for orders from one customer!' => 'Sammelauftr?ge funktionieren nur f?r Auftr?ge von einem Kunden!',
177 178
  'Comment'                     => 'Kommentar',
178 179
  'Company'                     => 'Firma',
179 180
  'Company Name'                => 'Firmenname',
locale/en_GB/all
114 114
  'Click on login name to edit!' => '',
115 115
  'Close Books up to'           => '',
116 116
  'Closed'                      => '',
117
  'Collective Orders only work for orders from one customer!' => '',
117 118
  'Company'                     => '',
118 119
  'Compare to'                  => '',
119 120
  'Confirm!'                    => '',

Auch abrufbar als: Unified diff