def create_right_menu():
    weight0=""
    weight1=""
    weight2=""
    weight3=""
    weight=""
    rows=[]
    _rows=[]
    __rows=[]
    ___rows=[]
    rows = py_db.executeAndReturnRows("select * from tbl_template_right_menu where trm_weight=0 and trm_parent_id=0")
    for row in rows:
        weight0=weight0+"<ul>"+row[1]
        _rows = py_db.executeAndReturnRows("select * from tbl_template_right_menu where trm_weight=1 and trm_parent_id={0}".format(row[0]))
        weight1=""
        if len(_rows) > 1 : weight1="<ul>"
        for _row in _rows:
            weight1=weight1+"<li><a href='{0}'>".format(_row[5].__str__())+_row[1]+"</a>"
            __rows = py_db.executeAndReturnRows("select * from tbl_template_right_menu where trm_weight=2 and trm_parent_id={0}".format(_row[0]))
            weight2=""
            if len(__rows) > 1 : weight2="<ul>"
            for __row in __rows:
                weight2=weight2+"<li><a href='{0}'>".format(__row[5].__str__())+__row[1]+"</a>"
                ___rows = py_db.executeAndReturnRows("select * from tbl_template_right_menu where trm_weight=3 and trm_parent_id={0}".format(__row[0]))
                weight3=""
                if len(___rows) > 1 : weight3="<ul>"
                for ___row in ___rows:
                    weight3=weight3+"<li><a href='{0}'>".format(___row[5].__str__())+___row[1]+"</a></li>"
                if len(___rows)  >1: weight2=weight2+weight3+"</ul></li>"
                else : weight2=weight2+weight3+"</li>"
            if len(__rows) > 1 : weight1=weight1+weight2+"</ul></li>"
            else : weight1=weight1+weight2+"</li>"
        if len(_rows) > 1 : weight0=weight0+weight1+"</li></ul>"
        else : weight0=weight0+weight1+"</ul>"
    return weight0      
def create_prn_ahdaf_tree():
    ul = ""
    rows = py_db.executeAndReturnRows("select * from tbl_irib_olaviats order by io_id")
    #<ul class='ul_ahdaf_14' id='ul_14'>
    ul = "<ul class='tree'>"
    i1 = 0
    i2 = 0
    i3 = 0
    for row in rows:
	i1=i1+1
	i2 = 0
	i3 = 0 
	ul = ul+"<li id='olaviat_{1}'><a href='#'> {2} -  {0}</a>".format(row[1],row[0],i1)
	rows_rahbord =  py_db.executeAndReturnRows("select * from tbl_irib_olaviats_mozoo where iom_link = '{0}' order by iom_id".format(row[0]))
	if len(rows_rahbord)>0: ul = ul+"<ul>"
	i2 = 0
	i3 = 0
	for row_r in rows_rahbord:
	    i2=i2+1
	    ul = ul+"<li id='rahbord_{1}'><a href='#'> {2} -  {3} -  {0} </a>".format(row_r[1],row[0],i1,i2)
	    rows_mehvar =  py_db.executeAndReturnRows("select * from tbl_irib_olaviats_mozoo_mehvarz where iomm_link = '{0}' order by iomm_id".format(row_r[0]))
	    if len(rows_mehvar)>0: ul = ul+"<ul>"
	    i3=0
	    for row_m in rows_mehvar:
		i3=i3+1
		ul = ul+"<li id='mehvar_{1}'> <a href='#'>  {2} -  {3} - {4} - {0}</a></li>".format(row_m[1],row[0],i1,i2,i3)
	    if len(rows_mehvar)>0: ul = ul+"</ul></li>"
	if len(rows_rahbord)>0: ul = ul+"</ul></li>"
	else :  ul = ul+"</ul></li>"
    ul = '<div class="span9 well mhrz cccf" id="div_mohvarz_tree">'+ul + "</ul></div>"
    print ul
