Sfoglia il codice sorgente

[Administration] Formulaires : boutons "Sauvegarder et rester"

feature/rotating_product
Guillaume Bourgeois 6 mesi fa
parent
commit
01133b31ec
8 ha cambiato i file con 41 aggiunte e 22 eliminazioni
  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 Vedi File

@@ -81,6 +81,17 @@ class BackendController extends CommonController
{
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 Vedi File

@@ -102,7 +102,8 @@ class PointSaleController extends BackendController
$this->initPaymentMethodsByCreditFunctioning($pointSale);
$distributionModule->addPointSaleIncomingDistributions($pointSale);

return $this->redirect(['index']);
$this->setFlash('success', 'Point de vente créé.');
return $this->redirectAfterSave('point-sale', $pointSale->id);
} else {
return $this->render('create', array_merge($this->initForm(), [
'model' => $pointSale,
@@ -132,8 +133,7 @@ class PointSaleController extends BackendController
$distributionModule->addPointSaleIncomingDistributions($model);

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

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

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

@@ -140,7 +140,7 @@ class ProductController extends BackendController

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

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

@@ -188,7 +188,8 @@ class ProductController extends BackendController
$productModule->update($model);

$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 Vedi File

@@ -135,6 +135,7 @@ class UserController extends BackendController
$this->processLinkPointSale($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.");
return $this->redirectAfterSave('user', $userExist->id);
} else {
if ($model->load(\Yii::$app->request->post()) && $model->validate() && YII_ENV != 'demo') {

@@ -159,14 +160,13 @@ class UserController extends BackendController

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

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

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

}

public function actionView($id)

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

@@ -0,0 +1,11 @@
<?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 Vedi File

@@ -315,9 +315,9 @@ $featureChecker = FeatureModule::getInstance()->getChecker();
</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(); ?>
</div>

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

@@ -223,10 +223,9 @@ $taxRateModule = $this->getTaxRateModule();

<?= $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(); ?>


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

@@ -150,12 +150,9 @@ $distributionModule = DistributionModule::getInstance();
<?php /* $form->field($model, 'product_price_percent')
->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 class="col-md-4">
@@ -213,7 +210,7 @@ $distributionModule = DistributionModule::getInstance();

<?php if (
$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-heading">
<h3 class="panel-title">

Loading…
Annulla
Salva