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

(-)a/C4/Members.pm (-13 / +3 lines)
Lines 1474-1493 addresses. Link Here
1474
1474
1475
sub GetFirstValidEmailAddress {
1475
sub GetFirstValidEmailAddress {
1476
    my $borrowernumber = shift;
1476
    my $borrowernumber = shift;
1477
    my $dbh = C4::Context->dbh;
1478
    my $sth = $dbh->prepare( "SELECT email, emailpro, B_email FROM borrowers where borrowernumber = ? ");
1479
    $sth->execute( $borrowernumber );
1480
    my $data = $sth->fetchrow_hashref;
1481
1477
1482
    if ($data->{'email'}) {
1478
    my $borrower = Koha::Database->new()->schema()->resultset('Borrower')->find( $borrowernumber );
1483
       return $data->{'email'};
1479
1484
    } elsif ($data->{'emailpro'}) {
1480
    return $borrower->FirstValidEmailAddress();
1485
       return $data->{'emailpro'};
1486
    } elsif ($data->{'B_email'}) {
1487
       return $data->{'B_email'};
1488
    } else {
1489
       return '';
1490
    }
1491
}
1481
}
1492
1482
1493
=head2 GetNoticeEmailAddress
1483
=head2 GetNoticeEmailAddress
(-)a/Koha/Schema/Result/Borrower.pm (-109 / +549 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-627 __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
605
__PACKAGE__->add_unique_constraint("cardnumber", ["cardnumber"]);
600
__PACKAGE__->has_many(
606
601
  "accountlines_borrowernumbers",
607
=head1 RELATIONS
602
  "Koha::Schema::Result::Accountline",
603
  { "foreign.borrowernumber" => "self.borrowernumber" },
604
  { cascade_copy => 0, cascade_delete => 0 },
605
);
608
606
609
=head2 accountlines
607
=head2 accountoffsets_borrowernumbers
610
608
611
Type: has_many
609
Type: has_many
612
610
613
Related object: L<Koha::Schema::Result::Accountline>
611
Related object: L<Koha::Schema::Result::Accountoffset>
614
612
615
=cut
613
=cut
616
614
617
__PACKAGE__->has_many(
615
__PACKAGE__->has_many(
618
  "accountlines",
616
  "accountoffsets_borrowernumbers",
619
  "Koha::Schema::Result::Accountline",
617
  "Koha::Schema::Result::Accountoffset",
620
  { "foreign.borrowernumber" => "self.borrowernumber" },
618
  { "foreign.borrowernumber" => "self.borrowernumber" },
621
  { cascade_copy => 0, cascade_delete => 0 },
619
  { cascade_copy => 0, cascade_delete => 0 },
622
);
620
);
623
621
624
=head2 accountoffsets
622
=head2 accountoffsets_borrowernumbers
625
623
626
Type: has_many
624
Type: has_many
627
625
Lines 630-642 Related object: L<Koha::Schema::Result::Accountoffset> Link Here
630
=cut
628
=cut
631
629
632
__PACKAGE__->has_many(
630
__PACKAGE__->has_many(
633
  "accountoffsets",
631
  "accountoffsets_borrowernumbers",
634
  "Koha::Schema::Result::Accountoffset",
632
  "Koha::Schema::Result::Accountoffset",
635
  { "foreign.borrowernumber" => "self.borrowernumber" },
633
  { "foreign.borrowernumber" => "self.borrowernumber" },
636
  { cascade_copy => 0, cascade_delete => 0 },
634
  { cascade_copy => 0, cascade_delete => 0 },
637
);
635
);
638
636
639
=head2 aqbasketusers
637
=head2 aqbasketusers_borrowernumbers
638
639
Type: has_many
640
641
Related object: L<Koha::Schema::Result::Aqbasketuser>
642
643
=cut
644
645
__PACKAGE__->has_many(
646
  "aqbasketusers_borrowernumbers",
647
  "Koha::Schema::Result::Aqbasketuser",
648
  { "foreign.borrowernumber" => "self.borrowernumber" },
649
  { cascade_copy => 0, cascade_delete => 0 },
650
);
651
652
=head2 aqbasketusers_borrowernumbers
640
653
641
Type: has_many
654
Type: has_many
642
655
Lines 645-657 Related object: L<Koha::Schema::Result::Aqbasketuser> Link Here
645
=cut
658
=cut
646
659
647
__PACKAGE__->has_many(
660
__PACKAGE__->has_many(
648
  "aqbasketusers",
661
  "aqbasketusers_borrowernumbers",
649
  "Koha::Schema::Result::Aqbasketuser",
662
  "Koha::Schema::Result::Aqbasketuser",
650
  { "foreign.borrowernumber" => "self.borrowernumber" },
663
  { "foreign.borrowernumber" => "self.borrowernumber" },
651
  { cascade_copy => 0, cascade_delete => 0 },
664
  { cascade_copy => 0, cascade_delete => 0 },
652
);
665
);
653
666
654
=head2 aqbudgetborrowers
667
=head2 aqbudgetborrowers_borrowernumbers
668
669
Type: has_many
670
671
Related object: L<Koha::Schema::Result::Aqbudgetborrower>
672
673
=cut
674
675
__PACKAGE__->has_many(
676
  "aqbudgetborrowers_borrowernumbers",
677
  "Koha::Schema::Result::Aqbudgetborrower",
678
  { "foreign.borrowernumber" => "self.borrowernumber" },
679
  { cascade_copy => 0, cascade_delete => 0 },
680
);
681
682
=head2 aqbudgetborrowers_borrowernumbers
655
683
656
Type: has_many
684
Type: has_many
657
685
Lines 660-672 Related object: L<Koha::Schema::Result::Aqbudgetborrower> Link Here
660
=cut
688
=cut
661
689
662
__PACKAGE__->has_many(
690
__PACKAGE__->has_many(
663
  "aqbudgetborrowers",
691
  "aqbudgetborrowers_borrowernumbers",
664
  "Koha::Schema::Result::Aqbudgetborrower",
692
  "Koha::Schema::Result::Aqbudgetborrower",
665
  { "foreign.borrowernumber" => "self.borrowernumber" },
693
  { "foreign.borrowernumber" => "self.borrowernumber" },
666
  { cascade_copy => 0, cascade_delete => 0 },
694
  { cascade_copy => 0, cascade_delete => 0 },
667
);
695
);
668
696
669
=head2 borrower_attributes
697
=head2 borrower_attributes_borrowernumbers
670
698
671
Type: has_many
699
Type: has_many
672
700
Lines 675-687 Related object: L<Koha::Schema::Result::BorrowerAttribute> Link Here
675
=cut
703
=cut
676
704
677
__PACKAGE__->has_many(
705
__PACKAGE__->has_many(
678
  "borrower_attributes",
706
  "borrower_attributes_borrowernumbers",
679
  "Koha::Schema::Result::BorrowerAttribute",
707
  "Koha::Schema::Result::BorrowerAttribute",
680
  { "foreign.borrowernumber" => "self.borrowernumber" },
708
  { "foreign.borrowernumber" => "self.borrowernumber" },
681
  { cascade_copy => 0, cascade_delete => 0 },
709
  { cascade_copy => 0, cascade_delete => 0 },
682
);
710
);
683
711
684
=head2 borrower_debarments
712
=head2 borrower_attributes_borrowernumbers
713
714
Type: has_many
715
716
Related object: L<Koha::Schema::Result::BorrowerAttribute>
717
718
=cut
719
720
__PACKAGE__->has_many(
721
  "borrower_attributes_borrowernumbers",
722
  "Koha::Schema::Result::BorrowerAttribute",
723
  { "foreign.borrowernumber" => "self.borrowernumber" },
724
  { cascade_copy => 0, cascade_delete => 0 },
725
);
726
727
=head2 borrower_debarments_borrowernumbers
685
728
686
Type: has_many
729
Type: has_many
687
730
Lines 690-702 Related object: L<Koha::Schema::Result::BorrowerDebarment> Link Here
690
=cut
733
=cut
691
734
692
__PACKAGE__->has_many(
735
__PACKAGE__->has_many(
693
  "borrower_debarments",
736
  "borrower_debarments_borrowernumbers",
694
  "Koha::Schema::Result::BorrowerDebarment",
737
  "Koha::Schema::Result::BorrowerDebarment",
695
  { "foreign.borrowernumber" => "self.borrowernumber" },
738
  { "foreign.borrowernumber" => "self.borrowernumber" },
696
  { cascade_copy => 0, cascade_delete => 0 },
739
  { cascade_copy => 0, cascade_delete => 0 },
697
);
740
);
698
741
699
=head2 borrower_files
742
=head2 borrower_debarments_borrowernumbers
743
744
Type: has_many
745
746
Related object: L<Koha::Schema::Result::BorrowerDebarment>
747
748
=cut
749
750
__PACKAGE__->has_many(
751
  "borrower_debarments_borrowernumbers",
752
  "Koha::Schema::Result::BorrowerDebarment",
753
  { "foreign.borrowernumber" => "self.borrowernumber" },
754
  { cascade_copy => 0, cascade_delete => 0 },
755
);
756
757
=head2 borrower_files_borrowernumbers
758
759
Type: has_many
760
761
Related object: L<Koha::Schema::Result::BorrowerFile>
762
763
=cut
764
765
__PACKAGE__->has_many(
766
  "borrower_files_borrowernumbers",
767
  "Koha::Schema::Result::BorrowerFile",
768
  { "foreign.borrowernumber" => "self.borrowernumber" },
769
  { cascade_copy => 0, cascade_delete => 0 },
770
);
771
772
=head2 borrower_files_borrowernumbers
700
773
701
Type: has_many
774
Type: has_many
702
775
Lines 705-717 Related object: L<Koha::Schema::Result::BorrowerFile> Link Here
705
=cut
778
=cut
706
779
707
__PACKAGE__->has_many(
780
__PACKAGE__->has_many(
708
  "borrower_files",
781
  "borrower_files_borrowernumbers",
709
  "Koha::Schema::Result::BorrowerFile",
782
  "Koha::Schema::Result::BorrowerFile",
710
  { "foreign.borrowernumber" => "self.borrowernumber" },
783
  { "foreign.borrowernumber" => "self.borrowernumber" },
711
  { cascade_copy => 0, cascade_delete => 0 },
784
  { cascade_copy => 0, cascade_delete => 0 },
712
);
785
);
713
786
714
=head2 borrower_message_preferences
787
=head2 borrower_message_preferences_borrowernumbers
788
789
Type: has_many
790
791
Related object: L<Koha::Schema::Result::BorrowerMessagePreference>
792
793
=cut
794
795
__PACKAGE__->has_many(
796
  "borrower_message_preferences_borrowernumbers",
797
  "Koha::Schema::Result::BorrowerMessagePreference",
798
  { "foreign.borrowernumber" => "self.borrowernumber" },
799
  { cascade_copy => 0, cascade_delete => 0 },
800
);
801
802
=head2 borrower_message_preferences_borrowernumbers
715
803
716
Type: has_many
804
Type: has_many
717
805
Lines 720-731 Related object: L<Koha::Schema::Result::BorrowerMessagePreference> Link Here
720
=cut
808
=cut
721
809
722
__PACKAGE__->has_many(
810
__PACKAGE__->has_many(
723
  "borrower_message_preferences",
811
  "borrower_message_preferences_borrowernumbers",
724
  "Koha::Schema::Result::BorrowerMessagePreference",
812
  "Koha::Schema::Result::BorrowerMessagePreference",
725
  { "foreign.borrowernumber" => "self.borrowernumber" },
813
  { "foreign.borrowernumber" => "self.borrowernumber" },
726
  { cascade_copy => 0, cascade_delete => 0 },
814
  { cascade_copy => 0, cascade_delete => 0 },
727
);
815
);
728
816
817
=head2 categorycode
818
819
Type: belongs_to
820
821
Related object: L<Koha::Schema::Result::Category>
822
823
=cut
824
825
__PACKAGE__->belongs_to(
826
  "categorycode",
827
  "Koha::Schema::Result::Category",
828
  { categorycode => "categorycode" },
829
  { on_delete => "CASCADE", on_update => "CASCADE" },
830
);
831
729
=head2 branchcode
832
=head2 branchcode
730
833
731
Type: belongs_to
834
Type: belongs_to
Lines 756-762 __PACKAGE__->belongs_to( Link Here
756
  { is_deferrable => 1, on_delete => "RESTRICT", on_update => "RESTRICT" },
859
  { is_deferrable => 1, on_delete => "RESTRICT", on_update => "RESTRICT" },
757
);
860
);
758
861
759
=head2 course_instructors
862
=head2 branchcode
863
864
Type: belongs_to
865
866
Related object: L<Koha::Schema::Result::Branch>
867
868
=cut
869
870
__PACKAGE__->belongs_to(
871
  "branchcode",
872
  "Koha::Schema::Result::Branch",
873
  { branchcode => "branchcode" },
874
  { on_delete => "CASCADE", on_update => "CASCADE" },
875
);
876
877
=head2 club_enrollments
878
879
Type: has_many
880
881
Related object: L<Koha::Schema::Result::ClubEnrollment>
882
883
=cut
884
885
__PACKAGE__->has_many(
886
  "club_enrollments",
887
  "Koha::Schema::Result::ClubEnrollment",
888
  { "foreign.borrower" => "self.borrowernumber" },
889
  { cascade_copy => 0, cascade_delete => 0 },
890
);
891
892
=head2 course_instructors_borrowernumbers
893
894
Type: has_many
895
896
Related object: L<Koha::Schema::Result::CourseInstructor>
897
898
=cut
899
900
__PACKAGE__->has_many(
901
  "course_instructors_borrowernumbers",
902
  "Koha::Schema::Result::CourseInstructor",
903
  { "foreign.borrowernumber" => "self.borrowernumber" },
904
  { cascade_copy => 0, cascade_delete => 0 },
905
);
906
907
=head2 course_instructors_borrowernumbers
760
908
761
Type: has_many
909
Type: has_many
762
910
Lines 765-777 Related object: L<Koha::Schema::Result::CourseInstructor> Link Here
765
=cut
913
=cut
766
914
767
__PACKAGE__->has_many(
915
__PACKAGE__->has_many(
768
  "course_instructors",
916
  "course_instructors_borrowernumbers",
769
  "Koha::Schema::Result::CourseInstructor",
917
  "Koha::Schema::Result::CourseInstructor",
770
  { "foreign.borrowernumber" => "self.borrowernumber" },
918
  { "foreign.borrowernumber" => "self.borrowernumber" },
771
  { cascade_copy => 0, cascade_delete => 0 },
919
  { cascade_copy => 0, cascade_delete => 0 },
772
);
920
);
773
921
774
=head2 creator_batches
922
=head2 creator_batches_borrower_numbers
775
923
776
Type: has_many
924
Type: has_many
777
925
Lines 780-792 Related object: L<Koha::Schema::Result::CreatorBatch> Link Here
780
=cut
928
=cut
781
929
782
__PACKAGE__->has_many(
930
__PACKAGE__->has_many(
783
  "creator_batches",
931
  "creator_batches_borrower_numbers",
784
  "Koha::Schema::Result::CreatorBatch",
932
  "Koha::Schema::Result::CreatorBatch",
785
  { "foreign.borrower_number" => "self.borrowernumber" },
933
  { "foreign.borrower_number" => "self.borrowernumber" },
786
  { cascade_copy => 0, cascade_delete => 0 },
934
  { cascade_copy => 0, cascade_delete => 0 },
787
);
935
);
788
936
789
=head2 hold_fill_targets
937
=head2 creator_batches_borrower_numbers
938
939
Type: has_many
940
941
Related object: L<Koha::Schema::Result::CreatorBatch>
942
943
=cut
944
945
__PACKAGE__->has_many(
946
  "creator_batches_borrower_numbers",
947
  "Koha::Schema::Result::CreatorBatch",
948
  { "foreign.borrower_number" => "self.borrowernumber" },
949
  { cascade_copy => 0, cascade_delete => 0 },
950
);
951
952
=head2 hold_fill_targets_borrowernumbers
790
953
791
Type: has_many
954
Type: has_many
792
955
Lines 795-807 Related object: L<Koha::Schema::Result::HoldFillTarget> Link Here
795
=cut
958
=cut
796
959
797
__PACKAGE__->has_many(
960
__PACKAGE__->has_many(
798
  "hold_fill_targets",
961
  "hold_fill_targets_borrowernumbers",
799
  "Koha::Schema::Result::HoldFillTarget",
962
  "Koha::Schema::Result::HoldFillTarget",
800
  { "foreign.borrowernumber" => "self.borrowernumber" },
963
  { "foreign.borrowernumber" => "self.borrowernumber" },
801
  { cascade_copy => 0, cascade_delete => 0 },
964
  { cascade_copy => 0, cascade_delete => 0 },
802
);
965
);
803
966
804
=head2 issues
967
=head2 hold_fill_targets_borrowernumbers
968
969
Type: has_many
970
971
Related object: L<Koha::Schema::Result::HoldFillTarget>
972
973
=cut
974
975
__PACKAGE__->has_many(
976
  "hold_fill_targets_borrowernumbers",
977
  "Koha::Schema::Result::HoldFillTarget",
978
  { "foreign.borrowernumber" => "self.borrowernumber" },
979
  { cascade_copy => 0, cascade_delete => 0 },
980
);
981
982
=head2 issues_borrowernumbers
983
984
Type: has_many
985
986
Related object: L<Koha::Schema::Result::Issue>
987
988
=cut
989
990
__PACKAGE__->has_many(
991
  "issues_borrowernumbers",
992
  "Koha::Schema::Result::Issue",
993
  { "foreign.borrowernumber" => "self.borrowernumber" },
994
  { cascade_copy => 0, cascade_delete => 0 },
995
);
996
997
=head2 issues_borrowernumbers
805
998
806
Type: has_many
999
Type: has_many
807
1000
Lines 810-822 Related object: L<Koha::Schema::Result::Issue> Link Here
810
=cut
1003
=cut
811
1004
812
__PACKAGE__->has_many(
1005
__PACKAGE__->has_many(
813
  "issues",
1006
  "issues_borrowernumbers",
814
  "Koha::Schema::Result::Issue",
1007
  "Koha::Schema::Result::Issue",
815
  { "foreign.borrowernumber" => "self.borrowernumber" },
1008
  { "foreign.borrowernumber" => "self.borrowernumber" },
816
  { cascade_copy => 0, cascade_delete => 0 },
1009
  { cascade_copy => 0, cascade_delete => 0 },
817
);
1010
);
818
1011
819
=head2 message_queues
1012
=head2 message_queue_borrowernumbers
1013
1014
Type: has_many
1015
1016
Related object: L<Koha::Schema::Result::MessageQueue>
1017
1018
=cut
1019
1020
__PACKAGE__->has_many(
1021
  "message_queue_borrowernumbers",
1022
  "Koha::Schema::Result::MessageQueue",
1023
  { "foreign.borrowernumber" => "self.borrowernumber" },
1024
  { cascade_copy => 0, cascade_delete => 0 },
1025
);
1026
1027
=head2 message_queue_borrowernumbers
820
1028
821
Type: has_many
1029
Type: has_many
822
1030
Lines 825-837 Related object: L<Koha::Schema::Result::MessageQueue> Link Here
825
=cut
1033
=cut
826
1034
827
__PACKAGE__->has_many(
1035
__PACKAGE__->has_many(
828
  "message_queues",
1036
  "message_queue_borrowernumbers",
829
  "Koha::Schema::Result::MessageQueue",
1037
  "Koha::Schema::Result::MessageQueue",
830
  { "foreign.borrowernumber" => "self.borrowernumber" },
1038
  { "foreign.borrowernumber" => "self.borrowernumber" },
831
  { cascade_copy => 0, cascade_delete => 0 },
1039
  { cascade_copy => 0, cascade_delete => 0 },
832
);
1040
);
833
1041
834
=head2 old_issues
1042
=head2 old_issues_borrowernumbers
835
1043
836
Type: has_many
1044
Type: has_many
837
1045
Lines 840-852 Related object: L<Koha::Schema::Result::OldIssue> Link Here
840
=cut
1048
=cut
841
1049
842
__PACKAGE__->has_many(
1050
__PACKAGE__->has_many(
843
  "old_issues",
1051
  "old_issues_borrowernumbers",
844
  "Koha::Schema::Result::OldIssue",
1052
  "Koha::Schema::Result::OldIssue",
845
  { "foreign.borrowernumber" => "self.borrowernumber" },
1053
  { "foreign.borrowernumber" => "self.borrowernumber" },
846
  { cascade_copy => 0, cascade_delete => 0 },
1054
  { cascade_copy => 0, cascade_delete => 0 },
847
);
1055
);
848
1056
849
=head2 old_reserves
1057
=head2 old_issues_borrowernumbers
1058
1059
Type: has_many
1060
1061
Related object: L<Koha::Schema::Result::OldIssue>
1062
1063
=cut
1064
1065
__PACKAGE__->has_many(
1066
  "old_issues_borrowernumbers",
1067
  "Koha::Schema::Result::OldIssue",
1068
  { "foreign.borrowernumber" => "self.borrowernumber" },
1069
  { cascade_copy => 0, cascade_delete => 0 },
1070
);
1071
1072
=head2 old_reserves_borrowernumbers
850
1073
851
Type: has_many
1074
Type: has_many
852
1075
Lines 855-867 Related object: L<Koha::Schema::Result::OldReserve> Link Here
855
=cut
1078
=cut
856
1079
857
__PACKAGE__->has_many(
1080
__PACKAGE__->has_many(
858
  "old_reserves",
1081
  "old_reserves_borrowernumbers",
859
  "Koha::Schema::Result::OldReserve",
1082
  "Koha::Schema::Result::OldReserve",
860
  { "foreign.borrowernumber" => "self.borrowernumber" },
1083
  { "foreign.borrowernumber" => "self.borrowernumber" },
861
  { cascade_copy => 0, cascade_delete => 0 },
1084
  { cascade_copy => 0, cascade_delete => 0 },
862
);
1085
);
863
1086
864
=head2 patron_list_patrons
1087
=head2 old_reserves_borrowernumbers
1088
1089
Type: has_many
1090
1091
Related object: L<Koha::Schema::Result::OldReserve>
1092
1093
=cut
1094
1095
__PACKAGE__->has_many(
1096
  "old_reserves_borrowernumbers",
1097
  "Koha::Schema::Result::OldReserve",
1098
  { "foreign.borrowernumber" => "self.borrowernumber" },
1099
  { cascade_copy => 0, cascade_delete => 0 },
1100
);
1101
1102
=head2 patron_list_patrons_borrowernumbers
1103
1104
Type: has_many
1105
1106
Related object: L<Koha::Schema::Result::PatronListPatron>
1107
1108
=cut
1109
1110
__PACKAGE__->has_many(
1111
  "patron_list_patrons_borrowernumbers",
1112
  "Koha::Schema::Result::PatronListPatron",
1113
  { "foreign.borrowernumber" => "self.borrowernumber" },
1114
  { cascade_copy => 0, cascade_delete => 0 },
1115
);
1116
1117
=head2 patron_list_patrons_borrowernumbers
865
1118
866
Type: has_many
1119
Type: has_many
867
1120
Lines 870-882 Related object: L<Koha::Schema::Result::PatronListPatron> Link Here
870
=cut
1123
=cut
871
1124
872
__PACKAGE__->has_many(
1125
__PACKAGE__->has_many(
873
  "patron_list_patrons",
1126
  "patron_list_patrons_borrowernumbers",
874
  "Koha::Schema::Result::PatronListPatron",
1127
  "Koha::Schema::Result::PatronListPatron",
875
  { "foreign.borrowernumber" => "self.borrowernumber" },
1128
  { "foreign.borrowernumber" => "self.borrowernumber" },
876
  { cascade_copy => 0, cascade_delete => 0 },
1129
  { cascade_copy => 0, cascade_delete => 0 },
877
);
1130
);
878
1131
879
=head2 patron_lists
1132
=head2 patron_lists_owners
1133
1134
Type: has_many
1135
1136
Related object: L<Koha::Schema::Result::PatronList>
1137
1138
=cut
1139
1140
__PACKAGE__->has_many(
1141
  "patron_lists_owners",
1142
  "Koha::Schema::Result::PatronList",
1143
  { "foreign.owner" => "self.borrowernumber" },
1144
  { cascade_copy => 0, cascade_delete => 0 },
1145
);
1146
1147
=head2 patron_lists_owners
880
1148
881
Type: has_many
1149
Type: has_many
882
1150
Lines 885-897 Related object: L<Koha::Schema::Result::PatronList> Link Here
885
=cut
1153
=cut
886
1154
887
__PACKAGE__->has_many(
1155
__PACKAGE__->has_many(
888
  "patron_lists",
1156
  "patron_lists_owners",
889
  "Koha::Schema::Result::PatronList",
1157
  "Koha::Schema::Result::PatronList",
890
  { "foreign.owner" => "self.borrowernumber" },
1158
  { "foreign.owner" => "self.borrowernumber" },
891
  { cascade_copy => 0, cascade_delete => 0 },
1159
  { cascade_copy => 0, cascade_delete => 0 },
892
);
1160
);
893
1161
894
=head2 patroncards
1162
=head2 patroncards_borrowernumbers
895
1163
896
Type: has_many
1164
Type: has_many
897
1165
Lines 900-912 Related object: L<Koha::Schema::Result::Patroncard> Link Here
900
=cut
1168
=cut
901
1169
902
__PACKAGE__->has_many(
1170
__PACKAGE__->has_many(
903
  "patroncards",
1171
  "patroncards_borrowernumbers",
904
  "Koha::Schema::Result::Patroncard",
1172
  "Koha::Schema::Result::Patroncard",
905
  { "foreign.borrowernumber" => "self.borrowernumber" },
1173
  { "foreign.borrowernumber" => "self.borrowernumber" },
906
  { cascade_copy => 0, cascade_delete => 0 },
1174
  { cascade_copy => 0, cascade_delete => 0 },
907
);
1175
);
908
1176
909
=head2 patronimage
1177
=head2 patroncards_borrowernumbers
1178
1179
Type: has_many
1180
1181
Related object: L<Koha::Schema::Result::Patroncard>
1182
1183
=cut
1184
1185
__PACKAGE__->has_many(
1186
  "patroncards_borrowernumbers",
1187
  "Koha::Schema::Result::Patroncard",
1188
  { "foreign.borrowernumber" => "self.borrowernumber" },
1189
  { cascade_copy => 0, cascade_delete => 0 },
1190
);
1191
1192
=head2 patronimage_borrowernumber
910
1193
911
Type: might_have
1194
Type: might_have
912
1195
Lines 915-927 Related object: L<Koha::Schema::Result::Patronimage> Link Here
915
=cut
1198
=cut
916
1199
917
__PACKAGE__->might_have(
1200
__PACKAGE__->might_have(
918
  "patronimage",
1201
  "patronimage_borrowernumber",
919
  "Koha::Schema::Result::Patronimage",
1202
  "Koha::Schema::Result::Patronimage",
920
  { "foreign.borrowernumber" => "self.borrowernumber" },
1203
  { "foreign.borrowernumber" => "self.borrowernumber" },
921
  { cascade_copy => 0, cascade_delete => 0 },
1204
  { cascade_copy => 0, cascade_delete => 0 },
922
);
1205
);
923
1206
924
=head2 ratings
1207
=head2 patronimage_borrowernumber
1208
1209
Type: might_have
1210
1211
Related object: L<Koha::Schema::Result::Patronimage>
1212
1213
=cut
1214
1215
__PACKAGE__->might_have(
1216
  "patronimage_borrowernumber",
1217
  "Koha::Schema::Result::Patronimage",
1218
  { "foreign.borrowernumber" => "self.borrowernumber" },
1219
  { cascade_copy => 0, cascade_delete => 0 },
1220
);
1221
1222
=head2 ratings_borrowernumbers
1223
1224
Type: has_many
1225
1226
Related object: L<Koha::Schema::Result::Rating>
1227
1228
=cut
1229
1230
__PACKAGE__->has_many(
1231
  "ratings_borrowernumbers",
1232
  "Koha::Schema::Result::Rating",
1233
  { "foreign.borrowernumber" => "self.borrowernumber" },
1234
  { cascade_copy => 0, cascade_delete => 0 },
1235
);
1236
1237
=head2 ratings_borrowernumbers
925
1238
926
Type: has_many
1239
Type: has_many
927
1240
Lines 930-942 Related object: L<Koha::Schema::Result::Rating> Link Here
930
=cut
1243
=cut
931
1244
932
__PACKAGE__->has_many(
1245
__PACKAGE__->has_many(
933
  "ratings",
1246
  "ratings_borrowernumbers",
934
  "Koha::Schema::Result::Rating",
1247
  "Koha::Schema::Result::Rating",
935
  { "foreign.borrowernumber" => "self.borrowernumber" },
1248
  { "foreign.borrowernumber" => "self.borrowernumber" },
936
  { cascade_copy => 0, cascade_delete => 0 },
1249
  { cascade_copy => 0, cascade_delete => 0 },
937
);
1250
);
938
1251
939
=head2 reserves
1252
=head2 reserves_borrowernumbers
1253
1254
Type: has_many
1255
1256
Related object: L<Koha::Schema::Result::Reserve>
1257
1258
=cut
1259
1260
__PACKAGE__->has_many(
1261
  "reserves_borrowernumbers",
1262
  "Koha::Schema::Result::Reserve",
1263
  { "foreign.borrowernumber" => "self.borrowernumber" },
1264
  { cascade_copy => 0, cascade_delete => 0 },
1265
);
1266
1267
=head2 reserves_borrowernumbers
940
1268
941
Type: has_many
1269
Type: has_many
942
1270
Lines 945-957 Related object: L<Koha::Schema::Result::Reserve> Link Here
945
=cut
1273
=cut
946
1274
947
__PACKAGE__->has_many(
1275
__PACKAGE__->has_many(
948
  "reserves",
1276
  "reserves_borrowernumbers",
949
  "Koha::Schema::Result::Reserve",
1277
  "Koha::Schema::Result::Reserve",
950
  { "foreign.borrowernumber" => "self.borrowernumber" },
1278
  { "foreign.borrowernumber" => "self.borrowernumber" },
951
  { cascade_copy => 0, cascade_delete => 0 },
1279
  { cascade_copy => 0, cascade_delete => 0 },
952
);
1280
);
953
1281
954
=head2 reviews
1282
=head2 reviews_borrowernumbers
955
1283
956
Type: has_many
1284
Type: has_many
957
1285
Lines 960-972 Related object: L<Koha::Schema::Result::Review> Link Here
960
=cut
1288
=cut
961
1289
962
__PACKAGE__->has_many(
1290
__PACKAGE__->has_many(
963
  "reviews",
1291
  "reviews_borrowernumbers",
964
  "Koha::Schema::Result::Review",
1292
  "Koha::Schema::Result::Review",
965
  { "foreign.borrowernumber" => "self.borrowernumber" },
1293
  { "foreign.borrowernumber" => "self.borrowernumber" },
966
  { cascade_copy => 0, cascade_delete => 0 },
1294
  { cascade_copy => 0, cascade_delete => 0 },
967
);
1295
);
968
1296
969
=head2 subscriptionroutinglists
1297
=head2 reviews_borrowernumbers
1298
1299
Type: has_many
1300
1301
Related object: L<Koha::Schema::Result::Review>
1302
1303
=cut
1304
1305
__PACKAGE__->has_many(
1306
  "reviews_borrowernumbers",
1307
  "Koha::Schema::Result::Review",
1308
  { "foreign.borrowernumber" => "self.borrowernumber" },
1309
  { cascade_copy => 0, cascade_delete => 0 },
1310
);
1311
1312
=head2 subscriptionroutinglist_borrowernumbers
970
1313
971
Type: has_many
1314
Type: has_many
972
1315
Lines 975-987 Related object: L<Koha::Schema::Result::Subscriptionroutinglist> Link Here
975
=cut
1318
=cut
976
1319
977
__PACKAGE__->has_many(
1320
__PACKAGE__->has_many(
978
  "subscriptionroutinglists",
1321
  "subscriptionroutinglist_borrowernumbers",
979
  "Koha::Schema::Result::Subscriptionroutinglist",
1322
  "Koha::Schema::Result::Subscriptionroutinglist",
980
  { "foreign.borrowernumber" => "self.borrowernumber" },
1323
  { "foreign.borrowernumber" => "self.borrowernumber" },
981
  { cascade_copy => 0, cascade_delete => 0 },
1324
  { cascade_copy => 0, cascade_delete => 0 },
982
);
1325
);
983
1326
984
=head2 tags_all
1327
=head2 subscriptionroutinglist_borrowernumbers
1328
1329
Type: has_many
1330
1331
Related object: L<Koha::Schema::Result::Subscriptionroutinglist>
1332
1333
=cut
1334
1335
__PACKAGE__->has_many(
1336
  "subscriptionroutinglist_borrowernumbers",
1337
  "Koha::Schema::Result::Subscriptionroutinglist",
1338
  { "foreign.borrowernumber" => "self.borrowernumber" },
1339
  { cascade_copy => 0, cascade_delete => 0 },
1340
);
1341
1342
=head2 tags_all_borrowernumbers
1343
1344
Type: has_many
1345
1346
Related object: L<Koha::Schema::Result::TagAll>
1347
1348
=cut
1349
1350
__PACKAGE__->has_many(
1351
  "tags_all_borrowernumbers",
1352
  "Koha::Schema::Result::TagAll",
1353
  { "foreign.borrowernumber" => "self.borrowernumber" },
1354
  { cascade_copy => 0, cascade_delete => 0 },
1355
);
1356
1357
=head2 tags_all_borrowernumbers
985
1358
986
Type: has_many
1359
Type: has_many
987
1360
Lines 990-1002 Related object: L<Koha::Schema::Result::TagAll> Link Here
990
=cut
1363
=cut
991
1364
992
__PACKAGE__->has_many(
1365
__PACKAGE__->has_many(
993
  "tags_all",
1366
  "tags_all_borrowernumbers",
994
  "Koha::Schema::Result::TagAll",
1367
  "Koha::Schema::Result::TagAll",
995
  { "foreign.borrowernumber" => "self.borrowernumber" },
1368
  { "foreign.borrowernumber" => "self.borrowernumber" },
996
  { cascade_copy => 0, cascade_delete => 0 },
1369
  { cascade_copy => 0, cascade_delete => 0 },
997
);
1370
);
998
1371
999
=head2 tags_approvals
1372
=head2 tags_approvals_approved_by
1373
1374
Type: has_many
1375
1376
Related object: L<Koha::Schema::Result::TagsApproval>
1377
1378
=cut
1379
1380
__PACKAGE__->has_many(
1381
  "tags_approvals_approved_by",
1382
  "Koha::Schema::Result::TagsApproval",
1383
  { "foreign.approved_by" => "self.borrowernumber" },
1384
  { cascade_copy => 0, cascade_delete => 0 },
1385
);
1386
1387
=head2 tags_approvals_approved_by
1000
1388
1001
Type: has_many
1389
Type: has_many
1002
1390
Lines 1005-1017 Related object: L<Koha::Schema::Result::TagsApproval> Link Here
1005
=cut
1393
=cut
1006
1394
1007
__PACKAGE__->has_many(
1395
__PACKAGE__->has_many(
1008
  "tags_approvals",
1396
  "tags_approvals_approved_by",
1009
  "Koha::Schema::Result::TagsApproval",
1397
  "Koha::Schema::Result::TagsApproval",
1010
  { "foreign.approved_by" => "self.borrowernumber" },
1398
  { "foreign.approved_by" => "self.borrowernumber" },
1011
  { cascade_copy => 0, cascade_delete => 0 },
1399
  { cascade_copy => 0, cascade_delete => 0 },
1012
);
1400
);
1013
1401
1014
=head2 user_permissions
1402
=head2 user_permissions_borrowernumbers
1015
1403
1016
Type: has_many
1404
Type: has_many
1017
1405
Lines 1020-1032 Related object: L<Koha::Schema::Result::UserPermission> Link Here
1020
=cut
1408
=cut
1021
1409
1022
__PACKAGE__->has_many(
1410
__PACKAGE__->has_many(
1023
  "user_permissions",
1411
  "user_permissions_borrowernumbers",
1024
  "Koha::Schema::Result::UserPermission",
1412
  "Koha::Schema::Result::UserPermission",
1025
  { "foreign.borrowernumber" => "self.borrowernumber" },
1413
  { "foreign.borrowernumber" => "self.borrowernumber" },
1026
  { cascade_copy => 0, cascade_delete => 0 },
1414
  { cascade_copy => 0, cascade_delete => 0 },
1027
);
1415
);
1028
1416
1029
=head2 virtualshelfcontents
1417
=head2 user_permissions_borrowernumbers
1418
1419
Type: has_many
1420
1421
Related object: L<Koha::Schema::Result::UserPermission>
1422
1423
=cut
1424
1425
__PACKAGE__->has_many(
1426
  "user_permissions_borrowernumbers",
1427
  "Koha::Schema::Result::UserPermission",
1428
  { "foreign.borrowernumber" => "self.borrowernumber" },
1429
  { cascade_copy => 0, cascade_delete => 0 },
1430
);
1431
1432
=head2 virtualshelfcontents_borrowernumbers
1030
1433
1031
Type: has_many
1434
Type: has_many
1032
1435
Lines 1035-1110 Related object: L<Koha::Schema::Result::Virtualshelfcontent> Link Here
1035
=cut
1438
=cut
1036
1439
1037
__PACKAGE__->has_many(
1440
__PACKAGE__->has_many(
1038
  "virtualshelfcontents",
1441
  "virtualshelfcontents_borrowernumbers",
1039
  "Koha::Schema::Result::Virtualshelfcontent",
1442
  "Koha::Schema::Result::Virtualshelfcontent",
1040
  { "foreign.borrowernumber" => "self.borrowernumber" },
1443
  { "foreign.borrowernumber" => "self.borrowernumber" },
1041
  { cascade_copy => 0, cascade_delete => 0 },
1444
  { cascade_copy => 0, cascade_delete => 0 },
1042
);
1445
);
1043
1446
1044
=head2 virtualshelfshares
1447
=head2 virtualshelfcontents_borrowernumbers
1045
1448
1046
Type: has_many
1449
Type: has_many
1047
1450
1048
Related object: L<Koha::Schema::Result::Virtualshelfshare>
1451
Related object: L<Koha::Schema::Result::Virtualshelfcontent>
1049
1452
1050
=cut
1453
=cut
1051
1454
1052
__PACKAGE__->has_many(
1455
__PACKAGE__->has_many(
1053
  "virtualshelfshares",
1456
  "virtualshelfcontents_borrowernumbers",
1054
  "Koha::Schema::Result::Virtualshelfshare",
1457
  "Koha::Schema::Result::Virtualshelfcontent",
1055
  { "foreign.borrowernumber" => "self.borrowernumber" },
1458
  { "foreign.borrowernumber" => "self.borrowernumber" },
1056
  { cascade_copy => 0, cascade_delete => 0 },
1459
  { cascade_copy => 0, cascade_delete => 0 },
1057
);
1460
);
1058
1461
1059
=head2 virtualshelves
1462
=head2 virtualshelfshares_borrowernumbers
1060
1463
1061
Type: has_many
1464
Type: has_many
1062
1465
1063
Related object: L<Koha::Schema::Result::Virtualshelve>
1466
Related object: L<Koha::Schema::Result::Virtualshelfshare>
1064
1467
1065
=cut
1468
=cut
1066
1469
1067
__PACKAGE__->has_many(
1470
__PACKAGE__->has_many(
1068
  "virtualshelves",
1471
  "virtualshelfshares_borrowernumbers",
1069
  "Koha::Schema::Result::Virtualshelve",
1472
  "Koha::Schema::Result::Virtualshelfshare",
1070
  { "foreign.owner" => "self.borrowernumber" },
1473
  { "foreign.borrowernumber" => "self.borrowernumber" },
1071
  { cascade_copy => 0, cascade_delete => 0 },
1474
  { cascade_copy => 0, cascade_delete => 0 },
1072
);
1475
);
1073
1476
1074
=head2 basketnoes
1477
=head2 virtualshelfshares_borrowernumbers
1075
1478
1076
Type: many_to_many
1479
Type: has_many
1077
1480
1078
Composing rels: L</aqbasketusers> -> basketno
1481
Related object: L<Koha::Schema::Result::Virtualshelfshare>
1079
1482
1080
=cut
1483
=cut
1081
1484
1082
__PACKAGE__->many_to_many("basketnoes", "aqbasketusers", "basketno");
1485
__PACKAGE__->has_many(
1486
  "virtualshelfshares_borrowernumbers",
1487
  "Koha::Schema::Result::Virtualshelfshare",
1488
  { "foreign.borrowernumber" => "self.borrowernumber" },
1489
  { cascade_copy => 0, cascade_delete => 0 },
1490
);
1083
1491
1084
=head2 budgets
1492
=head2 virtualshelves_owners
1085
1493
1086
Type: many_to_many
1494
Type: has_many
1087
1495
1088
Composing rels: L</aqbudgetborrowers> -> budget
1496
Related object: L<Koha::Schema::Result::Virtualshelve>
1089
1497
1090
=cut
1498
=cut
1091
1499
1092
__PACKAGE__->many_to_many("budgets", "aqbudgetborrowers", "budget");
1500
__PACKAGE__->has_many(
1501
  "virtualshelves_owners",
1502
  "Koha::Schema::Result::Virtualshelve",
1503
  { "foreign.owner" => "self.borrowernumber" },
1504
  { cascade_copy => 0, cascade_delete => 0 },
1505
);
1093
1506
1094
=head2 courses
1507
=head2 virtualshelves_owners
1095
1508
1096
Type: many_to_many
1509
Type: has_many
1097
1510
1098
Composing rels: L</course_instructors> -> course
1511
Related object: L<Koha::Schema::Result::Virtualshelve>
1099
1512
1100
=cut
1513
=cut
1101
1514
1102
__PACKAGE__->many_to_many("courses", "course_instructors", "course");
1515
__PACKAGE__->has_many(
1516
  "virtualshelves_owners",
1517
  "Koha::Schema::Result::Virtualshelve",
1518
  { "foreign.owner" => "self.borrowernumber" },
1519
  { cascade_copy => 0, cascade_delete => 0 },
1520
);
1103
1521
1104
1522
1105
# Created by DBIx::Class::Schema::Loader v0.07039 @ 2014-08-18 13:01:05
1523
# Created by DBIx::Class::Schema::Loader v0.07039 @ 2014-08-18 13:01:05
1106
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:ZzZiKYN4b/LuEARX4rawhA
1524
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:ZzZiKYN4b/LuEARX4rawhA
1107
1525
1526
sub FirstValidEmailAddress {
1527
    my ( $self ) = @_;
1528
1529
    return $self->email() || $self->emailpro() || $self->b_email() || q{};
1530
}
1531
1532
sub ClubsEnrolledCount {
1533
    my ( $self ) = @_;
1534
1535
    return $self->club_enrollments({ date_canceled => undef })->count();
1536
}
1537
1538
sub ClubsEnrollableCount {
1539
    my ( $self, $is_enrollable_from_opac ) = @_;
1540
1541
    my $params;
1542
    $params->{is_enrollable_from_opac} = $is_enrollable_from_opac
1543
      if $is_enrollable_from_opac;
1544
    $params->{is_email_required} = 0 unless $self->FirstValidEmailAddress();
1545
1546
    return $self->result_source->schema->resultset('Club')
1547
      ->search( $params, { prefetch => 'club_template' } )->count();
1548
}
1108
1549
1109
# You can replace this text with custom content, and it will be preserved on regeneration
1110
1;
1550
1;
(-)a/Koha/Schema/Result/Club.pm (+168 lines)
Line 0 Link Here
1
package Koha::Schema::Result::Club;
2
3
# Created by DBIx::Class::Schema::Loader
4
# DO NOT MODIFY THE FIRST PART OF THIS FILE
5
6
use strict;
7
use warnings;
8
9
use base 'DBIx::Class::Core';
10
11
12
=head1 NAME
13
14
Koha::Schema::Result::Club
15
16
=cut
17
18
__PACKAGE__->table("clubs");
19
20
=head1 ACCESSORS
21
22
=head2 id
23
24
  data_type: 'integer'
