" . $mid . " ORDER BY `Message_ID` ASC" . $limit; $log .= $items . PHP_EOL; $items = ( array ) $nc_core->db->get_results( $items, ARRAY_A ); if( !empty( $items ) ){ foreach( ( array ) $items as $item ){ if( $item['percent'] > 0 ){ continue; } $mid = $item['Message_ID']; $PriceMin = $item['PriceMinimum'] ?: $item['Price']; $PriceNew = $percent ? str_replace( ',', '.', ( ( $PriceMin / 100 ) * ( 100 + $percent ) ) ) : $PriceMin; $nc_core->db->query( "UPDATE `Message284` SET `Price` = '" . $PriceNew . "', `PriceMinimum` = '" . $PriceMin . "' WHERE `Message_ID` = " . $mid ); } $count_items = count( $items ); $counts = $counts + $count_items; if( $count_items == 1000 ){ $counts = imp_update_percents( $percent, $where, $mid, $counts ); } } return $counts; } if( md5( $f_brand_percent ) != md5( $brand_percent_hav['brand_percent'] ) ){ foreach( ( array ) $brand_percent_save as $brand => $percent ){ $not_update_brands[] = $brand; $old_percent = $brand_percent_old[ $brand ] ?: 0; if( $old_percent != $percent ){ $update_brands[ $brand ] = $percent; } unset( $brand_percent_old[ $brand ] ); } foreach( ( array ) $brand_percent_old as $brand => $percent ){ $update_brands[ $brand ] = $price_percent; } } else { $not_update_brands = array_keys( $brand_percent_save ); if( $all_update == 1 ){ $update_brands = $brand_percent_save; } } if( !empty( $update_brands ) ){ foreach( ( array ) $update_brands as $brand => $percent ){ $brand_where = $wheres . " AND `Vendor` = '" . $brand . "'"; $counts = imp_update_percents( $percent, $brand_where ); $log .= $brand . " - обновили: " . $counts . PHP_EOL; } } if( $all_update == 1 || $f_price_percent != $brand_percent_hav['price_percent'] ){ foreach( $not_update_brands as $ind => $brand ){ $not_update_brands[ $ind ] = "'" . $brand . "'"; } $wheres_all .= $wheres . " AND `Vendor` NOT IN (" . implode( ',', $not_update_brands ) . ")"; $counts = imp_update_percents( $f_price_percent, $wheres_all ); $log .= "Обновили общих: " . $counts . PHP_EOL; } $log .= "--------------------------------------------" . PHP_EOL; // file_put_contents('/var/www/tehno/data/www/techno-expert-project.ru/brand_percent_log-' . date('d-m-Y') . '.txt', $log, FILE_APPEND | LOCK_EX); } ?> db->get_results( "SELECT * FROM `Message284` WHERE `ImportSourceID` = '" . $f_import_id . "' AND `noUPerce` != 1 AND `IsSale` != 1", ARRAY_A ); } if( $f_sale_npo != 1 ){ $items = ( array ) $nc_core->db->get_results( "SELECT * FROM `Message284` WHERE `ImportSourceID` = '" . $f_import_id . "' AND `noUPerce` != 1", ARRAY_A ); } $log = "= " . count($items) . PHP_EOL; file_put_contents('/var/www/tehno/data/www/techno-expert-project.ru/test_log.txt', $log, FILE_APPEND | LOCK_EX); foreach( ( array ) $items as $item ){ $add_price_percent = $brand_percent_save[ $item['Vendor'] ] ?: $price_percent; $PriceMin = $item['PriceMinimum'] ?: $item['Price']; $PriceNew = $add_price_percent ? str_replace( ',', '.', ( ( $PriceMin / 100 ) * ( 100 + $add_price_percent ) ) ) : $PriceMin; if( $item['Vendor'] == 'GRILL MASTER' ){ $log = "UPDATE `Message284` SET `Price` = '" . $PriceNew . "', `PriceMinimum` = '" . $PriceMin . "' WHERE `Message_ID` = " . $item['Message_ID'] . PHP_EOL; file_put_contents('/var/www/tehno/data/www/techno-expert-project.ru/test_log.txt', $log, FILE_APPEND | LOCK_EX); } // $nc_core->db->query( "UPDATE `Message284` SET `Price` = '" . $PriceNew . "', `PriceMinimum` = '" . $PriceMin . "' WHERE `Message_ID` = " . $item['Message_ID'] ); } } } */ ?>