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

(-)a/C4/Members.pm (-13 / +3 lines)
Lines 1521-1540 addresses. Link Here
1521
1521
1522
sub GetFirstValidEmailAddress {
1522
sub GetFirstValidEmailAddress {
1523
    my $borrowernumber = shift;
1523
    my $borrowernumber = shift;
1524
    my $dbh = C4::Context->dbh;
1525
    my $sth = $dbh->prepare( "SELECT email, emailpro, B_email FROM borrowers where borrowernumber = ? ");
1526
    $sth->execute( $borrowernumber );
1527
    my $data = $sth->fetchrow_hashref;
1528
1524
1529
    if ($data->{'email'}) {
1525
    my $borrower = Koha::Database->new()->schema()->resultset('Borrower')->find( $borrowernumber );
1530
       return $data->{'email'};
1526
1531
    } elsif ($data->{'emailpro'}) {
1527
    return $borrower->FirstValidEmailAddress();
1532
       return $data->{'emailpro'};
1533
    } elsif ($data->{'B_email'}) {
1534
       return $data->{'B_email'};
1535
    } else {
1536
       return '';
1537
    }
1538
}
1528
}
1539
1529
1540
=head2 GetNoticeEmailAddress
1530
=head2 GetNoticeEmailAddress
(-)a/Koha/Schema/Result/Borrower.pm (-106 / +528 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 201-207 __PACKAGE__->table("borrowers"); Link Here
201
=head2 dateofbirth
197
=head2 dateofbirth
202
198
203
  data_type: 'date'
199
  data_type: 'date'
204
  datetime_undef_if_invalid: 1
205
  is_nullable: 1
200
  is_nullable: 1
206
201
207
=head2 branchcode
202
=head2 branchcode
Lines 223-235 __PACKAGE__->table("borrowers"); Link Here
223
=head2 dateenrolled
218
=head2 dateenrolled
224
219
225
  data_type: 'date'
220
  data_type: 'date'
226
  datetime_undef_if_invalid: 1
227
  is_nullable: 1
221
  is_nullable: 1
228
222
229
=head2 dateexpiry
223
=head2 dateexpiry
230
224
231
  data_type: 'date'
225
  data_type: 'date'
232
  datetime_undef_if_invalid: 1
233
  is_nullable: 1
226
  is_nullable: 1
234
227
235
=head2 gonenoaddress
228
=head2 gonenoaddress
Lines 245-251 __PACKAGE__->table("borrowers"); Link Here
245
=head2 debarred
238
=head2 debarred
246
239
247
  data_type: 'date'
240
  data_type: 'date'
248
  datetime_undef_if_invalid: 1
249
  is_nullable: 1
241
  is_nullable: 1
250
242
251
=head2 debarredcomment
243
=head2 debarredcomment
Lines 493-499 __PACKAGE__->add_columns( Link Here
493
  "B_phone",
485
  "B_phone",
494
  { accessor => "b_phone", data_type => "mediumtext", is_nullable => 1 },
486
  { accessor => "b_phone", data_type => "mediumtext", is_nullable => 1 },
495
  "dateofbirth",
487
  "dateofbirth",
496
  { data_type => "date", datetime_undef_if_invalid => 1, is_nullable => 1 },
488
  { data_type => "date", is_nullable => 1 },
497
  "branchcode",
489
  "branchcode",
498
  {
490
  {
499
    data_type => "varchar",
491
    data_type => "varchar",
Lines 511-525 __PACKAGE__->add_columns( Link Here
511
    size => 10,
503
    size => 10,
512
  },
504
  },
513
  "dateenrolled",
505
  "dateenrolled",
514
  { data_type => "date", datetime_undef_if_invalid => 1, is_nullable => 1 },
506
  { data_type => "date", is_nullable => 1 },
515
  "dateexpiry",
507
  "dateexpiry",
516
  { data_type => "date", datetime_undef_if_invalid => 1, is_nullable => 1 },
508
  { data_type => "date", is_nullable => 1 },
517
  "gonenoaddress",
509
  "gonenoaddress",
518
  { data_type => "tinyint", is_nullable => 1 },
510
  { data_type => "tinyint", is_nullable => 1 },
519
  "lost",
511
  "lost",
520
  { data_type => "tinyint", is_nullable => 1 },
512
  { data_type => "tinyint", is_nullable => 1 },
521
  "debarred",
513
  "debarred",
522
  { data_type => "date", datetime_undef_if_invalid => 1, is_nullable => 1 },
514
  { data_type => "date", is_nullable => 1 },
523
  "debarredcomment",
515
  "debarredcomment",
524
  { data_type => "varchar", is_nullable => 1, size => 255 },
516
  { data_type => "varchar", is_nullable => 1, size => 255 },
525
  "contactname",
517
  "contactname",
Lines 577-604 __PACKAGE__->add_columns( Link Here
577
  "privacy",
569
  "privacy",
578
  { data_type => "integer", default_value => 1, is_nullable => 0 },
570
  { data_type => "integer", default_value => 1, is_nullable => 0 },
579
);
571
);
572
__PACKAGE__->set_primary_key("borrowernumber");
573
__PACKAGE__->add_unique_constraint("cardnumber", ["cardnumber"]);
580
574
581
=head1 PRIMARY KEY
575
=head1 RELATIONS
582
576
583
=over 4
577
=head2 accountlines_borrowernumbers
584
578
585
=item * L</borrowernumber>
579
Type: has_many
586
580
587
=back
581
Related object: L<Koha::Schema::Result::Accountline>
588
582
589
=cut
583
=cut
590
584
591
__PACKAGE__->set_primary_key("borrowernumber");
585
__PACKAGE__->has_many(
592
586
  "accountlines_borrowernumbers",
593
=head1 UNIQUE CONSTRAINTS
587
  "Koha::Schema::Result::Accountline",
594
588
  { "foreign.borrowernumber" => "self.borrowernumber" },
595
=head2 C<cardnumber>
589
  { cascade_copy => 0, cascade_delete => 0 },
590
);
596
591
597
=over 4
592
=head2 accountlines_borrowernumbers
598
593
599
=item * L</cardnumber>
594
Type: has_many
600
595
601
=back
596
Related object: L<Koha::Schema::Result::Accountline>
602
597
603
=cut
598
=cut
604
599
Lines 618-639 __PACKAGE__->add_unique_constraint("userid", ["userid"]); Link Here
618
613
619
=head1 RELATIONS
614
=head1 RELATIONS
620
615
621
=head2 accountlines
616
=head2 accountoffsets_borrowernumbers
622
617
623
Type: has_many
618
Type: has_many
624
619
625
Related object: L<Koha::Schema::Result::Accountline>
620
Related object: L<Koha::Schema::Result::Accountoffset>
626
621
627
=cut
622
=cut
628
623
629
__PACKAGE__->has_many(
624
__PACKAGE__->has_many(
630
  "accountlines",
625
  "accountoffsets_borrowernumbers",
631
  "Koha::Schema::Result::Accountline",
626
  "Koha::Schema::Result::Accountoffset",
632
  { "foreign.borrowernumber" => "self.borrowernumber" },
627
  { "foreign.borrowernumber" => "self.borrowernumber" },
633
  { cascade_copy => 0, cascade_delete => 0 },
628
  { cascade_copy => 0, cascade_delete => 0 },
634
);
629
);
635
630
636
=head2 accountoffsets
631
=head2 accountoffsets_borrowernumbers
637
632
638
Type: has_many
633
Type: has_many
639
634
Lines 642-654 Related object: L<Koha::Schema::Result::Accountoffset> Link Here
642
=cut
637
=cut
643
638
644
__PACKAGE__->has_many(
639
__PACKAGE__->has_many(
645
  "accountoffsets",
640
  "accountoffsets_borrowernumbers",
646
  "Koha::Schema::Result::Accountoffset",
641
  "Koha::Schema::Result::Accountoffset",
647
  { "foreign.borrowernumber" => "self.borrowernumber" },
642
  { "foreign.borrowernumber" => "self.borrowernumber" },
648
  { cascade_copy => 0, cascade_delete => 0 },
643
  { cascade_copy => 0, cascade_delete => 0 },
649
);
644
);
650
645
651
=head2 aqbasketusers
646
=head2 aqbasketusers_borrowernumbers
652
647
653
Type: has_many
648
Type: has_many
654
649
Lines 657-669 Related object: L<Koha::Schema::Result::Aqbasketuser> Link Here
657
=cut
652
=cut
658
653
659
__PACKAGE__->has_many(
654
__PACKAGE__->has_many(
660
  "aqbasketusers",
655
  "aqbasketusers_borrowernumbers",
661
  "Koha::Schema::Result::Aqbasketuser",
656
  "Koha::Schema::Result::Aqbasketuser",
662
  { "foreign.borrowernumber" => "self.borrowernumber" },
657
  { "foreign.borrowernumber" => "self.borrowernumber" },
663
  { cascade_copy => 0, cascade_delete => 0 },
658
  { cascade_copy => 0, cascade_delete => 0 },
664
);
659
);
665
660
666
=head2 aqbudgetborrowers
661
=head2 aqbasketusers_borrowernumbers
662
663
Type: has_many
664
665
Related object: L<Koha::Schema::Result::Aqbasketuser>
666
667
=cut
668
669
__PACKAGE__->has_many(
670
  "aqbasketusers_borrowernumbers",
671
  "Koha::Schema::Result::Aqbasketuser",
672
  { "foreign.borrowernumber" => "self.borrowernumber" },
673
  { cascade_copy => 0, cascade_delete => 0 },
674
);
675
676
=head2 aqbudgetborrowers_borrowernumbers
677
678
Type: has_many
679
680
Related object: L<Koha::Schema::Result::Aqbudgetborrower>
681
682
=cut
683
684
__PACKAGE__->has_many(
685
  "aqbudgetborrowers_borrowernumbers",
686
  "Koha::Schema::Result::Aqbudgetborrower",
687
  { "foreign.borrowernumber" => "self.borrowernumber" },
688
  { cascade_copy => 0, cascade_delete => 0 },
689
);
690
691
=head2 aqbudgetborrowers_borrowernumbers
667
692
668
Type: has_many
693
Type: has_many
669
694
Lines 672-684 Related object: L<Koha::Schema::Result::Aqbudgetborrower> Link Here
672
=cut
697
=cut
673
698
674
__PACKAGE__->has_many(
699
__PACKAGE__->has_many(
675
  "aqbudgetborrowers",
700
  "aqbudgetborrowers_borrowernumbers",
676
  "Koha::Schema::Result::Aqbudgetborrower",
701
  "Koha::Schema::Result::Aqbudgetborrower",
677
  { "foreign.borrowernumber" => "self.borrowernumber" },
702
  { "foreign.borrowernumber" => "self.borrowernumber" },
678
  { cascade_copy => 0, cascade_delete => 0 },
703
  { cascade_copy => 0, cascade_delete => 0 },
679
);
704
);
680
705
681
=head2 borrower_attributes
706
=head2 borrower_attributes_borrowernumbers
707
708
Type: has_many
709
710
Related object: L<Koha::Schema::Result::BorrowerAttribute>
711
712
=cut
713
714
__PACKAGE__->has_many(
715
  "borrower_attributes_borrowernumbers",
716
  "Koha::Schema::Result::BorrowerAttribute",
717
  { "foreign.borrowernumber" => "self.borrowernumber" },
718
  { cascade_copy => 0, cascade_delete => 0 },
719
);
720
721
=head2 borrower_attributes_borrowernumbers
682
722
683
Type: has_many
723
Type: has_many
684
724
Lines 687-699 Related object: L<Koha::Schema::Result::BorrowerAttribute> Link Here
687
=cut
727
=cut
688
728
689
__PACKAGE__->has_many(
729
__PACKAGE__->has_many(
690
  "borrower_attributes",
730
  "borrower_attributes_borrowernumbers",
691
  "Koha::Schema::Result::BorrowerAttribute",
731
  "Koha::Schema::Result::BorrowerAttribute",
692
  { "foreign.borrowernumber" => "self.borrowernumber" },
732
  { "foreign.borrowernumber" => "self.borrowernumber" },
693
  { cascade_copy => 0, cascade_delete => 0 },
733
  { cascade_copy => 0, cascade_delete => 0 },
694
);
734
);
695
735
696
=head2 borrower_debarments
736
=head2 borrower_debarments_borrowernumbers
697
737
698
Type: has_many
738
Type: has_many
699
739
Lines 702-714 Related object: L<Koha::Schema::Result::BorrowerDebarment> Link Here
702
=cut
742
=cut
703
743
704
__PACKAGE__->has_many(
744
__PACKAGE__->has_many(
705
  "borrower_debarments",
745
  "borrower_debarments_borrowernumbers",
706
  "Koha::Schema::Result::BorrowerDebarment",
746
  "Koha::Schema::Result::BorrowerDebarment",
707
  { "foreign.borrowernumber" => "self.borrowernumber" },
747
  { "foreign.borrowernumber" => "self.borrowernumber" },
708
  { cascade_copy => 0, cascade_delete => 0 },
748
  { cascade_copy => 0, cascade_delete => 0 },
709
);
749
);
710
750
711
=head2 borrower_files
751
=head2 borrower_debarments_borrowernumbers
752
753
Type: has_many
754
755
Related object: L<Koha::Schema::Result::BorrowerDebarment>
756
757
=cut
758
759
__PACKAGE__->has_many(
760
  "borrower_debarments_borrowernumbers",
761
  "Koha::Schema::Result::BorrowerDebarment",
762
  { "foreign.borrowernumber" => "self.borrowernumber" },
763
  { cascade_copy => 0, cascade_delete => 0 },
764
);
765
766
=head2 borrower_files_borrowernumbers
712
767
713
Type: has_many
768
Type: has_many
714
769
Lines 717-729 Related object: L<Koha::Schema::Result::BorrowerFile> Link Here
717
=cut
772
=cut
718
773
719
__PACKAGE__->has_many(
774
__PACKAGE__->has_many(
720
  "borrower_files",
775
  "borrower_files_borrowernumbers",
721
  "Koha::Schema::Result::BorrowerFile",
776
  "Koha::Schema::Result::BorrowerFile",
722
  { "foreign.borrowernumber" => "self.borrowernumber" },
777
  { "foreign.borrowernumber" => "self.borrowernumber" },
723
  { cascade_copy => 0, cascade_delete => 0 },
778
  { cascade_copy => 0, cascade_delete => 0 },
724
);
779
);
725
780
726
=head2 borrower_message_preferences
781
=head2 borrower_files_borrowernumbers
782
783
Type: has_many
784
785
Related object: L<Koha::Schema::Result::BorrowerFile>
786
787
=cut
788
789
__PACKAGE__->has_many(
790
  "borrower_files_borrowernumbers",
791
  "Koha::Schema::Result::BorrowerFile",
792
  { "foreign.borrowernumber" => "self.borrowernumber" },
793
  { cascade_copy => 0, cascade_delete => 0 },
794
);
795
796
=head2 borrower_message_preferences_borrowernumbers
727
797
728
Type: has_many
798
Type: has_many
729
799
Lines 732-738 Related object: L<Koha::Schema::Result::BorrowerMessagePreference> Link Here
732
=cut
802
=cut
733
803
734
__PACKAGE__->has_many(
804
__PACKAGE__->has_many(
735
  "borrower_message_preferences",
805
  "borrower_message_preferences_borrowernumbers",
806
  "Koha::Schema::Result::BorrowerMessagePreference",
807
  { "foreign.borrowernumber" => "self.borrowernumber" },
808
  { cascade_copy => 0, cascade_delete => 0 },
809
);
810
811
=head2 borrower_message_preferences_borrowernumbers
812
813
Type: has_many
814
815
Related object: L<Koha::Schema::Result::BorrowerMessagePreference>
816
817
=cut
818
819
__PACKAGE__->has_many(
820
  "borrower_message_preferences_borrowernumbers",
736
  "Koha::Schema::Result::BorrowerMessagePreference",
821
  "Koha::Schema::Result::BorrowerMessagePreference",
737
  { "foreign.borrowernumber" => "self.borrowernumber" },
822
  { "foreign.borrowernumber" => "self.borrowernumber" },
738
  { cascade_copy => 0, cascade_delete => 0 },
823
  { cascade_copy => 0, cascade_delete => 0 },
Lines 783-789 __PACKAGE__->belongs_to( Link Here
783
  { is_deferrable => 1, on_delete => "RESTRICT", on_update => "RESTRICT" },
868
  { is_deferrable => 1, on_delete => "RESTRICT", on_update => "RESTRICT" },
784
);
869
);
785
870
786
=head2 course_instructors
871
=head2 branchcode
872
873
Type: belongs_to
874
875
Related object: L<Koha::Schema::Result::Branch>
876
877
=cut
878
879
__PACKAGE__->belongs_to(
880
  "branchcode",
881
  "Koha::Schema::Result::Branch",
882
  { branchcode => "branchcode" },
883
  { on_delete => "CASCADE", on_update => "CASCADE" },
884
);
885
886
=head2 club_enrollments
887
888
Type: has_many
889
890
Related object: L<Koha::Schema::Result::ClubEnrollment>
891
892
=cut
893
894
__PACKAGE__->has_many(
895
  "club_enrollments",
896
  "Koha::Schema::Result::ClubEnrollment",
897
  { "foreign.borrower" => "self.borrowernumber" },
898
  { cascade_copy => 0, cascade_delete => 0 },
899
);
900
901
=head2 course_instructors_borrowernumbers
787
902
788
Type: has_many
903
Type: has_many
789
904
Lines 792-804 Related object: L<Koha::Schema::Result::CourseInstructor> Link Here
792
=cut
907
=cut
793
908
794
__PACKAGE__->has_many(
909
__PACKAGE__->has_many(
795
  "course_instructors",
910
  "course_instructors_borrowernumbers",
796
  "Koha::Schema::Result::CourseInstructor",
911
  "Koha::Schema::Result::CourseInstructor",
797
  { "foreign.borrowernumber" => "self.borrowernumber" },
912
  { "foreign.borrowernumber" => "self.borrowernumber" },
798
  { cascade_copy => 0, cascade_delete => 0 },
913
  { cascade_copy => 0, cascade_delete => 0 },
799
);
914
);
800
915
801
=head2 creator_batches
916
=head2 course_instructors_borrowernumbers
917
918
Type: has_many
919
920
Related object: L<Koha::Schema::Result::CourseInstructor>
921
922
=cut
923
924
__PACKAGE__->has_many(
925
  "course_instructors_borrowernumbers",
926
  "Koha::Schema::Result::CourseInstructor",
927
  { "foreign.borrowernumber" => "self.borrowernumber" },
928
  { cascade_copy => 0, cascade_delete => 0 },
929
);
930
931
=head2 creator_batches_borrower_numbers
802
932
803
Type: has_many
933
Type: has_many
804
934
Lines 807-819 Related object: L<Koha::Schema::Result::CreatorBatch> Link Here
807
=cut
937
=cut
808
938
809
__PACKAGE__->has_many(
939
__PACKAGE__->has_many(
810
  "creator_batches",
940
  "creator_batches_borrower_numbers",
811
  "Koha::Schema::Result::CreatorBatch",
941
  "Koha::Schema::Result::CreatorBatch",
812
  { "foreign.borrower_number" => "self.borrowernumber" },
942
  { "foreign.borrower_number" => "self.borrowernumber" },
813
  { cascade_copy => 0, cascade_delete => 0 },
943
  { cascade_copy => 0, cascade_delete => 0 },
814
);
944
);
815
945
816
=head2 hold_fill_targets
946
=head2 creator_batches_borrower_numbers
947
948
Type: has_many
949
950
Related object: L<Koha::Schema::Result::CreatorBatch>
951
952
=cut
953
954
__PACKAGE__->has_many(
955
  "creator_batches_borrower_numbers",
956
  "Koha::Schema::Result::CreatorBatch",
957
  { "foreign.borrower_number" => "self.borrowernumber" },
958
  { cascade_copy => 0, cascade_delete => 0 },
959
);
960
961
=head2 hold_fill_targets_borrowernumbers
817
962
818
Type: has_many
963
Type: has_many
819
964
Lines 822-834 Related object: L<Koha::Schema::Result::HoldFillTarget> Link Here
822
=cut
967
=cut
823
968
824
__PACKAGE__->has_many(
969
__PACKAGE__->has_many(
825
  "hold_fill_targets",
970
  "hold_fill_targets_borrowernumbers",
826
  "Koha::Schema::Result::HoldFillTarget",
971
  "Koha::Schema::Result::HoldFillTarget",
827
  { "foreign.borrowernumber" => "self.borrowernumber" },
972
  { "foreign.borrowernumber" => "self.borrowernumber" },
828
  { cascade_copy => 0, cascade_delete => 0 },
973
  { cascade_copy => 0, cascade_delete => 0 },
829
);
974
);
830
975
831
=head2 issues
976
=head2 hold_fill_targets_borrowernumbers
977
978
Type: has_many
979
980
Related object: L<Koha::Schema::Result::HoldFillTarget>
981
982
=cut
983
984
__PACKAGE__->has_many(
985
  "hold_fill_targets_borrowernumbers",
986
  "Koha::Schema::Result::HoldFillTarget",
987
  { "foreign.borrowernumber" => "self.borrowernumber" },
988
  { cascade_copy => 0, cascade_delete => 0 },
989
);
990
991
=head2 issues_borrowernumbers
992
993
Type: has_many
994
995
Related object: L<Koha::Schema::Result::Issue>
996
997
=cut
998
999
__PACKAGE__->has_many(
1000
  "issues_borrowernumbers",
1001
  "Koha::Schema::Result::Issue",
1002
  { "foreign.borrowernumber" => "self.borrowernumber" },
1003
  { cascade_copy => 0, cascade_delete => 0 },
1004
);
1005
1006
=head2 issues_borrowernumbers
832
1007
833
Type: has_many
1008
Type: has_many
834
1009
Lines 837-849 Related object: L<Koha::Schema::Result::Issue> Link Here
837
=cut
1012
=cut
838
1013
839
__PACKAGE__->has_many(
1014
__PACKAGE__->has_many(
840
  "issues",
1015
  "issues_borrowernumbers",
841
  "Koha::Schema::Result::Issue",
1016
  "Koha::Schema::Result::Issue",
842
  { "foreign.borrowernumber" => "self.borrowernumber" },
1017
  { "foreign.borrowernumber" => "self.borrowernumber" },
843
  { cascade_copy => 0, cascade_delete => 0 },
1018
  { cascade_copy => 0, cascade_delete => 0 },
844
);
1019
);
845
1020
846
=head2 message_queues
1021
=head2 message_queue_borrowernumbers
847
1022
848
Type: has_many
1023
Type: has_many
849
1024
Lines 852-864 Related object: L<Koha::Schema::Result::MessageQueue> Link Here
852
=cut
1027
=cut
853
1028
854
__PACKAGE__->has_many(
1029
__PACKAGE__->has_many(
855
  "message_queues",
1030
  "message_queue_borrowernumbers",
856
  "Koha::Schema::Result::MessageQueue",
1031
  "Koha::Schema::Result::MessageQueue",
857
  { "foreign.borrowernumber" => "self.borrowernumber" },
1032
  { "foreign.borrowernumber" => "self.borrowernumber" },
858
  { cascade_copy => 0, cascade_delete => 0 },
1033
  { cascade_copy => 0, cascade_delete => 0 },
859
);
1034
);
860
1035
861
=head2 old_issues
1036
=head2 message_queue_borrowernumbers
1037
1038
Type: has_many
1039
1040
Related object: L<Koha::Schema::Result::MessageQueue>
1041
1042
=cut
1043
1044
__PACKAGE__->has_many(
1045
  "message_queue_borrowernumbers",
1046
  "Koha::Schema::Result::MessageQueue",
1047
  { "foreign.borrowernumber" => "self.borrowernumber" },
1048
  { cascade_copy => 0, cascade_delete => 0 },
1049
);
1050
1051
=head2 old_issues_borrowernumbers
1052
1053
Type: has_many
1054
1055
Related object: L<Koha::Schema::Result::OldIssue>
1056
1057
=cut
1058
1059
__PACKAGE__->has_many(
1060
  "old_issues_borrowernumbers",
1061
  "Koha::Schema::Result::OldIssue",
1062
  { "foreign.borrowernumber" => "self.borrowernumber" },
1063
  { cascade_copy => 0, cascade_delete => 0 },
1064
);
1065
1066
=head2 old_issues_borrowernumbers
862
1067
863
Type: has_many
1068
Type: has_many
864
1069
Lines 867-879 Related object: L<Koha::Schema::Result::OldIssue> Link Here
867
=cut
1072
=cut
868
1073
869
__PACKAGE__->has_many(
1074
__PACKAGE__->has_many(
870
  "old_issues",
1075
  "old_issues_borrowernumbers",
871
  "Koha::Schema::Result::OldIssue",
1076
  "Koha::Schema::Result::OldIssue",
872
  { "foreign.borrowernumber" => "self.borrowernumber" },
1077
  { "foreign.borrowernumber" => "self.borrowernumber" },
873
  { cascade_copy => 0, cascade_delete => 0 },
1078
  { cascade_copy => 0, cascade_delete => 0 },
874
);
1079
);
875
1080
876
=head2 old_reserves
1081
=head2 old_reserves_borrowernumbers
1082
1083
Type: has_many
1084
1085
Related object: L<Koha::Schema::Result::OldReserve>
1086
1087
=cut
1088
1089
__PACKAGE__->has_many(
1090
  "old_reserves_borrowernumbers",
1091
  "Koha::Schema::Result::OldReserve",
1092
  { "foreign.borrowernumber" => "self.borrowernumber" },
1093
  { cascade_copy => 0, cascade_delete => 0 },
1094
);
1095
1096
=head2 old_reserves_borrowernumbers
877
1097
878
Type: has_many
1098
Type: has_many
879
1099
Lines 882-894 Related object: L<Koha::Schema::Result::OldReserve> Link Here
882
=cut
1102
=cut
883
1103
884
__PACKAGE__->has_many(
1104
__PACKAGE__->has_many(
885
  "old_reserves",
1105
  "old_reserves_borrowernumbers",
886
  "Koha::Schema::Result::OldReserve",
1106
  "Koha::Schema::Result::OldReserve",
887
  { "foreign.borrowernumber" => "self.borrowernumber" },
1107
  { "foreign.borrowernumber" => "self.borrowernumber" },
888
  { cascade_copy => 0, cascade_delete => 0 },
1108
  { cascade_copy => 0, cascade_delete => 0 },
889
);
1109
);
890
1110
891
=head2 patron_list_patrons
1111
=head2 patron_list_patrons_borrowernumbers
892
1112
893
Type: has_many
1113
Type: has_many
894
1114
Lines 897-909 Related object: L<Koha::Schema::Result::PatronListPatron> Link Here
897
=cut
1117
=cut
898
1118
899
__PACKAGE__->has_many(
1119
__PACKAGE__->has_many(
900
  "patron_list_patrons",
1120
  "patron_list_patrons_borrowernumbers",
901
  "Koha::Schema::Result::PatronListPatron",
1121
  "Koha::Schema::Result::PatronListPatron",
902
  { "foreign.borrowernumber" => "self.borrowernumber" },
1122
  { "foreign.borrowernumber" => "self.borrowernumber" },
903
  { cascade_copy => 0, cascade_delete => 0 },
1123
  { cascade_copy => 0, cascade_delete => 0 },
904
);
1124
);
905
1125
906
=head2 patron_lists
1126
=head2 patron_list_patrons_borrowernumbers
1127
1128
Type: has_many
1129
1130
Related object: L<Koha::Schema::Result::PatronListPatron>
1131
1132
=cut
1133
1134
__PACKAGE__->has_many(
1135
  "patron_list_patrons_borrowernumbers",
1136
  "Koha::Schema::Result::PatronListPatron",
1137
  { "foreign.borrowernumber" => "self.borrowernumber" },
1138
  { cascade_copy => 0, cascade_delete => 0 },
1139
);
1140
1141
=head2 patron_lists_owners
907
1142
908
Type: has_many
1143
Type: has_many
909
1144
Lines 912-924 Related object: L<Koha::Schema::Result::PatronList> Link Here
912
=cut
1147
=cut
913
1148
914
__PACKAGE__->has_many(
1149
__PACKAGE__->has_many(
915
  "patron_lists",
1150
  "patron_lists_owners",
916
  "Koha::Schema::Result::PatronList",
1151
  "Koha::Schema::Result::PatronList",
917
  { "foreign.owner" => "self.borrowernumber" },
1152
  { "foreign.owner" => "self.borrowernumber" },
918
  { cascade_copy => 0, cascade_delete => 0 },
1153
  { cascade_copy => 0, cascade_delete => 0 },
919
);
1154
);
920
1155
921
=head2 patroncards
1156
=head2 patron_lists_owners
1157
1158
Type: has_many
1159
1160
Related object: L<Koha::Schema::Result::PatronList>
1161
1162
=cut
1163
1164
__PACKAGE__->has_many(
1165
  "patron_lists_owners",
1166
  "Koha::Schema::Result::PatronList",
1167
  { "foreign.owner" => "self.borrowernumber" },
1168
  { cascade_copy => 0, cascade_delete => 0 },
1169
);
1170
1171
=head2 patroncards_borrowernumbers
1172
1173
Type: has_many
1174
1175
Related object: L<Koha::Schema::Result::Patroncard>
1176
1177
=cut
1178
1179
__PACKAGE__->has_many(
1180
  "patroncards_borrowernumbers",
1181
  "Koha::Schema::Result::Patroncard",
1182
  { "foreign.borrowernumber" => "self.borrowernumber" },
1183
  { cascade_copy => 0, cascade_delete => 0 },
1184
);
1185
1186
=head2 patroncards_borrowernumbers
922
1187
923
Type: has_many
1188
Type: has_many
924
1189
Lines 927-939 Related object: L<Koha::Schema::Result::Patroncard> Link Here
927
=cut
1192
=cut
928
1193
929
__PACKAGE__->has_many(
1194
__PACKAGE__->has_many(
930
  "patroncards",
1195
  "patroncards_borrowernumbers",
931
  "Koha::Schema::Result::Patroncard",
1196
  "Koha::Schema::Result::Patroncard",
932
  { "foreign.borrowernumber" => "self.borrowernumber" },
1197
  { "foreign.borrowernumber" => "self.borrowernumber" },
933
  { cascade_copy => 0, cascade_delete => 0 },
1198
  { cascade_copy => 0, cascade_delete => 0 },
934
);
1199
);
935
1200
936
=head2 patronimage
1201
=head2 patronimage_borrowernumber
1202
1203
Type: might_have
1204
1205
Related object: L<Koha::Schema::Result::Patronimage>
1206
1207
=cut
1208
1209
__PACKAGE__->might_have(
1210
  "patronimage_borrowernumber",
1211
  "Koha::Schema::Result::Patronimage",
1212
  { "foreign.borrowernumber" => "self.borrowernumber" },
1213
  { cascade_copy => 0, cascade_delete => 0 },
1214
);
1215
1216
=head2 patronimage_borrowernumber
937
1217
938
Type: might_have
1218
Type: might_have
939
1219
Lines 942-954 Related object: L<Koha::Schema::Result::Patronimage> Link Here
942
=cut
1222
=cut
943
1223
944
__PACKAGE__->might_have(
1224
__PACKAGE__->might_have(
945
  "patronimage",
1225
  "patronimage_borrowernumber",
946
  "Koha::Schema::Result::Patronimage",
1226
  "Koha::Schema::Result::Patronimage",
947
  { "foreign.borrowernumber" => "self.borrowernumber" },
1227
  { "foreign.borrowernumber" => "self.borrowernumber" },
948
  { cascade_copy => 0, cascade_delete => 0 },
1228
  { cascade_copy => 0, cascade_delete => 0 },
949
);
1229
);
950
1230
951
=head2 ratings
1231
=head2 ratings_borrowernumbers
952
1232
953
Type: has_many
1233
Type: has_many
954
1234
Lines 957-969 Related object: L<Koha::Schema::Result::Rating> Link Here
957
=cut
1237
=cut
958
1238
959
__PACKAGE__->has_many(
1239
__PACKAGE__->has_many(
960
  "ratings",
1240
  "ratings_borrowernumbers",
961
  "Koha::Schema::Result::Rating",
1241
  "Koha::Schema::Result::Rating",
962
  { "foreign.borrowernumber" => "self.borrowernumber" },
1242
  { "foreign.borrowernumber" => "self.borrowernumber" },
963
  { cascade_copy => 0, cascade_delete => 0 },
1243
  { cascade_copy => 0, cascade_delete => 0 },
964
);
1244
);
965
1245
966
=head2 reserves
1246
=head2 ratings_borrowernumbers
1247
1248
Type: has_many
1249
1250
Related object: L<Koha::Schema::Result::Rating>
1251
1252
=cut
1253
1254
__PACKAGE__->has_many(
1255
  "ratings_borrowernumbers",
1256
  "Koha::Schema::Result::Rating",
1257
  { "foreign.borrowernumber" => "self.borrowernumber" },
1258
  { cascade_copy => 0, cascade_delete => 0 },
1259
);
1260
1261
=head2 reserves_borrowernumbers
967
1262
968
Type: has_many
1263
Type: has_many
969
1264
Lines 972-984 Related object: L<Koha::Schema::Result::Reserve> Link Here
972
=cut
1267
=cut
973
1268
974
__PACKAGE__->has_many(
1269
__PACKAGE__->has_many(
975
  "reserves",
1270
  "reserves_borrowernumbers",
976
  "Koha::Schema::Result::Reserve",
1271
  "Koha::Schema::Result::Reserve",
977
  { "foreign.borrowernumber" => "self.borrowernumber" },
1272
  { "foreign.borrowernumber" => "self.borrowernumber" },
978
  { cascade_copy => 0, cascade_delete => 0 },
1273
  { cascade_copy => 0, cascade_delete => 0 },
979
);
1274
);
980
1275
981
=head2 reviews
1276
=head2 reserves_borrowernumbers
1277
1278
Type: has_many
1279
1280
Related object: L<Koha::Schema::Result::Reserve>
1281
1282
=cut
1283
1284
__PACKAGE__->has_many(
1285
  "reserves_borrowernumbers",
1286
  "Koha::Schema::Result::Reserve",
1287
  { "foreign.borrowernumber" => "self.borrowernumber" },
1288
  { cascade_copy => 0, cascade_delete => 0 },
1289
);
1290
1291
=head2 reviews_borrowernumbers
982
1292
983
Type: has_many
1293
Type: has_many
984
1294
Lines 987-999 Related object: L<Koha::Schema::Result::Review> Link Here
987
=cut
1297
=cut
988
1298
989
__PACKAGE__->has_many(
1299
__PACKAGE__->has_many(
990
  "reviews",
1300
  "reviews_borrowernumbers",
991
  "Koha::Schema::Result::Review",
1301
  "Koha::Schema::Result::Review",
992
  { "foreign.borrowernumber" => "self.borrowernumber" },
1302
  { "foreign.borrowernumber" => "self.borrowernumber" },
993
  { cascade_copy => 0, cascade_delete => 0 },
1303
  { cascade_copy => 0, cascade_delete => 0 },
994
);
1304
);
995
1305
996
=head2 subscriptionroutinglists
1306
=head2 reviews_borrowernumbers
1307
1308
Type: has_many
1309
1310
Related object: L<Koha::Schema::Result::Review>
1311
1312
=cut
1313
1314
__PACKAGE__->has_many(
1315
  "reviews_borrowernumbers",
1316
  "Koha::Schema::Result::Review",
1317
  { "foreign.borrowernumber" => "self.borrowernumber" },
1318
  { cascade_copy => 0, cascade_delete => 0 },
1319
);
1320
1321
=head2 subscriptionroutinglist_borrowernumbers
1322
1323
Type: has_many
1324
1325
Related object: L<Koha::Schema::Result::Subscriptionroutinglist>
1326
1327
=cut
1328
1329
__PACKAGE__->has_many(
1330
  "subscriptionroutinglist_borrowernumbers",
1331
  "Koha::Schema::Result::Subscriptionroutinglist",
1332
  { "foreign.borrowernumber" => "self.borrowernumber" },
1333
  { cascade_copy => 0, cascade_delete => 0 },
1334
);
1335
1336
=head2 subscriptionroutinglist_borrowernumbers
997
1337
998
Type: has_many
1338
Type: has_many
999
1339
Lines 1002-1014 Related object: L<Koha::Schema::Result::Subscriptionroutinglist> Link Here
1002
=cut
1342
=cut
1003
1343
1004
__PACKAGE__->has_many(
1344
__PACKAGE__->has_many(
1005
  "subscriptionroutinglists",
1345
  "subscriptionroutinglist_borrowernumbers",
1006
  "Koha::Schema::Result::Subscriptionroutinglist",
1346
  "Koha::Schema::Result::Subscriptionroutinglist",
1007
  { "foreign.borrowernumber" => "self.borrowernumber" },
1347
  { "foreign.borrowernumber" => "self.borrowernumber" },
1008
  { cascade_copy => 0, cascade_delete => 0 },
1348
  { cascade_copy => 0, cascade_delete => 0 },
1009
);
1349
);
1010
1350
1011
=head2 tags_all
1351
=head2 tags_all_borrowernumbers
1012
1352
1013
Type: has_many
1353
Type: has_many
1014
1354
Lines 1017-1029 Related object: L<Koha::Schema::Result::TagAll> Link Here
1017
=cut
1357
=cut
1018
1358
1019
__PACKAGE__->has_many(
1359
__PACKAGE__->has_many(
1020
  "tags_all",
1360
  "tags_all_borrowernumbers",
1021
  "Koha::Schema::Result::TagAll",
1361
  "Koha::Schema::Result::TagAll",
1022
  { "foreign.borrowernumber" => "self.borrowernumber" },
1362
  { "foreign.borrowernumber" => "self.borrowernumber" },
1023
  { cascade_copy => 0, cascade_delete => 0 },
1363
  { cascade_copy => 0, cascade_delete => 0 },
1024
);
1364
);
1025
1365
1026
=head2 tags_approvals
1366
=head2 tags_all_borrowernumbers
1367
1368
Type: has_many
1369
1370
Related object: L<Koha::Schema::Result::TagAll>
1371
1372
=cut
1373
1374
__PACKAGE__->has_many(
1375
  "tags_all_borrowernumbers",
1376
  "Koha::Schema::Result::TagAll",
1377
  { "foreign.borrowernumber" => "self.borrowernumber" },
1378
  { cascade_copy => 0, cascade_delete => 0 },
1379
);
1380
1381
=head2 tags_approvals_approved_by
1382
1383
Type: has_many
1384
1385
Related object: L<Koha::Schema::Result::TagsApproval>
1386
1387
=cut
1388
1389
__PACKAGE__->has_many(
1390
  "tags_approvals_approved_by",
1391
  "Koha::Schema::Result::TagsApproval",
1392
  { "foreign.approved_by" => "self.borrowernumber" },
1393
  { cascade_copy => 0, cascade_delete => 0 },
1394
);
1395
1396
=head2 tags_approvals_approved_by
1027
1397
1028
Type: has_many
1398
Type: has_many
1029
1399
Lines 1032-1044 Related object: L<Koha::Schema::Result::TagsApproval> Link Here
1032
=cut
1402
=cut
1033
1403
1034
__PACKAGE__->has_many(
1404
__PACKAGE__->has_many(
1035
  "tags_approvals",
1405
  "tags_approvals_approved_by",
1036
  "Koha::Schema::Result::TagsApproval",
1406
  "Koha::Schema::Result::TagsApproval",
1037
  { "foreign.approved_by" => "self.borrowernumber" },
1407
  { "foreign.approved_by" => "self.borrowernumber" },
1038
  { cascade_copy => 0, cascade_delete => 0 },
1408
  { cascade_copy => 0, cascade_delete => 0 },
1039
);
1409
);
1040
1410
1041
=head2 user_permissions
1411
=head2 user_permissions_borrowernumbers
1042
1412
1043
Type: has_many
1413
Type: has_many
1044
1414
Lines 1047-1059 Related object: L<Koha::Schema::Result::UserPermission> Link Here
1047
=cut
1417
=cut
1048
1418
1049
__PACKAGE__->has_many(
1419
__PACKAGE__->has_many(
1050
  "user_permissions",
1420
  "user_permissions_borrowernumbers",
1051
  "Koha::Schema::Result::UserPermission",
1421
  "Koha::Schema::Result::UserPermission",
1052
  { "foreign.borrowernumber" => "self.borrowernumber" },
1422
  { "foreign.borrowernumber" => "self.borrowernumber" },
1053
  { cascade_copy => 0, cascade_delete => 0 },
1423
  { cascade_copy => 0, cascade_delete => 0 },
1054
);
1424
);
1055
1425
1056
=head2 virtualshelfcontents
1426
=head2 user_permissions_borrowernumbers
1427
1428
Type: has_many
1429
1430
Related object: L<Koha::Schema::Result::UserPermission>
1431
1432
=cut
1433
1434
__PACKAGE__->has_many(
1435
  "user_permissions_borrowernumbers",
1436
  "Koha::Schema::Result::UserPermission",
1437
  { "foreign.borrowernumber" => "self.borrowernumber" },
1438
  { cascade_copy => 0, cascade_delete => 0 },
1439
);
1440
1441
=head2 virtualshelfcontents_borrowernumbers
1057
1442
1058
Type: has_many
1443
Type: has_many
1059
1444
Lines 1062-1137 Related object: L<Koha::Schema::Result::Virtualshelfcontent> Link Here
1062
=cut
1447
=cut
1063
1448
1064
__PACKAGE__->has_many(
1449
__PACKAGE__->has_many(
1065
  "virtualshelfcontents",
1450
  "virtualshelfcontents_borrowernumbers",
1066
  "Koha::Schema::Result::Virtualshelfcontent",
1451
  "Koha::Schema::Result::Virtualshelfcontent",
1067
  { "foreign.borrowernumber" => "self.borrowernumber" },
1452
  { "foreign.borrowernumber" => "self.borrowernumber" },
1068
  { cascade_copy => 0, cascade_delete => 0 },
1453
  { cascade_copy => 0, cascade_delete => 0 },
1069
);
1454
);
1070
1455
1071
=head2 virtualshelfshares
1456
=head2 virtualshelfcontents_borrowernumbers
1072
1457
1073
Type: has_many
1458
Type: has_many
1074
1459
1075
Related object: L<Koha::Schema::Result::Virtualshelfshare>
1460
Related object: L<Koha::Schema::Result::Virtualshelfcontent>
1076
1461
1077
=cut
1462
=cut
1078
1463
1079
__PACKAGE__->has_many(
1464
__PACKAGE__->has_many(
1080
  "virtualshelfshares",
1465
  "virtualshelfcontents_borrowernumbers",
1081
  "Koha::Schema::Result::Virtualshelfshare",
1466
  "Koha::Schema::Result::Virtualshelfcontent",
1082
  { "foreign.borrowernumber" => "self.borrowernumber" },
1467
  { "foreign.borrowernumber" => "self.borrowernumber" },
1083
  { cascade_copy => 0, cascade_delete => 0 },
1468
  { cascade_copy => 0, cascade_delete => 0 },
1084
);
1469
);
1085
1470
1086
=head2 virtualshelves
1471
=head2 virtualshelfshares_borrowernumbers
1087
1472
1088
Type: has_many
1473
Type: has_many
1089
1474
1090
Related object: L<Koha::Schema::Result::Virtualshelve>
1475
Related object: L<Koha::Schema::Result::Virtualshelfshare>
1091
1476
1092
=cut
1477
=cut
1093
1478
1094
__PACKAGE__->has_many(
1479
__PACKAGE__->has_many(
1095
  "virtualshelves",
1480
  "virtualshelfshares_borrowernumbers",
1096
  "Koha::Schema::Result::Virtualshelve",
1481
  "Koha::Schema::Result::Virtualshelfshare",
1097
  { "foreign.owner" => "self.borrowernumber" },
1482
  { "foreign.borrowernumber" => "self.borrowernumber" },
1098
  { cascade_copy => 0, cascade_delete => 0 },
1483
  { cascade_copy => 0, cascade_delete => 0 },
1099
);
1484
);
1100
1485
1101
=head2 basketnoes
1486
=head2 virtualshelfshares_borrowernumbers
1102
1487
1103
Type: many_to_many
1488
Type: has_many
1104
1489
1105
Composing rels: L</aqbasketusers> -> basketno
1490
Related object: L<Koha::Schema::Result::Virtualshelfshare>
1106
1491
1107
=cut
1492
=cut
1108
1493
1109
__PACKAGE__->many_to_many("basketnoes", "aqbasketusers", "basketno");
1494
__PACKAGE__->has_many(
1495
  "virtualshelfshares_borrowernumbers",
1496
  "Koha::Schema::Result::Virtualshelfshare",
1497
  { "foreign.borrowernumber" => "self.borrowernumber" },
1498
  { cascade_copy => 0, cascade_delete => 0 },
1499
);
1110
1500
1111
=head2 budgets
1501
=head2 virtualshelves_owners
1112
1502
1113
Type: many_to_many
1503
Type: has_many
1114
1504
1115
Composing rels: L</aqbudgetborrowers> -> budget
1505
Related object: L<Koha::Schema::Result::Virtualshelve>
1116
1506
1117
=cut
1507
=cut
1118
1508
1119
__PACKAGE__->many_to_many("budgets", "aqbudgetborrowers", "budget");
1509
__PACKAGE__->has_many(
1510
  "virtualshelves_owners",
1511
  "Koha::Schema::Result::Virtualshelve",
1512
  { "foreign.owner" => "self.borrowernumber" },
1513
  { cascade_copy => 0, cascade_delete => 0 },
1514
);
1120
1515
1121
=head2 courses
1516
=head2 virtualshelves_owners
1122
1517
1123
Type: many_to_many
1518
Type: has_many
1124
1519
1125
Composing rels: L</course_instructors> -> course
1520
Related object: L<Koha::Schema::Result::Virtualshelve>
1126
1521
1127
=cut
1522
=cut
1128
1523
1129
__PACKAGE__->many_to_many("courses", "course_instructors", "course");
1524
__PACKAGE__->has_many(
1525
  "virtualshelves_owners",
1526
  "Koha::Schema::Result::Virtualshelve",
1527
  { "foreign.owner" => "self.borrowernumber" },
1528
  { cascade_copy => 0, cascade_delete => 0 },
1529
);
1130
1530
1131
1531
1132
# Created by DBIx::Class::Schema::Loader v0.07039 @ 2014-12-31 14:08:18
1532
# Created by DBIx::Class::Schema::Loader v0.07039 @ 2014-12-31 14:08:18
1133
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:mOTD/GsDpo3RPjUjTHrLRQ
1533
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:mOTD/GsDpo3RPjUjTHrLRQ
1134
1534
1535
sub FirstValidEmailAddress {
1536
    my ( $self ) = @_;
1537
1538
    return $self->email() || $self->emailpro() || $self->b_email() || q{};
1539
}
1540
1541
sub ClubsEnrolledCount {
1542
    my ( $self ) = @_;
1543
1544
    return $self->club_enrollments({ date_canceled => undef })->count();
1545
}
1546
1547
sub ClubsEnrollableCount {
1548
    my ( $self, $is_enrollable_from_opac ) = @_;
1549
1550
    my $params;
1551
    $params->{is_enrollable_from_opac} = $is_enrollable_from_opac
1552
      if $is_enrollable_from_opac;
1553
    $params->{is_email_required} = 0 unless $self->FirstValidEmailAddress();
1554
1555
    return $self->result_source->schema->resultset('Club')
1556
      ->search( $params, { prefetch => 'club_template' } )->count();
1557
}
1135
1558
1136
# You can replace this text with custom content, and it will be preserved on regeneration
1137
1;
1559
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 59-62 sub Version { Link Here
59
    };
59
    };
60
}
60
}
61
61
62
sub UserEnv {
63
    my ( $self, $key ) = @_;
64
    my $userenv = C4::Context->userenv;
65
    return $userenv ? $userenv->{$key} : undef;
66
}
62
1;
67
1;
(-)a/circ/circulation.pl (+3 lines)
Lines 617-622 $template->param( picture => 1 ) if $picture; Link Here
617
617
618
my $canned_notes = GetAuthorisedValues("BOR_NOTES");
618
my $canned_notes = GetAuthorisedValues("BOR_NOTES");
619
619
620
my $schema = Koha::Database->new()->schema();
621
620
$template->param(
622
$template->param(
621
    debt_confirmed            => $debt_confirmed,
623
    debt_confirmed            => $debt_confirmed,
622
    SpecifyDueDate            => $duedatespec_allow,
624
    SpecifyDueDate            => $duedatespec_allow,
Lines 625-630 $template->param( Link Here
625
    canned_bor_notes_loop     => $canned_notes,
627
    canned_bor_notes_loop     => $canned_notes,
626
    debarments                => GetDebarments({ borrowernumber => $borrowernumber }),
628
    debarments                => GetDebarments({ borrowernumber => $borrowernumber }),
627
    todaysdate                => dt_from_string()->set(hour => 23)->set(minute => 59),
629
    todaysdate                => dt_from_string()->set(hour => 23)->set(minute => 59),
630
    borrower                  => $schema->resultset('Borrower')->find( $borrowernumber ),
628
);
631
);
629
632
630
output_html_with_http_headers $query, $cookie, $template->output;
633
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 72-75 INSERT INTO permissions (module_bit, code, description) VALUES Link Here
72
   (19, 'tool', 'Use tool plugins'),
72
   (19, 'tool', 'Use tool plugins'),
73
   (19, 'report', 'Use report plugins'),
73
   (19, 'report', 'Use report plugins'),
74
   (19, 'configure', 'Configure plugins')
74
   (19, 'configure', 'Configure plugins')
75
   (20, 'edit_templates', 'Create and update club templates'),
76
   (20, 'edit_clubs', 'Create and update clubs'),
77
   (20, 'enroll', 'Enroll patrons in clubs')
75
;
78
;
(-)a/installer/data/mysql/kohastructure.sql (+174 lines)
Lines 3502-3507 CREATE TABLE items_search_fields ( Link Here
3502
    ON DELETE SET NULL ON UPDATE CASCADE
3502
    ON DELETE SET NULL ON UPDATE CASCADE
3503
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
3503
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
3504
3504
3505
--
3506
-- Table structure for table 'clubs'
3507
--
3508
3509
CREATE TABLE clubs (
3510
    id int(11) NOT NULL AUTO_INCREMENT,
3511
    club_template int(11) NOT NULL,
3512
    `name` tinytext NOT NULL,
3513
    description text,
3514
    date_start date DEFAULT NULL,
3515
    date_end date DEFAULT NULL,
3516
    branch varchar(11) DEFAULT NULL,
3517
    date_created timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
3518
    date_updated timestamp NULL DEFAULT NULL,
3519
    PRIMARY KEY (id),
3520
    KEY club_template (club_template),
3521
    KEY branch (branch)
3522
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
3523
3524
-- --------------------------------------------------------
3525
3526
--
3527
-- Table structure for table 'club_enrollments'
3528
--
3529
3530
CREATE TABLE club_enrollments (
3531
    id int(11) NOT NULL AUTO_INCREMENT,
3532
    club int(11) NOT NULL,
3533
    borrower int(11) NOT NULL,
3534
    date_enrolled timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
3535
    date_canceled timestamp NULL DEFAULT NULL,
3536
    date_created timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
3537
    date_updated timestamp NULL DEFAULT NULL,
3538
    branch varchar(11) DEFAULT NULL,
3539
    PRIMARY KEY (id),
3540
    KEY club (club),
3541
    KEY borrower (borrower),
3542
    KEY branch (branch)
3543
) ENGINE=InnoDB  DEFAULT CHARSET=utf8;
3544
3545
-- --------------------------------------------------------
3546
3547
--
3548
-- Table structure for table 'club_enrollment_fields'
3549
--
3550
3551
CREATE TABLE club_enrollment_fields (
3552
    id int(11) NOT NULL AUTO_INCREMENT,
3553
    club_enrollment int(11) NOT NULL,
3554
    club_template_enrollment_field int(11) NOT NULL,
3555
    `value` text NOT NULL,
3556
    PRIMARY KEY (id),
3557
    KEY club_enrollment (club_enrollment),
3558
    KEY club_template_enrollment_field (club_template_enrollment_field),
3559
    KEY club_template_enrollment_field_2 (club_template_enrollment_field)
3560
) ENGINE=InnoDB  DEFAULT CHARSET=utf8;
3561
3562
-- --------------------------------------------------------
3563
3564
--
3565
-- Table structure for table 'club_fields'
3566
--
3567
3568
CREATE TABLE club_fields (
3569
    id int(11) NOT NULL AUTO_INCREMENT,
3570
    club_template_field int(11) NOT NULL,
3571
    club int(11) NOT NULL,
3572
    `value` text,
3573
    PRIMARY KEY (id),
3574
    KEY club_template_field (club_template_field,club),
3575
    KEY club (club)
3576
) ENGINE=InnoDB  DEFAULT CHARSET=utf8;
3577
3578
-- --------------------------------------------------------
3579
3580
--
3581
-- Table structure for table 'club_templates'
3582
--
3583
3584
CREATE TABLE club_templates (
3585
    id int(11) NOT NULL AUTO_INCREMENT,
3586
    `name` tinytext NOT NULL,
3587
    description text,
3588
    is_enrollable_from_opac tinyint(1) NOT NULL DEFAULT '0',
3589
    is_email_required tinyint(1) NOT NULL DEFAULT '0',
3590
    branch varchar(10) CHARACTER SET utf8 DEFAULT NULL,
3591
    date_created timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
3592
    date_updated timestamp NULL DEFAULT NULL,
3593
    is_deletable tinyint(1) NOT NULL DEFAULT '1',
3594
    PRIMARY KEY (id),
3595
    KEY branch (branch)
3596
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
3597
3598
-- --------------------------------------------------------
3599
3600
--
3601
-- Table structure for table 'club_template_enrollment_fields'
3602
--
3603
3604
CREATE TABLE club_template_enrollment_fields (
3605
    id int(11) NOT NULL AUTO_INCREMENT,
3606
    club_template int(11) NOT NULL,
3607
    `name` tinytext NOT NULL,
3608
    description text,
3609
    authorised_value_category varchar(16) DEFAULT NULL,
3610
    PRIMARY KEY (id),
3611
    KEY club_template (club_template),
3612
    KEY club_template_2 (club_template)
3613
) ENGINE=InnoDB  DEFAULT CHARSET=utf8;
3614
3615
-- --------------------------------------------------------
3616
3617
--
3618
-- Table structure for table 'club_template_fields'
3619
--
3620
3621
CREATE TABLE club_template_fields (
3622
    id int(11) NOT NULL AUTO_INCREMENT,
3623
    club_template int(11) NOT NULL,
3624
    `name` tinytext NOT NULL,
3625
    description text,
3626
    authorised_value_category varchar(16) DEFAULT NULL,
3627
    PRIMARY KEY (id),
3628
    KEY club_template (club_template)
3629
) ENGINE=InnoDB  DEFAULT CHARSET=utf8;
3630
3631
--
3632
-- Constraints for table `clubs`
3633
--
3634
ALTER TABLE `clubs`
3635
ADD CONSTRAINT clubs_ibfk_1 FOREIGN KEY (club_template) REFERENCES club_templates (id) ON DELETE CASCADE ON UPDATE CASCADE,
3636
ADD CONSTRAINT clubs_ibfk_2 FOREIGN KEY (branch) REFERENCES branches (branchcode);
3637
3638
--
3639
-- Constraints for table `club_enrollments`
3640
--
3641
ALTER TABLE `club_enrollments`
3642
ADD CONSTRAINT club_enrollments_ibfk_1 FOREIGN KEY (club) REFERENCES clubs (id) ON DELETE CASCADE ON UPDATE CASCADE,
3643
ADD CONSTRAINT club_enrollments_ibfk_2 FOREIGN KEY (borrower) REFERENCES borrowers (borrowernumber) ON DELETE CASCADE ON UPDATE CASCADE,
3644
ADD CONSTRAINT club_enrollments_ibfk_3 FOREIGN KEY (branch) REFERENCES branches (branchcode) ON DELETE SET NULL ON UPDATE CASCADE;
3645
3646
--
3647
-- Constraints for table `club_enrollment_fields`
3648
--
3649
ALTER TABLE `club_enrollment_fields`
3650
ADD CONSTRAINT club_enrollment_fields_ibfk_1 FOREIGN KEY (club_enrollment) REFERENCES club_enrollments (id) ON DELETE CASCADE ON UPDATE CASCADE,
3651
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;
3652
3653
--
3654
-- Constraints for table `club_fields`
3655
--
3656
ALTER TABLE `club_fields`
3657
ADD CONSTRAINT club_fields_ibfk_3 FOREIGN KEY (club_template_field) REFERENCES club_template_fields (id) ON DELETE CASCADE ON UPDATE CASCADE,
3658
ADD CONSTRAINT club_fields_ibfk_4 FOREIGN KEY (club) REFERENCES clubs (id) ON DELETE CASCADE ON UPDATE CASCADE;
3659
3660
--
3661
-- Constraints for table `club_templates`
3662
--
3663
ALTER TABLE `club_templates`
3664
ADD CONSTRAINT club_templates_ibfk_1 FOREIGN KEY (branch) REFERENCES branches (branchcode) ON DELETE SET NULL ON UPDATE CASCADE;
3665
3666
--
3667
-- Constraints for table `club_template_enrollment_fields`
3668
--
3669
ALTER TABLE `club_template_enrollment_fields`
3670
ADD CONSTRAINT club_template_enrollment_fields_ibfk_1 FOREIGN KEY (club_template) REFERENCES club_templates (id) ON DELETE CASCADE ON UPDATE CASCADE;
3671
3672
--
3673
-- Constraints for table `club_template_fields`
3674
--
3675
ALTER TABLE `club_template_fields`
3676
ADD CONSTRAINT club_template_fields_ibfk_1 FOREIGN KEY (club_template) REFERENCES club_templates (id) ON DELETE CASCADE ON UPDATE CASCADE;
3677
3678
>>>>>>> Bug 12461 - Add patron clubs feature
3505
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
3679
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
3506
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
3680
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
3507
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
3681
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
(-)a/installer/data/mysql/updatedatabase.pl (+149 lines)
Lines 9656-9661 if(CheckVersion($DBversion)) { Link Here
9656
    SetVersion($DBversion);
9656
    SetVersion($DBversion);
9657
}
9657
}
9658
9658
9659
$DBversion = "3.19.00.XXX";
9660
if ( CheckVersion($DBversion) ) {
9661
    $dbh->do("INSERT INTO userflags (bit, flag, flagdesc, defaulton) VALUES ('20', 'clubs', 'Patron clubs', '0')");
9662
9663
    $dbh->do("
9664
        CREATE TABLE clubs (
9665
            id int(11) NOT NULL AUTO_INCREMENT,
9666
            club_template int(11) NOT NULL,
9667
            `name` tinytext NOT NULL,
9668
            description text,
9669
            date_start date DEFAULT NULL,
9670
            date_end date DEFAULT NULL,
9671
            branch varchar(11) DEFAULT NULL,
9672
            date_created timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
9673
            date_updated timestamp NULL DEFAULT NULL,
9674
            PRIMARY KEY (id),
9675
            KEY club_template (club_template),
9676
            KEY branch (branch)
9677
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
9678
    ");
9679
9680
    $dbh->do("
9681
        CREATE TABLE club_enrollments (
9682
            id int(11) NOT NULL AUTO_INCREMENT,
9683
            club int(11) NOT NULL,
9684
            borrower int(11) NOT NULL,
9685
            date_enrolled timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
9686
            date_canceled timestamp NULL DEFAULT NULL,
9687
            date_created timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
9688
            date_updated timestamp NULL DEFAULT NULL,
9689
            branch varchar(11) DEFAULT NULL,
9690
            PRIMARY KEY (id),
9691
            KEY club (club),
9692
            KEY borrower (borrower),
9693
            KEY branch (branch)
9694
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
9695
    ");
9696
9697
    $dbh->do("
9698
        CREATE TABLE club_enrollment_fields (
9699
            id int(11) NOT NULL AUTO_INCREMENT,
9700
            club_enrollment int(11) NOT NULL,
9701
            club_template_enrollment_field int(11) NOT NULL,
9702
            `value` text NOT NULL,
9703
            PRIMARY KEY (id),
9704
            KEY club_enrollment (club_enrollment),
9705
            KEY club_template_enrollment_field (club_template_enrollment_field),
9706
            KEY club_template_enrollment_field_2 (club_template_enrollment_field)
9707
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
9708
    ");
9709
9710
    $dbh->do("
9711
        CREATE TABLE club_fields (
9712
            id int(11) NOT NULL AUTO_INCREMENT,
9713
            club_template_field int(11) NOT NULL,
9714
            club int(11) NOT NULL,
9715
            `value` text,
9716
            PRIMARY KEY (id),
9717
            KEY club_template_field (club_template_field,club),
9718
            KEY club (club)
9719
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
9720
    ");
9721
9722
    $dbh->do("
9723
        CREATE TABLE club_templates (
9724
            id int(11) NOT NULL AUTO_INCREMENT,
9725
            `name` tinytext NOT NULL,
9726
            description text,
9727
            is_enrollable_from_opac tinyint(1) NOT NULL DEFAULT '0',
9728
            is_email_required tinyint(1) NOT NULL DEFAULT '0',
9729
            branch varchar(10) CHARACTER SET utf8 DEFAULT NULL,
9730
            date_created timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
9731
            date_updated timestamp NULL DEFAULT NULL,
9732
            is_deletable tinyint(1) NOT NULL DEFAULT '1',
9733
            PRIMARY KEY (id),
9734
            KEY branch (branch)
9735
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8 DEFAULT;
9736
    ");
9737
9738
    $dbh->do("
9739
        CREATE TABLE club_template_enrollment_fields (
9740
            id int(11) NOT NULL AUTO_INCREMENT,
9741
            club_template int(11) NOT NULL,
9742
            `name` tinytext NOT NULL,
9743
            description text,
9744
            authorised_value_category varchar(16) DEFAULT NULL,
9745
            PRIMARY KEY (id),
9746
            KEY club_template (club_template),
9747
            KEY club_template_2 (club_template)
9748
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
9749
    ");
9750
9751
    $dbh->do("
9752
        CREATE TABLE club_template_fields (
9753
            id int(11) NOT NULL AUTO_INCREMENT,
9754
            club_template int(11) NOT NULL,
9755
            `name` tinytext NOT NULL,
9756
            description text,
9757
            authorised_value_category varchar(16) DEFAULT NULL,
9758
            PRIMARY KEY (id),
9759
            KEY club_template (club_template)
9760
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
9761
    ");
9762
9763
    $dbh->do("
9764
        ALTER TABLE `clubs`
9765
            ADD CONSTRAINT clubs_ibfk_1 FOREIGN KEY (club_template) REFERENCES club_templates (id) ON DELETE CASCADE ON UPDATE CASCADE,
9766
            ADD CONSTRAINT clubs_ibfk_2 FOREIGN KEY (branch) REFERENCES branches (branchcode);
9767
    ");
9768
9769
    $dbh->do("
9770
        ALTER TABLE `club_enrollments`
9771
            ADD CONSTRAINT club_enrollments_ibfk_1 FOREIGN KEY (club) REFERENCES clubs (id) ON DELETE CASCADE ON UPDATE CASCADE,
9772
            ADD CONSTRAINT club_enrollments_ibfk_2 FOREIGN KEY (borrower) REFERENCES borrowers (borrowernumber) ON DELETE CASCADE ON UPDATE CASCADE,
9773
            ADD CONSTRAINT club_enrollments_ibfk_3 FOREIGN KEY (branch) REFERENCES branches (branchcode) ON DELETE SET NULL ON UPDATE CASCADE;
9774
    ");
9775
9776
    $dbh->do("
9777
        ALTER TABLE `club_enrollment_fields`
9778
            ADD CONSTRAINT club_enrollment_fields_ibfk_1 FOREIGN KEY (club_enrollment) REFERENCES club_enrollments (id) ON DELETE CASCADE ON UPDATE CASCADE,
9779
            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;
9780
    ");
9781
9782
    $dbh->do("
9783
        ALTER TABLE `club_fields`
9784
            ADD CONSTRAINT club_fields_ibfk_3 FOREIGN KEY (club_template_field) REFERENCES club_template_fields (id) ON DELETE CASCADE ON UPDATE CASCADE,
9785
            ADD CONSTRAINT club_fields_ibfk_4 FOREIGN KEY (club) REFERENCES clubs (id) ON DELETE CASCADE ON UPDATE CASCADE;
9786
    ");
9787
9788
    $dbh->do("
9789
        ALTER TABLE `club_templates`
9790
            ADD CONSTRAINT club_templates_ibfk_1 FOREIGN KEY (branch) REFERENCES branches (branchcode) ON DELETE SET NULL ON UPDATE CASCADE;
9791
    ");
9792
9793
    $dbh->do("
9794
        ALTER TABLE `club_template_enrollment_fields`
9795
            ADD CONSTRAINT club_template_enrollment_fields_ibfk_1 FOREIGN KEY (club_template) REFERENCES club_templates (id) ON DELETE CASCADE ON UPDATE CASCADE;
9796
    ");
9797
9798
    $dbh->do("
9799
        ALTER TABLE `club_template_fields`
9800
            ADD CONSTRAINT club_template_fields_ibfk_1 FOREIGN KEY (club_template) REFERENCES club_templates (id) ON DELETE CASCADE ON UPDATE CASCADE;
9801
    ");
9802
9803
   print "Upgrade to $DBversion done (Bug 12461 - Add patron clubs feature)\n";
9804
   SetVersion ($DBversion);
9805
>>>>>>> Bug 12461 - Add patron clubs feature
9806
}
9807
9659
=head1 FUNCTIONS
9808
=head1 FUNCTIONS
9660
9809
9661
=head2 TableExists($table)
9810
=head2 TableExists($table)
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt (+19 lines)
Lines 69-74 $(document).ready(function() { Link Here
69
69
70
70
71
    [% IF !( CircAutoPrintQuickSlip == 'clear' ) %]
71
    [% IF !( CircAutoPrintQuickSlip == 'clear' ) %]
72
        $('#clubs-tab-link').on('click', function() {
73
            $('#clubs-tab').text(_("Loading..."));
74
            $('#clubs-tab').load('/cgi-bin/koha/clubs/patron-clubs-tab.pl?borrowernumber=[% borrowernumber %]');
75
        });
76
72
        // listen submit to trigger qslip on empty checkout
77
        // listen submit to trigger qslip on empty checkout
73
        $('#mainform').bind('submit',function() {
78
        $('#mainform').bind('submit',function() {
74
            if ($('#barcode').val() == '') {
79
            if ($('#barcode').val() == '') {
Lines 772-777 No patron matched <span class="ex">[% message %]</span> Link Here
772
        [% END %]
777
        [% END %]
773
    </li>
778
    </li>
774
779
780
    [% IF CAN_user_clubs && ( borrower.ClubsEnrolledCount || borrower.ClubsEnrollableCount ) %]
781
        <li>
782
            <a id="clubs-tab-link" href="#clubs-tab">
783
                Clubs ([% borrower.ClubsEnrolledCount %]/[% borrower.ClubsEnrollableCount %])
784
            </a>
785
        </li>
786
    [% END %]
787
775
    [% IF relatives_issues_count %]
788
    [% IF relatives_issues_count %]
776
        <li><a id="relatives-issues-tab" href="#relatives-issues">Relatives' checkouts</a></li>
789
        <li><a id="relatives-issues-tab" href="#relatives-issues">Relatives' checkouts</a></li>
777
    [% END %]
790
    [% END %]
Lines 812-817 No patron matched <span class="ex">[% message %]</span> Link Here
812
    </div>
825
    </div>
813
[% END %]
826
[% END %]
814
827
828
[% IF CAN_user_clubs %]
829
    <div id="clubs-tab">
830
        Loading...
831
    </div>
832
[% END %]
833
815
[% INCLUDE borrower_debarments.inc %]
834
[% INCLUDE borrower_debarments.inc %]
816
835
817
<div id="reserves">
836
<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 42-47 var MSG_ADD_MESSAGE = _("Add a new message"); Link Here
42
var MSG_EXPORT_SELECT_CHECKOUTS = _("You must select checkout(s) to export");
42
var MSG_EXPORT_SELECT_CHECKOUTS = _("You must select checkout(s) to export");
43
43
44
$(document).ready(function() {
44
$(document).ready(function() {
45
    $('#clubs-tab-link').on('click', function() {
46
        $('#clubs-tab').text(_("Loading..."));
47
        $('#clubs-tab').load('/cgi-bin/koha/clubs/patron-clubs-tab.pl?borrowernumber=[% borrowernumber %]');
48
    });
49
45
    $('#finesholdsissues').tabs({
50
    $('#finesholdsissues').tabs({
46
        // Correct table sizing for tables hidden in tabs
51
        // Correct table sizing for tables hidden in tabs
47
        // http://www.datatables.net/examples/api/tabs_and_scrolling.html
52
        // http://www.datatables.net/examples/api/tabs_and_scrolling.html
Lines 424-429 function validate1(date) { Link Here
424
            [% END %]
429
            [% END %]
425
        </li>
430
        </li>
426
        <li><a id="debarments-tab-link" href="#reldebarments">[% debarments.size %] Restrictions</a></li>
431
        <li><a id="debarments-tab-link" href="#reldebarments">[% debarments.size %] Restrictions</a></li>
432
        [% IF CAN_user_clubs && ( borrower.ClubsEnrolledCount || borrower.ClubsEnrollableCount ) %]
433
            <li>
434
                <a id="clubs-tab-link" href="#clubs-tab">
435
                    Clubs ([% borrower.ClubsEnrolledCount %]/[% borrower.ClubsEnrollableCount %])
436
                </a>
437
            </li>
438
        [% END %]
427
    </ul>
439
    </ul>
428
440
429
[% INCLUDE "checkouts-table.inc" %]
441
[% INCLUDE "checkouts-table.inc" %]
Lines 456-461 function validate1(date) { Link Here
456
    [% END %]
468
    [% END %]
457
</div>
469
</div>
458
470
471
<div id="clubs-tab">
472
    Loading...
473
</div>
474
459
[% INCLUDE borrower_debarments.inc %]
475
[% INCLUDE borrower_debarments.inc %]
460
476
461
<div id="reserves">
477
<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 280-285 Link Here
280
                            [% END # IF issues_count %]
288
                            [% END # IF issues_count %]
281
                        </div> <!-- / .opac-user-checkouts -->
289
                        </div> <!-- / .opac-user-checkouts -->
282
290
291
                        <div id="opac-user-clubs">
292
                            Loading...
293
                        </div>
294
283
                        [% IF ( OPACFinesTab ) %]
295
                        [% IF ( OPACFinesTab ) %]
284
                            <!-- FINES BOX -->
296
                            <!-- FINES BOX -->
285
                            [% IF ( BORROWER_INF.amountoverfive ) %]
297
                            [% IF ( BORROWER_INF.amountoverfive ) %]
Lines 727-732 Link Here
727
            [% END %]
739
            [% END %]
728
740
729
            $( ".suspend-until" ).datepicker({ minDate: 1 }); // Require that "until date" be in the future
741
            $( ".suspend-until" ).datepicker({ minDate: 1 }); // Require that "until date" be in the future
742
743
            $('#opac-user-clubs-tab-link').on('click', function() {
744
                $('#opac-user-clubs').text(_("Loading..."));
745
                $('#opac-user-clubs').load('/cgi-bin/koha/clubs/clubs-tab.pl?borrowernumber=[% borrowernumber %]');
746
            });
730
        });
747
        });
731
        //]]>
748
        //]]>
732
    </script>
749
    </script>
(-)a/members/moremember.pl (+3 lines)
Lines 355-360 if (C4::Context->preference('EnhancedMessagingPreferences')) { Link Here
355
# Computes full borrower address
355
# Computes full borrower address
356
my $address = $data->{'streetnumber'} . " $roadtype " . $data->{'address'};
356
my $address = $data->{'streetnumber'} . " $roadtype " . $data->{'address'};
357
357
358
my $schema =  Koha::Database->new()->schema();
359
358
# in template <TMPL_IF name="I"> => instutitional (A for Adult, C for children) 
360
# in template <TMPL_IF name="I"> => instutitional (A for Adult, C for children) 
359
$template->param( $data->{'categorycode'} => 1 ); 
361
$template->param( $data->{'categorycode'} => 1 ); 
360
$template->param(
362
$template->param(
Lines 385-390 $template->param( Link Here
385
    relatives_issues_count => $relatives_issues_count,
387
    relatives_issues_count => $relatives_issues_count,
386
    relatives_borrowernumbers => \@relatives,
388
    relatives_borrowernumbers => \@relatives,
387
    address => $address
389
    address => $address
390
    borrower => $schema->resultset('Borrower')->find( $borrowernumber ),
388
);
391
);
389
392
390
output_html_with_http_headers $input, $cookie, $template->output;
393
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 36-41 use C4::Letters; Link Here
36
use C4::Branch; # GetBranches
36
use C4::Branch; # GetBranches
37
use Koha::DateUtils;
37
use Koha::DateUtils;
38
use Koha::Borrower::Debarments qw(IsDebarred);
38
use Koha::Borrower::Debarments qw(IsDebarred);
39
use Koha::Database;
40
41
my $schema = Koha::Database->new()->schema();
39
42
40
use constant ATTRIBUTE_SHOW_BARCODE => 'SHOW_BCODE';
43
use constant ATTRIBUTE_SHOW_BARCODE => 'SHOW_BCODE';
41
44
Lines 388-399 $template->param( Link Here
388
    patronupdate => $patronupdate,
391
    patronupdate => $patronupdate,
389
    OpacRenewalAllowed => C4::Context->preference("OpacRenewalAllowed"),
392
    OpacRenewalAllowed => C4::Context->preference("OpacRenewalAllowed"),
390
    userview => 1,
393
    userview => 1,
391
);
392
393
$template->param(
394
    SuspendHoldsOpac => C4::Context->preference('SuspendHoldsOpac'),
394
    SuspendHoldsOpac => C4::Context->preference('SuspendHoldsOpac'),
395
    AutoResumeSuspendedHolds => C4::Context->preference('AutoResumeSuspendedHolds'),
395
    AutoResumeSuspendedHolds => C4::Context->preference('AutoResumeSuspendedHolds'),
396
    OpacHoldNotes => C4::Context->preference('OpacHoldNotes'),
396
    OpacHoldNotes => C4::Context->preference('OpacHoldNotes'),
397
    borrower => $schema->resultset('Borrower')->find($borrowernumber),
397
);
398
);
398
399
399
output_html_with_http_headers $query, $cookie, $template->output;
400
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