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

(-)a/C4/Suggestions.pm (-1 / +1 lines)
Lines 688-694 sub MarcRecordFromNewSuggestion { Link Here
688
    }
688
    }
689
    else {
689
    else {
690
        $record->append_fields(
690
        $record->append_fields(
691
            MARC::Field->new($it_tag, ' ', ' ', $it_subfield => $suggestion->{author})
691
            MARC::Field->new($it_tag, ' ', ' ', $it_subfield => $suggestion->{itemtype})
692
        );
692
        );
693
    }
693
    }
694
694
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt (-1 / +31 lines)
Lines 239-244 Link Here
239
[% END %]
239
[% END %]
240
240
241
[% IF ( op_save ) %]
241
[% IF ( op_save ) %]
242
    [% FOR m IN messages %]
243
        <div class="dialog [% m.type %]">
244
            [% SWITCH m.code %]
245
            [% CASE 'biblio_exists' %]
246
                A similar document already exists: <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% m.id %]">[% m.title %]</a>. Click on "Confirm your suggestion" to ignore this message.
247
            [% CASE %]
248
                [% m.code %]
249
            [% END %]
250
        </div>
251
    [% END %]
242
    <form id="add_edit" action="suggestion.pl" method="post" class="validated">
252
    <form id="add_edit" action="suggestion.pl" method="post" class="validated">
243
    <input type="hidden" name="redirect" id="redirect" value="[% redirect | html %]" />
253
    <input type="hidden" name="redirect" id="redirect" value="[% redirect | html %]" />
244
    <input type="hidden" name="borrowernumber" id="borrowernumber" value="[% borrowernumber | html %]" />
254
    <input type="hidden" name="borrowernumber" id="borrowernumber" value="[% borrowernumber | html %]" />
Lines 410-416 Link Here
410
			<input type="text" readonly="readonly" id="total" name="total" size="10" value="[% total | html %]"/>
420
			<input type="text" readonly="readonly" id="total" name="total" size="10" value="[% total | html %]"/>
411
                </li></ol>
421
                </li></ol>
412
    </fieldset><input type="hidden" id="returnsuggested" name="returnsuggested" value="[% IF ( returnsuggestedby ) %][% returnsuggestedby | html %][% ELSE %]noone[% END %]"/>
422
    </fieldset><input type="hidden" id="returnsuggested" name="returnsuggested" value="[% IF ( returnsuggestedby ) %][% returnsuggestedby | html %][% ELSE %]noone[% END %]"/>
413
    <fieldset class="action"><input type="hidden" name="op" value="[% op | html %]" />[% IF ( suggestionid ) %]<input type="submit" value="Save" /> <a class="cancel" href="[% IF ( returnsuggestedby ) %]/cgi-bin/koha/members/moremember.pl?borrowernumber=[% returnsuggestedby | uri %]#suggestions[% ELSE %]suggestion.pl[% END %]">Cancel</a>[% ELSE %]<input type="submit" value="Submit your suggestion" /> <a class="cancel" href="suggestion.pl">Cancel</a>[% END %]
423
    <fieldset class="action">
424
        <input type="hidden" name="op" value="[% op | html %]" />
425
        [% IF ( suggestionid ) %]
426
            [% IF ( need_confirm ) %]
427
                <input type="hidden" name="save_confirmed" value="1" />
428
                <input onclick="this.form.op.value = 'save'; this.form.submit();" type="submit" value="Confirm your suggestion" />
429
            [% ELSE %]
430
                <input type="submit" value="Save" />
431
            [% END %]
432
            <a class="cancel" href="[% IF ( returnsuggestedby ) %]/cgi-bin/koha/members/moremember.pl?borrowernumber=[% returnsuggestedby | uri %]#suggestions[% ELSE %]suggestion.pl[% END %]">Cancel</a>
433
        [% ELSE %]
434
            [% IF ( need_confirm ) %]
435
                <input type="hidden" name="save_confirmed" value="1" />
436
                <input onclick="this.form.op.value = 'save'; this.form.submit();" type="submit" value="Confirm your suggestion" />
437
            [% ELSE %]
438
                <input type="submit" value="Submit your suggestion" />
439
            [% END %]
