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

(-)a/clubs/patron-enroll.pl (-2 / +7 lines)
Lines 24-29 use CGI; Link Here
24
use C4::Auth qw( get_template_and_user );
24
use C4::Auth qw( get_template_and_user );
25
use C4::Output qw( output_html_with_http_headers );
25
use C4::Output qw( output_html_with_http_headers );
26
use Koha::Clubs;
26
use Koha::Clubs;
27
use Koha::Club::Enrollment::Fields;
27
28
28
my $cgi = CGI->new;
29
my $cgi = CGI->new;
29
30
Lines 38-49 my ( $template, $loggedinuser, $cookie ) = get_template_and_user( Link Here
38
39
39
my $id             = $cgi->param('id');
40
my $id             = $cgi->param('id');
40
my $borrowernumber = $cgi->param('borrowernumber');
41
my $borrowernumber = $cgi->param('borrowernumber');
42
my $enrollent_id   = scalar $cgi->param('enrollent_id');
41
43
42
my $club = Koha::Clubs->find($id);
44
my $club = Koha::Clubs->find($id);
45
my @club_enrollment_fields = Koha::Club::Enrollment::Fields->search({'club_enrollment_id'=> $enrollent_id})->as_list;
43
46
44
$template->param(
47
$template->param(
45
    club           => $club,
48
    club                   => $club,
46
    borrowernumber => $borrowernumber,
49
    borrowernumber         => $borrowernumber,
50
    enrollent_id           => $enrollent_id || 0,
51
    club_enrollment_fields => \@club_enrollment_fields,
47
);
52
);
48
53
49
output_html_with_http_headers( $cgi, $cookie, $template->output );
54
output_html_with_http_headers( $cgi, $cookie, $template->output );
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/clubs/patron-clubs-tab.tt (-2 / +5 lines)
Lines 21-26 Link Here
21
                    <td>[% e.date_enrolled | $KohaDates %]</td>
21
                    <td>[% e.date_enrolled | $KohaDates %]</td>
22
                    [% IF CAN_user_clubs_enroll %]
22
                    [% IF CAN_user_clubs_enroll %]
23
                        <td>
23
                        <td>
24
                            <button class="btn btn-xs btn-default" onclick="loadEnrollmentForm([% e.club.id %],[% e.id %])">
25
                                <i class="fa fa-edit"></i>Modify enrollment
26
                            </button>
24
                            <button class="btn btn-xs btn-default" onclick="cancelEnrollment( [% e.id | html %] )">
27
                            <button class="btn btn-xs btn-default" onclick="cancelEnrollment( [% e.id | html %] )">
25
                                <i class="fa fa-remove"></i> Cancel enrollment
28
                                <i class="fa fa-remove"></i> Cancel enrollment
26
                            </button>
29
                            </button>
Lines 72-80 $("#table_clubnoenrollmemnts, #table_clubenrollments").dataTable($.extend(true, Link Here
72
}));
75
}));
73
76
74
[% IF CAN_user_clubs_enroll %]
77
[% IF CAN_user_clubs_enroll %]
75
function loadEnrollmentForm( id ) {
78
function loadEnrollmentForm( id, enrollent_id = 0 ) {
76
    $("body").css("cursor", "progress");
79
    $("body").css("cursor", "progress");
77
    $('#clubs-tab').load('/cgi-bin/koha/clubs/patron-enroll.pl?borrowernumber=[% borrowernumber | html %]&id=' + id, function() {
80
    $('#clubs-tab').load('/cgi-bin/koha/clubs/patron-enroll.pl?borrowernumber=[% borrowernumber | html %]&id=' + id +'&enrollent_id='+ enrollent_id, function() {
78
        $("body").css("cursor", "default");
81
        $("body").css("cursor", "default");
79
    });
82
    });
80
83
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/clubs/patron-enroll.tt (-2 / +27 lines)
Lines 1-7 Link Here
1
[% USE AuthorisedValues %]
1
[% USE AuthorisedValues %]
2
[% SET AuthorisedValuesCategories = AuthorisedValues.GetCategories %]
2
[% SET AuthorisedValuesCategories = AuthorisedValues.GetCategories %]
3
3
4
<h1>
4
<h1 id="heading">
5
    Enroll in <em>[% club.name | html %]</em>
5
    Enroll in <em>[% club.name | html %]</em>
6
</h1>
6
</h1>
7
7
Lines 9-16 Link Here
9
    <form id="patron-enrollment-form">
9
    <form id="patron-enrollment-form">
10
        <input type="hidden" name="id" value="[% club.id | html %]" />
10
        <input type="hidden" name="id" value="[% club.id | html %]" />
11
        <input type="hidden" name="borrowernumber" value="[% borrowernumber | html %]" />
11
        <input type="hidden" name="borrowernumber" value="[% borrowernumber | html %]" />
12
        <input type="hidden" name="enrollent_id" value="[% enrollent_id | html %]" />
12
        <fieldset class="rows">
13
        <fieldset class="rows">
13
            <ol>
14
            <ol>
15
            [% IF club_enrollment_fields %]
16
                [% FOREACH f IN club.club_template.club_template_enrollment_fields %]
17
                    [% FOREACH c IN club_enrollment_fields %]
18
                        [% IF f.id == c.club_template_enrollment_field_id %]
19
                            <li>
20
                                <label>[% f.name %]</label>
21
                                [% IF f.authorised_value_category %]
22
                                    <select name="[% f.id %]">
23
                                        [% FOREACH a IN AuthorisedValues.Get( f.authorised_value_category ) %]
24
                                        <option value="[% a.authorised_value %]" [% IF a.authorised_value == c.value %]selected="selected"[% END %]>[% a.lib %]</option>
25
                                        [% END %]
26
                                    </select>
27
                                [% ELSE %]
28
                                    <input type="text" name="[% f.id %]" value="[% c.value %]"/>
29
                                [% END %]
30
                                <span class="hint">[% f.description %]</span>
31
                            </li>
32
                        [% END %]
33
                    [% END %]
34
                [% END %]
35
            [% ELSE %]
14
                [% FOREACH f IN club.club_template.club_template_enrollment_fields %]
36
                [% FOREACH f IN club.club_template.club_template_enrollment_fields %]
15
                    <li>
37
                    <li>
16
                        <label>[% f.name | html %]</label>
38
                        <label>[% f.name | html %]</label>
Lines 26-32 Link Here
26
                        <span class="hint">[% f.description | html %]</span>
48
                        <span class="hint">[% f.description | html %]</span>
27
                    </li>
49
                    </li>
28
                [% END %]
50
                [% END %]
29
51
            [% END %]
30
                <li>
52
                <li>
31
                    <a href="#" class="btn btn-sm btn-default" onclick="addEnrollment(); return false;">Finish enrollment</a>
53
                    <a href="#" class="btn btn-sm btn-default" onclick="addEnrollment(); return false;">Finish enrollment</a>
32
                    <a class="cancel" href="#" onclick="showClubs(); return false;">Cancel</a>
54
                    <a class="cancel" href="#" onclick="showClubs(); return false;">Cancel</a>
Lines 37-42 Link Here
37
</div>
59
</div>
38
60
39
<script>
61
<script>
62
if([% enrollent_id %]){
63
    $("#heading").html(_("Modifying enrollment")+" <em>[% club.name %]</em>");
64
}
40
function addEnrollment() {
65
function addEnrollment() {
41
    $("body").css("cursor", "progress");
66
    $("body").css("cursor", "progress");
42
    $.ajax({
67
    $.ajax({
(-)a/opac/svc/club/enroll (-1 / +1 lines)
Lines 64-70 if ( $borrowernumber && $id ) { Link Here
64
                {
64
                {
65
                    club_enrollment_id                => $enrollment->id(),
65
                    club_enrollment_id                => $enrollment->id(),
66
                    club_template_enrollment_field_id => $e->id(),
66
                    club_template_enrollment_field_id => $e->id(),
67
                    value                             => $cgi->param( $e->id() ),
67
                    value                             => scalar $cgi->param( $e->id() ),
68
                }
68
                }
69
            )->store();
69
            )->store();
70
        }
70
        }
(-)a/svc/club/enroll (-4 / +26 lines)
Lines 38-48 if ( $auth_status ne "ok" ) { Link Here
38
38
39
my $id             = $cgi->param('id');
39
my $id             = $cgi->param('id');
40
my $borrowernumber = $cgi->param('borrowernumber');
40
my $borrowernumber = $cgi->param('borrowernumber');
41
my $enrollent_id   = scalar $cgi->param('enrollent_id');
41
42
42
my $club = Koha::Clubs->find($id);
43
my $club = Koha::Clubs->find($id);
43
44
44
my $enrollment;
45
my $enrollment;
45
if ($club) {
46
47
my @club_enrollment_fields;
48
49
if($enrollent_id){
50
    my @enrollment_fields = $club->club_template()->club_template_enrollment_fields()->as_list;
51
    @club_enrollment_fields = Koha::Club::Enrollment::Fields->search({'club_enrollment_id'=> $enrollent_id})->as_list;
52
53
    foreach my $club_enrollment_field (@club_enrollment_fields){
54
        foreach my $e (@enrollment_fields){
55
            if($e->id()==$club_enrollment_field->club_template_enrollment_field_id){
56
                my $value = $cgi->param( $e->id() );
57
                $club_enrollment_field->value($value);
58
                $club_enrollment_field->update();
59
            }
60
        }
61
    }
62
}
63
elsif ($club) {
46
    $enrollment = Koha::Club::Enrollment->new(
64
    $enrollment = Koha::Club::Enrollment->new(
47
        {
65
        {
48
            club_id        => $club->id(),
66
            club_id        => $club->id(),
Lines 61-67 if ($club) { Link Here
61
                {
79
                {
62
                    club_enrollment_id                => $enrollment->id(),
80
                    club_enrollment_id                => $enrollment->id(),
63
                    club_template_enrollment_field_id => $e->id(),
81
                    club_template_enrollment_field_id => $e->id(),
64
                    value                             => $cgi->param( $e->id() ),
82
                    value                             => scalar $cgi->param( $e->id() ),
65
                }
83
                }
66
            )->store();
84
            )->store();
67
        }
85
        }
Lines 71-74 if ($club) { Link Here
71
binmode STDOUT, ':encoding(UTF-8)';
89
binmode STDOUT, ':encoding(UTF-8)';
72
print $cgi->header( -type => 'text/plain', -charset => 'UTF-8' );
90
print $cgi->header( -type => 'text/plain', -charset => 'UTF-8' );
73
91
74
print to_json( { success => $enrollment ? 1 : 0 } );
92
if($enrollent_id){
93
    print to_json( { success => @club_enrollment_fields ? 1 : 0 } );
94
}
95
else{
96
    print to_json( { success => $enrollment ? 1 : 0 } );
97
}
75
- 

Return to bug 25079