[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

SF.net SVN: ledger-smb:[4933] trunk



Revision: 4933
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=4933&view=rev
Author:   einhverfr
Date:     2012-06-20 14:58:42 +0000 (Wed, 20 Jun 2012)
Log Message:
-----------
Most of the work required to do file attachmets for employees, customers, and vendors

Modified Paths:
--------------
    trunk/LedgerSMB/Scripts/file.pm
    trunk/sql/modules/Files.sql

Added Paths:
-----------
    trunk/LedgerSMB/File/ECA.pm
    trunk/LedgerSMB/File/Entity.pm

Added: trunk/LedgerSMB/File/ECA.pm
===================================================================
--- trunk/LedgerSMB/File/ECA.pm	                        (rev 0)
+++ trunk/LedgerSMB/File/ECA.pm	2012-06-20 14:58:42 UTC (rev 4933)
@@ -0,0 +1,56 @@
+=pod
+
+=head1 NAME
+
+LedgerSMB::File::ECA - Manages attachments to customers and vendors
+
+=head1 SYNOPSIS
+
+TODO
+
+=head1 INHERITS
+
+=over
+
+=item  LedgerSMB::File
+
+Provides all properties and accessors.  This subclass provides additional 
+methods only
+
+=back
+
+=cut
+
+package LedgerSMB::File::ECA;
+use Moose;
+extends 'LedgerSMB::File';
+
+=head1 METHODS
+
+=over
+
+=item attach
+
+Attaches or links a specific file to the given transaction.
+
+=cut
+
+sub attach {
+    my ($self, $args) = @_;
+    $self->exec_method({funcname => 'file__attach_to_eca'});
+    $self->commit unless $args->{no_commit};
+}
+
+=back
+
+=head1 COPYRIGHT
+
+Copyright (C) 2011 The LedgerSMB Core Team
+
+This file is licensed under the Gnu General Public License version 2, or at your
+option any later version.  A copy of the license should have been included with
+your software.
+
+=cut
+
+1;

Added: trunk/LedgerSMB/File/Entity.pm
===================================================================
--- trunk/LedgerSMB/File/Entity.pm	                        (rev 0)
+++ trunk/LedgerSMB/File/Entity.pm	2012-06-20 14:58:42 UTC (rev 4933)
@@ -0,0 +1,56 @@
+=pod
+
+=head1 NAME
+
+LedgerSMB::File::Entity - File attachmets for contacts and entities
+
+=head1 SYNOPSIS
+
+TODO
+
+=head1 INHERITS
+
+=over
+
+=item  LedgerSMB::File
+
+Provides all properties and accessors.  This subclass provides additional 
+methods only
+
+=back
+
+=cut
+
+package LedgerSMB::File::Entity;
+use Moose;
+extends 'LedgerSMB::File';
+
+=head1 METHODS
+
+=over
+
+=item attach
+
+Attaches or links a specific file to the given transaction.
+
+=cut
+
+sub attach {
+    my ($self, $args) = @_;
+    $self->exec_method({funcname => 'file__attach_to_entity'});
+    $self->commit unless $args->{no_commit};
+}
+
+=back
+
+=head1 COPYRIGHT
+
+Copyright (C) 2011 The LedgerSMB Core Team
+
+This file is licensed under the Gnu General Public License version 2, or at your
+option any later version.  A copy of the license should have been included with
+your software.
+
+=cut
+
+1;

Modified: trunk/LedgerSMB/Scripts/file.pm
===================================================================
--- trunk/LedgerSMB/Scripts/file.pm	2012-06-20 14:47:55 UTC (rev 4932)
+++ trunk/LedgerSMB/Scripts/file.pm	2012-06-20 14:58:42 UTC (rev 4933)
@@ -25,6 +25,8 @@
 use LedgerSMB::File::Transaction;
 use LedgerSMB::File::Order;
 use LedgerSMB::File::Part;
+use LedgerSMB::File::Entity;
+use LedgerSMB::File::ECA;
 use strict;
 use CGI::Simple;
 

Modified: trunk/sql/modules/Files.sql
===================================================================
--- trunk/sql/modules/Files.sql	2012-06-20 14:47:55 UTC (rev 4932)
+++ trunk/sql/modules/Files.sql	2012-06-20 14:58:42 UTC (rev 4933)
@@ -90,6 +90,82 @@
 Note that currently links (setting id) is NOT supported because we dont have a
 use case of linking files to parts$$;
 
+CREATE OR REPLACE FUNCTION file__attach_to_entity
+(in_content bytea, in_mime_type_id int, in_file_name text,
+in_description text, in_id int, in_ref_key int, in_file_class int)
+RETURNS file_base
+AS
+$$
+DECLARE retval file_base;
+BEGIN
+   IF in_id IS NOT NULL THEN
+       IF in_content THEN
+          RAISE EXCEPTION $e$Can't specify id and content in attachment$e$;--'
+       END IF;
+       RAISE EXCEPTION 'links not implemented';
+       RETURN retval;
+   ELSE
+       INSERT INTO file_entity
+                   (content, mime_type_id, file_name, description, ref_key,
+                   file_class, uploaded_by, uploaded_at)
+            VALUES (in_content, in_mime_type_id, in_file_name, in_description,
+                   in_ref_key, in_file_class, person__get_my_entity_id(), 
+                   now());
+        SELECT * INTO retval FROM file_base 
+         where id = currval('file_base_id_seq');
+
+        RETURN retval;
+    END IF;
+END;
+$$ LANGUAGE PLPGSQL;
+
+COMMENT ON FUNCTION file__attach_to_entity
+(in_content bytea, in_mime_type_id int, in_file_name text,
+in_description text, in_id int, in_ref_key int, in_file_class int) IS
+$$ Attaches or links a file to a contact or entity.  in_content OR id can be 
+set. Setting both raises an exception.
+
+Note that currently links (setting id) is NOT supported because we dont have a
+use case of linking files to entities$$;
+
+CREATE OR REPLACE FUNCTION file__attach_to_eca
+(in_content bytea, in_mime_type_id int, in_file_name text,
+in_description text, in_id int, in_ref_key int, in_file_class int)
+RETURNS file_base
+AS
+$$
+DECLARE retval file_base;
+BEGIN
+   IF in_id IS NOT NULL THEN
+       IF in_content THEN
+          RAISE EXCEPTION $e$Can't specify id and content in attachment$e$;--'
+       END IF;
+       RAISE EXCEPTION 'links not implemented';
+       RETURN retval;
+   ELSE
+       INSERT INTO file_eca
+                   (content, mime_type_id, file_name, description, ref_key,
+                   file_class, uploaded_by, uploaded_at)
+            VALUES (in_content, in_mime_type_id, in_file_name, in_description,
+                   in_ref_key, in_file_class, person__get_my_entity_id(), 
+                   now());
+        SELECT * INTO retval FROM file_base 
+         where id = currval('file_base_id_seq');
+
+        RETURN retval;
+    END IF;
+END;
+$$ LANGUAGE PLPGSQL;
+
+COMMENT ON FUNCTION file__attach_to_eca
+(in_content bytea, in_mime_type_id int, in_file_name text,
+in_description text, in_id int, in_ref_key int, in_file_class int) IS
+$$ Attaches or links a file to a good or service.  in_content OR id can be set.
+Setting both raises an exception.
+
+Note that currently links (setting id) is NOT supported because we dont have a
+use case of linking files to entity credit accounts.$$;
+
 CREATE OR REPLACE FUNCTION file__attach_to_order
 (in_content bytea, in_mime_type_id int, in_file_name text,
 in_description text, in_id int, in_ref_key int, in_file_class int)

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.