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

(-)a/C4/ClubsAndServices.pm (+1192 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 2007 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 strict;
27
28
require Exporter;
29
30
use C4::Context;
31
32
use DBI;
33
34
use vars qw($VERSION @ISA @EXPORT);
35
36
# set the version for version checking
37
$VERSION = 0.01;
38
39
=head1 NAME
40
41
C4::ClubsAndServices - Functions for managing clubs and services
42
43
=head1 FUNCTIONS
44
45
=over 2
46
47
=cut
48
49
@ISA = qw( Exporter );
50
@EXPORT = qw( 
51
  AddClubOrServiceArchetype  
52
  UpdateClubOrServiceArchetype
53
  DeleteClubOrServiceArchetype
54
  
55
  AddClubOrService
56
  UpdateClubOrService
57
  DeleteClubOrService
58
  
59
  EnrollInClubOrService
60
  GetEnrollments
61
  GetClubsAndServices
62
  GetClubOrService
63
  GetClubsAndServicesArchetypes
64
  GetClubOrServiceArchetype
65
  DoesEnrollmentRequireData
66
  CancelClubOrServiceEnrollment
67
  GetEnrolledClubsAndServices
68
  GetPubliclyEnrollableClubsAndServices
69
  GetAllEnrollableClubsAndServices
70
  GetCasEnrollments
71
72
  ReserveForBestSellersClub
73
  
74
  getTodayMysqlDateFormat
75
);
76
77
## function AddClubOrServiceArchetype
78
## Creates a new archetype for a club or service
79
## An archetype is something after which other things a patterned,
80
## For example, you could create a 'Summer Reading Club' club archtype
81
## which is then used to create an individual 'Summer Reading Club' 
82
## *for each library* in your system.
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
## Output:
111
##   $success: 1 if all database operations were successful, 0 otherwise
112
##   $errorCode: Code for reason of failure, good for translating errors in templates
113
##   $errorMessage: English description of error
114
sub AddClubOrServiceArchetype {
115
  my ( $type, $title, $description, $publicEnrollment, 
116
       $casData1Title, $casData2Title, $casData3Title, 
117
       $caseData1Title, $caseData2Title, $caseData3Title, 
118
       $casData1Desc, $casData2Desc, $casData3Desc, 
119
       $caseData1Desc, $caseData2Desc, $caseData3Desc, 
120
       $caseRequireEmail, $branchcode ) = @_;
121
122
  ## Check for all neccessary parameters
123
  if ( ! $type ) {
124
    return ( 0, 1, "No Type Given" );
125
  } 
126
  if ( ! $title ) {
127
    return ( 0, 2, "No Title Given" );
128
  } 
129
  if ( ! $description ) {
130
    return ( 0, 3, "No Description Given" );
131
  } 
132
133
  my $success = 1;
134
135
  my $dbh = C4::Context->dbh;
136
137
  my $sth;
138
  $sth = $dbh->prepare("INSERT INTO clubsAndServicesArchetypes ( casaId, type, title, description, publicEnrollment, caseRequireEmail, branchcode, last_updated ) 
139
                        VALUES ( NULL, ?, ?, ?, ?, ?, ?, CURRENT_TIMESTAMP)");
140
  $sth->execute( $type, $title, $description, $publicEnrollment, $caseRequireEmail, $branchcode ) or $success = 0;
141
  my $casaId = $dbh->{'mysql_insertid'};
142
  $sth->finish;
143
144
  if ( $casData1Title ) {
145
    $sth = $dbh->prepare("UPDATE clubsAndServicesArchetypes SET casData1Title = ? WHERE casaId = ?");
146
    $sth->execute( $casData1Title, $casaId ) or $success = 0;
147
    $sth->finish;
148
  }
149
  if ( $casData2Title ) {
150
    $sth = $dbh->prepare("UPDATE clubsAndServicesArchetypes SET casData2Title = ? WHERE casaId = ?");
151
    $sth->execute( $casData2Title, $casaId ) or $success = 0;
152
    $sth->finish;
153
  }
154
  if ( $casData3Title ) {
155
    $sth = $dbh->prepare("UPDATE clubsAndServicesArchetypes SET casData3Title = ? WHERE casaId = ?");
156
    $sth->execute( $casData3Title, $casaId ) or $success = 0;
157
    $sth->finish;
158
  }
159
160
  
161
  if ( $caseData1Title ) {
162
    $sth = $dbh->prepare("UPDATE clubsAndServicesArchetypes SET caseData1Title = ? WHERE casaId = ?");
163
    $sth->execute( $caseData1Title, $casaId ) or $success = 0;
164
    $sth->finish;
165
  }
166
  if ( $caseData2Title ) {
167
    $sth = $dbh->prepare("UPDATE clubsAndServicesArchetypes SET caseData2Title = ? WHERE casaId = ?");
168
    $sth->execute( $caseData2Title, $casaId ) or $success = 0;
169
    $sth->finish;
170
  }
171
  if ( $caseData3Title ) {
172
    $sth = $dbh->prepare("UPDATE clubsAndServicesArchetypes SET caseData3Title = ? WHERE casaId = ?");
173
    $sth->execute( $caseData3Title, $casaId ) or $success = 0;
174
    $sth->finish;
175
  }
176
177
  if ( $casData1Desc ) {
178
    $sth = $dbh->prepare("UPDATE clubsAndServicesArchetypes SET casData1Desc = ? WHERE casaId = ?");
179
    $sth->execute( $casData1Desc, $casaId ) or $success = 0;
180
    $sth->finish;
181
  }
182
  if ( $casData2Desc ) {
183
    $sth = $dbh->prepare("UPDATE clubsAndServicesArchetypes SET casData2Desc = ? WHERE casaId = ?");
184
    $sth->execute( $casData2Desc, $casaId ) or $success = 0;
185
    $sth->finish;
186
  }
187
  if ( $casData3Desc ) {
188
    $sth = $dbh->prepare("UPDATE clubsAndServicesArchetypes SET casData3Desc = ? WHERE casaId = ?");
189
    $sth->execute( $casData3Desc, $casaId ) or $success = 0;
190
    $sth->finish;
191
  }
192
  
193
  if ( $caseData1Desc ) {
194
    $sth = $dbh->prepare("UPDATE clubsAndServicesArchetypes SET caseData1Desc = ? WHERE casaId = ?");
195
    $sth->execute( $caseData1Desc, $casaId ) or $success = 0;
196
    $sth->finish;
197
  }
198
  if ( $caseData2Desc ) {
199
    $sth = $dbh->prepare("UPDATE clubsAndServicesArchetypes SET caseData2Desc = ? WHERE casaId = ?");
200
    $sth->execute( $caseData2Desc, $casaId ) or $success = 0;
201
    $sth->finish;
202
  }
203
  if ( $caseData3Desc ) {
204
    $sth = $dbh->prepare("UPDATE clubsAndServicesArchetypes SET caseData3Desc = ? WHERE casaId = ?");
205
    $sth->execute( $caseData3Desc, $casaId ) or $success = 0;
206
    $sth->finish;
207
  }
208
209
  my ( $errorCode, $errorMessage );
210
  if ( ! $success ) {
211
    $errorMessage = "Database Failure";
212
    $errorCode = 4;
213
  }
214
  
215
  return( $success, $errorCode, $errorMessage );
216
  
217
}
218
219
## function UpdateClubOrServiceArchetype
220
## Updates an archetype for a club or service
221
## Input:
222
##   $casaId: id of the archetype to be updated
223
##   $type : 'club' or 'service', could be extended to add more types
224
##   $title: short description of the club or service
225
##   $description: long description of the club or service
226
##   $publicEnrollment: If true, any borrower should be able
227
##       to enroll in club or service from opac. If false,
228
##       Only a librarian should be able to enroll a borrower
229
##       in the club or service.
230
##   $casData1Title: explanation of what is stored in
231
##      clubsAndServices.casData1Title
232
##   $casData2Title: same but for casData2Title
233
##   $casData3Title: same but for casData3Title
234
##   $caseData1Title: explanation of what is stored in
235
##     clubsAndServicesEnrollment.data1
236
##   $caseData2Title: Same but for data2
237
##   $caseData3Title: Same but for data3
238
##   $casData1Desc: Long explanation of what is stored in
239
##      clubsAndServices.casData1Title
240
##   $casData2Desc: same but for casData2Title
241
##   $casData3Desc: same but for casData3Title
242
##   $caseData1Desc: Long explanation of what is stored in
243
##     clubsAndServicesEnrollment.data1
244
##   $caseData2Desc: Same but for data2
245
##   $caseData3Desc: Same but for data3
246
##   $caseRequireEmail: If 1, enrollment in clubs or services based on this archetype will require a valid e-mail address field in the borrower
247
##	record as specified in the syspref AutoEmailPrimaryAddress
248
## Output:
249
##   $success: 1 if all database operations were successful, 0 otherwise
250
##   $errorCode: Code for reason of failure, good for translating errors in templates
251
##   $errorMessage: English description of error
252
sub UpdateClubOrServiceArchetype {
253
  my ( $casaId, $type, $title, $description, $publicEnrollment, 
254
       $casData1Title, $casData2Title, $casData3Title, 
255
       $caseData1Title, $caseData2Title, $caseData3Title,
256
       $casData1Desc, $casData2Desc, $casData3Desc, 
257
       $caseData1Desc, $caseData2Desc, $caseData3Desc,
258
       $caseRequireEmail,
259
     ) = @_;
260
261
  ## Check for all neccessary parameters
262
  if ( ! $casaId ) {
263
    return ( 0, 1, "No Id Given" );
264
  }
265
  if ( ! $type ) {
266
    return ( 0, 2, "No Type Given" );
267
  } 
268
  if ( ! $title ) {
269
    return ( 0, 3, "No Title Given" );
270
  } 
271
  if ( ! $description ) {
272
    return ( 0, 4, "No Description Given" );
273
  } 
274
275
  my $success = 1;
276
277
  my $dbh = C4::Context->dbh;
278
279
  my $sth;
280
  $sth = $dbh->prepare("UPDATE clubsAndServicesArchetypes 
281
                        SET 
282
                        type = ?, title = ?, description = ?, publicEnrollment = ?, 
283
                        casData1Title = ?, casData2Title = ?, casData3Title = ?,
284
                        caseData1Title = ?, caseData2Title = ?, caseData3Title = ?, 
285
                        casData1Desc = ?, casData2Desc = ?, casData3Desc = ?,
286
                        caseData1Desc = ?, caseData2Desc = ?, caseData3Desc = ?, caseRequireEmail = ?,
287
                        last_updated = NOW() WHERE casaId = ?");
288
289
  $sth->execute( $type, $title, $description, $publicEnrollment, 
290
                 $casData1Title, $casData2Title, $casData3Title, 
291
                 $caseData1Title, $caseData2Title, $caseData3Title, 
292
                 $casData1Desc, $casData2Desc, $casData3Desc, 
293
                 $caseData1Desc, $caseData2Desc, $caseData3Desc, 
294
                 $caseRequireEmail, $casaId ) 
295
      or return ( $success = 0, my $errorCode = 6, my $errorMessage = $sth->errstr() );
296
  $sth->finish;
297
  
298
  return $success;
299
  
300
}
301
302
## function DeleteClubOrServiceArchetype
303
## Deletes an Archetype of the given id
304
## and all Clubs or Services based on it,
305
## and all Enrollments based on those clubs
306
## or services.
307
## Input:
308
##   $casaId : id of the Archtype to be deleted
309
## Output:
310
##   $success : 1 on successful deletion, 0 otherwise
311
sub DeleteClubOrServiceArchetype {
312
  my ( $casaId ) = @_;
313
314
  ## Paramter check
315
  if ( ! $casaId ) {
316
    return 0;
317
  }
318
  
319
  my $success = 1;
320
321
  my $dbh = C4::Context->dbh;
322
323
  my $sth;
324
325
  $sth = $dbh->prepare("DELETE FROM clubsAndServicesEnrollments WHERE casaId = ?");
326
  $sth->execute( $casaId ) or $success = 0;
327
  $sth->finish;
328
329
  $sth = $dbh->prepare("DELETE FROM clubsAndServices WHERE casaId = ?");
330
  $sth->execute( $casaId ) or $success = 0;
331
  $sth->finish;
332
333
  $sth = $dbh->prepare("DELETE FROM clubsAndServicesArchetypes WHERE casaId = ?");
334
  $sth->execute( $casaId ) or $success = 0;
335
  $sth->finish;
336
337
  return 1;
338
}
339
340
## function AddClubOrService
341
## Creates a new club or service in the database
342
## Input:
343
##   $type: 'club' or 'service', other types may be added as necessary.
344
##   $title: Short description of the club or service
345
##   $description: Long description of the club or service
346
##   $casData1: The data described in case.casData1Title
347
##   $casData2: The data described in case.casData2Title
348
##   $casData3: The data described in case.casData3Title
349
##   $startDate: The date the club or service begins ( Optional: Defaults to TODAY() )
350
##   $endDate: The date the club or service ends ( Optional )
351
##   $branchcode: Branch that created this club or service ( Optional: NULL is system-wide )
352
## Output:
353
##   $success: 1 on successful add, 0 on failure
354
##   $errorCode: Code for reason of failure, good for translating errors in templates
355
##   $errorMessage: English description of error
356
sub AddClubOrService {
357
  my ( $casaId, $title, $description, $casData1, $casData2, $casData3, $startDate, $endDate, $branchcode ) = @_;
358
359
  ## Check for all neccessary parameters
360
  if ( ! $casaId ) {
361
    return ( 0, 1, "No Archetype Given" );
362
  } 
363
  if ( ! $title ) {
364
    return ( 0, 2, "No Title Given" );
365
  } 
366
  if ( ! $description ) {
367
    return ( 0, 3, "No Description Given" );
368
  } 
369
  
370
  my $success = 1;
371
372
  if ( ! $startDate ) {
373
    $startDate = getTodayMysqlDateFormat();
374
  }
375
  
376
  my $dbh = C4::Context->dbh;
377
378
  my $sth;
379
  if ( $endDate ) {
380
    $sth = $dbh->prepare("INSERT INTO clubsAndServices ( casId, casaId, title, description, casData1, casData2, casData3, startDate, endDate, branchcode, last_updated ) 
381
                             VALUES ( NULL, ?, ?, ?, ?, ?, ?, ?, ?, ?, CURRENT_TIMESTAMP)");
382
    $sth->execute( $casaId, $title, $description, $casData1, $casData2, $casData3, $startDate, $endDate, $branchcode ) or $success = 0;
383
  } else {
384
    $sth = $dbh->prepare("INSERT INTO clubsAndServices ( casId, casaId, title, description, casData1, casData2, casData3, startDate, branchcode, last_updated ) 
385
                             VALUES ( NULL, ?, ?, ?, ?, ?, ?, ?, ?, CURRENT_TIMESTAMP)");
386
    $sth->execute( $casaId, $title, $description, $casData1, $casData2, $casData3, $startDate, $branchcode ) or $success = 0;
387
  }
388
  $sth->finish;
389
390
  my ( $errorCode, $errorMessage );
391
  if ( ! $success ) {
392
    $errorMessage = "Database Failure";
393
    $errorCode = 5;
394
  }
395
  
396
  return( $success, $errorCode, $errorMessage );
397
}
398
399
## function UpdateClubOrService
400
## Updates club or service in the database
401
## Input:
402
##   $casId: id of the club or service to be updated
403
##   $type: 'club' or 'service', other types may be added as necessary.
404
##   $title: Short description of the club or service
405
##   $description: Long description of the club or service
406
##   $casData1: The data described in case.casData1Title
407
##   $casData2: The data described in case.casData2Title
408
##   $casData3: The data described in case.casData3Title
409
##   $startDate: The date the club or service begins ( Optional: Defaults to TODAY() )
410
##   $endDate: The date the club or service ends ( Optional )
411
## Output:
412
##   $success: 1 on successful add, 0 on failure
413
##   $errorCode: Code for reason of failure, good for translating errors in templates
414
##   $errorMessage: English description of error
415
sub UpdateClubOrService {
416
  my ( $casId, $casaId, $title, $description, $casData1, $casData2, $casData3, $startDate, $endDate ) = @_;
417
418
  ## Check for all neccessary parameters
419
  if ( ! $casId ) {
420
    return ( 0, 1, "No casId Given" );
421
  }
422
  if ( ! $casaId ) {
423
    return ( 0, 2, "No Archetype Given" );
424
  } 
425
  if ( ! $title ) {
426
    return ( 0, 3, "No Title Given" );
427
  } 
428
  if ( ! $description ) {
429
    return ( 0, 4, "No Description Given" );
430
  } 
431
  
432
  my $success = 1;
433
434
  if ( ! $startDate ) {
435
    $startDate = getTodayMysqlDateFormat();
436
  }
437
  
438
  my $dbh = C4::Context->dbh;
439
440
  my $sth;
441
  if ( $endDate ) {
442
    $sth = $dbh->prepare("UPDATE clubsAndServices SET casaId = ?, title = ?, description = ?, casData1 = ?, casData2 = ?, casData3 = ?, startDate = ?, endDate = ?, last_updated = NOW() WHERE casId = ?");
443
    $sth->execute( $casaId, $title, $description, $casData1, $casData2, $casData3, $startDate, $endDate, $casId ) or return( my $success = 0, my $errorCode = 5, my $errorMessage = $sth->errstr() );
444
  } else {
445
    $sth = $dbh->prepare("UPDATE clubsAndServices SET casaId = ?, title = ?, description = ?, casData1 = ?, casData2 = ?, casData3 = ?, startDate = ?, endDate = NULL, last_updated = NOW() WHERE casId = ?");
446
    $sth->execute( $casaId, $title, $description, $casData1, $casData2, $casData3, $startDate, $casId ) or return( my $success = 0, my $errorCode = 5, my $errorMessage = $sth->errstr() );
447
  }
448
  $sth->finish;
449
450
  my ( $errorCode, $errorMessage );
451
  if ( ! $success ) {
452
    $errorMessage = "Database Failure";
453
    $errorCode = 5;
454
  }
455
  
456
  return( $success, $errorCode, $errorMessage );
457
}
458
459
## function DeleteClubOrService
460
## Deletes a club or service of the given id
461
## and all enrollments based on it.
462
## Input:
463
##   $casId : id of the club or service to be deleted
464
## Output:
465
##   $success : 1 on successful deletion, 0 otherwise
466
sub DeleteClubOrService {
467
  my ( $casId ) = @_;
468
469
  if ( ! $casId ) {
470
    return 0;
471
  }
472
  
473
  my $success = 1;
474
475
  my $dbh = C4::Context->dbh;
476
477
  my $sth;
478
  $sth = $dbh->prepare("DELETE FROM clubsAndServicesEnrollments WHERE casId = ?");
479
  $sth->execute( $casId ) or $success = 0;
480
  $sth->finish;
481
482
  $sth = $dbh->prepare("DELETE FROM clubsAndServices WHERE casId = ?");
483
  $sth->execute( $casId ) or $success = 0;
484
  $sth->finish;
485
  
486
  return 1;
487
}
488
489
## function EnrollInClubOrService
490
## Enrolls a borrower in a given club or service
491
## Input:
492
##   $casId: The unique id of the club or service being enrolled in
493
##   $borrowerCardnumber: The card number of the enrolling borrower
494
##   $dateEnrolled: Date the enrollment begins ( Optional: Defauls to TODAY() )
495
##   $data1: The data described in ClubsAndServicesArchetypes.caseData1Title
496
##   $data2: The data described in ClubsAndServicesArchetypes.caseData2Title
497
##   $data3: The data described in ClubsAndServicesArchetypes.caseData3Title
498
##   $branchcode: The branch where this club or service enrollment is,
499
##   $borrowernumber: ( Optional: Alternative to using $borrowerCardnumber )
500
## Output:
501
##   $success: 1 on successful enrollment, 0 on failure
502
##   $errorCode: Code for reason of failure, good for translating errors in templates
503
##   $errorMessage: English description of error
504
sub EnrollInClubOrService {
505
  my ( $casaId, $casId, $borrowerCardnumber, $dateEnrolled, $data1, $data2, $data3, $branchcode, $borrowernumber ) = @_;
506
507
  ## Check for all neccessary parameters
508
  unless ( $casaId ) {
509
    return ( 0, 1, "No casaId Given" );
510
  }
511
  unless ( $casId ) {
512
    return ( 0, 2, "No casId Given" );
513
  } 
514
  unless ( ( $borrowerCardnumber || $borrowernumber ) ) {
515
    return ( 0, 3, "No Borrower Given" );
516
  } 
517
  
518
  my $member;
519
  if ( $borrowerCardnumber ) {
520
    $member = C4::Members::GetMember( cardnumber => $borrowerCardnumber );
521
  } elsif ( $borrowernumber ) {
522
    $member = C4::Members::GetMember( borrowernumber => $borrowernumber );
523
  } else {
524
    return ( 0, 3, "No Borrower Given" );
525
  }
526
  
527
  unless ( $member ) {
528
    return ( 0, 4, "No Matching Borrower Found" );
529
  }
530
531
  my $casa = GetClubOrServiceArchetype( $casaId, 1 );
532
  if ( $casa->{'caseRequireEmail'} ) {
533
    my $AutoEmailPrimaryAddress = C4::Context->preference('AutoEmailPrimaryAddress');    
534
    unless( $member->{ $AutoEmailPrimaryAddress } ) {
535
      return( 0, 4, "Email Address Required: No Valid Email Address In Borrower Record" );
536
    }
537
  }
538
  
539
  $borrowernumber = $member->{'borrowernumber'};
540
  
541
  if ( isEnrolled( $casId, $borrowernumber ) ) { return ( 0, 5, "Member is already enrolled!" ); }
542
543
  if ( ! $dateEnrolled ) {
544
    $dateEnrolled = getTodayMysqlDateFormat();
545
  }
546
547
  my $dbh = C4::Context->dbh;
548
  my $sth = $dbh->prepare("INSERT INTO clubsAndServicesEnrollments ( caseId, casaId, casId, borrowernumber, data1, data2, data3, dateEnrolled, dateCanceled, last_updated, branchcode)
549
                           VALUES ( NULL, ?, ?, ?, ?, ?, ?, ?, NULL, NOW(), ? )");
550
  $sth->execute( $casaId, $casId, $borrowernumber, $data1, $data2, $data3, $dateEnrolled, $branchcode ) or return( my $success = 0, my $errorCode = 4, my $errorMessage = $sth->errstr() );
551
  $sth->finish;
552
  
553
  return $success = 1;
554
}
555
556
## function GetEnrollments
557
## Returns information about the clubs and services
558
##   the given borrower is enrolled in.
559
## Input:
560
##   $borrowernumber: The borrowernumber of the borrower
561
## Output:
562
##   $results: Reference to an array of associated arrays
563
sub GetEnrollments {
564
  my ( $borrowernumber ) = @_;
565
566
  my $dbh = C4::Context->dbh;
567
  
568
  my $sth = $dbh->prepare("SELECT * FROM clubsAndServices, clubsAndServicesEnrollments 
569
                           WHERE clubsAndServices.casId = clubsAndServicesEnrollments.casId
570
                           AND clubsAndServicesEnrollments.borrowernumber = ?");
571
  $sth->execute( $borrowernumber ) or return 0;
572
  
573
  my @results;
574
  while ( my $row = $sth->fetchrow_hashref ) {
575
    push( @results , $row );
576
  }
577
  
578
  $sth->finish;
579
  
580
  return \@results;
581
}
582
583
## function GetCasEnrollments
584
## Returns information about the clubs and services borrowers that are enrolled
585
## Input:
586
##   $casId: The id of the club or service to look up enrollments for
587
## Output:
588
##   $results: Reference to an array of associated arrays
589
sub GetCasEnrollments {
590
  my ( $casId ) = @_;
591
592
  my $dbh = C4::Context->dbh;
593
  
594
  my $sth = $dbh->prepare("SELECT * FROM clubsAndServicesEnrollments, borrowers
595
                           WHERE clubsAndServicesEnrollments.borrowernumber = borrowers.borrowernumber
596
                           AND clubsAndServicesEnrollments.casId = ? AND dateCanceled IS NULL
597
                           ORDER BY surname, firstname");
598
  $sth->execute( $casId ) or return 0;
599
  
600
  my @results;
601
  while ( my $row = $sth->fetchrow_hashref ) {
602
    push( @results , $row );
603
  }
604
  
605
  $sth->finish;
606
  
607
  return \@results;
608
}
609
610
## function GetClubsAndServices
611
## Returns information about clubs and services
612
## Input:
613
##   $type: ( Optional: 'club' or 'service' )
614
##   $branchcode: ( Optional: Get clubs and services only created by this branch )
615
##   $orderby: ( Optional: name of column to sort by )
616
## Output:
617
##   $results: 
618
##     Reference to an array of associated arrays
619
sub GetClubsAndServices {
620
  my ( $type, $branchcode, $orderby ) = @_;
621
  $orderby = 'startDate DESC' unless ( $orderby );
622
623
  my $dbh = C4::Context->dbh;
624
625
  my ( $sth, @results );
626
  if ( $type && $branchcode ) {
627
    $sth = $dbh->prepare("SELECT clubsAndServices.casId, 
628
                                 clubsAndServices.casaId,
629
                                 clubsAndServices.title, 
630
                                 clubsAndServices.description, 
631
                                 clubsAndServices.casData1,
632
                                 clubsAndServices.casData2,
633
                                 clubsAndServices.casData3,
634
                                 clubsAndServices.startDate, 
635
                                 clubsAndServices.endDate,
636
                                 clubsAndServices.last_updated,
637
                                 clubsAndServices.branchcode
638
                          FROM clubsAndServices, clubsAndServicesArchetypes 
639
                          WHERE 
640
                            clubsAndServices.casaId = clubsAndServicesArchetypes.casaId 
641
                            AND clubsAndServices.branchcode = ?
642
                            AND clubsAndServicesArchetypes.type = ? 
643
                          ORDER BY $orderby
644
    ");
645
    $sth->execute( $branchcode, $type ) or return 0;
646
    
647
  } elsif ( $type ) {
648
    $sth = $dbh->prepare("SELECT clubsAndServices.casId, 
649
                                 clubsAndServices.casaId,
650
                                 clubsAndServices.title, 
651
                                 clubsAndServices.description, 
652
                                 clubsAndServices.casData1,
653
                                 clubsAndServices.casData2,
654
                                 clubsAndServices.casData3,
655
                                 clubsAndServices.startDate, 
656
                                 clubsAndServices.endDate,
657
                                 clubsAndServices.last_updated,
658
                                 clubsAndServices.branchcode
659
                          FROM clubsAndServices, clubsAndServicesArchetypes 
660
                          WHERE
661
                            clubsAndServices.casaId = clubsAndServicesArchetypes.casaId 
662
                            AND clubsAndServicesArchetypes.type = ? 
663
                          ORDER BY $orderby
664
    ");
665
    $sth->execute( $type ) or return 0;
666
    
667
  } elsif ( $branchcode ) {
668
    $sth = $dbh->prepare("SELECT clubsAndServices.casId, 
669
                                 clubsAndServices.casaId,
670
                                 clubsAndServices.title, 
671
                                 clubsAndServices.description, 
672
                                 clubsAndServices.casData1,
673
                                 clubsAndServices.casData2,
674
                                 clubsAndServices.casData3,
675
                                 clubsAndServices.startDate, 
676
                                 clubsAndServices.endDate,
677
                                 clubsAndServices.last_updated,
678
                                 clubsAndServices.branchcode
679
                          FROM clubsAndServices, clubsAndServicesArchetypes 
680
                          WHERE 
681
                            clubsAndServices.casaId = clubsAndServicesArchetypes.casaId 
682
                            AND clubsAndServices.branchcode = ? 
683
                          ORDER BY $orderby
684
    ");
685
    $sth->execute( $branchcode ) or return 0;
686
    
687
  } else { ## Get all clubs and services
688
    $sth = $dbh->prepare("SELECT * FROM clubsAndServices ORDER BY $orderby");
689
    $sth->execute() or return 0;  
690
  }
691
692
  while ( my $row = $sth->fetchrow_hashref ) {
693
    push( @results , $row );
694
  }
695
696
  $sth->finish;
697
  
698
  return \@results;
699
  
700
}
701
702
703
## function GetClubOrService
704
## Returns information about a club or service
705
## Input:
706
##   $casId: Id of club or service to get
707
## Output:
708
##   $results: 
709
##     $casId, $casaId, $title, $description, $casData1, $casData2, $casData3, $startDate, $endDate, $last_updated, $branchcode
710
sub GetClubOrService {
711
  my ( $casId ) = @_;
712
713
  my $dbh = C4::Context->dbh;
714
715
  my ( $sth, @results );
716
  $sth = $dbh->prepare("SELECT * FROM clubsAndServices WHERE casId = ?");
717
  $sth->execute( $casId ) or return 0;
718
    
719
  my $row = $sth->fetchrow_hashref;
720
  
721
  $sth->finish;
722
  
723
  return (
724
      $$row{'casId'},
725
      $$row{'casaId'},
726
      $$row{'title'},
727
      $$row{'description'},
728
      $$row{'casData1'},
729
      $$row{'casData2'},
730
      $$row{'casData3'},
731
      $$row{'startDate'},
732
      $$row{'endDate'},
733
      $$row{'last_updated'},
734
      $$row{'branchcode'}
735
  );
736
    
737
}
738
739
## function GetClubsAndServicesArchetypes
740
## Returns information about clubs and services archetypes
741
## Input:
742
##   $type: 'club' or 'service' ( Optional: Defaults to all types )
743
##   $branchcode: Get clubs or services created by this branch ( Optional )
744
## Output:
745
##   $results: 
746
##     Otherwise: Reference to an array of associated arrays
747
##     Except: 0 on failure
748
sub GetClubsAndServicesArchetypes {
749
  my ( $type, $branchcode ) = @_;
750
  my $dbh = C4::Context->dbh;
751
  
752
  my $sth;
753
  if ( $type && $branchcode) {
754
    $sth = $dbh->prepare("SELECT * FROM clubsAndServicesArchetypes WHERE type = ? AND branchcode = ?");
755
    $sth->execute( $type, $branchcode ) or return 0;
756
  } elsif ( $type ) {
757
    $sth = $dbh->prepare("SELECT * FROM clubsAndServicesArchetypes WHERE type = ?");
758
    $sth->execute( $type ) or return 0;
759
  } elsif ( $branchcode ) {
760
    $sth = $dbh->prepare("SELECT * FROM clubsAndServicesArchetypes WHERE branchcode = ?");
761
    $sth->execute( $branchcode ) or return 0;
762
  } else {
763
    $sth = $dbh->prepare("SELECT * FROM clubsAndServicesArchetypes");
764
    $sth->execute() or return 0;  
765
  }
766
  
767
  my @results;
768
  while ( my $row = $sth->fetchrow_hashref ) {
769
    push( @results , $row );
770
  }
771
772
  $sth->finish;
773
  
774
  return \@results;
775
}
776
777
## function GetClubOrServiceArchetype
778
## Returns information about a club or services archetype
779
## Input:
780
##   $casaId: Id of Archetype to get
781
##   $asHashref: Optional, if true, will return hashref instead of array
782
## Output:
783
##   $results: 
784
##     ( $casaId, $type, $title, $description, $publicEnrollment, 
785
##     $casData1Title, $casData2Title, $casData3Title,
786
##     $caseData1Title, $caseData2Title, $caseData3Title, 
787
##     $casData1Desc, $casData2Desc, $casData3Desc,
788
##     $caseData1Desc, $caseData2Desc, $caseData3Desc, 
789
##     $caseRequireEmail, $last_updated, $branchcode )
790
##     Except: 0 on failure
791
sub GetClubOrServiceArchetype {
792
  my ( $casaId, $asHashref ) = @_;
793
  
794
  my $dbh = C4::Context->dbh;
795
  
796
  my $sth;
797
  $sth = $dbh->prepare("SELECT * FROM clubsAndServicesArchetypes WHERE casaId = ?");
798
  $sth->execute( $casaId ) or return 0;
799
800
  my $row = $sth->fetchrow_hashref;
801
  
802
  $sth->finish;
803
  
804
  if ( $asHashref ) { return $row; }
805
806
  return (
807
      $$row{'casaId'},
808
      $$row{'type'},
809
      $$row{'title'},
810
      $$row{'description'},
811
      $$row{'publicEnrollment'},
812
      $$row{'casData1Title'},
813
      $$row{'casData2Title'},
814
      $$row{'casData3Title'},
815
      $$row{'caseData1Title'},
816
      $$row{'caseData2Title'},
817
      $$row{'caseData3Title'},
818
      $$row{'casData1Desc'},
819
      $$row{'casData2Desc'},
820
      $$row{'casData3Desc'},
821
      $$row{'caseData1Desc'},
822
      $$row{'caseData2Desc'},
823
      $$row{'caseData3Desc'},
824
      $$row{'caseRequireEmail'},
825
      $$row{'last_updated'},
826
      $$row{'branchcode'}
827
  );
828
}
829
830
## function DoesEnrollmentRequireData
831
## Returns 1 if the given Archetype has
832
##   data fields that need to be filled in
833
##   at the time of enrollment.
834
## Input:
835
##   $casaId: Id of Archetype to get
836
## Output:
837
##   1: Enrollment will require extra data
838
##   0: Enrollment will not require extra data
839
sub DoesEnrollmentRequireData {
840
  my ( $casaId ) = @_;
841
  
842
  my $dbh = C4::Context->dbh;
843
  
844
  my $sth;
845
  $sth = $dbh->prepare("SELECT caseData1Title FROM clubsAndServicesArchetypes WHERE casaId = ?");
846
  $sth->execute( $casaId ) or return 0;
847
848
  my $row = $sth->fetchrow_hashref;
849
  
850
  $sth->finish;
851
852
  if ( $$row{'caseData1Title'} ) {
853
    return 1;
854
  } else {
855
    return 0;
856
  }
857
}
858
859
860
## function CancelClubOrServiceEnrollment
861
## Cancels the given enrollment in a club or service
862
## Input:
863
##   $caseId: The id of the enrollment to be canceled
864
## Output:
865
##   $success: 1 on successful cancelation, 0 otherwise
866
sub CancelClubOrServiceEnrollment {
867
  my ( $caseId ) = @_;
868
  
869
  my $success = 1;
870
  
871
  my $dbh = C4::Context->dbh;
872
  
873
  my $sth = $dbh->prepare("UPDATE clubsAndServicesEnrollments SET dateCanceled = CURDATE(), last_updated = NOW() WHERE caseId = ?");
874
  $sth->execute( $caseId ) or $success = 0;
875
  $sth->finish;
876
  
877
  return $success;
878
}
879
880
## function GetEnrolledClubsAndServices
881
## Returns information about clubs and services
882
## the given borrower is enrolled in.
883
## Input:
884
##   $borrowernumber
885
## Output:
886
##   $results: 
887
##     Reference to an array of associated arrays
888
sub GetEnrolledClubsAndServices {
889
  my ( $borrowernumber ) = @_;
890
  my $dbh = C4::Context->dbh;
891
892
  my ( $sth, @results );
893
  $sth = $dbh->prepare("SELECT
894
                          clubsAndServicesEnrollments.caseId,
895
                          clubsAndServices.casId,
896
                          clubsAndServices.casaId,
897
                          clubsAndServices.title,
898
                          clubsAndServices.description,
899
                          clubsAndServices.branchcode,
900
                          clubsAndServicesArchetypes.type,
901
                          clubsAndServicesArchetypes.publicEnrollment
902
                        FROM clubsAndServices, clubsAndServicesArchetypes, clubsAndServicesEnrollments
903
                        WHERE ( 
904
                          clubsAndServices.casaId = clubsAndServicesArchetypes.casaId 
905
                          AND clubsAndServices.casId = clubsAndServicesEnrollments.casId
906
                          AND ( clubsAndServices.endDate >= CURRENT_DATE() OR clubsAndServices.endDate IS NULL )
907
                          AND clubsAndServicesEnrollments.dateCanceled IS NULL
908
                          AND clubsAndServicesEnrollments.borrowernumber = ?
909
                        )
910
                        ORDER BY type, title
911
                       ");
912
  $sth->execute( $borrowernumber ) or return 0;
913
    
914
  while ( my $row = $sth->fetchrow_hashref ) {
915
    push( @results , $row );
916
  }
917
918
  $sth->finish;
919
  
920
  return \@results;
921
  
922
}
923
924
## function GetPubliclyEnrollableClubsAndServices
925
## Returns information about clubs and services
926
## the given borrower can enroll in.
927
## Input:
928
##   $borrowernumber
929
## Output:
930
##   $results: 
931
##     Reference to an array of associated arrays
932
sub GetPubliclyEnrollableClubsAndServices {
933
  my ( $borrowernumber ) = @_;
934
935
  my $dbh = C4::Context->dbh;
936
937
  my ( $sth, @results );
938
  $sth = $dbh->prepare("
939
SELECT 
940
DISTINCT ( clubsAndServices.casId ), 
941
         clubsAndServices.title,
942
         clubsAndServices.description,
943
         clubsAndServices.branchcode,
944
         clubsAndServicesArchetypes.type,
945
         clubsAndServices.casaId
946
FROM clubsAndServices, clubsAndServicesArchetypes
947
WHERE clubsAndServicesArchetypes.casaId = clubsAndServices.casaId
948
AND clubsAndServicesArchetypes.publicEnrollment =1
949
AND clubsAndServices.casId NOT
950
IN (
951
  SELECT clubsAndServices.casId
952
  FROM clubsAndServices, clubsAndServicesEnrollments
953
  WHERE clubsAndServicesEnrollments.casId = clubsAndServices.casId
954
  AND clubsAndServicesEnrollments.dateCanceled IS NULL
955
  AND clubsAndServicesEnrollments.borrowernumber = ?
956
)
957
 ORDER BY type, title");
958
  $sth->execute( $borrowernumber ) or return 0;
959
    
960
  while ( my $row = $sth->fetchrow_hashref ) {
961
    push( @results , $row );
962
  }
963
964
  $sth->finish;
965
  
966
  return \@results;
967
  
968
}
969
970
## function GetAllEnrollableClubsAndServices
971
## Returns information about clubs and services
972
## the given borrower can enroll in.
973
## Input:
974
##   $borrowernumber
975
## Output:
976
##   $results: 
977
##     Reference to an array of associated arrays
978
sub GetAllEnrollableClubsAndServices {
979
  my ( $borrowernumber, $branchcode ) = @_;
980
  
981
  if ( $branchcode eq '' ) {
982
    $branchcode = '%';
983
  }
984
985
  my $dbh = C4::Context->dbh;
986
987
  my ( $sth, @results );
988
  $sth = $dbh->prepare("
989
SELECT 
990
DISTINCT ( clubsAndServices.casId ), 
991
         clubsAndServices.title,
992
         clubsAndServices.description,
993
         clubsAndServices.branchcode,
994
         clubsAndServicesArchetypes.type,
995
         clubsAndServices.casaId
996
FROM clubsAndServices, clubsAndServicesArchetypes
997
WHERE clubsAndServicesArchetypes.casaId = clubsAndServices.casaId
998
AND ( 
999
  DATE(clubsAndServices.endDate) >= CURDATE()
1000
  OR
1001
  clubsAndServices.endDate IS NULL
1002
)
1003
AND clubsAndServices.branchcode LIKE ?
1004
AND clubsAndServices.casId NOT
1005
IN (
1006
  SELECT clubsAndServices.casId
1007
  FROM clubsAndServices, clubsAndServicesEnrollments
1008
  WHERE clubsAndServicesEnrollments.casId = clubsAndServices.casId
1009
  AND clubsAndServicesEnrollments.dateCanceled IS NULL
1010
  AND clubsAndServicesEnrollments.borrowernumber = ?
1011
)
1012
 ORDER BY type, title");
1013
  $sth->execute( $branchcode, $borrowernumber ) or return 0;
1014
    
1015
  while ( my $row = $sth->fetchrow_hashref ) {
1016
    push( @results , $row );
1017
  }
1018
1019
  $sth->finish;
1020
  
1021
  return \@results;
1022
  
1023
}
1024
1025
1026
sub getBorrowernumberByCardnumber {
1027
  my $dbh = C4::Context->dbh;
1028
  
1029
  my $sth = $dbh->prepare("SELECT borrowernumber FROM borrowers WHERE cardnumber = ?");
1030
  $sth->execute( @_ ) or return( 0 );
1031
1032
  my $row = $sth->fetchrow_hashref;
1033
    
1034
  my $borrowernumber = $$row{'borrowernumber'};
1035
  $sth->finish;
1036
1037
  return( $borrowernumber );  
1038
}
1039
1040
sub isEnrolled {
1041
  my ( $casId, $borrowernumber ) = @_;
1042
  
1043
  my $dbh = C4::Context->dbh;
1044
  
1045
  my $sth = $dbh->prepare("SELECT COUNT(*) as isEnrolled FROM clubsAndServicesEnrollments WHERE casId = ? AND borrowernumber = ? AND dateCanceled IS NULL");
1046
  $sth->execute( $casId, $borrowernumber ) or return( 0 );
1047
1048
  my $row = $sth->fetchrow_hashref;
1049
    
1050
  my $isEnrolled = $$row{'isEnrolled'};
1051
  $sth->finish;
1052
1053
  return( $isEnrolled );  
1054
}
1055
1056
sub getTodayMysqlDateFormat {
1057
  my ($day,$month,$year) = (localtime)[3,4,5];
1058
  my $today = sprintf("%04d-%02d-%02d", $year + 1900, $month + 1, $day);
1059
  return $today;
1060
}
1061
1062
## This should really be moved to a new module, C4::ClubsAndServices::BestSellersClub
1063
sub ReserveForBestSellersClub {
1064
  my ( $biblionumber ) = @_;
1065
1066
  unless( $biblionumber ) { return; }
1067
  
1068
  my $dbh = C4::Context->dbh;
1069
  my $sth;
1070
1071
  ## Grab the bib for this biblionumber, we will need the author and title to find the relevent clubs
1072
  my $biblio_data = C4::Biblio::GetBiblioData( $biblionumber );
1073
  my $author = $biblio_data->{'author'};
1074
  my $title = $biblio_data->{'title'};
1075
  my $itemtype = $biblio_data->{'itemtype'};
1076
  
1077
  ## Find the casaId for the Bestsellers Club archetype
1078
  $sth = $dbh->prepare("SELECT * FROM clubsAndServicesArchetypes WHERE title LIKE 'Bestsellers Club' ");
1079
  $sth->execute();
1080
  my $casa = $sth->fetchrow_hashref();
1081
  my $casaId = $casa->{'casaId'};
1082
  $sth->finish();
1083
1084
  unless( $casaId ) { return; }
1085
    
1086
  ## Find all the relevent bestsellers clubs
1087
  ## casData1 is title, casData2 is author
1088
  $sth = $dbh->prepare("SELECT * FROM clubsAndServices WHERE casaId = ?");
1089
  $sth->execute( $casaId );
1090
  my @clubs;
1091
  while ( my $club = $sth->fetchrow_hashref() ) {
1092
    #warn "Author/casData2 : '$author'/ " . $club->{'casData2'} . "'";
1093
    #warn "Title/casData1 : '$title'/" . $club->{'casData1'} . "'";
1094
1095
    ## If the author, title or both match, keep it.
1096
    if ( ($club->{'casData1'} eq $title) || ($club->{'casData2'} eq $author) ) {
1097
      push( @clubs, $club );
1098
      #warn "casId" . $club->{'casId'};
1099
    } elsif ( $club->{'casData1'} =~ m/%/ ) { # Title is using % as a wildcard
1100
      my @substrings = split(/%/, $club->{'casData1'} );
1101
      my $all_match = 1;
1102
      foreach my $sub ( @substrings ) {
1103
        unless( $title =~ m/\Q$sub/) {
1104
          $all_match = 0;
1105
        }
1106
      }
1107
      if ( $all_match ) { push( @clubs, $club ); }
1108
    } elsif ( $club->{'casData2'} =~ m/%/ ) { # Author is using % as a wildcard
1109
      my @substrings = split(/%/, $club->{'casData2'} );
1110
      my $all_match = 1;
1111
      foreach my $sub ( @substrings ) {
1112
        unless( $author =~ m/\Q$sub/) {
1113
          $all_match = 0;
1114
        }
1115
      }
1116
      
1117
      ## Make sure the bib is in the list of itemtypes to use
1118
      my @itemtypes = split( / /, $club->{'casData3'} );
1119
      my $found_itemtype_match = 0;
1120
      if ( @itemtypes ) { ## If no itemtypes are listed, all itemtypes are valid, skip test.
1121
        foreach my $it ( @itemtypes ) {
1122
          if ( $it eq $itemtype ) {
1123
            $found_itemtype_match = 1;
1124
            last; ## Short circuit for speed.
1125
          }
1126
        }
1127
        $all_match = 0 unless ( $found_itemtype_match ); 
1128
      }
1129
      
1130
      if ( $all_match ) { push( @clubs, $club ); }
1131
    }
1132
  }
1133
  $sth->finish();
1134
  
1135
  unless( scalar( @clubs ) ) { return; }
1136
  
1137
  ## Get all the members of the relevant clubs, but only get each borrower once, even if they are in multiple relevant clubs
1138
  ## Randomize the order of the borrowers
1139
  my @casIds;
1140
  my $sql = "SELECT DISTINCT(borrowers.borrowernumber) FROM borrowers, clubsAndServicesEnrollments
1141
             WHERE clubsAndServicesEnrollments.borrowernumber = borrowers.borrowernumber
1142
             AND (";
1143
  my $clubsCount = scalar( @clubs );
1144
  foreach my $club ( @clubs ) {
1145
    $sql .= " casId = ?";
1146
    if ( --$clubsCount ) {
1147
      $sql .= " OR";
1148
    }
1149
    push( @casIds, $club->{'casId'} );
1150
  }
1151
  $sql .= " ) ORDER BY RAND()";
1152
  
1153
  
1154
  $sth = $dbh->prepare( $sql );
1155
  $sth->execute( @casIds );
1156
  my @borrowers;
1157
  while ( my $borrower = $sth->fetchrow_hashref() ) {
1158
    push( @borrowers, $borrower );
1159
  }
1160
  
1161
  unless( scalar( @borrowers ) ) { return; }
1162
  
1163
  my $priority = 1;
1164
  foreach my $borrower ( @borrowers ) {
1165
    C4::Reserves::AddReserve(
1166
      my $branch = $borrower->{'branchcode'},
1167
      my $borrowernumber = $borrower->{'borrowernumber'},
1168
      $biblionumber,
1169
      my $constraint = 'a',
1170
      my $bibitems,
1171
      $priority,
1172
      my $notes = "Automatic Reserve for Bestsellers Club",
1173
      $title,
1174
      my $checkitem,
1175
      my $found,
1176
      my $expire_date
1177
    );
1178
    $priority++;
1179
  }
1180
}
1181
1182
1;
1183
1184
__END__
1185
1186
=back
1187
1188
=head1 AUTHOR
1189
1190
Kyle Hall <kylemhall@gmail.com>
1191
1192
=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 952-957 if ( $op eq "addbiblio" ) { Link Here
952
        }
953
        }
953
        else {
954
        else {
954
            ( $biblionumber, $oldbibitemnum ) = AddBiblio( $record, $frameworkcode );
955
            ( $biblionumber, $oldbibitemnum ) = AddBiblio( $record, $frameworkcode );
956
            ReserveForBestSellersClub( $biblionumber );
955
        }
957
        }
956
        if ($redirect eq "items" || ($mode ne "popup" && !$is_a_modif && $redirect ne "view")){
958
        if ($redirect eq "items" || ($mode ne "popup" && !$is_a_modif && $redirect ne "view")){
957
	    if ($frameworkcode eq 'FA'){
959
	    if ($frameworkcode eq 'FA'){
(-)a/circ/circulation.pl (+4 lines)
Lines 35-40 use C4::Members; Link Here
35
use C4::Biblio;
35
use C4::Biblio;
36
use C4::Reserves;
36
use C4::Reserves;
37
use C4::Context;
37
use C4::Context;
38
use C4::ClubsAndServices;
38
use CGI::Session;
39
use CGI::Session;
39
use C4::Members::Attributes qw(GetBorrowerAttributes);
40
use C4::Members::Attributes qw(GetBorrowerAttributes);
40
41
Lines 99-104 my $findborrower = $query->param('findborrower'); Link Here
99
$findborrower =~ s|,| |g;
100
$findborrower =~ s|,| |g;
100
my $borrowernumber = $query->param('borrowernumber');
101
my $borrowernumber = $query->param('borrowernumber');
101
102
103
102
$branch  = C4::Context->userenv->{'branch'};  
104
$branch  = C4::Context->userenv->{'branch'};  
103
$printer = C4::Context->userenv->{'branchprinter'};
105
$printer = C4::Context->userenv->{'branchprinter'};
104
106
Lines 720-725 $template->param( picture => 1 ) if $picture; Link Here
720
722
721
my $canned_notes = GetAuthorisedValues("BOR_NOTES");
723
my $canned_notes = GetAuthorisedValues("BOR_NOTES");
722
724
725
$template->param( ClubsAndServicesLoop => GetEnrolledClubsAndServices( $borrowernumber ) );
726
723
$template->param(
727
$template->param(
724
    debt_confirmed            => $debt_confirmed,
728
    debt_confirmed            => $debt_confirmed,
725
    SpecifyDueDate            => $duedatespec_allow,
729
    SpecifyDueDate            => $duedatespec_allow,
(-)a/clubs_services/clubs_services.pl (+38 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
use strict;
3
use CGI;
4
use C4::Output;
5
use C4::Auth;
6
use C4::Context;
7
use C4::ClubsAndServices;
8
9
my $query = new CGI;
10
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
11
    {
12
        template_name   => "clubs_services/clubs_services.tmpl",
13
        query           => $query,
14
        type            => "intranet",
15
        authnotrequired => 1,
16
        flagsrequired   => { parameters => 1 },
17
        debug           => 1,
18
    }
19
);
20
21
my $branchcode = C4::Context->userenv->{branch};
22
23
my $clubs    = GetClubsAndServices( 'club',    $branchcode );
24
my $services = GetClubsAndServices( 'service', $branchcode );
25
26
$template->param(
27
    intranetcolorstylesheet =>
28
      C4::Context->preference("intranetcolorstylesheet"),
29
    intranetstylesheet => C4::Context->preference("intranetstylesheet"),
30
    IntranetNav        => C4::Context->preference("IntranetNav"),
31
32
    clubs_services => 1,
33
34
    clubsLoop    => $clubs,
35
    servicesLoop => $services,
36
);
37
38
output_html_with_http_headers $query, $cookie, $template->output;
(-)a/clubs_services/clubs_services_enrollments.pl (+39 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
use strict;
3
use CGI;
4
use C4::Output;
5
use C4::Auth;
6
use C4::Context;
7
use C4::ClubsAndServices;
8
9
my $query = new CGI;
10
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
11
    {
12
        template_name   => "clubs_services/clubs_services_enrollments.tmpl",
13
        query           => $query,
14
        type            => "intranet",
15
        authnotrequired => 1,
16
        flagsrequired   => { parameters => 1 },
17
        debug           => 1,
18
    }
19
);
20
21
my $casId = $query->param('casId');
22
my (
23
    $casId,    $casaId,       $title,    $description,
24
    $casData1, $casData2,     $casData3, $startDate,
25
    $endDate,  $last_updated, $branchcode
26
) = GetClubOrService($casId);
27
$template->param( casTitle => $title );
28
29
my $enrollments = GetCasEnrollments($casId);
30
$template->param( enrollments_loop => $enrollments );
31
32
$template->param(
33
    intranetcolorstylesheet =>
34
      C4::Context->preference("intranetcolorstylesheet"),
35
    intranetstylesheet => C4::Context->preference("intranetstylesheet"),
36
    IntranetNav        => C4::Context->preference("IntranetNav"),
37
);
38
39
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
use strict;
3
use CGI;
4
use C4::Output;
5
use C4::Auth;
6
use C4::Context;
7
use C4::ClubsAndServices;
8
9
my $query = new CGI;
10
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
11
    {
12
        template_name   => "clubs_services/edit_archetypes.tmpl",
13
        query           => $query,
14
        type            => "intranet",
15
        authnotrequired => 0,
16
        flagsrequired   => { parameters => 1 },
17
        debug           => 1,
18
    }
19
);
20
21
my $branchcode = C4::Context->userenv->{branch};
22
23
## Create new Archetype
24
if ( $query->param('action') eq 'create' ) {
25
    my $type             = $query->param('type');
26
    my $title            = $query->param('title');
27
    my $description      = $query->param('description');
28
    my $publicEnrollment =  ( $query->param('publicEnrollment') eq 'yes' ) ? 1 : 0;
29
30
    my $casData1Title = $query->param('casData1Title');
31
    my $casData2Title = $query->param('casData2Title');
32
    my $casData3Title = $query->param('casData3Title');
33
34
    my $caseData1Title = $query->param('caseData1Title');
35
    my $caseData2Title = $query->param('caseData2Title');
36
    my $caseData3Title = $query->param('caseData3Title');
37
38
    my $casData1Desc = $query->param('casData1Desc');
39
    my $casData2Desc = $query->param('casData2Desc');
40
    my $casData3Desc = $query->param('casData3Desc');
41
42
    my $caseData1Desc = $query->param('caseData1Desc');
43
    my $caseData2Desc = $query->param('caseData2Desc');
44
    my $caseData3Desc = $query->param('caseData3Desc');
45
46
    my $caseRequireEmail = $query->param('caseRequireEmail') ? '1' : '0';
47
48
    my ( $createdSuccessfully, $errorCode, $errorMessage ) =
49
      AddClubOrServiceArchetype(
50
        $type,             $title,            $description,
51
        $publicEnrollment, $casData1Title,    $casData2Title,
52
        $casData3Title,    $caseData1Title,   $caseData2Title,
53
        $caseData3Title,   $casData1Desc,     $casData2Desc,
54
        $casData3Desc,     $caseData1Desc,    $caseData2Desc,
55
        $caseData3Desc,    $caseRequireEmail, $branchcode
56
      );
57
58
    $template->param(
59
        previousActionCreate => 1,
60
        createdTitle         => $title,
61
    );
62
63
    if ($createdSuccessfully) {
64
        $template->param( createSuccess => 1 );
65
    }
66
    else {
67
        $template->param( createFailure  => 1 );
68
        $template->param( failureMessage => $errorMessage );
69
    }
70
71
}
72
73
## Delete an Archtype
74
elsif ( $query->param('action') eq 'delete' ) {
75
    my $casaId  = $query->param('casaId');
76
    my $success = DeleteClubOrServiceArchetype($casaId);
77
78
    $template->param( previousActionDelete => 1 );
79
    if ($success) {
80
        $template->param( deleteSuccess => 1 );
81
    }
82
    else {
83
        $template->param( deleteFailure => 1 );
84
    }
85
}
86
87
## Edit a club or service: grab data, put in form.
88
elsif ( $query->param('action') eq 'edit' ) {
89
    my $casaId = $query->param('casaId');
90
    my (
91
        $casaId,         $type,             $title,
92
        $description,    $publicEnrollment, $casData1Title,
93
        $casData2Title,  $casData3Title,    $caseData1Title,
94
        $caseData2Title, $caseData3Title,   $casData1Desc,
95
        $casData2Desc,   $casData3Desc,     $caseData1Desc,
96
        $caseData2Desc,  $caseData3Desc,    $caseRequireEmail,
97
        $casaTimestamp,  $casaBranchcode
98
    ) = GetClubOrServiceArchetype($casaId);
99
100
    $template->param(
101
        previousActionEdit   => 1,
102
        editCasaId           => $casaId,
103
        editType             => $type,
104
        editTitle            => $title,
105
        editDescription      => $description,
106
        editCasData1Title    => $casData1Title,
107
        editCasData2Title    => $casData2Title,
108
        editCasData3Title    => $casData3Title,
109
        editCaseData1Title   => $caseData1Title,
110
        editCaseData2Title   => $caseData2Title,
111
        editCaseData3Title   => $caseData3Title,
112
        editCasData1Desc     => $casData1Desc,
113
        editCasData2Desc     => $casData2Desc,
114
        editCasData3Desc     => $casData3Desc,
115
        editCaseData1Desc    => $caseData1Desc,
116
        editCaseData2Desc    => $caseData2Desc,
117
        editCaseData3Desc    => $caseData3Desc,
118
        editCaseRequireEmail => $caseRequireEmail,
119
        editCasaTimestamp    => $casaTimestamp,
120
        editCasaBranchcode   => $casaBranchcode
121
    );
122
123
    if ($publicEnrollment) {
124
        $template->param( editPublicEnrollment => 1 );
125
    }
126
}
127
128
# Update an Archetype
129
elsif ( $query->param('action') eq 'update' ) {
130
    my $casaId           = $query->param('casaId');
131
    my $type             = $query->param('type');
132
    my $title            = $query->param('title');
133
    my $description      = $query->param('description');
134
    my $publicEnrollment =  ( $query->param('publicEnrollment') eq 'yes' ) ? 1 : 0;
135
    
136
    my $casData1Title = $query->param('casData1Title');
137
    my $casData2Title = $query->param('casData2Title');
138
    my $casData3Title = $query->param('casData3Title');
139
140
    my $caseData1Title = $query->param('caseData1Title');
141
    my $caseData2Title = $query->param('caseData2Title');
142
    my $caseData3Title = $query->param('caseData3Title');
143
144
    my $casData1Desc = $query->param('casData1Desc');
145
    my $casData2Desc = $query->param('casData2Desc');
146
    my $casData3Desc = $query->param('casData3Desc');
147
148
    my $caseData1Desc = $query->param('caseData1Desc');
149
    my $caseData2Desc = $query->param('caseData2Desc');
150
    my $caseData3Desc = $query->param('caseData3Desc');
151
152
    my $caseRequireEmail = $query->param('caseRequireEmail');
153
154
    my ( $createdSuccessfully, $errorCode, $errorMessage ) =
155
      UpdateClubOrServiceArchetype(
156
        $casaId,         $type,             $title,
157
        $description,    $publicEnrollment, $casData1Title,
158
        $casData2Title,  $casData3Title,    $caseData1Title,
159
        $caseData2Title, $caseData3Title,   $casData1Desc,
160
        $casData2Desc,   $casData3Desc,     $caseData1Desc,
161
        $caseData2Desc,  $caseData3Desc,    $caseRequireEmail
162
      );
163
164
    $template->param(
165
        previousActionUpdate => 1,
166
        updatedTitle         => $title,
167
    );
168
169
    if ($createdSuccessfully) {
170
        $template->param( updateSuccess => 1 );
171
    }
172
    else {
173
        $template->param( updateFailure  => 1 );
174
        $template->param( failureMessage => $errorMessage );
175
    }
176
177
}
178
179
my $clubArchetypes    = GetClubsAndServicesArchetypes('club');
180
my $serviceArchetypes = GetClubsAndServicesArchetypes('service');
181
182
$template->param(
183
    intranetcolorstylesheet =>
184
      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 (+200 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
use strict;
3
use CGI;
4
use C4::Output;
5
use C4::Auth;
6
use C4::Context;
7
use C4::ClubsAndServices;
8
9
my $query = new CGI;
10
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
11
    {
12
        template_name   => "clubs_services/edit_clubs_services.tmpl",
13
        query           => $query,
14
        type            => "intranet",
15
        authnotrequired => 1,
16
        flagsrequired   => { parameters => 1 },
17
        debug           => 1,
18
    }
19
);
20
21
my $branchcode = C4::Context->userenv->{branch};
22
23
# Archetype selected for Club or Service creation
24
if ( $query->param('action') eq 'selectArchetype' ) {
25
    my $casaId = $query->param('casaId');
26
27
    my (
28
        $casaId,          $casaType,             $casaTitle,
29
        $casaDescription, $casaPublicEnrollment, $casData1Title,
30
        $casData2Title,   $casData3Title,        $caseData1Title,
31
        $caseData2Title,  $caseData3Title,       $casData1Desc,
32
        $casData2Desc,    $casData3Desc,         $caseData1Desc,
33
        $caseData2Desc,   $caseData3Desc,        $casaTimestamp
34
    ) = GetClubOrServiceArchetype($casaId);
35
36
    $template->param(
37
        previousActionSelectArchetype => 1,
38
39
        casaId               => $casaId,
40
        casaType             => $casaType,
41
        casaTitle            => $casaTitle,
42
        casaDescription      => $casaDescription,
43
        casaPublicEnrollment => $casaPublicEnrollment,
44
        casData1Title        => $casData1Title,
45
        casData2Title        => $casData2Title,
46
        casData3Title        => $casData3Title,
47
        caseData1Title       => $caseData1Title,
48
        caseData2Title       => $caseData2Title,
49
        caseData3Title       => $caseData3Title,
50
        casData1Desc         => $casData1Desc,
51
        casData2Desc         => $casData2Desc,
52
        casData3Desc         => $casData3Desc,
53
        caseData1Desc        => $caseData1Desc,
54
        caseData2Desc        => $caseData2Desc,
55
        caseData3Desc        => $caseData3Desc,
56
        caseTimestamp        => $casaTimestamp
57
    );
58
}
59
60
# Create new Club or Service
61
elsif ( $query->param('action') eq 'create' ) {
62
    my $casaId      = $query->param('casaId');
63
    my $title       = $query->param('title');
64
    my $description = $query->param('description');
65
    my $casData1    = $query->param('casData1');
66
    my $casData2    = $query->param('casData2');
67
    my $casData3    = $query->param('casData3');
68
    my $startDate   = $query->param('startDate');
69
    my $endDate     = $query->param('endDate');
70
71
    my ( $createdSuccessfully, $errorCode, $errorMessage ) = AddClubOrService(
72
        $casaId,   $title,     $description, $casData1, $casData2,
73
        $casData3, $startDate, $endDate,     $branchcode
74
    );
75
76
    $template->param(
77
        previousActionCreate => 1,
78
        createdTitle         => $title,
79
    );
80
81
    if ($createdSuccessfully) {
82
        $template->param( createSuccess => 1 );
83
    }
84
    else {
85
        $template->param( createFailure  => 1 );
86
        $template->param( failureMessage => $errorMessage );
87
    }
88
}
89
90
## Delete a club or service
91
elsif ( $query->param('action') eq 'delete' ) {
92
    my $casId   = $query->param('casId');
93
    my $success = DeleteClubOrService($casId);
94
95
    $template->param( previousActionDelete => 1 );
96
    if ($success) {
97
        $template->param( deleteSuccess => 1 );
98
    }
99
    else {
100
        $template->param( deleteFailure => 1 );
101
    }
102
}
103
104
## Edit a club or service: grab data, put in form.
105
elsif ( $query->param('action') eq 'edit' ) {
106
    my $casId = $query->param('casId');
107
    my (
108
        $casId,    $casaId,   $title,     $description, $casData1,
109
        $casData2, $casData3, $startDate, $endDate,     $timestamp
110
    ) = GetClubOrService($casId);
111
112
    my (
113
        $casaId,          $casaType,             $casaTitle,
114
        $casaDescription, $casaPublicEnrollment, $casData1Title,
115
        $casData2Title,   $casData3Title,        $caseData1Title,
116
        $caseData2Title,  $caseData3Title,       $casData1Desc,
117
        $casData2Desc,    $casData3Desc,         $caseData1Desc,
118
        $caseData2Desc,   $caseData3Desc,        $casaTimestamp
119
    ) = GetClubOrServiceArchetype($casaId);
120
121
    $template->param(
122
        previousActionSelectArchetype => 1,
123
        previousActionEdit            => 1,
124
        editCasId                     => $casId,
125
        editCasaId                    => $casaId,
126
        editTitle                     => $title,
127
        editDescription               => $description,
128
        editCasData1                  => $casData1,
129
        editCasData2                  => $casData2,
130
        editCasData3                  => $casData3,
131
        editStartDate                 => $startDate,
132
        editEndDate                   => $endDate,
133
        editTimestamp                 => $timestamp,
134
135
        casaId        => $casaId,
136
        casaTitle     => $casaTitle,
137
        casData1Title => $casData1Title,
138
        casData2Title => $casData2Title,
139
        casData3Title => $casData3Title,
140
        casData1Desc  => $casData1Desc,
141
        casData2Desc  => $casData2Desc,
142
        casData3Desc  => $casData3Desc
143
    );
144
}
145
146
# Update a Club or Service
147
if ( $query->param('action') eq 'update' ) {
148
    my $casId       = $query->param('casId');
149
    my $casaId      = $query->param('casaId');
150
    my $title       = $query->param('title');
151
    my $description = $query->param('description');
152
    my $casData1    = $query->param('casData1');
153
    my $casData2    = $query->param('casData2');
154
    my $casData3    = $query->param('casData3');
155
    my $startDate   = $query->param('startDate');
156
    my $endDate     = $query->param('endDate');
157
158
    my ( $createdSuccessfully, $errorCode, $errorMessage ) =
159
      UpdateClubOrService(
160
        $casId,    $casaId,   $title,     $description, $casData1,
161
        $casData2, $casData3, $startDate, $endDate
162
      );
163
164
    $template->param(
165
        previousActionUpdate => 1,
166
        updatedTitle         => $title,
167
    );
168
169
    if ($createdSuccessfully) {
170
        $template->param( updateSuccess => 1 );
171
    }
172
    else {
173
        $template->param( updateFailure  => 1 );
174
        $template->param( failureMessage => $errorMessage );
175
    }
176
}
177
178
my $clubs    = GetClubsAndServices( 'club',    $query->cookie('branch') );
179
my $services = GetClubsAndServices( 'service', $query->cookie('branch') );
180
my $archetypes = GetClubsAndServicesArchetypes();
181
182
if ($archetypes)
183
{    ## Disable 'Create New Club or Service' if there are no archetypes defined.
184
    $template->param( archetypes => 1 );
185
}
186
187
$template->param(
188
    intranetcolorstylesheet =>
189
      C4::Context->preference("intranetcolorstylesheet"),
190
    intranetstylesheet => C4::Context->preference("intranetstylesheet"),
191
    IntranetNav        => C4::Context->preference("IntranetNav"),
192
193
    edit_clubs_services => 1,
194
195
    clubsLoop      => $clubs,
196
    servicesLoop   => $services,
197
    archetypesLoop => $archetypes,
198
);
199
200
output_html_with_http_headers $query, $cookie, $template->output;
(-)a/clubs_services/enroll_clubs_services.pl (+104 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
use strict;
3
use CGI;
4
use C4::Output;
5
use C4::Auth;
6
use C4::Context;
7
use C4::ClubsAndServices;
8
9
my $query = new CGI;
10
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
11
    {
12
        template_name   => "clubs_services/enroll_clubs_services.tmpl",
13
        query           => $query,
14
        type            => "intranet",
15
        authnotrequired => 1,
16
        flagsrequired   => { parameters => 1 },
17
        debug           => 1,
18
    }
19
);
20
21
my $branchcode = $query->cookie('branch');
22
23
if ( $query->param('action') eq 'enroll' ) {
24
    my $borrowerBarcode = $query->param('borrowerBarcode');
25
    my $casId           = $query->param('casId');
26
    my $casaId          = $query->param('casaId');
27
    my $data1           = $query->param('data1');
28
    my $data2           = $query->param('data2');
29
    my $data3           = $query->param('data3');
30
31
    my $dateEnrolled;    # Will default to Today
32
33
    my ( $success, $errorCode, $errorMessage ) =
34
      EnrollInClubOrService( $casaId, $casId, $borrowerBarcode, $dateEnrolled,
35
        $data1, $data2, $data3, $branchcode );
36
37
    $template->param(
38
        previousActionEnroll => 1,
39
        enrolledBarcode      => $borrowerBarcode,
40
    );
41
42
    if ($success) {
43
        $template->param( enrollSuccess => 1 );
44
    }
45
    else {
46
        $template->param( enrollFailure  => 1 );
47
        $template->param( failureMessage => $errorMessage );
48
    }
49
50
}
51
52
my ( $casId, $casaId, $casTitle, $casDescription, $casStartDate, $casEndDate,
53
    $casTimestamp )
54
  = GetClubOrService( $query->param('casId') );
55
my (
56
    $casaId,          $casaType,             $casaTitle,
57
    $casaDescription, $casaPublicEnrollment, $casData1Title,
58
    $casData2Title,   $casData3Title,        $caseData1Title,
59
    $caseData2Title,  $caseData3Title,       $casData1Desc,
60
    $casData2Desc,    $casData3Desc,         $caseData1Desc,
61
    $caseData2Desc,   $caseData3Desc,        $timestamp
62
) = GetClubOrServiceArchetype($casaId);
63
64
$template->param(
65
    intranetcolorstylesheet =>
66
      C4::Context->preference("intranetcolorstylesheet"),
67
    intranetstylesheet => C4::Context->preference("intranetstylesheet"),
68
    IntranetNav        => C4::Context->preference("IntranetNav"),
69
70
    casId          => $casId,
71
    casTitle       => $casTitle,
72
    casDescription => $casDescription,
73
    casStartDate   => $casStartDate,
74
    casEndDate     => $casEndDate,
75
    casTimeStamp   => $casTimestamp,
76
77
    casaId               => $casaId,
78
    casaType             => $casaType,
79
    casaTitle            => $casaTitle,
80
    casaDescription      => $casaDescription,
81
    casaPublicEnrollment => $casaPublicEnrollment,
82
);
83
84
if ($caseData1Title) {
85
    $template->param( caseData1Title => $caseData1Title );
86
}
87
if ($caseData2Title) {
88
    $template->param( caseData2Title => $caseData2Title );
89
}
90
if ($caseData3Title) {
91
    $template->param( caseData3Title => $caseData3Title );
92
}
93
94
if ($caseData1Desc) {
95
    $template->param( caseData1Desc => $caseData1Desc );
96
}
97
if ($caseData2Desc) {
98
    $template->param( caseData2Desc => $caseData2Desc );
99
}
100
if ($caseData3Desc) {
101
    $template->param( caseData3Desc => $caseData3Desc );
102
}
103
104
output_html_with_http_headers $query, $cookie, $template->output;
(-)a/installer/data/mysql/kohastructure.sql (+79 lines)
Lines 2687-2692 CREATE TABLE `bibliocoverimage` ( Link Here
2687
 CONSTRAINT `bibliocoverimage_fk1` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE
2687
 CONSTRAINT `bibliocoverimage_fk1` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE
2688
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2688
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2689
2689
2690
--
2691
-- Table structure for table `clubsAndServices`
2692
-- 
2693
2694
DROP TABLE IF EXISTS `clubsAndServices`;
2695
CREATE TABLE `clubsAndServices` (
2696
  `casId` int(11) NOT NULL auto_increment,
2697
  `casaId` int(11) NOT NULL default '0' COMMENT 'foreign key to clubsAndServicesArchetypes',
2698
  `title` text NOT NULL,
2699
  `description` text,
2700
  `casData1` text COMMENT 'Data described in casa.casData1Title',
2701
  `casData2` text COMMENT 'Data described in casa.casData2Title',
2702
  `casData3` text COMMENT 'Data described in casa.casData3Title',
2703
  `startDate` date NOT NULL default '0000-00-00',
2704
  `endDate` date default NULL,
2705
  `branchcode` varchar(4) NOT NULL COMMENT 'branch where club or service was created.',
2706
  `last_updated` timestamp NOT NULL default CURRENT_TIMESTAMP,
2707
  PRIMARY KEY  (`casId`)
2708
) ENGINE=MyISAM  DEFAULT CHARSET=utf8;
2709
2710
-- 
2711
-- Table structure for table `clubsAndServicesArchetypes`
2712
-- 
2713
2714
DROP TABLE IF EXISTS `clubsAndServicesArchetypes`;
2715
CREATE TABLE `clubsAndServicesArchetypes` (
2716
  `casaId` int(11) NOT NULL auto_increment,
2717
  `type` enum('club','service') NOT NULL default 'club',
2718
  `title` text NOT NULL COMMENT 'title of this archetype',
2719
  `description` text NOT NULL COMMENT 'long description of this archetype',
2720
  `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.',
2721
  `casData1Title` text COMMENT 'Title of contents in cas.data1',
2722
  `casData2Title` text COMMENT 'Title of contents in cas.data2',
2723
  `casData3Title` text COMMENT 'Title of contents in cas.data3',
2724
  `caseData1Title` text COMMENT 'Name of what is stored in cAsE.data1',
2725
  `caseData2Title` text COMMENT 'Name of what is stored in cAsE.data2',
2726
  `caseData3Title` text COMMENT 'Name of what is stored in cAsE.data3',
2727
  `casData1Desc` text,
2728
  `casData2Desc` text,
2729
  `casData3Desc` text,
2730
  `caseData1Desc` text,
2731
  `caseData2Desc` text,
2732
  `caseData3Desc` text,
2733
  `caseRequireEmail` tinyint(1) NOT NULL default '0',
2734
  `branchcode` varchar(4) default NULL COMMENT 'branch where archetype was created.',
2735
  `last_updated` timestamp NOT NULL default CURRENT_TIMESTAMP,
2736
  `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.',
2737
  PRIMARY KEY  (`casaId`)
2738
) ENGINE=MyISAM  DEFAULT CHARSET=utf8;
2739
2740
--
2741
-- Preset data for ClubsAndServicesArchetypes
2742
--
2743
2744
INSERT INTO `clubsAndServicesArchetypes` ( `casaId` , `type` , `title` , `description` , `publicEnrollment` , `casData1Title` , `casData2Title` , `casData3Title` , `caseData1Title` , `caseData2Title` , `caseData3Title` , `casData1Desc` , `casData2Desc` , `casData3Desc` , `caseData1Desc` , `caseData2Desc` , `caseData3Desc` , `branchcode` , `last_updated`, `system_defined` )
2745
VALUES ( '', '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', '', '', '', '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.', '', '', '', 'NO_L', '2009-09-28 10:29:01', 1 );
2746
INSERT INTO `clubsAndServicesArchetypes` (`casaId`, `type`, `title`, `description`, `publicEnrollment`, `casData1Title`, `casData2Title`, `casData3Title`, `caseData1Title`, `caseData2Title`, `caseData3Title`, `casData1Desc`, `casData2Desc`, `casData3Desc`, `caseData1Desc`, `caseData2Desc`, `caseData3Desc`, `branchcode`, `last_updated`, `system_defined` ) 
2747
VALUES ( '', '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, 'NO_L', '2009-05-17 08:57:10', 1);
2748
2749
-- 
2750
-- Table structure for table `clubsAndServicesEnrollments`
2751
-- 
2752
2753
DROP TABLE IF EXISTS `clubsAndServicesEnrollments`;
2754
CREATE TABLE `clubsAndServicesEnrollments` (
2755
  `caseId` int(11) NOT NULL auto_increment,
2756
  `casaId` int(11) NOT NULL default '0' COMMENT 'foreign key to clubsAndServicesArchtypes',
2757
  `casId` int(11) NOT NULL default '0' COMMENT 'foreign key to clubsAndServices',
2758
  `borrowernumber` int(11) NOT NULL default '0' COMMENT 'foreign key to borrowers',
2759
  `data1` text COMMENT 'data described in casa.data1description',
2760
  `data2` text,
2761
  `data3` text,
2762
  `dateEnrolled` date NOT NULL default '0000-00-00' COMMENT 'date borrowers service begins',
2763
  `dateCanceled` date default NULL COMMENT 'date borrower decided to end service',
2764
  `last_updated` timestamp NOT NULL default CURRENT_TIMESTAMP,
2765
  `branchcode` varchar(4) default NULL COMMENT 'foreign key to branches',
2766
  PRIMARY KEY  (`caseId`)
2767
) ENGINE=MyISAM  DEFAULT CHARSET=utf8;
2768
                  
2690
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
2769
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
2691
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
2770
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
2692
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
2771
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
(-)a/installer/data/mysql/updatedatabase.pl (+70 lines)
Lines 4670-4675 if (C4::Context->preference("Version") < TransformToNum($DBversion)) { Link Here
4670
    SetVersion ($DBversion);
4670
    SetVersion ($DBversion);
4671
}
4671
}
4672
4672
4673
<<<<<<< HEAD
4673
$DBversion = "3.07.00.013";
4674
$DBversion = "3.07.00.013";
4674
if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4675
if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4675
    $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OpacExportOptions','bibtex|dc|marcxml|marc8|utf8|marcstd|mods|ris','Define available export options on OPAC detail page.','','free');");
4676
    $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OpacExportOptions','bibtex|dc|marcxml|marc8|utf8|marcstd|mods|ris','Define available export options on OPAC detail page.','','free');");
Lines 4712-4717 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { Link Here
4712
    SetVersion($DBversion);
4713
    SetVersion($DBversion);
4713
}
4714
}
4714
4715
4716
$DBversion = "3.07.00.XXX";
4717
if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4718
4719
    $dbh->do("CREATE TABLE clubsAndServices (
4720
  casId int(11) NOT NULL auto_increment,
4721
  casaId int(11) NOT NULL default '0' COMMENT 'foreign key to clubsAndServicesArchetypes',
4722
  title text NOT NULL,
4723
  description text,
4724
  casData1 text COMMENT 'Data described in casa.casData1Title',
4725
  casData2 text COMMENT 'Data described in casa.casData2Title',
4726
  casData3 text COMMENT 'Data described in casa.casData3Title',
4727
  startDate date NOT NULL default '0000-00-00',
4728
  endDate date default NULL,
4729
  branchcode varchar(4) NOT NULL COMMENT 'branch where club or service was created.',
4730
  last_updated timestamp NOT NULL default CURRENT_TIMESTAMP,
4731
  PRIMARY KEY  (casId)
4732
) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
4733
4734
  $dbh->do("CREATE TABLE clubsAndServicesArchetypes (
4735
  casaId int(11) NOT NULL auto_increment,
4736
  type enum('club','service') NOT NULL default 'club',
4737
  title text NOT NULL COMMENT 'title of this archetype',
4738
  description text NOT NULL COMMENT 'long description of this archetype',
4739
  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.',
4740
  casData1Title text COMMENT 'Title of contents in cas.data1',
4741
  casData2Title text COMMENT 'Title of contents in cas.data2',
4742
  casData3Title text COMMENT 'Title of contents in cas.data3',
4743
  caseData1Title text COMMENT 'Name of what is stored in cAsE.data1',
4744
  caseData2Title text COMMENT 'Name of what is stored in cAsE.data2',
4745
  caseData3Title text COMMENT 'Name of what is stored in cAsE.data3',
4746
  casData1Desc text,
4747
  casData2Desc text,
4748
  casData3Desc text,
4749
  caseData1Desc text,
4750
  caseData2Desc text,
4751
  caseData3Desc text,
4752
  caseRequireEmail tinyint(1) NOT NULL default '0',
4753
  branchcode varchar(4) default NULL COMMENT 'branch where archetype was created.',
4754
  last_updated timestamp NOT NULL default CURRENT_TIMESTAMP,
4755
  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.',
4756
  PRIMARY KEY  (casaId)
4757
) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
4758
4759
  $dbh->do("REPLACE INTO clubsAndServicesArchetypes ( casaId , type , title , description , publicEnrollment , casData1Title , casData2Title , casData3Title , caseData1Title , caseData2Title , caseData3Title , casData1Desc , casData2Desc , casData3Desc , caseData1Desc , caseData2Desc , caseData3Desc , branchcode , last_updated, system_defined )
4760
VALUES ( '', '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', '', '', '', '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, '2009-09-28 10:29:01', '1' );
4761
");
4762
  $dbh->do("REPLACE INTO clubsAndServicesArchetypes (casaId, type, title, description, publicEnrollment, casData1Title, casData2Title, casData3Title, caseData1Title, caseData2Title, caseData3Title, casData1Desc, casData2Desc, casData3Desc, caseData1Desc, caseData2Desc, caseData3Desc, branchcode, last_updated, system_defined) 
4763
VALUES ( '', '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, NULL, '2009-05-17 08:57:10', '1');
4764
");
4765
4766
  $dbh->do("CREATE TABLE clubsAndServicesEnrollments (
4767
  caseId int(11) NOT NULL auto_increment,
4768
  casaId int(11) NOT NULL default '0' COMMENT 'foreign key to clubsAndServicesArchtypes',
4769
  casId int(11) NOT NULL default '0' COMMENT 'foreign key to clubsAndServices',
4770
  borrowernumber int(11) NOT NULL default '0' COMMENT 'foreign key to borrowers',
4771
  data1 text COMMENT 'data described in casa.data1description',
4772
  data2 text,
4773
  data3 text,
4774
  dateEnrolled date NOT NULL default '0000-00-00' COMMENT 'date borrowers service begins',
4775
  dateCanceled date default NULL COMMENT 'date borrower decided to end service',
4776
  last_updated timestamp NOT NULL default CURRENT_TIMESTAMP,
4777
  branchcode varchar(4) default NULL COMMENT 'foreign key to branches',
4778
  PRIMARY KEY  (caseId)
4779
) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
4780
4781
    print "Upgrade to $DBversion done ( Added tables for Clubs & Services )\n";
4782
    SetVersion($DBversion);
4783
}
4784
4715
=head1 FUNCTIONS
4785
=head1 FUNCTIONS
4716
4786
4717
=head2 DropAllForeignKeys($table)
4787
=head2 DropAllForeignKeys($table)
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/circ-menu.inc (+1 lines)
Lines 69-74 Link Here
69
	 [% IF ( CAN_user_updatecharges ) %]
69
	 [% IF ( CAN_user_updatecharges ) %]
70
	[% IF ( finesview ) %]<li class="active">[% ELSE %]<li>[% END %]<a href="/cgi-bin/koha/members/boraccount.pl?borrowernumber=[% borrowernumber %]">Fines</a></li>
70
	[% IF ( finesview ) %]<li class="active">[% ELSE %]<li>[% END %]<a href="/cgi-bin/koha/members/boraccount.pl?borrowernumber=[% borrowernumber %]">Fines</a></li>
71
	[% END %]
71
	[% END %]
72
	[% 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>
72
	[% IF ( intranetreadinghistory ) %][% IF ( readingrecordview ) %]<li class="active">[% ELSE %]<li>[% END %]<a href="/cgi-bin/koha/members/readingrec.pl?borrowernumber=[% borrowernumber %]">Circulation History</a></li>[% END %]
73
	[% IF ( intranetreadinghistory ) %][% IF ( readingrecordview ) %]<li class="active">[% ELSE %]<li>[% END %]<a href="/cgi-bin/koha/members/readingrec.pl?borrowernumber=[% borrowernumber %]">Circulation History</a></li>[% END %]
73
	[% IF ( CAN_user_parameters ) %][% 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>[% END %]
74
	[% IF ( CAN_user_parameters ) %][% 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>[% END %]
74
    [% IF ( EnhancedMessagingPreferences ) %]
75
    [% IF ( EnhancedMessagingPreferences ) %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/members-menu.inc (+2 lines)
Lines 10-14 Link Here
10
    [% IF ( EnhancedMessagingPreferences ) %]
10
    [% IF ( EnhancedMessagingPreferences ) %]
11
    [% END %]
11
    [% END %]
12
	[% IF ( sentnotices ) %]<li class="active">[% ELSE %]<li>[% END %]<a href="/cgi-bin/koha/members/notices.pl?borrowernumber=[% borrowernumber %]">Notices</a></li>
12
	[% IF ( sentnotices ) %]<li class="active">[% ELSE %]<li>[% END %]<a href="/cgi-bin/koha/members/notices.pl?borrowernumber=[% borrowernumber %]">Notices</a></li>
13
	[% 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>
14
13
</ul></div>
15
</ul></div>
14
[% END %]
16
[% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt (-1 / +8 lines)
Lines 658-664 No patron matched <span class="ex">[% message %]</span> Link Here
658
	
658
	
659
     <!-- /If flagged -->[% END %]
659
     <!-- /If flagged -->[% END %]
660
660
661
	
661
        [% IF ( ClubsAndServicesLoop ) %]
662
                <h4>Clubs & Services</h4>
663
                <ul>
664
                        [% FOREACH ClubOrService IN ClubsAndServicesLoop %]
665
                                <li><a href="/cgi-bin/koha/members/clubs_services.pl?borrowernumber=[% ClubOrService.borrowernumber %]">[% ClubOrService.title %]</a></li>
666
                        [% END %]
667
                </ul>
668
        [% END %]
662
669
663
</div>
670
</div>
664
</div>
671
</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
</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; Edit Archetypes
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
<!-- These messages are uneccessary because you can see if it was deleted or created immediately
21
      [% IF ( previousActionCreate ) %]
22
        [% IF ( createSuccess ) %]
23
          <p>Archtype '[% createdTitle %]' Created Succesfully!</p>
24
        [% ELSE %]
25
          <p>Archtype '[% createdTitle %]' Failed To Be Created!</p>
26
          <p>Reason: <strong>[% failureMessage %]</strong></p>
27
        [% END %]
28
      [% END %]
29
30
      [% IF ( previousActionDelete ) %]
31
        [% IF ( DeleteSuccess ) %]
32
          <p>Archtype Deleted Succesfully!</p>
33
        [% ELSE %]
34
          <p>Archtype Failed To Be Deleted!</p>
35
        [% END %]
36
      [% END %]
37
38
      [% IF ( previousActionUpdate ) %]
39
        [% IF ( updateSuccess ) %]
40
          <p>Archetype '[% updatedTitle %]' Updated Succesfully!</p>
41
        [% ELSE %]
42
          <p>Archetype '[% updatedTitle %]' Failed To Be Updated!</p>
43
          <p>Reason: <strong>[% failureMessage %]</strong></p>
44
        [% END %]
45
      [% END %]
46
-->
47
48
      <!-- LIST ALL ARCHETYPES -->
49
          <table>
50
            <tr><th colspan="99">Club Archetypes</th></tr>
51
            <tr>
52
              <th>Owner</strong</td>
53
              <th>Title</th>
54
              <th>Description</th>
55
              <th>Public Enrollment</th>
56
	      <th>Require Email</th>
57
	      <th>Club Data 1 Title</th>
58
	      <th>Club Data 2 Title</th>
59
              <th>Club Data 3 Title</th>
60
	      <th>Enrollment Data 1 Title</th>
61
	      <th>Enrollment Data 2 Title</th>
62
              <th>Enrollment Data 3 Title</th>
63
	      <th></th>
64
              <th></th>
65
            </tr>
66
67
        [% IF ( clubArchetypesLoop ) %]
68
            [% FOREACH clubArchetypesLoo IN clubArchetypesLoop %]
69
              <tr>
70
                <td>[% clubArchetypesLoo.branchcode %]</td>
71
                <td>[% clubArchetypesLoo.title %]</td>
72
                <td>[% clubArchetypesLoo.description %]</td>
73
                <td>[% IF clubArchetypesLoo.publicEnrollment %]&#10004;[% END %]</td>
74
                <td>[% IF clubArchetypesLoo.caseRequireEmail %]&#10004;[% END %]</td>
75
                <td>[% clubArchetypesLoo.casData1Title %]</td>
76
                <td>[% clubArchetypesLoo.casData2Title %]</td>
77
                <td>[% clubArchetypesLoo.casData3Title %]</td>
78
                <td>[% clubArchetypesLoo.caseData1Title %]</td>
79
                <td>[% clubArchetypesLoo.caseData2Title %]</td>
80
                <td>[% clubArchetypesLoo.caseData3Title %]</td>
81
                <td>[% UNLESS ( clubArchetypesLoo.system_defined ) %]<a href="edit_archetypes.pl?action=edit&casaId=[% clubArchetypesLoo.casaId %]">Edit</a>[% END %]</td>
82
                <td>[% UNLESS ( clubArchetypesLoo.system_defined ) %]<a href="edit_archetypes.pl?action=delete&casaId=[% clubArchetypesLoo.casaId %]">Delete</a>[% END %]</td>
83
              </tr>
84
            [% END %]
85
        [% ELSE %]
86
            <tr><td colspan="99">There are no Club Archetypes currently defined.</td></tr>
87
        [% END %]
88
89
            <tr><td colspan="99">&nbsp;</td></tr>
90
91
            <tr><th colspan="99">Service Archetypes</th></tr>
92
            <tr>
93
              <th>Owner</strong</td>
94
              <th>Title</th>
95
              <th>Description</th>
96
              <th>Public Enrollment</th>
97
	      <th>Require Email</th>
98
	      <th>Service Data 1 Title</th>
99
	      <th>Service Data 2 Title</th>
100
              <th>Service Data 3 Title</th>
101
	      <th>Enrollment Data 1 Title</th>
102
	      <th>Enrollment Data 2 Title</th>
103
              <th>Enrollment Data 3 Title</th>
104
	      <th></th>
105
              <th></th>
106
            </tr>
107
108
        [% IF ( serviceArchetypesLoop ) %]
109
            [% FOREACH serviceArchetypesLoo IN serviceArchetypesLoop %]
110
              <tr>
111
                <td>[% serviceArchetypesLoo.branchcode %]</td>
112
                <td>[% serviceArchetypesLoo.title %]</td>
113
                <td>[% serviceArchetypesLoo.description %]</td>
114
                <td>[% IF serviceArchetypesLoo.publicEnrollment %]&#10004;[% END %]</td>
115
                <td>[% IF serviceArchetypesLoo.caseRequireEmail %]&#10004;[% END %]</td>
116
                <td>[% serviceArchetypesLoo.casData1Title %]</td>
117
                <td>[% serviceArchetypesLoo.casData2Title %]</td>
118
                <td>[% serviceArchetypesLoo.casData3Title %]</td>
119
                <td>[% serviceArchetypesLoo.caseData1Title %]</td>
120
                <td>[% serviceArchetypesLoo.caseData2Title %]</td>
121
                <td>[% serviceArchetypesLoo.caseData3Title %]</td>
122
                <td>[% UNLESS ( serviceArchetypesLoo.system_defined ) %]<a href="edit_archetypes.pl?action=edit&casaId=[% serviceArchetypesLoo.casaId %]">Edit</a>[% END %]</td>
123
                <td>[% UNLESS ( serviceArchetypesLoo.system_defined ) %]<a href="edit_archetypes.pl?action=delete&casaId=[% serviceArchetypesLoo.casaId %]">Delete</a>[% END %]</td>
124
              </tr>
125
            [% END %]
126
          </table>
127
        [% ELSE %]
128
            <tr><td colspan="12"> There are no Service Archetypes currently defined.</td></tr>
129
        [% END %]
130
131
      <!-- ADD NEW ARCHETYPE FORM -->
132
133
<table>
134
  <tr>
135
        [% IF ( previousActionEdit ) %]
136
          <th>Edit an Archetype</th>
137
        [% ELSE %]
138
          <th>Create New Archetype</th>
139
        [% END %]
140
  </tr>
141
  <tr>
142
    <td>
143
        <form action="edit_archetypes.pl" method="post">
144
          [% IF ( previousActionEdit ) %]
145
            <input type="hidden" name="action" value="update" />
146
            <input type="hidden" name="casaId" value="[% editCasaId %]" />
147
          [% ELSE %]
148
            <input type="hidden" name="action" value="create" />
149
          [% END %]
150
151
          <label for="type">Type: </label>
152
          <select name="type">
153
            [% IF ( editType ) %]<option label="Keep Current Type" value="[% editType %]">Keep Current Type</option>[% END %]
154
            <option label="Club" value="club">Club</option>
155
            <option label="Service" value="service">Service</option>
156
          </select>
157
          <br />
158
           
159
          <label for="title">Title: </label>
160
          <input type="text" name="title" [% IF ( editTitle ) %] value="[% editTitle %]" [% END %] />
161
          <br />
162
163
          <label for="description">Description: </label>
164
          <input type="text" size="75" name="description" [% IF ( editDescription ) %] value="[% editDescription %]" [% END %]  />
165
          <br />
166
167
          <label for="publicEnrollment">Public Enrollment</label>
168
          <input type="radio" name="publicEnrollment" value="yes" [% IF ( editPublicEnrollment ) %] checked [% END %] >Yes</input>
169
          <input type="radio" name="publicEnrollment" value="no" [% IF ( editPublicEnrollment ) %][% ELSE %] checked [% END %]>No</input>
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" [% IF ( editCasData1Title ) %] value="[% editCasData1Title %]" [% END %] /></td>
183
              <td><label for="casData1Title">Description</label></td>
184
              <td><input type="text" name="casData1Desc" [% IF ( editCasData1Desc ) %] value="[% editCasData1Desc %]" [% END %] /></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" [% IF ( editCasData2Title ) %] value="[% editCasData2Title %]" [% END %] /></td>
191
              <td><label for="casData2Title">Description</label></td>
192
              <td><input type="text" name="casData2Desc" [% IF ( editCasData2Desc ) %] value="[% editCasData2Desc %]" [% END %] /></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" [% IF ( editCasData3Title ) %] value="[% editCasData3Title %]" [% END %] /></td>
199
              <td><label for="casData3Title">Description</label></td>
200
              <td><input type="text" name="casData3Desc" [% IF ( editCasData3Desc ) %] value="[% editCasData3Desc %]" [% END %] /></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 reading 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" [% IF ( editCaseData1Title ) %] value="[% editCaseData1Title %]" [% END %] /></td>
214
              <td><label for="caseData1Title">Description</label></td>
215
              <td><input type="text" name="caseData1Desc" [% IF ( editCaseData1Desc ) %] value="[% editCaseData1Desc %]" [% END %] /></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" [% IF ( editCaseData2Title ) %] value="[% editCaseData2Title %]" [% END %] /></td>
222
              <td><label for="caseData2Title">Description</label></td>
223
              <td><input type="text" name="caseData2Desc" [% IF ( editCaseData2Desc ) %] value="[% editCaseData2Desc %]" [% END %] /></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" [% IF ( editCaseData3Title ) %] value="[% editCaseData3Title %]" [% END %] /></td>
230
              <td><label for="caseData3Title">Description</label></td>
231
              <td><input type="text" name="caseData3Desc" [% IF ( editCaseData3Desc ) %] value="[% editCaseData3Desc %]" [% END %] /></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 E-mail</td>
239
			<td><i>If checked, a borrower will not be able to enroll unless he or she has a valid e-mail 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 (+325 lines)
Line 0 Link Here
1
[% INCLUDE 'doc-head-open.inc' %]  
2
<title>Koha &rsaquo; Tools &rsaquo; Clubs &amp Services &rsaquo; Edit</title>
3
[% INCLUDE 'doc-head-close.inc' %]
4
[% INCLUDE 'calendar.inc' %]
5
</head>
6
<body>
7
[% INCLUDE 'header.inc' %]
8
9
<div id="breadcrumbs">
10
  <a href="/cgi-bin/koha/mainpage.pl">Home</a> 
11
  &rsaquo; <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a>
12
  &rsaquo; <a href="/cgi-bin/koha/clubs_services/clubs_services.pl">Clubs &amp; Services</a>
13
  &rsaquo; Edit
14
</div>
15
16
<div id="doc3" class="yui-t2">
17
   <div id="bd">
18
        <div id="yui-main">
19
        <div class="yui-b">
20
21
<!-- These messages are uneccessary because you can see if it was deleted or created immediately
22
      [% IF ( previousActionCreate ) %]
23
        [% IF ( createSuccess ) %]
24
          <p>Club Or Service '[% createdTitle %]' Created Succesfully!</p>
25
        [% ELSE %]
26
          <p>Club or Service '[% createdTitle %]' Failed To Be Created!</p>
27
          <p>Reason: <strong>[% failureMessage %]</strong></p>
28
        [% END %]
29
      [% END %]
30
31
      [% IF ( previousActionDelete ) %]
32
        [% IF ( DeleteSuccess ) %]
33
          <p>Club or Service Deleted Succesfully!</p>
34
        [% ELSE %]
35
          <p>Club or Service Failed To Be Deleted!</p>
36
        [% END %]
37
      [% END %]
38
39
      [% IF ( previousActionUpdate ) %]
40
        [% IF ( updateSuccess ) %]
41
          <p>Club Or Service '[% updatedTitle %]' Updated Succesfully!</p>
42
        [% ELSE %]
43
          <p>Club or Service '[% updatedTitle %]' Failed To Be Updated!</p>
44
          <p>Reason: <strong>[% failureMessage %]</strong></p>
45
        [% END %]
46
      [% END %]
47
-->
48
49
          <table>
50
          <tr><th colspan="7">Clubs</th></tr>
51
            <tr>
52
              <th>Owner</th>
53
              <th>Title</th>
54
              <th>Description</th>
55
              <th>Start Date</th>
56
              <th>End Date</th>
57
              <th></th>
58
              <th></th>
59
            </tr>
60
         [% IF ( clubsLoop ) %]
61
            [% FOREACH clubsLoo IN clubsLoop %]
62
              <tr>
63
                <td>[% clubsLoo.branchcode %]</td>
64
                <td>[% clubsLoo.title %]</td>
65
                <td>[% clubsLoo.description %]</td>
66
                <td>[% clubsLoo.startDate %]</td>
67
                <td>[% clubsLoo.endDate %]</td>
68
                <td><a href="edit_clubs_services.pl?action=edit&casaId=[% clubsLoo.casaId %]&casId=[% clubsLoo.casId %]">Edit</a></td>
69
                <td><a href="edit_clubs_services.pl?action=delete&casId=[% clubsLoo.casId %]">Delete</a></td>
70
              </tr>
71
            [% END %]
72
        [% ELSE %]
73
          <tr><td colspan="7">There are no Clubs currently defined.</td></tr>
74
        [% END %]
75
76
          <tr><td colspan="7">&nbsp;</td></tr>
77
78
          <tr><th colspan="7">Services</th></tr>
79
80
            <tr>
81
              <th>Owner</th>
82
              <th>Title</th>
83
              <th>Description</th>
84
              <th>Start Date</th>
85
              <th>End Date</th>
86
              <th></th>
87
              <th></th>
88
            </tr>
89
90
        [% IF ( servicesLoop ) %]
91
            [% FOREACH servicesLoo IN servicesLoop %]
92
              <tr>
93
                <td>[% servicesLoo.branchcode %]</td>
94
                <td>[% servicesLoo.title %]</td>
95
                <td>[% servicesLoo.description %]</td>
96
                <td>[% servicesLoo.startDate %]</td>
97
                <td>[% servicesLoo.endDate %]</td>
98
                <td><a href="edit_clubs_services.pl?action=edit&casaId=[% servicesLoo.casaId %]&casId=[% servicesLoo.casId %]">Edit</a></td>
99
                <td><a href="edit_clubs_services.pl?action=delete&casId=[% servicesLoo.casId %]">Delete</a></td>
100
              </tr>
101
            [% END %]
102
          </table>
103
        [% ELSE %]
104
          <tr><td colspan="7">There are no Services currently defined.</td></tr>
105
        [% END %]
106
107
108
    [% IF ( previousActionSelectArchetype ) %]
109
      <!-- ADD NEW CAS FORM -->
110
       <table>
111
        [% IF ( previousActionEdit ) %]
112
          <tr><th colspan="10">Edit a Club or Service</th></tr>
113
        [% ELSE %]
114
          <tr><th colspan="10">Create New Club Or Service</th></tr>
115
        [% END %]
116
        <form action="edit_clubs_services.pl" method="post">
117
          [% IF ( previousActionEdit ) %]
118
            <input type="hidden" name="action" value="update" />
119
            <input type="hidden" name="casId" value="[% editCasId %]" />
120
          [% ELSE %]
121
            <input type="hidden" name="action" value="create" />
122
          [% END %]
123
124
125
            <tr>
126
              <td>
127
                <label for="casaId">Archetype: </label>
128
              </td>
129
              <td colspan="9">
130
                <select name="casaId">
131
                  <option value="[% casaId %]">[% casaTitle %]</option>
132
                </select>
133
              </td>
134
            </tr>
135
            <tr>
136
              <td>
137
                <label for="title">Title: </label>
138
              </td>
139
              <td colspan="9">
140
               <input type="text" name="title" [% IF ( editTitle ) %] value="[% editTitle %]" [% END %] />
141
              </td>
142
            </tr>
143
        
144
            <tr>
145
              <td>
146
                <label for="description">Description: </label>
147
              </td>
148
              <td colspan="2">
149
                <input type="text" size="50" name="description" [% IF ( editDescription ) %] value="[% editDescription %]" [% END %] />
150
              </td>
151
            </tr>
152
153
            [% IF ( casData1Title ) %]
154
              <tr>
155
                <td>
156
                  <label for="casData1">[% casData1Title %]: </label>
157
                </td>
158
                <td>
159
                  <input type="text" name="casData1" [% IF ( editCasData1 ) %] value="[% editCasData1 %]" [% END %] />
160
                </td>
161
                <td><i>[% casData1Desc %]</i></td>
162
              </tr>
163
            [% END %]
164
165
            [% IF ( casData2Title ) %]
166
              <tr>
167
                <td>
168
                  <label for="casData2">[% casData2Title %]: </label>
169
                </td>
170
                <td>
171
                  <input type="text" name="casData2" [% IF ( editCasData2 ) %] value="[% editCasData2 %]" [% END %] />
172
                </td>
173
                <td><i>[% casData2Desc %]</i></td>
174
              </tr>
175
            [% END %]
176
177
            [% IF ( casData3Title ) %]
178
              <tr>
179
                <td>
180
                  <label for="casData3">[% casData3Title %]: </label>
181
                </td>
182
                <td>
183
                  <input type="text" name="casData3" [% IF ( editCasData3 ) %] value="[% editCasData3 %]" [% END %] />
184
                </td>
185
                <td><i>[% casData3Desc %]</i></td>
186
              </tr>
187
            [% END %]
188
189
            <tr><td colspan="3"><i>Date format is : YYYY-MM-DD</i></td></tr>
190
191
192
            <tr>
193
              <td>
194
                <label for="startDate">Start Date: </label>
195
              </td>
196
              <td>
197
                <input type="text" size="10" maxlength="10" id= "startDate" name="startDate" [% IF ( editStartDate ) %] value="[% editStartDate %]" [% END %] />
198
199
		<img src="/intranet-tmpl/prog/en/lib/calendar/cal.gif" alt="Show Calendar"  border="0" id="CalendarStartDate" style="cursor: pointer;" />
200
                <script language="JavaScript" type="text/javascript">
201
			 //<![CDATA[
202
                   function validate1(date) {
203
                         var today = new Date();
204
                         if ( date < today ) {
205
                             return true;
206
                          } else {
207
                             return false;
208
                          }
209
                     };
210
                     function refocus(calendar) {
211
                        $('#barcode').focus();
212
                        calendar.hide();
213
                     };
214
215
                     Calendar.setup(
216
                          {
217
                             inputField : "startDate",
218
                             ifFormat : "%Y-%m-%d",
219
                             button : "CalendarStartDate",
220
                             onClose : refocus
221
                           }
222
                        );
223
				//]]>
224
                 </script>
225
226
              </td>
227
              <td>
228
                <i>Optional: Leave blank for start date of today.</i>
229
              </td>
230
            </tr>
231
232
            <tr>
233
              <td>
234
                <label for="endDate">End Date: </label>
235
              </td>
236
              <td>
237
                <input type="text" size="10" maxlength="10" id="endDate" name="endDate" [% IF ( editEndDate ) %] value="[% editEndDate %]" [% END %] />
238
239
		<img src="/intranet-tmpl/prog/en/lib/calendar/cal.gif" alt="Show Calendar"  border="0" id="CalendarEndDate" style="cursor: pointer;" />
240
                <script language="JavaScript" type="text/javascript">
241
			 //<![CDATA[
242
                   function validate1(date) {
243
                         var today = new Date();
244
                         if ( date < today ) {
245
                             return true;
246
                          } else {
247
                             return false;
248
                          }
249
                     };
250
                     function refocus(calendar) {
251
                        $('#barcode').focus();
252
                        calendar.hide();
253
                     };
254
255
                     Calendar.setup(
256
                          {
257
                             inputField : "endDate",
258
                             ifFormat : "%Y-%m-%d",
259
                             button : "CalendarEndDate",
260
                             onClose : refocus
261
                           }
262
                        );
263
				//]]>
264
                 </script>
265
266
              </td>
267
              <td>
268
                <i>Optional: Leave blank for no end date.</i>
269
              </td>
270
            </tr>
271
272
            <tr>
273
              <td colspan="3">
274
                [% IF ( previousActionEdit ) %]
275
                  <input type="submit" value="Update" />
276
                [% ELSE %]
277
                  <input type="submit" value="Create" />
278
                [% END %]
279
              </td>
280
            </tr>
281
          </table>
282
        </form>
283
    [% ELSE %]
284
285
      <!-- SELECT ARCHETYPE FORM -->
286
      <table>
287
      <tr><th colspan="2">Create New Club or Service</th></tr>
288
      <tr><td>
289
      [% IF ( archetypes ) %]
290
        <form action="edit_clubs_services.pl" method="post">
291
          <input type="hidden" name="action" value="selectArchetype" />
292
          <label for="casaId">Select Archetype</label>
293
          <select name="casaId">
294
            [% FOREACH archetypesLoo IN archetypesLoop %]
295
              <option value="[% archetypesLoo.casaId %]">[% archetypesLoo.title %]</option>
296
            [% END %]
297
          </select>
298
          </td>
299
          <td><input type="submit" value="Create" /></td>
300
	</form>
301
      [% ELSE %]
302
        No Archetypes Defined.
303
      [% END %]
304
      </tr>
305
      </table>
306
    [% END %]
307
308
</div>
309
</div>
310
311
<div class="yui-b">
312
<div id="menu">
313
  <ul>
314
    [% IF ( clubs_services ) %]<li class="active">[% ELSE %]<li>[% END %]<a href="clubs_services.pl">Clubs &amp; Services Home</a></li>
315
    [% IF ( edit_archetypes ) %]<li class="active">[% ELSE %]<li>[% END %]<a href="edit_archetypes.pl">Edit Archetypes</a></li>
316
    [% IF ( edit_clubs_services ) %]<li class="active">[% ELSE %]<li>[% END %]<a href="edit_clubs_services.pl">Edit Clubs & Services</a></li>
317
  </ul>
318
</div>
319
</div>
320
321
</div>
322
</div>
323
324
[% INCLUDE 'intranet-bottom.inc' %]
325
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/clubs_services/enroll_clubs_services.tt (+89 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>Reason: <strong>[% failureMessage %]</strong></div>
26
            [% END %]
27
          [% END %]
28
29
30
          <h3>Enroll a Patron in <i>[% casTitle %]</i></h3>
31
      </div>
32
33
      <div>
34
        <form action="enroll_clubs_services.pl" method="post">
35
        <table>
36
          [% IF ( caseData1Title ) %]
37
            <tr>
38
              <th><label for="data1">[% caseData1Title %]: </label></th>
39
              <td><input type="text" id="data1" name="data1" /></td>
40
              <td><i>[% caseData1Desc %]</i></td>
41
            </tr>
42
          [% END %]
43
44
          [% IF ( caseData2Title ) %]
45
            <tr>
46
              <th><label for="data2">[% caseData2Title %]: </label></th>
47
              <td><input type="text" id="data2" name="data2" /></td>
48
              <td><i>[% caseData2Desc %]</i></td>
49
            </tr>
50
          [% END %]
51
52
          [% IF ( caseData3Title ) %]
53
            <tr>
54
              <th><label for="data3">[% caseData3Title %]: </label></th>
55
              <td><input type="text" id="data3" name="data3" /></td>
56
              <td><i>[% caseData3Desc %]</i></td>
57
            </tr>
58
          [% END %]
59
60
          <tr>
61
            <th><label for="borrowerBarcode">Borrower Cardnumber: </label></th>
62
            <td colspan="2"><input type="text" id="borrowerBarcode" name="borrowerBarcode" /></td>
63
          </tr>
64
65
          <input type="hidden" id="casId" name="casId" value="[% casId %]" />
66
          <input type="hidden" id="casaId" name="casaId" value="[% casaId %]" />
67
          <input type="hidden" name="action" value="enroll" /> 
68
          <tr><td colspan="3"><input type="submit" value="Enroll" /></td></tr>
69
        </table>
70
        </form>
71
      </div>
72
73
</div>
74
</div>
75
76
<div class="yui-b">
77
<div id="menu"> 
78
  <ul>
79
    [% IF ( clubs_services ) %]<li class="active">[% ELSE %]<li>[% END %]<a href="clubs_services.pl">Clubs &amp; Services Home</a></li>
80
    [% IF ( edit_archetypes ) %]<li class="active">[% ELSE %]<li>[% END %]<a href="edit_archetypes.pl">Edit Archetypes</a></li>
81
    [% IF ( edit_clubs_services ) %]<li class="active">[% ELSE %]<li>[% END %]<a href="edit_clubs_services.pl">Edit Clubs & Services</a></li>
82
  </ul>
83
</div>
84
</div>
85
86
</div>
87
</div> 
88
89
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/clubs_services.tt (+84 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><a href="clubs_services.pl?action=cancel&caseId=[% enrolledClubsAndServicesLoo.caseId %]&borrowernumber=[% borrowernumber %]">Cancel</a></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
  <tr><td colspan="5">&nbsp;</td></tr>
47
48
  <thead>
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
  </thead>
58
59
  <tbody>
60
[% IF ( enrollableClubsAndServicesLoop ) %]
61
62
    [% FOREACH enrollableClubsAndServicesLoo IN enrollableClubsAndServicesLoop %]
63
      [% IF ( enrollableClubsAndServicesLoo.odd ) %]<tr class="highlight">[% ELSE %]<tr>[% END %]
64
        <td>[% enrollableClubsAndServicesLoo.title %]</td>
65
        <td>[% enrollableClubsAndServicesLoo.description %]</td>
66
        <td>[% enrollableClubsAndServicesLoo.branchcode %]</td>
67
        <td>[% enrollableClubsAndServicesLoo.type %]</td>
68
        <td><a href="clubs_services_enroll.pl?casId=[% enrollableClubsAndServicesLoo.casId %]&casaId=[% enrollableClubsAndServicesLoo.casaId %]&borrowernumber=[% borrowernumber %]">Enroll</a></td>
69
      </tr>
70
    [% END %]
71
[% ELSE %]
72
  <tr><td colspan="5">There Are No New Clubs Or Services To Enroll In</td></tr>
73
[% END %]
74
  </tbody>
75
76
  </table>
77
78
</div>
79
</div>
80
<div class="yui-b">
81
[% INCLUDE 'circ-menu.inc' %]
82
</div>
83
</div> 
84
[% 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 55-60 Link Here
55
	<dd>Upload patron images in batch or one at a time</dd>
55
	<dd>Upload patron images in batch or one at a time</dd>
56
    [% END %]
56
    [% END %]
57
57
58
    <dt><a href="/cgi-bin/koha/clubs_services/clubs_services.pl">Clubs & Services</a></dt>
59
    <dd>Create and Edit Clubs & Services</dd>
58
60
59
61
60
	</dl>
62
	</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 (+58 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)
18
    = get_template_and_user({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
# get borrower information ....
27
my $borrowerData = GetMemberDetails( $borrowernumber );
28
$template->param(
29
  borrowernumber => $borrowernumber,
30
  surname => $borrowerData->{'surname'},
31
  firstname => $borrowerData->{'firstname'},
32
  cardnumber => $borrowerData->{'cardnumber'},
33
  address => $borrowerData->{'address'},
34
  city => $borrowerData->{'city'},
35
  phone => $borrowerData->{'phone'},
36
  email => $borrowerData->{'email'},
37
  categorycode => $borrowerData->{'categorycode'},
38
  categoryname => $borrowerData->{'description'},
39
  branchcode => $borrowerData->{'branchcode'},
40
  branchname => C4::Branch::GetBranchName($borrowerData->{'branchcode'}),
41
);
42
                                                
43
44
45
if ( $query->param('action') eq 'cancel' ) { ## Cancel the enrollment in the passed club or service
46
  CancelClubOrServiceEnrollment( $query->param('caseId') );
47
}
48
49
## Get the borrowers current clubs & services
50
my $enrolledClubsAndServices = GetEnrolledClubsAndServices( $borrowernumber );
51
$template->param( enrolledClubsAndServicesLoop => $enrolledClubsAndServices );
52
53
## Get clubs & services the borrower can enroll in from the Intranet
54
my $enrollableClubsAndServices = GetAllEnrollableClubsAndServices( $borrowernumber, $query->cookie('branch') );
55
$template->param( enrollableClubsAndServicesLoop => $enrollableClubsAndServices );
56
57
output_html_with_http_headers $query, $cookie, $template->output;
58
(-)a/members/clubs_services_enroll.pl (+133 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)
18
    = get_template_and_user({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
# get borrower information ....
27
my $borrowerData = GetMemberDetails( $borrowernumber );
28
$template->param(
29
  borrowernumber => $borrowernumber,
30
  surname => $borrowerData->{'surname'},
31
  firstname => $borrowerData->{'firstname'},
32
  cardnumber => $borrowerData->{'cardnumber'},
33
  address => $borrowerData->{'address'},
34
  city => $borrowerData->{'city'},
35
  phone => $borrowerData->{'phone'},
36
  email => $borrowerData->{'email'},
37
  categorycode => $borrowerData->{'categorycode'},
38
  categoryname => $borrowerData->{'description'},
39
  branchcode => $borrowerData->{'branchcode'},
40
  branchname => C4::Branch::GetBranchName($borrowerData->{'branchcode'}),
41
);
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, $errorCode, $errorMessage ) = EnrollInClubOrService( $casaId, $casId, '', $dateEnrolled, $data1, $data2, $data3, '', $borrowernumber  );
54
                
55
  $template->param(
56
    previousActionEnroll => 1,
57
  );
58
                            
59
  if ( $success ) {
60
    $template->param( enrollSuccess => 1 );
61
  } else {
62
    $template->param( enrollFailure => 1 );
63
    $template->param( failureMessage => $errorMessage );
64
  }
65
                                              
66
} elsif ( DoesEnrollmentRequireData( $query->param('casaId') ) ) { ## We were not passed any data, and the service requires extra data
67
  my ( $casId, $casaId, $casTitle, $casDescription, $casStartDate, $casEndDate, $casTimestamp ) = GetClubOrService( $query->param('casId') );
68
  my ( $casaId, $casaType, $casaTitle, $casaDescription, $casaPublicEnrollment,
69
       $casData1Title, $casData2Title, $casData3Title,
70
       $caseData1Title, $caseData2Title, $caseData3Title,
71
       $casData1Desc, $casData2Desc, $casData3Desc,
72
       $caseData1Desc, $caseData2Desc, $caseData3Desc,
73
       $timestamp )= GetClubOrServiceArchetype( $casaId );
74
  $template->param(
75
                  casId => $casId,
76
                  casTitle => $casTitle,
77
                  casDescription => $casDescription,
78
                  casStartDate => $casStartDate,
79
                  casEndDate => $casEndDate,
80
                  casTimeStamp => $casTimestamp,
81
                  casaId => $casaId,
82
                  casaType => $casaType,
83
                  casaTitle => $casaTitle,
84
                  casaDescription => $casaDescription,
85
                  casaPublicEnrollment => $casaPublicEnrollment,
86
87
                  borrowernumber => $borrowernumber,
88
                  );
89
90
  if ( $caseData1Title ) {
91
    $template->param( caseData1Title => $caseData1Title );
92
  }
93
  if ( $caseData2Title ) {
94
    $template->param( caseData2Title => $caseData2Title );
95
  }
96
  if ( $caseData3Title ) {
97
    $template->param( caseData3Title => $caseData3Title );
98
  }
99
  
100
  if ( $caseData1Desc ) {
101
    $template->param( caseData1Desc => $caseData1Desc );
102
  }
103
  if ( $caseData2Desc ) {
104
    $template->param( caseData2Desc => $caseData2Desc );
105
  }
106
  if ( $caseData3Desc ) {
107
    $template->param( caseData3Desc => $caseData3Desc );
108
  }
109
      
110
} else { ## We were not passed any data, but the enrollment does not require any
111
112
  my $casId = $query->param('casId');
113
  my $casaId = $query->param('casaId');
114
            
115
  my $dateEnrolled; # Will default to Today
116
              
117
  my ( $success, $errorCode, $errorMessage ) = EnrollInClubOrService( $casaId, $casId, '', $dateEnrolled, '', '', '', '', $borrowernumber  );
118
                
119
  $template->param(
120
    previousActionEnroll => 1,
121
  );
122
                            
123
  if ( $success ) {
124
    $template->param( enrollSuccess => 1 );
125
  } else {
126
    $template->param( enrollFailure => 1 );
127
    $template->param( failureMessage => $errorMessage );
128
  }
129
130
131
}
132
output_html_with_http_headers $query, $cookie, $template->output;
133
(-)a/misc/cronjobs/mailinglist/mailinglist.pl (+178 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 HTML::Template::Pro;
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 "\nmailinglist.pl --name [Club Name] --start [Days Ago] --end [Days Ago]\n\n";
65
  print "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";
66
  print "All arguments are optional. Defaults are to run for all clubs, with dates from 7 to 0 days ago.\n\n";
67
  exit;
68
}
69
70
unless( C4::Context->preference('OPACBaseURL') ) { die("Koha System Preference 'OPACBaseURL' is not set!"); }
71
my $opacUrl = 'http://' . C4::Context->preference('OPACBaseURL');
72
        
73
my $dbh = C4::Context->dbh;
74
my $sth;
75
76
## Step 0: Get the date from last week
77
  #Gets localtime on the computer executed on.
78
  my ($d, $m, $y) = (localtime)[3,4,5];
79
80
  ## 0.1 Get start date
81
  #Adjust the offset to either a neg or pos number of days.
82
  my $offset = -7;
83
  if ( $start ) { $offset = $start * -1; }
84
  #Formats the date and sets the offset to subtract 60 days form the #current date. This works with the first line above.
85
  my ($y2, $m2, $d2) = Add_Delta_Days($y+1900, $m+1, $d, $offset);
86
  #Checks to see if the month is greater than 10.
87
  if ($m2<10) {$m2 = "0" . $m2;};
88
  #Put in format of mysql date YYYY-MM-DD
89
  my $afterDate = $y2 . '-' . $m2 . '-' . $d2;
90
  if ( $verbose ) { print "Date $offset Days Ago: $afterDate\n"; }
91
92
  ## 0.2 Get end date
93
  #Adjust the offset to either a neg or pos number of days.
94
  $offset = 0;
95
  if ( $end ) { $offset = $end * -1; }
96
  ($y2, $m2, $d2) = Add_Delta_Days($y+1900, $m+1, $d, $offset);
97
  if ($m2<10) {$m2 = "0" . $m2;};
98
  my $beforeDate = $y2 . '-' . $m2 . '-' . $d2;
99
  if ( $verbose ) { print "Date $offset Days Ago: $beforeDate\n"; }
100
101
if ( $name ) {
102
103
  $sth = $dbh->prepare("SELECT * FROM clubsAndServices WHERE clubsAndServices.title = ?");
104
  $sth->execute( $name );
105
  
106
} else { ## No name given, process all items
107
108
  ## Grab the "New Items E-mail List" Archetype
109
  $sth = $dbh->prepare("SELECT * FROM clubsAndServicesArchetypes WHERE title = 'New Items E-mail List'");
110
  $sth->execute;
111
  my $archetype = $sth->fetchrow_hashref();
112
113
  ## Grab all the mailing lists
114
  $sth = $dbh->prepare("SELECT * FROM clubsAndServices WHERE clubsAndServices.casaId = ?");
115
  $sth->execute( $archetype->{'casaId'} );
116
  
117
}
118
119
## For each mailing list, generate the list of new items, then get the subscribers, then mail the list to the subscribers
120
while( my $mailingList = $sth->fetchrow_hashref() ) {
121
  ## Get the new Items
122
  if ( $verbose ) { print "###\nWorking On Mailing List: " . $mailingList->{'title'} . "\n"; }
123
  my $itemtype = $mailingList->{'casData1'};
124
  my $callnumber = $mailingList->{'casData2'};
125
  ## If either are empty, ignore them with a wildcard
126
  if ( ! $itemtype ) { $itemtype = '%'; }
127
  if ( ! $callnumber ) { $callnumber = '%'; }
128
  
129
  my $sth2 = $dbh->prepare("SELECT
130
                            biblio.author, 
131
                            biblio.title, 
132
                            biblio.biblionumber,
133
                            biblioitems.isbn, 
134
                            items.itemcallnumber
135
                            FROM 
136
                            items, biblioitems, biblio
137
                            WHERE
138
                            biblio.biblionumber = biblioitems.biblionumber AND
139
                            biblio.biblionumber = items.biblionumber AND
140
                            biblioitems.itemtype LIKE ? AND
141
                            items.itemcallnumber LIKE ? AND
142
                            dateaccessioned >= ? AND
143
                            dateaccessioned <= ?");
144
  $sth2->execute( $itemtype, $callnumber, $afterDate, $beforeDate );
145
  my @newItems;
146
  while ( my $row = $sth2->fetchrow_hashref ) {
147
    $row->{'opacUrl'} = $opacUrl;
148
    push( @newItems , $row );
149
  }
150
print Dumper ( @newItems );
151
  $sth2->finish;
152
  my $newItems = \@newItems;          
153
  my $template = HTML::Template->new( filename => 'mailinglist.tmpl' );
154
  $template->param( 
155
                    listTitle => $mailingList->{'title'},
156
                    newItemsLoop => $newItems,
157
                  );
158
  my $email = $template->output;
159
  
160
  ## Get all the members subscribed to this list
161
  $sth2 = $dbh->prepare("SELECT * FROM clubsAndServicesEnrollments, borrowers 
162
                         WHERE
163
                         borrowers.borrowernumber = clubsAndServicesEnrollments.borrowernumber AND
164
                         clubsAndServicesEnrollments.dateCanceled IS NULL AND
165
                         clubsAndServicesEnrollments.casId = ?");
166
  $sth2->execute( $mailingList->{'casId'} );
167
  while ( my $borrower = $sth2->fetchrow_hashref() ) {
168
    if ( $verbose ) { print "Borrower Email: " . $borrower->{'email'} . "\n"; }
169
    
170
    my $letter;
171
    $letter->{'title'} = 'New Items @ Your Library: ' . $mailingList->{'title'};
172
    $letter->{'content'} = $email;
173
    $letter->{'code'} = 'MAILINGLIST';
174
    C4::Message->enqueue($letter, $borrower, 'email');
175
  }
176
  
177
  
178
}
(-)a/misc/cronjobs/mailinglist/mailinglist.tmpl (+35 lines)
Line 0 Link Here
1
<html>
2
  <head></head>
3
  <body>
4
    <table>
5
      <h2>New Items @ Your Library!</h2>
6
      <h3><!-- TMPL_VAR NAME="listTitle" --></h3>
7
<!-- TMPL_LOOP NAME="newItemsLoop" -->
8
9
<a href="<!-- TMPL_VAR NAME="opacUrl" -->/cgi-bin/koha/opac-detail.pl?bib=<!-- TMPL_VAR NAME="biblionumber" ESCAPE="URL" -->">
10
<h2 style="color:#000000;font:bold 15px Verdana, Geneva, Arial, Helvetica, sans-serif;border-bottom:3px solid #ffcc33">
11
  <!-- TMPL_VAR NAME="title" -->
12
</h2>
13
</a>
14
<table border="0" cellpadding="2" cellspacing="0" width="92%" align="center">
15
  <tr>
16
    <td valign="top">
17
      <a href="<!-- TMPL_VAR NAME="opacUrl" -->/cgi-bin/koha/opac-detail.pl?bib=<!-- TMPL_VAR NAME="biblionumber" ESCAPE="URL" -->"><img src="<!-- TMPL_IF NAME="isbn" -->http://images.amazon.com/images/P/<!-- TMPL_VAR name="isbn" -->.01.TZZZZZZZ.jpg<!-- TMPL_ELSE -->http://g-images.amazon.com/images/G/01/x-site/icons/no-img-sm.gif<!-- /TMPL_IF -->" alt="" class="thumbnail" /></a>
18
    </td>
19
    <td valign="top">
20
      <p style="color:#000000">
21
        <ul>
22
          <li>Author: <!-- TMPL_VAR NAME="author" --></li>
23
          <li>ISBN: <!-- TMPL_VAR NAME="isbn" --></li>
24
          <li>Call Number: <!-- TMPL_VAR NAME="itemcallnumber" --></li>
25
        </ul>
26
        <br>
27
      </p>
28
    </td>
29
  </tr>
30
</table>
31
<!-- /TMPL_LOOP -->
32
33
34
  </body>
35
</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