440
            <a class="cancel" href="suggestion.pl">Cancel</a>
441
        [% END %]
414
    </fieldset>
442
    </fieldset>
415
    </form>
443
    </form>
416
[% END %]
444
[% END %]
Lines 428-433 Link Here
428
        [% SWITCH m.code %]
456
        [% SWITCH m.code %]
429
        [% CASE 'already_exists' %]
457
        [% CASE 'already_exists' %]
430
            The suggestion has not been added. A suggestion with this title already exists (<a href='/cgi-bin/koha/suggestion/suggestion.pl?suggestionid=[% m.id | html %]&op=show'>suggestion #[% m.id | html %]</a>)
458
            The suggestion has not been added. A suggestion with this title already exists (<a href='/cgi-bin/koha/suggestion/suggestion.pl?suggestionid=[% m.id | html %]&op=show'>suggestion #[% m.id | html %]</a>)
459
        [% CASE 'biblio_exists' %]
460
            A similar document already exists: <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% m.id %]">[% m.title %]</a>. Click on "Confirm your suggestion" to ignore this message.
431
        [% CASE %]
461
        [% CASE %]
432
            [% m.code | html %]
462
            [% m.code | html %]
433
        [% END %]
463
        [% END %]
(-)a/suggestion/suggestion.pl (-41 / +60 lines)
Lines 91-96 my $returnsuggested = $input->param('returnsuggested'); Link Here
91
my $managedby       = $input->param('managedby');
91
my $managedby       = $input->param('managedby');
92
my $displayby       = $input->param('displayby') || '';
92
my $displayby       = $input->param('displayby') || '';
93
my $tabcode         = $input->param('tabcode');
93
my $tabcode         = $input->param('tabcode');
94
my $save_confirmed  = $input->param('save_confirmed') || 0;
95
94
my $reasonsloop     = GetAuthorisedValues("SUGGEST");
96
my $reasonsloop     = GetAuthorisedValues("SUGGEST");
95
97
96
# filter informations which are not suggestion related.
98
# filter informations which are not suggestion related.
Lines 122-181 my $branchfilter = $input->param('branchcode') || C4::Context->userenv->{'branch Link Here
122
#########################################
124
#########################################
123
##  Operations
125
##  Operations
124
##
126
##
125
if ( $op =~ /save/i ) {
126
127
127
    for my $date_key ( qw( suggesteddate manageddate accepteddate rejecteddate ) ) {
128
if ( $op =~ /save/i ) {
128
        $suggestion_only->{$date_key} = dt_from_string( $suggestion_only->{$date_key} )
129
    my @messages;
129
            if $suggestion_only->{$date_key};
130
    my $biblio = MarcRecordFromNewSuggestion({
131
            title => $suggestion_only->{title},
132
            author => $suggestion_only->{author},
133
            itemtype => $suggestion_only->{itemtype},
134
    });
135
136
    if ( ( my ($duplicatebiblionumber, $duplicatetitle) = FindDuplicate($biblio) ) && !$save_confirmed ) {
137
        push @messages, { type => 'error', code => 'biblio_exists', id => $duplicatebiblionumber, title => $duplicatetitle };
138
        $template->param(
139
            messages => \@messages,
140
            need_confirm => 1
141
        );
142
        delete $suggestion_ref->{suggesteddate};
143
        Init($suggestion_ref);
130
    }
144
    }
145
    else {
131
146
132
    if ( $suggestion_only->{"STATUS"} ) {
147
        for my $date_key ( qw( suggesteddate manageddate accepteddate rejecteddate ) ) {
133
        if ( my $tmpstatus = lc( $suggestion_only->{"STATUS"} ) =~ /ACCEPTED|REJECTED/i ) {
148
            $suggestion_only->{$date_key} = dt_from_string( $suggestion_only->{$date_key} )
134
            $suggestion_only->{ lc( $suggestion_only->{"STATUS"}) . "date" } = dt_from_string;
149
                if $suggestion_only->{$date_key};
135
            $suggestion_only->{ lc( $suggestion_only->{"STATUS"}) . "by" }   = C4::Context->userenv->{number};
136
        }
150
        }
137
        $suggestion_only->{manageddate} = dt_from_string;
138
        $suggestion_only->{"managedby"}   = C4::Context->userenv->{number};
139
    }
140
151
141
    my $otherreason = $input->param('other_reason');
152
        if ( $suggestion_only->{"STATUS"} ) {
142
    if ($suggestion_only->{reason} eq 'other' && $otherreason) {
153
            if ( my $tmpstatus = lc( $suggestion_only->{"STATUS"} ) =~ /ACCEPTED|REJECTED/i ) {
143
        $suggestion_only->{reason} = $otherreason;
154
                $suggestion_only->{ lc( $suggestion_only->{"STATUS"}) . "date" } = dt_from_string;
144
    }
155
                $suggestion_only->{ lc( $suggestion_only->{"STATUS"}) . "by" }   = C4::Context->userenv->{number};
156
            }
157
            $suggestion_only->{manageddate} = dt_from_string;
158
            $suggestion_only->{"managedby"}   = C4::Context->userenv->{number};
159
        }
160
161
        my $otherreason = $input->param('other_reason');
162
        if ($suggestion_only->{reason} eq 'other' && $otherreason) {
163
            $suggestion_only->{reason} = $otherreason;
164
        }
145
165
146
    if ( $suggestion_only->{'suggestionid'} > 0 ) {
166
        if ( $suggestion_only->{'suggestionid'} > 0 ) {
147
        &ModSuggestion($suggestion_only);
167
            &ModSuggestion($suggestion_only);
148
    } else {
168
        } else {
149
        ###FIXME:Search here if suggestion already exists.
169
            ###FIXME:Search here if suggestion already exists.
150
        my $suggestions_loop =
170
            my $suggestions_loop =
151
            SearchSuggestion( $suggestion_only );
171
                SearchSuggestion( $suggestion_only );
152
        if (@$suggestions_loop>=1){
172
            if (@$suggestions_loop>=1){
153
            #some suggestion are answering the request Donot Add
173
                #some suggestion are answering the request Donot Add
154
            my @messages;
174
                my @messages;
155
            for my $suggestion ( @$suggestions_loop ) {
175
                for my $suggestion ( @$suggestions_loop ) {
156
                push @messages, { type => 'error', code => 'already_exists', id => $suggestion->{suggestionid} };
176
                    push @messages, { type => 'error', code => 'already_exists', id => $suggestion->{suggestionid} };
177
                }
178
                $template->param( messages => \@messages );
179
            }
180
            else {
181
                ## Adding some informations related to suggestion
182
                &NewSuggestion($suggestion_only);
157
            }
183
            }
158
            $template->param( messages => \@messages );
184
            # empty fields, to avoid filter in "SearchSuggestion"
159
        } 
160
        else {    
161
            ## Adding some informations related to suggestion
162
            &NewSuggestion($suggestion_only);
163
        }
185
        }
164
        # empty fields, to avoid filter in "SearchSuggestion"
186
        map{delete $$suggestion_ref{$_}} keys %$suggestion_ref;
165
    }  
187
        $op = 'else';
166
    map{delete $$suggestion_ref{$_}} keys %$suggestion_ref;
167
    $op = 'else';
168
188
169
    if( $redirect eq 'purchase_suggestions' ) {
189
        if( $redirect eq 'purchase_suggestions' ) {
170
        print $input->redirect("/cgi-bin/koha/members/purchase-suggestions.pl?borrowernumber=$borrowernumber");
190
            print $input->redirect("/cgi-bin/koha/members/purchase-suggestions.pl?borrowernumber=$borrowernumber");
191
        }
171
    }
192
    }
172
173
}
193
}
174
elsif ($op=~/add/) {
194
elsif ($op=~/add/) {
175
    #Adds suggestion  
195
    #Adds suggestion
176
    Init($suggestion_ref);
196
    Init($suggestion_ref);
177
    $op ='save';
197
    $op ='save';
178
} 
198
}
179
elsif ($op=~/edit/) {
199
elsif ($op=~/edit/) {
180
    #Edit suggestion  
200
    #Edit suggestion  
181
    $suggestion_ref=&GetSuggestion($$suggestion_ref{'suggestionid'});
201
    $suggestion_ref=&GetSuggestion($$suggestion_ref{'suggestionid'});
182
- 

Return to bug 14973