ajout changement de client d'un rdf
This commit is contained in:
@@ -45,6 +45,11 @@ def get_dossier_by_sinistre(request,societe, nosin):
|
||||
results = request.dbsession.execute(query).first()
|
||||
return results
|
||||
|
||||
def get_clients_byName(request, societe, nom):
|
||||
query = "SELECT * FROM clients WHERE societe = '%s' and nom LIKE '%s';" % (societe, nom + '%');
|
||||
results = request.dbsession.execute(query).fetchall()
|
||||
return results
|
||||
|
||||
|
||||
def get_devis_by_no(request,nodossier):
|
||||
societe = nodossier[0:2]
|
||||
@@ -281,10 +286,16 @@ def validate_rapport(request, no_id):
|
||||
query = "UPDATE dem_rdf SET date_relu=CURRENT_DATE WHERE no_id = :no_id"
|
||||
execute_query(request, query, {'no_id': no_id})
|
||||
|
||||
def insert_facture_rdf(request, societe, nochantier, user, ref, date_rapport):
|
||||
def update_rapport_client(request, norapport, nomClient, codeClient):
|
||||
societe = codeClient[0:2]
|
||||
cd_cli = int(codeClient[3:])
|
||||
query = "UPDATE dem_rdf SET CD_CLI = :cd_cli, NOMCLI = :nomClient WHERE no_id = :norapport"
|
||||
execute_query(request, query, {'norapport': norapport, 'cd_cli': cd_cli, 'nomClient': nomClient})
|
||||
|
||||
def insert_facture_rdf(request, societe, nochantier, cd_cli, nomcli, user, ref, date_rapport):
|
||||
# créer une facture vierge à partir du dossier
|
||||
query = "CALL spINS_FACTURE_RDF(:societe, :nochantier, :user, :ref, :date_rapport)"
|
||||
execute_query(request, query, {'societe': societe, 'nochantier': nochantier, 'user': user, 'ref': ref, 'date_rapport': date_rapport})
|
||||
query = "CALL spINS_FACTURE_RDF(:societe, :nochantier, :cd_cli, :nomcli, :user, :ref, :date_rapport)"
|
||||
execute_query(request, query, {'societe': societe, 'nochantier': nochantier, 'cd_cli': cd_cli, 'nomcli': nomcli, 'user': user, 'ref': ref, 'date_rapport': date_rapport})
|
||||
|
||||
def insert_dossier(request, societe, cd_cli, c_nom, c_adr, c_adr2, c_cp, c_ville, c_telp, nosin, c_obs, tx_trav):
|
||||
# créer une dem_devis selon l'email de l'OS
|
||||
|
||||
@@ -7,6 +7,7 @@ def includeme(config):
|
||||
# default
|
||||
config.add_route('home', '/')
|
||||
config.add_route('affiche_message','/affiche_message/{login}')
|
||||
config.add_route('ajax_client', '/ajax_client')
|
||||
config.add_route('ajax_codepostal', '/ajax_codepostal')
|
||||
config.add_route('ajax_lookup', '/ajax_lookup')
|
||||
config.add_route('changer_mdp', '/changer_mdp')
|
||||
@@ -26,6 +27,7 @@ def includeme(config):
|
||||
config.add_route('dossier_selected', '/dossier_selected/{goto}/{date}/{nodossier}')
|
||||
config.add_route('dossier_view', '/dossier_view/{nodossier}')
|
||||
config.add_route('rdf_bill','/rdf_bill/{no_id}')
|
||||
config.add_route('rdf_client','/rdf_client/{no_id}')
|
||||
config.add_route('rdf_edit','/rdf_edit/{nodossier}/{date_inter}')
|
||||
config.add_route('rdf_list','/rdf_list')
|
||||
config.add_route('rdf_rapport','/rdf_rapport/{no_id}')
|
||||
|
||||
@@ -65,7 +65,7 @@
|
||||
<div class="form-group">
|
||||
<label class="col-xs-3 control-label">Nom ou numéro</label>
|
||||
<div class="col-xs-8">
|
||||
<input type="text" class="form-control" id="name" name="name" placeholder="3 caractères minimum" />
|
||||
<input type="text" class="form-control" id="name" name="name" placeholder="4 caractères minimum" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
|
||||
@@ -59,15 +59,13 @@
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-sm-offset-3 col-sm-9">
|
||||
<div class="form-group">
|
||||
<a class="btn btn-default" href="/agenda/${rdv.rdv_debut.strftime('%Y-%m-%d')}">
|
||||
<span class="glyphicon glyphicon-arrow-left"></span> Annuler</a>
|
||||
<button class="btn btn-primary" type="submit" name="form.submitted">
|
||||
<span class="glyphicon glyphicon-ok"></span> Enregistrer</button>
|
||||
<button class="btn btn-danger" type="submit" name="form.deleted"
|
||||
tal:condition="nolig != '0' and logged_in.upper()==rdv.USERMAJ.upper()">
|
||||
<span class="glyphicon glyphicon-remove"></span> Supprimer</button>
|
||||
</div>
|
||||
<a class="btn btn-default" href="/agenda/${rdv.rdv_debut.strftime('%Y-%m-%d')}">
|
||||
<span class="glyphicon glyphicon-arrow-left"></span> Annuler</a>
|
||||
<button class="btn btn-primary" type="submit" name="form.submitted">
|
||||
<span class="glyphicon glyphicon-ok"></span> Enregistrer</button>
|
||||
<button class="btn btn-danger" type="submit" name="form.deleted"
|
||||
tal:condition="nolig != '0' and logged_in.upper()==rdv.USERMAJ.upper()">
|
||||
<span class="glyphicon glyphicon-remove"></span> Supprimer</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -249,7 +249,7 @@
|
||||
<th>Date interv.</th>
|
||||
<th>Date rapport</th>
|
||||
<th>Chantier</th>
|
||||
<th>No sinistre</th>
|
||||
<th>Client</th>
|
||||
<th>Modif le</th>
|
||||
</tr>
|
||||
<tr tal:repeat="rapport rapports">
|
||||
@@ -260,7 +260,7 @@
|
||||
<td tal:condition="rapport.date_rapport">${rapport.date_rapport.strftime('%d-%m-%Y')}</td>
|
||||
<td tal:condition="not rapport.date_rapport"></td>
|
||||
<td>${rapport.C_QUALITE} ${rapport.C_NOM}</td>
|
||||
<td>${rapport.NOSIN}</td>
|
||||
<td>${rapport.NOMCLI}</td>
|
||||
<td>${rapport.modif_le.strftime('%d-%m-%Y')} - ${rapport.auteur_code}</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
91
mondumas/templates/dossier/rdf_client.pt
Normal file
91
mondumas/templates/dossier/rdf_client.pt
Normal file
@@ -0,0 +1,91 @@
|
||||
<metal:block use-macro="main_template">
|
||||
<div metal:fill-slot="content">
|
||||
|
||||
<div tal:condition="message" tal:content="message" class="alert alert-danger" />
|
||||
<br />
|
||||
|
||||
<div class="row">
|
||||
<form id="rdf_client-form" class="form-horizontal" 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-sm-3">N° rapport</label>
|
||||
<div class="col-sm-9">
|
||||
<p class="form-control-static">${rapport.no_id}</p>
|
||||
</div>
|
||||
<label class="control-label col-sm-3">Date d'intervention</label>
|
||||
<div class="col-sm-9">
|
||||
<p class="form-control-static">${rapport.date_inter.strftime('%d-%m-%Y')}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-sm-3">Nom chantier</label>
|
||||
<div class="col-sm-9">
|
||||
<p class="form-control-static text-danger">${rapport.C_QUALITE} ${rapport.C_NOM}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-sm-3">Nom du client actuel</label>
|
||||
<div class="col-sm-9">
|
||||
<p class="form-control-static">${rapport.NOMCLI}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">Nom du nouveau client</label>
|
||||
<div class="col-sm-9">
|
||||
<input type="text" class="form-control" id="name" name="name" placeholder="4 caractères minimum" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="col-sm-offset-3 col-sm-9">
|
||||
<a class="btn btn-default" href="${request.route_url('rdf_view', no_id=norapport)}">
|
||||
<span class="glyphicon glyphicon-arrow-left"></span> Annuler</a>
|
||||
<button class="btn btn-primary" type="submit" name="form.submitted">
|
||||
<span class="glyphicon glyphicon-ok"></span> Enregistrer</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div> <!-- row -->
|
||||
<br />
|
||||
<br />
|
||||
<br />
|
||||
|
||||
</div>
|
||||
<div metal:fill-slot="additional_scripts">
|
||||
<!-- autocomplete plugin -->
|
||||
<link href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css" rel="stylesheet">
|
||||
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$('#rdf_client-form').formValidation({
|
||||
framework: 'bootstrap',
|
||||
excluded: ':disabled',
|
||||
icon: {
|
||||
valid: 'glyphicon glyphicon-ok',
|
||||
invalid: 'glyphicon glyphicon-remove',
|
||||
validating: 'glyphicon glyphicon-refresh'
|
||||
},
|
||||
});
|
||||
$('#name').autocomplete({
|
||||
source: function (request, response) {
|
||||
$.ajax({
|
||||
url:'/ajax_client',
|
||||
dataType: 'json',
|
||||
data: {
|
||||
recherche: 'PL' + request.term,
|
||||
},
|
||||
success: function (data) {
|
||||
response( data );
|
||||
},
|
||||
});
|
||||
},
|
||||
minLength: 4,
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
</metal:block>
|
||||
@@ -18,41 +18,35 @@
|
||||
<label class="control-label">N° dossier</label> : ${nodossier}<br />
|
||||
<label class="control-label">N° rapport</label> : ${norapport}<br />
|
||||
<label class="control-label">Date d'intervention</label> : ${rapport.date_inter.strftime('%d-%m-%Y')}<br />
|
||||
<label class="control-label" for="rapport">Compte-rendu : </label>
|
||||
<label class="radio-inline">
|
||||
<input type="radio" name="rapport" value="Définitif" disabled="disabled"
|
||||
tal:attributes="checked rapport.rapport=='Définitif'">Définitif
|
||||
</label>
|
||||
<label class="radio-inline">
|
||||
<input type="radio" name="rapport" value="Provisoire" disabled="disabled"
|
||||
tal:attributes="checked rapport.rapport=='Provisoire'">Provisoire
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<br />
|
||||
<h4 class="text-center text-primary">ADRESSE d'INTERVENTION</h4>
|
||||
<table class="table table-condensed ">
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
<h4>${rapport.C_QUALITE} ${rapport.C_NOM}</h4>
|
||||
${rapport.C_ADR}<br />
|
||||
<span tal:condition="rapport.C_ADR2">${rapport.C_ADR2}<br /></span>
|
||||
${rapport.C_CP} ${rapport.C_VILLE}<br />
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Assureur : <b>${rapport.NOMCLI}</b><br />
|
||||
No Sinistre : ${rapport.NOSIN}
|
||||
<br />
|
||||
Téléphone : ${rapport.C_TEL1}<br />
|
||||
Mobile: ${rapport.C_TELP}<br />
|
||||
</p>
|
||||
<p tal:condition="pt_name != 'rdf_rapport'">
|
||||
<a href="${request.route_url('rdf_client', no_id=norapport)}"
|
||||
tal:condition="access > 0">[ Changer le client ]</a>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<br />
|
||||
<table class="table table-condensed ">
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
<h4>${rapport.C_QUALITE} ${rapport.C_NOM}</h4>
|
||||
${rapport.C_ADR}<br />
|
||||
<span tal:condition="rapport.C_ADR2">${rapport.C_ADR2}<br /></span>
|
||||
${rapport.C_CP} ${rapport.C_VILLE}<br />
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Assureur : <b>${rapport.NOMCLI}</b><br />
|
||||
No Sinistre : ${rapport.NOSIN}
|
||||
<br />
|
||||
Téléphone : ${rapport.C_TEL1}<br />
|
||||
Mobile: ${rapport.C_TELP}<br />
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<form id="rdf_view-form" action="${url}" method="post"
|
||||
data-fv-framework="bootstrap"
|
||||
@@ -60,7 +54,7 @@
|
||||
data-fv-icon-invalid="glyphicon glyphicon-remove"
|
||||
data-fv-icon-validating="glyphicon glyphicon-refresh">
|
||||
|
||||
<div class="form-group">
|
||||
<div class="form-group">
|
||||
<label class="control-label" for="rapport">Compte-rendu : </label>
|
||||
<label class="radio-inline">
|
||||
<input type="radio" name="rapport" value="Définitif" disabled="disabled"
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
<div class="form-group">
|
||||
<label class="control-label col-sm-3">Dern. modif le</label>
|
||||
<div class="col-sm-9">
|
||||
${suivi.DATEMAJ.strftime('%d-%m-%Y %H:%M')} par ${suivi.USERMAJ}
|
||||
<p class="form-control-static">${suivi.DATEMAJ.strftime('%d-%m-%Y %H:%M')} par ${suivi.USERMAJ}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
|
||||
@@ -44,7 +44,7 @@ def rdv_edit(request):
|
||||
rdv['C_QUALITE'] = ''
|
||||
rdv['C_NOM'] = ''
|
||||
rdv['rdv_debut'] = datetime.today()
|
||||
rdv['COMMENT'] = 'RDV DEVIS'
|
||||
rdv['COMMENT'] = ''
|
||||
rdv['LISTE'] = logged_in
|
||||
rdv['DATEMAJ'] = date.today()
|
||||
rdv['USERMAJ'] = logged_in
|
||||
|
||||
@@ -27,7 +27,8 @@ import json
|
||||
from ..models.default import *
|
||||
from ..models.agenda import *
|
||||
from ..models.dossier import (
|
||||
get_chantiers_byName
|
||||
get_chantiers_byName,
|
||||
get_clients_byName
|
||||
)
|
||||
|
||||
def to_decimal(x):
|
||||
@@ -295,4 +296,19 @@ def ajax_lookup(request):
|
||||
|
||||
return Response(json.dumps(liste))
|
||||
|
||||
@view_config(route_name='ajax_client')
|
||||
def ajax_client(request):
|
||||
recherche = request.GET['recherche']
|
||||
societe = recherche[:2] # 1er car.
|
||||
name = recherche[2:]
|
||||
|
||||
# lire les clients
|
||||
clients = get_clients_byName(request, societe, name)
|
||||
liste=[]
|
||||
for row in clients:
|
||||
d = "%s | %s-%s"% (row.NOM, societe, row.CD_CLI)
|
||||
liste.append(d)
|
||||
|
||||
return Response(json.dumps(liste))
|
||||
|
||||
|
||||
|
||||
@@ -540,6 +540,40 @@ def rdf_list(request):
|
||||
'dt_data': json.dumps(liste),
|
||||
}
|
||||
|
||||
@view_config(route_name='rdf_client', renderer='../templates/dossier/rdf_client.pt', permission='view')
|
||||
def rdf_client(request):
|
||||
logged_in = request.authenticated_userid.upper()
|
||||
norapport = request.matchdict['no_id']
|
||||
message = ''
|
||||
|
||||
# lire code accès du user
|
||||
access = get_userAccess(request, logged_in)
|
||||
if access == 0:
|
||||
request.session.flash("Vous n'avez pas les droits nécessaires pour changer de client.", 'danger')
|
||||
return HTTPFound(location=request.route_url('rdf_view', no_id=norapport))
|
||||
|
||||
url = request.route_url('rdf_client', no_id=norapport)
|
||||
|
||||
# lire le rapport
|
||||
rapport = get_rapport_by_no_id(request, norapport)
|
||||
nodossier = 'PL-' + str(rapport.nochantier)
|
||||
|
||||
if 'form.submitted' in request.params:
|
||||
nomClient = request.params['name'].split(' | ')
|
||||
update_rapport_client(request, norapport, nomClient[0], nomClient[1])
|
||||
request.session.flash("Le client du rapporta été modifié avec succès.", 'success')
|
||||
return HTTPFound(location=request.route_url('dossier_view', nodossier=nodossier))
|
||||
|
||||
|
||||
return {
|
||||
'page_title': "Changer le client du RDF n° %s" % norapport,
|
||||
'url': url,
|
||||
'message': message,
|
||||
'access': access,
|
||||
'norapport': norapport,
|
||||
'rapport': rapport,
|
||||
}
|
||||
|
||||
@view_config(route_name='rdf_view', renderer='../templates/dossier/rdf_view.pt', permission='view')
|
||||
def rdf_view(request):
|
||||
logged_in = request.authenticated_userid.upper()
|
||||
@@ -706,7 +740,7 @@ def rdf_bill(request):
|
||||
if 'form.submitted' in request.params:
|
||||
# lire article à facturer
|
||||
article = request.params['article']
|
||||
insert_facture_rdf(request, 'PL', rapport.nochantier, logged_in, article, rapport.date_inter.strftime('%d-%m-%Y'))
|
||||
insert_facture_rdf(request, 'PL', rapport.nochantier, rapport.CD_CLI, rapport.NOMCLI, logged_in, article, rapport.date_inter.strftime('%d-%m-%Y'))
|
||||
|
||||
request.session.flash("Le rapport a été généré avec succès.", 'success')
|
||||
return HTTPFound(location=request.route_url('dossier_view', nodossier=nodossier))
|
||||
|
||||
Reference in New Issue
Block a user