25
  is_auto_increment: 1
26
  is_nullable: 0
27
28
=head2 club_template
29
30
  data_type: 'integer'
31
  is_foreign_key: 1
32
  is_nullable: 0
33
34
=head2 name
35
36
  data_type: 'tinytext'
37
  is_nullable: 0
38
39
=head2 description
40
41
  data_type: 'text'
42
  is_nullable: 1
43
44
=head2 date_start
45
46
  data_type: 'date'
47
  is_nullable: 0
48
49
=head2 date_end
50
51
  data_type: 'date'
52
  is_nullable: 1
53
54
=head2 branch
55
56
  data_type: 'varchar'
57
  is_foreign_key: 1
58
  is_nullable: 1
59
  size: 11
60
61
=head2 date_created
62
63
  data_type: 'timestamp'
64
  default_value: current_timestamp
65
  is_nullable: 0
66
67
=head2 date_updated
68
69
  data_type: 'timestamp'
70
  is_nullable: 1
71
72
=cut
73
74
__PACKAGE__->add_columns(
75
  "id",
76
  { data_type => "integer", is_auto_increment => 1, is_nullable => 0 },
77
  "club_template",
78
  { data_type => "integer", is_foreign_key => 1, is_nullable => 0 },
79
  "name",
80
  { data_type => "tinytext", is_nullable => 0 },
81
  "description",
82
  { data_type => "text", is_nullable => 1 },
83
  "date_start",
84
  { data_type => "date", is_nullable => 0 },
85
  "date_end",
86
  { data_type => "date", is_nullable => 1 },
87
  "branch",
88
  { data_type => "varchar", is_foreign_key => 1, is_nullable => 1, size => 11 },
89
  "date_created",
90
  {
91
    data_type     => "timestamp",
92
    default_value => \"current_timestamp",
93
    is_nullable   => 0,
94
  },
95
  "date_updated",
96
  { data_type => "timestamp", is_nullable => 1 },
97
);
98
__PACKAGE__->set_primary_key("id");
99
100
=head1 RELATIONS
101
102
=head2 club_enrollments
103
104
Type: has_many
105
106
Related object: L<Koha::Schema::Result::ClubEnrollment>
107
108
=cut
109
110
__PACKAGE__->has_many(
111
  "club_enrollments",
112
  "Koha::Schema::Result::ClubEnrollment",
113
  { "foreign.club" => "self.id" },
114
  { cascade_copy => 0, cascade_delete => 0 },
115
);
116
117
=head2 club_fields
118
119
Type: has_many
120
121
Related object: L<Koha::Schema::Result::ClubField>
122
123
=cut
124
125
__PACKAGE__->has_many(
126
  "club_fields",
127
  "Koha::Schema::Result::ClubField",
128
  { "foreign.club" => "self.id" },
129
  { cascade_copy => 0, cascade_delete => 0 },
130
);
131
132
=head2 club_template
133
134
Type: belongs_to
135
136
Related object: L<Koha::Schema::Result::ClubTemplate>
137
138
=cut
139
140
__PACKAGE__->belongs_to(
141
  "club_template",
142
  "Koha::Schema::Result::ClubTemplate",
143
  { id => "club_template" },
144
  { on_delete => "CASCADE", on_update => "CASCADE" },
145
);
146
147
=head2 branch
148
149
Type: belongs_to
150
151
Related object: L<Koha::Schema::Result::Branch>
152
153
=cut
154
155
__PACKAGE__->belongs_to(
156
  "branch",
157
  "Koha::Schema::Result::Branch",
158
  { branchcode => "branch" },
159
  { join_type => "LEFT", on_delete => "CASCADE", on_update => "CASCADE" },
160
);
161
162
163
# Created by DBIx::Class::Schema::Loader v0.07000 @ 2014-05-30 09:55:12
164
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:Y6kcTQulxM9XeOpDV+TiiQ
165
166
167
# You can replace this text with custom content, and it will be preserved on regeneration
168
1;
(-)a/Koha/Schema/Result/ClubEnrollment.pm (+167 lines)
Line 0 Link Here
1
package Koha::Schema::Result::ClubEnrollment;
2
3
# Created by DBIx::Class::Schema::Loader
4
# DO NOT MODIFY THE FIRST PART OF THIS FILE
5
6
use strict;
7
use warnings;
8
9
use base 'DBIx::Class::Core';
10
11
12
=head1 NAME
13
14
Koha::Schema::Result::ClubEnrollment
15
16
=cut
17
18
__PACKAGE__->table("club_enrollments");
19
20
=head1 ACCESSORS
21
22
=head2 id
23
24
  data_type: 'integer'
