Ejemplo n.º 1
0
class By_periodViewWidget(F_Widget):

    def __init__(self, parent=0, *args, **kwargs):
        super(By_periodViewWidget, self).__init__(parent=parent, *args, \
                                                                **kwargs)

        self.table = By_periodTableWidget(parent=self)
        self.title = F_PageTitle(_(u"Periodic report"))

        self.on_date = FormatDate(QtCore.QDate(date.today().year, 01, 01))
        self.end_date = FormatDate(QtCore.QDate.currentDate())
        self.Button = Button(_(u"OK"))
        self.Button.clicked.connect(self.rapport_filter)
        vbox = QtGui.QVBoxLayout()
        # Grid
        gridbox = QtGui.QGridLayout()
        gridbox.addWidget(FormLabel(_(u"On date")), 0, 1)
        gridbox.addWidget(self.on_date, 0, 2)
        gridbox.addWidget(FormLabel(_(u"End date")), 1, 1)
        gridbox.addWidget(self.end_date, 1, 2)
        gridbox.addWidget(FormLabel(""), 0, 3)
        gridbox.addWidget(self.Button, 2, 2)
        gridbox.setColumnStretch(3, 5)

        #~ gridbox.addWidget(FormLabel(_("Reports of ") + \
                                    #~ self.on_date.text() + _(u" to ") + \
                                    #~ self.end_date.text()), 4, 3)
        vbox.addWidget(self.title)
        vbox.addLayout(gridbox)
        vbox.addWidget(self.table)
        self.setLayout(vbox)

    def refresh(self):
        l_date = [format_date(self.on_date.text()), \
                  format_date(self.end_date.text())]
        self.table.refresh_period(l_date)

    def rapport_filter(self):
        self.refresh()
Ejemplo n.º 2
0
class InventaireViewWidget(F_Widget):

    def __init__(self, parent=0, *args, **kwargs):
        super(InventaireViewWidget, self).__init__(parent=parent, *args,
                                                                **kwargs)

        self.table = InventaireTableWidget(parent=self)
        self.title = F_PageTitle(_(u"Inventory"))

        self.on_date = FormatDate(QtCore.QDate(date.today().year,\
                                                            01, 01))
        self.end_date = FormatDate(QtCore.QDate.currentDate())
        self.Button = Button(u"Ok")
        self.Button.clicked.connect(self.rapport_filter)
        self.Button_export = Button_export(_(u"Export xls"))
        self.Button_export.clicked.connect(self.rapport_filter)
        vbox = QtGui.QVBoxLayout()
        # Grid
        gridbox = QtGui.QGridLayout()
        gridbox.addWidget(FormLabel(_(u"On date")), 0, 1)
        gridbox.addWidget(self.on_date, 0, 2)
        gridbox.addWidget(FormLabel(_(u"End date")), 1, 1)
        gridbox.addWidget(self.end_date, 1, 2)
        gridbox.addWidget(FormLabel(""), 0, 3)
        gridbox.addWidget(self.Button, 2, 2)
        gridbox.setColumnStretch(3, 5)
        gridbox.addWidget(self.Button_export, 2, 6)
        vbox.addWidget(self.title)
        vbox.addLayout(gridbox)
        vbox.addWidget(self.table)
        self.setLayout(vbox)

    def refresh(self):
        l_date = [format_date(self.on_date.text()),
                  format_date(self.end_date.text())]
        self.table.refresh_period(l_date)

    def rapport_filter(self):
        self.refresh()
Ejemplo n.º 3
0
class AlertViewWidget(QtGui.QDialog, F_Widget):
    def __init__(self, parent, *args, **kwargs):
        QtGui.QDialog.__init__(self, parent, *args, **kwargs)
        self.setWindowTitle(_(u"Alerts"))

        vbox = QtGui.QVBoxLayout()
        vbox.addWidget(F_BoxTitle(_(u"Create Alert")))
        self.objets = QtGui.QTextEdit()
        self.date_a = FormatDate(QtCore.QDate.currentDate())

        vbox = QtGui.QVBoxLayout()
        # Grid
        gridbox = QtGui.QGridLayout()
        gridbox.addWidget(FormLabel(_(u"Objets")), 0, 0)
        gridbox.addWidget(self.objets, 0, 1)
        gridbox.addWidget(FormLabel(_(u"On date")), 1, 0)
        gridbox.addWidget(self.date_a, 1, 1)
        gridbox.setColumnStretch(3, 3)
        butt = Button_save(_(u"Records the change"))
        butt.clicked.connect(self.save_alerte)
        cancel_but = Button_save(_(u"Cancel"))
        cancel_but.clicked.connect(self.cancel)
        gridbox.addWidget(butt, 3, 0)
        gridbox.addWidget(cancel_but, 3, 1)

        vbox.addLayout(gridbox)
        self.setLayout(vbox)

    def cancel(self):
        self.close()

    def save_alerte(self):

        date_a = self.date_a.text()
        day, month, year = date_a.split("/")
        dt = datetime.now()
        datetime_ = datetime(
            int(year), int(month), int(day), int(dt.hour), int(dt.minute), int(dt.second), int(dt.microsecond)
        )
        alt = Alerte()
        alt.objets = unicode(self.objets.toPlainText())
        alt.date_a = datetime_
        alt.save()

        self.cancel()
        raise_success(_(u"Confirmation"), _(u"The store has been changing"))
