Neal Wilson 7 gadus atpakaļ
vecāks
revīzija
364c6d4199
1 mainītis faili ar 45 papildinājumiem un 0 dzēšanām
  1. 45
    0
      config/Windows/purchase.xml

+ 45
- 0
config/Windows/purchase.xml Parādīt failu

@@ -201,7 +201,52 @@
201 201
             var feesTable = findChildObject(this, 'fees');
202 202
             var submitButton = findChildObject(this, 'submit');
203 203
             var dateField = findChildObject(this, 'date');
204
+            var validate = function() {
205
+                if(vendorField.currentText == '') {
206
+                    displayError(TTR("purchase", "Missing Input"),
207
+                                 TTR("purchase", "Vendor is a required field."));
208
+                    return false;
209
+                }
210
+                for(var i = 0; i < form.elements(); i++) {
211
+                    if(findChildObject(form.elementAt(i), 'name').text == '') {
212
+                        displayError(TTR("purchase", "Missing Input"),
213
+                                     TTR("purchase", "Item is a required field."));
214
+                        return false;
215
+                    }
216
+                    if(findChildObject(form.elementAt(i), 'quantity').text == '') {
217
+                        displayError(TTR("purchase", "Missing Input"),
218
+                                     TTR("purchase", "Quantity is a required field."));
219
+                        return false;
220
+                    }
221
+                    if(findChildObject(form.elementAt(i), 'cost').text == '') {
222
+                        displayError(TTR("purchase", "Missing Input"),
223
+                                     TTR("purchase", "Cost is a required field."));
224
+                        return false;
225
+                    }
226
+                    if(findChildObject(form.elementAt(i), 'origin').currentText == '') {
227
+                        displayError(TTR("purchase", "Missing Input"),
228
+                                     TTR("purchase", "Origin is a required field."));
229
+                        return false;
230
+                    }
231
+                    if(findChildObject(form.elementAt(i), 'bags').text == '') {
232
+                        displayError(TTR("purchase", "Missing Input"),
233
+                                     TTR("purchase", "Bags is a required field."));
234
+                        return false;
235
+                    }
236
+                    if(findChildObject(form.elementAt(i), 'isDecaf').checked) {
237
+                        if(findChildObject(form.elementAt(i), 'decafEntry').currentText) {
238
+                            displayError(TTR("purchase", "Missing Input"),
239
+                                         TTR("purchase", "Decaffeination method is a required field for decaffeinated coffees."));
240
+                            return false;
241
+                        }
242
+                    }
243
+                }
244
+                return true;
245
+            };
204 246
             submitButton.clicked.connect(function() {
247
+                if(!validate()) {
248
+                    return;
249
+                }
205 250
                 var query = new QSqlQuery;
206 251
                 var q = "INSERT INTO invoices (id, invoice, vendor, time) VALUES (default, :invoice, :vendor, :date) RETURNING id";
207 252
                 query.prepare(q);

Notiek ielāde…
Atcelt
Saglabāt