public static function GetLastFileNameByDealID($deal_id) { $res = ""; $maxdata = 0; $maxfid = 0; $arIDs = CArkaCrm::GetSentFilesIDs($deal_id); foreach ($arIDs as $fid) { $dat = CArkaCrm::GetFileDateByID($fid); if ($dat > $maxdata) { $maxdata = $dat; $maxfid = $fid; } } if ($maxfid != 0) { $res = CArkaCrm::GetFileNameByID($maxfid); } return $res; }