Révision 8c2a3d1e plugins/anet_epacks/front/plugin_anet_epacks.verif_contract_epack.php
plugins/anet_epacks/front/plugin_anet_epacks.verif_contract_epack.php | ||
---|---|---|
25 | 25 |
$automatique = ""; |
26 | 26 |
$manuel = ""; |
27 | 27 |
|
28 |
$query = "SELECT FK_enduser,code FROM glpi_plugin_anet_epacks WHERE FK_contract='0' AND FK_enduser>'0'";
|
|
28 |
$query = "SELECT FK_enduser,code FROM glpi_plugin_anet_epacks WHERE (FK_contract='0' OR FK_contract='-1') AND FK_enduser>'0'";
|
|
29 | 29 |
$result = $DB->query($query); |
30 | 30 |
//print $query; |
31 | 31 |
while($data=$DB->fetch_array($result)) { |
... | ... | |
37 | 37 |
$data1=$DB->fetch_array($result1); |
38 | 38 |
$clientfinal = $data1['completename']; |
39 | 39 |
|
40 |
|
|
41 |
$query2 = "SELECT * FROM glpi_contracts WHERE FK_entities='" . $enduser . "'"; |
|
40 |
//order by pour prendre le dernier contrat ... si on recolle automatiquement et qu'il y a un ancien contrat il faut recoller avecle plus recent |
|
41 |
$query2 = "SELECT *,(TO_DAYS(begin_date) + (duration*30)) AS endDay FROM glpi_contracts WHERE FK_entities='" . $enduser . "' AND (TO_DAYS(begin_date) + (duration*30)) > TO_DAYS(NOW()) AND deleted='0' ORDER BY begin_date DESC LIMIT 1"; |
|
42 |
//print "<pre>$query2</pre>"; |
|
42 | 43 |
$result2 = $DB->query($query2); |
43 | 44 |
$data2=$DB->fetch_array($result2); |
44 |
|
|
45 |
if(trim($data2['name'])) {
|
|
46 |
$query3 = "UPDATE glpi_plugin_anet_epacks SET FK_contract='" . $data2['ID'] . "' WHERE FK_enduser='$enduser' AND FK_contract='0'";
|
|
45 |
if(trim($data2['name']) != "") { |
|
46 |
$query3 = "UPDATE glpi_plugin_anet_epacks SET FK_contract='" . $data2['ID'] . "' WHERE FK_enduser='$enduser'";
|
|
47 |
//$query3 = "UPDATE glpi_plugin_anet_epacks SET FK_contract='-1' WHERE FK_enduser='$enduser'";
|
|
47 | 48 |
$automatique .= "<p>Recollement automatique pour $code -> $clientfinal -> nouvelle ref contrat: " . $data2['ID'] . "</p>"; |
49 |
//print $query3; |
|
48 | 50 |
$result3 = $DB->query($query3); |
49 | 51 |
$data3=$DB->fetch_array($result3); |
50 | 52 |
} |
51 | 53 |
else { |
52 |
$manuel .= "<tr><td>$code</td><td>$clientfinal</td><td>$enduser</td><td>" . $data2['ID'] . "</td></tr>\n"; |
|
54 |
if(is_array($data2)) { |
|
55 |
$manuel .= "<tr><td>$code</td><td>$clientfinal</td><td>$enduser</td><td>" . $data2['ID'] . "</td></tr>\n"; |
|
56 |
} |
|
53 | 57 |
} |
54 | 58 |
} |
55 | 59 |
|
Formats disponibles : Unified diff