def getErjaList(param2): rows = py_db.executeAndReturnRows( ''' SELECT t1.i_date_of_create, t1.i_date_of_seen, (SELECT t2.u_complete_name FROM tbl_users t2 WHERE t2.u_id=t1.i_active_user_link LIMIT 1) AS current, (SELECT t2.u_complete_name FROM tbl_users t2 WHERE t2.u_id=t1.`i_prev_active_user_link` LIMIT 1) AS lastuser, t1.i_order, CASE TRUE WHEN t1.`i_erja_type` = 1 THEN "معمولی" WHEN t1.i_erja_type = 2 THEN "فوری" WHEN t1.i_erja_type = 3 THEN "خیلی فوری" END AS hello , CASE TRUE WHEN t1.i_position = 1 THEN "خوانده نشده" WHEN t1.i_position = 2 THEN "خوانده شده" WHEN t1.i_position = 3 THEN "ارجاع شده" WHEN t1.i_position = 4 THEN "بایگانی شده" END AS hello FROM tbl_inbox t1 WHERE t1.i_letter_link = {0} AND t1.i_erja_type=1 ORDER BY t1.i_id asc '''.format(param2) ); i=0 str = "<div>" for row in rows: s="" if i==0: s="<div>"+"ثبت در سیستم مورخه "+":"+py_db.mil_to_sh_with_time(row[0].strftime("%Y-%m-%d %H:%M:%S"))+"<br>"+" توسط "+ row[2]+":"+ "</div>"+"<hr>" s=s else: s="<div> با هامش "+":"+row[4]+"<br>"+" ارسال شده به "+":"+row[2]+"<br>"+" در تاریخ "+":"+ py_db.mil_to_sh_with_time(row[0].strftime("%Y-%m-%d %H:%M:%S"))+"<br>"+" وضعیت "+":"+row[6]+"</div>ارجاع کننده : "+row[3]+"<hr>" s=s #dd = str=str+s i=i+1 str=str+"</div>" print 'Content-Type: text/html; charset=utf-8' print '' print str
and ( {1} order by i_id desc LIMIT 51) r GROUP BY r.i_letter_link ORDER BY i_position ASC,i_id DESC limit 50 """.format(py_db.user_id,sds) partstr="" partstr="""(i_active_user_link='{0}') and""".format(py_db.user_id) if baygani==1: sqlstr=sqlstr.replace(partstr,"(i_prev_active_user_link='{0}') and".format(py_db.user_id)) #print sqlstr db = py_db.GetDB(); cur=db.cursor() cur.execute(sqlstr) rows=cur.fetchall() str="" for row in rows: str=str+"|" daa="" if row[6].__str__()=="":daa="مشاهده نشده" else: daa=py_db.mil_to_sh_with_time(row[6].__str__()) str=str+row[11].__str__()+"$"+row[1].__str__()+"$"+row[2].__str__()+"$"+py_db.mil_to_sh_with_time(row[3].__str__())+"$"+py_db.mil_to_sh_with_time(row[5].__str__())+"$"+daa+"$"+row[7].__str__()+"$"+row[8].__str__()+"$"+row[9].__str__()+"$"+row[11].__str__()+"$"+row[10].__str__()+"$"+row[12].__str__() db.close() str=str.replace("00:00:00",""); print str
def get_pos(sel2): dtt = form.getvalue("dt2","-1"); ttl = form.getvalue("totalrows","-1") dttt = [] dttt = dtt.split("mm") dtt = "between '"+py_db.sh_to_mil(dttt[0])+" "+dttt[1]+":00' and '"+py_db.sh_to_mil(dttt[2])+" "+dttt[3]+":00' " sqlst ="""SELECT w.* FROM (SELECT @row := @row + 1 AS _ROW, t.* FROM `tbl_gps_positions` t,(SELECT @row:=0) r WHERE g_sat_count > 5 and g_user_id IN ({0}) AND g_date {1} ORDER BY g_date DESC ) w WHERE MOD(_ROW,{2})=0 """.format(sel2,dtt,ttl) rows = py_db.executeAndReturnRows(sqlst) str = "" i=0 for row in rows : if i==0: str = "{0}!{1}!{2}!{3}!{4}".format(row[2].__str__(),row[3].__str__(),row[4].__str__(), py_db.mil_to_sh_with_time(row[6].__str__()),row[7].__str__()) else: str = str+"cz{0}!{1}!{2}!{3}!{4}".format(row[2].__str__(),row[3].__str__(),row[4].__str__(),py_db.mil_to_sh_with_time(row[6].__str__()),row[7].__str__()) i+=1 print 'Content-Type: text/html; charset=utf-8' print "" print str