2 Commits

Author SHA1 Message Date
  Neal Wilson dcfaceb488
WIP: new purchase interface 4 years ago
  Neal Wilson 6735c11109
Prototype department list management 4 years ago

+ 39
- 0
config/Windows/departmentlist.xml View File

@@ -0,0 +1,39 @@
1
+<window id="departmentlist">
2
+    <layout type="vertical">
3
+        <layout type="horizontal">
4
+            <!-- Reserved for filters, &c. -->
5
+        </layout>
6
+        <sqlview id="departments" />
7
+    </layout>
8
+    <menu name="File">
9
+        <item id="newdepartment">New Department</item>
10
+    </menu>
11
+    <program>
12
+        <![CDATA[
13
+var window = this;
14
+this.windowTitle = TTR("departmentlist", "Typica - Department List");
15
+var departments = findChildObject(this, "departments");
16
+var update = function() {
17
+    departments.setQuery("SELECT id, name FROM depts ORDER BY id");
18
+};
19
+update();
20
+//var notification = Application.subscribe("deptschange");
21
+//notification.notify.connect(update);
22
+departments.openEntryRow.connect(function(row) {
23
+    var args = new Object;
24
+    args.newDepartment = false;
25
+    args.currentName = departments.data(row, 1);
26
+    args.departmentId = departments.data(row, 0);
27
+    args.updateCallback = update;
28
+    createWindow("renamedepartment", args);
29
+});
30
+var newdepartment = findChildObject(this, "newdepartment");
31
+newdepartment.triggered.connect(function() {
32
+    var args = new Object;
33
+    args.newDepartment = true;
34
+    args.updateCallback = update;
35
+    createWindow("renamedepartment", args);
36
+});
37
+        ]]>
38
+    </program>
39
+</window>

+ 13
- 10
config/Windows/navigation.xml View File

@@ -2,11 +2,6 @@
2 2
     <layout type="horizontal">
3 3
     <layout type="vertical">
4 4
     <layout type="grid">
5
-        <row>
6
-            <column>
7
-                <button name="Configure Roasters" id="configure" type="push" />
8
-            </column>
9
-        </row>
10 5
         <row>
11 6
             <column>
12 7
                 <button name="Roasting Schedule" id="schedule" type="push" />
@@ -81,13 +76,17 @@
81 76
     <webview id="dashboard" stretch="1" />
82 77
     </layout>
83 78
     <menu name="Reports" type="reports" src="Reports" />
84
-    <menu name="Database">
85
-        <item id="resetconnection">Forget Connection Details</item>
86
-    </menu>
87 79
 	<menu name="Users">
88 80
 		<item id="switchuser">Switch User</item>
89 81
 		<item id="createuser">Create New Users</item>
90 82
 	</menu>
83
+    <menu name="Settings">
84
+        <item id="resetconnection">Forget Database Connection</item>
85
+        <item id="configure">Preferences</item>
86
+    </menu>
87
+    <menu name="Lists">
88
+        <item id="departmentlist">Department List</item>
89
+    </menu>
91 90
     <program>
92 91
         var window = this;
93 92
         var navigationwindow = window;
@@ -182,11 +181,15 @@
182 181
                 window.loggingWindow.activateWindow();
183 182
             }
184 183
         });
185
-        var configurebutton = findChildObject(this, 'configure');
186
-        configurebutton.clicked.connect(function() {
184
+        var configure = findChildObject(this, 'configure');
185
+        configure.triggered.connect(function() {
187 186
             var confwindow = new SettingsWindow;
188 187
             confwindow.show();
189 188
         });
189
+        var departmentlist = findChildObject(this, 'departmentlist');
190
+        departmentlist.triggered.connect(function() {
191
+            createWindow("departmentlist");
192
+        });
190 193
         <![CDATA[
191 194
             var DBCreateBase = function() {
192 195
                 var query = new QSqlQuery();

+ 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>

+ 38
- 0
config/Windows/renamedepartment.xml View File

@@ -0,0 +1,38 @@
1
+<window id="renamedepartment">
2
+    <layout type="vertical">
3
+        <layout type="horizontal">
4
+            <label>Department Name:</label>
5
+            <line id="namefield" />
6
+        </layout>
7
+        <layout type="horizontal">
8
+            <button name="Save" type="push" id="save" />
9
+        </layout>
10
+    </layout>
11
+    <program>
12
+        <![CDATA[
13
+var window = this;
14
+this.windowTitle = "Typica - Set Department Name";
15
+var namefield = findChildObject(this, "namefield");
16
+if(this.arguments.newDepartment) {
17
+    namefield.text = "New Department";
18
+} else {
19
+    namefield.text = this.arguments.currentName;
20
+}
21
+var save = findChildObject(this, "save");
22
+save.clicked.connect(function() {
23
+    var query = new QSqlQuery();
24
+    if(window.arguments.newDepartment) {
25
+        query.prepare("INSERT INTO depts(id, name) VALUES (default, :name)");
26
+    } else {
27
+        query.prepare("UPDATE depts SET name = :name WHERE id = :id");
28
+        query.bind(":id", window.arguments.departmentId);
29
+    }
30
+    query.bind(":name", namefield.text);
31
+    query.exec();
32
+    query.invalidate();
33
+    window.arguments.updateCallback();
34
+    window.close();
35
+});
36
+        ]]>
37
+    </program>
38
+</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