Beispiel #1
0
 def famEvent(self, x):
     fnr = self.fnr
     tag = self.tag.name
     tag = utils.num2Tag(tag)
     # print("famEvent", x.text, "Feld", x.name, "Famnr", fnr, "Tag", tag)
     x.normalize()
     try:
         with conn:
             c = conn.cursor()
             r1 = c.execute(
                 "UPDATE arbeitsblatt set " + x.name +
                 " = ? where tag=? and fnr=?", (x.text, tag, fnr))
             if r1.rowcount == 0:  # row did not yet exist
                 vals = {
                     "tag": tag,
                     "fnr": fnr,
                     "einsatzstelle": "",
                     "beginn": "",
                     "ende": "",
                     "fahrtzeit": "",
                     "mvv_euro": "",
                     "kh": 0
                 }
                 vals[x.name] = x.text
                 c.execute(
                     "INSERT INTO arbeitsblatt VALUES(:tag,:fnr,:einsatzstelle,:beginn,:ende,:fahrtzeit,:mvv_euro,:kh)",
                     vals)
     except Exception as e:
         utils.printEx("fam0:", e)
Beispiel #2
0
 def checkBoxEvent(self, x):
     fnr = self.fnr
     tag = self.tag.name
     tag = utils.num2Tag(tag)
     # print("checkBoxEvent state", x.state, "active", x.active, "Famnr", fnr, "Tag", tag)
     try:
         with conn:
             c = conn.cursor()
             r1 = c.execute(
                 "UPDATE arbeitsblatt set kh = ? where tag=? and fnr=?",
                 (int(x.active), tag, fnr))
             if r1.rowcount == 0:  # row did not yet exist
                 vals = {
                     "tag": tag,
                     "fnr": fnr,
                     "einsatzstelle": "",
                     "beginn": "",
                     "ende": "",
                     "fahrtzeit": "",
                     "mvv_euro": "",
                     "kh": int(x.active)
                 }
                 c.execute(
                     "INSERT INTO arbeitsblatt VALUES(:tag,:fnr,:einsatzstelle,:beginn,:ende,:fahrtzeit,:mvv_euro,:kh)",
                     vals)
     except Exception as e:
         utils.printEx("fam0:", e)
Beispiel #3
0
 def fillinStdBegEnd(self, wtag2Stunden):
     if self.ids.beginn.text != "" or self.ids.ende.text != "":
         return
     tag = self.tag.name
     tag = utils.num2Tag(tag)
     self.ids.beginn.text = utils.stdBeg(tag, wtag2Stunden)
     self.famEvent(self.ids.beginn)
     self.ids.ende.text = utils.stdEnd(tag, wtag2Stunden)
     self.famEvent(self.ids.ende)
     pass
Beispiel #4
0
 def vorschlag1(self, t):
     t = int(t)
     tag = utils.num2Tag(t)
     wt = utils.num2WT(t)
     if self.app.dokorrektur or wt == "Sa" or wt == "So":
         return (tag, 1, "", "", "", "", "", 0)
     try:
         with conn:
             c = conn.cursor()
             for tv in range(t - 1, t - 5, -1):
                 wtv = utils.num2WT(tv)
                 if wtv == "Sa" or wtv == "So":
                     continue
                 tvtag = utils.num2Tag(tv)
                 c.execute(
                     "SELECT einsatzstelle, beginn, ende, fahrtzeit, mvv_euro, kh"
                     " from arbeitsblatt WHERE tag = ? and fnr = 1",
                     (tvtag, ))
                 r = c.fetchmany(2)
                 r = utils.elimEmpty(r, 0)
                 if len(r) == 0:
                     break
                 elif len(r) == 1:
                     if r[0][0].lower() not in utils.skipES:
                         vals = r[0]
                         if self.app.menu.ids.wochenstunden.text == "38,5":  # übertrieben?
                             if wt == "Fr":
                                 vals = (vals[0], "08:00", "15:00",
                                         *vals[3:])
                             elif wtv == "Fr":
                                 vals = (vals[0], "08:00", "16:30",
                                         *vals[3:])
                         self.parent.vorschlagsTag = tvtag
                         return (tag, 1, *vals)
                 else:
                     raise ValueError(
                         "mehr als ein Eintrag für Tag {}, Fnr 1".format(
                             tag))
     except Exception as e:
         utils.printEx("fam1:", e)
     tag = utils.num2Tag(t)
     return (tag, 1, "", "", "", "", "", 0)
Beispiel #5
0
    def clear(self):
        self.ids.einsatzstelle.text = ""
        self.ids.beginn.text = ""
        self.ids.ende.text = ""
        self.ids.fahrtzeit.text = ""
        self.ids.mvv_euro.text = ""
        self.ids.kh.active = 0

        tag = self.tag.name
        tag = utils.num2Tag(tag)
        try:
            with conn:
                c = conn.cursor()
                r1 = c.execute("DELETE FROM arbeitsblatt where tag=?", (tag, ))
        except Exception as e:
            utils.printEx("fam0:", e)
