class MagasinViewWidget(F_Widget): def __init__(self, magasin="", parent=0, *args, **kwargs): super(MagasinViewWidget, self).__init__(parent=parent, *args, **kwargs) self.setWindowTitle(_(u"Stores")) vbox = QtGui.QVBoxLayout() vbox.addWidget(F_PageTitle(_(u"The list of stores"))) tablebox = QtGui.QVBoxLayout() tablebox.addWidget(F_BoxTitle(_(u"Table stores"))) self.stori_table = MagasinTableWidget(parent=self) tablebox.addWidget(self.stori_table) formbox = QtGui.QVBoxLayout() editbox = QtGui.QGridLayout() self.name = QtGui.QLineEdit() self.qte_maxi_stok = IntLineEdit() editbox.addWidget(QtGui.QLabel((_(u"Name"))), 0, 0) editbox.addWidget(self.name, 1, 0) editbox.addWidget(QtGui.QLabel((_(u"Max quantity"))), 0, 1) editbox.addWidget(self.qte_maxi_stok, 1, 1) editbox.setColumnStretch(0, 2) editbox.setColumnStretch(3, 2) butt = Button_save(_(u"Save")) butt.clicked.connect(self.add_operation) editbox.addWidget(butt, 1, 2) formbox.addLayout(editbox) vbox.addLayout(formbox) vbox.addLayout(tablebox) self.setLayout(vbox) def add_operation(self): ''' add operation ''' if unicode(self.name.text()) != "": magasin = Magasin() magasin.name = unicode(self.name.text()) magasin.qte_maxi_stok = int(self.qte_maxi_stok.text()) magasin.save() self.name.clear() self.qte_maxi_stok.clear() self.stori_table.refresh_() raise_success(_(u"Confirmation"), _(u"Registered operation")) else: raise_error(_("Error"), _(u"Give the name of the store"))
class G_reportViewWidget(F_Widget): def __init__(self, parent=0, *args, **kwargs): super(G_reportViewWidget, self).__init__(parent=parent,\ *args, **kwargs) self.setWindowTitle(_(u"Management reports")) vbox = QtGui.QVBoxLayout() tablebox = QtGui.QVBoxLayout() tablebox.addWidget(F_BoxTitle(_(u"Table rapports"))) self.table_op = StockRapTableWidget(parent=self) tablebox.addWidget(self.table_op) formbox = QtGui.QVBoxLayout() editbox = QtGui.QGridLayout() self.qte_utilise = IntLineEdit() self.qte_utilise.setDragEnabled(True) self.date_ = FormatDate(QtCore.QDate.currentDate()) self.date_.setFont(QtGui.QFont("Courier New", 10, True)) self.time = QtGui.QDateTimeEdit(QtCore.QTime.currentTime()) self.liste_type = [_(u"input"), _(u"out")] #Combobox widget self.box_type = QtGui.QComboBox() for index in self.liste_type: self.box_type.addItem(u'%(type)s' % {'type': index}) #Combobox widget self.liste_magasin = Magasin.all() self.box_mag = QtGui.QComboBox() for index in xrange(0, len(self.liste_magasin)): op = self.liste_magasin[index] sentence = u"%(name)s" % {'name': op.name} self.box_mag.addItem(sentence, QtCore.QVariant(op.id)) #Combobox widget self.liste_produit = Produit.all() self.box_prod = QtGui.QComboBox() for index in xrange(0, len(self.liste_produit)): op = self.liste_produit[index] sentence = _(u"%(libelle)s") % {'libelle': op.libelle} self.box_prod.addItem(sentence, QtCore.QVariant(op.id)) editbox.addWidget(QtGui.QLabel(_(u"Type")), 0, 0) editbox.addWidget(self.box_type, 1, 0) editbox.addWidget(QtGui.QLabel(_(u"Store")), 0, 1) editbox.addWidget(self.box_mag, 1, 1) editbox.addWidget(QtGui.QLabel(_(u"Product")), 0, 2) editbox.addWidget(self.box_prod, 1, 2) editbox.addWidget(QtGui.QLabel((_(u"Quantite utilise"))), 0, 3) editbox.addWidget(self.qte_utilise, 1, 3) editbox.addWidget(QtGui.QLabel((_(u"Date"))), 0, 4) editbox.addWidget(self.date_, 1, 4) butt = Button_save(_(u"Save")) butt.clicked.connect(self.add_operation) editbox.addWidget(butt, 1, 5) formbox.addLayout(editbox) editbox.setColumnStretch(7, 2) vbox.addLayout(formbox) vbox.addLayout(tablebox) self.setLayout(vbox) def refresh(self): self.table_op.refresh() def add_operation(self): ''' add operation ''' type_ = self.liste_type[self.box_type.currentIndex()] magasin = self.liste_magasin[self.box_mag.currentIndex()] produit = self.liste_produit[self.box_prod.currentIndex()] qte_utilise = self.qte_utilise.text() date_ = self.date_.text() day, month, year = date_.split('/') dt = datetime.now() datetime_ = datetime(int(year), int(month), int(day), int(dt.hour), int(dt.minute), int(dt.second), int(dt.microsecond)) if unicode(self.qte_utilise.text()) != "": strap = StockRapport() strap.type_ = unicode(type_) strap.magasin = magasin strap.produit = produit strap.qte_utilise = int(qte_utilise) strap.date_rapp = datetime_ strap.restant = 0 strap.save() self.qte_utilise.clear() self.table_op.refresh_() raise_success(_(u"Confirmation"), _(u"Registered operation")) else: raise_error(_(u"error"), _(u"Give the quantity used"))
class ChickenCoopViewWidget(F_Widget): """ Gestion de pasin """ def __init__(self, parent=0, *args, **kwargs): super(ChickenCoopViewWidget, self).__init__(parent=parent, *args, **kwargs) self.setWindowTitle(_(u"Chicken Coop")) vbox = QtGui.QVBoxLayout() self.title = F_PageTitle(_("Chicken Coop")) tablebox = QtGui.QVBoxLayout() tablebox.addWidget(F_BoxTitle(_(u"Table Chicken Coop"))) self.poussin_table = ChickenCoopTableWidget(parent=self) tablebox.addWidget(self.poussin_table) formbox = QtGui.QVBoxLayout() editbox = QtGui.QGridLayout() butt = Button_save(_(u"Save")) liste_type = [_(u"chicken coop"), _(u"the brooding")] #Combobox widget self.type_ = QtGui.QComboBox() for index in liste_type: self.type_.addItem(u'%(type)s' % {'type': index}) self.num = IntLineEdit() self.nbr_sujet = IntLineEdit() self.nbr_sujet_maxi = IntLineEdit() self.date = FormatDate(QtCore.QDate.currentDate()) self.date.setFont(QtGui.QFont("Courier New", 10, True)) self.num.setValidator(QtGui.QIntValidator()) editbox.addWidget(QtGui.QLabel((_(u"Type"))), 0, 0) editbox.addWidget(self.type_, 1, 0) editbox.addWidget(QtGui.QLabel((_(u"Number of chicken coop"))), 0, 1) editbox.addWidget(self.num, 1, 1) editbox.addWidget(QtGui.QLabel((_(u"Max"))), 0, 2) editbox.addWidget(self.nbr_sujet_maxi, 1, 2) editbox.addWidget(QtGui.QLabel((_(u"Date"))), 0, 3) editbox.addWidget(self.date, 1, 3) editbox.addWidget(butt, 1, 4) butt.clicked.connect(self.add_chickencoop) editbox.addWidget(butt, 1, 2) formbox.addLayout(editbox) vbox.addLayout(formbox) vbox.addLayout(tablebox) self.setLayout(vbox) def add_chickencoop(self): ''' add operation ''' date_ = self.date.text() day, month, year = date_.split('/') dt = datetime.now() datetime_ = datetime(int(year), int(month), int(day), int(dt.hour), int(dt.minute), int(dt.second), int(dt.microsecond)) if unicode(self.num.text()) != "": poussin = ChickenCoop() poussin.type_ = int(self.type_.currentIndex()) poussin.num = int(self.num.text()) poussin.nbr_sujet_maxi = int(self.nbr_sujet_maxi.text()) poussin.date = datetime_ poussin.save() self.num.clear() self.nbr_sujet_maxi.clear() self.poussin_table.refresh_() raise_success(_(u"Confirmation"), _(u"Registered operation")) else: raise_error(_("Error"), _(u"Give the name of the store"))
class PsRapportViewWidget(F_Widget): """ Gestion de ps """ def __init__(self, parent=0, *args, **kwargs): super(PsRapportViewWidget, self).__init__(parent=parent, *args, **kwargs) self.setWindowTitle(_(u"Monitoring")) vbox = QtGui.QVBoxLayout() self.title = F_PageTitle(_("Monitoring")) tablebox = QtGui.QVBoxLayout() tablebox.addWidget(F_BoxTitle(_(u"Table of monitored"))) self.chiks_table = ChiksTableWidget(parent=self) tablebox.addWidget(self.chiks_table) formbox = QtGui.QVBoxLayout() editbox = QtGui.QGridLayout() self.nb_death = IntLineEdit() self.nb_eggs = IntLineEdit() self.weight = FloatLineEdit() self.date_report = FormatDate(QtCore.QDate.currentDate()) self.date_report.setFont(QtGui.QFont("Courier New", 10, True)) #Combobox widget self.list_chicken_coop = ChickenCoop.all() self.chicken_coop = QtGui.QComboBox() for index in xrange(0, len(self.list_chicken_coop)): op = self.list_chicken_coop[index] sentence = _(u"%(full_name)s") % {'full_name': op.full_name()} self.chicken_coop.addItem(sentence, QtCore.QVariant(op.id)) butt = Button_save(_(u"Save")) editbox.addWidget(QtGui.QLabel((_(u"Date"))), 0, 0) editbox.addWidget(self.date_report, 1, 0) editbox.addWidget(QtGui.QLabel((_(u"Chicken coop"))), 0, 1) editbox.addWidget(self.chicken_coop, 1, 1) editbox.addWidget(QtGui.QLabel((_(u"Death"))), 0, 2) editbox.addWidget(self.nb_death, 1, 2) editbox.addWidget(QtGui.QLabel((_(u"Weight"))), 0, 3) editbox.addWidget(self.weight, 1, 3) editbox.addWidget(QtGui.QLabel((_(u"Number of eggs"))), 0, 4) editbox.addWidget(self.nb_eggs, 1, 4) editbox.addWidget(butt, 1, 5) butt.clicked.connect(self.add_chiks) formbox.addLayout(editbox) vbox.addLayout(formbox) vbox.addLayout(tablebox) self.setLayout(vbox) def add_chiks(self): ''' add operation ''' date_ = self.date_report.text() day, month, year = date_.split('/') dt = datetime.now() chicken_coop = self.list_chicken_coop[self.chicken_coop.currentIndex()] print chicken_coop.id datetime_ = datetime(int(year), int(month), int(day), int(dt.hour), int(dt.minute), int(dt.second), int(dt.microsecond)) if unicode(self.nb_death.text()) != "": ps = PsRapport() ps.nb_death = int(self.nb_death.text()) ps.weight = int(self.weight.text()) ps.nb_eggs = int(self.nb_eggs.text()) ps.date_report = datetime_ ps.psarrivage = chicken_coop.id ps.save() self.nb_death.clear() self.nb_eggs.clear() self.weight.clear() self.chiks_table.refresh_() else: raise_error(_("Error"), _(u"Give the number of the death"))