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

(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-suggestions.tt (-7 / +30 lines)
Lines 29-37 Link Here
29
                            <h1>Enter a new purchase suggestion</h1>
29
                            <h1>Enter a new purchase suggestion</h1>
30
30
31
                            <p>Please fill out this form to make a purchase suggestion. You will receive an email when the library processes your suggestion</p>
31
                            <p>Please fill out this form to make a purchase suggestion. You will receive an email when the library processes your suggestion</p>
32
                            <p>Only the title is required, but the more information you enter the easier it will be for the librarians to find the title you're requesting. The "Notes" field can be used to provide any additional information.</p>
32
                            [% IF (mandatoryfields) %]
33
                            <p>Form fields labeled in red are mandatory. The more information you enter the easier it will be for the librarians to find the title you're requesting.
34
                            [% ELSE %]
35
                            <p>Only the title is required, but the more information you enter the easier it will be for the librarians to find the title you're requesting.
36
                            [% END %]
37
                            The "Notes" field can be used to provide any additional information.</p>
33
38
34
                            <form action="/cgi-bin/koha/opac-suggestions.pl" method="post">
39
                            <form action="/cgi-bin/koha/opac-suggestions.pl" id="newsuggestionform" onsubmit="return Check(this);" method="post">
35
                                <fieldset class="rows">
40
                                <fieldset class="rows">
36
                                    <ol>
41
                                    <ol>
37
                                        <li><label class="required" for="title">Title:</label><input type="text" id="title" name="title" class="span6" maxlength="255" /></li>
42
                                        <li><label class="required" for="title">Title:</label><input type="text" id="title" name="title" class="span6" maxlength="255" /></li>
Lines 94-100 Link Here
94
                                <fieldset class="action">
99
                                <fieldset class="action">
95
                                    <input type="hidden" name="suggestedby" value="[% suggestedbyme %]" />
100
                                    <input type="hidden" name="suggestedby" value="[% suggestedbyme %]" />
96
                                    <input type="hidden" name="op" value="add_confirm" />
101
                                    <input type="hidden" name="op" value="add_confirm" />
97
                                    <input type="submit" onclick="Check(this.form); return false;" class="btn" value="Submit your suggestion" /> <a class="action" href="/cgi-bin/koha/opac-suggestions.pl">Cancel</a>
102
                                    <input type="submit" class="btn" value="Submit your suggestion" /> <a class="action" href="/cgi-bin/koha/opac-suggestions.pl">Cancel</a>
98
                                </fieldset>
103
                                </fieldset>
99
                            </form>
104
                            </form>
100
                        [% END #  IF op_add %]
105
                        [% END #  IF op_add %]
Lines 304-326 Link Here
304
          return true;
309
          return true;
305
        });
310
        });
306
        [% END %]
311
        [% END %]
312
        [% IF ( op_add && mandatoryfields ) %]
313
        var FldsRequired = [[% mandatoryfields %]];
314
        for (var i = 0; i < FldsRequired.length; i++) {
315
            var rqinput = $('#' + FldsRequired[i]);
316
            if (rqinput.length != 1) continue;
317
            $(rqinput).attr("required", "required");
318
            var rqlabel = $("label[for=" + rqinput.attr("id") + "]");
319
            if (rqlabel.length != 1) continue;
320
            $(rqlabel).addClass('required');
321
        }
322
        [% END %]
307
    });
323
    });
308
324
309
    function Check(f) {
325
    function Check(f) {
310
        var _alertString="";
326
        var _alertString="";
311
        var alertString2;
327
        var alertString2;
312
328
313
        if(f.title.value.length ==0){
329
        var FieldsRequired = [[% mandatoryfields %]];
314
            _alertString += _("- You must enter a Title") + "\n";
330
        FieldsRequired.unshift("title");
331
332
        for (var i = 0; i < FieldsRequired.length; i++) {
333
            var lbl = FieldsRequired[i];
334
            if (!f[lbl] || (f[lbl].value.length != 0)) continue;
335
            _alertString += _("- Some mandatory fields are missing") + "\n";
336
            break;
315
        }
337
        }
316
338
317
        if (_alertString.length==0) {
339
        if (_alertString.length == 0) {
318
            f.submit();
340
            return true;
319
        } else {
341
        } else {
320
            alertString2 = _("Form not submitted because of the following problem(s)");
342
            alertString2 = _("Form not submitted because of the following problem(s)");
321
            alertString2 += "\n------------------------------------------------------------------------------------\n\n";
343
            alertString2 += "\n------------------------------------------------------------------------------------\n\n";
322
            alertString2 += _alertString;
344
            alertString2 += _alertString;
323
            alert(alertString2);
345
            alert(alertString2);
346
            return false;
324
        }
347
        }
325
    }
348
    }
326
//]]>
349
//]]>
(-)a/opac/opac-suggestions.pl (-1 / +17 lines)
Lines 156-161 if ( C4::Context->preference("AllowPurchaseSuggestionBranchChoice") ) { Link Here
156
    $template->param( branchloop => $branchloop );
156
    $template->param( branchloop => $branchloop );
157
}
157
}
158
158
159
my $mandatoryfields = '';
160
{
161
    my $fldsreqsp = C4::Context->preference("OPACSuggestionMandatoryFields");
162
    last unless ($op eq 'add' && $fldsreqsp);
163
    my $supported_rf = {
164
        map { ($_, 1); } qw(
165
            author copyrightdate isbn publishercode collectiontitle
166
            place itemtype patronreason note
167
        )
168
    };
169
    my %fh = map {
170
        ($_ && $supported_rf->{$_})? ('"'.$_.'"', 1): ();
171
    } (split(/\s*\|\s*/, $fldsreqsp));
172
    $mandatoryfields = join(',', (sort keys %fh));
173
}
174
159
$template->param(
175
$template->param(
160
	%$suggestion,
176
	%$suggestion,
161
	itemtypeloop=> $supportlist,
177
	itemtypeloop=> $supportlist,
Lines 164-169 $template->param( Link Here
164
    showall    => $allsuggestions,
180
    showall    => $allsuggestions,
165
    "op_$op"         => 1,
181
    "op_$op"         => 1,
166
    suggestionsview => 1,
182
    suggestionsview => 1,
183
    mandatoryfields => $mandatoryfields,
167
);
184
);
168
185
169
output_html_with_http_headers $input, $cookie, $template->output;
186
output_html_with_http_headers $input, $cookie, $template->output;
170
- 

Return to bug 10848