Modifier une facture


[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_factures WHERE ID = ‘.$id);
$donnees = $reponse->fetch();
[/insert_php]

Modifier une facture









.


[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(« Erreur – Fichier Volumineux »);

}

// 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/$UploadName »);
}

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

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

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

$idCci = $_GET[‘id’];
$date=date(« Y-m-d H:i:s »);
$montant=$_POST[‘facture_montant’].’.’.$_POST[‘facture_montant2’];
$sql = ‘UPDATE wp_factures SET facture_description = :facture_description, facture_status = :facture_status ,facture_montant = :facture_montant ,facture_url = :UploadFileField , date_modif = :date WHERE ID = ‘.$id ;

$stmt = $bdd->prepare($sql);
$stmt->bindParam(‘:facture_description’, $facture_description, PDO::PARAM_STR);
$stmt->bindParam(‘:facture_status’, $facture_status, PDO::PARAM_STR);
$stmt->bindParam(‘:facture_montant’, $montant, 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-factures_client/?id=’.$donnees[‘ID_user’]);
exit();

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