View | Details | Raw Unified | Return to bug 15174
Collapse All | Expand All

(-)a/C4/Members.pm (-2 / +57 lines)
Lines 191-197 the value "1". Link Here
191
sub GetMemberDetails {
191
sub GetMemberDetails {
192
    my ( $borrowernumber, $cardnumber ) = @_;
192
    my ( $borrowernumber, $cardnumber ) = @_;
193
    my $dbh = C4::Context->dbh;
193
    my $dbh = C4::Context->dbh;
194
    my $query;
195
    my $sth;
194
    my $sth;
196
    if ($borrowernumber) {
195
    if ($borrowernumber) {
197
        $sth = $dbh->prepare("
196
        $sth = $dbh->prepare("
Lines 252-257 sub GetMemberDetails { Link Here
252
        $borrower->{'showname'} = $borrower->{'firstname'};
251
        $borrower->{'showname'} = $borrower->{'firstname'};
253
    }
252
    }
254
253
254
    # fetch and add additional categories
255
    my $query = '
256
    SELECT * FROM categories_additional
257
    WHERE borrowernumber = ?
258
    ';
259
    $sth = $dbh->prepare($query);
260
    $sth->execute( $borrower->{'borrowernumber'} );
261
    my @cats = map { $_->{'categorycode'} } @{ $sth->fetchall_arrayref( {} ) };
262
    $borrower->{'additionalcategories'} = \@cats;
263
255
    # Handle setting the true behavior for BlockExpiredPatronOpacActions
264
    # Handle setting the true behavior for BlockExpiredPatronOpacActions
256
    $borrower->{'BlockExpiredPatronOpacActions'} =
265
    $borrower->{'BlockExpiredPatronOpacActions'} =
257
      C4::Context->preference('BlockExpiredPatronOpacActions')
266
      C4::Context->preference('BlockExpiredPatronOpacActions')
Lines 462-468 sub GetMember { Link Here
462
    my $data = $sth->fetchall_arrayref({});
471
    my $data = $sth->fetchall_arrayref({});
463
    #FIXME interface to this routine now allows generation of a result set
472
    #FIXME interface to this routine now allows generation of a result set
464
    #so whole array should be returned but bowhere in the current code expects this
473
    #so whole array should be returned but bowhere in the current code expects this
465
    if (@{$data} ) {
474
    if ( @{$data} ) {
475
476
        # fetch and add additional categories
477
        $select = '
478
        SELECT * FROM categories_additional
479
        WHERE borrowernumber = ?
480
        ';
481
        $sth = $dbh->prepare($select);
482
        $sth->execute( $data->[0]->{'borrowernumber'} );
483
        my @cats = map { $_->{'categorycode'} } @{ $sth->fetchall_arrayref( {} ) };
484
        $data->[0]->{'additionalcategories'} = \@cats;
485
466
        return $data->[0];
486
        return $data->[0];
467
    }
487
    }
468
488
Lines 644-649 true on success, or false on failure Link Here
644
664
645
sub ModMember {
665
sub ModMember {
646
    my (%data) = @_;
666
    my (%data) = @_;
667
    my $dbh    = C4::Context->dbh;
647
    # test to know if you must update or not the borrower password
668
    # test to know if you must update or not the borrower password
648
    if (exists $data{password}) {
669
    if (exists $data{password}) {
649
        if ($data{password} eq '****' or $data{password} eq '') {
670
        if ($data{password} eq '****' or $data{password} eq '') {
Lines 663-668 sub ModMember { Link Here
663
    my @columns = $schema->source('Borrower')->columns;
684
    my @columns = $schema->source('Borrower')->columns;
664
    my $new_borrower = { map { join(' ', @columns) =~ /$_/ ? ( $_ => $data{$_} ) : () } keys(%data) };
685
    my $new_borrower = { map { join(' ', @columns) =~ /$_/ ? ( $_ => $data{$_} ) : () } keys(%data) };
665
    delete $new_borrower->{flags};
686
    delete $new_borrower->{flags};
687
    delete $new_borrower->{additionalcategories};
666
688
667
    $new_borrower->{dateofbirth}  ||= undef if exists $new_borrower->{dateofbirth};
689
    $new_borrower->{dateofbirth}  ||= undef if exists $new_borrower->{dateofbirth};
668
    $new_borrower->{dateenrolled} ||= undef if exists $new_borrower->{dateenrolled};
690
    $new_borrower->{dateenrolled} ||= undef if exists $new_borrower->{dateenrolled};
Lines 708-713 sub ModMember { Link Here
708
            NLSync({ 'borrowernumber' => $data{'borrowernumber'} });
730
            NLSync({ 'borrowernumber' => $data{'borrowernumber'} });
709
        }
731
        }
710
732
733
        # Update additional categories
734
        my $query = '
735
        DELETE FROM categories_additional
736
        WHERE borrowernumber = ?
737
        ';
738
        my $sth = $dbh->prepare($query);
739
        $sth->execute($data{'borrowernumber'});
740
        if ( @{ $data{'additionalcategories'} } ) {
741
            $query = '
742
            INSERT INTO categories_additional
743
            ( categorycode, borrowernumber )
744
            VALUES ( ?, ? )
745
            ';
746
            $sth = $dbh->prepare($query);
747
            for my $cat ( @{ $data{'additionalcategories'} } ) {
748
                $sth->execute( $cat, $data{'borrowernumber'} );
749
            }
750
        }
751
711
        logaction("MEMBERS", "MODIFY", $data{'borrowernumber'}, "UPDATE (executed w/ arg: $data{'borrowernumber'})") if C4::Context->preference("BorrowersLog");
752
        logaction("MEMBERS", "MODIFY", $data{'borrowernumber'}, "UPDATE (executed w/ arg: $data{'borrowernumber'})") if C4::Context->preference("BorrowersLog");
712
    }
753
    }
713
    return $execute_success;
754
    return $execute_success;
Lines 769-774 sub AddMember { Link Here
769
    my @columns = $schema->source('Borrower')->columns;
810
    my @columns = $schema->source('Borrower')->columns;
770
    my $new_member = { map { join(' ',@columns) =~ /$_/ ? ( $_ => $data{$_} )  : () } keys(%data) } ;
811
    my $new_member = { map { join(' ',@columns) =~ /$_/ ? ( $_ => $data{$_} )  : () } keys(%data) } ;
771
    delete $new_member->{borrowernumber};
812
    delete $new_member->{borrowernumber};
813
    delete $new_member->{additionalcategories};
772
814
773
    my $rs = $schema->resultset('Borrower');
815
    my $rs = $schema->resultset('Borrower');
774
    $data{borrowernumber} = $rs->create($new_member)->id;
816
    $data{borrowernumber} = $rs->create($new_member)->id;
Lines 785-790 sub AddMember { Link Here
785
        });
827
        });
786
    }
828
    }
787
829
830
    # Add additional categories
831
    if ( @{ $data{'additionalcategories'} } ) {
832
        my $query = '
833
        INSERT INTO categories_additional
834
        ( categorycode, borrowernumber )
835
        VALUES ( ?, ? )
836
        ';
837
        my $sth = $dbh->prepare($query);
838
        for my $cat ( @{ $data{'additionalcategories'} } ) {
839
            $sth->execute( $cat, $data{borrowernumber} );
840
        }
841
    }
842
788
    # mysql_insertid is probably bad.  not necessarily accurate and mysql-specific at best.
843
    # mysql_insertid is probably bad.  not necessarily accurate and mysql-specific at best.
789
    logaction("MEMBERS", "CREATE", $data{'borrowernumber'}, "") if C4::Context->preference("BorrowersLog");
844
    logaction("MEMBERS", "CREATE", $data{'borrowernumber'}, "") if C4::Context->preference("BorrowersLog");
790
845
(-)a/circ/circulation.pl (+10 lines)
Lines 235-240 if ( $print eq 'yes' && $borrowernumber ne '' ) { Link Here
235
    $borrowernumber = '';
235
    $borrowernumber = '';
236
}
236
}
237
237
238
my $category = $query->param('category');
239
238
#
240
#
239
# STEP 2 : FIND BORROWER
241
# STEP 2 : FIND BORROWER
240
# if there is a list of find borrowers....
242
# if there is a list of find borrowers....
Lines 329-340 if ($borrowernumber) { Link Here
329
331
330
}
332
}
331
333
334
my %cats;
335
map {$cats{$_->{categorycode}} = $_} @{GetBorrowercategoryList()};
336
$template->param(categories => \%cats);
337
332
#
338
#
333
# STEP 3 : ISSUING
339
# STEP 3 : ISSUING
334
#
340
#
335
#
341
#
336
if (@$barcodes) {
342
if (@$barcodes) {
337
  my $checkout_infos;
343
  my $checkout_infos;
344
345
  # set session category
346
  $borrower->{categorycode} = $category if $category;
347
338
  for my $barcode ( @$barcodes ) {
348
  for my $barcode ( @$barcodes ) {
339
    my $template_params = { barcode => $barcode };
349
    my $template_params = { barcode => $barcode };
340
    # always check for blockers on issuing
350
    # always check for blockers on issuing
(-)a/installer/data/mysql/atomicupdate/bug_15174-additional-categories.sql (+9 lines)
Line 0 Link Here
1
DROP TABLE IF EXISTS `categories_additional`;
2
CREATE TABLE `categories_additional` ( -- association table between categories and borrowers
3
  `id` int(11) NOT NULL auto_increment,
4
  `categorycode` varchar(10) NOT NULL default '',
5
  `borrowernumber` int(11) NOT NULL,
6
  PRIMARY KEY (`id`),
7
  CONSTRAINT `categories_additional_ibfk_1` FOREIGN KEY (`categorycode`) REFERENCES `categories` (`categorycode`) ON DELETE CASCADE,
8
  CONSTRAINT `categories_additional_ibfk_2` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE
9
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/circ-menu.inc (+3 lines)
Lines 59-64 Link Here
59
        [% END %]
59
        [% END %]
60
    [% END %][% END %]
60
    [% END %][% END %]
61
    <li class="patroncategory">Category: [% categoryname %] ([% categorycode %])</li>
61
    <li class="patroncategory">Category: [% categoryname %] ([% categorycode %])</li>
62
    [% IF additionalcategories %]
63
    <li class="patronadditionalcategory">Additional categories: [% additionalcategories.join(', ') %]</li>
64
    [% END %]
62
    <li class="patronlibrary">Home library: [% IF ( branchname ) %][% branchname %][% ELSE %][% branch %][% END %]</li>
65
    <li class="patronlibrary">Home library: [% IF ( branchname ) %][% branchname %][% ELSE %][% branch %][% END %]</li>
63
</ul></div>
66
</ul></div>
64
<div id="menu">
67
<div id="menu">
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt (+10 lines)
Lines 651-656 No patron matched <span class="ex">[% message %]</span> Link Here
651
        [% END %]
651
        [% END %]
652
    [% END %]
652
    [% END %]
653
653
654
    [% IF additionalcategories %]
655
        <div class="hint">Choose category for this checkout:</div>
656
        <select name="category">
657
            <option value="[% categorycode %]">[% categories.$categorycode.description %]</option>
658
            [% FOR cat IN additionalcategories %]
659
            <option value="[% cat %]">[% categories.$cat.description %]</option>
660
            [% END %]
661
        </select>
662
    [% END %]
663
654
    [% IF Koha.Preference('OnSiteCheckouts') %]
664
    [% IF Koha.Preference('OnSiteCheckouts') %]
655
        <div class="onsite_checkout-select">
665
        <div class="onsite_checkout-select">
656
            [% IF noissues %]
666
            [% IF noissues %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation_batch_checkouts.tt (+15 lines)
Lines 73-78 $(document).ready(function() { Link Here
73
          </li>
73
          </li>
74
        </ol>
74
        </ol>
75
      </fieldset>
75
      </fieldset>
76
    [% IF additionalcategories %]
77
      <fieldset class="rows">
78
        <ol>
79
          <li>
80
            <label for="barcodelist">Choose category for this checkout:</label>
81
            <select name="category">
82
                <option value="[% categorycode %]">[% categories.$categorycode.description %]</option>
83
                [% FOR cat IN additionalcategories %]
84
                <option value="[% cat %]">[% categories.$cat.description %]</option>
85
                [% END %]
86
            </select>
87
          </li>
88
        </ol>
89
      </fieldset>
90
    [% END %]
76
      <input type="hidden" name="op" value="show" />
91
      <input type="hidden" name="op" value="show" />
77
      <fieldset class="action">
92
      <fieldset class="action">
78
        <input type="hidden" name="borrowernumber" id="borrowernumber" value="[% borrowernumber %]" />
93
        <input type="hidden" name="borrowernumber" id="borrowernumber" value="[% borrowernumber %]" />
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt (+32 lines)
Lines 25-30 Link Here
25
            document.form.country.value=RegExp.$4;
25
            document.form.country.value=RegExp.$4;
26
        });
26
        });
27
27
28
28
        [% IF categorycode %]
29
        [% IF categorycode %]
29
            update_category_code( "[% categorycode %]" );
30
            update_category_code( "[% categorycode %]" );
30
        [% ELSE %]
31
        [% ELSE %]
Lines 104-109 Link Here
104
        if ( $(category_code).is("select") ) {
105
        if ( $(category_code).is("select") ) {
105
            category_code = $("#categorycode_entry").find("option:selected").val();
106
            category_code = $("#categorycode_entry").find("option:selected").val();
106
        }
107
        }
108
109
        $("#additionalcategories_entry").find('option').removeAttr('disabled');
110
        $("#additionalcategories_entry")
111
        .find('option[value="'+category_code+'"]')
112
        .attr('disabled', 'disabled');
113
107
        var mytables = $(".attributes_table");
114
        var mytables = $(".attributes_table");
108
        $(mytables).find("li").hide();
115
        $(mytables).find("li").hide();
109
        $(mytables).find(" li[data-category_code='"+category_code+"']").show();
116
        $(mytables).find(" li[data-category_code='"+category_code+"']").show();
Lines 670-675 Link Here
670
       </select>
677
       </select>
671
       <span class="required">Required</span>
678
       <span class="required">Required</span>
672
    </li>
679
    </li>
680
    <li>
681
        <label for="additionalcategories_entry" class="required">Additonal categories: </label>
682
        <select multiple id="additionalcategories_entry" name="additionalcategories">
683
        [% FOREACH typeloo IN typeloop %]
684
            [% FOREACH categoryloo IN typeloo.categoryloop %]
685
                [% IF ( loop.first ) %]
686
                    [% IF ( typeloo.typename_C ) %]<optgroup label="Child">[% END %]
687
                    [% IF ( typeloo.typename_A ) %]<optgroup label="Adult">[% END %]
688
                    [% IF ( typeloo.typename_S ) %]<optgroup label="Staff">[% END %]
689
                    [% IF ( typeloo.typename_I ) %]<optgroup label="Organization">[% END %]
690
                    [% IF ( typeloo.typename_P ) %]<optgroup label="Professional">[% END %]
691
                    [% IF ( typeloo.typename_X ) %]<optgroup label="Statistical">[% END %]
692
                [% END %]
693
                [% IF additionalcategories.grep("^$categoryloo.categorycode\$").size %]
694
                    <option value="[% categoryloo.categorycode %]" selected="selected" data-typename="[% typeloo.typename %]">[% categoryloo.categoryname %]</option>
695
                [% ELSE %]
696
                    <option value="[% categoryloo.categorycode %]" data-typename="[% typeloo.typename %]">[% categoryloo.categoryname %]</option>
697
                [% END %]
698
                [% IF ( loop.last ) %]
699
                    </optgroup>
700
                [% END %]
701
            [% END %]
702
       [% END %]
703
       </select>
704
    </li>
673
        [% UNLESS nosort1 %]
705
        [% UNLESS nosort1 %]
674
    <li>
706
    <li>
675
      [% IF ( mandatorysort1 ) %]
707
      [% IF ( mandatorysort1 ) %]
(-)a/members/memberentry.pl (-2 / +9 lines)
Lines 144-149 $template->param( "checked" => 1 ) if ( defined($nodouble) && $nodouble eq 1 ); Link Here
144
( $borrower_data = GetMember( 'borrowernumber' => $borrowernumber ) ) if ( $op eq 'modify' or $op eq 'save' or $op eq 'duplicate' );
144
( $borrower_data = GetMember( 'borrowernumber' => $borrowernumber ) ) if ( $op eq 'modify' or $op eq 'save' or $op eq 'duplicate' );
145
my $categorycode  = $input->param('categorycode') || $borrower_data->{'categorycode'};
145
my $categorycode  = $input->param('categorycode') || $borrower_data->{'categorycode'};
146
my $category_type = $input->param('category_type') || '';
146
my $category_type = $input->param('category_type') || '';
147
147
unless ($category_type or !($categorycode)){
148
unless ($category_type or !($categorycode)){
148
    my $borrowercategory = GetBorrowercategory($categorycode);
149
    my $borrowercategory = GetBorrowercategory($categorycode);
149
    $category_type    = $borrowercategory->{'category_type'};
150
    $category_type    = $borrowercategory->{'category_type'};
Lines 160-166 my %newdata; Link Here
160
if ( $op eq 'insert' || $op eq 'modify' || $op eq 'save' || $op eq 'duplicate' ) {
161
if ( $op eq 'insert' || $op eq 'modify' || $op eq 'save' || $op eq 'duplicate' ) {
161
    my @names = ( $borrower_data && $op ne 'save' ) ? keys %$borrower_data : $input->param();
162
    my @names = ( $borrower_data && $op ne 'save' ) ? keys %$borrower_data : $input->param();
162
    foreach my $key (@names) {
163
    foreach my $key (@names) {
163
        if (defined $input->param($key)) {
164
        if ( $key eq 'additionalcategories' ) {
165
            my @acats = $input->multi_param('additionalcategories');
166
            $newdata{$key} = \@acats;
167
        }
168
        elsif ( defined $input->param($key) ) {
164
            $newdata{$key} = $input->param($key);
169
            $newdata{$key} = $input->param($key);
165
            $newdata{$key} =~ s/\"/&quot;/g unless $key eq 'borrowernotes' or $key eq 'opacnote';
170
            $newdata{$key} =~ s/\"/&quot;/g unless $key eq 'borrowernotes' or $key eq 'opacnote';
166
        }
171
        }
Lines 530-535 foreach (qw(C A S P I X)) { Link Here
530
$template->param('typeloop' => \@typeloop,
535
$template->param('typeloop' => \@typeloop,
531
        no_categories => $no_categories);
536
        no_categories => $no_categories);
532
if($no_categories){ $no_add = 1; }
537
if($no_categories){ $no_add = 1; }
538
539
$template->param( additionalcategories => $data{'additionalcategories'});
540
533
# test in city
541
# test in city
534
if ( $guarantorid ) {
542
if ( $guarantorid ) {
535
    $select_city = getidcity($data{city});
543
    $select_city = getidcity($data{city});
536
- 

Return to bug 15174