#!c:/python/python.exe # # # v1.12 : optimisation de la taille du code # réduction de la redondance du code # Tests des vides sur code " " au lieu du null # Nécessite un base traitée avec LEIWEB v1.87 ou supérieur # Nécessite SQLWeb.py V.1.55odbc ou supérieur # v1.13 : Possibilité de filtrer les CRDP par critères+modalités dans les boucle crd et crdp # v1.14 : Résolution d'un pb de doublons dans lp quand cat1 et cat2 sont renseignés # v1.15 : Sélection multiple par type # v1.16 : Supporte les tags différentiés dans la boucle desext (debutcriteredescriptifX,...) au lieu d'un seul (debutcritere,...) # Rationnalisation des boucles de genres-catégories-types et prest # Recherche par noms possibles sur lp (le caractère '%' ou %25 en URL est utilisé pour *) # v1.17 : Prend en compte les bornes Valmin et Valmax lors d'une recherche par valeur de critère avec un plancher ou un plafond # v1.18 : Tri de la boucle lp par du et au pour calendrier au lieu de seulement du import sys,cgi,string, time import SQLWeb, skelTags import parametre class sqlwebfunctions: #--------------------------------------------------------------------------------- def __init__ (self): self.maversion="1.18" return def version(self): # renvoie le numéro de version de la librairie return self.maversion #--------------------------------------------------------------------------------- def isnumeric(self,lenomb): # fonction testant si une expression est numérique (entière) # arg lenomb : chaine # retourne 1 si lenomb est numérique, 0 sinon ok = 1 chref = '0123456789' i = 0 while i < len(lenomb) and ok == 1: if string.find(chref, lenomb[i]) == -1: ok = 0 i = i + 1 return ok #--------------------------------------------------------------------------------- def isdate(self,ladate): # fonction testant la validité d'une date # arg ladate : chaine de date sous forme j/m/a # retourne 1 si ladate est une date valide 0 sinon ok = 1 tablomax =(0,31,28,31,30,31,30,31,31,30,31,30,31) # on teste la forme d'une date ok if string.count(ladate,'/') != 2: ok = 0 else: ladate = string.split(ladate,'/') # on teste si la date est ok if self.isnumeric(ladate[0]) != 1 or self.isnumeric(ladate[1]) != 1 or self.isnumeric(ladate[2]) != 1: ok = 0 elif int(ladate[1]) < 1 or int(ladate[1]) > 12: ok = 0 else: if int(ladate[0]) < 1: ok = 0 else: if int(ladate[1]) == 2: # on fait tout de suite le mois de février if ((int(ladate[2])) % 100) != 0 and ((int(ladate[2])) % 4) == 0 and (int(ladate[0])) > 29: # année bissextile ok = 0 elif int(ladate[2]) % 100 != 0 and int(ladate[2]) % 4 == 0 and int(ladate[0]) == 29: ok = 1 elif int(ladate[0]) > 28: ok = 0 elif int(ladate[0]) > tablomax[int(ladate[1])]: ok = 0 return ok #--------------------------------------------------------------------------------- def traitecfCrit(self,entree): # cette fonction génère la chaine sql d'une recherche multicritères # à partir des paramètres d'url en entrée # paramètre : entree : tableau de 4 paramètres d'entrée # qs : tableau des paramètres de l'url # cmptsuite : compteur de laisons chainées de crdp # lefrom : clause from existante # lewhere : clause where déjà existante (ou having) # retour : les mêmes paramètres qu'en entrée mis à jour (clauses sql) qs = entree[0] # cmptsuite = entree[1] lefrom = entree[2] lewhere = entree[3] leidb = SQLWeb.SQLWeb(parametre.machine,parametre.base) #cmptsuite = 0 for k in qs.keys(): if k[:7]=='selCri_': cmptsuite = cmptsuite + 1 # test des parametres de valeurs valmin = '' valmax = '' where_val_listprod = '' typeval = '' lecri = str(k[7:]) for l in qs.keys(): if l == 'valMin_' + lecri: if qs[l] != '' and qs[l] != None: valmin = qs[l] if l =='valMax_' + lecri: if qs[l] != '' and qs[l] != None: valmax = qs[l] if qs[k] == '0': estquantitatif=1 else: estquantitatif = 0 where_val_listprod = '' # si pas de valeurs demandees, on ne fait rien (pas + cher) if (valmin == '' or valmin == None) and (valmax == '' or valmax==None): val_listprod = '' else: # sinon, on requete pour connaitre typeval leidb.selectsql("select typedevaleur, qualitatif from leinetcriteres where leinetcriteres.critere=" + lecri) e = leidb.fetchsql() lechampval = 'valeur' if e: typeval = e['typedevaleur'] if e['qualitatif'] == 0: estquantitatif = 1 else: estquantitatif = 0 # préparation des formats selon type de valeur if typeval == 3: # cas de la date : préparation des formats # passage du format francais au format américain lechampval = 'valeurdate' if valmin != '' or valmin != None: # on teste la forme d'une date ok if self.isdate(valmin) == 0: valmin = '' else: valmin = string.split(valmin,'/') valmin = '#' + valmin[1] + '/' + valmin[0] + '/' + valmin[2] + '#' if valmax != '' and valmax != None: if self.isdate(valmax) == 0: valmax = '' else: valmax = string.split(valmax,'/') valmax = '#' + valmax[1] + '/' + valmax[0] + '/' + valmax[2] + '#' elif typeval == 1 or typeval == 5: # cas numérique ou monétaire lechampval = 'valeurnum' if valmin != '' and valmin != None: if self.isnumeric(valmin) == 0: valmin = '' if valmax != '' and valmax != None: if self.isnumeric(valmax) == 0: valmax = '' else: # non géré par défaut (pb de nulls avec le texte) if valmin != '' and valmin !=None: valmin = "'" + valmin + "'" if valmax != '' and valmax !=None: valmax = "'" + valmax + "'" valmin = '' valmax = '' # maintenant, on traite tous les types de val de facon standard if (valmin != '' and valmin != None) and (valmax != '' and valmax != None): where_val_listprod = ' and (a' + str(cmptsuite) + '.[' + lechampval + '] between ' + valmin + ' and ' + valmax + ')' elif (valmin == '' or valmin==None) and (valmax != '' and valmax != None): where_val_listprod = ' and (a' + str(cmptsuite) + '.[' + lechampval + '] <= ' + valmax + ')' elif (valmax == '' or valmax == None) and (valmin != '' and valmin != None): where_val_listprod = ' and (a' + str(cmptsuite) + '.[' + lechampval + '] >= ' + valmin + ')' else: where_val_listprod = '' #on ne prend pas critere + modalite si le critère est quantitatif et qu'aucune valeur n'a été fournie if where_val_listprod!='' or estquantitatif!=1: if(cmptsuite>1): lefrom = '(' + lefrom + ' left join [leinetcriteresdesproduits] as a' + str(cmptsuite) + ' on a' + str(cmptsuite-1) + '.produit = a' + str(cmptsuite) + '.produit)' lewhere = lewhere + ' and (a' + str(cmptsuite) + '.[critere]=' + k[7:] + ' and a' + str(cmptsuite) + '.modalite=' + qs[k] + where_val_listprod + ')' else: lefrom = '(' + lefrom + ' left join [leinetcriteresdesproduits] as a' + str(cmptsuite) + ' on leinetproduits.produit = a' + str(cmptsuite) + '.produit)' lewhere = lewhere + ' and (a' + str(cmptsuite) + '.[critere]=' + k[7:] + ' and a' + str(cmptsuite) + '.modalite=' + qs[k] + where_val_listprod + ')' else: cmptsuite = cmptsuite - 1 sortie = (qs, cmptsuite,lefrom,lewhere) return sortie #---------------------------------------------------------------------------------------------------- def interface(self, qs): # fonction principale champtri = parametre.champtri leidb = SQLWeb.SQLWeb(parametre.machine,parametre.base) for i in qs.keys(): if(str(i)!="page"): qs[i]=string.lower(str(qs[i][0])) else: qs[i]=qs[i][0] # ouverture du skelette if qs.has_key('version'): print 'content-type:text/html\n' print '' print '' print 'version des logiciels web vbc installes' print '' #leidb = SQLWeb.SQLWeb(parametre.machine,parametre.base) e = leidb.versionsql() print '
version de la librairie de fonctions : ' + self.maversion print '
version du connecteur DB : ' + e print '' sys.stdout.flush leidb.endsql() sys.exit() if qs.has_key('page'): smt = skelTags.skelTags(parametre.chemin, qs['page']) else: smt = skelTags.skelTags(parametre.chemin,'erreur.sk') print 'content-type:text/html\n' smt.printtag('begin') print "erreur : il faut donner un skelette destination : manque paramètre 'page'." smt.printtag('end') leidb.endsql() sys.exit() print 'content-type:text/html\n' smt.printtag('begin') cntcrd = 1 ignore = {} if qs.has_key('ign'): igno = string.split(qs['ign'],",") for igo in igno: ignore[igo]=1 if qs.has_key('boucle'): code = string.split(qs['boucle'],",") # boucle de param (permet le choix des differents paramttre a afficher for t in code: # boucle qui ne fait rien if t=='rien': smt.printtag('debutrien') smt.printtag('finrien') # affichage de la listes des genres, catégories, types, communes, critères if t=='cntg' or t=='cntc' or t=='cntt' or t=='g' or t=='c' or t=='t' or t=='comm' or t=='cr': legroupby ='' lewhere = ' where 1=1 ' table = 'leinetproduits' tablef = 'leinetsyntheseproduits' if t=='cr': # cas particulier table = 'leinetsyntheseproduits' tablef = 'leinetsyntheseproduits_1' if (qs.has_key('critselect') and qs['critselect']!=''): synthese = 1 table = 'leinetsyntheseproduits' legroupby = legroupby + ' , ' + table + '.critere, ' + table + '.modalite ' if t=='cr': # Cas particulier ##tablef = 'leinetsyntheseproduits_1' lewhere = lewhere + ' and (' + table +'.critere in (%(critselect)s)) '%qs else: lehaving = lehaving + ' and (' + tablef + '.critere in (' + qs['critselect'] + '))' else: qs['critselect']='' legroupby = '' lehaving = ' having 1=1 ' synthese = 0 hor = 0 legenre = 0 # Vaut 1 si on doit lier la table des genres lacat = 0 # 1 Vaut 1 Si on doit lier la table des catégories if qs.has_key('critfiltre') and qs['critfiltre'] != '': synthese = 1 ##if t=='cr': # Cas particulier ## tablef = 'leinetsyntheseproduits_1' table = 'leinetsyntheseproduits' synthese = 1 legroupby = legroupby + ' , ' + tablef + '.critere, ' + tablef + '.modalite ' lehaving = lehaving + ' and (((' + tablef + '.critere)=' + qs['critfiltre'] + ') and ((' + tablef + '.modalite)=' + qs['modfiltre'] + ')) ' else: qs['critfiltre']='' qs['modfiltre']='' if qs.has_key('au') and qs['au'] != '': hor = 1 # passage du format francais au format américain leau = string.split(qs['au'],'/') leauau = leau[1] + '/' + leau[0] + '/' + leau[2] lewhere = lewhere + ' and not (([leinethoraires].[du] > #' + leauau + '#) ' if qs.has_key('du') and qs['du'] != '' : # passage du format francais au format américain ledu = string.split(qs['du'],'/') ledudu = ledu[1] + '/' + ledu[0] + '/' + ledu[2] lewhere = lewhere + ' or ([leinethoraires].[au] < #' + ledudu + '#)) ' else: lewhere = lewhere + ' ) ' qs['du'] = '' else: #print 'pas de au' qs['au'] = '' if qs.has_key('du') and qs['du'] != '' : hor = 1 #from_cntg = ' from leinetgenresdeproduits left join (leinetcategories left join (leinethoraires right join (' + table + ' right join leinettypesdeproduits on ' + table + '.typedeproduit = leinettypesdeproduits.type) on leinethoraires.produit = ' + table + '.produit) on (leinetcategories.categorie = leinettypesdeproduits.categorie1 or leinetcategories.categorie = leinettypesdeproduits.categorie2)) on leinetgenresdeproduits.genre = leinetcategories.genre' # passage du format francais au format américain ledu = string.split(qs['du'],'/') ledudu = ledu[1] + '/' + ledu[0] + '/' + ledu[2] lewhere = lewhere + ' and not ([leinethoraires].[au] <#' + ledudu + '#) ' else: qs['du']='' qs['au']='' if qs.has_key('mois') and qs['mois'] != '' : hor = 1 mois = qs['mois'] ms = int(mois[0:2]) an = int(mois[3:7]) if(ms==12): msf=1 anf=an + 1 else: msf=ms+1 anf=an deb = str(ms) + '/01/' + str(an) fin = str(msf) + '/01/' + str(anf) lewhere = lewhere + ' and not (( leinethoraires.du >=#' + fin + '#) or (leinethoraires.au <#' + deb + '#))' else: qs['mois']='' if qs.has_key('dept') and qs['dept'] != '': lewhere = lewhere + ' and ' + table + '.dpt=%(dept)s '%qs else: qs['dept'] = '' if qs.has_key('deptselect') and qs['deptselect'] != '': lewhere = lewhere + ' and ' + table + '.dpt in (%(deptselect)s) '%qs else: qs['deptselect'] = '' if qs.has_key('ville') and qs['ville'] != '' : laville = string.lower(string.upper(qs['ville'])) lewhere = lewhere + ' and lcase(' + table + '.[ville]) = '' + laville + '' ' else: qs['ville'] = '' if qs.has_key('villeselect') and qs['villeselect'] != '' : laville = string.lower(string.upper(qs['villeselect'])) lewhere = lewhere + ' and lcase(' + table + '.[ville]) in (' + laville + ')' else: qs['villeselect'] = '' if qs.has_key('genreselect') and qs['genreselect'] != '': lehaving = lehaving + ' and (leinetcategories.genre in (%(genreselect)s)) '%qs legroupby = legroupby + ', leinetcategories.genre' lacat = 1 else: qs['genreselect'] = '' if qs.has_key('genre') and qs['genre'] != '': lehaving = lehaving + " and (leinetcategories.genre in (%(genre)s))"%qs legroupby = legroupby + ', leinetcategories.genre' lacat = 1 else: qs['genre'] = '' if qs.has_key('catselect') and qs['catselect'] != '': lehaving = lehaving + " and (leinetcategories.categorie in (%(catselect)s)"%qs legroupby = legroupby + ', leinetcategories.categorie' lacat = 1 else: qs['catselect'] = '' if qs.has_key('categorie') and qs['categorie'] != '': lehaving = lehaving + " and (leinetcategories.categorie in (%(categorie)s)) "%qs legroupby = legroupby + ', leinetcategories.categorie' lacat = 1 else: qs['categorie'] = '' if qs.has_key('type') and qs['type'] != '': lehaving = lehaving + " and (leinettypesdeproduits.type in (%(type)s)) "%qs legroupby = legroupby + ', leinettypesdeproduits.type' else: qs['type'] = '' if qs.has_key('typeselect') and qs['typeselect'] != '': lehaving = lehaving + " and (leinettypesdeproduits.type in (%(typeselect)s)) "%qs legroupby = legroupby + ', leinettypesdeproduits.type' else: qs['typeselect'] = '' #lefrom = '(' + lefrom + 'left join ' + table + ' on leinettypesdeproduits.type = ' + table + '.typedeproduit' lefrom = ' (leinetgenresdeproduits left join (leinetcategories left join (leinettypesdeproduits left join ' + table + ' on leinettypesdeproduits.type = ' + table + '.typedeproduit) on leinetcategories.categorie = leinettypesdeproduits.categorie1 or leinetcategories.categorie = leinettypesdeproduits.categorie2) on leinetgenresdeproduits.genre = leinetcategories.genre)' if hor == 1: lefrom = ' (leinetgenresdeproduits left join (leinetcategories left join (leinettypesdeproduits left join (' + table + ' left join leinethoraires on ' + table + '.produit = leinethoraires.produit) on leinettypesdeproduits.type = ' + table + '.typedeproduit) on leinetcategories.categorie = leinettypesdeproduits.categorie1 or leinetcategories.categorie = leinettypesdeproduits.categorie2) on leinetgenresdeproduits.genre = leinetcategories.genre)' #lefrom = '(' + lefrom + ' left join leinethoraires on ' + table + '.produit = leinethoraires.produit)' lefrom = ' from ' + lefrom if t=='g' or t=='cntg': leselect = 'select count(' + table + '.produit) as cntproduit, leinetgenresdeproduits.genre as cle , leinetgenresdeproduits.nomdugenre as lib, leinetgenresdeproduits.ordre' legroupby = ' group by leinetgenresdeproduits.genre, leinetgenresdeproduits.nomdugenre, leinetgenresdeproduits.ordre' + legroupby leorder = ' order by leinetgenresdeproduits.nomdugenre' req = leselect + lefrom + lewhere + legroupby + lehaving + leorder # print req leidb.selectsql(req) e = leidb.fetchsql() qstr = qs.copy() if t=='cntg': if not e: if smt.tags.has_key('debutnoreponsecntgenre'): smt.printtag('debutnoreponsecntgenre') smt.printtag('finnoreponsecntgenre') else: smt.printtag('debutcntgenre') while e: #for i in e.keys(): # if e[i]=='' or e[i]==None: # e[i]=' ' qstr.update(e) print smt.gettag('debutdetailcntgenre')%qstr e = leidb.fetchsql() smt.printtag('findetailcntgenre') smt.printtag('fincntgenre') if t=='g': ###leselect = 'select distinct leinetgenresdeproduits.genre as cle, leinetgenresdeproduits.nomdugenre as lib ' ###legroupby = ' group by leinetgenresdeproduits.genre, leinetgenresdeproduits.nomdugenre, leinetgenresdeproduits.ordre' + legroupby ###leorder = ' order by leinetgenresdeproduits.nomdugenre' ###req = leselect + lefrom + lewhere + legroupby + lehaving + leorder # print req ###leidb.selectsql(req) ###e = leidb.fetchsql() if not e: if smt.tags.has_key('debutnoreponsegenre'): smt.printtag('debutnoreponsegenre') smt.printtag('finnoreponsegenre') else: smt.printtag('debutgenre') while e: #for i in e.keys(): # if e[i]=='' or e[i]==None: # e[i]=' ' qstr.update(e) print smt.gettag('debutdetailgenre')%qstr e = leidb.fetchsql() smt.printtag('findetailgenre') smt.printtag('fingenre') if t=='c' or t=='cntc': leselect = 'select count(' + table +'.produit) as cntproduit, leinetcategories.categorie, leinetcategories.nom, leinetcategories.genre ' legroupby = ' group by leinetcategories.categorie, leinetcategories.nom, leinetcategories.genre ' + legroupby leorder = ' order by leinetcategories.nom' req = leselect + lefrom + lewhere + legroupby + lehaving + leorder #req = string.lower(req) # print req leidb.selectsql(req) e = leidb.fetchsql() qstr = qs.copy() if t=='cntc': if not e: if smt.tags.has_key('debutnoreponsecntcategorie'): smt.printtag('debutnoreponsecntcategorie') smt.printtag('finnoreponsecntcategorie') else: smt.printtag('debutcntcategorie') while e: #for i in e.keys(): # if e[i]=='' or e[i]==None: # e[i]=' ' qstr.update(e)#qs.update(e) print smt.gettag('debutdetailcntcategorie')%qstr e = leidb.fetchsql() smt.printtag('findetailcntcategorie') smt.printtag('fincntcategorie') if t=='c': ###leselect = "select distinct leinetcategories.categorie,leinetcategories.nom " ###legroupby = ' group by leinetcategories.categorie, leinetcategories.nom, leinetcategories.genre ' + legroupby ###leorder = ' order by leinetcategories.nom' ###req = leselect + lefrom + lewhere + legroupby + lehaving + leorder #req = string.lower(req) #print req ###leidb.selectsql(req) ###e = leidb.fetchsql() if not e: if smt.tags.has_key('debutnoreponsecategorie'): smt.printtag('debutnoreponsecategorie') smt.printtag('finnoreponsecategorie') else: qstr = qs.copy() smt.printtag('debutcategorie') while e: #for i in e.keys(): # if e[i]=='' or e[i]==None: # e[i]=' ' qstr.update(e) print smt.gettag('debutdetailcategorie')%qstr e = leidb.fetchsql() smt.printtag('findetailcategorie') smt.printtag('fincategorie') if t=='t' or t=='cntt': leselect = 'select count(' + table + '.produit) as cntproduit, leinettypesdeproduits.type, leinettypesdeproduits.nom, leinettypesdeproduits.categorie1, leinettypesdeproduits.categorie2, leinettypesdeproduits.tagd, leinettypesdeproduits.tagf ' legroupby = " group by leinetcategories.categorie, leinettypesdeproduits.type, leinettypesdeproduits.nom, leinettypesdeproduits.categorie1, leinettypesdeproduits.categorie2, leinettypesdeproduits.tagd, leinettypesdeproduits.tagf " + legroupby leorder = ' order by leinettypesdeproduits.nom' req = leselect + lefrom + lewhere + legroupby + lehaving + leorder #req = string.lower(req) # print req leidb.selectsql(req) e = leidb.fetchsql() qstr = qs.copy() if t=='cntt': if not e: if smt.tags.has_key('debutnoreponsecnttype'): smt.printtag('debutnoreponsecnttype') smt.printtag('finnoreponsecnttype') else: smt.printtag('debutcnttype') while e: #for i in e.keys(): # if e[i]=='' or e[i]==None: # e[i]=' ' qstr.update(e) print smt.gettag('debutdetailcnttype')%qstr e = leidb.fetchsql() smt.printtag('findetailcnttype') smt.printtag('fincnttype') if t=='t': ###leselect = 'select distinct leinettypesdeproduits.type,leinettypesdeproduits.nom ' ###legroupby = " group by leinetcategories.categorie, leinettypesdeproduits.type, leinettypesdeproduits.nom, leinettypesdeproduits.categorie1, leinettypesdeproduits.categorie2, leinettypesdeproduits.tagd, leinettypesdeproduits.tagf " + legroupby ###leorder = ' order by leinettypesdeproduits.nom' ###req = leselect + lefrom + lewhere + legroupby + lehaving + leorder # print req ###leidb.selectsql(req) ###e = leidb.fetchsql() if not e: if smt.tags.has_key('debutnoreponsetype'): smt.printtag('debutnoreponsetype') smt.printtag('finnoreponsetype') else: smt.printtag('debuttype') while e: #for i in e.keys(): # if e[i]=='' or e[i]==None: # e[i]=' ' qstr.update(e) print smt.gettag('debutdetailtype')%qstr e = leidb.fetchsql() smt.printtag('findetailtype') smt.printtag('fintype') if t=='comm': leselect = 'select distinct ' + table + '.ville ' legroupby = ' group by ' + table + '.ville ' + legroupby leorder = ' order by ' + table + '.ville' req = leselect + lefrom + lewhere + legroupby + lehaving + leorder req = string.lower(req) # print req leidb.selectsql(req) e = leidb.fetchsql() if not e: if smt.tags.has_key('debutnoreponselistecommune'): smt.printtag('debutnoreponselistecommune') smt.printtag('finnoreponselistecommune') else: #qstr = qs.copy() smt.printtag('debutlistecommune') while e: #for el in e.keys(): # if(e[el]==None or e[el]==''): # e[el]=' ' #qstr.update(e) print smt.gettag('debutdetaillistecommune')%e e = leidb.fetchsql() smt.printtag('findetaillistecommune') smt.printtag('finlistecommune') if t=='cr': if hor == 1: leplus = '(' + table + ' left join leinethoraires on ' + table + '.produit = leinethoraires.produit)' else: leplus = table if synthese == 1: #dans le cas de la boucle cr, on doit un deuxième synthese pdts pour le critfiltre lefrom = ' (leinetgenresdeproduits left join (leinetcategories left join (leinettypesdeproduits left join (' + leplus + ' left join leinetsyntheseproduits as ' + tablef + ' on ' + table + '.produit = ' + tablef + '.produit) on leinettypesdeproduits.type = ' + table + '.typedeproduit) on leinetcategories.categorie = leinettypesdeproduits.categorie1 or leinetcategories.categorie = leinettypesdeproduits.categorie2) on leinetgenresdeproduits.genre = leinetcategories.genre)' else: lefrom = ' (leinetgenresdeproduits left join (leinetcategories left join (leinettypesdeproduits left join ' + leplus + ' on leinettypesdeproduits.type = ' + table + '.typedeproduit) on leinetcategories.categorie = leinettypesdeproduits.categorie1 or leinetcategories.categorie = leinettypesdeproduits.categorie2) on leinetgenresdeproduits.genre = leinetcategories.genre)' #lefrom = '(' + lefrom + ' left join leinethoraires on ' + table + '.produit = leinethoraires.produit)' lefrom = ' from ' + lefrom leselect = 'select distinct ' + table + '.critere, ' + table + '.cri, ' + table + '.modalite, ' + table + '.moda, ' + table + '.qualitatif, ' + table + '.typedevaleur' legroupby = ' group by ' + table + '.critere, ' + table + '.cri, ' + table + '.modalite, ' + table + '.moda, ' + table + '.qualitatif, ' + table + '.typedevaleur' + legroupby lewhere = lewhere + ' and ' + table + '.critere is not null and ' + table + '.modalite is not null' leorder = '' # ' order by ' + table + '.cri, ' + table + '.moda' req = leselect + lefrom + lewhere + legroupby + lehaving + leorder #req = string.lower(req) #print req #sys.exit() leidb.selectsql(req) e = leidb.fetchsql() qqchose = 0 if not e: if smt.tags.has_key('debutnoreponsecritere'): smt.printtag('debutnoreponsecritere') smt.printtag('finnoreponsecritere') else: qstr = qs.copy() smt.printtag('debutcritere') precedent = '' dernierqual = 1 while e : if precedent != e['critere']: #for i in e.keys(): # if e[i]=='' or e[i]==None: # e[i]=' ' if(precedent!='' and precedent!=None): if dernierqual != 0: smt.printtag('findetailmodalite') # si on rajoute les valeurs s'il y a lieu if dernierqual==2 or dernierqual==0: if smt.tags.has_key('debutvaleur'): print smt.gettag('debutvaleur')%qstr print smt.gettag('finvaleur')%qstr ### smt.printtag('findetailmodalite') ###print smt.gettag('findetailcritere') # on passe au nouvel enregistrement qstr.update(e) print smt.gettag('debutdetailcritere')%qstr if e['qualitatif'] == 0: if smt.tags.has_key('debutquantitatif'): print smt.gettag('debutquantitatif')%qstr print smt.gettag('finquantitatif')%qstr else: #print smt.gettag('debutqualitatif')%qstr #print smt.gettag('finqualitatif')%qstr if smt.tags.has_key('debutqualitatif'): print smt.gettag('debutqualitatif')%qstr print smt.gettag('finqualitatif')%qstr print smt.gettag('debutdetailmodalite')%qstr precedent = e['critere'] dernierqual = e['qualitatif'] # on traite le qualitatif 0 en particulier #if e['qualitatif'] != 0: # print 'pas 0' + str(e['critere']) # print smt.gettag('debutdetailmodalite')%qstr else: #for i in e.keys(): # if e[i]=='' or e[i]==None: # e[i]=' ' qstr.update(e) if e['qualitatif'] != 0: #print 'pas 0' + str(e['critere']) print smt.gettag('debutdetailmodalite')%qstr qqchose = 1 e = leidb.fetchsql() if qqchose == 1: if dernierqual != 0: if smt.tags.has_key('findetailmodalite'): smt.printtag('findetailmodalite') # si on rajoute les valeurs s'il y a lieu if dernierqual==2 or dernierqual==0: if smt.tags.has_key('debutvaleur'): print smt.gettag('debutvaleur')%qstr print smt.gettag('finvaleur')%qstr smt.printtag('findetailcritere') smt.printtag('fincritere') #affichage de la liste des produits if t=='lp' or t=='cntlp' or t=='sumg' or t=='sumc' or t=='sumt' or t=='nav' or t=='aig': horlie = 0 leselect = '' legroupby = '' table = 'leinetproduits' lefrom = table lewhere = ' where 1=1 ' leorder = champtri cmptsuite = 0 lacat = 0 # 1 Si on doit lier la table des catégories if qs.has_key('critfiltre') and qs['critfiltre'] != '': cmptsuite = cmptsuite + 1 lefrom = '(' + lefrom + ' left join [leinetcriteresdesproduits] as a' + str(cmptsuite) + ' on leinetproduits.produit = a' + str(cmptsuite) + '.produit)' lewhere = lewhere + ' and (a' + str(cmptsuite) + '.[critere]= %(critfiltre)s and a' %qs + str(cmptsuite) + '.modalite=%(modfiltre)s)' %qs else: qs['critfiltre']='' qs['modfiltre']='' if qs.has_key('cfCrit') and qs['cfCrit'] != '': entree = (qs, cmptsuite,lefrom,lewhere) sortie = self.traitecfCrit(entree) qs = sortie[0] cmptsuite = sortie[1] lefrom = sortie[2] lewhere = sortie[3] else: qs['cfCrit'] = '' if qs.has_key('nomprod') and qs['nomprod'] != '' : lenomprod = string.lower(string.upper(qs['nomprod'])) lewhere = lewhere + ' and lcase(' + table + '.[nom]) like '' + lenomprod +''' else: qs['nomprod'] = '' if qs.has_key('ville') and qs['ville'] != '' : laville = string.lower(string.upper(qs['ville'])) lewhere = lewhere + ' and lcase(' + table + '.[ville]) = '' + laville +''' else: qs['ville'] = '' if qs.has_key('villeselect') and qs['villeselect'] != '' : laville = string.lower(string.upper(qs['villeselect'])) lewhere = lewhere + ' and lcase(' + table + '.[ville]) in (' + laville + ')' else: qs['villeselect'] = '' if qs.has_key('type') and qs['type'] != '': lewhere = lewhere + ' and (leinetproduits.typedeproduit in (%(type)s)) '%qs else: qs['type']='' if qs.has_key('typeselect') and qs['typeselect'] != '': lewhere = lewhere + ' and (leinetproduits.typedeproduit in (%(typeselect)s)) '%qs else: qs['typeselect']='' #if qs.has_key('categorie') or qs.has_key('genre'): # from_listprod = ' ( leinetcategories right join (' + from_listprod + ') on leinetcategories.categorie = leinettypesdeproduits.categorie1 or leinetcategories.categorie = leinettypesdeproduits.categorie2 )' if qs.has_key('categorie') and qs['categorie'] != '': lewhere = lewhere + ' and ((leinettypesdeproduits.categorie1)=%(categorie)s or (leinettypesdeproduits.categorie2)=%(categorie)s)'%qs else: qs['categorie'] = '' if qs.has_key('catselect') and qs['catselect'] != '': lewhere = lewhere + ' and ((leinettypesdeproduits.categorie1) in (%(catselect)s) or (leinettypesdeproduits.categorie2) in (%(catselect)s))'%qs else: qs['catselect'] = '' if qs.has_key('genre') and qs['genre'] != '': lewhere = lewhere + ' and ((leinetcategories.genre) = %(genre)s) '%qs lacat = 1 else: qs['genre'] = '' if qs.has_key('genreselect') and qs['genreselect'] != '': lewhere = lewhere + ' and ((leinetcategories.genre) in (%(genreselect)s)) '%qs lacat = 1 else: qs['genreselect'] = '' if qs.has_key('au') and qs['au'] != '' : horlie = 1 leorder = ' leinethoraires.du, ' + champtri # passage du format francais au format américain leau = string.split(qs['au'],'/') leauau = leau[1] + '/' + leau[0] + '/' + leau[2] lewhere = lewhere + ' and not (([leinethoraires].[du] > #' + leauau + '#) ' if qs.has_key('du') and qs['du'] != '' : # passage du format francais au format américain ledu = string.split(qs['du'],'/') ledudu = ledu[1] + '/' + ledu[0] + '/' + ledu[2] lewhere = lewhere + ' or ([leinethoraires].[au] < #' + ledudu + '#)) ' leorder = ' leinethoraires.du, leinethoraires.au, ' + champtri else: lewhere = lewhere + ' ) ' qs['du'] = '' else: qs['au'] = '' if qs.has_key('du') and qs['du'] != '' : horlie = 1 # passage du format francais au format américain ledu = string.split(qs['du'],'/') ledudu = ledu[1] + '/' + ledu[0] + '/' + ledu[2] lewhere = lewhere + ' and not ([leinethoraires].[au] <#' + ledudu + '#) ' leorder = ' leinethoraires.du, leinethoraires.au, ' + champtri else: qs['du']='' qs['au']='' if qs.has_key('mois') and qs['mois'] != '' : horlie = 1 mois = qs['mois'] ms = int(mois[0:2]) an = int(mois[3:7]) if(ms==12): msf=1 anf=an + 1 else: msf=ms+1 anf=an deb = str(ms) + '/01/' + str(an) fin = str(msf) + '/01/' + str(anf) lewhere = lewhere + ' and not (( leinethoraires.du >=#' + fin + '#) or (leinethoraires.au <#' + deb + '#))' leorder = ' leinethoraires.du, leinethoraires.au, ' + champtri else: qs['mois']='' if qs.has_key('dept') and qs['dept'] != '': lewhere = lewhere + ' and leinetproduits.dpt=%(dept)s '%qs else: qs['dept'] = '' if qs.has_key('deptselect') and qs['deptselect'] != '': lewhere = lewhere + ' and leinetproduits.dpt in (%(deptselect)s) '%qs else: qs['deptselect'] = '' if horlie==1: lefrom = '(leinethoraires right join (' + lefrom + ') on leinethoraires.produit = ' + table + '.produit)' leselect= leselect + ' ,format([leinethoraires].[du],'dd/mm/yyyy') as du, format([leinethoraires].[au],'dd/mm/yyyy') as au ' legroupby = legroupby + ', [leinethoraires].[du], [leinethoraires].[au]' # On lie la table des types lefrom = '(' + lefrom + ' left join leinettypesdeproduits on leinetproduits.typedeproduit = leinettypesdeproduits.type) ' # Si besoin, la table des catégories if lacat==1: lefrom = '(' + lefrom + ' left join leinetcategories on leinettypesdeproduits.categorie1 = leinetcategories.categorie or leinettypesdeproduits.categorie2 = leinetcategories.categorie) ' if t=='lp': leorder = ' order by ' + leorder #+ 'leinetproduits.alea ' leselect = 'select leinetproduits.*, leinetproduits.memo1 ' + leselect #if horlie == 1: # leselect = leselect + ',format([leinethoraires].[du],"dd/mm/yyyy") as du, format([leinethoraires].[au],"dd/mm/yyyy") as au ' req = leselect + ' from ' + lefrom + lewhere + leorder # print req #req = string.lower(req) if qs.has_key('from') and qs.has_key('nbperpage'): leidb.selectsql(req,qs['from'],qs['nbperpage']) else: leidb.selectsql(req) e = leidb.fetchsql() nbres = 0 if not e: if smt.tags.has_key('debutnoreponselisteproduit'): smt.printtag('debutnoreponselisteproduit') smt.printtag('finnoreponselisteproduit') else: qstr = qs.copy() smt.printtag('debutlisteproduit') while e: #for el in e.keys(): # if(e[el]==None or e[el]==''): # e[el]=' ' if(e['image1']==' '): e['image1'] = '' if(e['image2']==' '): e['image2'] = '' if(e['image3']==' '): e['image3'] = '' if(e['image4']==' '): e['image4'] = '' if(e['dpt']==' '): e['dpt'] = '' qstr.update(e) print smt.gettag('debutdetaillisteproduit')%qstr e = leidb.fetchsql() smt.printtag('findetaillisteproduit') smt.printtag('finlisteproduit') #-- else: leselect = 'select count(leinetproduits.produit) as nbf' # pas d'order by : on veut juste le nb req = leselect + ' from ' + lefrom + lewhere # print req req = string.lower(req) leidb.selectsql(req) e = leidb.fetchsql() nbf = 0 if not e: f = {'nbf':0} else: f = {'nbf':e['nbf']} qstr = qs.copy() f['sumgenre'] = f['nbf'] f['sumcat'] = f['nbf'] f['sumtype'] = f['nbf'] qstr.update(f) if(t=='sumg'): if f['nbf']==0: if smt.tags.has_key('debutnoreponsesumgenre'): smt.printtag('debutnoreponsesumgenre') smt.printtag('finnoreponsesumgenre') else: print smt.gettag('debutsumgenre')%qstr smt.printtag('finsumgenre') else: print smt.gettag('debutsumgenre')%qstr smt.printtag('finsumgenre') if(t=='sumc'): if f['nbf']==0: if smt.tags.has_key('debutnoreponsesumcategorie'): smt.printtag('debutnoreponsesumcategorie') smt.printtag('finnoreponsesumcategorie') else: print smt.gettag('debutsumcategorie')%qstr smt.printtag('finsumcategorie') else: print smt.gettag('debutsumcategorie')%qstr smt.printtag('finsumcategorie') if(t=='sumt'): if f['nbf']==0: if smt.tags.has_key('debutnoreponsesumtype'): smt.printtag('debutnoreponsesumtype') smt.printtag('finnoreponsesumtype') else: print smt.gettag('debutsumtype')%qstr smt.printtag('finsumtype') else: print smt.gettag('debutsumtype')%qstr smt.printtag('finsumtype') if(t=='cntlp'): if f['nbf']==0: if smt.tags.has_key('debutnoreponsecomptelisteproduit'): smt.printtag('debutnoreponsecomptelisteproduit') smt.printtag('finnoreponsecomptelisteproduit') else: print smt.gettag('debutcomptelisteproduit')%qstr smt.printtag('fincomptelisteproduit') else: print smt.gettag('debutcomptelisteproduit')%qstr smt.printtag('fincomptelisteproduit') if(t=='aig'): if f['nbf']==0: print 'content-type:text/html\n' smt.printtag('selectionvide') smt.printtag('end') sys.stdout.flush() leidb.endsql() sys.exit() else: if qs.has_key('nombmax'): nbresmax = qs['nombmax'] else: nbresmax = 50 nbres=f['nbf'] if not qs.has_key('from'): qs['nbperpage']='1' if not qs.has_key('nbperpage'): qs['nbperpage']='10' if not qs.has_key('dept'): qs['dept']='' if not qs.has_key('critfiltre'): qs['critfiltre']='' if not qs.has_key('modfiltre'): qs['modfiltre']='' if not qs.has_key('critselect'): qs['critselect']='' if int(nbres)' smt.printtag('finparametre') #permet de decomposer le boudins de texte de critères descriptifs d'un pdt if t=='des': #leidb = SQLWeb.SQLWeb(parametre.machine,parametre.base) leselect = 'select leinetproduits.descriptif ' lefrom = ' leinetproduits ' lewhere = ' where 1=1 ' if qs.has_key('produit'): lewhere = lewhere + ' and leinetproduits.produit = %(produit)s' %qs req = leselect + ' from ' + lefrom + lewhere #req_produit = string.lower(req_produit) leidb.selectsql(req) e = leidb.fetchsql() if e['descriptif'] != ' ': chaine = string.replace(e['descriptif'], " ", "\t") tableau = string.split(chaine, " ") crittest = 0 smt.printtag('debutdescriptif') for t in tableau: if t[0] == "\t": if crittest: e['modalite'] = string.strip(t) #for i in e.keys(): # if e[i]=='' or e[i]==None: # e[i]=' ' print smt.gettag('debutmodalite')%e crittest = 0 else: e['critere'] = '' e['modalite'] = string.strip(t) #for i in e.keys(): # if e[i]=='' or e[i]==None: # e[i]=' ' print smt.gettag('debutmodalite')%e crittest = 0 else: e['critere'] = t print smt.gettag('debutcritere')%e crittest = 1 smt.printtag('fincritere') smt.printtag('finmodalite') crittest =0 smt.printtag('findescriptif') #leidb.endsql() #permet de decomposer le boudins de texte de critères de différentes classes if t=='desext': #leidb = SQLWeb.SQLWeb(parametre.machine,parametre.base) leselect = 'select leinetproduits.descriptif1,descriptif2,descriptif4,descriptif8,descriptif16,descriptif32 ' lefrom = ' leinetproduits ' lewhere = ' where 1=1 ' if qs.has_key('produit'): lewhere = lewhere + ' and leinetproduits.produit = %(produit)s' %qs req = leselect + ' from ' + lefrom + lewhere #req_produit = string.lower(req_produit) leidb.selectsql(req) e = leidb.fetchsql() #print 'fetch' qqchose=0 if qs.has_key('classe'): classe = string.split(qs['classe'],",") for cl in classe: if e.has_key(cl): crittest =0 if e[cl] != ' ' and e[cl] != '': #if e[cl]=='': # print 'lespace ' + e[cl] # print 'la classe : ' + str(cl) #print 'classe : ' + e[cl] qqchose=1 chaine = string.replace(e[cl], " ", "\t") tableau = string.split(chaine, " ") #print "chaine : " + chaine crittest = 0 tagdeb = 'debut'+cl tagfin = 'fin'+cl smt.printtag(tagdeb) for t in tableau: if t[0] == "\t": if crittest: e['modalite'] = string.strip(t) #for i in e.keys(): # if e[i]==' ': # e[i]='' #if e[i]=='' or e[i]==None: # e[i]=' ' ## Compatibilité avec les versions antérieures à 1.16 if smt.tags.has_key('debutmodalite' + cl): print smt.gettag('debutmodalite' + cl)%e else: print smt.gettag('debutmodalite')%e crittest = 0 else: e['critere'] = '' e['modalite'] = string.strip(t) #for i in e.keys(): # if e[i]==None: # e[i]='' #if e[i]=='' or e[i]==None: # e[i]=' ' ## Compatibilité avec les versions antérieures à 1.16 if smt.tags.has_key('debutmodalite' + cl): print smt.gettag('debutmodalite' + cl)%e else: print smt.gettag('debutmodalite')%e crittest = 0 else: e['critere'] = t ## Compatibilité avec les versions antérieures à 1.16 if smt.tags.has_key('debutcritere' + cl): print smt.gettag('debutcritere' + cl)%e else: print smt.gettag('debutcritere')%e crittest = 1 if qqchose==1: ## Compatibilité avec les versions antérieures à 1.16 if smt.tags.has_key('fincritere' + cl): smt.printtag('fincritere' + cl) else: smt.printtag('fincritere') if smt.tags.has_key('finmodalite' + cl): smt.printtag('finmodalite' + cl) else: smt.printtag('finmodalite') smt.printtag(tagfin) #leidb.endsql() #permet de verifier si il y a des produits associes if t=='ass': #leidb = SQLWeb.SQLWeb(parametre.machine,parametre.base) # smt.printtag('debutproduitassocie') req = 'select couplages from leinetproduits where produit = %(produit)s' %qs #req_ass = string.lower(req_ass) leidb.selectsql(req) ass= leidb.fetchsql() if ass['couplages'] and ass['couplages'] != ' ': #for i in ass.keys(): # if ass[i]=='' or ass[i]==None: # ass[i]=' ' print smt.gettag('debutproduitassocie')%ass smt.printtag('finproduitassocie') if t=='listass': req = 'select * from leinetproduits where produit in (%(couplage)s)' %qs #req_listass = string.lower(req_listass) leidb.selectsql(req) e = leidb.fetchsql() if not e: if smt.tags.has_key('debutnoreponselisteproduitassocie'): smt.printtag('debutnoreponselisteproduitassocie') smt.printtag('finnoreponselisteproduitassocie') else: smt.printtag('debutlisteproduitassocie') while e: #for i in e.keys(): # if e[i]=='' or e[i]==None: # e[i]=' ' if(e['dpt']==None): e['dpt'] = ' ' print smt.gettag('debutdetaillisteproduitassocie')%e e = leidb.fetchsql() smt.printtag('findetaillisteproduitassocie') smt.printtag('finlisteproduitassocie') # plus pratique que le dernier, on l'appelle juste avec un n° de produit if t=='listass2': leidb2 = SQLWeb.SQLWeb(parametre.machine,parametre.base) req = 'select * from leinetproduits where produit = %(produit)s' %qs #req_listass = string.lower(req_listass) leidb.selectsql(req) e = leidb.fetchsql() unas = 0 while e: if e.has_key('couplages'): if e['couplages']!=' ': print smt.gettag('debutlisteproduitassocie2')%e chaine = string.split(e['couplages'],",") for t in chaine: req = "select produit, nom from leinetproduits where produit="+t #req = string.lower(sql_pdt) leidb2.selectsql(req) f = leidb2.fetchsql() while f: #for i in f.keys(): # if f[i]=='' or f[i]==None: # f[i]=' ' print smt.gettag('debutproduitassocie')%f unas=1 f = leidb2.fetchsql() else: if smt.tags.has_key('debutnoreponselisteproduitassocie2'): smt.printtag('debutnoreponselisteproduitassocie2') smt.printtag('finnoreponselisteproduitassocie2') else: if smt.tags.has_key('debutnoreponselisteproduitassocie2'): smt.printtag('debutnoreponselisteproduitassocie2') smt.printtag('finnoreponselisteproduitassocie2') e = leidb.fetchsql() #else: # e = leidb.fetchsql() if unas==1: smt.printtag('finproduitassocie') smt.printtag('finlisteproduitassocie2') #leidb.endsql() leidb2.endsql() if t=='picto': #leidb = SQLWeb.SQLWeb(parametre.machine,parametre.base) smt.printtag('debutaffichepicto') req = 'select leinetsyntheseproduits.critere, leinetsyntheseproduits.modalite, leinetsyntheseproduits.cri, leinetsyntheseproduits.moda, leinetsyntheseproduits.produit from leinetsyntheseproduits ' req = req + ' where produit =' + qs['prod'] if qs.has_key('critmodpicto'): req = req + ' and (' chaine = string.split(qs['critmodpicto'], ";") for t in chaine: decomp = string.split(t,"-") req = req + ' ((leinetsyntheseproduits.critere = ' + decomp[0] +')' x = len(decomp) if x!=1: req = req + ' and (leinetsyntheseproduits.modalite in (' + decomp[1] + '))) or ' else: req = req +') or ' temp = string.split(req) temp.reverse() temp[0] = '' temp.reverse() req = string.join(temp) req = req + ')' #req_picto = string.lower(req_picto) leidb.selectsql(req) e=leidb.fetchsql() smt.printtag('debutbouclepicto') while e: #for i in e.keys(): # if e[i]=='' or e[i]==None: # e[i]=' ' e['images'] = e['critere'] + '-' + e['modalite'] print smt.gettag('finbouclepicto')%e e = leidb.fetchsql() smt.printtag('finaffichepicto') #leidb.endsql() #affichage de la liste des criteres descriptifs (vb 9/8/00) if t=='crd': #leidb = SQLWeb.SQLWeb(parametre.machine,parametre.base) smt.printtag('debutcriteredesc') leselect = 'select distinct leinetcriteresdesproduitsdesc.*' lefrom = ' from leinetcriteresdesproduitsdesc ' leorder = ' order by leinetcriteresdesproduitsdesc.critere' lewhere = ' where (leinetcriteresdesproduitsdesc.produit = %(produit)s) '%qs lewhere2 = '' cmptsuite = 0 lecri = '' lamod = '' ###---### if qs.has_key('cfMod'): # On filtre par modalités for k in qs.keys(): if k[:7]=='modSel_': # test des parametres de valeurs lecri = str(k[7:]) ordre = string.split(qs[k],',') lewhere2 = '' lewhere = ' where (leinetcriteresdesproduitsdesc.produit = %(produit)s) '%qs lewhere = lewhere + ' and (leinetcriteresdesproduitsdesc.critere='+lecri+ ') and (' for t in ordre: lewhere2 = lewhere2 + ' or leinetcriteresdesproduitsdesc.modalite='+t if lewhere2!='': lewhere2 = lewhere2[4:] lewhere = lewhere + lewhere2 + ')' else: lewhere = lewhere + '1=1)' req = leselect + lefrom + lewhere + leorder #print req #req_crd = string.lower(req_crd) leidb.selectsql(req) e = leidb.fetchsql() precedant = '' while e: if precedant == e['critere']: e['critere'] = ' ' e['nomcrit'] = ' ' else: precedant = e['critere'] #for i in e.keys(): # if e[i]=='' or e[i]==None: # e[i]=' ' print smt.gettag('debutdetailcriteredesc')%e print smt.gettag('debutdetailmodalitedesc')%e e = leidb.fetchsql() smt.printtag('findetailmodalitedesc') smt.printtag('findetailcriteredesc') smt.printtag('fincriteredesc') elif qs.has_key('critselect') : # OU on filtre par critères ordre = string.split(qs['critselect'],',') for t in ordre: lewhere = ' where (leinetcriteresdesproduitsdesc.produit = %(produit)s) '%qs if qs.has_key('critselect') : lewhere = lewhere +' and (leinetcriteresdesproduitsdesc.critere = ' + t + ')' req = leselect + lefrom + lewhere + leorder #req_crd = string.lower(req_crd) leidb.selectsql(req) e = leidb.fetchsql() precedant = '' while e: if precedant == e['critere']: e['critere'] = ' ' e['nomcrit'] = ' ' else: precedant = e['critere'] #for i in e.keys(): # if e[i]=='' or e[i]==None: # e[i]=' ' print smt.gettag('debutdetailcriteredesc')%e print smt.gettag('debutdetailmodalitedesc')%e e = leidb.fetchsql() smt.printtag('findetailmodalitedesc') smt.printtag('findetailcriteredesc') smt.printtag('fincriteredesc') else: # OU on filtre pas req = leselect + lefrom + lewhere + leorder #req_crd = string.lower(req_crd) leidb.selectsql(req) e = leidb.fetchsql() precedant = '' while e: if precedant == e['critere']: e['critere'] = ' ' e['nomcrit'] = ' ' else: precedant = e['critere'] #for i in e.keys(): # if e[i]=='' or e[i]==None: # e[i]=' ' print smt.gettag('debutdetailcriteredesc')%e print smt.gettag('debutdetailmodalitedesc')%e e = leidb.fetchsql() smt.printtag('findetailmodalitedesc') smt.printtag('findetailcriteredesc') smt.printtag('fincriteredesc') #leidb.endsql() #affichage de la liste des criteres descriptifs (vb 9/8/00) if t=='crdp': #leidb = SQLWeb.SQLWeb(parametre.machine,parametre.base) smt.printtag('debutcriteredesc'+str(cntcrd)) leselect = 'select distinct leinetcriteresdesproduitsdesc.*' lefrom = ' from leinetcriteresdesproduitsdesc ' leorder = ' order by leinetcriteresdesproduitsdesc.critere' nomcritselect = 'critselect'+str(cntcrd) nommodselect = 'modselect'+str(cntcrd) ordre = string.split(nomcritselect,',') for t in ordre: lewhere = ' where (leinetcriteresdesproduitsdesc.produit = %(produit)s) '%qs if qs.has_key(nomcritselect): if qs.has_key(nommodselect): if qs[nommodselect]!='': lewhere = lewhere +' and (leinetcriteresdesproduitsdesc.critere ='+qs[nomcritselect]+' and leinetcriteresdesproduitsdesc.modalite in ('+qs[nommodselect]+'))' else: lewhere = lewhere +' and (leinetcriteresdesproduitsdesc.critere in (0,'+qs[nomcritselect]+')) ' else: lewhere = lewhere +' and (leinetcriteresdesproduitsdesc.critere in (0,'+qs[nomcritselect]+')) ' req = leselect + lefrom + lewhere + leorder #print req_crd #req_crd = string.lower(req_crd) leidb.selectsql(req) e = leidb.fetchsql() precedant = '' qqchose = 0 while e: #for i in e.keys(): # if e[i]=='' or e[i]==None: # e[i]=' ' if precedant == e['critere']: # patch nico 31/01/2001 # e['critere'] = ' ' #e[critere] = '' e['nomcrit'] = ' ' else: precedant = e['critere'] ### - Comportement normal ### print smt.gettag('debutdetailcritere'+str(cntcrd))%e ### - Fin de Comportement normal Compatibilité ### - Comportement anormal - Compatibilité print smt.gettag('debutdetailcritere'+str(cntcrd))%e ### - Fin de Comportement anormal - Compatibilité qqchose = 1 print smt.gettag('debutdetailmodalitedesc'+str(cntcrd))%e smt.printtag('findetailmodalitedesc'+str(cntcrd)) e = leidb.fetchsql() if qqchose == 1: smt.printtag('findetailcriteredesc'+str(cntcrd)) smt.printtag('fincriteredesc'+str(cntcrd)) cntcrd = cntcrd+1 #leidb.endsql() if t=='hor': #leidb = SQLWeb.SQLWeb(parametre.machine,parametre.base) leselect = 'select leinethoraires.produit, format([leinethoraires].[du],'dd/mm/yy') as du, format([leinethoraires].[au],'dd/mm/yy') as au, leinethoraires.nomproduit ' lefrom = ' from leinethoraires ' lewhere = ' where produit = %(produit)s '%qs req = leselect + lefrom + lewhere #req_hor = string.lower(req_hor) leidb.selectsql(req) e = leidb.fetchsql() qstr = qs.copy() if e: smt.printtag('debuthoraire') while e: #for i in e.keys(): # if e[i]=='' or e[i]==None: # e[i]=' ' qstr.update(e) print smt.gettag('debutdetailhoraire')%qstr e = leidb.fetchsql() smt.printtag('findetailhoraire') smt.printtag('finhoraire') else: if smt.tags.has_key('debutnoreponsehoraire'): smt.printtag('debutnoreponsehoraire') smt.printtag('finnoreponsehoraire') #leidb.endsql() if t=='prest2' or t=='prest': #leidb = SQLWeb.SQLWeb(parametre.machine,parametre.base) req = "select leinetprestataire.*, leinetproduits.produit" req = req + " from leinetprestataire inner join leinetproduits on leinetprestataire.prestataire = leinetproduits.prestataire" req = req + " where (((leinetproduits.produit)=%(produit)s))" %qs #req_prest = string.lower(req_prest) leidb.selectsql(req) e = leidb.fetchsql() if e: qstr = qs.copy() ##for i in e.keys(): # if e[i]=='' or e[i]==None: # e[i]=' ' if e['dpt']==None: e['dpt']=' ' qstr.update(e) print smt.gettag('debutprestataire')%qstr if e.has_key('email'): if e['email'] != ' ' and smt.tags.has_key('debutemailprestataire'): print smt.gettag('debutemailprestataire')%qstr smt.printtag('finemailprestataire') if e.has_key('url'): if e['url'] != ' ' and smt.tags.has_key('debuturlprestataire'): print smt.gettag('debuturlprestataire')%qstr smt.printtag('finurlprestataire') smt.printtag('finprestataire') #leidb.endsql() if t=='v': print smt.gettag('debutparametres')%qs smt.printtag('finparametres') if t=='afcr': #leidb = SQLWeb.SQLWeb(parametre.machine,parametre.base) req = "select distinct leinetsyntheseproduits.critere, leinetsyntheseproduits.modalite, leinetsyntheseproduits.cri, leinetsyntheseproduits.moda " req = req + " from leinetsyntheseproduits " req = req + " where (((leinetsyntheseproduits.critere)=%(critfiltre)s) and ((leinetsyntheseproduits.modalite)=%(modfiltre)s)) "%qs #req_afcr = string.lower(req_afcr) leidb.selectsql(req) e = leidb.fetchsql() if e: #for i in e.keys(): # if e[i]=='' or e[i]==None: # e[i]=' ' print smt.gettag('debutaffichecritmod')%e smt.printtag('finaffichecritmod') else: if smt.tags.has_key('debutnoreponseaffichecritmod'): smt.printtag('debutnoreponseaffichecritmod') smt.printtag('finnoreponseaffichecritmod') #leidb.endsql() else: print "erreur : il faut donner au squelette (.sk) les paramètres à afficher.
par exemple un paramètre boucle=

" smt.printtag('end') leidb.endsql() sys.exit() smt.printtag('end') leidb.endsql() return 1