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

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



Revision: 6338
          http://sourceforge.net/p/ledger-smb/code/6338
Author:   einhverfr
Date:     2014-01-02 03:34:58 +0000 (Thu, 02 Jan 2014)
Log Message:
-----------
Adding routines for db-storage of invoice templates and the like

Modified Paths:
--------------
    trunk/UI/am-taxes.html
    trunk/sql/Pg-database.sql
    trunk/sql/modules/Fixes.sql
    trunk/sql/modules/LOADORDER

Added Paths:
-----------
    trunk/sql/modules/Templates.sql

Modified: trunk/UI/am-taxes.html
===================================================================
--- trunk/UI/am-taxes.html	2014-01-01 23:33:19 UTC (rev 6337)
+++ trunk/UI/am-taxes.html	2014-01-02 03:34:58 UTC (rev 6338)
@@ -22,7 +22,7 @@
 	  <td><input name="taxrate_<?lsmb i ?>" size="6" value="<?lsmb form.item("taxrate_$i") ?>" /></td>
 	  <td><input name="minvalue_<?lsmb i ?>" size="6" value="<?lsmb form.item("minvalue_$i") ?>" /></td>
 	  <td><input name="taxnumber_<?lsmb i ?>" value="<?lsmb form.item("taxnumber_$i") ?>" /></td>
-	  <td><input class="date" name="validto_<?lsmb i ?>" size="11" value="<?lsmb form.item("validto_$i") ?>" title="<?lsmb user.dateformat ?>" /></td>
+	  <td><input class="date" id="validto-<?lsmb i ?>" name="validto_<?lsmb i ?>" size="11" value="<?lsmb form.item("validto_$i") ?>" title="<?lsmb user.dateformat ?>" /></td>
 	  <td><input name="pass_<?lsmb i ?>" size="6" value="<?lsmb form.item("pass_$i") ?>" /></td>
 	  <td><?lsmb PROCESS select element_data=row.1 ?></td>
 	</tr>

Modified: trunk/sql/Pg-database.sql
===================================================================
--- trunk/sql/Pg-database.sql	2014-01-01 23:33:19 UTC (rev 6337)
+++ trunk/sql/Pg-database.sql	2014-01-02 03:34:58 UTC (rev 6338)
@@ -4850,4 +4850,15 @@
 -- helpful to keeping the selection of all years fast
 create index ac_transdate_year_idx on acc_trans(EXTRACT ('YEAR' FROM transdate));
 
+CREATE TABLE template ( -- not for UI templates
+    id serial not null unique,
+    template_name text not null,
+    language_code varchar(6) references language(code),
+    template text not null,
+    unique(template_name, language_code)
+);
+
+CREATE UNIQUE INDEX template_name_idx_u ON template(template_name) 
+WHERE language_code is null; -- Pseudo-Pkey
+
 commit;

Modified: trunk/sql/modules/Fixes.sql
===================================================================
--- trunk/sql/modules/Fixes.sql	2014-01-01 23:33:19 UTC (rev 6337)
+++ trunk/sql/modules/Fixes.sql	2014-01-02 03:34:58 UTC (rev 6338)
@@ -297,3 +297,18 @@
 
 COMMIT;
 
+BEGIN;
+
+CREATE TABLE template ( -- not for UI templates
+    id serial not null unique,
+    template_name text not null,
+    language_code varchar(6) references language(code),
+    template text not null,
+    unique(template_name, language_code)
+);
+
+CREATE UNIQUE INDEX template_name_idx_u ON template(template_name) 
+WHERE language_code is null; -- Pseudo-Pkey
+
+commit;
+

Modified: trunk/sql/modules/LOADORDER
===================================================================
--- trunk/sql/modules/LOADORDER	2014-01-01 23:33:19 UTC (rev 6337)
+++ trunk/sql/modules/LOADORDER	2014-01-02 03:34:58 UTC (rev 6338)
@@ -40,3 +40,4 @@
 OrderEntry.sql
 Goods.sql
 Roles.sql
+Templates.sql

Added: trunk/sql/modules/Templates.sql
===================================================================
--- trunk/sql/modules/Templates.sql	                        (rev 0)
+++ trunk/sql/modules/Templates.sql	2014-01-02 03:34:58 UTC (rev 6338)
@@ -0,0 +1,37 @@
+BEGIN;
+
+CREATE OR REPLACE FUNCTION template__get(
+in_template_name text, in_language_code varchar(6)
+) RETURNS template language sql as
+$$
+SELECT * FROM template 
+ WHERE template_name = $1 AND language_code IS NOT DISTINCT FROM $2;
+$$;
+
+CREATE OR REPLACE FUNCTION template__get_by_id(in_id int)
+RETURNS template language sql as
+$$
+SELECT * FROM template WHERE id = $1;
+$$;
+
+CREATE OR REPLACE FUNCTION template__save(
+in_template_name text, in_language_code varchar(6), in_template text
+) 
+RETURNS template LANGUAGE PLPGSQL AS
+$$
+BEGIN
+   UPDATE template SET template = in_template
+    WHERE template_name = in_template_name AND
+          language_code IS NOT DISTINCT FROM in_language_code;
+          
+   IF FOUND THEN
+      RETURN template_get(in_template_name, in_language_code);
+   END;
+   INSERT INTO template (template_name, language_code, template)
+   VALUES (in_template_name, language_code, template);
+
+   RETURN template_get(in_template_name, in_language_code);
+END;
+$$;
+
+COMMIT;

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


------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT 
organizations don't have a clear picture of how application performance 
affects their revenue. With AppDynamics, you get 100% visibility into your 
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
_______________________________________________
Ledger-smb-commits mailing list
..hidden..
https://lists.sourceforge.net/lists/listinfo/ledger-smb-commits