taxkey,
taxdescription,
round(rate * 100, 2) AS rate,
- chart_id
+ chart_id,
+ (id IN (SELECT tax_id
+ FROM acc_trans)) AS tax_already_used
FROM tax
WHERE id = ? |;
# insert detail records in acc_trans
$query =
qq|INSERT INTO acc_trans | .
- qq| (trans_id, chart_id, amount, transdate, project_id, taxkey, tax_id)| .
+ qq| (trans_id, chart_id, amount, transdate, project_id, taxkey, tax_id, chart_link)| .
qq|VALUES (?, (SELECT c.id FROM chart c WHERE c.accno = ?), | .
- qq| ?, ?, ?, ?, ?)|;
+ qq| ?, ?, ?, ?, ?,| .
+ qq| (SELECT c.link FROM chart c WHERE c.accno = ?))|;
@values = ($form->{id}, $form->{AP_amounts}{"amount_$i"},
$form->{"amount_$i"}, conv_date($form->{transdate}),
- $project_id, $form->{"taxkey_$i"}, conv_i($form->{"tax_id_$i"}));
+ $project_id, $form->{"taxkey_$i"}, conv_i($form->{"tax_id_$i"}),
+ $form->{AP_amounts}{"amount_$i"});
do_query($form, $dbh, $query, @values);
if ($form->{"tax_$i"} != 0) {
# insert detail records in acc_trans
$query =
qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, | .
- qq| project_id, taxkey, tax_id) | .
+ qq| project_id, taxkey, tax_id, chart_link) | .
qq|VALUES (?, (SELECT c.id FROM chart c WHERE c.accno = ?), | .
- qq| ?, ?, ?, ?, ?)|;
+ qq| ?, ?, ?, ?, ?,| .
+ qq| (SELECT c.link FROM chart c WHERE c.accno = ?))|;
@values = ($form->{id}, $form->{AP_amounts}{"tax_$i"},
$form->{"tax_$i"}, conv_date($form->{transdate}),
- $project_id, $form->{"taxkey_$i"}, conv_i($form->{"tax_id_$i"}));
+ $project_id, $form->{"taxkey_$i"}, conv_i($form->{"tax_id_$i"}),
+ $form->{AP_amounts}{"tax_$i"});
do_query($form, $dbh, $query, @values);
}
# add payables
$query =
- qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, taxkey, tax_id) | .
+ qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, taxkey, tax_id, chart_link) | .
qq|VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, | .
qq| (SELECT taxkey_id FROM chart WHERE accno = ?),| .
qq| (SELECT tax_id| .
qq| FROM chart| .
qq| WHERE accno = ?)| .
qq| AND startdate <= ?| .
- qq| ORDER BY startdate DESC LIMIT 1))|;
+ qq| ORDER BY startdate DESC LIMIT 1),| .
+ qq| (SELECT c.link FROM chart c WHERE c.accno = ?))|;
@values = ($form->{id}, $form->{AP_amounts}{payables}, $form->{payables},
- conv_date($form->{transdate}), $form->{AP_amounts}{payables}, $form->{AP_amounts}{payables}, conv_date($form->{transdate}));
+ conv_date($form->{transdate}), $form->{AP_amounts}{payables}, $form->{AP_amounts}{payables}, conv_date($form->{transdate}),
+ $form->{AP_amounts}{payables});
do_query($form, $dbh, $query, @values);
}
2);
if ($form->{payables}) {
$query =
- qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, project_id, taxkey, tax_id) | .
+ qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, project_id, taxkey, tax_id, chart_link) | .
qq|VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, ?, | .
qq| (SELECT taxkey_id FROM chart WHERE accno = ?),| .
qq| (SELECT tax_id| .
qq| FROM chart| .
qq| WHERE accno = ?)| .
qq| AND startdate <= ?| .
- qq| ORDER BY startdate DESC LIMIT 1))|;
+ qq| ORDER BY startdate DESC LIMIT 1),| .
+ qq| (SELECT c.link FROM chart c WHERE c.accno = ?))|;
@values = ($form->{id}, $form->{AP_payables}, $amount,
conv_date($form->{"datepaid_$i"}), $project_id,
- $form->{AP_payables}, $form->{AP_payables}, conv_date($form->{"datepaid_$i"}));
+ $form->{AP_payables}, $form->{AP_payables}, conv_date($form->{"datepaid_$i"}),
+ $form->{AP_payables});
do_query($form, $dbh, $query, @values);
}
$form->{payables} = $amount;
# add payment
my $gldate = (conv_date($form->{"gldate_$i"}))? conv_date($form->{"gldate_$i"}) : conv_date($form->current_date($myconfig));
$query =
- qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, gldate, source, memo, project_id, taxkey, tax_id) | .
+ qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, gldate, source, memo, project_id, taxkey, tax_id, chart_link) | .
qq|VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, ?, ?, ?, ?, | .
qq| (SELECT taxkey_id FROM chart WHERE accno = ?), | .
qq| (SELECT tax_id| .
qq| FROM chart| .
qq| WHERE accno = ?)| .
qq| AND startdate <= ?| .
- qq| ORDER BY startdate DESC LIMIT 1))|;
+ qq| ORDER BY startdate DESC LIMIT 1),| .
+ qq| (SELECT c.link FROM chart c WHERE c.accno = ?))|;
@values = ($form->{id}, $form->{"AP_paid_account_$i"}, $form->{"paid_$i"},
conv_date($form->{"datepaid_$i"}), $gldate, $form->{"source_$i"},
$form->{"memo_$i"}, $project_id, $form->{"AP_paid_account_$i"},
- $form->{"AP_paid_account_$i"}, conv_date($form->{"datepaid_$i"}));
+ $form->{"AP_paid_account_$i"}, conv_date($form->{"datepaid_$i"}),
+ $form->{"AP_paid_account_$i"});
do_query($form, $dbh, $query, @values);
# add exchange rate difference
($form->{"exchangerate_$i"} - 1), 2);
if ($amount != 0) {
$query =
- qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, fx_transaction, cleared, project_id, taxkey, tax_id) | .
+ qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, fx_transaction, cleared, project_id, taxkey, tax_id, chart_link) | .
qq|VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, 't', 'f', ?, | .
qq| (SELECT taxkey_id FROM chart WHERE accno = ?), | .
qq| (SELECT tax_id| .
qq| FROM chart| .
qq| WHERE accno = ?)| .
qq| AND startdate <= ?| .
- qq| ORDER BY startdate DESC LIMIT 1))|;
+ qq| ORDER BY startdate DESC LIMIT 1),| .
+ qq| (SELECT c.link FROM chart c WHERE c.accno = ?))|;
@values = ($form->{id}, $form->{"AP_paid_account_$i"}, $amount,
conv_date($form->{"datepaid_$i"}), $project_id,
$form->{"AP_paid_account_$i"},
- $form->{"AP_paid_account_$i"}, conv_date($form->{"datepaid_$i"}));
+ $form->{"AP_paid_account_$i"}, conv_date($form->{"datepaid_$i"}),
+ $form->{"AP_paid_account_$i"});
do_query($form, $dbh, $query, @values);
}
if ($amount != 0) {
$query =
- qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, fx_transaction, cleared, project_id, taxkey, tax_id) | .
+ qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, fx_transaction, cleared, project_id, taxkey, tax_id, chart_link) | .
qq|VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, 't', 'f', ?, | .
qq| (SELECT taxkey_id FROM chart WHERE accno = ?)| .
qq| (SELECT tax_id| .
qq| FROM chart| .
qq| WHERE accno = ?)| .
qq| AND startdate <= ?| .
- qq| ORDER BY startdate DESC LIMIT 1))|;
- @values = ($form->{id}, ($amount > 0) ?
- $form->{fxgain_accno} : $form->{fxloss_accno},
+ qq| ORDER BY startdate DESC LIMIT 1),| .
+ qq| (SELECT c.link FROM chart c WHERE c.accno = ?))|;
+ @values = ($form->{id},
+ ($amount > 0) ? $form->{fxgain_accno} : $form->{fxloss_accno},
$amount, conv_date($form->{"datepaid_$i"}), $project_id,
- ($amount > 0) ?
- $form->{fxgain_accno} : $form->{fxloss_accno},
- ($amount > 0) ? $form->{fxgain_accno} : $form->{fxloss_accno}, conv_date($form->{"datepaid_$i"}));
+ ($amount > 0) ? $form->{fxgain_accno} : $form->{fxloss_accno},
+ ($amount > 0) ? $form->{fxgain_accno} : $form->{fxloss_accno}, conv_date($form->{"datepaid_$i"}),
+ ($amount > 0) ? $form->{fxgain_accno} : $form->{fxloss_accno});
do_query($form, $dbh, $query, @values);
}
my $project_id = conv_i($form->{"project_id_$i"});
# insert detail records in acc_trans
- $query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, project_id, taxkey, tax_id)
- VALUES (?, (SELECT c.id FROM chart c WHERE c.accno = ?), ?, ?, ?, ?, ?)|;
+ $query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, project_id, taxkey, tax_id, chart_link)
+ VALUES (?, (SELECT c.id FROM chart c WHERE c.accno = ?), ?, ?, ?, ?, ?, (SELECT c.link FROM chart c WHERE c.accno = ?))|;
@values = (conv_i($form->{id}), $form->{AR_amounts}{"amount_$i"}, conv_i($form->{"amount_$i"}), conv_date($form->{transdate}), $project_id,
- conv_i($form->{"taxkey_$i"}), conv_i($form->{"tax_id_$i"}));
+ conv_i($form->{"taxkey_$i"}), conv_i($form->{"tax_id_$i"}), $form->{AR_amounts}{"amount_$i"});
do_query($form, $dbh, $query, @values);
if ($form->{"tax_$i"} != 0) {
# insert detail records in acc_trans
- $query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, project_id, taxkey, tax_id)
- VALUES (?, (SELECT c.id FROM chart c WHERE c.accno = ?), ?, ?, ?, ?, ?)|;
+ $query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, project_id, taxkey, tax_id, chart_link)
+ VALUES (?, (SELECT c.id FROM chart c WHERE c.accno = ?), ?, ?, ?, ?, ?, (SELECT c.link FROM chart c WHERE c.accno = ?))|;
@values = (conv_i($form->{id}), $form->{AR_amounts}{"tax_$i"}, conv_i($form->{"tax_$i"}), conv_date($form->{transdate}), $project_id,
- conv_i($form->{"taxkey_$i"}), conv_i($form->{"tax_id_$i"}));
+ conv_i($form->{"taxkey_$i"}), conv_i($form->{"tax_id_$i"}), $form->{AR_amounts}{"tax_$i"});
do_query($form, $dbh, $query, @values);
}
}
}
# add recievables
- $query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, taxkey, tax_id)
+ $query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, taxkey, tax_id, chart_link)
VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, (SELECT taxkey_id FROM chart WHERE accno = ?),
(SELECT tax_id
FROM taxkeys
FROM chart
WHERE accno = ?)
AND startdate <= ?
- ORDER BY startdate DESC LIMIT 1))|;
+ ORDER BY startdate DESC LIMIT 1),
+ (SELECT c.link FROM chart c WHERE c.accno = ?))|;
@values = (conv_i($form->{id}), $form->{AR_amounts}{receivables}, conv_i($form->{receivables}), conv_date($form->{transdate}),
- $form->{AR_amounts}{receivables}, $form->{AR_amounts}{receivables}, conv_date($form->{transdate}));
+ $form->{AR_amounts}{receivables}, $form->{AR_amounts}{receivables}, conv_date($form->{transdate}), $form->{AR_amounts}{receivables});
do_query($form, $dbh, $query, @values);
} else {
if ($amount != 0) {
# add receivable
- $query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, project_id, taxkey, tax_id)
+ $query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, project_id, taxkey, tax_id, chart_link)
VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, ?, (SELECT taxkey_id FROM chart WHERE accno = ?),
(SELECT tax_id
FROM taxkeys
FROM chart
WHERE accno = ?)
AND startdate <= ?
- ORDER BY startdate DESC LIMIT 1))|;
- @values = (conv_i($form->{id}), $form->{AR}{receivables}, $amount, conv_date($form->{"datepaid_$i"}), $project_id, $form->{AR}{receivables}, $form->{AR}{receivables}, conv_date($form->{"datepaid_$i"}));
+ ORDER BY startdate DESC LIMIT 1),
+ (SELECT c.link FROM chart c WHERE c.accno = ?))|;
+ @values = (conv_i($form->{id}), $form->{AR}{receivables}, $amount, conv_date($form->{"datepaid_$i"}), $project_id, $form->{AR}{receivables}, $form->{AR}{receivables}, conv_date($form->{"datepaid_$i"}),
+ $form->{AR}{receivables});
+
do_query($form, $dbh, $query, @values);
}
my $project_id = conv_i($form->{"paid_project_id_$i"});
my $gldate = (conv_date($form->{"gldate_$i"}))? conv_date($form->{"gldate_$i"}) : conv_date($form->current_date($myconfig));
$amount = $form->{"paid_$i"} * -1;
- $query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, gldate, source, memo, project_id, taxkey, tax_id)
+ $query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, gldate, source, memo, project_id, taxkey, tax_id, chart_link)
VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, ?, ?, ?, ?, (SELECT taxkey_id FROM chart WHERE accno = ?),
(SELECT tax_id
FROM taxkeys
FROM chart
WHERE accno = ?)
AND startdate <= ?
- ORDER BY startdate DESC LIMIT 1))|;
+ ORDER BY startdate DESC LIMIT 1),
+ (SELECT c.link FROM chart c WHERE c.accno = ?))|;
@values = (conv_i($form->{id}), $form->{AR}{"paid_$i"}, $amount, conv_date($form->{"datepaid_$i"}), $gldate, $form->{"source_$i"}, $form->{"memo_$i"}, $project_id, $form->{AR}{"paid_$i"},
- $form->{AR}{"paid_$i"}, conv_date($form->{"datepaid_$i"}));
+ $form->{AR}{"paid_$i"}, conv_date($form->{"datepaid_$i"}), $form->{AR}{"paid_$i"});
do_query($form, $dbh, $query, @values);
# exchangerate difference for payment
$amount = $form->round_amount( $form->{"paid_$i"} * ($form->{"exchangerate_$i"} - 1) * -1, 2);
if ($amount != 0) {
- $query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, fx_transaction, cleared, project_id, taxkey, tax_id)
+ $query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, fx_transaction, cleared, project_id, taxkey, tax_id, chart_link)
VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, 't', 'f', ?, (SELECT taxkey_id FROM chart WHERE accno = ?),
(SELECT tax_id
FROM taxkeys
FROM chart
WHERE accno = ?)
AND startdate <= ?
- ORDER BY startdate DESC LIMIT 1))|;
+ ORDER BY startdate DESC LIMIT 1),
+ (SELECT c.link FROM chart c WHERE c.accno = ?))|;
@values = (conv_i($form->{id}), $form->{AR}{"paid_$i"}, $amount, conv_date($form->{"datepaid_$i"}), $project_id, $form->{AR}{"paid_$i"},
- $form->{AR}{"paid_$i"}, conv_date($form->{"datepaid_$i"}));
+ $form->{AR}{"paid_$i"}, conv_date($form->{"datepaid_$i"}), $form->{AR}{"paid_$i"});
do_query($form, $dbh, $query, @values);
}
if ($amount != 0) {
my $accno = ($amount > 0) ? $form->{fxgain_accno} : $form->{fxloss_accno};
- $query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, fx_transaction, cleared, project_id, taxkey, tax_id)
+ $query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, fx_transaction, cleared, project_id, taxkey, tax_id, chart_link)
VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, 't', 'f', ?, (SELECT taxkey_id FROM chart WHERE accno = ?),
(SELECT tax_id
FROM taxkeys
FROM chart
WHERE accno = ?)
AND startdate <= ?
- ORDER BY startdate DESC LIMIT 1))|;
- @values = (conv_i($form->{id}), $accno, $amount, conv_date($form->{"datepaid_$i"}), $project_id, $accno, $accno, conv_date($form->{"datepaid_$i"}));
+ ORDER BY startdate DESC LIMIT 1),
+ (SELECT c.link FROM chart c WHERE c.accno = ?))|;
+ @values = (conv_i($form->{id}), $accno, $amount, conv_date($form->{"datepaid_$i"}), $project_id, $accno, $accno, conv_date($form->{"datepaid_$i"}), $accno);
do_query($form, $dbh, $query, @values);
}
}
LEFT JOIN vendor v on (v.id = ap.vendor_id)
WHERE storno_id is null AND storno is true AND ap.id not in (SELECT storno_id FROM ap WHERE storno_id is not null AND storno is true);
|;
-
+
my $stornos_ohne_partner = selectall_hashref_query($::form, $self->dbh, $query);
$self->tester->ok(@$stornos_ohne_partner == 0, 'Es sollte keine Stornos ohne Partner geben');
my $where = "1 = 1";
my @values;
- my %allowed_sort_columns =
- map { $_, 1 } qw(
- id customernumber vendornumber name contact phone fax email street
- taxnumber business invnumber ordnumber quonumber zipcode city
+ my %allowed_sort_columns = (
+ "id" => "id",
+ "customernumber" => "customernumber",
+ "vendornumber" => "vendornumber",
+ "name" => "ct.name",
+ "contact" => "contact",
+ "phone" => "phone",
+ "fax" => "fax",
+ "email" => "email",
+ "street" => "street",
+ "taxnumber" => "taxnumber",
+ "business" => "business",
+ "invnumber" => "invnumber",
+ "ordnumber" => "ordnumber",
+ "quonumber" => "quonumber",
+ "zipcode" => "zipcode",
+ "city" => "city",
+ "country" => "country",
+ "salesman" => "e.name"
);
- my $sortorder = $form->{sort} && $allowed_sort_columns{$form->{sort}} ? $form->{sort} : "name";
- $form->{sort} = $sortorder;
+
+ $form->{sort} ||= "name";
+ my $sortorder;
+ if ( $join_records ) {
+ # in UNION case order by hash key, e.g. salesman
+ # the UNION created an implicit select around the result
+ $sortorder = $allowed_sort_columns{$form->{sort}} ? $form->{sort} : "name";
+ } else {
+ # in not UNION case order by hash value, e.g. e.name
+ $sortorder = $allowed_sort_columns{$form->{sort}} ? $allowed_sort_columns{$form->{sort}} : "ct.name";
+ }
my $sortdir = !defined $form->{sortdir} ? 'ASC' : $form->{sortdir} ? 'ASC' : 'DESC';
if ($sortorder !~ /(business|id)/ && !$join_records) {
push @values, ('%' . $form->{addr_city} . '%') x 2;
}
+ if ($form->{addr_country}) {
+ $where .= " AND ((lower(ct.country) LIKE lower(?))
+ OR
+ (ct.id IN (
+ SELECT trans_id
+ FROM shipto
+ WHERE (module = 'CT')
+ AND (lower(shiptocountry) LIKE lower(?))
+ ))
+ )";
+ push @values, ('%' . $form->{addr_country} . '%') x 2;
+ }
+
if ( $form->{status} eq 'orphaned' ) {
$where .=
qq| AND ct.id NOT IN | .
}
my $query =
- qq|SELECT ct.*, b.description AS business | .
+ qq|SELECT ct.*, b.description AS business, e.name as salesman | .
(qq|, NULL AS invnumber, NULL AS ordnumber, NULL AS quonumber, NULL AS invid, NULL AS module, NULL AS formtype, NULL AS closed | x!! $join_records) .
qq|FROM $cv ct | .
qq|LEFT JOIN business b ON (ct.business_id = b.id) | .
+ qq|LEFT JOIN employee e ON (ct.salesman_id = e.id) | .
qq|WHERE $where|;
my @saved_values = @values;
push(@values, @saved_values);
$query .=
qq| UNION | .
- qq|SELECT ct.*, b.description AS business, | .
+ qq|SELECT ct.*, b.description AS business, e.name as salesman, | .
qq| a.invnumber, a.ordnumber, a.quonumber, a.id AS invid, | .
qq| '$module' AS module, 'invoice' AS formtype, | .
qq| (a.amount = a.paid) AS closed | .
qq|FROM $cv ct | .
qq|JOIN $ar a ON (a.${cv}_id = ct.id) | .
qq|LEFT JOIN business b ON (ct.business_id = b.id) | .
+ qq|LEFT JOIN employee e ON (ct.salesman_id = e.id) | .
qq|WHERE $where AND (a.invoice = '1')|;
}
push(@values, @saved_values);
$query .=
qq| UNION | .
- qq|SELECT ct.*, b.description AS business,| .
+ qq|SELECT ct.*, b.description AS business, e.name as salesman, | .
qq| ' ' AS invnumber, o.ordnumber, o.quonumber, o.id AS invid, | .
qq| 'oe' AS module, 'order' AS formtype, o.closed | .
qq|FROM $cv ct | .
qq|JOIN oe o ON (o.${cv}_id = ct.id) | .
qq|LEFT JOIN business b ON (ct.business_id = b.id) | .
+ qq|LEFT JOIN employee e ON (ct.salesman_id = e.id) | .
qq|WHERE $where AND (o.quotation = '0')|;
}
push(@values, @saved_values);
$query .=
qq| UNION | .
- qq|SELECT ct.*, b.description AS business, | .
+ qq|SELECT ct.*, b.description AS business, e.name as salesman, | .
qq| ' ' AS invnumber, o.ordnumber, o.quonumber, o.id AS invid, | .
qq| 'oe' AS module, 'quotation' AS formtype, o.closed | .
qq|FROM $cv ct | .
qq|JOIN oe o ON (o.${cv}_id = ct.id) | .
qq|LEFT JOIN business b ON (ct.business_id = b.id) | .
+ qq|LEFT JOIN employee e ON (ct.salesman_id = e.id) | .
qq|WHERE $where AND (o.quotation = '1')|;
}
}
$query = qq|SELECT * FROM contacts WHERE (cp_cv_id = ?)|;
$form->{CONTACTS} = selectall_hashref_query($form, $dbh, $query, $vc_id);
+ # Only show default pricegroup for customer, not vendor, which is why this is outside the main query
+ ($form->{pricegroup}) = selectrow_query($form, $dbh, qq|SELECT pricegroup FROM pricegroup WHERE id = ?|, $form->{klass});
+
$dbh->disconnect();
$main::lxdebug->leave_sub();
croak "Unsupported type: " . $options->{type} unless $options->{type} =~ m/^(?:html|js|json)$/;
# The "template" argument must be a string or a reference to one.
+ $template = ${ $template } if ((ref($template) || '') eq 'REF') && (ref(${ $template }) eq 'SL::Presenter::EscapedText');
croak "Unsupported 'template' reference type: " . ref($template) if ref($template) && (ref($template) !~ m/^(?:SCALAR|SL::Presenter::EscapedText)$/);
# If all output is turned off then don't output the header either.
scalar's content is used as the content to process. The C<type> option
is not considered in this case.
+C<$template> can also be an instance of L<SL::Presenter::EscapedText>
+or a reference to such an instance. Both of these cases are handled
+the same way as if C<$template> were a reference to a scalar: its
+content is processed, and C<type> is not considered.
+
Other reference types, unknown options and unknown arguments to the
C<type> option cause the function to L<croak>.
--- /dev/null
+package SL::Controller::RecordLinks;
+
+use strict;
+
+use parent qw(SL::Controller::Base);
+
+use SL::DB::Order;
+use SL::DB::DeliveryOrder;
+use SL::DB::Invoice;
+use SL::DB::PurchaseInvoice;
+use SL::Locale::String;
+
+#
+# actions
+#
+
+sub action_ajax_list {
+ my ($self) = @_;
+
+ eval {
+ die $::locale->text("Invalid parameters") if (!$::form->{object_id} || ($::form->{object_model} !~ m/^(?:Order|DeliveryOrder|Invoice|PurchaseInvoice)$/));
+
+ my $model = 'SL::DB::' . $::form->{object_model};
+ my $object = $model->new(id => $::form->{object_id})->load || die $::locale->text("Record not found");
+ my $linked_records = $object->linked_records(direction => 'both');
+ my $output = SL::Presenter->get->grouped_record_list($linked_records);
+ $self->render(\$output, { layout => 0, process => 0 });
+
+ 1;
+ } or do {
+ $self->render('generic/error', { layout => 0 }, label_error => $@);
+ };
+}
+
+1;
next;
}
- # determine at which array position the reference value (called absumsatz) is
+ # determine at which array position the reference value (called absumsatz) is
# and which amount it has
for my $j (0 .. (scalar(@{$trans}) - 1)) {
-
+
# Three cases:
# 1: gl transaction (Dialogbuchung), invoice is false, no double split booking allowed
my ($self, $entries) = @_;
my $default_tax_id = SL::DB::Manager::Tax->find_by(taxkey => 0)->id;
+ my $chart_link;
while (my ($chart_id, $spec) = each %{ $entries }) {
$spec = { taxkey => 0, tax_id => $default_tax_id, amount => $spec } unless ref $spec;
+ $chart_link = SL::DB::Manager::Chart->find_by(id => $chart_id)->{'link'};
+ $chart_link ||= '';
+
SL::DB::AccTransaction->new(trans_id => $self->id,
chart_id => $chart_id,
amount => $spec->{amount},
tax_id => $spec->{tax_id},
taxkey => $spec->{taxkey},
project_id => $self->globalproject_id,
- transdate => $self->transdate)->save;
+ transdate => $self->transdate,
+ chart_link => $chart_link)->save;
}
}
itime => { type => 'timestamp', default => 'now()' },
mtime => { type => 'timestamp' },
tax_id => { type => 'integer', not_null => 1 },
+ chart_link => { type => 'text', not_null => 1 },
],
primary_key_columns => [ 'acc_trans_id' ],
class => 'SL::DB::Project',
key_columns => { project_id => 'id' },
},
+
+ tax => {
+ class => 'SL::DB::Tax',
+ key_columns => { tax_id => 'id' },
+ },
],
);
key_columns => { ar_chart_id => 'id' },
},
- oe => {
+ order => {
class => 'SL::DB::Order',
key_columns => { oe_id => 'id' },
},
use SL::DB::MetaSetup::PeriodicInvoicesConfig;
-__PACKAGE__->meta->add_relationships(
- order => {
- type => 'many to one',
- class => 'SL::DB::Order',
- column_map => { oe_id => 'id' },
- },
-);
-
-__PACKAGE__->meta->initialize;
-
# Creates get_all, get_all_count, get_all_iterator, delete_all and update_all.
__PACKAGE__->meta->make_manager_class;
push @header, "<meta http-equiv='refresh' content='$refresh_time;$refresh_url'>";
}
- push @header, map { qq|<link rel="stylesheet" href="$_" type="text/css" title="Stylesheet">| } $layout->stylesheets;
+ my $auto_reload_resources_param = $layout->auto_reload_resources_param;
+
+ push @header, map { qq|<link rel="stylesheet" href="${_}${auto_reload_resources_param}" type="text/css" title="Stylesheet">| } $layout->stylesheets;
push @header, "<style type='text/css'>\@page { size:landscape; }</style> " if $self->{landscape};
push @header, "<link rel='shortcut icon' href='$self->{favicon}' type='image/x-icon'>" if -f $self->{favicon};
- push @header, map { qq|<script type="text/javascript" src="$_"></script>| } $layout->javascripts;
+ push @header, map { qq|<script type="text/javascript" src="${_}${auto_reload_resources_param}"></script>| } $layout->javascripts;
push @header, $self->{javascript} if $self->{javascript};
push @header, map { $_->show_javascript } @{ $self->{AJAX} || [] };
if ($amount != 0) {
$query =
qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate,
- source, memo, project_id, taxkey, ob_transaction, cb_transaction, tax_id)
+ source, memo, project_id, taxkey, ob_transaction, cb_transaction, tax_id, chart_link)
VALUES (?, (SELECT id FROM chart WHERE accno = ?),
- ?, ?, ?, ?, ?, ?, ?, ?, ?)|;
+ ?, ?, ?, ?, ?, ?, ?, ?, ?, (SELECT link FROM chart WHERE accno = ?))|;
@values = (conv_i($form->{id}), $accno, $amount, conv_date($form->{transdate}),
- $form->{"source_$i"}, $form->{"memo_$i"}, $project_id, $taxkey, $form->{ob_transaction} ? 't' : 'f', $form->{cb_transaction} ? 't' : 'f', conv_i($form->{"tax_id_$i"}));
+ $form->{"source_$i"}, $form->{"memo_$i"}, $project_id, $taxkey, $form->{ob_transaction} ? 't' : 'f', $form->{cb_transaction} ? 't' : 'f', conv_i($form->{"tax_id_$i"}), $accno);
do_query($form, $dbh, $query, @values);
}
# add taxentry
$query =
qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate,
- source, memo, project_id, taxkey, tax_id)
+ source, memo, project_id, taxkey, tax_id, chart_link)
VALUES (?, (SELECT chart_id FROM tax WHERE id = ?),
- ?, ?, ?, ?, ?, ?, ?)|;
+ ?, ?, ?, ?, ?, ?, ?, (SELECT link
+ FROM chart
+ WHERE id = (SELECT chart_id
+ FROM tax
+ WHERE id = ?)))|;
@values = (conv_i($form->{id}), conv_i($form->{"tax_id_$i"}),
$tax, conv_date($form->{transdate}), $form->{"source_$i"},
- $form->{"memo_$i"}, $project_id, $taxkey, conv_i($form->{"tax_id_$i"}));
+ $form->{"memo_$i"}, $project_id, $taxkey, conv_i($form->{"tax_id_$i"}), conv_i($form->{"tax_id_$i"}));
do_query($form, $dbh, $query, @values);
}
}
push(@arvalues, '%' . $form->{description} . '%');
push(@apvalues, '%' . $form->{description} . '%');
}
-
+
if ($form->{employee} =~ /--/) {
($form->{employee_id},$form->{employee_name}) = split(/--/,$form->{employee});
#if ($form->{employee_id}) {
'source' => { 'gl' => 'ac.source', 'arap' => 'ac.source', },
'description' => { 'gl' => 'g.description', 'arap' => 'ct.name', },
);
-
+
# sortdir = sort direction (ascending or descending)
my $sortdir = !defined $form->{sortdir} ? 'ASC' : $form->{sortdir} ? 'ASC' : 'DESC';
my $sortkey = $sort_columns{$form->{sort}} ? $form->{sort} : $form->{datesort}; # default used to be transdate
# allocated >= 0
# add entry for inventory, this one is for the sold item
- $query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, taxkey, tax_id) VALUES (?, ?, ?, ?, (SELECT taxkey_id FROM chart WHERE id = ?),
- (SELECT tax_id
+ $query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, taxkey, tax_id) VALUES (?, ?, ?, ?,
+ (SELECT taxkey_id
+ FROM taxkeys
+ WHERE chart_id= ?
+ AND startdate <= ?
+ ORDER BY startdate DESC LIMIT 1),
+ (SELECT tax_id
FROM taxkeys
- WHERE chart_id= (SELECT id
- FROM chart
- WHERE accno = ?)
+ WHERE chart_id= ?
AND startdate <= ?
- ORDER BY startdate DESC LIMIT 1))|;
- @values = ($ref->{trans_id}, $ref->{inventory_accno_id}, $linetotal, $ref->{transdate}, $ref->{inventory_accno_id}, $ref->{inventory_accno_id}, $ref->{transdate});
+ ORDER BY startdate DESC LIMIT 1),
+ (SELECT chart_link FROM chart WHERE id = ?))|;
+ @values = ($ref->{trans_id}, $ref->{inventory_accno_id}, $linetotal, $ref->{transdate}, $ref->{inventory_accno_id}, $ref->{transdate}, $ref->{inventory_accno_id}, $ref->{transdate},
+ $ref->{inventory_accno_id});
do_query($form, $dbh, $query, @values);
# add expense
- $query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, taxkey, tax_id) VALUES (?, ?, ?, ?, (SELECT taxkey from tax WHERE chart_id = ?),
+ $query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, taxkey, tax_id) VALUES (?, ?, ?, ?,
+ (SELECT taxkey_id
+ FROM taxkeys
+ WHERE chart_id= ?
+ AND startdate <= ?
+ ORDER BY startdate DESC LIMIT 1),
(SELECT tax_id
FROM taxkeys
- WHERE chart_id= (SELECT id
- FROM chart
- WHERE accno = ?)
+ WHERE chart_id= ?
AND startdate <= ?
- ORDER BY startdate DESC LIMIT 1))|;
- @values = ($ref->{trans_id}, $ref->{expense_accno_id}, ($linetotal * -1), $ref->{transdate}, $ref->{expense_accno_id}, $ref->{expense_accno_id}, $ref->{transdate});
+ ORDER BY startdate DESC LIMIT 1),
+ (SELECT chart_link FROM chart WHERE id = ?))|;
+ @values = ($ref->{trans_id}, $ref->{expense_accno_id}, ($linetotal * -1), $ref->{transdate}, $ref->{expense_accno_id}, $ref->{transdate}, $ref->{expense_accno_id}, $ref->{transdate},
+ $ref->{expense_accno_id});
do_query($form, $dbh, $query, @values);
}
};
next if $payments_only || !$form->{amount}{$trans_id}{$accno};
- $query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, taxkey, project_id, tax_id)
+ $query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, taxkey, project_id, tax_id, chart_link)
VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?,
- (SELECT taxkey_id FROM chart WHERE accno = ?), ?,
+ (SELECT taxkey_id
+ FROM taxkeys
+ WHERE chart_id= (SELECT id
+ FROM chart
+ WHERE accno = ?)
+ AND startdate <= ?
+ ORDER BY startdate DESC LIMIT 1),
+ ?,
(SELECT tax_id
FROM taxkeys
WHERE chart_id= (SELECT id
FROM chart
WHERE accno = ?)
AND startdate <= ?
- ORDER BY startdate DESC LIMIT 1))|;
+ ORDER BY startdate DESC LIMIT 1),
+ (SELECT link FROM chart WHERE accno = ?))|;
@values = ($trans_id, $accno, $form->{amount}{$trans_id}{$accno},
- conv_date($form->{invdate}), $accno, $project_id, $accno, conv_date($form->{invdate}));
+ conv_date($form->{invdate}), $accno, conv_date($form->{invdate}), $project_id, $accno, conv_date($form->{invdate}), $accno);
do_query($form, $dbh, $query, @values);
}
}
# record AP
if ($form->{amount}{ $form->{id} }{ $form->{AP} } != 0) {
- $query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, taxkey, project_id, tax_id)
+ $query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, taxkey, project_id, tax_id, chart_link)
VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?,
- (SELECT taxkey_id FROM chart WHERE accno = ?), ?,
+ (SELECT taxkey_id
+ FROM taxkeys
+ WHERE chart_id= (SELECT id
+ FROM chart
+ WHERE accno = ?)
+ AND startdate <= ?
+ ORDER BY startdate DESC LIMIT 1),
+ ?,
(SELECT tax_id
FROM taxkeys
WHERE chart_id= (SELECT id
FROM chart
WHERE accno = ?)
AND startdate <= ?
- ORDER BY startdate DESC LIMIT 1))|;
+ ORDER BY startdate DESC LIMIT 1),
+ (SELECT link FROM chart WHERE accno = ?))|;
@values = (conv_i($form->{id}), $form->{AP}, $amount,
- $form->{"datepaid_$i"}, $form->{AP}, $project_id, $form->{AP}, conv_date($form->{"datepaid_$i"}));
+ $form->{"datepaid_$i"}, $form->{AP}, conv_date($form->{"datepaid_$i"}), $project_id, $form->{AP}, conv_date($form->{"datepaid_$i"}), $form->{AP});
do_query($form, $dbh, $query, @values);
}
my $gldate = (conv_date($form->{"gldate_$i"}))? conv_date($form->{"gldate_$i"}) : conv_date($form->current_date($myconfig));
$query =
- qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, gldate, source, memo, taxkey, project_id, tax_id)
+ qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, gldate, source, memo, taxkey, project_id, tax_id, chart_link)
VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, ?, ?, ?,
- (SELECT taxkey_id FROM chart WHERE accno = ?), ?,
+ (SELECT taxkey_id
+ FROM taxkeys
+ WHERE chart_id= (SELECT id
+ FROM chart WHERE accno = ?)
+ AND startdate <= ?
+ ORDER BY startdate DESC LIMIT 1),
+ ?,
(SELECT tax_id
FROM taxkeys
WHERE chart_id= (SELECT id
FROM chart WHERE accno = ?)
AND startdate <= ?
- ORDER BY startdate DESC LIMIT 1))|;
+ ORDER BY startdate DESC LIMIT 1),
+ (SELECT link FROM chart WHERE accno = ?))|;
@values = (conv_i($form->{id}), $accno, $form->{"paid_$i"}, $form->{"datepaid_$i"},
- $gldate, $form->{"source_$i"}, $form->{"memo_$i"}, $accno, $project_id, $accno, conv_date($form->{"datepaid_$i"}));
+ $gldate, $form->{"source_$i"}, $form->{"memo_$i"}, $accno, conv_date($form->{"datepaid_$i"}), $project_id, $accno, conv_date($form->{"datepaid_$i"}), $accno);
do_query($form, $dbh, $query, @values);
$exchangerate = 0;
$form->{fx}{$accno}{$transdate} = $form->round_amount($form->{fx}{$accno}{$transdate}, 2);
next if ($form->{fx}{$accno}{$transdate} == 0);
- $query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, cleared, fx_transaction, taxkey, project_id, tax_id)
+ $query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, cleared, fx_transaction, taxkey, project_id, tax_id, chart_link)
VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, '0', '1', 0, ?,
- (SELECT tax_id
- FROM taxkeys
- WHERE chart_id= (SELECT id
- FROM chart
- WHERE accno = ?)
- AND startdate <= ?
- ORDER BY startdate DESC LIMIT 1))|;
- @values = (conv_i($form->{id}), $accno, $form->{fx}{$accno}{$transdate}, conv_date($transdate), $project_id, $accno, $form->{fx}{$accno}{$transdate});
+ (SELECT id FROM tax WHERE taxkey=0 LIMIT 1),
+ (SELECT link FROM chart WHERE accno = ?))|;
+ @values = (conv_i($form->{id}), $accno, $form->{fx}{$accno}{$transdate}, conv_date($transdate), $project_id, $accno);
do_query($form, $dbh, $query, @values);
}
}
if (!$payments_only && ($form->{amount_cogs}{$trans_id}{$accno} != 0)) {
$query =
- qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, tax_id, taxkey, project_id)
- VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, (SELECT id FROM tax WHERE taxkey=0), 0, ?)|;
- @values = (conv_i($trans_id), $accno, $form->{amount_cogs}{$trans_id}{$accno}, conv_date($form->{invdate}), conv_i($project_id));
+ qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, tax_id, taxkey, project_id, chart_link)
+ VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, (SELECT id FROM tax WHERE taxkey=0), 0, ?, (SELECT link FROM chart WHERE accno = ?))|;
+ @values = (conv_i($trans_id), $accno, $form->{amount_cogs}{$trans_id}{$accno}, conv_date($form->{invdate}), conv_i($project_id), $accno);
do_query($form, $dbh, $query, @values);
$form->{amount_cogs}{$trans_id}{$accno} = 0;
}
if (!$payments_only && ($form->{amount_cogs}{$trans_id}{$accno} != 0)) {
$query =
- qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, tax_id, taxkey, project_id)
- VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, (SELECT id FROM tax WHERE taxkey=0), 0, ?)|;
- @values = (conv_i($trans_id), $accno, $form->{amount_cogs}{$trans_id}{$accno}, conv_date($form->{invdate}), conv_i($project_id));
+ qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, tax_id, taxkey, project_id, chart_link)
+ VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, (SELECT id FROM tax WHERE taxkey=0), 0, ?, (SELECT link FROM chart WHERE accno = ?))|;
+ @values = (conv_i($trans_id), $accno, $form->{amount_cogs}{$trans_id}{$accno}, conv_date($form->{invdate}), conv_i($project_id), $accno);
do_query($form, $dbh, $query, @values);
}
}
if (!$payments_only && ($form->{amount}{$trans_id}{$accno} != 0)) {
$query =
- qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, tax_id, taxkey, project_id)
+ qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, tax_id, taxkey, project_id, chart_link)
VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?,
(SELECT tax_id
FROM taxkeys
WHERE accno = ?)
AND startdate <= ?
ORDER BY startdate DESC LIMIT 1),
- (SELECT taxkey_id FROM chart WHERE accno = ?), ?)|;
- @values = (conv_i($trans_id), $accno, $form->{amount}{$trans_id}{$accno}, conv_date($form->{invdate}), $accno, conv_date($taxdate), $accno, conv_i($project_id));
+ (SELECT taxkey_id
+ FROM taxkeys
+ WHERE chart_id= (SELECT id
+ FROM chart
+ WHERE accno = ?)
+ AND startdate <= ?
+ ORDER BY startdate DESC LIMIT 1),
+ ?,
+ (SELECT link FROM chart WHERE accno = ?))|;
+ @values = (conv_i($trans_id), $accno, $form->{amount}{$trans_id}{$accno}, conv_date($form->{invdate}), $accno, conv_date($taxdate), $accno, conv_date($taxdate), conv_i($project_id), $accno);
do_query($form, $dbh, $query, @values);
$form->{amount}{$trans_id}{$accno} = 0;
}
if (!$payments_only && ($form->{amount}{$trans_id}{$accno} != 0)) {
$query =
- qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, tax_id, taxkey, project_id)
+ qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, tax_id, taxkey, project_id, chart_link)
VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?,
(SELECT tax_id
FROM taxkeys
WHERE accno = ?)
AND startdate <= ?
ORDER BY startdate DESC LIMIT 1),
- (SELECT taxkey_id FROM chart WHERE accno = ?), ?)|;
- @values = (conv_i($trans_id), $accno, $form->{amount}{$trans_id}{$accno}, conv_date($form->{invdate}), $accno, conv_date($taxdate), $accno, conv_i($project_id));
+ (SELECT taxkey_id
+ FROM taxkeys
+ WHERE chart_id= (SELECT id
+ FROM chart
+ WHERE accno = ?)
+ AND startdate <= ?
+ ORDER BY startdate DESC LIMIT 1),
+ ?,
+ (SELECT link FROM chart WHERE accno = ?))|;
+ @values = (conv_i($trans_id), $accno, $form->{amount}{$trans_id}{$accno}, conv_date($form->{invdate}), $accno, conv_date($taxdate), $accno, conv_date($taxdate), conv_i($project_id), $accno);
do_query($form, $dbh, $query, @values);
}
}
if ($form->{amount}{ $form->{id} }{ $form->{AR} } != 0) {
$query =
- qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, tax_id, taxkey, project_id)
+ qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, tax_id, taxkey, project_id, chart_link)
VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?,
(SELECT tax_id
FROM taxkeys
WHERE accno = ?)
AND startdate <= ?
ORDER BY startdate DESC LIMIT 1),
- (SELECT taxkey_id FROM chart WHERE accno = ?), ?)|;
- @values = (conv_i($form->{"id"}), $form->{AR}, $amount, $form->{"datepaid_$i"}, $form->{AR}, conv_date($taxdate), $form->{AR}, $project_id);
+ (SELECT taxkey_id
+ FROM taxkeys
+ WHERE chart_id= (SELECT id
+ FROM chart
+ WHERE accno = ?)
+ AND startdate <= ?
+ ORDER BY startdate DESC LIMIT 1),
+ ?,
+ (SELECT link FROM chart WHERE accno = ?))|;
+ @values = (conv_i($form->{"id"}), $form->{AR}, $amount, $form->{"datepaid_$i"}, $form->{AR}, conv_date($taxdate), $form->{AR}, conv_date($taxdate), $project_id, $form->{AR});
do_query($form, $dbh, $query, @values);
}
my $gldate = (conv_date($form->{"gldate_$i"}))? conv_date($form->{"gldate_$i"}) : conv_date($form->current_date($myconfig));
$query =
- qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, gldate, source, memo, tax_id, taxkey, project_id)
+ qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, gldate, source, memo, tax_id, taxkey, project_id, chart_link)
VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, ?, ?, ?,
(SELECT tax_id
FROM taxkeys
WHERE accno = ?)
AND startdate <= ?
ORDER BY startdate DESC LIMIT 1),
- (SELECT taxkey_id FROM chart WHERE accno = ?), ?)|;
+ (SELECT taxkey_id
+ FROM taxkeys
+ WHERE chart_id= (SELECT id
+ FROM chart
+ WHERE accno = ?)
+ AND startdate <= ?
+ ORDER BY startdate DESC LIMIT 1),
+ ?,
+ (SELECT link FROM chart WHERE accno = ?))|;
@values = (conv_i($form->{"id"}), $accno, $form->{"paid_$i"}, $form->{"datepaid_$i"},
- $gldate, $form->{"source_$i"}, $form->{"memo_$i"}, $accno, conv_date($taxdate), $accno, $project_id);
+ $gldate, $form->{"source_$i"}, $form->{"memo_$i"}, $accno, conv_date($taxdate), $accno, conv_date($taxdate), $project_id, $accno);
do_query($form, $dbh, $query, @values);
# exchangerate difference
if ( $form->{fx}{$accno}{$transdate} != 0 ) {
$query =
- qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, cleared, fx_transaction, tax_id, taxkey, project_id)
+ qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, cleared, fx_transaction, tax_id, taxkey, project_id, chart_link)
VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, '0', '1',
(SELECT tax_id
FROM taxkeys
WHERE accno = ?)
AND startdate <= ?
ORDER BY startdate DESC LIMIT 1),
- (SELECT taxkey_id FROM chart WHERE accno = ?), ?)|;
- @values = (conv_i($form->{"id"}), $accno, $form->{fx}{$accno}{$transdate}, conv_date($transdate), $accno, conv_date($taxdate), $accno, conv_i($project_id));
+ (SELECT taxkey_id
+ FROM taxkeys
+ WHERE chart_id= (SELECT id
+ FROM chart
+ WHERE accno = ?)
+ AND startdate <= ?
+ ORDER BY startdate DESC LIMIT 1),
+ ?,
+ (SELECT link FROM chart WHERE accno = ?))|;
+ @values = (conv_i($form->{"id"}), $accno, $form->{fx}{$accno}{$transdate}, conv_date($transdate), $accno, conv_date($taxdate), $accno, conv_date($taxdate), conv_i($project_id), $accno);
do_query($form, $dbh, $query, @values);
}
}
use parent qw(SL::Controller::Base);
use List::MoreUtils qw(uniq);
+use Time::HiRes qw();
use Rose::Object::MakeMethods::Generic (
- 'scalar --get_set_init' => qw(menu),
+ 'scalar --get_set_init' => [ qw(menu auto_reload_resources_param) ],
'scalar' => qw(focus),
'array' => [
'add_stylesheets_inline' => { interface => 'add', hash_key => 'stylesheets_inline' },
Menu->new('menu.ini');
}
+sub init_auto_reload_resources_param {
+ return '' unless $::lx_office_conf{debug}->{auto_reload_resources};
+ return sprintf('?rand=%d-%d-%d', Time::HiRes::gettimeofday(), int(rand 1000000000000));
+}
+
##########################################
# inheritable/overridable
##########################################
}
sub uri_decode {
- my $str = $_[0] || '';
+ my $str = $_[0] // '';
$str =~ tr/+/ /;
$str =~ s/\\$//;
croak "Unsupported type: " . $options->{type} unless $options->{type} =~ m/^(?:html|js|json)$/;
# The "template" argument must be a string or a reference to one.
+ $template = ${ $template } if ((ref($template) || '') eq 'REF') && (ref(${ $template }) eq 'SL::Presenter::EscapedText');
croak "Unsupported 'template' reference type: " . ref($template) if ref($template) && (ref($template) !~ m/^(?:SCALAR|SL::Presenter::EscapedText)$/);
# Look for the file given by $template if $template is not a reference.
# If no processing is requested then return the content.
if (!$options->{process}) {
# If $template is a reference then don't try to read a file.
- return SL::Presenter::EscapedText->new(text => ${ $template }, is_escaped => 1) if ref $template;
+ my $ref = ref $template;
+ return $template if $ref eq 'SL::Presenter::EscapedText';
+ return SL::Presenter::EscapedText->new(text => ${ $template }, is_escaped => 1) if $ref eq 'SCALAR';
# Otherwise return the file's content.
my $file = IO::File->new($source, "r") || croak("Template file ${source} could not be read");
scalar's content is used as the content to process. The C<type> option
is not considered in this case.
+C<$template> can also be an instance of L<SL::Presenter::EscapedText>
+or a reference to such an instance. Both of these cases are handled
+the same way as if C<$template> were a reference to a scalar: its
+content is processed, and C<type> is not considered.
+
Other reference types, unknown options and unknown arguments to the
C<type> option cause the function to L<croak>.
AND ((c.link LIKE '%:${ARAP}') OR (c.link LIKE '${ARAP}:%') OR (c.link = '${ARAP}'))
LIMIT 1| ],
- 'add_acc_trans' => [ qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, gldate, source, memo)
- VALUES (?, ?, ?, ?, current_date, ?, '')| ],
+ 'add_acc_trans' => [ qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, gldate, source, memo, taxkey, tax_id , chart_link)
+ VALUES (?, ?, ?, ?, current_date, ?, '', 0, (SELECT id FROM tax WHERE taxkey=0 LIMIT 1), (SELECT link FROM chart WHERE id=?))| ],
'update_arap' => [ qq|UPDATE ${arap}
SET paid = paid + ?
my ($arap_chart_id) = $handles{get_arap}->[0]->fetchrow_array();
# Record the payment in acc_trans offsetting AR/AP.
- do_statement($form, @{ $handles{add_acc_trans} }, $orig_item->{"${arap}_id"}, $arap_chart_id, -1 * $mult * $orig_item->{amount}, $item->{execution_date}, '');
- do_statement($form, @{ $handles{add_acc_trans} }, $orig_item->{"${arap}_id"}, $orig_item->{chart_id}, $mult * $orig_item->{amount}, $item->{execution_date}, $orig_item->{reference});
+ do_statement($form, @{ $handles{add_acc_trans} }, $orig_item->{"${arap}_id"}, $arap_chart_id, -1 * $mult * $orig_item->{amount}, $item->{execution_date}, '', $arap_chart_id);
+ do_statement($form, @{ $handles{add_acc_trans} }, $orig_item->{"${arap}_id"}, $orig_item->{chart_id}, $mult * $orig_item->{amount}, $item->{execution_date}, $orig_item->{reference},
+ $orig_item->{chart_id});
# Update the invoice to reflect the new paid amount.
do_statement($form, @{ $handles{update_arap} }, $orig_item->{amount}, $orig_item->{"${arap}_id"});
my $query =
qq|SELECT ct.id as customerid, ct.name as customername,ct.customernumber,ct.country,ar.invnumber,ar.id,ar.transdate,p.partnumber,pg.partsgroup,i.parts_id,i.qty,i.price_factor,i.discount,i.description as description,i.lastcost,i.sellprice,i.fxsellprice,i.marge_total,i.marge_percent,i.unit,b.description as business,e.name as employee,e2.name as salesman, to_char(ar.transdate,'Month') as month, to_char(ar.transdate, 'YYYYMM') as nummonth, p.unit as parts_unit, p.weight | .
- qq|FROM invoice i | .
+ qq|FROM invoice i | .
qq|JOIN ar on (i.trans_id = ar.id) | .
qq|JOIN parts p on (i.parts_id = p.id) | .
qq|LEFT JOIN partsgroup pg on (p.partsgroup_id = pg.id) | .
push(@values, $form->{"project_id"}, $form->{"project_id"});
}
if ($form->{business_id}) {
- $where .= qq| AND ct.business_id = ? |;
+ $where .= qq| AND ct.business_id = ? |;
push(@values, $form->{"business_id"});
}
$where .= qq| AND ($cvar_where_ic)|;
push @values, @cvar_values_ic;
}
-
+
$query .= " WHERE $where ORDER BY $sortorder "; # LIMIT 5000";
my @result = selectall_hashref_query($form, $dbh, $query, @values);
$form->header();
+ #set readonly if the there are entries in acc_trans with the tax
+ my $readonly = $form->{tax_already_used} ? 'readonly' : '';
+
my $parameters_ref = {
+ readonly => $readonly,
};
# Ausgabe des Templates
$main::auth->assert('config');
- $form->isblank("rate", $locale->text('Taxrate missing!'));
- $form->isblank("taxdescription", $locale->text('Taxdescription missing!'));
- $form->isblank("taxkey", $locale->text('Taxkey missing!'));
+ $form->error($locale->text('Taxkey missing!')) unless length($form->{taxkey}) != 0;
+ $form->error($locale->text('Taxdescription missing!')) unless length($form->{taxdescription}) != 0;
+ $form->error($locale->text('Taxrate missing!')) unless length($form->{rate}) != 0;
$form->{rate} = $form->parse_amount(\%myconfig, $form->{rate});
+ if ($form->{taxkey} == 0 and $form->{rate} > 0) {
+ $form->error($locale->text('Taxkey 0 is reserved for rate 0'));
+ }
+
if ( $form->{rate} < 0 || $form->{rate} >= 100 ) {
$form->error($locale->text('Tax Percent is a number between 0 and 100'));
}
push @options, $locale->text('Billing/shipping address (city)') . " : $form->{addr_city}" if $form->{addr_city};
push @options, $locale->text('Billing/shipping address (zipcode)') . " : $form->{zipcode}" if $form->{addr_zipcode};
push @options, $locale->text('Billing/shipping address (street)') . " : $form->{street}" if $form->{addr_street};
+ push @options, $locale->text('Billing/shipping address (country)') . " : $form->{country}" if $form->{addr_country};
if ($form->{business_id}) {
my $business = SL::DB::Manager::Business->find_by(id => $form->{business_id});
}
my @columns = (
- 'id', 'name', "$form->{db}number", 'contact', 'phone',
- 'fax', 'email', 'taxnumber', 'street', 'zipcode' , 'city',
- 'business', 'invnumber', 'ordnumber', 'quonumber'
+ 'id', 'name', "$form->{db}number", 'contact', 'phone',
+ 'fax', 'email', 'taxnumber', 'street', 'zipcode' , 'city',
+ 'business', 'invnumber', 'ordnumber', 'quonumber', 'salesman', 'country'
);
my @includeable_custom_variables = grep { $_->{includeable} } @{ $cvar_configs };
'street' => { 'text' => $locale->text('Street'), },
'zipcode' => { 'text' => $locale->text('Zipcode'), },
'city' => { 'text' => $locale->text('City'), },
+ 'country' => { 'text' => $locale->text('Country'), },
+ 'salesman' => { 'text' => $locale->text('Salesman'), },
%column_defs_cvars,
);
my @hidden_variables = ( qw(
db status obsolete name contact email cp_name addr_street addr_zipcode
- addr_city business_id
+ addr_city addr_country business_id
), "$form->{db}number",
map({ "cvar_$_->{name}" } @searchable_custom_variables),
map({'cvar_'. $_->{name} .'_qtyop'} grep({$_->{type} eq 'number'} @searchable_custom_variables)),
# If set to 1 then the installation will be kept unlocked even if a
# database upgrade fails.
keep_installation_unlocked = 0
+
+# If set to 1 then all resource links (JavaScript, CSS files) output
+# via $::request->{layout}->use_stylesheet() / use_javascript() will
+# be made unique by appending a random GET parameter. This will cause
+# the web browser to always reload the resources.
+auto_reload_resources = 0
color: #333333;
font-family: Trebuchet MS, Tahoma, Verdana, Arial, sans-serif;
font-size: 1.1em;
+ overflow: hidden;
}
.tabwidget ul {
border: 1px #dddddd;
color: #fe5f14;
margin: 0;
- padding: .2em .2em 0;
}
.tabwidget ul::after {
.tabwidget .ui-state-hover a, .tabwidget .ui-state-hover a:hover {
color: #fe5f14;
}
+
+.ui-tabs .ui-tabs-nav li a { padding: .2em .7em; }
color: #000000;
font-family: Trebuchet MS, Tahoma, Verdana, Arial, sans-serif;
font-size: 1.1em;
+ overflow: hidden;
}
.tabwidget ul {
border: 0;
color: #000000;
margin: 0;
- padding: .2em .2em 0;
}
.tabwidget ul::after {
color: #000000;
text-decoration: underline;
}
+
+.ui-tabs .ui-tabs-nav li a { padding: .2em .7em; }
'*) Since version 2.7 these parameters ares set in the client database and not in the configuration file, details in chapter:' => '*) Seit 2.7 werden Gewinnermittlungsart, Versteuerungsart und Warenbuchungsmethode in der Mandanten-DB gesteuert und nicht mehr in der Konfigurationsdatei, Umstellungs-Details:',
'*/' => '*/',
'---please select---' => '---bitte auswählen---',
+ '. Automatically generated.' => '. Automatisch erzeugt.',
'...after loggin in' => '...nach dem Anmelden',
'...done' => '...fertig',
'...on the TODO list' => '...auf der Aufgabenliste',
+ '0% tax with taxkey' => '0% Steuer mit Steuerschlüssel ',
'1. Quarter' => '1. Quartal',
'2. Quarter' => '2. Quartal',
'3. Quarter' => '3. Quartal',
'Bilanz' => 'Bilanz',
'Billing Address' => 'Rechnungsadresse',
'Billing/shipping address (city)' => 'Rechnungsadresse (Stadt)',
+ 'Billing/shipping address (country)' => 'Rechnungsadresse (Land)',
'Billing/shipping address (street)' => 'Rechnungsadresse (Straße)',
'Billing/shipping address (zipcode)' => 'Rechnungsadresse (PLZ)',
'Bin' => 'Lagerplatz',
'Income accno' => 'Erlöskonto',
'Incoming Payments' => 'Zahlungseingänge',
'Incoming invoice number' => 'Eingangsrechnungsnummer',
+ 'Inconsistency in database' => 'Unstimmigkeiten in der Datenbank',
'Incorrect Password!' => 'Ungültiges Passwort!',
'Incorrect password!' => 'Ungültiges Passwort!',
'Incorrect username or password!' => 'Ungültiger Benutzername oder falsches Passwort!',
'Please Check the bank information for each vendor:' => 'Bitte überprüfen Sie die Kontoinformationen der Lieferanten:',
'Please ask your administrator to create warehouses and bins.' => 'Bitten Sie Ihren Administrator, dass er Lager und Lagerplätze anlegt.',
'Please contact your administrator.' => 'Bitte wenden Sie sich an Ihren Administrator.',
+ 'Please define a taxkey for the following taxes and run the update again:' => 'Bitte definieren Sie einen Steuerschlüssel für die folgenden Steuern und starten Sie dann das Update erneut:',
'Please enter a profile name.' => 'Bitte geben Sie einen Profilnamen an.',
'Please enter the login for the new user.' => 'Bitte geben Sie das Login für den neuen Benutzer ein.',
'Please enter the name of the database that will be used as the template for the new database:' => 'Bitte geben Sie den Namen der Datenbank an, die als Vorlage für die neue Datenbank benutzt wird:',
'Please select the destination bank account for the collections:' => 'Bitte wählen Sie das Bankkonto als Ziel für die Einzüge aus:',
'Please select the source bank account for the transfers:' => 'Bitte wählen Sie das Bankkonto als Quelle für die Überweisungen aus:',
'Please seletct the dataset you want to delete:' => 'Bitte wählen Sie die zu löschende Datenbank aus:',
+ 'Please set another taxnumber for the following taxes and run the update again:' => 'Bitte wählen Sie ein anderes Steuerautomatik-Konto für die folgenden Steuern aus uns starten Sie dann das Update erneut.',
'Please specify a description for the warehouse designated for these goods.' => 'Bitte geben Sie den Namen des Ziellagers für die übernommenen Daten ein.',
'Plural' => 'Plural',
'Port' => 'Port',
'Taxes' => 'Steuern',
'Taxkey' => 'Steuerschlüssel',
'Taxkey missing!' => 'Steuerschlüssel fehlt!',
+ 'Taxkey 0 is reserved for rate 0' => 'Der Steuerschlüssel 0 darf keinen Steuersatz über 0 haben.',
'Taxkey_coa' => 'Steuerschlüssel',
'Taxkeys and Taxreport Preferences' => 'Steuerautomatik und UStVA',
'Taxlink_coa' => 'Steuerautomatik',
'There are #1 more open invoices from this vendor with other currencies.' => 'Es gibt #1 weitere offene Rechnungen von diesem Lieferanten, die in anderen Währungen ausgestellt wurden.',
'There are #1 unfinished follow-ups of which #2 are due.' => 'Es gibt #1 Wiedervorlage(n), von denen #2 fällig ist/sind.',
'There are bookings to the account 3803 after 01.01.2007. If you didn\'t change this account manually to 19% the bookings are probably incorrect.' => 'Das Konto 3803 wurde nach dem 01.01.2007 bebucht. Falls Sie dieses Konto nicht manuell auf 19% gestellt haben sind die Buchungen wahrscheinlich mit falscher Umsatzsteuer gebucht worden.',
+ 'There are entries in tax where taxkey is NULL.' => 'In der Datenbank sind Steuern ohne Steuerschlüssel vorhanden (in der Tabelle tax Spalte taxkey).',
'There are four tax zones.' => 'Es gibt vier Steuerzonen.',
+ 'There are invalid taxnumbers in use.' => 'Es werden ungültige Steuerautomatik-Konten benutzt.',
'There are no entries in the background job history.' => 'Es gibt keine Einträge im Hintergrund-Job-Verlauf.',
'There are no items in stock.' => 'Dieser Artikel ist nicht eingelagert.',
'There are no items on your TODO list at the moment.' => 'Ihre Aufgabenliste enthält momentan keine Einträge.',
'There are still transfers not matching the qty of the delivery order. Stock operations can not be changed later. Do you really want to proceed?' => 'Einige der Lagerbewegungen sind nicht vollständig und Lagerbewegungen können nachträglich nicht mehr verändert werden. Wollen Sie wirklich fortfahren?',
'There are usually three ways to install Perl modules.' => 'Es gibt normalerweise drei Arten, ein Perlmodul zu installieren.',
'There is already a taxkey 0 with tax rate not 0.' => 'Es existiert bereits ein Steuerschlüssel mit Steuersatz ungleich 0%.',
+ 'There is an inconsistancy in your database.' => 'In Ihrer Datenbank sind Unstimmigkeiten vorhanden.',
'There is at least one sales or purchase invoice for which kivitendo recorded an inventory transaction with taxkeys even though no tax was recorded.' => 'Es gibt mindestens eine Verkaufs- oder Einkaufsrechnung, für die kivitendo eine Warenbestandsbuchung ohne dazugehörige Steuerbuchung durchgeführt hat.',
'There is at least one transaction for which the user has chosen a logically wrong taxkey.' => 'Es gibt mindestens eine Buchung, bei der ein logisch nicht passender Steuerschlüssel ausgewählt wurde.',
'There is not enough available of \'#1\' at warehouse \'#2\', bin \'#3\', #4, #5, for the transfer of #6.' => 'Von \'#1\' ist in Lager \'#2\', Lagerplatz \'#3\', #4, #5, nicht genügend eingelagert, um insgesamt #6 auszulagern.',
'*) Since version 2.7 these parameters ares set in the client database and not in the lx-erp.conf / lx_office.conf file, details in chapter:' => '',
'*/' => '',
'---please select---' => '',
+ '. Automatically generated.' => '',
'...after loggin in' => '',
'...done' => '',
'...on the TODO list' => '',
+ '0% tax with taxkey' => '',
'1. Quarter' => '',
'2. Quarter' => '',
'3. Quarter' => '',
'Taxes' => '',
'Taxkey' => '',
'Taxkey missing!' => '',
+ 'Taxkey 0 is reserved for rate 0' => '',
'Taxkey_coa' => '',
'Taxkeys and Taxreport Preferences' => '',
'Taxlink_coa' => '',
'There are #1 more open invoices from this vendor with other currencies.' => '',
'There are #1 unfinished follow-ups of which #2 are due.' => '',
'There are bookings to the account 3803 after 01.01.2007. If you didn\'t change this account manually to 19% the bookings are probably incorrect.' => '',
+ 'There are entries in tax where taxkey is NULL.' => '',
'There are four tax zones.' => '',
+ 'There are invalid taxnumbers in use.' => '',
+ 'There are no entries in the background job history.' => '',
'There are no items in stock.' => '',
'There are no items on your TODO list at the moment.' => '',
'There are still entries in the database for which no unit has been assigned.' => '',
'There are still transfers not matching the qty of the delivery order. Stock operations can not be changed later. Do you really want to proceed?' => '',
'There are usually three ways to install Perl modules.' => '',
'There is already a taxkey 0 with tax rate not 0.' => '',
+ 'There is an inconsistancy in your database.' => '',
'There is at least one sales or purchase invoice for which kivitendo recorded an inventory transaction with taxkeys even though no tax was recorded.' => '',
'There is at least one transaction for which the user has chosen a logically wrong taxkey.' => '',
'There is not enough available of \'#1\' at warehouse \'#2\', bin \'#3\', #4, #5, for the transfer of #6.' => '',
use SL::Locale;
use SL::LXDebug;
use Data::Dumper;
+use List::Util qw(max);
# this is a cleaned up version of am.pl
# it lacks redirection, some html setup and most of the authentication process.
Data::Dumper::Dumper(@_);
}
+sub ptab {
+ my @rows = ref($_[0]) eq 'ARRAY' ? @{ $_[0] } : @_;
+ return '<empty result set>' unless @rows;
+
+ my @columns = sort keys %{ $rows[0] };
+ my @widths = map { max @{ $_ } } map { my $column = $_; [ length($column), map { length("" . ($_->{$column} // '')) } @rows ] } @columns;
+ my @output = (join ' | ', map { my $width = $widths[$_]; sprintf "\%-${width}s", $columns[$_] } (0..@columns - 1));
+ push @output, join('-+-', map { '-' x $_ } @widths);
+ push @output, map { my $row = $_; join(' | ', map { my $width = $widths[$_]; sprintf "\%-${width}s", $row->{ $columns[$_] } // '' } (0..@columns - 1) ) } @rows;
+
+ return join("\n", @output);
+}
+
+sub pobj {
+ my ($obj) = @_;
+ return '<no object>' unless $obj;
+
+ my $ref = ref $obj;
+ $ref =~ s/^SL::DB:://;
+ my %primaries = map { ($_ => 1) } $obj->meta->primary_key;
+ my @columns = map { "${_}:" . ($obj->$_ // 'UNDEF') } sort $obj->meta->primary_key;
+ push @columns, map { "${_}:" . ($obj->$_ // 'UNDEF') } grep { !$primaries{$_} } sort map { $_->{name} } $obj->meta->columns;
+
+ return "<${ref} " . join(' ', @columns) . '>';
+}
+
+sub sql {
+ my $dbh = ref($_[0]) ? shift : $::form->get_standard_dbh;
+ my ($query, @args) = @_;
+
+ if ($query =~ m/^\s*select/i) {
+ ptab($dbh->selectall_arrayref($query, { Slice => {} }, @args));
+ } else {
+ $dbh->do($query, { Slice => {} }, @args);
+ }
+}
+
1;
__END__
different depth, you'll have to change that. A nice feature would be to
configure that, or at least to be able to change it at runtime.
+=head2 ptab C<@data>
+
+Returns a tabular representation of C<@data>. C<@data> must be an
+array or array reference containing hash references. Column widths are
+calculated automatically.
+
+Undefined values are represented by an empty column.
+
+Example usage:
+
+ ptab($dbh->selectall_arrayref("SELECT * FROM employee", { Slice => {} }));
+
+=head2 pobj C<$obj>
+
+Returns a textual representation of the L<Rose::DB> instance
+C<$obj>. This includes the class name, then the primary key columns as
+name/value pairs and then all other columns as name/value pairs.
+
+Undefined values are represented by C<UNDEF>.
+
+Example usage:
+
+ pobj(SL::DB::Manager::Employee->find_by(login => 'demo'));
+
+=head2 sql C<[ $dbh, ] $query, @bind_values>
+
+Executes an SQL query using the optional bind values. If the first
+parameter is a database handle then that database handle is used;
+otherwise the handle returned by L<SL::Form/get_standard_dbh> is used.
+
+If the query is a C<SELECT> then the result is filtered through
+L<ptab()>. Otherwise the result of C<$dbh->do($query, undef, @bind_values)>
+is returned.
+
+Example usage:
+
+ sql(qq|SELECT * FROM employee|);
+ sql(SL::DB::Employee->new->db->dbh,
+ qq|UPDATE employee SET notes = ? WHERE login = ?|,
+ 'This guy is evil!', 'demo');
+
=head2 lxinit C<login>
Login into lx-office using a specified login. No password will be required, and
orderitems => { parts => 'part', trans => 'order', },
delivery_order_items => { parts => 'part' },
invoice => { parts => 'part' },
+
+ periodic_invoices_configs => { oe => 'order' },
);
sub setup {
--- /dev/null
+-- @tag: add_chart_link_to_acc_trans
+-- @description: Neue Spalte chart_link in der acc_trans
+-- @depends: release_3_0_0
+
+--neue Spalte hinzufügen:
+ALTER TABLE acc_trans ADD COLUMN chart_link text;
+
+--Spalte mit Werten füllen:
+UPDATE acc_trans SET chart_link = (SELECT link FROM chart WHERE id=chart_id);
+
+--Spalte als Pflichtfeld definieren:
+ALTER TABLE acc_trans ALTER chart_link SET NOT NULL;
-- @tag: add_fkey_tax_id_to_acc_trans
-- @description: Setzt einen Fremdschlüssel zu der Tabellenspalte tax_id in der acc_trans
--- @depends: release_3_0_0
+-- @depends: release_3_0_0 add_tax_id_to_acc_trans
ALTER TABLE acc_trans ADD FOREIGN KEY (tax_id) REFERENCES tax(id);
-- @tag: add_tax_id_to_acc_trans
-- @description: Neue Spalte tax_id in der acc_trans
--- @depends: release_2_7_0
+-- @depends: release_3_0_0 charts_without_taxkey
-- @charset: utf-8
--Neue Spalte tax_id in acc_trans:
--- /dev/null
+# @tag: tax_constraints
+# @description: Setzt Fremdschlüssel und andere constraints auf die Tabellen tax und taxkeys
+# @depends: release_3_0_0 charts_without_taxkey
+# @charset: utf-8
+
+use utf8;
+use strict;
+use SL::Locale;
+
+die("This script cannot be run from the command line.") unless ($main::form);
+
+sub mydberror {
+ my ($msg) = @_;
+ die($dbup_locale->text("Database update error:") . "<br>$msg<br>" . $DBI::errstr);
+}
+
+sub do_query {
+ my ($query, $may_fail) = @_;
+
+ if (!$dbh->do($query)) {
+ mydberror($query) unless ($may_fail);
+ $dbh->rollback();
+ $dbh->begin_work();
+ }
+}
+
+sub do_update {
+ #CHECK CONSISTANCY OF tax
+ #update tax.rate and tax.taxdescription in order to set later NOT NULL constraints
+ my $query= <<SQL;
+ UPDATE tax SET rate=0 WHERE rate IS NULL;
+ UPDATE tax SET taxdescription='-' WHERE COALESCE(taxdescription, '') = '';
+SQL
+
+ do_query($query);
+
+ #check automatic tax accounts
+ $query= <<SQL;
+ SELECT count(*) FROM tax WHERE chart_id NOT IN (SELECT id FROM chart);
+SQL
+
+ my ($invalid_tax_account) = $dbh->selectrow_array($query);
+
+ if ($invalid_tax_account > 0){
+ #list all invalid tax accounts
+ $query = <<SQL;
+ SELECT id,
+ taxkey,
+ taxdescription,
+ round(rate * 100, 2) AS rate
+ FROM tax WHERE chart_id NOT IN (SELECT id FROM chart);
+SQL
+
+ my $sth = $dbh->prepare($query);
+ $sth->execute || $main::form->dberror($query);
+
+ $main::form->{TAX} = [];
+ while (my $ref = $sth->fetchrow_hashref("NAME_lc")) {
+ push @{ $main::form->{TAX} }, $ref;
+ }
+ $sth->finish;
+
+ $main::form->{invalid_tax_account} = 1;
+ print_error_message();
+ return 0;
+ }
+
+ #check entry tax.taxkey of NOT NULL
+ $query= <<SQL;
+ SELECT count(*) FROM tax WHERE taxkey IS NULL;
+SQL
+
+ my ($taxkey_is_null) = $dbh->selectrow_array($query);
+
+ if ($taxkey_is_null > 0){
+ #list all invalid tax accounts
+ $query = <<SQL;
+ SELECT id,
+ taxdescription,
+ round(rate * 100, 2) AS rate,
+ (SELECT accno FROM chart WHERE id = chart_id) AS taxnumber,
+ (SELECT description FROM chart WHERE id = chart_id) AS account_description
+ FROM tax
+ WHERE taxkey IS NULL;
+SQL
+
+ my $sth = $dbh->prepare($query);
+ $sth->execute || $main::form->dberror($query);
+
+ $main::form->{TAX} = [];
+ while (my $ref = $sth->fetchrow_hashref("NAME_lc")) {
+ push @{ $main::form->{TAX} }, $ref;
+ }
+ $sth->finish;
+
+ $main::form->{taxkey_is_null} = 1;
+ print_error_message();
+ return 0;
+ }
+ #END CHECK OF tax
+
+ #CHECK CONSISTANCY OF taxkeys
+ #delete invalide entries in taxkeys
+ $query= <<SQL;
+ DELETE FROM taxkeys
+ WHERE chart_id IS NULL
+ OR chart_id NOT IN (SELECT id FROM chart)
+ OR startdate IS NULL;
+SQL
+
+ do_query($query);
+
+ #There are 3 cases for taxkeys.tax_id and taxkeys.taxkey_id
+ #taxkeys.taxkey_id is NULL and taxkeys.tax_id is not NULL:
+
+ #Update taxkeys.taxkey_id with tax.taxkey
+ $query= <<SQL;
+ UPDATE taxkeys
+ SET taxkey_id = (SELECT t.taxkey
+ FROM tax t
+ WHERE t.id=tax_id)
+ WHERE taxkey_id IS NULL
+ AND tax_id IS NOT NULL;
+SQL
+
+ do_query($query);
+
+ #taxkeys.taxkey_id and taxkeys.tax_id are NULL:
+
+ #Set taxkey 0 in this case:
+ $query= <<SQL;
+ UPDATE taxkeys
+ SET taxkey_id = 0, tax_id = (SELECT id FROM tax WHERE taxkey=0)
+ WHERE taxkey_id IS NULL
+ AND tax_id IS NULL;
+SQL
+
+ do_query($query);
+
+ #Last case where taxkeys.taxkey_id is not null and taxkeys.tax_id is null
+
+ #If such entries exist we update with an entry in tax where tax.rate=0
+ #and tax.taxkey corresponds to taxkeys.taxkey_id.
+ #If no entry in tax with rate 0 and taxkey taxkeys.taxkey_id exists
+ #we create one.
+ $query= <<SQL;
+ SELECT DISTINCT taxkey_id
+ FROM taxkeys
+ WHERE taxkey_id IS NOT NULL
+ AND tax_id IS NULL;
+SQL
+
+ my $sth = $dbh->prepare($query);
+ $sth->execute || $main::form->dberror($query);
+
+ $main::form->{TAXID} = [];
+ my $rowcount = 0;
+ while (my $ref = $sth->fetchrow_hashref("NAME_lc")) {
+ push @{ $main::form->{TAXID} }, $ref;
+ $rowcount++;
+ }
+ $sth->finish;
+
+ my $insertquery;
+ my $updatequery;
+ my $tax_id;
+ for my $i (0 .. $rowcount-1){
+ $query= qq|
+ SELECT id FROM tax WHERE rate = 0 and taxkey=| . $main::form->{TAXID}[$i]->{taxkey_id} . qq| LIMIT 1
+|;
+ ($tax_id) = $dbh->selectrow_array($query);
+ if ( not $tax_id ){
+ $insertquery=qq|
+ INSERT INTO tax (rate, taxdescription, taxkey) VALUES (0, '| . $::locale->text('0% tax with taxkey') . $main::form->{TAXID}[$i]->{taxkey_id} . $::locale->text('. Automatically generated.') .
+ qq|', | . $main::form->{TAXID}[$i]->{taxkey_id} . qq|);
+|;
+ do_query($insertquery);
+ ($tax_id) = $dbh->selectrow_array($query);
+ $tax_id || $main::form->dberror($query);
+ }
+ $updatequery = qq|
+ UPDATE taxkeys SET tax_id= | . $tax_id . qq| WHERE taxkey_id = | . $main::form->{TAXID}[$i]->{taxkey_id} . qq| AND tax_id IS NULL
+|;
+ do_query($updatequery);
+ }
+
+ #The triple taxkey_id, chart_id, startdate in taxkeys has to be unique
+ #Select these entries:
+ $query= <<SQL;
+ SELECT DISTINCT tk1.chart_id AS chart_id, tk1.startdate AS startdate
+ FROM taxkeys tk1
+ WHERE (SELECT count(*)
+ FROM taxkeys tk2
+ WHERE tk2.chart_id = tk1.chart_id
+ AND tk2.startdate = tk1.startdate) > 1;
+SQL
+
+ $sth = $dbh->prepare($query);
+ $sth->execute || $main::form->dberror($query);
+
+ $main::form->{TAXKEYS} = [];
+ $rowcount = 0;
+ while (my $ref = $sth->fetchrow_hashref("NAME_lc")) {
+ push @{ $main::form->{TAXKEYS} }, $ref;
+ $rowcount++;
+ }
+ $sth->finish;
+
+ for my $i (0 .. $rowcount-1){
+ $query= qq|
+ DELETE FROM taxkeys tk1
+ WHERE (SELECT count(*)
+ FROM taxkeys tk2
+ WHERE tk2.chart_id = tk1.chart_id
+ AND tk2.startdate = tk1.startdate) > 1
+ AND NOT tk1.id = (SELECT id
+ FROM taxkeys
+ WHERE chart_id = | . $main::form->{TAXKEYS}[$i]->{chart_id} . qq|
+ AND startdate = '| . $main::form->{TAXKEYS}[$i]->{startdate} . qq|'
+ LIMIT 1)
+|;
+
+ do_query($query);
+ }
+
+ #END CHECK OF taxkeys
+
+ #ADD CONSTRAINTS:
+ #Now the database is consistent, so we can add constraints:
+ #Crate NOT NULL constraint for tax.rate with default value 0
+ $query= <<SQL;
+ ALTER TABLE tax ALTER COLUMN rate SET NOT NULL;
+ ALTER TABLE tax ALTER COLUMN rate SET DEFAULT 0;
+SQL
+
+ do_query($query);
+
+ #Create NOT NULL constraint for tax.description
+ $query= <<SQL;
+ ALTER TABLE tax ALTER COLUMN taxdescription SET NOT NULL;
+SQL
+
+ do_query($query);
+
+ #Create foreign key for tax.chart_id to chart.id
+ $query= <<SQL;
+ ALTER TABLE tax ADD FOREIGN KEY (chart_id) REFERENCES chart(id);
+SQL
+
+ do_query($query);
+
+ #Create NOT NULL constraint for tax.taxkey
+ $query= <<SQL;
+ ALTER TABLE tax ALTER COLUMN taxkey SET NOT NULL;
+SQL
+
+ do_query($query);
+
+ #Create NOT NULL constraint for taxkey.chart_id and foreign key for taxkey.chart_id
+ $query= <<SQL;
+ ALTER TABLE taxkeys ALTER COLUMN chart_id SET NOT NULL;
+ ALTER TABLE taxkeys ADD FOREIGN KEY (chart_id) REFERENCES chart(id);
+SQL
+
+ do_query($query);
+
+ #Create NOT NULL constraint for taxkey.startdate
+ $query= <<SQL;
+ ALTER TABLE taxkeys ALTER COLUMN startdate SET NOT NULL;
+SQL
+
+ do_query($query);
+
+ #Create NOT NULL constraint for taxkey.taxkey_id
+ $query= <<SQL;
+ ALTER TABLE taxkeys ALTER COLUMN taxkey_id SET NOT NULL;
+SQL
+
+ do_query($query);
+
+ #Create NOT NULL constraint for taxkey.tax_id
+ $query= <<SQL;
+ ALTER TABLE taxkeys ALTER COLUMN tax_id SET NOT NULL;
+SQL
+
+ do_query($query);
+
+ #The triple chart_id, taxkey_id, startdate should be unique:
+ $query= <<SQL;
+ CREATE UNIQUE INDEX taxkeys_chartid_startdate ON taxkeys(chart_id, startdate);
+SQL
+
+ do_query($query);
+ #ALL CONSTRAINTS WERE ADDED
+
+ return 1;
+}; # end do_update
+
+
+sub print_error_message {
+ print $main::form->parse_html_template("dbupgrade/tax_constraints");
+}
+
+return do_update();
use SL::Locale;
use SL::LXDebug;
use Data::Dumper;
+use SL::Layout::None;
use SL::LxOfficeConf;
use SL::InstanceConfiguration;
+use SL::Request;
sub _login {
my $login = shift;
$::form = Form->new;
$::auth = SL::Auth->new;
$::instance_conf = SL::InstanceConfiguration->new;
- $::request = { cgi => CGI->new({}) };
+ $::request = SL::Request->new( cgi => CGI->new({}), layout => SL::Layout::None->new );
die 'cannot reach auth db' unless $::auth->session_tables_present;
sub reset_test_env {
$ENV{HTTP_USER_AGENT} = 'Perl Tests';
- $::request = {
+ $::request = SL::Request->new(
cgi => CGI->new({}),
layout => SL::Layout::Javascript->new,
- };
+ );
$::myconfig{menustyle} = 'javascript';
<table width="100%">
<tr>
<td>[% 'tax_taxkey' | $T8 %]</td>
- <td><input name="taxkey" size="2" value="[% HTML.escape(taxkey) %]"></td>
+ <td><input name="taxkey" size="2" value="[% HTML.escape(taxkey) %]" [% readonly %]></td>
</tr>
<tr>
<tr>
<td>[% 'tax_percent' | $T8 %]</td>
- <td><input name="rate" size="10" value="[% HTML.escape(rate) %]"> %</td>
+ <td><input name="rate" size="10" value="[% HTML.escape(rate) %]" [% readonly %]> %</td>
</tr>
<tr>
<input type="submit" class="submit" name="action" value="[% 'Save' | $T8 %]">
- [% IF orphaned %]
+ [% IF orphaned AND NOT tax_already_used %]
<input type="submit" class="submit" name="action" value="[% 'Delete' | $T8 %]">
[% END %]
<td>[% HTML.escape(discount) %]%</td>
</tr>
+ [% IF is_customer %]
+ <tr>
+ <td align="right">[% 'Pricegroup' | $T8 %]</td>
+ <td>[% HTML.escape(pricegroup) %]</td>
+ </tr>
+ [% END %]
+
<tr>
<td align="right">[% 'Payment Terms' | $T8 %]</td>
<td>[% HTML.escape(payment_terms) %]</td>
<th align="right" nowrap>[% 'Billing/shipping address (city)' | $T8 %]</th>
<td><input name="addr_city" size="35"></td>
</tr>
+ <tr>
+ <th align="right" nowrap>[% 'Billing/shipping address (country)' | $T8 %]</th>
+ <td><input name="addr_country" size="35"></td>
+ </tr>
+
[% IF SHOW_BUSINESS_TYPES %]
<tr>
<th align="right" nowrap>[% IF IS_CUSTOMER %][% 'Customer type' | $T8 %][% ELSE %][% 'Vendor type' | $T8 %][% END %]</th>
<td>
<input name="l_city" id="l_city" type="checkbox" class="checkbox" value="Y" checked>
<label for="l_city">[% 'City' | $T8 %]</label>
- </td>
+ </td>
</tr>
<tr>
<label for="l_quonumber">[% IF IS_CUSTOMER %][% 'Quotations' | $T8 %][% ELSE %][% 'RFQs' | $T8 %][% END %]</label>
</td>
<td>
+ <input name="l_country" id="l_country" type="checkbox" class="checkbox" value="Y" checked>
+ <label for="l_country">[% 'Country' | $T8 %]</label>
+ </td>
+ </tr>
+ [% IF IS_CUSTOMER %]
+ <tr>
+ <td>
+ <input name="l_salesman" id="l_salesman" type="checkbox" class="checkbox" value="Y">
+ <label for="l_salesman">[% 'Salesman' | $T8 %]</label>
</td>
</tr>
+ [% END %]
[% CUSTOM_VARIABLES_INCLUSION_CODE %]
--- /dev/null
+[%- USE T8 %]
+[% USE HTML %]<div class="listtop">[% 'Inconsistency in database' | $T8 %]</div>
+
+<form name="Form" method="post" action="login.pl">
+<input type="hidden" name="action" value="login">
+
+<p>[% 'There is an inconsistancy in your database.' | $T8 %]</p>
+<p>[% 'Please contact your administrator.' | $T8 %]</p>
+
+[% IF invalid_tax_account %]
+ <p>[% 'There are invalid taxnumbers in use.' | $T8 %]</p>
+ <p>[% 'Please set another taxnumber for the following taxes and run the update again:' | $T8 %]</p>
+ <table>
+ <tr>
+ <th class="listheading">[% 'tax_taxkey' | $T8 %]</th>
+ <th class="listheading">[% 'tax_taxdescription' | $T8 %]</th>
+ <th class="listheading">[% 'tax_rate' | $T8 %]</th>
+ </tr>
+
+ [% SET row_odd = '1' %][% FOREACH row = TAX %]
+ <tr class="listrow[% IF row_odd %]1[% SET row_odd = '0' %][% ELSE %]0[% SET row_odd = '1' %][% END %]">
+ <td align="right">[% HTML.escape(row.taxkey) %]</td>
+ <td align="left"> [% HTML.escape(row.taxdescription) %]</a></td>
+ <td align="right">[% HTML.escape(row.rate) %] %</td>
+ </tr>
+ [% END %]
+ </table>
+
+[% END %]
+
+[% IF taxkey_is_null %]
+ <p>[% 'There are entries in tax where taxkey is NULL.' | $T8 %]</p>
+ <p>[% 'Please define a taxkey for the following taxes and run the update again:' | $T8 %]</p>
+ <table>
+ <tr>
+ <th class="listheading">[% 'tax_taxdescription' | $T8 %]</th>
+ <th class="listheading">[% 'tax_rate' | $T8 %]</th>
+ <th class="listheading">[% 'taxnumber' | $T8 %]</th>
+ <th class="listheading">[% 'account_description' | $T8 %]</th>
+ </tr>
+
+ [% SET row_odd = '1' %][% FOREACH row = TAX %]
+ <tr class="listrow[% IF row_odd %]1[% SET row_odd = '0' %][% ELSE %]0[% SET row_odd = '1' %][% END %]">
+ <td align="left"> [% HTML.escape(row.taxdescription) %]</a></td>
+ <td align="right">[% HTML.escape(row.rate) %] %</td>
+ <td align="right">[% HTML.escape(row.taxnumber) %]</td>
+ <td>[% HTML.escape(row.account_description) %]</td>
+ </tr>
+ [% END %]
+ </table>
+
+[% END %]
+</form>
</table>
</p>
- <hr size="3" noshade>
+ </div>
+[% PROCESS 'webdav/_list.html' %]
+ <div id="ui-tabs-1">
+ [%- LxERP.t8("Loading...") %]
+ </div>
+</div>
- [%- IF conf_webdav %]
- <div class="listtop" align="left">[% 'Documents in the WebDAV repository' | $T8 %]</div>
-
- <p>
- <table width="100%">
- <tr>
- <td align="left" width="30%"><b>[% 'File name' | $T8 %]</b></td>
- <td align="left" width="70%"><b>[% 'WebDAV link' | $T8 %]</b></td>
- </tr>
-
- [%- FOREACH file = WEBDAV %]
- <tr>
- <td align="left">[% HTML.escape(file.name) %]</td>
- <td align="left"><a href="[% HTML.escape(file.link) %]">[% HTML.escape(file.type) %]</a></td>
- </tr>
- [%- END %]
-
- </table>
- </p>
-
- <hr size="3" noshade>
- [%- END %]
+<hr size="3" noshade>
<p>[% PRINT_OPTIONS %]</p>
<form method="post" name="do" action="do.pl">
+ <div class="tabwidget">
+ <ul>
+ <li><a href="#ui-tabs-basic-data">[% 'Basic Data' | $T8 %]</a></li>
+[%- IF conf_webdav %]
+ <li><a href="#ui-tabs-webdav">[% 'WebDAV' | $T8 %]</a></li>
+[%- END %]
+[%- IF id %]
+ <li><a href="controller.pl?action=RecordLinks/ajax_list&object_model=DeliveryOrder&object_id=[% HTML.url(id) %]">[% 'Linked Records' | $T8 %]</a></li>
+[%- END %]
+ </ul>
+
+ <div id="ui-tabs-basic-data">
+
<input type="hidden" name="follow_up_trans_id_1" value="[% HTML.escape(id) %]">
<input type="hidden" name="follow_up_trans_type_1" value="[% HTML.escape(type) %]">
<input type="hidden" name="follow_up_trans_info_1" value="[% HTML.escape(follow_up_trans_info) %]">
</td>
</tr>
-[% PROCESS 'webdav/_list.html' %]
-
[% PROCESS 'ir/_payments.html' %]
- <tr>
- <td><hr size="3" noshade></td>
- </tr>
- <tr>
- <td>
-[% print_options %]
- </td>
- </tr>
</table>
+</div>
+[% PROCESS 'webdav/_list.html' %]
+<div id="ui-tabs-1">
+ [%- LxERP.t8("Loading...") %]
+</div>
+</div>
+<hr size="3" noshade>
+<p>[% print_options %]</p>
[% IF id %]
[%- INCLUDE 'common/flash.html' %]
+<div class="tabwidget">
+ <ul>
+ <li><a href="#ui-tabs-basic-data">[% 'Basic Data' | $T8 %]</a></li>
+[%- IF conf_webdav %]
+ <li><a href="#ui-tabs-webdav">[% 'WebDAV' | $T8 %]</a></li>
+[%- END %]
+[%- IF id %]
+ <li><a href="controller.pl?action=RecordLinks/ajax_list&object_model=PurchaseInvoice&object_id=[% HTML.url(id) %]">[% 'Linked Records' | $T8 %]</a></li>
+[%- END %]
+ </ul>
+
+ <div id="ui-tabs-basic-data">
<table width="100%">
<tr>
<td valign="top">
[%- USE T8 %]
[%- USE HTML %]
[%- USE LxERP %]
-[%- USE L %]
+[%- USE L %][%- USE P -%]
<tr>
<td>
<table width="100%">
</td>
</tr>
-[% PROCESS 'webdav/_list.html' %]
-
[% PROCESS 'is/_payments.html' %]
-
- <tr>
- <td><hr size="3" noshade></td>
- </tr>
- <tr>
- <td>
-[% print_options %]
- </td>
- </tr>
</table>
+</div>
+[% PROCESS 'webdav/_list.html' %]
+<div id="ui-tabs-1">
+ [% LxERP.t8('Loading...') %]
+</div>
+</div>
+<hr size="3" noshade>
+<p>[% print_options %]</p>
[% IF id %]
[%- PROCESS 'common/flash.html' %]
+<div class="tabwidget">
+ <ul>
+ <li><a href="#ui-tabs-basic-data">[% 'Basic Data' | $T8 %]</a></li>
+[%- IF conf_webdav %]
+ <li><a href="#ui-tabs-webdav">[% 'WebDAV' | $T8 %]</a></li>
+[%- END %]
+[%- IF id %]
+ <li><a href="controller.pl?action=RecordLinks/ajax_list&object_model=Invoice&object_id=[% HTML.url(id) %]">[% 'Linked Records' | $T8 %]</a></li>
+[%- END %]
+ </ul>
+
+<div id="ui-tabs-basic-data">
<table width="100%">
<tr>
<td valign="top">
</table>
</td>
</tr>
- <tr>
- <td><hr size="3" noshade></td>
- </tr>
+</table>
-[%- IF webdav %]
- <tr>
- <th class="listtop" align="left">Dokumente im Webdav-Repository</th>
- </tr>
- <tr>
- <td>
- <table width="100%">
- <tr>
- <td align="left" width="30%"><b>Dateiname</b></td>
- <td align="left" width="70%"><b>Webdavlink</b></td>
- </tr>
- [%- FOREACH file = WEBDAV %]
- <tr>
- <td align="left">[% HTML.escape(file.name) %]</td>
- <td align="left"><a href="[% file.link %]">[% HTML.escape(file.type) %]</a></td>
- </tr>
- [%- END %]
- </table>
- </td>
- </tr>
- <tr>
- <td><hr size="3" noshade></td>
- </tr>
-[%- END %]
+</div>
+[%- PROCESS 'webdav/_list.html' %]
+<div id="ui-tabs-1">
+ [%- LxERP.t8("Loading...") %]
+</div>
+</div>
- <tr>
- <td>
- [% print_options %]
- </td>
- </tr>
-</table>
+<hr size="3" noshade>
+
+<p>[% PRINT_OPTIONS %]</p>
[% label_edit %]<br>
<input class="submit" type="submit" name="action_update" id="update_button" value="[% 'Update' | $T8 %]">
[%- INCLUDE 'common/flash.html' %]
+ <div class="tabwidget">
+ <ul>
+ <li><a href="#ui-tabs-basic-data">[% 'Basic Data' | $T8 %]</a></li>
+[%- IF conf_webdav %]
+ <li><a href="#ui-tabs-webdav">[% 'WebDAV' | $T8 %]</a></li>
+[%- END %]
+[%- IF id %]
+ <li><a href="controller.pl?action=RecordLinks/ajax_list&object_model=Order&object_id=[% HTML.url(id) %]">[% 'Linked Records' | $T8 %]</a></li>
+[%- END %]
+ </ul>
+
+ <div id="ui-tabs-basic-data">
+
<table width="100%">
<tr>
<td>
-[% USE L %][% USE LxERP %]
+[% USE L %][% USE LxERP %][%- USE P -%]
<div class="listtop">[%- P.escape(title) %]</div>
<div style="padding-bottom: 15px">
+[% USE HTML %][% USE T8 %]
-[%- IF webdav %]
- <tr>
- <td><hr size="3" noshade></td>
- </tr>
+[%- IF conf_webdav %]
+<div id="ui-tabs-webdav">
+
+ <div class="listtop" align="left">[% 'Documents in the WebDAV repository' | $T8 %]</div>
+
+ <table width="100%">
<tr>
- <th class="listtop" align="left">Dokumente im Webdav-Repository</th>
+ <td align="left" width="30%"><b>[% 'File name' | $T8 %]</b></td>
+ <td align="left" width="70%"><b>[% 'WebDAV link' | $T8 %]</b></td>
</tr>
+
+[%- FOREACH file = WEBDAV %]
<tr>
- <td>
- <table width="100%">
- <tr>
- <td align="left" width="30%"><b>Dateiname</b></td>
- <td align="left" width="70%"><b>Webdavlink</b></td>
- </tr>
- [%- FOREACH file = WEBDAV %]
- <tr>
- <td align="left">[% file.name %]</td>
- <td align="left"><a href="[% file.link %]">[% file.type %]</a></td>
- </tr>
- [%- END %]
- </table>
- </td>
+ <td align="left">[% HTML.escape(file.name) %]</td>
+ <td align="left"><a href="[% HTML.escape(file.link) %]">[% HTML.escape(file.type) %]</a></td>
</tr>
-[% END %]
+[%- END %]
+ </table>
+</div>
+
+[%- END %]