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

(-)a/C4/Reports/Guided.pm (+1 lines)
Lines 33-38 use C4::Log; Link Here
33
33
34
use Koha::AuthorisedValues;
34
use Koha::AuthorisedValues;
35
use Koha::Patron::Categories;
35
use Koha::Patron::Categories;
36
use Koha::SharedContent;
36
37
37
BEGIN {
38
BEGIN {
38
    require Exporter;
39
    require Exporter;
(-)a/C4/Serials.pm (+7 lines)
Lines 35-40 use Koha::DateUtils; Link Here
35
use Koha::Serial;
35
use Koha::Serial;
36
use Koha::Subscriptions;
36
use Koha::Subscriptions;
37
use Koha::Subscription::Histories;
37
use Koha::Subscription::Histories;
38
use Koha::SharedContent;
38
39
39
use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
40
use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
40
41
Lines 280-285 sub GetSubscription { Link Here
280
    });
281
    });
281
    $subscription->{additional_fields} = $additional_field_values->{$subscriptionid};
282
    $subscription->{additional_fields} = $additional_field_values->{$subscriptionid};
282
283
284
    if ( my $mana_id = $subscription->{mana_id} ) {
285
        my $mana_subscription = Koha::SharedContent::get_entity_by_id(
286
            'subscription', $mana_id, {usecomments => 1});
287
        $subscription->{comments} = $mana_subscription->{data}->{comments};
288
    }
289
283
    return $subscription;
290
    return $subscription;
