Added checks in Product::deleteAction()

This commit is contained in:
Frank Schubert
2024-02-21 16:00:41 +01:00
parent b833c57a98
commit db240354a4
2 changed files with 26 additions and 2 deletions

View File

@@ -154,7 +154,7 @@ class ContractModel {
return null;
}
public static function count($filter) {
public static function countActive($filter) {
$db = FronkDB::singleton();
$where = self::getSqlFilter($filter);
@@ -215,6 +215,30 @@ class ContractModel {
return $items;
}
public static function count($filter) {
$db = FronkDB::singleton();
$where = self::getSqlFilter($filter);
$sql = "SELECT COUNT(*) as cnt FROM (
SELECT Contract.* FROM Contract
LEFT JOIN Address ON (Contract.owner_id = Address.id)
LEFT JOIN OrderProduct ON (Contract.orderproduct_id = OrderProduct.id)
LEFT JOIN `Order` ON (OrderProduct.order_id = `Order`.id)
LEFT JOIN Product ON (Contract.product_id = Product.id)
WHERE $where
GROUP BY Contract.id
) contract";
mfLoghandler::singleton()->debug($sql);
$res = $db->query($sql);
if($db->num_rows($res)) {
$data = $db->fetch_object($res);
return $data->cnt;
}
return 0;
}
public static function search($filter, $limit = false) {
//var_dump($filter);exit;
$items = [];

View File

@@ -205,7 +205,7 @@ class OrderProductModel
if (array_key_exists("product_id", $filter)) {
$product_id = $filter['product_id'];
if (is_numeric($product_id)) {
$where .= " AND order_id=$product_id";
$where .= " AND product_id=$product_id";
}
}