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

(-)a/C4/Members.pm (-13 / +3 lines)
Lines 1473-1492 addresses. Link Here
1473
1473
1474
sub GetFirstValidEmailAddress {
1474
sub GetFirstValidEmailAddress {
1475
    my $borrowernumber = shift;
1475
    my $borrowernumber = shift;
1476
    my $dbh = C4::Context->dbh;
1477
    my $sth = $dbh->prepare( "SELECT email, emailpro, B_email FROM borrowers where borrowernumber = ? ");
1478
    $sth->execute( $borrowernumber );
1479
    my $data = $sth->fetchrow_hashref;
1480
1476
1481
    if ($data->{'email'}) {
1477
    my $borrower = Koha::Database->new()->schema()->resultset('Borrower')->find( $borrowernumber );
1482
       return $data->{'email'};
1478
1483
    } elsif ($data->{'emailpro'}) {
1479
    return $borrower->FirstValidEmailAddress();
1484
       return $data->{'emailpro'};
1485
    } elsif ($data->{'B_email'}) {
1486
       return $data->{'B_email'};
1487
    } else {
1488
       return '';
1489
    }
1490
}
1480
}
1491
1481
1492
=head2 GetNoticeEmailAddress
1482
=head2 GetNoticeEmailAddress
(-)a/Koha/Schema/Result/Borrower.pm (-110 / +550 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
758
759
Type: has_many
760
761
Related object: L<Koha::Schema::Result::BorrowerMessagePreference>
762
763
=cut
764
765
__PACKAGE__->has_many(
766
  "borrower_message_preferences_borrowernumbers",
767
  "Koha::Schema::Result::BorrowerMessagePreference",
768
  { "foreign.borrowernumber" => "self.borrowernumber" },
769
  { cascade_copy => 0, cascade_delete => 0 },
770
);
771
772
=head2 borrower_message_preferences_borrowernumbers
685
773
686
Type: has_many
774
Type: has_many
687
775
Lines 690-701 Related object: L<Koha::Schema::Result::BorrowerMessagePreference> Link Here
690
=cut
778
=cut
691
779
692
__PACKAGE__->has_many(
780
__PACKAGE__->has_many(
693
  "borrower_message_preferences",
781
  "borrower_message_preferences_borrowernumbers",
694
  "Koha::Schema::Result::BorrowerMessagePreference",
782
  "Koha::Schema::Result::BorrowerMessagePreference",
695
  { "foreign.borrowernumber" => "self.borrowernumber" },
783
  { "foreign.borrowernumber" => "self.borrowernumber" },
696
  { cascade_copy => 0, cascade_delete => 0 },
784
  { cascade_copy => 0, cascade_delete => 0 },
697
);
785
);
698
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 726-732 __PACKAGE__->belongs_to( Link Here
726
  { is_deferrable => 1, on_delete => "RESTRICT", on_update => "RESTRICT" },
829
  { is_deferrable => 1, on_delete => "RESTRICT", on_update => "RESTRICT" },
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
863
864
Type: has_many
865
866
Related object: L<Koha::Schema::Result::CourseInstructor>
867
868
=cut
869
870
__PACKAGE__->has_many(
871
  "course_instructors_borrowernumbers",
872
  "Koha::Schema::Result::CourseInstructor",
873
  { "foreign.borrowernumber" => "self.borrowernumber" },
874
  { cascade_copy => 0, cascade_delete => 0 },
875
);
876
877
=head2 course_instructors_borrowernumbers
730
878
731
Type: has_many
879
Type: has_many
732
880
Lines 735-747 Related object: L<Koha::Schema::Result::CourseInstructor> Link Here
735
=cut
883
=cut
736
884
737
__PACKAGE__->has_many(
885
__PACKAGE__->has_many(
738
  "course_instructors",
886
  "course_instructors_borrowernumbers",
739
  "Koha::Schema::Result::CourseInstructor",
887
  "Koha::Schema::Result::CourseInstructor",
740
  { "foreign.borrowernumber" => "self.borrowernumber" },
888
  { "foreign.borrowernumber" => "self.borrowernumber" },
741
  { cascade_copy => 0, cascade_delete => 0 },
889
  { cascade_copy => 0, cascade_delete => 0 },
742
);
890
);
743
891
744
=head2 creator_batches
892
=head2 creator_batches_borrower_numbers
745
893
746
Type: has_many
894
Type: has_many
747
895
Lines 750-762 Related object: L<Koha::Schema::Result::CreatorBatch> Link Here
750
=cut
898
=cut
751
899
752
__PACKAGE__->has_many(
900
__PACKAGE__->has_many(
753
  "creator_batches",
901
  "creator_batches_borrower_numbers",
754
  "Koha::Schema::Result::CreatorBatch",
902
  "Koha::Schema::Result::CreatorBatch",
755
  { "foreign.borrower_number" => "self.borrowernumber" },
903
  { "foreign.borrower_number" => "self.borrowernumber" },
756
  { cascade_copy => 0, cascade_delete => 0 },
904
  { cascade_copy => 0, cascade_delete => 0 },
757
);
905
);
758
906
759
=head2 hold_fill_targets
907
=head2 creator_batches_borrower_numbers
908
909
Type: has_many
910
911
Related object: L<Koha::Schema::Result::CreatorBatch>
912
913
=cut
914
915
__PACKAGE__->has_many(
916
  "creator_batches_borrower_numbers",
917
  "Koha::Schema::Result::CreatorBatch",
918
  { "foreign.borrower_number" => "self.borrowernumber" },
919
  { cascade_copy => 0, cascade_delete => 0 },
920
);
921
922
=head2 hold_fill_targets_borrowernumbers
760
923
761
Type: has_many
924
Type: has_many
762
925
Lines 765-777 Related object: L<Koha::Schema::Result::HoldFillTarget> Link Here
765
=cut
928
=cut
766
929
767
__PACKAGE__->has_many(
930
__PACKAGE__->has_many(
768
  "hold_fill_targets",
931
  "hold_fill_targets_borrowernumbers",
769
  "Koha::Schema::Result::HoldFillTarget",
932
  "Koha::Schema::Result::HoldFillTarget",
770
  { "foreign.borrowernumber" => "self.borrowernumber" },
933
  { "foreign.borrowernumber" => "self.borrowernumber" },
771
  { cascade_copy => 0, cascade_delete => 0 },
934
  { cascade_copy => 0, cascade_delete => 0 },
772
);
935
);
773
936
774
=head2 issues
937
=head2 hold_fill_targets_borrowernumbers
938
939
Type: has_many
940
941
Related object: L<Koha::Schema::Result::HoldFillTarget>
942
943
=cut
944
945
__PACKAGE__->has_many(
946
  "hold_fill_targets_borrowernumbers",
947
  "Koha::Schema::Result::HoldFillTarget",
948
  { "foreign.borrowernumber" => "self.borrowernumber" },
949
  { cascade_copy => 0, cascade_delete => 0 },
950
);
951
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
1223
1224
Type: has_many
1225
1226
Related object: L<Koha::Schema::Result::Reserve>
1227
1228
=cut
1229
1230
__PACKAGE__->has_many(
1231
  "reserves_borrowernumbers",
1232
  "Koha::Schema::Result::Reserve",
1233
  { "foreign.borrowernumber" => "self.borrowernumber" },
1234
  { cascade_copy => 0, cascade_delete => 0 },
1235
);
1236
1237
=head2 reserves_borrowernumbers
910
1238
911
Type: has_many
1239
Type: has_many
912
1240
Lines 915-927 Related object: L<Koha::Schema::Result::Reserve> Link Here
915
=cut
1243
=cut
916
1244
917
__PACKAGE__->has_many(
1245
__PACKAGE__->has_many(
918
  "reserves",
1246
  "reserves_borrowernumbers",
919
  "Koha::Schema::Result::Reserve",
1247
  "Koha::Schema::Result::Reserve",
920
  { "foreign.borrowernumber" => "self.borrowernumber" },
1248
  { "foreign.borrowernumber" => "self.borrowernumber" },
921
  { cascade_copy => 0, cascade_delete => 0 },
1249
  { cascade_copy => 0, cascade_delete => 0 },
922
);
1250
);
923
1251
924
=head2 reviews
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
1343
1344
Type: has_many
1345
1346
Related object: L<Koha::Schema::Result::TagsApproval>
1347
1348
=cut
1349
1350
__PACKAGE__->has_many(
1351
  "tags_approvals_approved_by",
1352
  "Koha::Schema::Result::TagsApproval",
1353
  { "foreign.approved_by" => "self.borrowernumber" },
1354
  { cascade_copy => 0, cascade_delete => 0 },
1355
);
1356
1357
=head2 tags_approvals_approved_by
970
1358
971
Type: has_many
1359
Type: has_many
972
1360
Lines 975-987 Related object: L<Koha::Schema::Result::TagsApproval> Link Here
975
=cut
1363
=cut
976
1364
977
__PACKAGE__->has_many(
1365
__PACKAGE__->has_many(
978
  "tags_approvals",
1366
  "tags_approvals_approved_by",
979
  "Koha::Schema::Result::TagsApproval",
1367
  "Koha::Schema::Result::TagsApproval",
980
  { "foreign.approved_by" => "self.borrowernumber" },
1368
  { "foreign.approved_by" => "self.borrowernumber" },
981
  { cascade_copy => 0, cascade_delete => 0 },
1369
  { cascade_copy => 0, cascade_delete => 0 },
982
);
1370
);
983
1371
984
=head2 user_permissions
1372
=head2 user_permissions_borrowernumbers
985
1373
986
Type: has_many
1374
Type: has_many
987
1375
Lines 990-1002 Related object: L<Koha::Schema::Result::UserPermission> Link Here
990
=cut
1378
=cut
991
1379
992
__PACKAGE__->has_many(
1380
__PACKAGE__->has_many(
993
  "user_permissions",
1381
  "user_permissions_borrowernumbers",
994
  "Koha::Schema::Result::UserPermission",
1382
  "Koha::Schema::Result::UserPermission",
995
  { "foreign.borrowernumber" => "self.borrowernumber" },
1383
  { "foreign.borrowernumber" => "self.borrowernumber" },
996
  { cascade_copy => 0, cascade_delete => 0 },
1384
  { cascade_copy => 0, cascade_delete => 0 },
997
);
1385
);
998
1386
999
=head2 virtualshelfcontents
1387
=head2 user_permissions_borrowernumbers
1388
1389
Type: has_many
1390
1391
Related object: L<Koha::Schema::Result::UserPermission>
1392
1393
=cut
1394
1395
__PACKAGE__->has_many(
1396
  "user_permissions_borrowernumbers",
1397
  "Koha::Schema::Result::UserPermission",
1398
  { "foreign.borrowernumber" => "self.borrowernumber" },
1399
  { cascade_copy => 0, cascade_delete => 0 },
1400
);
1401
1402
=head2 virtualshelfcontents_borrowernumbers
1000
1403
1001
Type: has_many
1404
Type: has_many
1002
1405
Lines 1005-1080 Related object: L<Koha::Schema::Result::Virtualshelfcontent> Link Here
1005
=cut
1408
=cut
1006
1409
1007
__PACKAGE__->has_many(
1410
__PACKAGE__->has_many(
1008
  "virtualshelfcontents",
1411
  "virtualshelfcontents_borrowernumbers",
1009
  "Koha::Schema::Result::Virtualshelfcontent",
1412
  "Koha::Schema::Result::Virtualshelfcontent",
1010
  { "foreign.borrowernumber" => "self.borrowernumber" },
1413
  { "foreign.borrowernumber" => "self.borrowernumber" },
1011
  { cascade_copy => 0, cascade_delete => 0 },
1414
  { cascade_copy => 0, cascade_delete => 0 },
1012
);
1415
);
1013
1416
1014
=head2 virtualshelfshares
1417
=head2 virtualshelfcontents_borrowernumbers
1015
1418
1016
Type: has_many
1419
Type: has_many
1017
1420
1018
Related object: L<Koha::Schema::Result::Virtualshelfshare>
1421
Related object: L<Koha::Schema::Result::Virtualshelfcontent>
1019
1422
1020
=cut
1423
=cut
1021
1424
1022
__PACKAGE__->has_many(
1425
__PACKAGE__->has_many(
1023
  "virtualshelfshares",
1426
  "virtualshelfcontents_borrowernumbers",
1024
  "Koha::Schema::Result::Virtualshelfshare",
1427
  "Koha::Schema::Result::Virtualshelfcontent",
1025
  { "foreign.borrowernumber" => "self.borrowernumber" },
1428
  { "foreign.borrowernumber" => "self.borrowernumber" },
1026
  { cascade_copy => 0, cascade_delete => 0 },
1429
  { cascade_copy => 0, cascade_delete => 0 },
1027
);
1430
);
1028
1431
1029
=head2 virtualshelves
1432
=head2 virtualshelfshares_borrowernumbers
1030
1433
1031
Type: has_many
1434
Type: has_many
1032
1435
1033
Related object: L<Koha::Schema::Result::Virtualshelve>
1436
Related object: L<Koha::Schema::Result::Virtualshelfshare>
1034
1437
1035
=cut
1438
=cut
1036
1439
1037
__PACKAGE__->has_many(
1440
__PACKAGE__->has_many(
1038
  "virtualshelves",
1441
  "virtualshelfshares_borrowernumbers",
1039
  "Koha::Schema::Result::Virtualshelve",
1442
  "Koha::Schema::Result::Virtualshelfshare",
1040
  { "foreign.owner" => "self.borrowernumber" },
1443
  { "foreign.borrowernumber" => "self.borrowernumber" },
1041
  { cascade_copy => 0, cascade_delete => 0 },
1444
  { cascade_copy => 0, cascade_delete => 0 },
1042
);
1445
);
1043
1446
1044
=head2 basketnoes
1447
=head2 virtualshelfshares_borrowernumbers
1045
1448
1046
Type: many_to_many
1449
Type: has_many
1047
1450
1048
Composing rels: L</aqbasketusers> -> basketno
1451
Related object: L<Koha::Schema::Result::Virtualshelfshare>
1049
1452
1050
=cut
1453
=cut
1051
1454
1052
__PACKAGE__->many_to_many("basketnoes", "aqbasketusers", "basketno");
1455
__PACKAGE__->has_many(
1456
  "virtualshelfshares_borrowernumbers",
1457
  "Koha::Schema::Result::Virtualshelfshare",
1458
  { "foreign.borrowernumber" => "self.borrowernumber" },
1459
  { cascade_copy => 0, cascade_delete => 0 },
1460
);
1053
1461
1054
=head2 budgets
1462
=head2 virtualshelves_owners
1055
1463
1056
Type: many_to_many
1464
Type: has_many
1057
1465
1058
Composing rels: L</aqbudgetborrowers> -> budget
1466
Related object: L<Koha::Schema::Result::Virtualshelve>
1059
1467
1060
=cut
1468
=cut
1061
1469
1062
__PACKAGE__->many_to_many("budgets", "aqbudgetborrowers", "budget");
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
);
1063
1476
1064
=head2 courses
1477
=head2 virtualshelves_owners
1065
1478
1066
Type: many_to_many
1479
Type: has_many
1067
1480
1068
Composing rels: L</course_instructors> -> course
1481
Related object: L<Koha::Schema::Result::Virtualshelve>
1069
1482
1070
=cut
1483
=cut
1071
1484
1072
__PACKAGE__->many_to_many("courses", "course_instructors", "course");
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
);
1073
1491
1074
1492
1075
# Created by DBIx::Class::Schema::Loader v0.07039 @ 2014-07-11 09:26:55
1493
# Created by DBIx::Class::Schema::Loader v0.07039 @ 2014-07-11 09:26:55
1076
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:5cfpOojccKCoVRMj+0mWHg
1494
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:TIft8zTHaGV8X/T6uhW8uw
1495
1496
sub FirstValidEmailAddress {
1497
    my ( $self ) = @_;
1498
1499
    return $self->email() || $self->emailpro() || $self->b_email() || q{};
1500
}
1501
1502
sub ClubsEnrolledCount {
1503
    my ( $self ) = @_;
1504
1505
    return $self->club_enrollments({ date_canceled => undef })->count();
1506
}
1507
1508
sub ClubsEnrollableCount {
1509
    my ( $self, $is_enrollable_from_opac ) = @_;
1510
1511
    my $params;
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 (+3 lines)
Lines 572-577 $template->param( picture => 1 ) if $picture; Link Here
572
572
573
my $canned_notes = GetAuthorisedValues("BOR_NOTES");
573
my $canned_notes = GetAuthorisedValues("BOR_NOTES");
574
574
575
my $schema = Koha::Database->new()->schema();
576
575
$template->param(
577
$template->param(
576
    debt_confirmed            => $debt_confirmed,
578
    debt_confirmed            => $debt_confirmed,
577
    SpecifyDueDate            => $duedatespec_allow,
579
    SpecifyDueDate            => $duedatespec_allow,
Lines 581-586 $template->param( Link Here
581
    export_with_csv_profile   => C4::Context->preference("ExportWithCsvProfile"),
583
    export_with_csv_profile   => C4::Context->preference("ExportWithCsvProfile"),
582
    canned_bor_notes_loop     => $canned_notes,
584
    canned_bor_notes_loop     => $canned_notes,
583
    debarments                => GetDebarments({ borrowernumber => $borrowernumber }),
585
    debarments                => GetDebarments({ borrowernumber => $borrowernumber }),
586
    borrower                  => $schema->resultset('Borrower')->find( $borrowernumber ),
584
);
587
);
585
588
586
output_html_with_http_headers $query, $cookie, $template->output;
589
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 8589-8594 if ( CheckVersion($DBversion) ) { Link Here
8589
    SetVersion ($DBversion);
8589
    SetVersion ($DBversion);
8590
}
8590
}
8591
8591
8592
$DBversion = "3.17.00.XXX";
8593
if ( CheckVersion($DBversion) ) {
8594
    $dbh->do("INSERT INTO userflags (bit, flag, flagdesc, defaulton) VALUES ('20', 'clubs', 'Patron clubs', '0')");
8595
8596
    $dbh->do("
8597
        CREATE TABLE clubs (
8598
            id int(11) NOT NULL AUTO_INCREMENT,
8599
            club_template int(11) NOT NULL,
8600
            `name` tinytext NOT NULL,
8601
            description text,
8602
            date_start date DEFAULT NULL,
8603
            date_end date DEFAULT NULL,
8604
            branch varchar(11) DEFAULT NULL,
8605
            date_created timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
8606
            date_updated timestamp NULL DEFAULT NULL,
8607
            PRIMARY KEY (id),
8608
            KEY club_template (club_template),
8609
            KEY branch (branch)
8610
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
8611
    ");
8612
8613
    $dbh->do("
8614
        CREATE TABLE club_enrollments (
8615
            id int(11) NOT NULL AUTO_INCREMENT,
8616
            club int(11) NOT NULL,
8617
            borrower int(11) NOT NULL,
8618
            date_enrolled timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
8619
            date_canceled timestamp NULL DEFAULT NULL,
8620
            date_created timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
8621
            date_updated timestamp NULL DEFAULT NULL,
8622
            branch varchar(11) DEFAULT NULL,
8623
            PRIMARY KEY (id),
8624
            KEY club (club),
8625
            KEY borrower (borrower),
8626
            KEY branch (branch)
8627
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
8628
    ");
8629
8630
    $dbh->do("
8631
        CREATE TABLE club_enrollment_fields (
8632
            id int(11) NOT NULL AUTO_INCREMENT,
8633
            club_enrollment int(11) NOT NULL,
8634
            club_template_enrollment_field int(11) NOT NULL,
8635
            `value` text NOT NULL,
8636
            PRIMARY KEY (id),
8637
            KEY club_enrollment (club_enrollment),
8638
            KEY club_template_enrollment_field (club_template_enrollment_field),
8639
            KEY club_template_enrollment_field_2 (club_template_enrollment_field)
8640
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
8641
    ");
8642
8643
    $dbh->do("
8644
        CREATE TABLE club_fields (
8645
            id int(11) NOT NULL AUTO_INCREMENT,
8646
            club_template_field int(11) NOT NULL,
8647
            club int(11) NOT NULL,
8648
            `value` text,
8649
            PRIMARY KEY (id),
8650
            KEY club_template_field (club_template_field,club),
8651
            KEY club (club)
8652
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
8653
    ");
8654
8655
    $dbh->do("
8656
        CREATE TABLE club_templates (
8657
            id int(11) NOT NULL AUTO_INCREMENT,
8658
            `name` tinytext NOT NULL,
8659
            description text,
8660
            is_enrollable_from_opac tinyint(1) NOT NULL DEFAULT '0',
8661
            is_email_required tinyint(1) NOT NULL DEFAULT '0',
8662
            branch varchar(10) CHARACTER SET utf8 DEFAULT NULL,
8663
            date_created timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
8664
            date_updated timestamp NULL DEFAULT NULL,
8665
            is_deletable tinyint(1) NOT NULL DEFAULT '1',
8666
            PRIMARY KEY (id),
8667
            KEY branch (branch)
8668
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8 DEFAULT;
8669
    ");
8670
8671
    $dbh->do("
8672
        CREATE TABLE club_template_enrollment_fields (
8673
            id int(11) NOT NULL AUTO_INCREMENT,
8674
            club_template int(11) NOT NULL,
8675
            `name` tinytext NOT NULL,
8676
            description text,
8677
            authorised_value_category varchar(16) DEFAULT NULL,
8678
            PRIMARY KEY (id),
8679
            KEY club_template (club_template),
8680
            KEY club_template_2 (club_template)
8681
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
8682
    ");
8683
8684
    $dbh->do("
8685
        CREATE TABLE club_template_fields (
8686
            id int(11) NOT NULL AUTO_INCREMENT,
8687
            club_template int(11) NOT NULL,
8688
            `name` tinytext NOT NULL,
8689
            description text,
8690
            authorised_value_category varchar(16) DEFAULT NULL,
8691
            PRIMARY KEY (id),
8692
            KEY club_template (club_template)
8693
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
8694
    ");
8695
8696
    $dbh->do("
8697
        ALTER TABLE `clubs`
8698
            ADD CONSTRAINT clubs_ibfk_1 FOREIGN KEY (club_template) REFERENCES club_templates (id) ON DELETE CASCADE ON UPDATE CASCADE,
8699
            ADD CONSTRAINT clubs_ibfk_2 FOREIGN KEY (branch) REFERENCES branches (branchcode);
8700
    ");
8701
8702
    $dbh->do("
8703
        ALTER TABLE `club_enrollments`
8704
            ADD CONSTRAINT club_enrollments_ibfk_1 FOREIGN KEY (club) REFERENCES clubs (id) ON DELETE CASCADE ON UPDATE CASCADE,
8705
            ADD CONSTRAINT club_enrollments_ibfk_2 FOREIGN KEY (borrower) REFERENCES borrowers (borrowernumber) ON DELETE CASCADE ON UPDATE CASCADE,
8706
            ADD CONSTRAINT club_enrollments_ibfk_3 FOREIGN KEY (branch) REFERENCES branches (branchcode) ON DELETE SET NULL ON UPDATE CASCADE;
8707
    ");
8708
8709
    $dbh->do("
8710
        ALTER TABLE `club_enrollment_fields`
8711
            ADD CONSTRAINT club_enrollment_fields_ibfk_1 FOREIGN KEY (club_enrollment) REFERENCES club_enrollments (id) ON DELETE CASCADE ON UPDATE CASCADE,
8712
            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;
8713
    ");
8714
8715
    $dbh->do("
8716
        ALTER TABLE `club_fields`
8717
            ADD CONSTRAINT club_fields_ibfk_3 FOREIGN KEY (club_template_field) REFERENCES club_template_fields (id) ON DELETE CASCADE ON UPDATE CASCADE,
8718
            ADD CONSTRAINT club_fields_ibfk_4 FOREIGN KEY (club) REFERENCES clubs (id) ON DELETE CASCADE ON UPDATE CASCADE;
8719
    ");
8720
8721
    $dbh->do("
8722
        ALTER TABLE `club_templates`
8723
            ADD CONSTRAINT club_templates_ibfk_1 FOREIGN KEY (branch) REFERENCES branches (branchcode) ON DELETE SET NULL ON UPDATE CASCADE;
8724
    ");
8725
8726
    $dbh->do("
8727
        ALTER TABLE `club_template_enrollment_fields`
8728
            ADD CONSTRAINT club_template_enrollment_fields_ibfk_1 FOREIGN KEY (club_template) REFERENCES club_templates (id) ON DELETE CASCADE ON UPDATE CASCADE;
8729
    ");
8730
8731
    $dbh->do("
8732
        ALTER TABLE `club_template_fields`
8733
            ADD CONSTRAINT club_template_fields_ibfk_1 FOREIGN KEY (club_template) REFERENCES club_templates (id) ON DELETE CASCADE ON UPDATE CASCADE;
8734
    ");
8735
8736
   print "Upgrade to $DBversion done (Bug 12461 - Add patron clubs feature)\n";
8737
   SetVersion ($DBversion);
8738
}
8739
8592
=head1 FUNCTIONS
8740
=head1 FUNCTIONS
8593
8741
8594
=head2 TableExists($table)
8742
=head2 TableExists($table)
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt (+19 lines)
Lines 45-50 var MSG_EXPORT_SELECT_CHECKOUTS = _("You must select checkout(s) to export"); Link Here
45
45
46
$(document).ready(function() {
46
$(document).ready(function() {
47
    [% IF !( CircAutoPrintQuickSlip == 'clear' ) %]
47
    [% IF !( CircAutoPrintQuickSlip == 'clear' ) %]
48
        $('#clubs-tab-link').on('click', function() {
49
            $('#clubs-tab').text(_("Loading..."));
50
            $('#clubs-tab').load('/cgi-bin/koha/clubs/patron-clubs-tab.pl?borrowernumber=[% borrowernumber %]');
51
        });
52
48
        // listen submit to trigger qslip on empty checkout
53
        // listen submit to trigger qslip on empty checkout
49
        $('#mainform').bind('submit',function() {
54
        $('#mainform').bind('submit',function() {
50
            if ($('#barcode').val() == '') {
55
            if ($('#barcode').val() == '') {
Lines 662-667 No patron matched <span class="ex">[% message %]</span> Link Here
662
        [% END %]
667
        [% END %]
663
    </li>
668
    </li>
664
669
670
    [% IF CAN_user_clubs && ( borrower.ClubsEnrolledCount || borrower.ClubsEnrollableCount ) %]
671
        <li>
672
            <a id="clubs-tab-link" href="#clubs-tab">
673
                Clubs ([% borrower.ClubsEnrolledCount %]/[% borrower.ClubsEnrollableCount %])
674
            </a>
675
        </li>
676
    [% END %]
677
665
    [% IF relatives_issues_count %]
678
    [% IF relatives_issues_count %]
666
        <li><a id="relatives-issues-tab" href="#relatives-issues">Relatives' checkouts</a></li>
679
        <li><a id="relatives-issues-tab" href="#relatives-issues">Relatives' checkouts</a></li>
667
    [% END %]
680
    [% END %]
Lines 737-742 No patron matched <span class="ex">[% message %]</span> Link Here
737
    </div>
750
    </div>
738
[% END %]
751
[% END %]
739
752
753
[% IF CAN_user_clubs %]
754
    <div id="clubs-tab">
755
        Loading...
756
    </div>
757
[% END %]
758
740
[% INCLUDE borrower_debarments.inc %]
759
[% INCLUDE borrower_debarments.inc %]
741
760
742
<div id="reserves">
761
<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 33-38 var relatives_borrowernumbers = new Array(); Link Here
33
[% END %]
33
[% END %]
34
34
35
$(document).ready(function() {
35
$(document).ready(function() {
36
    $('#clubs-tab-link').on('click', function() {
37
        $('#clubs-tab').text(_("Loading..."));
38
        $('#clubs-tab').load('/cgi-bin/koha/clubs/patron-clubs-tab.pl?borrowernumber=[% borrowernumber %]');
39
    });
40
36
    $('#finesholdsissues').tabs({
41
    $('#finesholdsissues').tabs({
37
        // Correct table sizing for tables hidden in tabs
42
        // Correct table sizing for tables hidden in tabs
38
        // http://www.datatables.net/examples/api/tabs_and_scrolling.html
43
        // http://www.datatables.net/examples/api/tabs_and_scrolling.html
Lines 406-411 function validate1(date) { Link Here
406
            [% END %]
411
            [% END %]
407
        </li>
412
        </li>
408
        <li><a id="debarments-tab-link" href="#reldebarments">[% debarments.size %] Restrictions</a></li>
413
        <li><a id="debarments-tab-link" href="#reldebarments">[% debarments.size %] Restrictions</a></li>
414
        [% IF CAN_user_clubs && ( borrower.ClubsEnrolledCount || borrower.ClubsEnrollableCount ) %]
415
            <li>
416
                <a id="clubs-tab-link" href="#clubs-tab">
417
                    Clubs ([% borrower.ClubsEnrolledCount %]/[% borrower.ClubsEnrollableCount %])
418
                </a>
419
            </li>
420
        [% END %]
409
    </ul>
421
    </ul>
410
422
411
    <div id="checkouts">
423
    <div id="checkouts">
Lines 498-503 function validate1(date) { Link Here
498
    [% END %]
510
    [% END %]
499
</div>
511
</div>
500
512
513
<div id="clubs-tab">
514
    Loading...
515
</div>
516
501
[% INCLUDE borrower_debarments.inc %]
517
[% INCLUDE borrower_debarments.inc %]
502
518
503
<div id="reserves">
519
<div id="reserves">
(-)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 277-282 Link Here
277
                            [% END # IF issues_count %]
285
                            [% END # IF issues_count %]
278
                        </div> <!-- / .opac-user-checkouts -->
286
                        </div> <!-- / .opac-user-checkouts -->
279
287
288
                        <div id="opac-user-clubs">
289
                            Loading...
290
                        </div>
291
280
                        [% IF ( OPACFinesTab ) %]
292
                        [% IF ( OPACFinesTab ) %]
281
                            <!-- FINES BOX -->
293
                            <!-- FINES BOX -->
282
                            [% IF ( BORROWER_INF.amountoverfive ) %]
294
                            [% IF ( BORROWER_INF.amountoverfive ) %]
Lines 724-729 Link Here
724
            [% END %]
736
            [% END %]
725
737
726
            $( ".suspend-until" ).datepicker({ minDate: 1 }); // Require that "until date" be in the future
738
            $( ".suspend-until" ).datepicker({ minDate: 1 }); // Require that "until date" be in the future
739
740
            $('#opac-user-clubs-tab-link').on('click', function() {
741
                $('#opac-user-clubs').text(_("Loading..."));
742
                $('#opac-user-clubs').load('/cgi-bin/koha/clubs/clubs-tab.pl?borrowernumber=[% borrowernumber %]');
743
            });
727
        });
744
        });
728
        //]]>
745
        //]]>
729
    </script>
746
    </script>
(-)a/members/moremember.pl (+3 lines)
Lines 341-346 if (C4::Context->preference('EnhancedMessagingPreferences')) { Link Here
341
# Computes full borrower address
341
# Computes full borrower address
342
my $address = $data->{'streetnumber'} . " $roadtype " . $data->{'address'};
342
my $address = $data->{'streetnumber'} . " $roadtype " . $data->{'address'};
343
343
344
my $schema =  Koha::Database->new()->schema();
345
344
# in template <TMPL_IF name="I"> => instutitional (A for Adult, C for children) 
346
# in template <TMPL_IF name="I"> => instutitional (A for Adult, C for children) 
345
$template->param( $data->{'categorycode'} => 1 ); 
347
$template->param( $data->{'categorycode'} => 1 ); 
346
$template->param(
348
$template->param(
Lines 371-376 $template->param( Link Here
371
    relatives_issues_count => $relatives_issues_count,
373
    relatives_issues_count => $relatives_issues_count,
372
    relatives_borrowernumbers => \@relatives,
374
    relatives_borrowernumbers => \@relatives,
373
    address => $address
375
    address => $address
376
    borrower => $schema->resultset('Borrower')->find( $borrowernumber ),
374
);
377
);
375
378
376
output_html_with_http_headers $input, $cookie, $template->output;
379
output_html_with_http_headers $input, $cookie, $template->output;
(-)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 383-394 $template->param( Link Here
383
    patronupdate => $patronupdate,
386
    patronupdate => $patronupdate,
384
    OpacRenewalAllowed => C4::Context->preference("OpacRenewalAllowed"),
387
    OpacRenewalAllowed => C4::Context->preference("OpacRenewalAllowed"),
385
    userview => 1,
388
    userview => 1,
386
);
387
388
$template->param(
389
    SuspendHoldsOpac => C4::Context->preference('SuspendHoldsOpac'),
389
    SuspendHoldsOpac => C4::Context->preference('SuspendHoldsOpac'),
390
    AutoResumeSuspendedHolds => C4::Context->preference('AutoResumeSuspendedHolds'),
390
    AutoResumeSuspendedHolds => C4::Context->preference('AutoResumeSuspendedHolds'),
391
    OpacHoldNotes => C4::Context->preference('OpacHoldNotes'),
391
    OpacHoldNotes => C4::Context->preference('OpacHoldNotes'),
392
    borrower => $schema->resultset('Borrower')->find($borrowernumber),
392
);
393
);
393
394
394
output_html_with_http_headers $query, $cookie, $template->output;
395
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