284
}
291
}
285
292
(-)a/Koha/Report.pm (+57 lines)
Lines 20-25 use Modern::Perl; Link Here
20
use Carp;
20
use Carp;
21
21
22
use Koha::Database;
22
use Koha::Database;
23
use JSON;
24
use Koha::Reports;
23
25
24
use base qw(Koha::Object);
26
use base qw(Koha::Object);
25
27
Lines 33-38 Koha::Report - Koha Report Object class Link Here
33
35
34
=cut
36
=cut
35
37
38
=head3 get_search_info
39
40
Return search info
41
42
=cut
43
44
sub get_search_info {
45
    my $self = shift;
46
    my $sub_mana_info = { 'query' => shift };
47
    return $sub_mana_info;
48
}
49
50
=head3 get_sharable_info
51
52
Return properties that can be shared.
53
54
=cut
55
56
sub get_sharable_info {
57
    my $self             = shift;
58
    my $shared_report_id = shift;
59
    my $report           = Koha::Reports->find($shared_report_id);
60
    my $sub_mana_info    = {
61
        'savedsql'     => $report->savedsql,
62
        'report_name'  => $report->report_name,
63
        'notes'        => $report->notes,
64
        'report_group' => $report->report_group,
65
        'type'         => $report->type,
66
    };
67
    return $sub_mana_info;
68
}
69
70
=head3 new_from_mana
71
72
Clear a Mana report to be imported in Koha?
73
74
=cut
75
76
sub new_from_mana {
77
    my $self = shift;
78
    my $data = shift;
79
80
    $data->{mana_id} = $data->{id};
81
82
    delete $data->{exportemail};
83
    delete $data->{kohaversion};
84
    delete $data->{creationdate};
85
    delete $data->{lastimport};
86
    delete $data->{id};
87
    delete $data->{nbofusers};
88
    delete $data->{language};
89
90
    Koha::Report->new($data)->store;
91
}
92
36
=head3 _type
93
=head3 _type
37
94
38
Returns name of corresponding DBIC resultset
95
Returns name of corresponding DBIC resultset
(-)a/Koha/Reports.pm (+6 lines)
Lines 55-58 sub object_class { Link Here
55
    return 'Koha::Report';
55
    return 'Koha::Report';
56
}
56
}
57
57
58
=head1 AUTHOR
59
60
Kyle M Hall <kyle@bywatersolutions.com>
61
62
=cut
63
58
1;
64
1;
(-)a/Koha/SharedContent.pm (-37 / +159 lines)
Lines 22-90 use JSON; Link Here
22
use HTTP::Request;
22
use HTTP::Request;
23
use LWP::UserAgent;
23
use LWP::UserAgent;
24
24
25
our $MANA_IP = "http://10.25.159.107:5000";
25
use Koha::Serials;
26
use Koha::Reports;
27
use C4::Context;
26
28
27
sub manaRequest {
29
=head1 DESCRIPTION
30
31
Package for accessing shared content via Mana
32
33
=head2 Package Functions
34
35
=cut
36
37
=head3 process_request
38
39
=cut
40
41
sub process_request {
28
    my $mana_request = shift;
42
    my $mana_request = shift;
29
    my $result;
43
    my $result;
30
31
    $mana_request->content_type('application/json');
44
    $mana_request->content_type('application/json');
32
    my $userAgent = LWP::UserAgent->new;
45
    my $userAgent = LWP::UserAgent->new;
33
    my $response  = $userAgent->request($mana_request);
46
    if ( $mana_request->method eq "POST" ){
34
47
        my $content;
35
    if ( $response->code ne "204" ) {
48
        if ($mana_request->content) {$content = from_json( $mana_request->content )};
36
        $result = from_json( $response->decoded_content );
49
        $content->{securitytoken} = C4::Context->preference("ManaToken");
50
        $mana_request->content( to_json($content) );
37
    }
51
    }
52
53
    my $response = $userAgent->request($mana_request);
54
55
    eval { $result = from_json( $response->decoded_content, { utf8 => 1} ); };
38
    $result->{code} = $response->code;
56
    $result->{code} = $response->code;
57
    if ( $@ ){
58
        $result->{msg} = $@;
59
    }
60
    if ($response->is_error){
61
        $result->{msg} = "An error occurred, mana server returned: " . $response->message;
62
    }
63
    return $result ;
64
}
65
66
=head3 increment_entity_value
67
68
=cut
39
69
40
    return $result if ( $response->code =~ /^2..$/ );
70
sub increment_entity_value {
71
    return process_request(build_request('increment', @_));
41
}
72
}
42
73
43
sub manaNewUserPatchRequest {
74
=head3 send_entity
44
    my $resource = shift;
75
45
    my $id       = shift;
76
=cut
77
78
sub send_entity {
79
    my ($lang, $loggedinuser, $resourceid, $resourcetype, $content) = @_;
46
80
47
    my $url = "$MANA_IP/$resource/$id.json/newUser";
81
    unless ( $content ) {
48
    my $request = HTTP::Request->new( PATCH => $url );
82
        $content = prepare_entity_data($lang, $loggedinuser, $resourceid, $resourcetype);
83
    }
84
85
    my $result = process_request(build_request('post', $resourcetype, $content));
49
86
50
    return manaRequest($request);
87
    if ( $result and ($result->{code} eq "200" or $result->{code} eq "201") ) {
88
        my $packages = "Koha::".ucfirst($resourcetype)."s";
89
        my $resource = $packages->find($resourceid);
90
        eval { $resource->set( { mana_id => $result->{id} } )->store };
91
    }
92
    return $result;
51
}
93
}
52
94
53
sub manaPostRequest {
95
=head3 prepare_entity_data
54
    my $resource = shift;
96
55
    my $content  = shift;
97
=cut
56
98
57
    my $url = "$MANA_IP/$resource.json";
99
sub prepare_entity_data {
58
    my $request = HTTP::Request->new( POST => $url );
100
    my ($lang, $loggedinuser, $ressourceid, $ressourcetype) = @_;
101
    $lang ||= C4::Context->preference('language');
59
102
60
    $content->{bulk_import} = 0;
103
    my $mana_email;
61
    my $json = to_json( $content, { utf8 => 1 } );
104
    if ( $loggedinuser ne 0 ) {
62
    $request->content($json);
105
        my $borrower = Koha::Patrons->find($loggedinuser);
106
        $mana_email = $borrower->first_valid_email_address
107
            || Koha::Libraries->find( C4::Context->userenv->{'branch'} )->branchemail
108
    }
109
    $mana_email = C4::Context->preference('KohaAdminEmailAddress')
110
      if ( ( not defined($mana_email) ) or ( $mana_email eq '' ) );
63
111
64
    return manaRequest($request);
112
    my %versions = C4::Context::get_versions();
113
114
    my $mana_info = {
115
        language    => $lang,
116
        kohaversion => $versions{'kohaVersion'},
117
        exportemail => $mana_email
118
    };
119
120
    my $ressource_mana_info;
121
    my $packages = "Koha::".ucfirst($ressourcetype)."s";
122
    my $package = "Koha::".ucfirst($ressourcetype);
123
    $ressource_mana_info = $package->get_sharable_info($ressourceid);
124
    $ressource_mana_info = { %$ressource_mana_info, %$mana_info };
125
126
    return $ressource_mana_info;
127
}
128
129
=head3 get_entity_by_id
130
131
=cut
132
133
sub get_entity_by_id {
134
    return process_request(build_request('getwithid', @_));
135
}
136
137
=head3 search_entities
138
139
=cut
140
141
sub search_entities {
142
    return process_request(build_request('get', @_));
65
}
143
}
66
144
67
sub manaGetRequestWithId {
145
=head3 build_request
146
147
=cut
148
149
sub build_request {
150
    my $type = shift;
68
    my $resource = shift;
151
    my $resource = shift;
69
    my $id       = shift;
152
    my $mana_url = get_sharing_url();
153
154
    if ( $type eq 'get' ) {
155
        my $params = shift;
156
        $params = join '&',
157
            map { defined $params->{$_} ? $_ . "=" . $params->{$_} : () }
158
            keys %$params;
159
        my $url = "$mana_url/$resource.json?$params";
160
        return HTTP::Request->new( GET => $url );
161
    }
162
163
    if ( $type eq 'getwithid' ) {
164
        my $id = shift;
165
        my $params = shift;
166
        $params = join '&',
167
            map { defined $params->{$_} ? $_ . "=" . $params->{$_} : () }
168
            keys %$params;
169
170
        my $url = "$mana_url/$resource/$id.json?$params";
171
        return HTTP::Request->new( GET => $url );
172
    }
173
174
    if ( $type eq 'post' ) {
175
        my $content  = shift;
70
176
71
    my $url = "$MANA_IP/$resource/$id.json";
177
        my $url = "$mana_url/$resource.json";
72
    my $request = HTTP::Request->new( GET => $url );
178
        my $request = HTTP::Request->new( POST => $url );
73
179
74
    return manaRequest($request);
180
        my $json = to_json( $content, { utf8 => 1 } );
181
        $request->content($json);
182
183
        return $request;
184
    }
185
186
    if ( $type eq 'increment' ) {
187
        my $id       = shift;
188
        my $field    = shift;
189
        my $step     = shift;
190
        my $param;
191
192
        $param->{step} = $step || 1;
193
        $param->{id} = $id;
194
        $param->{resource} = $resource;
195
        $param = join '&',
196
           map { defined $param->{$_} ? $_ . "=" . $param->{$_} : () }
197
               keys %$param;
198
        my $url = "$mana_url/$resource/$id.json/increment/$field?$param";
199
        my $request = HTTP::Request->new( POST => $url );
200
201
    }
75
}
202
}
76
203
77
sub manaGetRequest {
204
=head3 get_sharing_url
78
    my $resource   = shift;
79
    my $parameters = shift;
80
205
81
    $parameters = join '&',
206
=cut
82
      map { defined $parameters->{$_} ? $_ . "=" . $parameters->{$_} : () }
83
      keys %$parameters;
84
    my $url = "$MANA_IP/$resource.json?$parameters";
85
    my $request = HTTP::Request->new( GET => $url );
86
207
87
    return manaRequest($request);
208
sub get_sharing_url {
209
    return C4::Context->config('mana_config');
88
}
210
}
89
211
90
1;
212
1;
(-)a/Koha/Subscription.pm (-1 / +13 lines)
Lines 125-137 sub frequency { Link Here
125
    return Koha::Subscription::Frequency->_new_from_dbic($frequency_rs);
125
    return Koha::Subscription::Frequency->_new_from_dbic($frequency_rs);
126
}
126
}
127
127
128
=head3 type
128
=head3 get_search_info
129
129
130
=cut
130
=cut
131
131
132
sub get_search_info {
132
sub get_search_info {
133
    my $self=shift;
133
    my $searched_sub_id = shift;
134
    my $searched_sub_id = shift;
134
    my $biblio = Koha::Biblios->find( { 'biblionumber' => $searched_sub_id } );
135
    my $biblio = Koha::Biblios->find( { 'biblionumber' => $searched_sub_id } );
136
    return unless $biblio;
135
    my $biblioitem =
137
    my $biblioitem =
136
      Koha::Biblioitems->find( { 'biblionumber' => $searched_sub_id } );
138
      Koha::Biblioitems->find( { 'biblionumber' => $searched_sub_id } );
137
139
Lines 144-150 sub get_search_info { Link Here
144
    return $sub_mana_info;
146
    return $sub_mana_info;
145
}
147
}
146
148
149
=head3 get_sharable_info
150
151
=cut
152
147
sub get_sharable_info {
153
sub get_sharable_info {
154
    my $self = shift;
148
    my $shared_sub_id = shift;
155
    my $shared_sub_id = shift;
149
    my $subscription  = Koha::Subscriptions->find($shared_sub_id);
156
    my $subscription  = Koha::Subscriptions->find($shared_sub_id);
150
    my $biblio        = Koha::Biblios->find( $subscription->biblionumber );
157
    my $biblio        = Koha::Biblios->find( $subscription->biblionumber );
Lines 189-194 sub get_sharable_info { Link Here
189
    return $sub_mana_info;
196
    return $sub_mana_info;
190
}
197
}
191
198
199
200
=head3 _type
201
202
=cut
203
192
sub _type {
204
sub _type {
193
    return 'Subscription';
205
    return 'Subscription';
194
}
206
}
(-)a/Koha/Subscription/Numberpatterns.pm (-1 / +33 lines)
Lines 32-38 Koha::SubscriptionNumberpatterns - Koha SubscriptionNumberpattern object set cla Link Here
32
32
33
=cut
33
=cut
34
34
35
=head3 uniqeLabel
35
=head3 uniqueLabel
36
36
37
=cut
37
=cut
38
38
Lines 52-57 sub uniqueLabel { Link Here
52
    return $label;
52
    return $label;
53
}
53
}
54
54
55
=head3 new_or_existing
56
57
=cut
58
59
sub new_or_existing {
60
    my ($self, $params) = @_;
61
62
    my $params_np;
63
    if ( $params->{'numbering_pattern'} eq 'mana' ) {
64
        foreach (qw/numberingmethod label1 add1 every1 whenmorethan1 setto1
65
                   numbering1 label2 add2 every2 whenmorethan2 setto2 numbering2
66
                   label3 add3 every3 whenmorethan3 setto3 numbering3/) {
67
            $params_np->{$_} = $params->{$_} if $params->{$_};
68
        }
69
70
        my $existing = Koha::Subscription::Numberpatterns->search($params_np)->next();
71
72
        if ($existing) {
73
            return $existing->id;
74
        }
75
76
        $params_np->{label} = Koha::Subscription::Numberpatterns->uniqueLabel($params->{'patternname'});
77
        $params_np->{description} = $params->{'sndescription'};
78
79
80
        my $subscription_np = Koha::Subscription::Numberpattern->new()->set($params_np)->store();
81
        return $subscription_np->id;
82
    }
83
84
    return $params->{'numbering_pattern'};
85
}
86
55
=head3 type
87
=head3 type
56
88
57
=cut
89
=cut
(-)a/debian/templates/koha-conf-site.xml.in (+3 lines)
Lines 285-290 __END_SRU_PUBLICSERVER__ Link Here
285
 <logdir>__LOG_DIR__</logdir>
285
 <logdir>__LOG_DIR__</logdir>
286
 <docdir>/usr/share/doc/koha-common</docdir>
286
 <docdir>/usr/share/doc/koha-common</docdir>
287
 <backupdir>/var/spool/koha/__KOHASITE__</backupdir>
287
 <backupdir>/var/spool/koha/__KOHASITE__</backupdir>
288
 <!-- URL of the mana KB server -->
289
 <!-- alternative value http://mana-test.koha-community.org to query the test server -->
290
 <mana_config>https://mana-kb.koha-community.org</mana_config>
288
 <!-- Enable the two following to allow superlibrarians to download
291
 <!-- Enable the two following to allow superlibrarians to download
289
      database and configuration dumps (respectively) from the Export
292
      database and configuration dumps (respectively) from the Export
290
      tool -->
293
      tool -->
(-)a/etc/koha-conf.xml (+4 lines)
Lines 153-158 __PAZPAR2_TOGGLE_XML_POST__ Link Here
153
 <!-- Path to the config file for SMS::Send -->
153
 <!-- Path to the config file for SMS::Send -->
154
 <sms_send_config>__KOHA_CONF_DIR__/sms_send/</sms_send_config>
154
 <sms_send_config>__KOHA_CONF_DIR__/sms_send/</sms_send_config>
155
155
156
 <!-- URL of the mana KB server -->
157
 <!-- alternative value http://mana-test.koha-community.org to query the test server -->
158
 <mana_config>http://mana-kb.koha-community.org</mana_config>
159
156
 <!-- Configuration for Plack -->
160
 <!-- Configuration for Plack -->
157
 <plack_max_requests>50</plack_max_requests>
161
 <plack_max_requests>50</plack_max_requests>
158
 <plack_workers>2</plack_workers>
162
 <plack_workers>2</plack_workers>
(-)a/installer/data/mysql/atomicupdate/mana_01-add_mana_id.perl (+13 lines)
Line 0 Link Here
1
$DBversion = 'XXX';
2
if( CheckVersion( $DBversion ) ) {
3
    if( !column_exists( 'subscription', 'mana_id' ) ) {
4
        $dbh->do( "ALTER TABLE subscription ADD mana_id int(11) NULL DEFAULT NULL" );
5
    }
6
7
    if( !column_exists( 'saved_sql', 'mana_id' ) ) {
8
        $dbh->do( "ALTER TABLE saved_sql ADD mana_id int(11) NULL DEFAULT NULL" );
9
    }
10
11
    SetVersion( $DBversion );
12
    print "Upgrade to $DBversion done (Bug 17047 - Add column mana_id in subscription and saved_sql tables)\n";
13
}
(-)a/installer/data/mysql/atomicupdate/mana_01-add_mana_id_in_subscription.sql (-1 lines)
Line 1 Link Here
1
ALTER TABLE subscription ADD mana_id int(11);
(-)a/installer/data/mysql/atomicupdate/mana_02-add_Mana_syspref.sql (-1 / +1 lines)
Line 1 Link Here
1
INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES ('Mana', '1', 'request to Mana Webservice. Mana centralize commun information between other Koha to facilitate the creation of new subscriptions, vendors, report queries etc... You can search, share, import and comment the content of Mana.', NULL, 'YesNo');
1
INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES ('Mana','2', 0|1|2,'request to Mana Webservice. Mana centralize commun information between other Koha to facilitate the creation of new subscriptions, vendors, report queries etc... You can search, share, import and comment the content of Mana.','Choice');
(-)a/installer/data/mysql/atomicupdate/mana_03-add_mana_autoshare.sql (+2 lines)
Line 0 Link Here
1
INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES
2
('AutoShareWithMana','','','defines datas automatically shared with mana','multiple');
(-)a/installer/data/mysql/atomicupdate/mana_04-add_mana_token.sql (+2 lines)
Line 0 Link Here
1
INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES
2
('ManaToken','',NULL,'Security token used for authentication on Mana KB service (anti spam)','Textarea');
(-)a/installer/data/mysql/atomicupdate/skeleton.perl (-1 / +1 lines)
Lines 1-4 Link Here
1
$DBversion = 'XXX';  # will be replaced by the RM
1
$DBversion = 'XXX';
2
if( CheckVersion( $DBversion ) ) {
2
if( CheckVersion( $DBversion ) ) {
3
    # you can use $dbh here like:
3
    # you can use $dbh here like:
4
    # $dbh->do( "ALTER TABLE biblio ADD COLUMN badtaste int" );
4
    # $dbh->do( "ALTER TABLE biblio ADD COLUMN badtaste int" );
(-)a/installer/data/mysql/kohastructure.sql (+2 lines)
Lines 1462-1467 CREATE TABLE saved_sql ( -- saved sql reports Link Here
1462
    report_area varchar(6) default NULL,
1462
    report_area varchar(6) default NULL,
1463
    report_group varchar(80) default NULL,
1463
    report_group varchar(80) default NULL,
1464
    report_subgroup varchar(80) default NULL,
1464
    report_subgroup varchar(80) default NULL,
1465
    `mana_id` int(11) NULL DEFAULT NULL,
1465
   PRIMARY KEY  (`id`),
1466
   PRIMARY KEY  (`id`),
1466
   KEY sql_area_group_idx (report_group, report_subgroup),
1467
   KEY sql_area_group_idx (report_group, report_subgroup),
1467
   KEY boridx (`borrowernumber`)
1468
   KEY boridx (`borrowernumber`)
Lines 2127-2132 CREATE TABLE `subscription` ( -- information related to the subscription Link Here
2127
  `reneweddate` date default NULL, -- date of last renewal for the subscription
2128
  `reneweddate` date default NULL, -- date of last renewal for the subscription
2128
  `itemtype` VARCHAR( 10 ) NULL,
2129
  `itemtype` VARCHAR( 10 ) NULL,
2129
  `previousitemtype` VARCHAR( 10 ) NULL,
2130
  `previousitemtype` VARCHAR( 10 ) NULL,
2131
  `mana_id` int(11) NULL DEFAULT NULL,
2130
  PRIMARY KEY  (`subscriptionid`),
2132
  PRIMARY KEY  (`subscriptionid`),
2131
  KEY `by_biblionumber` (`biblionumber`),
2133
  KEY `by_biblionumber` (`biblionumber`),
2132
  CONSTRAINT subscription_ibfk_1 FOREIGN KEY (periodicity) REFERENCES subscription_frequencies (id) ON DELETE SET NULL ON UPDATE CASCADE,
2134
  CONSTRAINT subscription_ibfk_1 FOREIGN KEY (periodicity) REFERENCES subscription_frequencies (id) ON DELETE SET NULL ON UPDATE CASCADE,
(-)a/installer/data/mysql/sysprefs.sql (-1 / +1 lines)
Lines 66-71 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
66
('AutoCreateAuthorities','0',NULL,'Automatically create authorities that do not exist when cataloging records.','YesNo'),
66
('AutoCreateAuthorities','0',NULL,'Automatically create authorities that do not exist when cataloging records.','YesNo'),
67
('AutoEmailOpacUser','0',NULL,'Sends notification emails containing new account details to patrons - when account is created.','YesNo'),
67
('AutoEmailOpacUser','0',NULL,'Sends notification emails containing new account details to patrons - when account is created.','YesNo'),
68
('AutoEmailPrimaryAddress','OFF','email|emailpro|B_email|cardnumber|OFF','Defines the default email address where \'Account Details\' emails are sent.','Choice'),
68
('AutoEmailPrimaryAddress','OFF','email|emailpro|B_email|cardnumber|OFF','Defines the default email address where \'Account Details\' emails are sent.','Choice'),
69
('AutoShareWithMana','subscription','','defines datas automatically shared with mana','multiple'),
69
('AutoLocation','0',NULL,'If ON, IP authentication is enabled, blocking access to the staff client from unauthorized IP addresses','YesNo'),
70
('AutoLocation','0',NULL,'If ON, IP authentication is enabled, blocking access to the staff client from unauthorized IP addresses','YesNo'),
70
('AutomaticItemReturn','1',NULL,'If ON, Koha will automatically set up a transfer of this item to its homebranch','YesNo'),
71
('AutomaticItemReturn','1',NULL,'If ON, Koha will automatically set up a transfer of this item to its homebranch','YesNo'),
71
('autoMemberNum','0','','If ON, patron number is auto-calculated','YesNo'),
72
('autoMemberNum','0','','If ON, patron number is auto-calculated','YesNo'),
Lines 275-281 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
275
('LocalHoldsPriorityPatronControl',  'PickupLibrary',  'HomeLibrary|PickupLibrary',  'decides if the feature operates using the library set as the patron''s home library, or the library set as the pickup library for the given hold.',  'Choice'),
276
('LocalHoldsPriorityPatronControl',  'PickupLibrary',  'HomeLibrary|PickupLibrary',  'decides if the feature operates using the library set as the patron''s home library, or the library set as the pickup library for the given hold.',  'Choice'),
276
('makePreviousSerialAvailable','0','','make previous serial automatically available when collecting a new serial. Please note that the item-level_itypes syspref must be set to specific item.','YesNo'),
277
('makePreviousSerialAvailable','0','','make previous serial automatically available when collecting a new serial. Please note that the item-level_itypes syspref must be set to specific item.','YesNo'),
277
('Mana','1',NULL,'request to Mana Webservice. Mana centralize commun information between other Koha to facilitate the creation of new subscriptions, vendors, report queries etc... You can search, share, import and comment the content of Mana.','YesNo'),
278
('Mana','1',NULL,'request to Mana Webservice. Mana centralize commun information between other Koha to facilitate the creation of new subscriptions, vendors, report queries etc... You can search, share, import and comment the content of Mana.','YesNo'),
278
('hide_marc','0',NULL,'If ON, disables display of MARC fields, subfield codes & indicators (still shows data)','YesNo'),
279
('ManInvInNoissuesCharge','1',NULL,'MANUAL_INV charges block checkouts (added to noissuescharge).','YesNo'),
279
('ManInvInNoissuesCharge','1',NULL,'MANUAL_INV charges block checkouts (added to noissuescharge).','YesNo'),
280
('MARCAuthorityControlField008','|| aca||aabn           | a|a     d',NULL,'Define the contents of MARC21 authority control field 008 position 06-39','Textarea'),
280
('MARCAuthorityControlField008','|| aca||aabn           | a|a     d',NULL,'Define the contents of MARC21 authority control field 008 position 06-39','Textarea'),
281
('MarcFieldDocURL', NULL, NULL, 'URL used for MARC field documentation. Following substitutions are available: {MARC} = marc flavour, eg. "MARC21" or "UNIMARC". {FIELD} = field number, eg. "000" or "048". {LANG} = user language, eg. "en" or "fi-FI"', 'free'),
281
('MarcFieldDocURL', NULL, NULL, 'URL used for MARC field documentation. Following substitutions are available: {MARC} = marc flavour, eg. "MARC21" or "UNIMARC". {FIELD} = field number, eg. "000" or "048". {LANG} = user language, eg. "en" or "fi-FI"', 'free'),
(-)a/koha-tmpl/intranet-tmpl/lib/jquery/activatemana.js (+18 lines)
Line 0 Link Here
1
$(document).ready(function(){
2
    $("#activatemana").on("click", function(){
3
        var mylastname = $("#lastname").val()
4
        var myfirstname = $("#firstname").val()
5
        var myemail = $("#email").val()
6
        $.ajax( {
7
            type: "POST",
8
            url: "/cgi-bin/koha/svc/mana/token",
9
            data: { lastname: mylastname, firstname: myfirstname, email: myemail},
10
            dataType: "json",
11
        })
12
        .done(function(result){
13
            $("#pref_ManaToken").val(result.token);
14
            $("#pref_ManaToken").trigger("input");
15
        });
16
        return false;
17
    });
18
});
(-)a/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss (+6 lines)
Lines 717-722 ol { Link Here
717
    background-color: #FFD000 !important;
717
    background-color: #FFD000 !important;
718
}
718
}
719
719
720
.warned-row,
721
.warned-row td { background-color: #FF9000 !important }
722
723
.high-warned-row,
724
.high-warned-row td { background-color: #FF0000 !important }
725
720
tbody {
726
tbody {
721
    tr {
727
    tr {
722
        &:nth-child(odd) {
728
        &:nth-child(odd) {
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc (-1 / +1 lines)
Lines 118-124 jQuery(function($){ Link Here
118
        dayNamesMin: [_("Su"),_("Mo"),_("Tu"),_("We"),_("Th"),_("Fr"),_("Sa")],
118
        dayNamesMin: [_("Su"),_("Mo"),_("Tu"),_("We"),_("Th"),_("Fr"),_("Sa")],
119
        weekHeader: _("Wk"),
119
        weekHeader: _("Wk"),
120
        dateFormat: "[% IF ( dateformat == "us" ) %]mm/dd/yy[% ELSIF ( dateformat == "metric" ) %]dd/mm/yy[% ELSIF ( dateformat == "dmydot" ) %]dd.mm.yy[% ELSE %]yy-mm-dd[% END %]",
120
        dateFormat: "[% IF ( dateformat == "us" ) %]mm/dd/yy[% ELSIF ( dateformat == "metric" ) %]dd/mm/yy[% ELSIF ( dateformat == "dmydot" ) %]dd.mm.yy[% ELSE %]yy-mm-dd[% END %]",
121
        firstDay: [% Koha.Preference('CalendarFirstDayOfWeek') | html %],
121
        firstDay: '[% Koha.Preference('CalendarFirstDayOfWeek') | html %]',
122
        isRTL: [% IF ( bidi ) %]true[% ELSE %]false[% END %],
122
        isRTL: [% IF ( bidi ) %]true[% ELSE %]false[% END %],
123
        showMonthAfterYear: false,
123
        showMonthAfterYear: false,
124
        yearSuffix: ''};
124
        yearSuffix: ''};
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/mana-subscription-search-result.inc (-46 lines)
Lines 1-46 Link Here
1
[% USE KohaDates %]
2
<table id="mana_results_datatable">
3
    <thead>
4
        <tr>
5
            <th>ISSN</th>
6
            <th class="anti-the">Title</th>
7
            <th>Frequency</th>
8
            <th>Numbering pattern</th>
9
            <th class="NoSort">Number of users</th>
10
            <th class="title-string">Last Import</th>
11
            [% UNLESS search_only %]
12
              <th class="NoSort">Actions</th>
13
            [% END %]
14
        </tr>
15
    </thead>
16
    <tfoot>
17
        <tr>
18
            <td><input type="text" class="dt-filter" data-column_num="0" placeholder="Search ISSN" /></td>
19
            <td><input type="text" class="dt-filter" data-column_num="1" placeholder="Search title" /></td>
20
            <td><input type="text" class="dt-filter" data-column_num="2" placeholder="Search frequency" /></td>
21
            <td><input type="text" class="dt-filter" data-column_num="3" placeholder="Search numbering pattern" /></td>
22
            <td></td>
23
            <td><input type="text" class="dt-filter" data-column_num="5" placeholder="Search last import" /></td>
24
            [% UNLESS search_only %]
25
              <td></td>
26
            [% END %]
27
        </tr>
28
    </tfoot>
29
    <tbody>
30
        [% FOREACH subscription IN subscriptions %]
31
            [% UNLESS subscription.cannotdisplay %]
32
                <tr id="row[% subscription.subscriptionid %]">
33
                    <td>[% IF ( subscription.issn ) %][% subscription.issn %][% END %]</td>
34
                    <td>[% subscription.title %]</a></td>
35
                    <td>[% IF ( subscription.sfdescription ) %][% subscription.sfdescription %][% END %]</td>
36
                    <td>[% IF ( subscription.numberingmethod ) %][% subscription.numberingmethod %][% END %]</td>
37
                    <td>[% IF ( subscription.nbofusers ) %][% subscription.nbofusers %][% END %]</td>
38
                    <td><span title="[% subscription.lastimport %]">[% subscription.lastimport | $KohaDates %]</span></td>
39
                    [% UNLESS search_only %]
40
                      <td><a style="cursor:pointer" onclick="mana_use([% subscription.id %])"> <i class="fa fa-inbox"></i> Use</a></td>
41
                    [% END %]
42
                </tr>
43
            [% END %]
44
        [% END %]
45
    </tbody>
46
</table>
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/mana.inc (+44 lines)
Line 0 Link Here
1
<script type="text/JavaScript">
2
//<![CDATA[
3
$(document).ready(function() {
4
    function mana_increment(mana_id, resource, fieldvalue, stepvalue = 1) {
5
        $.ajax( {
6
            type: "POST",
7
            url: "/cgi-bin/koha/svc/mana/increment",
8
            data: {id: mana_id, resource: resource, field: fieldvalue, step: stepvalue},
9
            datatype: "json",
10
        })
11
    }
12
13
    function mana_comment( target_id, manamsg, resource_type ) {
14
        $.ajax( {
15
            type: "POST",
16
            url: "/cgi-bin/koha/svc/mana/share",
17
            data: {message: manamsg, resource: resource_type , resource_id: target_id},
18
            datatype: "json",
19
        })
20
    }
21
22
    $(document).on('click', 'ul li.mana-comment', function() {
23
        id = $(this).attr('data-id');
24
        mana_increment(id, 'resource_comment', 'nb');
25
    });
26
27
    $(document).on('click', 'ul li.mana-other-comment', function() {
28
        $('#mana-comment-box').modal('show');
29
    });
30
31
    $(document).on('click', '#mana-send-comment', function() {
32
        var resource_type = $('#mana-resource').val();
33
        var resource_id = $('#mana-resource-id').val();
34
        var comment = $("#mana-comment").val();
35
        mana_comment(resource_id, comment, resource_type);
36
        $("#mana-comment-box").modal("hide");
37
    });
38
39
    $(document).on('click', '#mana-comment-close', function() {
40
        $("#mana-comment-box").modal("hide");
41
    });
42
});
43
//]]>
44
</script>
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/mana/mana-report-search-result.inc (+81 lines)
Line 0 Link Here
1
[% USE KohaDates %]
2
[% USE Koha %]
3
[% USE AuthorisedValues %]
4
[% USE Branches %]
5
6
<script type="text/javascript">
7
//<![CDATA[
8
$(document).ready(function() {
9
    $(document).on('click', 'button.mana-use', function() {
10
        id = $(this).attr('id');
11
        mana_use(id.substr(9));
12
    });
13
14
    $(document).on('change', 'select.mana-actions', function() {
15
        report_id = $(this).attr('id').substr(13);
16
        if ($(this).val() == 'other') {
17
            $('input#selected_id').val(report_id);
18
            $('#comment_box').modal('show');
19
        } else {
20
            comment_id = $(this).val();
21
            mana_increment(comment_id, 'resource_comment', 'nb');
22
        }
23
    });
24
});
25
//]]>
26
</script>
27
[% INCLUDE 'mana.inc' %]
28
29
[% IF statuscode == "200" AND reports %]
30
    <table id="mana_results_datatable" width=100%>
31
        <thead>
32
            <tr>
33
                <th>Report Name</th>
34
                <th class="anti-the" width=35%>Notes</th>
35
                <th>Type</th>
36
                <th title="number of libraries using this pattern"># of users</th>
37
                <th class="title-string" title="last time a library used this pattern">Last import</th>
38
                <th> Comments </th>
39
                [% UNLESS search_only %]
40
                  <th class="NoSort">Actions</th>
41
                [% END %]
42
            </tr>
43
        </thead>
44
        <tbody>
45
            [% FOREACH report IN reports %]
46
                [% UNLESS report.cannotdisplay %]
47
                    [% IF report.nbofcomment > highWarned %]
48
                  <tr id="row[% report.id %]" class = "high-warned-row">
49
                    [% ELSIF report.nbofcomment > warned %]
50
                  <tr id="row[% report.id %]" class = "warned-row">
51
                    [% ELSIF report.nbofcomment > lowWarned %]
52
                  <tr id="row[% report.id %]" class = "highlighted-row">
53
                    [% END %]
54
                    <input hidden class="rowid" value="[% report.id %]">
55
                    <td>[% IF ( report.report_name ) %][% report.report_name %][% END %]</td>
56
                    <td title="[% report.savedsql |html %]"><div>
57
                        [% IF report.notes.length > 200 %]
58
                            [% report.notes.substr(0,200) %]<a class="showbutton">Show More</a></div><div hidden>
59
                        [% END %]
60
                            [% report.notes %]
61
                        [% IF report.notes.length > 200 %]
62
                                <a class="hidebutton">Show Less</a></div> </td>
63
                        [% END %]
64
                    <td> [% report.type %] </td>
65
                    <td>[% IF ( report.nbofusers ) %][% report.nbofusers %][% END %]</td>
66
                    <td><span title="[% report.lastimport %]">[% report.lastimport | $KohaDates %]</span></td>
67
                    <td>[% FOREACH comment IN report.comments %][% comment.message %] ([% comment.nb %]) <br>[% END %]</td>
68
69
                    [% UNLESS search_only %]
70
                        <td>
71
                            <button class="mana-use" id="mana-use-[% report.id %]"><i class="fa fa-inbox"></i> Use</button>
72
                        </td>
73
                    [% END %]
74
                  </tr>
75
                [% END %]
76
            [% END %]
77
        </tbody>
78
    </table>
79
[% ELSE %]
80
    <h4> [% msg %]  statuscode: [% statuscode %]</h4>
81
[% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/mana/mana-subscription-search-result.inc (+92 lines)
Line 0 Link Here
1
[% USE KohaDates %]
2
[% USE Koha %]
3
[% USE AuthorisedValues %]
4
[% USE Branches %]
5
[% INCLUDE 'mana.inc' %]
6
<script type="text/javascript">
7
//<![CDATA[
8
$(document).ready(function() {
9
    $(document).on('click', 'button.mana-use', function() {
10
        id = $(this).attr('id');
11
        mana_use(id.substr(9));
12
    });
13
});
14
//]]>
15
</script>
16
17
[% IF statuscode == "200" %]
18
    <table id="mana_results_datatable" width=100%>
19
        <thead>
20
            <tr>
21
                <th>ISSN</th>
22
                <th class="anti-the" width=50%>Title</th>
23
                <th> Published by </th>
24
                <th>Frequency</th>
25
                <th>Numbering pattern</th>
26
                <th title="number of libraries using this pattern"># of users</th>
27
                <th class="title-string" title="last time a library used this pattern">Last import</th>
28
                <th> Comments </th>
29
                [% UNLESS search_only %]
30
                  <th class="NoSort">Actions</th>
31
                [% END %]
32
            </tr>
33
        </thead>
34
        <tbody>
35
            [% FOREACH subscription IN subscriptions %]
36
                [% UNLESS subscription.cannotdisplay %]
37
                    [% IF subscription.nbofcomment > highWarned  %]
38
                    <tr id="row[% subscription.subscriptionid %]" class = "high-warned-row" title="this resource has been reported more than [% highWarned %] times, take care!">
39
                    [% ELSIF subscription.nbofcomment > warned  %]
40
                    <tr id="row[% subscription.subscriptionid %]" class = "warned-row" title="this resource has been reported more than [% warned %] times, take care!">
41
                    [% ELSIF subscription.nbofcomment > lowWarned  %]
42
                    <tr id="row[% subscription.subscriptionid %]" class = "highlighted-row" title="this resource has been reported more than [% lowWarned %] times, take care!">
43
                    [% END %]
44
                    <input hidden class="rowid" value="[% subscription.id %]">
45
                        <td>[% IF ( subscription.issn ) %][% subscription.issn %][% END %]</td>
46
                        <td>[% subscription.title %]</a></td>
47
                        <td>[% IF ( subscription.publishercode ) %][% subscription.publishercode %][% END %]</td>
48
                        <td>[% IF ( subscription.sfdescription ) %][% subscription.sfdescription %][% END %]</td>
49
                        <td>[% IF ( subscription.numberingmethod ) %][% subscription.numberingmethod %][% END %]</td>
50
                        <td>[% IF ( subscription.nbofusers ) %][% subscription.nbofusers %][% END %]</td>
51
                        <td><span title="[% subscription.lastimport %]">[% subscription.lastimport | $KohaDates %]</span></td>
52
                        <td>[% FOREACH comment IN subscription.comments %][% comment.message %] ([% comment.nb %]) <br>[% END %]</td>
53
54
                        [% UNLESS search_only %]
55
                            <td>
56
                                <button class="mana-use" id="mana-use-[% subscription.id %]"><i class="fa fa-inbox"></i> Use</button>
57
                                <select class="mana-actions" id="mana-actions-[% subscription.id %]">
58
                                    <option selected disabled>Report mistake</option>
59
                                    [% FOREACH comment IN subscription.comments %]
60
                                        <option value="[% comment.id %]"> [% comment.message %] ([% comment.nb %])</option>
61
                                    [% END %]
62
                                        <option>other</option>
63
                                </select>
64
                                <button hidden class="actionreport2" hidden> Cancel</button>
65
                            </td>
66
                        [% END %]
67
                    </tr>
68
                [% END %]
69
            [% END %]
70
        </tbody>
71
    </table>
72
[% ELSE %]
73
    <h4>Mana search fails with the code: [% statuscode %] </h4>
74
[% END %]
75
76
<div id="comment_box" class="modal" tabindex="-1" role="dialog" aria-labelledby="mana_search_result_label" style="display: none;">
77
    <div class="modal-dialog modal-lg" style="width: 30%">
78
        <div class="modal-content" style="">
79
            <div class="modal-header">
80
                <button type="button" id="commentCloseButton" class="closebtn" aria-hidden="true">×</button>
81
                <h3 id="mana_submit_comment"> Please enter a new commment (max 35 caracters)</h3>
82
            </div>
83
            <div class="modal-body">
84
                <form>
85
                    <input hidden id="selected_id" value="">
86
                    <input type="text" id="manamsg"> Comment:
87
                </form>
88
                <button id="CommentButton"> Comment </button>
89
            </div>
90
        </div>
91
    </div>
92
</div>
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/reports-toolbar.inc (+138 lines)
Lines 6-11 Link Here
6
            <ul class="dropdown-menu">
6
            <ul class="dropdown-menu">
7
                <li id="newmenuc"><a href="/cgi-bin/koha/reports/guided_reports.pl?phase=Build%20new">New guided report</a> </li>
7
                <li id="newmenuc"><a href="/cgi-bin/koha/reports/guided_reports.pl?phase=Build%20new">New guided report</a> </li>
8
                <li id="newsql"><a href="/cgi-bin/koha/reports/guided_reports.pl?phase=Create%20report%20from%20SQL">New SQL report</a> </li>
8
                <li id="newsql"><a href="/cgi-bin/koha/reports/guided_reports.pl?phase=Create%20report%20from%20SQL">New SQL report</a> </li>
9
                [% IF Koha.Preference('Mana')==1 %]
10
                <li id="newsql"><a href="" data-toggle="modal" data-target="#mana_search_result">New SQL from Mana</a> </li>
11
                [% END %]
9
            </ul>
12
            </ul>
10
        </div>
13
        </div>
11
    [% END %]
14
    [% END %]
Lines 47-52 Link Here
47
            </div>
50
            </div>
48
        [% END %]
51
        [% END %]
49
52
53
        [% IF ( mana_id && Koha.Preference('Mana') == 1 ) %]
54
            <div class="btn-group">
55
                <button class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown"> Report mistake <span class="caret"></span></button>
56
                <ul class="dropdown-menu">
57
                    [% FOREACH c IN mana_comments %]
58
                        <li class="mana-comment" data-id="[% c.id %]">
59
                            <a href="#">[% c.message %] ([% c.nb %])</a>
60
                        </li>
61
                    [% END %]
62
                    <li role="separator" class="divider"></li>
63
                    <li class="mana-other-comment"><a href="#">Other</a> </li>
64
                </ul>
65
            </div>
66
67
            <div id="mana-comment-box" class="modal" tabindex="-1" role="dialog" aria-labelledby="mana_search_result_label" style="display: none;">
68
                <div class="modal-dialog modal-lg" style="width: 30%">
69
                    <div class="modal-content" style="">
70
                        <div class="modal-header">
71
                            <button type="button" id="mana-comment-close" class="closebtn"  aria-hidden="true">×</button>
72
                            <h3 id="mana_submit_comment"> Please enter a new commment (max 35 caracters)</h3>
73
                        </div>
74
                        <div class="modal-body">
75
                            <input hidden id="mana-resource" value="report">
76
                            <input hidden id="mana-resource-id" value="[% mana_id %]">
77
                            <div>
78
                                <input type="text" maxlength="35" size="35" id="mana-comment">
79
                            </div>
80
                            <button id="mana-send-comment"> Comment </button>
81
                        </div>
82
                    </div>
83
                </div>
84
            </div>
85
        [% END %]
86
50
        [% IF ( execute ) %]
87
        [% IF ( execute ) %]
51
            [% BLOCK params %]
88
            [% BLOCK params %]
52
                [%- FOREACH param IN sql_params %]&amp;sql_params=[% param | uri %][% END %]
89
                [%- FOREACH param IN sql_params %]&amp;sql_params=[% param | uri %][% END %]
Lines 77-79 Link Here
77
114
78
    [% END %]
115
    [% END %]
79
</div>
116
</div>
117
118
[% IF Koha.Preference('Mana')==1 %]
119
    <div id="mana_search_result" class="modal fade container-fluid" tabindex="-1" role="dialog" aria-labelledby="mana_search_result_label" style="width: 100%; left:0%; margin-left: auto; display: none;">
120
        <div class="modal-dialog modal-lg">
121
            <div class="modal-content">
122
                <div class="modal-header">
123
                    <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
124
                    <h3 id="mana_search_result_label"> Mana Search</h3>
125
                </div>
126
                <div>
127
                    <form id="search_form" style="margin-left: 5%">
128
                        Please enter a few key words:
129
                        <input type=text id=mana_search_field>
130
                        <input type=button class="mana_search_button" value="Search">
131
                    </form>
132
                    <div class="modal-body">
133
                    </div>
134
                </div>
135
            </div>
136
        </div>
137
    </div>
138
[% END %]
139
140
<script type="text/javascript">
141
    function mana_use( mana_id ){
142
        $.ajax( {
143
            type:"POST",
144
            url: "/cgi-bin/koha/svc/mana/use",
145
            data: {id:mana_id, resource: 'report', saveinbase: 1},
146
            dataType: "json",
147
        })
148
        .done( function (result){
149
            if ( result.errmsg ){
150
                alert( result.errmsg );
151
            }
152
            else{
153
                window.location = ("/cgi-bin/koha/reports/guided_reports.pl?reports=").concat(result.id).concat("&amp;phase=Show%20SQL&mana_success=1&phase=Edit%20SQL");
154
            }
155
        })
156
        .fail( function ( foo, msg, longmsg, bla ){
157
        });
158
    }
159
160
    function mana_search( textquery ){
161
        $.ajax({
162
            type: "POST",
163
            url: "/cgi-bin/koha/svc/mana/search",
164
            data: {biblionumber: $("#biblionumber").val(), resource: 'report', id: textquery, usecomments: 1},
165
            dataType: "html",
166
        })
167
        .done( function( result ) {
168
            $("#mana_search_result .modal-body").html(result);
169
            $("#mana_search_result_label").text(_("Results from Mana Knowledge Base"));
170
            $("#mana_results_datatable").dataTable($.extend(true, {}, dataTablesDefaults,{
171
                "sPaginationType":"four_button",
172
                "autoWidth": false,
173
                "columnDefs": [
174
                    { "width": "35%", "targets": 1 }
175
                ],
176
                "aoColumnDefs": [
177
                    { 'bSortable': false, "bSearchable": false, 'aTargets': [ 'NoSort' ] },
178
                    { "sType": "title-string", "aTargets" : [ "title-string" ] },
179
                    { 'sType': "anti-the", 'aTargets' : [ 'anti-the'] }
180
                ]
181
            }));
182
            if($("td.dataTables_empty").length == 0){
183
                 $("#mana_search").show();
184
            }
185
186
            $( "select[class='actionreport1']" ).show();
187
            $( "button[class='actionreport2']" ).hide();
188
189
            $(".showbutton").on("click", function(){
190
                $(this).parent().hide();
191
                $(this).parent().next().show();
192
            });
193
194
            $("a[class='hidebutton']").on("click", function(){
195
                $(this).parent().hide();
196
                $(this).parent().prev().show();
197
            });
198
199
            $("#commentCloseButton").on("click", function(){
200
                $("#comment_box").modal("hide");
201
            });
202
203
            $(".actionreport1").on("click", function(){
204
                $("#selectedcomment").val($(this).val());
205
                $(this).parent("select").hide();
206
                $(this).parent("select").next().show();
207
            });
208
209
            $(".actionreport2").on("click", function(){
210
                $(this).hide();
211
                $(this).prev().show();
212
                mana_increment($("#selectedcomment").val(), 'resource_comment', 'nb', -1);
213
            });
214
        }).fail( function( result ){
215
        });
216
    }
217
</script>
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/serials-toolbar.inc (-10 / +43 lines)
Lines 7-17 Link Here
7
            [% ELSE %]
7
            [% ELSE %]
8
                <div class="btn-group"><a id="newsubscription" class="btn btn-default btn-sm" href="/cgi-bin/koha/serials/subscription-add.pl"><i class="fa fa-plus"></i> New subscription</a></div>
8
                <div class="btn-group"><a id="newsubscription" class="btn btn-default btn-sm" href="/cgi-bin/koha/serials/subscription-add.pl"><i class="fa fa-plus"></i> New subscription</a></div>
9
            [% END %]
9
            [% END %]
10
            [% IF Koha.Preference('Mana') %]
10
            [% IF Koha.Preference('Mana') and Koha.Preference('AutoShareWithMana').grep('subscription').size == 0 %]
11
                [% IF one_language_enabled==0 or mana_id %]
11
                [% IF one_language_enabled==0 or mana_id %]
12
                    <div class="btn-group"><a data-toggle="modal" data-toggle="tooltip" title="Your email address will be associated to your sharing." data-target="#mana_share_modal" class="btn btn-small"><i class="fa fa-share-alt"></i> Share</a></div>
12
                    <div class="btn-group"><a data-toggle="modal" data-toggle="tooltip" title="Share the subscription with other librairies. Your email address will be associated to your sharing." data-target="#mana_share_modal" class="btn btn-default btn-sm"><i class="fa fa-share-alt"></i> Share</a></div>
13
                [% ELSE %]
13
                [% ELSE %]
14
                    <div class="btn-group" data-toggle="tooltip" title="Your email address will be associated to your sharing."><a class="btn btn-small" onclick="share()"><i class="fa fa-share-alt"></i> Share</a></div>
14
                    <div class="btn-group" id="mana-subscription-share" data-toggle="tooltip" title="Share the subscription with other libraries. Your email address will be associated to your sharing."><a class="btn btn-default btn-sm"><i class="fa fa-share-alt"></i> Share</a></div>
15
                [% END %]
15
                [% END %]
16
            [% END %]
16
            [% END %]
17
        [% END %]
17
        [% END %]
Lines 60-65 Link Here
60
                [% END %]
60
                [% END %]
61
            [% END %]
61
            [% END %]
62
        [% END %]
62
        [% END %]
63
64
        [% IF ( mana_id && Koha.Preference('Mana') == 1 ) %]
65
            <div class="btn-group">
66
                <button class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown"> Report mistake <span class="caret"></span></button>
67
                <ul class="dropdown-menu">
68
                    [% FOREACH c IN mana_comments %]
69
                        <li class="mana-comment" data-id="[% c.id %]">
70
                            <a href="#">[% c.message %] ([% c.nb %])</a>
71
                        </li>
72
                    [% END %]
73
                    <li role="separator" class="divider"></li>
74
                    <li class="mana-other-comment"><a href="#">Other</a> </li>
75
                </ul>
76
            </div>
77
78
            <div id="mana-comment-box" class="modal" tabindex="-1" role="dialog" aria-labelledby="mana_search_result_label" style="display: none;">
79
                <div class="modal-dialog modal-lg" style="width: 30%">
80
                    <div class="modal-content" style="">
81
                        <div class="modal-header">
82
                            <button type="button" id="mana-comment-close" class="closebtn"  aria-hidden="true">×</button>
83
                            <h3 id="mana_submit_comment"> Please enter a new commment (max 35 caracters)</h3>
84
                        </div>
85
                        <div class="modal-body">
86
                            <input hidden id="mana-resource" value="subscription">
87
                            <input hidden id="mana-resource-id" value="[% mana_id %]">
88
                            <div>
89
                                <input type="text" maxlength="35" size="35" id="mana-comment">
90
                            </div>
91
                            <button id="mana-send-comment"> Comment </button>
92
                        </div>
93
                    </div>
94
                </div>
95
            </div>
96
        [% END %]
63
    </div>
97
    </div>
64
[% ELSIF CAN_user_serials_create_subscription %]
98
[% ELSIF CAN_user_serials_create_subscription %]
65
    <div id="toolbar" class="btn-toolbar">
99
    <div id="toolbar" class="btn-toolbar">
Lines 80-97 Link Here
80
            <div class="modal-body">
114
            <div class="modal-body">
81
                [% IF (mana_id) %]
115
                [% IF (mana_id) %]
82
                    <div class="alert">
116
                    <div class="alert">
83
                        <p>Your subscription is already linked with a Mana subscription model. Share it if you have made modifications, otherwide it will do nothing.</p>
117
<h1>[% (mana_id) %]</h1>
118
                        <p>Your subscription is already linked with a Mana subscription model. Share it if you have made modifications, otherwise it will do nothing.</p>
84
                    </div>
119
                    </div>
85
                [% END %]
120
                [% END %]
86
                [% IF ( languages_loop ) %]
121
                [% IF ( languages_loop ) %]
87
                    [% UNLESS ( one_language_enabled ) %]
122
                    [% UNLESS ( one_language_enabled ) %]
88
                        <div class="rows">
123
                        <div class="rows">
89
                            <p>The frequency and the numberpattern of [% bibliotitle %] are :</p>
124
                                <li><span class="label">Frequency: </span>
90
                            <ol>
91
                                <li><span class="label">Frequency : </span>
92
                                        [% frequency.description %]
125
                                        [% frequency.description %]
93
                                </li>
126
                                </li>
94
                                <li><span class="label">Number pattern : </span>
127
                                <li><span class="label">Number pattern: </span>
95
                                    [% numberpattern.label %]
128
                                    [% numberpattern.label %]
96
                                </li>
129
                                </li>
97
                            </ol>
130
                            </ol>
Lines 99-105 Link Here
99
                        <div class="rows">
132
                        <div class="rows">
100
                            <form method="get" id="mana_share_form" action="/cgi-bin/koha/serials/subscription-detail.pl" class="validated" >
133
                            <form method="get" id="mana_share_form" action="/cgi-bin/koha/serials/subscription-detail.pl" class="validated" >
101
                                <fieldset>
134
                                <fieldset>
102
                                    <label for="mana_language">Language of your sharing :</label>
135
                                    <label for="mana_language">Language:</label>
103
                                    <select id="mana_language" name="mana_language">
136
                                    <select id="mana_language" name="mana_language">
104
                                        [% FOREACH languages_loo IN languages_loop %]
137
                                        [% FOREACH languages_loo IN languages_loop %]
105
                                            [% IF ( languages_loo.group_enabled ) %]
138
                                            [% IF ( languages_loo.group_enabled ) %]
Lines 162-168 Link Here
162
                [% IF one_language_enabled==0 %]
195
                [% IF one_language_enabled==0 %]
163
                    <button type="submit" form="mana_share_form" class="btn btn-primary">Share</button>
196
                    <button type="submit" form="mana_share_form" class="btn btn-primary">Share</button>
164
                [% ELSE %]
197
                [% ELSE %]
165
                    <div class="btn-group"><a class="btn btn-primary" onclick="share()">Share</a></div>
198
                    <div class="btn-group" id="mana-subscription-share"><a class="btn btn-primary">Share</a></div>
166
                [% END %]
199
                [% END %]
167
            </div>
200
            </div>
168
        </div>
201
        </div>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/admin-home.tt (-1 / +6 lines)
Lines 13-19 Link Here
13
<div class="main container-fluid">
13
<div class="main container-fluid">
14
    <div class="row">
14
    <div class="row">
15
        <div class="col-md-10 col-md-offset-1 col-lg-8 col-lg-offset-2">
15
        <div class="col-md-10 col-md-offset-1 col-lg-8 col-lg-offset-2">
16
16
            [% IF ( Koha.Preference('Mana') == 2) %]
17
                <fieldset>
18
                    <p><center> You haven't decided if you want to activate Mana Knowlede Base, please let us know by clicking<center></p>
19
                    <a href=/cgi-bin/koha/admin/preferences.pl?tab=&op=search&searchfield=request+to+mana+webservice><center>Here</center></a>
20
                </fieldset>
21
           [% END %]
17
        <h1>Koha administration</h1>
22
        <h1>Koha administration</h1>
18
        <div class="row">
23
        <div class="row">
19
            <div class="col-md-6 sysprefs">
24
            <div class="col-md-6 sysprefs">
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences.tt (+1 lines)
Lines 197-202 Link Here
197
    [% Asset.js("lib/jquery/plugins/humanmsg.js") | $raw %]
197
    [% Asset.js("lib/jquery/plugins/humanmsg.js") | $raw %]
198
    [% Asset.js("js/ajax.js") | $raw %]
198
    [% Asset.js("js/ajax.js") | $raw %]
199
    [% Asset.js("js/pages/preferences.js") | $raw %]
199
    [% Asset.js("js/pages/preferences.js") | $raw %]
200
    [% Asset.js("lib/jquery/activatemana.js") | $raw %]
200
    [%# Add WYSIWYG editor for htmlarea system preferences %]
201
    [%# Add WYSIWYG editor for htmlarea system preferences %]
201
    [% INCLUDE 'wysiwyg-systempreferences.inc' %]
202
    [% INCLUDE 'wysiwyg-systempreferences.inc' %]
202
[% END %]
203
[% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/web_services.pref (-3 / +14 lines)
Lines 63-71 Web services: Link Here
63
        -
63
        -
64
            - pref: Mana
64
            - pref: Mana
65
              choices:
65
              choices:
66
                  yes: Enable
66
                  0: Disable
67
                  no: Disable
67
                  1: Enable
68
            - request to Mana Webservice. Mana centralize commun information between other Koha to facilitate the creation of new subscriptions, vendors, report queries etc... You can search, share, import and comment the content of Mana.
68
                  2: No, let me think about it
69
            - request to Mana Webservice. Mana centralize commun information between other Koha to facilitate the creation of new subscriptions, vendors, report queries etc... You can search, share, import and comment the content of Mana. The informations shared with Mana KB are shared under the CC-0 license. More infos about CC-0 license on https://creativecommons.org/choose/zero/
70
        -
71
             - "Security token used to authenticate on mana:"
72
             - pref: ManaToken
73
               class: Text
74
             - <br> You need a security token to authenticate on Mana. If this sytem preference is empty, please fill in the following form, you will receive an email to confirm and activate your token. <br> <form> First name <input name="firstname" type="text" id="firstname"> <br> Last name <input name="lastname" type=text id=lastname> <br> Email address <input name="email" type=text id=email><br> <input type=submit id=activatemana value="Send"></form>
75
        -
76
            - 'Fields automatically shared with mana'
77
            - pref: AutoShareWithMana
78
              multiple:
79
                subscription: Subscriptions
69
    Reporting:
80
    Reporting:
70
        -
81
        -
71
            - Only return
82
            - Only return
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/mana/mana-report-search-result.tt (+1 lines)
Line 0 Link Here
1
[% INCLUDE 'mana/mana-report-search-result.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/mana/mana-subscription-search-result.tt (+1 lines)
Line 0 Link Here
1
[% INCLUDE 'mana/mana-subscription-search-result.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt (-6 / +164 lines)
Lines 135-140 canned reports and writing custom SQL reports.</p> Link Here
135
    </div>
135
    </div>
136
[% END %]
136
[% END %]
137
137
138
[% IF report_converted %]
139
    <div class="dialog message">
140
        The report "[% report_converted %]" has been converted.
141
    </div>
142
[% END %]
143
144
138
[% IF ( saved1 ) %]
145
[% IF ( saved1 ) %]
139
[% IF ( savedreports ) %]<h1>Saved reports</h1>
146
[% IF ( savedreports ) %]<h1>Saved reports</h1>
140
147
Lines 169-174 canned reports and writing custom SQL reports.</p> Link Here
169
                <option value="">All</option>
176
                <option value="">All</option>
170
            </select>
177
            </select>
171
        </div>
178
        </div>
179
<div style="display:inline-block">
180
    [% IF manamsg %]
181
     <div id="mana_search" class="dialog message">
182
        <p> [% manamsg %] </p>
183
    </div>
184
    [% END %]
185
186
</script>
187
172
<form action="/cgi-bin/koha/reports/guided_reports.pl" id="reports_form" method="post">
188
<form action="/cgi-bin/koha/reports/guided_reports.pl" id="reports_form" method="post">
173
<input type="hidden" name="phase" value="Delete Multiple" />
189
<input type="hidden" name="phase" value="Delete Multiple" />
174
        <table id="table_reports">
190
        <table id="table_reports">
Lines 204-226 canned reports and writing custom SQL reports.</p> Link Here
204
            <tbody>
220
            <tbody>
205
                [% FOREACH savedreport IN savedreports %]
221
                [% FOREACH savedreport IN savedreports %]
206
                    [% UNLESS ( loop.odd ) %]<tr class="odd">[% ELSE %]<tr>[% END %]
222
                    [% UNLESS ( loop.odd ) %]<tr class="odd">[% ELSE %]<tr>[% END %]
207
                        <td>
223
                        <td class="report_checkbox">
208
                            [% IF ( CAN_user_reports_delete_reports ) %] <!-- not break CSS -->
224
                            [% IF ( CAN_user_reports_delete_reports ) %] <!-- not break CSS -->
209
                                <input type="checkbox" name="ids" value="[% savedreport.id | html %]" />
225
                                <input type="checkbox" name="ids" value="[% savedreport.id | html %]" />
210
                            [% END %]
226
                            [% END %]
227
                        <input hidden class="report_sql" value="[% savedreport.savedsql |html %]">
211
                        </td>
228
                        </td>
212
                        <td><label for="ids">[% savedreport.id | html %]</label></td>
229
                        <td class="report_id"><label for="ids">[% savedreport.id | html %]</label></td>
213
                        <td>
230
                        <td class="report_name">
214
                            [% IF ( savedreport.report_name ) %]
231
                            [% IF ( savedreport.report_name ) %]
215
                                [% savedreport.report_name | html %]
232
                                [% savedreport.report_name | html %]
216
                            [% ELSE %]
233
                            [% ELSE %]
217
                                [ no name ]
234
                                [ no name ]
218
                            [% END %]
235
                            [% END %]
219
                        </td>
236
                        </td>
220
                        <td>[% savedreport.type | html %]</td>
237
                        <td class="report_type">[% savedreport.type | html %]</td>
221
                        <td>[% savedreport.groupname | html %]</td>
238
                        <td class="report_group">[% savedreport.groupname | html %]</td>
222
                        <td>[% savedreport.subgroupname | html %]</td>
239
                        <td>[% savedreport.subgroupname | html %]</td>
223
                        <td>[% savedreport.notes | html %]</td>
240
                        <td class="report_notes">[% savedreport.notes | html %]</td>
224
                        <td>[% savedreport.borrowersurname | html %][% IF ( savedreport.borrowerfirstname ) %], [% savedreport.borrowerfirstname | html %][% END %] ([% savedreport.borrowernumber | html %])</td>
241
                        <td>[% savedreport.borrowersurname | html %][% IF ( savedreport.borrowerfirstname ) %], [% savedreport.borrowerfirstname | html %][% END %] ([% savedreport.borrowernumber | html %])</td>
225
                        <td><span title="[% savedreport.date_created | html %]">[% savedreport.date_created | $KohaDates %]</span></td>
242
                        <td><span title="[% savedreport.date_created | html %]">[% savedreport.date_created | $KohaDates %]</span></td>
226
                        <td><span title="[% savedreport.last_modified | html %]">[% savedreport.last_modified | $KohaDates  with_hours => 1 %]</span></td>
243
                        <td><span title="[% savedreport.last_modified | html %]">[% savedreport.last_modified | $KohaDates  with_hours => 1 %]</span></td>
Lines 267-272 canned reports and writing custom SQL reports.</p> Link Here
267
                                            <li><a href="/cgi-bin/koha/reports/guided_reports.pl?reports=[% savedreport.id | uri %]&amp;phase=Edit%20SQL"><i class="fa fa-pencil"></i> Edit</a></li>
284
                                            <li><a href="/cgi-bin/koha/reports/guided_reports.pl?reports=[% savedreport.id | uri %]&amp;phase=Edit%20SQL"><i class="fa fa-pencil"></i> Edit</a></li>
268
                                            <li><a title="Duplicate this saved report" href="/cgi-bin/koha/reports/guided_reports.pl?phase=Create report from SQL&amp;sql=[% savedreport.savedsql |uri %]&amp;reportname=[% savedreport.report_name |uri %]&amp;notes=[% savedreport.notes |uri %]"><i class="fa fa-copy"></i> Duplicate</a></li>
285
                                            <li><a title="Duplicate this saved report" href="/cgi-bin/koha/reports/guided_reports.pl?phase=Create report from SQL&amp;sql=[% savedreport.savedsql |uri %]&amp;reportname=[% savedreport.report_name |uri %]&amp;notes=[% savedreport.notes |uri %]"><i class="fa fa-copy"></i> Duplicate</a></li>
269
                                        [% END %]
286
                                        [% END %]
287
                                        [% IF (Koha.Preference('Mana') == 1) %]
288
                                            <li><a class="ShareButton" data-toggle="modal" href="#mana_share_report" title="Share your report with Mana Knowledge Base"><i class="fa fa-share-alt"></i> Share</a></li>
289
                                        [% END %]
270
                                        <li><a href="/cgi-bin/koha/tools/scheduler.pl?id=[% savedreport.id | uri %]"><i class="fa fa-clock-o"></i> Schedule</a></li>
290
                                        <li><a href="/cgi-bin/koha/tools/scheduler.pl?id=[% savedreport.id | uri %]"><i class="fa fa-clock-o"></i> Schedule</a></li>
271
                                        [% IF ( CAN_user_reports_delete_reports ) %]
291
                                        [% IF ( CAN_user_reports_delete_reports ) %]
272
                                            <li><a class="confirmdelete" title="Delete this saved report" href="/cgi-bin/koha/reports/guided_reports.pl?reports=[% savedreport.id | html %]&amp;phase=Delete%20Saved"><i class="fa fa-trash"></i> Delete</a></li>
292
                                            <li><a class="confirmdelete" title="Delete this saved report" href="/cgi-bin/koha/reports/guided_reports.pl?reports=[% savedreport.id | html %]&amp;phase=Delete%20Saved"><i class="fa fa-trash"></i> Delete</a></li>
Lines 279-284 canned reports and writing custom SQL reports.</p> Link Here
279
                [% END %]
299
                [% END %]
280
            </tbody>
300
            </tbody>
281
        </table>
301
        </table>
302
</div>
282
        [% IF ( CAN_user_reports_delete_reports ) %]
303
        [% IF ( CAN_user_reports_delete_reports ) %]
283
        <fieldset class="action">
304
        <fieldset class="action">
284
            <input type="submit" value="Delete selected" />
305
            <input type="submit" value="Delete selected" />
Lines 319-324 canned reports and writing custom SQL reports.</p> Link Here
319
[% END %]
340
[% END %]
320
[% END %]
341
[% END %]
321
342
343
<div id="mana_share_report" class="modal fade" tabindex="-1" role="dialog" arialabelledby="mana_share_modal_label" style="display: none;">
344
    <div class="modal-dialog">
345
        <div class="modal-content">
346
            <div class="modal-header">
347
                <h3 id="mana_share_modal_label">Share with Mana</h3>
348
            </div>
349
            <div class="modal-body">
350
                [% IF (mana_id) %]
351
                    <div class="alert">
352
                        <p>Your subscription is already linked with a Mana subscription model. Share it if you have made modifications, otherwise it will do nothing.</p>
353
                    </div>
354
                [% END %]
355
                <div id="note-error" class="alert alert-danger" role="alert">
356
                    Please enter a report name and descriptive note before sharing (minimum 20 characters)
357
                </div>
358
                [% IF ( languages_loop ) %]
359
                    [% UNLESS ( one_language_enabled ) %]
360
                        <div class="shared_infos rows">
361
                                <li> <span class="label">Id: </span><div id="shared_id"></div>
362
                                </li>
363
                                <li> <span class="label">Name: </span><div id="shared_name"></div>
364
                                </li>
365
                                <li> <span class="label">SQL: </span><div id="shared_sql"></div>
366
                                </li>
367
                                <li> <span class="label">Group: </span><div id="shared_group"></div>
368
                                </li>
369
                                <li> <span class="label">Type: </span><div id="shared_type"></div>
370
                                </li>
371
                                <li> <span class="label">Notes: </span><div id="shared_notes"></div>
372
                                </li>
373
374
                        </div>
375
                        <div class="rows">
376
                            <form method="post" id="mana_share_form" action="/cgi-bin/koha/reports/guided_reports.pl?phase=Share" class="validated" >
377
                                <input type="hidden" name="phase" value="Share">
378
379
                                <fieldset class="shared_infos">
380
                                    <label for="mana_language">Language:</label>
381
                                    <select id="mana_language" name="mana_language">
382
                                        [% FOREACH languages_loo IN languages_loop %]
383
                                            [% IF ( languages_loo.group_enabled ) %]
384
                                                [% IF ( languages_loo.plural ) %]
385
                                                    [% FOREACH sublanguages_loo IN languages_loo.sublanguages_loop %]
386
                                                        [% IF ( sublanguages_loo.enabled ) %]
387
                                                            [% IF ( sublanguages_loo.sublanguage_current ) %]
388
                                                                <option value="[% languages_loo.rfc4646_subtag %]" selected>
389
                                                                    [% sublanguages_loo.native_description %]
390
                                                                    [% sublanguages_loo.script_description %]
391
                                                                    [% sublanguages_loo.region_description %]
392
393
                                                                    [% sublanguages_loo.variant_description %]
394
                                                                    ([% sublanguages_loo.rfc4646_subtag %])
395
                                                                </option>
396
                                                            [% ELSE %]
397
                                                                <option value="[% languages_loo.rfc4646_subtag %]">
398
                                                                    [% sublanguages_loo.native_description %]
399
                                                                    [% sublanguages_loo.script_description %]
400
                                                                    [% sublanguages_loo.region_description %]
401
                                                                    [% sublanguages_loo.variant_description %]
402
                                                                    ([% sublanguages_loo.rfc4646_subtag %])
403
                                                                </option>
404
                                                            [% END %]
405
                                                        [% END %]
406
                                                    [% END %]
407
                                                [% ELSE %]
408
                                                    [% IF ( languages_loo.group_enabled ) %]
409
                                                        [% IF ( languages_loo.current ) %]
410
                                                            <option value="[% languages_loo.rfc4646_subtag %]" selected>
411
                                                                [% IF ( languages_loo.native_description ) %]
412
                                                                    [% languages_loo.native_description %]
413
                                                                [% ELSE %]
414
                                                                    [% languages_loo.rfc4646_subtag %]
415
                                                                [% END %]
416
                                                            </option>
417
                                                        [% ELSE %]
418
                                                            <option value="[% languages_loo.rfc4646_subtag %]">
419
                                                                [% IF ( languages_loo.native_description ) %]
420
                                                                    [% languages_loo.native_description %]
421
                                                                [% ELSE %]
422
                                                                    [% languages_loo.rfc4646_subtag %]
423
                                                                [% END %]
424
                                                            </option>
425
                                                        [% END %]
426
                                                    [% END %]
427
                                                [% END %]
428
                                            [% END %]
429
                                        [% END %]
430
                                    </select>
431
                                    <input type="hidden" id="reportid" name="reportid" value="[% savedreport.id %]"/>
432
                                </fieldset>
433
                            </form>
434
                        </div>
435
                    [% END %]
436
                [% END %]
437
            </div>
438
            <div class="modal-footer">
439
                <button class="btn" id="ManaCloseButton" data-dismiss="modal" aria-hidden="true">Close</button>
440
                [% IF one_language_enabled==0 %]
441
                    <button id="ManaShareButton" type="submit" form="mana_share_form" class="btn btn-primary shared_infos">Share</button>
442
                [% ELSE %]
443
                    <div id="ManaShareButton" class="btn-group"><a class="btn btn-primary shared_infos">Share</a></div>
444
                [% END %]
445
            </div>
446
        </div>
447
    </div>
448
</div>
449
322
450
323
[% IF ( build1 ) %]
451
[% IF ( build1 ) %]
324
[% IF ( cache_error) %]
452
[% IF ( cache_error) %]
Lines 944-949 canned reports and writing custom SQL reports.</p> Link Here
944
    [% Asset.js("lib/d3c3/d3.min.js") | $raw %]
1072
    [% Asset.js("lib/d3c3/d3.min.js") | $raw %]
945
    [% Asset.js("lib/d3c3/c3.min.js") | $raw %]
1073
    [% Asset.js("lib/d3c3/c3.min.js") | $raw %]
946
    [% INCLUDE 'calendar.inc' %]
1074
    [% INCLUDE 'calendar.inc' %]
1075
    [% INCLUDE 'mana.inc' %]
947
    [% IF ( saved1 ) %]
1076
    [% IF ( saved1 ) %]
948
        [% INCLUDE 'datatables.inc' %]
1077
        [% INCLUDE 'datatables.inc' %]
949
        [% INCLUDE 'columns_settings.inc' %]
1078
        [% INCLUDE 'columns_settings.inc' %]
Lines 1151-1156 canned reports and writing custom SQL reports.</p> Link Here
1151
                window.history.back();
1280
                window.history.back();
1152
            });
1281
            });
1153
1282
1283
            $(".mana_search_button").on("click",function(){
1284
                mana_search($("#mana_search_field").val());
1285
            });
1286
1287
            $(".ShareButton").on("click", function(){
1288
                $("#note-error").hide();
1289
                if($(this).closest("tr").find(".report_notes").text().length < 20 || $(this).closest("tr").find(".report_name").text().length < 20){
1290
                    $(".shared_infos").hide();
1291
                    $("#note-error").show();
1292
                }
1293
                else{
1294
                    $("#shared_id").html($(this).closest("tr").find(".report_id").text());
1295
                    $("#shared_name").html($(this).closest("tr").find(".report_name").text());
1296
                    $("#shared_sql").html($(this).closest("tr").find(".report_sql").val());
1297
                    $("#shared_type").html($(this).closest("tr").find(".report_type").text());
1298
                    $("#shared_group").html($(this).closest("tr").find(".report_group").text());
1299
                    $("#shared_notes").html($(this).closest("tr").find(".report_notes").text());
1300
                }
1301
            });
1302
1303
            $("#ManaCloseButton").on("click", function() {
1304
                $(".shared_infos").show();
1305
            });
1306
1154
            $("#addColumn").on("click",function(){
1307
            $("#addColumn").on("click",function(){
1155
                addColumn();
1308
                addColumn();
1156
            });
1309
            });
Lines 1341-1347 canned reports and writing custom SQL reports.</p> Link Here
1341
            $(".delete").on("click",function(){
1494
            $(".delete").on("click",function(){
1342
                return confirmDelete(MSG_CONFIRM_DELETE);
1495
                return confirmDelete(MSG_CONFIRM_DELETE);
1343
            });
1496
            });
1497
1498
            $('div#ManaShareButton').click(function() {
1499
                window.location="/cgi-bin/koha/reports/guided_reports.pl?phase=Share";
1500
            });
1344
        });
1501
        });
1502
1345
        function addColumn() {
1503
        function addColumn() {
1346
            $("#availableColumns option:selected").clone().appendTo("#selectedColumns").attr("selected", "selected");
1504
            $("#availableColumns option:selected").clone().appendTo("#selectedColumns").attr("selected", "selected");
1347
        }
1505
        }
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/mana-subscription-search-result.tt (-1 lines)
Line 1 Link Here
1
[% INCLUDE 'mana-subscription-search-result.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-search.tt (-1 / +2 lines)
Lines 297-303 Link Here
297
            </ul>
297
            </ul>
298
            [% IF mana %]
298
            [% IF mana %]
299
                <div id="mana">
299
                <div id="mana">
300
                    [% INCLUDE 'mana-subscription-search-result.inc' %]
300
                    [% INCLUDE 'mana/mana-subscription-search-result.inc' %]
301
                </div>
301
                </div>
302
            [% ELSE %]
302
            [% ELSE %]
303
            <div id="opened">
303
            <div id="opened">
Lines 421-426 Link Here
421
[% MACRO jsinclude BLOCK %]
421
[% MACRO jsinclude BLOCK %]
422
    [% INCLUDE 'calendar.inc' %]
422
    [% INCLUDE 'calendar.inc' %]
423
    [% INCLUDE 'datatables.inc' %]
423
    [% INCLUDE 'datatables.inc' %]
424
    [% INCLUDE 'mana.inc' %]
424
    <script>
425
    <script>
425
        var subscriptionid = "[% subscriptionid | html %]";
426
        var subscriptionid = "[% subscriptionid | html %]";
426
        var MSG_CLOSE_SUBSCRIPTION = _("Are you sure you want to close this subscription?");
427
        var MSG_CLOSE_SUBSCRIPTION = _("Are you sure you want to close this subscription?");
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt (-10 / +15 lines)
Lines 10-16 Link Here
10
<style type="text/css">
10
<style type="text/css">
11
fieldset.rows li.radio { width: 100%; } /* override staff-global.css */
11
fieldset.rows li.radio { width: 100%; } /* override staff-global.css */
12
.yui-u li p label.widelabel {
12
.yui-u li p label.widelabel {
13
    width: 300px;  /* not enough for IE7 apparently */
13
width: 300px;  /* not enough for IE7 apparently */
14
}
14
}
15
</style>
15
</style>
16
</head>
16
</head>
Lines 214-221 fieldset.rows li.radio { width: 100%; } /* override staff-global.css */ Link Here
214
214
215
                <div id="page_2">
215
                <div id="page_2">
216
                    <div class="col-md-6">
216
                    <div class="col-md-6">
217
                        <div id="mana_search" class="dialog message">
217
                [% IF ( Koha.Preference('Mana') == 2) %]
218
                            <p>Frequency and Numbering pattern have been already proposed for this subscription on Mana. To show results, click <a style="cursor:pointer" data-toggle="modal" data-target="#mana_search_result">Here</a></p>
218
                    <fieldset>
219
                        <p><center>You haven't activated the Mana Knowledge Base, click
220
                        <a href=/cgi-bin/koha/admin/preferences.pl?tab=&op=search&searchfield=request+to+mana+webservice>here</a>
221
                         to configure.</center></p>
222
                    </fieldset>
223
                [% END %]
224
225
                        <div hidden id="mana_search" class="dialog message">
219
                        </div>
226
                        </div>
220
                        <div id="subscription_form_planning">
227
                        <div id="subscription_form_planning">
221
                            <fieldset class="rows">
228
                            <fieldset class="rows">
Lines 490-496 fieldset.rows li.radio { width: 100%; } /* override staff-global.css */ Link Here
490
                            <fieldset class="action">
497
                            <fieldset class="action">
491
                                <input type="button" id="subscription_add_previous" value="&lt;&lt; Previous" style="float:left;"/>
498
                                <input type="button" id="subscription_add_previous" value="&lt;&lt; Previous" style="float:left;"/>
492
                                <input id="testpatternbutton" type="button" value="Test prediction pattern" />
499
                                <input id="testpatternbutton" type="button" value="Test prediction pattern" />
493
                                <input type="submit" onclick="removeDisabledAttr()" value="Save subscription" style="float:right;" accesskey="w"/>
500
                                <input id="save-subscription" type="submit" value="Save subscription" style="float:right;" accesskey="w"/>
494
                            </fieldset>
501
                            </fieldset>
495
                        </div>
502
                        </div>
496
                    </div>
503
                    </div>
Lines 500-522 fieldset.rows li.radio { width: 100%; } /* override staff-global.css */ Link Here
500
                </div>
507
                </div>
501
            </form>
508
            </form>
502
        </div>
509
        </div>
503
        <div id="mana_search_result" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="mana_search_result_label" style="width: 90%; left:5%; margin-left: auto; display: none;">
510
        <div id="mana_search_result" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="mana_search_result_label" style="width: 100%; left:0%; margin-left: auto; display: none;">
504
            <div class="modal-dialog modal-lg">
511
            <div class="modal-dialog modal-lg">
505
                <div class="modal-content">
512
                <div class="modal-content">
506
                    <div class="modal-header">
513
                    <div class="modal-header">
514
                        <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
507
                        <h3 id="mana_search_result_label"></h3>
515
                        <h3 id="mana_search_result_label"></h3>
508
                    </div>
516
                    </div>
509
                    <div class="modal-body">
517
                    <div class="modal-body">
510
                    </div>
511
                    <div class="modal-footer">
512
                        <button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
513
                    </div>
514
                </div>
515
            </div>
518
            </div>
516
        </div>
519
        </div>
517
520
518
[% MACRO jsinclude BLOCK %]
521
[% MACRO jsinclude BLOCK %]
519
    [% INCLUDE 'calendar.inc' %]
522
    [% INCLUDE 'calendar.inc' %]
523
    [% INCLUDE 'datatables.inc' %]
520
    <script type="text/javascript">
524
    <script type="text/javascript">
521
        var subscriptionid = "[% subscriptionid | html %]";
525
        var subscriptionid = "[% subscriptionid | html %]";
522
        var irregularity = "[% irregularity | html %]";
526
        var irregularity = "[% irregularity | html %]";
Lines 525-530 fieldset.rows li.radio { width: 100%; } /* override staff-global.css */ Link Here
525
        [% FOREACH field IN dont_export_field_loop %]
529
        [% FOREACH field IN dont_export_field_loop %]
526
            tags.push("[% field.fieldid | html %]");
530
            tags.push("[% field.fieldid | html %]");
527
        [% END %]
531
        [% END %]
532
        var mana_enabled = [% Koha.Preference('Mana') %]
528
        var MSG_LINK_TO_VENDOR = _("If you wish to claim late or missing issues you must link this subscription to a vendor. Click OK to ignore or Cancel to return and enter a vendor");
533
        var MSG_LINK_TO_VENDOR = _("If you wish to claim late or missing issues you must link this subscription to a vendor. Click OK to ignore or Cancel to return and enter a vendor");
529
        var MSG_LINK_BIBLIO = _("You must choose or create a bibliographic record");
534
        var MSG_LINK_BIBLIO = _("You must choose or create a bibliographic record");
530
        var MSG_REQUIRED_SUB_LENGTH = _("You must choose a subscription length or an end date.");
535
        var MSG_REQUIRED_SUB_LENGTH = _("You must choose a subscription length or an end date.");
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tt (-6 / +3 lines)
Lines 29-35 Link Here
29
        <div class="col-sm-10 col-sm-push-2">
29
        <div class="col-sm-10 col-sm-push-2">
30
            <main>
30
            <main>
31
31
32
    [% INCLUDE 'serials-toolbar.inc' mana_id = mana_id %]
32
    [% INCLUDE 'serials-toolbar.inc' %]
33
33
34
    <h1>Subscription for [% bibliotitle | html %] [% IF closed %](closed)[% END %]</h1>
34
    <h1>Subscription for [% bibliotitle | html %] [% IF closed %](closed)[% END %]</h1>
35
    [% IF ( abouttoexpire ) %]
35
    [% IF ( abouttoexpire ) %]
Lines 62-72 Link Here
62
    [% IF mana_code.defined %]
62
    [% IF mana_code.defined %]
63
        <div id="alert-community" class="dialog message">
63
        <div id="alert-community" class="dialog message">
64
            <p>
64
            <p>
65
                [% IF (mana_code == 201) %]
65
                [% mana_code %]
66
                    The export is done, thank you for your contribution.
67
                [% ELSIF (mana_code == 200) %]
68
                    The model already exists on Mana, thank you for your contribution.
69
                [% END %]
70
            </p>
66
            </p>
71
        </div>
67
        </div>
72
    [% END %]
68
    [% END %]
Lines 480-485 Link Here
480
        var MSG_REOPEN_SUBSCRIPTION = _("Are you sure you want to reopen this subscription?");
476
        var MSG_REOPEN_SUBSCRIPTION = _("Are you sure you want to reopen this subscription?");
481
        var CONFIRM_DELETE_SUBSCRIPTION = _("Are you sure you want to delete this subscription?");
477
        var CONFIRM_DELETE_SUBSCRIPTION = _("Are you sure you want to delete this subscription?");
482
    </script>
478
    </script>
479
    [% INCLUDE 'mana.inc' %]
483
    [% Asset.js("js/serials-toolbar.js") | $raw %]
480
    [% Asset.js("js/serials-toolbar.js") | $raw %]
484
    [% INCLUDE 'datatables.inc' %]
481
    [% INCLUDE 'datatables.inc' %]
485
    [% Asset.js("lib/jquery/plugins/treetable/jquery.treetable.js") | $raw %]
482
    [% Asset.js("lib/jquery/plugins/treetable/jquery.treetable.js") | $raw %]
(-)a/koha-tmpl/intranet-tmpl/prog/js/serials-toolbar.js (+3 lines)
Lines 40-43 function popup(subscriptionid) { Link Here
40
        popup( subscriptionid );
40
        popup( subscriptionid );
41
        return false;
41
        return false;
42
    });
42
    });
43
    $("#mana-subscription-share").click(function() {
44
        window.location="subscription-detail.pl?subscriptionid=" + subscriptionid + "&op=share";
45
    });
43
 });
46
 });
(-)a/koha-tmpl/intranet-tmpl/prog/js/subscription-add.js (-15 / +29 lines)
Lines 393-420 function show_page_2() { Link Here
393
}
393
}
394
394
395
function mana_search() {
395
function mana_search() {
396
    $("#mana_search").html("<p>" + _("Mana kb is being asked for your subscription..") + "</p>");
397
    $("#mana_search").show();
398
396
    $.ajax({
399
    $.ajax({
397
        type: "POST",
400
        type: "POST",
398
        url: "/cgi-bin/koha/svc/mana/search",
401
        url: "/cgi-bin/koha/svc/mana/search",
399
        data: {biblionumber : $("#biblionumber").val()},
402
        data: {id: $("#biblionumber").val(), resource: 'subscription', usecomments: 1},
400
        dataType: "html",
403
        dataType: "html",
401
    })
404
    })
402
    .done( function( result ) {
405
    .done( function( result ) {
403
    $("#mana_search_result .modal-body").html(result);
406
        $("#mana_search_result .modal-body").html(result);
404
        $("#mana_search_result_label").text("Results from Mana");
407
        $("#mana_search_result_label").text(_("Results from Mana Knowledge Base"));
405
        $("#mana_results_datatable").dataTable($.extend(true, {}, dataTablesDefaults, {
408
        $("#mana_results_datatable").dataTable($.extend(true, {}, dataTablesDefaults, {
406
            "sPaginationType": "four_button",
409
            "sPaginationType": "four_button",
410
            "order":[[4, "desc"], [5, "desc"]],
411
            "autoWidth": false,
412
            "columnDefs": [
413
                { "width": "35%", "targets": 1 }
414
            ],
407
            "aoColumnDefs": [
415
            "aoColumnDefs": [
408
                { 'bSortable': false, "bSearchable": false, 'aTargets': [ 'NoSort' ] },
416
                { 'bSortable': false, "bSearchable": false, 'aTargets': [ 'NoSort' ] },
409
                { "sType": "title-string", "aTargets" : [ "title-string" ] },
417
                { "sType": "title-string", "aTargets" : [ "title-string" ] },
410
                { 'sType': "anti-the", 'aTargets' : [ 'anti-the'] }
418
                { 'sType': "anti-the", 'aTargets' : [ 'anti-the'] }
411
            ]
419
            ]
412
        }));
420
        }));
413
        if($("td.dataTables_empty").length == 0){
421
        if( $("#mana_results_datatable").length && $("td.dataTables_empty").length == 0){
414
            $("#mana_search").show();
422
            $("#mana_search").html("<p>" + _("Subscription found on Mana Knowledge Base:") + "</p><p> <a style='cursor:pointer' data-toggle='modal' data-target='#mana_search_result'>" + _("Quick fill") + "</a></p>");
415
        }
423
        }
416
    }).fail(function(result){
424
        else if ( $("#mana_results_datatable").length ){
417
    });
425
            $("#mana_search").html("<p>" + _("No subscription found on Mana Knowledge Base :(") + "</p><p>" + _(" Please feel free to share you pattern with all others librarians once you are done") + "</p>");
426
        }
427
        else{
428
            $("#mana_search").html( result );
429
        }
430
        $("#mana_search").show();
431
    })
418
}
432
}
419
433
420
function mana_use(mana_id){
434
function mana_use(mana_id){
Lines 423-429 function mana_use(mana_id){ Link Here
423
    $.ajax( {
437
    $.ajax( {
424
        type: "POST",
438
        type: "POST",
425
        url: "/cgi-bin/koha/svc/mana/use",
439
        url: "/cgi-bin/koha/svc/mana/use",
426
        data: {id : mana_id},
440
        data: {id: mana_id, resource: 'subscription'},
427
        dataType: "json",
441
        dataType: "json",
428
    })
442
    })
429
    .done(function(result){
443
    .done(function(result){
Lines 492-502 function mana_use(mana_id){ Link Here
492
    });
506
    });
493
}
507
}
494
508
495
function removeDisabledAttr() {
496
    $('select:disabled').removeAttr('disabled');
497
}
498
499
$(document).ready(function() {
509
$(document).ready(function() {
510
    mana_search();
500
    $("#displayexample").hide();
511
    $("#displayexample").hide();
501
    $("#mana_search_result").modal("hide");
512
    $("#mana_search_result").modal("hide");
502
    $("#aqbooksellerid").on('keypress', function(e) {
513
    $("#aqbooksellerid").on('keypress', function(e) {
Lines 606-614 $(document).ready(function() { Link Here
606
    });
617
    });
607
    $("#subscription_add_next").on("click",function(){
618
    $("#subscription_add_next").on("click",function(){
608
        if ( Check_page1() ){
619
        if ( Check_page1() ){
609
            [% IF Koha.Preference('Mana') %]
620
            if ( mana_enabled ) {
610
                mana_search();
621
                mana_search();
611
            [% END %]
622
            }
612
            show_page_2();
623
            show_page_2();
613
        }
624
        }
614
    });
625
    });
Lines 636-639 $(document).ready(function() { Link Here
636
        e.preventDefault();
647
        e.preventDefault();
637
        testPredictionPattern();
648
        testPredictionPattern();
638
    });
649
    });
639
});
650
    $('#save-subscription').on("click", function(e){
651
        $('select:disabled').removeAttr('disabled');
652
    });
653
});
(-)a/reports/guided_reports.pl (-1 / +18 lines)
Lines 38-43 use Koha::AuthorisedValues; Link Here
38
use Koha::BiblioFrameworks;
38
use Koha::BiblioFrameworks;
39
use Koha::Libraries;
39
use Koha::Libraries;
40
use Koha::Patron::Categories;
40
use Koha::Patron::Categories;
41
use Koha::SharedContent;
41
42
42
=head1 NAME
43
=head1 NAME
43
44
Lines 145-150 elsif ( $phase eq 'Build new' ) { Link Here
145
        }
146
        }
146
    }
147
    }
147
    $template->param(
148
    $template->param(
149
        'manamsg' => $input->param('manamsg') || '',
148
        'saved1'                => 1,
150
        'saved1'                => 1,
149
        'savedreports'          => $reports,
151
        'savedreports'          => $reports,
150
        'usecache'              => $usecache,
152
        'usecache'              => $usecache,
Lines 180-185 elsif ( $phase eq 'Show SQL'){ Link Here
180
        'notes'      => $report->notes,
182
        'notes'      => $report->notes,
181
        'sql'     => $report->savedsql,
183
        'sql'     => $report->savedsql,
182
        'showsql' => 1,
184
        'showsql' => 1,
185
        'mana_success' => $input->param('mana_success'),
186
        'mana_success' => scalar $input->param('mana_success'),
187
        'mana_id' => $report->{mana_id},
188
        'mana_comments' => $report->{comments}
183
    );
189
    );
184
}
190
}
185
191
Lines 198-203 elsif ( $phase eq 'Edit SQL'){ Link Here
198
        'public' => $report->public,
204
        'public' => $report->public,
199
        'usecache' => $usecache,
205
        'usecache' => $usecache,
200
        'editsql'    => 1,
206
        'editsql'    => 1,
207
        'mana_id' => $report->{mana_id},
208
        'mana_comments' => $report->{comments}
201
    );
209
    );
