Bug 6750 Guarantor search broken on translated templates

Fix the JavaScript to avoid implementing complex string substitution into JS
function call. This patch solves the bug and keep the ability to copy
borrower's address, name, etc., containing new line, simple quote, etc.

Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
(cherry picked from commit f64aaf063e)

Signed-off-by: Chris Nighswonger <chris.nighswonger@gmail.com>
This commit is contained in:
Frédéric Demians 2011-09-01 10:09:48 +02:00 committed by Chris Nighswonger
parent fa1ed689e3
commit 429322795d
1 changed files with 32 additions and 6 deletions

View File

@ -6,7 +6,19 @@
</style>
<script type="text/javascript">
<!--
function fillguarantor(id, surname, firstname, streetnumber, address, address2, city, state, zipcode, country, branchcode) {
function fillguarantor(id) {
var $ = window.$;
var surname = $('#' + id + 'surname').text();
var firstname = $('#' + id + 'firstname').text();
var streetnumber = $('#' + id + 'streetnumber').text();
var address = $('#' + id + 'address').text();
var address2 = $('#' + id + 'address2').text();
var city = $('#' + id + 'city').text();
var state = $('#' + id + 'state').text();
var zipcode = $('#' + id + 'zipcode').text();
var country = $('#' + id + 'country').text();
var branchcode = $('#' + id + 'branchcode').text();
var $ = window.opener.$;
var form = $('#entryform').get(0);
@ -71,16 +83,30 @@
<th>Select?</th>
</tr>
[% FOREACH resultsloo IN resultsloop %]
[% import(resultsloo) %]
<tr>
<td>[% resultsloo.cardnumber %]</td>
<td>[% cardnumber %]</td>
<td>
[% resultsloo.surname %], [% resultsloo.firstname %]
[% surname %], [% firstname %]
</td>
<td>[% resultsloo.dateofbirth %]</td>
<td><p>[% resultsloo.address %] [% resultsloo.address2 %] [% resultsloo.city %] [% resultsloo.state %] [% resultsloo.zipcode %] [% resultsloo.country %]</p></td>
<td>[% dateofbirth %]</td>
<td><p>[% address %] [% address2 %] [% city %] [% state %] [% zipcode %] [% country %]</p></td>
<td>
<span style="display:none;">
<span id="[% borrowernumber %]surname">[% surname %]</span>
<span id="[% borrowernumber %]firstname">[% firstname %]</span>
<span id="[% borrowernumber %]streetnumber">[% streetnumber %]</span>
<span id="[% borrowernumber %]address">[% address %]</span>
<span id="[% borrowernumber %]address2">[% address2 %]</span>
<span id="[% borrowernumber %]city">[% city %]</span>
<span id="[% borrowernumber %]state">[% state %]</span>
<span id="[% borrowernumber %]zipcode">[% zipcode %]</span>
<span id="[% borrowernumber %]country">[% country %]</span>
<span id="[% borrowernumber %]branchcode">[% branchcode %]</span>
</span>
<form action="">
<input type="button" onclick="fillguarantor('[% resultsloo.borrowernumber %]', '[% resultsloo.surname |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]', '[% resultsloo.firstname |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]', '[% resultsloo.streetnumber |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]', '[% resultsloo.address |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]','[% resultsloo.address2 |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]', '[% resultsloo.city |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]', '[% resultsloo.state |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]','[% resultsloo.zipcode |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]','[% resultsloo.country |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]','[% resultsloo.branchcode |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]'); return false;" value="Select"/>
<input type="button" onclick="fillguarantor('[% borrowernumber %]'); return false;" value="Select"/>
</form>
</td>
</tr>