X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FIS.pm;h=b595616565fb1b17d9343915f177f58f28506f57;hb=8e2065873b0e00dde437383bb22c57be508e331f;hp=f546b51078036e56789b0f11d09c5b27debdca39;hpb=b9b02c1a0d19519228670ffdc491df9064199ff5;p=kivitendo-erp.git diff --git a/SL/IS.pm b/SL/IS.pm index f546b5107..b59561656 100644 --- a/SL/IS.pm +++ b/SL/IS.pm @@ -36,6 +36,8 @@ package IS; use Data::Dumper; use SL::AM; +use SL::Common; +use SL::DBUtils; sub invoice_details { $main::lxdebug->enter_sub(); @@ -474,8 +476,6 @@ sub post_invoice { $form->get_employee($dbh); } - $form->{contact_id} = $form->{cp_id}; - $form->{contact_id} *= 1; $form->{payment_id} *= 1; $form->{language_id} *= 1; $form->{taxzone_id} *= 1; @@ -978,36 +978,38 @@ Message: $form->{message}\r| if $form->{message}; # save AR record $query = qq|UPDATE ar set invnumber = '$form->{invnumber}', - ordnumber = '$form->{ordnumber}', - quonumber = '$form->{quonumber}', - cusordnumber = '$form->{cusordnumber}', + ordnumber = '$form->{ordnumber}', + quonumber = '$form->{quonumber}', + cusordnumber = '$form->{cusordnumber}', transdate = '$form->{invdate}', + orddate = | . conv_dateq($form->{orddate}) . qq|, + quodate = | . conv_dateq($form->{quodate}) . qq|, customer_id = $form->{customer_id}, amount = $amount, netamount = $netamount, paid = $form->{paid}, - datepaid = $datepaid, - duedate = $duedate, + datepaid = $datepaid, + duedate = $duedate, deliverydate = $deliverydate, - invoice = '1', - shippingpoint = '$form->{shippingpoint}', - shipvia = '$form->{shipvia}', - terms = $form->{terms}, - notes = '$form->{notes}', - intnotes = '$form->{intnotes}', - taxincluded = '$form->{taxincluded}', - curr = '$form->{currency}', - department_id = $form->{department_id}, - payment_id = $form->{payment_id}, + invoice = '1', + shippingpoint = '$form->{shippingpoint}', + shipvia = '$form->{shipvia}', + terms = $form->{terms}, + notes = '$form->{notes}', + intnotes = '$form->{intnotes}', + taxincluded = '$form->{taxincluded}', + curr = '$form->{currency}', + department_id = $form->{department_id}, + payment_id = $form->{payment_id}, type = '$form->{type}', - language_id = $form->{language_id}, - taxzone_id = $form->{taxzone_id}, - shipto_id = $form->{shipto_id}, - delivery_customer_id = $form->{delivery_customer_id}, - delivery_vendor_id = $form->{delivery_vendor_id}, - employee_id = $form->{employee_id}, + language_id = $form->{language_id}, + taxzone_id = $form->{taxzone_id}, + shipto_id = $form->{shipto_id}, + delivery_customer_id = $form->{delivery_customer_id}, + delivery_vendor_id = $form->{delivery_vendor_id}, + employee_id = $form->{employee_id}, storno = '$form->{storno}', - cp_id = $form->{contact_id} + cp_id = | . conv_i($form->{"cp_id"}, 'NULL') . qq| WHERE id = $form->{id} |; $dbh->do($query) || $form->dberror($query); @@ -1037,9 +1039,7 @@ Message: $form->{message}\r| if $form->{message}; # save printed, emailed and queued $form->save_status($dbh); - if ($form->{webdav}) { - &webdav_folder($myconfig, $form); - } + Common::webdav_folder($form) if ($main::webdav); my $rc = $dbh->commit; $dbh->disconnect; @@ -1484,6 +1484,7 @@ sub retrieve_invoice { # retrieve invoice $query = qq|SELECT a.invnumber, a.ordnumber, a.quonumber, a.cusordnumber, + a.orddate, a.quodate, a.transdate AS invdate, a.deliverydate, a.paid, a.storno, a.gldate, a.shippingpoint, a.shipvia, a.terms, a.notes, a.intnotes, a.taxzone_id, a.duedate, a.taxincluded, a.curr AS currency, a.shipto_id, a.cp_id, @@ -1656,9 +1657,7 @@ sub retrieve_invoice { } $sth->finish; - if ($form->{webdav}) { - &webdav_folder($myconfig, $form); - } + Common::webdav_folder($form) if ($main::webdav); } my $rc = $dbh->commit; @@ -1771,14 +1770,6 @@ sub get_customer { } $sth->finish; - $form->get_contacts($dbh, $form->{customer_id}); - $form->{cp_id} *= 1; - - # get contact if selected - if ($form->{cp_id}) { - $form->get_contact($dbh, $form->{cp_id}); - } - # get shipto if we did not converted an order or invoice if (!$form->{shipto}) { map { delete $form->{$_} } @@ -1809,19 +1800,6 @@ sub get_customer { } $sth->finish; - # get shipping addresses - $query = qq|SELECT s.shipto_id,s.shiptoname,s.shiptodepartment_1 - FROM shipto s - WHERE s.trans_id = $form->{customer_id}|; - $sth = $dbh->prepare($query); - $sth->execute || $form->dberror($query); - - my $customertax = (); - while ($ref = $sth->fetchrow_hashref(NAME_lc)) { - push(@{ $form->{SHIPTO} }, $ref); - } - $sth->finish; - # setup last accounts used for this customer if (!$form->{id} && $form->{type} !~ /_(order|quotation)/) { $query = qq|SELECT c.accno, c.description, c.link, c.category @@ -2204,36 +2182,5 @@ sub get_pricegroups_for_parts { $main::lxdebug->leave_sub(); } -sub webdav_folder { - $main::lxdebug->enter_sub(); - - my ($myconfig, $form) = @_; - -SWITCH: { - $path = "webdav/rechnungen/" . $form->{invnumber}, last SWITCH - if ($form->{vc} eq "customer"); - $path = "webdav/einkaufsrechnungen/" . $form->{invnumber}, last SWITCH - if ($form->{vc} eq "vendor"); - } - - if (!-d $path) { - mkdir($path, 0770) or die "can't make directory $!\n"; - } else { - if ($form->{id}) { - @files = <$path/*>; - foreach $file (@files) { - $file =~ /\/([^\/]*)$/; - $fname = $1; - $ENV{'SCRIPT_NAME'} =~ /\/([^\/]*)\//; - $lxerp = $1; - $link = "http://" . $ENV{'SERVER_NAME'} . "/" . $lxerp . "/" . $file; - $form->{WEBDAV}{$fname} = $link; - } - } - } - - $main::lxdebug->leave_sub(); -} - 1;