def classMoveStudent(self, session, moveclass, students):
     session = session
     classtable = 'student_class'+str(session)
     arr = []
     g = Db()
     for student in students:
         f = g.select(classtable, '', 1, {'studentID':student})
         if f and int(f[0]) > 1:
             h = g.update(classtable, {'classID': moveclass}, {'id': f[0]})
             h = f[0]
             
         else:
             h = g.insert(classtable, {'studentID': student, 'classID': moveclass,'active': 0})   
             
         arr.append(h)
     return arr
    def button_click(self, a, b):
        # shost is a QString object

        b.close()
        s1 = self.le.text()
        s2 = self.le2.text()
        self.a = a
        g = Db()
        if (len(s1) > 0):
            y = {'name': s1.lower(), 'abbrv': s2.lower()}
            z = {'id': self.a}
            g.update('datas', y, z)

        self.form = AffectiveForm()
        self.form.show()
        self.close()
Exemple #3
0
    def getQuantity(self):
        if self.storeData.currentIndex() > -1:
            s = self.hold_store[self.storeData.currentIndex()]
            _session = self.session
            g = Db()
            db = 'school_stores' + str(_session)
            fi = g.selectStoreQuantity(db, s)
            remain = 0
            arr = {}
            for a in fi:
                arr[a['state']] = a['qty']

            if 1 in arr:
                re = arr[1]
            else:
                re = 0

            if 2 in arr:
                isu = arr[2]
            else:
                isu = 0

            if 3 in arr:
                dam = arr[3]
            else:
                dam = 0

            if 4 in arr:
                bor = arr[4]
            else:
                bor = 0

            if 5 in arr:
                ret = arr[5]
            else:
                ret = 0

            borrowed = float(bor) - float(ret)
            issued = float(isu) + float(borrowed) + float(dam)
            remain = float(re) - float(issued)
            self.quantityText.setText('QTY: ' + str(remain))
            if remain == 0 and (self.r2.isChecked() or self.r3.isChecked()
                                or self.r4.isChecked()):
                self.quantityData.setEnabled(False)
            else:
                self.quantityData.setEnabled(True)
            return remain
    def button_click(self):
        tex = ' Please wait processing, do not cancel or close..'
        self.feesPop.setText(tex)
        _term = self.term
        _class = self.cla
        _students = self.students
        _amount = self.feesAmount.text()
        _fee = self.hol[self.feesCombo.currentIndex()]
        feeStudent = 0
        feeStudentUp = 0
        ins = []
        ups = []
        for j in _class:
            st = self.getClassStudent([j])
            post = StudentTable(self.term, [None], [None], [None])
            _students = post.getIDs(st[1])
            data = {}
            data['pubID'] = 'fee'
            data['subID'] = _term
            data['abbrv'] = _fee
            data['name'] = j

            cn = Db()
            check = cn.selectn('datas', '', 1, data)
            if (check and check['id'] > 0):
                if float(check['description']) == float(_amount):
                    pass
                else:
                    #update
                    sid = cn.update('datas', {'description': _amount},
                                    {'id': check['id']})
                    re = self.feeStudentsUpdate(_term, _students, _fee,
                                                _amount, check['id'])
                    feeStudent = re[0]
                    feeStudentUp = re[1]
            else:
                data['description'] = _amount
                sid = cn.insert('datas', data)
                if int(sid) > 0:
                    feeStudent = self.feeStudents(_term, _students, _fee,
                                                  _amount, sid)

            ins.append(int(feeStudent))
            ups.append(int(feeStudentUp))
        tex = ' TOTAL of ' + str(sum(ins)) + ' inserted ' + str(
            sum(ups)) + ' updated.'
        self.feesPop.setText(tex)
Exemple #5
0
 def chkFunc(self, a, b):
     # shost is a QString object
     self.a = a
     self.b = b
     g = Db()
     g.update('datas', {'active':1}, {'active':0})
     
     if b.isChecked() == True:
         y = { 'active':0}
     else:
         y = { 'active':1}
      
     
     z = {'id': self.a}
     j = g.update('datas', y, z)
    
     return j 
Exemple #6
0
def getName(a, b=[]):
    store_sub_name = {}
    cn = Db()
    for subz in b:
        sub_name = None
        sub_name = cn.selectn('students', '', 1, {'id': subz})
        if sub_name:
            if (a == 0):
                nam = str(sub_name['surname'] + ' ' +
                          sub_name['firstname']).title()
                store_sub_name.update({subz: nam})
            elif (a == 1):
                nm = str(sub_name['surname'] + ' ' +
                         sub_name['firstname']).title()
                nam = [sub_name['schno'], nm]
                store_sub_name.update({subz: nam})
    return store_sub_name