Beispiel #6
0
 def fillin(self, t, fnr, app):
     self.app = app
     tag = utils.num2Tag(t)
     if fnr == 1:
         self.parent.vorschlagsTag = None
     try:
         with conn:
             c = conn.cursor()
             c.execute(
                 "SELECT einsatzstelle, beginn, ende, fahrtzeit, mvv_euro, kh"
                 " from arbeitsblatt WHERE tag = ? and fnr = ?", (tag, fnr))
             r = c.fetchmany(2)
             r = utils.elimEmpty(r, 0)
             if len(r) == 0:
                 if int(t) < 2:
                     vals = self.vorschlag1(
                         t) if fnr == 1 else self.vorschlag23(t, fnr)
                     if vals[2] != "" or vals[3] != "" or vals[
                             4] != "" or vals[5] != "" or vals[6] != "":
                         c.execute(
                             "INSERT INTO arbeitsblatt VALUES(?,?,?,?,?,?,?,?)",
                             vals)
                 else:
                     vals = (tag, fnr, "", "", "", "", "", 0)
             elif len(r) == 1:
                 vals = (tag, fnr, *r[0])
             else:
                 raise ValueError(
                     "mehr als ein Eintrag für Tag {}, Fnr {}".format(
                         tag, fnr))
             self.ids.einsatzstelle.text = vals[2]
             self.ids.beginn.text = vals[3]
             self.ids.ende.text = vals[4]
             self.ids.fahrtzeit.text = vals[5]
             self.ids.mvv_euro.text = vals[6]
             self.ids.kh.active = vals[7]
     except Exception as e:
         utils.printEx("fam3:", e)
Beispiel #7
0
 def vorschlag23(self, t, fnr):
     tag = utils.num2Tag(t)
     tvtag = self.parent.vorschlagsTag
     if tvtag is None:
         return (tag, fnr, "", "", "", "", "", 0)
     try:
         with conn:
             c = conn.cursor()
             c.execute(
                 "SELECT einsatzstelle, beginn, ende, fahrtzeit, mvv_euro, kh"
                 " from arbeitsblatt WHERE tag = ? and fnr = ?",
                 (tvtag, fnr))
             r = c.fetchmany(2)
             r = utils.elimEmpty(r, 0)
             if len(r) == 1:
                 vals = r[0]
                 return (tag, fnr, *vals)
             elif len(r) > 1:
                 raise ValueError(
                     "mehr als ein Eintrag für Tag {}, Fnr {}".format(
                         tag, fnr))
     except Exception as e:
         utils.printEx("fam2:", e)
     return (tag, fnr, "", "", "", "", "", 0)
Beispiel #8
0
    def checkComplete(self):
        rows = []
        try:
            with conn:
                c = conn.cursor()
                c.execute(
                    "SELECT tag,fnr,einsatzstelle,beginn,ende,fahrtzeit,mvv_euro,kh "
                    "from arbeitsblatt WHERE tag like ?",
                    ("__." + self.month, ))
                while True:
                    r = c.fetchmany(100)
                    r = utils.elimEmpty(r, 2)
                    if len(r) == 0:
                        break
                    rows.extend(r)
        except Exception as e:
            utils.printEx("arbex0:", e)

        rows.sort(key=lambda xr: xr[0] + str(xr[
            1]))  # sort by tag and fnr, i.e. 01.01.20, 02.01.20,...,31.01.20
        lastFnr = 0
        lastTnr = 999
        nrows = []
        for row in rows:
            # print("row", row)
            if row[R_Einsatzstelle] == "" and row[R_Beginn] == "" and row[
                    R_Ende] == "":
                continue
            self.tag = row[R_Tag]
            tnr = utils.tag2Nummer(self.tag)
            wday = utils.day2WT(self.tag)
            if wday == "Sa" or wday == "So":
                continue
            dayMiss = fnrMiss = False
            if lastTnr != 999 and tnr > lastTnr + 1:
                if wday != "Mo":
                    self.tag = utils.num2Tag(lastTnr + 1)
                    wday = utils.day2WT(self.tag)
                    dayMiss = True
            fnr = row[R_Fnr]
            if lastTnr != tnr:
                if fnr != 1:
                    fnrMiss = True
            elif fnr != lastFnr + 1:
                fnrMiss = True
            lastTnr = tnr
            lastFnr = fnr
            if dayMiss or fnrMiss or (row[R_Einsatzstelle] == ""
                                      or row[R_Beginn] == ""
                                      or row[R_Ende] == ""):
                dia = MDDialog(size_hint=(.8, .4),
                               title="Daten unvollständig",
                               text="Bitte Daten von " + wday + ", " +
                               self.tag + " vervollständigen",
                               text_button_ok="OK",
                               events_callback=self.evcb)
                dia.open()
                return None
            text = self.checkRow(row)
            if text is not None:
                dia = MDDialog(size_hint=(.8, .4),
                               title="Daten falsch",
                               text=text + ", bitte Daten von " + wday + ", " +
                               self.tag + " ausbessern",
                               text_button_ok="OK",
                               events_callback=self.evcb)
                dia.open()
                return None
            nrows.append(row)
        # print("Vollständig!")
        return nrows