$(document).ready(function() {
- $(".selectlist input[type=text]").change(function() {
- var filtre = $(this).val();
- var choix = $(this).parent().find("option");
- choix.show();
- choix.each(function(idx) {
- if ($(this).html().indexOf(filtre) == -1) $(this).hide();
- });
- });
+ $(".selectlist input[type=text]").change(function() {
+ var filtre = $(this).val();
+ var choix = $(this).parent().find("option");
+ choix.show();
+ choix.each(function(idx) {
+ if ($(this).html().indexOf(filtre) == -1) $(this).hide();
});
+ });
+
+ // Set initial value.
+ var current_id_filter = $('#get_post_by_id').val().replace(' ', '');
+
+ $('#get_post_by_id').keyup(function(e){
+
+ // Get current value.
+ var id_filter = $('#get_post_by_id').val().replace(' ', '');
+
+ // If value has changed and is >= 1 in length, then fais-le.
+ if (id_filter.length >= 1 && current_id_filter != id_filter) {
+
+ // Reset initial value.
+ current_id_filter = id_filter;
+
+ var found = false;
+ $('#id_postes_rh').children('option').each(function(i, poste_op){
+ var poste_op = $(poste_op);
+ var tmp_val = 'rh-' + id_filter;
+ // console.log('searching ' + tmp_val + $(poste).attr('value'));
+ if (tmp_val == poste_op.attr('value')) {
+ found = true
+ $('#id_postes_rh').val(tmp_val);
+ return false;
+ }
+ });
+ // Si on a rien trouvé, reset à la valeur nulle.
+ if (!found) {
+ $('#id_postes_rh').val('');
+ }
+ }
+ });
+});
+
# -*- encoding: utf-8 -*-
+import datetime
from django import forms
from django.core.urlresolvers import reverse
from django.forms.models import BaseInlineFormSet
def _poste_rh_choices(self, request):
""" Menu déroulant pour les postes."""
postes_dae = dae.Poste.objects.exclude(etat__in=(POSTE_ETAT_FINALISE, ))
+ today = datetime.date.today()
id_poste_dae_commences = [p.id_rh_id for p in postes_dae if p.id_rh is not None]
postes_rh = rh.Poste.objects.ma_region_ou_service(request.user) \
.exclude(id__in=id_poste_dae_commences) \
+ .filter(Q(date_debut__lte=today) &
+ (Q(date_fin__gte=today) |
+ Q(date_fin__isnull=True))
+ ) \
.order_by('implantation', '-date_debut', )
return [('', '----------')] + \
<form action="" method="post" enctype="multipart/form-data">
<ul>
<li>
- <h3>Poste existant, ayant fait l'objet d'une validation dans DAE</h3>
+ <h3>Poste existant dans DAE</h3>
{{ form.non_field_errors }}
<div class="selectlist">
{% if request.user|test_membre_drh %}
<span class="info"> puis appuyer sur TAB</span>
{% endif %}
<div>{{ form.postes_rh }}</div>
+ <input type="text" id="get_post_by_id" />
</div>
<p><input type="submit" value="Créer la DAE" /></p>
</li>