File tree Expand file tree Collapse file tree 1 file changed +24
-4
lines changed Expand file tree Collapse file tree 1 file changed +24
-4
lines changed Original file line number Diff line number Diff line change @@ -2922,10 +2922,30 @@ function update084xto0850()
29222922 FROM `glpi_softwarelicenses` " ;
29232923
29242924 foreach ($ DB ->request ($ queryl ) as $ datal ) {
2925- if (
2926- ($ datal ['number ' ] >= 0 )
2927- && ($ datal ['number ' ] < Item_SoftwareLicense::countForLicense ($ datal ['id ' ], -1 , 'Computer ' ))
2928- ) {
2925+ if (!($ datal ['number ' ] >= 0 )) {
2926+ continue ;
2927+ }
2928+
2929+ $ count_for_license = $ DB ->request ([
2930+ 'FROM ' => 'glpi_computers_softwarelicenses ' ,
2931+ 'COUNT ' => 'cpt ' ,
2932+ 'INNER JOIN ' => [
2933+ 'glpi_computers ' => [
2934+ 'FKEY ' => [
2935+ 'glpi_computers ' => 'id ' ,
2936+ 'glpi_computers_softwarelicenses ' => 'computers_id '
2937+ ]
2938+ ]
2939+ ],
2940+ 'WHERE ' => [
2941+ 'glpi_computers_softwarelicenses.softwarelicenses_id ' => $ datal ['id ' ],
2942+ 'glpi_computers.is_deleted ' => 0 ,
2943+ 'glpi_computers.is_template ' => 0 ,
2944+ 'glpi_computers_softwarelicenses.is_deleted ' => 0
2945+ ]
2946+ ])->current ()['cpt ' ];
2947+
2948+ if ($ datal ['number ' ] < $ count_for_license ) {
29292949 $ queryl2 = "UPDATE `glpi_softwarelicenses`
29302950 SET `is_valid` = 0
29312951 WHERE `id` = ' " . $ datal ['id ' ] . "' " ;
You can’t perform that action at this time.
0 commit comments