From 5197325fe4dd9760cbee7e8b5e7a1d7343816b85 Mon Sep 17 00:00:00 2001 From: Phuoc CAO Date: Tue, 18 Sep 2018 16:32:27 +0200 Subject: [PATCH] ajout chantier_lookup.pt --- mondumas/models/agenda.py | 57 ++++++-------- mondumas/models/default.py | 6 ++ mondumas/routes.py | 1 + mondumas/templates/agenda/dossier_view.pt | 90 +++++++++++++++------ mondumas/templates/chantier_lookup.pt | 95 +++++++++++++++++++++++ mondumas/templates/home.pt | 5 ++ mondumas/views/agenda.py | 4 +- mondumas/views/default.py | 36 +++++++++ 8 files changed, 235 insertions(+), 59 deletions(-) create mode 100644 mondumas/templates/chantier_lookup.pt diff --git a/mondumas/models/agenda.py b/mondumas/models/agenda.py index ec082d4..897bf74 100644 --- a/mondumas/models/agenda.py +++ b/mondumas/models/agenda.py @@ -26,48 +26,37 @@ def get_users_agenda(request): results = request.dbsession.execute(query).fetchall() return results -def get_table(code): - if code == 'DD': - table = 'dem_devis' - elif code == 'OS': - table = 'ordres' - else: - table = 'rdvous' - return table - -def get_table_details(code): - if code == 'DD': - table = 'dem_lig' - elif code == 'OS': - table = 'ordres_lig' - else: - table = 'rdvous_lig' - return table - - def get_dossier_by_no(request,nodossier): societe = nodossier[0:2] - table = get_table(nodossier[3:5]) - no_id = nodossier[6:] + no_id = nodossier[3:] query = """ -SELECT d.*, c.*, a.NOM as nom_cabinet, e.NOM as nom_expert FROM %s d +SELECT d.*, c.*, a.NOM as nom_cabinet, e.NOM as nom_expert FROM dem_devis d INNER JOIN clients c ON d.societe = c.societe and d.cd_cli = c.cd_cli INNER JOIN p_cabinet a ON d.cabinet = a.code INNER JOIN p_experts e ON d.cabinet = e.code_cab and d.expert = e.code_exp -where d.societe = '%s' and d.no_id=%s;""" % (table, societe, no_id); +where d.societe = '%s' and d.no_id=%s;""" % (societe, no_id); results = request.dbsession.execute(query).first() return results def get_dossier_rdv_by_no(request,nodossier, nolig): societe = nodossier[0:2] - table = get_table_details(nodossier[3:5]) - no_id = nodossier[6:] + no_id = nodossier[3:] + if nolig == '0': - query = "SELECT * FROM %s where societe = '%s' and no_id=%s;" % (table, societe, no_id) + query = "SELECT * FROM dem_lig where societe = '%s' and no_id=%s;" % (societe, no_id) results = request.dbsession.execute(query).fetchall() else: - query = "SELECT * FROM %s where societe = '%s' and no_id=%s and nolig=%s;" % (table, societe, no_id, nolig) + query = "SELECT * FROM dem_lig where societe = '%s' and no_id=%s and nolig=%s;" % (societe, no_id, nolig) results = request.dbsession.execute(query).first() + + return results + +def get_documents_byChantier(request,nodossier): + societe = nodossier[0:2] + no_id = nodossier[3:] + + query = "CALL spGET_DOSSIERS_byNumeo('%s',%s);" % (societe, no_id) + results = request.dbsession.execute(query).fetchall() return results def get_rendez_vous(request, itc): @@ -77,7 +66,7 @@ def get_rendez_vous(request, itc): datedeb = d.strftime('%Y-%m-01') # lire les rdv de l'ITC - query = """SELECT CONCAT(l.societe,"-DD-",l.no_id) as nodossier, l.rdv_debut, l.rdv_fin, e.c_nom FROM dem_lig l + query = """SELECT CONCAT(l.societe,"-",l.no_id) as nodossier, l.rdv_debut, l.rdv_fin, e.c_nom FROM dem_lig l INNER JOIN dem_devis e ON l.societe=e.societe AND l.no_id=e.no_id WHERE l.datevi >= :datedeb AND l.liste=:itc ORDER BY l.datevi, l.heurevi """ @@ -86,16 +75,14 @@ def get_rendez_vous(request, itc): def delete_rdv(request, nodossier, nolig): societe = nodossier[0:2] - table = get_table_details(nodossier[3:5]) - no_id = nodossier[6:] + no_id = nodossier[3:] - query = "DELETE FROM %s where societe = '%s' and no_id=%s and nolig=%s;" % (table, societe, no_id, nolig) + query = "DELETE FROM dem_lig where societe = '%s' and no_id=%s and nolig=%s;" % (societe, no_id, nolig) execute_query(request, query, {}) def update_rdv(request, nodossier, nolig, comment, commentvi, date_rdv): societe = nodossier[0:2] - table = get_table_details(nodossier[3:5]) - no_id = nodossier[6:] + no_id = nodossier[3:] # formater les champs ddate = datetime.strptime(date_rdv, '%d-%m-%Y %H:%M') @@ -104,9 +91,9 @@ def update_rdv(request, nodossier, nolig, comment, commentvi, date_rdv): auj = date.today().strftime("%Y-%m-%d") if nolig == '0': - query = "INSERT INTO %s SET societe='%s',no_id=%s,date='%s',datevi='%s',heurevi='%s',comment='%s',commentvi='%s'" % (table, societe, no_id,auj,datevi, heurevi, comment, commentvi) + query = "INSERT INTO dem_devis SET societe='%s',no_id=%s,date='%s',datevi='%s',heurevi='%s',comment='%s',commentvi='%s'" % (societe, no_id,auj,datevi, heurevi, comment, commentvi) else: - query = "UPDATE %s SET datevi='%s', heurevi='%s', comment='%s', commentvi='%s' where societe = '%s' and no_id=%s and nolig=%s;" % (table, datevi, heurevi, comment, commentvi, societe, no_id, nolig) + query = "UPDATE dem_ligs SET datevi='%s', heurevi='%s', comment='%s', commentvi='%s' where societe = '%s' and no_id=%s and nolig=%s;" % (datevi, heurevi, comment, commentvi, societe, no_id, nolig) execute_query(request, query, {}) diff --git a/mondumas/models/default.py b/mondumas/models/default.py index 37cdafb..b50a4f0 100644 --- a/mondumas/models/default.py +++ b/mondumas/models/default.py @@ -81,3 +81,9 @@ def delete_membre(request, cd_uti): query = "DELETE FROM p_users WHERE cd_uti = :cd_uti ;" execute_query(request, query, {'cd_uti': cd_uti}) +def get_chantiers_byName(request, societe, name, tous): + + query = "CALL spGET_CHANTIERS_byName('%s','%s');" % (societe, name) + results = request.dbsession.execute(query).fetchall() + return results + diff --git a/mondumas/routes.py b/mondumas/routes.py index f4322fe..5610f89 100644 --- a/mondumas/routes.py +++ b/mondumas/routes.py @@ -3,6 +3,7 @@ def includeme(config): config.add_route('home', '/') config.add_route('agenda', '/agenda') config.add_route('planning', '/planning') + config.add_route('chantier_lookup', '/chantier_lookup') config.add_route('changer_mdp', '/changer_mdp') config.add_route('dossier_view', '/dossier_view/{nodossier}') config.add_route('rdv_edit','/rdv_edit/{nodossier}/{nolig}') diff --git a/mondumas/templates/agenda/dossier_view.pt b/mondumas/templates/agenda/dossier_view.pt index c6eb274..e99b352 100644 --- a/mondumas/templates/agenda/dossier_view.pt +++ b/mondumas/templates/agenda/dossier_view.pt @@ -82,30 +82,74 @@ -

