use SL::Webdav::File;
use Rose::Object::MakeMethods::Generic (
- 'scalar --get_set_init' => [ qw(letter all_employees models) ],
+ 'scalar --get_set_init' => [ qw(letter all_employees models webdav_objects) ],
);
__PACKAGE__->run_before('check_auth_edit');
SL::DB::Manager::Employee->get_all(query => [ deleted => 0 ]);
}
+sub init_webdav_objects {
+ my ($self) = @_;
+
+ return [] if !$self->letter || !$self->letter->letternumber || !$::instance_conf->get_webdav;
+
+ my $webdav = SL::Webdav->new(
+ type => 'letter',
+ number => $self->letter->letternumber,
+ );
+
+ my $webdav_path = $webdav->webdav_path;
+ my @all_objects = $webdav->get_all_objects;
+
+ return [ map {
+ +{ name => $_->filename,
+ type => t8('File'),
+ link => File::Spec->catdir($webdav_path, $_->filename),
+ }
+ } @all_objects ];
+}
+
sub check_auth_edit {
$::auth->assert('sales_letter_edit');
}
[%- USE L %]
[%- USE P %]
[%- USE LxERP %]
+[%- SET WEBDAV = SELF.webdav_objects %]
<h1>[% title | html %]</h1>
<form action='controller.pl' method='POST'>
<ul>
<li><a href="#ui-tabs-letter">[% LxERP.t8("Letter") %]</a></li>
[%- IF letter.id %]
+ [%- IF INSTANCE_CONF.get_webdav %]
+ <li><a href="#ui-tabs-webdav">[% LxERP.t8('WebDAV') %]</a></li>
+ [%- END %]
<li><a href="controller.pl?action=RecordLinks/ajax_list&object_model=Letter&object_id=[% HTML.url(letter.id) %]">[% LxERP.t8("Linked Records") %]</a></li>
[%- END %]
</ul>
</table>
</div>
+ [% PROCESS 'webdav/_list.html' %]
<div id="ui-tabs-1">
[%- LxERP.t8("Loading...") %]
</div>