[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
SF.net SVN: ledger-smb:[3623] trunk
- Subject: SF.net SVN: ledger-smb:[3623] trunk
- From: ..hidden..
- Date: Thu, 04 Aug 2011 00:09:36 +0000
Revision: 3623
http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=3623&view=rev
Author: einhverfr
Date: 2011-08-04 00:09:35 +0000 (Thu, 04 Aug 2011)
Log Message:
-----------
File attachments now work for invoices and orders. Binary data is getting corrupted and working on fixing that, however
Modified Paths:
--------------
trunk/LedgerSMB/AA.pm
trunk/LedgerSMB/IR.pm
trunk/LedgerSMB/IS.pm
trunk/LedgerSMB/OE.pm
trunk/bin/ir.pl
trunk/bin/is.pl
trunk/bin/oe.pl
trunk/scripts/file.pl
Modified: trunk/LedgerSMB/AA.pm
===================================================================
--- trunk/LedgerSMB/AA.pm 2011-08-03 22:57:59 UTC (rev 3622)
+++ trunk/LedgerSMB/AA.pm 2011-08-04 00:09:35 UTC (rev 3623)
@@ -721,6 +721,7 @@
);
}
+
=item delete_transaction(\%myconfig, $form)
Deletes a transaction identified by $form->{id}, whether it is an ar or ap
Modified: trunk/LedgerSMB/IR.pm
===================================================================
--- trunk/LedgerSMB/IR.pm 2011-08-03 22:57:59 UTC (rev 3622)
+++ trunk/LedgerSMB/IR.pm 2011-08-04 00:09:35 UTC (rev 3623)
@@ -37,6 +37,29 @@
use LedgerSMB::Sysconfig;
use Math::BigFloat;
+=over
+
+=item get_files
+
+Returns a list of files associated with the existing transaction. This is
+provisional, and will change for 1.4 as the GL transaction functionality is
+ {ref_key => $self->{id}, file_class => 1}
+rewritten
+
+=cut
+
+sub get_files {
+ my ($self, $form, $locale) = @_;
+ return if !$form->{id};
+ my $file = LedgerSMB::File->new();
+ $file->new_dbobject({base => $form, locale => $locale});
+ @{$form->{files}} = $file->list({ref_key => $form->{id}, file_class => 1});
+ @{$form->{file_links}} = $file->list_links(
+ {ref_key => $form->{id}, file_class => 1}
+ );
+
+}
+
sub post_invoice {
my ( $self, $myconfig, $form ) = @_;
Modified: trunk/LedgerSMB/IS.pm
===================================================================
--- trunk/LedgerSMB/IS.pm 2011-08-03 22:57:59 UTC (rev 3622)
+++ trunk/LedgerSMB/IS.pm 2011-08-04 00:09:35 UTC (rev 3623)
@@ -73,6 +73,29 @@
$sth->finish;
}
+=over
+
+=item get_files
+
+Returns a list of files associated with the existing transaction. This is
+provisional, and will change for 1.4 as the GL transaction functionality is
+ {ref_key => $self->{id}, file_class => 1}
+rewritten
+
+=cut
+
+sub get_files {
+ my ($self, $form, $locale) = @_;
+ return if !$form->{id};
+ my $file = LedgerSMB::File->new();
+ $file->new_dbobject({base => $form, locale => $locale});
+ @{$form->{files}} = $file->list({ref_key => $form->{id}, file_class => 1});
+ @{$form->{file_links}} = $file->list_links(
+ {ref_key => $form->{id}, file_class => 1}
+ );
+
+}
+
sub clear_till {
my ( $self, $myconfig, $form ) = @_;
%pos_config = %{ $form->{pos_config} };
@@ -2704,3 +2727,4 @@
1;
+
Modified: trunk/LedgerSMB/OE.pm
===================================================================
--- trunk/LedgerSMB/OE.pm 2011-08-03 22:57:59 UTC (rev 3622)
+++ trunk/LedgerSMB/OE.pm 2011-08-04 00:09:35 UTC (rev 3623)
@@ -36,6 +36,29 @@
use LedgerSMB::Tax;
use LedgerSMB::Sysconfig;
+=over
+
+=item get_files
+
+Returns a list of files associated with the existing transaction. This is
+provisional, and will change for 1.4 as the GL transaction functionality is
+ {ref_key => $self->{id}, file_class => 2}
+rewritten
+
+=cut
+
+sub get_files {
+ my ($self, $form, $locale) = @_;
+ return if !$form->{id};
+ my $file = LedgerSMB::File->new();
+ $file->new_dbobject({base => $form, locale => $locale});
+ @{$form->{files}} = $file->list({ref_key => $form->{id}, file_class => 2});
+ @{$form->{file_links}} = $file->list_links(
+ {ref_key => $form->{id}, file_class => 2}
+ );
+
+}
+
sub transactions {
my ( $self, $myconfig, $form ) = @_;
Modified: trunk/bin/ir.pl
===================================================================
--- trunk/bin/ir.pl 2011-08-03 22:57:59 UTC (rev 3622)
+++ trunk/bin/ir.pl 2011-08-04 00:09:35 UTC (rev 3623)
@@ -865,6 +865,63 @@
}
}
+ if ($form->{id}){
+ IR->get_files($form, $locale);
+ print qq|
+<table width="100%">
+<tr class="listtop">
+<th colspan="4">| . $locale->text('Attached and Linked Files') . qq|</th>
+<tr class="listheading">
+<th>| . $locale->text('File name') . qq|</th>
+<th>| . $locale->text('File type') . qq|</th>
+<th>| . $locale->text('Attached at') . qq|</th>
+<th>| . $locale->text('Attached by') . qq|</th>
+</tr> |;
+ foreach my $file (@{$form->{files}}){
+ print qq|
+<tr>
+<td><a href="file.pl?action=get&file_class=1&ref_key=$form->{id}&id=$file->{id}"
+ >$file->{file_name}</a></td>
+<td>$file->{mime_type}</td>
+<td>$file->{uploaded_at}</td>
+<td>$file->{uploaded_by_name}</td>
+</tr>
+ |;
+ }
+ print qq|
+<table width="100%">
+<tr class="listheading">
+<th>| . $locale->text('File name') . qq|</th>
+<th>| . $locale->text('File type') . qq|</th>
+<th>| . $locale->text('Attached To Type') . qq|</th>
+<th>| . $locale->text('Attached To') . qq|</th>
+<th>| . $locale->text('Attached at') . qq|</th>
+<th>| . $locale->text('Attached by') . qq|</th>
+</tr>|;
+ foreach my $link (@{$form->{file_links}}){
+ $aclass=" ";
+ if ($link.src_class == 1){
+ $aclass="Transaction";
+ } elsif ($link.src_class == 2){
+ $aclass="Order";
+ }
+ print qq|
+<tr>
+<td> $file->{file_name} </td>
+<td> $file->{mime_type} </td>
+<td> $aclass </td>
+<td> $file->{reference} </td>
+<td> $file->{attached_at} </td>
+<td> $file->{attached_by} </td>
+</tr>|;
+ }
+ print qq|
+</table>|;
+ $callback = $form->escape("ir.pl?action=edit&id=".$form->{id});
+ print qq|
+<a href="file.pl?action=show_attachment_screen&ref_key=$form->{id}&file_class=1&callback=$callback"
+ >[| . $locale->text('Attach') . qq|]</a>|;
+ }
if ( $form->{lynx} ) {
require "bin/menu.pl";
Modified: trunk/bin/is.pl
===================================================================
--- trunk/bin/is.pl 2011-08-03 22:57:59 UTC (rev 3622)
+++ trunk/bin/is.pl 2011-08-04 00:09:35 UTC (rev 3623)
@@ -996,6 +996,63 @@
}
+ if ($form->{id}){
+ IS->get_files($form, $locale);
+ print qq|
+<table width="100%">
+<tr class="listtop">
+<th colspan="4">| . $locale->text('Attached and Linked Files') . qq|</th>
+<tr class="listheading">
+<th>| . $locale->text('File name') . qq|</th>
+<th>| . $locale->text('File type') . qq|</th>
+<th>| . $locale->text('Attached at') . qq|</th>
+<th>| . $locale->text('Attached by') . qq|</th>
+</tr> |;
+ foreach my $file (@{$form->{files}}){
+ print qq|
+<tr>
+<td><a href="file.pl?action=get&file_class=1&ref_key=$form->{id}&id=$file->{id}"
+ >$file->{file_name}</a></td>
+<td>$file->{mime_type}</td>
+<td>$file->{uploaded_at}</td>
+<td>$file->{uploaded_by_name}</td>
+</tr>
+ |;
+ }
+ print qq|
+<table width="100%">
+<tr class="listheading">
+<th>| . $locale->text('File name') . qq|</th>
+<th>| . $locale->text('File type') . qq|</th>
+<th>| . $locale->text('Attached To Type') . qq|</th>
+<th>| . $locale->text('Attached To') . qq|</th>
+<th>| . $locale->text('Attached at') . qq|</th>
+<th>| . $locale->text('Attached by') . qq|</th>
+</tr>|;
+ foreach my $link (@{$form->{file_links}}){
+ $aclass=" ";
+ if ($link.src_class == 1){
+ $aclass="Transaction";
+ } elsif ($link.src_class == 2){
+ $aclass="Order";
+ }
+ print qq|
+<tr>
+<td> $file->{file_name} </td>
+<td> $file->{mime_type} </td>
+<td> $aclass </td>
+<td> $file->{reference} </td>
+<td> $file->{attached_at} </td>
+<td> $file->{attached_by} </td>
+</tr>|;
+ }
+ print qq|
+</table>|;
+ $callback = $form->escape("is.pl?action=edit&id=".$form->{id});
+ print qq|
+<a href="file.pl?action=show_attachment_screen&ref_key=$form->{id}&file_class=1&callback=$callback"
+ >[| . $locale->text('Attach') . qq|]</a>|;
+ }
if ( $form->{lynx} ) {
require "bin/menu.pl";
&menubar;
Modified: trunk/bin/oe.pl
===================================================================
--- trunk/bin/oe.pl 2011-08-03 22:57:59 UTC (rev 3622)
+++ trunk/bin/oe.pl 2011-08-04 00:09:35 UTC (rev 3623)
@@ -871,6 +871,63 @@
for ( sort { $button{$a}->{ndx} <=> $button{$b}->{ndx} } keys %button ) {
$form->print_button( \%button, $_ );
}
+ if ($form->{id}){
+ OE->get_files($form, $locale);
+ print qq|
+<table width="100%">
+<tr class="listtop">
+<th colspan="4">| . $locale->text('Attached and Linked Files') . qq|</th>
+<tr class="listheading">
+<th>| . $locale->text('File name') . qq|</th>
+<th>| . $locale->text('File type') . qq|</th>
+<th>| . $locale->text('Attached at') . qq|</th>
+<th>| . $locale->text('Attached by') . qq|</th>
+</tr> |;
+ foreach my $file (@{$form->{files}}){
+ print qq|
+<tr>
+<td><a href="file.pl?action=get&file_class=1&ref_key=$form->{id}&id=$file->{id}"
+ >$file->{file_name}</a></td>
+<td>$file->{mime_type}</td>
+<td>$file->{uploaded_at}</td>
+<td>$file->{uploaded_by_name}</td>
+</tr>
+ |;
+ }
+ print qq|
+<table width="100%">
+<tr class="listheading">
+<th>| . $locale->text('File name') . qq|</th>
+<th>| . $locale->text('File type') . qq|</th>
+<th>| . $locale->text('Attached To Type') . qq|</th>
+<th>| . $locale->text('Attached To') . qq|</th>
+<th>| . $locale->text('Attached at') . qq|</th>
+<th>| . $locale->text('Attached by') . qq|</th>
+</tr>|;
+ foreach my $link (@{$form->{file_links}}){
+ $aclass=" ";
+ if ($link.src_class == 1){
+ $aclass="Transaction";
+ } elsif ($link.src_class == 2){
+ $aclass="Order";
+ }
+ print qq|
+<tr>
+<td> $file->{file_name} </td>
+<td> $file->{mime_type} </td>
+<td> $aclass </td>
+<td> $file->{reference} </td>
+<td> $file->{attached_at} </td>
+<td> $file->{attached_by} </td>
+</tr>|;
+ }
+ print qq|
+</table>|;
+ $callback = $form->escape("oe.pl?action=edit&id=".$form->{id});
+ print qq|
+<a href="file.pl?action=show_attachment_screen&ref_key=$form->{id}&file_class=1&callback=$callback"
+ >[| . $locale->text('Attach') . qq|]</a>|;
+ }
if ( $form->{lynx} ) {
require "bin/menu.pl";
Modified: trunk/scripts/file.pl
===================================================================
--- trunk/scripts/file.pl 2011-08-03 22:57:59 UTC (rev 3622)
+++ trunk/scripts/file.pl 2011-08-04 00:09:35 UTC (rev 3623)
@@ -93,6 +93,8 @@
my $fdata = join ("\n", <$fh>);
$file->content($fdata);
}
+ $request->{content} = $file->content;
+ $request->debug({file => '/tmp/file'});
$file->attach;
my $cgi = CGI::Simple->new;
print $cgi->redirect($request->{callback});
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.