dh_ackergaul
vor 3 Tagen bb80cdf5a6157ca1f3a276e12e9faae9a4739cb7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
<!DOCTYPE html>
<html>
 
<head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=11">
    <title>GenericKataTree</title>
    <script language="JavaScript" src="../../../js/default.js"></script>
    <style>
        body {
            font-family: "Segoe UI", Calibri, Helvetica, Arial, sans-serif;
            font-size: 14px;
            color: #212121;
            background-color: #ffffff;
            margin: 0;
            padding: 16px;
        }
 
        .articleForm {
            max-width: 360px;
            border: 1px solid #D1D3D4;
            padding: 16px;
        }
 
        .articleForm h2 {
            margin: 0 0 12px;
            font-size: 16px;
            font-weight: bold;
        }
 
        .articleForm .formRow {
            margin-bottom: 10px;
        }
 
        .articleForm label {
            display: block;
            margin-bottom: 3px;
            font-weight: bold;
            color: #333333;
        }
 
        /* width 95% statt 100% + box-sizing: IE7 unterstuetzt box-sizing nicht */
        .articleForm input {
            width: 95%;
            padding: 5px 7px;
            border: 1px solid #bdbdbd;
            background-color: #ffffff;
            font-family: "Segoe UI", Calibri, Arial, sans-serif;
            font-size: 13px;
            color: #212121;
        }
 
        .articleForm input:focus {
            border-color: #F7931E;
        }
 
        .articleForm .formActions {
            margin-top: 14px;
            text-align: right;
        }
 
        .articleForm button {
            padding: 5px 14px;
            margin-left: 6px;
            border: 1px solid #bdbdbd;
            background-color: #f0f0f0;
            color: #212121;
            font-family: inherit;
            font-size: 13px;
            cursor: pointer;
        }
 
        .articleForm button:hover {
            background-color: #E8E8E8;
            border-color: #808285;
        }
 
        .articleForm button.primary {
            background-color: #F7931E;
            border-color: #F7931E;
            color: #ffffff;
        }
 
        .articleForm button.primary:hover {
            background-color: #ff8014;
            border-color: #ff8014;
        }
 
        /* ----- Artikelliste (Tabelle) ----- */
        .articleTable {
            margin-top: 24px;
            border-collapse: collapse;
            border: 1px solid #D1D3D4;
            width: 600px;
            font-family: "Segoe UI", Calibri, Arial, sans-serif;
            font-size: 13px;
        }
 
        .articleTable th,
        .articleTable td {
            border: 1px solid #ECECEC;
            padding: 6px 10px;
            text-align: left;
            vertical-align: middle;
        }
 
        .articleTable thead th {
            background-color: #ECECEC;
            color: #212121;
            font-weight: bold;
        }
 
        .articleTable tbody tr {
            background-color: #ffffff;
        }
 
        .articleTable tbody tr.alt {
            background-color: #fbfbfb;
        }
 
        .articleTable .priceCell,
        .articleTable .qtyCell {
            text-align: right;
            white-space: nowrap;
        }
 
        .articleTable .qtyCell {
            width: 60px;
        }
 
        .articleTable .actionCell {
            width: 80px;
            text-align: center;
        }
 
        .articleTable .emptyState {
            color: #707070;
            font-style: italic;
            text-align: center;
            padding: 14px;
        }
 
        .articleTable button.deleteBtn {
            padding: 3px 10px;
            border: 1px solid #bdbdbd;
            background-color: #f0f0f0;
            color: #212121;
            font-family: "Segoe UI", Calibri, Arial, sans-serif;
            font-size: 12px;
            cursor: pointer;
        }
 
        .articleTable button.deleteBtn:hover {
            background-color: #808285;
            border-color: #555555;
            color: #ffffff;
        }
    </style>
</head>
 
