<table>
<tbody>
<tr>
+ <th>{{ form.implantation.label_tag }} :<br />{{ form.implantation.errors }}</th>
+ <td>{{ form.implantation }}</td>
+ </tr>
+ <tr>
<th>{{ form.poste.label_tag }} :<br />{{ form.poste.errors }}</th>
<td>{{ form.poste }}</td>
</tr>
<td>{{ form.type_poste }}</td>
</tr>
<tr>
- <th>{{ form.implantation.label_tag }} :<br />{{ form.implantation.errors }}</th>
- <td>{{ form.implantation }}</td>
- </tr>
- <tr>
<th>{{ form.service.label_tag }} :<br />{{ form.service.errors }}</th>
<td>{{ form.service }}</td>
</tr>
url(r'^salaire/(.*)/(.*)/(.*)$', 'salaire', name='salaire'),
url(r'^coefficient$', 'coefficient', name='dae_coefficient'),
url(r'^liste_valeurs_point$', 'liste_valeurs_point', name='liste_valeurs_point'),
+ url(r'^liste_postes$', 'liste_postes', name='liste_postes'),
url(r'^devise$', 'devise', name='dae_devise'),
url(r'^devise/code$', 'devise_code', name='dae_devise_code'),
url(r'^add-remun$', 'add_remun', name='add_remun'),
data.append({'id' : o.id, 'label' : o.__unicode__(), })
return HttpResponse(dumps(data))
+def liste_postes(request):
+ """ Appel AJAX :
+ input : implantation_id
+ output : JSON liste de valeur point
+ """
+ method = request.method
+ params = getattr(request, method, [])
+ data = []
+
+ # Voir le code de _poste_choices dans forms.py
+ dae_ = dae.Poste.objects.filter(actif=True, id_rh__isnull=True)
+ copies = dae.Poste.objects.exclude(id_rh__isnull=True)
+ rh_postes_actifs = rh.Poste.objects.filter(actif=True)
+
+ if 'implantation_id' in params and params.get('implantation_id') is not u"":
+ implantation_id = params.get('implantation_id')
+ dae_ = dae_.filter(implantation__id=implantation_id)
+ copies = copies.filter(implantation__id=implantation_id)
+ rh_postes_actifs = rh_postes_actifs.filter(implantation__id=implantation_id)
+
+ id_copies = [p.id_rh_id for p in copies.all()]
+ rhv1 = rh_postes_actifs.exclude(id__in=id_copies)
+ rhv1 = rhv1.select_related(depth=1)
+ data = [('', 'Nouveau poste')] + \
+ sorted([('dae-%s' % p.id, unicode(p)) for p in dae_ | copies] +
+ [('rh-%s' % p.id, unicode(p)) for p in rhv1],
+ key=lambda t: t[1])
+ return HttpResponse(dumps(data))
+
def devise(request):
""" Appel AJAX :
input : valeur_point
* POSTE
*******************************************************************************/
+/* filter les postes en fonction de l'implantation choisie */
+function charger_postes(implantation_id) {
+ var params = {'implantation_id' : implantation_id};
+ var chargement_p = $.getJSON('/dae/liste_postes', params);
+ chargement_p.success(function(data) {
+ var items = [];
+
+ var options = "";
+ $.each(data, function(index) {
+ options += '<option value="' + data[index][0] + '">' + data[index][1] + '</option>';
+ });
+
+ $("#id_poste").html(options);
+ });
+}
/* Construction dynamique des valeurs de point en fonction de l'implantation choisie */
function charger_valeurs_point(implantation_id) {
var implantation_id = $("#id_implantation").val();
$("#id_implantation").change(function() {
var implantation_id = this.value;
+ charger_postes(implantation_id);
charger_valeurs_point(implantation_id);
});