def create_prn_chnl_tree():
    ul = ""
    rows = py_db.executeAndReturnRows("select * from tbl_irib_channels order by ic_id")
    
    for row in rows:
	ul = ul + "<li id='chanel_{1}' ><a href='#'> {0}</a>".format(row[1],row[0])
	_rows = py_db.executeAndReturnRows("select * from tbl_irib_channels_group where icg_link_to_channels = {0}".format(row[0]))
	if len(_rows)> 0 : ul = ul+"<ul>"
	for _row in _rows:
	    ul = ul+"<li id='chgroups_{1}' ><a href='#'> {0}</a></li>".format(_row[2],_row[0])
	if len(_rows)> 0 : ul = ul+"</ul></li>"
    ul = '<div class="span3 well chnls cccf" id="div_channels_tree"><ul>{0}</ul></div>'.format(ul)
    print ul
def create_edit_content(get_edit_content):
    rows = py_db.executeAndReturnRows("select * from tbl_irib_mehvarha where cim_id = {0}".format(get_edit_content))
    rows_channels = py_db.executeAndReturnRows("select * from tbl_irib_channels order by ic_id ")
    rows_mehvarz = py_db.executeAndReturnRows("select * from tbl_irib_ahdaf order by c_id")
    #creating mehvarz dropdown
    select = "<select id='sel_ahdaf'>"
    cim_codes = rows[0][2]
    i=1
    for r in rows_mehvarz:
	if r[0]==cim_codes:
	    select = select + "<option value={0} selected>{2} - {1}</option>".format(r[0],r[1],i)
	else:
	    select = select + "<option value={0}>{2} - {1}</option>".format(r[0],r[1],i)
	    
	i+=1
    select = select+"</select>"
    
    def create_select(value,_id):
	_select = """
	<select id='sel_olv_{0}'>
	<option value=2>الویت اول</option>
	<option value=1>الویت دوم</option>
	<option value=0>بدوم الویت</option>
	</select>
	""".format(_id)
	_select = _select.replace("value="+value,"value="+value+" selected")
	return _select
    # begining check position with channels
    items= []
    for rp in rows_channels:
        rows_position_fari = """
        select count(*) from tbl_irib_mehvarha_content where imc_channels_link = {0} and imc_mehvar_link={1} and imc_type={2}
        """.format(rp[0],rows[0][0],1)
        rows_position_asli = """
        select count(*) from tbl_irib_mehvarha_content where imc_channels_link = {0} and imc_mehvar_link={1} and imc_type={2}
        """.format(rp[0],rows[0][0],2)
        result_fari = py_db.executeAndReturnRows(rows_position_fari)[0][0].__str__()
        result_asli = py_db.executeAndReturnRows(rows_position_asli)[0][0].__str__()
	
	main_result = "0"
	if result_fari == "1" and result_asli=="0" : main_result = "1"
	if result_fari == "0" and result_asli=="1" : main_result = "2"

        items.append([rp[0],rp[1],rows[0][1],main_result])
    div = "<div><textarea id='txt_mehvar'>{0}</textarea><input type='hidden' id='mehvar_code' value='{2}'><br>{1}<table><tbody>".format(rows[0][1],select,get_edit_content)
    for it in items:
        div = div+"<tr><td>{0}</td><td>{1}</td></tr>".format(it[1],create_select(it[3],it[0]))
    div = div+"</tbody></table></div><a href='#' onclick='post_edited_data()'>ثبت اطلاعات</a>-----<a href='#' onclick=''>لغو</a>"
    print div
