Browse Source

[Administration] Formulaires : boutons "Sauvegarder et rester"

feature/rotating_product
Guillaume Bourgeois 6 months ago
parent
commit
01133b31ec
8 changed files with 41 additions and 22 deletions
  1. +11
    -0
      backend/controllers/BackendController.php
  2. +3
    -3
      backend/controllers/PointSaleController.php
  3. +3
    -2
      backend/controllers/ProductController.php
  4. +2
    -2
      backend/controllers/UserController.php
  5. +11
    -0
      backend/views/_include/form_actions.php
  6. +4
    -4
      backend/views/point-sale/_form.php
  7. +3
    -4
      backend/views/product/_form.php
  8. +4
    -7
      backend/views/user/_form.php

+ 11
- 0
backend/controllers/BackendController.php View File

{ {
return $this->redirect(['dashboard/index']); return $this->redirect(['dashboard/index']);
} }

public function redirectAfterSave(string $baseRoute, int $id)
{
$postParams = \Yii::$app->request->post();
if(isset($postParams['save-stay'])) {
return $this->redirect([$baseRoute.'/update', 'id' => $id]);
}
else {
return $this->redirect(['index']);
}
}
} }


?> ?>

+ 3
- 3
backend/controllers/PointSaleController.php View File

$this->initPaymentMethodsByCreditFunctioning($pointSale); $this->initPaymentMethodsByCreditFunctioning($pointSale);
$distributionModule->addPointSaleIncomingDistributions($pointSale); $distributionModule->addPointSaleIncomingDistributions($pointSale);