SUIVI

-

- Nouvelle ligne

+
+ +
+
+

+ +  SUIVI +

+
+
+
+

+ Nouvelle ligne

+ + + + + + + + + + + + + +
DateActionRendez-vousPar
${detail.DATE.strftime('%d/%m/%Y')}${detail.COMMENT} ${detail.COMMENTVI} + + + + ${detail.rdv_debut.strftime('%d/%m/%Y %H:%M')} + avec ${detail.LISTE} + + ${detail.USERMAJ}
+
+
+
+ +
+ +
+
+ + + + + + + + + + + + + + + +
NuméroDateClientMontantStatut
${detail.TYPE}-${detail.numero}${detail.date.strftime('%d-%m/-%Y')}${detail.nomcli}${layout.to_euro(detail.montant)}${detail.status}
+
+
+
+
- - - - - - - - - - - - - -
DateVisiteActionAvec
${detail.DATE.strftime('%d/%m/%Y')} - - - - ${detail.rdv_debut.strftime('%d/%m/%Y %H:%M')} - - ${detail.COMMENT} ${detail.COMMENTVI}${detail.LISTE}
diff --git a/mondumas/templates/chantier_lookup.pt b/mondumas/templates/chantier_lookup.pt new file mode 100644 index 0000000..5e412ea --- /dev/null +++ b/mondumas/templates/chantier_lookup.pt @@ -0,0 +1,95 @@ + +
+ +
+ +
+ +
+ +
+ +
+ +
+
+
+ +
+ +
+
+ +
+
+ + Afficher les chantiers cloturées +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ + + + + + + + + + + + + + + + + + + +
NuméroDateClientChantierMontantSinistreStatut
+ ${societe}-${detail.numero} + ${detail.date.strftime('%d-%m/-%Y')}${detail.nomcli}${detail.chantier}${layout.to_euro(detail.montant)}${detail.nosin}${detail.status}
+
+
+
+
+ + + +
+ diff --git a/mondumas/templates/home.pt b/mondumas/templates/home.pt index 1b2adac..b204d71 100644 --- a/mondumas/templates/home.pt +++ b/mondumas/templates/home.pt @@ -14,6 +14,11 @@