def create_main_table_master_editing():
    rows_channels = py_db.executeAndReturnRows("select * from tbl_irib_channels order by ic_id")
    channel_rows_count = len(rows_channels)
    channel_rows_count = channel_rows_count + 3
    top_colspan = ['ردیف','کد هدف','عنوان محور','شبکه ها']
    channels_col = []
    for row in rows_channels:
        channels_col.append([row[0],row[1]])
    #creating title columns
    header_cols = "<td rowspan=2>ردیف</td>"
    header_cols = header_cols+"<td rowspan=2>کد هدف</td>"
    header_cols = header_cols+"<td rowspan=2>عنوان محور</td>"
    header_cols = header_cols+"<td colspan = {0}>شبکه ها</td>".format(channel_rows_count - 3)
    header_cols = "<table id='tbl_main_grid'><tbody><tr class = 'col_header'>{0}</tr><tr class = 'col_header1'>".format(header_cols)
    #creating channels list title columns
    for i in channels_col:
        header_cols = header_cols+"<td>{0}</td>".format(i[1])
    header_cols = header_cols+"</tr>"
    rows_mehvarha = py_db.executeAndReturnRows("select * from tbl_irib_mehvarha order by cim_id")
    sqlstr = ""
    for row in rows_channels:
        sqlstr = sqlstr+"""
        , CONCAT(
        CAST( (SELECT COUNT(*) FROM tbl_irib_mehvarha_content AS x2 WHERE x2.`imc_mehvar_link` = x1.cim_id AND 
        x2.`imc_channels_link`= {0} AND x2.imc_type=1) AS CHAR(2) )
        ,
	CAST( (SELECT COUNT(*) FROM tbl_irib_mehvarha_content AS x2 WHERE x2.`imc_mehvar_link` = x1.cim_id AND 
        x2.`imc_channels_link`= {0} AND x2.imc_type=2) AS CHAR(2) )) AS ch{0}
        """.format(row[0])
    sql = " SELECT x1.* {0} FROM  tbl_irib_mehvarha  AS x1 order by cim_id".format(sqlstr)
    rows = py_db.executeAndReturnRows(sql)
    ii = 0
    ct = ""
    for row in rows:
        ct = ct+"<tr>"
        ii = 0;
        for r in row:
            if ii==1:
                ct = ct+"<td class='tdXs'>{0}-- <a href='#' onclick='get_edit_content({1})'> ویرایش </a> -- <a href='#' onclick=''> نظر </a></td>".format(r,row[0])
            else:
                p=r;
                if r=="00":p="--"
                if r=="01":p="اول"
                if r=="10":p="دوم"
                ct = ct+"<td>{0}</td>".format(p)
            ii = ii+1
        ct = ct+"</tr>"
    header_cols = header_cols+ct+"</tbody></table>"
    print header_cols
def send_channel_groups_with_mehvarz(channelID,mehvar):
    rows = py_db.executeAndReturnRows("select * from tbl_irib_channels_group where icg_link_to_channels={0} order by icg_id desc".format(channelID))
    str = ''
    for row in rows:
	_rows = py_db.executeAndReturnRows("select * from tbl_irib_ch_gr_meh where icgm_channel_link={0} and icgm_mehvar_link={1}  and icgm_out='0'".format(row[0],mehvar))
	if len(_rows)==0:
	    str = str+"_{0}po{1}po{2}po{3}po{4}po{5}".format(row[0],row[2],'no','','','')
	else:
	    #Code Group Shabake, Name Group Shabake , Code Mehvar Name Mehvar , Matne Mehvare Special , Percent
	    str = str+"_{0}po{1}po{2}po{3}po{4}po{5}".format(row[0],
							    row[2],
							    _rows[0][2],
							    py_db.executeAndReturnRows("select iomm_name from tbl_irib_olaviats_mozoo_mehvarz where iomm_id={0}".format(_rows[0][2]))[0][0] ,
							    _rows[0][3],
							    _rows[0][4].__str__())
    print str
def get_items_field_name(objects_array):
    items = []
    for obj in objects_array:
        # getting items properties
        field_name = py_db.executeAndReturnRows("select fi_field_name,fi_object_type from tbl_form_items where fi_id={0} ".format(obj[0]))
        items.append([field_name[0][0],obj[1],field_name[0][1]])
    return items    #it returns 0=field_name  , 2=object_name , 1=field_type
def create_main_ul_master():
    rows_mehvarha = py_db.executeAndReturnRows("select cim_id from tbl_irib_mehvarha order by cim_id")
    
    content = ""
    for row in rows_mehvarha:
	content=content+create_content_div(row[0])
    print "<ul><li>"+content+"</li></ul>"
    def get_child(parent_id,level=1):
	rows = py_db.executeAndReturnRows("select * from tbl_irib_book where ib_parent = {0}".format(parent_id))
	if len(rows)>0:
	    print "<ul>"
	    for row in rows:
		print "<li id='li_{1}'>{0}</li>".format(row[1],row[0])
		get_child(row[0],level+1)
	    print "</ul>" 
