stats
This commit is contained in:
@@ -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})
|
||||
|
||||
|
||||
@@ -32,10 +32,17 @@ def get_rappels_rdv(request):
|
||||
results = request.dbsession.execute(query, {})
|
||||
return results.fetchall()
|
||||
|
||||
def get_orphans_DE(request, societe):
|
||||
def get_stats_dd(request, societe):
|
||||
|
||||
query = "SELECT * FROM devis WHERE societe = '%s' AND nochantier = 0 ORDER BY date desc LIMIT 50 ;" % (societe)
|
||||
results = request.dbsession.execute(query).first()
|
||||
query = """SELECT societe, year(date) as Annee, COUNT(*) as Total,
|
||||
SUM(IF(status = '', 1, 0)) AS Created,
|
||||
SUM(IF(status = 'Devis', 1, 0)) AS Devis,
|
||||
SUM(IF(status = 'Commandé', 1, 0)) AS Commande,
|
||||
SUM(IF(status = 'Facturé', 1, 0)) AS Facture,
|
||||
SUM(IF(status = 'Régl part.', 1, 0)) AS ReglePart,
|
||||
SUM(IF(status = 'Réglée', 1, 0)) AS Regle
|
||||
FROM dem_devis where societe=:societe group by societe, year(date);"""
|
||||
results = request.dbsession.execute(query, {'societe': societe}).fetchall()
|
||||
return results
|
||||
|
||||
def get_dossiers_byChantier(request, societe, name):
|
||||
|
||||
@@ -61,3 +61,31 @@ def get_societes(request, societe):
|
||||
query = "SELECT * FROM p_societe WHERE societe = :societe;"
|
||||
results = request.dbsession.execute(query, {'societe': societe}).first()
|
||||
return results
|
||||
|
||||
def chantierExiste(request,societe, no_id):
|
||||
query = "SELECT no_id FROM dem_devis WHERE societe = :societe and no_id = :no_id;"
|
||||
results = request.dbsession.execute(query, {'societe': societe, 'no_id': no_id}).first()
|
||||
if results:
|
||||
return len(results) > 0
|
||||
else:
|
||||
return False
|
||||
|
||||
def get_all_chantiers(request,societe):
|
||||
query = "SELECT * FROM dem_devis WHERE societe = :societe;"
|
||||
results = request.dbsession.execute(query, {'societe': societe}).fetchall()
|
||||
return results
|
||||
|
||||
def get_last_facture(request, societe, nochantier):
|
||||
query = "SELECT * FROM facture WHERE societe = :societe AND nochantier = :nochantier order by date DESC LIMIT 1;"
|
||||
results = request.dbsession.execute(query, {'societe': societe, 'nochantier': nochantier}).first()
|
||||
return results
|
||||
|
||||
def get_last_devis(request, societe, nochantier):
|
||||
query = "SELECT * FROM devis WHERE societe = :societe AND nochantier = :nochantier order by date DESC LIMIT 1;"
|
||||
results = request.dbsession.execute(query, {'societe': societe, 'nochantier': nochantier}).first()
|
||||
return results
|
||||
|
||||
def update_chantier_status(request, societe, no_id, status):
|
||||
query = "UPDATE dem_devis SET status = :status, DATEMAJ = DATEMAJ WHERE societe = :societe AND no_id = :no_id AND status <> :status;"
|
||||
execute_query(request, query, {'societe': societe, 'no_id': no_id, 'status': status})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user