25
  is_auto_increment: 1
26
  is_nullable: 0
27
28
=head2 club
29
30
  data_type: 'integer'
31
  is_foreign_key: 1
32
  is_nullable: 0
33
34
=head2 borrower
35
36
  data_type: 'integer'
37
  is_foreign_key: 1
38
  is_nullable: 0
39
40
=head2 date_enrolled
41
42
  data_type: 'timestamp'
43
  default_value: current_timestamp
44
  is_nullable: 0
45
46
=head2 date_canceled
47
48
  data_type: 'timestamp'
49
  is_nullable: 1
50
51
=head2 date_created
52
53
  data_type: 'timestamp'
54
  default_value: '0000-00-00 00:00:00'
55
  is_nullable: 0
56
57
=head2 date_updated
58
59
  data_type: 'timestamp'
60
  is_nullable: 1
61
62
=head2 branch
63
64
  data_type: 'varchar'
65
  is_foreign_key: 1
66
  is_nullable: 1
67
  size: 11
68
69
=cut
70
71
__PACKAGE__->add_columns(
72
  "id",
73
  { data_type => "integer", is_auto_increment => 1, is_nullable => 0 },
74
  "club",
75
  { data_type => "integer", is_foreign_key => 1, is_nullable => 0 },
76
  "borrower",
77
  { data_type => "integer", is_foreign_key => 1, is_nullable => 0 },
78
  "date_enrolled",
79
  {
80
    data_type     => "timestamp",
81
    default_value => \"current_timestamp",
82
    is_nullable   => 0,
83
  },
84
  "date_canceled",
85
  { data_type => "timestamp", is_nullable => 1 },
86
  "date_created",
87
  {
88
    data_type     => "timestamp",
89
    default_value => "0000-00-00 00:00:00",
90
    is_nullable   => 0,
91
  },
92
  "date_updated",
93
  { data_type => "timestamp", is_nullable => 1 },
94
  "branch",
95
  { data_type => "varchar", is_foreign_key => 1, is_nullable => 1, size => 11 },
96
);
97
__PACKAGE__->set_primary_key("id");
98
99
=head1 RELATIONS
100
101
=head2 club_enrollment_fields
102
103
Type: has_many
104
105
Related object: L<Koha::Schema::Result::ClubEnrollmentField>
106
107
=cut
108
109
__PACKAGE__->has_many(
110
  "club_enrollment_fields",
111
  "Koha::Schema::Result::ClubEnrollmentField",
112
  { "foreign.club_enrollment" => "self.id" },
113
  { cascade_copy => 0, cascade_delete => 0 },
114
);
115
116
=head2 club
117
118
Type: belongs_to
119
120
Related object: L<Koha::Schema::Result::Club>
121
122
=cut
123
124
__PACKAGE__->belongs_to(
125
  "club",
126
  "Koha::Schema::Result::Club",
127
  { id => "club" },
128
  { on_delete => "CASCADE", on_update => "CASCADE" },
129
);
130
131
=head2 borrower
132
133
Type: belongs_to
134
135
Related object: L<Koha::Schema::Result::Borrower>
136
137
=cut
138
139
__PACKAGE__->belongs_to(
140
  "borrower",
141
  "Koha::Schema::Result::Borrower",
142
  { borrowernumber => "borrower" },
143
  { on_delete => "CASCADE", on_update => "CASCADE" },
144
);
145
146
=head2 branch
147
148
Type: belongs_to
149
150
Related object: L<Koha::Schema::Result::Branch>
151
152
=cut
153
154
__PACKAGE__->belongs_to(
155
  "branch",
156
  "Koha::Schema::Result::Branch",
157
  { branchcode => "branch" },
158
  { join_type => "LEFT", on_delete => "CASCADE", on_update => "CASCADE" },
159
);
160
161
162
# Created by DBIx::Class::Schema::Loader v0.07000 @ 2014-05-30 09:55:12
163
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:mfTpVLaQhTKJ//QnRm2f5A
164
165
166
# You can replace this text with custom content, and it will be preserved on regeneration
167
1;
(-)a/Koha/Schema/Result/ClubEnrollmentField.pm (+97 lines)
Line 0 Link Here
1
package Koha::Schema::Result::ClubEnrollmentField;
2
3
# Created by DBIx::Class::Schema::Loader
4
# DO NOT MODIFY THE FIRST PART OF THIS FILE
5
6
use strict;
7
use warnings;
8
9
use base 'DBIx::Class::Core';
10
11
12
=head1 NAME
13
14
Koha::Schema::Result::ClubEnrollmentField
15
16
=cut
17
18
__PACKAGE__->table("club_enrollment_fields");
19
20
=head1 ACCESSORS
21
22
=head2 id
23
24
  data_type: 'integer'
25
  is_auto_increment: 1
26
  is_nullable: 0
27
28
=head2 club_enrollment
29
30
  data_type: 'integer'
31
  is_foreign_key: 1
32
  is_nullable: 0
33
34
=head2 club_template_enrollment_field
35
36
  data_type: 'integer'
37
  is_foreign_key: 1
38
  is_nullable: 0
39
40
=head2 value
41
42
  data_type: 'text'
43
  is_nullable: 0
44
45
=cut
46
47
__PACKAGE__->add_columns(
48
  "id",
49
  { data_type => "integer", is_auto_increment => 1, is_nullable => 0 },
50
  "club_enrollment",
51
  { data_type => "integer", is_foreign_key => 1, is_nullable => 0 },
52
  "club_template_enrollment_field",
53
  { data_type => "integer", is_foreign_key => 1, is_nullable => 0 },
54
  "value",
55
  { data_type => "text", is_nullable => 0 },
56
);
57
__PACKAGE__->set_primary_key("id");
58
59
=head1 RELATIONS
60
61
=head2 club_template_enrollment_field
62
63
Type: belongs_to
64
65
Related object: L<Koha::Schema::Result::ClubTemplateEnrollmentField>
66
67
=cut
68
69
__PACKAGE__->belongs_to(
70
  "club_template_enrollment_field",
71
  "Koha::Schema::Result::ClubTemplateEnrollmentField",
72
  { id => "club_template_enrollment_field" },
73
  { on_delete => "CASCADE", on_update => "CASCADE" },
74
);
75
76
=head2 club_enrollment
77
78
Type: belongs_to
79
80
Related object: L<Koha::Schema::Result::ClubEnrollment>
81
82
=cut
83
84
__PACKAGE__->belongs_to(
85
  "club_enrollment",
86
  "Koha::Schema::Result::ClubEnrollment",
87
  { id => "club_enrollment" },
88
  { on_delete => "CASCADE", on_update => "CASCADE" },
89
);
90
91
92
# Created by DBIx::Class::Schema::Loader v0.07000 @ 2014-05-30 09:55:12
93
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:bOPkyazyrsDwUKKS4oHHdQ
94
95
96
# You can replace this text with custom content, and it will be preserved on regeneration
97
1;
(-)a/Koha/Schema/Result/ClubField.pm (+127 lines)
Line 0 Link Here
1
package Koha::Schema::Result::ClubField;
2
3
# Created by DBIx::Class::Schema::Loader
4
# DO NOT MODIFY THE FIRST PART OF THIS FILE
5
6
use strict;
7
use warnings;
8
9
use base 'DBIx::Class::Core';
10
11
12
=head1 NAME
13
14
Koha::Schema::Result::ClubField
15
16
=cut
17
18
__PACKAGE__->table("club_fields");
19
20
=head1 ACCESSORS
21
22
=head2 id
23
24
  data_type: 'integer'
25
  is_auto_increment: 1
26
  is_nullable: 0
27
28
=head2 club_template_field
29
30
  data_type: 'integer'
31
  is_foreign_key: 1
32
  is_nullable: 0
33
34
=head2 club
35
36
  data_type: 'integer'
37
  is_foreign_key: 1
38
  is_nullable: 0
39
40
=head2 value
41
42
  data_type: 'text'
43
  is_nullable: 1
44
45
=cut
46
47
__PACKAGE__->add_columns(
48
  "id",
49
  { data_type => "integer", is_auto_increment => 1, is_nullable => 0 },
50
  "club_template_field",
51
  { data_type => "integer", is_foreign_key => 1, is_nullable => 0 },
52
  "club",
53
  { data_type => "integer", is_foreign_key => 1, is_nullable => 0 },
54
  "value",
55
  { data_type => "text", is_nullable => 1 },
56
);
57
__PACKAGE__->set_primary_key("id");
58
59
=head1 RELATIONS
60
61
=head2 club_template_field
62
63
Type: belongs_to
64
65
Related object: L<Koha::Schema::Result::ClubTemplateField>
66
67
=cut
68
69
__PACKAGE__->belongs_to(
70
  "club_template_field",
71
  "Koha::Schema::Result::ClubTemplateField",
72
  { id => "club_template_field" },
73
  { on_delete => "CASCADE", on_update => "CASCADE" },
74
);
75
76
=head2 club
77
78
Type: belongs_to
79
80
Related object: L<Koha::Schema::Result::Club>
81
82
=cut
83
84
__PACKAGE__->belongs_to(
85
  "club",
86
  "Koha::Schema::Result::Club",
87
  { id => "club" },
88
  { on_delete => "CASCADE", on_update => "CASCADE" },
89
);
90
91
=head2 z_clubs_rewrite_clubs
92
93
Type: has_many
94
95
Related object: L<Koha::Schema::Result::ZClubRewrite>
96
97
=cut
98
99
__PACKAGE__->has_many(
100
  "z_clubs_rewrite_clubs",
101
  "Koha::Schema::Result::ZClubRewrite",
102
  { "foreign.club" => "self.id" },
103
  { cascade_copy => 0, cascade_delete => 0 },
104
);
105
106
=head2 z_clubs_rewrite_club_template_fields
107
108
Type: has_many
109
110
Related object: L<Koha::Schema::Result::ZClubRewrite>
111
112
=cut
113
114
__PACKAGE__->has_many(
115
  "z_clubs_rewrite_club_template_fields",
116
  "Koha::Schema::Result::ZClubRewrite",
117
  { "foreign.club_template_field" => "self.club_template_field" },
118
  { cascade_copy => 0, cascade_delete => 0 },
119
);
120
121
122
# Created by DBIx::Class::Schema::Loader v0.07000 @ 2014-05-30 09:55:12
123
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:B5i1BInvl7L9Mjor17Okrw
124
125
126
# You can replace this text with custom content, and it will be preserved on regeneration
127
1;
(-)a/Koha/Schema/Result/ClubTemplate.pm (+168 lines)
Line 0 Link Here
1
package Koha::Schema::Result::ClubTemplate;
2
3
# Created by DBIx::Class::Schema::Loader
4
# DO NOT MODIFY THE FIRST PART OF THIS FILE
5
6
use strict;
7
use warnings;
8
9
use base 'DBIx::Class::Core';
10
11
12
=head1 NAME
13
14
Koha::Schema::Result::ClubTemplate
15
16
=cut
17
18
__PACKAGE__->table("club_templates");
19
20
=head1 ACCESSORS
21
22
=head2 id
23
24
  data_type: 'integer'
