107 lines
2.2 KiB
Perl
107 lines
2.2 KiB
Perl
=head1 NAME
|
|
|
|
App::api::actions::Action_Print
|
|
|
|
=head1 DESCRIPTION
|
|
|
|
Action to print.
|
|
|
|
=head1 ARGUMENTS
|
|
|
|
(
|
|
TYPE => 'Print',
|
|
ID => 'print' (default),
|
|
LABEL => 'Print' (default)
|
|
)
|
|
|
|
=cut
|
|
|
|
use strict;
|
|
use warnings;
|
|
use utf8;
|
|
|
|
package Dam::Components::Actions::Print;
|
|
|
|
use Exporter qw(import);
|
|
our @EXPORT = qw(
|
|
Action__html Action__js
|
|
);
|
|
|
|
use Dam::Util;
|
|
use Dam::DamLogic;
|
|
|
|
|
|
|
|
my $ID_DEFAULT = 'print';
|
|
|
|
|
|
|
|
sub __arguments {
|
|
my $arg_ref = shift;
|
|
|
|
check_arguments($arg_ref,
|
|
TYPE => [ ARG_REQUIRED ],
|
|
ID => [ ARG_DEFAULT, $ID_DEFAULT ],
|
|
LABEL => [ ARG_DEFAULT, _t('Print') ]
|
|
);
|
|
}
|
|
|
|
|
|
|
|
sub Action__html {
|
|
my ($self, $arg_ref, $info_ref) = @_;
|
|
|
|
__arguments($arg_ref);
|
|
|
|
return is_report() ? strval('
|
|
<button type="button" class="btn btn-success input-lg" id="', $$arg_ref{ID},'"><span class="glyphicon glyphicon-print"></span> ', $$arg_ref{LABEL},'</button>
|
|
') : '';
|
|
}
|
|
|
|
|
|
|
|
sub Action__js {
|
|
my ($self, $arg_ref) = @_;
|
|
|
|
__arguments($arg_ref);
|
|
|
|
return is_report() ? strval('
|
|
$("#', $$arg_ref{ID},'").click(function(){
|
|
window.print();
|
|
});
|
|
') : '';
|
|
}
|
|
|
|
|
|
|
|
1;
|
|
|
|
=head1 AUTHOR
|
|
|
|
Manuel Cillero C<< <manuel@cillero.es> >>
|
|
|
|
=head1 COPYRIGHT
|
|
|
|
The MIT License (MIT)
|
|
|
|
Copyright (c) 2004-2020 Manuel Cillero. All rights reserved.
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
in the Software without restriction, including without limitation the rights
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
furnished to do so, subject to the following conditions:
|
|
|
|
The above copyright notice and this permission notice shall be included in all
|
|
copies or substantial portions of the Software.
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
SOFTWARE.
|
|
|
|
=cut
|