<body>
 
    <form id="articleForm" class="articleForm">
 
        <div class="formActions">
            <button type="button" onclick="openDialog()">Dialog anzeigen</button>
        </div>
        <h2>Artikel erfassen</h2>
 
        <div class="formRow">
            <label for="artNr">Artikelnummer</label>
            <input type="text" id="artNr" name="artNr">
        </div>
 
        <div class="formRow">
            <label for="artDescription">Artikelbeschreibung</label>
            <input type="text" id="artDescription" name="artDescription">
        </div>
 
        <div class="formRow">
            <label for="artPrice">Artikelpreis (&euro;)</label>
            <input type="text" id="artPrice" name="artPrice" onkeyup="filterPriceInput(this);"
                onchange="filterPriceInput(this);"
                onpaste="setTimeout(function(){filterPriceInput(document.getElementById('artPrice'));},0);">
        </div>
 
        <div class="formRow">
            <label for="artQuantity">Menge</label>
            <input type="text" id="artQuantity" name="artQuantity" value="1" onkeyup="filterQuantityInput(this);"
                onchange="filterQuantityInput(this);"
                onpaste="setTimeout(function(){filterQuantityInput(document.getElementById('artQuantity'));},0);">
        </div>
 
        <div class="formActions">
 
            <button type="button" class="primary" onclick="addArticle()">Speichern</button>
        </div>
    </form>
 
    <table id="articleTable" class="articleTable" cellspacing="0">
        <thead>
            <tr>
                <th>GUID</th>
                <th>Artikelnummer</th>
                <th>Beschreibung</th>
                <th>Menge</th>
                <th>Preis</th>
                <th>&nbsp;</th>
            </tr>
        </thead>
        <tbody id="articleTableBody">
            <tr>
                <td colspan="5" class="emptyState">Noch keine Artikel erfasst.</td>
            </tr>
        </tbody>
    </table>
 
