@@ -82,14 +82,19 @@ class BackendController extends CommonController | |||
return $this->redirect(['dashboard/index']); | |||
} | |||
public function redirectAfterSave(string $baseRoute, int $id) | |||
public function redirectAfterSave(string $baseRoute, int $id, string $redirectUrl = null) | |||
{ | |||
$postParams = \Yii::$app->request->post(); | |||
if(isset($postParams['save-stay'])) { | |||
return $this->redirect([$baseRoute.'/update', 'id' => $id]); | |||
} | |||
else { | |||
return $this->redirect(['index']); | |||
if($redirectUrl) { | |||
return $this->redirect($redirectUrl); | |||
} | |||
else { | |||
return $this->redirect(['index']); | |||
} | |||
} | |||
} | |||
} |
@@ -323,6 +323,14 @@ class DistributionController extends BackendController | |||
$distributionJsonData['potential_revenues'] = Price::format($productModule->getProductDistributionPotentialRevenues($productsArray)); | |||
$distributionJsonData['potential_revenues_with_tax'] = Price::format($productModule->getProductDistributionPotentialRevenues($productsArray, true)); | |||
$distributionJsonData['potential_weight'] = number_format($productModule->getProductDistributionPotentialWeight($productsArray), 2); | |||
$distributionJsonData['user_create_href'] = \Yii::$app->urlManager->createUrl([ | |||
'user/create', | |||
'redirectUrl' => \Yii::$app->urlManager->createAbsoluteUrl([ | |||
'distribution/index', | |||
'date' => $distribution->date, | |||
'displayFormOrderCreate' => 1 | |||
]) | |||
]); | |||
return $distributionJsonData; | |||
} |
@@ -122,12 +122,13 @@ class UserController extends BackendController | |||
]); | |||
} | |||
public function actionCreate() | |||
public function actionCreate(string $redirectUrl = null) | |||
{ | |||
$userModule = $this->getUserModule(); | |||
$producerModule = $this->getProducerModule(); | |||
$producerCurrent = $this->getProducerCurrent(); | |||
$model = $userModule->instanciateUser(); | |||
$model->redirect_url = $redirectUrl; | |||
$posts = Yii::$app->request->post(); | |||
$userExist = false; | |||
@@ -165,7 +166,7 @@ class UserController extends BackendController | |||
$this->setFlash('success', 'Utilisateur créé.'); | |||
return $this->redirectAfterSave('user', $userCreate->id); | |||
return $this->redirectAfterSave('user', $userCreate->id, $model->redirect_url); | |||
} | |||
} | |||
@@ -5,6 +5,9 @@ use yii\helpers\Html; | |||
?> | |||
<div class="form-group form-actions"> | |||
<?php if(isset($form)): ?> | |||
<?= $form->field($model, 'redirect_url', ['options' => ['class' => 'field-redirect-url']])->hiddenInput() ?> | |||
<?php endif; ?> | |||
<?= 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']) ?> |
@@ -661,7 +661,7 @@ $this->setPageTitle('Distributions') ; | |||
<a v-if="producer && producer.credit && order.id_user > 0 && user.id_user == order.id_user" class="btn btn-xs btn-primary btn-credit" :href="baseUrl+'/user/credit?id='+user.id_user" v-for="user in users">{{ parseFloat(user.credit).toFixed(2).replace(/(\d)(?=(\d{3})+(?:\.\d+)?$)/g, "$1,")+' €' }}</a> | |||
<label class="control-label" for="select-id-user"> | |||
Utilisateur | |||
<a v-if="!order.id_user || order.id_user == 0" class="btn btn-default btn-xs" href="<?= Yii::$app->urlManager->createUrl('user/create'); ?>"> | |||
<a v-if="!order.id_user || order.id_user == 0" class="btn btn-default btn-xs" :href="distribution.user_create_href"> | |||
<span class="glyphicon glyphicon-plus"></span> | |||
Créer un utilisateur | |||
</a> |
@@ -151,6 +151,7 @@ $distributionModule = DistributionModule::getInstance(); | |||
->dropDownList( ProductPrice::percentValues(), [])->hint('Pourcentage appliqué aux prix de chaque produit pour cet utilisateur.');*/ ?> | |||
<?= $this->render('@backend/views/_include/form_actions.php',[ | |||
'form' => $form, | |||
'model' => $model, | |||
]); ?> | |||
</div> |
@@ -2008,67 +2008,71 @@ body.skin-black .content-wrapper .form-actions { | |||
body.skin-black .content-wrapper .form-actions a, body.skin-black .content-wrapper .form-actions button { | |||
margin-left: 10px; | |||
} | |||
/* line 497, ../sass/_adminlte.scss */ | |||
/* line 496, ../sass/_adminlte.scss */ | |||
body.skin-black .content-wrapper .form-actions .field-redirect-url { | |||
display: none; | |||
} | |||
/* line 501, ../sass/_adminlte.scss */ | |||
body.skin-black .content-wrapper .form-buttons { | |||
margin-top: 25px; | |||
text-align: right; | |||
} | |||
/* line 504, ../sass/_adminlte.scss */ | |||
/* line 508, ../sass/_adminlte.scss */ | |||
body.skin-black .main-footer a { | |||
color: #F39C12; | |||
} | |||
/* line 509, ../sass/_adminlte.scss */ | |||
/* line 513, ../sass/_adminlte.scss */ | |||
body.skin-black .gridview-pagesize { | |||
float: right; | |||
margin-bottom: 8px; | |||
} | |||
/* line 514, ../sass/_adminlte.scss */ | |||
/* line 518, ../sass/_adminlte.scss */ | |||
body.skin-black #yii-debug-toolbar { | |||
bottom: 64px; | |||
} | |||
/* line 519, ../sass/_adminlte.scss */ | |||
/* line 523, ../sass/_adminlte.scss */ | |||
body.login-page { | |||
background: none; | |||
background-color: white; | |||
} | |||
/* line 523, ../sass/_adminlte.scss */ | |||
/* line 527, ../sass/_adminlte.scss */ | |||
body.login-page .login-box .login-logo { | |||
text-align: center; | |||
font-family: 'worksans_bold'; | |||
} | |||
/* line 527, ../sass/_adminlte.scss */ | |||
/* line 531, ../sass/_adminlte.scss */ | |||
body.login-page .login-box .login-logo img { | |||
width: 150px; | |||
} | |||
/* line 533, ../sass/_adminlte.scss */ | |||
/* line 537, ../sass/_adminlte.scss */ | |||
body.login-page .login-box .login-box-body, | |||
body.login-page .login-box .login-box-body input#loginform-email, | |||
body.login-page .login-box .login-box-body input#loginform-password, | |||
body.login-page .login-box .login-box-body .btn-primary { | |||
font-size: 14px; | |||
} | |||
/* line 540, ../sass/_adminlte.scss */ | |||
/* line 544, ../sass/_adminlte.scss */ | |||
body.login-page .login-box .login-box-body .btn-primary { | |||
background-color: #F39C12; | |||
border-color: #F39C12; | |||
padding: 5px 10px; | |||
margin-bottom: 15px; | |||
} | |||
/* line 546, ../sass/_adminlte.scss */ | |||
/* line 550, ../sass/_adminlte.scss */ | |||
body.login-page .login-box .login-box-body .btn-primary:active { | |||
background-color: #f4a62a; | |||
border-color: #F39C12; | |||
} | |||
/* line 552, ../sass/_adminlte.scss */ | |||
/* line 556, ../sass/_adminlte.scss */ | |||
body.login-page .login-box .login-box-body a { | |||
color: #F39C12; | |||
} | |||
/* line 554, ../sass/_adminlte.scss */ | |||
/* line 558, ../sass/_adminlte.scss */ | |||
body.login-page .login-box .login-box-body a:hover { | |||
color: #f4a62a; | |||
} | |||
/* line 559, ../sass/_adminlte.scss */ | |||
/* line 563, ../sass/_adminlte.scss */ | |||
body.login-page .login-box .login-box-body .checkbox label input { | |||
position: relative; | |||
top: 0px; |
@@ -135,7 +135,7 @@ if($(selector).length) { | |||
+ ('0' + (this.date.getMonth() + 1)).slice(-2) + '/' | |||
+ this.date.getFullYear(); | |||
} | |||
this.init(); | |||
this.init(false, true); | |||
this.loading = false; | |||
}, | |||
methods: { | |||
@@ -157,7 +157,7 @@ if($(selector).length) { | |||
&& today.getMonth() == this.date.getMonth() | |||
&& today.getDay() == this.date.getDay(); | |||
}, | |||
init: function (idActivePointSale) { | |||
init: function (idActivePointSale, displayFormOrderCreate) { | |||
var app = this; | |||
this.showLoading = true; | |||
@@ -288,6 +288,10 @@ if($(selector).length) { | |||
highlight: highlightStyle, | |||
dates: app.date | |||
}); | |||
if(displayFormOrderCreate && searchParams.has('displayFormOrderCreate')) { | |||
app.openModalFormOrderCreate(); | |||
} | |||
}); | |||
}, | |||
initCountActiveProducts: function () { |
@@ -492,6 +492,10 @@ body.skin-black { | |||
a, button { | |||
margin-left: 10px; | |||
} | |||
.field-redirect-url { | |||
display: none; | |||
} | |||
} | |||
.form-buttons { |
@@ -47,6 +47,8 @@ class ActiveRecordCommon extends \yii\db\ActiveRecord | |||
const SEARCH_ONE = 'one'; | |||
const SEARCH_COUNT = 'count'; | |||
public ?string $redirect_url = ''; | |||
public function populateFieldObject($fieldIdentifier, $fieldObject, $object) | |||
{ | |||
$this->{$fieldIdentifier} = $object->id; |
@@ -118,7 +118,7 @@ class User extends ActiveRecordCommon implements IdentityInterface | |||
['password_old', 'verifyPasswordOld'], | |||
['password_new', 'verifyPasswordNew'], | |||
['password_new_confirm', 'verifyPasswordNewConfirm'], | |||
[['date_last_connection', 'password_old', 'password_new', 'password_new_confirm', 'password_hash', 'points_sale', 'product_price_percent', 'user_groups'], 'safe'], | |||
[['date_last_connection', 'password_old', 'password_new', 'password_new_confirm', 'password_hash', 'points_sale', 'product_price_percent', 'user_groups', 'redirect_url'], 'safe'], | |||
]; | |||
} | |||