use utf8;
use warnings; no warnings "redefine";
use strict;
use Dbase::Help qw(DoFn Do qquote);
use Dbase::Globals qw(content);
use Fehler qw(problem);
use Loader qw(line_in log_update);

sub set_messtyp_collectd_intervall($;$) {
    my ( $idi, $kn ) = @_;

    content( my $collectd_intervall = line_in 'Collectd Intervall: ' )
      or return;

    return problem "Das ist ein Pflichtfeld und kann daher nicht gelöscht werden.\n"
      if $collectd_intervall eq '-';
    return problem( qq(Das ist kein gültiges Intervall (nur Ziffern).) )
      if $collectd_intervall !~ /^\d+\z/;

    $collectd_intervall = qquote($collectd_intervall);
    return $collectd_intervall unless defined $idi;

    log_update mess_typ => id => $idi, undef, 'collectd_intervall', undef,
        DoFn("SELECT collectd_intervall FROM mess_typ WHERE id = $idi");
    Do("UPDATE mess_typ SET collectd_intervall = $collectd_intervall WHERE id = $idi");
}

1;
