diff --git a/retailcrm/lib/RetailcrmReferences.php b/retailcrm/lib/RetailcrmReferences.php index c4be561..bb1b7c6 100644 --- a/retailcrm/lib/RetailcrmReferences.php +++ b/retailcrm/lib/RetailcrmReferences.php @@ -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;