Exemple #10
0
def add_old_mehvarz_to_new(_added_mehvar_id,_selected_code_id):
    py_db.executesql("""
insert into tbl_irib_olaviats_mozoo_mehvarz
(`iomm_name`,`iomm_link`) values
('{0}','{1}')""".format(
    py_db.executeAndReturnRows("select _text from mehvarz where id="+_selected_code_id)[0][0],
    _added_mehvar_id
    ))
    print "ok"
def get_items_value_from_tbl(key_id,key_field_name,tbl_name,objects_array):
    items = []
    objs = get_items_field_name(objects_array);
    for obj in objs:
        #getting stored value 
        sql = "select {0} from {1} where {2} = {3}".format(obj[0],tbl_name,key_field_name,key_id)
        objsValue = py_db.executeAndReturnRows(sql)[0][0]
        items.append([objsValue,obj[0],obj[1],obj[2]])
    return items
Exemple #12
0
def print_company_details(company_id):
    rows = py_db.executeAndReturnRows("SELECT * FROM tbl_sell_customers WHERE c_id = {0}".format(company_id))
    if len(rows) == 0:
        print "0"
    else :
        row = rows[0]
        str = "{0}^^{1}^^{2}^^{3}^^{4}^^{5}^^{6}^^{7}^^{8}^^{9}^^{10}^^{11}".format(row[0],row[1],row[2],row[3],row[4],
                                                                                row[5],row[6],row[7],row[8],row[9],
                                                                                row[10],row[11])
        print str
Exemple #13
0
def send_chlist():
    rows = py_db.executeAndReturnRows("select * from tbl_irib_channels order by ic_id")
    i=0
    res = ""
    for row in rows:
	i=i+1
	if i==1:
	   res=row[0].__str__()+"====="+row[1].__str__()
	else:
	    res = res+"____"+row[0].__str__()+"====="+row[1].__str__()
    print res
Exemple #14
0
def send_olaviats_mozoo_mehvar_list(id):
    rows = py_db.executeAndReturnRows("select * from tbl_irib_olaviats_mozoo_mehvarz where iomm_link={0} order by iomm_id".format(id))
    i=0
    res = ""
    for row in rows:
	i=i+1
	if i==1:
	   res=row[0].__str__()+"====="+row[1].__str__()
	else:
	    res = res+"____"+row[0].__str__()+"====="+row[1].__str__()
    print res
Exemple #15
0
def send_channel_lists():
    rows = py_db.executeAndReturnRows("select * from tbl_irib_channels order by ic_id ")
    i=0
    str = ""
    for row in rows:
        if i == 0:
            str = row[0].__str__()+"^^"+row[1].__str__()
        else :
            str = str+")))"+row[0].__str__()+"^^"+row[1].__str__()
        i=i+1
    str = convert_items_to_checkboxes("channels",str)
    print str
Exemple #16
0
def send_search_result(_search_text):
    
    rtxt = "select * from mehvarz where  match (_text) against('{0}')".format(_search_text)
    rows =py_db.executeAndReturnRows(rtxt)
    str84 = ""
    for row in rows:
	str84 = str84+"{2} - {0}<a class='a_add_meh' onclick='add_meh({1})' >+</a><br>".format(row[1],row[2],row[0])

    ss = str84
    
    
    r_txt = "SELECT COUNT(_year) ,_year FROM  `mehvarz`  WHERE match (_text) against('{0}') GROUP BY _year".format(_search_text)
    rows =py_db.executeAndReturnRows(r_txt)
    str_srch = ""
    for row in rows:
	str_srch = str_srch + "<span id='scscscd'> سال {0} نتیجه {1} </span> - ".format(row[1],row[0])
    str_srch = "<div id='div_srch'>{0}</div>".format(str_srch)
    
    
    
    #ss = ss.replace(_search_text,"<span class = 'sp_found'>{0}</span>".format(_search_text))
    print ss+"____"+str_srch
