Update positions after delete

This commit is contained in:
Abhishek Kumar
2024-02-09 17:28:57 +05:30
parent 772f639751
commit 491e92d295
2 changed files with 12 additions and 2 deletions

View File

@@ -12,7 +12,7 @@
<input type="checkbox" class="bulk-service-products-status">
</th>
<th class="col-sm-1">
<span>{l s='ID Product'}</span>
<span>{l s='ID'}</span>
</th>
<th class="col-sm-2">
<span>{l s='Name'}</span>

View File

@@ -59,10 +59,20 @@ class RoomTypeServiceProduct extends ObjectModel
$where .= ' AND `id_element` = '.(int) $idElement;
}
return Db::getInstance()->delete(
$result = Db::getInstance()->delete(
'htl_room_type_service_product',
$where
);
// Update positions
Db::getInstance()->execute('SET @i = -1', false);
$result &= Db::getInstance()->execute(
'UPDATE `'._DB_PREFIX_.'htl_room_type_service_product`
SET `position` = @i:=@i+1
ORDER BY `position` ASC'
);
return $result;
}
public function addRoomProductLink($idProduct, $values, $elementType)