fixed createWorkordersFromPreorders to add statusflag filter
This commit is contained in:
@@ -646,6 +646,21 @@ class PreorderModel
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($filter['preorder_status_flags_all']) && is_array($filter['preorder_status_flags_all'])) {
|
||||
$sanitized_flags = array_map('intval', $filter['preorder_status_flags_all']);
|
||||
$flags_list = implode(',', $sanitized_flags);
|
||||
$flags_count = count($sanitized_flags);
|
||||
$dbName = FRONKDB_DBNAME;
|
||||
|
||||
$where .= " AND tt_preorder.id IN (
|
||||
SELECT psv.preorder_id
|
||||
FROM `{$dbName}`.PreorderStatusflagValue psv
|
||||
WHERE psv.flag_id IN ({$flags_list}) AND psv.value = 1
|
||||
GROUP BY psv.preorder_id
|
||||
HAVING COUNT(DISTINCT psv.flag_id) = {$flags_count}
|
||||
)";
|
||||
}
|
||||
|
||||
if (array_key_exists("preorder_status_flags_disabled", $filter)) {
|
||||
$preorder_status_flags_disabled = $filter['preorder_status_flags_disabled'];
|
||||
if (is_array($preorder_status_flags_disabled) && count($preorder_status_flags_disabled)) {
|
||||
|
||||
@@ -85,7 +85,7 @@ class RMLWorkorderAdminController extends TTCrud
|
||||
}
|
||||
|
||||
private function createWorkordersFromPreorders() {
|
||||
$newPreorders = PreorderModel::searchActive(['status_code' => 220]);
|
||||
$newPreorders = PreorderModel::searchActive(['status_code' => 220, 'preorder_status_flags_all' => [3,5]]);
|
||||
if (empty($newPreorders)) return;
|
||||
|
||||
foreach ($newPreorders as $preorder) {
|
||||
|
||||
Reference in New Issue
Block a user