-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.php
103 lines (88 loc) · 3.19 KB
/
functions.php
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
<?php
require __DIR__."/vendor/autoload.php" ;
use Dompdf\Dompdf;
use Dompdf\Options;
function display_data($data){
if(isset($_POST['Envoyer'])){
if(isset($data))
echo" ".$data;
}
}
function display_module($data){
if(isset($_POST['Envoyer'])){
if(!empty($data)) {
foreach($data as $value){
return $value." ";
}
}
}
}
function store_txt(){
if($_SERVER['REQUEST_METHOD']=="POST"){
if(isset($_POST['Envoyer'])){
$fp=fopen("cv_file.txt","w");
fwrite($fp,
"-> Nom: " .$_POST['nom'].
"\n-> prenom: " .$_POST['prenom'].
"\n-> age: " .$_POST['age'].
"\n-> numero de telephone: " .$_POST['tele'].
"\n-> Email: " .$_POST['email'].
"\n-> vous etes en: ".$_POST['filiere'].
"\n-> annee: ".$_POST['annee'].
"\n-> modules :".display_module($_POST['mod']).
"\n-> nombre de projets: ".$_POST['project'].
"\n-> remarque: " .$_POST['remarque'].
"\n");
fclose($fp);}
}
}
function generate_cv(){
if(isset($_POST['download'])) {
$nom =$_POST['nom'];
$prenom =$_POST['prenom'];
$age =$_POST['age'];
$tel =$_POST['tele'];
$email =$_POST['email'];
$filiere =$_POST['filiere'];
$annee =$_POST['annee'];
$module=$_POST['mod'];
$projet =$_POST['project'];
$description =$_POST['desc'];
$club=$_POST['club'];
$remarque=$_POST['remarque'];
$file = $_FILES["photo"];
if(isset($_FILES['photo'])){
$file=$_FILES['photo'];
$namefile=$file['photo'];
$tmp_name=$file['tmp_name'];
$file_size=$file['size'];
$image_path='uploads/'.$namefile;
move_uploaded_file($tmp_name , $image_path);
}
$html = "<style>";
$html = "p { color: pink }";
$html = "</style>";
$html = '<img src="'.$image_path.'" width=200px height=200px >';
$html .= "<p><b>Nom et Prenom </b>: $nom $prenom </p>" ;
$html .= "<p><b>Age</b>: $age </p>" ;
$html .= "<p><b>Numero </b>: $tel</p>" ;
$html .= "<p><b>Email</b>: $email </p>" ;
$html .= "<p><b>Filiere</b>: $filiere</p>" ;
$html .= "<p><b>Niveau</b>: $annee</p>" ;
$html .= "<p><b>Modules</b>: $module</p>" ;
$html .= "<p><b>Projects</b>: $projet</p>" ;
$html .= "<p><b>Remarque</b>: $remarque</p>" ;
$options = new Options;
$options->setChroot(__DIR__);
$options->setIsRemoteEnabled(true);
$dompdf = new Dompdf($options);
$dompdf->setPaper("A4", "landscape");
$dompdf->loadHtml($html);
$dompdf->render();
$dompdf->addInfo("Title", "CV");
$dompdf->stream("invoice.pdf", ["Attachment" => 0]);
$output = $dompdf->output();
file_put_contents("file.pdf", $output);
}
}
?>