Ejemplo n.º 4
0
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"))
Ejemplo n.º 5
0
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 = MagasinTableWidget(parent=self)
        tablebox.addWidget(self.table_op)

        self.nbr_carton = QtGui.QLineEdit()
        self.nbr_carton.setDragEnabled(True)
        self.nbr_carton.setValidator(QtGui.QIntValidator())

        self.date_ = FormatDate(QtCore.QDate.currentDate())
        self.date_.setFont(QtGui.QFont("Courier New", 10, True))

        self.time = QtGui.QDateTimeEdit(QtCore.QTime.currentTime())
        formbox = QtGui.QVBoxLayout()
        editbox = QtGui.QGridLayout()
        formbox.addWidget(F_BoxTitle(_(u"add report")))

        self.liste_type = [_(u"input"), _(u"inout")]
        #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 = session.query(Magasin)\
                                    .order_by(desc(Magasin.id)).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 = session.query(Produit)\
                                    .order_by(desc(Produit.id)).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"Number of carton "))), 0, 3)
        editbox.addWidget(self.nbr_carton, 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)
        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()]
        nbr_carton = self.nbr_carton.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.nbr_carton.text()) != "":
            r = remaining(type_,  nbr_carton, magasin.id, produit.id)
            if r[0] == None:
                raise_error(_(u"error"), r[1])
            else:
                report = Rapport(unicode(type_), int(nbr_carton), datetime_)
                report.magasin = magasin
                report.produit = produit
                report.restant = r[0]
                session.add(report)
                session.commit()
                self.nbr_carton.clear()
                self.table_op.refresh_()
                raise_success(_(u"Confirmation"), _(u"Registered operation"))
        else:
            raise_error(_(u"error"), _(u"Donnez le nbre de carton"))
Ejemplo n.º 6
0
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"))
Ejemplo n.º 7
0
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"))
Ejemplo n.º 8
0
class ChiksViewWidget(F_Widget):
    """ Gestion de ps  """

    def __init__(self, parent=0, *args, **kwargs):
        super(ChiksViewWidget, self).__init__(parent=parent,
                                                        *args, **kwargs)

        self.setWindowTitle(_(u"chiks"))
        vbox = QtGui.QVBoxLayout()
        self.title = F_PageTitle(_("chiks"))

        tablebox = QtGui.QVBoxLayout()
        tablebox.addWidget(F_BoxTitle(_(u"Table chiks")))
        self.chiks_table = ChiksTableWidget(parent=self)
        tablebox.addWidget(self.chiks_table)

        formbox = QtGui.QVBoxLayout()
        editbox = QtGui.QGridLayout()

        self.race = QtGui.QLineEdit()
        self.nb_total_chiks = QtGui.QLineEdit()
        self.date_arriver = FormatDate(QtCore.QDate.currentDate())
        self.date_arriver.setFont(QtGui.QFont("Courier New", 10, True))

        #Combobox widget
        self.list_chicken_coop = list(ChickenCoop.select().filter(type_=1))
        self.chicken_coop = QtGui.QComboBox()
        for index in xrange(0, len(self.list_chicken_coop)):
            op = self.list_chicken_coop[index]
            sentence = _(u"%(libelle)s") % {'libelle': op.full_name()}
            self.chicken_coop.addItem(sentence, QtCore.QVariant(op.id))

        butt = Button_save(_(u"Save"))
        self.nb_total_chiks.setValidator(QtGui.QIntValidator())
        editbox.addWidget(QtGui.QLabel((_(u"Nombre de sujet"))), 0, 0)
        editbox.addWidget(self.nb_total_chiks, 1, 0)
        editbox.addWidget(QtGui.QLabel((_(u"Chicken Coop"))), 0, 1)
        editbox.addWidget(self.chicken_coop, 1, 1)
        editbox.addWidget(QtGui.QLabel((_(u"Race"))), 0, 2)
        editbox.addWidget(self.race, 1, 2)
        editbox.addWidget(QtGui.QLabel((_(u"Date"))), 0, 3)
        editbox.addWidget(self.date_arriver, 1, 3)
        editbox.addWidget(butt, 1, 4)

        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_arriver.text()
        day, month, year = date_.split('/')
        dt = datetime.now()
        chicken_coop = self.list_chicken_coop[self.chicken_coop.currentIndex()]
        datetime_ = datetime(int(year), int(month), int(day),
                             int(dt.hour), int(dt.minute), int(dt.second),
                             int(dt.microsecond))

        if unicode(self.nb_total_chiks.text()) != "" :
            if int(self.nb_total_chiks.text()) >= chicken_coop.nbr_sujet_maxi:
                raise_error(_("Error"), _(u"%s can take only %s chicks") \
                    % (chicken_coop.full_name(), chicken_coop.nbr_sujet_maxi))
            else:
                if chicken_coop.status == 1:
                    raise_error(_("Error"), _(u"%s est occupée") \
                    % (chicken_coop.full_name()))
                else:
                    ps = PsArrivage()
                    ps.race = unicode(self.race.text())
                    ps.nb_total_chiks = int(self.nb_total_chiks.text())
                    ps.arrival_date = datetime_
                    ps.chicken_coop = chicken_coop
                    ps.chicken_coop.status = 1
                    chicken_coop.save()
                    ps.save()
                    self.nb_total_chiks.clear()
                    self.race.clear()
                    self.chiks_table.refresh_()
                    raise_success(_(u"Confirmation"), _(u"Registered operation"))
        else:
            raise_error(_("Error"), _(u"Give the number of the chiks"))