| 
      
            Lines 51-98
          sub list_rules {
      
      
        Link Here
      
     | 
  
        
          | 51 | 
           | 
          51 | 
           | 
        
        
          | 52 | 
              return try { | 
          52 | 
              return try { | 
        
        
          | 53 | 
                  my $effective       = $c->param('effective') // 1; | 
          53 | 
                  my $effective       = $c->param('effective') // 1; | 
        
            
               | 
               | 
              54 | 
                      my $kinds           = $c->param('rules') // [ keys %{ Koha::CirculationRules->rule_kinds } ]; | 
            
        
          | 54 | 
                  my $item_type       = $c->param('item_type_id'); | 
          55 | 
                  my $item_type       = $c->param('item_type_id'); | 
        
        
          | 55 | 
                  my $branchcode      = $c->param('library_id'); | 
          56 | 
                  my $branchcode      = $c->param('library_id'); | 
        
        
          | 56 | 
                  my $patron_category = $c->param('patron_category_id'); | 
          57 | 
                  my $patron_category = $c->param('patron_category_id'); | 
        
          
            
              | 57 | 
                      my $kinds           = $c->param('rules') // [ keys %{ Koha::CirculationRules->rule_kinds } ]; | 
              58 | 
                      my ($filter_branch, $filter_itemtype, $filter_patron);  | 
            
        
          | 58 | 
           | 
          59 | 
           | 
        
        
          | 59 | 
                  if ($item_type) { | 
          60 | 
                  if ($item_type) { | 
        
          
            
              | 60 | 
                          my $type = Koha::ItemTypes->find($item_type);  | 
              61 | 
                          $filter_itemtype = 1;  | 
            
            
              | 61 | 
                          return $c->render_invalid_parameter_value(  | 
              62 | 
                          if ( $item_type eq '*' ) { | 
            
            
              | 62 | 
                              { | 
              63 | 
                              $item_type = undef;  | 
            
            
              | 63 | 
                                  path   => '/query/item_type_id',  | 
              64 | 
                          } else { | 
            
            
              | 64 | 
                                  values => { | 
              65 | 
                              my $type = Koha::ItemTypes->find($item_type);  | 
            
            
              | 65 | 
                                      uri   => '/api/v1/item_types',  | 
              66 | 
                              return $c->render_invalid_parameter_value(  | 
            
            
              | 66 | 
                                      field => 'item_type_id'  | 
              67 | 
                                  { | 
            
            
               | 
               | 
              68 | 
                                      path   => '/query/item_type_id',  | 
            
            
              | 69 | 
                                      values => { | 
            
            
              | 70 | 
                                          uri   => '/api/v1/item_types',  | 
            
            
              | 71 | 
                                          field => 'item_type_id'  | 
            
            
              | 72 | 
                                      }  | 
            
        
          | 67 | 
                              }  | 
          73 | 
                              }  | 
        
          
            
              | 68 | 
                              }  | 
              74 | 
                              ) unless $type;  | 
            
            
              | 69 | 
                          ) unless $type;  | 
              75 | 
                          }  | 
            
        
          | 70 | 
                  }  | 
          76 | 
                  }  | 
        
        
          | 71 | 
           | 
          77 | 
           | 
        
        
          | 72 | 
                  if ($branchcode) { | 
          78 | 
                  if ($branchcode) { | 
        
          
            
              | 73 | 
                          my $library = Koha::Libraries->find($branchcode);  | 
              79 | 
                          $filter_branch = 1;  | 
            
            
              | 74 | 
                          return $c->render_invalid_parameter_value(  | 
              80 | 
                          if ( $branchcode eq '*' ) { | 
            
            
              | 75 | 
                              { | 
              81 | 
                              $branchcode = undef;  | 
            
            
              | 76 | 
                                  path   => '/query/library_id',  | 
              82 | 
                          } else { | 
            
            
              | 77 | 
                                  values => { | 
              83 | 
                              my $library = Koha::Libraries->find($branchcode);  | 
            
            
              | 78 | 
                                      uri   => '/api/v1/libraries',  | 
              84 | 
                              return $c->render_invalid_parameter_value(  | 
            
            
              | 79 | 
                                      field => 'library_id'  | 
              85 | 
                                  { | 
            
            
               | 
               | 
              86 | 
                                      path   => '/query/library_id',  | 
            
            
              | 87 | 
                                      values => { | 
            
            
              | 88 | 
                                          uri   => '/api/v1/libraries',  | 
            
            
              | 89 | 
                                          field => 'library_id'  | 
            
            
              | 90 | 
                                      }  | 
            
        
          | 80 | 
                              }  | 
          91 | 
                              }  | 
        
          
            
              | 81 | 
                              }  | 
              92 | 
                              ) unless $library;  | 
            
            
              | 82 | 
                          ) unless $library;  | 
              93 | 
                          }  | 
            
        
          | 83 | 
                  }  | 
          94 | 
                  }  | 
        
        
          | 84 | 
           | 
          95 | 
           | 
        
        
          | 85 | 
                  if ($patron_category) { | 
          96 | 
                  if ($patron_category) { | 
        
          
            
              | 86 | 
                          my $category = Koha::Patron::Categories->find($patron_category);  | 
              97 | 
                          $filter_patron = 1;  | 
            
            
              | 87 | 
                          return $c->render_invalid_parameter_value(  | 
              98 | 
                          if ( $patron_category eq '*' ) { | 
            
            
              | 88 | 
                              { | 
              99 | 
                              $patron_category = undef;  | 
            
            
              | 89 | 
                                  path   => '/query/patron_category_id',  | 
              100 | 
                          } else { | 
            
            
              | 90 | 
                                  values => { | 
              101 | 
                              my $category = Koha::Patron::Categories->find($patron_category);  | 
            
            
              | 91 | 
                                      uri   => '/api/v1/patron_categories',  | 
              102 | 
                              return $c->render_invalid_parameter_value(  | 
            
            
              | 92 | 
                                      field => 'patron_category_id'  | 
              103 | 
                                  { | 
            
            
               | 
               | 
              104 | 
                                      path   => '/query/patron_category_id',  | 
            
            
              | 105 | 
                                      values => { | 
            
            
              | 106 | 
                                          uri   => '/api/v1/patron_categories',  | 
            
            
              | 107 | 
                                          field => 'patron_category_id'  | 
            
            
              | 108 | 
                                      }  | 
            
        
          | 93 | 
                              }  | 
          109 | 
                              }  | 
        
          
            
              | 94 | 
                              }  | 
              110 | 
                              ) unless $category;  | 
            
            
              | 95 | 
                          ) unless $category;  | 
              111 | 
                          }  | 
            
        
          | 96 | 
                  }  | 
          112 | 
                  }  | 
        
        
          | 97 | 
           | 
          113 | 
           | 
        
        
          | 98 | 
                  my $rules;  | 
          114 | 
                  my $rules;  | 
        
  
    | 
      
            Lines 116-122
          sub list_rules {
      
      
        Link Here
      
     | 
  
        
          | 116 | 
                      }  | 
          132 | 
                      }  | 
        
        
          | 117 | 
           | 
          133 | 
           | 
        
        
          | 118 | 
                      $rules = Koha::CirculationRules->search(  | 
          134 | 
                      $rules = Koha::CirculationRules->search(  | 
        
          
            
              | 119 | 
                              {}, | 
              135 | 
                              { | 
            
            
               | 
               | 
              136 | 
                                  ( $filter_branch   ? ( branchcode   => $branchcode )      : () ),  | 
            
            
              | 137 | 
                                  ( $filter_itemtype ? ( itemtype     => $item_type )       : () ),  | 
            
            
              | 138 | 
                                  ( $filter_patron   ? ( categorycode => $patron_category ) : () )  | 
            
            
              | 139 | 
                              },  | 
            
        
          | 120 | 
                          { | 
          140 | 
                          { | 
        
        
          | 121 | 
                              select   => $select,  | 
          141 | 
                              select   => $select,  | 
        
        
          | 122 | 
                              as       => $as,  | 
          142 | 
                              as       => $as,  | 
        
            
              | 123 | 
              -   | 
               | 
               |