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
|
<?php
include('check-session.php');
require_once("Connections/eSDRv2.php");
include('fonction_utile.php');
include_once("client.class.php");
if (isset($_GET['id'])) {
$id = $_GET['id'];
$leClient = new client($id);
}
$erreur = "0";
$resultat = 0;
echo "Je passe bien ici <br />";
echo $_POST['lapin'];
if (isset($_POST['lapin'])) {
echo "_POST['lapin'] passe bien <br />";
}
//si le bouton enregistrer ou valicer est pressé
if ((isset($_POST['enregistrer'])) or (isset($_POST['lapin']))) {
echo "isset traitement save <br />";
//Vérifier si le champs mail est vide
if (empty($_POST['mailClient'])) {
$erreur .= "1";
}
//verifier si la syntaxe du mail saisi est correct
elseif (VerifierAdresseMail($_POST['mailClient']) == false) {
$erreur .= "4";
}
//verifier que le champs nom n'est pas vide
if (empty($_POST['nomClient'])){
$erreur .= "2";
}
if (isset($_POST['enregistrer'])) {
$queryVerifMail = pg_query("SELECT * FROM adddmiin_client WHERE client_emailclient = '".$_POST['mailClient']."'");
if (pg_num_rows($queryVerifMail) > 0) {
$erreur .= "5";
}
}
echo $erreur;
if ($erreur == "0") {
//si il n'y a aucune erreur et que le mail n'est pas déjà présent dans la base de donnée, on insert
echo "erreur == 0s";
$param = NULL;
$newClient = new client($param);
$newClient->setCategClient(mb_strtoupper($_POST['categClient']));
$newClient->setTypeClient(mb_strtoupper($_POST['typeClient']));
$newClient->setPaysClient(mb_strtoupper(traitementChaine($_POST['depClient'])));
$newClient->setCPClient($_POST['cpClient']);
$newClient->setTelUnClient($_POST['telUnClient']);
$newClient->setTelDeuxClient($_POST['telDeuxClient']);
$newClient->setBudgetClient($_POST['budgetClient']);
$newClient->setOrigineClient($_POST['origineClient']);
$newClient->setMailClient(traitementChaine($_POST['mailClient']));
$newClient->setNomClient(mb_strtoupper(traitementChaine($_POST['nomClient'])));
$newClient->setStructureClient(mb_strtoupper(traitementChaine($_POST['structureClient'])));
$newClient->setAdresseClient(mb_strtoupper(traitementChaine($_POST['adresseClient'])));
$newClient->setVilleClient(mb_strtoupper(traitementChaine($_POST['villeClient'])));
$newClient->setCommentaireClient(traitementChaine($_POST['commentaireClient']));
if (isset($_POST['spectNoel'])) $newClient->setSpectRueClient($_POST['spectNoel']);
if (isset($_POST['spectCarna'])) $newClient->setSpectCarnavalClient($_POST['spectCarna']);
if (isset($_POST['spectEte'])) $newClient->setSpectEteClient($_POST['spectEte']);
if (isset($_POST['spectHiver'])) $newClient->setSpectHiverClient($_POST['spectHiver']);
if (isset($_POST['spectRue'])) $newClient->setSpectRueClient($_POST['spectRue']);
if (isset($_POST['spectSalle'])) $newClient->setSpectSalleCLient($_POST['spectSalle']);
if (isset($_POST['invit'])) $newClient->setInvitationClient($_POST['invit']);
if (isset($_POST['newsTB'])) $newClient->setNewsTbClient($_POST['newsTB']);
if (isset($_POST['newsSDR'])) $newClient->setNewsSdrClient($_POST['newsSDR']);
$newClient->setOrigineClient($_SESSION['login']);
$resultat = $newClient->AjouterClient();
if ($resultat == -1) {
//$message = "Le contact ".$newClient->getNomClient()." a bien ete sauvegarde dans la base de donnees";
$leNomClient = $newClient->getNomClient();
//$leNomClient = str_replace("'", "'", $newClient->getNomClient());
}
else {
$message = "Le mail '".$newClient->getMailClient()."' existe deja dans la base de donnees";
header("Location: newficheclient.php?erreur=3");
}
} // fin ajout client
}
function Type() {
$retour="";
$artid = 1;
$genreQuery=pg_query("select * from adddmiin_types order by type_numtype desc") or die('Type ');
while ($row=pg_fetch_array($genreQuery, NULL, PGSQL_ASSOC)) {
$nomGenre = $row['type_libelletype'];
echo "<option value=\"$nomGenre\">$nomGenre</option>";
}
return $retour;
}
function Categ() {
$retour="";
$artid = 1;
$genreQuery=pg_query("select * from adddmiin_categories order by cat_id_cat desc") or die('Genre ');
while ($row=pg_fetch_array($genreQuery, NULL, PGSQL_ASSOC)) {
$nomGenre = $row['cat_libelle_cat'];
echo "<option value=\"$nomGenre\">$nomGenre</option>";
}
return $retour;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Nouveau Client</title>
<link href="style-esdr-ficheclient.css" rel="stylesheet" type="text/css" />
</head>
<body>
<?php
if ($resultat == -1) {
echo "insertion ok";
echo "<script language=\"javascript\">
window.location = 'ficheclient.php?nomclient=".$leNomClient."'
</script>";
}
if (isset($_POST['annuler'])) {
echo "<script> window.close(); </script>";
}
if (strstr($erreur, "1")) {
echo "<script> alert('Le mail du client est obligatoire à la saisi');</script>";
}
if (strstr($erreur, "2")) {
echo "<script> alert('Le nom du client est obligatoire à la saisi');</script>";
}
if (strstr($erreur, "3")) {
echo "<script>alert('Ce mail est deja repertorie dans la base de donnees');</script>";
}
if (strstr($erreur, "4")) {
echo "<script>alert('Ce mail n est pas valide ! Veuillez saisir un mail valide !');</script>";
}
?>
<form method="post" action="newficheclient.php" >
<div id="colonneUne">
<table>
<tr>
<td class="titre">CAT</td>
<td><select name="categClient"><?php Categ() ?></select><?php echo "<a href=\"#\" onclick=\"window.open('categorie.php','categPopUp','menubar=no, status=no, scrollbars=no, menubar=no, width=300, height=350');\">?</a>" ?></td>
</tr>
<tr>
<td class="titre">TYPE</td>
<td><select name="typeClient"><?php Type()?></select> <?php echo "<a href=\"#\" onclick=\"window.open('type.php','TypePopup','menubar=no, status=no, scrollbars=no, menubar=no, width=300, height=600');\">?</a>" ?></td>
</tr>
<tr>
<td class="titre">Pays</td>
<td><input type="text" name="depClient" <?php if (isset($_POST['depClient'])) echo "value='".$_POST['depClient']."'"; ?> /></td>
</tr>
<tr>
<td class="titre">Code Postal</td>
<td><input type="text" name="cpClient" /> <?php //echo "<a href=\"#\" onclick=\"window.open('type.php','TypePopup','menubar=no, status=no, scrollbars=no, menubar=no, width=300, height=600');\">?</a>" ?> </td>
</tr>
<tr>
<td class="titre">Tel1</td>
<td><input type="text" name="telUnClient" <?php if (isset($_POST['telUnClient'])) echo "value='".$_POST['telUnClient']."'"; ?> /></td>
</tr>
<tr>
<td class="titre">Tel2</td>
<td><input type="text" name="telDeuxClient" <?php if (isset($_POST['telDeuxClient'])) echo "value='".$_POST['telDeuxClient']."'"; ?> /></td>
</tr>
<tr>
<td class="titre">Budget</td>
<td><input type="text" name="budgetClient" <?php if (isset($_POST['budgetClient'])) echo "value='".$_POST['budgetClient']."'"; ?> />€</td>
</tr>
<tr>
<td class="titre">Origine</td>
<td><input type="text" name="origineClient" readonly="readonly" /></td>
</tr>
</table>
</div>
<div id="colonneDeux">
<table>
<tr>
<td class="titre">eMail</td>
<td class="info"><input type="text" placeholder="Obligatoire" name="mailClient" <?php if (isset($_POST['mailClient'])) echo "value='".$_POST['mailClient']."'"; ?> /></td>
</tr>
<tr>
<td class="titre">Nom</td>
<td class="info"><input type="text" placeholder="Obligatoire" name="nomClient" <?php if (isset($_POST['nomClient'])) echo "value='".$_POST['nomClient']."'"; ?> /></td>
</tr>
<tr>
<td class="titre">Structure</td>
<td class="info"><input type="text" name="structureClient" <?php if (isset($_POST['structureClient'])) echo "value='".$_POST['structureClient']."'"; ?> /></td>
</tr>
<tr>
<td class="titre">Ville</td>
<td class="info"><input type="text" name="villeClient" <?php if (isset($_POST['villeClient'])) echo "value='".$_POST['villeClient']."'"; ?> /></td>
</tr>
<tr>
<td class="titre">adresse</td>
<td class="info"><input type="text" name="adresseClient" <?php if (isset($_POST['adresseClient'])) echo "value='".$_POST['adresseClient']."'"; ?> /></td>
</tr>
<tr>
<td class="titre">Commentaire</td>
<td><textarea type="textarea" name="commentaireClient" rows="7" cols="18"><?php if (isset($_POST['commentaireClient'])) echo $_POST['commentaireClient']; ?></textarea></td>
</tr>
</table>
</div>
<br />
<div id="caracteristique">
<label for="noel">Noel</label><input id="noel" name="spectNoel" type="checkbox" />
<label for="carnaval">Carnaval</label><input id="carnaval" name="spectCarna" type="checkbox" />
<label for="ete">Été</label><input id="ete" name="spectEte" type="checkbox" />
<label for="hiver">Hiver</label><input id="hiver" name="spectHiver" type="checkbox" />
<label for="rue">Rue</label><input id="rue" name="spectRue" type="checkbox" />
<label for="salle">Salle</label><input id="salle" name="spectSalle" type="checkbox" />
<label for="invit">Invitation</label><input id="invit" name="invit" type="checkbox" />
<label for="newsTB">News TB</label><input id="newsTB" name="newsTB" type="checkbox" />
<label for="newsSDR">News SDR</label><input id="newsSDR" name="newsSDR" type="checkbox" />
</div>
<?php
if (strstr($erreur, "5")) {
echo "<script>
window.open('mailexistant.php?mail=".$_POST['mailClient']."', 'Contact existant', config='height=100, width=1000, toolbar=no, menubar=no, scrollbars=no');
</script>
<h1>Ce mail est déjà renseigné sur un client !</h1>;
";
}
if (isset($_POST['enregistrer']) and $erreur == "05") {
echo "
<input type=\"submit\" id=\"enregistrer\" name=\"lapin\" value=\"Confirmer\" />
<input type=\"submit\" id=\"supprimer\" name=\"annuler\" value=\"Annuler\" />
";
}
else {
echo "<input type=\"submit\" id=\"enregistrer\" name=\"enregistrer\" value=\"Enregistrer\" />";
}
?>
</form>
</body>
</html> |
Partager