Exemple #7
0
    def pullFees(self):
        term = self.term
        student = self.student
        fee_id_array = []
        cn = Db()
        db_fee = 'student_fee' + str(term)
        db_pay = 'student_pay' + str(term)

        fee = cn.selectn(db_fee, '', '', {'studentID': student})
        pay = cn.selectn(db_pay, '', '', {'studentID': student})
        #get all fees
        arr = {}
        arr1 = {}
        for r in fee:
            fee_id_array.append(int(r['feeID']))
            arr[int(r['feeID'])] = {}

        for r in pay:
            fee_id_array.append(int(r['feeID']))
            arr1[int(r['feeID'])] = {}

        for r in fee:
            get_mon = cn.selectn(
                'datas', '', 1, {
                    'pubID': 'fee',
                    'subID': self.term,
                    'name': self.clasz,
                    'abbrv': r['feeID']
                })
            if arr[int(r['feeID'])] and isinstance(arr[int(r['feeID'])], dict):
                arr[int(r['feeID'])][int(r['id'])] = get_mon['description']
            else:
                arr[int(r['feeID'])] = {}
                arr[int(r['feeID'])][int(r['id'])] = get_mon['description']

        for r in pay:
            if arr1[int(r['feeID'])] and isinstance(arr1[int(r['feeID'])],
                                                    dict):
                arr1[int(r['feeID'])][int(r['id'])] = r['amount']
            else:
                arr1[int(r['feeID'])] = {}
                arr1[int(r['feeID'])][int(r['id'])] = r['amount']

        fee_ids = list(set(fee_id_array))
        fin = [fee_ids, arr, arr1]
        return fin
    def button_edit(self):
        ailment = self.ailmentData.toPlainText()
        treatment = self.treatmentData.toPlainText()
        _date = self.dateData.date().toPyDate()
        _date = time.mktime(_date.timetuple())

        db = 'school_medicals' + str(self.mainses)

        if len(ailment) > 0 and len(treatment) > 0:
            arr = {}
            arr['ailment'] = ailment
            arr['treatment'] = treatment
            arr['datepaid'] = _date
            g = Db()
            g.update(db, arr, {'id': self.mainrow})

        ## set subject
        self.getValue()
Exemple #9
0
    def button_click(self, a, c, b):
        # shost is a QString object
        b.close()
        s1 = self.le.text()
        s2 = self.le2.text()
        fil = str(s3) + ":" + str(s4) + ":" + str(s5)
        self.a = a
        self.c = c
        g = Db()
        if (len(s1) > 0 and len(s2) > 0):

            y = {'name': s1, 'abbrv': s2, 'active': 0}
            z = {'id': self.a}
            g.update('datas', y, z)

        self.form = ExpenseTypeForm(self.c)
        self.form.show()
        self.close()
    def button_click(self):
        ailment = self.ailmentData.toPlainText()
        treatment = self.treatmentData.toPlainText()
        _date = self.dateData.date().toPyDate()
        _date = time.mktime(_date.timetuple())

        db = 'school_medicals' + str(self.sessionID)

        if len(ailment) > 0 and len(treatment) > 0:
            arr = {}
            arr['studentID'] = self.student
            arr['ailment'] = ailment
            arr['treatment'] = treatment
            arr['datepaid'] = _date
            g = Db()
            g.insert(db, arr)

        ## set subject
        self.getValue()
    def button_edit(self):
        action = self.actionData.toPlainText()
        reaction = self.reactionData.toPlainText()
        staff = self.staffData.text()
        _date = self.dateData.date().toPyDate()
        _date = time.mktime(_date.timetuple())

        db = 'school_conducts' + str(self.sessionID)

        if len(action) > 0 and len(reaction) > 0:
            arr = {}
            arr['action'] = action
            arr['reaction'] = reaction
            arr['datepaid'] = _date
            arr['staffname'] = staff
            g = Db()
            g.update(db, arr, {'id': self.edit})

        ## set subject
        self.getValue()
Exemple #12
0
 def button_click(self, a, b):
     # shost is a QString object
     b.close()
     s1 = self.le.text()
     s2 = self.le2.date().toPyDate()
     s3 = self.le3.date().toPyDate()
     self.a = a
     g = Db()
     if(len(s1) > 0):
         y = { 'name':s1, 'start_date':s2, 'end_date':s3}
         z = {'id':self.a}
         g.update('terms', y, z)
         if self.a and self.a > 0:
                 g.createClass(self.a)
                 g.createFee(self.a)
                 g.createResult(self.a) 
     
     self.form = TermForm(self.a)
     self.form.show()
     self.close()
