Modifier Le Contrat


[insert_php]

try {
$bdd = new PDO(‘mysql:host=abassurcfxab.mysql.db;dbname=abassurcfxab;charset=utf8’, ‘abassurcfxab’, ‘TYm77GFPSzzg’);

} catch (PDOException $e) {

echo ‘‘;
die();
}
$id=$_GET[‘id’];
$user_ID = get_current_user_id();

$reponse = $bdd->query(‘SELECT * FROM wp_contrats WHERE ID = ‘.$id);
$donnees = $reponse->fetch();
[/insert_php]

Modifier un contrat









[insert_php]
// On commence par récupérer les champs
if(isset($_POST[‘modifier’]))
{
// Creates the Variables needed to upload the file

$UploadName = $_FILES[‘UploadFileField’][‘name’];
$UploadName = mt_rand(100000, 999999).$UploadName;
$UploadTmp = $_FILES[‘UploadFileField’][‘tmp_name’];
$UploadType = $_FILES[‘UploadFileField’][‘type’];
$FileSize = $_FILES[‘UploadFileField’][‘size’];

// Removes Unwanted Spaces and characters from the files names of the files being uploaded

$UploadName = preg_replace(« #[^a-z0-9.]#i », «  », $UploadName);

// Upload File Size Limit

if(($FileSize > 1250000)){

die(« Error – File to Big »);

}

// Checks a File has been Selected and Uploads them into a Directory on your Server

if(!$UploadTmp){
die(« Aucun fichier sélectionné, veuillez télécharger à nouveau »);
}
else if ( $UploadType != « application/pdf ») {

die( « L’extension de fichier n’est pas de type PDF.!! »);
}else{
move_uploaded_file($UploadTmp, « Upload_contrat/$UploadName »);
}

if(isset($_POST[‘contrat_description’])) $contrat_description=$_POST[‘contrat_description’];
else $contrat_description= » »;

if(isset($_POST[‘contrat_status’])) $contrat_status=$_POST[‘contrat_status’];
else $facture_status= » »;

$idCci = $_GET[‘id’];
$date=date(« Y-m-d H:i:s »);
$sql = ‘UPDATE wp_contrats SET contrat_description = :contrat_description, contrat_status = :contrat_status ,contrat_url = :UploadFileField , date_modif = :date WHERE ID = ‘.$id ;

$stmt = $bdd->prepare($sql);
$stmt->bindParam(‘:contrat_description’, $contrat_description, PDO::PARAM_STR);
$stmt->bindParam(‘:contrat_status’, $contrat_status, PDO::PARAM_STR);
$stmt->bindParam(‘:UploadFileField’, $UploadName, PDO::PARAM_STR);
$stmt->bindParam(‘date’, $date, PDO::PARAM_STR);
$stmt->execute();

if($stmt)
{
//echo ‘‘;
// Redirection de l’admin vers la page de consultation
header(‘Location: http://espace.ab-assur.com/consulter-les-contrats_client/?id=’.$donnees[‘ID_user’]);
exit();

}
else {
echo ‘‘;
}
}[/insert_php]