0) { $PRICE += $multiplier; } } else if ($sign == '-') { if ($multiplier > 0) { $PRICE -= $multiplier; } } else if ($sign == '*') { if ($multiplier > 0) { $PRICE *= $multiplier; } } else if ($sign == '/') { if ($multiplier > 0) { $PRICE /= $multiplier; } } } $row['PRICE'] = $PRICE; return $row; } public static function convertToArticle( $value ) { if (is_array($value)) { $row = $value; // 1. Уберем префикс который разделен пробелом (если он есть) $words = explode(" ", $row['ARTICLE']); if (count($words) > 1) { array_shift($words); $row['ARTICLE'] = implode(" ", $words); } if( isset( $row['BRAND'] ) && isset( self::$importer_id ) ){ // 2. Уберем брендовый префикс (если он есть) self::$brand = $row['BRAND']; $prefix = ''; // запрос закешируем $prefix = ImportersPrefix::getDb()->cache( function ($db) { return ImportersPrefix::find()->where([ 'importer_id' => self::$importer_id, 'brand' => self::$brand ])->one(); }); if ($prefix) { $row['BRAND'] = str_replace($prefix, "", $row['BRAND']); } } return $row; } else { $words = explode( " ", $value ); if ( count( $words ) > 1) { array_shift( $words ); $value = implode( " ", $words ); } return $value; } } public static function convertToBrand($value) { $res = self::convertToEncode($value); $res = trim(strtoupper($res)); $res = str_replace("Ä", "A", str_replace("Ö", "O", str_replace("Ü", "U", str_replace("Ë", "E", str_replace("Ò", "O", $res))))); $res = str_replace(array('@', '#', '~', '"', "'", "?", "!"), '', $res); return $res; } public static function convertToTimestamp($value) { if ( self::$begin_of_the_day ){ $res = mktime(0,0,0,(int)substr($value,3,2),(int)substr($value,0,2),(int)substr($value,6,4)); } else { $res = mktime(23,59,59,(int)substr($value,3,2),(int)substr($value,0,2),(int)substr($value,6,4)); } return $res; } public static function convertToFloat( $value ) { if ($value == '') { $value = 0; } $value = trim(str_replace(",", ".", $value)); $value = preg_replace("/[^0-9.]+/", "", strtoupper($value)); if ($value == '') { return ''; } $value = round( (float)$value, self::$precision ); return $value; } }