Exemple #13
0
    def button_save(self):
        row = self.editrow

        s1 = self.le1.text()
        s2 = self.le2.text()
        g = Db()
        try:
            if (len(s1) > 0) and (len(s2) > 0) and row and row > 0:
                y = {'name': s1.lower(), 'abbrv': s2.lower(), 'active': 0}
                z = {'id': row}
                g.update('datas', y, z)
                self.makeTree()
                self.button_reset()
                if self.titleID == 1:
                    #if class was changed only relod class menu on main window
                    self.par.menuStudent()
                    self.par.dropdownStudent()
            else:
                pass
        except:
            pass
Exemple #14
0
    def button_click(self, a, c, b):
        # shost is a QString object
        b.close()
        s1 = self.le.text()
        s2 = self.le2.text()
        s3 = self.le3.text()
        s4 = self.le4.text()
        s5 = self.le5.text()
        fil = str(s3) + ":" + str(s4) + ":" + str(s5)
        self.a = a
        self.c = c
        g = Db()
        if (len(s1) > 0 and len(s2) > 0 and len(s3) > 0 and len(s4) > 0):

            y = {'name': s1, 'abbrv': s2, 'description': fil, 'active': 0}
            z = {'id': self.a}
            g.update('datas', y, z)

        self.form = GradingForm(self.c)
        self.form.show()
        self.close()
Exemple #15
0
    def feeStudents(self, session, students, fee, amount):
        db = 'student_fee' + str(session)
        cn = Db()
        fd = []
        ed = []

        for s in students:
            data = {}
            data['studentID'] = s[0]
            data['feeID'] = fee

            chk = cn.selectn(db, '', 1, data)
            if (chk and int(chk['id']) > 0):
                #confirm if money available
                pass
            else:
                #if money not set , set
                e = cn.insert(db, data)
                ed.append(e)

        return len(ed)
Exemple #16
0
 def setActive(self):
     g = Db()
     for i in self.hold_data:
         if self.hold_data[i].checkState(0) == Qt.Checked:
             g.update('datas', {'active': 0}, {'id': i})
         else:
             g.update('datas', {'active': 1}, {'id': i})
Exemple #17
0
 def button_click(self):
     fname = self.mainLink
     im1 = fname
     file1 = 'pic_thumb/'
     file2 = 'pic_main/'
     lnk = "logo.png"
   
     im1.thumbnail((128, 128))
     im1.save(file1 + lnk, "PNG" )
     
     im1.thumbnail((300, 300))
     im1.save(file2 + lnk, "PNG")
 
     g = Db()
     sel = g.selectn('datas', '', 1, {'pubID':'datas', 'name':'logo'})
     if sel and sel['id'] > 0:
         pass
     else:
         g.insert('datas', {'pubID':'datas', 'name':'logo', 'description': lnk})
         
     self.setCurrentPix()  
     self.button_close(self)
Exemple #18
0
    def editRow(self, a):
        _session = self.session
        g = Db()
        db = 'school_stores' + str(_session)
        data = g.selectn(db, '', 1, {'id': a})
        if len(data) > 0:
            try:
                amt = float(data['amount'])
                qty = float(data['quantity'])
                if amt > 0 and qty > 0:
                    cost = amt * qty
                else:
                    cost = 0
            except:
                cost = 0
                amt = 0
                qty = 0

            if data['state'] == 1:
                self.r1.setChecked(True)
            elif data['state'] == 2:
                self.r2.setChecked(True)
            elif data['state'] == 3:
                self.r3.setChecked(True)
            elif data['state'] == 4:
                self.r4.setChecked(True)
            elif data['state'] == 5:
                self.r5.setChecked(True)

            self.amountData.setText(str(cost))
            self.descriptionData.clear()
            self.descriptionData.insertPlainText(str(data['description']))
            self.tellerData.setText(str(data['teller']))
            self.periodData.setText(str(data['period']))
            self.personData.setText(str(data['person']))
            self.quantityData.setText(str(qty))
            stID = self.hold_store.keys()[self.hold_store.values().index(
                data['itemID'])]
            self.storeData.setCurrentIndex(stID)
    def button_click(self):
        action = self.actionData.toPlainText()
        reaction = self.reactionData.toPlainText()
        staff = self.staffData.text()
        _date = self.dateData.date().toPyDate()
        _date = time.mktime(_date.timetuple())

        db = 'school_conducts' + str(self.sessionID)

        if len(action) > 0 and len(reaction) > 0:
            arr = {}
            arr['studentID'] = self.student
            arr['action'] = action
            arr['reaction'] = reaction
            arr['datepaid'] = _date
            arr['staffname'] = staff
            arr['state'] = 1
            g = Db()
            g.insert(db, arr)

        ## set subject
        self.getValue()