25
  is_auto_increment: 1
26
  is_nullable: 0
27
28
=head2 name
29
30
  data_type: 'tinytext'
31
  is_nullable: 0
32
33
=head2 description
34
35
  data_type: 'text'
36
  is_nullable: 1
37
38
=head2 is_enrollable_from_opac
39
40
  data_type: 'tinyint'
41
  default_value: 0
42
  is_nullable: 0
43
44
=head2 is_email_required
45
46
  data_type: 'tinyint'
47
  default_value: 0
48
  is_nullable: 0
49
50
=head2 branch
51
52
  data_type: 'varchar'
53
  is_foreign_key: 1
54
  is_nullable: 1
55
  size: 10
56
57
=head2 date_created
58
59
  data_type: 'timestamp'
60
  default_value: current_timestamp
61
  is_nullable: 0
62
63
=head2 date_updated
64
65
  data_type: 'timestamp'
66
  is_nullable: 1
67
68
=head2 is_deletable
69
70
  data_type: 'tinyint'
71
  default_value: 1
72
  is_nullable: 0
73
74
=cut
75
76
__PACKAGE__->add_columns(
77
  "id",
78
  { data_type => "integer", is_auto_increment => 1, is_nullable => 0 },
79
  "name",
80
  { data_type => "tinytext", is_nullable => 0 },
81
  "description",
82
  { data_type => "text", is_nullable => 1 },
83
  "is_enrollable_from_opac",
84
  { data_type => "tinyint", default_value => 0, is_nullable => 0 },
85
  "is_email_required",
86
  { data_type => "tinyint", default_value => 0, is_nullable => 0 },
87
  "branch",
88
  { data_type => "varchar", is_foreign_key => 1, is_nullable => 1, size => 10 },
89
  "date_created",
90
  {
91
    data_type     => "timestamp",
92
    default_value => \"current_timestamp",
93
    is_nullable   => 0,
94
  },
95
  "date_updated",
96
  { data_type => "timestamp", is_nullable => 1 },
97
  "is_deletable",
98
  { data_type => "tinyint", default_value => 1, is_nullable => 0 },
99
);
100
__PACKAGE__->set_primary_key("id");
101
102
=head1 RELATIONS
103
104
=head2 club_template_enrollment_fields
105
106
Type: has_many
107
108
Related object: L<Koha::Schema::Result::ClubTemplateEnrollmentField>
109
110
=cut
111
112
__PACKAGE__->has_many(
113
  "club_template_enrollment_fields",
114
  "Koha::Schema::Result::ClubTemplateEnrollmentField",
115
  { "foreign.club_template" => "self.id" },
116
  { cascade_copy => 0, cascade_delete => 0 },
117
);
118
119
=head2 club_template_fields
120
121
Type: has_many
122
123
Related object: L<Koha::Schema::Result::ClubTemplateField>
124
125
=cut
126
127
__PACKAGE__->has_many(
128
  "club_template_fields",
129
  "Koha::Schema::Result::ClubTemplateField",
130
  { "foreign.club_template" => "self.id" },
131
  { cascade_copy => 0, cascade_delete => 0 },
132
);
133
134
=head2 branch
135
136
Type: belongs_to
137
138
Related object: L<Koha::Schema::Result::Branch>
139
140
=cut
141
142
__PACKAGE__->belongs_to(
143
  "branch",
144
  "Koha::Schema::Result::Branch",
145
  { branchcode => "branch" },
146
  { join_type => "LEFT", on_delete => "CASCADE", on_update => "CASCADE" },
147
);
148
149
=head2 clubs
150
151
Type: has_many
152
153
Related object: L<Koha::Schema::Result::Club>
154
155
=cut
156
157
__PACKAGE__->has_many(
158
  "clubs",
159
  "Koha::Schema::Result::Club",
160
  { "foreign.club_template" => "self.id" },
161
  { cascade_copy => 0, cascade_delete => 0 },
162
);
163
164
165
# Created by DBIx::Class::Schema::Loader v0.07000 @ 2014-05-23 10:30:48
166
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:XhoCAiWRvHG5FBNhr7JEkg
167
168
1;
(-)a/Koha/Schema/Result/ClubTemplateEnrollmentField.pm (+104 lines)
Line 0 Link Here
1
package Koha::Schema::Result::ClubTemplateEnrollmentField;
2
3
# Created by DBIx::Class::Schema::Loader
4
# DO NOT MODIFY THE FIRST PART OF THIS FILE
5
6
use strict;
7
use warnings;
8
9
use base 'DBIx::Class::Core';
10
11
12
=head1 NAME
13
14
Koha::Schema::Result::ClubTemplateEnrollmentField
15
16
=cut
17
18
__PACKAGE__->table("club_template_enrollment_fields");
19
20
=head1 ACCESSORS
21
22
=head2 id
23
24
  data_type: 'integer'
25
  is_auto_increment: 1
26
  is_nullable: 0
27
28
=head2 club_template
29
30
  data_type: 'integer'
31
  is_foreign_key: 1
32
  is_nullable: 0
33
34
=head2 name
35
36
  data_type: 'tinytext'
37
  is_nullable: 0
38
39
=head2 description
40
41
  data_type: 'text'
42
  is_nullable: 1
43
44
=head2 authorised_value_category
45
46
  data_type: 'varchar'
47
  is_nullable: 1
48
  size: 16
49
50
=cut
51
52
__PACKAGE__->add_columns(
53
  "id",
54
  { data_type => "integer", is_auto_increment => 1, is_nullable => 0 },
55
  "club_template",
56
  { data_type => "integer", is_foreign_key => 1, is_nullable => 0 },
57
  "name",
58
  { data_type => "tinytext", is_nullable => 0 },
59
  "description",
60
  { data_type => "text", is_nullable => 1 },
61
  "authorised_value_category",
62
  { data_type => "varchar", is_nullable => 1, size => 16 },
63
);
64
__PACKAGE__->set_primary_key("id");
65
66
=head1 RELATIONS
67
68
=head2 club_enrollment_fields
69
70
Type: has_many
71
72
Related object: L<Koha::Schema::Result::ClubEnrollmentField>
73
74
=cut
75
76
__PACKAGE__->has_many(
77
  "club_enrollment_fields",
78
  "Koha::Schema::Result::ClubEnrollmentField",
79
  { "foreign.club_template_enrollment_field" => "self.id" },
80
  { cascade_copy => 0, cascade_delete => 0 },
81
);
82
83
=head2 club_template
84
85
Type: belongs_to
86
87
Related object: L<Koha::Schema::Result::ClubTemplate>
88
89
=cut
90
91
__PACKAGE__->belongs_to(
92
  "club_template",
93
  "Koha::Schema::Result::ClubTemplate",
94
  { id => "club_template" },
95
  { on_delete => "CASCADE", on_update => "CASCADE" },
96
);
97
98
99
# Created by DBIx::Class::Schema::Loader v0.07000 @ 2014-05-30 09:55:12
100
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:FO/5gEcTgdIYma9hmhXdNw
101
102
103
# You can replace this text with custom content, and it will be preserved on regeneration
104
1;
(-)a/Koha/Schema/Result/ClubTemplateField.pm (+104 lines)
Line 0 Link Here
1
package Koha::Schema::Result::ClubTemplateField;
2
3
# Created by DBIx::Class::Schema::Loader
4
# DO NOT MODIFY THE FIRST PART OF THIS FILE
5
6
use strict;
7
use warnings;
8
9
use base 'DBIx::Class::Core';
10
11
12
=head1 NAME
13
14
Koha::Schema::Result::ClubTemplateField
15
16
=cut
17
18
__PACKAGE__->table("club_template_fields");
19
20
=head1 ACCESSORS
21
22
=head2 id
23
24
  data_type: 'integer'
25
  is_auto_increment: 1
26
  is_nullable: 0
27
28
=head2 club_template
29
30
  data_type: 'integer'
31
  is_foreign_key: 1
32
  is_nullable: 0
33
34
=head2 name
35
36
  data_type: 'tinytext'
37
  is_nullable: 0
38
39
=head2 description
40
41
  data_type: 'text'
42
  is_nullable: 1
43
44
=head2 authorised_value_category
45
46
  data_type: 'varchar'
47
  is_nullable: 1
48
  size: 16
