Ajouter 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’];

$reponse = $bdd->query(‘SELECT * FROM wp_users WHERE ID = ‘.$id);
$donnees = $reponse->fetch();
[/insert_php]
[insert_php]
if (!file_exists(Upload)) {
//Créer un dossier ‘Upload/’
mkdir(‘Upload/’, 0777, true);

//Créer un identifiant difficile à deviner
$nom = md5(uniqid(rand(), true));
}
[/insert_php]

Ajouter une facture







.

[insert_php]
// On commence par récupérer les champs
if(isset($_POST[‘inserer’]))
{
// 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[‘user_nicename’])) $user_nicename=$_POST[‘user_nicename’];
else $user_nicename= » »;

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

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

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

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

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

$idCci = $_GET[‘id’];
$montant=$_POST[‘facture_montant’].’.’.$_POST[‘facture_montant2’];
$req = $bdd->prepare(‘INSERT INTO wp_factures(ID_user, user_nicename, user_email,user_registered , facture_description, facture_url, facture_montant,facture_registered) VALUES(:ID_user, :user_nicename, :user_email, :user_registered, :facture_description, :UploadName, :facture_montant, NOW())’);
$req->execute(array(

‘ID_user’ => $idCci,
‘user_nicename’ => $user_nicename,
‘user_email’ => $user_email,
‘user_registered’ => $user_registered,
‘facture_description’ => $facture_description,
‘UploadName’ => $UploadName,
‘facture_montant’ => $montant,
));

if($req)
{
echo ‘‘;

// Redirection de l’admin vers la page de consultation
header(‘Location: http://espace.ab-assur.com/consulter-la-liste-des-clients/’);
exit();

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