Bug 22284: Add new checkbox in Library Groups
[srvgit] / about.pl
index e95dbc1..dc63800 100755 (executable)
--- a/about.pl
+++ b/about.pl
@@ -444,6 +444,67 @@ $template->param( 'bad_yaml_prefs' => \@bad_yaml_prefs ) if @bad_yaml_prefs;
         );
     }
 }
+
+# Circ rule warnings
+{
+    my $dbh   = C4::Context->dbh;
+    my $units = $dbh->selectall_arrayref(
+        q|SELECT branchcode, categorycode, itemtype, lengthunit FROM issuingrules WHERE lengthunit NOT IN ( 'days', 'hours' ); |,
+        { Slice => {} }
+    );
+
+    if (@$units) {
+        $template->param(
+            warnIssuingRules => 1,
+            ir_units         => $units,
+        );
+    }
+}
+
+# Guarantor relationships warnings
+{
+    my $dbh   = C4::Context->dbh;
+    my ($bad_relationships_count) = $dbh->selectall_arrayref(q{
+        SELECT COUNT(*)
+        FROM (
+            SELECT relationship FROM borrower_relationships WHERE relationship='_bad_data'
+            UNION ALL
+            SELECT relationship FROM borrowers WHERE relationship='_bad_data') a
+    });
+
+    $bad_relationships_count = $bad_relationships_count->[0]->[0];
+
+    my $existing_relationships = $dbh->selectall_arrayref(q{
+          SELECT DISTINCT(relationship)
+          FROM (
+              SELECT relationship FROM borrower_relationships WHERE relationship IS NOT NULL
+              UNION ALL
+              SELECT relationship FROM borrowers WHERE relationship IS NOT NULL) a
+    });
+
+    my %valid_relationships = map { $_ => 1 } split( /,|\|/, C4::Context->preference('borrowerRelationship') );
+    $valid_relationships{ _bad_data } = 1; # we handle this case in another way
+
+    my $wrong_relationships = [ grep { !$valid_relationships{ $_->[0] } } @{$existing_relationships} ];
+    if ( @$wrong_relationships or $bad_relationships_count ) {
+
+        $template->param(
+            warnRelationships => 1,
+        );
+
+        if ( $wrong_relationships ) {
+            $template->param(
+                wrong_relationships => $wrong_relationships
+            );
+        }
+        if ($bad_relationships_count) {
+            $template->param(
+                bad_relationships_count => $bad_relationships_count,
+            );
+        }
+    }
+}
+
 my %versions = C4::Context::get_versions();
 
 $template->param(
@@ -531,7 +592,10 @@ if ( defined C4::Context->config('docdir') ) {
 }
 
 ## Release teams
-my $teams = LoadFile("$docdir"."/teams.yaml");
+my $teams =
+  -e "$docdir" . "/teams.yaml"
+  ? LoadFile( "$docdir" . "/teams.yaml" )
+  : {};
 my $dev_team = (sort {$b <=> $a} (keys %{$teams->{team}}))[0];
 my $short_version = substr($versions{'kohaVersion'},0,5);
 my $minor = substr($versions{'kohaVersion'},3,2);