49
50
=cut
51
52
__PACKAGE__->add_columns(
53
  "id",
54
  { data_type => "integer", is_auto_increment => 1, is_nullable => 0 },
55
  "club_template",
56
  { data_type => "integer", is_foreign_key => 1, is_nullable => 0 },
57
  "name",
58
  { data_type => "tinytext", is_nullable => 0 },
59
  "description",
60
  { data_type => "text", is_nullable => 1 },
61
  "authorised_value_category",
62
  { data_type => "varchar", is_nullable => 1, size => 16 },
63
);
64
__PACKAGE__->set_primary_key("id");
65
66
=head1 RELATIONS
67
68
=head2 club_fields
69
70
Type: has_many
71
72
Related object: L<Koha::Schema::Result::ClubField>
73
74
=cut
75
76
__PACKAGE__->has_many(
77
  "club_fields",
78
  "Koha::Schema::Result::ClubField",
79
  { "foreign.club_template_field" => "self.id" },
80
  { cascade_copy => 0, cascade_delete => 0 },
81
);
82
83
=head2 club_template
84
85
Type: belongs_to
86
87
Related object: L<Koha::Schema::Result::ClubTemplate>
88
89
=cut
90
91
__PACKAGE__->belongs_to(
92
  "club_template",
93
  "Koha::Schema::Result::ClubTemplate",
94
  { id => "club_template" },
95
  { on_delete => "CASCADE", on_update => "CASCADE" },
96
);
97
98
99
# Created by DBIx::Class::Schema::Loader v0.07000 @ 2014-05-23 11:09:48
100
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:rm9181l4mTPyIpDBQTERBQ
101
102
103
# You can replace this text with custom content, and it will be preserved on regeneration
104
1;
(-)a/Koha/Template/Plugin/AuthorisedValues.pm (+6 lines)
Lines 40-45 sub GetAuthValueDropbox { Link Here
40
    return C4::Koha::GetAuthvalueDropbox($category, $default);
40
    return C4::Koha::GetAuthvalueDropbox($category, $default);
41
}
41
}
42
42
43
sub Categories {
44
    my ( $self ) = @_;
45
46
    return GetAuthorisedValueCategories();
47
}
48
43
1;
49
1;
44
50
45
=head1 NAME
51
=head1 NAME
(-)a/Koha/Template/Plugin/Borrowers.pm (+4 lines)
Lines 48-51 sub IsDebarred { Link Here
48
    return Koha::Borrower::Debarments::IsDebarred($borrower->{borrowernumber});
48
    return Koha::Borrower::Debarments::IsDebarred($borrower->{borrowernumber});
49
}
49
}
50
50
51
sub HasValidEmailAddress {
52
53
}
54
51
1;
55
1;
(-)a/Koha/Template/Plugin/Branches.pm (+7 lines)
Lines 26-31 use Encode qw{encode decode}; Link Here
26
use C4::Koha;
26
use C4::Koha;
27
use C4::Context;
27
use C4::Context;
28
28
29
sub GetBranches {
30
    my ($self) = @_;
31
32
    my $dbh = C4::Context->dbh;
33
    return $dbh->selectall_arrayref( "SELECT * FROM branches", { Slice => {} } );
34
}
35
29
sub GetName {
36
sub GetName {
30
    my ( $self, $branchcode ) = @_;
37
    my ( $self, $branchcode ) = @_;
31
38
(-)a/Koha/Template/Plugin/Koha.pm (+5 lines)
Lines 44-47 sub Preference { Link Here
44
    return C4::Context->preference( $pref );
44
    return C4::Context->preference( $pref );
45
}
45
}
46
46
47
sub UserEnv {
48
    my ( $self, $key ) = @_;
49
    my $userenv = C4::Context->userenv;
50
    return $userenv ? $userenv->{$key} : undef;
51
}
47
1;
52
1;
(-)a/circ/circulation.pl (+3 lines)
Lines 565-570 $template->param( picture => 1 ) if $picture; Link Here
565
565
566
my $canned_notes = GetAuthorisedValues("BOR_NOTES");
566
my $canned_notes = GetAuthorisedValues("BOR_NOTES");
567
567
568
my $schema = Koha::Database->new()->schema();
569
568
$template->param(
570
$template->param(
569
    debt_confirmed            => $debt_confirmed,
571
    debt_confirmed            => $debt_confirmed,
570
    SpecifyDueDate            => $duedatespec_allow,
572
    SpecifyDueDate            => $duedatespec_allow,
Lines 574-579 $template->param( Link Here
574
    export_with_csv_profile   => C4::Context->preference("ExportWithCsvProfile"),
576
    export_with_csv_profile   => C4::Context->preference("ExportWithCsvProfile"),
575
    canned_bor_notes_loop     => $canned_notes,
577
    canned_bor_notes_loop     => $canned_notes,
576
    debarments                => GetDebarments({ borrowernumber => $borrowernumber }),
578
    debarments                => GetDebarments({ borrowernumber => $borrowernumber }),
579
    borrower                  => $schema->resultset('Borrower')->find( $borrowernumber ),
577
);
580
);
578
581
579
output_html_with_http_headers $query, $cookie, $template->output;
582
output_html_with_http_headers $query, $cookie, $template->output;
(-)a/clubs/clubs-add-modify.pl (+125 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Copyright 2013 ByWater Solutions
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it
8
# under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
11
#
12
# Koha is distributed in the hope that it will be useful, but
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
20
use Modern::Perl;
21
22
use CGI;
23
24
use C4::Auth;
25
use C4::Output;
26
use Koha::Database;
27
use Koha::DateUtils qw(dt_from_string);
28
29
my $cgi = new CGI;
30
31
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
32
    {
33
        template_name   => 'clubs/clubs-add-modify.tt',
34
        query           => $cgi,
35
        type            => 'intranet',
36
        authnotrequired => 0,
37
        flagsrequired   => { clubs => 'edit_clubs' },
38
    }
39
);
40
41
my $schema = Koha::Database->new()->schema();
42
43
my $id   = $cgi->param('id');
44
my $club = $schema->resultset('Club')->find($id);
45
46
my $club_template_id =
47
  $club ? $club->club_template()->id() : $cgi->param('club_template_id');
48
my $club_template = $schema->resultset('ClubTemplate')->find($club_template_id);
49
50
my $date_start = $cgi->param('date_start');
51
$date_start = $date_start ? dt_from_string($date_start) : undef;
52
my $date_end = $cgi->param('date_end');
53
$date_end = $date_end ? dt_from_string($date_end) : undef;
54
55
if ( $cgi->param('name') ) {    # Update or create club
56
    if ($club) {
57
        $club->update(
58
            {
59
                id            => $id                             || undef,
60
                club_template => $cgi->param('club_template_id') || undef,
61
                name          => $cgi->param('name')             || undef,
62
                description   => $cgi->param('description')      || undef,
63
                branch        => $cgi->param('branchcode')       || undef,
64
                date_start    => $date_start,
65
                date_end      => $date_end,
66
                date_updated  => dt_from_string(),
67
            }
68
        );
69
    }
70
    else {
71
        $club = $schema->resultset('Club')->create(
72
            {
73
                id            => $id                             || undef,
74
                club_template => $cgi->param('club_template_id') || undef,
75
                name          => $cgi->param('name')             || undef,
76
                description   => $cgi->param('description')      || undef,
77
                branch        => $cgi->param('branchcode')       || undef,
78
                date_start    => $date_start,
79
                date_end      => $date_end,
80
                date_updated  => dt_from_string(),
81
            }
82
        );
83
84
    }
85
86
    my @club_template_field_id = $cgi->param('club_template_field_id');
87
    my @club_field_id          = $cgi->param('club_field_id');
88
    my @club_field             = $cgi->param('club_field');
89
90
    for ( my $i = 0 ; $i < @club_template_field_id ; $i++ ) {
91
        my $club_template_field_id = $club_template_field_id[$i] || undef;
92
        my $club_field_id          = $club_field_id[$i]          || undef;
93
        my $club_field             = $club_field[$i]             || undef;
94
95
        if ($club_field_id) {
96
            $schema->resultset('ClubField')->find($club_field_id)->update(
97
                {
98
                    club                => $club->id(),
99
                    club_template_field => $club_template_field_id,
100
                    value               => $club_field,
101
                }
102
            );
103
        }
104
        else {
105
            $schema->resultset('ClubField')->create(
106
                {
107
                    club                => $club->id(),
108
                    club_template_field => $club_template_field_id,
109
                    value               => $club_field,
110
                }
111
            );
112
        }
113
    }
114
115
    $id ||= $club->id();
116
}
117
118
$club = $schema->resultset('Club')->find($id);
119
120
$template->param(
121
    club_template => $club_template,
122
    club          => $club,
123
);
124
125
output_html_with_http_headers( $cgi, $cookie, $template->output );
(-)a/clubs/clubs.pl (+50 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Copyright 2013 ByWater Solutions
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it
8
# under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
11
#
12
# Koha is distributed in the hope that it will be useful, but
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
20
use Modern::Perl;
21
22
use CGI;
23
24
use C4::Auth;
25
use C4::Output;
26
use Koha::Database;
27
28
my $cgi = new CGI;
29
30
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
31
    {
32
        template_name   => "clubs/clubs.tt",
33
        query           => $cgi,
34
        type            => "intranet",
35
        authnotrequired => 0,
36
        flagsrequired   => { clubs => '*' },
37
    }
38
);
39
40
my $schema = Koha::Database->new()->schema();
41
42
my @club_templates = $schema->resultset("ClubTemplate")->all();
43
my @clubs          = $schema->resultset("Club")->all();
44
45
$template->param(
46
    club_templates => \@club_templates,
47
    clubs          => \@clubs
48
);
49
50
output_html_with_http_headers( $cgi, $cookie, $template->output );
(-)a/clubs/patron-clubs-tab.pl (+59 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Copyright 2013 ByWater Solutions
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it
8
# under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
11
#
12
# Koha is distributed in the hope that it will be useful, but
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
20
use Modern::Perl;
21
22
use CGI;
23
24
use C4::Auth;
25
use C4::Output;
26
use Koha::Database;
27
28
my $cgi = new CGI;
29
30
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
31
    {
32
        template_name   => "clubs/patron-clubs-tab.tt",
33
        query           => $cgi,
34
        type            => "intranet",
35
        authnotrequired => 0,
36
        flagsrequired   => { clubs => '*' },
37
    }
38
);
39
40
my $borrowernumber = $cgi->param('borrowernumber');
41
42
my $schema = Koha::Database->new()->schema();
43
44
my @enrollments =
45
  $schema->resultset("ClubEnrollment")
46
  ->search( { borrower => $borrowernumber, date_canceled => undef } );
47
48
my @clubs =
49
  $schema->resultset("Club")
50
  ->search(
51
    { id => { -not_in => [ map { $_->club()->id() } @enrollments ] } } );
52
53
$template->param(
54
    enrollments    => \@enrollments,
55
    clubs          => \@clubs,
56
    borrowernumber => $borrowernumber
57
);
58
59
output_html_with_http_headers( $cgi, $cookie, $template->output );
(-)a/clubs/patron-enroll.pl (+52 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Copyright 2013 ByWater Solutions
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it
8
# under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
11
#
12
# Koha is distributed in the hope that it will be useful, but
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
20
use Modern::Perl;
21
22
use CGI;
23
24
use C4::Auth;
25
use C4::Output;
26
use Koha::Database;
27
28
my $cgi = new CGI;
29
30
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
31
    {
32
        template_name   => "clubs/patron-enroll.tt",
33
        query           => $cgi,
34
        type            => "intranet",
35
        authnotrequired => 0,
36
        flagsrequired   => { clubs => '*' },
37
    }
38
);
39
40
my $id             = $cgi->param('id');
41
my $borrowernumber = $cgi->param('borrowernumber');
42
43
my $schema = Koha::Database->new()->schema();
44
45
my $club = $schema->resultset("Club")->find($id);
46
47
$template->param(
48
    club           => $club,
49
    borrowernumber => $borrowernumber,
50
);
51
52
output_html_with_http_headers( $cgi, $cookie, $template->output );
(-)a/clubs/templates-add-modify.pl (+139 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Copyright 2013 ByWater Solutions
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it
8
# under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
11
#
12
# Koha is distributed in the hope that it will be useful, but
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
20
use Modern::Perl;
21
22
use CGI;
23
24
use C4::Auth;
25
use C4::Output;
26
use Koha::Database;
27
use Koha::DateUtils qw(dt_from_string);
28
29
my $cgi = new CGI;
30
31
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
32
    {
33
        template_name   => 'clubs/templates-add-modify.tt',
34
        query           => $cgi,
35
        type            => 'intranet',
36
        authnotrequired => 0,
37
        flagsrequired   => { clubs => 'edit_templates' },
38
    }
39
);
40
41
my $id = $cgi->param('id');
42
43
my $schema = Koha::Database->new()->schema();
44
45
my $club_template;
46
47
if ( $cgi->param('name') ) {    # Update or create club
48
    $club_template = $schema->resultset('ClubTemplate')->update_or_create(
49
        {
50
            id          => $id                        || undef,
51
            name        => $cgi->param('name')        || undef,
52
            description => $cgi->param('description') || undef,
53
            branch      => $cgi->param('branchcode')  || undef,
54
            date_updated            => dt_from_string(),
55
            is_email_required       => $cgi->param('is_email_required') ? 1 : 0,
56
            is_enrollable_from_opac => $cgi->param('is_enrollable_from_opac')
57
            ? 1
58
            : 0,
59
        }
60
    );
61
62
    $id ||= $club_template->id();
63
64
    # Update club creation fields
65
    my @field_id          = $cgi->param('club_template_field_id');
66
    my @field_name        = $cgi->param('club_template_field_name');
67
    my @field_description = $cgi->param('club_template_field_description');
68
    my @field_authorised_value_category =
69
      $cgi->param('club_template_field_authorised_value_category');
70
71
    my @field_delete = $cgi->param('club_template_field_delete');
72
73
    for ( my $i = 0 ; $i < @field_id ; $i++ ) {
74
        my $field_id          = $field_id[$i];
75
        my $field_name        = $field_name[$i];
76
        my $field_description = $field_description[$i];
77
        my $field_authorised_value_category =
78
          $field_authorised_value_category[$i];
79
80
        if ( grep( /^$field_id$/, @field_delete ) ) {
81
            $schema->resultset('ClubTemplateField')->find($field_id)->delete();
82
        }
83
        else {
84
            $club_template =
85
              $schema->resultset('ClubTemplateField')->update_or_create(
86
                {
87
                    id            => $field_id,
88
                    club_template => $id,
89
                    name          => $field_name,
90
                    description   => $field_description,
91
                    authorised_value_category =>
92
                      $field_authorised_value_category,
93
                }
94
              );
95
        }
96
    }
97
98
    # Update club enrollment fields
99
    @field_id   = $cgi->param('club_template_enrollment_field_id');
100
    @field_name = $cgi->param('club_template_enrollment_field_name');
101
    @field_description =
102
      $cgi->param('club_template_enrollment_field_description');
103
    @field_authorised_value_category =
104
      $cgi->param('club_template_enrollment_field_authorised_value_category');
105
106
    @field_delete = $cgi->param('club_template_enrollment_field_delete');
107
108
    for ( my $i = 0 ; $i < @field_id ; $i++ ) {
109
        my $field_id          = $field_id[$i];
110
        my $field_name        = $field_name[$i];
111
        my $field_description = $field_description[$i];
112
        my $field_authorised_value_category =
113
          $field_authorised_value_category[$i];
114
115
        if ( grep( /^$field_id$/, @field_delete ) ) {
116
            $schema->resultset('ClubTemplateEnrollmentField')->find($field_id)
117
              ->delete();
118
        }
119
        else {
120
            $club_template =
121
              $schema->resultset('ClubTemplateEnrollmentField')
122
              ->update_or_create(
123
                {
124
                    id            => $field_id,
125
                    club_template => $id,
126
                    name          => $field_name,
127
                    description   => $field_description,
128
                    authorised_value_category =>
129
                      $field_authorised_value_category,
130
                }
131
              );
132
        }
133
    }
134
}
135
136
$club_template = $schema->resultset('ClubTemplate')->find($id);
137
$template->param( club_template => $club_template );
138
139
output_html_with_http_headers( $cgi, $cookie, $template->output );
(-)a/installer/data/mysql/en/mandatory/userflags.sql (+1 lines)
Lines 18-20 INSERT INTO userflags (bit, flag, flagdesc, defaulton) VALUES Link Here
18
(17,'staffaccess','Allow staff members to modify permissions for other staff members',0),
18
(17,'staffaccess','Allow staff members to modify permissions for other staff members',0),
19
(18,'coursereserves','Course reserves',0),
19
(18,'coursereserves','Course reserves',0),
20
(19, 'plugins', 'Koha plugins', '0');
20
(19, 'plugins', 'Koha plugins', '0');
21
(20, 'clubs', 'Patron clubs', '0');
(-)a/installer/data/mysql/en/mandatory/userpermissions.sql (+3 lines)
Lines 68-71 INSERT INTO permissions (module_bit, code, description) VALUES Link Here
68
   (19, 'tool', 'Use tool plugins'),
68
   (19, 'tool', 'Use tool plugins'),
69
   (19, 'report', 'Use report plugins'),
69
   (19, 'report', 'Use report plugins'),
70
   (19, 'configure', 'Configure plugins')
70
   (19, 'configure', 'Configure plugins')
71
   (20, 'edit_templates', 'Create and update club templates'),
72
   (20, 'edit_clubs', 'Create and update clubs'),
73
   (20, 'enroll', 'Enroll patrons in clubs')
71
;
74
;
(-)a/installer/data/mysql/kohastructure.sql (+173 lines)
Lines 3453-3458 CREATE TABLE IF NOT EXISTS columns_settings ( Link Here
3453
    PRIMARY KEY(module, page, tablename, columnname)
3453
    PRIMARY KEY(module, page, tablename, columnname)
3454
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
3454
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
3455
3455
3456
--
3457
-- Table structure for table 'clubs'
3458
--
3459
3460
CREATE TABLE clubs (
3461
    id int(11) NOT NULL AUTO_INCREMENT,
3462
    club_template int(11) NOT NULL,
3463
    `name` tinytext NOT NULL,
3464
    description text,
3465
    date_start date DEFAULT NULL,
3466
    date_end date DEFAULT NULL,
3467
    branch varchar(11) DEFAULT NULL,
3468
    date_created timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
3469
    date_updated timestamp NULL DEFAULT NULL,
3470
    PRIMARY KEY (id),
3471
    KEY club_template (club_template),
3472
    KEY branch (branch)
3473
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
3474
3475
-- --------------------------------------------------------
3476
3477
--
3478
-- Table structure for table 'club_enrollments'
3479
--
3480
3481
CREATE TABLE club_enrollments (
3482
    id int(11) NOT NULL AUTO_INCREMENT,
3483
    club int(11) NOT NULL,
3484
    borrower int(11) NOT NULL,
3485
    date_enrolled timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
3486
    date_canceled timestamp NULL DEFAULT NULL,
3487
    date_created timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
3488
    date_updated timestamp NULL DEFAULT NULL,
3489
    branch varchar(11) DEFAULT NULL,
3490
    PRIMARY KEY (id),
3491
    KEY club (club),
3492
    KEY borrower (borrower),
3493
    KEY branch (branch)
3494
) ENGINE=InnoDB  DEFAULT CHARSET=utf8;
3495
3496
-- --------------------------------------------------------
3497
3498
--
3499
-- Table structure for table 'club_enrollment_fields'
3500
--
3501
3502
CREATE TABLE club_enrollment_fields (
3503
    id int(11) NOT NULL AUTO_INCREMENT,
3504
    club_enrollment int(11) NOT NULL,
3505
    club_template_enrollment_field int(11) NOT NULL,
3506
    `value` text NOT NULL,
3507
    PRIMARY KEY (id),
3508
    KEY club_enrollment (club_enrollment),
3509
    KEY club_template_enrollment_field (club_template_enrollment_field),
3510
    KEY club_template_enrollment_field_2 (club_template_enrollment_field)
3511
) ENGINE=InnoDB  DEFAULT CHARSET=utf8;
3512
3513
-- --------------------------------------------------------
3514
3515
--
3516
-- Table structure for table 'club_fields'
3517
--
3518
3519
CREATE TABLE club_fields (
3520
    id int(11) NOT NULL AUTO_INCREMENT,
3521
    club_template_field int(11) NOT NULL,
3522
    club int(11) NOT NULL,
3523
    `value` text,
3524
    PRIMARY KEY (id),
3525
    KEY club_template_field (club_template_field,club),
3526
    KEY club (club)
3527
) ENGINE=InnoDB  DEFAULT CHARSET=utf8;
3528
3529
-- --------------------------------------------------------
3530
3531
--
3532
-- Table structure for table 'club_templates'
3533
--
3534
3535
CREATE TABLE club_templates (
3536
    id int(11) NOT NULL AUTO_INCREMENT,
3537
    `name` tinytext NOT NULL,
3538
    description text,
3539
    is_enrollable_from_opac tinyint(1) NOT NULL DEFAULT '0',
3540
    is_email_required tinyint(1) NOT NULL DEFAULT '0',
3541
    branch varchar(10) CHARACTER SET utf8 DEFAULT NULL,
3542
    date_created timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
3543
    date_updated timestamp NULL DEFAULT NULL,
3544
    is_deletable tinyint(1) NOT NULL DEFAULT '1',
3545
    PRIMARY KEY (id),
3546
    KEY branch (branch)
3547
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
3548
3549
-- --------------------------------------------------------
3550
3551
--
3552
-- Table structure for table 'club_template_enrollment_fields'
3553
--
3554
3555
CREATE TABLE club_template_enrollment_fields (
3556
    id int(11) NOT NULL AUTO_INCREMENT,
3557
    club_template int(11) NOT NULL,
3558
    `name` tinytext NOT NULL,
3559
    description text,
3560
    authorised_value_category varchar(16) DEFAULT NULL,
3561
    PRIMARY KEY (id),
3562
    KEY club_template (club_template),
3563
    KEY club_template_2 (club_template)
3564
) ENGINE=InnoDB  DEFAULT CHARSET=utf8;
3565
3566
-- --------------------------------------------------------
3567
3568
--
3569
-- Table structure for table 'club_template_fields'
3570
--
3571
3572
CREATE TABLE club_template_fields (
3573
    id int(11) NOT NULL AUTO_INCREMENT,
3574
    club_template int(11) NOT NULL,
3575
    `name` tinytext NOT NULL,
3576
    description text,
3577
    authorised_value_category varchar(16) DEFAULT NULL,
3578
    PRIMARY KEY (id),
3579
    KEY club_template (club_template)
3580
) ENGINE=InnoDB  DEFAULT CHARSET=utf8;
3581
3582
--
3583
-- Constraints for table `clubs`
3584
--
3585
ALTER TABLE `clubs`
3586
ADD CONSTRAINT clubs_ibfk_1 FOREIGN KEY (club_template) REFERENCES club_templates (id) ON DELETE CASCADE ON UPDATE CASCADE,
3587
ADD CONSTRAINT clubs_ibfk_2 FOREIGN KEY (branch) REFERENCES branches (branchcode);
3588
3589
--
3590
-- Constraints for table `club_enrollments`
3591
--
3592
ALTER TABLE `club_enrollments`
3593
ADD CONSTRAINT club_enrollments_ibfk_1 FOREIGN KEY (club) REFERENCES clubs (id) ON DELETE CASCADE ON UPDATE CASCADE,
3594
ADD CONSTRAINT club_enrollments_ibfk_2 FOREIGN KEY (borrower) REFERENCES borrowers (borrowernumber) ON DELETE CASCADE ON UPDATE CASCADE,
3595
ADD CONSTRAINT club_enrollments_ibfk_3 FOREIGN KEY (branch) REFERENCES branches (branchcode) ON DELETE SET NULL ON UPDATE CASCADE;
3596
3597
--
3598
-- Constraints for table `club_enrollment_fields`
3599
--
3600
ALTER TABLE `club_enrollment_fields`
3601
ADD CONSTRAINT club_enrollment_fields_ibfk_1 FOREIGN KEY (club_enrollment) REFERENCES club_enrollments (id) ON DELETE CASCADE ON UPDATE CASCADE,
3602
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;
3603
3604
--
3605
-- Constraints for table `club_fields`
3606
--
3607
ALTER TABLE `club_fields`
3608
ADD CONSTRAINT club_fields_ibfk_3 FOREIGN KEY (club_template_field) REFERENCES club_template_fields (id) ON DELETE CASCADE ON UPDATE CASCADE,
3609
ADD CONSTRAINT club_fields_ibfk_4 FOREIGN KEY (club) REFERENCES clubs (id) ON DELETE CASCADE ON UPDATE CASCADE;
3610
3611
--
3612
-- Constraints for table `club_templates`
3613
--
3614
ALTER TABLE `club_templates`
3615
ADD CONSTRAINT club_templates_ibfk_1 FOREIGN KEY (branch) REFERENCES branches (branchcode) ON DELETE SET NULL ON UPDATE CASCADE;
3616
3617
--
3618
-- Constraints for table `club_template_enrollment_fields`
3619
--
3620
ALTER TABLE `club_template_enrollment_fields`
3621
ADD CONSTRAINT club_template_enrollment_fields_ibfk_1 FOREIGN KEY (club_template) REFERENCES club_templates (id) ON DELETE CASCADE ON UPDATE CASCADE;
3622
3623
--
3624
-- Constraints for table `club_template_fields`
3625
--
3626
ALTER TABLE `club_template_fields`
3627
ADD CONSTRAINT club_template_fields_ibfk_1 FOREIGN KEY (club_template) REFERENCES club_templates (id) ON DELETE CASCADE ON UPDATE CASCADE;
3628
3456
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
3629
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
3457
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
3630
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
3458
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
3631
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
(-)a/installer/data/mysql/updatedatabase.pl (+148 lines)
Lines 8751-8756 if ( CheckVersion($DBversion) ) { Link Here
8751
    SetVersion($DBversion);
8751
    SetVersion($DBversion);
8752
}
8752
}
8753
8753
8754
$DBversion = "3.17.00.XXX";
8755
if ( CheckVersion($DBversion) ) {
8756
    $dbh->do("INSERT INTO userflags (bit, flag, flagdesc, defaulton) VALUES ('20', 'clubs', 'Patron clubs', '0')");
8757
8758
    $dbh->do("
8759
        CREATE TABLE clubs (
8760
            id int(11) NOT NULL AUTO_INCREMENT,
8761
            club_template int(11) NOT NULL,
8762
            `name` tinytext NOT NULL,
8763
            description text,
8764
            date_start date DEFAULT NULL,
8765
            date_end date DEFAULT NULL,
8766
            branch varchar(11) DEFAULT NULL,
8767
            date_created timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
8768
            date_updated timestamp NULL DEFAULT NULL,
8769
            PRIMARY KEY (id),
8770
            KEY club_template (club_template),
8771
            KEY branch (branch)
8772
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
8773
    ");
8774
8775
    $dbh->do("
8776
        CREATE TABLE club_enrollments (
8777
            id int(11) NOT NULL AUTO_INCREMENT,
8778
            club int(11) NOT NULL,
8779
            borrower int(11) NOT NULL,
8780
            date_enrolled timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
8781
            date_canceled timestamp NULL DEFAULT NULL,
8782
            date_created timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
8783
            date_updated timestamp NULL DEFAULT NULL,
8784
            branch varchar(11) DEFAULT NULL,
8785
            PRIMARY KEY (id),
8786
            KEY club (club),
8787
            KEY borrower (borrower),
8788
            KEY branch (branch)
8789
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
8790
    ");
8791
8792
    $dbh->do("
8793
        CREATE TABLE club_enrollment_fields (
8794
            id int(11) NOT NULL AUTO_INCREMENT,
8795
            club_enrollment int(11) NOT NULL,
8796
            club_template_enrollment_field int(11) NOT NULL,
8797
            `value` text NOT NULL,
8798
            PRIMARY KEY (id),
8799
            KEY club_enrollment (club_enrollment),
8800
            KEY club_template_enrollment_field (club_template_enrollment_field),
8801
            KEY club_template_enrollment_field_2 (club_template_enrollment_field)
8802
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
8803
    ");
8804
8805
    $dbh->do("
8806
        CREATE TABLE club_fields (
8807
            id int(11) NOT NULL AUTO_INCREMENT,
8808
            club_template_field int(11) NOT NULL,
8809
            club int(11) NOT NULL,
8810
            `value` text,
8811
            PRIMARY KEY (id),
8812
            KEY club_template_field (club_template_field,club),
8813
            KEY club (club)
8814
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
8815
    ");
8816
8817
    $dbh->do("
8818
        CREATE TABLE club_templates (
8819
            id int(11) NOT NULL AUTO_INCREMENT,
8820
            `name` tinytext NOT NULL,
8821
            description text,
8822
            is_enrollable_from_opac tinyint(1) NOT NULL DEFAULT '0',
8823
            is_email_required tinyint(1) NOT NULL DEFAULT '0',
8824
            branch varchar(10) CHARACTER SET utf8 DEFAULT NULL,
8825
            date_created timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
8826
            date_updated timestamp NULL DEFAULT NULL,
8827
            is_deletable tinyint(1) NOT NULL DEFAULT '1',
8828
            PRIMARY KEY (id),
8829
            KEY branch (branch)
8830
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8 DEFAULT;
8831
    ");
8832
8833
    $dbh->do("
8834
        CREATE TABLE club_template_enrollment_fields (
8835
            id int(11) NOT NULL AUTO_INCREMENT,
8836
            club_template int(11) NOT NULL,
8837
            `name` tinytext NOT NULL,
8838
            description text,
8839
            authorised_value_category varchar(16) DEFAULT NULL,
8840
            PRIMARY KEY (id),
8841
            KEY club_template (club_template),
8842
            KEY club_template_2 (club_template)
8843
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
8844
    ");
8845
8846
    $dbh->do("
8847
        CREATE TABLE club_template_fields (
8848
            id int(11) NOT NULL AUTO_INCREMENT,
8849
            club_template int(11) NOT NULL,
8850
            `name` tinytext NOT NULL,
8851
            description text,
8852
            authorised_value_category varchar(16) DEFAULT NULL,
8853
            PRIMARY KEY (id),
8854
            KEY club_template (club_template)
8855
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
8856
    ");
8857
8858
    $dbh->do("
8859
        ALTER TABLE `clubs`
8860
            ADD CONSTRAINT clubs_ibfk_1 FOREIGN KEY (club_template) REFERENCES club_templates (id) ON DELETE CASCADE ON UPDATE CASCADE,
8861
            ADD CONSTRAINT clubs_ibfk_2 FOREIGN KEY (branch) REFERENCES branches (branchcode);
8862
    ");
8863
8864
    $dbh->do("
8865
        ALTER TABLE `club_enrollments`
8866
            ADD CONSTRAINT club_enrollments_ibfk_1 FOREIGN KEY (club) REFERENCES clubs (id) ON DELETE CASCADE ON UPDATE CASCADE,
8867
            ADD CONSTRAINT club_enrollments_ibfk_2 FOREIGN KEY (borrower) REFERENCES borrowers (borrowernumber) ON DELETE CASCADE ON UPDATE CASCADE,
8868
            ADD CONSTRAINT club_enrollments_ibfk_3 FOREIGN KEY (branch) REFERENCES branches (branchcode) ON DELETE SET NULL ON UPDATE CASCADE;
8869
    ");
8870
8871
    $dbh->do("
8872
        ALTER TABLE `club_enrollment_fields`
8873
            ADD CONSTRAINT club_enrollment_fields_ibfk_1 FOREIGN KEY (club_enrollment) REFERENCES club_enrollments (id) ON DELETE CASCADE ON UPDATE CASCADE,
8874
            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;
8875
    ");
8876
8877
    $dbh->do("
8878
        ALTER TABLE `club_fields`
8879
            ADD CONSTRAINT club_fields_ibfk_3 FOREIGN KEY (club_template_field) REFERENCES club_template_fields (id) ON DELETE CASCADE ON UPDATE CASCADE,
8880
            ADD CONSTRAINT club_fields_ibfk_4 FOREIGN KEY (club) REFERENCES clubs (id) ON DELETE CASCADE ON UPDATE CASCADE;
8881
    ");
8882
8883
    $dbh->do("
8884
        ALTER TABLE `club_templates`
8885
            ADD CONSTRAINT club_templates_ibfk_1 FOREIGN KEY (branch) REFERENCES branches (branchcode) ON DELETE SET NULL ON UPDATE CASCADE;
8886
    ");
8887
8888
    $dbh->do("
8889
        ALTER TABLE `club_template_enrollment_fields`
8890
            ADD CONSTRAINT club_template_enrollment_fields_ibfk_1 FOREIGN KEY (club_template) REFERENCES club_templates (id) ON DELETE CASCADE ON UPDATE CASCADE;
8891
    ");
8892
8893
    $dbh->do("
8894
        ALTER TABLE `club_template_fields`
8895
            ADD CONSTRAINT club_template_fields_ibfk_1 FOREIGN KEY (club_template) REFERENCES club_templates (id) ON DELETE CASCADE ON UPDATE CASCADE;
8896
    ");
8897
8898
   print "Upgrade to $DBversion done (Bug 12461 - Add patron clubs feature)\n";
8899
   SetVersion ($DBversion);
8900
}
8901
8754
=head1 FUNCTIONS
8902
=head1 FUNCTIONS
8755
8903
8756
=head2 TableExists($table)
8904
=head2 TableExists($table)
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt (+19 lines)
Lines 45-50 var MSG_EXPORT_SELECT_CHECKOUTS = _("You must select checkout(s) to export"); Link Here
45
45
46
$(document).ready(function() {
46
$(document).ready(function() {
47
    [% IF !( CircAutoPrintQuickSlip == 'clear' ) %]
47
    [% IF !( CircAutoPrintQuickSlip == 'clear' ) %]
48
        $('#clubs-tab-link').on('click', function() {
49
            $('#clubs-tab').text(_("Loading..."));
50
            $('#clubs-tab').load('/cgi-bin/koha/clubs/patron-clubs-tab.pl?borrowernumber=[% borrowernumber %]');
51
        });
52
48
        // listen submit to trigger qslip on empty checkout
53
        // listen submit to trigger qslip on empty checkout
49
        $('#mainform').bind('submit',function() {
54
        $('#mainform').bind('submit',function() {
50
            if ($('#barcode').val() == '') {
55
            if ($('#barcode').val() == '') {
Lines 666-671 No patron matched <span class="ex">[% message %]</span> Link Here
666
        [% END %]
671
        [% END %]
667
    </li>
672
    </li>
668
673
674
    [% IF CAN_user_clubs && ( borrower.ClubsEnrolledCount || borrower.ClubsEnrollableCount ) %]
675
        <li>
676
            <a id="clubs-tab-link" href="#clubs-tab">
677
                Clubs ([% borrower.ClubsEnrolledCount %]/[% borrower.ClubsEnrollableCount %])
678
            </a>
679
        </li>
680
    [% END %]
681
669
    [% IF relatives_issues_count %]
682
    [% IF relatives_issues_count %]
670
        <li><a id="relatives-issues-tab" href="#relatives-issues">Relatives' checkouts</a></li>
683
        <li><a id="relatives-issues-tab" href="#relatives-issues">Relatives' checkouts</a></li>
671
    [% END %]
684
    [% END %]
Lines 741-746 No patron matched <span class="ex">[% message %]</span> Link Here
741
    </div>
754
    </div>
742
[% END %]
755
[% END %]
743
756
757
[% IF CAN_user_clubs %]
758
    <div id="clubs-tab">
759
        Loading...
760
    </div>
761
[% END %]
762
744
[% INCLUDE borrower_debarments.inc %]
763
[% INCLUDE borrower_debarments.inc %]
745
764
746
<div id="reserves">
765
<div id="reserves">
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/clubs/clubs-add-modify.tt (+136 lines)
Line 0 Link Here
1
[% USE KohaDates %]
2
[% USE EncodeUTF8 %]
3
[% USE Branches %]
4
[% USE AuthorisedValues %]
5
[% SET AuthorisedValuesCategories = AuthorisedValues.Categories %]
6
[% INCLUDE 'doc-head-open.inc' %]
7
<title>Koha &rsaquo; Tools &rsaquo; Patron clubs &rsaquo; Club</title>
8
[% INCLUDE 'doc-head-close.inc' %]
9
[% INCLUDE 'calendar.inc' %]
10
11
<script type="text/javascript">
12
//<![CDATA[
13
14
function CheckForm() {
15
  if ( !$("#club-name").val() ) {
16
    alert( _("Name is a required field!")  );
17
    return false;
18
  }
19
20
  return true;
21
}
22
23
//]]>
24
</script>
25
26
</head>
27
28
<body>
29
[% INCLUDE 'header.inc' %]
30
[% INCLUDE 'cat-search.inc' %]
31
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> &rsaquo; <a href="clubs.pl">Patron clubs</a> &rsaquo; Add / modify club</div>
32
33
<div class="yui-t7">
34
    <div class="yui-main">
35
        <form method="post" onsubmit="return CheckForm()">
36
            <input type="hidden" name="id" value="[% club.id %]" />
37
            <input type="hidden" name="club_template_id" value="[% club_template.id %]" />
38
39
            <fieldset class="rows">
40
41
                <legend>
42
                    [% IF club %]
43
                        Modify club <i>[% club.name %]</i>
44
                    [% ELSE %]
45
                        Create a new <i>[% club_template.name %]</i> club
46
                    [% END %]
47
                </legend>
48
49
                <ol>
50
                    <li>
51
                        <label class="required" for="name">Name:</label>
52
                        <input id="club-name" name="name" type="text" value="[% club.name %]" />
53
                    </li>
54
55
                    <li>
56
                        <label for="description">Description:</label>
57
                        <input id="club-template-name" name="description" type="text" value="[% club.description %]" />
58
                    </li>
59
60
                    <li>
61
                        <label for="date_start">Start date:</label>
62
                        <input name="date_start" id="from" size="10" readonly="readonly" class="datepickerfrom" value="[% club.date_start | $KohaDates %]">
63
                    </li>
64
65
                    <li>
66
                        <label for="date_end">End date:</label>
67
                        <input name="date_end" id="to" size="10" readonly="readonly" class="datepickerto" value="[% club.date_end | $KohaDates %]" >
68
                    </li>
69
70
                    <li>
71
                        <label for="name">Branch:</label>
72
                        <select name="branchcode" id="club-template-branchcode">
73
                            <option value="">&nbsp</option>
74
                            [% FOREACH b IN Branches.GetBranches() %]
75
                                [% IF b.branchcode == club.branch.branchcode %]
76
                                    <option value="[% b.branchcode %]" selected="selected">[% b.branchname | $EncodeUTF8 %]</option>
77
                                [% ELSE %]
78
                                    <option value="[% b.branchcode %]">[% b.branchname | $EncodeUTF8 %]</option>
79
                                [% END %]
80
                            [% END %]
81
                        </select>
82
                    </li>
83
84
                    [% IF club %]
85
                        [% FOREACH f IN club.club_fields %]
86
                            <li>
87
                                <input type="hidden" name="club_template_field_id" value="[% f.club_template_field.id %]" />
88
                                <input type="hidden" name="club_field_id" value="[% f.id %]" />
89
90
                                <label for="club_field">[% f.club_template_field.name %]</label>
91
                                [% IF f.club_template_field.authorised_value_category %]
92
                                    <select name="club_field">
93
                                        [% FOREACH a IN AuthorisedValues.Get( f.club_template_field.authorised_value_category ) %]
94
                                            [% IF a.authorised_value == f.value %]
95
                                                <option value="[% a.authorised_value %]" selected="selected">[% a.lib %]</option>
96
                                            [% ELSE %]
97
                                                <option value="[% a.authorised_value %]">[% a.lib %]</option>
98
                                            [% END %]
99
                                        [% END %]
100
                                    </select>
101
                                [% ELSE %]
102
                                    <input type="text" name="club_field" value="[% f.value %]" />
103
                                [% END %]
104
                            </li>
105
                        [% END %]
106
                    [% ELSE %]
107
                        [% FOREACH f IN club_template.club_template_fields %]
108
                            <li>
109
                                <input type="hidden" name="club_template_field_id" value="[% f.id %]" />
110
111
                                <label for="club_field">[% f.name %]</label>
112
                                [% IF f.authorised_value_category %]
113
                                    <select name="club_field">
114
                                        [% FOREACH a IN AuthorisedValues.Get( f.authorised_value_category ) %]
115
                                            <option value="[% a.authorised_value %]">[% a.lib %]</option>
116
                                        [% END %]
117
                                    </select>
118
                                [% ELSE %]
119
                                    <input type="text" name="club_field" />
120
                                [% END %]
121
                            </li>
122
                        [% END %]
123
                    [% END %]
124
125
                </ol>
126
127
            </fieldset>
128
129
            <input type="submit" class="btn" value="Save" />
130
131
            <a href="clubs.pl" class="cancel">Cancel</a>
132
        </form>
133
    </div>
134
</div>
135
136
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/clubs/clubs.tt (+206 lines)
Line 0 Link Here
1
[% USE EncodeUTF8 %]
2
[% USE Koha %]
3
[% INCLUDE 'doc-head-open.inc' %]
4
<title>Koha &rsaquo; Tools &rsaquo; Patron clubs</title>
5
[% INCLUDE 'doc-head-close.inc' %]
6
7
<link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" />
8
[% INCLUDE 'datatables.inc' %]
9
10
<script type="text/javascript">
11
//<![CDATA[
12
    $(document).ready(function() {
13
        tTable = $('#club-templates-table').dataTable($.extend(true, {}, dataTablesDefaults, {
14
            "aoColumnDefs": [
15
                { "aTargets": [ -1, -2 ], "bSortable": false, "bSearchable": false },
16
            ]
17
        } ));
18
19
        cTable = $('#clubs-table').dataTable($.extend(true, {}, dataTablesDefaults, {
20
            "aoColumnDefs": [
21
                { "aTargets": [ -1, -2 ], "bSortable": false, "bSearchable": false },
22
            ]
23
        } ));
24
    });
25
26
    function ConfirmDeleteTemplate( id, name, a ) {
27
        if ( confirm( _("Are you sure you want to delete the club template") + name + "?" ) ) {
28
            $.ajax({
29
                type: "POST",
30
                url: '/cgi-bin/koha/svc/club/template/delete',
31
                data: { id: id },
32
                success: function( data ) {
33
                    if ( data.success ) {
34
                        tTable.fnDeleteRow(a.closest("tr")[0]);
35
                    } else {
36
                        alert(_("Unable to delete template!"));
37
                    }
38
                },
39
                dataType: 'json'
40
            });
41
        }
42
    }
43
44
    function ConfirmDeleteClub( id, name, a ) {
45
        if ( confirm( _("Are you sure you want to delete the club ") + name + "?" ) ) {
46
            $.ajax({
47
                type: "POST",
48
                url: '/cgi-bin/koha/svc/club/delete',
49
                data: { id: id },
50
                success: function( data ) {
51
                    if ( data.success ) {
52
                        cTable.fnDeleteRow(a.closest("tr")[0]);
53
                    } else {
54
                        alert(_("Unable to delete club!"));
55
                    }
56
                },
57
                dataType: 'json'
58
            });
59
        }
60
    }
61
//]]>
62
</script>
63
64
</head>
65
66
<body>
67
[% INCLUDE 'header.inc' %]
68
[% INCLUDE 'cat-search.inc' %]
69
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> &rsaquo; Patron clubs</div>
70
71
<div class="yui-t7">
72
    <div class="yui-main">
73
        <h1>Patron clubs</h1>
74
75
76
        <h3>Club templates</h3>
77
78
        [% IF CAN_user_clubs_edit_templates %]
79
            <div class="btn-group">
80
                <a class="btn btn-small" href="templates-add-modify.pl"><i class="icon-plus"></i> New club template</a>
81
            </div>
82
        [% END %]
83
84
        <table id="club-templates-table">
85
            <thead>
86
                <tr>
87
                    <th>Name</th>
88
                    <th>Description</th>
89
                    <th>Public enrollment</th>
90
                    <th>Email required</th>
91
                    <th>Branch</th>
92
                    <th>&nbsp;</th>
93
                    <th>&nbsp;</th>
94
                </tr>
95
            </thead>
96
97
            <tbody>
98
                [% FOREACH t IN club_templates %]
99
                    <tr>
100
                        <td>[% t.name | $EncodeUTF8 %]</td>
101
                        <td>[% t.description | $EncodeUTF8 %]</td>
102
                        <td>
103
                            [% IF t.is_enrollable_from_opac %]
104
                                Yes
105
                            [% ELSE %]
106
                                No
107
                            [% END %]
108
                        </td>
109
                        <td>
110
                            [% IF t.is_email_required %]
111
                                Yes
112
                            [% ELSE %]
113
                                No
114
                            [% END %]
115
                        </td>
116
                        <td>[% t.branch.branchname | $EncodeUTF8 %]</td>
117
                        <td>
118
                            [% IF CAN_user_clubs_edit_templates && t.is_deletable && ( CAN_user_superlibrarian || t.branch.branchcode == Koha.UserEnv('branch') ) %]
119
                                <a class="btn btn-mini" href="templates-add-modify.pl?id=[% t.id %]">
120
                                    <i class="icon-edit"></i> Edit
121
                                </a>
122
                            [% END %]
123
                        </td>
124
                        <td>
125
                            [% IF CAN_user_clubs_edit_templates && t.is_deletable && ( CAN_user_superlibrarian || t.branch.branchcode == Koha.UserEnv('branch') ) %]
126
                                <a class="btn btn-mini" href="#" onclick='ConfirmDeleteTemplate([% t.id %], "[% t.name | html %]", $(this) ); return false;'>
127
                                    <i class="icon-trash"></i> Delete
128
                                </a>
129
                            [% END %]
130
                        </td>
131
                    </tr>
132
                [% END %]
133
            </tbody>
134
        </table>
135
136
        <h3>Clubs</h3>
137
138
        [% IF CAN_user_clubs_edit_clubs %]
139
            <div class="btn-group">
140
                <div class="btn-group">
141
                    <button class="btn btn-small dropdown-toggle" data-toggle="dropdown"><i class="icon-plus"></i> New club <span class="caret"></span></button>
142
                    <ul class="dropdown-menu">
143
                        [% FOREACH t IN club_templates %]
144
                            <li><a href="/cgi-bin/koha/clubs/clubs-add-modify.pl?club_template_id=[% t.id %]">[% t.name %]</a></li>
145
                        [% END %]
146
                    </ul>
147
                </div>
148
            </div>
149
        [% END %]
150
151
        <table id="clubs-table">
152
            <thead>
153
                <tr>
154
                    <th>Name</th>
155
                    <th>Template</th>
156
                    <th>Description</th>
157
                    <th>Public enrollment</th>
158
                    <th>Email required</th>
159
                    <th>Branch</th>
160
                    <th>&nbsp;</th>
161
                    <th>&nbsp;</th>
162
                </tr>
163
            </thead>
164
165
            <tbody>
166
                [% FOREACH c IN clubs %]
167
                    <tr>
168
                        <td>[% c.name | $EncodeUTF8 %]</td>
169
                        <td>[% c.club_template.name | $EncodeUTF8 %]</td>
170
                        <td>[% c.description | $EncodeUTF8 %]</td>
171
                        <td>
172
                            [% IF c.club_template.is_enrollable_from_opac %]
173
                                Yes
174
                            [% ELSE %]
175
                                No
176
                            [% END %]
177
                        </td>
178
                        <td>
179
                            [% IF c.club_template.is_email_required %]
180
                                Yes
181
                            [% ELSE %]
182
                                No
183
                            [% END %]
184
                        </td>
185
                        <td>[% c.branch.branchname | $EncodeUTF8 %]</td>
186
                        <td>
187
                            [% IF CAN_user_clubs_edit_clubs && ( CAN_user_superlibrarian || c.branch.branchcode == Koha.UserEnv('branch') ) %]
188
                                <a class="btn btn-mini" href="clubs-add-modify.pl?id=[% c.id %]">
189
                                    <i class="icon-edit"></i> Edit
190
                                </a>
191
                            [% END %]
192
                        </td>
193
                        <td>
194
                            [% IF CAN_user_clubs_edit_clubs && ( CAN_user_superlibrarian || c.branch.branchcode == Koha.UserEnv('branch') ) %]
195
                                <a class="btn btn-mini" href="#" onclick='ConfirmDeleteClub([% c.id %], "[% c.name | html %]", $(this) ); return false;'>
196
                                    <i class="icon-trash"></i> Delete
197
                                </a>
198
                            [% END %]
199
                        </td>
200
                    </tr>
201
                [% END %]
202
            </tbody>
203
        </table>
204
    </div>
205
</div>
206
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/clubs/patron-clubs-tab.tt (+103 lines)
Line 0 Link Here
1
[% USE EncodeUTF8 %]
2
[% USE KohaDates %]
3
4
[% IF enrollments %]
5
    <table>
6
        <thead>
7
            <tr>
8
                <th colspan="4">
9
                    Clubs currently enrolled in
10
                </th>
11
            </tr>
12
            <tr>
13
                <th>Name</th>
14
                <th>Description</th>
15
                <th>Date enrolled</th>
16
                [% IF CAN_user_clubs_enroll %]<th>&nbsp;</th>[% END %]
17
            </tr>
18
        </thead>
19
20
        <tbody>
21
            [% FOREACH e IN enrollments %]
22
                <tr>
23
                    <td>[% e.club.name | $EncodeUTF8 %]</td>
24
                    <td>[% e.club.description | $EncodeUTF8 %]</td>
25
                    <td>[% e.date_enrolled | $KohaDates %]</td>
26
                    [% IF CAN_user_clubs_enroll %]
27
                        <td>
28
                            <a class="btn btn-mini" onclick="cancelEnrollment( [% e.id %] )">
29
                                <i class="icon-remove"></i> Cancel
30
                            </a>
31
                        </td>
32
                    [% END %]
33
                </tr>
34
            [% END %]
35
        </tbody>
36
    </table>
37
[% END %]
38
39
[% IF clubs %]
40
    <table>
41
        <thead>
42
            <tr>
43
                <th colspan="3">
44
                    Clubs not enrolled in
45
                </th>
46
            </tr>
47
            <tr>
48
                <th>Name</th>
49
                <th>Description</th>
50
                [% IF CAN_user_clubs_enroll %]<th>&nbsp;</th>[% END %]
51
            </tr>
52
        </thead>
53
54
        <tbody>
55
            [% FOREACH c IN clubs %]
56
                <tr>
57
                    <td>[% c.name | $EncodeUTF8 %]</td>
58
                    <td>[% c.description | $EncodeUTF8 %]</td>
59
                    [% IF CAN_user_clubs_enroll %]
60
                        <td>
61
                            <a class="btn btn-mini" onclick="loadEnrollmentForm([% c.id %])">
62
                                <i class="icon-plus"></i> Enroll
63
                            </a>
64
                        </td>
65
                    [% END %]
66
                </tr>
67
            [% END %]
68
        </tbody>
69
    </table>
70
[% END %]
71
72
[% IF CAN_user_clubs_enroll %]
73
<script type="text/javascript">
74
function loadEnrollmentForm( id ) {
75
    $("body").css("cursor", "progress");
76
    $('#clubs-tab').load('/cgi-bin/koha/clubs/patron-enroll.pl?borrowernumber=[% borrowernumber %]&id=' + id, function() {
77
        $("body").css("cursor", "default");
78
    });
79
80
    return false;
81
}
82
83
function cancelEnrollment( id ) {
84
    $("body").css("cursor", "progress");
85
    $.ajax({
86
        type: "POST",
87
        url: '/cgi-bin/koha/svc/club/cancel_enrollment',
88
        data: { id: id },
89
        success: function( data ) {
90
            if ( data.success ) {
91
                $('#clubs-tab').load('/cgi-bin/koha/clubs/patron-clubs-tab.pl?borrowernumber=[% borrowernumber %]', function() {
92
                    $("body").css("cursor", "default");
93
                });
94
            } else {
95
                alert(_("Unable to cancel enrollment!"));
96
            }
97
        },
98
        dataType: 'json'
99
    });
100
    return false;
101
}
102
</script>
103
[% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/clubs/patron-enroll.tt (+67 lines)
Line 0 Link Here
1
[% USE EncodeUTF8 %]
2
[% USE AuthorisedValues %]
3
[% SET AuthorisedValuesCategories = AuthorisedValues.Categories %]
4
5
<h3>
6
    Enroll in <i>[% club.name | $EncodeUTF8 %]</i>
7
</h3>
8
9
<div class="container">
10
    <form id="patron-enrollment-form">
11
        <input type="hidden" name="id" value="[% club.id %]" />
12
        <input type="hidden" name="borrowernumber" value="[% borrowernumber %]" />
13
        <fieldset class="rows">
14
            <ol>
15
                [% FOREACH f IN club.club_template.club_template_enrollment_fields %]
16
                    <li>
17
                        <label>[% f.name %]</label>
18
                        [% IF f.authorised_value_category %]
19
                            <select name="[% f.id %]">
20
                                [% FOREACH a IN AuthorisedValues.Get( f.club_template_field.authorised_value_category ) %]
21
                                    <option value="[% a.authorised_value %]">[% a.lib %]</option>
22
                                [% END %]
23
                            </select>
24
                        [% ELSE %]
25
                            <input type="text" name="[% f.id %]" />
26
                        [% END %]
27
                        <span class="hint">[% f.description %]</span>
28
                    </li>
29
                [% END %]
30
31
                <li>
32
                    <a href="#" class="btn" onclick="addEnrollment(); return false;"><i class="icon-plus"></i> Enroll</a>
33
                    <a href="#" onclick="showClubs(); return false;">Cancel</a>
34
                </li>
35
            </ol>
36
        </fieldset>
37
    </form>
38
</div>
39
40
<script type="text/javascript">
41
function addEnrollment() {
42
    $("body").css("cursor", "progress");
43
    $.ajax({
44
        type: "POST",
45
        url: '/cgi-bin/koha/svc/club/enroll',
46
        data: $( "#patron-enrollment-form" ).serialize(),
47
        success: function( data ) {
48
            if ( data.success ) {
49
                $('#clubs-tab').load('/cgi-bin/koha/clubs/patron-clubs-tab.pl?borrowernumber=[% borrowernumber %]&id=[% club.id %]', function() {
50
                    $("body").css("cursor", "default");
51
                });
52
            } else {
53
                alert(_("Unable to create enrollment!"));
54
            }
55
        },
56
        dataType: 'json'
57
    });
58
    return false;
59
}
60
61
function showClubs() {
62
    $("body").css("cursor", "progress");
63
    $('#clubs-tab').load('/cgi-bin/koha/clubs/patron-clubs-tab.pl?borrowernumber=[% borrowernumber %]&id=[% club.id %]', function() {
64
        $("body").css("cursor", "default");
65
    });
66
}
67
</script>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/clubs/templates-add-modify.tt (+252 lines)
Line 0 Link Here
1
[% USE EncodeUTF8 %]
2
[% USE Branches %]
3
[% USE AuthorisedValues %]
4
[% SET AuthorisedValuesCategories = AuthorisedValues.Categories %]
5
[% INCLUDE 'doc-head-open.inc' %]
6
<title>Koha &rsaquo; Tools &rsaquo; Patron clubs &rsaquo; Club template</title>
7
[% INCLUDE 'doc-head-close.inc' %]
8
9
<script type="text/javascript">
10
//<![CDATA[
11
12
function CheckForm() {
13
  if ( !$("#club-template-name").val() ) {
14
    alert( _("Name is a required field!")  );
15
    return false;
16
  }
17
18
  return true;
19
}
20
21
//]]>
22
</script>
23
24
</head>
25
26
<body>
27
[% INCLUDE 'header.inc' %]
28
[% INCLUDE 'cat-search.inc' %]
29
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> &rsaquo; <a href="clubs.pl">Patron clubs</a> &rsaquo; Add / modify club template</div>
30
31
<div class="yui-t7">
32
    <div class="yui-main">
33
34
        <form method="post" onsubmit="return CheckForm()">
35
            <input type="hidden" name="id" value="[% club_template.id %]" />
36
37
            <fieldset class="rows">
38
39
                <legend>
40
                    [% IF club_template %]
41
                        Modify club template <i>[% club_template.name %]</i>
42
                    [% ELSE %]
43
                        Create a new club template
44
                    [% END %]
45
                </legend>
46
47
                <ol>
48
                    <li>
49
                        <label class="required" for="name">Name:</label>
50
                        <input id="club-template-name" name="name" type="text" value="[% club_template.name %]" />
51
                    </li>
52
53
                    <li>
54
                        <label for="description">Description:</label>
55
                        <input id="club-template-description" name="description" type="text" value="[% club_template.description %]" />
56
                    </li>
57
58
                    <li>
59
                        <label for="name">Allow public enrollment:</label>
60
                        [% IF club_template.is_enrollable_from_opac %]
61
                            <input type="checkbox" id="club-template-is-enrollable-from-opac" name="is_enrollable_from_opac" checked="checked" />
62
                        [% ELSE %]
63
                            <input type="checkbox" id="club-template-is-enrollable-from-opac" name="is_enrollable_from_opac" />
64
                        [% END %]
65
                        <span class="hint">If a template allows public enrollment, patrons can enroll in a club based on this template from the public catalog.</span>
66
                    </li>
67
68
                    <li>
69
                        <label for="name">Require valid email address:</label>
70
                        [% IF club_template.is_email_required %]
71
                            <input type="checkbox" id="club-template-is-email-required" name="is_email_required" checked="checked" />
72
                        [% ELSE %]
73
                            <input type="checkbox" id="club-template-is-email-required" name="is_email_required" />
74
                        [% END %]
75
                        <span class="hint">If set, a club based on this template can only be enrolled in by patrons with a valid email address.</span>
76
                    </li>
77
78
                    <li>
79
                        <label for="name">Branch:</label>
80
                        <select name="branchcode" id="club-template-branchcode">
81
                            <option value="">&nbsp</option>
82
                            [% FOREACH b IN Branches.GetBranches() %]
83
                                [% IF b.branchcode == club_template.branch.branchcode %]
84
                                    <option value="[% b.branchcode %]" selected="selected">[% b.branchname | $EncodeUTF8 %]</option>
85
                                [% ELSE %]
86
                                    <option value="[% b.branchcode %]">[% b.branchname | $EncodeUTF8 %]</option>
87
                                [% END %]
88
                            [% END %]
89
                        </select>
90
                        <span class="hint">If set, only librarians logged in with this branch will be able to modify this club template.</span>
91
                    </li>
92
93
                </ol>
94
95
                <h2>Club fields:</h2>
96
                <span class="hint">These fields will be used in the creation of clubs based on this template</span>
97
                <span id="club-template-fields">
98
                    [% FOREACH f IN club_template.club_template_fields %]
99
                        <ul>
100
                            <input type="hidden" name="club_template_field_id" value="[% f.id %]" />
101
                            <li>
102
                                <label for="field-name-[% f.id %]">Name:</label>
103
                                <input name="club_template_field_name" id="field-name-[% f.id %]" value="[% f.name %]" />
104
                            </li>
105
106
                            <li>
107
                                <label for="field-description-[% f.id %]">Description:</label>
108
                                <input name="club_template_field_description" id="field-description-[% f.id %]" value="[% f.description %]" />
109
                            </li>
110
111
                            <li>
112
                                <label for="field-description-[% f.id %]">Authorised value category:</label>
113
                                <select name="club_template_field_authorised_value_category" id="field-authorised-value-category-[% f.id %]">
114
                                    <option value="">&nbsp;</option>
115
                                    [% FOREACH c IN AuthorisedValuesCategories %]
116
                                        [% IF f.authorised_value_category == c %]
117
                                            <option selected="selected" value="[% c %]">[% c %]</option>
118
                                        [% ELSE %]
119
                                            <option value="[% c %]">[% c %]</option>
120
                                        [% END %]
121
                                    [% END %]
122
                                </select>
123
                            </li>
124
125
                            <li>
126
                                <label for="field-delete-[% f.id %]">Delete field:</label>
127
                                <input type="checkbox" name="club_template_field_delete" id="field-delete-[% f.id %]" value="[% f.id %]" />
128
                            </li>
129
130
                            <hr/>
131
                        </ul>
132
                    [% END %]
133
                </span>
134
                <a href="#" class="btn" onclick="$('#new-field-template').clone().attr('id','').show().appendTo('#club-template-fields'); return false;">
135
                    Add new field
136
                </a>
137
138
                <h2>Enrollment fields:</h2>
139
                <span class="hint">These fields will be used when enrolling a patron in a club based on this template</span>
140
                <span id="club-template-enrollment-fields">
141
                    [% FOREACH f IN club_template.club_template_enrollment_fields %]
142
                        <ul>
143
                            <input type="hidden" name="club_template_enrollment_field_id" value="[% f.id %]" />
144
                            <li>
145
                                <label for="enrollment-field-name-[% f.id %]">Name:</label>
146
                                <input name="club_template_enrollment_field_name" id="enrollment-field-name-[% f.id %]" value="[% f.name %]" />
147
                            </li>
148
149
                            <li>
150
                                <label for="enrollment-field-description-[% f.id %]">Description:</label>
151
                                <input name="club_template_enrollment_field_description" id="enrollment-field-description-[% f.id %]" value="[% f.description %]" />
152
                            </li>
153
154
                            <li>
155
                                <label for="enrollment-field-description-[% f.id %]">Authorised value category:</label>
156
                                <select name="club_template_enrollment_field_authorised_value_category" id="enrollment-field-authorised-value-category-[% f.id %]">
157
                                    <option value="">&nbsp;</option>
158
                                    [% FOREACH c IN AuthorisedValuesCategories %]
159
                                        [% IF f.authorised_value_category == c %]
160
                                            <option selected="selected" value="[% c %]">[% c %]</option>
161
                                        [% ELSE %]
162
                                            <option value="[% c %]">[% c %]</option>
163
                                        [% END %]
164
                                    [% END %]
165
                                </select>
166
                            </li>
167
168
                            <li>
169
                                <label for="enrollment-field-delete-[% f.id %]">Delete field:</label>
170
                                <input type="checkbox" name="club_template_enrollment_field_delete" id="enrollment-field-delete-[% f.id %]" value="[% f.id %]" />
171
                            </li>
172
173
                            <hr/>
174
                        </ul>
175
                    [% END %]
176
                </span>
177
                <a href="#" class="btn" onclick="$('#new-enrollment-field-template').clone().attr('id','').show().appendTo('#club-template-enrollment-fields'); return false;">
178
                    Add new field
179
                </a>
180
181
            </fieldset>
182
183
            <input type="hidden" name="id" value="[% club_template.id %]" />
184
185
            <input type="submit" class="btn" value="Save" />
186
187
            <a href="clubs.pl" class="cancel">Cancel</a>
188
        </form>
189
    </div>
190
</div>
191
192
<span id="new-field-template" style="display:none">
193
    <ul>
194
        <input type="hidden" name="club_template_field_id" value="" />
195
196
        <li>
197
            <label for="club_template_field_name">Name:</label>
198
            <input name="club_template_field_name" />
199
        </li>
200
201
        <li>
202
            <label for="club_template_field_description">Description:</label>
203
            <input name="club_template_field_description" />
204
        </li>
205
206
        <li>
207
            <label for="club_template_field_authorised_value_category">Authorised value category:</label>
208
            <select name="club_template_field_authorised_value_category">
209
                <option value="">&nbsp;</option>
210
                [% FOREACH c IN AuthorisedValuesCategories %]
211
                    <option value="[% c %]">[% c %]</option>
212
                [% END %]
213
            </select>
214
        </li>
215
216
        <a href="#" onclick="$(this).parent().remove(); return false;">Cancel</a>
217
218
        <hr/>
219
    </ul>
220
</span>
221
222
<span id="new-enrollment-field-template" style="display:none">
223
    <ul>
224
        <input type="hidden" name="club_template_enrollment_field_id" value="" />
225
226
        <li>
227
            <label for="club_template_enrollment_field_name">Name:</label>
228
            <input name="club_template_enrollment_field_name" />
229
        </li>
230
231
        <li>
232
            <label for="club_template_enrollment_field_description">Description:</label>
233
            <input name="club_template_enrollment_field_description" />
234
        </li>
235
236
        <li>
237
            <label for="club_template_enrollment_field_authorised_value_category">Authorised value category:</label>
238
            <select name="club_template_enrollment_field_authorised_value_category">
239
                <option value="">&nbsp;</option>
240
                [% FOREACH c IN AuthorisedValuesCategories %]
241
                    <option value="[% c %]">[% c %]</option>
242
                [% END %]
243
            </select>
244
        </li>
245
246
        <a href="#" onclick="$(this).parent().remove(); return false;">Cancel</a>
247
248
        <hr/>
249
    </ul>
250
</span>
251
252
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt (+16 lines)
Lines 33-38 var relatives_borrowernumbers = new Array(); Link Here
33
[% END %]
33
[% END %]
34
34
35
$(document).ready(function() {
35
$(document).ready(function() {
36
    $('#clubs-tab-link').on('click', function() {
37
        $('#clubs-tab').text(_("Loading..."));
38
        $('#clubs-tab').load('/cgi-bin/koha/clubs/patron-clubs-tab.pl?borrowernumber=[% borrowernumber %]');
39
    });
40
36
    $('#finesholdsissues').tabs({
41
    $('#finesholdsissues').tabs({
37
        // Correct table sizing for tables hidden in tabs
42
        // Correct table sizing for tables hidden in tabs
38
        // http://www.datatables.net/examples/api/tabs_and_scrolling.html
43
        // http://www.datatables.net/examples/api/tabs_and_scrolling.html
Lines 406-411 function validate1(date) { Link Here
406
            [% END %]
411
            [% END %]
407
        </li>
412
        </li>
408
        <li><a id="debarments-tab-link" href="#reldebarments">[% debarments.size %] Restrictions</a></li>
413
        <li><a id="debarments-tab-link" href="#reldebarments">[% debarments.size %] Restrictions</a></li>
414
        [% IF CAN_user_clubs && ( borrower.ClubsEnrolledCount || borrower.ClubsEnrollableCount ) %]
415
            <li>
416
                <a id="clubs-tab-link" href="#clubs-tab">
417
                    Clubs ([% borrower.ClubsEnrolledCount %]/[% borrower.ClubsEnrollableCount %])
418
                </a>
419
            </li>
420
        [% END %]
409
    </ul>
421
    </ul>
410
422
411
    <div id="checkouts">
423
    <div id="checkouts">
Lines 498-503 function validate1(date) { Link Here
498
    [% END %]
510
    [% END %]
499
</div>
511
</div>
500
512
513
<div id="clubs-tab">
514
    Loading...
515
</div>
516
501
[% INCLUDE borrower_debarments.inc %]
517
[% INCLUDE borrower_debarments.inc %]
502
518
503
<div id="reserves">
519
<div id="reserves">
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/tools-home.tt (+5 lines)
Lines 15-20 Link Here
15
<div class="yui-u first">
15
<div class="yui-u first">
16
<h3>Patrons and circulation</h3>
16
<h3>Patrons and circulation</h3>
17
<dl>
17
<dl>
18
    [% IF CAN_user_clubs_edit_clubs || CAN_user_clubs_edit_templates %]
19
    <dt><a href="/cgi-bin/koha/clubs/clubs.pl">Patron clubs</a>
20
    <dd>Manage patrons clubs.</dd>
21
    [% END %]
22
18
    [% IF (CAN_user_tools_manage_patron_lists) %]
23
    [% IF (CAN_user_tools_manage_patron_lists) %]
19
    <dt><a href="/cgi-bin/koha/patron_lists/lists.pl">Patron lists</a>
24
    <dt><a href="/cgi-bin/koha/patron_lists/lists.pl">Patron lists</a>
20
    <dd>Manage lists of patrons.</dd>
25
    <dd>Manage lists of patrons.</dd>
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/clubs/clubs-tab.tt (+103 lines)
Line 0 Link Here
1
[% USE EncodeUTF8 %]
2
[% USE KohaDates %]
3
4
[% IF enrollments %]
5
    <table id="clubs-table-enrolled" class="table table-bordered table-striped">
6
        <thead>
7
            <tr>
8
                <th colspan="4">
9
                    Clubs you are currently enrolled in
10
                </th>
11
            </tr>
12
            <tr>
13
                <th>Name</th>
14
                <th>Description</th>
15
                <th>Date enrolled</th>
16
                <th>&nbsp;</th>
17
            </tr>
18
        </thead>
19
20
        <tbody>
21
            [% FOREACH e IN enrollments %]
22
                <tr>
23
                    <td>[% e.club.name | $EncodeUTF8 %]</td>
24
                    <td>[% e.club.description | $EncodeUTF8 %]</td>
25
                    <td>[% e.date_enrolled | $KohaDates %]</td>
26
                    [% IF e.club.club_template.is_enrollable_from_opac %]
27
                        <td>
28
                            <a class="btn btn-mini" onclick="cancelEnrollment( [% e.id %] )">
29
                                <i class="icon-remove"></i> Cancel
30
                            </a>
31
                        </td>
32
                    [% END %]
33
                </tr>
34
            [% END %]
35
        </tbody>
36
    </table>
37
[% END %]
38
39
[% IF clubs %]
40
    <table id="clubs-table-unenrolled" class="table table-bordered table-striped">
41
        <thead>
42
            <tr>
43
                <th colspan="3">
44
                    Clubs you can enroll in
45
                </th>
46
            </tr>
47
            <tr>
48
                <th>Name</th>
49
                <th>Description</th>
50
                <th>&nbsp;</th>
51
            </tr>
52
        </thead>
53
54
        <tbody>
55
            [% FOREACH c IN clubs %]
56
                <tr>
57
                    <td>[% c.name | $EncodeUTF8 %]</td>
58
                    <td>[% c.description | $EncodeUTF8 %]</td>
59
                    <td>
60
                        [% IF borrower.FirstValidEmailAddress %]
61
                            <a class="btn btn-mini" onclick="loadEnrollmentForm([% c.id %])">
62
                                <i class="icon-plus"></i> Enroll
63
                            </a>
64
                        [% ELSE %]
65
                            <span class="hint">You must have an email address to enroll</span>
66
                        [% END %]
67
                    </td>
68
                </tr>
69
            [% END %]
70
        </tbody>
71
    </table>
72
[% END %]
73
74
<script type="text/javascript">
75
function loadEnrollmentForm( id ) {
76
    $("body").css("cursor", "progress");
77
    $('#opac-user-clubs').load('/cgi-bin/koha/clubs/enroll.pl?borrowernumber=[% borrower.borrowernumber %]&id=' + id, function() {
78
        $("body").css("cursor", "default");
79
    });
80
81
    return false;
82
}
83
84
function cancelEnrollment( id ) {
85
    $("body").css("cursor", "progress");
86
    $.ajax({
87
        type: "POST",
88
        url: '/cgi-bin/koha/svc/club/cancel_enrollment',
89
        data: { id: id },
90
        success: function( data ) {
91
            if ( data.success ) {
92
                $('#opac-user-clubs').load('/cgi-bin/koha/clubs/clubs-tab.pl?borrowernumber=[% borrower.borrowernumber %]', function() {
93
                    $("body").css("cursor", "default");
94
                });
95
            } else {
96
                alert(_("Unable to cancel enrollment!"));
97
            }
98
        },
99
        dataType: 'json'
100
    });
101
    return false;
102
}
103
</script>
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/clubs/enroll.tt (+67 lines)
Line 0 Link Here
1
[% USE EncodeUTF8 %]
2
[% USE AuthorisedValues %]
3
[% SET AuthorisedValuesCategories = AuthorisedValues.Categories %]
4
5
<h3>
6
    Enroll in <i>[% club.name | $EncodeUTF8 %]</i>
7
</h3>
8
9
<div class="container">
10
    <form id="patron-enrollment-form">
11
        <input type="hidden" name="id" value="[% club.id %]" />
12
        <input type="hidden" name="borrowernumber" value="[% borrowernumber %]" />
13
        <fieldset class="rows">
14
            <ol>
15
                [% FOREACH f IN club.club_template.club_template_enrollment_fields %]
16
                    <li>
17
                        <label>[% f.name %]</label>
18
                        [% IF f.authorised_value_category %]
19
                            <select name="[% f.id %]">
20
                                [% FOREACH a IN AuthorisedValues.Get( f.club_template_field.authorised_value_category ) %]
21
                                    <option value="[% a.authorised_value %]">[% a.lib %]</option>
22
                                [% END %]
23
                            </select>
24
                        [% ELSE %]
25
                            <input type="text" name="[% f.id %]" />
26
                        [% END %]
27
                        <span class="hint">[% f.description %]</span>
28
                    </li>
29
                [% END %]
30
31
                <li>
32
                    <a href="#" class="btn" onclick="addEnrollment(); return false;"><i class="icon-plus"></i> Enroll</a>
33
                    <a href="#" onclick="showClubs(); return false;">Cancel</a>
34
                </li>
35
            </ol>
36
        </fieldset>
37
    </form>
38
</div>
39
40
<script type="text/javascript">
41
function addEnrollment() {
42
    $("body").css("cursor", "progress");
43
    $.ajax({
44
        type: "POST",
45
        url: '/cgi-bin/koha/svc/club/enroll',
46
        data: $( "#patron-enrollment-form" ).serialize(),
47
        success: function( data ) {
48
            if ( data.success ) {
49
                $('#opac-user-clubs').load('/cgi-bin/koha/clubs/clubs-tab.pl?borrowernumber=[% borrowernumber %]&id=[% club.id %]', function() {
50
                    $("body").css("cursor", "default");
51
                });
52
            } else {
53
                alert(_("Unable to create enrollment!"));
54
            }
55
        },
56
        dataType: 'json'
57
    });
58
    return false;
59
}
60
61
function showClubs() {
62
    $("body").css("cursor", "progress");
63
    $('#opac-user-clubs').load('/cgi-bin/koha/clubs/clubs-tab.pl?borrowernumber=[% borrowernumber %]&id=[% club.id %]', function() {
64
        $("body").css("cursor", "default");
65
    });
66
}
67
</script>
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt (+17 lines)
Lines 111-116 Link Here
111
                                [% IF ( BORROWER_INF.amountlessthanzero ) %]<li><a href="#opac-user-fines">Credits ([% BORROWER_INF.amountoutstanding %])</a></li>[% END %]
111
                                [% IF ( BORROWER_INF.amountlessthanzero ) %]<li><a href="#opac-user-fines">Credits ([% BORROWER_INF.amountoutstanding %])</a></li>[% END %]
112
                            [% END %]
112
                            [% END %]
113
                            [% IF ( waiting_count ) %][% IF ( BORROWER_INF.atdestination ) %]<li><a href="#opac-user-waiting">Waiting ([% waiting_count %])</a></li>[% END %][% END %]
113
                            [% IF ( waiting_count ) %][% IF ( BORROWER_INF.atdestination ) %]<li><a href="#opac-user-waiting">Waiting ([% waiting_count %])</a></li>[% END %][% END %]
114
                            [% IF borrower.ClubsEnrolledCount || borrower.ClubsEnrollableCount %]
115
                                <li>
116
                                    <a id="opac-user-clubs-tab-link" href="#opac-user-clubs">
117
                                        Clubs ([% borrower.ClubsEnrolledCount %]/[% borrower.ClubsEnrollableCount %])
118
                                    </a>
119
                                </li>
120
                            [% END %]
121
114
                            [% IF ( reserves_count ) %]<li><a href="#opac-user-holds">Holds ([% reserves_count %])</a></li>[% END %]
122
                            [% IF ( reserves_count ) %]<li><a href="#opac-user-holds">Holds ([% reserves_count %])</a></li>[% END %]
115
                        </ul>
123
                        </ul>
116
124
Lines 277-282 Link Here
277
                            [% END # IF issues_count %]
285
                            [% END # IF issues_count %]
278
                        </div> <!-- / .opac-user-checkouts -->
286
                        </div> <!-- / .opac-user-checkouts -->
279
287
288
                        <div id="opac-user-clubs">
289
                            Loading...
290
                        </div>
291
280
                        [% IF ( OPACFinesTab ) %]
292
                        [% IF ( OPACFinesTab ) %]
281
                            <!-- FINES BOX -->
293
                            <!-- FINES BOX -->
282
                            [% IF ( BORROWER_INF.amountoverfive ) %]
294
                            [% IF ( BORROWER_INF.amountoverfive ) %]
Lines 724-729 Link Here
724
            [% END %]
736
            [% END %]
725
737
726
            $( ".suspend-until" ).datepicker({ minDate: 1 }); // Require that "until date" be in the future
738
            $( ".suspend-until" ).datepicker({ minDate: 1 }); // Require that "until date" be in the future
739
740
            $('#opac-user-clubs-tab-link').on('click', function() {
741
                $('#opac-user-clubs').text(_("Loading..."));
742
                $('#opac-user-clubs').load('/cgi-bin/koha/clubs/clubs-tab.pl?borrowernumber=[% borrowernumber %]');
743
            });
727
        });
744
        });
728
        //]]>
745
        //]]>
729
    </script>
746
    </script>
(-)a/members/moremember.pl (+3 lines)
Lines 341-346 if (C4::Context->preference('EnhancedMessagingPreferences')) { Link Here
341
# Computes full borrower address
341
# Computes full borrower address
342
my $address = $data->{'streetnumber'} . " $roadtype " . $data->{'address'};
342
my $address = $data->{'streetnumber'} . " $roadtype " . $data->{'address'};
343
343
344
my $schema =  Koha::Database->new()->schema();
345
344
# in template <TMPL_IF name="I"> => instutitional (A for Adult, C for children) 
346
# in template <TMPL_IF name="I"> => instutitional (A for Adult, C for children) 
345
$template->param( $data->{'categorycode'} => 1 ); 
347
$template->param( $data->{'categorycode'} => 1 ); 
346
$template->param(
348
$template->param(
Lines 371-376 $template->param( Link Here
371
    relatives_issues_count => $relatives_issues_count,
373
    relatives_issues_count => $relatives_issues_count,
372
    relatives_borrowernumbers => \@relatives,
374
    relatives_borrowernumbers => \@relatives,
373
    address => $address
375
    address => $address
376
    borrower => $schema->resultset('Borrower')->find( $borrowernumber ),
374
);
377
);
375
378
376
output_html_with_http_headers $input, $cookie, $template->output;
379
output_html_with_http_headers $input, $cookie, $template->output;
(-)a/opac/clubs/clubs-tab.pl (+67 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Copyright 2013 ByWater Solutions
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it
8
# under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
11
#
12
# Koha is distributed in the hope that it will be useful, but
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
20
use Modern::Perl;
21
22
use CGI;
23
24
use C4::Auth;
25
use C4::Output;
26
use Koha::Database;
27
28
my $cgi = new CGI;
29
30
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
31
    {
32
        template_name   => "clubs/clubs-tab.tt",
33
        query           => $cgi,
34
        type            => "opac",
35
        authnotrequired => 0,
36
    }
37
);
38
39
my $borrowernumber = $cgi->param('borrowernumber');
40
41
my $schema = Koha::Database->new()->schema();
42
43
my $borrower = $schema->resultset('Borrower')->find($borrowernumber);
44
45
my @enrollments = $schema->resultset("ClubEnrollment")->search(
46
    {
47
        borrower      => $borrowernumber,
48
        date_canceled => undef,
49
    },
50
    { prefetch => 'club' }
51
);
52
53
my @clubs = $schema->resultset("Club")->search(
54
    {
55
        'me.id' => { -not_in => [ map { $_->club()->id() } @enrollments ] },
56
        'club_template.is_enrollable_from_opac' => 1,
57
    },
58
    { prefetch => 'club_template' }
59
);
60
61
$template->param(
62
    enrollments => \@enrollments,
63
    clubs       => \@clubs,
64
    borrower    => $borrower,
65
);
66
67
output_html_with_http_headers( $cgi, $cookie, $template->output );
(-)a/opac/clubs/enroll.pl (+51 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Copyright 2013 ByWater Solutions
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it
8
# under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
11
#
12
# Koha is distributed in the hope that it will be useful, but
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
20
use Modern::Perl;
21
22
use CGI;
23
24
use C4::Auth;
25
use C4::Output;
26
use Koha::Database;
27
28
my $cgi = new CGI;
29
30
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
31
    {
32
        template_name   => "clubs/enroll.tt",
33
        query           => $cgi,
34
        type            => "opac",
35
        authnotrequired => 0,
36
    }
37
);
38
39
my $id             = $cgi->param('id');
40
my $borrowernumber = $cgi->param('borrowernumber');
41
42
my $schema = Koha::Database->new()->schema();
43
44
my $club = $schema->resultset("Club")->find($id);
45
46
$template->param(
47
    club           => $club,
48
    borrowernumber => $borrowernumber,
49
);
50
51
output_html_with_http_headers( $cgi, $cookie, $template->output );
(-)a/opac/opac-user.pl (-3 / +4 lines)
Lines 35-40 use C4::Items; Link Here
35
use C4::Letters;
35
use C4::Letters;
36
use C4::Branch; # GetBranches
36
use C4::Branch; # GetBranches
37
use Koha::DateUtils;
37
use Koha::DateUtils;
38
use Koha::Database;
39
40
my $schema = Koha::Database->new()->schema();
38
41
39
use constant ATTRIBUTE_SHOW_BARCODE => 'SHOW_BCODE';
42
use constant ATTRIBUTE_SHOW_BARCODE => 'SHOW_BCODE';
40
43
Lines 383-394 $template->param( Link Here
383
    patronupdate => $patronupdate,
386
    patronupdate => $patronupdate,
384
    OpacRenewalAllowed => C4::Context->preference("OpacRenewalAllowed"),
387
    OpacRenewalAllowed => C4::Context->preference("OpacRenewalAllowed"),
385
    userview => 1,
388
    userview => 1,
386
);
387
388
$template->param(
389
    SuspendHoldsOpac => C4::Context->preference('SuspendHoldsOpac'),
389
    SuspendHoldsOpac => C4::Context->preference('SuspendHoldsOpac'),
390
    AutoResumeSuspendedHolds => C4::Context->preference('AutoResumeSuspendedHolds'),
390
    AutoResumeSuspendedHolds => C4::Context->preference('AutoResumeSuspendedHolds'),
391
    OpacHoldNotes => C4::Context->preference('OpacHoldNotes'),
391
    OpacHoldNotes => C4::Context->preference('OpacHoldNotes'),
392
    borrower => $schema->resultset('Borrower')->find($borrowernumber),
392
);
393
);
393
394
394
output_html_with_http_headers $query, $cookie, $template->output;
395
output_html_with_http_headers $query, $cookie, $template->output;
(-)a/opac/svc/club/cancel_enrollment (+52 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Copyright 2014 ByWater Solutions
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 2 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
#
20
21
use Modern::Perl;
22
23
use CGI;
24
use JSON qw(to_json);
25
26
use C4::Auth qw(check_cookie_auth);
27
use Koha::Database;
28
29
my $cgi = new CGI;
30
31
my ( $auth_status, $sessionID ) =
32
  check_cookie_auth( $cgi->cookie('CGISESSID') );
33
if ( $auth_status ne "ok" ) {
34
    exit 0;
35
}
36
37
my $borrowernumber = C4::Context->userenv->{'number'};
38
39
my $id = $cgi->param('id');
40
41
my $schema = Koha::Database->new()->schema();
42
43
my $enrollment = $schema->resultset('ClubEnrollment')->find($id);
44
45
if ( $enrollment && $enrollment->get_column('borrower') == $borrowernumber ) {
46
    $enrollment->update( { date_canceled => \'NOW()' } );
47
}
48
49
binmode STDOUT, ':encoding(UTF-8)';
50
print $cgi->header( -type => 'text/plain', -charset => 'UTF-8' );
51
52
print to_json( { success => $enrollment ? 1 : 0 } );
(-)a/opac/svc/club/enroll (+79 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Copyright 2014 ByWater Solutions
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 2 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
#
20
21
use Modern::Perl;
22
23
use CGI;
24
use JSON qw(to_json);
25
26
use C4::Auth qw(check_cookie_auth);
27
use Koha::Database;
28
29
my $cgi = new CGI;
30
31
my ( $auth_status, $sessionID ) =
32
  check_cookie_auth( $cgi->cookie('CGISESSID') );
33
if ( $auth_status ne "ok" ) {
34
    exit 0;
35
}
36
37
my $borrowernumber = C4::Context->userenv->{'number'};
38
39
my $id = $cgi->param('id');
40
41
my $enrollment;
42
if ( $borrowernumber && $id ) {
43
    my $schema = Koha::Database->new()->schema();
44
45
    my $club = $schema->resultset('Club')->find($id);
46
47
    if ( $club->club_template()->is_enrollable_from_opac() ) {
48
        $enrollment = $schema->resultset('ClubEnrollment')->create(
49
            {
50
                club          => $club->id(),
51
                borrower      => $borrowernumber,
52
                date_enrolled => \'NOW()',
53
                date_created  => \'NOW()',
54
                branch        => C4::Context->userenv
55
                ? C4::Context->userenv->{'branch'}
56
                : undef,
57
            }
58
        );
59
60
        my @enrollment_fields =
61
          $club->club_template()->club_template_enrollment_fields();
62
63
        foreach my $e (@enrollment_fields) {
64
            my $club_enrollment_field =
65
              $schema->resultset('ClubEnrollmentField')->create(
66
                {
67
                    club_enrollment                => $enrollment->id(),
68
                    club_template_enrollment_field => $e->id(),
69
                    value                          => $cgi->param( $e->id() ),
70
                }
71
              );
72
        }
73
    }
74
}
75
76
binmode STDOUT, ':encoding(UTF-8)';
77
print $cgi->header( -type => 'text/plain', -charset => 'UTF-8' );
78
79
print to_json( { success => $enrollment ? 1 : 0 } );
(-)a/svc/club/cancel_enrollment (+48 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Copyright 2014 ByWater Solutions
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 2 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
#
20
21
use Modern::Perl;
22
23
use CGI;
24
use JSON qw(to_json);
25
26
use C4::Auth qw(check_cookie_auth);
27
use Koha::Database;
28
29
my $cgi = new CGI;
30
31
my ( $auth_status, $sessionID ) =
32
  check_cookie_auth( $cgi->cookie('CGISESSID'), { clubs => 'enroll' } );
33
if ( $auth_status ne "ok" ) {
34
    exit 0;
35
}
36
37
my $id = $cgi->param('id');
38
39
my $schema = Koha::Database->new()->schema();
40
41
my $enrollment =
42
  $schema->resultset('ClubEnrollment')->find($id)
43
  ->update( { date_canceled => \'NOW()' } );
44
45
binmode STDOUT, ':encoding(UTF-8)';
46
print $cgi->header( -type => 'text/plain', -charset => 'UTF-8' );
47
48
print to_json( { success => $enrollment ? 1 : 0 } );
(-)a/svc/club/delete (+50 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Copyright 2014 ByWater Solutions
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 2 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
#
20
21
use Modern::Perl;
22
23
use CGI;
24
use JSON qw(to_json);
25
26
use C4::Auth qw(check_cookie_auth);
27
use Koha::Database;
28
29
my $cgi = new CGI;
30
31
my ( $auth_status, $sessionID ) = check_cookie_auth( $cgi->cookie('CGISESSID'),
32
    { clubs => 'edit_clubs' } );
33
if ( $auth_status ne "ok" ) {
34
    exit 0;
35
}
36
37
my $success = 0;
38
39
my $id = $cgi->param('id');
40
41
my $club =
42
  Koha::Database->new()->schema()->resultset('Club')->find($id);
43
if ($club) {
44
    $success = $club->delete();
45
}
46
47
binmode STDOUT, ':encoding(UTF-8)';
48
print $cgi->header( -type => 'text/plain', -charset => 'UTF-8' );
49
50
print to_json( { success => $success ? 1 : 0 } );
(-)a/svc/club/enroll (+78 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Copyright 2014 ByWater Solutions
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 2 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
#
20
21
use Modern::Perl;
22
23
use CGI;
24
use JSON qw(to_json);
25
26
use C4::Auth qw(check_cookie_auth);
27
use Koha::Database;
28
29
my $cgi = new CGI;
30
31
my ( $auth_status, $sessionID ) =
32
  check_cookie_auth( $cgi->cookie('CGISESSID'), { clubs => 'enroll' } );
33
if ( $auth_status ne "ok" ) {
34
    exit 0;
35
}
36
37
my $id             = $cgi->param('id');
38
my $borrowernumber = $cgi->param('borrowernumber');
39
40
my $schema = Koha::Database->new()->schema();
41
42
my $club = $schema->resultset('Club')->find($id);
43
44
my $enrollment;
45
if ($club) {
46
    $enrollment = $schema->resultset('ClubEnrollment')->create(
47
        {
48
            club          => $club->id(),
49
            borrower      => $borrowernumber,
50
            date_enrolled => \'NOW()',
51
            date_created  => \'NOW()',
52
            branch        => C4::Context->userenv
53
            ? C4::Context->userenv->{'branch'}
54
            : undef,
55
        }
56
    );
57
58
    if ($enrollment) {
59
        my @enrollment_fields =
60
          $club->club_template()->club_template_enrollment_fields();
61
62
        foreach my $e (@enrollment_fields) {
63
            my $club_enrollment_field =
64
              $schema->resultset('ClubEnrollmentField')->create(
65
                {
66
                    club_enrollment                => $enrollment->id(),
67
                    club_template_enrollment_field => $e->id(),
68
                    value                          => $cgi->param( $e->id() ),
69
                }
70
              );
71
        }
72
    }
73
}
74
75
binmode STDOUT, ':encoding(UTF-8)';
76
print $cgi->header( -type => 'text/plain', -charset => 'UTF-8' );
77
78
print to_json( { success => $enrollment ? 1 : 0 } );
(-)a/svc/club/template/delete (-1 / +50 lines)
Line 0 Link Here
0
- 
1
#!/usr/bin/perl
2
3
# Copyright 2014 ByWater Solutions
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 2 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
#
20
21
use Modern::Perl;
22
23
use CGI;
24
use JSON qw(to_json);
25
26
use C4::Auth qw(check_cookie_auth);
27
use Koha::Database;
28
29
my $cgi = new CGI;
30
31
my ( $auth_status, $sessionID ) = check_cookie_auth( $cgi->cookie('CGISESSID'),
32
    { clubs => 'edit_templates' } );
33
if ( $auth_status ne "ok" ) {
34
    exit 0;
35
}
36
37
my $success = 0;
38
39
my $id = $cgi->param('id');
40
41
my $club_template =
42
  Koha::Database->new()->schema()->resultset('ClubTemplate')->find($id);
43
if ($club_template) {
44
    $success = $club_template->delete();
45
}
46
47
binmode STDOUT, ':encoding(UTF-8)';
48
print $cgi->header( -type => 'text/plain', -charset => 'UTF-8' );
49
50
print to_json( { success => $success ? 1 : 0 } );

Return to bug 12461