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

(-)a/C4/Members.pm (-13 / +3 lines)
Lines 1469-1488 addresses. Link Here
1469
1469
1470
sub GetFirstValidEmailAddress {
1470
sub GetFirstValidEmailAddress {
1471
    my $borrowernumber = shift;
1471
    my $borrowernumber = shift;
1472
    my $dbh = C4::Context->dbh;
1473
    my $sth = $dbh->prepare( "SELECT email, emailpro, B_email FROM borrowers where borrowernumber = ? ");
1474
    $sth->execute( $borrowernumber );
1475
    my $data = $sth->fetchrow_hashref;
1476
1472
1477
    if ($data->{'email'}) {
1473
    my $borrower = Koha::Database->new()->schema()->resultset('Borrower')->find( $borrowernumber );
1478
       return $data->{'email'};
1474
1479
    } elsif ($data->{'emailpro'}) {
1475
    return $borrower->FirstValidEmailAddress();
1480
       return $data->{'emailpro'};
1481
    } elsif ($data->{'B_email'}) {
1482
       return $data->{'B_email'};
1483
    } else {
1484
       return '';
1485
    }
1486
}
1476
}
1487
1477
1488
=head2 GetNoticeEmailAddress
1478
=head2 GetNoticeEmailAddress
(-)a/Koha/Schema/Result/Borrower.pm (-112 / +552 lines)
Lines 1-21 Link Here
1
use utf8;
2
package Koha::Schema::Result::Borrower;
1
package Koha::Schema::Result::Borrower;
3
2
4
# Created by DBIx::Class::Schema::Loader
3
# Created by DBIx::Class::Schema::Loader
5
# DO NOT MODIFY THE FIRST PART OF THIS FILE
4
# DO NOT MODIFY THE FIRST PART OF THIS FILE
6
5
7
=head1 NAME
8
9
Koha::Schema::Result::Borrower
10
11
=cut
12
13
use strict;
6
use strict;
14
use warnings;
7
use warnings;
15
8
16
use base 'DBIx::Class::Core';
9
use base 'DBIx::Class::Core';
17
10
18
=head1 TABLE: C<borrowers>
11
12
=head1 NAME
13
14
Koha::Schema::Result::Borrower
19
15
20
=cut
16
=cut
21
17
Lines 191-197 __PACKAGE__->table("borrowers"); Link Here
191
=head2 dateofbirth
187
=head2 dateofbirth
192
188
193
  data_type: 'date'
189
  data_type: 'date'
194
  datetime_undef_if_invalid: 1
195
  is_nullable: 1
190
  is_nullable: 1
196
191
197
=head2 branchcode
192
=head2 branchcode
Lines 213-225 __PACKAGE__->table("borrowers"); Link Here
213
=head2 dateenrolled
208
=head2 dateenrolled
214
209
215
  data_type: 'date'
210
  data_type: 'date'
216
  datetime_undef_if_invalid: 1
217
  is_nullable: 1
211
  is_nullable: 1
218
212
219
=head2 dateexpiry
213
=head2 dateexpiry
220
214
221
  data_type: 'date'
215
  data_type: 'date'
222
  datetime_undef_if_invalid: 1
223
  is_nullable: 1
216
  is_nullable: 1
224
217
225
=head2 gonenoaddress
218
=head2 gonenoaddress
Lines 235-241 __PACKAGE__->table("borrowers"); Link Here
235
=head2 debarred
228
=head2 debarred
236
229
237
  data_type: 'date'
230
  data_type: 'date'
238
  datetime_undef_if_invalid: 1
239
  is_nullable: 1
231
  is_nullable: 1
