IVT Contract Import WIP

This commit is contained in:
Frank Schubert
2023-11-02 16:05:40 +01:00
parent 90f65abd6f
commit e5f7b59ab4
14 changed files with 610 additions and 7 deletions

View File

@@ -24,6 +24,8 @@ class ContractModel {
public $finish_date_by;
public $cancel_date;
public $cancel_date_by;
public $imported_from;
public $imported_data;
public $note = null;
public $create_by = null;
@@ -152,13 +154,18 @@ class ContractModel {
$db = FronkDB::singleton();
$where = self::getSqlFilter($filter);
$sql = "SELECT COUNT(*) as cnt FROM Contract
$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";
AND (cancel_date IS NULL OR cancel_date > UNIX_TIMESTAMP())
GROUP BY Contract.id
) contract";
mfLoghandler::singleton()->debug($sql);
$res = $db->query($sql);
if($db->num_rows($res)) {
@@ -317,6 +324,20 @@ class ContractModel {
}
}
if(array_key_exists("imported_from", $filter)) {
$imported_from = FronkDB::singleton()->escape($filter["imported_from"]);
if($imported_from) {
$where .= " AND Contract.imported_from like '$imported_from'";
}
}
if(array_key_exists("imported_data", $filter)) {
$imported_data = FronkDB::singleton()->escape($filter["imported_data"]);
if($imported_data) {
$where .= " AND Contract.imported_data like '$imported_data'";
}
}
if(array_key_exists("add-where", $filter)) {
$where .= " ".$filter['add-where'];
}