summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xLedgerSMB/Form.pm26
-rwxr-xr-xsql/Pg-functions.sql4
-rw-r--r--sql/Pg-upgrade-2.6.17-2.6.18.sql3
3 files changed, 33 insertions, 0 deletions
diff --git a/LedgerSMB/Form.pm b/LedgerSMB/Form.pm
index 07c1b3c6..6bca3ddd 100755
--- a/LedgerSMB/Form.pm
+++ b/LedgerSMB/Form.pm
@@ -1280,6 +1280,32 @@ sub db_init {
}
}
+sub get_custom_queries {
+ my ($self, $tablename) = @_;
+ my @rc;
+ my %temphash;
+ my @elements;
+ my $query;
+ for (@{$self->{custom_db_fields}{$tablename}}){
+ @elements = split (/:/, $_);
+ push @{$temphash{$elements[0]}}, $elements[1];
+ }
+ for (keys %temphash){
+ $query = "SELECT ";
+ my $first = 1;
+ for (@{$temphash{$_}}){
+ $query .= "$_";
+ if ($first == 0){
+ $query .= ", "
+ }
+ $first = 0;
+ }
+ $query .= " FROM $_ WHERE field_id = ?";
+ push @rc, $query;
+ }
+ @rc;
+}
+
sub dbconnect {
my ($self, $myconfig) = @_;
diff --git a/sql/Pg-functions.sql b/sql/Pg-functions.sql
index c11def4d..26d23473 100755
--- a/sql/Pg-functions.sql
+++ b/sql/Pg-functions.sql
@@ -263,9 +263,11 @@ BEGIN
RETURN NEW;
END;
' LANGUAGE PLPGSQL;
+-- end function
CREATE TRIGGER parts_short AFTER UPDATE ON parts
FOR EACH ROW EXECUTE PROCEDURE trigger_parts_short();
+-- end function
CREATE OR REPLACE FUNCTION add_custom_field (VARCHAR, VARCHAR, VARCHAR)
RETURNS BOOL AS
@@ -296,6 +298,7 @@ BEGIN
RETURN TRUE;
END;
' LANGUAGE PLPGSQL;
+-- end function
CREATE OR REPLACE FUNCTION drop_custom_field (VARCHAR, VARCHAR)
RETURNS BOOL AS
@@ -313,3 +316,4 @@ BEGIN
RETURN TRUE;
END;
' LANGUAGE PLPGSQL;
+-- end function
diff --git a/sql/Pg-upgrade-2.6.17-2.6.18.sql b/sql/Pg-upgrade-2.6.17-2.6.18.sql
index 39c726b6..b18e327e 100644
--- a/sql/Pg-upgrade-2.6.17-2.6.18.sql
+++ b/sql/Pg-upgrade-2.6.17-2.6.18.sql
@@ -94,6 +94,7 @@ BEGIN
RETURN NEW;
END;
' LANGUAGE PLPGSQL;
+-- end function
CREATE TRIGGER parts_short AFTER UPDATE ON parts
FOR EACH ROW EXECUTE PROCEDURE trigger_parts_short();
@@ -263,6 +264,7 @@ BEGIN
RETURN TRUE;
END;
' LANGUAGE PLPGSQL;
+-- end function
CREATE OR REPLACE FUNCTION drop_custom_field (VARCHAR, VARCHAR)
RETURNS BOOL AS
@@ -280,5 +282,6 @@ BEGIN
RETURN TRUE;
END;
' LANGUAGE PLPGSQL;
+-- end function
UPDATE defaults SET version = '2.6.18';