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

(-)a/C4/Auth.pm (+1 lines)
Lines 202-207 sub get_template_and_user { Link Here
202
            $template->param( CAN_user_serials          => 1 );
202
            $template->param( CAN_user_serials          => 1 );
203
            $template->param( CAN_user_reports          => 1 );
203
            $template->param( CAN_user_reports          => 1 );
204
            $template->param( CAN_user_staffaccess      => 1 );
204
            $template->param( CAN_user_staffaccess      => 1 );
205
            $template->param( CAN_user_clubs_services   => 1 );
205
            foreach my $module (keys %$all_perms) {
206
            foreach my $module (keys %$all_perms) {
206
                foreach my $subperm (keys %{ $all_perms->{$module} }) {
207
                foreach my $subperm (keys %{ $all_perms->{$module} }) {
207
                    $template->param( "CAN_user_${module}_${subperm}" => 1 );
208
                    $template->param( "CAN_user_${module}_${subperm}" => 1 );
(-)a/C4/ClubsAndServices.pm (+1272 lines)
Line 0 Link Here
1
package C4::ClubsAndServices;
2
3
# $Id: ClubsAndServices.pm,v 0.1 2007/04/10 kylemhall
4
5
# This package is intended for dealing with clubs and services
6
# and enrollments in such, such as summer reading clubs, and
7
# library newsletters
8
9
# Copyright 2012 Kyle Hall
10
#
11
# This file is part of Koha.
12
#
13
# Koha is free software; you can redistribute it and/or modify it under the
14
# terms of the GNU General Public License as published by the Free Software
15
# Foundation; either version 2 of the License, or (at your option) any later
16
# version.
17
#
18
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
19
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
20
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
21
#
22
# You should have received a copy of the GNU General Public License along with
23
# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
24
# Suite 330, Boston, MA  02111-1307 USA
25
26
use Modern::Perl;
27
28
require Exporter;
29
30
use C4::Context;
31
32
use vars qw($VERSION @ISA @EXPORT);
33
34
# set the version for version checking
35
$VERSION = 0.01;
36
37
=head1 NAME
38
39
C4::ClubsAndServices - Functions for managing clubs and services
40
41
=head1 FUNCTIONS
42
43
=over 2
44
45
=cut
46
47
@ISA    = qw( Exporter );
48
@EXPORT = qw(
49
  AddClubOrServiceArchetype
50
  UpdateClubOrServiceArchetype
51
  DeleteClubOrServiceArchetype
52
53
  AddClubOrService
54
  UpdateClubOrService
55
  DeleteClubOrService
56
57
  EnrollInClubOrService
58
  GetEnrollments
59
  GetClubsAndServices
60
  GetClubOrService
61
  GetClubsAndServicesArchetypes
62
  GetClubOrServiceArchetype
63
  DoesEnrollmentRequireData
64
  CancelClubOrServiceEnrollment
65
  GetEnrolledClubsAndServices
66
  GetPubliclyEnrollableClubsAndServices
67
  GetAllEnrollableClubsAndServices
68
  GetCasEnrollments
69
70
  ReserveForBestSellersClub
71
72
  getTodayMysqlDateFormat
73
);
74
75
=head2 AddClubOrServiceArchetype
76
77
Creates a new archetype for a club or service
78
An archetype is something after which other things a patterned,
79
For example, you could create a 'Summer Reading Club' club archtype
80
which is then used to create an individual 'Summer Reading Club'
81
*for each library* in your system.
82
83
Input:
84
   $type : 'club' or 'service', could be extended to add more types
85
   $title: short description of the club or service
86
   $description: long description of the club or service
87
   $publicEnrollment: If true, any borrower should be able
88
       to enroll in club or service from opac. If false,
89
       Only a librarian should be able to enroll a borrower
90
       in the club or service.
91
   $casData1Title: explanation of what is stored in
92
      clubsAndServices.casData1Title
93
   $casData2Title: same but for casData2Title
94
   $casData3Title: same but for casData3Title
95
   $caseData1Title: explanation of what is stored in
96
     clubsAndServicesEnrollment.data1
97
   $caseData2Title: Same but for data2
98
   $caseData3Title: Same but for data3
99
   $casData1Desc: Long explanation of what is stored in
100
      clubsAndServices.casData1Title
101
   $casData2Desc: same but for casData2Title
102
   $casData3Desc: same but for casData3Title
103
   $caseData1Desc: Long explanation of what is stored in
104
     clubsAndServicesEnrollment.data1
105
   $caseData2Desc: Same but for data2
106
   $caseData3Desc: Same but for data3
107
   $caseRequireEmail: If 1, enrollment in clubs or services based on this archetype will require a valid e-mail address field in the borrower
108
	record as specified in the syspref AutoEmailPrimaryAddress
109
   $branchcode: The branchcode for the branch where this Archetype was created
110
111
 Output:
112
   $success: 1 if all database operations were successful, 0 otherwise
113
   $errorCode: Code for reason of failure, good for translating errors in templates
114
   $errorMessage: English description of error
115
116
=cut
117
118
sub AddClubOrServiceArchetype {
119
    my ($type,          $title,          $description,    $publicEnrollment, $casData1Title,    $casData2Title,
120
        $casData3Title, $caseData1Title, $caseData2Title, $caseData3Title,   $casData1Desc,     $casData2Desc,
121
        $casData3Desc,  $caseData1Desc,  $caseData2Desc,  $caseData3Desc,    $caseRequireEmail, $branchcode
122
    ) = @_;
123
124
    ## Check for all neccessary parameters
125
    if ( !$type ) {
126
        return ( 0, "NO_TYPE" );
127
    }
128
    if ( !$title ) {
129
        return ( 0, "NO_TITLE" );
130
    }
131
    if ( !$description ) {
132
        return ( 0, "NO_DESCRIPTION" );
133
    }
134
135
    my $success = 1;
136
137
    my $dbh = C4::Context->dbh;
138
139
    my $sth;
140
    $sth = $dbh->prepare(
141
        "INSERT INTO clubsAndServicesArchetypes ( casaId, type, title, description, publicEnrollment, caseRequireEmail, branchcode, last_updated )
142
                        VALUES ( NULL, ?, ?, ?, ?, ?, ?, CURRENT_TIMESTAMP)"
143
    );
144
    $sth->execute( $type, $title, $description, $publicEnrollment, $caseRequireEmail, $branchcode ) or $success = 0;
145
    my $casaId = $dbh->{'mysql_insertid'};
146
    $sth->finish;
147
148
    if ($casData1Title) {
149
        $sth = $dbh->prepare("UPDATE clubsAndServicesArchetypes SET casData1Title = ? WHERE casaId = ?");
150
        $sth->execute( $casData1Title, $casaId ) or $success = 0;
151
        $sth->finish;
152
    }
153
    if ($casData2Title) {
154
        $sth = $dbh->prepare("UPDATE clubsAndServicesArchetypes SET casData2Title = ? WHERE casaId = ?");
155
        $sth->execute( $casData2Title, $casaId ) or $success = 0;
156
        $sth->finish;
157
    }
158
    if ($casData3Title) {
159
        $sth = $dbh->prepare("UPDATE clubsAndServicesArchetypes SET casData3Title = ? WHERE casaId = ?");
160
        $sth->execute( $casData3Title, $casaId ) or $success = 0;
161
        $sth->finish;
162
    }
163
164
    if ($caseData1Title) {
165
        $sth = $dbh->prepare("UPDATE clubsAndServicesArchetypes SET caseData1Title = ? WHERE casaId = ?");
166
        $sth->execute( $caseData1Title, $casaId ) or $success = 0;
167
        $sth->finish;
168
    }
169
    if ($caseData2Title) {
170
        $sth = $dbh->prepare("UPDATE clubsAndServicesArchetypes SET caseData2Title = ? WHERE casaId = ?");
171
        $sth->execute( $caseData2Title, $casaId ) or $success = 0;
172
        $sth->finish;
173
    }
174
    if ($caseData3Title) {
175
        $sth = $dbh->prepare("UPDATE clubsAndServicesArchetypes SET caseData3Title = ? WHERE casaId = ?");
176
        $sth->execute( $caseData3Title, $casaId ) or $success = 0;
177
        $sth->finish;
178
    }
179
180
    if ($casData1Desc) {
181
        $sth = $dbh->prepare("UPDATE clubsAndServicesArchetypes SET casData1Desc = ? WHERE casaId = ?");
182
        $sth->execute( $casData1Desc, $casaId ) or $success = 0;
183
        $sth->finish;
184
    }
185
    if ($casData2Desc) {
186
        $sth = $dbh->prepare("UPDATE clubsAndServicesArchetypes SET casData2Desc = ? WHERE casaId = ?");
187
        $sth->execute( $casData2Desc, $casaId ) or $success = 0;
188
        $sth->finish;
189
    }
190
    if ($casData3Desc) {
191
        $sth = $dbh->prepare("UPDATE clubsAndServicesArchetypes SET casData3Desc = ? WHERE casaId = ?");
192
        $sth->execute( $casData3Desc, $casaId ) or $success = 0;
193
        $sth->finish;
194
    }
195
196
    if ($caseData1Desc) {
197
        $sth = $dbh->prepare("UPDATE clubsAndServicesArchetypes SET caseData1Desc = ? WHERE casaId = ?");
198
        $sth->execute( $caseData1Desc, $casaId ) or $success = 0;
199
        $sth->finish;
200
    }
201
    if ($caseData2Desc) {
202
        $sth = $dbh->prepare("UPDATE clubsAndServicesArchetypes SET caseData2Desc = ? WHERE casaId = ?");
203
        $sth->execute( $caseData2Desc, $casaId ) or $success = 0;
204
        $sth->finish;
205
    }
206
    if ($caseData3Desc) {
207
        $sth = $dbh->prepare("UPDATE clubsAndServicesArchetypes SET caseData3Desc = ? WHERE casaId = ?");
208
        $sth->execute( $caseData3Desc, $casaId ) or $success = 0;
209
        $sth->finish;
210
    }
211
212
    my ( $errorCode, $errorMessage );
213
    if ( !$success ) {
214
        $errorMessage = "DB_ERROR";
215
    }
216
217
    return ( $success, $errorMessage );
218
219
}
220
221
=head2 UpdateClubOrServiceArchetype
222
223
 Updates an archetype for a club or service
224
225
 Input:
226
   $casaId: id of the archetype to be updated
227
   $type : 'club' or 'service', could be extended to add more types
228
   $title: short description of the club or service
229
   $description: long description of the club or service
230
   $publicEnrollment: If true, any borrower should be able
231
       to enroll in club or service from opac. If false,
232
       Only a librarian should be able to enroll a borrower
233
       in the club or service.
234
   $casData1Title: explanation of what is stored in
235
      clubsAndServices.casData1Title
236
   $casData2Title: same but for casData2Title
237
   $casData3Title: same but for casData3Title
238
   $caseData1Title: explanation of what is stored in
239
     clubsAndServicesEnrollment.data1
240
   $caseData2Title: Same but for data2
241
   $caseData3Title: Same but for data3
242
   $casData1Desc: Long explanation of what is stored in
243
      clubsAndServices.casData1Title
244
   $casData2Desc: same but for casData2Title
245
   $casData3Desc: same but for casData3Title
246
   $caseData1Desc: Long explanation of what is stored in
247
     clubsAndServicesEnrollment.data1
248
   $caseData2Desc: Same but for data2
249
   $caseData3Desc: Same but for data3
250
   $caseRequireEmail: If 1, enrollment in clubs or services based on this archetype will require a valid e-mail address field in the borrower
251
	record as specified in the syspref AutoEmailPrimaryAddress
252
253
 Output:
254
   $success: 1 if all database operations were successful, 0 otherwise
255
   $errorCode: Code for reason of failure, good for translating errors in templates
256
   $errorMessage: English description of error
257
258
=cut
259
260
sub UpdateClubOrServiceArchetype {
261
    my ($casaId,        $type,          $title,          $description,    $publicEnrollment, $casData1Title,
262
        $casData2Title, $casData3Title, $caseData1Title, $caseData2Title, $caseData3Title,   $casData1Desc,
263
        $casData2Desc,  $casData3Desc,  $caseData1Desc,  $caseData2Desc,  $caseData3Desc,    $caseRequireEmail,
264
    ) = @_;
265
266
    ## Check for all neccessary parameters
267
    if ( !$casaId ) {
268
        return ( 0, "NO_ID" );
269
    }
270
    if ( !$type ) {
271
        return ( 0, "NO_TYPE" );
272
    }
273
    if ( !$title ) {
274
        return ( 0, "NO_TITLE" );
275
    }
276
    if ( !$description ) {
277
        return ( 0, "NO_DESCRIPTION" );
278
    }
279
280
    my $success = 1;
281
282
    my $dbh = C4::Context->dbh;
283
284
    my $sth;
285
    $sth = $dbh->prepare(
286
        "UPDATE clubsAndServicesArchetypes
287
         SET
288
         type = ?, title = ?, description = ?, publicEnrollment = ?,
289
         casData1Title = ?, casData2Title = ?, casData3Title = ?,
290
         caseData1Title = ?, caseData2Title = ?, caseData3Title = ?,
291
         casData1Desc = ?, casData2Desc = ?, casData3Desc = ?,
292
         caseData1Desc = ?, caseData2Desc = ?, caseData3Desc = ?, caseRequireEmail = ?,
293
         last_updated = NOW() WHERE casaId = ?"
294
    );
295
296
    $sth->execute(
297
        $type,          $title,          $description,    $publicEnrollment, $casData1Title,    $casData2Title,
298
        $casData3Title, $caseData1Title, $caseData2Title, $caseData3Title,   $casData1Desc,     $casData2Desc,
299
        $casData3Desc,  $caseData1Desc,  $caseData2Desc,  $caseData3Desc,    $caseRequireEmail, $casaId
300
    ) or return ( $success = 0, my $errorMessage = "DB_ERROR" );
301
    $sth->finish;
302
303
    return $success;
304
305
}
306
307
=head2 DeleteClubOrServiceArchetype
308
309
 Deletes an Archetype of the given id
310
 and all Clubs or Services based on it,
311
 and all Enrollments based on those clubs
312
 or services.
313
314
 Input:
315
   $casaId : id of the Archtype to be deleted
316
317
 Output:
318
   $success : 1 on successful deletion, 0 otherwise
319
320
=cut
321
322
sub DeleteClubOrServiceArchetype {
323
    my ($casaId) = @_;
324
325
    ## Paramter check
326
    if ( !$casaId ) {
327
        return 0;
328
    }
329
330
    my $success = 1;
331
332
    my $dbh = C4::Context->dbh;
333
334
    my $sth;
335
336
    $sth = $dbh->prepare("DELETE FROM clubsAndServicesEnrollments WHERE casaId = ?");
337
    $sth->execute($casaId) or $success = 0;
338
    $sth->finish;
339
340
    $sth = $dbh->prepare("DELETE FROM clubsAndServices WHERE casaId = ?");
341
    $sth->execute($casaId) or $success = 0;
342
    $sth->finish;
343
344
    $sth = $dbh->prepare("DELETE FROM clubsAndServicesArchetypes WHERE casaId = ?");
345
    $sth->execute($casaId) or $success = 0;
346
    $sth->finish;
347
348
    return 1;
349
}
350
351
=head2 AddClubOrService
352
353
 Creates a new club or service in the database
354
355
 Input:
356
   $type: 'club' or 'service', other types may be added as necessary.
357
   $title: Short description of the club or service
358
   $description: Long description of the club or service
359
   $casData1: The data described in case.casData1Title
360
   $casData2: The data described in case.casData2Title
361
   $casData3: The data described in case.casData3Title
362
   $startDate: The date the club or service begins ( Optional: Defaults to TODAY() )
363
   $endDate: The date the club or service ends ( Optional )
364
   $branchcode: Branch that created this club or service ( Optional: NULL is system-wide )
365
366
 Output:
367
   $success: 1 on successful add, 0 on failure
368
   $errorCode: Code for reason of failure, good for translating errors in templates
369
   $errorMessage: English description of error
370
371
=cut
372
373
sub AddClubOrService {
374
    my ( $casaId, $title, $description, $casData1, $casData2, $casData3, $startDate, $endDate, $branchcode ) = @_;
375
376
    ## Check for all neccessary parameters
377
    if ( !$casaId ) {
378
        return ( 0, "NO_ARCHETYPE" );
379
    }
380
    if ( !$title ) {
381
        return ( 0, "NO_TITLE" );
382
    }
383
    if ( !$description ) {
384
        return ( 0, "NO_DESCRIPTION" );
385
    }
386
387
    my $success = 1;
388
389
    if ( !$startDate ) {
390
        $startDate = getTodayMysqlDateFormat();
391
    }
392
393
    my $dbh = C4::Context->dbh;
394
395
    my $sth;
396
    if ($endDate) {
397
        $sth = $dbh->prepare(
398
            "INSERT INTO clubsAndServices ( casId, casaId, title, description, casData1, casData2, casData3, startDate, endDate, branchcode, last_updated )
399
                             VALUES ( NULL, ?, ?, ?, ?, ?, ?, ?, ?, ?, CURRENT_TIMESTAMP)"
400
        );
401
        $sth->execute( $casaId, $title, $description, $casData1, $casData2, $casData3, $startDate, $endDate, $branchcode ) or $success = 0;
402
    } else {
403
        $sth = $dbh->prepare(
404
            "INSERT INTO clubsAndServices ( casId, casaId, title, description, casData1, casData2, casData3, startDate, branchcode, last_updated )
405
                             VALUES ( NULL, ?, ?, ?, ?, ?, ?, ?, ?, CURRENT_TIMESTAMP)"
406
        );
407
        $sth->execute( $casaId, $title, $description, $casData1, $casData2, $casData3, $startDate, $branchcode ) or $success = 0;
408
    }
409
    $sth->finish;
410
411
    my ( $errorCode, $errorMessage );
412
    if ( !$success ) {
413
        $errorMessage = "DB_ERROR";
414
    }
415
416
    return ( $success, $errorCode, $errorMessage );
417
}
418
419
=head UpdateClubOrService
420
421
 Updates club or service in the database
422
423
 Input:
424
   $casId: id of the club or service to be updated
425
   $type: 'club' or 'service', other types may be added as necessary.
426
   $title: Short description of the club or service
427
   $description: Long description of the club or service
428
   $casData1: The data described in case.casData1Title
429
   $casData2: The data described in case.casData2Title
430
   $casData3: The data described in case.casData3Title
431
   $startDate: The date the club or service begins ( Optional: Defaults to TODAY() )
432
   $endDate: The date the club or service ends ( Optional )
433
434
 Output:
435
   $success: 1 on successful add, 0 on failure
436
   $errorCode: Code for reason of failure, good for translating errors in templates
437
   $errorMessage: English description of error
438
439
=cut
440
441
sub UpdateClubOrService {
442
    my ( $casId, $casaId, $title, $description, $casData1, $casData2, $casData3, $startDate, $endDate ) = @_;
443
444
    ## Check for all neccessary parameters
445
    if ( !$casId ) {
446
        return ( 0, "NO_CAS_ID" );
447
    }
448
    if ( !$casaId ) {
449
        return ( 0, "NO_CASA_ID" );
450
    }
451
    if ( !$title ) {
452
        return ( 0, "NO_TITLE" );
453
    }
454
    if ( !$description ) {
455
        return ( 0, "NO_DESCRIPTION" );
456
    }
457
458
    my $success = 1;
459
460
    if ( !$startDate ) {
461
        $startDate = getTodayMysqlDateFormat();
462
    }
463
464
    my $dbh = C4::Context->dbh;
465
466
    my $sth;
467
    if ($endDate) {
468
        $sth = $dbh->prepare(
469
"UPDATE clubsAndServices SET casaId = ?, title = ?, description = ?, casData1 = ?, casData2 = ?, casData3 = ?, startDate = ?, endDate = ?, last_updated = NOW() WHERE casId = ?"
470
        );
471
        $sth->execute( $casaId, $title, $description, $casData1, $casData2, $casData3, $startDate, $endDate, $casId )
472
          or return ( my $success = 0, my $errorCode = 5, my $errorMessage = $sth->errstr() );
473
    } else {
474
        $sth = $dbh->prepare(
475
"UPDATE clubsAndServices SET casaId = ?, title = ?, description = ?, casData1 = ?, casData2 = ?, casData3 = ?, startDate = ?, endDate = NULL, last_updated = NOW() WHERE casId = ?"
476
        );
477
        $sth->execute( $casaId, $title, $description, $casData1, $casData2, $casData3, $startDate, $casId )
478
          or return ( my $success = 0, my $errorCode = 5, my $errorMessage = $sth->errstr() );
479
    }
480
    $sth->finish;
481
482
    my ( $errorCode, $errorMessage );
483
    if ( !$success ) {
484
        $errorMessage = "DB_ERROR";
485
    }
486
487
    return ( $success, $errorMessage );
488
}
489
490
=head2 DeleteClubOrService
491
492
 Deletes a club or service of the given id and all enrollments based on it.
493
494
 Input:
495
   $casId : id of the club or service to be deleted
496
497
 Output:
498
   $success : 1 on successful deletion, 0 otherwise
499
500
=cut
501
502
sub DeleteClubOrService {
503
    my ($casId) = @_;
504
505
    if ( !$casId ) {
506
        return 0;
507
    }
508
509
    my $success = 1;
510
511
    my $dbh = C4::Context->dbh;
512
513
    my $sth;
514
    $sth = $dbh->prepare("DELETE FROM clubsAndServicesEnrollments WHERE casId = ?");
515
    $sth->execute($casId) or $success = 0;
516
    $sth->finish;
517
518
    $sth = $dbh->prepare("DELETE FROM clubsAndServices WHERE casId = ?");
519
    $sth->execute($casId) or $success = 0;
520
    $sth->finish;
521
522
    return 1;
523
}
524
525
=head EnrollInClubOrService
526
527
 Enrolls a borrower in a given club or service
528
529
 Input:
530
   $casId: The unique id of the club or service being enrolled in
531
   $borrowerCardnumber: The card number of the enrolling borrower
532
   $dateEnrolled: Date the enrollment begins ( Optional: Defauls to TODAY() )
533
   $data1: The data described in ClubsAndServicesArchetypes.caseData1Title
534
   $data2: The data described in ClubsAndServicesArchetypes.caseData2Title
535
   $data3: The data described in ClubsAndServicesArchetypes.caseData3Title
536
   $branchcode: The branch where this club or service enrollment is,
537
   $borrowernumber: ( Optional: Alternative to using $borrowerCardnumber )
538
539
 Output:
540
   $success: 1 on successful enrollment, 0 on failure
541
   $errorCode: Code for reason of failure, good for translating errors in templates
542
   $errorMessage: English description of error
543
544
=cut
545
546
sub EnrollInClubOrService {
547
    my ( $casaId, $casId, $borrowerCardnumber, $dateEnrolled, $data1, $data2, $data3, $branchcode, $borrowernumber ) = @_;
548
549
    ## Check for all neccessary parameters
550
    unless ($casaId) {
551
        return ( 0, "NO_CASA_ID" );
552
    }
553
    unless ($casId) {
554
        return ( 0, "NO_CAS_ID" );
555
    }
556
    unless ( $borrowerCardnumber || $borrowernumber ) {
557
        return ( 0, "NO_BORROWER" );
558
    }
559
560
    my $member;
561
    if ($borrowerCardnumber) {
562
        $member = C4::Members::GetMember( cardnumber => $borrowerCardnumber );
563
    } elsif ($borrowernumber) {
564
        $member = C4::Members::GetMember( borrowernumber => $borrowernumber );
565
    }
566
567
    unless ($member) {
568
        return ( 0, "NO_BORROWER_FOUND" );
569
    }
570
571
    my $casa = GetClubOrServiceArchetype( $casaId, 1 );
572
    if ( $casa->{'caseRequireEmail'} ) {
573
        my $AutoEmailPrimaryAddress = C4::Context->preference('AutoEmailPrimaryAddress');
574
        unless ( $member->{$AutoEmailPrimaryAddress} ) {
575
            return ( 0, "NO_EMAIL" );
576
        }
577
    }
578
579
    $borrowernumber = $member->{'borrowernumber'};
580
581
    if ( isEnrolled( $casId, $borrowernumber ) ) { return ( 0, "ENROLLED" ); }
582
583
    if ( !$dateEnrolled ) {
584
        $dateEnrolled = getTodayMysqlDateFormat();
585
    }
586
587
    my $dbh = C4::Context->dbh;
588
    my $sth = $dbh->prepare(
589
        "INSERT INTO clubsAndServicesEnrollments ( caseId, casaId, casId, borrowernumber, data1, data2, data3, dateEnrolled, dateCanceled, last_updated, branchcode)
590
                           VALUES ( NULL, ?, ?, ?, ?, ?, ?, ?, NULL, NOW(), ? )"
591
    );
592
    $sth->execute( $casaId, $casId, $borrowernumber, $data1, $data2, $data3, $dateEnrolled, $branchcode )
593
      or return ( my $success = 0, my $errorCode = 4, my $errorMessage = $sth->errstr() );
594
    $sth->finish;
595
596
    return $success = 1;
597
}
598
599
=head2 GetEnrollments
600
601
 Returns information about the clubs and services the given borrower is enrolled in.
602
603
 Input:
604
   $borrowernumber: The borrowernumber of the borrower
605
606
 Output:
607
   $results: Reference to an array of associated arrays
608
609
=cut
610
611
sub GetEnrollments {
612
    my ($borrowernumber) = @_;
613
614
    my $dbh = C4::Context->dbh;
615
616
    my $sth = $dbh->prepare(
617
        "SELECT * FROM clubsAndServices, clubsAndServicesEnrollments
618
         WHERE clubsAndServices.casId = clubsAndServicesEnrollments.casId
619
         AND clubsAndServicesEnrollments.borrowernumber = ?"
620
    );
621
    $sth->execute($borrowernumber) or return 0;
622
623
    my @results;
624
    while ( my $row = $sth->fetchrow_hashref ) {
625
        push( @results, $row );
626
    }
627
628
    $sth->finish;
629
630
    return \@results;
631
}
632
633
=head2 GetCasEnrollments
634
635
 Returns information about the clubs and services borrowers that are enrolled
636
637
 Input:
638
   $casId: The id of the club or service to look up enrollments for
639
640
 Output:
641
   $results: Reference to an array of associated arrays
642
643
=cut
644
645
sub GetCasEnrollments {
646
    my ($casId) = @_;
647
648
    my $dbh = C4::Context->dbh;
649
650
    my $sth = $dbh->prepare(
651
        "SELECT * FROM clubsAndServicesEnrollments, borrowers
652
         WHERE clubsAndServicesEnrollments.borrowernumber = borrowers.borrowernumber
653
         AND clubsAndServicesEnrollments.casId = ? AND dateCanceled IS NULL
654
         ORDER BY surname, firstname"
655
    );
656
    $sth->execute($casId) or return 0;
657
658
    my @results;
659
    while ( my $row = $sth->fetchrow_hashref ) {
660
        push( @results, $row );
661
    }
662
663
    $sth->finish;
664
665
    return \@results;
666
}
667
668
=head2 GetClubsAndServices
669
670
 Returns information about clubs and services
671
672
 Input:
673
   $type: ( Optional: 'club' or 'service' )
674
   $branchcode: ( Optional: Get clubs and services only created by this branch )
675
   $orderby: ( Optional: name of column to sort by )
676
677
 Output:
678
   $results: Reference to an array of associated arrays
679
680
=cut
681
682
sub GetClubsAndServices {
683
    my ( $type, $branchcode, $orderby ) = @_;
684
    $orderby = 'startDate DESC' unless ($orderby);
685
686
    my $dbh = C4::Context->dbh;
687
688
    my ( $sth, @results );
689
    if ( $type && $branchcode ) {
690
        $sth = $dbh->prepare(
691
            "SELECT clubsAndServices.casId,
692
                    clubsAndServices.casaId,
693
                    clubsAndServices.title,
694
                    clubsAndServices.description,
695
                    clubsAndServices.casData1,
696
                    clubsAndServices.casData2,
697
                    clubsAndServices.casData3,
698
                    clubsAndServices.startDate,
699
                    clubsAndServices.endDate,
700
                    clubsAndServices.last_updated,
701
                    clubsAndServices.branchcode
702
             FROM clubsAndServices, clubsAndServicesArchetypes
703
             WHERE
704
                    clubsAndServices.casaId = clubsAndServicesArchetypes.casaId
705
                AND clubsAndServices.branchcode = ?
706
                AND clubsAndServicesArchetypes.type = ?
707
            ORDER BY $orderby
708
            "
709
        );
710
        $sth->execute( $branchcode, $type ) or return 0;
711
712
    } elsif ($type) {
713
        $sth = $dbh->prepare(
714
            "SELECT clubsAndServices.casId,
715
                    clubsAndServices.casaId,
716
                    clubsAndServices.title,
717
                    clubsAndServices.description,
718
                    clubsAndServices.casData1,
719
                    clubsAndServices.casData2,
720
                    clubsAndServices.casData3,
721
                    clubsAndServices.startDate,
722
                    clubsAndServices.endDate,
723
                    clubsAndServices.last_updated,
724
                    clubsAndServices.branchcode
725
             FROM clubsAndServices, clubsAndServicesArchetypes
726
             WHERE
727
                    clubsAndServices.casaId = clubsAndServicesArchetypes.casaId
728
                AND clubsAndServicesArchetypes.type = ?
729
             ORDER BY $orderby
730
            "
731
        );
732
        $sth->execute($type) or return 0;
733
734
    } elsif ($branchcode) {
735
        $sth = $dbh->prepare(
736
            "SELECT clubsAndServices.casId,
737
                    clubsAndServices.casaId,
738
                    clubsAndServices.title,
739
                    clubsAndServices.description,
740
                    clubsAndServices.casData1,
741
                    clubsAndServices.casData2,
742
                    clubsAndServices.casData3,
743
                    clubsAndServices.startDate,
744
                    clubsAndServices.endDate,
745
                    clubsAndServices.last_updated,
746
                    clubsAndServices.branchcode
747
             FROM clubsAndServices, clubsAndServicesArchetypes
748
             WHERE
749
                    clubsAndServices.casaId = clubsAndServicesArchetypes.casaId
750
                AND clubsAndServices.branchcode = ?
751
             ORDER BY $orderby
752
            "
753
        );
754
        $sth->execute($branchcode) or return 0;
755
756
    } else {    ## Get all clubs and services
757
        $sth = $dbh->prepare("SELECT * FROM clubsAndServices ORDER BY $orderby");
758
        $sth->execute() or return 0;
759
    }
760
761
    while ( my $row = $sth->fetchrow_hashref ) {
762
        push( @results, $row );
763
    }
764
765
    $sth->finish;
766
767
    return \@results;
768
769
}
770
771
=head2 GetClubOrService
772
773
 Returns information about a club or service
774
775
 Input:
776
   $casId: Id of club or service to get
777
778
 Output: $casId, $casaId, $title, $description, $casData1, $casData2, $casData3, $startDate, $endDate, $last_updated, $branchcode
779
780
=cut
781
782
sub GetClubOrService {
783
    my ($casId) = @_;
784
785
    my $dbh = C4::Context->dbh;
786
787
    my ( $sth, @results );
788
    $sth = $dbh->prepare("SELECT * FROM clubsAndServices WHERE casId = ?");
789
    $sth->execute($casId) or return 0;
790
791
    my $row = $sth->fetchrow_hashref;
792
793
    $sth->finish;
794
795
    return (
796
        $$row{'casId'},    $$row{'casaId'},    $$row{'title'},   $$row{'description'},  $$row{'casData1'}, $$row{'casData2'},
797
        $$row{'casData3'}, $$row{'startDate'}, $$row{'endDate'}, $$row{'last_updated'}, $$row{'branchcode'}
798
    );
799
800
}
801
802
=head2 GetClubsAndServicesArchetypes
803
804
 Returns information about clubs and services archetypes
805
806
 Input:
807
   $type: 'club' or 'service' ( Optional: Defaults to all types )
808
   $branchcode: Get clubs or services created by this branch ( Optional )
809
810
 Output:
811
   $results:
812
     Otherwise: Reference to an array of associated arrays
813
     Except: 0 on failure
814
815
=cut
816
817
sub GetClubsAndServicesArchetypes {
818
    my ( $type, $branchcode ) = @_;
819
    my $dbh = C4::Context->dbh;
820
821
    my $sth;
822
    if ( $type && $branchcode ) {
823
        $sth = $dbh->prepare("SELECT * FROM clubsAndServicesArchetypes WHERE type = ? AND branchcode = ?");
824
        $sth->execute( $type, $branchcode ) or return 0;
825
    } elsif ($type) {
826
        $sth = $dbh->prepare("SELECT * FROM clubsAndServicesArchetypes WHERE type = ?");
827
        $sth->execute($type) or return 0;
828
    } elsif ($branchcode) {
829
        $sth = $dbh->prepare("SELECT * FROM clubsAndServicesArchetypes WHERE branchcode = ?");
830
        $sth->execute($branchcode) or return 0;
831
    } else {
832
        $sth = $dbh->prepare("SELECT * FROM clubsAndServicesArchetypes");
833
        $sth->execute() or return 0;
834
    }
835
836
    my @results;
837
    while ( my $row = $sth->fetchrow_hashref ) {
838
        push( @results, $row );
839
    }
840
841
    $sth->finish;
842
843
    return \@results;
844
}
845
846
=head2 GetClubOrServiceArchetype
847
848
 Returns information about a club or services archetype
849
850
 Input:
851
   $casaId: Id of Archetype to get
852
   $asHashref: Optional, if true, will return hashref instead of array
853
854
 Output:
855
     ( $casaId, $type, $title, $description, $publicEnrollment,
856
     $casData1Title, $casData2Title, $casData3Title,
857
     $caseData1Title, $caseData2Title, $caseData3Title,
858
     $casData1Desc, $casData2Desc, $casData3Desc,
859
     $caseData1Desc, $caseData2Desc, $caseData3Desc,
860
     $caseRequireEmail, $last_updated, $branchcode )
861
     Except: 0 on failure
862
863
=cut
864
865
sub GetClubOrServiceArchetype {
866
    my ( $casaId, $asHashref ) = @_;
867
868
    my $dbh = C4::Context->dbh;
869
870
    my $sth;
871
    $sth = $dbh->prepare("SELECT * FROM clubsAndServicesArchetypes WHERE casaId = ?");
872
    $sth->execute($casaId) or return 0;
873
874
    my $row = $sth->fetchrow_hashref;
875
876
    $sth->finish;
877
878
    if ($asHashref) { return $row; }
879
880
    return (
881
        $$row{'casaId'},         $$row{'type'},          $$row{'title'},            $$row{'description'},    $$row{'publicEnrollment'},
882
        $$row{'casData1Title'},  $$row{'casData2Title'}, $$row{'casData3Title'},    $$row{'caseData1Title'}, $$row{'caseData2Title'},
883
        $$row{'caseData3Title'}, $$row{'casData1Desc'},  $$row{'casData2Desc'},     $$row{'casData3Desc'},   $$row{'caseData1Desc'},
884
        $$row{'caseData2Desc'},  $$row{'caseData3Desc'}, $$row{'caseRequireEmail'}, $$row{'last_updated'},   $$row{'branchcode'}
885
    );
886
}
887
888
=head2  DoesEnrollmentRequireData
889
890
 Returns 1 if the given Archetype has
891
   data fields that need to be filled in
892
   at the time of enrollment.
893
894
 Input:
895
   $casaId: Id of Archetype to get
896
897
 Output:
898
   1: Enrollment will require extra data
899
   0: Enrollment will not require extra data
900
901
=cut
902
903
sub DoesEnrollmentRequireData {
904
    my ($casaId) = @_;
905
906
    my $dbh = C4::Context->dbh;
907
908
    my $sth;
909
    $sth = $dbh->prepare("SELECT caseData1Title FROM clubsAndServicesArchetypes WHERE casaId = ?");
910
    $sth->execute($casaId) or return 0;
911
912
    my $row = $sth->fetchrow_hashref;
913
914
    $sth->finish;
915
916
    if ( $$row{'caseData1Title'} ) {
917
        return 1;
918
    } else {
919
        return 0;
920
    }
921
}
922
923
=head2 CancelClubOrServiceEnrollment
924
925
 Cancels the given enrollment in a club or service
926
927
 Input:
928
   $caseId: The id of the enrollment to be canceled
929
930
 Output:
931
   $success: 1 on successful cancelation, 0 otherwise
932
933
=cut
934
935
sub CancelClubOrServiceEnrollment {
936
    my ($caseId) = @_;
937
938
    my $success = 1;
939
940
    my $dbh = C4::Context->dbh;
941
942
    my $sth = $dbh->prepare("UPDATE clubsAndServicesEnrollments SET dateCanceled = CURDATE(), last_updated = NOW() WHERE caseId = ?");
943
    $sth->execute($caseId) or $success = 0;
944
    $sth->finish;
945
946
    return $success;
947
}
948
949
=head2 GetEnrolledClubsAndServices
950
951
 Returns information about clubs and services
952
 the given borrower is enrolled in.
953
954
 Input:
955
   $borrowernumber
956
957
 Output:
958
   $results: Reference to an array of associated arrays
959
960
=cut
961
962
sub GetEnrolledClubsAndServices {
963
    my ($borrowernumber) = @_;
964
    my $dbh = C4::Context->dbh;
965
966
    my ( $sth, @results );
967
    $sth = $dbh->prepare(
968
        "SELECT
969
             clubsAndServicesEnrollments.caseId,
970
             clubsAndServices.casId,
971
             clubsAndServices.casaId,
972
             clubsAndServices.title,
973
             clubsAndServices.description,
974
             clubsAndServices.branchcode,
975
             clubsAndServicesArchetypes.type,
976
             clubsAndServicesArchetypes.publicEnrollment
977
         FROM clubsAndServices, clubsAndServicesArchetypes, clubsAndServicesEnrollments
978
         WHERE (
979
               clubsAndServices.casaId = clubsAndServicesArchetypes.casaId
980
           AND clubsAndServices.casId = clubsAndServicesEnrollments.casId
981
           AND ( clubsAndServices.endDate >= CURRENT_DATE() OR clubsAndServices.endDate IS NULL )
982
           AND clubsAndServicesEnrollments.dateCanceled IS NULL
983
           AND clubsAndServicesEnrollments.borrowernumber = ?
984
         )
985
         ORDER BY type, title
986
        "
987
    );
988
    $sth->execute($borrowernumber) or return 0;
989
990
    while ( my $row = $sth->fetchrow_hashref ) {
991
        push( @results, $row );
992
    }
993
994
    $sth->finish;
995
996
    return \@results;
997
998
}
999
1000
=head2 GetPubliclyEnrollableClubsAndServices
1001
1002
 Returns information about clubs and services
1003
 the given borrower can enroll in.
1004
1005
 Input:
1006
   $borrowernumber
1007
1008
 Output:
1009
   $results: Reference to an array of associated arrays
1010
1011
=cut
1012
1013
sub GetPubliclyEnrollableClubsAndServices {
1014
    my ($borrowernumber) = @_;
1015
1016
    my $dbh = C4::Context->dbh;
1017
1018
    my ( $sth, @results );
1019
    $sth = $dbh->prepare( "
1020
SELECT
1021
DISTINCT ( clubsAndServices.casId ),
1022
         clubsAndServices.title,
1023
         clubsAndServices.description,
1024
         clubsAndServices.branchcode,
1025
         clubsAndServicesArchetypes.type,
1026
         clubsAndServices.casaId
1027
FROM clubsAndServices, clubsAndServicesArchetypes
1028
WHERE clubsAndServicesArchetypes.casaId = clubsAndServices.casaId
1029
AND clubsAndServicesArchetypes.publicEnrollment =1
1030
AND clubsAndServices.casId NOT
1031
IN (
1032
  SELECT clubsAndServices.casId
1033
  FROM clubsAndServices, clubsAndServicesEnrollments
1034
  WHERE clubsAndServicesEnrollments.casId = clubsAndServices.casId
1035
  AND clubsAndServicesEnrollments.dateCanceled IS NULL
1036
  AND clubsAndServicesEnrollments.borrowernumber = ?
1037
)
1038
 ORDER BY type, title" );
1039
    $sth->execute($borrowernumber) or return 0;
1040
1041
    while ( my $row = $sth->fetchrow_hashref ) {
1042
        push( @results, $row );
1043
    }
1044
1045
    $sth->finish;
1046
1047
    return \@results;
1048
1049
}
1050
1051
=head2 GetAllEnrollableClubsAndServices
1052
1053
 Returns information about clubs and services
1054
 the given borrower can enroll in.
1055
1056
 Input:
1057
   $borrowernumber
1058
1059
 Output:
1060
   $results: Reference to an array of associated arrays
1061
1062
=cut
1063
1064
sub GetAllEnrollableClubsAndServices {
1065
    my ( $borrowernumber, $branchcode ) = @_;
1066
1067
    if ( $branchcode eq '' ) {
1068
        $branchcode = '%';
1069
    }
1070
1071
    my $dbh = C4::Context->dbh;
1072
1073
    my ( $sth, @results );
1074
    $sth = $dbh->prepare( "
1075
SELECT
1076
DISTINCT ( clubsAndServices.casId ),
1077
         clubsAndServices.title,
1078
         clubsAndServices.description,
1079
         clubsAndServices.branchcode,
1080
         clubsAndServicesArchetypes.type,
1081
         clubsAndServices.casaId
1082
FROM clubsAndServices, clubsAndServicesArchetypes
1083
WHERE clubsAndServicesArchetypes.casaId = clubsAndServices.casaId
1084
AND (
1085
  DATE(clubsAndServices.endDate) >= CURDATE()
1086
  OR
1087
  clubsAndServices.endDate IS NULL
1088
)
1089
AND clubsAndServices.branchcode LIKE ?
1090
AND clubsAndServices.casId NOT
1091
IN (
1092
  SELECT clubsAndServices.casId
1093
  FROM clubsAndServices, clubsAndServicesEnrollments
1094
  WHERE clubsAndServicesEnrollments.casId = clubsAndServices.casId
1095
  AND clubsAndServicesEnrollments.dateCanceled IS NULL
1096
  AND clubsAndServicesEnrollments.borrowernumber = ?
1097
)
1098
 ORDER BY type, title" );
1099
    $sth->execute( $branchcode, $borrowernumber ) or return 0;
1100
1101
    while ( my $row = $sth->fetchrow_hashref ) {
1102
        push( @results, $row );
1103
    }
1104
1105
    $sth->finish;
1106
1107
    return \@results;
1108
1109
}
1110
1111
sub getBorrowernumberByCardnumber {
1112
    my $dbh = C4::Context->dbh;
1113
1114
    my $sth = $dbh->prepare("SELECT borrowernumber FROM borrowers WHERE cardnumber = ?");
1115
    $sth->execute(@_) or return (0);
1116
1117
    my $row = $sth->fetchrow_hashref;
1118
1119
    my $borrowernumber = $$row{'borrowernumber'};
1120
    $sth->finish;
1121
1122
    return ($borrowernumber);
1123
}
1124
1125
sub isEnrolled {
1126
    my ( $casId, $borrowernumber ) = @_;
1127
1128
    my $dbh = C4::Context->dbh;
1129
1130
    my $sth = $dbh->prepare("SELECT COUNT(*) as isEnrolled FROM clubsAndServicesEnrollments WHERE casId = ? AND borrowernumber = ? AND dateCanceled IS NULL");
1131
    $sth->execute( $casId, $borrowernumber ) or return (0);
1132
1133
    my $row = $sth->fetchrow_hashref;
1134
1135
    my $isEnrolled = $$row{'isEnrolled'};
1136
    $sth->finish;
1137
1138
    return ($isEnrolled);
1139
}
1140
1141
sub getTodayMysqlDateFormat {
1142
    my ( $day, $month, $year ) = (localtime)[ 3, 4, 5 ];
1143
    my $today = sprintf( "%04d-%02d-%02d", $year + 1900, $month + 1, $day );
1144
    return $today;
1145
}
1146
1147
sub ReserveForBestSellersClub {
1148
    my ($biblionumber) = @_;
1149
1150
    unless ($biblionumber) { return; }
1151
1152
    my $dbh = C4::Context->dbh;
1153
    my $sth;
1154
1155
    ## Grab the bib for this biblionumber, we will need the author and title to find the relevent clubs
1156
    my $biblio_data = C4::Biblio::GetBiblioData($biblionumber);
1157
    my $author      = $biblio_data->{'author'};
1158
    my $title       = $biblio_data->{'title'};
1159
    my $itemtype    = $biblio_data->{'itemtype'};
1160
1161
    ## Find the casaId for the Bestsellers Club archetype
1162
    $sth = $dbh->prepare("SELECT * FROM clubsAndServicesArchetypes WHERE code LIKE 'BESTSELLERS_CLUB' ");
1163
    $sth->execute();
1164
    my $casa   = $sth->fetchrow_hashref();
1165
    my $casaId = $casa->{'casaId'};
1166
    $sth->finish();
1167
1168
    unless ($casaId) { return; }
1169
1170
    ## Find all the relevent bestsellers clubs
1171
    ## casData1 is title, casData2 is author
1172
    $sth = $dbh->prepare("SELECT * FROM clubsAndServices WHERE casaId = ?");
1173
    $sth->execute($casaId);
1174
    my @clubs;
1175
    while ( my $club = $sth->fetchrow_hashref() ) {
1176
1177
        #warn "Author/casData2 : '$author'/ " . $club->{'casData2'} . "'";
1178
        #warn "Title/casData1 : '$title'/" . $club->{'casData1'} . "'";
1179
1180
        ## If the author, title or both match, keep it.
1181
        if ( ( $club->{'casData1'} eq $title ) || ( $club->{'casData2'} eq $author ) ) {
1182
            push( @clubs, $club );
1183
1184
            #warn "casId" . $club->{'casId'};
1185
        } elsif ( $club->{'casData1'} =~ m/%/ ) {    # Title is using % as a wildcard
1186
            my @substrings = split( /%/, $club->{'casData1'} );
1187
            my $all_match = 1;
1188
            foreach my $sub (@substrings) {
1189
                unless ( $title =~ m/\Q$sub/ ) {
1190
                    $all_match = 0;
1191
                }
1192
            }
1193
            if ($all_match) { push( @clubs, $club ); }
1194
        } elsif ( $club->{'casData2'} =~ m/%/ ) {    # Author is using % as a wildcard
1195
            my @substrings = split( /%/, $club->{'casData2'} );
1196
            my $all_match = 1;
1197
            foreach my $sub (@substrings) {
1198
                unless ( $author =~ m/\Q$sub/ ) {
1199
                    $all_match = 0;
1200
                }
1201
            }
1202
1203
            ## Make sure the bib is in the list of itemtypes to use
1204
            my @itemtypes = split( / /, $club->{'casData3'} );
1205
            my $found_itemtype_match = 0;
1206
            if (@itemtypes) {                        ## If no itemtypes are listed, all itemtypes are valid, skip test.
1207
                foreach my $it (@itemtypes) {
1208
                    if ( $it eq $itemtype ) {
1209
                        $found_itemtype_match = 1;
1210
                        last;                        ## Short circuit for speed.
1211
                    }
1212
                }
1213
                $all_match = 0 unless ($found_itemtype_match);
1214
            }
1215
1216
            if ($all_match) { push( @clubs, $club ); }
1217
        }
1218
    }
1219
    $sth->finish();
1220
1221
    unless ( scalar(@clubs) ) { return; }
1222
1223
    ## Get all the members of the relevant clubs, but only get each borrower once, even if they are in multiple relevant clubs
1224
    ## Randomize the order of the borrowers
1225
    my @casIds;
1226
    my $sql = "SELECT DISTINCT(borrowers.borrowernumber) FROM borrowers, clubsAndServicesEnrollments
1227
             WHERE clubsAndServicesEnrollments.borrowernumber = borrowers.borrowernumber
1228
             AND (";
1229
    my $clubsCount = scalar(@clubs);
1230
    foreach my $club (@clubs) {
1231
        $sql .= " casId = ?";
1232
        if ( --$clubsCount ) {
1233
            $sql .= " OR";
1234
        }
1235
        push( @casIds, $club->{'casId'} );
1236
    }
1237
    $sql .= " ) ORDER BY RAND()";
1238
1239
    $sth = $dbh->prepare($sql);
1240
    $sth->execute(@casIds);
1241
    my @borrowers;
1242
    while ( my $borrower = $sth->fetchrow_hashref() ) {
1243
        push( @borrowers, $borrower );
1244
    }
1245
1246
    unless ( scalar(@borrowers) ) { return; }
1247
1248
    my $priority = 1;
1249
    foreach my $borrower (@borrowers) {
1250
        C4::Reserves::AddReserve(
1251
            my $branch         = $borrower->{'branchcode'},
1252
            my $borrowernumber = $borrower->{'borrowernumber'},
1253
            $biblionumber, my $constraint = 'a',
1254
            my $bibitems, $priority, my $notes = $casa->{'title'},
1255
            $title, my $checkitem,
1256
            my $found, my $expire_date
1257
        );
1258
        $priority++;
1259
    }
1260
}
1261
1262
1;
1263
1264
__END__
1265
1266
=back
1267
1268
=head1 AUTHOR
1269
1270
Kyle M Hall <kylemhall@gmail.com>
1271
1272
=cut
(-)a/cataloguing/addbiblio.pl (+2 lines)
Lines 35-40 use C4::Branch; # XXX subfield_is_koha_internal_p Link Here
35
use C4::ClassSource;
35
use C4::ClassSource;
36
use C4::ImportBatch;
36
use C4::ImportBatch;
37
use C4::Charset;
37
use C4::Charset;
38
use C4::ClubsAndServices;
38
39
39
use Date::Calc qw(Today);
40
use Date::Calc qw(Today);
40
use MARC::File::USMARC;
41
use MARC::File::USMARC;
Lines 867-872 if ( $op eq "addbiblio" ) { Link Here
867
        }
868
        }
868
        else {
869
        else {
869
            ( $biblionumber, $oldbibitemnum ) = AddBiblio( $record, $frameworkcode );
870
            ( $biblionumber, $oldbibitemnum ) = AddBiblio( $record, $frameworkcode );
871
            ReserveForBestSellersClub( $biblionumber );
870
        }
872
        }
871
        if ($redirect eq "items" || ($mode ne "popup" && !$is_a_modif && $redirect ne "view")){
873
        if ($redirect eq "items" || ($mode ne "popup" && !$is_a_modif && $redirect ne "view")){
872
	    if ($frameworkcode eq 'FA'){
874
	    if ($frameworkcode eq 'FA'){
(-)a/circ/circulation.pl (+4 lines)
Lines 36-41 use C4::Members; Link Here
36
use C4::Biblio;
36
use C4::Biblio;
37
use C4::Reserves;
37
use C4::Reserves;
38
use C4::Context;
38
use C4::Context;
39
use C4::ClubsAndServices;
39
use CGI::Session;
40
use CGI::Session;
40
use C4::Members::Attributes qw(GetBorrowerAttributes);
41
use C4::Members::Attributes qw(GetBorrowerAttributes);
41
use Koha::DateUtils;
42
use Koha::DateUtils;
Lines 105-110 my $findborrower = $query->param('findborrower'); Link Here
105
$findborrower =~ s|,| |g;
106
$findborrower =~ s|,| |g;
106
my $borrowernumber = $query->param('borrowernumber');
107
my $borrowernumber = $query->param('borrowernumber');
107
108
109
108
$branch  = C4::Context->userenv->{'branch'};  
110
$branch  = C4::Context->userenv->{'branch'};  
109
$printer = C4::Context->userenv->{'branchprinter'};
111
$printer = C4::Context->userenv->{'branchprinter'};
110
112
Lines 730-735 $template->param( picture => 1 ) if $picture; Link Here
730
732
731
my $canned_notes = GetAuthorisedValues("BOR_NOTES");
733
my $canned_notes = GetAuthorisedValues("BOR_NOTES");
732
734
735
$template->param( ClubsAndServicesLoop => GetEnrolledClubsAndServices( $borrowernumber ) );
736
733
$template->param(
737
$template->param(
734
    debt_confirmed            => $debt_confirmed,
738
    debt_confirmed            => $debt_confirmed,
735
    SpecifyDueDate            => $duedatespec_allow,
739
    SpecifyDueDate            => $duedatespec_allow,
(-)a/clubs_services/clubs_services.pl (+55 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Author: Kyle M Hall
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
use Modern::Perl;
21
22
use CGI;
23
use C4::Output;
24
use C4::Auth;
25
use C4::Context;
26
use C4::ClubsAndServices;
27
28
my $query = new CGI;
29
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
30
    {   template_name   => "clubs_services/clubs_services.tmpl",
31
        query           => $query,
32
        type            => "intranet",
33
        authnotrequired => 0,
34
35
        #        flagsrequired   => { clubs_services => 'create_clubs_service' },
36
    }
37
);
38
39
my $branchcode = C4::Context->userenv->{branch};
40
41
my $clubs    = GetClubsAndServices( 'club',    $branchcode );
42
my $services = GetClubsAndServices( 'service', $branchcode );
43
44
$template->param(
45
    intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"),
46
    intranetstylesheet      => C4::Context->preference("intranetstylesheet"),
47
    IntranetNav             => C4::Context->preference("IntranetNav"),
48
49
    clubs_services => 1,
50
51
    clubsLoop    => $clubs,
52
    servicesLoop => $services,
53
);
54
55
output_html_with_http_headers $query, $cookie, $template->output;
(-)a/clubs_services/clubs_services_enrollments.pl (+51 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Author: Kyle M Hall
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
use Modern::Perl;
21
22
use CGI;
23
use C4::Output;
24
use C4::Auth;
25
use C4::Context;
26
use C4::ClubsAndServices;
27
28
my $query = new CGI;
29
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
30
    {   template_name   => "clubs_services/clubs_services_enrollments.tmpl",
31
        query           => $query,
32
        type            => "intranet",
33
        authnotrequired => 0,
34
        flagsrequired   => { clubs_services => 'enroll_borrower' },
35
    }
36
);
37
38
my $casId = $query->param('casId');
39
my ( $casId, $casaId, $title, $description, $casData1, $casData2, $casData3, $startDate, $endDate, $last_updated, $branchcode ) = GetClubOrService($casId);
40
$template->param( casTitle => $title );
41
42
my $enrollments = GetCasEnrollments($casId);
43
$template->param( enrollments_loop => $enrollments );
44
45
$template->param(
46
    intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"),
47
    intranetstylesheet      => C4::Context->preference("intranetstylesheet"),
48
    IntranetNav             => C4::Context->preference("IntranetNav"),
49
);
50
51
output_html_with_http_headers $query, $cookie, $template->output;
(-)a/clubs_services/edit_archetypes.pl (+194 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Author: Kyle M Hall
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
use Modern::Perl;
21
22
use CGI;
23
use C4::Output;
24
use C4::Auth;
25
use C4::Context;
26
use C4::ClubsAndServices;
27
28
my $query = new CGI;
29
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
30
    {   template_name   => "clubs_services/edit_archetypes.tmpl",
31
        query           => $query,
32
        type            => "intranet",
33
        authnotrequired => 0,
34
        flagsrequired   => { clubs_services => 'create_archetype' },
35
    }
36
);
37
38
my $branchcode = C4::Context->userenv->{branch};
39
40
## Create new Archetype
41
if ( $query->param('action') eq 'create' ) {
42
    my $type             = $query->param('type');
43
    my $title            = $query->param('title');
44
    my $description      = $query->param('description');
45
    my $publicEnrollment = ( $query->param('publicEnrollment') eq 'yes' ) ? 1 : 0;
46
47
    my $casData1Title = $query->param('casData1Title');
48
    my $casData2Title = $query->param('casData2Title');
49
    my $casData3Title = $query->param('casData3Title');
50
51
    my $caseData1Title = $query->param('caseData1Title');
52
    my $caseData2Title = $query->param('caseData2Title');
53
    my $caseData3Title = $query->param('caseData3Title');
54
55
    my $casData1Desc = $query->param('casData1Desc');
56
    my $casData2Desc = $query->param('casData2Desc');
57
    my $casData3Desc = $query->param('casData3Desc');
58
59
    my $caseData1Desc = $query->param('caseData1Desc');
60
    my $caseData2Desc = $query->param('caseData2Desc');
61
    my $caseData3Desc = $query->param('caseData3Desc');
62
63
    my $caseRequireEmail = $query->param('caseRequireEmail') ? '1' : '0';
64
65
    my ( $createdSuccessfully, $errorMessage ) = AddClubOrServiceArchetype(
66
        $type,          $title,          $description,    $publicEnrollment, $casData1Title,    $casData2Title,
67
        $casData3Title, $caseData1Title, $caseData2Title, $caseData3Title,   $casData1Desc,     $casData2Desc,
68
        $casData3Desc,  $caseData1Desc,  $caseData2Desc,  $caseData3Desc,    $caseRequireEmail, $branchcode
69
    );
70
71
    $template->param(
72
        previousActionCreate => 1,
73
        createdTitle         => $title,
74
    );
75
76
    if ($createdSuccessfully) {
77
        $template->param( createSuccess => 1 );
78
    } else {
79
        $template->param( createFailure => 1 );
80
        $template->param( errorMessage  => $errorMessage );
81
    }
82
83
}
84
85
## Delete an Archtype
86
elsif ( $query->param('action') eq 'delete' ) {
87
    my $casaId  = $query->param('casaId');
88
    my $success = DeleteClubOrServiceArchetype($casaId);
89
90
    $template->param( previousActionDelete => 1 );
91
    if ($success) {
92
        $template->param( deleteSuccess => 1 );
93
    } else {
94
        $template->param( deleteFailure => 1 );
95
    }
96
}
97
98
## Edit a club or service: grab data, put in form.
99
elsif ( $query->param('action') eq 'edit' ) {
100
    my $casaId = $query->param('casaId');
101
    my ($casaId,        $type,           $title,          $description,      $publicEnrollment, $casData1Title, $casData2Title,
102
        $casData3Title, $caseData1Title, $caseData2Title, $caseData3Title,   $casData1Desc,     $casData2Desc,  $casData3Desc,
103
        $caseData1Desc, $caseData2Desc,  $caseData3Desc,  $caseRequireEmail, $casaTimestamp,    $casaBranchcode
104
    ) = GetClubOrServiceArchetype($casaId);
105
106
    $template->param(
107
        previousActionEdit   => 1,
108
        editCasaId           => $casaId,
109
        editType             => $type,
110
        editTitle            => $title,
111
        editDescription      => $description,
112
        editCasData1Title    => $casData1Title,
113
        editCasData2Title    => $casData2Title,
114
        editCasData3Title    => $casData3Title,
115
        editCaseData1Title   => $caseData1Title,
116
        editCaseData2Title   => $caseData2Title,
117
        editCaseData3Title   => $caseData3Title,
118
        editCasData1Desc     => $casData1Desc,
119
        editCasData2Desc     => $casData2Desc,
120
        editCasData3Desc     => $casData3Desc,
121
        editCaseData1Desc    => $caseData1Desc,
122
        editCaseData2Desc    => $caseData2Desc,
123
        editCaseData3Desc    => $caseData3Desc,
124
        editCaseRequireEmail => $caseRequireEmail,
125
        editCasaTimestamp    => $casaTimestamp,
126
        editCasaBranchcode   => $casaBranchcode
127
    );
128
129
    if ($publicEnrollment) {
130
        $template->param( editPublicEnrollment => 1 );
131
    }
132
}
133
134
# Update an Archetype
135
elsif ( $query->param('action') eq 'update' ) {
136
    my $casaId           = $query->param('casaId');
137
    my $type             = $query->param('type');
138
    my $title            = $query->param('title');
139
    my $description      = $query->param('description');
140
    my $publicEnrollment = ( $query->param('publicEnrollment') eq 'yes' ) ? 1 : 0;
141
142
    my $casData1Title = $query->param('casData1Title');
143
    my $casData2Title = $query->param('casData2Title');
144
    my $casData3Title = $query->param('casData3Title');
145
146
    my $caseData1Title = $query->param('caseData1Title');
147
    my $caseData2Title = $query->param('caseData2Title');
148
    my $caseData3Title = $query->param('caseData3Title');
149
150
    my $casData1Desc = $query->param('casData1Desc');
151
    my $casData2Desc = $query->param('casData2Desc');
152
    my $casData3Desc = $query->param('casData3Desc');
153
154
    my $caseData1Desc = $query->param('caseData1Desc');
155
    my $caseData2Desc = $query->param('caseData2Desc');
156
    my $caseData3Desc = $query->param('caseData3Desc');
157
158
    my $caseRequireEmail = $query->param('caseRequireEmail');
159
160
    my ( $createdSuccessfully, $errorMessage ) = UpdateClubOrServiceArchetype(
161
        $casaId,        $type,          $title,          $description,    $publicEnrollment, $casData1Title,
162
        $casData2Title, $casData3Title, $caseData1Title, $caseData2Title, $caseData3Title,   $casData1Desc,
163
        $casData2Desc,  $casData3Desc,  $caseData1Desc,  $caseData2Desc,  $caseData3Desc,    $caseRequireEmail
164
    );
165
166
    $template->param(
167
        previousActionUpdate => 1,
168
        updatedTitle         => $title,
169
    );
170
171
    if ($createdSuccessfully) {
172
        $template->param( updateSuccess => 1 );
173
    } else {
174
        $template->param( updateFailure => 1 );
175
        $template->param( errorMessage  => $errorMessage );
176
    }
177
178
}
179
180
my $clubArchetypes    = GetClubsAndServicesArchetypes('club');
181
my $serviceArchetypes = GetClubsAndServicesArchetypes('service');
182
183
$template->param(
184
    intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"),
185
    intranetstylesheet      => C4::Context->preference("intranetstylesheet"),
186
    IntranetNav             => C4::Context->preference("IntranetNav"),
187
188
    edit_archetypes => 1,
189
190
    clubArchetypesLoop    => $clubArchetypes,
191
    serviceArchetypesLoop => $serviceArchetypes,
192
);
193
194
output_html_with_http_headers $query, $cookie, $template->output;
(-)a/clubs_services/edit_clubs_services.pl (+195 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Author: Kyle M Hall
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
use Modern::Perl;
21
22
use CGI;
23
use C4::Output;
24
use C4::Auth;
25
use C4::Context;
26
use C4::ClubsAndServices;
27
use Koha::DateUtils;
28
29
my $query = new CGI;
30
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
31
    {   template_name   => "clubs_services/edit_clubs_services.tmpl",
32
        query           => $query,
33
        type            => "intranet",
34
        authnotrequired => 0,
35
        flagsrequired   => { clubs_services => 'create_club_service' },
36
    }
37
);
38
39
my $branchcode = C4::Context->userenv->{branch};
40
41
# Archetype selected for Club or Service creation
42
if ( $query->param('action') eq 'selectArchetype' ) {
43
    my $casaId = $query->param('casaId');
44
45
    my ($casaId,        $casaType,      $casaTitle,      $casaDescription, $casaPublicEnrollment, $casData1Title,
46
        $casData2Title, $casData3Title, $caseData1Title, $caseData2Title,  $caseData3Title,       $casData1Desc,
47
        $casData2Desc,  $casData3Desc,  $caseData1Desc,  $caseData2Desc,   $caseData3Desc,        $casaTimestamp
48
    ) = GetClubOrServiceArchetype($casaId);
49
50
    $template->param(
51
        previousActionSelectArchetype => 1,
52
53
        casaId               => $casaId,
54
        casaType             => $casaType,
55
        casaTitle            => $casaTitle,
56
        casaDescription      => $casaDescription,
57
        casaPublicEnrollment => $casaPublicEnrollment,
58
        casData1Title        => $casData1Title,
59
        casData2Title        => $casData2Title,
60
        casData3Title        => $casData3Title,
61
        caseData1Title       => $caseData1Title,
62
        caseData2Title       => $caseData2Title,
63
        caseData3Title       => $caseData3Title,
64
        casData1Desc         => $casData1Desc,
65
        casData2Desc         => $casData2Desc,
66
        casData3Desc         => $casData3Desc,
67
        caseData1Desc        => $caseData1Desc,
68
        caseData2Desc        => $caseData2Desc,
69
        caseData3Desc        => $caseData3Desc,
70
        caseTimestamp        => $casaTimestamp
71
    );
72
}
73
74
# Create new Club or Service
75
elsif ( $query->param('action') eq 'create' ) {
76
    my $casaId      = $query->param('casaId');
77
    my $title       = $query->param('title');
78
    my $description = $query->param('description');
79
    my $casData1    = $query->param('casData1');
80
    my $casData2    = $query->param('casData2');
81
    my $casData3    = $query->param('casData3');
82
    my $startDate   = output_pref( dt_from_string( $query->param('startDate') ), 'iso' );
83
    my $endDate     = output_pref( dt_from_string( $query->param('endDate') ), 'iso' );
84
85
    my ( $createdSuccessfully, $errorMessage ) = AddClubOrService( $casaId, $title, $description, $casData1, $casData2, $casData3, $startDate, $endDate, $branchcode );
86
87
    $template->param(
88
        previousActionCreate => 1,
89
        createdTitle         => $title,
90
    );
91
92
    if ($createdSuccessfully) {
93
        $template->param( createSuccess => 1 );
94
    } else {
95
        $template->param( createFailure => 1 );
96
        $template->param( errorMessage  => $errorMessage );
97
    }
98
}
99
100
## Delete a club or service
101
elsif ( $query->param('action') eq 'delete' ) {
102
    my $casId   = $query->param('casId');
103
    my $success = DeleteClubOrService($casId);
104
105
    $template->param( previousActionDelete => 1 );
106
    if ($success) {
107
        $template->param( deleteSuccess => 1 );
108
    } else {
109
        $template->param( deleteFailure => 1 );
110
    }
111
}
112
113
## Edit a club or service: grab data, put in form.
114
elsif ( $query->param('action') eq 'edit' ) {
115
    my $casId = $query->param('casId');
116
    my ( $casId, $casaId, $title, $description, $casData1, $casData2, $casData3, $startDate, $endDate, $timestamp ) = GetClubOrService($casId);
117
118
    my ($casaId,        $casaType,      $casaTitle,      $casaDescription, $casaPublicEnrollment, $casData1Title,
119
        $casData2Title, $casData3Title, $caseData1Title, $caseData2Title,  $caseData3Title,       $casData1Desc,
120
        $casData2Desc,  $casData3Desc,  $caseData1Desc,  $caseData2Desc,   $caseData3Desc,        $casaTimestamp
121
    ) = GetClubOrServiceArchetype($casaId);
122
123
    $template->param(
124
        previousActionSelectArchetype => 1,
125
        previousActionEdit            => 1,
126
        editCasId                     => $casId,
127
        editCasaId                    => $casaId,
128
        editTitle                     => $title,
129
        editDescription               => $description,
130
        editCasData1                  => $casData1,
131
        editCasData2                  => $casData2,
132
        editCasData3                  => $casData3,
133
        editStartDate                 => $startDate,
134
        editEndDate                   => $endDate,
135
        editTimestamp                 => $timestamp,
136
137
        casaId        => $casaId,
138
        casaTitle     => $casaTitle,
139
        casData1Title => $casData1Title,
140
        casData2Title => $casData2Title,
141
        casData3Title => $casData3Title,
142
        casData1Desc  => $casData1Desc,
143
        casData2Desc  => $casData2Desc,
144
        casData3Desc  => $casData3Desc
145
    );
146
}
147
148
# Update a Club or Service
149
if ( $query->param('action') eq 'update' ) {
150
    my $casId       = $query->param('casId');
151
    my $casaId      = $query->param('casaId');
152
    my $title       = $query->param('title');
153
    my $description = $query->param('description');
154
    my $casData1    = $query->param('casData1');
155
    my $casData2    = $query->param('casData2');
156
    my $casData3    = $query->param('casData3');
157
    my $startDate   = output_pref( dt_from_string( $query->param('startDate') ), 'iso' );
158
    my $endDate     = output_pref( dt_from_string( $query->param('endDate') ), 'iso' );
159
160
    my ( $createdSuccessfully, $errorMessage ) = UpdateClubOrService( $casId, $casaId, $title, $description, $casData1, $casData2, $casData3, $startDate, $endDate );
161
162
    $template->param(
163
        previousActionUpdate => 1,
164
        updatedTitle         => $title,
165
    );
166
167
    if ($createdSuccessfully) {
168
        $template->param( updateSuccess => 1 );
169
    } else {
170
        $template->param( updateFailure => 1 );
171
        $template->param( errorMessage  => $errorMessage );
172
    }
173
}
174
175
my $clubs    = GetClubsAndServices( 'club',    $query->cookie('branch') );
176
my $services = GetClubsAndServices( 'service', $query->cookie('branch') );
177
my $archetypes = GetClubsAndServicesArchetypes();
178
179
if ($archetypes) {    ## Disable 'Create New Club or Service' if there are no archetypes defined.
180
    $template->param( archetypes => 1 );
181
}
182
183
$template->param(
184
    intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"),
185
    intranetstylesheet      => C4::Context->preference("intranetstylesheet"),
186
    IntranetNav             => C4::Context->preference("IntranetNav"),
187
188
    edit_clubs_services => 1,
189
190
    clubsLoop      => $clubs,
191
    servicesLoop   => $services,
192
    archetypesLoop => $archetypes,
193
);
194
195
output_html_with_http_headers $query, $cookie, $template->output;
(-)a/clubs_services/enroll_clubs_services.pl (+111 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Author: Kyle M Hall
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
use Modern::Perl;
21
22
use CGI;
23
use C4::Output;
24
use C4::Auth;
25
use C4::Context;
26
use C4::ClubsAndServices;
27
28
my $query = new CGI;
29
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
30
    {   template_name   => "clubs_services/enroll_clubs_services.tmpl",
31
        query           => $query,
32
        type            => "intranet",
33
        authnotrequired => 0,
34
        flagsrequired   => { clubs_services => 'enroll_borrower' },
35
    }
36
);
37
38
my $branchcode = $query->cookie('branch');
39
40
if ( $query->param('action') eq 'enroll' ) {
41
    my $borrowerBarcode = $query->param('borrowerBarcode');
42
    my $casId           = $query->param('casId');
43
    my $casaId          = $query->param('casaId');
44
    my $data1           = $query->param('data1');
45
    my $data2           = $query->param('data2');
46
    my $data3           = $query->param('data3');
47
48
    my $dateEnrolled;    # Will default to Today
49
50
    my ( $success, $errorMessage ) = EnrollInClubOrService( $casaId, $casId, $borrowerBarcode, $dateEnrolled, $data1, $data2, $data3, $branchcode );
51
52
    $template->param(
53
        previousActionEnroll => 1,
54
        enrolledBarcode      => $borrowerBarcode,
55
    );
56
57
    if ($success) {
58
        $template->param( enrollSuccess => 1 );
59
    } else {
60
        $template->param( enrollFailure => 1 );
61
        $template->param( errorMessage  => $errorMessage );
62
    }
63
64
}
65
66
my ( $casId, $casaId, $casTitle, $casDescription, $casStartDate, $casEndDate, $casTimestamp ) = GetClubOrService( $query->param('casId') );
67
my ($casaId,        $casaType,      $casaTitle,      $casaDescription, $casaPublicEnrollment, $casData1Title,
68
    $casData2Title, $casData3Title, $caseData1Title, $caseData2Title,  $caseData3Title,       $casData1Desc,
69
    $casData2Desc,  $casData3Desc,  $caseData1Desc,  $caseData2Desc,   $caseData3Desc,        $timestamp
70
) = GetClubOrServiceArchetype($casaId);
71
72
$template->param(
73
    intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"),
74
    intranetstylesheet      => C4::Context->preference("intranetstylesheet"),
75
    IntranetNav             => C4::Context->preference("IntranetNav"),
76
77
    casId          => $casId,
78
    casTitle       => $casTitle,
79
    casDescription => $casDescription,
80
    casStartDate   => $casStartDate,
81
    casEndDate     => $casEndDate,
82
    casTimeStamp   => $casTimestamp,
83
84
    casaId               => $casaId,
85
    casaType             => $casaType,
86
    casaTitle            => $casaTitle,
87
    casaDescription      => $casaDescription,
88
    casaPublicEnrollment => $casaPublicEnrollment,
89
);
90
91
if ($caseData1Title) {
92
    $template->param( caseData1Title => $caseData1Title );
93
}
94
if ($caseData2Title) {
95
    $template->param( caseData2Title => $caseData2Title );
96
}
97
if ($caseData3Title) {
98
    $template->param( caseData3Title => $caseData3Title );
99
}
100
101
if ($caseData1Desc) {
102
    $template->param( caseData1Desc => $caseData1Desc );
103
}
104
if ($caseData2Desc) {
105
    $template->param( caseData2Desc => $caseData2Desc );
106
}
107
if ($caseData3Desc) {
108
    $template->param( caseData3Desc => $caseData3Desc );
109
}
110
111
output_html_with_http_headers $query, $cookie, $template->output;
(-)a/installer/data/mysql/de-DE/mandatory/clubs_and_services_archetypes.sql (+4 lines)
Line 0 Link Here
1
INSERT INTO `clubsAndServicesArchetypes` (`casaId`, `code`, `type`, `title`, `description`, `publicEnrollment`, `casData1Title`, `casData2Title`, `casData3Title`, `caseData1Title`, `caseData2Title`, `caseData3Title`, `casData1Desc`, `casData2Desc`, `casData3Desc`, `caseData1Desc`, `caseData2Desc`, `caseData3Desc`, `caseRequireEmail`, `branchcode`, `last_updated`, `system_defined`) VALUES
2
(1, 'BESTSELLERS_CLUB', 'club', 'Bestsellers Club', 'This club archetype gives the patrons the ability join a club for a given author and for staff to batch generate a holds list which shuffles the holds queue when specific titles or books by certain authors are received.', 0, 'Title', 'Author', 'Item Types', NULL, NULL, NULL, 'If filled in, the the club will only apply to books where the title matches this field. Must be identical to the MARC field mapped to title.', 'If filled in, the the club will only apply to books where the author matches this field. Must be identical to the MARC field mapped to author.', 'Put a list of space separated Item Types here for that this club should work for. Leave it blank for all item types.', NULL, NULL, NULL, 0, NULL, '2009-09-28 10:29:01', 1),
3
(2, 'NEW_ITEMS_EMAIL_LIST', 'service', 'New Items E-mail List', 'This club archetype gives the patrons the ability join a mailing list which will e-mail weekly lists of new items for the given itemtype and callnumber combination given.', 0, 'Itemtype', 'Callnumber', NULL, NULL, NULL, NULL, 'The Itemtype to be looked up. Use % for all itemtypes.', 'The callnumber to look up. Use % as wildcard.', NULL, NULL, NULL, NULL, 0, NULL, '2009-05-17 08:57:10', 1);
4
(-)a/installer/data/mysql/de-DE/mandatory/clubs_and_services_archetypes.txt (+2 lines)
Line 0 Link Here
1
System defined archetypes for the clubs and services feature.
2
These archetypes are required by Koha for certain functionality.
(-)a/installer/data/mysql/en/mandatory/clubs_and_services_archetypes.sql (+4 lines)
Line 0 Link Here
1
INSERT INTO `clubsAndServicesArchetypes` (`casaId`, `code`, `type`, `title`, `description`, `publicEnrollment`, `casData1Title`, `casData2Title`, `casData3Title`, `caseData1Title`, `caseData2Title`, `caseData3Title`, `casData1Desc`, `casData2Desc`, `casData3Desc`, `caseData1Desc`, `caseData2Desc`, `caseData3Desc`, `caseRequireEmail`, `branchcode`, `last_updated`, `system_defined`) VALUES
2
(1, 'BESTSELLERS_CLUB', 'club', 'Bestsellers Club', 'This club archetype gives the patrons the ability join a club for a given author and for staff to batch generate a holds list which shuffles the holds queue when specific titles or books by certain authors are received.', 0, 'Title', 'Author', 'Item Types', NULL, NULL, NULL, 'If filled in, the the club will only apply to books where the title matches this field. Must be identical to the MARC field mapped to title.', 'If filled in, the the club will only apply to books where the author matches this field. Must be identical to the MARC field mapped to author.', 'Put a list of space separated Item Types here for that this club should work for. Leave it blank for all item types.', NULL, NULL, NULL, 0, NULL, '2009-09-28 10:29:01', 1),
3
(2, 'NEW_ITEMS_EMAIL_LIST', 'service', 'New Items E-mail List', 'This club archetype gives the patrons the ability join a mailing list which will e-mail weekly lists of new items for the given itemtype and callnumber combination given.', 0, 'Itemtype', 'Callnumber', NULL, NULL, NULL, NULL, 'The Itemtype to be looked up. Use % for all itemtypes.', 'The callnumber to look up. Use % as wildcard.', NULL, NULL, NULL, NULL, 0, NULL, '2009-05-17 08:57:10', 1);
4
(-)a/installer/data/mysql/en/mandatory/clubs_and_services_archetypes.txt (+2 lines)
Line 0 Link Here
1
System defined archetypes for the clubs and services feature.
2
These archetypes are required by Koha for certain functionality.
(-)a/installer/data/mysql/en/mandatory/userflags.sql (+1 lines)
Lines 15-17 INSERT INTO `userflags` VALUES(14,'editauthorities','Allow to edit authorities', Link Here
15
INSERT INTO `userflags` VALUES(15,'serials','Allow to manage serials subscriptions',0);
15
INSERT INTO `userflags` VALUES(15,'serials','Allow to manage serials subscriptions',0);
16
INSERT INTO `userflags` VALUES(16,'reports','Allow to access to the reports module',0);
16
INSERT INTO `userflags` VALUES(16,'reports','Allow to access to the reports module',0);
17
INSERT INTO `userflags` VALUES(17,'staffaccess','Modify login / permissions for staff users',0);
17
INSERT INTO `userflags` VALUES(17,'staffaccess','Modify login / permissions for staff users',0);
18
INSERT INTO `userflags` VALUES(18,'clubs_services','Access to the clubs & services module',0);
(-)a/installer/data/mysql/en/mandatory/userpermissions.sql (-1 / +4 lines)
Lines 51-55 INSERT INTO permissions (module_bit, code, description) VALUES Link Here
51
   (15, 'renew_subscription', 'Renew a subscription'),
51
   (15, 'renew_subscription', 'Renew a subscription'),
52
   (15, 'routing', 'Routing'),
52
   (15, 'routing', 'Routing'),
53
   (16, 'execute_reports', 'Execute SQL reports'),
53
   (16, 'execute_reports', 'Execute SQL reports'),
54
   (16, 'create_reports', 'Create SQL Reports')
54
   (16, 'create_reports', 'Create SQL Reports'),
55
   (18, 'create_club_service', 'Create and edit clubs and services from existing archetypes.'),
56
   (18, 'create_archetype', 'Create and edit archetype.'),
57
   (18, 'enroll_borrower', 'Enroll borrower in a club or service.')
55
;
58
;
(-)a/installer/data/mysql/es-ES/mandatory/clubs_and_services_archetypes.sql (+4 lines)
Line 0 Link Here
1
INSERT INTO `clubsAndServicesArchetypes` (`casaId`, `code`, `type`, `title`, `description`, `publicEnrollment`, `casData1Title`, `casData2Title`, `casData3Title`, `caseData1Title`, `caseData2Title`, `caseData3Title`, `casData1Desc`, `casData2Desc`, `casData3Desc`, `caseData1Desc`, `caseData2Desc`, `caseData3Desc`, `caseRequireEmail`, `branchcode`, `last_updated`, `system_defined`) VALUES
2
(1, 'BESTSELLERS_CLUB', 'club', 'Bestsellers Club', 'This club archetype gives the patrons the ability join a club for a given author and for staff to batch generate a holds list which shuffles the holds queue when specific titles or books by certain authors are received.', 0, 'Title', 'Author', 'Item Types', NULL, NULL, NULL, 'If filled in, the the club will only apply to books where the title matches this field. Must be identical to the MARC field mapped to title.', 'If filled in, the the club will only apply to books where the author matches this field. Must be identical to the MARC field mapped to author.', 'Put a list of space separated Item Types here for that this club should work for. Leave it blank for all item types.', NULL, NULL, NULL, 0, NULL, '2009-09-28 10:29:01', 1),
3
(2, 'NEW_ITEMS_EMAIL_LIST', 'service', 'New Items E-mail List', 'This club archetype gives the patrons the ability join a mailing list which will e-mail weekly lists of new items for the given itemtype and callnumber combination given.', 0, 'Itemtype', 'Callnumber', NULL, NULL, NULL, NULL, 'The Itemtype to be looked up. Use % for all itemtypes.', 'The callnumber to look up. Use % as wildcard.', NULL, NULL, NULL, NULL, 0, NULL, '2009-05-17 08:57:10', 1);
4
(-)a/installer/data/mysql/es-ES/mandatory/clubs_and_services_archetypes.txt (+2 lines)
Line 0 Link Here
1
System defined archetypes for the clubs and services feature.
2
These archetypes are required by Koha for certain functionality.
(-)a/installer/data/mysql/fr-FR/1-Obligatoire/clubs_and_services_archetypes.sql (+4 lines)
Line 0 Link Here
1
INSERT INTO `clubsAndServicesArchetypes` (`casaId`, `code`, `type`, `title`, `description`, `publicEnrollment`, `casData1Title`, `casData2Title`, `casData3Title`, `caseData1Title`, `caseData2Title`, `caseData3Title`, `casData1Desc`, `casData2Desc`, `casData3Desc`, `caseData1Desc`, `caseData2Desc`, `caseData3Desc`, `caseRequireEmail`, `branchcode`, `last_updated`, `system_defined`) VALUES
2
(1, 'BESTSELLERS_CLUB', 'club', 'Bestsellers Club', 'This club archetype gives the patrons the ability join a club for a given author and for staff to batch generate a holds list which shuffles the holds queue when specific titles or books by certain authors are received.', 0, 'Title', 'Author', 'Item Types', NULL, NULL, NULL, 'If filled in, the the club will only apply to books where the title matches this field. Must be identical to the MARC field mapped to title.', 'If filled in, the the club will only apply to books where the author matches this field. Must be identical to the MARC field mapped to author.', 'Put a list of space separated Item Types here for that this club should work for. Leave it blank for all item types.', NULL, NULL, NULL, 0, NULL, '2009-09-28 10:29:01', 1),
3
(2, 'NEW_ITEMS_EMAIL_LIST', 'service', 'New Items E-mail List', 'This club archetype gives the patrons the ability join a mailing list which will e-mail weekly lists of new items for the given itemtype and callnumber combination given.', 0, 'Itemtype', 'Callnumber', NULL, NULL, NULL, NULL, 'The Itemtype to be looked up. Use % for all itemtypes.', 'The callnumber to look up. Use % as wildcard.', NULL, NULL, NULL, NULL, 0, NULL, '2009-05-17 08:57:10', 1);
4
(-)a/installer/data/mysql/fr-FR/1-Obligatoire/clubs_and_services_archetypes.txt (+2 lines)
Line 0 Link Here
1
System defined archetypes for the clubs and services feature.
2
These archetypes are required by Koha for certain functionality.
(-)a/installer/data/mysql/it-IT/necessari/clubs_and_services_archetypes.sql (+4 lines)
Line 0 Link Here
1
INSERT INTO `clubsAndServicesArchetypes` (`casaId`, `code`, `type`, `title`, `description`, `publicEnrollment`, `casData1Title`, `casData2Title`, `casData3Title`, `caseData1Title`, `caseData2Title`, `caseData3Title`, `casData1Desc`, `casData2Desc`, `casData3Desc`, `caseData1Desc`, `caseData2Desc`, `caseData3Desc`, `caseRequireEmail`, `branchcode`, `last_updated`, `system_defined`) VALUES
2
(1, 'BESTSELLERS_CLUB', 'club', 'Bestsellers Club', 'This club archetype gives the patrons the ability join a club for a given author and for staff to batch generate a holds list which shuffles the holds queue when specific titles or books by certain authors are received.', 0, 'Title', 'Author', 'Item Types', NULL, NULL, NULL, 'If filled in, the the club will only apply to books where the title matches this field. Must be identical to the MARC field mapped to title.', 'If filled in, the the club will only apply to books where the author matches this field. Must be identical to the MARC field mapped to author.', 'Put a list of space separated Item Types here for that this club should work for. Leave it blank for all item types.', NULL, NULL, NULL, 0, NULL, '2009-09-28 10:29:01', 1),
3
(2, 'NEW_ITEMS_EMAIL_LIST', 'service', 'New Items E-mail List', 'This club archetype gives the patrons the ability join a mailing list which will e-mail weekly lists of new items for the given itemtype and callnumber combination given.', 0, 'Itemtype', 'Callnumber', NULL, NULL, NULL, NULL, 'The Itemtype to be looked up. Use % for all itemtypes.', 'The callnumber to look up. Use % as wildcard.', NULL, NULL, NULL, NULL, 0, NULL, '2009-05-17 08:57:10', 1);
4
(-)a/installer/data/mysql/it-IT/necessari/clubs_and_services_archetypes.txt (+2 lines)
Line 0 Link Here
1
System defined archetypes for the clubs and services feature.
2
These archetypes are required by Koha for certain functionality.
(-)a/installer/data/mysql/kohastructure.sql (+101 lines)
Lines 2915-2920 CREATE TABLE `quotes` ( Link Here
2915
  PRIMARY KEY (`id`)
2915
  PRIMARY KEY (`id`)
2916
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2916
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2917
2917
2918
--
2919
-- Table structure for table `clubsAndServicesArchetypes`
2920
--
2921
2922
DROP TABLE IF EXISTS `clubsAndServicesArchetypes`;
2923
CREATE TABLE `clubsAndServicesArchetypes` (
2924
  `casaId` int(11) NOT NULL AUTO_INCREMENT,
2925
  `code` varchar(64) DEFAULT NULL,
2926
  `type` enum('club','service') NOT NULL DEFAULT 'club',
2927
  `title` text NOT NULL, -- 'title of this archetype',
2928
  `description` text NOT NULL, -- 'long description of this archetype',
2929
  `publicEnrollment` tinyint(1) NOT NULL DEFAULT '0', -- 'If 1, patron should be able to enroll in club or service from OPAC, if 0, only a librarian should be able to enroll a patron in the club or service.',
2930
  `casData1Title` text, -- 'Title of contents in cas.data1',
2931
  `casData2Title` text, -- 'Title of contents in cas.data2',
2932
  `casData3Title` text, -- 'Title of contents in cas.data3',
2933
  `caseData1Title` text, -- 'Name of what is stored in cAsE.data1',
2934
  `caseData2Title` text, -- 'Name of what is stored in cAsE.data2',
2935
  `caseData3Title` text, -- 'Name of what is stored in cAsE.data3',
2936
  `casData1Desc` text,
2937
  `casData2Desc` text,
2938
  `casData3Desc` text,
2939
  `caseData1Desc` text,
2940
  `caseData2Desc` text,
2941
  `caseData3Desc` text,
2942
  `caseRequireEmail` tinyint(1) NOT NULL DEFAULT '0',
2943
  `branchcode` varchar(4) DEFAULT NULL, -- 'branch where archetype was created.',
2944
  `last_updated` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
2945
  `system_defined` tinyint(1) NOT NULL DEFAULT '0', -- 'if true, archetype comes as part of koha. These archetypes have associated scripts such that modifying the archetype would break the script.',
2946
  PRIMARY KEY (`casaId`),
2947
  KEY `branchcode` (`branchcode`)
2948
) ENGINE=InnoDB  DEFAULT CHARSET=utf8;
2949
2950
--
2951
-- Constraints for table `clubsAndServicesArchetypes`
2952
--
2953
ALTER TABLE `clubsAndServicesArchetypes`
2954
  ADD CONSTRAINT `clubsAndServicesArchetypes_ibfk_1` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE;
2955
2956
--
2957
-- Table structure for table `clubsAndServices`
2958
--
2959
2960
DROP TABLE IF EXISTS `clubsAndServices`;
2961
CREATE TABLE `clubsAndServices` (
2962
  `casId` int(11) NOT NULL AUTO_INCREMENT,
2963
  `casaId` int(11) NOT NULL DEFAULT '0', -- 'foreign key to clubsAndServicesArchetypes',
2964
  `title` text NOT NULL,
2965
  `description` text,
2966
  `casData1` text, -- 'Data described in casa.casData1Title',
2967
  `casData2` text, -- 'Data described in casa.casData2Title',
2968
  `casData3` text, -- 'Data described in casa.casData3Title',
2969
  `startDate` date NOT NULL DEFAULT '0000-00-00',
2970
  `endDate` date DEFAULT NULL,
2971
  `branchcode` varchar(4) NOT NULL, -- 'branch where club or service was created.',
2972
  `last_updated` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
2973
  PRIMARY KEY (`casId`),
2974
  KEY `casaId` (`casaId`),
2975
  KEY `branchcode` (`branchcode`)
2976
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2977
2978
--
2979
-- Constraints for table `clubsAndServices`
2980
--
2981
ALTER TABLE `clubsAndServices`
2982
  ADD CONSTRAINT `clubsAndServices_ibfk_2` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE,
2983
  ADD CONSTRAINT `clubsAndServices_ibfk_1` FOREIGN KEY (`casaId`) REFERENCES `clubsAndServicesArchetypes` (`casaId`) ON DELETE CASCADE ON UPDATE CASCADE;
2984
2985
--
2986
-- Table structure for table `clubsAndServicesEnrollments`
2987
--
2988
2989
DROP TABLE IF EXISTS `clubsAndServicesEnrollments`;
2990
CREATE TABLE `clubsAndServicesEnrollments` (
2991
  `caseId` int(11) NOT NULL AUTO_INCREMENT,
2992
  `casaId` int(11) NOT NULL DEFAULT '0', -- 'foreign key to clubsAndServicesArchtypes',
2993
  `casId` int(11) NOT NULL DEFAULT '0', -- 'foreign key to clubsAndServices',
2994
  `borrowernumber` int(11) NOT NULL DEFAULT '0', -- 'foreign key to borrowers',
2995
  `data1` text, -- 'data described in casa.data1description',
2996
  `data2` text,
2997
  `data3` text,
2998
  `dateEnrolled` date NOT NULL DEFAULT '0000-00-00', -- 'date borrowers service begins',
2999
  `dateCanceled` date DEFAULT NULL, -- 'date borrower decided to end service',
3000
  `last_updated` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
3001
  `branchcode` varchar(4) DEFAULT NULL, -- 'foreign key to branches',
3002
  PRIMARY KEY (`caseId`),
3003
  KEY `casaId` (`casaId`),
3004
  KEY `casId` (`casId`),
3005
  KEY `borrowernumber` (`borrowernumber`),
3006
  KEY `branchcode` (`branchcode`)
3007
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
3008
3009
--
3010
-- Constraints for table `clubsAndServicesEnrollments`
3011
--
3012
ALTER TABLE `clubsAndServicesEnrollments`
3013
  ADD CONSTRAINT `clubsAndServicesEnrollments_ibfk_4` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE,
3014
  ADD CONSTRAINT `clubsAndServicesEnrollments_ibfk_1` FOREIGN KEY (`casaId`) REFERENCES `clubsAndServicesArchetypes` (`casaId`) ON DELETE CASCADE ON UPDATE CASCADE,
3015
  ADD CONSTRAINT `clubsAndServicesEnrollments_ibfk_2` FOREIGN KEY (`casId`) REFERENCES `clubsAndServices` (`casId`) ON DELETE CASCADE ON UPDATE CASCADE,
3016
  ADD CONSTRAINT `clubsAndServicesEnrollments_ibfk_3` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE;
3017
3018
2918
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
3019
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
2919
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
3020
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
2920
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
3021
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
(-)a/installer/data/mysql/nb-NO/1-Obligatorisk/clubs_and_services_archetypes.sql (+4 lines)
Line 0 Link Here
1
INSERT INTO `clubsAndServicesArchetypes` (`casaId`, `code`, `type`, `title`, `description`, `publicEnrollment`, `casData1Title`, `casData2Title`, `casData3Title`, `caseData1Title`, `caseData2Title`, `caseData3Title`, `casData1Desc`, `casData2Desc`, `casData3Desc`, `caseData1Desc`, `caseData2Desc`, `caseData3Desc`, `caseRequireEmail`, `branchcode`, `last_updated`, `system_defined`) VALUES
2
(1, 'BESTSELLERS_CLUB', 'club', 'Bestsellers Club', 'This club archetype gives the patrons the ability join a club for a given author and for staff to batch generate a holds list which shuffles the holds queue when specific titles or books by certain authors are received.', 0, 'Title', 'Author', 'Item Types', NULL, NULL, NULL, 'If filled in, the the club will only apply to books where the title matches this field. Must be identical to the MARC field mapped to title.', 'If filled in, the the club will only apply to books where the author matches this field. Must be identical to the MARC field mapped to author.', 'Put a list of space separated Item Types here for that this club should work for. Leave it blank for all item types.', NULL, NULL, NULL, 0, NULL, '2009-09-28 10:29:01', 1),
3
(2, 'NEW_ITEMS_EMAIL_LIST', 'service', 'New Items E-mail List', 'This club archetype gives the patrons the ability join a mailing list which will e-mail weekly lists of new items for the given itemtype and callnumber combination given.', 0, 'Itemtype', 'Callnumber', NULL, NULL, NULL, NULL, 'The Itemtype to be looked up. Use % for all itemtypes.', 'The callnumber to look up. Use % as wildcard.', NULL, NULL, NULL, NULL, 0, NULL, '2009-05-17 08:57:10', 1);
4
(-)a/installer/data/mysql/nb-NO/1-Obligatorisk/clubs_and_services_archetypes.txt (+2 lines)
Line 0 Link Here
1
System defined archetypes for the clubs and services feature.
2
These archetypes are required by Koha for certain functionality.
(-)a/installer/data/mysql/pl-PL/mandatory/clubs_and_services_archetypes.sql (+4 lines)
Line 0 Link Here
1
INSERT INTO `clubsAndServicesArchetypes` (`casaId`, `code`, `type`, `title`, `description`, `publicEnrollment`, `casData1Title`, `casData2Title`, `casData3Title`, `caseData1Title`, `caseData2Title`, `caseData3Title`, `casData1Desc`, `casData2Desc`, `casData3Desc`, `caseData1Desc`, `caseData2Desc`, `caseData3Desc`, `caseRequireEmail`, `branchcode`, `last_updated`, `system_defined`) VALUES
2
(1, 'BESTSELLERS_CLUB', 'club', 'Bestsellers Club', 'This club archetype gives the patrons the ability join a club for a given author and for staff to batch generate a holds list which shuffles the holds queue when specific titles or books by certain authors are received.', 0, 'Title', 'Author', 'Item Types', NULL, NULL, NULL, 'If filled in, the the club will only apply to books where the title matches this field. Must be identical to the MARC field mapped to title.', 'If filled in, the the club will only apply to books where the author matches this field. Must be identical to the MARC field mapped to author.', 'Put a list of space separated Item Types here for that this club should work for. Leave it blank for all item types.', NULL, NULL, NULL, 0, NULL, '2009-09-28 10:29:01', 1),
3
(2, 'NEW_ITEMS_EMAIL_LIST', 'service', 'New Items E-mail List', 'This club archetype gives the patrons the ability join a mailing list which will e-mail weekly lists of new items for the given itemtype and callnumber combination given.', 0, 'Itemtype', 'Callnumber', NULL, NULL, NULL, NULL, 'The Itemtype to be looked up. Use % for all itemtypes.', 'The callnumber to look up. Use % as wildcard.', NULL, NULL, NULL, NULL, 0, NULL, '2009-05-17 08:57:10', 1);
4
(-)a/installer/data/mysql/pl-PL/mandatory/clubs_and_services_archetypes.txt (+2 lines)
Line 0 Link Here
1
System defined archetypes for the clubs and services feature.
2
These archetypes are required by Koha for certain functionality.
(-)a/installer/data/mysql/ru-RU/mandatory/clubs_and_services_archetypes.sql (+4 lines)
Line 0 Link Here
1
INSERT INTO `clubsAndServicesArchetypes` (`casaId`, `code`, `type`, `title`, `description`, `publicEnrollment`, `casData1Title`, `casData2Title`, `casData3Title`, `caseData1Title`, `caseData2Title`, `caseData3Title`, `casData1Desc`, `casData2Desc`, `casData3Desc`, `caseData1Desc`, `caseData2Desc`, `caseData3Desc`, `caseRequireEmail`, `branchcode`, `last_updated`, `system_defined`) VALUES
2
(1, 'BESTSELLERS_CLUB', 'club', 'Bestsellers Club', 'This club archetype gives the patrons the ability join a club for a given author and for staff to batch generate a holds list which shuffles the holds queue when specific titles or books by certain authors are received.', 0, 'Title', 'Author', 'Item Types', NULL, NULL, NULL, 'If filled in, the the club will only apply to books where the title matches this field. Must be identical to the MARC field mapped to title.', 'If filled in, the the club will only apply to books where the author matches this field. Must be identical to the MARC field mapped to author.', 'Put a list of space separated Item Types here for that this club should work for. Leave it blank for all item types.', NULL, NULL, NULL, 0, NULL, '2009-09-28 10:29:01', 1),
3
(2, 'NEW_ITEMS_EMAIL_LIST', 'service', 'New Items E-mail List', 'This club archetype gives the patrons the ability join a mailing list which will e-mail weekly lists of new items for the given itemtype and callnumber combination given.', 0, 'Itemtype', 'Callnumber', NULL, NULL, NULL, NULL, 'The Itemtype to be looked up. Use % for all itemtypes.', 'The callnumber to look up. Use % as wildcard.', NULL, NULL, NULL, NULL, 0, NULL, '2009-05-17 08:57:10', 1);
4
(-)a/installer/data/mysql/ru-RU/mandatory/clubs_and_services_archetypes.txt (+2 lines)
Line 0 Link Here
1
System defined archetypes for the clubs and services feature.
2
These archetypes are required by Koha for certain functionality.
(-)a/installer/data/mysql/uk-UA/mandatory/clubs_and_services_archetypes.sql (+4 lines)
Line 0 Link Here
1
INSERT INTO `clubsAndServicesArchetypes` (`casaId`, `code`, `type`, `title`, `description`, `publicEnrollment`, `casData1Title`, `casData2Title`, `casData3Title`, `caseData1Title`, `caseData2Title`, `caseData3Title`, `casData1Desc`, `casData2Desc`, `casData3Desc`, `caseData1Desc`, `caseData2Desc`, `caseData3Desc`, `caseRequireEmail`, `branchcode`, `last_updated`, `system_defined`) VALUES
2
(1, 'BESTSELLERS_CLUB', 'club', 'Bestsellers Club', 'This club archetype gives the patrons the ability join a club for a given author and for staff to batch generate a holds list which shuffles the holds queue when specific titles or books by certain authors are received.', 0, 'Title', 'Author', 'Item Types', NULL, NULL, NULL, 'If filled in, the the club will only apply to books where the title matches this field. Must be identical to the MARC field mapped to title.', 'If filled in, the the club will only apply to books where the author matches this field. Must be identical to the MARC field mapped to author.', 'Put a list of space separated Item Types here for that this club should work for. Leave it blank for all item types.', NULL, NULL, NULL, 0, NULL, '2009-09-28 10:29:01', 1),
3
(2, 'NEW_ITEMS_EMAIL_LIST', 'service', 'New Items E-mail List', 'This club archetype gives the patrons the ability join a mailing list which will e-mail weekly lists of new items for the given itemtype and callnumber combination given.', 0, 'Itemtype', 'Callnumber', NULL, NULL, NULL, NULL, 'The Itemtype to be looked up. Use % for all itemtypes.', 'The callnumber to look up. Use % as wildcard.', NULL, NULL, NULL, NULL, 0, NULL, '2009-05-17 08:57:10', 1);
4
(-)a/installer/data/mysql/uk-UA/mandatory/clubs_and_services_archetypes.txt (+2 lines)
Line 0 Link Here
1
System defined archetypes for the clubs and services feature.
2
These archetypes are required by Koha for certain functionality.
(-)a/installer/data/mysql/updatedatabase.pl (+106 lines)
Lines 5928-5933 if (C4::Context->preference("Version") < TransformToNum($DBversion)) { Link Here
5928
}
5928
}
5929
5929
5930
5930
5931
$DBversion = "3.09.00.XXX";
5932
if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
5933
5934
    $dbh->do("
5935
CREATE TABLE `clubsAndServicesArchetypes` (
5936
  `casaId` int(11) NOT NULL AUTO_INCREMENT,
5937
  `code` varchar(64) DEFAULT NULL,
5938
  `type` enum('club','service') NOT NULL DEFAULT 'club',
5939
  `title` text NOT NULL COMMENT 'title of this archetype',
5940
  `description` text NOT NULL COMMENT 'long description of this archetype',
5941
  `publicEnrollment` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'If 1, patron should be able to enroll in club or service from OPAC, if 0, only a librarian should be able to enroll a patron in the club or service.',
5942
  `casData1Title` text COMMENT 'Title of contents in cas.data1',
5943
  `casData2Title` text COMMENT 'Title of contents in cas.data2',
5944
  `casData3Title` text COMMENT 'Title of contents in cas.data3',
5945
  `caseData1Title` text COMMENT 'Name of what is stored in cAsE.data1',
5946
  `caseData2Title` text COMMENT 'Name of what is stored in cAsE.data2',
5947
  `caseData3Title` text COMMENT 'Name of what is stored in cAsE.data3',
5948
  `casData1Desc` text,
5949
  `casData2Desc` text,
5950
  `casData3Desc` text,
5951
  `caseData1Desc` text,
5952
  `caseData2Desc` text,
5953
  `caseData3Desc` text,
5954
  `caseRequireEmail` tinyint(1) NOT NULL DEFAULT '0',
5955
  `branchcode` varchar(4) DEFAULT NULL COMMENT 'branch where archetype was created.',
5956
  `last_updated` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
5957
  `system_defined` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'if true, archetype comes as part of koha. These archetypes have associated scripts such that modifying the archetype would break the script.',
5958
  PRIMARY KEY (`casaId`),
5959
  KEY `branchcode` (`branchcode`)
5960
) ENGINE=InnoDB  DEFAULT CHARSET=utf8;
5961
"):
5962
5963
    $dbh->do("
5964
INSERT INTO `clubsAndServicesArchetypes` (`casaId`, `code`, `type`, `title`, `description`, `publicEnrollment`, `casData1Title`, `casData2Title`, `casData3Title`, `caseData1Title`, `caseData2Title`, `caseData3Title`, `casData1Desc`, `casData2Desc`, `casData3Desc`, `caseData1Desc`, `caseData2Desc`, `caseData3Desc`, `caseRequireEmail`, `branchcode`, `last_updated`, `system_defined`) VALUES
5965
(1, 'BESTSELLERS_CLUB', 'club', 'Bestsellers Club', 'This club archetype gives the patrons the ability join a club for a given author and for staff to batch generate a holds list which shuffles the holds queue when specific titles or books by certain authors are received.', 0, 'Title', 'Author', 'Item Types', NULL, NULL, NULL, 'If filled in, the the club will only apply to books where the title matches this field. Must be identical to the MARC field mapped to title.', 'If filled in, the the club will only apply to books where the author matches this field. Must be identical to the MARC field mapped to author.', 'Put a list of space separated Item Types here for that this club should work for. Leave it blank for all item types.', NULL, NULL, NULL, 0, NULL, '2009-09-28 10:29:01', 1),
5966
(2, 'NEW_ITEMS_EMAIL_LIST', 'service', 'New Items E-mail List', 'This club archetype gives the patrons the ability join a mailing list which will e-mail weekly lists of new items for the given itemtype and callnumber combination given.', 0, 'Itemtype', 'Callnumber', NULL, NULL, NULL, NULL, 'The Itemtype to be looked up. Use % for all itemtypes.', 'The callnumber to look up. Use % as wildcard.', NULL, NULL, NULL, NULL, 0, NULL, '2009-05-17 08:57:10', 1);
5967
");
5968
5969
    $dbh->do("
5970
ALTER TABLE `clubsAndServicesArchetypes`
5971
  ADD CONSTRAINT `clubsAndServicesArchetypes_ibfk_1` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE;
5972
");
5973
5974
    $dbh->do("
5975
CREATE TABLE `clubsAndServices` (
5976
  `casId` int(11) NOT NULL AUTO_INCREMENT,
5977
  `casaId` int(11) NOT NULL DEFAULT '0' COMMENT 'foreign key to clubsAndServicesArchetypes',
5978
  `title` text NOT NULL,
5979
  `description` text,
5980
  `casData1` text COMMENT 'Data described in casa.casData1Title',
5981
  `casData2` text COMMENT 'Data described in casa.casData2Title',
5982
  `casData3` text COMMENT 'Data described in casa.casData3Title',
5983
  `startDate` date NOT NULL DEFAULT '0000-00-00',
5984
  `endDate` date DEFAULT NULL,
5985
  `branchcode` varchar(4) NOT NULL COMMENT 'branch where club or service was created.',
5986
  `last_updated` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
5987
  PRIMARY KEY (`casId`),
5988
  KEY `casaId` (`casaId`),
5989
  KEY `branchcode` (`branchcode`)
5990
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
5991
");
5992
5993
    $dbh->do("
5994
ALTER TABLE `clubsAndServices`
5995
  ADD CONSTRAINT `clubsAndServices_ibfk_2` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE,
5996
  ADD CONSTRAINT `clubsAndServices_ibfk_1` FOREIGN KEY (`casaId`) REFERENCES `clubsAndServicesArchetypes` (`casaId`) ON DELETE CASCADE ON UPDATE CASCADE;
5997
");
5998
5999
    $dbh->do("
6000
CREATE TABLE `clubsAndServicesEnrollments` (
6001
  `caseId` int(11) NOT NULL AUTO_INCREMENT,
6002
  `casaId` int(11) NOT NULL DEFAULT '0' COMMENT 'foreign key to clubsAndServicesArchtypes',
6003
  `casId` int(11) NOT NULL DEFAULT '0' COMMENT 'foreign key to clubsAndServices',
6004
  `borrowernumber` int(11) NOT NULL DEFAULT '0' COMMENT 'foreign key to borrowers',
6005
  `data1` text COMMENT 'data described in casa.data1description',
6006
  `data2` text,
6007
  `data3` text,
6008
  `dateEnrolled` date NOT NULL DEFAULT '0000-00-00' COMMENT 'date borrowers service begins',
6009
  `dateCanceled` date DEFAULT NULL COMMENT 'date borrower decided to end service',
6010
  `last_updated` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
6011
  `branchcode` varchar(4) DEFAULT NULL COMMENT 'foreign key to branches',
6012
  PRIMARY KEY (`caseId`),
6013
  KEY `casaId` (`casaId`),
6014
  KEY `casId` (`casId`),
6015
  KEY `borrowernumber` (`borrowernumber`),
6016
  KEY `branchcode` (`branchcode`)
6017
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
6018
");
6019
6020
    $dbh->do("
6021
ALTER TABLE `clubsAndServicesEnrollments`
6022
  ADD CONSTRAINT `clubsAndServicesEnrollments_ibfk_4` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE,
6023
  ADD CONSTRAINT `clubsAndServicesEnrollments_ibfk_1` FOREIGN KEY (`casaId`) REFERENCES `clubsAndServicesArchetypes` (`casaId`) ON DELETE CASCADE ON UPDATE CASCADE,
6024
  ADD CONSTRAINT `clubsAndServicesEnrollments_ibfk_2` FOREIGN KEY (`casId`) REFERENCES `clubsAndServices` (`casId`) ON DELETE CASCADE ON UPDATE CASCADE,
6025
  ADD CONSTRAINT `clubsAndServicesEnrollments_ibfk_3` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE;
6026
");
6027
6028
    $dbh->do("INSERT INTO userflags ( bit, flag, flagdesc, defaulton ) VALUES ('19',  'clubs_services',  'Access to the clubs & services module',  '0' )");
6029
    $dbh->do("INSERT INTO permissions ( module_bit, code, description ) VALUES ( '19',  'create_club_service',  'Create and edit clubs and services from existing archetypes.' )");
6030
    $dbh->do("INSERT INTO permissions ( module_bit, code, description ) VALUES ( '19', 'create_archetype', 'Create and edit archetype' ) ");
6031
    $dbh->do("INSERT INTO permissions ( module_bit, code, description ) VALUES ( '19', 'enroll_borrower', 'Enroll borrower in a club or service.' )");
6032
6033
    print "Upgrade to $DBversion done ( Added Clubs & Services )\n";
6034
    SetVersion($DBversion);
6035
}
6036
5931
=head1 FUNCTIONS
6037
=head1 FUNCTIONS
5932
6038
5933
=head2 TableExists($table)
6039
=head2 TableExists($table)
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/circ-menu.inc (+1 lines)
Lines 76-81 Link Here
76
    [% IF ( CAN_user_parameters ) %]
76
    [% IF ( CAN_user_parameters ) %]
77
        [% IF ( logview ) %]<li class="active">[% ELSE %]<li>[% END %]<a href="/cgi-bin/koha/tools/viewlog.pl?do_it=1&amp;modules=MEMBERS&amp;modules=circulation&amp;object=[% borrowernumber %]&amp;src=circ">Modification log</a></li>
77
        [% IF ( logview ) %]<li class="active">[% ELSE %]<li>[% END %]<a href="/cgi-bin/koha/tools/viewlog.pl?do_it=1&amp;modules=MEMBERS&amp;modules=circulation&amp;object=[% borrowernumber %]&amp;src=circ">Modification log</a></li>
78
    [% END %]
78
    [% END %]
79
    [% IF ( clubs_services ) %]<li class="active">[% ELSE %]<li>[% END %]<a href="/cgi-bin/koha/members/clubs_services.pl?borrowernumber=[% borrowernumber %]">Clubs &amp; Services</a></li>
79
    [% IF ( EnhancedMessagingPreferences ) %]
80
    [% IF ( EnhancedMessagingPreferences ) %]
80
	[% IF ( sentnotices ) %]<li class="active">[% ELSE %]<li>[% END %]<a href="/cgi-bin/koha/members/notices.pl?borrowernumber=[% borrowernumber %]">Notices</a></li>
81
	[% IF ( sentnotices ) %]<li class="active">[% ELSE %]<li>[% END %]<a href="/cgi-bin/koha/members/notices.pl?borrowernumber=[% borrowernumber %]">Notices</a></li>
81
    [% END %]
82
    [% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/members-menu.inc (+1 lines)
Lines 15-20 Link Here
15
    [% IF ( EnhancedMessagingPreferences ) %]
15
    [% IF ( EnhancedMessagingPreferences ) %]
16
	[% IF ( sentnotices ) %]<li class="active">[% ELSE %]<li>[% END %]<a href="/cgi-bin/koha/members/notices.pl?borrowernumber=[% borrowernumber %]">Notices</a></li>
16
	[% IF ( sentnotices ) %]<li class="active">[% ELSE %]<li>[% END %]<a href="/cgi-bin/koha/members/notices.pl?borrowernumber=[% borrowernumber %]">Notices</a></li>
17
    [% END %]
17
    [% END %]
18
    [% IF clubs_services %]<li class="active">[% ELSE %]<li>[% END %]<a href="/cgi-bin/koha/members/clubs_services.pl?borrowernumber=[% borrowernumber %]" -->">Clubs &amp; Services</a></li>
18
    [% IF (  statisticsview ) %]<li class="active">[% ELSE %]<li>[% END %]<a href="/cgi-bin/koha/members/statistics.pl?borrowernumber=[% borrowernumber %]">Statistics</a></li>
19
    [% IF (  statisticsview ) %]<li class="active">[% ELSE %]<li>[% END %]<a href="/cgi-bin/koha/members/statistics.pl?borrowernumber=[% borrowernumber %]">Statistics</a></li>
19
    [% IF EnableBorrowerFiles %]
20
    [% IF EnableBorrowerFiles %]
20
        [% IF ( borrower_files ) %]<li class="active">[% ELSE %]<li>[% END %]<a href="/cgi-bin/koha/members/files.pl?borrowernumber=[% borrowernumber %]">Files</a></li>
21
        [% IF ( borrower_files ) %]<li class="active">[% ELSE %]<li>[% END %]<a href="/cgi-bin/koha/members/files.pl?borrowernumber=[% borrowernumber %]">Files</a></li>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt (-1 / +8 lines)
Lines 730-736 No patron matched <span class="ex">[% message %]</span> Link Here
730
	
730
	
731
     <!-- /If flagged -->[% END %]
731
     <!-- /If flagged -->[% END %]
732
732
733
	
733
        [% IF ( ClubsAndServicesLoop ) %]
734
                <h4>Clubs & Services</h4>
735
                <ul>
736
                        [% FOREACH ClubOrService IN ClubsAndServicesLoop %]
737
                                <li><a href="/cgi-bin/koha/members/clubs_services.pl?borrowernumber=[% borrowernumber %]">[% ClubOrService.title %]</a></li>
738
                        [% END %]
739
                </ul>
740
        [% END %]
734
741
735
</div>
742
</div>
736
</div>
743
</div>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/clubs_services/clubs_services.tt (+93 lines)
Line 0 Link Here
1
[% INCLUDE 'doc-head-open.inc' %]
2
<title>Koha &rsaquo; Tools &rsaquo; Clubs &amp; services</title>
3
[% INCLUDE 'doc-head-close.inc' %]
4
</head>
5
<body>
6
[% INCLUDE 'header.inc' %]
7
8
<div id="breadcrumbs">
9
  <a href="/cgi-bin/koha/mainpage.pl">Home</a>
10
  &rsaquo; <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a>
11
  &rsaquo; Clubs &amp; services
12
</div>
13
14
<div id="doc3" class="yui-t2">
15
   <div id="bd">
16
        <div id="yui-main">
17
        <div class="yui-b">
18
19
          <table>
20
            <tr>
21
		<th colspan="6">Clubs</th>
22
	   </tr>
23
24
            <tr>
25
              <th>Title</th>
26
              <th>Description</th>
27
              <th>Start date</th>
28
              <th>End date</th>
29
              <th>&nbsp;</th>
30
	      <th>&nbsp;</th>
31
            </tr>
32
33
        [% IF ( clubsLoop ) %]
34
            [% FOREACH clubsLoo IN clubsLoop %]
35
              <tr>
36
                <td>[% clubsLoo.title %]</td>
37
                <td>[% clubsLoo.description %]</td>
38
                <td>[% clubsLoo.startDate %]</td>
39
                <td>[% clubsLoo.endDate %]</td>
40
                <td><a href="enroll_clubs_services.pl?casId=[% clubsLoo.casId %]">Enroll</a></td>
41
                <td><a href="clubs_services_enrollments.pl?casId=[% clubsLoo.casId %]">Details</a></td>
42
              </tr>
43
            [% END %]
44
        [% ELSE %]
45
          <tr><td colspan="5">There are no clubs currently defined.</td></tr>
46
        [% END %]
47
48
            <tr><td colspan="6">&nbsp;</td></tr>
49
50
            <tr>
51
                <th colspan="6">Services</th>
52
            </tr>
53
54
            <tr>
55
              <th>Title</th>
56
              <th>Description</th>
57
              <th>Start date</th>
58
              <th>End date</th>
59
              <th>&nbsp;</th>
60
	      <th>&nbsp;</th>
61
            </tr>
62
        [% IF ( servicesLoop ) %]
63
            [% FOREACH servicesLoo IN servicesLoop %]
64
              <tr>
65
                <td>[% servicesLoo.title %]</td>
66
                <td>[% servicesLoo.description %]</td>
67
                <td>[% servicesLoo.startDate %]</td>
68
                <td>[% servicesLoo.endDate %]</td>
69
                <td><a href="enroll_clubs_services.pl?casId=[% servicesLoo.casId %]">Enroll</a></td>
70
                <td><a href="clubs_services_enrollments.pl?casId=[% servicesLoo.casId %]">Details</a></td>
71
              </tr>
72
            [% END %]
73
        [% ELSE %]
74
          <tr><td colspan="6">There are no services currently defined.</td></tr>
75
        [% END %]
76
        </table>
77
</div>
78
</div>
79
80
<div class="yui-b">
81
<div id="menu">
82
  <ul>
83
    [% IF ( clubs_services ) %]<li class="active">[% ELSE %]<li>[% END %]<a href="clubs_services.pl">Clubs &amp; services home</a></li>
84
    [% IF ( edit_archetypes ) %]<li class="active">[% ELSE %]<li>[% END %]<a href="edit_archetypes.pl">Edit archetypes</a></li>
85
    [% IF ( edit_clubs_services ) %]<li class="active">[% ELSE %]<li>[% END %]<a href="edit_clubs_services.pl">Edit clubs & services</a></li>
86
  </ul>
87
</div>
88
</div>
89
90
</div>
91
</div>
92
93
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/clubs_services/clubs_services_enrollments.tt (+67 lines)
Line 0 Link Here
1
[% INCLUDE 'doc-head-open.inc' %]
2
<title>Koha &rsaquo; Tools &rsaquo; Clubs &amp services</title>
3
[% INCLUDE 'doc-head-close.inc' %]
4
</head>
5
<body>
6
[% INCLUDE 'header.inc' %]
7
8
<div id="breadcrumbs">
9
  <a href="/cgi-bin/koha/mainpage.pl">Home</a>
10
  &rsaquo; <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a>
11
  &rsaquo; <a href="/cgi-bin/koha/clubs_services/clubs_services.pl">Clubs &amp; Services</a>
12
  &rsaquo; Details
13
</div>
14
15
<div id="doc3" class="yui-t2">
16
   <div id="bd">
17
        <div id="yui-main">
18
        <div class="yui-b">
19
20
	<h2>Details for [% casTitle %]</h2>
21
          <table>
22
	    <tr>
23
		<th colspan="4">Enrollments</td>
24
	    </tr>
25
            <tr>
26
              <th>Name</th>
27
	      <th>&nbsp;</th>
28
              <th>Borrower<br/>details</th>
29
	      <th>Cancel<br/>Enrollment</th>
30
            </tr>
31
32
        [% IF ( enrollments_loop ) %]
33
            [% FOREACH enrollments_loo IN enrollments_loop %]
34
              <tr>
35
                <td>[% enrollments_loo.surname %], [% enrollments_loo.firstname %]</td>
36
		<td>&nbsp</td>
37
		<td><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% enrollments_loo.borrowernumber %]">Details</a></td>
38
		<td>
39
                  <a
40
                     href="/cgi-bin/koha/members/clubs_services.pl?action=cancel&caseId=[% enrollments_loo.caseId %]&borrowernumber=[% enrollments_loo.borrowernumber %]"
41
		     target="new"
42
                  >
43
			Cancel enrollment
44
		  </a>
45
              </tr>
46
            [% END %]
47
        [% ELSE %]
48
          <tr><td colspan="6">There are borrowers currently enrolled.</td></tr>
49
        [% END %]
50
        </table>
51
</div>
52
</div>
53
54
<div class="yui-b">
55
<div id="menu">
56
  <ul>
57
    [% IF ( clubs_services ) %]<li class="active">[% ELSE %]<li>[% END %]<a href="clubs_services.pl">Clubs &amp; Services Home</a></li>
58
    [% IF ( edit_archetypes ) %]<li class="active">[% ELSE %]<li>[% END %]<a href="edit_archetypes.pl">Edit archetypes</a></li>
59
    [% IF ( edit_clubs_services ) %]<li class="active">[% ELSE %]<li>[% END %]<a href="edit_clubs_services.pl">Edit clubs & services</a></li>
60
  </ul>
61
</div>
62
</div>
63
64
</div>
65
</div>
66
67
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/clubs_services/edit_archetypes.tt (+270 lines)
Line 0 Link Here
1
[% INCLUDE 'doc-head-open.inc' %]
2
<title>Koha &rsaquo; Tools &rsaquo; Clubs &amp; services &rsaquo; Edit archetypes</title>
3
[% INCLUDE 'doc-head-close.inc' %]
4
5
<script type="text/javascript" language="javascript">
6
//<![CDATA[
7
function validateForm()
8
{
9
  var title = document.forms["archetype_form"]["title"].value;
10
  if ( title == null || title == "") {
11
    alert(_("Title is a required field"));
12
    return false;
13
  }
14
15
  var description = document.forms["archetype_form"]["description"].value;
16
  if ( description == null || description == "") {
17
    alert(_("Description is a required field"));
18
    return false;
19
  }
20
}
21
//]]>
22
</script>
23
24
</head>
25
<body>
26
[% INCLUDE 'header.inc' %]
27
28
<div id="breadcrumbs">
29
  <a href="/cgi-bin/koha/mainpage.pl">Home</a>
30
  &rsaquo; <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a>
31
  &rsaquo; <a href="/cgi-bin/koha/clubs_services/clubs_services.pl">Clubs &amp; services</a>
32
  &rsaquo; Edit archetypes
33
</div>
34
35
<div id="doc3" class="yui-t2">
36
   <div id="bd">
37
        <div id="yui-main">
38
     <div class="yui-b">
39
40
      <!-- LIST ALL ARCHETYPES -->
41
          <table>
42
            <tr><th colspan="99">Club archetypes</th></tr>
43
            <tr>
44
              <th>Owner</strong</td>
45
              <th>Title</th>
46
              <th>Description</th>
47
              <th>Public enrollment</th>
48
	      <th>Require email</th>
49
	      <th>Club data 1 title</th>
50
	      <th>Club data 2 title</th>
51
              <th>Club data 3 title</th>
52
	      <th>Enrollment data 1 title</th>
53
	      <th>Enrollment data 2 title</th>
54
              <th>Enrollment data 3 title</th>
55
	      <th>&nbsp;</th>
56
              <th>&nbsp;</th>
57
            </tr>
58
59
        [% IF ( clubArchetypesLoop ) %]
60
            [% FOREACH clubArchetypesLoo IN clubArchetypesLoop %]
61
              <tr>
62
                <td>[% clubArchetypesLoo.branchcode %]</td>
63
                <td>[% clubArchetypesLoo.title %]</td>
64
                <td>[% clubArchetypesLoo.description %]</td>
65
                <td>[% IF clubArchetypesLoo.publicEnrollment %]&#10004;[% END %]</td>
66
                <td>[% IF clubArchetypesLoo.caseRequireEmail %]&#10004;[% END %]</td>
67
                <td>[% clubArchetypesLoo.casData1Title %]</td>
68
                <td>[% clubArchetypesLoo.casData2Title %]</td>
69
                <td>[% clubArchetypesLoo.casData3Title %]</td>
70
                <td>[% clubArchetypesLoo.caseData1Title %]</td>
71
                <td>[% clubArchetypesLoo.caseData2Title %]</td>
72
                <td>[% clubArchetypesLoo.caseData3Title %]</td>
73
                <td>[% UNLESS ( clubArchetypesLoo.system_defined ) %]<a href="edit_archetypes.pl?action=edit&casaId=[% clubArchetypesLoo.casaId %]">Edit</a>[% END %]</td>
74
                <td>[% UNLESS ( clubArchetypesLoo.system_defined ) %]<a href="edit_archetypes.pl?action=delete&casaId=[% clubArchetypesLoo.casaId %]">Delete</a>[% END %]</td>
75
              </tr>
76
            [% END %]
77
        [% ELSE %]
78
            <tr><td colspan="99">There are no club archetypes currently defined.</td></tr>
79
        [% END %]
80
81
            <tr><td colspan="99">&nbsp;</td></tr>
82
83
            <tr><th colspan="99">Service archetypes</th></tr>
84
            <tr>
85
              <th>Owner</strong</td>
86
              <th>Title</th>
87
              <th>Description</th>
88
              <th>Public enrollment</th>
89
	      <th>Require email</th>
90
	      <th>Service data 1 title</th>
91
	      <th>Service data 2 title</th>
92
              <th>Service data 3 title</th>
93
	      <th>Enrollment data 1 title</th>
94
	      <th>Enrollment data 2 title</th>
95
              <th>Enrollment data 3 title</th>
96
	      <th>&nbsp;</th>
97
              <th>&nbsp;</th>
98
            </tr>
99
100
        [% IF ( serviceArchetypesLoop ) %]
101
            [% FOREACH serviceArchetypesLoo IN serviceArchetypesLoop %]
102
              <tr>
103
                <td>[% serviceArchetypesLoo.branchcode %]</td>
104
                <td>[% serviceArchetypesLoo.title %]</td>
105
                <td>[% serviceArchetypesLoo.description %]</td>
106
                <td>[% IF serviceArchetypesLoo.publicEnrollment %]&#10004;[% END %]</td>
107
                <td>[% IF serviceArchetypesLoo.caseRequireEmail %]&#10004;[% END %]</td>
108
                <td>[% serviceArchetypesLoo.casData1Title %]</td>
109
                <td>[% serviceArchetypesLoo.casData2Title %]</td>
110
                <td>[% serviceArchetypesLoo.casData3Title %]</td>
111
                <td>[% serviceArchetypesLoo.caseData1Title %]</td>
112
                <td>[% serviceArchetypesLoo.caseData2Title %]</td>
113
                <td>[% serviceArchetypesLoo.caseData3Title %]</td>
114
                <td>[% UNLESS ( serviceArchetypesLoo.system_defined ) %]<a href="edit_archetypes.pl?action=edit&casaId=[% serviceArchetypesLoo.casaId %]">Edit</a>[% END %]</td>
115
                <td>[% UNLESS ( serviceArchetypesLoo.system_defined ) %]<a href="edit_archetypes.pl?action=delete&casaId=[% serviceArchetypesLoo.casaId %]">Delete</a>[% END %]</td>
116
              </tr>
117
            [% END %]
118
          </table>
119
        [% ELSE %]
120
            <tr><td colspan="12">There are no service archetypes currently defined.</td></tr>
121
        [% END %]
122
123
      <!-- ADD NEW ARCHETYPE FORM -->
124
125
<table>
126
  <tr>
127
        [% IF ( previousActionEdit ) %]
128
          <th>Edit an archetype</th>
129
        [% ELSE %]
130
          <th>Create new archetype</th>
131
        [% END %]
132
  </tr>
133
  <tr>
134
    <td>
135
        <form action="edit_archetypes.pl" id="archetype_form" name="archetype_form" method="post" onsubmit="return validateForm()" >
136
          [% IF ( previousActionEdit ) %]
137
            <input type="hidden" name="action" value="update" />
138
            <input type="hidden" name="casaId" value="[% editCasaId %]" />
139
          [% ELSE %]
140
            <input type="hidden" name="action" value="create" />
141
          [% END %]
142
143
          <label for="type">Type: </label>
144
          <select name="type">
145
            [% IF ( editType ) %]<option label="Keep current type" value="[% editType %]">Keep current type</option>[% END %]
146
            <option label="Club" value="club">Club</option>
147
            <option label="Service" value="service">Service</option>
148
          </select>
149
          <br />
150
151
          <label for="title">Title: </label>
152
          <input type="text" name="title" id="title" [% IF ( editTitle ) %] value="[% editTitle %]" [% END %] />
153
          <i>required</i>
154
          <br />
155
156
          <label for="description">Description: </label>
157
          <input type="text" size="75" name="description" id="description" [% IF ( editDescription ) %] value="[% editDescription %]" [% END %]  />
158
          <i>required</i>
159
          <br />
160
161
          <label for="publicEnrollment">Public enrollment</label>
162
          [% IF ( editPublicEnrollment ) %]
163
              <input type="radio" name="publicEnrollment" value="yes" checked="checked">Yes</input>
164
              <input type="radio" name="publicEnrollment" value="no">No</input>
165
          [% ELSE %]
166
              <input type="radio" name="publicEnrollment" value="yes">Yes</input>
167
              <input type="radio" name="publicEnrollment" value="no" checked="checked">No</input>
168
          [% END %]
169
170
          <br />
171
172
             <h6>The following fields are generic fields that you can define to hold any data you might need upon club/service creation that is not stored elsewhere in Koha.
173
             These fields will appear when a person creates a new club or service, at that time the system will ask for the data that is defined in this field.
174
             For example, if you were to create a "Summer Reading Club" archetype, and you want to compare summer reading clubs by year, you would enter 'Year' in
175
             the 'Title' field, and 'Year that this Summer Reading Club is Taking Place' in the 'Description' field.
176
             If you do not need to store any extra data for a club or service, just leave these blank.
177
             </h6>
178
          <table>
179
            <tr>
180
              <td><label>Club/service data 1</lable></td>
181
              <td><label for="casData1Title">Title</label></td>
182
              <td><input type="text" name="casData1Title" value="[% editCasData1Title %]" /></td>
183
              <td><label for="casData1Title">Description</label></td>
184
              <td><input type="text" name="casData1Desc" value="[% editCasData1Desc %]" /></td>
185
            </tr>
186
187
            <tr>
188
              <td><label>Club/service data 2</lable></td>
189
              <td><label for="casData2Title">Title</label></td>
190
              <td><input type="text" name="casData2Title" value="[% editCasData2Title %]" /></td>
191
              <td><label for="casData2Title">Description</label></td>
192
              <td><input type="text" name="casData2Desc" value="[% editCasData2Desc %]" /></td>
193
            </tr>
194
195
            <tr>
196
              <td><label>Club/service data 3</lable></td>
197
              <td><label for="casData3Title">Title</label></td>
198
              <td><input type="text" name="casData3Title" value="[% editCasData3Title %]" /></td>
199
              <td><label for="casData3Title">Description</label></td>
200
              <td><input type="text" name="casData3Desc" value="[% editCasData3Desc %]" /></td>
201
            </tr>
202
          </table>
203
             <h6>The following fields are generic fields that you can define to hold any data you might need on borrower enrollment that is not stored elsewhere in Koha.
204
             These fields will appear on the enrollment page.
205
             For example, if you were to create a "Summer Reading Club" archetype, and you need to keep track of which grade the reader will be entering after summer,
206
             you would enterer 'Grade' in the 'Title' field and 'The grade the participant will be entering after summer' in the 'Description' field.
207
             If you do not need to store any extra enrollment data for this club or service, just leave these blank.
208
             </h6>
209
          <table>
210
            <tr>
211
              <td><label>Enrollment data 1</lable></td>
212
              <td><label for="caseData1Title">Title</label></td>
213
              <td><input type="text" name="caseData1Title" value="[% editCaseData1Title %]" /></td>
214
              <td><label for="caseData1Title">Description</label></td>
215
              <td><input type="text" name="caseData1Desc" value="[% editCaseData1Desc %]" /></td>
216
            </tr>
217
218
            <tr>
219
              <td><label>Enrollment data 2</lable></td>
220
              <td><label for="caseData2Title">Title</label></td>
221
              <td><input type="text" name="caseData2Title" value="[% editCaseData2Title %]" /></td>
222
              <td><label for="caseData2Title">Description</label></td>
223
              <td><input type="text" name="caseData2Desc" value="[% editCaseData2Desc %]" /></td>
224
            </tr>
225
226
            <tr>
227
              <td><label>Enrollment data 3</lable></td>
228
              <td><label for="caseData3Title">Title</label></td>
229
              <td><input type="text" name="caseData3Title" value="[% editCaseData3Title %]" /></td>
230
              <td><label for="caseData3Title">Description</label></td>
231
              <td><input type="text" name="caseData3Desc" value="[% editCaseData3Desc %]" /></td>
232
            </tr>
233
          </table>
234
235
	  <table>
236
		<tr>
237
			<td><input type="checkbox" name="caseRequireEmail" id="caseRequireEmail" value="1" [% IF ( editCaseRequireEmail ) %]checked="checked"[% END %] /></td>
238
			<td>Require email</td>
239
			<td><i>If checked, a borrower will not be able to enroll unless he or she has a valid email address on record in the field specified in the System Preference 'AutoEmailPrimaryAddress'.</i></td>
240
		</tr>
241
	  </table>
242
243
          <br />
244
          [% IF ( previousActionEdit ) %]
245
            <input type="submit" value="Update" />
246
          [% ELSE %]
247
            <input type="submit" value="Create" />
248
          [% END %]
249
250
        </form>
251
    </td>
252
  </tr>
253
</table>
254
</div>
255
</div>
256
257
<div class="yui-b">
258
<div id="menu">
259
  <ul>
260
    [% IF ( clubs_services ) %]<li class="active">[% ELSE %]<li>[% END %]<a href="clubs_services.pl">Clubs &amp; services home</a></li>
261
    [% IF ( edit_archetypes ) %]<li class="active">[% ELSE %]<li>[% END %]<a href="edit_archetypes.pl">Edit archetypes</a></li>
262
    [% IF ( edit_clubs_services ) %]<li class="active">[% ELSE %]<li>[% END %]<a href="edit_clubs_services.pl">Edit clubs & services</a></li>
263
  </ul>
264
</div>
265
</div>
266
267
</div>
268
</div>
269
270
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/clubs_services/edit_clubs_services.tt (+258 lines)
Line 0 Link Here
1
[% USE KohaDates %]
2
[% INCLUDE 'doc-head-open.inc' %]
3
<title>Koha &rsaquo; Tools &rsaquo; Clubs &amp services &rsaquo; Edit</title>
4
[% INCLUDE 'doc-head-close.inc' %]
5
[% INCLUDE 'calendar.inc' %]
6
7
<script type="text/javascript" language="javascript">
8
//<![CDATA[
9
function validateForm()
10
{
11
  var title = document.forms["club_service_form"]["title"].value;
12
  if ( title == null || title == "") {
13
    alert(_("Title is a required field"));
14
    return false;
15
  }
16
17
  var description = document.forms["club_service_form"]["description"].value;
18
  if ( description == null || description == "") {
19
    alert(_("Description is a required field"));
20
    return false;
21
  }
22
}
23
//]]>
24
</script>
25
26
</head>
27
<body>
28
[% INCLUDE 'header.inc' %]
29
30
<div id="breadcrumbs">
31
  <a href="/cgi-bin/koha/mainpage.pl">Home</a>
32
  &rsaquo; <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a>
33
  &rsaquo; <a href="/cgi-bin/koha/clubs_services/clubs_services.pl">Clubs &amp; services</a>
34
  &rsaquo; Edit
35
</div>
36
37
<div id="doc3" class="yui-t2">
38
   <div id="bd">
39
        <div id="yui-main">
40
        <div class="yui-b">
41
42
          <table>
43
          <tr><th colspan="7">Clubs</th></tr>
44
            <tr>
45
              <th>Owner</th>
46
              <th>Title</th>
47
              <th>Description</th>
48
              <th>Start date</th>
49
              <th>End date</th>
50
              <th></th>
51
              <th></th>
52
            </tr>
53
         [% IF ( clubsLoop ) %]
54
            [% FOREACH clubsLoo IN clubsLoop %]
55
              <tr>
56
                <td>[% clubsLoo.branchcode %]</td>
57
                <td>[% clubsLoo.title %]</td>
58
                <td>[% clubsLoo.description %]</td>
59
                <td>[% clubsLoo.startDate | $KohaDates %]</td>
60
                <td>[% clubsLoo.endDate | $KohaDates %]</td>
61
                <td><a href="edit_clubs_services.pl?action=edit&casaId=[% clubsLoo.casaId %]&casId=[% clubsLoo.casId %]">Edit</a></td>
62
                <td><a href="edit_clubs_services.pl?action=delete&casId=[% clubsLoo.casId %]">Delete</a></td>
63
              </tr>
64
            [% END %]
65
        [% ELSE %]
66
          <tr><td colspan="7">There are no clubs currently defined.</td></tr>
67
        [% END %]
68
69
          <tr><td colspan="7">&nbsp;</td></tr>
70
71
          <tr><th colspan="7">Services</th></tr>
72
73
            <tr>
74
              <th>Owner</th>
75
              <th>Title</th>
76
              <th>Description</th>
77
              <th>Start date</th>
78
              <th>End date</th>
79
              <th></th>
80
              <th></th>
81
            </tr>
82
83
        [% IF ( servicesLoop ) %]
84
            [% FOREACH servicesLoo IN servicesLoop %]
85
              <tr>
86
                <td>[% servicesLoo.branchcode %]</td>
87
                <td>[% servicesLoo.title %]</td>
88
                <td>[% servicesLoo.description %]</td>
89
                <td>[% servicesLoo.startDate | $KohaDates %]</td>
90
                <td>[% servicesLoo.endDate | $KohaDates %]</td>
91
                <td><a href="edit_clubs_services.pl?action=edit&casaId=[% servicesLoo.casaId %]&casId=[% servicesLoo.casId %]">Edit</a></td>
92
                <td><a href="edit_clubs_services.pl?action=delete&casId=[% servicesLoo.casId %]">Delete</a></td>
93
              </tr>
94
            [% END %]
95
          </table>
96
        [% ELSE %]
97
          <tr><td colspan="7">There are no services currently defined.</td></tr>
98
        [% END %]
99
100
101
    [% IF ( previousActionSelectArchetype ) %]
102
      <!-- ADD NEW CAS FORM -->
103
       <table>
104
        [% IF ( previousActionEdit ) %]
105
          <tr><th colspan="10">Edit a club or service</th></tr>
106
        [% ELSE %]
107
          <tr><th colspan="10">Create new club or service</th></tr>
108
        [% END %]
109
        <form action="edit_clubs_services.pl" name="club_service_form" id="club_service_form" method="post" onsubmit="return validateForm()">
110
          [% IF ( previousActionEdit ) %]
111
            <input type="hidden" name="action" value="update" />
112
            <input type="hidden" name="casId" value="[% editCasId %]" />
113
          [% ELSE %]
114
            <input type="hidden" name="action" value="create" />
115
          [% END %]
116
117
118
            <tr>
119
              <td>
120
                <label for="casaId">Archetype: </label>
121
              </td>
122
              <td colspan="9">
123
                <select name="casaId">
124
                  <option value="[% casaId %]">[% casaTitle %]</option>
125
                </select>
126
              </td>
127
            </tr>
128
            <tr>
129
              <td>
130
                <label for="title">Title: </label>
131
              </td>
132
              <td colspan="9">
133
               <input type="text" name="title" id="title" value="[% editTitle %]" />
134
              </td>
135
            </tr>
136
137
            <tr>
138
              <td>
139
                <label for="description">Description: </label>
140
              </td>
141
              <td colspan="2">
142
                <input type="text" size="50" name="description" id="description" value="[% editDescription %]" />
143
              </td>
144
            </tr>
145
146
            [% IF ( casData1Title ) %]
147
              <tr>
148
                <td>
149
                  <label for="casData1">[% casData1Title %]: </label>
150
                </td>
151
                <td>
152
                  <input type="text" name="casData1" value="[% editCasData1 %]" />
153
                </td>
154
                <td><i>[% casData1Desc %]</i></td>
155
              </tr>
156
            [% END %]
157
158
            [% IF ( casData2Title ) %]
159
              <tr>
160
                <td>
161
                  <label for="casData2">[% casData2Title %]: </label>
162
                </td>
163
                <td>
164
                  <input type="text" name="casData2" value="[% editCasData2 %]" />
165
                </td>
166
                <td><i>[% casData2Desc %]</i></td>
167
              </tr>
168
            [% END %]
169
170
            [% IF ( casData3Title ) %]
171
              <tr>
172
                <td>
173
                  <label for="casData3">[% casData3Title %]: </label>
174
                </td>
175
                <td>
176
                  <input type="text" name="casData3" value="[% editCasData3 %]" />
177
                </td>
178
                <td><i>[% casData3Desc %]</i></td>
179
              </tr>
180
            [% END %]
181
182
            <tr>
183
              <td>
184
                <label for="startDate">Start date: </label>
185
              </td>
186
              <td>
187
                <input type="text" size="10" maxlength="10" id= "startDate" name="startDate" value="[% editStartDate | $KohaDates%]" class="datepicker"/>
188
              </td>
189
              <td>
190
                <i>Optional: Leave blank for start date of today.</i>
191
              </td>
192
            </tr>
193
194
            <tr>
195
              <td>
196
                <label for="endDate">End date: </label>
197
              </td>
198
              <td>
199
                <input type="text" size="10" maxlength="10" id="endDate" name="endDate" value="[% editEndDate | $KohaDates %]" class="datepicker"/>
200
              </td>
201
              <td>
202
                <i>Optional: Leave blank for no end date.</i>
203
              </td>
204
            </tr>
205
206
            <tr>
207
              <td colspan="3">
208
                [% IF ( previousActionEdit ) %]
209
                  <input type="submit" value="Update" />
210
                [% ELSE %]
211
                  <input type="submit" value="Create" />
212
                [% END %]
213
              </td>
214
            </tr>
215
          </table>
216
        </form>
217
    [% ELSE %]
218
219
      <!-- SELECT ARCHETYPE FORM -->
220
      <table>
221
      <tr><th colspan="2">Create new club or service</th></tr>
222
      <tr><td>
223
      [% IF ( archetypes ) %]
224
        <form action="edit_clubs_services.pl" method="post">
225
          <input type="hidden" name="action" value="selectArchetype" />
226
          <label for="casaId">Select srchetype</label>
227
          <select name="casaId">
228
            [% FOREACH archetypesLoo IN archetypesLoop %]
229
              <option value="[% archetypesLoo.casaId %]">[% archetypesLoo.title %]</option>
230
            [% END %]
231
          </select>
232
          </td>
233
          <td><input type="submit" value="Create" /></td>
234
	</form>
235
      [% ELSE %]
236
        No archetypes defined.
237
      [% END %]
238
      </tr>
239
      </table>
240
    [% END %]
241
242
</div>
243
</div>
244
245
<div class="yui-b">
246
<div id="menu">
247
  <ul>
248
    [% IF ( clubs_services ) %]<li class="active">[% ELSE %]<li>[% END %]<a href="clubs_services.pl">Clubs &amp; services home</a></li>
249
    [% IF ( edit_archetypes ) %]<li class="active">[% ELSE %]<li>[% END %]<a href="edit_archetypes.pl">Edit archetypes</a></li>
250
    [% IF ( edit_clubs_services ) %]<li class="active">[% ELSE %]<li>[% END %]<a href="edit_clubs_services.pl">Edit clubs & services</a></li>
251
  </ul>
252
</div>
253
</div>
254
255
</div>
256
</div>
257
258
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/clubs_services/enroll_clubs_services.tt (+95 lines)
Line 0 Link Here
1
[% INCLUDE 'doc-head-open.inc' %]
2
<title>Koha &rsaquo; Tools &rsaquo; Clubs &amp services &rsaquo; Enroll</title>
3
[% INCLUDE 'doc-head-close.inc' %]
4
</head>
5
<body>
6
[% INCLUDE 'header.inc' %]
7
8
<div id="breadcrumbs">
9
  <a href="/cgi-bin/koha/mainpage.pl">Home</a>
10
  &rsaquo; <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a>
11
  &rsaquo; <a href="/cgi-bin/koha/clubs_services/clubs_services.pl">Clubs &amp; services</a>
12
  &rsaquo; Enroll
13
</div>
14
15
<div id="doc3" class="yui-t2">
16
   <div id="bd">
17
        <div id="yui-main">
18
        <div class="yui-b">
19
      <div>
20
          [% IF ( previousActionEnroll ) %]
21
            [% IF ( enrollSuccess ) %]
22
              <div>Patron with cardnumber '[% enrolledBarcode %]' enrolled succesfully!</div>
23
            [% ELSE %]
24
              <div>Failed to enroll patron with cardnumber '[% enrolledBarcode %]'!</div>
25
              <div>
26
                  <strong>
27
                      [% IF failureMessage == 'NO_BORROWER' %]No patron was provided.[% END %]
28
                      [% IF failureMessage == 'NO_BORROWER_FOUND' %]No patron was found.[% END %]
29
                      [% IF failureMessage == 'NO_EMAIL' %]Email address required: no valid email address in borrower record.[% END %]
30
                  </strong>
31
              </div>
32
            [% END %]
33
          [% END %]
34
35
36
          <h3>Enroll a patron in <i>[% casTitle %]</i></h3>
37
      </div>
38
39
      <div>
40
        <form action="enroll_clubs_services.pl" method="post">
41
        <table>
42
          [% IF ( caseData1Title ) %]
43
            <tr>
44
              <th><label for="data1">[% caseData1Title %]: </label></th>
45
              <td><input type="text" id="data1" name="data1" /></td>
46
              <td><i>[% caseData1Desc %]</i></td>
47
            </tr>
48
          [% END %]
49
50
          [% IF ( caseData2Title ) %]
51
            <tr>
52
              <th><label for="data2">[% caseData2Title %]: </label></th>
53
              <td><input type="text" id="data2" name="data2" /></td>
54
              <td><i>[% caseData2Desc %]</i></td>
55
            </tr>
56
          [% END %]
57
58
          [% IF ( caseData3Title ) %]
59
            <tr>
60
              <th><label for="data3">[% caseData3Title %]: </label></th>
61
              <td><input type="text" id="data3" name="data3" /></td>
62
              <td><i>[% caseData3Desc %]</i></td>
63
            </tr>
64
          [% END %]
65
66
          <tr>
67
            <th><label for="borrowerBarcode">Borrower cardnumber: </label></th>
68
            <td colspan="2"><input type="text" id="borrowerBarcode" name="borrowerBarcode" /></td>
69
          </tr>
70
71
          <input type="hidden" id="casId" name="casId" value="[% casId %]" />
72
          <input type="hidden" id="casaId" name="casaId" value="[% casaId %]" />
73
          <input type="hidden" name="action" value="enroll" />
74
          <tr><td colspan="3"><input type="submit" value="Enroll" /></td></tr>
75
        </table>
76
        </form>
77
      </div>
78
79
</div>
80
</div>
81
82
<div class="yui-b">
83
<div id="menu">
84
  <ul>
85
    [% IF ( clubs_services ) %]<li class="active">[% ELSE %]<li>[% END %]<a href="clubs_services.pl">Clubs &amp; services home</a></li>
86
    [% IF ( edit_archetypes ) %]<li class="active">[% ELSE %]<li>[% END %]<a href="edit_archetypes.pl">Edit archetypes</a></li>
87
    [% IF ( edit_clubs_services ) %]<li class="active">[% ELSE %]<li>[% END %]<a href="edit_clubs_services.pl">Edit clubs & services</a></li>
88
  </ul>
89
</div>
90
</div>
91
92
</div>
93
</div>
94
95
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/clubs_services.tt (+85 lines)
Line 0 Link Here
1
[% INCLUDE 'doc-head-open.inc' %]
2
<title>Koha &rsaquo; Patrons &rsaquo; Account for [% firstname %] [% surname %]</title>
3
[% INCLUDE 'doc-head-close.inc' %]
4
</head>
5
<body>
6
[% INCLUDE 'header.inc' %]
7
[% INCLUDE 'patron-search.inc' %]
8
9
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/members/members-home.pl">Patrons</a>  &rsaquo; Clubs &amp; Services for [% firstname %] [% surname %]</div>
10
11
<div id="doc3" class="yui-t2">
12
   <div id="bd">
13
        <div id="yui-main">
14
        <div class="yui-b">
15
16
<table>
17
<thead>
18
<tr><th colspan="5">Currently Enrolled Clubs & Services</th></tr>
19
<tr>
20
  <th>Title</th>
21
  <th>Description</th>
22
  <th>Library</th>
23
  <th>Type</th>
24
  <th></th>
25
</tr>
26
</thead>
27
<tbody>
28
29
[% IF ( enrolledClubsAndServicesLoop ) %]
30
31
    [% FOREACH enrolledClubsAndServicesLoo IN enrolledClubsAndServicesLoop %]
32
      [% IF ( enrolledClubsAndServicesLoo.odd ) %]<tr class="highlight">[% ELSE %]<tr>[% END %]
33
        <td>[% enrolledClubsAndServicesLoo.title %]</td>
34
        <td>[% enrolledClubsAndServicesLoo.description %]</td>
35
        <td>[% enrolledClubsAndServicesLoo.branchcode %]</td>
36
        <td>[% enrolledClubsAndServicesLoo.type %]</td>
37
        <td>[% IF ( CAN_user_clubs_services_enroll_borrower ) %]<a href="clubs_services.pl?action=cancel&caseId=[% enrolledClubsAndServicesLoo.caseId %]&borrowernumber=[% borrowernumber %]">Cancel</a>[% END %]</td>
38
      </tr>
39
    [% END %]
40
41
[% ELSE %]
42
  <tr><td colspan="5"><Patron Is Not Enrolled In Any Clubs Or Services</tr></td>
43
[% END %]
44
  </tbody>
45
46
[% IF ( CAN_user_clubs_services_enroll_borrower ) %]
47
  <tr><td colspan="5">&nbsp;</td></tr>
48
49
  <thead>
50
  <tr><th colspan="5">Enroll In Clubs & Services</th></tr>
51
  <tr>
52
    <th>Title</th>
53
    <th>Description</th>
54
    <th>Library</th>
55
    <th>Type</th>
56
    <th></th>
57
  </tr>
58
  </thead>
59
60
  <tbody>
61
    [% IF ( enrollableClubsAndServicesLoop ) %]
62
63
      [% FOREACH enrollableClubsAndServicesLoo IN enrollableClubsAndServicesLoop %]
64
        [% IF ( enrollableClubsAndServicesLoo.odd ) %]<tr class="highlight">[% ELSE %]<tr>[% END %]
65
          <td>[% enrollableClubsAndServicesLoo.title %]</td>
66
          <td>[% enrollableClubsAndServicesLoo.description %]</td>
67
          <td>[% enrollableClubsAndServicesLoo.branchcode %]</td>
68
          <td>[% enrollableClubsAndServicesLoo.type %]</td>
69
          <td><a href="clubs_services_enroll.pl?casId=[% enrollableClubsAndServicesLoo.casId %]&casaId=[% enrollableClubsAndServicesLoo.casaId %]&borrowernumber=[% borrowernumber %]">Enroll</a></td>
70
        </tr>
71
      [% END %]
72
    [% ELSE %]
73
      <tr><td colspan="5">There Are No New Clubs Or Services To Enroll In</td></tr>
74
    [% END %]
75
  </tbody>
76
[% END %]
77
</table>
78
79
</div>
80
</div>
81
<div class="yui-b">
82
[% INCLUDE 'circ-menu.inc' %]
83
</div>
84
</div>
85
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/clubs_services_enroll.tt (+73 lines)
Line 0 Link Here
1
[% INCLUDE 'doc-head-open.inc' %]
2
<title>Koha &rsaquo; Patrons &rsaquo; Account for [% firstname %] [% surname %]</title>
3
[% INCLUDE 'doc-head-close.inc' %]
4
</head>
5
<body>
6
[% INCLUDE 'header.inc' %]
7
[% INCLUDE 'patron-search.inc' %]
8
9
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/members/members-home.pl">Patrons</a> &rsaquo; Clubs &amp; Services for [% firstname %] [% surname %]</div>
10
11
<div id="doc3" class="yui-t2">
12
   <div id="bd">
13
        <div id="yui-main">
14
        <div class="yui-b">
15
16
[% IF ( previousActionEnroll ) %]
17
  [% IF ( enrollSuccess ) %]
18
    <div>Enrolled Succesfully!</div>
19
    <div><a href="/cgi-bin/koha/members/clubs_services.pl?borrowernumber=[% borrowernumber %]">Back To Clubs & Services</a></div>
20
  [% ELSE %]
21
    <div>Failed to Enroll!</div>
22
    <div>Reason: <strong>[% failureMessage %]</strong></div>
23
    <div><a href="/cgi-bin/koha/members/clubs_services.pl?borrowernumber=[% borrowernumber %]">Back To Clubs & Services</a></div>
24
  [% END %]
25
[% END %]
26
27
[% IF ( caseData1Title ) %]
28
  <div>
29
    <h4>Please Enter The Following Information</h4>
30
    <form action="clubs_services_enroll.pl" method="post">
31
    <table>
32
      [% IF ( caseData1Title ) %]
33
        <tr>
34
          <td><label for="data1">[% caseData1Title %]: </label></td>
35
          <td><input type="text" id="data1" name="data1" /></td>
36
          <td><i>[% caseData1Desc %]</i></td>
37
        </tr>
38
      [% END %]
39
40
      [% IF ( caseData2Title ) %]
41
        <tr>
42
          <td><label for="data2">[% caseData2Title %]: </label></td>
43
          <td><input type="text" id="data2" name="data2" /></td>
44
          <td><i>[% caseData2Desc %]</i></td>
45
        </tr>
46
      [% END %]
47
48
      [% IF ( caseData3Title ) %]
49
        <tr>
50
          <td><label for="data3">[% caseData3Title %]: </label></td>
51
          <td><input type="text" id="data3" name="data3" /></td>
52
          <td><i>[% caseData3Desc %]</i></td>
53
        </tr>
54
      [% END %]
55
56
      <input type="hidden" id="casId" name="casId" value="[% casId %]" />
57
      <input type="hidden" id="casaId" name="casaId" value="[% casaId %]" />
58
      <input type="hidden" id="borrowernumber" name="borrowernumber" value="[% borrowernumber %]" />
59
      <input type="hidden" name="action" value="enroll" />
60
      <tr><td colspan="3"><input type="submit" value="Enroll" /></td></tr>
61
    </table>
62
    </form>
63
  </div>
64
[% END %]
65
66
</div>
67
</div>
68
69
<div class="yui-b">
70
[% INCLUDE 'circ-menu.inc' %]
71
</div>
72
</div>
73
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/tools-home.tt (+2 lines)
Lines 60-65 Link Here
60
	<dd>Upload patron images in batch or one at a time</dd>
60
	<dd>Upload patron images in batch or one at a time</dd>
61
    [% END %]
61
    [% END %]
62
62
63
    <dt><a href="/cgi-bin/koha/clubs_services/clubs_services.pl">Clubs & Services</a></dt>
64
    <dd>Create and Edit Clubs & Services</dd>
63
65
64
66
65
	</dl>
67
	</dl>
(-)a/koha-tmpl/opac-tmpl/prog/en/includes/usermenu.inc (-1 / +1 lines)
Lines 32-38 Link Here
32
  [% IF ( virtualshelves ) %] 
32
  [% IF ( virtualshelves ) %] 
33
  [% IF ( listsview ) %]<li class="active">[% ELSE %]<li>[% END %]<a href="/cgi-bin/koha/opac-shelves.pl?display=privateshelves">my lists</a></li>
33
  [% IF ( listsview ) %]<li class="active">[% ELSE %]<li>[% END %]<a href="/cgi-bin/koha/opac-shelves.pl?display=privateshelves">my lists</a></li>
34
  [% END %]
34
  [% END %]
35
35
  [% IF ( clubs_services ) %]<li class="active">[% ELSE %]<li>[% END %]<a href="/cgi-bin/koha/opac-clubsAndServices.pl">my clubs &amp; services</a></li>
36
</ul>
36
</ul>
37
</div>
37
</div>
38
[% END %][% ELSE %][% END %]
38
[% END %][% ELSE %][% END %]
(-)a/koha-tmpl/opac-tmpl/prog/en/modules/opac-clubsAndServices-enroll.tt (+72 lines)
Line 0 Link Here
1
[% INCLUDE 'doc-head-open.inc' %]
2
[% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha Online[% END %] Catalog &rsaquo; Clubs &amp;
3
[% FOREACH BORROWER_INF IN BORROWER_INFO %]
4
    [% BORROWER_INF.firstname %][% BORROWER_INF.surname %]
5
[% END %]
6
[% INCLUDE 'doc-head-close.inc' %]
7
8
</head>
9
<body id="opac-user">
10
<div id="doc3" class="yui-t1">
11
<div id="bd">
12
[% INCLUDE 'masthead.inc' %]
13
14
<div id="yui-main">
15
<div class="yui-b">
16
17
[% IF ( previousActionEnroll ) %]
18
  [% IF ( enrollSuccess ) %]
19
    <div>Enrolled Succesfully!</div>
20
  [% ELSE %]
21
    <div>Failed to Enroll!</div>
22
    <div>Reason: <strong>[% failureMessage %]</strong></div>
23
  [% END %]
24
[% END %]
25
26
[% IF ( caseData1Title ) %]
27
  <table>
28
    <tr><th colspan="10">Please Enter The Following Information</th></tr>
29
    <form action="opac-clubsAndServices-enroll.pl" method="post">
30
      [% IF ( caseData1Title ) %]
31
        <tr>
32
          <td><label for="data1">[% caseData1Title %]: </label></td>
33
          <td><input type="text" id="data1" name="data1" /></td>
34
          <td><i>[% caseData1Desc %]</i></td>
35
        </tr>
36
      [% END %]
37
38
      [% IF ( caseData2Title ) %]
39
        <tr>
40
          <td><label for="data2">[% caseData2Title %]: </label></td>
41
          <td><input type="text" id="data2" name="data2" /></td>
42
          <td><i>[% caseData2Desc %]</i></td>
43
        </tr>
44
      [% END %]
45
46
      [% IF ( caseData3Title ) %]
47
        <tr>
48
          <td><label for="data3">[% caseData3Title %]: </label></td>
49
          <td><input type="text" id="data3" name="data3" /></td>
50
          <td><i>[% caseData3Desc %]</i></td>
51
        </tr>
52
      [% END %]
53
54
      <input type="hidden" id="casId" name="casId" value="[% casId %]" />
55
      <input type="hidden" id="casaId" name="casaId" value="[% casaId %]" />
56
      <input type="hidden" id="borrowernumber" name="borrowernumber" value="[% borrowernumber %]" />
57
      <input type="hidden" name="action" value="enroll" />
58
      <tr><td colspan="3"><input type="submit" value="Enroll" /></td></tr>
59
    </form>
60
  </table>
61
[% END %]
62
63
</div>
64
</div>
65
<div class="yui-b">
66
<div class="container">
67
[% INCLUDE 'navigation.inc' %]
68
[% INCLUDE 'usermenu.inc' %]
69
</div>
70
</div>
71
</div>
72
[% INCLUDE 'opac-bottom.inc' %]
(-)a/koha-tmpl/opac-tmpl/prog/en/modules/opac-clubsAndServices.tt (+84 lines)
Line 0 Link Here
1
[% INCLUDE 'doc-head-open.inc' %]
2
[% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha Online[% END %] Catalog &rsaquo; Clubs &amp; Services for
3
[% FOREACH BORROWER_INF IN BORROWER_INFO %]
4
    [% BORROWER_INF.firstname %][% BORROWER_INF.surname %]
5
[% END %]
6
[% INCLUDE 'doc-head-close.inc' %]
7
8
</head>
9
<body id="opac-user">
10
<div id="doc3" class="yui-t1">
11
<div id="bd">
12
[% INCLUDE 'masthead.inc' %]
13
14
<div id="yui-main">
15
<div class="yui-b">
16
17
<table>
18
<tr><th colspan="5">My Clubs & Services</th></tr>
19
<tr>
20
  <th>Title</th>
21
  <th>Description</th>
22
  <th>Library</th>
23
  <th>Type</th>
24
  <th></th>
25
</tr>
26
27
[% IF ( enrolledClubsAndServicesLoop ) %]
28
29
    [% FOREACH enrolledClubsAndServicesLoo IN enrolledClubsAndServicesLoop %]
30
      [% IF ( enrolledClubsAndServicesLoo.odd ) %]<tr class="highlight">[% ELSE %]<tr>[% END %]
31
        <td>[% enrolledClubsAndServicesLoo.title %]</td>
32
        <td>[% enrolledClubsAndServicesLoo.description %]</td>
33
        <td>[% enrolledClubsAndServicesLoo.branchcode %]</td>
34
        <td>[% enrolledClubsAndServicesLoo.type %]</td>
35
        <td>
36
            [% IF ( enrolledClubsAndServicesLoo.publicEnrollment ) %]
37
              <a href="opac-clubsAndServices.pl?action=cancel&caseId=[% enrolledClubsAndServicesLoo.caseId %]">Cancel</a>
38
            [% END %]
39
        </td>
40
      </tr>
41
    [% END %]
42
43
[% ELSE %]
44
  <tr><td colspan="10">You Are Not Enrolled In Any Clubs Or Services</td></tr>
45
[% END %]
46
47
  <tr><td colspan="5">&nbsp</td></tr>
48
49
  <tr><th colspan="5">Enroll In Clubs & Services</th></tr>
50
  <tr>
51
    <th>Title</th>
52
    <th>Description</th>
53
    <th>Library</th>
54
    <th>Type</th>
55
    <th></th>
56
  </tr>
57
58
[% IF ( enrollableClubsAndServicesLoop ) %]
59
60
    [% FOREACH enrollableClubsAndServicesLoo IN enrollableClubsAndServicesLoop %]
61
      [% IF ( enrollableClubsAndServicesLoo.odd ) %]<tr class="highlight">[% ELSE %]<tr>[% END %]
62
        <td>[% enrollableClubsAndServicesLoo.title %]</td>
63
        <td>[% enrollableClubsAndServicesLoo.description %]</td>
64
        <td>[% enrollableClubsAndServicesLoo.branchcode %]</td>
65
        <td>[% enrollableClubsAndServicesLoo.type %]</td>
66
        <td><a href="opac-clubsAndServices-enroll.pl?casId=[% enrollableClubsAndServicesLoo.casId %]&casaId=[% enrollableClubsAndServicesLoo.casaId %]">Enroll</a></td>
67
      </tr>
68
    [% END %]
69
70
[% ELSE %]
71
  <tr><td colspan="10">There Are No New Clubs Or Services To Enroll In</td></tr>
72
[% END %]
73
</table>
74
75
</div>
76
</div>
77
<div class="yui-b">
78
<div class="container">
79
[% INCLUDE 'navigation.inc' %]
80
[% INCLUDE 'usermenu.inc' %]
81
</div>
82
</div>
83
</div>
84
[% INCLUDE 'opac-bottom.inc' %]
(-)a/members/clubs_services.pl (+56 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
use strict;
3
4
use CGI;
5
6
use C4::Output;
7
use C4::Search;
8
use C4::Auth;
9
use C4::Koha;
10
use C4::Members;
11
use C4::ClubsAndServices;
12
13
my $query = new CGI;
14
15
my $borrowernumber = $query->param('borrowernumber');
16
17
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
18
    {   template_name   => "members/clubs_services.tmpl",
19
        query           => $query,
20
        type            => "intranet",
21
        authnotrequired => 0,
22
        flagsrequired   => { borrow => 1 },
23
        debug           => 1,
24
    }
25
);
26
27
# get borrower information ....
28
my $borrowerData = GetMemberDetails($borrowernumber);
29
$template->param(
30
    borrowernumber => $borrowernumber,
31
    surname        => $borrowerData->{'surname'},
32
    firstname      => $borrowerData->{'firstname'},
33
    cardnumber     => $borrowerData->{'cardnumber'},
34
    address        => $borrowerData->{'address'},
35
    city           => $borrowerData->{'city'},
36
    phone          => $borrowerData->{'phone'},
37
    email          => $borrowerData->{'email'},
38
    categorycode   => $borrowerData->{'categorycode'},
39
    categoryname   => $borrowerData->{'description'},
40
    branchcode     => $borrowerData->{'branchcode'},
41
    branchname     => C4::Branch::GetBranchName( $borrowerData->{'branchcode'} ),
42
);
43
44
if ( $query->param('action') eq 'cancel' ) {    ## Cancel the enrollment in the passed club or service
45
    CancelClubOrServiceEnrollment( $query->param('caseId') );
46
}
47
48
## Get the borrowers current clubs & services
49
my $enrolledClubsAndServices = GetEnrolledClubsAndServices($borrowernumber);
50
$template->param( enrolledClubsAndServicesLoop => $enrolledClubsAndServices );
51
52
## Get clubs & services the borrower can enroll in from the Intranet
53
my $enrollableClubsAndServices = GetAllEnrollableClubsAndServices( $borrowernumber, $query->cookie('branch') );
54
$template->param( enrollableClubsAndServicesLoop => $enrollableClubsAndServices );
55
56
output_html_with_http_headers $query, $cookie, $template->output;
(-)a/members/clubs_services_enroll.pl (+125 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
use strict;
3
4
use CGI;
5
6
use C4::Output;
7
use C4::Search;
8
use C4::Auth;
9
use C4::Koha;
10
use C4::Members;
11
use C4::ClubsAndServices;
12
13
my $query = new CGI;
14
15
my $borrowernumber = $query->param('borrowernumber');
16
17
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
18
    {   template_name   => "members/clubs_services_enroll.tmpl",
19
        query           => $query,
20
        type            => "intranet",
21
        authnotrequired => 0,
22
        flagsrequired   => { borrow => 1 },
23
        debug           => 1,
24
    }
25
);
26
27
# get borrower information ....
28
my $borrowerData = GetMemberDetails($borrowernumber);
29
$template->param(
30
    borrowernumber => $borrowernumber,
31
    surname        => $borrowerData->{'surname'},
32
    firstname      => $borrowerData->{'firstname'},
33
    cardnumber     => $borrowerData->{'cardnumber'},
34
    address        => $borrowerData->{'address'},
35
    city           => $borrowerData->{'city'},
36
    phone          => $borrowerData->{'phone'},
37
    email          => $borrowerData->{'email'},
38
    categorycode   => $borrowerData->{'categorycode'},
39
    categoryname   => $borrowerData->{'description'},
40
    branchcode     => $borrowerData->{'branchcode'},
41
    branchname     => C4::Branch::GetBranchName( $borrowerData->{'branchcode'} ),
42
);
43
44
if ( $query->param('action') eq 'enroll' ) {    ## We were passed the necessary fields from the enrollment page.
45
    my $casId  = $query->param('casId');
46
    my $casaId = $query->param('casaId');
47
    my $data1  = $query->param('data1');
48
    my $data2  = $query->param('data2');
49
    my $data3  = $query->param('data3');
50
51
    my $dateEnrolled;                           # Will default to Today
52
53
    my ( $success, $errorMessage ) = EnrollInClubOrService( $casaId, $casId, '', $dateEnrolled, $data1, $data2, $data3, '', $borrowernumber );
54
55
    $template->param( previousActionEnroll => 1, );
56
57
    if ($success) {
58
        $template->param( enrollSuccess => 1 );
59
    } else {
60
        $template->param( enrollFailure => 1 );
61
        $template->param( errorMessage  => $errorMessage );
62
    }
63
64
} elsif ( DoesEnrollmentRequireData( $query->param('casaId') ) ) {    ## We were not passed any data, and the service requires extra data
65
    my ( $casId, $casaId, $casTitle, $casDescription, $casStartDate, $casEndDate, $casTimestamp ) = GetClubOrService( $query->param('casId') );
66
    my ($casaId,        $casaType,      $casaTitle,      $casaDescription, $casaPublicEnrollment, $casData1Title,
67
        $casData2Title, $casData3Title, $caseData1Title, $caseData2Title,  $caseData3Title,       $casData1Desc,
68
        $casData2Desc,  $casData3Desc,  $caseData1Desc,  $caseData2Desc,   $caseData3Desc,        $timestamp
69
    ) = GetClubOrServiceArchetype($casaId);
70
    $template->param(
71
        casId                => $casId,
72
        casTitle             => $casTitle,
73
        casDescription       => $casDescription,
74
        casStartDate         => $casStartDate,
75
        casEndDate           => $casEndDate,
76
        casTimeStamp         => $casTimestamp,
77
        casaId               => $casaId,
78
        casaType             => $casaType,
79
        casaTitle            => $casaTitle,
80
        casaDescription      => $casaDescription,
81
        casaPublicEnrollment => $casaPublicEnrollment,
82
83
        borrowernumber => $borrowernumber,
84
    );
85
86
    if ($caseData1Title) {
87
        $template->param( caseData1Title => $caseData1Title );
88
    }
89
    if ($caseData2Title) {
90
        $template->param( caseData2Title => $caseData2Title );
91
    }
92
    if ($caseData3Title) {
93
        $template->param( caseData3Title => $caseData3Title );
94
    }
95
96
    if ($caseData1Desc) {
97
        $template->param( caseData1Desc => $caseData1Desc );
98
    }
99
    if ($caseData2Desc) {
100
        $template->param( caseData2Desc => $caseData2Desc );
101
    }
102
    if ($caseData3Desc) {
103
        $template->param( caseData3Desc => $caseData3Desc );
104
    }
105
106
} else {    ## We were not passed any data, but the enrollment does not require any
107
108
    my $casId  = $query->param('casId');
109
    my $casaId = $query->param('casaId');
110
111
    my $dateEnrolled;    # Will default to Today
112
113
    my ( $success, $errorMessage ) = EnrollInClubOrService( $casaId, $casId, '', $dateEnrolled, '', '', '', '', $borrowernumber );
114
115
    $template->param( previousActionEnroll => 1, );
116
117
    if ($success) {
118
        $template->param( enrollSuccess => 1 );
119
    } else {
120
        $template->param( enrollFailure => 1 );
121
        $template->param( errorMessage  => $errorMessage );
122
    }
123
124
}
125
output_html_with_http_headers $query, $cookie, $template->output;
(-)a/misc/cronjobs/mailinglist/mailinglist.pl (+200 lines)
Line 0 Link Here
1
#!/usr/bin/perl -w
2
#-----------------------------------
3
# Description: This script generates e-mails
4
# sent to subscribers of e-mail lists from
5
# the New Items E-mail List archetype
6
# in the ClubsAndServices module
7
#
8
# This file is part of Koha.
9
#
10
# Koha is free software; you can redistribute it and/or modify it under the
11
# terms of the GNU General Public License as published by the Free Software
12
# Foundation; either version 2 of the License, or (at your option) any later
13
# version.
14
#
15
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
16
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
17
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
18
#
19
# You should have received a copy of the GNU General Public License along with
20
# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
21
# Suite 330, Boston, MA  02111-1307 USA
22
23
# DOCUMENTATION
24
# This script utilizes the 'New Items E-mail List' archetype
25
# from the ClubsAndServices.pm module.
26
# If you do not have this archtype, create an archetype of that name
27
# with club/service data 1 as Itemtype, and club/service data 2 as Callnumber.
28
# No other data is needed.
29
30
# The script grabs all new items with the given itemtype and callnumber.
31
# When creating lists to use this script, use % as a wildcard.
32
# If all your science fiction books are of itemtype FIC and have a callnumber
33
# beginning with 'FIC SF', then you would create a service based on this
34
# Archetype and input 'FIC' as the Itemtype, and 'FIC SF%' as the Callnumber.
35
36
# The e-mails are based on the included HTML::Template file mailinglist.tmpl
37
# If you would like to modify the style of the e-mail, just alter that file.
38
39
use strict;
40
41
use C4::Context;
42
use C4::Dates;
43
use C4::Message;
44
45
use Mail::Sendmail;
46
use Getopt::Long;
47
use Date::Calc qw(Add_Delta_Days);
48
use Template;
49
50
use Data::Dumper;
51
52
use Getopt::Long;
53
my ( $name, $start, $end, $help );
54
my $verbose = 0;
55
GetOptions(
56
    'name=s'  => \$name,
57
    'start=i' => \$start,
58
    'end=i'   => \$end,
59
    'verbose' => \$verbose,
60
    'help'    => \$help,
61
);
62
63
if ($help) {
64
    print
65
"\nmailinglist.pl --name [Club Name] --start [Days Ago] --end [Days Ago]\n\n";
66
    print
67
"Example: 'mailinglist.pl --name \"My Club' --start 7 --end 0\" will send\na list of items cataloged since last week to the members of the club\nnamed MyClub\n\n";
68
    print
69
"All arguments are optional. Defaults are to run for all clubs, with dates from 7 to 0 days ago.\n\n";
70
    exit;
71
}
72
73
unless ( C4::Context->preference('OPACBaseURL') ) {
74
    die("Koha System Preference 'OPACBaseURL' is not set!");
75
}
76
my $opacUrl = 'http://' . C4::Context->preference('OPACBaseURL');
77
78
my $dbh = C4::Context->dbh;
79
my $sth;
80
81
## Step 0: Get the date from last week
82
#Gets localtime on the computer executed on.
83
my ( $d, $m, $y ) = (localtime)[ 3, 4, 5 ];
84
85
## 0.1 Get start date
86
#Adjust the offset to either a neg or pos number of days.
87
my $offset = -7;
88
if ($start) { $offset = $start * -1; }
89
90
#Formats the date and sets the offset to subtract 60 days form the #current date. This works with the first line above.
91
my ( $y2, $m2, $d2 ) = Add_Delta_Days( $y + 1900, $m + 1, $d, $offset );
92
93
#Checks to see if the month is greater than 10.
94
if ( $m2 < 10 ) { $m2 = "0" . $m2; }
95
96
#Put in format of mysql date YYYY-MM-DD
97
my $afterDate = $y2 . '-' . $m2 . '-' . $d2;
98
if ($verbose) { print "Date $offset Days Ago: $afterDate\n"; }
99
100
## 0.2 Get end date
101
#Adjust the offset to either a neg or pos number of days.
102
$offset = 0;
103
if ($end) { $offset = $end * -1; }
104
( $y2, $m2, $d2 ) = Add_Delta_Days( $y + 1900, $m + 1, $d, $offset );
105
if ( $m2 < 10 ) { $m2 = "0" . $m2; }
106
my $beforeDate = $y2 . '-' . $m2 . '-' . $d2;
107
if ($verbose) { print "Date $offset Days Ago: $beforeDate\n"; }
108
109
if ($name) {
110
111
    $sth = $dbh->prepare(
112
        "SELECT * FROM clubsAndServices WHERE clubsAndServices.title = ?");
113
    $sth->execute($name);
114
115
}
116
else {    ## No name given, process all items
117
118
    ## Grab the "New Items E-mail List" Archetype
119
    $sth = $dbh->prepare(
120
"SELECT * FROM clubsAndServicesArchetypes WHERE code = 'NEW_ITEMS_EMAIL_LIST'"
121
    );
122
    $sth->execute;
123
    my $archetype = $sth->fetchrow_hashref();
124
125
    ## Grab all the mailing lists
126
    $sth = $dbh->prepare(
127
        "SELECT * FROM clubsAndServices WHERE clubsAndServices.casaId = ?");
128
    $sth->execute( $archetype->{'casaId'} );
129
130
}
131
132
## For each mailing list, generate the list of new items, then get the subscribers, then mail the list to the subscribers
133
while ( my $mailingList = $sth->fetchrow_hashref() ) {
134
    ## Get the new Items
135
    if ($verbose) {
136
        print "###\nWorking On Mailing List: " . $mailingList->{'title'} . "\n";
137
    }
138
    my $itemtype   = $mailingList->{'casData1'};
139
    my $callnumber = $mailingList->{'casData2'};
140
    ## If either are empty, ignore them with a wildcard
141
    if ( !$itemtype )   { $itemtype   = '%'; }
142
    if ( !$callnumber ) { $callnumber = '%'; }
143
144
    my $sth2 = $dbh->prepare(
145
        "SELECT
146
             biblio.author,
147
             biblio.title,
148
             biblio.biblionumber,
149
             biblioitems.isbn,
150
             items.itemcallnumber
151
          FROM
152
             items, biblioitems, biblio
153
          WHERE
154
             biblio.biblionumber = biblioitems.biblionumber AND
155
             biblio.biblionumber = items.biblionumber AND
156
             biblioitems.itemtype LIKE ? AND
157
             items.itemcallnumber LIKE ? AND
158
             dateaccessioned >= ? AND
159
             dateaccessioned <= ?
160
        "
161
    );
162
    $sth2->execute( $itemtype, $callnumber, $afterDate, $beforeDate );
163
    my @newItems;
164
    while ( my $row = $sth2->fetchrow_hashref ) {
165
        $row->{'opacUrl'} = $opacUrl;
166
        push( @newItems, $row );
167
    }
168
    print Dumper (@newItems);
169
    $sth2->finish;
170
    my $newItems = \@newItems;
171
    my $template = Template->new();
172
173
    my $vars = {
174
        listTitle    => $mailingList->{'title'},
175
        newItemsLoop => $newItems,
176
    };
177
    my $email = $template->process( 'mailinglist.tt', $vars );
178
179
    ## Get all the members subscribed to this list
180
    $sth2 = $dbh->prepare(
181
        "SELECT * FROM clubsAndServicesEnrollments, borrowers
182
                         WHERE
183
                         borrowers.borrowernumber = clubsAndServicesEnrollments.borrowernumber AND
184
                         clubsAndServicesEnrollments.dateCanceled IS NULL AND
185
                         clubsAndServicesEnrollments.casId = ?"
186
    );
187
    $sth2->execute( $mailingList->{'casId'} );
188
    while ( my $borrower = $sth2->fetchrow_hashref() ) {
189
        if ($verbose) {
190
            print "Borrower Email: " . $borrower->{'email'} . "\n";
191
        }
192
193
        my $letter;
194
        $letter->{'title'} =
195
          'New Items @ Your Library: ' . $mailingList->{'title'};
196
        $letter->{'content'} = $email;
197
        $letter->{'code'}    = 'MAILINGLIST';
198
        C4::Message->enqueue( $letter, $borrower, 'email' );
199
    }
200
}
(-)a/misc/cronjobs/mailinglist/mailinglist.tt (+34 lines)
Line 0 Link Here
1
<html>
2
  <head></head>
3
  <body>
4
    <table>
5
      <h2>New Items @ Your Library!</h2>
6
      <h3>[% listTitle %]</h3>
7
8
       [% FOREACH item IN newItemsLoop %]
9
           <a href="[% item.opacUrl %]/cgi-bin/koha/opac-detail.pl?bib=[% item.biblionumber | uri %]">
10
               <h2 style="color:#000000;font:bold 15px Verdana, Geneva, Arial, Helvetica, sans-serif;border-bottom:3px solid #ffcc33">
11
                   [% item.title %]
12
               </h2>
13
           </a>
14
15
           <table border="0" cellpadding="2" cellspacing="0" width="92%" align="center">
16
               <tr>
17
                   <td valign="top">
18
                       <a href="[% item.opacUrl %]/cgi-bin/koha/opac-detail.pl?bib=[% item.biblionumber | uri %]">View in the catalog.</a>
19
                   </td>
20
21
                   <td valign="top">
22
                       <p style="color:#000000">
23
                           <ul>
24
                               <li>Author: [% item.author %]</li>
25
                               <li>ISBN: [% item.isbn %]</li>
26
                               <li>Call Number: [% item.itemcallnumber %]</li>
27
                           </ul>
28
                       </p>
29
                   </td>
30
               </tr>
31
           </table>
32
       [% END %]
33
  </body>
34
</html>
(-)a/opac/opac-clubsAndServices-enroll.pl (+146 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# This file is part of Koha.
4
#
5
# Koha is free software; you can redistribute it and/or modify it under the
6
# terms of the GNU General Public License as published by the Free Software
7
# Foundation; either version 2 of the License, or (at your option) any later
8
# version.
9
#
10
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
11
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
13
#
14
# You should have received a copy of the GNU General Public License along with
15
# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
16
# Suite 330, Boston, MA  02111-1307 USA
17
18
19
use strict;
20
21
use CGI;
22
23
use C4::Auth;
24
use C4::Koha;
25
use C4::Circulation;
26
use C4::Reserves;
27
use C4::Members;
28
use C4::Output;
29
use C4::Biblio;
30
use C4::Items;
31
use C4::Dates qw/format_date/;
32
use C4::Letters;
33
use C4::Branch; # GetBranches
34
use C4::ClubsAndServices;
35
36
my $query = new CGI;
37
38
my ($template, $borrowernumber, $cookie)
39
    = get_template_and_user({template_name => "opac-clubsAndServices-enroll.tmpl",
40
                             query => $query,
41
                             type => "opac",
42
                             authnotrequired => 0,
43
                             flagsrequired => {borrow => 1},
44
                             debug => 1,
45
                             });
46
47
# get borrower information ....
48
my ( $borr ) = GetMemberDetails( $borrowernumber );
49
50
$borr->{'dateenrolled'} = format_date( $borr->{'dateenrolled'} );
51
$borr->{'expiry'}       = format_date( $borr->{'expiry'} );
52
$borr->{'dateofbirth'}  = format_date( $borr->{'dateofbirth'} );
53
$borr->{'ethnicity'}    = fixEthnicity( $borr->{'ethnicity'} );
54
55
56
if ( $query->param('action') eq 'enroll' ) { ## We were passed the necessary fields from the enrollment page.
57
  my $casId = $query->param('casId');
58
  my $casaId = $query->param('casaId');
59
  my $data1 = $query->param('data1');
60
  my $data2 = $query->param('data2');
61
  my $data3 = $query->param('data3');
62
63
  my $dateEnrolled; # Will default to Today
64
65
  my ( $success, $errorCode, $errorMessage ) = EnrollInClubOrService( $casaId, $casId, '', $dateEnrolled, $data1, $data2, $data3, '', $borrowernumber  );
66
67
  $template->param(
68
    previousActionEnroll => 1,
69
  );
70
71
  if ( $success ) {
72
    $template->param( enrollSuccess => 1 );
73
  } else {
74
    $template->param( enrollFailure => 1 );
75
    $template->param( failureMessage => $errorMessage );
76
  }
77
78
} elsif ( DoesEnrollmentRequireData( $query->param('casaId') ) ) { ## We were not passed any data, and the service requires extra data
79
  my ( $casId, $casaId, $casTitle, $casDescription, $casStartDate, $casEndDate, $casTimestamp ) = GetClubOrService( $query->param('casId') );
80
  my ( $casaId, $casaType, $casaTitle, $casaDescription, $casaPublicEnrollment,
81
       $casData1Title, $casData2Title, $casData3Title,
82
       $caseData1Title, $caseData2Title, $caseData3Title,
83
       $casData1Desc, $casData2Desc, $casData3Desc,
84
       $caseData1Desc, $caseData2Desc, $caseData3Desc,
85
       $timestamp )= GetClubOrServiceArchetype( $casaId );
86
  $template->param(
87
                  casId => $casId,
88
                  casTitle => $casTitle,
89
                  casDescription => $casDescription,
90
                  casStartDate => $casStartDate,
91
                  casEndDate => $casEndDate,
92
                  casTimeStamp => $casTimestamp,
93
                  casaId => $casaId,
94
                  casaType => $casaType,
95
                  casaTitle => $casaTitle,
96
                  casaDescription => $casaDescription,
97
                  casaPublicEnrollment => $casaPublicEnrollment,
98
99
                  borrowernumber => $borrowernumber,
100
                  );
101
102
  if ( $caseData1Title ) {
103
    $template->param( caseData1Title => $caseData1Title );
104
  }
105
  if ( $caseData2Title ) {
106
    $template->param( caseData2Title => $caseData2Title );
107
  }
108
  if ( $caseData3Title ) {
109
    $template->param( caseData3Title => $caseData3Title );
110
  }
111
112
  if ( $caseData1Desc ) {
113
    $template->param( caseData1Desc => $caseData1Desc );
114
  }
115
  if ( $caseData2Desc ) {
116
    $template->param( caseData2Desc => $caseData2Desc );
117
  }
118
  if ( $caseData3Desc ) {
119
    $template->param( caseData3Desc => $caseData3Desc );
120
  }
121
122
} else { ## We were not passed any data, but the enrollment does not require any
123
124
  my $casId = $query->param('casId');
125
  my $casaId = $query->param('casaId');
126
127
  my $dateEnrolled; # Will default to Today
128
129
  my ( $success, $errorCode, $errorMessage ) = EnrollInClubOrService( $casaId, $casId, '', $dateEnrolled, '', '', '', '', $borrowernumber  );
130
  $template->param(
131
    previousActionEnroll => 1,
132
  );
133
134
  if ( $success ) {
135
    $template->param( enrollSuccess => 1 );
136
  } else {
137
    $template->param( enrollFailure => 1 );
138
    $template->param( failureMessage => $errorMessage );
139
  }
140
141
142
}
143
144
$template->param( clubs_services => 1 );
145
146
output_html_with_http_headers $query, $cookie, $template->output;
(-)a/opac/opac-clubsAndServices.pl (-1 / +69 lines)
Line 0 Link Here
0
- 
1
#!/usr/bin/perl
2
3
# This file is part of Koha.
4
#
5
# Koha is free software; you can redistribute it and/or modify it under the
6
# terms of the GNU General Public License as published by the Free Software
7
# Foundation; either version 2 of the License, or (at your option) any later
8
# version.
9
#
10
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
11
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
13
#
14
# You should have received a copy of the GNU General Public License along with
15
# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
16
# Suite 330, Boston, MA  02111-1307 USA
17
18
19
use strict;
20
21
use CGI;
22
23
use C4::Auth;
24
use C4::Koha;
25
use C4::Circulation;
26
use C4::Reserves;
27
use C4::Members;
28
use C4::Output;
29
use C4::Biblio;
30
use C4::Items;
31
use C4::Dates qw/format_date/;
32
use C4::Letters;
33
use C4::Branch; # GetBranches
34
use C4::ClubsAndServices;
35
36
my $query = new CGI;
37
38
my ($template, $borrowernumber, $cookie)
39
    = get_template_and_user({template_name => "opac-clubsAndServices.tmpl",
40
			     query => $query,
41
			     type => "opac",
42
			     authnotrequired => 0,
43
			     flagsrequired => {borrow => 1},
44
			     debug => 1,
45
			     });
46
47
# get borrower information ....
48
my ( $borr ) = GetMemberDetails( $borrowernumber );
49
50
$borr->{'dateenrolled'} = format_date( $borr->{'dateenrolled'} );
51
$borr->{'expiry'}       = format_date( $borr->{'expiry'} );
52
$borr->{'dateofbirth'}  = format_date( $borr->{'dateofbirth'} );
53
$borr->{'ethnicity'}    = fixEthnicity( $borr->{'ethnicity'} );
54
55
if ( $query->param('action') eq 'cancel' ) { ## Cancel the enrollment in the passed club or service
56
  CancelClubOrServiceEnrollment( $query->param('caseId') );
57
}
58
59
## Get the borrowers current clubs & services
60
my $enrolledClubsAndServices = GetEnrolledClubsAndServices( $borrowernumber );
61
$template->param( enrolledClubsAndServicesLoop => $enrolledClubsAndServices );
62
63
## Get clubs & services the borrower can enroll in from the OPAC
64
my $enrollableClubsAndServices = GetPubliclyEnrollableClubsAndServices( $borrowernumber );
65
$template->param( enrollableClubsAndServicesLoop => $enrollableClubsAndServices );
66
67
$template->param( clubs_services => 1 );
68
69
output_html_with_http_headers $query, $cookie, $template->output;

Return to bug 7572