[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
SF.net SVN: ledger-smb:[4708] branches/1.3
- Subject: SF.net SVN: ledger-smb:[4708] branches/1.3
- From: ..hidden..
- Date: Sun, 13 May 2012 09:24:26 +0000
Revision: 4708
http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=4708&view=rev
Author: einhverfr
Date: 2012-05-13 09:24:26 +0000 (Sun, 13 May 2012)
Log Message:
-----------
Updated changelog
Modified Paths:
--------------
branches/1.3/Changelog
branches/1.3/LedgerSMB/AM.pm
branches/1.3/LedgerSMB/File.pm
branches/1.3/LedgerSMB/Form.pm
branches/1.3/Makefile.PL
branches/1.3/UI/am-defaults.html
branches/1.3/bin/am.pl
branches/1.3/bin/io.pl
branches/1.3/sql/Pg-database.sql
branches/1.3/sql/modules/Files.sql
branches/1.3/sql/modules/Fixes.sql
Modified: branches/1.3/Changelog
===================================================================
--- branches/1.3/Changelog 2012-05-12 12:25:14 UTC (rev 4707)
+++ branches/1.3/Changelog 2012-05-13 09:24:26 UTC (rev 4708)
@@ -7,6 +7,8 @@
* Taxes::Simple now respects min/max values based on subtotal (Chris T)
* Fixed company name/address missing from income statement (Chris T, h/t Mark L)
* Fixed company name/address missing from balance sheet (Chris T, h/t Mark L)
+* Optional image retrieval with size detection for latex templates (Chris T)
+* Added option to attach images to LaTeX PDF invoices/orders/etc (Chris T)
Mark L is Matt Lubratt
Modified: branches/1.3/LedgerSMB/AM.pm
===================================================================
--- branches/1.3/LedgerSMB/AM.pm 2012-05-12 12:25:14 UTC (rev 4707)
+++ branches/1.3/LedgerSMB/AM.pm 2012-05-13 09:24:26 UTC (rev 4708)
@@ -1704,7 +1704,7 @@
sonumber ponumber sqnumber rfqnumber partnumber
employeenumber customernumber vendornumber projectnumber
yearend curr weightunit businessnumber default_country
- check_prefix password_duration templates vclimit)
+ check_prefix password_duration templates vclimit template_images)
}
for (@$defaults)
{
Modified: branches/1.3/LedgerSMB/File.pm
===================================================================
--- branches/1.3/LedgerSMB/File.pm 2012-05-12 12:25:14 UTC (rev 4707)
+++ branches/1.3/LedgerSMB/File.pm 2012-05-13 09:24:26 UTC (rev 4708)
@@ -75,10 +75,25 @@
ID of class of the original attachment point (for a link)
+=item file_path
+
+Path, relative to $LedgerSMB::tempdir, where file data is stored (for LaTeX use
+of attached images).
+
=item dbobject
Object for db interface.
+=item sizex
+
+X axis dimensions, if Image::Size is installed and file is image (only on files
+retrieved for invoices).
+
+=item sizey
+
+Y axis dimensions, if Image::Size is installed and file is image (only on files
+retrieved for invoices).
+
=item x_info
A hash for extended information
@@ -105,6 +120,9 @@
file_class => '$',
src_class => '$',
dbobject => 'LedgerSMB::DBObject',
+ file_path => '$',
+ sizex => '$',
+ sizey => '$',
x_info => '%'
};
@@ -271,6 +289,52 @@
$self->merge($ref);
}
+=item get_for_template({ref_key => int, file_class => int})
+
+Returns file data for invoices for embedded images, except that content is set
+to a directive relative to tempdir where these files are stored.
+
+=cut
+
+sub get_for_template{
+ my ($self, $args) = @_;
+
+ my @results = $self->exec_method(
+ {funcname => 'file__get_for_template',
+ args => [$args->{ref_key}, $args->{file_class}]
+ }
+ );
+ if ( -d $LedgerSMB::Sysconfig::tempdir . '/' . $$){
+ die 'directory exists';
+ }
+ mkdir $LedgerSMB::Sysconfig::tempdir . '/' . $$;
+ $self->file_path($LedgerSMB::Sysconfig::tempdir . '/' . $$);
+
+ for my $result (@results) {
+ open FILE, '>', $self->file_path . "/$result->{file_name}";
+ print FILE $result->{content};
+ close FILE;
+ eval { # Block used so that Image::Size is optional
+ require Image::Size;
+ my ($x, $y);
+ ($x, $y) = imgsize(\{$result->{content}});
+ $result->{sizex} = $x;
+ $result->{sizey} = $y;
+ };
+ }
+}
+
+
+sub DESTROY {
+ my ($self) = $_;
+ opendir(TMP, $self->{file_path}) || return 1;
+ for my $file (readdir(TMP)){
+ unlink $self->{file_path} . '/' . $file;
+ }
+ closedir (TMP);
+ rmdir $self->{file_path};
+}
+
=item list({ref_key => int, file_class => int})
Lists files directly attached to the object.
Modified: branches/1.3/LedgerSMB/Form.pm
===================================================================
--- branches/1.3/LedgerSMB/Form.pm 2012-05-12 12:25:14 UTC (rev 4707)
+++ branches/1.3/LedgerSMB/Form.pm 2012-05-13 09:24:26 UTC (rev 4708)
@@ -1290,6 +1290,26 @@
qq|<button class="submit" type="submit" name="action" value="$name" accesskey="$button->{$name}{key}" title="$button->{$name}{value} [Alt-$button->{$name}{key}]">$button->{$name}{value}</button>\n|;
}
+
+=item test_should_get_images
+
+Returns true if images should get be retrieved for embedding in templates
+
+=cut
+
+
+sub test_should_get_images {
+ my ($self) = @_;
+ my $dbh = $self->{dbh};
+ my $sth = $dbh->prepare(
+ "SELECT value FROM defaults WHERE setting_key = 'template_images'"
+ );
+ $sth->execute;
+ my ($retval) = $sth->fetchrow_array();
+ return $retval;
+}
+
+
# Database routines used throughout
=item $form->db_init($myconfig);
Modified: branches/1.3/Makefile.PL
===================================================================
--- branches/1.3/Makefile.PL 2012-05-12 12:25:14 UTC (rev 4707)
+++ branches/1.3/Makefile.PL 2012-05-13 09:24:26 UTC (rev 4708)
@@ -39,6 +39,10 @@
test_requires 'Test::Trap';
test_requires 'Test::Exception';
+feature 'Size detection for images for embedding in LaTeX templates',
+ -default => 1,
+ 'Image::Size' => 0;
+
feature 'POS module credit card processing support',
-default => 0,
'Net::TCLink' => 0;
Modified: branches/1.3/UI/am-defaults.html
===================================================================
--- branches/1.3/UI/am-defaults.html 2012-05-12 12:25:14 UTC (rev 4707)
+++ branches/1.3/UI/am-defaults.html 2012-05-13 09:24:26 UTC (rev 4708)
@@ -34,6 +34,10 @@
<th align="right"><?lsmb text('Separate Duties') ?></th>
<td><input name="separate_duties" size="5" value="<?lsmb form.separate_duties ?>" /></td>
</tr>
+ <tr>
+ <th align="right"><?lsmb text('Images in Templates') ?></th>
+ <td><input name="template_images" size="5" value="<?lsmb form.template_images ?>" /></td>
+ </tr>
<tr>
<th align="right"><?lsmb text('default_language') ?></th>
<td>
Modified: branches/1.3/bin/am.pl
===================================================================
--- branches/1.3/bin/am.pl 2012-05-12 12:25:14 UTC (rev 4707)
+++ branches/1.3/bin/am.pl 2012-05-13 09:24:26 UTC (rev 4708)
@@ -80,7 +80,7 @@
my @default_others = qw(businessnumber weightunit separate_duties default_language
inventory_accno_id income_accno_id expense_accno_id
fxgain_accno_id fxloss_accno_id default_country
- templates curr);
+ templates curr template_images);
sub save_as_new {
Modified: branches/1.3/bin/io.pl
===================================================================
--- branches/1.3/bin/io.pl 2012-05-12 12:25:14 UTC (rev 4707)
+++ branches/1.3/bin/io.pl 2012-05-13 09:24:26 UTC (rev 4708)
@@ -43,6 +43,7 @@
use LedgerSMB::Template;
use LedgerSMB::Sysconfig;
use LedgerSMB::Company_Config;
+use LedgerSMB::File;
# any custom scripts for this one
if ( -f "bin/custom/io.pl" ) {
@@ -1576,6 +1577,26 @@
$order = 1;
}
+ if ($form->test_should_get_images){
+ my $file = LedgerSMB::File->new();
+ $file->new_dbobject({base => $form, locale => $locale});
+ my @files;
+ my $fc;
+ if ($inv eq 'inv') {
+ $fc = 1;
+ } else {
+ $fc = 2;
+ }
+ my @files = $file->get_for_template(
+ {ref_key => $form->{id}, file_class => $fc}
+ );
+ $form->{file_list} = ..hidden..;
+ $form->{file_path} = $file->file_path;
+ $form->error($file->file_path);
+ }
+
+ $form->error;
+
&validate_items;
$form->{"${inv}date"} = $form->{transdate};
Modified: branches/1.3/sql/Pg-database.sql
===================================================================
--- branches/1.3/sql/Pg-database.sql 2012-05-12 12:25:14 UTC (rev 4707)
+++ branches/1.3/sql/Pg-database.sql 2012-05-13 09:24:26 UTC (rev 4708)
@@ -3768,7 +3768,8 @@
CREATE TABLE mime_type (
id serial not null unique,
- mime_type text primary key
+ mime_type text primary key,
+ invoice_include bool default false,
);
COMMENT ON TABLE mime_type IS
@@ -4459,6 +4460,8 @@
INSERT INTO mime_type (mime_type) VALUES('application/vnd.ms-tnef');
INSERT INTO mime_type (mime_type) VALUES('video/vnd.rn-realvideo');
+UPDATE mime_type SET invoice_include = 'true' where mime_type like 'image/%';
+
CREATE TABLE file_class (
id serial not null unique,
class text primary key
Modified: branches/1.3/sql/modules/Files.sql
===================================================================
--- branches/1.3/sql/modules/Files.sql 2012-05-12 12:25:14 UTC (rev 4707)
+++ branches/1.3/sql/modules/Files.sql 2012-05-13 09:24:26 UTC (rev 4708)
@@ -152,6 +152,22 @@
content bytea
);
+CREATE OR REPLACE FUNCTION file__get_for_template
+(in_ref_key int, in_file_class int)
+RETURNS SETOF file_list_item AS
+$$
+
+SELECT m.mime_type, f.file_name, 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;
+
+$$ language sql;
+
+
CREATE OR REPLACE FUNCTION file__list_by(in_ref_key int, in_file_class int)
RETURNS SETOF file_list_item AS
$$
Modified: branches/1.3/sql/modules/Fixes.sql
===================================================================
--- branches/1.3/sql/modules/Fixes.sql 2012-05-12 12:25:14 UTC (rev 4707)
+++ branches/1.3/sql/modules/Fixes.sql 2012-05-13 09:24:26 UTC (rev 4708)
@@ -240,7 +240,6 @@
COMMIT;
BEGIN; -- Search Assets menu
-UPDATE update menu_node set position = 3 where position = 2 and parent = 229;
update menu_node set parent = 229 where id = 233;
COMMIT;
@@ -271,3 +270,10 @@
COMMIT;
+
+BEGIN;
+
+ALTER TABLE mime_type ADD invoice_include bool default false;
+UPDATE mime_type SET invoice_include = 'true' where mime_type like 'image/%';
+
+COMMIT;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.