</body>
<script type="text/javascript">
 
 
    var posList = DoSyncFPSAction("AdditionalPositions.GetArticleList", []);
 
    debugger;
 
    // ----- Liste & Render -----
    var articleList = [];
    // ----- Modell -----
    function Artikel(id, artNr, description, price, quantity) {
        this.id = id;
        this.artNr = artNr;
        this.description = description;
        this.price = price;
        this.quantity = quantity;
    }
    Artikel.prototype.getPriceFormatted = function () {
        return this.price + " &euro;";
    };
    // ----- Submit -----
    function addArticle() {
        var artNr = document.getElementById("artNr");
        var artDesc = document.getElementById("artDescription");
        var artPrice = document.getElementById("artPrice");
        var artQty = document.getElementById("artQuantity");
 
        if (artNr.value.length === 0) {
            // alert("Bitte Artikelnummer eingeben.");
            // artNr.focus();
            // return false;
        }
        if (artDesc.value.length === 0) {
            alert("Bitte Artikelbeschreibung eingeben.");
            artDesc.focus();
            return false;
        }
        if (!isValidPrice(artPrice.value)) {
            alert("Bitte einen gueltigen Preis aus Ziffern und optional einem Punkt eingeben (z.B. 12.50).");
            artPrice.focus();
            return false;
        }
        if (!isValidQuantity(artQty.value)) {
            alert("Bitte eine ganzzahlige Menge groesser als 0 eingeben.");
            artQty.focus();
            return false;
        }
 
 
 
        var newPos = DoSyncFPSAction("AdditionalPositions.AddNeutralArticle", { "artNr": artNr.value, "artDesc": artDesc.value, "artPrice": artPrice.value, "artQty": artQty.value });
        debugger;
        articleList[articleList.length] = new Artikel(
            newPos.id,
            newPos.artNr,
            newPos.artDesc,
            newPos.artPrice,
            newPos.artQty
        );
        renderArticleTable();
    }
 
 
    function deleteArticle(guid) {
        // Array.prototype.splice ist in IE7 verfuegbar (ES3).
        var list = DoSyncFPSAction("AdditionalPositions.DeleteArticle", { "artPosIds": [guid] });
        debugger;
        renderArticleTable();
    }
 
 
    function renderArticleTable() {
        var tbody = document.getElementById("articleTableBody");
        if (!tbody) return;
 
        // IE wirft "Unknown runtime error" beim Setzen von innerHTML auf
        // tbody/table/tr -> Zeilen ueber das DOM-Tableprogramming-Interface neu aufbauen.
        while (tbody.rows.length > 0) {
            tbody.deleteRow(0);
        }
 
        if (articleList.length === 0) {
            var emptyRow = tbody.insertRow(-1);
            var emptyCell = emptyRow.insertCell(-1);
            emptyCell.colSpan = 6;
            emptyCell.className = "emptyState";
            emptyCell.appendChild(document.createTextNode("Noch keine Artikel erfasst."));
            return;
        }
 
        for (var i = 0; i < articleList.length; i++) {
            var a = articleList[i];
            var row = tbody.insertRow(-1);
            if (i % 2 === 1) {
                row.className = "alt";
            }
 
            row.insertCell(-1).appendChild(document.createTextNode(a.id == null ? "" : String(a.id)));
            row.insertCell(-1).appendChild(document.createTextNode(a.artNr == null ? "" : String(a.artNr)));
            row.insertCell(-1).appendChild(document.createTextNode(a.description == null ? "" : String(a.description)));
 
            var qtyCell = row.insertCell(-1);
            qtyCell.className = "qtyCell";
            qtyCell.appendChild(document.createTextNode(a.quantity == null ? "" : String(a.quantity)));
 
            var priceCell = row.insertCell(-1);
            priceCell.className = "priceCell";
            priceCell.appendChild(document.createTextNode(a.getPriceFormatted()));
 
            var actionCell = row.insertCell(-1);
            actionCell.className = "actionCell";
            // <input type="button"> statt <button>, weil im IE die "type"-
            // Eigenschaft eines via createElement("button") erzeugten Elements
            // nicht mehr aenderbar ist ("Das Objekt unterstuetzt diese Aktion nicht").
            var btn = document.createElement("input");
            btn.type = "button";
            btn.className = "deleteBtn";
            btn.value = "Löschen";
            // Closure ueber i, damit jeder Button seinen eigenen Index behaelt.
            btn.onclick = (function (idx) { return function () { deleteArticle(a.id); }; })(i);
            actionCell.appendChild(btn);
        }
    }
 
 
    function escapeHtml(s) {
        if (s === null || s === undefined) return "";
        return String(s)
            .replace(/&/g, "&amp;")
            .replace(/</g, "&lt;")
            .replace(/>/g, "&gt;")
            .replace(/"/g, "&quot;")
            .replace(/'/g, "&#39;");
    }
 
    // ----- Preis-Filter / Validierung -----
    function filterPriceInput(input) {
        var val = input.value;
        var cleaned = val.replace(/[^0-9.]/g, "");
        var firstDot = cleaned.indexOf(".");
        if (firstDot !== -1) {
            cleaned = cleaned.substring(0, firstDot + 1)
                + cleaned.substring(firstDot + 1).replace(/\./g, "");
        }
        if (cleaned !== val) {
            input.value = cleaned;
        }
    }
 
    function isValidPrice(val) {
        if (val.length === 0) return false;
        return /^[0-9]+(\.[0-9]+)?$/.test(val);
    }
 
    // Menge: nur Ziffern, kein Punkt, keine fuehrenden Nullen erzwungen, mindestens 1.
    function filterQuantityInput(input) {
        var cleaned = input.value.replace(/[^0-9]/g, "");
        if (cleaned !== input.value) {
            input.value = cleaned;
        }
    }
 
    function isValidQuantity(val) {
        if (val.length === 0) return false;
        if (!/^[0-9]+$/.test(val)) return false;
        return parseInt(val, 10) > 0;
    }
 
    function openDialog() {
        var Version = DhMcControlObj.StringValueDest(-340, 0).value;
        var FPVersion = DhMcControlObj.TableValueDest(32, 92715, 0, 0).value;
 
        if (FPVersion === "Development EGGO" || FPVersion === "Furnplan Eggo") {
            if (window.event && window.event.ctrlKey === true) {
                // Bei EGGO mit gedrückter STRG-Taste neuen Dialog öffnen
                DhMcControlObj.DoActionSimpleCL(17024);
                return;
            } else {
                parent.parent.OpenConfigMenu("../zusatzpos.html");
                return;
            }
        }
 
        if (window.event && window.event.ctrlKey === true) {
            parent.parent.OpenConfigMenu("../zusatzpos.html");
            return;
        }
 
        DhMcControlObj.DoActionSimpleCL(17024);
    }
</script>
 
</html>