diff --git a/brmbar3/TODO b/brmbar3/TODO index 56c4c09..d0be53d 100644 --- a/brmbar3/TODO +++ b/brmbar3/TODO @@ -2,9 +2,9 @@ + Stock management link + User management link + Bilance overview (Cash, Profit, Credit total) -- Item picker from list (only items with non-zero quantities) -- User management - - List of users +/ Item picker from list (only items with non-zero quantities) +/ User management + + List of users - Withdrawal of user credit - Numerical manual entry support - Use for credit charge diff --git a/brmbar3/brmbar-gui-qt4.py b/brmbar3/brmbar-gui-qt4.py index a0cb280..9ca8943 100755 --- a/brmbar3/brmbar-gui-qt4.py +++ b/brmbar3/brmbar-gui-qt4.py @@ -80,6 +80,10 @@ class ShopAdapter(QtCore.QObject): def balance_credit(self): return shop.credit_negbalance_str() + @QtCore.Slot(result='QVariant') + def userList(self): + return [ self.acct_debt_map(a) for a in shop.account_list("debt") ] + db = psycopg2.connect("dbname=brmbar") shop = brmbar.Shop.new_with_defaults(db) currency = shop.currency diff --git a/brmbar3/brmbar-gui-qt4/Management.qml b/brmbar3/brmbar-gui-qt4/Management.qml index c21c3d9..47a16ac 100644 --- a/brmbar3/brmbar-gui-qt4/Management.qml +++ b/brmbar3/brmbar-gui-qt4/Management.qml @@ -129,6 +129,9 @@ Item { y: 430 width: 360 text: "User Mgmt" + onButtonClick: { + loadPage("UserMgmt") + } } BarButton { diff --git a/brmbar3/brmbar-gui-qt4/UserMgmt.qml b/brmbar3/brmbar-gui-qt4/UserMgmt.qml new file mode 100644 index 0000000..eee1fd9 --- /dev/null +++ b/brmbar3/brmbar-gui-qt4/UserMgmt.qml @@ -0,0 +1,115 @@ +// import QtQuick 1.0 // to target S60 5th Edition or Maemo 5 +import QtQuick 1.1 +import QtQuick 1.0 + +Item { + id: page + anchors.fill: parent + + property variant name: "" + property variant dbid: "" + property variant price: "" + property variant user_list_model + + BarcodeInput { + color: "#00ff00" /* just for debugging */ + onAccepted: { + var acct = shop.barcodeInput(text) + text = "" + if (typeof(acct) == "undefined") { + status_text.setStatus("Unknown barcode", "#ff4444") + return + } + if (acct.acctype != "debt") { + loadPageByAcct(acct) + return + } + loadPage("UserEdit", { name: acct["name"], dbid: acct["id"], negbalance: acct["negbalance"] }) + } + } + + Item { + id: user_list_container + x: 65 + y: 156 + width: 899 + height: 250 + + ListView { + id: user_list + anchors.fill: parent + clip: true + delegate: Item { + x: 5 + height: 80 + + Text { + text: modelData.name + anchors.verticalCenter: parent.verticalCenter + color: "#ffffff" + font.pointSize: 34 + } + + Text { + anchors.verticalCenter: parent.verticalCenter + x: 300 + width: 254 + color: "#ffff7c" + text: modelData.negbalance_str + horizontalAlignment: Text.AlignRight + font.pointSize: 34 + } + + BarButton { + anchors.verticalCenter: parent.verticalCenter + x: 600 + width: 240 + height: 68 + text: "Withdraw" + fontSize: 34 + } + } + model: user_list_model +// model: ListModel { +// ListElement { +// name: "pasky"; negbalance: "400.00 Kč" +// } +// +// ListElement { +// name: "růža"; negbalance: "1200.00 Kč" +// } +// } + } + + BarScrollBar { + id: user_list_scrollbar + anchors.right: parent.right + anchors.rightMargin: 0 + flickableItem: user_list + } + } + + BarButton { + id: add_user + x: 65 + y: 582 + width: 360 + text: "Add User" + fontSize: 44 + } + + BarButton { + id: cancel + x: 599 + y: 582 + width: 360 + text: "Main Screen" + onButtonClick: { + loadPage("MainPage") + } + } + + Component.onCompleted: { + user_list_model = shop.userList() + } +}