do_query($form, $dbh, $query, $form->{id});
} else {
- my $uid = rand() . time;
-
- $uid .= $form->{login};
-
- $uid = substr($uid, 2, 75);
+ ($form->{id}) = selectrow_query($form, $dbh, qq|SELECT nextval('glid')|);
+
$query =
- qq|INSERT INTO ap (invnumber, employee_id,currency_id) | .
- qq|VALUES (?, (SELECT e.id FROM employee e WHERE e.login = ?),
+ qq|INSERT INTO ap (id, invnumber, employee_id,currency_id) | .
+ qq|VALUES (?, ?, (SELECT e.id FROM employee e WHERE e.login = ?),
(SELECT id FROM currencies WHERE name = ?) )|;
- do_query($form, $dbh, $query, $uid, $form->{login}, $form->{currency});
+ do_query($form, $dbh, $query, $form->{id}, $form->{invnumber}, $form->{login}, $form->{currency});
- $query = qq|SELECT a.id FROM ap a
- WHERE a.invnumber = ?|;
- ($form->{id}) = selectrow_query($form, $dbh, $query, $uid);
}
- $form->{invnumber} = $form->{id} unless $form->{invnumber};
-
$query = qq|UPDATE ap SET
- invnumber = ?, transdate = ?, ordnumber = ?, vendor_id = ?, taxincluded = ?,
+ transdate = ?, ordnumber = ?, vendor_id = ?, taxincluded = ?,
amount = ?, duedate = ?, paid = ?, netamount = ?,
currency_id = (SELECT id FROM currencies WHERE name = ?), notes = ?, department_id = ?, storno = ?, storno_id = ?,
globalproject_id = ?, direct_debit = ?
WHERE id = ?|;
- @values = ($form->{invnumber}, conv_date($form->{transdate}),
+ @values = (conv_date($form->{transdate}),
$form->{ordnumber}, conv_i($form->{vendor_id}),
$form->{taxincluded} ? 't' : 'f', $form->{invtotal},
conv_date($form->{duedate}), $form->{invpaid},
my ($inline) = @_;
- # check if there is a vendor, invoice and due date
+ # check if there is a vendor, invoice, due date and invnumber
$form->isblank("transdate", $locale->text("Invoice Date missing!"));
$form->isblank("duedate", $locale->text("Due Date missing!"));
$form->isblank("vendor", $locale->text('Vendor missing!'));
+ $form->isblank("invnumber", $locale->text('Invoice Number missing!'));
if ($myconfig{mandatory_departments} && !$form->{department}) {
$form->{saved_message} = $::locale->text('You have to specify a department.');