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