Exemple #17
0
def create_channel_with_checked (hadaf_id):
    rows_channels = py_db.executeAndReturnRows("select * from tbl_irib_channels order by ic_id")
    channels_col = []
    for row in rows_channels:
        channels_col.append([row[0],row[1]])
    sqlstr=""
    fr=""
    i=0

    sqlstr = """
    
    SELECT 
x1.*,

      CONCAT(
        CAST( (SELECT COUNT(*) FROM tbl_irib_mehvarha_content AS x2 WHERE x2.`imc_mehvar_link` = {2} AND 
        x2.`imc_channels_link`= x1.`ic_id` AND x2.imc_type=1) AS CHAR(2) )
        ,
	CAST( (SELECT COUNT(*) FROM tbl_irib_mehvarha_content AS x2 WHERE x2.`imc_mehvar_link` = {2} AND 
        x2.`imc_channels_link`= x1.`ic_id`  AND x2.imc_type=2) AS CHAR(2) )) AS ch1
 FROM `tbl_irib_channels` AS x1
    
    """.format(row[0],fr,hadaf_id)
    rows = py_db.executeAndReturnRows(sqlstr)
    li = ""
    for row in rows:
	cc=""
	if row[2] == "01": cc="الویت اول"
	if row[2] == "10": cc="الویت دوم"
	if row[2] == "00": cc="---"
	
	li=li+"""
	<div class="div_ch"><span class="div_ch_name">{0}</span><span class="div_ch_value">{1}</span></div>
	
	
	""".format(row[1],cc)

    return ""+li+""
Exemple #18
0
def do_update(request,keyfieldID):
    update_str = ""
    sql="select f_table_name,f_key_field from tbl_forms where f_id=(select fi_link_to_form_name from tbl_form_items where fi_id='{0}' limit 1)".format(request[0][0])
    
    tt = py_db.executeAndReturnRows(sql)
    table_name = tt[0][0]
    ketfield_name = tt[0][1]
    
    for item in request:
        if update_str == "":update_str ="{0}='{1}'".format(item[2][15],item[1])
        else: update_str +=",{0}='{1}'".format(item[2][15],item[1])
        
    sql="update {0} set {1} where {2}".format(table_name,update_str,ketfield_name+"='{0}'".format(keyfieldID[0]))
    #print sql
    
    sql=sql.replace("'empty'",'(NULL)')
    py_db.executesql(sql)
Exemple #19
0
def do_insert(request):
    insert_str = ""
    before_value = ""
    after_value = ""
    sql="select f_table_name from tbl_forms where f_id=(select fi_link_to_form_name from tbl_form_items where fi_id='{0}' limit 1)".format(request[0][0])
    table_name = py_db.executeAndReturnRows(sql)[0][0]
    #print request
    for item in request:
        #print item.__str__()+"<br>"
        #['1', '1', (1L, u'\u0646\u0627\u0645', 1, None, None, None, 1, 0, None, None, 1L, 1L, None, None, None, u'soccc_name')]
        if before_value == "":before_value ="{0}".format(item[2][15])
        else: before_value +=",{0}".format(item[2][15])
        if after_value == "":after_value ="'{0}'".format(item[1])
        else: after_value +=",'{0}'".format(item[1])
        
    sql="insert into {0} ({1}) values ({2})".format(table_name,before_value,after_value)
    py_db.executesql(sql)
    return sql
Exemple #20
0
def get_lookup(title,tablename,display_field_name,return_value,destination_object):
    sql = "select {0},{1} from {2} order by {0}".format(return_value,display_field_name,tablename)
    sql = sql.replace('"','')

    rows = py_db.executeAndReturnRows(sql)
    str = ""
    str = "<table><tbody><tr><td colspan=3>{0}</td></tr><tr><td colspan=3> جستجو </td></tr>".format(title)
    for row in rows:
        str = str+"""<tr><td>{0}</td><td>{1}</td><td><a href='#' onclick='send_to_obj("{0}","{2}");'>انتخاب</a></td></tr>""".format(row[0],row[1],destination_object)
    str = str+"</tbody></table>"
    html = """


    
    """
    
    
    print str
