package Koha::Plugin::Pt::KEEPS::BackofficeDesign;

use Modern::Perl;

use C4::Context;
use base qw(Koha::Plugins::Base);

our $VERSION = '1.0';

our $metadata = {
    name   => 'KEEPS - Backoffice Design',
    author => 'Keep Solutions',
    description => 'Install files for backoffice designs',
    date_authored   => '2023-05-31',
    date_updated    => undef,
    minimum_version => '21.05',
    maximum_version => undef,
    version         => $VERSION,
};

sub new {
    my ( $class, $args ) = @_;

    $args->{'metadata'} = $metadata;
    $args->{'metadata'}->{'class'} = $class;

    my $self = $class->SUPER::new($args);


    return $self;
}

# Mandatory even if does nothing
sub install {
    my ( $self, $args ) = @_;

    my $back_office_path = '/KEEPS/koha/intranet/htdocs/intranet-tmpl/prog/css/keeps/backoffice.css';
    my $images_path='/KEEPS/koha/intranet/htdocs/intranet-tmpl/prog/images';

    # Use default design when there isn't anything
    #  coming from the COPY_IN
    if(!-f $back_office_path){
        system("cp -r /KEEPS/koha/var/lib/koha/plugins/Koha/Plugin/Pt/KEEPS/BackofficeDesign/design/css/keeps/backofficeoffice.css /KEEPS/koha/intranet/htdocs/intranet-tmpl/prog/css/keeps");
    }
    if(!-d $images_path){
        system("cp -r /KEEPS/koha/var/lib/koha/plugins/Koha/Plugin/Pt/KEEPS/BackofficeDesign/design/images /KEEPS/koha/intranet/htdocs/intranet-tmpl/prog");
    }
    return 1;
}

# Mandatory even if does nothing
sub upgrade {
    my ( $self, $args ) = @_;

    return 1;
}

# Mandatory even if does nothing
sub uninstall {
    my ( $self, $args ) = @_;

    return 1;
}

sub intranet_js {
    my ( $self ) = @_;

    return qq%

%;
}

sub opac_js {
    my ( $self ) = @_;
    
    return qq%
%;
}

1;

