| 
      
            Lines 37-56
          use Date::Calc qw/Date_to_Days check_date/;
      
      
        Link Here
      
     | 
  
        
          | 37 | 
          use Getopt::Long;  | 
          37 | 
          use Getopt::Long;  | 
        
        
          | 38 | 
          use Pod::Usage;  | 
          38 | 
          use Pod::Usage;  | 
        
        
          | 39 | 
           | 
          39 | 
           | 
        
            
               | 
               | 
              40 | 
              =head1 NAME  | 
            
            
              | 41 | 
               | 
            
            
              | 42 | 
              serialsUpdate.pl - change status of serials that are late  | 
            
            
              | 43 | 
               | 
            
            
              | 44 | 
              =head1 SYNOPSIS  | 
            
            
              | 45 | 
               | 
            
            
              | 46 | 
              serialsUpdate.pl [ -h | -m ][ -v ] -c ][ --note "you are late" ][ --no-note ]  | 
            
            
              | 47 | 
               | 
            
            
              | 48 | 
               Options:  | 
            
            
              | 49 | 
                 --h --help -?   Brief help message  | 
            
            
              | 50 | 
                 --man           Full documentation  | 
            
            
              | 51 | 
                 --verbose -v    Verbose mode  | 
            
            
              | 52 | 
                 -c              Confirm : without this option, the script will report the concerned serials  | 
            
            
              | 53 | 
                                 without modifying database  | 
            
            
              | 54 | 
                 --note          Note set to concerned serials, by default "Automatically set to late"  | 
            
            
              | 55 | 
                 --no-note       Do not set a note one concerned serials  | 
            
            
              | 56 | 
               | 
            
            
              | 57 | 
              =cut  | 
            
            
              | 58 | 
               | 
            
        
          | 40 | 
          my $dbh = C4::Context->dbh;  | 
          59 | 
          my $dbh = C4::Context->dbh;  | 
        
        
          | 41 | 
           | 
          60 | 
           | 
        
        
          | 42 | 
          my $man     = 0;  | 
          61 | 
          my $man     = 0;  | 
        
        
          | 43 | 
          my $help    = 0;  | 
          62 | 
          my $help    = 0;  | 
        
        
          | 44 | 
          my $confirm = 0;  | 
          63 | 
          my $confirm = 0;  | 
        
            
               | 
               | 
              64 | 
              my $verbose = 0;  | 
            
            
              | 65 | 
              my $note    = '';  | 
            
            
              | 66 | 
              my $nonote  = 0;  | 
            
        
          | 45 | 
           | 
          67 | 
           | 
        
        
          | 46 | 
          GetOptions(  | 
          68 | 
          GetOptions(  | 
        
          
            
              | 47 | 
                  'help|?' => \$help,  | 
              69 | 
                  'help|h|?'  => \$help,  | 
            
            
              | 48 | 
                  'c'      => \$confirm,  | 
              70 | 
                  'man'       => \$man,  | 
            
            
               | 
               | 
              71 | 
                  'v|verbose' => \$verbose,  | 
            
            
              | 72 | 
                  'c'         => \$confirm,  | 
            
            
              | 73 | 
                  'note:s'    => \$note,  | 
            
            
              | 74 | 
                  'no-note'   => \$nonote,  | 
            
        
          | 49 | 
          ) or pod2usage(2);  | 
          75 | 
          ) or pod2usage(2);  | 
        
        
          | 50 | 
           | 
          76 | 
           | 
        
        
          | 51 | 
          pod2usage(1) if $help;  | 
          77 | 
          pod2usage(1) if $help;  | 
        
        
          | 52 | 
          pod2usage( -verbose => 2 ) if $man;  | 
          78 | 
          pod2usage( -verbose => 2 ) if $man;  | 
        
        
          | 53 | 
           | 
          79 | 
           | 
        
            
               | 
               | 
              80 | 
              $verbose and !$confirm and print "### Database will not be modified ###\n";  | 
            
            
              | 81 | 
               | 
            
            
              | 82 | 
              if ($note && $nonote) { | 
            
            
              | 83 | 
                  $note = '';  | 
            
            
              | 84 | 
              }  | 
            
            
              | 85 | 
              if (!$note && !$nonote) { | 
            
            
              | 86 | 
                  $note = 'Automatically set to late';  | 
            
            
              | 87 | 
              }  | 
            
            
              | 88 | 
              $verbose and print $note ? "Note : $note\n" : "No note\n";  | 
            
            
              | 89 | 
               | 
            
        
          | 54 | 
          # select all serials with not "irregular" periodicity that are late  | 
          90 | 
          # select all serials with not "irregular" periodicity that are late  | 
        
        
          | 55 | 
          my $sth = $dbh->prepare(" | 
          91 | 
          my $sth = $dbh->prepare(" | 
        
        
          | 56 | 
               SELECT *  | 
          92 | 
               SELECT *  | 
        
  
    | 
      
            Lines 81-96
          while ( my $issue = $sth->fetchrow_hashref ) {
      
      
        Link Here
      
     | 
  
        
          | 81 | 
                          && Date_to_Days( $year, $month, $day ) <  | 
          117 | 
                          && Date_to_Days( $year, $month, $day ) <  | 
        
        
          | 82 | 
                          Date_to_Days( $tyear, $tmonth, $tday ) )  | 
          118 | 
                          Date_to_Days( $tyear, $tmonth, $tday ) )  | 
        
        
          | 83 | 
                      { | 
          119 | 
                      { | 
        
          
            
              | 84 | 
                        | 
              120 | 
                          $confirm and   | 
            
        
          | 85 | 
                      ModSerialStatus( $issue->{serialid}, $issue->{serialseq}, | 
          121 | 
                      ModSerialStatus( $issue->{serialid}, $issue->{serialseq}, | 
        
        
          | 86 | 
                          $issue->{planneddate}, $issue->{publisheddate}, | 
          122 | 
                          $issue->{planneddate}, $issue->{publisheddate}, | 
        
          
            
              | 87 | 
                              3, "Automatically set to late" );  | 
              123 | 
                              3, $note );  | 
            
            
              | 88 | 
                          print $issue->{serialid}." update\n"; | 
              124 | 
                          $verbose and print "Serial id=" . $issue->{serialid}." update\n"; | 
            
        
          | 89 | 
                      }  | 
          125 | 
                      }  | 
        
        
          | 90 | 
                  }else{ | 
          126 | 
                  }else{ | 
        
          
            
              | 91 | 
                          print "Error with serial(".$issue->{serialid}.") has no existent  | 
              127 | 
                          $verbose and print "Error with serial(".$issue->{serialid}.") has no existent  | 
            
        
          | 92 | 
                             subscription(".$issue->{subscriptionid}.") attached | 
          128 | 
                             subscription(".$issue->{subscriptionid}.") attached | 
        
          
            
              | 93 | 
                                 or planneddate is ";  | 
              129 | 
                                 or planneddate is wrong\n";  | 
            
        
          | 94 | 
                  }  | 
          130 | 
                  }  | 
        
        
          | 95 | 
              }  | 
          131 | 
              }  | 
        
        
          | 96 | 
          }  | 
          132 | 
          }  | 
        
            
              | 97 | 
              -   | 
               | 
               |