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

(-)a/C4/Auth.pm (+1 lines)
Lines 207-212 sub get_template_and_user { Link Here
207
            $template->param( CAN_user_serials          => 1 );
207
            $template->param( CAN_user_serials          => 1 );
208
            $template->param( CAN_user_reports          => 1 );
208
            $template->param( CAN_user_reports          => 1 );
209
            $template->param( CAN_user_staffaccess      => 1 );
209
            $template->param( CAN_user_staffaccess      => 1 );
210
            $template->param( CAN_user_clubs_services   => 1 );
210
            foreach my $module (keys %$all_perms) {
211
            foreach my $module (keys %$all_perms) {
211
                foreach my $subperm (keys %{ $all_perms->{$module} }) {
212
                foreach my $subperm (keys %{ $all_perms->{$module} }) {
212
                    $template->param( "CAN_user_${module}_${subperm}" => 1 );
213
                    $template->param( "CAN_user_${module}_${subperm}" => 1 );
(-)a/C4/ClubsAndServices.pm (+1289 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
=head2 AddClubOrServiceArchetype
78
79
Creates a new archetype for a club or service
80
An archetype is something after which other things a patterned,
81
For example, you could create a 'Summer Reading Club' club archtype
82
which is then used to create an individual 'Summer Reading Club' 
83
*for each library* in your system.
84
85
Input:
86
   $type : 'club' or 'service', could be extended to add more types
87
   $title: short description of the club or service
88
   $description: long description of the club or service
89
   $publicEnrollment: If true, any borrower should be able
90
       to enroll in club or service from opac. If false,
91
       Only a librarian should be able to enroll a borrower
92
       in the club or service.
93
   $casData1Title: explanation of what is stored in
94
      clubsAndServices.casData1Title
95
   $casData2Title: same but for casData2Title
96
   $casData3Title: same but for casData3Title
97
   $caseData1Title: explanation of what is stored in
98
     clubsAndServicesEnrollment.data1
99
   $caseData2Title: Same but for data2
100
   $caseData3Title: Same but for data3
101
   $casData1Desc: Long explanation of what is stored in
102
      clubsAndServices.casData1Title
103
   $casData2Desc: same but for casData2Title
104
   $casData3Desc: same but for casData3Title
105
   $caseData1Desc: Long explanation of what is stored in
106
     clubsAndServicesEnrollment.data1
107
   $caseData2Desc: Same but for data2
108
   $caseData3Desc: Same but for data3
109
   $caseRequireEmail: If 1, enrollment in clubs or services based on this archetype will require a valid e-mail address field in the borrower
110
	record as specified in the syspref AutoEmailPrimaryAddress
111
   $branchcode: The branchcode for the branch where this Archetype was created
112
113
 Output:
114
   $success: 1 if all database operations were successful, 0 otherwise
115
   $errorCode: Code for reason of failure, good for translating errors in templates
116
   $errorMessage: English description of error
117
118
=cut
119
120
sub AddClubOrServiceArchetype {
121
  my ( $type, $title, $description, $publicEnrollment, 
122
       $casData1Title, $casData2Title, $casData3Title, 
123
       $caseData1Title, $caseData2Title, $caseData3Title, 
124
       $casData1Desc, $casData2Desc, $casData3Desc, 
125
       $caseData1Desc, $caseData2Desc, $caseData3Desc, 
126
       $caseRequireEmail, $branchcode ) = @_;
127
128
  ## Check for all neccessary parameters
129
  if ( ! $type ) {
130
    return ( 0, 1, "No Type Given" );
131
  } 
132
  if ( ! $title ) {
133
    return ( 0, 2, "No Title Given" );
134
  } 
135
  if ( ! $description ) {
136
    return ( 0, 3, "No Description Given" );
137
  } 
138
139
  my $success = 1;
140
141
  my $dbh = C4::Context->dbh;
142
143
  my $sth;
144
  $sth = $dbh->prepare("INSERT INTO clubsAndServicesArchetypes ( casaId, type, title, description, publicEnrollment, caseRequireEmail, branchcode, last_updated ) 
145
                        VALUES ( NULL, ?, ?, ?, ?, ?, ?, CURRENT_TIMESTAMP)");
146
  $sth->execute( $type, $title, $description, $publicEnrollment, $caseRequireEmail, $branchcode ) or $success = 0;
147
  my $casaId = $dbh->{'mysql_insertid'};
148
  $sth->finish;
149
150
  if ( $casData1Title ) {
151
    $sth = $dbh->prepare("UPDATE clubsAndServicesArchetypes SET casData1Title = ? WHERE casaId = ?");
152
    $sth->execute( $casData1Title, $casaId ) or $success = 0;
153
    $sth->finish;
154
  }
155
  if ( $casData2Title ) {
156
    $sth = $dbh->prepare("UPDATE clubsAndServicesArchetypes SET casData2Title = ? WHERE casaId = ?");
157
    $sth->execute( $casData2Title, $casaId ) or $success = 0;
158
    $sth->finish;
159
  }
160
  if ( $casData3Title ) {
161
    $sth = $dbh->prepare("UPDATE clubsAndServicesArchetypes SET casData3Title = ? WHERE casaId = ?");
162
    $sth->execute( $casData3Title, $casaId ) or $success = 0;
163
    $sth->finish;
164
  }
165
166
  
167
  if ( $caseData1Title ) {
168
    $sth = $dbh->prepare("UPDATE clubsAndServicesArchetypes SET caseData1Title = ? WHERE casaId = ?");
169
    $sth->execute( $caseData1Title, $casaId ) or $success = 0;
170
    $sth->finish;
171
  }
172
  if ( $caseData2Title ) {
173
    $sth = $dbh->prepare("UPDATE clubsAndServicesArchetypes SET caseData2Title = ? WHERE casaId = ?");
174
    $sth->execute( $caseData2Title, $casaId ) or $success = 0;
175
    $sth->finish;
176
  }
177
  if ( $caseData3Title ) {
178
    $sth = $dbh->prepare("UPDATE clubsAndServicesArchetypes SET caseData3Title = ? WHERE casaId = ?");
179
    $sth->execute( $caseData3Title, $casaId ) or $success = 0;
180
    $sth->finish;
181
  }
182
183
  if ( $casData1Desc ) {
184
    $sth = $dbh->prepare("UPDATE clubsAndServicesArchetypes SET casData1Desc = ? WHERE casaId = ?");
185
    $sth->execute( $casData1Desc, $casaId ) or $success = 0;
186
    $sth->finish;
187
  }
188
  if ( $casData2Desc ) {
189
    $sth = $dbh->prepare("UPDATE clubsAndServicesArchetypes SET casData2Desc = ? WHERE casaId = ?");
190
    $sth->execute( $casData2Desc, $casaId ) or $success = 0;
191
    $sth->finish;
192
  }
193
  if ( $casData3Desc ) {
194
    $sth = $dbh->prepare("UPDATE clubsAndServicesArchetypes SET casData3Desc = ? WHERE casaId = ?");
195
    $sth->execute( $casData3Desc, $casaId ) or $success = 0;
196
    $sth->finish;
197
  }
198
  
199
  if ( $caseData1Desc ) {
200
    $sth = $dbh->prepare("UPDATE clubsAndServicesArchetypes SET caseData1Desc = ? WHERE casaId = ?");
201
    $sth->execute( $caseData1Desc, $casaId ) or $success = 0;
202
    $sth->finish;
203
  }
204
  if ( $caseData2Desc ) {
205
    $sth = $dbh->prepare("UPDATE clubsAndServicesArchetypes SET caseData2Desc = ? WHERE casaId = ?");
206
    $sth->execute( $caseData2Desc, $casaId ) or $success = 0;
207
    $sth->finish;
208
  }
209
  if ( $caseData3Desc ) {
210
    $sth = $dbh->prepare("UPDATE clubsAndServicesArchetypes SET caseData3Desc = ? WHERE casaId = ?");
211
    $sth->execute( $caseData3Desc, $casaId ) or $success = 0;
212
    $sth->finish;
213
  }
214
215
  my ( $errorCode, $errorMessage );
216
  if ( ! $success ) {
217
    $errorMessage = "Database Failure";
218
    $errorCode = 4;
219
  }
220
  
221
  return( $success, $errorCode, $errorMessage );
222
  
223
}
224
225
=head2 UpdateClubOrServiceArchetype
226
227
 Updates an archetype for a club or service
228
229
 Input:
230
   $casaId: id of the archetype to be updated
231
   $type : 'club' or 'service', could be extended to add more types
232
   $title: short description of the club or service
233
   $description: long description of the club or service
234
   $publicEnrollment: If true, any borrower should be able
235
       to enroll in club or service from opac. If false,
236
       Only a librarian should be able to enroll a borrower
237
       in the club or service.
238
   $casData1Title: explanation of what is stored in
239
      clubsAndServices.casData1Title
240
   $casData2Title: same but for casData2Title
241
   $casData3Title: same but for casData3Title
242
   $caseData1Title: explanation of what is stored in
243
     clubsAndServicesEnrollment.data1
244
   $caseData2Title: Same but for data2
245
   $caseData3Title: Same but for data3
246
   $casData1Desc: Long explanation of what is stored in
247
      clubsAndServices.casData1Title
248
   $casData2Desc: same but for casData2Title
249
   $casData3Desc: same but for casData3Title
250
   $caseData1Desc: Long explanation of what is stored in
251
     clubsAndServicesEnrollment.data1
252
   $caseData2Desc: Same but for data2
253
   $caseData3Desc: Same but for data3
254
   $caseRequireEmail: If 1, enrollment in clubs or services based on this archetype will require a valid e-mail address field in the borrower
255
	record as specified in the syspref AutoEmailPrimaryAddress
256
257
 Output:
258
   $success: 1 if all database operations were successful, 0 otherwise
259
   $errorCode: Code for reason of failure, good for translating errors in templates
260
   $errorMessage: English description of error
261
   
262
=cut
263
264
sub UpdateClubOrServiceArchetype {
265
  my ( $casaId, $type, $title, $description, $publicEnrollment, 
266
       $casData1Title, $casData2Title, $casData3Title, 
267
       $caseData1Title, $caseData2Title, $caseData3Title,
268
       $casData1Desc, $casData2Desc, $casData3Desc, 
269
       $caseData1Desc, $caseData2Desc, $caseData3Desc,
270
       $caseRequireEmail,
271
     ) = @_;
272
273
  ## Check for all neccessary parameters
274
  if ( ! $casaId ) {
275
    return ( 0, 1, "No Id Given" );
276
  }
277
  if ( ! $type ) {
278
    return ( 0, 2, "No Type Given" );
279
  } 
280
  if ( ! $title ) {
281
    return ( 0, 3, "No Title Given" );
282
  } 
283
  if ( ! $description ) {
284
    return ( 0, 4, "No Description Given" );
285
  } 
286
287
  my $success = 1;
288
289
  my $dbh = C4::Context->dbh;
290
291
  my $sth;
292
  $sth = $dbh->prepare("UPDATE clubsAndServicesArchetypes 
293
                        SET 
294
                        type = ?, title = ?, description = ?, publicEnrollment = ?, 
295
                        casData1Title = ?, casData2Title = ?, casData3Title = ?,
296
                        caseData1Title = ?, caseData2Title = ?, caseData3Title = ?, 
297
                        casData1Desc = ?, casData2Desc = ?, casData3Desc = ?,
298
                        caseData1Desc = ?, caseData2Desc = ?, caseData3Desc = ?, caseRequireEmail = ?,
299
                        last_updated = NOW() WHERE casaId = ?");
300
301
  $sth->execute( $type, $title, $description, $publicEnrollment, 
302
                 $casData1Title, $casData2Title, $casData3Title, 
303
                 $caseData1Title, $caseData2Title, $caseData3Title, 
304
                 $casData1Desc, $casData2Desc, $casData3Desc, 
305
                 $caseData1Desc, $caseData2Desc, $caseData3Desc, 
306
                 $caseRequireEmail, $casaId ) 
307
      or return ( $success = 0, my $errorCode = 6, my $errorMessage = $sth->errstr() );
308
  $sth->finish;
309
  
310
  return $success;
311
  
312
}
313
314
=head2 DeleteClubOrServiceArchetype
315
316
 Deletes an Archetype of the given id
317
 and all Clubs or Services based on it,
318
 and all Enrollments based on those clubs
319
 or services.
320
321
 Input:
322
   $casaId : id of the Archtype to be deleted
323
324
 Output:
325
   $success : 1 on successful deletion, 0 otherwise
326
327
=cut
328
329
sub DeleteClubOrServiceArchetype {
330
  my ( $casaId ) = @_;
331
332
  ## Paramter check
333
  if ( ! $casaId ) {
334
    return 0;
335
  }
336
  
337
  my $success = 1;
338
339
  my $dbh = C4::Context->dbh;
340
341
  my $sth;
342
343
  $sth = $dbh->prepare("DELETE FROM clubsAndServicesEnrollments WHERE casaId = ?");
344
  $sth->execute( $casaId ) or $success = 0;
345
  $sth->finish;
346
347
  $sth = $dbh->prepare("DELETE FROM clubsAndServices WHERE casaId = ?");
348
  $sth->execute( $casaId ) or $success = 0;
349
  $sth->finish;
350
351
  $sth = $dbh->prepare("DELETE FROM clubsAndServicesArchetypes WHERE casaId = ?");
352
  $sth->execute( $casaId ) or $success = 0;
353
  $sth->finish;
354
355
  return 1;
356
}
357
358
=head2 AddClubOrService
359
360
 Creates a new club or service in the database
361
362
 Input:
363
   $type: 'club' or 'service', other types may be added as necessary.
364
   $title: Short description of the club or service
365
   $description: Long description of the club or service
366
   $casData1: The data described in case.casData1Title
367
   $casData2: The data described in case.casData2Title
368
   $casData3: The data described in case.casData3Title
369
   $startDate: The date the club or service begins ( Optional: Defaults to TODAY() )
370
   $endDate: The date the club or service ends ( Optional )
371
   $branchcode: Branch that created this club or service ( Optional: NULL is system-wide )
372
373
 Output:
374
   $success: 1 on successful add, 0 on failure
375
   $errorCode: Code for reason of failure, good for translating errors in templates
376
   $errorMessage: English description of error
377
   
378
=cut
379
380
sub AddClubOrService {
381
  my ( $casaId, $title, $description, $casData1, $casData2, $casData3, $startDate, $endDate, $branchcode ) = @_;
382
383
  ## Check for all neccessary parameters
384
  if ( ! $casaId ) {
385
    return ( 0, 1, "No Archetype Given" );
386
  } 
387
  if ( ! $title ) {
388
    return ( 0, 2, "No Title Given" );
389
  } 
390
  if ( ! $description ) {
391
    return ( 0, 3, "No Description Given" );
392
  } 
393
  
394
  my $success = 1;
395
396
  if ( ! $startDate ) {
397
    $startDate = getTodayMysqlDateFormat();
398
  }
399
  
400
  my $dbh = C4::Context->dbh;
401
402
  my $sth;
403
  if ( $endDate ) {
404
    $sth = $dbh->prepare("INSERT INTO clubsAndServices ( casId, casaId, title, description, casData1, casData2, casData3, startDate, endDate, branchcode, last_updated ) 
405
                             VALUES ( NULL, ?, ?, ?, ?, ?, ?, ?, ?, ?, CURRENT_TIMESTAMP)");
406
    $sth->execute( $casaId, $title, $description, $casData1, $casData2, $casData3, $startDate, $endDate, $branchcode ) or $success = 0;
407
  } else {
408
    $sth = $dbh->prepare("INSERT INTO clubsAndServices ( casId, casaId, title, description, casData1, casData2, casData3, startDate, branchcode, last_updated ) 
409
                             VALUES ( NULL, ?, ?, ?, ?, ?, ?, ?, ?, CURRENT_TIMESTAMP)");
410
    $sth->execute( $casaId, $title, $description, $casData1, $casData2, $casData3, $startDate, $branchcode ) or $success = 0;
411
  }
412
  $sth->finish;
413
414
  my ( $errorCode, $errorMessage );
415
  if ( ! $success ) {
416
    $errorMessage = "Database Failure";
417
    $errorCode = 5;
418
  }
419
  
420
  return( $success, $errorCode, $errorMessage );
421
}
422
423
=head UpdateClubOrService
424
425
 Updates club or service in the database
426
427
 Input:
428
   $casId: id of the club or service to be updated
429
   $type: 'club' or 'service', other types may be added as necessary.
430
   $title: Short description of the club or service
431
   $description: Long description of the club or service
432
   $casData1: The data described in case.casData1Title
433
   $casData2: The data described in case.casData2Title
434
   $casData3: The data described in case.casData3Title
435
   $startDate: The date the club or service begins ( Optional: Defaults to TODAY() )
436
   $endDate: The date the club or service ends ( Optional )
437
438
 Output:
439
   $success: 1 on successful add, 0 on failure
440
   $errorCode: Code for reason of failure, good for translating errors in templates
441
   $errorMessage: English description of error
442
443
=cut
444
445
sub UpdateClubOrService {
446
  my ( $casId, $casaId, $title, $description, $casData1, $casData2, $casData3, $startDate, $endDate ) = @_;
447
448
  ## Check for all neccessary parameters
449
  if ( ! $casId ) {
450
    return ( 0, 1, "No casId Given" );
451
  }
452
  if ( ! $casaId ) {
453
    return ( 0, 2, "No Archetype Given" );
454
  } 
455
  if ( ! $title ) {
456
    return ( 0, 3, "No Title Given" );
457
  } 
458
  if ( ! $description ) {
459
    return ( 0, 4, "No Description Given" );
460
  } 
461
  
462
  my $success = 1;
463
464
  if ( ! $startDate ) {
465
    $startDate = getTodayMysqlDateFormat();
466
  }
467
  
468
  my $dbh = C4::Context->dbh;
469
470
  my $sth;
471
  if ( $endDate ) {
472
    $sth = $dbh->prepare("UPDATE clubsAndServices SET casaId = ?, title = ?, description = ?, casData1 = ?, casData2 = ?, casData3 = ?, startDate = ?, endDate = ?, last_updated = NOW() WHERE casId = ?");
473
    $sth->execute( $casaId, $title, $description, $casData1, $casData2, $casData3, $startDate, $endDate, $casId ) or return( my $success = 0, my $errorCode = 5, my $errorMessage = $sth->errstr() );
474
  } else {
475
    $sth = $dbh->prepare("UPDATE clubsAndServices SET casaId = ?, title = ?, description = ?, casData1 = ?, casData2 = ?, casData3 = ?, startDate = ?, endDate = NULL, last_updated = NOW() WHERE casId = ?");
476
    $sth->execute( $casaId, $title, $description, $casData1, $casData2, $casData3, $startDate, $casId ) or return( my $success = 0, my $errorCode = 5, my $errorMessage = $sth->errstr() );
477
  }
478
  $sth->finish;
479
480
  my ( $errorCode, $errorMessage );
481
  if ( ! $success ) {
482
    $errorMessage = "Database Failure";
483
    $errorCode = 5;
484
  }
485
  
486
  return( $success, $errorCode, $errorMessage );
487
}
488
489
=head2 DeleteClubOrService
490
491
 Deletes a club or service of the given id and all enrollments based on it.
492
493
 Input:
494
   $casId : id of the club or service to be deleted
495
496
 Output:
497
   $success : 1 on successful deletion, 0 otherwise
498
499
=cut
500
501
sub DeleteClubOrService {
502
  my ( $casId ) = @_;
503
504
  if ( ! $casId ) {
505
    return 0;
506
  }
507
  
508
  my $success = 1;
509
510
  my $dbh = C4::Context->dbh;
511
512
  my $sth;
513
  $sth = $dbh->prepare("DELETE FROM clubsAndServicesEnrollments WHERE casId = ?");
514
  $sth->execute( $casId ) or $success = 0;
515
  $sth->finish;
516
517
  $sth = $dbh->prepare("DELETE FROM clubsAndServices WHERE casId = ?");
518
  $sth->execute( $casId ) or $success = 0;
519
  $sth->finish;
520
  
521
  return 1;
522
}
523
524
=head EnrollInClubOrService
525
526
 Enrolls a borrower in a given club or service
527
528
 Input:
529
   $casId: The unique id of the club or service being enrolled in
530
   $borrowerCardnumber: The card number of the enrolling borrower
531
   $dateEnrolled: Date the enrollment begins ( Optional: Defauls to TODAY() )
532
   $data1: The data described in ClubsAndServicesArchetypes.caseData1Title
533
   $data2: The data described in ClubsAndServicesArchetypes.caseData2Title
534
   $data3: The data described in ClubsAndServicesArchetypes.caseData3Title
535
   $branchcode: The branch where this club or service enrollment is,
536
   $borrowernumber: ( Optional: Alternative to using $borrowerCardnumber )
537
538
 Output:
539
   $success: 1 on successful enrollment, 0 on failure
540
   $errorCode: Code for reason of failure, good for translating errors in templates
541
   $errorMessage: English description of error
542
543
=cut
544
545
sub EnrollInClubOrService {
546
  my ( $casaId, $casId, $borrowerCardnumber, $dateEnrolled, $data1, $data2, $data3, $branchcode, $borrowernumber ) = @_;
547
548
  ## Check for all neccessary parameters
549
  unless ( $casaId ) {
550
    return ( 0, 1, "No casaId Given" );
551
  }
552
  unless ( $casId ) {
553
    return ( 0, 2, "No casId Given" );
554
  } 
555
  unless ( ( $borrowerCardnumber || $borrowernumber ) ) {
556
    return ( 0, 3, "No Borrower Given" );
557
  } 
558
  
559
  my $member;
560
  if ( $borrowerCardnumber ) {
561
    $member = C4::Members::GetMember( cardnumber => $borrowerCardnumber );
562
  } elsif ( $borrowernumber ) {
563
    $member = C4::Members::GetMember( borrowernumber => $borrowernumber );
564
  } else {
565
    return ( 0, 3, "No Borrower Given" );
566
  }
567
  
568
  unless ( $member ) {
569
    return ( 0, 4, "No Matching Borrower Found" );
570
  }
571
572
  my $casa = GetClubOrServiceArchetype( $casaId, 1 );
573
  if ( $casa->{'caseRequireEmail'} ) {
574
    my $AutoEmailPrimaryAddress = C4::Context->preference('AutoEmailPrimaryAddress');    
575
    unless( $member->{ $AutoEmailPrimaryAddress } ) {
576
      return( 0, 4, "Email Address Required: No Valid Email Address In Borrower Record" );
577
    }
578
  }
579
  
580
  $borrowernumber = $member->{'borrowernumber'};
581
  
582
  if ( isEnrolled( $casId, $borrowernumber ) ) { return ( 0, 5, "Member is already enrolled!" ); }
583
584
  if ( ! $dateEnrolled ) {
585
    $dateEnrolled = getTodayMysqlDateFormat();
586
  }
587
588
  my $dbh = C4::Context->dbh;
589
  my $sth = $dbh->prepare("INSERT INTO clubsAndServicesEnrollments ( caseId, casaId, casId, borrowernumber, data1, data2, data3, dateEnrolled, dateCanceled, last_updated, branchcode)
590
                           VALUES ( NULL, ?, ?, ?, ?, ?, ?, ?, NULL, NOW(), ? )");
591
  $sth->execute( $casaId, $casId, $borrowernumber, $data1, $data2, $data3, $dateEnrolled, $branchcode ) or return( my $success = 0, my $errorCode = 4, my $errorMessage = $sth->errstr() );
592
  $sth->finish;
593
  
594
  return $success = 1;
595
}
596
597
=head2 GetEnrollments
598
599
 Returns information about the clubs and services the given borrower is enrolled in.
600
601
 Input:
602
   $borrowernumber: The borrowernumber of the borrower
603
604
 Output:
605
   $results: Reference to an array of associated arrays
606
607
=cut
608
609
sub GetEnrollments {
610
  my ( $borrowernumber ) = @_;
611
612
  my $dbh = C4::Context->dbh;
613
  
614
  my $sth = $dbh->prepare("SELECT * FROM clubsAndServices, clubsAndServicesEnrollments 
615
                           WHERE clubsAndServices.casId = clubsAndServicesEnrollments.casId
616
                           AND clubsAndServicesEnrollments.borrowernumber = ?");
617
  $sth->execute( $borrowernumber ) or return 0;
618
  
619
  my @results;
620
  while ( my $row = $sth->fetchrow_hashref ) {
621
    push( @results , $row );
622
  }
623
  
624
  $sth->finish;
625
  
626
  return \@results;
627
}
628
629
=head2 GetCasEnrollments
630
631
 Returns information about the clubs and services borrowers that are enrolled
632
633
 Input:
634
   $casId: The id of the club or service to look up enrollments for
635
636
 Output:
637
   $results: Reference to an array of associated arrays
638
   
639
=cut
640
641
sub GetCasEnrollments {
642
  my ( $casId ) = @_;
643
644
  my $dbh = C4::Context->dbh;
645
  
646
  my $sth = $dbh->prepare("SELECT * FROM clubsAndServicesEnrollments, borrowers
647
                           WHERE clubsAndServicesEnrollments.borrowernumber = borrowers.borrowernumber
648
                           AND clubsAndServicesEnrollments.casId = ? AND dateCanceled IS NULL
649
                           ORDER BY surname, firstname");
650
  $sth->execute( $casId ) or return 0;
651
  
652
  my @results;
653
  while ( my $row = $sth->fetchrow_hashref ) {
654
    push( @results , $row );
655
  }
656
  
657
  $sth->finish;
658
  
659
  return \@results;
660
}
661
662
=head2 GetClubsAndServices
663
664
 Returns information about clubs and services
665
666
 Input:
667
   $type: ( Optional: 'club' or 'service' )
668
   $branchcode: ( Optional: Get clubs and services only created by this branch )
669
   $orderby: ( Optional: name of column to sort by )
670
671
 Output:
672
   $results: Reference to an array of associated arrays
673
674
=cut
675
     
676
sub GetClubsAndServices {
677
  my ( $type, $branchcode, $orderby ) = @_;
678
  $orderby = 'startDate DESC' unless ( $orderby );
679
680
  my $dbh = C4::Context->dbh;
681
682
  my ( $sth, @results );
683
  if ( $type && $branchcode ) {
684
    $sth = $dbh->prepare("SELECT clubsAndServices.casId, 
685
                                 clubsAndServices.casaId,
686
                                 clubsAndServices.title, 
687
                                 clubsAndServices.description, 
688
                                 clubsAndServices.casData1,
689
                                 clubsAndServices.casData2,
690
                                 clubsAndServices.casData3,
691
                                 clubsAndServices.startDate, 
692
                                 clubsAndServices.endDate,
693
                                 clubsAndServices.last_updated,
694
                                 clubsAndServices.branchcode
695
                          FROM clubsAndServices, clubsAndServicesArchetypes 
696
                          WHERE 
697
                            clubsAndServices.casaId = clubsAndServicesArchetypes.casaId 
698
                            AND clubsAndServices.branchcode = ?
699
                            AND clubsAndServicesArchetypes.type = ? 
700
                          ORDER BY $orderby
701
    ");
702
    $sth->execute( $branchcode, $type ) or return 0;
703
    
704
  } elsif ( $type ) {
705
    $sth = $dbh->prepare("SELECT clubsAndServices.casId, 
706
                                 clubsAndServices.casaId,
707
                                 clubsAndServices.title, 
708
                                 clubsAndServices.description, 
709
                                 clubsAndServices.casData1,
710
                                 clubsAndServices.casData2,
711
                                 clubsAndServices.casData3,
712
                                 clubsAndServices.startDate, 
713
                                 clubsAndServices.endDate,
714
                                 clubsAndServices.last_updated,
715
                                 clubsAndServices.branchcode
716
                          FROM clubsAndServices, clubsAndServicesArchetypes 
717
                          WHERE
718
                            clubsAndServices.casaId = clubsAndServicesArchetypes.casaId 
719
                            AND clubsAndServicesArchetypes.type = ? 
720
                          ORDER BY $orderby
721
    ");
722
    $sth->execute( $type ) or return 0;
723
    
724
  } elsif ( $branchcode ) {
725
    $sth = $dbh->prepare("SELECT clubsAndServices.casId, 
726
                                 clubsAndServices.casaId,
727
                                 clubsAndServices.title, 
728
                                 clubsAndServices.description, 
729
                                 clubsAndServices.casData1,
730
                                 clubsAndServices.casData2,
731
                                 clubsAndServices.casData3,
732
                                 clubsAndServices.startDate, 
733
                                 clubsAndServices.endDate,
734
                                 clubsAndServices.last_updated,
735
                                 clubsAndServices.branchcode
736
                          FROM clubsAndServices, clubsAndServicesArchetypes 
737
                          WHERE 
738
                            clubsAndServices.casaId = clubsAndServicesArchetypes.casaId 
739
                            AND clubsAndServices.branchcode = ? 
740
                          ORDER BY $orderby
741
    ");
742
    $sth->execute( $branchcode ) or return 0;
743
    
744
  } else { ## Get all clubs and services
745
    $sth = $dbh->prepare("SELECT * FROM clubsAndServices ORDER BY $orderby");
746
    $sth->execute() or return 0;  
747
  }
748
749
  while ( my $row = $sth->fetchrow_hashref ) {
750
    push( @results , $row );
751
  }
752
753
  $sth->finish;
754
  
755
  return \@results;
756
  
757
}
758
759
=head2 GetClubOrService
760
761
 Returns information about a club or service
762
763
 Input:
764
   $casId: Id of club or service to get
765
766
 Output: $casId, $casaId, $title, $description, $casData1, $casData2, $casData3, $startDate, $endDate, $last_updated, $branchcode
767
768
=cut
769
770
sub GetClubOrService {
771
  my ( $casId ) = @_;
772
773
  my $dbh = C4::Context->dbh;
774
775
  my ( $sth, @results );
776
  $sth = $dbh->prepare("SELECT * FROM clubsAndServices WHERE casId = ?");
777
  $sth->execute( $casId ) or return 0;
778
    
779
  my $row = $sth->fetchrow_hashref;
780
  
781
  $sth->finish;
782
  
783
  return (
784
      $$row{'casId'},
785
      $$row{'casaId'},
786
      $$row{'title'},
787
      $$row{'description'},
788
      $$row{'casData1'},
789
      $$row{'casData2'},
790
      $$row{'casData3'},
791
      $$row{'startDate'},
792
      $$row{'endDate'},
793
      $$row{'last_updated'},
794
      $$row{'branchcode'}
795
  );
796
    
797
}
798
799
=head2 GetClubsAndServicesArchetypes
800
801
 Returns information about clubs and services archetypes
802
803
 Input:
804
   $type: 'club' or 'service' ( Optional: Defaults to all types )
805
   $branchcode: Get clubs or services created by this branch ( Optional )
806
807
 Output:
808
   $results: 
809
     Otherwise: Reference to an array of associated arrays
810
     Except: 0 on failure
811
     
812
=cut
813
814
sub GetClubsAndServicesArchetypes {
815
  my ( $type, $branchcode ) = @_;
816
  my $dbh = C4::Context->dbh;
817
  
818
  my $sth;
819
  if ( $type && $branchcode) {
820
    $sth = $dbh->prepare("SELECT * FROM clubsAndServicesArchetypes WHERE type = ? AND branchcode = ?");
821
    $sth->execute( $type, $branchcode ) or return 0;
822
  } elsif ( $type ) {
823
    $sth = $dbh->prepare("SELECT * FROM clubsAndServicesArchetypes WHERE type = ?");
824
    $sth->execute( $type ) or return 0;
825
  } elsif ( $branchcode ) {
826
    $sth = $dbh->prepare("SELECT * FROM clubsAndServicesArchetypes WHERE branchcode = ?");
827
    $sth->execute( $branchcode ) or return 0;
828
  } else {
829
    $sth = $dbh->prepare("SELECT * FROM clubsAndServicesArchetypes");
830
    $sth->execute() or return 0;  
831
  }
832
  
833
  my @results;
834
  while ( my $row = $sth->fetchrow_hashref ) {
835
    push( @results , $row );
836
  }
837
838
  $sth->finish;
839
  
840
  return \@results;
841
}
842
843
=head2 GetClubOrServiceArchetype
844
845
 Returns information about a club or services archetype
846
847
 Input:
848
   $casaId: Id of Archetype to get
849
   $asHashref: Optional, if true, will return hashref instead of array
850
851
 Output:
852
     ( $casaId, $type, $title, $description, $publicEnrollment, 
853
     $casData1Title, $casData2Title, $casData3Title,
854
     $caseData1Title, $caseData2Title, $caseData3Title, 
855
     $casData1Desc, $casData2Desc, $casData3Desc,
856
     $caseData1Desc, $caseData2Desc, $caseData3Desc, 
857
     $caseRequireEmail, $last_updated, $branchcode )
858
     Except: 0 on failure
859
860
=cut
861
862
sub GetClubOrServiceArchetype {
863
  my ( $casaId, $asHashref ) = @_;
864
  
865
  my $dbh = C4::Context->dbh;
866
  
867
  my $sth;
868
  $sth = $dbh->prepare("SELECT * FROM clubsAndServicesArchetypes WHERE casaId = ?");
869
  $sth->execute( $casaId ) or return 0;
870
871
  my $row = $sth->fetchrow_hashref;
872
  
873
  $sth->finish;
874
  
875
  if ( $asHashref ) { return $row; }
876
877
  return (
878
      $$row{'casaId'},
879
      $$row{'type'},
880
      $$row{'title'},
881
      $$row{'description'},
882
      $$row{'publicEnrollment'},
883
      $$row{'casData1Title'},
884
      $$row{'casData2Title'},
885
      $$row{'casData3Title'},
886
      $$row{'caseData1Title'},
887
      $$row{'caseData2Title'},
888
      $$row{'caseData3Title'},
889
      $$row{'casData1Desc'},
890
      $$row{'casData2Desc'},
891
      $$row{'casData3Desc'},
892
      $$row{'caseData1Desc'},
893
      $$row{'caseData2Desc'},
894
      $$row{'caseData3Desc'},
895
      $$row{'caseRequireEmail'},
896
      $$row{'last_updated'},
897
      $$row{'branchcode'}
898
  );
899
}
900
901
=head2  DoesEnrollmentRequireData
902
903
 Returns 1 if the given Archetype has
904
   data fields that need to be filled in
905
   at the time of enrollment.
906
907
 Input:
908
   $casaId: Id of Archetype to get
909
910
 Output:
911
   1: Enrollment will require extra data
912
   0: Enrollment will not require extra data
913
914
=cut
915
916
sub DoesEnrollmentRequireData {
917
  my ( $casaId ) = @_;
918
  
919
  my $dbh = C4::Context->dbh;
920
  
921
  my $sth;
922
  $sth = $dbh->prepare("SELECT caseData1Title FROM clubsAndServicesArchetypes WHERE casaId = ?");
923
  $sth->execute( $casaId ) or return 0;
924
925
  my $row = $sth->fetchrow_hashref;
926
  
927
  $sth->finish;
928
929
  if ( $$row{'caseData1Title'} ) {
930
    return 1;
931
  } else {
932
    return 0;
933
  }
934
}
935
936
937
=head2 CancelClubOrServiceEnrollment
938
939
 Cancels the given enrollment in a club or service
940
941
 Input:
942
   $caseId: The id of the enrollment to be canceled
943
944
 Output:
945
   $success: 1 on successful cancelation, 0 otherwise
946
947
=cut
948
949
sub CancelClubOrServiceEnrollment {
950
  my ( $caseId ) = @_;
951
  
952
  my $success = 1;
953
  
954
  my $dbh = C4::Context->dbh;
955
  
956
  my $sth = $dbh->prepare("UPDATE clubsAndServicesEnrollments SET dateCanceled = CURDATE(), last_updated = NOW() WHERE caseId = ?");
957
  $sth->execute( $caseId ) or $success = 0;
958
  $sth->finish;
959
  
960
  return $success;
961
}
962
963
=head2 GetEnrolledClubsAndServices
964
965
 Returns information about clubs and services
966
 the given borrower is enrolled in.
967
968
 Input:
969
   $borrowernumber
970
971
 Output:
972
   $results: Reference to an array of associated arrays
973
   
974
=cut
975
976
sub GetEnrolledClubsAndServices {
977
  my ( $borrowernumber ) = @_;
978
  my $dbh = C4::Context->dbh;
979
980
  my ( $sth, @results );
981
  $sth = $dbh->prepare("SELECT
982
                          clubsAndServicesEnrollments.caseId,
983
                          clubsAndServices.casId,
984
                          clubsAndServices.casaId,
985
                          clubsAndServices.title,
986
                          clubsAndServices.description,
987
                          clubsAndServices.branchcode,
988
                          clubsAndServicesArchetypes.type,
989
                          clubsAndServicesArchetypes.publicEnrollment
990
                        FROM clubsAndServices, clubsAndServicesArchetypes, clubsAndServicesEnrollments
991
                        WHERE ( 
992
                          clubsAndServices.casaId = clubsAndServicesArchetypes.casaId 
993
                          AND clubsAndServices.casId = clubsAndServicesEnrollments.casId
994
                          AND ( clubsAndServices.endDate >= CURRENT_DATE() OR clubsAndServices.endDate IS NULL )
995
                          AND clubsAndServicesEnrollments.dateCanceled IS NULL
996
                          AND clubsAndServicesEnrollments.borrowernumber = ?
997
                        )
998
                        ORDER BY type, title
999
                       ");
1000
  $sth->execute( $borrowernumber ) or return 0;
1001
    
1002
  while ( my $row = $sth->fetchrow_hashref ) {
1003
    push( @results , $row );
1004
  }
1005
1006
  $sth->finish;
1007
  
1008
  return \@results;
1009
  
1010
}
1011
1012
=head2 GetPubliclyEnrollableClubsAndServices
1013
1014
 Returns information about clubs and services
1015
 the given borrower can enroll in.
1016
1017
 Input:
1018
   $borrowernumber
1019
1020
 Output:
1021
   $results: Reference to an array of associated arrays
1022
1023
=cut
1024
1025
sub GetPubliclyEnrollableClubsAndServices {
1026
  my ( $borrowernumber ) = @_;
1027
1028
  my $dbh = C4::Context->dbh;
1029
1030
  my ( $sth, @results );
1031
  $sth = $dbh->prepare("
1032
SELECT 
1033
DISTINCT ( clubsAndServices.casId ), 
1034
         clubsAndServices.title,
1035
         clubsAndServices.description,
1036
         clubsAndServices.branchcode,
1037
         clubsAndServicesArchetypes.type,
1038
         clubsAndServices.casaId
1039
FROM clubsAndServices, clubsAndServicesArchetypes
1040
WHERE clubsAndServicesArchetypes.casaId = clubsAndServices.casaId
1041
AND clubsAndServicesArchetypes.publicEnrollment =1
1042
AND clubsAndServices.casId NOT
1043
IN (
1044
  SELECT clubsAndServices.casId
1045
  FROM clubsAndServices, clubsAndServicesEnrollments
1046
  WHERE clubsAndServicesEnrollments.casId = clubsAndServices.casId
1047
  AND clubsAndServicesEnrollments.dateCanceled IS NULL
1048
  AND clubsAndServicesEnrollments.borrowernumber = ?
1049
)
1050
 ORDER BY type, title");
1051
  $sth->execute( $borrowernumber ) or return 0;
1052
    
1053
  while ( my $row = $sth->fetchrow_hashref ) {
1054
    push( @results , $row );
1055
  }
1056
1057
  $sth->finish;
1058
  
1059
  return \@results;
1060
  
1061
}
1062
1063
=head2 GetAllEnrollableClubsAndServices
1064
1065
 Returns information about clubs and services
1066
 the given borrower can enroll in.
1067
1068
 Input:
1069
   $borrowernumber
1070
1071
 Output:
1072
   $results: Reference to an array of associated arrays
1073
1074
=cut
1075
1076
sub GetAllEnrollableClubsAndServices {
1077
  my ( $borrowernumber, $branchcode ) = @_;
1078
  
1079
  if ( $branchcode eq '' ) {
1080
    $branchcode = '%';
1081
  }
1082
1083
  my $dbh = C4::Context->dbh;
1084
1085
  my ( $sth, @results );
1086
  $sth = $dbh->prepare("
1087
SELECT 
1088
DISTINCT ( clubsAndServices.casId ), 
1089
         clubsAndServices.title,
1090
         clubsAndServices.description,
1091
         clubsAndServices.branchcode,
1092
         clubsAndServicesArchetypes.type,
1093
         clubsAndServices.casaId
1094
FROM clubsAndServices, clubsAndServicesArchetypes
1095
WHERE clubsAndServicesArchetypes.casaId = clubsAndServices.casaId
1096
AND ( 
1097
  DATE(clubsAndServices.endDate) >= CURDATE()
1098
  OR
1099
  clubsAndServices.endDate IS NULL
1100
)
1101
AND clubsAndServices.branchcode LIKE ?
1102
AND clubsAndServices.casId NOT
1103
IN (
1104
  SELECT clubsAndServices.casId
1105
  FROM clubsAndServices, clubsAndServicesEnrollments
1106
  WHERE clubsAndServicesEnrollments.casId = clubsAndServices.casId
1107
  AND clubsAndServicesEnrollments.dateCanceled IS NULL
1108
  AND clubsAndServicesEnrollments.borrowernumber = ?
1109
)
1110
 ORDER BY type, title");
1111
  $sth->execute( $branchcode, $borrowernumber ) or return 0;
1112
    
1113
  while ( my $row = $sth->fetchrow_hashref ) {
1114
    push( @results , $row );
1115
  }
1116
1117
  $sth->finish;
1118
  
1119
  return \@results;
1120
  
1121
}
1122
1123
1124
sub getBorrowernumberByCardnumber {
1125
  my $dbh = C4::Context->dbh;
1126
  
1127
  my $sth = $dbh->prepare("SELECT borrowernumber FROM borrowers WHERE cardnumber = ?");
1128
  $sth->execute( @_ ) or return( 0 );
1129
1130
  my $row = $sth->fetchrow_hashref;
1131
    
1132
  my $borrowernumber = $$row{'borrowernumber'};
1133
  $sth->finish;
1134
1135
  return( $borrowernumber );  
1136
}
1137
1138
sub isEnrolled {
1139
  my ( $casId, $borrowernumber ) = @_;
1140
  
1141
  my $dbh = C4::Context->dbh;
1142
  
1143
  my $sth = $dbh->prepare("SELECT COUNT(*) as isEnrolled FROM clubsAndServicesEnrollments WHERE casId = ? AND borrowernumber = ? AND dateCanceled IS NULL");
1144
  $sth->execute( $casId, $borrowernumber ) or return( 0 );
1145
1146
  my $row = $sth->fetchrow_hashref;
1147
    
1148
  my $isEnrolled = $$row{'isEnrolled'};
1149
  $sth->finish;
1150
1151
  return( $isEnrolled );  
1152
}
1153
1154
sub getTodayMysqlDateFormat {
1155
  my ($day,$month,$year) = (localtime)[3,4,5];
1156
  my $today = sprintf("%04d-%02d-%02d", $year + 1900, $month + 1, $day);
1157
  return $today;
1158
}
1159
1160
sub ReserveForBestSellersClub {
1161
  my ( $biblionumber ) = @_;
1162
1163
  unless( $biblionumber ) { return; }
1164
  
1165
  my $dbh = C4::Context->dbh;
1166
  my $sth;
1167
1168
  ## Grab the bib for this biblionumber, we will need the author and title to find the relevent clubs
1169
  my $biblio_data = C4::Biblio::GetBiblioData( $biblionumber );
1170
  my $author = $biblio_data->{'author'};
1171
  my $title = $biblio_data->{'title'};
1172
  my $itemtype = $biblio_data->{'itemtype'};
1173
  
1174
  ## Find the casaId for the Bestsellers Club archetype
1175
  $sth = $dbh->prepare("SELECT * FROM clubsAndServicesArchetypes WHERE title LIKE 'Bestsellers Club' ");
1176
  $sth->execute();
1177
  my $casa = $sth->fetchrow_hashref();
1178
  my $casaId = $casa->{'casaId'};
1179
  $sth->finish();
1180
1181
  unless( $casaId ) { return; }
1182
    
1183
  ## Find all the relevent bestsellers clubs
1184
  ## casData1 is title, casData2 is author
1185
  $sth = $dbh->prepare("SELECT * FROM clubsAndServices WHERE casaId = ?");
1186
  $sth->execute( $casaId );
1187
  my @clubs;
1188
  while ( my $club = $sth->fetchrow_hashref() ) {
1189
    #warn "Author/casData2 : '$author'/ " . $club->{'casData2'} . "'";
1190
    #warn "Title/casData1 : '$title'/" . $club->{'casData1'} . "'";
1191
1192
    ## If the author, title or both match, keep it.
1193
    if ( ($club->{'casData1'} eq $title) || ($club->{'casData2'} eq $author) ) {
1194
      push( @clubs, $club );
1195
      #warn "casId" . $club->{'casId'};
1196
    } elsif ( $club->{'casData1'} =~ m/%/ ) { # Title is using % as a wildcard
1197
      my @substrings = split(/%/, $club->{'casData1'} );
1198
      my $all_match = 1;
1199
      foreach my $sub ( @substrings ) {
1200
        unless( $title =~ m/\Q$sub/) {
1201
          $all_match = 0;
1202
        }
1203
      }
1204
      if ( $all_match ) { push( @clubs, $club ); }
1205
    } elsif ( $club->{'casData2'} =~ m/%/ ) { # Author is using % as a wildcard
1206
      my @substrings = split(/%/, $club->{'casData2'} );
1207
      my $all_match = 1;
1208
      foreach my $sub ( @substrings ) {
1209
        unless( $author =~ m/\Q$sub/) {
1210
          $all_match = 0;
1211
        }
1212
      }
1213
      
1214
      ## Make sure the bib is in the list of itemtypes to use
1215
      my @itemtypes = split( / /, $club->{'casData3'} );
1216
      my $found_itemtype_match = 0;
1217
      if ( @itemtypes ) { ## If no itemtypes are listed, all itemtypes are valid, skip test.
1218
        foreach my $it ( @itemtypes ) {
1219
          if ( $it eq $itemtype ) {
1220
            $found_itemtype_match = 1;
1221
            last; ## Short circuit for speed.
1222
          }
1223
        }
1224
        $all_match = 0 unless ( $found_itemtype_match ); 
1225
      }
1226
      
1227
      if ( $all_match ) { push( @clubs, $club ); }
1228
    }
1229
  }
1230
  $sth->finish();
1231
  
1232
  unless( scalar( @clubs ) ) { return; }
1233
  
1234
  ## Get all the members of the relevant clubs, but only get each borrower once, even if they are in multiple relevant clubs
1235
  ## Randomize the order of the borrowers
1236
  my @casIds;
1237
  my $sql = "SELECT DISTINCT(borrowers.borrowernumber) FROM borrowers, clubsAndServicesEnrollments
1238
             WHERE clubsAndServicesEnrollments.borrowernumber = borrowers.borrowernumber
1239
             AND (";
1240
  my $clubsCount = scalar( @clubs );
1241
  foreach my $club ( @clubs ) {
1242
    $sql .= " casId = ?";
1243
    if ( --$clubsCount ) {
1244
      $sql .= " OR";
1245
    }
1246
    push( @casIds, $club->{'casId'} );
1247
  }
1248
  $sql .= " ) ORDER BY RAND()";
1249
  
1250
  
1251
  $sth = $dbh->prepare( $sql );
1252
  $sth->execute( @casIds );
1253
  my @borrowers;
1254
  while ( my $borrower = $sth->fetchrow_hashref() ) {
1255
    push( @borrowers, $borrower );
1256
  }
1257
  
1258
  unless( scalar( @borrowers ) ) { return; }
1259
  
1260
  my $priority = 1;
1261
  foreach my $borrower ( @borrowers ) {
1262
    C4::Reserves::AddReserve(
1263
      my $branch = $borrower->{'branchcode'},
1264
      my $borrowernumber = $borrower->{'borrowernumber'},
1265
      $biblionumber,
1266
      my $constraint = 'a',
1267
      my $bibitems,
1268
      $priority,
1269
      my $notes = "Automatic Reserve for Bestsellers Club",
1270
      $title,
1271
      my $checkitem,
1272
      my $found,
1273
      my $expire_date
1274
    );
1275
    $priority++;
1276
  }
1277
}
1278
1279
1;
1280
1281
__END__
1282
1283
=back
1284
1285
=head1 AUTHOR
1286
1287
Kyle M Hall <kylemhall@gmail.com>
1288
1289
=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 (+37 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 => 0,
16
#        flagsrequired   => { clubs_services => 'create_clubs_service' },
17
    }
18
);
19
20
my $branchcode = C4::Context->userenv->{branch};
21
22
my $clubs    = GetClubsAndServices( 'club',    $branchcode );
23
my $services = GetClubsAndServices( 'service', $branchcode );
24
25
$template->param(
26
    intranetcolorstylesheet =>
27
      C4::Context->preference("intranetcolorstylesheet"),
28
    intranetstylesheet => C4::Context->preference("intranetstylesheet"),
29
    IntranetNav        => C4::Context->preference("IntranetNav"),
30
31
    clubs_services => 1,
32
33
    clubsLoop    => $clubs,
34
    servicesLoop => $services,
35
);
36
37
output_html_with_http_headers $query, $cookie, $template->output;
(-)a/clubs_services/clubs_services_enrollments.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_enrollments.tmpl",
13
        query           => $query,
14
        type            => "intranet",
15
        authnotrequired => 0,
16
        flagsrequired   => { clubs_services => 'enroll_borrower' },
17
    }
18
);
19
20
my $casId = $query->param('casId');
21
my (
22
    $casId,    $casaId,       $title,    $description,
23
    $casData1, $casData2,     $casData3, $startDate,
24
    $endDate,  $last_updated, $branchcode
25
) = GetClubOrService($casId);
26
$template->param( casTitle => $title );
27
28
my $enrollments = GetCasEnrollments($casId);
29
$template->param( enrollments_loop => $enrollments );
30
31
$template->param(
32
    intranetcolorstylesheet =>
33
      C4::Context->preference("intranetcolorstylesheet"),
34
    intranetstylesheet => C4::Context->preference("intranetstylesheet"),
35
    IntranetNav        => C4::Context->preference("IntranetNav"),
36
);
37
38
output_html_with_http_headers $query, $cookie, $template->output;
(-)a/clubs_services/edit_archetypes.pl (+193 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   => { clubs_services => 'create_archetype' },
17
    }
18
);
19
20
my $branchcode = C4::Context->userenv->{branch};
21
22
## Create new Archetype
23
if ( $query->param('action') eq 'create' ) {
24
    my $type             = $query->param('type');
25
    my $title            = $query->param('title');
26
    my $description      = $query->param('description');
27
    my $publicEnrollment =  ( $query->param('publicEnrollment') eq 'yes' ) ? 1 : 0;
28
29
    my $casData1Title = $query->param('casData1Title');
30
    my $casData2Title = $query->param('casData2Title');
31
    my $casData3Title = $query->param('casData3Title');
32
33
    my $caseData1Title = $query->param('caseData1Title');
34
    my $caseData2Title = $query->param('caseData2Title');
35
    my $caseData3Title = $query->param('caseData3Title');
36
37
    my $casData1Desc = $query->param('casData1Desc');
38
    my $casData2Desc = $query->param('casData2Desc');
39
    my $casData3Desc = $query->param('casData3Desc');
40
41
    my $caseData1Desc = $query->param('caseData1Desc');
42
    my $caseData2Desc = $query->param('caseData2Desc');
43
    my $caseData3Desc = $query->param('caseData3Desc');
44
45
    my $caseRequireEmail = $query->param('caseRequireEmail') ? '1' : '0';
46
47
    my ( $createdSuccessfully, $errorCode, $errorMessage ) =
48
      AddClubOrServiceArchetype(
49
        $type,             $title,            $description,
50
        $publicEnrollment, $casData1Title,    $casData2Title,
51
        $casData3Title,    $caseData1Title,   $caseData2Title,
52
        $caseData3Title,   $casData1Desc,     $casData2Desc,
53
        $casData3Desc,     $caseData1Desc,    $caseData2Desc,
54
        $caseData3Desc,    $caseRequireEmail, $branchcode
55
      );
56
57
    $template->param(
58
        previousActionCreate => 1,
59
        createdTitle         => $title,
60
    );
61
62
    if ($createdSuccessfully) {
63
        $template->param( createSuccess => 1 );
64
    }
65
    else {
66
        $template->param( createFailure  => 1 );
67
        $template->param( failureMessage => $errorMessage );
68
    }
69
70
}
71
72
## Delete an Archtype
73
elsif ( $query->param('action') eq 'delete' ) {
74
    my $casaId  = $query->param('casaId');
75
    my $success = DeleteClubOrServiceArchetype($casaId);
76
77
    $template->param( previousActionDelete => 1 );
78
    if ($success) {
79
        $template->param( deleteSuccess => 1 );
80
    }
81
    else {
82
        $template->param( deleteFailure => 1 );
83
    }
84
}
85
86
## Edit a club or service: grab data, put in form.
87
elsif ( $query->param('action') eq 'edit' ) {
88
    my $casaId = $query->param('casaId');
89
    my (
90
        $casaId,         $type,             $title,
91
        $description,    $publicEnrollment, $casData1Title,
92
        $casData2Title,  $casData3Title,    $caseData1Title,
93
        $caseData2Title, $caseData3Title,   $casData1Desc,
94
        $casData2Desc,   $casData3Desc,     $caseData1Desc,
95
        $caseData2Desc,  $caseData3Desc,    $caseRequireEmail,
96
        $casaTimestamp,  $casaBranchcode
97
    ) = GetClubOrServiceArchetype($casaId);
98
99
    $template->param(
100
        previousActionEdit   => 1,
101
        editCasaId           => $casaId,
102
        editType             => $type,
103
        editTitle            => $title,
104
        editDescription      => $description,
105
        editCasData1Title    => $casData1Title,
106
        editCasData2Title    => $casData2Title,
107
        editCasData3Title    => $casData3Title,
108
        editCaseData1Title   => $caseData1Title,
109
        editCaseData2Title   => $caseData2Title,
110
        editCaseData3Title   => $caseData3Title,
111
        editCasData1Desc     => $casData1Desc,
112
        editCasData2Desc     => $casData2Desc,
113
        editCasData3Desc     => $casData3Desc,
114
        editCaseData1Desc    => $caseData1Desc,
115
        editCaseData2Desc    => $caseData2Desc,
116
        editCaseData3Desc    => $caseData3Desc,
117
        editCaseRequireEmail => $caseRequireEmail,
118
        editCasaTimestamp    => $casaTimestamp,
119
        editCasaBranchcode   => $casaBranchcode
120
    );
121
122
    if ($publicEnrollment) {
123
        $template->param( editPublicEnrollment => 1 );
124
    }
125
}
126
127
# Update an Archetype
128
elsif ( $query->param('action') eq 'update' ) {
129
    my $casaId           = $query->param('casaId');
130
    my $type             = $query->param('type');
131
    my $title            = $query->param('title');
132
    my $description      = $query->param('description');
133
    my $publicEnrollment =  ( $query->param('publicEnrollment') eq 'yes' ) ? 1 : 0;
134
    
135
    my $casData1Title = $query->param('casData1Title');
136
    my $casData2Title = $query->param('casData2Title');
137
    my $casData3Title = $query->param('casData3Title');
138
139
    my $caseData1Title = $query->param('caseData1Title');
140
    my $caseData2Title = $query->param('caseData2Title');
141
    my $caseData3Title = $query->param('caseData3Title');
142
143
    my $casData1Desc = $query->param('casData1Desc');
144
    my $casData2Desc = $query->param('casData2Desc');
145
    my $casData3Desc = $query->param('casData3Desc');
146
147
    my $caseData1Desc = $query->param('caseData1Desc');
148
    my $caseData2Desc = $query->param('caseData2Desc');
149
    my $caseData3Desc = $query->param('caseData3Desc');
150
151
    my $caseRequireEmail = $query->param('caseRequireEmail');
152
153
    my ( $createdSuccessfully, $errorCode, $errorMessage ) =
154
      UpdateClubOrServiceArchetype(
155
        $casaId,         $type,             $title,
156
        $description,    $publicEnrollment, $casData1Title,
157
        $casData2Title,  $casData3Title,    $caseData1Title,
158
        $caseData2Title, $caseData3Title,   $casData1Desc,
159
        $casData2Desc,   $casData3Desc,     $caseData1Desc,
160
        $caseData2Desc,  $caseData3Desc,    $caseRequireEmail
161
      );
162
163
    $template->param(
164
        previousActionUpdate => 1,
165
        updatedTitle         => $title,
166
    );
167
168
    if ($createdSuccessfully) {
169
        $template->param( updateSuccess => 1 );
170
    }
171
    else {
172
        $template->param( updateFailure  => 1 );
173
        $template->param( failureMessage => $errorMessage );
174
    }
175
176
}
177
178
my $clubArchetypes    = GetClubsAndServicesArchetypes('club');
179
my $serviceArchetypes = GetClubsAndServicesArchetypes('service');
180
181
$template->param(
182
    intranetcolorstylesheet =>
183
      C4::Context->preference("intranetcolorstylesheet"),
184
    intranetstylesheet => C4::Context->preference("intranetstylesheet"),
185
    IntranetNav        => C4::Context->preference("IntranetNav"),
186
187
    edit_archetypes => 1,
188
189
    clubArchetypesLoop    => $clubArchetypes,
190
    serviceArchetypesLoop => $serviceArchetypes,
191
);
192
193
output_html_with_http_headers $query, $cookie, $template->output;
(-)a/clubs_services/edit_clubs_services.pl (+199 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 => 0,
16
        flagsrequired   => { clubs_services => 'create_club_service' },
17
    }
18
);
19
20
my $branchcode = C4::Context->userenv->{branch};
21
22
# Archetype selected for Club or Service creation
23
if ( $query->param('action') eq 'selectArchetype' ) {
24
    my $casaId = $query->param('casaId');
25
26
    my (
27
        $casaId,          $casaType,             $casaTitle,
28
        $casaDescription, $casaPublicEnrollment, $casData1Title,
29
        $casData2Title,   $casData3Title,        $caseData1Title,
30
        $caseData2Title,  $caseData3Title,       $casData1Desc,
31
        $casData2Desc,    $casData3Desc,         $caseData1Desc,
32
        $caseData2Desc,   $caseData3Desc,        $casaTimestamp
33
    ) = GetClubOrServiceArchetype($casaId);
34
35
    $template->param(
36
        previousActionSelectArchetype => 1,
37
38
        casaId               => $casaId,
39
        casaType             => $casaType,
40
        casaTitle            => $casaTitle,
41
        casaDescription      => $casaDescription,
42
        casaPublicEnrollment => $casaPublicEnrollment,
43
        casData1Title        => $casData1Title,
44
        casData2Title        => $casData2Title,
45
        casData3Title        => $casData3Title,
46
        caseData1Title       => $caseData1Title,
47
        caseData2Title       => $caseData2Title,
48
        caseData3Title       => $caseData3Title,
49
        casData1Desc         => $casData1Desc,
50
        casData2Desc         => $casData2Desc,
51
        casData3Desc         => $casData3Desc,
52
        caseData1Desc        => $caseData1Desc,
53
        caseData2Desc        => $caseData2Desc,
54
        caseData3Desc        => $caseData3Desc,
55
        caseTimestamp        => $casaTimestamp
56
    );
57
}
58
59
# Create new Club or Service
60
elsif ( $query->param('action') eq 'create' ) {
61
    my $casaId      = $query->param('casaId');
62
    my $title       = $query->param('title');
63
    my $description = $query->param('description');
64
    my $casData1    = $query->param('casData1');
65
    my $casData2    = $query->param('casData2');
66
    my $casData3    = $query->param('casData3');
67
    my $startDate   = $query->param('startDate');
68
    my $endDate     = $query->param('endDate');
69
70
    my ( $createdSuccessfully, $errorCode, $errorMessage ) = AddClubOrService(
71
        $casaId,   $title,     $description, $casData1, $casData2,
72
        $casData3, $startDate, $endDate,     $branchcode
73
    );
74
75
    $template->param(
76
        previousActionCreate => 1,
77
        createdTitle         => $title,
78
    );
79
80
    if ($createdSuccessfully) {
81
        $template->param( createSuccess => 1 );
82
    }
83
    else {
84
        $template->param( createFailure  => 1 );
85
        $template->param( failureMessage => $errorMessage );
86
    }
87
}
88
89
## Delete a club or service
90
elsif ( $query->param('action') eq 'delete' ) {
91
    my $casId   = $query->param('casId');
92
    my $success = DeleteClubOrService($casId);
93
94
    $template->param( previousActionDelete => 1 );
95
    if ($success) {
96
        $template->param( deleteSuccess => 1 );
97
    }
98
    else {
99
        $template->param( deleteFailure => 1 );
100
    }
101
}
102
103
## Edit a club or service: grab data, put in form.
104
elsif ( $query->param('action') eq 'edit' ) {
105
    my $casId = $query->param('casId');
106
    my (
107
        $casId,    $casaId,   $title,     $description, $casData1,
108
        $casData2, $casData3, $startDate, $endDate,     $timestamp
109
    ) = GetClubOrService($casId);
110
111
    my (
112
        $casaId,          $casaType,             $casaTitle,
113
        $casaDescription, $casaPublicEnrollment, $casData1Title,
114
        $casData2Title,   $casData3Title,        $caseData1Title,
115
        $caseData2Title,  $caseData3Title,       $casData1Desc,
116
        $casData2Desc,    $casData3Desc,         $caseData1Desc,
117
        $caseData2Desc,   $caseData3Desc,        $casaTimestamp
118
    ) = GetClubOrServiceArchetype($casaId);
119
120
    $template->param(
121
        previousActionSelectArchetype => 1,
122
        previousActionEdit            => 1,
123
        editCasId                     => $casId,
124
        editCasaId                    => $casaId,
125
        editTitle                     => $title,
126
        editDescription               => $description,
127
        editCasData1                  => $casData1,
128
        editCasData2                  => $casData2,
129
        editCasData3                  => $casData3,
130
        editStartDate                 => $startDate,
131
        editEndDate                   => $endDate,
132
        editTimestamp                 => $timestamp,
133
134
        casaId        => $casaId,
135
        casaTitle     => $casaTitle,
136
        casData1Title => $casData1Title,
137
        casData2Title => $casData2Title,
138
        casData3Title => $casData3Title,
139
        casData1Desc  => $casData1Desc,
140
        casData2Desc  => $casData2Desc,
141
        casData3Desc  => $casData3Desc
142
    );
143
}
144
145
# Update a Club or Service
146
if ( $query->param('action') eq 'update' ) {
147
    my $casId       = $query->param('casId');
148
    my $casaId      = $query->param('casaId');
149
    my $title       = $query->param('title');
150
    my $description = $query->param('description');
151
    my $casData1    = $query->param('casData1');
152
    my $casData2    = $query->param('casData2');
153
    my $casData3    = $query->param('casData3');
154
    my $startDate   = $query->param('startDate');
155
    my $endDate     = $query->param('endDate');
156
157
    my ( $createdSuccessfully, $errorCode, $errorMessage ) =
158
      UpdateClubOrService(
159
        $casId,    $casaId,   $title,     $description, $casData1,
160
        $casData2, $casData3, $startDate, $endDate
161
      );
162
163
    $template->param(
164
        previousActionUpdate => 1,
165
        updatedTitle         => $title,
166
    );
167
168
    if ($createdSuccessfully) {
169
        $template->param( updateSuccess => 1 );
170
    }
171
    else {
172
        $template->param( updateFailure  => 1 );
173
        $template->param( failureMessage => $errorMessage );
174
    }
175
}
176
177
my $clubs    = GetClubsAndServices( 'club',    $query->cookie('branch') );
178
my $services = GetClubsAndServices( 'service', $query->cookie('branch') );
179
my $archetypes = GetClubsAndServicesArchetypes();
180
181
if ($archetypes)
182
{    ## Disable 'Create New Club or Service' if there are no archetypes defined.
183
    $template->param( archetypes => 1 );
184
}
185
186
$template->param(
187
    intranetcolorstylesheet =>
188
      C4::Context->preference("intranetcolorstylesheet"),
189
    intranetstylesheet => C4::Context->preference("intranetstylesheet"),
190
    IntranetNav        => C4::Context->preference("IntranetNav"),
191
192
    edit_clubs_services => 1,
193
194
    clubsLoop      => $clubs,
195
    servicesLoop   => $services,
196
    archetypesLoop => $archetypes,
197
);
198
199
output_html_with_http_headers $query, $cookie, $template->output;
(-)a/clubs_services/enroll_clubs_services.pl (+103 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 => 0,
16
        flagsrequired   => { clubs_services => 'enroll_borrower' },
17
    }
18
);
19
20
my $branchcode = $query->cookie('branch');
21
22
if ( $query->param('action') eq 'enroll' ) {
23
    my $borrowerBarcode = $query->param('borrowerBarcode');
24
    my $casId           = $query->param('casId');
25
    my $casaId          = $query->param('casaId');
26
    my $data1           = $query->param('data1');
27
    my $data2           = $query->param('data2');
28
    my $data3           = $query->param('data3');
29
30
    my $dateEnrolled;    # Will default to Today
31
32
    my ( $success, $errorCode, $errorMessage ) =
33
      EnrollInClubOrService( $casaId, $casId, $borrowerBarcode, $dateEnrolled,
34
        $data1, $data2, $data3, $branchcode );
35
36
    $template->param(
37
        previousActionEnroll => 1,
38
        enrolledBarcode      => $borrowerBarcode,
39
    );
40
41
    if ($success) {
42
        $template->param( enrollSuccess => 1 );
43
    }
44
    else {
45
        $template->param( enrollFailure  => 1 );
46
        $template->param( failureMessage => $errorMessage );
47
    }
48
49
}
50
51
my ( $casId, $casaId, $casTitle, $casDescription, $casStartDate, $casEndDate,
52
    $casTimestamp )
53
  = GetClubOrService( $query->param('casId') );
54
my (
55
    $casaId,          $casaType,             $casaTitle,
56
    $casaDescription, $casaPublicEnrollment, $casData1Title,
57
    $casData2Title,   $casData3Title,        $caseData1Title,
58
    $caseData2Title,  $caseData3Title,       $casData1Desc,
59
    $casData2Desc,    $casData3Desc,         $caseData1Desc,
60
    $caseData2Desc,   $caseData3Desc,        $timestamp
61
) = GetClubOrServiceArchetype($casaId);
62
63
$template->param(
64
    intranetcolorstylesheet =>
65
      C4::Context->preference("intranetcolorstylesheet"),
66
    intranetstylesheet => C4::Context->preference("intranetstylesheet"),
67
    IntranetNav        => C4::Context->preference("IntranetNav"),
68
69
    casId          => $casId,
70
    casTitle       => $casTitle,
71
    casDescription => $casDescription,
72
    casStartDate   => $casStartDate,
73
    casEndDate     => $casEndDate,
74
    casTimeStamp   => $casTimestamp,
75
76
    casaId               => $casaId,
77
    casaType             => $casaType,
78
    casaTitle            => $casaTitle,
79
    casaDescription      => $casaDescription,
80
    casaPublicEnrollment => $casaPublicEnrollment,
81
);
82
83
if ($caseData1Title) {
84
    $template->param( caseData1Title => $caseData1Title );
85
}
86
if ($caseData2Title) {
87
    $template->param( caseData2Title => $caseData2Title );
88
}
89
if ($caseData3Title) {
90
    $template->param( caseData3Title => $caseData3Title );
91
}
92
93
if ($caseData1Desc) {
94
    $template->param( caseData1Desc => $caseData1Desc );
95
}
96
if ($caseData2Desc) {
97
    $template->param( caseData2Desc => $caseData2Desc );
98
}
99
if ($caseData3Desc) {
100
    $template->param( caseData3Desc => $caseData3Desc );
101
}
102
103
output_html_with_http_headers $query, $cookie, $template->output;
(-)a/installer/data/mysql/en/mandatory/userflags.sql (+1 lines)
Lines 15-17 INSERT INTO `userflags` VALUES(14,'editauthorities','Allow to edit authorities', Link Here
15
INSERT INTO `userflags` VALUES(15,'serials','Allow to manage serials subscriptions',0);
15
INSERT INTO `userflags` VALUES(15,'serials','Allow to manage serials subscriptions',0);
16
INSERT INTO `userflags` VALUES(16,'reports','Allow to access to the reports module',0);
16
INSERT INTO `userflags` VALUES(16,'reports','Allow to access to the reports module',0);
17
INSERT INTO `userflags` VALUES(17,'staffaccess','Modify login / permissions for staff users',0);
17
INSERT INTO `userflags` VALUES(17,'staffaccess','Modify login / permissions for staff users',0);
18
INSERT INTO `userflags` VALUES(18,'clubs_services','Access to the clubs & services module',0);
(-)a/installer/data/mysql/en/mandatory/userpermissions.sql (-1 / +4 lines)
Lines 46-50 INSERT INTO permissions (module_bit, code, description) VALUES Link Here
46
   (15, 'renew_subscription', 'Renew a subscription'),
46
   (15, 'renew_subscription', 'Renew a subscription'),
47
   (15, 'routing', 'Routing'),
47
   (15, 'routing', 'Routing'),
48
   (16, 'execute_reports', 'Execute SQL reports'),
48
   (16, 'execute_reports', 'Execute SQL reports'),
49
   (16, 'create_reports', 'Create SQL Reports')
49
   (16, 'create_reports', 'Create SQL Reports'),
50
   (18, 'create_club_service', 'Create and edit clubs and services from existing archetypes.'),
51
   (18, 'create_archetype', 'Create and edit archetype.'),
52
   (18, 'enroll_borrower', 'Enroll borrower in a club or service.')
50
;
53
;
(-)a/installer/data/mysql/kohastructure.sql (+79 lines)
Lines 2705-2710 CREATE TABLE `bibliocoverimage` ( Link Here
2705
 CONSTRAINT `bibliocoverimage_fk1` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE
2705
 CONSTRAINT `bibliocoverimage_fk1` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE
2706
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2706
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2707
2707
2708
--
2709
-- Table structure for table `clubsAndServices`
2710
-- 
2711
2712
DROP TABLE IF EXISTS `clubsAndServices`;
2713
CREATE TABLE `clubsAndServices` (
2714
  `casId` int(11) NOT NULL auto_increment,
2715
  `casaId` int(11) NOT NULL default '0' COMMENT 'foreign key to clubsAndServicesArchetypes',
2716
  `title` text NOT NULL,
2717
  `description` text,
2718
  `casData1` text COMMENT 'Data described in casa.casData1Title',
2719
  `casData2` text COMMENT 'Data described in casa.casData2Title',
2720
  `casData3` text COMMENT 'Data described in casa.casData3Title',
2721
  `startDate` date NOT NULL default '0000-00-00',
2722
  `endDate` date default NULL,
2723
  `branchcode` varchar(4) NOT NULL COMMENT 'branch where club or service was created.',
2724
  `last_updated` timestamp NOT NULL default CURRENT_TIMESTAMP,
2725
  PRIMARY KEY  (`casId`)
2726
) ENGINE=MyISAM  DEFAULT CHARSET=utf8;
2727
2728
-- 
2729
-- Table structure for table `clubsAndServicesArchetypes`
2730
-- 
2731
2732
DROP TABLE IF EXISTS `clubsAndServicesArchetypes`;
2733
CREATE TABLE `clubsAndServicesArchetypes` (
2734
  `casaId` int(11) NOT NULL auto_increment,
2735
  `type` enum('club','service') NOT NULL default 'club',
2736
  `title` text NOT NULL COMMENT 'title of this archetype',
2737
  `description` text NOT NULL COMMENT 'long description of this archetype',
2738
  `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.',
2739
  `casData1Title` text COMMENT 'Title of contents in cas.data1',
2740
  `casData2Title` text COMMENT 'Title of contents in cas.data2',
2741
  `casData3Title` text COMMENT 'Title of contents in cas.data3',
2742
  `caseData1Title` text COMMENT 'Name of what is stored in cAsE.data1',
2743
  `caseData2Title` text COMMENT 'Name of what is stored in cAsE.data2',
2744
  `caseData3Title` text COMMENT 'Name of what is stored in cAsE.data3',
2745
  `casData1Desc` text,
2746
  `casData2Desc` text,
2747
  `casData3Desc` text,
2748
  `caseData1Desc` text,
2749
  `caseData2Desc` text,
2750
  `caseData3Desc` text,
2751
  `caseRequireEmail` tinyint(1) NOT NULL default '0',
2752
  `branchcode` varchar(4) default NULL COMMENT 'branch where archetype was created.',
2753
  `last_updated` timestamp NOT NULL default CURRENT_TIMESTAMP,
2754
  `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.',
2755
  PRIMARY KEY  (`casaId`)
2756
) ENGINE=MyISAM  DEFAULT CHARSET=utf8;
2757
2758
--
2759
-- Preset data for ClubsAndServicesArchetypes
2760
--
2761
2762
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` )
2763
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 );
2764
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` ) 
2765
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);
2766
2767
-- 
2768
-- Table structure for table `clubsAndServicesEnrollments`
2769
-- 
2770
2771
DROP TABLE IF EXISTS `clubsAndServicesEnrollments`;
2772
CREATE TABLE `clubsAndServicesEnrollments` (
2773
  `caseId` int(11) NOT NULL auto_increment,
2774
  `casaId` int(11) NOT NULL default '0' COMMENT 'foreign key to clubsAndServicesArchtypes',
2775
  `casId` int(11) NOT NULL default '0' COMMENT 'foreign key to clubsAndServices',
2776
  `borrowernumber` int(11) NOT NULL default '0' COMMENT 'foreign key to borrowers',
2777
  `data1` text COMMENT 'data described in casa.data1description',
2778
  `data2` text,
2779
  `data3` text,
2780
  `dateEnrolled` date NOT NULL default '0000-00-00' COMMENT 'date borrowers service begins',
2781
  `dateCanceled` date default NULL COMMENT 'date borrower decided to end service',
2782
  `last_updated` timestamp NOT NULL default CURRENT_TIMESTAMP,
2783
  `branchcode` varchar(4) default NULL COMMENT 'foreign key to branches',
2784
  PRIMARY KEY  (`caseId`)
2785
) ENGINE=MyISAM  DEFAULT CHARSET=utf8;
2786
                  
2708
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
2787
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
2709
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
2788
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
2710
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
2789
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
(-)a/installer/data/mysql/updatedatabase.pl (+74 lines)
Lines 4734-4739 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { Link Here
4734
    SetVersion($DBversion);
4734
    SetVersion($DBversion);
4735
}
4735
}
4736
4736
4737
$DBversion = "3.07.00.XXX";
4738
if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4739
4740
    $dbh->do("CREATE TABLE clubsAndServices (
4741
  casId int(11) NOT NULL auto_increment,
4742
  casaId int(11) NOT NULL default '0' COMMENT 'foreign key to clubsAndServicesArchetypes',
4743
  title text NOT NULL,
4744
  description text,
4745
  casData1 text COMMENT 'Data described in casa.casData1Title',
4746
  casData2 text COMMENT 'Data described in casa.casData2Title',
4747
  casData3 text COMMENT 'Data described in casa.casData3Title',
4748
  startDate date NOT NULL default '0000-00-00',
4749
  endDate date default NULL,
4750
  branchcode varchar(4) NOT NULL COMMENT 'branch where club or service was created.',
4751
  last_updated timestamp NOT NULL default CURRENT_TIMESTAMP,
4752
  PRIMARY KEY  (casId)
4753
) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
4754
4755
    $dbh->do("CREATE TABLE clubsAndServicesArchetypes (
4756
  casaId int(11) NOT NULL auto_increment,
4757
  type enum('club','service') NOT NULL default 'club',
4758
  title text NOT NULL COMMENT 'title of this archetype',
4759
  description text NOT NULL COMMENT 'long description of this archetype',
4760
  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.',
4761
  casData1Title text COMMENT 'Title of contents in cas.data1',
4762
  casData2Title text COMMENT 'Title of contents in cas.data2',
4763
  casData3Title text COMMENT 'Title of contents in cas.data3',
4764
  caseData1Title text COMMENT 'Name of what is stored in cAsE.data1',
4765
  caseData2Title text COMMENT 'Name of what is stored in cAsE.data2',
4766
  caseData3Title text COMMENT 'Name of what is stored in cAsE.data3',
4767
  casData1Desc text,
4768
  casData2Desc text,
4769
  casData3Desc text,
4770
  caseData1Desc text,
4771
  caseData2Desc text,
4772
  caseData3Desc text,
4773
  caseRequireEmail tinyint(1) NOT NULL default '0',
4774
  branchcode varchar(4) default NULL COMMENT 'branch where archetype was created.',
4775
  last_updated timestamp NOT NULL default CURRENT_TIMESTAMP,
4776
  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.',
4777
  PRIMARY KEY  (casaId)
4778
) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
4779
4780
    $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 )
4781
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' );
4782
");
4783
    $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) 
4784
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');
4785
");
4786
4787
    $dbh->do("CREATE TABLE clubsAndServicesEnrollments (
4788
  caseId int(11) NOT NULL auto_increment,
4789
  casaId int(11) NOT NULL default '0' COMMENT 'foreign key to clubsAndServicesArchtypes',
4790
  casId int(11) NOT NULL default '0' COMMENT 'foreign key to clubsAndServices',
4791
  borrowernumber int(11) NOT NULL default '0' COMMENT 'foreign key to borrowers',
4792
  data1 text COMMENT 'data described in casa.data1description',
4793
  data2 text,
4794
  data3 text,
4795
  dateEnrolled date NOT NULL default '0000-00-00' COMMENT 'date borrowers service begins',
4796
  dateCanceled date default NULL COMMENT 'date borrower decided to end service',
4797
  last_updated timestamp NOT NULL default CURRENT_TIMESTAMP,
4798
  branchcode varchar(4) default NULL COMMENT 'foreign key to branches',
4799
  PRIMARY KEY  (caseId)
4800
) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
4801
4802
    $dbh->do("INSERT INTO userflags ( bit, flag, flagdesc, defaulton ) VALUES ('18',  'clubs_services',  'Access to the clubs & services module',  '0' )");
4803
    $dbh->do("INSERT INTO permissions ( module_bit, code, description ) VALUES ( '18',  'create_club_service',  'Create and edit clubs and services from existing archetypes.' )");
4804
    $dbh->do("INSERT INTO permissions ( module_bit, code, description ) VALUES ( '18', 'create_archetype', 'Create and edit archetype' ) ");
4805
    $dbh->do("INSERT INTO permissions ( module_bit, code, description ) VALUES ( '18', 'enroll_borrower', 'Enroll borrower in a club or service.' )");
4806
4807
    print "Upgrade to $DBversion done ( Added tables for Clubs & Services )\n";
4808
    SetVersion($DBversion);
4809
}
4810
4737
=head1 FUNCTIONS
4811
=head1 FUNCTIONS
4738
4812
4739
=head2 DropAllForeignKeys($table)
4813
=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=[% 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 (+85 lines)
Line 0 Link Here
1
[% INCLUDE 'doc-head-open.inc' %]
2
<title>Koha &rsaquo; Patrons &rsaquo; Account for [% firstname %] [% surname %]</title>
3
[% INCLUDE 'doc-head-close.inc' %]
4
</head>
5
<body>
6
[% INCLUDE 'header.inc' %]
7
[% INCLUDE 'patron-search.inc' %]
8
9
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/members/members-home.pl">Patrons</a>  &rsaquo; Clubs &amp; Services for [% firstname %] [% surname %]</div>
10
11
<div id="doc3" class="yui-t2">
12
   <div id="bd">
13
        <div id="yui-main">
14
        <div class="yui-b">
15
16
<table>
17
<thead>
18
<tr><th colspan="5">Currently Enrolled Clubs & Services</th></tr>
19
<tr>
20
  <th>Title</th>
21
  <th>Description</th>
22
  <th>Library</th>
23
  <th>Type</th>
24
  <th></th>
25
</tr>
26
</thead>
27
<tbody>
28
29
[% IF ( enrolledClubsAndServicesLoop ) %]
30
31
    [% FOREACH enrolledClubsAndServicesLoo IN enrolledClubsAndServicesLoop %]
32
      [% IF ( enrolledClubsAndServicesLoo.odd ) %]<tr class="highlight">[% ELSE %]<tr>[% END %]
33
        <td>[% enrolledClubsAndServicesLoo.title %]</td>
34
        <td>[% enrolledClubsAndServicesLoo.description %]</td>
35
        <td>[% enrolledClubsAndServicesLoo.branchcode %]</td>
36
        <td>[% enrolledClubsAndServicesLoo.type %]</td>
37
        <td>[% IF ( CAN_user_clubs_services_enroll_borrower ) %]<a href="clubs_services.pl?action=cancel&caseId=[% enrolledClubsAndServicesLoo.caseId %]&borrowernumber=[% borrowernumber %]">Cancel</a>[% END %]</td>
38
      </tr>
39
    [% END %]
40
41
[% ELSE %]
42
  <tr><td colspan="5"><Patron Is Not Enrolled In Any Clubs Or Services</tr></td>
43
[% END %]
44
  </tbody>
45
46
[% IF ( CAN_user_clubs_services_enroll_borrower ) %]
47
  <tr><td colspan="5">&nbsp;</td></tr>
48
49
  <thead>
50
  <tr><th colspan="5">Enroll In Clubs & Services</th></tr>
51
  <tr>
52
    <th>Title</th>
53
    <th>Description</th>
54
    <th>Library</th>
55
    <th>Type</th>
56
    <th></th>
57
  </tr>
58
  </thead>
59
60
  <tbody>
61
    [% IF ( enrollableClubsAndServicesLoop ) %]
62
63
      [% FOREACH enrollableClubsAndServicesLoo IN enrollableClubsAndServicesLoop %]
64
        [% IF ( enrollableClubsAndServicesLoo.odd ) %]<tr class="highlight">[% ELSE %]<tr>[% END %]
65
          <td>[% enrollableClubsAndServicesLoo.title %]</td>
66
          <td>[% enrollableClubsAndServicesLoo.description %]</td>
67
          <td>[% enrollableClubsAndServicesLoo.branchcode %]</td>
68
          <td>[% enrollableClubsAndServicesLoo.type %]</td>
69
          <td><a href="clubs_services_enroll.pl?casId=[% enrollableClubsAndServicesLoo.casId %]&casaId=[% enrollableClubsAndServicesLoo.casaId %]&borrowernumber=[% borrowernumber %]">Enroll</a></td>
70
        </tr>
71
      [% END %]
72
    [% ELSE %]
73
      <tr><td colspan="5">There Are No New Clubs Or Services To Enroll In</td></tr>
74
    [% END %]
75
  </tbody>
76
[% END %]
77
</table>
78
79
</div>
80
</div>
81
<div class="yui-b">
82
[% INCLUDE 'circ-menu.inc' %]
83
</div>
84
</div> 
85
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/clubs_services_enroll.tt (+73 lines)
Line 0 Link Here
1
[% INCLUDE 'doc-head-open.inc' %]
2
<title>Koha &rsaquo; Patrons &rsaquo; Account for [% firstname %] [% surname %]</title>
3
[% INCLUDE 'doc-head-close.inc' %]
4
</head>
5
<body>
6
[% INCLUDE 'header.inc' %]
7
[% INCLUDE 'patron-search.inc' %]
8
9
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/members/members-home.pl">Patrons</a> &rsaquo; Clubs &amp; Services for [% firstname %] [% surname %]</div>
10
11
<div id="doc3" class="yui-t2">
12
   <div id="bd">
13
        <div id="yui-main">
14
        <div class="yui-b">
15
16
[% IF ( previousActionEnroll ) %]
17
  [% IF ( enrollSuccess ) %]
18
    <div>Enrolled Succesfully!</div>
19
    <div><a href="/cgi-bin/koha/members/clubs_services.pl?borrowernumber=[% borrowernumber %]">Back To Clubs & Services</a></div>
20
  [% ELSE %]
21
    <div>Failed to Enroll!</div>
22
    <div>Reason: <strong>[% failureMessage %]</strong></div>
23
    <div><a href="/cgi-bin/koha/members/clubs_services.pl?borrowernumber=[% borrowernumber %]">Back To Clubs & Services</a></div>
24
  [% END %]
25
[% END %]
26
27
[% IF ( caseData1Title ) %]
28
  <div>
29
    <h4>Please Enter The Following Information</h4>
30
    <form action="clubs_services_enroll.pl" method="post">
31
    <table>
32
      [% IF ( caseData1Title ) %]
33
        <tr>
34
          <td><label for="data1">[% caseData1Title %]: </label></td>
35
          <td><input type="text" id="data1" name="data1" /></td>
36
          <td><i>[% caseData1Desc %]</i></td>
37
        </tr>
38
      [% END %]
39
40
      [% IF ( caseData2Title ) %]
41
        <tr>
42
          <td><label for="data2">[% caseData2Title %]: </label></td>
43
          <td><input type="text" id="data2" name="data2" /></td>
44
          <td><i>[% caseData2Desc %]</i></td>
45
        </tr>
46
      [% END %]
47
48
      [% IF ( caseData3Title ) %]
49
        <tr>
50
          <td><label for="data3">[% caseData3Title %]: </label></td>
51
          <td><input type="text" id="data3" name="data3" /></td>
52
          <td><i>[% caseData3Desc %]</i></td>
53
        </tr>
54
      [% END %]
55
56
      <input type="hidden" id="casId" name="casId" value="[% casId %]" />
57
      <input type="hidden" id="casaId" name="casaId" value="[% casaId %]" />
58
      <input type="hidden" id="borrowernumber" name="borrowernumber" value="[% borrowernumber %]" />
59
      <input type="hidden" name="action" value="enroll" />
60
      <tr><td colspan="3"><input type="submit" value="Enroll" /></td></tr>
61
    </table>
62
    </form>
63
  </div>
64
[% END %]
65
66
</div>
67
</div>
68
69
<div class="yui-b">
70
[% INCLUDE 'circ-menu.inc' %]
71
</div>
72
</div> 
73
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/tools-home.tt (+2 lines)
Lines 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