Exemple #20
0
    def __init__(self, parent=None):
        super(OfflineDialog, self).__init__(parent)
        
        self.pagetitle = 'Offline Back Up' 
        stylesheet = Valid().background() + Valid().font()

        
        self.hold_data = {}
        self.tree = QTreeWidget()
        self.tree.setHeaderLabel("Choose Sessions to Back-up")
        self.tree.headerItem().setText(0, 'Name')
        #self.tree.setStyleSheet(treeStyleSheet)
        arr = Db().selectn('session','', 5)
        if arr and len(arr) > 0:
               for val in arr:
                 child = QTreeWidgetItem(self.tree)
                 child.setFlags(child.flags() | Qt.ItemIsUserCheckable)
                 child.setText(0, str(val['name']).upper())
                 self.hold_data[val['id']] = child
                 child.setCheckState(0, Qt.Checked)
                
        
        
        self.pb = QPushButton()
        self.pb.setObjectName("Add")
        self.pb.setText("Save")
        
        self.pb1 = QPushButton()
        self.pb1.setObjectName("Cancel")
        self.pb1.setText("Close")
        
        hbo = QHBoxLayout()
        hbo.addWidget(self.pb1)
        hbo.addStretch()
        hbo.addWidget(self.pb)
        
        groupBox2 = QGroupBox('')
        groupBox2.setLayout(hbo)
            
        grid = QGridLayout()
        grid.addWidget(self.tree, 0, 0)
        grid.addWidget(groupBox2, 1, 0)
        
        self.setLayout(grid)
        self.connect(self.pb, SIGNAL("clicked()"), lambda: self.button_click())
        self.connect(self.pb1, SIGNAL("clicked()"), lambda: self.button_close(self))
        
        self.setStyleSheet(stylesheet)
        #self.setWindowIcon(QIcon(self.titleIcon))
        self.setWindowTitle(self.pagetitle)
Exemple #21
0
    def button_edit(self):
        row = self.getSelected()
        self.sessionMain = 0
        if row:
            self.groupBox2.setTitle('Edit')
            self.editrow = row
            g = Db()
            data = g.selectn('datas', '', 1, {'id': row})
            if self.titleID == data['pubID']:
                self.sessionMain = 1
            else:
                self.sessionMain = 0

            try:
                self.le1.setText(data['name'])
            except:
                self.le1.setText('')
            try:
                self.le2.setText(data['abbrv'])
            except:
                self.le2.setText('')
            self.pb.hide()
            self.pb4.show()
Exemple #22
0
    def button_click(self, a, b):
        # shost is a QString object
        b.close()
        self.a = a
        s1 = self.le.text()
        s2 = self.le2.text()
        s3 = self.le3.text()
        s4 = self.le4.text()
        s5 = self.le5.text()
        fil = str(s3) + ":" + str(s4) + ":" + str(s5)

        g = Db()
        try:
            if (len(s1) > 0 and len(s2) > 0 and len(s3) > 0 and len(s4) > 0):
                y = {
                    'name': s1,
                    'abbrv': s2,
                    'pubID': 12,
                    'subID': self.a,
                    'description': fil,
                    'active': 0
                }
                w = g.insert('datas', y)
                print(w)
            else:
                pass
        except:
            pass

        try:
            self.lunchForm(self.a)
        except:
            pass
        try:
            self.close()
        except:
            pass
Exemple #23
0
 def button_click(self, a):
     # shost is a QString object
     a.close()
     s1 = self.le.text()
     s2 = self.le2.text()
     g = Db()
     try:
         if(len(s1) > 0) and (len(s2) > 0):
             y = { 'name':s1.lower(), 'abbrv':s2.lower(), 'pubID':5, 'active':0}
             k = g.insert('datas', y)
             print(k)
         else:
             pass
     except:
         pass
     
     try:
         self.lunchForm()
     except:
         pass
     try:
         self.close()
     except:
         pass
Exemple #24
0
    def getSelection(self):

        self.le1.clear()
        self.le2.clear()

        if self.hold_data_add['addnew'].isSelected():
            self.sessionMain = 0
            self.groupBox2.setTitle('Add New')
            self.groupBox2.show()
        else:
            r = None
            for i in self.hold_data_add_item:
                if self.hold_data_add_item[i].isSelected():
                    r = i
            if r:
                self.sessionMain = r
                g = Db()
                v = g.selectn('datas', '', 1, {'id': r})
                vname = str(v['name']).upper()
                self.groupBox2.setTitle('ADD ' + str(vname) + ' ITEM')
                self.groupBox2.show()
            else:
                self.groupBox2.setTitle('Add')
                self.groupBox2.hide()
