-
Notifications
You must be signed in to change notification settings - Fork 0
/
facture_validate_list.php
180 lines (164 loc) · 13.2 KB
/
facture_validate_list.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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
<?php
require_once('config.php');
require_once('global_functions.php');
$list = $_GET['validlist'];
$type = $_GET['type'];
if(isset($_GET['client'])){
$client = " AND `idclient`='".$_GET['client']."'";
}
if($list){
$output = "<div style='display: inline-block; height:inherit; overflow:auto;margin: 0px auto;'><table><tr><th>Type de Facture</th><th>Client</th><th width=500px>Facture</th><th>PDF</th><th>Dévalidation</th></tr>";
switch($type){
case "cantine":
$output .= getcantinelist($client);
break;
case "etal":
$output .= getetallist($client);
break;
case "amarrage":
$output .= getamarragelist($client);
break;
default:
$output .= getcantinelist($client);
$output .= getetallist($client);
$output .= getamarragelist($client);
break;
}
$output .= "</table></div>";
}else{
$output = "<div style='display: inline-block; height:inherit; overflow:auto;margin: 0px auto;'><table><tr><th>Type de Facture</th><th>Client</th><th width=500px>Devis</th><th>PDF</th><th>Validation/Rejet</th></tr>";
switch($type){
case "cantine":
$output .= getcantinevalidate($client);
break;
case "etal":
$output .= getetalvalidate($client);
break;
case "amarrage":
$output .= getamarragevalidate($client);
break;
default:
$output .= getcantinevalidate($client);
$output .= getetalvalidate($client);
$output .= getamarragevalidate($client);
break;
}
$output .= "</table></div>";
}
print $output;
####################################functions######################################
function getetalvalidate($client){
$mysqli = new mysqli(DBSERVER, DBUSER, DBPWD, DB);
$query = "SELECT * FROM `".DB."`.`factures_etal` INNER JOIN `mandataires` ON `factures_etal`.`idclient` = `mandataires`.`mandataireid` WHERE `factures_etal`.`validation` = '0'$client";
$result = $mysqli->query($query);
while($row = $result->fetch_array(MYSQLI_ASSOC)){
$output .= "<tr><td>place et étal</td><td><a href='mandataires.php?edit=".$row["mandataireid"]."&hideerrors=1'>".$row["mandataireprefix"]." ".$row["mandataireRS"]." / ".htmlentities($row["mandatairenom"])." ".htmlentities($row["mandataireprenom"])."</a></td>".
"<td>Devis ".$row["communeid"]." du ".french_date($row["datefacture"])." montant de ";
$output .= trispace($row["montantfcp"]);
$output .= " FCP (soit ".$row["montanteuro"]."€)</td><td style=\"text-align:center\"><a href='createpdf.php?idfacture=".$row['idfacture']."&type=etal' target='_blank'><img src=\"img/pdf.png\" alt=\"pdf\" class=\"ico\"></a></td>".
"<td style=\"text-align:center\"><a href=\"javascript:validate('etal','".$row["idfacture"]."',true)\">".
"<img src=\"img/checked.png\" alt=\"checked\" height=\"32\" style=\"border:0px\"></a> / <a href=\"javascript:validate('etal','".$row["idfacture"]."',false)\">".
"<img src=\"img/close.png\" alt=\"close\" height=\"32\" style=\"border:0px\"></a></td></tr>";
}
return $output;
}
function getetallist($client){
$mysqli = new mysqli(DBSERVER, DBUSER, DBPWD, DB);
$query = "SELECT * FROM `".DB."`.`factures_etal` INNER JOIN `mandataires` ON `factures_etal`.`idclient` = `mandataires`.`mandataireid` WHERE `factures_etal`.`validation` = '1' AND `acceptation` = '1' AND `reglement` = '0'$client";
$result = $mysqli->query($query);
while($row = $result->fetch_array(MYSQLI_ASSOC)){
if($row["duplicata"]=='0'){$pdf="<img src=\"img/opdf.png\" alt=\"original\" class=\"ico\">";}else{$pdf="<img src=\"img/dpdf.png\" alt=\"duplicata\" class=\"ico\">";}
$type='etal';
$output .= "<tr><td>place et étal</td><td><a href='mandataires.php?edit=".$row["mandataireid"]."&hideerrors=1'>".$row["mandataireprefix"]." ".$row["mandataireRS"]." / ".htmlentities($row["mandatairenom"])." ".htmlentities($row["mandataireprenom"])."</a></td>".
"<td>Facture ".$row["communeid"]." du ".french_date($row["datefacture"])." montant de ";
$output .= trispace($row["montantfcp"]);
$output .= " FCP (soit ".$row["montanteuro"]."€)</td><td><a href='createpdf.php?idfacture=".$row['idfacture']."&type=$type' target='_blank'>$pdf</a></td><td class='center'><a href=\"javascript:devalidate('$type','".$row["idfacture"]."')\"><img src=\"img/close.png\" alt=\"close\" height=\"32\" style=\"border:0px\"></a></td></tr>";
}
return $output;
}
function getamarragevalidate($client){
$mysqli = new mysqli(DBSERVER, DBUSER, DBPWD, DB);
$query = "SELECT * FROM `".DB."`.`factures_amarrage` INNER JOIN `clients` ON `factures_amarrage`.`idclient` = `clients`.`clientid` WHERE `factures_amarrage`.`validation` = '0' AND `factures_amarrage`.`type_client` = 'C'$client";
$result = $mysqli->query($query);
while($row = $result->fetch_array(MYSQLI_ASSOC)){
$type='amarrage';
$output .= "<tr><td>$type<br/>".$row["navire"]."</td><td><a href='clients.php?edit=".$row["clientid"]."&hideerrors=1'>".$row["clientcivilite"]." ".strtoupper(htmlentities($row["clientnom"]))." ".strtoupper(htmlentities($row["clientprenom"]))." ".strtoupper(htmlentities($row["clientprenom2"]))."</a></td>".
"<td>Devis ".$row["communeid"]." du ".french_date($row["datefacture"])." montant de ";
$output .= trispace($row["montantfcp"]);
$output .= " FCP (soit ".$row["montanteuro"]."€)</td><td style=\"text-align:center\"><a href='createpdf.php?idfacture=".$row['idfacture']."&type=$type' target='_blank'><img src=\"img/pdf.png\" alt=\"pdf\" class=\"ico\"></a></td>".
"<td style=\"text-align:center\"><a href=\"javascript:validate('$type','".$row["idfacture"]."',true)\">".
"<img src=\"img/checked.png\" alt=\"checked\" height=\"32\" style=\"border:0px\"></a> / <a href=\"javascript:validate('$type','".$row["idfacture"]."',false)\">".
"<img src=\"img/close.png\" alt=\"close\" height=\"32\" style=\"border:0px\"></a></td></tr>";
}
$query = "SELECT * FROM `".DB."`.`factures_amarrage` INNER JOIN `mandataires` ON `factures_amarrage`.`idclient` = `mandataires`.`mandataireid` WHERE `factures_amarrage`.`validation` = '0' AND `factures_amarrage`.`type_client` = 'M'$client";
$result = $mysqli->query($query);
while($row = $result->fetch_array(MYSQLI_ASSOC)){
$type='amarrage';
$output .= "<tr><td>$type</td><td><a href='mandataires.php?edit=".$row["mandataireid"]."&hideerrors=1'>".$row["mandataireprefix"]." ".$row["mandataireRS"]." ".strtoupper(htmlentities($row["mandatairenom"]))." ".strtoupper(htmlentities($row["mandataireprenom"]))."</a></td>".
"<td>Devis ".$row["communeid"]." du ".french_date($row["datefacture"])." montant de ";
$output .= trispace($row["montantfcp"]);
$output .= " FCP (soit ".$row["montanteuro"]."€)</td><td style=\"text-align:center\"><a href='createpdf.php?idfacture=".$row['idfacture']."&type=$type' target='_blank'><img src=\"img/pdf.png\" alt=\"pdf\" class=\"ico\"></a></td>".
"<td style=\"text-align:center\"><a href=\"javascript:validate('$type','".$row["idfacture"]."',true)\">".
"<img src=\"img/checked.png\" alt=\"checked\" height=\"32\" style=\"border:0px\"></a> / <a href=\"javascript:validate('$type','".$row["idfacture"]."',false)\">".
"<img src=\"img/close.png\" alt=\"close\" height=\"32\" style=\"border:0px\"></a></td></tr>";
}
return $output;
}
function getamarragelist($client){
$mysqli = new mysqli(DBSERVER, DBUSER, DBPWD, DB);
$query = "SELECT * FROM `".DB."`.`factures_amarrage` INNER JOIN `clients` ON `factures_amarrage`.`idclient` = `clients`.`clientid` WHERE `factures_amarrage`.`validation` = '1' AND `acceptation` = '1' AND `reglement` = '0'$client";
$result = $mysqli->query($query);
while($row = $result->fetch_array(MYSQLI_ASSOC)){
if($row["duplicata"]=='0'){$pdf="<img src=\"img/opdf.png\" alt=\"original\" class=\"ico\">";}else{$pdf="<img src=\"img/dpdf.png\" alt=\"duplicata\" class=\"ico\">";}
$type='amarrage';
$output .= "<tr><td>$type<br/>".$row["navire"]."</td><td><a href='clients.php?edit=".$row["clientid"]."&hideerrors=1'>".$row["clientcivilite"]." ".strtoupper(htmlentities($row["clientnom"]))." ".strtoupper(htmlentities($row["clientprenom"]))." ".strtoupper(htmlentities($row["clientprenom2"]))."</a></td>".
"<td>Facture ".$row["communeid"]." du ".french_date($row["datefacture"])." montant de ";
$output .= trispace($row["montantfcp"]);
$output .= " FCP (soit ".$row["montanteuro"]."€)</td><td><a href='createpdf.php?idfacture=".$row['idfacture']."&type=$type' target='_blank'>$pdf</a></td><td class='center'><a href=\"javascript:devalidate('$type','".$row["idfacture"]."')\"><img src=\"img/close.png\" alt=\"close\" height=\"32\" style=\"border:0px\"></a></td></tr>";
}
return $output;
}
function getcantinevalidate($client){
$mysqli = new mysqli(DBSERVER, DBUSER, DBPWD, DB);
$query = "SELECT * FROM `".DB."`.`factures_cantine` INNER JOIN `clients` ON `factures_cantine`.`idclient` = `clients`.`clientid` WHERE `factures_cantine`.`validation` = '0'$client";
$result = $mysqli->query($query);
while($row = $result->fetch_array(MYSQLI_ASSOC)){
$type='cantine';
$enfant_prenom = "<br/>".getEnfantPrenom($row['idfacture']);
$output .= "<tr><td>$type$enfant_prenom</td><td><a href='clients.php?edit=".$row["clientid"]."&hideerrors=1'>".$row["clientcivilite"]." ".strtoupper(htmlentities($row["clientnom"]))." ".strtoupper(htmlentities($row["clientprenom"]))." ".strtoupper(htmlentities($row["clientprenom2"]))."</a></td>".
"<td>Devis ".$row["communeid"]." du ".french_date($row["datefacture"])." montant de ";
$output .= trispace($row["montantfcp"]);
$output .= " FCP (soit ".$row["montanteuro"]."€)</td><td style=\"text-align:center\"><a href='createpdf.php?idfacture=".$row['idfacture']."&type=$type' target='_blank'><img src=\"img/pdf.png\" alt=\"pdf\" class=\"ico\"></a></td>".
"<td style=\"text-align:center\"><a href=\"javascript:validate('$type','".$row["idfacture"]."',true)\">".
"<img src=\"img/checked.png\" alt=\"checked\" height=\"32\" style=\"border:0px\"></a> / <a href=\"javascript:validate('$type','".$row["idfacture"]."',false)\">".
"<img src=\"img/close.png\" alt=\"close\" height=\"32\" style=\"border:0px\"></a></td></tr>";
}
return $output;
}
function getcantinelist($client){
$mysqli = new mysqli(DBSERVER, DBUSER, DBPWD, DB);
$query = "SELECT * FROM `".DB."`.`factures_cantine` INNER JOIN `clients` ON `factures_cantine`.`idclient` = `clients`.`clientid` WHERE `factures_cantine`.`validation` = '1' AND `acceptation` = '1' AND `reglement` = '0'$client";
$result = $mysqli->query($query);
while($row = $result->fetch_array(MYSQLI_ASSOC)){
if($row["duplicata"]=='0'){$pdf="<img src=\"img/opdf.png\" alt=\"original\" class=\"ico\">";}else{$pdf="<img src=\"img/dpdf.png\" alt=\"duplicata\" class=\"ico\">";}
$type='cantine';
$enfant_prenom = "<br/>".getEnfantPrenom($row['idfacture']);
$output .= "<tr><td>$type$enfant_prenom</td><td><a href='clients.php?edit=".$row["clientid"]."&hideerrors=1'>".$row["clientcivilite"]." ".strtoupper(htmlentities($row["clientnom"]))." ".strtoupper(htmlentities($row["clientprenom"]))." ".strtoupper(htmlentities($row["clientprenom2"]))."</td>".
"<td>Facture ".$row["communeid"]." du ".french_date($row["datefacture"])." montant de ";
$output .= trispace($row["montantfcp"]);
$output .= " FCP (soit ".$row["montanteuro"]."€)</a></td><td><a href='createpdf.php?idfacture=".$row['idfacture']."&type=$type' target='_blank'>$pdf</a></td>".
"<td class='center'><a href=\"javascript:devalidate('$type','".$row["idfacture"]."')\"><img src=\"img/close.png\" alt=\"close\" height=\"32\" style=\"border:0px\"></a></td></tr>";
}
return $output;
}
function getEnfantPrenom($idfacture){
$mysqli = new mysqli(DBSERVER, DBUSER, DBPWD, DB);
$query = "SELECT `enfants`.`prenom` FROM `factures_cantine_details` INNER JOIN `enfants` ".
" ON `factures_cantine_details`.`idenfant`=`enfants`.`enfantid` WHERE `factures_cantine_details`.`idfacture`='$idfacture'";
$result = $mysqli->query($query);
$row = $result->fetch_array(MYSQLI_ASSOC);
$output = $row["prenom"];
$mysqli->close();
return $output;
}
?>