This commit is contained in:
2021-02-16 14:35:26 +01:00
parent 3915b0e59b
commit 6212692b19
15 changed files with 250 additions and 227 deletions

View File

@@ -126,9 +126,9 @@ def get_docs_attaches(request, nodossier, norapport, origine, filename):
nochantier = int(nodossier[3:])
if filename == '':
query = "SELECT * FROM dossier_attaches WHERE nomrep = 'DOCS_ATTACHES' AND societe = :societe AND nochantier = :nochantier AND nodossier=0 AND origine = :origine ORDER BY cree_le;"
query = "SELECT * FROM dossier_attaches WHERE societe = :societe AND nochantier = :nochantier AND nodossier=0 AND origine = :origine ORDER BY cree_le;"
else:
query = """SELECT * FROM dossier_attaches WHERE nomrep = 'DOCS_ATTACHES' AND societe = :societe AND nochantier = :nochantier
query = """SELECT * FROM dossier_attaches WHERE societe = :societe AND nochantier = :nochantier
AND nodossier = :norapport AND origine = :origine AND nomfichier = :filename ORDER BY cree_le;"""
results = request.dbsession.execute(query, {'societe': societe, 'nochantier': nochantier,
'norapport': norapport, 'origine': origine, 'filename': filename}).fetchall()
@@ -137,7 +137,7 @@ def get_docs_attaches(request, nodossier, norapport, origine, filename):
def get_photos(request, nodossier, norapport, origine):
societe = nodossier[0:2]
nochantier = int(nodossier[3:])
query = """SELECT * FROM dossier_attaches WHERE nomrep = 'DOCS_ATTACHES' AND societe = :societe AND nochantier = :nochantier
query = """SELECT * FROM dossier_attaches WHERE societe = :societe AND nochantier = :nochantier
AND nodossier = :norapport AND origine = :origine AND UPPER(RIGHT(nomfichier,3)) <> 'PDF' ORDER BY cree_le;"""
results = request.dbsession.execute(query, {'societe': societe, 'nochantier': nochantier, 'norapport': norapport, 'origine': origine}).fetchall()
return results
@@ -153,7 +153,7 @@ def delete_photos(request, nodossier, norapport, origine, nomfic):
if os.path.exists(file_path):
os.remove(file_path)
query = "DELETE FROM dossier_attaches WHERE nomrep='DOCS_ATTACHES' AND societe=:societe AND nochantier=:nochantier AND nodossier=:norapport AND origine=:origine AND nomfichier=:nomfic;"
query = "DELETE FROM dossier_attaches WHERE societe=:societe AND nochantier=:nochantier AND nodossier=:norapport AND origine=:origine AND nomfichier=:nomfic;"
execute_query(request, query, {'societe': societe, 'nochantier': nochantier, 'norapport': norapport, 'origine': origine, 'nomfic': nomfic})
def rename_photos(request, nodossier, norapport, origine, nomfic, new_nomfic):
@@ -162,7 +162,7 @@ def rename_photos(request, nodossier, norapport, origine, nomfic, new_nomfic):
query = """
UPDATE dossier_attaches SET nomfichier = :new_nomfic
WHERE nomrep='DOCS_ATTACHES' AND societe=:societe AND nochantier=:nochantier AND nodossier=:norapport AND origine=:origine AND nomfichier=:nomfic;
WHERE societe=:societe AND nochantier=:nochantier AND nodossier=:norapport AND origine=:origine AND nomfichier=:nomfic;
"""
execute_query(request, query, {'societe': societe, 'nochantier': nochantier, 'norapport': norapport,
'origine': origine, 'nomfic': nomfic, 'new_nomfic': new_nomfic})
@@ -204,8 +204,8 @@ def insert_dossier_attaches(request, nodossier, norapport, origine, filename, fi
if item:
return
# enregistrer dans la table dossier_attaches
query = """INSERT INTO dossier_attaches (nomrep, societe, nochantier, nodossier, origine, nomfichier, taillefichier, cree_le, usermaj)
VALUES('DOCS_ATTACHES',:societe,:nochantier,:norapport,:origine,:filename,:filesize,NOW(),:user);"""
query = """INSERT INTO dossier_attaches (societe, nochantier, nodossier, origine, nomfichier, taillefichier, cree_le, usermaj)
VALUES(:societe,:nochantier,:norapport,:origine,:filename,:filesize,NOW(),:user);"""
execute_query(request, query, {'societe': societe, 'nochantier': nochantier, 'norapport': norapport,
'origine': origine, 'filename': filename, 'filesize': filesize, 'user': user})