|
|
@@ -186,33 +186,26 @@ class ProducerAdminController extends BackendController |
|
|
|
$productsArray = Product::searchAll([ |
|
|
|
'id_producer' => $idProducer |
|
|
|
]) ; |
|
|
|
|
|
|
|
$connection = Yii::$app->getDb(); |
|
|
|
|
|
|
|
foreach($productsArray as $product) { |
|
|
|
$product->price = $product->price / (1 + $product->taxRate->value) ; |
|
|
|
$product->price = round($product->price / (1 + $product->taxRate->value), 2) ; |
|
|
|
$product->save() ; |
|
|
|
|
|
|
|
$command = $connection->createCommand(" |
|
|
|
UPDATE `product_order` |
|
|
|
SET price = ROUND(price / (1 + :tax_value), 2) |
|
|
|
WHERE id_product = :id_product", |
|
|
|
[ |
|
|
|
':id_product' => $product->id, |
|
|
|
':tax_value' => $product->taxRate->value |
|
|
|
]); |
|
|
|
|
|
|
|
$result = $command->query(); |
|
|
|
} |
|
|
|
|
|
|
|
// product_order |
|
|
|
$ordersArray = Order::searchAll([ |
|
|
|
'distribution.id_producer' => $idProducer |
|
|
|
]) ; |
|
|
|
foreach($ordersArray as $order) { |
|
|
|
foreach($order->productOrder as $productOrder) { |
|
|
|
$productOrder->price = $productOrder->price / (1 + $productOrder->taxRate->value) ; |
|
|
|
$productOrder->save() ; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// product_subscription |
|
|
|
$subscriptionsArray = Subscription::searchAll([ |
|
|
|
'subscription.id_producer' => $idProducer |
|
|
|
]) ; |
|
|
|
foreach($subscriptionsArray as $subscription) { |
|
|
|
foreach($subscription->productSubscription as $productSubscription) { |
|
|
|
$productSubscription->price = $productSubscription->price / (1 + $productSubscription->taxRate->value) ; |
|
|
|
$productSubscription->save() ; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
echo 'ok' ; |
|
|
|
} |
|
|
|
|
|
|
|
/** |