Example #1
0
def excul_subjectsPool(cmb, excul_id, edited_activity_id=0):
    # collect activity_ids for exculset_id
    sql = " SELECT es.id \
              FROM excul_groups eg \
              JOIN excul_subjects es ON es.id = eg.excul_subject_id \
             WHERE eg.id = %d " % (excul_id, )
    
    activityIDs = fetch.getList(sql)

    if edited_activity_id:
	l = []
	for x in activityIDs:
	    #rint x
	    if not x == edited_activity_id: l.append(x)
	activityIDs = l
	
    activityIDs = [str(x) for x in activityIDs]
    #rint 'activityIDs',activityIDs
	
    listStr = "'%s'" % ','.join(activityIDs)
    
    sql = " SELECT id, name \
              FROM excul_subjects \
             WHERE NOT FIND_IN_SET(id, %s) \
	     ORDER BY name" % listStr
    #rint sql, fetch.getAllCol(sql)
    fillCmb(cmb, fetch.getAllCol(sql), 'without activity')
    restore(cmb, int(edited_activity_id))
Example #2
0
def genNoBlank(cmb, sql, first_item='') :
    #rint 'loadCmb: genNoBlank:', sql, fetch.getAll_dict(sql)
    #sql should be designed to return first two items  'id' , 'title'
    dataSet = fetch.getAllCol(sql)
    origional_id = fetch.cmbID(cmb)
    
    cmb.Freeze()  # locks the combo so that other processes are not called
    
    cmb.Clear()
    if first_item:      cmb.Append(first_item, '0')
    for row in dataSet: cmb.Append(str(row[1]), row[0])
    restore(cmb, origional_id)
    
    cmb.Thaw()
Example #3
0
def inv_students(cmb, filter_panel):
    school_id, course_id, form_id = filter_panel.getSelectedIDs()
    #rint 'inv_students', cmb, school_id, course_title_id, batch_id
    
    if form_id:
	sql ="SELECT s.id, s.name \
		FROM students s \
		JOIN students_by_form sbf ON s.id = sbf.student_id \
		JOIN forms              f ON f.id = sbf.form_id \
	       WHERE s.is_active = 1 \
		 AND f.id = %d" % form_id
	
    elif course_id:
	sql ="SELECT s.id, s.name \
		FROM students s \
		JOIN students_by_form sbf ON s.id = sbf.student_id \
		JOIN forms              f ON f.id = sbf.batch_id \
	       WHERE s.is_active = 1 \
		 AND f.course_id = %d" % course_id
	
    sql += " AND register_schYr < %d" % gVar.schYr
    origional_id = fetch.cmbID(cmb)
    dataSet      = fetch.getAllCol(sql)
    cmb.Freeze()  # locks the combo so that other processes are not called
    
    cmb.Clear()
    first_item = ""
    if first_item:
	cmb.Append(first_item, -1)
	cmb.Append('', 0)
    for row in dataSet:
	if row[1]: fn = "%s " % row[1]
	else: fn=''
	if row[2]: mn = "%s " %  row[2]
	else: mn = ''
	if row[3]: ln = "%s " %  row[3]
	else: ln=''
	
	ful_name = "%s%s%s" % (fn,mn,ln)
	cmb.Append(ful_name, row[0])
    
    restored = restore(cmb, origional_id)
    cmb.Thaw()
    
    if restored:
	cmb.Thaw() 
	return origional_id
    else:
	cmb.SetSelection(1)
	cmb.Thaw()
Example #4
0
def updateAddressIDs():
    sql = "SELECT id, aiID, nextItemID FROM address_items"
    res = fetch.getAllCol(sql)
    i = 0
    for row  in res:
        iid, aiID, nextItemID = row
        
        sql = "SELECT id FROM address_items WHERE aiID = %d" % nextItemID
        ##rintsql
        next_item_id = fetch.getDig(sql)
        
        sql = "UPDATE address_items \
                  SET next_item_id = %d \
                WHERE id = %d" % (next_item_id, iid)
        ##rintsql
        fetch.updateDB(sql)
Example #5
0
def gen(cmb, sql , first_item='') : #sql should be designed to return two items 'id' and 'title'
    ##rint"loadCmb gen:", sql, len(fetch.getAllCol(sql))
    
    origional_id = fetch.cmbID(cmb)
    dataSet      = fetch.getAllCol(sql)
    ##rint'dataSet:' , dataSet
    
    
    cmb.Freeze()  # locks the combo so that other processes are not called
    cmb.Clear()
    if first_item:
	cmb.Append(first_item, 0)
    for row in dataSet:
	#rint 'cmb load ,  id=', row[0],'   str=', row[1]
	cmb.Append(str(row[1]), int(row[0]))
    restored = restore(cmb, origional_id)
    
    cmb.Thaw()    
    if restored: return origional_id
    else:        return 0
Example #6
0
def exculTeacherPool(cmb, schedule_id, edited_teacher_id=0):
    exculList  = fetch.exculGroupsDATA_forScheduleID(schedule_id)
    for x in exculList:
	print exculList[x]
    teacherIDs = [str(exculList[x][3]) for x in exculList]
    print 'teacherIDs',teacherIDs
    if edited_teacher_id:
	l = []
	for x in teacherIDs:
	    if not x == str(edited_teacher_id): l.append(x)
	teacherIDs = l

    listStr = "'%s'" % ','.join(teacherIDs)
    
    sql = " SELECT id, name \
              FROM staff \
             WHERE position_id = 33 \
               AND %d BETWEEN join_schYr AND exit_schYr \
               AND NOT FIND_IN_SET(id, %s) \
	     ORDER BY name" % (gVar.schYr, listStr)
    print sql
    fillCmb(cmb, fetch.getAllCol(sql),'without teacher')
    restore(cmb, int(edited_teacher_id))
Example #7
0
def genAdd(cmb, sql , first_item='') : #sql should be designed to return two items 'id' and 'title'
    origional_id = fetch.cmbID(cmb)
    dataSet      = fetch.getAllCol(sql)
    cmb.Freeze()  # locks the combo so that other processes are not called
    cmb.Clear()
    
    if first_item:
	cmb.Append(first_item, -1)
	cmb.Append('', 0)
    for row in dataSet:
	#rint 'x'
	cmb.Append(str(row[1]), row[0])
    
    restored = restore(cmb, origional_id)
    
    cmb.Thaw()
    
    if restored:
	cmb.Thaw()  
	return origional_id
    else:
	cmb.SetSelection(1)
	cmb.Thaw()
	return