Révision 7c20505e plugins/anet_epacks/front/plugin_anet_epacks.generate_odt_revendeur2.form.php
plugins/anet_epacks/front/plugin_anet_epacks.generate_odt_revendeur2.form.php | ||
---|---|---|
21 | 21 |
global $DB; |
22 | 22 |
|
23 | 23 |
//Un pack non attribué |
24 |
$query="SELECT * FROM glpi_plugin_anet_epacks WHERE FK_clientderyxeo='0' AND creation_date='0000-00-00' AND code LIKE 'ENR09%' LIMIT 1;";
|
|
24 |
$query="SELECT * FROM glpi_plugin_anet_epacks WHERE FK_clientderyxeo='0' AND creation_date='0000-00-00' AND code LIKE 'RVD11%' LIMIT 1;";
|
|
25 | 25 |
//$DB->query($query) or die($DB->error()); |
26 | 26 |
$result = $DB->query($query); |
27 | 27 |
$data=$DB->fetch_array($result); |
28 | 28 |
|
29 | 29 |
if($data['code'] == "") { |
30 | 30 |
print "Erreur, il n'y a plus de pack disponible ... "; |
31 |
print "On vient d'en créer un nouveau, actualisez la page pour l'utiliser ..."; |
|
32 |
$nb_packs = 1; |
|
33 |
$prefix = "RVD11-01-"; |
|
34 |
for($i = 0; $i < $nb_packs; $i++) { |
|
35 |
srand(); |
|
36 |
$code=$prefix . rand(1000,9999) . "-" . chr(rand(65,90)) . chr(rand(65,90)) . chr(rand(65,90)) . chr(rand(65,90)) . "-" . rand(1000,9999); |
|
37 |
$password=rand(1000,9999) . "-" . rand(1000,9999); |
|
38 |
$query="INSERT into glpi_plugin_anet_epacks(creation_date,expiration_date,code,password) values( '0000-00-00' ,'2011-12-31','$code','$password');"; |
|
39 |
print $query; |
|
40 |
$DB->query($query);// or die($DB->error()); |
|
41 |
} |
|
31 | 42 |
exit; |
32 |
}
|
|
43 |
} |
|
33 | 44 |
|
34 | 45 |
$odf->setVars('code', $data['code']); |
35 | 46 |
$odf->setVars('password', $data['password']); |
Formats disponibles : Unified diff