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

(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/rotating_collections/addItems.tt (-34 / +18 lines)
Lines 26-69 Link Here
26
              [% INCLUDE 'rotating-collections-toolbar.inc' %]
26
              [% INCLUDE 'rotating-collections-toolbar.inc' %]
27
              <h1>Collection <i>[% collection.colTitle | html %]</i></h1>
27
              <h1>Collection <i>[% collection.colTitle | html %]</i></h1>
28
28
29
              [% IF ( previousActionAdd ) %]
29
              [% IF ( messages ) %]
30
                [% IF ( addSuccess ) %]
30
                <div class="dialog message">
31
                  <div class="dialog message">Item with barcode '[% barcode | html %]' added successfully</div>
31
                  [% FOR message IN messages %]
32
                [% ELSE %]
32
                    [% IF message.code == 'success_adding_item' %]
33
                  <div class="dialog alert">
33
                      Item with barcode '[% barcode | html %]' added successfully<br />
34
                    <p>Failed to add item with barcode <i>[% barcode | html %]</i>:
34
                    [% ELSIF message.code == 'success_removing_item' %]
35
                    <p>
35
                      Item with barcode '[% barcode | html %]' removed successfully<br />
36
                        [% IF failureMessage == "NO_ITEM" %]
36
                    [% END %]
37
                            No item with matching barcode found
37
                  [% END %]
38
                        [% ELSIF failureMessage == "IN_COLLECTION_OTHER" %]
39
                            Item is already in a different rotating collection
40
                        [% ELSIF failureMessage == "IN_COLLECTION" %]
41
                            Item is already in this collection
42
                        [% ELSE %]
43
                            [% failureMessage | html %]
44
                        [% END %]
45
                    </p>
46
                </div>
38
                </div>
47
                [% END %]
48
              [% END %]
39
              [% END %]
49
40
50
              [% IF ( previousActionRemove ) %]
41
              [% IF ( errors ) %]
51
                [% IF ( removeSuccess ) %]
42
                <div class="dialog alert">
52
                  <div class="dialog message">Item with barcode <i>[% barcode | html %]</i> removed successfully</div>
43
                  [% FOR error IN errors %]
53
                [% ELSE %]
44
                    [% IF error.code == 'error_adding_item' %]
54
                  <div class="dialog alert">
45
                      Failed to add item with barcode '[% barcode | html%]'<br />
55
                    Failed to remove item with barcode <i>[% barcode | html %]</i>:
46
                    [% ELSIF error.code == 'error_removing_item' %]
56
                    <p>
47
                      Failed to remove item with barcode <i>[% barcode | html %]</i><br />
57
                        [% IF failureMessage == "NO_ITEM" %]
48
                    [% END %]
58
                            No item with matching barcode found
49
                  [% END %]
59
                        [% ELSIF failureMessage == "NOT_IN_COLLECTION" %]
60
                            Item is not in this collection
61
                        [% ELSE %]
62
                            [% failureMessage | html %]
63
                        [% END %]
64
                    </p>
65
                </div>
50
                </div>
66
                [% END %]
67
              [% END %]
51
              [% END %]
68
52
69
              <div>
53
              <div>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/rotating_collections/editCollections.tt (-60 / +33 lines)
Lines 6-12 Link Here
6
    [%- IF ( action == "new" ) %]
6
    [%- IF ( action == "new" ) %]
7
        Add a new collection
7
        Add a new collection
8
    [% ELSE %]
8
    [% ELSE %]
9
        Edit collection [% editColTitle | html %]
9
        Edit collection [% collection.colTitle | html %]
10
    [% END -%]
10
    [% END -%]
11
</title>
11
</title>
12
[% INCLUDE 'doc-head-close.inc' %]
12
[% INCLUDE 'doc-head-close.inc' %]
Lines 19-25 Link Here
19
    [%- IF ( action == "new" ) %]
19
    [%- IF ( action == "new" ) %]
20
        Add a new collection
20
        Add a new collection
21
    [% ELSE %]
21
    [% ELSE %]
22
        <a href="/cgi-bin/koha/rotating_collections/addItems.pl?colId=[% editColId | html %]">Collection <i>[% editColTitle | html %]</i></a> &rsaquo; Edit
22
        <a href="/cgi-bin/koha/rotating_collections/addItems.pl?colId=[% collection.colId | html %]">Collection <i>[% collection.colTitle | html %]</i></a> &rsaquo; Edit
23
    [% END -%]
23
    [% END -%]
24
</div>
24
</div>
25
25
Lines 28-95 Link Here
28
        <div id="yui-main">
28
        <div id="yui-main">
29
            <div class="yui-b">
29
            <div class="yui-b">
30
30
31
              [% IF ( previousActionCreate ) %]
31
              [% IF messages %]
32
                [% IF ( createSuccess ) %]
32
                <div class="dialog message">
33
                    <div class="dialog message">
33
                  [% FOR message IN messages %]
34
                        <p>Collection <i>[% createdTitle | html %]</i> added successfully</p>
34
                    [% IF message.code == "success_on_insert" %]
35
                        <p><a href="/cgi-bin/koha/rotating_collections/rotatingCollections.pl">Return to rotating collections home</a></p>
35
                      <p>Collection <i>[% createdTitle | html %]</i> added successfully</p>
36
                    </div>
36
                    [% ELSIF message.code == "success_on_delete" %]
37
                [% ELSE %]
37
                      <p>Collection deleted successfully</p>
38
                  <div class="dialog alert">
38
                    [% ELSIF message.code == "success_on_update" %]
39
                    <p>Collection <i>[% createdTitle | html %]</i> failed to be added</p>
39
                      <p>Collection <i>[% updatedTitle | html %]</i> updated successfully</p>
40
                    <p>
40
                    [% END %]
41
                        [% IF failureMessage == "NO_TITLE" %]
41
                  [% END %]
42
                            No title entered.
42
                  <p><a href="/cgi-bin/koha/rotating_collections/rotatingCollections.pl">Return to rotating collections home</a></p>
43
                        [% ELSIF failureMessage == "DUPLICATE_TITLE" %]
43
                </div>
44
                            Title already in use.
45
                        [% ELSIF failureMessage == "NO_DESCRIPTION" %]
46
                            No description entered.
47
                        [% ELSE %]
48
                            [% failureMessage | html %]
49
                        [% END %]
50
                    </p>
51
                  </div>
52
                [% END %]
53
              [% END %]
54
55
              [% IF ( previousActionDelete ) %]
56
                [% IF ( deleteSuccess ) %]
57
                  <div class="dialog message">
58
                    <p>Collection deleted successfully</p>
59
                    <p><a href="/cgi-bin/koha/rotating_collections/rotatingCollections.pl">Return to rotating collections home</a></p>
60
                  </div>
61
                [% ELSE %]
62
                  <div class="dialog alert">Collection failed to be deleted</div>
63
                [% END %]
64
              [% END %]
44
              [% END %]
65
45
66
              [% IF ( previousActionUpdate ) %]
46
              [% IF errors %]
67
                [% IF ( updateSuccess ) %]
47
                <div class="dialog alert">
68
                  <div class="dialog message">
48
                  [% FOR error IN errors %]
69
                      <p>Collection <i>[% updatedTitle | html %]</i> updated successfully</p>
49
                    [% IF error.code == "error_on_insert" %]
70
                      <p><a href="/cgi-bin/koha/rotating_collections/rotatingCollections.pl">Return to rotating collections home</a></p>
50
                      <p>Collection <i>[% createdTitle | html %]</i> failed to be added</p>
71
                  </div>
51
                    [% ELSIF  error.code == "error_on_delete" %]
72
                [% ELSE %]
52
                      <p>Collection failed to be deleted</p>
73
                  <div class="dialog alert">
53
                    [% ELSIF  error.code == "error_on_updated" %]
74
                    <p>Collection <i>[% updatedTitle | html %]</i> failed to be updated</p>
54
                      <p>Collection <i>[% updatedTitle | html %]</i> failed to be updated</p>
75
                    <p>
55
                    [% END %]
76
                        [% IF failureMessage == "NO_ID" %]
56
                  [% END %]
77
                            No collection id given.
57
                  <p><a href="/cgi-bin/koha/rotating_collections/rotatingCollections.pl">Return to rotating collections home</a></p>
78
                        [% ELSIF failureMessage == "DUPLICATE_TITLE" %]
79
                            Title already in use.
80
                        [% ELSE %]
81
                            [% failureMessage | html %]
82
                        [% END %]
83
                    </p>
84
                </div>
58
                </div>
85
                [% END %]
86
              [% END %]
59
              [% END %]
87
60
88
              <div>
61
              <div>
89
62
90
                [% IF action == "new" || action == "edit" %]
63
                [% IF action == "new" || action == "edit" %]
91
                    [% IF ( previousActionEdit ) %]
64
                    [% IF ( previousActionEdit ) %]
92
                      <h1>Edit collection <i>[% editColTitle | html %]</i></h1>
65
                      <h1>Edit collection <i>[% collection.colTitle | html %]</i></h1>
93
                    [% ELSE %]
66
                    [% ELSE %]
94
                      <h1>Add new collection</h1>
67
                      <h1>Add new collection</h1>
95
                    [% END %]
68
                    [% END %]
Lines 97-103 Link Here
97
                    <form action="editCollections.pl" method="post" class="validated">
70
                    <form action="editCollections.pl" method="post" class="validated">
98
                        [% IF ( previousActionEdit ) %]
71
                        [% IF ( previousActionEdit ) %]
99
                            <input type="hidden" name="action" value="update" />
72
                            <input type="hidden" name="action" value="update" />
100
                            <input type="hidden" name="colId" value="[% editColId | html %]" />
73
                            <input type="hidden" name="colId" value="[% collection.colId | html %]" />
101
                        [% ELSE %]
74
                        [% ELSE %]
102
                            <input type="hidden" name="action" value="create" />
75
                            <input type="hidden" name="action" value="create" />
103
                        [% END %]
76
                        [% END %]
Lines 106-113 Link Here
106
                            <ol>
79
                            <ol>
107
                                <li>
80
                                <li>
108
                                    <label class="required" for="title">Title: </label>
81
                                    <label class="required" for="title">Title: </label>
109
                                    [% IF ( editColTitle ) %]
82
                                    [% IF ( collection.colTitle ) %]
110
                                        <input type="text" name="title" value="[% editColTitle | html %]" required="required" />
83
                                        <input type="text" name="title" value="[% collection.colTitle | html %]" required="required" />
111
                                        <span class="required">Required</span>
84
                                        <span class="required">Required</span>
112
                                    [% ELSE %]
85
                                    [% ELSE %]
113
                                        <input type="text" name="title" required="required" />
86
                                        <input type="text" name="title" required="required" />
Lines 116-123 Link Here
116
                                </li>
89
                                </li>
117
                                <li>
90
                                <li>
118
                                    <label for="description">Description: </label>
91
                                    <label for="description">Description: </label>
119
                                    [% IF (editColDescription ) %]
92
                                    [% IF (collection.colDesc ) %]
120
                                        <input type="text" size="50" name="description" value="[% editColDescription | html %]" />
93
                                        <input type="text" size="50" name="description" value="[% collection.colDesc | html %]" />
121
                                    [% ELSE %]
94
                                    [% ELSE %]
122
                                        <input type="text" size="50" name="description" />
95
                                        <input type="text" size="50" name="description" />
123
                                    [% END %]
96
                                    [% END %]
(-)a/rotating_collections/editCollections.pl (-17 / +12 lines)
Lines 29-34 use Koha::RotatingCollections; Link Here
29
my $query = new CGI;
29
my $query = new CGI;
30
my $action = $query->param('action');
30
my $action = $query->param('action');
31
my @messages;
31
my @messages;
32
my @errors;
32
33
33
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
34
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
34
    {
35
    {
Lines 45-50 my ( $template, $loggedinuser, $cookie ) = get_template_and_user( Link Here
45
if ( $action eq 'create' ) {
46
if ( $action eq 'create' ) {
46
    my $title       = $query->param('title');
47
    my $title       = $query->param('title');
47
    my $description = $query->param('description');
48
    my $description = $query->param('description');
49
    $template->param( createdTitle => $title );
48
50
49
    my $collection = Koha::RotatingCollection->new(
51
    my $collection = Koha::RotatingCollection->new(
50
        {   colTitle => $title,
52
        {   colTitle => $title,
Lines 55-88 if ( $action eq 'create' ) { Link Here
55
    eval { $collection->store; };
57
    eval { $collection->store; };
56
58
57
    if ($@) {
59
    if ($@) {
58
        push @messages, { type => 'error', code => 'error_on_insert' };
60
        push @errors, { code => 'error_on_insert' };
59
    } else {
61
    } else {
60
        push @messages, { type => 'message', code => 'success_on_insert' };
62
        push @messages, { code => 'success_on_insert' };
61
    }
63
    }
62
64
63
    $action = "list";
64
65
} elsif ( $action eq 'delete' ) { # Delete collection
65
} elsif ( $action eq 'delete' ) { # Delete collection
66
    my $colId = $query->param('colId');
66
    my $colId = $query->param('colId');
67
    my $collection = Koha::RotatingCollections->find($colId);
67
    my $collection = Koha::RotatingCollections->find($colId);
68
    my $deleted = eval { $collection->delete; };
68
    my $deleted = eval { $collection->delete; };
69
69
70
    if ( $@ or not $deleted ) {
70
    if ( $@ or not $deleted ) {
71
        push @messages, { type => 'error', code => 'error_on_delete' };
71
        push @errors, { code => 'error_on_delete' };
72
    } else {
72
    } else {
73
        push @messages, { type => 'message', code => 'success_on_delete' };
73
        push @messages, { code => 'success_on_delete' };
74
    }
74
    }
75
75
76
    $action = "list";
77
78
} elsif ( $action eq 'edit' ) { # Edit page of collection
76
} elsif ( $action eq 'edit' ) { # Edit page of collection
79
    my $collection = Koha::RotatingCollections->find($query->param('colId'));
77
    my $collection = Koha::RotatingCollections->find($query->param('colId'));
80
78
81
    $template->param(
79
    $template->param(
82
        previousActionEdit => 1,
80
        previousActionEdit => 1,
83
        editColId          => $collection->colId,
81
        collection         => $collection,
84
        editColTitle       => $collection->colTitle,
85
        editColDescription => $collection->colDesc,
86
    );
82
    );
87
83
88
} elsif ( $action eq 'update' ) { # Update collection
84
} elsif ( $action eq 'update' ) { # Update collection
Lines 90-95 if ( $action eq 'create' ) { Link Here
90
    my $title       = $query->param('title');
86
    my $title       = $query->param('title');
91
    my $description = $query->param('description');
87
    my $description = $query->param('description');
92
88
89
    $template->param( updatedTitle => $title );
90
93
    if ($colId) {
91
    if ($colId) {
94
        my $collection = Koha::RotatingCollections->find($colId);
92
        my $collection = Koha::RotatingCollections->find($colId);
95
        $collection->colTitle($title);
93
        $collection->colTitle($title);
Lines 98-116 if ( $action eq 'create' ) { Link Here
98
        eval { $collection->store; };
96
        eval { $collection->store; };
99
97
100
        if ($@) {
98
        if ($@) {
101
            push @messages, { type => 'error', code => 'error_on_update' };
99
            push @errors, { code => 'error_on_update' };
102
        } else {
100
        } else {
103
            push @messages, { type => 'message', code => 'success_on_update' };
101
            push @messages, { code => 'success_on_update' };
104
        }
102
        }
105
106
        $action = "list";
107
    }
103
    }
108
109
}
104
}
110
105
111
$template->param(
106
$template->param(
112
    action   => $action,
107
    action   => $action,
113
    messages => \@messages,
108
    messages => \@messages,
109
    errors   => \@errors,
114
);
110
);
115
111
116
output_html_with_http_headers $query, $cookie, $template->output;
112
output_html_with_http_headers $query, $cookie, $template->output;
117
- 

Return to bug 18606