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