ajout chantier_lookup.pt

This commit is contained in:
2018-09-18 16:32:27 +02:00
parent 78657a8d75
commit 5197325fe4
8 changed files with 235 additions and 59 deletions

View File

@@ -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, {})

View File

@@ -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

View File

@@ -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}')

View File

@@ -82,30 +82,74 @@
</div>
</div> <!-- row -->
<h3>SUIVI</h3>
<div class="panel-group" id="accordion">
<!-- PANEL SUIVI -->
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion" href="#panel-suivi">
<span class="glyphicon glyphicon-arrow-down"></span>&nbsp;SUIVI</a>
</h4>
</div>
<div id="panel-suivi" class="panel-collapse collapse">
<div class="panel-body">
<p><a class="btn btn-success" role="button" href="${request.route_url('rdv_edit', nodossier=nodossier, nolig='0')}">
<span class="glyphicon glyphicon-plus"></span> Nouvelle ligne</a></p>
<table class="table table-bordered">
<tr>
<th>Date</th>
<th>Visite</th>
<th>Action</th>
<th class="text-center">Avec</th>
<th>Rendez-vous</th>
<th class="text-center">Par</th>
</tr>
<tr tal:repeat="detail details">
<td>${detail.DATE.strftime('%d/%m/%Y')}</td>
<td>${detail.COMMENT} ${detail.COMMENTVI}</td>
<td>
<span tal:condition="detail.rdv_debut==None"></span>
<span tal:condition="detail.rdv_debut<>None">
<a href="${request.route_url('rdv_edit', nodossier=nodossier, nolig=detail.NOLIG)}">
${detail.rdv_debut.strftime('%d/%m/%Y %H:%M')}</a>
avec ${detail.LISTE}
</span>
</td>
<td>${detail.COMMENT} ${detail.COMMENTVI}</td>
<td class="text-center">${detail.LISTE}</td>
<td class="text-center">${detail.USERMAJ}</td>
</tr>
</table>
</div>
</div>
</div>
<!-- PANEL SUIVI -->
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion" href="#panel-documents">
<span class="glyphicon glyphicon-arrow-down"></span>&nbsp;DEVIS - FACTURES</a>
</h4>
</div>
<div id="panel-documents" class="panel-collapse collapse">
<div class="panel-body">
<table class="table table-bordered">
<tr>
<th>Numéro</th>
<th>Date</th>
<th>Client</th>
<th class="text-right">Montant</th>
<th class="text-center">Statut</th>
</tr>
<tr tal:repeat="detail documents">
<td>${detail.TYPE}-${detail.numero}</td>
<td>${detail.date.strftime('%d-%m/-%Y')}</td>
<td>${detail.nomcli}</td>
<td class="text-right">${layout.to_euro(detail.montant)}</td>
<td class="text-center">${detail.status}</td>
</tr>
</table>
</div>
</div>
</div>
</div>
</div>
</metal:block>

View File

@@ -0,0 +1,95 @@
<metal:block use-macro="main_template">
<div metal:fill-slot="content">
<div class="alert alert-danger" tal:condition="message" tal:content="message" />
<div class="row">
<form id="site-search-form" class="form-horizontal" role="form" action="${url}" method="post"
data-fv-framework="bootstrap"
data-fv-icon-valid="glyphicon glyphicon-ok"
data-fv-icon-invalid="glyphicon glyphicon-remove"
data-fv-icon-validating="glyphicon glyphicon-refresh">
<div class="form-group">
<label class="control-label col-xs-4" for="societe">Societe</label>
<div class="col-xs-3">
<select class="form-control" id="societe" name="societe">
<div tal:repeat="item societes">
<option value="${item}" tal:attributes="selected societe==item and 'selected' or None">${item}</option>
</div>
</select>
</div>
</div>
<div class="form-group">
<label class="col-xs-4 control-label">Nom ou numéro du chantier</label>
<div class="col-xs-8">
<input type="text" class="form-control" name="name" value="${name}"
data-fv-notempty="true"
data-fv-notempty-message="Le nom ou le numéro est obligatoire"
data-fv-stringlength="true"
data-fv-stringlength-min="2"
data-fv-stringlength-max="30"
data-fv-stringlength-message="Le nom ou le numéro doit avoir de 2 à 30 caractères de long" />
</div>
</div>
<!-- case a cocher "Afficher fiches cloturées" -->
<div class="form-group">
<div class="col-xs-offset-4 col-xs-8">
<input type="checkbox" name="cb_tous" value="cb_tous"
tal:attributes="checked cb_tous == 'oui' and 'checked' or None">
Afficher les chantiers cloturées</input>
</div>
</div>
<div class="form-group">
<div class="col-xs-offset-4 col-xs-8">
<button class="btn btn-primary" type="submit" name="form.submitted">
<span class="glyphicon glyphicon-search"></span>&nbsp;Rechercher</button>
</div>
</div>
</form>
</div><!-- row -->
<div class="row">
<div tal:condition="chantiers">
<table class="table table-bordered">
<tr>
<th>Numéro</th>
<th>Date</th>
<th>Client</th>
<th>Chantier</th>
<th class="text-right">Montant</th>
<th>Sinistre</th>
<th class="text-center">Statut</th>
</tr>
<tr tal:repeat="detail chantiers">
<td>
<a href="dossier_view/${societe}-${detail.numero}">${societe}-${detail.numero}<a>
</td>
<td>${detail.date.strftime('%d-%m/-%Y')}</td>
<td>${detail.nomcli}</td>
<td>${detail.chantier}</td>
<td class="text-right">${layout.to_euro(detail.montant)}</td>
<td>${detail.nosin}</td>
<td class="text-center">${detail.status}</td>
</tr>
</table>
</div>
<br />
<br />
</div>
<script>
$(document).ready(function() {
$('#site-search-form').formValidation();
$('form input').on('keypress', function(e) {
return e.which !== 13;
});
});
</script>
</div>
</metal:block>

View File

@@ -14,6 +14,11 @@
<span class="glyphicon glyphicon-calendar logo-small"></span><br />
<h4>PLANNING</h4></a>
</div>
<div class="col-sm-3">
<a href="${request.application_url}/chantier_lookup">
<span class="glyphicon glyphicon-search logo-small"></span>
<h4>RECH. CHANTIER</h4></a>
</div>
</div> <!-- row 1 -->
<br />
<div class="row well" tal:condition="layout.isAdmin">

View File

@@ -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,
}

View File

@@ -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,
}