202
}
210
}
203
211
Lines 547-553 elsif ( $phase eq 'Build report' ) { Link Here
547
555
548
elsif ( $phase eq 'Save' ) {
556
elsif ( $phase eq 'Save' ) {
549
    # Save the report that has just been built
557
    # Save the report that has just been built
550
    my $area           = $input->param('area');
558
    my $area = $input->param('area');
551
    my $sql  = $input->param('sql');
559
    my $sql  = $input->param('sql');
552
    my $type = $input->param('type');
560
    my $type = $input->param('type');
553
    $template->param(
561
    $template->param(
Lines 651-656 elsif ( $phase eq 'Save Report' ) { Link Here
651
                    cache_expiry   => $cache_expiry,
659
                    cache_expiry   => $cache_expiry,
652
                    public         => $public,
660
                    public         => $public,
653
                } );
661
                } );
662
654
                logaction( "REPORTS", "ADD", $id, "$name | $sql" ) if C4::Context->preference("ReportsLog");
663
                logaction( "REPORTS", "ADD", $id, "$name | $sql" ) if C4::Context->preference("ReportsLog");
655
            $template->param(
664
            $template->param(
656
                'save_successful' => 1,
665
                'save_successful' => 1,
Lines 668-673 elsif ( $phase eq 'Save Report' ) { Link Here
668
    }
677
    }
669
}
678
}
670
679
680
elsif ($phase eq 'Share'){
681
    my $result = Koha::SharedContent::send_entity($input->param('mana_language'), $borrowernumber, scalar $input->param('reportid'), 'report');
682
    if ( $result ) {
683
        print $input->redirect("/cgi-bin/koha/reports/guided_reports.pl?phase=Use%20saved&manamsg=".$result->{msg});
684
    }else{
685
        print $input->redirect("/cgi-bin/koha/reports/guided_reports.pl?phase=Use%20saved&manamsg=noanswer");
686
    }
687
}
671
elsif ($phase eq 'Run this report'){
688
elsif ($phase eq 'Run this report'){
672
    # execute a saved report
689
    # execute a saved report
673
    my $limit      = $input->param('limit') || 20;
690
    my $limit      = $input->param('limit') || 20;
(-)a/serials/serials-collection.pl (-1 / +1 lines)
Lines 85-91 if($op eq 'gennext' && @subscriptionid){ Link Here
85
            ) = GetNextSeq($subscription, $pattern, $frequency, $expected->{publisheddate});
85
            ) = GetNextSeq($subscription, $pattern, $frequency, $expected->{publisheddate});
86
86
87
             ## We generate the next publication date
87
             ## We generate the next publication date
88
             my $frequency = C4::Serials::Frequency::GetSubscriptionFrequency($subscription->{periodicity});
88
             $frequency = C4::Serials::Frequency::GetSubscriptionFrequency($subscription->{periodicity});
89
             my $nextpublisheddate = GetNextDate($subscription, $expected->{publisheddate}, $frequency, 1);
89
             my $nextpublisheddate = GetNextDate($subscription, $expected->{publisheddate}, $frequency, 1);
90
             my $planneddate = $date_received_today ? dt_from_string : $nextpublisheddate;
90
             my $planneddate = $date_received_today ? dt_from_string : $nextpublisheddate;
91
             ## Creating the new issue
91
             ## Creating the new issue
(-)a/serials/serials-search.pl (-1 / +4 lines)
Lines 96-109 for my $field ( @$additional_fields ) { Link Here
96
96
97
my $expiration_date_dt = $expiration_date ? dt_from_string( $expiration_date ) : undef;
97
my $expiration_date_dt = $expiration_date ? dt_from_string( $expiration_date ) : undef;
98
my @subscriptions;
98
my @subscriptions;
99
my $mana_statuscode;
99
if ($searched){
100
if ($searched){
100
    if ($mana) {
101
    if ($mana) {
101
        my $result = Koha::SharedContent::manaGetRequest("subscription",{
102
        my $result = Koha::SharedContent::search_entities("subscription",{
102
            title        => $title,
103
            title        => $title,
103
            issn         => $ISSN,
104
            issn         => $ISSN,
104
            ean          => $EAN,
105
            ean          => $EAN,
105
            publisher    => $publisher
106
            publisher    => $publisher
106
        });
107
        });
108
        $mana_statuscode = $result->{code};
107
        @subscriptions = @{ $result->{data} };
109
        @subscriptions = @{ $result->{data} };
108
    }
110
    }
109
    else {
111
    else {
Lines 127-132 if ($searched){ Link Here
127
if ($mana) {
129
if ($mana) {
128
    $template->param(
130
    $template->param(
129
        subscriptions => \@subscriptions,
131
        subscriptions => \@subscriptions,
132
        statuscode    => $mana_statuscode,
130
        total         => scalar @subscriptions,
133
        total         => scalar @subscriptions,
131
        title_filter  => $title,
134
        title_filter  => $title,
132
        ISSN_filter   => $ISSN,
135
        ISSN_filter   => $ISSN,
(-)a/serials/subscription-add.pl (-46 / +23 lines)
Lines 292-326 sub _guess_enddate { Link Here
292
    return $enddate;
292
    return $enddate;
293
}
293
}
294
294
295
sub manage_subscription_numbering_pattern_id {
295
sub redirect_add_subscription {
296
    my $params;
296
    my $periodicity = $query->param('frequency');
297
    if ( $query->param('numbering_pattern') eq 'mana' ) {
297
    if ($periodicity eq 'mana') {
298
        foreach (qw/numberingmethod label1 add1 every1 whenmorethan1 setto1
299
                   numbering1 label2 add2 every2 whenmorethan2 setto2 numbering2
300
                   label3 add3 every3 whenmorethan3 setto3 numbering3/) {
301
            $params->{$_} = $query->param($_) if $query->param($_);
302
        }
303
304
        my $existing = Koha::Subscription::Numberpatterns->search($params)->next();
305
306
        if ($existing) {
307
            return $existing->id;
308
        }
309
310
        $params->{label} = Koha::Subscription::Numberpattern->uniqueLabel($query->param('patternname'));
311
        $params->{description} = $query->param('sndescription');
312
313
314
        my $subscription_np = Koha::Subscription::Numberpattern->new()->set($params)->store();
315
        return $subscription_np->id;
316
    }
317
318
    return $query->param('numbering_pattern');
319
}
320
321
sub manage_subscription_frequencies_id {
322
    my $periodicity;
323
    if ( $query->param('frequency') eq 'mana' ) {
324
        my $subscription_freq = Koha::Subscription::Frequency->new()->set(
298
        my $subscription_freq = Koha::Subscription::Frequency->new()->set(
325
            {
299
            {
326
                description   => $query->param('sfdescription'),
300
                description   => $query->param('sfdescription'),
Lines 331-345 sub manage_subscription_frequencies_id { Link Here
331
        )->store();
305
        )->store();
332
        $periodicity = $subscription_freq->id;
306
        $periodicity = $subscription_freq->id;
333
    }
307
    }
334
    else {
308
    my $numberpattern = Koha::Subscription::Numberpatterns->new_or_existing({ $query->Vars });
335
        $periodicity = $query->param('frequency');
336
    }
337
    return $periodicity;
338
}
339
340
sub redirect_add_subscription {
341
    my $periodicity = manage_subscription_frequencies_id();
342
    my $numberpattern = manage_subscription_numbering_pattern_id();
343
309
344
    my $auser          = $query->param('user');
310
    my $auser          = $query->param('user');
345
    my $branchcode     = $query->param('branchcode');
311
    my $branchcode     = $query->param('branchcode');
Lines 379-388 sub redirect_add_subscription { Link Here
379
    my $mana_id;
345
    my $mana_id;
380
    if ( $query->param('mana_id') ne "" ) {
346
    if ( $query->param('mana_id') ne "" ) {
381
        $mana_id = $query->param('mana_id');
347
        $mana_id = $query->param('mana_id');
382
        Koha::SharedContent::manaNewUserPatchRequest("subscription",$mana_id);
348
        Koha::SharedContent::increment_entity_value("subscription",$mana_id, "nbofusers");
383
    }
384
    else {
385
        $mana_id = undef;
386
    }
349
    }
387
350
388
    my $startdate      = output_pref( { str => scalar $query->param('startdate'),      dateonly => 1, dateformat => 'iso' } );
351
    my $startdate      = output_pref( { str => scalar $query->param('startdate'),      dateonly => 1, dateformat => 'iso' } );
Lines 406-412 sub redirect_add_subscription { Link Here
406
        $staffdisplaycount, $opacdisplaycount, $graceperiod, $location, $enddate,
369
        $staffdisplaycount, $opacdisplaycount, $graceperiod, $location, $enddate,
407
        $skip_serialseq, $itemtype, $previousitemtype, $mana_id
370
        $skip_serialseq, $itemtype, $previousitemtype, $mana_id
408
    );
371
    );
409
372
    if ( (C4::Context->preference('Mana')) and ( grep { $_ eq "subscription" } split(/,/, C4::Context->preference('AutoShareWithMana'))) ){
373
        my $result = Koha::SharedContent::send_entity( $query->param('mana_language') || '', $loggedinuser, $subscriptionid, 'subscription');
374
        $template->param( mana_msg => $result->{msg} );
375
    }
410
    my $additional_fields = Koha::AdditionalField->all( { tablename => 'subscription' } );
376
    my $additional_fields = Koha::AdditionalField->all( { tablename => 'subscription' } );
411
    insert_additional_fields( $additional_fields, $biblionumber, $subscriptionid );
377
    insert_additional_fields( $additional_fields, $biblionumber, $subscriptionid );
412
378
Lines 434-441 sub redirect_mod_subscription { Link Here
434
        ? output_pref( { str => $nextacquidate, dateonly => 1, dateformat => 'iso' } )
400
        ? output_pref( { str => $nextacquidate, dateonly => 1, dateformat => 'iso' } )
435
        : $firstacquidate;
401
        : $firstacquidate;
436
402
437
    my $periodicity = manage_subscription_frequencies_id();
403
    my $periodicity = $query->param('frequency');
438
    my $numberpattern = manage_subscription_numbering_pattern_id();
404
    if ($periodicity eq 'mana') {
405
        my $subscription_freq = Koha::Subscription::Frequency->new()->set(
406
            {
407
                description   => $query->param('sfdescription'),
408
                unit          => $query->param('unit'),
409
                unitsperissue => $query->param('unitsperissue'),
410
                issuesperunit => $query->param('issuesperunit'),
411
            }
412
        )->store();
413
        $periodicity = $subscription_freq->id;
414
    }
415
    my $numberpattern = Koha::Subscription::Numberpatterns->new_or_existing({ $query->Vars });
439
416
440
    my $subtype = $query->param('subtype');
417
    my $subtype = $query->param('subtype');
441
    my $sublength = $query->param('sublength');
418
    my $sublength = $query->param('sublength');
Lines 466-472 sub redirect_mod_subscription { Link Here
466
    my $mana_id;
443
    my $mana_id;
467
    if ( defined( $query->param('mana_id') ) ) {
444
    if ( defined( $query->param('mana_id') ) ) {
468
        $mana_id = $query->param('mana_id');
445
        $mana_id = $query->param('mana_id');
469
        Koha::SharedContent::manaNewUserPatchRequest("subscription",$mana_id);
446
        Koha::SharedContent::increment_entity_value("subscription",$mana_id, "nbofusers");
470
    }
447
    }
471
    else {
448
    else {
472
        $mana_id = undef;
449
        $mana_id = undef;
(-)a/serials/subscription-detail.pl (-43 / +5 lines)
Lines 33-43 use Koha::Acquisition::Bookseller; Link Here
33
use Date::Calc qw/Today Day_of_Year Week_of_Year Add_Delta_Days/;
33
use Date::Calc qw/Today Day_of_Year Week_of_Year Add_Delta_Days/;
34
use Carp;
34
use Carp;
35
35
36
use LWP::UserAgent;
37
use Koha::SharedContent;
36
use Koha::SharedContent;
38
use Koha::Patrons;
39
use Koha::Subscriptions;
40
use Koha::Libraries;
41
37
42
my $query = new CGI;
38
my $query = new CGI;
43
my $op = $query->param('op') || q{};
39
my $op = $query->param('op') || q{};
Lines 66-72 my ($template, $loggedinuser, $cookie) Link Here
66
                debug => 1,
62
                debug => 1,
67
                });
63
                });
68
64
69
70
my $subs = GetSubscription($subscriptionid);
65
my $subs = GetSubscription($subscriptionid);
71
66
72
output_and_exit( $query, $cookie, $template, 'unknown_subscription')
67
output_and_exit( $query, $cookie, $template, 'unknown_subscription')
Lines 104-147 if ($op eq 'del') { Link Here
104
    }
99
    }
105
}
100
}
106
elsif ( $op and $op eq "share" ) {
101
elsif ( $op and $op eq "share" ) {
107
    my $mana_language;
102
    my $mana_language = $query->param('mana_language');
108
    if ( $query->param('mana_language') ) {
103
    my $result = Koha::SharedContent::send_entity($mana_language, $loggedinuser, $subscriptionid, 'subscription');
109
        $mana_language = $query->param('mana_language');
104
    $template->param( mana_code => $result->{msg} );
110
    }
105
    $subs->{mana_id} = $result->{id};
111
    else {
112
        $mana_language = C4::Context->preference('language');
113
    }
114
115
    my $mana_email;
116
    if ( $loggedinuser ne 0 ) {
117
        my $borrower = Koha::Patrons->find($loggedinuser);
118
        $mana_email = $borrower->email
119
          if ( ( not defined($mana_email) ) or ( $mana_email eq '' ) );
120
        $mana_email = $borrower->emailpro
121
          if ( ( not defined($mana_email) ) or ( $mana_email eq '' ) );
122
        $mana_email =
123
          Koha::Libraries->find( C4::Context->userenv->{'branch'} )->branchemail
124
          if ( ( not defined($mana_email) ) or ( $mana_email eq '' ) );
125
    }
126
    $mana_email = C4::Context->preference('KohaAdminEmailAddress')
127
      if ( ( not defined($mana_email) ) or ( $mana_email eq '' ) );
128
    my %versions = C4::Context::get_versions();
129
130
    my $mana_info = {
131
        language    => $mana_language,
132
        kohaversion => $versions{'kohaVersion'},
133
        exportemail => $mana_email
134
    };
135
    my $sub_mana_info = Koha::Subscription::get_sharable_info($subscriptionid);
136
    $sub_mana_info = { %$sub_mana_info, %$mana_info };
137
    my $result = Koha::SharedContent::manaPostRequest( "subscription",
138
        $sub_mana_info );
139
    if ( $result->{code} eq "200" and $result->{code} eq "201" ) {
140
        my $subscription = Koha::Subscriptions->find($subscriptionid);
141
        $subscription->set( { mana_id => $result->{id} } )->store;
142
        $subs->{mana_id} = $result->{id};
143
    }
144
    $template->param( mana_code => $result->{code} );
145
}
106
}
146
107
147
my $hasRouting = check_routing($subscriptionid);
108
my $hasRouting = check_routing($subscriptionid);
Lines 210-215 $template->param( Link Here
210
    default_bib_view => $default_bib_view,
171
    default_bib_view => $default_bib_view,
211
    orders_grouped => $orders_grouped,
172
    orders_grouped => $orders_grouped,
212
    (uc(C4::Context->preference("marcflavour"))) => 1,
173
    (uc(C4::Context->preference("marcflavour"))) => 1,
174
    mana_comments => $subs->{comments},
213
);
175
);
214
176
215
output_html_with_http_headers $query, $cookie, $template->output;
177
output_html_with_http_headers $query, $cookie, $template->output;
(-)a/svc/mana/increment (+48 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Copyright 2017 BibLibre Baptiste Wojtkowski
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it
8
# under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
11
#
12
# Koha is distributed in the hope that it will be useful, but
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
#
20
21
use Modern::Perl;
22
23
use Koha::SharedContent;
24
use C4::Auth qw(check_cookie_auth);
25
26
use CGI;
27
use JSON;
28
29
30
my $input = new CGI;
31
binmode STDOUT, ":encoding(UTF-8)";
32
print $input->header( -type => 'text/plain', -charset => 'UTF-8' );
33
34
my ( $auth_status, $sessionID ) =
35
  check_cookie_auth( $input->cookie('CGISESSID'),
36
    { serials => 'create_subscription' } );
37
38
if ( $auth_status ne "ok" ) {
39
    exit 0;
40
}
41
my $result = Koha::SharedContent::increment_entity_value(
42
    scalar $input->param('resource'),
43
    scalar $input->param('id'),
44
    scalar $input->param('field'),
45
    scalar $input->param('step')
46
);
47
48
return $result;
(-)a/svc/mana/search (-8 / +29 lines)
Lines 18-25 Link Here
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
#
19
#
20
20
21
use strict;
21
use Modern::Perl;
22
use warnings;
23
22
24
use Koha::SharedContent;
23
use Koha::SharedContent;
25
use Koha::Subscription;
24
use Koha::Subscription;
Lines 39-47 if ( $auth_status ne "ok" ) { Link Here
39
    exit 0;
38
    exit 0;
40
}
39
}
41
40
41
my $templatename;
42
if ($input->param( "resource" ) eq 'report') {
43
    $templatename = "mana/mana-report-search-result.tt";
44
} else {
45
    $templatename = "mana/mana-subscription-search-result.tt";
46
}
47
42
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
48
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
43
    {
49
    {
44
        template_name   => "serials/mana-subscription-search-result.tt",
50
        template_name   => $templatename,
45
        query           => $input,
51
        query           => $input,
46
        type            => "intranet",
52
        type            => "intranet",
47
        authnotrequired => 0,
53
        authnotrequired => 0,
Lines 52-62 my ( $template, $loggedinuser, $cookie ) = get_template_and_user( Link Here
52
    }
58
    }
53
);
59
);
54
60
55
my $biblionumber = $input->param('biblionumber');
61
my ($identifier, $sub_mana_info);
62
$identifier = $input->param('id');
63
$template->param( lowWarned => 5, warned => 10, highWarned => 20);
64
my $package = "Koha::".ucfirst($input->param( 'resource' ));
65
$sub_mana_info = $package->get_search_info($identifier);
66
67
$sub_mana_info->{ usecomments } = $input->param('usecomments');
68
my $resourcename = $input->param('resource');
69
my $result = Koha::SharedContent::search_entities( $resourcename, $sub_mana_info);
70
my $nbofcomment;
71
foreach my $resource (@{ $result->{data} }){
72
    $nbofcomment = 0;
73
    foreach my $comment (@{ $resource->{comments} }){
74
        $nbofcomment += $comment->{nb};
75
    }
76
    $resource->{nbofcomment} = $nbofcomment;
77
}
56
78
57
my $sub_mana_info = Koha::Subscription::get_search_info($biblionumber);
79
$template->param( $input->param('resource')."s" => $result->{data} );
58
my $result =
80
$template->param( statuscode => $result->{code} );
59
  Koha::SharedContent::manaGetRequest( "subscription", $sub_mana_info );
81
$template->param( msg => $result->{msg} );
60
$template->param( subscriptions => $result->{data} );
61
82
62
output_with_http_headers $input, $cookie, $template->output, 'json';
83
output_with_http_headers $input, $cookie, $template->output, 'json';
(-)a/svc/mana/share (+69 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Copyright 2017 BibLibre Baptiste Wojtkowski
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it
8
# under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
11
#
12
# Koha is distributed in the hope that it will be useful, but
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
#
20
21
use Modern::Perl;
22
23
use Koha::SharedContent;
24
use C4::Auth qw(check_cookie_auth);
25
26
use CGI;
27
use JSON;
28
29
30
my $input = new CGI;
31
binmode STDOUT, ":encoding(UTF-8)";
32
print $input->header( -type => 'text/plain', -charset => 'UTF-8' );
33
34
my ( $auth_status, $sessionID ) =
35
  check_cookie_auth( $input->cookie('CGISESSID'),
36
    { serials => 'create_subscription' } );
37
38
if ( $auth_status ne "ok" ) {
39
    exit 0;
40
}
41
42
43
my $content;
44
$content->{resource_id} = $input->param("resource_id");
45
$content->{resource_type} = $input->param("resource");
46
$content->{message} = $input->param("message");
47
Koha::SharedContent::send_entity('', undef, undef, 'resource_comment', $content);
48
my $package = "Koha::".ucfirst($input->param('resource'));
49
my $resource;
50
my $result;
51
eval{
52
    $result = Koha::SharedContent::get_entity_by_id(
53
        scalar $input->param('resource'),
54
        scalar $input->param('id')
55
    );
56
};
57
if ( $@ or $result->{code} == 500 ){
58
    $resource->{errmsg} =  "Error: mana access got broken, please try again later\n\n ( error: $@ )";
59
}
60
else{
61
    if ( $input->param( 'saveinbase' )) {
62
        $resource = { id => $package->new_from_mana($result->{data})->id };
63
    }
64
    else{
65
        $resource = $result->{data};
66
    }
67
}
68
69
print(to_json($resource));
(-)a/svc/mana/token (+55 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Copyright 2016 BibLibre Baptiste Wojtkowski
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it
8
# under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
11
#
12
# Koha is distributed in the hope that it will be useful, but
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
#
20
21
22
use Modern::Perl;
23
24
use Koha::SharedContent;
25
use C4::Auth qw(check_cookie_auth);
26
27
use CGI;
28
use JSON;
29
30
my $input = new CGI;
31
binmode STDOUT, ":encoding(UTF-8)";
32
print $input->header( -type => 'text/plain', -charset => 'UTF-8' );
33
34
my ( $auth_status, $sessionID ) =
35
  check_cookie_auth( $input->cookie('CGISESSID'),
36
    { serials => 'create_subscription' } );
37
38
if ( $auth_status ne "ok" ) {
39
    exit 0;
40
}
41
42
my $mana_ip = C4::Context->config('mana_config');
43
44
my $url = "$mana_ip/getsecuritytoken";
45
my $request = HTTP::Request->new( POST => $url );
46
47
my $content;
48
$content->{ firstname }= $input->param("firstname");
49
$content->{ lastname }= $input->param("lastname");
50
$content->{ email }= $input->param("email");
51
my $json = to_json( $content, { utf8 => 1 } );
52
$request->content($json);
53
my $result = Koha::SharedContent::process_request($request);
54
55
print(to_json($result));
(-)a/svc/mana/use (-7 / +15 lines)
Lines 18-28 Link Here
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
#
19
#
20
20
21
use strict;
21
use Modern::Perl;
22
use warnings;
23
22
24
use Koha::SharedContent;
23
use Koha::SharedContent;
25
use C4::Auth qw(check_cookie_auth);
24
use C4::Auth qw(check_cookie_auth);
25
use Koha::Report;
26
26
27
use CGI;
27
use CGI;
28
use JSON;
28
use JSON;
Lines 40-48 if ( $auth_status ne "ok" ) { Link Here
40
    exit 0;
40
    exit 0;
41
}
41
}
42
42
43
my $result = Koha::SharedContent::manaGetRequestWithId("subscription", $input->param('id') );
43
my $result = Koha::SharedContent::get_entity_by_id(
44
    scalar $input->param('resource'),
45
    scalar $input->param('id')
46
);
47
my $package = "Koha::".ucfirst($input->param('resource'));
48
my $resource;
44
49
45
my $subscription;
50
if ( $input->param( 'saveinbase' )) {
46
$subscription = $result->{data};
51
    $resource = { id => $package->new_from_mana($result->{data})->id };
47
52
}
48
print(to_json($subscription));
53
else{
54
    $resource = $result->{data};
55
}
56
print(to_json($resource));
(-)a/t/db_dependent/Koha/SharedContent.t (-2 / +225 lines)
Lines 20-29 Link Here
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use t::lib::TestBuilder;
22
use t::lib::TestBuilder;
23
use Test::More tests => 1;
23
use t::lib::Mocks;
24
use Test::MockModule;
25
use Test::MockObject;
26
use Test::More tests => 44;
24
use Koha::Database;
27
use Koha::Database;
28
use Koha::Patrons;
29
use Koha::Subscriptions;
30
31
use HTTP::Status qw(:constants :is status_message);
25
32
26
use_ok('Koha::SharedContent');
33
use_ok('Koha::SharedContent');
27
34
28
my $schema = Koha::Database->new->schema;
35
my $schema = Koha::Database->new->schema;
29
$schema->storage->txn_begin;    # mode insertion
36
$schema->storage->txn_begin;
37
38
my $builder = t::lib::TestBuilder->new();
39
40
my $want_error = 0;
41
my $post_request = 0;
42
my $query = {};
43
44
t::lib::Mocks::mock_config( 'mana_config', 'https://foo.bar');
45
46
is(Koha::SharedContent::get_sharing_url(), 'https://foo.bar', 'Mana URL');
47
48
my $result = Koha::SharedContent::search_entities('report', $query);
49
ok($result->{msg} =~ /Can\'t connect to foo.bar:443$/, 'Unable to connect');
50
is($result->{code}, 500, 'Code is 500');
51
52
my $ua = Test::MockModule->new('LWP::UserAgent');
53
$ua->mock('request', sub {
54
        return mock_response();
55
});
56
57
$want_error = 1;
58
$query = {query => 'foo', usecomments => 1};
59
$result = Koha::SharedContent::search_entities('report', $query);
60
ok($result->{msg} =~ /^Error thrown by decoded_content/, 'Error in decoded_content');
61
is($result->{code}, 500, 'Code is 500');
62
63
$want_error = 0;
64
$query = {title => 'foo', usecomments => 1};
65
$result = Koha::SharedContent::search_entities('subscription', $query);
66
is($result->{code}, 200, 'search_entities success');
67
68
$result = Koha::SharedContent::get_entity_by_id('subscription', 23);
69
is($result->{code}, 200, 'get_entity_by_id success');
70
71
my $params = {
72
    title => 'The English historical review',
73
    issn => '0013-8266',
74
    ean => '',
75
    publishercode => 'Longman'
76
};
77
78
# Search a subscription.
79
my $request = Koha::SharedContent::build_request('get', 'subscription', $params);
80
is($request->method, 'GET', 'Get subscription - Method is get');
81
82
my %query = $request->uri->query_form;
83
is($query{title}, 'The English historical review', 'Check title');
84
is($query{issn}, '0013-8266', 'Check issn');
85
is($query{ean}, '', 'Check ean');
86
is($query{publishercode}, 'Longman', 'Check publisher');
87
88
is($request->uri->path, '/subscription.json', 'Path is subscription');
89
90
# Get a report by id.
91
$request = Koha::SharedContent::build_request('getwithid', 'report', 26);
92
is($request->method, 'GET', 'Get with id - Method is get');
93
94
is($request->uri->path, '/report/26.json', 'Path is report/26.json');
95
96
# Share a report.
97
my $content = {
98
    'kohaversion' => '17.06.00.008',
99
    'language' => 'fr-FR',
100
    'notes' => 'some notes',
101
    'report_group' => '',
102
    'exportemail' => 'xx@xx.com',
103
    'report_name' => 'A useless report',
104
    'savedsql' => 'SELECT * FROM ITEMS',
105
    'type' => undef
106
};
107
108
$request = Koha::SharedContent::build_request('post', 'report', $content);
109
is($request->method, 'POST', 'Share report - Method is post');
110
111
is($request->uri->path, '/report.json', 'Path is report.json');
112
113
# prepare shared data
114
my $loggedinuser = $builder->build({
115
    source => 'Borrower',
116
    value => {
117
        email => '',
118
        emailpro => '',
119
        B_email => ''
120
    }
121
});
122
123
my $library = $builder->build({
124
    source => 'Branch',
125
});
126
127
my $biblio = $builder->build({
128
    source => 'Biblio',
129
});
130
131
my $biblioitem = $builder->build({
132
    source => 'Biblioitem',
133
    value => {
134
        biblionumber => $biblio->{biblionumber}
135
    }
136
});
137
138
my $subscriptionFrequency = $builder->build({
139
    source => 'SubscriptionFrequency'
140
});
141
142
my $subscriptionNumberpattern = $builder->build({
143
    source => 'SubscriptionNumberpattern'
144
});
145
146
my $subscription = $builder->build({
147
    source => 'Subscription',
148
    value => {
149
        biblionumber => $biblio->{biblionumber},
150
        periodicity => $subscriptionFrequency->{id},
151
        numberpattern => $subscriptionNumberpattern->{id},
152
        mana_id => undef
153
    }
154
});
155
156
C4::Context->_new_userenv('xxx');
157
C4::Context->set_userenv(0,0,0,
158
    $loggedinuser->{firstname},
159
    $loggedinuser->{surname},
160
    $library->{branchcode},
161
    'Midway Public Library', '', '', '');
162
163
t::lib::Mocks::mock_preference('language', 'en');
164
165
$post_request = 1;
166
$result = Koha::SharedContent::send_entity('en', $loggedinuser->{borrowernumber}, $subscription->{subscriptionid}, 'subscription');
167
is($result->{code}, 200, 'send_entity success');
168
169
my $s = Koha::Subscriptions->find($subscription->{subscriptionid});
170
is($s->mana_id, 5, 'Mana id is set');
171
172
my $data = Koha::SharedContent::prepare_entity_data(
173
    '',
174
    $loggedinuser->{borrowernumber},
175
    $subscription->{subscriptionid},
176
    'subscription'
177
);
178
179
is($data->{language}, 'en', 'Language is set to default');
180
my $branch = Koha::Libraries->find($library->{branchcode});
181
is($data->{exportemail}, $branch->branchemail, 'Email is set with the userenv branch one');
182
is($data->{title}, $biblio->{title}, 'Shared title');
183
is($data->{sfdescription}, $subscriptionFrequency->{description}, 'Shared sfdescription');
184
is($data->{unit}, $subscriptionFrequency->{unit}, 'Shared unit');
185
is($data->{unitsperissue}, $subscriptionFrequency->{unitsperissue}, 'Shared unitsperissue');
186
is($data->{issuesperunit}, $subscriptionFrequency->{issuesperunit}, 'Shared issuesperunit');
187
188
is($data->{label}, $subscriptionNumberpattern->{label}, 'Shared np label');
189
is($data->{sndescription}, $subscriptionNumberpattern->{description}, 'Shared np description');
190
is($data->{numberingmethod}, $subscriptionNumberpattern->{numberingmethod}, 'Shared numberingmethod');
191
is($data->{label1}, $subscriptionNumberpattern->{label1}, 'Shared label1');
192
is($data->{add1}, $subscriptionNumberpattern->{add1}, 'Shared add1');
193
is($data->{every1}, $subscriptionNumberpattern->{every1}, 'Shared every1');
194
is($data->{whenmorethan1}, $subscriptionNumberpattern->{whenmorethan1}, 'Shared whenmorethan1');
195
is($data->{setto1}, $subscriptionNumberpattern->{setto1}, 'Shared setto1');
196
is($data->{numbering1}, $subscriptionNumberpattern->{numbering1}, 'Shared numbering1');
197
is($data->{issn}, $biblioitem->{issn}, 'Shared ISSN');
198
is($data->{ean}, $biblioitem->{ean}, 'Shared EAN');
199
is($data->{publishercode}, $biblioitem->{publishercode}, 'Shared publishercode');
200
201
sub mock_response {
202
    my $response = Test::MockObject->new();
203
204
    if ($want_error) {
205
        $response->mock('code', sub {
206
            return 500;
207
        });
208
        $response->mock('is_error', sub {
209
            return 0;
210
        });
211
        $response->mock('decoded_content', sub {
212
            die 'Error thrown by decoded_content';
213
        });
214
    } elsif ( $post_request ) {
215
        $response->mock('code', sub {
216
            return 200;
217
        });
218
        $response->mock('is_error', sub {
219
            return 0;
220
        });
221
        $response->mock('decoded_content', sub {
222
            return '{"code": "200", "msg": "foo", "id": "5"}';
223
        });
224
    } else {
225
        $response->mock('code', sub {
226
            return 200;
227
        });
228
        $response->mock('is_error', sub {
229
            return 0;
230
        });
231
        $response->mock('decoded_content', sub {
232
            return '';
233
        });
234
    }
235
}
236
237
# Increment request.
238
$request = Koha::SharedContent::build_request('increment',
239
                                             'subscription',
240
                                             12,
241
                                             'foo');
242
243
is($request->method, 'POST', 'Increment subscription - Method is post');
244
245
%query = $request->uri->query_form;
246
is($query{id}, 12, 'Check id');
247
is($query{step}, 1, 'Step is default');
248
is($query{resource}, 'subscription', 'Check ressource');
249
250
is($request->uri->path, '/subscription/12.json/increment/foo', 'Path is subscription');
251
252
$schema->storage->txn_rollback;
(-)a/t/db_dependent/Koha/Subscription.t (-2 / +2 lines)
Lines 31-37 use t::lib::TestBuilder; Link Here
31
31
32
my $schema = Koha::Database->new->schema;
32
my $schema = Koha::Database->new->schema;
33
$schema->storage->txn_begin;
33
$schema->storage->txn_begin;
34
my $builder = t::lib::TestBuilder->new;
35
34
36
use_ok('Koha::Subscription');
35
use_ok('Koha::Subscription');
37
36
Lines 150-155 my $ref = { Link Here
150
    'unit'            => $sub_freq_1->{unit},
149
    'unit'            => $sub_freq_1->{unit},
151
    'unitsperissue'   => $sub_freq_1->{unitsperissue},
150
    'unitsperissue'   => $sub_freq_1->{unitsperissue},
152
    'issuesperunit'   => $sub_freq_1->{issuesperunit},
151
    'issuesperunit'   => $sub_freq_1->{issuesperunit},
152
    'label'           => $sub_np_1->{label},
153
    'sndescription'   => $sub_np_1->{description},
153
    'sndescription'   => $sub_np_1->{description},
154
    'numberingmethod' => $sub_np_1->{numberingmethod},
154
    'numberingmethod' => $sub_np_1->{numberingmethod},
155
    'label'           => $sub_np_1->{label},
155
    'label'           => $sub_np_1->{label},
Lines 176-182 my $ref = { Link Here
176
    'publishercode'   => $bi_1->{publishercode}
176
    'publishercode'   => $bi_1->{publishercode}
177
};
177
};
178
178
179
is_deeply( Koha::Subscription::get_sharable_info( $sub_1->{subscriptionid} ),
179
is_deeply( Koha::Subscription->get_sharable_info( $sub_1->{subscriptionid} ),
180
    $ref, "get_sharable_info function is ok" );
180
    $ref, "get_sharable_info function is ok" );
181
181
182
$schema->storage->txn_rollback;
182
$schema->storage->txn_rollback;
(-)a/t/db_dependent/Koha/Subscription/Numberpatterns.t (+97 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Copyright 2017 BibLibre
4
#
5
# This file is part of Koha
6
#
7
# Koha is free software; you can redistribute it and/or modify it
8
# under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
11
#
12
# Koha is distributed in the hope that it will be useful, but
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
20
use Modern::Perl;
21
22
use t::lib::TestBuilder;
23
use Test::More tests => 6;
24
use Koha::Database;
25
26
use_ok('Koha::Subscription::Numberpatterns');
27
28
my $schema = Koha::Database->new->schema;
29
$schema->storage->txn_begin;
30
my $builder = t::lib::TestBuilder->new;
31
32
my $dbh = C4::Context->dbh;
33
$dbh->do('DELETE FROM subscription_numberpatterns');
34
35
my $numberpattern = $builder->build({
36
    source => 'SubscriptionNumberpattern',
37
    value => {
38
        label => 'Volume, Number, Issue',
39
        description => 'Volume Number Issue 1',
40
        numberingmethod => 'Vol.{X}, Number {Y}, Issue {Z}',
41
        label1 => 'Volume',
42
        add1 => '1',
43
        every1 => '48',
44
        whenmorethan1 => '99999',
45
        setto1 => '1',
46
        numbering1 => undef,
47
        label2 => 'Number',
48
        add2 => '1',
49
        every2 => '4',
50
        whenmorethan2 => '12',
51
        setto2 => '1',
52
        numbering2 => undef,
53
        label3 => 'Issue',
54
        add3 => '1',
55
        every3 => '1',
56
        whenmorethan3 => '4',
57
        setto3 => '1',
58
        numbering3 => undef
59
    }
60
});
61
62
my $search_ok = {
63
    umberingmethod => 'Vol.{X}, Number {Y}, Issue {Z}',
64
    label1 => 'Volume', add1 => '1', every1 => '48',
65
    whenmorethan1 => '99999', setto1 => '1',
66
    label2 => 'Number', add2 => '1', every2 => '4',
67
    whenmorethan2 => '12', setto2 => '1',
68
    label3 => 'Issue', add3 => '1', every3 => '1',
69
    whenmorethan3 => '4', setto3 => '1',
70
    numbering_pattern => 'mana'
71
};
72
73
my $number_pattern_id = Koha::Subscription::Numberpatterns->new_or_existing($search_ok);
74
is($number_pattern_id, $numberpattern->{id}, 'new_or_existing method should find the existing number pattern');
75
76
$number_pattern_id = Koha::Subscription::Numberpatterns->new_or_existing({numbering_pattern => 1});
77
is($number_pattern_id, 1, 'new_or_existing method should return passed numbering_pattern');
78
79
my $search_not_ok = {
80
    patternname => 'Number',
81
    sndescription => 'Simple Numbering method',
82
    numberingmethod => 'No.{X}',
83
    label1 => 'Number',
84
    add1 => 1,
85
    every1 => 1,
86
    whenmorethan1 => 99999,
87
    setto1 => 1,
88
    numbering_pattern => 'mana'
89
};
90
91
$number_pattern_id = Koha::Subscription::Numberpatterns->new_or_existing($search_not_ok);
92
my $new_number_pattern = Koha::Subscription::Numberpatterns->find($number_pattern_id);
93
is($new_number_pattern->label, 'Number');
94
is($new_number_pattern->description, 'Simple Numbering method');
95
is($new_number_pattern->numberingmethod, 'No.{X}');
96
97
$schema->storage->txn_rollback;
(-)a/t/db_dependent/Serials.t (-1 / +1 lines)
Lines 283-289 my $pattern = C4::Serials::Numberpattern::GetSubscriptionNumberpattern($subscrip Link Here
283
( $total_issues, @serials ) = C4::Serials::GetSerials( $subscriptionid );
283
( $total_issues, @serials ) = C4::Serials::GetSerials( $subscriptionid );
284
my $publisheddate = output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 });
284
my $publisheddate = output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 });
285
( $total_issues, @serials ) = C4::Serials::GetSerials( $subscriptionid );
285
( $total_issues, @serials ) = C4::Serials::GetSerials( $subscriptionid );
286
my $frequency = C4::Serials::Frequency::GetSubscriptionFrequency($subscription->{periodicity});
286
$frequency = C4::Serials::Frequency::GetSubscriptionFrequency($subscription->{periodicity});
287
my $nextpublisheddate = C4::Serials::GetNextDate($subscription, $publisheddate, $frequency, 1);
287
my $nextpublisheddate = C4::Serials::GetNextDate($subscription, $publisheddate, $frequency, 1);
288
my @statuses = qw( 2 2 3 3 3 3 3 4 4 41 42 43 44 5 );
288
my @statuses = qw( 2 2 3 3 3 3 3 4 4 41 42 43 44 5 );
289
# Add 14 serials
289
# Add 14 serials
(-)a/t/db_dependent/Serials/GetFictiveIssueNumber.t (-114 / +219 lines)
Lines 1-126 Link Here
1
#!/usr/bin/perl
1
#!/usr/bin/perl
2
2
3
use C4::Context;
3
# This test deals with GetFictiveIssueNumber (from C4::Serials)
4
use Test::More tests => 18;
4
5
use Modern::Perl;
5
use Modern::Perl;
6
use Test::More tests => 5;
7
8
use Koha::Database;
9
use C4::Serials;
10
use C4::Serials::Frequency;
6
11
12
my $schema  = Koha::Database->new->schema;
13
$schema->storage->txn_begin;
7
my $dbh = C4::Context->dbh;
14
my $dbh = C4::Context->dbh;
8
$dbh->{RaiseError} = 1;
9
$dbh->{AutoCommit} = 0;
10
15
11
use C4::Serials::Frequency;
16
subtest 'Tests for irregular frequency' => sub {
12
use C4::Serials;
17
    plan tests => 2;
13
18
14
# TEST CASE - 1 issue per day, no irregularities
19
    # Add a frequency
15
my $frequency = {
20
    my $freq_irr = AddSubscriptionFrequency({
16
    description   => "One issue per day",
21
        description => "Irregular",
17
    unit          => 'day',
22
        unit => undef,
18
    issuesperunit => 1,
23
    });
19
    unitsperissue => 1,
20
};
21
24
22
my $subscription = {
25
    # Test it
23
    firstacquidate     => '1970-01-01',
26
    my $subscription = {
24
    irregularity       => '',
27
        periodicity => $freq_irr,
25
    countissuesperunit => 1,
28
        firstacquidate => '1972-02-07',
26
};
29
    };
27
my $issueNumber;
30
    is( C4::Serials::GetFictiveIssueNumber($subscription, '1972-12-31'), undef, 'Irregular: should be undef' );
28
31
    is( C4::Serials::GetFictiveIssueNumber($subscription, '1973-12-31'), undef, 'Irregular: still undef' );
29
$issueNumber =
30
  C4::Serials::GetFictiveIssueNumber( $subscription, '1970-01-01', $frequency );
31
is( $issueNumber, '1' );
32
33
$issueNumber =
34
  C4::Serials::GetFictiveIssueNumber( $subscription, '1970-01-02', $frequency );
35
is( $issueNumber, '2' );
36
$issueNumber =
37
  C4::Serials::GetFictiveIssueNumber( $subscription, '1970-01-03', $frequency );
38
is( $issueNumber, '3' );
39
40
# TEST CASE - 2 issues per day, no irregularity
41
$frequency = {
42
    description   => "Two issues per day",
43
    unit          => 'day',
44
    issuesperunit => 2,
45
    unitsperissue => 1,
46
};
32
};
47
$subscription = {
33
48
    firstacquidate     => '1970-01-01',
34
subtest 'Tests for yearly frequencies' => sub {
49
    irregularity       => '',
35
    plan tests => 10;
50
    countissuesperunit => 1,
36
51
};
37
    # First add a few frequencies
52
$issueNumber =
38
    my $freq_1i_1y = AddSubscriptionFrequency({
53
  C4::Serials::GetFictiveIssueNumber( $subscription, '1970-01-01', $frequency );
39
        description => "1 issue per year",
54
is( $issueNumber, '1' );
40
        unit => 'year',
55
$issueNumber =
41
        issuesperunit => 1,
56
  C4::Serials::GetFictiveIssueNumber( $subscription, '1970-01-02', $frequency );
42
        unitsperissue => 1,
57
is( $issueNumber, '3' );
43
    });
58
$issueNumber =
44
    my $freq_1i_3y = AddSubscriptionFrequency({
59
  C4::Serials::GetFictiveIssueNumber( $subscription, '1970-01-03', $frequency );
45
        description => "1 issue per 3 years",
60
is( $issueNumber, '5' );
46
        unit => 'year',
61
47
        issuesperunit => 1,
62
$subscription->{countissuesperunit} = 2;
48
        unitsperissue => 3,
63
$issueNumber =
49
    });
64
  C4::Serials::GetFictiveIssueNumber( $subscription, '1970-01-01', $frequency );
50
    my $freq_5i_1y = AddSubscriptionFrequency({
65
is( $issueNumber, '2' );
51
        description => "5 issues per year",
66
$issueNumber =
52
        unit => 'year',
67
  C4::Serials::GetFictiveIssueNumber( $subscription, '1970-01-02', $frequency );
53
        issuesperunit => 5,
68
is( $issueNumber, '4' );
54
        unitsperissue => 1,
69
$issueNumber =
55
    });
70
  C4::Serials::GetFictiveIssueNumber( $subscription, '1970-01-03', $frequency );
56
    my $freq_366i_1y = AddSubscriptionFrequency({
71
is( $issueNumber, '6' );
57
        description => "366 issue per year",
72
58
        unit => 'year',
73
# TEST CASE - 1 issue every 2 days, no irregularity
59
        issuesperunit => 366,
74
$frequency = {
60
        unitsperissue => 1,
75
    description   => "one issue every two days",
61
    });
76
    unit          => 'day',
62
77
    issuesperunit => 1,
63
    # TEST CASE - 1 issue per year
78
    unitsperissue => 2,
64
    my $subscription = {
65
        periodicity => $freq_1i_1y,
66
        firstacquidate => '1972-02-10',
67
        countissuesperunit => 1,
68
    };
69
70
    my $frequency = GetSubscriptionFrequency($freq_1i_1y);
71
72
    is( C4::Serials::GetFictiveIssueNumber($subscription, '1973-02-09', $frequency), 1, 'Feb 9 still 1' );
73
    is( C4::Serials::GetFictiveIssueNumber($subscription, '1973-02-10', $frequency), 2, 'Feb 10 goes to 2' );
74
75
    # TEST CASE - 1 issue per 3 years
76
    $subscription->{periodicity} = $freq_1i_3y;
77
    $subscription->{firstacquidate} = '1972-02-20';
78
    $frequency = GetSubscriptionFrequency($freq_1i_3y);
79
    is( C4::Serials::GetFictiveIssueNumber($subscription, '1975-02-19', $frequency), 1, 'Feb 19, 1975 still 1' );
80
    is( C4::Serials::GetFictiveIssueNumber($subscription, '1975-02-20', $frequency), 2, 'Feb 20, 1975 goes to 2' );
81
82
    # TEST CASE - 5 issues per year
83
    $subscription->{periodicity} = $freq_5i_1y;
84
    $subscription->{firstacquidate} = '1972-02-29'; #leap year
85
    $subscription->{countissuesperunit} = 1;
86
    $frequency = GetSubscriptionFrequency($freq_5i_1y);
87
    is( C4::Serials::GetFictiveIssueNumber($subscription, '1972-05-11', $frequency), 1, 'May 11 still 1' );
88
    $subscription->{countissuesperunit} = 2;
89
    is( C4::Serials::GetFictiveIssueNumber($subscription, '1972-05-12', $frequency), 2, 'May 12 goes to 2' );
90
    $subscription->{countissuesperunit} = 5;
91
    is( C4::Serials::GetFictiveIssueNumber($subscription, '1973-02-27', $frequency), 5, 'Feb 27 should still be 5' );
92
    $subscription->{countissuesperunit} = 1;
93
    is( C4::Serials::GetFictiveIssueNumber($subscription, '1973-02-28', $frequency), 6, 'Feb 28 goes to 6' );
94
95
    # TEST CASE - 366 issues per year (hypothetical example)
96
    # Testing prevention of divide by zero
97
    $subscription->{periodicity} = $freq_366i_1y;
98
    $subscription->{firstacquidate} = '1972-02-29'; #leap year
99
    $subscription->{countissuesperunit} = 366;
100
    $frequency = GetSubscriptionFrequency($freq_366i_1y);
101
    is( C4::Serials::GetFictiveIssueNumber($subscription, '1973-02-27', $frequency), 366, 'Feb 27 still at 366' );
102
    is( C4::Serials::GetFictiveIssueNumber($subscription, '1973-02-28', $frequency), 732, 'Feb 28 goes to 732' );
103
79
};
104
};
80
$subscription = {
105
81
    firstacquidate     => '1970-01-01',
106
subtest 'Tests for monthly frequencies' => sub {
82
    irregularity       => '',
107
    plan tests => 8;
83
    countissuesperunit => 1,
108
109
    # First add a few frequencies
110
    my $freq_1i_5m = AddSubscriptionFrequency({
111
        description => "1 issue per 5 months",
112
        unit => 'month',
113
        issuesperunit => 1,
114
        unitsperissue => 5,
115
    });
116
    my $freq_4i_1m = AddSubscriptionFrequency({
117
        description => "4 issue per month",
118
        unit => 'month',
119
        issuesperunit => 4,
120
        unitsperissue => 1,
121
    });
122
123
    # TEST CASE - 1 issue per 5 months
124
    my $subscription = {
125
        periodicity => $freq_1i_5m,
126
        firstacquidate => '1972-02-10',
127
        countissuesperunit => 1,
128
    };
129
    my $frequency = GetSubscriptionFrequency($freq_1i_5m);
130
    is( C4::Serials::GetFictiveIssueNumber($subscription, '1972-07-09', $frequency), 1, 'Jul 9 still 1' );
131
    is( C4::Serials::GetFictiveIssueNumber($subscription, '1972-07-10', $frequency), 2, 'Jul 10 goes to 2' );
132
    is( C4::Serials::GetFictiveIssueNumber($subscription, '1973-05-09', $frequency), 3, 'May 9 still 3' );
133
    is( C4::Serials::GetFictiveIssueNumber($subscription, '1973-05-10', $frequency), 4, 'May 10 goes to 4' );
134
135
    # TEST CASE - 4 issue per 1 months
136
    $subscription = {
137
        periodicity => $freq_4i_1m,
138
        firstacquidate => '1972-02-22',
139
        countissuesperunit => 1,
140
    };
141
    $frequency = GetSubscriptionFrequency($freq_4i_1m);
142
    is( C4::Serials::GetFictiveIssueNumber($subscription, '1972-02-28', $frequency), 1, 'Feb 28 still 1' );
143
    $subscription->{countissuesperunit} = 2;
144
    is( C4::Serials::GetFictiveIssueNumber($subscription, '1972-02-29', $frequency), 2, 'Feb 29 goes to 2' );
145
    $subscription->{countissuesperunit} = 4;
146
    is( C4::Serials::GetFictiveIssueNumber($subscription, '1972-03-21', $frequency), 4, 'Mar 21 still 4' );
147
    $subscription->{countissuesperunit} = 1;
148
    is( C4::Serials::GetFictiveIssueNumber($subscription, '1972-03-22', $frequency), 5, 'Mar 22 goes to 5' );
149
84
};
150
};
85
$issueNumber =
151
86
  C4::Serials::GetFictiveIssueNumber( $subscription, '1970-01-01', $frequency );
152
subtest 'Tests for weekly frequencies' => sub {
87
is( $issueNumber, 1 );
153
    plan tests => 4;
88
$issueNumber =
154
89
  C4::Serials::GetFictiveIssueNumber( $subscription, '1970-01-02', $frequency );
155
    # First add a few frequencies
90
is( $issueNumber, 1 );
156
    my $freq_1i_7w = AddSubscriptionFrequency({
91
$issueNumber =
157
        description => "1 issue per 7 weeks",
92
  C4::Serials::GetFictiveIssueNumber( $subscription, '1970-01-03', $frequency );
158
        unit => 'week',
93
is( $issueNumber, 2 );
159
        issuesperunit => 1,
94
$issueNumber =
160
        unitsperissue => 7,
95
  C4::Serials::GetFictiveIssueNumber( $subscription, '1970-01-04', $frequency );
161
    });
96
is( $issueNumber, 2 );
162
    my $freq_3i_1w = AddSubscriptionFrequency({
97
$issueNumber =
163
        description => "3 issues per week",
98
  C4::Serials::GetFictiveIssueNumber( $subscription, '1970-01-05', $frequency );
164
        unit => 'week',
99
is( $issueNumber, 3 );
165
        issuesperunit => 3,
100
166
        unitsperissue => 1,
101
# TEST CASE - 1 issue per week, no irregularity
167
    });
102
$frequency = {
168
103
    description   => "one issue per week",
169
    # TEST CASE - 1 issue per 7 weeks
104
    unit          => 'week',
170
    my $subscription = {
105
    issuesperunit => 1,
171
        periodicity => $freq_1i_7w,
106
    unitsperissue => 1,
172
        firstacquidate => '1972-02-10',
173
        countissuesperunit => 1,
174
    };
175
    my $frequency = GetSubscriptionFrequency($freq_1i_7w);
176
    is( C4::Serials::GetFictiveIssueNumber($subscription, '1972-03-29', $frequency), 1, 'Mar 29 still 1' );
177
    is( C4::Serials::GetFictiveIssueNumber($subscription, '1972-03-30', $frequency), 2, 'Mar 30 goes to 2' );
178
179
    # TEST CASE - 3 issue per 1 week
180
    $subscription = {
181
        periodicity => $freq_3i_1w,
182
        firstacquidate => '1972-02-03',
183
        countissuesperunit => 1,
184
    };
185
    $subscription->{countissuesperunit} = 3;
186
    $frequency = GetSubscriptionFrequency($freq_3i_1w);
187
    is( C4::Serials::GetFictiveIssueNumber($subscription, '1972-02-09', $frequency), 3, 'Feb 9 still 3' );
188
    $subscription->{countissuesperunit} = 1;
189
    is( C4::Serials::GetFictiveIssueNumber($subscription, '1972-02-10', $frequency), 4, 'Feb 10 goes to 4' );
107
};
190
};
108
$subscription = {
191
109
    firstacquidate     => '1970-01-01',
192
subtest 'Tests for dayly frequencies' => sub {
110
    irregularity       => '',
193
    plan tests => 4;
111
    countissuesperunit => 1,
194
195
    # First add a few frequencies
196
    my $freq_1i_12d = AddSubscriptionFrequency({
197
        description => "1 issue per 12 days",
198
        unit => 'day',
199
        issuesperunit => 1,
200
        unitsperissue => 12,
201
    });
202
    my $freq_3i_1d = AddSubscriptionFrequency({
203
        description => "3 issues per day",
204
        unit => 'day',
205
        issuesperunit => 3,
206
        unitsperissue => 1,
207
    });
208
209
    # TEST CASE - 1 issue per 12 days
210
    my $subscription = {
211
        periodicity => $freq_1i_12d,
212
        firstacquidate => '1972-03-16',
213
        countissuesperunit => 1,
214
    };
215
    my $frequency = GetSubscriptionFrequency($freq_1i_12d);
216
    is( C4::Serials::GetFictiveIssueNumber($subscription, '1972-03-27', $frequency), 1, 'Mar 27 still 1' );
217
    is( C4::Serials::GetFictiveIssueNumber($subscription, '1972-03-28', $frequency), 2, 'Mar 28 goes to 2' );
218
219
    # TEST CASE - 3 issue per day
220
    $subscription = {
221
        periodicity => $freq_3i_1d,
222
        firstacquidate => '1972-04-23',
223
        countissuesperunit => 1,
224
    };
225
    $subscription->{countissuesperunit} = 3;
226
    $frequency = GetSubscriptionFrequency($freq_3i_1d);
227
    is( C4::Serials::GetFictiveIssueNumber($subscription, '1972-05-01', $frequency), 27, 'May 1 still 27' );
228
    $subscription->{countissuesperunit} = 1;
229
    is( C4::Serials::GetFictiveIssueNumber($subscription, '1972-05-02', $frequency), 28, 'May 2 goes to 28' );
112
};
230
};
113
$issueNumber =
231
114
  C4::Serials::GetFictiveIssueNumber( $subscription, '1970-01-01', $frequency );
232
$schema->storage->txn_rollback;
115
is( $issueNumber, 1 );
116
$issueNumber =
117
  C4::Serials::GetFictiveIssueNumber( $subscription, '1970-01-02', $frequency );
118
is( $issueNumber, 1 );
119
$issueNumber =
120
  C4::Serials::GetFictiveIssueNumber( $subscription, '1970-01-08', $frequency );
121
is( $issueNumber, 2 );
122
$issueNumber =
123
  C4::Serials::GetFictiveIssueNumber( $subscription, '1970-01-15', $frequency );
124
is( $issueNumber, 3 );
125
126
$dbh->rollback;
127
- 

Return to bug 17047