Voilà actuellement je réalise une application pour mon stage et je dois la faire avec le fraamework CodeIgniter. Le problème avec la fonction suivante elle ne me renvoie pas là où il faut

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
function modif_fiche($id = -1)
	{
		
		// Si l'id n'est pas renseigné, on revient
		if($id == -1)
		{
			header("Location: ".site_url("depart"));
			return;
		}
		if(element("submit", $_POST, "") == "Reinitialiser")
		{
			header("Location: ".site_url("depart"));
			return;
		}
		$this->load->library('validation');
		$this->page['titre'] = "Modification fiche personnelle";
		//$this->page['header'][]['ligne'] = '<script type="text/javascript" src="'.base_url().'web/js/ajax.js"></script>';

		// On recharge la page formulaire.


		// Règles de validation
		$rules['bureau']	= "required|integer";
		$rules['adresse']	= "max_length[100]";
		$rules['telephone_perso'] = "max_length[50]";
		$rules['telephone_portable'] = "max_length[50]";
		$rules['telephone_imft'] = "numeric|max_length[4]";
		$rules['appartenance'] = "required";
		$rules['fonction'] = "required";
		$rules['statut'] = "required";
		$rules['date_depart'] = "required";
		$this->validation->set_rules($rules);

		// Nom des champs pour les messages d'erreur
		$fields['bureau']	= 'bureau';
		$fields['adresse']	= 'adresse personnelle';
		$fields['telephone_perso']	= 'téléphone personnel';
		$fields['telephone_portable']	= 'téléphone portable';
		$fields['telephone_imft']	= 'téléphone de bureau';
		$fields['appartenance']		= 'appartenance';
		$fields['fonction']	= "fonction";
		$fields['statut']	= "statut";
		$fields['date_depart']	= "date départ";
		$this->validation->set_fields($fields);

		// Entre quoi on mettra les erreurs
		$this->validation->set_error_delimiters('<div class="boite_erreur">', '</div>');

		// Si les données sont valides
		$this->data['message'] = "";
		$modification = false;
		if ($this->validation->run())
		{
			$modification = true;

			// On modifie les informations
			$this->db->query("INSERT INTO personnel_prolongation VALUES ('".$id."','".$_POST['adresse']."','".$this->chainenull(addslashes($_POST['telephone_perso']))."','".$this->chainenull(addslashes($_POST['telephone_portable']))."','".$this->chainenull(addslashes($_POST['telephone_imft']))."','".$_POST['personnel_fonction']."','".$_POST['personnel_appartenance']."','".$_POST['personnel_statut']."','".$_POST['bureau']."','".datefr_to_dateus($_POST['personnel_date_depart'])."')");

			header("Location: ".site_url("depart/prolonger"));
			return;
			
		}

		// Informations sur le compte
		$query = $this->db->query("SELECT personnel.*, bureau_batiment FROM personnel, bureau WHERE personnel_bureau = bureau_id AND personnel_id = $id");
		$ligne = $query->row_array();
		$this->data = array_merge($this->data, $ligne);

		/*
		 * Valeurs par défaut dans le formulaire
		 */

		// Si il y a eu des modification, ou si c'est le premier chargement du formulaire, on prend depuis la BDD
		if($modification || !isset($_POST['batiment']))
		{

			$query = $this->db->query("select * FROM personnel_prolongation WHERE personnel_id = $id");
			if($query->num_rows() == 0)
			{
			$query = $this->db->query("SELECT personnel.*, bureau_batiment FROM personnel, bureau WHERE personnel_bureau = bureau_id AND personnel_id = $id");
			$ligne = $query->row_array();
			$this->data = array_merge($this->data, $ligne);

			$this->data['valeur_batiment'] = $this->data['bureau_batiment'];
			$this->data['valeur_bureau'] = $this->data['personnel_bureau'];
			$this->data['valeur_adresse'] = $this->data['personnel_adresse'];
			$this->data['valeur_telephone_perso'] = $this->data['personnel_telephone_perso'];
			$this->data['valeur_telephone_portable'] = $this->data['personnel_telephone_portable'];
			$this->data['valeur_telephone_imft'] = $this->data['personnel_telephone_imft'];
			$this->data['valeur_appartenance']= $this->data['personnel_appartenance'];
			$this->data['valeur_fonction']=$this->data['personnel_fonction'];
			$this->data['valeur_statut']=$this->data['personnel_statut'];
			$this->data['valeur_date_depart']=$this->data['personnel_date_depart'];
			}
			else
			{
			$query = $this->db->query("SELECT personnel.*, bureau_batiment FROM personnel_prolongation, bureau WHERE personnel_bureau = bureau_id AND personnel_id = ".$id);
			$ligne = $query->row_array();
			$this->data = array_merge($this->data, $ligne);

			$this->data['valeur_batiment'] = $this->data['bureau_batiment'];
			$this->data['valeur_bureau'] = $this->data['personnel_bureau'];
			$this->data['valeur_adresse'] = $this->data['personnel_adresse'];
			$this->data['valeur_telephone_perso'] = $this->data['personnel_telephone_perso'];
			$this->data['valeur_telephone_portable'] = $this->data['personnel_telephone_portable'];
			$this->data['valeur_telephone_imft'] = $this->data['personnel_telephone_imft'];
			$this->data['valeur_appartenance']= $this->data['personnel_appartenance'];
			$this->data['valeur_fonction']=$this->data['personnel_fonction'];
			$this->data['valeur_statut']=$this->data['personnel_statut'];
			$this->data['valeur_date_depart']=$this->data['personnel_date_depart'];
			}
			
		}

		// Sinon, si le formulaire a déjà été chargé
		else
		{
			$this->data['valeur_batiment'] = $_POST['batiment'];
			$this->data['valeur_bureau'] = $_POST['bureau'];
			$this->data['valeur_adresse'] = $_POST['adresse'];
			$this->data['valeur_telephone_perso'] = $_POST['telephone_perso'];
			$this->data['valeur_telephone_portable'] = $_POST['telephone_portable'];
			$this->data['valeur_telephone_imft'] = $_POST['telephone_imft'];
			$this->data['appartenance_id']= $_POST['personnel_appartenance'];
			$this->data['fonction_id']=$_POST['personnel_fonction'];
			$this->data['statut_id']=$_POST['personnel_statut'];
			$this->data['date_depart']=$_POST['personnel_date_depart'];
		}


		// On selectionne le bureau par défaut
		$this->data['javascript_bureau'] = "<script>
		new Ajax.Updater('blocBureaux', '".site_url("ajax/listebureau")."/".$this->data['valeur_batiment']."/".$this->data['valeur_bureau']."', { method: 'get' });
		</script>";


		// Liste des batiments
		$query = $this->db->query("SELECT * FROM batiment ORDER BY batiment_libelle");
		$i = 0;
		foreach ($query->result() as $row)
		{
			$this->data['liste_batiment'][$i]['batiment_id'] = $row->batiment_id;
			$this->data['liste_batiment'][$i]['batiment_libelle'] = $row->batiment_libelle;
			$this->data['liste_batiment'][$i]['selected'] = ($row->batiment_id == $this->data['valeur_batiment']) ? ' selected="selected"' : '';
			$i++;
		}
		// Liste des appartenances
		$query = $this->db->query("SELECT * FROM appartenance ORDER BY appartenance_libelle");
		$i = 0;
		foreach ($query->result() as $row)
		{
			$this->data['liste_appartenance'][$i]['appartenance_id'] = $row->appartenance_id;
			$this->data['liste_appartenance'][$i]['appartenance_libelle'] = $row->appartenance_libelle;
			$this->data['liste_appartenance'][$i]['selected'] = ($row->appartenance_id == $this->data['valeur_appartenance']) ? ' selected="selected"' : '';
			$i++;
		}
		// Liste des fonctions
		$query = $this->db->query("SELECT * FROM fonction ORDER BY fonction_libelle");
		$i = 0;
		foreach ($query->result() as $row)
		{
			$this->data['liste_fonction'][$i]['fonction_id'] = $row->fonction_id;
			$this->data['liste_fonction'][$i]['fonction_libelle'] = $row->fonction_libelle;
			$this->data['liste_fonction'][$i]['selected'] = ($row->fonction_id == $this->data['valeur_fonction']) ? ' selected="selected"' : '';
			$i++;
		}

		// Liste des statut
		$query = $this->db->query("SELECT * FROM statut ORDER BY statut_libelle");
		$i = 0;
		foreach ($query->result() as $row)
		{
			$this->data['liste_statut'][$i]['statut_id'] = $row->statut_id;
			$this->data['liste_statut'][$i]['statut_libelle'] = $row->statut_libelle;
			$this->data['liste_statut'][$i]['selected'] = ($row->statut_id == $this->data['valeur_statut']) ? ' selected="selected"' : '';
			$i++;
		}
			// On met la page courante dans le gabarit
			$this->Inserer('depart/modif_fiche', $this->data);
	
			// On affiche le gabarit entier.
			$this->Afficher();
	}

lorsque je réinisialise, ou que je valide, l'application me renvoie sur l'URL:
depart/modif_fiche/{id}
hors c'est pas se que j'ai écris dans le code.

De plus je reprend un application déjà existante et j'aimerai savoir a quoi sert $id = -1 dans les paramètres de la fonction, $id je sais pourquoi mais c'ets le -1 qui me pose problème.. Merci d'avance