Neal Wilson пре 7 година
родитељ
комит
38b2cd6438
1 измењених фајлова са 113 додато и 108 уклоњено
  1. 113
    108
      config/Windows/editinvoiceitem.xml

+ 113
- 108
config/Windows/editinvoiceitem.xml Прегледај датотеку

@@ -1,109 +1,114 @@
1 1
 <window id="invoiceitemdetail">
2
-	<layout type="vertical">
3
-		<layout type="grid">
4
-			<row>
5
-				<column><label>Name</label></column>
6
-				<column><line id="name" /></column>
7
-			</row>
8
-			<row>
9
-				<column><label>Reference</label></column>
10
-				<column><line id="reference" /></column>
11
-			</row>
12
-			<row>
13
-				<column><label>Unit Cost</label></column>
14
-				<column><line validator="numeric" id="cost" /></column>
15
-			</row>
16
-			<row>
17
-				<column><label>Quantity</label></column>
18
-				<column><line validator="numeric" id="quantity" /></column>
19
-			</row>
20
-			<row>
21
-				<column><label>Bags</label></column>
22
-				<column><line validator="numeric" id="bags" /></column>
23
-			</row>
24
-		</layout>
25
-		<button name="Submit" type="push" id="submit" />
26
-	</layout>
27
-	<program>
28
-		<![CDATA[
29
-			window = this;
30
-			this.windowTitle = 'Typica - Item Detail';
31
-			var nameField = findChildObject(this, 'name');
32
-			var referenceField = findChildObject(this, 'reference');
33
-			var costField = findChildObject(this, 'cost');
34
-			var quantityField = findChildObject(this, 'quantity');
35
-			var bagsField = findChildObject(this, 'bags');
36
-			this.dataSet = function() {
37
-				nameField.text = window.rowData[2];
38
-				referenceField.text = window.rowData[3];
39
-				costField.text = window.rowData[4];
40
-				quantityField.text = window.rowData[5];
41
-				bagsField.text = window.rowData[6];
42
-			};
43
-			button = findChildObject(this, 'submit');
44
-			button.clicked.connect(function() {
45
-				var query = new QSqlQuery();
46
-				if(nameField.text != window.rowData[2]) {
47
-					query.prepare("UPDATE items SET name = :name WHERE id = :id");
48
-					query.bind(":name", nameField.text);
49
-					query.bind(":id", Number(window.rowData[1]));
50
-					query.exec();
51
-					query.prepare("UPDATE invoice_items SET description = :name WHERE item_id = :id");
52
-					query.bind(":name", nameField.text);
53
-					query.bind(":id", Number(window.rowData[1]));
54
-					query.exec();
55
-					window.rowData[2] = nameField.text;
56
-				}
57
-				if(referenceField.text != window.rowData[3]) {
58
-					query.prepare("UPDATE items SET reference = :ref WHERE id = :id");
59
-					query.bind(":ref", referenceField.text);
60
-					query.bind(":id", Number(window.rowData[1]));
61
-					query.exec();
62
-					window.rowData[3] = referenceField.text;
63
-				}
64
-				var cqupdated = false;
65
-				var qbupdated = false;
66
-				if(costField.text != window.rowData[4]) {
67
-					cqupdated = true;
68
-					query.prepare("UPDATE purchase SET cost = :cost WHERE item = :id");
69
-					query.bind(":cost", Number(costField.text));
70
-					query.bind(":id", Number(window.rowData[1]));
71
-					query.exec();
72
-					window.rowData[4] = costField.text;
73
-				}
74
-				if(quantityField.text != window.rowData[5]) {
75
-					cqupdated = true;
76
-					qbupdated = true;
77
-					query.prepare("UPDATE purchase SET quantity = :qty WHERE item = :id");
78
-					query.bind(":qty", Number(quantityField.text));
79
-					query.bind(":id", Number(window.rowData[1]));
80
-					query.exec();
81
-					window.rowData[5] = quantityField.text;
82
-					query.prepare("UPDATE items SET quantity = (SELECT balance FROM item_history(:id) WHERE time = (SELECT max(time) FROM item_history(:id2))) WHERE id = :id3");
83
-					query.bind(":id", Number(window.rowData[1]));
84
-					query.bind(":id2", Number(window.rowData[1]));
85
-					query.bind(":id3", Number(window.rowData[1]));
86
-					query.exec();
87
-				}
88
-				if(bagsField.text != window.rowData[6]) {
89
-					qbupdated = true;
90
-					window.rowData[6] = bagsField.text;
91
-				}
92
-				if(cqupdated) {
93
-					query.prepare("UPDATE invoice_items SET cost = :total WHERE item_id = :id");
94
-					query.bind(":total", Number(window.rowData[5]) * Number(window.rowData[4]));
95
-					query.bind(":id", Number(window.rowData[1]));
96
-					query.exec();
97
-				}
98
-				if(qbupdated) {
99
-					query.prepare("UPDATE lb_bag_conversion SET conversion = :conv WHERE item = :id");
100
-					query.bind(":conv", Number(window.rowData[5]) / Number(window.rowData[6]));
101
-					query.bind(":id", Number(window.rowData[1]));
102
-					query.exec();
103
-				}
104
-				query = query.invalidate();
105
-				window.close();
106
-			});
107
-		]]>
108
-	</program>
109
-</window>
2
+    <layout type="vertical">
3
+        <layout type="grid">
4
+            <row>
5
+                <column><label>Name</label></column>
6
+                <column><line id="name" /></column>
7
+            </row>
8
+            <row>
9
+                <column><label>Reference</label></column>
10
+                <column><line id="reference" /></column>
11
+            </row>
12
+            <row>
13
+                <column><label>Unit Cost</label></column>
14
+                <column><line validator="numeric" id="cost" /></column>
15
+            </row>
16
+            <row>
17
+                <column><label>Quantity</label></column>
18
+                <column><line validator="numeric" id="quantity" /></column>
19
+            </row>
20
+            <row>
21
+                <column><label>Bags</label></column>
22
+                <column><line validator="numeric" id="bags" /></column>
23
+            </row>
24
+        </layout>
25
+        <button name="Submit" type="push" id="submit" />
26
+    </layout>
27
+    <program>
28
+        <![CDATA[
29
+            window = this;
30
+            this.windowTitle = 'Typica - Item Detail';
31
+            var nameField = findChildObject(this, 'name');
32
+            var referenceField = findChildObject(this, 'reference');
33
+            var costField = findChildObject(this, 'cost');
34
+            var quantityField = findChildObject(this, 'quantity');
35
+            var bagsField = findChildObject(this, 'bags');
36
+            this.dataSet = function() {
37
+                nameField.text = window.rowData[2];
38
+                referenceField.text = window.rowData[3];
39
+                costField.text = window.rowData[4];
40
+                quantityField.text = window.rowData[5];
41
+                bagsField.text = window.rowData[6];
42
+            };
43
+            button = findChildObject(this, 'submit');
44
+            button.clicked.connect(function() {
45
+                var query = new QSqlQuery();
46
+                if(nameField.text != window.rowData[2]) {
47
+                    query.prepare("UPDATE items SET name = :name WHERE id = :id");
48
+                    query.bind(":name", nameField.text);
49
+                    query.bind(":id", Number(window.rowData[1]));
50
+                    query.exec();
51
+                    query.prepare("UPDATE invoice_items SET description = :name WHERE item_id = :id");
52
+                    query.bind(":name", nameField.text);
53
+                    query.bind(":id", Number(window.rowData[1]));
54
+                    query.exec();
55
+                    window.rowData[2] = nameField.text;
56
+                }
57
+                if(referenceField.text != window.rowData[3]) {
58
+                    query.prepare("UPDATE items SET reference = :ref WHERE id = :id");
59
+                    query.bind(":ref", referenceField.text);
60
+                    query.bind(":id", Number(window.rowData[1]));
61
+                    query.exec();
62
+                    window.rowData[3] = referenceField.text;
63
+                }
64
+                var cqupdated = false;
65
+                var qbupdated = false;
66
+                if(costField.text != window.rowData[4]) {
67
+                    cqupdated = true;
68
+                    query.prepare("UPDATE purchase SET cost = :cost WHERE item = :id");
69
+                    query.bind(":cost", Number(costField.text));
70
+                    query.bind(":id", Number(window.rowData[1]));
71
+                    query.exec();
72
+                    window.rowData[4] = costField.text;
73
+                }
74
+                if(quantityField.text != window.rowData[5]) {
75
+                    cqupdated = true;
76
+                    qbupdated = true;
77
+                    query.prepare("UPDATE purchase SET quantity = :qty WHERE item = :id");
78
+                    query.bind(":qty", Number(quantityField.text));
79
+                    query.bind(":id", Number(window.rowData[1]));
80
+                    query.exec();
81
+                    window.rowData[5] = quantityField.text;
82
+                    query.prepare("UPDATE items SET quantity = (SELECT balance FROM item_history(:id) WHERE time = (SELECT max(time) FROM item_history(:id2))) WHERE id = :id3");
83
+                    query.bind(":id", Number(window.rowData[1]));
84
+                    query.bind(":id2", Number(window.rowData[1]));
85
+                    query.bind(":id3", Number(window.rowData[1]));
86
+                    query.exec();
87
+                }
88
+                if(bagsField.text != window.rowData[6]) {
89
+                    qbupdated = true;
90
+                    window.rowData[6] = bagsField.text;
91
+                }
92
+                if(cqupdated) {
93
+                    query.prepare("UPDATE invoice_items SET cost = :total WHERE item_id = :id");
94
+                    query.bind(":total", Number(window.rowData[5]) * Number(window.rowData[4]));
95
+                    query.bind(":id", Number(window.rowData[1]));
96
+                    query.exec();
97
+                }
98
+                if(qbupdated) {
99
+                    query.exec("SELECT 1 FROM lb_bag_conversion WHERE item = :id");
100
+                    if(query.next()) {
101
+                        query.prepare("UPDATE lb_bag_conversion SET conversion = :conv WHERE item = :id");
102
+                    } else {
103
+                        query.prepare("INSERT INTO lb_bag_conversion (item, conversion) VALUES (:id, :conv)");
104
+                    }
105
+                    query.bind(":conv", Number(window.rowData[5]) / Number(window.rowData[6]));
106
+                    query.bind(":id", Number(window.rowData[1]));
107
+                    query.exec();
108
+                }
109
+                query = query.invalidate();
110
+                window.close();
111
+            });
112
+        ]]>
113
+    </program>
114
+</window>

Loading…
Откажи
Сачувај