diff --git a/development.ini b/development.ini index 6234a0d..3640f35 100644 --- a/development.ini +++ b/development.ini @@ -23,7 +23,7 @@ sqlalchemy.url = mysql://phuoc:phuoc!@localhost/bddevfac?charset=utf8 # sqlalchemy.url = mysql://phuoc:phuoc!@192.168.0.31/bddevfac?charset=utf8 mondumas.admin_email = cao.thien-phuoc@orange.fr -mondumas.devfac_url = mondumas:static/DEVFAC/ +mondumas.devfac_url = mondumas:static/DEVFAC/DOCS_ATTACHES/ mondumas.devfac_dir = /DEVFAC14/DOCS_ATTACHES # Mailer configuration diff --git a/mondumas/models/dossier.py b/mondumas/models/dossier.py index 142b202..03dc97a 100644 --- a/mondumas/models/dossier.py +++ b/mondumas/models/dossier.py @@ -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}) diff --git a/mondumas/models/parametres.py b/mondumas/models/parametres.py index 6f30205..abed1c0 100644 --- a/mondumas/models/parametres.py +++ b/mondumas/models/parametres.py @@ -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): diff --git a/mondumas/models/utils.py b/mondumas/models/utils.py index e53e37b..353d957 100644 --- a/mondumas/models/utils.py +++ b/mondumas/models/utils.py @@ -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}) + diff --git a/mondumas/routes.py b/mondumas/routes.py index 5e7dad8..d6f358c 100644 --- a/mondumas/routes.py +++ b/mondumas/routes.py @@ -58,7 +58,7 @@ def includeme(config): config.add_route('emails_msg', '/emails_msg/{nolig}') config.add_route('expert_edit', '/expert_edit/{code_cab}/{code_exp}') config.add_route('infrastructure', '/infrastructure') - config.add_route('orphans_de', '/orphans_de/{societe}') + config.add_route('stats_dd', '/stats_dd/{societe}') config.add_route('rappels_rdv', '/rappels_rdv') config.add_route('rdf_cause_edit', '/rdf_cause_edit/{code}') config.add_route('rdf_causes', '/rdf_causes') @@ -71,3 +71,4 @@ def includeme(config): # utils config.add_route('batch_nuit', '/batch_nuit/{param}') + config.add_route('batch_test', '/batch_test/{param}') diff --git a/mondumas/templates/dossier/dossier_lookup.pt b/mondumas/templates/dossier/dossier_lookup.pt index bcff91d..73588c2 100644 --- a/mondumas/templates/dossier/dossier_lookup.pt +++ b/mondumas/templates/dossier/dossier_lookup.pt @@ -70,7 +70,7 @@ $.fn.dataTable.moment('DD-MM-YYYY'); $('#dossiers_list').DataTable({ data: dataSet, - pageLength: 50, + pageLength: 100, bLengthChange: false, language: { url: 'https://cdn.datatables.net/plug-ins/1.10.16/i18n/French.json' @@ -89,10 +89,13 @@ if ( data[6] == "Humidité" ) { $('td', row).eq(6).css('background-color', 'Crimson').css('color', 'white'); } - if ( data[6] == "En-cours" ) { + if ( data[6] == "Devis" || data[6] == "Commandé") { $('td', row).eq(6).css('background-color', 'Orange'); } - if ( data[6] == "Terminé" ) { + if ( data[6] == "Facturé") { + $('td', row).eq(6).css('background-color', 'LightBlue'); + } + if ( data[6] == "Réglée" || data[6] == "Régl part.") { $('td', row).eq(6).css('background-color', 'LightGreen'); } }, diff --git a/mondumas/templates/dossier/dossier_view.pt b/mondumas/templates/dossier/dossier_view.pt index 1c0ae82..11cf108 100644 --- a/mondumas/templates/dossier/dossier_view.pt +++ b/mondumas/templates/dossier/dossier_view.pt @@ -238,9 +238,9 @@
-
-
diff --git a/mondumas/templates/parametres/orphans_de.pt b/mondumas/templates/parametres/orphans_de.pt
deleted file mode 100644
index b20b3c3..0000000
--- a/mondumas/templates/parametres/orphans_de.pt
+++ /dev/null
@@ -1,156 +0,0 @@
-
-
-
-
-
- CHANTIER
-
- ${devis.C_QUALITE} ${devis.C_NOM}
- ${devis.C_ADR}
- ${devis.C_ADR2}
- ${devis.C_CP} ${devis.C_VILLE}
-
-
-
- Police
-
- Sinistre
-
- ${devis.NOPOL}
-
- ${devis.NOSIN}
-
-
-
-
-
-
- CLIENT
- NO DEVIS
- DATE
-
-
- ${devis.NOMCLI}
- ${devis.NO_ID}
- ${devis.DATE.strftime('%d-%m-%Y')}
-
-
-
-
-
-
-
- Numéro
- Date
- Client
- Chantier
- Montant
- Sinistre
- Ch.
-
-
-
| Année | +A traiter | +Devis | +Commandé | +Facturé | +Régl part. | +Réglée | +Total | +
|---|