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

(-)a/C4/Suggestions.pm (-1 / +1 lines)
Lines 682-688 sub MarcRecordFromNewSuggestion { Link Here
682
    }
682
    }
683
    else {
683
    else {
684
        $record->append_fields(
684
        $record->append_fields(
685
            MARC::Field->new($it_tag, ' ', ' ', $it_subfield => $suggestion->{author})
685
            MARC::Field->new($it_tag, ' ', ' ', $it_subfield => $suggestion->{itemtype})
686
        );
686
        );
687
    }
687
    }
688
688
(-)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 (-39 / +58 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 121-177 $template->param('borrowernumber' => $borrowernumber); Link Here
121
#########################################
123
#########################################
122
##  Operations
124
##  Operations
123
##
125
##
126
124
if ( $op =~ /save/i ) {
127
if ( $op =~ /save/i ) {
125
    $suggestion_only->{suggesteddate} = dt_from_string( $suggestion_only->{suggesteddate} )
128
    my @messages;
126
        if $suggestion_only->{suggesteddate};
129
    my $biblio = MarcRecordFromNewSuggestion({
130
            title => $suggestion_only->{title},
131
            author => $suggestion_only->{author},
132
            itemtype => $suggestion_only->{itemtype},
133
    });
134
135
    if ( ( my ($duplicatebiblionumber, $duplicatetitle) = FindDuplicate($biblio) ) && !$save_confirmed ) {
136
        push @messages, { type => 'error', code => 'biblio_exists', id => $duplicatebiblionumber, title => $duplicatetitle };
137
        $template->param(
138
            messages => \@messages,
139
            need_confirm => 1
140
        );
141
        delete $suggestion_ref->{suggesteddate};
142
        Init($suggestion_ref);
143
    }
144
    else {
145
        $suggestion_only->{suggesteddate} = dt_from_string( $suggestion_only->{suggesteddate} )
146
            if $suggestion_only->{suggesteddate};
127
147
128
    if ( $suggestion_only->{"STATUS"} ) {
148
        if ( $suggestion_only->{"STATUS"} ) {
129
        if ( my $tmpstatus = lc( $suggestion_only->{"STATUS"} ) =~ /ACCEPTED|REJECTED/i ) {
149
            if ( my $tmpstatus = lc( $suggestion_only->{"STATUS"} ) =~ /ACCEPTED|REJECTED/i ) {
130
            $suggestion_only->{ lc( $suggestion_only->{"STATUS"}) . "date" } = dt_from_string;
150
                $suggestion_only->{ lc( $suggestion_only->{"STATUS"}) . "date" } = dt_from_string;
131
            $suggestion_only->{ lc( $suggestion_only->{"STATUS"}) . "by" }   = C4::Context->userenv->{number};
151
                $suggestion_only->{ lc( $suggestion_only->{"STATUS"}) . "by" }   = C4::Context->userenv->{number};
152
            }
153
            $suggestion_only->{manageddate} = dt_from_string;
154
            $suggestion_only->{"managedby"}   = C4::Context->userenv->{number};
132
        }
155
        }
133
        $suggestion_only->{manageddate} = dt_from_string;
134
        $suggestion_only->{"managedby"}   = C4::Context->userenv->{number};
135
    }
136
156
137
    my $otherreason = $input->param('other_reason');
157
        my $otherreason = $input->param('other_reason');
138
    if ($suggestion_only->{reason} eq 'other' && $otherreason) {
158
        if ($suggestion_only->{reason} eq 'other' && $otherreason) {
139
        $suggestion_only->{reason} = $otherreason;
159
            $suggestion_only->{reason} = $otherreason;
140
    }
160
        }
141
161
142
    if ( $suggestion_only->{'suggestionid'} > 0 ) {
162
        if ( $suggestion_only->{'suggestionid'} > 0 ) {
143
        &ModSuggestion($suggestion_only);
163
            &ModSuggestion($suggestion_only);
144
    } else {
164
        } else {
145
        ###FIXME:Search here if suggestion already exists.
165
            ###FIXME:Search here if suggestion already exists.
146
        my $suggestions_loop =
166
            my $suggestions_loop =
147
            SearchSuggestion( $suggestion_only );
167
                SearchSuggestion( $suggestion_only );
148
        if (@$suggestions_loop>=1){
168
            if (@$suggestions_loop>=1){
149
            #some suggestion are answering the request Donot Add
169
                #some suggestion are answering the request Donot Add
150
            my @messages;
170
                my @messages;
151
            for my $suggestion ( @$suggestions_loop ) {
171
                for my $suggestion ( @$suggestions_loop ) {
152
                push @messages, { type => 'error', code => 'already_exists', id => $suggestion->{suggestionid} };
172
                    push @messages, { type => 'error', code => 'already_exists', id => $suggestion->{suggestionid} };
173
                }
174
                $template->param( messages => \@messages );
175
            }
176
            else {
177
                ## Adding some informations related to suggestion
178
                &NewSuggestion($suggestion_only);
153
            }
179
            }
154
            $template->param( messages => \@messages );
180
            # empty fields, to avoid filter in "SearchSuggestion"
155
        } 
156
        else {    
157
            ## Adding some informations related to suggestion
158
            &NewSuggestion($suggestion_only);
159
        }
181
        }
160
        # empty fields, to avoid filter in "SearchSuggestion"
182
        map{delete $$suggestion_ref{$_}} keys %$suggestion_ref;
161
    }  
183
        $op = 'else';
162
    map{delete $$suggestion_ref{$_}} keys %$suggestion_ref;
163
    $op = 'else';
164
184
165
    if( $redirect eq 'purchase_suggestions' ) {
185
        if( $redirect eq 'purchase_suggestions' ) {
166
        print $input->redirect("/cgi-bin/koha/members/purchase-suggestions.pl?borrowernumber=$borrowernumber");
186
            print $input->redirect("/cgi-bin/koha/members/purchase-suggestions.pl?borrowernumber=$borrowernumber");
187
        }
167
    }
188
    }
168
169
}
189
}
170
elsif ($op=~/add/) {
190
elsif ($op=~/add/) {
171
    #Adds suggestion  
191
    #Adds suggestion
172
    Init($suggestion_ref);
192
    Init($suggestion_ref);
173
    $op ='save';
193
    $op ='save';
174
} 
194
}
175
elsif ($op=~/edit/) {
195
elsif ($op=~/edit/) {
176
    #Edit suggestion  
196
    #Edit suggestion  
177
    $suggestion_ref=&GetSuggestion($$suggestion_ref{'suggestionid'});
197
    $suggestion_ref=&GetSuggestion($$suggestion_ref{'suggestionid'});
178
- 

Return to bug 14973