Files
Fuchs_Intranet/Fuchs/wwwroot/web/fis.inv.de.js
T
Stefan bfc695ed6a Invoice set pricing: wire editor + align editor/backend contract
Front-end (fis.inv_shared.js / fis.inv_txt_de.js, rebuilt bundles):
- 3-way set display switch (setprice/itemprices/setonly) via admin.setmode,
  emitted into InvoiceOptions by FdsInvoiceData.BuildInvoiceOptions.
- Each request block now posts items[] in the backend contract shape
  (title/desc/qty/price_net/total_net + set type/setId tags) via itemToContract.
- invcPayload normalises the editor model to the field names BuildInvoiceParams
  reads (sms totals -> new.total_net/total_gross, invoicetitle->title,
  loc->provisionlocation, admin.paymentterms->new.paymentterm, CustomerId->customerid).

Back-end:
- BuildInvoiceOptions adds the setmode token alongside §13b.
- VAT rate+amount now taken from sms.vat (HighestVat) instead of the broken
  items 'is List<object>' detection that pinned the rate to 19.
- InvoiceSetPricing blanks price/total cells for text/title heading lines.

Tests: set-pricing text-line blanking, HighestVat selection/parsing, updated
the VAT param test to the sms.vat contract. 180 passing.

Note: the second VAT slot (InvoiceVAT_2) stays unused by design; mixed-rate
invoices store only the highest rate (pre-existing, accepted).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-06 10:48:14 +02:00

