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-6 Link Here
1
[% USE AuthorisedValues %]
1
[% USE AuthorisedValues %]
2
2
3
<h1>
3
<h1 id="heading">
4
    Enroll in <em>[% club.name | html %]</em>
4
    Enroll in <em>[% club.name | html %]</em>
5
</h1>
5
</h1>
6
6
Lines 8-15 Link Here
8
    <form id="patron-enrollment-form">
8
    <form id="patron-enrollment-form">
9
        <input type="hidden" name="id" value="[% club.id | html %]" />
9
        <input type="hidden" name="id" value="[% club.id | html %]" />
10
        <input type="hidden" name="borrowernumber" value="[% borrowernumber | html %]" />
10
        <input type="hidden" name="borrowernumber" value="[% borrowernumber | html %]" />
11
        <input type="hidden" name="enrollent_id" value="[% enrollent_id | html %]" />
11
        <fieldset class="rows">
12
        <fieldset class="rows">
12
            <ol>
13
            <ol>
14
            [% IF club_enrollment_fields %]
15
                [% FOREACH f IN club.club_template.club_template_enrollment_fields %]
16
                    [% FOREACH c IN club_enrollment_fields %]
17
                        [% IF f.id == c.club_template_enrollment_field_id %]
18
                            <li>
19
                                <label>[% f.name %]</label>
20
                                [% IF f.authorised_value_category %]
21
                                    <select name="[% f.id %]">
22
                                        [% FOREACH a IN AuthorisedValues.Get( f.authorised_value_category ) %]
23
                                        <option value="[% a.authorised_value %]" [% IF a.authorised_value == c.value %]selected="selected"[% END %]>[% a.lib %]</option>
24
                                        [% END %]
25
                                    </select>
26
                                [% ELSE %]
27
                                    <input type="text" name="[% f.id %]" value="[% c.value %]"/>
28
                                [% END %]
29
                                <span class="hint">[% f.description %]</span>
30
                            </li>
31
                        [% END %]
32
                    [% END %]
33
                [% END %]
34
            [% ELSE %]
13
                [% FOREACH f IN club.club_template.club_template_enrollment_fields %]
35
                [% FOREACH f IN club.club_template.club_template_enrollment_fields %]
14
                    <li>
36
                    <li>
15
                        <label>[% f.name | html %]</label>
37
                        <label>[% f.name | html %]</label>
Lines 25-31 Link Here
25
                        <span class="hint">[% f.description | html %]</span>
47
                        <span class="hint">[% f.description | html %]</span>
26
                    </li>
48
                    </li>
27
                [% END %]
49
                [% END %]
28
50
            [% END %]
29
                <li>
51
                <li>
30
                    <a href="#" class="btn btn-sm btn-default" onclick="addEnrollment(); return false;">Finish enrollment</a>
52
                    <a href="#" class="btn btn-sm btn-default" onclick="addEnrollment(); return false;">Finish enrollment</a>
31
                    <a class="cancel" href="#" onclick="showClubs(); return false;">Cancel</a>
53
                    <a class="cancel" href="#" onclick="showClubs(); return false;">Cancel</a>
Lines 36-41 Link Here
36
</div>
58
</div>
37
59
38
<script>
60
<script>
61
if([% enrollent_id %]){
62
    $("#heading").html(_("Modifying enrollment")+" <em>[% club.name %]</em>");
63
}
39
function addEnrollment() {
64
function addEnrollment() {
40
    $("body").css("cursor", "progress");
65
    $("body").css("cursor", "progress");
41
    $.ajax({
66
    $.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