FSN#25848 Forse code refactoring. Geen functionele wijzigingen
svn path=/Website/trunk/; revision=19582
This commit is contained in:
@@ -8,8 +8,6 @@
|
||||
var dateInputs = new Object();
|
||||
function checkFactuurExistCallback(json, textStatus)
|
||||
{
|
||||
if (textStatus == "success")
|
||||
{
|
||||
if (json.aantal > 0)
|
||||
if (confirm(L("lcl_fin_invoice_number") + " " + json.fac_nr + L("lcl_fin_is_al") + json.aantal + L("lcl_fin_register_total") + json.totaal + ". " + L("lcl_fin_toch_doorgaan")))
|
||||
document.forms.u2.submit();
|
||||
@@ -17,25 +15,20 @@ function checkFactuurExistCallback(json, textStatus)
|
||||
return false;
|
||||
else
|
||||
document.forms.u2.submit();
|
||||
}
|
||||
else
|
||||
alert("checkFactuurExistCallback: " + textStatus);
|
||||
}
|
||||
|
||||
function checkInput()
|
||||
{
|
||||
var filled_lines = 0;
|
||||
var blank_lines = 0;
|
||||
for (i = 0; i < selectedItems.length; i++) //i.v.m. prototype.js
|
||||
|
||||
$("table#sel_items input[id^=sum]").each(function()
|
||||
{
|
||||
if (selectedItems[i] != null)
|
||||
{
|
||||
if (parseFloat(document.getElementById("sum" + i).value.replace(',', '.')) != 0)
|
||||
if (myParseFloat($(this).val()) != 0)
|
||||
filled_lines++;
|
||||
else
|
||||
blank_lines++;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (!filled_lines)
|
||||
{ // Er zijn geen volledig ingevulde factuurregels.
|
||||
@@ -161,14 +154,14 @@ function FcltGetRefInfoCallback(json)
|
||||
{
|
||||
// Hoeveel factuurregels zijn er?
|
||||
var count = 0;
|
||||
for (i in selectedItems)
|
||||
$("table#sel_items input[id^=sum]").each(function()
|
||||
{
|
||||
if (selectedItems[i] != null)
|
||||
count++;
|
||||
}
|
||||
if (myParseFloat($(this).val()) != 0)
|
||||
count++;
|
||||
});
|
||||
|
||||
// Als er door de referenties verschillende btw tabellen wordt gebruikt terwijl er factuurregels zijn, dan wijziging niet accepteren en melding geven
|
||||
if (count > 0 && $("#btwtabel_key").val() != json.btwtabel_key)
|
||||
if (count > 0 && window.btwtabel_key != json.btwtabel_key)
|
||||
{
|
||||
alert(L("lcl_fin_ref_btw_diff"));
|
||||
$("#referentienr").val($("#referentienr_old").val());
|
||||
@@ -184,8 +177,8 @@ function FcltGetRefInfoCallback(json)
|
||||
{
|
||||
$('#lev_uit').click(function()
|
||||
{
|
||||
refurl = "appl/prs/prs_show_bedrijf.asp?bedrijf_key=" + json.lev_uit_key; // TODO: Welke urole moet meegegeven worden fo/bo. Nu is fo gekozen
|
||||
FcltMgr.openDetail(refurl, json.lev_uit);
|
||||
refurl = "appl/prs/prs_bedrijf.asp?bedrijf_key=" + json.lev_uit_key;
|
||||
FcltMgr.openDetail(refurl);
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -225,10 +218,6 @@ function FcltGetRefInfoCallback(json)
|
||||
|
||||
if (json.show_omschr)
|
||||
{
|
||||
// De opdracht omschrijving niet in een <textarea> omdat dit veld bij contact en bestelling referenties niet zichtbaar is
|
||||
// Dit omdat de functie $('textarea').autogrow() dan de foutmelding "Invalid argument." geeft. (standaard jquery component)
|
||||
//$("#opdr_omschr").html('<textarea class="fldtxt" readonly>' + json.opdr_omschr + "</textarea>");
|
||||
//$('textarea').autogrow(); // Zet de textarea van de opdracht omschrijving weer helemaal open, zodat alle text zichtbaar is
|
||||
$("#opdr_omschr").html(json.opdr_omschr);
|
||||
$("#tr_opdr_omschr").show();
|
||||
}
|
||||
@@ -278,8 +267,8 @@ function FcltGetRefInfoCallback(json)
|
||||
{
|
||||
$('#reflink').click(function()
|
||||
{
|
||||
refurl = "appl/mld/mld_opdr.asp?urole=fo&opdr_key=" + json.ref_key; // TODO: Welke urole moet meegegeven worden fo/bo. Nu is fo gekozen
|
||||
FcltMgr.openDetail(refurl, L("lcl_shared_order") + " " + json.referentie);
|
||||
refurl = "appl/mld/mld_opdr.asp?urole=fo&opdr_key=" + json.ref_key;
|
||||
FcltMgr.openDetail(refurl);
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -296,8 +285,8 @@ function FcltGetRefInfoCallback(json)
|
||||
{
|
||||
$('#reflink').click(function()
|
||||
{
|
||||
refurl = "appl/bes/bes_opdr.asp?urole=fo&ordernr=" + json.ref_key // TODO: Welke urole moet meegegeven worden fo/bo. Nu is fo gekozen
|
||||
FcltMgr.openDetail(refurl, L("lcl_fin_bestelopdracht") + " " + bes_bestelling_prefix + json.referentie);
|
||||
refurl = "appl/bes/bes_opdr.asp?urole=fo&ordernr=" + json.ref_key
|
||||
FcltMgr.openDetail(refurl);
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -311,33 +300,24 @@ function FcltGetRefInfoCallback(json)
|
||||
{
|
||||
$('#reflink').click(function()
|
||||
{
|
||||
refurl = "appl/CNT/cnt_contract.asp?urole=fo&cnt_key=" + json.ref_key // TODO: Welke urole moet meegegeven worden fo/bo. Nu is fo gekozen
|
||||
FcltMgr.openDetail(refurl, L("lcl_fin_contract") + " " + json.referentie);
|
||||
refurl = "appl/cnt/cnt_contract.asp?urole=fo&cnt_key=" + json.ref_key;
|
||||
FcltMgr.openDetail(refurl);
|
||||
}
|
||||
);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (json.aantalfacturen > 0)
|
||||
{
|
||||
$("#fincnt").val(json.aantalfacturen);
|
||||
$("#finsom").val(currency_pref + json.totaalbedrag + currency_suff);
|
||||
FcltMgr.resized(window);
|
||||
}
|
||||
else
|
||||
{
|
||||
$("#fincnt").val(json.aantalfacturen);
|
||||
$("#finsom").val(currency_pref + json.totaalbedrag + currency_suff);
|
||||
}
|
||||
$("#fincnt").val(json.aantalfacturen);
|
||||
$("#finsom").val(currency_pref + json.totaalbedrag + currency_suff);
|
||||
|
||||
$("#btwtabel_key").val(json.btwtabel_key);
|
||||
btwtabel = json.btwtabel;
|
||||
window.btwtabel_key = json.btwtabel_key;
|
||||
window.btwtabel = json.btwtabel;
|
||||
|
||||
if (count == 0 && json.refchanged && fin_key == -1)
|
||||
{
|
||||
AddItem();
|
||||
$("#show_calendar").focus();
|
||||
$("#show_calendar").focus(); // Het eerstvolgende veld
|
||||
}
|
||||
|
||||
FcltMgr.resized(window);
|
||||
@@ -365,11 +345,10 @@ function referenceChanged(refchanged)
|
||||
|
||||
function updateLocation()
|
||||
{
|
||||
for (var i = 0; i <= rowIndex; i++)
|
||||
$("table#sel_items input[id^=ref]").each(function()
|
||||
{
|
||||
if ($("#ref" + i).length)
|
||||
$("#ref" + i).val($("#loc_code").val());
|
||||
}
|
||||
$(this).val($("#loc_code").val());
|
||||
});
|
||||
}
|
||||
|
||||
function checkDividePeriod(value)
|
||||
@@ -423,3 +402,153 @@ function kenmerkDividePeriodChange(evt)
|
||||
if (el.value != oldT) el.value = oldT;
|
||||
}
|
||||
|
||||
function myParseFloat(txt)
|
||||
{
|
||||
txt = txt.replace(currency_pref, "");
|
||||
txt = txt.replace(currency_suff, "");
|
||||
return parseFloat(txt.replace(',', '.'));
|
||||
}
|
||||
|
||||
// Array selectedItems is vervallen 5.3.3; we houden alles in de HTML bij
|
||||
|
||||
// Werk het totaal van een regel en het totaal generaal bij
|
||||
// obj is mogelijk een van de velden in regel, welke doet er niet zo toe
|
||||
function setPrice(obj)
|
||||
{
|
||||
if (obj)
|
||||
{
|
||||
var $row = $(obj).closest("tr");
|
||||
var btwkey = $row.find("[id^=BTW]").val();
|
||||
var sum = myParseFloat($row.find("[id^=sum]").val());
|
||||
|
||||
for (var j = 0; j < window.btwtabel.length; j++)
|
||||
{
|
||||
if (btwkey == btwtabel[j].key)
|
||||
btwdata = btwtabel[j];
|
||||
}
|
||||
|
||||
var sumBTW = sum;
|
||||
if (!btwdata.verlegd)
|
||||
sumBTW = sumBTW * (1 + btwdata.perc / 100);
|
||||
$row.find("[id^=sumBTW]").val(currency_pref + num2curr(sumBTW) + currency_suff);
|
||||
}
|
||||
// Nu totaal bijwerken
|
||||
var totalBTW = 0;
|
||||
$("table#sel_items input[id^=sumBTW]").each(function()
|
||||
{
|
||||
totalBTW += myParseFloat($(this).val());
|
||||
});
|
||||
|
||||
$("#totalBTW_txt").html(currency_pref + num2curr(totalBTW) + currency_suff);
|
||||
}
|
||||
|
||||
// Voeg een ieuwe regel toe na het plus-knopje
|
||||
function AddItem() // als je hieronder iets aanpast controleer dan ook fin.inc/CreateEditRow
|
||||
{
|
||||
var sum = 0;
|
||||
var descr = "";
|
||||
var BTW = -1; /*DUMMY*/
|
||||
var sumBTW = 0;
|
||||
var ref = $("#loc_code").val();
|
||||
var ksrt_key = -1;
|
||||
var ksrt_oms = "";
|
||||
var verlegd = 0;
|
||||
|
||||
var rowIndex = parseInt($("#rowIndex").val());
|
||||
rowIndex++;
|
||||
$("#rowIndex").val(rowIndex);
|
||||
|
||||
var table = $("#sel_items")[0];
|
||||
|
||||
// Insert data rows
|
||||
var tr = table.insertRow(-1);
|
||||
|
||||
// Create drop button
|
||||
cell = tr.insertCell(-1);
|
||||
cell.innerHTML = "<img src='../Pictures/order_cancel.gif' OnClick='DeleteOrderLine(this)' style='cursor:pointer'>";
|
||||
|
||||
// Create description field
|
||||
cell = tr.insertCell(-1);
|
||||
cell.innerHTML = "<input type='text' class='fld'"
|
||||
+ " id='descript" + rowIndex + "' name='descript" + rowIndex + "' maxlength='50' value='" + descr + "'>";
|
||||
|
||||
// Create reference field
|
||||
cell = tr.insertCell(-1);
|
||||
cell.innerHTML = "<input type='text' class='fldfinref'"
|
||||
+ " id='ref" + rowIndex + "' name='ref" + rowIndex + "' maxlength=30 value='" + ref + "'>"; // TODO: escapen
|
||||
|
||||
if (fin_enable_kostensoort != 0)
|
||||
{ // Create charge type field
|
||||
cell = tr.insertCell(-1);
|
||||
cell.innerHTML = "<input id='fincostsrt" + rowIndex + "_show' class='fldcontactpers' value='" + ksrt_oms + "'" + ">"
|
||||
+ "<input type='hidden' id='fincostsrt" + rowIndex + "' name='fincostsrt" + rowIndex + "' value='" + ksrt_key + "'>";
|
||||
|
||||
var x = new Suggest({ objectName: "sgCostCentre" + rowIndex,
|
||||
queryField: $("#fincostsrt" + rowIndex + "_show")[0],
|
||||
queryUrl: "../shared/suggest/SuggestKostensoort.asp?a=1",
|
||||
initKey: ksrt_key,
|
||||
keyField: $("#fincostsrt" + rowIndex)[0],
|
||||
highlightDescript: true
|
||||
});
|
||||
window["sgCostCentre" + rowIndex] = x;
|
||||
}
|
||||
|
||||
// Create sum field
|
||||
cell = tr.insertCell(-1);
|
||||
cell.innerHTML = "<input type='text' class='fldfinbedrag'"
|
||||
+ " id='sum" + rowIndex + "' name='sum" + rowIndex + "' maxlength=10 value='" + num2curr(sum) + "'>";
|
||||
cell.align = 'right';
|
||||
|
||||
// Create BTW field
|
||||
cell = tr.insertCell(-1);
|
||||
|
||||
var htmlText = "<select type='text' class='fldfinbtw' id='BTW" + rowIndex
|
||||
+ "' name='BTW" + rowIndex + "'>"
|
||||
for (var j = 0; j < btwtabel.length; j++)
|
||||
{
|
||||
htmlText += "<option value='" + btwtabel[j].key + "' "
|
||||
+ (fin_btw_default == btwtabel[j].key? "selected" : "") + ">"
|
||||
+ btwtabel[j].oms + "</option>"; // TODO: escapen
|
||||
}
|
||||
htmlText += "</select>";
|
||||
cell.innerHTML = htmlText;
|
||||
cell.align = 'right';
|
||||
|
||||
// Sum incl. tax
|
||||
cell = tr.insertCell(-1);
|
||||
cell.innerHTML = "<input type='text' class='fldfinbedrag' readonly='1' id='sumBTW" + rowIndex
|
||||
+ "' value='" + currency_pref + num2curr(sumBTW) + "'>";
|
||||
cell.align = 'right';
|
||||
|
||||
document.getElementById("descript" + rowIndex).focus();
|
||||
|
||||
}
|
||||
|
||||
function DeleteOrderLine(obj)
|
||||
{
|
||||
if (!confirm(L("lcl_fin_cancelfac")))
|
||||
return;
|
||||
|
||||
var tr = $(obj).closest("tr");
|
||||
tr.remove();
|
||||
// remove from totalBTW
|
||||
setPrice(null);
|
||||
}
|
||||
|
||||
function SumChanged(obj)
|
||||
{
|
||||
var sum = myParseFloat(obj.value);
|
||||
var defaultamount = 0;
|
||||
if (obj.value == '')
|
||||
obj.value = sum = defaultamount;
|
||||
if (obj.value == '' || isNaN(sum) ||
|
||||
!isGoodNumber(obj.value + "", false,false,8,2))
|
||||
{
|
||||
alert(L("lcl_fin_invalidSum"));
|
||||
obj.focus();
|
||||
return;
|
||||
}
|
||||
obj.value = num2curr(sum);
|
||||
|
||||
setPrice(obj);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user