lib/calcms: remove comments and shorten expressions

This commit is contained in:
Milan
2024-04-24 23:20:20 +02:00
parent 6436822ec5
commit df0982c0a6
39 changed files with 252 additions and 366 deletions

View File

@@ -6,6 +6,7 @@ no warnings 'redefine';
use Data::Dumper;
use Date::Calc();
use time();
use db();
use log();
@@ -16,7 +17,6 @@ use work_schedule();
# table: calcms_work_dates
# columns: id, studio_id, schedule_id, start(datetime), end(datetime)
# TODO: delete column schedule_id
#use base 'Exporter';
our @EXPORT_OK = qw(get_columns get insert update delete get_dates);
sub get_columns($) {
@@ -118,9 +118,9 @@ sub get ($$) {
sub update($$) {
my ($config, $entry) = @_;
return undef unless defined $entry->{project_id};
return undef unless defined $entry->{studio_id};
return undef unless defined $entry->{schedule_id};
for ('project_id', 'studio_id', 'schedule_id' ) {
return undef unless defined $entry->{$_}
};
my $dbh = db::connect($config);
@@ -183,15 +183,12 @@ sub update($$) {
$entry->{start_date} = time::add_hours_to_datetime( $entry->{start}, -$day_start );
$entry->{end_date} = time::add_hours_to_datetime( $entry->{end}, -$day_start );
db::insert( $dbh, 'calcms_work_dates', $entry );
#print STDERR "$entry->{start_date}\n";
$i++;
} else {
$j++;
}
}
#print STDERR "$i work_dates updates\n";
return $j . " dates out of studio times, " . $i;
}
@@ -286,8 +283,6 @@ sub get_dates($$$$) {
my @start_date = ( $start[0], $start[1], $start[2] );
my $start_time = sprintf( '%02d:%02d:%02d', $start[3], $start[4], $start[5] );
#print STDERR "$start_datetime,$end_date,$duration,$frequency\n";
#return on single date
my $date = {};
$date->{start} = sprintf( "%04d-%02d-%02d", @start_date ) . ' ' . $start_time;
@@ -338,9 +333,9 @@ sub get_dates($$$$) {
sub delete($$) {
my ($config, $entry) = @_;
return undef unless defined $entry->{project_id};
return undef unless defined $entry->{studio_id};
return undef unless defined $entry->{schedule_id};
for ('project_id', 'studio_id', 'schedule_id') {
return undef unless defined $entry->{$_}
};
my $dbh = db::connect($config);