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 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365
| <?php
session_start();
/*Connexion BDD*/
include("connexion.php");
//date en France
date_default_timezone_set('Europe/Paris');
?>
<!DOCTYPE html>
<html>
<head> <title>Capitalisation RLF : formulaire de saisie</title>
<script type="text/javascript">
function create_champ(i) {
var i2 = i + 1;
var a = 1;
var b = a - 1;
var c = a;
var d = a + 1;
var e = a + 2;
var f = a + 3;
var g = a + 4;
var h = a + 5;
var j = a + 6;
var k = a + 7;
document.getElementById('leschamps_'+i).innerHTML = '<fieldset><legend>INTERLOCUTEUR ' +i2+ '</legend><div class="row"><section class="col col-6"><label class="input"><i class="icon-append fa fa-user"></i><input type="text" name="nom_pers_['+i+']['+b+']" id="nom_pers" placeholder="Nom "></label></section><section class="col col-6"><label class="input"><i class="icon-append fa fa-user"></i><input type="text" name="nom_pers_['+i+']['+c+']" id="nom_pers" placeholder="Prénom "></label></section></div><section><label class="input"><input type="text" name="nom_pers_['+i+']['+d+']" id="nom_pers" placeholder="Fonction "></label><i></i></section><div class="row"><section class="col col-6"><label class="input"><i class="icon-append fa fa-phone"></i><input type="tel" name="nom_pers_['+i+']['+e+']" class="tel_m" placeholder="Téléphone mobile" onmouseover="myFunction()"></label></section><section class="col col-6"><label class="input"><i class="icon-append fa fa-phone"></i><input type="tel" name="nom_pers_['+i+']['+f+']" class="tel_d" placeholder="Téléphone domicile" onmselect="myFunction()"></label></section></div><div class="row"><section class="col col-6"><label class="input"><i class="icon-append fa fa-phone"></i><input type="tel" name="nom_pers_['+i+']['+g+']" class="tel_p" placeholder="Téléphone bureau" onmouseover="myFunction()"></label></section></div><div class="row"><section class="col col-6"><label class="input"><i class="icon-append fa fa-envelope-o"></i><input type="email" name="nom_pers_['+i+']['+h+']" id="mail_pers" placeholder="Mail"></label></section><section class="col col-6"><label class="input"><i class="icon-append fa fa-phone"></i><input type="tel" name="nom_pers['+i+']['+j+']" class="fax_pers" placeholder="Fax" ></label></section></div><section><label class="label">Description du contact</label><label class="textarea"><i class="icon-append fa fa-comment"></i><textarea rows="4" name="nom_pers_['+i+']['+k+']" id="desc_pers"></textarea></label></section></fieldset>';
document.getElementById('leschamps_'+i).innerHTML += (i <= 10) ? '<br /><span id="leschamps_'+i2+'"><a href="javascript:create_champ('+i2+')">Ajouter un champs</a></span>' : '';
}
</script>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0">
<link rel="stylesheet" href="css/demo.css">
<link type='text/css' href='css/basic.css' rel='stylesheet' media='screen' />
<link rel="stylesheet" href="css/font-awesome.css">
<link rel="stylesheet" href="css/sky-forms-f.css">
<link rel="stylesheet" href="css/sky-forms-red.css">
<!--[if lt IE 9]>
<link rel="stylesheet" href="css/sky-forms-ie8.css">
<![endif]-->
<script src="js/jquery.min.js"></script>
<script src="js/jquery.validate.min.js"></script>
<script src="js/jquery.maskedinput.min.js"></script>
<script src="js/jquery.modal.js"></script>
<script type="text/javascript" src="https://pin.authentification.croix-rouge.fr/forms/js/jquery-ui.min.js"></script>
<script type="text/javascript" src="js/jquery.ui.datepicker-fr.js"></script>
<script type="text/javascript" src="http://api.geonames.org/export/geonamesData.js?username=croixrougecrf"></script>
<script type="text/javascript" src="js/jsr_class.js"></script>
<!--[if lt IE 10]>
<script src="js/jquery.placeholder.min.js"></script>
<![endif]-->
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<script src="js/sky-forms-ie8.js"></script>
<![endif]-->
</head>
<?php
//Lire ou Afficher les données
//1)on se connecte à la BDD
$id_struct=$_SESSION['id_struct'];
//2)On récupère le contenu de la table structure
$reponse1 = $bdd->query("SELECT id_typologie FROM structure WHERE id_struct=$id_struct");
while ($donnees = $reponse1->fetch())
$id_typo=$donnees['id_typologie'];
echo $id_typo;
$reponse = $bdd->query("SELECT typologie FROM typologie WHERE id_typologie=$id_typo");
$reponse2 = $bdd->query("SELECT famille_contact FROM structure WHERE id_struct=$id_struct");
//3) On affiche chaque entrée une à une
while ($donnees = $reponse->fetch()){?>
<?php
$reponse->closeCursor(); // 4) Termine le traitement de la requête
?>
<body class="bg-red" onload="setDefaultCountry();">
<!--Formulaire------------------------------------------->
<div class="body">
<form enctype="multipart/form-data" action="" method="post" id="sky-form" class="sky-form">
<header>Formulaire de saisie de la personne</header>
<!--id struct-->
<fieldset>
<div class="row">
<section class="col col-6">
<label class="input">
<i class="icon-append fa fa-user"></i>
<input type="text" name="id_struct" id="id_struct" VALUE="<?php echo $donnees['typologie']; }?>" disabled="disabled">
</label>
</section>
<!--fAMILLE DE CONTACT-->
<?php while ($donnees = $reponse2->fetch()){ ?>
<section class="col col-6">
<label class="input">
<i class="icon-append fa fa-user"></i>
<input type="text" name="id_struct" id="id_struct" VALUE="<?php echo $donnees['famille_contact']; }?>" disabled="disabled">
</label>
</label>
</section>
</div>
</fieldset>
<!--Fin id_struct-->
<?php
if(empty($_POST['valider']))
{
?>
<fieldset><legend> INTERLOCUTEUR 1 </legend>
<div class="row">
<!--Nom contact 1-->
<section class="col col-6">
<label class="input">
<i class="icon-append fa fa-user"></i>
<input type="text" name="nom_pers_[0][0]" id="nom_pers" placeholder="Nom "/>
</label>
</section>
<!--Fin Nom contact 1-->
<!--PRénom -->
<section class="col col-6">
<label class="input">
<i class="icon-append fa fa-user"></i>
<input type="text" name="nom_pers_[0][1]" id="nom_pers" placeholder="Prénom "/>
</label>
</section>
<!--PRénom-->
</div>
<!--Fonction 1-->
<section>
<label class="input">
<input type="text" name="nom_pers_[0][2]" id="nom_pers" placeholder="Fonction ">
</label>
<i></i>
</section>
<!--Fin Fonction 1-->
<div class="row">
<!--N° Mobile-->
<section class="col col-6">
<label class="input">
<i class="icon-append fa fa-phone"></i>
<input type="tel" name="nom_pers_[0][3]" class="tel_m" placeholder="Téléphone mobile" onmouseover="myFunction()">
</label>
</section>
<!--N° Mobile-->
<!--N° Domicile-->
<section class="col col-6">
<label class="input">
<i class="icon-append fa fa-phone"></i>
<input type="tel" name="nom_pers_[0][4]" class="tel_d" placeholder="Téléphone domicile" onmouseover="myFunction()">
</label>
</section>
<!--N° Domicile-->
</div>
<div class="row">
<!--N° Pro-->
<section class="col col-6">
<label class="input">
<i class="icon-append fa fa-phone"></i>
<input type="tel" name="nom_pers_[0][5]" class="tel_p" placeholder="Téléphone bureau" onmouseover="myFunction()">
</label>
</section>
<!--N° Pro-->
</div>
<div class="row">
<!--Mail-->
<section class="col col-6">
<label class="input">
<i class="icon-append fa fa-envelope-o"></i>
<input type="email" name="nom_pers_[0][6]" id="mail_pers" placeholder="Mail">
</label>
</section>
<!-- Mail-->
<!--Fax-->
<section class="col col-6">
<label class="input">
<i class="icon-append fa fa-phone"></i>
<input type="tel" name="nom_pers_[0][7]" class="fax_pers" placeholder="Fax">
</label>
</section>
<!--Fin Fax-->
</div>
<!--Description-->
<section>
<label class="label">Description du contact</label>
<label class="textarea">
<i class="icon-append fa fa-comment"></i>
<textarea rows="4" name="nom_pers_[0][8]" id="desc_pers"></textarea>
</label>
</section>
<!--Fin Description 1-->
</fieldset>
<span id="leschamps_1"> <a href="javascript:create_champ(1)"> Ajouter un champs </a></span>
<footer>
<button type="submit" value="envoyer" name="valider" class="button">Valider</button>
<!--<a href="rlf2.php" class="button button-primary">Rechercher</a>-->
</footer>
</form>
<?php
}
else
{ $date_ajout = date('Y-m-d H:i:s');
$id_struct=$_SESSION['id_struct'];
//echo 'Voila le résultat du formulaire<br/>';
PRINT_r($_POST).'<br />';
//echo '<br/>et voila le résultat des champs en affichage<br/>';
foreach ($_POST['nom_pers_'] as $v1) {
$nom = $v1[0];
$prenom = $v1[1];
$fonction = $v1[2];
$tel_m = $v1[3];
$tel_d = $v1[4];
$tel_p = $v1[5];
$mail_pers = $v1[6];
$fax_pers = $v1[7];
$desc_pres = $v1[8];
echo $prenom.'<br />';
$bdd->exec("INSERT INTO personne VALUES (null,'$nom','$prenom','$fonction','$tel_m','$tel_d','$tel_p','$mail_pers','$fax_pers','$desc_pres','$date_ajout',NULL,'$id_struct')");
}
}
?>
<script type="text/javascript">
function myFunction()
{
// Masking
$(".tel_m").mask('(33) 9-99-99-99-99', {placeholder:'X'});
$(".tel_d").mask('(33) 9-99-99-99-99', {placeholder:'X'});
$(".tel_p").mask('(33) 9-99-99-99-99', {placeholder:'X'});
$(".fax_pers").mask('(33) 9-99-99-99-99', {placeholder:'X'});
$("#postalcodeInput").mask('99999', {placeholder:'X'});
//$("#postalcodeInput").mask('99999', {placeholder:'X'});
}
// Validation
$("#sky-form").validate(
{
// Règles de validation
rules:
{
nom_contact:
{
required: true
},
prenom:
{
required: true
},
email:
{
required: true,
email: true
},
tel_struct:
{
//digits: true
},
fax_struct:
{
//digits: true
},
tel_m:
{
//digits: true
},
tel_d:
{
//digits: true
},
tel_p:
{
//digits: true
},
fax_pers:
{
//digits: true
},
},
// Messages pour validation
messages:
{
nom_contact:
{
required: 'Saisissez un nom'
},
prenom:
{
required: 'Saisissez un prénom'
},
email:
{
required: 'Entrez une adresse email valide',
email: 'Entrez une adresse email valide'
},
tel_struct:
{
digit: 'Entrez seulement des chiffres'
},
fax_struct:
{
digit: 'Entrez seulement des chiffres'
},
tel_m:
{
digit: 'Entrez seulement des chiffres'
},
tel_d:
{
digit: 'Entrez seulement des chiffres'
},
tel_p:
{
digit: 'Entrez seulement des chiffres'
},
fax_pers:
{
digit: 'Entrez seulement des chiffres'
},
},
/* Ajax form submition
/*submitHandler: function(form)
{
$(form).ajaxSubmit(
{
beforeSend: function()
{
$('#sky-form button[type="submit"]').attr('disabled', true);
},
success: function()
{
$("#sky-form").addClass('submited');
}
});
},*/
// Do not change code below
errorPlacement: function(error, element)
{
error.insertAfter(element.parent());
}
});
</script>
</div>
</body>
</html> |
Partager