Exemple #21
0
def create_content_div(mehvar_id):
    row = py_db.executeAndReturnRows("""select x1.`cim_id`,x1.`cim_name`,x1.`cim_codes`,
				     (select c_name from tbl_irib_ahdaf where c_id = x1.cim_codes) as ahadaf_text
				     from tbl_irib_mehvarha as x1 where x1.cim_id = """+mehvar_id.__str__()+" order by cim_id")[0]
    div = """
    
    <ul class="ul_channel" id="ul_{4}">
    
    <li class="li_right">
<table>
<tbody>
    <tr><td class="td_onv">ردیف</td><td class="td_val1">{0}</td></tr>
    <tr><td class="td_onv">هدف</td><td class="td_val2">{1}</td></tr>
    <tr><td class="td_onv">محور</td><td class="td_val3">{2}</td></tr>
    <tr><td class="td_vir" colspan=2> <a href='#' onclick='get_edit_content({4})'> ویرایش </a>  <a href='#' onclick=''> نظر </a>
    <span>آخرین ویرایش در تاریخ : 93/01/01  - تعداد نظرات  : .... - تعداد ویرایش ها : .....</span>
    
    </td></tr>
    </tbody></table>




    </li>



    <li class="li_left">
    <ul>
    {3}</ul>
    </li>
    </ul>
    
    """.format(row[0].__str__(),
	       row[1].__str__(),
	       row[2].__str__()+"- "+row[3].__str__(),
	       create_channel_with_checked(mehvar_id),
	       mehvar_id)
    return div
Exemple #22
0
def generate_ul():
    def is_key_ext_in_ar(array,key):
	for ar in array:
	    if ar == key : return True
	return False
    
    def get_child(parent_id,level=1):
	rows = py_db.executeAndReturnRows("select * from tbl_irib_book where ib_parent = {0}".format(parent_id))
	if len(rows)>0:
	    print "<ul>"
	    for row in rows:
		print "<li id='li_{1}'>{0}</li>".format(row[1],row[0])
		get_child(row[0],level+1)
	    print "</ul>" 

    rows = py_db.executeAndReturnRows("select * from tbl_irib_book ORDER BY ib_parent")
    if len(rows)>0:
	print "<ul>"
	for row in rows:
	    print "<li id='li_{1}'>{0}</li>".format(row[1],row[0])
	    get_child(row[0])
	    print "</ul>"
	    return
def read_form_from_database_and_generate_html_with_objects_map(form_id):
# in this line i get form name for making form tag
    f_english_form_name = py_db.executeAndReturnRows("select f_english_form_name from tbl_forms where f_id={0}".format(form_id))[0][0].__str__()
# we get form items right now
    sql = """
    select
    fi_id,
    fi_name,
    fi_object_type,
    fi_if_radio_group_name,
    fi_if_mask_maskstring,
    fi_if_3_4_5_link_value,
    fi_not_null,
    fi_check_value_between,
    fi_check_value_from_to,
    fi_if_4_link_tbl_name,
    fi_link_to_form_name,
    fi_order,
    fi_default_value,
    fi_length,
    fi_exp
    from tbl_form_items where fi_link_to_form_name = (select f_id from tbl_forms where f_id={0}) order by fi_order
    """.format(form_id)
    rows = py_db.executeAndReturnRows(sql)
#this is link for sending data to server
# i set function name for js post then i will write other nec code
    formhtml=''
# generating vars
    script=""
    index=0
    objs_mapping=[]
# here we go making form items
#==============================================================
#==============================================================
#==============================================================
    for row in rows:
        if row[2] <> 7 and row[2] <> 8 :
            index=index+1
#__________________________________________________________________________________

        obj_map=[]
        obj_map.append(row[0])
        obj_map.append("obj_"+index.__str__())
        objs_mapping.append(obj_map)       
# Generating Simple Tags ---------------------------------------------------------------------------------------
        formhtml=formhtml+"<tr>"
        exp = ""
# getting if default value has or not
        def_val = " "
        if row[12]!="-1":
            def_val = " value='{0}'".format(row[12])