PLANNING

+
diff --git a/mondumas/views/agenda.py b/mondumas/views/agenda.py index 89a53a5..b440776 100644 --- a/mondumas/views/agenda.py +++ b/mondumas/views/agenda.py @@ -85,12 +85,14 @@ def dossier_view(request): return HTTPFound(location=request.route_url("agenda")) # lire tous le suivi du dossier details = get_dossier_rdv_by_no(request, nodossier, '0') - + # lire toutes les dossiers du chantiers + documents = get_documents_byChantier(request, nodossier) return { 'page_title': u"Dossier : %s" % (nodossier), 'nodossier': nodossier, 'dossier': dossier, 'details': details, + 'documents': documents, } diff --git a/mondumas/views/default.py b/mondumas/views/default.py index 4b62b95..1f3b7b7 100644 --- a/mondumas/views/default.py +++ b/mondumas/views/default.py @@ -303,3 +303,39 @@ def user_edit(request): 'access': access, 'message': message, } + +@view_config(route_name='chantier_lookup', renderer='../templates/chantier_lookup.pt', permission='view') +def chantier_lookup(request): + + # recherche chantier + url = request.route_url('chantier_lookup') + + message = u'' + societes = ['PE','ME','PL','PO','CD'] + societe = 'PE' + chantiers = [] + name = u'' + cb_tous = "non" + if 'form.submitted' in request.params: + name = request.params['name'] + societe = request.params['societe'] + # si afficher tous les fiches ? + if 'cb_tous' in request.params: + cb_tous = "oui" + chantiers = get_chantiers_byName(request, societe, name, True) + else: + cb_tous = "non" + chantiers = get_chantiers_byName(request, societe, name, False) + if len(chantiers) == 0: + message = u"Chantier non trouvé : %s" % name + + return { + 'page_title': u"Rechercher un chantier", + 'url': url, + 'message': message, + 'chantiers': chantiers, + 'societes': societes, + 'societe': societe, + 'name': name, + 'cb_tous': cb_tous, + }