projects
/
kivitendo-erp.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'master' of ssh://lx-office/~/lx-office-erp
[kivitendo-erp.git]
/
SL
/
CT.pm
diff --git
a/SL/CT.pm
b/SL/CT.pm
index
f2745fb
..
2397fe7
100644
(file)
--- a/
SL/CT.pm
+++ b/
SL/CT.pm
@@
-123,7
+123,14
@@
sub get_tuple {
}
# check if it is orphaned
}
# check if it is orphaned
- my $arap = ( $form->{db} eq 'customer' ) ? "ar" : "ap";
+ my $arap = ( $form->{db} eq 'customer' ) ? "ar" : "ap";
+ my $num_args = 2;
+ my $makemodel = '';
+ if ($form->{db} eq 'vendor') {
+ $makemodel = qq| UNION SELECT 1 FROM makemodel mm WHERE mm.make = ?|;
+ $num_args++;
+ }
+
$query =
qq|SELECT a.id | .
qq|FROM $arap a | .
$query =
qq|SELECT a.id | .
qq|FROM $arap a | .
@@
-133,8
+140,10
@@
sub get_tuple {
qq|SELECT a.id | .
qq|FROM oe a | .
qq|JOIN $cv ct ON (a.${cv}_id = ct.id) | .
qq|SELECT a.id | .
qq|FROM oe a | .
qq|JOIN $cv ct ON (a.${cv}_id = ct.id) | .
- qq|WHERE ct.id = ?|;
- my ($dummy) = selectrow_query($form, $dbh, $query, $form->{id}, $form->{id});
+ qq|WHERE ct.id = ?|
+ . $makemodel;
+ my ($dummy) = selectrow_query($form, $dbh, $query, (conv_i($form->{id})) x $num_args);
+
$form->{status} = "orphaned" unless ($dummy);
$dbh->disconnect;
$form->{status} = "orphaned" unless ($dummy);
$dbh->disconnect;
@@
-185,13
+194,6
@@
sub query_titles_and_greetings {
my $dbh = $form->dbconnect($myconfig);
my $dbh = $form->dbconnect($myconfig);
- $query =
- qq|SELECT DISTINCT(cp_greeting) | .
- qq|FROM contacts | .
- qq|WHERE cp_greeting ~ '[a-zA-Z]' | .
- qq|ORDER BY cp_greeting|;
- $form->{GREETINGS} = [ selectall_array_query($form, $dbh, $query) ];
-
$query =
qq|SELECT DISTINCT(greeting) | .
qq|FROM customer | .
$query =
qq|SELECT DISTINCT(greeting) | .
qq|FROM customer | .
@@
-367,7
+369,6
@@
sub save_customer {
$query = undef;
if ( $form->{cp_id} ) {
$query = qq|UPDATE contacts SET | .
$query = undef;
if ( $form->{cp_id} ) {
$query = qq|UPDATE contacts SET | .
- qq|cp_greeting = ?, | .
qq|cp_title = ?, | .
qq|cp_givenname = ?, | .
qq|cp_name = ?, | .
qq|cp_title = ?, | .
qq|cp_givenname = ?, | .
qq|cp_name = ?, | .
@@
-383,10
+384,10
@@
sub save_customer {
qq|cp_project = ?, | .
qq|cp_privatphone = ?, | .
qq|cp_privatemail = ?, | .
qq|cp_project = ?, | .
qq|cp_privatphone = ?, | .
qq|cp_privatemail = ?, | .
- qq|cp_birthday = ? | .
+ qq|cp_birthday = ?, | .
+ qq|cp_gender = ? | .
qq|WHERE cp_id = ?|;
@values = (
qq|WHERE cp_id = ?|;
@values = (
- $form->{cp_greeting},
$form->{cp_title},
$form->{cp_givenname},
$form->{cp_name},
$form->{cp_title},
$form->{cp_givenname},
$form->{cp_name},
@@
-403,18
+404,18
@@
sub save_customer {
$form->{cp_privatphone},
$form->{cp_privatemail},
$form->{cp_birthday},
$form->{cp_privatphone},
$form->{cp_privatemail},
$form->{cp_birthday},
+ $form->{cp_gender} eq 'f' ? 'f' : 'm',
$form->{cp_id}
);
} elsif ( $form->{cp_name} || $form->{cp_givenname} ) {
$query =
$form->{cp_id}
);
} elsif ( $form->{cp_name} || $form->{cp_givenname} ) {
$query =
- qq|INSERT INTO contacts ( cp_cv_id, cp_
greeting, cp_
title, cp_givenname, | .
+ qq|INSERT INTO contacts ( cp_cv_id, cp_title, cp_givenname, | .
qq| cp_name, cp_email, cp_phone1, cp_phone2, cp_abteilung, cp_fax, cp_mobile1, | .
qq| cp_mobile2, cp_satphone, cp_satfax, cp_project, cp_privatphone, cp_privatemail, | .
qq| cp_name, cp_email, cp_phone1, cp_phone2, cp_abteilung, cp_fax, cp_mobile1, | .
qq| cp_mobile2, cp_satphone, cp_satfax, cp_project, cp_privatphone, cp_privatemail, | .
- qq| cp_birthday) | .
+ qq| cp_birthday
, cp_gender
) | .
qq|VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)|;
@values = (
$form->{id},
qq|VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)|;
@values = (
$form->{id},
- $form->{cp_greeting},
$form->{cp_title},
$form->{cp_givenname},
$form->{cp_name},
$form->{cp_title},
$form->{cp_givenname},
$form->{cp_name},
@@
-430,7
+431,8
@@
sub save_customer {
$form->{cp_project},
$form->{cp_privatphone},
$form->{cp_privatemail},
$form->{cp_project},
$form->{cp_privatphone},
$form->{cp_privatemail},
- $form->{cp_birthday}
+ $form->{cp_birthday},
+ $form->{cp_gender} eq 'f' ? 'f' : 'm',
);
}
do_query( $form, $dbh, $query, @values ) if ($query);
);
}
do_query( $form, $dbh, $query, @values ) if ($query);
@@
-572,7
+574,6
@@
sub save_vendor {
$query = undef;
if ( $form->{cp_id} ) {
$query = qq|UPDATE contacts SET | .
$query = undef;
if ( $form->{cp_id} ) {
$query = qq|UPDATE contacts SET | .
- qq|cp_greeting = ?, | .
qq|cp_title = ?, | .
qq|cp_givenname = ?, | .
qq|cp_name = ?, | .
qq|cp_title = ?, | .
qq|cp_givenname = ?, | .
qq|cp_name = ?, | .
@@
-588,10
+589,10
@@
sub save_vendor {
qq|cp_project = ?, | .
qq|cp_privatphone = ?, | .
qq|cp_privatemail = ?, | .
qq|cp_project = ?, | .
qq|cp_privatphone = ?, | .
qq|cp_privatemail = ?, | .
- qq|cp_birthday = ? | .
+ qq|cp_birthday = ?, | .
+ qq|cp_gender = ? | .
qq|WHERE cp_id = ?|;
@values = (
qq|WHERE cp_id = ?|;
@values = (
- $form->{cp_greeting},
$form->{cp_title},
$form->{cp_givenname},
$form->{cp_name},
$form->{cp_title},
$form->{cp_givenname},
$form->{cp_name},
@@
-608,18
+609,18
@@
sub save_vendor {
$form->{cp_privatphone},
$form->{cp_privatemail},
$form->{cp_birthday},
$form->{cp_privatphone},
$form->{cp_privatemail},
$form->{cp_birthday},
+ $form->{cp_gender} eq 'f' ? 'f' : 'm',
$form->{cp_id}
);
} elsif ( $form->{cp_name} || $form->{cp_givenname} ) {
$query =
$form->{cp_id}
);
} elsif ( $form->{cp_name} || $form->{cp_givenname} ) {
$query =
- qq|INSERT INTO contacts ( cp_cv_id, cp_
greeting, cp_
title, cp_givenname, | .
+ qq|INSERT INTO contacts ( cp_cv_id, cp_title, cp_givenname, | .
qq| cp_name, cp_email, cp_phone1, cp_phone2, cp_abteilung, cp_fax, cp_mobile1, | .
qq| cp_mobile2, cp_satphone, cp_satfax, cp_project, cp_privatphone, cp_privatemail, | .
qq| cp_name, cp_email, cp_phone1, cp_phone2, cp_abteilung, cp_fax, cp_mobile1, | .
qq| cp_mobile2, cp_satphone, cp_satfax, cp_project, cp_privatphone, cp_privatemail, | .
- qq| cp_birthday) | .
+ qq| cp_birthday
, cp_gender
) | .
qq|VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)|;
@values = (
$form->{id},
qq|VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)|;
@values = (
$form->{id},
- $form->{cp_greeting},
$form->{cp_title},
$form->{cp_givenname},
$form->{cp_name},
$form->{cp_title},
$form->{cp_givenname},
$form->{cp_name},
@@
-635,7
+636,8
@@
sub save_vendor {
$form->{cp_project},
$form->{cp_privatphone},
$form->{cp_privatemail},
$form->{cp_project},
$form->{cp_privatphone},
$form->{cp_privatemail},
- $form->{cp_birthday}
+ $form->{cp_birthday},
+ $form->{cp_gender}
);
}
do_query($form, $dbh, $query, @values) if ($query);
);
}
do_query($form, $dbh, $query, @values) if ($query);
@@
-695,7
+697,7
@@
sub search {
$form->{sort} = $sortorder;
my $sortdir = !defined $form->{sortdir} ? 'ASC' : $form->{sortdir} ? 'ASC' : 'DESC';
$form->{sort} = $sortorder;
my $sortdir = !defined $form->{sortdir} ? 'ASC' : $form->{sortdir} ? 'ASC' : 'DESC';
-
if ($sortorder ne 'id'
) {
+
if ($sortorder ne 'id' && 1 >= scalar grep { $form->{$_} } qw(l_ordnumber l_quonumber l_invnumber)
) {
$sortorder = "lower($sortorder) ${sortdir}";
} else {
$sortorder .= " ${sortdir}";
$sortorder = "lower($sortorder) ${sortdir}";
} else {
$sortorder .= " ${sortdir}";
@@
-909,6
+911,7
@@
sub get_delivery {
my $arap = $form->{db} eq "vendor" ? "ap" : "ar";
my $db = $form->{db} eq "customer" ? "customer" : "vendor";
my $arap = $form->{db} eq "vendor" ? "ap" : "ar";
my $db = $form->{db} eq "customer" ? "customer" : "vendor";
+ my $qty_sign = $form->{db} eq 'vendor' ? ' * -1 AS qty' : '';
my $where = " WHERE 1=1 ";
my @values;
my $where = " WHERE 1=1 ";
my @values;
@@
-930,7
+933,7
@@
sub get_delivery {
push(@values, conv_date($form->{to}));
}
my $query =
push(@values, conv_date($form->{to}));
}
my $query =
- qq|SELECT s.shiptoname, i.qty, | .
+ qq|SELECT s.shiptoname, i.qty
$qty_sign
, | .
qq| ${arap}.id, ${arap}.transdate, ${arap}.invnumber, ${arap}.ordnumber, | .
qq| i.description, i.unit, i.sellprice, | .
qq| oe.id AS oe_id | .
qq| ${arap}.id, ${arap}.transdate, ${arap}.invnumber, ${arap}.ordnumber, | .
qq| i.description, i.unit, i.sellprice, | .
qq| oe.id AS oe_id | .