1845 lines
92 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
let $rct = {
mdl: 'Aufträge',
or: 'offene Aufträge',
orr: 'offene Aufträge (4 W)',
rn: 'Auftragsnummer',
iov: { all: 'Auftragsübersicht (alle)', '': 'Auftragsübersicht' },
wk: 'Woche',
nd: 'Keine Daten gefunden.',
h: 'Uhr',
rq1: 'Auftragsdaten werden von MFR abgerufen.\nDer Vorgang kann bis zu 90Sek dauern.',
rq2: 'Auftragsdaten werden geladen',
rq1f: 'Die Auftragsdaten von MFR konnten nicht oder nicht schnell genug abgerufen werde.\nMöchten Sie mit den bestehenden Daten trotzdem weitermachen?',
note1: 'Im Bruttobetrag sind {0} Lohnkosten enthalten (netto {1}). Die darin enthaltene Umsatzsteuer beträgt {2}.',
note2: 'Bitte beachten Sie, nach §14 Abs. 1 Umsatzsteuergesetz ist diese Rechnung ein Zahlungsbeleg oder eine andere beweiskräftige Unterlage für 2 Jahre nach Ablauf des Kalenderjahres der Ausstellung dieser Rechnung aufzubewahren, soweit nicht aufgrund anderer gesetzlicher Regelungen andere ggf.längere Aufbewahrungsfristen gelten.',
note3: 'Privathaushalten erstattet das Finanzamt bis zu {0} des Arbeitslohns mit der nächsten Steuererklärung.',
note4: 'Für bereits erbrachte Arbeiten, Dienstleistungen, Materiallieferungen und getätigte Bestellvorgänge zum oben genannten Bauvorhaben, die sich aus dem mit Ihnen geschlossenen Vertrag ergeben, stellen wir Ihnen vertragsgemäß unsere Akontozahlung in Rechnung. ' +
'Eine Endabrechnung erhalten Sie als Schlussrechnung nach Abschluss des gesamten Bauvorhabens. Das Ausführungsdatum entnehmen Sie bitte dem Schlusstext dieser Rechnung. Wir danken Ihnen herzlich für das entgegengebrachte Vertrauen und bitten Sie um kurzfristigen Ausgleich der Akontorechnung.',
note13b: 'Gem. §13b Umsatzsteuergesetz unterliegen Sie der Steuerschuldnerschaft des Leistungsempfängers zur Umsatzsteuer aus dieser Rechnung mit einem Steuersatz von 19%.',
crI: 'Rechnung erstellen',
crII: 'Abschlagsrechnung erstellen',
dII: 'Für eine Abschlagsrechnung darf nur ein Auftrag gewählt werden.',
dnS: 'Für eine Rechnung muss mindestens ein Auftrag gewählt werden.',
inv: 'Rechnung',
invs: 'Rechnungen',
req: 'Auftrag',
provP: 'Leistungszeitraum',
provD: 'Leistungsdatum',
cP: 'Position ändern',
iRb: 'Zeile darunter einfügen',
dR: 'Zeile löschen',
sV: 'USt festlegen',
cD: 'Löschen?',
mR: 'Zeile verschieben',
svcPart: 'Service-Anteil',
vat: 'Umsatzsteuer',
combP: 'Positionen zusammenfassen',
iSum: 'Zwischensumme',
dtRel: 'Freigegeben am: ',
dtCr: 'Erstellt am: ',
rqV: 'USt des Auftrags?',
cthd: 'wirklich aus-/einblenden ?',
cst: { style: 'currency', currency: 'EUR' },
sts: {
IsWorkDone: 'Arbeiten erledigt'
, Closed: 'Auftrag geschlossen'
, SubcontractorPendingConfirmation: 'Warten auf Bestätigung (Unterauftrag)'
, Scheduled: 'Geplant'
, OfferIsRejected: 'Angebot abgelehnt'
, OfferIsSend: 'Offen (Angebot versandt)'
, CollaborationWaitingConfirmation: 'Warten auf Bestätigung (Zusammenarbeit)'
, Released: 'Freigegeben'
, OfferIsConfirmed: 'Bestätigt'
, InProgress: 'In Bearbeitung'
, ReadyForScheduling: 'Zur Planung'
, Created: 'Erstellt'
, Rejected: 'Abgebrochen'
, Invoiced: 'Rechnung gestellt'
, '-': '-'
}, invHR: ['Pos.', 'Menge', 'Artikelbezeichnung', 'VK', 'Summe']
, frm: {
invoiceaddress: 'Adresse'
, loc: 'Leistungsort / Lieferadresse'
, invoiceemail: 'Email'
}
}, $rcol = {
req: new fields_definition('Auftrag', 'Aufträge', [
{
name: 'tags', label: '', type: 'string', dfnc: function (i, x) {
if ((i || '') !== '') {
$(this).aC('tags');
i.split(',').forEach((j) => {
if (j !== '') {
$(this).append($$.sc('tag ' + j.replace(' ', '_').replace('\/', '_').toLowerCase(), j));
}
})
}
}
},
{ name: 'DateOfCreation', label: 'Datum', type: 'date', title: function (x) { $(this).attr('title', $rct.dtCr + fdt(x.DateOfCreation).ne('-') + ' \n' + $rct.dtRel + fdt(x.DateReleased).ne('-')); } },
{ name: 'CustomerName', label: 'Kunde (Firma)', type: 'string' },
{ name: 'Name', label: 'Auftragsname', type: 'string' },
{ name: 'ExternalId', label: 'Auftragsnummer', type: 'string' },
{ name: 'ParentExtenalId', label: 'PAuftrag', type: 'string' },
{ name: 'InvoiceId', label: 'RNummer', type: 'string', dfnc: function (i, x) { $(this).rwText(i, ' ').find('span').each(function () { $(this).aC('cla').click({ id: $(this).text() }, $inv.jdbn); }) } },
{ name: 'State', label: 'Status', type: 'string' },
{ name: 'WorkDoneAt', label: 'Erledigt am', type: 'date' },
{ name: 'Description', label: 'Beschreibung', type: 'html' }
]),
itm: new fields_definition('Auftragsposition', 'Auftragspositionen', [
{ name: 'NameOrNumber', label: 'Bezeichnung', type: 'string' },
{ name: 'Type', label: 'Typ', type: 'select', required: true, value: 'Text', url: [{ value: 'Text', label: 'Text' }, { value: 'Equipment', label: 'Ausrüstung' }, { value: 'Material', label: 'Material' }, { value: 'Service', label: 'Arbeitsleistung' }], change: function (x) { $req.quantChange.call(this, x); } },
{ name: 'quantityhours', label: 'Anzahl / Menge', type: 'number', precision: '0.01', value: 1, change: function (x) { $inv.quantChange.call(this, x); } },
{ name: 'UnitString', label: 'Einheit', type: 'select', url: ['LFDM', 'Stck', 'Std.', 'QM', 'AW', 'Pauschal'], change: function (x) { $inv.quantChange.call(this, x); } },
{ name: 'net', label: 'EinzelPreis netto', type: 'number', precision: '0.01', value: 0, change: function (x) { $inv.quantChange.call(this, x); }},
{ name: 'net_val', label: 'GesamtPreis netto', type: 'number', precision: '0.01', value: 0 },
{ name: 'vat_val', label: 'GesamtPreis USt', type: 'number', precision: '0.01', value: 0 },
{ name: 'svcnet_val', label: 'Arbeitslohn netto', type: 'number', precision: '0.01', value: 0 },
{ name: 'svcvat_val', label: 'Arbeitslohn USt', type: 'number', precision: '0.01', value: 0 },
{ name: 'net_pos', label: 'Netto', type: 'string' },
{ name: 'bo_pos', label: 'Brutto', type: 'string' },
{ name: 'vat', label: 'USt', type: 'string', value: '19,0%', change: function (x) { $inv.quantChange.call(this, x); } },
{ name: 'Note', label: 'Details', type: 'html', tinymce: true }
])
};
let $ict = {
mdl: 'Rechnungen',
iov: {
all: 'Rechnungen (alle)', '': 'Rechnungen (nur fertige)', '#d': 'Rechnungen (nur Entwürfe)', '#u': 'Rechnungen (nur unbezahlt)', '#r': 'Rechnungen (nur angemahnt)', '#a': 'Rechnungen (nur Akonto)', '#c': 'Rechnungen (nur Storno)', '#ru': 'Rechnungen (nur angemahnt + unbez.)'
},
uba: ', gesamter Zeitraum)',
req: 'Auftrag',
inv: 'Rechnung',
rem: 'Mahnung',
in: 'Rechnungsnummer',
cc: 'Kunde',
wk: 'Woche',
nd: 'Keine Daten gefunden.',
dl: 'Herunterladen',
ed: 'Bearbeiten',
ced: 'Bearbeitung fortsetzen',
sItm: 'Einzelheiten anzeigen',
sPay: 'Zahlungen anzeigen',
cdI: 'Entwurf der Rechnung löschen?',
rel: 'Neu Laden',
relm: 'Bitte laden Sie Liste manuell neu, um die Änderungen zu sehen.',
dsp: 'Rechnung anzeigen',
storno: 'Storno-Rechnung erstellen',
credit: 'Gutschrift erstellen',
remd: 'Mahnung erstellen',
remdt: 'Mahnung erstellen zur Rechnung {0}',
remlst: 'Mahnungen anzeigen',
remdsp: 'Mahnung anzeigen',
remres: 'Mahnung erneut senden',
remresc: 'Mahnung {0} wirklich erneut senden?',
remresr: 'Mahnung {0} wurde erfolgreich versandt.',
setpyd: 'Bezahlt markieren',
cpyd: 'Rechnung wirklich als bezahlt markieren?',
setupd: 'Bezahlt-Markierung aufheben',
cupd: 'Bezahlt-Markierung wirklich aufheben?',
ivE: 'Die Email-Adresse ist vermutlich nicht gültig.',
ivEc: '\nMöchten Sie fortfahren?',
pna: 'Diese Seite ist in der Vorschau nicht verfügbar',
tpe: 'Die Anzahl von {0} Seiten wird aktuell nicht unterstützt',
eis: 'Der Rechnungsentwurf konnte nicht gespeichert werden.',
iss: 'Zwischenstand speichern.',
p13b: 'USt -> §13b',
setm: 'Set-Preisanzeige',
setmo: {
setprice: 'Set mit Preis Positionen ohne Preis',
itemprices: 'Positionen mit Preis Set als Überschrift',
setonly: 'Nur Set mit Preis Positionen ausgeblendet'
},
ctp: 'Ansprechpartner festlegen',
mfr: 'Von MFR neu abrufen',
rq1: 'Auftragsdaten werden von MFR abgerufen.\nDer Vorgang kann bis zu 90Sek dauern.',
rq2: 'Auftragsdaten werden geladen',
iq1: 'Rechnungsdaten werden von MFR abgerufen.\nDer Vorgang kann bis zu 90Sek dauern.',
iq2: 'Rechnungsdaten werden geladen',
sis: 'Rechnung als versandt markieren',
srs: 'Mahnung als versandt markieren',
sisc: 'Rechnung wirklich als versandt markieren?',
srsc: 'Mahnung wirklich als versandt markieren?',
iSt: {dft: 'Entwurf', uns: 'nicht versandt', pyd: 'bezahlt', cc: 'storniert', op: 'offen', due: 'fällig', ovd: 'überfällig', rem: 'angemahnt' },
rSt: ['', 'Überfällig', '2. Mahnung', '3. Stufe'],
pSt: { 'a': 'Vollst.', 'p': 'Teilz.' },
ivT: { i: 'AbschlagsR.', f: 'SchlussR', r: 'Rechnung', c: 'StornoR.' },
rovlh: 'Übersicht der bisherigen Mahnungen',
rovl: ['Betreff', 'Betrag', 'Betrag gezahlt', 'fertiggestellt am'],
remHR: ['Rechnung', 'vom', 'Rechnungsbetrag', 'bereits bezahlt', 'noch offen'],
remt: {
f: ['Sehr geehrte Damen und Herren,', 'ein Mahnschreiben sollte kurz, freundlich und erfolgreich sein. Kurz ist es, freundlich sowieso; ob es auch erfolgreich ist, hängt von Ihnen ab.']
, m: ['Sehr geehrte Damen und Herren,', 'nun müssen wir Sie noch einmal anschreiben.', 'Wahrscheinlich haben Sie triftige Gründe dafür, warum Sie die Zahlung unserer Forderung nicht vornehmen und auch nicht auf unsere Mahnung reagieren. Sollten wir darüber nicht einmal sprechen?', 'Bitte nehmen Sie umgehend in dieser Sache mit uns Kontakt auf.']
, l: ['Sehr geehrte Damen und Herren,', 'Eine DRITTE MAHNUNG zu erhalten bereitet Ihnen bestimmt ebenso wenig Freude wie uns, sie zu verschicken. Leider haben wir auf unsere zweite Mahnung noch keine Antwort von Ihnen erhalten.", "Wir bitten Sie, den offenen Betrag innerhalb der nächsten 7 Werktage nach Erhalt dieses Schreibens zu begleichen. Nach Ablauf dieser Frist erfolgt keine weitere Mahnung mehr.', 'Sollte die Forderung bis dahin nicht beglichen sein, eröffnen wir das gerichtliche Mahnverfahren. Sollten Sie die Rechnung inzwischen beglichen haben, so betrachten Sie bitte dieses Schreiben als gegenstandslos.']
},
remt2: {
f: ['Wir bitten Sie, den noch offenen Rechnungsbetrag innerhalb einer Woche auf unser Konto zu überweisen.', 'Sollten Sie den Betrag bereits überwiesen haben, so bitten wir Sie, diese Zahlungserinnerung als gegenstandslos zu betrachten.']
, m: ['Um Ihnen zusätzliche Kosten für weitere Mahnungen zu ersparen, bitten wir Sie nunmehr um die Überweisung des noch zu zahlenden Gesamtbetrages inklusive der ggf. bereits fälligen Mahnzinsen und Mahngebühren innerhalb von einer Woche.']
, l: []
}, payi: { account: 'Konto', name: 'Zahler', text: 'Verw.Zweck', InvoiceID: 'Rechnung', amount: 'Betrag', date: 'Datum', manual: 'Typ'}
}, $invcol = {
datev: new fields_definition('Rechnung', 'Rechnungen', [
{ name: 'Umsatz (ohne Soll/Haben-Kz)', label: 'Umsatz (ohne Soll/Haben-Kz)', type: 'string' },
/*{ name: 'EINZELPOS_brutto', label: 'EINZELPOS_brutto', type: 'string' },
{ name: 'EINZELPOS_netto', label: 'EINZELPOS_netto', type: 'string' },*/
{ name: 'vf', label: 'vf', type: 'string' },
{ name: 'Soll/Haben-Kennzeichen', label: 'Soll/Haben-Kennzeichen', type: 'string' },
{ name: 'Konto', label: 'Konto', type: 'string' },
{ name: 'Gegenkonto', label: 'Gegenkonto', type: 'string' },
{ name: 'BU-Schlüssel', label: 'BU-Schlüssel', type: 'string' },
{ name: 'Belegdatum', label: 'Belegdatum', type: 'string' },
{ name: 'Belegfeld 1', label: 'Belegfeld 1', type: 'string' },
{ name: 'Belegfeld 2', label: 'Belegfeld 2', type: 'string' },
{ name: 'Buchungstext', label: 'Buchungstext', type: 'string' }
])
, inv: new fields_definition('Rechnung', 'Rechnungen', [
{ name: 'invstatus', label: 'Status', type: 'select', url: $ict.iSt },
{ name: 'balance', label: 'Umsatz', type: 'string', dtype: 'currency' },
{ name: 'CustomerName', label: 'Kunde', type: 'string' },
{ name: 'InvoiceId', label: 'RNummer', type: 'string' },
{ name: 'InvoiceType', label: 'Typ', type: 'select', url: $ict.ivT },
//{ name: 'requestcount', label: 'Anz. Aufträge', type: 'string', dtype: 'num' },
{ name: 'request', label: 'Auftrag', type: 'string', dtype: 'num' },
/*{ name: 'EINZELPOS_brutto', label: 'EINZELPOS_brutto', type: 'string', dtype: 'currency' },
{ name: 'EINZELPOS_netto', label: 'EINZELPOS_netto', type: 'string', dtype: 'currency' },*/
{ name: 'vat', label: 'MwSt', type: 'string', dtype: 'num' },
{ name: 'deb_cred', label: 'Soll/Haben', type: 'string' },
{ name: 'customer', label: 'Konto', type: 'string', dtype: 'num' },
{ name: 'contra_account', label: 'Gegenkonto', type: 'string', dtype: 'num' },
{ name: 'Belegdatum', label: 'Belegdatum', type: 'date' },
{ name: 'reminderstatus', label: 'MahnStatus', type: 'select', url: $ict.rSt },
{ name: 'reminder', label: '# Mahnungen', type: 'integer' },
{ name: 'Buchungstext', label: 'Buchungstext', type: 'string' },
{ name: 'Payment', label: 'Zahlung', type: 'string' }
/*{ name: 'PaymentStatus', label: 'Zahlungsstatus', type: 'select', url: $ict.pSt}*/
])
, rem: new fields_definition('Zahlungserinnerung', 'Zahlungserinnerung', [
{ name: 'amount', label: 'Rechnungsbetrag', type: 'number', precision: '0.01', value: 1 },
{ name: 'amount_payed', label: 'bereits bezahlt', type: 'number', precision: '0.01', value: 1 }
])
, rem2: new fields_definition('Zahlungserinnerung', 'Zahlungserinnerung', [
{ name: 'DocumentName', label: 'Name', type: 'string' },
{ name: 'subject', label: 'Betreff', type: 'string' },
{ name: 'DateSent', label: 'Versanddatum', type: 'date' },
{ name: 'status', label: 'Status', type: 'string' },
//{ name: 'IsDraft', label: 'Entwurf', type: 'boolean' },
{ name: 'amount_open', label: 'offener Betrag', type: 'number', precision: '0.01' },
{ name: 'InvoiceId', label: 'RNummer', type: 'string' },
//{ name: 'InvoiceDocumentName', label: 'RechnungName', type: 'string' }
])
, rid: new fields_definition('Zahlungserinnerung', 'Zahlungserinnerung', [
{ name: 'type', label: 'Typ', type: 'select', url: [['f', 'einfache Zahlungserinnerung'],[ 'm', 'Mahnung'],[ 'l', 'letzte Mahnung']], required: true},
{ name: 'level', label: 'Stufe', type: 'select', url: [['1', 'Stufe 1'], ['2', 'Stufe 2'], ['3', 'Stufe 3'], ['4', 'Stufe 4'], ['5', 'Stufe 5'], ['6', 'Stufe 6']], required: true }
])
, ctp: new fields_definition('Ansprechpartner', 'Ansprechpartner', [
{ name: 'name', label: 'Name', type: 'string' },
{ name: 'email', label: 'Email', type: 'string' }
])
};
let gi = (n, c) => $$.sc('glyphicon glyphicon-' + n).aC(c);
let $inv = {
init2: function (type, options) {
type = type || 'inv';
options = options || {};
$ocms.getScript([
//{ script: 'web/jstree.min.js', css: 'web/jstree.min.css', condition: typeof $.fn.jstree !== 'function' }
//, { script: 'web/jquery.qtip.min.js', css: 'web/jquery.qtip.min.css', condition: typeof $.fn.qtip !== 'function' }
//, { script: 'web/typeahead.min.js', css: '', condition: typeof $.fn.typeahead !== 'function' }
//, { script: 'web/fullcalendar.min.js', module: 'FullCalendar', css: 'web/fullcalendar.min.css', condition: typeof FullCalendar !== 'object' }
], function () {
//FullCalendar = $vm.FullCalendar;
$inv.init3(type, options);
});
}, init3: async function (type, options) {
$fis.cf(true);
let lf = $fis.lf(true);
$('#topbar').ocmsmenu([]); //{ lbl: 'home', fnc: $inv.init3 }
$('#activemodule').text($ict.mdl);
let pa = [(async () => {
if (await $fis.getAuth('fds_inv') > 0) {
$inv.prepLst('');
lf.aC('fix'); //initially should be shown - for convenience
}
})(), new Promise((resolve, reject) => {
$fis.prepAuth(['fds_reminder']);
})];
await Promise.all(pa);
}, prepLst: function (includes) {
let td = new Date();
let lf = $fis.lf(true).ldng(1), sd = new Date('2021-01-01');
let frm = $fis.frm_list();
frm.IN(function () { });
let mitm = []
$.each($ict.iov, (ic, il) => {
mitm.push({ lbl: il, fnc: () => { $inv.prepLst(ic); lf.aC('fix'); } });
});
$fis.lfm().ocmsmenu([{ lbl: 'Filter', itm: mitm }]);
let osb = $$.i({ placeholder: $ict.in }).appendTo($$.dc('mth ivn', lf)).enterKey(function (ev) {
let mth = $(this), v = mth.val() || '';
ev.stopPropagation();
mth.parent().siblings().rC('selected');
if (v.length > 3) {
mth.parent().aC('selected');
$inv.renderinv('i:' + v, 's', 'all');
mth.val('');
}
});
let osb2 = $$.i({ placeholder: $ict.cc }).appendTo($$.dc('mth ivc', lf)).enterKey(function (ev) {
let mth = $(this), v = mth.val() || '';
ev.stopPropagation();
mth.parent().siblings().rC('selected');
if (v.length >= 3) {
mth.parent().aC('selected');
$inv.renderinv('c:' + v, 's', 'all');
mth.val('');
}
});
if (includes.substr(0,1) === '#') {
$$.dc('mth extra', lf).text($ict.iov[includes].replace(')',$ict.uba)).click(function (ev) {
let mth = $(this);
ev.stopPropagation();
mth.siblings().rC('selected');
if (mth.is('.selected') === true) {
mth.toggleClass('selected');
let tgt = fdt(new Date(), 'yy-MM-dd');
$inv.renderinv(tgt, 'a', includes);
}
mth.aC('selected');
});
}
lf.append('<hr />');
let mthl = $$.dc('mthl', lf), thisyear = td.getFullYear(), thismonth = td.getMonth() + 1;
for (let tyr = sd.getFullYear(); tyr <= thisyear; tyr++) {
let yr = $$.dc('yr').prependTo(mthl).text($ict.iov[includes] + ' - ' + tyr.toString()).toggleClass('selected', tyr === thisyear);
yr.click({
yr: tyr
}, function (ev) {
ev.stopPropagation();
yr.siblings().rC('selected');
yr.aC('selected');
});
let mfrm = $$.dc('mfrm', yr);
for (let tmt = 0; tmt < (tyr !== thisyear ? 12 : thismonth); tmt++) {
sd = new Date(tyr, tmt, 1);
let mth = $$.dc('mth').prependTo(mfrm).text($ict.iov[includes] + ' - ' + fdt(sd, 'MMM yyyy'));
mth.click({
yr: tyr, mt: tmt
}, function (ev) {
ev.stopPropagation();
mth.siblings().rC('selected');
if (mth.is('.selected') === true) {
mth.toggleClass('selected');
let tgt = fdt(new Date(ev.data.yr, ev.data.mt, 1), 'yy-MM-dd');
$inv.renderinv(tgt, 'm', includes);
}
mth.aC('selected');
});
if (includes === '') { // only for combi of final invoices
let mthdl = $$.dc('mthdl', mth).append(gi('compressed', 'ico'));
mthdl.click({
yr: tyr, mt: tmt
}, function (ev) {
ev.stopPropagation();
let tgt = fdt(new Date(ev.data.yr, ev.data.mt, 1), 'yy-MM-dd');
$inv.downloadzip(tgt, 'm');
});
}
let fwf = getMonday(sd), rd = fwf, lwf = new Date(sd);
lwf.setMonth(lwf.getMonth() + 1);
lwf.setDate(0);
lwf = getMonday(lwf);
let wfrm = $$.dc('wfrm', mth);
while (rd <= lwf) {
let wk = $$.dc('wk', wfrm).text(($ict.wk || 'W') + ' ' + fdt(rd, 'dd.MM.yy'));
wk.click({
rd: new Date(rd)
}, function (ev) {
ev.stopPropagation();
let tgt = fdt(ev.data.rd, 'yy-MM-dd');
$inv.renderinv(tgt, 'w', includes);
mth.siblings().rC('selected').find('.wk').rC('selected');
mth.aC('selected').find('.wk').rC('selected');
wk.aC('selected');
});
let wkdl = $$.dc('wkdl', wk).append(gi('compressed', 'ico'));
wkdl.click({
rd: new Date(rd)
}, function (ev) {
ev.stopPropagation();
let tgt = fdt(ev.data.rd, 'yy-MM-dd');
$inv.downloadzip(tgt, 'w');
});
rd.setDate(rd.getDate() + 7);
}
}
}
lf.ldng(0);
}, rerenderinv: function () {
let invfrm = $('#contentframe .invfrm:first');
if (invfrm.length > 0) {
let sets = invfrm.data('sets') || {};
if (sets.mode) {
$inv.renderinv(sets.tgt, sets.mode, sets.includes);
}
}
}, renderinv: function (tgt, mode, includes) {
let invlst = $fis.frm_list(true, true).ldng(1), invfrm = $$.dc('invfrm', invlst).aC('md' + mode).data('sets', $.extend({}, { tgt: tgt, mode: mode, includes: includes }));
let lf = $fis.lf();
$ocms.postXT({
url: $ocms.url('inv/invl'), data: { mode: mode, tgt: tgt, includes: includes }, success: (response) => {
lf.rC('fix').aC('hd');
$$.dc('ovhd', invfrm).text(response.admin.title);
let ts = $$.tblset({}, invfrm), fd = $invcol.inv;
let thr = $$.tr(ts.hd);
let haux = $$.th(thr);
$.each(fd.fields || [], (ci, cx) => {
$$.th(thr).text(cx.label);
if (cx.name === 'vat') {
$$.th(thr);
}
});
$.each(response.invoices || [], (ri, rw) => {
let tr = $$.tr(ts.bdy);
tr.click(function () {
lf.rC('fix').aC('hd');
tr.toggleClass('selected').siblings().rC('selected').find('td.av').rC('av');
tr.find('td.av').rC('av');
if (tr.is('.selected') === true) {
$inv.iMn(rw);
} else {
$inv.eM();
}
});
let raux = $$.td(tr, { class: 'raux' });
if (rw.hasFile) {
$$.dc('idl ilbtn', raux, { title: $ict.dl + '\n' + rw.DocumentName }).append(gi('save-file', 'ico')).click({ id: rw.Id }, $inv.downloadinv);
$$.dc('idl ilbtn', raux, { title: $ict.dsp + '\n' + rw.DocumentName }).append(gi('eye-open', 'ico')).click({ id: rw.Id, typ: 'inv' }, $inv.jdisp);
} else if (rw.isFinal === false && $fis.isAuth('fds_inv',2) === true) {
$$.dc('idl ilbtn', raux, { title: $ict.ed }).append(gi('edit', 'ico')).click({ id: rw.Id }, $inv.doContInv);
}
$$.dc('iitm ilbtn', raux, { title: $ict.sItm }).append(gi('list', 'ico')).click({ id: rw.Id }, $inv.showitm);
$$.dc('iitm ilbtn', raux, { title: $ict.sPay }).append(gi('euro', 'ico')).click({ id: rw.Id }, $inv.showpay);
$.each(fd.fields || [], (ci, cx) => {
let td = $$.td(tr).aC(cx.dtype), sel, o;
if ((cx.type || '') === 'select') {
td.text((cx.url || {})[rw[cx.name]] || '');
} else {
td.text(rw[cx.name])
}
switch (cx.name || '') {
case 'vat':
sel = $$.sel().appendTo($$.td(tr, { class: 'vsel' }));
o = (response.admin.ust_options || '19,0%;16,0%;0,0%').split(';');
$.each(o, (oi, oo) => { $$.opt(oo, oo).appendTo(sel); });
sel.click(function (ev) { ev.stopPropagation(); }).val(rw[cx.name]).change().change({ frm: invfrm, tgt: tgt, mode: mode, id: rw.Id, td: td, includes: includes }, $inv.setvat);
td.toggleClass('hl', rw[cx.name].substr(0, 2) !== o[0].substr(0, 2)).click(function (ev) {
ev.stopPropagation();
$(this).toggleClass('av');
});
break;
case 'balance':
td.aC('sh_' + (rw.SollHaben || '').toLowerCase());
break;
case 'invstatus': //drop through by intention
case 'reminderstatus':
td.aC((cx.name === 'invstatus' ? 'is_' : 'rs_') + rw[cx.name]);
break;
}
});
});
}, complete: () => { invlst.ldng(0); }
});
}, setvat: function (ev) {
let sel = $(this), data = ev.data || {};
$ocms.postXT({
url: $ocms.url('inv/setvat'), data: { id: data.id, val: sel.val() }, success: (response) => {
data.td.rC('av');
$inv.renderinv(data.tgt, data.mode, data.includes);
}
});
}, downloadzip: function (tgt, mode) {
let frm = $(this).empty();
window.open($ocms.url('inv/datevzip?mode=' + mode + '&tgt=' + encodeURIComponent(tgt)), '_blank');
}, showitm: function (ev) {
let tr = $(this).closest('tr');
ev.stopPropagation();
if (tr.is('.selected') === false) {
return;
}
$ocms.postXT({
url: $ocms.url('inv/rqi'), data: { id: ev.data.id }, success: (response) => {
let fr = $$.dc('rfrm');
if ((response.requests || []).length < 1) {
fr.text($ict.nd);
} else {
$.each(response.requests || [], function (ri, rx) {
let rq = $$.dc('srq', fr);
$$.dc('nme', rq).text(rx.name);
let rif = $$.tblset({ class: 'if' }, rq);
$.each(rx.items || [], (ii, ix) => {
let itr = $$.tr({ id: 'itm' + ix.Id }).appendTo(rif.bdy);
$$.td(itr).text(ix.NameOrNumber);
$$.td(itr).text(ix.Type);
$$.td(itr).aC('currency').text(ix.net_pos);
$$.td(itr).aC('currency').text(ix.bo_pos);
$$.td(itr).aC('num').text(ix.vat);
});
});
}
$ocms.dlg(fr, { width: 1000 });
}
});
}, showpay: function (ev) {
let tr = $(this).closest('tr');
ev.stopPropagation();
if (tr.is('.selected') === false) {
return;
}
$ocms.postXT({
url: $ocms.url('inv/pyi'), data: { id: ev.data.id }, success: (response) => {
let fr = $$.dc('rfrm');
if ((response.payments || []).length < 1) {
fr.text($ict.nd);
} else {
let rif = $$.tblset({ class: 'if' }, fr);
let hr = $$.tr(rif.hd);
$.each(['date','account', 'name', 'text', 'InvoiceID', 'amount', 'manual'], (hi, hx) => {
$$.th(hr, $ict.payi[hx]);
});
$.each(response.payments, (ii, ix) => {
let itr = $$.tr({ id: 'itm' + ix.banking_uid }).appendTo(rif.bdy);
$$.td(itr).aC('date').text(ix.date);
$$.td(itr).text(ix.account);
$$.td(itr).text(ix.name);
$$.td(itr).text(ix.text);
$$.td(itr).text(ix.InvoiceID);
$$.td(itr).aC('currency').text(ix.amount);
$$.td(itr).text(ix.manual);
});
}
$ocms.dlg(fr, { width: 1000, title: 'Übersicht der Zahlungen' });
}
});
}, downloadinv: function (ev) {
let tr = $(this).closest('tr');
ev.stopPropagation();
if (tr.is('.selected') === false) {
return;
}
window.open($ocms.url('inv/rdoc?id=' + ev.data.id), '_blank');
}, doContInv: function(ev) {
let tr = $(this).closest('tr');
ev.stopPropagation();
if (tr.is('.selected') === false) {
return;
}
$inv.cntInv({ id: ev.data.id });
}
}
let $$inv = { init2: $inv.init2, auth: {} };
export default $$inv;
$inv.cInv = function (ev) {
let tr = $(this).closest('tr');
ev.stopPropagation();
if (tr.is('.selected') === false) {
return;
} else if ($fis.isAuth('fds_inv', 2) === false) {
return;
}
$inv.cInv2({ id: ev.data.id });
};
$inv.rMn = (o) => {
let m = [{ lbl: $ict.req, itm: [] }];
if (bool(o, false) === true && $fis.isAuth('fds_inv', 2) === true) {
Array.prototype.push.apply(m[0].itm, [
{ lbl: $rct.crI, fnc: $inv.ccInv, data: { typ: 'r' } }
, { lbl: $rct.crII, fnc: $inv.ccInv, data: { typ: 'i' } }
]);
}
m.push({ lbl: $ict.rel, fnc: $inv.rReload });
return $('#topbar').ocmsmenu(m);
};
$inv.iMnr = (ix) => {
let f = booln(ix.isFinal, true), id = ix.Id, fds = booln(ix.fds, false);
let m = [
{ glyph: 'glyphicon-menu-left', fnc: () => { $fis.frm_edit().remove(); } },
{ lbl: $ict.inv, itm: [] }, { lbl: $ict.rem, itm: [] }
];
if (f === false && $fis.isAuth('fds_inv', 2) === true) {
m[1].itm.push({ lbl: $ict.ced, fnc: $inv.clCntInv });
} else if ($fis.isAuth('fds_inv', 1) === true) {
m[1].itm.push({ lbl: $ict.dsp, fnc: () => $inv.disp(id, 'inv') })
}
if (fds === true && f === true && $fis.isAuth('fds_inv', 2) === true) {
m[1].itm.push({ lbl: $ict.storno, fnc: () => $inv.storno(id, fds) });
m[1].itm.push({ lbl: $ict.credit, fnc: () => $inv.credit(id, fds) });
}
if (f === true && $fis.isAuth('fds_reminder', 2) === true) {
m[2].itm.push({ lbl: $ict.remd, fnc: () => $inv.ccRem(id, ix.InvoiceId) });
m[2].itm.push({ lbl: $ict.remlst, fnc: () => $inv.dspRem(id) });
}
if (f === true && $fis.isAuth('fds_reminder', 2) === true && booln(ix.IsSent, false) === false) {
m[2].itm.push({ lbl: $ict.srs, fnc: () => $inv.srs(id) });
}
m.push({ lbl: $ict.rel, fnc: $inv.rReload });
return $('#topbar').ocmsmenu(m);
};
$inv.iMn = (ix) => {
let f = booln(ix.isFinal, true), id = ix.Id, fds = booln(ix.fds, false);
let m = [{ glyph: 'glyphicon-menu-left', fnc: () => { $fis.frm_edit().remove(); } },
{ lbl: $ict.inv, itm: [] }, { lbl: $ict.rem, itm: [] }
];
if (f === false && $fis.isAuth('fds_inv', 2) === true) {
m[1].itm.push({ lbl: $ict.ced, fnc: () => { $inv.cntInv({ id: id }); } });
} else if ( $fis.isAuth('fds_inv', 1) === true) {
m[1].itm.push({ lbl: $ict.dsp, fnc: () => $inv.disp(id, 'inv') })
}
if ($fis.isAuth('fds_inv', 2) === true) {
m[1].itm.push({ lbl: $ict.storno, fnc: () => $inv.storno(id, fds) })
m[1].itm.push({ lbl: $ict.credit, fnc: () => $inv.credit(id, fds) });
}
if (f === true && booln(ix.IsPayed, false) === false) {
if ($fis.isAuth('fds_reminder', 2) === true) {
m[2].itm.push({ lbl: $ict.remd, fnc: () => $inv.ccRem(id, ix.InvoiceId) });
}
if ($fis.isAuth('fds_inv', 2) === true) {
m[1].itm.push({ lbl: $ict.setpyd, fnc: () => $inv.setPyd(id) });
}
} else if (f === true && booln(ix.IsPayed, false) === true && (ix.PaymentStatus || '') === 'm') {
if ($fis.isAuth('fds_inv', 2) === true) {
m[1].itm.push({ lbl: $ict.setupd, fnc: () => $inv.setUpd(id) });
}
}
if ($fis.isAuth('fds_reminder', 2) === true) {
m[2].itm.push({ lbl: $ict.remlst, fnc: () => $inv.dspRem(id) });
}
if (f === true && $fis.isAuth('fds_inv', 2) === true && booln(ix.IsSent, false) === false) {
m[1].itm.push({ lbl: $ict.sis, fnc: () => $inv.sis(id) });
}
if (fds === false) {
m[1].itm.push({ lbl: $ict.mfr, fnc: () => $inv.mfrrel(id) });
}
return $('#topbar').ocmsmenu(m);
}
$inv.eM = (r, re, opt) => {
let m = [];
if (booln(r, false) === true || booln(re, false) === true) {
m.push({ glyph: 'glyphicon-menu-left', fnc: () => { $fis.lf(true); $fis.frm_edit().remove(); } });
}
if ((opt || '').split(',').includes('iss') === true) {
m.push({ lbl: $ict.iss, fnc: $inv.ssave });
}
if ((opt || '').split(',').includes('ctp') === true) {
m.push({ lbl: $ict.ctp, fnc: $inv.sctp });
}
if ((opt || '').split(',').includes('p13b') === true) {
m.push({ lbl: $ict.p13b, fnc: $inv.sp13b });
}
if ((opt || '').split(',').includes('setm') === true) {
m.push({ lbl: $ict.setm, fnc: $inv.ssetmode });
}
if (booln(r, false) === true) {
m.push({ lbl: $ict.rel, fnc: $inv.rReload });
}
return $('#topbar').ocmsmenu(m); /* empty Array => empty menu */
};
$inv.cInv2 = function (data) {
let fr = $$.dc('rfrm').ldng(1);
let o = $ocms.dlg(fr, { width: 1000 });
if (o) { o.ft.rwText($rct.rq1); }
let mainfnc = () => {
$ocms.postXT({
url: $ocms.url('req/get'), timeout: 60, data: { id: data.id, mode: 'r' }, success: (response) => {
//console.debug(response);
response.admin = response.admin || {};
let lf = $fis.lf(true).aC('fix').rC('hd');
$fis.frm_edit().IN();
$inv.eM(true, true);
if ((response.requests || []).length < 1) {
lf.aC('fix').text($rct.nd);
} else {
$$.dc('lh', lf, $rct.mdl);
let iv = $$.d(), rq = $$.ul({ class: 'rql' }).data({ search: data.id, parent: response.admin.parent }).appendTo(lf), rqa = {}, cl = $rcol.req.lbl();
$.each(response.requests || [], function (ri, rx) {
let rli = $$.li({ class: 'cli rli' }).data($.extend({}, rx)).appendTo(rq);
let lihd = $$.dc('lihd', rli).addClass(rx.state);
if (booln(rx.open, false) === true) {
lihd.append($$.sc('cbox').click(() => {
rli.tC('checked');
iv.find('li').rC('checked');
if (rli.is('.checked') === true) {
$inv.rMn(rx.open);
} else {
$inv.eM(true);
}
}));
}
lihd.append([$$.sc('eid', rx.ExternalId), $$.sc('nme', rx.Name)]);
$$.dc('lidt', rli).append([$$.dc('rqs').append([$$.s(cl.State + ': '), $$.s($rct.sts[rx.State || '-'])]), $$.dc('ivn').append([$$.s(cl.InvoiceId + ': '), $$.s(rx.InvoiceId || '- -')]), $$.dc('wda').append([$$.s(cl.WorkDoneAt + ': '), $$.s(fdt(rx.WorkDoneAt, 'dd.MM.yyyy'))])]);
rqa[rx.Id] = rli;
});
if ((response.inv || []).length > 0) {
$$.dc('lh', lf, $rct.invs);
iv = $$.ul({ class: 'ivl' }).appendTo(lf); /* first assignment to iv is fake, just to prevent issues */
$.each(response.inv || [], (ii, ix) => {
let ili = $$.li({ class: 'cli ili' }).data($.extend({}, ix)).appendTo(iv);
let lihd = $$.dc('lihd', ili).addClass(ix.invstatus);
if (booln(ix.isFinal, true) === false) {
lihd.append($$.sc('cbox').click(() => {
if ((ix.Id || '') !== '') {
ili.tC('checked').siblings().rC('checked'); rq.find('li').rC('checked');
if (ili.is('.checked') === true) {
$inv.iMnr(ix);
} else {
$inv.eM(true); /* empty menu */
}
}
}));
} else if (['', 'dft'].indexOf(ix.invstatus) < 0) {
lihd.append($$.sc('dli').click(function () { $inv.disp(ix.Id, 'inv'); }));
}
lihd.append($$.sc('nme', ix.DocumentName || ix.Id));
$$.dc('lidt', ili).append([$$.dc('wda').append([$$.s(fdt(ix.DateCreated, 'dd.MM.yyyy'))]), $$.d().text($ict.iSt[ix.invstatus] || ix.invstatus)]);
});
}
}
}, complete: () => {
if (o) { o.c.trigger('modal_close'); }
}
});
};
$ocms.postXT({
url: $ocms.url('req/pget'), timeout: 90, data: { id: data.id }, success: (r1) => {
if (o) { o.ft.rwText($rct.rq2); }
mainfnc();
}, error: () => {
if (confirm($rct.rq1f)) {
if (o) { o.ft.rwText($rct.rq2); }
mainfnc();
} else {
if (o) { o.c.trigger('modal_close'); }
}
}
});
};
$inv.ccInv = function (ev) { //normale rechnung
let data = ev.data || {}, typ = data.typ || 'r';
let lf = $fis.lf(), rql = lf.children('ul.rql'), parent = rql.data('parent');
let selli = [];
rql.find('li.rli.checked').each(function () {
selli.push($(this).data('Id'));
});
if (selli.length < 1) { // abort if none selected
alert($rct.dnS);
return;
}else if (typ === 'i' && selli.length > 1) { // abort if intermediate invoice and several selected
alert($rct.dII);
return;
}
let edf = $fis.frm_edit(), frm = $$.dc('invoice_layout', edf).append($$.dc('btn sprev').click($inv.sprev));
let ww = $fis.cf().width() > (frm.width() + lf.width() + 20);
lf.tC('fix', ww).tC('hd', !ww);
$inv.eM(false, true);
let fr = $$.dc('rfrm').ldng(1);
let o = $ocms.dlg(fr, { width: 1000 });
o.ft.rwText($rct.rq2);
$ocms.postXT({
url: $ocms.url('req/iget'), timeout: 60, data: { id: parent, mode: 'ful', typ: typ, sel: selli.join(',') }, success: (response) => {
//console.debug(response);
let rq = $$.dc('srq', frm);
let rif = $$.tblset({ class: 'invi' }, rq);
rif.bdy.remove();
rif.ft = $$[0]('tfoot');
response.admin = response.admin || {};
response.admin.p13b = bool(response.admin.p13b || '', (((response.inv || {}).InvoiceOptions || '').split(',').includes('§13b') === true));
rif.tbl.data($.extend({ new: {}, sms: {}, itm: {} }, { admin: response.admin, companies: response.companies, locations: response.locations }));
let thr = $$.tr(rif.hd).aC('shd').append([$$.th().aC('aux')]); /* header row for items */
$rct.invHR.forEach(h => $$.th(thr, h));
rif.tbl.on('fds.inv', $inv.invSumUpdate);
$.each(response.requests || [], function (ri, rx) {
let srqid = rx.Id || 0;
if (srqid !== 0) {
let worknotes = $inv.worknotes(rx);
rx.text = response.admin.type === 'i' ? ($rct.req + (jine([rx.ExternalId, rx.Name], ': ').eine(' ', ''))) : (jine([jine([fdt(rx.WorkDoneAt, 'dd.MM.yy'), rx.ExternalId], ' - ' + $rct.req + ' '), worknotes.ne(rx.Name)], ': \n'));
let bdy = $$.tbody(rif.tbl).data($.extend({}, rx));
$inv.rendersrq.call(bdy);
}
});
/* add an empty */
let atr = $$.tr($$.tbody(rif.tbl), { class: 'placeholder' }).data({ net_val: 0, vat_val: 0, svcnet_val: 0, svcvat_val: 0, net: 0 });
$inv.rrw.call(atr);
rif.ft.appendTo(rif.tbl);
let admin = response.admin || {}, fm = (cls, txt, nme, hd, dta) => {
let fr = $$.dc('inpfrm', frm).aC(cls).append(typeof hd === 'string' ? $$.dc('ahd', hd) : (hd > 0 ? $$.dc('ahd', $rct.frm[nme]) : null)), fc = $$.dc('content', fr).rwText(txt);
$$.dc('axf', fr).append($$.dc('ibtn edit').data('dialog', $rct.frm[nme]).append(gi('pencil')).click($.extend({ t: fc, nme: nme, change: (nv) => { rif.tbl.data('new')[nme] = nv; } }, dta), $inv.eHtml));
rif.tbl.data('new')[nme] = txt;
};
fm('tfrm', admin.invoicetitle, 'invoicetitle', 0, null);
fm('adrfrm', admin.invoiceaddress, 'invoiceaddress', 0, null);
fm('locfrm', '', 'loc', 1, { list: deepCopy(response.locations), lbl: 'ref', property: 'address' });
fm('emailfrm', admin.invoiceemail, 'invoiceemail', 0, null);
$$.dc('sndfrm', frm).append($$.dc('content').text(admin.sender));
let admtxt, admlbl;
if (admin.provisionend) {
admlbl = admin.provisionstart ? $rct.provP : $rct.provD;
admtxt = admin.provisionstart ? (fdt(admin.provisionstart, 'dd.MM.yyyy') + ' - ' + fdt(admin.provisionend, 'dd.MM.yyyy')) : fdt(admin.provisionend, 'dd.MM.yyyy');
}
fm('admfrm', admtxt, 'provisionperiod', admlbl, 1, null);
rif.tbl.data('new').CustomValues = admin.CustomValues || '';
$$.dc('inpfrm ctpfrm', frm).text(jObj(admin.CustomValues, 'contactName'));
//adm = $$.dc('admfrm', frm), admc = $$.dc('content', adm),
rif.tbl.children('tbody').each($inv.bdysort);
rif.tbl.trigger('fds.inv'); /* trigger calculations */
$inv.eM(false, true, 'iss,p13b,setm,ctp');
}, complete: () => {
o.c.trigger('modal_close');
}
});
};
$inv.ccStInv = function (ev) { // Stornorechnung
let data = ev.data || {};
let lf = $fis.lf(), oldinv = data.id;
let frm = $$.dc('invoice_layout', $fis.frm_edit()).append($$.dc('btn sprev').click($inv.sprev));
let ww = $fis.cf().width() > (frm.width() + lf.width() + 20);
lf.tC('fix', ww).tC('hd', !ww);
$inv.eM(false, true);
let fr = $$.dc('rfrm').ldng(1);
let o = $ocms.dlg(fr, { width: 1000 });
o.ft.rwText($ict.iq1);
$ocms.postXT({
url: $ocms.url('inv/pget'), timeout: 90, data: { id: data.id }, success: (response) => {
if (o) { o.ft.rwText($ict.iq2); }
$ocms.postXT({
url: $ocms.url('inv/icget'), timeout: 60, data: { id: oldinv }, success: (response) => {
//console.debug(response);
let rq = $$.dc('srq', frm);
let rif = $$.tblset({ class: 'invi' }, rq);
rif.bdy.remove();
rif.ft = $$[0]('tfoot');
response.admin = response.admin || {};
response.admin.p13b = bool(response.admin.p13b || '', (((response.inv || {}).InvoiceOptions || '').split(',').includes('§13b') === true));
rif.tbl.data($.extend({ new: {}, sms: {}, itm: {} }, { admin: response.admin, companies: response.companies, locations: response.locations }));
let thr = $$.tr(rif.hd).aC('shd').append([$$.th().aC('aux')]); /* header row for items */
$rct.invHR.forEach(h => $$.th(thr, h));
rif.tbl.on('fds.inv', $inv.invSumUpdate);
$.each(response.requests || [], function (ri, rx) {
let srqid = rx.Id || 0;
if (srqid !== 0) {
let worknotes = $inv.worknotes(rx);
rx.text = response.admin.type === 'i' ? ($rct.req + (jine([rx.ExternalId, rx.Name], ': ').eine(' ', ''))) : (jine([fdt(rx.WorkDoneAt, 'dd.MM.yy') + worknotes.ne(rx.Name)], ': '));
let bdy = $$.tbody(rif.tbl).data($.extend({}, rx));
$inv.rendersrq.call(bdy);
}
});
/* add an empty */
let atr = $$.tr($$.tbody(rif.tbl), { class: 'placeholder' }).data({ net_val: 0, vat_val: 0, svcnet_val: 0, svcvat_val: 0, net: 0 });
$inv.rrw.call(atr);
rif.ft.appendTo(rif.tbl);
let admin = response.admin || {}, fm = (cls, txt, nme, hd, dta) => {
let fr = $$.dc('inpfrm', frm).aC(cls).append(typeof hd === 'string' ? $$.dc('ahd', hd) : (hd > 0 ? $$.dc('ahd', $rct.frm[nme]) : null)), fc = $$.dc('content', fr).rwText(txt);
$$.dc('axf', fr).append($$.dc('ibtn edit').data('dialog', $rct.frm[nme]).append(gi('pencil')).click($.extend({ t: fc, nme: nme, change: (nv) => { rif.tbl.data('new')[nme] = nv; } }, dta), $inv.eHtml));
rif.tbl.data('new')[nme] = txt;
};
fm('tfrm', admin.invoicetitle, 'invoicetitle', 0, null);
fm('adrfrm', admin.invoiceaddress, 'invoiceaddress', 0, null);
fm('locfrm', admin.provisionlocation, 'loc', 1, { list: deepCopy(response.locations), lbl: 'ref', property: 'address' });
fm('emailfrm', admin.invoiceemail, 'invoiceemail', 0, null);
$$.dc('sndfrm', frm).append($$.dc('content').text(admin.sender));
let admtxt, admlbl;
if (admin.provisionend) {
admlbl = admin.provisionstart ? $rct.provP : $rct.provD;
admtxt = admin.provisionstart ? (fdt(admin.provisionstart, 'dd.MM.yyyy') + ' - ' + fdt(admin.provisionend, 'dd.MM.yyyy')) : fdt(admin.provisionend, 'dd.MM.yyyy');
}
fm('admfrm', admtxt, 'provisionperiod', admlbl, 1, null);
rif.tbl.data('new').CustomValues = admin.CustomValues || '';
$$.dc('inpfrm ctpfrm', frm).text(jObj(admin.CustomValues, 'contactName'));
//adm = $$.dc('admfrm', frm), admc = $$.dc('content', adm),
rif.tbl.children('tbody').each($inv.bdysort);
rif.tbl.trigger('fds.inv'); /* trigger calculations */
}, complete: () => {
o.c.trigger('modal_close');
}
});
}, error: () => {
if (o) { o.c.trigger('modal_close'); }
}
});
};
$inv.clCntInv = function (ev) { // click-handler for invoice continuation
let lf = $fis.lf(false), selli = [];
lf.find('li.ili.checked').each(function () {
selli.push($(this).data('Id'));
});
if (selli.length === 1) {
//$('#contentframe').empty();
$inv.cntInv({ id: selli[0] });
}
};
$inv.cntInv = function (data) { //invoice continuation
data = data || {};
let lf = $fis.lf(false).rC('fix').aC('hd'), frm = $$.dc('invoice_layout', $fis.frm_edit()).append($$.dc('btn sprev').click($inv.sedit));
$inv.eM(false, true);
let fr = $$.dc('rfrm').ldng(1);
let o = $ocms.dlg(fr, { width: 1000 });
o.ft.rwText($rct.rq2);
$ocms.postXT({
url: $ocms.url('inv/get'), timeout: 60, data: { id: data.id }, success: (response) => {
//console.debug(response);
response.admin = response.admin || {};
let inv = response.inv || {};
let rq = $$.dc('srq', frm);
let rif = $$.tblset({ class: 'invi' }, rq);
rif.bdy.remove();
rif.ft = $$[0]('tfoot');
rif.tbl.data($.extend({ invid: inv.Id, new: {}, sms: { }, itm: {}, bai: [] }, response));
let thr = $$.tr(rif.hd).aC('shd').append([$$.th().aC('aux')]); /* header row for items */
$rct.invHR.forEach(h => $$.th(thr, h));
rif.tbl.on('fds.inv', $inv.invSumUpdate);
$.each(response.req || [], function (ri, rx) {
let bdy = $$.tbody(rif.tbl).data($.extend({}, rx));
$inv.rendersrq.call(bdy);
});
/* add an empty */
let atr = $$.tr($$.tbody(rif.tbl), { class: 'placeholder' }).data({ net_val: 0, vat_val: 0, svcnet_val: 0, svcvat_val: 0, net: 0 });
$inv.rrw.call(atr);
rif.ft.appendTo(rif.tbl);
let fm = (cls, txt, nme, hd, dta) => {
let fr = $$.dc('inpfrm', frm).aC(cls).append(typeof hd === 'string' ? $$.dc('ahd', hd) : (hd > 0 ? $$.dc('ahd', $rct.frm[nme]) : null)), fc = $$.dc('content', fr).rwText(txt);
$$.dc('axf', fr).append($$.dc('ibtn edit').data('dialog', $rct.frm[nme]).append(gi('pencil')).click($.extend({ t: fc, nme: nme, change: (nv) => { rif.tbl.data('new')[nme] = nv; } }, dta), $inv.eHtml));
rif.tbl.data('new')[nme] = txt;
};
fm('tfrm', inv.InvoiceTitle, 'invoicetitle', 0, null);
fm('adrfrm', inv.SendToAddress, 'invoiceaddress', 0, null);
fm('locfrm', inv.ProvisionLocation, 'loc', 1, null);
fm('emailfrm', inv.SendToEmail, 'invoiceemail', 0, null);
$$.dc('sndfrm', frm).append($$.dc('content').text(response.admin.sender));
fm('admfrm', inv.ProvisionPeriod, 'provisionperiod', ((inv.ProvisionPeriod || '').includes('-') === true ? $rct.provP : $rct.provD), 1, null);
rif.tbl.data('new').CustomValues = inv.CustomValues || '';
$$.dc('inpfrm ctpfrm', frm).text(jObj(inv.CustomValues, 'contactName'));
//adm = $$.dc('admfrm', frm), admc = $$.dc('content', adm),
rif.tbl.children('tbody').each($inv.bdysort);
rif.tbl.trigger('fds.inv'); /* trigger calculations */
$inv.eM(false, true, 'iss,p13b,setm,ctp');
}, complete: () => {
o.c.trigger('modal_close');
}
});
};
$inv.cSt = function (data) {
data = data || {};
let lf = $fis.lf(), frm = $$.dc('invoice_layout', $fis.frm_edit()).append($$.dc('btn sprev').click($inv.sedit));
let ww = $fis.cf().width() > (frm.width() + lf.width() + 20);
lf.tC('fix', ww).tC('hd', !ww);
$inv.eM(false, true);
let fr = $$.dc('rfrm').ldng(1);
let o = $ocms.dlg(fr, { width: 1000 });
o.ft.rwText($ict.iq1);
$ocms.postXT({
url: $ocms.url('inv/pget'), data: { id: data.id }, success: (response) => {
if (o) { o.ft.rwText($ict.iq2); }
$ocms.postXT({
url: $ocms.url('inv/storno'), data: { id: data.id, mode: data.mode }, success: (response) => {
//console.debug(response);
response.admin = response.admin || {};
response.admin.p13b = bool(response.admin.p13b || '', (((response.inv || {}).InvoiceOptions || '').split(',').includes('§13b') === true));
let inv = response.inv || {};
let rq = $$.dc('srq', frm);
let rif = $$.tblset({ class: 'invi' }, rq);
rif.bdy.remove();
rif.ft = $$[0]('tfoot');
rif.tbl.data($.extend({ invid: inv.Id, new: {}, sms: {}, itm: {}, bai: [] }, response));
let thr = $$.tr(rif.hd).aC('shd').append([$$.th().aC('aux')]); /* header row for items */
$rct.invHR.forEach(h => $$.th(thr, h));
rif.tbl.on('fds.inv', $inv.invSumUpdate);
$.each(response.req || [], function (ri, rx) {
let bdy = $$.tbody(rif.tbl).data($.extend({}, rx));
$inv.rendersrq.call(bdy);
});
/* add an empty */
let atr = $$.tr($$.tbody(rif.tbl), { class: 'placeholder' }).data({ net_val: 0, vat_val: 0, svcnet_val: 0, svcvat_val: 0, net: 0 });
$inv.rrw.call(atr);
rif.ft.appendTo(rif.tbl);
let fm = (cls, txt, nme, hd, dta) => {
let fr = $$.dc('inpfrm', frm).aC(cls).append(typeof hd === 'string' ? $$.dc('ahd', hd) : (hd > 0 ? $$.dc('ahd', $rct.frm[nme]) : null)), fc = $$.dc('content', fr).rwText(txt);
$$.dc('axf', fr).append($$.dc('ibtn edit').data('dialog', $rct.frm[nme]).append(gi('pencil')).click($.extend({ t: fc, nme: nme, change: (nv) => { rif.tbl.data('new')[nme] = nv; } }, dta), $inv.eHtml));
rif.tbl.data('new')[nme] = txt;
};
fm('tfrm', inv.InvoiceTitle, 'invoicetitle', 0, null);
fm('adrfrm', inv.SendToAddress, 'invoiceaddress', 0, null);
fm('locfrm', inv.ProvisionLocation, 'loc', 1, null);
fm('emailfrm', inv.SendToEmail, 'invoiceemail', 0, null);
$$.dc('sndfrm', frm).append($$.dc('content').text(response.admin.sender));
fm('admfrm', inv.ProvisionPeriod, 'provisionperiod', ((inv.ProvisionPeriod || '').includes('-') === true ? $rct.provP : $rct.provD), 1, null);
rif.tbl.data('new').CustomValues = inv.CustomValues || '';
$$.dc('inpfrm ctpfrm', frm).text(jObj(inv.CustomValues,'contactName'));
//adm = $$.dc('admfrm', frm), admc = $$.dc('content', adm),
rif.tbl.children('tbody').each($inv.bdysort);
rif.tbl.trigger('fds.inv'); /* trigger calculations */
}, complete: () => {
o.c.trigger('modal_close');
}
});
}, error: () => {
if (o) { o.c.trigger('modal_close'); }
}
});
};
$inv.eHtml = function (ev) {
let t = $(this), frmct = ev.data instanceof jQuery ? ev.data : ev.data.t, flds = [
{ name: 'txt', label: 'Text', type: 'html', value: frmct.html(), tinymce: true, attr: { style: 'height: 300px' } }
];
let change = ev.data.change || null;
let sets = {
title: t.data('dialog') || '',
success: function (response) {
frmct.html(response.txt);
if (typeof change === 'function') {
change(response.txt);
}
},
tinymce: { valid_elements: 'br', hidemenu: true, hidetoolbar: true }
}
if (Array.isArray(ev.data.list)) {
let optf = $$.dc('lstfrm');
$.each(ev.data.list, (ii, lx) => {
let li = $$.dc('li', optf).append((ev.data.lbl || '') !== '' ? $$.dc('lbl').rwText(lx[ev.data.lbl]) : null);
$$.dc('adr', li).rwText(lx[ev.data.property]).data('val', lx[ev.data.property]).click(function () {
let t = $(this), tgt = t.closest('.modal-body').find(':input[name="txt"]');
if (tgt.is('.tinymce')) {
tinymce.get(tgt.attr('id')).setContent($$.s().rwText(t.data('val')).html());
} else if (tgt.prop('tagName') === 'TEXTAREA') {
tgt.val(t.data('val')).change();
} else {
tgt.rwText(t.data('val'));
}
});
});
sets.addcontent = optf;
}
$ocms.dlgform(flds, sets);
};
$inv.setVat = function (ev) {
let t = $(this), thisrow = ev.data;
let vat = prompt($rct.rqV);
if (vat) {
vat = parseFloat(vat.replace('%', ''));
if (vat > 1) {
vat = vat * 0.01;
}
if (isNaN(vat) === false) {
thisrow.siblings('.itm').each(function () {
let rwi = $(this), dta = rwi.data();
dta.vat = fnum(vat, { style: 'percent' }).replace(' ', '');
if ((dta.net_val || 0) > 0) {
dta.vat_val = dta.net_val * vat;
}
if ((dta.svcnet_val || 0) > 0) {
dta.svcvat_val = dta.svcnet_val * vat;
}
});
$inv.t_fds_inv();
}
}
};
$inv.inRow = function (ev) {
let t = $(this), thisrow = ev.data, dta = {}, flds = $rcol.itm.clone(['SortOrder', 'NameOrNumber', 'Type', 'quantityhours', 'UnitString', 'net', 'svcnet_val', 'svcvat_val', 'net_val', 'vat_val', 'vat', 'Note']); /* fields without values */
let nid = 'N' + (((1 + Math.random()) * 0x10000) || 0).toString(16).substr(6), newrow = $$.tr({ id: 'itm_' + nid.toString(), class: 'itm' });
$ocms.dlgform(flds, {
title: t.data('dialog') || '',
success: function (response) {
newrow.data($.extend({ Id: nid }, dta, response));
$inv.rrw.call(newrow);
newrow.insertAfter(thisrow);
$inv.t_fds_inv();
}, typedvalues: true
});
};
$inv.eRow = function (ev) {
let t = $(this), row = ev.data, dta = row.data() || {}, fnme = ['SortOrder', 'NameOrNumber', 'Type', 'quantityhours', 'UnitString', 'net', 'svcnet_val', 'svcvat_val', 'net_val', 'vat_val', 'vat', 'Note'];
if (!dta.id && (dta.Type || '') === '') {
fnme.unshift('Type');
}
let flds = $rcol.itm.clone(fnme).applyValues(dta);
flds.set('Type', 'hidden', 'type');
$inv.eRw.call(t, row, dta, flds);
};
$inv.eRw = function(row, dta, flds) {
let t = $(this);
$ocms.dlgform(flds, {
title: t.data('dialog') || '',
success: function (res) {
let d = {}
if ((dta.Id || '') === '') {
d.Id = 'N' + (((1 + Math.random()) * 0x10000) || 0).toString(16).substr(6);
row.attr('id', 'itm_' + d.Id.toString());
}
d.quantity = ((res.quantityhours ||'').toString() + ' ' + (res.UnitString || '').toString()).trimEnd();
row.data($.extend({}, dta, res, d));
console.debug('eRw success %o', row.data());
$inv.rrw.call(row);
$inv.t_fds_inv();
}, typedvalues: true
});
};
$inv.bdysort = (i, e) => { $(e).Sortable({ dragItem: false, dragHandleClass: 'ico', parentident: 'tr', swapdone: (p1, p2, i1, i2) => { $inv.t_fds_inv(); } }) }
$inv.rrw = function () {
let rw = $(this), dta = rw.data(), co = {}, ph = rw.is('.placeholder'), hn = rw.is('.hidenote');
let oHtml = (e) => $$.d().append(e).html();
let bc = [
$$.dc('ibtn insb', { title: $rct.iRb }).append(gi('indent-left')).click(rw, $inv.inRow)
];
if (ph === false) {
bc.unshift($$.dc('ibtn edit', { title: $rct.cP }).append(gi('pencil')).click(rw, $inv.eRow));
bc.push($$.dc('ibtn del', { title: $rct.dR }).append(gi('trash')).click(function (e) { if (confirm($rct.cD)) { rw.remove(); $inv.t_fds_inv(); } }));
}
let axf = $$.dc('axf').append(bc);
if (ph === true) {
co = { id: '', typ: 'placeholder' };
} else if (rw.is('.itm.osum') === true) {
co = { invrqid: dta.InvRqId, id: 'osum' + rw.index(), typ: 'osum', p: '', q: null, t: oHtml(dta.tbl.tbl), tt: null, v: null, vt: dta.net_val, vs: dta.svcnet_val, vat: dta.vat, vv: dta.vat_val, vsv: dta.svcvat_val, det: false };
} else {
co = { invrqid: dta.InvRqId, id: dta.Id || '', typ: dta.Type || 'other', p: '', q: null, t: '', tt: null, v: null, vt: dta.net_val, vs: dta.svcnet_val, vat: dta.vat, vv: dta.vat_val, vsv: dta.svcvat_val, det: (dta.Note || '') !== '' && hn === false };
$$.dc('ibtn ico move', axf, { title: $rct.mR }); /* should be the last added */
co.p = dta.position || (dta.SortOrder || '');
if (co.id === '') {
co.t = '';
} else if (['Text', 'Title'].includes(co.typ) && (dta.net_val || 0) === 0) {
co.t = dta.htmltext || (((dta.NameOrNumber || '').substr(0, 1) !== '#' ? oHtml($$[0]('p').text(dta.NameOrNumber)) : '') + (dta.Note || ''));
} else {
co.tt = co.det ? '' : $$.s(dta.Note || '').text();
co.q = dta.quantity || (fnum(dta.quantityhours) + ' ' + (dta.UnitString || ''));
co.t = dta.htmltext ||(co.det ? (oHtml($$.s(dta.NameOrNumber || '')) + oHtml($$.dc('desc').html(dta.Note))) : oHtml($$.s(dta.NameOrNumber || '')));
co.v = dta.net
co.vt = dta.net_val
}
}
if ((dta.Note || '') !== '') {
$$.dc('ibtn add', axf).append(gi('object-align-left')).click(function (e) {
$inv.rrw.call(rw.tC('hidenote'));
});
}
let tda = [
$$.tdc('aux').append(axf),
$$.tdc('keep').text(co.p)
];
if (co.id === '') {
tda.push($$.td(rw, { colspan: 4 }).append(co.t));
} else {
Array.prototype.push.apply(tda, co.q ? [$$.tdc('keep').text(co.q)] : []);
Array.prototype.push.apply(tda, [
$$.tdc('txt', { colspan: !co.q ? 2 : 1, title: co.tt }).append(co.t),
$$.tdc('currency').text(fnum(co.v, $rct.cst)),
$$.tdc('currency inetval').text(fnum(co.vt, $rct.cst)).attr('title', $rct.svcPart + ': ' + fnum(co.vs, $rct.cst))
]);
}
rw.empty().attr('class', ph ? 'placeholder' : 'itm').aC(co.Typ).tC('hidenote', hn).append(tda);
dta.co = co;
};
$inv.invSumUpdate = function () {
let tbl = $(this), ft = tbl.children('tfoot').empty(), p13b = bool((tbl.data().admin || {}).p13b || '', false);
tbl.nextAll('.fnote').remove();
let sms = { ttn: 0, ttb: 0, ttvat: 0, tscn: 0, tscvat: 0, vat: {}, itmnet: {} }, ba = [];
let rwcy = (lbl, val, cls) => $$.tdc('currency', $$.tr(ft, { class: cls || 'tsum' }).append([$$.tdc('aux'), $$.td({ colspan: 4 }).text(lbl)]), fnum(val, $rct.cst)), fn = (t) => $$.dc('fnote').insertAfter(tbl).rwText(t);
let csms = function (rrx, sms, sid) {
sms.tscn += (rrx.svcnet_val || 0);
sms.tscvat += (rrx.svcvat_val || 0);
sms.ttn += (rrx.net_val || 0);
sms.ttvat += (rrx.vat_val || 0);
sms.ttb += ((rrx.net_val || 0) + (rrx.vat_val || 0));
if ((rrx.vat || '') !== '') {
sms.vat[rrx.vat] = (sms.vat[rrx.vat] || 0) + (rrx.vat_val || 0);
}
//sms.itmnet[sid] = (sms.itmnet[sid] || 0) + (rrx.net_val || 0);
};
let bds = tbl.children('tbody');
bds.each((bi, bdy) => {
let b = $(bdy), rx = b.data() || {}, i = [], citems = [], cset = null, bnet = 0, itm = b.find('tr.itm'), iso = 0, ipos = 0;
b.tC('empty', itm.length < 1);
itm.each((ti, tx) => {
let rrx = $(tx).data() || {}; csms(rrx, sms, rx.Id); bnet += (rrx.net_val || 0); i.push(rrx.co);
//console.debug('rrx %o', rrx);
/* backend item contract (title/desc/qty/price_net/total_net + set flags), see InvoiceSetPricing.
Set grouping: an item of Type 'set' is a header that claims the following items in this
block as its members until the next set header (mfr__items has no explicit member link). */
let citem = $inv.itemToContract(rrx);
if (citem.type === 'set' && citem.id !== '') { cset = citem.id; }
else if (cset !== null && (citem.id || '') !== '') { citem.setId = cset; }
citems.push(citem);
if (((typeof rrx.SortOrder === 'undefined' || rrx.SortOrder === null) ? -1 : rrx.SortOrder) > -1) {
if (['text', 'title'].includes((rrx.Type || 'other').toLowerCase()) === false) { ipos++; }
rrx.SortOrder = iso;
rrx.position = ipos;
$inv.rrw.call(tx);
}
});
//console.debug('%o', {
// f: b.find('tr.isum > td.isumval'), t: fnum(bnet, $rct.cst), n: bnet
//});
b.find('tr.isum > td.isumval').text(fnum(bnet, $rct.cst));
ba.push({ Id: rx.Id, nme: rx.Name, text: rx.text, itm: i, items: citems, netval: bnet });
});
let nonempty = tbl.find('tbody:not(.empty)').length;
bds.find('tr.isum').tC('hidden', nonempty < 2);
//let fnet = $$.tdc('currency', $$.tr(ft, { class: 'tsum' }).append([$$.tdc('aux'), $$.td({ colspan: 4 }).text('Netto')]), fnum(sms.ttn, $rct.cst));
rwcy('Netto', sms.ttn);
if (p13b === false) {
$.each(sms.vat, (vi, vx) => {
//$$.tdc('currency vat', $$.tr(ft, { class: 'tvat' }).append([$$.tdc('aux'), $$.td({ colspan: 4 }).text('Umsatzsteuer ' + vi)]), fnum(vx, $rct.cst));
rwcy($rct.vat + ' ' + vi, vx, 'tvat');
});
} else {
sms.ttb = sms.ttn;
}
//let fsum = $$.tdc('currency', $$.tr(ft, { class: 'tsum' }).append([$$.tdc('aux'), $$.td({ colspan: 4 }).text('Summe')]), fnum(sms.ttb, $rct.cst));
rwcy('Summe', sms.ttb);
let itype = tbl.data().admin.type;
if (itype === 'i') {
fn($rct.note2);
fn($rct.note4);
} else if (itype === 'c') {
fn($rct.note2);
} else {
fn(string($rct.note3, [fnum((sms.tscn + sms.tscvat) * (tbl.data().admin.tax_servicerefund || 0), $rct.cst)])).aC('ntax');
fn($rct.note2);
fn(string($rct.note1, [fnum(sms.tscn + sms.tscvat, $rct.cst), fnum(sms.tscn, $rct.cst), fnum(sms.tscvat, $rct.cst)]));
}
if (p13b === true) {
fn($rct.note13b);
}
tbl.data('sms', sms);
tbl.data('bai', ba);
};
$inv.worknotes = function (rx) {
let wn = '';
rx.steps.forEach((s, si) => {
let flds;
try {
flds = JSON.parse(s.Data || {}).fields || [];
} catch (e) {
console.debug(e);
flds = [];
}
if (Array.isArray(flds || '') !== true) {
if (typeof flds === 'object' && Array.isArray(flds.field || '') === true) {
flds = flds.field;
} else {
flds = [];
}
}
flds.forEach((v, si) => {
if (v.name === 'Ausgeführte Arbeiten') {
wn = v.result || '';
}
});
});
return wn;
};
$inv.rendersrq = function () {
let bdy = $(this).empty(), onesum = bdy.is('.onesum');
let rx = bdy.data();
//if (ri > 0) {
// $$.tr(bdy).aC('sep nosort').append($$.td({ colspan: 6 }));
//}
let rtr = $$.tr(bdy, { id: 'srq' + rx.Id }).aC('title nosort'), cl = $rcol.itm.lbl();
let aux = $$.dc('axf').appendTo($$.tdc('aux', rtr));
$$.dc('ibtn osum', aux, { title: $rct.combP }).append(gi('euro')).click(function (e) {
bdy.tC('onesum');
$inv.rendersrq.call(bdy);
$inv.t_fds_inv();
});
$$.dc('ibtn setvat', aux, { title: $rct.sV }).append(gi('gbp')).click(rtr, $inv.setVat);
$$.dc('ibtn insb', aux, { title: $rct.iRb }).append(gi('indent-left')).click(rtr, $inv.inRow);
let stxt = $$.sc('text', rx.text);
let nme = $$.td(rtr, { colspan: onesum ? 4 : 5 }).append(stxt), oidta, numkeys = ['net_val', 'vat_val', 'svcnet_val', 'svcvat_val', 'net'];
$$.dc('ibtn edit', aux).data('dialog', $rcol.req.lbl().Name).append(gi('pencil')).click({ t: stxt, change: (nv) => { rx.text = nv; $inv.t_fds_inv(); } }, $inv.eHtml)
if (onesum) {
$$.tdc('currency isumval', rtr);
oidta = { Id: rx.Id.toString() + '_osum', net_val: 0, vat_val: 0, svcnet_val: 0, svcvat_val: 0, net: 0 };
oidta.tbl = $$.tblset({ class: 'stbl' });
}
$.each(rx.items || [], (ii, ix) => {
let itr, idta = { Id: ix.Id, net_val: ix.net_val || 0, vat_val: ix.vat_val || 0, svcnet_val: 0, svcvat_val: 0, net: ix.net || 0, Note: ix.Note || '' };
switch (ix.Type.toLowerCase()) {
case 'service':
idta.svcnet_val = ix.net_val || 0;
idta.svcvat_val = ix.vat_val || 0;
}
if (onesum) {
itr = $$.tr(oidta.tbl.bdy, { id: 'itm' + ix.Id, class: 'sitm' }).aC(ix.Type);
if (ix.Type === 'Text' || ix.Type === 'Title') {
$$.td(itr, { colspan: 2 }).html(ix.htmltext || ix.Note);
} else {
$$.tdc('keep', itr).text(ix.quantity || ((ix.quantityhours || 0) > 0 ? fnum(ix.quantityhours) + (ix.UnitString || '').eine(' ','') : ''));
if (ix.htmltext) {
$$.tdc('txt', itr).html(ix.htmltext);
} else {
$$.tdc('txt', itr).text(ix.NameOrNumber).attr('title', ix.Note);
}
}
$.each(numkeys, (k, ky) => { oidta[ky] += idta[ky]; });
itr.data(idta);
} else {
$.extend(idta, ix);
itr = $$.tr(bdy, { id: 'itm' + ix.Id, class: 'itm' });
itr.data(idta);
$inv.rrw.call(itr);
}
});
if (onesum) {
let oi = $$.tr(bdy, { id: 'itmsq' + rx.Id, class: 'itm osum' }).data(oidta);
$inv.rrw.call(oi);
} else {
let istr = $$.tr(bdy).aC('isum nosort');
$$.tdc('aux', istr);
$$.td(istr, { colspan: 4 }).text($rct.iSum);
$$.tdc('currency isumval', istr);
}
};
$inv.t_fds_inv = () => { $('div.invoice_layout table.invi').trigger('fds.inv'); };
$inv.sedit = () => {
$inv.sprev(true);
};
$inv.jdisp = function (ev) {
ev.stopPropagation();
if (ev.data.id) {
$inv.disp(ev.data.id, (ev.data.typ ||''));
}
}
$inv.disp = (id, typ) => {
let u = '';
switch (typ) {
case 'inv':
u = 'inv/rdoc';
break;
case 'rem':
u = 'rem/rdoc';
break;
}
if (u !== '') {
$ocms.postXT({
url: $ocms.url(u), data: { id: id || '', typ: 'img' }, success: (response) => {
let c = $$.dc('imagecollection pdfpreview'), vhr = Math.round(vh() * 0.88), invid = response.id;
$.each(response.img || [], function (ii, img) {
$$.dc('pdfp', c).append($$.img(img).css('max-height', (vhr - rpx(6)).toString() + 'px'));
});
$ocms.dlg(c, {
size: [vhr, Math.round(vw() * 0.88)], zindex_min: 50, form: false, exclusive:false
});
}
});
}
};
$inv.jdbn = function (ev) {
$ocms.postXT({
url: $ocms.url('inv/rdocn'), data: { name: ev.data.id || '', typ: 'img' }, success: (response) => {
let c = $$.dc('imagecollection pdfpreview'), vhr = Math.round(vh() * 0.88), invid = response.id;
$.each(response.img || [], function (ii, img) {
$$.dc('pdfp', c).append($$.img(img).css('max-height', (vhr - rpx(6)).toString() + 'px'));
});
$ocms.dlg(c, {
size: [vhr, Math.round(vw() * 0.88)], zindex: 50, form: false
});
}
});
};
$inv.sp13b = () => {
var l = $('div.invoice_layout'), tbl = l.find('table.invi'), d = tbl.data();
d.admin.p13b = true;
if ((d.inv.InvoiceOptions || '').split(',').includes('§13b') === false) {
d.inv.InvoiceOptions += ',§13b';
} else {
}
tbl.trigger('fds.inv');
};
/* Maps an item row's data to the backend item contract consumed by InvoiceSetPricing
/ FuchsPdf.ApplyInvoice: { id, type, title (plain), desc (html), qty, price_net,
total_net, vat }. Set membership (type:'set' header + setId on members) is added by
the caller. The invoice total comes from the registration balance, so per-item
totals here are purely presentational. */
$inv.itemToContract = function (rrx) {
rrx = rrx || {};
let oHtml = (e) => $$.d().append(e).html();
let type = (rrx.Type || '').toString().toLowerCase();
let ci = { id: (rrx.Id || '').toString(), type: type, title: '', desc: '', qty: '', price_net: '', total_net: (rrx.net_val || 0), vat: rrx.vat || '' };
if (rrx.co && rrx.co.typ === 'osum') {
/* combined single-sum line — the on-screen "title" is an HTML sub-table; render it as desc */
ci.desc = rrx.co.t || '';
ci.total_net = (rrx.net_val || 0);
} else if (['text', 'title'].includes(type) && (rrx.net_val || 0) === 0) {
/* heading / free-text line, no price */
ci.desc = rrx.htmltext || ((((rrx.NameOrNumber || '').substr(0, 1) !== '#') ? oHtml($$[0]('p').text(rrx.NameOrNumber || '')) : '') + (rrx.Note || ''));
ci.total_net = '';
} else {
/* normal priced item (incl. set headers, which carry their own set price or 0) */
ci.title = rrx.NameOrNumber || '';
ci.desc = rrx.Note || '';
ci.qty = rrx.quantity || ((rrx.quantityhours || 0) !== 0 ? (fnum(rrx.quantityhours) + (rrx.UnitString ? ' ' + rrx.UnitString : '')) : '');
ci.price_net = (rrx.net || 0);
ci.total_net = (rrx.net_val || 0);
}
return ci;
};
/* 3-way set-pricing display switch. Mirrors §13b: writes the choice onto admin.setmode,
which BuildInvoiceParams turns into the "setmode:<mode>" InvoiceOptions token the PDF reads. */
$inv.ssetmode = () => {
let l = $('div.invoice_layout'), tbl = l.find('table.invi'), d = tbl.data();
d.admin = d.admin || {};
let cur = (d.admin.setmode || 'setprice'), o;
let btn = (mode) => $$.dc('btn', $ict.setmo[mode]).tC('selected', cur === mode).click(() => { o.c.trigger('modal_close'); $inv.setSetmode(mode); });
let fr = $$.dc('choicefrm').append([btn('setprice'), btn('itemprices'), btn('setonly')]);
o = $ocms.dlg(fr, { width: 800 });
};
$inv.setSetmode = (mode) => {
let l = $('div.invoice_layout'), tbl = l.find('table.invi'), d = tbl.data();
d.admin = d.admin || {};
d.admin.setmode = mode; /* posted in admin -> BuildInvoiceParams writes setmode: into InvoiceOptions */
d.inv = d.inv || {}; /* keep a local InvoiceOptions reflection in sync (cosmetic) */
let opts = (d.inv.InvoiceOptions || '').split(',').filter(x => x !== '' && x.indexOf('setmode:') !== 0);
if (mode && mode !== 'setprice') { opts.push('setmode:' + mode); }
d.inv.InvoiceOptions = opts.join(',');
};
$inv.sctp = () => {
let flds = $invcol.ctp;
$ocms.dlgform(flds, {
title: $ict.ctp,
success: function (response) {
var l = $('div.invoice_layout'), tbl = l.find('table.invi'), d = tbl.data();
let cvo = {};
if (typeof d.new !== 'undefined' && (d.new.CustomValues || '').substr(0, 1) === '{') {
cvo = JSON.parse(d.inv.CustomValues);
}
cvo.contactName = response.name;
cvo.contactEmail = response.email;
d.new.CustomValues = JSON.stringify(cvo); //Assign it to new Values so that this is submitted also
l.find('.ctpfrm').text(ne(response.name, response.email));
}, typedvalues: true
});
};
/* Normalises the editor's working model into the exact field names the C# backend
(FdsInvoiceData.BuildInvoiceParams) reads, then returns the `invc` payload:
- balances/service sums come from `sms` (ttn/ttb), exposed on `new` as total_net/total_gross;
- every VAT rate's net amount is exposed as new.vat_<rate>_net (the backend reads the highest);
- new.invoicetitle -> new.title, new.loc -> new.provisionlocation, admin.paymentterms ->
new.paymentterm, admin.CustomerId -> admin.customerid.
Originals are kept alongside; the source objects are not mutated. */
$inv.invcPayload = function (d) {
d = d || {};
let sms = d.sms || {}, nw = $.extend({}, d.new), adm = $.extend({}, d.admin);
nw.total_net = sms.ttn || 0;
nw.total_gross = sms.ttb || 0;
/* VAT (rate + amount) is taken by the backend straight from the posted sms.vat map
(FdsInvoiceData.HighestVat), so no per-rate new.vat_* keys are needed here. */
nw.title = (nw.invoicetitle != null ? nw.invoicetitle : (nw.title || ''));
nw.provisionlocation = (nw.loc != null ? nw.loc : (nw.provisionlocation || ''));
nw.paymentterm = (adm.paymentterms != null ? adm.paymentterms : (nw.paymentterm || ''));
adm.customerid = (adm.customerid != null ? adm.customerid : adm.CustomerId);
return { admin: adm, req: d.bai, sms: d.sms, new: nw };
};
$inv.ssave = () => {
var l = $('div.invoice_layout'), d = l.find('table.invi').data();
$inv.t_fds_inv();
l.aC('freeze');
$ocms.postXT({
url: $ocms.url('req/save'), data: { invc: JSON.stringify($inv.invcPayload(d)), id: d.invid || '' }, success: (response) => {
$inv.cntInv({ id: response.id });
}, error: () => {
alert($ict.eis);
}, complete: () => {
l.rC('freeze');
}
});
};
$inv.sprev = (change) => {
var l = $('div.invoice_layout'), d = l.find('table.invi').data();
change = bool(change, false);
$inv.t_fds_inv();
l.aC('freeze');
//console.debug({ admin: d.admin, req: d.bai, sms: d.sms, new: d.new });
if ($fis.ValidateEmail(d.new.invoiceemail || '') === false) {
if (bool(confirm($ict.ivE + $ict.ivEc),false) === false) {
l.rC('freeze');
return;
}
}
$ocms.postXT({
url: $ocms.url('req/' + (change === true ?'sedit':'sprep')), data: { invc: JSON.stringify($inv.invcPayload(d)), id: d.invid ||'' }, success: (response) => {
l.rC('freeze');
let c = $$.dc('imagecollection pdfpreview'), vhr = Math.round(vh() * 0.88), invid = response.id, invtp = response.total;
if (invtp > 10) {
$$.dc('note warn', c).text($ict.tpe);
}
$.each(response.img || [], function (ii, img) {
$$.dc('pdfp', c).append($$.img(img).css('max-height', (vhr - rpx(6)).toString() + 'px'));
});
for (let ic = (response.img || []).length + 1; ic <= invtp; ic++) {
$$.dc('pdfp ph', c).append($$.dc('note', $ict.pna));
}
$ocms.dlg(c, {
size: [vhr, Math.round(vw() * 0.88)], zindex: 50, form: false, button: $rct.crI, confirm: function (e) {
let ct = $(this);
$ocms.postXT({
url: $ocms.url('req/sconf'), data: { id: invid }, success: () => {
ct.trigger('modal_close');
window.open($ocms.url('req/idoc') + '?id=' + invid, '_blank'); /* open pdf in new tab */
$ocms.init('req'); /* go back to request list */
$inv.rReload();
}, error: () => {
alert($t.f1);
ct.trigger('modal_close');
}
});
}, cancel: function (e) {
let ct = $(this);
if (confirm($ict.cdI)) {
$ocms.postXT({
url: $ocms.url('req/sdel'), data: {
id: invid
}
});
}
$inv.rReload();
}
});
}
});
};
$inv.rReload = () => {
try {
let s = $('#listframe ul.rql:first').data();
$inv.cInv2({ id: s.search });
} catch (e) { }
};
$inv.quantChange = function (i) {
//console.debug({ t: this, i: i });
let t = $(this), f = t.closest('form'), fi = {}, pf = (i) => parseFloat(i.toString().replace('%', '').replace(',', '.')), rtp = (num) => num.toFixed(2);
f.find(':input').each((i, e) => { fi[$(e).attr('name')] = $(e); });
let qv = parseInt(fi.quantityhours.val() || '0'), nv = pf(fi.net.val() || '0'), vat = pf(fi.vat.val()) * 0.01;
if (qv > 0 && nv > 0) {
fi.net_val.val(rtp(qv * nv));
fi.vat_val.val(rtp(qv * nv * vat));
if (['Service'].includes(fi.Type.val())) {
fi.svcnet_val.val(rtp(qv * nv));
fi.svcvat_val.val(rtp(qv * nv * vat));
}
}
};
$inv.storno = function (id, fds) {
let o, fr = $$.dc('choicefrm').append([
$$.dc('btn', 'Storno ohne Details').click({ id: id, mode: 'simple' }, (ev) => { o.c.trigger('modal_close'); $inv.cSt(ev.data); })
, $$.dc('btn', 'Storno mit neuer Rechnung').click({ id: id }, (ev) => { o.c.trigger('modal_close'); $inv.ccStInv(ev); })
, $$.dc('btn', 'Storno mit best. Rechnung').tC('inactive', bool(fds, false) === false).click({ id: id, mode: 'copy' }, (ev) => { if (bool(fds, false) === true) { o.c.trigger('modal_close'); $inv.cSt(ev.data); }})
]);
o = $ocms.dlg(fr, { width: 1000 });
};
$inv.credit = function (id, fds) {
let o, fr = $$.dc('choicefrm').append([
$$.dc('btn', 'Gutschrift').click({ id: id, mode: 'credit' }, (ev) => { o.c.trigger('modal_close'); $inv.cSt(ev.data); })
]);
o = $ocms.dlg(fr, { width: 1000 });
};
$inv.setPyd = function (id) { // set invoice payed
if (confirm($ict.cpyd)) {
$ocms.postXT({
url: $ocms.url('inv/setpyd'), timeout: 60, data: { id: id }, success: (response) => {
alert($ict.relm);
}, error: () => {
alert($t.f1);
}
});
}
};
$inv.setUpd = function (id) { // set invoice payed
if (confirm($ict.cupd)) {
$ocms.postXT({
url: $ocms.url('inv/setupd'), timeout: 60, data: { id: id }, success: (response) => {
alert($ict.relm);
}, error: () => {
alert($t.f1);
}
});
}
};
$inv.resendRem = function (ev) {
ev.stopPropagation();
if (ev.data.id && confirm(string($ict.remresc, [ev.data.name]))) {
$ocms.postXT({
url: $ocms.url('rem/resend'), timeout: 60, data: { id: ev.data.id }, success: (response) => {
alert(string($ict.remresr, [ev.data.name]));
}, error: () => {
alert($t.f1);
}
});
}
};
$inv.dspRem = function (id) { //reminder creation
let fr = $$.dc('rfrm').ldng(1);
let o = $ocms.dlg(fr, { width: 1000 });
o.ft.rwText($rct.rq2);
$ocms.postXT({
url: $ocms.url('inv/getrem'), timeout: 60, data: { id: id, drafts: false }, success: (response) => {
o.ft.empty();
let ts = $$.tblset({ class: 'invtbl'}, fr.empty()), fd = $invcol.rem2;
let thr = $$.tr(ts.hd), haux = $$.th(thr);
$.each(fd.fields || [], (ci, cx) => {
$$.th(thr).text(cx.label);
});
let cst = false;
$.each(response, (ri, rw) => {
cst = !cst;
let tr = $$.tr(ts.bdy).tC('alt', cst), raux = $$.td(tr);
tr.click(function () {
tr.tC('selected').siblings().rC('selected');
});
if (bool(rw.hasFile, false)=== true) {
$$.dc('idl ilbtn', raux, { title: $ict.dl + '\n' + rw.DocumentName }).append(gi('save-file', 'ico')).click({ id: rw.Id }, $inv.downloadrem);
$$.dc('idl ilbtn', raux, { title: $ict.remdsp + '\n' + rw.DocumentName }).append(gi('eye-open', 'ico')).click({ id: rw.Id, typ: 'rem' }, $inv.jdisp);
$$.dc('idl ilbtn', raux, { title: $ict.remres + '\n' + rw.DocumentName }).append(gi('refresh', 'ico')).click({ id: rw.Id, typ: 'rem', name: rw.DocumentName }, $inv.resendRem);
}
$.each(fd.fields || [], (ci, cx) => {
let td = $$.td(tr).aC(cx.dtype), val = rw[cx.name];
if (typeof cx.dfnc === 'function') {
cx.dfnc.call(td, val, rw);
} else {
switch (cx.type || '') {
case 'date':
td.text(fdt(rw[cx.name], 'dd.MM.yy'));
break;
case 'datetime':
td.text(fdt(rw[cx.name]));
break;
case 'html':
td.append($$.dc('ctw').html(val));
td.append($$.dc('ttip').html(val));
break;
default:
td.text(rw[cx.name]);
}
}
switch (cx.name || '') {
case 'InvoiceId':
td.aC('keep');
break;
}
switch (typeof cx.title) {
case 'function':
cx.title.call(td, rw);
break;
case 'string':
td.attr('title', cs.title);
}
});
});
}, error: () => {
fr.empty();
o.ft.rwText($t.f1);
}, complete: () => {
fr.ldng(0);
}
});
};
$inv.ccRem = function (id, InvoiceId) { //reminder creation
let t = $(this);
$ocms.postXT({
url: $ocms.url('rem/lrem'), timeout: 60, data: { id: id }, success: (response) => {
let flds = $invcol.rid.clone(); /* fields without values */
flds.applyValues(response.ov);
let ac = $$.dc('ac'), tbl = $$.tblset({class: 'fullgrid fullwidth'}, ac);
if ((response.lst || []).length > 0) {
$$.d({ 'style': 'margin: 1.5rem 0 1rem 0;font-size: 110%;text-decoration: underline;'}).prependTo(ac).text($ict.rovlh);
let trh = $$.tr(tbl.hd);
$ict.rovl.forEach((f, n) => $$.th(trh, f));
$.each(response.lst, (ri, rw) => {
let tr = $$.tr(tbl.bdy);
tr.append([$$.tdc('keep', rw.subject), $$.tdc('currency', fnum(rw.amount, $rct.cst)), $$.tdc('currency', fnum(rw.amount_payed, $rct.cst)), $$.tdc('keep', fdt(rw.DateFinalized, 'dd.MM.yy'))]);
});
} else {
$$.td($$.tr(tbl.bdy), $ict.nd);
}
$ocms.dlgform(flds, {
addcontent: ac,
title: string($ict.remdt, [InvoiceId || '?']),
success: function (sets) {
$inv.ccRem_s2(id, sets);
}, typedvalues: true
});
}
});
};
$inv.rRemRw = function (dta) {
let tr = $(this), rem = dta.rm || {};
tr.empty().data({ invoiceid: rem.invoiceid, invoicedate: rem.invoicedate, amount: rem.amount, amount_payed: rem.amount_payed });
let axf = $$.dc('axf').append($$.dc('ibtn edit', { title: $rct.cP }).append(gi('pencil')).click(tr, $inv.eRowR));
tr.append([$$.tdc('aux').append(axf), $$.tdc('keep', rem.invoiceid), $$.tdc('keep', fdt(rem.invoicedate, 'dd.MM.yy')), $$.tdc('currency', fnum(rem.amount, $rct.cst)), $$.tdc('currency', fnum(rem.amount_payed, $rct.cst)), $$.tdc('currency', fnum(rem.amount - rem.amount_payed, $rct.cst))]);
};
$inv.eRowR = function (ev) {
let t = $(this), row = ev.data, dta = row.data() || {};
let flds = $invcol.rem.clone().applyValues(dta);
$ocms.dlgform(flds, {
title: t.data('dialog') || '',
success: function (res) {
let tbl = t.closest('table'), tdta = tbl.data();
$.extend(tdta.rm, res);
tbl.data(tdta);
$inv.rRemRw.call(row, tdta);
}, typedvalues: true
});
};
$inv.ccRem_s2 = function (id, sets) { //reminder creation
let lf = $fis.lf(false).rC('fix').aC('hd'), frm = $$.dc('invoice_layout', $fis.frm_edit()).append($$.dc('btn sprev').click($inv.rprev));
$inv.eM(false, true);
let fr = $$.dc('rfrm').ldng(1);
//let o = $ocms.dlg(fr, { width: 1000 });
//o.ft.rwText($rct.rq2);
$ocms.postXT({
url: $ocms.url('rem/get'), timeout: 60, data: $.extend({ id: id }, sets), success: (response) => {
//console.debug(response);
let rem = response.rm || {};
let rq = $$.dc('srq', frm);
$ict.remt[rem.type].forEach(r => $$[0]('p').rwText(r).appendTo(rq));
let rif = $$.tblset({ class: 'invi' }, rq);
rif.ft = $$[0]('tfoot');
rif.tbl.data($.extend({ invid: rem.invid, new: {} }, response));
let thr = $$.tr(rif.hd).aC('shd').append([$$.th().aC('aux')]); /* header row for items */
$ict.remHR.forEach(h => $$.th(thr, h));
$inv.rRemRw.call($$.tr(rif.bdy), rif.tbl.data());
rif.ft.appendTo(rif.tbl);
$ict.remt2[rem.type].forEach(r => $$[0]('p').rwText(r).appendTo(rq));
let fm = (cls, txt, nme, hd, dta) => {
let fr = $$.dc('inpfrm', frm).aC(cls).append(typeof hd === 'string' ? $$.dc('ahd', hd) : (hd > 0 ? $$.dc('ahd', $rct.frm[nme]) : null)), fc = $$.dc('content', fr).rwText(txt);
$$.dc('axf', fr).append($$.dc('ibtn edit').data('dialog', $rct.frm[nme]).append(gi('pencil')).click($.extend({ t: fc, nme: nme, change: (nv) => { rif.tbl.data('new')[nme] = nv; } }, dta), $inv.eHtml));
rif.tbl.data('new')[nme] = txt;
};
fm('tfrm', rem.subject, 'subject', 0, null);
fm('adrfrm', rem.invoiceaddress, 'invoiceaddress', 0, null);
// fm('locfrm', rem.ProvisionLocation, 'loc', 1, null);
fm('emailfrm', rem.invoiceemail, 'invoiceemail', 0, null);
$$.dc('sndfrm', frm).append($$.dc('content').text(rem.sender));
//adm = $$.dc('admfrm', frm), admc = $$.dc('content', adm),
rif.tbl.children('tbody').each($inv.bdysort);
rif.tbl.trigger('fds.inv'); /* trigger calculations */
}, complete: () => {
//o.c.trigger('modal_close');
}
});
};
$inv.rprev = () => {
var l = $('div.invoice_layout'), tbl = l.find('table.invi'), d = tbl.data();
$.extend(d.new, tbl.find('tbody > tr:first').data());
l.aC('freeze');
//console.debug({ rem: d.rm, new: d.new });
if ($fis.ValidateEmail(d.new.invoiceemail || '') === false) {
if (bool(confirm($ict.ivE + $ict.ivEc), false) === false) {
l.rC('freeze');
return;
}
}
$ocms.postXT({
url: $ocms.url('rem/prep'), data: { remc: JSON.stringify({ rem: d.rm, new: d.new }), id: d.invid || '' }, success: (response) => {
l.rC('freeze');
let c = $$.dc('imagecollection pdfpreview'), vhr = Math.round(vh() * 0.88), remid = response.id;
$.each(response.img || [], function (ii, img) {
$$.dc('pdfp', c).append($$.img(img).css('max-height', (vhr - rpx(6)).toString() + 'px'));
});
$ocms.dlg(c, {
size: [vhr, Math.round(vw() * 0.88)], zindex: 50, form: false, button: $ict.remd, confirm: function (e) {
let ct = $(this);
$ocms.postXT({
url: $ocms.url('rem/conf'), data: { id: remid }, success: () => {
ct.trigger('modal_close');
window.open($ocms.url('rem/idoc') + '?id=' + remid, '_blank'); /* open pdf in new tab */
$ocms.init('req'); /* go back to request list */
$inv.rReload();
}, error: () => {
alert($t.f1);
ct.trigger('modal_close');
}
});
}, cancel: function (e) {
let ct = $(this);
if (confirm($ict.cdI)) {
$ocms.postXT({
url: $ocms.url('rem/del'), data: {
id: remid
}
});
}
$inv.rReload();
}
});
}
});
};
$inv.sis = (id) => {
if (confirm($ict.sisc)) {
$ocms.postXT({
url: $ocms.url('inv/sis'), data: { id: id || '' }, success: (response) => { }
});
}
};
$inv.srs = (id) => {
if (confirm($ict.srsc)) {
$ocms.postXT({
url: $ocms.url('rem/srs'), data: { id: id || '' }, success: (response) => { }
});
}
};
$inv.mfrrel = (id) => {
$('#contentframe').ldng();
$ocms.postXT({
url: $ocms.url('inv/mfrrel'), data: { id: id || '' }, success: (response) => { $inv.rerenderinv(); }, complete: () => {
$('#contentframe').ldng(0);
}
});
};