-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclassPerteOccaz.php
129 lines (109 loc) · 3.87 KB
/
classPerteOccaz.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
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
<?php
class PerteOccaz {
public $idSortie;
private $montant;
private $motif;
private $datesout;
public $message;
function __construct($montant, $motif, $datesout) {
$this->montant = $montant;
$this->motif = $motif;
$this->datesout = $datesout;
}
function insererSortie() {
include 'connexion.php';
$sql = ("INSERT INTO PerteOccaz (Montant, Commentaire, Dates) values ('".$this->montant."', '".$this->motif."', '".$this->datesout."')");
if(mysqli_query($db, $sql)){
}else{
$this->message = mysqli_error($db);
}
}
function updateSortie() {
include 'connexion.php';
$updC= ("UPDATE `PerteOccaz` SET `Montant` = $this->montant WHERE idPerteOccaz =$this->idSortie");
if(mysqli_query($db,$updC)){echo"";}else{
$this->message = mysqli_error($db);
return;
}
$updC1= ("UPDATE `PerteOccaz` SET `Commentaire` = '".$this->motif."' WHERE idPerteOccaz =$this->idSortie");
if(mysqli_query($db,$updC1)){echo"";}else{
$this->message = mysqli_error($db);
return;
}
$updC3= ("UPDATE `PerteOccaz` SET `Dates` = '".$this->datesout."' WHERE idPerteOccaz =$this->idSortie");
if(mysqli_query($db,$updC3)){echo"";}else{
$this->message = mysqli_error($db);
return;
}
}
function deleteCaisse() {
include 'connexion.php';
$delete = ("DELETE FROM PerteOccaz WHERE idPerteOccaz =$this->idSortie");
if (mysqli_query($db, $delete)){echo"";} else {
$this->message = mysqli_error($db);
return;
}
}
}
$q = $_REQUEST["q"];
$tabC = explode("::", $q);
$autre = '';
if (end($tabC) == 'add') {
if ($q !== "") {
$hint = $q;
$salaire = new PerteOccaz($tabC[0], $tabC[1], $tabC[2]);
$salaire->insererSortie();
$autre = $salaire->message;
if( $salaire->message) {
$hint = $autre;
}
}
$sucess = '<div class="alert alert-success" role="alert">
Insertion fait avec success
</div>';
$error = '<div class="alert alert-danger" role="alert">
Erreur '.$autre.'
</div>';
echo $hint == $autre ? $error : $sucess;
}
if(end($tabC) == 'update') {
$idCaisse = $tabC[3];
if ($q !== "") {
$hint = $q;
$salaire = new PerteOccaz($tabC[0], $tabC[1], $tabC[2]);
$salaire->idSortie = $idCaisse;
$salaire->updateSortie();
$autre = $salaire->message;
if( $salaire->message) {
$hint = $autre;
}
}
$sucess = '<div class="alert alert-success" role="alert">
Modification fait avec success
</div>';
$error = '<div class="alert alert-danger" role="alert">
Erreur '.$autre.'
</div>';
echo $hint == $autre ? $error : $sucess;
}
if(end($tabC) == 'delete') {
$idCaisse = $tabC[4];
if ($q !== "") {
$hint = $q;
$salaire = new PerteOccaz(1, 2, 3);
$salaire->idSortie = $tabC[0];
$salaire->deleteCaisse();
$autre = $salaire->message;
if( $salaire->message) {
$hint = $autre;
}
}
$sucess = '<div class="alert alert-success" role="alert">
Modification fait avec success
</div>';
$error = '<div class="alert alert-danger" role="alert">
Erreur '.$autre.'
</div>';
echo $hint == $autre ? $error : $sucess;
}
?>