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

SF.net SVN: ledger-smb:[5038] branches/1.3



Revision: 5038
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=5038&view=rev
Author:   einhverfr
Date:     2012-07-25 07:43:11 +0000 (Wed, 25 Jul 2012)
Log Message:
-----------
Adding retrieval for parts image to file retrieval

Modified Paths:
--------------
    branches/1.3/Changelog
    branches/1.3/sql/modules/Files.sql

Modified: branches/1.3/Changelog
===================================================================
--- branches/1.3/Changelog	2012-07-25 06:35:33 UTC (rev 5037)
+++ branches/1.3/Changelog	2012-07-25 07:43:11 UTC (rev 5038)
@@ -13,6 +13,7 @@
 * Saving a part now returns to editing the same part (Chris T, h/t Brian W)
 * If pos.conf.pl is not found, now returns an intelligible error (Chris T)
 * Adding action/id div to top of many screens (Chris T, h/t Erik H)
+* File->get_for_template now gets most recent parts image (Chris T)
 
 Changelog for 1.3.20
 * Fixes for es_AR translation, duplicate keys removed (Andres B)

Modified: branches/1.3/sql/modules/Files.sql
===================================================================
--- branches/1.3/sql/modules/Files.sql	2012-07-25 06:35:33 UTC (rev 5037)
+++ branches/1.3/sql/modules/Files.sql	2012-07-25 07:43:11 UTC (rev 5038)
@@ -157,14 +157,22 @@
 RETURNS SETOF file_list_item AS
 $$ 
 
-SELECT m.mime_type, f.file_name, f.description, f.uploaded_by, e.name, 
+SELECT m.mime_type, CASE WHEN f.file_class = 3 THEN ref_key ||'-'|| f.file_name
+                         ELSE f.file_name END, 
+       f.description, f.uploaded_by, e.name, 
        f.uploaded_at, f.id, f.ref_key, f.file_class,  f.content
   FROM mime_type m
   JOIN file_base f ON f.mime_type_id = m.id
   JOIN entity e ON f.uploaded_by = e.id
  WHERE f.ref_key = $1 and f.file_class = $2
-       AND m.invoice_include;
-
+       AND m.invoice_include 
+       OR id IN (SELECT max(id) 
+                   FROM file_base fb
+                   JOIN mime_type m ON fb.mime_type_id = m.id
+                        AND m.mime_type ilike 'image%'
+                   JOIN invoice i ON i.trans_id = in_ref_key 
+                        AND i.parts_id = fb.ref_key
+                  WHERE fb.file_class = 3)
 $$ language sql;
 
 

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