#________________________________
        if row[14] !=None:exp=row[14] 
# handling if simple textbox 
        if row[2] == 1:
            if row[4]!=None:
                script+='$("#obj_{0}").mask("{1}");'.format(index,row[4])
            formhtml += """<td class='td_lbls'>{1}</td><td><input type="text" name="obj_{0}" id="obj_{0}"  {3}/></td><td>{2}</td>""".format(index,row[1],exp,def_val)
# handling if simple textbox 
        if row[2] == 6:
            script += '$("#obj_{0}").mask("{1}");'.format(index,"1399/99/99")
            formhtml += """<td class='td_lbls'>{1}</td><td><input type="text" name="obj_{0}" id="obj_{0}"   {3}/> </td><td>{2}</td>""".format(index,row[1],exp,def_val)
    
 # handling if simple textbox 
        if row[2] == 2:
            formhtml += """<td class='td_lbls'>{1}</td><td><input type="text" name="obj_{0}" id="obj_{0}"   {3}/> </td><td>{2}</td>""".format(index,row[1],exp,def_val)
            
#______________________________
        if row[2]==3:
            def_val = ""
            if row[12]=="checked":
                def_val = ' checked="checked"'
            formhtml += """<td class='td_lbls'>{2}</td><td><input id="obj_{0}" name="obj_{0}"  type="checkbox" {1}  /> </td><td>{3}</td>""".format(index,def_val,row[1],exp)   

#______________________________
        if row[2]==4:
            def_val = ""
            if row[12]=="checked":
                def_val = ' checked="checked"'
                
            if row[3]!=None:
                def_val += ' group="'+row[3]+'"'

            formhtml += """<td class='td_lbls'>{2}</td><td><input name="obj_{0}"  id="obj_{0}" type="radio"  {1}   /> </td><td>{3}</td>""".format(index,def_val,row[1],exp)   
 #______________________________       
        if row[2]==5:
            ssql = "select {0},{1} from {2} {3}".format(
                row[9].split(":::")[1],
                row[9].split(":::")[2],
                row[9].split(":::")[0],
                row[9].split(":::")[3])
            ssql = ssql.replace("//1//",py_login.get_user_id())
            ssql = ssql.replace("//2//",py_login.get_socc_id())
            
            rowss = py_db.executeAndReturnRows(ssql)
            dd=""
            for r in rowss:
                dd+=' <option value="{0}">{1}</option>'.format(r[1],r[0])
                formhtml +="""  <td>{2}</td><td>  <select name="obj_{0}"  id="obj_{0}"> {1}  </select></td><td>{3}</td>  """.format(index,dd,row[1],exp)   
        
        formhtml=formhtml+"</tr>"
    
#--------------------Scripts ---------------------
        if row[2]==2:
            #// checking if text is integer
            script+= ' $("#obj_{0}").ForceNumericOnly();'.format(index)
        if row[6]==1:
            #checking if it is empty or not
            pass
#==============================================================
#==============================================================
#==============================================================
#here i make form
# i put hv as validation for hacking purposes
    formhtml = ' <a href="#" onclick="submit_frm_'+f_english_form_name+'()">Post</a>  '+formhtml

    HV = ord_validation_mapping( py_db.encode(conv_array_to_str(objs_mapping)))
    #print HV
    script = '   <script type="text/javascript">  {0}  </script>'.format(script)
    formhtml= create_form_html( HV,f_english_form_name,formhtml+script)
    htm = []
    htm.append(formhtml)

    htm.append(objs_mapping)
    return htm
Exemple #24
0
def print_current_company_details ():
    row = py_db.executeAndReturnRows("select * from tbl_sell_seller")[0]
    str = "{0}ddr{1}ddr{2}ddr{3}ddr{4}ddr{5}ddr{6}ddr{7}ddr{8}ddr{9}ddr{10}".format(row[0],row[1],row[2],row[3],row[4],row[5],row[6],row[7],row[8],row[9],row[10])
    print str
def get_form_name_from_form_id(formID):
    return py_db.executeAndReturnRows("select f_english_form_name from tbl_forms where f_id = {0} limit 1".format(formID))[0][0]
