Sorting CRM statuses using 'ordering'

This commit is contained in:
gleemand 2021-05-31 12:09:15 +03:00 committed by GitHub
parent 4fb5030c23
commit df8f030c84
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -286,13 +286,22 @@ class RetailcrmReferences
$crmStatusTypes[] = array(
'id_option' => '',
'name' => '',
'ordering' => '',
);
foreach ($request->statuses as $sType) {
$crmStatusTypes[] = array(
'id_option' => $sType['code'],
'name' => $sType['name']
'name' => $sType['name'],
'ordering' => $sType['ordering'],
);
}
usort($crmStatusTypes, function ($a, $b) {
if ($a['ordering'] == $b['ordering']) {
return 0;
} else {
return ($a['ordering'] < $b['ordering'] ? -1 : 1);
}
});
}
return $crmStatusTypes;