return $this->redirect(['index']);
$this->setFlash('success', 'Point de vente créé.');
return $this->redirectAfterSave('point-sale', $pointSale->id);
} else { } else {
return $this->render('create', array_merge($this->initForm(), [ return $this->render('create', array_merge($this->initForm(), [
'model' => $pointSale, 'model' => $pointSale,
$distributionModule->addPointSaleIncomingDistributions($model); $distributionModule->addPointSaleIncomingDistributions($model);


$this->setFlash('success', 'Point de vente modifié.'); $this->setFlash('success', 'Point de vente modifié.');

return $this->redirect(['index']);
return $this->redirectAfterSave('point-sale', $model->id);
} else { } else {
return $this->render('update', array_merge($this->initForm($id), [ return $this->render('update', array_merge($this->initForm($id), [
'model' => $model, 'model' => $model,

+ 3
- 2
backend/controllers/ProductController.php View File



$this->setFlash('success', 'Produit <strong>' . Html::encode($model->name) . '</strong> ajouté'); $this->setFlash('success', 'Produit <strong>' . Html::encode($model->name) . '</strong> ajouté');


return $this->redirect(['index']);
return $this->redirectAfterSave('product', $model->id);
} }
} }


$productModule->update($model); $productModule->update($model);


$this->setFlash('success', 'Produit <strong>' . Html::encode($model->name) . '</strong> modifié'); $this->setFlash('success', 'Produit <strong>' . Html::encode($model->name) . '</strong> modifié');
return $this->redirect(['index']);

return $this->redirectAfterSave('product', $model->id);
} }
} }



+ 2
- 2
backend/controllers/UserController.php View File

$this->processLinkPointSale($userExist); $this->processLinkPointSale($userExist);
$this->processLinkUserGroup($userExist); $this->processLinkUserGroup($userExist);
$this->setFlash('success', "L'utilisateur que vous souhaitez créer possède déjà un compte sur la plateforme. Il vient d'être lié à votre établissement."); $this->setFlash('success', "L'utilisateur que vous souhaitez créer possède déjà un compte sur la plateforme. Il vient d'être lié à votre établissement.");
return $this->redirectAfterSave('user', $userExist->id);
} else { } else {
if ($model->load(\Yii::$app->request->post()) && $model->validate() && YII_ENV != 'demo') { if ($model->load(\Yii::$app->request->post()) && $model->validate() && YII_ENV != 'demo') {




$this->setFlash('success', 'Utilisateur créé.'); $this->setFlash('success', 'Utilisateur créé.');


return $this->refresh();
return $this->redirectAfterSave('user', $userCreate->id);
} }
} }


return $this->render('create', array_merge($this->initForm($model), [ return $this->render('create', array_merge($this->initForm($model), [
'model' => $model, 'model' => $model,
])); ]));

} }


public function actionView($id) public function actionView($id)

+ 11
- 0
backend/views/_include/form_actions.php View File

<?php

use yii\helpers\Html;

?>

<div class="form-group form-actions">
<?= Html::a('Retour', ['index'], ['class' => 'btn btn-default']) ?>
<?= Html::submitButton($model->isNewRecord ? 'Créer' : 'Modifier', ['class' => 'btn btn-primary', 'name' => 'save']) ?>
<?= Html::submitButton($model->isNewRecord ? 'Créer et rester' : 'Modifier et rester', ['class' => 'btn btn-primary', 'name' => 'save-stay']) ?>
</div>

+ 4
- 4
backend/views/point-sale/_form.php View File

</div> </div>
<div class="clr"></div> <div class="clr"></div>


<div class="form-group form-actions">
<?= Html::a('Retour', ['point-sale/index'], ['class' => 'btn btn-default']) ?>
<?= Html::submitButton($model->isNewRecord ? 'Créer' : 'Modifier', ['class' => 'btn btn-primary']) ?>
</div>
<?= $this->render('@backend/views/_include/form_actions.php',[
'model' => $model,
]); ?>
<?php ActiveForm::end(); ?> <?php ActiveForm::end(); ?>
</div> </div>

+ 3
- 4
backend/views/product/_form.php View File



<?= $form->field($model, 'id_producer')->hiddenInput()->label('') ?> <?= $form->field($model, 'id_producer')->hiddenInput()->label('') ?>


<div class="form-group form-actions">
<?= Html::a('Retour', ['product/index'], ['class' => 'btn btn-default']) ?>
<?= Html::submitButton($model->isNewRecord ? 'Créer' : 'Modifier', ['class' => 'btn btn-primary']) ?>
</div>
<?= $this->render('@backend/views/_include/form_actions.php',[
'model' => $model,
]); ?>


<?php ActiveForm::end(); ?> <?php ActiveForm::end(); ?>



+ 4
- 7
backend/views/user/_form.php View File

<?php /* $form->field($model, 'product_price_percent') <?php /* $form->field($model, 'product_price_percent')
->dropDownList( ProductPrice::percentValues(), [])->hint('Pourcentage appliqué aux prix de chaque produit pour cet utilisateur.');*/ ?> ->dropDownList( ProductPrice::percentValues(), [])->hint('Pourcentage appliqué aux prix de chaque produit pour cet utilisateur.');*/ ?>


<div class="form-group form-actions">
<?= Html::a('Retour', ['user/index'], ['class' => 'btn btn-default']) ?>
<?= Html::submitButton($model->isNewRecord ? 'Créer' : 'Modifier', ['class' => 'btn btn-primary']) ?>
</div>


<?= $this->render('@backend/views/_include/form_actions.php',[
'model' => $model,
]); ?>
</div> </div>


<div class="col-md-4"> <div class="col-md-4">


<?php if ( <?php if (
$distributionModule->getExportManager()->isEnabled(ExportManager::SHOPPING_CART_LABELS_PDF) $distributionModule->getExportManager()->isEnabled(ExportManager::SHOPPING_CART_LABELS_PDF)
|| $producerModule->getSolver()->getConfig('option_export_evoliz')): ?>
|| $producerModule->getSolver()->getConfig('option_export_evoliz')): ?>
<div class="panel panel-default"> <div class="panel panel-default">
<div class="panel-heading"> <div class="panel-heading">
<h3 class="panel-title"> <h3 class="panel-title">

Loading…
Cancel
Save