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

Return to bug 14963