def get_key_field_name_from_form_id(formID):
    return py_db.executeAndReturnRows("select f_key_field from tbl_forms where f_id = {0} limit 1".format(formID))[0][0]
    b=b.replace('ظ','ظ')
    b=b.replace('ق','ق')
    b=b.replace('ط','ط')
    b=b.replace('پ','پ')
    b=b.replace('د','د')
    

    
        

    print b    
    return b

#print ord("د")
#print ord("د")


rows = py_db.executeAndReturnRows("select * from mehvarz")
cco = 0
for row in rows:
    r1 = prepare_farsi_alf(row[1])
    py_db.executesql("""
                     update mehvarz set
                     _text = '{0}' where id='{1}'
                     """.format(r1,row[2]))
    cco += cco
    print cco
    
    
print "succ"
Exemple #28
0
    ['ch_nasim','شبکه نسیم']]

asliii = "الویت  های اول"
FARII = "الویت  های دوم"

tbl = ""
RadeefeShabake = 0;
for ch in channels:
    RadeefeShabake=0
    #retrieving *
    tbl = tbl+"<table  class='tbl_irib'  cellpadding='0' cellspacing='0' ><tbody><tr class='tr_ch'><td colspan='3'>{0}</td><tr>".format(ch[1])
    for i in mehv:
        sql='select main_code,Onvan from sheet_anavin where {0}="*" and LinkToAhdaf ="{1}" order by main_code'.format(ch[0],i[0])
        
        
        rows = py_db.executeAndReturnRows(sql)
        c=0
        
        assli_zero = 0
        if len(rows) != 0:
            tbl=tbl+"<tr class='tr_onvan'><td colspan='2'>{1}</td><td>{0}</td><tr>".format(i[2],i[1])
        else: assli_zero = 1

        for row in rows:
            RadeefeShabake=RadeefeShabake+1
            if c==0:
                tbl=tbl+"<tr class='tr_onvan_asli'><td colspan='3'>{0}</td><tr>".format(asliii)
                tbl=tbl+"<tr class='tr_onvan'><td>ردیف</td><td>محور ها</td><td>کد</td><tr>".format(i[2],i[1])
            c=c+1
            tbl = tbl+"<tr><td>{2}</td><td>{1}</td><td>{0}</td></tr>".format(row[0],row[1],RadeefeShabake)
            
 
 
    


print 'Content-Type: text/html; charset=utf-8'
print ''
frm = ""
tmpl = ""


form = cgi.FieldStorage()
formID = form.getvalue("id","-1")


form_name = py_db.executeAndReturnRows("select f_english_form_name from tbl_forms where f_id = "+formID.__str__())[0][0]

frm = render_page(form_name, "testtttt")
tmpl = get_template_page()
tmpl = tmpl.replace("##content", frm)
#tmpl = tmpl.replace("##loginInfo", py_db.get_company_name_from_user_id(user_id)+" خوش آمدید")
#tmpl = tmpl.replace("##UserInfo", py_login.get_username_from_user_id(user_id))
tmpl = tmpl.replace("##Menu", create_right_menu())

print tmpl




    
Exemple #30
0
objs_array = unhashed.split("::")
keyfieldID=""
if fff_key!="-1":
    _OOO = fff_key.split("::")
    for __ord in _OOO:
        if __ord <> "" and __ord.isdigit():
            _hashed+= chr(int(__ord))
    _unhashed = py_db.decode(_hashed)
    keyfieldID = _unhashed.split("::")




#getting form data from db
#print objs_array
hs=py_db.executeAndReturnRows("select * from tbl_form_items where fi_link_to_form_name = (select fi_link_to_form_name from tbl_form_items where fi_id={0}) order by fi_order".format(objs_array[1].split("##")[1]))
# converting hashed mapping to array
http_inputs = []
for ob in objs_array:
    if ob!="":
        ps=[]
        ps.append(ob.split("##")[0])
        ps.append(ob.split("##")[1])
        http_inputs.append(ps)

items=[]
# here we are going to make final array which contains mapped field and webform 

for row in hs:
    item=[]
    for i in http_inputs :