|
|
@@ -174,13 +174,19 @@ class ProductController extends BackendController |
|
|
|
* @param integer $id |
|
|
|
* @return mixed |
|
|
|
*/ |
|
|
|
public function actionDelete($id) |
|
|
|
public function actionDelete($id, $confirm = false) |
|
|
|
{ |
|
|
|
$model = $this->findModel($id) ; |
|
|
|
$model->delete(); |
|
|
|
ProductDistribution::deleteAll(['id_product' => $id]) ; |
|
|
|
$product = $this->findModel($id) ; |
|
|
|
|
|
|
|
Yii::$app->getSession()->setFlash('success', 'Produit <strong>'.Html::encode($model->name).'</strong> supprimé'); |
|
|
|
if($confirm) { |
|
|
|
$product->delete(); |
|
|
|
ProductDistribution::deleteAll(['id_product' => $id]) ; |
|
|
|
Yii::$app->getSession()->setFlash('success', 'Produit <strong>'.Html::encode($product->name).'</strong> supprimé'); |
|
|
|
} |
|
|
|
else { |
|
|
|
Yii::$app->getSession()->setFlash('info', 'Souhaitez-vous vraiment supprimer le produit <strong>'.Html::encode($product->name).'</strong> ? ' |
|
|
|
. Html::a('Oui',['product/delete','id' => $id, 'confirm' => 1], ['class' => 'btn btn-default']).' '.Html::a('Non', ['product/index'], ['class' => 'btn btn-default'])); |
|
|
|
} |
|
|
|
|
|
|
|
return $this->redirect(['index']); |
|
|
|
} |