240
232
241
=head2 debarredcomment
233
=head2 debarredcomment
Lines 463-469 __PACKAGE__->add_columns( Link Here
463
  "b_phone",
455
  "b_phone",
464
  { data_type => "mediumtext", is_nullable => 1 },
456
  { data_type => "mediumtext", is_nullable => 1 },
465
  "dateofbirth",
457
  "dateofbirth",
466
  { data_type => "date", datetime_undef_if_invalid => 1, is_nullable => 1 },
458
  { data_type => "date", is_nullable => 1 },
467
  "branchcode",
459
  "branchcode",
468
  {
460
  {
469
    data_type => "varchar",
461
    data_type => "varchar",
Lines 481-495 __PACKAGE__->add_columns( Link Here
481
    size => 10,
473
    size => 10,
482
  },
474
  },
483
  "dateenrolled",
475
  "dateenrolled",
484
  { data_type => "date", datetime_undef_if_invalid => 1, is_nullable => 1 },
476
  { data_type => "date", is_nullable => 1 },
485
  "dateexpiry",
477
  "dateexpiry",
486
  { data_type => "date", datetime_undef_if_invalid => 1, is_nullable => 1 },
478
  { data_type => "date", is_nullable => 1 },
487
  "gonenoaddress",
479
  "gonenoaddress",
488
  { data_type => "tinyint", is_nullable => 1 },
480
  { data_type => "tinyint", is_nullable => 1 },
489
  "lost",
481
  "lost",
490
  { data_type => "tinyint", is_nullable => 1 },
482
  { data_type => "tinyint", is_nullable => 1 },
491
  "debarred",
483
  "debarred",
492
  { data_type => "date", datetime_undef_if_invalid => 1, is_nullable => 1 },
484
  { data_type => "date", is_nullable => 1 },
493
  "debarredcomment",
485
  "debarredcomment",
494
  { data_type => "varchar", is_nullable => 1, size => 255 },
486
  { data_type => "varchar", is_nullable => 1, size => 255 },
495
  "contactname",
487
  "contactname",
Lines 547-597 __PACKAGE__->add_columns( Link Here
547
  "privacy",
539
  "privacy",
548
  { data_type => "integer", default_value => 1, is_nullable => 0 },
540
  { data_type => "integer", default_value => 1, is_nullable => 0 },
549
);
541
);
542
__PACKAGE__->set_primary_key("borrowernumber");
543
__PACKAGE__->add_unique_constraint("cardnumber", ["cardnumber"]);
550
544
551
=head1 PRIMARY KEY
545
=head1 RELATIONS
552
546
553
=over 4
547
=head2 accountlines_borrowernumbers
554
548
555
=item * L</borrowernumber>
549
Type: has_many
556
550
557
=back
551
Related object: L<Koha::Schema::Result::Accountline>
558
552
559
=cut
553
=cut
560
554
561
__PACKAGE__->set_primary_key("borrowernumber");
555
__PACKAGE__->has_many(
562
556
  "accountlines_borrowernumbers",
563
=head1 UNIQUE CONSTRAINTS
557
  "Koha::Schema::Result::Accountline",
564
558
  { "foreign.borrowernumber" => "self.borrowernumber" },
565
=head2 C<cardnumber>
559
  { cascade_copy => 0, cascade_delete => 0 },
560
);
566
561
567
=over 4
562
=head2 accountlines_borrowernumbers
568
563
569
=item * L</cardnumber>
564
Type: has_many
570
565
571
=back
566
Related object: L<Koha::Schema::Result::Accountline>
572
567
573
=cut
568
=cut
574
569
575
__PACKAGE__->add_unique_constraint("cardnumber", ["cardnumber"]);
570
__PACKAGE__->has_many(
576
571
  "accountlines_borrowernumbers",
577
=head1 RELATIONS
572
  "Koha::Schema::Result::Accountline",
573
  { "foreign.borrowernumber" => "self.borrowernumber" },
574
  { cascade_copy => 0, cascade_delete => 0 },
575
);
578
576
579
=head2 accountlines
577
=head2 accountoffsets_borrowernumbers
580
578
581
Type: has_many
579
Type: has_many
582
580
583
Related object: L<Koha::Schema::Result::Accountline>
581
Related object: L<Koha::Schema::Result::Accountoffset>
584
582
585
=cut
583
=cut
586
584
587
__PACKAGE__->has_many(
585
__PACKAGE__->has_many(
588
  "accountlines",
586
  "accountoffsets_borrowernumbers",
589
  "Koha::Schema::Result::Accountline",
587
  "Koha::Schema::Result::Accountoffset",
590
  { "foreign.borrowernumber" => "self.borrowernumber" },
588
  { "foreign.borrowernumber" => "self.borrowernumber" },
591
  { cascade_copy => 0, cascade_delete => 0 },
589
  { cascade_copy => 0, cascade_delete => 0 },
592
);
590
);
593
591
594
=head2 accountoffsets
592
=head2 accountoffsets_borrowernumbers
595
593
596
Type: has_many
594
Type: has_many
597
595
Lines 600-612 Related object: L<Koha::Schema::Result::Accountoffset> Link Here
600
=cut
598
=cut
601
599
602
__PACKAGE__->has_many(
600
__PACKAGE__->has_many(
603
  "accountoffsets",
601
  "accountoffsets_borrowernumbers",
604
  "Koha::Schema::Result::Accountoffset",
602
  "Koha::Schema::Result::Accountoffset",
605
  { "foreign.borrowernumber" => "self.borrowernumber" },
603
  { "foreign.borrowernumber" => "self.borrowernumber" },
606
  { cascade_copy => 0, cascade_delete => 0 },
604
  { cascade_copy => 0, cascade_delete => 0 },
607
);
605
);
608
606
609
=head2 aqbasketusers
607
=head2 aqbasketusers_borrowernumbers
608
609
Type: has_many
610
611
Related object: L<Koha::Schema::Result::Aqbasketuser>
612
613
=cut
614
615
__PACKAGE__->has_many(
616
  "aqbasketusers_borrowernumbers",
617
  "Koha::Schema::Result::Aqbasketuser",
618
  { "foreign.borrowernumber" => "self.borrowernumber" },
619
  { cascade_copy => 0, cascade_delete => 0 },
620
);
621
622
=head2 aqbasketusers_borrowernumbers
610
623
611
Type: has_many
624
Type: has_many
612
625
Lines 615-627 Related object: L<Koha::Schema::Result::Aqbasketuser> Link Here
615
=cut
628
=cut
616
629
617
__PACKAGE__->has_many(
630
__PACKAGE__->has_many(
618
  "aqbasketusers",
631
  "aqbasketusers_borrowernumbers",
619
  "Koha::Schema::Result::Aqbasketuser",
632
  "Koha::Schema::Result::Aqbasketuser",
620
  { "foreign.borrowernumber" => "self.borrowernumber" },
633
  { "foreign.borrowernumber" => "self.borrowernumber" },
621
  { cascade_copy => 0, cascade_delete => 0 },
634
  { cascade_copy => 0, cascade_delete => 0 },
622
);
635
);
623
636
624
=head2 aqbudgetborrowers
637
=head2 aqbudgetborrowers_borrowernumbers
638
639
Type: has_many
640
641
Related object: L<Koha::Schema::Result::Aqbudgetborrower>
642
643
=cut
644
645
__PACKAGE__->has_many(
646
  "aqbudgetborrowers_borrowernumbers",
647
  "Koha::Schema::Result::Aqbudgetborrower",
648
  { "foreign.borrowernumber" => "self.borrowernumber" },
649
  { cascade_copy => 0, cascade_delete => 0 },
650
);
651
652
=head2 aqbudgetborrowers_borrowernumbers
625
653
626
Type: has_many
654
Type: has_many
627
655
Lines 630-642 Related object: L<Koha::Schema::Result::Aqbudgetborrower> Link Here
630
=cut
658
=cut
631
659
632
__PACKAGE__->has_many(
660
__PACKAGE__->has_many(
633
  "aqbudgetborrowers",
661
  "aqbudgetborrowers_borrowernumbers",
634
  "Koha::Schema::Result::Aqbudgetborrower",
662
  "Koha::Schema::Result::Aqbudgetborrower",
635
  { "foreign.borrowernumber" => "self.borrowernumber" },
663
  { "foreign.borrowernumber" => "self.borrowernumber" },
636
  { cascade_copy => 0, cascade_delete => 0 },
664
  { cascade_copy => 0, cascade_delete => 0 },
637
);
665
);
638
666
639
=head2 borrower_attributes
667
=head2 borrower_attributes_borrowernumbers
640
668
641
Type: has_many
669
Type: has_many
642
670
Lines 645-657 Related object: L<Koha::Schema::Result::BorrowerAttribute> Link Here
645
=cut
673
=cut
646
674
647
__PACKAGE__->has_many(
675
__PACKAGE__->has_many(
648
  "borrower_attributes",
676
  "borrower_attributes_borrowernumbers",
649
  "Koha::Schema::Result::BorrowerAttribute",
677
  "Koha::Schema::Result::BorrowerAttribute",
650
  { "foreign.borrowernumber" => "self.borrowernumber" },
678
  { "foreign.borrowernumber" => "self.borrowernumber" },
651
  { cascade_copy => 0, cascade_delete => 0 },
679
  { cascade_copy => 0, cascade_delete => 0 },
652
);
680
);
653
681
654
=head2 borrower_debarments
682
=head2 borrower_attributes_borrowernumbers
683
684
Type: has_many
685
686
Related object: L<Koha::Schema::Result::BorrowerAttribute>
687
688
=cut
689
690
__PACKAGE__->has_many(
691
  "borrower_attributes_borrowernumbers",
692
  "Koha::Schema::Result::BorrowerAttribute",
693
  { "foreign.borrowernumber" => "self.borrowernumber" },
694
  { cascade_copy => 0, cascade_delete => 0 },
695
);
696
697
=head2 borrower_debarments_borrowernumbers
655
698
656
Type: has_many
699
Type: has_many
657
700
Lines 660-672 Related object: L<Koha::Schema::Result::BorrowerDebarment> Link Here
660
=cut
703
=cut
661
704
662
__PACKAGE__->has_many(
705
__PACKAGE__->has_many(
663
  "borrower_debarments",
706
  "borrower_debarments_borrowernumbers",
664
  "Koha::Schema::Result::BorrowerDebarment",
707
  "Koha::Schema::Result::BorrowerDebarment",
665
  { "foreign.borrowernumber" => "self.borrowernumber" },
708
  { "foreign.borrowernumber" => "self.borrowernumber" },
666
  { cascade_copy => 0, cascade_delete => 0 },
709
  { cascade_copy => 0, cascade_delete => 0 },
667
);
710
);
668
711
669
=head2 borrower_files
712
=head2 borrower_debarments_borrowernumbers
713
714
Type: has_many
715
716
Related object: L<Koha::Schema::Result::BorrowerDebarment>
717
718
=cut
719
720
__PACKAGE__->has_many(
721
  "borrower_debarments_borrowernumbers",
722
  "Koha::Schema::Result::BorrowerDebarment",
723
  { "foreign.borrowernumber" => "self.borrowernumber" },
724
  { cascade_copy => 0, cascade_delete => 0 },
725
);
726
727
=head2 borrower_files_borrowernumbers
728
729
Type: has_many
730
731
Related object: L<Koha::Schema::Result::BorrowerFile>
732
733
=cut
734
735
__PACKAGE__->has_many(
736
  "borrower_files_borrowernumbers",
737
  "Koha::Schema::Result::BorrowerFile",
738
  { "foreign.borrowernumber" => "self.borrowernumber" },
739
  { cascade_copy => 0, cascade_delete => 0 },
740
);
741
742
=head2 borrower_files_borrowernumbers
670
743
671
Type: has_many
744
Type: has_many
672
745
Lines 675-687 Related object: L<Koha::Schema::Result::BorrowerFile> Link Here
675
=cut
748
=cut
676
749
677
__PACKAGE__->has_many(
750
__PACKAGE__->has_many(
678
  "borrower_files",
751
  "borrower_files_borrowernumbers",
679
  "Koha::Schema::Result::BorrowerFile",
752
  "Koha::Schema::Result::BorrowerFile",
680
  { "foreign.borrowernumber" => "self.borrowernumber" },
753
  { "foreign.borrowernumber" => "self.borrowernumber" },
681
  { cascade_copy => 0, cascade_delete => 0 },
754
  { cascade_copy => 0, cascade_delete => 0 },
682
);
755
);
683
756
684
=head2 borrower_message_preferences
757
=head2 borrower_message_preferences_borrowernumbers
685
758
686
Type: has_many
759
Type: has_many
687
760
Lines 690-701 Related object: L<Koha::Schema::Result::BorrowerMessagePreference> Link Here
690
=cut
763
=cut
691
764
692
__PACKAGE__->has_many(
765
__PACKAGE__->has_many(
693
  "borrower_message_preferences",
766
  "borrower_message_preferences_borrowernumbers",
694
  "Koha::Schema::Result::BorrowerMessagePreference",
767
  "Koha::Schema::Result::BorrowerMessagePreference",
695
  { "foreign.borrowernumber" => "self.borrowernumber" },
768
  { "foreign.borrowernumber" => "self.borrowernumber" },
696
  { cascade_copy => 0, cascade_delete => 0 },
769
  { cascade_copy => 0, cascade_delete => 0 },
697
);
770
);
698
771
772
=head2 borrower_message_preferences_borrowernumbers
773
774
Type: has_many
775
776
Related object: L<Koha::Schema::Result::BorrowerMessagePreference>
777
778
=cut
779
780
__PACKAGE__->has_many(
781
  "borrower_message_preferences_borrowernumbers",
782
  "Koha::Schema::Result::BorrowerMessagePreference",
783
  { "foreign.borrowernumber" => "self.borrowernumber" },
784
  { cascade_copy => 0, cascade_delete => 0 },
785
);
786
787
=head2 categorycode
788
789
Type: belongs_to
790
791
Related object: L<Koha::Schema::Result::Category>
792
793
=cut
794
795
__PACKAGE__->belongs_to(
796
  "categorycode",
797
  "Koha::Schema::Result::Category",
798
  { categorycode => "categorycode" },
799
  { on_delete => "CASCADE", on_update => "CASCADE" },
800
);
801
699
=head2 branchcode
802
=head2 branchcode
700
803
701
Type: belongs_to
804
Type: belongs_to
Lines 708-714 __PACKAGE__->belongs_to( Link Here
708
  "branchcode",
811
  "branchcode",
709
  "Koha::Schema::Result::Branch",
812
  "Koha::Schema::Result::Branch",
710
  { branchcode => "branchcode" },
813
  { branchcode => "branchcode" },
711
  { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" },
814
  { on_delete => "CASCADE", on_update => "CASCADE" },
712
);
815
);
713
816
714
=head2 categorycode
817
=head2 categorycode
Lines 723-732 __PACKAGE__->belongs_to( Link Here
723
  "categorycode",
826
  "categorycode",
724
  "Koha::Schema::Result::Category",
827
  "Koha::Schema::Result::Category",
725
  { categorycode => "categorycode" },
828
  { categorycode => "categorycode" },
726
  { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" },
829
  { on_delete => "CASCADE", on_update => "CASCADE" },
727
);
830
);
728
831
729
=head2 course_instructors
832
=head2 branchcode
833
834
Type: belongs_to
835
836
Related object: L<Koha::Schema::Result::Branch>
837
838
=cut
839
840
__PACKAGE__->belongs_to(
841
  "branchcode",
842
  "Koha::Schema::Result::Branch",
843
  { branchcode => "branchcode" },
844
  { on_delete => "CASCADE", on_update => "CASCADE" },
845
);
846
847
=head2 club_enrollments
848
849
Type: has_many
850
851
Related object: L<Koha::Schema::Result::ClubEnrollment>
852
853
=cut
854
855
__PACKAGE__->has_many(
856
  "club_enrollments",
857
  "Koha::Schema::Result::ClubEnrollment",
858
  { "foreign.borrower" => "self.borrowernumber" },
859
  { cascade_copy => 0, cascade_delete => 0 },
860
);
861
862
=head2 course_instructors_borrowernumbers
730
863
731
Type: has_many
864
Type: has_many
732
865
Lines 735-747 Related object: L<Koha::Schema::Result::CourseInstructor> Link Here
735
=cut
868
=cut
736
869
737
__PACKAGE__->has_many(
870
__PACKAGE__->has_many(
738
  "course_instructors",
871
  "course_instructors_borrowernumbers",
739
  "Koha::Schema::Result::CourseInstructor",
872
  "Koha::Schema::Result::CourseInstructor",
740
  { "foreign.borrowernumber" => "self.borrowernumber" },
873
  { "foreign.borrowernumber" => "self.borrowernumber" },
741
  { cascade_copy => 0, cascade_delete => 0 },
874
  { cascade_copy => 0, cascade_delete => 0 },
742
);
875
);
743
876
744
=head2 creator_batches
877
=head2 course_instructors_borrowernumbers
878
879
Type: has_many
880
881
Related object: L<Koha::Schema::Result::CourseInstructor>
882
883
=cut
884
885
__PACKAGE__->has_many(
886
  "course_instructors_borrowernumbers",
887
  "Koha::Schema::Result::CourseInstructor",
888
  { "foreign.borrowernumber" => "self.borrowernumber" },
889
  { cascade_copy => 0, cascade_delete => 0 },
890
);
891
892
=head2 creator_batches_borrower_numbers
893
894
Type: has_many
895
896
Related object: L<Koha::Schema::Result::CreatorBatch>
897
898
=cut
899
900
__PACKAGE__->has_many(
901
  "creator_batches_borrower_numbers",
902
  "Koha::Schema::Result::CreatorBatch",
903
  { "foreign.borrower_number" => "self.borrowernumber" },
904
  { cascade_copy => 0, cascade_delete => 0 },
905
);
906
907
=head2 creator_batches_borrower_numbers
745
908
746
Type: has_many
909
Type: has_many
747
910
Lines 750-762 Related object: L<Koha::Schema::Result::CreatorBatch> Link Here
750
=cut
913
=cut
751
914
752
__PACKAGE__->has_many(
915
__PACKAGE__->has_many(
753
  "creator_batches",
916
  "creator_batches_borrower_numbers",
754
  "Koha::Schema::Result::CreatorBatch",
917
  "Koha::Schema::Result::CreatorBatch",
755
  { "foreign.borrower_number" => "self.borrowernumber" },
918
  { "foreign.borrower_number" => "self.borrowernumber" },
756
  { cascade_copy => 0, cascade_delete => 0 },
919
  { cascade_copy => 0, cascade_delete => 0 },
757
);
920
);
758
921
759
=head2 hold_fill_targets
922
=head2 hold_fill_targets_borrowernumbers
923
924
Type: has_many
925
926
Related object: L<Koha::Schema::Result::HoldFillTarget>
927
928
=cut
929
930
__PACKAGE__->has_many(
931
  "hold_fill_targets_borrowernumbers",
932
  "Koha::Schema::Result::HoldFillTarget",
933
  { "foreign.borrowernumber" => "self.borrowernumber" },
934
  { cascade_copy => 0, cascade_delete => 0 },
935
);
936
937
=head2 hold_fill_targets_borrowernumbers
760
938
761
Type: has_many
939
Type: has_many
762
940
Lines 765-777 Related object: L<Koha::Schema::Result::HoldFillTarget> Link Here
765
=cut
943
=cut
766
944
767
__PACKAGE__->has_many(
945
__PACKAGE__->has_many(
768
  "hold_fill_targets",
946
  "hold_fill_targets_borrowernumbers",
769
  "Koha::Schema::Result::HoldFillTarget",
947
  "Koha::Schema::Result::HoldFillTarget",
770
  { "foreign.borrowernumber" => "self.borrowernumber" },
948
  { "foreign.borrowernumber" => "self.borrowernumber" },
771
  { cascade_copy => 0, cascade_delete => 0 },
949
  { cascade_copy => 0, cascade_delete => 0 },
772
);
950
);
773
951
774
=head2 issues
952
=head2 issues_borrowernumbers
953
954
Type: has_many
955
956
Related object: L<Koha::Schema::Result::Issue>
957
958
=cut
959
960
__PACKAGE__->has_many(
961
  "issues_borrowernumbers",
962
  "Koha::Schema::Result::Issue",
963
  { "foreign.borrowernumber" => "self.borrowernumber" },
964
  { cascade_copy => 0, cascade_delete => 0 },
965
);
966
967
=head2 issues_borrowernumbers
775
968
776
Type: has_many
969
Type: has_many
777
970
Lines 780-792 Related object: L<Koha::Schema::Result::Issue> Link Here
780
=cut
973
=cut
781
974
782
__PACKAGE__->has_many(
975
__PACKAGE__->has_many(
783
  "issues",
976
  "issues_borrowernumbers",
784
  "Koha::Schema::Result::Issue",
977
  "Koha::Schema::Result::Issue",
785
  { "foreign.borrowernumber" => "self.borrowernumber" },
978
  { "foreign.borrowernumber" => "self.borrowernumber" },
786
  { cascade_copy => 0, cascade_delete => 0 },
979
  { cascade_copy => 0, cascade_delete => 0 },
787
);
980
);
788
981
789
=head2 message_queues
982
=head2 message_queue_borrowernumbers
983
984
Type: has_many
985
986
Related object: L<Koha::Schema::Result::MessageQueue>
987
988
=cut
989
990
__PACKAGE__->has_many(
991
  "message_queue_borrowernumbers",
992
  "Koha::Schema::Result::MessageQueue",
993
  { "foreign.borrowernumber" => "self.borrowernumber" },
994
  { cascade_copy => 0, cascade_delete => 0 },
995
);
996
997
=head2 message_queue_borrowernumbers
790
998
791
Type: has_many
999
Type: has_many
792
1000
Lines 795-807 Related object: L<Koha::Schema::Result::MessageQueue> Link Here
795
=cut
1003
=cut
796
1004
797
__PACKAGE__->has_many(
1005
__PACKAGE__->has_many(
798
  "message_queues",
1006
  "message_queue_borrowernumbers",
799
  "Koha::Schema::Result::MessageQueue",
1007
  "Koha::Schema::Result::MessageQueue",
800
  { "foreign.borrowernumber" => "self.borrowernumber" },
1008
  { "foreign.borrowernumber" => "self.borrowernumber" },
801
  { cascade_copy => 0, cascade_delete => 0 },
1009
  { cascade_copy => 0, cascade_delete => 0 },
802
);
1010
);
803
1011
804
=head2 old_issues
1012
=head2 old_issues_borrowernumbers
805
1013
806
Type: has_many
1014
Type: has_many
807
1015
Lines 810-822 Related object: L<Koha::Schema::Result::OldIssue> Link Here
810
=cut
1018
=cut
811
1019
812
__PACKAGE__->has_many(
1020
__PACKAGE__->has_many(
813
  "old_issues",
1021
  "old_issues_borrowernumbers",
814
  "Koha::Schema::Result::OldIssue",
1022
  "Koha::Schema::Result::OldIssue",
815
  { "foreign.borrowernumber" => "self.borrowernumber" },
1023
  { "foreign.borrowernumber" => "self.borrowernumber" },
816
  { cascade_copy => 0, cascade_delete => 0 },
1024
  { cascade_copy => 0, cascade_delete => 0 },
817
);
1025
);
818
1026
819
=head2 old_reserves
1027
=head2 old_issues_borrowernumbers
1028
1029
Type: has_many
1030
1031
Related object: L<Koha::Schema::Result::OldIssue>
1032
1033
=cut
1034
1035
__PACKAGE__->has_many(
1036
  "old_issues_borrowernumbers",
1037
  "Koha::Schema::Result::OldIssue",
1038
  { "foreign.borrowernumber" => "self.borrowernumber" },
1039
  { cascade_copy => 0, cascade_delete => 0 },
1040
);
1041
1042
=head2 old_reserves_borrowernumbers
820
1043
821
Type: has_many
1044
Type: has_many
822
1045
Lines 825-837 Related object: L<Koha::Schema::Result::OldReserve> Link Here
825
=cut
1048
=cut
826
1049
827
__PACKAGE__->has_many(
1050
__PACKAGE__->has_many(
828
  "old_reserves",
1051
  "old_reserves_borrowernumbers",
829
  "Koha::Schema::Result::OldReserve",
1052
  "Koha::Schema::Result::OldReserve",
830
  { "foreign.borrowernumber" => "self.borrowernumber" },
1053
  { "foreign.borrowernumber" => "self.borrowernumber" },
831
  { cascade_copy => 0, cascade_delete => 0 },
1054
  { cascade_copy => 0, cascade_delete => 0 },
832
);
1055
);
833
1056
834
=head2 patron_list_patrons
1057
=head2 old_reserves_borrowernumbers
1058
1059
Type: has_many
1060
1061
Related object: L<Koha::Schema::Result::OldReserve>
1062
1063
=cut
1064
1065
__PACKAGE__->has_many(
1066
  "old_reserves_borrowernumbers",
1067
  "Koha::Schema::Result::OldReserve",
1068
  { "foreign.borrowernumber" => "self.borrowernumber" },
1069
  { cascade_copy => 0, cascade_delete => 0 },
1070
);
1071
1072
=head2 patron_list_patrons_borrowernumbers
1073
1074
Type: has_many
1075
1076
Related object: L<Koha::Schema::Result::PatronListPatron>
1077
1078
=cut
1079
1080
__PACKAGE__->has_many(
1081
  "patron_list_patrons_borrowernumbers",
1082
  "Koha::Schema::Result::PatronListPatron",
1083
  { "foreign.borrowernumber" => "self.borrowernumber" },
1084
  { cascade_copy => 0, cascade_delete => 0 },
1085
);
1086
1087
=head2 patron_list_patrons_borrowernumbers
835
1088
836
Type: has_many
1089
Type: has_many
837
1090
Lines 840-852 Related object: L<Koha::Schema::Result::PatronListPatron> Link Here
840
=cut
1093
=cut
841
1094
842
__PACKAGE__->has_many(
1095
__PACKAGE__->has_many(
843
  "patron_list_patrons",
1096
  "patron_list_patrons_borrowernumbers",
844
  "Koha::Schema::Result::PatronListPatron",
1097
  "Koha::Schema::Result::PatronListPatron",
845
  { "foreign.borrowernumber" => "self.borrowernumber" },
1098
  { "foreign.borrowernumber" => "self.borrowernumber" },
846
  { cascade_copy => 0, cascade_delete => 0 },
1099
  { cascade_copy => 0, cascade_delete => 0 },
847
);
1100
);
848
1101
849
=head2 patron_lists
1102
=head2 patron_lists_owners
1103
1104
Type: has_many
1105
1106
Related object: L<Koha::Schema::Result::PatronList>
1107
1108
=cut
1109
1110
__PACKAGE__->has_many(
1111
  "patron_lists_owners",
1112
  "Koha::Schema::Result::PatronList",
1113
  { "foreign.owner" => "self.borrowernumber" },
1114
  { cascade_copy => 0, cascade_delete => 0 },
1115
);
1116
1117
=head2 patron_lists_owners
850
1118
851
Type: has_many
1119
Type: has_many
852
1120
Lines 855-867 Related object: L<Koha::Schema::Result::PatronList> Link Here
855
=cut
1123
=cut
856
1124
857
__PACKAGE__->has_many(
1125
__PACKAGE__->has_many(
858
  "patron_lists",
1126
  "patron_lists_owners",
859
  "Koha::Schema::Result::PatronList",
1127
  "Koha::Schema::Result::PatronList",
860
  { "foreign.owner" => "self.borrowernumber" },
1128
  { "foreign.owner" => "self.borrowernumber" },
861
  { cascade_copy => 0, cascade_delete => 0 },
1129
  { cascade_copy => 0, cascade_delete => 0 },
862
);
1130
);
863
1131
864
=head2 patroncards
1132
=head2 patroncards_borrowernumbers
865
1133
866
Type: has_many
1134
Type: has_many
867
1135
Lines 870-882 Related object: L<Koha::Schema::Result::Patroncard> Link Here
870
=cut
1138
=cut
871
1139
872
__PACKAGE__->has_many(
1140
__PACKAGE__->has_many(
873
  "patroncards",
1141
  "patroncards_borrowernumbers",
874
  "Koha::Schema::Result::Patroncard",
1142
  "Koha::Schema::Result::Patroncard",
875
  { "foreign.borrowernumber" => "self.borrowernumber" },
1143
  { "foreign.borrowernumber" => "self.borrowernumber" },
876
  { cascade_copy => 0, cascade_delete => 0 },
1144
  { cascade_copy => 0, cascade_delete => 0 },
877
);
1145
);
878
1146
879
=head2 patronimage
1147
=head2 patroncards_borrowernumbers
1148
1149
Type: has_many
1150
1151
Related object: L<Koha::Schema::Result::Patroncard>
1152
1153
=cut
1154
1155
__PACKAGE__->has_many(
1156
  "patroncards_borrowernumbers",
1157
  "Koha::Schema::Result::Patroncard",
1158
  { "foreign.borrowernumber" => "self.borrowernumber" },
1159
  { cascade_copy => 0, cascade_delete => 0 },
1160
);
1161
1162
=head2 patronimage_borrowernumber
880
1163
881
Type: might_have
1164
Type: might_have
882
1165
Lines 885-897 Related object: L<Koha::Schema::Result::Patronimage> Link Here
885
=cut
1168
=cut
886
1169
887
__PACKAGE__->might_have(
1170
__PACKAGE__->might_have(
888
  "patronimage",
1171
  "patronimage_borrowernumber",
889
  "Koha::Schema::Result::Patronimage",
1172
  "Koha::Schema::Result::Patronimage",
890
  { "foreign.borrowernumber" => "self.borrowernumber" },
1173
  { "foreign.borrowernumber" => "self.borrowernumber" },
891
  { cascade_copy => 0, cascade_delete => 0 },
1174
  { cascade_copy => 0, cascade_delete => 0 },
892
);
1175
);
893
1176
894
=head2 ratings
1177
=head2 patronimage_borrowernumber
1178
1179
Type: might_have
1180
1181
Related object: L<Koha::Schema::Result::Patronimage>
1182
1183
=cut
1184
1185
__PACKAGE__->might_have(
1186
  "patronimage_borrowernumber",
1187
  "Koha::Schema::Result::Patronimage",
1188
  { "foreign.borrowernumber" => "self.borrowernumber" },
1189
  { cascade_copy => 0, cascade_delete => 0 },
1190
);
1191
1192
=head2 ratings_borrowernumbers
1193
1194
Type: has_many
1195
1196
Related object: L<Koha::Schema::Result::Rating>
1197
1198
=cut
1199
1200
__PACKAGE__->has_many(
1201
  "ratings_borrowernumbers",
1202
  "Koha::Schema::Result::Rating",
1203
  { "foreign.borrowernumber" => "self.borrowernumber" },
1204
  { cascade_copy => 0, cascade_delete => 0 },
1205
);
1206
1207
=head2 ratings_borrowernumbers
895
1208
896
Type: has_many
1209
Type: has_many
897
1210
Lines 900-912 Related object: L<Koha::Schema::Result::Rating> Link Here
900
=cut
1213
=cut
901
1214
902
__PACKAGE__->has_many(
1215
__PACKAGE__->has_many(
903
  "ratings",
1216
  "ratings_borrowernumbers",
904
  "Koha::Schema::Result::Rating",
1217
  "Koha::Schema::Result::Rating",
905
  { "foreign.borrowernumber" => "self.borrowernumber" },
1218
  { "foreign.borrowernumber" => "self.borrowernumber" },
906
  { cascade_copy => 0, cascade_delete => 0 },
1219
  { cascade_copy => 0, cascade_delete => 0 },
907
);
1220
);
908
1221
909
=head2 reserves
1222
=head2 reserves_borrowernumbers
910
1223
911
Type: has_many
1224
Type: has_many
912
1225
Lines 915-927 Related object: L<Koha::Schema::Result::Reserve> Link Here
915
=cut
1228
=cut
916
1229
917
__PACKAGE__->has_many(
1230
__PACKAGE__->has_many(
918
  "reserves",
1231
  "reserves_borrowernumbers",
919
  "Koha::Schema::Result::Reserve",
1232
  "Koha::Schema::Result::Reserve",
920
  { "foreign.borrowernumber" => "self.borrowernumber" },
1233
  { "foreign.borrowernumber" => "self.borrowernumber" },
921
  { cascade_copy => 0, cascade_delete => 0 },
1234
  { cascade_copy => 0, cascade_delete => 0 },
922
);
1235
);
923
1236
924
=head2 reviews
1237
=head2 reserves_borrowernumbers
1238
1239
Type: has_many
1240
1241
Related object: L<Koha::Schema::Result::Reserve>
1242
1243
=cut
1244
1245
__PACKAGE__->has_many(
1246
  "reserves_borrowernumbers",
1247
  "Koha::Schema::Result::Reserve",
1248
  { "foreign.borrowernumber" => "self.borrowernumber" },
1249
  { cascade_copy => 0, cascade_delete => 0 },
1250
);
1251
1252
=head2 reviews_borrowernumbers
925
1253
926
Type: has_many
1254
Type: has_many
927
1255
Lines 930-942 Related object: L<Koha::Schema::Result::Review> Link Here
930
=cut
1258
=cut
931
1259
932
__PACKAGE__->has_many(
1260
__PACKAGE__->has_many(
933
  "reviews",
1261
  "reviews_borrowernumbers",
934
  "Koha::Schema::Result::Review",
1262
  "Koha::Schema::Result::Review",
935
  { "foreign.borrowernumber" => "self.borrowernumber" },
1263
  { "foreign.borrowernumber" => "self.borrowernumber" },
936
  { cascade_copy => 0, cascade_delete => 0 },
1264
  { cascade_copy => 0, cascade_delete => 0 },
937
);
1265
);
938
1266
939
=head2 subscriptionroutinglists
1267
=head2 reviews_borrowernumbers
1268
1269
Type: has_many
1270
1271
Related object: L<Koha::Schema::Result::Review>
1272
1273
=cut
1274
1275
__PACKAGE__->has_many(
1276
  "reviews_borrowernumbers",
1277
  "Koha::Schema::Result::Review",
1278
  { "foreign.borrowernumber" => "self.borrowernumber" },
1279
  { cascade_copy => 0, cascade_delete => 0 },
1280
);
1281
1282
=head2 subscriptionroutinglist_borrowernumbers
940
1283
941
Type: has_many
1284
Type: has_many
942
1285
Lines 945-957 Related object: L<Koha::Schema::Result::Subscriptionroutinglist> Link Here
945
=cut
1288
=cut
946
1289
947
__PACKAGE__->has_many(
1290
__PACKAGE__->has_many(
948
  "subscriptionroutinglists",
1291
  "subscriptionroutinglist_borrowernumbers",
949
  "Koha::Schema::Result::Subscriptionroutinglist",
1292
  "Koha::Schema::Result::Subscriptionroutinglist",
950
  { "foreign.borrowernumber" => "self.borrowernumber" },
1293
  { "foreign.borrowernumber" => "self.borrowernumber" },
951
  { cascade_copy => 0, cascade_delete => 0 },
1294
  { cascade_copy => 0, cascade_delete => 0 },
952
);
1295
);
953
1296
954
=head2 tags_all
1297
=head2 subscriptionroutinglist_borrowernumbers
1298
1299
Type: has_many
1300
1301
Related object: L<Koha::Schema::Result::Subscriptionroutinglist>
1302
1303
=cut
1304
1305
__PACKAGE__->has_many(
1306
  "subscriptionroutinglist_borrowernumbers",
1307
  "Koha::Schema::Result::Subscriptionroutinglist",
1308
  { "foreign.borrowernumber" => "self.borrowernumber" },
1309
  { cascade_copy => 0, cascade_delete => 0 },
1310
);
1311
1312
=head2 tags_all_borrowernumbers
1313
1314
Type: has_many
1315
1316
Related object: L<Koha::Schema::Result::TagAll>
1317
1318
=cut
1319
1320
__PACKAGE__->has_many(
1321
  "tags_all_borrowernumbers",
1322
  "Koha::Schema::Result::TagAll",
1323
  { "foreign.borrowernumber" => "self.borrowernumber" },
1324
  { cascade_copy => 0, cascade_delete => 0 },
1325
);
1326
1327
=head2 tags_all_borrowernumbers
955
1328
956
Type: has_many
1329
Type: has_many
957
1330
Lines 960-972 Related object: L<Koha::Schema::Result::TagAll> Link Here
960
=cut
1333
=cut
961
1334
962
__PACKAGE__->has_many(
1335
__PACKAGE__->has_many(
963
  "tags_all",
1336
  "tags_all_borrowernumbers",
964
  "Koha::Schema::Result::TagAll",
1337
  "Koha::Schema::Result::TagAll",
965
  { "foreign.borrowernumber" => "self.borrowernumber" },
1338
  { "foreign.borrowernumber" => "self.borrowernumber" },
966
  { cascade_copy => 0, cascade_delete => 0 },
1339
  { cascade_copy => 0, cascade_delete => 0 },
967
);
1340
);
968
1341
969
=head2 tags_approvals
1342
=head2 tags_approvals_approved_by
970
1343
971
Type: has_many
1344
Type: has_many
972
1345
Lines 975-987 Related object: L<Koha::Schema::Result::TagsApproval> Link Here
975
=cut
1348
=cut
976
1349
977
__PACKAGE__->has_many(
1350
__PACKAGE__->has_many(
978
  "tags_approvals",
1351
  "tags_approvals_approved_by",
979
  "Koha::Schema::Result::TagsApproval",
1352
  "Koha::Schema::Result::TagsApproval",
980
  { "foreign.approved_by" => "self.borrowernumber" },
1353
  { "foreign.approved_by" => "self.borrowernumber" },
981
  { cascade_copy => 0, cascade_delete => 0 },
1354
  { cascade_copy => 0, cascade_delete => 0 },
982
);
1355
);
983
1356
984
=head2 user_permissions
1357
=head2 tags_approvals_approved_by
1358
1359
Type: has_many
1360
1361
Related object: L<Koha::Schema::Result::TagsApproval>
1362
1363
=cut
1364
1365
__PACKAGE__->has_many(
1366
  "tags_approvals_approved_by",
1367
  "Koha::Schema::Result::TagsApproval",
1368
  { "foreign.approved_by" => "self.borrowernumber" },
1369
  { cascade_copy => 0, cascade_delete => 0 },
1370
);
1371
1372
=head2 user_permissions_borrowernumbers
1373
1374
Type: has_many
1375
1376
Related object: L<Koha::Schema::Result::UserPermission>
1377
1378
=cut
1379
1380
__PACKAGE__->has_many(
1381
  "user_permissions_borrowernumbers",
1382
  "Koha::Schema::Result::UserPermission",
1383
  { "foreign.borrowernumber" => "self.borrowernumber" },
1384
  { cascade_copy => 0, cascade_delete => 0 },
1385
);
1386
1387
=head2 user_permissions_borrowernumbers
985
1388
986
Type: has_many
1389
Type: has_many
987
1390
Lines 990-1002 Related object: L<Koha::Schema::Result::UserPermission> Link Here
990
=cut
1393
=cut
991
1394
992
__PACKAGE__->has_many(
1395
__PACKAGE__->has_many(
993
  "user_permissions",
1396
  "user_permissions_borrowernumbers",
994
  "Koha::Schema::Result::UserPermission",
1397
  "Koha::Schema::Result::UserPermission",
995
  { "foreign.borrowernumber" => "self.borrowernumber" },
1398
  { "foreign.borrowernumber" => "self.borrowernumber" },
996
  { cascade_copy => 0, cascade_delete => 0 },
1399
  { cascade_copy => 0, cascade_delete => 0 },
997
);
1400
);
998
1401
999
=head2 virtualshelfcontents
1402
=head2 virtualshelfcontents_borrowernumbers
1403
1404
Type: has_many
1405
1406
Related object: L<Koha::Schema::Result::Virtualshelfcontent>
1407
1408
=cut
1409
1410
__PACKAGE__->has_many(
1411
  "virtualshelfcontents_borrowernumbers",
1412
  "Koha::Schema::Result::Virtualshelfcontent",
1413
  { "foreign.borrowernumber" => "self.borrowernumber" },
1414
  { cascade_copy => 0, cascade_delete => 0 },
1415
);
1416
1417
=head2 virtualshelfcontents_borrowernumbers
1000
1418
1001
Type: has_many
1419
Type: has_many
1002
1420
Lines 1005-1017 Related object: L<Koha::Schema::Result::Virtualshelfcontent> Link Here
1005
=cut
1423
=cut
1006
1424
1007
__PACKAGE__->has_many(
1425
__PACKAGE__->has_many(
1008
  "virtualshelfcontents",
1426
  "virtualshelfcontents_borrowernumbers",
1009
  "Koha::Schema::Result::Virtualshelfcontent",
1427
  "Koha::Schema::Result::Virtualshelfcontent",
1010
  { "foreign.borrowernumber" => "self.borrowernumber" },
1428
  { "foreign.borrowernumber" => "self.borrowernumber" },
1011
  { cascade_copy => 0, cascade_delete => 0 },
1429
  { cascade_copy => 0, cascade_delete => 0 },
1012
);
1430
);
1013
1431
1014
=head2 virtualshelfshares
1432
=head2 virtualshelfshares_borrowernumbers
1015
1433
1016
Type: has_many
1434
Type: has_many
1017
1435
Lines 1020-1080 Related object: L<Koha::Schema::Result::Virtualshelfshare> Link Here
1020
=cut
1438
=cut
1021
1439
1022
__PACKAGE__->has_many(
1440
__PACKAGE__->has_many(
1023
  "virtualshelfshares",
1441
  "virtualshelfshares_borrowernumbers",
1024
  "Koha::Schema::Result::Virtualshelfshare",
1442
  "Koha::Schema::Result::Virtualshelfshare",
1025
  { "foreign.borrowernumber" => "self.borrowernumber" },
1443
  { "foreign.borrowernumber" => "self.borrowernumber" },
1026
  { cascade_copy => 0, cascade_delete => 0 },
1444
  { cascade_copy => 0, cascade_delete => 0 },
1027
);
1445
);
1028
1446
1029
=head2 virtualshelves
1447
=head2 virtualshelfshares_borrowernumbers
1030
1448
1031
Type: has_many
1449
Type: has_many
1032
1450
1033
Related object: L<Koha::Schema::Result::Virtualshelve>
1451
Related object: L<Koha::Schema::Result::Virtualshelfshare>
1034
1452
1035
=cut
1453
=cut
1036
1454
1037
__PACKAGE__->has_many(
1455
__PACKAGE__->has_many(
1038
  "virtualshelves",
1456
  "virtualshelfshares_borrowernumbers",
1039
  "Koha::Schema::Result::Virtualshelve",
1457
  "Koha::Schema::Result::Virtualshelfshare",
1040
  { "foreign.owner" => "self.borrowernumber" },
1458
  { "foreign.borrowernumber" => "self.borrowernumber" },
1041
  { cascade_copy => 0, cascade_delete => 0 },
1459
  { cascade_copy => 0, cascade_delete => 0 },
1042
);
1460
);
1043
1461
1044
=head2 basketnoes
1462
=head2 virtualshelves_owners
1045
1463
1046
Type: many_to_many
1464
Type: has_many
1047
1465
1048
Composing rels: L</aqbasketusers> -> basketno
1466
Related object: L<Koha::Schema::Result::Virtualshelve>
1049
1467
1050
=cut
1468
=cut
1051
1469
1052
__PACKAGE__->many_to_many("basketnoes", "aqbasketusers", "basketno");
1470
__PACKAGE__->has_many(
1471
  "virtualshelves_owners",
1472
  "Koha::Schema::Result::Virtualshelve",
1473
  { "foreign.owner" => "self.borrowernumber" },
1474
  { cascade_copy => 0, cascade_delete => 0 },
1475
);
1053
1476
1054
=head2 budgets
1477
=head2 virtualshelves_owners
1055
1478
1056
Type: many_to_many
1479
Type: has_many
1057
1480
1058
Composing rels: L</aqbudgetborrowers> -> budget
1481
Related object: L<Koha::Schema::Result::Virtualshelve>
1059
1482
1060
=cut
1483
=cut
1061
1484
1062
__PACKAGE__->many_to_many("budgets", "aqbudgetborrowers", "budget");
1485
__PACKAGE__->has_many(
1486
  "virtualshelves_owners",
1487
  "Koha::Schema::Result::Virtualshelve",
1488
  { "foreign.owner" => "self.borrowernumber" },
1489
  { cascade_copy => 0, cascade_delete => 0 },
1490
);
1063
1491
1064
=head2 courses
1065
1492
1066
Type: many_to_many
1493
# Created by DBIx::Class::Schema::Loader v0.07000 @ 2014-06-20 09:20:52
1494
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:TIft8zTHaGV8X/T6uhW8uw
1067
1495
1068
Composing rels: L</course_instructors> -> course
1496
sub FirstValidEmailAddress {
1497
    my ( $self ) = @_;
1069
1498
1070
=cut
1499
    return $self->email() || $self->emailpro() || $self->b_email() || q{};
1500
}
1501
1502
sub ClubsEnrolledCount {
1503
    my ( $self ) = @_;
1071
1504
1072
__PACKAGE__->many_to_many("courses", "course_instructors", "course");
1505
    return $self->club_enrollments({ date_canceled => undef })->count();
1506
}
1073
1507
1508
sub ClubsEnrollableCount {
1509
    my ( $self, $is_enrollable_from_opac ) = @_;
1074
1510
1075
# Created by DBIx::Class::Schema::Loader v0.07025 @ 2013-10-31 16:31:19
1511
    my $params;
1076
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:z4kW3xYX1CyrwvGdZu32nA
1512
    $params->{is_enrollable_from_opac} = $is_enrollable_from_opac
1513
      if $is_enrollable_from_opac;
1514
    $params->{is_email_required} = 0 unless $self->FirstValidEmailAddress();
1077
1515
1516
    return $self->result_source->schema->resultset('Club')
1517
      ->search( $params, { prefetch => 'club_template' } )->count();
1518
}
1078
1519
1079
# You can replace this text with custom content, and it will be preserved on regeneration
1080
1;
1520
1;
(-)a/Koha/Schema/Result/Club.pm (+168 lines)
Line 0 Link Here
1
package Koha::Schema::Result::Club;
2
3
# Created by DBIx::Class::Schema::Loader
4
# DO NOT MODIFY THE FIRST PART OF THIS FILE
5
6
use strict;
7
use warnings;
8
9
use base 'DBIx::Class::Core';
10
11
12
=head1 NAME
13
14
Koha::Schema::Result::Club
15
16
=cut
17
18
__PACKAGE__->table("clubs");
19
20
=head1 ACCESSORS
21
22
=head2 id
23
24
  data_type: 'integer'
25
  is_auto_increment: 1
26
  is_nullable: 0
27
28
=head2 club_template
29
30
  data_type: 'integer'
31
  is_foreign_key: 1
32
  is_nullable: 0
33
34
=head2 name
35
36
  data_type: 'tinytext'
37
  is_nullable: 0
38
39
=head2 description
40
41
  data_type: 'text'
42
  is_nullable: 1
43
44
=head2 date_start
45
46
  data_type: 'date'
47
  is_nullable: 0
48
49
=head2 date_end
50
51
  data_type: 'date'
52
  is_nullable: 1
53
54
=head2 branch
55
56
  data_type: 'varchar'
57
  is_foreign_key: 1
58
  is_nullable: 1
59
  size: 11
60
61
=head2 date_created
62
63
  data_type: 'timestamp'
64
  default_value: current_timestamp
65
  is_nullable: 0
66
67
=head2 date_updated
68
69
  data_type: 'timestamp'
70
  is_nullable: 1
71
72
=cut
73
74
__PACKAGE__->add_columns(
75
  "id",
76
  { data_type => "integer", is_auto_increment => 1, is_nullable => 0 },
77
  "club_template",
78
  { data_type => "integer", is_foreign_key => 1, is_nullable => 0 },
79
  "name",
80
  { data_type => "tinytext", is_nullable => 0 },
81
  "description",
82
  { data_type => "text", is_nullable => 1 },
83
  "date_start",
84
  { data_type => "date", is_nullable => 0 },
85
  "date_end",
86
  { data_type => "date", is_nullable => 1 },
87
  "branch",
88
  { data_type => "varchar", is_foreign_key => 1, is_nullable => 1, size => 11 },
89
  "date_created",
90
  {
91
    data_type     => "timestamp",
92
    default_value => \"current_timestamp",
93
    is_nullable   => 0,
94
  },
95
  "date_updated",
96
  { data_type => "timestamp", is_nullable => 1 },
97
);
98
__PACKAGE__->set_primary_key("id");
99
100
=head1 RELATIONS
101
102
=head2 club_enrollments
103
104
Type: has_many
105
106
Related object: L<Koha::Schema::Result::ClubEnrollment>
107
108
=cut
109
110
__PACKAGE__->has_many(
111
  "club_enrollments",
112
  "Koha::Schema::Result::ClubEnrollment",
113
  { "foreign.club" => "self.id" },
114
  { cascade_copy => 0, cascade_delete => 0 },
115
);
116
117
=head2 club_fields
118
119
Type: has_many
120
121
Related object: L<Koha::Schema::Result::ClubField>
122
123
=cut
124
125
__PACKAGE__->has_many(
126
  "club_fields",
127
  "Koha::Schema::Result::ClubField",
128
  { "foreign.club" => "self.id" },
129
  { cascade_copy => 0, cascade_delete => 0 },
130
);
131
132
=head2 club_template
133
134
Type: belongs_to
135
136
Related object: L<Koha::Schema::Result::ClubTemplate>
137
138
=cut
139
140
__PACKAGE__->belongs_to(
141
  "club_template",
142
  "Koha::Schema::Result::ClubTemplate",
143
  { id => "club_template" },
144
  { on_delete => "CASCADE", on_update => "CASCADE" },
145
);
146
147
=head2 branch
148
149
Type: belongs_to
150
151
Related object: L<Koha::Schema::Result::Branch>
152
153
=cut
154
155
__PACKAGE__->belongs_to(
156
  "branch",
157
  "Koha::Schema::Result::Branch",
158
  { branchcode => "branch" },
159
  { join_type => "LEFT", on_delete => "CASCADE", on_update => "CASCADE" },
160
);
161
162
163
# Created by DBIx::Class::Schema::Loader v0.07000 @ 2014-05-30 09:55:12
164
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:Y6kcTQulxM9XeOpDV+TiiQ
165
166
167
# You can replace this text with custom content, and it will be preserved on regeneration
168
1;
(-)a/Koha/Schema/Result/ClubEnrollment.pm (+167 lines)
Line 0 Link Here
1
package Koha::Schema::Result::ClubEnrollment;
2
3
# Created by DBIx::Class::Schema::Loader
4
# DO NOT MODIFY THE FIRST PART OF THIS FILE
5
6
use strict;
7
use warnings;
8
9
use base 'DBIx::Class::Core';
10
11
12
=head1 NAME
13
14
Koha::Schema::Result::ClubEnrollment
15
16
=cut
17
18
__PACKAGE__->table("club_enrollments");
19
20
=head1 ACCESSORS
21
22
=head2 id
23
24
  data_type: 'integer'
25
  is_auto_increment: 1
26
  is_nullable: 0
27
28
=head2 club
29
30
  data_type: 'integer'
31
  is_foreign_key: 1
32
  is_nullable: 0
33
34
=head2 borrower
35
36
  data_type: 'integer'
37
  is_foreign_key: 1
38
  is_nullable: 0
39
40
=head2 date_enrolled
41
42
  data_type: 'timestamp'
43
  default_value: current_timestamp
44
  is_nullable: 0
45
46
=head2 date_canceled
47
48
  data_type: 'timestamp'
49
  is_nullable: 1
50
51
=head2 date_created
52
53
  data_type: 'timestamp'
54
  default_value: '0000-00-00 00:00:00'
55
  is_nullable: 0
56
57
=head2 date_updated
58
59
  data_type: 'timestamp'
60
  is_nullable: 1
61
62
=head2 branch
63
64
  data_type: 'varchar'
65
  is_foreign_key: 1
66
  is_nullable: 1
67
  size: 11
68
69
=cut
70
71
__PACKAGE__->add_columns(
72
  "id",
73
  { data_type => "integer", is_auto_increment => 1, is_nullable => 0 },
74
  "club",
75
  { data_type => "integer", is_foreign_key => 1, is_nullable => 0 },
76
  "borrower",
77
  { data_type => "integer", is_foreign_key => 1, is_nullable => 0 },
78
  "date_enrolled",
79
  {
80
    data_type     => "timestamp",
81
    default_value => \"current_timestamp",
82
    is_nullable   => 0,
83
  },
84
  "date_canceled",
85
  { data_type => "timestamp", is_nullable => 1 },
86
  "date_created",
87
  {
88
    data_type     => "timestamp",
89
    default_value => "0000-00-00 00:00:00",
90
    is_nullable   => 0,
91
  },
92
  "date_updated",
93
  { data_type => "timestamp", is_nullable => 1 },
94
  "branch",
95
  { data_type => "varchar", is_foreign_key => 1, is_nullable => 1, size => 11 },
96
);
97
__PACKAGE__->set_primary_key("id");
98
99
=head1 RELATIONS
100
101
=head2 club_enrollment_fields
102
103
Type: has_many
104
105
Related object: L<Koha::Schema::Result::ClubEnrollmentField>
106
107
=cut
108
109
__PACKAGE__->has_many(
110
  "club_enrollment_fields",
111
  "Koha::Schema::Result::ClubEnrollmentField",
112
  { "foreign.club_enrollment" => "self.id" },
113
  { cascade_copy => 0, cascade_delete => 0 },
114
);
115
116
=head2 club
117
118
Type: belongs_to
119
120
Related object: L<Koha::Schema::Result::Club>
121
122
=cut
123
124
__PACKAGE__->belongs_to(
125
  "club",
126
  "Koha::Schema::Result::Club",
127
  { id => "club" },
128
  { on_delete => "CASCADE", on_update => "CASCADE" },
129
);
130
131
=head2 borrower
132
133
Type: belongs_to
134
135
Related object: L<Koha::Schema::Result::Borrower>
136
137
=cut
138
139
__PACKAGE__->belongs_to(
140
  "borrower",
141
  "Koha::Schema::Result::Borrower",
142
  { borrowernumber => "borrower" },
143
  { on_delete => "CASCADE", on_update => "CASCADE" },
144
);
145
146
=head2 branch
147
148
Type: belongs_to
149
150
Related object: L<Koha::Schema::Result::Branch>
151
152
=cut
153
154
__PACKAGE__->belongs_to(
155
  "branch",
156
  "Koha::Schema::Result::Branch",
157
  { branchcode => "branch" },
158
  { join_type => "LEFT", on_delete => "CASCADE", on_update => "CASCADE" },
159
);
160
161
162
# Created by DBIx::Class::Schema::Loader v0.07000 @ 2014-05-30 09:55:12
163
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:mfTpVLaQhTKJ//QnRm2f5A
164
165
166
# You can replace this text with custom content, and it will be preserved on regeneration
167
1;
(-)a/Koha/Schema/Result/ClubEnrollmentField.pm (+97 lines)
Line 0 Link Here
1
package Koha::Schema::Result::ClubEnrollmentField;
2
3
# Created by DBIx::Class::Schema::Loader
4
# DO NOT MODIFY THE FIRST PART OF THIS FILE
5
6
use strict;
7
use warnings;
8
9
use base 'DBIx::Class::Core';
10
11
12
=head1 NAME
13
14
Koha::Schema::Result::ClubEnrollmentField
15
16
=cut
17
18
__PACKAGE__->table("club_enrollment_fields");
19
20
=head1 ACCESSORS
21
22
=head2 id
23
24
  data_type: 'integer'
25
  is_auto_increment: 1
26
  is_nullable: 0
27
28
=head2 club_enrollment
29
30
  data_type: 'integer'
31
  is_foreign_key: 1
32
  is_nullable: 0
33
34
=head2 club_template_enrollment_field
35
36
  data_type: 'integer'
37
  is_foreign_key: 1
38
  is_nullable: 0
39
40
=head2 value
41
42
  data_type: 'text'
43
  is_nullable: 0
44
45
=cut
46
47
__PACKAGE__->add_columns(
48
  "id",
49
  { data_type => "integer", is_auto_increment => 1, is_nullable => 0 },
50
  "club_enrollment",
51
  { data_type => "integer", is_foreign_key => 1, is_nullable => 0 },
52
  "club_template_enrollment_field",
53
  { data_type => "integer", is_foreign_key => 1, is_nullable => 0 },
54
  "value",
55
  { data_type => "text", is_nullable => 0 },
56
);
57
__PACKAGE__->set_primary_key("id");
58
59
=head1 RELATIONS
60
61
=head2 club_template_enrollment_field
62
63
Type: belongs_to
64
65
Related object: L<Koha::Schema::Result::ClubTemplateEnrollmentField>
66
67
=cut
68
69
__PACKAGE__->belongs_to(
70
  "club_template_enrollment_field",
71
  "Koha::Schema::Result::ClubTemplateEnrollmentField",
72
  { id => "club_template_enrollment_field" },
73
  { on_delete => "CASCADE", on_update => "CASCADE" },
74
);
75
76
=head2 club_enrollment
77
78
Type: belongs_to
79
80
Related object: L<Koha::Schema::Result::ClubEnrollment>
81
82
=cut
83
84
__PACKAGE__->belongs_to(
85
  "club_enrollment",
86
  "Koha::Schema::Result::ClubEnrollment",
87
  { id => "club_enrollment" },
88
  { on_delete => "CASCADE", on_update => "CASCADE" },
89
);
90
91
92
# Created by DBIx::Class::Schema::Loader v0.07000 @ 2014-05-30 09:55:12
93
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:bOPkyazyrsDwUKKS4oHHdQ
94
95
96
# You can replace this text with custom content, and it will be preserved on regeneration
97
1;
(-)a/Koha/Schema/Result/ClubField.pm (+127 lines)
Line 0 Link Here
1
package Koha::Schema::Result::ClubField;
2
3
# Created by DBIx::Class::Schema::Loader
4
# DO NOT MODIFY THE FIRST PART OF THIS FILE
5
6
use strict;
7
use warnings;
8
9
use base 'DBIx::Class::Core';
10
11
12
=head1 NAME
13
14
Koha::Schema::Result::ClubField
15
16
=cut
17
18
__PACKAGE__->table("club_fields");
19
20
=head1 ACCESSORS
21
22
=head2 id
23
24
  data_type: 'integer'
25
  is_auto_increment: 1
26
  is_nullable: 0
27
28
=head2 club_template_field
29
30
  data_type: 'integer'
31
  is_foreign_key: 1
32
  is_nullable: 0
33
34
=head2 club
35
36
  data_type: 'integer'
37
  is_foreign_key: 1
38
  is_nullable: 0
39
40
=head2 value
41
42
  data_type: 'text'
43
  is_nullable: 1
44
45
=cut
46
47
__PACKAGE__->add_columns(
48
  "id",
49
  { data_type => "integer", is_auto_increment => 1, is_nullable => 0 },
50
  "club_template_field",
51
  { data_type => "integer", is_foreign_key => 1, is_nullable => 0 },
52
  "club",
53
  { data_type => "integer", is_foreign_key => 1, is_nullable => 0 },
54
  "value",
55
  { data_type => "text", is_nullable => 1 },
56
);
57
__PACKAGE__->set_primary_key("id");
58
59
=head1 RELATIONS
60
61
=head2 club_template_field
62
63
Type: belongs_to
64
65
Related object: L<Koha::Schema::Result::ClubTemplateField>
66
67
=cut
68
69
__PACKAGE__->belongs_to(
70
  "club_template_field",
71
  "Koha::Schema::Result::ClubTemplateField",
72
  { id => "club_template_field" },
73
  { on_delete => "CASCADE", on_update => "CASCADE" },
74
);
75
76
=head2 club
77
78
Type: belongs_to
79
80
Related object: L<Koha::Schema::Result::Club>
81
82
=cut
83
84
__PACKAGE__->belongs_to(
85
  "club",
86
  "Koha::Schema::Result::Club",
87
  { id => "club" },
88
  { on_delete => "CASCADE", on_update => "CASCADE" },
89
);
90
91
=head2 z_clubs_rewrite_clubs
92
93
Type: has_many
94
95
Related object: L<Koha::Schema::Result::ZClubRewrite>
96
97
=cut
98
99
__PACKAGE__->has_many(
100
  "z_clubs_rewrite_clubs",
101
  "Koha::Schema::Result::ZClubRewrite",
102
  { "foreign.club" => "self.id" },
103
  { cascade_copy => 0, cascade_delete => 0 },
104
);
105
106
=head2 z_clubs_rewrite_club_template_fields
107
108
Type: has_many
109
110
Related object: L<Koha::Schema::Result::ZClubRewrite>
111
112
=cut
113
114
__PACKAGE__->has_many(
115
  "z_clubs_rewrite_club_template_fields",
116
  "Koha::Schema::Result::ZClubRewrite",
117
  { "foreign.club_template_field" => "self.club_template_field" },
118
  { cascade_copy => 0, cascade_delete => 0 },
119
);
120
121
122
# Created by DBIx::Class::Schema::Loader v0.07000 @ 2014-05-30 09:55:12
123
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:B5i1BInvl7L9Mjor17Okrw
124
125
126
# You can replace this text with custom content, and it will be preserved on regeneration
127
1;
(-)a/Koha/Schema/Result/ClubTemplate.pm (+168 lines)
Line 0 Link Here
1
package Koha::Schema::Result::ClubTemplate;
2
3
# Created by DBIx::Class::Schema::Loader
4
# DO NOT MODIFY THE FIRST PART OF THIS FILE
5
6
use strict;
7
use warnings;
8
9
use base 'DBIx::Class::Core';
10
11
12
=head1 NAME
13
14
Koha::Schema::Result::ClubTemplate
15
16
=cut
17
18
__PACKAGE__->table("club_templates");
19
20
=head1 ACCESSORS
21
22
=head2 id
23
24
  data_type: 'integer'
25
  is_auto_increment: 1
26
  is_nullable: 0
27
28
=head2 name
29
30
  data_type: 'tinytext'
31
  is_nullable: 0
32
33
=head2 description
34
35
  data_type: 'text'
36
  is_nullable: 1
37
38
=head2 is_enrollable_from_opac
39
40
  data_type: 'tinyint'
41
  default_value: 0
42
  is_nullable: 0
43
44
=head2 is_email_required
45
46
  data_type: 'tinyint'
47
  default_value: 0
48
  is_nullable: 0
49
50
=head2 branch
51
52
  data_type: 'varchar'
53
  is_foreign_key: 1
54
  is_nullable: 1
55
  size: 10
56
57
=head2 date_created
58
59
  data_type: 'timestamp'
60
  default_value: current_timestamp
61
  is_nullable: 0
62
63
=head2 date_updated
64
65
  data_type: 'timestamp'
66
  is_nullable: 1
67
68
=head2 is_deletable
69
70
  data_type: 'tinyint'
71
  default_value: 1
72
  is_nullable: 0
73
74
=cut
75
76
__PACKAGE__->add_columns(
77
  "id",
78
  { data_type => "integer", is_auto_increment => 1, is_nullable => 0 },
79
  "name",
80
  { data_type => "tinytext", is_nullable => 0 },
81
  "description",
82
  { data_type => "text", is_nullable => 1 },
83
  "is_enrollable_from_opac",
84
  { data_type => "tinyint", default_value => 0, is_nullable => 0 },
85
  "is_email_required",
86
  { data_type => "tinyint", default_value => 0, is_nullable => 0 },
87
  "branch",
88
  { data_type => "varchar", is_foreign_key => 1, is_nullable => 1, size => 10 },
89
  "date_created",
90
  {
91
    data_type     => "timestamp",
92
    default_value => \"current_timestamp",
93
    is_nullable   => 0,
94
  },
95
  "date_updated",
96
  { data_type => "timestamp", is_nullable => 1 },
97
  "is_deletable",
98
  { data_type => "tinyint", default_value => 1, is_nullable => 0 },
99
);
100
__PACKAGE__->set_primary_key("id");
101
102
=head1 RELATIONS
103
104
=head2 club_template_enrollment_fields
105
106
Type: has_many
107
108
Related object: L<Koha::Schema::Result::ClubTemplateEnrollmentField>
109
110
=cut
111
112
__PACKAGE__->has_many(
113
  "club_template_enrollment_fields",
114
  "Koha::Schema::Result::ClubTemplateEnrollmentField",
115
  { "foreign.club_template" => "self.id" },
116
  { cascade_copy => 0, cascade_delete => 0 },
117
);
118
119
=head2 club_template_fields
120
121
Type: has_many
122
123
Related object: L<Koha::Schema::Result::ClubTemplateField>
124
125
=cut
126
127
__PACKAGE__->has_many(
128
  "club_template_fields",
129
  "Koha::Schema::Result::ClubTemplateField",
130
  { "foreign.club_template" => "self.id" },
131
  { cascade_copy => 0, cascade_delete => 0 },
132
);
133
134
=head2 branch
135
136
Type: belongs_to
137
138
Related object: L<Koha::Schema::Result::Branch>
139
140
=cut
141
142
__PACKAGE__->belongs_to(
143
  "branch",
144
  "Koha::Schema::Result::Branch",
145
  { branchcode => "branch" },
146
  { join_type => "LEFT", on_delete => "CASCADE", on_update => "CASCADE" },
147
);
148
149
=head2 clubs
150
151
Type: has_many
152
153
Related object: L<Koha::Schema::Result::Club>
154
155
=cut
156
157
__PACKAGE__->has_many(
158
  "clubs",
159
  "Koha::Schema::Result::Club",
160
  { "foreign.club_template" => "self.id" },
161
  { cascade_copy => 0, cascade_delete => 0 },
162
);
163
164
165
# Created by DBIx::Class::Schema::Loader v0.07000 @ 2014-05-23 10:30:48
166
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:XhoCAiWRvHG5FBNhr7JEkg
167
168
1;
(-)a/Koha/Schema/Result/ClubTemplateEnrollmentField.pm (+104 lines)
Line 0 Link Here
1
package Koha::Schema::Result::ClubTemplateEnrollmentField;
2
3
# Created by DBIx::Class::Schema::Loader
4
# DO NOT MODIFY THE FIRST PART OF THIS FILE
5
6
use strict;
7
use warnings;
8
9
use base 'DBIx::Class::Core';
10
11
12
=head1 NAME
13
14
Koha::Schema::Result::ClubTemplateEnrollmentField
15
16
=cut
17
18
__PACKAGE__->table("club_template_enrollment_fields");
19
20
=head1 ACCESSORS
21
22
=head2 id
23
24
  data_type: 'integer'
25
  is_auto_increment: 1
26
  is_nullable: 0
27
28
=head2 club_template
29
30
  data_type: 'integer'
31
  is_foreign_key: 1
32
  is_nullable: 0
33
34
=head2 name
35
36
  data_type: 'tinytext'
37
  is_nullable: 0
38
39
=head2 description
40
41
  data_type: 'text'
42
  is_nullable: 1
43
44
=head2 authorised_value_category
45
46
  data_type: 'varchar'
47
  is_nullable: 1
48
  size: 16
49
50
=cut
51
52
__PACKAGE__->add_columns(
53
  "id",
54
  { data_type => "integer", is_auto_increment => 1, is_nullable => 0 },
55
  "club_template",
56
  { data_type => "integer", is_foreign_key => 1, is_nullable => 0 },
57
  "name",
58
  { data_type => "tinytext", is_nullable => 0 },
59
  "description",
60
  { data_type => "text", is_nullable => 1 },
61
  "authorised_value_category",
62
  { data_type => "varchar", is_nullable => 1, size => 16 },
63
);
64
__PACKAGE__->set_primary_key("id");
65
66
=head1 RELATIONS
67
68
=head2 club_enrollment_fields
69
70
Type: has_many
71
72
Related object: L<Koha::Schema::Result::ClubEnrollmentField>
73
74
=cut
75
76
__PACKAGE__->has_many(
77
  "club_enrollment_fields",
78
  "Koha::Schema::Result::ClubEnrollmentField",
79
  { "foreign.club_template_enrollment_field" => "self.id" },
80
  { cascade_copy => 0, cascade_delete => 0 },
81
);
82
83
=head2 club_template
84
85
Type: belongs_to
86
87
Related object: L<Koha::Schema::Result::ClubTemplate>
88
89
=cut
90
91
__PACKAGE__->belongs_to(
92
  "club_template",
93
  "Koha::Schema::Result::ClubTemplate",
94
  { id => "club_template" },
95
  { on_delete => "CASCADE", on_update => "CASCADE" },
96
);
97
98
99
# Created by DBIx::Class::Schema::Loader v0.07000 @ 2014-05-30 09:55:12
100
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:FO/5gEcTgdIYma9hmhXdNw
101
102
103
# You can replace this text with custom content, and it will be preserved on regeneration
104
1;
(-)a/Koha/Schema/Result/ClubTemplateField.pm (+104 lines)
Line 0 Link Here
1
package Koha::Schema::Result::ClubTemplateField;
2
3
# Created by DBIx::Class::Schema::Loader
4
# DO NOT MODIFY THE FIRST PART OF THIS FILE
5
6
use strict;
7
use warnings;
8
9
use base 'DBIx::Class::Core';
10
11
12
=head1 NAME
13
14
Koha::Schema::Result::ClubTemplateField
15
16
=cut
17
18
__PACKAGE__->table("club_template_fields");
19
20
=head1 ACCESSORS
21
22
=head2 id
23
24
  data_type: 'integer'
25
  is_auto_increment: 1
26
  is_nullable: 0
27
28
=head2 club_template
29
30
  data_type: 'integer'
31
  is_foreign_key: 1
32
  is_nullable: 0
33
34
=head2 name
35
36
  data_type: 'tinytext'
37
  is_nullable: 0
38
39
=head2 description
40
41
  data_type: 'text'
42
  is_nullable: 1
43
44
=head2 authorised_value_category
45
46
  data_type: 'varchar'
47
  is_nullable: 1
48
  size: 16
49
50
=cut
51
52
__PACKAGE__->add_columns(
53
  "id",
54
  { data_type => "integer", is_auto_increment => 1, is_nullable => 0 },
55
  "club_template",
56
  { data_type => "integer", is_foreign_key => 1, is_nullable => 0 },
57
  "name",
58
  { data_type => "tinytext", is_nullable => 0 },
59
  "description",
60
  { data_type => "text", is_nullable => 1 },
61
  "authorised_value_category",
62
  { data_type => "varchar", is_nullable => 1, size => 16 },
63
);
64
__PACKAGE__->set_primary_key("id");
65
66
=head1 RELATIONS
67
68
=head2 club_fields
69
70
Type: has_many
71
72
Related object: L<Koha::Schema::Result::ClubField>
73
74
=cut
75
76
__PACKAGE__->has_many(
77
  "club_fields",
78
  "Koha::Schema::Result::ClubField",
79
  { "foreign.club_template_field" => "self.id" },
80
  { cascade_copy => 0, cascade_delete => 0 },
81
);
82
83
=head2 club_template
84
85
Type: belongs_to
86
87
Related object: L<Koha::Schema::Result::ClubTemplate>
88
89
=cut
90
91
__PACKAGE__->belongs_to(
92
  "club_template",
93
  "Koha::Schema::Result::ClubTemplate",
94
  { id => "club_template" },
95
  { on_delete => "CASCADE", on_update => "CASCADE" },
96
);
97
98
99
# Created by DBIx::Class::Schema::Loader v0.07000 @ 2014-05-23 11:09:48
100
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:rm9181l4mTPyIpDBQTERBQ
101
102
103
# You can replace this text with custom content, and it will be preserved on regeneration
104
1;
(-)a/Koha/Template/Plugin/AuthorisedValues.pm (+6 lines)
Lines 40-45 sub GetAuthValueDropbox { Link Here
40
    return C4::Koha::GetAuthvalueDropbox($category, $default);
40
    return C4::Koha::GetAuthvalueDropbox($category, $default);
41
}
41
}
42
42
43
sub Categories {
44
    my ( $self ) = @_;
45
46
    return GetAuthorisedValueCategories();
47
}
48
43
1;
49
1;
44
50
45
=head1 NAME
51
=head1 NAME
(-)a/Koha/Template/Plugin/Borrowers.pm (+4 lines)
Lines 48-51 sub IsDebarred { Link Here
48
    return Koha::Borrower::Debarments::IsDebarred($borrower->{borrowernumber});
48
    return Koha::Borrower::Debarments::IsDebarred($borrower->{borrowernumber});
49
}
49
}
50
50
51
sub HasValidEmailAddress {
52
53
}
54
51
1;
55
1;
(-)a/Koha/Template/Plugin/Branches.pm (+7 lines)
Lines 26-31 use Encode qw{encode decode}; Link Here
26
use C4::Koha;
26
use C4::Koha;
27
use C4::Context;
27
use C4::Context;
28
28
29
sub GetBranches {
30
    my ($self) = @_;
31
32
    my $dbh = C4::Context->dbh;
33
    return $dbh->selectall_arrayref( "SELECT * FROM branches", { Slice => {} } );
34
}
35
29
sub GetName {
36
sub GetName {
30
    my ( $self, $branchcode ) = @_;
37
    my ( $self, $branchcode ) = @_;
31
38
(-)a/Koha/Template/Plugin/Koha.pm (+5 lines)
Lines 44-47 sub Preference { Link Here
44
    return C4::Context->preference( $pref );
44
    return C4::Context->preference( $pref );
45
}
45
}
46
46
47
sub UserEnv {
48
    my ( $self, $key ) = @_;
49
    my $userenv = C4::Context->userenv;
50
    return $userenv ? $userenv->{$key} : undef;
51
}
47
1;
52
1;
(-)a/circ/circulation.pl (+4 lines)
Lines 42-47 use CGI::Session; Link Here
42
use C4::Members::Attributes qw(GetBorrowerAttributes);
42
use C4::Members::Attributes qw(GetBorrowerAttributes);
43
use Koha::Borrower::Debarments qw(GetDebarments IsDebarred);
43
use Koha::Borrower::Debarments qw(GetDebarments IsDebarred);
44
use Koha::DateUtils;
44
use Koha::DateUtils;
45
use Koha::Database;
45
46
46
use Date::Calc qw(
47
use Date::Calc qw(
47
  Today
48
  Today
Lines 762-767 $template->param( picture => 1 ) if $picture; Link Here
762
763
763
my $canned_notes = GetAuthorisedValues("BOR_NOTES");
764
my $canned_notes = GetAuthorisedValues("BOR_NOTES");
764
765
766
my $schema = Koha::Database->new()->schema();
767
765
$template->param(
768
$template->param(
766
    debt_confirmed            => $debt_confirmed,
769
    debt_confirmed            => $debt_confirmed,
767
    SpecifyDueDate            => $duedatespec_allow,
770
    SpecifyDueDate            => $duedatespec_allow,
Lines 771-776 $template->param( Link Here
771
    export_with_csv_profile   => C4::Context->preference("ExportWithCsvProfile"),
774
    export_with_csv_profile   => C4::Context->preference("ExportWithCsvProfile"),
772
    canned_bor_notes_loop     => $canned_notes,
775
    canned_bor_notes_loop     => $canned_notes,
773
    debarments                => GetDebarments({ borrowernumber => $borrowernumber }),
776
    debarments                => GetDebarments({ borrowernumber => $borrowernumber }),
777
    borrower                  => $schema->resultset('Borrower')->find( $borrowernumber ),
774
);
778
);
775
779
776
output_html_with_http_headers $query, $cookie, $template->output;
780
output_html_with_http_headers $query, $cookie, $template->output;
(-)a/clubs/clubs-add-modify.pl (+125 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Copyright 2013 ByWater Solutions
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it
8
# under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
11
#
12
# Koha is distributed in the hope that it will be useful, but
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
20
use Modern::Perl;
21
22
use CGI;
23
24
use C4::Auth;
25
use C4::Output;
26
use Koha::Database;
27
use Koha::DateUtils qw(dt_from_string);
28
29
my $cgi = new CGI;
30
31
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
32
    {
33
        template_name   => 'clubs/clubs-add-modify.tt',
34
        query           => $cgi,
35
        type            => 'intranet',
36
        authnotrequired => 0,
37
        flagsrequired   => { clubs => 'edit_clubs' },
38
    }
39
);
40
41
my $schema = Koha::Database->new()->schema();
42
43
my $id   = $cgi->param('id');
44
my $club = $schema->resultset('Club')->find($id);
45
46
my $club_template_id =
47
  $club ? $club->club_template()->id() : $cgi->param('club_template_id');
48
my $club_template = $schema->resultset('ClubTemplate')->find($club_template_id);
49
50
my $date_start = $cgi->param('date_start');
51
$date_start = $date_start ? dt_from_string($date_start) : undef;
52
my $date_end = $cgi->param('date_end');
53
$date_end = $date_end ? dt_from_string($date_end) : undef;
54
55
if ( $cgi->param('name') ) {    # Update or create club
56
    if ($club) {
57
        $club->update(
58
            {
59
                id            => $id                             || undef,
60
                club_template => $cgi->param('club_template_id') || undef,
61
                name          => $cgi->param('name')             || undef,
62
                description   => $cgi->param('description')      || undef,
63
                branch        => $cgi->param('branchcode')       || undef,
64
                date_start    => $date_start,
65
                date_end      => $date_end,
66
                date_updated  => dt_from_string(),
67
            }
68
        );
69
    }
70
    else {
71
        $club = $schema->resultset('Club')->create(
72
            {
73
                id            => $id                             || undef,
74
                club_template => $cgi->param('club_template_id') || undef,
75
                name          => $cgi->param('name')             || undef,
76
                description   => $cgi->param('description')      || undef,
77
                branch        => $cgi->param('branchcode')       || undef,
78
                date_start    => $date_start,
79
                date_end      => $date_end,
80
                date_updated  => dt_from_string(),
81
            }
82
        );
83
84
    }
85
86
    my @club_template_field_id = $cgi->param('club_template_field_id');
87
    my @club_field_id          = $cgi->param('club_field_id');
88
    my @club_field             = $cgi->param('club_field');
89
90
    for ( my $i = 0 ; $i < @club_template_field_id ; $i++ ) {
91
        my $club_template_field_id = $club_template_field_id[$i] || undef;
92
        my $club_field_id          = $club_field_id[$i]          || undef;
93
        my $club_field             = $club_field[$i]             || undef;
94
95
        if ($club_field_id) {
96
            $schema->resultset('ClubField')->find($club_field_id)->update(
97
                {
98
                    club                => $club->id(),
99
                    club_template_field => $club_template_field_id,
100
                    value               => $club_field,
101
                }
102
            );
103
        }
104
        else {
105
            $schema->resultset('ClubField')->create(
106
                {
107
                    club                => $club->id(),
108
                    club_template_field => $club_template_field_id,
109
                    value               => $club_field,
110
                }
111
            );
112
        }
113
    }
114
115
    $id ||= $club->id();
116
}
117
118
$club = $schema->resultset('Club')->find($id);
119
120
$template->param(
121
    club_template => $club_template,
122
    club          => $club,
123
);
124
125
output_html_with_http_headers( $cgi, $cookie, $template->output );
(-)a/clubs/clubs.pl (+50 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Copyright 2013 ByWater Solutions
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it
8
# under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
11
#
12
# Koha is distributed in the hope that it will be useful, but
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
20
use Modern::Perl;
21
22
use CGI;
23
24
use C4::Auth;
25
use C4::Output;
26
use Koha::Database;
27
28
my $cgi = new CGI;
29
30
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
31
    {
32
        template_name   => "clubs/clubs.tt",
33
        query           => $cgi,
34
        type            => "intranet",
35
        authnotrequired => 0,
36
        flagsrequired   => { clubs => '*' },
37
    }
38
);
39
40
my $schema = Koha::Database->new()->schema();
41
42
my @club_templates = $schema->resultset("ClubTemplate")->all();
43
my @clubs          = $schema->resultset("Club")->all();
44
45
$template->param(
46
    club_templates => \@club_templates,
47
    clubs          => \@clubs
48
);
49
50
output_html_with_http_headers( $cgi, $cookie, $template->output );
(-)a/clubs/patron-clubs-tab.pl (+59 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Copyright 2013 ByWater Solutions
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it
8
# under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
11
#
12
# Koha is distributed in the hope that it will be useful, but
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
20
use Modern::Perl;
21
22
use CGI;
23
24
use C4::Auth;
25
use C4::Output;
26
use Koha::Database;
27
28
my $cgi = new CGI;
29
30
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
31
    {
32
        template_name   => "clubs/patron-clubs-tab.tt",
33
        query           => $cgi,
34
        type            => "intranet",
35
        authnotrequired => 0,
36
        flagsrequired   => { clubs => '*' },
37
    }
38
);
39
40
my $borrowernumber = $cgi->param('borrowernumber');
41
42
my $schema = Koha::Database->new()->schema();
43
44
my @enrollments =
45
  $schema->resultset("ClubEnrollment")
46
  ->search( { borrower => $borrowernumber, date_canceled => undef } );
47
48
my @clubs =
49
  $schema->resultset("Club")
50
  ->search(
51
    { id => { -not_in => [ map { $_->club()->id() } @enrollments ] } } );
52
53
$template->param(
54
    enrollments    => \@enrollments,
55
    clubs          => \@clubs,
56
    borrowernumber => $borrowernumber
57
);
58
59
output_html_with_http_headers( $cgi, $cookie, $template->output );
(-)a/clubs/patron-enroll.pl (+52 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Copyright 2013 ByWater Solutions
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it
8
# under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
11
#
12
# Koha is distributed in the hope that it will be useful, but
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
20
use Modern::Perl;
21
22
use CGI;
23
24
use C4::Auth;
25
use C4::Output;
26
use Koha::Database;
27
28
my $cgi = new CGI;
29
30
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
31
    {
32
        template_name   => "clubs/patron-enroll.tt",
33
        query           => $cgi,
34
        type            => "intranet",
35
        authnotrequired => 0,
36
        flagsrequired   => { clubs => '*' },
37
    }
38
);
39
40
my $id             = $cgi->param('id');
41
my $borrowernumber = $cgi->param('borrowernumber');
42
43
my $schema = Koha::Database->new()->schema();
44
45
my $club = $schema->resultset("Club")->find($id);
46
47
$template->param(
48
    club           => $club,
49
    borrowernumber => $borrowernumber,
50
);
51
52
output_html_with_http_headers( $cgi, $cookie, $template->output );
(-)a/clubs/templates-add-modify.pl (+139 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Copyright 2013 ByWater Solutions
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it
8
# under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
11
#
12
# Koha is distributed in the hope that it will be useful, but
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
20
use Modern::Perl;
21
22
use CGI;
23
24
use C4::Auth;
25
use C4::Output;
26
use Koha::Database;
27
use Koha::DateUtils qw(dt_from_string);
28
29
my $cgi = new CGI;
30
31
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
32
    {
33
        template_name   => 'clubs/templates-add-modify.tt',
34
        query           => $cgi,
35
        type            => 'intranet',
36
        authnotrequired => 0,
37
        flagsrequired   => { clubs => 'edit_templates' },
38
    }
39
);
40
41
my $id = $cgi->param('id');
42
43
my $schema = Koha::Database->new()->schema();
44
45
my $club_template;
46
47
if ( $cgi->param('name') ) {    # Update or create club
48
    $club_template = $schema->resultset('ClubTemplate')->update_or_create(
49
        {
50
            id          => $id                        || undef,
51
            name        => $cgi->param('name')        || undef,
52
            description => $cgi->param('description') || undef,
53
            branch      => $cgi->param('branchcode')  || undef,
54
            date_updated            => dt_from_string(),
55
            is_email_required       => $cgi->param('is_email_required') ? 1 : 0,
56
            is_enrollable_from_opac => $cgi->param('is_enrollable_from_opac')
57
            ? 1
58
            : 0,
59
        }
60
    );
61
62
    $id ||= $club_template->id();
63
64
    # Update club creation fields
65
    my @field_id          = $cgi->param('club_template_field_id');
66
    my @field_name        = $cgi->param('club_template_field_name');
67
    my @field_description = $cgi->param('club_template_field_description');
68
    my @field_authorised_value_category =
69
      $cgi->param('club_template_field_authorised_value_category');
70
71
    my @field_delete = $cgi->param('club_template_field_delete');
72
73
    for ( my $i = 0 ; $i < @field_id ; $i++ ) {
74
        my $field_id          = $field_id[$i];
75
        my $field_name        = $field_name[$i];
76
        my $field_description = $field_description[$i];
77
        my $field_authorised_value_category =
78
          $field_authorised_value_category[$i];
79
80
        if ( grep( /^$field_id$/, @field_delete ) ) {
81
            $schema->resultset('ClubTemplateField')->find($field_id)->delete();
82
        }
83
        else {
84
            $club_template =
85
              $schema->resultset('ClubTemplateField')->update_or_create(
86
                {
87
                    id            => $field_id,
88
                    club_template => $id,
89
                    name          => $field_name,
90
                    description   => $field_description,
91
                    authorised_value_category =>
92
                      $field_authorised_value_category,
93
                }
94
              );
95
        }
96
    }
97
98
    # Update club enrollment fields
99
    @field_id   = $cgi->param('club_template_enrollment_field_id');
100
    @field_name = $cgi->param('club_template_enrollment_field_name');
101
    @field_description =
102
      $cgi->param('club_template_enrollment_field_description');
103
    @field_authorised_value_category =
104
      $cgi->param('club_template_enrollment_field_authorised_value_category');
105
106
    @field_delete = $cgi->param('club_template_enrollment_field_delete');
107
108
    for ( my $i = 0 ; $i < @field_id ; $i++ ) {
109
        my $field_id          = $field_id[$i];
110
        my $field_name        = $field_name[$i];
111
        my $field_description = $field_description[$i];
112
        my $field_authorised_value_category =
113
          $field_authorised_value_category[$i];
114
115
        if ( grep( /^$field_id$/, @field_delete ) ) {
116
            $schema->resultset('ClubTemplateEnrollmentField')->find($field_id)
117
              ->delete();
118
        }
119
        else {
120
            $club_template =
121
              $schema->resultset('ClubTemplateEnrollmentField')
122
              ->update_or_create(
123
                {
124
                    id            => $field_id,
125
                    club_template => $id,
126
                    name          => $field_name,
127
                    description   => $field_description,
128
                    authorised_value_category =>
129
                      $field_authorised_value_category,
130
                }
131
              );
132
        }
133
    }
134
}
135
136
$club_template = $schema->resultset('ClubTemplate')->find($id);
137
$template->param( club_template => $club_template );
138
139
output_html_with_http_headers( $cgi, $cookie, $template->output );
(-)a/installer/data/mysql/en/mandatory/userflags.sql (+1 lines)
Lines 18-20 INSERT INTO userflags (bit, flag, flagdesc, defaulton) VALUES Link Here
18
(17,'staffaccess','Allow staff members to modify permissions for other staff members',0),
18
(17,'staffaccess','Allow staff members to modify permissions for other staff members',0),
19
(18,'coursereserves','Course reserves',0),
19
(18,'coursereserves','Course reserves',0),
20
(19, 'plugins', 'Koha plugins', '0');
20
(19, 'plugins', 'Koha plugins', '0');
21
(20, 'clubs', 'Patron clubs', '0');
(-)a/installer/data/mysql/en/mandatory/userpermissions.sql (+3 lines)
Lines 68-71 INSERT INTO permissions (module_bit, code, description) VALUES Link Here
68
   (19, 'tool', 'Use tool plugins'),
68
   (19, 'tool', 'Use tool plugins'),
69
   (19, 'report', 'Use report plugins'),
69
   (19, 'report', 'Use report plugins'),
70
   (19, 'configure', 'Configure plugins')
70
   (19, 'configure', 'Configure plugins')
71
   (20, 'edit_templates', 'Create and update club templates'),
72
   (20, 'edit_clubs', 'Create and update clubs'),
73
   (20, 'enroll', 'Enroll patrons in clubs')
71
;
74
;
(-)a/installer/data/mysql/kohastructure.sql (+173 lines)
Lines 3422-3427 CREATE TABLE IF NOT EXISTS `misc_files` ( -- miscellaneous files attached to rec Link Here
3422
  KEY `record_id` (`record_id`)
3422
  KEY `record_id` (`record_id`)
3423
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
3423
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
3424
3424
3425
--
3426
-- Table structure for table 'clubs'
3427
--
3428
3429
CREATE TABLE clubs (
3430
    id int(11) NOT NULL AUTO_INCREMENT,
3431
    club_template int(11) NOT NULL,
3432
    `name` tinytext NOT NULL,
3433
    description text,
3434
    date_start date DEFAULT NULL,
3435
    date_end date DEFAULT NULL,
3436
    branch varchar(11) DEFAULT NULL,
3437
    date_created timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
3438
    date_updated timestamp NULL DEFAULT NULL,
3439
    PRIMARY KEY (id),
3440
    KEY club_template (club_template),
3441
    KEY branch (branch)
3442
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
3443
3444
-- --------------------------------------------------------
3445
3446
--
3447
-- Table structure for table 'club_enrollments'
3448
--
3449
3450
CREATE TABLE club_enrollments (
3451
    id int(11) NOT NULL AUTO_INCREMENT,
3452
    club int(11) NOT NULL,
3453
    borrower int(11) NOT NULL,
3454
    date_enrolled timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
3455
    date_canceled timestamp NULL DEFAULT NULL,
3456
    date_created timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
3457
    date_updated timestamp NULL DEFAULT NULL,
3458
    branch varchar(11) DEFAULT NULL,
3459
    PRIMARY KEY (id),
3460
    KEY club (club),
3461
    KEY borrower (borrower),
3462
    KEY branch (branch)
3463
) ENGINE=InnoDB  DEFAULT CHARSET=utf8;
3464
3465
-- --------------------------------------------------------
3466
3467
--
3468
-- Table structure for table 'club_enrollment_fields'
3469
--
3470
3471
CREATE TABLE club_enrollment_fields (
3472
    id int(11) NOT NULL AUTO_INCREMENT,
3473
    club_enrollment int(11) NOT NULL,
3474
    club_template_enrollment_field int(11) NOT NULL,
3475
    `value` text NOT NULL,
3476
    PRIMARY KEY (id),
3477
    KEY club_enrollment (club_enrollment),
3478
    KEY club_template_enrollment_field (club_template_enrollment_field),
3479
    KEY club_template_enrollment_field_2 (club_template_enrollment_field)
3480
) ENGINE=InnoDB  DEFAULT CHARSET=utf8;
3481
3482
-- --------------------------------------------------------
3483
3484
--
3485
-- Table structure for table 'club_fields'
3486
--
3487
3488
CREATE TABLE club_fields (
3489
    id int(11) NOT NULL AUTO_INCREMENT,
3490
    club_template_field int(11) NOT NULL,
3491
    club int(11) NOT NULL,
3492
    `value` text,
3493
    PRIMARY KEY (id),
3494
    KEY club_template_field (club_template_field,club),
3495
    KEY club (club)
3496
) ENGINE=InnoDB  DEFAULT CHARSET=utf8;
3497
3498
-- --------------------------------------------------------
3499
3500
--
3501
-- Table structure for table 'club_templates'
3502
--
3503
3504
CREATE TABLE club_templates (
3505
    id int(11) NOT NULL AUTO_INCREMENT,
3506
    `name` tinytext NOT NULL,
3507
    description text,
3508
    is_enrollable_from_opac tinyint(1) NOT NULL DEFAULT '0',
3509
    is_email_required tinyint(1) NOT NULL DEFAULT '0',
3510
    branch varchar(10) CHARACTER SET utf8 DEFAULT NULL,
3511
    date_created timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
3512
    date_updated timestamp NULL DEFAULT NULL,
3513
    is_deletable tinyint(1) NOT NULL DEFAULT '1',
3514
    PRIMARY KEY (id),
3515
    KEY branch (branch)
3516
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
3517
3518
-- --------------------------------------------------------
3519
3520
--
3521
-- Table structure for table 'club_template_enrollment_fields'
3522
--
3523
3524
CREATE TABLE club_template_enrollment_fields (
3525
    id int(11) NOT NULL AUTO_INCREMENT,
3526
    club_template int(11) NOT NULL,
3527
    `name` tinytext NOT NULL,
3528
    description text,
3529
    authorised_value_category varchar(16) DEFAULT NULL,
3530
    PRIMARY KEY (id),
3531
    KEY club_template (club_template),
3532
    KEY club_template_2 (club_template)
3533
) ENGINE=InnoDB  DEFAULT CHARSET=utf8;
3534
3535
-- --------------------------------------------------------
3536
3537
--
3538
-- Table structure for table 'club_template_fields'
3539
--
3540
3541
CREATE TABLE club_template_fields (
3542
    id int(11) NOT NULL AUTO_INCREMENT,
3543
    club_template int(11) NOT NULL,
3544
    `name` tinytext NOT NULL,
3545
    description text,
3546
    authorised_value_category varchar(16) DEFAULT NULL,
3547
    PRIMARY KEY (id),
3548
    KEY club_template (club_template)
3549
) ENGINE=InnoDB  DEFAULT CHARSET=utf8;
3550
3551
--
3552
-- Constraints for table `clubs`
3553
--
3554
ALTER TABLE `clubs`
3555
ADD CONSTRAINT clubs_ibfk_1 FOREIGN KEY (club_template) REFERENCES club_templates (id) ON DELETE CASCADE ON UPDATE CASCADE,
3556
ADD CONSTRAINT clubs_ibfk_2 FOREIGN KEY (branch) REFERENCES branches (branchcode);
3557
3558
--
3559
-- Constraints for table `club_enrollments`
3560
--
3561
ALTER TABLE `club_enrollments`
3562
ADD CONSTRAINT club_enrollments_ibfk_1 FOREIGN KEY (club) REFERENCES clubs (id) ON DELETE CASCADE ON UPDATE CASCADE,
3563
ADD CONSTRAINT club_enrollments_ibfk_2 FOREIGN KEY (borrower) REFERENCES borrowers (borrowernumber) ON DELETE CASCADE ON UPDATE CASCADE,
3564
ADD CONSTRAINT club_enrollments_ibfk_3 FOREIGN KEY (branch) REFERENCES branches (branchcode) ON DELETE SET NULL ON UPDATE CASCADE;
3565
3566
--
3567
-- Constraints for table `club_enrollment_fields`
3568
--
3569
ALTER TABLE `club_enrollment_fields`
3570
ADD CONSTRAINT club_enrollment_fields_ibfk_1 FOREIGN KEY (club_enrollment) REFERENCES club_enrollments (id) ON DELETE CASCADE ON UPDATE CASCADE,
3571
ADD CONSTRAINT club_enrollment_fields_ibfk_2 FOREIGN KEY (club_template_enrollment_field) REFERENCES club_template_enrollment_fields (id) ON DELETE CASCADE ON UPDATE CASCADE;
3572
3573
--
3574
-- Constraints for table `club_fields`
3575
--
3576
ALTER TABLE `club_fields`
3577
ADD CONSTRAINT club_fields_ibfk_3 FOREIGN KEY (club_template_field) REFERENCES club_template_fields (id) ON DELETE CASCADE ON UPDATE CASCADE,
3578
ADD CONSTRAINT club_fields_ibfk_4 FOREIGN KEY (club) REFERENCES clubs (id) ON DELETE CASCADE ON UPDATE CASCADE;
3579
3580
--
3581
-- Constraints for table `club_templates`
3582
--
3583
ALTER TABLE `club_templates`
3584
ADD CONSTRAINT club_templates_ibfk_1 FOREIGN KEY (branch) REFERENCES branches (branchcode) ON DELETE SET NULL ON UPDATE CASCADE;
3585
3586
--
3587
-- Constraints for table `club_template_enrollment_fields`
3588
--
3589
ALTER TABLE `club_template_enrollment_fields`
3590
ADD CONSTRAINT club_template_enrollment_fields_ibfk_1 FOREIGN KEY (club_template) REFERENCES club_templates (id) ON DELETE CASCADE ON UPDATE CASCADE;
3591
3592
--
3593
-- Constraints for table `club_template_fields`
3594
--
3595
ALTER TABLE `club_template_fields`
3596
ADD CONSTRAINT club_template_fields_ibfk_1 FOREIGN KEY (club_template) REFERENCES club_templates (id) ON DELETE CASCADE ON UPDATE CASCADE;
3597
3425
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
3598
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
3426
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
3599
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
3427
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
3600
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
(-)a/installer/data/mysql/updatedatabase.pl (+148 lines)
Lines 8551-8556 if (CheckVersion($DBversion)) { Link Here
8551
    SetVersion($DBversion);
8551
    SetVersion($DBversion);
8552
}
8552
}
8553
8553
8554
$DBversion = "3.17.00.XXX";
8555
if ( CheckVersion($DBversion) ) {
8556
    $dbh->do("INSERT INTO userflags (bit, flag, flagdesc, defaulton) VALUES ('20', 'clubs', 'Patron clubs', '0')");
8557
8558
    $dbh->do("
8559
        CREATE TABLE clubs (
8560
            id int(11) NOT NULL AUTO_INCREMENT,
8561
            club_template int(11) NOT NULL,
8562
            `name` tinytext NOT NULL,
8563
            description text,
8564
            date_start date DEFAULT NULL,
8565
            date_end date DEFAULT NULL,
8566
            branch varchar(11) DEFAULT NULL,
8567
            date_created timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
8568
            date_updated timestamp NULL DEFAULT NULL,
8569
            PRIMARY KEY (id),
8570
            KEY club_template (club_template),
8571
            KEY branch (branch)
8572
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
8573
    ");
8574
8575
    $dbh->do("
8576
        CREATE TABLE club_enrollments (
8577
            id int(11) NOT NULL AUTO_INCREMENT,
8578
            club int(11) NOT NULL,
8579
            borrower int(11) NOT NULL,
8580
            date_enrolled timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
8581
            date_canceled timestamp NULL DEFAULT NULL,
8582
            date_created timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
8583
            date_updated timestamp NULL DEFAULT NULL,
8584
            branch varchar(11) DEFAULT NULL,
8585
            PRIMARY KEY (id),
8586
            KEY club (club),
8587
            KEY borrower (borrower),
8588
            KEY branch (branch)
8589
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
8590
    ");
8591
8592
    $dbh->do("
8593
        CREATE TABLE club_enrollment_fields (
8594
            id int(11) NOT NULL AUTO_INCREMENT,
8595
            club_enrollment int(11) NOT NULL,
8596
            club_template_enrollment_field int(11) NOT NULL,
8597
            `value` text NOT NULL,
8598
            PRIMARY KEY (id),
8599
            KEY club_enrollment (club_enrollment),
8600
            KEY club_template_enrollment_field (club_template_enrollment_field),
8601
            KEY club_template_enrollment_field_2 (club_template_enrollment_field)
8602
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
8603
    ");
8604
8605
    $dbh->do("
8606
        CREATE TABLE club_fields (
8607
            id int(11) NOT NULL AUTO_INCREMENT,
8608
            club_template_field int(11) NOT NULL,
8609
            club int(11) NOT NULL,
8610
            `value` text,
8611
            PRIMARY KEY (id),
8612
            KEY club_template_field (club_template_field,club),
8613
            KEY club (club)
8614
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
8615
    ");
8616
8617
    $dbh->do("
8618
        CREATE TABLE club_templates (
8619
            id int(11) NOT NULL AUTO_INCREMENT,
8620
            `name` tinytext NOT NULL,
8621
            description text,
8622
            is_enrollable_from_opac tinyint(1) NOT NULL DEFAULT '0',
8623
            is_email_required tinyint(1) NOT NULL DEFAULT '0',
8624
            branch varchar(10) CHARACTER SET utf8 DEFAULT NULL,
8625
            date_created timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
8626
            date_updated timestamp NULL DEFAULT NULL,
8627
            is_deletable tinyint(1) NOT NULL DEFAULT '1',
8628
            PRIMARY KEY (id),
8629
            KEY branch (branch)
8630
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8 DEFAULT;
8631
    ");
8632
8633
    $dbh->do("
8634
        CREATE TABLE club_template_enrollment_fields (
8635
            id int(11) NOT NULL AUTO_INCREMENT,
8636
            club_template int(11) NOT NULL,
8637
            `name` tinytext NOT NULL,
8638
            description text,
8639
            authorised_value_category varchar(16) DEFAULT NULL,
8640
            PRIMARY KEY (id),
8641
            KEY club_template (club_template),
8642
            KEY club_template_2 (club_template)
8643
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
8644
    ");
8645
8646
    $dbh->do("
8647
        CREATE TABLE club_template_fields (
8648
            id int(11) NOT NULL AUTO_INCREMENT,
8649
            club_template int(11) NOT NULL,
8650
            `name` tinytext NOT NULL,
8651
            description text,
8652
            authorised_value_category varchar(16) DEFAULT NULL,
8653
            PRIMARY KEY (id),
8654
            KEY club_template (club_template)
8655
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
8656
    ");
8657
8658
    $dbh->do("
8659
        ALTER TABLE `clubs`
8660
            ADD CONSTRAINT clubs_ibfk_1 FOREIGN KEY (club_template) REFERENCES club_templates (id) ON DELETE CASCADE ON UPDATE CASCADE,
8661
            ADD CONSTRAINT clubs_ibfk_2 FOREIGN KEY (branch) REFERENCES branches (branchcode);
8662
    ");
8663
8664
    $dbh->do("
8665
        ALTER TABLE `club_enrollments`
8666
            ADD CONSTRAINT club_enrollments_ibfk_1 FOREIGN KEY (club) REFERENCES clubs (id) ON DELETE CASCADE ON UPDATE CASCADE,
8667
            ADD CONSTRAINT club_enrollments_ibfk_2 FOREIGN KEY (borrower) REFERENCES borrowers (borrowernumber) ON DELETE CASCADE ON UPDATE CASCADE,
8668
            ADD CONSTRAINT club_enrollments_ibfk_3 FOREIGN KEY (branch) REFERENCES branches (branchcode) ON DELETE SET NULL ON UPDATE CASCADE;
8669
    ");
8670
8671
    $dbh->do("
8672
        ALTER TABLE `club_enrollment_fields`
8673
            ADD CONSTRAINT club_enrollment_fields_ibfk_1 FOREIGN KEY (club_enrollment) REFERENCES club_enrollments (id) ON DELETE CASCADE ON UPDATE CASCADE,
8674
            ADD CONSTRAINT club_enrollment_fields_ibfk_2 FOREIGN KEY (club_template_enrollment_field) REFERENCES club_template_enrollment_fields (id) ON DELETE CASCADE ON UPDATE CASCADE;
8675
    ");
8676
8677
    $dbh->do("
8678
        ALTER TABLE `club_fields`
8679
            ADD CONSTRAINT club_fields_ibfk_3 FOREIGN KEY (club_template_field) REFERENCES club_template_fields (id) ON DELETE CASCADE ON UPDATE CASCADE,
8680
            ADD CONSTRAINT club_fields_ibfk_4 FOREIGN KEY (club) REFERENCES clubs (id) ON DELETE CASCADE ON UPDATE CASCADE;
8681
    ");
8682
8683
    $dbh->do("
8684
        ALTER TABLE `club_templates`
8685
            ADD CONSTRAINT club_templates_ibfk_1 FOREIGN KEY (branch) REFERENCES branches (branchcode) ON DELETE SET NULL ON UPDATE CASCADE;
8686
    ");
8687
8688
    $dbh->do("
8689
        ALTER TABLE `club_template_enrollment_fields`
8690
            ADD CONSTRAINT club_template_enrollment_fields_ibfk_1 FOREIGN KEY (club_template) REFERENCES club_templates (id) ON DELETE CASCADE ON UPDATE CASCADE;
8691
    ");
8692
8693
    $dbh->do("
8694
        ALTER TABLE `club_template_fields`
8695
            ADD CONSTRAINT club_template_fields_ibfk_1 FOREIGN KEY (club_template) REFERENCES club_templates (id) ON DELETE CASCADE ON UPDATE CASCADE;
8696
    ");
8697
8698
   print "Upgrade to $DBversion done (Bug 12461 - Add patron clubs feature)\n";
8699
   SetVersion ($DBversion);
8700
}
8701
8554
=head1 FUNCTIONS
8702
=head1 FUNCTIONS
8555
8703
8556
=head2 TableExists($table)
8704
=head2 TableExists($table)
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt (+18 lines)
Lines 26-31 var MSG_EXPORT_SELECT_CHECKOUTS = _("You must select checkout(s) to export"); Link Here
26
[% IF ( borrowernumber ) %]if($.cookie("holdfor") != [% borrowernumber %]){ $.cookie("holdfor",null, { path: "/", expires: 0 }); }[% ELSE %]$.cookie("holdfor",null, { path: "/", expires: 0 });[% END %]
26
[% IF ( borrowernumber ) %]if($.cookie("holdfor") != [% borrowernumber %]){ $.cookie("holdfor",null, { path: "/", expires: 0 }); }[% ELSE %]$.cookie("holdfor",null, { path: "/", expires: 0 });[% END %]
27
[% UNLESS ( borrowernumber ) %][% UNLESS ( CGIselectborrower ) %]window.onload=function(){ $('#findborrower').focus(); };[% END %][% END %]
27
[% UNLESS ( borrowernumber ) %][% UNLESS ( CGIselectborrower ) %]window.onload=function(){ $('#findborrower').focus(); };[% END %][% END %]
28
	 $(document).ready(function() {
28
	 $(document).ready(function() {
29
        $('#clubs-tab-link').on('click', function() {
30
            $('#clubs-tab').text(_("Loading..."));
31
            $('#clubs-tab').load('/cgi-bin/koha/clubs/patron-clubs-tab.pl?borrowernumber=[% borrowernumber %]');
32
        });
33
29
        $('#patronlists').tabs([% IF ( UseTablesortForCirc ) %]{
34
        $('#patronlists').tabs([% IF ( UseTablesortForCirc ) %]{
30
            // Correct table sizing for tables hidden in tabs
35
            // Correct table sizing for tables hidden in tabs
31
            // http://www.datatables.net/examples/api/tabs_and_scrolling.html
36
            // http://www.datatables.net/examples/api/tabs_and_scrolling.html
Lines 711-716 No patron matched <span class="ex">[% message %]</span> Link Here
711
            <a href="#reserves">0 Holds</a>
716
            <a href="#reserves">0 Holds</a>
712
    [% END %]</li>
717
    [% END %]</li>
713
    <li><a id="debarments-tab-link" href="#reldebarments">[% debarments.size %] Restrictions</a></li>
718
    <li><a id="debarments-tab-link" href="#reldebarments">[% debarments.size %] Restrictions</a></li>
719
    [% IF CAN_user_clubs && ( borrower.ClubsEnrolledCount || borrower.ClubsEnrollableCount ) %]
720
        <li>
721
            <a id="clubs-tab-link" href="#clubs-tab">
722
                Clubs ([% borrower.ClubsEnrolledCount %]/[% borrower.ClubsEnrollableCount %])
723
            </a>
724
        </li>
725
    [% END %]
714
726
715
</ul>
727
</ul>
716
728
Lines 1042-1047 No patron matched <span class="ex">[% message %]</span> Link Here
1042
</div>
1054
</div>
1043
[% END %]<!-- end displayrelissues -->
1055
[% END %]<!-- end displayrelissues -->
1044
1056
1057
[% IF CAN_user_clubs %]
1058
    <div id="clubs-tab">
1059
        Loading...
1060
    </div>
1061
[% END %]
1062
1045
[% INCLUDE borrower_debarments.inc %]
1063
[% INCLUDE borrower_debarments.inc %]
1046
1064
1047
<div id="reserves">
1065
<div id="reserves">
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/clubs/clubs-add-modify.tt (+136 lines)
Line 0 Link Here
1
[% USE KohaDates %]
2
[% USE EncodeUTF8 %]
3
[% USE Branches %]
4
[% USE AuthorisedValues %]
5
[% SET AuthorisedValuesCategories = AuthorisedValues.Categories %]
6
[% INCLUDE 'doc-head-open.inc' %]
7
<title>Koha &rsaquo; Tools &rsaquo; Patron clubs &rsaquo; Club</title>
8
[% INCLUDE 'doc-head-close.inc' %]
9
[% INCLUDE 'calendar.inc' %]
10
11
<script type="text/javascript">
12
//<![CDATA[
13
14
function CheckForm() {
15
  if ( !$("#club-name").val() ) {
16
    alert( _("Name is a required field!")  );
17
    return false;
18
  }
19
20
  return true;
21
}
22
23
//]]>
24
</script>
25
26
</head>
27
28
<body>
29
[% INCLUDE 'header.inc' %]
30
[% INCLUDE 'cat-search.inc' %]
31
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> &rsaquo; <a href="clubs.pl">Patron clubs</a> &rsaquo; Add / modify club</div>
32
33
<div class="yui-t7">
34
    <div class="yui-main">
35
        <form method="post" onsubmit="return CheckForm()">
36
            <input type="hidden" name="id" value="[% club.id %]" />
37
            <input type="hidden" name="club_template_id" value="[% club_template.id %]" />
38
39
            <fieldset class="rows">
40
41
                <legend>
42
                    [% IF club %]
43
                        Modify club <i>[% club.name %]</i>
44
                    [% ELSE %]
45
                        Create a new <i>[% club_template.name %]</i> club
46
                    [% END %]
47
                </legend>
48
49
                <ol>
50
                    <li>
51
                        <label class="required" for="name">Name:</label>
52
                        <input id="club-name" name="name" type="text" value="[% club.name %]" />
53
                    </li>
54
55
                    <li>
56
                        <label for="description">Description:</label>
57
                        <input id="club-template-name" name="description" type="text" value="[% club.description %]" />
58
                    </li>
59
60
                    <li>
61
                        <label for="date_start">Start date:</label>
62
                        <input name="date_start" id="from" size="10" readonly="readonly" class="datepickerfrom" value="[% club.date_start | $KohaDates %]">
63
                    </li>
64
65
                    <li>
66
                        <label for="date_end">End date:</label>
67
                        <input name="date_end" id="to" size="10" readonly="readonly" class="datepickerto" value="[% club.date_end | $KohaDates %]" >
68
                    </li>
69
70
                    <li>
71
                        <label for="name">Branch:</label>
72
                        <select name="branchcode" id="club-template-branchcode">
73
                            <option value="">&nbsp</option>
74
                            [% FOREACH b IN Branches.GetBranches() %]
75
                                [% IF b.branchcode == club.branch.branchcode %]
76
                                    <option value="[% b.branchcode %]" selected="selected">[% b.branchname | $EncodeUTF8 %]</option>
77
                                [% ELSE %]
78
                                    <option value="[% b.branchcode %]">[% b.branchname | $EncodeUTF8 %]</option>
79
                                [% END %]
80
                            [% END %]
81
                        </select>
82
                    </li>
83
84
                    [% IF club %]
85
                        [% FOREACH f IN club.club_fields %]
86
                            <li>
87
                                <input type="hidden" name="club_template_field_id" value="[% f.club_template_field.id %]" />
88
                                <input type="hidden" name="club_field_id" value="[% f.id %]" />
89
90
                                <label for="club_field">[% f.club_template_field.name %]</label>
91
                                [% IF f.club_template_field.authorised_value_category %]
92
                                    <select name="club_field">
93
                                        [% FOREACH a IN AuthorisedValues.Get( f.club_template_field.authorised_value_category ) %]
94
                                            [% IF a.authorised_value == f.value %]
95
                                                <option value="[% a.authorised_value %]" selected="selected">[% a.lib %]</option>
96
                                            [% ELSE %]
97
                                                <option value="[% a.authorised_value %]">[% a.lib %]</option>
98
                                            [% END %]
99
                                        [% END %]
100
                                    </select>
101
                                [% ELSE %]
102
                                    <input type="text" name="club_field" value="[% f.value %]" />
103
                                [% END %]
104
                            </li>
105
                        [% END %]
106
                    [% ELSE %]
107
                        [% FOREACH f IN club_template.club_template_fields %]
108
                            <li>
109
                                <input type="hidden" name="club_template_field_id" value="[% f.id %]" />
110
111
                                <label for="club_field">[% f.name %]</label>
112
                                [% IF f.authorised_value_category %]
113
                                    <select name="club_field">
114
                                        [% FOREACH a IN AuthorisedValues.Get( f.authorised_value_category ) %]
115
                                            <option value="[% a.authorised_value %]">[% a.lib %]</option>
116
                                        [% END %]
117
                                    </select>
118
                                [% ELSE %]
119
                                    <input type="text" name="club_field" />
120
                                [% END %]
121
                            </li>
122
                        [% END %]
123
                    [% END %]
124
125
                </ol>
126
127
            </fieldset>
128
129
            <input type="submit" class="btn" value="Save" />
130
131
            <a href="clubs.pl" class="cancel">Cancel</a>
132
        </form>
133
    </div>
134
</div>
135
136
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/clubs/clubs.tt (+206 lines)
Line 0 Link Here
1
[% USE EncodeUTF8 %]
2
[% USE Koha %]
3
[% INCLUDE 'doc-head-open.inc' %]
4
<title>Koha &rsaquo; Tools &rsaquo; Patron clubs</title>
5
[% INCLUDE 'doc-head-close.inc' %]
6
7
<link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" />
8
[% INCLUDE 'datatables.inc' %]
9
10
<script type="text/javascript">
11
//<![CDATA[
12
    $(document).ready(function() {
13
        tTable = $('#club-templates-table').dataTable($.extend(true, {}, dataTablesDefaults, {
14
            "aoColumnDefs": [
15
                { "aTargets": [ -1, -2 ], "bSortable": false, "bSearchable": false },
16
            ]
17
        } ));
18
19
        cTable = $('#clubs-table').dataTable($.extend(true, {}, dataTablesDefaults, {
20
            "aoColumnDefs": [
21
                { "aTargets": [ -1, -2 ], "bSortable": false, "bSearchable": false },
22
            ]
23
        } ));
24
    });
25
26
    function ConfirmDeleteTemplate( id, name, a ) {
27
        if ( confirm( _("Are you sure you want to delete the club template") + name + "?" ) ) {
28
            $.ajax({
29
                type: "POST",
30
                url: '/cgi-bin/koha/svc/club/template/delete',
31
                data: { id: id },
32
                success: function( data ) {
33
                    if ( data.success ) {
34
                        tTable.fnDeleteRow(a.closest("tr")[0]);
35
                    } else {
36
                        alert(_("Unable to delete template!"));
37
                    }
38
                },
39
                dataType: 'json'
40
            });
41
        }
42
    }
43
44
    function ConfirmDeleteClub( id, name, a ) {
45
        if ( confirm( _("Are you sure you want to delete the club ") + name + "?" ) ) {
46
            $.ajax({
47
                type: "POST",
48
                url: '/cgi-bin/koha/svc/club/delete',
49
                data: { id: id },
50
                success: function( data ) {
51
                    if ( data.success ) {
52
                        cTable.fnDeleteRow(a.closest("tr")[0]);
53
                    } else {
54
                        alert(_("Unable to delete club!"));
55
                    }
56
                },
57
                dataType: 'json'
58
            });
59
        }
60
    }
61
//]]>
62
</script>
63
64
</head>
65
66
<body>
67
[% INCLUDE 'header.inc' %]
68
[% INCLUDE 'cat-search.inc' %]
69
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> &rsaquo; Patron clubs</div>
70
71
<div class="yui-t7">
72
    <div class="yui-main">
73
        <h1>Patron clubs</h1>
74
75
76
        <h3>Club templates</h3>
77
78
        [% IF CAN_user_clubs_edit_templates %]
79
            <div class="btn-group">
80
                <a class="btn btn-small" href="templates-add-modify.pl"><i class="icon-plus"></i> New club template</a>
81
            </div>
82
        [% END %]
83
84
        <table id="club-templates-table">
85
            <thead>
86
                <tr>
87
                    <th>Name</th>
88
                    <th>Description</th>
89
                    <th>Public enrollment</th>
90
                    <th>Email required</th>
91
                    <th>Branch</th>
92
                    <th>&nbsp;</th>
93
                    <th>&nbsp;</th>
94
                </tr>
95
            </thead>
96
97
            <tbody>
98
                [% FOREACH t IN club_templates %]
99
                    <tr>
100
                        <td>[% t.name | $EncodeUTF8 %]</td>
101
                        <td>[% t.description | $EncodeUTF8 %]</td>
102
                        <td>
103
                            [% IF t.is_enrollable_from_opac %]
104
                                Yes
105
                            [% ELSE %]
106
                                No
107
                            [% END %]
108
                        </td>
109
                        <td>
110
                            [% IF t.is_email_required %]
111
                                Yes
112
                            [% ELSE %]
113
                                No
114
                            [% END %]
115
                        </td>
116
                        <td>[% t.branch.branchname | $EncodeUTF8 %]</td>
117
                        <td>
118
                            [% IF CAN_user_clubs_edit_templates && t.is_deletable && ( CAN_user_superlibrarian || t.branch.branchcode == Koha.UserEnv('branch') ) %]
119
                                <a class="btn btn-mini" href="templates-add-modify.pl?id=[% t.id %]">
120
                                    <i class="icon-edit"></i> Edit
121
                                </a>
122
                            [% END %]
123
                        </td>
124
                        <td>
125
                            [% IF CAN_user_clubs_edit_templates && t.is_deletable && ( CAN_user_superlibrarian || t.branch.branchcode == Koha.UserEnv('branch') ) %]
126
                                <a class="btn btn-mini" href="#" onclick='ConfirmDeleteTemplate([% t.id %], "[% t.name | html %]", $(this) ); return false;'>
127
                                    <i class="icon-trash"></i> Delete
128
                                </a>
129
                            [% END %]
130
                        </td>
131
                    </tr>
132
                [% END %]
133
            </tbody>
134
        </table>
135
136
        <h3>Clubs</h3>
137
138
        [% IF CAN_user_clubs_edit_clubs %]
139
            <div class="btn-group">
140
                <div class="btn-group">
141
                    <button class="btn btn-small dropdown-toggle" data-toggle="dropdown"><i class="icon-plus"></i> New club <span class="caret"></span></button>
142
                    <ul class="dropdown-menu">
143
                        [% FOREACH t IN club_templates %]
144
                            <li><a href="/cgi-bin/koha/clubs/clubs-add-modify.pl?club_template_id=[% t.id %]">[% t.name %]</a></li>
145
                        [% END %]
146
                    </ul>
147
                </div>
148
            </div>
149
        [% END %]
150
151
        <table id="clubs-table">
152
            <thead>
153
                <tr>
154
                    <th>Name</th>
155
                    <th>Template</th>
156
                    <th>Description</th>
157
                    <th>Public enrollment</th>
158
                    <th>Email required</th>
159
                    <th>Branch</th>
160
                    <th>&nbsp;</th>
161
                    <th>&nbsp;</th>
162
                </tr>
163
            </thead>
164
165
            <tbody>
166
                [% FOREACH c IN clubs %]
167
                    <tr>
168
                        <td>[% c.name | $EncodeUTF8 %]</td>
169
                        <td>[% c.club_template.name | $EncodeUTF8 %]</td>
170
                        <td>[% c.description | $EncodeUTF8 %]</td>
171
                        <td>
172
                            [% IF c.club_template.is_enrollable_from_opac %]
173
                                Yes
174
                            [% ELSE %]
175
                                No
176
                            [% END %]
177
                        </td>
178
                        <td>
179
                            [% IF c.club_template.is_email_required %]
180
                                Yes
181
                            [% ELSE %]
182
                                No
183
                            [% END %]
184
                        </td>
185
                        <td>[% c.branch.branchname | $EncodeUTF8 %]</td>
186
                        <td>
187
                            [% IF CAN_user_clubs_edit_clubs && ( CAN_user_superlibrarian || c.branch.branchcode == Koha.UserEnv('branch') ) %]
188
                                <a class="btn btn-mini" href="clubs-add-modify.pl?id=[% c.id %]">
189
                                    <i class="icon-edit"></i> Edit
190
                                </a>
191
                            [% END %]
192
                        </td>
193
                        <td>
194
                            [% IF CAN_user_clubs_edit_clubs && ( CAN_user_superlibrarian || c.branch.branchcode == Koha.UserEnv('branch') ) %]
195
                                <a class="btn btn-mini" href="#" onclick='ConfirmDeleteClub([% c.id %], "[% c.name | html %]", $(this) ); return false;'>
196
                                    <i class="icon-trash"></i> Delete
197
                                </a>
198
                            [% END %]
199
                        </td>
200
                    </tr>
201
                [% END %]
202
            </tbody>
203
        </table>
204
    </div>
205
</div>
206
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/clubs/patron-clubs-tab.tt (+103 lines)
Line 0 Link Here
1
[% USE EncodeUTF8 %]
2
[% USE KohaDates %]
3
4
[% IF enrollments %]
5
    <table>
6
        <thead>
7
            <tr>
8
                <th colspan="4">
9
                    Clubs currently enrolled in
10
                </th>
11
            </tr>
12
            <tr>
13
                <th>Name</th>
14
                <th>Description</th>
15
                <th>Date enrolled</th>
16
                [% IF CAN_user_clubs_enroll %]<th>&nbsp;</th>[% END %]
17
            </tr>
18
        </thead>
19
20
        <tbody>
21
            [% FOREACH e IN enrollments %]
22
                <tr>
23
                    <td>[% e.club.name | $EncodeUTF8 %]</td>
24
                    <td>[% e.club.description | $EncodeUTF8 %]</td>
25
                    <td>[% e.date_enrolled | $KohaDates %]</td>
26
                    [% IF CAN_user_clubs_enroll %]
27
                        <td>
28
                            <a class="btn btn-mini" onclick="cancelEnrollment( [% e.id %] )">
29
                                <i class="icon-remove"></i> Cancel
30
                            </a>
31
                        </td>
32
                    [% END %]
33
                </tr>
34
            [% END %]
35
        </tbody>
36
    </table>
37
[% END %]
38
39
[% IF clubs %]
40
    <table>
41
        <thead>
42
            <tr>
43
                <th colspan="3">
44
                    Clubs not enrolled in
45
                </th>
46
            </tr>
47
            <tr>
48
                <th>Name</th>
49
                <th>Description</th>
50
                [% IF CAN_user_clubs_enroll %]<th>&nbsp;</th>[% END %]
51
            </tr>
52
        </thead>
53
54
        <tbody>
55
            [% FOREACH c IN clubs %]
56
                <tr>
57
                    <td>[% c.name | $EncodeUTF8 %]</td>
58
                    <td>[% c.description | $EncodeUTF8 %]</td>
59
                    [% IF CAN_user_clubs_enroll %]
60
                        <td>
61
                            <a class="btn btn-mini" onclick="loadEnrollmentForm([% c.id %])">
62
                                <i class="icon-plus"></i> Enroll
63
                            </a>
64
                        </td>
65
                    [% END %]
66
                </tr>
67
            [% END %]
68
        </tbody>
69
    </table>
70
[% END %]
71
72
[% IF CAN_user_clubs_enroll %]
73
<script type="text/javascript">
74
function loadEnrollmentForm( id ) {
75
    $("body").css("cursor", "progress");
76
    $('#clubs-tab').load('/cgi-bin/koha/clubs/patron-enroll.pl?borrowernumber=[% borrowernumber %]&id=' + id, function() {
77
        $("body").css("cursor", "default");
78
    });
79
80
    return false;
81
}
82
83
function cancelEnrollment( id ) {
84
    $("body").css("cursor", "progress");
85
    $.ajax({
86
        type: "POST",
87
        url: '/cgi-bin/koha/svc/club/cancel_enrollment',
88
        data: { id: id },
89
        success: function( data ) {
90
            if ( data.success ) {
91
                $('#clubs-tab').load('/cgi-bin/koha/clubs/patron-clubs-tab.pl?borrowernumber=[% borrowernumber %]', function() {
92
                    $("body").css("cursor", "default");
93
                });
94
            } else {
95
                alert(_("Unable to cancel enrollment!"));
96
            }
97
        },
98
        dataType: 'json'
99
    });
100
    return false;
101
}
102
</script>
103
[% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/clubs/patron-enroll.tt (+67 lines)
Line 0 Link Here
1
[% USE EncodeUTF8 %]
2
[% USE AuthorisedValues %]
3
[% SET AuthorisedValuesCategories = AuthorisedValues.Categories %]
4
5
<h3>
6
    Enroll in <i>[% club.name | $EncodeUTF8 %]</i>
7
</h3>
8
9
<div class="container">
10
    <form id="patron-enrollment-form">
11
        <input type="hidden" name="id" value="[% club.id %]" />
12
        <input type="hidden" name="borrowernumber" value="[% borrowernumber %]" />
13
        <fieldset class="rows">
14
            <ol>
15
                [% FOREACH f IN club.club_template.club_template_enrollment_fields %]
16
                    <li>
17
                        <label>[% f.name %]</label>
18
                        [% IF f.authorised_value_category %]
19
                            <select name="[% f.id %]">
20
                                [% FOREACH a IN AuthorisedValues.Get( f.club_template_field.authorised_value_category ) %]
21
                                    <option value="[% a.authorised_value %]">[% a.lib %]</option>
22
                                [% END %]
23
                            </select>
24
                        [% ELSE %]
25
                            <input type="text" name="[% f.id %]" />
26
                        [% END %]
27
                        <span class="hint">[% f.description %]</span>
28
                    </li>
29
                [% END %]
30
31
                <li>
32
                    <a href="#" class="btn" onclick="addEnrollment(); return false;"><i class="icon-plus"></i> Enroll</a>
33
                    <a href="#" onclick="showClubs(); return false;">Cancel</a>
34
                </li>
35
            </ol>
36
        </fieldset>
37
    </form>
38
</div>
39
40
<script type="text/javascript">
41
function addEnrollment() {
42
    $("body").css("cursor", "progress");
43
    $.ajax({
44
        type: "POST",
45
        url: '/cgi-bin/koha/svc/club/enroll',
46
        data: $( "#patron-enrollment-form" ).serialize(),
47
        success: function( data ) {
48
            if ( data.success ) {
49
                $('#clubs-tab').load('/cgi-bin/koha/clubs/patron-clubs-tab.pl?borrowernumber=[% borrowernumber %]&id=[% club.id %]', function() {
50
                    $("body").css("cursor", "default");
51
                });
52
            } else {
53
                alert(_("Unable to create enrollment!"));
54
            }
55
        },
56
        dataType: 'json'
57
    });
58
    return false;
59
}
60
61
function showClubs() {
62
    $("body").css("cursor", "progress");
63
    $('#clubs-tab').load('/cgi-bin/koha/clubs/patron-clubs-tab.pl?borrowernumber=[% borrowernumber %]&id=[% club.id %]', function() {
64
        $("body").css("cursor", "default");
65
    });
66
}
67
</script>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/clubs/templates-add-modify.tt (+252 lines)
Line 0 Link Here
1
[% USE EncodeUTF8 %]
2
[% USE Branches %]
3
[% USE AuthorisedValues %]
4
[% SET AuthorisedValuesCategories = AuthorisedValues.Categories %]
5
[% INCLUDE 'doc-head-open.inc' %]
6
<title>Koha &rsaquo; Tools &rsaquo; Patron clubs &rsaquo; Club template</title>
7
[% INCLUDE 'doc-head-close.inc' %]
8
9
<script type="text/javascript">
10
//<![CDATA[
11
12
function CheckForm() {
13
  if ( !$("#club-template-name").val() ) {
14
    alert( _("Name is a required field!")  );
15
    return false;
16
  }
17
18
  return true;
19
}
20
21
//]]>
22
</script>
23
24
</head>
25
26
<body>
27
[% INCLUDE 'header.inc' %]
28
[% INCLUDE 'cat-search.inc' %]
29
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> &rsaquo; <a href="clubs.pl">Patron clubs</a> &rsaquo; Add / modify club template</div>
30
31
<div class="yui-t7">
32
    <div class="yui-main">
33
34
        <form method="post" onsubmit="return CheckForm()">
35
            <input type="hidden" name="id" value="[% club_template.id %]" />
36
37
            <fieldset class="rows">
38
39
                <legend>
40
                    [% IF club_template %]
41
                        Modify club template <i>[% club_template.name %]</i>
42
                    [% ELSE %]
43
                        Create a new club template
44
                    [% END %]
45
                </legend>
46
47
                <ol>
48
                    <li>
49
                        <label class="required" for="name">Name:</label>
50
                        <input id="club-template-name" name="name" type="text" value="[% club_template.name %]" />
51
                    </li>
52
53
                    <li>
54
                        <label for="description">Description:</label>
55
                        <input id="club-template-description" name="description" type="text" value="[% club_template.description %]" />
56
                    </li>
57
58
                    <li>
59
                        <label for="name">Allow public enrollment:</label>
60
                        [% IF club_template.is_enrollable_from_opac %]
61
                            <input type="checkbox" id="club-template-is-enrollable-from-opac" name="is_enrollable_from_opac" checked="checked" />
62
                        [% ELSE %]
63
                            <input type="checkbox" id="club-template-is-enrollable-from-opac" name="is_enrollable_from_opac" />
64
                        [% END %]
65
                        <span class="hint">If a template allows public enrollment, patrons can enroll in a club based on this template from the public catalog.</span>
66
                    </li>
67
68
                    <li>
69
                        <label for="name">Require valid email address:</label>
70
                        [% IF club_template.is_email_required %]
71
                            <input type="checkbox" id="club-template-is-email-required" name="is_email_required" checked="checked" />
72
                        [% ELSE %]
73
                            <input type="checkbox" id="club-template-is-email-required" name="is_email_required" />
74
                        [% END %]
75
                        <span class="hint">If set, a club based on this template can only be enrolled in by patrons with a valid email address.</span>
76
                    </li>
77
78
                    <li>
79
                        <label for="name">Branch:</label>
80
                        <select name="branchcode" id="club-template-branchcode">
81
                            <option value="">&nbsp</option>
82
                            [% FOREACH b IN Branches.GetBranches() %]
83
                                [% IF b.branchcode == club_template.branch.branchcode %]
84
                                    <option value="[% b.branchcode %]" selected="selected">[% b.branchname | $EncodeUTF8 %]</option>
85
                                [% ELSE %]
86
                                    <option value="[% b.branchcode %]">[% b.branchname | $EncodeUTF8 %]</option>
87
                                [% END %]
88
                            [% END %]
89
                        </select>
90
                        <span class="hint">If set, only librarians logged in with this branch will be able to modify this club template.</span>
91
                    </li>
92
93
                </ol>
94
95
                <h2>Club fields:</h2>
96
                <span class="hint">These fields will be used in the creation of clubs based on this template</span>
97
                <span id="club-template-fields">
98
                    [% FOREACH f IN club_template.club_template_fields %]
99
                        <ul>
100
                            <input type="hidden" name="club_template_field_id" value="[% f.id %]" />
101
                            <li>
102
                                <label for="field-name-[% f.id %]">Name:</label>
103
                                <input name="club_template_field_name" id="field-name-[% f.id %]" value="[% f.name %]" />
104
                            </li>
105
106
                            <li>
107
                                <label for="field-description-[% f.id %]">Description:</label>
108
                                <input name="club_template_field_description" id="field-description-[% f.id %]" value="[% f.description %]" />
109
                            </li>
110
111
                            <li>
112
                                <label for="field-description-[% f.id %]">Authorised value category:</label>
113
                                <select name="club_template_field_authorised_value_category" id="field-authorised-value-category-[% f.id %]">
114
                                    <option value="">&nbsp;</option>
115
                                    [% FOREACH c IN AuthorisedValuesCategories %]
116
                                        [% IF f.authorised_value_category == c %]
117
                                            <option selected="selected" value="[% c %]">[% c %]</option>
118
                                        [% ELSE %]
119
                                            <option value="[% c %]">[% c %]</option>
120
                                        [% END %]
121
                                    [% END %]
122
                                </select>
123
                            </li>
124
125
                            <li>
126
                                <label for="field-delete-[% f.id %]">Delete field:</label>
127
                                <input type="checkbox" name="club_template_field_delete" id="field-delete-[% f.id %]" value="[% f.id %]" />
128
                            </li>
129
130
                            <hr/>
131
                        </ul>
132
                    [% END %]
133
                </span>
134
                <a href="#" class="btn" onclick="$('#new-field-template').clone().attr('id','').show().appendTo('#club-template-fields'); return false;">
135
                    Add new field
136
                </a>
137
138
                <h2>Enrollment fields:</h2>
139
                <span class="hint">These fields will be used when enrolling a patron in a club based on this template</span>
140
                <span id="club-template-enrollment-fields">
141
                    [% FOREACH f IN club_template.club_template_enrollment_fields %]
142
                        <ul>
143
                            <input type="hidden" name="club_template_enrollment_field_id" value="[% f.id %]" />
144
                            <li>
145
                                <label for="enrollment-field-name-[% f.id %]">Name:</label>
146
                                <input name="club_template_enrollment_field_name" id="enrollment-field-name-[% f.id %]" value="[% f.name %]" />
147
                            </li>
148
149
                            <li>
150
                                <label for="enrollment-field-description-[% f.id %]">Description:</label>
151
                                <input name="club_template_enrollment_field_description" id="enrollment-field-description-[% f.id %]" value="[% f.description %]" />
152
                            </li>
153
154
                            <li>
155
                                <label for="enrollment-field-description-[% f.id %]">Authorised value category:</label>
156
                                <select name="club_template_enrollment_field_authorised_value_category" id="enrollment-field-authorised-value-category-[% f.id %]">
157
                                    <option value="">&nbsp;</option>
158
                                    [% FOREACH c IN AuthorisedValuesCategories %]
159
                                        [% IF f.authorised_value_category == c %]
160
                                            <option selected="selected" value="[% c %]">[% c %]</option>
161
                                        [% ELSE %]
162
                                            <option value="[% c %]">[% c %]</option>
163
                                        [% END %]
164
                                    [% END %]
165
                                </select>
166
                            </li>
167
168
                            <li>
169
                                <label for="enrollment-field-delete-[% f.id %]">Delete field:</label>
170
                                <input type="checkbox" name="club_template_enrollment_field_delete" id="enrollment-field-delete-[% f.id %]" value="[% f.id %]" />
171
                            </li>
172
173
                            <hr/>
174
                        </ul>
175
                    [% END %]
176
                </span>
177
                <a href="#" class="btn" onclick="$('#new-enrollment-field-template').clone().attr('id','').show().appendTo('#club-template-enrollment-fields'); return false;">
178
                    Add new field
179
                </a>
180
181
            </fieldset>
182
183
            <input type="hidden" name="id" value="[% club_template.id %]" />
184
185
            <input type="submit" class="btn" value="Save" />
186
187
            <a href="clubs.pl" class="cancel">Cancel</a>
188
        </form>
189
    </div>
190
</div>
191
192
<span id="new-field-template" style="display:none">
193
    <ul>
194
        <input type="hidden" name="club_template_field_id" value="" />
195
196
        <li>
197
            <label for="club_template_field_name">Name:</label>
198
            <input name="club_template_field_name" />
199
        </li>
200
201
        <li>
202
            <label for="club_template_field_description">Description:</label>
203
            <input name="club_template_field_description" />
204
        </li>
205
206
        <li>
207
            <label for="club_template_field_authorised_value_category">Authorised value category:</label>
208
            <select name="club_template_field_authorised_value_category">
209
                <option value="">&nbsp;</option>
210
                [% FOREACH c IN AuthorisedValuesCategories %]
211
                    <option value="[% c %]">[% c %]</option>
212
                [% END %]
213
            </select>
214
        </li>
215
216
        <a href="#" onclick="$(this).parent().remove(); return false;">Cancel</a>
217
218
        <hr/>
219
    </ul>
220
</span>
221
222
<span id="new-enrollment-field-template" style="display:none">
223
    <ul>
224
        <input type="hidden" name="club_template_enrollment_field_id" value="" />
225
226
        <li>
227
            <label for="club_template_enrollment_field_name">Name:</label>
228
            <input name="club_template_enrollment_field_name" />
229
        </li>
230
231
        <li>
232
            <label for="club_template_enrollment_field_description">Description:</label>
233
            <input name="club_template_enrollment_field_description" />
234
        </li>
235
236
        <li>
237
            <label for="club_template_enrollment_field_authorised_value_category">Authorised value category:</label>
238
            <select name="club_template_enrollment_field_authorised_value_category">
239
                <option value="">&nbsp;</option>
240
                [% FOREACH c IN AuthorisedValuesCategories %]
241
                    <option value="[% c %]">[% c %]</option>
242
                [% END %]
243
            </select>
244
        </li>
245
246
        <a href="#" onclick="$(this).parent().remove(); return false;">Cancel</a>
247
248
        <hr/>
249
    </ul>
250
</span>
251
252
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt (+16 lines)
Lines 17-22 Link Here
17
<script type="text/JavaScript">
17
<script type="text/JavaScript">
18
//<![CDATA[
18
//<![CDATA[
19
$(document).ready(function() {
19
$(document).ready(function() {
20
    $('#clubs-tab-link').on('click', function() {
21
        $('#clubs-tab').text(_("Loading..."));
22
        $('#clubs-tab').load('/cgi-bin/koha/clubs/patron-clubs-tab.pl?borrowernumber=[% borrowernumber %]');
23
    });
24
20
    $('#finesholdsissues').tabs({
25
    $('#finesholdsissues').tabs({
21
        // Correct table sizing for tables hidden in tabs
26
        // Correct table sizing for tables hidden in tabs
22
        // http://www.datatables.net/examples/api/tabs_and_scrolling.html
27
        // http://www.datatables.net/examples/api/tabs_and_scrolling.html
Lines 434-439 function validate1(date) { Link Here
434
            <a href="#onhold">0 Holds</a>
439
            <a href="#onhold">0 Holds</a>
435
    [% END %]</li>
440
    [% END %]</li>
436
        <li><a id="debarments-tab-link" href="#reldebarments">[% debarments.size %] Restrictions</a></li>
441
        <li><a id="debarments-tab-link" href="#reldebarments">[% debarments.size %] Restrictions</a></li>
442
        [% IF CAN_user_clubs && ( borrower.ClubsEnrolledCount || borrower.ClubsEnrollableCount ) %]
443
            <li>
444
                <a id="clubs-tab-link" href="#clubs-tab">
445
                    Clubs ([% borrower.ClubsEnrolledCount %]/[% borrower.ClubsEnrollableCount %])
446
                </a>
447
            </li>
448
        [% END %]
437
    </ul>
449
    </ul>
438
450
439
    <form action="/cgi-bin/koha/reserve/renewscript.pl" method="post" class="checkboxed">
451
    <form action="/cgi-bin/koha/reserve/renewscript.pl" method="post" class="checkboxed">
Lines 617-622 function validate1(date) { Link Here
617
    [% END %]
629
    [% END %]
618
</div>
630
</div>
619
631
632
<div id="clubs-tab">
633
    Loading...
634
</div>
635
620
[% INCLUDE borrower_debarments.inc %]
636
[% INCLUDE borrower_debarments.inc %]
621
637
622
<div id="onhold">
638
<div id="onhold">
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/tools-home.tt (+5 lines)
Lines 15-20 Link Here
15
<div class="yui-u first">
15
<div class="yui-u first">
16
<h3>Patrons and circulation</h3>
16
<h3>Patrons and circulation</h3>
17
<dl>
17
<dl>
18
    [% IF CAN_user_clubs_edit_clubs || CAN_user_clubs_edit_templates %]
19
    <dt><a href="/cgi-bin/koha/clubs/clubs.pl">Patron clubs</a>
20
    <dd>Manage patrons clubs.</dd>
21
    [% END %]
22
18
    [% IF (CAN_user_tools_manage_patron_lists) %]
23
    [% IF (CAN_user_tools_manage_patron_lists) %]
19
    <dt><a href="/cgi-bin/koha/patron_lists/lists.pl">Patron lists</a>
24
    <dt><a href="/cgi-bin/koha/patron_lists/lists.pl">Patron lists</a>
20
    <dd>Manage lists of patrons.</dd>
25
    <dd>Manage lists of patrons.</dd>
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/clubs/clubs-tab.tt (+103 lines)
Line 0 Link Here
1
[% USE EncodeUTF8 %]
2
[% USE KohaDates %]
3
4
[% IF enrollments %]
5
    <table id="clubs-table-enrolled" class="table table-bordered table-striped">
6
        <thead>
7
            <tr>
8
                <th colspan="4">
9
                    Clubs you are currently enrolled in
10
                </th>
11
            </tr>
12
            <tr>
13
                <th>Name</th>
14
                <th>Description</th>
15
                <th>Date enrolled</th>
16
                <th>&nbsp;</th>
17
            </tr>
18
        </thead>
19
20
        <tbody>
21
            [% FOREACH e IN enrollments %]
22
                <tr>
23
                    <td>[% e.club.name | $EncodeUTF8 %]</td>
24
                    <td>[% e.club.description | $EncodeUTF8 %]</td>
25
                    <td>[% e.date_enrolled | $KohaDates %]</td>
26
                    [% IF e.club.club_template.is_enrollable_from_opac %]
27
                        <td>
28
                            <a class="btn btn-mini" onclick="cancelEnrollment( [% e.id %] )">
29
                                <i class="icon-remove"></i> Cancel
30
                            </a>
31
                        </td>
32
                    [% END %]
33
                </tr>
34
            [% END %]
35
        </tbody>
36
    </table>
37
[% END %]
38
39
[% IF clubs %]
40
    <table id="clubs-table-unenrolled" class="table table-bordered table-striped">
41
        <thead>
42
            <tr>
43
                <th colspan="3">
44
                    Clubs you can enroll in
45
                </th>
46
            </tr>
47
            <tr>
48
                <th>Name</th>
49
                <th>Description</th>
50
                <th>&nbsp;</th>
51
            </tr>
52
        </thead>
53
54
        <tbody>
55
            [% FOREACH c IN clubs %]
56
                <tr>
57
                    <td>[% c.name | $EncodeUTF8 %]</td>
58
                    <td>[% c.description | $EncodeUTF8 %]</td>
59
                    <td>
60
                        [% IF borrower.FirstValidEmailAddress %]
61
                            <a class="btn btn-mini" onclick="loadEnrollmentForm([% c.id %])">
62
                                <i class="icon-plus"></i> Enroll
63
                            </a>
64
                        [% ELSE %]
65
                            <span class="hint">You must have an email address to enroll</span>
66
                        [% END %]
67
                    </td>
68
                </tr>
69
            [% END %]
70
        </tbody>
71
    </table>
72
[% END %]
73
74
<script type="text/javascript">
75
function loadEnrollmentForm( id ) {
76
    $("body").css("cursor", "progress");
77
    $('#opac-user-clubs').load('/cgi-bin/koha/clubs/enroll.pl?borrowernumber=[% borrower.borrowernumber %]&id=' + id, function() {
78
        $("body").css("cursor", "default");
79
    });
80
81
    return false;
82
}
83
84
function cancelEnrollment( id ) {
85
    $("body").css("cursor", "progress");
86
    $.ajax({
87
        type: "POST",
88
        url: '/cgi-bin/koha/svc/club/cancel_enrollment',
89
        data: { id: id },
90
        success: function( data ) {
91
            if ( data.success ) {
92
                $('#opac-user-clubs').load('/cgi-bin/koha/clubs/clubs-tab.pl?borrowernumber=[% borrower.borrowernumber %]', function() {
93
                    $("body").css("cursor", "default");
94
                });
95
            } else {
96
                alert(_("Unable to cancel enrollment!"));
97
            }
98
        },
99
        dataType: 'json'
100
    });
101
    return false;
102
}
103
</script>
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/clubs/enroll.tt (+67 lines)
Line 0 Link Here
1
[% USE EncodeUTF8 %]
2
[% USE AuthorisedValues %]
3
[% SET AuthorisedValuesCategories = AuthorisedValues.Categories %]
4
5
<h3>
6
    Enroll in <i>[% club.name | $EncodeUTF8 %]</i>
7
</h3>
8
9
<div class="container">
10
    <form id="patron-enrollment-form">
11
        <input type="hidden" name="id" value="[% club.id %]" />
12
        <input type="hidden" name="borrowernumber" value="[% borrowernumber %]" />
13
        <fieldset class="rows">
14
            <ol>
15
                [% FOREACH f IN club.club_template.club_template_enrollment_fields %]
16
                    <li>
17
                        <label>[% f.name %]</label>
18
                        [% IF f.authorised_value_category %]
19
                            <select name="[% f.id %]">
20
                                [% FOREACH a IN AuthorisedValues.Get( f.club_template_field.authorised_value_category ) %]
21
                                    <option value="[% a.authorised_value %]">[% a.lib %]</option>
22
                                [% END %]
23
                            </select>
24
                        [% ELSE %]
25
                            <input type="text" name="[% f.id %]" />
26
                        [% END %]
27
                        <span class="hint">[% f.description %]</span>
28
                    </li>
29
                [% END %]
30
31
                <li>
32
                    <a href="#" class="btn" onclick="addEnrollment(); return false;"><i class="icon-plus"></i> Enroll</a>
33
                    <a href="#" onclick="showClubs(); return false;">Cancel</a>
34
                </li>
35
            </ol>
36
        </fieldset>
37
    </form>
38
</div>
39
40
<script type="text/javascript">
41
function addEnrollment() {
42
    $("body").css("cursor", "progress");
43
    $.ajax({
44
        type: "POST",
45
        url: '/cgi-bin/koha/svc/club/enroll',
46
        data: $( "#patron-enrollment-form" ).serialize(),
47
        success: function( data ) {
48
            if ( data.success ) {
49
                $('#opac-user-clubs').load('/cgi-bin/koha/clubs/clubs-tab.pl?borrowernumber=[% borrowernumber %]&id=[% club.id %]', function() {
50
                    $("body").css("cursor", "default");
51
                });
52
            } else {
53
                alert(_("Unable to create enrollment!"));
54
            }
55
        },
56
        dataType: 'json'
57
    });
58
    return false;
59
}
60
61
function showClubs() {
62
    $("body").css("cursor", "progress");
63
    $('#opac-user-clubs').load('/cgi-bin/koha/clubs/clubs-tab.pl?borrowernumber=[% borrowernumber %]&id=[% club.id %]', function() {
64
        $("body").css("cursor", "default");
65
    });
66
}
67
</script>
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt (+17 lines)
Lines 111-116 Link Here
111
                                [% IF ( BORROWER_INF.amountlessthanzero ) %]<li><a href="#opac-user-fines">Credits ([% BORROWER_INF.amountoutstanding %])</a></li>[% END %]
111
                                [% IF ( BORROWER_INF.amountlessthanzero ) %]<li><a href="#opac-user-fines">Credits ([% BORROWER_INF.amountoutstanding %])</a></li>[% END %]
112
                            [% END %]
112
                            [% END %]
113
                            [% IF ( waiting_count ) %][% IF ( BORROWER_INF.atdestination ) %]<li><a href="#opac-user-waiting">Waiting ([% waiting_count %])</a></li>[% END %][% END %]
113
                            [% IF ( waiting_count ) %][% IF ( BORROWER_INF.atdestination ) %]<li><a href="#opac-user-waiting">Waiting ([% waiting_count %])</a></li>[% END %][% END %]
114
                            [% IF borrower.ClubsEnrolledCount || borrower.ClubsEnrollableCount %]
115
                                <li>
116
                                    <a id="opac-user-clubs-tab-link" href="#opac-user-clubs">
117
                                        Clubs ([% borrower.ClubsEnrolledCount %]/[% borrower.ClubsEnrollableCount %])
118
                                    </a>
119
                                </li>
120
                            [% END %]
121
114
                            [% IF ( reserves_count ) %]<li><a href="#opac-user-holds">Holds ([% reserves_count %])</a></li>[% END %]
122
                            [% IF ( reserves_count ) %]<li><a href="#opac-user-holds">Holds ([% reserves_count %])</a></li>[% END %]
115
                        </ul>
123
                        </ul>
116
124
Lines 276-281 Link Here
276
                            [% END # IF issues_count %]
284
                            [% END # IF issues_count %]
277
                        </div> <!-- / .opac-user-checkouts -->
285
                        </div> <!-- / .opac-user-checkouts -->
278
286
287
                        <div id="opac-user-clubs">
288
                            Loading...
289
                        </div>
290
279
                        [% IF ( OPACFinesTab ) %]
291
                        [% IF ( OPACFinesTab ) %]
280
                            <!-- FINES BOX -->
292
                            <!-- FINES BOX -->
281
                            [% IF ( BORROWER_INF.amountoverfive ) %]
293
                            [% IF ( BORROWER_INF.amountoverfive ) %]
Lines 723-728 Link Here
723
            [% END %]
735
            [% END %]
724
736
725
            $( ".suspend-until" ).datepicker({ minDate: 1 }); // Require that "until date" be in the future
737
            $( ".suspend-until" ).datepicker({ minDate: 1 }); // Require that "until date" be in the future
738
739
            $('#opac-user-clubs-tab-link').on('click', function() {
740
                $('#opac-user-clubs').text(_("Loading..."));
741
                $('#opac-user-clubs').load('/cgi-bin/koha/clubs/clubs-tab.pl?borrowernumber=[% borrowernumber %]');
742
            });
726
        });
743
        });
727
        //]]>
744
        //]]>
728
    </script>
745
    </script>
(-)a/members/moremember.pl (+3 lines)
Lines 419-424 if (C4::Context->preference('EnhancedMessagingPreferences')) { Link Here
419
    $template->param(TalkingTechItivaPhone => C4::Context->preference("TalkingTechItivaPhoneNotification"));
419
    $template->param(TalkingTechItivaPhone => C4::Context->preference("TalkingTechItivaPhoneNotification"));
420
}
420
}
421
421
422
my $schema =  Koha::Database->new()->schema();
423
422
# in template <TMPL_IF name="I"> => instutitional (A for Adult, C for children) 
424
# in template <TMPL_IF name="I"> => instutitional (A for Adult, C for children) 
423
$template->param( $data->{'categorycode'} => 1 ); 
425
$template->param( $data->{'categorycode'} => 1 ); 
424
$template->param(
426
$template->param(
Lines 449-454 $template->param( Link Here
449
    SuspendHoldsIntranet => C4::Context->preference('SuspendHoldsIntranet'),
451
    SuspendHoldsIntranet => C4::Context->preference('SuspendHoldsIntranet'),
450
    RoutingSerials => C4::Context->preference('RoutingSerials'),
452
    RoutingSerials => C4::Context->preference('RoutingSerials'),
451
    debarments => GetDebarments({ borrowernumber => $borrowernumber }),
453
    debarments => GetDebarments({ borrowernumber => $borrowernumber }),
454
    borrower => $schema->resultset('Borrower')->find( $borrowernumber ),
452
);
455
);
453
$template->param( $error => 1 ) if $error;
456
$template->param( $error => 1 ) if $error;
454
457
(-)a/opac/clubs/clubs-tab.pl (+67 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Copyright 2013 ByWater Solutions
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it
8
# under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
11
#
12
# Koha is distributed in the hope that it will be useful, but
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
20
use Modern::Perl;
21
22
use CGI;
23
24
use C4::Auth;
25
use C4::Output;
26
use Koha::Database;
27
28
my $cgi = new CGI;
29
30
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
31
    {
32
        template_name   => "clubs/clubs-tab.tt",
33
        query           => $cgi,
34
        type            => "opac",
35
        authnotrequired => 0,
36
    }
37
);
38
39
my $borrowernumber = $cgi->param('borrowernumber');
40
41
my $schema = Koha::Database->new()->schema();
42
43
my $borrower = $schema->resultset('Borrower')->find($borrowernumber);
44
45
my @enrollments = $schema->resultset("ClubEnrollment")->search(
46
    {
47
        borrower      => $borrowernumber,
48
        date_canceled => undef,
49
    },
50
    { prefetch => 'club' }
51
);
52
53
my @clubs = $schema->resultset("Club")->search(
54
    {
55
        'me.id' => { -not_in => [ map { $_->club()->id() } @enrollments ] },
56
        'club_template.is_enrollable_from_opac' => 1,
57
    },
58
    { prefetch => 'club_template' }
59
);
60
61
$template->param(
62
    enrollments => \@enrollments,
63
    clubs       => \@clubs,
64
    borrower    => $borrower,
65
);
66
67
output_html_with_http_headers( $cgi, $cookie, $template->output );
(-)a/opac/clubs/enroll.pl (+51 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Copyright 2013 ByWater Solutions
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it
8
# under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
11
#
12
# Koha is distributed in the hope that it will be useful, but
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
20
use Modern::Perl;
21
22
use CGI;
23
24
use C4::Auth;
25
use C4::Output;
26
use Koha::Database;
27
28
my $cgi = new CGI;
29
30
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
31
    {
32
        template_name   => "clubs/enroll.tt",
33
        query           => $cgi,
34
        type            => "opac",
35
        authnotrequired => 0,
36
    }
37
);
38
39
my $id             = $cgi->param('id');
40
my $borrowernumber = $cgi->param('borrowernumber');
41
42
my $schema = Koha::Database->new()->schema();
43
44
my $club = $schema->resultset("Club")->find($id);
45
46
$template->param(
47
    club           => $club,
48
    borrowernumber => $borrowernumber,
49
);
50
51
output_html_with_http_headers( $cgi, $cookie, $template->output );
(-)a/opac/opac-user.pl (-3 / +4 lines)
Lines 35-40 use C4::Items; Link Here
35
use C4::Letters;
35
use C4::Letters;
36
use C4::Branch; # GetBranches
36
use C4::Branch; # GetBranches
37
use Koha::DateUtils;
37
use Koha::DateUtils;
38
use Koha::Database;
39
40
my $schema = Koha::Database->new()->schema();
38
41
39
use constant ATTRIBUTE_SHOW_BARCODE => 'SHOW_BCODE';
42
use constant ATTRIBUTE_SHOW_BARCODE => 'SHOW_BCODE';
40
43
Lines 379-390 $template->param( Link Here
379
    patronupdate => $patronupdate,
382
    patronupdate => $patronupdate,
380
    OpacRenewalAllowed => C4::Context->preference("OpacRenewalAllowed"),
383
    OpacRenewalAllowed => C4::Context->preference("OpacRenewalAllowed"),
381
    userview => 1,
384
    userview => 1,
382
);
383
384
$template->param(
385
    SuspendHoldsOpac => C4::Context->preference('SuspendHoldsOpac'),
385
    SuspendHoldsOpac => C4::Context->preference('SuspendHoldsOpac'),
386
    AutoResumeSuspendedHolds => C4::Context->preference('AutoResumeSuspendedHolds'),
386
    AutoResumeSuspendedHolds => C4::Context->preference('AutoResumeSuspendedHolds'),
387
    OpacHoldNotes => C4::Context->preference('OpacHoldNotes'),
387
    OpacHoldNotes => C4::Context->preference('OpacHoldNotes'),
388
    borrower => $schema->resultset('Borrower')->find($borrowernumber),
388
);
389
);
389
390
390
output_html_with_http_headers $query, $cookie, $template->output;
391
output_html_with_http_headers $query, $cookie, $template->output;
(-)a/opac/svc/club/cancel_enrollment (+52 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Copyright 2014 ByWater Solutions
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 2 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
#
20
21
use Modern::Perl;
22
23
use CGI;
24
use JSON qw(to_json);
25
26
use C4::Auth qw(check_cookie_auth);
27
use Koha::Database;
28
29
my $cgi = new CGI;
30
31
my ( $auth_status, $sessionID ) =
32
  check_cookie_auth( $cgi->cookie('CGISESSID') );
33
if ( $auth_status ne "ok" ) {
34
    exit 0;
35
}
36
37
my $borrowernumber = C4::Context->userenv->{'number'};
38
39
my $id = $cgi->param('id');
40
41
my $schema = Koha::Database->new()->schema();
42
43
my $enrollment = $schema->resultset('ClubEnrollment')->find($id);
44
45
if ( $enrollment && $enrollment->get_column('borrower') == $borrowernumber ) {
46
    $enrollment->update( { date_canceled => \'NOW()' } );
47
}
48
49
binmode STDOUT, ':encoding(UTF-8)';
50
print $cgi->header( -type => 'text/plain', -charset => 'UTF-8' );
51
52
print to_json( { success => $enrollment ? 1 : 0 } );
(-)a/opac/svc/club/enroll (+79 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Copyright 2014 ByWater Solutions
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 2 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
#
20
21
use Modern::Perl;
22
23
use CGI;
24
use JSON qw(to_json);
25
26
use C4::Auth qw(check_cookie_auth);
27
use Koha::Database;
28
29
my $cgi = new CGI;
30
31
my ( $auth_status, $sessionID ) =
32
  check_cookie_auth( $cgi->cookie('CGISESSID') );
33
if ( $auth_status ne "ok" ) {
34
    exit 0;
35
}
36
37
my $borrowernumber = C4::Context->userenv->{'number'};
38
39
my $id = $cgi->param('id');
40
41
my $enrollment;
42
if ( $borrowernumber && $id ) {
43
    my $schema = Koha::Database->new()->schema();
44
45
    my $club = $schema->resultset('Club')->find($id);
46
47
    if ( $club->club_template()->is_enrollable_from_opac() ) {
48
        $enrollment = $schema->resultset('ClubEnrollment')->create(
49
            {
50
                club          => $club->id(),
51
                borrower      => $borrowernumber,
52
                date_enrolled => \'NOW()',
53
                date_created  => \'NOW()',
54
                branch        => C4::Context->userenv
55
                ? C4::Context->userenv->{'branch'}
56
                : undef,
57
            }
58
        );
59
60
        my @enrollment_fields =
61
          $club->club_template()->club_template_enrollment_fields();
62
63
        foreach my $e (@enrollment_fields) {
64
            my $club_enrollment_field =
65
              $schema->resultset('ClubEnrollmentField')->create(
66
                {
67
                    club_enrollment                => $enrollment->id(),
68
                    club_template_enrollment_field => $e->id(),
69
                    value                          => $cgi->param( $e->id() ),
70
                }
71
              );
72
        }
73
    }
74
}
75
76
binmode STDOUT, ':encoding(UTF-8)';
77
print $cgi->header( -type => 'text/plain', -charset => 'UTF-8' );
78
79
print to_json( { success => $enrollment ? 1 : 0 } );
(-)a/svc/club/cancel_enrollment (+48 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Copyright 2014 ByWater Solutions
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 2 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
#
20
21
use Modern::Perl;
22
23
use CGI;
24
use JSON qw(to_json);
25
26
use C4::Auth qw(check_cookie_auth);
27
use Koha::Database;
28
29
my $cgi = new CGI;
30
31
my ( $auth_status, $sessionID ) =
32
  check_cookie_auth( $cgi->cookie('CGISESSID'), { clubs => 'enroll' } );
33
if ( $auth_status ne "ok" ) {
34
    exit 0;
35
}
36
37
my $id = $cgi->param('id');
38
39
my $schema = Koha::Database->new()->schema();
40
41
my $enrollment =
42
  $schema->resultset('ClubEnrollment')->find($id)
43
  ->update( { date_canceled => \'NOW()' } );
44
45
binmode STDOUT, ':encoding(UTF-8)';
46
print $cgi->header( -type => 'text/plain', -charset => 'UTF-8' );
47
48
print to_json( { success => $enrollment ? 1 : 0 } );
(-)a/svc/club/delete (+50 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Copyright 2014 ByWater Solutions
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 2 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
#
20
21
use Modern::Perl;
22
23
use CGI;
24
use JSON qw(to_json);
25
26
use C4::Auth qw(check_cookie_auth);
27
use Koha::Database;
28
29
my $cgi = new CGI;
30
31
my ( $auth_status, $sessionID ) = check_cookie_auth( $cgi->cookie('CGISESSID'),
32
    { clubs => 'edit_clubs' } );
33
if ( $auth_status ne "ok" ) {
34
    exit 0;
35
}
36
37
my $success = 0;
38
39
my $id = $cgi->param('id');
40
41
my $club =
42
  Koha::Database->new()->schema()->resultset('Club')->find($id);
43
if ($club) {
44
    $success = $club->delete();
45
}
46
47
binmode STDOUT, ':encoding(UTF-8)';
48
print $cgi->header( -type => 'text/plain', -charset => 'UTF-8' );
49
50
print to_json( { success => $success ? 1 : 0 } );
(-)a/svc/club/enroll (+78 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Copyright 2014 ByWater Solutions
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 2 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
#
20
21
use Modern::Perl;
22
23
use CGI;
24
use JSON qw(to_json);
25
26
use C4::Auth qw(check_cookie_auth);
27
use Koha::Database;
28
29
my $cgi = new CGI;
30
31
my ( $auth_status, $sessionID ) =
32
  check_cookie_auth( $cgi->cookie('CGISESSID'), { clubs => 'enroll' } );
33
if ( $auth_status ne "ok" ) {
34
    exit 0;
35
}
36
37
my $id             = $cgi->param('id');
38
my $borrowernumber = $cgi->param('borrowernumber');
39
40
my $schema = Koha::Database->new()->schema();
41
42
my $club = $schema->resultset('Club')->find($id);
43
44
my $enrollment;
45
if ($club) {
46
    $enrollment = $schema->resultset('ClubEnrollment')->create(
47
        {
48
            club          => $club->id(),
49
            borrower      => $borrowernumber,
50
            date_enrolled => \'NOW()',
51
            date_created  => \'NOW()',
52
            branch        => C4::Context->userenv
53
            ? C4::Context->userenv->{'branch'}
54
            : undef,
55
        }
56
    );
57
58
    if ($enrollment) {
59
        my @enrollment_fields =
60
          $club->club_template()->club_template_enrollment_fields();
61
62
        foreach my $e (@enrollment_fields) {
63
            my $club_enrollment_field =
64
              $schema->resultset('ClubEnrollmentField')->create(
65
                {
66
                    club_enrollment                => $enrollment->id(),
67
                    club_template_enrollment_field => $e->id(),
68
                    value                          => $cgi->param( $e->id() ),
69
                }
70
              );
71
        }
72
    }
73
}
74
75
binmode STDOUT, ':encoding(UTF-8)';
76
print $cgi->header( -type => 'text/plain', -charset => 'UTF-8' );
77
78
print to_json( { success => $enrollment ? 1 : 0 } );
(-)a/svc/club/template/delete (-1 / +50 lines)
Line 0 Link Here
0
- 
1
#!/usr/bin/perl
2
3
# Copyright 2014 ByWater Solutions
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 2 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
#
20
21
use Modern::Perl;
22
23
use CGI;
24
use JSON qw(to_json);
25
26
use C4::Auth qw(check_cookie_auth);
27
use Koha::Database;
28
29
my $cgi = new CGI;
30
31
my ( $auth_status, $sessionID ) = check_cookie_auth( $cgi->cookie('CGISESSID'),
32
    { clubs => 'edit_templates' } );
33
if ( $auth_status ne "ok" ) {
34
    exit 0;
35
}
36
37
my $success = 0;
38
39
my $id = $cgi->param('id');
40
41
my $club_template =
42
  Koha::Database->new()->schema()->resultset('ClubTemplate')->find($id);
43
if ($club_template) {
44
    $success = $club_template->delete();
45
}
46
47
binmode STDOUT, ':encoding(UTF-8)';
48
print $cgi->header( -type => 'text/plain', -charset => 'UTF-8' );
49
50
print to_json( { success => $success ? 1 : 0 } );

Return to bug 12461