|
|
|
|
|
|
|
|
use common\models\Producer; |
|
|
use common\models\Producer; |
|
|
use yii\data\ActiveDataProvider; |
|
|
use yii\data\ActiveDataProvider; |
|
|
use common\models\Invoice; |
|
|
use common\models\Invoice; |
|
|
|
|
|
use common\models\Product; |
|
|
|
|
|
use common\models\Order; |
|
|
|
|
|
use common\models\Subscription; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* UserController implements the CRUD actions for User model. |
|
|
* UserController implements the CRUD actions for User model. |
|
|
|
|
|
|
|
|
'dataProviderInvoice' => $dataProviderInvoice, |
|
|
'dataProviderInvoice' => $dataProviderInvoice, |
|
|
]); |
|
|
]); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function actionProducerInstallTaxUpdatePrices($idProducer, $idTaxRate) |
|
|
|
|
|
{ |
|
|
|
|
|
$taxRate = TaxRate::searchOne([ |
|
|
|
|
|
'id' => $idTaxRate |
|
|
|
|
|
]) ; |
|
|
|
|
|
|
|
|
|
|
|
// product |
|
|
|
|
|
$productsArray = Product::searchAll([ |
|
|
|
|
|
'id_producer' => $idProducer |
|
|
|
|
|
]) ; |
|
|
|
|
|
|
|
|
|
|
|
foreach($productsArray as $product) { |
|
|
|
|
|
$product->price = $product->price / (1 + $taxRate->value) ; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// product_order |
|
|
|
|
|
$ordersArray = Order::searchAll([ |
|
|
|
|
|
'distribution.id_producer' => $idProducer |
|
|
|
|
|
]) ; |
|
|
|
|
|
foreach($ordersArray as $order) { |
|
|
|
|
|
foreach($order->productOrder as $productOrder) { |
|
|
|
|
|
$productOrder->price = $productOrder->price / (1 + $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 + $taxRate->value) ; |
|
|
|
|
|
$productSubscription->save() ; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* Recherche un établissement. |
|
|
* Recherche un établissement. |