Exemple #25
0
    def button1_click(self, a):
        # shost is a QString object
        arr = {}
        arr['schno'] = self.schnoData.text()
        arr['surname'] = self.surnameData.text()
        arr['firstname'] = self.firstnameData.text()
        arr['othername'] = self.middlenameData.text()
        arr['soo'] = self.sooData.text()
        arr['lga'] = self.lgaData.text()
        arr['addr'] = self.addrData.toPlainText()
        dob = self.dobData.date()
        arr['dob'] = dob.toPyDate()
        admit = self.admitData.date()
        arr['admit'] = admit.toPyDate()
        arr['active'] = 0

        arr['g1'] = self.g1Data.text()
        arr['g1rel'] = self.g1relData.itemData(self.g1relData.currentIndex())
        arr['g1p1'] = self.g1p1Data.text()
        arr['g1p2'] = self.g1p2Data.text()
        arr['g1email'] = self.g1emailData.text()
        arr['g1addr'] = self.g1addData.text()
        arr['g2'] = self.g2Data.text()
        arr['g2rel'] = self.g2relData.itemData(self.g2relData.currentIndex())
        arr['g2p1'] = self.g2p1Data.text()
        arr['g2p2'] = self.g2p2Data.text()
        arr['g2email'] = self.g2emailData.text()
        arr['g2addr'] = self.g2addData.text()

        self.a = a
        print(arr)
        g = Db()
        if ((arr['surname']) and (arr['firstname']) and (arr['schno'])):
            r = g.update('students', arr, {'id': self.a})
        print(r)
        self.close()
Exemple #26
0
    def getChecked(self, a):
        g = Db()
        for i in self.hold_data:
            if self.hold_data[i].checkState(0) == Qt.Checked:
                g.update('datas', {'active': 0}, {'id': i})
            else:
                g.update('datas', {'active': 1}, {'id': i})

        if self.titleID == 1:
            #if class was changed only reload class menu on main window
            self.par.menuStudent()
            self.par.dropdownStudent()
Exemple #27
0
 def button_click(self):
     arr = {}
     arr['namex'] = self.schoolNameData.text()
     arr['alias'] = self.schoolAliasData.text()
     arr['motto'] = self.schoolMottoData.text()
     arr['address'] = self.schoolAddressData.text()
     arr['city'] = self.schoolCityData.text()
     arr['country'] = self.schoolCountryData.text()
     arr['state'] = self.schoolStateData.text()
     arr['email1'] = self.schoolEmail1Data.text()
     arr['email2'] = self.schoolEmail2Data.text()
     arr['phone1'] = self.schoolPhone1Data.text()
     arr['phone2'] = self.schoolPhone2Data.text()
     arr['zip'] = self.schoolZipData.text()
     arr['pmb'] = self.schoolPmbData.text()
     arr['color1'] = self.colorPrimaryLbl.text()
     arr['color2'] = self.colorSecondaryLbl.text()
     
     #print(arr)
     db = 'datas'
     g = Db()
     
     for a in arr:
         s = g.selectn(db , '', 1, {'pubID':'datas', 'name':a})
         if s and s['id'] > 0:
             if arr[a] and len(arr[a]) > 0:
                 g.update(db, {'description': arr[a]}, {'id':s['id']})
             else:
                 g.delete(db, {'id':s['id']})
         else:
             if arr[a] and len(arr[a]) > 0:
                 print(arr[a])
                 g.insert(db, {'pubID': 'datas', 'name':a, 'description': arr[a]})
     
 
     self.button_close(self)
Exemple #28
0
    def pullStudentsID(self, a, b = [], c = None):

        self.a = a
        self.b = b
        termtable = 'student_class'+str(self.a)
        cn = Db()
        try:
            if c == 0:
                students = cn.selectStudentClass(termtable, self.b)
            elif c == 1:
                students = cn.selectStudentClass(termtable, self.b, c)
            elif c == 2:
                students = cn.selectStudentClass(termtable, self.b, c)
            else:
                students = cn.selectStudentClass(termtable, self.b)
        except:
            students = cn.selectStudentClass(termtable, self.b)
        return students
 def pullOne(self, b):
     cn = Db()
     arr = cn.selectn('datas', '', 1, {'id': b})
     return arr
 def pullSubjects(self):
     cn = Db()
     arr = cn.selectn('datas', '', '', {'pubID': 7})
     return arr