Browse Source

WIP: new purchase interface

Neal Wilson 5 years ago
parent
commit
dcfaceb488
Signed by: Neal Wilson <neal@typica.us> GPG Key ID: 2A0BDDE701E66EB9
2 changed files with 318 additions and 2 deletions
  1. 314
    0
      config/Windows/purchase2.xml
  2. 4
    2
      config/config.xml

+ 314
- 0
config/Windows/purchase2.xml View File

@@ -0,0 +1,314 @@
1
+<window id="purchase">
2
+    <layout type="vertical">
3
+        <layout type="horizontal">
4
+            <label>Date:</label>
5
+            <calendar id="date" />
6
+            <label>Vendor:</label>
7
+            <sqldrop data="0" display="0" showdata="false" editable="true" id="vendor">
8
+                <query>SELECT DISTINCT vendor FROM purchase UNION SELECT '' ORDER BY vendor ASC</query>
9
+            </sqldrop>
10
+            <label>Invoice:</label>
11
+            <line id="invoice" />
12
+            <stretch />
13
+        </layout>
14
+        <layout type="stack" id="pages">
15
+            <page>
16
+                <layout type="vertical">
17
+                    <sqltablearray columns="15" id="orderdetails" editable="false" selectionBehavior="rows">
18
+                        <column name="ID" />
19
+                        <column name="Bags" />
20
+                        <column name="Name" />
21
+                        <column name="Cost" />
22
+                        <column name="Bag Weight" />
23
+                        <column name="Total Cost" />
24
+                        <column name="Certifications" />
25
+                        <column name="Attributes" />
26
+                        <column name="Type" />
27
+                        <column name="Update" />
28
+                        <column name="Old Name" />
29
+                        <column name="Old Cost" />
30
+                        <column name="Origin" />
31
+                        <column name="Decaf" />
32
+                        <column name="Decaf Method" />
33
+                    </sqltablearray>
34
+                </layout>
35
+            </page>
36
+            <page>
37
+                <layout type="horizontal">
38
+                    <stretch />
39
+                    <layout type="vertical">
40
+                        <stretch />
41
+                        <button name="New Item" type="push" id="newItem" />
42
+                        <button name="New Fee" type="push" id="newFee" />
43
+                        <button name="Cancel" type="push" id="newCancel" />
44
+                        <stretch />
45
+                    </layout>
46
+                    <stretch />
47
+                </layout>
48
+            </page>
49
+            <page>
50
+                <layout type="vertical">
51
+                    <tabbar id="tabs" />
52
+                    <layout type="stack" id="itemStack">
53
+                        <page>
54
+                            <layout type="form">
55
+                                <row label="Number of Bags">
56
+                                    <line id="itemBags" validator="numeric" />
57
+                                </row>
58
+                                <row label="Item Name">
59
+                                    <sqldrop data="0" display="0" showdata="false" editable="true" id="itemName">
60
+                                        <query>SELECT DISTINCT name FROM coffees UNION SELECT '' ORDER BY name ASC</query>
61
+                                    </sqldrop>
62
+                                </row>
63
+                                <row label="Origin">
64
+                                    <sqldrop data="0" display="0" showdata="false" editable="true" id="itemOrigin">
65
+                                        <query>SELECT DISTINCT origin FROM coffees UNION SELECT '' ORDER BY origin ASC</query>
66
+                                    </sqldrop>
67
+                                </row>
68
+                                <row label="Quantity">
69
+                                    <layout type="horizontal">
70
+                                        <line id="itemQuantity" validator="numeric" />
71
+                                        <sqldrop id="units" />
72
+                                        <sqldrop id="quantityDivision" />
73
+                                    </layout>
74
+                                </row>
75
+                                <row label="Cost">
76
+                                    <layout type="horizontal">
77
+                                        <line id="itemCost" validator="numeric" />
78
+                                        <sqldrop id="costDivision" />
79
+                                    </layout>
80
+                                </row>
81
+                                <row label="Decaffeination">
82
+                                    <layout type="horizontal">
83
+                                        <button type="check" id="isDecaf" name="Decaffeinated" />
84
+                                        <label>Decaffeination Method</label>
85
+                                        <sqldrop data="0" display="0" showdata="false" editable="true" id="decafMethod">
86
+                                            <query>SELECT DISTINCT decaf_method FROM decaf_coffees UNION SELECT '' ORDER BY decaf_method ASC</query>
87
+                                        </sqldrop>
88
+                                    </layout>
89
+                                </row>
90
+                            </layout>
91
+                        </page>
92
+                        <page>
93
+                            <layout type="vertical">
94
+                                <sqltablearray columns="1" id="itemCertifications">
95
+                                    <column name="Certification" delegate="sql" showdata="false" data="0" display="0" editable="true">SELECT DISTINCT certification FROM certifications UNION SELECT '' ORDER BY certification ASC</column>
96
+                                </sqltablearray>
97
+                            </layout>
98
+                        </page>
99
+                        <page>
100
+                            <layout type="vertical">
101
+                                <sqltablearray columns="2" id="itemAttributes">
102
+                                    <column name="Attribute" delegate="sql" showdata="false" data="0" display="0">SELECT DISTINCT name FROM item_attributes UNION SELECT '' ORDER BY name ASC</column>
103
+                                    <column name="Value" />
104
+                                </sqltablearray>
105
+                            </layout>
106
+                        </page>
107
+                    </layout>
108
+                    <layout type="horizontal">
109
+                        <button name="Cancel" type="push" id="itemCancel" />
110
+                        <button name="Delete" type="push" id="itemDelete" />
111
+                        <stretch />
112
+                        <button name="Save" type="push" id="itemSave" />
113
+                    </layout>
114
+                </layout>
115
+            </page>
116
+            <page>
117
+                <layout type="horizontal">
118
+                    <stretch />
119
+                    <layout type="vertical">
120
+                        <stretch />
121
+                        <layout type="form">
122
+                            <row label="Description: ">
123
+                                <line id="feeDescription" />
124
+                            </row>
125
+                            <row label="Price: ">
126
+                                <line id="feePrice" />
127
+                            </row>
128
+                        </layout>
129
+                        <stretch />
130
+                        <layout type="horizontal">
131
+                            <button name="Cancel" type="push" id="feeCancel" />
132
+                            <button name="Delete" type="push" id="feeDelete" />
133
+                            <stretch />
134
+                            <button name="Save" type="push" id="feeSave" />
135
+                        </layout>
136
+                        <stretch />
137
+                    </layout>
138
+                    <stretch />
139
+                </layout>
140
+            </page>
141
+        </layout>
142
+        <stretch />
143
+    </layout>
144
+    <program>
145
+        <![CDATA[
146
+var window = this;
147
+this.windowTitle = TTR("purchase", "Typica - Coffee Purchase");
148
+var pages = findChildObject(this, 'pages');
149
+pages.setCurrentIndex(0);
150
+var table = findChildObject(this, 'orderdetails');
151
+// table.hideColumn(6);
152
+table.hideColumn(7);
153
+table.hideColumn(8);
154
+table.hideColumn(9);
155
+table.hideColumn(10);
156
+table.hideColumn(11);
157
+table.hideColumn(12);
158
+table.hideColumn(13);
159
+table.hideColumn(14);
160
+table.resizeColumnsToContents();
161
+var units = findChildObject(this, 'units');
162
+units.addItem("Lb");
163
+units.addItem("Kg");
164
+var quantityDivision = findChildObject(this, 'quantityDivision');
165
+quantityDivision.addItem("Total");
166
+quantityDivision.addItem("Per Bag");
167
+var costDivision = findChildObject(this, 'costDivision');
168
+costDivision.addItem("Total");
169
+costDivision.addItem("Per Unit");
170
+var isDecaf = findChildObject(this, 'isDecaf');
171
+var decafMethod = findChildObject(this, 'decafMethod');
172
+var itemCertifications = findChildObject(this, 'itemCertifications');
173
+var itemAttributes = findChildObject(this, 'itemAttributes');
174
+var currentRow;
175
+table.doubleClicked.connect(function(index) {
176
+    currentRow = index.row();
177
+    var type = table.data(currentRow, 8, 0);
178
+    if(type == "PURCHASE") {
179
+        loadItemPage();
180
+    } else if(type == "FEE") {
181
+        loadFeePage();
182
+    } else {
183
+        pages.setCurrentIndex(1);
184
+    }
185
+});
186
+var tabs = findChildObject(this, 'tabs');
187
+tabs.addTab(TTR("purchase", "Required Details"));
188
+tabs.addTab(TTR("purchase", "Certifications"));
189
+tabs.addTab(TTR("purchase", "Attributes"));
190
+var itemStack = findChildObject(this, 'itemStack');
191
+tabs.currentChanged.connect(function(index) {
192
+    itemStack.setCurrentIndex(index);
193
+});
194
+function loadItemPage() {
195
+    pages.setCurrentIndex(2);
196
+}
197
+var newItem = findChildObject(this, 'newItem');
198
+newItem.clicked.connect(function() {
199
+    pages.setCurrentIndex(2);
200
+});
201
+var itemBags = findChildObject(this, 'itemBags');
202
+var itemName = findChildObject(this, 'itemName');
203
+var itemOrigin = findChildObject(this, 'itemOrigin');
204
+var itemQuantity = findChildObject(this, 'itemQuantity');
205
+var itemCost = findChildObject(this, 'itemCost');
206
+var itemSave = findChildObject(this, 'itemSave');
207
+function itemClear() {
208
+    itemBags.text = '';
209
+    itemName.currentText = '';
210
+    itemOrigin.currentText = '';
211
+    itemCost.text = '';
212
+    itemQuantity.text = '';
213
+    pages.setCurrentIndex(0);
214
+}
215
+var itemCancel = findChildObject(this, 'itemCancel');
216
+itemCancel.clicked.connect(function() {
217
+    itemClear();
218
+});
219
+itemSave.clicked.connect(function() {
220
+    if(table.data(currentRow, 9, 0) == "NOP") {
221
+        table.setData(currentRow, 0, "UPDATE", 0);
222
+    } else {
223
+        table.setData(currentRow, 9, "INSERT", 0);
224
+    }
225
+    table.setData(currentRow, 8, "PURCHASE", 0);
226
+    table.setData(currentRow, 1, itemBags.text, 0);
227
+    table.setData(currentRow, 2, itemName.currentText, 0);
228
+    table.setData(currentRow, 12, itemOrigin.currentText, 0);
229
+    var factor = 1;
230
+    if(units.currentIndex == 1) {
231
+        factor = 2.2;
232
+    }
233
+    if(costDivision.currentIndex == 1) {
234
+        table.setData(currentRow, 3, Number(itemCost.text)/factor, 0);
235
+    } else {
236
+        if(quantityDivision.currentIndex == 0) {
237
+            table.setData(currentRow, 3, Number(itemCost.text)/Number(itemQuantity.text)/factor, 0);
238
+        } else {
239
+            table.setData(currentRow, 3, Number(itemCost.text)/(Number(itemQuantity.text)*Number(itemBags.text))/factor, 0);
240
+        }
241
+    }
242
+    if(quantityDivision.currentIndex == 1) {
243
+        table.setData(currentRow, 4, Number(itemQuantity.text)/factor, 0);
244
+    } else {
245
+        table.setData(currentRow, 4, Number(itemQuantity.text)/Number(itemBags.text)/factor, 0);
246
+    }
247
+    table.setData(currentRow, 5, Number(table.data(currentRow, 1, 0)) * Number(table.data(currentRow, 3, 0)) * Number(table.data(currentRow, 4, 0)));
248
+    if(isDecaf.checked) {
249
+        table.setData(currentRow, 13, "true", 0);
250
+        table.setData(currentRow, 14, decafMethod.currentText, 0);
251
+    } else {
252
+        table.setData(currentRow, 13, "false", 0);
253
+    }
254
+    if(itemCertifications.model().rowCount() > 1) {
255
+        table.setData(currentRow, 6, itemCertifications.quotedColumnArray(0, 0), 0);
256
+    }
257
+    itemClear();
258
+});
259
+var newCancel = findChildObject(this, 'newCancel');
260
+newCancel.clicked.connect(function() {
261
+    pages.setCurrentIndex(0);
262
+});
263
+var newFee = findChildObject(this, 'newFee');
264
+newFee.clicked.connect(function() {
265
+    pages.setCurrentIndex(3);
266
+});
267
+var feeCancel = findChildObject(this, 'feeCancel');
268
+feeCancel.clicked.connect(function() {
269
+    clearFeePage();
270
+});
271
+var feeDescription = findChildObject(this, 'feeDescription');
272
+var feePrice = findChildObject(this, 'feePrice');
273
+var feeSave = findChildObject(this, 'feeSave');
274
+feeSave.clicked.connect(function() {
275
+    if(table.data(currentRow, 9, 0) == "NOP") {
276
+        table.setData(currentRow, 10, table.data(currentRow, 2, 0));
277
+        table.setData(currentRow, 11, table.data(currentRow, 5, 0));
278
+        table.setData(currentRow, 0, "UPDATE", 0);
279
+    } else {
280
+        table.setData(currentRow, 9, "INSERT", 0);
281
+    }
282
+    table.setData(currentRow, 2, feeDescription.text, 0);
283
+    table.setData(currentRow, 3, feePrice.text, 0);
284
+    table.setData(currentRow, 5, feePrice.text, 0);
285
+    table.setData(currentRow, 8, "FEE", 0);
286
+    clearFeePage();
287
+});
288
+function clearFeePage() {
289
+    feeDescription.text = "";
290
+    feePrice.text = "";
291
+    table.resizeColumnsToContents();
292
+    pages.setCurrentIndex(0);
293
+}
294
+function loadFeePage() {
295
+    feeDescription.text = table.data(currentRow, 2, 0);
296
+    feePrice.text = table.data(currentRow, 5, 0);
297
+    pages.setCurrentIndex(3);
298
+}
299
+var feeDelete = findChildObject(this, 'feeDelete');
300
+feeDelete.clicked.connect(function() {
301
+    if(table.data(currentRow, 9, 0) == "INSERT") {
302
+        table.removeRow(currentRow);
303
+    } else if(table.data(currentRow, 9, 0) == "UPDATE") {
304
+        table.setData(currentRow, 9, "DELETE", 0);
305
+        table.hideRow(currentRow);
306
+    } else if(table.data(currentRow, 9, 0) == "NOP") {
307
+        table.setData(currentRow, 9, "DELETE", 0);
308
+        table.hideRow(currentRow);
309
+    }
310
+    clearFeePage();
311
+});
312
+        ]]>
313
+    </program>
314
+</window>

+ 4
- 2
config/config.xml View File

@@ -21,7 +21,7 @@
21 21
     <include src="Windows/cuppingformsbysession.xml" />
22 22
     <include src="Windows/cuppingsessionsummary.xml" />
23 23
     <include src="Windows/cuppingsummary.xml" />
24
-    <include src="Windows/purchase.xml" />
24
+    <include src="Windows/purchase2.xml" />
25 25
     <include src="Windows/invoiceinfo.xml" />
26 26
     <include src="Windows/editinvoice.xml" />
27 27
     <include src="Windows/editinvoiceitem.xml" />
@@ -36,8 +36,10 @@
36 36
 	<include src="Windows/manuallogentry.xml" />
37 37
     <include src="Windows/schedule.xml" />
38 38
 	<include src="Windows/editinventorytransaction.xml" />
39
+    <include src="Windows/departmentlist.xml" />
40
+    <include src="Windows/renamedepartment.xml" />
39 41
     <program>
40
-        <![CDATA[
42
+        <![CDATA[        
41 43
             Windows = new Object();
42 44
             var loggingWindow;
43 45
             var currentBatchInfo;

Loading…
Cancel
Save