65 lines
2.4 KiB
Python
65 lines
2.4 KiB
Python
# SPDX-License-Identifier: WTFPL
|
|
|
|
import os
|
|
import gi
|
|
gi.require_version("Gtk", "3.0")
|
|
from gi.repository import GLib, Gtk, Gdk
|
|
|
|
from .view import View
|
|
from yms import gtkutils, combobox, treeview
|
|
from yms.model import equipment
|
|
|
|
class EquipmentView(View):
|
|
|
|
def __init__(self, context):
|
|
super().__init__(context, _("Equipment"), "equipment.ui")
|
|
|
|
self.equip = equipment.Equipment(context.db) # current record
|
|
self.newrecord = False
|
|
|
|
self.lst_equipment = Gtk.ListStore(int, str, str, str, str, str, str)
|
|
sql = (
|
|
"SELECT e.eid, e.ename, c.compname, e.model, e.serial, "
|
|
"DATE_FORMAT(e.purchdate, '{}'), e.remarks "
|
|
"FROM equipment AS e LEFT OUTER JOIN company AS c ON (e.manufacturer=c.compid) "
|
|
"WHERE e.vid=%s "
|
|
"ORDER BY e.ename"
|
|
).format("%%d.%%m.%%Y") # TODO format from settings via mapping
|
|
self.db.cur.execute(sql, (context.vessel.vid,))
|
|
for row in self.db.cur.fetchall():
|
|
self.lst_equipment.append(row)
|
|
|
|
treeview.add_column(self.tree['equipment'], _('ID'), 0)
|
|
treeview.add_column(self.tree['equipment'], _('Name'), 1)
|
|
treeview.add_column(self.tree['equipment'], _('Manufacturer'), 2)
|
|
treeview.add_column(self.tree['equipment'], _('Model'), 3)
|
|
treeview.add_column(self.tree['equipment'], _('Serial'), 4)
|
|
treeview.add_column(self.tree['equipment'], _('Age'), 5)
|
|
treeview.add_column(self.tree['equipment'], _('Remarks'), 6)
|
|
self.tree['equipment'].set_model(self.lst_equipment)
|
|
|
|
# buttons on list page
|
|
def on_but_new_clicked(self, widget):
|
|
self.topwidget.set_visible_child(self.box['equip_edit'])
|
|
|
|
def on_but_edit_clicked(self, widget):
|
|
self.topwidget.set_visible_child(self.box['equip_edit'])
|
|
|
|
def on_but_detail_clicked(self, widget):
|
|
self.topwidget.set_visible_child(self.box['equip_detail'])
|
|
|
|
# buttons on detail page
|
|
# edit2 uses edit callback
|
|
def on_but_close_clicked(self, widget):
|
|
self.topwidget.set_visible_child(self.box['equipment'])
|
|
|
|
def on_but_delete_clicked(self, widget):
|
|
self.topwidget.set_visible_child(self.box['equipment'])
|
|
|
|
# buttons on edit page
|
|
def on_but_save_clicked(self, widget):
|
|
pass
|
|
|
|
def on_but_cancel_clicked(self, widget):
|
|
self.topwidget.set_visible_child(self.box['equipment'])
|